App.vue 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019
  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%, #1e254f, #070910 60%);
  849. color: #f8fafc;
  850. overflow: hidden;
  851. box-sizing: border-box;
  852. }
  853. .aurora {
  854. position: absolute;
  855. inset: 0;
  856. pointer-events: none;
  857. opacity: 0.45;
  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(62, 164, 255, 0.42), transparent 60%);
  866. filter: blur(80px);
  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(125, 86, 255, 0.36), 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(94, 211, 182, 0.32), 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(11, 16, 32, 0.78);
  901. border: 1px solid rgba(148, 163, 184, 0.12);
  902. box-shadow: 0 24px 56px rgba(11, 16, 32, 0.4);
  903. backdrop-filter: blur(18px);
  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.2), rgba(125, 86, 255, 0.16));
  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: #c5d3f5;
  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: rgba(226, 232, 240, 0.94);
  972. }
  973. textarea,
  974. input,
  975. select {
  976. padding: 14px 16px;
  977. border-radius: 16px;
  978. border: 1px solid rgba(148, 163, 184, 0.25);
  979. background: rgba(15, 23, 42, 0.55);
  980. color: #f8fafc;
  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(96, 165, 250, 0.8);
  989. box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
  990. background: rgba(15, 23, 42, 0.75);
  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.18);
  1048. border: 1px solid rgba(148, 163, 184, 0.28);
  1049. color: rgba(226, 232, 240, 0.9);
  1050. font-size: 14px;
  1051. font-weight: 500;
  1052. cursor: pointer;
  1053. transition: background 0.2s ease, border-color 0.2s ease;
  1054. }
  1055. .secondary-btn:hover {
  1056. background: rgba(148, 163, 184, 0.28);
  1057. border-color: rgba(148, 163, 184, 0.4);
  1058. }
  1059. .error-chip {
  1060. margin-top: 16px;
  1061. display: inline-flex;
  1062. align-items: center;
  1063. gap: 8px;
  1064. padding: 10px 14px;
  1065. background: rgba(248, 113, 113, 0.14);
  1066. border: 1px solid rgba(248, 113, 113, 0.35);
  1067. border-radius: 14px;
  1068. color: #fecaca;
  1069. font-size: 14px;
  1070. }
  1071. .error-chip svg {
  1072. width: 18px;
  1073. height: 18px;
  1074. fill: currentColor;
  1075. }
  1076. .panel-result {
  1077. display: flex;
  1078. flex-direction: column;
  1079. gap: 18px;
  1080. }
  1081. .status-bar {
  1082. display: flex;
  1083. align-items: center;
  1084. justify-content: space-between;
  1085. gap: 12px;
  1086. flex-wrap: wrap;
  1087. }
  1088. .status-main {
  1089. display: flex;
  1090. align-items: center;
  1091. gap: 12px;
  1092. flex-wrap: wrap;
  1093. }
  1094. .status-controls {
  1095. display: flex;
  1096. gap: 8px;
  1097. }
  1098. .status-chip {
  1099. display: inline-flex;
  1100. align-items: center;
  1101. gap: 8px;
  1102. background: rgba(59, 130, 246, 0.18);
  1103. padding: 8px 14px;
  1104. border-radius: 999px;
  1105. font-size: 13px;
  1106. color: rgba(191, 219, 254, 0.9);
  1107. border: 1px solid rgba(59, 130, 246, 0.35);
  1108. transition: background 0.3s ease;
  1109. }
  1110. .status-chip.active {
  1111. background: rgba(99, 102, 241, 0.24);
  1112. border-color: rgba(129, 140, 248, 0.45);
  1113. }
  1114. .status-chip .dot {
  1115. width: 8px;
  1116. height: 8px;
  1117. border-radius: 999px;
  1118. background: #38bdf8;
  1119. box-shadow: 0 0 12px rgba(56, 189, 248, 0.8);
  1120. animation: pulse 1.8s ease-in-out infinite;
  1121. }
  1122. .status-meta {
  1123. color: rgba(148, 163, 184, 0.9);
  1124. font-size: 13px;
  1125. }
  1126. .timeline-wrapper {
  1127. margin-top: 12px;
  1128. max-height: 220px;
  1129. overflow-y: auto;
  1130. padding-right: 8px;
  1131. scrollbar-width: thin;
  1132. scrollbar-color: rgba(79, 70, 229, 0.55) rgba(15, 23, 42, 0.6);
  1133. }
  1134. .timeline-wrapper::-webkit-scrollbar {
  1135. width: 6px;
  1136. }
  1137. .timeline-wrapper::-webkit-scrollbar-track {
  1138. background: rgba(15, 23, 42, 0.45);
  1139. border-radius: 999px;
  1140. }
  1141. .timeline-wrapper::-webkit-scrollbar-thumb {
  1142. background: linear-gradient(180deg, rgba(96, 165, 250, 0.9), rgba(129, 140, 248, 0.75));
  1143. border-radius: 999px;
  1144. }
  1145. .timeline-wrapper::-webkit-scrollbar-thumb:hover {
  1146. background: linear-gradient(180deg, rgba(129, 140, 248, 0.95), rgba(165, 180, 252, 0.85));
  1147. }
  1148. .timeline {
  1149. list-style: none;
  1150. padding: 0;
  1151. margin: 0;
  1152. display: flex;
  1153. flex-direction: column;
  1154. gap: 14px;
  1155. position: relative;
  1156. padding-left: 12px;
  1157. }
  1158. .timeline::before {
  1159. content: "";
  1160. position: absolute;
  1161. top: 8px;
  1162. bottom: 8px;
  1163. left: 0;
  1164. width: 2px;
  1165. background: linear-gradient(180deg, rgba(59, 130, 246, 0.4), rgba(129, 140, 248, 0.1));
  1166. }
  1167. .timeline li {
  1168. position: relative;
  1169. padding-left: 24px;
  1170. color: rgba(226, 232, 240, 0.95);
  1171. font-size: 14px;
  1172. line-height: 1.5;
  1173. }
  1174. .timeline-node {
  1175. position: absolute;
  1176. left: -12px;
  1177. top: 6px;
  1178. width: 10px;
  1179. height: 10px;
  1180. border-radius: 999px;
  1181. background: linear-gradient(135deg, #38bdf8, #7c3aed);
  1182. box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
  1183. }
  1184. .timeline-enter-active,
  1185. .timeline-leave-active {
  1186. transition: all 0.35s ease, opacity 0.35s ease;
  1187. }
  1188. .timeline-enter-from,
  1189. .timeline-leave-to {
  1190. opacity: 0;
  1191. transform: translateY(-6px);
  1192. }
  1193. .tasks-section {
  1194. display: grid;
  1195. grid-template-columns: 280px 1fr;
  1196. gap: 20px;
  1197. align-items: start;
  1198. }
  1199. @media (max-width: 960px) {
  1200. .tasks-section {
  1201. grid-template-columns: 1fr;
  1202. }
  1203. }
  1204. .tasks-list {
  1205. background: rgba(15, 23, 42, 0.55);
  1206. border: 1px solid rgba(148, 163, 184, 0.26);
  1207. border-radius: 18px;
  1208. padding: 18px;
  1209. display: flex;
  1210. flex-direction: column;
  1211. gap: 16px;
  1212. box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.1);
  1213. }
  1214. .tasks-list h3 {
  1215. margin: 0;
  1216. font-size: 16px;
  1217. font-weight: 600;
  1218. color: rgba(224, 231, 255, 0.92);
  1219. }
  1220. .tasks-list ul {
  1221. list-style: none;
  1222. margin: 0;
  1223. padding: 0;
  1224. display: flex;
  1225. flex-direction: column;
  1226. gap: 12px;
  1227. }
  1228. .task-item {
  1229. border-radius: 14px;
  1230. border: 1px solid transparent;
  1231. transition: border-color 0.2s ease, background 0.2s ease;
  1232. }
  1233. .task-item.completed {
  1234. border-color: rgba(56, 189, 248, 0.3);
  1235. }
  1236. .task-item.active {
  1237. border-color: rgba(129, 140, 248, 0.6);
  1238. background: rgba(79, 70, 229, 0.18);
  1239. }
  1240. .task-button {
  1241. width: 100%;
  1242. display: flex;
  1243. align-items: center;
  1244. justify-content: space-between;
  1245. gap: 12px;
  1246. padding: 12px 14px 6px;
  1247. background: transparent;
  1248. border: none;
  1249. color: inherit;
  1250. cursor: pointer;
  1251. text-align: left;
  1252. }
  1253. .task-title {
  1254. font-weight: 600;
  1255. font-size: 14px;
  1256. color: rgba(226, 232, 240, 0.95);
  1257. }
  1258. .task-status {
  1259. display: inline-flex;
  1260. align-items: center;
  1261. justify-content: center;
  1262. padding: 4px 10px;
  1263. border-radius: 999px;
  1264. font-size: 12px;
  1265. font-weight: 500;
  1266. color: #0f172a;
  1267. background: rgba(148, 163, 184, 0.42);
  1268. }
  1269. .task-status.pending {
  1270. background: rgba(148, 163, 184, 0.32);
  1271. color: rgba(226, 232, 240, 0.9);
  1272. }
  1273. .task-status.in_progress {
  1274. background: rgba(129, 140, 248, 0.32);
  1275. color: rgba(224, 231, 255, 0.95);
  1276. }
  1277. .task-status.completed {
  1278. background: rgba(34, 197, 94, 0.32);
  1279. color: #dcfce7;
  1280. }
  1281. .task-status.skipped {
  1282. background: rgba(248, 113, 113, 0.24);
  1283. color: #fecaca;
  1284. }
  1285. .task-intent {
  1286. margin: 0;
  1287. padding: 0 14px 12px 14px;
  1288. font-size: 13px;
  1289. color: rgba(148, 163, 184, 0.85);
  1290. }
  1291. .task-detail {
  1292. background: rgba(15, 23, 42, 0.55);
  1293. border: 1px solid rgba(148, 163, 184, 0.26);
  1294. border-radius: 18px;
  1295. padding: 22px;
  1296. display: flex;
  1297. flex-direction: column;
  1298. gap: 18px;
  1299. box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.12);
  1300. }
  1301. .task-header {
  1302. display: flex;
  1303. justify-content: space-between;
  1304. align-items: flex-start;
  1305. flex-wrap: wrap;
  1306. gap: 12px;
  1307. }
  1308. .task-chip-group {
  1309. display: flex;
  1310. align-items: center;
  1311. gap: 8px;
  1312. flex-wrap: wrap;
  1313. }
  1314. .task-header h3 {
  1315. margin: 0;
  1316. font-size: 18px;
  1317. font-weight: 600;
  1318. color: rgba(226, 232, 240, 0.96);
  1319. }
  1320. .task-header .muted {
  1321. margin: 6px 0 0;
  1322. }
  1323. .task-label {
  1324. padding: 6px 12px;
  1325. border-radius: 999px;
  1326. background: rgba(59, 130, 246, 0.18);
  1327. border: 1px solid rgba(59, 130, 246, 0.35);
  1328. font-size: 12px;
  1329. color: rgba(191, 219, 254, 0.95);
  1330. }
  1331. .task-label.note-chip {
  1332. background: rgba(34, 197, 94, 0.2);
  1333. border-color: rgba(34, 197, 94, 0.35);
  1334. color: #bbf7d0;
  1335. }
  1336. .task-label.path-chip {
  1337. display: inline-flex;
  1338. align-items: center;
  1339. gap: 6px;
  1340. max-width: 360px;
  1341. background: rgba(56, 189, 248, 0.16);
  1342. border-color: rgba(56, 189, 248, 0.32);
  1343. color: #bae6fd;
  1344. overflow: hidden;
  1345. text-overflow: ellipsis;
  1346. white-space: nowrap;
  1347. }
  1348. .path-label {
  1349. font-weight: 500;
  1350. }
  1351. .path-text {
  1352. max-width: 220px;
  1353. overflow: hidden;
  1354. text-overflow: ellipsis;
  1355. white-space: nowrap;
  1356. }
  1357. .chip-action {
  1358. border: none;
  1359. background: rgba(14, 116, 144, 0.28);
  1360. color: #a5f3fc;
  1361. padding: 3px 8px;
  1362. border-radius: 10px;
  1363. font-size: 11px;
  1364. cursor: pointer;
  1365. transition: background 0.2s ease, color 0.2s ease;
  1366. }
  1367. .chip-action:hover {
  1368. background: rgba(8, 145, 178, 0.42);
  1369. color: #ecfeff;
  1370. }
  1371. .task-notices {
  1372. background: rgba(59, 130, 246, 0.12);
  1373. border: 1px solid rgba(96, 165, 250, 0.2);
  1374. border-radius: 16px;
  1375. padding: 14px 18px;
  1376. color: rgba(191, 219, 254, 0.96);
  1377. }
  1378. .task-notices h4 {
  1379. margin: 0 0 8px;
  1380. font-size: 14px;
  1381. font-weight: 600;
  1382. }
  1383. .task-notices ul {
  1384. list-style: disc;
  1385. margin: 0 0 0 18px;
  1386. padding: 0;
  1387. display: flex;
  1388. flex-direction: column;
  1389. gap: 6px;
  1390. }
  1391. .task-notices li {
  1392. font-size: 13px;
  1393. }
  1394. .report-block {
  1395. background: rgba(15, 23, 42, 0.58);
  1396. border: 1px solid rgba(148, 163, 184, 0.26);
  1397. border-radius: 18px;
  1398. padding: 22px;
  1399. display: flex;
  1400. flex-direction: column;
  1401. gap: 12px;
  1402. }
  1403. .report-block h3 {
  1404. margin: 0;
  1405. font-size: 18px;
  1406. font-weight: 600;
  1407. color: rgba(226, 232, 240, 0.96);
  1408. }
  1409. .block-pre {
  1410. font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular,
  1411. Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  1412. font-size: 13px;
  1413. line-height: 1.7;
  1414. white-space: pre-wrap;
  1415. word-break: break-word;
  1416. color: rgba(226, 232, 240, 0.95);
  1417. background: rgba(15, 23, 42, 0.72);
  1418. padding: 16px;
  1419. border-radius: 14px;
  1420. border: 1px solid rgba(148, 163, 184, 0.24);
  1421. overflow: auto;
  1422. max-height: 420px;
  1423. scrollbar-width: thin;
  1424. scrollbar-color: rgba(94, 129, 244, 0.8) rgba(12, 16, 30, 0.7);
  1425. }
  1426. .block-pre::-webkit-scrollbar {
  1427. width: 6px;
  1428. }
  1429. .block-pre::-webkit-scrollbar-track {
  1430. background: rgba(12, 16, 30, 0.7);
  1431. border-radius: 999px;
  1432. }
  1433. .block-pre::-webkit-scrollbar-thumb {
  1434. background: linear-gradient(180deg, rgba(99, 102, 241, 0.9), rgba(59, 130, 246, 0.75));
  1435. border-radius: 999px;
  1436. }
  1437. .block-pre::-webkit-scrollbar-thumb:hover {
  1438. background: linear-gradient(180deg, rgba(129, 140, 248, 0.95), rgba(165, 180, 252, 0.85));
  1439. }
  1440. .summary-block .block-pre,
  1441. .sources-block .block-pre {
  1442. max-height: 360px;
  1443. }
  1444. .tools-block {
  1445. position: relative;
  1446. margin-top: 16px;
  1447. padding: 20px;
  1448. border-radius: 18px;
  1449. background: rgba(12, 18, 34, 0.65);
  1450. border: 1px solid rgba(148, 163, 184, 0.18);
  1451. box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.05);
  1452. display: flex;
  1453. flex-direction: column;
  1454. gap: 12px;
  1455. }
  1456. .tools-block h3 {
  1457. margin: 0;
  1458. font-size: 16px;
  1459. font-weight: 600;
  1460. color: rgba(224, 231, 255, 0.92);
  1461. letter-spacing: 0.02em;
  1462. }
  1463. .tool-list {
  1464. list-style: none;
  1465. margin: 0;
  1466. padding: 0;
  1467. display: flex;
  1468. flex-direction: column;
  1469. gap: 12px;
  1470. }
  1471. .tool-entry {
  1472. background: rgba(15, 23, 42, 0.72);
  1473. border: 1px solid rgba(148, 163, 184, 0.2);
  1474. border-radius: 14px;
  1475. padding: 14px;
  1476. display: flex;
  1477. flex-direction: column;
  1478. gap: 10px;
  1479. }
  1480. .tool-entry-header {
  1481. display: flex;
  1482. flex-wrap: wrap;
  1483. gap: 8px;
  1484. align-items: center;
  1485. justify-content: space-between;
  1486. }
  1487. .tool-entry-title {
  1488. font-weight: 600;
  1489. color: rgba(226, 232, 240, 0.95);
  1490. }
  1491. .tool-entry-note {
  1492. font-size: 12px;
  1493. color: rgba(125, 211, 252, 0.9);
  1494. }
  1495. .tool-entry-path {
  1496. margin: 0;
  1497. font-size: 12px;
  1498. display: flex;
  1499. align-items: center;
  1500. gap: 6px;
  1501. color: rgba(191, 219, 254, 0.92);
  1502. }
  1503. .tool-subtitle {
  1504. margin: 0;
  1505. font-size: 13px;
  1506. color: rgba(191, 219, 254, 0.9);
  1507. font-weight: 500;
  1508. }
  1509. .tool-pre {
  1510. font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular,
  1511. Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  1512. font-size: 12px;
  1513. line-height: 1.6;
  1514. white-space: pre-wrap;
  1515. word-break: break-word;
  1516. color: rgba(226, 232, 240, 0.95);
  1517. background: rgba(10, 16, 30, 0.68);
  1518. padding: 12px;
  1519. border-radius: 12px;
  1520. border: 1px solid rgba(148, 163, 184, 0.2);
  1521. overflow: auto;
  1522. max-height: 260px;
  1523. scrollbar-width: thin;
  1524. scrollbar-color: rgba(94, 129, 244, 0.8) rgba(12, 16, 30, 0.7);
  1525. }
  1526. .tool-pre::-webkit-scrollbar {
  1527. width: 6px;
  1528. }
  1529. .tool-pre::-webkit-scrollbar-track {
  1530. background: rgba(12, 16, 30, 0.7);
  1531. }
  1532. .tool-pre::-webkit-scrollbar-thumb {
  1533. background: rgba(94, 129, 244, 0.8);
  1534. border-radius: 10px;
  1535. }
  1536. .link-btn {
  1537. background: none;
  1538. border: none;
  1539. color: #7dd3fc;
  1540. cursor: pointer;
  1541. padding: 0 4px;
  1542. font-size: 12px;
  1543. border-radius: 8px;
  1544. transition: color 0.2s ease, background 0.2s ease;
  1545. }
  1546. .link-btn:hover {
  1547. color: #e0f2fe;
  1548. background: rgba(125, 211, 252, 0.18);
  1549. }
  1550. .sources-block,
  1551. .summary-block {
  1552. position: relative;
  1553. margin-top: 16px;
  1554. padding: 18px;
  1555. border-radius: 18px;
  1556. background: rgba(12, 18, 34, 0.65);
  1557. border: 1px solid rgba(148, 163, 184, 0.18);
  1558. box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.05);
  1559. }
  1560. .sources-history {
  1561. margin-top: 16px;
  1562. display: flex;
  1563. flex-direction: column;
  1564. gap: 10px;
  1565. }
  1566. .sources-history h4 {
  1567. margin: 0;
  1568. color: rgba(224, 231, 255, 0.88);
  1569. font-size: 14px;
  1570. letter-spacing: 0.01em;
  1571. }
  1572. .history-list {
  1573. display: flex;
  1574. flex-direction: column;
  1575. gap: 10px;
  1576. }
  1577. .history-list details {
  1578. background: rgba(10, 16, 30, 0.55);
  1579. border: 1px solid rgba(71, 85, 105, 0.35);
  1580. border-radius: 14px;
  1581. padding: 12px 16px;
  1582. color: rgba(226, 232, 240, 0.9);
  1583. transition: border-color 0.2s ease, background 0.2s ease;
  1584. }
  1585. .history-list details[open] {
  1586. background: rgba(15, 23, 42, 0.65);
  1587. border-color: rgba(96, 165, 250, 0.35);
  1588. }
  1589. .history-list summary {
  1590. cursor: pointer;
  1591. font-weight: 600;
  1592. outline: none;
  1593. list-style: none;
  1594. display: flex;
  1595. align-items: center;
  1596. justify-content: space-between;
  1597. }
  1598. .history-list summary::-webkit-details-marker {
  1599. display: none;
  1600. }
  1601. .history-list summary::after {
  1602. content: "▾";
  1603. margin-left: 6px;
  1604. font-size: 12px;
  1605. opacity: 0.7;
  1606. transition: transform 0.2s ease;
  1607. }
  1608. .history-list details[open] summary::after {
  1609. transform: rotate(180deg);
  1610. }
  1611. .block-highlight {
  1612. animation: glow 1.2s ease;
  1613. }
  1614. .sources-block h3,
  1615. .summary-block h3 {
  1616. margin: 0 0 14px;
  1617. color: rgba(224, 231, 255, 0.92);
  1618. letter-spacing: 0.02em;
  1619. }
  1620. .sources-list {
  1621. list-style: none;
  1622. margin: 0;
  1623. padding: 0;
  1624. display: flex;
  1625. flex-direction: column;
  1626. gap: 10px;
  1627. }
  1628. .source-item {
  1629. position: relative;
  1630. display: inline-flex;
  1631. flex-direction: column;
  1632. gap: 6px;
  1633. }
  1634. .source-link {
  1635. color: #38bdf8;
  1636. text-decoration: none;
  1637. font-weight: 600;
  1638. letter-spacing: 0.01em;
  1639. transition: color 0.2s ease;
  1640. }
  1641. .source-link::after {
  1642. content: " ↗";
  1643. font-size: 12px;
  1644. opacity: 0.6;
  1645. }
  1646. .source-link:hover {
  1647. color: #fbbf24;
  1648. }
  1649. .source-tooltip {
  1650. display: none;
  1651. position: absolute;
  1652. bottom: calc(100% + 12px);
  1653. left: 50%;
  1654. transform: translateX(-50%);
  1655. background: rgba(8, 11, 20, 0.96);
  1656. color: #e2e8f0;
  1657. padding: 14px 16px;
  1658. border-radius: 16px;
  1659. box-shadow: 0 16px 36px rgba(8, 11, 20, 0.55);
  1660. width: min(420px, 90vw);
  1661. z-index: 20;
  1662. border: 1px solid rgba(148, 163, 184, 0.2);
  1663. }
  1664. .source-tooltip::after {
  1665. content: "";
  1666. position: absolute;
  1667. top: 100%;
  1668. left: 50%;
  1669. transform: translateX(-50%);
  1670. border-width: 10px;
  1671. border-style: solid;
  1672. border-color: rgba(8, 11, 20, 0.96) transparent transparent transparent;
  1673. }
  1674. .source-tooltip::before {
  1675. content: "";
  1676. position: absolute;
  1677. bottom: -12px;
  1678. left: 50%;
  1679. transform: translateX(-50%);
  1680. border-width: 12px 10px 0 10px;
  1681. border-style: solid;
  1682. border-color: rgba(8, 11, 20, 0.96) transparent transparent transparent;
  1683. }
  1684. .source-tooltip p {
  1685. margin: 0 0 8px;
  1686. font-size: 13px;
  1687. line-height: 1.6;
  1688. }
  1689. .source-tooltip p:last-child {
  1690. margin-bottom: 0;
  1691. }
  1692. .muted-text {
  1693. color: rgba(148, 163, 184, 0.8);
  1694. }
  1695. .source-item:hover .source-tooltip,
  1696. .source-item:focus-within .source-tooltip {
  1697. display: block;
  1698. }
  1699. .hint.muted {
  1700. color: rgba(148, 163, 184, 0.74);
  1701. }
  1702. @keyframes float {
  1703. 0% {
  1704. transform: translate3d(0, 0, 0) rotate(0deg);
  1705. }
  1706. 50% {
  1707. transform: translate3d(10%, 6%, 0) rotate(3deg);
  1708. }
  1709. 100% {
  1710. transform: translate3d(0, 0, 0) rotate(0deg);
  1711. }
  1712. }
  1713. @keyframes spin {
  1714. to {
  1715. transform: rotate(360deg);
  1716. }
  1717. }
  1718. @keyframes pulse {
  1719. 0%,
  1720. 100% {
  1721. transform: scale(1);
  1722. opacity: 1;
  1723. }
  1724. 50% {
  1725. transform: scale(1.3);
  1726. opacity: 0.5;
  1727. }
  1728. }
  1729. @keyframes glow {
  1730. 0% {
  1731. box-shadow: 0 0 0 rgba(59, 130, 246, 0.3);
  1732. border-color: rgba(59, 130, 246, 0.5);
  1733. }
  1734. 100% {
  1735. box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.12);
  1736. border-color: rgba(148, 163, 184, 0.2);
  1737. }
  1738. }
  1739. @media (max-width: 960px) {
  1740. .app-shell {
  1741. padding: 56px 16px;
  1742. }
  1743. .layout {
  1744. flex-direction: column;
  1745. align-items: stretch;
  1746. }
  1747. .panel {
  1748. padding: 22px;
  1749. }
  1750. .panel-form,
  1751. .panel-result {
  1752. max-width: none;
  1753. }
  1754. .status-bar {
  1755. flex-direction: column;
  1756. align-items: flex-start;
  1757. }
  1758. .status-main,
  1759. .status-controls {
  1760. width: 100%;
  1761. }
  1762. .status-controls {
  1763. justify-content: flex-start;
  1764. }
  1765. }
  1766. @media (max-width: 600px) {
  1767. .options {
  1768. flex-direction: column;
  1769. }
  1770. .status-meta {
  1771. font-size: 12px;
  1772. }
  1773. .panel-head {
  1774. flex-direction: column;
  1775. align-items: flex-start;
  1776. }
  1777. .panel-form h1 {
  1778. font-size: 24px;
  1779. }
  1780. }
  1781. </style>