argo-search 2.15.0 → 2.16.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 +1 -1
- package/README.es.md +27 -5
- package/README.ja.md +27 -5
- package/README.ko.md +27 -5
- package/README.md +68 -19
- package/README.zh.md +68 -19
- package/SKILL.md +7 -7
- package/assets/readme/counts.json +1 -1
- package/backends/domain_profiles.json +107 -6
- package/backends/engine_registry.yaml +15 -2
- package/backends/quota_profiles.json +13 -3
- package/bin/argo +3 -0
- package/config.yaml +16 -0
- package/docs/CHANGELOG.md +15 -0
- package/docs/ENGINE_CATALOG.md +11 -10
- package/docs/MCP_SETUP.md +9 -0
- package/docs/RELEASE_NOTES_v2.16.0.md +58 -0
- package/engines/specs/archive_org.yaml +1 -1
- package/engines/specs/carbon_intensity.yaml +1 -1
- package/engines/specs/crates.yaml +1 -1
- package/engines/specs/crossref.yaml +4 -2
- package/engines/specs/crt_sh.yaml +1 -1
- package/engines/specs/dblp.yaml +1 -1
- package/engines/specs/devto.yaml +1 -1
- package/engines/specs/docker_hub.yaml +1 -1
- package/engines/specs/europepmc.yaml +1 -1
- package/engines/specs/fxtwitter.yaml +1 -1
- package/engines/specs/gbfs_nyc.yaml +1 -1
- package/engines/specs/gleif.yaml +1 -1
- package/engines/specs/gov_regulations.yaml +1 -1
- package/engines/specs/hf_datasets.yaml +1 -1
- package/engines/specs/huggingface.yaml +1 -1
- package/engines/specs/keenable.yaml +7 -1
- package/engines/specs/linux_do.yaml +63 -0
- package/engines/specs/local_crossref.yaml +3 -1
- package/engines/specs/local_github.yaml +1 -1
- package/engines/specs/local_npm.yaml +6 -0
- package/engines/specs/local_openstreetmap.yaml +1 -1
- package/engines/specs/maven.yaml +1 -1
- package/engines/specs/mdn.yaml +1 -1
- package/engines/specs/musicbrainz.yaml +1 -1
- package/engines/specs/nasa_images.yaml +1 -1
- package/engines/specs/nhtsa_vpic.yaml +6 -3
- package/engines/specs/npm.yaml +1 -1
- package/engines/specs/nuget.yaml +1 -1
- package/engines/specs/nvd.yaml +1 -1
- package/engines/specs/openalex.yaml +4 -2
- package/engines/specs/openreview.yaml +1 -1
- package/engines/specs/polymarket.yaml +1 -1
- package/engines/specs/sec_edgar.yaml +1 -1
- package/engines/specs/steam.yaml +1 -1
- package/engines/specs/vam.yaml +1 -1
- package/engines/specs/wikidata.yaml +1 -1
- package/engines/specs/wikipedia.yaml +1 -1
- package/engines/specs/zhihu_hot_app.yaml +1 -1
- package/package.json +2 -1
- package/packages/dsh-plugin/dsh/client.js +14 -13
- package/packages/dsh-plugin/dsh/index.js +6 -0
- package/packages/dsh-plugin/dsh/runner.js +1 -1
- package/packages/dsh-plugin/dsh/workbench-client.js +796 -0
- package/packages/dsh-plugin/dsh/workbench-md.js +386 -0
- package/packages/dsh-plugin/dsh/workbench-suggestions.js +148 -0
- package/packages/dsh-plugin/dsh/workbench.js +966 -0
- package/packages/dsh-plugin/icon.svg +23 -0
- package/packages/dsh-plugin/package.json +3 -1
- package/packages/dsh-plugin/test/workbench.test.js +92 -0
- package/scripts/argo_paths.py +2 -2
- package/scripts/badcase_ledger.py +9 -0
- package/scripts/cache.py +1 -1
- package/scripts/circuit_breaker.py +16 -3
- package/scripts/config_cache.py +19 -7
- package/scripts/daemon.py +5 -0
- package/scripts/engine_dispatch.py +5 -2
- package/scripts/engine_env.py +13 -4
- package/scripts/engines_base.py +24 -3
- package/scripts/engines_builders_archive.py +4 -3
- package/scripts/engines_builders_batch11.py +2 -1
- package/scripts/engines_builders_batch13.py +4 -3
- package/scripts/engines_builders_batch14.py +2 -1
- package/scripts/engines_builders_batch15.py +2 -1
- package/scripts/engines_builders_batch9.py +2 -2
- package/scripts/engines_builders_cn.py +7 -7
- package/scripts/engines_builders_data.py +12 -11
- package/scripts/engines_builders_data_macro.py +5 -4
- package/scripts/engines_builders_dsh.py +2 -1
- package/scripts/engines_builders_feeds.py +34 -19
- package/scripts/engines_builders_finance.py +2 -1
- package/scripts/engines_builders_intl.py +3 -2
- package/scripts/engines_builders_media.py +59 -12
- package/scripts/engines_builders_science.py +8 -7
- package/scripts/engines_builders_skill.py +2 -1
- package/scripts/engines_builders_tech.py +3 -3
- package/scripts/engines_builders_weather.py +9 -4
- package/scripts/engines_http.py +50 -1
- package/scripts/engines_mcp.py +28 -6
- package/scripts/evidence_loop.py +15 -1
- package/scripts/extend_route_labels.py +6 -0
- package/scripts/fetch_jina.py +98 -0
- package/scripts/fetch_v3.py +52 -93
- package/scripts/image_vision/vision_probe +0 -0
- package/scripts/install.sh +2 -0
- package/scripts/matrix_search_eval.py +8 -10
- package/scripts/mcp_transport.py +10 -5
- package/scripts/numeric_verify.py +3 -2
- package/scripts/output_transparency.py +3 -0
- package/scripts/quota.py +30 -29
- package/scripts/recovery.py +19 -16
- package/scripts/recovery_runner.py +29 -10
- package/scripts/redskill/redskill_engine.py +2 -1
- package/scripts/route.py +8 -0
- package/scripts/route_combo.py +11 -2
- package/scripts/route_policy.py +1 -1
- package/scripts/search_attribution.py +20 -0
- package/scripts/search_entry.py +27 -0
- package/scripts/search_output.py +18 -7
- package/scripts/search_pipeline.py +3 -3
- package/scripts/semantic_evidence.py +20 -11
- package/scripts/serp_guard.py +13 -1
- package/scripts/settings_page.py +1 -0
- package/scripts/single_flight.py +1 -1
- package/scripts/social_engines/hackernews_engine.py +2 -1
- package/scripts/social_engines/reddit_engine.py +2 -1
- package/scripts/social_engines/zhihu_engine.py +2 -1
- package/scripts/source_audit.py +42 -7
- package/scripts/usage_log.py +24 -9
- package/scripts/watch.py +3 -3
- package/scripts/zhihu_quota.py +2 -1
- package/sub-skills/argo-wide-research/SKILL.md +7 -5
- package/sub-skills/ego-search/{SKILL.md → README.md} +15 -47
- package/sub-skills/ego-search/scripts/ego_search.py +13 -4
- package/sub-skills/js-run/{SKILL.md → README.md} +3 -20
- package/sub-skills/local-search/{SKILL.md → README.md} +3 -8
- package/sub-skills/local-search/engine_registry.py +32 -7
- package/sub-skills/local-seek/SKILL.md +20 -22
package/scripts/engines_mcp.py
CHANGED
|
@@ -44,6 +44,7 @@ import json
|
|
|
44
44
|
import re
|
|
45
45
|
import select
|
|
46
46
|
import subprocess
|
|
47
|
+
import time
|
|
47
48
|
import urllib.error
|
|
48
49
|
import urllib.request
|
|
49
50
|
from typing import Any
|
|
@@ -93,6 +94,21 @@ def _parse_jsonrpc_body(text: str) -> dict[str, Any] | None:
|
|
|
93
94
|
|
|
94
95
|
# ── Streamable HTTP 通道 ─────────────────────────────────────────────────────
|
|
95
96
|
|
|
97
|
+
def _client_info() -> dict[str, str]:
|
|
98
|
+
"""握手用的 clientInfo:版本读单源,不再手抄字面量。
|
|
99
|
+
|
|
100
|
+
此前这里写死 "2.14.1",v2.15.0 升版时没人改——而 release_check 的八处
|
|
101
|
+
机器声明扫描不含本文件,升版盲区就是这么来的。真源与 mcp_transport
|
|
102
|
+
同口径:argo_search.__version__(release_check 已把它列为声明之一)。
|
|
103
|
+
"""
|
|
104
|
+
try:
|
|
105
|
+
import argo_search
|
|
106
|
+
version = str(argo_search.__version__)
|
|
107
|
+
except Exception:
|
|
108
|
+
version = "unknown"
|
|
109
|
+
return {"name": "argo", "version": version}
|
|
110
|
+
|
|
111
|
+
|
|
96
112
|
class _HttpChannel:
|
|
97
113
|
"""Streamable HTTP JSON-RPC 通道(握手/回执/工具调用按 MCP 2025-06-18)。
|
|
98
114
|
|
|
@@ -142,7 +158,7 @@ class _HttpChannel:
|
|
|
142
158
|
self._request("initialize", {
|
|
143
159
|
"protocolVersion": _PROTOCOL_VERSION,
|
|
144
160
|
"capabilities": {},
|
|
145
|
-
"clientInfo":
|
|
161
|
+
"clientInfo": _client_info(),
|
|
146
162
|
})
|
|
147
163
|
self._request("notifications/initialized", notify=True)
|
|
148
164
|
|
|
@@ -182,12 +198,18 @@ class _StdioChannel:
|
|
|
182
198
|
self._proc.stdin.flush()
|
|
183
199
|
if notify:
|
|
184
200
|
return None
|
|
185
|
-
|
|
201
|
+
# 预算按墙钟而不是「未就绪的次数」:旧实现只在 select 超时未就绪时
|
|
202
|
+
# deadline -= 1.0,只要对端持续吐帧(日志通知、其它 id 的响应、空行、
|
|
203
|
+
# 解析失败的行)就永远不减,MCP 通知流可以把一次 tools/call 挂死到
|
|
204
|
+
# 线程被杀。截止期在这里唯一,任何读到的行都不得延长它。
|
|
205
|
+
deadline = time.monotonic() + max(0.0, float(self._timeout))
|
|
186
206
|
stream = self._proc.stdout
|
|
187
|
-
while
|
|
188
|
-
|
|
207
|
+
while True:
|
|
208
|
+
remaining = deadline - time.monotonic()
|
|
209
|
+
if remaining <= 0:
|
|
210
|
+
break
|
|
211
|
+
ready, _, _ = select.select([stream], [], [], min(remaining, 1.0))
|
|
189
212
|
if not ready:
|
|
190
|
-
deadline -= 1.0
|
|
191
213
|
continue
|
|
192
214
|
line = stream.readline()
|
|
193
215
|
if not line:
|
|
@@ -209,7 +231,7 @@ class _StdioChannel:
|
|
|
209
231
|
"params": {
|
|
210
232
|
"protocolVersion": _PROTOCOL_VERSION,
|
|
211
233
|
"capabilities": {},
|
|
212
|
-
"clientInfo":
|
|
234
|
+
"clientInfo": _client_info(),
|
|
213
235
|
},
|
|
214
236
|
}, notify=False)
|
|
215
237
|
self._next_id += 1
|
package/scripts/evidence_loop.py
CHANGED
|
@@ -45,6 +45,16 @@ def _log(message: str) -> None:
|
|
|
45
45
|
# timing.elapsed_ms 里只看到 1.2s。核验是「加分项」不是「必须项」:到点
|
|
46
46
|
# 未回来的 URL 进 pending(语义与 fetch 失败完全一致),已回来的照常回填。
|
|
47
47
|
# 默认 5s 高于典型核验 2.9s,只砍尾部;需要完整降级链时设 0。
|
|
48
|
+
#
|
|
49
|
+
# 2026-11-16:预算是够的,缺的是并发。实测 --verify 10 只能核到 2-4 条,
|
|
50
|
+
# 一开始以为是 5s 太短,把预算按 top_k 放大到 13.4s——受控 A/B(同批查询、
|
|
51
|
+
# 同一批 URL、每次独立证据缓存)显示核验 31→38 条(1.2x)却把耗时
|
|
52
|
+
# 25.0→42.2s(1.7x),每条核验成本 0.8→1.1s **上升 37%**,不划算,已回退。
|
|
53
|
+
# 真正的瓶颈是 max_workers=3:10 个 URL 排 3 个 worker,预算全花在排队上。
|
|
54
|
+
# 只把并发放到 6、预算维持 5s,三轮冷启动 A/B(每臂互不重叠的唯一 URL,
|
|
55
|
+
# 绕开证据缓存复用)实测:核验 15.0→23.0 条(1.5x)、耗时 25.0→24.5s
|
|
56
|
+
# (持平略降)、每条核验成本 1.67→1.06s(降 36%)。所以预算公式保持原样,
|
|
57
|
+
# 只放宽 worker 上限。
|
|
48
58
|
def _verify_budget_s() -> float:
|
|
49
59
|
try:
|
|
50
60
|
raw = os.environ.get("ARGO_VERIFY_BUDGET_S", "5") or "5"
|
|
@@ -557,10 +567,14 @@ def verify_results(results: list[dict[str, Any]],
|
|
|
557
567
|
if targets and budget_s > 0:
|
|
558
568
|
# 硬墙钟:到点就返回,未完成的 URL 进 pending,不 join 卡住的线程。
|
|
559
569
|
# 预算只约束「这次核验等多久」,不改单 URL 的降级链语义。
|
|
570
|
+
# worker 上限 6(原 3):核验是纯 I/O 等待,3 个 worker 装不下 10 个
|
|
571
|
+
# URL,预算全花在排队。实测同样 5s 预算下核验 15→23 条(1.5x)、
|
|
572
|
+
# 耗时持平(唯一 URL 三轮冷启动 A/B,数字以文件头记录为准)。
|
|
573
|
+
# 单 URL 自带 8s deadline,放宽 worker 不会放大最坏耗时。
|
|
560
574
|
from bounded_run import TaskError, run_bounded
|
|
561
575
|
finished, unfinished = run_bounded(
|
|
562
576
|
targets, _fetch_one, budget_s,
|
|
563
|
-
max_workers=min(len(targets),
|
|
577
|
+
max_workers=min(len(targets), 6))
|
|
564
578
|
for item, value in finished:
|
|
565
579
|
if isinstance(value, TaskError):
|
|
566
580
|
_log(f"verify fetch 任务异常 {item.get('url') or ''}: "
|
|
@@ -138,6 +138,12 @@ COLLISION_ANCHORS: list[tuple[str, str, str, str]] = [
|
|
|
138
138
|
# v2.10.2:学术检索正例
|
|
139
139
|
("科研数据集 开放数据 下载", "dataset_search", "academic", "v2.10.2"),
|
|
140
140
|
("google scholar 学术论文 期刊", "scholar_search", "academic", "v2.10.2"),
|
|
141
|
+
# 外部审计 2026-11-16:QDII/外管局额度类查询此前掉进 chinese_general 用
|
|
142
|
+
# 通用源打(fund_query/financial_news 词表均无这些词),而 eastmoney 点名
|
|
143
|
+
# 实测 1.0s 5 条相关。额度/限额数据问法归 fund_query;法规解读问法让位
|
|
144
|
+
# financial_news(fund_query 的 QDII 款带同款 unless)。
|
|
145
|
+
("QDII 额度 外管局 最新限额", "fund_query", "factual", "audit-2026-11-16"),
|
|
146
|
+
("QDII 管理办法 解读", "financial_news", "factual", "audit-2026-11-16"),
|
|
141
147
|
]
|
|
142
148
|
|
|
143
149
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""fetch_jina.py — r.jina.ai 阅读器层(fetch_v3 第一级C)。
|
|
3
|
+
|
|
4
|
+
从 fetch_v3.py 拆出(2026-11-17):与 fetch_jsrun、fetch_render_tinyfish
|
|
5
|
+
同构,独立成模块让 fetch_v3 行数回到祖父文件上限内。本层只负责「请求 Jina
|
|
6
|
+
并解析出 markdown」,公网边界(is_public_host)由调用方保证。
|
|
7
|
+
|
|
8
|
+
定位:HTTP/TLS 直连全败后的免浏览器快速路径——jina 在远端渲染并返回
|
|
9
|
+
markdown,命中则免去 CDP 冷启动。有 Key 用 Key(ARGO_JINA_API_KEY),
|
|
10
|
+
无 Key 走免 Key 匿名档兜底。失败返回 None,由 fetch_v3 主链降级到
|
|
11
|
+
Parallel/Wayback/浏览器。
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import re
|
|
17
|
+
import sys
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
SCRIPT_DIR = Path(__file__).resolve().parent
|
|
21
|
+
if str(SCRIPT_DIR) not in sys.path:
|
|
22
|
+
sys.path.insert(0, str(SCRIPT_DIR))
|
|
23
|
+
|
|
24
|
+
import engine_states
|
|
25
|
+
from engine_env import env_flag, get_env
|
|
26
|
+
from engines_http import lazy_logger
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def enabled() -> bool:
|
|
30
|
+
"""r.jina.ai 阅读器级开关:ARGO_FETCH_JINA=0 关闭,默认开启。"""
|
|
31
|
+
return env_flag("ARGO_FETCH_JINA")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def fetch(url: str, max_chars: int = 8000, timeout: float = 8.0) -> dict | None:
|
|
35
|
+
"""r.jina.ai 阅读器(有 Key 用 Key,无 Key 走免 Key 兜底)。
|
|
36
|
+
|
|
37
|
+
Key 档与免 Key 档的差异(2026-11-17 实测):免 Key 匿名池按 IP 信誉
|
|
38
|
+
间歇返回 401 AuthenticationRequiredError(bad IP reputation),同机
|
|
39
|
+
4 次请求 3 次被拒;带 ARGO_JINA_API_KEY 稳定 200、500 RPM。故优先带
|
|
40
|
+
Key,缺失时仍走匿名档兜底(有总比没有强,失败由上层降级)。
|
|
41
|
+
"""
|
|
42
|
+
import fetch_v3 # 延迟导入:复用 _make_result / _looks_like_markdown,避免循环引用
|
|
43
|
+
|
|
44
|
+
try:
|
|
45
|
+
from http_client import HttpClient
|
|
46
|
+
client = HttpClient(timeout=min(timeout, 10.0), max_retries=0,
|
|
47
|
+
jitter=False)
|
|
48
|
+
headers = {
|
|
49
|
+
"User-Agent": "argo-fetch-v3/1.0 (+local-research; jina-reader)",
|
|
50
|
+
"Accept": "text/plain",
|
|
51
|
+
# 显式声明返回格式,避免默认格式漂移(官方可选 markdown/html/text/...)
|
|
52
|
+
"X-Respond-With": "markdown",
|
|
53
|
+
# 远端渲染等待上限对齐本级超时(官方上限 180s),避免默认值白等
|
|
54
|
+
"X-Timeout": str(int(min(max(timeout, 1.0), 180.0))),
|
|
55
|
+
# 输出 token 预算:超预算会被 Jina 以 409 BudgetExceededError
|
|
56
|
+
# 拒绝(2026-11-17 实测:8000 字符的 openai 页实际需 5806 token,
|
|
57
|
+
# 比例约 0.73 token/字符,含 Title/URL/Published 等 frontmatter)。
|
|
58
|
+
# 按 max_chars * 1.5 留余量,下限 1024 防短页被误拒。
|
|
59
|
+
"X-Token-Budget": str(max(1024, int(max_chars * 1.5))),
|
|
60
|
+
}
|
|
61
|
+
api_key = get_env("ARGO_JINA_API_KEY").strip()
|
|
62
|
+
if api_key:
|
|
63
|
+
headers["Authorization"] = f"Bearer {api_key}"
|
|
64
|
+
resp = client.get(f"https://r.jina.ai/{url}", extra_headers=headers)
|
|
65
|
+
except Exception as e:
|
|
66
|
+
# 失败可见化:jina 是降级链一级,静默 return None 让故障无法归因
|
|
67
|
+
#(静默棘轮口径只数 Pass/Continue,return None 形态在此补日志)
|
|
68
|
+
lazy_logger("unified_search.fetch_jina").warning(
|
|
69
|
+
"jina reader 失败(%s),降级 Parallel/Wayback/浏览器", e)
|
|
70
|
+
return None
|
|
71
|
+
if resp.get("status", 0) != 200 or not resp.get("text"):
|
|
72
|
+
return None
|
|
73
|
+
raw = resp["text"]
|
|
74
|
+
title = ""
|
|
75
|
+
m = re.search(r"^Title:\s*(.+)$", raw[:2000], re.MULTILINE)
|
|
76
|
+
if m:
|
|
77
|
+
title = m.group(1).strip()[:200]
|
|
78
|
+
if "Markdown Content:" in raw:
|
|
79
|
+
raw = raw.split("Markdown Content:", 1)[1].lstrip()
|
|
80
|
+
if not fetch_v3._looks_like_markdown(raw):
|
|
81
|
+
return None
|
|
82
|
+
result = fetch_v3._make_result(url, "", max_chars,
|
|
83
|
+
engine_states.FETCH_JINA_READER)
|
|
84
|
+
result["content"] = raw[:max_chars]
|
|
85
|
+
result["length"] = len(result["content"])
|
|
86
|
+
result["title"] = title
|
|
87
|
+
# 额度可见化:Reader 响应头带 x-ratelimit-*(RPM 档)与 x-usage-tokens
|
|
88
|
+
# (本次消耗)。10M 免费 token 是共享钱包,落进结果便于观测消耗。
|
|
89
|
+
resp_headers = {str(k).lower(): v
|
|
90
|
+
for k, v in (resp.get("headers") or {}).items()}
|
|
91
|
+
quota = {k: v for k, v in resp_headers.items()
|
|
92
|
+
if k.startswith(("x-ratelimit", "x-usage"))}
|
|
93
|
+
if quota:
|
|
94
|
+
result["jina_quota"] = quota
|
|
95
|
+
remaining = resp_headers.get("x-ratelimit-remaining")
|
|
96
|
+
if remaining and str(remaining).strip().isdigit() and int(remaining) < 50:
|
|
97
|
+
result["jina_low_quota"] = True
|
|
98
|
+
return result
|
package/scripts/fetch_v3.py
CHANGED
|
@@ -32,11 +32,13 @@ TLS 指纹伪造层(第一级B):
|
|
|
32
32
|
|
|
33
33
|
from __future__ import annotations
|
|
34
34
|
|
|
35
|
+
import atexit
|
|
35
36
|
import json
|
|
36
37
|
import os
|
|
37
38
|
import re
|
|
38
39
|
import signal
|
|
39
40
|
import sys
|
|
41
|
+
import threading
|
|
40
42
|
import time
|
|
41
43
|
import traceback
|
|
42
44
|
import urllib.parse
|
|
@@ -54,6 +56,7 @@ if SCRIPT_DIR not in sys.path:
|
|
|
54
56
|
# 渲染层(第二级A):TinyFish 直连渲染,独立模块以保持本文件聚焦主链调度;
|
|
55
57
|
# engine_states 是状态词表唯一真源(2026-11-09 收口)
|
|
56
58
|
import fetch_render_tinyfish as _render_tinyfish
|
|
59
|
+
import fetch_jina as _fetch_jina
|
|
57
60
|
import engine_states
|
|
58
61
|
from except_sets import IO_BENIGN, OPT_IMPORT, SHAPE_BENIGN # 收窄词汇表(2026-11-13 裸吞收口)
|
|
59
62
|
|
|
@@ -71,7 +74,7 @@ import fetch_quality as _quality
|
|
|
71
74
|
# 本地状态目录唯一来源(env ARGO_STATE_DIR → config cache.db_path 父目录 → 旧路径)
|
|
72
75
|
import argo_paths as _paths
|
|
73
76
|
from net_proxy import open_url # 出口调度唯一入口(issue #13 同类修复)
|
|
74
|
-
from engine_env import env_flag #
|
|
77
|
+
from engine_env import env_flag, get_env # env_flag 判开关;get_env 读密钥(os.environ 优先,env 文件热读保底)
|
|
75
78
|
from cli_io import dumps
|
|
76
79
|
from fetch_jsrun import _jsrun_challenge_fetch, _jsrun_enabled # js-run 轻量车道(拆出独立模块)
|
|
77
80
|
|
|
@@ -549,11 +552,8 @@ def _mobile_first_host(url: str) -> bool:
|
|
|
549
552
|
|
|
550
553
|
|
|
551
554
|
# ─── 身份记忆(per-host 成功档位,跨进程小文件)─────────────────────────────
|
|
552
|
-
#
|
|
553
|
-
# 首次访问未知分流站:桌面失败 → 移动成功(2 次触碰);记忆生效后(TTL 24h)
|
|
554
|
-
# 直接移动首发(1 次触碰)。实测依据:抖音类站点按 IP 递进限速,请求节奏比
|
|
555
|
-
# 身份选择重要一个数量级,省掉的每次试错都是真实的封禁风险。
|
|
556
555
|
_IDENTITY_TTL = 86400
|
|
556
|
+
_identity_lock = threading.Lock()
|
|
557
557
|
|
|
558
558
|
|
|
559
559
|
def _identity_path() -> str:
|
|
@@ -561,18 +561,11 @@ def _identity_path() -> str:
|
|
|
561
561
|
patched = globals().get("_IDENTITY_PATH")
|
|
562
562
|
if patched is not None:
|
|
563
563
|
return patched
|
|
564
|
-
return os.environ.get(
|
|
565
|
-
"ARGO_IDENTITY_MEMORY",
|
|
566
|
-
str(_paths.state_path("fetch-identity.json")))
|
|
564
|
+
return os.environ.get("ARGO_IDENTITY_MEMORY", str(_paths.state_path("fetch-identity.json")))
|
|
567
565
|
|
|
568
566
|
|
|
569
567
|
def __getattr__(name: str):
|
|
570
|
-
"""`_IDENTITY_PATH` 每次访问按当前 ARGO_IDENTITY_MEMORY 解析(PEP 562)。
|
|
571
|
-
|
|
572
|
-
290d3d8 同口径:状态根在导入后被改写是常态(测试临时目录、多工作树)。
|
|
573
|
-
模块内裸名查找不触发本函数(LOAD_GLOBAL 语义),函数体一律走
|
|
574
|
-
_identity_path();这里只维持外部属性访问与 monkeypatch 契约。
|
|
575
|
-
"""
|
|
568
|
+
"""`_IDENTITY_PATH` 每次访问按当前 ARGO_IDENTITY_MEMORY 解析(PEP 562)。"""
|
|
576
569
|
if name == "_IDENTITY_PATH":
|
|
577
570
|
return _identity_path()
|
|
578
571
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -582,60 +575,67 @@ _identity_mem: dict[str, float] = {}
|
|
|
582
575
|
_identity_loaded = False
|
|
583
576
|
_identity_dirty = False
|
|
584
577
|
_identity_last_flush = 0.0
|
|
585
|
-
_IDENTITY_FLUSH_INTERVAL = 30.0
|
|
578
|
+
_IDENTITY_FLUSH_INTERVAL = 30.0
|
|
579
|
+
_identity_atexit_registered = False
|
|
586
580
|
|
|
587
581
|
|
|
588
|
-
def
|
|
582
|
+
def _identity_load_locked() -> None:
|
|
589
583
|
global _identity_loaded, _identity_mem
|
|
590
584
|
if _identity_loaded:
|
|
591
585
|
return
|
|
592
586
|
_identity_loaded = True
|
|
593
587
|
try:
|
|
594
|
-
|
|
595
|
-
raw = json.load(f)
|
|
588
|
+
raw = json.loads(Path(_identity_path()).read_text(encoding="utf-8"))
|
|
596
589
|
now = time.time()
|
|
597
|
-
|
|
598
|
-
for h, t in raw.items():
|
|
599
|
-
try:
|
|
600
|
-
exp = float(t)
|
|
601
|
-
if exp > now:
|
|
602
|
-
mem[str(h)] = exp
|
|
603
|
-
except (TypeError, ValueError):
|
|
604
|
-
continue # 单条脏数据不拖垮整表(旧版本/手改字段)
|
|
605
|
-
_identity_mem = mem
|
|
590
|
+
_identity_mem = {str(h): float(t) for h, t in raw.items() if isinstance(t, (int, float)) and float(t) > now}
|
|
606
591
|
except Exception:
|
|
607
592
|
_identity_mem = {}
|
|
608
593
|
|
|
609
594
|
|
|
610
|
-
def
|
|
611
|
-
"""记录「该 host 移动端身份成功过」,最多每 30s 写一次文件。失败静默(纯增益层)。"""
|
|
595
|
+
def _identity_flush() -> None:
|
|
612
596
|
global _identity_dirty, _identity_last_flush
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
_identity_mem[host] = time.time() + _IDENTITY_TTL
|
|
619
|
-
_identity_dirty = True
|
|
620
|
-
now = time.monotonic()
|
|
621
|
-
if _identity_last_flush > 0.0 and now - _identity_last_flush < _IDENTITY_FLUSH_INTERVAL:
|
|
622
|
-
return
|
|
623
|
-
_identity_last_flush = now
|
|
597
|
+
with _identity_lock:
|
|
598
|
+
if not _identity_dirty:
|
|
599
|
+
return
|
|
600
|
+
snap, p = dict(_identity_mem), Path(_identity_path())
|
|
601
|
+
_identity_dirty, _identity_last_flush = False, time.monotonic()
|
|
624
602
|
try:
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
603
|
+
now = time.time()
|
|
604
|
+
with _paths.file_lock(p):
|
|
605
|
+
raw = json.loads(p.read_text(encoding="utf-8")) if p.exists() else {}
|
|
606
|
+
merged = {str(h): float(t) for h, t in raw.items() if isinstance(t, (int, float)) and float(t) > now} if isinstance(raw, dict) else {}
|
|
607
|
+
merged.update({h: exp for h, exp in snap.items() if exp > max(now, merged.get(h, 0.0))})
|
|
608
|
+
_paths.atomic_write_json(p, merged, indent=None)
|
|
609
|
+
except (*IO_BENIGN, ValueError):
|
|
630
610
|
pass
|
|
631
611
|
|
|
632
612
|
|
|
613
|
+
def _identity_remember_mobile(host: str) -> None:
|
|
614
|
+
"""记录「该 host 移动端身份成功过」,最多每 30s 写盘 + atexit 兜底。"""
|
|
615
|
+
global _identity_dirty, _identity_atexit_registered
|
|
616
|
+
if not host:
|
|
617
|
+
return
|
|
618
|
+
with _identity_lock:
|
|
619
|
+
_identity_load_locked()
|
|
620
|
+
if len(_identity_mem) >= 512:
|
|
621
|
+
_identity_mem.pop(next(iter(_identity_mem)), None)
|
|
622
|
+
_identity_mem[host] = time.time() + _IDENTITY_TTL
|
|
623
|
+
_identity_dirty = True
|
|
624
|
+
if not _identity_atexit_registered:
|
|
625
|
+
atexit.register(_identity_flush)
|
|
626
|
+
_identity_atexit_registered = True
|
|
627
|
+
need_flush = _identity_last_flush == 0.0 or (time.monotonic() - _identity_last_flush) >= _IDENTITY_FLUSH_INTERVAL
|
|
628
|
+
if need_flush:
|
|
629
|
+
_identity_flush()
|
|
630
|
+
|
|
631
|
+
|
|
633
632
|
def _identity_is_mobile(host: str) -> bool:
|
|
634
633
|
"""该 host 近 24h 内移动身份是否成功过。"""
|
|
635
634
|
if not host:
|
|
636
635
|
return False
|
|
637
|
-
|
|
638
|
-
|
|
636
|
+
with _identity_lock:
|
|
637
|
+
_identity_load_locked()
|
|
638
|
+
return _identity_mem.get(host, 0) > time.time()
|
|
639
639
|
|
|
640
640
|
|
|
641
641
|
def _mobile_http_fetch(url: str, max_chars: int = 8000,
|
|
@@ -906,19 +906,14 @@ def _make_result(url: str, html: str, max_chars: int,
|
|
|
906
906
|
return result
|
|
907
907
|
|
|
908
908
|
|
|
909
|
-
# ───
|
|
909
|
+
# ─── 第三方代理公网边界(jina 与 Parallel 共用;请求层见 fetch_jina.py)─────
|
|
910
910
|
|
|
911
911
|
_JINA_PRIVATE_HOST = re.compile(
|
|
912
912
|
r"^(localhost|127\.|10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|169\.254\.|0\.)")
|
|
913
913
|
|
|
914
914
|
|
|
915
|
-
def _jina_enabled() -> bool:
|
|
916
|
-
"""r.jina.ai 阅读器级开关:ARGO_FETCH_JINA=0 关闭,默认开启。"""
|
|
917
|
-
return env_flag("ARGO_FETCH_JINA")
|
|
918
|
-
|
|
919
|
-
|
|
920
915
|
def _is_public_host(host: str) -> bool:
|
|
921
|
-
"""r.jina.ai
|
|
916
|
+
"""第三方代理(r.jina.ai / Parallel)只接公网 URL。
|
|
922
917
|
|
|
923
918
|
内网/本机/裸 IP 一律跳过——把内部地址送出第三方 = 拓扑泄露;
|
|
924
919
|
域名形 IP(全数字)与含冒号的 IPv6 字面量同判为裸地址。
|
|
@@ -934,42 +929,6 @@ def _is_public_host(host: str) -> bool:
|
|
|
934
929
|
return "." in host
|
|
935
930
|
|
|
936
931
|
|
|
937
|
-
def _jina_reader_fetch(url: str, max_chars: int = 8000,
|
|
938
|
-
timeout: float = 8.0) -> dict | None:
|
|
939
|
-
"""r.jina.ai 阅读器(keyless 免费层)。
|
|
940
|
-
|
|
941
|
-
定位:HTTP/TLS 直连全败后的免浏览器快速路径——jina 在远端渲染并返回
|
|
942
|
-
markdown,命中则免去 CDP 冷启动。免费层有速率限制,失败/429 返回 None
|
|
943
|
-
静默放行走 Wayback/浏览器。调用方须先过 _is_public_host(第三方代理边界)。
|
|
944
|
-
"""
|
|
945
|
-
try:
|
|
946
|
-
from http_client import HttpClient
|
|
947
|
-
client = HttpClient(timeout=min(timeout, 10.0), max_retries=0,
|
|
948
|
-
jitter=False)
|
|
949
|
-
resp = client.get(f"https://r.jina.ai/{url}", extra_headers={
|
|
950
|
-
"User-Agent": "argo-fetch-v3/1.0 (+local-research; jina-reader)",
|
|
951
|
-
"Accept": "text/plain",
|
|
952
|
-
})
|
|
953
|
-
except Exception:
|
|
954
|
-
return None
|
|
955
|
-
if resp.get("status", 0) != 200 or not resp.get("text"):
|
|
956
|
-
return None
|
|
957
|
-
raw = resp["text"]
|
|
958
|
-
title = ""
|
|
959
|
-
m = re.search(r"^Title:\s*(.+)$", raw[:2000], re.MULTILINE)
|
|
960
|
-
if m:
|
|
961
|
-
title = m.group(1).strip()[:200]
|
|
962
|
-
if "Markdown Content:" in raw:
|
|
963
|
-
raw = raw.split("Markdown Content:", 1)[1].lstrip()
|
|
964
|
-
if not _looks_like_markdown(raw):
|
|
965
|
-
return None
|
|
966
|
-
result = _make_result(url, "", max_chars, engine_states.FETCH_JINA_READER)
|
|
967
|
-
result["content"] = raw[:max_chars]
|
|
968
|
-
result["length"] = len(result["content"])
|
|
969
|
-
result["title"] = title
|
|
970
|
-
return result
|
|
971
|
-
|
|
972
|
-
|
|
973
932
|
# ─── 第一级D:Parallel 免费 MCP web_fetch(keyless 云端渲染+提取)────────────
|
|
974
933
|
|
|
975
934
|
_PARALLEL_MCP_URL = "https://search.parallel.ai/mcp"
|
|
@@ -1560,15 +1519,15 @@ def fetch_v3(url: str, max_chars: int = 8000, timeout: float = 8.0,
|
|
|
1560
1519
|
result = spoof
|
|
1561
1520
|
|
|
1562
1521
|
if not result.get("stop_signal") and _budget_left() > 0:
|
|
1563
|
-
# 第一级C:r.jina.ai
|
|
1522
|
+
# 第一级C:r.jina.ai 阅读器(请求层见 fetch_jina.py)。
|
|
1564
1523
|
# HTTP/TLS 直连全败时的免浏览器快速路径;markdown-only 同
|
|
1565
1524
|
# tinyfish,need_html 场景跳过;第三方代理只接公网 URL。
|
|
1566
|
-
if (not gated and not need_html and
|
|
1525
|
+
if (not gated and not need_html and _fetch_jina.enabled()
|
|
1567
1526
|
and _is_public_host(host)
|
|
1568
1527
|
and (not result.get("success")
|
|
1569
1528
|
or _needs_browser(result))):
|
|
1570
1529
|
# 超时受剩余预算约束:deadline 场景本级不得击穿总预算
|
|
1571
|
-
jina =
|
|
1530
|
+
jina = _fetch_jina.fetch(
|
|
1572
1531
|
url, max_chars, timeout=_level_timeout(timeout))
|
|
1573
1532
|
if jina is not None and jina.get("success"):
|
|
1574
1533
|
jina["http_fallback"] = True
|
|
Binary file
|
package/scripts/install.sh
CHANGED
|
@@ -139,6 +139,8 @@ if [[ -d "$INSTALL_DIR/.git" ]]; then
|
|
|
139
139
|
run git -C "$INSTALL_DIR" fetch --depth 1 origin "$BRANCH"
|
|
140
140
|
run git -C "$INSTALL_DIR" checkout "$BRANCH"
|
|
141
141
|
git -C "$INSTALL_DIR" pull --ff-only origin "$BRANCH" 2>/dev/null || warn "pull 失败(可能有本地改动),继续使用当前版本"
|
|
142
|
+
# 升级三提醒(2026-11-17):新码落盘 ≠ 生效;缓存库迁移已随代码自动化。
|
|
143
|
+
info "升级提醒:MCP 宿主里的 argo 连接器与 argo daemon 若在运行,重启以加载新代码(详见 docs/UPGRADE.md)"
|
|
142
144
|
elif [[ -d "$INSTALL_DIR" && -f "$INSTALL_DIR/scripts/search.py" ]]; then
|
|
143
145
|
info "目录已存在且含 Argo 源码,跳过克隆: $INSTALL_DIR"
|
|
144
146
|
else
|
|
@@ -985,15 +985,19 @@ LIVE_CASES: list[dict[str, Any]] = [
|
|
|
985
985
|
]
|
|
986
986
|
|
|
987
987
|
|
|
988
|
-
def _blob_from_results(results: list[dict]
|
|
988
|
+
def _blob_from_results(results: list[dict]) -> str:
|
|
989
|
+
"""只拼结果正文证据。
|
|
990
|
+
|
|
991
|
+
`engines_used` / `engine` 是「谁答的」元数据,不是答案内容:拼进来会让
|
|
992
|
+
gold 里的源名(pubchem、nasa 这类)命中在引擎标识上,一条正文毫不相关
|
|
993
|
+
的结果也能判 hit。引擎维度由 `eng_ok` 单独把关。
|
|
994
|
+
"""
|
|
989
995
|
parts: list[str] = []
|
|
990
996
|
for x in results:
|
|
991
997
|
for k in ("title", "snippet", "content", "url", "source", "engine"):
|
|
992
998
|
v = x.get(k)
|
|
993
999
|
if v:
|
|
994
1000
|
parts.append(str(v))
|
|
995
|
-
parts.extend(str(u) for u in used)
|
|
996
|
-
parts.append(eng or "")
|
|
997
1001
|
return " ".join(parts).lower()
|
|
998
1002
|
|
|
999
1003
|
|
|
@@ -1024,7 +1028,7 @@ def run_live(c: Checker) -> None:
|
|
|
1024
1028
|
domain_got = r.get("domain")
|
|
1025
1029
|
combo = r.get("engines_combo") or r.get("engines") or []
|
|
1026
1030
|
recovery = r.get("recovery")
|
|
1027
|
-
blob = _blob_from_results(results
|
|
1031
|
+
blob = _blob_from_results(results)
|
|
1028
1032
|
|
|
1029
1033
|
dom_ok = case.get("domain") is None or domain_got == case["domain"]
|
|
1030
1034
|
primary = case.get("primary")
|
|
@@ -1052,12 +1056,6 @@ def run_live(c: Checker) -> None:
|
|
|
1052
1056
|
for p in pollute_keys:
|
|
1053
1057
|
if p in src and p not in pollute_hit:
|
|
1054
1058
|
pollute_hit.append(p)
|
|
1055
|
-
for u in used:
|
|
1056
|
-
ul = str(u).lower()
|
|
1057
|
-
for p in pollute_keys:
|
|
1058
|
-
if p == ul and p not in pollute_hit:
|
|
1059
|
-
# 若仅作为 recovery 未进 results 可不算污染;仅 results 源算
|
|
1060
|
-
pass
|
|
1061
1059
|
|
|
1062
1060
|
# 严格:top results 的 source 不得为 pollute
|
|
1063
1061
|
pollute_ok = not pollute_hit
|
package/scripts/mcp_transport.py
CHANGED
|
@@ -39,7 +39,7 @@ except Exception: # pragma: no cover
|
|
|
39
39
|
|
|
40
40
|
# 版本来源:与 package.json / SKILL.md 保持一致(发布时统一升版;
|
|
41
41
|
# tests/test_consistency_gates.py 会四端对账,漂移即红)
|
|
42
|
-
ARGO_MCP_VERSION = "2.
|
|
42
|
+
ARGO_MCP_VERSION = "2.16.0"
|
|
43
43
|
|
|
44
44
|
_response_format = "content-length" # 根据客户端请求自动切换
|
|
45
45
|
|
|
@@ -62,9 +62,13 @@ def handle_rpc(method: str, params: dict[str, Any]) -> dict[str, Any]:
|
|
|
62
62
|
# 短指令:降 tools 上下文;细节在 tool schema。
|
|
63
63
|
# URL 在 results[].url(默认 envelope=False,不生成 sources)。
|
|
64
64
|
#
|
|
65
|
-
# 文案只写「CORE
|
|
66
|
-
#
|
|
67
|
-
#
|
|
65
|
+
# 文案只写「CORE 指哪几个」的语义;all 才打开的附加名单抄在这里,
|
|
66
|
+
# 是因为不少宿主不把 initialize instructions 之外的上下文透给模型,
|
|
67
|
+
# 不抄它们就永远不知道这些工具存在(2026-11-17 补全:此前抄了
|
|
68
|
+
# 11/15,漏 pdf/social_search/article/job 四个)。抄写漂移由机械
|
|
69
|
+
# 对拍锁死——test_mcp_consolidated_tools.py::
|
|
70
|
+
# test_instructions_matches_core 断言本名单 == TOOLS 全集 − CORE,
|
|
71
|
+
# 增删工具忘了改这里即红。
|
|
68
72
|
#
|
|
69
73
|
# 不点名 argo_local_search:它是真工具(domain=local 也能用),但
|
|
70
74
|
# 已不在默认注入面,写进「日常」文案会让模型去调一个没挂的工具。
|
|
@@ -75,7 +79,8 @@ def handle_rpc(method: str, params: dict[str, Any]) -> dict[str, Any]:
|
|
|
75
79
|
"argo_screenshot 截图)。argo_search 用 domain 切社交/招聘/本机。"
|
|
76
80
|
"其余工具默认不注入 schema,ARGO_MCP_TOOLS=all 打开:"
|
|
77
81
|
"local_search/local_read/recompute/evidence/clarify/crawl/"
|
|
78
|
-
"extract/preflight/answer/
|
|
82
|
+
"pdf/social_search/article/job/extract/preflight/answer/"
|
|
83
|
+
"watch/cite。"
|
|
79
84
|
),
|
|
80
85
|
}
|
|
81
86
|
|
|
@@ -209,7 +209,8 @@ def numeric_verify_results(results: list[dict[str, Any]],
|
|
|
209
209
|
return page, method
|
|
210
210
|
|
|
211
211
|
# 墙钟预算与 verify 同一开关(ARGO_VERIFY_BUDGET_S,默认 5s):到点未回的
|
|
212
|
-
# URL 记 pending,语义与 fetch
|
|
212
|
+
# URL 记 pending,语义与 fetch 失败一致。worker 上限 6 同理——核验是纯
|
|
213
|
+
# I/O 等待,3 个 worker 装不下更多 URL,预算会全花在排队上(见 evidence_loop)。
|
|
213
214
|
from evidence_loop import _verify_budget_s
|
|
214
215
|
budget_s = _verify_budget_s()
|
|
215
216
|
|
|
@@ -220,7 +221,7 @@ def numeric_verify_results(results: list[dict[str, Any]],
|
|
|
220
221
|
elif budget_s > 0 and len(targets) > 1:
|
|
221
222
|
from bounded_run import TaskError, run_bounded
|
|
222
223
|
finished, unfinished = run_bounded(
|
|
223
|
-
targets, _fetch_one, budget_s, max_workers=min(len(targets),
|
|
224
|
+
targets, _fetch_one, budget_s, max_workers=min(len(targets), 6))
|
|
224
225
|
for item, value in finished:
|
|
225
226
|
if isinstance(value, TaskError):
|
|
226
227
|
pending.append(item[0].get("url") or "")
|
|
@@ -112,6 +112,9 @@ def build_failures(result: dict[str, Any], limit: int = 6) -> list[dict[str, Any
|
|
|
112
112
|
# 周期边界前不会因重试改变。标出来,避免 Agent 立刻重试同一个源。
|
|
113
113
|
if status.startswith(engine_states.OUTCOME_SKIPPED_PREFIX):
|
|
114
114
|
item["persistent"] = True
|
|
115
|
+
if o.get("http_status") is not None:
|
|
116
|
+
# 原始 HTTP 状态码(403/404/429…):语义 status 之外的事实层
|
|
117
|
+
item["http_status"] = o.get("http_status")
|
|
115
118
|
detail = str(o.get("detail") or "").strip()
|
|
116
119
|
if detail:
|
|
117
120
|
item["detail"] = detail[:160]
|