argo-search 2.14.1 → 2.15.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 (171) hide show
  1. package/AGENTS.md +8 -6
  2. package/README.es.md +54 -832
  3. package/README.ja.md +53 -833
  4. package/README.ko.md +53 -831
  5. package/README.md +126 -769
  6. package/README.zh.md +124 -893
  7. package/SKILL.md +17 -18
  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 +42 -0
  12. package/backends/engine_concept_vectors.json +1525 -1525
  13. package/backends/engine_registry.yaml +124 -28
  14. package/backends/quota_profiles.json +70 -0
  15. package/bin/argo +30 -17
  16. package/config.yaml +173 -33
  17. package/docs/ADDING_NEW_ENGINE.md +10 -0
  18. package/docs/ARGO_INTRO.md +1 -1
  19. package/docs/CHANGELOG.md +23 -0
  20. package/docs/ENGINE_CATALOG.md +97 -85
  21. package/docs/MCP_SETUP.md +1 -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/RELEASING.md +1 -1
  25. package/engines/specs/ai_labs.yaml +89 -0
  26. package/engines/specs/bilibili_hot.yaml +11 -1
  27. package/engines/specs/brave.yaml +3 -3
  28. package/engines/specs/cisa_alerts.yaml +40 -0
  29. package/engines/specs/cn_ai_news.yaml +10 -8
  30. package/engines/specs/digup.yaml +11 -6
  31. package/engines/specs/douyin_hot.yaml +11 -1
  32. package/engines/specs/dw_news.yaml +4 -2
  33. package/engines/specs/eng_blogs.yaml +63 -0
  34. package/engines/specs/europeana.yaml +3 -4
  35. package/engines/specs/felo.yaml +3 -3
  36. package/engines/specs/firecrawl.yaml +3 -0
  37. package/engines/specs/fourget.yaml +5 -2
  38. package/engines/specs/france24.yaml +6 -4
  39. package/engines/specs/fxtwitter.yaml +29 -6
  40. package/engines/specs/grepapp_mcp.yaml +62 -0
  41. package/engines/specs/guardian_rss.yaml +6 -4
  42. package/engines/specs/itotii.yaml +13 -1
  43. package/engines/specs/lobsters.yaml +41 -0
  44. package/engines/specs/local_seek.yaml +6 -0
  45. package/engines/specs/open_meteo.yaml +1 -1
  46. package/engines/specs/redskill.yaml +2 -0
  47. package/engines/specs/searxng.yaml +4 -2
  48. package/engines/specs/sec_edgar.yaml +8 -3
  49. package/engines/specs/tinyfish.yaml +2 -0
  50. package/engines/specs/tinyfish_news.yaml +2 -0
  51. package/engines/specs/tinyfish_paper.yaml +2 -0
  52. package/engines/specs/toutiao_hot.yaml +11 -1
  53. package/engines/specs/train.yaml +3 -0
  54. package/engines/specs/twitter.yaml +4 -0
  55. package/engines/specs/unpaywall.yaml +6 -0
  56. package/engines/specs/vam.yaml +17 -3
  57. package/engines/specs/weibo_hot.yaml +11 -1
  58. package/engines/specs/wolframalpha.yaml +3 -3
  59. package/engines/specs/xiaohongshu.yaml +2 -0
  60. package/engines/specs/zhihu.yaml +3 -18
  61. package/engines/specs/zhihu_kb.yaml +18 -0
  62. package/engines/specs/zhihu_questions.yaml +19 -0
  63. package/package.json +3 -2
  64. package/packages/dsh-plugin/README.md +9 -14
  65. package/packages/dsh-plugin/dsh/client.js +467 -1024
  66. package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
  67. package/packages/dsh-plugin/dsh/runner.js +2 -0
  68. package/packages/dsh-plugin/package.json +8 -3
  69. package/packages/dsh-plugin/scripts/sync-local.mjs +87 -0
  70. package/packages/dsh-plugin/scripts/sync-local.sh +13 -1
  71. package/packages/dsh-plugin/test/diagnostics.test.js +38 -1
  72. package/packages/dsh-plugin/test/size-gate.test.js +2 -9
  73. package/scripts/adaptive.py +7 -1
  74. package/scripts/archive_run.py +112 -53
  75. package/scripts/argo_paths.py +40 -3
  76. package/scripts/badcase_ledger.py +108 -9
  77. package/scripts/build_concept_table.py +112 -55
  78. package/scripts/cache.py +5 -1
  79. package/scripts/caliber_isolation.py +60 -23
  80. package/scripts/circuit_breaker.py +56 -8
  81. package/scripts/cli_io.py +20 -2
  82. package/scripts/config_cache.py +31 -0
  83. package/scripts/daemon.py +146 -51
  84. package/scripts/dormant_ledger.py +23 -9
  85. package/scripts/engine_dispatch.py +3 -3
  86. package/scripts/engine_env.py +182 -1
  87. package/scripts/engine_families.py +50 -7
  88. package/scripts/engine_states.py +3 -50
  89. package/scripts/engine_validate.py +13 -45
  90. package/scripts/engines.py +15 -31
  91. package/scripts/engines_base.py +42 -58
  92. package/scripts/engines_builders.py +0 -15
  93. package/scripts/engines_builders_batch10.py +346 -100
  94. package/scripts/engines_builders_batch11.py +2 -75
  95. package/scripts/engines_builders_batch9.py +15 -24
  96. package/scripts/engines_builders_cn.py +0 -194
  97. package/scripts/engines_builders_feeds.py +55 -5
  98. package/scripts/engines_builders_intl.py +15 -115
  99. package/scripts/engines_builders_pixiv.py +2 -16
  100. package/scripts/engines_builders_search.py +7 -14
  101. package/scripts/engines_builders_tech.py +5 -14
  102. package/scripts/engines_builders_weather.py +236 -0
  103. package/scripts/engines_fields.py +91 -0
  104. package/scripts/engines_http.py +135 -0
  105. package/scripts/engines_mcp.py +383 -0
  106. package/scripts/engines_parsers.py +13 -369
  107. package/scripts/engines_schema_drift.py +260 -0
  108. package/scripts/evidence.py +13 -0
  109. package/scripts/evidence_loop.py +4 -3
  110. package/scripts/fetch_jsrun.py +15 -11
  111. package/scripts/fetch_v3.py +28 -28
  112. package/scripts/fulltext_store.py +42 -1
  113. package/scripts/fxtwitter_api.py +8 -7
  114. package/scripts/gen_engine_catalog.py +2 -2
  115. package/scripts/general_pool.py +15 -4
  116. package/scripts/health_check.py +1 -1
  117. package/scripts/link_source.py +65 -24
  118. package/scripts/local_seek_adapter.py +57 -17
  119. package/scripts/mcp_handlers.py +53 -31
  120. package/scripts/mcp_handlers_surface.py +6 -18
  121. package/scripts/mcp_transport.py +1 -1
  122. package/scripts/min_version_scan.py +7 -3
  123. package/scripts/network_aware.py +7 -13
  124. package/scripts/pre-commit +45 -43
  125. package/scripts/query_understanding.py +30 -6
  126. package/scripts/quota.py +6 -1
  127. package/scripts/rank_signals.py +9 -0
  128. package/scripts/recompute.py +15 -5
  129. package/scripts/recovery.py +21 -15
  130. package/scripts/release.py +14 -26
  131. package/scripts/release_check.py +5 -25
  132. package/scripts/replay_eval.py +2 -2
  133. package/scripts/research_cli.py +40 -0
  134. package/scripts/research_notes.py +368 -0
  135. package/scripts/route.py +32 -70
  136. package/scripts/route_audit.py +259 -0
  137. package/scripts/route_combo.py +10 -4
  138. package/scripts/route_domains.py +150 -23
  139. package/scripts/route_lang.py +20 -7
  140. package/scripts/route_log.py +26 -9
  141. package/scripts/route_policy.py +85 -6
  142. package/scripts/route_telemetry_export.py +199 -0
  143. package/scripts/rrf_classic.py +5 -22
  144. package/scripts/search.py +2 -1
  145. package/scripts/search_attribution.py +33 -10
  146. package/scripts/search_entry.py +5 -1
  147. package/scripts/search_output.py +5 -4
  148. package/scripts/search_pipeline.py +12 -0
  149. package/scripts/search_rank.py +21 -11
  150. package/scripts/semantic_evidence.py +375 -168
  151. package/scripts/settings_page.py +3 -3
  152. package/scripts/social_engines/xiaohongshu_engine.py +2 -1
  153. package/scripts/social_engines/zhihu_engine.py +251 -43
  154. package/scripts/sogou_weixin_browser.py +5 -6
  155. package/scripts/source_audit.py +2 -2
  156. package/scripts/source_ledger.py +2 -15
  157. package/scripts/source_selection.py +45 -20
  158. package/scripts/straggler_policy.py +1 -2
  159. package/scripts/sync_backends.py +17 -0
  160. package/scripts/tfidf_router.py +23 -11
  161. package/scripts/time_utils.py +54 -1
  162. package/scripts/train.py +68 -2
  163. package/scripts/usage_log.py +26 -1
  164. package/sub-skills/argo-wide-research/SKILL.md +68 -0
  165. package/sub-skills/ego-search/SKILL.md +1 -1
  166. package/sub-skills/local-seek/scripts/seek_fts.py +58 -3
  167. package/scripts/caliber_dedupe.py +0 -66
  168. package/scripts/engines_builders_batch16.py +0 -13
  169. package/scripts/health_probe.py +0 -253
  170. package/scripts/social_engines/twitter_engine.py +0 -514
  171. package/scripts/sync_installs.py +0 -29
@@ -26,247 +26,126 @@ window.__ModuleLoader__.load({
26
26
  const NS = 'wide-research';
27
27
  const SECTION_ID = 'argo';
28
28
 
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
- },
29
+ // 双语字典:[zh, en] 单源表,避免两份拷贝各自漂移
30
+ const I18N = {
31
+ title: ['Argo 搜索配置', 'Argo Search Settings'],
32
+ 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.'],
33
+ loading: ['配置加载中…', 'Loading configuration…'],
34
+ unavailable: ['本插件的配置服务不可用(未挂载或只读)。', 'Configuration service unavailable (not mounted or read-only).'],
35
+ readonly: ['当前配置只读。', 'Configuration is read-only.'],
36
+ saved: ['已保存', 'Saved'],
37
+ refused: ['宿主拒绝写入(可能只读或字段不可热更新)', 'Host refused the write (read-only or not live-editable)'],
38
+ save: ['保存', 'Save'],
39
+ saving: ['保存中…', 'Saving…'],
40
+ on: ['开', 'on'],
41
+ off: ['关', 'off'],
42
+ showMore: ['显示更多', 'Show more'],
43
+ showLess: ['收起', 'Show less'],
44
+ tabAccess: ['接入', 'Access'],
45
+ tabTools: ['工具', 'Tools'],
46
+ tabKeys: ['密钥', 'Keys'],
47
+ tabResearch: ['研究', 'Research'],
48
+ tabAdvanced: ['高级', 'Advanced'],
49
+ tabDashboard: ['看板', 'Dashboard'],
50
+ tabEngines: ['引擎', 'Engines'],
51
+ dashboardTitle: ['运行监控与健康态看板', 'Runtime Monitoring & Health Dashboard'],
52
+ routeHealthTitle: ['路由观测', 'Routing telemetry'],
53
+ routeHealthHint: ['最近的路由决策与引擎状态(宿主提供时显示)。', 'Recent routing decisions and engine status (when provided by the host).'],
54
+ 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.'],
55
+ dashboardHint: ['实时监控常驻 MCP 连接池、上游搜索源拓扑与额度状态,提供一键预设与快速调优。', 'Real-time overview of the resident MCP connection pool, upstream search engine matrix, and quick workflow presets.'],
56
+ poolTitle: ['常驻 MCP 连接池监控', 'Resident MCP Pool Monitoring'],
57
+ poolStatusHealthy: ['按需连接 · 连接数不常驻', 'On demand · no resident connections'],
58
+ presetTitle: ['工作流快速预设', 'Workflow Presets'],
59
+ presetHint: ['一键对齐常用工作场景的并发与引擎策略,免去逐项手动调优。', 'One-click presets tailored for common research and search workflows.'],
60
+ presetFast: ['极速日常', 'Fast & Free'],
61
+ presetFastDesc: ['免密免费源优先,关闭 TF-IDF 重排与数值交叉比对,超低延迟', 'Keyless & free sources, disable rerank & crosscheck for lowest latency'],
62
+ presetStandard: ['平衡生产(推荐)', 'Balanced (Recommended)'],
63
+ presetStandardDesc: ['开启 TF-IDF 重排、数值交叉核验、主流付费源,标准超时', 'TF-IDF rerank, numeric crosscheck, mainstream paid sources, standard timeouts'],
64
+ presetDeep: ['深度调研', 'Deep Research'],
65
+ presetDeepDesc: ['激活更多取证工具、对冲自适应宽限、语义证据层、更大并发', 'Full forensic tools, adaptive hedge grace, semantic evidence layer, max concurrency'],
66
+ presetApplied: ['已应用预设:', 'Preset applied:'],
67
+ matrixTitle: ['核心引擎拓扑与覆盖全景', 'Core Engine Topology & Coverage'],
68
+ matrixHint: ['当前可用引擎的接入层级与角色分工。带免密标识的引擎无需密钥即可直接使用。', 'Access tiers and roles of available engines. Keyless engines work without an API key.'],
69
+ matrixConfigured: ['密钥已就绪', 'Key Ready'],
70
+ matrixKeyless: ['免密层可用', 'Keyless Ready'],
71
+ matrixPending: ['待配密钥', 'Key Required'],
72
+ searchFilterPlaceholder: ['输入关键词快速筛选...', 'Filter by keyword or engine...'],
73
+ summary: ['Argo · web_search {search} · web_fetch {fetch} · 原生工具 {tools} 个 · 研究 {workers}/{max}', 'Argo · web_search {search} · web_fetch {fetch} · {tools} native tools · research {workers}/{max}'],
74
+ accessTitle: ['接入方式', 'Access'],
75
+ searchSeam: ['宿主 web_search 走 argo', 'Route host web_search to argo'],
76
+ searchSeamHint: ['关闭后 web_search 回到宿主默认搜索后端(web 行 searchProvider)。', 'When off, web_search falls back to the host provider configured on the web row.'],
77
+ fetchSeam: ['宿主 web_fetch 走 argo', 'Route host web_fetch to argo'],
78
+ fetchSeamHint: ['开启前必须在 web 配置行加 fetchProvider: argo;否则两个 provider 同时可用会报 WEB_PROVIDER_AMBIGUOUS。', 'Requires fetchProvider: argo on the web row; otherwise two available providers trigger WEB_PROVIDER_AMBIGUOUS.'],
79
+ entryTitle: ['引擎入口', 'Engine entry'],
80
+ 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.'],
81
+ command: ['命令', 'Command'],
82
+ args: ['参数(一行一个)', 'Args (one per line)'],
83
+ searchTimeout: ['搜索超时 (ms)', 'Search timeout (ms)'],
84
+ fetchTimeout: ['抓取超时 (ms)', 'Fetch timeout (ms)'],
85
+ fetchChars: ['抓取正文上限(字符)', 'Fetch body cap (chars)'],
86
+ idle: ['连接空闲回收 (ms)', 'Idle recycle (ms)'],
87
+ concurrency: ['并发连接数', 'Concurrent connections'],
88
+ toolsTitle: ['原生工具', 'Native tools'],
89
+ toolsHint: ['勾选即注册为原生一等工具(CLI 单发,不依赖 MCP)。长尾工具只在需要时开,避免每轮工具面膨胀。', 'Checked tools register as native first-class tools (single-shot CLI, no MCP). Enable long-tail tools only when needed.'],
90
+ toolPresetTitle: ['推荐组合', 'Recommended sets'],
91
+ toolPresetHint: ['按场景一键套用(会覆盖当前勾选)。工具分区见下方。', 'Apply a scenario preset in one click (replaces current selection). See the grouped tools below.'],
92
+ coreTools: ['高频路径', 'Hot path'],
93
+ longTools: ['长尾取证', 'Long tail'],
94
+ nativeTimeout: ['单次调用超时 (ms)', 'Per-call timeout (ms)'],
95
+ nativeChars: ['返回文本上限(字符)', 'Returned text cap (chars)'],
96
+ keysTitle: ['API 密钥', 'API keys'],
97
+ 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.'],
98
+ commonKeys: ['常用引擎', 'Common engines'],
99
+ moreKeys: ['更多引擎', 'More engines'],
100
+ configured: ['已配置', 'Configured'],
101
+ notConfigured: ['未配置', 'Not configured'],
102
+ forward: ['转发', 'Forward'],
103
+ keyPlaceholderSet: ['输入新值(留空保留现有密钥)', 'Enter a new value (leave blank to keep the current key)'],
104
+ keyPlaceholderEmpty: ['粘贴 API Key', 'Paste API key'],
105
+ saveKey: ['保存', 'Save'],
106
+ clearKey: ['清除', 'Clear'],
107
+ keySaved: ['密钥已保存;下一次新建 argo 连接生效(池内旧连接最长 60s 回收)。', 'Key saved; effective on the next new argo connection (old pooled connections recycle within ~60s).'],
108
+ keyCleared: ['密钥已清除。', 'Key cleared.'],
109
+ keyUnavailable: ['凭证服务不可用。', 'Credential service unavailable.'],
110
+ researchTitle: ['研究编排', 'Research'],
111
+ workers: ['默认 worker 数', 'Default workers'],
112
+ maxWorkers: ['worker 上限', 'Worker cap'],
113
+ tracks: ['轨道上限', 'Track cap'],
114
+ sources: ['每轨信源上限', 'Sources per track'],
115
+ workerTokens: ['worker token 上限', 'Worker token cap'],
116
+ synthTokens: ['综合 token 上限', 'Synthesis token cap'],
117
+ reportDir: ['报告落盘目录', 'Report directory'],
118
+ advancedTitle: ['高级', 'Advanced'],
119
+ allow: ['worker 工具白名单(一行一个)', 'Worker tool allowlist (one per line)'],
120
+ allowHint: ['留空表示使用内置默认(MCP 与原生工具双写)。wide_research 自身与 argo_research 会被硬排除。', 'Empty uses the built-in default (MCP + native tools). wide_research itself and argo_research are always excluded.'],
121
+ deny: ['worker 工具拒绝名单(一行一个)', 'Worker tool denylist (one per line)'],
122
+ keyRefs: ['凭证转发名单(一行一个)', 'Credential forwarding refs (one per line)'],
123
+ keyRefsHint: ['这些引用名会经 DSH credentials 解析后作为环境变量传给 argo 子进程;没有对应凭证的项会被跳过。', 'These refs resolve through DSH credentials and reach the argo child process as environment variables. Missing refs are skipped.'],
124
+ structural: ['结构性字段', 'Structural fields'],
125
+ 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.'],
126
+ 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.'],
127
+ noKey: ['(未配置)', '(not configured)'],
128
+ enginesTitle: ['argo 引擎开关', 'argo engine switches'],
129
+ 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.'],
130
+ groupCache: ['缓存与排序', 'Cache & ranking'],
131
+ groupFetch: ['抓取层', 'Fetch layer'],
132
+ groupSemantic: ['语义与自适应', 'Semantics & adaptivity'],
133
+ groupEngines: ['引擎启停', 'Engine on-off'],
134
+ groupNet: ['网络出口', 'Network'],
135
+ groupLocal: ['本机检索', 'Local search'],
136
+ groupMisc: ['其他', 'Misc'],
137
+ groupPaid: ['额度与预算', 'Quotas & budgets'],
138
+ 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.'],
139
+ envDefault: ['默认', 'default'],
140
+ envRange: ['需在 {min}–{max} 之间', 'must be between {min} and {max}'],
141
+ keySourceFile: ['凭证库', 'credential store'],
142
+ keySourceEnv: ['启动环境', 'launch environment'],
143
+ keySourceProjectEnv: ['项目 .env', 'project .env'],
144
+ keySourceUserEnv: ['家目录 .env', 'home .env'],
145
+ keySourceOther: ['其他层', 'other layer'],
146
+ keyReadonly: ['只读', 'read-only'],
147
+ keyOverrideHint: ['保存后将覆盖当前层', 'saving overrides the current layer'],
148
+ deepseekShared: ['与宿主 web_search 官方后端共用同一把 key,改动同时影响两边', 'Shared with the host web_search backend; changing it affects both'],
270
149
  };
271
150
 
272
151
  // 工具分区(场景化):核心 / 取证 / 本地 / 长尾。
@@ -320,7 +199,8 @@ window.__ModuleLoader__.load({
320
199
  { ref: "EASTMONEY_APIKEY", common: false, label: "东财妙想", en: "Eastmoney Miaoxiang", engines: ["em_miaoxiang"] },
321
200
  { ref: "FELO_API_KEY", common: false, label: "Felo AI搜索", en: "Felo AI Search", engines: ["felo"] },
322
201
  { ref: "FIRECRAWL_API_KEY", common: false, label: "Firecrawl", en: "Firecrawl", engines: ["firecrawl"] },
323
- { ref: "FOURGET_URL", common: false, label: "4get 极简元搜索", en: "Fourget", engines: ["fourget"] },
202
+ { ref: "FOURGET_URL", common: false, label: "4get 极简元搜索", en: "4get", engines: ["fourget"] },
203
+ { ref: "GEMINI_API_KEY", common: false, label: "语义证据·Gemini 决策", en: "Semantic Evidence · Gemini Decision", engines: [] },
324
204
  { ref: "GITHUB_TOKEN", common: false, label: "GitHub", en: "GitHub", engines: ["github"] },
325
205
  { ref: "KEENABLE_API_KEY", common: false, label: "Keenable", en: "Keenable", engines: ["keenable"] },
326
206
  { ref: "METASO_API_KEY", common: false, label: "秘塔", en: "Metaso", engines: ["metaso", "metaso_doc", "metaso_image", "metaso_podcast", "metaso_scholar", "metaso_video"] },
@@ -333,12 +213,13 @@ window.__ModuleLoader__.load({
333
213
  { ref: "SEARXNG_URL", common: false, label: "SearXNG", en: "SearXNG", engines: ["searxng"] },
334
214
  { ref: "SELTZ_API_KEY", common: false, label: "Seltz搜索", en: "Seltz Search", engines: ["seltz"] },
335
215
  { ref: "SERPAPI_API_KEY", common: false, label: "Google Lens 反搜图", en: "Google Lens (SerpAPI)", engines: ["google_lens"] },
216
+ { ref: "TYPESAFE_API_KEY", common: false, label: "语义证据·JEV(TypeSafe)", en: "Semantic Evidence · JEV (TypeSafe)", engines: [] },
336
217
  { ref: "UNPAYWALL_EMAIL", common: false, label: "Unpaywall 开放获取定位", en: "Unpaywall Open Access", engines: ["unpaywall"] },
337
218
  { ref: "WEB_SEARCH_API_KEY", common: false, label: "字节搜索", en: "ByteDance Search", engines: ["byted"] },
338
219
  { ref: "WEREAD_API_KEY", common: false, label: "微信读书", en: "WeRead", engines: ["weread"] },
339
220
  { ref: "WOLFRAM_APPID", common: false, label: "WolframAlpha", en: "WolframAlpha", engines: ["wolframalpha"] },
340
221
  { 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"] },
222
+ { ref: "ZHIHU_ACCESS_SECRET", common: false, label: "知乎", en: "Zhihu", engines: ["zhihu", "zhihu_global", "zhihu_hot", "zhihu_kb", "zhihu_questions", "zhihu_user"] },
342
223
  ];
343
224
  // </generated:keys>
344
225
 
@@ -406,8 +287,59 @@ window.__ModuleLoader__.load({
406
287
  workerMaxTokens: 5000, synthesisMaxTokens: 7000, reportDir: '',
407
288
  };
408
289
 
290
+ const FORM_FIELDS = {
291
+ access: [
292
+ { key: 'command', prop: 'searchCommand', type: 'text', label: 'command', layout: 'full' },
293
+ { key: 'argsText', prop: 'searchArgs', type: 'lines', label: 'args', fallbackNonEmpty: true, layout: 'full' },
294
+ { key: 'searchTimeoutMs', prop: 'searchTimeoutMs', type: 'num', min: 1000, label: 'searchTimeout' },
295
+ { key: 'fetchTimeoutMs', prop: 'fetchTimeoutMs', type: 'num', min: 1000, label: 'fetchTimeout' },
296
+ // argo_fetch 工具 schema 上限 50000:与 clamp 对齐防显示失真
297
+ { key: 'fetchMaxChars', prop: 'fetchMaxChars', type: 'num', min: 500, max: 50_000, step: 500, label: 'fetchChars' },
298
+ { key: 'searchIdleMs', prop: 'searchIdleMs', type: 'num', min: 0, step: 1000, label: 'idle' },
299
+ { key: 'searchConcurrency', prop: 'searchConcurrency', type: 'num', min: 1, label: 'concurrency' },
300
+ ],
301
+ tools: [
302
+ { key: 'nativeTimeoutMs', prop: 'nativeTimeoutMs', type: 'num', min: 1000, label: 'nativeTimeout' },
303
+ { key: 'nativeMaxChars', prop: 'nativeMaxChars', type: 'num', min: 500, step: 500, label: 'nativeChars' },
304
+ ],
305
+ research: [
306
+ { key: 'defaultWorkers', prop: 'defaultWorkers', type: 'num', min: 1, label: 'workers' },
307
+ { key: 'maxWorkers', prop: 'maxWorkers', type: 'num', min: 1, minDraft: 'defaultWorkers', label: 'maxWorkers' },
308
+ { key: 'maxTracks', prop: 'maxTracks', type: 'num', min: 2, label: 'tracks' },
309
+ { key: 'maxSourcesPerTrack', prop: 'maxSourcesPerTrack', type: 'num', min: 1, label: 'sources' },
310
+ { key: 'workerMaxTokens', prop: 'workerMaxTokens', type: 'num', min: 512, step: 512, label: 'workerTokens' },
311
+ { key: 'synthesisMaxTokens', prop: 'synthesisMaxTokens', type: 'num', min: 512, step: 512, label: 'synthTokens' },
312
+ { key: 'reportDir', prop: 'reportDir', type: 'text', allowEmpty: true, label: 'reportDir', layout: 'full' },
313
+ ],
314
+ advanced: [
315
+ { key: 'allowText', prop: 'childToolAllow', type: 'lines', label: 'allow', hint: 'allowHint', layout: 'full' },
316
+ { key: 'denyText', prop: 'childToolDeny', type: 'lines', label: 'deny', layout: 'full' },
317
+ { key: 'keyRefsText', prop: 'keyRefs', type: 'lines', label: 'keyRefs', hint: 'keyRefsHint', layout: 'full' },
318
+ ],
319
+ };
320
+
321
+ const PRESETS = [
322
+ {
323
+ id: 'fast', titleKey: 'presetFast', descKey: 'presetFastDesc', badge: '15s 超时', badgeColor: 'blue', active: false,
324
+ env: { ARGO_TFIDF_RERANK: '0', ARGO_NUMBER_CROSSCHECK: '0', ARGO_PAID_SEARCH: 'off', ARGO_ADAPTIVE_GRACE: '1', ARGO_SERIAL_STAGGER_S: '0.5' },
325
+ fields: { searchTimeoutMs: 15000, fetchTimeoutMs: 15000 },
326
+ },
327
+ {
328
+ id: 'standard', titleKey: 'presetStandard', descKey: 'presetStandardDesc', badge: '标准生产', badgeColor: 'green', active: true,
329
+ 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' },
330
+ fields: { searchTimeoutMs: 30000, fetchTimeoutMs: 25000 },
331
+ },
332
+ {
333
+ id: 'deep', titleKey: 'presetDeep', descKey: 'presetDeepDesc', badge: '深度核验', badgeColor: 'blue', active: false,
334
+ 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' },
335
+ fields: { searchTimeoutMs: 45000, fetchTimeoutMs: 35000, nativeTimeoutMs: 60000 },
336
+ },
337
+ ];
338
+
339
+ const col = (gap) => ({ display: 'flex', flexDirection: 'column', gap });
340
+ const rowBetween = (gap = 8) => ({ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap });
409
341
  const S = {
410
- wrap: { display: 'flex', flexDirection: 'column', gap: 14, maxWidth: 800, color: 'var(--dsw-alias-label-primary, #1f2328)' },
342
+ wrap: { ...col(14), maxWidth: 800, color: 'var(--dsw-alias-label-primary, #1f2328)' },
411
343
  title: { margin: 0, fontSize: 18, fontWeight: 600, lineHeight: '26px' },
412
344
  hint: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary, #7b818b)' },
413
345
  notice: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-state-business-primary, #3b6ef6)' },
@@ -419,10 +351,10 @@ window.__ModuleLoader__.load({
419
351
  color: active ? 'var(--dsw-alias-label-primary, #1f2328)' : 'var(--dsw-alias-label-tertiary, #7b818b)',
420
352
  borderBottom: active ? '2px solid var(--dsw-alias-state-business-primary, #3b6ef6)' : '2px solid transparent',
421
353
  }),
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)' },
354
+ 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
355
  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 },
356
+ row: rowBetween(12),
357
+ field: { ...col(4), minWidth: 0 },
426
358
  label: { fontSize: 13, fontWeight: 500, lineHeight: '18px' },
427
359
  sub: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary, #7b818b)' },
428
360
  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 +365,83 @@ window.__ModuleLoader__.load({
433
365
  check: { display: 'flex', alignItems: 'center', gap: 8, fontSize: 13, cursor: 'pointer' },
434
366
  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
367
  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
368
  status: { margin: 0, fontSize: 12, minHeight: 18, lineHeight: '18px' },
442
369
  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 },
370
+ keyHead: { ...col(2), minWidth: 0 },
444
371
  code: { fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace', fontSize: 10, color: 'var(--dsw-alias-label-tertiary, #7b818b)' },
445
372
  dot: (on) => ({ display: 'inline-block', width: 6, height: 6, borderRadius: 999, background: on ? '#2da44e' : 'var(--dsw-alias-border-l4, #d0d7de)', marginRight: 5 }),
446
373
  actions: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' },
447
- switchWrap: { display: 'flex', alignItems: 'center', gap: 8 },
448
374
  divider: { height: '.5px', background: 'var(--dsw-alias-border-l2, #eee)', margin: '2px 0' },
449
375
  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)' },
376
+ 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
377
  metricLabel: { fontSize: 11, fontWeight: 500, color: 'var(--dsw-alias-label-tertiary, #7b818b)', textTransform: 'uppercase', letterSpacing: '0.04em' },
452
378
  metricValue: { fontSize: 18, fontWeight: 600, lineHeight: '22px', color: 'var(--dsw-alias-label-primary, #1f2328)' },
453
379
  metricSub: { fontSize: 11, lineHeight: '16px', color: 'var(--dsw-alias-label-secondary, #4b5563)' },
454
380
  presetGrid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))', gap: 10 },
455
381
  presetCard: (active) => ({
456
- display: 'flex', flexDirection: 'column', gap: 6, padding: '12px 14px', borderRadius: 10, cursor: 'pointer', textAlign: 'left',
382
+ ...col(6), padding: '12px 14px', borderRadius: 10, cursor: 'pointer', textAlign: 'left',
457
383
  border: active ? '1.5px solid var(--dsw-alias-state-business-primary, #3b6ef6)' : '.5px solid var(--dsw-alias-border-l3, #e5e7eb)',
458
384
  background: active ? 'var(--dsw-alias-bg-layer-1, #fff)' : 'var(--dsw-alias-settings-card-fill, #fff)',
459
385
  boxShadow: active ? '0 1px 3px rgba(59, 110, 246, 0.12)' : 'none',
460
386
  }),
461
387
  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) => ({
388
+ 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)' },
389
+ badge: (c) => ({
464
390
  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')),
391
+ background: c === 'green' ? 'rgba(46, 160, 67, 0.12)' : (c === 'blue' ? 'rgba(59, 110, 246, 0.12)' : 'rgba(100, 116, 139, 0.12)'),
392
+ color: c === 'green' ? '#2da44e' : (c === 'blue' ? '#3b6ef6' : '#64748b'),
393
+ border: '.5px solid ' + (c === 'green' ? '#2da44e' : (c === 'blue' ? '#3b6ef6' : '#64748b')),
468
394
  }),
469
395
  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
396
  };
471
397
 
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);
398
+ const asString = (v, fb) => (typeof v === 'string' ? v : (fb ?? ''));
399
+ const asArray = (v) => (Array.isArray(v) ? v.filter((item) => typeof item === 'string') : []);
400
+ const lines = (text) => String(text ?? '').split('\n').map((l) => l.trim()).filter(Boolean);
401
+ function asNumber(v, fb) {
402
+ const n = typeof v === 'number' ? v : Number.parseInt(String(v ?? ''), 10);
403
+ return Number.isFinite(n) ? n : fb;
487
404
  }
488
405
 
489
406
  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
- }));
407
+ const out = {};
408
+ for (const specs of Object.values(FORM_FIELDS)) {
409
+ for (const f of specs) {
410
+ if (f.type === 'lines') out[f.key] = asArray(value[f.prop]).join('\n');
411
+ else if (f.type === 'num') out[f.key] = String(asNumber(value[f.prop], DEFAULTS[f.prop]));
412
+ else out[f.key] = asString(value[f.prop], DEFAULTS[f.prop]);
413
+ }
414
+ }
415
+ return out;
556
416
  }
557
417
 
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
- }
418
+ const Card = (p) => h('section', { style: S.card }, [
419
+ p.title ? h('h3', { key: 't', style: S.cardTitle }, p.title) : null,
420
+ p.hint ? h('p', { key: 'h', style: S.hint }, p.hint) : null,
421
+ p.children,
422
+ ]);
423
+ const Field = (p) => h('label', { style: S.field }, [
424
+ h('span', { key: 'l', style: S.label }, p.label),
425
+ p.children,
426
+ p.hint ? h('span', { key: 'h', style: S.sub }, p.hint) : null,
427
+ ]);
428
+ const Switch = (p) => h('div', { style: S.row }, [
429
+ h('div', { key: 'txt', style: { minWidth: 0 } }, [
430
+ h('div', { key: 'l', style: S.label }, p.label),
431
+ p.hint ? h('div', { key: 'h', style: S.sub }, p.hint) : null,
432
+ ]),
433
+ h('input', {
434
+ key: 'i', type: 'checkbox', checked: p.checked === true, disabled: p.disabled === true,
435
+ onChange: (e) => p.onChange(e.target.checked), 'aria-label': p.label,
436
+ }),
437
+ ]);
438
+ const NumberField = (p) => h(Field, { label: p.label, hint: p.hint }, h('input', {
439
+ type: 'number', style: S.input, value: p.value, min: p.min, step: p.step ?? 1,
440
+ disabled: p.disabled === true, onChange: (e) => p.onChange(e.target.value),
441
+ }));
442
+ const PrimaryButton = (p) => h('button', {
443
+ type: 'button', style: p.primary ? S.btnPrimary : S.btn, disabled: p.disabled === true, onClick: p.onClick,
444
+ }, p.children);
566
445
 
567
446
  function ArgoPanel(props) {
568
447
  const state = props.useArgoForm((snapshot) => snapshot);
@@ -574,51 +453,36 @@ window.__ModuleLoader__.load({
574
453
  const locale = props.locale;
575
454
  const initialLang = locale && locale.getSnapshot && locale.getSnapshot().active === 'en' ? 'en' : 'zh';
576
455
  const [lang, setLang] = useState(initialLang);
577
-
578
- const [tab, setTab] = useState('dashboard');
456
+ const [tab, setTab] = useState('dashboard'); // hooks[1]:测试按此索引注入页签
579
457
  const [draft, setDraft] = useState(() => toDraft(value));
580
458
  const [busy, setBusy] = useState('');
581
459
  const [message, setMessage] = useState('');
582
460
  const [error, setError] = useState(false);
583
-
584
461
  const [credentials, setCredentials] = useState({});
585
462
  const [keyDraft, setKeyDraft] = useState({});
586
463
  const [keyBusy, setKeyBusy] = useState('');
587
464
  const [showAllKeys, setShowAllKeys] = useState(false);
588
-
589
- // argoEnv 引擎开关:bool 类即时写;num/str/list 类走草稿 + 分组保存。
465
+ // argoEnv 引擎开关:bool 类即时写;num/str/list 类走草稿 + 分组保存
590
466
  const [envDraft, setEnvDraft] = useState({});
591
467
  const [envBusy, setEnvBusy] = useState('');
592
468
  const [engineFilter, setEngineFilter] = useState('');
593
469
  const [keyFilter, setKeyFilter] = useState('');
594
- // 路由观测(宿主经 remote 事件推送;无推送时卡片显示终端命令提示)
595
470
  const [routeHealth, setRouteHealth] = useState(null);
596
471
 
597
472
  const dirty = useRef(new Set());
598
- // 读-改-写共享配置字段(keyRefs / nativeTools / argoEnv)时读实时快照,
599
- // 不读渲染时快照:保存是 await 之后的异步写,连续两次操作都从渲染值出发
600
- // 会把前一次的结果挤掉(丢一个转发勾选/工具勾选)。
473
+ const credSeq = useRef(0);
474
+ // 读-改-写共享字段(keyRefs / nativeTools / argoEnv)读实时快照,防连点丢更新
601
475
  const liveValue = () => {
602
- const snapshot = typeof props.useArgoForm?.getSnapshot === 'function'
603
- ? props.useArgoForm.getSnapshot()
604
- : undefined;
605
- return snapshot && snapshot.value ? snapshot.value : value;
476
+ const snap = typeof props.useArgoForm?.getSnapshot === 'function' ? props.useArgoForm.getSnapshot() : undefined;
477
+ return snap && snap.value ? snap.value : value;
606
478
  };
607
- // describe 往返乱序防护:只认最新一次请求的响应(同官方 settings 页口径)。
608
- const credSeq = useRef(0);
609
479
 
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
- };
480
+ const langIdx = lang === 'en' ? 1 : 0;
481
+ const t = (key) => (I18N[key] ? (I18N[key][langIdx] ?? I18N[key][0]) : key);
615
482
 
616
483
  useEffect(() => {
617
484
  const off = locale && locale.subscribe
618
- ? locale.subscribe(() => {
619
- const next = locale.getSnapshot && locale.getSnapshot().active === 'en' ? 'en' : 'zh';
620
- setLang(next);
621
- })
485
+ ? locale.subscribe(() => setLang(locale.getSnapshot && locale.getSnapshot().active === 'en' ? 'en' : 'zh'))
622
486
  : undefined;
623
487
  return typeof off === 'function' ? off : undefined;
624
488
  }, [locale]);
@@ -637,12 +501,10 @@ window.__ModuleLoader__.load({
637
501
  if (!props.credentials || typeof props.credentials.describe !== 'function') return;
638
502
  const seq = ++credSeq.current;
639
503
  try {
640
- const response = await props.credentials.describe(KEYS.map((entry) => entry.ref));
504
+ const res = await props.credentials.describe(KEYS.map((entry) => entry.ref));
641
505
  if (seq !== credSeq.current) return;
642
- if (response && response.ok) setCredentials(response.value || {});
643
- } catch {
644
- /* 凭证服务暂不可用:保留上一次状态 */
645
- }
506
+ if (res && res.ok) setCredentials(res.value || {});
507
+ } catch { /* 凭证服务暂不可用 */ }
646
508
  };
647
509
 
648
510
  useEffect(() => {
@@ -658,150 +520,94 @@ window.__ModuleLoader__.load({
658
520
  return () => { for (const off of offs) off(); };
659
521
  }, [state]);
660
522
 
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
- };
523
+ const edit = (key, text) => { dirty.current.add(key); setDraft((p) => ({ ...p, [key]: text })); };
524
+ const report = (ok, text) => { setError(!ok); setMessage(text); };
670
525
 
671
- const write = async (ops) => {
526
+ const runSave = async (key, fn) => {
672
527
  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
- }
684
- };
685
-
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']);
528
+ setBusy(key);
529
+ try { return await fn(); }
530
+ catch (cause) { report(false, cause && cause.message ? cause.message : String(cause)); return false; }
531
+ finally { setBusy(''); }
718
532
  };
719
533
 
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
- };
534
+ const write = (ops) => runSave('save', async () => {
535
+ const ok = await props.mutate(ops);
536
+ report(ok, ok ? t('saved') : t('refused'));
537
+ return ok;
538
+ });
727
539
 
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
- };
540
+ const setField = (field, next) => runSave(field, async () => {
541
+ const ok = await props.set(field, next);
542
+ report(ok, ok ? t('saved') : t('refused'));
543
+ return ok;
544
+ });
742
545
 
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']);
546
+ const saveFormGroup = async (groupKey) => {
547
+ const specs = FORM_FIELDS[groupKey];
548
+ const parsed = {};
549
+ const ops = specs.map((f) => {
550
+ let val;
551
+ if (f.type === 'lines') {
552
+ const arr = lines(draft[f.key]);
553
+ val = f.fallbackNonEmpty && !arr.length ? DEFAULTS[f.prop] : arr;
554
+ } else if (f.type === 'num') {
555
+ const minVal = f.minDraft ? Math.max(f.min, parsed[f.minDraft]) : f.min;
556
+ val = Math.max(minVal, asNumber(draft[f.key], DEFAULTS[f.prop]));
557
+ if (f.max !== undefined) val = Math.min(f.max, val);
558
+ } else {
559
+ const trimmed = draft[f.key].trim();
560
+ val = f.allowEmpty ? trimmed : (trimmed || DEFAULTS[f.prop]);
561
+ }
562
+ parsed[f.key] = val;
563
+ return { op: 'set', path: [f.prop], value: val };
564
+ });
565
+ const ok = await write(ops);
566
+ if (ok) for (const f of specs) dirty.current.delete(f.key);
750
567
  };
751
568
 
752
569
  const toggleTool = (id) => {
753
570
  const current = new Set(asArray(liveValue().nativeTools));
754
571
  if (current.has(id)) current.delete(id);
755
572
  else current.add(id);
756
- const ordered = TOOLS.map((tool) => tool.id).filter((toolId) => current.has(toolId));
573
+ const ordered = TOOLS.map((tool) => tool.id).filter((tid) => current.has(tid));
757
574
  for (const extra of current) if (!ordered.includes(extra)) ordered.push(extra);
758
575
  void setField('nativeTools', ordered);
759
576
  };
760
577
 
761
- // 推荐组合:一键套用一组工具(场景化分区之上的快捷入口)。
762
- // 只增不减会覆盖用户已有勾选,所以是「设为这组」而非「追加这组」。
763
578
  const applyToolPreset = async (tools) => {
764
- const ordered = TOOLS.map((tool) => tool.id).filter((toolId) => tools.includes(toolId));
579
+ const ordered = TOOLS.map((tool) => tool.id).filter((tid) => tools.includes(tid));
765
580
  for (const extra of tools) if (!ordered.includes(extra)) ordered.push(extra);
766
581
  await props.set('nativeTools', ordered);
767
582
  };
768
583
 
769
- const saveKey = async (ref) => {
584
+ const mutateKey = async (ref, action) => {
585
+ setKeyBusy(ref);
586
+ try { await action(); await refreshCredentials(); }
587
+ catch (cause) { report(false, cause && cause.message ? cause.message : String(cause)); }
588
+ finally { setKeyBusy(''); }
589
+ };
590
+
591
+ const saveKey = (ref) => {
770
592
  const key = asString(keyDraft[ref]).trim();
771
593
  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]: '' }));
594
+ return mutateKey(ref, async () => {
595
+ const res = await props.credentials.set(ref, key);
596
+ if (!res || !res.ok) throw new Error(res && res.error ? res.error.message : t('keyUnavailable'));
597
+ setKeyDraft((p) => ({ ...p, [ref]: '' }));
779
598
  const refs = asArray(liveValue().keyRefs);
780
599
  if (!refs.includes(ref)) await props.set('keyRefs', [...refs, ref]);
781
600
  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
- }
601
+ });
788
602
  };
789
603
 
790
- const clearKey = async (ref) => {
604
+ const clearKey = (ref) => {
791
605
  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
- }
606
+ return mutateKey(ref, async () => {
607
+ const res = await props.credentials.unset(ref);
608
+ if (!res || !res.ok) throw new Error(res && res.error ? res.error.message : t('keyUnavailable'));
798
609
  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
- }
610
+ });
805
611
  };
806
612
 
807
613
  const setForward = (ref, on) => {
@@ -811,12 +617,7 @@ window.__ModuleLoader__.load({
811
617
  void setField('keyRefs', [...refs]);
812
618
  };
813
619
 
814
- // ── argoEnv 引擎开关:KEY=VALUE 行 ↔ 控件 ──
815
- // argoEnv 行集合是单一真源:每次写入都基于实时快照读-改-写,只碰白名单
816
- // 内的名字。白名单外的行**被清掉**,不是原样保留——apply 期对白名单外
817
- // 名字是 loud fail(整个插件加载失败),直接写 profile patch 写错的开关
818
- // 会让人卡在「改不回来」;这里任何一次面板写入都顺手清毒,是最容易碰到
819
- // 的恢复入口。
620
+ // argoEnv 单一真源:写入时过滤白名单外脏键,避免 apply 期 loud fail 卡死
820
621
  const envMap = () => {
821
622
  const map = {};
822
623
  for (const entry of asArray(liveValue().argoEnv)) {
@@ -825,31 +626,24 @@ window.__ModuleLoader__.load({
825
626
  }
826
627
  return map;
827
628
  };
828
- // 与 argo 的 env_flag 判定对齐:空串/0/false/no/off/n/disable/disabled/none 算关。
829
629
  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
630
+ const envBoolState = (spec, map) => (
631
+ map[spec.name] === undefined
833
632
  ? spec.def === true
834
- : !ENV_FALSY.includes(String(raw).trim().toLowerCase());
835
- };
633
+ : !ENV_FALSY.includes(String(map[spec.name]).trim().toLowerCase())
634
+ );
836
635
  const writeEnvLines = async (updates) => {
837
636
  const map = envMap();
838
637
  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;
638
+ const val = updates[name];
639
+ if (val === null || val === undefined || val === '') delete map[name];
640
+ else map[name] = val;
842
641
  }
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);
642
+ return props.set('argoEnv', Object.keys(map).filter((n) => ENV_NAMES.has(n)).map((n) => `${n}=${map[n]}`));
847
643
  };
848
644
  const toggleEnv = (spec, on) => {
849
645
  if (disabled) return;
850
- // 开关状态直接落 0/1:文案与 env 同向(开=1,关=0),不做反转。
851
- const value = on ? '1' : '0';
852
- void writeEnvLines({ [spec.name]: value })
646
+ void writeEnvLines({ [spec.name]: on ? '1' : '0' })
853
647
  .then((ok) => report(ok, ok ? t('saved') : t('refused')))
854
648
  .catch((cause) => report(false, cause && cause.message ? cause.message : String(cause)));
855
649
  };
@@ -857,14 +651,9 @@ window.__ModuleLoader__.load({
857
651
  if (disabled) return;
858
652
  const updates = {};
859
653
  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
- }
654
+ if (spec.group !== group || spec.kind === 'bool' || envDraft[spec.name] === undefined) continue;
655
+ const text = String(envDraft[spec.name]).trim();
656
+ if (text === '') { updates[spec.name] = null; continue; }
868
657
  if (spec.kind === 'num') {
869
658
  const n = Number(text);
870
659
  if (!Number.isFinite(n) || n < spec.min || n > spec.max) {
@@ -880,71 +669,28 @@ window.__ModuleLoader__.load({
880
669
  const ok = await writeEnvLines(updates);
881
670
  report(ok, ok ? t('saved') : t('refused'));
882
671
  if (ok) setEnvDraft({});
883
- } catch (cause) {
884
- report(false, cause && cause.message ? cause.message : String(cause));
885
- } finally {
886
- setEnvBusy('');
887
- }
672
+ } catch (cause) { report(false, cause && cause.message ? cause.message : String(cause)); }
673
+ finally { setEnvBusy(''); }
888
674
  };
889
675
 
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
- };
676
+ const applyPreset = (preset) => runSave('preset', async () => {
677
+ const map = { ...envMap(), ...preset.env };
678
+ const ops = Object.entries(preset.fields).map(([path, val]) => ({ op: 'set', path: [path], value: val }));
679
+ const envLines = Object.keys(map).filter((n) => ENV_NAMES.has(n)).map((n) => `${n}=${map[n]}`);
680
+ ops.push({ op: 'set', path: ['argoEnv'], value: envLines });
681
+ const ok = await props.mutate(ops);
682
+ report(ok, ok ? `${t('presetApplied')} ${t(preset.titleKey)}` : t('refused'));
683
+ return ok;
684
+ });
937
685
 
938
686
  if (props.view === 'summary') {
939
- const summary = t('summary')
687
+ return t('summary')
940
688
  .replace('{search}', value.searchProviderEnabled !== false ? t('on') : t('off'))
941
689
  .replace('{fetch}', value.fetchProviderEnabled !== false ? t('on') : t('off'))
942
690
  .replace('{tools}', String(asArray(value.nativeTools).length))
943
691
  .replace('{workers}', String(asNumber(value.defaultWorkers, DEFAULTS.defaultWorkers)))
944
692
  .replace('{max}', String(asNumber(value.maxWorkers, DEFAULTS.maxWorkers)));
945
- return summary;
946
693
  }
947
-
948
694
  if (!ready) {
949
695
  return h('div', { style: S.wrap }, [
950
696
  h('h2', { key: 't', style: S.title }, t('title')),
@@ -952,202 +698,131 @@ window.__ModuleLoader__.load({
952
698
  ]);
953
699
  }
954
700
 
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
- ]),
701
+ const renderField = (f) => {
702
+ if (f.type === 'num') {
703
+ return h(NumberField, {
704
+ key: f.key, label: t(f.label), min: f.min, step: f.step,
705
+ value: draft[f.key], disabled, onChange: (next) => edit(f.key, next),
706
+ });
707
+ }
708
+ const isLines = f.type === 'lines';
709
+ return h(Field, { key: f.key, label: t(f.label), hint: f.hint ? t(f.hint) : undefined }, h(isLines ? 'textarea' : 'input', {
710
+ type: isLines ? undefined : 'text',
711
+ style: isLines ? { ...S.input, ...S.textarea, ...S.mono } : { ...S.input, ...S.mono },
712
+ value: draft[f.key], disabled, spellCheck: false,
713
+ onChange: (e) => edit(f.key, e.target.value),
714
+ }));
715
+ };
716
+ const renderGroup = (groupKey) => {
717
+ const specs = FORM_FIELDS[groupKey];
718
+ const full = specs.filter((f) => f.layout === 'full').map(renderField);
719
+ const grid = specs.filter((f) => f.layout !== 'full').map(renderField);
720
+ return [
721
+ ...full,
722
+ grid.length ? h('div', { key: 'g', style: S.grid }, grid) : null,
723
+ ];
724
+ };
725
+ const saveBtn = (groupKey) => h('div', { key: 'save', style: S.actions }, [
726
+ h(PrimaryButton, {
727
+ primary: true, disabled: disabled || busy === 'save',
728
+ onClick: () => { void saveFormGroup(groupKey); },
729
+ }, busy === 'save' ? t('saving') : t('save')),
980
730
  ]);
981
731
 
982
732
  const keyRow = (entry) => {
983
733
  const info = credentials[entry.ref];
984
734
  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 时提示保存后会覆盖当前层。
735
+ const rowWritable = !info || info.writable !== false;
989
736
  const sourceLabel = configured && typeof info.source === 'string'
990
- ? t('keySource' + info.source.split('-').map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(''))
737
+ ? t('keySource' + info.source.split('-').map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(''))
991
738
  : '';
992
739
  const statusParts = [configured ? t('configured') : t('notConfigured')];
993
740
  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'));
741
+ if (configured && !rowWritable) statusParts.push(t('keyReadonly'));
742
+ if (configured && rowWritable && info.source !== undefined && info.source !== 'file') statusParts.push(t('keyOverrideHint'));
996
743
  return h('div', { key: entry.ref, style: S.keyRow }, [
997
744
  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
- ]),
745
+ h('span', { key: 'n', style: S.label }, [h('span', { key: 'dot', style: S.dot(configured) }), lang === 'en' ? (entry.en || entry.label) : entry.label]),
1002
746
  h('span', { key: 'ref', style: S.code }, entry.ref),
1003
747
  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,
748
+ entry.ref === 'DEEPSEEK_API_KEY' ? h('span', { key: 'shared', style: S.sub }, t('deepseekShared')) : null,
1007
749
  ]),
1008
- h('div', { key: 'body', style: { display: 'flex', flexDirection: 'column', gap: 6 } }, [
750
+ h('div', { key: 'body', style: col(6) }, [
1009
751
  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 })),
752
+ key: 'i', type: 'password', autoComplete: 'off', spellCheck: false, style: S.input,
753
+ value: asString(keyDraft[entry.ref]), placeholder: t(configured ? 'keyPlaceholderSet' : 'keyPlaceholderEmpty'),
754
+ disabled: disabled || !props.credentials || !rowWritable,
755
+ onChange: (e) => setKeyDraft((p) => ({ ...p, [entry.ref]: e.target.value })),
1019
756
  }),
1020
757
  h('div', { key: 'a', style: S.actions }, [
1021
758
  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
- }),
759
+ h('input', { key: 'i', type: 'checkbox', checked: asArray(value.keyRefs).includes(entry.ref), disabled, onChange: (e) => setForward(entry.ref, e.target.checked) }),
1029
760
  h('span', { key: 't' }, t('forward')),
1030
761
  ]),
1031
762
  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,
763
+ 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')),
764
+ 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
765
  ]),
1047
766
  ]),
1048
767
  ]);
1049
768
  };
1050
769
 
1051
- const commonKeys = KEYS.filter((entry) => entry.common);
1052
- const visibleKeys = showAllKeys ? KEYS : commonKeys;
1053
-
1054
770
  const panel = [];
1055
-
1056
771
  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
- // 未推送时给出终端命令提示——不让面板空白,也不假装有数据。
772
+ const configuredKeys = Object.values(credentials).filter((c) => c && c.configured).length;
773
+ const searchOn = value.searchProviderEnabled !== false;
774
+ const fetchOn = value.fetchProviderEnabled !== false;
775
+ const poolConc = asNumber(value.searchConcurrency, DEFAULTS.searchConcurrency);
776
+ const metrics = [
777
+ { k: 'pool', label: t('poolTitle'), val: `${poolConc} 并发`, dot: poolConc > 0, sub: `${t('poolStatusHealthy')} · 空闲回收 ${asNumber(value.searchIdleMs, DEFAULTS.searchIdleMs) / 1000}s` },
778
+ { k: 'seam', label: t('accessTitle'), val: searchOn && fetchOn ? '双路接管' : (searchOn || fetchOn ? '单路接管' : '未接管'), sub: `Search: ${searchOn ? 'ON' : 'OFF'} · Fetch: ${fetchOn ? 'ON' : 'OFF'}` },
779
+ { k: 'tools', label: t('toolsTitle'), val: `${asArray(value.nativeTools).length} / ${TOOLS.length}`, sub: '已就绪原生 MCP 工具' },
780
+ { k: 'keys', label: t('keysTitle'), val: `${configuredKeys} 配置 · ${CORE_ENGINES.filter((e) => e.keyless).length} 免密`, sub: '覆盖全局多源引擎' },
781
+ ];
782
+ panel.push(h('div', { key: 'metrics', style: S.metricGrid }, metrics.map((m) => h('div', { key: m.k, style: S.metricCard }, [
783
+ h('span', { key: 'l', style: S.metricLabel }, m.label),
784
+ m.dot !== undefined
785
+ ? 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)])
786
+ : h('span', { key: 'val', style: S.metricValue }, m.val),
787
+ h('span', { key: 's', style: S.metricSub }, m.sub),
788
+ ]))));
789
+ const rhSummary = routeHealth && routeHealth.summary;
790
+ const topLangs = rhSummary && rhSummary.langCounts
791
+ ? Object.entries(rhSummary.langCounts).sort((a, b) => b[1] - a[1]).slice(0, 3).map(([k, n]) => `${k}:${n}`).join(' · ')
792
+ : '';
793
+ const topDomains = rhSummary && Array.isArray(rhSummary.topDomains)
794
+ ? rhSummary.topDomains.slice(0, 3).map((d) => `${d.name}:${d.count}`).join(' · ')
795
+ : '';
1093
796
  panel.push(h(Card, { key: 'route', title: t('routeHealthTitle'), hint: t('routeHealthHint') }, [
1094
797
  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
- ])))
798
+ ? h('div', { key: 'rows', style: col(6) }, [
799
+ rhSummary ? h('div', { key: 'sum', style: S.sub }, `${rhSummary.total} 条 · 兜底 ${Math.round((rhSummary.fallbackRate || 0) * 100)}%${topLangs ? ' · ' + topLangs : ''}`) : null,
800
+ topDomains ? h('div', { key: 'doms', style: S.sub }, `高频域:${topDomains}`) : null,
801
+ ...routeHealth.samples.slice(-5).reverse().map((r, i) => {
802
+ const langTag = r.effective_lang || r.primary_lang || '-';
803
+ const intentTag = Array.isArray(r.intents) && r.intents.length > 0 ? ` · ${r.intents.join(',')}` : '';
804
+ const confTag = r.confidence !== '' && r.confidence !== undefined ? ` (${r.confidence})` : '';
805
+ return h('div', { key: 'r' + i, style: S.keyRow }, [
806
+ h('span', { key: 'q', style: S.label }, `${r.domain || 'fallback'} · ${langTag}${intentTag}`),
807
+ h('span', { key: 'd', style: S.sub }, `${r.engine || '-'}${confTag}`),
808
+ ]);
809
+ }),
810
+ ])
1101
811
  : h('p', { key: 'hint', style: S.hint }, t('routeHealthFallback')),
1102
812
  ]));
1103
-
1104
813
  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
- ]),
814
+ h('div', { key: 'grid', style: S.presetGrid }, PRESETS.map((p) => h('div', { key: p.id, style: S.presetCard(p.active), onClick: () => { void applyPreset(p); } }, [
815
+ 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)]),
816
+ h('span', { key: 'd', style: S.sub }, t(p.descKey)),
817
+ ]))),
1140
818
  ]));
1141
-
1142
819
  panel.push(h(Card, { key: 'matrix', title: t('matrixTitle'), hint: t('matrixHint') }, [
1143
820
  h('div', { key: 'grid', style: S.matrixGrid }, CORE_ENGINES.map((engine) => {
1144
821
  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
822
  return h('div', { key: engine.id, style: S.matrixCard }, [
1148
- h('div', { key: 'h', style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 6 } }, [
823
+ h('div', { key: 'h', style: rowBetween(6) }, [
1149
824
  h('span', { key: 'n', style: S.label }, lang === 'en' ? engine.nameEn : engine.nameZh),
1150
- h('span', { key: 'b', style: S.badge(badgeType) }, badgeText),
825
+ h('span', { key: 'b', style: S.badge(hasKey ? 'green' : (engine.keyless ? 'blue' : 'gray')) }, t(hasKey ? 'matrixConfigured' : (engine.keyless ? 'matrixKeyless' : 'matrixPending'))),
1151
826
  ]),
1152
827
  h('span', { key: 'r', style: S.sub }, lang === 'en' ? engine.roleEn : engine.roleZh),
1153
828
  ]);
@@ -1157,337 +832,105 @@ window.__ModuleLoader__.load({
1157
832
 
1158
833
  if (tab === 'access') {
1159
834
  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
- ]),
835
+ h(Switch, { key: 's', checked: value.searchProviderEnabled !== false, disabled, label: t('searchSeam'), hint: t('searchSeamHint'), onChange: (n) => { void setField('searchProviderEnabled', n); } }),
836
+ h(Switch, { key: 'f', checked: value.fetchProviderEnabled !== false, disabled, label: t('fetchSeam'), hint: t('fetchSeamHint'), onChange: (n) => { void setField('fetchProviderEnabled', n); } }),
1219
837
  ]));
838
+ panel.push(h(Card, { key: 'entry', title: t('entryTitle'), hint: t('entryHint') }, [...renderGroup('access'), saveBtn('access')]));
1220
839
  }
1221
840
 
1222
841
  if (tab === 'tools') {
1223
842
  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),
843
+ h('div', { key: 'grid', style: S.presetGrid }, TOOL_PRESETS.map((pr) =>
844
+ h('button', { key: pr.id, type: 'button', disabled, style: S.presetCard(false), onClick: () => { void applyToolPreset(pr.tools); } }, [
845
+ 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} 工具`)]),
846
+ h('span', { key: 'd', style: S.sub }, lang === 'en' ? pr.descEn : pr.descZh),
1235
847
  ]))),
1236
848
  ]));
1237
849
  panel.push(h(Card, { key: 'tools', title: t('toolsTitle'), hint: t('toolsHint') }, [
1238
850
  ...TOOL_GROUPS.map((grp, gi) => [
1239
851
  gi > 0 ? h('div', { key: 'div' + gi, style: S.divider }) : null,
1240
- h('div', { key: grp.id, style: { display: 'flex', flexDirection: 'column', gap: 4 } }, [
852
+ h('div', { key: grp.id, style: col(4) }, [
1241
853
  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)),
854
+ h('div', { key: 'g', style: S.toolGrid }, TOOLS.filter((tl) => tl.group === grp.id).map((tl) => h('label', { key: tl.id, style: S.check }, [
855
+ h('input', { key: 'i', type: 'checkbox', checked: asArray(value.nativeTools).includes(tl.id), disabled, onChange: () => toggleTool(tl.id) }),
856
+ 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))]),
857
+ ]))),
1243
858
  ]),
1244
859
  ]),
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
- ]),
860
+ ...renderGroup('tools'),
861
+ saveBtn('tools'),
1259
862
  ]));
1260
863
  }
1261
864
 
1262
865
  if (tab === 'engines') {
1263
866
  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」补上(见该测试注释)。
867
+ // 固定分组顺序防白名单增删导致面板乱序(test/client.test.js 校验每个开关都有控件)
1274
868
  const groups = ['cache', 'fetch', 'semantic', 'engines', 'net', 'local', 'paid', 'misc'];
1275
- const groupTitle = (group) => t('group' + group.charAt(0).toUpperCase() + group.slice(1));
869
+ const groupTitle = (g) => t('group' + g.charAt(0).toUpperCase() + g.slice(1));
1276
870
  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
- }));
871
+ panel.push(h('input', { key: 'filter', type: 'text', style: S.filterInput, placeholder: t('searchFilterPlaceholder'), value: engineFilter, onChange: (e) => setEngineFilter(e.target.value) }));
1285
872
  const query = engineFilter.trim().toLowerCase();
1286
873
  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')));
874
+ let specs = ENGINE_TOGGLES.filter((s) => s.group === group);
875
+ if (query && !group.toLowerCase().includes(query) && !groupTitle(group).toLowerCase().includes(query)) {
876
+ specs = specs.filter((s) => [s.name, s.zh, s.en, s.hintZh, s.hintEn].some((v) => (v || '').toLowerCase().includes(query)));
1307
877
  }
878
+ if (!specs.length) continue;
879
+ const bools = specs.filter((s) => s.kind === 'bool');
880
+ const fields = specs.filter((s) => s.kind !== 'bool');
881
+ const children = group === 'paid' ? [h('p', { key: 'groupHint', style: S.hint }, t('groupPaidHint'))] : [];
1308
882
  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
- }));
883
+ const suffix = map[spec.name] !== undefined ? '' : (lang === 'en' ? ` (${t('envDefault')})` : `(${t('envDefault')})`);
884
+ 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
885
  }
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
- ]));
886
+ if (fields.length) {
887
+ children.push(h('div', { key: 'fields', style: S.grid }, fields.map((spec) => {
888
+ const cur = envDraft[spec.name] !== undefined ? envDraft[spec.name] : (map[spec.name] !== undefined ? map[spec.name] : (spec.kind === 'num' ? String(spec.def) : ''));
889
+ const isNum = spec.kind === 'num';
890
+ return h(Field, { key: spec.name, label: lang === 'en' ? spec.en : spec.zh, hint: lang === 'en' ? spec.hintEn : spec.hintZh }, h('input', {
891
+ key: 'i', type: isNum ? 'number' : 'text', style: isNum ? S.input : { ...S.input, ...S.mono },
892
+ value: cur, min: isNum ? spec.min : undefined, max: isNum ? spec.max : undefined, step: isNum ? (spec.step ?? 1) : undefined,
893
+ disabled, spellCheck: isNum ? undefined : false, onChange: (e) => setEnvDraft((p) => ({ ...p, [spec.name]: e.target.value })),
894
+ }));
895
+ })));
896
+ 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
897
  }
1365
898
  panel.push(h(Card, { key: group, title: groupTitle(group) }, children));
1366
899
  }
1367
900
  }
1368
901
 
1369
902
  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;
903
+ const q = keyFilter.trim().toLowerCase();
904
+ const list = q
905
+ ? KEYS.filter((e) => [e.ref, e.label, e.en, ...e.engines].some((v) => (v || '').toLowerCase().includes(q)))
906
+ : (showAllKeys ? KEYS : KEYS.filter((e) => e.common));
1374
907
  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')),
908
+ h('input', { key: 'filter', type: 'text', style: S.filterInput, placeholder: t('searchFilterPlaceholder'), value: keyFilter, onChange: (e) => setKeyFilter(e.target.value) }),
909
+ h('span', { key: 'l', style: S.label }, t(q ? 'keysTitle' : 'commonKeys')),
910
+ ...list.map(keyRow),
911
+ q ? null : h('div', { key: 'a', style: S.actions }, [
912
+ h('button', { key: 'more', type: 'button', style: S.btn, onClick: () => setShowAllKeys((p) => !p) }, t(showAllKeys ? 'showLess' : 'showMore')),
1392
913
  props.credentials ? null : h('span', { key: 'u', style: S.sub }, t('keyUnavailable')),
1393
914
  ]),
1394
915
  ]));
1395
916
  }
1396
917
 
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
- }
918
+ if (tab === 'research') panel.push(h(Card, { key: 'research', title: t('researchTitle') }, [...renderGroup('research'), saveBtn('research')]));
919
+ if (tab === 'advanced') panel.push(h(Card, { key: 'adv', title: t('advancedTitle') }, [
920
+ ...renderGroup('advanced'), saveBtn('advanced'), h('div', { key: 'div', style: S.divider }),
921
+ 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'))]),
922
+ ]));
1475
923
 
924
+ const tabs = [['dashboard', 'tabDashboard'], ['access', 'tabAccess'], ['tools', 'tabTools'], ['engines', 'tabEngines'], ['keys', 'tabKeys'], ['research', 'tabResearch'], ['advanced', 'tabAdvanced']];
1476
925
  return h('div', { style: S.wrap }, [
1477
- h('div', { key: 'head', style: { display: 'flex', flexDirection: 'column', gap: 4 } }, [
926
+ h('div', { key: 'head', style: col(4) }, [
1478
927
  h('h2', { key: 't', style: S.title }, t('title')),
1479
928
  h('p', { key: 'i', style: S.hint }, t('intro')),
1480
929
  ]),
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,
930
+ h('div', { key: 'tabs', style: S.tabs }, tabs.map(([id, lk]) => h('button', {
931
+ key: id, type: 'button', style: S.tab(tab === id), onClick: () => setTab(id),
932
+ }, t(lk)))),
933
+ message ? h('p', { style: error ? S.error : S.notice, role: 'status' }, message) : h('p', { style: S.status }, disabled ? t('readonly') : ''),
1491
934
  ...panel,
1492
935
  ]);
1493
936
  }