lantern-harness 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/README.md +6 -6
- package/builtin/session/lh-spaces.mjs +102 -0
- package/cli/data-root.mjs +80 -3
- package/cli/lantern.mjs +2 -1
- package/cli/server.mjs +4 -0
- package/cli/spaces.mjs +91 -5
- package/config/app.defaults.json +4 -2
- package/dist/500.html +9 -5
- package/dist/_astro/Base.ByB0D4ZA.css +1 -0
- package/dist/_astro/{Base.astro_astro_type_script_index_0_lang.lxEwQ1R4.js → Base.astro_astro_type_script_index_0_lang.Cg_8YLVA.js} +1 -1
- package/dist/_astro/CaseGenerateApp.BlZyjWEr.js +9 -0
- package/dist/_astro/CasesLibrary.C76La3Xj.js +1 -0
- package/dist/_astro/ChatApp.gfsPLvan.js +269 -0
- package/dist/_astro/ColumnResize.Bs6GL3DJ.js +1 -0
- package/dist/_astro/DatePicker.BdwFRioL.js +1 -0
- package/dist/_astro/{DocsFileBrowser.DkE26UTR.js → DocsFileBrowser.BxAyrkkw.js} +1 -1
- package/dist/_astro/KnowledgeLibrary.Cv488Hot.js +1 -0
- package/dist/_astro/NavLibraries.ALZ9e12z.js +1 -0
- package/dist/_astro/PluginsPage.B2uxCiHL.js +1 -0
- package/dist/_astro/{PluginsPage.BNzpPg2H.js → PluginsPage.DEkyOfQE.js} +2 -2
- package/dist/_astro/PromptsLibrary.BUC1OiCH.js +1 -0
- package/dist/_astro/RequirementsLibrary.D3olQI63.js +1 -0
- package/dist/_astro/{SearchableSelect.DMS2XmXc.js → SearchableSelect.DP74JRWW.js} +1 -1
- package/dist/_astro/SelectDropdown.D2i7-lQC.js +1 -0
- package/dist/_astro/{SettingsDialog.DC0e7580.js → SettingsDialog.CrMDjSLJ.js} +1 -1
- package/dist/_astro/SlideOverDrawer.C7UVeCX1.js +1 -0
- package/dist/_astro/SpaceSwitcher.Wf8EPYUx.js +7 -0
- package/dist/_astro/TasksBoard.2j7rGT9O.js +1 -0
- package/dist/_astro/TemplatesLibrary.J0x7yIcY.js +1 -0
- package/dist/_astro/TodosBoard.BugeB7_7.js +1 -0
- package/dist/_astro/app-config.vqDkEMS3.js +1 -0
- package/dist/_astro/doc-roots.DAJP9Svr.js +1 -0
- package/dist/_astro/i18n.9qZsrs3u.js +7 -0
- package/dist/_astro/{open-docs-in-session.D3JCwMWB.js → open-docs-in-session.fLwnA5qh.js} +1 -1
- package/dist/_astro/plugins.DSUPSizB.js +1 -0
- package/dist/_astro/project-docs.Cd2gKPKh.js +1 -0
- package/dist/_astro/{settings.BoQ0e0m1.js → settings.CkbipdPI.js} +2 -2
- package/dist/_astro/{useListAnim.CnbC_9MC.js → useListAnim.Y3N2budK.js} +1 -1
- package/dist/cases/generate/index.html +10 -6
- package/dist/cases/library/index.html +10 -6
- package/dist/docs/changelog/index.html +69 -6
- package/dist/docs/install/index.html +22 -8
- package/dist/docs/manual/index.html +74 -11
- package/dist/index.html +10 -6
- package/dist/knowledge/index.html +10 -6
- package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +9 -5
- package/dist/plugins/index.html +10 -6
- package/dist/prompts/index.html +10 -6
- package/dist/requirements/index.html +10 -6
- package/dist/tasks/index.html +253 -0
- package/dist/templates/index.html +10 -6
- package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +9 -5
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +9 -5
- package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +9 -5
- package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +9 -5
- package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +9 -5
- package/dist/todos/index.html +253 -0
- package/docs//345/205/250/345/261/200/346/217/222/344/273/266.md +2 -2
- package/docs//345/256/211/350/243/205/346/211/213/345/206/214.md +10 -8
- package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +73 -23
- package/lh-plugins/lh-project-docs.mjs +2 -0
- package/lh-plugins/lh-tasks.mjs +223 -0
- package/lh-plugins/lh-todos.mjs +297 -0
- package/lh-plugins/storage-domain.mjs +1 -0
- package/package.json +1 -1
- package/dist/_astro/Base.B9f_iFAZ.css +0 -1
- package/dist/_astro/CaseGenerateApp.Br4uKjun.js +0 -9
- package/dist/_astro/CasesLibrary.CpPoVQ4P.js +0 -1
- package/dist/_astro/ChatApp.CYSPlSNP.js +0 -258
- package/dist/_astro/KnowledgeLibrary.DZinlAWn.js +0 -1
- package/dist/_astro/NavLibraries.EayBsg5g.js +0 -1
- package/dist/_astro/PluginsPage.CY61glLU.js +0 -1
- package/dist/_astro/PromptsLibrary.DfrrCjs7.js +0 -1
- package/dist/_astro/RequirementsLibrary.Dt0Gj6Nr.js +0 -1
- package/dist/_astro/SelectDropdown.Dc7QaPbH.js +0 -1
- package/dist/_astro/SpaceSwitcher.Yy2w8MDF.js +0 -7
- package/dist/_astro/TemplatesLibrary.uK-SjK1z.js +0 -1
- package/dist/_astro/app-config.CpjKWnzM.js +0 -1
- package/dist/_astro/i18n.BVvhz-vw.js +0 -7
- package/dist/_astro/plugins.CrpY8UI9.js +0 -1
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/lib.DJNDi_Ht.js","_astro/react-dom.CqAxpHMt.js","_astro/ExcelFieldTags.B_XMwNNx.js","_astro/jsx-runtime.BUXbF_vF.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{c as e,n as t,t as n}from"./react-dom.CqAxpHMt.js";import{F as r,I as i,L as a,P as o,R as s,i as c,p as l,r as u,t as d,u as f,z as p}from"./app-config.CpjKWnzM.js";import{c as m,d as h,f as g,l as _,n as ee,t as v,u as y}from"./SearchableSelect.DMS2XmXc.js";import{a as b,c as x,d as S,f as C,i as w,n as T,o as E,r as D,s as te,t as ne,u as O}from"./ExcelFieldTags.B_XMwNNx.js";import{a as re,i as k,r as ie,s as ae,t as oe}from"./llm.BZEzE0x2.js";import{b as A,f as se,h as ce,m as j,n as le,o as M,r as N,t as ue,u as P,y as de}from"./SelectDropdown.Dc7QaPbH.js";import{i as fe,n as pe,r as me,t as he}from"./prompts-meta.F4wwkjUA.js";import{d as ge,f as F,l as _e,m as I,o as ve,p as ye,r as be,s as xe,y as Se}from"./settings.BoQ0e0m1.js";import{t as Ce}from"./jsx-runtime.BUXbF_vF.js";import{t as we}from"./ConfirmDialog.BYz4HREM.js";import{i as Te,n as Ee,r as De,t as Oe}from"./menu.CqkL87bV.js";import{a as ke,i as Ae,o as je,r as Me,t as Ne}from"./plugins.CrpY8UI9.js";import{C as Pe,D as Fe,E as L,O as Ie,S as Le,T as Re,_ as ze,a as Be,b as Ve,c as He,d as Ue,f as We,g as Ge,h as Ke,i as qe,l as Je,m as Ye,n as Xe,o as Ze,p as Qe,r as $e,s as et,u as tt,v as nt,w as rt,x as it,y as at}from"./open-docs-in-session.D3JCwMWB.js";import{n as ot}from"./i18n.BVvhz-vw.js";import{$ as st,A as ct,B as lt,C as ut,D as dt,E as ft,F as pt,G as mt,H as ht,I as gt,J as _t,K as vt,L as yt,M as bt,N as xt,O as St,P as Ct,Q as wt,R as Tt,T as Et,U as Dt,V as Ot,W as kt,X as At,Y as jt,Z as Mt,_ as Nt,a as Pt,at as Ft,b as It,c as Lt,d as Rt,et as zt,f as Bt,g as Vt,h as Ht,i as Ut,it as Wt,j as Gt,k as Kt,l as qt,m as Jt,n as Yt,nt as Xt,o as Zt,p as Qt,q as $t,r as en,rt as tn,s as nn,t as rn,tt as an,u as on,v as sn,w as R,x as cn,y as ln,z as un}from"./PluginsPage.BNzpPg2H.js";import{t as dn}from"./NamePromptDialog.DGBlDH_k.js";var z=e(t(),1),fn=e(n(),1),pn=`/__tb_sessions/runs`;async function mn(e){try{return(await fetch(pn,{signal:e??AbortSignal.timeout(1500)})).ok}catch{return!1}}async function hn(e){let t=await fetch(pn,{signal:e??AbortSignal.timeout(3e3)});if(!t.ok)return[];let n=await t.json();return Array.isArray(n.runs)?n.runs:[]}async function gn(e){let t=await fetch(pn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0}:{ok:!1,error:n.error||`HTTP ${t.status}`}}async function _n(e){await fetch(`${pn}/${encodeURIComponent(e)}/stop`,{method:`POST`}).catch(()=>{})}async function vn(e){try{let t=await fetch(`${pn}/${encodeURIComponent(e)}`,{signal:AbortSignal.timeout(3e3)});return t.status===404?{ok:!1}:t.ok?await t.json():null}catch{return null}}function yn(e){return e===`completed`||e===`stopped`||e===`error`}function bn(e,t,n,r){let i=new AbortController,a=`${pn}/${encodeURIComponent(e)}/events?after=${Math.max(0,t)}`;return(async()=>{try{let e=await fetch(a,{headers:{Accept:`text/event-stream`},signal:i.signal});if(!e.ok||!e.body){r?.(Error(`SSE ${e.status}`));return}let t=e.body.getReader(),o=new TextDecoder,s=``;for(;;){let{done:e,value:a}=await t.read();if(e){i.signal.aborted||r?.(Error(`SSE disconnected`));break}s+=o.decode(a,{stream:!0});let c=s.split(`
|
|
3
|
-
`);s=c.pop()??``;for(let e of c){let t=e.trim();if(!t.startsWith(`data:`))continue;let r=t.slice(5).trim();if(r)try{n(JSON.parse(r))}catch{}}}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;r?.(e instanceof Error?e:Error(String(e)))}})(),()=>i.abort()}function xn(e,t,n){let r=!1,i=Math.max(0,t),a=0,o=null,s,c=n.maxAttempts??10,l=()=>{r=!0,s!=null&&clearTimeout(s),s=void 0,o?.(),o=null},u=()=>{r||n.signal?.aborted||(o?.(),o=bn(e,i,e=>{typeof e.seq==`number`&&Number.isFinite(e.seq)&&(i=Math.max(i,e.seq)),n.onEvent(e),e.type===`status`&&yn(e.status)&&(n.onTerminal?.(e),l())},t=>{r||n.signal?.aborted||(async()=>{a+=1;try{let r=await vn(e);if(r?.ok&&typeof r.seq==`number`&&(i=Math.max(i,r.seq)),r?.ok&&yn(r.status)){let e={type:`status`,status:r.status,seq:r.seq,assistant:r.assistant};n.onEvent(e),n.onTerminal?.(e),l();return}if(r&&r.ok===!1){n.onGaveUp?.(Error(t.message||`run not found`)),l();return}}catch{}if(a>=c){n.onGaveUp?.(t),l();return}let r=Math.min(4e3,250*a);s=setTimeout(u,r)})()}))},d=()=>l();return n.signal?.addEventListener(`abort`,d),u(),()=>{n.signal?.removeEventListener(`abort`,d),l()}}function Sn(e){for(let t of e)if(t.role===`user`&&typeof t.content==`string`){let e=t.content.trim();if(e)return e}return``}function Cn(e,t){let n=(e||``).trim()||`新对话`;return n===`新对话`||n===Pe(t)}function wn(e){let t=String(e??``).trim().replace(/^["「『]+|["」』]+$/g,``).replace(/\s+/g,` `).replace(/^标题[::]\s*/i,``);return t=t.replace(/[。.!!]+$/g,``).trim(),t?t.length>28?`${t.slice(0,28)}…`:t:``}async function Tn(e,t,n){let r=t.trim().slice(0,800);if(!r)return null;let i=[{role:`system`,content:`你为对话生成侧栏短标题。只输出标题本身:中文优先,不超过 16 个字,无引号、无标点收尾、无解释。`},{role:`user`,content:`用户首条消息:\n${r}\n\n请给出标题:`}];try{return wn(await ie(e,i,n))||null}catch{return null}}function En(e){let t=Array.isArray(e.messages)?e.messages:[],n=0,r=0,i=0,a=0,o=0;for(let e of t){if(!e||typeof e!=`object`)continue;let t=e;t.role===`user`?n+=1:t.role===`assistant`&&(r+=1);let s=t.usage;if(s&&typeof s==`object`){let e=s;typeof e.promptTokens==`number`&&(i+=e.promptTokens),typeof e.completionTokens==`number`&&(a+=e.completionTokens),typeof e.totalTokens==`number`?o+=e.totalTokens:(typeof e.promptTokens==`number`||typeof e.completionTokens==`number`)&&(o+=(Number(e.promptTokens)||0)+(Number(e.completionTokens)||0))}}let s=e.goal,c=!!(s&&s.status!==`cleared`&&s.text?.trim());return{sessionId:e.id,title:e.title||`新对话`,messageCount:t.length,userCount:n,assistantCount:r,promptTokens:i,completionTokens:a,totalTokens:o,createdAt:e.createdAt,updatedAt:e.updatedAt,hasGoal:c,todoCount:Array.isArray(e.todos)?e.todos.length:0}}function Dn(e){let t=new Date(e.createdAt).toLocaleString(),n=new Date(e.updatedAt).toLocaleString();return[`会话:${e.title}`,`消息 ${e.messageCount}(用户 ${e.userCount} / 助手 ${e.assistantCount})`,`用量≈ 输入 ${e.promptTokens} · 输出 ${e.completionTokens} · 合计 ${e.totalTokens}`,`待办 ${e.todoCount} · 目标 ${e.hasGoal?`有`:`无`}`,`创建 ${t}`,`更新 ${n}`].join(`
|
|
4
|
-
`)}var On=new Map,kn=new Map,An=40;function jn(e,t,n=``){return`${e}:${t}:${n}`}function Mn(e){for(;e.size>An;){let t=e.keys().next().value;if(t===void 0)break;e.delete(t)}}function Nn(e,t,n,r,i=``){let a=e===`outline`?On:kn,o=jn(t,n,i),s=a.get(t);if(s&&s.stamp===o)return s.value;let c=r();return a.set(t,{stamp:o,value:c}),Mn(a),c}var Pn=`/__tb_sessions/log`;function Fn(e){let t=String(e.userContent??``).trim(),n=String(e.assistantContent??``).trim(),r=String(e.reasoning??``).trim(),i=[];if(t&&i.push({role:`user`,content:t}),n||r){let e={role:`assistant`,content:n};r&&(e.reasoning_content=r),i.push(e)}return i}async function In(e){try{let t=await fetch(Pn,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:AbortSignal.timeout(5e3)}),n=await t.json().catch(()=>({}));return t.ok?{ok:!0,path:n.path}:{ok:!1,error:n.error||`HTTP ${t.status}`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}function Ln(e){return String(e??``).trim()}function Rn(e,t=80){let n=Ln(e).replace(/\s+/g,` `);return n?n.length>t?`${n.slice(0,t)}…`:n:``}function zn(e,t=40){let n=[],r=null;for(let i=0;i<e.length;i++){let a=e[i];if(a.role===`user`){let e=Ln(a.content),t=Rn(e);if(!t)continue;r&&n.push({index:n.length+1,userPreview:r.preview,assistantPreview:``,userText:r.text,assistantText:``,userTime:r.time,endMessageIndex:r.messageIndex}),r={text:e,preview:t,time:typeof a.time==`number`?a.time:void 0,messageIndex:i}}else if(a.role===`assistant`&&r){let e=Ln(a.content),t=Ln(a.reasoning)||void 0;n.push({index:n.length+1,userPreview:r.preview,assistantPreview:Rn(e)||(t?`(含思考)`:``),userText:r.text,assistantText:e,reasoning:t,reasoningDuration:typeof a.reasoningDuration==`number`?a.reasoningDuration:void 0,userTime:r.time,assistantTime:typeof a.time==`number`?a.time:void 0,endMessageIndex:i}),r=null}if(n.length>=t)break}return r&&n.length<t&&n.push({index:n.length+1,userPreview:r.preview,assistantPreview:``,userText:r.text,assistantText:``,userTime:r.time,endMessageIndex:r.messageIndex}),n}function Bn(e,t){let n=String(t??``).trim();return!n||n===`inherit`||n===e.model?e:{...e,model:n}}var Vn=`/__tb_fs`,Hn=`你可以使用 office_to_pdf:优先用本机 LibreOffice 转为 PDF;若未安装,则对 docx/xlsx/pptx 降级抽取正文为同目录 .extracted.md(需写权限)。`,Un={type:`function`,function:{name:`office_to_pdf`,description:`Convert Office docs to PDF via LibreOffice when available; otherwise extract text to .extracted.md for docx/xlsx/pptx.`,parameters:{type:`object`,properties:{path:{type:`string`,description:`Input file path relative to workspace (or absolute when allowed)`},outDir:{type:`string`,description:`Optional output directory (default: same as input)`}},required:[`path`]}}};async function Wn(e,t,n){if(e!==`office_to_pdf`)return JSON.stringify({error:`unknown tool: ${e}`});let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({ok:!1,error:`invalid JSON arguments`})}let i=String(r.path??``).trim();if(!i)return JSON.stringify({ok:!1,error:`path is required`});try{let e=await(await fetch(`${Vn}/office-to-pdf`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({path:i,outDir:typeof r.outDir==`string`?r.outDir:void 0,access:n}),signal:AbortSignal.timeout(13e4)})).json().catch(()=>({}));return JSON.stringify(e,null,2)}catch(e){return JSON.stringify({ok:!1,error:e instanceof Error?e.message:String(e)})}}var Gn=`/__tb_fs`,Kn=`你可以使用 load_workspace_dependencies:查询本机 node / npm / pnpm / python 等可执行文件绝对路径(需本地 fs 服务)。`,qn={type:`function`,function:{name:`load_workspace_dependencies`,description:`Resolve absolute paths of common runtimes/package managers on this machine (node, npm, pnpm, python, …).`,parameters:{type:`object`,properties:{}}}};async function Jn(e){if(e!==`load_workspace_dependencies`)return JSON.stringify({error:`unknown tool: ${e}`});try{let e=await fetch(`${Gn}/workspace-dependencies`,{signal:AbortSignal.timeout(8e3)}),t=await e.json().catch(()=>({}));if(!e.ok){let n=typeof t==`object`&&t&&`error`in t?String(t.error):`HTTP ${e.status}`;return JSON.stringify({ok:!1,error:n})}return JSON.stringify(t,null,2)}catch(e){return JSON.stringify({ok:!1,error:e instanceof Error?e.message:String(e)})}}function Yn(e){return Array.isArray(e)}function B(e){return Yn(e)?e.some(e=>e.type===`image_url`):!1}function Xn(e){let t=e.filter(e=>e.type===`text`).map(e=>e.text),n=e.filter(e=>e.type===`image_url`).length,r=n>0?`[image-offload] 已卸载 ${n} 张图片(超预算,仅保留最近附图)。`:``;return[{type:`text`,text:[...t,r].filter(Boolean).join(`
|
|
5
|
-
`)||r||`(图片已卸载)`}]}function Zn(e,t={}){let n=Math.max(0,Math.floor(t.keepRecentImageMessages??1)),r=[];for(let t=0;t<e.length;t++){let n=e[t];n.role===`user`&&B(n.content)&&r.push(t)}if(r.length<=n)return e;let i=new Set(r.slice(-n)),a=!1,o=e.map((e,t)=>e.role!==`user`||!B(e.content)||i.has(t)||!Yn(e.content)?e:(a=!0,{...e,content:Xn(e.content)}));return a?o:e}function Qn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var $n=Qn();function er(e){$n=e}var tr={exec:()=>null};function V(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(nr.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var nr={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},rr=/^(?:[ \t]*(?:\n|$))+/,ir=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,ar=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,or=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,sr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,cr=/(?:[*+-]|\d{1,9}[.)])/,lr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ur=V(lr).replace(/bull/g,cr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),dr=V(lr).replace(/bull/g,cr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),fr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,pr=/^[^\n]+/,H=/(?!\s*\])(?:\\.|[^\[\]\\])+/,mr=V(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,H).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),hr=V(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,cr).getRegex(),gr=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,_r=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,vr=V(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,_r).replace(`tag`,gr).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),yr=V(fr).replace(`hr`,or).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,gr).getRegex(),br={blockquote:V(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,yr).getRegex(),code:ir,def:mr,fences:ar,heading:sr,hr:or,html:vr,lheading:ur,list:hr,newline:rr,paragraph:yr,table:tr,text:pr},xr=V(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,or).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,gr).getRegex(),Sr={...br,lheading:dr,table:xr,paragraph:V(fr).replace(`hr`,or).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,xr).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,gr).getRegex()},Cr={...br,html:V(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,_r).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:tr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:V(fr).replace(`hr`,or).replace(`heading`,` *#{1,6} *[^
|
|
6
|
-
]`).replace(`lheading`,ur).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},wr=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Tr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Er=/^( {2,}|\\)\n(?!\s*$)/,Dr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Or=/[\p{P}\p{S}]/u,kr=/[\s\p{P}\p{S}]/u,Ar=/[^\s\p{P}\p{S}]/u,U=V(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,kr).getRegex(),jr=/(?!~)[\p{P}\p{S}]/u,Mr=/(?!~)[\s\p{P}\p{S}]/u,Nr=/(?:[^\s\p{P}\p{S}]|~)/u,Pr=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Fr=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Ir=V(Fr,`u`).replace(/punct/g,Or).getRegex(),Lr=V(Fr,`u`).replace(/punct/g,jr).getRegex(),Rr=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,zr=V(Rr,`gu`).replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,kr).replace(/punct/g,Or).getRegex(),Br=V(Rr,`gu`).replace(/notPunctSpace/g,Nr).replace(/punctSpace/g,Mr).replace(/punct/g,jr).getRegex(),Vr=V(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Ar).replace(/punctSpace/g,kr).replace(/punct/g,Or).getRegex(),Hr=V(/\\(punct)/,`gu`).replace(/punct/g,Or).getRegex(),Ur=V(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Wr=V(_r).replace(`(?:-->|$)`,`-->`).getRegex(),Gr=V(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Wr).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Kr=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,qr=V(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,Kr).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Jr=V(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Kr).replace(`ref`,H).getRegex(),Yr=V(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,H).getRegex(),Xr={_backpedal:tr,anyPunctuation:Hr,autolink:Ur,blockSkip:Pr,br:Er,code:Tr,del:tr,emStrongLDelim:Ir,emStrongRDelimAst:zr,emStrongRDelimUnd:Vr,escape:wr,link:qr,nolink:Yr,punctuation:U,reflink:Jr,reflinkSearch:V(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Jr).replace(`nolink`,Yr).getRegex(),tag:Gr,text:Dr,url:tr},Zr={...Xr,link:V(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Kr).getRegex(),reflink:V(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Kr).getRegex()},Qr={...Xr,emStrongRDelimAst:Br,emStrongLDelim:Lr,url:V(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,`i`).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},$r={...Qr,br:V(Er).replace(`{2,}`,`*`).getRegex(),text:V(Qr.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},ei={normal:br,gfm:Sr,pedantic:Cr},ti={normal:Xr,gfm:Qr,breaks:$r,pedantic:Zr},ni={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},ri=e=>ni[e];function ii(e,t){if(t){if(nr.escapeTest.test(e))return e.replace(nr.escapeReplace,ri)}else if(nr.escapeTestNoEncode.test(e))return e.replace(nr.escapeReplaceNoEncode,ri);return e}function ai(e){try{e=encodeURI(e).replace(nr.percentDecode,`%`)}catch{return null}return e}function oi(e,t){let n=e.replace(nr.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(nr.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(nr.slashPipe,`|`);return n}function si(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function ci(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function li(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function ui(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
7
|
-
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
8
|
-
`)}var di=class{options;rules;lexer;constructor(e){this.options=e||$n}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:si(e,`
|
|
9
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=ui(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=si(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:si(t[0],`
|
|
10
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=si(t[0],`
|
|
11
|
-
`).split(`
|
|
12
|
-
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
13
|
-
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
14
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
15
|
-
${s}`:s,r=r?`${r}
|
|
16
|
-
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
|
|
17
|
-
`+e.join(`
|
|
18
|
-
`),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}if(u?.type===`list`){let t=u,a=t.raw+`
|
|
19
|
-
`+e.join(`
|
|
20
|
-
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
21
|
-
`)}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=t[2].split(`
|
|
22
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,e=>` `.repeat(3*e.length)),l=e.split(`
|
|
23
|
-
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
24
|
-
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d);for(;e;){let f=e.split(`
|
|
25
|
-
`,1)[0],p;if(l=f,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),p=l):p=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||t.test(l)||n.test(l))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
26
|
-
`+p.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
27
|
-
`+l}!u&&!l.trim()&&(u=!0),r+=f+`
|
|
28
|
-
`,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){let t=i.items[e].tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=oi(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
29
|
-
`):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(oi(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
30
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=si(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=ci(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),li(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return li(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&!(r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},fi=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||$n,this.options.tokenizer=this.options.tokenizer||new di,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:nr,block:ei.normal,inline:ti.normal};this.options.pedantic?(t.block=ei.pedantic,t.inline=ti.pedantic):this.options.gfm&&(t.block=ei.gfm,t.inline=this.options.breaks?ti.breaks:ti.gfm),this.tokenizer.rules=t}static get rules(){return{block:ei,inline:ti}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(nr.carriageReturn,`
|
|
31
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(nr.tabCharGlobal,` `).replace(nr.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
|
|
32
|
-
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=`
|
|
33
|
-
`+r.raw,n.text+=`
|
|
34
|
-
`+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if((r=this.tokenizer.fences(e))||(r=this.tokenizer.heading(e))||(r=this.tokenizer.hr(e))||(r=this.tokenizer.blockquote(e))||(r=this.tokenizer.list(e))||(r=this.tokenizer.html(e))){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=`
|
|
35
|
-
`+r.raw,n.text+=`
|
|
36
|
-
`+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if((r=this.tokenizer.table(e))||(r=this.tokenizer.lheading(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=`
|
|
37
|
-
`+r.raw,a.text+=`
|
|
38
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length)}else if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=`
|
|
39
|
-
`+r.raw,n.text+=`
|
|
40
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,a=``;for(;e;){i||(a=``),i=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if((r=this.tokenizer.escape(e))||(r=this.tokenizer.tag(e))||(r=this.tokenizer.link(e))){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if((r=this.tokenizer.emStrong(e,n,a))||(r=this.tokenizer.codespan(e))||(r=this.tokenizer.br(e))||(r=this.tokenizer.del(e))||(r=this.tokenizer.autolink(e))||!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let o=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(o=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(o)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(a=r.raw.slice(-1)),i=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r)}else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}return t}},pi=class{options;parser;constructor(e){this.options=e||$n}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(nr.notSpaceStart)?.[0],i=e.replace(nr.endingNewline,``)+`
|
|
41
|
-
`;return r?`<pre><code class="language-`+ii(r)+`">`+(n?i:ii(i,!0))+`</code></pre>
|
|
42
|
-
`:`<pre><code>`+(n?i:ii(i,!0))+`</code></pre>
|
|
43
|
-
`}blockquote({tokens:e}){return`<blockquote>
|
|
44
|
-
${this.parser.parse(e)}</blockquote>
|
|
45
|
-
`}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
46
|
-
`}hr(e){return`<hr>
|
|
47
|
-
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
48
|
-
`+r+`</`+i+`>
|
|
49
|
-
`}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+ii(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
|
|
50
|
-
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox">`}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
51
|
-
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
52
|
-
<thead>
|
|
53
|
-
`+t+`</thead>
|
|
54
|
-
`+r+`</table>
|
|
55
|
-
`}tablerow({text:e}){return`<tr>
|
|
56
|
-
${e}</tr>
|
|
57
|
-
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
58
|
-
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ii(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=ai(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+ii(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=ai(e);if(i===null)return ii(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${ii(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:ii(e.text)}},mi=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},hi=class e{options;renderer;textRenderer;constructor(e){this.options=e||$n,this.options.renderer=this.options.renderer||new pi,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new mi}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}let a=i;switch(a.type){case`space`:n+=this.renderer.space(a);continue;case`hr`:n+=this.renderer.hr(a);continue;case`heading`:n+=this.renderer.heading(a);continue;case`code`:n+=this.renderer.code(a);continue;case`table`:n+=this.renderer.table(a);continue;case`blockquote`:n+=this.renderer.blockquote(a);continue;case`list`:n+=this.renderer.list(a);continue;case`html`:n+=this.renderer.html(a);continue;case`paragraph`:n+=this.renderer.paragraph(a);continue;case`text`:{let i=a,o=this.renderer.text(i);for(;r+1<e.length&&e[r+1].type===`text`;)i=e[++r],o+=`
|
|
59
|
-
`+this.renderer.text(i);n+=t?this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},gi=class{options;block;constructor(e){this.options=e||$n}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?fi.lex:fi.lexInline}provideParser(){return this.block?hi.parse:hi.parseInline}},_i=class{defaults=Qn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=hi;Renderer=pi;TextRenderer=mi;Lexer=fi;Tokenizer=di;Hooks=gi;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new pi(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new di(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new gi;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=gi.passThroughHooks.has(n)?e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then(e=>a.call(t,e));let n=i.call(t,e);return a.call(t,n)}:(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return fi.lex(e,t??this.defaults)}parser(e,t){return hi.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(t==null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));i.hooks&&(i.hooks.options=i,i.hooks.block=e);let o=i.hooks?i.hooks.provideLexer():e?fi.lex:fi.lexInline,s=i.hooks?i.hooks.provideParser():e?hi.parse:hi.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(e=>o(e,i)).then(e=>i.hooks?i.hooks.processAllTokens(e):e).then(e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then(()=>e):e).then(e=>s(e,i)).then(e=>i.hooks?i.hooks.postprocess(e):e).catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let e=o(t,i);i.hooks&&(e=i.hooks.processAllTokens(e)),i.walkTokens&&this.walkTokens(e,i.walkTokens);let n=s(e,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
60
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+ii(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},vi=new _i;function W(e,t){return vi.parse(e,t)}W.options=W.setOptions=function(e){return vi.setOptions(e),W.defaults=vi.defaults,er(W.defaults),W},W.getDefaults=Qn,W.defaults=$n,W.use=function(...e){return vi.use(...e),W.defaults=vi.defaults,er(W.defaults),W},W.walkTokens=function(e,t){return vi.walkTokens(e,t)},W.parseInline=vi.parseInline,W.Parser=hi,W.parser=hi.parse,W.Renderer=pi,W.TextRenderer=mi,W.Lexer=fi,W.lexer=fi.lex,W.Tokenizer=di,W.Hooks=gi,W.parse=W,W.options,W.setOptions,W.use,W.walkTokens,W.parseInline,hi.parse,fi.lex;function yi(e,t){this.v=e,this.k=t}function bi(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function xi(e){if(Array.isArray(e))return e}function Si(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Ci(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
61
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wi(e,t){return xi(e)||Si(e,t)||Ti(e,t)||Ci()}function Ti(e,t){if(e){if(typeof e==`string`)return bi(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?bi(e,t):void 0}}function Ei(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof yi;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}Ei.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},Ei.prototype.next=function(e){return this._invoke(`next`,e)},Ei.prototype.throw=function(e){return this._invoke(`throw`,e)},Ei.prototype.return=function(e){return this._invoke(`return`,e)};var Di=Object.entries,Oi=Object.setPrototypeOf,ki=Object.isFrozen,Ai=Object.getPrototypeOf,ji=Object.getOwnPropertyDescriptor,Mi=Object.freeze,G=Object.seal,Ni=Object.create,Pi=typeof Reflect<`u`&&Reflect,Fi=Pi.apply,Ii=Pi.construct;Mi||=function(e){return e},G||=function(e){return e},Fi||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Ii||=function(e){return new e(...[...arguments].slice(1))};var Li=J(Array.prototype.forEach);Array.prototype.indexOf;var Ri=J(Array.prototype.lastIndexOf),K=J(Array.prototype.pop),zi=J(Array.prototype.push),Bi=J(Array.prototype.slice),q=J(Array.prototype.splice),Vi=Array.isArray,Hi=aa(Set),Ui=J(Set.prototype.add),Wi=J(Set.prototype.has),Gi=J(String.prototype.toLowerCase),Ki=J(String.prototype.toString),qi=J(String.prototype.match),Ji=J(String.prototype.replace),Yi=J(String.prototype.indexOf),Xi=J(String.prototype.trim),Zi=J(Number.prototype.toString),Qi=J(Boolean.prototype.toString),$i=typeof BigInt>`u`?null:J(BigInt.prototype.toString),ea=typeof Symbol>`u`?null:J(Symbol.prototype.toString),ta=J(Object.prototype.hasOwnProperty),na=J(Object.prototype.toString),ra=J(RegExp.prototype.test),ia=aa(TypeError);function J(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return Fi(e,t,n)}}function aa(e){return function(){return Ii(e,[...arguments])}}function Y(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Gi;if(Oi&&Oi(e,null),!Vi(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ki(t)||(t[r]=e),i=e)}e[i]=!0}return e}function oa(e){for(let t=0;t<e.length;t++)ta(e,t)||(e[t]=null);return e}function sa(e){let t=Ni(null);for(let r of Di(e)){var n=wi(r,2);let i=n[0],a=n[1];ta(e,i)&&(t[i]=Vi(a)?oa(a):a&&typeof a==`object`&&a.constructor===Object?sa(a):a)}return t}function ca(e){switch(typeof e){case`string`:return e;case`number`:return Zi(e);case`boolean`:return Qi(e);case`bigint`:return $i?$i(e):`0`;case`symbol`:return ea?ea(e):`Symbol()`;case`undefined`:return na(e);case`function`:case`object`:{if(e===null)return na(e);let t=e,n=X(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:na(e)}return na(e)}default:return na(e)}}function X(e,t){for(;e!==null;){let n=ji(e,t);if(n){if(n.get)return J(n.get);if(typeof n.value==`function`)return J(n.value)}e=Ai(e)}function n(){return null}return n}function la(e,t){for(;e!==null;){let n=ji(e,t);if(n)return n.get?J(n.get):null;e=Ai(e)}return null}function ua(e){try{return ra(e,``),!0}catch{return!1}}var da=Mi(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),fa=Mi(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),pa=Mi([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),ma=Mi([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),ha=Mi(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),ga=Mi([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),_a=Mi([`#text`]),va=Mi(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),ya=Mi(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),ba=Mi(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),xa=Mi([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Sa=G(/{{[\w\W]*|^[\w\W]*}}/g),Ca=G(/<%[\w\W]*|^[\w\W]*%>/g),wa=G(/\${[\w\W]*/g),Ta=G(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ea=G(/^aria-[\-\w]+$/),Da=G(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Oa=G(/^(?:\w+script|data):/i),ka=G(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Aa=G(/^html$/i),ja=G(/^[a-z][.\w]*(-[.\w]+)+$/i),Ma=G(/<[/\w!]/g),Na=G(/<[/\w]/g),Pa=G(/<\/no(script|embed|frames)/i),Fa=G(/\/>/i),Z={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Ia=Mi(Y({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),La=function(){return typeof window>`u`?null:window},Ra=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},za=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ba=function(e,t,n,r){return ta(e,t)&&Vi(e[t])?Y(r.base?sa(r.base):{},e[t],r.transform):n},Va=function(e,t,n){let r=ta(e,t)?e[t]:void 0;return r&&typeof r==`object`?sa(r):n()};function Ha(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:La(),t=e=>Ha(e);if(t.version=`3.4.17`,t.removed=[],!e||!e.document||e.document.nodeType!==Z.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=X(d,`cloneNode`),p=X(d,`remove`),m=X(d,`removeAttributeNode`),h=X(d,`nextSibling`),g=X(d,`childNodes`),_=X(d,`parentNode`),ee=X(d,`shadowRoot`),v=X(d,`attributes`),y=o&&o.prototype?X(o.prototype,`nodeType`):null,b=o&&o.prototype?X(o.prototype,`nodeName`):null,x=o&&o.prototype?X(o.prototype,`ownerDocument`):null,S=function(e){return y?y(e):e.nodeType},C=function(e){return b?b(e):e.nodeName},w=la(d,`namespaceURI`),T=function(e){return w?w(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let E,D=``,te,ne=!1,O=0,re=function(){if(O>0)throw ia(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},k=function(e){re(),O++;try{return E.createHTML(e)}finally{O--}},ie=function(e){re(),O++;try{return E.createScriptURL(e)}finally{O--}},ae=function(){return ne||=(te=Ra(u,i),!0),te},oe=n,A=oe.implementation,se=oe.createNodeIterator,ce=oe.createDocumentFragment,j=oe.getElementsByTagName,le=r.importNode,M=za();t.isSupported=typeof Di==`function`&&typeof _==`function`&&A&&A.createHTMLDocument!==void 0;let N=Sa,ue=Ca,P=wa,de=Ta,fe=Ea,pe=Oa,me=ka,he=ja,ge=Da,F=null,_e=Y({},[...da,...fa,...pa,...ha,..._a]),I=null,ve=Y({},[...va,...ya,...ba,...xa]),ye=Object.seal(Ni(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),be=null,xe=null,Se=Object.seal(Ni(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ce=!0,we=!0,Te=!1,Ee=!0,De=!1,Oe=!0,ke=!1,Ae=!1,je=null,Me=null,Ne=!1,Pe=!1,Fe=!1,L=!1,Ie=!0,Le=!1,Re=`user-content-`,ze=!0,Be=!1,Ve=null,He={},Ue=null,We=Y({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Ge=null,Ke=Y({},[`audio`,`video`,`img`,`source`,`image`,`track`]),qe=null,Je=Y({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ye=`http://www.w3.org/1998/Math/MathML`,Xe=`http://www.w3.org/2000/svg`,Ze=`http://www.w3.org/1999/xhtml`,Qe=Ze,$e=!1,et=null,tt=Y({},[Ye,Xe,Ze],Ki),nt=Mi([`mi`,`mo`,`mn`,`ms`,`mtext`]),rt=Y({},nt),it=Mi([`annotation-xml`]),at=Y({},it),ot=Y({},[`title`,`style`,`font`,`a`,`script`]),st=null,ct=[`application/xhtml+xml`,`text/html`],lt=null,ut=null,dt=n.createElement(`form`),ft=function(e){return e instanceof RegExp||e instanceof Function},pt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ut&&ut===e)return;(!e||typeof e!=`object`)&&(e={}),e=sa(e),st=ct.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,lt=st===`application/xhtml+xml`?Ki:Gi,F=Ba(e,`ALLOWED_TAGS`,_e,{transform:lt}),I=Ba(e,`ALLOWED_ATTR`,ve,{transform:lt}),et=Ba(e,`ALLOWED_NAMESPACES`,tt,{transform:Ki}),qe=Ba(e,`ADD_URI_SAFE_ATTR`,Je,{transform:lt,base:Je}),Ge=Ba(e,`ADD_DATA_URI_TAGS`,Ke,{transform:lt,base:Ke}),Ue=Ba(e,`FORBID_CONTENTS`,We,{transform:lt}),be=Ba(e,`FORBID_TAGS`,sa({}),{transform:lt}),xe=Ba(e,`FORBID_ATTR`,sa({}),{transform:lt}),He=ta(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?sa(e.USE_PROFILES):e.USE_PROFILES:!1,Ce=e.ALLOW_ARIA_ATTR!==!1,we=e.ALLOW_DATA_ATTR!==!1,Te=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ee=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,De=e.SAFE_FOR_TEMPLATES||!1,Oe=e.SAFE_FOR_XML!==!1,ke=e.WHOLE_DOCUMENT||!1,Pe=e.RETURN_DOM||!1,Fe=e.RETURN_DOM_FRAGMENT||!1,L=e.RETURN_TRUSTED_TYPE||!1,Ne=e.FORCE_BODY||!1,Ie=e.SANITIZE_DOM!==!1,Le=e.SANITIZE_NAMED_PROPS||!1,ze=e.KEEP_CONTENT!==!1,Be=e.IN_PLACE||!1,ge=ua(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Da,Qe=typeof e.NAMESPACE==`string`?e.NAMESPACE:Ze,rt=Va(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>Y({},nt)),at=Va(e,`HTML_INTEGRATION_POINTS`,()=>Y({},it));let t=Va(e,`CUSTOM_ELEMENT_HANDLING`,()=>Ni(null));if(ye=Ni(null),ta(t,`tagNameCheck`)&&ft(t.tagNameCheck)&&(ye.tagNameCheck=t.tagNameCheck),ta(t,`attributeNameCheck`)&&ft(t.attributeNameCheck)&&(ye.attributeNameCheck=t.attributeNameCheck),ta(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(ye.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),G(ye),De&&(we=!1),Fe&&(Pe=!0),He&&(F=Y({},_a),I=Ni(null),He.html===!0&&(Y(F,da),Y(I,va)),He.svg===!0&&(Y(F,fa),Y(I,ya),Y(I,xa)),He.svgFilters===!0&&(Y(F,pa),Y(I,ya),Y(I,xa)),He.mathMl===!0&&(Y(F,ha),Y(I,ba),Y(I,xa))),Se.tagCheck=null,Se.attributeCheck=null,ta(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Se.tagCheck=e.ADD_TAGS:Vi(e.ADD_TAGS)&&(F===_e&&(F=sa(F)),Y(F,e.ADD_TAGS,lt))),ta(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Se.attributeCheck=e.ADD_ATTR:Vi(e.ADD_ATTR)&&(I===ve&&(I=sa(I)),Y(I,e.ADD_ATTR,lt))),ta(e,`ADD_FORBID_CONTENTS`)&&Vi(e.ADD_FORBID_CONTENTS)&&(Ue===We&&(Ue=sa(Ue)),Y(Ue,e.ADD_FORBID_CONTENTS,lt)),ze&&(F[`#text`]=!0),ke&&Y(F,[`html`,`head`,`body`]),F.table&&(Y(F,[`tbody`]),delete be.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw ia(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw ia(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=E;E=e.TRUSTED_TYPES_POLICY;try{D=k(``)}catch(e){throw E=t,e}}else e.TRUSTED_TYPES_POLICY===null?(E=void 0,D=``):(E===void 0&&(E=ae()),E&&typeof D==`string`&&(D=k(``)));Mi&&Mi(e),ut=e},mt=Y({},[...fa,...pa,...ma]),ht=Y({},[...ha,...ga]),gt=function(e,t,n){return t.namespaceURI===Ze?e===`svg`:t.namespaceURI===Ye?e===`svg`&&(n===`annotation-xml`||rt[n]):!!mt[e]},_t=function(e,t,n){return t.namespaceURI===Ze?e===`math`:t.namespaceURI===Xe?e===`math`&&at[n]:!!ht[e]},vt=function(e,t,n){return t.namespaceURI===Xe&&!at[n]||t.namespaceURI===Ye&&!rt[n]?!1:!ht[e]&&(ot[e]||!mt[e])},yt=function(e){let t=T(e),n=Gi(C(e)),r=_(e),i,a;return r&&S(r)===Z.element?(i={namespaceURI:T(r)},a=Gi(C(r))):(i={namespaceURI:Qe},a=`template`),et[t]?t===Xe?gt(n,i,a):t===Ye?_t(n,i,a):t===Ze?vt(n,i,a):!!(st===`application/xhtml+xml`&&et[t]):!1},bt=function(e){zi(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw ia(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},xt=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},St=function(e){Et(e);let t=g(e);t&&Li(Bi(t),e=>{try{p(e)}catch{}});let n=S(e)===Z.element?v(e):null;if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&xt(e,r,i)}},Ct=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}zi(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Pe||Fe)try{bt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},wt=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||I[lt(i)]||xt(e,r,i)}},Tt=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&S(e)===Z.element){let t=ee(e);Vt(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},Et=function(e){Tt(e,e=>{S(e)===Z.element&&wt(e)})},Dt=function(e){let t=[];return Tt(e,e=>{t.push(e)},!0),t},Ot=function(e,t){let n=Hi();Li(Dt(e),e=>{S(e)===Z.element&&Ui(n,e)}),Li(t,e=>{S(e)===Z.element&&!Wi(n,e)&&wt(e)})},kt=function(e,n){let r=!1;return Li(t.removed,t=>{t.element&&(r||=t.element===e,Et(t.element))}),Ot(e,n),r},At=function(e,t){let n=Ve,r=null,i=()=>(r||(r=Hi(),Li(t,e=>{Ui(r,e)})),r);for(let t=0;;t++){let r=Dt(e),a=[e],o=!1;if(Li(r,e=>{S(e)===Z.documentFragment?zi(a,e):!o&&!Wi(n,e)&&(o=Wi(i(),e))}),!o)return;if(t>=8)throw ia(`the tree kept changing during in-place sanitization; refusing to return it`);Li(a,(t,n)=>{jt(t,n>0,e,i())})}},jt=function(e,t,n,r){let i=It(e),a;for(;a=i.nextNode();)Wi(r,a)&&!Wi(Ve,a)&&(t&&Ut(M.uponSanitizeShadowNode,a,null),Yt(a,n),nn(a,n),Vt(a.content)&&rn(a.content))},Mt=function(e){Ve&&Ui(Ve,e)},Nt=function(e,t){return Oe?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Pt=function(e){Oe&&Tt(e,e=>{let t=S(e);if(t===Z.processingInstruction||t===Z.comment&&ra(Na,e.data)){try{p(e)}catch{}return!1}if(t===Z.element){let t=e,n=lt(C(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Nt(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},Ft=function(e){let t=null,r=null;if(Ne)e=`<remove></remove>`+e;else{let t=qi(e,/^[\r\n\t ]+/);r=t&&t[0]}st===`application/xhtml+xml`&&Qe===Ze&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=E?k(e):e;if(Qe===Ze)try{t=new l().parseFromString(i,st)}catch{}if(!t||!t.documentElement){t=A.createDocument(Qe,`template`,null);try{t.documentElement.innerHTML=$e?D:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Qe===Ze?j.call(t,ke?`html`:`body`)[0]:ke?t.documentElement:a},It=function(e){let t=x?x(e):e.ownerDocument;return se.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Lt=function(e){return e=Ji(e,N,` `),e=Ji(e,ue,` `),e=Ji(e,P,` `),e},Rt=function(e){zt(e);let t=e.querySelectorAll?.call(e,`template`);t&&Li(t,e=>{Vt(e.content)&&Rt(e.content)})},zt=function(e){e.normalize();let t=x?x(e):e.ownerDocument,n=se.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=Lt(r.data),r=n.nextNode()},Bt=function(e){let t=b?b(e):null;return typeof t!=`string`||lt(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==g(e)},Vt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===Z.documentFragment}catch{return!1}},Ht=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Ut(e,n,r){e.length!==0&&Li(e,e=>{e.call(t,n,r,ut)})}let Wt=function(e,t){return!!(Oe&&e.hasChildNodes()&&!Ht(e.firstElementChild)&&ra(Ma,e.textContent)&&ra(Ma,e.innerHTML)||Oe&&Ia[t]&&S(e)===Z.element&&T(e)===Ze&&(Ht(e.firstElementChild)||typeof e.textContent==`string`&&ra(Ma,e.textContent))||e.nodeType===Z.processingInstruction||Oe&&e.nodeType===Z.comment&&ra(Na,e.data))},Gt=function(e,t){return e instanceof RegExp?ra(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Kt=function(e,t,n){if(!be[t]&&Qt(t)&&Gt(ye.tagNameCheck,t))return!1;if(ze&&!Ue[t]&&!Ue[Gi(t)]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,h(e))}}}return bt(e),!0},qt=function(e,t,n,r){return e.length===0?t:t===n||t===r?sa(t):t},Jt=function(e,t){return e===t||_(e)!==null?!1:(Be&&Et(e),!0)},Yt=function(e,n){if(Mt(e),Ut(M.beforeSanitizeElements,e,null),Jt(e,n))return!0;if(Bt(e))return bt(e),!0;let r=lt(C(e));if(F=qt(M.uponSanitizeElement,F,_e,je),Ut(M.uponSanitizeElement,e,{tagName:r,allowedTags:F}),Jt(e,n))return!0;if(Wt(e,r))return bt(e),!0;if(be[r]||!(Se.tagCheck instanceof Function&&Se.tagCheck(r))&&!F[r]){let t=Kt(e,r,n);return t===!1&&(Ut(M.afterSanitizeElements,e,null),Jt(e,n))?!0:t}if(S(e)===Z.element&&!yt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&ra(Pa,e.innerHTML))return bt(e),!0;if(De&&e.nodeType===Z.text){let n=Lt(e.textContent);e.textContent!==n&&(zi(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Ut(M.afterSanitizeElements,e,null),Jt(e,n)},Xt=function(e,t,r){if(xe[t]||Nt(t,e)||Ie&&(t===`id`||t===`name`)&&(r in n||r in dt))return!1;let i=I[t]||Se.attributeCheck instanceof Function&&Se.attributeCheck(t,e);return we&&ra(de,t)||Ce&&ra(fe,t)?!0:i?qe[t]||ra(ge,Ji(r,me,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Yi(r,`data:`)===0&&Ge[e]||Te&&!ra(pe,Ji(r,me,``))?!0:!r:Qt(e)&&Gt(ye.tagNameCheck,e)&&Gt(ye.attributeNameCheck,t,e)||t===`is`&&ye.allowCustomizedBuiltInElements&&Gt(ye.tagNameCheck,r)},Zt=Y({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Qt=function(e){return!Zt[Gi(e)]&&ra(he,e)},$t=function(e,t,n,r){if(E&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return k(r);case`TrustedScriptURL`:return ie(r)}return r},en=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Bt(e)||(bt(e),!1)}catch{return Ct(t,e),!1}},tn=function(e,t){return Oe&&ra(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,t)?!0:Gi(e)===`attributename`&&qi(t,`href`)!==null},nn=function(e,n){if(Ut(M.beforeSanitizeAttributes,e,null),Jt(e,n))return;let r=e.attributes;if(!r||Bt(e))return;I=qt(M.uponSanitizeAttribute,I,ve,Me);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:I,forceKeepAttr:void 0},a=r.length,o=lt(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=lt(s),d=l,f=s===`value`?d:Xi(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Ut(M.uponSanitizeAttribute,e,i),f=i.attrValue,Le&&(u===`id`||u===`name`)&&Yi(f,Re)!==0&&(Ct(s,e,n),f=Re+f,p=!0),tn(s,f)?Ct(s,e,n):i.forceKeepAttr||(i.keepAttr?!Ee&&ra(Fa,f)?Ct(s,e,n):(De&&(f=Lt(f)),Xt(o,u,f)?(f=$t(o,u,c,f),f!==d&&en(e,s,c,f)&&p&&K(t.removed)):Ct(s,e,n)):Ct(s,e,n))}Ut(M.afterSanitizeAttributes,e,null),Jt(e,n)},rn=function(e){let t=null,n=It(e);for(Ut(M.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Ut(M.uponSanitizeShadowNode,t,null),Yt(t,e),nn(t,e),Vt(t.content)&&rn(t.content),S(t)===Z.element){let e=ee(t);Vt(e)&&(an(e),rn(e))}De&&zt(e),Ut(M.afterSanitizeShadowDOM,e,null)},an=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){rn(e.shadow);continue}let n=e.node,r=S(n)===Z.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&<(e)===`template`){let e=n.content;Vt(e)&&t.push({node:e,shadow:null})}}if(r){let e=ee(n);Vt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if($e=!e,$e&&(e=`<!-->`),typeof e!=`string`&&!Ht(e)&&(e=ca(e),typeof e!=`string`))throw ia(`dirty is not a string, aborting`);if(!t.isSupported)return e;Ae?(F=je,I=Me):pt(n),(M.uponSanitizeElement.length>0||M.uponSanitizeAttribute.length>0)&&(F=sa(F)),M.uponSanitizeAttribute.length>0&&(I=sa(I)),t.removed=[];let c=Be&&typeof e!=`string`&&Ht(e),l=[],u=Ve;if(c){Pt(e);let t=C(e);if(typeof t==`string`){let n=lt(t);if(!F[n]||be[n])throw St(e),ia(`root node is forbidden and cannot be sanitized in-place`)}if(Bt(e))throw St(e),ia(`root node is clobbered and cannot be sanitized in-place`);l=Dt(e),Ve=Hi()}else if(Ht(e))i=Ft(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Z.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),an(i);else{if(!Pe&&!De&&!ke&&e.indexOf(`<`)===-1)return E&&L?k(e):e;if(i=Ft(e),!i)return Pe?null:L?D:``}i&&Ne&&bt(i.firstChild);let d=c?e:i;try{c&&an(e);let t=It(d);for(;o=t.nextNode();)Yt(o,d),nn(o,d),Vt(o.content)&&rn(o.content);c&&At(e,l)}catch(t){throw c&&(St(e),kt(e,l)),t}finally{Ve=u}if(c){if(kt(e,l))throw ia(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return De&&Rt(e),e}if(Pe){if(De&&Rt(i),Fe)for(s=ce.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(I.shadowroot||I.shadowrootmode)&&(s=le.call(r,s,!0)),s}let f=ke?i.outerHTML:i.innerHTML;return ke&&F[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&ra(Aa,i.ownerDocument.doctype.name)&&(f=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
62
|
-
`+f),De&&(f=Lt(f)),E&&L?k(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};pt(e),Ae=!0,je=F,Me=I},t.clearConfig=function(){ut=null,Ae=!1,je=null,Me=null,E=te,D=``},t.isValidAttribute=function(e,t,n){ut||pt({});let r=lt(e),i=lt(t);return typeof n==`string`&&(tn(t,n)||!Ee&&ra(Fa,n))?!1:Xt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&ta(M,e)&&zi(M[e],t)},t.removeHook=function(e,t){if(ta(M,e)){if(t!==void 0){let n=Ri(M[e],t);return n===-1?void 0:q(M[e],n,1)[0]}return K(M[e])}},t.removeHooks=function(e){ta(M,e)&&(M[e]=[])},t.removeAllHooks=function(){M=za()},t}var Ua=Ha();function Wa(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}var Ga=new _i({renderer:{code({text:e,lang:t,escaped:n}){return`<div class="code-block"><div class="code-block-head"><span>${Wa((t??``).trim().split(/\s+/)[0]||`代码块`)}</span><button type="button" data-copy-code>复制</button></div><pre><code>${n?e:Wa(e)}</code></pre></div>`},link(e){return`<a href="${Wa(e.href||``)}"${e.title?` title="${Wa(e.title)}"`:``} target="_blank" rel="noopener noreferrer">${this.parser.parseInline(e.tokens??[])}</a>`}}});function Ka(e){let t=Ga.parse(e,{async:!1});return Ua.sanitize(t,{ADD_ATTR:[`target`]})}function qa(e){let t=[e.templateTitle||e.templateId?.split(`/`).pop()||`默认模板`,e.outputFormat.toUpperCase()];return e.reqPath&&t.push(e.reqPath.split(`/`).pop()||e.reqPath),t.join(` · `)}function Ja(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1]??e.match(/\{[\s\S]*\}/)?.[0]??e.match(/\[[\s\S]*\]/)?.[0];if(!t)return null;try{let e=JSON.parse(t);if(Array.isArray(e)&&e.length>0)return{docTitle:``,cases:e,coverageRate:null,uncovered:[],writeNote:``};if(e&&typeof e==`object`){let t=e,n=t.用例??t.cases??t.items;if(!Array.isArray(n)||n.length===0)return null;let r=t.需求名称??t.文档名称??t.docTitle??t.title,i=typeof r==`string`?r.trim():``,a=t.覆盖需求率??t.coverageRate??t.coverage,o=null;if(typeof a==`number`&&Number.isFinite(a))o=Math.max(0,Math.min(100,Math.round(a)));else if(typeof a==`string`&&a.trim()){let e=parseInt(a.replace(/%/g,``),10);Number.isFinite(e)&&(o=Math.max(0,Math.min(100,e)))}let s=t.未覆盖说明??t.uncovered??t.omissions,c=Array.isArray(s)?s.map(e=>String(e).trim()).filter(Boolean):typeof s==`string`&&s.trim()?[s.trim()]:[],l=t.编写说明??t.note??t.summary,u=typeof l==`string`?l.trim():``;return{docTitle:i,cases:n,coverageRate:o,uncovered:c,writeNote:u}}}catch{return null}return null}function Ya(e){return e.replace(/[\\/:*?"<>|]/g,`_`).replace(/\s+/g,`-`).slice(0,48)||`cases`}function Xa(e,t){let n=[];for(let r of t){let t=e.filter(e=>!String(e[r]??``).trim()).length;t===e.length?n.push(`字段「${r}」全部为空`):t>Math.max(2,Math.floor(e.length*.3))&&n.push(`字段「${r}」有 ${t}/${e.length} 条为空`)}return n}function Za(e,t=``){let n=_(e.caseType).label,r=e.templateHeaders.length>0?e.templateHeaders:[...O],i=e.outputFormat===`md`?`最终结果将保存为 Markdown 表格文件`:e.outputFormat===`csv`?`最终结果将保存为 CSV 文件`:`最终结果将保存为 Excel 文件`,a=e.promptBody.trim();if(!a)throw Error(`请先在生成测试用例插件中选择提示词`);return`${a}
|
|
63
|
-
${e.templateBody?`\n\n### 用例模板:${e.templateTitle||e.templateId||``}\n${e.templateBody.slice(0,8e3)}`:`\n\n### 模板字段:${r.join(`、`)}`}
|
|
64
|
-
|
|
65
|
-
【运行时约束 · 生成测试用例插件已启用】
|
|
66
|
-
- 本轮以「生成测试用例」插件所选提示词为准,不要再遵循工作台闲聊/系统提示词风格
|
|
67
|
-
- 用例类型:${n}
|
|
68
|
-
- ${i}
|
|
69
|
-
- 需求名称默认可用「${t||`未命名需求`}」
|
|
70
|
-
- 「用例」对象键必须与模板字段完全一致:${r.join(`、`)}
|
|
71
|
-
- 仅输出一个 JSON 对象(可无代码围栏),结构为:
|
|
72
|
-
{"需求名称":"...","覆盖需求率":0-100,"未覆盖说明":["..."],"编写说明":"...","用例":[...]}
|
|
73
|
-
- 不要输出 JSON 以外的解释性正文;界面只会展示执行摘要,用例由系统静默入库`}function Qa(e=0){return`正在编写用例…\n\n已用 ${Math.max(0,Math.floor(e))}s · 通常约 30–120 秒\n完成后将给出覆盖率与入库结果。`}function $a(e){if(!e.ok)return[`**执行失败**`,``,e.error||`未知错误`,``,`可调整插件中的需求 / 模板 / 提示词后重试。`].join(`
|
|
74
|
-
`);let t=[`**执行成功**`,``,`- 需求名称:${e.title||`—`}`,`- 共编写:${e.count??0} 条用例`,`- 覆盖需求率:${e.coverageRate==null?`未给出(已按用例入库)`:`${e.coverageRate}%`}`];e.path&&t.push(`- 入库文件:用例管理/${e.path}`),e.writeNote&&t.push(``,`**编写说明**`,e.writeNote);let n=e.uncovered??[];if(t.push(``,`**未覆盖 / 未编写原因**`),n.length)for(let e of n)t.push(`- ${e}`);else t.push(`- 无(模型未声明未覆盖项)`);let r=e.fieldGaps??[];if(r.length){t.push(``,`**字段完整性检测**`);for(let e of r)t.push(`- ${e}`)}return t.join(`
|
|
75
|
-
`)}async function eo(e){if(!Me(`cases`))throw Error(je(`cases`));let t=_(e.caseType),n=Ya(e.title),r=e.outputFormat===`md`?`.md`:e.outputFormat===`csv`?`.csv`:`.xlsx`,i=e.linkedPath||`${n}${r}`;i.includes(`/`)&&!e.linkedPath&&(i=`${n}${r}`);let a=e.headers.length?e.headers:[...O];return e.outputFormat===`md`?await A(`cases`,i,te(e.cases,e.title,a)):e.outputFormat===`csv`?await A(`cases`,i,E(e.cases,a)):await de(`cases`,i,await x(e.cases,a,t.label)),i}async function to(e,t,n){let r=Ja(e);if(!r){let e=`未能解析出用例结果,未写入文件`;return{ok:!1,error:e,summary:$a({ok:!1,error:e})}}let i=t.templateHeaders.length>0?t.templateHeaders:[...O],a=T(r.cases,i),o=r.docTitle||n||_(t.caseType).label,s=Xa(a,i);try{let e=await eo({cases:a,headers:i,caseType:t.caseType,outputFormat:t.outputFormat,title:o}),n=$a({ok:!0,title:o,path:e,count:a.length,coverageRate:r.coverageRate,uncovered:r.uncovered,writeNote:r.writeNote,fieldGaps:s});return{ok:!0,path:e,count:a.length,title:o,coverageRate:r.coverageRate,uncovered:r.uncovered,writeNote:r.writeNote,fieldGaps:s,summary:n}}catch(e){let t=e instanceof Error?e.message:String(e);return{ok:!1,error:t,summary:$a({ok:!1,error:t})}}}function no(){let e=u().promptKinds;return a(e?.length?e:o)}function ro(e){let t=no();return t.find(t=>t.id===e)??t[0]??o[0]}function io(e){let t=a(e);return f({promptKinds:t}),d(),t}function ao(e){let t=e.trim();if(!t)throw Error(`类型名称不能为空`);if(t.length>40)throw Error(`类型名称过长(最多 40 字)`);let n=no();if(n.some(e=>e.label===t))throw Error(`已存在「${t}」`);let a={id:i(),label:t,hint:r(t)};return io([...n,a]),a}function oo(e,t){let n=t.trim();if(!n)throw Error(`类型名称不能为空`);if(n.length>40)throw Error(`类型名称过长(最多 40 字)`);let i=no(),a=i.findIndex(t=>t.id===e);if(a<0)throw Error(`类型不存在`);if(i.some(t=>t.id!==e&&t.label===n))throw Error(`已存在「${n}」`);let o=i[a],s={...o,label:n,hint:o.id===`case`||o.id===`general`?o.hint:r(n)},c=[...i];return c[a]=s,io(c),s}function so(e){let t=no();if(t.length<=1)throw Error(`至少保留一个提示词类型`);if(!t.some(t=>t.id===e))throw Error(`类型不存在`);return io(t.filter(t=>t.id!==e))}function co(e){return`${ro(e.kind).label} · ${e.titleHint.trim()||`未命名`}`}function lo(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1]??e.match(/\{[\s\S]*\}/)?.[0];if(!t)return null;try{let e=JSON.parse(t);if(!e||typeof e!=`object`)return null;let n=e.提示词名称??e.title??e.name,r=e.正文??e.body??e.content??e.markdown,i=typeof n==`string`?n.trim():``,a=typeof r==`string`?r.trim():``;if(!a)return null;let o=e.质检通过??e.qcPass??e.pass,s=typeof o==`boolean`?o:typeof o!=`string`||!/^(false|0|no|否|未通过|fail)/i.test(o.trim()),c=e.质检问题??e.qcIssues??e.issues,l=Array.isArray(c)?c.map(e=>String(e).trim()).filter(Boolean):typeof c==`string`&&c.trim()?[c.trim()]:[],u=e.质检说明??e.qcNote??e.note;return{title:i,body:a,qcPass:s,qcIssues:l,qcNote:typeof u==`string`?u.trim():``}}catch{return null}}function uo(e){return e.replace(/[\\/:*?"<>|]/g,`_`).replace(/\s+/g,``).replace(/\.md$/i,``).slice(0,64)||`未命名提示词`}function fo(e,t=``){let n=[...e.qcIssues],r=(e.title||t||`未命名提示词`).trim();e.qcPass||n.push(`模型自检未通过(质检通过=false)`),(!r||r.length<2)&&n.push(`提示词名称过短(至少 2 字)`),r.length>80&&n.push(`提示词名称过长(最多 80 字)`),/[\\/]/.test(r)&&n.push(`提示词名称不可包含路径分隔符`);let i=uo(r),a=`${i}.md`;fe(a)&&n.push(`不可覆盖受保护提示词「${a}」`),e.body.trim()?e.body.trim().length<80&&n.push(`正文过短(建议不少于 80 字)`):n.push(`正文为空`),!/^#\s+/m.test(e.body)&&!e.body.includes(`
|
|
76
|
-
`)&&n.push(`正文建议使用 Markdown 标题与分段结构`);let o=[...new Set(n.filter(Boolean))];return{ok:o.length===0,issues:o,title:r,fileBase:i}}function po(e){return`你是资深提示词工程师,擅长为测试与研发场景编写可落地的中文提示词。
|
|
77
|
-
|
|
78
|
-
【任务】
|
|
79
|
-
根据用户在对话中的需求,编写一份完整的 Markdown 提示词正文,供后续入库到提示词库。
|
|
80
|
-
具体要求以用户本轮及近期对话输入为准。
|
|
81
|
-
|
|
82
|
-
【类型】
|
|
83
|
-
${ro(e.kind).hint}
|
|
84
|
-
|
|
85
|
-
【用户期望名称】
|
|
86
|
-
${e.titleHint.trim()||`(可在结果中自拟简洁中文名)`}
|
|
87
|
-
|
|
88
|
-
【输出前自检(必须)】
|
|
89
|
-
1. 角色与目标是否清晰?
|
|
90
|
-
2. 约束是否可执行、无互相矛盾?
|
|
91
|
-
3. 是否避免空话与不可判定要求?
|
|
92
|
-
4. 用例类提示词:是否要求按模板字段输出、步骤换行、按需求覆盖(不设固定条数)?
|
|
93
|
-
5. 若未通过,将「质检通过」设为 false,并在「质检问题」列出具体项。
|
|
94
|
-
|
|
95
|
-
【输出格式(强制)】
|
|
96
|
-
仅输出一个 JSON 对象(可无代码围栏),不要其它解释:
|
|
97
|
-
{
|
|
98
|
-
"提示词名称": "简短中文名(不含 .md)",
|
|
99
|
-
"质检通过": true,
|
|
100
|
-
"质检问题": [],
|
|
101
|
-
"质检说明": "一句话说明质检结论",
|
|
102
|
-
"正文": "# 标题\\n\\n完整 Markdown 正文……"
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
约束:
|
|
106
|
-
- 「正文」为完整 Markdown 字符串,可含换行;不要把正文拆到 JSON 外。
|
|
107
|
-
- 「质检通过」为 false 时系统不会入库。
|
|
108
|
-
- 不要输出 JSON 以外的闲聊;界面只展示执行摘要。`}function mo(e=0){return`正在编写提示词…\n\n已用 ${Math.max(0,Math.floor(e))}s · 通常约 30–90 秒\n完成后将质检并自动入库到提示词管理。`}function ho(e){if(!e.ok){let t=[`**执行失败 / 未入库**`,``,e.error||`质检未通过或解析失败`],n=e.issues??[];if(n.length){t.push(``,`**质检问题**`);for(let e of n)t.push(`- ${e}`)}return t.push(``,`可在对话中补充要求后重新发送,或在插件中修改名称/类型。`),t.join(`
|
|
109
|
-
`)}let t=[`**执行成功**`,``,`- 提示词名称:${e.title||`—`}`];return e.path&&t.push(`- 入库文件:提示词管理/${e.path}`),e.qcNote&&t.push(``,`**质检说明**`,e.qcNote),t.push(``,`下方卡片可点击打开文件。`),t.join(`
|
|
110
|
-
`)}async function go(e){let t=`${e}.md`;try{let{entries:n}=await P(`prompts`,`.`),r=new Set(n.filter(e=>e.type===`file`).map(e=>e.name));if(!r.has(t))return t;for(let t=2;t<100;t++){let n=`${e}-${t}.md`;if(!r.has(n))return n}}catch{}return`${e}-${Date.now().toString(36)}.md`}async function _o(e,t){let n=lo(e);if(!n){let e=`未能解析出提示词结果,未写入文件`;return{ok:!1,error:e,issues:[],summary:ho({ok:!1,error:e})}}let r=fo(n,t.titleHint);if(!r.ok){let e=`入库前质检未通过`;return{ok:!1,error:e,issues:r.issues,summary:ho({ok:!1,error:e,issues:r.issues,qcNote:n.qcNote})}}if(!Me(`prompts`)){let e=je(`prompts`);return{ok:!1,error:e,issues:[],summary:ho({ok:!1,error:e})}}try{let e=await go(r.fileBase);await A(`prompts`,e,n.body.endsWith(`
|
|
111
|
-
`)?n.body:`${n.body}\n`);let t=ho({ok:!0,title:r.title,path:e,qcNote:n.qcNote});return{ok:!0,path:e,title:r.title,qcNote:n.qcNote,summary:t}}catch(e){let t=e instanceof Error?e.message:String(e);return{ok:!1,error:t,issues:[],summary:ho({ok:!1,error:t})}}}function vo(){let e=u().knowledgeCategories;return e?.length?[...e]:[...s]}function yo(e){let t=p(e);return f({knowledgeCategories:t}),d(),t}function bo(e){let t=e.trim();if(!t)throw Error(`分类名称不能为空`);if(t.length>40)throw Error(`分类名称过长(最多 40 字)`);if(/[\\/]/.test(t))throw Error(`分类名称不可包含路径分隔符`);let n=vo();if(n.includes(t))throw Error(`已存在「${t}」`);return yo([...n,t]),t}function xo(e,t){let n=t.trim();if(!n)throw Error(`分类名称不能为空`);if(n.length>40)throw Error(`分类名称过长(最多 40 字)`);if(/[\\/]/.test(n))throw Error(`分类名称不可包含路径分隔符`);let r=vo(),i=r.indexOf(e);if(i<0)throw Error(`分类不存在`);if(r.some((e,t)=>t!==i&&e===n))throw Error(`已存在「${n}」`);let a=[...r];return a[i]=n,yo(a),n}function So(e){let t=vo();if(t.length<=1)throw Error(`至少保留一个分类`);if(!t.includes(e))throw Error(`分类不存在`);return yo(t.filter(t=>t!==e))}function Co(e){let t=e.titleHint.trim()||`未命名`;return`${e.category} · ${t}`}function wo(e){return vo().includes(e)}function To(e){let t=e.match(/```(?:json)?\s*([\s\S]*?)```/)?.[1]??e.match(/\{[\s\S]*\}/)?.[0];if(!t)return null;try{let e=JSON.parse(t);if(!e||typeof e!=`object`)return null;let n=e.标题??e.知识库名称??e.title??e.name,r=e.分类??e.category,i=e.描述??e.description,a=e.正文??e.body??e.content??e.markdown,o=typeof n==`string`?n.trim():``,s=typeof r==`string`?r.trim():``,c=typeof i==`string`?i.trim():``,l=typeof a==`string`?a.trim():``;if(!l)return null;let u=e.质检通过??e.qcPass??e.pass,d=typeof u==`boolean`?u:typeof u!=`string`||!/^(false|0|no|否|未通过|fail)/i.test(u.trim()),f=e.质检问题??e.qcIssues??e.issues,p=Array.isArray(f)?f.map(e=>String(e).trim()).filter(Boolean):typeof f==`string`&&f.trim()?[f.trim()]:[],m=e.质检说明??e.qcNote??e.note;return{title:o,category:s,description:c,body:l,qcPass:d,qcIssues:p,qcNote:typeof m==`string`?m.trim():``}}catch{return null}}function Eo(e){return e.replace(/[\\/:*?"<>|]/g,`_`).replace(/\s+/g,``).replace(/\.md$/i,``).slice(0,64)||`未命名知识`}function Do(e){let t=e.trim();return!t||/[:#{}[\],&*?|>!<>=%@`"'\\\n]/.test(t)||/^\s|\s$/.test(e)?JSON.stringify(t):t}function Oo(e){return(e.match(/^---\r?\n[\s\S]*?\r?\n---\r?\n?([\s\S]*)$/)?.[1]??e).trim()}function ko(e){let t=e.description.trim(),n=Oo(e.body),r=n.startsWith(`#`)?n:`# ${e.title}\n\n${n}`,i=[`---`,`title: ${Do(e.title)}`,`category: ${Do(e.category)}`];return t&&i.push(`description: ${Do(t)}`),i.push(`---`,``,r,``),i.join(`
|
|
112
|
-
`)}function Ao(e,t){let n=[...e.qcIssues],r=(e.title||t.titleHint||`未命名知识`).trim(),i=(e.category||t.category||``).trim();wo(i)||(i=t.category),e.qcPass||n.push(`模型自检未通过(质检通过=false)`),(!r||r.length<2)&&n.push(`标题过短(至少 2 字)`),r.length>80&&n.push(`标题过长(最多 80 字)`),/[\\/]/.test(r)&&n.push(`标题不可包含路径分隔符`),wo(i)||n.push(`分类必须是:${vo().join(` / `)}`),e.body.trim()?e.body.trim().length<60&&n.push(`正文过短(建议不少于 60 字)`):n.push(`正文为空`);let a=[...new Set(n.filter(Boolean))];return{ok:a.length===0,issues:a,title:r,category:i,fileBase:Eo(r),description:(e.description||``).trim().slice(0,120)}}function jo(e){let t=e.titleHint.trim()||`(可在结果中自拟简洁中文名)`;return`你是资深测试知识库编辑,擅长把规范、方法论、环境约定写成可复用的 Markdown 文档。
|
|
113
|
-
|
|
114
|
-
【任务】
|
|
115
|
-
根据用户在对话中提供的素材/需求,编写一份完整的知识库 Markdown 正文,入库到知识库对应分类目录。
|
|
116
|
-
具体要求以用户本轮及近期对话输入为准。
|
|
117
|
-
|
|
118
|
-
【目标分类】
|
|
119
|
-
${e.category}
|
|
120
|
-
(分类仅限:${vo().join(` / `)};不要写成需求文档或测试用例)
|
|
121
|
-
|
|
122
|
-
【用户期望标题】
|
|
123
|
-
${t}
|
|
124
|
-
|
|
125
|
-
【内容要求】
|
|
126
|
-
1. 结构清晰:标题、条目/表格/步骤可执行;避免空话。
|
|
127
|
-
2. 可复用:适合后续对话用「@」引用。
|
|
128
|
-
3. 不要输出用例表格字段集;不要写成需求 PRD。
|
|
129
|
-
|
|
130
|
-
【输出前自检(必须)】
|
|
131
|
-
1. 分类是否正确?
|
|
132
|
-
2. 标题是否简洁可作文件名?
|
|
133
|
-
3. 正文是否可落地、无互相矛盾?
|
|
134
|
-
4. 若未通过,将「质检通过」设为 false,并在「质检问题」列出具体项。
|
|
135
|
-
|
|
136
|
-
【输出格式(强制)】
|
|
137
|
-
仅输出一个 JSON 对象(可无代码围栏),不要其它解释:
|
|
138
|
-
{
|
|
139
|
-
"标题": "简短中文名(不含 .md)",
|
|
140
|
-
"分类": "${e.category}",
|
|
141
|
-
"描述": "一句话摘要",
|
|
142
|
-
"质检通过": true,
|
|
143
|
-
"质检问题": [],
|
|
144
|
-
"质检说明": "一句话说明质检结论",
|
|
145
|
-
"正文": "# 标题\\n\\n完整 Markdown 正文……"
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
约束:
|
|
149
|
-
- 「正文」为完整 Markdown 字符串(可含换行);frontmatter 由系统自动拼接,正文不要再写 --- frontmatter。
|
|
150
|
-
- 「质检通过」为 false 时系统不会入库。
|
|
151
|
-
- 不要输出 JSON 以外的闲聊;界面只展示执行摘要。`}function Mo(e=0){return`正在编写知识库文档…\n\n已用 ${Math.max(0,Math.floor(e))}s · 通常约 30–90 秒\n完成后将质检并自动入库到知识库管理。`}function No(e){if(!e.ok){let t=[`**执行失败 / 未入库**`,``,e.error||`质检未通过或解析失败`],n=e.issues??[];if(n.length){t.push(``,`**质检问题**`);for(let e of n)t.push(`- ${e}`)}return t.push(``,`可调整说明后重新发送,或在插件中修改分类/标题。`),t.join(`
|
|
152
|
-
`)}let t=[`**执行成功**`,``,`- 标题:${e.title||`—`}`];return e.category&&t.push(`- 分类:${e.category}`),e.path&&t.push(`- 入库文件:知识库管理/${e.path}`),e.qcNote&&t.push(``,`**质检说明**`,e.qcNote),t.push(``,`下方卡片可点击打开文件;对话中也可用「@」引用(构建后或刷新列表)。`),t.join(`
|
|
153
|
-
`)}async function Po(e){let t=`${e}.md`;try{let{entries:n}=await P(`knowledge`,`.`),r=new Set(n.filter(e=>e.type===`file`).map(e=>e.name));if(!r.has(t))return t;for(let t=2;t<100;t++){let n=`${e}-${t}.md`;if(!r.has(n))return n}}catch{}return`${e}-${Date.now().toString(36)}.md`}async function Fo(e,t){let n=To(e);if(!n){let e=`未能解析出知识库结果,未写入文件`;return{ok:!1,error:e,issues:[],summary:No({ok:!1,error:e})}}let r=Ao(n,t);if(!r.ok){let e=`入库前质检未通过`;return{ok:!1,error:e,issues:r.issues,summary:No({ok:!1,error:e,issues:r.issues,qcNote:n.qcNote})}}if(!Me(`knowledgeLib`)){let e=je(`knowledgeLib`);return{ok:!1,error:e,issues:[],summary:No({ok:!1,error:e})}}try{let e=await Po(r.fileBase),t=ko({title:r.title,category:r.category,description:r.description,body:n.body});await A(`knowledge`,e,t.endsWith(`
|
|
154
|
-
`)?t:`${t}\n`);let i=No({ok:!0,title:r.title,path:e,category:r.category,qcNote:n.qcNote});return{ok:!0,path:e,title:r.title,category:r.category,qcNote:n.qcNote,summary:i}}catch(e){let t=e instanceof Error?e.message:String(e);return{ok:!1,error:t,issues:[],summary:No({ok:!1,error:t})}}}var Io=`你是 Lantern Harness(仓库 lantern-harness)的「插件开发」助手,只负责在本项目里开发「扩展插件」。
|
|
155
|
-
|
|
156
|
-
# 铁律:先评估、再确认、后开发
|
|
157
|
-
1. 收到需求后,先只读调研相关代码(fs_read / fs_glob / fs_grep,必要时用只读命令),弄清现有插件约定。
|
|
158
|
-
调研纪律:先用 fs_grep 定位符号 / 字符串,再只读命中片段;不要为了「看清楚」把整个目录、整份大文件逐个读一遍;
|
|
159
|
-
与本次插件无关的模块不必打开;发出确认选项前,读取次数控制在必要范围(一般 8 次以内,确有必要再增加)。
|
|
160
|
-
2. 在改任何文件之前,必须调用 ask_user_question 提出 2~4 个选择题(每题 2~4 个选项),覆盖:
|
|
161
|
-
- 插件形态:纯提示词型 / 带配置面板 / 侧栏库 / 需要本地服务能力
|
|
162
|
-
- 范围与边界:做什么、不做什么
|
|
163
|
-
- 命名与入口:插件 id / 中文名 / 从「+」「/」还是侧栏进入
|
|
164
|
-
- 默认开关:新插件在新建空间里默认开还是关(推荐默认关)
|
|
165
|
-
每题给出推荐项,便于用户直接确认。
|
|
166
|
-
3. 用户回答之前,禁止 fs_write / fs_mkdir / 改配置 / 写文档;这一轮只允许只读调研。
|
|
167
|
-
4. 用户确认后才开始实现;用户改选或补充要求时,按新答案调整后再动手。
|
|
168
|
-
5. 「确认」只认用户明确表达(如「开始实施」「按这个方案做」「确认」)。用户跳过(skipped)、关闭提问卡片、没作答、沉默,都不算确认,也绝不等于批准实施:
|
|
169
|
-
- 这类情况先停手,用几行说明你将采用的默认假设(哪几项按推荐)、插件形态与准备改动的文件范围;
|
|
170
|
-
- 然后等用户明确回复「开始实施」再写文件;跳过当轮只能写代码计划,禁止 fs_write / fs_mkdir / 改配置。
|
|
171
|
-
6. 只改与本次插件相关的文件:不重构无关代码、不改主题样式、不动其它插件行为、不执行 git commit / git push。
|
|
172
|
-
7. 完成后用简短条目汇报:插件 id / 中文名 / 入口位置 / 默认开关 / 改动文件 / 用户如何验证。
|
|
173
|
-
|
|
174
|
-
# 项目插件实现位置(先读再改)
|
|
175
|
-
- 注册表:src/lib/plugins.ts → PluginId 联合类型 + PLUGIN_CATALOG(字段:id/name/description/version/requiresDev/defaultEnabled/hasPanel/requires)
|
|
176
|
-
- 新建空间默认开关:config/app.defaults.json 的 plugins;同时补 src/lib/app-config.ts 的 emptyAppConfig().plugins
|
|
177
|
-
- 我的插件页:src/components/islands/PluginsPage.tsx(按注册表自动渲染;Tab「扩展插件」即扩展插件列表,卡片按 PLUGIN_CATALOG 的 category 分组)
|
|
178
|
-
- 工作台入口:hasPanel=true 的插件会自动出现在「+」弹窗与「/」菜单;入口文案与面板打开逻辑在 src/components/islands/ChatApp.tsx(pluginMenuItems / openPluginPanel / pickPluginMenu / 菜单 tip)
|
|
179
|
-
- 胶囊型入口(与「计划」「插件开发」一致):在 ChatApp 的 composerChip 增加一个取值,+ 菜单里点击后只激活胶囊,用户在主输入框描述要求后发送
|
|
180
|
-
- 带配置面板的插件:新建 src/components/islands/XxxPanel.tsx(复用 SlideOverDrawer);配置类型放 src/lib/xxx.ts;若配置需要跟会话保存,加到 src/lib/sessions.ts 的 ChatSession 与 SessionMetaPatch,并在 ChatApp 的会话切换 / 新建流程里同步
|
|
181
|
-
- 纯提示词型插件:在 src/lib/xxx.ts 导出固定系统提示词与 buildXxxSystemPrompt(),在 ChatApp 的 executeSend 里按会话配置替换 baseSystem
|
|
182
|
-
- 侧栏库:src/lib/nav-menu.ts(NavEntryId / NavEntryDef / i18n 键)、src/lib/plugin-nav.ts、src/components/islands/NavLibraries.tsx、src/lib/i18n.ts,以及 lh-plugins/lh-project-docs.mjs 的 DOC_ROOT_DIRS
|
|
183
|
-
- 本地 API:新建 lh-plugins/lh-xxx.mjs(导出 lhXxxPlugin,提供 configureServer 中间件),并在 astro.config.mjs 与 cli/server.mjs 的插件列表里注册;数据根用 builtin/session/space-context.mjs 的 getDataRoot() / getBaseRoot();PLUGIN_CATALOG 里补 category(内容库 / 生成能力 / 记忆与检索 / 开发工具),没有合适的分类时先问用户
|
|
184
|
-
- 文档:更新 docs/操作手册.md 的插件表与对应章节;在 CHANGELOG.md 顶部(当前版本或 Unreleased)增加条目
|
|
185
|
-
|
|
186
|
-
# 默认值约定
|
|
187
|
-
- 新建空间的插件开关全部默认关闭:config/app.defaults.json 与 src/lib/app-config.ts 的 emptyAppConfig().plugins 都写 false,不要为新插件破例。
|
|
188
|
-
- PLUGIN_CATALOG 里的 defaultEnabled 也写 false:新增插件默认关闭,由用户在「我的插件」里手动开启。
|
|
189
|
-
- 依赖其它插件时用 requires 声明(如生成器依赖对应管理插件)。
|
|
190
|
-
|
|
191
|
-
# 验证
|
|
192
|
-
- 可用时至少运行 pnpm typecheck;涉及服务端或纯函数时补充/运行相关 node:test。
|
|
193
|
-
- 不执行 git commit / git push,不擅自格式化无关文件。
|
|
194
|
-
- 改完说明哪些点没有实际运行验证,不要声称已跑通。
|
|
195
|
-
|
|
196
|
-
# 回答风格
|
|
197
|
-
- 中文、直接、少客套;评估阶段先说结论(做成哪种插件、为什么),再给确认选项。
|
|
198
|
-
- 不要空泛地描述「可以开发」,要给具体方案与取舍。
|
|
199
|
-
- 需要用户批准开工时,用一句明确的话收尾,例如「确认无误请回复:开始实施」。`;function Lo(e,t){let n=String(t??``).trim(),r=[Io];return n&&r.push(`# 本次运行环境\n项目根(可直接用 fs_* 工具读写):${n}`),r.push(`# 本次需求\n${e.requirement.trim()||`(未填写,按用户后续消息执行)`}`),r.join(`
|
|
200
|
-
|
|
201
|
-
`)}var Ro=`/__tb_fs`,zo=`你可以使用 Skill 工具(本地 fs 可用时):
|
|
202
|
-
- skill_list:列出工作区 / 项目根下约定目录中的 SKILL.md
|
|
203
|
-
- skill_load:按 id(目录名)或 path 加载技能正文到本轮上下文
|
|
204
|
-
- 需要遵循某技能流程时先 skill_list 再 skill_load,勿臆造技能内容`,Bo=[{type:`function`,function:{name:`skill_list`,description:`List available skills (SKILL.md) under the workspace / project (.cursor/skills, .agents/skills, skills/, or */SKILL.md).`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`skill_load`,description:`Load a skill by id (directory name) or path to SKILL.md. Returns the skill markdown body (may be truncated).`,parameters:{type:`object`,properties:{name:{type:`string`,description:`Skill id / directory name from skill_list, or relative/absolute path to SKILL.md`},path:{type:`string`,description:`Optional path to SKILL.md (alias of name)`}}}}}];async function Vo(e,t){if(e===`skill_list`)try{let e=await fetch(`${Ro}/skills`,{signal:AbortSignal.timeout(5e3)}),t=await e.json().catch(()=>({}));return e.ok?JSON.stringify({ok:!0,count:t.count??t.skills?.length??0,skills:t.skills??[]},null,2):JSON.stringify({ok:!1,error:t.error||`HTTP ${e.status}`})}catch(e){return JSON.stringify({ok:!1,error:e instanceof Error?e.message:String(e)})}if(e===`skill_load`){let e={};try{e=JSON.parse(t||`{}`)}catch{return JSON.stringify({ok:!1,error:`invalid JSON arguments`})}let n=String(e.name??e.path??e.id??``).trim();if(!n)return JSON.stringify({ok:!1,error:`name or path is required`});try{let e=await fetch(`${Ro}/skill-load`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n}),signal:AbortSignal.timeout(8e3)}),t=await e.json().catch(()=>({}));if(!e.ok){let n=typeof t==`object`&&t&&`error`in t?String(t.error):`HTTP ${e.status}`;return JSON.stringify({ok:!1,error:n})}return JSON.stringify(t,null,2)}catch(e){return JSON.stringify({ok:!1,error:e instanceof Error?e.message:String(e)})}}return JSON.stringify({error:`unknown tool: ${e}`})}var Ho=`/__tb_sessions/query`;function Uo(e){if(!e||typeof e!=`object`)return``;let t=e;return typeof t.content==`string`?t.content:Array.isArray(t.content)?t.content.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&`text`in e?String(e.text??``):``).join(`
|
|
205
|
-
`):``}function Wo(e,t){let n=t.trim().toLowerCase();if(!n)return null;let r=(e.title||``).trim(),i=0,a=``;r.toLowerCase().includes(n)&&(i+=10,a=r);let o=Array.isArray(e.messages)?e.messages:[];for(let e=o.length-1;e>=0;e--){let t=Uo(o[e]),r=t.toLowerCase().indexOf(n);if(!(r<0)){if(i+=1,!a){let e=Math.max(0,r-24),i=Math.min(t.length,r+n.length+48);a=`${e>0?`…`:``}${t.slice(e,i).replace(/\s+/g,` `)}${i<t.length?`…`:``}`}if(o.length-e>40)break}}return i<=0?null:{score:i,snippet:a||r||e.id}}function Go(e,t,n){let r=String(t??``).trim();if(!r||!e?.sessions?.length)return[];let i=Math.min(Math.max(n?.limit??20,1),50),a=n?.includeArchived===!0,o=[];for(let t of e.sessions){if(t.deleted||t.archived&&!a)continue;let e=Wo(t,r);e&&o.push({sessionId:t.id,title:t.title||`新对话`,archived:!!t.archived,score:e.score,snippet:e.snippet,updatedAt:t.updatedAt})}return o.sort((e,t)=>t.score-e.score||t.updatedAt-e.updatedAt),o.slice(0,i)}async function Ko(e,t){let n=String(e??``).trim();if(!n)return{backend:`sqlite`,hits:[]};try{let e=new URLSearchParams({q:n,limit:String(t?.limit??20)});t?.includeArchived&&e.set(`archived`,`1`);let r=await fetch(`${Ho}?${e}`,{signal:AbortSignal.timeout(4e3)}),i=await r.json().catch(()=>null);return!r.ok||!i||!Array.isArray(i.hits)?null:{backend:i.backend||`sqlite`,hits:i.hits}}catch{return null}}var qo=`你可以使用工作区变更工具:
|
|
206
|
-
- workspace_changes_list:查看本会话内已记录的写文件/建目录
|
|
207
|
-
- workspace_changes_clear:清空本会话变更记录(不回滚磁盘文件)`,Jo=[{type:`function`,function:{name:`workspace_changes_list`,description:`List workspace file mutations recorded in this chat session (fs_write / fs_mkdir).`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`workspace_changes_clear`,description:`Clear the in-session workspace change log (does not delete files on disk).`,parameters:{type:`object`,properties:{}}}}];function Yo(e){return String(e??``).trim().replace(/\\/g,`/`).replace(/^\.\//,``)}function Xo(e,t){let n=Yo(t.path);if(!n)return Array.isArray(e)?[...e]:[];let r={path:n,op:t.op,at:t.at??Date.now()};return[...Array.isArray(e)?e.filter(e=>Yo(e.path)!==n):[],r].slice(-100)}function Zo(e,t){if(e!==`fs_write`&&e!==`fs_mkdir`)return null;try{let n=JSON.parse(t||`{}`);if(n.error||n.ok===!1)return null;let r=Yo(String(n.path??``));return r?{path:r,op:e===`fs_mkdir`?`mkdir`:`write`}:null}catch{return null}}function Qo(e,t){if(e===`workspace_changes_list`){let e=Array.isArray(t)?t:[];return{text:JSON.stringify({ok:!0,count:e.length,changes:e.map(e=>({path:e.path,op:e.op,at:new Date(e.at).toISOString()}))},null,2)}}return e===`workspace_changes_clear`?{text:JSON.stringify({ok:!0,cleared:!0,count:0}),next:[]}:{text:JSON.stringify({error:`unknown tool: ${e}`})}}var $o=6e5;function es(e){if(e==null||!Number.isFinite(e)||e<0)return`unavailable`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m${r}s`:`${n}m`;let i=Math.floor(n/60),a=n%60;return a?`${i}h${a}m`:`${i}h`}function ts(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`unavailable`}catch{return`unavailable`}}function ns(e,t){try{return`${new Intl.DateTimeFormat(`en-CA`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1,timeZoneName:`shortOffset`}).format(e).replace(`,`,``)} (${t})`}catch{return e.toISOString()}}function rs(e={}){let t=e.now??Date.now(),n=ts(),r=e.lastInjectAt??null;if(!(r==null||!Number.isFinite(r)||t-r>=6e5)&&r!=null)return{text:`【时间上下文 time-context】沿用上次采样(节流 ${$o/6e4} 分钟)。浏览器时区:${n}。解释未标注时区的日期时间时请使用该时区;若不确定请向用户确认。`,injected:!1,at:r};let i=e.lastUserMessageAt!=null&&Number.isFinite(e.lastUserMessageAt)?t-e.lastUserMessageAt:null;return{text:[`【时间上下文 time-context】`,`当前时间:${ns(new Date(t),n)}`,`浏览器时区:${n}`,`距上一轮用户消息:${es(i)}`,`解释未标注时区的日期时间时请使用上述时区;若时区信息混杂或缺失,请向用户确认。`].join(`
|
|
208
|
-
`),injected:!0,at:t}}var is=`会话交互工具(默认可用):
|
|
209
|
-
- todo_write:维护本会话完整待办列表(替换式写入);多步任务用它展示进度;允许多个 in_progress
|
|
210
|
-
- ask_user_question:向用户提出结构化问题并等待回答;缺信息或需确认时使用,勿空猜`,as={type:`function`,function:{name:`todo_write`,description:`Record and update a task list for multi-step work. Replace the complete list each call. Keep active work in_progress (several allowed in parallel). Mark completed as soon as done. Skip for trivial single-step tasks.`,parameters:{type:`object`,properties:{todos:{type:`array`,description:`The COMPLETE task list, replacing any previous list.`,items:{type:`object`,properties:{content:{type:`string`,description:`What the task is — a short imperative line.`},status:{type:`string`,enum:[`pending`,`in_progress`,`completed`],description:`pending | in_progress | completed`}},required:[`content`,`status`]}}},required:[`todos`]}}},os={type:`function`,function:{name:`ask_user_question`,description:`Ask the user a concise structured question when you need confirmation, a choice, or missing information before proceeding. Pauses until the user answers.`,parameters:{type:`object`,properties:{questions:{type:`array`,description:`Questions to ask the user before continuing.`,items:{type:`object`,properties:{id:{type:`string`,description:`Stable id; echoed in the answer.`},question:{type:`string`,description:`The specific question.`},header:{type:`string`,description:`Optional short heading.`},options:{type:`array`,items:{type:`object`,properties:{label:{type:`string`},description:{type:`string`}},required:[`label`]}},multi_select:{type:`boolean`,description:`Allow selecting more than one option. Default false.`}},required:[`id`,`question`]}}},required:[`questions`]}}};function ss(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=String(n.content??``).trim(),r=String(n.status??``);e&&(r===`pending`||r===`in_progress`||r===`completed`)&&t.push({content:e,status:r})}return t}function cs(e){let t={};try{t=JSON.parse(e||`{}`)}catch{return[]}if(!Array.isArray(t.questions))return[];let n=[];for(let e of t.questions){if(!e||typeof e!=`object`)continue;let t=String(e.id??``).trim(),r=String(e.question??``).trim();if(!t||!r)continue;let i=e.options,a=Array.isArray(i)?i.map(e=>({label:String(e?.label??``).trim(),description:e?.description?String(e.description):void 0})).filter(e=>e.label):void 0;n.push({id:t,question:r,header:e.header?String(e.header):void 0,options:a?.length?a:void 0,multi_select:!!e.multi_select})}return n}function ls(e,t){let n=e.options??[];if(!n.length)return null;let r=t.trim().split(/[,,、;;\s]+/).filter(Boolean);if(!r.length)return null;let i=[];for(let e of r){let t=Number(e.replace(/^第/,``).replace(/[.。)]$/,``));if(!Number.isInteger(t)||t<1||t>n.length)return null;let r=n[t-1]?.label;r&&!i.includes(r)&&i.push(r)}return!e.multi_select&&i.length>1?null:i.length?i:null}function us(e,t){let n=t??{selected:[],text:``};if(n.skipped)return{id:e.id,selected:[],skipped:!0};let r=n.text.trim();if(r){let t=e.options?.length?ls(e,r):null;return t?{id:e.id,selected:t}:{id:e.id,text:r}}return{id:e.id,selected:[...n.selected]}}function ds(e,t){return e.map((e,n)=>{let r=t[n],i=r?.skipped?`(跳过,未作答)`:r?.text?.trim()?r.text.trim():(r?.selected??[]).join(`、`)||`(跳过,未作答)`,a=e.header?`${e.header} / ${e.question}`:e.question;return`${n+1}. ${a}\n → ${i}`}).join(`
|
|
211
|
-
`)}var fs=`【计划模式 · 探查中】当前禁止写操作(不可 fs_write / bash / pwsh 等)。
|
|
212
|
-
- 先用只读工具(fs_list / fs_read / fs_glob / fs_grep / web_* / kb_*)探查
|
|
213
|
-
- 形成方案后调用 submit_plan,等待用户批准;未批准前不要声称已修改文件
|
|
214
|
-
- 可用 ask_user_question / todo_write 澄清与拆解`,ps=`【计划模式 · 已批准】用户已批准方案,可以按批准内容实施(写文件 / 执行命令)。
|
|
215
|
-
- 实施中若需大幅变更方案,再次 submit_plan 征求批准
|
|
216
|
-
- 仍优先小步、可回滚的改动`,ms={type:`function`,function:{name:`submit_plan`,description:`Submit an implementation plan for user approval (plan mode). Blocks until the user approves or rejects.`,parameters:{type:`object`,properties:{title:{type:`string`,description:`Short plan title`},summary:{type:`string`,description:`What will change and why`},steps:{type:`array`,items:{type:`string`},description:`Ordered implementation steps`}},required:[`title`,`steps`]}}};function hs(e){try{let t=JSON.parse(e||`{}`),n=String(t.title??``).trim(),r=String(t.summary??``).trim(),i=Array.isArray(t.steps)?t.steps.map(e=>String(e??``).trim()).filter(Boolean):[];return!n||!i.length?null:{title:n,summary:r,steps:i.slice(0,24)}}catch{return null}}var gs=8e4,_s=.28;function vs(e){return(e.content?.length??0)+(e.reasoning?.length??0)}function ys(e){return e.reduce((e,t)=>e+vs(t),0)}function bs(e){let t=e?oe[e]:void 0;return t&&t>0?Math.max(24e3,Math.floor(t*4*_s)):gs}function xs(e,t){return ys(e)>=bs(t)}function Ss(e){return e.map(e=>{let t=e.role===`user`?`User`:`Assistant`,n=(e.content||``).trim(),r=e.reasoning?.trim()?`\n[thinking]\n${e.reasoning.trim().slice(0,1200)}`:``;return`${t}:\n${n.slice(0,6e3)}${r}`}).join(`
|
|
217
|
-
|
|
218
|
-
---
|
|
219
|
-
|
|
220
|
-
`).slice(0,6e4)}async function Cs(e,t,n){let r=Ss(t);if(!r.trim())return``;let i=[{role:`system`,content:`你是会话压缩助手。将对话历史压缩为简洁中文摘要,保留:目标、关键决策、文件路径、未完成事项、约束。不要编造;不要输出寒暄;用条目或短段落,控制在 800 字以内。`},{role:`user`,content:`请压缩下列对话历史:\n\n${r}`}];return(await ie(e,i,n)).trim()||`(摘要为空)`}async function ws(e,t,n){let r=Math.max(2,n?.keepRecent??8);if(t.length<=r+1||!n?.force&&!xs(t,e.model))return{messages:t,summary:``,compacted:!1};let i=t.slice(0,-r),a=t.slice(-r),o=await Cs(e,i,n?.signal);return{messages:[{role:`user`,content:`【会话摘要 · 较早消息已压缩】\n${o}`},{role:`assistant`,content:`已记录摘要。后续回复将基于摘要与最近对话继续。`},...a],summary:o,compacted:!0}}function Ts(e){return/^\/compact(?:\s|$)/i.test(e.trim())}var Es=`你可以使用会话目标工具:
|
|
221
|
-
- goal_get:读取本会话当前目标
|
|
222
|
-
- goal_set:设定或更新目标(status=active)
|
|
223
|
-
- goal_done:将目标标为已完成
|
|
224
|
-
- goal_clear:清除目标
|
|
225
|
-
有活跃目标时应围绕其推进;重大偏离前用 ask_user_question 或更新目标。
|
|
226
|
-
系统可能在目标未完成时自动续轮(goal-round-driver);完成后务必 goal_done,避免空转。`,Ds=[{type:`function`,function:{name:`goal_get`,description:`Get the current session goal (text + status).`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`goal_set`,description:`Set or replace the session goal. Marks it active.`,parameters:{type:`object`,properties:{text:{type:`string`,description:`Goal statement for this session`}},required:[`text`]}}},{type:`function`,function:{name:`goal_done`,description:`Mark the current session goal as done.`,parameters:{type:`object`,properties:{}}}},{type:`function`,function:{name:`goal_clear`,description:`Clear the session goal.`,parameters:{type:`object`,properties:{}}}}];function Os(e){if(!e||typeof e!=`object`)return null;let t=e,n=String(t.text??``).trim();if(!n)return null;let r=t.status===`done`||t.status===`cleared`||t.status===`active`?t.status:`active`;return{text:n.slice(0,500),status:r,updatedAt:typeof t.updatedAt==`number`?t.updatedAt:Date.now()}}function ks(e){return!e||e.status===`cleared`||!e.text?JSON.stringify({ok:!0,goal:null}):JSON.stringify({ok:!0,goal:{text:e.text,status:e.status}})}function As(e){return!e||e.status!==`active`?null:e.text.trim()||null}function js(e){let t=e.trim();if(!/^\/goal(?:\s|$)/i.test(t))return null;let n=t.replace(/^\/goal\s*/i,``).trim();if(!n)return{kind:`show`};if(/^clear\b/i.test(n))return{kind:`clear`};if(/^done\b/i.test(n))return{kind:`done`};if(/^set\s+/i.test(n)){let e=n.replace(/^set\s+/i,``).trim();return e?{kind:`set`,text:e}:{kind:`show`}}return{kind:`set`,text:n}}function Ms(e){return js(e)!=null}var Ns=`[goal-round-driver]`;function Ps(e,t,n){return`${Ns} 续轮 ${t}/${n}:请继续推进目标「${e.trim().slice(0,200)}」。若已完成请调用 goal_done;若阻塞请说明原因或 ask_user_question,勿空转重复相同工具。`}function Fs(e){return e.trimStart().startsWith(Ns)}function Is(e){let t=Math.max(1,Math.floor(e.maxRounds??3));return!(!e.goalActive||!e.turnOk||e.aborted||e.hasFollowUp||e.askUserPending||e.roundsUsed>=t)}function Ls(e){return e.trim().replace(/[\\/:*?"<>|]+/g,`_`).replace(/\s+/g,` `).slice(0,48)||`session`}function Rs(e){if(!e||typeof e!=`object`)return{raw:e};let t=e,n={role:t.role,content:(t.content,t.content)};return typeof t.reasoning==`string`&&t.reasoning&&(n.reasoning=t.reasoning),typeof t.time==`number`&&(n.time=t.time),typeof t.model==`string`&&(n.model=t.model),t.usage&&typeof t.usage==`object`&&(n.usage=t.usage),typeof t.scheduleId==`string`&&(n.scheduleId=t.scheduleId),Array.isArray(t.attachments)&&(n.attachments=t.attachments.map(e=>{if(!e||typeof e!=`object`)return e;let t=e;return{name:t.name,size:t.size,type:t.type}})),Array.isArray(t.images)&&(n.images=t.images.map(e=>{if(!e||typeof e!=`object`)return e;let t=e;return{id:t.id,name:t.name,omittedDataUrl:!0}})),Array.isArray(t.refs)&&(n.refs=t.refs),n}var zs=`lantern-harness-session-v1`;function Bs(e){return{exportedAt:new Date().toISOString(),format:zs,session:{id:e.id,title:e.title,createdAt:e.createdAt,updatedAt:e.updatedAt,archived:e.archived,pinned:e.pinned,workspacePath:e.workspacePath,goal:e.goal,todos:e.todos,messages:(e.messages??[]).map(Rs)}}}function Vs(e){return`${JSON.stringify(Bs(e),null,2)}\n`}function Hs(e){let t=[];t.push(JSON.stringify({type:`session`,exportedAt:new Date().toISOString(),id:e.id,title:e.title,createdAt:e.createdAt,updatedAt:e.updatedAt,workspacePath:e.workspacePath,goal:e.goal}));for(let n of e.messages??[])t.push(JSON.stringify({type:`message`,sessionId:e.id,...Rs(n)}));return`${t.join(`
|
|
227
|
-
`)}\n`}function Us(e,t,n){let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.rel=`noopener`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function Ws(e,t=`json`){if(typeof document>`u`)return{ok:!1,error:`download requires browser`};let n=new Date().toISOString().replace(/[:.]/g,`-`).slice(0,19),r=`session-${Ls(e.title)}-${n}`;if(t===`jsonl`){let t=`${r}.jsonl`;return Us(t,Hs(e),`application/x-ndjson;charset=utf-8`),{ok:!0,filename:t}}let i=`${r}.json`;return Us(i,Vs(e),`application/json;charset=utf-8`),{ok:!0,filename:i}}var Gs=`tw-session-schedules`,Ks=`/__tb_schedule`,qs=`你可以使用定时提醒工具:
|
|
228
|
-
- schedule_create:创建提醒(text + dueAt ISO 或 delayMinutes)
|
|
229
|
-
- schedule_list:列出本会话未取消的提醒
|
|
230
|
-
- schedule_update:修改 text / dueAt
|
|
231
|
-
- schedule_cancel:取消提醒
|
|
232
|
-
本地服务在线时提醒落盘并由主机到点写入原会话;否则仅页面打开时投递。`,Js=[{type:`function`,function:{name:`schedule_create`,description:`Create a session reminder. Provide dueAt (ISO datetime) or delayMinutes from now.`,parameters:{type:`object`,properties:{text:{type:`string`,description:`Reminder content`},dueAt:{type:`string`,description:`ISO 8601 datetime`},delayMinutes:{type:`number`,description:`Minutes from now (alternative to dueAt)`}},required:[`text`]}}},{type:`function`,function:{name:`schedule_list`,description:`List scheduled reminders for the current session.`,parameters:{type:`object`,properties:{includeDelivered:{type:`boolean`}}}}},{type:`function`,function:{name:`schedule_update`,description:`Update a scheduled reminder text and/or dueAt.`,parameters:{type:`object`,properties:{id:{type:`string`},text:{type:`string`},dueAt:{type:`string`},delayMinutes:{type:`number`}},required:[`id`]}}},{type:`function`,function:{name:`schedule_cancel`,description:`Cancel a scheduled reminder.`,parameters:{type:`object`,properties:{id:{type:`string`}},required:[`id`]}}}];function Ys(){return`sch_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}var Xs=null;async function Zs(){try{let e=await fetch(`${Ks}/health`,{signal:AbortSignal.timeout(1500)});return e.ok?(Xs=!!(await e.json()).ok,Xs):(Xs=!1,!1)}catch{return Xs=!1,!1}}function Qs(){try{let e=localStorage.getItem(l(Gs));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.map(e=>ec(e)).filter(e=>!!e):[]}catch{return[]}}function $s(e){localStorage.setItem(l(Gs),JSON.stringify(e.slice(-200)))}function ec(e){if(!e||typeof e!=`object`)return null;let t=e,n=String(t.id??``).trim(),r=String(t.sessionId??``).trim(),i=String(t.text??``).trim(),a=Number(t.dueAt);if(!n||!r||!i||!Number.isFinite(a))return null;let o=t.status===`delivered`||t.status===`cancelled`||t.status===`scheduled`?t.status:`scheduled`;return{id:n,sessionId:r,text:i.slice(0,500),dueAt:a,status:o,createdAt:Number(t.createdAt)||Date.now(),updatedAt:Number(t.updatedAt)||Date.now()}}function tc(e){if(typeof e.delayMinutes==`number`&&Number.isFinite(e.delayMinutes)){let t=Math.max(.1,e.delayMinutes);return Date.now()+Math.round(t*6e4)}let t=String(e.dueAt??``).trim();if(!t)return null;let n=Date.parse(t);return Number.isFinite(n)?n:null}function nc(e,t=!1){return Qs().filter(t=>t.sessionId===e).filter(e=>t||e.status===`scheduled`).sort((e,t)=>e.dueAt-t.dueAt)}function rc(e,t){let n=String(t.text??``).trim();if(!n)return{ok:!1,error:`text is required`};if(!e)return{ok:!1,error:`no active session`};let r=tc(t);if(r==null)return{ok:!1,error:`dueAt or delayMinutes is required`};if(r<Date.now()-5e3)return{ok:!1,error:`dueAt is in the past`};let i=Date.now(),a={id:Ys(),sessionId:e,text:n.slice(0,500),dueAt:r,status:`scheduled`,createdAt:i,updatedAt:i},o=Qs();return o.push(a),$s(o),{ok:!0,reminder:a}}function ic(e,t){let n=String(t.id??``).trim();if(!n)return{ok:!1,error:`id is required`};let r=Qs(),i=r.findIndex(t=>t.id===n&&t.sessionId===e);if(i<0)return{ok:!1,error:`reminder not found`};let a=r[i];if(a.status!==`scheduled`)return{ok:!1,error:`cannot update status=${a.status}`};let o=a.dueAt;if(t.dueAt!=null||t.delayMinutes!=null){let e=tc(t);if(e==null)return{ok:!1,error:`invalid dueAt / delayMinutes`};o=e}let s=t.text==null?a.text:String(t.text).trim();if(!s)return{ok:!1,error:`text cannot be empty`};let c={...a,text:s.slice(0,500),dueAt:o,updatedAt:Date.now()};return r[i]=c,$s(r),{ok:!0,reminder:c}}function ac(e,t){let n=String(t??``).trim();if(!n)return{ok:!1,error:`id is required`};let r=Qs(),i=r.findIndex(t=>t.id===n&&t.sessionId===e);if(i<0)return{ok:!1,error:`reminder not found`};let a={...r[i],status:`cancelled`,updatedAt:Date.now()};return r[i]=a,$s(r),{ok:!0,reminder:a}}function oc(e=Date.now()){let t=Qs(),n=[],r=!1;for(let i=0;i<t.length;i++){let a=t[i];if(a.status===`scheduled`&&a.dueAt<=e){let o={...a,status:`delivered`,updatedAt:e};t[i]=o,n.push(o),r=!0}}return r&&$s(t),n}function sc(e,t){return`⏰ 定时提醒:${e}\n<!--tb-schedule:${t}-->`}async function cc(e,t){try{let n=await fetch(`${Ks}${e}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t),signal:AbortSignal.timeout(8e3)});return n.ok?await n.json():null}catch{return null}}async function lc(){if(Xs!==!1){let e=await cc(`/claim`,{});if(e&&e.ok)return Xs=!0,Array.isArray(e.reminders)?e.reminders.map(ec).filter(e=>!!e):[];if(Xs===!0)return oc();if(await Zs(),Xs){let e=await cc(`/claim`,{});if(e&&e.ok&&Array.isArray(e.reminders))return e.reminders.map(ec).filter(e=>!!e)}}return oc()}async function uc(e,t,n){let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({error:`invalid JSON arguments`})}if(Xs??await Zs()){if(e===`schedule_create`){let e=await cc(`/create`,{...r,sessionId:n});if(e)return JSON.stringify(e,null,2)}else if(e===`schedule_list`)try{let e=new URLSearchParams({sessionId:n,includeDelivered:r.includeDelivered?`1`:`0`}),t=await fetch(`${Ks}/list?${e}`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return JSON.stringify(await t.json(),null,2)}catch{}else if(e===`schedule_update`){let e=await cc(`/update`,{...r,sessionId:n});if(e)return JSON.stringify(e,null,2)}else if(e===`schedule_cancel`){let e=await cc(`/cancel`,{id:r.id,sessionId:n});if(e)return JSON.stringify(e,null,2)}else return JSON.stringify({error:`unknown tool: ${e}`});Xs=!1}if(e===`schedule_create`)return JSON.stringify(rc(n,r),null,2);if(e===`schedule_list`){let e=nc(n,!!r.includeDelivered);return JSON.stringify({ok:!0,count:e.length,reminders:e},null,2)}return e===`schedule_update`?JSON.stringify(ic(n,r),null,2):e===`schedule_cancel`?JSON.stringify(ac(n,r.id),null,2):JSON.stringify({error:`unknown tool: ${e}`})}var dc=[{id:`explore`,label:`探索`,description:`只读查文件 / 搜网页,汇总结论(不可写盘、无 bash)`,mode:`explore`},{id:`general`,label:`通用`,description:`可读写工作区文件 + 网页(无 bash、不可再派生子代理)`,mode:`general`}],fc=`你可以使用子代理工具(进程内;默认与主会话同模型,可在设置里改子代理模型):
|
|
233
|
-
- list_agents:列出可用预设与正在运行/最近完成的子代理
|
|
234
|
-
- spawn_subagent:派生子代理执行独立任务(默认等待完成;background=true 则后台跑)
|
|
235
|
-
- fork_subagent:带着当前对话上下文 fork 子代理并行干活
|
|
236
|
-
- subagent_list / subagent_await / subagent_abort:查看、等待、中断
|
|
237
|
-
适合可隔离的探索/子任务;主会话勿把全部工作塞给子代理。`,pc=[{type:`function`,function:{name:`list_agents`,description:`List available subagent presets and recent/running subagents.`,parameters:{type:`object`,properties:{includeRecent:{type:`boolean`,description:`Include recent finished agents (default true)`}}}}},{type:`function`,function:{name:`spawn_subagent`,description:`Spawn a subagent to run a focused task. Default waits until done and returns the result.`,parameters:{type:`object`,properties:{agent:{type:`string`,description:`Preset id: explore | general (default explore)`},prompt:{type:`string`,description:`Task for the subagent`},background:{type:`boolean`,description:`If true, return id immediately; use subagent_await later`}},required:[`prompt`]}}},{type:`function`,function:{name:`fork_subagent`,description:`Fork a subagent with a slice of the current conversation context, then run a task.`,parameters:{type:`object`,properties:{agent:{type:`string`,description:`Preset id: explore | general`},prompt:{type:`string`,description:`Task for the forked subagent`},background:{type:`boolean`}},required:[`prompt`]}}},{type:`function`,function:{name:`subagent_list`,description:`List running and recent subagents for this page session.`,parameters:{type:`object`,properties:{includeDone:{type:`boolean`}}}}},{type:`function`,function:{name:`subagent_await`,description:`Wait for a background subagent to finish and return its result.`,parameters:{type:`object`,properties:{id:{type:`string`},timeoutMs:{type:`number`,description:`Default 120000`}},required:[`id`]}}},{type:`function`,function:{name:`subagent_abort`,description:`Abort a running subagent.`,parameters:{type:`object`,properties:{id:{type:`string`}},required:[`id`]}}}],mc=2,hc=6,gc=24,_c=12e3,vc=new Map,yc=new Map,bc=new Map;function xc(){return`sa_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Sc(e){let t=String(e??`explore`).trim()||`explore`;return dc.find(e=>e.id===t)??dc[0]}function Cc(){let e=0;for(let t of vc.values())t.status===`running`&&e++;return e}function wc(){if(vc.size<=gc)return;let e=[...vc.values()].sort((e,t)=>e.updatedAt-t.updatedAt);for(let t of e){if(vc.size<=gc)break;t.status!==`running`&&(vc.delete(t.id),yc.delete(t.id),bc.delete(t.id))}}function Tc(e){return{id:e.id,agent:e.agent,prompt:e.prompt.slice(0,200),forked:e.forked,status:e.status,createdAt:e.createdAt,updatedAt:e.updatedAt,result:e.result,error:e.error,toolCalls:e.toolCalls}}function Ec(e,t){return e.mode===`explore`?`readonly`:t===`full`?`readwrite`:t}async function Dc(e,t,n,r){let i=new AbortController;yc.set(e.id,i);let a=()=>i.abort();n.parentSignal?.addEventListener(`abort`,a);let o=0;try{if(i.signal.aborted||n.parentSignal?.aborted)throw new DOMException(`Aborted`,`AbortError`);let a=Ec(t,n.access),s=[],c=`你是 Lantern Harness 子代理「${t.id}」(${t.label})。\n任务:独立完成用户交给你的子任务,给出简洁可核对的结论。\n- 不要声称自己是主会话;不要尝试再派生子代理或执行 shell\n- 工具轮次有限,优先检索再结论`;n.fsEnabled&&(s.push(..._t(a)),c+=`\n\n${Ot}`),n.webEnabled&&(s.push(...gt),c+=`\n\n${pt}`),s.length||(c+=`
|
|
238
|
-
(当前无 fs/web 工具,仅凭已有上下文回答。)`);let l=[{role:`system`,content:c}];if(r&&n.parentMessages?.length){let e=n.parentMessages.filter(e=>e.role===`user`||e.role===`assistant`).slice(-12).map(e=>({role:e.role,content:typeof e.content==`string`?e.content.slice(0,4e3):JSON.stringify(e.content).slice(0,4e3)}));l.push(...e)}l.push({role:`user`,content:`【子代理任务】\n${e.prompt}`}),n.onHint?.(`子代理 ${e.id}(${t.id})运行中…`);let u=``;for await(let t of ae(n.settings,l,i.signal,{tools:s.length?s:void 0,maxToolRounds:4,thinking:!1,runTool:s.length?async(t,r)=>(o++,n.onHint?.(`子代理 ${e.id}: ${t}`),t.startsWith(`fs_`)?n.runFs(t,r,a):t.startsWith(`web_`)?n.runWeb(t,r):JSON.stringify({error:`subagent cannot use tool: ${t}`})):void 0}))t.type===`content`&&(u+=t.delta);let d=u.trim().slice(0,_c);e.status=`done`,e.result=d||`(子代理无文本输出)`,e.toolCalls=o,e.updatedAt=Date.now()}catch(t){let r=t instanceof DOMException&&t.name===`AbortError`||i.signal.aborted||!!n.parentSignal?.aborted;e.status=r?`aborted`:`error`,e.error=r?`aborted`:t instanceof Error?t.message:String(t),e.toolCalls=o,e.updatedAt=Date.now()}finally{n.parentSignal?.removeEventListener(`abort`,a),yc.delete(e.id),wc()}}function Oc(e,t,n,r,i){if(!e)return{ok:!1,error:`prompt is required`};if(Cc()>=i)return{ok:!1,error:`too many running subagents (max ${i})`};let a=Sc(t),o=Date.now(),s={id:xc(),agent:a.id,prompt:e.slice(0,4e3),forked:r,status:`running`,createdAt:o,updatedAt:o};vc.set(s.id,s);let c=Dc(s,a,n,r).then(()=>s);return bc.set(s.id,c),{ok:!0,rec:s,job:c}}function kc(e,t,n){let r=Oc(String(e.prompt??``).trim(),e.agent,t,n,mc);return r.ok?e.background===!0?(r.job.finally(()=>{}),JSON.stringify({ok:!0,id:r.rec.id,agent:r.rec.agent,status:`running`,forked:n,hint:`Use subagent_await to get the result`})):r.job.then(e=>JSON.stringify({ok:e.status===`done`,id:e.id,agent:e.agent,status:e.status,forked:e.forked,toolCalls:e.toolCalls??0,result:e.result,error:e.error},null,2)):JSON.stringify({ok:!1,error:r.error})}async function Ac(e,t,n){let r=Oc(e.trim(),n?.agent??`explore`,t,!!n?.forked,hc);if(!r.ok)return{ok:!1,id:``,text:null,error:r.error};let i=await r.job;return i.status===`done`?{ok:!0,id:i.id,text:i.result??null}:{ok:!1,id:i.id,text:null,error:i.error??i.status}}function jc(e=!0){return[...vc.values()].filter(t=>e||t.status===`running`).sort((e,t)=>t.updatedAt-e.updatedAt).map(Tc)}function Mc(e){let t=String(e??``).trim();if(!t)return{ok:!1,error:`id is required`};let n=vc.get(t);return n?n.status===`running`?(yc.get(t)?.abort(),{ok:!0,record:{...Tc(n),status:`aborted`}}):{ok:!0,record:Tc(n)}:{ok:!1,error:`subagent not found`}}async function Nc(e,t){let n=String(e??``).trim();if(!n)return JSON.stringify({ok:!1,error:`id is required`});let r=typeof t==`number`&&Number.isFinite(t)?Math.min(Math.max(1e3,t),3e5):12e4,i=vc.get(n);if(!i)return JSON.stringify({ok:!1,error:`subagent not found`});if(i.status!==`running`)return JSON.stringify({ok:i.status===`done`,...Tc(i)},null,2);let a=bc.get(n);if(!a)return JSON.stringify({ok:!1,error:`subagent waiter missing`});let o=await Promise.race([a,new Promise(e=>{setTimeout(()=>e(null),r)})]);return o?JSON.stringify({ok:o.status===`done`,...Tc(o)},null,2):JSON.stringify({ok:!1,id:n,status:`running`,error:`timeout after ${r}ms`})}async function Pc(e,t,n){let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({error:`invalid JSON arguments`})}if(e===`list_agents`){let e=r.includeRecent!==!1;return JSON.stringify({ok:!0,presets:dc,agents:jc(e),running:Cc(),maxConcurrent:mc},null,2)}return e===`subagent_list`?JSON.stringify({ok:!0,agents:jc(r.includeDone!==!1),running:Cc()},null,2):e===`subagent_abort`?JSON.stringify(Mc(r.id),null,2):e===`subagent_await`?await Nc(r.id,r.timeoutMs):e===`spawn_subagent`?await Promise.resolve(kc(r,n,!1)):e===`fork_subagent`?await Promise.resolve(kc(r,n,!0)):JSON.stringify({error:`unknown tool: ${e}`})}var Fc=4e4,Ic=5e4,Lc=12,Rc=4,zc=80,Bc=`你可以使用 workflow 工具(仅当用户明确要求工作流 / 大规模多代理编排时):
|
|
239
|
-
- 参数:meta{name,description,phases?}、script(纯 JS 函数体,可用 top-level await)、args?
|
|
240
|
-
- 脚本内钩子:agent(prompt, opts?)、parallel(fns)、pipeline(fns)、phase(name)、log(...)
|
|
241
|
-
- agent() 返回子代理结论文本,失败返回 null
|
|
242
|
-
- 一两个子任务请用 spawn_subagent / fork_subagent,勿滥用 workflow`,Vc=[{type:`function`,function:{name:`workflow`,description:`Run a JavaScript orchestration script that fans out subagents and returns a JSON value. Use ONLY when the user explicitly asks for a workflow or large multi-agent orchestration. Script body may use top-level await and helpers: agent, parallel, pipeline, phase, log. Example body: const xs = await parallel([() => agent("task A"), () => agent("task B")]); return xs.filter(Boolean);`,parameters:{type:`object`,properties:{meta:{type:`object`,description:`Workflow identity`,properties:{name:{type:`string`},description:{type:`string`},phases:{type:`array`,items:{type:`string`}}},required:[`name`,`description`]},script:{type:`string`,description:`Plain JavaScript body (no export). Globals: args, agent, parallel, pipeline, phase, log.`},args:{type:`object`,description:`JSON object exposed to the script as args (wrap arrays in a field)`}},required:[`meta`,`script`]}}}];function Hc(){return`wf_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Uc(e){if(!e||typeof e!=`object`)return{error:`meta is required`};let t=e,n=String(t.name??``).trim(),r=String(t.description??``).trim();if(!n)return{error:`meta.name is required`};if(!r)return{error:`meta.description is required`};let i=Array.isArray(t.phases)?t.phases.map(e=>String(e).trim()).filter(Boolean).slice(0,20):void 0;return{name:n.slice(0,80),description:r.slice(0,400),phases:i}}function Wc(e){return/\brequire\b|\bprocess\.|\bchild_process\b|\bfs\.|\bglobalThis\b|\bFunction\s*\(|\beval\s*\(|\bimport\s*\(|\bXMLHttpRequest\b|\blocalStorage\b|\bindexedDB\b|\bdocument\.|\bwindow\./.test(e)?`script uses disallowed APIs (browser/Node escape)`:null}async function Gc(e,t,n,r){let i=Array(e.length),a=0;async function o(){for(;a<e.length;){if(r?.aborted)throw new DOMException(`Aborted`,`AbortError`);let t=a++;i[t]=await n(e[t],t)}}let s=Math.min(Math.max(1,t),e.length||1);return await Promise.all(Array.from({length:s},()=>o())),i}async function Kc(e,t,n,r){let i=Hc(),a=[],o=[],s=0,c=Lc,l=(...t)=>{let n=t.map(e=>{if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `);a.push(n.slice(0,500)),a.length>zc&&a.splice(0,a.length-zc),r.onHint?.(`workflow ${e.name}: ${n.slice(0,80)}`)},u=async(e,t)=>{if(r.parentSignal?.aborted)throw new DOMException(`Aborted`,`AbortError`);let n=String(e??``).trim();if(!n)return null;if(c<=0)return l(`agent budget exhausted`),null;c--,s++;let i=t?.label?` [${t.label}]`:``;l(`agent${i}: ${n.slice(0,120)}`);let a=await Ac(n,r,{agent:t?.agent??`explore`,forked:!1});return a.ok?a.text:(l(`agent failed${i}: ${a.error??`error`}`),null)},d=async(e,t=Rc)=>{if(!Array.isArray(e))throw Error(`parallel() expects an array of functions`);return Gc(e.slice(0,Lc),Math.min(Rc,t||Rc),async e=>{if(typeof e!=`function`)return null;try{return await e()}catch(e){return l(`parallel task error`,e instanceof Error?e.message:String(e)),null}},r.parentSignal)},f=async e=>{if(!Array.isArray(e))throw Error(`pipeline() expects an array of functions`);let t=[];for(let n of e.slice(0,Lc)){if(r.parentSignal?.aborted)throw new DOMException(`Aborted`,`AbortError`);if(typeof n!=`function`)t.push(null);else try{t.push(await n())}catch(e){l(`pipeline task error`,e instanceof Error?e.message:String(e)),t.push(null)}}return t},p=t=>{let n=String(t??``).trim()||`phase`;o.push(n.slice(0,80)),l(`phase: ${n}`),r.onHint?.(`workflow ${e.name} · ${n}`)},m=(...e)=>l(...e),h=Wc(t);if(h)return{ok:!1,kind:`foreground`,runId:i,name:e.name,agentsStarted:0,stopReason:`error`,error:h};if(t.length>Fc)return{ok:!1,kind:`foreground`,runId:i,name:e.name,agentsStarted:0,stopReason:`error`,error:`script too long (max ${Fc})`};try{let c=Object.getPrototypeOf(async function(){}).constructor,l=await new c(`args`,`agent`,`parallel`,`pipeline`,`phase`,`log`,`"use strict";\n${t}`)(n,u,d,f,p,m);if(r.parentSignal?.aborted)return{ok:!1,kind:`foreground`,runId:i,name:e.name,agentsStarted:s,stopReason:`cancelled`,error:`workflow run was cancelled`,logs:a,phases:o};let h=l===void 0?null:l;try{let e=JSON.stringify(h);h=e&&e.length>Ic?{truncated:!0,preview:e.slice(0,Ic)}:e===void 0?null:JSON.parse(e)}catch{h=String(h).slice(0,Ic)}return{ok:!0,kind:`foreground`,runId:i,name:e.name,agentsStarted:s,result:h,stopReason:`completed`,logs:a,phases:o}}catch(t){let n=t instanceof DOMException&&t.name===`AbortError`||!!r.parentSignal?.aborted;return{ok:!1,kind:`foreground`,runId:i,name:e.name,agentsStarted:s,stopReason:n?`cancelled`:`error`,error:n?`workflow run was cancelled`:t instanceof Error?t.message:String(t),logs:a,phases:o}}}async function qc(e,t,n){if(e!==`workflow`)return JSON.stringify({error:`unknown tool: ${e}`});let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({error:`invalid JSON arguments`})}let i=Uc(r.meta);if(`error`in i)return JSON.stringify({ok:!1,error:i.error});let a=String(r.script??``);if(!a.trim())return JSON.stringify({ok:!1,error:`script is required`});let o=r.args&&typeof r.args==`object`&&!Array.isArray(r.args)?r.args:{};n.onHint?.(`workflow "${i.name}" 启动…`);let s=await Kc(i,a,o,n);return s.ok?[`workflow "${s.name}" completed (${s.agentsStarted} agent${s.agentsStarted===1?``:`s`}).`,`Return value:`,JSON.stringify(s.result,null,2)].join(`
|
|
243
|
-
`):s.stopReason===`cancelled`?`Error: workflow run was cancelled${s.error&&s.error!==`workflow run was cancelled`?` (${s.error})`:``}`:`Error: workflow run failed: ${s.error??`unknown`}`}function Jc(e){return e===`md`?`Markdown`:e===`xlsx`||e===`xls`?`Excel`:e===`docx`||e===`doc`?`Word`:e===`dir`?`文件夹`:e===`file`?`文件`:e.toUpperCase()}function Yc(e,t){return!(t&&![e.title,e.category,e.id,e.description,e.path,e.format,Jc(e.format)].join(`
|
|
244
|
-
`).toLowerCase().includes(t)&&(t!==`excel`&&t!==`表格`&&t!==`xls`||e.format!==`xlsx`&&e.format!==`xls`)&&(t!==`word`&&t!==`文档`&&t!==`doc`||e.format!==`docx`&&e.format!==`doc`)&&(t!==`md`&&t!==`markdown`&&t!==`标记`||e.format!==`md`))}var Xc=`用户可能通过「@」引用了知识库与模板下的 Markdown / Excel / Word 等文档(消息中会列出路径)。仅当用户引用了文档,或问题明显依赖知识库/模板时,再调用 kb_read / kb_search;一般闲聊或无关问题不要为了凑答去检索。读取时:Markdown 为全文,Excel/Word 为字段或元数据摘要;不要臆造未读到的正文。`,Zc=[{type:`function`,function:{name:`kb_search`,description:`在知识库与模板(含 Markdown、Excel、Word)中按关键词搜索,返回 path、标题、格式与摘要。`,parameters:{type:`object`,properties:{query:{type:`string`,description:`搜索关键词,如 接口、excel、用例`},scope:{type:`string`,enum:[`all`,`knowledge`,`templates`],description:`限定范围,默认 all`}},required:[`query`]}}},{type:`function`,function:{name:`kb_read`,description:`按 path 读取文档。Markdown 返回全文;Excel/Word 返回构建期摘要。path 如 测试模板库/接口测试用例/接口测试用例模版.xlsx 或 知识库管理/xxx.md`,parameters:{type:`object`,properties:{path:{type:`string`,description:`相对路径(与引用列表中的 path 一致)`}},required:[`path`]}}}];function Qc(e){return e.trim().replace(/^\/+/,``).replace(/\\/g,`/`)}function $c(e,t){let n=Qc(t),r=n.replace(/\.md$/i,``);return e.find(e=>{let t=Qc(e.path);return t===n||t===`${r}.md`||`${e.collection}/${e.id}`===n||`${e.collection}/${e.id}.md`===n||e.id===n||e.id===r})}async function el(e,t,n){let r={};try{r=JSON.parse(t||`{}`)}catch{return JSON.stringify({error:`invalid JSON arguments`})}let i=typeof n.base==`string`&&n.base?n.base:`/`,a=i.endsWith(`/`)?i:`${i}/`;try{switch(e){case`kb_search`:{let e=String(r.query??``).trim().toLowerCase(),t=String(r.scope??`all`);if(!e)return JSON.stringify({error:`query required`,results:[]});let i=n.docs.filter(e=>t===`all`||e.collection===t).filter(t=>Yc(t,e)).slice(0,12).map(e=>({path:e.path,title:e.title,category:e.category,collection:e.collection,format:e.format,snippet:e.description||e.category}));return JSON.stringify({results:i,count:i.length})}case`kb_read`:{let e=$c(n.docs,String(r.path??``));if(!e)return JSON.stringify({error:`未找到文档;请使用 kb_search 返回的 path`,path:String(r.path??``)});if(e.attachText)return JSON.stringify({path:e.path,title:e.title,category:e.category,format:e.format,content:e.attachText,note:`Office 模板返回构建期摘要,非完整二进制内容`});let t=`${a}raw/${e.collection}/${e.id}.md`,i=await fetch(t);if(!i.ok)return JSON.stringify({error:`读取失败 HTTP ${i.status}`,path:e.path});let o=await i.text();return JSON.stringify({path:e.path,title:e.title,category:e.category,format:e.format,content:o})}default:return JSON.stringify({error:`unknown tool: ${e}`})}}catch(e){return JSON.stringify({error:e instanceof Error?e.message:String(e)})}}var tl=10485760,nl=new Set([`png`,`jpg`,`jpeg`,`webp`,`gif`]),rl=new Set([`xlsx`,`xls`,`xlsm`,`xlsb`,`ods`]),il=new Set([`docx`]),al=new Set(`md.markdown.txt.text.json.csv.tsv.yaml.yml.xml.html.htm.log.sql.feature.toml.ini.conf.properties.rst.css.js.ts.tsx.jsx.py.java.go.rs.sh.bash.zsh.env.gitignore.dockerfile.makefile.svg`.split(`.`)),ol=[...al,...nl,...rl,...il,`doc`,`pdf`];function sl(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t+1).toLowerCase():``}async function cl(e){let t=await e.arrayBuffer(),n=S(t,{type:`array`}),r=[`# ${e.name}`,`工作表数:${n.SheetNames.length}`,``];for(let e of n.SheetNames){let t=n.Sheets[e];if(!t)continue;let i=C.sheet_to_csv(t);r.push(`## ${e}`,i.trim()||`(空表)`,``)}return r.join(`
|
|
245
|
-
`).trim()}async function ll(t){let n=await Se(()=>import(`./lib.DJNDi_Ht.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1,2,3])),r=await t.arrayBuffer(),i=await n.extractRawText({arrayBuffer:r}),a=(i.value??``).trim(),o=[`# ${t.name}`,``];return i.messages?.length&&o.push(`(解析备注:${i.messages.slice(0,3).map(e=>e.message).join(`;`)})`,``),o.push(a||`(未提取到正文)`),o.join(`
|
|
246
|
-
`)}async function ul(e){let t=sl(e.name);if(!t)throw Error(`${e.name}:无法识别扩展名`);if(e.size>10485760)throw Error(`${e.name}:超过 ${Math.round(tl/1024/1024)} MB`);if(nl.has(t)||e.type.startsWith(`image/`))return{kind:`image`,file:e};if(rl.has(t))return{kind:`text`,name:e.name,size:e.size,content:await cl(e)};if(il.has(t))return{kind:`text`,name:e.name,size:e.size,content:await ll(e)};if(t===`doc`)throw Error(`${e.name}:旧版 .doc 请另存为 .docx 后再添加`);if(t===`pdf`)throw Error(`${e.name}:PDF 暂不解析正文,请转 Markdown/图片后添加`);if(al.has(t)||e.type.startsWith(`text/`)||e.type===`application/json`)return{kind:`text`,name:e.name,size:e.size,content:await e.text()};throw Error(`${e.name}:暂不支持的类型 .${t}`)}var dl=[{prefix:`知识库管理`,aliases:[`knowledge`],collection:`knowledge`,category:`知识库`},{prefix:`用例管理`,aliases:[`cases`],collection:`cases`,category:`用例`},{prefix:`提示词管理`,aliases:[`prompts`],collection:`prompts`,category:`提示词`},{prefix:`测试模板库`,aliases:[`templates`],collection:`templates`,category:`模板`}];function fl(e){return e.replace(/\\/g,`/`).replace(/\/+/g,`/`)}function pl(e){let t=fl(e),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t}function ml(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t+1).toLowerCase():`file`}function hl(e){let t=e.trim();if(!/^file:/i.test(t))return null;try{let e=new URL(t),n=decodeURIComponent(e.pathname||``);return/^\/[A-Za-z]:\//.test(n)&&(n=n.slice(1)),fl(n)}catch{return null}}function gl(e){let t=fl(e);return t.startsWith(`/`)||/^[A-Za-z]:\//.test(t)}function _l(e){let t=e.trim();return!t||t.includes(`
|
|
247
|
-
`)||/\s/.test(t)||t.includes(`://`)||t.includes(`/`)||t.includes(`\\`)?!1:/\.[A-Za-z0-9]{1,16}$/.test(t)}function vl(e){let t=e.trim();return!t||t.includes(`
|
|
248
|
-
`)?!1:!!(/^file:/i.test(t)||gl(t)||(t.includes(`/`)||t.includes(`\\`))&&!/\s/.test(t)&&t.length<512)}function yl(e){let t=[],n=e.getData(`text/uri-list`)||``;for(let e of n.split(/\r?\n/)){let n=e.trim();if(!n||n.startsWith(`#`))continue;let r=hl(n);r?t.push(r):gl(n)&&t.push(fl(n))}let r=(e.getData(`text/plain`)||``).trim();if(r&&!r.includes(`
|
|
249
|
-
`)){let e=hl(r);e?t.push(e):vl(r)&&!_l(r)&&t.push(fl(r))}return[...new Set(t)]}function bl(e){return{collection:e.collection,id:`${e.collection}:${e.path}`,title:e.title||pl(e.path),category:e.category,path:e.path,format:e.format||ml(e.path)}}function xl(e,t){let n=fl(e),r=fl(t).replace(/\/$/,``);return n===r?``:n.startsWith(`${r}/`)?n.slice(r.length+1):null}function Sl(e,t){let n=fl(e.trim()),r=hl(n);r&&(n=r);let i=t.projectRoot?fl(t.projectRoot):``,a=t.workspace?fl(t.workspace):``,o=n;if(i){let e=xl(n,i);e!=null&&(o=e)}for(let{prefix:e,aliases:t,collection:n,category:r}of dl)for(let i of[e,...t??[]])if(o!==i&&o.startsWith(`${i}/`)){let e=o.slice(i.length+1);if(!e)continue;return bl({collection:n,path:e,title:pl(e),category:r,format:ml(e)})}if(a){let e=xl(n,a);if(e!=null&&e!==``)return bl({collection:`workspace`,path:e,title:pl(e),category:t.workspaceLabel||`工作区`,format:ml(e)})}if(!gl(o)&&o.includes(`/`)){let e=o.split(`/`)[0]||``,n=dl.find(t=>t.prefix===e||t.aliases?.includes(e));if(n){let t=o.slice(e.length+1);if(t)return bl({collection:n.collection,path:t,title:pl(t),category:n.category,format:ml(t)})}return bl({collection:`workspace`,path:o,title:pl(o),category:t.workspaceLabel||`工作区`,format:ml(o)})}return null}function Cl(e,t){let n=e.trim();if(!n)return null;let r=n.toLowerCase(),i=t.filter(e=>{let t=pl(e.path).toLowerCase(),n=(e.title||``).toLowerCase();return t===r||n===r||e.path.toLowerCase()===r});return i.length===1?bl(i[0]):null}var Q=Ce(),wl=220;function Tl({open:e,onClose:t,title:n,closeAriaLabel:r=`关闭面板`,children:i,footer:a}){let[o,s]=(0,z.useState)(e),[c,l]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{if(e){s(!0);let e=window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>l(!0))});return()=>window.cancelAnimationFrame(e)}l(!1);let t=window.setTimeout(()=>s(!1),wl);return()=>window.clearTimeout(t)},[e]),(0,z.useEffect)(()=>{if(!e)return;function n(e){e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),t())}return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t]),o?(0,Q.jsxs)(`div`,{className:`fixed inset-0 z-60 flex justify-end`,role:`dialog`,"aria-modal":`true`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`absolute inset-0 bg-stone-900/30 transition-opacity duration-200 ease-out ${c?`opacity-100`:`opacity-0`}`,"aria-label":r,onClick:t}),(0,Q.jsxs)(`aside`,{className:`tw-slide-over relative w-full max-w-md h-full shadow-2xl border-l border-stone-200 flex flex-col transition-transform duration-200 ease-out will-change-transform ${c?`translate-x-0`:`translate-x-full`}`,children:[(0,Q.jsxs)(`header`,{className:`shrink-0 h-12 px-4 border-b border-stone-100 flex items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`tw-slide-over-title text-sm font-semibold text-stone-800 flex-1`,children:n}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`tw-icon-btn w-8 h-8 rounded-lg`,"data-hint":`关闭(Esc)`,children:`✕`})]}),(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4 space-y-4`,children:i}),a]})]}):null}var El=[{value:`md`,label:`Markdown 表格`},{value:`xlsx`,label:`Excel`},{value:`csv`,label:`CSV`}];async function Dl(e,t){let n=t.find(t=>t.id===e)?.templateFolder??_(e).templateFolder;try{let{entries:e}=await P(`templates`,n),t=e.filter(e=>e.type===`file`).sort((e,t)=>(t.mtime??0)-(e.mtime??0)),r=[];for(let e of t){let t=e.name.toLowerCase(),n=[...O],i=``;try{if(t.endsWith(`.xlsx`)||t.endsWith(`.xls`)){let t=await j(`templates`,e.path);if(t.encoding===`base64`&&t.contentBase64){let e=b(t.contentBase64);n=e.headers,i=e.body}}else if(t.endsWith(`.csv`)){let t=await ce(`templates`,e.path),r=D(t.content);n=r.headers,i=r.body}else if(t.endsWith(`.md`)||t.endsWith(`.txt`)){let t=await ce(`templates`,e.path),r=w(t.content);n=r.headers,i=r.body}}catch{i=``}r.push({id:e.path,title:e.name.replace(/\.[^.]+$/,``),body:i,headers:n})}return r}catch{return[]}}async function Ol(t){let n=t.toLowerCase();if(n.endsWith(`.md`)||n.endsWith(`.txt`)||n.endsWith(`.csv`))return(await ce(`requirements`,t)).content;if(n.endsWith(`.docx`)){let n=await j(`requirements`,t);if(n.encoding!==`base64`||!n.contentBase64)throw Error(`无法读取 docx`);let r=atob(n.contentBase64),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return((await(await Se(()=>import(`./lib.DJNDi_Ht.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1,2,3]))).extractRawText({arrayBuffer:i.buffer})).value??``).trim()}return``}function kl({open:e,onClose:t,initial:n,onConfirm:r}){let[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)([]),[l,u]=(0,z.useState)(n?.reqPath??``),[d,f]=(0,z.useState)(()=>y()),[p,b]=(0,z.useState)(n?.caseType??y()[0]?.id??`functional`),[x,S]=(0,z.useState)([]),[C,w]=(0,z.useState)(n?.templateId??``),[T,E]=(0,z.useState)([]),[D,te]=(0,z.useState)(n?.promptPath??``),[re,k]=(0,z.useState)(n?.promptBody??``),[ie,ae]=(0,z.useState)([]),[oe,A]=(0,z.useState)(n?.knowledgePaths??[]),[se,j]=(0,z.useState)(n?.outputFormat??`xlsx`),[le,N]=(0,z.useState)(null),[de,fe]=(0,z.useState)(!1),[pe,he]=(0,z.useState)(null),[ge,F]=(0,z.useState)(``),[_e,I]=(0,z.useState)(!1),[ve,ye]=(0,z.useState)(()=>Me(`prompts`)),[be,xe]=(0,z.useState)(()=>Me(`knowledgeLib`)),[Se,Ce]=(0,z.useState)(()=>Me(`requirements`)),[we,Te]=(0,z.useState)(()=>Me(`templates`)),Ee=(0,z.useMemo)(()=>x.find(e=>e.id===C)??x[0],[x,C]),De=d.find(e=>e.id===p)??d[0]??_(p),Oe=De.label;function Ae(e){let t=y();f(t),b(n=>{let r=e??n;return t.some(e=>e.id===r)?r:t[0]?.id??n})}function je(){try{pe===`add`?Ae(m(ge).id):pe===`edit`&&(g(p,ge),Ae(p)),he(null),F(``),N(null)}catch(e){N(e instanceof Error?e.message:String(e))}}(0,z.useEffect)(()=>{let e=()=>{ye(Me(`prompts`)),xe(Me(`knowledgeLib`)),Ce(Me(`requirements`)),Te(Me(`templates`))},t=ke(()=>e());return c().then(e),t},[]),(0,z.useEffect)(()=>{e&&(Ae(n?.caseType),u(n?.reqPath??``),b(n?.caseType??y()[0]?.id??`functional`),w(n?.templateId??``),te(n?.promptPath??``),k(n?.promptBody??``),A(n?.knowledgePaths??[]),j(n?.outputFormat??`xlsx`),he(null),F(``),I(!1),N(null),(async()=>{let e=await M(`templates`)&&await M(`prompts`)&&await M(`requirements`)&&await M(`knowledge`);if(a(e),!e)return;async function t(e,n,r){let{entries:i}=await P(e,n);for(let n of i)n.type===`file`?r.push(n):await t(e,n.path,r)}if(!Se)s([]),u(``);else try{let e=[];await t(`requirements`,`.`,e),s(e),u(t=>t&&e.some(e=>e.path===t)?t:``)}catch{}if(!be)ae([]),A([]);else try{let e=[];await t(`knowledge`,`.`,e),e.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),ae(e),A(t=>t.filter(t=>e.some(e=>e.path===t)))}catch{}if(!ve)E([]),te(``),k(``);else try{let e=[];await t(`prompts`,`.`,e);let r=e.filter(e=>!me(e.path));r.sort((e,t)=>(t.mtime??0)-(e.mtime??0)),E(r),te(e=>e&&r.some(t=>t.path===e)?e:n?.promptPath&&r.some(e=>e.path===n.promptPath)?n.promptPath:r.find(e=>e.path.includes(`功能测试用例提示词`))?.path??r[0]?.path??``)}catch{}})())},[e,n,ve,be,Se]),(0,z.useEffect)(()=>{if(!e||!i)return;if(!we){S([]),w(``);return}let t=!1;return Dl(p,d).then(e=>{t||(S(e),w(t=>t&&e.some(e=>e.id===t)?t:n?.templateId&&e.some(e=>e.id===n.templateId)?n.templateId:e[0]?.id??``))}),()=>{t=!0}},[e,i,we,p,d,n?.templateId]),(0,z.useEffect)(()=>{D?ce(`prompts`,D).then(e=>k(e.content)).catch(()=>k(``)):k(``)},[D]);let Ne=o.map(e=>({value:e.path,label:e.path})),Pe=x.map(e=>({value:e.id,label:e.title})),Fe=T.map(e=>({value:e.path,label:e.path.replace(/\.[^.]+$/,``)})),L=ie.map(e=>({value:e.path,label:e.path.replace(/\.[^.]+$/,``)}));async function Ie(){fe(!0),N(null);try{if(!ve){N(`请先在「我的插件」中启用「提示词管理」`);return}if(!D||!re.trim()){N(`请先选择用例生成提示词(不再使用「默认提示词」或工作台系统提示词)`);return}let e=x.find(e=>e.id===C)??x[0],i=``;if(l)try{i=(await Ol(l)).slice(0,12e3)}catch(e){N(e instanceof Error?e.message:String(e));return}let a=[];for(let e of oe)try{let t=await ce(`knowledge`,e);a.push(`\n### 知识库:${e}\n${t.content.slice(0,6e3)}`)}catch{a.push(`\n### 知识库:${e}\n(无法读取)`)}r({active:!0,caseType:p,outputFormat:se,reqPath:l||void 0,templateId:e?.id,templateTitle:e?.title,promptPath:D,knowledgePaths:oe.length?[...oe]:void 0,templateHeaders:e?.headers?.length?e.headers:[...O],templateBody:[e?.body||``,i?`\n### 需求文档:${l}\n${i}`:``,...a].join(``).trim(),promptBody:re.trim(),confirmedAt:Date.now(),linkedCasePath:n?.linkedCasePath}),t()}finally{fe(!1)}}return(0,Q.jsxs)(Tl,{open:e,onClose:t,title:`生成测试用例 · 配置`,closeAriaLabel:`关闭生成测试用例面板`,footer:(0,Q.jsxs)(`footer`,{className:`shrink-0 p-4 border-t border-stone-100 flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm text-stone-600 rounded-lg hover:bg-stone-100`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:de||!i||!ve||!D,onClick:()=>void Ie(),className:`flex-1 h-9 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`确认`})]}),children:[i?null:(0,Q.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900`,children:`本地文档服务未就绪,无法读写文档库。`}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5`,children:`按所选用例类型、模板与提示词生成可入库用例:确认后在主输入框描述需求并发送,输出结构化用例并写入用例库,可在「用例管理」中查看。`}),le?(0,Q.jsx)(`div`,{className:`text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2`,children:le}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-stone-500 flex-1`,children:`用例类型`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-[#4176e6] hover:underline`,onClick:()=>{he(`add`),F(``),N(null),I(!1)},children:`新增`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-600 hover:underline`,onClick:()=>{he(`edit`),F(De.label),N(null),I(!1)},children:`编辑`}),_e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-stone-500 shrink-0`,children:`确认删除?`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-red-600 hover:underline shrink-0`,onClick:()=>{I(!1);try{let e=h(p);f(e),b(e[0]?.id??``),he(null),N(null)}catch(e){N(e instanceof Error?e.message:String(e))}},children:`确认`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-500 hover:underline shrink-0`,onClick:()=>I(!1),children:`取消`})]}):(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-red-600 hover:underline disabled:opacity-40`,disabled:d.length<=1,onClick:()=>{he(null),I(!0),N(null)},children:`删除`})]}),(0,Q.jsx)(ue,{options:d.map(e=>({value:e.id,label:e.label})),value:p,onChange:e=>{b(e),I(!1)}}),pe?(0,Q.jsxs)(`div`,{className:`mt-2 rounded-lg border border-stone-200 bg-stone-50 p-2 space-y-2`,children:[(0,Q.jsx)(`label`,{className:`text-[11px] text-stone-500`,htmlFor:`cg-type-draft`,children:pe===`add`?`新类型名称`:`修改名称`}),(0,Q.jsx)(`input`,{id:`cg-type-draft`,value:ge,onChange:e=>F(e.target.value),placeholder:`如:安全测试`,className:`w-full h-8 px-2 text-sm rounded-md border border-stone-200 bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/40`,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),je())}}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs font-medium text-white bg-[#4176e6] rounded-md hover:bg-[#3565c7]`,onClick:je,children:`保存`}),(0,Q.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs text-stone-600 rounded-md hover:bg-stone-200/80`,onClick:()=>{he(null),F(``)},children:`取消`})]}),(0,Q.jsx)(`p`,{className:`text-[10px] text-stone-400 leading-4`,children:`模板目录约定为「名称 + 用例」,如「安全测试」→ 测试模板库/安全测试用例/`})]}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-stone-500`,children:`输出格式`}),(0,Q.jsx)(ue,{options:El,value:se,onChange:j})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:`需求文档`}),(0,Q.jsx)(v,{options:Ne,value:l,onChange:u,allowEmpty:!1,disabled:!Se,placeholder:Se?Ne.length?`搜索并选择需求文档…`:`请先在需求文档库中上传`:`需求文档库未启用`}),Se?null:(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:`请先在「我的插件」中启用「需求文档库」后再选择。`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:[`用例模板`,(0,Q.jsxs)(`span`,{className:`ml-1 font-normal text-stone-400`,children:[`(`,Oe,` · `,De.templateFolder,`)`]})]}),(0,Q.jsx)(v,{options:Pe,value:Ee?.id??``,onChange:w,allowEmpty:!1,disabled:!we,placeholder:we?Pe.length?`搜索并选择模板…`:`暂无「${De.templateFolder}」模板`:`测试模板库未启用`}),we?null:(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:`请先在「我的插件」中启用「测试模板库」后再选择;未启用时按默认字段生成。`}),Ee?.headers?.length?(0,Q.jsx)(ne,{fields:Ee.headers}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:`提示词`}),(0,Q.jsx)(v,{options:Fe,value:D,onChange:te,allowEmpty:!1,disabled:!ve,placeholder:ve?Fe.length?`搜索并选择提示词…`:`请先在提示词管理中上传`:`提示词管理未启用`}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:ve?`启用后主会话将只使用该提示词,不再叠加「系统提示词」。`:`请先在「我的插件」中启用「提示词管理」后再选择。`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-stone-500 mb-0.5`,children:`引用知识库(可多选)`}),(0,Q.jsx)(ee,{options:L,values:oe,onChange:A,disabled:!be,placeholder:be?L.length?`选择知识库文档…`:`暂无知识库文档`:`知识库管理未启用`}),be?null:(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:`请先在「我的插件」中启用「知识库管理」后再引用。`})]})]})}function Al({open:e,onClose:t,initial:n,onConfirm:r}){let[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(()=>no()),[u,d]=(0,z.useState)(no()[0]?.id??`case`),[f,p]=(0,z.useState)(null),[m,h]=(0,z.useState)(null),[g,_]=(0,z.useState)(``),[ee,v]=(0,z.useState)(!1),y=c.find(e=>e.id===u)??c[0]??ro(u);function b(e){let t=no();l(t),d(n=>{let r=e??n;return t.some(e=>e.id===r)?r:t[0]?.id??n})}function x(){try{m===`add`?b(ao(g).id):m===`edit`&&(oo(u,g),b(u)),h(null),_(``),p(null)}catch(e){p(e instanceof Error?e.message:String(e))}}(0,z.useEffect)(()=>{e&&(b(n?.kind),s(n?.titleHint??``),d(n?.kind??no()[0]?.id??`case`),h(null),_(``),v(!1),p(null),M(`prompts`).then(a))},[e,n]);function S(){p(null),i?(r({active:!0,titleHint:o.trim(),kind:u,confirmedAt:Date.now(),linkedPromptPath:n?.linkedPromptPath}),t()):p(`本地文档服务未就绪,无法写入提示词库`)}return(0,Q.jsxs)(Tl,{open:e,onClose:t,title:`生成提示词 · 配置`,closeAriaLabel:`关闭生成提示词面板`,footer:(0,Q.jsxs)(`footer`,{className:`shrink-0 p-4 border-t border-stone-100 flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm text-stone-600 rounded-lg hover:bg-stone-100`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!i,onClick:S,className:`flex-1 h-9 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`确认`})]}),children:[i?null:(0,Q.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900`,children:`本地文档服务未就绪,无法读写提示词库。`}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5`,children:`按所选类型生成可复用提示词:确认后在主输入框描述编写要求并发送,质检通过后写入提示词库,可在「提示词管理」中查看与引用。`}),f?(0,Q.jsx)(`div`,{className:`text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2`,children:f}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-stone-500 flex-1`,children:`提示词类型`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-[#4176e6] hover:underline`,onClick:()=>{h(`add`),_(``),p(null),v(!1)},children:`新增`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-600 hover:underline`,onClick:()=>{h(`edit`),_(y.label),p(null),v(!1)},children:`编辑`}),ee?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-stone-500 shrink-0`,children:`确认删除?`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-red-600 hover:underline shrink-0`,onClick:()=>{v(!1);try{let e=so(u);l(e),d(e[0]?.id??``),h(null),p(null)}catch(e){p(e instanceof Error?e.message:String(e))}},children:`确认`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-500 hover:underline shrink-0`,onClick:()=>v(!1),children:`取消`})]}):(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-red-600 hover:underline disabled:opacity-40`,disabled:c.length<=1,onClick:()=>{h(null),v(!0),p(null)},children:`删除`})]}),(0,Q.jsx)(ue,{options:c.map(e=>({value:e.id,label:e.label})),value:u,onChange:e=>{d(e),v(!1)}}),(0,Q.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400 leading-4 break-words`,children:y.hint}),m?(0,Q.jsxs)(`div`,{className:`mt-2 rounded-lg border border-stone-200 bg-stone-50 p-2 space-y-2`,children:[(0,Q.jsx)(`label`,{className:`text-[11px] text-stone-500`,htmlFor:`pg-kind-draft`,children:m===`add`?`新类型名称`:`修改名称`}),(0,Q.jsx)(`input`,{id:`pg-kind-draft`,value:g,onChange:e=>_(e.target.value),placeholder:`如:缺陷分析提示词`,className:`w-full h-8 px-2 text-sm rounded-md border border-stone-200 bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/40`,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),x())}}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs font-medium text-white bg-[#4176e6] rounded-md hover:bg-[#3565c7]`,onClick:x,children:`保存`}),(0,Q.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs text-stone-600 rounded-md hover:bg-stone-200/80`,onClick:()=>{h(null),_(``)},children:`取消`})]})]}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,htmlFor:`pg-title`,children:`期望名称`}),(0,Q.jsx)(`input`,{id:`pg-title`,value:o,onChange:e=>s(e.target.value),placeholder:`如:接口测试用例提示词.md`,className:`mt-1 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 focus:outline-none focus:ring-2 focus:ring-[#4176e6]/40`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-4`,children:`可填期望文件名;留空则由模型自拟。具体编写要求在主输入框描述。`})]})]})}function jl({open:e,onClose:t,initial:n,onConfirm:r}){let[i,a]=(0,z.useState)(!1),[o,s]=(0,z.useState)(``),[c,l]=(0,z.useState)(()=>vo()),[u,d]=(0,z.useState)(vo()[0]??`测试规范`),[f,p]=(0,z.useState)(null),[m,h]=(0,z.useState)(null),[g,_]=(0,z.useState)(``),[ee,v]=(0,z.useState)(!1);function y(e){let t=vo();l(t),d(n=>{let r=e??n;return t.includes(r)?r:t[0]??n})}function b(){try{m===`add`?y(bo(g)):m===`edit`&&y(xo(u,g)),h(null),_(``),p(null)}catch(e){p(e instanceof Error?e.message:String(e))}}(0,z.useEffect)(()=>{e&&(y(n?.category),s(n?.titleHint??``),d(n?.category??vo()[0]??`测试规范`),h(null),_(``),v(!1),p(null),M(`knowledge`).then(a))},[e,n]);function x(){p(null),i?(r({active:!0,titleHint:o.trim(),category:u,confirmedAt:Date.now(),linkedKnowledgePath:n?.linkedKnowledgePath}),t()):p(`本地文档服务未就绪,无法写入知识库`)}return(0,Q.jsxs)(Tl,{open:e,onClose:t,title:`生成知识库 · 配置`,closeAriaLabel:`关闭生成知识库面板`,footer:(0,Q.jsxs)(`footer`,{className:`shrink-0 p-4 border-t border-stone-100 flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:t,className:`h-9 px-3 text-sm text-stone-600 rounded-lg hover:bg-stone-100`,children:`取消`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!i,onClick:x,className:`flex-1 h-9 text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`确认`})]}),children:[i?null:(0,Q.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900`,children:`本地文档服务未就绪,无法读写知识库。`}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5`,children:`按所选分类沉淀测试规范、方法论或环境约定:确认后在主输入框粘贴/描述素材并发送,质检通过后写入知识库,可在「知识库管理」中查看与 @ 引用。`}),f?(0,Q.jsx)(`div`,{className:`text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2`,children:f}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,Q.jsx)(`div`,{className:`text-xs font-medium text-stone-500 flex-1`,children:`分类`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-[#4176e6] hover:underline`,onClick:()=>{h(`add`),_(``),p(null),v(!1)},children:`新增`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-600 hover:underline`,onClick:()=>{h(`edit`),_(u),p(null),v(!1)},children:`编辑`}),ee?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`text-[11px] text-stone-500 shrink-0`,children:`确认删除?`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-red-600 hover:underline shrink-0`,onClick:()=>{v(!1);try{let e=So(u);l(e),d(e[0]??``),h(null),p(null)}catch(e){p(e instanceof Error?e.message:String(e))}},children:`确认`}),(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-500 hover:underline shrink-0`,onClick:()=>v(!1),children:`取消`})]}):(0,Q.jsx)(`button`,{type:`button`,className:`text-[11px] text-red-600 hover:underline disabled:opacity-40`,disabled:c.length<=1,onClick:()=>{h(null),v(!0),p(null)},children:`删除`})]}),(0,Q.jsx)(ue,{options:c.map(e=>({value:e,label:e})),value:u,onChange:e=>{d(e),v(!1)}}),m?(0,Q.jsxs)(`div`,{className:`mt-2 rounded-lg border border-stone-200 bg-stone-50 p-2 space-y-2`,children:[(0,Q.jsx)(`label`,{className:`text-[11px] text-stone-500`,htmlFor:`kg-cat-draft`,children:m===`add`?`新分类名称`:`修改名称`}),(0,Q.jsx)(`input`,{id:`kg-cat-draft`,value:g,onChange:e=>_(e.target.value),placeholder:`如:安全基线`,className:`w-full h-8 px-2 text-sm rounded-md border border-stone-200 bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/40`,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())}}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs font-medium text-white bg-[#4176e6] rounded-md hover:bg-[#3565c7]`,onClick:b,children:`保存`}),(0,Q.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs text-stone-600 rounded-md hover:bg-stone-200/80`,onClick:()=>{h(null),_(``)},children:`取消`})]}),(0,Q.jsx)(`p`,{className:`text-[10px] text-stone-400 leading-4`,children:`分类写入文档 frontmatter,文件平铺存放于 知识库管理/;改名不会自动迁移已有文件。`})]}):null]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,htmlFor:`kg-title`,children:`期望名称`}),(0,Q.jsx)(`input`,{id:`kg-title`,value:o,onChange:e=>s(e.target.value),placeholder:`如:接口自动化环境约定.md`,className:`mt-1 w-full h-9 px-3 text-sm rounded-lg border border-stone-200 focus:outline-none focus:ring-2 focus:ring-[#4176e6]/40`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-4`,children:`可填期望文件名;留空则由模型自拟。素材与编写要求在主输入框描述。`})]})]})}var Ml={user:`用户档案`,memory:`长期记忆`,key:`项目关键记忆`,project:`项目日志`};function Nl(e){return e?e.replace(/\\/g,`/`).replace(/^\/Users\/[^/]+/,`~`):``}var Pl={project:{title:`项目日志`,fileHint:`MEMORY.md`,desc:`项目进展流水账,按需查阅,默认不注入上下文。`,curated:!1},key:{title:`项目关键记忆`,fileHint:`KEY.md`,desc:`项目关键约定与事实;写入需经待确认记忆建议采纳后注入。`,curated:!0},memory:{title:`长期记忆`,fileHint:`MEMORY.md`,desc:`全局环境与跨项目事实,注入所有会话;写入需审查建议并经确认。`,curated:!0}},Fl=[{id:`guide`,label:`指南`},{id:`suggestions`,label:`待确认记忆建议`},{id:`project`,label:`项目日志`},{id:`key`,label:`项目关键记忆 KEY.md`},{id:`memory`,label:`长期记忆 MEMORY.md`},{id:`agents`,label:`全局规则 AGENTS.md`},{id:`archive`,label:`归档`},{id:`settings`,label:`设置`}];function Il({live:e,pluginOn:t,workspacePath:n=``}){let[r,i]=(0,z.useState)(`suggestions`),[a,o]=(0,z.useState)(null),[s,c]=(0,z.useState)({}),[l,u]=(0,z.useState)(``),[d,f]=(0,z.useState)([]),[p,m]=(0,z.useState)([]),[h,g]=(0,z.useState)(`memory`),[_,ee]=(0,z.useState)(null),[v,y]=(0,z.useState)([]),[b,x]=(0,z.useState)(null),[S,C]=(0,z.useState)(``),[w,T]=(0,z.useState)(!1),[E,D]=(0,z.useState)(null),[te,ne]=(0,z.useState)(null),[O,re]=(0,z.useState)(null),k=n.trim(),ie=(0,z.useCallback)(async()=>{if(!e)o(null),c({}),f([]),y([]);else{x(null);try{let[e,t,n,i,a]=await Promise.all([Et(),ft(k,`all`),dt(),R(),mt().catch(()=>null)]);o(e),c(t.tracks),u(t.projectId||``),f(n),ee(i),y(a?.files?.length?a.files:a?.text?[{path:`AGENTS.md`,name:`AGENTS.md`}]:[]),r===`archive`&&m(await ut(h,k))}catch(e){x(e instanceof Error?e.message:String(e))}}},[e,k,r,h]);if((0,z.useEffect)(()=>{ie()},[ie]),!t)return(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-center px-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-stone-600`,children:`会话记忆未启用`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`在「我的插件」中打开「会话记忆」后,可在此管理记忆轨与待确认记忆建议`})]});if(!e)return(0,Q.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-center px-6`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-stone-600`,children:`会话记忆中间件未就绪`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-stone-400`,children:`本地记忆服务未就绪`})]});let ae=r===`memory`||r===`key`,oe=r===`memory`||r===`key`||r===`project`,A=oe?s[r]?.entries??[]:[],se=oe?s[r]?.path:null,ce=a?.path||`.lantern/local/memories`;async function j(e){T(!0);try{await sn(e),await ie()}catch(e){x(e instanceof Error?e.message:String(e))}finally{T(!1)}}async function le(e){T(!0);try{await bt(e),await ie()}catch(e){x(e instanceof Error?e.message:String(e))}finally{T(!1)}}function M(e){ae&&ne(e)}async function N(){if(te==null||!ae)return;let e=te;ne(null),T(!0);try{await ln(r,e,k),await ie()}catch(e){x(e instanceof Error?e.message:String(e))}finally{T(!1)}}async function ue(){if(O==null)return;let e=O;re(null),T(!0);try{await It(h,e,k),await ie()}catch(e){x(e instanceof Error?e.message:String(e))}finally{T(!1)}}function P(e){D(e)}async function de(){if(E==null)return;let e=E;D(null),T(!0);try{await cn(r,e,k),await ie()}catch(e){x(e instanceof Error?e.message:String(e))}finally{T(!1)}}async function fe(){if(ae&&S.trim()){T(!0);try{await St(r,S.trim(),k),C(``),await ie()}catch(e){x(e instanceof Error?e.message:String(e))}finally{T(!1)}}}async function pe(e){T(!0);try{let t=await Ct(e);ee(t)}catch(e){x(e instanceof Error?e.message:String(e))}finally{T(!1)}}function me(e){let t=Pl[e],n=e===`key`?`KEY.md`:t.fileHint,r=e===`key`?`项目关键记忆 ${n}`:e===`memory`?`长期记忆 ${n}`:t.title,i=Nl(se)||`${Nl(ce)}/…/${n}`;return(0,Q.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 flex-wrap min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:r}),t.curated?null:(0,Q.jsx)(`span`,{className:`px-1.5 py-0.5 text-[10px] rounded bg-stone-100 text-stone-500 border border-stone-200`,children:`只读追加`}),(0,Q.jsxs)(`span`,{className:`text-[11px] text-stone-400 tabular-nums`,children:[A.length,` 条`]}),(0,Q.jsx)(`span`,{className:`max-w-full break-all whitespace-normal text-[11px] text-[#4176e6] bg-[#edf3fe] border border-[#4176e6]/20 rounded-lg px-2 py-0.5 font-mono leading-4`,"data-hint":se||i,children:i})]}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5 break-words`,children:t.desc}),k?(0,Q.jsxs)(`p`,{className:`text-[11px] text-stone-400 break-all`,children:[`当前会话工作目录:`,(0,Q.jsx)(`span`,{className:`font-mono`,children:k}),l?(0,Q.jsxs)(Q.Fragment,{children:[` · `,`项目 id `,(0,Q.jsx)(`span`,{className:`font-mono`,children:l.slice(0,12)})]}):null]}):null]})}return(0,Q.jsxs)(`div`,{className:`h-full flex flex-col min-h-0`,children:[(0,Q.jsxs)(`div`,{className:`shrink-0 flex flex-wrap items-center gap-2 px-4 py-2 border-b border-stone-200/80`,children:[Fl.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`h-7 px-2.5 text-xs rounded-md whitespace-normal text-left leading-tight ${r===e.id?`bg-stone-900 text-white`:`text-stone-600 hover:bg-stone-100`}`,children:[e.label,e.id===`suggestions`&&d.length>0?(0,Q.jsxs)(`span`,{className:`ml-1 tabular-nums`,children:[`(`,d.length,`)`]}):null]},e.id)),(0,Q.jsxs)(`span`,{className:`text-[11px] text-stone-400 tabular-nums`,children:[a?.entryCount??0,` 条 · 待确认 `,a?.suggestionCount??d.length]})]}),b?(0,Q.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:b}):null,(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto p-4`,children:[r===`guide`?(0,Q.jsxs)(`div`,{className:`space-y-3 max-w-2xl`,children:[(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`确认制:为什么必须你点头`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-stone-500 leading-5`,children:`记忆会改变后续对话行为。长期记忆 / 项目关键记忆经「待确认记忆建议」采纳后才写入并注入;项目日志可直写但不注入。`})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`待确认记忆建议:AI 只提议,你拍板`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-stone-500 leading-5`,children:`后台或对话中产出的记忆建议进入独立队列。采纳可写入对应轨;拒绝则丢弃。`}),(0,Q.jsxs)(`ul`,{className:`mt-2 space-y-1.5 text-xs text-stone-600`,children:[(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2 break-words`,children:`采纳 → 长期记忆 MEMORY.md / 项目关键记忆 KEY.md`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`拒绝 → 丢弃,不落盘`})]})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`各轨文件(对齐 dsh)`}),(0,Q.jsxs)(`ul`,{className:`mt-2 space-y-1.5 text-xs text-stone-600`,children:[(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`项目日志 · 项目目录 MEMORY.md(不注入)`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`项目关键记忆 KEY.md(注入,需确认)`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`长期记忆 MEMORY.md(注入,需确认)`}),(0,Q.jsx)(`li`,{className:`rounded-lg bg-stone-50 border border-stone-100 px-2.5 py-2`,children:`全局规则:展示工作区 AGENTS.md 等规则文件`})]})]}),(0,Q.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`编辑与维护`}),(0,Q.jsx)(`p`,{className:`mt-1.5 text-xs text-stone-500 leading-5`,children:`可在本 Tab 浏览条目、手动添加(注入轨)、归档或删除。文件为 § 分隔结构化记忆,用外部编辑器打开时请谨慎修改。`}),(0,Q.jsxs)(`p`,{className:`mt-2 text-[11px] text-amber-700/90`,children:[`存储目录:`,(0,Q.jsx)(`code`,{className:`font-mono`,children:ce})]})]})]}):null,r===`suggestions`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`待确认记忆建议`}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-stone-500 leading-5`,children:`后台审查或对话沉淀产出的记忆建议:采纳后写入记忆文件并注入;拒绝则丢弃。`})]}),d.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-stone-50/50 px-4 py-16 text-center text-sm text-stone-400`,children:`没有待确认的建议。`}):(0,Q.jsx)(`ul`,{className:`space-y-3`,children:d.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-lg border border-amber-200/80 bg-amber-50/30 p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-stone-400 mb-1 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-amber-100 text-amber-900 border border-amber-200 font-medium`,children:`待确认记忆建议`}),(0,Q.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-white text-stone-600 border border-stone-200`,children:Ml[e.target]??e.target}),(0,Q.jsx)(`span`,{children:e.time}),e.hits&&e.hits>1?(0,Q.jsxs)(`span`,{children:[`×`,e.hits]}):null]}),(0,Q.jsx)(`p`,{className:`text-sm text-stone-800 whitespace-pre-wrap`,children:e.content}),e.reason?(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-stone-500`,children:[`原因:`,e.reason]}):null,(0,Q.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:w,onClick:()=>void j(e.id),className:`h-7 px-2.5 text-xs text-white bg-emerald-600 rounded-md hover:bg-emerald-700 disabled:opacity-40`,children:`采纳`}),(0,Q.jsx)(`button`,{type:`button`,disabled:w,onClick:()=>void le(e.id),className:`h-7 px-2.5 text-xs text-stone-600 border border-stone-200 rounded-md hover:bg-stone-50 disabled:opacity-40`,children:`拒绝`})]})]},e.id))})]}):null,oe?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[me(r),ae?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white p-3 space-y-2`,children:[(0,Q.jsx)(`textarea`,{value:S,onChange:e=>C(e.target.value),placeholder:r===`key`?`输入一条项目关键约定,例如:本仓库包管理器用 pnpm…`:`输入一条想长期记住的全局事实/惯例/环境…`,rows:3,className:`w-full text-sm rounded-lg border border-stone-200 px-3 py-2 focus:outline-none focus:border-[#4176e6] resize-y`}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] text-stone-400`,children:`手动写入会直接落盘;重要偏好更推荐走「待确认记忆建议」。`}),(0,Q.jsx)(`button`,{type:`button`,disabled:w||!S.trim(),onClick:()=>void fe(),className:`shrink-0 h-8 px-3 text-xs text-white bg-[#4176e6] rounded-lg disabled:opacity-40`,children:`保存`})]})]}):(0,Q.jsx)(`p`,{className:`text-xs text-stone-400`,children:`本轨由对话中 memory_append 自动追加,一般不注入上下文。`}),A.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-stone-50/50 px-4 py-12 text-center text-sm text-stone-400`,children:`(文件不存在或为空)`}):(0,Q.jsx)(`ul`,{className:`space-y-2`,children:A.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-lg border border-stone-200 bg-white px-3 py-2.5 flex gap-2`,children:[(0,Q.jsx)(`p`,{className:`flex-1 text-sm text-stone-800 whitespace-pre-wrap`,children:e.text}),(0,Q.jsxs)(`div`,{className:`shrink-0 self-start flex flex-col gap-0.5`,children:[ae?(0,Q.jsx)(`button`,{type:`button`,disabled:w,onClick:()=>void M(e.index),className:`h-7 px-2 text-[11px] text-stone-500 hover:bg-stone-50 rounded-md`,children:`归档`}):null,(0,Q.jsx)(`button`,{type:`button`,disabled:w,onClick:()=>void P(e.index),className:`h-7 px-2 text-[11px] text-red-600 hover:bg-red-50 rounded-md`,children:`删除`})]})]},`${r}-${e.index}`))})]}):null,r===`agents`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-stone-800`,children:`全局规则`}),(0,Q.jsx)(`p`,{className:`text-xs text-stone-500 leading-5`,children:`工作区规则文件(AGENTS.md 等),随系统提示注入。`}),v.length===0?(0,Q.jsx)(`div`,{className:`rounded-xl border border-dashed border-stone-200 bg-stone-50/50 px-4 py-12 text-center text-sm text-stone-400`,children:`(未找到规则文件)`}):(0,Q.jsx)(`ul`,{className:`space-y-2 w-full`,children:v.map(e=>{let t=Nl(e.abs)||Nl(e.path)||e.label||e.path||e.name;return(0,Q.jsx)(`li`,{className:`w-full`,children:(0,Q.jsxs)(`div`,{className:`w-full flex items-center gap-4 rounded-xl border border-stone-200 bg-white px-4 py-3.5`,children:[(0,Q.jsx)(`span`,{className:`w-12 h-12 rounded-xl bg-[#edf3fe] text-[#4176e6] flex items-center justify-center text-[11px] font-semibold shrink-0`,children:(e.name.split(`.`).pop()||`MD`).toUpperCase()}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-[15px] font-medium text-stone-800 break-all`,children:e.name||`AGENTS.md`}),(0,Q.jsx)(`span`,{className:`block text-xs text-stone-400 break-all font-mono mt-1`,children:t})]}),(0,Q.jsx)(`button`,{type:`button`,disabled:w,onClick:()=>{x(null),T(!0),At(e.path||e.name||`AGENTS.md`,ve(),{abs:e.abs}).catch(e=>x(e instanceof Error?e.message:String(e))).finally(()=>T(!1))},className:`shrink-0 h-9 px-4 text-xs text-[#4176e6] border border-[#4176e6]/30 rounded-lg hover:bg-[#f5f8ff] disabled:opacity-40`,children:`打开文件`})]})},e.abs||e.path)})})]}):null,r===`archive`?(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`div`,{className:`flex gap-2`,children:[`user`,`memory`,`key`].map(e=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{g(e)},className:`h-7 px-2.5 text-xs rounded-md ${h===e?`bg-stone-800 text-white`:`border border-stone-200`}`,children:Ml[e]??e},e))}),p.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-stone-400 text-center py-10`,children:`暂无归档`}):(0,Q.jsx)(`ul`,{className:`space-y-2`,children:p.map(e=>(0,Q.jsxs)(`li`,{className:`rounded-lg border border-stone-200 bg-white px-3 py-2.5 flex gap-2`,children:[(0,Q.jsx)(`p`,{className:`flex-1 text-sm text-stone-800 whitespace-pre-wrap`,children:e.text}),(0,Q.jsxs)(`div`,{className:`shrink-0 self-start flex flex-col gap-0.5`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:w,onClick:()=>void(async()=>{T(!0);try{await ct(h,e.index,k),await ie()}catch(e){x(e instanceof Error?e.message:String(e))}finally{T(!1)}})(),className:`h-7 px-2 text-[11px] text-emerald-700 hover:bg-emerald-50 rounded-md`,children:`转正`}),(0,Q.jsx)(`button`,{type:`button`,disabled:w,onClick:()=>re(e.index),className:`h-7 px-2 text-[11px] text-red-600 hover:bg-red-50 rounded-md`,children:`删除`})]})]},`a-${e.index}`))})]}):null,r===`settings`&&_?(0,Q.jsxs)(`div`,{className:`space-y-4 max-w-md`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm text-stone-700`,children:[(0,Q.jsx)(`span`,{children:`每回合注入 USER / MEMORY / KEY`}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:_.injectMemory,onChange:e=>void pe({injectMemory:e.target.checked})})]}),(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm text-stone-700`,children:[(0,Q.jsx)(`span`,{children:`收尾提示写 project`}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:_.perTurnProjectWrites,onChange:e=>void pe({perTurnProjectWrites:e.target.checked})})]}),(0,Q.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm text-stone-700`,children:[(0,Q.jsx)(`span`,{children:`重要事实用 suggest(KEY)`}),(0,Q.jsx)(`input`,{type:`checkbox`,checked:_.perTurnKeyWrites,onChange:e=>void pe({perTurnKeyWrites:e.target.checked})})]}),(0,Q.jsxs)(`p`,{className:`text-xs text-stone-400 leading-5 break-all`,children:[`存储目录:`,(0,Q.jsx)(`code`,{className:`font-mono`,children:a?.path??`.lantern/local/memories`}),`。memory/key 经待确认记忆建议后注入;project 不注入。`]})]}):null]}),(0,Q.jsx)(we,{open:E!=null,title:`删除记忆`,message:`永久删除该条目?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>D(null),onConfirm:()=>void de()}),(0,Q.jsx)(we,{open:te!=null,title:`归档记忆`,message:`归档该条目?归档后不再注入上下文。`,confirmLabel:`归档`,cancelLabel:`取消`,onClose:()=>ne(null),onConfirm:()=>void N()}),(0,Q.jsx)(we,{open:O!=null,title:`删除归档`,message:`永久删除该归档?此操作不可恢复。`,confirmLabel:`删除`,cancelLabel:`取消`,danger:!0,onClose:()=>re(null),onConfirm:()=>void ue()})]})}function Ll(e,t,n){let r=e;if(n.knowledge&&(r=`${r}\n\n${Xc}`),n.fs&&(r=`${r}\n\n${Ot}\n\n${zo}\n\n${qo}\n\n${Kn}\n\n${Hn}`),n.bash&&(r=`${r}\n\n${en}`),n.pwsh&&(r=`${r}\n\n${nn}`),n.web&&(r=`${r}\n\n${pt}`),n.memory&&(r=`${r}\n\n${Vt}`),n.interact&&(r=`${r}\n\n${is}`),n.planPhase===`planning`&&(r=`${r}\n\n${fs}`),n.planPhase===`approved`&&(r=`${r}\n\n${ps}`),n.goalEnabled){r=`${r}\n\n${Es}`;let e=As(n.goal);e&&(r=`${r}\n\n【当前会话目标】${e}`)}n.scheduleEnabled&&(r=`${r}\n\n${qs}`),n.subagentEnabled&&(r=`${r}\n\n${fc}`),n.workflowEnabled&&(r=`${r}\n\n${Bc}`);let i=n.memory?t.slice(-10):t;return[{role:`system`,content:r},...i]}function Rl(e){if(!/(?:^|[\s\n])\/$/.test(e))return null;let t=e.lastIndexOf(`/`);return t<0?null:{from:t}}function zl(e){let t=/(?:^|[\s\n])@([^\s@]*)$/.exec(e);if(!t)return null;let n=e.lastIndexOf(`@`);return n<0?null:{from:n,query:t[1]??``}}function Bl(e){let t=/\s*(?:[((](?:recommended|推荐)[))])\s*$/i;return t.test(e)?{label:e.replace(t,``),recommended:!0}:{label:e,recommended:!1}}var Vl=pe,Hl=5,Ul=[`image/png`,`image/jpeg`,`image/jpg`,`image/webp`,`image/gif`];function Wl(e){let t=[];if(e.content&&t.push(e.content),e.refs?.length){let n=e.refs.filter(e=>e.collection!==`workspace`),r=e.refs.filter(e=>e.collection===`workspace`);if(n.length){let e=n.filter(e=>e.collection===`knowledge`||e.collection===`templates`),r=n.filter(e=>e.collection===`prompts`||e.collection===`cases`);if(e.length){let n=e.map(e=>`- ${e.path} 《${e.title}》(${e.category} · ${Jc(e.format)})`);t.push(`引用项目文档(请使用 kb_read 读取):\n${n.join(`
|
|
250
|
-
`)}`)}if(r.length){let e=r.map(e=>`- ${e.collection}/${e.path} 《${e.title}》(${e.category})`);t.push(`引用管理文档(路径已给出,正文可能已在上文):\n${e.join(`
|
|
251
|
-
`)}`)}}if(r.length){let e=r.map(e=>`- ${e.path} 《${e.title}》(${e.format===`dir`?`文件夹`:`文件`})`);t.push(`引用工作区路径(请使用 fs_list / fs_read):\n${e.join(`
|
|
252
|
-
`)}`)}}return e.attachments?.length&&t.push(e.attachments.map(e=>`附件《${e.name}》:\n\`\`\`\`\n${e.content}\n\`\`\`\``).join(`
|
|
253
|
-
|
|
254
|
-
`)),t.join(`
|
|
255
|
-
|
|
256
|
-
`)}function Gl(e){let t=Wl(e);if(!e.images?.length)return t;let n=[];t?n.push({type:`text`,text:t}):n.push({type:`text`,text:`请查看图片。`});for(let t of e.images)n.push({type:`image_url`,image_url:{url:t.dataUrl}});return n}function Kl(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result??``)),r.onerror=()=>n(Error(`读取图片失败`)),r.readAsDataURL(e)})}async function ql(e){if(!Ul.includes(e.type)&&!/\.(png|jpe?g|webp|gif)$/i.test(e.name))throw Error(`${e.name||`图片`}:不支持的格式`);if(e.size>10485760)throw Error(`${e.name||`图片`}:超过 ${Math.round(tl/1024/1024)} MB`);let t=await Kl(e);if(!t.startsWith(`data:image/`))throw Error(`无法识别为图片`);return{id:`img_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,name:e.name||`paste-${new Date().toISOString().slice(11,19).replace(/:/g,``)}.png`,size:e.size,mime:e.type||`image/png`,dataUrl:t}}function Jl(e,t){return e.length+t.length}var Yl=[{value:`low`,label:`Low`,desc:`响应更快,适合简单问答`},{value:`high`,label:`High`,desc:`质量与速度均衡(默认)`},{value:`max`,label:`Max`,desc:`最深推理,适合复杂分析`}],Xl=[{value:`readonly`,label:`仅可查看`},{value:`readwrite`,label:`工作区内修改`},{value:`full`,label:`完全权限`}];function Zl(e){return e===`present`?`交付文件`:e===`todo_write`?`待办`:e===`ask_user_question`?`向用户提问`:e===`bash`?`Bash`:e===`pwsh`?`PowerShell`:e.startsWith(`bash_session_`)||e.startsWith(`pwsh_session_`)?`持久终端`:e.startsWith(`working_directory_`)?`工作目录`:e.startsWith(`skill_`)?`Skill`:e.startsWith(`workspace_changes_`)?`工作区变更`:e===`load_workspace_dependencies`?`工作区依赖`:e===`office_to_pdf`?`Office转PDF`:e===`submit_plan`?`提交计划`:e.startsWith(`goal_`)?`会话目标`:e.startsWith(`schedule_`)?`定时提醒`:e===`list_agents`||e===`spawn_subagent`||e===`fork_subagent`||e.startsWith(`subagent_`)?`子代理`:e===`workflow`?`工作流`:e===`job_list`?`任务列表`:e===`job_output`?`任务输出`:e===`job_kill`?`终止任务`:e===`web_search`?ot(`tool.kind.webSearch`):e===`web_fetch`?ot(`tool.kind.webFetch`):e.startsWith(`kb_`)?ot(`tool.kind.kb`):e.startsWith(`fs_`)?ot(`tool.kind.fs`):e.startsWith(`memory_`)?ot(`tool.kind.memory`):e}function Ql(e){let t=String(e??``).trim();if(!t)return`请求失败`;if(/service_unavailable|too busy|瞬时繁忙|服务繁忙/i.test(t))return`模型服务瞬时繁忙,请稍后重试`;try{let e=JSON.parse(t),n=e?.error??e;if(n&&typeof n==`object`){let e=`${n.message||``} ${n.code||``} ${n.type||``}`;if(/service_unavailable|too busy/i.test(e))return`模型服务瞬时繁忙,请稍后重试`;if(typeof n.message==`string`&&n.message.trim())return n.message.trim()}}catch{}return t.length>280?`${t.slice(0,280)}…`:t}function $l(e){return e===`present`?`fs`:e===`todo_write`||e===`ask_user_question`||e===`bash`||e===`pwsh`||e.startsWith(`bash_session_`)||e.startsWith(`pwsh_session_`)||e.startsWith(`working_directory_`)||e.startsWith(`skill_`)||e.startsWith(`workspace_changes_`)||e===`load_workspace_dependencies`||e===`office_to_pdf`||e===`submit_plan`||e.startsWith(`goal_`)||e.startsWith(`schedule_`)||e===`list_agents`||e===`spawn_subagent`||e===`fork_subagent`||e.startsWith(`subagent_`)||e===`workflow`||e.startsWith(`job_`)?`tool`:e===`web_search`?`web_search`:e===`web_fetch`?`web_fetch`:e.startsWith(`fs_`)?`fs`:e.startsWith(`kb_`)?`kb`:e.startsWith(`memory_`)?`memory`:`tool`}function eu({kind:e,status:t}){let n=t===`error`?`w-3.5 h-3.5 shrink-0 text-red-500`:t===`running`?`w-3.5 h-3.5 shrink-0 text-stone-500`:`w-3.5 h-3.5 shrink-0 text-stone-400`;return t===`running`&&e===`thinking`?(0,Q.jsx)(`span`,{className:`w-3.5 h-3.5 shrink-0 rounded-full border-2 border-purple-400 border-t-transparent animate-spin`}):e===`thinking`?(0,Q.jsxs)($,{className:n,children:[(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,Q.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`web_search`||e===`web_fetch`?(0,Q.jsxs)($,{className:n,children:[(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,Q.jsx)(`path`,{d:`M2 12h20`}),(0,Q.jsx)(`path`,{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`})]}):e===`fs`||e===`kb`?(0,Q.jsxs)($,{className:n,children:[(0,Q.jsx)(`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`}),(0,Q.jsx)(`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`})]}):e===`memory`?(0,Q.jsx)($,{className:n,children:(0,Q.jsx)(`path`,{d:`M12 2a4 4 0 0 1 4 4v2h2a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2V6a4 4 0 0 1 4-4Z`})}):(0,Q.jsx)($,{className:n,children:(0,Q.jsx)(`path`,{d:`m12 3 1.9 5.8H20l-4.9 3.6 1.9 5.8L12 14.6 7.1 18.2l1.9-5.8L4 8.8h6.1Z`})})}function tu(e,t){if(!t)return``;if(e.startsWith(`web_`))return un(e,t);if(e===`present`)try{let e=(JSON.parse(t).files??[]).map(e=>e.path).filter(Boolean);return e.slice(0,3).join(`, `)+(e.length>3?`…`:``)}catch{return``}try{let n=JSON.parse(t);if(e===`submit_plan`){let e=typeof n.title==`string`?n.title.trim():``;return e.length>60?`${e.slice(0,60)}…`:e}if(e===`bash`||e===`pwsh`){let e=typeof n.command==`string`?n.command.trim():``,t=n.background===!0?` [bg]`:``;return`${e.length>80?`${e.slice(0,80)}…`:e}${t}`}if(e.startsWith(`bash_session_`)||e.startsWith(`pwsh_session_`)){let e=typeof n.sessionId==`string`?n.sessionId.trim():``,t=typeof n.command==`string`?n.command.trim():``;return[e,t.length>48?`${t.slice(0,48)}…`:t].filter(Boolean).join(` · `)}if(e.startsWith(`working_directory_`)){let e=typeof n.path==`string`?n.path.trim():``;return[typeof n.id==`string`?n.id.trim():``,e].filter(Boolean).join(` · `)}if(e.startsWith(`skill_`))return[typeof n.name==`string`?n.name.trim():``,typeof n.path==`string`?n.path.trim():``].filter(Boolean).join(` · `);if(e.startsWith(`workspace_changes_`))return``;if(e.startsWith(`job_`))return typeof n.jobId==`string`?n.jobId.trim():``;if(e.startsWith(`schedule_`)){let e=typeof n.text==`string`?n.text.trim():``,t=typeof n.id==`string`?n.id.trim():``,r=typeof n.dueAt==`string`?n.dueAt.trim():``,i=typeof n.delayMinutes==`number`&&Number.isFinite(n.delayMinutes)?`+${n.delayMinutes}m`:``;return[e,t,r||i].filter(Boolean).join(` · `)}if(e===`list_agents`||e===`spawn_subagent`||e===`fork_subagent`||e.startsWith(`subagent_`)){let t=typeof n.agent==`string`?n.agent.trim():``,r=typeof n.prompt==`string`?n.prompt.trim():``,i=typeof n.id==`string`?n.id.trim():``,a=r.length>48?`${r.slice(0,48)}…`:r;return[e===`fork_subagent`?`fork`:``,t,i,a].filter(Boolean).join(` · `)}if(e===`workflow`){let e=n.meta;return(typeof e?.name==`string`?e.name.trim():``)||`workflow`}if(e===`fs_glob`||e===`fs_grep`){let e=typeof n.pattern==`string`?n.pattern.trim():``;return[e,typeof n.path==`string`?n.path.trim():``].filter(Boolean).join(` @ `)||e}if(typeof n.path==`string`&&n.path.trim())return n.path.trim();if(typeof n.query==`string`&&n.query.trim())return n.query.trim()}catch{}return``}function nu(e){let t=``,n=0,r=/\r?\n(?:[\t ]*\r?\n)+/g;for(;;){let i=r.exec(e),a=i===null?e.length:i.index+i[0].indexOf(`
|
|
257
|
-
`),o=e.indexOf(`
|
|
258
|
-
`,n);if(o!==-1&&o<=a){let r=e.slice(n,o).trim();r!==``&&(t=r)}if(i===null)return t;n=i.index+i[0].length}}function ru(e,t,n,r){return e===`concise`?r===`running`?ot(`tool.running`):null:e===`standard`?ot(r===`running`?`tool.callingKind`:`tool.doneKind`,{kind:t}):ot(e===`detailed`?r===`running`?`tool.callingNamed`:`tool.doneNamed`:r===`running`?`tool.callingFull`:`tool.doneFull`,{kind:t,name:n})}function $({className:e=``,children:t}){return(0,Q.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:t})}var iu=({className:e=``})=>(0,Q.jsx)($,{className:e,children:(0,Q.jsx)(`path`,{d:`m6 9 6 6 6-6`})}),au=({className:e=``})=>(0,Q.jsx)($,{className:e,children:(0,Q.jsx)(`path`,{d:`m9 18 6-6-6-6`})}),ou=({className:e=``})=>(0,Q.jsx)($,{className:e,children:(0,Q.jsx)(`path`,{d:`M20 6 9 17l-5-5`})}),su=({className:e=``})=>(0,Q.jsxs)($,{className:e,children:[(0,Q.jsx)(`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`}),(0,Q.jsx)(`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`})]}),cu=({className:e=``})=>(0,Q.jsxs)($,{className:e,children:[(0,Q.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}),(0,Q.jsx)(`path`,{d:`M3 5v14a9 3 0 0 0 18 0V5`}),(0,Q.jsx)(`path`,{d:`M3 12a9 3 0 0 0 18 0`})]}),lu=({className:e=``})=>(0,Q.jsxs)($,{className:e,children:[(0,Q.jsx)(`path`,{d:`m12 14 4-4`}),(0,Q.jsx)(`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`})]}),uu=({className:e=``})=>(0,Q.jsxs)($,{className:e,children:[(0,Q.jsx)(`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`}),(0,Q.jsx)(`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`})]}),du=({className:e=``})=>(0,Q.jsx)($,{className:e,children:(0,Q.jsx)(`path`,{d:`m16.5 9.4-7.07 7.07a3 3 0 0 1-4.24-4.24l7.07-7.07a2 2 0 1 1 2.83 2.83L8.02 14.1a1 1 0 0 1-1.41-1.41l7.07-7.07`})}),fu=({className:e=``})=>(0,Q.jsxs)($,{className:e,children:[(0,Q.jsx)(`path`,{d:`m5 12 7-7 7 7`}),(0,Q.jsx)(`path`,{d:`M12 19V5`})]}),pu=({className:e=``,open:t=!1})=>(0,Q.jsx)($,{className:e,children:t?(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6A2 2 0 0 1 18.45 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.69.9H18a2 2 0 0 1 2 2v2`})}):(0,Q.jsx)(`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9l-.81-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`})}),mu=({className:e=``,open:t=!1})=>(0,Q.jsx)(`svg`,{className:`${e} tw-arrow ${t?`is-open`:``}`,viewBox:`0 0 12 12`,fill:`currentColor`,"aria-hidden":!0,children:(0,Q.jsx)(`path`,{d:`M4.2 2.4a.75.75 0 0 1 1.2-.57l4.2 3.35a.75.75 0 0 1 0 1.14l-4.2 3.35A.75.75 0 0 1 4.2 9.1V2.9Z`})}),hu=({className:e=``})=>(0,Q.jsxs)($,{className:e,children:[(0,Q.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,Q.jsx)(`path`,{d:`m21 21-4.3-4.3`})]}),gu=({className:e=``})=>(0,Q.jsxs)($,{className:e,children:[(0,Q.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}),(0,Q.jsx)(`path`,{d:`M12 8v8`}),(0,Q.jsx)(`path`,{d:`M8 12h8`})]}),_u=({className:e=``,filled:t=!1})=>(0,Q.jsx)($,{className:e,children:t?(0,Q.jsx)(`path`,{fill:`currentColor`,stroke:`none`,d:`M12 2a3 3 0 0 1 3 3v3.5l2.5 2.5V13h-3.5V20l-1.5 2-1.5-2v-7H7.5v-2L10 8.5V5a3 3 0 0 1 3-3Z`}):(0,Q.jsx)(`path`,{d:`M12 17v5M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16h14v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6a2 2 0 0 0-2-2h-2a2 2 0 0 0-2 2z`})}),vu=({className:e=``})=>(0,Q.jsxs)($,{className:e,children:[(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,Q.jsx)(`circle`,{cx:`5`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,Q.jsx)(`circle`,{cx:`19`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`})]}),yu=({className:e=``})=>(0,Q.jsxs)($,{className:e,children:[(0,Q.jsx)(`path`,{d:`M4 8h16v11a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V8Z`}),(0,Q.jsx)(`path`,{d:`M8 8V5a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v3`}),(0,Q.jsx)(`path`,{d:`M10 12h4`})]}),bu=({className:e=``})=>(0,Q.jsxs)($,{className:e,children:[(0,Q.jsx)(`path`,{d:`M12 22v-5`}),(0,Q.jsx)(`path`,{d:`M9 8V2`}),(0,Q.jsx)(`path`,{d:`M15 8V2`}),(0,Q.jsx)(`path`,{d:`M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z`})]});function xu(e){let t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return`刚刚`;let n=Math.floor(t/60);if(n<60)return`${n}分钟`;let r=Math.floor(n/60);if(r<24)return`${r}小时`;let i=Math.floor(r/24);if(i<30)return`${i}天`;let a=Math.floor(i/30);return a<12?`${a}个月`:`${Math.floor(a/12)}年`}function Su(e){let t=xu(e);return t===`刚刚`?`刚刚`:t.endsWith(`前`)?t:`${t}前`}function Cu({open:e,onToggle:t,onRename:n,onDelete:r}){let i=(0,z.useRef)(null);return(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{ref:i,type:`button`,"aria-label":`更多`,onClick:e=>{e.stopPropagation(),t()},className:`w-6 h-6 flex items-center justify-center rounded text-(--tw-label-tertiary) hover:text-(--tw-label-primary) hover:bg-(--tw-session-hover-bg)`,children:(0,Q.jsx)(vu,{className:`w-3.5 h-3.5`})}),(0,Q.jsxs)(wu,{open:e,anchorRef:i,dataAttr:`data-ws-menu`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[13px] text-stone-700 hover:bg-stone-50`,onClick:e=>{e.stopPropagation(),n()},children:[(0,Q.jsxs)($,{className:`w-3.5 h-3.5`,children:[(0,Q.jsx)(`path`,{d:`M12 20h9`}),(0,Q.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),`重命名`]}),r?(0,Q.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[13px] text-red-600 hover:bg-red-50`,onClick:e=>{e.stopPropagation(),r()},children:[(0,Q.jsxs)($,{className:`w-3.5 h-3.5`,children:[(0,Q.jsx)(`path`,{d:`M3 6h18`}),(0,Q.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,Q.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`})]}),`删除工作区`]}):null]})]})}function wu({open:e,anchorRef:t,dataAttr:n,children:r}){let[i,a]=(0,z.useState)(null);return(0,z.useLayoutEffect)(()=>{if(!e){a(null);return}let n=()=>{let e=t.current;if(!e)return;let n=e.getBoundingClientRect(),r=n.bottom+200>window.innerHeight-8,i=Math.max(8,Math.min(n.left,window.innerWidth-160-8));a({top:r?n.top-4:n.bottom+4,left:i,openUp:r})};return n(),window.addEventListener(`scroll`,n,!0),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`scroll`,n,!0),window.removeEventListener(`resize`,n)}},[e,t]),!e||!i||typeof document>`u`?null:(0,fn.createPortal)((0,Q.jsx)(`div`,{[n]:``,className:`tw-popover tw-popover-anim z-80 w-40 rounded-xl border border-stone-200 py-1 shadow-lg`,style:{position:`fixed`,top:i.top,left:i.left,transform:i.openUp?`translateY(-100%)`:void 0},children:r}),document.body)}function Tu({s:e,nested:t=!1,active:n,menuOpen:r,busy:i,onOpen:a,onRename:o,onToggleMenu:s,onTogglePin:c,onToggleArchive:l,onExport:u,onRemove:d,onRestore:f}){let p=(0,z.useRef)(null),m=(0,z.useRef)(null),h=(0,z.useRef)(null),g=(0,z.useRef)(null),_=(0,z.useRef)(null),ee=(0,z.useRef)(null),[v,y]=(0,z.useState)(!1),[b,x]=(0,z.useState)(!1),[S,C]=(0,z.useState)(null);function w(){_.current!=null&&(clearTimeout(_.current),_.current=null)}function T(){ee.current!=null&&(clearTimeout(ee.current),ee.current=null)}function E(){T(),ee.current=setTimeout(()=>{x(!1),w()},180)}function D(){T(),w(),_.current=setTimeout(()=>x(!0),1e3)}let te=Sn(Array.isArray(e.messages)?e.messages:[]).trim().replace(/\s+/g,` `)||e.title||`新对话`;(0,z.useLayoutEffect)(()=>{let e=h.current,t=g.current;if(!e||!t)return;let n=()=>{t.style.maxWidth=`none`,t.style.overflow=`visible`,t.style.display=`inline-block`;let n=t.scrollWidth;t.style.maxWidth=``,t.style.overflow=``,t.style.display=``;let r=e.clientWidth,i=n>r+1;y(i),i?t.style.setProperty(`--tw-marquee-shift`,`${Math.min(0,r-n-28)}px`):t.style.removeProperty(`--tw-marquee-shift`)};n();let r=typeof ResizeObserver<`u`?new ResizeObserver(n):null;return r?.observe(e),()=>r?.disconnect()},[e.title]),(0,z.useLayoutEffect)(()=>{if(!b||r){C(null);return}let e=()=>{let e=p.current;if(!e)return;let t=e.getBoundingClientRect();C({top:t.top+t.height/2,left:t.right+8})};return e(),window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[b,r,e.title]),(0,z.useEffect)(()=>{r&&(w(),T(),x(!1))},[r]);let ne=i?`生成中`:`空闲`,O=!!(e.archived||e.deleted);return(0,Q.jsxs)(`div`,{ref:p,className:`tw-session-row relative ${t?`is-nested`:``} ${n?`is-selected`:``} ${r?`is-menu-open`:``} ${i?`is-busy`:``} ${O?`opacity-50`:``}`,onMouseLeave:()=>{w(),E()},children:[i?(0,Q.jsx)(`span`,{className:`tw-session-busy-slot`,"data-hint":`生成中`,"aria-label":`生成中`,children:(0,Q.jsx)(`span`,{className:`tw-session-busy-dot`,"aria-hidden":!0})}):null,e.pinned&&!O?(0,Q.jsx)(`span`,{className:`tw-slot`,"aria-hidden":!0,children:(0,Q.jsx)(_u,{filled:!0,className:`tw-pin-indicator w-3 h-3`})}):null,(0,Q.jsx)(`button`,{ref:h,type:`button`,onClick:a,onDoubleClick:o,onMouseEnter:()=>D(),onMouseLeave:()=>{w(),E()},className:`tw-session-title text-left outline-none focus:outline-none focus-visible:outline-none ${v?`is-overflow`:``}`,children:(0,Q.jsx)(`span`,{ref:g,className:`tw-session-title-inner`,children:e.title})}),(0,Q.jsx)(`span`,{className:`tw-session-time pr-1`,children:xu(e.updatedAt)}),(0,Q.jsxs)(`div`,{"data-session-menu":``,className:`tw-row-actions items-center gap-0.5 shrink-0`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`button`,{ref:m,type:`button`,"aria-label":`更多`,onClick:s,className:`tw-session-action-btn w-6 h-6 flex items-center justify-center rounded`,children:(0,Q.jsx)(vu,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(wu,{open:r,anchorRef:m,dataAttr:`data-session-menu`,children:e.deleted?(0,Q.jsxs)(Q.Fragment,{children:[f?(0,Q.jsx)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[13px] text-stone-700 hover:bg-stone-50`,onClick:f,children:`恢复会话`}):null,(0,Q.jsx)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[13px] text-red-600 hover:bg-red-50`,onClick:d,children:`永久删除`})]}):(0,Q.jsxs)(Q.Fragment,{children:[!e.archived&&(0,Q.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[13px] text-stone-700 hover:bg-stone-50`,onClick:c,children:[(0,Q.jsx)(_u,{filled:!!e.pinned,className:`w-3.5 h-3.5`}),e.pinned?`取消置顶`:`置顶会话`]}),(0,Q.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[13px] text-stone-700 hover:bg-stone-50`,onClick:o,children:[(0,Q.jsxs)($,{className:`w-3.5 h-3.5`,children:[(0,Q.jsx)(`path`,{d:`M12 20h9`}),(0,Q.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]}),`重命名`]}),(0,Q.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[13px] text-stone-700 hover:bg-stone-50`,onClick:l,children:[(0,Q.jsx)(yu,{className:`w-3.5 h-3.5`}),e.archived?`取消归档`:`归档会话`]}),(0,Q.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[13px] text-stone-700 hover:bg-stone-50`,onClick:u,children:[(0,Q.jsxs)($,{className:`w-3.5 h-3.5`,children:[(0,Q.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,Q.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,Q.jsx)(`line`,{x1:`12`,x2:`12`,y1:`15`,y2:`3`})]}),`导出会话`]}),e.archived?(0,Q.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-[13px] text-red-600 hover:bg-red-50`,onClick:d,children:[(0,Q.jsxs)($,{className:`w-3.5 h-3.5`,children:[(0,Q.jsx)(`path`,{d:`M3 6h18`}),(0,Q.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,Q.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`})]}),`永久删除`]}):null]})})]}),!e.deleted&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":e.archived?`取消归档`:`归档会话`,"data-hint":e.archived?`取消归档`:`归档会话`,onClick:l,className:`tw-session-action-btn w-6 h-6 flex items-center justify-center rounded`,children:(0,Q.jsx)(yu,{className:`w-3.5 h-3.5`})}),!e.archived&&!e.deleted&&(0,Q.jsx)(`button`,{type:`button`,"data-hint":e.pinned?`取消置顶`:`置顶`,onClick:c,className:`tw-session-action-btn w-6 h-6 flex items-center justify-center rounded`,children:(0,Q.jsx)(_u,{filled:!!e.pinned,className:`w-3.5 h-3.5`})})]}),b&&!r&&S&&typeof document<`u`?(0,fn.createPortal)((0,Q.jsxs)(`div`,{className:`tw-session-preview`,role:`tooltip`,style:{position:`fixed`,top:S.top,left:S.left,transform:`translateY(-50%)`},onMouseEnter:()=>{w(),T(),x(!0)},onMouseLeave:()=>E(),children:[(0,Q.jsx)(`div`,{className:`tw-session-preview-title`,children:te}),(0,Q.jsx)(`div`,{className:`tw-session-preview-meta`,children:Su(e.updatedAt)}),(0,Q.jsx)(`div`,{className:`tw-session-preview-status ${i?`is-busy`:``}`,children:ne})]}),document.body):null]})}var Eu=`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`;function Du({level:e,className:t=``}){return(0,Q.jsxs)($,{className:t,children:[(0,Q.jsx)(`path`,{d:Eu}),e===`readonly`&&(0,Q.jsx)(`path`,{d:`m9 12 2 2 4-4`}),e===`readwrite`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`path`,{d:`M9 10h6`}),(0,Q.jsx)(`path`,{d:`M9 14h3`})]}),e===`full`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`path`,{d:`M12 8v4`}),(0,Q.jsx)(`path`,{d:`M12 16h.01`})]})]})}function Ou(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ku(e){return`${e.toLocaleString(`en-US`)} tok`}function Au(e){let t=e/1e3;if(t<60)return`${Math.round(t*10)/10} 秒`;let n=Math.round(t);return`${Math.floor(n/60)} 分 ${n%60} 秒`}function ju(e){return e>=99.95?`100`:e>=10?String(Math.round(e)):e.toFixed(1)}function Mu(e){let t=0;for(let n of e)t+=/[\u4e00-\u9fff]/.test(n)?1:.25;return Math.max(1,Math.round(t))}function Nu(e){return e.uncachedTokens==null?e.cachedTokens==null?e.promptTokens:Math.max(0,e.promptTokens-e.cachedTokens):e.uncachedTokens}function Pu(e){return e?typeof e.completionTokens==`number`&&e.completionTokens>0?e.completionTokens:typeof e.totalTokens==`number`&&typeof e.promptTokens==`number`?Math.max(0,e.totalTokens-e.promptTokens):typeof e.completionTokens==`number`?Math.max(0,e.completionTokens):0:0}function Fu(e,t){return t<=0?null:e/t*100}function Iu(e){return e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function Lu(e){let t=new Date(e),n=`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`;return t.toDateString()===new Date().toDateString()?n:`${t.getMonth()+1}/${t.getDate()} ${n}`}async function Ru(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{let t=document.createElement(`textarea`);t.value=e,t.style.cssText=`position:fixed;opacity:0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}}function zu({text:e}){let[t,n]=(0,z.useState)(!1),r=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>{r.current!==null&&window.clearTimeout(r.current)},[]);async function i(){t||await Ru(e)&&(n(!0),r.current=window.setTimeout(()=>n(!1),1e3))}return(0,Q.jsx)(`button`,{type:`button`,onClick:i,"aria-label":t?`已复制`:`复制`,className:`tw-icon-btn tw-msg-action-btn inline-flex items-center justify-center rounded-md transition-colors`,children:t?(0,Q.jsx)(ou,{className:`w-3.5 h-3.5 text-emerald-600`}):(0,Q.jsx)(su,{className:`w-3.5 h-3.5`})})}function Bu({pct:e}){return(0,Q.jsxs)(`svg`,{className:`w-3.5 h-3.5 -rotate-90`,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:[(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:`8`,fill:`none`,stroke:`var(--color-stone-200)`,strokeWidth:`3`}),(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:`8`,fill:`none`,stroke:`#4176e6`,strokeWidth:`3`,strokeLinecap:`round`,strokeDasharray:`${Math.max(e,1)/100*50.27} 50.27`})]})}function Vu(){let[e,t]=(0,z.useState)(!1),n=(0,z.useRef)(null),r=(0,z.useRef)(null),[i,a]=(0,z.useState)(null);return(0,z.useEffect)(()=>{if(!e){a(null);return}let t=()=>{let e=n.current,t=r.current;if(!e||!t)return;let i=e.getBoundingClientRect(),o=t.getBoundingClientRect(),s=i.left+i.width/2-o.width/2;s=Math.max(12,Math.min(s,window.innerWidth-o.width-12));let c=i.top-o.height-8;c<12&&(c=i.bottom+8),a({position:`fixed`,left:s,top:c,visibility:`visible`})};a({position:`fixed`,left:0,top:0,visibility:`hidden`});let i=requestAnimationFrame(t);return window.addEventListener(`resize`,t),window.addEventListener(`scroll`,t,!0),()=>{cancelAnimationFrame(i),window.removeEventListener(`resize`,t),window.removeEventListener(`scroll`,t,!0)}},[e]),(0,z.useEffect)(()=>{if(!e)return;let i=e=>{e.key===`Escape`&&t(!1)},a=e=>{let i=e.target;n.current?.contains(i)||r.current?.contains(i)||t(!1)};return document.addEventListener(`keydown`,i),document.addEventListener(`click`,a,!0),()=>{document.removeEventListener(`keydown`,i),document.removeEventListener(`click`,a,!0)}},[e]),{open:e,setOpen:t,rootRef:n,panelRef:r,pos:i}}function Hu({title:e,titleValue:t,icon:n,children:r}){return(0,Q.jsxs)(`div`,{className:`tw-popover w-[min(320px,calc(100vw-24px))] rounded-2xl border border-stone-200 p-3.5 shadow-xl text-left`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px]`,children:[n,(0,Q.jsx)(`span`,{className:`tw-popover-title font-medium text-stone-800`,children:e}),t!==void 0&&(0,Q.jsx)(`span`,{className:`tw-popover-muted ml-auto text-stone-500 tabular-nums`,children:t})]}),(0,Q.jsx)(`div`,{className:`mt-2.5 mb-2.5 border-t border-stone-100`}),r]})}function Uu({rows:e}){return(0,Q.jsx)(`dl`,{className:`grid grid-cols-[1fr_auto] gap-x-6 gap-y-2 text-[13px]`,children:e.filter(e=>!e.hide).map(e=>(0,Q.jsxs)(`div`,{className:`contents`,children:[(0,Q.jsx)(`dt`,{className:`text-stone-500`,children:e.label}),(0,Q.jsx)(`dd`,{className:`text-stone-800 tabular-nums text-right`,children:e.value})]},e.label))})}function Wu({label:e,icon:t,ariaLabel:n,title:r,titleValue:i,children:a,variant:o=`pill`}){let{open:s,setOpen:c,rootRef:l,panelRef:u,pos:d}=Vu();return(0,Q.jsxs)(`span`,{ref:l,className:`relative inline-flex items-center`,children:[(0,Q.jsxs)(`button`,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":s,"aria-label":n,onClick:()=>c(!s),className:o===`ghost`?`tw-msg-action-meta inline-flex items-center gap-1 tabular-nums transition-colors ${s?`text-stone-600`:`text-stone-400 hover:text-stone-600`}`:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full transition-colors ${s?`bg-stone-200/70 text-stone-600`:`hover:bg-stone-200/60 hover:text-stone-600`}`,children:[t,(0,Q.jsx)(`span`,{className:`leading-none`,children:e})]}),s&&(0,fn.createPortal)((0,Q.jsx)(`div`,{ref:u,role:`dialog`,"aria-label":r,style:d??{position:`fixed`,left:0,top:0,visibility:`hidden`},className:`z-80`,children:(0,Q.jsx)(Hu,{title:r,titleValue:i,icon:t,children:a})}),document.body)]})}function Gu({messages:e,busy:t,onRestoreCheckpoint:n}){let[r,i]=(0,z.useState)(()=>new Set),a=(0,z.useMemo)(()=>zn(e.map(e=>({role:e.role,content:typeof e.content==`string`?e.content:Wl(e),time:e.time}))),[e]);function o(e){i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return a.length?(0,Q.jsx)(`ol`,{className:`list-none m-0 p-0 w-full max-w-[min(64rem,100%)] mx-auto space-y-2`,children:a.map(e=>{let i=r.has(e.index),a=!!e.assistantText;return(0,Q.jsxs)(`li`,{className:`rounded-xl border bg-white shadow-sm overflow-hidden ${i?`border-[#4176e6]/35`:`border-stone-200`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-1 px-3 py-2.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>o(e.index),"aria-expanded":i,className:`min-w-0 flex-1 text-left hover:bg-stone-50/80 rounded-lg -mx-1 px-1 py-0.5 transition-colors`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,Q.jsxs)(`span`,{className:`text-[11px] font-medium text-stone-400 tabular-nums`,children:[`第 `,e.index,` 轮`]}),(0,Q.jsx)(iu,{className:`w-3.5 h-3.5 text-stone-400 ml-auto shrink-0 transition-transform ${i?`rotate-180`:``}`})]}),i?null:(0,Q.jsxs)(`div`,{className:`space-y-1 text-[13px] leading-5`,children:[(0,Q.jsxs)(`p`,{className:`m-0 text-stone-800 truncate`,children:[(0,Q.jsx)(`span`,{className:`text-stone-400 mr-1.5`,children:`用户`}),e.userPreview]}),(0,Q.jsxs)(`p`,{className:`m-0 text-stone-600 truncate`,children:[(0,Q.jsx)(`span`,{className:`text-stone-400 mr-1.5`,children:`助手`}),e.assistantPreview||`(待回复)`]})]})]}),n?(0,Q.jsx)(`button`,{type:`button`,disabled:t||!a,"data-hint":a?`截断到本轮末,填入续写并发送`:`待本轮助手回复完成后可从此处继续`,className:`shrink-0 mt-0.5 text-[11px] text-[#4176e6] hover:underline disabled:opacity-40 disabled:no-underline px-1 whitespace-nowrap`,onClick:()=>n(e.endMessageIndex,e.index),children:`从此处继续`}):null]}),i?(0,Q.jsxs)(`div`,{className:`px-3 pb-3 space-y-2.5 text-[13px] leading-5 border-t border-stone-100 pt-2.5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-[11px] font-medium text-stone-400 mb-0.5`,children:`用户`}),(0,Q.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-stone-800`,children:e.userText||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`div`,{className:`text-[11px] font-medium text-stone-400 mb-0.5`,children:`助手`}),e.assistantText?(0,Q.jsx)(`div`,{className:`chat-md prose prose-sm prose-stone max-w-none tw-chat-text`,dangerouslySetInnerHTML:{__html:Ka(e.assistantText)}}):(0,Q.jsx)(`div`,{className:`text-stone-400`,children:`(待回复)`})]})]}):null]},e.index)})}):(0,Q.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-stone-400`,children:`暂无回合(还没有用户/助手对话)`})}function Ku({messages:e,model:t,systemPromptTokens:n}){let r=e.filter(e=>e.role===`assistant`&&e.usage);if(!r.length)return null;let i=r[r.length-1],a=e.filter(e=>e.role===`user`).length,o=r.length,s=r.reduce((e,t)=>e+(t.usage?.totalTokens??0),0),c=r.reduce((e,t)=>e+(t.usage?.promptTokens??0),0),l=r.reduce((e,t)=>e+(t.usage?.cachedTokens??0),0),u=r.reduce((e,t)=>e+(t.usage?Nu(t.usage):0),0),d=r.reduce((e,t)=>e+(t.usage?.cacheWriteTokens??0),0),f=r.reduce((e,t)=>e+Pu(t.usage),0),p=r.some(e=>e.usage?.cachedTokens!=null),m=p?Fu(l,c):null,h=r.reduce((e,t)=>e+(t.llmMs??0),0),g=r.reduce((e,t)=>e+(t.toolMs??0),0),_=r.map(e=>e.ttftMs).filter(e=>e!=null&&e>0),ee=_.length?_.reduce((e,t)=>e+t,0)/_.length:0,v=r.reduce((e,t)=>t.llmMs==null||t.ttftMs==null?e:e+Math.max(0,t.llmMs-t.ttftMs),0),y=r.map(e=>e.tps).filter(e=>e!=null&&e>0),b=y.length?y.reduce((e,t)=>e+t,0)/y.length:void 0,x=v>200&&f>0?f/(v/1e3):b??(i.tps&&i.tps>0?i.tps:void 0),S=t?oe[t]:void 0,C=i.usage?.promptTokens??0,w=S?Math.min(100,C/S*100):void 0,T=Math.min(n,C),E=Math.max(0,C-T);return(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-1 pt-2 text-xs text-stone-400 tabular-nums select-none`,children:[(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(lu,{className:`w-3.5 h-3.5`}),label:(0,Q.jsxs)(Q.Fragment,{children:[a,` 轮 `,o,` 步`,x?` · ${Math.round(x)} tok/s`:``]}),ariaLabel:`会话统计`,title:`会话统计`,children:(0,Q.jsx)(Uu,{rows:[{label:`模型用时`,value:h>0?Au(h):`—`},{label:`工具调用用时`,value:g>0?Au(g):`—`},{label:`首 token 平均 (TTFT)`,value:_.length?Au(ee):`—`},{label:`输出速度 (TPS)`,value:x?`${Math.round(x)} tok/s`:`—`}]})}),(0,Q.jsx)(Wu,{icon:(0,Q.jsx)(cu,{className:`w-3.5 h-3.5`}),label:(0,Q.jsxs)(Q.Fragment,{children:[Ou(s),` tok`,m==null?``:` · 缓存命中 ${ju(m)}%`]}),ariaLabel:`Token 用量`,title:`Token 用量`,titleValue:ku(s),children:(0,Q.jsx)(Uu,{rows:[{label:`缓存命中`,value:m==null?`—`:`${ju(m)}%`,hide:m==null},{label:`未缓存输入`,value:ku(u)},{label:`缓存读取`,value:ku(l),hide:!p},{label:`缓存写入`,value:ku(d),hide:d<=0},{label:`输出`,value:ku(f)}]})}),w!==void 0&&S&&(0,Q.jsxs)(Wu,{icon:(0,Q.jsx)(Bu,{pct:w}),label:`${ju(w)}%`,ariaLabel:`上下文占用`,title:`上下文已用 ${ju(w)}%`,titleValue:`~${Ou(C)} / ${Ou(S)}`,children:[(0,Q.jsxs)(`div`,{className:`h-2 rounded-full bg-stone-100 overflow-hidden flex mb-3`,children:[(0,Q.jsx)(`span`,{className:`h-full bg-stone-400`,style:{width:`${T/S*100}%`},"data-hint":`系统提示词`}),(0,Q.jsx)(`span`,{className:`h-full bg-[#4176e6]`,style:{width:`${E/S*100}%`},"data-hint":`对话消息`})]}),(0,Q.jsx)(Uu,{rows:[{label:`系统提示词`,value:`~${Ou(T)}`},{label:`对话消息`,value:`~${Ou(E)}`}]}),(0,Q.jsx)(`p`,{className:`mt-2.5 text-[11px] leading-4 text-stone-400`,children:`分段为示意估算(API 不返回上下文拆分);总量以最近一轮 prompt_tokens 为准。`})]})]})}function qu({usage:e,model:t}){let n=e.cachedTokens==null?null:Fu(e.cachedTokens,e.promptTokens);return(0,Q.jsx)(Wu,{variant:`ghost`,icon:(0,Q.jsx)(cu,{className:`w-3.5 h-3.5 shrink-0`}),label:(0,Q.jsxs)(Q.Fragment,{children:[`用量 `,Ou(e.totalTokens),` tok`]}),ariaLabel:`本轮用量`,title:`本轮用量`,titleValue:ku(e.totalTokens),children:(0,Q.jsx)(Uu,{rows:[{label:`提供方 / 模型`,value:t??`—`,hide:!t},{label:`缓存命中`,value:n==null?`—`:`${ju(n)}%`,hide:n==null},{label:`未缓存输入`,value:ku(Nu(e))},{label:`缓存读取`,value:ku(e.cachedTokens??0),hide:e.cachedTokens==null},{label:`缓存写入`,value:ku(e.cacheWriteTokens??0),hide:!(e.cacheWriteTokens&&e.cacheWriteTokens>0)},{label:`输出`,value:ku(e.completionTokens)}]})})}function Ju({settings:e}){let[t,n]=(0,z.useState)(!1),[r,i]=(0,z.useState)(null),[a,o]=(0,z.useState)([]),[s,c]=(0,z.useState)(`idle`),l=(0,z.useRef)(null),u=(0,z.useRef)(0);if((0,z.useEffect)(()=>{if(!t)return;let e=()=>{n(!1),i(null)},r=t=>{l.current?.contains(t.target)||e()},a=t=>{t.key===`Escape`&&e()};return document.addEventListener(`mousedown`,r),document.addEventListener(`keydown`,a),()=>{document.removeEventListener(`mousedown`,r),document.removeEventListener(`keydown`,a)}},[t]),(0,z.useEffect)(()=>{if(!t||!e)return;let n=e.availableModels?.length?e.availableModels:[e.model];o(n),c(e.availableModels?.length?`ok`:`loading`);let r=++u.current;k(e.baseURL,e.apiKey).then(t=>{if(r!==u.current)return;let n=t.length?t:[e.model];o(n),c(`ok`),t.length&&I({availableModels:t})}).catch(()=>{r===u.current&&c(n.length>1?`ok`:`fail`)})},[t,e]),!e)return(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>ye(`model`),className:`flex items-center gap-1 h-7 shrink-0 pl-2 pr-1 text-[13px] leading-5 font-medium text-stone-500 rounded-md hover:bg-stone-100 transition-colors`,children:[(0,Q.jsx)(`span`,{className:`whitespace-nowrap`,children:`配置模型`}),(0,Q.jsx)(iu,{className:`w-3.5 h-3.5 shrink-0 text-stone-400`})]});let d=e.reasoningEffort??`high`,f=Yl.find(e=>e.value===d)?.label??`High`;function p(e){I(e),n(!1),i(null)}let m=e=>`w-full flex items-center gap-3 px-3 py-2 rounded-lg text-left text-[13px] transition-colors ${e?`bg-stone-100`:`hover:bg-stone-100`}`;return(0,Q.jsxs)(`div`,{ref:l,className:`relative`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{n(e=>!e),i(null)},className:`tw-composer-bar-model group flex items-center gap-1 h-7 shrink-0 pl-2 pr-1 text-[13px] leading-5 font-medium rounded-md outline-none focus:outline-none focus-visible:outline-none transition-colors ${t?`bg-stone-100`:`hover:bg-stone-100`}`,title:`${e.model} · ${f}`,"aria-label":`模型 ${e.model},推理 ${f}`,children:[(0,Q.jsx)(`span`,{className:`tw-composer-bar-model-name max-w-40 truncate text-stone-600`,children:e.model}),(0,Q.jsx)(`span`,{className:`tw-composer-bar-effort whitespace-nowrap text-stone-400`,children:f}),(0,Q.jsx)(iu,{className:`w-3.5 h-3.5 shrink-0 text-stone-400 transition-transform ${t?`rotate-180`:``}`})]}),t&&(0,Q.jsxs)(`div`,{className:`tw-popover tw-popover-anim absolute bottom-full right-0 mb-2 w-64 rounded-xl border border-stone-200 p-1 shadow-xl z-50`,children:[(0,Q.jsxs)(`button`,{type:`button`,onMouseEnter:()=>i(`model`),onClick:()=>i(`model`),className:m(r===`model`),children:[(0,Q.jsx)(`span`,{className:`text-stone-700`,children:`模型`}),(0,Q.jsx)(`span`,{className:`ml-auto max-w-32 truncate text-stone-400`,children:e.model}),(0,Q.jsx)(au,{className:`w-3.5 h-3.5 text-stone-400`})]}),(0,Q.jsxs)(`button`,{type:`button`,onMouseEnter:()=>i(`effort`),onClick:()=>i(`effort`),className:m(r===`effort`),children:[(0,Q.jsx)(`span`,{className:`text-stone-700`,children:`推理等级`}),(0,Q.jsx)(`span`,{className:`ml-auto text-stone-400`,children:f}),(0,Q.jsx)(au,{className:`w-3.5 h-3.5 text-stone-400`})]}),r===`model`&&(0,Q.jsxs)(`div`,{className:`tw-popover tw-popover-anim absolute right-full bottom-0 mr-1.5 w-64 max-h-72 overflow-y-auto rounded-xl border border-stone-200 p-1 shadow-xl`,children:[s===`loading`&&a.length<=1&&(0,Q.jsx)(`div`,{className:`px-3 py-2 text-xs text-stone-400`,children:`正在识别可用模型…`}),a.map(t=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>p({model:t}),className:m(!1),children:[(0,Q.jsx)(`span`,{className:`flex-1 truncate ${t===e.model?`text-stone-900 font-medium`:`text-stone-600`}`,children:t}),t===e.model&&(0,Q.jsx)(ou,{className:`w-3.5 h-3.5 text-[#4176e6]`})]},t)),(0,Q.jsx)(`div`,{className:`mt-1 border-t border-stone-100 pt-1`,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{n(!1),i(null),ye(`model`)},className:`w-full px-3 py-1.5 rounded-lg text-left text-xs text-stone-400 hover:bg-stone-100`,children:s===`fail`?`识别失败,打开设置检查…`:a.length>1?`打开设置 · 模型…`:`打开设置识别可用模型…`})})]}),r===`effort`&&(0,Q.jsx)(`div`,{className:`tw-popover tw-popover-anim absolute right-full bottom-0 mr-1.5 w-60 rounded-xl border border-stone-200 p-1 shadow-xl`,children:Yl.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>p({reasoningEffort:e.value}),className:`w-full px-3 py-2 rounded-lg text-left hover:bg-stone-100 transition-colors`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`flex-1 ${d===e.value?`text-stone-900 font-medium`:`text-stone-600`}`,children:e.label}),d===e.value&&(0,Q.jsx)(ou,{className:`w-3.5 h-3.5 text-[#4176e6]`})]}),(0,Q.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400`,children:e.desc})]},e.value))})]})]})}var Yu=null;function Xu(){if(!Yu){let e=Qe();Yu={store:e,messages:e.sessions.find(t=>t.id===e.activeId)?.messages??[]}}return Yu}function Zu({slashDocs:e=[]}){let[t,n]=(0,z.useState)(null),[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(()=>Xu().store),[s,l]=(0,z.useState)(()=>Xu().messages),[u,d]=(0,z.useState)(``),[f,p]=(0,z.useState)([]),[m,h]=(0,z.useState)([]),[g,_]=(0,z.useState)([]),[ee,v]=(0,z.useState)(Vl),[y,b]=(0,z.useState)(!1),[x,S]=(0,z.useState)(null),C=(0,z.useRef)(null);C.current=x;let[w,T]=(0,z.useState)(!1),[E,D]=(0,z.useState)(null),te=(0,z.useRef)(null);te.current=E;let[ne,O]=(0,z.useState)(!1),[k,ie]=(0,z.useState)(null),oe=(0,z.useRef)(null);oe.current=k;let[A,j]=(0,z.useState)(null),ue=(0,z.useRef)(null);ue.current=A;let P=(0,z.useRef)(null),[de,fe]=(0,z.useState)(null),[pe,me]=(0,z.useState)(0),[I,Se]=(0,z.useState)(!1),[Ce,Me]=(0,z.useState)(null),[Pe,Qe]=(0,z.useState)(null),[ct,ut]=(0,z.useState)(null),[dt,ft]=(0,z.useState)(null),[pt,bt]=(0,z.useState)(null),[St,Ct]=(0,z.useState)(!1),[Ot,It]=(0,z.useState)([]),[Vt,en]=(0,z.useState)(null),[nn,sn]=(0,z.useState)(`error`);function R(e,t=`error`){sn(t),en(e)}let[cn,ln]=(0,z.useState)(`readonly`),[un,fn]=(0,z.useState)(!1),[pn,yn]=(0,z.useState)(!0),[bn,wn]=(0,z.useState)(!1),[On,kn]=(0,z.useState)(()=>Ae()),[An,jn]=(0,z.useState)(null),[Mn,Pn]=(0,z.useState)(null),[Ln,Rn]=(0,z.useState)(!1),[zn,Vn]=(0,z.useState)(null),[Hn,Gn]=(0,z.useState)(null),[Kn,Yn]=(0,z.useState)(null),[B,Xn]=(0,z.useState)(null),[Qn,$n]=(0,z.useState)(!1),[er,tr]=(0,z.useState)({}),[V,nr]=(0,z.useState)(``),[rr,ir]=(0,z.useState)(!1),[ar,or]=(0,z.useState)(null),[sr,cr]=(0,z.useState)(`dialog`),[lr,ur]=(0,z.useState)(()=>typeof window>`u`?{language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}:xe()),[dr,fr]=(0,z.useState)(!1),[pr,H]=(0,z.useState)(null),[mr,hr]=(0,z.useState)(0),[gr,_r]=(0,z.useState)(!1),[vr,yr]=(0,z.useState)(!1),[br,xr]=(0,z.useState)(!1),[Sr,Cr]=(0,z.useState)(!0),[wr,Tr]=(0,z.useState)([]),[Er,Dr]=(0,z.useState)([]),Or=!!(On.memory&&An?.ok),kr=!!On.knowledge,Ar=!!Kn?.ok,U=!!Mn?.ok,jr=Ln&&!U,Mr=!!zn?.ok,Nr=!!(Hn?.ok&&Hn.available),Pr=(0,z.useRef)(null),Fr=(0,z.useRef)(new Map),Ir=(0,z.useRef)(null),Lr=(0,z.useRef)(new Map),Rr=(0,z.useRef)(new Map),zr=(0,z.useRef)(new Map),Br=(0,z.useRef)(null),Vr=(0,z.useRef)(!1),Hr=(0,z.useRef)(null),Ur=(0,z.useRef)(null),[Wr,Gr]=(0,z.useState)([]),[Kr,qr]=(0,z.useState)(null),Jr=(0,z.useRef)(null),Yr=(0,z.useRef)(0),Xr=(0,z.useRef)(new Set),[Zr,Qr]=(0,z.useState)(`off`),[$r,ei]=(0,z.useState)(null),[ti,ni]=(0,z.useState)(null),[ri,ii]=(0,z.useState)(null),[ai,oi]=(0,z.useState)({}),[si,ci]=(0,z.useState)(0),[li,ui]=(0,z.useState)(!1),[di,fi]=(0,z.useState)(null),[pi,mi]=(0,z.useState)(!1),[hi,gi]=(0,z.useState)(``),_i=(0,z.useRef)([]),vi=(0,z.useRef)(null);function W(e){_i.current=e,Tr(e)}function yi(e){let t=e.content.trim().replace(/\s+/g,` `);if(t)return t.length>28?`${t.slice(0,28)}…`:t;let n=e.files.length+e.imgs.length+e.refs.length;return n>0?`附件 ${n} 项`:`(空消息)`}let bi=(0,z.useRef)(null),xi=(0,z.useRef)(null),Si=(0,z.useRef)(null),Ci=(0,z.useRef)(null),wi=(0,z.useRef)(null),Ti=(0,z.useRef)(null),Ei=(0,z.useRef)(null),Di=(0,z.useRef)(null),Oi=(0,z.useRef)({}),ki=!!(U&&B?.workspace),Ai=zl(u),ji=(()=>{if(!Ai||!kr)return[];let t=Ai.query.toLowerCase();return(t?e.filter(e=>Yc(e,t)):e).slice(0,10)})(),Mi=(()=>{if(!Ai||!ki)return[];let e=Ai.query.toLowerCase(),t=Er.map(e=>({collection:`workspace`,id:`ws:${e.path}`,title:e.name,category:Wt(B?.workspace,B?.projectRoot),description:e.path,format:e.type===`dir`?`dir`:`file`,path:e.path}));return(e?t.filter(t=>Yc(t,e)||t.path.toLowerCase().includes(e)||t.title.toLowerCase().includes(e)):t).slice(0,10)})(),G=[...ji.map(e=>({section:`project`,doc:e})),...Mi.map(e=>({section:`workspace`,doc:e}))],Ni=!(!Ai||gr),Pi=Rl(u),Fi=Ne.filter(e=>e.hasPanel&&On[e.id]),Ii=!!(Pi&&!vr&&!Ni&&Fi.length>0),Li=(0,z.useRef)(!0),Ri=(0,z.useRef)(!1),K=(0,z.useRef)(null),zi=(0,z.useRef)(null),Bi=(0,z.useRef)([]);Bi.current=s,zi.current=B;function q(e){K.current=e,o(e),nt(e)}let Vi=a?.sessions.find(e=>e.id===a.activeId),Hi=Vi?.id,Ui=Vi?.access;(0,z.useEffect)(()=>{Hi&&ln(Ui??ve())},[Hi,Ui]),(0,z.useEffect)(()=>{let e=!1,t=F(()=>n(_e())),r=ke(e=>kn(e)),a=ge(e=>{ur(e),be(e)});return(async()=>{if(await c(),e)return;let t=xe();ur(t),be(t),n(_e()),ln(ve()),kn(Ae()),yn(We());let r=new URLSearchParams(window.location.search),a=r.get(`session`),s=await tt({preferSessionId:a});if(e)return;let u=s;if(a&&!u.sessions.some(e=>e.id===a))try{let e=sessionStorage.getItem(Xe(a));if(e){let t=JSON.parse(e)?.session;t&&t.id===a&&(u={...u,sessions:[t,...u.sessions.filter(e=>e.id!==a)],activeId:a},await Je(u))}}catch{}if(a)try{sessionStorage.removeItem(Xe(a))}catch{}let d=r.get(`focusRoot`),f=r.get(`focusPath`),p=r.get(`attachRoot`),m=r.get(`attachPath`),h=r.get(`attachName`),g=null;if(d&&f)try{g=`${d}:${decodeURIComponent(f).replace(/\\/g,`/`).replace(/^\/+/,``)}`}catch{g=`${d}:${f}`}if(a&&u.sessions.some(e=>e.id===a)&&(u=Le(u,a),nt(u)),g&&fe(g),p&&m){let e=p;if(e===`cases`||e===`prompts`||e===`knowledge`||e===`templates`){let t=m,n=h||``;try{t=decodeURIComponent(m).replace(/\\/g,`/`).replace(/^\/+/,``),h&&(n=decodeURIComponent(h))}catch{}n||=t.split(`/`).pop()||t;let r=(n.split(`.`).pop()||`md`).toLowerCase(),i=e===`cases`?`用例`:e===`prompts`?`提示词`:e===`knowledge`?`知识库`:`模板`;_([{collection:e,id:`${e}:${t}`,title:n,category:i,path:t,format:r}])}}try{let e=new URL(window.location.href);e.searchParams.delete(`session`),e.searchParams.delete(`focusRoot`),e.searchParams.delete(`focusPath`),e.searchParams.delete(`attachRoot`),e.searchParams.delete(`attachPath`),e.searchParams.delete(`attachName`),window.history.replaceState({},``,e.pathname+e.search+e.hash)}catch{}let ee=[];try{ee=(await hn()).map(e=>e.sessionId)}catch{ee=[]}let y=new Set(ee);u=y.size?{...u,sessions:u.sessions.map(e=>{if(y.has(e.id))return e;let t=at(e.messages);return t===e.messages?e:{...e,messages:t}})}:Ve(u);let x=ve();u.sessions.some(e=>!e.access)&&(u={...u,sessions:u.sessions.map(e=>e.access?e:{...e,access:x})}),K.current=u,o(u),nt(u);let C=u.sessions.find(e=>e.id===u.activeId);if(l(C?.messages??[]),S(C?.caseGen?.active?C.caseGen:null),D(C?.promptGen?.active?C.promptGen:null),ie(C?.knowledgeGen?.active?C.knowledgeGen:null),j(C?.pluginDev?.active?C.pluginDev:null),ln(C?.access??x),C?.pluginDev?.active&&(ei(`pluginDev`),C.access!==`readwrite`&&C.access!==`full`)){ln(`readwrite`);let e={...u,sessions:u.sessions.map(e=>e.id===u.activeId?{...e,access:`readwrite`}:e)};K.current=e,o(e),nt(e)}Gr(ss(C?.todos));{let e=Os(C?.goal);Jr.current=e,qr(e)}C?.workspacePath&&tr(e=>({...e,[C.workspacePath]:!0})),cr(`dialog`),It(ee),i(!0),ee.length&&queueMicrotask(()=>{for(let e of ee)Y(e,!0),e===K.current?.activeId&&(Vr.current=!0,Ct(!0),ca(e,0))});try{let e=new URL(window.location.href),t=e.searchParams.get(`plugin`);if(t===`promptGen`||t===`knowledgeGen`||t===`caseGen`||t===`pluginDev`){let n=t;if(Ae()[n]){if(n===`pluginDev`)ga();else{let e=K.current?.sessions.find(e=>e.id===K.current?.activeId);if((!e||e.archived||e.deleted||Array.isArray(e.messages)&&e.messages.length>0||e.caseGen?.active||e.promptGen?.active||e.knowledgeGen?.active)&&K.current){let e=K.current.activeId,t=ea(e)??K.current,n=B?.workspace?.trim()||void 0,r=Ze(t,{workspacePath:n,access:ve()});K.current=r,o(r),nt(r),l([]),S(null),D(null),ie(null),Gr([]),Jr.current=null,qr(null),Qr(`off`)}n===`promptGen`?T(!0):n===`knowledgeGen`?O(!0):b(!0)}}else R(je(n));e.searchParams.delete(`plugin`),window.history.replaceState({},``,e.pathname+e.search+e.hash)}}catch{}(async()=>{try{if(!await M(`prompts`))return;let e=(await ce(`prompts`,he)).content.trim();e&&v(e)}catch{}})(),Et().then(e=>jn(e)),vt().then(e=>{Pn(e),Rn(!0)}),qt().then(e=>Vn(e)),on().then(e=>Gn(e)),yt().then(e=>Yn(e)),$t().then(e=>{Xn(e),e?.workspace&&tr(t=>({...t,[e.workspace]:!0}))})})(),()=>{e=!0,t(),r(),a()}},[]),(0,z.useEffect)(()=>{!On.memory&&sr===`memory`&&cr(`dialog`)},[On.memory,sr]),(0,z.useEffect)(()=>{if(!r)return;let e=!1,t=async()=>{if(!K.current)return;let t=await lc();if(e||!K.current)return;let n=K.current,r=!1;for(let e of t){let t=n.sessions.find(t=>t.id===e.sessionId)?.messages??[],i=`<!--tb-schedule:${e.id}-->`;if(!t.some(t=>t.scheduleId===e.id||typeof t.content==`string`&&t.content.includes(i))){let t={role:`assistant`,content:sc(e.text,e.id),time:Date.now(),scheduleId:e.id};n=$e(n,e.sessionId,t),e.sessionId===n.activeId&&(r=!0)}try{typeof Notification<`u`&&Notification.permission===`granted`&&new Notification(`Lantern Harness 定时提醒`,{body:e.text})}catch{}}let i=await He();if(!e&&K.current){if(i){let e=Ye(n,i);e!==n&&(n=e,n.activeId&&(r=!0))}if((n!==K.current||t.length)&&q(n),r){let e=n.sessions.find(e=>e.id===n.activeId);l(e?.messages??[])}}};t();let n=window.setInterval(()=>{t()},1e4);return()=>{e=!0,window.clearInterval(n)}},[r]),(0,z.useEffect)(()=>{if(!r||!U||!B)return;let e=a?.sessions.find(e=>e.id===a.activeId);Ji(e)},[r,U,a?.activeId,B?.items]),(0,z.useEffect)(()=>{let e=e=>{if(e.key!==`Shift`||e.repeat||e.ctrlKey||e.metaKey||e.altKey)return;let t=document.activeElement;t instanceof HTMLElement&&t!==document.body&&(t.tagName===`TEXTAREA`||t.tagName===`INPUT`||t.tagName===`SELECT`||t.isContentEditable||t.blur())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,z.useEffect)(()=>{hr(0),_r(!1)},[Ai?.query,Ai?.from]),(0,z.useEffect)(()=>{yr(!1),me(0)},[Pi?.from]),(0,z.useEffect)(()=>{me(e=>Fi.length?Math.min(e,Fi.length-1):0)},[Fi.length]),(0,z.useEffect)(()=>{if(!Ni||!ki){ki||Dr([]);return}let e=!1;return jt(cn,{maxDepth:3,maxEntries:80}).then(t=>{e||Dr(t)}),()=>{e=!0}},[Ni,ki,cn,B?.workspace]),(0,z.useEffect)(()=>{if(!Ni)return;let e=Ci.current;e&&e.querySelector(`[data-mention-index="${mr}"]`)?.scrollIntoView({block:`nearest`})},[mr,Ni,G.length]),(0,z.useEffect)(()=>{if(!Ii)return;let e=wi.current;e&&e.querySelector(`[data-plugin-index="${pe}"]`)?.scrollIntoView({block:`nearest`})},[pe,Ii,Fi.length]),(0,z.useEffect)(()=>{if(!Ni&&!Ii&&!br)return;function e(e){let t=e.target;Ci.current?.contains(t)||wi.current?.contains(t)||Ti.current?.contains(t)||xi.current?.contains(t)||e.target?.closest?.(`[data-add-menu-btn]`)||(_r(!0),yr(!0),xr(!1))}return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[Ni,Ii,br]),(0,z.useEffect)(()=>{if(!Vt||nn!==`ok`)return;function e(e){let t=e.target;Ei.current?.contains(t)||R(null)}let t=window.setTimeout(()=>{document.addEventListener(`pointerdown`,e,!0)},0);return()=>{window.clearTimeout(t),document.removeEventListener(`pointerdown`,e,!0)}},[Vt,nn]),(0,z.useEffect)(()=>{if(!ar&&!ct)return;function e(e){let t=e.target;t?.closest?.(`[data-session-menu]`)||t?.closest?.(`[data-ws-menu]`)||(or(null),ut(null))}return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[ar,ct]);function Wi(){Et().then(e=>jn(e)),vt().then(e=>{Pn(e),Rn(!0)}),qt().then(e=>Vn(e)),on().then(e=>Gn(e)),yt().then(e=>Yn(e)),$t().then(e=>Xn(e))}function Gi(e){Xn(e),tr(t=>({...t,[e.workspace]:!0}))}async function Ki(e,t=`select`){if(U&&!Qn){$n(!0),R(null);try{Gi(t===`add`?await kt(e):await tn(e))}catch(e){R(e instanceof Error?e.message:String(e))}finally{$n(!1)}}}function qi(e){let t=zi.current;if(!t)return null;let n=e?.workspacePath?.trim();return n&&(n===t.harnessRoot||t.items.some(e=>e.path===n))?n:t.projectRoot?.trim()||null}async function Ji(e){if(!U||Qn)return;let t=qi(e);if(!t)return;let n=zi.current;if(n&&t!==n.workspace){$n(!0);try{Gi(await tn(t))}catch{}finally{$n(!1)}}}async function Yi(e){if(!U||Qn)return;await Ki(e.path,`select`);let t=K.current;if(!t)return;let n=t.sessions.find(e=>e.id===t.activeId);n&&!n.workspacePath&&((n.messages??[]).length>0||(q(Be(t,n.id,e.path)),tr(t=>({...t,[e.path]:!0}))))}async function Xi(){if(U&&!Qn){$n(!0),R(null);try{let e=await Mt();if(!e)return;Gi(await kt(e))}catch(e){R(e instanceof Error?e.message:String(e))}finally{$n(!1)}}}async function Zi(){let e=dt;if(e&&U&&!Qn){if(e.id===`ws_project`)ft(null);else{ft(null),ut(null),$n(!0),R(null);try{K.current&&q(rt(K.current,e.path));let t=await wt(e.id);Gi(t),t.projectRoot&&tr(e=>({...e,[t.projectRoot]:!0}))}catch(e){R(e instanceof Error?e.message:String(e))}finally{$n(!1)}}}}function Qi(e){U&&!Qn&&e.id!==`ws_project`&&(or(null),ut(null),ft(e))}async function $i(e){let t=pt;if(bt(null),t&&U){$n(!0),R(null);try{Gi(await st(t,e))}catch(e){R(e instanceof Error?e.message:String(e))}finally{$n(!1)}}}function ea(e){if(!e||!K.current)return K.current;let t=K.current.sessions.find(t=>t.id===e);if(!t||!Ue(t))return K.current;let n=Oi.current[e];return n&&(n.input?.trim()||(n.attachments?.length??0)>0||(n.images?.length??0)>0||(n.docRefs?.length??0)>0)?K.current:(delete Oi.current[e],et(K.current,e))}function ta(e){Ai&&(e.collection!==`workspace`&&!kr?R(je(`knowledge`)):g.length>=Hl?R(`最多引用 ${Hl} 篇文档`):(R(null),_(t=>t.some(t=>t.collection===e.collection&&t.path===e.path)?t:[...t,{collection:e.collection,id:e.id,title:e.title,category:e.category,path:e.path,format:e.format}].slice(0,Hl)),d(u.slice(0,Ai.from).replace(/\s+$/,``)),_r(!0),xi.current?.focus()))}function na(){Pi&&(d(u.slice(0,Pi.from).replace(/\s+$/,``)),yr(!0))}function ra(e){if(!On[e])return R(je(e)),!1;if(R(null),e===`caseGen`)return b(!0),!0;if(e===`promptGen`)return T(!0),!0;if(e===`knowledgeGen`)return O(!0),!0;if(e===`pluginDev`)return ga(),!0;if(e===`memory`)return cr(`memory`),!0;if(e===`knowledge`){let e=u.replace(/\s+$/,``);return d(e?`${e} @`:`@`),_r(!1),requestAnimationFrame(()=>xi.current?.focus()),!0}return!1}function ia(e){na(),ra(e)}function J(){let e=bi.current;if(!e)return;let t=e.scrollHeight-e.clientHeight-e.scrollTop<=48;if(Ri.current){if(!t)return;Ri.current=!1}Li.current=t,fn(!t)}function aa(){let e=bi.current;e&&(Li.current=!0,Ri.current=!0,fn(!1),e.scrollTo({top:e.scrollHeight,behavior:`smooth`}))}(0,z.useEffect)(()=>{if(!r||!K.current)return;let e=K.current.sessions.find(e=>e.id===K.current.activeId)?.messages??[],t=JSON.stringify(e)!==JSON.stringify(s),n=Re(K.current,s,{touchUpdatedAt:t});K.current=n,o(n),nt(n),Li.current&&!Ri.current&&bi.current?.scrollTo({top:bi.current.scrollHeight})},[s,r]),(0,z.useEffect)(()=>{let e=()=>{K.current&&nt(K.current)};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[]),(0,z.useLayoutEffect)(()=>{let e=xi.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,280)}px`)},[u]),(0,z.useEffect)(()=>{if(!r||!de||!s.length)return;let e=de,t=window.setTimeout(()=>{let t=(bi.current??document).querySelector(`[data-focus-doc="${CSS.escape(e)}"]`);t instanceof HTMLElement&&(t.scrollIntoView({behavior:`smooth`,block:`center`}),t.classList.add(`ring-2`,`ring-[#4176e6]`,`ring-offset-2`),window.setTimeout(()=>{t.classList.remove(`ring-2`,`ring-[#4176e6]`,`ring-offset-2`)},2400)),fe(null)},80);return()=>window.clearTimeout(t)},[r,de,s]);function Y(e,t){It(n=>{let r=n.includes(e);return t&&!r?[...n,e]:!t&&r?n.filter(t=>t!==e):n}),K.current?.activeId===e&&(Vr.current=t,Ct(t))}function oa(e){e&&(Fr.current.get(e)?.abort.abort(),Lr.current.get(e)?.(),Lr.current.delete(e),_n(e))}function sa(e,t){if(t.type===`reasoning`&&t.delta)X(e,n=>{let r=n[n.length-1];if(r?.role!==`assistant`)return n;let i=re((r.reasoning??``)+t.delta),a=[...r.activitySteps??[]],o=a.findIndex(e=>e.kind===`thinking`),s={id:`thinking`,kind:`thinking`,title:`思考`,detail:nu(i).replaceAll(`**`,``).slice(0,80)||void 0,status:`running`};o>=0?a[o]={...a[o],...s}:a.unshift(s);let c=n.slice(),l=zr.current.get(e),u=r.ttftMs;return l&&l.firstToken==null&&(l.firstToken=Date.now(),u=Math.max(0,l.firstToken-l.start)),c[c.length-1]={...r,reasoning:i,activitySteps:a,turnStatus:`running`,ttftMs:u},c});else if(t.type===`content`&&t.delta)X(e,n=>{let r=n[n.length-1];if(r?.role!==`assistant`)return n;let i=(r.activitySteps??[]).map(e=>e.kind===`thinking`&&e.status===`running`?{...e,status:`done`}:e),a=n.slice(),o=zr.current.get(e),s=r.ttftMs;return o&&o.firstToken==null&&(o.firstToken=Date.now(),s=Math.max(0,o.firstToken-o.start)),a[a.length-1]={...r,content:re((r.content??``)+t.delta),activitySteps:i,turnStatus:`running`,ttftMs:s},a});else if(t.type===`tool`&&t.name){let n=Zl(t.name),r=tu(t.name,t.args),i=`tool_${t.name}_${t.args?.slice(0,24)??``}`;ua(e,i,t.status);let a=t.status===`done`&&typeof t.result==`string`&&/^\s*\{\s*"error"\s*:/.test(t.result);X(e,e=>{let o=e[e.length-1];if(o?.role!==`assistant`)return e;let s=[...o.activitySteps??[]],c=s.findIndex(e=>e.id===i||e.detail===r&&e.title===n&&e.status===`running`),l={id:i,kind:$l(t.name),title:n,detail:r||void 0,status:t.status===`running`?`running`:a?`error`:`done`};c>=0?s[c]={...s[c],...l}:s.push(l);let u=e.slice();return u[u.length-1]={...o,activitySteps:s,turnStatus:`running`},u}),K.current?.activeId===e&&H(ru(xe().toolStepDetail,n,t.name,t.status===`running`?`running`:`done`))}else if(t.type===`usage`&&t.usage)X(e,e=>{let n=e[e.length-1];if(n?.role!==`assistant`)return e;let r=e.slice();return r[r.length-1]={...n,usage:t.usage},r});else if(t.type===`status`){let n=t.status;(n===`completed`||n===`stopped`||n===`error`)&&(X(e,e=>{let r=e[e.length-1];if(r?.role!==`assistant`)return e;let i=t.assistant,a=e.slice(),o=typeof i?.toolMs==`number`?i.toolMs:void 0,s=typeof i?.llmMs==`number`?i.llmMs:void 0,c=typeof i?.ttftMs==`number`?i.ttftMs:void 0,l=typeof i?.tps==`number`?i.tps:void 0;return a[a.length-1]={...r,content:typeof i?.content==`string`?i.content:r.content,reasoning:typeof i?.reasoning==`string`?i.reasoning:r.reasoning,reasoningApi:typeof i?.reasoningApi==`string`?i.reasoningApi:r.reasoningApi,activitySteps:(i?.activitySteps??r.activitySteps??[]).map(e=>e.status===`running`?{...e,status:`done`}:e),turnStatus:n===`completed`?`completed`:`stopped`,time:Date.now(),usage:i?.usage??r.usage,model:typeof i?.model==`string`?i.model:r.model,toolMs:o==null?r.toolMs:Math.max(o,r.toolMs??0),llmMs:s??r.llmMs,ttftMs:c??r.ttftMs,tps:l??r.tps},a}),n===`error`&&t.error&&K.current?.activeId===e&&R(Ql(t.error)),Fr.current.delete(e),Ir.current===e&&(Ir.current=null),Y(e,!1),K.current?.activeId===e&&H(null))}}function ca(e,t=0){Lr.current.get(e)?.(),Y(e,!0),(async()=>{let n=await vn(e),r=t;if(n?.ok&&n.assistant&&(r=Math.max(r,n.seq??0),X(e,e=>{let t=e[e.length-1],r=t?.role===`assistant`?t:{role:`assistant`,content:``,turnStatus:`running`},i=n.assistant,a={...r,content:typeof i?.content==`string`?i.content:r.content,reasoning:typeof i?.reasoning==`string`?i.reasoning:r.reasoning,reasoningApi:typeof i?.reasoningApi==`string`?i.reasoningApi:r.reasoningApi,activitySteps:i?.activitySteps??r.activitySteps,turnStatus:n.status===`completed`?`completed`:n.status===`stopped`||n.status===`error`?`stopped`:`running`,usage:i?.usage??r.usage,model:typeof i?.model==`string`?i.model:r.model,llmMs:typeof i?.llmMs==`number`?i.llmMs:r.llmMs,ttftMs:typeof i?.ttftMs==`number`?i.ttftMs:r.ttftMs,toolMs:typeof i?.toolMs==`number`?Math.max(i.toolMs,r.toolMs??0):r.toolMs,tps:typeof i?.tps==`number`?i.tps:r.tps};if(t?.role===`assistant`){let t=e.slice();return t[t.length-1]=a,t}return[...e,a]}),n.status&&n.status!==`running`&&n.status!==`waiting_user`)){Y(e,!1);return}let i=xn(e,r,{onEvent:t=>sa(e,t),onGaveUp:t=>{K.current?.activeId===e&&R(t.message||`与服务端回合断开`),Y(e,!1)}});Lr.current.set(e,i)})()}function X(e,t,n){let r=Fr.current.get(e),i=K.current?.sessions.find(t=>t.id===e)?.messages??[],a=r?.messages??(K.current?.activeId===e?Bi.current:i),o=typeof t==`function`?t(a):t;r&&(r.messages=o),K.current?.activeId===e&&(Bi.current=o,l(o)),K.current&&q(Fe(K.current,e,o,{touchUpdatedAt:n?.touchUpdatedAt!==!1}))}function la(e){let t=Ir.current??K.current?.activeId;t&&X(t,t=>{let n=t[t.length-1];if(n?.role!==`assistant`)return t;let r=t.slice();return r[r.length-1]=e(n),r})}function ua(e,t,n){let r=`${e}:${t}`;if(n===`running`){Rr.current.set(r,Date.now());return}if(n!==`done`&&n!==`error`)return;let i=Rr.current.get(r);if(Rr.current.delete(r),i==null)return;let a=Math.max(0,Date.now()-i);X(e,e=>{let t=e[e.length-1];if(t?.role!==`assistant`)return e;let n=e.slice();return n[n.length-1]={...t,toolMs:(t.toolMs??0)+a},n})}async function da(e){if(!e.length)return;let t=[],n=[],r=Jl(f,m);for(let i of e)if(r+t.length>=6)n.push(`${i.name||`图片`}(最多 6 个文件)`);else try{t.push(await ql(i))}catch(e){n.push(e instanceof Error?e.message:String(e))}t.length&&h(e=>[...e,...t].slice(0,6)),R(n.length?`以下图片未添加:${n.join(`、`)}`:null)}function fa(){d(``),p([]),h([]),_([]),_r(!1),yr(!1)}function pa(){if($r===`plan`&&(Ia(),Qr(`off`)),$r===`pluginDev`){j(null),ue.current=null,K.current&&q(L(K.current,{pluginDev:void 0}));let e=P.current;P.current=null,e===`readonly`&&(ln(`readonly`),K.current&&q(L(K.current,{access:`readonly`})))}ei(null)}function ma(){ei(`goal`),requestAnimationFrame(()=>xi.current?.focus())}function ha(){Qr(e=>e===`off`?`planning`:e),ei(`plan`),requestAnimationFrame(()=>xi.current?.focus())}function ga(){U?(ei(`pluginDev`),cn===`readonly`&&(P.current=`readonly`,ln(`readwrite`),K.current&&q(L(K.current,{access:`readwrite`}))),requestAnimationFrame(()=>xi.current?.focus())):R(`本地文件服务未就绪:插件开发需要读写项目源码`)}function _a(e){return e.filter(e=>e.role===`user`||e.role===`assistant`).map(e=>({role:e.role,content:typeof e.content==`string`?e.content:``,reasoning:e.reasoning}))}async function va(e){if(!t)return ye(`model`),!1;let n=_a(Bi.current);if(n.length<4)return R(`对话轮次较少,无需压缩`),!1;H(`正在压缩上下文…`);try{let{messages:r,compacted:i}=await ws(t,n,{force:e.force,signal:e.signal});if(!i)return H(null),R(`当前上下文未超过阈值,未压缩`),!1;let a=Date.now(),o=r.map((e,t)=>({role:e.role,content:e.content,reasoning:e.reasoning,time:a+t}));return Bi.current=o,l(o),K.current&&q(Re(K.current,o,{touchUpdatedAt:!0})),H(null),!0}catch(e){return H(null),e instanceof DOMException&&e.name===`AbortError`||R(e instanceof Error?e.message:String(e)),!1}}async function ya(e,n){let r=e===void 0,i=(e??u).trim(),a=r?f:[],o=r?g:[],s=r?m:[];if(!i&&!a.length&&!o.length&&!s.length)return;if(!t){ye(`model`);return}if(Ts(i)&&!a.length&&!o.length&&!s.length){if(Vr.current){R(`请等待当前回复结束后再压缩`);return}r&&fa(),await va({force:!0})&&R(null);return}if($r===`goal`&&i&&!a.length&&!o.length&&!s.length&&!Ms(i)&&!Ts(i)){r&&fa();let e={text:i.slice(0,500),status:`active`,updatedAt:Date.now()};Jr.current=e,qr(e),Yr.current=0,K.current&&q(L(K.current,{goal:e})),ei(null),R(`已设定目标:${e.text}`);return}if(Ms(i)&&!a.length&&!o.length&&!s.length){let e=js(i);if(r&&fa(),!e)return;if(e.kind===`show`){let e=Kr;R(e&&e.status!==`cleared`?`当前目标(${e.status}):${e.text}`:`当前无会话目标。可用 /goal set <内容> 设定`);return}if(e.kind===`clear`){Jr.current=null,qr(null),Yr.current=0,K.current&&q(L(K.current,{goal:void 0})),R(`已清除会话目标`);return}if(e.kind===`done`){if(!Kr?.text){R(`当前无目标可标记完成`);return}let e={...Kr,status:`done`,updatedAt:Date.now()};Jr.current=e,qr(e),Yr.current=0,K.current&&q(L(K.current,{goal:e})),R(`已标记目标完成:${e.text}`);return}if(e.kind===`set`&&e.text){let t={text:e.text.slice(0,500),status:`active`,updatedAt:Date.now()};Jr.current=t,qr(t),Yr.current=0,K.current&&q(L(K.current,{goal:t})),R(`已设定目标:${t.text}`);return}return}if($r===`pluginDev`&&i&&!a.length&&!o.length&&!s.length){if(Vr.current){R(`请等待当前回复结束后再开始插件开发`);return}await ja(i)}let c={id:`q_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`,content:i,files:[...a],refs:[...o],imgs:[...s]};if(Vr.current){let e=xe().busySendBehavior??`queue`;if((n?.forceBusy??e)===`queue`){W([..._i.current,c]),r&&fa();return}vi.current=c,r&&fa(),oa(K.current?.activeId)}else await ba(c)}async function ba(n){let r=K.current?.activeId;if(!t||!r||Fr.current.has(r))return;let{content:i,files:a,refs:o,imgs:s}=n;Fs(i)||(Yr.current=0),R(null);let c=Date.now(),u={role:`user`,content:i,time:c};a.length&&(u.attachments=a),o.length&&(u.refs=o),s.length&&(u.images=s);let d=Bi.current,f=d[d.length-1];f?.role===`assistant`&&!f.content&&!f.reasoning&&(d=d.slice(0,-1));let p=[...d,u];if(xs(_a(p),t.model)){H(`上下文较长,正在压缩…`);try{let{messages:e,compacted:n}=await ws(t,_a(p),{force:!1,signal:void 0});if(n){let t=Date.now();p=e.map((e,n)=>({role:e.role,content:e.content,reasoning:e.reasoning,time:t+n})),Bi.current=p,l(p),K.current&&q(Re(K.current,p,{touchUpdatedAt:!0}))}}catch{}H(null)}let m=[...p,{role:`assistant`,content:``,time:c,turnStatus:`running`}];Bi.current=m,l(m),fa();let h=new AbortController;Ir.current=r,Fr.current.set(r,{abort:h,messages:m}),Pr.current=h,Y(r,!0),Li.current=!0,fn(!1);let g=Zn(p.map(e=>{let t={role:e.role,content:Gl(e)},n=(e.reasoningApi??e.reasoning)?.trim();return e.role===`assistant`&&n&&(t.reasoning_content=n),t}),{keepRecentImageMessages:1}),_=Or,v=kr,y=U,b=Ar,x=Zr===`planning`,w=On.pluginDev&&ue.current?.active?ue.current:null,T=w?cn===`full`?`full`:`readwrite`:x?`readonly`:cn,E=Mr&&T!==`readonly`,ne=Nr&&T!==`readonly`,O=zi.current?.workspace?.trim()||``,k=O?`\n当前工作区:${O}`:``,A=On.promptGen&&te.current?.active?te.current:null,se=!A&&On.knowledgeGen&&oe.current?.active?oe.current:null,ce=!A&&!se&&On.caseGen&&C.current?.active?C.current:null,j=!!(A||se||ce),le=O,M=ee;if(w)M=Lo(w,zi.current?.harnessRoot||zi.current?.projectRoot||O);else if(A)M=po(A);else if(se)M=jo(se);else if(ce){if(!ce.promptBody?.trim()){R(`生成测试用例已启用,但未选择提示词。请打开插件重新「确认」。`),Fr.current.delete(r),Ir.current=null,Pr.current=null,Y(r,!1),l(e=>e[e.length-1]?.role===`assistant`&&!e[e.length-1]?.content?e.slice(0,-1):e);return}try{M=Za(ce,ce.reqPath?.split(`/`).pop()?.replace(/\.[^.]+$/,``)||``)}catch(e){R(e instanceof Error?e.message:String(e)),Fr.current.delete(r),Ir.current=null,Pr.current=null,Y(r,!1);return}}if(!j){let e=rs({lastUserMessageAt:[...p].reverse().find(e=>e.role===`user`&&e!==p[p.length-1])?.time??[...p].reverse().find(e=>e.role===`user`)?.time??null,lastInjectAt:Br.current});if(e.injected&&(Br.current=e.at),M=`${M}\n\n${e.text}`,y)try{let e=await mt();e?.text&&(M=`${M}\n\n${lt}\n\n${e.text}`)}catch{}}let N=Ll(M,g,{memory:_&&!j,knowledge:v&&!j,fs:y&&!j,web:b&&!j,bash:E&&!j,pwsh:ne&&!j,interact:!j,planPhase:j||w?`off`:Zr,goalEnabled:!j,goal:Kr,scheduleEnabled:!j,subagentEnabled:!j,workflowEnabled:!j}).map((e,t)=>t===0&&e.role===`system`&&y&&k&&!j?{...e,content:`${typeof e.content==`string`?e.content:``}${k}`}:e);if(_&&!j&&!w){H(`记忆注入中…`);let{context:e}=await Gt(i,{cwd:le});if(e&&N[0]?.role===`system`){let t=typeof N[0].content==`string`?N[0].content:``;N=[{...N[0],content:`${t}\n\n${e}`},...N.slice(1)]}H(null)}let P=[];j||(v&&P.push(...Zc),y&&(P.push(..._t(T)),P.push(...Dt),P.push(...Bo),P.push(...Jo),P.push(qn),x||(P.push(Un),P.push(ht))),E&&(P.push(Ut),P.push(...Yt)),ne&&(P.push(Lt),P.push(...Zt)),(E||ne)&&P.push(...Pt),b&&P.push(...gt),_&&P.push(...Nt),P.push(as),P.push(os),P.push(...Ds),P.push(...Js),P.push(...pc),P.push(...Vc),(Zr===`planning`||Zr===`approved`)&&P.push(ms));let de=Date.now(),fe=0;zr.current.set(r,{start:de});let pe=0,me=!1,he=``,ge=!1,F,_e=!!(A||se||ce);function I(e){return A?mo(e):se?Mo(e):Qa(e)}function ve(){return A?`正在编写提示词…`:se?`正在编写知识库…`:`正在编写用例…`}let ye=!1;try{let n=``,a=``,o=``;if(_e){H(ve());let e=()=>{let e=Math.max(0,Math.floor((Date.now()-de)/1e3));la(t=>({...t,content:I(e)}))};e(),F=window.setInterval(e,1e3)}if(!_e&&!w&&await mn(h.signal)){let e=P.filter(e=>{let t=e.function?.name??``;return!(!t||t===`ask_user_question`||t===`submit_plan`||t===`workflow`||t===`spawn_subagent`||t===`fork_subagent`||t===`list_agents`||t.startsWith(`subagent_`))});(await gn({sessionId:r,messages:N,settings:{baseURL:t.baseURL,apiKey:t.apiKey,model:t.model,reasoningEffort:t.reasoningEffort},tools:e,thinking:!0,workspace:O||``,access:T})).ok&&(ye=!0,await new Promise(e=>{let t=!1,n=()=>{t||(t=!0,e())},i=()=>{_n(r)};h.signal.addEventListener(`abort`,i),Lr.current.get(r)?.();let a=xn(r,0,{signal:h.signal,onEvent:e=>sa(r,e),onTerminal:e=>{ge=e.status===`completed`,h.signal.removeEventListener(`abort`,i),Lr.current.delete(r),n()},onGaveUp:e=>{K.current?.activeId===r&&R(e.message||`与服务端回合断开`),X(r,e=>{let t=e[e.length-1];if(t?.role!==`assistant`)return e;let n=e.slice();return n[n.length-1]={...t,turnStatus:`stopped`,activitySteps:(t.activitySteps??[]).map(e=>e.status===`running`?{...e,status:`done`}:e)},n}),h.signal.removeEventListener(`abort`,i),Lr.current.delete(r),n()}});Lr.current.set(r,()=>{a(),n()})}))}if(!ye){let s=ae(t,N,h.signal,{tools:P.length?P:void 0,runTool:P.length?async(n,i)=>{fr(!0);let a=Zl(n);H(ru(xe().toolStepDetail,a,n,`running`));let o=Date.now();try{if(n.startsWith(`kb_`))return await el(n,i,{base:`/`,docs:e});if(n.startsWith(`fs_`)){let e=await zt(n,i,T),t=Zo(n,e);if(t&&K.current){let e=Xo(K.current.sessions.find(e=>e.id===r)?.workspaceChanges,t);q(Ie(K.current,r,{workspaceChanges:e}))}return e}if(n.startsWith(`skill_`))return await Vo(n,i);if(n===`load_workspace_dependencies`)return await Jn(n);if(n===`office_to_pdf`)return x?JSON.stringify({error:`计划模式探查中:请先 submit_plan 并等待批准`}):await Wn(n,i,T);if(n.startsWith(`workspace_changes_`)){let e=K.current?.sessions.find(e=>e.id===r),{text:t,next:i}=Qo(n,e?.workspaceChanges);return i&&K.current&&q(Ie(K.current,r,{workspaceChanges:i})),t}if(n.startsWith(`working_directory_`)){let{text:e,info:t}=await Xt(n,i);return t&&(Gi(t),n===`working_directory_set`&&K.current&&q(Ie(K.current,r,{workspacePath:t.workspace}))),e}if(n===`present`){if(x)return JSON.stringify({error:`计划模式探查中:请先 submit_plan 并等待批准`});let e=await an(i,T);try{let t=JSON.parse(e);t.ok&&t.files?.length&&la(e=>{let n=e.presentFiles??[],r=new Map(n.map(e=>[e.path,e]));for(let e of t.files)r.set(e.path,e);return{...e,presentFiles:[...r.values()]}})}catch{}return e}if(n===`todo_write`){let e;try{e=JSON.parse(i||`{}`).todos}catch{return JSON.stringify({error:`invalid JSON arguments`})}let t=ss(e);return K.current?.activeId===r&&Gr(t),K.current&&q(Ie(K.current,r,{todos:t})),JSON.stringify({ok:!0,count:t.length,todos:t})}if(n.startsWith(`goal_`)){if(n===`goal_get`)return ks(K.current?.activeId===r?Jr.current:Os(K.current?.sessions.find(e=>e.id===r)?.goal));if(n===`goal_set`){let e=``;try{e=String(JSON.parse(i||`{}`).text??``).trim()}catch{return JSON.stringify({error:`invalid JSON arguments`})}if(!e)return JSON.stringify({error:`text is required`});let t={text:e.slice(0,500),status:`active`,updatedAt:Date.now()};return K.current?.activeId===r&&(Jr.current=t,qr(t),Yr.current=0),K.current&&q(Ie(K.current,r,{goal:t})),ks(t)}if(n===`goal_done`){let e=K.current?.activeId===r?Jr.current:Os(K.current?.sessions.find(e=>e.id===r)?.goal);if(!e?.text)return JSON.stringify({ok:!1,error:`no goal to complete`});let t={...e,status:`done`,updatedAt:Date.now()};return K.current?.activeId===r&&(Jr.current=t,qr(t),Yr.current=0),K.current&&q(Ie(K.current,r,{goal:t})),ks(t)}return n===`goal_clear`?(K.current?.activeId===r&&(Jr.current=null,qr(null),Yr.current=0),K.current&&q(Ie(K.current,r,{goal:void 0})),JSON.stringify({ok:!0,goal:null})):JSON.stringify({error:`unknown tool: ${n}`})}if(n.startsWith(`schedule_`))return await uc(n,i,r);if(n===`list_agents`||n===`spawn_subagent`||n===`fork_subagent`||n.startsWith(`subagent_`))return await Pc(n,i,{settings:Bn(t,xe().subagentModel),parentSignal:h.signal,access:T,fsEnabled:y,webEnabled:b,parentMessages:g,onHint:e=>H(e),runFs:(e,t,n)=>zt(e,t,n),runWeb:(e,t)=>Tt(e,t)});if(n===`workflow`)return await qc(n,i,{settings:t,parentSignal:h.signal,access:T,fsEnabled:y,webEnabled:b,parentMessages:g,onHint:e=>H(e),runFs:(e,t,n)=>zt(e,t,n),runWeb:(e,t)=>Tt(e,t)});if(n===`ask_user_question`){let e=cs(i);if(!e.length)return JSON.stringify({error:`questions is required`});let t={};for(let n of e)t[n.id]={selected:[],text:``};return oi(t),ci(0),ui(!1),fi(null),mi(!1),gi(``),ii(e),await new Promise((e,t)=>{Hr.current={resolve:e,reject:t};let n=Pr.current,r=()=>{n?.signal.removeEventListener(`abort`,r),Z()};n?.signal.addEventListener(`abort`,r)})}if(n===`submit_plan`){let e=hs(i);return e?(ni(e),await new Promise((e,t)=>{Ur.current={resolve:e,reject:t};let n=Pr.current,r=()=>{n?.signal.removeEventListener(`abort`,r),Ia()};n?.signal.addEventListener(`abort`,r)})):JSON.stringify({error:`title and steps are required`})}return n===`bash`?await Bt(i,T):n===`pwsh`?await Ht(i,T):n.startsWith(`bash_session_`)?await Rt(n,i,T):n.startsWith(`pwsh_session_`)?await Jt(n,i,T):n.startsWith(`job_`)?await Qt(n,i,T):n.startsWith(`web_`)?await Tt(n,i):n.startsWith(`memory_`)?await xt(n,i,le):JSON.stringify({error:`unknown tool: ${n}`})}finally{let e=Math.max(0,Date.now()-o);la(t=>({...t,toolMs:(t.toolMs??0)+e})),fr(!1),Wi()}}:void 0});for await(let e of s){if(e.type===`tool`){let t=Zl(e.name);H(ru(xe().toolStepDetail,t,e.name,e.status===`running`?`running`:`done`));let n=tu(e.name,e.args),r=`tool_${e.name}_${e.args?.slice(0,24)??``}`,i=e.status===`done`&&typeof e.result==`string`&&/^\s*\{\s*"error"\s*:/.test(e.result);la(a=>{let o=[...a.activitySteps??[]],s=o.findIndex(e=>e.id===r||e.detail===n&&e.title===t&&e.status===`running`),c={id:r,kind:$l(e.name),title:t,detail:n||void 0,status:e.status===`running`?`running`:i?`error`:`done`};return s>=0?o[s]={...o[s],...c}:o.push(c),{...a,activitySteps:o}});continue}if(e.type===`usage`){let n=Date.now(),r=fe?(n-fe)/1e3:0,i=Pu(e.usage),a=r>.2&&i>0?i/r:void 0;la(r=>({...r,usage:e.usage,tps:a,model:t.model,ttftMs:fe?fe-de:r.ttftMs,llmMs:n-de}));continue}if(fe===0&&(fe=Date.now(),la(e=>({...e,ttftMs:fe-de,model:t.model}))),e.type===`reasoning_api`){la(t=>({...t,reasoningApi:e.content}));continue}e.type===`reasoning`&&pe===0&&(pe=Date.now());let r=e.type===`content`&&pe>0&&!me;if(r&&(me=!0),_e){e.type===`content`&&(A?a+=e.delta:se?o+=e.delta:n+=e.delta);let t=I(Math.max(0,Math.floor((Date.now()-de)/1e3)));if(e.type===`reasoning`){he+=e.delta;let n=re(he);la(e=>{let i={...e,reasoning:n,content:t};return r&&(i.reasoningDuration=Math.max(1,Math.round((Date.now()-pe)/1e3))),i})}else r&&la(e=>({...e,content:t,reasoningDuration:Math.max(1,Math.round((Date.now()-pe)/1e3))}))}else e.type===`reasoning`&&(he+=e.delta),la(t=>{let n=e.type===`reasoning`?{...t,reasoning:re(he)}:{...t,content:re(t.content+e.delta)};if(e.type===`reasoning`){let e=[...n.activitySteps??[]],t=e.findIndex(e=>e.kind===`thinking`),r={id:`thinking`,kind:`thinking`,title:`思考`,detail:nu(n.reasoning??``).replaceAll(`**`,``).slice(0,80)||void 0,status:`running`};t>=0?e[t]={...e[t],...r}:e.unshift(r),n.activitySteps=e}if(r){n.reasoningDuration=Math.max(1,Math.round((Date.now()-pe)/1e3));let e=[...n.activitySteps??[]],t=e.findIndex(e=>e.kind===`thinking`);t>=0&&(e[t]={...e[t],status:`done`}),n.activitySteps=e}return n})}if(ge=!0,!_e){let e=[...K.current?.sessions.find(e=>e.id===r)?.messages??[]].reverse().find(e=>e.role===`assistant`);e&&typeof e.content==`string`&&!e.content.trim()&&R(`模型本轮没有返回正文(可能工具轮次用尽或输出被截断),请重试或回复「继续」`)}{let e=pe>0&&!me?Math.max(1,Math.round((Date.now()-pe)/1e3)):null;la(t=>{let n=(t.activitySteps??[]).map(e=>e.kind===`thinking`&&e.status===`running`?{...e,status:`done`}:e),r={...t,activitySteps:n};return e!=null&&t.reasoning&&t.reasoningDuration==null&&(r.reasoningDuration=e),r})}if(F!=null&&(window.clearInterval(F),F=void 0),A){H(`正在质检并入库…`);let e=await _o(a,A);if(la(t=>({...t,content:e.summary,docsFile:e.ok?{root:`prompts`,path:e.path,name:e.path.split(`/`).pop()||e.title||e.path}:void 0})),e.ok&&K.current){let t={...A,linkedPromptPath:e.path};D(t),te.current=t,q(L(K.current,{promptGen:t}))}}else if(se){H(`正在质检并入库…`);let e=await Fo(o,se);if(la(t=>({...t,content:e.summary,docsFile:e.ok?{root:`knowledge`,path:e.path,name:e.path.split(`/`).pop()||e.title||e.path,note:e.category}:void 0})),e.ok&&K.current){let t={...se,linkedKnowledgePath:e.path};ie(t),oe.current=t,q(L(K.current,{knowledgeGen:t}))}}else if(ce){H(`正在检测覆盖并入库…`);let e=ce.reqPath?.split(`/`).pop()?.replace(/\.[^.]+$/,``)||i.slice(0,24),t=await to(n,ce,e);if(la(e=>({...e,content:t.summary,caseFile:t.ok?{path:t.path,name:t.path.split(`/`).pop()||t.path,count:t.count}:void 0})),t.ok&&K.current){let e={...ce,linkedCasePath:t.path};S(e),C.current=e,q(L(K.current,{caseGen:e}))}}}ye&&ge&&la(e=>({...e,turnStatus:e.turnStatus===`stopped`?`stopped`:`completed`,activitySteps:(e.activitySteps??[]).map(e=>e.status===`running`?{...e,status:`done`}:e)}))}catch(e){e instanceof DOMException&&e.name===`AbortError`||K.current?.activeId===r&&R(e instanceof Error?e.message:String(e)),X(r,e=>{let t=e[e.length-1];if(t?.role===`assistant`&&!t.content&&!t.reasoning&&!t.activitySteps?.length)return e.slice(0,-1);if(t?.role!==`assistant`)return e;let n=e.slice();return n[n.length-1]={...t,activitySteps:(t.activitySteps??[]).map(e=>e.status===`running`?{...e,status:`done`}:e)},n})}finally{F!=null&&(window.clearInterval(F),F=void 0);let e=Date.now(),n=zr.current.get(r),a=fe||n?.firstToken||0;la(n=>{let r=n.llmMs??e-de,i=n.ttftMs??(a?a-de:void 0),o=i==null?0:Math.max(0,(r-i)/1e3),s=Pu(n.usage),c=n.tps??(o>.2&&s>0?s/o:void 0);return{...n,time:e,model:n.model??t.model,llmMs:r,ttftMs:i,tps:c,turnStatus:n.turnStatus===`stopped`||n.turnStatus===`completed`?n.turnStatus:ge?`completed`:(h.signal.aborted||!ye)&&n.turnStatus===`running`?`stopped`:n.turnStatus,activitySteps:(n.activitySteps??[]).map(e=>e.status===`running`?{...e,status:`done`}:e)}}),zr.current.delete(r),Fr.current.delete(r),Lr.current.get(r)?.(),Lr.current.delete(r),Ir.current===r&&(Ir.current=null),Pr.current===h&&(Pr.current=null),Y(r,!1);{let e=xe().toolStepDetail;e===`full`?window.setTimeout(()=>H(null),2800):e===`detailed`?window.setTimeout(()=>H(null),1200):H(null)}if(ge&&_&&Kt(i,le).finally(()=>{Wi()}),ge&&K.current){let e=[...K.current.sessions.find(e=>e.id===r)?.messages??[]].reverse().find(e=>e.role===`assistant`),n=Fn({userContent:i,assistantContent:typeof e?.content==`string`?e.content:``,reasoning:e?.reasoning});n.length&&In({sessionId:r,model:e?.model??t.model,messages:n})}if(ge&&t&&!h.signal.aborted&&K.current){let e=K.current.sessions.find(e=>e.id===r),n=e?.messages??[];if(e&&!Xr.current.has(r)&&Cn(e.title,n)){let e=Sn(n);e&&(Xr.current.add(r),Tn(t,e).then(e=>{if(!e||!K.current)return;let t=K.current.sessions.find(e=>e.id===r);t&&Cn(t.title,t.messages)&&q(Ge(K.current,r,e))}))}}let o=K.current?.activeId===r,s=null;if(o){s=vi.current,vi.current=null,!s&&_i.current.length&&(s=_i.current[0],W(_i.current.slice(1)));let e=As(Jr.current);if(!s&&!j&&Is({goalActive:!!e,turnOk:ge,aborted:h.signal.aborted,hasFollowUp:!1,askUserPending:!!Hr.current,roundsUsed:Yr.current,maxRounds:3})){let t=Yr.current+1;Yr.current=t,s={id:`goal_drv_${Date.now().toString(36)}`,content:Ps(e,t,3),files:[],refs:[],imgs:[]}}}s&&window.setTimeout(()=>{ba(s)},0)}}function xa(){vi.current=null,W([]),Yr.current=0;let e=K.current?.activeId;e&&X(e,e=>{let t=e[e.length-1];if(t?.role!==`assistant`)return e;let n=e.slice();return n[n.length-1]={...t,turnStatus:`stopped`,activitySteps:(t.activitySteps??[]).map(e=>e.status===`running`?{...e,status:`done`}:e)},n}),oa(e)}function Sa(e){W(_i.current.filter(t=>t.id!==e))}function Ca(e){let t=_i.current.find(t=>t.id===e);t&&(Sa(e),d(t.content),p(t.files),h(t.imgs),_(t.refs),requestAnimationFrame(()=>xi.current?.focus()))}function wa(e){let t=_i.current.find(t=>t.id===e);t&&(W(_i.current.filter(t=>t.id!==e)),Vr.current?(vi.current=t,oa(K.current?.activeId)):ba(t))}function Ta(e){let t=[..._i.current],n=e??t.shift()??null;n&&(W(t),Vr.current?(vi.current=n,oa(K.current?.activeId)):ba(n))}function Ea(e,t){let n=!(s[e]?.reasoningOpen??!1);if(l(t=>t.map((t,n)=>n===e?{...t,reasoningOpen:!t.reasoningOpen}:t)),n){let e=t.currentTarget;requestAnimationFrame(()=>{(e.nextElementSibling??e).scrollIntoView({block:`nearest`,behavior:`smooth`})})}}function Da(e){e&&(u.trim()||f.length>0||m.length>0||g.length>0?Oi.current[e]={input:u,attachments:f,images:m,docRefs:g}:delete Oi.current[e])}function Oa(e){let t=e?Oi.current[e]:void 0;d(t?.input??``),p(t?.attachments??[]),h(t?.images??[]),_(t?.docRefs??[])}function ka(e){e?.abortRun!==!1&&oa(K.current?.activeId),Vr.current=!1,Ct(!1),p([]),h([]),_([]),d(``),R(null),fn(!1),Li.current=!0,e?.clearDraft&&K.current?.activeId&&delete Oi.current[K.current.activeId]}function Aa(e,t){if(!K.current)return;cr(`dialog`);let n=K.current.activeId,r=K.current.sessions.find(e=>e.id===n),i=!!r&&!r.archived&&!r.deleted&&(!Array.isArray(r.messages)||r.messages.length===0),a=n=>({...n,title:n.title?.trim()||`新对话`,caseGen:e===`caseGen`?t:void 0,promptGen:e===`promptGen`?t:void 0,knowledgeGen:e===`knowledgeGen`?t:void 0,updatedAt:Date.now()}),o;if(i&&n)ka({clearDraft:!0,abortRun:!1}),o={...K.current,activeId:n,sessions:K.current.sessions.map(e=>e.id===n?a(e):e)};else{Da(n),ka({clearDraft:!0,abortRun:!1});let e=ea(n)??K.current,t=B?.workspace?.trim()||void 0;o=Ze(e,{workspacePath:t,access:ve()});let r=o.activeId;o={...o,sessions:o.sessions.map(e=>e.id===r?a(e):e)}}q(o),l([]),S(e===`caseGen`?t:null),C.current=e===`caseGen`?t:null,D(e===`promptGen`?t:null),te.current=e===`promptGen`?t:null,ie(e===`knowledgeGen`?t:null),oe.current=e===`knowledgeGen`?t:null;let s=o.sessions.find(e=>e.id===o.activeId)?.workspacePath||B?.workspace?.trim()||B?.projectRoot;s&&tr(e=>({...e,[s]:!0})),Ji(o.sessions.find(e=>e.id===o.activeId))}async function ja(e){let t=K.current;if(!t)return;let n=t.sessions.find(e=>e.id===t.activeId),r=zi.current?.harnessRoot?.trim()||zi.current?.projectRoot?.trim()||zi.current?.workspace?.trim(),i=n?.pluginDev?.active?n.pluginDev:{active:!0,requirement:e.trim(),confirmedAt:Date.now()};if(q(L(t,{pluginDev:i,access:cn===`full`?`full`:`readwrite`,...r?{workspacePath:r}:{}})),j(i),ue.current=i,P.current=null,Ia(),Qr(`off`),r&&tr(e=>({...e,[r]:!0})),U&&r&&zi.current?.workspace!==r)try{Gi(await tn(r))}catch{}}function Ma(e){e?.active?Aa(`caseGen`,e):(S(null),C.current=null,K.current&&q(L(K.current,{caseGen:void 0})))}function Na(e){e?.active?Aa(`promptGen`,e):(D(null),te.current=null,K.current&&q(L(K.current,{promptGen:void 0})))}function Pa(e){e?.active?Aa(`knowledgeGen`,e):(ie(null),oe.current=null,K.current&&q(L(K.current,{knowledgeGen:void 0})))}function Fa(e){if(Se(!1),!K.current)return;cr(`dialog`);let t=K.current.activeId;Da(t),ka({clearDraft:!0,abortRun:!1});let n=ea(t)??K.current,r=e?.trim()||B?.workspace?.trim()||void 0,i=Ze(n,{workspacePath:r,access:ve()});q(i),l([]),S(null),D(null),ie(null),j(null),ue.current=null,Gr([]),Jr.current=null,qr(null),Yr.current=0,Qr(`off`),ei(e=>e===`pluginDev`?null:e),Z(),Ia();let a=r||B?.projectRoot;a&&tr(e=>({...e,[a]:!0})),Ji(i.sessions.find(e=>e.id===i.activeId))}function Z(){let e=Hr.current;e&&(Hr.current=null,ii(null),oi({}),ci(0),ui(!1),fi(null),mi(!1),gi(``),e.resolve(JSON.stringify({canceled:!0,error:`user aborted`})))}function Ia(){let e=Ur.current;e&&(Ur.current=null,ni(null),e.resolve(JSON.stringify({approved:!1,canceled:!0})))}function La(){let e=Ur.current;e&&(Ur.current=null,ni(null),Qr(`approved`),e.resolve(JSON.stringify({approved:!0,message:`用户已批准计划,可以开始实施`})))}function Ra(){let e=Ur.current;e&&(Ur.current=null,ni(null),Qr(`planning`),e.resolve(JSON.stringify({approved:!1,message:`用户驳回了计划,请修订后再次 submit_plan`})))}function za(){Qr(e=>e===`off`?(ei(`plan`),`planning`):(Ia(),ei(e=>e===`plan`?null:e),`off`))}function Ba(e,t){return!e||!t?!1:t.skipped||t.text.trim()!==``?!0:e.options?.length?t.selected.length>0:!1}function Va(e,t,n){let r=Hr.current;if(!r)return;Hr.current=null,ii(null),oi({}),ci(0),ui(!1),fi(null),mi(!1),gi(``),R(null);let i=t.filter(e=>e.skipped).length,a=String(n?.skipReason??``).trim();r.resolve(JSON.stringify({answers:t,summary:ds(e,t),...i?{skipped:!0,approvalRequired:!0,...a?{skipReason:a}:{},note:`用户跳过了部分或全部问题:跳过的题不算确认,也未批准实施。`+(a?`用户给出的跳过原因:${a}。`:``)+`本轮只允许只读调研与文字方案,禁止 fs_write / fs_mkdir / 改配置;请先说明采用的默认假设(哪几项按推荐)与准备改动的范围`+(a?`,并针对上述原因给出调整`:``)+`,然后等用户明确回复「开始实施」再动手。`}:{note:`answers 为结构化答案;summary 是同一批答案的中文文本版本,可直接据此继续,无需再次提问。`},...n}))}function Ha(e,t,n){oi(r=>{let i=r[e.id]??{selected:[],text:``},a=e.multi_select?n?i.selected.filter(e=>e!==t):[...i.selected,t]:[t];return{...r,[e.id]:{selected:a,text:``,skipped:!1}}}),fi(null),e.multi_select||ci(e=>Math.min(e+1,(ri?.length??1)-1))}function Ua(e){let t=ri?.length??0;t&&(ci(Math.max(0,Math.min(e,t-1))),fi(null))}function Wa(e,t){e&&(oi(n=>{let r=n[e.id]??{selected:[],text:``};return{...n,[e.id]:{selected:e.multi_select?r.selected:[],text:t,skipped:!1}}}),fi(null))}function Ga(e,t){let n=t.trim(),r=n&&e.options?.length?ls(e,n):null,i=r?{selected:r,text:``,skipped:!1}:{selected:e.multi_select?ai[e.id]?.selected??[]:[],text:n,skipped:!1},a={...ai,[e.id]:i};oi(a),fi(null),Cs?Ya(a):Ua(ys+1)}function Ja(e){return(ri??[]).map(t=>{let n=us(t,e[t.id]??{selected:[],text:``});return n.skipped||n.text?.trim()||n.selected?.length?n:{id:t.id,selected:[],skipped:!0}})}function Ya(e=ai,t=!1){let n=ri;if(!n?.length||!Hr.current)return!1;let r=Ja(e),i=r.findIndex(e=>!e.skipped&&!e.text?.trim()&&!e.selected?.length);if(i>=0)return Ua(i),fi(n[i]?.options?.length?`请先选择选项再提交`:`请先填写回答再提交`),!1;if(!t&&r.some(e=>e.skipped))return mi(!0),fi(null),!1;let a=hi.trim();return Va(n,r,a?{skipReason:a}:void 0),!0}function Xa(){let e=ri,t=bs;if(!e?.length||!t)return;let n={...ai,[t.id]:{selected:[],text:``,skipped:!0}};oi(n),fi(null),Cs?Ya(n):Ua(ys+1)}function $a(){Ya(ai,!0)}function eo(){mi(!1);let e=Ja(ai).findIndex(e=>e.skipped);Ua(e>=0?e:0)}function no(e){if(Se(!1),!K.current||(cr(`dialog`),or(null),e===K.current.activeId))return;let t=K.current.activeId;Da(t),Z(),Ia(),Qr(`off`),R(null),fn(!1),Li.current=!0;let n=ea(t)??K.current;n.sessions.some(t=>t.id===e)||(n=K.current);let r=Le(n,e),i=r.sessions.find(t=>t.id===e),a=Fr.current.get(e)?.messages??i?.messages??[];Bi.current=a,l(a);let o=Fr.current.has(e)||Ot.includes(e);Vr.current=o,Ct(o),Pr.current=Fr.current.get(e)?.abort??null,o&&!Lr.current.has(e)&&ca(e,0),S(i?.caseGen?.active?i.caseGen:null),D(i?.promptGen?.active?i.promptGen:null),ie(i?.knowledgeGen?.active?i.knowledgeGen:null),j(i?.pluginDev?.active?i.pluginDev:null),ei(e=>i?.pluginDev?.active?`pluginDev`:e===`pluginDev`?null:e),Gr(ss(i?.todos));{let e=Os(i?.goal);Jr.current=e,qr(e),Yr.current=0}Oa(e),q(r),Ji(i)}function ro(e){if(!K.current)return;or(null),ut(null);let t=K.current.activeId===e;t&&ka({clearDraft:!0}),delete Oi.current[e];let n=et(K.current,e);if(q(n),t){let e=n.sessions.find(e=>e.id===n.activeId);l(e?.messages??[]),S(e?.caseGen?.active?e.caseGen:null),D(e?.promptGen?.active?e.promptGen:null),ie(e?.knowledgeGen?.active?e.knowledgeGen:null),j(e?.pluginDev?.active?e.pluginDev:null),ei(t=>e?.pluginDev?.active?`pluginDev`:t===`pluginDev`?null:t)}}function io(e,t){if(!K.current)return;or(null);let n=K.current.activeId===e&&t;n&&ka();let r=qe(K.current,e,t);if(q(r),n){let e=r.sessions.find(e=>e.id===r.activeId);l(e?.messages??[])}}function ao(e){if(!K.current)return;let t=K.current.sessions.find(t=>t.id===e);t&&(or(null),q(Ke(K.current,e,!t.pinned)))}function oo(e){K.current&&K.current.sessions.some(t=>t.id===e)&&(or(null),ut(null),Me(e))}function so(){let e=K.current?.activeId,t=K.current?.sessions.find(t=>t.id===e);t?R(Nn(`stats`,t.id,t.updatedAt,()=>Dn(En(t))),`ok`):R(`无活跃会话可统计`)}function lo(e){K.current&&Ce&&(Xr.current.add(Ce),q(Ge(K.current,Ce,e)),Me(null))}function uo(){yn(e=>(ze(!e),!e))}async function fo(e){let t=Array.from(e.target.files??[]);e.target.value=``,await vo(t)}function ho(){let t=e.map(e=>({collection:e.collection,path:e.path,title:e.title,category:e.category,format:String(e.format)})),n=Er.map(e=>({collection:`workspace`,path:e.path,title:e.name,category:Wt(B?.workspace,B?.projectRoot),format:e.type===`dir`?`dir`:`file`}));return[...t,...n]}function go(e){e.length&&_(t=>{let n=[...t];for(let t of e){if(n.length>=Hl)break;n.some(e=>e.collection===t.collection&&e.path===t.path)||n.push(t)}return n})}async function vo(e,t){let n=[],r=[],i=[],a=Jl(f,m);for(let o of e)if(a>=6)i.push(`${o.name}(最多 6 个文件)`);else try{let e=await ul(o);e.kind===`image`?r.push(await ql(e.file)):n.push({name:e.name,size:e.size,content:e.content,path:t?.get(o.name)||t?.get(e.name)}),a+=1}catch(e){i.push(e instanceof Error?e.message:String(e))}n.length&&p(e=>[...e,...n]),r.length&&h(e=>[...e,...r]),R(i.length?`以下文件未添加:${i.join(`、`)}`:null),xi.current?.focus()}function yo(e){let t=e.clipboardData;if(!t)return;let n=Array.from(t.items??[]),r=n.filter(e=>e.kind===`file`&&e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(e=>!!e),i=n.filter(e=>e.kind===`file`&&!e.type.startsWith(`image/`)).map(e=>e.getAsFile()).filter(e=>!!e);for(let e of Array.from(t.files??[]))e.type.startsWith(`image/`)?r.some(t=>t.name===e.name&&t.size===e.size)||r.push(e):i.some(t=>t.name===e.name&&t.size===e.size)||i.push(e);let a=yl(t),o=(t.getData(`text/plain`)||``).trim(),s=ho(),c=Wt(B?.workspace,B?.projectRoot),l={projectRoot:B?.projectRoot,workspace:B?.workspace,workspaceLabel:c},u=[],d=new Map;for(let e of a){let t=Sl(e,l);t?(u.push(t),d.set(pl(e),t.path)):d.set(pl(e),e)}let f=null;!r.length&&!i.length&&!a.length&&_l(o)&&(f=Cl(o,s));let p=[],m=[];for(let e of i){let t=d.get(e.name),n=(t?Sl(t,l):null)||Cl(e.name,s);n?p.push(n):m.push(e)}(u.length>0||p.length>0||f||r.length>0||m.length>0)&&(e.preventDefault(),R(null),go([...u,...p,...f?[f]:[]]),r.length&&da(r),m.length&&vo(m,d),xi.current?.focus())}function bo(e){let t=e.target.closest(`[data-copy-code]`);t&&Ru(t.closest(`.code-block`)?.querySelector(`pre`)?.textContent??``).then(e=>{e&&(t.textContent=`已复制`,window.setTimeout(()=>{t.textContent=`复制`},1e3))})}let xo=s.length===0,So=!!(u.trim()||f.length||g.length||m.length),wo=-1,To=-1;s.forEach((e,t)=>{e.role===`user`?wo=t:e.role===`assistant`&&(To=t)});let Eo=e=>e===wo||e===To?``:`opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity`,Do=Xl.find(e=>e.value===cn)??Xl[0],Oo=$r===`pluginDev`,ko=(a?.sessions??[]).filter(e=>!e.archived&&!e.deleted),Ao=(a?.sessions??[]).filter(e=>e.archived&&!e.deleted),No=B?.items??[],Po=new Set(No.map(e=>e.path)),Io=B?.workspace??``,Ro=B?.projectRoot??``,zo=a?.sessions.find(e=>e.id===a.activeId),Ho=zo?.workspacePath,Uo=!Ho||!Po.has(Ho),Wo=B?.workspace?.trim()||``,qo=No.find(e=>e.path===Wo),Yo=qo?Ft(qo,Ro):Wo?Wt(Wo,Ro):`工作区`,$o=V.trim().toLowerCase(),es=(0,z.useMemo)(()=>$o?new Set(Go(a,V,{limit:50,includeArchived:!0}).map(e=>e.sessionId)):null,[$o,a,V]),[ts,ns]=(0,z.useState)(null);(0,z.useEffect)(()=>{if(!$o){ns(null);return}let e=!1;return ns(null),Ko(V,{limit:50,includeArchived:!0}).then(t=>{!e&&t?.hits&&ns(new Set(t.hits.map(e=>e.sessionId)))}),()=>{e=!0}},[$o,V]);let is=ts??es,fs=is?Ao.filter(e=>is.has(e.id)):Ao;function ps(e){let t=e.id===`ws_project`||e.path===Ro;return it(ko.filter(n=>!(n.workspacePath!==e.path&&(!t||n.workspacePath&&Po.has(n.workspacePath)))).filter(e=>!is||is.has(e.id)))}let gs=No.filter(e=>!$o||e.name.toLowerCase().includes($o)||e.path.toLowerCase().includes($o)?!0:ps(e).length>0);function _s({s:e,nested:t=!1}){let n=e.id===a?.activeId,r=ar===e.id,i=Ot.includes(e.id);return(0,Q.jsx)(Tu,{s:e,nested:t,active:n,menuOpen:r,busy:i,onOpen:()=>no(e.id),onRename:()=>oo(e.id),onToggleMenu:()=>{ut(null),or(r?null:e.id)},onTogglePin:()=>ao(e.id),onToggleArchive:()=>io(e.id,!e.archived),onExport:()=>{or(null);let t=Ws(e,`json`);R(t.ok?`已导出 ${t.filename}`:t.error)},onRemove:()=>{or(null),ut(null),Qe(e.id)}})}let vs=ri?.length??0,ys=Math.max(0,Math.min(si,vs-1)),bs=ri?.[ys],Ss=bs&&ai[bs.id]||{selected:[],text:``},Cs=ys>=vs-1,Es=Ba(bs,Ss),Ns=(ri??[]).map((e,t)=>({q:e,index:t})).filter(({q:e})=>ai[e.id]?.skipped);return(0,Q.jsxs)(`div`,{className:`tw-app h-full min-h-0 flex overflow-hidden bg-(--tw-surface-page)`,children:[(0,Q.jsxs)(`aside`,{className:`tw-session-rail shrink-0 border-r border-(--tw-border) flex flex-col transition-[width] ${pn?`w-64`:`w-10`}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 ${pn?`px-2.5 pt-2.5`:`px-1 pt-2 justify-center`}`,children:[pn&&(0,Q.jsx)(`div`,{className:`flex-1 min-w-0 text-[13px] font-medium text-stone-700 truncate px-1`,children:ot(`chat.workbench`,void 0,lr.language)}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":pn?`收起侧栏`:`展开侧栏`,onClick:uo,className:`w-8 h-8 shrink-0 flex items-center justify-center rounded-lg text-stone-500 hover:bg-stone-200/70`,children:(0,Q.jsx)($,{className:`w-4 h-4`,children:pn?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}),(0,Q.jsx)(`path`,{d:`M9 3v18`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}),(0,Q.jsx)(`path`,{d:`M15 3v18`})]})})})]}),pn?(0,Q.jsxs)(`div`,{className:`px-2.5 pt-2 space-y-1.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>Fa(),className:`w-full h-9 flex items-center justify-center gap-1.5 text-[13px] font-medium text-stone-700 bg-white rounded-full border border-stone-200/80 shadow-sm hover:bg-stone-50 transition-colors`,children:[(0,Q.jsxs)($,{className:`w-3.5 h-3.5`,children:[(0,Q.jsx)(`path`,{d:`M5 12h14`}),(0,Q.jsx)(`path`,{d:`M12 5v14`})]}),ot(`chat.newSession`,void 0,lr.language)]}),(0,Q.jsxs)(`button`,{type:`button`,"data-hint":`我的插件`,onClick:()=>Se(e=>!e),className:`tw-rail-plugin-btn w-full h-9 flex items-center justify-center gap-1.5 text-[13px] font-medium rounded-full transition-colors ${I?`is-active`:``}`,children:[(0,Q.jsx)(bu,{className:`w-3.5 h-3.5`}),`插件`]})]}):(0,Q.jsxs)(`div`,{className:`px-1 pt-1 flex flex-col gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>Fa(),"data-hint":`新会话`,className:`w-8 h-8 flex items-center justify-center rounded-lg text-[#4176e6] hover:bg-white/80`,children:(0,Q.jsxs)($,{className:`w-4 h-4`,children:[(0,Q.jsx)(`path`,{d:`M5 12h14`}),(0,Q.jsx)(`path`,{d:`M12 5v14`})]})}),(0,Q.jsx)(`button`,{type:`button`,"data-hint":`我的插件`,onClick:()=>Se(e=>!e),className:`tw-rail-plugin-btn tw-rail-plugin-btn--icon w-8 h-8 flex items-center justify-center rounded-lg ${I?`is-active`:``}`,children:(0,Q.jsx)(bu,{className:`w-4 h-4`})})]}),pn&&(0,Q.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-2 py-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 px-1.5 pb-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 text-[12px] font-semibold text-stone-500`,children:ot(`chat.workspace`,void 0,lr.language)}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`搜索`,onClick:()=>{ir(e=>!e),rr&&nr(``)},className:`w-6 h-6 flex items-center justify-center rounded text-stone-400 hover:text-stone-700 hover:bg-stone-200/70`,children:(0,Q.jsx)(hu,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,"data-hint":U?`添加工作区(选择本地文件夹)`:`本地文件服务未就绪`,disabled:!U||Qn,onClick:()=>void Xi(),className:`w-6 h-6 flex items-center justify-center rounded text-stone-400 hover:text-stone-700 hover:bg-stone-200/70 disabled:opacity-40`,children:(0,Q.jsx)(gu,{className:`w-3.5 h-3.5`})})]}),rr&&(0,Q.jsx)(`input`,{value:V,onChange:e=>nr(e.target.value),placeholder:`搜索工作区 / 会话标题 / 消息`,className:`w-full mb-2 px-2.5 py-1.5 text-[12px] rounded-lg border border-stone-200 bg-white text-stone-700 placeholder:text-stone-400 focus:outline-none focus:ring-1 focus:ring-[#4176e6]/40`}),jr&&(0,Q.jsx)(`div`,{className:`px-1.5 py-2 text-[11px] text-amber-700/80`,children:`本地文件服务未就绪,工作区暂不可用`}),(0,Q.jsxs)(`div`,{className:`space-y-0.5`,children:[gs.map(e=>{let t=ps(e),n=!!(er[e.path]??t.length>0),r=e.id===`ws_project`||e.path===Ro,i=!!(zo&&(Uo?r:Ho===e.path)),a=ct===e.id;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`tw-project-row group relative ${i?`is-active`:``} ${n?`is-expanded`:``} ${a?`is-menu-open`:``}`,children:[(0,Q.jsxs)(`button`,{type:`button`,"data-hint":e.path,onClick:t=>{t.stopPropagation(),or(null),ut(null),tr(t=>({...t,[e.path]:!n})),U&&e.path!==Io&&Ki(e.path,`select`)},className:`flex-1 min-w-0 h-full flex items-center gap-1.5 text-left outline-none focus:outline-none`,children:[(0,Q.jsx)(`span`,{className:`tw-slot tw-folder`,children:(0,Q.jsx)(pu,{open:n,className:`w-3.5 h-3.5`})}),(0,Q.jsx)(`span`,{className:`tw-slot tw-chevron`,children:(0,Q.jsx)(mu,{open:n,className:`w-3 h-3`})}),(0,Q.jsx)(`span`,{className:`tw-project-title`,children:Ft(e,Ro)})]}),(0,Q.jsxs)(`div`,{className:`tw-ws-actions relative shrink-0`,"data-ws-menu":``,children:[(0,Q.jsx)(Cu,{open:a,onToggle:()=>{or(null),ut(a?null:e.id)},onRename:()=>{or(null),ut(null),bt(e.id)},onDelete:e.id===`ws_project`?void 0:()=>Qi(e)}),(0,Q.jsx)(`button`,{type:`button`,"data-hint":`在此工作区新建会话`,onClick:t=>{t.stopPropagation(),Fa(e.path)},className:`w-6 h-6 flex items-center justify-center rounded text-(--tw-label-tertiary) hover:text-(--tw-label-primary) hover:bg-(--tw-session-hover-bg)`,children:(0,Q.jsxs)($,{className:`w-3.5 h-3.5`,children:[(0,Q.jsx)(`path`,{d:`M5 12h14`}),(0,Q.jsx)(`path`,{d:`M12 5v14`})]})})]})]}),(0,Q.jsx)(`div`,{className:`tw-collapse ${n?`is-open`:``}`,children:(0,Q.jsx)(`div`,{className:`tw-collapse-inner`,children:t.map(e=>(0,Q.jsx)(_s,{s:e,nested:!0},e.id))})})]},e.id)}),!gs.length&&U&&(0,Q.jsx)(`div`,{className:`px-2 py-3 text-xs text-stone-400`,children:`暂无工作区`})]}),fs.length>0&&(0,Q.jsxs)(`div`,{className:`mt-3 pt-2 border-t border-stone-200/60`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>wn(e=>!e),className:`w-full flex items-center gap-1 px-1.5 pb-1 text-[11px] text-stone-400 hover:text-stone-600`,children:[(0,Q.jsx)(iu,{className:`w-3 h-3 transition-transform ${bn?`rotate-180`:``}`}),`已归档 (`,fs.length,`)`]}),(0,Q.jsx)(`div`,{className:`tw-collapse ${bn?`is-open`:``}`,children:(0,Q.jsx)(`div`,{className:`tw-collapse-inner space-y-0.5`,children:fs.map(e=>(0,Q.jsx)(_s,{s:e},e.id))})})]})]}),pn&&(Io||dr||pr)&&(0,Q.jsxs)(`div`,{className:`shrink-0 border-t border-stone-200/60 px-3 py-2 space-y-1`,children:[Io&&(0,Q.jsxs)(`div`,{className:`tw-rail-workspace-footer`,"data-hint":Io,children:[(0,Q.jsx)(`span`,{className:`tw-rail-workspace-label`,"data-i18n":`chat.workspace`,children:`工作区`}),(0,Q.jsx)(`span`,{className:`tw-rail-workspace-name`,children:Wt(Io,Ro)})]}),(dr||pr)&&(0,Q.jsx)(`div`,{className:`text-[11px] text-(--tw-accent)`,children:pr??ot(`tool.running`,void 0,lr.language)})]})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex flex-col flex-1 ${I?`hidden`:``}`,children:[xo?null:(0,Q.jsxs)(`div`,{className:`shrink-0 border-b border-(--tw-border) bg-(--tw-surface-page)`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-3 px-6 pt-4 pb-2 min-w-0`,children:(0,Q.jsx)(`button`,{type:`button`,"data-hint":`点击重命名`,onClick:()=>{let e=a?.activeId;e&&oo(e)},className:`min-w-0 flex-1 text-left text-[18px] leading-7 font-semibold text-(--tw-label-primary) truncate hover:text-[#4176e6] transition-colors`,children:a?.sessions.find(e=>e.id===a.activeId)?.title||`新对话`})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-6 px-6`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>cr(`dialog`),className:`relative h-10 text-sm transition-colors ${sr===`dialog`?`text-[#4176e6] font-medium`:`text-stone-500 hover:text-stone-700`}`,children:[`对话`,sr===`dialog`&&(0,Q.jsx)(`span`,{className:`absolute left-0 right-0 -bottom-px h-0.5 bg-[#4176e6] rounded-full`})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>cr(`thread`),className:`relative h-10 text-sm transition-colors ${sr===`thread`?`text-[#4176e6] font-medium`:`text-stone-500 hover:text-stone-700`}`,children:[`回合`,sr===`thread`&&(0,Q.jsx)(`span`,{className:`absolute left-0 right-0 -bottom-px h-0.5 bg-[#4176e6] rounded-full`})]}),On.memory&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>cr(`memory`),className:`relative h-10 text-sm transition-colors ${sr===`memory`?`text-[#4176e6] font-medium`:`text-stone-500 hover:text-stone-700`}`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[`记忆`,(An?.suggestionCount??0)>0?(0,Q.jsx)(`span`,{className:`min-w-4.5 h-4.5 px-1 inline-flex items-center justify-center rounded-full bg-red-500 text-[10px] font-medium text-white tabular-nums leading-none`,"data-hint":`${An?.suggestionCount} 条待确认`,children:An.suggestionCount>99?`99+`:An.suggestionCount}):null]}),sr===`memory`&&(0,Q.jsx)(`span`,{className:`absolute left-0 right-0 -bottom-px h-0.5 bg-[#4176e6] rounded-full`})]})]}),Kr&&Kr.status!==`cleared`&&sr===`dialog`?(0,Q.jsx)(`div`,{className:`px-6 pb-2`,children:(0,Q.jsxs)(`div`,{className:`rounded-xl border border-[#4176e6]/25 bg-[#f5f8ff] px-3 py-2 flex items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-[11px] font-medium text-[#4176e6] shrink-0 pt-0.5`,children:[`目标`,Kr.status===`done`?`·完成`:``]}),(0,Q.jsx)(`span`,{className:`flex-1 min-w-0 text-[12px] leading-5 ${Kr.status===`done`?`text-stone-400 line-through`:`text-stone-800`}`,children:Kr.text}),(0,Q.jsx)(`button`,{type:`button`,"data-hint":`清除目标`,className:`text-[11px] text-stone-400 hover:text-stone-600 shrink-0`,onClick:()=>{Jr.current=null,qr(null),Yr.current=0,K.current&&q(L(K.current,{goal:void 0}))},children:`清除`})]})}):null,Wr.length>0&&sr===`dialog`?(0,Q.jsx)(`div`,{className:`px-6 pb-3`,children:(0,Q.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`text-[11px] font-medium text-stone-500 mb-1.5`,children:[`待办 · `,Wr.filter(e=>e.status===`completed`).length,`/`,Wr.length]}),(0,Q.jsx)(`ul`,{className:`space-y-1 max-h-28 overflow-y-auto`,children:Wr.map((e,t)=>(0,Q.jsxs)(`li`,{className:`flex items-start gap-2 text-[12px] text-stone-700`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 w-3.5 h-3.5 rounded-sm border shrink-0 flex items-center justify-center text-[9px] ${e.status===`completed`?`bg-emerald-500 border-emerald-500 text-white`:e.status===`in_progress`?`border-[#4176e6] text-[#4176e6]`:`border-stone-300 text-transparent`}`,"aria-hidden":!0,children:e.status===`completed`?`✓`:e.status===`in_progress`?`…`:``}),(0,Q.jsx)(`span`,{className:e.status===`completed`?`line-through text-stone-400`:``,children:e.content})]},`${t}-${e.content}`))})]})}):null]}),sr===`memory`&&On.memory?(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 bg-(--tw-surface-page) tw-pane-enter`,children:(0,Q.jsx)(Il,{live:Or,pluginOn:!!On.memory,workspacePath:a?.sessions.find(e=>e.id===a.activeId)?.workspacePath||B?.projectRoot||``})},`memory-${a?.activeId??``}`):sr===`thread`?(0,Q.jsx)(`div`,{className:`flex-1 min-h-0 bg-(--tw-surface-page) tw-pane-enter overflow-y-auto px-12 sm:px-16 lg:px-20 py-6`,children:(0,Q.jsx)(Gu,{messages:s,busy:!!(a?.activeId&&Ot.includes(a.activeId)),onRestoreCheckpoint:(e,t)=>{let n=K.current?.activeId;if(!n)return;if(Ot.includes(n)||St){R(`请等待当前回复结束后再从此处继续`);return}let r=Math.max(0,Math.min(e,Bi.current.length-1)),i=Bi.current.slice(0,r+1);Bi.current=i,l(i),K.current&&q(Re(K.current,i,{touchUpdatedAt:!0}));let a=`请从第 ${t} 轮继续`;cr(`dialog`),d(a),sn(`ok`),R(`已回到第 ${t} 轮,正在继续…`),window.setTimeout(()=>{ya(a)},0)}})},`thread-${a?.activeId??``}`):(0,Q.jsxs)(`div`,{className:`relative flex-1 min-h-0 flex flex-col${xo?` justify-center`:``}`,children:[xo?(0,Q.jsxs)(`div`,{className:`shrink-0 flex flex-col items-center text-center px-8 sm:px-10 lg:px-12 pb-8`,children:[(0,Q.jsx)(`img`,{src:`/brand-mark.png`,alt:``,width:64,height:64,className:`w-16 h-16 rounded-[14px] object-contain`}),(0,Q.jsx)(`h2`,{className:`mt-5 text-[22px] leading-8 font-semibold tracking-tight text-stone-800 text-balance`,children:ot(`chat.emptyTitle`,void 0,lr.language)})]}):null,xo?null:(0,Q.jsxs)(`div`,{className:`relative flex-1 min-h-0`,children:[(0,Q.jsx)(`div`,{ref:bi,onScroll:J,className:`h-full overflow-y-auto px-8 sm:px-10 lg:px-12 py-6`,style:{fontSize:`var(--tw-session-font-size, ${lr.sessionFontSize}px)`},children:(0,Q.jsx)(`div`,{className:`w-full max-w-[min(64rem,100%)] mx-auto flex flex-col gap-4`,onClick:bo,children:s.map((e,n)=>e.role===`user`?(0,Q.jsxs)(`div`,{className:`group flex flex-col items-end gap-1`,children:[e.refs?.length||e.attachments?.length||e.images?.length?(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1.5 max-w-[82%]`,children:[e.refs?.map(e=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2.5 py-1.5 text-xs text-[#4176e6] bg-white border border-[#4176e6]/30 rounded-lg`,"data-hint":e.path,children:[(0,Q.jsx)(uu,{className:`w-3.5 h-3.5`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-stone-400 shrink-0`,children:Jc(e.format)}),(0,Q.jsx)(`span`,{className:`max-w-40 truncate`,children:e.title})]},e.path)),e.attachments?.map(e=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2.5 py-1.5 text-xs text-stone-600 bg-white border border-stone-200 rounded-lg`,children:[(0,Q.jsx)(uu,{className:`w-3.5 h-3.5 text-[#4176e6]`}),(0,Q.jsx)(`span`,{className:`max-w-48 truncate`,children:e.name}),(0,Q.jsx)(`span`,{className:`text-stone-400`,children:Iu(e.size)})]},e.name)),e.images?.map(e=>(0,Q.jsx)(`a`,{href:e.dataUrl,target:`_blank`,rel:`noreferrer`,className:`block overflow-hidden rounded-lg border border-stone-200 bg-white`,"data-hint":e.name,children:(0,Q.jsx)(`img`,{src:e.dataUrl,alt:e.name,className:`max-h-40 max-w-48 object-contain`})},e.id))]}):null,e.content&&(0,Q.jsx)(`div`,{className:`tw-chat-text max-w-[82%] px-4 py-2.5 bg-[#edf3fe] rounded-2xl whitespace-pre-wrap break-words`,children:e.content}),(0,Q.jsxs)(`div`,{className:`tw-msg-actions ${Eo(n)}`,children:[e.time!=null&&(0,Q.jsx)(`span`,{className:`tw-msg-action-time pr-0.5`,children:Lu(e.time)}),(0,Q.jsx)(zu,{text:e.content})]})]},n):(0,Q.jsxs)(`div`,{className:`group`,children:[e.turnStatus===`stopped`?(0,Q.jsxs)(`div`,{className:`mb-2`,children:[(0,Q.jsx)(`div`,{className:`text-[13px] text-stone-500 py-1`,children:`已停止`}),(0,Q.jsx)(`div`,{className:`border-t border-stone-200/80`})]}):null,(()=>{let t=e.activitySteps??[],r=t.some(e=>e.status===`running`),i=n===s.length-1&&e.turnStatus!==`stopped`&&(St||r),a=i&&!e.content,o=t.filter(e=>e.kind!==`thinking`);if(!(a||e.reasoning||o.length>0||t.length>0))return null;let c=e.reasoningOpen??!1,l=i||c||r,u=a&&!c&&!l&&e.reasoning?nu(e.reasoning).replaceAll(`**`,``):``;return(0,Q.jsxs)(`div`,{className:`mb-2`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>Ea(n,e),className:`flex w-full items-center gap-2 py-1 text-left select-none`,children:[a||i&&!e.content?(0,Q.jsx)(`span`,{className:`w-3.5 h-3.5 shrink-0 rounded-full border-2 border-purple-400 border-t-transparent animate-spin`}):(0,Q.jsxs)($,{className:`w-3.5 h-3.5 shrink-0 text-stone-400`,children:[(0,Q.jsx)(`path`,{d:`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`}),(0,Q.jsx)(`path`,{d:`M9 18h6`}),(0,Q.jsx)(`path`,{d:`M10 22h4`})]}),(0,Q.jsx)(`span`,{className:`text-[13px] font-medium shrink-0 ${i&&!e.content?`text-shimmer`:`text-shimmer-static`}`,children:i&&!e.content?t.some(e=>e.kind!==`thinking`&&e.status===`running`)?`正在分析请求`:`思考中…`:i?`正在生成…`:e.turnStatus===`stopped`?`已完成分析`:`思考完成`}),!i&&e.reasoningDuration!=null&&(0,Q.jsxs)(`span`,{className:`text-xs text-stone-400 shrink-0`,children:[`用时 `,e.reasoningDuration,`s`]}),(0,Q.jsx)(iu,{className:`w-3.5 h-3.5 shrink-0 text-stone-400 transition-transform ${c?`rotate-180`:``}`}),u?(0,Q.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-xs text-shimmer-muted think-mask`,children:u}):null]}),l&&t.length>0?(0,Q.jsx)(`ul`,{className:`mt-1.5 mb-1 pl-5.5 space-y-1.5`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:`text-[12px] flex items-start gap-2 min-w-0 ${e.status===`error`?`text-red-600`:e.status===`running`?`text-stone-600`:`text-stone-500`}`,children:[(0,Q.jsx)(eu,{kind:e.kind,status:e.status}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 leading-5`,children:[(0,Q.jsx)(`span`,{className:`font-medium ${e.status===`running`?`text-shimmer`:``}`,children:e.title}),e.detail?(0,Q.jsxs)(`span`,{className:`text-stone-400`,children:[` · `,(0,Q.jsx)(`span`,{className:e.status===`error`?`text-red-600`:e.status===`running`?`text-shimmer-muted`:``,"data-hint":e.detail,children:e.detail.length>72?`${e.detail.slice(0,72)}…`:e.detail})]}):e.status===`running`?(0,Q.jsxs)(`span`,{className:`text-stone-400 text-shimmer-muted`,children:[` · `,`…`]}):null]})]},e.id))}):null,c&&e.reasoning?(0,Q.jsx)(`div`,{className:`mt-1.5 mb-2 pl-5.5 text-[13px] leading-5 text-stone-500 whitespace-pre-wrap max-h-80 overflow-y-auto`,children:e.reasoning}):null,e.turnStatus===`stopped`?(0,Q.jsx)(`div`,{className:`mt-1.5 pl-5.5`,children:(0,Q.jsx)(`span`,{className:`tw-turn-stopped-pill`,children:`已停止`})}):null]})})(),e.content?(0,Q.jsx)(`div`,{className:`chat-md prose prose-sm prose-stone max-w-none tw-chat-text`,dangerouslySetInnerHTML:{__html:Ka(e.content)}}):null,e.caseFile?(0,Q.jsxs)(`button`,{type:`button`,"data-focus-doc":`cases:${e.caseFile.path.replace(/\\/g,`/`)}`,"data-hint":`双击本地打开`,onDoubleClick:()=>{se(`cases`,e.caseFile.path).catch(e=>R(e instanceof Error?e.message:String(e)))},className:`mt-3 w-full max-w-md flex items-center gap-3 rounded-xl border border-stone-200 bg-white px-3 py-2.5 text-left hover:border-[#4176e6] hover:bg-[#f5f8ff] transition-colors cursor-pointer`,children:[(0,Q.jsx)(`span`,{className:`w-10 h-10 rounded-lg bg-emerald-50 text-emerald-700 flex items-center justify-center text-[10px] font-semibold shrink-0`,children:e.caseFile.name.split(`.`).pop()?.toUpperCase()||`FILE`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm text-stone-800 truncate`,children:e.caseFile.name}),(0,Q.jsxs)(`span`,{className:`block text-[11px] text-stone-400 truncate`,children:[N(`cases`),e.caseFile.path,e.caseFile.count>0?` · ${e.caseFile.count} 条`:``,` · 双击本地打开`]})]})]}):null,e.docsFile?(0,Q.jsxs)(`button`,{type:`button`,"data-focus-doc":`${e.docsFile.root}:${e.docsFile.path.replace(/\\/g,`/`)}`,"data-hint":`点击本地打开`,onClick:()=>{se(e.docsFile.root,e.docsFile.path).catch(e=>R(e instanceof Error?e.message:String(e)))},className:`mt-3 w-full max-w-md flex items-center gap-3 rounded-xl border border-stone-200 bg-white px-3 py-2.5 text-left hover:border-[#4176e6] hover:bg-[#f5f8ff] transition-colors cursor-pointer`,children:[(0,Q.jsx)(`span`,{className:`w-10 h-10 rounded-lg flex items-center justify-center text-[10px] font-semibold shrink-0 ${e.docsFile.root===`knowledge`?`bg-amber-50 text-amber-800`:`bg-sky-50 text-sky-700`}`,children:e.docsFile.name.split(`.`).pop()?.toUpperCase()||`MD`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm text-stone-800 truncate`,children:e.docsFile.name}),(0,Q.jsxs)(`span`,{className:`block text-[11px] text-stone-400 truncate`,children:[N(e.docsFile.root),e.docsFile.path,e.docsFile.note?` · ${e.docsFile.note}`:``,` · 点击打开`]})]})]}):null,e.presentFiles?.length?e.presentFiles.map(e=>(0,Q.jsxs)(`button`,{type:`button`,"data-hint":`点击本地打开`,onClick:()=>{At(e.path,cn).catch(e=>R(e instanceof Error?e.message:String(e)))},className:`mt-3 w-full max-w-md flex items-center gap-3 rounded-xl border border-stone-200 bg-white px-3 py-2.5 text-left hover:border-[#4176e6] hover:bg-[#f5f8ff] transition-colors cursor-pointer`,children:[(0,Q.jsx)(`span`,{className:`w-10 h-10 rounded-lg bg-violet-50 text-violet-700 flex items-center justify-center text-[10px] font-semibold shrink-0`,children:e.name.split(`.`).pop()?.toUpperCase()||`FILE`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`block text-sm text-stone-800 truncate`,children:e.name}),(0,Q.jsxs)(`span`,{className:`block text-[11px] text-stone-400 truncate`,children:[e.path,e.description?` · ${e.description}`:``,` · 点击打开`]})]})]},e.path)):null,e.content&&!(n===s.length-1&&St)?(0,Q.jsxs)(`div`,{className:`tw-msg-actions mt-1 ${Eo(n)}`,children:[(0,Q.jsx)(zu,{text:e.content}),e.usage&&(0,Q.jsx)(qu,{usage:e.usage,model:e.model??t?.model}),e.time!=null&&(0,Q.jsx)(`span`,{className:`tw-msg-action-time`,children:Lu(e.time)})]}):null]},n))})}),un&&(0,Q.jsx)(`button`,{type:`button`,onClick:aa,"data-hint":`回到底部`,className:`absolute bottom-3 right-8 sm:right-10 lg:right-12 w-8 h-8 rounded-full bg-white border border-stone-200 shadow-md flex items-center justify-center text-stone-500 hover:text-stone-800 transition-colors`,children:(0,Q.jsx)(iu,{className:`w-4 h-4`})})]},`dialog-${a?.activeId??``}`),Vt&&(0,Q.jsx)(`div`,{className:`shrink-0 px-8 sm:px-10 lg:px-12 pb-2`,children:(0,Q.jsxs)(`div`,{ref:Ei,className:`w-full max-w-[min(64rem,100%)] mx-auto flex items-start gap-3 px-4 py-3 rounded-xl text-sm border ${nn===`ok`?`tw-notice-anim`:``} ${nn===`ok`?`bg-emerald-50 border-emerald-200 text-emerald-900`:`bg-red-50 border-red-200 text-red-800`}`,children:[(0,Q.jsx)(`span`,{className:`mt-0.5 w-5 h-5 shrink-0 rounded-full flex items-center justify-center text-xs font-semibold ${nn===`ok`?`bg-emerald-100 text-emerald-700`:`bg-red-100 text-red-600`}`,children:nn===`ok`?`i`:`!`}),(0,Q.jsx)(`pre`,{className:`flex-1 min-w-0 m-0 font-sans text-[13px] leading-5 whitespace-pre-wrap break-words`,children:Vt.replace(/\*\*/g,``).replace(/\s*:\s*\*\*/g,`: `).trim()}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>R(null),className:`shrink-0 text-xs ${nn===`ok`?`text-emerald-500 hover:text-emerald-700`:`text-red-400 hover:text-red-600`}`,children:`关闭`})]})}),(0,Q.jsxs)(`div`,{className:`shrink-0 px-8 sm:px-10 lg:px-12 pb-3`,children:[(0,Q.jsxs)(`div`,{className:`w-full max-w-[min(64rem,100%)] mx-auto`,children:[E?.active&&On.promptGen?(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 px-3 py-2 rounded-xl border border-[#4176e6]/30 bg-[#edf3fe] text-xs text-[#3565c7]`,children:[(0,Q.jsxs)(`span`,{className:`flex-1 min-w-0 truncate`,children:[`生成提示词已启用 · `,co(E)]}),(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 hover:underline`,onClick:()=>T(!0),children:`改配置`}),(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 text-stone-500 hover:text-stone-800`,onClick:()=>Na(null),children:`取消`})]}):null,k?.active&&On.knowledgeGen?(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 px-3 py-2 rounded-xl border border-amber-300/60 bg-amber-50 text-xs text-amber-900`,children:[(0,Q.jsxs)(`span`,{className:`flex-1 min-w-0 truncate`,children:[`生成知识库已启用 · `,Co(k)]}),(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 hover:underline`,onClick:()=>O(!0),children:`改配置`}),(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 text-stone-500 hover:text-stone-800`,onClick:()=>Pa(null),children:`取消`})]}):null,x?.active&&On.caseGen?(0,Q.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 px-3 py-2 rounded-xl border border-[#4176e6]/30 bg-[#edf3fe] text-xs text-[#3565c7]`,children:[(0,Q.jsxs)(`span`,{className:`flex-1 min-w-0 truncate`,children:[`生成测试用例已启用 · `,qa(x)]}),(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 hover:underline`,onClick:()=>b(!0),children:`改配置`}),(0,Q.jsx)(`button`,{type:`button`,className:`shrink-0 text-stone-500 hover:text-stone-800`,onClick:()=>Ma(null),children:`取消`})]}):null,wr.length>0?(0,Q.jsx)(`div`,{className:`mb-2 rounded-xl border border-stone-200/80 bg-stone-100/80 overflow-hidden`,children:wr.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 border-b border-stone-200/60 last:border-b-0`,children:[(0,Q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-stone-400 shrink-0`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-[13px] text-stone-700`,children:yi(e)}),(0,Q.jsx)(`button`,{type:`button`,"data-hint":`编辑回输入框`,onClick:()=>Ca(e.id),className:`tw-icon-btn w-7 h-7 rounded-md flex items-center justify-center outline-none`,children:(0,Q.jsxs)($,{className:`w-3.5 h-3.5`,children:[(0,Q.jsx)(`path`,{d:`M12 20h9`}),(0,Q.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}),(0,Q.jsx)(`button`,{type:`button`,"data-hint":`从队列移除`,onClick:()=>Sa(e.id),className:`tw-icon-btn w-7 h-7 rounded-md flex items-center justify-center outline-none`,children:(0,Q.jsxs)($,{className:`w-3.5 h-3.5`,children:[(0,Q.jsx)(`path`,{d:`M3 6h18`}),(0,Q.jsx)(`path`,{d:`M8 6V4h8v2`}),(0,Q.jsx)(`path`,{d:`M19 6l-1 14H6L5 6`})]})}),(0,Q.jsx)(`button`,{type:`button`,"data-hint":`插话立即发送(其后队列仍会续发)`,onClick:()=>wa(e.id),className:`tw-icon-btn w-7 h-7 rounded-md flex items-center justify-center outline-none text-[#4176e6]`,children:(0,Q.jsx)(fu,{className:`w-3.5 h-3.5`})})]},e.id))}):null,ti?(0,Q.jsxs)(`div`,{className:`mb-2 rounded-xl border border-amber-300/60 bg-amber-50/90 px-4 py-3 shadow-sm`,children:[(0,Q.jsx)(`div`,{className:`text-[13px] font-medium text-stone-800 mb-1`,children:`待批准计划`}),(0,Q.jsx)(`div`,{className:`text-[14px] font-medium text-stone-900`,children:ti.title}),ti.summary?(0,Q.jsx)(`p`,{className:`mt-1 text-[13px] text-stone-600 leading-5`,children:ti.summary}):null,(0,Q.jsx)(`ol`,{className:`mt-2 list-decimal pl-5 space-y-1 text-[13px] text-stone-700`,children:ti.steps.map((e,t)=>(0,Q.jsx)(`li`,{children:e},`${t}-${e.slice(0,24)}`))}),(0,Q.jsxs)(`div`,{className:`mt-3 flex items-center justify-end gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`h-8 px-3 rounded-lg border border-stone-200 bg-white text-[12px] text-stone-600 hover:bg-stone-50`,onClick:()=>Ra(),children:`驳回`}),(0,Q.jsx)(`button`,{type:`button`,className:`h-8 px-3 rounded-lg bg-[#4176e6] text-[12px] text-white hover:bg-[#3467d4]`,onClick:()=>La(),children:`批准实施`})]})]}):null,vs>0&&bs?(0,Q.jsxs)(`div`,{className:`mb-2 flex max-h-[min(60vh,520px)] flex-col overflow-hidden rounded-2xl border border-stone-200 bg-white shadow-[0_6px_24px_rgba(15,23,42,0.08)]`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-between gap-4 px-5 ${li?`items-center py-3.5`:`items-start pt-4`}`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`div`,{className:`mb-1 text-[11px] leading-4 text-stone-400`,children:pi?`跳过确认`:bs.header||`模型需要你的确认`}),(0,Q.jsx)(`h3`,{className:`text-[15px] leading-5.5 font-medium text-stone-900`,children:pi?`确认 ${Ns.length} 道跳过的题怎么处理`:bs.question})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[li?(0,Q.jsx)(`span`,{className:`text-[11px] leading-4 text-stone-400`,children:pi?`已跳过 ${Ns.length} 题`:`第 ${ys+1} 步 / 共 ${vs} 步`}):null,(0,Q.jsx)(`button`,{type:`button`,"aria-label":li?`展开问题`:`收起问题`,onClick:()=>ui(e=>!e),className:`grid h-6 w-6 place-items-center rounded-full text-stone-400 outline-none hover:bg-stone-100 hover:text-stone-600`,children:(0,Q.jsx)(iu,{className:`h-4 w-4 transition-transform ${li?`rotate-180`:``}`})})]})]}),li?null:pi?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-2`,children:[(0,Q.jsx)(`p`,{className:`text-[12px] leading-5 text-stone-500`,children:`跳过不算确认,本轮不会开始改代码。留下原因后我只出方案,等你回复「开始实施」。`}),(0,Q.jsx)(`ul`,{className:`mt-2 space-y-1 rounded-lg bg-stone-50 px-3 py-2`,children:Ns.map(({q:e,index:t})=>(0,Q.jsxs)(`li`,{className:`text-[12px] leading-5 text-stone-600`,children:[(0,Q.jsxs)(`span`,{className:`text-stone-400`,children:[t+1,`.`]}),` `,e.header?`${e.header} / `:``,e.question,(0,Q.jsx)(`span`,{className:`ml-1 text-stone-400`,children:`— 已跳过`})]},e.id))}),(0,Q.jsx)(`textarea`,{autoFocus:!0,value:hi,onChange:e=>gi(e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),$a())},rows:3,className:`mt-2 w-full resize-none rounded-lg border border-stone-200 px-2.5 py-2 text-[13px] leading-5 outline-none focus:border-[#4176e6]`,placeholder:`为什么跳过这几题?例如:先只做评估,方案我稍后定 / 这几项按你推荐的来`})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 px-5 pt-2 pb-3`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>eo(),className:`h-8 shrink-0 rounded-lg px-2 text-[12px] text-stone-500 outline-none hover:bg-stone-100 hover:text-stone-700`,children:`返回继续回答`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>$a(),className:`h-8 shrink-0 rounded-lg bg-[#4176e6] px-3.5 text-[12px] font-medium text-white hover:bg-[#3467d4]`,children:`提交并继续`})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-1`,children:[bs.options?.length?(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col gap-0.5`,role:bs.multi_select?`group`:`radiogroup`,children:bs.options.map((e,t)=>{let n=Ss.selected.includes(e.label),r=Bl(e.label);return(0,Q.jsxs)(`button`,{type:`button`,role:bs.multi_select?`checkbox`:`radio`,"aria-checked":n,onClick:()=>Ha(bs,e.label,n),className:`flex w-full shrink-0 items-start gap-2 rounded-lg border px-2 py-2 text-left outline-none transition-colors ${n?`border-[#4176e6]/40 bg-[#f2f7ff]`:`border-transparent hover:bg-stone-50`}`,children:[bs.multi_select?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 grid h-4 w-4 shrink-0 place-items-center rounded border ${n?`border-[#4176e6] bg-[#4176e6] text-white`:`border-stone-300 text-transparent`}`,children:(0,Q.jsx)(ou,{className:`h-3 w-3`})}):(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 grid h-5 w-5 shrink-0 place-items-center rounded-md text-[11px] font-medium ${n?`bg-[#4176e6] text-white`:`bg-stone-100 text-stone-500`}`,children:t+1}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] leading-5 font-medium text-stone-800`,children:r.label}),r.recommended?(0,Q.jsx)(`span`,{className:`rounded bg-[#edf3fe] px-1 text-[10px] leading-4 font-semibold text-[#4176e6]`,children:`推荐`}):null]}),e.description?(0,Q.jsx)(`span`,{className:`mt-0.5 block text-[12px] leading-4.5 text-stone-400`,children:e.description}):null]})]},`${e.label}-${t}`)})}):(0,Q.jsx)(`div`,{className:`px-1.5 py-2`,children:(0,Q.jsx)(`textarea`,{autoFocus:!0,value:Ss.text,onChange:e=>Wa(bs,e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),Ga(bs,Ss.text))},rows:2,className:`w-full resize-none rounded-lg border border-stone-200 px-2.5 py-2 text-[13px] leading-5 outline-none focus:border-[#4176e6]`,placeholder:`输入你的回答…`})}),bs.options?.length?(0,Q.jsx)(`div`,{className:`mt-1 px-1.5 pb-1`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-stone-200 px-2 py-1.5 focus-within:border-[#4176e6]`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`mt-0.5 grid h-4 w-4 shrink-0 place-items-center rounded bg-stone-100 text-[10px] font-medium text-stone-500`,children:`#`}),(0,Q.jsx)(`textarea`,{value:Ss.text,onChange:e=>Wa(bs,e.target.value),onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),Ga(bs,Ss.text))},rows:1,className:`min-h-5 w-full resize-none bg-transparent text-[13px] leading-5 outline-none`,placeholder:`输入序号选择(如 1${bs.multi_select?` 或 1,3`:``}),也可直接写你的回答`})]})}):null,(0,Q.jsx)(`div`,{className:`px-2 pb-2 pt-1 text-[11px] leading-4 text-stone-400`,children:bs.options?.length?`回车确认这一步;跳过的题会在提交前让你说明原因,不会直接开始实施`:`回车确认;跳过的题会在提交前让你说明原因,不会直接开始实施`})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 px-5 pt-2 pb-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":`上一步`,disabled:ys===0,onClick:()=>Ua(ys-1),className:`grid h-6 w-6 place-items-center rounded-full text-stone-400 outline-none hover:bg-stone-100 hover:text-stone-600 disabled:cursor-default disabled:text-stone-200 disabled:hover:bg-transparent`,children:(0,Q.jsx)(au,{className:`h-4 w-4 rotate-180`})}),(0,Q.jsxs)(`span`,{className:`px-1 text-[12px] font-medium text-stone-500`,children:[`第 `,ys+1,` 步 / 共 `,vs,` 步`]}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`下一步`,disabled:Cs,onClick:()=>Ua(ys+1),className:`grid h-6 w-6 place-items-center rounded-full text-stone-400 outline-none hover:bg-stone-100 hover:text-stone-600 disabled:cursor-default disabled:text-stone-200 disabled:hover:bg-transparent`,children:(0,Q.jsx)(au,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[di?(0,Q.jsx)(`span`,{className:`truncate text-[11px] text-rose-500`,children:di}):null,(0,Q.jsx)(`button`,{type:`button`,onClick:()=>Xa(),className:`h-8 shrink-0 rounded-lg px-2 text-[12px] text-stone-500 outline-none hover:bg-stone-100 hover:text-stone-700`,children:`跳过`}),(0,Q.jsx)(`button`,{type:`button`,disabled:!Es,onClick:()=>Cs?Ya():Ua(ys+1),className:`h-8 shrink-0 rounded-lg bg-[#4176e6] px-3.5 text-[12px] font-medium text-white hover:bg-[#3467d4] disabled:cursor-not-allowed disabled:bg-stone-300`,children:Cs?`提交回答`:`下一步`})]})]})]})]}):null,(0,Q.jsxs)(`div`,{ref:Di,className:`pt-2 rounded-[20px] bg-white border border-stone-200 shadow-[0_4px_20px_rgba(15,23,42,0.06)] transition-shadow focus-within:shadow-[0_4px_24px_rgba(65,118,230,0.14)]`,children:[(g.length>0||f.length>0||m.length>0)&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pt-0.5 pb-2`,children:[g.map(e=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 pl-2.5 pr-1 py-1 text-xs text-[#4176e6] bg-[#edf3fe] border border-[#4176e6]/25 rounded-lg`,"data-hint":e.collection===`workspace`?e.path:`${e.collection}/${e.path}`,children:[(0,Q.jsx)(uu,{className:`w-3.5 h-3.5`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-[#4176e6]/80 shrink-0`,children:e.collection===`workspace`?`工作区`:e.collection===`prompts`||e.collection===`cases`||e.collection===`knowledge`?e.category:Jc(e.format)}),(0,Q.jsx)(`span`,{className:`max-w-48 truncate`,children:e.title}),(0,Q.jsx)(`button`,{type:`button`,"data-hint":`移除引用`,onClick:()=>_(t=>t.filter(t=>t.collection!==e.collection||t.path!==e.path)),className:`w-5 h-5 flex items-center justify-center rounded text-[#4176e6]/70 hover:text-[#4176e6] hover:bg-white/80`,children:(0,Q.jsxs)($,{className:`w-3 h-3`,children:[(0,Q.jsx)(`path`,{d:`M18 6 6 18`}),(0,Q.jsx)(`path`,{d:`m6 6 12 12`})]})})]},`${e.collection}:${e.path}`)),f.map((e,t)=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-1.5 pl-2.5 pr-1 py-1 text-xs text-[#4176e6] bg-[#edf3fe] border border-[#4176e6]/25 rounded-lg`,"data-hint":e.path||e.name,children:[(0,Q.jsx)(uu,{className:`w-3.5 h-3.5`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-[#4176e6]/80 shrink-0`,children:`文件`}),(0,Q.jsx)(`span`,{className:`max-w-48 truncate`,children:e.name}),(0,Q.jsx)(`button`,{type:`button`,"data-hint":`移除`,onClick:()=>p(e=>e.filter((e,n)=>n!==t)),className:`w-5 h-5 flex items-center justify-center rounded text-[#4176e6]/70 hover:text-[#4176e6] hover:bg-white/80`,children:(0,Q.jsxs)($,{className:`w-3 h-3`,children:[(0,Q.jsx)(`path`,{d:`M18 6 6 18`}),(0,Q.jsx)(`path`,{d:`m6 6 12 12`})]})})]},`${e.name}-${t}`)),m.map(e=>(0,Q.jsxs)(`span`,{className:`relative group inline-flex rounded-lg border border-stone-200 overflow-hidden bg-stone-50`,"data-hint":`${e.name} · ${Iu(e.size)}`,children:[(0,Q.jsx)(`img`,{src:e.dataUrl,alt:e.name,className:`h-14 w-14 object-cover`}),(0,Q.jsx)(`button`,{type:`button`,"data-hint":`移除图片`,onClick:()=>h(t=>t.filter(t=>t.id!==e.id)),className:`absolute top-0.5 right-0.5 w-5 h-5 flex items-center justify-center rounded bg-black/55 text-white hover:bg-black/75`,children:(0,Q.jsxs)($,{className:`w-3 h-3`,children:[(0,Q.jsx)(`path`,{d:`M18 6 6 18`}),(0,Q.jsx)(`path`,{d:`m6 6 12 12`})]})})]},e.id))]}),(0,Q.jsxs)(`div`,{className:`relative`,children:[br&&!Ii&&!Ni&&(0,Q.jsx)(`div`,{ref:Ti,className:`tw-composer-menu tw-popover-anim absolute bottom-full left-0 right-0 mb-3 z-40 h-[min(70vh,20rem)] overflow-hidden rounded-xl border border-stone-200 py-2.5 shadow-[0_4px_14px_-4px_rgba(15,23,42,0.08)]`,children:(0,Q.jsxs)(`div`,{className:`tw-dsh-scroll h-full overflow-y-auto overflow-x-hidden`,children:[(0,Q.jsx)(`div`,{className:`px-3 pt-0.5 pb-1.5 text-[11px] font-medium text-stone-400 tracking-wide`,children:`添加`}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{xr(!1),Si.current?.click()},className:`tw-composer-menu-item w-full flex items-center gap-2.5 px-3 py-2 text-left rounded-lg hover:bg-stone-100`,children:[(0,Q.jsx)(du,{className:`w-4 h-4 shrink-0 text-stone-500`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 text-[13px] text-stone-800`,children:[`文件`,(0,Q.jsx)(`span`,{className:`ml-1.5 text-stone-400 font-normal`,children:`file`})]}),(0,Q.jsx)(`span`,{className:`shrink-0 max-w-[45%] text-right text-[11px] text-stone-400 truncate`,children:`添加本地附件`})]}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{xr(!1),ma()},className:`tw-composer-menu-item w-full flex items-center gap-2.5 px-3 py-2 text-left rounded-lg hover:bg-stone-100`,children:[(0,Q.jsxs)($,{className:`w-4 h-4 shrink-0 text-stone-500`,children:[(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`6`}),(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`2`})]}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 text-[13px] text-stone-800`,children:[`目标`,(0,Q.jsx)(`span`,{className:`ml-1.5 text-stone-400 font-normal`,children:`goal`})]}),(0,Q.jsx)(`span`,{className:`shrink-0 max-w-[45%] text-right text-[11px] text-stone-400 truncate`,children:`设置或查看长期任务目标`})]}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{xr(!1),Zr===`off`?ha():za()},className:`tw-composer-menu-item w-full flex items-center gap-2.5 px-3 py-2 text-left rounded-lg hover:bg-stone-100 ${Zr===`planning`?`bg-amber-50`:Zr===`approved`?`bg-emerald-50`:``}`,children:[(0,Q.jsxs)($,{className:`w-4 h-4 shrink-0 ${Zr===`planning`?`text-amber-800`:Zr===`approved`?`text-emerald-800`:`text-stone-500`}`,children:[(0,Q.jsx)(`path`,{d:`M8 6h13`}),(0,Q.jsx)(`path`,{d:`M8 12h13`}),(0,Q.jsx)(`path`,{d:`M8 18h13`}),(0,Q.jsx)(`path`,{d:`M3 6h.01`}),(0,Q.jsx)(`path`,{d:`M3 12h.01`}),(0,Q.jsx)(`path`,{d:`M3 18h.01`})]}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 text-[13px] text-stone-800`,children:[`计划`,(0,Q.jsx)(`span`,{className:`ml-1.5 text-stone-400 font-normal`,children:`plan`})]}),(0,Q.jsx)(`span`,{className:`shrink-0 max-w-[45%] text-right text-[11px] text-stone-400 truncate`,children:`进入或退出计划模式`})]}),Fi.length?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 border-t border-stone-100`}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>Cr(e=>!e),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left hover:bg-stone-50`,children:[(0,Q.jsx)(`span`,{className:`flex-1 text-[11px] font-medium text-stone-400 tracking-wide`,children:`扩展插件`}),(0,Q.jsx)(iu,{className:`w-3.5 h-3.5 text-stone-400 shrink-0 transition-transform ${Sr?`rotate-180`:``}`})]}),Sr?Fi.map(e=>{let t=e.id===`caseGen`?`case`:e.id===`promptGen`?`prompt`:e.id===`knowledgeGen`?`knowledge`:e.id===`pluginDev`?`dev`:``,n=e.id===`caseGen`?`打开配置后生成用例并写入用例库`:e.id===`promptGen`?`对话生成提示词并写入提示词库`:e.id===`knowledgeGen`?`对话生成规范/方法论并写入知识库`:e.id===`pluginDev`?`输入需求后先评估确认,再开发扩展插件`:``;return(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{xr(!1),ia(e.id)},className:`tw-composer-menu-item w-full flex items-center gap-2.5 px-3 py-2 text-left rounded-lg hover:bg-stone-100`,children:[(0,Q.jsx)(bu,{className:`w-4 h-4 shrink-0 text-stone-500`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 text-[13px] text-stone-800`,children:[e.name,t?(0,Q.jsx)(`span`,{className:`ml-1.5 text-stone-400 font-normal`,children:t}):null]}),n?(0,Q.jsx)(`span`,{className:`shrink-0 max-w-[45%] text-right text-[11px] text-stone-400 truncate`,children:n}):null]},e.id)}):null]}):null,(0,Q.jsx)(`div`,{className:`my-1 border-t border-stone-100`}),(0,Q.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 text-[11px] font-medium text-stone-400 tracking-wide`,children:`指令`}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{xr(!1),Vr.current?R(`请等待当前回复结束后再压缩`):va({force:!0}).then(e=>{e&&R(`已压缩上下文`)})},className:`tw-composer-menu-item w-full flex items-center gap-2.5 px-3 py-2 text-left rounded-lg hover:bg-stone-100`,children:[(0,Q.jsx)($,{className:`w-4 h-4 shrink-0 text-stone-500`,children:(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`})}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 text-[13px] text-stone-800`,children:[`压缩`,(0,Q.jsx)(`span`,{className:`ml-1.5 text-stone-400 font-normal`,children:`compact`})]}),(0,Q.jsx)(`span`,{className:`shrink-0 max-w-[45%] text-right text-[11px] text-stone-400 truncate`,children:`压缩以上对话内容`})]}),(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{xr(!1),so()},className:`tw-composer-menu-item w-full flex items-center gap-2.5 px-3 py-2 text-left rounded-lg hover:bg-stone-100`,children:[(0,Q.jsxs)($,{className:`w-4 h-4 shrink-0 text-stone-500`,children:[(0,Q.jsx)(`path`,{d:`M3 3v18h18`}),(0,Q.jsx)(`path`,{d:`M7 14v4`}),(0,Q.jsx)(`path`,{d:`M12 10v8`}),(0,Q.jsx)(`path`,{d:`M17 6v12`})]}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 text-[13px] text-stone-800`,children:[`会话统计`,(0,Q.jsx)(`span`,{className:`ml-1.5 text-stone-400 font-normal`,children:`stats`})]}),(0,Q.jsx)(`span`,{className:`shrink-0 max-w-[45%] text-right text-[11px] text-stone-400 truncate`,children:`查看本会话用量摘要`})]})]})}),Ii&&(0,Q.jsxs)(`div`,{ref:wi,className:`tw-composer-menu tw-popover-anim absolute bottom-full left-0 right-0 mb-2 mx-2 z-40 max-h-64 overflow-y-auto rounded-xl border border-stone-200 shadow-xl p-1`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-stone-400`,children:`插件`}),Fi.map((e,t)=>(0,Q.jsxs)(`button`,{type:`button`,"data-plugin-index":t,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>me(t),onClick:()=>ia(e.id),className:`tw-composer-menu-item w-full text-left px-3 py-2 rounded-lg transition-colors ${t===pe?`is-active`:``}`,children:[(0,Q.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,Q.jsx)(`div`,{className:`text-[13px] font-medium text-stone-800 flex-1`,children:e.name})}),(0,Q.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 line-clamp-2`,children:e.description})]},e.id))]}),Ni&&(0,Q.jsx)(`div`,{ref:Ci,className:`tw-composer-menu tw-popover-anim absolute bottom-full left-0 right-0 mb-2 mx-2 z-40 max-h-64 overflow-y-auto rounded-xl border border-stone-200 shadow-xl p-1`,children:G.length===0?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-stone-400 space-y-1`,children:[kr?(0,Q.jsx)(`p`,{children:`项目文档:无匹配`}):null,ki?(0,Q.jsx)(`p`,{children:`工作区:无匹配`}):(0,Q.jsx)(`p`,{children:`工作区:请先在侧栏添加并选择工作区`}),kr?null:(0,Q.jsxs)(`p`,{children:[`「知识库检索」未启用:启用后才能用 @ 引用`,le(`knowledge`),` / `,le(`templates`),`文档`]})]}):(0,Q.jsxs)(Q.Fragment,{children:[ji.length>0?(0,Q.jsxs)(`div`,{className:`px-3 py-1.5 text-[11px] font-medium text-stone-400`,children:[`项目文档(`,le(`knowledge`),` / `,le(`templates`),`)`]}):null,G.map((e,t)=>{let n=e.doc,r=G[t-1],i=e.section===`workspace`&&r?.section!==`workspace`;return(0,Q.jsxs)(`div`,{children:[i?(0,Q.jsxs)(Q.Fragment,{children:[ji.length>0?(0,Q.jsx)(`div`,{className:`my-1 mx-2 border-t border-stone-200`,role:`separator`}):null,(0,Q.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] font-medium text-stone-400`,children:`工作区`})]}):null,(0,Q.jsxs)(`button`,{type:`button`,"data-mention-index":t,onMouseDown:e=>e.preventDefault(),onClick:()=>ta(n),className:`tw-composer-menu-item w-full text-left px-3 py-2 rounded-lg transition-colors ${t===mr?`is-active`:``}`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[13px] text-stone-800`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] px-1.5 py-0.5 rounded bg-stone-100 text-stone-500 shrink-0`,children:n.collection===`knowledge`?le(`knowledge`):n.collection===`templates`?le(`templates`):n.format===`dir`?`文件夹`:`文件`}),n.collection===`workspace`?null:(0,Q.jsx)(`span`,{className:`text-[11px] px-1.5 py-0.5 rounded bg-stone-100 text-stone-500 shrink-0`,children:Jc(n.format)}),(0,Q.jsx)(`span`,{className:`truncate font-medium`,children:n.title})]}),(0,Q.jsx)(`div`,{className:`mt-0.5 pl-0 text-xs text-stone-400 truncate`,children:n.collection===`workspace`?n.path:`${n.category}${n.description?` · ${n.description}`:``}`})]})]},`${n.collection}/${n.id}`)}),kr?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`my-1 mx-2 border-t border-stone-200`,role:`separator`}),(0,Q.jsx)(`p`,{className:`px-3 py-1.5 text-[11px] text-stone-400`,children:`「知识库检索」未启用:@ 仅引用工作区文件`})]})]})}),(0,Q.jsxs)(`div`,{className:`flex items-start gap-2 px-3`,children:[$r===`goal`?(0,Q.jsxs)(`span`,{className:`tw-composer-mode-chip is-goal`,"data-hint":`会话目标`,children:[(0,Q.jsxs)($,{className:`w-3.5 h-3.5 shrink-0`,children:[(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`6`}),(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`2`})]}),(0,Q.jsx)(`span`,{children:`目标`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`取消目标输入`,onClick:()=>ei(null),children:(0,Q.jsxs)($,{className:`w-3 h-3`,children:[(0,Q.jsx)(`path`,{d:`M18 6 6 18`}),(0,Q.jsx)(`path`,{d:`m6 6 12 12`})]})})]}):null,$r===`plan`?(0,Q.jsxs)(`span`,{className:`tw-composer-mode-chip is-plan${Zr===`approved`?` is-approved`:``}`,"data-hint":Zr===`approved`?`计划模式·已批准`:`计划模式·探查中`,children:[(0,Q.jsxs)($,{className:`w-3.5 h-3.5 shrink-0`,children:[(0,Q.jsx)(`path`,{d:`M8 6h13`}),(0,Q.jsx)(`path`,{d:`M8 12h13`}),(0,Q.jsx)(`path`,{d:`M8 18h13`}),(0,Q.jsx)(`path`,{d:`M3 6h.01`}),(0,Q.jsx)(`path`,{d:`M3 12h.01`}),(0,Q.jsx)(`path`,{d:`M3 18h.01`})]}),(0,Q.jsx)(`span`,{children:`计划`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`退出计划模式`,onClick:()=>pa(),children:(0,Q.jsxs)($,{className:`w-3 h-3`,children:[(0,Q.jsx)(`path`,{d:`M18 6 6 18`}),(0,Q.jsx)(`path`,{d:`m6 6 12 12`})]})})]}):null,$r===`pluginDev`?(0,Q.jsxs)(`span`,{className:`tw-composer-mode-chip is-plugin-dev`,children:[(0,Q.jsxs)($,{className:`w-3.5 h-3.5 shrink-0`,children:[(0,Q.jsx)(`path`,{d:`M9 7V3`}),(0,Q.jsx)(`path`,{d:`M15 7V3`}),(0,Q.jsx)(`path`,{d:`M6 7h12v4a6 6 0 0 1-12 0V7Z`}),(0,Q.jsx)(`path`,{d:`M12 17v4`})]}),(0,Q.jsx)(`span`,{children:`插件开发`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`退出插件开发`,onClick:()=>pa(),children:(0,Q.jsxs)($,{className:`w-3 h-3`,children:[(0,Q.jsx)(`path`,{d:`M18 6 6 18`}),(0,Q.jsx)(`path`,{d:`m6 6 12 12`})]})})]}):null,(0,Q.jsx)(`textarea`,{ref:xi,value:u,onChange:e=>d(e.target.value),onPaste:yo,onKeyDown:e=>{if(Ii&&Fi.length){if(e.key===`ArrowDown`){e.preventDefault(),me(e=>(e+1)%Fi.length);return}if(e.key===`ArrowUp`){e.preventDefault(),me(e=>(e-1+Fi.length)%Fi.length);return}if(e.key===`Escape`){e.preventDefault(),yr(!0),Pi&&d(u.slice(0,Pi.from));return}if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){e.preventDefault();let t=Fi[pe]??Fi[0];t&&ia(t.id);return}}if(Ni&&G.length){if(e.key===`ArrowDown`){e.preventDefault(),hr(e=>(e+1)%G.length);return}if(e.key===`ArrowUp`){e.preventDefault(),hr(e=>(e-1+G.length)%G.length);return}if(e.key===`Escape`){e.preventDefault(),_r(!0),Ai&&d(u.slice(0,Ai.from));return}if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){e.preventDefault();let t=G[mr]?.doc;t&&ta(t);return}}if(e.key===`Escape`&&br)e.preventDefault(),xr(!1);else if(e.key===`Escape`&&(Ai||Pi)){e.preventDefault(),_r(!0),yr(!0);let t=Ai?.from??Pi?.from;t!=null&&d(u.slice(0,t))}else if(e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing){e.preventDefault();let t=e.metaKey||e.ctrlKey;if(Vr.current){if(t){let e=u.trim();if(e||f.length>0||m.length>0||g.length>0){let t={id:`q_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`,content:e,files:[...f],refs:[...g],imgs:[...m]};fa(),Ta(t)}else _i.current.length&&Ta();return}ya(void 0,{forceBusy:xe().busySendBehavior??`queue`})}else ya()}},rows:1,placeholder:t?wr.length>0&&St?`Cmd/Ctrl+Enter 插话发送全部排队消息`:kr?`请输入内容,或用 @ 引用文档`:ki?`请输入内容,或用 @ 引用工作区文件`:`请输入内容(@ 引用文档需先启用「知识库检索」)`:`请先配置模型(左下角「设置」→ 模型)`,className:`tw-chat-input block min-w-0 flex-1 min-h-13 pl-0 pr-2 pt-1.5 pb-0.5 bg-transparent resize-none focus:outline-none placeholder:text-(--tw-label-tertiary)`})]})]}),(0,Q.jsxs)(`div`,{className:`tw-composer-bar flex items-center gap-1.5 px-3 pb-3 pt-3`,children:[(0,Q.jsx)(`button`,{type:`button`,"data-add-menu-btn":!0,"aria-label":Zr===`off`?`添加`:Zr===`planning`?`添加(计划模式·探查中)`:`添加(计划模式·已批准)`,onClick:()=>{xr(e=>!e),_r(!0),yr(!0)},className:`tw-icon-btn w-8 h-8 shrink-0 rounded-full flex items-center justify-center outline-none focus:outline-none focus-visible:outline-none transition-colors ${br?`bg-(--tw-session-hover-bg)`:``}`,children:(0,Q.jsxs)($,{className:`w-4 h-4`,children:[(0,Q.jsx)(`path`,{d:`M5 12h14`}),(0,Q.jsx)(`path`,{d:`M12 5v14`})]})}),U&&(0,Q.jsxs)(De,{children:[(0,Q.jsxs)(Oe,{title:Wo?`工作区:${Wo}`:`选择工作区`,"aria-label":Yo?`工作区:${Yo}`:`选择工作区`,disabled:Qn,className:`tw-composer-bar-ws group flex items-center gap-1 h-7 shrink-0 max-w-[min(40vw,11rem)] pl-1.5 pr-1 text-[13px] leading-5 font-medium text-stone-600 rounded-md outline-none focus:outline-none focus-visible:outline-none hover:bg-stone-100 data-[open]:bg-stone-100 transition-colors disabled:opacity-50`,children:[(0,Q.jsx)(pu,{className:`w-3.5 h-3.5 shrink-0 text-stone-500`}),(0,Q.jsx)(`span`,{className:`tw-composer-bar-label truncate`,children:Yo}),(0,Q.jsx)(iu,{className:`tw-composer-bar-chevron w-3.5 h-3.5 shrink-0 text-stone-400 transition-transform group-data-[open]:rotate-180`})]}),(0,Q.jsxs)(Te,{transition:!0,anchor:{to:`top start`,gap:8},className:`tw-select-menu tw-menu-anim z-50 w-[min(100vw-2rem,16rem)] rounded-xl border border-stone-200 py-1 shadow-xl focus:outline-none`,children:[(B?.items??[]).map(e=>{let t=e.path===Wo;return(0,Q.jsx)(Ee,{children:(0,Q.jsxs)(`button`,{type:`button`,disabled:Qn,onClick:()=>void Yi(e),className:`w-full flex items-center gap-2.5 px-3 py-2 text-left data-[focus]:bg-stone-100 disabled:opacity-50`,children:[(0,Q.jsx)(pu,{className:`w-4 h-4 shrink-0 text-stone-500`}),(0,Q.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-[13px] ${t?`text-stone-900 font-medium`:`text-stone-700`}`,"data-hint":e.path,children:Ft(e,Ro)}),t&&(0,Q.jsx)(ou,{className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`})]})},e.id)}),(B?.items?.length??0)>0&&(0,Q.jsx)(`div`,{className:`my-1 border-t border-stone-100`}),(0,Q.jsx)(Ee,{children:(0,Q.jsxs)(`button`,{type:`button`,disabled:Qn,onClick:()=>void Xi(),className:`w-full flex items-center gap-2.5 px-3 py-2 text-left text-[13px] text-stone-700 data-[focus]:bg-stone-100 disabled:opacity-50`,children:[(0,Q.jsx)(`span`,{className:`w-4 h-4 shrink-0 flex items-center justify-center text-stone-500 text-base leading-none`,children:`+`}),`添加工作区...`]})})]})]}),(0,Q.jsxs)(De,{children:[(0,Q.jsxs)(Oe,{title:`访问权限:${Do.label}`,"aria-label":`访问权限:${Do.label}`,className:`tw-composer-bar-access group flex items-center gap-1 h-7 shrink-0 max-w-55 pl-2 pr-1 text-[13px] leading-5 font-medium text-stone-600 rounded-md outline-none focus:outline-none focus-visible:outline-none hover:bg-stone-100 data-[open]:bg-stone-100 transition-colors`,children:[(0,Q.jsx)(Du,{level:cn,className:`w-3.5 h-3.5 shrink-0 text-stone-500`}),(0,Q.jsx)(`span`,{className:`tw-composer-bar-label truncate`,children:Do.label}),(0,Q.jsx)(`span`,{className:`ml-0.5 w-1.5 h-1.5 rounded-full shrink-0 ${U?`bg-emerald-500`:`bg-stone-300`}`,"data-hint":U?`Runner 在线`:`Runner 离线`}),(0,Q.jsx)(iu,{className:`tw-composer-bar-chevron w-3.5 h-3.5 shrink-0 text-stone-400 transition-transform group-data-[open]:rotate-180`})]}),(0,Q.jsxs)(Te,{transition:!0,anchor:{to:`top start`,gap:8},className:`tw-select-menu tw-menu-anim z-50 w-56 rounded-xl border border-stone-200 p-1 shadow-xl focus:outline-none`,children:[(0,Q.jsx)(`div`,{className:`px-3 py-1.5 text-[11px] text-stone-400`,children:U?`本地文件服务已连接`:`本地文件服务未就绪`}),Xl.map(e=>{let t=Oo&&e.value===`readonly`;return(0,Q.jsx)(Ee,{disabled:t,children:(0,Q.jsxs)(`button`,{type:`button`,disabled:t,onClick:()=>{ln(e.value),K.current&&q(L(K.current,{access:e.value}))},className:`w-full flex items-center gap-2 px-3 py-2 rounded-lg text-left text-[13px] data-[focus]:bg-stone-100 disabled:cursor-not-allowed`,children:[(0,Q.jsx)(Du,{level:e.value,className:`w-4 h-4 shrink-0 ${t?`text-stone-300`:`text-stone-500`}`}),(0,Q.jsx)(`span`,{className:`flex-1 ${t?`text-stone-400`:cn===e.value?`text-stone-900 font-medium`:`text-stone-700`}`,children:e.label}),t?(0,Q.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`插件开发需要写入`}):cn===e.value?(0,Q.jsx)(ou,{className:`w-3.5 h-3.5 text-[#4176e6]`}):null]})},e.value)})]})]}),(0,Q.jsx)(`span`,{className:`flex-1`}),(0,Q.jsx)(Ju,{settings:t}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{Vr.current?xa():ya()},disabled:!St&&!So,"aria-label":St?`停止生成`:`发送`,className:`w-8 h-8 shrink-0 rounded-full flex items-center justify-center outline-none focus:outline-none focus-visible:outline-none transition-colors ${St?`bg-stone-200 text-stone-700 hover:bg-stone-300`:`bg-[#4176e6] text-white hover:bg-[#3565c7] disabled:bg-[#a9c3ef] disabled:cursor-not-allowed`}`,children:St?(0,Q.jsx)(`span`,{className:`w-2.5 h-2.5 bg-current rounded-xs`}):(0,Q.jsx)(fu,{className:`w-4 h-4`})})]})]}),(0,Q.jsx)(Ku,{messages:s,model:t?.model,systemPromptTokens:Mu(ee)})]}),(0,Q.jsx)(`input`,{ref:Si,type:`file`,multiple:!0,hidden:!0,accept:[...ol.map(e=>`.${e}`),`image/*`,`text/*`,`application/json`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.ms-excel`,`application/msword`].join(`,`),onChange:e=>void fo(e)})]})]})]}),I?(0,Q.jsx)(`div`,{className:`tw-plugins-rail flex-1 min-w-0 min-h-0 self-stretch h-full overflow-hidden flex flex-col`,children:(0,Q.jsx)(rn,{embedded:!0})}):null,(0,Q.jsx)(kl,{open:y,initial:x,onClose:()=>b(!1),onConfirm:e=>Ma(e)}),(0,Q.jsx)(Al,{open:w,initial:E,onClose:()=>T(!1),onConfirm:e=>Na(e)}),(0,Q.jsx)(jl,{open:ne,initial:k,onClose:()=>O(!1),onConfirm:e=>Pa(e)}),(0,Q.jsx)(dn,{open:!!Ce,title:`重命名会话`,label:`会话名称`,placeholder:`请输入会话名称`,initialValue:Ce?a?.sessions.find(e=>e.id===Ce)?.title??``:``,confirmLabel:`保存`,cancelLabel:`取消`,onClose:()=>Me(null),onConfirm:lo}),(0,Q.jsx)(dn,{open:!!pt,title:`重命名工作区`,label:`显示名称`,placeholder:`请输入工作区名称`,initialValue:pt?B?.items.find(e=>e.id===pt)?.name??``:``,confirmLabel:`保存`,cancelLabel:`取消`,onClose:()=>bt(null),onConfirm:e=>void $i(e)}),(0,Q.jsx)(we,{open:!!Pe,title:`删除会话`,message:Pe?`确定永久删除「${a?.sessions.find(e=>e.id===Pe)?.title??`该会话`}」?此操作不可恢复。`:``,confirmLabel:`删除`,cancelLabel:`取消`,danger:`outline`,onClose:()=>Qe(null),onConfirm:()=>{if(!Pe)return;let e=Pe;Qe(null),ro(e)}}),(0,Q.jsx)(we,{open:!!dt,title:`删除工作区`,message:dt?`将把「${dt.name}」从工作区列表中移除。文件夹与会话记录会保留,其会话将归入项目根工作区。`:``,confirmLabel:`删除工作区`,cancelLabel:`取消`,danger:`outline`,onClose:()=>ft(null),onConfirm:()=>void Zi()})]})}export{Zu as default};
|