argo-search 2.14.1 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +8 -6
- package/README.es.md +57 -813
- package/README.ja.md +56 -814
- package/README.ko.md +56 -812
- package/README.md +160 -754
- package/README.zh.md +152 -872
- package/SKILL.md +22 -23
- package/assets/readme/counts.json +1 -1
- package/assets/readme/hero.svg +23 -23
- package/backends/concept_vectors.bin +0 -0
- package/backends/domain_profiles.json +149 -6
- package/backends/engine_concept_vectors.json +1525 -1525
- package/backends/engine_registry.yaml +139 -30
- package/backends/quota_profiles.json +83 -3
- package/bin/argo +33 -17
- package/config.yaml +189 -33
- package/docs/ADDING_NEW_ENGINE.md +10 -0
- package/docs/ARGO_INTRO.md +1 -1
- package/docs/CHANGELOG.md +38 -0
- package/docs/ENGINE_CATALOG.md +102 -89
- package/docs/MCP_SETUP.md +10 -1
- package/docs/RELEASE_NOTES_v2.14.1.md +4 -4
- package/docs/RELEASE_NOTES_v2.15.0.md +50 -0
- package/docs/RELEASE_NOTES_v2.16.0.md +58 -0
- package/docs/RELEASING.md +1 -1
- package/engines/specs/ai_labs.yaml +89 -0
- package/engines/specs/archive_org.yaml +1 -1
- package/engines/specs/bilibili_hot.yaml +11 -1
- package/engines/specs/brave.yaml +3 -3
- package/engines/specs/carbon_intensity.yaml +1 -1
- package/engines/specs/cisa_alerts.yaml +40 -0
- package/engines/specs/cn_ai_news.yaml +10 -8
- package/engines/specs/crates.yaml +1 -1
- package/engines/specs/crossref.yaml +4 -2
- package/engines/specs/crt_sh.yaml +1 -1
- package/engines/specs/dblp.yaml +1 -1
- package/engines/specs/devto.yaml +1 -1
- package/engines/specs/digup.yaml +11 -6
- package/engines/specs/docker_hub.yaml +1 -1
- package/engines/specs/douyin_hot.yaml +11 -1
- package/engines/specs/dw_news.yaml +4 -2
- package/engines/specs/eng_blogs.yaml +63 -0
- package/engines/specs/europeana.yaml +3 -4
- package/engines/specs/europepmc.yaml +1 -1
- package/engines/specs/felo.yaml +3 -3
- package/engines/specs/firecrawl.yaml +3 -0
- package/engines/specs/fourget.yaml +5 -2
- package/engines/specs/france24.yaml +6 -4
- package/engines/specs/fxtwitter.yaml +30 -7
- package/engines/specs/gbfs_nyc.yaml +1 -1
- package/engines/specs/gleif.yaml +1 -1
- package/engines/specs/gov_regulations.yaml +1 -1
- package/engines/specs/grepapp_mcp.yaml +62 -0
- package/engines/specs/guardian_rss.yaml +6 -4
- package/engines/specs/hf_datasets.yaml +1 -1
- package/engines/specs/huggingface.yaml +1 -1
- package/engines/specs/itotii.yaml +13 -1
- package/engines/specs/keenable.yaml +7 -1
- package/engines/specs/linux_do.yaml +63 -0
- package/engines/specs/lobsters.yaml +41 -0
- package/engines/specs/local_crossref.yaml +3 -1
- package/engines/specs/local_github.yaml +1 -1
- package/engines/specs/local_npm.yaml +6 -0
- package/engines/specs/local_openstreetmap.yaml +1 -1
- package/engines/specs/local_seek.yaml +6 -0
- package/engines/specs/maven.yaml +1 -1
- package/engines/specs/mdn.yaml +1 -1
- package/engines/specs/musicbrainz.yaml +1 -1
- package/engines/specs/nasa_images.yaml +1 -1
- package/engines/specs/nhtsa_vpic.yaml +6 -3
- package/engines/specs/npm.yaml +1 -1
- package/engines/specs/nuget.yaml +1 -1
- package/engines/specs/nvd.yaml +1 -1
- package/engines/specs/open_meteo.yaml +1 -1
- package/engines/specs/openalex.yaml +4 -2
- package/engines/specs/openreview.yaml +1 -1
- package/engines/specs/polymarket.yaml +1 -1
- package/engines/specs/redskill.yaml +2 -0
- package/engines/specs/searxng.yaml +4 -2
- package/engines/specs/sec_edgar.yaml +9 -4
- package/engines/specs/steam.yaml +1 -1
- package/engines/specs/tinyfish.yaml +2 -0
- package/engines/specs/tinyfish_news.yaml +2 -0
- package/engines/specs/tinyfish_paper.yaml +2 -0
- package/engines/specs/toutiao_hot.yaml +11 -1
- package/engines/specs/train.yaml +3 -0
- package/engines/specs/twitter.yaml +4 -0
- package/engines/specs/unpaywall.yaml +6 -0
- package/engines/specs/vam.yaml +17 -3
- package/engines/specs/weibo_hot.yaml +11 -1
- package/engines/specs/wikidata.yaml +1 -1
- package/engines/specs/wikipedia.yaml +1 -1
- package/engines/specs/wolframalpha.yaml +3 -3
- package/engines/specs/xiaohongshu.yaml +2 -0
- package/engines/specs/zhihu.yaml +3 -18
- package/engines/specs/zhihu_hot_app.yaml +1 -1
- package/engines/specs/zhihu_kb.yaml +18 -0
- package/engines/specs/zhihu_questions.yaml +19 -0
- package/package.json +4 -2
- package/packages/dsh-plugin/README.md +9 -14
- package/packages/dsh-plugin/dsh/client.js +481 -1037
- package/packages/dsh-plugin/dsh/diagnostics.js +71 -20
- package/packages/dsh-plugin/dsh/index.js +6 -0
- package/packages/dsh-plugin/dsh/runner.js +3 -1
- package/packages/dsh-plugin/dsh/workbench-client.js +796 -0
- package/packages/dsh-plugin/dsh/workbench-md.js +386 -0
- package/packages/dsh-plugin/dsh/workbench-suggestions.js +148 -0
- package/packages/dsh-plugin/dsh/workbench.js +966 -0
- package/packages/dsh-plugin/icon.svg +23 -0
- package/packages/dsh-plugin/package.json +10 -3
- package/packages/dsh-plugin/scripts/sync-local.mjs +87 -0
- package/packages/dsh-plugin/scripts/sync-local.sh +13 -1
- package/packages/dsh-plugin/test/diagnostics.test.js +38 -1
- package/packages/dsh-plugin/test/size-gate.test.js +2 -9
- package/packages/dsh-plugin/test/workbench.test.js +92 -0
- package/scripts/adaptive.py +7 -1
- package/scripts/archive_run.py +112 -53
- package/scripts/argo_paths.py +42 -5
- package/scripts/badcase_ledger.py +117 -9
- package/scripts/build_concept_table.py +112 -55
- package/scripts/cache.py +6 -2
- package/scripts/caliber_isolation.py +60 -23
- package/scripts/circuit_breaker.py +72 -11
- package/scripts/cli_io.py +20 -2
- package/scripts/config_cache.py +44 -1
- package/scripts/daemon.py +151 -51
- package/scripts/dormant_ledger.py +23 -9
- package/scripts/engine_dispatch.py +8 -5
- package/scripts/engine_env.py +191 -1
- package/scripts/engine_families.py +50 -7
- package/scripts/engine_states.py +3 -50
- package/scripts/engine_validate.py +13 -45
- package/scripts/engines.py +15 -31
- package/scripts/engines_base.py +66 -61
- package/scripts/engines_builders.py +0 -15
- package/scripts/engines_builders_archive.py +4 -3
- package/scripts/engines_builders_batch10.py +346 -100
- package/scripts/engines_builders_batch11.py +4 -76
- package/scripts/engines_builders_batch13.py +4 -3
- package/scripts/engines_builders_batch14.py +2 -1
- package/scripts/engines_builders_batch15.py +2 -1
- package/scripts/engines_builders_batch9.py +16 -25
- package/scripts/engines_builders_cn.py +7 -201
- package/scripts/engines_builders_data.py +12 -11
- package/scripts/engines_builders_data_macro.py +5 -4
- package/scripts/engines_builders_dsh.py +2 -1
- package/scripts/engines_builders_feeds.py +76 -11
- package/scripts/engines_builders_finance.py +2 -1
- package/scripts/engines_builders_intl.py +18 -117
- package/scripts/engines_builders_media.py +59 -12
- package/scripts/engines_builders_pixiv.py +2 -16
- package/scripts/engines_builders_science.py +8 -7
- package/scripts/engines_builders_search.py +7 -14
- package/scripts/engines_builders_skill.py +2 -1
- package/scripts/engines_builders_tech.py +8 -17
- package/scripts/engines_builders_weather.py +241 -0
- package/scripts/engines_fields.py +91 -0
- package/scripts/engines_http.py +184 -0
- package/scripts/engines_mcp.py +405 -0
- package/scripts/engines_parsers.py +13 -369
- package/scripts/engines_schema_drift.py +260 -0
- package/scripts/evidence.py +13 -0
- package/scripts/evidence_loop.py +19 -4
- package/scripts/extend_route_labels.py +6 -0
- package/scripts/fetch_jina.py +98 -0
- package/scripts/fetch_jsrun.py +15 -11
- package/scripts/fetch_v3.py +79 -120
- package/scripts/fulltext_store.py +42 -1
- package/scripts/fxtwitter_api.py +8 -7
- package/scripts/gen_engine_catalog.py +2 -2
- package/scripts/general_pool.py +15 -4
- package/scripts/health_check.py +1 -1
- package/scripts/image_vision/vision_probe +0 -0
- package/scripts/install.sh +2 -0
- package/scripts/link_source.py +65 -24
- package/scripts/local_seek_adapter.py +57 -17
- package/scripts/matrix_search_eval.py +8 -10
- package/scripts/mcp_handlers.py +53 -31
- package/scripts/mcp_handlers_surface.py +6 -18
- package/scripts/mcp_transport.py +10 -5
- package/scripts/min_version_scan.py +7 -3
- package/scripts/network_aware.py +7 -13
- package/scripts/numeric_verify.py +3 -2
- package/scripts/output_transparency.py +3 -0
- package/scripts/pre-commit +45 -43
- package/scripts/query_understanding.py +30 -6
- package/scripts/quota.py +36 -30
- package/scripts/rank_signals.py +9 -0
- package/scripts/recompute.py +15 -5
- package/scripts/recovery.py +38 -29
- package/scripts/recovery_runner.py +29 -10
- package/scripts/redskill/redskill_engine.py +2 -1
- package/scripts/release.py +14 -26
- package/scripts/release_check.py +5 -25
- package/scripts/replay_eval.py +2 -2
- package/scripts/research_cli.py +40 -0
- package/scripts/research_notes.py +368 -0
- package/scripts/route.py +40 -70
- package/scripts/route_audit.py +259 -0
- package/scripts/route_combo.py +21 -6
- package/scripts/route_domains.py +150 -23
- package/scripts/route_lang.py +20 -7
- package/scripts/route_log.py +26 -9
- package/scripts/route_policy.py +85 -6
- package/scripts/route_telemetry_export.py +199 -0
- package/scripts/rrf_classic.py +5 -22
- package/scripts/search.py +2 -1
- package/scripts/search_attribution.py +53 -10
- package/scripts/search_entry.py +32 -1
- package/scripts/search_output.py +23 -11
- package/scripts/search_pipeline.py +15 -3
- package/scripts/search_rank.py +21 -11
- package/scripts/semantic_evidence.py +394 -178
- package/scripts/serp_guard.py +13 -1
- package/scripts/settings_page.py +4 -3
- package/scripts/single_flight.py +1 -1
- package/scripts/social_engines/hackernews_engine.py +2 -1
- package/scripts/social_engines/reddit_engine.py +2 -1
- package/scripts/social_engines/xiaohongshu_engine.py +2 -1
- package/scripts/social_engines/zhihu_engine.py +252 -43
- package/scripts/sogou_weixin_browser.py +5 -6
- package/scripts/source_audit.py +44 -9
- package/scripts/source_ledger.py +2 -15
- package/scripts/source_selection.py +45 -20
- package/scripts/straggler_policy.py +1 -2
- package/scripts/sync_backends.py +17 -0
- package/scripts/tfidf_router.py +23 -11
- package/scripts/time_utils.py +54 -1
- package/scripts/train.py +68 -2
- package/scripts/usage_log.py +50 -10
- package/scripts/watch.py +3 -3
- package/scripts/zhihu_quota.py +2 -1
- package/sub-skills/argo-wide-research/SKILL.md +70 -0
- package/sub-skills/ego-search/{SKILL.md → README.md} +15 -47
- package/sub-skills/ego-search/scripts/ego_search.py +13 -4
- package/sub-skills/js-run/{SKILL.md → README.md} +3 -20
- package/sub-skills/local-search/{SKILL.md → README.md} +3 -8
- package/sub-skills/local-search/engine_registry.py +32 -7
- package/sub-skills/local-seek/SKILL.md +20 -22
- package/sub-skills/local-seek/scripts/seek_fts.py +58 -3
- package/scripts/caliber_dedupe.py +0 -66
- package/scripts/engines_builders_batch16.py +0 -13
- package/scripts/health_probe.py +0 -253
- package/scripts/social_engines/twitter_engine.py +0 -514
- package/scripts/sync_installs.py +0 -29
|
@@ -0,0 +1,796 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @taxueseek/argo-dsh — 搜索分析工作台前端模块(ES Module,零构建依赖)
|
|
3
|
+
*
|
|
4
|
+
* 通过 /argo/workbench-client.js 由 Host 提供,挂载到 DSH:
|
|
5
|
+
* - main slot(key: 'argo-workbench')
|
|
6
|
+
* - sidebar.panellist(id: 'argo-workbench')
|
|
7
|
+
* - 全局划词浮层(选中对话内容一键进入工作台分析)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { CSS, renderMarkdown } from '/argo/workbench-md.js'
|
|
11
|
+
|
|
12
|
+
const STATE_KEY = 'argo-workbench:state.v1'
|
|
13
|
+
const PREFS_KEY = 'argo-workbench:prefs.v1'
|
|
14
|
+
|
|
15
|
+
const CORE_MODES = [
|
|
16
|
+
{ id: 'general', label: '全网搜索', desc: '多源快查,先给结论再列出处', ph: '搜任何问题、概念、报错或资料(Enter 发送,Shift+Enter 换行)…' },
|
|
17
|
+
{ id: 'hotspot', label: '热点分析', desc: '梳理近期事件脉络、争议与各方立场', ph: '输入热点事件、行业动态或争议话题,看多方观点…' },
|
|
18
|
+
{ id: 'research', label: '深度研究', desc: '多维拆解、原文核验并生成研究报告', ph: '输入需要系统调研的复杂问题,生成带来源账本的报告…' },
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
const TOPIC_CARDS = [
|
|
22
|
+
{
|
|
23
|
+
id: 'verify',
|
|
24
|
+
label: '真假核验',
|
|
25
|
+
desc: '抓取原文核对出处,给出可信度判断',
|
|
26
|
+
ph: '输入需要核验真假的传闻、数据或说法…',
|
|
27
|
+
samples: [
|
|
28
|
+
'核验某项公开行业统计数据的原始官方出处',
|
|
29
|
+
'核实近期热门科技传闻的官方公告与时间线',
|
|
30
|
+
'核对某软件开源协议或最新收费政策的官方条款',
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'compare',
|
|
35
|
+
label: '选型对比',
|
|
36
|
+
desc: '多维度对比产品、方案优缺点与替代',
|
|
37
|
+
ph: '输入要对比的两个或多个产品、工具或方案…',
|
|
38
|
+
samples: [
|
|
39
|
+
'主流本地知识库方案对比:架构、成本与适用场景',
|
|
40
|
+
'常见全文检索与向量数据库选型优缺点对比',
|
|
41
|
+
'主流个人知识管理工具功能与迁移成本对比',
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'academic',
|
|
46
|
+
label: '学术文献',
|
|
47
|
+
desc: '学术多源深挖,梳理方法与实验结论',
|
|
48
|
+
ph: '输入论文主题、研究方向或具体文献关键词…',
|
|
49
|
+
samples: [
|
|
50
|
+
'推理时计算扩展方法最新研究综述与实验对比',
|
|
51
|
+
'多智能体协作与检索增强生成前沿论文梳理',
|
|
52
|
+
'端侧模型量化与低延迟推理优化技术进展',
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'plugin',
|
|
57
|
+
label: '插件评测',
|
|
58
|
+
desc: '汇总官方说明、社区口碑与安装注意',
|
|
59
|
+
ph: '输入想评估的工具、扩展或插件类型…',
|
|
60
|
+
samples: [
|
|
61
|
+
'热门效率工具与浏览器扩展的真实口碑与安全评估',
|
|
62
|
+
'常用代码编辑器高星插件生态对比与避坑指南',
|
|
63
|
+
'开源自动化工作流插件的局限性与替代方案',
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'local',
|
|
68
|
+
label: '本机检索',
|
|
69
|
+
desc: '基于 local-seek 检索本机代码与文档',
|
|
70
|
+
ph: '输入要在本机检索的关键词、符号或文件名…',
|
|
71
|
+
samples: [
|
|
72
|
+
'circuit_breaker',
|
|
73
|
+
'engine_states',
|
|
74
|
+
'wide-research',
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
const pickSample = (samples) => samples[Math.floor(Math.random() * samples.length)]
|
|
80
|
+
|
|
81
|
+
const ALL_MODES = [...CORE_MODES, ...TOPIC_CARDS]
|
|
82
|
+
|
|
83
|
+
function injectStyle() {
|
|
84
|
+
if (typeof document === 'undefined') return
|
|
85
|
+
if (document.getElementById('argo-wb-style')) return
|
|
86
|
+
const el = document.createElement('style')
|
|
87
|
+
el.id = 'argo-wb-style'
|
|
88
|
+
el.textContent = CSS
|
|
89
|
+
document.head.appendChild(el)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function readStorage(key, fallback) {
|
|
93
|
+
try {
|
|
94
|
+
const raw = window.localStorage.getItem(key)
|
|
95
|
+
return raw ? JSON.parse(raw) : fallback
|
|
96
|
+
} catch {
|
|
97
|
+
return fallback
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function writeStorage(key, value) {
|
|
102
|
+
try {
|
|
103
|
+
window.localStorage.setItem(key, JSON.stringify(value))
|
|
104
|
+
} catch { /* ignore */ }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function formatInterval(mins) {
|
|
108
|
+
if (mins >= 43200) return '每月一次'
|
|
109
|
+
if (mins >= 10080) return '每周一次'
|
|
110
|
+
if (mins >= 1440) return '每日一次'
|
|
111
|
+
return mins >= 60 ? `每 ${Math.round(mins / 60)} 小时` : `每 ${mins} 分钟`
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function formatTime(iso) {
|
|
115
|
+
if (!iso) return '尚未运行'
|
|
116
|
+
try {
|
|
117
|
+
const d = new Date(iso)
|
|
118
|
+
return `${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`
|
|
119
|
+
} catch {
|
|
120
|
+
return iso
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function mountArgoWorkbench(ctx, react) {
|
|
125
|
+
injectStyle()
|
|
126
|
+
const h = react.createElement
|
|
127
|
+
const { useState, useEffect, useRef } = react
|
|
128
|
+
|
|
129
|
+
let pendingExternal = null
|
|
130
|
+
const listeners = new Set()
|
|
131
|
+
|
|
132
|
+
const requestSearch = (query, mode = 'general') => {
|
|
133
|
+
const clean = String(query || '').trim()
|
|
134
|
+
if (!clean) return false
|
|
135
|
+
pendingExternal = { query: clean, mode }
|
|
136
|
+
for (const fn of listeners) fn(pendingExternal)
|
|
137
|
+
return true
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const resolveLang = () => {
|
|
141
|
+
const loc = ctx?.locale ?? (typeof ctx?.get === 'function' ? ctx.get('locale') : null)
|
|
142
|
+
const active = loc?.getSnapshot?.()?.active || (typeof navigator !== 'undefined' ? navigator.language : 'zh')
|
|
143
|
+
return String(active).toLowerCase().startsWith('en') ? 'en' : 'zh'
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function WorkbenchApp() {
|
|
147
|
+
const saved = readStorage(STATE_KEY, null)
|
|
148
|
+
const [prefs, setPrefs] = useState(() => readStorage(PREFS_KEY, { selection: true }))
|
|
149
|
+
const [lang, setLang] = useState(resolveLang)
|
|
150
|
+
const [view, setView] = useState('home')
|
|
151
|
+
const [input, setInput] = useState('')
|
|
152
|
+
const [activeQuery, setActiveQuery] = useState(saved?.query || '')
|
|
153
|
+
const [mode, setMode] = useState('general')
|
|
154
|
+
const [topicSamples, setTopicSamples] = useState(() => Object.fromEntries(TOPIC_CARDS.map(t => [t.id, pickSample(t.samples)])))
|
|
155
|
+
const [suggestions, setSuggestions] = useState([])
|
|
156
|
+
const [cards, setCards] = useState(saved?.cards || [])
|
|
157
|
+
const [turns, setTurns] = useState(saved?.turns || [])
|
|
158
|
+
const [stageText, setStageText] = useState('')
|
|
159
|
+
const [loading, setLoading] = useState(false)
|
|
160
|
+
const [filter, setFilter] = useState('all')
|
|
161
|
+
const [flashId, setFlashId] = useState('')
|
|
162
|
+
const [followup, setFollowup] = useState('')
|
|
163
|
+
const [popover, setPopover] = useState(null) // null | 'debug' | 'settings' | 'watch'
|
|
164
|
+
const [diagItems, setDiagItems] = useState([])
|
|
165
|
+
const [healthInfo, setHealthInfo] = useState(null)
|
|
166
|
+
const [gateResult, setGateResult] = useState(null)
|
|
167
|
+
const [clarifyInfo, setClarifyInfo] = useState(null)
|
|
168
|
+
const [evidenceSummary, setEvidenceSummary] = useState(null)
|
|
169
|
+
const [watches, setWatches] = useState([])
|
|
170
|
+
const [watchQuery, setWatchQuery] = useState('')
|
|
171
|
+
const [watchInterval, setWatchInterval] = useState(1440)
|
|
172
|
+
const [watchBusyId, setWatchBusyId] = useState('')
|
|
173
|
+
const inputRef = useRef(null)
|
|
174
|
+
const esRef = useRef(null)
|
|
175
|
+
const abortRef = useRef(null)
|
|
176
|
+
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
writeStorage(STATE_KEY, { query: activeQuery, mode, cards, turns })
|
|
179
|
+
}, [activeQuery, mode, cards, turns])
|
|
180
|
+
|
|
181
|
+
const refreshWatches = async () => {
|
|
182
|
+
try {
|
|
183
|
+
const res = await fetch('/argo/api/watches')
|
|
184
|
+
const data = await res.json()
|
|
185
|
+
if (Array.isArray(data.items)) setWatches(data.items)
|
|
186
|
+
} catch { /* ignore */ }
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const refreshSuggestions = async (targetMode = mode, targetLang = lang, shuffle = false) => {
|
|
190
|
+
try {
|
|
191
|
+
const res = await fetch(`/argo/api/suggestions?mode=${encodeURIComponent(targetMode)}&lang=${encodeURIComponent(targetLang)}&shuffle=${shuffle ? '1' : '0'}`)
|
|
192
|
+
const data = await res.json()
|
|
193
|
+
if (Array.isArray(data?.items)) setSuggestions(data.items)
|
|
194
|
+
} catch { /* ignore */ }
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
useEffect(() => {
|
|
198
|
+
const loc = ctx?.locale ?? (typeof ctx?.get === 'function' ? ctx.get('locale') : null)
|
|
199
|
+
if (!loc?.subscribe) return undefined
|
|
200
|
+
return loc.subscribe(() => setLang(resolveLang()))
|
|
201
|
+
}, [])
|
|
202
|
+
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
refreshSuggestions(mode, lang, false)
|
|
205
|
+
}, [mode, lang])
|
|
206
|
+
|
|
207
|
+
useEffect(() => { refreshWatches() }, [])
|
|
208
|
+
|
|
209
|
+
const startSearch = (qText, targetMode = mode, refresh = false) => {
|
|
210
|
+
const q = String(qText || '').trim()
|
|
211
|
+
if (!q) return
|
|
212
|
+
if (esRef.current) { esRef.current.close(); esRef.current = null }
|
|
213
|
+
if (abortRef.current) { abortRef.current.abort(); abortRef.current = null }
|
|
214
|
+
|
|
215
|
+
setView('result')
|
|
216
|
+
setActiveQuery(q)
|
|
217
|
+
setInput(q)
|
|
218
|
+
setMode(targetMode)
|
|
219
|
+
setCards([])
|
|
220
|
+
setTurns([{ role: 'assistant', text: '' }])
|
|
221
|
+
setStageText('正在连接 Argo 多源检索引擎…')
|
|
222
|
+
setLoading(true)
|
|
223
|
+
setFilter('all')
|
|
224
|
+
setPopover(null)
|
|
225
|
+
setGateResult(null)
|
|
226
|
+
setClarifyInfo(null)
|
|
227
|
+
setEvidenceSummary(null)
|
|
228
|
+
|
|
229
|
+
const url = `/argo/api/stream?q=${encodeURIComponent(q)}&mode=${encodeURIComponent(targetMode)}&refresh=${refresh ? '1' : '0'}`
|
|
230
|
+
const es = new EventSource(url)
|
|
231
|
+
esRef.current = es
|
|
232
|
+
|
|
233
|
+
const parse = (ev) => { try { return JSON.parse(ev.data) } catch { return {} } }
|
|
234
|
+
es.addEventListener('status', (ev) => { const d = parse(ev); if (d.message) setStageText(d.message) })
|
|
235
|
+
es.addEventListener('clarify', (ev) => { const d = parse(ev); if (d && (d.explanation || d.ambiguities?.length)) setClarifyInfo(d) })
|
|
236
|
+
es.addEventListener('evidence', (ev) => { const d = parse(ev); if (d && (d.crossValidation || d.summary)) setEvidenceSummary(d) })
|
|
237
|
+
es.addEventListener('cards', (ev) => { const d = parse(ev); if (Array.isArray(d.cards)) setCards(d.cards) })
|
|
238
|
+
es.addEventListener('gate', (ev) => { const d = parse(ev); if (typeof d.passed === 'boolean') setGateResult(d) })
|
|
239
|
+
es.addEventListener('verify-update', (ev) => {
|
|
240
|
+
const d = parse(ev)
|
|
241
|
+
if (d.card) setCards(prev => prev.map(c => c.id === d.card.id ? d.card : c))
|
|
242
|
+
})
|
|
243
|
+
es.addEventListener('answer', (ev) => {
|
|
244
|
+
const d = parse(ev)
|
|
245
|
+
if (!d.delta) return
|
|
246
|
+
setTurns(prev => {
|
|
247
|
+
const next = [...prev]
|
|
248
|
+
const last = next[next.length - 1]
|
|
249
|
+
if (last && last.role === 'assistant') next[next.length - 1] = { ...last, text: last.text + d.delta }
|
|
250
|
+
return next
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
es.addEventListener('answer-status', (ev) => { const d = parse(ev); if (d.message) setStageText(d.message) })
|
|
254
|
+
es.addEventListener('done', () => { setLoading(false); setStageText(''); es.close(); esRef.current = null })
|
|
255
|
+
es.addEventListener('failure', (ev) => { const d = parse(ev); setLoading(false); setStageText(`检索出错:${d.message || '未知错误'}`); es.close(); esRef.current = null })
|
|
256
|
+
es.onerror = () => { if (es.readyState === EventSource.CLOSED) setLoading(false) }
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
useEffect(() => {
|
|
260
|
+
const handler = (req) => {
|
|
261
|
+
if (!req) return
|
|
262
|
+
pendingExternal = null
|
|
263
|
+
startSearch(req.query, req.mode || mode)
|
|
264
|
+
}
|
|
265
|
+
listeners.add(handler)
|
|
266
|
+
if (pendingExternal) handler(pendingExternal)
|
|
267
|
+
return () => {
|
|
268
|
+
listeners.delete(handler)
|
|
269
|
+
if (esRef.current) esRef.current.close()
|
|
270
|
+
if (abortRef.current) abortRef.current.abort()
|
|
271
|
+
}
|
|
272
|
+
}, [])
|
|
273
|
+
|
|
274
|
+
const handleFollowup = async (e) => {
|
|
275
|
+
e.preventDefault()
|
|
276
|
+
const q = followup.trim()
|
|
277
|
+
if (!q || loading) return
|
|
278
|
+
setFollowup('')
|
|
279
|
+
setLoading(true)
|
|
280
|
+
setStageText('正在结合当前证据回答追问…')
|
|
281
|
+
|
|
282
|
+
const historySnapshot = [...turns]
|
|
283
|
+
setTurns(prev => [...prev, { role: 'user', text: q }, { role: 'assistant', text: '' }])
|
|
284
|
+
|
|
285
|
+
const ac = new AbortController()
|
|
286
|
+
abortRef.current = ac
|
|
287
|
+
try {
|
|
288
|
+
const res = await fetch('/argo/api/followup', {
|
|
289
|
+
method: 'POST',
|
|
290
|
+
headers: { 'Content-Type': 'application/json' },
|
|
291
|
+
body: JSON.stringify({ query: activeQuery, mode, cards, history: historySnapshot, question: q }),
|
|
292
|
+
signal: ac.signal,
|
|
293
|
+
})
|
|
294
|
+
const reader = res.body.getReader()
|
|
295
|
+
const dec = new TextDecoder()
|
|
296
|
+
let buf = ''
|
|
297
|
+
while (true) {
|
|
298
|
+
const { value, done } = await reader.read()
|
|
299
|
+
if (done) break
|
|
300
|
+
buf += dec.decode(value, { stream: true })
|
|
301
|
+
const parts = buf.split('\n\n')
|
|
302
|
+
buf = parts.pop() || ''
|
|
303
|
+
for (const chunk of parts) {
|
|
304
|
+
const evMatch = chunk.match(/^event:\s*(.+)$/m)
|
|
305
|
+
const dataMatch = chunk.match(/^data:\s*(.+)$/m)
|
|
306
|
+
if (!dataMatch) continue
|
|
307
|
+
const evName = evMatch ? evMatch[1].trim() : 'message'
|
|
308
|
+
const payload = JSON.parse(dataMatch[1])
|
|
309
|
+
if (evName === 'answer' && payload.delta) {
|
|
310
|
+
setTurns(prev => {
|
|
311
|
+
const next = [...prev]
|
|
312
|
+
const last = next[next.length - 1]
|
|
313
|
+
if (last && last.role === 'assistant') next[next.length - 1] = { ...last, text: last.text + payload.delta }
|
|
314
|
+
return next
|
|
315
|
+
})
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
} catch { /* ignore */ } finally {
|
|
320
|
+
setLoading(false)
|
|
321
|
+
setStageText('')
|
|
322
|
+
abortRef.current = null
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const createWatch = async (qStr, targetMode = mode, mins = watchInterval) => {
|
|
327
|
+
const q = String(qStr || '').trim()
|
|
328
|
+
if (!q) return
|
|
329
|
+
try {
|
|
330
|
+
const res = await fetch('/argo/api/watches', {
|
|
331
|
+
method: 'POST',
|
|
332
|
+
headers: { 'Content-Type': 'application/json' },
|
|
333
|
+
body: JSON.stringify({ query: q, mode: targetMode, intervalMinutes: mins }),
|
|
334
|
+
})
|
|
335
|
+
const data = await res.json()
|
|
336
|
+
if (Array.isArray(data.items)) setWatches(data.items)
|
|
337
|
+
setWatchQuery('')
|
|
338
|
+
setWatchOpen(true)
|
|
339
|
+
} catch { /* ignore */ }
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const runWatchNow = async (id) => {
|
|
343
|
+
setWatchBusyId(id)
|
|
344
|
+
try {
|
|
345
|
+
const res = await fetch('/argo/api/watches/run', {
|
|
346
|
+
method: 'POST',
|
|
347
|
+
headers: { 'Content-Type': 'application/json' },
|
|
348
|
+
body: JSON.stringify({ id }),
|
|
349
|
+
})
|
|
350
|
+
const data = await res.json()
|
|
351
|
+
if (Array.isArray(data.items)) setWatches(data.items)
|
|
352
|
+
} finally {
|
|
353
|
+
setWatchBusyId('')
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const deleteWatch = async (id) => {
|
|
358
|
+
try {
|
|
359
|
+
const res = await fetch(`/argo/api/watches?id=${encodeURIComponent(id)}`, { method: 'DELETE' })
|
|
360
|
+
const data = await res.json()
|
|
361
|
+
if (Array.isArray(data.items)) setWatches(data.items)
|
|
362
|
+
} catch { /* ignore */ }
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
const openWatchResult = (w) => {
|
|
366
|
+
setView('result')
|
|
367
|
+
setActiveQuery(w.query)
|
|
368
|
+
setInput(w.query)
|
|
369
|
+
setMode(w.mode || 'general')
|
|
370
|
+
setCards(Array.isArray(w.lastCards) ? w.lastCards : [])
|
|
371
|
+
setTurns([{ role: 'assistant', text: w.lastSummary || '该定时任务尚未生成摘要,可点击「立即执行」或「强制刷新」。' }])
|
|
372
|
+
setWatchOpen(false)
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const scrollToCard = (cardId) => {
|
|
376
|
+
const el = document.getElementById(`aw-${cardId}`)
|
|
377
|
+
if (el) {
|
|
378
|
+
el.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
379
|
+
setFlashId(cardId)
|
|
380
|
+
setTimeout(() => setFlashId(''), 1400)
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
const refreshHealth = async () => {
|
|
385
|
+
try {
|
|
386
|
+
const res = await fetch('/argo/api/health')
|
|
387
|
+
const data = await res.json()
|
|
388
|
+
if (data?.ok) setHealthInfo(data)
|
|
389
|
+
} catch { /* ignore */ }
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
const openDebug = async () => {
|
|
393
|
+
const next = popover === 'debug' ? null : 'debug'
|
|
394
|
+
setPopover(next)
|
|
395
|
+
if (next === 'debug') {
|
|
396
|
+
refreshHealth()
|
|
397
|
+
try {
|
|
398
|
+
const res = await fetch('/argo/api/diagnostics')
|
|
399
|
+
const data = await res.json()
|
|
400
|
+
setDiagItems(data.items || [])
|
|
401
|
+
} catch { /* ignore */ }
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const toggleWatchPanel = () => {
|
|
406
|
+
const next = popover === 'watch' ? null : 'watch'
|
|
407
|
+
setPopover(next)
|
|
408
|
+
if (next === 'watch') refreshWatches()
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
const toggleSettingsPanel = () => {
|
|
412
|
+
const next = popover === 'settings' ? null : 'settings'
|
|
413
|
+
setPopover(next)
|
|
414
|
+
if (next === 'settings') refreshHealth()
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const toggleEgoSearch = async () => {
|
|
418
|
+
const current = Boolean(healthInfo?.egoSearch?.enabled)
|
|
419
|
+
try {
|
|
420
|
+
const res = await fetch('/argo/api/ego-search', {
|
|
421
|
+
method: 'POST',
|
|
422
|
+
headers: { 'Content-Type': 'application/json' },
|
|
423
|
+
body: JSON.stringify({ enabled: !current }),
|
|
424
|
+
})
|
|
425
|
+
const data = await res.json()
|
|
426
|
+
if (data?.ok) setHealthInfo(prev => ({ ...(prev || {}), egoSearch: data.egoSearch }))
|
|
427
|
+
} catch { /* ignore */ }
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const toggleSelectionPref = () => {
|
|
431
|
+
const next = { ...prefs, selection: !prefs.selection }
|
|
432
|
+
setPrefs(next)
|
|
433
|
+
writeStorage(PREFS_KEY, next)
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
const currentModeObj = ALL_MODES.find(m => m.id === mode) || CORE_MODES[0]
|
|
437
|
+
const lockedTopic = TOPIC_CARDS.find(t => t.id === mode) || null
|
|
438
|
+
const verifiedCount = cards.filter(c => c.verified).length
|
|
439
|
+
const visibleCards = filter === 'verified'
|
|
440
|
+
? cards.filter(c => c.verified)
|
|
441
|
+
: (filter === 'all' ? cards : cards.filter(c => c.source === filter))
|
|
442
|
+
const sources = [...new Set(cards.map(c => c.source))]
|
|
443
|
+
|
|
444
|
+
const renderWatchDrawer = () => popover !== 'watch' ? null : h('div', { className: 'aw-popover' },
|
|
445
|
+
h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: '10px' } },
|
|
446
|
+
h('strong', null, '定时搜索与追踪'),
|
|
447
|
+
h('button', { type: 'button', className: 'aw-filter', onClick: () => setPopover(null) }, '关闭')),
|
|
448
|
+
h('form', {
|
|
449
|
+
style: { display: 'flex', gap: '6px', marginBottom: '10px' },
|
|
450
|
+
onSubmit: (e) => { e.preventDefault(); createWatch(watchQuery || activeQuery || input, mode, watchInterval) },
|
|
451
|
+
},
|
|
452
|
+
h('input', {
|
|
453
|
+
className: 'aw-top-input',
|
|
454
|
+
style: { border: '1px solid var(--aw-border)', borderRadius: '8px', padding: '5px 8px', background: 'var(--aw-sunken)' },
|
|
455
|
+
placeholder: '输入定时追踪关键词…',
|
|
456
|
+
value: watchQuery,
|
|
457
|
+
onChange: (e) => setWatchQuery(e.target.value),
|
|
458
|
+
}),
|
|
459
|
+
h('select', {
|
|
460
|
+
className: 'aw-select',
|
|
461
|
+
style: { height: '28px' },
|
|
462
|
+
value: watchInterval,
|
|
463
|
+
onChange: (e) => setWatchInterval(Number(e.target.value)),
|
|
464
|
+
},
|
|
465
|
+
h('option', { value: 1440 }, '每日一次'),
|
|
466
|
+
h('option', { value: 10080 }, '每周一次'),
|
|
467
|
+
h('option', { value: 43200 }, '每月一次')),
|
|
468
|
+
h('button', { type: 'submit', className: 'aw-filter active' }, '添加')),
|
|
469
|
+
watches.length === 0
|
|
470
|
+
? h('div', { style: { color: 'var(--aw-text-3)', padding: '8px 0' } }, '暂无定时搜索任务')
|
|
471
|
+
: watches.map(w => h('div', { key: w.id, className: 'aw-watch-row' },
|
|
472
|
+
h('div', { style: { fontWeight: 600 } }, `[${w.modeLabel || w.mode}] ${w.query}`),
|
|
473
|
+
h('div', { style: { color: 'var(--aw-text-3)' } }, `${formatInterval(w.intervalMinutes)} · 上次:${formatTime(w.lastRunAt)} · 来源 ${w.lastCardCount || 0}`),
|
|
474
|
+
h('div', { className: 'aw-watch-actions' },
|
|
475
|
+
w.lastSummary ? h('button', { type: 'button', className: 'aw-filter active', onClick: () => openWatchResult(w) }, '查看结果') : null,
|
|
476
|
+
h('button', {
|
|
477
|
+
type: 'button',
|
|
478
|
+
className: 'aw-filter',
|
|
479
|
+
disabled: watchBusyId === w.id,
|
|
480
|
+
onClick: () => runWatchNow(w.id),
|
|
481
|
+
}, watchBusyId === w.id ? '执行中…' : '立即执行'),
|
|
482
|
+
h('button', { type: 'button', className: 'aw-filter', onClick: () => deleteWatch(w.id) }, '删除')))))
|
|
483
|
+
|
|
484
|
+
if (view === 'home') {
|
|
485
|
+
return h('div', { className: 'aw-root' },
|
|
486
|
+
h('div', { className: 'aw-hero' },
|
|
487
|
+
h('div', { className: 'aw-hero-top' },
|
|
488
|
+
h('button', { type: 'button', className: 'aw-icon-btn', onClick: toggleWatchPanel }, `定时搜索 (${watches.length})`)),
|
|
489
|
+
renderWatchDrawer(),
|
|
490
|
+
h('div', { className: 'aw-hero-inner' },
|
|
491
|
+
h('h1', { className: 'aw-slogan' }, lang === 'en' ? 'Search Wide, Verify Fast' : '搜得到,查得快'),
|
|
492
|
+
h('p', { className: 'aw-sub' }, lang === 'en' ? 'Multi-source search, hotspot brief, deep research & scheduled watch' : '全网搜索,热点分析,深度研究,定时搜索'),
|
|
493
|
+
h('form', {
|
|
494
|
+
className: 'aw-box',
|
|
495
|
+
onSubmit: (e) => { e.preventDefault(); startSearch(input, mode) },
|
|
496
|
+
},
|
|
497
|
+
h('textarea', {
|
|
498
|
+
ref: inputRef,
|
|
499
|
+
className: 'aw-textarea',
|
|
500
|
+
placeholder: currentModeObj.ph,
|
|
501
|
+
value: input,
|
|
502
|
+
onChange: (e) => setInput(e.target.value),
|
|
503
|
+
onKeyDown: (e) => {
|
|
504
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
505
|
+
e.preventDefault()
|
|
506
|
+
startSearch(input, mode)
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
}),
|
|
510
|
+
h('div', { className: 'aw-box-foot' },
|
|
511
|
+
h('div', { className: 'aw-modes' },
|
|
512
|
+
CORE_MODES.map(m => h('button', {
|
|
513
|
+
key: m.id,
|
|
514
|
+
type: 'button',
|
|
515
|
+
title: m.desc,
|
|
516
|
+
className: `aw-mode-btn ${mode === m.id ? 'active' : ''}`,
|
|
517
|
+
onClick: () => setMode(m.id),
|
|
518
|
+
}, m.label)),
|
|
519
|
+
lockedTopic ? h('span', { className: 'aw-topic-chip' },
|
|
520
|
+
`${lang === 'en' ? 'Topic' : '主题'}:${lockedTopic.label}`,
|
|
521
|
+
h('button', { type: 'button', title: '取消特定主题', onClick: () => setMode('general') }, '×')) : null),
|
|
522
|
+
h('button', {
|
|
523
|
+
type: 'submit',
|
|
524
|
+
className: 'aw-send',
|
|
525
|
+
disabled: !input.trim(),
|
|
526
|
+
title: '开始检索分析',
|
|
527
|
+
}, '→'))),
|
|
528
|
+
suggestions.length > 0 ? h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: '8px', marginTop: '14px', alignItems: 'center' } },
|
|
529
|
+
suggestions.map((s, idx) => h('button', {
|
|
530
|
+
key: `${s.source}-${idx}`,
|
|
531
|
+
type: 'button',
|
|
532
|
+
className: 'aw-filter',
|
|
533
|
+
style: { display: 'inline-flex', alignItems: 'center', gap: '5px', fontSize: '12px', maxWidth: '100%' },
|
|
534
|
+
onClick: () => startSearch(s.query, mode),
|
|
535
|
+
},
|
|
536
|
+
h('span', { style: { opacity: 0.7, fontSize: '11px' } }, `[${s.tag}]`),
|
|
537
|
+
h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', maxWidth: '240px' } }, s.query))),
|
|
538
|
+
h('button', {
|
|
539
|
+
type: 'button',
|
|
540
|
+
className: 'aw-preset-try',
|
|
541
|
+
style: { color: 'var(--aw-text-3)', marginLeft: 'auto' },
|
|
542
|
+
onClick: () => refreshSuggestions(mode, lang, true),
|
|
543
|
+
}, lang === 'en' ? 'Shuffle' : '换一批')) : null,
|
|
544
|
+
h('div', { className: 'aw-sec-head' },
|
|
545
|
+
h('span', null, '特定主题'),
|
|
546
|
+
h('div', { style: { display: 'flex', gap: '10px', alignItems: 'center' } },
|
|
547
|
+
activeQuery && cards.length > 0 ? h('button', {
|
|
548
|
+
type: 'button',
|
|
549
|
+
className: 'aw-preset-try',
|
|
550
|
+
onClick: () => setView('result'),
|
|
551
|
+
}, `继续上次:${activeQuery.slice(0, 14)}${activeQuery.length > 14 ? '…' : ''} ↗`) : null,
|
|
552
|
+
h('button', {
|
|
553
|
+
type: 'button',
|
|
554
|
+
className: 'aw-preset-try',
|
|
555
|
+
style: { color: 'var(--aw-text-3)' },
|
|
556
|
+
onClick: () => setTopicSamples(Object.fromEntries(TOPIC_CARDS.map(t => [t.id, pickSample(t.samples)]))),
|
|
557
|
+
}, '换一批引导'))),
|
|
558
|
+
h('div', { className: 'aw-presets' },
|
|
559
|
+
TOPIC_CARDS.map(item => h('div', {
|
|
560
|
+
key: item.id,
|
|
561
|
+
className: `aw-preset ${mode === item.id ? 'selected' : ''}`,
|
|
562
|
+
onClick: () => { setMode(item.id); inputRef.current?.focus?.() },
|
|
563
|
+
},
|
|
564
|
+
h('div', null,
|
|
565
|
+
h('div', { className: 'aw-preset-tag' }, item.label),
|
|
566
|
+
h('div', { className: 'aw-preset-desc', style: { marginTop: '4px' } }, item.desc)),
|
|
567
|
+
h('button', {
|
|
568
|
+
type: 'button',
|
|
569
|
+
className: 'aw-preset-try',
|
|
570
|
+
onClick: (e) => { e.stopPropagation(); startSearch(topicSamples[item.id] || pickSample(item.samples), item.id) },
|
|
571
|
+
}, '试一试 ↗')))))))
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
return h('div', { className: 'aw-root' },
|
|
575
|
+
h('div', { className: 'aw-topbar' },
|
|
576
|
+
h('button', { type: 'button', className: 'aw-icon-btn', onClick: () => setView('home') }, '← 首页'),
|
|
577
|
+
h('select', {
|
|
578
|
+
className: 'aw-select',
|
|
579
|
+
value: mode,
|
|
580
|
+
onChange: (e) => {
|
|
581
|
+
const nextMode = e.target.value
|
|
582
|
+
setMode(nextMode)
|
|
583
|
+
if (activeQuery) startSearch(activeQuery, nextMode)
|
|
584
|
+
},
|
|
585
|
+
}, ALL_MODES.map(m => h('option', { key: m.id, value: m.id }, m.label))),
|
|
586
|
+
h('form', {
|
|
587
|
+
className: 'aw-top-form',
|
|
588
|
+
onSubmit: (e) => { e.preventDefault(); startSearch(input, mode) },
|
|
589
|
+
},
|
|
590
|
+
h('input', {
|
|
591
|
+
className: 'aw-top-input',
|
|
592
|
+
value: input,
|
|
593
|
+
onChange: (e) => setInput(e.target.value),
|
|
594
|
+
placeholder: '输入新的查询…',
|
|
595
|
+
}),
|
|
596
|
+
h('button', {
|
|
597
|
+
type: 'button',
|
|
598
|
+
className: 'aw-filter',
|
|
599
|
+
title: '跳过缓存重新检索',
|
|
600
|
+
onClick: () => startSearch(input || activeQuery, mode, true),
|
|
601
|
+
}, '强制刷新'),
|
|
602
|
+
h('button', {
|
|
603
|
+
type: 'submit',
|
|
604
|
+
className: 'aw-send',
|
|
605
|
+
style: { width: '28px', height: '28px' },
|
|
606
|
+
disabled: !input.trim(),
|
|
607
|
+
}, '→')),
|
|
608
|
+
h('div', { className: 'aw-stat-pill' }, `${cards.length} 条来源,${verifiedCount} 条已核验`),
|
|
609
|
+
h('button', {
|
|
610
|
+
type: 'button',
|
|
611
|
+
className: 'aw-icon-btn',
|
|
612
|
+
title: '把当前查询加入定时追踪',
|
|
613
|
+
onClick: () => createWatch(activeQuery, mode, watchInterval),
|
|
614
|
+
}, '定时追踪'),
|
|
615
|
+
h('button', { type: 'button', className: 'aw-icon-btn', onClick: toggleWatchPanel }, `定时 (${watches.length})`),
|
|
616
|
+
h('button', { type: 'button', className: 'aw-icon-btn', onClick: openDebug }, 'DEBUG'),
|
|
617
|
+
h('button', {
|
|
618
|
+
type: 'button',
|
|
619
|
+
className: 'aw-icon-btn',
|
|
620
|
+
onClick: toggleSettingsPanel,
|
|
621
|
+
}, '设置')),
|
|
622
|
+
|
|
623
|
+
renderWatchDrawer(),
|
|
624
|
+
|
|
625
|
+
popover === 'debug' ? h('div', { className: 'aw-popover' },
|
|
626
|
+
h('div', { style: { fontWeight: 600, marginBottom: '8px' } }, '最近 20 次工作台检索诊断'),
|
|
627
|
+
healthInfo?.breaker ? h('div', { style: { padding: '6px 8px', marginBottom: '8px', borderRadius: '8px', background: 'var(--aw-sunken)', fontSize: '12px' } },
|
|
628
|
+
`熔断器:${healthInfo.breaker.total} 源 · 非闭合 ${healthInfo.breaker.nonClosedCount} 源` +
|
|
629
|
+
(healthInfo.breaker.topTripped?.length ? `(${healthInfo.breaker.topTripped.slice(0, 3).map(t => `${t.engine}:${t.state}`).join(', ')})` : '')) : null,
|
|
630
|
+
diagItems.length === 0
|
|
631
|
+
? h('div', { style: { color: 'var(--aw-text-3)' } }, '暂无记录')
|
|
632
|
+
: diagItems.map((it, idx) => h('div', {
|
|
633
|
+
key: idx,
|
|
634
|
+
style: { padding: '6px 0', borderBottom: '1px solid var(--aw-border)' },
|
|
635
|
+
},
|
|
636
|
+
h('div', { style: { fontWeight: 600 } }, `[${it.mode}] ${it.query}`),
|
|
637
|
+
h('div', { style: { color: 'var(--aw-text-3)' } }, `${it.durationMs}ms · 来源 ${it.cardCount} · 核验 ${it.verifiedCount ?? 0} · ${it.status}`)))) : null,
|
|
638
|
+
|
|
639
|
+
popover === 'settings' ? h('div', { className: 'aw-popover', style: { width: '280px' } },
|
|
640
|
+
h('div', { style: { fontWeight: 600, marginBottom: '10px' } }, '工作台偏好与能力'),
|
|
641
|
+
h('label', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', cursor: 'pointer', marginBottom: '8px' } },
|
|
642
|
+
h('span', null, '对话划词浮层(Argo 分析)'),
|
|
643
|
+
h('input', { type: 'checkbox', checked: Boolean(prefs.selection), onChange: toggleSelectionPref })),
|
|
644
|
+
h('label', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', cursor: 'pointer' } },
|
|
645
|
+
h('span', null, '登录态专业搜索(ego-search)'),
|
|
646
|
+
h('input', { type: 'checkbox', checked: Boolean(healthInfo?.egoSearch?.enabled), onChange: toggleEgoSearch })),
|
|
647
|
+
h('button', {
|
|
648
|
+
type: 'button',
|
|
649
|
+
className: 'aw-icon-btn',
|
|
650
|
+
style: { marginTop: '12px', width: '100%', justifyContent: 'center' },
|
|
651
|
+
onClick: () => {
|
|
652
|
+
window.localStorage.removeItem(STATE_KEY)
|
|
653
|
+
setActiveQuery(''); setCards([]); setTurns([]); setGateResult(null); setView('home'); setPopover(null)
|
|
654
|
+
},
|
|
655
|
+
}, '清空当前工作台记录')) : null,
|
|
656
|
+
|
|
657
|
+
h('div', { className: 'aw-main' },
|
|
658
|
+
h('div', null,
|
|
659
|
+
h('div', { className: 'aw-q-head' },
|
|
660
|
+
h('h2', { className: 'aw-q-title' }, activeQuery),
|
|
661
|
+
h('span', { className: 'aw-badge' }, currentModeObj.label),
|
|
662
|
+
evidenceSummary?.crossValidation ? h('span', {
|
|
663
|
+
className: 'aw-badge',
|
|
664
|
+
title: evidenceSummary.crossValidation.detail || '',
|
|
665
|
+
}, `交叉验证:${evidenceSummary.crossValidation.corroboration_level || 'unknown'}${evidenceSummary.summary ? ` · 高可信 ${evidenceSummary.summary.high_credibility || 0}` : ''}`) : null,
|
|
666
|
+
gateResult ? h('span', {
|
|
667
|
+
className: 'aw-badge',
|
|
668
|
+
title: (gateResult.warnings || []).join(';'),
|
|
669
|
+
style: { background: gateResult.passed ? 'var(--aw-sunken)' : '#fef2f2', color: gateResult.passed ? 'var(--aw-text-2)' : '#b91c1c' },
|
|
670
|
+
}, gateResult.passed ? '质量门禁通过' : '质量门禁未达标') : null),
|
|
671
|
+
clarifyInfo ? h('div', { style: { fontSize: '12px', color: 'var(--aw-text-2)', padding: '6px 10px', marginBottom: '10px', borderRadius: '8px', background: 'var(--aw-sunken)' } },
|
|
672
|
+
clarifyInfo.explanation || '',
|
|
673
|
+
Array.isArray(clarifyInfo.ambiguities) && clarifyInfo.ambiguities.length > 0
|
|
674
|
+
? ` · 歧义提示:${clarifyInfo.ambiguities.slice(0, 2).map(a => a.term || a).join(' / ')}`
|
|
675
|
+
: '') : null,
|
|
676
|
+
loading || stageText ? h('div', { className: 'aw-progress' },
|
|
677
|
+
loading ? h('span', { className: 'aw-dot' }) : null,
|
|
678
|
+
h('span', null, stageText || '处理中…')) : null,
|
|
679
|
+
turns.map((turn, idx) => h('div', { key: idx, className: 'aw-turn' },
|
|
680
|
+
turn.role === 'user'
|
|
681
|
+
? h('div', { className: 'aw-turn-q' }, turn.text)
|
|
682
|
+
: h('div', { className: 'aw-md' }, renderMarkdown(h, turn.text, cards, scrollToCard)))),
|
|
683
|
+
!loading && cards.length > 0 ? h('form', { className: 'aw-followup', onSubmit: handleFollowup },
|
|
684
|
+
h('input', {
|
|
685
|
+
value: followup,
|
|
686
|
+
onChange: (e) => setFollowup(e.target.value),
|
|
687
|
+
placeholder: '基于当前检索证据继续追问细节…',
|
|
688
|
+
}),
|
|
689
|
+
h('button', { type: 'submit', className: 'aw-send', disabled: !followup.trim() }, '→')) : null),
|
|
690
|
+
|
|
691
|
+
h('div', null,
|
|
692
|
+
h('div', { className: 'aw-right-head' },
|
|
693
|
+
h('strong', { style: { fontSize: '13px' } }, '证据与原文出处'),
|
|
694
|
+
h('div', { className: 'aw-filters' },
|
|
695
|
+
h('button', {
|
|
696
|
+
type: 'button',
|
|
697
|
+
className: `aw-filter ${filter === 'all' ? 'active' : ''}`,
|
|
698
|
+
onClick: () => setFilter('all'),
|
|
699
|
+
}, `全部 (${cards.length})`),
|
|
700
|
+
verifiedCount > 0 ? h('button', {
|
|
701
|
+
type: 'button',
|
|
702
|
+
className: `aw-filter ${filter === 'verified' ? 'active' : ''}`,
|
|
703
|
+
onClick: () => setFilter('verified'),
|
|
704
|
+
}, `已核验 (${verifiedCount})`) : null,
|
|
705
|
+
sources.slice(0, 4).map(src => h('button', {
|
|
706
|
+
key: src,
|
|
707
|
+
type: 'button',
|
|
708
|
+
className: `aw-filter ${filter === src ? 'active' : ''}`,
|
|
709
|
+
onClick: () => setFilter(src),
|
|
710
|
+
}, src)))),
|
|
711
|
+
h('div', { className: 'aw-cards' },
|
|
712
|
+
visibleCards.length === 0
|
|
713
|
+
? h('div', { style: { color: 'var(--aw-text-3)', fontSize: '13px', padding: '12px' } }, loading ? '正在拉取多源证据…' : '暂无匹配卡片')
|
|
714
|
+
: visibleCards.map(c => h('div', {
|
|
715
|
+
key: c.id,
|
|
716
|
+
id: `aw-${c.id}`,
|
|
717
|
+
className: `aw-card ${flashId === c.id ? 'flash' : ''}`,
|
|
718
|
+
},
|
|
719
|
+
h('div', { className: 'aw-card-top' },
|
|
720
|
+
h('span', { className: 'aw-card-src' },
|
|
721
|
+
h('span', { className: 'aw-idx' }, String(c.index)),
|
|
722
|
+
h('span', null, `${c.source}${c.domain ? ` · ${c.domain}` : ''}`)),
|
|
723
|
+
c.verified ? h('span', { className: 'aw-verified' }, '已核验原文') : null),
|
|
724
|
+
h('p', { className: 'aw-card-quote' }, (c.verifiedText || c.snippet || '暂无摘录').slice(0, 220)),
|
|
725
|
+
h('a', {
|
|
726
|
+
className: 'aw-card-link',
|
|
727
|
+
href: c.url,
|
|
728
|
+
target: '_blank',
|
|
729
|
+
rel: 'noopener noreferrer',
|
|
730
|
+
},
|
|
731
|
+
h('span', { style: { overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, c.title),
|
|
732
|
+
h('span', { style: { flexShrink: 0 } }, '↗'))))))))
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
function SelectionPill() {
|
|
736
|
+
const [hit, setHit] = useState(null)
|
|
737
|
+
|
|
738
|
+
useEffect(() => {
|
|
739
|
+
const checkSelection = () => {
|
|
740
|
+
const prefs = readStorage(PREFS_KEY, { selection: true })
|
|
741
|
+
if (!prefs.selection) { setHit(null); return }
|
|
742
|
+
const sel = window.getSelection?.()
|
|
743
|
+
const text = sel ? String(sel.toString() || '').trim() : ''
|
|
744
|
+
if (text.length < 4 || text.length > 200) { setHit(null); return }
|
|
745
|
+
const range = sel.rangeCount > 0 ? sel.getRangeAt(0) : null
|
|
746
|
+
if (!range) { setHit(null); return }
|
|
747
|
+
const rect = range.getBoundingClientRect()
|
|
748
|
+
if (!rect || (rect.width === 0 && rect.height === 0)) { setHit(null); return }
|
|
749
|
+
setHit({ text, top: Math.max(12, rect.top - 38), left: Math.min(window.innerWidth - 130, Math.max(12, rect.left)) })
|
|
750
|
+
}
|
|
751
|
+
const onUp = () => setTimeout(checkSelection, 20)
|
|
752
|
+
document.addEventListener('mouseup', onUp)
|
|
753
|
+
document.addEventListener('keyup', onUp)
|
|
754
|
+
return () => {
|
|
755
|
+
document.removeEventListener('mouseup', onUp)
|
|
756
|
+
document.removeEventListener('keyup', onUp)
|
|
757
|
+
}
|
|
758
|
+
}, [])
|
|
759
|
+
|
|
760
|
+
if (!hit) return null
|
|
761
|
+
return h('button', {
|
|
762
|
+
type: 'button',
|
|
763
|
+
className: 'aw-sel-pill',
|
|
764
|
+
style: { top: `${hit.top}px`, left: `${hit.left}px` },
|
|
765
|
+
onMouseDown: (e) => {
|
|
766
|
+
e.preventDefault()
|
|
767
|
+
const text = hit.text
|
|
768
|
+
setHit(null)
|
|
769
|
+
requestSearch(text, 'general')
|
|
770
|
+
try {
|
|
771
|
+
ctx.get?.('layout')?.selectPanel?.('argo-workbench')
|
|
772
|
+
} catch { /* ignore */ }
|
|
773
|
+
},
|
|
774
|
+
}, 'Argo 分析')
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
const offs = [
|
|
778
|
+
ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: 'argo-workbench' }, WorkbenchApp)),
|
|
779
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register(
|
|
780
|
+
{ name: 'sidebar.panellist', id: 'argo-workbench', order: 5, label: 'Argo 搜索' },
|
|
781
|
+
({ size = 20, active }) => h('svg', {
|
|
782
|
+
width: size, height: size, viewBox: '0 0 24 24', fill: 'none',
|
|
783
|
+
stroke: active ? '#ea580c' : 'currentColor', strokeWidth: 1.8,
|
|
784
|
+
strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true,
|
|
785
|
+
},
|
|
786
|
+
h('circle', { cx: 11, cy: 11, r: 7 }),
|
|
787
|
+
h('path', { d: 'M16.5 16.5 21 21' }),
|
|
788
|
+
h('path', { d: 'M11 7.2 13.8 13.8 11 12.3 8.2 13.8 11 7.2Z', fill: '#ea580c', stroke: 'none' })),
|
|
789
|
+
)),
|
|
790
|
+
ctx.slots.inject('global', () => ctx.slots.register({ name: 'global', key: 'argo-workbench-pill' }, SelectionPill)),
|
|
791
|
+
]
|
|
792
|
+
|
|
793
|
+
return () => {
|
|
794
|
+
for (const off of offs) if (typeof off === 'function') off()
|
|
795
|
+
}
|
|
796
|
+
}
|