argo-search 2.16.0 → 2.18.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 +4 -2
- package/README.es.md +15 -5
- package/README.ja.md +15 -5
- package/README.ko.md +15 -5
- package/README.md +16 -6
- package/README.zh.md +16 -6
- package/SKILL.md +12 -11
- package/assets/readme/counts.json +1 -1
- package/assets/readme/hero.svg +3 -3
- package/assets/readme/hero.template.svg +121 -0
- package/assets/readme/proof-routes.svg +17 -16
- package/backends/domain_profiles.json +121 -18
- package/backends/engine_registry.yaml +23 -0
- package/backends/env_passthrough.txt +2 -0
- package/backends/quota_profiles.json +20 -0
- package/bin/argo +78 -12
- package/docs/CHANGELOG.md +35 -1
- package/docs/COMMIT_STANDARD.md +12 -2
- package/docs/ENGINE_CATALOG.md +36 -33
- package/docs/RELEASE_NOTES_v2.17.0.md +66 -0
- package/docs/RELEASE_NOTES_v2.18.0.md +87 -0
- package/docs/RELEASING.md +2 -2
- package/engines/specs/crossref.yaml +2 -0
- package/engines/specs/hackernews.yaml +2 -0
- package/engines/specs/helve.yaml +49 -0
- package/engines/specs/hf_papers.yaml +2 -0
- package/engines/specs/openalex.yaml +9 -2
- package/engines/specs/twitter_cli.yaml +17 -0
- package/engines/specs/twitter_syndication.yaml +2 -3
- package/package.json +3 -1
- package/packages/dsh-plugin/README.md +5 -2
- package/packages/dsh-plugin/cordis.patch.yml +4 -1
- package/packages/dsh-plugin/dsh/client.js +57 -63
- package/packages/dsh-plugin/dsh/diagnostics.js +25 -4
- package/packages/dsh-plugin/dsh/index.js +109 -21
- package/packages/dsh-plugin/dsh/native-tools.mjs +10 -0
- package/packages/dsh-plugin/dsh/route-guard.js +95 -0
- package/packages/dsh-plugin/dsh/runner.js +49 -6
- package/packages/dsh-plugin/dsh/wide-research.js +20 -18
- package/packages/dsh-plugin/dsh/workbench-client.js +119 -20
- package/packages/dsh-plugin/dsh/workbench-io.js +182 -0
- package/packages/dsh-plugin/dsh/workbench-search.js +445 -0
- package/packages/dsh-plugin/dsh/workbench-suggestions.js +387 -75
- package/packages/dsh-plugin/dsh/workbench.js +277 -497
- package/packages/dsh-plugin/package.json +4 -3
- package/packages/dsh-plugin/scripts/sync-local.mjs +4 -2
- package/packages/dsh-plugin/scripts/sync-local.sh +4 -2
- package/packages/dsh-plugin/test/client.test.js +26 -0
- package/packages/dsh-plugin/test/diagnostics.test.js +5 -2
- package/packages/dsh-plugin/test/index.test.js +150 -1
- package/packages/dsh-plugin/test/workbench-concurrency.test.js +96 -0
- package/packages/dsh-plugin/test/workbench.test.js +422 -9
- package/scripts/adaptive.py +13 -11
- package/scripts/affected_tests.py +324 -0
- package/scripts/badcase_ledger.py +93 -2
- package/scripts/browser_auth.py +178 -4
- package/scripts/cache.py +68 -69
- package/scripts/check_commit_report.py +59 -9
- package/scripts/chrome_cdp.py +71 -0
- package/scripts/circuit_breaker.py +77 -12
- package/scripts/cli_io.py +8 -3
- package/scripts/config_cache.py +4 -3
- package/scripts/daemon.py +9 -2
- package/scripts/engine_add.py +45 -0
- package/scripts/engine_dispatch.py +27 -47
- package/scripts/engine_failure.py +33 -0
- package/scripts/engine_families.py +1 -0
- package/scripts/engine_fingerprint.py +114 -0
- package/scripts/engine_health.py +130 -0
- package/scripts/engine_states.py +54 -4
- package/scripts/engines.py +2 -0
- package/scripts/engines_base.py +19 -44
- package/scripts/engines_builders_intl.py +20 -94
- package/scripts/engines_builders_search.py +19 -8
- package/scripts/engines_builders_tech.py +16 -16
- package/scripts/engines_fields.py +23 -0
- package/scripts/engines_twitter_cli.py +182 -0
- package/scripts/evidence_grounding.py +182 -0
- package/scripts/fetch_browser.py +25 -10
- package/scripts/fetch_cli_output.py +75 -0
- package/scripts/fetch_dispatch.py +248 -0
- package/scripts/fetch_quality.py +11 -0
- package/scripts/fetch_v3.py +48 -114
- package/scripts/gate_manifest_check.py +75 -0
- package/scripts/gen_readme_art.py +264 -0
- package/scripts/intent_router.py +224 -0
- package/scripts/mcp_compact.py +3 -0
- package/scripts/mcp_handlers.py +24 -4
- package/scripts/mcp_tools.py +2 -0
- package/scripts/mcp_transport.py +24 -5
- package/scripts/mcp_warm.py +15 -11
- package/scripts/numeric_verify.py +9 -0
- package/scripts/output_transparency.py +10 -0
- package/scripts/pre-commit +65 -8
- package/scripts/query_operators.py +229 -1
- package/scripts/quota.py +19 -37
- package/scripts/release.py +16 -1
- package/scripts/release_check.py +1 -2
- package/scripts/research_gates.py +85 -1
- package/scripts/research_notes.py +52 -5
- package/scripts/retry_policy.py +17 -3
- package/scripts/route_combo.py +21 -4
- package/scripts/search.py +29 -29
- package/scripts/search_cli.py +104 -8
- package/scripts/search_output.py +4 -1
- package/scripts/social_research.py +8 -6
- package/scripts/source_discovery.py +611 -0
- package/scripts/sync_backends.py +45 -0
- package/scripts/time_utils.py +28 -0
- package/scripts/twitter_single_read.py +107 -0
- package/scripts/x_keyword_route.py +138 -0
- package/scripts/x_search.py +24 -33
- package/scripts/zhihu_answer_body.py +96 -0
- package/scripts/zhihu_answer_fetch.py +66 -0
- package/scripts/zhihu_answer_lookup.py +138 -0
- package/sub-skills/ego-search/README.md +9 -0
- package/sub-skills/ego-search/scripts/ego_search.py +182 -15
- package/sub-skills/ego-search/scripts/pacing.py +291 -0
- package/sub-skills/ego-search/scripts/quality.py +262 -6
- package/sub-skills/ego-search/scripts/runtime.py +7 -1
- package/sub-skills/ego-search/scripts/site_profiles.py +157 -0
- package/sub-skills/ego-search/scripts/webbridge_adapter.py +7 -1
- package/sub-skills/local-seek/SKILL.md +3 -1
- package/sub-skills/local-seek/scripts/seek.py +80 -109
- package/sub-skills/local-seek/scripts/seek_git.py +65 -0
- package/sub-skills/local-seek/scripts/seek_inspect.py +242 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taxueseek/argo-dsh",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.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",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"dsh": "^0.2.0-rc.1 || ^0.2.1 || ^0.2.2-0",
|
|
35
35
|
"dshReleases": {
|
|
36
36
|
"0.2.2-rc.1": "compatible",
|
|
37
|
-
"0.2.2-rc.2": "compatible"
|
|
37
|
+
"0.2.2-rc.2": "compatible",
|
|
38
|
+
"0.2.2-rc.5": "compatible"
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
},
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"@deepseek-ai/schemastery": "^3.19.0"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
|
-
"check": "node --check dsh/index.js && node --check dsh/specs.js && node --check dsh/runner.js && node --check dsh/wide-research.js && node --check dsh/diagnostics.js && node --check dsh/client.js && node --check scripts/sync-local.mjs",
|
|
49
|
+
"check": "node --check dsh/index.js && node --check dsh/specs.js && node --check dsh/runner.js && node --check dsh/wide-research.js && node --check dsh/diagnostics.js && node --check dsh/route-guard.js && node --check dsh/client.js && node --check dsh/workbench.js && node --check dsh/workbench-io.js && node --check dsh/workbench-client.js && node --check dsh/workbench-md.js && node --check dsh/workbench-suggestions.js && node --check dsh/native-tools.mjs && node --check scripts/sync-local.mjs",
|
|
49
50
|
"sync-local": "node scripts/sync-local.mjs",
|
|
50
51
|
"typecheck": "npm run check",
|
|
51
52
|
"test": "node --test test/*.test.js"
|
|
@@ -64,7 +64,9 @@ for (const p of profiles) {
|
|
|
64
64
|
}
|
|
65
65
|
if (mode === 'check') {
|
|
66
66
|
const same = filesEqual(path.join(SRC, 'dsh'), path.join(dest, 'dsh'))
|
|
67
|
-
&&
|
|
67
|
+
&& ['package.json', 'cordis.patch.yml', 'icon.svg'].every(
|
|
68
|
+
(f) => filesEqual(path.join(SRC, f), path.join(dest, f)),
|
|
69
|
+
);
|
|
68
70
|
if (same) console.log(`[ok] ${p}`);
|
|
69
71
|
else {
|
|
70
72
|
console.log(`[drift] ${p}: 源码与已安装 bundle 不一致,请运行 npm run sync-local`);
|
|
@@ -77,7 +79,7 @@ for (const p of profiles) {
|
|
|
77
79
|
fs.cpSync(dest, bakDir, { recursive: true, force: true });
|
|
78
80
|
fs.rmSync(path.join(dest, 'dsh'), { recursive: true, force: true });
|
|
79
81
|
fs.cpSync(path.join(SRC, 'dsh'), path.join(dest, 'dsh'), { recursive: true, force: true });
|
|
80
|
-
for (const f of ['package.json', 'cordis.patch.yml', 'README.md']) {
|
|
82
|
+
for (const f of ['package.json', 'cordis.patch.yml', 'README.md', 'icon.svg']) {
|
|
81
83
|
fs.copyFileSync(path.join(SRC, f), path.join(dest, f));
|
|
82
84
|
}
|
|
83
85
|
console.log(`[synced] ${p}`);
|
|
@@ -63,7 +63,9 @@ for p in "${PROFILES[@]}"; do
|
|
|
63
63
|
fi
|
|
64
64
|
if [ "$MODE" = check ]; then
|
|
65
65
|
if diff -rq "$SRC/dsh" "$DEST/dsh" >/dev/null 2>&1 \
|
|
66
|
-
&& cmp -s "$SRC/package.json" "$DEST/package.json"
|
|
66
|
+
&& cmp -s "$SRC/package.json" "$DEST/package.json" \
|
|
67
|
+
&& cmp -s "$SRC/cordis.patch.yml" "$DEST/cordis.patch.yml" \
|
|
68
|
+
&& cmp -s "$SRC/icon.svg" "$DEST/icon.svg"; then
|
|
67
69
|
echo "[ok] $p"
|
|
68
70
|
else
|
|
69
71
|
echo "[drift] $p: 源码与已安装 bundle 不一致,跑一次不带 --check 的同步"
|
|
@@ -73,7 +75,7 @@ for p in "${PROFILES[@]}"; do
|
|
|
73
75
|
fi
|
|
74
76
|
cp -a "$DEST" "$DSH_HOME/backups/argo-dsh-sync-$TS-$p"
|
|
75
77
|
rsync -a --delete "$SRC/dsh/" "$DEST/dsh/"
|
|
76
|
-
rsync -a "$SRC/package.json" "$SRC/cordis.patch.yml" "$SRC/README.md" "$DEST/"
|
|
78
|
+
rsync -a "$SRC/package.json" "$SRC/cordis.patch.yml" "$SRC/README.md" "$SRC/icon.svg" "$DEST/"
|
|
77
79
|
echo "[synced] $p"
|
|
78
80
|
done
|
|
79
81
|
|
|
@@ -422,3 +422,29 @@ test('dashboard tab renders metrics, workflow presets, and engine topology matri
|
|
|
422
422
|
assert.ok(flat.some((node) => node.props && node.props.key === 'presets'), 'dashboard 应包含工作流预设')
|
|
423
423
|
assert.ok(flat.some((node) => node.props && node.props.key === 'matrix'), 'dashboard 应包含核心引擎拓扑矩阵')
|
|
424
424
|
})
|
|
425
|
+
|
|
426
|
+
test('SafeArgoPanel wraps ArgoPanel in an ErrorBoundary that isolates render failures', () => {
|
|
427
|
+
const definition = loadBundle()
|
|
428
|
+
class FakeComponent {
|
|
429
|
+
constructor(props) { this.props = props; this.state = {} }
|
|
430
|
+
}
|
|
431
|
+
const react = {
|
|
432
|
+
Component: FakeComponent,
|
|
433
|
+
createElement: (type, props, ...children) => ({ type, props: props || {}, children }),
|
|
434
|
+
useState: () => [undefined, () => {}],
|
|
435
|
+
useEffect: () => {},
|
|
436
|
+
useRef: () => ({ current: new Set() }),
|
|
437
|
+
}
|
|
438
|
+
const mod = definition.factory((id) => {
|
|
439
|
+
if (id === 'react') return react
|
|
440
|
+
throw new Error(`unexpected require: ${id}`)
|
|
441
|
+
})
|
|
442
|
+
assert.equal(typeof mod.PanelBoundary, 'function')
|
|
443
|
+
const tree = mod.SafeArgoPanel({ view: 'page' })
|
|
444
|
+
assert.equal(tree.type, mod.PanelBoundary)
|
|
445
|
+
const inst = new mod.PanelBoundary({ children: 'ok' })
|
|
446
|
+
inst.state = mod.PanelBoundary.getDerivedStateFromError(new Error('boom'))
|
|
447
|
+
const fallback = inst.render()
|
|
448
|
+
assert.equal(fallback.type, 'div')
|
|
449
|
+
assert.match(String(fallback.children[0]), /boom/)
|
|
450
|
+
})
|
|
@@ -9,13 +9,16 @@ test('diagnostics: getMcpPoolStats returns pool status and active loads', () =>
|
|
|
9
9
|
const dummyPool = [
|
|
10
10
|
{ load: () => 0, proc: {} },
|
|
11
11
|
{ load: () => 2, proc: {} },
|
|
12
|
+
{ load: () => 0, proc: null },
|
|
12
13
|
]
|
|
13
14
|
const stats = getMcpPoolStats(dummyPool)
|
|
14
|
-
assert.equal(stats.poolSize,
|
|
15
|
+
assert.equal(stats.poolSize, 3)
|
|
15
16
|
assert.equal(stats.activeConnections, 1)
|
|
16
17
|
assert.equal(stats.totalLoad, 2)
|
|
17
|
-
assert.equal(stats.connections.length,
|
|
18
|
+
assert.equal(stats.connections.length, 3)
|
|
18
19
|
assert.equal(stats.connections[1].load, 2)
|
|
20
|
+
assert.equal(stats.connections[0].hasProcess, true)
|
|
21
|
+
assert.equal(stats.connections[2].hasProcess, false)
|
|
19
22
|
})
|
|
20
23
|
|
|
21
24
|
test('diagnostics: resetMcpPool evicts connections safely', () => {
|
|
@@ -3,7 +3,7 @@ import assert from 'node:assert/strict'
|
|
|
3
3
|
import { mkdtempSync, writeFileSync, readFileSync, existsSync } from 'node:fs'
|
|
4
4
|
import { tmpdir } from 'node:os'
|
|
5
5
|
import { join } from 'node:path'
|
|
6
|
-
import { apply } from '../dsh/index.js'
|
|
6
|
+
import { apply, installWebSearchRouteDecorator, capWebSearchSources } from '../dsh/index.js'
|
|
7
7
|
import { buildChildToolFilters, resolveArgoEnv } from '../dsh/specs.js'
|
|
8
8
|
import {
|
|
9
9
|
normalizeTracks,
|
|
@@ -1472,3 +1472,152 @@ test('pool: changing argoEnv evicts idle connection with stale configKey', async
|
|
|
1472
1472
|
assert.equal(spawnCount(), 2, 'argoEnv 变更后空闲旧连接应被淘汰并按新配置重建')
|
|
1473
1473
|
})
|
|
1474
1474
|
|
|
1475
|
+
test('web_search route decorator: DeepSeek routes pass through, other routes use argo, and dispose restores', async () => {
|
|
1476
|
+
const disposers = []
|
|
1477
|
+
const origSearchCalls = []
|
|
1478
|
+
const argoCalls = []
|
|
1479
|
+
let configuredProvider
|
|
1480
|
+
|
|
1481
|
+
const origSearch = async (req) => {
|
|
1482
|
+
origSearchCalls.push(req)
|
|
1483
|
+
return { sources: [{ url: 'https://deepseek.example/1', title: 'DS' }], truncated: false }
|
|
1484
|
+
}
|
|
1485
|
+
const origSearchReady = async (llmProvider) => llmProvider === 'deepseek-official' || llmProvider === 'deepseek-account'
|
|
1486
|
+
|
|
1487
|
+
const web = {
|
|
1488
|
+
config: { searchProvider: { get: () => configuredProvider } },
|
|
1489
|
+
search: origSearch,
|
|
1490
|
+
searchReady: origSearchReady,
|
|
1491
|
+
}
|
|
1492
|
+
const ctx = {
|
|
1493
|
+
effect(fn) {
|
|
1494
|
+
const cleanup = fn()
|
|
1495
|
+
if (typeof cleanup === 'function') disposers.push(cleanup)
|
|
1496
|
+
},
|
|
1497
|
+
}
|
|
1498
|
+
const config = { searchProviderEnabled: true }
|
|
1499
|
+
const runArgo = async (req) => {
|
|
1500
|
+
argoCalls.push(req)
|
|
1501
|
+
return {
|
|
1502
|
+
sources: [
|
|
1503
|
+
{ url: 'https://argo.example/1', title: 'A1' },
|
|
1504
|
+
{ url: 'https://argo.example/2', title: 'A2' },
|
|
1505
|
+
{ url: 'https://argo.example/3', title: 'A3' },
|
|
1506
|
+
],
|
|
1507
|
+
truncated: false,
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
installWebSearchRouteDecorator(ctx, web, config, runArgo)
|
|
1512
|
+
|
|
1513
|
+
// 1. DeepSeek 路由透传原生搜索与就绪检查
|
|
1514
|
+
assert.equal(await web.searchReady('deepseek-official'), true)
|
|
1515
|
+
assert.equal(await web.searchReady('deepseek-account'), true)
|
|
1516
|
+
const dsRes = await web.search({ query: 'q1', maxResults: 5, llmProvider: 'deepseek-official' })
|
|
1517
|
+
assert.equal(dsRes.sources[0].title, 'DS')
|
|
1518
|
+
assert.equal(origSearchCalls.length, 1)
|
|
1519
|
+
assert.equal(argoCalls.length, 0)
|
|
1520
|
+
|
|
1521
|
+
// 2. 非 DeepSeek 路由与无模型请求路由到 Argo,并按 maxResults 截断
|
|
1522
|
+
assert.equal(await web.searchReady('anthropic'), true)
|
|
1523
|
+
assert.equal(await web.searchReady(undefined), true)
|
|
1524
|
+
const otherRes = await web.search({ query: 'q2', maxResults: 2, llmProvider: 'anthropic' })
|
|
1525
|
+
assert.equal(otherRes.sources.length, 2)
|
|
1526
|
+
assert.equal(otherRes.truncated, true)
|
|
1527
|
+
assert.equal(argoCalls.length, 1)
|
|
1528
|
+
assert.equal(origSearchCalls.length, 1)
|
|
1529
|
+
|
|
1530
|
+
// 3. 显式 pin 了 searchProvider 时让位给宿主
|
|
1531
|
+
configuredProvider = 'deepseek-search-api'
|
|
1532
|
+
assert.equal(await web.searchReady('anthropic'), false)
|
|
1533
|
+
await web.search({ query: 'q3', maxResults: 5, llmProvider: 'anthropic' })
|
|
1534
|
+
assert.equal(origSearchCalls.length, 2)
|
|
1535
|
+
assert.equal(argoCalls.length, 1)
|
|
1536
|
+
configuredProvider = undefined
|
|
1537
|
+
|
|
1538
|
+
// 4. searchProviderEnabled=false 时让位给宿主
|
|
1539
|
+
config.searchProviderEnabled = false
|
|
1540
|
+
assert.equal(await web.searchReady('openai'), false)
|
|
1541
|
+
await web.search({ query: 'q4', maxResults: 5, llmProvider: 'openai' })
|
|
1542
|
+
assert.equal(origSearchCalls.length, 3)
|
|
1543
|
+
assert.equal(argoCalls.length, 1)
|
|
1544
|
+
|
|
1545
|
+
// 5. effect 卸载(HMR)应完整还原原始方法
|
|
1546
|
+
for (const cleanup of disposers) cleanup()
|
|
1547
|
+
assert.equal(web.search, origSearch)
|
|
1548
|
+
assert.equal(web.searchReady, origSearchReady)
|
|
1549
|
+
})
|
|
1550
|
+
|
|
1551
|
+
test('capWebSearchSources truncates only when sources exceed positive maxResults', () => {
|
|
1552
|
+
const sample = { sources: [{ url: '1' }, { url: '2' }, { url: '3' }], truncated: false }
|
|
1553
|
+
assert.equal(capWebSearchSources(sample, undefined), sample)
|
|
1554
|
+
assert.equal(capWebSearchSources(sample, 5), sample)
|
|
1555
|
+
assert.deepEqual(capWebSearchSources(sample, 2), {
|
|
1556
|
+
sources: [{ url: '1' }, { url: '2' }],
|
|
1557
|
+
truncated: true,
|
|
1558
|
+
})
|
|
1559
|
+
})
|
|
1560
|
+
|
|
1561
|
+
test('apply: wires route-aware web.search decorator end-to-end with searchViaArgoMCP', async () => {
|
|
1562
|
+
const disposers = []
|
|
1563
|
+
const origCalls = []
|
|
1564
|
+
const web = {
|
|
1565
|
+
registerSearchProvider: () => () => {},
|
|
1566
|
+
registerFetchProvider: () => () => {},
|
|
1567
|
+
async search(req) {
|
|
1568
|
+
origCalls.push(req)
|
|
1569
|
+
return { sources: [{ url: 'https://host.example', title: 'Host' }], truncated: false }
|
|
1570
|
+
},
|
|
1571
|
+
async searchReady(llmProvider) {
|
|
1572
|
+
return llmProvider === 'deepseek-official'
|
|
1573
|
+
},
|
|
1574
|
+
}
|
|
1575
|
+
const ctx = {
|
|
1576
|
+
tools: { register: () => () => {}, guard: () => {} },
|
|
1577
|
+
subagents: { getProvider: () => null, list: () => [] },
|
|
1578
|
+
effect(fn) {
|
|
1579
|
+
const cleanup = fn()
|
|
1580
|
+
if (typeof cleanup === 'function') disposers.push(cleanup)
|
|
1581
|
+
},
|
|
1582
|
+
get: (svc) => svc === 'web' ? web : null,
|
|
1583
|
+
}
|
|
1584
|
+
const jsonMcpScript = `
|
|
1585
|
+
let buf = ''
|
|
1586
|
+
process.stdin.on('data', (c) => {
|
|
1587
|
+
buf += c.toString()
|
|
1588
|
+
const lines = buf.split('\\n')
|
|
1589
|
+
buf = lines.pop()
|
|
1590
|
+
for (const line of lines) {
|
|
1591
|
+
if (!line.trim()) continue
|
|
1592
|
+
const msg = JSON.parse(line)
|
|
1593
|
+
if (msg.method === 'initialize') {
|
|
1594
|
+
process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id: msg.id, result: { protocolVersion: '2024-11-05', capabilities: {} } }) + '\\n')
|
|
1595
|
+
} else if (msg.method === 'tools/call') {
|
|
1596
|
+
const payload = { query: msg.params?.arguments?.query, results: [{ title: 'ArgoHit', url: 'https://argo.example/hit', snippet: 'from argo' }] }
|
|
1597
|
+
process.stdout.write(JSON.stringify({ jsonrpc: '2.0', id: msg.id, result: { content: [{ type: 'text', text: JSON.stringify(payload) }] } }) + '\\n')
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
})
|
|
1601
|
+
`
|
|
1602
|
+
apply(ctx, {
|
|
1603
|
+
searchCommand: process.execPath,
|
|
1604
|
+
searchArgs: ['-e', jsonMcpScript],
|
|
1605
|
+
searchIdleMs: 200,
|
|
1606
|
+
nativeTools: [],
|
|
1607
|
+
})
|
|
1608
|
+
|
|
1609
|
+
// DeepSeek 路由走宿主
|
|
1610
|
+
const hostRes = await web.search({ query: 'ds', maxResults: 5, llmProvider: 'deepseek-official' })
|
|
1611
|
+
assert.equal(hostRes.sources[0].title, 'Host')
|
|
1612
|
+
assert.equal(origCalls.length, 1)
|
|
1613
|
+
|
|
1614
|
+
// 非 DeepSeek 路由走 Argo MCP 池(验证 searchViaArgoMCP/resolveEntry 导入与调用全链路)
|
|
1615
|
+
assert.equal(await web.searchReady('anthropic'), true)
|
|
1616
|
+
const argoRes = await web.search({ query: 'other', maxResults: 5, llmProvider: 'anthropic' })
|
|
1617
|
+
assert.equal(argoRes.sources[0].title, 'ArgoHit')
|
|
1618
|
+
assert.equal(origCalls.length, 1)
|
|
1619
|
+
|
|
1620
|
+
for (const cleanup of disposers) cleanup()
|
|
1621
|
+
await disposeSharedMcp()
|
|
1622
|
+
})
|
|
1623
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// workbench-concurrency.test.js — 2026-11-21 审计收敛项:跨进程锁统一、
|
|
2
|
+
// watches 单一真源合并写、热榜让路可见化、track 成败真章。
|
|
3
|
+
import test from 'node:test'
|
|
4
|
+
import assert from 'node:assert/strict'
|
|
5
|
+
import { openSync, closeSync, unlinkSync, mkdtempSync, rmSync, existsSync } from 'node:fs'
|
|
6
|
+
import { tmpdir } from 'node:os'
|
|
7
|
+
import { join } from 'node:path'
|
|
8
|
+
import { acquireStateFileLock, releaseStateFileLock, mutateWatches } from '../dsh/workbench-io.js'
|
|
9
|
+
import { refreshDailyHotspots, createHotspotRefresher } from '../dsh/workbench-suggestions.js'
|
|
10
|
+
import { evaluateGates } from '../dsh/wide-research.js'
|
|
11
|
+
|
|
12
|
+
function withTempStateDir(fn) {
|
|
13
|
+
return async () => {
|
|
14
|
+
const dir = mkdtempSync(join(tmpdir(), 'argo-wb-test-'))
|
|
15
|
+
const prev = process.env.ARGO_STATE_DIR
|
|
16
|
+
process.env.ARGO_STATE_DIR = dir
|
|
17
|
+
try {
|
|
18
|
+
await fn(dir)
|
|
19
|
+
} finally {
|
|
20
|
+
if (prev === undefined) delete process.env.ARGO_STATE_DIR
|
|
21
|
+
else process.env.ARGO_STATE_DIR = prev
|
|
22
|
+
try { rmSync(dir, { recursive: true, force: true }) } catch { /* ignore */ }
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
test('state file lock: mutual exclusion, release and stale takeover', () => {
|
|
28
|
+
const file = join(mkdtempSync(join(tmpdir(), 'argo-lock-test-')), 'probe.lock')
|
|
29
|
+
const first = acquireStateFileLock(file)
|
|
30
|
+
assert.ok(first, 'first acquire must succeed')
|
|
31
|
+
assert.equal(acquireStateFileLock(file), null, 'second acquire must yield null while held')
|
|
32
|
+
releaseStateFileLock(first)
|
|
33
|
+
assert.ok(!existsSync(file), 'release removes lock file')
|
|
34
|
+
const again = acquireStateFileLock(file)
|
|
35
|
+
assert.ok(again, 're-acquire after release must succeed')
|
|
36
|
+
releaseStateFileLock(again)
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test('mutateWatches is single-truth read-modify-write under lock', withTempStateDir(async (dir) => {
|
|
40
|
+
const file = join(dir, 'config', 'workbench-watches.json')
|
|
41
|
+
const added = mutateWatches(list => { list.unshift({ id: 'w_test_a', query: 'a' }); return list }, file)
|
|
42
|
+
assert.ok(Array.isArray(added), 'mutate returns list when lock acquired')
|
|
43
|
+
const after = mutateWatches(list => { list.unshift({ id: 'w_test_b', query: 'b' }); return list }, file)
|
|
44
|
+
assert.ok(after.some(w => w.id === 'w_test_a'), 'second mutate preserves first-host change (no overwrite)')
|
|
45
|
+
assert.ok(after.some(w => w.id === 'w_test_b'), 'second mutate applies its own change')
|
|
46
|
+
// 锁被占时返回 null(忙语义)
|
|
47
|
+
const lock = acquireStateFileLock(`${file}.lock`)
|
|
48
|
+
assert.ok(lock)
|
|
49
|
+
try {
|
|
50
|
+
assert.equal(mutateWatches(list => list, file), null, 'mutateWatches yields null while lock held')
|
|
51
|
+
} finally {
|
|
52
|
+
releaseStateFileLock(lock)
|
|
53
|
+
}
|
|
54
|
+
}))
|
|
55
|
+
|
|
56
|
+
test('refreshDailyHotspots reports skipped=lock_busy instead of fake success', withTempStateDir(async (dir) => {
|
|
57
|
+
// 先让另一「宿主」持锁
|
|
58
|
+
const lock = acquireStateFileLock(join(dir, 'workbench-hotspots.json.lock'))
|
|
59
|
+
assert.ok(lock)
|
|
60
|
+
let cliCalled = false
|
|
61
|
+
const store = await refreshDailyHotspots({ runCli: () => { cliCalled = true; return {} } })
|
|
62
|
+
releaseStateFileLock(lock)
|
|
63
|
+
assert.equal(store.skipped, 'lock_busy', 'lock-busy must surface skipped marker')
|
|
64
|
+
assert.equal(cliCalled, false, 'yielded round must not fire engines')
|
|
65
|
+
}))
|
|
66
|
+
|
|
67
|
+
test('hotspot refresher isBusy derives from inflight (no double state)', async () => {
|
|
68
|
+
let releaseRunner
|
|
69
|
+
const gate = new Promise(resolve => { releaseRunner = resolve })
|
|
70
|
+
const refresher = createHotspotRefresher({ buildRunner: () => gate.then(() => async () => ({})) })
|
|
71
|
+
const inflight = refresher.trigger()
|
|
72
|
+
assert.equal(refresher.isBusy(), true, 'busy while inflight')
|
|
73
|
+
releaseRunner()
|
|
74
|
+
await inflight
|
|
75
|
+
assert.equal(refresher.isBusy(), false, 'not busy after inflight settles')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('summarizeTrackRuns stamps real failures so track gates can fire', async () => {
|
|
79
|
+
const { summarizeTrackRuns } = await import('../dsh/workbench.js')
|
|
80
|
+
const stats = summarizeTrackRuns([
|
|
81
|
+
{ payload: { results: [1] } },
|
|
82
|
+
{ payload: {} }, // CLI 正常返回但零结果:算完成,空结果由 no_sources 门管
|
|
83
|
+
{ payload: null }, // runArgoCli 失败(显式留痕,不再伪装成 {})
|
|
84
|
+
{ payload: { errors: ['timeout'] } },
|
|
85
|
+
])
|
|
86
|
+
assert.deepEqual(stats, { total: 4, completed: 2, failed: 2 })
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
test('evaluateGates consumes real track stats: partial failure warns, all-fail blocks', () => {
|
|
90
|
+
const base = { answer: 'x', sources: [{ url: 'https://a.com', title: 'A', confidence: 'high' }], tracks: [], warnings: [] }
|
|
91
|
+
const partial = evaluateGates({ ...base, stats: { sourceCount: 5, completedTracks: 1, failedTracks: 2 } })
|
|
92
|
+
assert.ok(partial.warnings.some(w => w.id === 'partial_track_failure'), 'partial failure must warn')
|
|
93
|
+
const allFailed = evaluateGates({ ...base, stats: { sourceCount: 0, completedTracks: 0, failedTracks: 3 } })
|
|
94
|
+
assert.ok(allFailed.failures.some(f => f.id === 'all_tracks_failed'), 'all-failed must be a gate failure')
|
|
95
|
+
assert.ok(allFailed.failures.some(f => f.id === 'no_completed_tracks'), 'zero completed must be a gate failure')
|
|
96
|
+
})
|