App.vue 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023
  1. <template>
  2. <main class="app-shell">
  3. <div class="aurora" aria-hidden="true">
  4. <span></span>
  5. <span></span>
  6. <span></span>
  7. </div>
  8. <div class="layout">
  9. <section class="panel panel-form">
  10. <header class="panel-head">
  11. <div class="logo">
  12. <svg viewBox="0 0 24 24" aria-hidden="true">
  13. <path
  14. d="M12 2.5c-.7 0-1.4.2-2 .6L4.6 7C3.6 7.6 3 8.7 3 9.9v4.2c0 1.2.6 2.3 1.6 2.9l5.4 3.9c1.2.8 2.8.8 4 0l5.4-3.9c1-.7 1.6-1.7 1.6-2.9V9.9c0-1.2-.6-2.3-1.6-2.9L14 3.1a3.6 3.6 0 0 0-2-.6Z"
  15. />
  16. </svg>
  17. </div>
  18. <div>
  19. <h1>深度研究助手</h1>
  20. <p>结合多轮智能检索与总结,实时呈现洞见与引用。</p>
  21. </div>
  22. </header>
  23. <form class="form" @submit.prevent="handleSubmit">
  24. <label class="field">
  25. <span>研究主题</span>
  26. <textarea
  27. v-model="form.topic"
  28. placeholder="例如:探索多模态模型在 2025 年的关键突破"
  29. rows="4"
  30. required
  31. ></textarea>
  32. </label>
  33. <section class="options">
  34. <label class="field option">
  35. <span>搜索引擎</span>
  36. <select v-model="form.searchApi">
  37. <option value="">沿用后端配置</option>
  38. <option
  39. v-for="option in searchOptions"
  40. :key="option"
  41. :value="option"
  42. >
  43. {{ option }}
  44. </option>
  45. </select>
  46. </label>
  47. </section>
  48. <div class="form-actions">
  49. <button class="submit" type="submit" :disabled="loading">
  50. <span class="submit-label">
  51. <svg
  52. v-if="loading"
  53. class="spinner"
  54. viewBox="0 0 24 24"
  55. aria-hidden="true"
  56. >
  57. <circle cx="12" cy="12" r="9" stroke-width="3" />
  58. </svg>
  59. {{ loading ? "研究进行中..." : "开始研究" }}
  60. </span>
  61. </button>
  62. <button
  63. v-if="loading"
  64. type="button"
  65. class="secondary-btn"
  66. @click="cancelResearch"
  67. >
  68. 取消研究
  69. </button>
  70. </div>
  71. </form>
  72. <p v-if="error" class="error-chip">
  73. <svg viewBox="0 0 20 20" aria-hidden="true">
  74. <path
  75. d="M10 3.2c-.3 0-.6.2-.8.5L3.4 15c-.4.7.1 1.6.8 1.6h11.6c.7 0 1.2-.9.8-1.6L10.8 3.7c-.2-.3-.5-.5-.8-.5Zm0 4.3c.4 0 .7.3.7.7v4c0 .4-.3.7-.7.7s-.7-.3-.7-.7V8.2c0-.4.3-.7.7-.7Zm0 6.6a1 1 0 1 1 0 2 1 1 0 0 1 0-2Z"
  76. />
  77. </svg>
  78. {{ error }}
  79. </p>
  80. <p v-else-if="loading" class="hint muted">
  81. 正在收集线索与证据,实时进展见右侧区域。
  82. </p>
  83. </section>
  84. <section
  85. class="panel panel-result"
  86. v-if="todoTasks.length || reportMarkdown || progressLogs.length"
  87. >
  88. <header class="status-bar">
  89. <div class="status-main">
  90. <div class="status-chip" :class="{ active: loading }">
  91. <span class="dot"></span>
  92. {{ loading ? "研究进行中" : "研究流程完成" }}
  93. </div>
  94. <span class="status-meta">
  95. 任务进度:{{ completedTasks }} / {{ totalTasks || todoTasks.length || 1 }}
  96. · 阶段记录 {{ progressLogs.length }} 条
  97. </span>
  98. </div>
  99. <div class="status-controls">
  100. <button class="secondary-btn" @click="logsCollapsed = !logsCollapsed">
  101. {{ logsCollapsed ? "展开流程" : "收起流程" }}
  102. </button>
  103. </div>
  104. </header>
  105. <div class="timeline-wrapper" v-show="!logsCollapsed && progressLogs.length">
  106. <transition-group name="timeline" tag="ul" class="timeline">
  107. <li v-for="(log, index) in progressLogs" :key="`${log}-${index}`">
  108. <span class="timeline-node"></span>
  109. <p>{{ log }}</p>
  110. </li>
  111. </transition-group>
  112. </div>
  113. <div class="tasks-section" v-if="todoTasks.length">
  114. <aside class="tasks-list">
  115. <h3>任务清单</h3>
  116. <ul>
  117. <li
  118. v-for="task in todoTasks"
  119. :key="task.id"
  120. :class="['task-item', { active: task.id === activeTaskId, completed: task.status === 'completed' }]"
  121. >
  122. <button
  123. type="button"
  124. class="task-button"
  125. @click="activeTaskId = task.id"
  126. >
  127. <span class="task-title">{{ task.title }}</span>
  128. <span class="task-status" :class="task.status">
  129. {{ formatTaskStatus(task.status) }}
  130. </span>
  131. </button>
  132. <p class="task-intent">{{ task.intent }}</p>
  133. </li>
  134. </ul>
  135. </aside>
  136. <article class="task-detail" v-if="currentTask">
  137. <header class="task-header">
  138. <div>
  139. <h3>{{ currentTaskTitle || "当前任务" }}</h3>
  140. <p class="muted" v-if="currentTaskIntent">
  141. {{ currentTaskIntent }}
  142. </p>
  143. </div>
  144. <div class="task-chip-group">
  145. <span class="task-label">查询:{{ currentTaskQuery || "" }}</span>
  146. <span
  147. v-if="currentTaskNoteId"
  148. class="task-label note-chip"
  149. :title="currentTaskNoteId"
  150. >
  151. 笔记:{{ currentTaskNoteId }}
  152. </span>
  153. <span
  154. v-if="currentTaskNotePath"
  155. class="task-label note-chip path-chip"
  156. :title="currentTaskNotePath"
  157. >
  158. <span class="path-label">路径:</span>
  159. <span class="path-text">{{ currentTaskNotePath }}</span>
  160. <button
  161. class="chip-action"
  162. type="button"
  163. @click="copyNotePath(currentTaskNotePath)"
  164. >
  165. 复制
  166. </button>
  167. </span>
  168. </div>
  169. </header>
  170. <section v-if="currentTask && currentTask.notices.length" class="task-notices">
  171. <h4>系统提示</h4>
  172. <ul>
  173. <li v-for="(notice, idx) in currentTask.notices" :key="`${notice}-${idx}`">
  174. {{ notice }}
  175. </li>
  176. </ul>
  177. </section>
  178. <section
  179. class="sources-block"
  180. :class="{ 'block-highlight': sourcesHighlight }"
  181. >
  182. <h3>最新来源</h3>
  183. <template v-if="currentTaskSources.length">
  184. <ul class="sources-list">
  185. <li
  186. v-for="(item, index) in currentTaskSources"
  187. :key="`${item.title}-${index}`"
  188. class="source-item"
  189. >
  190. <a
  191. class="source-link"
  192. :href="item.url || '#'"
  193. target="_blank"
  194. rel="noopener noreferrer"
  195. >
  196. {{ item.title || item.url || `来源 ${index + 1}` }}
  197. </a>
  198. <div v-if="item.snippet || item.raw" class="source-tooltip">
  199. <p v-if="item.snippet">{{ item.snippet }}</p>
  200. <p v-if="item.raw" class="muted-text">{{ item.raw }}</p>
  201. </div>
  202. </li>
  203. </ul>
  204. </template>
  205. <p v-else class="muted">暂无可用来源</p>
  206. </section>
  207. <section
  208. class="summary-block"
  209. :class="{ 'block-highlight': summaryHighlight }"
  210. >
  211. <h3>任务总结</h3>
  212. <pre class="block-pre">{{ currentTaskSummary || "暂无可用信息" }}</pre>
  213. </section>
  214. <section
  215. class="tools-block"
  216. :class="{ 'block-highlight': toolHighlight }"
  217. v-if="currentTaskToolCalls.length"
  218. >
  219. <h3>工具调用记录</h3>
  220. <ul class="tool-list">
  221. <li
  222. v-for="entry in currentTaskToolCalls"
  223. :key="`${entry.eventId}-${entry.timestamp}`"
  224. class="tool-entry"
  225. >
  226. <div class="tool-entry-header">
  227. <span class="tool-entry-title">
  228. #{{ entry.eventId }} {{ entry.agent }} → {{ entry.tool }}
  229. </span>
  230. <span
  231. v-if="entry.noteId"
  232. class="tool-entry-note"
  233. >
  234. 笔记:{{ entry.noteId }}
  235. </span>
  236. </div>
  237. <p v-if="entry.notePath" class="tool-entry-path">
  238. 笔记路径:
  239. <button
  240. class="link-btn"
  241. type="button"
  242. @click="copyNotePath(entry.notePath)"
  243. >
  244. 复制
  245. </button>
  246. <span class="path-text">{{ entry.notePath }}</span>
  247. </p>
  248. <p class="tool-subtitle">参数</p>
  249. <pre class="tool-pre">{{ formatToolParameters(entry.parameters) }}</pre>
  250. <template v-if="entry.result">
  251. <p class="tool-subtitle">执行结果</p>
  252. <pre class="tool-pre">{{ formatToolResult(entry.result) }}</pre>
  253. </template>
  254. </li>
  255. </ul>
  256. </section>
  257. </article>
  258. <article class="task-detail" v-else>
  259. <p class="muted">等待任务规划或执行结果。</p>
  260. </article>
  261. </div>
  262. <div
  263. v-if="reportMarkdown"
  264. class="report-block"
  265. :class="{ 'block-highlight': reportHighlight }"
  266. >
  267. <h3>最终报告</h3>
  268. <pre class="block-pre">{{ reportMarkdown }}</pre>
  269. </div>
  270. </section>
  271. </div>
  272. </main>
  273. </template>
  274. <script lang="ts" setup>
  275. import { computed, onBeforeUnmount, reactive, ref } from "vue";
  276. import {
  277. runResearchStream,
  278. type ResearchStreamEvent
  279. } from "./services/api";
  280. interface SourceItem {
  281. title: string;
  282. url: string;
  283. snippet: string;
  284. raw: string;
  285. }
  286. interface ToolCallLog {
  287. eventId: number;
  288. agent: string;
  289. tool: string;
  290. parameters: Record<string, unknown>;
  291. result: string;
  292. noteId: string | null;
  293. notePath: string | null;
  294. timestamp: number;
  295. }
  296. interface TodoTaskView {
  297. id: number;
  298. title: string;
  299. intent: string;
  300. query: string;
  301. status: string;
  302. summary: string;
  303. sourcesSummary: string;
  304. sourceItems: SourceItem[];
  305. notices: string[];
  306. noteId: string | null;
  307. notePath: string | null;
  308. toolCalls: ToolCallLog[];
  309. }
  310. const form = reactive({
  311. topic: "",
  312. searchApi: ""
  313. });
  314. const loading = ref(false);
  315. const error = ref("");
  316. const progressLogs = ref<string[]>([]);
  317. const logsCollapsed = ref(false);
  318. const todoTasks = ref<TodoTaskView[]>([]);
  319. const activeTaskId = ref<number | null>(null);
  320. const reportMarkdown = ref("");
  321. const summaryHighlight = ref(false);
  322. const sourcesHighlight = ref(false);
  323. const reportHighlight = ref(false);
  324. const toolHighlight = ref(false);
  325. let currentController: AbortController | null = null;
  326. const searchOptions = [
  327. "advanced",
  328. "duckduckgo",
  329. "tavily",
  330. "perplexity",
  331. "searxng"
  332. ];
  333. const TASK_STATUS_LABEL: Record<string, string> = {
  334. pending: "待执行",
  335. in_progress: "进行中",
  336. completed: "已完成",
  337. skipped: "已跳过"
  338. };
  339. function formatTaskStatus(status: string): string {
  340. return TASK_STATUS_LABEL[status] ?? status;
  341. }
  342. const totalTasks = computed(() => todoTasks.value.length);
  343. const completedTasks = computed(() =>
  344. todoTasks.value.filter((task) => task.status === "completed").length
  345. );
  346. const currentTask = computed(() => {
  347. if (activeTaskId.value !== null) {
  348. return todoTasks.value.find((task) => task.id === activeTaskId.value) ?? null;
  349. }
  350. return todoTasks.value[0] ?? null;
  351. });
  352. const currentTaskSources = computed(() => currentTask.value?.sourceItems ?? []);
  353. const currentTaskSummary = computed(() => currentTask.value?.summary ?? "");
  354. const currentTaskTitle = computed(() => currentTask.value?.title ?? "");
  355. const currentTaskIntent = computed(() => currentTask.value?.intent ?? "");
  356. const currentTaskQuery = computed(() => currentTask.value?.query ?? "");
  357. const currentTaskNoteId = computed(() => currentTask.value?.noteId ?? "");
  358. const currentTaskNotePath = computed(() => currentTask.value?.notePath ?? "");
  359. const currentTaskToolCalls = computed(
  360. () => currentTask.value?.toolCalls ?? []
  361. );
  362. const pulse = (flag: typeof summaryHighlight) => {
  363. flag.value = false;
  364. requestAnimationFrame(() => {
  365. flag.value = true;
  366. window.setTimeout(() => {
  367. flag.value = false;
  368. }, 1200);
  369. });
  370. };
  371. function parseSources(raw: string): SourceItem[] {
  372. if (!raw) {
  373. return [];
  374. }
  375. const items: SourceItem[] = [];
  376. const lines = raw.split("\n");
  377. let current: SourceItem | null = null;
  378. const truncate = (value: string, max = 360) => {
  379. const trimmed = value.trim();
  380. return trimmed.length > max ? `${trimmed.slice(0, max)}…` : trimmed;
  381. };
  382. const flush = () => {
  383. if (!current) {
  384. return;
  385. }
  386. const normalized: SourceItem = {
  387. title: current.title?.trim() || "",
  388. url: current.url?.trim() || "",
  389. snippet: current.snippet ? truncate(current.snippet) : "",
  390. raw: current.raw ? truncate(current.raw, 420) : ""
  391. };
  392. if (
  393. normalized.title ||
  394. normalized.url ||
  395. normalized.snippet ||
  396. normalized.raw
  397. ) {
  398. if (!normalized.title && normalized.url) {
  399. normalized.title = normalized.url;
  400. }
  401. items.push(normalized);
  402. }
  403. current = null;
  404. };
  405. const ensureCurrent = () => {
  406. if (!current) {
  407. current = { title: "", url: "", snippet: "", raw: "" };
  408. }
  409. };
  410. for (const line of lines) {
  411. const trimmed = line.trim();
  412. if (!trimmed) {
  413. continue;
  414. }
  415. if (/^\*/.test(trimmed) && trimmed.includes(" : ")) {
  416. flush();
  417. const withoutBullet = trimmed.replace(/^\*\s*/, "");
  418. const [titlePart, urlPart] = withoutBullet.split(" : ");
  419. current = {
  420. title: titlePart?.trim() || "",
  421. url: urlPart?.trim() || "",
  422. snippet: "",
  423. raw: ""
  424. };
  425. continue;
  426. }
  427. if (/^(Source|信息来源)\s*:/.test(trimmed)) {
  428. flush();
  429. const [, titlePart = ""] = trimmed.split(/:\s*(.+)/);
  430. current = {
  431. title: titlePart.trim(),
  432. url: "",
  433. snippet: "",
  434. raw: ""
  435. };
  436. continue;
  437. }
  438. if (/^URL\s*:/.test(trimmed)) {
  439. ensureCurrent();
  440. const [, urlPart = ""] = trimmed.split(/:\s*(.+)/);
  441. current!.url = urlPart.trim();
  442. continue;
  443. }
  444. if (
  445. /^(Most relevant content from source|信息内容)\s*:/.test(trimmed)
  446. ) {
  447. ensureCurrent();
  448. const [, contentPart = ""] = trimmed.split(/:\s*(.+)/);
  449. current!.snippet = contentPart.trim();
  450. continue;
  451. }
  452. if (
  453. /^(Full source content limited to|信息内容限制为)\s*:/.test(trimmed)
  454. ) {
  455. ensureCurrent();
  456. const [, rawPart = ""] = trimmed.split(/:\s*(.+)/);
  457. current!.raw = rawPart.trim();
  458. continue;
  459. }
  460. if (/^https?:\/\//.test(trimmed)) {
  461. ensureCurrent();
  462. if (!current!.url) {
  463. current!.url = trimmed;
  464. continue;
  465. }
  466. }
  467. ensureCurrent();
  468. current!.raw = current!.raw ? `${current!.raw}\n${trimmed}` : trimmed;
  469. }
  470. flush();
  471. return items;
  472. }
  473. function extractOptionalString(value: unknown): string | null {
  474. if (typeof value !== "string") {
  475. return null;
  476. }
  477. const trimmed = value.trim();
  478. return trimmed ? trimmed : null;
  479. }
  480. function ensureRecord(value: unknown): Record<string, unknown> {
  481. if (value && typeof value === "object" && !Array.isArray(value)) {
  482. return value as Record<string, unknown>;
  483. }
  484. return {};
  485. }
  486. function applyNoteMetadata(
  487. task: TodoTaskView,
  488. payload: Record<string, unknown>
  489. ): void {
  490. const noteId = extractOptionalString(payload.note_id);
  491. if (noteId) {
  492. task.noteId = noteId;
  493. }
  494. const notePath = extractOptionalString(payload.note_path);
  495. if (notePath) {
  496. task.notePath = notePath;
  497. }
  498. }
  499. function formatToolParameters(parameters: Record<string, unknown>): string {
  500. try {
  501. return JSON.stringify(parameters, null, 2);
  502. } catch (error) {
  503. console.warn("无法格式化工具参数", error, parameters);
  504. return Object.entries(parameters)
  505. .map(([key, value]) => `${key}: ${String(value)}`)
  506. .join("\n");
  507. }
  508. }
  509. function formatToolResult(result: string): string {
  510. const trimmed = result.trim();
  511. const limit = 900;
  512. if (trimmed.length > limit) {
  513. return `${trimmed.slice(0, limit)}…`;
  514. }
  515. return trimmed;
  516. }
  517. async function copyNotePath(path: string | null | undefined) {
  518. if (!path) {
  519. return;
  520. }
  521. try {
  522. await navigator.clipboard.writeText(path);
  523. progressLogs.value.push(`已复制笔记路径:${path}`);
  524. } catch (error) {
  525. console.warn("无法直接复制到剪贴板", error);
  526. window.prompt("复制以下笔记路径", path);
  527. progressLogs.value.push("请手动复制笔记路径");
  528. }
  529. }
  530. function resetWorkflowState() {
  531. todoTasks.value = [];
  532. activeTaskId.value = null;
  533. reportMarkdown.value = "";
  534. progressLogs.value = [];
  535. summaryHighlight.value = false;
  536. sourcesHighlight.value = false;
  537. reportHighlight.value = false;
  538. toolHighlight.value = false;
  539. logsCollapsed.value = false;
  540. }
  541. function findTask(taskId: unknown): TodoTaskView | undefined {
  542. const numeric =
  543. typeof taskId === "number"
  544. ? taskId
  545. : typeof taskId === "string"
  546. ? Number(taskId)
  547. : NaN;
  548. if (Number.isNaN(numeric)) {
  549. return undefined;
  550. }
  551. return todoTasks.value.find((task) => task.id === numeric);
  552. }
  553. function upsertTaskMetadata(task: TodoTaskView, payload: Record<string, unknown>) {
  554. if (typeof payload.title === "string" && payload.title.trim()) {
  555. task.title = payload.title.trim();
  556. }
  557. if (typeof payload.intent === "string" && payload.intent.trim()) {
  558. task.intent = payload.intent.trim();
  559. }
  560. if (typeof payload.query === "string" && payload.query.trim()) {
  561. task.query = payload.query.trim();
  562. }
  563. }
  564. const handleSubmit = async () => {
  565. if (!form.topic.trim()) {
  566. error.value = "请输入研究主题";
  567. return;
  568. }
  569. if (currentController) {
  570. currentController.abort();
  571. currentController = null;
  572. }
  573. loading.value = true;
  574. error.value = "";
  575. resetWorkflowState();
  576. const controller = new AbortController();
  577. currentController = controller;
  578. const payload = {
  579. topic: form.topic.trim(),
  580. search_api: form.searchApi || undefined
  581. };
  582. try {
  583. await runResearchStream(
  584. payload,
  585. (event: ResearchStreamEvent) => {
  586. if (event.type === "status") {
  587. const message =
  588. typeof event.message === "string" && event.message.trim()
  589. ? event.message
  590. : "流程状态更新";
  591. progressLogs.value.push(message);
  592. const payload = event as Record<string, unknown>;
  593. const task = findTask(payload.task_id);
  594. if (task && message) {
  595. task.notices.push(message);
  596. applyNoteMetadata(task, payload);
  597. }
  598. return;
  599. }
  600. if (event.type === "todo_list") {
  601. const tasks = Array.isArray(event.tasks)
  602. ? (event.tasks as Record<string, unknown>[])
  603. : [];
  604. todoTasks.value = tasks.map((item, index) => {
  605. const rawId =
  606. typeof item.id === "number"
  607. ? item.id
  608. : typeof item.id === "string"
  609. ? Number(item.id)
  610. : index + 1;
  611. const id = Number.isFinite(rawId) ? Number(rawId) : index + 1;
  612. const noteId =
  613. typeof item.note_id === "string" && item.note_id.trim()
  614. ? item.note_id.trim()
  615. : null;
  616. const notePath =
  617. typeof item.note_path === "string" && item.note_path.trim()
  618. ? item.note_path.trim()
  619. : null;
  620. return {
  621. id,
  622. title:
  623. typeof item.title === "string" && item.title.trim()
  624. ? item.title.trim()
  625. : `任务${id}`,
  626. intent:
  627. typeof item.intent === "string" && item.intent.trim()
  628. ? item.intent.trim()
  629. : "探索与主题相关的关键信息",
  630. query:
  631. typeof item.query === "string" && item.query.trim()
  632. ? item.query.trim()
  633. : form.topic.trim(),
  634. status:
  635. typeof item.status === "string" && item.status.trim()
  636. ? item.status.trim()
  637. : "pending",
  638. summary: "",
  639. sourcesSummary: "",
  640. sourceItems: [],
  641. notices: [],
  642. noteId,
  643. notePath,
  644. toolCalls: []
  645. } as TodoTaskView;
  646. });
  647. if (todoTasks.value.length) {
  648. activeTaskId.value = todoTasks.value[0].id;
  649. progressLogs.value.push("已生成任务清单");
  650. } else {
  651. progressLogs.value.push("未生成任务清单,使用默认任务继续");
  652. }
  653. return;
  654. }
  655. if (event.type === "task_status") {
  656. const payload = event as Record<string, unknown>;
  657. const task = findTask(event.task_id);
  658. if (!task) {
  659. return;
  660. }
  661. upsertTaskMetadata(task, payload);
  662. applyNoteMetadata(task, payload);
  663. const status =
  664. typeof event.status === "string" && event.status.trim()
  665. ? event.status.trim()
  666. : task.status;
  667. task.status = status;
  668. if (status === "in_progress") {
  669. task.summary = "";
  670. task.sourcesSummary = "";
  671. task.sourceItems = [];
  672. task.notices = [];
  673. activeTaskId.value = task.id;
  674. progressLogs.value.push(`开始执行任务:${task.title}`);
  675. } else if (status === "completed") {
  676. if (typeof event.summary === "string" && event.summary.trim()) {
  677. task.summary = event.summary.trim();
  678. }
  679. if (
  680. typeof event.sources_summary === "string" &&
  681. event.sources_summary.trim()
  682. ) {
  683. task.sourcesSummary = event.sources_summary.trim();
  684. task.sourceItems = parseSources(task.sourcesSummary);
  685. }
  686. progressLogs.value.push(`完成任务:${task.title}`);
  687. if (activeTaskId.value === task.id) {
  688. pulse(summaryHighlight);
  689. pulse(sourcesHighlight);
  690. }
  691. } else if (status === "skipped") {
  692. progressLogs.value.push(`任务跳过:${task.title}`);
  693. }
  694. return;
  695. }
  696. if (event.type === "sources") {
  697. const payload = event as Record<string, unknown>;
  698. const task = findTask(event.task_id);
  699. if (!task) {
  700. return;
  701. }
  702. const textCandidates = [
  703. payload.latest_sources,
  704. payload.sources_summary,
  705. payload.raw_context
  706. ];
  707. const latestText = textCandidates
  708. .map((value) => (typeof value === "string" ? value.trim() : ""))
  709. .find((value) => value);
  710. if (latestText) {
  711. task.sourcesSummary = latestText;
  712. task.sourceItems = parseSources(latestText);
  713. if (activeTaskId.value === task.id) {
  714. pulse(sourcesHighlight);
  715. }
  716. progressLogs.value.push(`已更新任务来源:${task.title}`);
  717. }
  718. if (typeof payload.backend === "string") {
  719. progressLogs.value.push(
  720. `当前使用搜索后端:${payload.backend}`
  721. );
  722. }
  723. applyNoteMetadata(task, payload);
  724. return;
  725. }
  726. if (event.type === "task_summary_chunk") {
  727. const payload = event as Record<string, unknown>;
  728. const task = findTask(event.task_id);
  729. if (!task) {
  730. return;
  731. }
  732. const chunk =
  733. typeof event.content === "string" ? event.content : "";
  734. task.summary += chunk;
  735. applyNoteMetadata(task, payload);
  736. if (activeTaskId.value === task.id) {
  737. pulse(summaryHighlight);
  738. }
  739. return;
  740. }
  741. if (event.type === "tool_call") {
  742. const payload = event as Record<string, unknown>;
  743. const eventId =
  744. typeof payload.event_id === "number"
  745. ? payload.event_id
  746. : Date.now();
  747. const agent =
  748. typeof payload.agent === "string" && payload.agent.trim()
  749. ? payload.agent.trim()
  750. : "Agent";
  751. const tool =
  752. typeof payload.tool === "string" && payload.tool.trim()
  753. ? payload.tool.trim()
  754. : "tool";
  755. const parameters = ensureRecord(payload.parameters);
  756. const result =
  757. typeof payload.result === "string" ? payload.result : "";
  758. const noteId = extractOptionalString(payload.note_id);
  759. const notePath = extractOptionalString(payload.note_path);
  760. const task = findTask(payload.task_id);
  761. if (task) {
  762. task.toolCalls.push({
  763. eventId,
  764. agent,
  765. tool,
  766. parameters,
  767. result,
  768. noteId,
  769. notePath,
  770. timestamp: Date.now()
  771. });
  772. if (noteId) {
  773. task.noteId = noteId;
  774. }
  775. if (notePath) {
  776. task.notePath = notePath;
  777. }
  778. const logSummary = noteId
  779. ? `${agent} 调用了 ${tool}(任务 ${task.id},笔记 ${noteId})`
  780. : `${agent} 调用了 ${tool}(任务 ${task.id})`;
  781. progressLogs.value.push(logSummary);
  782. if (activeTaskId.value === task.id) {
  783. pulse(toolHighlight);
  784. }
  785. } else {
  786. progressLogs.value.push(`${agent} 调用了 ${tool}`);
  787. }
  788. return;
  789. }
  790. if (event.type === "final_report") {
  791. const report =
  792. typeof event.report === "string" && event.report.trim()
  793. ? event.report.trim()
  794. : "";
  795. reportMarkdown.value = report || "报告生成失败,未获得有效内容";
  796. pulse(reportHighlight);
  797. progressLogs.value.push("最终报告已生成");
  798. return;
  799. }
  800. if (event.type === "error") {
  801. const detail =
  802. typeof event.detail === "string" && event.detail.trim()
  803. ? event.detail
  804. : "研究过程中发生错误";
  805. error.value = detail;
  806. progressLogs.value.push("研究失败,已停止流程");
  807. }
  808. },
  809. { signal: controller.signal }
  810. );
  811. if (!reportMarkdown.value) {
  812. reportMarkdown.value = "暂无生成的报告";
  813. }
  814. } catch (err) {
  815. if (err instanceof DOMException && err.name === "AbortError") {
  816. progressLogs.value.push("已取消当前研究任务");
  817. } else {
  818. error.value = err instanceof Error ? err.message : "请求失败";
  819. }
  820. } finally {
  821. loading.value = false;
  822. if (currentController === controller) {
  823. currentController = null;
  824. }
  825. }
  826. };
  827. const cancelResearch = () => {
  828. if (!loading.value || !currentController) {
  829. return;
  830. }
  831. progressLogs.value.push("正在尝试取消当前研究任务…");
  832. currentController.abort();
  833. };
  834. onBeforeUnmount(() => {
  835. if (currentController) {
  836. currentController.abort();
  837. currentController = null;
  838. }
  839. });
  840. </script>
  841. <style scoped>
  842. .app-shell {
  843. position: relative;
  844. min-height: 100vh;
  845. padding: 72px 24px;
  846. display: flex;
  847. justify-content: center;
  848. background: radial-gradient(circle at 20% 20%, #f8fafc, #dbeafe 60%);
  849. color: #1f2937;
  850. overflow: hidden;
  851. box-sizing: border-box;
  852. }
  853. .aurora {
  854. position: absolute;
  855. inset: 0;
  856. pointer-events: none;
  857. opacity: 0.55;
  858. }
  859. .aurora span {
  860. position: absolute;
  861. width: 45vw;
  862. height: 45vw;
  863. max-width: 520px;
  864. max-height: 520px;
  865. background: radial-gradient(circle, rgba(148, 197, 255, 0.35), transparent 60%);
  866. filter: blur(90px);
  867. animation: float 26s infinite linear;
  868. }
  869. .aurora span:nth-child(1) {
  870. top: -20%;
  871. left: -18%;
  872. animation-delay: 0s;
  873. }
  874. .aurora span:nth-child(2) {
  875. bottom: -25%;
  876. right: -20%;
  877. background: radial-gradient(circle, rgba(166, 139, 255, 0.28), transparent 60%);
  878. animation-delay: -9s;
  879. }
  880. .aurora span:nth-child(3) {
  881. top: 35%;
  882. left: 45%;
  883. background: radial-gradient(circle, rgba(164, 219, 216, 0.26), transparent 60%);
  884. animation-delay: -16s;
  885. }
  886. .layout {
  887. position: relative;
  888. width: min(1280px, 100%);
  889. display: flex;
  890. flex-wrap: wrap;
  891. gap: 24px;
  892. z-index: 1;
  893. align-items: flex-start;
  894. }
  895. .panel {
  896. position: relative;
  897. flex: 1 1 360px;
  898. padding: 24px;
  899. border-radius: 20px;
  900. background: rgba(255, 255, 255, 0.95);
  901. border: 1px solid rgba(148, 163, 184, 0.18);
  902. box-shadow: 0 24px 48px rgba(15, 23, 42, 0.12);
  903. backdrop-filter: blur(8px);
  904. overflow: hidden;
  905. }
  906. .panel-form {
  907. max-width: 420px;
  908. }
  909. .panel-result {
  910. min-width: 360px;
  911. flex: 2 1 420px;
  912. }
  913. .panel::before {
  914. content: "";
  915. position: absolute;
  916. inset: 0;
  917. background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(125, 86, 255, 0.1));
  918. opacity: 0;
  919. transition: opacity 0.35s ease;
  920. z-index: 0;
  921. }
  922. .panel:hover::before {
  923. opacity: 1;
  924. }
  925. .panel > * {
  926. position: relative;
  927. z-index: 1;
  928. }
  929. .panel-form h1 {
  930. margin: 0;
  931. font-size: 26px;
  932. letter-spacing: 0.01em;
  933. }
  934. .panel-form p {
  935. margin: 4px 0 0;
  936. color: #64748b;
  937. font-size: 13px;
  938. }
  939. .panel-head {
  940. display: flex;
  941. align-items: center;
  942. gap: 16px;
  943. margin-bottom: 24px;
  944. }
  945. .logo {
  946. width: 52px;
  947. height: 52px;
  948. display: grid;
  949. place-items: center;
  950. border-radius: 16px;
  951. background: linear-gradient(135deg, #2563eb, #7c3aed);
  952. box-shadow: 0 12px 28px rgba(59, 130, 246, 0.4);
  953. }
  954. .logo svg {
  955. width: 28px;
  956. height: 28px;
  957. fill: #f8fafc;
  958. }
  959. .form {
  960. display: flex;
  961. flex-direction: column;
  962. gap: 18px;
  963. }
  964. .field {
  965. display: flex;
  966. flex-direction: column;
  967. gap: 10px;
  968. }
  969. .field span {
  970. font-weight: 600;
  971. color: #475569;
  972. }
  973. textarea,
  974. input,
  975. select {
  976. padding: 14px 16px;
  977. border-radius: 16px;
  978. border: 1px solid rgba(148, 163, 184, 0.35);
  979. background: rgba(255, 255, 255, 0.92);
  980. color: #1f2937;
  981. font-size: 14px;
  982. transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  983. }
  984. textarea:focus,
  985. input:focus,
  986. select:focus {
  987. outline: none;
  988. border-color: rgba(37, 99, 235, 0.65);
  989. box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  990. background: #ffffff;
  991. }
  992. .options {
  993. display: flex;
  994. gap: 16px;
  995. flex-wrap: wrap;
  996. }
  997. .option {
  998. flex: 1;
  999. min-width: 140px;
  1000. }
  1001. .form-actions {
  1002. display: flex;
  1003. align-items: center;
  1004. gap: 12px;
  1005. flex-wrap: wrap;
  1006. }
  1007. .submit {
  1008. align-self: flex-start;
  1009. padding: 12px 24px;
  1010. border-radius: 16px;
  1011. border: none;
  1012. background: linear-gradient(135deg, #2563eb, #7c3aed);
  1013. color: #ffffff;
  1014. font-size: 15px;
  1015. font-weight: 600;
  1016. cursor: pointer;
  1017. transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  1018. display: inline-flex;
  1019. align-items: center;
  1020. gap: 10px;
  1021. position: relative;
  1022. }
  1023. .submit-label {
  1024. display: inline-flex;
  1025. align-items: center;
  1026. gap: 10px;
  1027. }
  1028. .submit .spinner {
  1029. width: 18px;
  1030. height: 18px;
  1031. fill: none;
  1032. stroke: rgba(255, 255, 255, 0.85);
  1033. stroke-linecap: round;
  1034. animation: spin 1s linear infinite;
  1035. }
  1036. .submit:disabled {
  1037. opacity: 0.7;
  1038. cursor: not-allowed;
  1039. }
  1040. .submit:not(:disabled):hover {
  1041. transform: translateY(-2px);
  1042. box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28);
  1043. }
  1044. .secondary-btn {
  1045. padding: 10px 18px;
  1046. border-radius: 14px;
  1047. background: rgba(148, 163, 184, 0.12);
  1048. border: 1px solid rgba(148, 163, 184, 0.28);
  1049. color: #1f2937;
  1050. font-size: 14px;
  1051. font-weight: 500;
  1052. cursor: pointer;
  1053. transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  1054. }
  1055. .secondary-btn:hover {
  1056. background: rgba(148, 163, 184, 0.2);
  1057. border-color: rgba(148, 163, 184, 0.35);
  1058. color: #0f172a;
  1059. }
  1060. .error-chip {
  1061. margin-top: 16px;
  1062. display: inline-flex;
  1063. align-items: center;
  1064. gap: 8px;
  1065. padding: 10px 14px;
  1066. background: rgba(248, 113, 113, 0.12);
  1067. border: 1px solid rgba(248, 113, 113, 0.35);
  1068. border-radius: 14px;
  1069. color: #b91c1c;
  1070. font-size: 14px;
  1071. }
  1072. .error-chip svg {
  1073. width: 18px;
  1074. height: 18px;
  1075. fill: currentColor;
  1076. }
  1077. .panel-result {
  1078. display: flex;
  1079. flex-direction: column;
  1080. gap: 18px;
  1081. }
  1082. .status-bar {
  1083. display: flex;
  1084. align-items: center;
  1085. justify-content: space-between;
  1086. gap: 12px;
  1087. flex-wrap: wrap;
  1088. }
  1089. .status-main {
  1090. display: flex;
  1091. align-items: center;
  1092. gap: 12px;
  1093. flex-wrap: wrap;
  1094. }
  1095. .status-controls {
  1096. display: flex;
  1097. gap: 8px;
  1098. }
  1099. .status-chip {
  1100. display: inline-flex;
  1101. align-items: center;
  1102. gap: 8px;
  1103. background: rgba(191, 219, 254, 0.28);
  1104. padding: 8px 14px;
  1105. border-radius: 999px;
  1106. font-size: 13px;
  1107. color: #1f2937;
  1108. border: 1px solid rgba(59, 130, 246, 0.35);
  1109. transition: background 0.3s ease, color 0.3s ease;
  1110. }
  1111. .status-chip.active {
  1112. background: rgba(129, 140, 248, 0.2);
  1113. border-color: rgba(129, 140, 248, 0.4);
  1114. color: #1e293b;
  1115. }
  1116. .status-chip .dot {
  1117. width: 8px;
  1118. height: 8px;
  1119. border-radius: 999px;
  1120. background: #2563eb;
  1121. box-shadow: 0 0 12px rgba(37, 99, 235, 0.45);
  1122. animation: pulse 1.8s ease-in-out infinite;
  1123. }
  1124. .status-meta {
  1125. color: #64748b;
  1126. font-size: 13px;
  1127. }
  1128. .timeline-wrapper {
  1129. margin-top: 12px;
  1130. max-height: 220px;
  1131. overflow-y: auto;
  1132. padding-right: 8px;
  1133. scrollbar-width: thin;
  1134. scrollbar-color: rgba(129, 140, 248, 0.45) rgba(226, 232, 240, 0.6);
  1135. }
  1136. .timeline-wrapper::-webkit-scrollbar {
  1137. width: 6px;
  1138. }
  1139. .timeline-wrapper::-webkit-scrollbar-track {
  1140. background: rgba(226, 232, 240, 0.6);
  1141. border-radius: 999px;
  1142. }
  1143. .timeline-wrapper::-webkit-scrollbar-thumb {
  1144. background: linear-gradient(180deg, rgba(129, 140, 248, 0.8), rgba(59, 130, 246, 0.7));
  1145. border-radius: 999px;
  1146. }
  1147. .timeline-wrapper::-webkit-scrollbar-thumb:hover {
  1148. background: linear-gradient(180deg, rgba(99, 102, 241, 0.9), rgba(37, 99, 235, 0.8));
  1149. }
  1150. .timeline {
  1151. list-style: none;
  1152. padding: 0;
  1153. margin: 0;
  1154. display: flex;
  1155. flex-direction: column;
  1156. gap: 14px;
  1157. position: relative;
  1158. padding-left: 12px;
  1159. }
  1160. .timeline::before {
  1161. content: "";
  1162. position: absolute;
  1163. top: 8px;
  1164. bottom: 8px;
  1165. left: 0;
  1166. width: 2px;
  1167. background: linear-gradient(180deg, rgba(59, 130, 246, 0.35), rgba(129, 140, 248, 0.15));
  1168. }
  1169. .timeline li {
  1170. position: relative;
  1171. padding-left: 24px;
  1172. color: #1e293b;
  1173. font-size: 14px;
  1174. line-height: 1.5;
  1175. }
  1176. .timeline-node {
  1177. position: absolute;
  1178. left: -12px;
  1179. top: 6px;
  1180. width: 10px;
  1181. height: 10px;
  1182. border-radius: 999px;
  1183. background: linear-gradient(135deg, #38bdf8, #7c3aed);
  1184. box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.22);
  1185. }
  1186. .timeline-enter-active,
  1187. .timeline-leave-active {
  1188. transition: all 0.35s ease, opacity 0.35s ease;
  1189. }
  1190. .timeline-enter-from,
  1191. .timeline-leave-to {
  1192. opacity: 0;
  1193. transform: translateY(-6px);
  1194. }
  1195. .tasks-section {
  1196. display: grid;
  1197. grid-template-columns: 280px 1fr;
  1198. gap: 20px;
  1199. align-items: start;
  1200. }
  1201. @media (max-width: 960px) {
  1202. .tasks-section {
  1203. grid-template-columns: 1fr;
  1204. }
  1205. }
  1206. .tasks-list {
  1207. background: rgba(255, 255, 255, 0.92);
  1208. border: 1px solid rgba(148, 163, 184, 0.26);
  1209. border-radius: 18px;
  1210. padding: 18px;
  1211. display: flex;
  1212. flex-direction: column;
  1213. gap: 16px;
  1214. box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.4);
  1215. }
  1216. .tasks-list h3 {
  1217. margin: 0;
  1218. font-size: 16px;
  1219. font-weight: 600;
  1220. color: #1f2937;
  1221. }
  1222. .tasks-list ul {
  1223. list-style: none;
  1224. margin: 0;
  1225. padding: 0;
  1226. display: flex;
  1227. flex-direction: column;
  1228. gap: 12px;
  1229. }
  1230. .task-item {
  1231. border-radius: 14px;
  1232. border: 1px solid transparent;
  1233. transition: border-color 0.2s ease, background 0.2s ease;
  1234. }
  1235. .task-item.completed {
  1236. border-color: rgba(56, 189, 248, 0.35);
  1237. background: rgba(191, 219, 254, 0.28);
  1238. }
  1239. .task-item.active {
  1240. border-color: rgba(129, 140, 248, 0.5);
  1241. background: rgba(224, 231, 255, 0.5);
  1242. }
  1243. .task-button {
  1244. width: 100%;
  1245. display: flex;
  1246. align-items: center;
  1247. justify-content: space-between;
  1248. gap: 12px;
  1249. padding: 12px 14px 6px;
  1250. background: transparent;
  1251. border: none;
  1252. color: inherit;
  1253. cursor: pointer;
  1254. text-align: left;
  1255. }
  1256. .task-title {
  1257. font-weight: 600;
  1258. font-size: 14px;
  1259. color: #1e293b;
  1260. }
  1261. .task-status {
  1262. display: inline-flex;
  1263. align-items: center;
  1264. justify-content: center;
  1265. padding: 4px 10px;
  1266. border-radius: 999px;
  1267. font-size: 12px;
  1268. font-weight: 500;
  1269. color: #1f2937;
  1270. background: rgba(148, 163, 184, 0.2);
  1271. }
  1272. .task-status.pending {
  1273. background: rgba(148, 163, 184, 0.18);
  1274. color: #475569;
  1275. }
  1276. .task-status.in_progress {
  1277. background: rgba(129, 140, 248, 0.24);
  1278. color: #312e81;
  1279. }
  1280. .task-status.completed {
  1281. background: rgba(34, 197, 94, 0.2);
  1282. color: #15803d;
  1283. }
  1284. .task-status.skipped {
  1285. background: rgba(248, 113, 113, 0.18);
  1286. color: #b91c1c;
  1287. }
  1288. .task-intent {
  1289. margin: 0;
  1290. padding: 0 14px 12px 14px;
  1291. font-size: 13px;
  1292. color: #64748b;
  1293. }
  1294. .task-detail {
  1295. background: rgba(255, 255, 255, 0.94);
  1296. border: 1px solid rgba(148, 163, 184, 0.26);
  1297. border-radius: 18px;
  1298. padding: 22px;
  1299. display: flex;
  1300. flex-direction: column;
  1301. gap: 18px;
  1302. box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.5);
  1303. }
  1304. .task-header {
  1305. display: flex;
  1306. justify-content: space-between;
  1307. align-items: flex-start;
  1308. flex-wrap: wrap;
  1309. gap: 12px;
  1310. }
  1311. .task-chip-group {
  1312. display: flex;
  1313. align-items: center;
  1314. gap: 8px;
  1315. flex-wrap: wrap;
  1316. }
  1317. .task-header h3 {
  1318. margin: 0;
  1319. font-size: 18px;
  1320. font-weight: 600;
  1321. color: #1f2937;
  1322. }
  1323. .task-header .muted {
  1324. margin: 6px 0 0;
  1325. }
  1326. .task-label {
  1327. padding: 6px 12px;
  1328. border-radius: 999px;
  1329. background: rgba(191, 219, 254, 0.32);
  1330. border: 1px solid rgba(59, 130, 246, 0.35);
  1331. font-size: 12px;
  1332. color: #1e3a8a;
  1333. }
  1334. .task-label.note-chip {
  1335. background: rgba(34, 197, 94, 0.2);
  1336. border-color: rgba(34, 197, 94, 0.35);
  1337. color: #15803d;
  1338. }
  1339. .task-label.path-chip {
  1340. display: inline-flex;
  1341. align-items: center;
  1342. gap: 6px;
  1343. max-width: 360px;
  1344. background: rgba(56, 189, 248, 0.2);
  1345. border-color: rgba(56, 189, 248, 0.35);
  1346. color: #0369a1;
  1347. overflow: hidden;
  1348. text-overflow: ellipsis;
  1349. white-space: nowrap;
  1350. }
  1351. .path-label {
  1352. font-weight: 500;
  1353. }
  1354. .path-text {
  1355. max-width: 220px;
  1356. overflow: hidden;
  1357. text-overflow: ellipsis;
  1358. white-space: nowrap;
  1359. }
  1360. .chip-action {
  1361. border: none;
  1362. background: rgba(56, 189, 248, 0.2);
  1363. color: #0369a1;
  1364. padding: 3px 8px;
  1365. border-radius: 10px;
  1366. font-size: 11px;
  1367. cursor: pointer;
  1368. transition: background 0.2s ease, color 0.2s ease;
  1369. }
  1370. .chip-action:hover {
  1371. background: rgba(14, 165, 233, 0.28);
  1372. color: #0f172a;
  1373. }
  1374. .task-notices {
  1375. background: rgba(191, 219, 254, 0.28);
  1376. border: 1px solid rgba(96, 165, 250, 0.35);
  1377. border-radius: 16px;
  1378. padding: 14px 18px;
  1379. color: #1f2937;
  1380. }
  1381. .task-notices h4 {
  1382. margin: 0 0 8px;
  1383. font-size: 14px;
  1384. font-weight: 600;
  1385. }
  1386. .task-notices ul {
  1387. list-style: disc;
  1388. margin: 0 0 0 18px;
  1389. padding: 0;
  1390. display: flex;
  1391. flex-direction: column;
  1392. gap: 6px;
  1393. }
  1394. .task-notices li {
  1395. font-size: 13px;
  1396. }
  1397. .report-block {
  1398. background: rgba(255, 255, 255, 0.94);
  1399. border: 1px solid rgba(148, 163, 184, 0.26);
  1400. border-radius: 18px;
  1401. padding: 22px;
  1402. display: flex;
  1403. flex-direction: column;
  1404. gap: 12px;
  1405. }
  1406. .report-block h3 {
  1407. margin: 0;
  1408. font-size: 18px;
  1409. font-weight: 600;
  1410. color: #1f2937;
  1411. }
  1412. .block-pre {
  1413. font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular,
  1414. Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  1415. font-size: 13px;
  1416. line-height: 1.7;
  1417. white-space: pre-wrap;
  1418. word-break: break-word;
  1419. color: #1f2937;
  1420. background: rgba(248, 250, 252, 0.9);
  1421. padding: 16px;
  1422. border-radius: 14px;
  1423. border: 1px solid rgba(148, 163, 184, 0.35);
  1424. overflow: auto;
  1425. max-height: 420px;
  1426. scrollbar-width: thin;
  1427. scrollbar-color: rgba(129, 140, 248, 0.6) rgba(226, 232, 240, 0.7);
  1428. }
  1429. .block-pre::-webkit-scrollbar {
  1430. width: 6px;
  1431. }
  1432. .block-pre::-webkit-scrollbar-track {
  1433. background: rgba(226, 232, 240, 0.7);
  1434. border-radius: 999px;
  1435. }
  1436. .block-pre::-webkit-scrollbar-thumb {
  1437. background: linear-gradient(180deg, rgba(99, 102, 241, 0.75), rgba(59, 130, 246, 0.65));
  1438. border-radius: 999px;
  1439. }
  1440. .block-pre::-webkit-scrollbar-thumb:hover {
  1441. background: linear-gradient(180deg, rgba(79, 70, 229, 0.8), rgba(37, 99, 235, 0.75));
  1442. }
  1443. .summary-block .block-pre,
  1444. .sources-block .block-pre {
  1445. max-height: 360px;
  1446. }
  1447. .tools-block {
  1448. position: relative;
  1449. margin-top: 16px;
  1450. padding: 20px;
  1451. border-radius: 18px;
  1452. background: rgba(255, 255, 255, 0.94);
  1453. border: 1px solid rgba(148, 163, 184, 0.18);
  1454. box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.4);
  1455. display: flex;
  1456. flex-direction: column;
  1457. gap: 12px;
  1458. }
  1459. .tools-block h3 {
  1460. margin: 0;
  1461. font-size: 16px;
  1462. font-weight: 600;
  1463. color: #1f2937;
  1464. letter-spacing: 0.02em;
  1465. }
  1466. .tool-list {
  1467. list-style: none;
  1468. margin: 0;
  1469. padding: 0;
  1470. display: flex;
  1471. flex-direction: column;
  1472. gap: 12px;
  1473. }
  1474. .tool-entry {
  1475. background: rgba(248, 250, 252, 0.95);
  1476. border: 1px solid rgba(148, 163, 184, 0.24);
  1477. border-radius: 14px;
  1478. padding: 14px;
  1479. display: flex;
  1480. flex-direction: column;
  1481. gap: 10px;
  1482. }
  1483. .tool-entry-header {
  1484. display: flex;
  1485. flex-wrap: wrap;
  1486. gap: 8px;
  1487. align-items: center;
  1488. justify-content: space-between;
  1489. }
  1490. .tool-entry-title {
  1491. font-weight: 600;
  1492. color: #1f2937;
  1493. }
  1494. .tool-entry-note {
  1495. font-size: 12px;
  1496. color: #0f766e;
  1497. }
  1498. .tool-entry-path {
  1499. margin: 0;
  1500. font-size: 12px;
  1501. display: flex;
  1502. align-items: center;
  1503. gap: 6px;
  1504. color: #2563eb;
  1505. }
  1506. .tool-subtitle {
  1507. margin: 0;
  1508. font-size: 13px;
  1509. color: #475569;
  1510. font-weight: 500;
  1511. }
  1512. .tool-pre {
  1513. font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular,
  1514. Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  1515. font-size: 12px;
  1516. line-height: 1.6;
  1517. white-space: pre-wrap;
  1518. word-break: break-word;
  1519. color: #1f2937;
  1520. background: rgba(248, 250, 252, 0.9);
  1521. padding: 12px;
  1522. border-radius: 12px;
  1523. border: 1px solid rgba(148, 163, 184, 0.28);
  1524. overflow: auto;
  1525. max-height: 260px;
  1526. scrollbar-width: thin;
  1527. scrollbar-color: rgba(129, 140, 248, 0.6) rgba(226, 232, 240, 0.7);
  1528. }
  1529. .tool-pre::-webkit-scrollbar {
  1530. width: 6px;
  1531. }
  1532. .tool-pre::-webkit-scrollbar-track {
  1533. background: rgba(226, 232, 240, 0.7);
  1534. }
  1535. .tool-pre::-webkit-scrollbar-thumb {
  1536. background: rgba(99, 102, 241, 0.7);
  1537. border-radius: 10px;
  1538. }
  1539. .link-btn {
  1540. background: none;
  1541. border: none;
  1542. color: #0369a1;
  1543. cursor: pointer;
  1544. padding: 0 4px;
  1545. font-size: 12px;
  1546. border-radius: 8px;
  1547. transition: color 0.2s ease, background 0.2s ease;
  1548. }
  1549. .link-btn:hover {
  1550. color: #0ea5e9;
  1551. background: rgba(14, 165, 233, 0.16);
  1552. }
  1553. .sources-block,
  1554. .summary-block {
  1555. position: relative;
  1556. margin-top: 16px;
  1557. padding: 18px;
  1558. border-radius: 18px;
  1559. background: rgba(255, 255, 255, 0.94);
  1560. border: 1px solid rgba(148, 163, 184, 0.18);
  1561. box-shadow: inset 0 0 0 1px rgba(226, 232, 240, 0.4);
  1562. }
  1563. .sources-history {
  1564. margin-top: 16px;
  1565. display: flex;
  1566. flex-direction: column;
  1567. gap: 10px;
  1568. }
  1569. .sources-history h4 {
  1570. margin: 0;
  1571. color: #1f2937;
  1572. font-size: 14px;
  1573. letter-spacing: 0.01em;
  1574. }
  1575. .history-list {
  1576. display: flex;
  1577. flex-direction: column;
  1578. gap: 10px;
  1579. }
  1580. .history-list details {
  1581. background: rgba(248, 250, 252, 0.95);
  1582. border: 1px solid rgba(148, 163, 184, 0.24);
  1583. border-radius: 14px;
  1584. padding: 12px 16px;
  1585. color: #1f2937;
  1586. transition: border-color 0.2s ease, background 0.2s ease;
  1587. }
  1588. .history-list details[open] {
  1589. background: rgba(224, 231, 255, 0.55);
  1590. border-color: rgba(129, 140, 248, 0.4);
  1591. }
  1592. .history-list summary {
  1593. cursor: pointer;
  1594. font-weight: 600;
  1595. outline: none;
  1596. list-style: none;
  1597. display: flex;
  1598. align-items: center;
  1599. justify-content: space-between;
  1600. }
  1601. .history-list summary::-webkit-details-marker {
  1602. display: none;
  1603. }
  1604. .history-list summary::after {
  1605. content: "▾";
  1606. margin-left: 6px;
  1607. font-size: 12px;
  1608. opacity: 0.7;
  1609. transition: transform 0.2s ease;
  1610. }
  1611. .history-list details[open] summary::after {
  1612. transform: rotate(180deg);
  1613. }
  1614. .block-highlight {
  1615. animation: glow 1.2s ease;
  1616. }
  1617. .sources-block h3,
  1618. .summary-block h3 {
  1619. margin: 0 0 14px;
  1620. color: #1f2937;
  1621. letter-spacing: 0.02em;
  1622. }
  1623. .sources-list {
  1624. list-style: none;
  1625. margin: 0;
  1626. padding: 0;
  1627. display: flex;
  1628. flex-direction: column;
  1629. gap: 10px;
  1630. }
  1631. .source-item {
  1632. position: relative;
  1633. display: inline-flex;
  1634. flex-direction: column;
  1635. gap: 6px;
  1636. }
  1637. .source-link {
  1638. color: #2563eb;
  1639. text-decoration: none;
  1640. font-weight: 600;
  1641. letter-spacing: 0.01em;
  1642. transition: color 0.2s ease;
  1643. }
  1644. .source-link::after {
  1645. content: " ↗";
  1646. font-size: 12px;
  1647. opacity: 0.6;
  1648. }
  1649. .source-link:hover {
  1650. color: #0f172a;
  1651. }
  1652. .source-tooltip {
  1653. display: none;
  1654. position: absolute;
  1655. bottom: calc(100% + 12px);
  1656. left: 50%;
  1657. transform: translateX(-50%);
  1658. background: rgba(255, 255, 255, 0.98);
  1659. color: #1f2937;
  1660. padding: 14px 16px;
  1661. border-radius: 16px;
  1662. box-shadow: 0 18px 32px rgba(15, 23, 42, 0.18);
  1663. width: min(420px, 90vw);
  1664. z-index: 20;
  1665. border: 1px solid rgba(148, 163, 184, 0.24);
  1666. }
  1667. .source-tooltip::after {
  1668. content: "";
  1669. position: absolute;
  1670. top: 100%;
  1671. left: 50%;
  1672. transform: translateX(-50%);
  1673. border-width: 10px;
  1674. border-style: solid;
  1675. border-color: rgba(255, 255, 255, 0.98) transparent transparent transparent;
  1676. }
  1677. .source-tooltip::before {
  1678. content: "";
  1679. position: absolute;
  1680. bottom: -12px;
  1681. left: 50%;
  1682. transform: translateX(-50%);
  1683. border-width: 12px 10px 0 10px;
  1684. border-style: solid;
  1685. border-color: rgba(255, 255, 255, 0.98) transparent transparent transparent;
  1686. filter: drop-shadow(0 -2px 4px rgba(15, 23, 42, 0.12));
  1687. }
  1688. .source-tooltip p {
  1689. margin: 0 0 8px;
  1690. font-size: 13px;
  1691. line-height: 1.6;
  1692. }
  1693. .source-tooltip p:last-child {
  1694. margin-bottom: 0;
  1695. }
  1696. .muted-text {
  1697. color: #64748b;
  1698. }
  1699. .source-item:hover .source-tooltip,
  1700. .source-item:focus-within .source-tooltip {
  1701. display: block;
  1702. }
  1703. .hint.muted {
  1704. color: #64748b;
  1705. }
  1706. @keyframes float {
  1707. 0% {
  1708. transform: translate3d(0, 0, 0) rotate(0deg);
  1709. }
  1710. 50% {
  1711. transform: translate3d(10%, 6%, 0) rotate(3deg);
  1712. }
  1713. 100% {
  1714. transform: translate3d(0, 0, 0) rotate(0deg);
  1715. }
  1716. }
  1717. @keyframes spin {
  1718. to {
  1719. transform: rotate(360deg);
  1720. }
  1721. }
  1722. @keyframes pulse {
  1723. 0%,
  1724. 100% {
  1725. transform: scale(1);
  1726. opacity: 1;
  1727. }
  1728. 50% {
  1729. transform: scale(1.3);
  1730. opacity: 0.5;
  1731. }
  1732. }
  1733. @keyframes glow {
  1734. 0% {
  1735. box-shadow: 0 0 0 rgba(59, 130, 246, 0.3);
  1736. border-color: rgba(59, 130, 246, 0.5);
  1737. }
  1738. 100% {
  1739. box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.12);
  1740. border-color: rgba(148, 163, 184, 0.2);
  1741. }
  1742. }
  1743. @media (max-width: 960px) {
  1744. .app-shell {
  1745. padding: 56px 16px;
  1746. }
  1747. .layout {
  1748. flex-direction: column;
  1749. align-items: stretch;
  1750. }
  1751. .panel {
  1752. padding: 22px;
  1753. }
  1754. .panel-form,
  1755. .panel-result {
  1756. max-width: none;
  1757. }
  1758. .status-bar {
  1759. flex-direction: column;
  1760. align-items: flex-start;
  1761. }
  1762. .status-main,
  1763. .status-controls {
  1764. width: 100%;
  1765. }
  1766. .status-controls {
  1767. justify-content: flex-start;
  1768. }
  1769. }
  1770. @media (max-width: 600px) {
  1771. .options {
  1772. flex-direction: column;
  1773. }
  1774. .status-meta {
  1775. font-size: 12px;
  1776. }
  1777. .panel-head {
  1778. flex-direction: column;
  1779. align-items: flex-start;
  1780. }
  1781. .panel-form h1 {
  1782. font-size: 24px;
  1783. }
  1784. }
  1785. </style>