argo-search 2.14.1 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/AGENTS.md +8 -6
  2. package/README.es.md +57 -813
  3. package/README.ja.md +56 -814
  4. package/README.ko.md +56 -812
  5. package/README.md +160 -754
  6. package/README.zh.md +152 -872
  7. package/SKILL.md +22 -23
  8. package/assets/readme/counts.json +1 -1
  9. package/assets/readme/hero.svg +23 -23
  10. package/backends/concept_vectors.bin +0 -0
  11. package/backends/domain_profiles.json +149 -6
  12. package/backends/engine_concept_vectors.json +1525 -1525
  13. package/backends/engine_registry.yaml +139 -30
  14. package/backends/quota_profiles.json +83 -3
  15. package/bin/argo +33 -17
  16. package/config.yaml +189 -33
  17. package/docs/ADDING_NEW_ENGINE.md +10 -0
  18. package/docs/ARGO_INTRO.md +1 -1
  19. package/docs/CHANGELOG.md +38 -0
  20. package/docs/ENGINE_CATALOG.md +102 -89
  21. package/docs/MCP_SETUP.md +10 -1
  22. package/docs/RELEASE_NOTES_v2.14.1.md +4 -4
  23. package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
  24. package/docs/RELEASE_NOTES_v2.16.0.md +58 -0
  25. package/docs/RELEASING.md +1 -1
  26. package/engines/specs/ai_labs.yaml +89 -0
  27. package/engines/specs/archive_org.yaml +1 -1
  28. package/engines/specs/bilibili_hot.yaml +11 -1
  29. package/engines/specs/brave.yaml +3 -3
  30. package/engines/specs/carbon_intensity.yaml +1 -1
  31. package/engines/specs/cisa_alerts.yaml +40 -0
  32. package/engines/specs/cn_ai_news.yaml +10 -8
  33. package/engines/specs/crates.yaml +1 -1
  34. package/engines/specs/crossref.yaml +4 -2
  35. package/engines/specs/crt_sh.yaml +1 -1
  36. package/engines/specs/dblp.yaml +1 -1
  37. package/engines/specs/devto.yaml +1 -1
  38. package/engines/specs/digup.yaml +11 -6
  39. package/engines/specs/docker_hub.yaml +1 -1
  40. package/engines/specs/douyin_hot.yaml +11 -1
  41. package/engines/specs/dw_news.yaml +4 -2
  42. package/engines/specs/eng_blogs.yaml +63 -0
  43. package/engines/specs/europeana.yaml +3 -4
  44. package/engines/specs/europepmc.yaml +1 -1
  45. package/engines/specs/felo.yaml +3 -3
  46. package/engines/specs/firecrawl.yaml +3 -0
  47. package/engines/specs/fourget.yaml +5 -2
  48. package/engines/specs/france24.yaml +6 -4
  49. package/engines/specs/fxtwitter.yaml +30 -7
  50. package/engines/specs/gbfs_nyc.yaml +1 -1
  51. package/engines/specs/gleif.yaml +1 -1
  52. package/engines/specs/gov_regulations.yaml +1 -1
  53. package/engines/specs/grepapp_mcp.yaml +62 -0
  54. package/engines/specs/guardian_rss.yaml +6 -4
  55. package/engines/specs/hf_datasets.yaml +1 -1
  56. package/engines/specs/huggingface.yaml +1 -1
  57. package/engines/specs/itotii.yaml +13 -1
  58. package/engines/specs/keenable.yaml +7 -1
  59. package/engines/specs/linux_do.yaml +63 -0
  60. package/engines/specs/lobsters.yaml +41 -0
  61. package/engines/specs/local_crossref.yaml +3 -1
  62. package/engines/specs/local_github.yaml +1 -1
  63. package/engines/specs/local_npm.yaml +6 -0
  64. package/engines/specs/local_openstreetmap.yaml +1 -1
  65. package/engines/specs/local_seek.yaml +6 -0
  66. package/engines/specs/maven.yaml +1 -1
  67. package/engines/specs/mdn.yaml +1 -1
  68. package/engines/specs/musicbrainz.yaml +1 -1
  69. package/engines/specs/nasa_images.yaml +1 -1
  70. package/engines/specs/nhtsa_vpic.yaml +6 -3
  71. package/engines/specs/npm.yaml +1 -1
  72. package/engines/specs/nuget.yaml +1 -1
  73. package/engines/specs/nvd.yaml +1 -1
  74. package/engines/specs/open_meteo.yaml +1 -1
  75. package/engines/specs/openalex.yaml +4 -2
  76. package/engines/specs/openreview.yaml +1 -1
  77. package/engines/specs/polymarket.yaml +1 -1
  78. package/engines/specs/redskill.yaml +2 -0
  79. package/engines/specs/searxng.yaml +4 -2
  80. package/engines/specs/sec_edgar.yaml +9 -4
  81. package/engines/specs/steam.yaml +1 -1
  82. package/engines/specs/tinyfish.yaml +2 -0
  83. package/engines/specs/tinyfish_news.yaml +2 -0
  84. package/engines/specs/tinyfish_paper.yaml +2 -0
  85. package/engines/specs/toutiao_hot.yaml +11 -1
  86. package/engines/specs/train.yaml +3 -0
  87. package/engines/specs/twitter.yaml +4 -0
  88. package/engines/specs/unpaywall.yaml +6 -0
  89. package/engines/specs/vam.yaml +17 -3
  90. package/engines/specs/weibo_hot.yaml +11 -1
  91. package/engines/specs/wikidata.yaml +1 -1
  92. package/engines/specs/wikipedia.yaml +1 -1
  93. package/engines/specs/wolframalpha.yaml +3 -3
  94. package/engines/specs/xiaohongshu.yaml +2 -0
  95. package/engines/specs/zhihu.yaml +3 -18
  96. package/engines/specs/zhihu_hot_app.yaml +1 -1
  97. package/engines/specs/zhihu_kb.yaml +18 -0
  98. package/engines/specs/zhihu_questions.yaml +19 -0
  99. package/package.json +4 -2
  100. package/packages/dsh-plugin/README.md +9 -14
  101. package/packages/dsh-plugin/dsh/client.js +481 -1037
  102. package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
  103. package/packages/dsh-plugin/dsh/index.js +6 -0
  104. package/packages/dsh-plugin/dsh/runner.js +3 -1
  105. package/packages/dsh-plugin/dsh/workbench-client.js +796 -0
  106. package/packages/dsh-plugin/dsh/workbench-md.js +386 -0
  107. package/packages/dsh-plugin/dsh/workbench-suggestions.js +148 -0
  108. package/packages/dsh-plugin/dsh/workbench.js +966 -0
  109. package/packages/dsh-plugin/icon.svg +23 -0
  110. package/packages/dsh-plugin/package.json +10 -3
  111. package/packages/dsh-plugin/scripts/sync-local.mjs +87 -0
  112. package/packages/dsh-plugin/scripts/sync-local.sh +13 -1
  113. package/packages/dsh-plugin/test/diagnostics.test.js +38 -1
  114. package/packages/dsh-plugin/test/size-gate.test.js +2 -9
  115. package/packages/dsh-plugin/test/workbench.test.js +92 -0
  116. package/scripts/adaptive.py +7 -1
  117. package/scripts/archive_run.py +112 -53
  118. package/scripts/argo_paths.py +42 -5
  119. package/scripts/badcase_ledger.py +117 -9
  120. package/scripts/build_concept_table.py +112 -55
  121. package/scripts/cache.py +6 -2
  122. package/scripts/caliber_isolation.py +60 -23
  123. package/scripts/circuit_breaker.py +72 -11
  124. package/scripts/cli_io.py +20 -2
  125. package/scripts/config_cache.py +44 -1
  126. package/scripts/daemon.py +151 -51
  127. package/scripts/dormant_ledger.py +23 -9
  128. package/scripts/engine_dispatch.py +8 -5
  129. package/scripts/engine_env.py +191 -1
  130. package/scripts/engine_families.py +50 -7
  131. package/scripts/engine_states.py +3 -50
  132. package/scripts/engine_validate.py +13 -45
  133. package/scripts/engines.py +15 -31
  134. package/scripts/engines_base.py +66 -61
  135. package/scripts/engines_builders.py +0 -15
  136. package/scripts/engines_builders_archive.py +4 -3
  137. package/scripts/engines_builders_batch10.py +346 -100
  138. package/scripts/engines_builders_batch11.py +4 -76
  139. package/scripts/engines_builders_batch13.py +4 -3
  140. package/scripts/engines_builders_batch14.py +2 -1
  141. package/scripts/engines_builders_batch15.py +2 -1
  142. package/scripts/engines_builders_batch9.py +16 -25
  143. package/scripts/engines_builders_cn.py +7 -201
  144. package/scripts/engines_builders_data.py +12 -11
  145. package/scripts/engines_builders_data_macro.py +5 -4
  146. package/scripts/engines_builders_dsh.py +2 -1
  147. package/scripts/engines_builders_feeds.py +76 -11
  148. package/scripts/engines_builders_finance.py +2 -1
  149. package/scripts/engines_builders_intl.py +18 -117
  150. package/scripts/engines_builders_media.py +59 -12
  151. package/scripts/engines_builders_pixiv.py +2 -16
  152. package/scripts/engines_builders_science.py +8 -7
  153. package/scripts/engines_builders_search.py +7 -14
  154. package/scripts/engines_builders_skill.py +2 -1
  155. package/scripts/engines_builders_tech.py +8 -17
  156. package/scripts/engines_builders_weather.py +241 -0
  157. package/scripts/engines_fields.py +91 -0
  158. package/scripts/engines_http.py +184 -0
  159. package/scripts/engines_mcp.py +405 -0
  160. package/scripts/engines_parsers.py +13 -369
  161. package/scripts/engines_schema_drift.py +260 -0
  162. package/scripts/evidence.py +13 -0
  163. package/scripts/evidence_loop.py +19 -4
  164. package/scripts/extend_route_labels.py +6 -0
  165. package/scripts/fetch_jina.py +98 -0
  166. package/scripts/fetch_jsrun.py +15 -11
  167. package/scripts/fetch_v3.py +79 -120
  168. package/scripts/fulltext_store.py +42 -1
  169. package/scripts/fxtwitter_api.py +8 -7
  170. package/scripts/gen_engine_catalog.py +2 -2
  171. package/scripts/general_pool.py +15 -4
  172. package/scripts/health_check.py +1 -1
  173. package/scripts/image_vision/vision_probe +0 -0
  174. package/scripts/install.sh +2 -0
  175. package/scripts/link_source.py +65 -24
  176. package/scripts/local_seek_adapter.py +57 -17
  177. package/scripts/matrix_search_eval.py +8 -10
  178. package/scripts/mcp_handlers.py +53 -31
  179. package/scripts/mcp_handlers_surface.py +6 -18
  180. package/scripts/mcp_transport.py +10 -5
  181. package/scripts/min_version_scan.py +7 -3
  182. package/scripts/network_aware.py +7 -13
  183. package/scripts/numeric_verify.py +3 -2
  184. package/scripts/output_transparency.py +3 -0
  185. package/scripts/pre-commit +45 -43
  186. package/scripts/query_understanding.py +30 -6
  187. package/scripts/quota.py +36 -30
  188. package/scripts/rank_signals.py +9 -0
  189. package/scripts/recompute.py +15 -5
  190. package/scripts/recovery.py +38 -29
  191. package/scripts/recovery_runner.py +29 -10
  192. package/scripts/redskill/redskill_engine.py +2 -1
  193. package/scripts/release.py +14 -26
  194. package/scripts/release_check.py +5 -25
  195. package/scripts/replay_eval.py +2 -2
  196. package/scripts/research_cli.py +40 -0
  197. package/scripts/research_notes.py +368 -0
  198. package/scripts/route.py +40 -70
  199. package/scripts/route_audit.py +259 -0
  200. package/scripts/route_combo.py +21 -6
  201. package/scripts/route_domains.py +150 -23
  202. package/scripts/route_lang.py +20 -7
  203. package/scripts/route_log.py +26 -9
  204. package/scripts/route_policy.py +85 -6
  205. package/scripts/route_telemetry_export.py +199 -0
  206. package/scripts/rrf_classic.py +5 -22
  207. package/scripts/search.py +2 -1
  208. package/scripts/search_attribution.py +53 -10
  209. package/scripts/search_entry.py +32 -1
  210. package/scripts/search_output.py +23 -11
  211. package/scripts/search_pipeline.py +15 -3
  212. package/scripts/search_rank.py +21 -11
  213. package/scripts/semantic_evidence.py +394 -178
  214. package/scripts/serp_guard.py +13 -1
  215. package/scripts/settings_page.py +4 -3
  216. package/scripts/single_flight.py +1 -1
  217. package/scripts/social_engines/hackernews_engine.py +2 -1
  218. package/scripts/social_engines/reddit_engine.py +2 -1
  219. package/scripts/social_engines/xiaohongshu_engine.py +2 -1
  220. package/scripts/social_engines/zhihu_engine.py +252 -43
  221. package/scripts/sogou_weixin_browser.py +5 -6
  222. package/scripts/source_audit.py +44 -9
  223. package/scripts/source_ledger.py +2 -15
  224. package/scripts/source_selection.py +45 -20
  225. package/scripts/straggler_policy.py +1 -2
  226. package/scripts/sync_backends.py +17 -0
  227. package/scripts/tfidf_router.py +23 -11
  228. package/scripts/time_utils.py +54 -1
  229. package/scripts/train.py +68 -2
  230. package/scripts/usage_log.py +50 -10
  231. package/scripts/watch.py +3 -3
  232. package/scripts/zhihu_quota.py +2 -1
  233. package/sub-skills/argo-wide-research/SKILL.md +70 -0
  234. package/sub-skills/ego-search/{SKILL.md → README.md} +15 -47
  235. package/sub-skills/ego-search/scripts/ego_search.py +13 -4
  236. package/sub-skills/js-run/{SKILL.md → README.md} +3 -20
  237. package/sub-skills/local-search/{SKILL.md → README.md} +3 -8
  238. package/sub-skills/local-search/engine_registry.py +32 -7
  239. package/sub-skills/local-seek/SKILL.md +20 -22
  240. package/sub-skills/local-seek/scripts/seek_fts.py +58 -3
  241. package/scripts/caliber_dedupe.py +0 -66
  242. package/scripts/engines_builders_batch16.py +0 -13
  243. package/scripts/health_probe.py +0 -253
  244. package/scripts/social_engines/twitter_engine.py +0 -514
  245. package/scripts/sync_installs.py +0 -29
@@ -1,16 +1,6 @@
1
- /*
2
- * @taxueseek/argo-dsh — 浏览器端设置页(无需构建步骤)
3
- *
4
- * 由 DSH ModuleLoader 以 lazy-CJS 方式加载:工厂函数里只 require('react'),
5
- * 其余能力(slots / configForms / remote.credentials / locale)全部由宿主
6
- * 通过 cordis 服务注入。设置值走 configForms(settings namespace =
7
- * 'wide-research'),密钥走 credentials 域——两者都不经过插件配置文件,
8
- * 密钥更不会回显明文。
9
- *
10
- * 注册两个位置:
11
- * settings.section —— 设置弹窗左侧一级菜单(主入口)
12
- * plugins.item —— 设置 > 插件 页里的卡片(摘要 + 同一面板)
13
- */
1
+ /* @taxueseek/argo-dsh — 浏览器端设置页与工作台入口(无需构建步骤)
2
+ * 由 DSH ModuleLoader 以 lazy-CJS 加载,注册 settings.section / plugins.item,
3
+ * 并在浏览器环境按需挂载 /argo/workbench-client.js 搜索分析工作台。 */
14
4
  window.__ModuleLoader__.load({
15
5
  id: '@taxueseek/argo-dsh',
16
6
  factory: (require) => {
@@ -26,247 +16,126 @@ window.__ModuleLoader__.load({
26
16
  const NS = 'wide-research';
27
17
  const SECTION_ID = 'argo';
28
18
 
29
- const DICT = {
30
- zh: {
31
- title: 'Argo 搜索配置',
32
- intro: '接入方式、原生工具、API 密钥与研究编排。保存后即时生效;工具名与 provider 属结构性字段,仍需在 profile patch 中修改。',
33
- loading: '配置加载中…',
34
- unavailable: '本插件的配置服务不可用(未挂载或只读)。',
35
- readonly: '当前配置只读。',
36
- saved: '已保存',
37
- refused: '宿主拒绝写入(可能只读或字段不可热更新)',
38
- save: '保存',
39
- saving: '保存中…',
40
- on: '开',
41
- off: '关',
42
- showMore: '显示更多',
43
- showLess: '收起',
44
- tabAccess: '接入',
45
- tabTools: '工具',
46
- tabKeys: '密钥',
47
- tabResearch: '研究',
48
- tabAdvanced: '高级',
49
- tabDashboard: '看板',
50
- dashboardTitle: '运行监控与健康态看板',
51
- routeHealthTitle: '路由观测',
52
- routeHealthHint: '最近的路由决策与引擎状态(宿主提供时显示)。',
53
- routeHealthFallback: '在终端运行 `argo stats` 或 `argo engine list` 查看路由健康、引擎成功率与配额消耗。',
54
- dashboardHint: '实时监控常驻 MCP 连接池、上游搜索源拓扑与额度状态,提供一键预设与快速调优。',
55
- poolTitle: '常驻 MCP 连接池监控',
56
- poolStatusHealthy: '按需连接 · 连接数不常驻',
57
- presetTitle: '工作流快速预设',
58
- presetHint: '一键对齐常用工作场景的并发与引擎策略,免去逐项手动调优。',
59
- presetFast: '极速日常',
60
- presetFastDesc: '免密免费源优先,关闭 TF-IDF 重排与数值交叉比对,超低延迟',
61
- presetStandard: '平衡生产(推荐)',
62
- presetStandardDesc: '开启 TF-IDF 重排、数值交叉核验、主流付费源,标准超时',
63
- presetDeep: '深度调研',
64
- presetDeepDesc: '激活更多取证工具、对冲自适应宽限、语义证据层、更大并发',
65
- presetApplied: '已应用预设:',
66
- matrixTitle: '核心引擎拓扑与覆盖全景',
67
- matrixHint: '当前可用引擎的接入层级与角色分工。带免密标识的引擎无需密钥即可直接使用。',
68
- matrixConfigured: '密钥已就绪',
69
- matrixKeyless: '免密层可用',
70
- matrixPending: '待配密钥',
71
- searchFilterPlaceholder: '输入关键词快速筛选...',
72
- summary: 'Argo · web_search {search} · web_fetch {fetch} · 原生工具 {tools} 个 · 研究 {workers}/{max}',
73
- accessTitle: '接入方式',
74
- searchSeam: '宿主 web_search 走 argo',
75
- searchSeamHint: '关闭后 web_search 回到宿主默认搜索后端(web 行 searchProvider)。',
76
- fetchSeam: '宿主 web_fetch 走 argo',
77
- fetchSeamHint: '开启前必须在 web 配置行加 fetchProvider: argo;否则两个 provider 同时可用会报 WEB_PROVIDER_AMBIGUOUS。',
78
- entryTitle: '引擎入口',
79
- entryHint: 'npx 模式填 npx,参数 -y / github:taxueseek/argo;本机模式填 python3,参数填 mcp_server.py 的绝对路径。',
80
- command: '命令',
81
- args: '参数(一行一个)',
82
- searchTimeout: '搜索超时 (ms)',
83
- fetchTimeout: '抓取超时 (ms)',
84
- fetchChars: '抓取正文上限(字符)',
85
- idle: '连接空闲回收 (ms)',
86
- concurrency: '并发连接数',
87
- toolsTitle: '原生工具',
88
- toolsHint: '勾选即注册为原生一等工具(CLI 单发,不依赖 MCP)。长尾工具只在需要时开,避免每轮工具面膨胀。',
89
- toolPresetTitle: '推荐组合',
90
- toolPresetHint: '按场景一键套用(会覆盖当前勾选)。工具分区见下方。',
91
- coreTools: '高频路径',
92
- longTools: '长尾取证',
93
- nativeTimeout: '单次调用超时 (ms)',
94
- nativeChars: '返回文本上限(字符)',
95
- keysTitle: 'API 密钥',
96
- keysHint: '密钥写入 DSH 凭证库(与 Models 页同一处),不会写进插件配置、不回显明文。只有勾选「转发」的引用才会作为环境变量传给 argo 子进程。「清除」只删凭证库里的值,环境变量或 .env 提供的 key 仍会生效。',
97
- commonKeys: '常用引擎',
98
- moreKeys: '更多引擎',
99
- configured: '已配置',
100
- notConfigured: '未配置',
101
- forward: '转发',
102
- keyPlaceholderSet: '输入新值(留空保留现有密钥)',
103
- keyPlaceholderEmpty: '粘贴 API Key',
104
- saveKey: '保存',
105
- clearKey: '清除',
106
- keySaved: '密钥已保存;下一次新建 argo 连接生效(池内旧连接最长 60s 回收)。',
107
- keyCleared: '密钥已清除。',
108
- keyUnavailable: '凭证服务不可用。',
109
- researchTitle: '研究编排',
110
- workers: '默认 worker 数',
111
- maxWorkers: 'worker 上限',
112
- tracks: '轨道上限',
113
- sources: '每轨信源上限',
114
- workerTokens: 'worker token 上限',
115
- synthTokens: '综合 token 上限',
116
- reportDir: '报告落盘目录',
117
- advancedTitle: '高级',
118
- allow: 'worker 工具白名单(一行一个)',
119
- allowHint: '留空表示使用内置默认(MCP 与原生工具双写)。wide_research 自身与 argo_research 会被硬排除。',
120
- deny: 'worker 工具拒绝名单(一行一个)',
121
- keyRefs: '凭证转发名单(一行一个)',
122
- keyRefsHint: '这些引用名会经 DSH credentials 解析后作为环境变量传给 argo 子进程;没有对应凭证的项会被跳过。',
123
- structural: '结构性字段',
124
- structuralHint: 'toolName / provider / searchProviderId / fetchProviderId 只能改 profile patch;watched patch 由官方 watcher 同 PID 重组,改后核对功能即可,不默认重启。',
125
- mcpHint: 'MCP 全量工具面(mcp__argo__*)是 profile 里的独立 mcp-argo 行,不在本页开关;需要时在 patch 中取消注释后按 live activation 分支验证。',
126
- noKey: '(未配置)',
127
- tabEngines: '引擎',
128
- enginesTitle: 'argo 引擎开关',
129
- enginesHint: '这些开关原先是 argo 的环境变量,只能改 ~/.config/argo/env 或启动环境;现在写进插件配置,随 argo 子进程生效。改动对下一次新建连接生效(池内旧连接按「连接空闲回收」时长退出,默认 60s)。密钥不在这里配,请用「密钥」页;本页也不收授权类开关(可复算执行、内网 URL)。',
130
- groupCache: '缓存与排序',
131
- groupFetch: '抓取层',
132
- groupSemantic: '语义与自适应',
133
- groupEngines: '引擎启停',
134
- groupNet: '网络出口',
135
- groupLocal: '本机检索',
136
- groupMisc: '其他',
137
- groupPaid: '额度与预算',
138
- groupPaidHint: '免费与付费源统一管理:金额计费的源设月度预算,按次数限额的源设日/月次数上限;0=不限制。额度或预算用尽后该源自动跳过并回落免费源。改动对下一次新建连接生效。',
139
- envDefault: '默认',
140
- envRange: '需在 {min}–{max} 之间',
141
- keySourceFile: '凭证库',
142
- keySourceEnv: '启动环境',
143
- keySourceProjectEnv: '项目 .env',
144
- keySourceUserEnv: '家目录 .env',
145
- keySourceOther: '其他层',
146
- keyReadonly: '只读',
147
- keyOverrideHint: '保存后将覆盖当前层',
148
- deepseekShared: '与宿主 web_search 官方后端共用同一把 key,改动同时影响两边',
149
- },
150
- en: {
151
- title: 'Argo Search Settings',
152
- intro: 'Access mode, native tools, API keys and research orchestration. Saves apply immediately; tool name and provider remain structural profile settings.',
153
- loading: 'Loading configuration…',
154
- unavailable: 'Configuration service unavailable (not mounted or read-only).',
155
- readonly: 'Configuration is read-only.',
156
- saved: 'Saved',
157
- refused: 'Host refused the write (read-only or not live-editable)',
158
- save: 'Save',
159
- saving: 'Saving…',
160
- on: 'on',
161
- off: 'off',
162
- showMore: 'Show more',
163
- showLess: 'Show less',
164
- tabAccess: 'Access',
165
- tabTools: 'Tools',
166
- tabKeys: 'Keys',
167
- tabResearch: 'Research',
168
- tabAdvanced: 'Advanced',
169
- tabDashboard: 'Dashboard',
170
- dashboardTitle: 'Runtime Monitoring & Health Dashboard',
171
- routeHealthTitle: 'Routing telemetry',
172
- routeHealthHint: 'Recent routing decisions and engine status (when provided by the host).',
173
- routeHealthFallback: 'Run `argo stats` or `argo engine list` in a terminal to inspect routing health, engine success rates and quota usage.',
174
- dashboardHint: 'Real-time overview of the resident MCP connection pool, upstream search engine matrix, and quick workflow presets.',
175
- poolTitle: 'Resident MCP Pool Monitoring',
176
- poolStatusHealthy: 'On demand · no resident connections',
177
- presetTitle: 'Workflow Presets',
178
- presetHint: 'One-click presets tailored for common research and search workflows.',
179
- presetFast: 'Fast & Free',
180
- presetFastDesc: 'Keyless & free sources, disable rerank & crosscheck for lowest latency',
181
- presetStandard: 'Balanced (Recommended)',
182
- presetStandardDesc: 'TF-IDF rerank, numeric crosscheck, mainstream paid sources, standard timeouts',
183
- presetDeep: 'Deep Research',
184
- presetDeepDesc: 'Full forensic tools, adaptive hedge grace, semantic evidence layer, max concurrency',
185
- presetApplied: 'Preset applied:',
186
- matrixTitle: 'Core Engine Topology & Coverage',
187
- matrixHint: 'Access tiers and roles of available engines. Keyless engines work without an API key.',
188
- matrixConfigured: 'Key Ready',
189
- matrixKeyless: 'Keyless Ready',
190
- matrixPending: 'Key Required',
191
- searchFilterPlaceholder: 'Filter by keyword or engine...',
192
- summary: 'Argo · web_search {search} · web_fetch {fetch} · {tools} native tools · research {workers}/{max}',
193
- accessTitle: 'Access',
194
- searchSeam: 'Route host web_search to argo',
195
- searchSeamHint: 'When off, web_search falls back to the host provider configured on the web row.',
196
- fetchSeam: 'Route host web_fetch to argo',
197
- fetchSeamHint: 'Requires fetchProvider: argo on the web row; otherwise two available providers trigger WEB_PROVIDER_AMBIGUOUS.',
198
- entryTitle: 'Engine entry',
199
- entryHint: 'npx mode: command npx, args -y / github:taxueseek/argo. Local mode: python3 plus the absolute mcp_server.py path.',
200
- command: 'Command',
201
- args: 'Args (one per line)',
202
- searchTimeout: 'Search timeout (ms)',
203
- fetchTimeout: 'Fetch timeout (ms)',
204
- fetchChars: 'Fetch body cap (chars)',
205
- idle: 'Idle recycle (ms)',
206
- concurrency: 'Concurrent connections',
207
- toolsTitle: 'Native tools',
208
- toolsHint: 'Checked tools register as native first-class tools (single-shot CLI, no MCP). Enable long-tail tools only when needed.',
209
- toolPresetTitle: 'Recommended sets',
210
- toolPresetHint: 'Apply a scenario preset in one click (replaces current selection). See the grouped tools below.',
211
- coreTools: 'Hot path',
212
- longTools: 'Long tail',
213
- nativeTimeout: 'Per-call timeout (ms)',
214
- nativeChars: 'Returned text cap (chars)',
215
- keysTitle: 'API keys',
216
- keysHint: 'Keys are stored in the DSH credential store (same place as the Models page), never in plugin config and never echoed. Only refs marked Forward reach the argo child process. Clear removes the stored value only; a key supplied by the environment or .env still applies.',
217
- commonKeys: 'Common engines',
218
- moreKeys: 'More engines',
219
- configured: 'Configured',
220
- notConfigured: 'Not configured',
221
- forward: 'Forward',
222
- keyPlaceholderSet: 'Enter a new value (leave blank to keep the current key)',
223
- keyPlaceholderEmpty: 'Paste API key',
224
- saveKey: 'Save',
225
- clearKey: 'Clear',
226
- keySaved: 'Key saved; effective on the next new argo connection (old pooled connections recycle within ~60s).',
227
- keyCleared: 'Key cleared.',
228
- keyUnavailable: 'Credential service unavailable.',
229
- researchTitle: 'Research',
230
- workers: 'Default workers',
231
- maxWorkers: 'Worker cap',
232
- tracks: 'Track cap',
233
- sources: 'Sources per track',
234
- workerTokens: 'Worker token cap',
235
- synthTokens: 'Synthesis token cap',
236
- reportDir: 'Report directory',
237
- advancedTitle: 'Advanced',
238
- allow: 'Worker tool allowlist (one per line)',
239
- allowHint: 'Empty uses the built-in default (MCP + native tools). wide_research itself and argo_research are always excluded.',
240
- deny: 'Worker tool denylist (one per line)',
241
- keyRefs: 'Credential forwarding refs (one per line)',
242
- keyRefsHint: 'These refs resolve through DSH credentials and reach the argo child process as environment variables. Missing refs are skipped.',
243
- structural: 'Structural fields',
244
- structuralHint: 'toolName / provider / searchProviderId / fetchProviderId are profile-patch only; the watched patch is reconciled by the official watcher on the same PID. Verify the behavior, no default restart.',
245
- mcpHint: 'The full MCP tool face (mcp__argo__*) is a separate mcp-argo entry in the profile patch; enable it there and verify through the live activation branch.',
246
- noKey: '(not configured)',
247
- tabEngines: 'Engines',
248
- enginesTitle: 'argo engine switches',
249
- enginesHint: 'These switches used to be argo environment variables, editable only in ~/.config/argo/env or the launch environment. They now live in plugin config and reach the argo child process. Changes apply to the next new connection (pooled connections retire after the idle recycle window, 60s by default). Keys do not belong here; use the Keys tab. Authorization switches (recompute execution, private URLs) are deliberately not exposed.',
250
- groupCache: 'Cache & ranking',
251
- groupFetch: 'Fetch layer',
252
- groupSemantic: 'Semantics & adaptivity',
253
- groupEngines: 'Engine on-off',
254
- groupNet: 'Network',
255
- groupLocal: 'Local search',
256
- groupMisc: 'Misc',
257
- groupPaid: 'Quotas & budgets',
258
- groupPaidHint: 'Free and paid sources share one manager: money-metered sources take a monthly budget, count-capped sources take daily/monthly call caps; 0 = unlimited. When a budget or cap is exhausted, that source is skipped and free fallbacks take over. Changes apply to the next new connection.',
259
- envDefault: 'default',
260
- envRange: 'must be between {min} and {max}',
261
- keySourceFile: 'credential store',
262
- keySourceEnv: 'launch environment',
263
- keySourceProjectEnv: 'project .env',
264
- keySourceUserEnv: 'home .env',
265
- keySourceOther: 'other layer',
266
- keyReadonly: 'read-only',
267
- keyOverrideHint: 'saving overrides the current layer',
268
- deepseekShared: 'Shared with the host web_search backend; changing it affects both',
269
- },
19
+ // 双语字典:[zh, en] 单源表,避免两份拷贝各自漂移
20
+ const I18N = {
21
+ title: ['Argo 搜索配置', 'Argo Search Settings'],
22
+ intro: ['接入方式、原生工具、API 密钥与研究编排。保存后即时生效;工具名与 provider 属结构性字段,仍需在 profile patch 中修改。', 'Access mode, native tools, API keys and research orchestration. Saves apply immediately; tool name and provider remain structural profile settings.'],
23
+ loading: ['配置加载中…', 'Loading configuration…'],
24
+ unavailable: ['本插件的配置服务不可用(未挂载或只读)。', 'Configuration service unavailable (not mounted or read-only).'],
25
+ readonly: ['当前配置只读。', 'Configuration is read-only.'],
26
+ saved: ['已保存', 'Saved'],
27
+ refused: ['宿主拒绝写入(可能只读或字段不可热更新)', 'Host refused the write (read-only or not live-editable)'],
28
+ save: ['保存', 'Save'],
29
+ saving: ['保存中…', 'Saving…'],
30
+ on: ['开', 'on'],
31
+ off: ['关', 'off'],
32
+ showMore: ['显示更多', 'Show more'],
33
+ showLess: ['收起', 'Show less'],
34
+ tabAccess: ['接入', 'Access'],
35
+ tabTools: ['工具', 'Tools'],
36
+ tabKeys: ['密钥', 'Keys'],
37
+ tabResearch: ['研究', 'Research'],
38
+ tabAdvanced: ['高级', 'Advanced'],
39
+ tabDashboard: ['看板', 'Dashboard'],
40
+ tabEngines: ['引擎', 'Engines'],
41
+ dashboardTitle: ['运行监控与健康态看板', 'Runtime Monitoring & Health Dashboard'],
42
+ routeHealthTitle: ['路由观测', 'Routing telemetry'],
43
+ routeHealthHint: ['最近的路由决策与引擎状态(宿主提供时显示)。', 'Recent routing decisions and engine status (when provided by the host).'],
44
+ routeHealthFallback: ['在终端运行 `argo stats` 或 `argo engine list` 查看路由健康、引擎成功率与配额消耗。', 'Run `argo stats` or `argo engine list` in a terminal to inspect routing health, engine success rates and quota usage.'],
45
+ dashboardHint: ['实时监控常驻 MCP 连接池、上游搜索源拓扑与额度状态,提供一键预设与快速调优。', 'Real-time overview of the resident MCP connection pool, upstream search engine matrix, and quick workflow presets.'],
46
+ poolTitle: ['常驻 MCP 连接池监控', 'Resident MCP Pool Monitoring'],
47
+ poolStatusHealthy: ['按需连接 · 连接数不常驻', 'On demand · no resident connections'],
48
+ presetTitle: ['工作流快速预设', 'Workflow Presets'],
49
+ presetHint: ['一键对齐常用工作场景的并发与引擎策略,免去逐项手动调优。', 'One-click presets tailored for common research and search workflows.'],
50
+ presetFast: ['极速日常', 'Fast & Free'],
51
+ presetFastDesc: ['免密免费源优先,关闭 TF-IDF 重排与数值交叉比对,超低延迟', 'Keyless & free sources, disable rerank & crosscheck for lowest latency'],
52
+ presetStandard: ['平衡生产(推荐)', 'Balanced (Recommended)'],
53
+ presetStandardDesc: ['开启 TF-IDF 重排、数值交叉核验、主流付费源,标准超时', 'TF-IDF rerank, numeric crosscheck, mainstream paid sources, standard timeouts'],
54
+ presetDeep: ['深度调研', 'Deep Research'],
55
+ presetDeepDesc: ['激活更多取证工具、对冲自适应宽限、语义证据层、更大并发', 'Full forensic tools, adaptive hedge grace, semantic evidence layer, max concurrency'],
56
+ presetApplied: ['已应用预设:', 'Preset applied:'],
57
+ matrixTitle: ['核心引擎拓扑与覆盖全景', 'Core Engine Topology & Coverage'],
58
+ matrixHint: ['当前可用引擎的接入层级与角色分工。带免密标识的引擎无需密钥即可直接使用。', 'Access tiers and roles of available engines. Keyless engines work without an API key.'],
59
+ matrixConfigured: ['密钥已就绪', 'Key Ready'],
60
+ matrixKeyless: ['免密层可用', 'Keyless Ready'],
61
+ matrixPending: ['待配密钥', 'Key Required'],
62
+ searchFilterPlaceholder: ['输入关键词快速筛选...', 'Filter by keyword or engine...'],
63
+ summary: ['Argo · web_search {search} · web_fetch {fetch} · 原生工具 {tools} 个 · 研究 {workers}/{max}', 'Argo · web_search {search} · web_fetch {fetch} · {tools} native tools · research {workers}/{max}'],
64
+ accessTitle: ['接入方式', 'Access'],
65
+ searchSeam: ['宿主 web_search 走 argo', 'Route host web_search to argo'],
66
+ searchSeamHint: ['关闭后 web_search 回到宿主默认搜索后端(web 行 searchProvider)。', 'When off, web_search falls back to the host provider configured on the web row.'],
67
+ fetchSeam: ['宿主 web_fetch 走 argo', 'Route host web_fetch to argo'],
68
+ fetchSeamHint: ['开启前必须在 web 配置行加 fetchProvider: argo;否则两个 provider 同时可用会报 WEB_PROVIDER_AMBIGUOUS。', 'Requires fetchProvider: argo on the web row; otherwise two available providers trigger WEB_PROVIDER_AMBIGUOUS.'],
69
+ entryTitle: ['引擎入口', 'Engine entry'],
70
+ entryHint: ['npx 模式填 npx,参数 -y / github:taxueseek/argo;本机模式填 python3,参数填 mcp_server.py 的绝对路径。', 'npx mode: command npx, args -y / github:taxueseek/argo. Local mode: python3 plus the absolute mcp_server.py path.'],
71
+ command: ['命令', 'Command'],
72
+ args: ['参数(一行一个)', 'Args (one per line)'],
73
+ searchTimeout: ['搜索超时 (ms)', 'Search timeout (ms)'],
74
+ fetchTimeout: ['抓取超时 (ms)', 'Fetch timeout (ms)'],
75
+ fetchChars: ['抓取正文上限(字符)', 'Fetch body cap (chars)'],
76
+ idle: ['连接空闲回收 (ms)', 'Idle recycle (ms)'],
77
+ concurrency: ['并发连接数', 'Concurrent connections'],
78
+ toolsTitle: ['原生工具', 'Native tools'],
79
+ toolsHint: ['勾选即注册为原生一等工具(CLI 单发,不依赖 MCP)。长尾工具只在需要时开,避免每轮工具面膨胀。', 'Checked tools register as native first-class tools (single-shot CLI, no MCP). Enable long-tail tools only when needed.'],
80
+ toolPresetTitle: ['推荐组合', 'Recommended sets'],
81
+ toolPresetHint: ['按场景一键套用(会覆盖当前勾选)。工具分区见下方。', 'Apply a scenario preset in one click (replaces current selection). See the grouped tools below.'],
82
+ coreTools: ['高频路径', 'Hot path'],
83
+ longTools: ['长尾取证', 'Long tail'],
84
+ nativeTimeout: ['单次调用超时 (ms)', 'Per-call timeout (ms)'],
85
+ nativeChars: ['返回文本上限(字符)', 'Returned text cap (chars)'],
86
+ keysTitle: ['API 密钥', 'API keys'],
87
+ keysHint: ['密钥写入 DSH 凭证库(与 Models 页同一处),不会写进插件配置、不回显明文。只有勾选「转发」的引用才会作为环境变量传给 argo 子进程。「清除」只删凭证库里的值,环境变量或 .env 提供的 key 仍会生效。', 'Keys are stored in the DSH credential store (same place as the Models page), never in plugin config and never echoed. Only refs marked Forward reach the argo child process. Clear removes the stored value only; a key supplied by the environment or .env still applies.'],
88
+ commonKeys: ['常用引擎', 'Common engines'],
89
+ moreKeys: ['更多引擎', 'More engines'],
90
+ configured: ['已配置', 'Configured'],
91
+ notConfigured: ['未配置', 'Not configured'],
92
+ forward: ['转发', 'Forward'],
93
+ keyPlaceholderSet: ['输入新值(留空保留现有密钥)', 'Enter a new value (leave blank to keep the current key)'],
94
+ keyPlaceholderEmpty: ['粘贴 API Key', 'Paste API key'],
95
+ saveKey: ['保存', 'Save'],
96
+ clearKey: ['清除', 'Clear'],
97
+ keySaved: ['密钥已保存;下一次新建 argo 连接生效(池内旧连接最长 60s 回收)。', 'Key saved; effective on the next new argo connection (old pooled connections recycle within ~60s).'],
98
+ keyCleared: ['密钥已清除。', 'Key cleared.'],
99
+ keyUnavailable: ['凭证服务不可用。', 'Credential service unavailable.'],
100
+ researchTitle: ['研究编排', 'Research'],
101
+ workers: ['默认 worker 数', 'Default workers'],
102
+ maxWorkers: ['worker 上限', 'Worker cap'],
103
+ tracks: ['轨道上限', 'Track cap'],
104
+ sources: ['每轨信源上限', 'Sources per track'],
105
+ workerTokens: ['worker token 上限', 'Worker token cap'],
106
+ synthTokens: ['综合 token 上限', 'Synthesis token cap'],
107
+ reportDir: ['报告落盘目录', 'Report directory'],
108
+ advancedTitle: ['高级', 'Advanced'],
109
+ allow: ['worker 工具白名单(一行一个)', 'Worker tool allowlist (one per line)'],
110
+ allowHint: ['留空表示使用内置默认(MCP 与原生工具双写)。wide_research 自身与 argo_research 会被硬排除。', 'Empty uses the built-in default (MCP + native tools). wide_research itself and argo_research are always excluded.'],
111
+ deny: ['worker 工具拒绝名单(一行一个)', 'Worker tool denylist (one per line)'],
112
+ keyRefs: ['凭证转发名单(一行一个)', 'Credential forwarding refs (one per line)'],
113
+ keyRefsHint: ['这些引用名会经 DSH credentials 解析后作为环境变量传给 argo 子进程;没有对应凭证的项会被跳过。', 'These refs resolve through DSH credentials and reach the argo child process as environment variables. Missing refs are skipped.'],
114
+ structural: ['结构性字段', 'Structural fields'],
115
+ structuralHint: ['toolName / provider / searchProviderId / fetchProviderId 只能改 profile patch;watched patch 由官方 watcher 同 PID 重组,改后核对功能即可,不默认重启。', 'toolName / provider / searchProviderId / fetchProviderId are profile-patch only; the watched patch is reconciled by the official watcher on the same PID. Verify the behavior, no default restart.'],
116
+ mcpHint: ['MCP 全量工具面(mcp__argo__*)是 profile 里的独立 mcp-argo 行,不在本页开关;需要时在 patch 中取消注释后按 live activation 分支验证。', 'The full MCP tool face (mcp__argo__*) is a separate mcp-argo entry in the profile patch; enable it there and verify through the live activation branch.'],
117
+ noKey: ['(未配置)', '(not configured)'],
118
+ enginesTitle: ['argo 引擎开关', 'argo engine switches'],
119
+ enginesHint: ['这些开关原先是 argo 的环境变量,只能改 ~/.config/argo/env 或启动环境;现在写进插件配置,随 argo 子进程生效。改动对下一次新建连接生效(池内旧连接按「连接空闲回收」时长退出,默认 60s)。密钥不在这里配,请用「密钥」页;本页也不收授权类开关(可复算执行、内网 URL)。', 'These switches used to be argo environment variables, editable only in ~/.config/argo/env or the launch environment. They now live in plugin config and reach the argo child process. Changes apply to the next new connection (pooled connections retire after the idle recycle window, 60s by default). Keys do not belong here; use the Keys tab. Authorization switches (recompute execution, private URLs) are deliberately not exposed.'],
120
+ groupCache: ['缓存与排序', 'Cache & ranking'],
121
+ groupFetch: ['抓取层', 'Fetch layer'],
122
+ groupSemantic: ['语义与自适应', 'Semantics & adaptivity'],
123
+ groupEngines: ['引擎启停', 'Engine on-off'],
124
+ groupNet: ['网络出口', 'Network'],
125
+ groupLocal: ['本机检索', 'Local search'],
126
+ groupMisc: ['其他', 'Misc'],
127
+ groupPaid: ['额度与预算', 'Quotas & budgets'],
128
+ groupPaidHint: ['免费与付费源统一管理:金额计费的源设月度预算,按次数限额的源设日/月次数上限;0=不限制。额度或预算用尽后该源自动跳过并回落免费源。改动对下一次新建连接生效。', 'Free and paid sources share one manager: money-metered sources take a monthly budget, count-capped sources take daily/monthly call caps; 0 = unlimited. When a budget or cap is exhausted, that source is skipped and free fallbacks take over. Changes apply to the next new connection.'],
129
+ envDefault: ['默认', 'default'],
130
+ envRange: ['需在 {min}–{max} 之间', 'must be between {min} and {max}'],
131
+ keySourceFile: ['凭证库', 'credential store'],
132
+ keySourceEnv: ['启动环境', 'launch environment'],
133
+ keySourceProjectEnv: ['项目 .env', 'project .env'],
134
+ keySourceUserEnv: ['家目录 .env', 'home .env'],
135
+ keySourceOther: ['其他层', 'other layer'],
136
+ keyReadonly: ['只读', 'read-only'],
137
+ keyOverrideHint: ['保存后将覆盖当前层', 'saving overrides the current layer'],
138
+ deepseekShared: ['与宿主 web_search 官方后端共用同一把 key,改动同时影响两边', 'Shared with the host web_search backend; changing it affects both'],
270
139
  };
271
140
 
272
141
  // 工具分区(场景化):核心 / 取证 / 本地 / 长尾。
@@ -320,7 +189,8 @@ window.__ModuleLoader__.load({
320
189
  { ref: "EASTMONEY_APIKEY", common: false, label: "东财妙想", en: "Eastmoney Miaoxiang", engines: ["em_miaoxiang"] },
321
190
  { ref: "FELO_API_KEY", common: false, label: "Felo AI搜索", en: "Felo AI Search", engines: ["felo"] },
322
191
  { ref: "FIRECRAWL_API_KEY", common: false, label: "Firecrawl", en: "Firecrawl", engines: ["firecrawl"] },
323
- { ref: "FOURGET_URL", common: false, label: "4get 极简元搜索", en: "Fourget", engines: ["fourget"] },
192
+ { ref: "FOURGET_URL", common: false, label: "4get 极简元搜索", en: "4get", engines: ["fourget"] },
193
+ { ref: "GEMINI_API_KEY", common: false, label: "语义证据·Gemini 决策", en: "Semantic Evidence · Gemini Decision", engines: [] },
324
194
  { ref: "GITHUB_TOKEN", common: false, label: "GitHub", en: "GitHub", engines: ["github"] },
325
195
  { ref: "KEENABLE_API_KEY", common: false, label: "Keenable", en: "Keenable", engines: ["keenable"] },
326
196
  { ref: "METASO_API_KEY", common: false, label: "秘塔", en: "Metaso", engines: ["metaso", "metaso_doc", "metaso_image", "metaso_podcast", "metaso_scholar", "metaso_video"] },
@@ -333,12 +203,13 @@ window.__ModuleLoader__.load({
333
203
  { ref: "SEARXNG_URL", common: false, label: "SearXNG", en: "SearXNG", engines: ["searxng"] },
334
204
  { ref: "SELTZ_API_KEY", common: false, label: "Seltz搜索", en: "Seltz Search", engines: ["seltz"] },
335
205
  { ref: "SERPAPI_API_KEY", common: false, label: "Google Lens 反搜图", en: "Google Lens (SerpAPI)", engines: ["google_lens"] },
206
+ { ref: "TYPESAFE_API_KEY", common: false, label: "语义证据·JEV(TypeSafe)", en: "Semantic Evidence · JEV (TypeSafe)", engines: [] },
336
207
  { ref: "UNPAYWALL_EMAIL", common: false, label: "Unpaywall 开放获取定位", en: "Unpaywall Open Access", engines: ["unpaywall"] },
337
208
  { ref: "WEB_SEARCH_API_KEY", common: false, label: "字节搜索", en: "ByteDance Search", engines: ["byted"] },
338
209
  { ref: "WEREAD_API_KEY", common: false, label: "微信读书", en: "WeRead", engines: ["weread"] },
339
210
  { ref: "WOLFRAM_APPID", common: false, label: "WolframAlpha", en: "WolframAlpha", engines: ["wolframalpha"] },
340
211
  { ref: "YDC_API_KEY", common: false, label: "You.com搜索", en: "You.com Search", engines: ["you"] },
341
- { ref: "ZHIHU_ACCESS_SECRET", common: false, label: "知乎", en: "Zhihu", engines: ["zhihu", "zhihu_global", "zhihu_hot", "zhihu_user"] },
212
+ { ref: "ZHIHU_ACCESS_SECRET", common: false, label: "知乎", en: "Zhihu", engines: ["zhihu", "zhihu_global", "zhihu_hot", "zhihu_kb", "zhihu_questions", "zhihu_user"] },
342
213
  ];
343
214
  // </generated:keys>
344
215
 
@@ -406,8 +277,59 @@ window.__ModuleLoader__.load({
406
277
  workerMaxTokens: 5000, synthesisMaxTokens: 7000, reportDir: '',
407
278
  };
408
279
 
280
+ const FORM_FIELDS = {
281
+ access: [
282
+ { key: 'command', prop: 'searchCommand', type: 'text', label: 'command', layout: 'full' },
283
+ { key: 'argsText', prop: 'searchArgs', type: 'lines', label: 'args', fallbackNonEmpty: true, layout: 'full' },
284
+ { key: 'searchTimeoutMs', prop: 'searchTimeoutMs', type: 'num', min: 1000, label: 'searchTimeout' },
285
+ { key: 'fetchTimeoutMs', prop: 'fetchTimeoutMs', type: 'num', min: 1000, label: 'fetchTimeout' },
286
+ // argo_fetch 工具 schema 上限 50000:与 clamp 对齐防显示失真
287
+ { key: 'fetchMaxChars', prop: 'fetchMaxChars', type: 'num', min: 500, max: 50_000, step: 500, label: 'fetchChars' },
288
+ { key: 'searchIdleMs', prop: 'searchIdleMs', type: 'num', min: 0, step: 1000, label: 'idle' },
289
+ { key: 'searchConcurrency', prop: 'searchConcurrency', type: 'num', min: 1, label: 'concurrency' },
290
+ ],
291
+ tools: [
292
+ { key: 'nativeTimeoutMs', prop: 'nativeTimeoutMs', type: 'num', min: 1000, label: 'nativeTimeout' },
293
+ { key: 'nativeMaxChars', prop: 'nativeMaxChars', type: 'num', min: 500, step: 500, label: 'nativeChars' },
294
+ ],
295
+ research: [
296
+ { key: 'defaultWorkers', prop: 'defaultWorkers', type: 'num', min: 1, label: 'workers' },
297
+ { key: 'maxWorkers', prop: 'maxWorkers', type: 'num', min: 1, minDraft: 'defaultWorkers', label: 'maxWorkers' },
298
+ { key: 'maxTracks', prop: 'maxTracks', type: 'num', min: 2, label: 'tracks' },
299
+ { key: 'maxSourcesPerTrack', prop: 'maxSourcesPerTrack', type: 'num', min: 1, label: 'sources' },
300
+ { key: 'workerMaxTokens', prop: 'workerMaxTokens', type: 'num', min: 512, step: 512, label: 'workerTokens' },
301
+ { key: 'synthesisMaxTokens', prop: 'synthesisMaxTokens', type: 'num', min: 512, step: 512, label: 'synthTokens' },
302
+ { key: 'reportDir', prop: 'reportDir', type: 'text', allowEmpty: true, label: 'reportDir', layout: 'full' },
303
+ ],
304
+ advanced: [
305
+ { key: 'allowText', prop: 'childToolAllow', type: 'lines', label: 'allow', hint: 'allowHint', layout: 'full' },
306
+ { key: 'denyText', prop: 'childToolDeny', type: 'lines', label: 'deny', layout: 'full' },
307
+ { key: 'keyRefsText', prop: 'keyRefs', type: 'lines', label: 'keyRefs', hint: 'keyRefsHint', layout: 'full' },
308
+ ],
309
+ };
310
+
311
+ 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
+ },
327
+ ];
328
+
329
+ const col = (gap) => ({ display: 'flex', flexDirection: 'column', gap });
330
+ const rowBetween = (gap = 8) => ({ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap });
409
331
  const S = {
410
- wrap: { display: 'flex', flexDirection: 'column', gap: 14, maxWidth: 800, color: 'var(--dsw-alias-label-primary, #1f2328)' },
332
+ wrap: { ...col(14), maxWidth: 800, color: 'var(--dsw-alias-label-primary, #1f2328)' },
411
333
  title: { margin: 0, fontSize: 18, fontWeight: 600, lineHeight: '26px' },
412
334
  hint: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary, #7b818b)' },
413
335
  notice: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-state-business-primary, #3b6ef6)' },
@@ -419,10 +341,10 @@ window.__ModuleLoader__.load({
419
341
  color: active ? 'var(--dsw-alias-label-primary, #1f2328)' : 'var(--dsw-alias-label-tertiary, #7b818b)',
420
342
  borderBottom: active ? '2px solid var(--dsw-alias-state-business-primary, #3b6ef6)' : '2px solid transparent',
421
343
  }),
422
- card: { display: 'flex', flexDirection: 'column', gap: 10, padding: '14px 16px', borderRadius: 12, border: '.5px solid var(--dsw-alias-border-l3, #e5e7eb)', background: 'var(--dsw-alias-settings-card-fill, #fff)' },
344
+ card: { ...col(10), padding: '14px 16px', borderRadius: 12, border: '.5px solid var(--dsw-alias-border-l3, #e5e7eb)', background: 'var(--dsw-alias-settings-card-fill, #fff)' },
423
345
  cardTitle: { margin: 0, fontSize: 14, fontWeight: 600, lineHeight: '20px' },
424
- row: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 },
425
- field: { display: 'flex', flexDirection: 'column', gap: 4, minWidth: 0 },
346
+ row: rowBetween(12),
347
+ field: { ...col(4), minWidth: 0 },
426
348
  label: { fontSize: 13, fontWeight: 500, lineHeight: '18px' },
427
349
  sub: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary, #7b818b)' },
428
350
  input: { width: '100%', boxSizing: 'border-box', font: 'inherit', fontSize: 13, lineHeight: '20px', padding: '7px 9px', borderRadius: 8, border: '.5px solid var(--dsw-alias-border-l4, #d0d7de)', background: 'var(--dsw-alias-bg-layer-1, #fff)', color: 'inherit' },
@@ -433,136 +355,83 @@ window.__ModuleLoader__.load({
433
355
  check: { display: 'flex', alignItems: 'center', gap: 8, fontSize: 13, cursor: 'pointer' },
434
356
  btn: { padding: '6px 12px', borderRadius: 8, border: '.5px solid var(--dsw-alias-border-l4, #d0d7de)', background: 'var(--dsw-alias-bg-layer-1, #fff)', color: 'inherit', font: 'inherit', fontSize: 12, lineHeight: '18px', cursor: 'pointer' },
435
357
  btnPrimary: { padding: '6px 14px', borderRadius: 8, border: '.5px solid var(--dsw-alias-state-business-primary, #3b6ef6)', background: 'var(--dsw-alias-state-business-primary, #3b6ef6)', color: '#fff', font: 'inherit', fontSize: 12, lineHeight: '18px', cursor: 'pointer' },
436
- chip: (on) => ({
437
- display: 'inline-flex', alignItems: 'center', gap: 6, padding: '3px 9px', borderRadius: 999, fontSize: 11, lineHeight: '16px', background: 'transparent',
438
- border: '.5px solid ' + (on ? 'var(--dsw-alias-state-business-primary, #3b6ef6)' : 'var(--dsw-alias-border-l3, #e5e7eb)'),
439
- color: on ? 'var(--dsw-alias-state-business-primary, #3b6ef6)' : 'var(--dsw-alias-label-tertiary, #7b818b)',
440
- }),
441
358
  status: { margin: 0, fontSize: 12, minHeight: 18, lineHeight: '18px' },
442
359
  keyRow: { display: 'grid', gridTemplateColumns: 'minmax(150px, 1fr) minmax(0, 1.5fr)', gap: 10, alignItems: 'start', padding: '10px 0', borderTop: '.5px solid var(--dsw-alias-border-l2, #eee)' },
443
- keyHead: { display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0 },
360
+ keyHead: { ...col(2), minWidth: 0 },
444
361
  code: { fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace', fontSize: 10, color: 'var(--dsw-alias-label-tertiary, #7b818b)' },
445
362
  dot: (on) => ({ display: 'inline-block', width: 6, height: 6, borderRadius: 999, background: on ? '#2da44e' : 'var(--dsw-alias-border-l4, #d0d7de)', marginRight: 5 }),
446
363
  actions: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' },
447
- switchWrap: { display: 'flex', alignItems: 'center', gap: 8 },
448
364
  divider: { height: '.5px', background: 'var(--dsw-alias-border-l2, #eee)', margin: '2px 0' },
449
365
  metricGrid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(170px, 1fr))', gap: 10 },
450
- metricCard: { display: 'flex', flexDirection: 'column', gap: 6, padding: '12px 14px', borderRadius: 10, border: '.5px solid var(--dsw-alias-border-l3, #e5e7eb)', background: 'var(--dsw-alias-bg-layer-2, #f8fafc)' },
366
+ metricCard: { ...col(6), padding: '12px 14px', borderRadius: 10, border: '.5px solid var(--dsw-alias-border-l3, #e5e7eb)', background: 'var(--dsw-alias-bg-layer-2, #f8fafc)' },
451
367
  metricLabel: { fontSize: 11, fontWeight: 500, color: 'var(--dsw-alias-label-tertiary, #7b818b)', textTransform: 'uppercase', letterSpacing: '0.04em' },
452
368
  metricValue: { fontSize: 18, fontWeight: 600, lineHeight: '22px', color: 'var(--dsw-alias-label-primary, #1f2328)' },
453
369
  metricSub: { fontSize: 11, lineHeight: '16px', color: 'var(--dsw-alias-label-secondary, #4b5563)' },
454
370
  presetGrid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))', gap: 10 },
455
371
  presetCard: (active) => ({
456
- display: 'flex', flexDirection: 'column', gap: 6, padding: '12px 14px', borderRadius: 10, cursor: 'pointer', textAlign: 'left',
372
+ ...col(6), padding: '12px 14px', borderRadius: 10, cursor: 'pointer', textAlign: 'left',
457
373
  border: active ? '1.5px solid var(--dsw-alias-state-business-primary, #3b6ef6)' : '.5px solid var(--dsw-alias-border-l3, #e5e7eb)',
458
374
  background: active ? 'var(--dsw-alias-bg-layer-1, #fff)' : 'var(--dsw-alias-settings-card-fill, #fff)',
459
375
  boxShadow: active ? '0 1px 3px rgba(59, 110, 246, 0.12)' : 'none',
460
376
  }),
461
377
  matrixGrid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))', gap: 8 },
462
- matrixCard: { display: 'flex', flexDirection: 'column', gap: 4, padding: '10px 12px', borderRadius: 8, border: '.5px solid var(--dsw-alias-border-l3, #e5e7eb)', background: 'var(--dsw-alias-bg-layer-1, #fff)' },
463
- badge: (color) => ({
378
+ matrixCard: { ...col(4), padding: '10px 12px', borderRadius: 8, border: '.5px solid var(--dsw-alias-border-l3, #e5e7eb)', background: 'var(--dsw-alias-bg-layer-1, #fff)' },
379
+ badge: (c) => ({
464
380
  display: 'inline-flex', alignItems: 'center', gap: 4, padding: '2px 8px', borderRadius: 999, fontSize: 10, fontWeight: 500, lineHeight: '14px',
465
- background: color === 'green' ? 'rgba(46, 160, 67, 0.12)' : (color === 'blue' ? 'rgba(59, 110, 246, 0.12)' : 'rgba(100, 116, 139, 0.12)'),
466
- color: color === 'green' ? '#2da44e' : (color === 'blue' ? '#3b6ef6' : '#64748b'),
467
- border: '.5px solid ' + (color === 'green' ? '#2da44e' : (color === 'blue' ? '#3b6ef6' : '#64748b')),
381
+ background: c === 'green' ? 'rgba(46, 160, 67, 0.12)' : (c === 'blue' ? 'rgba(59, 110, 246, 0.12)' : 'rgba(100, 116, 139, 0.12)'),
382
+ color: c === 'green' ? '#2da44e' : (c === 'blue' ? '#3b6ef6' : '#64748b'),
383
+ border: '.5px solid ' + (c === 'green' ? '#2da44e' : (c === 'blue' ? '#3b6ef6' : '#64748b')),
468
384
  }),
469
385
  filterInput: { width: '100%', boxSizing: 'border-box', font: 'inherit', fontSize: 12, lineHeight: '18px', padding: '6px 10px', borderRadius: 8, border: '.5px solid var(--dsw-alias-border-l4, #d0d7de)', background: 'var(--dsw-alias-bg-layer-1, #fff)', color: 'inherit', marginBottom: 8 },
470
386
  };
471
387
 
472
- function asString(value, fallback) {
473
- return typeof value === 'string' ? value : (fallback ?? '');
474
- }
475
-
476
- function asNumber(value, fallback) {
477
- const n = typeof value === 'number' ? value : Number.parseInt(String(value ?? ''), 10);
478
- return Number.isFinite(n) ? n : fallback;
479
- }
480
-
481
- function asArray(value) {
482
- return Array.isArray(value) ? value.filter((item) => typeof item === 'string') : [];
483
- }
484
-
485
- function lines(text) {
486
- return String(text ?? '').split('\n').map((line) => line.trim()).filter(Boolean);
388
+ const asString = (v, fb) => (typeof v === 'string' ? v : (fb ?? ''));
389
+ const asArray = (v) => (Array.isArray(v) ? v.filter((item) => typeof item === 'string') : []);
390
+ const lines = (text) => String(text ?? '').split('\n').map((l) => l.trim()).filter(Boolean);
391
+ function asNumber(v, fb) {
392
+ const n = typeof v === 'number' ? v : Number.parseInt(String(v ?? ''), 10);
393
+ return Number.isFinite(n) ? n : fb;
487
394
  }
488
395
 
489
396
  function toDraft(value) {
490
- return {
491
- command: asString(value.searchCommand, DEFAULTS.searchCommand),
492
- argsText: asArray(value.searchArgs).join('\n'),
493
- searchTimeoutMs: String(asNumber(value.searchTimeoutMs, DEFAULTS.searchTimeoutMs)),
494
- fetchTimeoutMs: String(asNumber(value.fetchTimeoutMs, DEFAULTS.fetchTimeoutMs)),
495
- fetchMaxChars: String(asNumber(value.fetchMaxChars, DEFAULTS.fetchMaxChars)),
496
- searchIdleMs: String(asNumber(value.searchIdleMs, DEFAULTS.searchIdleMs)),
497
- searchConcurrency: String(asNumber(value.searchConcurrency, DEFAULTS.searchConcurrency)),
498
- nativeTimeoutMs: String(asNumber(value.nativeTimeoutMs, DEFAULTS.nativeTimeoutMs)),
499
- nativeMaxChars: String(asNumber(value.nativeMaxChars, DEFAULTS.nativeMaxChars)),
500
- defaultWorkers: String(asNumber(value.defaultWorkers, DEFAULTS.defaultWorkers)),
501
- maxWorkers: String(asNumber(value.maxWorkers, DEFAULTS.maxWorkers)),
502
- maxTracks: String(asNumber(value.maxTracks, DEFAULTS.maxTracks)),
503
- maxSourcesPerTrack: String(asNumber(value.maxSourcesPerTrack, DEFAULTS.maxSourcesPerTrack)),
504
- workerMaxTokens: String(asNumber(value.workerMaxTokens, DEFAULTS.workerMaxTokens)),
505
- synthesisMaxTokens: String(asNumber(value.synthesisMaxTokens, DEFAULTS.synthesisMaxTokens)),
506
- reportDir: asString(value.reportDir, DEFAULTS.reportDir),
507
- allowText: asArray(value.childToolAllow).join('\n'),
508
- denyText: asArray(value.childToolDeny).join('\n'),
509
- keyRefsText: asArray(value.keyRefs).join('\n'),
510
- };
511
- }
512
-
513
- function Card(props) {
514
- return h('section', { style: S.card }, [
515
- props.title ? h('h3', { key: 't', style: S.cardTitle }, props.title) : null,
516
- props.hint ? h('p', { key: 'h', style: S.hint }, props.hint) : null,
517
- props.children,
518
- ]);
519
- }
520
-
521
- function Field(props) {
522
- return h('label', { style: S.field }, [
523
- h('span', { key: 'l', style: S.label }, props.label),
524
- props.children,
525
- props.hint ? h('span', { key: 'h', style: S.sub }, props.hint) : null,
526
- ]);
527
- }
528
-
529
- function Switch(props) {
530
- return h('div', { style: S.row }, [
531
- h('div', { key: 'txt', style: { minWidth: 0 } }, [
532
- h('div', { key: 'l', style: S.label }, props.label),
533
- props.hint ? h('div', { key: 'h', style: S.sub }, props.hint) : null,
534
- ]),
535
- h('input', {
536
- key: 'i',
537
- type: 'checkbox',
538
- checked: props.checked === true,
539
- disabled: props.disabled === true,
540
- onChange: (event) => props.onChange(event.target.checked),
541
- 'aria-label': props.label,
542
- }),
543
- ]);
544
- }
545
-
546
- function NumberField(props) {
547
- return h(Field, { label: props.label, hint: props.hint }, h('input', {
548
- type: 'number',
549
- style: S.input,
550
- value: props.value,
551
- min: props.min,
552
- step: props.step ?? 1,
553
- disabled: props.disabled === true,
554
- onChange: (event) => props.onChange(event.target.value),
555
- }));
397
+ const out = {};
398
+ for (const specs of Object.values(FORM_FIELDS)) {
399
+ for (const f of specs) {
400
+ if (f.type === 'lines') out[f.key] = asArray(value[f.prop]).join('\n');
401
+ else if (f.type === 'num') out[f.key] = String(asNumber(value[f.prop], DEFAULTS[f.prop]));
402
+ else out[f.key] = asString(value[f.prop], DEFAULTS[f.prop]);
403
+ }
404
+ }
405
+ return out;
556
406
  }
557
407
 
558
- function PrimaryButton(props) {
559
- return h('button', {
560
- type: 'button',
561
- style: props.primary ? S.btnPrimary : S.btn,
562
- disabled: props.disabled === true,
563
- onClick: props.onClick,
564
- }, props.children);
565
- }
408
+ const Card = (p) => h('section', { style: S.card }, [
409
+ p.title ? h('h3', { key: 't', style: S.cardTitle }, p.title) : null,
410
+ p.hint ? h('p', { key: 'h', style: S.hint }, p.hint) : null,
411
+ p.children,
412
+ ]);
413
+ const Field = (p) => h('label', { style: S.field }, [
414
+ h('span', { key: 'l', style: S.label }, p.label),
415
+ p.children,
416
+ p.hint ? h('span', { key: 'h', style: S.sub }, p.hint) : null,
417
+ ]);
418
+ const Switch = (p) => h('div', { style: S.row }, [
419
+ h('div', { key: 'txt', style: { minWidth: 0 } }, [
420
+ h('div', { key: 'l', style: S.label }, p.label),
421
+ p.hint ? h('div', { key: 'h', style: S.sub }, p.hint) : null,
422
+ ]),
423
+ h('input', {
424
+ key: 'i', type: 'checkbox', checked: p.checked === true, disabled: p.disabled === true,
425
+ onChange: (e) => p.onChange(e.target.checked), 'aria-label': p.label,
426
+ }),
427
+ ]);
428
+ const NumberField = (p) => h(Field, { label: p.label, hint: p.hint }, h('input', {
429
+ type: 'number', style: S.input, value: p.value, min: p.min, step: p.step ?? 1,
430
+ disabled: p.disabled === true, onChange: (e) => p.onChange(e.target.value),
431
+ }));
432
+ const PrimaryButton = (p) => h('button', {
433
+ type: 'button', style: p.primary ? S.btnPrimary : S.btn, disabled: p.disabled === true, onClick: p.onClick,
434
+ }, p.children);
566
435
 
567
436
  function ArgoPanel(props) {
568
437
  const state = props.useArgoForm((snapshot) => snapshot);
@@ -574,51 +443,36 @@ window.__ModuleLoader__.load({
574
443
  const locale = props.locale;
575
444
  const initialLang = locale && locale.getSnapshot && locale.getSnapshot().active === 'en' ? 'en' : 'zh';
576
445
  const [lang, setLang] = useState(initialLang);
577
-
578
- const [tab, setTab] = useState('dashboard');
446
+ const [tab, setTab] = useState('dashboard'); // hooks[1]:测试按此索引注入页签
579
447
  const [draft, setDraft] = useState(() => toDraft(value));
580
448
  const [busy, setBusy] = useState('');
581
449
  const [message, setMessage] = useState('');
582
450
  const [error, setError] = useState(false);
583
-
584
451
  const [credentials, setCredentials] = useState({});
585
452
  const [keyDraft, setKeyDraft] = useState({});
586
453
  const [keyBusy, setKeyBusy] = useState('');
587
454
  const [showAllKeys, setShowAllKeys] = useState(false);
588
-
589
- // argoEnv 引擎开关:bool 类即时写;num/str/list 类走草稿 + 分组保存。
455
+ // argoEnv 引擎开关:bool 类即时写;num/str/list 类走草稿 + 分组保存
590
456
  const [envDraft, setEnvDraft] = useState({});
591
457
  const [envBusy, setEnvBusy] = useState('');
592
458
  const [engineFilter, setEngineFilter] = useState('');
593
459
  const [keyFilter, setKeyFilter] = useState('');
594
- // 路由观测(宿主经 remote 事件推送;无推送时卡片显示终端命令提示)
595
460
  const [routeHealth, setRouteHealth] = useState(null);
596
461
 
597
462
  const dirty = useRef(new Set());
598
- // 读-改-写共享配置字段(keyRefs / nativeTools / argoEnv)时读实时快照,
599
- // 不读渲染时快照:保存是 await 之后的异步写,连续两次操作都从渲染值出发
600
- // 会把前一次的结果挤掉(丢一个转发勾选/工具勾选)。
463
+ const credSeq = useRef(0);
464
+ // 读-改-写共享字段(keyRefs / nativeTools / argoEnv)读实时快照,防连点丢更新
601
465
  const liveValue = () => {
602
- const snapshot = typeof props.useArgoForm?.getSnapshot === 'function'
603
- ? props.useArgoForm.getSnapshot()
604
- : undefined;
605
- return snapshot && snapshot.value ? snapshot.value : value;
466
+ const snap = typeof props.useArgoForm?.getSnapshot === 'function' ? props.useArgoForm.getSnapshot() : undefined;
467
+ return snap && snap.value ? snap.value : value;
606
468
  };
607
- // describe 往返乱序防护:只认最新一次请求的响应(同官方 settings 页口径)。
608
- const credSeq = useRef(0);
609
469
 
610
- const dict = lang === 'en' ? DICT.en : DICT.zh;
611
- const t = (key) => {
612
- const text = dict[key] !== undefined ? dict[key] : DICT.zh[key];
613
- return text !== undefined ? text : key;
614
- };
470
+ const langIdx = lang === 'en' ? 1 : 0;
471
+ const t = (key) => (I18N[key] ? (I18N[key][langIdx] ?? I18N[key][0]) : key);
615
472
 
616
473
  useEffect(() => {
617
474
  const off = locale && locale.subscribe
618
- ? locale.subscribe(() => {
619
- const next = locale.getSnapshot && locale.getSnapshot().active === 'en' ? 'en' : 'zh';
620
- setLang(next);
621
- })
475
+ ? locale.subscribe(() => setLang(locale.getSnapshot && locale.getSnapshot().active === 'en' ? 'en' : 'zh'))
622
476
  : undefined;
623
477
  return typeof off === 'function' ? off : undefined;
624
478
  }, [locale]);
@@ -637,12 +491,10 @@ window.__ModuleLoader__.load({
637
491
  if (!props.credentials || typeof props.credentials.describe !== 'function') return;
638
492
  const seq = ++credSeq.current;
639
493
  try {
640
- const response = await props.credentials.describe(KEYS.map((entry) => entry.ref));
494
+ const res = await props.credentials.describe(KEYS.map((entry) => entry.ref));
641
495
  if (seq !== credSeq.current) return;
642
- if (response && response.ok) setCredentials(response.value || {});
643
- } catch {
644
- /* 凭证服务暂不可用:保留上一次状态 */
645
- }
496
+ if (res && res.ok) setCredentials(res.value || {});
497
+ } catch { /* 凭证服务暂不可用 */ }
646
498
  };
647
499
 
648
500
  useEffect(() => {
@@ -658,150 +510,94 @@ window.__ModuleLoader__.load({
658
510
  return () => { for (const off of offs) off(); };
659
511
  }, [state]);
660
512
 
661
- const edit = (key, text) => {
662
- dirty.current.add(key);
663
- setDraft((previous) => ({ ...previous, [key]: text }));
664
- };
665
-
666
- const report = (ok, text) => {
667
- setError(!ok);
668
- setMessage(text);
669
- };
513
+ const edit = (key, text) => { dirty.current.add(key); setDraft((p) => ({ ...p, [key]: text })); };
514
+ const report = (ok, text) => { setError(!ok); setMessage(text); };
670
515
 
671
- const write = async (ops) => {
516
+ const runSave = async (key, fn) => {
672
517
  if (disabled) return false;
673
- setBusy('save');
674
- try {
675
- const ok = await props.mutate(ops);
676
- report(ok, ok ? t('saved') : t('refused'));
677
- return ok;
678
- } catch (cause) {
679
- report(false, cause && cause.message ? cause.message : String(cause));
680
- return false;
681
- } finally {
682
- setBusy('');
683
- }
518
+ setBusy(key);
519
+ try { return await fn(); }
520
+ catch (cause) { report(false, cause && cause.message ? cause.message : String(cause)); return false; }
521
+ finally { setBusy(''); }
684
522
  };
685
523
 
686
- const setField = async (field, next) => {
687
- if (disabled) return;
688
- setBusy(field);
689
- try {
690
- const ok = await props.set(field, next);
691
- report(ok, ok ? t('saved') : t('refused'));
692
- } catch (cause) {
693
- report(false, cause && cause.message ? cause.message : String(cause));
694
- } finally {
695
- setBusy('');
696
- }
697
- };
698
-
699
- const atLeast = (text, fallback, min) => Math.max(min, asNumber(text, fallback));
700
- const clearDirty = (keys) => {
701
- for (const key of keys) dirty.current.delete(key);
702
- };
703
-
704
- const saveAccess = async () => {
705
- const args = lines(draft.argsText);
706
- const ok = await write([
707
- { op: 'set', path: ['searchCommand'], value: draft.command.trim() || DEFAULTS.searchCommand },
708
- { op: 'set', path: ['searchArgs'], value: args.length ? args : DEFAULTS.searchArgs },
709
- { op: 'set', path: ['searchTimeoutMs'], value: atLeast(draft.searchTimeoutMs, DEFAULTS.searchTimeoutMs, 1000) },
710
- { op: 'set', path: ['fetchTimeoutMs'], value: atLeast(draft.fetchTimeoutMs, DEFAULTS.fetchTimeoutMs, 1000) },
711
- // argo_fetch 工具 schema 上限 50000(native-tools.mjs 由 mcp_tools.py
712
- // 生成):配更大会被 argo clamp 回 50000,面板显示值与实效不符,这里就地截断。
713
- { op: 'set', path: ['fetchMaxChars'], value: Math.min(50_000, atLeast(draft.fetchMaxChars, DEFAULTS.fetchMaxChars, 500)) },
714
- { op: 'set', path: ['searchIdleMs'], value: atLeast(draft.searchIdleMs, DEFAULTS.searchIdleMs, 0) },
715
- { op: 'set', path: ['searchConcurrency'], value: atLeast(draft.searchConcurrency, DEFAULTS.searchConcurrency, 1) },
716
- ]);
717
- if (ok) clearDirty(['command', 'argsText', 'searchTimeoutMs', 'fetchTimeoutMs', 'fetchMaxChars', 'searchIdleMs', 'searchConcurrency']);
718
- };
719
-
720
- const saveTools = async () => {
721
- const ok = await write([
722
- { op: 'set', path: ['nativeTimeoutMs'], value: atLeast(draft.nativeTimeoutMs, DEFAULTS.nativeTimeoutMs, 1000) },
723
- { op: 'set', path: ['nativeMaxChars'], value: atLeast(draft.nativeMaxChars, DEFAULTS.nativeMaxChars, 500) },
724
- ]);
725
- if (ok) clearDirty(['nativeTimeoutMs', 'nativeMaxChars']);
726
- };
524
+ const write = (ops) => runSave('save', async () => {
525
+ const ok = await props.mutate(ops);
526
+ report(ok, ok ? t('saved') : t('refused'));
527
+ return ok;
528
+ });
727
529
 
728
- const saveResearch = async () => {
729
- const workers = atLeast(draft.defaultWorkers, DEFAULTS.defaultWorkers, 1);
730
- const maxWorkers = Math.max(workers, atLeast(draft.maxWorkers, DEFAULTS.maxWorkers, 1));
731
- const ok = await write([
732
- { op: 'set', path: ['defaultWorkers'], value: workers },
733
- { op: 'set', path: ['maxWorkers'], value: maxWorkers },
734
- { op: 'set', path: ['maxTracks'], value: atLeast(draft.maxTracks, DEFAULTS.maxTracks, 2) },
735
- { op: 'set', path: ['maxSourcesPerTrack'], value: atLeast(draft.maxSourcesPerTrack, DEFAULTS.maxSourcesPerTrack, 1) },
736
- { op: 'set', path: ['workerMaxTokens'], value: atLeast(draft.workerMaxTokens, DEFAULTS.workerMaxTokens, 512) },
737
- { op: 'set', path: ['synthesisMaxTokens'], value: atLeast(draft.synthesisMaxTokens, DEFAULTS.synthesisMaxTokens, 512) },
738
- { op: 'set', path: ['reportDir'], value: draft.reportDir.trim() },
739
- ]);
740
- if (ok) clearDirty(['defaultWorkers', 'maxWorkers', 'maxTracks', 'maxSourcesPerTrack', 'workerMaxTokens', 'synthesisMaxTokens', 'reportDir']);
741
- };
530
+ const setField = (field, next) => runSave(field, async () => {
531
+ const ok = await props.set(field, next);
532
+ report(ok, ok ? t('saved') : t('refused'));
533
+ return ok;
534
+ });
742
535
 
743
- const saveAdvanced = async () => {
744
- const ok = await write([
745
- { op: 'set', path: ['childToolAllow'], value: lines(draft.allowText) },
746
- { op: 'set', path: ['childToolDeny'], value: lines(draft.denyText) },
747
- { op: 'set', path: ['keyRefs'], value: lines(draft.keyRefsText) },
748
- ]);
749
- if (ok) clearDirty(['allowText', 'denyText', 'keyRefsText']);
536
+ const saveFormGroup = async (groupKey) => {
537
+ const specs = FORM_FIELDS[groupKey];
538
+ const parsed = {};
539
+ const ops = specs.map((f) => {
540
+ let val;
541
+ if (f.type === 'lines') {
542
+ const arr = lines(draft[f.key]);
543
+ val = f.fallbackNonEmpty && !arr.length ? DEFAULTS[f.prop] : arr;
544
+ } else if (f.type === 'num') {
545
+ const minVal = f.minDraft ? Math.max(f.min, parsed[f.minDraft]) : f.min;
546
+ val = Math.max(minVal, asNumber(draft[f.key], DEFAULTS[f.prop]));
547
+ if (f.max !== undefined) val = Math.min(f.max, val);
548
+ } else {
549
+ const trimmed = draft[f.key].trim();
550
+ val = f.allowEmpty ? trimmed : (trimmed || DEFAULTS[f.prop]);
551
+ }
552
+ parsed[f.key] = val;
553
+ return { op: 'set', path: [f.prop], value: val };
554
+ });
555
+ const ok = await write(ops);
556
+ if (ok) for (const f of specs) dirty.current.delete(f.key);
750
557
  };
751
558
 
752
559
  const toggleTool = (id) => {
753
560
  const current = new Set(asArray(liveValue().nativeTools));
754
561
  if (current.has(id)) current.delete(id);
755
562
  else current.add(id);
756
- const ordered = TOOLS.map((tool) => tool.id).filter((toolId) => current.has(toolId));
563
+ const ordered = TOOLS.map((tool) => tool.id).filter((tid) => current.has(tid));
757
564
  for (const extra of current) if (!ordered.includes(extra)) ordered.push(extra);
758
565
  void setField('nativeTools', ordered);
759
566
  };
760
567
 
761
- // 推荐组合:一键套用一组工具(场景化分区之上的快捷入口)。
762
- // 只增不减会覆盖用户已有勾选,所以是「设为这组」而非「追加这组」。
763
568
  const applyToolPreset = async (tools) => {
764
- const ordered = TOOLS.map((tool) => tool.id).filter((toolId) => tools.includes(toolId));
569
+ const ordered = TOOLS.map((tool) => tool.id).filter((tid) => tools.includes(tid));
765
570
  for (const extra of tools) if (!ordered.includes(extra)) ordered.push(extra);
766
571
  await props.set('nativeTools', ordered);
767
572
  };
768
573
 
769
- const saveKey = async (ref) => {
574
+ const mutateKey = async (ref, action) => {
575
+ setKeyBusy(ref);
576
+ try { await action(); await refreshCredentials(); }
577
+ catch (cause) { report(false, cause && cause.message ? cause.message : String(cause)); }
578
+ finally { setKeyBusy(''); }
579
+ };
580
+
581
+ const saveKey = (ref) => {
770
582
  const key = asString(keyDraft[ref]).trim();
771
583
  if (!key || !props.credentials) return;
772
- setKeyBusy(ref);
773
- try {
774
- const response = await props.credentials.set(ref, key);
775
- if (!response || !response.ok) {
776
- throw new Error(response && response.error ? response.error.message : t('keyUnavailable'));
777
- }
778
- setKeyDraft((previous) => ({ ...previous, [ref]: '' }));
584
+ return mutateKey(ref, async () => {
585
+ const res = await props.credentials.set(ref, key);
586
+ if (!res || !res.ok) throw new Error(res && res.error ? res.error.message : t('keyUnavailable'));
587
+ setKeyDraft((p) => ({ ...p, [ref]: '' }));
779
588
  const refs = asArray(liveValue().keyRefs);
780
589
  if (!refs.includes(ref)) await props.set('keyRefs', [...refs, ref]);
781
590
  report(true, t('keySaved'));
782
- await refreshCredentials();
783
- } catch (cause) {
784
- report(false, cause && cause.message ? cause.message : String(cause));
785
- } finally {
786
- setKeyBusy('');
787
- }
591
+ });
788
592
  };
789
593
 
790
- const clearKey = async (ref) => {
594
+ const clearKey = (ref) => {
791
595
  if (!props.credentials) return;
792
- setKeyBusy(ref);
793
- try {
794
- const response = await props.credentials.unset(ref);
795
- if (!response || !response.ok) {
796
- throw new Error(response && response.error ? response.error.message : t('keyUnavailable'));
797
- }
596
+ return mutateKey(ref, async () => {
597
+ const res = await props.credentials.unset(ref);
598
+ if (!res || !res.ok) throw new Error(res && res.error ? res.error.message : t('keyUnavailable'));
798
599
  report(true, t('keyCleared'));
799
- await refreshCredentials();
800
- } catch (cause) {
801
- report(false, cause && cause.message ? cause.message : String(cause));
802
- } finally {
803
- setKeyBusy('');
804
- }
600
+ });
805
601
  };
806
602
 
807
603
  const setForward = (ref, on) => {
@@ -811,12 +607,7 @@ window.__ModuleLoader__.load({
811
607
  void setField('keyRefs', [...refs]);
812
608
  };
813
609
 
814
- // ── argoEnv 引擎开关:KEY=VALUE 行 ↔ 控件 ──
815
- // argoEnv 行集合是单一真源:每次写入都基于实时快照读-改-写,只碰白名单
816
- // 内的名字。白名单外的行**被清掉**,不是原样保留——apply 期对白名单外
817
- // 名字是 loud fail(整个插件加载失败),直接写 profile patch 写错的开关
818
- // 会让人卡在「改不回来」;这里任何一次面板写入都顺手清毒,是最容易碰到
819
- // 的恢复入口。
610
+ // argoEnv 单一真源:写入时过滤白名单外脏键,避免 apply 期 loud fail 卡死
820
611
  const envMap = () => {
821
612
  const map = {};
822
613
  for (const entry of asArray(liveValue().argoEnv)) {
@@ -825,31 +616,24 @@ window.__ModuleLoader__.load({
825
616
  }
826
617
  return map;
827
618
  };
828
- // 与 argo 的 env_flag 判定对齐:空串/0/false/no/off/n/disable/disabled/none 算关。
829
619
  const ENV_FALSY = ['', '0', 'false', 'no', 'off', 'n', 'disable', 'disabled', 'none'];
830
- const envBoolState = (spec, map) => {
831
- const raw = map[spec.name];
832
- return raw === undefined
620
+ const envBoolState = (spec, map) => (
621
+ map[spec.name] === undefined
833
622
  ? spec.def === true
834
- : !ENV_FALSY.includes(String(raw).trim().toLowerCase());
835
- };
623
+ : !ENV_FALSY.includes(String(map[spec.name]).trim().toLowerCase())
624
+ );
836
625
  const writeEnvLines = async (updates) => {
837
626
  const map = envMap();
838
627
  for (const name of Object.keys(updates)) {
839
- const value = updates[name];
840
- if (value === null || value === undefined || value === '') delete map[name];
841
- else map[name] = value;
628
+ const val = updates[name];
629
+ if (val === null || val === undefined || val === '') delete map[name];
630
+ else map[name] = val;
842
631
  }
843
- const lines = Object.keys(map)
844
- .filter((name) => ENV_NAMES.has(name))
845
- .map((name) => `${name}=${map[name]}`);
846
- return props.set('argoEnv', lines);
632
+ return props.set('argoEnv', Object.keys(map).filter((n) => ENV_NAMES.has(n)).map((n) => `${n}=${map[n]}`));
847
633
  };
848
634
  const toggleEnv = (spec, on) => {
849
635
  if (disabled) return;
850
- // 开关状态直接落 0/1:文案与 env 同向(开=1,关=0),不做反转。
851
- const value = on ? '1' : '0';
852
- void writeEnvLines({ [spec.name]: value })
636
+ void writeEnvLines({ [spec.name]: on ? '1' : '0' })
853
637
  .then((ok) => report(ok, ok ? t('saved') : t('refused')))
854
638
  .catch((cause) => report(false, cause && cause.message ? cause.message : String(cause)));
855
639
  };
@@ -857,14 +641,9 @@ window.__ModuleLoader__.load({
857
641
  if (disabled) return;
858
642
  const updates = {};
859
643
  for (const spec of ENGINE_TOGGLES) {
860
- if (spec.group !== group || spec.kind === 'bool') continue;
861
- const raw = envDraft[spec.name];
862
- if (raw === undefined) continue;
863
- const text = String(raw).trim();
864
- if (text === '') {
865
- updates[spec.name] = null;
866
- continue;
867
- }
644
+ if (spec.group !== group || spec.kind === 'bool' || envDraft[spec.name] === undefined) continue;
645
+ const text = String(envDraft[spec.name]).trim();
646
+ if (text === '') { updates[spec.name] = null; continue; }
868
647
  if (spec.kind === 'num') {
869
648
  const n = Number(text);
870
649
  if (!Number.isFinite(n) || n < spec.min || n > spec.max) {
@@ -880,71 +659,28 @@ window.__ModuleLoader__.load({
880
659
  const ok = await writeEnvLines(updates);
881
660
  report(ok, ok ? t('saved') : t('refused'));
882
661
  if (ok) setEnvDraft({});
883
- } catch (cause) {
884
- report(false, cause && cause.message ? cause.message : String(cause));
885
- } finally {
886
- setEnvBusy('');
887
- }
662
+ } catch (cause) { report(false, cause && cause.message ? cause.message : String(cause)); }
663
+ finally { setEnvBusy(''); }
888
664
  };
889
665
 
890
- const applyPreset = async (type) => {
891
- if (disabled) return;
892
- setBusy('preset');
893
- try {
894
- const map = envMap();
895
- const ops = [];
896
- if (type === 'fast') {
897
- map.ARGO_TFIDF_RERANK = '0';
898
- map.ARGO_NUMBER_CROSSCHECK = '0';
899
- map.ARGO_PAID_SEARCH = 'off';
900
- map.ARGO_ADAPTIVE_GRACE = '1';
901
- map.ARGO_SERIAL_STAGGER_S = '0.5';
902
- ops.push({ op: 'set', path: ['searchTimeoutMs'], value: 15000 });
903
- ops.push({ op: 'set', path: ['fetchTimeoutMs'], value: 15000 });
904
- } else if (type === 'standard') {
905
- map.ARGO_TFIDF_RERANK = '1';
906
- map.ARGO_NUMBER_CROSSCHECK = '1';
907
- map.ARGO_MINHASH_DEDUPE = '1';
908
- map.ARGO_PAID_SEARCH = 'auto';
909
- map.ARGO_ADAPTIVE_GRACE = '1';
910
- map.ARGO_SERIAL_STAGGER_S = '0.8';
911
- ops.push({ op: 'set', path: ['searchTimeoutMs'], value: 30000 });
912
- ops.push({ op: 'set', path: ['fetchTimeoutMs'], value: 25000 });
913
- } else if (type === 'deep') {
914
- map.ARGO_TFIDF_RERANK = '1';
915
- map.ARGO_NUMBER_CROSSCHECK = '1';
916
- map.ARGO_MINHASH_DEDUPE = '1';
917
- map.ARGO_SEMANTIC_EVIDENCE = '1';
918
- map.ARGO_ADAPTIVE_GRACE = '1';
919
- map.ARGO_PAID_SEARCH = 'auto';
920
- ops.push({ op: 'set', path: ['searchTimeoutMs'], value: 45000 });
921
- ops.push({ op: 'set', path: ['fetchTimeoutMs'], value: 35000 });
922
- ops.push({ op: 'set', path: ['nativeTimeoutMs'], value: 60000 });
923
- }
924
- const envLines = Object.keys(map)
925
- .filter((name) => ENV_NAMES.has(name))
926
- .map((name) => `${name}=${map[name]}`);
927
- ops.push({ op: 'set', path: ['argoEnv'], value: envLines });
928
- const ok = await props.mutate(ops);
929
- const presetName = type === 'fast' ? t('presetFast') : (type === 'standard' ? t('presetStandard') : t('presetDeep'));
930
- report(ok, ok ? `${t('presetApplied')} ${presetName}` : t('refused'));
931
- } catch (cause) {
932
- report(false, cause && cause.message ? cause.message : String(cause));
933
- } finally {
934
- setBusy('');
935
- }
936
- };
666
+ const applyPreset = (preset) => runSave('preset', async () => {
667
+ const map = { ...envMap(), ...preset.env };
668
+ const ops = Object.entries(preset.fields).map(([path, val]) => ({ op: 'set', path: [path], value: val }));
669
+ const envLines = Object.keys(map).filter((n) => ENV_NAMES.has(n)).map((n) => `${n}=${map[n]}`);
670
+ ops.push({ op: 'set', path: ['argoEnv'], value: envLines });
671
+ const ok = await props.mutate(ops);
672
+ report(ok, ok ? `${t('presetApplied')} ${t(preset.titleKey)}` : t('refused'));
673
+ return ok;
674
+ });
937
675
 
938
676
  if (props.view === 'summary') {
939
- const summary = t('summary')
677
+ return t('summary')
940
678
  .replace('{search}', value.searchProviderEnabled !== false ? t('on') : t('off'))
941
679
  .replace('{fetch}', value.fetchProviderEnabled !== false ? t('on') : t('off'))
942
680
  .replace('{tools}', String(asArray(value.nativeTools).length))
943
681
  .replace('{workers}', String(asNumber(value.defaultWorkers, DEFAULTS.defaultWorkers)))
944
682
  .replace('{max}', String(asNumber(value.maxWorkers, DEFAULTS.maxWorkers)));
945
- return summary;
946
683
  }
947
-
948
684
  if (!ready) {
949
685
  return h('div', { style: S.wrap }, [
950
686
  h('h2', { key: 't', style: S.title }, t('title')),
@@ -952,202 +688,131 @@ window.__ModuleLoader__.load({
952
688
  ]);
953
689
  }
954
690
 
955
- const tabButton = (id, label) => h('button', {
956
- key: id,
957
- type: 'button',
958
- style: S.tab(tab === id),
959
- onClick: () => setTab(id),
960
- }, label);
961
-
962
- const statusLine = message
963
- ? h('p', { style: error ? S.error : S.notice, role: 'status' }, message)
964
- : h('p', { style: S.status }, disabled ? t('readonly') : '');
965
-
966
- // 按 TOOL_GROUPS 顺序分组渲染(场景化分区,替代旧的 core/long 两分)
967
- const toolsByGroup = (gid) => TOOLS.filter((tool) => tool.group === gid);
968
- const toolCheckbox = (tool) => h('label', { key: tool.id, style: S.check }, [
969
- h('input', {
970
- key: 'i',
971
- type: 'checkbox',
972
- checked: asArray(value.nativeTools).includes(tool.id),
973
- disabled,
974
- onChange: () => toggleTool(tool.id),
975
- }),
976
- h('span', { key: 't' }, [
977
- h('span', { key: 'n', style: S.mono }, tool.id),
978
- h('span', { key: 'd', style: S.sub }, ' ' + (lang === 'en' ? tool.en : tool.zh)),
979
- ]),
691
+ const renderField = (f) => {
692
+ if (f.type === 'num') {
693
+ return h(NumberField, {
694
+ key: f.key, label: t(f.label), min: f.min, step: f.step,
695
+ value: draft[f.key], disabled, onChange: (next) => edit(f.key, next),
696
+ });
697
+ }
698
+ const isLines = f.type === 'lines';
699
+ return h(Field, { key: f.key, label: t(f.label), hint: f.hint ? t(f.hint) : undefined }, h(isLines ? 'textarea' : 'input', {
700
+ type: isLines ? undefined : 'text',
701
+ style: isLines ? { ...S.input, ...S.textarea, ...S.mono } : { ...S.input, ...S.mono },
702
+ value: draft[f.key], disabled, spellCheck: false,
703
+ onChange: (e) => edit(f.key, e.target.value),
704
+ }));
705
+ };
706
+ const renderGroup = (groupKey) => {
707
+ const specs = FORM_FIELDS[groupKey];
708
+ const full = specs.filter((f) => f.layout === 'full').map(renderField);
709
+ const grid = specs.filter((f) => f.layout !== 'full').map(renderField);
710
+ return [
711
+ ...full,
712
+ grid.length ? h('div', { key: 'g', style: S.grid }, grid) : null,
713
+ ];
714
+ };
715
+ const saveBtn = (groupKey) => h('div', { key: 'save', style: S.actions }, [
716
+ h(PrimaryButton, {
717
+ primary: true, disabled: disabled || busy === 'save',
718
+ onClick: () => { void saveFormGroup(groupKey); },
719
+ }, busy === 'save' ? t('saving') : t('save')),
980
720
  ]);
981
721
 
982
722
  const keyRow = (entry) => {
983
723
  const info = credentials[entry.ref];
984
724
  const configured = info && info.configured === true;
985
- const writable = !info || info.writable !== false;
986
- const forwarded = asArray(value.keyRefs).includes(entry.ref);
987
- // 来源层:回答「这把 key 从哪来」。保存写凭证库文件层,优先级高于
988
- // 启动环境与 .env,所以来源不是 file 时提示保存后会覆盖当前层。
725
+ const rowWritable = !info || info.writable !== false;
989
726
  const sourceLabel = configured && typeof info.source === 'string'
990
- ? t('keySource' + info.source.split('-').map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(''))
727
+ ? t('keySource' + info.source.split('-').map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(''))
991
728
  : '';
992
729
  const statusParts = [configured ? t('configured') : t('notConfigured')];
993
730
  if (sourceLabel && sourceLabel !== 'keySource' + info.source) statusParts.push(sourceLabel);
994
- if (configured && !writable) statusParts.push(t('keyReadonly'));
995
- if (configured && writable && info.source !== undefined && info.source !== 'file') statusParts.push(t('keyOverrideHint'));
731
+ if (configured && !rowWritable) statusParts.push(t('keyReadonly'));
732
+ if (configured && rowWritable && info.source !== undefined && info.source !== 'file') statusParts.push(t('keyOverrideHint'));
996
733
  return h('div', { key: entry.ref, style: S.keyRow }, [
997
734
  h('div', { key: 'head', style: S.keyHead }, [
998
- h('span', { key: 'n', style: S.label }, [
999
- h('span', { key: 'dot', style: S.dot(configured) }),
1000
- lang === 'en' ? (entry.en || entry.label) : entry.label,
1001
- ]),
735
+ h('span', { key: 'n', style: S.label }, [h('span', { key: 'dot', style: S.dot(configured) }), lang === 'en' ? (entry.en || entry.label) : entry.label]),
1002
736
  h('span', { key: 'ref', style: S.code }, entry.ref),
1003
737
  h('span', { key: 's', style: S.sub }, statusParts.join(' · ')),
1004
- entry.ref === 'DEEPSEEK_API_KEY'
1005
- ? h('span', { key: 'shared', style: S.sub }, t('deepseekShared'))
1006
- : null,
738
+ entry.ref === 'DEEPSEEK_API_KEY' ? h('span', { key: 'shared', style: S.sub }, t('deepseekShared')) : null,
1007
739
  ]),
1008
- h('div', { key: 'body', style: { display: 'flex', flexDirection: 'column', gap: 6 } }, [
740
+ h('div', { key: 'body', style: col(6) }, [
1009
741
  h('input', {
1010
- key: 'i',
1011
- type: 'password',
1012
- autoComplete: 'off',
1013
- spellCheck: false,
1014
- style: S.input,
1015
- value: asString(keyDraft[entry.ref]),
1016
- placeholder: configured ? t('keyPlaceholderSet') : t('keyPlaceholderEmpty'),
1017
- disabled: disabled || !props.credentials || !writable,
1018
- onChange: (event) => setKeyDraft((previous) => ({ ...previous, [entry.ref]: event.target.value })),
742
+ key: 'i', type: 'password', autoComplete: 'off', spellCheck: false, style: S.input,
743
+ value: asString(keyDraft[entry.ref]), placeholder: t(configured ? 'keyPlaceholderSet' : 'keyPlaceholderEmpty'),
744
+ disabled: disabled || !props.credentials || !rowWritable,
745
+ onChange: (e) => setKeyDraft((p) => ({ ...p, [entry.ref]: e.target.value })),
1019
746
  }),
1020
747
  h('div', { key: 'a', style: S.actions }, [
1021
748
  h('label', { key: 'f', style: S.check }, [
1022
- h('input', {
1023
- key: 'i',
1024
- type: 'checkbox',
1025
- checked: forwarded,
1026
- disabled,
1027
- onChange: (event) => setForward(entry.ref, event.target.checked),
1028
- }),
749
+ h('input', { key: 'i', type: 'checkbox', checked: asArray(value.keyRefs).includes(entry.ref), disabled, onChange: (e) => setForward(entry.ref, e.target.checked) }),
1029
750
  h('span', { key: 't' }, t('forward')),
1030
751
  ]),
1031
752
  h('span', { key: 'sp', style: { flex: 1 } }),
1032
- h('button', {
1033
- key: 's',
1034
- type: 'button',
1035
- style: S.btn,
1036
- disabled: disabled || !writable || keyBusy === entry.ref || asString(keyDraft[entry.ref]).trim() === '',
1037
- onClick: () => { void saveKey(entry.ref); },
1038
- }, keyBusy === entry.ref ? t('saving') : t('saveKey')),
1039
- configured ? h('button', {
1040
- key: 'c',
1041
- type: 'button',
1042
- style: S.btn,
1043
- disabled: disabled || !writable || keyBusy === entry.ref,
1044
- onClick: () => { void clearKey(entry.ref); },
1045
- }, t('clearKey')) : null,
753
+ h('button', { key: 's', type: 'button', style: S.btn, disabled: disabled || !rowWritable || keyBusy === entry.ref || asString(keyDraft[entry.ref]).trim() === '', onClick: () => { void saveKey(entry.ref); } }, t(keyBusy === entry.ref ? 'saving' : 'saveKey')),
754
+ configured ? h('button', { key: 'c', type: 'button', style: S.btn, disabled: disabled || !rowWritable || keyBusy === entry.ref, onClick: () => { void clearKey(entry.ref); } }, t('clearKey')) : null,
1046
755
  ]),
1047
756
  ]),
1048
757
  ]);
1049
758
  };
1050
759
 
1051
- const commonKeys = KEYS.filter((entry) => entry.common);
1052
- const visibleKeys = showAllKeys ? KEYS : commonKeys;
1053
-
1054
760
  const panel = [];
1055
-
1056
761
  if (tab === 'dashboard') {
1057
- const configuredKeyCount = Object.values(credentials).filter((c) => c && c.configured).length;
1058
- const keylessEngineCount = CORE_ENGINES.filter((e) => e.keyless).length;
1059
- const seamSearchOn = value.searchProviderEnabled !== false;
1060
- const seamFetchOn = value.fetchProviderEnabled !== false;
1061
- const activeToolCount = asArray(value.nativeTools).length;
1062
- const poolConcurrency = asNumber(value.searchConcurrency, DEFAULTS.searchConcurrency);
1063
- const poolIdleMs = asNumber(value.searchIdleMs, DEFAULTS.searchIdleMs);
1064
-
1065
- panel.push(h('div', { key: 'metrics', style: S.metricGrid }, [
1066
- h('div', { key: 'pool', style: S.metricCard }, [
1067
- h('span', { key: 'l', style: S.metricLabel }, t('poolTitle')),
1068
- h('div', { key: 'v', style: { display: 'flex', alignItems: 'center', gap: 6 } }, [
1069
- h('span', { key: 'dot', style: S.dot(poolConcurrency > 0) }),
1070
- h('span', { key: 'val', style: S.metricValue }, `${poolConcurrency} 并发`),
1071
- ]),
1072
- h('span', { key: 's', style: S.metricSub }, `${t('poolStatusHealthy')} · 空闲回收 ${poolIdleMs / 1000}s`),
1073
- ]),
1074
- h('div', { key: 'seam', style: S.metricCard }, [
1075
- h('span', { key: 'l', style: S.metricLabel }, t('accessTitle')),
1076
- h('span', { key: 'val', style: S.metricValue }, seamSearchOn && seamFetchOn ? '双路接管' : (seamSearchOn || seamFetchOn ? '单路接管' : '未接管')),
1077
- h('span', { key: 's', style: S.metricSub }, `Search: ${seamSearchOn ? 'ON' : 'OFF'} · Fetch: ${seamFetchOn ? 'ON' : 'OFF'}`),
1078
- ]),
1079
- h('div', { key: 'tools', style: S.metricCard }, [
1080
- h('span', { key: 'l', style: S.metricLabel }, t('toolsTitle')),
1081
- h('span', { key: 'val', style: S.metricValue }, `${activeToolCount} / ${TOOLS.length}`),
1082
- h('span', { key: 's', style: S.metricSub }, '已就绪原生 MCP 工具'),
1083
- ]),
1084
- h('div', { key: 'keys', style: S.metricCard }, [
1085
- h('span', { key: 'l', style: S.metricLabel }, t('keysTitle')),
1086
- h('span', { key: 'val', style: S.metricValue }, `${configuredKeyCount} 配置 · ${keylessEngineCount} 免密`),
1087
- h('span', { key: 's', style: S.metricSub }, '覆盖全局多源引擎'),
1088
- ]),
1089
- ]));
1090
-
1091
- // 路由观测卡:宿主经 remote 事件推送 routeHealth 时展示最近路由决策;
1092
- // 未推送时给出终端命令提示——不让面板空白,也不假装有数据。
762
+ const configuredKeys = Object.values(credentials).filter((c) => c && c.configured).length;
763
+ const searchOn = value.searchProviderEnabled !== false;
764
+ const fetchOn = value.fetchProviderEnabled !== false;
765
+ const poolConc = asNumber(value.searchConcurrency, DEFAULTS.searchConcurrency);
766
+ const metrics = [
767
+ { k: 'pool', label: t('poolTitle'), val: `${poolConc} 并发`, dot: poolConc > 0, sub: `${t('poolStatusHealthy')} · 空闲回收 ${asNumber(value.searchIdleMs, DEFAULTS.searchIdleMs) / 1000}s` },
768
+ { k: 'seam', label: t('accessTitle'), val: searchOn && fetchOn ? '双路接管' : (searchOn || fetchOn ? '单路接管' : '未接管'), sub: `Search: ${searchOn ? 'ON' : 'OFF'} · Fetch: ${fetchOn ? 'ON' : 'OFF'}` },
769
+ { k: 'tools', label: t('toolsTitle'), val: `${asArray(value.nativeTools).length} / ${TOOLS.length}`, sub: '已就绪原生 MCP 工具' },
770
+ { k: 'keys', label: t('keysTitle'), val: `${configuredKeys} 配置 · ${CORE_ENGINES.filter((e) => e.keyless).length} 免密`, sub: '覆盖全局多源引擎' },
771
+ ];
772
+ panel.push(h('div', { key: 'metrics', style: S.metricGrid }, metrics.map((m) => h('div', { key: m.k, style: S.metricCard }, [
773
+ h('span', { key: 'l', style: S.metricLabel }, m.label),
774
+ m.dot !== undefined
775
+ ? h('div', { key: 'v', style: { display: 'flex', alignItems: 'center', gap: 6 } }, [h('span', { key: 'd', style: S.dot(m.dot) }), h('span', { key: 'val', style: S.metricValue }, m.val)])
776
+ : h('span', { key: 'val', style: S.metricValue }, m.val),
777
+ h('span', { key: 's', style: S.metricSub }, m.sub),
778
+ ]))));
779
+ const rhSummary = routeHealth && routeHealth.summary;
780
+ const topLangs = rhSummary && rhSummary.langCounts
781
+ ? Object.entries(rhSummary.langCounts).sort((a, b) => b[1] - a[1]).slice(0, 3).map(([k, n]) => `${k}:${n}`).join(' · ')
782
+ : '';
783
+ const topDomains = rhSummary && Array.isArray(rhSummary.topDomains)
784
+ ? rhSummary.topDomains.slice(0, 3).map((d) => `${d.name}:${d.count}`).join(' · ')
785
+ : '';
1093
786
  panel.push(h(Card, { key: 'route', title: t('routeHealthTitle'), hint: t('routeHealthHint') }, [
1094
787
  routeHealth && Array.isArray(routeHealth.samples) && routeHealth.samples.length > 0
1095
- ? h('div', { key: 'rows', style: { display: 'flex', flexDirection: 'column', gap: 6 } },
1096
- routeHealth.samples.slice(0, 5).map((row, i) =>
1097
- h('div', { key: 'r' + i, style: S.keyRow }, [
1098
- h('span', { key: 'q', style: S.label }, String(row.query || '').slice(0, 40)),
1099
- h('span', { key: 'd', style: S.sub }, `${row.domain || '-'} · ${row.engine || '-'}`),
1100
- ])))
788
+ ? h('div', { key: 'rows', style: col(6) }, [
789
+ rhSummary ? h('div', { key: 'sum', style: S.sub }, `${rhSummary.total} 条 · 兜底 ${Math.round((rhSummary.fallbackRate || 0) * 100)}%${topLangs ? ' · ' + topLangs : ''}`) : null,
790
+ topDomains ? h('div', { key: 'doms', style: S.sub }, `高频域:${topDomains}`) : null,
791
+ ...routeHealth.samples.slice(-5).reverse().map((r, i) => {
792
+ const langTag = r.effective_lang || r.primary_lang || '-';
793
+ const intentTag = Array.isArray(r.intents) && r.intents.length > 0 ? ` · ${r.intents.join(',')}` : '';
794
+ const confTag = r.confidence !== '' && r.confidence !== undefined ? ` (${r.confidence})` : '';
795
+ return h('div', { key: 'r' + i, style: S.keyRow }, [
796
+ h('span', { key: 'q', style: S.label }, `${r.domain || 'fallback'} · ${langTag}${intentTag}`),
797
+ h('span', { key: 'd', style: S.sub }, `${r.engine || '-'}${confTag}`),
798
+ ]);
799
+ }),
800
+ ])
1101
801
  : h('p', { key: 'hint', style: S.hint }, t('routeHealthFallback')),
1102
802
  ]));
1103
-
1104
803
  panel.push(h(Card, { key: 'presets', title: t('presetTitle'), hint: t('presetHint') }, [
1105
- h('div', { key: 'grid', style: S.presetGrid }, [
1106
- h('div', {
1107
- key: 'fast',
1108
- style: S.presetCard(false),
1109
- onClick: () => { void applyPreset('fast'); },
1110
- }, [
1111
- h('div', { key: 't', style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' } }, [
1112
- h('span', { key: 'title', style: S.label }, t('presetFast')),
1113
- h('span', { key: 'badge', style: S.badge('blue') }, '15s 超时'),
1114
- ]),
1115
- h('span', { key: 'd', style: S.sub }, t('presetFastDesc')),
1116
- ]),
1117
- h('div', {
1118
- key: 'standard',
1119
- style: S.presetCard(true),
1120
- onClick: () => { void applyPreset('standard'); },
1121
- }, [
1122
- h('div', { key: 't', style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' } }, [
1123
- h('span', { key: 'title', style: S.label }, t('presetStandard')),
1124
- h('span', { key: 'badge', style: S.badge('green') }, '标准生产'),
1125
- ]),
1126
- h('span', { key: 'd', style: S.sub }, t('presetStandardDesc')),
1127
- ]),
1128
- h('div', {
1129
- key: 'deep',
1130
- style: S.presetCard(false),
1131
- onClick: () => { void applyPreset('deep'); },
1132
- }, [
1133
- h('div', { key: 't', style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' } }, [
1134
- h('span', { key: 'title', style: S.label }, t('presetDeep')),
1135
- h('span', { key: 'badge', style: S.badge('blue') }, '深度核验'),
1136
- ]),
1137
- h('span', { key: 'd', style: S.sub }, t('presetDeepDesc')),
1138
- ]),
1139
- ]),
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
+ ]))),
1140
808
  ]));
1141
-
1142
809
  panel.push(h(Card, { key: 'matrix', title: t('matrixTitle'), hint: t('matrixHint') }, [
1143
810
  h('div', { key: 'grid', style: S.matrixGrid }, CORE_ENGINES.map((engine) => {
1144
811
  const hasKey = engine.ref && credentials[engine.ref] && credentials[engine.ref].configured;
1145
- const badgeType = hasKey ? 'green' : (engine.keyless ? 'blue' : 'gray');
1146
- const badgeText = hasKey ? t('matrixConfigured') : (engine.keyless ? t('matrixKeyless') : t('matrixPending'));
1147
812
  return h('div', { key: engine.id, style: S.matrixCard }, [
1148
- h('div', { key: 'h', style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 6 } }, [
813
+ h('div', { key: 'h', style: rowBetween(6) }, [
1149
814
  h('span', { key: 'n', style: S.label }, lang === 'en' ? engine.nameEn : engine.nameZh),
1150
- h('span', { key: 'b', style: S.badge(badgeType) }, badgeText),
815
+ h('span', { key: 'b', style: S.badge(hasKey ? 'green' : (engine.keyless ? 'blue' : 'gray')) }, t(hasKey ? 'matrixConfigured' : (engine.keyless ? 'matrixKeyless' : 'matrixPending'))),
1151
816
  ]),
1152
817
  h('span', { key: 'r', style: S.sub }, lang === 'en' ? engine.roleEn : engine.roleZh),
1153
818
  ]);
@@ -1157,337 +822,105 @@ window.__ModuleLoader__.load({
1157
822
 
1158
823
  if (tab === 'access') {
1159
824
  panel.push(h(Card, { key: 'seam', title: t('accessTitle') }, [
1160
- h(Switch, {
1161
- key: 's',
1162
- checked: value.searchProviderEnabled !== false,
1163
- disabled,
1164
- label: t('searchSeam'),
1165
- hint: t('searchSeamHint'),
1166
- onChange: (next) => { void setField('searchProviderEnabled', next); },
1167
- }),
1168
- h(Switch, {
1169
- key: 'f',
1170
- checked: value.fetchProviderEnabled !== false,
1171
- disabled,
1172
- label: t('fetchSeam'),
1173
- hint: t('fetchSeamHint'),
1174
- onChange: (next) => { void setField('fetchProviderEnabled', next); },
1175
- }),
1176
- ]));
1177
- panel.push(h(Card, { key: 'entry', title: t('entryTitle'), hint: t('entryHint') }, [
1178
- h(Field, { key: 'c', label: t('command') }, h('input', {
1179
- type: 'text',
1180
- style: { ...S.input, ...S.mono },
1181
- value: draft.command,
1182
- disabled,
1183
- spellCheck: false,
1184
- onChange: (event) => edit('command', event.target.value),
1185
- })),
1186
- h(Field, { key: 'a', label: t('args') }, h('textarea', {
1187
- style: { ...S.input, ...S.textarea, ...S.mono },
1188
- value: draft.argsText,
1189
- disabled,
1190
- spellCheck: false,
1191
- onChange: (event) => edit('argsText', event.target.value),
1192
- })),
1193
- h('div', { key: 'g', style: S.grid }, [
1194
- h(NumberField, {
1195
- key: 'st', label: t('searchTimeout'), min: 1000, value: draft.searchTimeoutMs, disabled,
1196
- onChange: (next) => edit('searchTimeoutMs', next),
1197
- }),
1198
- h(NumberField, {
1199
- key: 'ft', label: t('fetchTimeout'), min: 1000, value: draft.fetchTimeoutMs, disabled,
1200
- onChange: (next) => edit('fetchTimeoutMs', next),
1201
- }),
1202
- h(NumberField, {
1203
- key: 'fc', label: t('fetchChars'), min: 500, step: 500, value: draft.fetchMaxChars, disabled,
1204
- onChange: (next) => edit('fetchMaxChars', next),
1205
- }),
1206
- h(NumberField, {
1207
- key: 'id', label: t('idle'), min: 0, step: 1000, value: draft.searchIdleMs, disabled,
1208
- onChange: (next) => edit('searchIdleMs', next),
1209
- }),
1210
- h(NumberField, {
1211
- key: 'cc', label: t('concurrency'), min: 1, value: draft.searchConcurrency, disabled,
1212
- onChange: (next) => edit('searchConcurrency', next),
1213
- }),
1214
- ]),
1215
- h('div', { key: 'a2', style: S.actions }, [
1216
- h(PrimaryButton, { primary: true, disabled: disabled || busy === 'save', onClick: () => { void saveAccess(); } },
1217
- busy === 'save' ? t('saving') : t('save')),
1218
- ]),
825
+ h(Switch, { key: 's', checked: value.searchProviderEnabled !== false, disabled, label: t('searchSeam'), hint: t('searchSeamHint'), onChange: (n) => { void setField('searchProviderEnabled', n); } }),
826
+ h(Switch, { key: 'f', checked: value.fetchProviderEnabled !== false, disabled, label: t('fetchSeam'), hint: t('fetchSeamHint'), onChange: (n) => { void setField('fetchProviderEnabled', n); } }),
1219
827
  ]));
828
+ panel.push(h(Card, { key: 'entry', title: t('entryTitle'), hint: t('entryHint') }, [...renderGroup('access'), saveBtn('access')]));
1220
829
  }
1221
830
 
1222
831
  if (tab === 'tools') {
1223
832
  panel.push(h(Card, { key: 'presets', title: t('toolPresetTitle'), hint: t('toolPresetHint') }, [
1224
- h('div', { key: 'grid', style: S.presetGrid }, TOOL_PRESETS.map((preset) =>
1225
- h('button', {
1226
- key: preset.id, type: 'button', disabled,
1227
- style: S.presetCard(false),
1228
- onClick: () => { void applyToolPreset(preset.tools); },
1229
- }, [
1230
- h('div', { key: 't', style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' } }, [
1231
- h('span', { key: 'title', style: S.label }, lang === 'en' ? preset.en : preset.zh),
1232
- h('span', { key: 'badge', style: S.badge('blue') }, String(preset.tools.length) + ' 工具'),
1233
- ]),
1234
- h('span', { key: 'd', style: S.sub }, lang === 'en' ? preset.descEn : preset.descZh),
833
+ h('div', { key: 'grid', style: S.presetGrid }, TOOL_PRESETS.map((pr) =>
834
+ h('button', { key: pr.id, type: 'button', disabled, style: S.presetCard(false), onClick: () => { void applyToolPreset(pr.tools); } }, [
835
+ h('div', { key: 't', style: rowBetween() }, [h('span', { key: 'title', style: S.label }, lang === 'en' ? pr.en : pr.zh), h('span', { key: 'badge', style: S.badge('blue') }, `${pr.tools.length} 工具`)]),
836
+ h('span', { key: 'd', style: S.sub }, lang === 'en' ? pr.descEn : pr.descZh),
1235
837
  ]))),
1236
838
  ]));
1237
839
  panel.push(h(Card, { key: 'tools', title: t('toolsTitle'), hint: t('toolsHint') }, [
1238
840
  ...TOOL_GROUPS.map((grp, gi) => [
1239
841
  gi > 0 ? h('div', { key: 'div' + gi, style: S.divider }) : null,
1240
- h('div', { key: grp.id, style: { display: 'flex', flexDirection: 'column', gap: 4 } }, [
842
+ h('div', { key: grp.id, style: col(4) }, [
1241
843
  h('span', { key: 'l', style: S.label }, lang === 'en' ? grp.en : grp.zh),
1242
- h('div', { key: 'g', style: S.toolGrid }, toolsByGroup(grp.id).map(toolCheckbox)),
844
+ h('div', { key: 'g', style: S.toolGrid }, TOOLS.filter((tl) => tl.group === grp.id).map((tl) => h('label', { key: tl.id, style: S.check }, [
845
+ h('input', { key: 'i', type: 'checkbox', checked: asArray(value.nativeTools).includes(tl.id), disabled, onChange: () => toggleTool(tl.id) }),
846
+ h('span', { key: 't' }, [h('span', { key: 'n', style: S.mono }, tl.id), h('span', { key: 'd', style: S.sub }, ' ' + (lang === 'en' ? tl.en : tl.zh))]),
847
+ ]))),
1243
848
  ]),
1244
849
  ]),
1245
- h('div', { key: 'g2', style: S.grid }, [
1246
- h(NumberField, {
1247
- key: 'nt', label: t('nativeTimeout'), min: 1000, value: draft.nativeTimeoutMs, disabled,
1248
- onChange: (next) => edit('nativeTimeoutMs', next),
1249
- }),
1250
- h(NumberField, {
1251
- key: 'nc', label: t('nativeChars'), min: 500, step: 500, value: draft.nativeMaxChars, disabled,
1252
- onChange: (next) => edit('nativeMaxChars', next),
1253
- }),
1254
- ]),
1255
- h('div', { key: 'a', style: S.actions }, [
1256
- h(PrimaryButton, { primary: true, disabled: disabled || busy === 'save', onClick: () => { void saveTools(); } },
1257
- busy === 'save' ? t('saving') : t('save')),
1258
- ]),
850
+ ...renderGroup('tools'),
851
+ saveBtn('tools'),
1259
852
  ]));
1260
853
  }
1261
854
 
1262
855
  if (tab === 'engines') {
1263
856
  const map = envMap();
1264
- // 渲染顺序即面板顺序。**不是**从 ENGINE_TOGGLES 去重推导——那样分组
1265
- // 顺序会随白名单增删而漂移,用户每次升级都看到重排的面板。
1266
- //
1267
- // 历史 bug(2026-10-21 定位):`paid` 一度不在这个清单里,于是
1268
- // ARGO_PAID_SEARCH 与 ARGO_BUDGET_DEEPSEEK_SEARCH 两条开关在
1269
- // specs.js 白名单、client.js ENGINE_TOGGLES、双语文案三处都齐全,
1270
- // 却在面板上完全不显示——用户配好了预算却找不到入口,还以为是插件
1271
- // 没装。漂移门禁只核对「两边名单同集合、字段一致」,核对不到「这个
1272
- // 分组到底渲不渲染」;已由 test/client.test.js 的「engines tab renders
1273
- // a control for every ENGINE_TOGGLES switch」补上(见该测试注释)。
857
+ // 固定分组顺序防白名单增删导致面板乱序(test/client.test.js 校验每个开关都有控件)
1274
858
  const groups = ['cache', 'fetch', 'semantic', 'engines', 'net', 'local', 'paid', 'misc'];
1275
- const groupTitle = (group) => t('group' + group.charAt(0).toUpperCase() + group.slice(1));
859
+ const groupTitle = (g) => t('group' + g.charAt(0).toUpperCase() + g.slice(1));
1276
860
  panel.push(h('p', { key: 'hint', style: S.hint }, t('enginesHint')));
1277
- panel.push(h('input', {
1278
- key: 'filter',
1279
- type: 'text',
1280
- style: S.filterInput,
1281
- placeholder: t('searchFilterPlaceholder'),
1282
- value: engineFilter,
1283
- onChange: (event) => setEngineFilter(event.target.value),
1284
- }));
861
+ panel.push(h('input', { key: 'filter', type: 'text', style: S.filterInput, placeholder: t('searchFilterPlaceholder'), value: engineFilter, onChange: (e) => setEngineFilter(e.target.value) }));
1285
862
  const query = engineFilter.trim().toLowerCase();
1286
863
  for (const group of groups) {
1287
- let specs = ENGINE_TOGGLES.filter((spec) => spec.group === group);
1288
- if (query) {
1289
- const groupNameMatch = group.toLowerCase().includes(query) || groupTitle(group).toLowerCase().includes(query);
1290
- if (!groupNameMatch) {
1291
- specs = specs.filter((spec) => {
1292
- const name = spec.name.toLowerCase();
1293
- const zh = (spec.zh || '').toLowerCase();
1294
- const en = (spec.en || '').toLowerCase();
1295
- const hintZh = (spec.hintZh || '').toLowerCase();
1296
- const hintEn = (spec.hintEn || '').toLowerCase();
1297
- return name.includes(query) || zh.includes(query) || en.includes(query) || hintZh.includes(query) || hintEn.includes(query);
1298
- });
1299
- }
1300
- }
1301
- if (specs.length === 0) continue;
1302
- const bools = specs.filter((spec) => spec.kind === 'bool');
1303
- const fields = specs.filter((spec) => spec.kind !== 'bool');
1304
- const children = [];
1305
- if (group === 'paid') {
1306
- children.push(h('p', { key: 'groupHint', style: S.hint }, t('groupPaidHint')));
864
+ let specs = ENGINE_TOGGLES.filter((s) => s.group === group);
865
+ if (query && !group.toLowerCase().includes(query) && !groupTitle(group).toLowerCase().includes(query)) {
866
+ specs = specs.filter((s) => [s.name, s.zh, s.en, s.hintZh, s.hintEn].some((v) => (v || '').toLowerCase().includes(query)));
1307
867
  }
868
+ if (!specs.length) continue;
869
+ const bools = specs.filter((s) => s.kind === 'bool');
870
+ const fields = specs.filter((s) => s.kind !== 'bool');
871
+ const children = group === 'paid' ? [h('p', { key: 'groupHint', style: S.hint }, t('groupPaidHint'))] : [];
1308
872
  for (const spec of bools) {
1309
- // 未配置时显示 argo 默认态并标注「默认」,配置过的显示自定义值,
1310
- // 让「这一行到底生不生效」在面板上一眼可辨。
1311
- const custom = map[spec.name] !== undefined;
1312
- const suffix = custom ? '' : (lang === 'en' ? ` (${t('envDefault')})` : `(${t('envDefault')})`);
1313
- children.push(h(Switch, {
1314
- key: spec.name,
1315
- checked: envBoolState(spec, map),
1316
- disabled,
1317
- label: (lang === 'en' ? spec.en : spec.zh) + suffix,
1318
- hint: lang === 'en' ? spec.hintEn : spec.hintZh,
1319
- onChange: (next) => toggleEnv(spec, next),
1320
- }));
873
+ const suffix = map[spec.name] !== undefined ? '' : (lang === 'en' ? ` (${t('envDefault')})` : `(${t('envDefault')})`);
874
+ children.push(h(Switch, { key: spec.name, checked: envBoolState(spec, map), disabled, label: (lang === 'en' ? spec.en : spec.zh) + suffix, hint: lang === 'en' ? spec.hintEn : spec.hintZh, onChange: (next) => toggleEnv(spec, next) }));
1321
875
  }
1322
- if (fields.length > 0) {
1323
- const fieldNodes = fields.map((spec) => {
1324
- const drafted = envDraft[spec.name];
1325
- const current = drafted !== undefined
1326
- ? drafted
1327
- : (map[spec.name] !== undefined ? map[spec.name] : (spec.kind === 'num' ? String(spec.def) : ''));
1328
- const control = spec.kind === 'num'
1329
- ? h('input', {
1330
- key: 'i',
1331
- type: 'number',
1332
- style: S.input,
1333
- value: current,
1334
- min: spec.min,
1335
- max: spec.max,
1336
- step: spec.step ?? 1,
1337
- disabled,
1338
- onChange: (event) => setEnvDraft((previous) => ({ ...previous, [spec.name]: event.target.value })),
1339
- })
1340
- : h('input', {
1341
- key: 'i',
1342
- type: 'text',
1343
- style: { ...S.input, ...S.mono },
1344
- value: current,
1345
- disabled,
1346
- spellCheck: false,
1347
- onChange: (event) => setEnvDraft((previous) => ({ ...previous, [spec.name]: event.target.value })),
1348
- });
1349
- return h(Field, {
1350
- key: spec.name,
1351
- label: lang === 'en' ? spec.en : spec.zh,
1352
- hint: lang === 'en' ? spec.hintEn : spec.hintZh,
1353
- }, control);
1354
- });
1355
- children.push(h('div', { key: 'fields', style: S.grid }, fieldNodes));
1356
- children.push(h('div', { key: 'save', style: S.actions }, [
1357
- h(PrimaryButton, {
1358
- key: 'b',
1359
- primary: true,
1360
- disabled: disabled || envBusy === group,
1361
- onClick: () => { void saveEnvGroup(group); },
1362
- }, envBusy === group ? t('saving') : t('save')),
1363
- ]));
876
+ if (fields.length) {
877
+ children.push(h('div', { key: 'fields', style: S.grid }, fields.map((spec) => {
878
+ const cur = envDraft[spec.name] !== undefined ? envDraft[spec.name] : (map[spec.name] !== undefined ? map[spec.name] : (spec.kind === 'num' ? String(spec.def) : ''));
879
+ const isNum = spec.kind === 'num';
880
+ return h(Field, { key: spec.name, label: lang === 'en' ? spec.en : spec.zh, hint: lang === 'en' ? spec.hintEn : spec.hintZh }, h('input', {
881
+ key: 'i', type: isNum ? 'number' : 'text', style: isNum ? S.input : { ...S.input, ...S.mono },
882
+ value: cur, min: isNum ? spec.min : undefined, max: isNum ? spec.max : undefined, step: isNum ? (spec.step ?? 1) : undefined,
883
+ disabled, spellCheck: isNum ? undefined : false, onChange: (e) => setEnvDraft((p) => ({ ...p, [spec.name]: e.target.value })),
884
+ }));
885
+ })));
886
+ children.push(h('div', { key: 'save', style: S.actions }, [h(PrimaryButton, { key: 'b', primary: true, disabled: disabled || envBusy === group, onClick: () => { void saveEnvGroup(group); } }, t(envBusy === group ? 'saving' : 'save'))]));
1364
887
  }
1365
888
  panel.push(h(Card, { key: group, title: groupTitle(group) }, children));
1366
889
  }
1367
890
  }
1368
891
 
1369
892
  if (tab === 'keys') {
1370
- const query = keyFilter.trim().toLowerCase();
1371
- const displayKeys = query
1372
- ? KEYS.filter((entry) => entry.ref.toLowerCase().includes(query) || entry.label.toLowerCase().includes(query) || (entry.en && entry.en.toLowerCase().includes(query)) || entry.engines.some((id) => id.includes(query)))
1373
- : visibleKeys;
893
+ const q = keyFilter.trim().toLowerCase();
894
+ const list = q
895
+ ? KEYS.filter((e) => [e.ref, e.label, e.en, ...e.engines].some((v) => (v || '').toLowerCase().includes(q)))
896
+ : (showAllKeys ? KEYS : KEYS.filter((e) => e.common));
1374
897
  panel.push(h(Card, { key: 'keys', title: t('keysTitle'), hint: t('keysHint') }, [
1375
- h('input', {
1376
- key: 'filter',
1377
- type: 'text',
1378
- style: S.filterInput,
1379
- placeholder: t('searchFilterPlaceholder'),
1380
- value: keyFilter,
1381
- onChange: (event) => setKeyFilter(event.target.value),
1382
- }),
1383
- h('span', { key: 'l', style: S.label }, query ? t('keysTitle') : t('commonKeys')),
1384
- ...displayKeys.map(keyRow),
1385
- query ? null : h('div', { key: 'a', style: S.actions }, [
1386
- h('button', {
1387
- key: 'more',
1388
- type: 'button',
1389
- style: S.btn,
1390
- onClick: () => setShowAllKeys((previous) => !previous),
1391
- }, showAllKeys ? t('showLess') : t('showMore')),
898
+ h('input', { key: 'filter', type: 'text', style: S.filterInput, placeholder: t('searchFilterPlaceholder'), value: keyFilter, onChange: (e) => setKeyFilter(e.target.value) }),
899
+ h('span', { key: 'l', style: S.label }, t(q ? 'keysTitle' : 'commonKeys')),
900
+ ...list.map(keyRow),
901
+ q ? null : h('div', { key: 'a', style: S.actions }, [
902
+ h('button', { key: 'more', type: 'button', style: S.btn, onClick: () => setShowAllKeys((p) => !p) }, t(showAllKeys ? 'showLess' : 'showMore')),
1392
903
  props.credentials ? null : h('span', { key: 'u', style: S.sub }, t('keyUnavailable')),
1393
904
  ]),
1394
905
  ]));
1395
906
  }
1396
907
 
1397
- if (tab === 'research') {
1398
- panel.push(h(Card, { key: 'research', title: t('researchTitle') }, [
1399
- h('div', { key: 'g', style: S.grid }, [
1400
- h(NumberField, {
1401
- key: 'dw', label: t('workers'), min: 1, value: draft.defaultWorkers, disabled,
1402
- onChange: (next) => edit('defaultWorkers', next),
1403
- }),
1404
- h(NumberField, {
1405
- key: 'mw', label: t('maxWorkers'), min: 1, value: draft.maxWorkers, disabled,
1406
- onChange: (next) => edit('maxWorkers', next),
1407
- }),
1408
- h(NumberField, {
1409
- key: 'mt', label: t('tracks'), min: 2, value: draft.maxTracks, disabled,
1410
- onChange: (next) => edit('maxTracks', next),
1411
- }),
1412
- h(NumberField, {
1413
- key: 'ms', label: t('sources'), min: 1, value: draft.maxSourcesPerTrack, disabled,
1414
- onChange: (next) => edit('maxSourcesPerTrack', next),
1415
- }),
1416
- h(NumberField, {
1417
- key: 'wt', label: t('workerTokens'), min: 512, step: 512, value: draft.workerMaxTokens, disabled,
1418
- onChange: (next) => edit('workerMaxTokens', next),
1419
- }),
1420
- h(NumberField, {
1421
- key: 'st', label: t('synthTokens'), min: 512, step: 512, value: draft.synthesisMaxTokens, disabled,
1422
- onChange: (next) => edit('synthesisMaxTokens', next),
1423
- }),
1424
- ]),
1425
- h(Field, { key: 'd', label: t('reportDir') }, h('input', {
1426
- type: 'text',
1427
- style: { ...S.input, ...S.mono },
1428
- value: draft.reportDir,
1429
- disabled,
1430
- spellCheck: false,
1431
- onChange: (event) => edit('reportDir', event.target.value),
1432
- })),
1433
- h('div', { key: 'a', style: S.actions }, [
1434
- h(PrimaryButton, { primary: true, disabled: disabled || busy === 'save', onClick: () => { void saveResearch(); } },
1435
- busy === 'save' ? t('saving') : t('save')),
1436
- ]),
1437
- ]));
1438
- }
1439
-
1440
- if (tab === 'advanced') {
1441
- panel.push(h(Card, { key: 'adv', title: t('advancedTitle') }, [
1442
- h(Field, { key: 'allow', label: t('allow'), hint: t('allowHint') }, h('textarea', {
1443
- style: { ...S.input, ...S.textarea, ...S.mono },
1444
- value: draft.allowText,
1445
- disabled,
1446
- spellCheck: false,
1447
- onChange: (event) => edit('allowText', event.target.value),
1448
- })),
1449
- h(Field, { key: 'deny', label: t('deny') }, h('textarea', {
1450
- style: { ...S.input, ...S.textarea, ...S.mono },
1451
- value: draft.denyText,
1452
- disabled,
1453
- spellCheck: false,
1454
- onChange: (event) => edit('denyText', event.target.value),
1455
- })),
1456
- h(Field, { key: 'refs', label: t('keyRefs'), hint: t('keyRefsHint') }, h('textarea', {
1457
- style: { ...S.input, ...S.textarea, ...S.mono },
1458
- value: draft.keyRefsText,
1459
- disabled,
1460
- spellCheck: false,
1461
- onChange: (event) => edit('keyRefsText', event.target.value),
1462
- })),
1463
- h('div', { key: 'a', style: S.actions }, [
1464
- h(PrimaryButton, { primary: true, disabled: disabled || busy === 'save', onClick: () => { void saveAdvanced(); } },
1465
- busy === 'save' ? t('saving') : t('save')),
1466
- ]),
1467
- h('div', { key: 'div', style: S.divider }),
1468
- h('div', { key: 'struct', style: { display: 'flex', flexDirection: 'column', gap: 4 } }, [
1469
- h('span', { key: 'l', style: S.label }, t('structural')),
1470
- h('span', { key: 'h', style: S.sub }, t('structuralHint')),
1471
- h('span', { key: 'm', style: S.sub }, t('mcpHint')),
1472
- ]),
1473
- ]));
1474
- }
908
+ if (tab === 'research') panel.push(h(Card, { key: 'research', title: t('researchTitle') }, [...renderGroup('research'), saveBtn('research')]));
909
+ if (tab === 'advanced') panel.push(h(Card, { key: 'adv', title: t('advancedTitle') }, [
910
+ ...renderGroup('advanced'), saveBtn('advanced'), h('div', { key: 'div', style: S.divider }),
911
+ h('div', { key: 'struct', style: col(4) }, [h('span', { key: 'l', style: S.label }, t('structural')), h('span', { key: 'h', style: S.sub }, t('structuralHint')), h('span', { key: 'm', style: S.sub }, t('mcpHint'))]),
912
+ ]));
1475
913
 
914
+ const tabs = [['dashboard', 'tabDashboard'], ['access', 'tabAccess'], ['tools', 'tabTools'], ['engines', 'tabEngines'], ['keys', 'tabKeys'], ['research', 'tabResearch'], ['advanced', 'tabAdvanced']];
1476
915
  return h('div', { style: S.wrap }, [
1477
- h('div', { key: 'head', style: { display: 'flex', flexDirection: 'column', gap: 4 } }, [
916
+ h('div', { key: 'head', style: col(4) }, [
1478
917
  h('h2', { key: 't', style: S.title }, t('title')),
1479
918
  h('p', { key: 'i', style: S.hint }, t('intro')),
1480
919
  ]),
1481
- h('div', { key: 'tabs', style: S.tabs }, [
1482
- tabButton('dashboard', t('tabDashboard')),
1483
- tabButton('access', t('tabAccess')),
1484
- tabButton('tools', t('tabTools')),
1485
- tabButton('engines', t('tabEngines')),
1486
- tabButton('keys', t('tabKeys')),
1487
- tabButton('research', t('tabResearch')),
1488
- tabButton('advanced', t('tabAdvanced')),
1489
- ]),
1490
- statusLine,
920
+ h('div', { key: 'tabs', style: S.tabs }, tabs.map(([id, lk]) => h('button', {
921
+ key: id, type: 'button', style: S.tab(tab === id), onClick: () => setTab(id),
922
+ }, t(lk)))),
923
+ message ? h('p', { style: error ? S.error : S.notice, role: 'status' }, message) : h('p', { style: S.status }, disabled ? t('readonly') : ''),
1491
924
  ...panel,
1492
925
  ]);
1493
926
  }
@@ -1530,6 +963,17 @@ window.__ModuleLoader__.load({
1530
963
  for (const off of offs) if (typeof off === 'function') off();
1531
964
  };
1532
965
  }), 'argo-dsh: settings page');
966
+
967
+ if (typeof window !== 'undefined' && typeof document !== 'undefined' && ctx.slots) {
968
+ ctx.effect(() => {
969
+ let disposed = false;
970
+ let unmount = null;
971
+ import('/argo/workbench-client.js').then((mod) => {
972
+ if (!disposed && typeof mod?.mountArgoWorkbench === 'function') unmount = mod.mountArgoWorkbench(ctx, react);
973
+ }).catch(() => {});
974
+ return () => { disposed = true; if (typeof unmount === 'function') unmount(); };
975
+ }, 'argo-dsh: workbench');
976
+ }
1533
977
  }
1534
978
 
1535
979
  exports.apply = apply;