argo-search 2.10.2 → 2.12.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/README.en.md +36 -21
  2. package/README.es.md +35 -20
  3. package/README.ja.md +36 -21
  4. package/README.ko.md +35 -20
  5. package/README.md +41 -22
  6. package/SKILL.md +19 -18
  7. package/backends/domain_profiles.json +30 -6
  8. package/backends/engine_registry.yaml +63 -13
  9. package/backends/quota_profiles.json +50 -10
  10. package/bin/argo +13 -0
  11. package/config.yaml +34 -20
  12. package/docs/ENGINE_CATALOG.md +14 -9
  13. package/docs/MCP_SETUP.md +16 -4
  14. package/docs/RELEASE_NOTES_v2.11.2.md +166 -0
  15. package/docs/RELEASE_NOTES_v2.12.0.md +65 -0
  16. package/docs/engines/pixiv.md +27 -0
  17. package/engines/specs/animetrace.yaml +35 -0
  18. package/engines/specs/google_lens.yaml +50 -0
  19. package/engines/specs/pixiv.yaml +52 -0
  20. package/engines/specs/saucenao.yaml +45 -0
  21. package/engines/specs/tracemoe.yaml +33 -0
  22. package/package.json +4 -2
  23. package/packages/dsh-plugin/README.md +20 -11
  24. package/packages/dsh-plugin/dsh/client.js +3 -3
  25. package/packages/dsh-plugin/dsh/index.js +27 -176
  26. package/packages/dsh-plugin/dsh/runner.js +19 -3
  27. package/packages/dsh-plugin/dsh/specs.js +133 -0
  28. package/packages/dsh-plugin/package.json +10 -2
  29. package/packages/dsh-plugin/test/client.test.js +4 -4
  30. package/packages/dsh-plugin/test/diagnostics.test.js +1 -1
  31. package/packages/dsh-plugin/test/index.test.js +49 -2
  32. package/scripts/adaptive.py +101 -27
  33. package/scripts/budget.py +13 -3
  34. package/scripts/build_route_labels.py +122 -169
  35. package/scripts/caliber_dedupe.py +4 -4
  36. package/scripts/caliber_isolation.py +17 -17
  37. package/scripts/concept_lookup.py +14 -1
  38. package/scripts/config.py +21 -3
  39. package/scripts/engine_admission.py +35 -17
  40. package/scripts/engine_dispatch.py +18 -17
  41. package/scripts/engine_env.py +4 -0
  42. package/scripts/engine_families.py +10 -4
  43. package/scripts/engines.py +15 -2
  44. package/scripts/engines_base.py +1 -1
  45. package/scripts/engines_builders.py +0 -1
  46. package/scripts/engines_builders_data.py +10 -10
  47. package/scripts/engines_builders_intl.py +4 -4
  48. package/scripts/engines_builders_pixiv.py +633 -0
  49. package/scripts/engines_builders_reverse_image.py +958 -0
  50. package/scripts/engines_builders_tech.py +0 -78
  51. package/scripts/env_store.py +216 -0
  52. package/scripts/extend_route_labels_by_capability.py +4 -4
  53. package/scripts/extend_route_labels_by_language.py +306 -0
  54. package/scripts/extend_route_labels_full_coverage.py +329 -0
  55. package/scripts/fetch_v3.py +74 -5
  56. package/scripts/image_vision/vision_probe +0 -0
  57. package/scripts/job.py +33 -7
  58. package/scripts/lint_spec_contracts.py +110 -0
  59. package/scripts/lint_stub_targets.py +130 -0
  60. package/scripts/local_image.py +25 -11
  61. package/scripts/mcp_compact.py +13 -0
  62. package/scripts/mcp_launch.sh +1 -1
  63. package/scripts/mcp_setup.py +85 -1
  64. package/scripts/mcp_transport.py +1 -1
  65. package/scripts/net_proxy.py +47 -0
  66. package/scripts/plan.py +11 -0
  67. package/scripts/pre-commit +24 -13
  68. package/scripts/query_signals.py +35 -20
  69. package/scripts/quota.py +116 -12
  70. package/scripts/recovery.py +38 -13
  71. package/scripts/redskill/redskill_engine.py +33 -10
  72. package/scripts/route.py +2 -2
  73. package/scripts/route_accuracy_eval.py +2 -2
  74. package/scripts/route_combo.py +22 -3
  75. package/scripts/route_domains.py +182 -50
  76. package/scripts/search.py +13 -14
  77. package/scripts/search_entry.py +38 -42
  78. package/scripts/search_output.py +3 -0
  79. package/scripts/search_pipeline.py +18 -23
  80. package/scripts/search_rank.py +22 -7
  81. package/scripts/serp_guard.py +7 -16
  82. package/scripts/settings_page.py +486 -0
  83. package/scripts/social_engines/twitter_engine.py +35 -2
  84. package/scripts/social_engines/xiaohongshu_engine.py +25 -0
  85. package/scripts/straggler_policy.py +8 -4
  86. package/scripts/tfidf_router.py +82 -24
@@ -0,0 +1,50 @@
1
+ # Google Lens · 通用视觉同源反查(SerpAPI 托管)
2
+ #
3
+ # 输入形态特殊:query 是一张图(公网图片 URL 或本地图片路径),不是关键词。上游
4
+ # 拿这张图做视觉匹配,分三档回来:exact_matches(就是这张图)、visual_matches
5
+ # (长得像的图与同源商品/帖子)、organic_results(讲到这张图的网页)。结果条目
6
+ # 各自带 `metadata.match_type` 标注归属哪一档——三档混成一列而不标注,调用方会
7
+ # 把「另一张相似的图」当成这张图的出处。
8
+ #
9
+ # 本地图片先 POST 到 SerpAPI Image API(`https://serpapi.com/image`,multipart,
10
+ # 只收 JPEG/PNG/WebP、单张 ≤500KB)换 `image_id`,再用 `image_id` 检索;该 id
11
+ # 10 分钟内有效,故上传后立即用掉。超限的本地图先缩到 1024px,仍超再退 768/512。
12
+ #
13
+ # 为什么走 SerpAPI:Google Lens 官方没有公开 API,免 key 的
14
+ # `lens.google.com/uploadbyurl` 只回壳页(2026-11-04 实测 200 但无结果 JSON)。
15
+ # SerpAPI 的 `engine=google_lens` 是文档最全的托管通道:`url` 传图片直链或
16
+ # `image_id` 传上传图,`type` 选 all/exact_matches/visual_matches,返回结构见
17
+ # https://serpapi.com/google-lens-api 。
18
+ #
19
+ # 计费:paid 档,按次扣费(Free 计划 250 次/月、50 次/小时);1 小时内完全相同
20
+ # 的参数走 SerpAPI 缓存、不计次。cost_per_call 按 Developer 计划 $75/5000 次
21
+ # ≈ ¥0.11/次折算,仅用于预算面板估算,不代表实扣金额。
22
+ #
23
+ # 路由形态:explicit_only —— 没有图片的普通查询落进来只会得到错误条目,
24
+ # 故不进自动路由候选池;用法是 `argo search "<图片URL或本地路径>" --engine google_lens`。
25
+ #
26
+ # 验证:
27
+ # python3 scripts/engine_validate.py --engine google_lens --stage all --admit --write-doc
28
+
29
+ engine_id: google_lens
30
+ type: google_lens
31
+ enabled: true
32
+ explicit_only: true
33
+ cost_tier: paid
34
+ cost_per_call: 0.11
35
+ cost_unit: cny
36
+ timeout: 30
37
+ num_results: 8
38
+ search_type: all
39
+ hl: zh-CN
40
+ country: cn
41
+ canary_query: "https://files.yande.re/image/2555de7669c169cd98a6c9da7da27edd/yande.re%20447155%20bigxixi%20feet%20pantyhose%20see_through.jpg"
42
+ label: Google Lens 反搜图
43
+ family: misc_vertical
44
+ priority: 37
45
+ required_env:
46
+ - ARGO_SERPAPI_API_KEY
47
+
48
+ coverage: [image, reverse_image]
49
+
50
+ desc: Google Lens 通用视觉反查(query 为公网图片 URL 或本地图片路径,本地图经 SerpAPI Image API 上传,付费档 250 次/月免费额度,回精确匹配/视觉相似/相关网页三档);cost_per_call ¥0.11 按 Developer 计划 $75/5000 次折算,仅面板估算,不代表实扣
@@ -0,0 +1,52 @@
1
+ # Pixiv 公开作品检索:关键词搜索与画师作品列表,匿名 Web / OAuth App API 双通道
2
+ #
3
+ # 未配置 refresh token 时走匿名 Web Ajax;配置后只走 App API,不合并或回退。
4
+ # 结果 channel 标出实际取数通道(web/app),排查时用于区分内容范围差异。
5
+ # Web/App 均无公开稳定性承诺,Pixiv 随时可能调整接口行为。
6
+ #
7
+ # 画师作品查询:query 写 user:<画师 id>、https://www.pixiv.net/users/<id>、
8
+ # 五到九位纯数字,或 画师:<画师名>(经 App 用户搜索取最匹配的一位)。
9
+ # 画师查询后接空格分隔的标签,用于在该画师作品里收窄,如 画师:ke-ta フランドール。
10
+ # 画师作品列表只有 App 接口能给出可用的图片直链,匿名通道返回明确提示。
11
+ #
12
+ # 标签匹配口径:search_target 取 partial_match_for_tags(默认,Web 用 s_mode=s_tag)、
13
+ # exact_match_for_tags(Web 用 s_mode=s_tag_full)、title_and_caption(Web 用 s_mode=s_tc);
14
+ # 调用方也可在单次请求里覆盖。标签串按空格分隔多个标签,日文名与中文本地化标签都能命中。
15
+ #
16
+ # 可选环境变量:
17
+ # ARGO_PIXIV_REFRESH_TOKEN Pixiv OAuth refresh token(只读,勿写入仓库)
18
+ # ARGO_PIXIV_ALLOW_R18 true 时允许 App R-18 结果与下游预览;默认过滤
19
+ #
20
+ # 防盗链说明:i.pximg.net 的图片直链需要 Referer: https://www.pixiv.net/ 才能下载,
21
+ # 插件层的图片下载链路已自动补全该头部,CLI 或其他直接访问场景需手动加 Referer。
22
+ #
23
+ # 图片直链:App 通道对每条结果并发补一次作品详情,image_url 取原图(meta_single_page
24
+ # 或多页作品的第一张),原图宽高比与预览一致;详情失败或取不到时保持 large 档。
25
+ # 此时 image_url_preview 保留 large 直链,供下游在体积超限时回退。
26
+ #
27
+ # App 支持 partial_match_for_tags / exact_match_for_tags / title_and_caption、
28
+ # start_date / end_date(YYYY-MM-DD)、search_ai_type=0/1 与 popular_desc。
29
+ # 验证:
30
+ # python3 scripts/engine_validate.py --engine pixiv --stage all --admit --write-doc
31
+
32
+ engine_id: pixiv
33
+ type: pixiv
34
+ enabled: true
35
+ explicit_only: true
36
+ cost_tier: free
37
+ family: misc_vertical
38
+ priority: 34
39
+ timeout: 20
40
+ order: date
41
+ canary_query: "初音ミク"
42
+ label: Pixiv 公开作品
43
+ desc: "Pixiv 作品检索:关键词搜图或按画师(user:<id>、画师主页链接、画师:<名>)列作品;结果标通道,默认过滤 R-18"
44
+ coverage: [image, media, web]
45
+ recommended: false
46
+ latency_ms: 2500
47
+
48
+ image_license: "版权所有(Pixiv 作品,作者保留权利)"
49
+
50
+ quality_queries:
51
+ - query: "初音ミク"
52
+ - query: "hatsune miku"
@@ -0,0 +1,45 @@
1
+ # SauceNAO · 二次元图源反查
2
+ #
3
+ # 输入形态特殊:query 必须是**公网可访问的图片 URL**,不是关键词。上游拿这张图
4
+ # 做指纹比对,返回它出自哪个库(Pixiv / Danbooru / Twitter / 游戏 CG 等),
5
+ # 以及相似度、作者、出处页。
6
+ #
7
+ # 为什么必须配 key:匿名档已关闭 API 调用(2026-11-04 实测不带 api_key 返回
8
+ # {"header":{"status":-1,"message":"The anonymous account type does not permit
9
+ # API usage."}})。saucenao.com 免费注册后每天 150 次;没有 key 时本引擎
10
+ # 在自动路由里被跳过,显式调用返回一条「缺 key」的 error 条目。
11
+ #
12
+ # 出口:站点在 Cloudflare 之后,urllib 直连吃 403 挑战页;取数走 TLS 指纹伪造
13
+ # (curl_cffi impersonate),代理仍按 net_proxy 的域规则/全局配置解析。
14
+ #
15
+ # 路由形态:explicit_only —— 没有图片 URL 的普通查询落进来只会得到错误条目,
16
+ # 故不进自动路由候选池;用法是 `argo search "<图片URL>" --engine saucenao`。
17
+ #
18
+ # 验证:
19
+ # python3 scripts/engine_validate.py --engine saucenao --stage all --admit --write-doc
20
+
21
+ engine_id: saucenao
22
+ type: saucenao
23
+ enabled: true
24
+ explicit_only: true
25
+ cost_tier: free
26
+ timeout: 20
27
+ num_results: 5
28
+ min_similarity: 30
29
+ # hide:0 全显示 / 1 隐藏露骨 / 2 再隐藏疑似露骨 / 3 只留安全内容。群聊默认 1——
30
+ # Pixiv、Kemono 这类库本身就带成人内容,等回传后再由调用方筛已经晚了。
31
+ hide: 1
32
+ # dedupe:0 不去重 / 1 按条目去重 / 2 连系列一起并(SauceNAO 默认 2)。
33
+ dedupe: 2
34
+ # db=999 搜全部索引;要限定库时换成 dbs: [5, 43](索引号列表,与 db 互斥)。
35
+ db: 999
36
+ canary_query: "https://files.yande.re/image/2555de7669c169cd98a6c9da7da27edd/yande.re%20447155%20bigxixi%20feet%20pantyhose%20see_through.jpg"
37
+ label: SauceNAO 反搜图
38
+ family: misc_vertical
39
+ priority: 35
40
+ required_env:
41
+ - ARGO_SAUCENAO_API_KEY
42
+
43
+ coverage: [image, reverse_image]
44
+
45
+ desc: SauceNAO 二次元图源反查(query 为图片 URL 或本地图片路径,免费 key 150 次/日,给相似度与 Pixiv 等出处页)
@@ -0,0 +1,33 @@
1
+ # trace.moe · 动画场景识别
2
+ #
3
+ # 输入形态特殊:query 必须是**公网可访问的图片 URL**,不是关键词。上游返回图中
4
+ # 场景所属动画作品、集数与时间点(AniList ID + filename + episode + at),并给出
5
+ # similarity(0-1)。
6
+ #
7
+ # 免 key,但按出口 IP 限频:免费档 100 次/小时(quota 字段可见)。实测共享机场
8
+ # 节点出口常被别的客户端打到 429,而该 API 直连可达——故 config.yaml 的
9
+ # network.proxy.rules 给 api.trace.moe 配了 ${ARGO_TRACEMOE_PROXY}(未设置即直连)。
10
+ #
11
+ # 结果形态:上游只给作品名/文件名/集数/时间点,不给「这张图出自哪一页」。url 槽
12
+ # 填 AniList 作品页(下一步去哪儿查证的入口),不是宣称图源就是那一页。
13
+ #
14
+ # 路由形态:explicit_only —— 理由同 saucenao,只经显式调用。
15
+ #
16
+ # 验证:
17
+ # python3 scripts/engine_validate.py --engine tracemoe --stage all --admit --write-doc
18
+
19
+ engine_id: tracemoe
20
+ type: tracemoe
21
+ enabled: true
22
+ explicit_only: true
23
+ cost_tier: free
24
+ timeout: 20
25
+ min_similarity: 0.7
26
+ canary_query: "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png"
27
+ label: trace.moe 场景识别
28
+ family: misc_vertical
29
+ priority: 38
30
+
31
+ coverage: [image, reverse_image]
32
+
33
+ desc: trace.moe 动画场景识别(query 为图片 URL,免 key,给作品名+集数+时间点,按出口 IP 限频)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "argo-search",
3
- "version": "2.10.2",
4
- "description": "Argo 阿尔戈 — 统一搜索与证据核验。推荐 npx -y argo-search(npm 发布版)或 install.sh 安装。多语言路由、284 个源(240 个免密钥开箱可用)、影视/体育/金融等垂直源、19 个 MCP 工具(与 CLI 能力面对齐)。",
3
+ "version": "2.12.0",
4
+ "description": "Argo 阿尔戈 — 统一搜索与证据核验。推荐 npx -y argo-search(npm 发布版)或 install.sh 安装。多语言路由、288 个源(242 个免密钥开箱可用)、影视/体育/金融等垂直源、19 个 MCP 工具(与 CLI 能力面对齐)。",
5
5
  "keywords": [
6
6
  "mcp",
7
7
  "mcp-server",
@@ -55,6 +55,8 @@
55
55
  "docs/RELEASE_NOTES_v2.9.0.md",
56
56
  "docs/RELEASE_NOTES_v2.10.1.md",
57
57
  "docs/RELEASE_NOTES_v2.10.2.md",
58
+ "docs/RELEASE_NOTES_v2.12.0.md",
59
+ "docs/RELEASE_NOTES_v2.11.2.md",
58
60
  "docs/RELEASE_NOTES_v2.10.0.md",
59
61
  "docs/RELEASE_NOTES_v2.9.9.md",
60
62
  "docs/RELEASE_NOTES_v2.9.8.md",
@@ -4,28 +4,35 @@ DeepSeek Harness 插件:一行同时挂上 [Argo](https://github.com/taxueseek
4
4
 
5
5
  ## 安装
6
6
 
7
+ 版本号以仓库根 `package.json` 的 `version` 为准(与 `argo --version`、npm 上的 `argo-search` 同步),本文不复制版本号。
8
+
7
9
  ```bash
8
- dsh plugin --profile web add @taxueseek/argo-dsh # npm 发布版,已支持,当前 2.10.0
10
+ dsh plugin --profile web add @taxueseek/argo-dsh # npm 发布版
9
11
  dsh plugin --profile web add "github:taxueseek/argo#main&path:packages/dsh-plugin" # GitHub main
10
12
  ```
11
13
 
12
- 重启 `dsh web` 后生效。
14
+ `@taxueseek/argo-dsh` 是 DSH 插件包,`argo-search` 是 CLI 包,两者不能互换。重启 `dsh web` 后生效。
13
15
 
14
- ### 本地开发:改完源码必须同步进 profile
16
+ ### 本地开发:改完源码必须同步进 profile(改动收尾固定步骤)
15
17
 
16
18
  profile 里的依赖是 `file:` / `github:`,pnpm 安装时**复制**进
17
19
  `node_modules/@taxueseek/argo-dsh`,不是软链。只改本仓源码、不跑同步,
18
20
  DSH 设置页读到的仍是旧 bundle(2026-10-22 实测:缓存开关与付费额度已改,
19
- 面板仍显示旧版)。
21
+ 面板仍显示旧版;2026-11-08 复核:web 与 desktop 两个 profile 均已漂移)。
20
22
 
21
23
  ```bash
22
- packages/dsh-plugin/scripts/sync-local.sh --check # 比对源码与已安装 bundle
23
- packages/dsh-plugin/scripts/sync-local.sh # 同步 web/desktop
24
- packages/dsh-plugin/scripts/sync-local.sh --restart # 同步并重启 dsh web
24
+ packages/dsh-plugin/scripts/sync-local.sh --check # 1. 比对源码与已安装 bundle,有漂移退出 1
25
+ packages/dsh-plugin/scripts/sync-local.sh # 2. 同步 web/desktop
26
+ packages/dsh-plugin/scripts/sync-local.sh --restart # 3. 同步并重启 dsh web
25
27
  ```
26
28
 
27
- 同步会先备份到 `~/.dsh/backups/argo-dsh-sync-<时间>-<profile>`;浏览器如仍显示
28
- 旧面板,做一次硬刷新(Cmd+Shift+R)。
29
+ **改完源码或文档后,必须跑到 `sync-local.sh --check` 输出 `[ok]` 才算交付完成**;不适用 `--check` 的场景(例如只改仓库内文档、不影响已安装 bundle)要在交付说明里写明跳过理由。同步会先备份到 `~/.dsh/backups/argo-dsh-sync-<时间>-<profile>`;浏览器如仍显示旧面板,做一次硬刷新(Cmd+Shift+R)。
30
+
31
+ ### 当前启用状态(web profile)
32
+
33
+ `wide_research` 编排、原生 `argo_search` / `argo_fetch` 与 `web` 服务行的 `searchProvider: argo` 已在用户层 `~/.dsh/profiles/web/cordis.patch.yml` 默认启用,无需取消任何注释即可使用。profile patch 里 `mcp-argo` 段注释掉的「按需开启」只针对 MCP 完整工具面,不代表整个插件未启用。
34
+
35
+ 该 patch 的 `fetchProviderEnabled: false` 是主动关闭 fetch seam,因此 `web` 服务行不 pin `fetchProvider`;若改为启用 fetch seam,必须按本文「web seam 的 pin 必读」一节在 `web` 服务行加 `fetchProvider: argo`,否则多个可用 provider 会触发 `WEB_PROVIDER_AMBIGUOUS`。
29
36
 
30
37
  本 bundle 提供 **三形态接入**——同一套 argo 检索能力(同引擎、同压缩、同守卫),三种调用通道互为冗余,按宿主能力自动降级:
31
38
 
@@ -89,7 +96,7 @@ argo 的 `deepseek_search` 引擎(官方 `api.deepseek.com/v1/tools/search`,
89
96
  - 安全:插件不读 key 文件、不落盘、不打日志;key 值只经内存进入 argo 子进程 env,任何输出与错误信息都不含它
90
97
  - 旧宿主无 credentials 服务时静默跳过:argo 侧该引擎按缺 key 停用,其余 265 个源不受影响
91
98
  - `keyRefs: []` 可整体关闭转发;后续要转发别的宿主凭证(如 `ARGO_EXA_API_KEY`),把引用名加进数组即可,entry 必须是 POSIX 标识符(apply 期 loud fail)
92
- - `argoEnv`(设置页「引擎」分区写入):argo 行为开关,一行一个 `KEY=VALUE`,名字限 curated 白名单(index.js 的 `ARGO_ENV_SPECS`,35 个;白名单外 apply 期 loud fail,防拼错静默失效);授权位与路径 / 状态类变量刻意不收。与 `keyRefs` 的分工:`keyRefs` 管密钥(凭证库),`argoEnv` 管行为开关(插件配置),两者都不落明文
99
+ - `argoEnv`(设置页「引擎」分区写入):argo 行为开关,一行一个 `KEY=VALUE`,名字限 curated 白名单(specs.js 的 `ARGO_ENV_SPECS`,35 个;白名单外 apply 期 loud fail,防拼错静默失效);授权位与路径 / 状态类变量刻意不收。与 `keyRefs` 的分工:`keyRefs` 管密钥(凭证库),`argoEnv` 管行为开关(插件配置),两者都不落明文
93
100
 
94
101
  ## 依赖
95
102
 
@@ -100,9 +107,11 @@ argo 的 `deepseek_search` 引擎(官方 `api.deepseek.com/v1/tools/search`,
100
107
 
101
108
  ## Compatibility(DSH Harness 版本对照)
102
109
 
110
+ 本机 `dsh --version` 与插件 `package.json` 的 `dsh.compatibility` 是版本真源;下表只保留历史验证记录,不声明「当前」版本。
111
+
103
112
  | argo-dsh | DSH Harness | 说明 |
104
113
  |----------|-------------|------|
105
- | 2.10.0(当前) | 0.2.1-rc.2(当前,运行中) | 与 2.9.9 同一套宿主适配;本版新增的技能索引/DSH 插件目录源与视频抓取都走既有工具面,插件侧无需改动 |
114
+ | 2.11.2(本机已装) | 0.2.2-rc.1(本机运行中) | `package.json` 的 compatibility 已含该版本;`wide_research` 与原生工具走既有工具面,插件侧无需改动 |
106
115
  | 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) |
107
116
  | 2.9.7(上一版,兼容) | 0.2.1-alpha.1(实测,兼容) | 旧宿主走 `start(provider, request)` 分支,`toolFilter` 启动期字段仍认;该分支由插件单测覆盖,未在 alpha.x 上重跑端到端 |
108
117
  | 2.9.2 | 0.2.1-alpha.1(实测) | 上一轮适配验证基线;rc.2 的新入口与 tool guard 自 2.9.4 起进入 |
@@ -344,7 +344,7 @@ window.__ModuleLoader__.load({
344
344
  { id: 'zhihu', nameZh: '知乎 Zhihu', nameEn: 'Zhihu', roleZh: '中文专业问答舆情', roleEn: 'Professional Q&A / Social', ref: 'ZHIHU_ACCESS_SECRET', keyless: true },
345
345
  ];
346
346
 
347
- // argo 引擎开关(argoEnv 的 KEY=VALUE 行)。与 index.js 的 ARGO_ENV_SPECS
347
+ // argo 引擎开关(argoEnv 的 KEY=VALUE 行)。与 specs.js 的 ARGO_ENV_SPECS
348
348
  // 同一份名单,由 test/client.test.js 的漂移门禁核对;kind 决定控件:
349
349
  // bool=开关、num=数字、str=文本、list=名单。def 仅作「未配置时显示什么」,
350
350
  // 缺省即不写该行。开关文案写正向行为或明确的关闭动作,不再用 invert 反转
@@ -1318,7 +1318,7 @@ window.__ModuleLoader__.load({
1318
1318
  //
1319
1319
  // 历史 bug(2026-10-21 定位):`paid` 一度不在这个清单里,于是
1320
1320
  // ARGO_PAID_SEARCH 与 ARGO_BUDGET_DEEPSEEK_SEARCH 两条开关在
1321
- // index.js 白名单、client.js ENGINE_TOGGLES、双语文案三处都齐全,
1321
+ // specs.js 白名单、client.js ENGINE_TOGGLES、双语文案三处都齐全,
1322
1322
  // 却在面板上完全不显示——用户配好了预算却找不到入口,还以为是插件
1323
1323
  // 没装。漂移门禁只核对「两边名单同集合、字段一致」,核对不到「这个
1324
1324
  // 分组到底渲不渲染」;已由 test/client.test.js 的「engines tab renders
@@ -1588,7 +1588,7 @@ window.__ModuleLoader__.load({
1588
1588
  exports.inject = inject;
1589
1589
  exports.ArgoPanel = ArgoPanel;
1590
1590
  // 静态数据导出供漂移门禁核对:TOOLS 必须与 native-tools.mjs(mcp_tools.py
1591
- // 生成产物)同名同集合,ENGINE_TOGGLES 必须与 index.js 的 ARGO_ENV_SPECS
1591
+ // 生成产物)同名同集合,ENGINE_TOGGLES 必须与 specs.js 的 ARGO_ENV_SPECS
1592
1592
  // 同名同集合——两边任何一边增删而另一边没跟上,测试即红。
1593
1593
  exports.TOOLS = TOOLS;
1594
1594
  exports.TOOL_GROUPS = TOOL_GROUPS;
@@ -22,6 +22,18 @@ import { createRequire } from 'node:module'
22
22
  import { dirname, join } from 'node:path'
23
23
  import { fileURLToPath } from 'node:url'
24
24
  import { NATIVE_TOOLS as NATIVE_TOOL_SPECS } from './native-tools.mjs'
25
+ import {
26
+ DEFAULT_CHILD_TOOLS,
27
+ buildChildToolFilters,
28
+ ARGO_ENV_SPECS,
29
+ ARGO_ENV_NAMES,
30
+ parseArgoEnvLine,
31
+ resolveArgoEnv,
32
+ setHostCredentials,
33
+ setActiveConfig,
34
+ CREDENTIAL_REF_PATTERN,
35
+ asStringArray,
36
+ } from './specs.js'
25
37
 
26
38
  const require = createRequire(import.meta.url)
27
39
 
@@ -29,41 +41,19 @@ import {
29
41
  DEFAULTS,
30
42
  PLUGIN_VERSION as RUNNER_PLUGIN_VERSION,
31
43
  setEnvResolver,
32
- resolveEntry,
33
- resolveNativeSpawn,
44
+ resetEnvResolver,
34
45
  makeNativeTool,
35
- nativeViaMcpPool,
36
- runNativeCall,
37
46
  disposeSharedMcp,
38
- searchViaArgoMCP,
39
47
  fetchViaArgo,
40
48
  mapArgoToWebResult,
41
- mapArgoToWebFetch,
42
49
  classifyFetchError,
43
- argoAborted,
44
- argoToolError,
45
50
  } from './runner.js'
46
51
 
47
52
  import {
48
- normalizeTracks,
49
- stageTracks,
50
- evaluateGates,
51
- normalizeSource,
52
- normalizeSourceUrl,
53
- buildLocalSources,
54
- parseJsonArray,
55
- parseJsonObject,
56
- extractValues,
57
- persistReport,
58
- startStructured,
59
- providerSupportsStructured,
60
- recomputeViaArgoMCP,
61
53
  createWideResearchTool,
62
54
  } from './wide-research.js'
63
55
 
64
56
  import {
65
- getMcpPoolStats,
66
- resetMcpPool,
67
57
  getRouteHealth,
68
58
  } from './diagnostics.js'
69
59
 
@@ -92,106 +82,11 @@ function resolvePluginVersion() {
92
82
  return RUNNER_PLUGIN_VERSION || '0.0.0-unknown'
93
83
  }
94
84
 
95
- export const PLUGIN_VERSION = resolvePluginVersion()
85
+ const PLUGIN_VERSION = resolvePluginVersion()
96
86
 
97
87
  export const name = 'wide-research'
98
88
  export const inject = ['tools', 'subagents', 'systemPrompt', 'web']
99
89
 
100
- const MCP_CHILD_TOOLS = Object.keys(NATIVE_TOOL_SPECS).map(name => `mcp__argo__${name}`)
101
- const DEFAULT_CHILD_TOOLS = Object.freeze([
102
- ...MCP_CHILD_TOOLS,
103
- 'argo_search',
104
- 'argo_fetch',
105
- 'web_search',
106
- 'web_fetch',
107
- ])
108
-
109
- export function buildChildToolFilters(config, toolName) {
110
- const base = Array.isArray(config?.childToolAllow) ? config.childToolAllow : DEFAULT_CHILD_TOOLS
111
- const blocked = new Set([toolName, 'mcp__argo__argo_research'])
112
- const deny = [...new Set([toolName, ...asStringArray(config?.childToolDeny, 100)])]
113
- const denySet = new Set(deny)
114
- const allow = [...new Set(asStringArray(base, 100).filter(tool => !blocked.has(tool) && !denySet.has(tool)))]
115
- return { allow, deny }
116
- }
117
-
118
- /**
119
- * 面板可露出的 argo 环境变量开关(curated 白名单)。
120
- *
121
- * 选录标准:日常会开合的行为开关,语义单一、默认值在 argo 侧稳定;授权位
122
- * (ARGO_ALLOW_RECOMPUTE / ARGO_ALLOW_PRIVATE_URLS,argo 要求 expand=False
123
- * + strict=True)与路径/状态类内部变量(ARGO_STATE_DIR / ARGO_HOME /
124
- * ARGO_DAEMON 等)刻意不收——前者不该一键放行,后者改了会动摇凭证 seam 的
125
- * 解析前提。每个名字都在 argo 仓 scripts/ 有读取点,由
126
- * tests/test_dsh_plugin_env_gate.py 对拍,防白名单漂移成 Fiction。
127
- *
128
- * kind:bool=开关(值 0/1)、num=数字,str=字符串,list=名单(逗号或路径分隔符分隔,照 argo 原语义)。
129
- * def=argo 侧默认值(仅面板展示用,缺省即不写该行、由 argo 自己决定)。
130
- *
131
- * 开关文案一律写「正向行为」或「明确的关闭动作」,**不要再用 invert 反转**:
132
- * 历史 bug(2026-10-22)——`关闭搜索结果缓存` 配 invert 后,未配置时面板显示
133
- * 为「开」,点一下反而把 ARGO_NO_CACHE 写成 0,缓存始终没关掉。
134
- */
135
- export const ARGO_ENV_SPECS = Object.freeze([
136
- { name: 'ARGO_NO_CACHE', kind: 'bool', group: 'cache', def: false, zh: '测试模式(关闭结果缓存)', en: 'Test mode (disable result cache)', hintZh: '日常保持关闭:结果缓存 1 小时。改进 Skill/插件、需要看实时结果时再打开', hintEn: 'Off by default: results are cached for 1h. Enable only when developing the skill/plugin' },
137
- { name: 'ARGO_TFIDF_RERANK', kind: 'bool', group: 'cache', def: true, zh: 'TF-IDF 重排', en: 'TF-IDF rerank', hintZh: '多引擎结果融合前的相关性重排,默认开', hintEn: 'Relevance rerank before fusion, on by default' },
138
- { name: 'ARGO_NUMBER_CROSSCHECK', kind: 'bool', group: 'cache', def: true, zh: '数值交叉校验', en: 'Number cross-check', hintZh: '对查询里的数值主张做跨源核对,默认开', hintEn: 'Cross-check numeric claims across sources, on by default' },
139
- { name: 'ARGO_MINHASH_DEDUPE', kind: 'bool', group: 'cache', def: true, zh: 'MinHash 去重', en: 'MinHash dedupe', hintZh: '近重复结果合并,默认开', hintEn: 'Merge near-duplicate results, on by default' },
140
- { name: 'ARGO_MINHASH_THRESHOLD', kind: 'num', group: 'cache', def: 0.85, min: 0.5, max: 1, step: 0.05, zh: '去重阈值', en: 'Dedupe threshold', hintZh: '越高越严(越多判为不同),默认 0.85', hintEn: 'Higher = stricter, default 0.85' },
141
- { name: 'ARGO_SERP_GUARD', kind: 'bool', group: 'cache', def: true, zh: 'SERP 守卫', en: 'SERP guard', hintZh: '拦截壳页/风控页混入结果,默认开;误杀时先关它复现', hintEn: 'Keep shell/blocked pages out of results, on by default' },
142
- { name: 'ARGO_FETCH_JINA', kind: 'bool', group: 'fetch', def: true, zh: 'Jina 阅读器抓取', en: 'Jina reader fetch', hintZh: 'r.jina.ai 正文提取,默认开', hintEn: 'r.jina.ai text extraction, on by default' },
143
- { name: 'ARGO_FETCH_MOBILE', kind: 'bool', group: 'fetch', def: true, zh: '移动端 UA 抓取', en: 'Mobile UA fetch', hintZh: '按 host 记忆移动端身份,默认开', hintEn: 'Per-host mobile identity, on by default' },
144
- { name: 'ARGO_FETCH_PARALLEL', kind: 'bool', group: 'fetch', def: true, zh: 'Parallel 免费渲染抓取', en: 'Parallel free render fetch', hintZh: 'keyless 云端渲染兜底,默认开', hintEn: 'Keyless cloud render fallback, on by default' },
145
- { name: 'ARGO_FETCH_DEADLINE_S', kind: 'num', group: 'fetch', def: 60, min: 5, max: 300, step: 5, zh: '抓取总截止(秒)', en: 'Fetch deadline (s)', hintZh: '单次抓取全链路墙钟上限,默认 60', hintEn: 'Wall-clock cap per fetch, default 60' },
146
- { name: 'ARGO_SEMANTIC_EVIDENCE', kind: 'bool', group: 'semantic', def: false, zh: '语义证据层', en: 'Semantic evidence', hintZh: '显式核验链路的零样本判定,默认关;开启后多一次外呼', hintEn: 'Zero-shot support check on the verify path, off by default' },
147
- { name: 'ARGO_ADAPTIVE_GRACE', kind: 'bool', group: 'semantic', def: true, zh: '对冲宽限自适应', en: 'Adaptive hedge grace', hintZh: '按引擎历史 p75 收窄对冲等待窗,默认开', hintEn: 'Narrow hedge window by engine p75, on by default' },
148
- { name: 'ARGO_ADAPTIVE_TAIL', kind: 'bool', group: 'semantic', def: false, zh: '分层尾宽', en: 'Layered straggler tail', hintZh: '尾宽按未回来引擎分层取值,默认关', hintEn: 'Per-engine layered tail width, off by default' },
149
- { name: 'ARGO_STRAGGLER_GRACE_S', kind: 'num', group: 'semantic', def: 1.5, min: 0, max: 30, step: 0.5, zh: '掉队宽限(秒)', en: 'Straggler grace (s)', hintZh: '已有引擎交付后还等多久,默认 1.5;0 关闭', hintEn: 'Wait after first delivery, default 1.5; 0 disables' },
150
- { name: 'ARGO_SERIAL_STAGGER_S', kind: 'num', group: 'semantic', def: 0.8, min: 0, max: 30, step: 0.5, zh: '串行起步间隔(秒)', en: 'Serial stagger (s)', hintZh: '首引擎超时前补发备选源的提前量,默认 0.8;0 最激进', hintEn: 'Lead before firing a backup source, default 0.8; 0 = fire together' },
151
- { name: 'ARGO_ENABLE_ENGINES', kind: 'list', group: 'engines', zh: '额外启用引擎', en: 'Extra enabled engines', hintZh: '逗号分隔;叠加在 config.yaml 启用集之上', hintEn: 'Comma-separated; adds to the config.yaml enabled set' },
152
- { name: 'ARGO_DISABLE_ENGINES', kind: 'list', group: 'engines', zh: '停用引擎', en: 'Disabled engines', hintZh: '逗号分隔;优先级高于启用集,调试单引擎时用', hintEn: 'Comma-separated; wins over the enabled set' },
153
- { name: 'ARGO_PROXY', kind: 'str', group: 'net', zh: 'argo 全局代理', en: 'argo global proxy', hintZh: 'http:// 代理 URL,或 direct 强制直连;留空走环境变量', hintEn: 'http:// proxy URL, or direct; empty falls back to env' },
154
- { name: 'ARGO_GDELT_PROXY', kind: 'str', group: 'net', zh: 'GDELT 代理', en: 'GDELT proxy', hintZh: 'GDELT 按出口 IP 限流,经本地代理更稳;留空自动直连', hintEn: 'GDELT rate-limits by egress IP; empty = direct' },
155
- { name: 'ARGO_LOCAL_SEEK_ROOTS', kind: 'list', group: 'local', zh: '本机检索根目录', en: 'Local seek roots', hintZh: '路径分隔符分隔;seek.py 的候选安装根,默认用打包位置', hintEn: 'Path-separated roots for seek.py; default uses the bundled copy' },
156
- { name: 'ARGO_LOCAL_SEEK_PATH', kind: 'str', group: 'local', zh: 'seek.py 绝对路径', en: 'seek.py path', hintZh: '显式指定 seek.py,优先于根目录候选', hintEn: 'Explicit seek.py, wins over root candidates' },
157
- { name: 'ARGO_LOCAL_READ_DIRS', kind: 'list', group: 'local', zh: '本机读取白名单', en: 'Local read allowlist', hintZh: '逗号分隔;不配置则 local_read 一律不放行', hintEn: 'Comma-separated; empty means local_read allows nothing' },
158
- { name: 'ARGO_TEXT_LEXICON', kind: 'str', group: 'local', zh: '词表 JSON 路径', en: 'Lexicon JSON path', hintZh: '文本处理词表覆盖,默认用打包词表', hintEn: 'Text lexicon override; default uses the bundled one' },
159
- { name: 'ARGO_PAID_SEARCH', kind: 'str', group: 'paid', def: 'auto', zh: '付费源策略', en: 'Paid source policy', hintZh: 'auto=优势域自动使用付费源;off=只用免费源。额度见下方', hintEn: 'auto = use paid sources in proven domains; off = free sources only. See quotas below' },
160
- { name: 'ARGO_BUDGET_DEEPSEEK_SEARCH', kind: 'num', group: 'paid', def: 5, min: 0, max: 1000, step: 1, zh: 'DeepSeek 月度预算(元)', en: 'DeepSeek monthly budget (CNY)', hintZh: '0=关闭;¥5≈1000次成功调用(¥0.005/次)', hintEn: '0 = off; CNY 5 ≈ 1000 successful calls (CNY 0.005 each)' },
161
- { name: 'ARGO_BUDGET_EXA', kind: 'num', group: 'paid', def: 10, min: 0, max: 10000, step: 1, zh: 'Exa 每月预算(美元)', en: 'Exa monthly budget (USD)', hintZh: '默认 $10/月(约 1000 次);0=关闭自动使用。按成功调用计费', hintEn: 'Default $10/month (~1000 calls); 0 = off. Billed per successful call' },
162
- { name: 'ARGO_QUOTA_ANYSEARCH_LIMIT', kind: 'num', group: 'paid', def: 1000, min: 0, max: 1000000, step: 1, zh: 'AnySearch 每日次数上限', en: 'AnySearch daily call cap', hintZh: '默认 1000/日;0=不限制。改动对下一次新建连接生效', hintEn: 'Default 1000/day; 0 = unlimited. Applies to new connections' },
163
- { name: 'ARGO_QUOTA_ZHIHU_LIMIT', kind: 'num', group: 'paid', def: 5000, min: 0, max: 1000000, step: 1, zh: '知乎 每日次数上限', en: 'Zhihu daily call cap', hintZh: '默认 5000/日;0=不限制。改动对下一次新建连接生效', hintEn: 'Default 5000/day; 0 = unlimited. Applies to new connections' },
164
- { name: 'ARGO_QUOTA_YUANBAO_LIMIT', kind: 'num', group: 'paid', def: 2000, min: 0, max: 1000000, step: 1, zh: '元宝 每月次数上限', en: 'Yuanbao monthly call cap', hintZh: '默认 2000/月;0=不限制。改动对下一次新建连接生效', hintEn: 'Default 2000/month; 0 = unlimited. Applies to new connections' },
165
- { name: 'ARGO_QUOTA_TAVILY_LIMIT', kind: 'num', group: 'paid', def: 1000, min: 0, max: 1000000, step: 1, zh: 'Tavily 每月次数上限', en: 'Tavily monthly call cap', hintZh: '默认 1000/月;0=不限制。改动对下一次新建连接生效', hintEn: 'Default 1000/month; 0 = unlimited. Applies to new connections' },
166
- { name: 'ARGO_NO_PREWARM', kind: 'bool', group: 'misc', def: false, zh: '关闭连接预热', en: 'Disable prewarm', hintZh: 'MCP 握手后预热引擎注册表,默认开;开启本项即关闭预热', hintEn: 'Prewarm the engine registry after handshake, on by default; enable this to turn it off' },
167
- { name: 'ARGO_USAGE_LOG', kind: 'bool', group: 'misc', def: true, zh: '使用日志', en: 'Usage log', hintZh: 'argo 侧 JSONL 使用账本,默认开', hintEn: 'argo JSONL usage ledger, on by default' },
168
- { name: 'ARGO_ENGINE_HTTP_CLIENT', kind: 'bool', group: 'misc', def: true, zh: 'HttpClient 连接池', en: 'HttpClient pool', hintZh: '引擎 HTTP 走连接池,默认开;=0 回退 urllib(诊断用)', hintEn: 'Pooled engine HTTP, on by default; =0 falls back to urllib' },
169
- { name: 'ARGO_ADMISSION_TTL_S', kind: 'num', group: 'misc', def: 1, min: 0, max: 60, step: 0.5, zh: '准入记忆 TTL(秒)', en: 'Admission memo TTL (s)', hintZh: '引擎准入状态记忆时长,默认 1;0 每次现查', hintEn: 'Admission memo window, default 1; 0 = always fresh' },
170
- { name: 'ARGO_CONFIG_STAMP_TTL_S', kind: 'num', group: 'misc', def: 1, min: 0, max: 60, step: 0.5, zh: '配置戳记忆 TTL(秒)', en: 'Config stamp memo TTL (s)', hintZh: '外部引擎扫描记忆时长,默认 1;0 每次现扫', hintEn: 'External engine scan memo window, default 1; 0 = always rescan' },
171
- ])
172
-
173
- const ARGO_ENV_NAMES = new Set(ARGO_ENV_SPECS.map(spec => spec.name))
174
- const ARGO_ENV_BY_NAME = new Map(ARGO_ENV_SPECS.map(spec => [spec.name, spec]))
175
-
176
- function parseArgoEnvLine(line) {
177
- const eq = line.indexOf('=')
178
- if (eq <= 0) return null
179
- const name = line.slice(0, eq).trim()
180
- const value = line.slice(eq + 1)
181
- if (!CREDENTIAL_REF_PATTERN.test(name)) return null
182
- return { name, value }
183
- }
184
-
185
- export function argoEnvOverlay(config = activeConfig) {
186
- const overlay = {}
187
- for (const entry of asStringArray(config?.argoEnv, 64)) {
188
- const parsed = parseArgoEnvLine(entry)
189
- if (parsed === null || !ARGO_ENV_NAMES.has(parsed.name)) continue
190
- overlay[parsed.name] = parsed.value
191
- }
192
- return overlay
193
- }
194
-
195
90
  const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value)
196
91
 
197
92
  const VOLATILE_WRITE = Symbol.for('cosmokit.volatile.write')
@@ -303,8 +198,6 @@ export const Config = Schema === undefined ? undefined : Schema.object({
303
198
  .volatile(),
304
199
  })
305
200
 
306
- const CREDENTIAL_REF_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/
307
-
308
201
  function readHostCredentials(ctx) {
309
202
  try {
310
203
  const service = typeof ctx?.get === 'function' ? ctx.get('credentials') : ctx?.credentials
@@ -321,34 +214,11 @@ function runEffect(ctx, fn) {
321
214
  return ctx.effect(fn)
322
215
  }
323
216
 
324
- let hostCredentials = undefined
325
- let activeConfig = DEFAULTS
326
-
327
- export async function resolveArgoEnv(config = activeConfig, options = {}) {
328
- const overlay = argoEnvOverlay(config)
329
- const refs = asStringArray(config?.keyRefs, 20)
330
- if (refs.length > 0) {
331
- const provider = options.credentials ?? config?.credentials ?? hostCredentials
332
- if (provider !== undefined) {
333
- for (const ref of refs) {
334
- try {
335
- const resolved = await provider.resolve(ref)
336
- if (typeof resolved?.value === 'string' && resolved.value !== '') overlay[ref] = resolved.value
337
- } catch { /* ignore */ }
338
- }
339
- }
340
- }
341
- return Object.keys(overlay).length > 0 ? { ...process.env, ...overlay } : undefined
342
- }
343
-
344
217
  const asString = (value, fallback = '') => typeof value === 'string' ? value.trim() : fallback
345
- const asStringArray = (value, maximum) => Array.isArray(value)
346
- ? value.filter(entry => typeof entry === 'string').map(entry => entry.trim()).filter(Boolean).slice(0, maximum)
347
- : []
348
218
 
349
219
  // 注入执行器的动态环境变量解析逻辑
350
220
  setEnvResolver(async (options, config) => {
351
- return resolveArgoEnv(config || activeConfig, options)
221
+ return resolveArgoEnv(config, options)
352
222
  })
353
223
 
354
224
  export function apply(ctx, providedConfig = {}) {
@@ -388,13 +258,14 @@ export function apply(ctx, providedConfig = {}) {
388
258
  }
389
259
  }
390
260
 
391
- hostCredentials = readHostCredentials(ctx)
392
- activeConfig = config
261
+ const hostCredentials = readHostCredentials(ctx)
262
+ setHostCredentials(hostCredentials)
263
+ setActiveConfig(config)
393
264
 
394
265
  runEffect(ctx, () => () => {
395
266
  disposeSharedMcp()
396
- hostCredentials = undefined
397
- activeConfig = DEFAULTS
267
+ setHostCredentials(undefined)
268
+ setActiveConfig(DEFAULTS)
398
269
  })
399
270
 
400
271
  const childIds = new Set()
@@ -427,6 +298,9 @@ export function apply(ctx, providedConfig = {}) {
427
298
  idleMs: config.searchIdleMs,
428
299
  max: config.searchConcurrency,
429
300
  config,
301
+ // issue #41:显式带上宿主凭证服务,否则池内连接 envResolver 解析
302
+ // keyRefs 时 provider 为 undefined,所有需 key 引擎静默 skipped。
303
+ credentials: hostCredentials,
430
304
  })
431
305
  },
432
306
  })
@@ -444,6 +318,8 @@ export function apply(ctx, providedConfig = {}) {
444
318
  max: config.searchConcurrency,
445
319
  maxChars: config.fetchMaxChars,
446
320
  config,
321
+ // issue #41:与 search 同理,fetch 池连接也要带上凭证服务。
322
+ credentials: hostCredentials,
447
323
  })
448
324
  },
449
325
  })
@@ -493,6 +369,8 @@ export function apply(ctx, providedConfig = {}) {
493
369
  try { dispose?.() } catch { /* ignore */ }
494
370
  }
495
371
  nativeRegistrations.clear()
372
+ resetEnvResolver()
373
+ disposeSharedMcp()
496
374
  })
497
375
 
498
376
  ctx.tools.register(createWideResearchTool(ctx, config, {
@@ -520,30 +398,3 @@ export function apply(ctx, providedConfig = {}) {
520
398
 
521
399
  return { childIds, syncNativeTools }
522
400
  }
523
-
524
- export {
525
- normalizeTracks,
526
- stageTracks,
527
- evaluateGates,
528
- normalizeSource,
529
- normalizeSourceUrl,
530
- buildLocalSources,
531
- parseJsonArray,
532
- parseJsonObject,
533
- extractValues,
534
- nativeViaMcpPool,
535
- runNativeCall,
536
- resolveNativeSpawn,
537
- makeNativeTool,
538
- disposeSharedMcp,
539
- startStructured,
540
- providerSupportsStructured,
541
- fetchViaArgo,
542
- mapArgoToWebResult,
543
- mapArgoToWebFetch,
544
- classifyFetchError,
545
- searchViaArgoMCP,
546
- persistReport,
547
- getMcpPoolStats,
548
- resetMcpPool,
549
- }
@@ -110,6 +110,10 @@ export function setEnvResolver(fn) {
110
110
  activeEnvResolver = fn
111
111
  }
112
112
 
113
+ export function resetEnvResolver() {
114
+ activeEnvResolver = null
115
+ }
116
+
113
117
  export async function resolveEnv(options = {}, config = undefined) {
114
118
  if (typeof activeEnvResolver === 'function') {
115
119
  return activeEnvResolver(options, config)
@@ -274,7 +278,8 @@ export function createMcpConnection(options) {
274
278
  } catch { /* ignore */ }
275
279
  }
276
280
  },
277
- close
281
+ close,
282
+ dispose: close,
278
283
  }
279
284
  return conn
280
285
  }
@@ -350,7 +355,12 @@ export async function acquireMcp(options, signal) {
350
355
  }
351
356
 
352
357
  export function disposeSharedMcp() {
353
- for (const conn of [...mcpPool]) conn.close()
358
+ for (const conn of [...mcpPool]) {
359
+ try {
360
+ if (typeof conn.dispose === 'function') conn.dispose()
361
+ else conn.close()
362
+ } catch { /* ignore */ }
363
+ }
354
364
  mcpPool.length = 0
355
365
  }
356
366
 
@@ -472,13 +482,19 @@ export async function searchViaArgoMCP(query, maxResults = 5, signal, options =
472
482
  const timeoutMs = options.timeoutMs ?? DEFAULTS.searchTimeoutMs
473
483
  const count = clamp(maxResults ?? 5, 5, 1, 20)
474
484
 
485
+ // 关键(issue #41):search 走 MCP 池,但池的连接此前只把 config 交给
486
+ // envResolver,没有把 caller 的 credentials 带上——而 web 搜索 provider
487
+ // 是经 registerSearchProvider 进来的,手里有 config 却没有 credentials 服务,
488
+ // 于是 resolveArgoEnv 的 provider 恒为 undefined,keyRefs 一个都解析不出来,
489
+ // 所有需 API key 的引擎长期 skipped-missing-env。这里把 config.credentials
490
+ // 显式并入,让「池内连接」与「单发兜底」两条路径解析出同一份 key。
475
491
  const conn = await acquireMcp({
476
492
  command,
477
493
  args,
478
494
  idleMs: options.idleMs ?? DEFAULTS.searchIdleMs,
479
495
  max: options.max ?? DEFAULTS.searchConcurrency,
480
496
  initMs: timeoutMs,
481
- credentials: options.credentials,
497
+ credentials: options.credentials ?? options.config?.credentials,
482
498
  config: options.config,
483
499
  }, signal)
484
500