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
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128" fill="none">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="v2-bg" x1="10" y1="8" x2="118" y2="120" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop offset="0%" stop-color="#FAF6F0"/>
|
|
5
|
+
<stop offset="100%" stop-color="#EFE7DA"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
<linearGradient id="v2-red" x1="34" y1="24" x2="94" y2="96" gradientUnits="userSpaceOnUse">
|
|
8
|
+
<stop offset="0%" stop-color="#F97316"/>
|
|
9
|
+
<stop offset="100%" stop-color="#DC2626"/>
|
|
10
|
+
</linearGradient>
|
|
11
|
+
</defs>
|
|
12
|
+
|
|
13
|
+
<!-- 暖砂纸底座 -->
|
|
14
|
+
<rect x="4" y="4" width="120" height="120" rx="28" fill="url(#v2-bg)"/>
|
|
15
|
+
<rect x="4.75" y="4.75" width="118.5" height="118.5" rx="27.25" stroke="#1E293B" stroke-opacity="0.10" stroke-width="1.5"/>
|
|
16
|
+
|
|
17
|
+
<!-- 平面构成:深炭黑圆环 + 赤陶红航帆 -->
|
|
18
|
+
<circle cx="58" cy="58" r="29" stroke="#1E293B" stroke-width="8"/>
|
|
19
|
+
<path d="M79 79L99 99" stroke="#1E293B" stroke-width="9" stroke-linecap="round"/>
|
|
20
|
+
|
|
21
|
+
<!-- 赤陶红立体帆面 -->
|
|
22
|
+
<path d="M58 34L75 73L58 66L41 73L58 34Z" fill="url(#v2-red)"/>
|
|
23
|
+
</svg>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taxueseek/argo-dsh",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "Argo 阿尔戈 — DSH plugin:argo 原生搜索/抓取工具 + web_search seam + wide_research 编排;自带设置页(接入/工具/API 密钥/研究/高级);argo MCP 19 工具全量面按需挂载。安装:dsh plugin --profile web add @taxueseek/argo-dsh(或从 GitHub main 装:dsh plugin --profile web add \"github:taxueseek/argo#main&path:packages/dsh-plugin\")",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
"./dsh": "./dsh/index.js",
|
|
11
11
|
"./specs": "./dsh/specs.js",
|
|
12
12
|
"./client": "./dsh/client.js",
|
|
13
|
+
"./icon": "./icon.svg",
|
|
13
14
|
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
14
15
|
"./package.json": "./package.json"
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
17
18
|
"dsh",
|
|
19
|
+
"icon.svg",
|
|
18
20
|
"cordis.patch.yml",
|
|
19
21
|
"README.md"
|
|
20
22
|
],
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import test from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
import { EventEmitter } from 'node:events'
|
|
4
|
+
import { createWorkbenchHandler } from '../dsh/workbench.js'
|
|
5
|
+
|
|
6
|
+
function mockReq(method, url, bodyObj = null) {
|
|
7
|
+
const req = new EventEmitter()
|
|
8
|
+
req.method = method
|
|
9
|
+
req.url = url
|
|
10
|
+
req.headers = { host: '127.0.0.1:8080' }
|
|
11
|
+
queueMicrotask(() => {
|
|
12
|
+
if (bodyObj !== null) req.emit('data', Buffer.from(JSON.stringify(bodyObj)))
|
|
13
|
+
req.emit('end')
|
|
14
|
+
})
|
|
15
|
+
return req
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function mockRes() {
|
|
19
|
+
const headers = {}
|
|
20
|
+
let chunks = ''
|
|
21
|
+
return {
|
|
22
|
+
statusCode: 200,
|
|
23
|
+
writableEnded: false,
|
|
24
|
+
destroyed: false,
|
|
25
|
+
setHeader(k, v) { headers[k.toLowerCase()] = v },
|
|
26
|
+
end(data = '') {
|
|
27
|
+
chunks += String(data)
|
|
28
|
+
this.writableEnded = true
|
|
29
|
+
},
|
|
30
|
+
json() { return JSON.parse(chunks || '{}') },
|
|
31
|
+
text() { return chunks },
|
|
32
|
+
headers,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
test('workbench /argo/api/health exposes local mode, egoSearch and breaker summary', async () => {
|
|
37
|
+
const handler = createWorkbenchHandler({}, {}, () => ({}))
|
|
38
|
+
try {
|
|
39
|
+
const res = mockRes()
|
|
40
|
+
await handler(mockReq('GET', '/argo/api/health'), res)
|
|
41
|
+
assert.equal(res.statusCode, 200)
|
|
42
|
+
const data = res.json()
|
|
43
|
+
assert.equal(data.ok, true)
|
|
44
|
+
assert.ok(Array.isArray(data.modes))
|
|
45
|
+
assert.ok(data.modes.some(m => m.id === 'local'))
|
|
46
|
+
assert.ok(data.modes.some(m => m.id === 'plugin'))
|
|
47
|
+
assert.equal(typeof data.egoSearch?.enabled, 'boolean')
|
|
48
|
+
assert.equal(typeof data.breaker?.total, 'number')
|
|
49
|
+
} finally {
|
|
50
|
+
handler.dispose()
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('workbench serves workbench-client.js and rejects missing query on /argo/api/stream', async () => {
|
|
55
|
+
const handler = createWorkbenchHandler({}, {}, () => ({}))
|
|
56
|
+
try {
|
|
57
|
+
const resJs = mockRes()
|
|
58
|
+
await handler(mockReq('GET', '/argo/workbench-client.js'), resJs)
|
|
59
|
+
assert.equal(resJs.statusCode, 200)
|
|
60
|
+
assert.ok(resJs.text().includes('mountArgoWorkbench'))
|
|
61
|
+
|
|
62
|
+
const resErr = mockRes()
|
|
63
|
+
await handler(mockReq('GET', '/argo/api/stream?mode=plugin'), resErr)
|
|
64
|
+
assert.equal(resErr.statusCode, 400)
|
|
65
|
+
assert.equal(resErr.json().error, 'missing_query')
|
|
66
|
+
} finally {
|
|
67
|
+
handler.dispose()
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
test('workbench /argo/api/suggestions adapts to mode and DSH locale', async () => {
|
|
72
|
+
const handler = createWorkbenchHandler({}, {}, () => ({}))
|
|
73
|
+
try {
|
|
74
|
+
const resZh = mockRes()
|
|
75
|
+
await handler(mockReq('GET', '/argo/api/suggestions?mode=hotspot&lang=zh'), resZh)
|
|
76
|
+
assert.equal(resZh.statusCode, 200)
|
|
77
|
+
const zh = resZh.json()
|
|
78
|
+
assert.equal(zh.ok, true)
|
|
79
|
+
assert.equal(zh.lang, 'zh')
|
|
80
|
+
assert.ok(zh.items.length > 0)
|
|
81
|
+
|
|
82
|
+
const resEn = mockRes()
|
|
83
|
+
await handler(mockReq('GET', '/argo/api/suggestions?mode=plugin&lang=en'), resEn)
|
|
84
|
+
assert.equal(resEn.statusCode, 200)
|
|
85
|
+
const en = resEn.json()
|
|
86
|
+
assert.equal(en.ok, true)
|
|
87
|
+
assert.equal(en.lang, 'en')
|
|
88
|
+
assert.ok(en.items.some(it => it.tag === 'Mode'))
|
|
89
|
+
} finally {
|
|
90
|
+
handler.dispose()
|
|
91
|
+
}
|
|
92
|
+
})
|
package/scripts/argo_paths.py
CHANGED
|
@@ -14,8 +14,8 @@ health.db 等文件,测试也难以整体隔离。
|
|
|
14
14
|
- 各模块只声明「文件名」,不再各自拼目录
|
|
15
15
|
- `python3 scripts/argo_paths.py [--json]` 可打印关键路径的实际来源
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
注意:历史 User-Agent 里的邮箱标识与状态目录命名无关,不在此处管理;
|
|
18
|
+
UA 已收敛到 engines_http.UA 单源(2026-11-18)。
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
21
|
from __future__ import annotations
|
|
@@ -14,6 +14,14 @@ lessons(把反复出现的根因导成 LESSONS.md 格式的清单)。
|
|
|
14
14
|
仲裁);本账本只收纳「真实发生的失败」并让它们可归因、可回归——对应评测
|
|
15
15
|
体系的 badcase 管理环节:发现 → 入账 → 归因 → 修复后 check 不复发。
|
|
16
16
|
|
|
17
|
+
## 运行方式注记(2026-11-18 审计澄清)
|
|
18
|
+
|
|
19
|
+
`ingest` 是**手动/定期维护动作**(`python3 scripts/badcase_ledger.py ingest`),
|
|
20
|
+
不在搜索热路径自动执行——badcase.db 的时间戳停在最后一次 ingest 的日期属
|
|
21
|
+
正常形态,勿据此判「写入路径已断、模块已死」(2026-11-17 审计曾误判)。
|
|
22
|
+
本文件同时是静默吞异常棘轮基线(BROAD_SILENT_CATCH_BASELINE)的真源,删除
|
|
23
|
+
模块会连棘轮一起丢。
|
|
24
|
+
|
|
17
25
|
## 2026-11-10 补的归因层:root_cause + Seen N×
|
|
18
26
|
|
|
19
27
|
原实现只到「发现 → 入账」:`check` 数近 N 天新增坏例的**条数**,不看**根因
|
|
@@ -188,6 +196,7 @@ _DETAIL_RULES: tuple[tuple[str, str], ...] = (
|
|
|
188
196
|
_KIND_CAUSE: dict[str, str] = {
|
|
189
197
|
"recovery": ROOT_CAUSE_RECOVERY,
|
|
190
198
|
"breaker": ROOT_CAUSE_BREAKER,
|
|
199
|
+
"empty_result": ROOT_CAUSE_PARSE_EMPTY,
|
|
191
200
|
}
|
|
192
201
|
|
|
193
202
|
|
package/scripts/cache.py
CHANGED
|
@@ -250,7 +250,7 @@ class LRUCache:
|
|
|
250
250
|
class SQLiteCache:
|
|
251
251
|
"""SQLite 持久化缓存,支持 TTL 过期、大小限制、gzip 压缩。"""
|
|
252
252
|
|
|
253
|
-
SCHEMA_VERSION =
|
|
253
|
+
SCHEMA_VERSION = 3 # 2026-11-17 bump:加列/改表必须与 bump 同提交(加列不 bump+版本早退曾让旧库升级即炸,test_cache_schema_migration 锁)
|
|
254
254
|
|
|
255
255
|
def __init__(self, db_path: str = DEFAULT_DB_PATH, ttl: int = DEFAULT_TTL,
|
|
256
256
|
max_size_mb: float | None = None):
|
|
@@ -249,20 +249,33 @@ class CircuitBreaker:
|
|
|
249
249
|
self._mutate_locked(_key_healed)
|
|
250
250
|
return True, "auth_key_changed"
|
|
251
251
|
disabled_at = float(st.get("disabled_at") or 0)
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
last_probe = float(st.get("reenable_probed_at") or 0)
|
|
253
|
+
if max(disabled_at, last_probe) == 0 or \
|
|
254
|
+
(time.time() - max(disabled_at, last_probe)) >= DISABLE_COOLDOWN_SECONDS:
|
|
254
255
|
def _reenable_probe() -> None:
|
|
255
256
|
# 锁内重读后再改:_reload_engines 刚整体替换过
|
|
256
257
|
# self._engines,闭包里的旧 st 会把另一进程刚落盘的
|
|
257
258
|
# 状态盖回去(017b01a 修的那类丢更新在 allow() 的漏网处)。
|
|
258
259
|
fresh = self._engines.get(engine) or {}
|
|
259
260
|
fresh["state"] = engine_states.BREAKER_HALF_OPEN
|
|
260
|
-
fresh["
|
|
261
|
+
fresh["reenable_probed_at"] = time.time() # 不覆盖 disabled_at,防探测失败后 1h 内无法再 disabled
|
|
262
|
+
fresh["half_open_probe_at"] = time.time()
|
|
261
263
|
self._engines[engine] = fresh
|
|
262
264
|
self._mutate_locked(_reenable_probe)
|
|
263
265
|
return True, "half_open_reenable"
|
|
264
266
|
return False, "auto_disabled"
|
|
265
267
|
|
|
268
|
+
if state == engine_states.BREAKER_HALF_OPEN:
|
|
269
|
+
probe_at = float(st.get("half_open_probe_at") or 0)
|
|
270
|
+
if probe_at > 0 and (time.time() - probe_at) < min(OPEN_SECONDS, 30):
|
|
271
|
+
return False, "half_open_probe_busy"
|
|
272
|
+
def _claim_probe() -> None:
|
|
273
|
+
fresh = self._engines.get(engine) or {}
|
|
274
|
+
fresh["half_open_probe_at"] = time.time()
|
|
275
|
+
self._engines[engine] = fresh
|
|
276
|
+
self._mutate_locked(_claim_probe)
|
|
277
|
+
return True, engine_states.BREAKER_HALF_OPEN
|
|
278
|
+
|
|
266
279
|
if state == engine_states.BREAKER_OPEN:
|
|
267
280
|
# 冷却期已过 → half-open 探测(除非已连续多次 open 触发自动禁用)
|
|
268
281
|
if time.time() - opened_at >= OPEN_SECONDS:
|
package/scripts/config_cache.py
CHANGED
|
@@ -139,7 +139,7 @@ def _config_disk_cache_path() -> Path:
|
|
|
139
139
|
override = os.environ.get(argo_paths.ENV_STATE_DIR, "").strip()
|
|
140
140
|
root = (Path(os.path.expanduser(override)) if override
|
|
141
141
|
else argo_paths.legacy_root())
|
|
142
|
-
slot = hashlib.sha256(str(_config_path()).encode("utf-8")).hexdigest()[:16]
|
|
142
|
+
slot = hashlib.sha256(str(_config_path().resolve()).encode("utf-8")).hexdigest()[:16]
|
|
143
143
|
return root / f"config-cache-{slot}.json"
|
|
144
144
|
|
|
145
145
|
|
|
@@ -367,8 +367,9 @@ def _save_config_disk_cache(st: os.stat_result, scan: tuple[float, int, int, str
|
|
|
367
367
|
_sweep_orphan_cache_slots(path)
|
|
368
368
|
|
|
369
369
|
|
|
370
|
-
# 存活但陈旧 checkout 槽的回收阈值:槽 mtime = 该 checkout
|
|
371
|
-
_SLOT_STALE_S =
|
|
370
|
+
# 存活但陈旧 checkout 槽的回收阈值:槽 mtime = 该 checkout 最后一次加载配置(重建仅 16-50ms)。
|
|
371
|
+
_SLOT_STALE_S = 3 * 86400
|
|
372
|
+
_TMP_SLOT_STALE_S = 86400
|
|
372
373
|
|
|
373
374
|
|
|
374
375
|
def _sweep_orphan_cache_slots(keep: Path) -> None:
|
|
@@ -403,6 +404,15 @@ def _sweep_orphan_cache_slots(keep: Path) -> None:
|
|
|
403
404
|
keep_cfg = str(((keep_payload.get("key") or {}).get("config_path")) or "").strip()
|
|
404
405
|
except Exception:
|
|
405
406
|
pass
|
|
407
|
+
def _norm_cfg(raw: str) -> str:
|
|
408
|
+
if not raw:
|
|
409
|
+
return ""
|
|
410
|
+
try:
|
|
411
|
+
return str(Path(raw).resolve())
|
|
412
|
+
except OSError:
|
|
413
|
+
return raw
|
|
414
|
+
|
|
415
|
+
keep_cfg = _norm_cfg(keep_cfg)
|
|
406
416
|
for path in siblings:
|
|
407
417
|
if path == keep:
|
|
408
418
|
continue
|
|
@@ -412,22 +422,24 @@ def _sweep_orphan_cache_slots(keep: Path) -> None:
|
|
|
412
422
|
except (OSError, ValueError, AttributeError):
|
|
413
423
|
# 读不动或结构不认识:一律不动。判定不了就不删,是这里的保守选择。
|
|
414
424
|
continue
|
|
425
|
+
norm_cfg = _norm_cfg(cfg_path)
|
|
415
426
|
if cfg_path and not Path(cfg_path).exists():
|
|
416
427
|
try:
|
|
417
428
|
path.unlink()
|
|
418
429
|
except OSError:
|
|
419
430
|
continue
|
|
420
|
-
elif
|
|
421
|
-
#
|
|
431
|
+
elif norm_cfg and keep_cfg and norm_cfg == keep_cfg:
|
|
432
|
+
# 同一物理仓库(含 symlink / .. 相对路径)的历史槽且超 2h 未动:安全回收
|
|
422
433
|
try:
|
|
423
434
|
if (time.time() - path.stat().st_mtime) > 7200:
|
|
424
435
|
path.unlink()
|
|
425
436
|
except OSError:
|
|
426
437
|
pass
|
|
427
438
|
elif cfg_path:
|
|
428
|
-
# 存活但陈旧的 checkout
|
|
439
|
+
# 存活但陈旧的 checkout 槽(/tmp 或 ~/tmp 下 24h,其余 3 天)
|
|
440
|
+
ttl = _TMP_SLOT_STALE_S if ("/tmp/" in cfg_path or "\\tmp\\" in cfg_path) else _SLOT_STALE_S
|
|
429
441
|
try:
|
|
430
|
-
if (time.time() - path.stat().st_mtime) >
|
|
442
|
+
if (time.time() - path.stat().st_mtime) > ttl:
|
|
431
443
|
path.unlink()
|
|
432
444
|
except OSError:
|
|
433
445
|
pass
|
package/scripts/daemon.py
CHANGED
|
@@ -541,6 +541,11 @@ class _Server:
|
|
|
541
541
|
else:
|
|
542
542
|
resp = {"ok": False, "error": f"未知 op: {op!r}"}
|
|
543
543
|
except Exception as e:
|
|
544
|
+
# 错误级落日志:daemon.log 此前零错误行,进程级故障不可检
|
|
545
|
+
#(2026-11-18 可观测性审计盲区修复)。stdout 已被时间戳
|
|
546
|
+
# 包装器接住,print 即带 [ISO] 前缀落盘。
|
|
547
|
+
print(f"[ERROR] op={op!r} handler {type(e).__name__}: {e}",
|
|
548
|
+
file=sys.stderr)
|
|
544
549
|
resp = {"ok": False, "error": f"{type(e).__name__}: {e}"}
|
|
545
550
|
# sendall 用的超时与 recv 的那把(60s)分开,且以**客户端声明
|
|
546
551
|
# 的预算**为准:一笔 run 超过 60s 时 sendall 抛 socket.timeout
|
|
@@ -537,8 +537,11 @@ def run_dispatch(*, query: str, retrieval_query: str, engines: list[str],
|
|
|
537
537
|
outcome["status"] = _mapped
|
|
538
538
|
outcome["detail"] = _text or outcome.get("detail")
|
|
539
539
|
if _note:
|
|
540
|
-
#
|
|
541
|
-
# 事后只能看到 kind
|
|
540
|
+
# 归因随熔断状态一起持久化(「为什么坏」必须在失败现场写下来,
|
|
541
|
+
# 事后只能看到 kind 粗标签);原始 HTTP 状态码同时透传进 outcome,
|
|
542
|
+
# 台账结构化可检 403/404/429,不再只埋在 detail 自由文本里。
|
|
543
|
+
if _note.get("status"):
|
|
544
|
+
outcome["http_status"] = int(_note["status"])
|
|
542
545
|
try:
|
|
543
546
|
from engine_failure import from_note
|
|
544
547
|
_attr = from_note(_note, eng)
|
package/scripts/engine_env.py
CHANGED
|
@@ -165,7 +165,11 @@ def reset_envfile_cache() -> None:
|
|
|
165
165
|
_zhihu_keychain_cache = None
|
|
166
166
|
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
# (monotonic 读取时刻, 值)。非空值黏进程生命周期(envfile 写回 reset 时清除,
|
|
169
|
+
# 与密钥轮换联动);空值(Keychain 超时/未录入)只黏短 TTL——否则 daemon/MCP
|
|
170
|
+
# 长驻进程首次读失败(如安全弹窗未应答)会让知乎全族整进程判缺钥且无自愈。
|
|
171
|
+
_ZHIHU_KEYCHAIN_NEG_TTL_S = 60.0
|
|
172
|
+
_zhihu_keychain_cache: tuple[float, str] | None = None
|
|
169
173
|
|
|
170
174
|
|
|
171
175
|
def _decode_keyring_secret(raw: str) -> str:
|
|
@@ -180,9 +184,14 @@ def _decode_keyring_secret(raw: str) -> str:
|
|
|
180
184
|
def _read_zhihu_keychain() -> str:
|
|
181
185
|
"""跨平台读取系统凭证库中知乎官方 CLI 管理的 Access Secret(macOS Keychain / Linux secret-tool / Windows keyring)。"""
|
|
182
186
|
global _zhihu_keychain_cache
|
|
187
|
+
import time as _time
|
|
183
188
|
with _envfile_lock:
|
|
184
189
|
if _zhihu_keychain_cache is not None:
|
|
185
|
-
|
|
190
|
+
_ts, _val = _zhihu_keychain_cache
|
|
191
|
+
# 非空值长期有效;空值短 TTL 后重探(自愈对称:envfile 有签名
|
|
192
|
+
# 热读,keychain 也不能黏死)
|
|
193
|
+
if _val or (_time.monotonic() - _ts) < _ZHIHU_KEYCHAIN_NEG_TTL_S:
|
|
194
|
+
return _val
|
|
186
195
|
import shutil
|
|
187
196
|
import sys
|
|
188
197
|
val = ""
|
|
@@ -210,8 +219,8 @@ def _read_zhihu_keychain() -> str:
|
|
|
210
219
|
except Exception:
|
|
211
220
|
val = ""
|
|
212
221
|
with _envfile_lock:
|
|
213
|
-
_zhihu_keychain_cache = val
|
|
214
|
-
return
|
|
222
|
+
_zhihu_keychain_cache = (_time.monotonic(), val)
|
|
223
|
+
return val
|
|
215
224
|
|
|
216
225
|
# 引擎 → 候选环境变量(从左到右优先)
|
|
217
226
|
# 第一项为推荐新名(ARGO_ 前缀),后续为历史兼容名
|
package/scripts/engines_base.py
CHANGED
|
@@ -14,6 +14,8 @@ import subprocess
|
|
|
14
14
|
import sys
|
|
15
15
|
import threading
|
|
16
16
|
import engine_states as _st # 失败归因词表唯一真源
|
|
17
|
+
# UA 与礼貌池邮箱单源(engines_http 顶层无反向依赖,不成环)
|
|
18
|
+
from engines_http import UA, contact_email as _contact_email, normalize_ua_headers
|
|
17
19
|
from engines_fields import _coerce_field # 字段取值原语真源在 engines_fields(无依赖底层),本模块复导出
|
|
18
20
|
|
|
19
21
|
import serp_kill_log # noqa: E402 守卫接线+误杀账本(2026-10-10 拆出,stdlib 级轻量)
|
|
@@ -81,12 +83,15 @@ except Exception: # pragma: no cover - archive_run 不可用时退化为基本
|
|
|
81
83
|
return text
|
|
82
84
|
|
|
83
85
|
|
|
84
|
-
def note_failure(engine: str, category: str, reason: str, detail: str = ""
|
|
86
|
+
def note_failure(engine: str, category: str, reason: str, detail: str = "",
|
|
87
|
+
status: int | None = None) -> None:
|
|
85
88
|
"""记录引擎最近一次失败的归因(覆盖式:只留最后一次)。
|
|
86
89
|
|
|
87
90
|
detail 在写入前脱敏:这里聚合了引擎名、状态码与**响应体**,是唯一能把
|
|
88
91
|
上游回显的凭证带进持久化状态的位置(会写进 circuit_breaker.json 并出现在
|
|
89
92
|
--list-engines 输出)。脱敏在唯一的写入点做,消费者无需各自处理。
|
|
93
|
+
status:原始 HTTP 状态码(可选)。透传进 outcome 后台账可结构化检索
|
|
94
|
+
403/404/429,不再只埋在 reason 自由文本里。
|
|
90
95
|
"""
|
|
91
96
|
if not engine:
|
|
92
97
|
return
|
|
@@ -96,6 +101,7 @@ def note_failure(engine: str, category: str, reason: str, detail: str = "") -> N
|
|
|
96
101
|
"reason": reason,
|
|
97
102
|
"detail": _redact_secrets(detail or "")[:200],
|
|
98
103
|
"ts": time.time(),
|
|
104
|
+
**({"status": int(status)} if status else {}),
|
|
99
105
|
}
|
|
100
106
|
|
|
101
107
|
|
|
@@ -361,6 +367,8 @@ def _build_http_engine(spec: dict[str, Any]) -> Any:
|
|
|
361
367
|
"""
|
|
362
368
|
url_template = spec.get("url", "")
|
|
363
369
|
headers = spec.get("headers", {"Content-Type": "application/json"})
|
|
370
|
+
# UA 单源归一:spec 手抄版本号字面量统一指向 engines_http.UA
|
|
371
|
+
headers = normalize_ua_headers(headers)
|
|
364
372
|
query_param = spec.get("query_param", "q")
|
|
365
373
|
fmt = spec.get("format", "")
|
|
366
374
|
# format 的双重身份:它本来是**解析提示**(_parse_http_payload 用它区分
|
|
@@ -407,6 +415,12 @@ def _build_http_engine(spec: dict[str, Any]) -> Any:
|
|
|
407
415
|
# 语言参数动态化(v2.7):按查询主语言覆盖静态 setlang/hl/lang/mkt
|
|
408
416
|
if k in ("setlang", "hl", "lang", "uselang", "mkt"):
|
|
409
417
|
v = _lang_param(k, query) or v
|
|
418
|
+
if k == "mailto":
|
|
419
|
+
# 礼貌池联系方式运行时注入(ARGO_CONTACT_EMAIL);未配置则
|
|
420
|
+
# 参数不发送——发保留域假邮箱会被降权,不发只降级为普通池
|
|
421
|
+
v = _contact_email()
|
|
422
|
+
if not v:
|
|
423
|
+
continue
|
|
410
424
|
parts.append(f"{k}={up.quote(_resolve(str(v), query, n, allowed_env=_allowed, **kwargs))}")
|
|
411
425
|
if parts:
|
|
412
426
|
separator = "&" if "?" in resolved_url else "?"
|
|
@@ -539,11 +553,12 @@ def _note_http_failure(engine: str, status: int, body: str) -> None:
|
|
|
539
553
|
try:
|
|
540
554
|
from engine_failure import classify
|
|
541
555
|
except ImportError: # 模块缺失时退化为最小事实,不猜类别
|
|
542
|
-
note_failure(engine, _st.FAILURE_UNKNOWN, f"http-{status}",
|
|
556
|
+
note_failure(engine, _st.FAILURE_UNKNOWN, f"http-{status}",
|
|
557
|
+
(body or "")[:120], status=status)
|
|
543
558
|
return
|
|
544
559
|
res = classify(status_code=status, output=(body or "")[:2000])
|
|
545
560
|
note_failure(engine, res["category"], res["reason"],
|
|
546
|
-
res.get("evidence") or (body or "")[:120])
|
|
561
|
+
res.get("evidence") or (body or "")[:120], status=status)
|
|
547
562
|
|
|
548
563
|
|
|
549
564
|
@contextmanager
|
|
@@ -910,6 +925,7 @@ def _build_html_engine(spec: dict[str, Any]) -> Any:
|
|
|
910
925
|
}
|
|
911
926
|
# 覆盖自定义 headers
|
|
912
927
|
headers.update(spec.get("headers", {}))
|
|
928
|
+
headers = normalize_ua_headers(headers) # UA 单源归一:同 _build_http_engine
|
|
913
929
|
query_param = spec.get("query_param", "q")
|
|
914
930
|
timeout = spec.get("timeout", 8)
|
|
915
931
|
extra_params = spec.get("extra_params", {})
|
|
@@ -950,6 +966,11 @@ def _build_html_engine(spec: dict[str, Any]) -> Any:
|
|
|
950
966
|
# 语言参数动态化:按查询主语言覆盖 setlang/hl/lang/mkt(此前漏 mkt)
|
|
951
967
|
if k in ("setlang", "hl", "lang", "uselang", "mkt"):
|
|
952
968
|
v = _lang_param(k, query) or v
|
|
969
|
+
if k == "mailto":
|
|
970
|
+
# 礼貌池联系方式运行时注入;未配置不发送(同 _build_http_engine)
|
|
971
|
+
v = _contact_email()
|
|
972
|
+
if not v:
|
|
973
|
+
continue
|
|
953
974
|
full_url += f"&{k}={up.quote(_resolve(str(v), query, n, allowed_env=_allowed, **kwargs))}" # **kwargs 必传(声明式路径 :441 传了):否则 {MODE}/{DEPTH} 带字面量花括号进 URL
|
|
954
975
|
resolved_headers = {
|
|
955
976
|
k: v for k, v in (
|
|
@@ -15,6 +15,7 @@ import urllib.request
|
|
|
15
15
|
from datetime import datetime
|
|
16
16
|
from typing import Any
|
|
17
17
|
|
|
18
|
+
from engines_http import UA
|
|
18
19
|
from engines_base import (
|
|
19
20
|
rank_score,
|
|
20
21
|
safe_search, _detect_anti_bot,
|
|
@@ -87,7 +88,7 @@ def _build_courtlistener_engine(spec: dict[str, Any]) -> Any:
|
|
|
87
88
|
注意 2026-05 起限额骤降(免费档约 5 次/分、125 次/天),qps 已压到 1。
|
|
88
89
|
"""
|
|
89
90
|
timeout = spec.get("timeout", 12)
|
|
90
|
-
_HEADERS = {"User-Agent":
|
|
91
|
+
_HEADERS = {"User-Agent": UA, "Accept": "application/json"}
|
|
91
92
|
|
|
92
93
|
@safe_search
|
|
93
94
|
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
@@ -135,7 +136,7 @@ def _build_gutenberg_engine(spec: dict[str, Any]) -> Any:
|
|
|
135
136
|
返回书名/作者/语言与 Gutenberg 书目页链接;Gutenberg 提供结构化全文。
|
|
136
137
|
"""
|
|
137
138
|
timeout = spec.get("timeout", 15)
|
|
138
|
-
_HEADERS = {"User-Agent":
|
|
139
|
+
_HEADERS = {"User-Agent": UA, "Accept": "application/json"}
|
|
139
140
|
|
|
140
141
|
@safe_search
|
|
141
142
|
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
@@ -188,7 +189,7 @@ def _build_wayback_cdx_engine(spec: dict[str, Any]) -> Any:
|
|
|
188
189
|
输入域名/URL,返回历史快照时间戳与状态码,是查已删除页面的唯一路径。
|
|
189
190
|
"""
|
|
190
191
|
timeout = spec.get("timeout", 20)
|
|
191
|
-
_HEADERS = {"User-Agent":
|
|
192
|
+
_HEADERS = {"User-Agent": UA, "Accept": "application/json"}
|
|
192
193
|
|
|
193
194
|
@safe_search
|
|
194
195
|
def _engine(query: str, n: int = 5, _timeout: float | None = None, **kwargs) -> list[dict[str, Any]]:
|
|
@@ -21,6 +21,7 @@ import urllib.parse
|
|
|
21
21
|
import urllib.request
|
|
22
22
|
from typing import Any
|
|
23
23
|
|
|
24
|
+
from engines_http import UA
|
|
24
25
|
from engines_base import (
|
|
25
26
|
finalize_image_fields,
|
|
26
27
|
rank_score,
|
|
@@ -33,7 +34,7 @@ from engines_http import lazy_logger
|
|
|
33
34
|
|
|
34
35
|
logger = lazy_logger()
|
|
35
36
|
|
|
36
|
-
_UA =
|
|
37
|
+
_UA = UA
|
|
37
38
|
_API = "https://commons.wikimedia.org/w/api.php"
|
|
38
39
|
|
|
39
40
|
# Commons 的 extmetadata 是一层「字段 → {value, source, hidden}」的包装,
|
|
@@ -19,6 +19,7 @@ import time
|
|
|
19
19
|
import urllib.request
|
|
20
20
|
from typing import Any
|
|
21
21
|
|
|
22
|
+
from engines_http import UA, UA_EDGAR
|
|
22
23
|
from engines_base import http_open, safe_search
|
|
23
24
|
|
|
24
25
|
|
|
@@ -140,7 +141,7 @@ def _sec_cf_ticker_map(to: float, state_dir: str = "") -> dict[str, str]:
|
|
|
140
141
|
pass
|
|
141
142
|
try:
|
|
142
143
|
req = urllib.request.Request("https://www.sec.gov/files/company_tickers.json",
|
|
143
|
-
headers={"User-Agent":
|
|
144
|
+
headers={"User-Agent": UA_EDGAR,
|
|
144
145
|
"Accept": "application/json"})
|
|
145
146
|
with http_open(req, timeout=max(to, 10), engine="sec_companyfacts") as resp:
|
|
146
147
|
raw = json.loads(resp.read().decode("utf-8", "replace"))
|
|
@@ -186,7 +187,7 @@ def _build_sec_companyfacts_engine(spec: dict[str, Any]) -> Any:
|
|
|
186
187
|
全文回答「哪些文件提到 X」,本引擎回答「这家公司历年财务数字」。
|
|
187
188
|
"""
|
|
188
189
|
timeout = spec.get("timeout", 15)
|
|
189
|
-
ua =
|
|
190
|
+
ua = UA_EDGAR
|
|
190
191
|
|
|
191
192
|
def _ticker_candidates(query: str) -> list[str]:
|
|
192
193
|
q = (query or "").strip()
|
|
@@ -314,7 +315,7 @@ def _build_frankfurter_engine(spec: dict[str, Any]) -> Any:
|
|
|
314
315
|
+ up.urlencode({"base": base, "symbols": ",".join(symbols)}))
|
|
315
316
|
try:
|
|
316
317
|
req = urllib.request.Request(url, headers={
|
|
317
|
-
"User-Agent":
|
|
318
|
+
"User-Agent": UA,
|
|
318
319
|
"Accept": "application/json"})
|
|
319
320
|
with http_open(req, timeout=to, engine=spec.get("_name", "")) as resp:
|
|
320
321
|
data = json.loads(resp.read().decode("utf-8", "replace"))
|
|
@@ -28,9 +28,10 @@ import urllib.request
|
|
|
28
28
|
from datetime import datetime, timedelta, timezone
|
|
29
29
|
from typing import Any
|
|
30
30
|
|
|
31
|
+
from engines_http import UA
|
|
31
32
|
from engines_base import http_open, safe_search
|
|
32
33
|
|
|
33
|
-
_UA =
|
|
34
|
+
_UA = UA
|
|
34
35
|
_CST = timezone(timedelta(hours=8)) # 三个中国市场源都按北京时间取「今天」
|
|
35
36
|
|
|
36
37
|
|
|
@@ -41,9 +41,10 @@ import urllib.request
|
|
|
41
41
|
from datetime import datetime, timedelta, timezone
|
|
42
42
|
from typing import Any
|
|
43
43
|
|
|
44
|
+
from engines_http import UA
|
|
44
45
|
from engines_base import http_open, note_failure, safe_search
|
|
45
46
|
|
|
46
|
-
_UA =
|
|
47
|
+
_UA = UA
|
|
47
48
|
_YUANBAO_URL = "https://api.wsa.cloud.tencent.com/SearchPro"
|
|
48
49
|
# 腾讯侧公布的中间价/新闻口径都按北京时间;本机可能不在东八区,日期归一
|
|
49
50
|
# 必须显式指定偏移,否则跨时区机器上「今天」会错一天。
|
|
@@ -49,14 +49,14 @@ from engines_base import (
|
|
|
49
49
|
)
|
|
50
50
|
|
|
51
51
|
from engines_http import (
|
|
52
|
-
http_json as _shared_http_json,
|
|
52
|
+
UA, http_json as _shared_http_json,
|
|
53
53
|
http_text as _shared_http_text,
|
|
54
54
|
lazy_logger,
|
|
55
55
|
)
|
|
56
56
|
|
|
57
57
|
logger = lazy_logger()
|
|
58
58
|
|
|
59
|
-
_UA =
|
|
59
|
+
_UA = UA
|
|
60
60
|
|
|
61
61
|
# e-Gov 法令列表进程内缓存(体积大、变动低频)
|
|
62
62
|
_EGOV_ENTRIES: list[str] | None = None
|
|
@@ -15,7 +15,7 @@ from typing import Any
|
|
|
15
15
|
|
|
16
16
|
from engine_env import get_env
|
|
17
17
|
|
|
18
|
-
from engines_base import safe_search, _run, _resolve, _get_path, _coerce_field, _http_get_raw, http_open, rank_score
|
|
18
|
+
from engines_base import safe_search, _run, _resolve, _get_path, _coerce_field, _http_get_raw, http_open, rank_score, UA
|
|
19
19
|
|
|
20
20
|
logger = logging.getLogger("unified_search.engines")
|
|
21
21
|
|
|
@@ -204,7 +204,7 @@ def _build_em_miaoxiang_engine(spec: dict[str, Any]) -> Any:
|
|
|
204
204
|
headers={
|
|
205
205
|
"apikey": key,
|
|
206
206
|
"Content-Type": "application/json",
|
|
207
|
-
"User-Agent":
|
|
207
|
+
"User-Agent": UA,
|
|
208
208
|
},
|
|
209
209
|
)
|
|
210
210
|
try:
|
|
@@ -979,7 +979,7 @@ def _build_zhihu_global_engine(spec: dict[str, Any]) -> Any:
|
|
|
979
979
|
"Authorization": f"Bearer {secret}",
|
|
980
980
|
"X-Request-Timestamp": str(int(time.time())),
|
|
981
981
|
"Content-Type": "application/json",
|
|
982
|
-
"User-Agent":
|
|
982
|
+
"User-Agent": UA,
|
|
983
983
|
}
|
|
984
984
|
try:
|
|
985
985
|
with http_open(urllib.request.Request(url, headers=headers), timeout=to, engine=spec.get("_name", "")) as resp:
|
|
@@ -1116,7 +1116,7 @@ def _build_zhihu_user_engine(spec: dict[str, Any]) -> Any:
|
|
|
1116
1116
|
"Authorization": f"Bearer {secret}",
|
|
1117
1117
|
"X-Request-Timestamp": str(int(time.time())),
|
|
1118
1118
|
"Content-Type": "application/json",
|
|
1119
|
-
"User-Agent":
|
|
1119
|
+
"User-Agent": UA,
|
|
1120
1120
|
}
|
|
1121
1121
|
try:
|
|
1122
1122
|
with http_open(urllib.request.Request(url, headers=headers), timeout=to, engine=spec.get("_name", "")) as resp:
|
|
@@ -1349,7 +1349,7 @@ def _build_std_samr_engine(spec: dict[str, Any]) -> Any:
|
|
|
1349
1349
|
to = _timeout or timeout
|
|
1350
1350
|
url = ("https://std.samr.gov.cn/gb/search/gbQueryPage"
|
|
1351
1351
|
f"?searchText={urllib.parse.quote(q)}&pageNumber=1&pageSize={min(max(int(n), 1), 50)}")
|
|
1352
|
-
raw = _http_get_raw(url, {"User-Agent":
|
|
1352
|
+
raw = _http_get_raw(url, {"User-Agent": UA, "Accept": "application/json"},
|
|
1353
1353
|
to, engine=spec.get("_name", "std_samr"))
|
|
1354
1354
|
if raw is None:
|
|
1355
1355
|
return []
|
|
@@ -1752,7 +1752,7 @@ def _build_people_daily_engine(spec: dict[str, Any]) -> Any:
|
|
|
1752
1752
|
"hasTitle": True, "hasContent": True, "isFuzzy": True,
|
|
1753
1753
|
"type": 0, "sortType": 2, "startTime": 0, "endTime": 0,
|
|
1754
1754
|
}).encode("utf-8"),
|
|
1755
|
-
headers={"Content-Type": "application/json", "User-Agent":
|
|
1755
|
+
headers={"Content-Type": "application/json", "User-Agent": UA},
|
|
1756
1756
|
method="POST",
|
|
1757
1757
|
)
|
|
1758
1758
|
try:
|
|
@@ -1888,7 +1888,7 @@ def _build_wikisource_engine(spec: dict[str, Any]) -> Any:
|
|
|
1888
1888
|
to = _timeout or timeout
|
|
1889
1889
|
url = ("https://zh.wikisource.org/w/api.php?action=query&format=json&list=search"
|
|
1890
1890
|
f"&srsearch={urllib.parse.quote(q)}&srlimit={min(max(int(n), 1), 20)}")
|
|
1891
|
-
raw = _http_get_raw(url, {"User-Agent":
|
|
1891
|
+
raw = _http_get_raw(url, {"User-Agent": UA, "Accept": "application/json"},
|
|
1892
1892
|
to, engine=spec.get("_name", "wikisource"))
|
|
1893
1893
|
if raw is None:
|
|
1894
1894
|
return []
|