argo-search 2.15.0 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/AGENTS.md +3 -1
  2. package/README.es.md +32 -5
  3. package/README.ja.md +32 -5
  4. package/README.ko.md +32 -5
  5. package/README.md +73 -19
  6. package/README.zh.md +73 -19
  7. package/SKILL.md +7 -7
  8. package/assets/readme/counts.json +1 -1
  9. package/assets/readme/hero.svg +3 -3
  10. package/assets/readme/hero.template.svg +121 -0
  11. package/assets/readme/proof-routes.svg +17 -16
  12. package/backends/domain_profiles.json +222 -24
  13. package/backends/engine_registry.yaml +26 -2
  14. package/backends/env_passthrough.txt +2 -0
  15. package/backends/quota_profiles.json +23 -3
  16. package/bin/argo +3 -0
  17. package/config.yaml +16 -0
  18. package/docs/CHANGELOG.md +31 -0
  19. package/docs/COMMIT_STANDARD.md +10 -0
  20. package/docs/ENGINE_CATALOG.md +40 -37
  21. package/docs/MCP_SETUP.md +9 -0
  22. package/docs/RELEASE_NOTES_v2.16.0.md +58 -0
  23. package/docs/RELEASE_NOTES_v2.17.0.md +64 -0
  24. package/docs/RELEASING.md +1 -1
  25. package/engines/specs/archive_org.yaml +1 -1
  26. package/engines/specs/carbon_intensity.yaml +1 -1
  27. package/engines/specs/crates.yaml +1 -1
  28. package/engines/specs/crossref.yaml +6 -2
  29. package/engines/specs/crt_sh.yaml +1 -1
  30. package/engines/specs/dblp.yaml +1 -1
  31. package/engines/specs/devto.yaml +1 -1
  32. package/engines/specs/docker_hub.yaml +1 -1
  33. package/engines/specs/europepmc.yaml +1 -1
  34. package/engines/specs/fxtwitter.yaml +1 -1
  35. package/engines/specs/gbfs_nyc.yaml +1 -1
  36. package/engines/specs/gleif.yaml +1 -1
  37. package/engines/specs/gov_regulations.yaml +1 -1
  38. package/engines/specs/hackernews.yaml +2 -0
  39. package/engines/specs/helve.yaml +49 -0
  40. package/engines/specs/hf_datasets.yaml +1 -1
  41. package/engines/specs/hf_papers.yaml +2 -0
  42. package/engines/specs/huggingface.yaml +1 -1
  43. package/engines/specs/keenable.yaml +7 -1
  44. package/engines/specs/linux_do.yaml +63 -0
  45. package/engines/specs/local_crossref.yaml +3 -1
  46. package/engines/specs/local_github.yaml +1 -1
  47. package/engines/specs/local_npm.yaml +6 -0
  48. package/engines/specs/local_openstreetmap.yaml +1 -1
  49. package/engines/specs/maven.yaml +1 -1
  50. package/engines/specs/mdn.yaml +1 -1
  51. package/engines/specs/musicbrainz.yaml +1 -1
  52. package/engines/specs/nasa_images.yaml +1 -1
  53. package/engines/specs/nhtsa_vpic.yaml +6 -3
  54. package/engines/specs/npm.yaml +1 -1
  55. package/engines/specs/nuget.yaml +1 -1
  56. package/engines/specs/nvd.yaml +1 -1
  57. package/engines/specs/openalex.yaml +13 -4
  58. package/engines/specs/openreview.yaml +1 -1
  59. package/engines/specs/polymarket.yaml +1 -1
  60. package/engines/specs/sec_edgar.yaml +1 -1
  61. package/engines/specs/steam.yaml +1 -1
  62. package/engines/specs/vam.yaml +1 -1
  63. package/engines/specs/wikidata.yaml +1 -1
  64. package/engines/specs/wikipedia.yaml +1 -1
  65. package/engines/specs/zhihu_hot_app.yaml +1 -1
  66. package/package.json +3 -1
  67. package/packages/dsh-plugin/README.md +5 -2
  68. package/packages/dsh-plugin/cordis.patch.yml +4 -1
  69. package/packages/dsh-plugin/dsh/client.js +69 -74
  70. package/packages/dsh-plugin/dsh/diagnostics.js +25 -4
  71. package/packages/dsh-plugin/dsh/index.js +115 -21
  72. package/packages/dsh-plugin/dsh/route-guard.js +95 -0
  73. package/packages/dsh-plugin/dsh/runner.js +50 -7
  74. package/packages/dsh-plugin/dsh/wide-research.js +20 -18
  75. package/packages/dsh-plugin/dsh/workbench-client.js +895 -0
  76. package/packages/dsh-plugin/dsh/workbench-io.js +163 -0
  77. package/packages/dsh-plugin/dsh/workbench-md.js +386 -0
  78. package/packages/dsh-plugin/dsh/workbench-search.js +385 -0
  79. package/packages/dsh-plugin/dsh/workbench-suggestions.js +460 -0
  80. package/packages/dsh-plugin/dsh/workbench.js +703 -0
  81. package/packages/dsh-plugin/icon.svg +23 -0
  82. package/packages/dsh-plugin/package.json +6 -3
  83. package/packages/dsh-plugin/scripts/sync-local.mjs +4 -2
  84. package/packages/dsh-plugin/scripts/sync-local.sh +4 -2
  85. package/packages/dsh-plugin/test/client.test.js +26 -0
  86. package/packages/dsh-plugin/test/diagnostics.test.js +5 -2
  87. package/packages/dsh-plugin/test/index.test.js +150 -1
  88. package/packages/dsh-plugin/test/workbench-concurrency.test.js +98 -0
  89. package/packages/dsh-plugin/test/workbench.test.js +420 -0
  90. package/scripts/adaptive.py +13 -11
  91. package/scripts/argo_paths.py +2 -2
  92. package/scripts/badcase_ledger.py +9 -0
  93. package/scripts/browser_auth.py +178 -4
  94. package/scripts/cache.py +69 -70
  95. package/scripts/check_commit_report.py +46 -0
  96. package/scripts/chrome_cdp.py +71 -0
  97. package/scripts/circuit_breaker.py +91 -13
  98. package/scripts/config_cache.py +23 -10
  99. package/scripts/daemon.py +14 -2
  100. package/scripts/engine_add.py +45 -0
  101. package/scripts/engine_dispatch.py +32 -49
  102. package/scripts/engine_env.py +13 -4
  103. package/scripts/engine_failure.py +33 -0
  104. package/scripts/engine_fingerprint.py +114 -0
  105. package/scripts/engine_health.py +130 -0
  106. package/scripts/engine_states.py +50 -0
  107. package/scripts/engines_base.py +31 -19
  108. package/scripts/engines_builders_archive.py +4 -3
  109. package/scripts/engines_builders_batch11.py +2 -1
  110. package/scripts/engines_builders_batch13.py +4 -3
  111. package/scripts/engines_builders_batch14.py +2 -1
  112. package/scripts/engines_builders_batch15.py +2 -1
  113. package/scripts/engines_builders_batch9.py +2 -2
  114. package/scripts/engines_builders_cn.py +7 -7
  115. package/scripts/engines_builders_data.py +12 -11
  116. package/scripts/engines_builders_data_macro.py +5 -4
  117. package/scripts/engines_builders_dsh.py +2 -1
  118. package/scripts/engines_builders_feeds.py +34 -19
  119. package/scripts/engines_builders_finance.py +2 -1
  120. package/scripts/engines_builders_intl.py +3 -2
  121. package/scripts/engines_builders_media.py +59 -12
  122. package/scripts/engines_builders_science.py +8 -7
  123. package/scripts/engines_builders_search.py +19 -8
  124. package/scripts/engines_builders_skill.py +2 -1
  125. package/scripts/engines_builders_tech.py +19 -19
  126. package/scripts/engines_builders_weather.py +9 -4
  127. package/scripts/engines_fields.py +23 -0
  128. package/scripts/engines_http.py +50 -1
  129. package/scripts/engines_mcp.py +28 -6
  130. package/scripts/evidence_grounding.py +182 -0
  131. package/scripts/evidence_loop.py +15 -1
  132. package/scripts/extend_route_labels.py +6 -0
  133. package/scripts/fetch_browser.py +25 -10
  134. package/scripts/fetch_jina.py +98 -0
  135. package/scripts/fetch_v3.py +52 -93
  136. package/scripts/gate_manifest_check.py +75 -0
  137. package/scripts/gen_readme_art.py +264 -0
  138. package/scripts/image_vision/vision_probe +0 -0
  139. package/scripts/install.sh +2 -0
  140. package/scripts/matrix_search_eval.py +8 -10
  141. package/scripts/mcp_transport.py +33 -9
  142. package/scripts/numeric_verify.py +12 -2
  143. package/scripts/output_transparency.py +3 -0
  144. package/scripts/pre-commit +57 -8
  145. package/scripts/query_operators.py +229 -1
  146. package/scripts/quota.py +46 -63
  147. package/scripts/recovery.py +19 -16
  148. package/scripts/recovery_runner.py +29 -10
  149. package/scripts/redskill/redskill_engine.py +2 -1
  150. package/scripts/release.py +16 -1
  151. package/scripts/research_gates.py +85 -1
  152. package/scripts/route.py +8 -0
  153. package/scripts/route_combo.py +24 -3
  154. package/scripts/route_policy.py +1 -1
  155. package/scripts/search_attribution.py +20 -0
  156. package/scripts/search_entry.py +27 -0
  157. package/scripts/search_output.py +18 -7
  158. package/scripts/search_pipeline.py +3 -3
  159. package/scripts/semantic_evidence.py +20 -11
  160. package/scripts/serp_guard.py +13 -1
  161. package/scripts/settings_page.py +1 -0
  162. package/scripts/single_flight.py +1 -1
  163. package/scripts/social_engines/hackernews_engine.py +2 -1
  164. package/scripts/social_engines/reddit_engine.py +2 -1
  165. package/scripts/social_engines/zhihu_engine.py +2 -1
  166. package/scripts/source_audit.py +42 -7
  167. package/scripts/source_discovery.py +611 -0
  168. package/scripts/sync_backends.py +45 -0
  169. package/scripts/usage_log.py +24 -9
  170. package/scripts/watch.py +3 -3
  171. package/scripts/zhihu_quota.py +2 -1
  172. package/sub-skills/argo-wide-research/SKILL.md +7 -5
  173. package/sub-skills/ego-search/{SKILL.md → README.md} +24 -47
  174. package/sub-skills/ego-search/scripts/ego_search.py +195 -19
  175. package/sub-skills/ego-search/scripts/pacing.py +291 -0
  176. package/sub-skills/ego-search/scripts/quality.py +262 -6
  177. package/sub-skills/ego-search/scripts/runtime.py +7 -1
  178. package/sub-skills/ego-search/scripts/site_profiles.py +157 -0
  179. package/sub-skills/ego-search/scripts/webbridge_adapter.py +7 -1
  180. package/sub-skills/js-run/{SKILL.md → README.md} +3 -20
  181. package/sub-skills/local-search/{SKILL.md → README.md} +3 -8
  182. package/sub-skills/local-search/engine_registry.py +32 -7
  183. package/sub-skills/local-seek/SKILL.md +20 -22
@@ -1,16 +1,6 @@
1
- /*
2
- * @taxueseek/argo-dsh — 浏览器端设置页(无需构建步骤)
3
- *
4
- * 由 DSH ModuleLoader 以 lazy-CJS 方式加载:工厂函数里只 require('react'),
5
- * 其余能力(slots / configForms / remote.credentials / locale)全部由宿主
6
- * 通过 cordis 服务注入。设置值走 configForms(settings namespace =
7
- * 'wide-research'),密钥走 credentials 域——两者都不经过插件配置文件,
8
- * 密钥更不会回显明文。
9
- *
10
- * 注册两个位置:
11
- * settings.section —— 设置弹窗左侧一级菜单(主入口)
12
- * plugins.item —— 设置 > 插件 页里的卡片(摘要 + 同一面板)
13
- */
1
+ /* @taxueseek/argo-dsh — 浏览器端设置页与工作台入口(无需构建步骤)
2
+ * 由 DSH ModuleLoader 以 lazy-CJS 加载,注册 settings.section / plugins.item,
3
+ * 并在浏览器环境按需挂载 /argo/workbench-client.js 搜索分析工作台。 */
14
4
  window.__ModuleLoader__.load({
15
5
  id: '@taxueseek/argo-dsh',
16
6
  factory: (require) => {
@@ -202,6 +192,7 @@ window.__ModuleLoader__.load({
202
192
  { ref: "FOURGET_URL", common: false, label: "4get 极简元搜索", en: "4get", engines: ["fourget"] },
203
193
  { ref: "GEMINI_API_KEY", common: false, label: "语义证据·Gemini 决策", en: "Semantic Evidence · Gemini Decision", engines: [] },
204
194
  { ref: "GITHUB_TOKEN", common: false, label: "GitHub", en: "GitHub", engines: ["github"] },
195
+ { ref: "HELVE_API_KEY", common: false, label: "Helve", en: "Helve", engines: ["helve"] },
205
196
  { ref: "KEENABLE_API_KEY", common: false, label: "Keenable", en: "Keenable", engines: ["keenable"] },
206
197
  { ref: "METASO_API_KEY", common: false, label: "秘塔", en: "Metaso", engines: ["metaso", "metaso_doc", "metaso_image", "metaso_podcast", "metaso_scholar", "metaso_video"] },
207
198
  { ref: "OCTEN_API_KEY", common: false, label: "Octen", en: "Octen", engines: ["octen"] },
@@ -319,21 +310,9 @@ window.__ModuleLoader__.load({
319
310
  };
320
311
 
321
312
  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
- },
313
+ { id: 'fast', titleKey: 'presetFast', descKey: 'presetFastDesc', badge: '15s 超时', badgeColor: 'blue', env: { ARGO_TFIDF_RERANK: '0', ARGO_NUMBER_CROSSCHECK: '0', ARGO_PAID_SEARCH: 'off', ARGO_ADAPTIVE_GRACE: '1', ARGO_SERIAL_STAGGER_S: '0.5' }, fields: { searchTimeoutMs: 15000, fetchTimeoutMs: 15000 } },
314
+ { id: 'standard', titleKey: 'presetStandard', descKey: 'presetStandardDesc', badge: '标准生产', badgeColor: 'green', env: { ARGO_TFIDF_RERANK: '1', ARGO_NUMBER_CROSSCHECK: '1', ARGO_MINHASH_DEDUPE: '1', ARGO_PAID_SEARCH: 'auto', ARGO_ADAPTIVE_GRACE: '1', ARGO_SERIAL_STAGGER_S: '0.8' }, fields: { searchTimeoutMs: 30000, fetchTimeoutMs: 25000 } },
315
+ { id: 'deep', titleKey: 'presetDeep', descKey: 'presetDeepDesc', badge: '深度核验', badgeColor: 'blue', env: { ARGO_TFIDF_RERANK: '1', ARGO_NUMBER_CROSSCHECK: '1', ARGO_MINHASH_DEDUPE: '1', ARGO_SEMANTIC_EVIDENCE: '1', ARGO_ADAPTIVE_GRACE: '1', ARGO_PAID_SEARCH: 'auto' }, fields: { searchTimeoutMs: 45000, fetchTimeoutMs: 35000, nativeTimeoutMs: 60000 } },
337
316
  ];
338
317
 
339
318
  const col = (gap) => ({ display: 'flex', flexDirection: 'column', gap });
@@ -518,7 +497,7 @@ window.__ModuleLoader__.load({
518
497
  if (typeof offRoute === 'function') offs.push(offRoute);
519
498
  }
520
499
  return () => { for (const off of offs) off(); };
521
- }, [state]);
500
+ }, [props.view, props.remote]);
522
501
 
523
502
  const edit = (key, text) => { dirty.current.add(key); setDraft((p) => ({ ...p, [key]: text })); };
524
503
  const report = (ok, text) => { setError(!ok); setMessage(text); };
@@ -575,11 +554,13 @@ window.__ModuleLoader__.load({
575
554
  void setField('nativeTools', ordered);
576
555
  };
577
556
 
578
- const applyToolPreset = async (tools) => {
557
+ const applyToolPreset = (tools) => runSave('nativeTools', async () => {
579
558
  const ordered = TOOLS.map((tool) => tool.id).filter((tid) => tools.includes(tid));
580
559
  for (const extra of tools) if (!ordered.includes(extra)) ordered.push(extra);
581
- await props.set('nativeTools', ordered);
582
- };
560
+ const ok = await props.set('nativeTools', ordered);
561
+ report(ok, ok ? t('saved') : t('refused'));
562
+ return ok;
563
+ });
583
564
 
584
565
  const mutateKey = async (ref, action) => {
585
566
  setKeyBusy(ref);
@@ -668,7 +649,13 @@ window.__ModuleLoader__.load({
668
649
  try {
669
650
  const ok = await writeEnvLines(updates);
670
651
  report(ok, ok ? t('saved') : t('refused'));
671
- if (ok) setEnvDraft({});
652
+ if (ok) {
653
+ setEnvDraft((prev) => {
654
+ const next = { ...prev };
655
+ for (const spec of specs) delete next[spec.name];
656
+ return next;
657
+ });
658
+ }
672
659
  } catch (cause) { report(false, cause && cause.message ? cause.message : String(cause)); }
673
660
  finally { setEnvBusy(''); }
674
661
  };
@@ -811,10 +798,16 @@ window.__ModuleLoader__.load({
811
798
  : h('p', { key: 'hint', style: S.hint }, t('routeHealthFallback')),
812
799
  ]));
813
800
  panel.push(h(Card, { key: 'presets', title: t('presetTitle'), hint: t('presetHint') }, [
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
- ]))),
801
+ h('div', { key: 'grid', style: S.presetGrid }, PRESETS.map((p) => {
802
+ const cur = liveValue();
803
+ const em = envMap();
804
+ const isMatch = Object.entries(p.fields || {}).every(([k, v]) => cur[k] === v)
805
+ && Object.entries(p.env || {}).every(([k, v]) => String(em[k] ?? '') === String(v));
806
+ return h('div', { key: p.id, style: S.presetCard(isMatch), onClick: () => { void applyPreset(p); } }, [
807
+ h('div', { key: 't', style: rowBetween() }, [h('span', { key: 'title', style: S.label }, t(p.titleKey)), h('span', { key: 'badge', style: S.badge(p.badgeColor) }, p.badge)]),
808
+ h('span', { key: 'd', style: S.sub }, t(p.descKey)),
809
+ ]);
810
+ })),
818
811
  ]));
819
812
  panel.push(h(Card, { key: 'matrix', title: t('matrixTitle'), hint: t('matrixHint') }, [
820
813
  h('div', { key: 'grid', style: S.matrixGrid }, CORE_ENGINES.map((engine) => {
@@ -937,55 +930,57 @@ window.__ModuleLoader__.load({
937
930
 
938
931
  const inject = ['slots', 'locale', 'configForms', 'remote', 'remote.credentials'];
939
932
 
933
+ // 局部 ErrorBoundary:设置页渲染异常时降级为局部报错卡,绝不拖垮宿主界面。
934
+ const PanelBoundary = typeof react.Component === 'function'
935
+ ? class ArgoErrorBoundary extends react.Component {
936
+ constructor(p) { super(p); this.state = { error: null }; }
937
+ static getDerivedStateFromError(error) { return { error }; }
938
+ render() {
939
+ if (this.state.error) {
940
+ return h('div', { style: { padding: 12, color: '#dc2626', fontSize: 12, whiteSpace: 'pre-wrap' } },
941
+ '[argo-dsh] 设置页渲染异常:' + String(this.state.error?.message ?? this.state.error));
942
+ }
943
+ return this.props.children;
944
+ }
945
+ }
946
+ : null;
947
+
948
+ function SafeArgoPanel(props) {
949
+ return PanelBoundary ? h(PanelBoundary, null, h(ArgoPanel, props)) : h(ArgoPanel, props);
950
+ }
951
+
952
+ // plugins.item 仅渲染一行只读摘要,完整 7-Tab 配置收敛至唯一 settings.section 入口。
953
+ function PluginSummaryItem(props) {
954
+ return SafeArgoPanel({ ...props, view: 'summary' });
955
+ }
956
+
940
957
  function apply(ctx) {
941
958
  const form = ctx.configForms.get(NS);
942
959
  const locale = ctx.locale ?? (typeof ctx.get === 'function' ? ctx.get('locale') : undefined);
943
960
  const credentials = ctx.remote ? ctx.remote.credentials : undefined;
944
961
  const label = () => 'Argo 搜索';
945
-
946
- const injected = () => ({
947
- hooks: { argoForm: form },
948
- set: (field, next) => form.set(field, next),
949
- mutate: (ops) => form.mutate(ops),
950
- credentials,
951
- remote: ctx.remote,
952
- locale,
953
- });
962
+ const injected = () => ({ hooks: { argoForm: form }, set: (f, n) => form.set(f, n), mutate: (ops) => form.mutate(ops), credentials, remote: ctx.remote, locale });
954
963
 
955
964
  ctx.effect(() => ctx.configForms.whileServed([NS], () => {
956
965
  const offs = [
957
- ctx.slots.inject('settings.section', () => ctx.slots.register({
958
- name: 'settings.section',
959
- id: SECTION_ID,
960
- order: 26,
961
- label,
962
- inject: injected,
963
- }, ArgoPanel)),
964
- ctx.slots.inject('plugins.item', () => ctx.slots.register({
965
- name: 'plugins.item',
966
- id: SECTION_ID,
967
- order: 50,
968
- label,
969
- inject: injected,
970
- }, ArgoPanel)),
966
+ ctx.slots.inject('settings.section', () => ctx.slots.register({ name: 'settings.section', id: SECTION_ID, order: 26, label, inject: injected }, SafeArgoPanel)),
967
+ ctx.slots.inject('plugins.item', () => ctx.slots.register({ name: 'plugins.item', id: SECTION_ID, order: 50, label, inject: injected }, PluginSummaryItem)),
971
968
  ];
972
- return () => {
973
- for (const off of offs) if (typeof off === 'function') off();
974
- };
969
+ return () => { for (const off of offs) if (typeof off === 'function') off(); };
975
970
  }), 'argo-dsh: settings page');
976
- }
977
971
 
978
- exports.apply = apply;
979
- exports.inject = inject;
980
- exports.ArgoPanel = ArgoPanel;
981
- // 静态数据导出供漂移门禁核对:TOOLS 必须与 native-tools.mjs(mcp_tools.py
982
- // 生成产物)同名同集合,ENGINE_TOGGLES 必须与 specs.js 的 ARGO_ENV_SPECS
983
- // 同名同集合——两边任何一边增删而另一边没跟上,测试即红。
984
- exports.TOOLS = TOOLS;
985
- exports.TOOL_GROUPS = TOOL_GROUPS;
986
- exports.ENGINE_TOGGLES = ENGINE_TOGGLES;
987
- exports.KEYS = KEYS;
972
+ if (typeof window !== 'undefined' && typeof document !== 'undefined' && ctx.slots) {
973
+ ctx.effect(() => {
974
+ let disposed = false, unmount = null;
975
+ import('/argo/workbench-client.js').then((mod) => {
976
+ if (!disposed && typeof mod?.mountArgoWorkbench === 'function') unmount = mod.mountArgoWorkbench(ctx, react);
977
+ }).catch(() => {});
978
+ return () => { disposed = true; if (typeof unmount === 'function') unmount(); };
979
+ }, 'argo-dsh: workbench');
980
+ }
981
+ }
988
982
 
983
+ Object.assign(exports, { apply, inject, ArgoPanel, SafeArgoPanel, PanelBoundary, TOOLS, TOOL_GROUPS, ENGINE_TOGGLES, KEYS });
989
984
  return module.exports;
990
985
  }
991
986
  });
@@ -10,7 +10,29 @@ import { homedir } from 'node:os'
10
10
  import { join } from 'node:path'
11
11
 
12
12
  const MAX_BYTES = 1024 * 1024 // 显式读取上限 1MB,防超大日志文件撑爆内存
13
- const BYTE_LIMIT_GUARD = 'maxBytes guard: 1024 * 1024'
13
+
14
+ async function readTailUtf8(filePath, maxBytes) {
15
+ let fh
16
+ try {
17
+ fh = await fs.open(filePath, 'r')
18
+ const { size } = await fh.stat()
19
+ if (size <= 0) return ''
20
+ const len = Math.min(size, maxBytes)
21
+ const offset = size - len
22
+ const buf = Buffer.allocUnsafe(len)
23
+ const { bytesRead } = await fh.read(buf, 0, len, offset)
24
+ const text = buf.subarray(0, bytesRead).toString('utf8')
25
+ if (offset > 0) {
26
+ const firstNl = text.indexOf('\n')
27
+ return firstNl >= 0 ? text.slice(firstNl + 1) : text
28
+ }
29
+ return text
30
+ } finally {
31
+ if (fh) {
32
+ try { await fh.close() } catch { /* ignore */ }
33
+ }
34
+ }
35
+ }
14
36
 
15
37
  /**
16
38
  * 解析 argo 运行时状态目录,遵循 argo_paths.py 跨平台约定:
@@ -52,8 +74,7 @@ export async function getRouteHealth(stateDir, limit = 10) {
52
74
  try {
53
75
  const routePath = join(dir, 'usage_log', 'route.jsonl')
54
76
  if (existsSync(routePath)) {
55
- const text = await fs.readFile(routePath, 'utf8')
56
- const truncated = text.length > MAX_BYTES ? text.slice(-MAX_BYTES) : text
77
+ const truncated = await readTailUtf8(routePath, MAX_BYTES)
57
78
  const lines = truncated.split('\n').filter(Boolean)
58
79
  for (const line of lines) {
59
80
  try {
@@ -114,7 +135,7 @@ export function getMcpPoolStats(pool = []) {
114
135
  const connections = pool.map((conn, index) => ({
115
136
  index,
116
137
  load: typeof conn.load === 'function' ? conn.load() : 0,
117
- hasProcess: Boolean(conn.proc ?? true),
138
+ hasProcess: Boolean(conn.proc),
118
139
  }))
119
140
 
120
141
  const totalLoad = connections.reduce((sum, item) => sum + item.load, 0)
@@ -44,7 +44,9 @@ import {
44
44
  resetEnvResolver,
45
45
  makeNativeTool,
46
46
  disposeSharedMcp,
47
+ searchViaArgoMCP,
47
48
  fetchViaArgo,
49
+ resolveEntry,
48
50
  mapArgoToWebResult,
49
51
  classifyFetchError,
50
52
  } from './runner.js'
@@ -57,6 +59,10 @@ import {
57
59
  getRouteHealth,
58
60
  } from './diagnostics.js'
59
61
 
62
+ import {
63
+ registerArgoWorkbench,
64
+ } from './workbench.js'
65
+
60
66
  /**
61
67
  * Schemastery 是可选依赖:装进 DSH profile 后由宿主依赖树提供,仓内单测
62
68
  * 没有 node_modules。导入失败时 Config 保持 undefined,宿主按「无 schema」
@@ -216,12 +222,87 @@ function runEffect(ctx, fn) {
216
222
 
217
223
  const asString = (value, fallback = '') => typeof value === 'string' ? value.trim() : fallback
218
224
 
219
- // 注入执行器的动态环境变量解析逻辑
220
- setEnvResolver(async (options, config) => {
221
- return resolveArgoEnv(config, options)
222
- })
225
+ const DEEPSEEK_MODEL_ROUTES = new Set(['deepseek-official', 'deepseek-account'])
226
+
227
+ export function capWebSearchSources(result, maxResults) {
228
+ if (!result || !Array.isArray(result.sources)) return result
229
+ if (typeof maxResults !== 'number' || !Number.isFinite(maxResults) || maxResults < 0) return result
230
+ if (result.sources.length <= maxResults) return result
231
+ return {
232
+ ...result,
233
+ sources: result.sources.slice(0, maxResults),
234
+ truncated: true,
235
+ }
236
+ }
237
+
238
+ function readConfiguredSearchProvider(web) {
239
+ try {
240
+ const raw = typeof web?.config?.searchProvider?.get === 'function'
241
+ ? web.config.searchProvider.get()
242
+ : web?.config?.searchProvider
243
+ const configured = typeof raw === 'string' && raw !== '' ? raw : web?.searchProviderEnv
244
+ return typeof configured === 'string' && configured !== '' ? configured : undefined
245
+ } catch {
246
+ return undefined
247
+ }
248
+ }
249
+
250
+ /**
251
+ * DSH v0.2.2-rc.5 起,未 pin `web.searchProvider` 时宿主默认把 DeepSeek 路由
252
+ * 交给免费的 `deepseek-official` 服务端搜索,把其他路由写死回落到按次计费的
253
+ * `deepseek-search-api`。这里在不抢占配置位的前提下按 `llmProvider` 透明分流:
254
+ * DeepSeek 路由透传宿主原生搜索;其余路由改由 argo 承接,用户显式 pin 时让位。
255
+ */
256
+ export function installWebSearchRouteDecorator(ctx, web, config, runArgoSearch) {
257
+ if (!web || typeof web.search !== 'function') return undefined
258
+
259
+ const shouldRouteToArgo = (llmProvider) =>
260
+ config.searchProviderEnabled !== false
261
+ && readConfiguredSearchProvider(web) === undefined
262
+ && !DEEPSEEK_MODEL_ROUTES.has(llmProvider)
263
+
264
+ const hadOwnSearch = Object.prototype.hasOwnProperty.call(web, 'search')
265
+ const rawOrigSearch = web.search
266
+ const wrappedSearch = async (request, signal) => {
267
+ if (shouldRouteToArgo(request?.llmProvider)) {
268
+ return capWebSearchSources(await runArgoSearch(request, signal), request?.maxResults)
269
+ }
270
+ return rawOrigSearch.call(web, request, signal)
271
+ }
272
+ web.search = wrappedSearch
273
+
274
+ const hasSearchReady = typeof web.searchReady === 'function'
275
+ const hadOwnSearchReady = hasSearchReady && Object.prototype.hasOwnProperty.call(web, 'searchReady')
276
+ const rawOrigSearchReady = hasSearchReady ? web.searchReady : undefined
277
+ let wrappedSearchReady
278
+ if (hasSearchReady) {
279
+ wrappedSearchReady = async (llmProvider) => {
280
+ if (shouldRouteToArgo(llmProvider)) return true
281
+ return rawOrigSearchReady.call(web, llmProvider)
282
+ }
283
+ web.searchReady = wrappedSearchReady
284
+ }
285
+
286
+ const restore = () => {
287
+ if (web.search === wrappedSearch) {
288
+ if (hadOwnSearch) web.search = rawOrigSearch
289
+ else delete web.search
290
+ }
291
+ if (hasSearchReady && web.searchReady === wrappedSearchReady) {
292
+ if (hadOwnSearchReady) web.searchReady = rawOrigSearchReady
293
+ else delete web.searchReady
294
+ }
295
+ }
296
+ runEffect(ctx, () => restore)
297
+ return restore
298
+ }
299
+
300
+ const _envResolverImpl = async (options, config) => resolveArgoEnv(config, options)
301
+ // 模块导入时预注册,apply() 内也会重注册以保证同进程 HMR 重载不丢失
302
+ setEnvResolver(_envResolverImpl)
223
303
 
224
304
  export function apply(ctx, providedConfig = {}) {
305
+ setEnvResolver(_envResolverImpl)
225
306
  const config = liveConfig(providedConfig)
226
307
  const toolName = asString(config.toolName, DEFAULTS.toolName)
227
308
  const providerName = asString(config.provider, DEFAULTS.provider)
@@ -242,7 +323,7 @@ export function apply(ctx, providedConfig = {}) {
242
323
  }
243
324
  }
244
325
 
245
- for (const ref of asStringArray(config.keyRefs, 20)) {
326
+ for (const ref of asStringArray(config.keyRefs, 64)) {
246
327
  if (!CREDENTIAL_REF_PATTERN.test(ref)) {
247
328
  throw new Error(`argo-dsh: keyRefs entry "${ref}" must be a POSIX-style identifier (e.g. DEEPSEEK_API_KEY)`)
248
329
  }
@@ -286,28 +367,36 @@ export function apply(ctx, providedConfig = {}) {
286
367
 
287
368
  const web = ctx.get?.('web') ?? ctx.web
288
369
  if (web && typeof web.registerSearchProvider === 'function') {
370
+ const runArgoSearch = (request, signal) => {
371
+ const entry = resolveEntry(config)
372
+ return searchViaArgoMCP(request.query, request.maxResults, signal, {
373
+ command: entry.command,
374
+ args: entry.args,
375
+ timeoutMs: config.searchTimeoutMs,
376
+ idleMs: config.searchIdleMs,
377
+ max: config.searchConcurrency,
378
+ config,
379
+ // issue #41:显式带上宿主凭证服务,否则池内连接 envResolver 解析
380
+ // keyRefs 时 provider 为 undefined,所有需 key 引擎静默 skipped。
381
+ credentials: hostCredentials,
382
+ })
383
+ }
289
384
  web.registerSearchProvider({
290
385
  id: asString(config.searchProviderId, DEFAULTS.searchProviderId),
386
+ title: 'Argo Multi-Engine Search',
387
+ description: '多引擎融合搜索、证据核验与中文增强(通过本机 argo-search 路由)',
291
388
  available: () => config.searchProviderEnabled !== false,
292
- search: (request, signal) => {
293
- const entry = resolveEntry(config)
294
- return searchViaArgoMCP(request.query, request.maxResults, signal, {
295
- command: entry.command,
296
- args: entry.args,
297
- timeoutMs: config.searchTimeoutMs,
298
- idleMs: config.searchIdleMs,
299
- max: config.searchConcurrency,
300
- config,
301
- // issue #41:显式带上宿主凭证服务,否则池内连接 envResolver 解析
302
- // keyRefs 时 provider 为 undefined,所有需 key 引擎静默 skipped。
303
- credentials: hostCredentials,
304
- })
305
- },
389
+ ready: () => config.searchProviderEnabled !== false,
390
+ search: runArgoSearch,
306
391
  })
392
+ installWebSearchRouteDecorator(ctx, web, config, runArgoSearch)
307
393
  if (typeof web.registerFetchProvider === 'function') {
308
394
  web.registerFetchProvider({
309
395
  id: asString(config.fetchProviderId, DEFAULTS.fetchProviderId),
396
+ title: 'Argo Web Fetch',
397
+ description: '多级降级网页全文提取与反爬绕过(通过本机 argo-search)',
310
398
  available: () => config.fetchProviderEnabled !== false,
399
+ ready: () => config.fetchProviderEnabled !== false,
311
400
  fetch: (request, signal) => {
312
401
  const entry = resolveEntry(config)
313
402
  return fetchViaArgo(request.url, signal, {
@@ -328,10 +417,14 @@ export function apply(ctx, providedConfig = {}) {
328
417
 
329
418
  const nativeRegistrations = new Map()
330
419
  // 路由观测推送:原生工具执行后读 argo 使用日志,经 remote 事件推给设置面板。
331
- // 失败静默(诊断是增值,不是依赖);无 remote 事件总线时跳过。
420
+ // 节流 3s 避免高频搜索连续读盘;失败静默,无 remote 事件总线时跳过。
421
+ let lastRouteEmitAt = 0
332
422
  const emitRouteHealth = async () => {
333
423
  try {
334
424
  if (!ctx.remote || typeof ctx.remote.$emit !== 'function') return
425
+ const now = Date.now()
426
+ if (now - lastRouteEmitAt < 3000) return
427
+ lastRouteEmitAt = now
335
428
  const data = await getRouteHealth()
336
429
  if (Array.isArray(data.samples) && data.samples.length > 0) {
337
430
  ctx.remote.$emit('route-health/updated', data)
@@ -370,7 +463,6 @@ export function apply(ctx, providedConfig = {}) {
370
463
  }
371
464
  nativeRegistrations.clear()
372
465
  resetEnvResolver()
373
- disposeSharedMcp()
374
466
  })
375
467
 
376
468
  ctx.tools.register(createWideResearchTool(ctx, config, {
@@ -396,5 +488,7 @@ export function apply(ctx, providedConfig = {}) {
396
488
  })
397
489
  } catch { /* ignore */ }
398
490
 
491
+ registerArgoWorkbench(ctx, config, () => readHostCredentials(ctx))
492
+
399
493
  return { childIds, syncNativeTools }
400
494
  }
@@ -0,0 +1,95 @@
1
+ /*
2
+ * @taxueseek/argo-dsh — 控制面路由安全围栏(TCP Peer 主防线 + Host/Origin 纵深)
3
+ *
4
+ * 仅允许本机回环对端访问控制面接口:
5
+ * 1. 当存在底层 TCP socket 时,以 req.socket.remoteAddress 为唯一主判据
6
+ * (无法被客户端伪造,绝不信任 X-Forwarded-For);
7
+ * 2. 叠加 Host 与 Origin 的回环/同源校验,防御本机浏览器的 DNS Rebinding。
8
+ */
9
+
10
+ const IPV4_LOOPBACK_RE = /^127\.(?:25[0-5]|2[0-4]\d|1?\d?\d)\.(?:25[0-5]|2[0-4]\d|1?\d?\d)\.(?:25[0-5]|2[0-4]\d|1?\d?\d)$/
11
+
12
+ export function isLoopbackAddress(addr) {
13
+ if (typeof addr !== 'string') return false
14
+ const raw = addr.trim().toLowerCase()
15
+ if (!raw) return false
16
+ if (raw === '::1' || raw === 'localhost') return true
17
+ if (IPV4_LOOPBACK_RE.test(raw)) return true
18
+ if (raw.startsWith('::ffff:')) {
19
+ return IPV4_LOOPBACK_RE.test(raw.slice(7))
20
+ }
21
+ return false
22
+ }
23
+
24
+ export function extractHostname(hostHeader) {
25
+ if (typeof hostHeader !== 'string' || !hostHeader.trim()) return ''
26
+ try {
27
+ return new URL(`http://${hostHeader.trim()}`).hostname.toLowerCase()
28
+ } catch {
29
+ return ''
30
+ }
31
+ }
32
+
33
+ export function isLoopbackHost(hostHeader) {
34
+ const host = extractHostname(hostHeader)
35
+ if (!host) return false
36
+ if (host === 'localhost' || host === '[::1]' || host === '::1') return true
37
+ return IPV4_LOOPBACK_RE.test(host)
38
+ }
39
+
40
+ export function checkLoopbackAndOrigin(ctx, req) {
41
+ const peer = req?.socket?.remoteAddress ?? req?.connection?.remoteAddress ?? req?.remoteAddress
42
+ if (peer !== undefined && peer !== null && peer !== '') {
43
+ if (!isLoopbackAddress(String(peer))) return false
44
+ } else if (!isLoopbackHost(req?.headers?.host)) {
45
+ return false
46
+ }
47
+
48
+ const hostHeader = req?.headers?.host
49
+ if (hostHeader && !isLoopbackHost(hostHeader)) {
50
+ const expected = ctx?.webServer?.getOrigin?.()
51
+ if (!expected) return false
52
+ try {
53
+ const expectedHost = new URL(expected).hostname.toLowerCase()
54
+ if (extractHostname(hostHeader) !== expectedHost) return false
55
+ } catch {
56
+ return false
57
+ }
58
+ }
59
+
60
+ const origin = req?.headers?.origin
61
+ if (!origin) return true
62
+ try {
63
+ const expected = ctx?.webServer?.getOrigin?.()
64
+ if (expected && origin === expected) return true
65
+ const parsed = new URL(origin)
66
+ return isLoopbackAddress(parsed.hostname)
67
+ } catch {
68
+ return false
69
+ }
70
+ }
71
+
72
+ /** 查询登录态 Profile 列表,并对冷启动未核验站点后台静默触发一次活体复核(60s 缓存)。 */
73
+ export async function resolveAuthStatusWithBgVerify({ runCli, verifyCache, inflight, allowVerify = true }) {
74
+ let profiles = []
75
+ try {
76
+ const out = await runCli(['auth', 'status', '--json'])
77
+ profiles = Array.isArray(out?.profiles) ? out.profiles : []
78
+ } catch {
79
+ profiles = []
80
+ }
81
+ const now = Date.now()
82
+ return profiles.map((p) => {
83
+ const site = String(p?.site || '')
84
+ const cached = verifyCache.get(site)
85
+ const fresh = cached && (now - cached.ts < 60_000) ? cached.data : null
86
+ if (site && !fresh && !inflight.has(site) && allowVerify) {
87
+ inflight.add(site)
88
+ runCli(['auth', 'verify', site, '--json'])
89
+ .then((v) => { verifyCache.set(site, { ts: Date.now(), data: v }) })
90
+ .catch(() => {})
91
+ .finally(() => { inflight.delete(site) })
92
+ }
93
+ return { ...p, verification: fresh || { pending: Boolean(site) } }
94
+ })
95
+ }
@@ -80,6 +80,7 @@ export const DEFAULTS = Object.freeze({
80
80
  'FOURGET_URL',
81
81
  'GEMINI_API_KEY',
82
82
  'GITHUB_TOKEN',
83
+ 'HELVE_API_KEY',
83
84
  'KEENABLE_API_KEY',
84
85
  'METASO_API_KEY',
85
86
  'OCTEN_API_KEY',
@@ -240,7 +241,7 @@ export function createMcpConnection(options) {
240
241
  proc.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n')
241
242
  } catch (err) {
242
243
  pending.delete(id)
243
- rej(err)
244
+ entry.rej(err)
244
245
  }
245
246
  })
246
247
  const result = chain.then(run)
@@ -295,8 +296,9 @@ export function createMcpConnection(options) {
295
296
  return initPromise
296
297
  },
297
298
  request: (method, params, timeoutMs = 0) => {
299
+ const p = send(method, params, timeoutMs)
298
300
  if (claims > 0) claims -= 1
299
- return send(method, params, timeoutMs)
301
+ return p
300
302
  },
301
303
  claim: () => {
302
304
  claims += 1
@@ -361,10 +363,13 @@ export async function acquireMcp(options, signal) {
361
363
  if (mcpPool.length >= max) throw err
362
364
  }
363
365
  }
366
+ const envCfg = (options.config && ('keyRefs' in options.config || 'argoEnv' in options.config))
367
+ ? options.config
368
+ : undefined
364
369
  if (mcpPool.length < max) {
365
370
  const conn = createMcpConnection({
366
371
  ...options,
367
- envResolver: () => resolveEnv(options),
372
+ envResolver: () => resolveEnv(options, envCfg),
368
373
  configKey: targetConfigKey,
369
374
  })
370
375
  mcpPool.push(conn)
@@ -378,7 +383,29 @@ export async function acquireMcp(options, signal) {
378
383
  }
379
384
  return conn
380
385
  }
381
- const least = mcpPool.reduce((a, b) => (a.load() <= b.load() ? a : b))
386
+ const matching = mcpPool.filter(entry => entry.configKey === undefined || entry.configKey === targetConfigKey)
387
+ if (matching.length === 0) {
388
+ // 满池且全部为旧 configKey 的忙连接:不可关闭在跑的连接,只能新建一条
389
+ // 临时超限(pool 瞬时 > max)。超限是自限的:函数开头会把空转的旧
390
+ // configKey 连接回收,新建的匹配连接下次会被 354 行的 idle 分支复用,
391
+ // 池随之收敛回 max 以内(2026-11-21 审计:原注释「替换最闲旧连接」与代码不符)
392
+ const conn = createMcpConnection({
393
+ ...options,
394
+ envResolver: () => resolveEnv(options, envCfg),
395
+ configKey: targetConfigKey,
396
+ })
397
+ mcpPool.push(conn)
398
+ conn.claim()
399
+ try {
400
+ await initializeWithSignal(conn, initMs, signal)
401
+ } catch (err) {
402
+ dropFromPool(conn)
403
+ conn.close()
404
+ throw err
405
+ }
406
+ return conn
407
+ }
408
+ const least = matching.reduce((a, b) => (a.load() <= b.load() ? a : b))
382
409
  least.claim()
383
410
  try {
384
411
  await initializeWithSignal(least, initMs, signal)
@@ -477,7 +504,11 @@ export async function fetchViaArgo(url, signal, options = {}, deps = {}) {
477
504
  return
478
505
  }
479
506
  const text = value?.content?.[0]?.text
480
- resolve(typeof text === 'string' ? JSON.parse(text) : {})
507
+ try {
508
+ resolve(typeof text === 'string' ? JSON.parse(text) : {})
509
+ } catch (parseErr) {
510
+ reject(argoToolError(`argo_fetch returned invalid JSON: ${parseErr.message}`))
511
+ }
481
512
  }, (err) => {
482
513
  if (signal !== undefined) signal.removeEventListener('abort', onAbort)
483
514
  reject(err)
@@ -616,12 +647,24 @@ export function runNativeCall({ command, args, env }, timeoutMs, signal) {
616
647
  signal.addEventListener('abort', onAbort, { once: true })
617
648
  detachAbort = () => signal.removeEventListener('abort', onAbort)
618
649
  }
650
+ const MAX_NATIVE_BYTES = 4 * 1024 * 1024
651
+ let stdoutBytes = 0
652
+ let stderrBytes = 0
619
653
  timer = setTimeout(() => {
620
654
  try { child.kill('SIGKILL') } catch { /* already gone */ }
621
655
  settle(reject, new Error(`argo native call timed out after ${timeoutMs}ms`))
622
656
  }, timeoutMs)
623
- child.stdout.on('data', (chunk) => { stdout += chunk })
624
- child.stderr.on('data', (chunk) => { stderr += chunk })
657
+ if (typeof timer.unref === 'function') timer.unref()
658
+ child.stdout.setEncoding('utf8')
659
+ child.stderr.setEncoding('utf8')
660
+ child.stdout.on('data', (chunk) => {
661
+ stdoutBytes += Buffer.byteLength(chunk, 'utf8')
662
+ if (stdoutBytes <= MAX_NATIVE_BYTES) stdout += chunk
663
+ })
664
+ child.stderr.on('data', (chunk) => {
665
+ stderrBytes += Buffer.byteLength(chunk, 'utf8')
666
+ if (stderrBytes <= 256 * 1024) stderr += chunk
667
+ })
625
668
  child.on('error', (err) => settle(reject, err))
626
669
  child.on('close', (code) => {
627
670
  if (code === 0) { settle(resolve, stdout); return }