argo-search 2.10.0 → 2.10.2
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/README.en.md +50 -10
- package/README.es.md +49 -9
- package/README.ja.md +50 -10
- package/README.ko.md +50 -10
- package/README.md +50 -30
- package/SKILL.md +11 -10
- package/backends/concept_vectors.bin +0 -0
- package/backends/engine_concept_vectors.json +3104 -0
- package/backends/engine_registry.yaml +2 -2
- package/backends/source_types_cn.json +9 -0
- package/config.yaml +105 -24
- package/docs/ENGINE_CATALOG.md +8 -8
- package/docs/RELEASE_NOTES_v2.10.1.md +57 -0
- package/docs/RELEASE_NOTES_v2.10.2.md +48 -0
- package/engines/_template_http.yaml +2 -0
- package/engines/specs/ncpssd.yaml +3 -0
- package/engines/specs/sciverse.yaml +1 -0
- package/package.json +4 -2
- package/packages/dsh-plugin/dsh/diagnostics.js +8 -3
- package/packages/dsh-plugin/dsh/index.js +7 -7
- package/packages/dsh-plugin/dsh/runner.js +72 -46
- package/packages/dsh-plugin/package.json +1 -1
- package/packages/dsh-plugin/test/index.test.js +43 -0
- package/scripts/argo_engine_registry.py +30 -4
- package/scripts/argo_paths.py +7 -1
- package/scripts/build_concept_table.py +612 -0
- package/scripts/build_route_labels.py +285 -0
- package/scripts/caliber_dedupe.py +66 -0
- package/scripts/caliber_isolation.py +4 -2
- package/scripts/ci_drift_gate.py +47 -24
- package/scripts/circuit_breaker.py +25 -3
- package/scripts/concept_lookup.py +212 -0
- package/scripts/engine_dispatch.py +6 -8
- package/scripts/engine_status.py +12 -5
- package/scripts/engines.py +29 -7
- package/scripts/engines_base.py +48 -17
- package/scripts/engines_builders_data.py +10 -3
- package/scripts/engines_builders_skill.py +87 -10
- package/scripts/evidence.py +26 -5
- package/scripts/extend_route_labels.py +239 -0
- package/scripts/extend_route_labels_by_capability.py +344 -0
- package/scripts/gen_routing_snapshot.py +22 -3
- package/scripts/lang_detect.py +12 -3
- package/scripts/local_seek.py +66 -14
- package/scripts/mcp_transport.py +1 -1
- package/scripts/numeric_verify.py +330 -0
- package/scripts/plan.py +25 -4
- package/scripts/pre-commit +2 -2
- package/scripts/rank_signals.py +48 -4
- package/scripts/ranking_eval.py +23 -1
- package/scripts/regression_p0p1.py +7 -2
- package/scripts/release.py +398 -0
- package/scripts/route.py +24 -3
- package/scripts/route_accuracy_eval.py +191 -0
- package/scripts/route_combo.py +32 -1
- package/scripts/route_domains.py +258 -5
- package/scripts/route_primary.py +101 -0
- package/scripts/search.py +5 -2
- package/scripts/search_cli.py +111 -7
- package/scripts/search_output.py +73 -1
- package/scripts/search_pipeline.py +9 -2
- package/scripts/search_rank.py +3 -1
- package/scripts/serp_guard.py +11 -0
- package/scripts/snippet_clean.py +60 -0
- package/scripts/social_engines/twitter_engine.py +127 -43
- package/scripts/social_engines/xiaohongshu_engine.py +11 -1
- package/scripts/tfidf_router.py +52 -2
- package/scripts/train.py +15 -0
- package/scripts/url_canon.py +2 -1
- package/scripts/verify_with.py +124 -0
- package/scripts/video_route.py +3 -3
- package/sub-skills/local-search/SKILL.md +3 -2
- package/sub-skills/local-search/bm25.py +89 -8
- package/sub-skills/local-search/config.yaml +12 -0
- package/sub-skills/local-search/parse_maps.yaml +8 -0
- package/sub-skills/local-search/parsers.py +5 -2
- package/sub-skills/local-search/search_v3.py +87 -1
- package/sub-skills/local-search/smart_router.py +1 -1
- package/sub-skills/local-seek/SKILL.md +6 -5
- package/sub-skills/local-seek/scripts/eval_rank.py +1 -1
- package/sub-skills/local-seek/scripts/seek.py +171 -40
- package/sub-skills/local-seek/scripts/seek_rank.py +191 -11
- package/engines/specs/_cisa_kev.yaml +0 -54
- package/engines/specs/_osv.yaml +0 -63
- package/scripts/image_vision/vision_probe +0 -0
|
@@ -8,18 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { spawn } from 'node:child_process'
|
|
11
|
-
import {
|
|
11
|
+
import { createRequire } from 'node:module'
|
|
12
12
|
import { homedir } from 'node:os'
|
|
13
13
|
import { dirname, join } from 'node:path'
|
|
14
14
|
import { fileURLToPath } from 'node:url'
|
|
15
15
|
import { NATIVE_TOOLS as NATIVE_TOOL_SPECS } from './native-tools.mjs'
|
|
16
16
|
|
|
17
|
+
const require = createRequire(import.meta.url)
|
|
18
|
+
|
|
17
19
|
function resolvePluginVersion() {
|
|
18
20
|
try {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const parsed = JSON.parse(raw)
|
|
22
|
-
if (typeof parsed?.version === 'string' && parsed.version !== '') return parsed.version
|
|
21
|
+
const pkg = require('../package.json')
|
|
22
|
+
if (typeof pkg?.version === 'string' && pkg.version !== '') return pkg.version
|
|
23
23
|
} catch { /* 打包裁剪/权限异常:回退,不阻断插件加载 */ }
|
|
24
24
|
return '0.0.0-unknown'
|
|
25
25
|
}
|
|
@@ -124,9 +124,18 @@ export function dropFromPool(conn) {
|
|
|
124
124
|
if (index >= 0) mcpPool.splice(index, 1)
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
function computeConfigKey(options = {}) {
|
|
128
|
+
const cmd = String(options.command ?? '')
|
|
129
|
+
const args = Array.isArray(options.args) ? options.args.join('\0') : ''
|
|
130
|
+
const argoEnv = Array.isArray(options.config?.argoEnv) ? options.config.argoEnv.join('\0') : ''
|
|
131
|
+
return `${cmd}\0${args}\0${argoEnv}`
|
|
132
|
+
}
|
|
133
|
+
|
|
127
134
|
export function createMcpConnection(options) {
|
|
128
|
-
const { command, args, idleMs, env } = options
|
|
135
|
+
const { command, args, idleMs, env, envResolver } = options
|
|
136
|
+
const configKey = options.configKey ?? computeConfigKey(options)
|
|
129
137
|
let proc = null
|
|
138
|
+
let initPromise = null
|
|
130
139
|
let buffer = ''
|
|
131
140
|
let nextId = 1
|
|
132
141
|
let chain = Promise.resolve()
|
|
@@ -146,6 +155,7 @@ export function createMcpConnection(options) {
|
|
|
146
155
|
const close = () => {
|
|
147
156
|
if (disposed) return
|
|
148
157
|
disposed = true
|
|
158
|
+
initPromise = null
|
|
149
159
|
if (idleTimer !== null) clearTimeout(idleTimer)
|
|
150
160
|
if (proc !== null) {
|
|
151
161
|
try { proc.kill() } catch { /* already gone */ }
|
|
@@ -199,44 +209,50 @@ export function createMcpConnection(options) {
|
|
|
199
209
|
}
|
|
200
210
|
|
|
201
211
|
const conn = {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
buffer
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
212
|
+
configKey,
|
|
213
|
+
initialize: (timeoutMs = 0) => {
|
|
214
|
+
if (initPromise !== null) return initPromise
|
|
215
|
+
initPromise = (async () => {
|
|
216
|
+
const spawnEnv = env !== undefined ? env : (typeof envResolver === 'function' ? await envResolver() : undefined)
|
|
217
|
+
if (disposed) throw argoAborted()
|
|
218
|
+
proc = spawn(command, args, { stdio: ['pipe', 'pipe', 'pipe'], env: spawnEnv ?? process.env })
|
|
219
|
+
proc.on('error', () => close())
|
|
220
|
+
proc.on('exit', () => close())
|
|
221
|
+
proc.stderr.on('data', () => { /* 预热日志忽略 */ })
|
|
222
|
+
proc.stdout.setEncoding('utf8')
|
|
223
|
+
proc.stdout.on('data', (chunk) => {
|
|
224
|
+
buffer += chunk
|
|
225
|
+
let nl
|
|
226
|
+
while ((nl = buffer.indexOf('\n')) >= 0) {
|
|
227
|
+
const line = buffer.slice(0, nl).trim()
|
|
228
|
+
buffer = buffer.slice(nl + 1)
|
|
229
|
+
if (line === '') continue
|
|
230
|
+
let msg
|
|
231
|
+
try {
|
|
232
|
+
msg = JSON.parse(line)
|
|
233
|
+
} catch {
|
|
234
|
+
continue
|
|
235
|
+
}
|
|
236
|
+
const entry = pending.get(msg.id)
|
|
237
|
+
if (entry === undefined) continue
|
|
238
|
+
pending.delete(msg.id)
|
|
239
|
+
if (msg.error !== undefined) entry.rej(new Error(msg.error.message ?? 'argo MCP error'))
|
|
240
|
+
else entry.res(msg.result)
|
|
221
241
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
clientInfo: { name: 'argo-dsh', version: PLUGIN_VERSION }
|
|
237
|
-
}, timeoutMs)
|
|
238
|
-
conn.notify('notifications/initialized', {})
|
|
239
|
-
return init
|
|
242
|
+
})
|
|
243
|
+
await new Promise((res, rej) => {
|
|
244
|
+
proc.once('spawn', res)
|
|
245
|
+
proc.once('error', rej)
|
|
246
|
+
})
|
|
247
|
+
const init = await send('initialize', {
|
|
248
|
+
protocolVersion: '2025-06-18',
|
|
249
|
+
capabilities: {},
|
|
250
|
+
clientInfo: { name: 'argo-dsh', version: PLUGIN_VERSION }
|
|
251
|
+
}, timeoutMs)
|
|
252
|
+
conn.notify('notifications/initialized', {})
|
|
253
|
+
return init
|
|
254
|
+
})()
|
|
255
|
+
return initPromise
|
|
240
256
|
},
|
|
241
257
|
request: (method, params, timeoutMs = 0) => {
|
|
242
258
|
if (claims > 0) claims -= 1
|
|
@@ -285,7 +301,14 @@ export function initializeWithSignal(conn, initMs, signal) {
|
|
|
285
301
|
export async function acquireMcp(options, signal) {
|
|
286
302
|
const max = Math.max(1, Number(options.max) || DEFAULTS.searchConcurrency)
|
|
287
303
|
const initMs = Math.max(0, Number(options.initMs) || 0)
|
|
288
|
-
const
|
|
304
|
+
const targetConfigKey = computeConfigKey(options)
|
|
305
|
+
for (const entry of [...mcpPool]) {
|
|
306
|
+
if (entry.load() === 0 && entry.configKey !== undefined && entry.configKey !== targetConfigKey) {
|
|
307
|
+
dropFromPool(entry)
|
|
308
|
+
entry.close()
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
const idle = mcpPool.find(entry => entry.load() === 0 && (entry.configKey === undefined || entry.configKey === targetConfigKey))
|
|
289
312
|
if (idle !== undefined) {
|
|
290
313
|
idle.claim()
|
|
291
314
|
try {
|
|
@@ -298,8 +321,11 @@ export async function acquireMcp(options, signal) {
|
|
|
298
321
|
}
|
|
299
322
|
}
|
|
300
323
|
if (mcpPool.length < max) {
|
|
301
|
-
const
|
|
302
|
-
|
|
324
|
+
const conn = createMcpConnection({
|
|
325
|
+
...options,
|
|
326
|
+
envResolver: () => resolveEnv(options),
|
|
327
|
+
configKey: targetConfigKey,
|
|
328
|
+
})
|
|
303
329
|
mcpPool.push(conn)
|
|
304
330
|
conn.claim()
|
|
305
331
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taxueseek/argo-dsh",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.2",
|
|
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",
|
|
@@ -1380,3 +1380,46 @@ test('makeNativeTool: WEB_ABORTED from pool is rethrown without falling back to
|
|
|
1380
1380
|
)
|
|
1381
1381
|
assert.equal(spawned, 0, '主动取消不得回退单发重跑')
|
|
1382
1382
|
})
|
|
1383
|
+
|
|
1384
|
+
test('pool: concurrent callers sharing a single connection coalesce initialize handshake', async () => {
|
|
1385
|
+
stubEnv({ ARGO_STUB_DELAY_MS: '30' })
|
|
1386
|
+
const tool = stubTool({ searchConcurrency: 1, searchIdleMs: 1000 })
|
|
1387
|
+
const [r1, r2] = await Promise.all([
|
|
1388
|
+
tool.execute({ query: 'concurrent-1' }),
|
|
1389
|
+
tool.execute({ query: 'concurrent-2' }),
|
|
1390
|
+
])
|
|
1391
|
+
assert.equal(tool.output.render({}, r1)[0].text, 'pooled-ok')
|
|
1392
|
+
assert.equal(tool.output.render({}, r2)[0].text, 'pooled-ok')
|
|
1393
|
+
assert.equal(spawnCount(), 1, '并发共享单连接时 initialize 应合并,只启动一个子进程')
|
|
1394
|
+
})
|
|
1395
|
+
|
|
1396
|
+
test('pool: changing argoEnv evicts idle connection with stale configKey', async () => {
|
|
1397
|
+
stubEnv()
|
|
1398
|
+
const tool1 = makeNativeTool(
|
|
1399
|
+
{
|
|
1400
|
+
searchCommand: process.execPath,
|
|
1401
|
+
searchArgs: [STUB_SERVER],
|
|
1402
|
+
searchConcurrency: 1,
|
|
1403
|
+
searchIdleMs: 5000,
|
|
1404
|
+
argoEnv: ['ARGO_PAID_SEARCH=off'],
|
|
1405
|
+
},
|
|
1406
|
+
'argo_search',
|
|
1407
|
+
{ mcpCall: nativeViaMcpPool },
|
|
1408
|
+
)
|
|
1409
|
+
await tool1.execute({ query: 'before-preset' })
|
|
1410
|
+
assert.equal(spawnCount(), 1)
|
|
1411
|
+
const tool2 = makeNativeTool(
|
|
1412
|
+
{
|
|
1413
|
+
searchCommand: process.execPath,
|
|
1414
|
+
searchArgs: [STUB_SERVER],
|
|
1415
|
+
searchConcurrency: 1,
|
|
1416
|
+
searchIdleMs: 5000,
|
|
1417
|
+
argoEnv: ['ARGO_PAID_SEARCH=auto'],
|
|
1418
|
+
},
|
|
1419
|
+
'argo_search',
|
|
1420
|
+
{ mcpCall: nativeViaMcpPool },
|
|
1421
|
+
)
|
|
1422
|
+
await tool2.execute({ query: 'after-preset' })
|
|
1423
|
+
assert.equal(spawnCount(), 2, 'argoEnv 变更后空闲旧连接应被淘汰并按新配置重建')
|
|
1424
|
+
})
|
|
1425
|
+
|
|
@@ -28,7 +28,17 @@ import argo_paths as _paths
|
|
|
28
28
|
ARGO_DIR = Path(__file__).resolve().parent.parent
|
|
29
29
|
LOCAL_SEARCH_DIR = ARGO_DIR / "sub-skills" / "local-search"
|
|
30
30
|
LOCAL_SEARCH_CONFIG = LOCAL_SEARCH_DIR / "config.yaml"
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def __getattr__(name: str):
|
|
34
|
+
"""`HEALTH_STATE_PATH` 每次访问按当前 ARGO_STATE_DIR 解析(PEP 562)。
|
|
35
|
+
|
|
36
|
+
与 circuit_breaker 同一口径:导入期常量会与改写后的 `ARGO_STATE_DIR` 脱节,
|
|
37
|
+
而读写必须落同一个文件。保留此名以维持「可读、可 patch」的既有契约。
|
|
38
|
+
"""
|
|
39
|
+
if name == "HEALTH_STATE_PATH":
|
|
40
|
+
return _paths.state_path("argo_engine_health.json")
|
|
41
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
32
42
|
|
|
33
43
|
# ── YAML mtime 缓存(route 热路径会高频调用 list_local_engines) ──────────────
|
|
34
44
|
_yaml_cache: dict[str, Any] | None = None
|
|
@@ -68,14 +78,30 @@ class EngineRegistry:
|
|
|
68
78
|
|
|
69
79
|
def __init__(self):
|
|
70
80
|
self._health: dict = {}
|
|
81
|
+
# 读模块属性(可被 monkeypatch),每次构造按当前 ARGO_STATE_DIR 解析。
|
|
82
|
+
# 用 `globals().get`:裸名查找不触发 PEP 562 `__getattr__`。
|
|
83
|
+
self._health_path = globals().get("HEALTH_STATE_PATH") or _paths.state_path(
|
|
84
|
+
"argo_engine_health.json")
|
|
71
85
|
self._local_names_cache: list[str] | None = None
|
|
72
86
|
self._local_names_mtime: float = -1.0
|
|
73
87
|
self._load_health()
|
|
74
88
|
|
|
89
|
+
def _health_state_path(self) -> Path:
|
|
90
|
+
"""健康状态路径:实例属性 → 模块属性(可 patch)→ 按当前环境解析。
|
|
91
|
+
|
|
92
|
+
收口成一处,是为了让绕过 `__init__` 的构造(测试用 `__new__` 直接注入
|
|
93
|
+
`_health`)也能拿到正确路径——否则 `_save_health` 会因缺 `_health_path`
|
|
94
|
+
抛错并被 `except` 吞掉,表现为「静默不写盘」。
|
|
95
|
+
"""
|
|
96
|
+
return (getattr(self, "_health_path", None)
|
|
97
|
+
or globals().get("HEALTH_STATE_PATH")
|
|
98
|
+
or _paths.state_path("argo_engine_health.json"))
|
|
99
|
+
|
|
75
100
|
def _load_health(self):
|
|
76
|
-
|
|
101
|
+
path = self._health_state_path()
|
|
102
|
+
if path.exists():
|
|
77
103
|
try:
|
|
78
|
-
self._health = json.loads(
|
|
104
|
+
self._health = json.loads(path.read_bytes())
|
|
79
105
|
except Exception:
|
|
80
106
|
self._health = {}
|
|
81
107
|
|
|
@@ -85,7 +111,7 @@ class EngineRegistry:
|
|
|
85
111
|
# 健康门状态丢失——"全体失忆"。同族事故已在
|
|
86
112
|
# sub-skills/local-search/engine_registry 与 local_seek 修过两例,
|
|
87
113
|
# 这是漏网的第三例;mkstemp 唯一 tmp + os.replace,失败自清理。
|
|
88
|
-
_paths.atomic_write_json(
|
|
114
|
+
_paths.atomic_write_json(self._health_state_path(), self._health, indent=None)
|
|
89
115
|
except Exception:
|
|
90
116
|
pass
|
|
91
117
|
|
package/scripts/argo_paths.py
CHANGED
|
@@ -316,12 +316,18 @@ def _check_lock_roundtrip(hold_s: float) -> tuple[str, str]:
|
|
|
316
316
|
pass
|
|
317
317
|
|
|
318
318
|
|
|
319
|
-
def run_checks(lock_hold_s: float = 0.
|
|
319
|
+
def run_checks(lock_hold_s: float = 0.15) -> list[dict[str, Any]]:
|
|
320
320
|
"""在**当前机器**上实测一遍路径解析与关键能力(`argo paths --check`)。
|
|
321
321
|
|
|
322
322
|
为什么要有它:跨平台分支(Windows 用哪个目录、msvcrt 锁是否真互斥、解释器候选
|
|
323
323
|
最终落到谁)在开发机上只能做契约级测试,真机验证此前得靠人肉翻代码。这里把
|
|
324
324
|
「这台机器上实际发生了什么」一次打印清楚——任何平台一条命令自行验证。
|
|
325
|
+
|
|
326
|
+
`lock_hold_s` 是子进程持锁时长,判据是「第二个持有者等待 ≥100 ms」(见
|
|
327
|
+
`_check_lock_roundtrip`),0.15 s 留足一倍余量即可。历史上这里写 0.6 s,
|
|
328
|
+
让每次自检固定空等 600 ms;同仓 `packages/argo-zcode/server/py_bridge.py`
|
|
329
|
+
与 `tests/test_platform_paths_conventions.py` 早已分别用 0.15 / 0.2,
|
|
330
|
+
此处对齐同一口径,自检结论不变。
|
|
325
331
|
"""
|
|
326
332
|
checks: list[dict[str, Any]] = []
|
|
327
333
|
|