argo-search 2.16.0 → 2.17.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.
Files changed (86) hide show
  1. package/AGENTS.md +3 -1
  2. package/README.es.md +9 -4
  3. package/README.ja.md +9 -4
  4. package/README.ko.md +9 -4
  5. package/README.md +9 -4
  6. package/README.zh.md +9 -4
  7. package/SKILL.md +1 -1
  8. package/assets/readme/counts.json +1 -1
  9. package/assets/readme/hero.svg +3 -3
  10. package/assets/readme/hero.template.svg +121 -0
  11. package/assets/readme/proof-routes.svg +17 -16
  12. package/backends/domain_profiles.json +115 -18
  13. package/backends/engine_registry.yaml +11 -0
  14. package/backends/env_passthrough.txt +2 -0
  15. package/backends/quota_profiles.json +10 -0
  16. package/docs/CHANGELOG.md +17 -1
  17. package/docs/COMMIT_STANDARD.md +10 -0
  18. package/docs/ENGINE_CATALOG.md +32 -30
  19. package/docs/RELEASE_NOTES_v2.17.0.md +64 -0
  20. package/docs/RELEASING.md +1 -1
  21. package/engines/specs/crossref.yaml +2 -0
  22. package/engines/specs/hackernews.yaml +2 -0
  23. package/engines/specs/helve.yaml +49 -0
  24. package/engines/specs/hf_papers.yaml +2 -0
  25. package/engines/specs/openalex.yaml +9 -2
  26. package/package.json +2 -1
  27. package/packages/dsh-plugin/README.md +5 -2
  28. package/packages/dsh-plugin/cordis.patch.yml +4 -1
  29. package/packages/dsh-plugin/dsh/client.js +57 -63
  30. package/packages/dsh-plugin/dsh/diagnostics.js +25 -4
  31. package/packages/dsh-plugin/dsh/index.js +109 -21
  32. package/packages/dsh-plugin/dsh/route-guard.js +95 -0
  33. package/packages/dsh-plugin/dsh/runner.js +49 -6
  34. package/packages/dsh-plugin/dsh/wide-research.js +20 -18
  35. package/packages/dsh-plugin/dsh/workbench-client.js +119 -20
  36. package/packages/dsh-plugin/dsh/workbench-io.js +163 -0
  37. package/packages/dsh-plugin/dsh/workbench-search.js +385 -0
  38. package/packages/dsh-plugin/dsh/workbench-suggestions.js +387 -75
  39. package/packages/dsh-plugin/dsh/workbench.js +234 -497
  40. package/packages/dsh-plugin/package.json +4 -3
  41. package/packages/dsh-plugin/scripts/sync-local.mjs +4 -2
  42. package/packages/dsh-plugin/scripts/sync-local.sh +4 -2
  43. package/packages/dsh-plugin/test/client.test.js +26 -0
  44. package/packages/dsh-plugin/test/diagnostics.test.js +5 -2
  45. package/packages/dsh-plugin/test/index.test.js +150 -1
  46. package/packages/dsh-plugin/test/workbench-concurrency.test.js +98 -0
  47. package/packages/dsh-plugin/test/workbench.test.js +337 -9
  48. package/scripts/adaptive.py +13 -11
  49. package/scripts/browser_auth.py +178 -4
  50. package/scripts/cache.py +68 -69
  51. package/scripts/check_commit_report.py +46 -0
  52. package/scripts/chrome_cdp.py +71 -0
  53. package/scripts/circuit_breaker.py +77 -12
  54. package/scripts/config_cache.py +4 -3
  55. package/scripts/daemon.py +9 -2
  56. package/scripts/engine_add.py +45 -0
  57. package/scripts/engine_dispatch.py +27 -47
  58. package/scripts/engine_failure.py +33 -0
  59. package/scripts/engine_fingerprint.py +114 -0
  60. package/scripts/engine_health.py +130 -0
  61. package/scripts/engine_states.py +50 -0
  62. package/scripts/engines_base.py +7 -16
  63. package/scripts/engines_builders_search.py +19 -8
  64. package/scripts/engines_builders_tech.py +16 -16
  65. package/scripts/engines_fields.py +23 -0
  66. package/scripts/evidence_grounding.py +182 -0
  67. package/scripts/fetch_browser.py +25 -10
  68. package/scripts/gate_manifest_check.py +75 -0
  69. package/scripts/gen_readme_art.py +264 -0
  70. package/scripts/mcp_transport.py +24 -5
  71. package/scripts/numeric_verify.py +9 -0
  72. package/scripts/pre-commit +57 -8
  73. package/scripts/query_operators.py +229 -1
  74. package/scripts/quota.py +19 -37
  75. package/scripts/release.py +16 -1
  76. package/scripts/research_gates.py +85 -1
  77. package/scripts/route_combo.py +13 -1
  78. package/scripts/source_discovery.py +611 -0
  79. package/scripts/sync_backends.py +45 -0
  80. package/sub-skills/ego-search/README.md +9 -0
  81. package/sub-skills/ego-search/scripts/ego_search.py +182 -15
  82. package/sub-skills/ego-search/scripts/pacing.py +291 -0
  83. package/sub-skills/ego-search/scripts/quality.py +262 -6
  84. package/sub-skills/ego-search/scripts/runtime.py +7 -1
  85. package/sub-skills/ego-search/scripts/site_profiles.py +157 -0
  86. package/sub-skills/ego-search/scripts/webbridge_adapter.py +7 -1
package/docs/RELEASING.md CHANGED
@@ -26,7 +26,7 @@ python3 scripts/release.py publish 2.10.1 --yes
26
26
  - 8 处机器声明:pyproject / package.json / dsh 插件包 / server.json(顶层 + packages)/ `__version__` / SKILL.md / `ARGO_MCP_VERSION`(ZCode 插件三处随 2026-11-13 packages/argo-zcode 剥离退出)
27
27
  - 五语 README 徽标、安装段「当前版本」散文、能力段标题
28
28
  - package.json 的 files 白名单补新发布说明;缺发布说明时生成带 `<!-- release-todo -->` 的骨架
29
- - `check`:release_check(结构)+ 内容清单 + `gen_engine_catalog.py --check`(目录计数)
29
+ - `check`:release_check(结构)+ 内容清单 + `gen_engine_catalog.py --check`(目录计数)+ `gen_readme_art.py --check`(对外证据图)
30
30
  - `publish`:全量 pytest → commit → tag → push main/tag → npm 发双包 → 轮询 registry 与 GitHub Release
31
31
 
32
32
  不管(要判断):
@@ -25,5 +25,7 @@ output_map:
25
25
  item_title: title
26
26
  item_url: URL
27
27
  item_summary: publisher
28
+ # 被引次数(Crossref 原生字段)
29
+ item_upstream_authority: is-referenced-by-count
28
30
  headers:
29
31
  User-Agent: argo-search
@@ -29,5 +29,7 @@ output_map:
29
29
  # url 为空的讨论帖交给 url_template 用 objectID 拼(原 builder 同款兜底)
30
30
  item_url: url
31
31
  url_template: "https://news.ycombinator.com/item?id={objectID}"
32
+ # HN 社区票数(热度档,与 fxtwitter likes 同形:只透传不赋权)
33
+ item_upstream_authority: points
32
34
  # 拼接模板:原 builder 的 `score: N | comments: N | by: author`
33
35
  item_summary_template: "score: {points} | comments: {num_comments} | by: {author}"
@@ -0,0 +1,49 @@
1
+ # Helve web search API (/v1/search)
2
+ # Docs: https://helve.dev
3
+ # OpenAPI: https://helve.dev/openapi.json
4
+ # Verify:
5
+ # export HELVE_API_KEY=hlv_...
6
+ # python3 scripts/search.py "climate change" --engine helve --json
7
+ #
8
+ # 计费与路由纪律:Helve 为按次计费网关($0.005/次,无月度免费额度),
9
+ # 对齐 deepseek_search 设为 cost_tier: paid + explicit_only: true,
10
+ # 仅经 --engine helve 显式调用,不进入自动路由与 fast/budget 档。
11
+
12
+ engine_id: helve
13
+ type: http
14
+ enabled: true
15
+ explicit_only: true
16
+ label: Helve
17
+ cost_tier: paid
18
+ family: web_general
19
+ priority: 60
20
+ qps: 5
21
+ cost_per_call: 0.005
22
+ cost_unit: usd
23
+ coverage:
24
+ - general
25
+ canary_query: "climate change"
26
+ desc: "Helve web search API (/v1/search,按次付费,仅 --engine helve 显式调用)"
27
+ method: POST
28
+ url: https://helve.dev/v1/search
29
+ timeout: 15
30
+
31
+ required_env:
32
+ - HELVE_API_KEY
33
+ allowed_env:
34
+ - HELVE_API_KEY
35
+
36
+ headers:
37
+ Authorization: Bearer {HELVE_API_KEY}
38
+ Content-Type: application/json
39
+
40
+ body:
41
+ query: "{query}"
42
+ max_results: "{n}"
43
+
44
+ # Helve /v1/search returns {results: [{title, url, snippets: [...], ...}], ...}
45
+ output_map:
46
+ items: results
47
+ item_title: title
48
+ item_url: url
49
+ item_summary: snippets.0
@@ -31,6 +31,8 @@ output_map:
31
31
  # 拼接模板:原 builder 输出 `摘要 · 发布日期 · upvotes: N · 作者`。
32
32
  # 社交信号(upvotes)是本源相对 arXiv/OpenAlex 的差异化价值,不能丢。
33
33
  item_summary_template: "{paper.summary} · {publishedAt} · upvotes: {paper.upvotes} · {paper.authors.0.name} · {paper.authors.1.name} · {paper.authors.2.name}"
34
+ # HF 社区 upvotes(社交信号,与摘要模板同字段)
35
+ item_upstream_authority: paper.upvotes
34
36
  item_published_at: paper.publishedAt
35
37
  canary_query: "attention"
36
38
  quality_queries:
@@ -23,7 +23,14 @@ url: https://api.openalex.org/works
23
23
  output_map:
24
24
  items: results
25
25
  item_title: title
26
- item_url: id
27
- item_summary: publication_year
26
+ # doi 是真实可点击链接(https://doi.org/...)——此前映射 id 是 OpenAlex 内部
27
+ # URL(https://openalex.org/W...),证据链断在自家 ID 上(2026-11-20 审计)
28
+ item_url: doi
29
+ # 摘要位此前只有 publication_year 一个数字,证据密度为零;摘要倒排
30
+ # (abstract_inverted_index)是 dict 需代码重组,声明式给不出,退而拼
31
+ # 「年份 · 期刊名」;缺期刊名的条目由模板折叠分隔符,退化为年份
32
+ item_summary_template: "{publication_year} · {primary_location.source.display_name}"
33
+ # 被引次数(学术权威量化,OpenAlex 原生字段)
34
+ item_upstream_authority: cited_by_count
28
35
  headers:
29
36
  User-Agent: argo-search
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "argo-search",
3
- "version": "2.16.0",
3
+ "version": "2.17.0",
4
4
  "description": "Argo 阿尔戈 — 统一搜索与证据核验。推荐 npx -y argo-search(npm 发布版)或 install.sh 安装。多语言路由、数百个源(大部分免密钥)、影视/体育/金融等垂直源、19 个 MCP 工具(默认注入 4 个核心,全量按需开启,与 CLI 能力面对齐)。",
5
5
  "keywords": [
6
6
  "mcp",
@@ -58,6 +58,7 @@
58
58
  "docs/RELEASE_NOTES_v2.10.1.md",
59
59
  "docs/RELEASE_NOTES_v2.10.2.md",
60
60
  "docs/RELEASE_NOTES_v2.11.2.md",
61
+ "docs/RELEASE_NOTES_v2.17.0.md",
61
62
  "docs/RELEASE_NOTES_v2.16.0.md",
62
63
  "docs/RELEASE_NOTES_v2.15.0.md",
63
64
  "docs/RELEASE_NOTES_v2.14.1.md",
@@ -30,7 +30,9 @@ packages/dsh-plugin/scripts/sync-local.sh # 2. 仅对目录副本做
30
30
 
31
31
  ### 当前启用状态(web profile)
32
32
 
33
- `wide_research` 编排、原生 `argo_search` / `argo_fetch` 与 `web` 服务行的 `searchProvider: argo` 已在用户层 `~/.dsh/profiles/web/cordis.patch.yml` 默认启用,无需取消任何注释即可使用。profile patch 里 `mcp-argo` 段注释掉的「按需开启」只针对 MCP 完整工具面,不代表整个插件未启用。
33
+ `wide_research` 编排、原生 `argo_search` / `argo_fetch`、搜索分析工作台(`/argo`)与 DSH `v0.2.2-rc.5` 路由感知 `web_search` 装饰器均已默认启用:
34
+ - **DSH `v0.2.2-rc.5` 及以上**:`web` 服务行的 `searchProvider` 建议**留空**(自动选择)——DeepSeek 模型路由透传宿主原生 `deepseek-official` 免费搜索,其他模型路由由本插件的路由装饰器透明转交 `argo`;如希望所有模型一律走 `argo`,仍可在 `web` 行显式设置 `searchProvider: argo`。
35
+ - `mcp-argo` 段注释掉的「按需开启」只针对 MCP 完整工具面,不代表整个插件未启用。
34
36
 
35
37
  该 patch 的 `fetchProviderEnabled: false` 是主动关闭 fetch seam,因此 `web` 服务行不 pin `fetchProvider`;若改为启用 fetch seam,必须按本文「web seam 的 pin 必读」一节在 `web` 服务行加 `fetchProvider: argo`,否则多个可用 provider 会触发 `WEB_PROVIDER_AMBIGUOUS`。
36
38
 
@@ -111,7 +113,8 @@ argo 的 `deepseek_search` 引擎(官方 `api.deepseek.com/v1/tools/search`,
111
113
 
112
114
  | argo-dsh | DSH Harness | 说明 |
113
115
  |----------|-------------|------|
114
- | 2.11.2(本机已装) | 0.2.2-rc.1(本机运行中) | `package.json` 的 compatibility 已含该版本;`wide_research` 与原生工具走既有工具面,插件侧无需改动 |
116
+ | 2.16.0(当前) | 0.2.2-rc.5(本机运行中) | 新增路由感知 `web_search` 装饰器(未 pin `searchProvider` 时 DeepSeek 路由透传官方免费搜索,其余路由自动转交 argo);补齐 `WebSearchProvider` / `WebFetchProvider` 的 `title`/`description`/`ready` 契约;新增 `/argo` 搜索分析工作台(8 专题模式 + 左答右证 SSE + 多轮追问 + 定时监控) |
117
+ | 2.11.2 | 0.2.2-rc.1 | `package.json` 的 compatibility 已含该版本;`wide_research` 与原生工具走既有工具面,插件侧无需改动 |
115
118
  | 2.9.9(上一版,兼容) | 0.2.1-rc.2(当前,运行中) | 自带设置页(接入 / 工具 / API 密钥 / 研究 / 高级)新增路由观测卡片(getRouteHealth 只读本机 usage_log / route.jsonl 汇总最近路由决策,无日志不假装有数据)与工具推荐组合(按场景一键套用工具勾选,中英双语);双栈入口 `startActivation({provider, label, request, signal, delivery})`;rc.2 移除 `toolFilter` 启动期字段后由插件内 tool guard 阻止 worker 嵌套调用 `wide_research`;`wide_research` 端到端实测通过(planner → 2 worker → synthesis,passed=true / 14 sources) |
116
119
  | 2.9.7(上一版,兼容) | 0.2.1-alpha.1(实测,兼容) | 旧宿主走 `start(provider, request)` 分支,`toolFilter` 启动期字段仍认;该分支由插件单测覆盖,未在 alpha.x 上重跑端到端 |
117
120
  | 2.9.2 | 0.2.1-alpha.1(实测) | 上一轮适配验证基线;rc.2 的新入口与 tool guard 自 2.9.4 起进入 |
@@ -8,7 +8,10 @@
8
8
  # 多个可用则 WEB_PROVIDER_AMBIGUOUS 直接报错」。web profile 默认挂着
9
9
  # dsh-web-fetch-http(免 key、永远可用),我们再注册一个 fetch provider
10
10
  # 就是两个可用——不 pin 的话 web_fetch 整个挂掉。故启用 fetch seam 的
11
- # profile 必须在 web 服务行配 fetchProvider: argo(searchProvider 同理)。
11
+ # profile 必须在 web 服务行配 fetchProvider: argo。
12
+ # searchProvider 建议留空:DSH v0.2.2-rc.5 起,未 pin 时 DeepSeek 路由
13
+ # 自动走免费的 deepseek-official 服务端搜索,其余路由由本插件路由装饰器
14
+ # 自动转交 argo(替代按次收费的 deepseek-search-api)。
12
15
  #
13
16
  # MCP 形态(mcp-argo,19 个 mcp__argo__* 完整工具面)默认不挂载:
14
17
  # 工具定义每轮注入上下文且压缩清不掉(实测 19 工具 ≈3.7K token/轮),而搜索 /
@@ -192,6 +192,7 @@ window.__ModuleLoader__.load({
192
192
  { ref: "FOURGET_URL", common: false, label: "4get 极简元搜索", en: "4get", engines: ["fourget"] },
193
193
  { ref: "GEMINI_API_KEY", common: false, label: "语义证据·Gemini 决策", en: "Semantic Evidence · Gemini Decision", engines: [] },
194
194
  { ref: "GITHUB_TOKEN", common: false, label: "GitHub", en: "GitHub", engines: ["github"] },
195
+ { ref: "HELVE_API_KEY", common: false, label: "Helve", en: "Helve", engines: ["helve"] },
195
196
  { ref: "KEENABLE_API_KEY", common: false, label: "Keenable", en: "Keenable", engines: ["keenable"] },
196
197
  { ref: "METASO_API_KEY", common: false, label: "秘塔", en: "Metaso", engines: ["metaso", "metaso_doc", "metaso_image", "metaso_podcast", "metaso_scholar", "metaso_video"] },
197
198
  { ref: "OCTEN_API_KEY", common: false, label: "Octen", en: "Octen", engines: ["octen"] },
@@ -309,21 +310,9 @@ window.__ModuleLoader__.load({
309
310
  };
310
311
 
311
312
  const PRESETS = [
312
- {
313
- id: 'fast', titleKey: 'presetFast', descKey: 'presetFastDesc', badge: '15s 超时', badgeColor: 'blue', active: false,
314
- env: { ARGO_TFIDF_RERANK: '0', ARGO_NUMBER_CROSSCHECK: '0', ARGO_PAID_SEARCH: 'off', ARGO_ADAPTIVE_GRACE: '1', ARGO_SERIAL_STAGGER_S: '0.5' },
315
- fields: { searchTimeoutMs: 15000, fetchTimeoutMs: 15000 },
316
- },
317
- {
318
- id: 'standard', titleKey: 'presetStandard', descKey: 'presetStandardDesc', badge: '标准生产', badgeColor: 'green', active: true,
319
- env: { ARGO_TFIDF_RERANK: '1', ARGO_NUMBER_CROSSCHECK: '1', ARGO_MINHASH_DEDUPE: '1', ARGO_PAID_SEARCH: 'auto', ARGO_ADAPTIVE_GRACE: '1', ARGO_SERIAL_STAGGER_S: '0.8' },
320
- fields: { searchTimeoutMs: 30000, fetchTimeoutMs: 25000 },
321
- },
322
- {
323
- id: 'deep', titleKey: 'presetDeep', descKey: 'presetDeepDesc', badge: '深度核验', badgeColor: 'blue', active: false,
324
- env: { ARGO_TFIDF_RERANK: '1', ARGO_NUMBER_CROSSCHECK: '1', ARGO_MINHASH_DEDUPE: '1', ARGO_SEMANTIC_EVIDENCE: '1', ARGO_ADAPTIVE_GRACE: '1', ARGO_PAID_SEARCH: 'auto' },
325
- fields: { searchTimeoutMs: 45000, fetchTimeoutMs: 35000, nativeTimeoutMs: 60000 },
326
- },
313
+ { id: 'fast', titleKey: 'presetFast', descKey: 'presetFastDesc', badge: '15s 超时', badgeColor: 'blue', env: { ARGO_TFIDF_RERANK: '0', ARGO_NUMBER_CROSSCHECK: '0', ARGO_PAID_SEARCH: 'off', ARGO_ADAPTIVE_GRACE: '1', ARGO_SERIAL_STAGGER_S: '0.5' }, fields: { searchTimeoutMs: 15000, fetchTimeoutMs: 15000 } },
314
+ { id: 'standard', titleKey: 'presetStandard', descKey: 'presetStandardDesc', badge: '标准生产', badgeColor: 'green', env: { ARGO_TFIDF_RERANK: '1', ARGO_NUMBER_CROSSCHECK: '1', ARGO_MINHASH_DEDUPE: '1', ARGO_PAID_SEARCH: 'auto', ARGO_ADAPTIVE_GRACE: '1', ARGO_SERIAL_STAGGER_S: '0.8' }, fields: { searchTimeoutMs: 30000, fetchTimeoutMs: 25000 } },
315
+ { id: 'deep', titleKey: 'presetDeep', descKey: 'presetDeepDesc', badge: '深度核验', badgeColor: 'blue', env: { ARGO_TFIDF_RERANK: '1', ARGO_NUMBER_CROSSCHECK: '1', ARGO_MINHASH_DEDUPE: '1', ARGO_SEMANTIC_EVIDENCE: '1', ARGO_ADAPTIVE_GRACE: '1', ARGO_PAID_SEARCH: 'auto' }, fields: { searchTimeoutMs: 45000, fetchTimeoutMs: 35000, nativeTimeoutMs: 60000 } },
327
316
  ];
328
317
 
329
318
  const col = (gap) => ({ display: 'flex', flexDirection: 'column', gap });
@@ -508,7 +497,7 @@ window.__ModuleLoader__.load({
508
497
  if (typeof offRoute === 'function') offs.push(offRoute);
509
498
  }
510
499
  return () => { for (const off of offs) off(); };
511
- }, [state]);
500
+ }, [props.view, props.remote]);
512
501
 
513
502
  const edit = (key, text) => { dirty.current.add(key); setDraft((p) => ({ ...p, [key]: text })); };
514
503
  const report = (ok, text) => { setError(!ok); setMessage(text); };
@@ -565,11 +554,13 @@ window.__ModuleLoader__.load({
565
554
  void setField('nativeTools', ordered);
566
555
  };
567
556
 
568
- const applyToolPreset = async (tools) => {
557
+ const applyToolPreset = (tools) => runSave('nativeTools', async () => {
569
558
  const ordered = TOOLS.map((tool) => tool.id).filter((tid) => tools.includes(tid));
570
559
  for (const extra of tools) if (!ordered.includes(extra)) ordered.push(extra);
571
- await props.set('nativeTools', ordered);
572
- };
560
+ const ok = await props.set('nativeTools', ordered);
561
+ report(ok, ok ? t('saved') : t('refused'));
562
+ return ok;
563
+ });
573
564
 
574
565
  const mutateKey = async (ref, action) => {
575
566
  setKeyBusy(ref);
@@ -658,7 +649,13 @@ window.__ModuleLoader__.load({
658
649
  try {
659
650
  const ok = await writeEnvLines(updates);
660
651
  report(ok, ok ? t('saved') : t('refused'));
661
- if (ok) setEnvDraft({});
652
+ if (ok) {
653
+ setEnvDraft((prev) => {
654
+ const next = { ...prev };
655
+ for (const spec of specs) delete next[spec.name];
656
+ return next;
657
+ });
658
+ }
662
659
  } catch (cause) { report(false, cause && cause.message ? cause.message : String(cause)); }
663
660
  finally { setEnvBusy(''); }
664
661
  };
@@ -801,10 +798,16 @@ window.__ModuleLoader__.load({
801
798
  : h('p', { key: 'hint', style: S.hint }, t('routeHealthFallback')),
802
799
  ]));
803
800
  panel.push(h(Card, { key: 'presets', title: t('presetTitle'), hint: t('presetHint') }, [
804
- h('div', { key: 'grid', style: S.presetGrid }, PRESETS.map((p) => h('div', { key: p.id, style: S.presetCard(p.active), onClick: () => { void applyPreset(p); } }, [
805
- h('div', { key: 't', style: rowBetween() }, [h('span', { key: 'title', style: S.label }, t(p.titleKey)), h('span', { key: 'badge', style: S.badge(p.badgeColor) }, p.badge)]),
806
- h('span', { key: 'd', style: S.sub }, t(p.descKey)),
807
- ]))),
801
+ h('div', { key: 'grid', style: S.presetGrid }, PRESETS.map((p) => {
802
+ const cur = liveValue();
803
+ const em = envMap();
804
+ const isMatch = Object.entries(p.fields || {}).every(([k, v]) => cur[k] === v)
805
+ && Object.entries(p.env || {}).every(([k, v]) => String(em[k] ?? '') === String(v));
806
+ return h('div', { key: p.id, style: S.presetCard(isMatch), onClick: () => { void applyPreset(p); } }, [
807
+ h('div', { key: 't', style: rowBetween() }, [h('span', { key: 'title', style: S.label }, t(p.titleKey)), h('span', { key: 'badge', style: S.badge(p.badgeColor) }, p.badge)]),
808
+ h('span', { key: 'd', style: S.sub }, t(p.descKey)),
809
+ ]);
810
+ })),
808
811
  ]));
809
812
  panel.push(h(Card, { key: 'matrix', title: t('matrixTitle'), hint: t('matrixHint') }, [
810
813
  h('div', { key: 'grid', style: S.matrixGrid }, CORE_ENGINES.map((engine) => {
@@ -927,47 +930,48 @@ window.__ModuleLoader__.load({
927
930
 
928
931
  const inject = ['slots', 'locale', 'configForms', 'remote', 'remote.credentials'];
929
932
 
933
+ // 局部 ErrorBoundary:设置页渲染异常时降级为局部报错卡,绝不拖垮宿主界面。
934
+ const PanelBoundary = typeof react.Component === 'function'
935
+ ? class ArgoErrorBoundary extends react.Component {
936
+ constructor(p) { super(p); this.state = { error: null }; }
937
+ static getDerivedStateFromError(error) { return { error }; }
938
+ render() {
939
+ if (this.state.error) {
940
+ return h('div', { style: { padding: 12, color: '#dc2626', fontSize: 12, whiteSpace: 'pre-wrap' } },
941
+ '[argo-dsh] 设置页渲染异常:' + String(this.state.error?.message ?? this.state.error));
942
+ }
943
+ return this.props.children;
944
+ }
945
+ }
946
+ : null;
947
+
948
+ function SafeArgoPanel(props) {
949
+ return PanelBoundary ? h(PanelBoundary, null, h(ArgoPanel, props)) : h(ArgoPanel, props);
950
+ }
951
+
952
+ // plugins.item 仅渲染一行只读摘要,完整 7-Tab 配置收敛至唯一 settings.section 入口。
953
+ function PluginSummaryItem(props) {
954
+ return SafeArgoPanel({ ...props, view: 'summary' });
955
+ }
956
+
930
957
  function apply(ctx) {
931
958
  const form = ctx.configForms.get(NS);
932
959
  const locale = ctx.locale ?? (typeof ctx.get === 'function' ? ctx.get('locale') : undefined);
933
960
  const credentials = ctx.remote ? ctx.remote.credentials : undefined;
934
961
  const label = () => 'Argo 搜索';
935
-
936
- const injected = () => ({
937
- hooks: { argoForm: form },
938
- set: (field, next) => form.set(field, next),
939
- mutate: (ops) => form.mutate(ops),
940
- credentials,
941
- remote: ctx.remote,
942
- locale,
943
- });
962
+ const injected = () => ({ hooks: { argoForm: form }, set: (f, n) => form.set(f, n), mutate: (ops) => form.mutate(ops), credentials, remote: ctx.remote, locale });
944
963
 
945
964
  ctx.effect(() => ctx.configForms.whileServed([NS], () => {
946
965
  const offs = [
947
- ctx.slots.inject('settings.section', () => ctx.slots.register({
948
- name: 'settings.section',
949
- id: SECTION_ID,
950
- order: 26,
951
- label,
952
- inject: injected,
953
- }, ArgoPanel)),
954
- ctx.slots.inject('plugins.item', () => ctx.slots.register({
955
- name: 'plugins.item',
956
- id: SECTION_ID,
957
- order: 50,
958
- label,
959
- inject: injected,
960
- }, ArgoPanel)),
966
+ ctx.slots.inject('settings.section', () => ctx.slots.register({ name: 'settings.section', id: SECTION_ID, order: 26, label, inject: injected }, SafeArgoPanel)),
967
+ ctx.slots.inject('plugins.item', () => ctx.slots.register({ name: 'plugins.item', id: SECTION_ID, order: 50, label, inject: injected }, PluginSummaryItem)),
961
968
  ];
962
- return () => {
963
- for (const off of offs) if (typeof off === 'function') off();
964
- };
969
+ return () => { for (const off of offs) if (typeof off === 'function') off(); };
965
970
  }), 'argo-dsh: settings page');
966
971
 
967
972
  if (typeof window !== 'undefined' && typeof document !== 'undefined' && ctx.slots) {
968
973
  ctx.effect(() => {
969
- let disposed = false;
970
- let unmount = null;
974
+ let disposed = false, unmount = null;
971
975
  import('/argo/workbench-client.js').then((mod) => {
972
976
  if (!disposed && typeof mod?.mountArgoWorkbench === 'function') unmount = mod.mountArgoWorkbench(ctx, react);
973
977
  }).catch(() => {});
@@ -976,17 +980,7 @@ window.__ModuleLoader__.load({
976
980
  }
977
981
  }
978
982
 
979
- exports.apply = apply;
980
- exports.inject = inject;
981
- exports.ArgoPanel = ArgoPanel;
982
- // 静态数据导出供漂移门禁核对:TOOLS 必须与 native-tools.mjs(mcp_tools.py
983
- // 生成产物)同名同集合,ENGINE_TOGGLES 必须与 specs.js 的 ARGO_ENV_SPECS
984
- // 同名同集合——两边任何一边增删而另一边没跟上,测试即红。
985
- exports.TOOLS = TOOLS;
986
- exports.TOOL_GROUPS = TOOL_GROUPS;
987
- exports.ENGINE_TOGGLES = ENGINE_TOGGLES;
988
- exports.KEYS = KEYS;
989
-
983
+ Object.assign(exports, { apply, inject, ArgoPanel, SafeArgoPanel, PanelBoundary, TOOLS, TOOL_GROUPS, ENGINE_TOGGLES, KEYS });
990
984
  return module.exports;
991
985
  }
992
986
  });
@@ -10,7 +10,29 @@ import { homedir } from 'node:os'
10
10
  import { join } from 'node:path'
11
11
 
12
12
  const MAX_BYTES = 1024 * 1024 // 显式读取上限 1MB,防超大日志文件撑爆内存
13
- const BYTE_LIMIT_GUARD = 'maxBytes guard: 1024 * 1024'
13
+
14
+ async function readTailUtf8(filePath, maxBytes) {
15
+ let fh
16
+ try {
17
+ fh = await fs.open(filePath, 'r')
18
+ const { size } = await fh.stat()
19
+ if (size <= 0) return ''
20
+ const len = Math.min(size, maxBytes)
21
+ const offset = size - len
22
+ const buf = Buffer.allocUnsafe(len)
23
+ const { bytesRead } = await fh.read(buf, 0, len, offset)
24
+ const text = buf.subarray(0, bytesRead).toString('utf8')
25
+ if (offset > 0) {
26
+ const firstNl = text.indexOf('\n')
27
+ return firstNl >= 0 ? text.slice(firstNl + 1) : text
28
+ }
29
+ return text
30
+ } finally {
31
+ if (fh) {
32
+ try { await fh.close() } catch { /* ignore */ }
33
+ }
34
+ }
35
+ }
14
36
 
15
37
  /**
16
38
  * 解析 argo 运行时状态目录,遵循 argo_paths.py 跨平台约定:
@@ -52,8 +74,7 @@ export async function getRouteHealth(stateDir, limit = 10) {
52
74
  try {
53
75
  const routePath = join(dir, 'usage_log', 'route.jsonl')
54
76
  if (existsSync(routePath)) {
55
- const text = await fs.readFile(routePath, 'utf8')
56
- const truncated = text.length > MAX_BYTES ? text.slice(-MAX_BYTES) : text
77
+ const truncated = await readTailUtf8(routePath, MAX_BYTES)
57
78
  const lines = truncated.split('\n').filter(Boolean)
58
79
  for (const line of lines) {
59
80
  try {
@@ -114,7 +135,7 @@ export function getMcpPoolStats(pool = []) {
114
135
  const connections = pool.map((conn, index) => ({
115
136
  index,
116
137
  load: typeof conn.load === 'function' ? conn.load() : 0,
117
- hasProcess: Boolean(conn.proc ?? true),
138
+ hasProcess: Boolean(conn.proc),
118
139
  }))
119
140
 
120
141
  const totalLoad = connections.reduce((sum, item) => sum + item.load, 0)
@@ -44,7 +44,9 @@ import {
44
44
  resetEnvResolver,
45
45
  makeNativeTool,
46
46
  disposeSharedMcp,
47
+ searchViaArgoMCP,
47
48
  fetchViaArgo,
49
+ resolveEntry,
48
50
  mapArgoToWebResult,
49
51
  classifyFetchError,
50
52
  } from './runner.js'
@@ -220,12 +222,87 @@ function runEffect(ctx, fn) {
220
222
 
221
223
  const asString = (value, fallback = '') => typeof value === 'string' ? value.trim() : fallback
222
224
 
223
- // 注入执行器的动态环境变量解析逻辑
224
- setEnvResolver(async (options, config) => {
225
- return resolveArgoEnv(config, options)
226
- })
225
+ const DEEPSEEK_MODEL_ROUTES = new Set(['deepseek-official', 'deepseek-account'])
226
+
227
+ export function capWebSearchSources(result, maxResults) {
228
+ if (!result || !Array.isArray(result.sources)) return result
229
+ if (typeof maxResults !== 'number' || !Number.isFinite(maxResults) || maxResults < 0) return result
230
+ if (result.sources.length <= maxResults) return result
231
+ return {
232
+ ...result,
233
+ sources: result.sources.slice(0, maxResults),
234
+ truncated: true,
235
+ }
236
+ }
237
+
238
+ function readConfiguredSearchProvider(web) {
239
+ try {
240
+ const raw = typeof web?.config?.searchProvider?.get === 'function'
241
+ ? web.config.searchProvider.get()
242
+ : web?.config?.searchProvider
243
+ const configured = typeof raw === 'string' && raw !== '' ? raw : web?.searchProviderEnv
244
+ return typeof configured === 'string' && configured !== '' ? configured : undefined
245
+ } catch {
246
+ return undefined
247
+ }
248
+ }
249
+
250
+ /**
251
+ * DSH v0.2.2-rc.5 起,未 pin `web.searchProvider` 时宿主默认把 DeepSeek 路由
252
+ * 交给免费的 `deepseek-official` 服务端搜索,把其他路由写死回落到按次计费的
253
+ * `deepseek-search-api`。这里在不抢占配置位的前提下按 `llmProvider` 透明分流:
254
+ * DeepSeek 路由透传宿主原生搜索;其余路由改由 argo 承接,用户显式 pin 时让位。
255
+ */
256
+ export function installWebSearchRouteDecorator(ctx, web, config, runArgoSearch) {
257
+ if (!web || typeof web.search !== 'function') return undefined
258
+
259
+ const shouldRouteToArgo = (llmProvider) =>
260
+ config.searchProviderEnabled !== false
261
+ && readConfiguredSearchProvider(web) === undefined
262
+ && !DEEPSEEK_MODEL_ROUTES.has(llmProvider)
263
+
264
+ const hadOwnSearch = Object.prototype.hasOwnProperty.call(web, 'search')
265
+ const rawOrigSearch = web.search
266
+ const wrappedSearch = async (request, signal) => {
267
+ if (shouldRouteToArgo(request?.llmProvider)) {
268
+ return capWebSearchSources(await runArgoSearch(request, signal), request?.maxResults)
269
+ }
270
+ return rawOrigSearch.call(web, request, signal)
271
+ }
272
+ web.search = wrappedSearch
273
+
274
+ const hasSearchReady = typeof web.searchReady === 'function'
275
+ const hadOwnSearchReady = hasSearchReady && Object.prototype.hasOwnProperty.call(web, 'searchReady')
276
+ const rawOrigSearchReady = hasSearchReady ? web.searchReady : undefined
277
+ let wrappedSearchReady
278
+ if (hasSearchReady) {
279
+ wrappedSearchReady = async (llmProvider) => {
280
+ if (shouldRouteToArgo(llmProvider)) return true
281
+ return rawOrigSearchReady.call(web, llmProvider)
282
+ }
283
+ web.searchReady = wrappedSearchReady
284
+ }
285
+
286
+ const restore = () => {
287
+ if (web.search === wrappedSearch) {
288
+ if (hadOwnSearch) web.search = rawOrigSearch
289
+ else delete web.search
290
+ }
291
+ if (hasSearchReady && web.searchReady === wrappedSearchReady) {
292
+ if (hadOwnSearchReady) web.searchReady = rawOrigSearchReady
293
+ else delete web.searchReady
294
+ }
295
+ }
296
+ runEffect(ctx, () => restore)
297
+ return restore
298
+ }
299
+
300
+ const _envResolverImpl = async (options, config) => resolveArgoEnv(config, options)
301
+ // 模块导入时预注册,apply() 内也会重注册以保证同进程 HMR 重载不丢失
302
+ setEnvResolver(_envResolverImpl)
227
303
 
228
304
  export function apply(ctx, providedConfig = {}) {
305
+ setEnvResolver(_envResolverImpl)
229
306
  const config = liveConfig(providedConfig)
230
307
  const toolName = asString(config.toolName, DEFAULTS.toolName)
231
308
  const providerName = asString(config.provider, DEFAULTS.provider)
@@ -246,7 +323,7 @@ export function apply(ctx, providedConfig = {}) {
246
323
  }
247
324
  }
248
325
 
249
- for (const ref of asStringArray(config.keyRefs, 20)) {
326
+ for (const ref of asStringArray(config.keyRefs, 64)) {
250
327
  if (!CREDENTIAL_REF_PATTERN.test(ref)) {
251
328
  throw new Error(`argo-dsh: keyRefs entry "${ref}" must be a POSIX-style identifier (e.g. DEEPSEEK_API_KEY)`)
252
329
  }
@@ -290,28 +367,36 @@ export function apply(ctx, providedConfig = {}) {
290
367
 
291
368
  const web = ctx.get?.('web') ?? ctx.web
292
369
  if (web && typeof web.registerSearchProvider === 'function') {
370
+ const runArgoSearch = (request, signal) => {
371
+ const entry = resolveEntry(config)
372
+ return searchViaArgoMCP(request.query, request.maxResults, signal, {
373
+ command: entry.command,
374
+ args: entry.args,
375
+ timeoutMs: config.searchTimeoutMs,
376
+ idleMs: config.searchIdleMs,
377
+ max: config.searchConcurrency,
378
+ config,
379
+ // issue #41:显式带上宿主凭证服务,否则池内连接 envResolver 解析
380
+ // keyRefs 时 provider 为 undefined,所有需 key 引擎静默 skipped。
381
+ credentials: hostCredentials,
382
+ })
383
+ }
293
384
  web.registerSearchProvider({
294
385
  id: asString(config.searchProviderId, DEFAULTS.searchProviderId),
386
+ title: 'Argo Multi-Engine Search',
387
+ description: '多引擎融合搜索、证据核验与中文增强(通过本机 argo-search 路由)',
295
388
  available: () => config.searchProviderEnabled !== false,
296
- search: (request, signal) => {
297
- const entry = resolveEntry(config)
298
- return searchViaArgoMCP(request.query, request.maxResults, signal, {
299
- command: entry.command,
300
- args: entry.args,
301
- timeoutMs: config.searchTimeoutMs,
302
- idleMs: config.searchIdleMs,
303
- max: config.searchConcurrency,
304
- config,
305
- // issue #41:显式带上宿主凭证服务,否则池内连接 envResolver 解析
306
- // keyRefs 时 provider 为 undefined,所有需 key 引擎静默 skipped。
307
- credentials: hostCredentials,
308
- })
309
- },
389
+ ready: () => config.searchProviderEnabled !== false,
390
+ search: runArgoSearch,
310
391
  })
392
+ installWebSearchRouteDecorator(ctx, web, config, runArgoSearch)
311
393
  if (typeof web.registerFetchProvider === 'function') {
312
394
  web.registerFetchProvider({
313
395
  id: asString(config.fetchProviderId, DEFAULTS.fetchProviderId),
396
+ title: 'Argo Web Fetch',
397
+ description: '多级降级网页全文提取与反爬绕过(通过本机 argo-search)',
314
398
  available: () => config.fetchProviderEnabled !== false,
399
+ ready: () => config.fetchProviderEnabled !== false,
315
400
  fetch: (request, signal) => {
316
401
  const entry = resolveEntry(config)
317
402
  return fetchViaArgo(request.url, signal, {
@@ -332,10 +417,14 @@ export function apply(ctx, providedConfig = {}) {
332
417
 
333
418
  const nativeRegistrations = new Map()
334
419
  // 路由观测推送:原生工具执行后读 argo 使用日志,经 remote 事件推给设置面板。
335
- // 失败静默(诊断是增值,不是依赖);无 remote 事件总线时跳过。
420
+ // 节流 3s 避免高频搜索连续读盘;失败静默,无 remote 事件总线时跳过。
421
+ let lastRouteEmitAt = 0
336
422
  const emitRouteHealth = async () => {
337
423
  try {
338
424
  if (!ctx.remote || typeof ctx.remote.$emit !== 'function') return
425
+ const now = Date.now()
426
+ if (now - lastRouteEmitAt < 3000) return
427
+ lastRouteEmitAt = now
339
428
  const data = await getRouteHealth()
340
429
  if (Array.isArray(data.samples) && data.samples.length > 0) {
341
430
  ctx.remote.$emit('route-health/updated', data)
@@ -374,7 +463,6 @@ export function apply(ctx, providedConfig = {}) {
374
463
  }
375
464
  nativeRegistrations.clear()
376
465
  resetEnvResolver()
377
- disposeSharedMcp()
378
466
  })
379
467
 
380
468
  ctx.tools.register(createWideResearchTool(ctx, config, {