argo-search 2.14.1 → 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 +8 -6
- package/README.es.md +57 -813
- package/README.ja.md +56 -814
- package/README.ko.md +56 -812
- package/README.md +160 -754
- package/README.zh.md +152 -872
- package/SKILL.md +22 -23
- 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 +149 -6
- package/backends/engine_concept_vectors.json +1525 -1525
- package/backends/engine_registry.yaml +139 -30
- package/backends/quota_profiles.json +83 -3
- package/bin/argo +33 -17
- package/config.yaml +189 -33
- package/docs/ADDING_NEW_ENGINE.md +10 -0
- package/docs/ARGO_INTRO.md +1 -1
- package/docs/CHANGELOG.md +38 -0
- package/docs/ENGINE_CATALOG.md +102 -89
- package/docs/MCP_SETUP.md +10 -1
- package/docs/RELEASE_NOTES_v2.14.1.md +4 -4
- package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
- package/docs/RELEASE_NOTES_v2.16.0.md +58 -0
- package/docs/RELEASING.md +1 -1
- package/engines/specs/ai_labs.yaml +89 -0
- package/engines/specs/archive_org.yaml +1 -1
- package/engines/specs/bilibili_hot.yaml +11 -1
- package/engines/specs/brave.yaml +3 -3
- package/engines/specs/carbon_intensity.yaml +1 -1
- package/engines/specs/cisa_alerts.yaml +40 -0
- package/engines/specs/cn_ai_news.yaml +10 -8
- 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/digup.yaml +11 -6
- package/engines/specs/docker_hub.yaml +1 -1
- 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/europepmc.yaml +1 -1
- 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 +30 -7
- 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/grepapp_mcp.yaml +62 -0
- package/engines/specs/guardian_rss.yaml +6 -4
- package/engines/specs/hf_datasets.yaml +1 -1
- package/engines/specs/huggingface.yaml +1 -1
- package/engines/specs/itotii.yaml +13 -1
- package/engines/specs/keenable.yaml +7 -1
- package/engines/specs/linux_do.yaml +63 -0
- package/engines/specs/lobsters.yaml +41 -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/local_seek.yaml +6 -0
- 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/open_meteo.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/redskill.yaml +2 -0
- package/engines/specs/searxng.yaml +4 -2
- package/engines/specs/sec_edgar.yaml +9 -4
- package/engines/specs/steam.yaml +1 -1
- 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/wikidata.yaml +1 -1
- package/engines/specs/wikipedia.yaml +1 -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_hot_app.yaml +1 -1
- package/engines/specs/zhihu_kb.yaml +18 -0
- package/engines/specs/zhihu_questions.yaml +19 -0
- package/package.json +4 -2
- package/packages/dsh-plugin/README.md +9 -14
- package/packages/dsh-plugin/dsh/client.js +481 -1037
- package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
- package/packages/dsh-plugin/dsh/index.js +6 -0
- package/packages/dsh-plugin/dsh/runner.js +3 -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 +10 -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/packages/dsh-plugin/test/workbench.test.js +92 -0
- package/scripts/adaptive.py +7 -1
- package/scripts/archive_run.py +112 -53
- package/scripts/argo_paths.py +42 -5
- package/scripts/badcase_ledger.py +117 -9
- package/scripts/build_concept_table.py +112 -55
- package/scripts/cache.py +6 -2
- package/scripts/caliber_isolation.py +60 -23
- package/scripts/circuit_breaker.py +72 -11
- package/scripts/cli_io.py +20 -2
- package/scripts/config_cache.py +44 -1
- package/scripts/daemon.py +151 -51
- package/scripts/dormant_ledger.py +23 -9
- package/scripts/engine_dispatch.py +8 -5
- package/scripts/engine_env.py +191 -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 +66 -61
- package/scripts/engines_builders.py +0 -15
- package/scripts/engines_builders_archive.py +4 -3
- package/scripts/engines_builders_batch10.py +346 -100
- package/scripts/engines_builders_batch11.py +4 -76
- 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 +16 -25
- package/scripts/engines_builders_cn.py +7 -201
- 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 +76 -11
- package/scripts/engines_builders_finance.py +2 -1
- package/scripts/engines_builders_intl.py +18 -117
- package/scripts/engines_builders_media.py +59 -12
- package/scripts/engines_builders_pixiv.py +2 -16
- package/scripts/engines_builders_science.py +8 -7
- package/scripts/engines_builders_search.py +7 -14
- package/scripts/engines_builders_skill.py +2 -1
- package/scripts/engines_builders_tech.py +8 -17
- package/scripts/engines_builders_weather.py +241 -0
- package/scripts/engines_fields.py +91 -0
- package/scripts/engines_http.py +184 -0
- package/scripts/engines_mcp.py +405 -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 +19 -4
- package/scripts/extend_route_labels.py +6 -0
- package/scripts/fetch_jina.py +98 -0
- package/scripts/fetch_jsrun.py +15 -11
- package/scripts/fetch_v3.py +79 -120
- 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/image_vision/vision_probe +0 -0
- package/scripts/install.sh +2 -0
- package/scripts/link_source.py +65 -24
- package/scripts/local_seek_adapter.py +57 -17
- package/scripts/matrix_search_eval.py +8 -10
- package/scripts/mcp_handlers.py +53 -31
- package/scripts/mcp_handlers_surface.py +6 -18
- package/scripts/mcp_transport.py +10 -5
- package/scripts/min_version_scan.py +7 -3
- package/scripts/network_aware.py +7 -13
- package/scripts/numeric_verify.py +3 -2
- package/scripts/output_transparency.py +3 -0
- package/scripts/pre-commit +45 -43
- package/scripts/query_understanding.py +30 -6
- package/scripts/quota.py +36 -30
- package/scripts/rank_signals.py +9 -0
- package/scripts/recompute.py +15 -5
- package/scripts/recovery.py +38 -29
- package/scripts/recovery_runner.py +29 -10
- package/scripts/redskill/redskill_engine.py +2 -1
- 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 +40 -70
- package/scripts/route_audit.py +259 -0
- package/scripts/route_combo.py +21 -6
- 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 +53 -10
- package/scripts/search_entry.py +32 -1
- package/scripts/search_output.py +23 -11
- package/scripts/search_pipeline.py +15 -3
- package/scripts/search_rank.py +21 -11
- package/scripts/semantic_evidence.py +394 -178
- package/scripts/serp_guard.py +13 -1
- package/scripts/settings_page.py +4 -3
- 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/xiaohongshu_engine.py +2 -1
- package/scripts/social_engines/zhihu_engine.py +252 -43
- package/scripts/sogou_weixin_browser.py +5 -6
- package/scripts/source_audit.py +44 -9
- 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 +50 -10
- package/scripts/watch.py +3 -3
- package/scripts/zhihu_quota.py +2 -1
- package/sub-skills/argo-wide-research/SKILL.md +70 -0
- 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/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/health_probe.py
DELETED
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
health_probe.py — 引擎健康探针(v2.5 新增)
|
|
4
|
-
|
|
5
|
-
对 HTTP 引擎做可达性检查,结果写入 SQLite 供 route.py 查询。
|
|
6
|
-
- 启动时全量探测
|
|
7
|
-
- 每 5 分钟后台自动刷新
|
|
8
|
-
- 连续 2 次失败标记 unavailable,1 次成功恢复
|
|
9
|
-
|
|
10
|
-
用法:
|
|
11
|
-
python3 health_probe.py # 单次探测
|
|
12
|
-
python3 health_probe.py --watch # 后台持续监控(每 5 分钟)
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
from __future__ import annotations
|
|
16
|
-
|
|
17
|
-
import os
|
|
18
|
-
import sqlite3
|
|
19
|
-
import sys
|
|
20
|
-
import threading
|
|
21
|
-
import time
|
|
22
|
-
import urllib.request
|
|
23
|
-
from pathlib import Path
|
|
24
|
-
from typing import Any
|
|
25
|
-
from net_proxy import open_url # 出口调度唯一入口(issue #13 同类修复)
|
|
26
|
-
from cli_io import dumps
|
|
27
|
-
# 状态词表唯一真源:探针三态(2026-11-09 收口)
|
|
28
|
-
import engine_states
|
|
29
|
-
|
|
30
|
-
SCRIPT_DIR = Path(__file__).parent
|
|
31
|
-
sys.path.insert(0, str(SCRIPT_DIR))
|
|
32
|
-
|
|
33
|
-
try:
|
|
34
|
-
from config import load_config, get_engines
|
|
35
|
-
except ImportError:
|
|
36
|
-
from config import load_config, get_engines
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
# ── 路径 ──────────────────────────────────────────────────────────────────────
|
|
40
|
-
|
|
41
|
-
def _db_path() -> Path:
|
|
42
|
-
"""状态库路径(惰性派生,支持 ARGO_STATE_DIR 覆盖)。"""
|
|
43
|
-
import argo_paths
|
|
44
|
-
return argo_paths.state_path("health.db")
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
DB_PATH = _db_path() # 兼容旧引用
|
|
48
|
-
PROBE_INTERVAL = 300 # 5 分钟
|
|
49
|
-
PROBE_TIMEOUT = 1.5 # 单次探测超时(快,不能拖慢启动)
|
|
50
|
-
MAX_FAILURES = engine_states.PROBE_MAX_FAILURES # 阈值真源见词表 §16
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# ── SQLite 存储 ───────────────────────────────────────────────────────────────
|
|
54
|
-
|
|
55
|
-
def _connect():
|
|
56
|
-
DB_PATH.parent.mkdir(parents=True, exist_ok=True)
|
|
57
|
-
conn = sqlite3.connect(str(DB_PATH), timeout=5)
|
|
58
|
-
import argo_paths
|
|
59
|
-
argo_paths.apply_state_pragmas(conn)
|
|
60
|
-
return conn
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def _init_db():
|
|
64
|
-
with _connect() as conn:
|
|
65
|
-
conn.execute("""
|
|
66
|
-
CREATE TABLE IF NOT EXISTS engine_health (
|
|
67
|
-
engine TEXT PRIMARY KEY,
|
|
68
|
-
status TEXT NOT NULL DEFAULT 'unknown',
|
|
69
|
-
consecutive_failures INTEGER DEFAULT 0,
|
|
70
|
-
last_probe_at REAL DEFAULT 0,
|
|
71
|
-
last_latency_ms REAL DEFAULT 0,
|
|
72
|
-
last_error TEXT DEFAULT ''
|
|
73
|
-
)
|
|
74
|
-
""")
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def _probe_http(url: str, timeout: float = PROBE_TIMEOUT) -> tuple[bool, float, str]:
|
|
78
|
-
"""探测 HTTP 引擎:发起 HEAD 请求检查可达性。"""
|
|
79
|
-
try:
|
|
80
|
-
req = urllib.request.Request(url, method="HEAD")
|
|
81
|
-
t0 = time.time()
|
|
82
|
-
with open_url(req, timeout=timeout) as resp:
|
|
83
|
-
elapsed = (time.time() - t0) * 1000
|
|
84
|
-
return True, elapsed, ""
|
|
85
|
-
except Exception as e:
|
|
86
|
-
return False, 0, str(e)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def _probe_cli(cmd: list[str], timeout: float = 2) -> tuple[bool, float, str]:
|
|
90
|
-
"""探测 CLI 引擎:检查命令是否存在。"""
|
|
91
|
-
import subprocess
|
|
92
|
-
if not cmd:
|
|
93
|
-
return False, 0, "empty command"
|
|
94
|
-
exe = cmd[0]
|
|
95
|
-
if isinstance(exe, str) and exe.startswith("~"):
|
|
96
|
-
exe = str(Path(exe).expanduser())
|
|
97
|
-
try:
|
|
98
|
-
import shutil
|
|
99
|
-
if shutil.which(exe):
|
|
100
|
-
return True, 0, ""
|
|
101
|
-
return False, 0, f"command not found: {exe}"
|
|
102
|
-
except Exception as e:
|
|
103
|
-
return False, 0, str(e)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
def probe_all_engines():
|
|
107
|
-
"""探测 local_* 子引擎(route 健康过滤的唯一消费面)。
|
|
108
|
-
|
|
109
|
-
非 local 引擎不做 HEAD 探测:1.5s 超时对慢源误报严重(wikipedia 曾因
|
|
110
|
-
9 次探测失败被标 unavailable),且探测结果无人消费。网络延迟估计
|
|
111
|
-
以 adaptive 数据为主,health_probe 仅保底。
|
|
112
|
-
"""
|
|
113
|
-
_init_db()
|
|
114
|
-
cfg = load_config()
|
|
115
|
-
engines = get_engines(cfg)
|
|
116
|
-
results = {}
|
|
117
|
-
|
|
118
|
-
for name, spec in engines.items():
|
|
119
|
-
if not name.startswith("local_"):
|
|
120
|
-
continue
|
|
121
|
-
engine_type = spec.get("type", "")
|
|
122
|
-
url = spec.get("url", "")
|
|
123
|
-
cmd = spec.get("cmd", [])
|
|
124
|
-
|
|
125
|
-
if engine_type == "http" and url:
|
|
126
|
-
ok, latency, err = _probe_http(url)
|
|
127
|
-
elif engine_type == "cli" and cmd:
|
|
128
|
-
ok, latency, err = _probe_cli(cmd)
|
|
129
|
-
else:
|
|
130
|
-
continue
|
|
131
|
-
|
|
132
|
-
# 更新数据库
|
|
133
|
-
with _connect() as conn:
|
|
134
|
-
row = conn.execute(
|
|
135
|
-
"SELECT consecutive_failures FROM engine_health WHERE engine = ?",
|
|
136
|
-
(name,),
|
|
137
|
-
).fetchone()
|
|
138
|
-
|
|
139
|
-
if ok:
|
|
140
|
-
new_status = engine_states.PROBE_STATUS_AVAILABLE
|
|
141
|
-
new_failures = 0
|
|
142
|
-
else:
|
|
143
|
-
prev_failures = row[0] if row else 0
|
|
144
|
-
new_failures = prev_failures + 1
|
|
145
|
-
new_status = (engine_states.PROBE_STATUS_UNAVAILABLE
|
|
146
|
-
if new_failures >= MAX_FAILURES
|
|
147
|
-
else engine_states.PROBE_STATUS_DEGRADED)
|
|
148
|
-
|
|
149
|
-
conn.execute(
|
|
150
|
-
"""INSERT OR REPLACE INTO engine_health
|
|
151
|
-
(engine, status, consecutive_failures, last_probe_at, last_latency_ms, last_error)
|
|
152
|
-
VALUES (?, ?, ?, ?, ?, ?)""",
|
|
153
|
-
(name, new_status, new_failures, time.time(), latency, err),
|
|
154
|
-
)
|
|
155
|
-
conn.commit()
|
|
156
|
-
|
|
157
|
-
results[name] = {
|
|
158
|
-
"status": (engine_states.PROBE_STATUS_AVAILABLE if ok
|
|
159
|
-
else engine_states.PROBE_STATUS_UNAVAILABLE),
|
|
160
|
-
"latency_ms": round(latency, 1),
|
|
161
|
-
"error": err,
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return results
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
def get_engine_status(engine: str) -> dict[str, Any]:
|
|
168
|
-
"""查询单个引擎的健康状态。单一真源:优先对齐熔断器证据。"""
|
|
169
|
-
try:
|
|
170
|
-
from circuit_breaker import get_breaker
|
|
171
|
-
allowed, _ = get_breaker().allow(engine)
|
|
172
|
-
if not allowed:
|
|
173
|
-
return {
|
|
174
|
-
"status": engine_states.PROBE_STATUS_UNAVAILABLE,
|
|
175
|
-
"consecutive_failures": 999,
|
|
176
|
-
"last_probe_at": time.time(),
|
|
177
|
-
"last_latency_ms": None,
|
|
178
|
-
"available": False,
|
|
179
|
-
}
|
|
180
|
-
except Exception:
|
|
181
|
-
pass
|
|
182
|
-
|
|
183
|
-
_init_db()
|
|
184
|
-
with _connect() as conn:
|
|
185
|
-
row = conn.execute(
|
|
186
|
-
"SELECT status, consecutive_failures, last_probe_at, last_latency_ms FROM engine_health WHERE engine = ?",
|
|
187
|
-
(engine,),
|
|
188
|
-
).fetchone()
|
|
189
|
-
if not row:
|
|
190
|
-
return {"status": engine_states.PROBE_STATUS_UNKNOWN,
|
|
191
|
-
"consecutive_failures": 0, "available": True}
|
|
192
|
-
return {
|
|
193
|
-
"status": row[0],
|
|
194
|
-
"consecutive_failures": row[1],
|
|
195
|
-
"last_probe_at": row[2],
|
|
196
|
-
"last_latency_ms": row[3],
|
|
197
|
-
"available": engine_states.is_probe_available(row[0]),
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
def get_all_status() -> dict[str, dict[str, Any]]:
|
|
202
|
-
"""获取所有引擎的健康状态。"""
|
|
203
|
-
_init_db()
|
|
204
|
-
with _connect() as conn:
|
|
205
|
-
rows = conn.execute(
|
|
206
|
-
"SELECT engine, status, consecutive_failures, last_probe_at, last_latency_ms FROM engine_health"
|
|
207
|
-
).fetchall()
|
|
208
|
-
return {
|
|
209
|
-
row[0]: {
|
|
210
|
-
"status": row[1],
|
|
211
|
-
"consecutive_failures": row[2],
|
|
212
|
-
"last_probe_at": row[3],
|
|
213
|
-
"last_latency_ms": row[4],
|
|
214
|
-
"available": engine_states.is_probe_available(row[1]),
|
|
215
|
-
}
|
|
216
|
-
for row in rows
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
def watch_background():
|
|
221
|
-
"""后台持续监控模式。在后台线程中运行,不阻塞 MCP 启动。"""
|
|
222
|
-
def _loop():
|
|
223
|
-
# 首次探测延迟 10 秒,让 MCP 先完成 initialize 握手
|
|
224
|
-
time.sleep(10)
|
|
225
|
-
try:
|
|
226
|
-
probe_all_engines()
|
|
227
|
-
except Exception:
|
|
228
|
-
pass
|
|
229
|
-
while True:
|
|
230
|
-
time.sleep(PROBE_INTERVAL)
|
|
231
|
-
try:
|
|
232
|
-
probe_all_engines()
|
|
233
|
-
except Exception:
|
|
234
|
-
pass
|
|
235
|
-
|
|
236
|
-
t = threading.Thread(target=_loop, daemon=True)
|
|
237
|
-
t.start()
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
# ── CLI ───────────────────────────────────────────────────────────────────────
|
|
241
|
-
|
|
242
|
-
if __name__ == "__main__":
|
|
243
|
-
if "--watch" in sys.argv:
|
|
244
|
-
print("启动后台健康监控(每 5 分钟)...", file=sys.stderr)
|
|
245
|
-
watch_background()
|
|
246
|
-
try:
|
|
247
|
-
while True:
|
|
248
|
-
time.sleep(60)
|
|
249
|
-
except KeyboardInterrupt:
|
|
250
|
-
pass
|
|
251
|
-
else:
|
|
252
|
-
results = probe_all_engines()
|
|
253
|
-
print(dumps(results))
|