@aalis/plugin-webui-client 0.12.2 → 0.12.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.
Files changed (65) hide show
  1. package/dist/assets/{AuthorityPage-moleXD4t.js → AuthorityPage-BqbTbZGl.js} +1 -1
  2. package/dist/assets/{DynamicPage-Dmz4Tfnd.js → DynamicPage-BLL0Jjj-.js} +6 -6
  3. package/dist/assets/FilesPage-CPzzHEJs.js +16 -0
  4. package/dist/assets/MarketplacePage-BnFRPE6h.js +6 -0
  5. package/dist/assets/{PlatformPage-Cl_2WBBf.js → PlatformPage-DfR5EkvP.js} +1 -1
  6. package/dist/assets/PluginConfigPage-BgARQZaR.js +23 -0
  7. package/dist/assets/SessionsPage-B2xpCNug.js +1 -0
  8. package/dist/assets/{arc-CvZyeOr3.js → arc-CQe2nGSx.js} +1 -1
  9. package/dist/assets/{architectureDiagram-3BPJPVTR-BM0rAG6h.js → architectureDiagram-3BPJPVTR-Cvkrufdn.js} +1 -1
  10. package/dist/assets/{blockDiagram-GPEHLZMM-C1sdysUR.js → blockDiagram-GPEHLZMM-BzO74F_v.js} +1 -1
  11. package/dist/assets/{c4Diagram-AAUBKEIU-CYJ-GB21.js → c4Diagram-AAUBKEIU-BlOYmvpJ.js} +1 -1
  12. package/dist/assets/channel-DxFgDxL2.js +1 -0
  13. package/dist/assets/{chunk-2J33WTMH-BkC9TJZK.js → chunk-2J33WTMH-DFwRx-nE.js} +1 -1
  14. package/dist/assets/{chunk-4BX2VUAB-C1A8aFsP.js → chunk-4BX2VUAB-CduB1PNc.js} +1 -1
  15. package/dist/assets/{chunk-55IACEB6-eTVfuioZ.js → chunk-55IACEB6-21xZxRLc.js} +1 -1
  16. package/dist/assets/{chunk-727SXJPM-xrA_1fYt.js → chunk-727SXJPM-BzmUekfP.js} +1 -1
  17. package/dist/assets/{chunk-AQP2D5EJ-BcR6_Tcf.js → chunk-AQP2D5EJ-CdlRaCrQ.js} +1 -1
  18. package/dist/assets/{chunk-FMBD7UC4-DpTtNcWD.js → chunk-FMBD7UC4-CJRlGDhE.js} +1 -1
  19. package/dist/assets/{chunk-ND2GUHAM-DmI-7NxM.js → chunk-ND2GUHAM-DnSWO3aS.js} +1 -1
  20. package/dist/assets/{chunk-QZHKN3VN-D1fOOvmu.js → chunk-QZHKN3VN-Dj5n19FW.js} +1 -1
  21. package/dist/assets/classDiagram-4FO5ZUOK-bnDp8shu.js +1 -0
  22. package/dist/assets/classDiagram-v2-Q7XG4LA2-bnDp8shu.js +1 -0
  23. package/dist/assets/{clock-AfKIpZ6h.js → clock-W2ha6TRb.js} +1 -1
  24. package/dist/assets/{cose-bilkent-S5V4N54A-0Zvy1yik.js → cose-bilkent-S5V4N54A-ClfKZKqe.js} +1 -1
  25. package/dist/assets/{dagre-BM42HDAG-CbDOMSTD.js → dagre-BM42HDAG-jazTBzPR.js} +1 -1
  26. package/dist/assets/{diagram-2AECGRRQ-B6c-LIf_.js → diagram-2AECGRRQ-DyxWZPwj.js} +1 -1
  27. package/dist/assets/{diagram-5GNKFQAL-DPmLgFlo.js → diagram-5GNKFQAL-DqCbPzXj.js} +1 -1
  28. package/dist/assets/{diagram-KO2AKTUF-smABeten.js → diagram-KO2AKTUF-CmZvNtBG.js} +1 -1
  29. package/dist/assets/{diagram-LMA3HP47-DAnV-Eg9.js → diagram-LMA3HP47-6T2L5BXp.js} +1 -1
  30. package/dist/assets/{diagram-OG6HWLK6-Cfojf2jW.js → diagram-OG6HWLK6-4sYw9ZQs.js} +1 -1
  31. package/dist/assets/{erDiagram-TEJ5UH35-DzDyUJju.js → erDiagram-TEJ5UH35-D0ob0KXX.js} +1 -1
  32. package/dist/assets/{flowDiagram-I6XJVG4X-BAgnVKAG.js → flowDiagram-I6XJVG4X--eCEup-R.js} +1 -1
  33. package/dist/assets/{ganttDiagram-6RSMTGT7-BU0cDMt_.js → ganttDiagram-6RSMTGT7-m3TQjkjn.js} +1 -1
  34. package/dist/assets/{gitGraphDiagram-PVQCEYII-Bt_u2cFR.js → gitGraphDiagram-PVQCEYII-CPGaB1tr.js} +1 -1
  35. package/dist/assets/{globe-BKJqBqHF.js → globe-DBjh8D_x.js} +1 -1
  36. package/dist/assets/index-CP1eHYpM.js +212 -0
  37. package/dist/assets/{infoDiagram-5YYISTIA-D8phaHgc.js → infoDiagram-5YYISTIA-BVnSCwcT.js} +1 -1
  38. package/dist/assets/{ishikawaDiagram-YF4QCWOH-CSaAlITY.js → ishikawaDiagram-YF4QCWOH-85DqNeCY.js} +1 -1
  39. package/dist/assets/{journeyDiagram-JHISSGLW-Bhyae5kY.js → journeyDiagram-JHISSGLW-Cky18vs0.js} +1 -1
  40. package/dist/assets/{kanban-definition-UN3LZRKU-ClO_qokD.js → kanban-definition-UN3LZRKU-D84piZkn.js} +1 -1
  41. package/dist/assets/{linear-D7VBgJ46.js → linear-TNUZDVve.js} +1 -1
  42. package/dist/assets/{mermaid.core-_uubCxEH.js → mermaid.core-CiVUCO-O.js} +4 -4
  43. package/dist/assets/{mindmap-definition-RKZ34NQL-BOojGeyt.js → mindmap-definition-RKZ34NQL-BFFaTXUp.js} +1 -1
  44. package/dist/assets/{pieDiagram-4H26LBE5-D3W4xNDm.js → pieDiagram-4H26LBE5-BPNYmIiO.js} +1 -1
  45. package/dist/assets/{quadrantDiagram-W4KKPZXB-DmE0WMKQ.js → quadrantDiagram-W4KKPZXB-OVTXENUG.js} +1 -1
  46. package/dist/assets/{requirementDiagram-4Y6WPE33-Ci15zBQo.js → requirementDiagram-4Y6WPE33-CGWBxus5.js} +1 -1
  47. package/dist/assets/{sankeyDiagram-5OEKKPKP-CZvJCqzF.js → sankeyDiagram-5OEKKPKP-C0MTZuTr.js} +1 -1
  48. package/dist/assets/{sequenceDiagram-3UESZ5HK-DImxZlZU.js → sequenceDiagram-3UESZ5HK-DT4KwDYb.js} +1 -1
  49. package/dist/assets/{stateDiagram-AJRCARHV-upGvcZz4.js → stateDiagram-AJRCARHV-BBNJwMVt.js} +1 -1
  50. package/dist/assets/{stateDiagram-v2-BHNVJYJU-CiXgli4u.js → stateDiagram-v2-BHNVJYJU-B4Inm8LB.js} +1 -1
  51. package/dist/assets/{timeline-definition-PNZ67QCA-DtnFAsZJ.js → timeline-definition-PNZ67QCA-DuhrqPcq.js} +1 -1
  52. package/dist/assets/{vennDiagram-CIIHVFJN-5XoGoPhA.js → vennDiagram-CIIHVFJN-DrwNTuSP.js} +1 -1
  53. package/dist/assets/{wardley-L42UT6IY-D2ahyUpa.js → wardley-L42UT6IY-CYF_y2Eu.js} +1 -1
  54. package/dist/assets/{wardleyDiagram-YWT4CUSO-DVuBRlrH.js → wardleyDiagram-YWT4CUSO-I6e0MQ-e.js} +1 -1
  55. package/dist/assets/{xychartDiagram-2RQKCTM6-CcTPMI_A.js → xychartDiagram-2RQKCTM6-Df7YUsb2.js} +1 -1
  56. package/dist/index.html +1 -1
  57. package/package.json +1 -1
  58. package/dist/assets/FilesPage-DUh-AYCa.js +0 -16
  59. package/dist/assets/MarketplacePage-DzmqvEhm.js +0 -6
  60. package/dist/assets/PluginConfigPage-Bda8iLH6.js +0 -23
  61. package/dist/assets/SessionsPage-Dmw9u5-k.js +0 -1
  62. package/dist/assets/channel-DwGWzMQA.js +0 -1
  63. package/dist/assets/classDiagram-4FO5ZUOK-mGzw7eqs.js +0 -1
  64. package/dist/assets/classDiagram-v2-Q7XG4LA2-mGzw7eqs.js +0 -1
  65. package/dist/assets/index-8Eh5USJy.js +0 -212
@@ -1 +0,0 @@
1
- import{r as x,j as e}from"./react-vendor-BPQixOLZ.js";import{p as S,b as xe,B as V,M as _,R,d as z,e as B,W as ge}from"./index-8Eh5USJy.js";import{M as F}from"./markdown-B2G8c9k5.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";function pe(s,h){const[j,n]=x.useState({segments:[],isStreaming:!1,done:!1}),o=x.useRef(null),d=!!(s&&(h==="active"||h==="waiting"));x.useEffect(()=>{if(!d||!s){n({segments:[],isStreaming:!1,done:!1});return}const b=location.protocol==="https:"?"wss:":"ws:",c=new WebSocket(`${b}//${location.host}/ws`);return o.current=c,c.onopen=()=>{c.send(JSON.stringify({type:"subscribe_session",sessionId:s}))},c.onmessage=u=>{try{const l=JSON.parse(u.data);if(l.type==="stream_resume"){let f=[];if(Array.isArray(l.segments)&&l.segments.length>0)f=l.segments;else{const g=l.reasoningContent??"",y=l.content??"";g&&f.push({type:"reasoning_text",content:g}),y&&f.push({type:"text",content:y})}n({segments:f,isStreaming:!l.done,done:!!l.done})}else l.type==="stream"?l.done?n(f=>({...f,isStreaming:!1,done:!0})):n(f=>{const g=[...f.segments],y=(C,E)=>{const T=g[g.length-1];T&&T.type===C?g[g.length-1]={type:C,content:T.content+E}:g.push({type:C,content:E})};return l.reasoningDelta&&y("reasoning_text",l.reasoningDelta),l.contentDelta&&y("text",l.contentDelta),{...f,segments:g,isStreaming:!0}}):l.type==="tool_call"?n(f=>{const g=[...f.segments];if(l.toolPhase==="start")g.push({type:"tool_call",name:l.toolName,args:l.toolArgs??{},startTime:Date.now()});else if(l.toolPhase==="end"&&l.toolResult!==void 0){const y=g.findLastIndex(C=>C.type==="tool_call"&&C.name===l.toolName&&C.result==null);if(y>=0){const C=g[y];g[y]={...C,result:l.toolResult,endTime:Date.now()}}}return{...f,segments:g,isStreaming:!0}}):l.type==="message"&&n(f=>({...f,done:!0,isStreaming:!1}))}catch{}},c.onclose=()=>{o.current=null},()=>{c.close(),o.current=null}},[s,d]);const a=x.useCallback(()=>{n({segments:[],isStreaming:!1,done:!1})},[]);return[j,a]}const Y={active:"进行中",waiting:"等待中",completed:"已完成",error:"错误",archived:"已归档"},q={active:"#4caf50",waiting:"#ff9800",completed:"#2196f3",error:"#f44336",archived:"#888"};function X(s,h){return s?s.length>h?s.slice(0,h)+"…":s:""}function M(s){return new Date(s).toLocaleString("zh-CN",{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Q(s){const h=[];for(const j of s)h.push(j.session.id),h.push(...Q(j.children));return h}function je(s,h){const j={...s};for(const n of Object.keys(h))j[n]===void 0&&(j[n]=null);return j}function fe({config:s,resolvedConfig:h,inheritedConfig:j,options:n,onSave:o,onCancel:d}){var I,A;const[a,b]=x.useState({...s}),c=h||{},u=j||{},l=(t,p)=>{b(v=>({...v,[t]:p}))},f=(t,p)=>!!t&&(t.includes("*")||t.includes(p)),g=t=>t.includes("*")?((n==null?void 0:n.toolGroups)??[]).map(p=>p.name):t,y=t=>f(a.enabledToolGroups,t)?"explicit":f(u.enabledToolGroups,t)&&!a.enabledToolGroups?"inherited":"off",C=t=>{if(y(t)==="inherited"){const v=g(u.enabledToolGroups||[]);l("enabledToolGroups",v.filter($=>$!==t))}else{const v=g(a.enabledToolGroups||u.enabledToolGroups||[]),$=v.includes(t)?v.filter(r=>r!==t):[...v,t];l("enabledToolGroups",$)}},E=()=>{b(t=>{const{enabledToolGroups:p,...v}=t;return v})};if(!n)return e.jsx("div",{className:"session-config-editor",children:e.jsx("span",{className:"session-config-loading",children:"加载配置选项…"})});const T=(t,p)=>!a[t]&&p?` (继承: ${p})`:"",N=(I=a.llm)!=null&&I.provider&&((A=a.llm)!=null&&A.model)?`${a.llm.provider}/${a.llm.model}`:"",w=n.models.filter(t=>!!t.provider).map(t=>({key:`${t.provider}/${t.id}`,provider:t.provider,model:t.id,label:`${t.provider} / ${t.id}${t.capabilities.length>0?` [${t.capabilities.join(",")}]`:""}`}));N&&!w.some(t=>t.key===N)&&w.unshift({key:N,provider:a.llm.provider,model:a.llm.model,label:`${a.llm.provider} / ${a.llm.model} (已离线)`});const G=u.llm?`${u.llm.provider} / ${u.llm.model}`:void 0;return e.jsxs("div",{className:"session-config-editor",onClick:t=>t.stopPropagation(),children:[e.jsxs("label",{className:"session-config-field",children:[e.jsxs("span",{children:["模型",!a.llm&&G?` (继承: ${G})`:""]}),e.jsxs("select",{value:N,onChange:t=>{const p=t.target.value;if(!p){l("llm",void 0);return}const v=w.find($=>$.key===p);v&&l("llm",{provider:v.provider,model:v.model})},children:[e.jsx("option",{value:"",children:G?`继承 (${G})`:"继承默认"}),w.map(t=>e.jsx("option",{value:t.key,children:t.label},t.key))]})]}),e.jsxs("label",{className:"session-config-field",children:[e.jsxs("span",{children:["人设",T("persona",u.persona)]}),e.jsxs("select",{value:a.persona||"",onChange:t=>l("persona",t.target.value||void 0),children:[e.jsx("option",{value:"",children:u.persona?`继承 (${u.persona})`:"继承默认"}),n.personas.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),n.toolGroups.length>0&&e.jsxs("div",{className:"session-config-field",children:[e.jsxs("span",{children:["工具分组",a.enabledToolGroups?"":" (继承)"]}),e.jsxs("div",{className:"session-config-chips",children:[n.toolGroups.map(t=>{const p=y(t.name);return e.jsx("button",{className:`session-config-chip ${p==="explicit"?"active":p==="inherited"?"active inherited":""}`,onClick:()=>C(t.name),title:`${t.name}${p==="inherited"?" (继承)":p==="explicit"?" (已覆盖)":""}`,children:t.label||t.name},t.name)}),a.enabledToolGroups&&e.jsx("button",{className:"session-config-chip reset",onClick:E,title:"恢复为继承",children:"↺ 重置"})]})]}),e.jsxs("label",{className:"session-config-field",children:[e.jsx("span",{children:"额外提示"}),e.jsx("textarea",{rows:2,value:a.systemPromptExtra||"",onChange:t=>l("systemPromptExtra",t.target.value||void 0),placeholder:"追加到系统提示之后…"})]}),e.jsxs("label",{className:"session-config-field",children:[e.jsx("span",{children:"工具迭代上限"}),e.jsx("input",{type:"number",min:0,max:50,value:a.maxToolIterations??"",onChange:t=>l("maxToolIterations",t.target.value?Number(t.target.value):void 0),placeholder:u.maxToolIterations?`继承 (${u.maxToolIterations})`:"默认"})]}),e.jsxs("div",{className:"session-config-toggles",children:[e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:a.disableOutputFormat??c.disableOutputFormat??!1,onChange:t=>l("disableOutputFormat",t.target.checked||void 0)}),e.jsxs("span",{children:["禁用结构化输出",a.disableOutputFormat===void 0&&u.disableOutputFormat?" (继承)":""]})]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:a.clientSideJsonRendering??c.clientSideJsonRendering??!1,onChange:t=>l("clientSideJsonRendering",t.target.checked||void 0)}),e.jsxs("span",{children:["客户端 JSON 渲染",a.clientSideJsonRendering===void 0&&u.clientSideJsonRendering?" (继承)":""]})]})]}),e.jsxs("div",{className:"session-config-actions",children:[e.jsx("button",{className:"session-config-btn save",onClick:()=>o(je(a,s)),children:"保存"}),e.jsx("button",{className:"session-config-btn cancel",onClick:d,children:"取消"})]})]})}function we({pluginName:s,activeSessionId:h,onSwitchSession:j,onStartNewChat:n,refreshSignal:o}){const[d,a]=x.useState([]),[b,c]=x.useState(null),[u,l]=x.useState(null),[f,g]=x.useState(!1),[y,C]=x.useState(null),[E,T]=x.useState(!1),[N,w]=x.useState(new Set),[G,I]=x.useState(null),[A,t]=x.useState(""),[p,v]=x.useState(null),[$,r]=x.useState(null),[L,K]=x.useState(null),[W,O]=x.useState(null),[U,m]=x.useState(null),P=x.useCallback(()=>{S(s,"getSessionTree").then(i=>{Array.isArray(i)&&a(i)}).catch(()=>C("无法加载会话树"))},[s]);x.useEffect(()=>{P();const i=setInterval(P,3e4);return()=>clearInterval(i)},[P]),x.useEffect(()=>{o&&(P(),$&&Promise.all([S(s,"getResolvedConfig",{sessionId:$,platform:"webui"}),S(s,"getInheritedDefaults",{sessionId:$,platform:"webui"})]).then(([i,k])=>{i&&O(i),k&&m(k)}).catch(()=>{}))},[o]);const H=x.useCallback(i=>{c(i),g(!0),S(s,"getSessionDetail",{id:i}).then(k=>l(k)).catch(()=>l(null)).finally(()=>g(!1))},[s]),se=async()=>{try{await S(s,"createSession",{}),P()}catch{}},te=async i=>{try{await S(s,"createSession",{parentId:i}),P()}catch{}},ne=async i=>{if(!A.trim()){I(null);return}try{await S(s,"renameSession",{id:i,title:A.trim()}),P()}catch{}I(null)},le=async i=>{try{await S(s,"archiveSession",{id:i}),P()}catch{}},ie=async i=>{try{const k=i===h;await S(s,"deleteSession",{id:i}),P(),b===i&&(c(null),l(null)),k&&n&&n()}catch{}v(null)},ae=async i=>{if($===i){r(null),O(null),m(null);return}r(i),O(null),m(null);try{const[k,D,J]=await Promise.all([L?Promise.resolve(L):S(s,"getConfigOptions"),S(s,"getResolvedConfig",{sessionId:i,platform:"webui"}),S(s,"getInheritedDefaults",{sessionId:i,platform:"webui"})]);k&&!L&&K(k),D&&O(D),J&&m(J)}catch{}},re=async(i,k)=>{try{await S(s,"updateSessionConfig",{id:i,config:k}),P(),r(null)}catch(D){const J=D instanceof Error?D.message:String(D);alert(`保存会话配置失败:${J}`)}},ce=i=>{w(k=>{const D=new Set(k);return D.has(i)?D.delete(i):D.add(i),D})},oe=()=>{const i=Q(d);w(new Set(i))},de=()=>w(new Set),he=async()=>{if(N.size!==0)try{await S(s,"batchArchive",{ids:[...N]}),w(new Set),P()}catch{}},me=async()=>{if(N.size!==0&&confirm(`确认删除选中的 ${N.size} 个会话?此操作不可恢复。`))try{await S(s,"batchDelete",{ids:[...N]}),w(new Set),b&&N.has(b)&&(c(null),l(null)),P()}catch{}},ue=()=>{T(!1),w(new Set)};return y?e.jsx("div",{className:"tree-page-error",children:y}):e.jsxs("div",{className:"session-tree-page",children:[e.jsxs("div",{className:"tree-visual-panel",children:[e.jsxs("div",{className:"tree-visual-header",children:[e.jsx("h3",{children:"会话"}),e.jsx("div",{className:"tree-header-actions",children:E?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"tree-batch-btn",onClick:oe,title:"全选",children:"全选"}),e.jsx("button",{className:"tree-batch-btn",onClick:de,title:"取消全选",children:"取消"}),e.jsxs("button",{className:"tree-batch-btn archive",onClick:he,disabled:N.size===0,children:["归档 (",N.size,")"]}),e.jsxs("button",{className:"tree-batch-btn danger",onClick:me,disabled:N.size===0,children:["删除 (",N.size,")"]}),e.jsx("button",{className:"tree-batch-btn",onClick:ue,children:"退出批量"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"tree-action-btn",onClick:se,title:"新建会话",children:"+"}),e.jsx("button",{className:"tree-action-btn",onClick:()=>T(!0),title:"批量管理",children:"☐"}),e.jsx("button",{className:"tree-refresh-btn",onClick:P,children:"⟳"})]})})]}),e.jsx("div",{className:"tree-visual-body",children:d.length===0?e.jsx("div",{className:"tree-empty",children:"暂无会话"}):d.map(i=>e.jsx(Z,{node:i,selectedId:b,activeSessionId:h,onSelect:H,depth:0,batchMode:E,selected:N,onToggleSelect:ce,onCreateChild:te,onRename:(k,D)=>{I(k),t(D)},onArchive:le,onDelete:k=>v(k),onOpenConfig:ae,editingId:G,editTitle:A,onEditTitleChange:t,onCommitRename:ne,onCancelEdit:()=>I(null),configEditingId:$,configOptions:L,resolvedConfig:W,inheritedConfig:U,onSaveConfig:re,onCancelConfig:()=>r(null)},i.session.id))})]}),e.jsx("div",{className:"tree-detail-panel",children:b?f?e.jsx("div",{className:"tree-detail-placeholder",children:"加载中…"}):u?e.jsx(ve,{detail:u,onSwitchSession:j,onRefresh:()=>H(u.session.id)}):e.jsx("div",{className:"tree-detail-placeholder",children:"无法加载会话信息"}):e.jsx("div",{className:"tree-detail-placeholder tree-detail-placeholder-idle",children:"点击会话节点查看详情"})}),p&&e.jsx("div",{className:"delete-confirm-overlay",onClick:()=>v(null),children:e.jsxs("div",{className:"delete-confirm-dialog",onClick:i=>i.stopPropagation(),children:[e.jsx("p",{children:"确定要删除此会话吗?子会话也会被一并删除,此操作无法撤销。"}),e.jsxs("div",{className:"delete-confirm-actions",children:[e.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>ie(p),children:"删除"}),e.jsx("button",{className:"btn btn-sm",onClick:()=>v(null),children:"取消"})]})]})})]})}function Z({node:s,selectedId:h,activeSessionId:j,onSelect:n,depth:o,batchMode:d,selected:a,onToggleSelect:b,onCreateChild:c,onRename:u,onArchive:l,onDelete:f,onOpenConfig:g,editingId:y,editTitle:C,onEditTitleChange:E,onCommitRename:T,onCancelEdit:N,configEditingId:w,configOptions:G,resolvedConfig:I,inheritedConfig:A,onSaveConfig:t,onCancelConfig:p}){const[v,$]=x.useState(!0),r=s.session,L=s.children.length>0,K=r.id===h,W=r.id===j,O=y===r.id,U=a.has(r.id);return e.jsxs("div",{className:"tree-node-group",children:[e.jsxs("div",{className:`tree-node ${K?"selected":""} ${W?"active-chat":""} status-${r.status}`,style:{marginLeft:o*24},onClick:()=>d?b(r.id):n(r.id),children:[d&&e.jsx("input",{type:"checkbox",className:"tree-node-checkbox",checked:U,onChange:()=>b(r.id),onClick:m=>m.stopPropagation()}),e.jsx("button",{className:"tree-node-toggle",onClick:m=>{m.stopPropagation(),$(!v)},style:{visibility:L?"visible":"hidden"},children:v?"▾":"▸"}),e.jsx("span",{className:"tree-node-status",style:{background:q[r.status]||"#888"}}),e.jsx("div",{className:"tree-node-info",children:O?e.jsx("input",{className:"tree-node-rename-input",value:C,onChange:m=>E(m.target.value),onBlur:()=>T(r.id),onKeyDown:m=>{m.key==="Enter"&&T(r.id),m.key==="Escape"&&N()},onClick:m=>m.stopPropagation(),autoFocus:!0}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tree-node-title",children:r.title||r.name}),e.jsxs("span",{className:"tree-node-meta",children:[Y[r.status]||r.status,r.createdBy&&r.createdBy!=="user"&&` · ${r.createdBy}`,` · ${M(r.createdAt)}`]})]})}),L&&e.jsx("span",{className:"tree-node-badge",children:s.children.length}),!d&&e.jsxs("div",{className:"tree-node-actions",onClick:m=>m.stopPropagation(),children:[e.jsx("button",{className:"tree-node-action-btn",title:"新建子会话",onClick:()=>c(r.id),children:"➕"}),e.jsx("button",{className:"tree-node-action-btn",title:"配置",onClick:()=>g(r.id),children:"⚙"}),e.jsx("button",{className:"tree-node-action-btn",title:"重命名",onClick:()=>u(r.id,r.title||r.name),children:"✎"}),r.status==="active"&&e.jsx("button",{className:"tree-node-action-btn",title:"归档",onClick:()=>l(r.id),children:"▪"}),e.jsx("button",{className:"tree-node-action-btn danger",title:"删除",onClick:()=>f(r.id),children:"✕"})]})]}),w===r.id&&e.jsx("div",{style:{marginLeft:o*24+24},children:e.jsx(fe,{config:r.config||{},resolvedConfig:I,inheritedConfig:A,options:G,onSave:m=>t(r.id,m),onCancel:p})}),L&&v&&e.jsx("div",{className:"tree-node-children",children:s.children.map(m=>e.jsxs("div",{className:"tree-child-wrapper",children:[m.session.inputContext&&e.jsxs("div",{className:"tree-flow-label",style:{marginLeft:(o+1)*24},children:[e.jsx("span",{className:"tree-flow-arrow",children:"↓"}),e.jsx("span",{className:"tree-flow-text",children:X(m.session.inputContext,80)})]}),e.jsx(Z,{node:m,selectedId:h,activeSessionId:j,onSelect:n,depth:o+1,batchMode:d,selected:a,onToggleSelect:b,onCreateChild:c,onRename:u,onArchive:l,onDelete:f,onOpenConfig:g,editingId:y,editTitle:C,onEditTitleChange:E,onCommitRename:T,onCancelEdit:N,configEditingId:w,configOptions:G,resolvedConfig:I,inheritedConfig:A,onSaveConfig:t,onCancelConfig:p}),m.session.result&&e.jsxs("div",{className:"tree-flow-label result",style:{marginLeft:(o+1)*24},children:[e.jsx("span",{className:"tree-flow-arrow",children:"↑"}),e.jsx("span",{className:"tree-flow-text",children:X(m.session.result,80)})]})]},m.session.id))})]})}function ve({detail:s,onSwitchSession:h,onRefresh:j}){const n=s.session,o=xe(s.messages),[d,a]=pe(n.id,n.status);return x.useEffect(()=>{d.done&&(a(),j==null||j())},[d.done,a,j]),e.jsxs("div",{className:"session-detail",children:[e.jsxs("div",{className:"session-detail-header",children:[e.jsx("h3",{children:n.title||n.name}),e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[h&&e.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>h(n.id),children:"进入对话"}),e.jsx("span",{className:"session-detail-status",style:{color:q[n.status]},children:Y[n.status]})]})]}),e.jsxs("div",{className:"session-detail-meta",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"ID:"})," ",n.id]}),e.jsxs("div",{children:[e.jsx("strong",{children:"创建时间:"})," ",new Date(n.createdAt).toLocaleString("zh-CN")]}),n.parentId&&e.jsxs("div",{children:[e.jsx("strong",{children:"父会话:"})," ",n.parentId]}),n.createdBy&&e.jsxs("div",{children:[e.jsx("strong",{children:"创建者:"})," ",n.createdBy]}),n.children.length>0&&e.jsxs("div",{children:[e.jsx("strong",{children:"子会话数:"})," ",n.children.length]})]}),n.inputContext&&e.jsxs("div",{className:"session-detail-context",children:[e.jsx("div",{className:"context-label",children:"来自父会话的指令"}),e.jsx("div",{className:"context-content",children:n.inputContext})]}),n.result&&e.jsxs("div",{className:"session-detail-result",children:[e.jsx("div",{className:"context-label",children:"给父会话的结果"}),e.jsx("div",{className:"context-content",children:n.result})]}),e.jsxs("div",{className:"session-detail-messages",children:[e.jsxs("h4",{children:["消息记录 (",s.messages.length,")"]}),o.length===0&&!d.isStreaming?e.jsx("div",{className:"no-messages",children:"暂无消息记录"}):e.jsxs("div",{className:"message-list",children:[o.map((b,c)=>e.jsx(be,{msg:b},c)),d.isStreaming&&d.segments.length>0&&e.jsxs("div",{className:"detail-message assistant streaming",children:[e.jsxs("div",{className:"detail-msg-role",children:["助手 ",e.jsx("span",{className:"streaming-indicator",children:"●"})]}),e.jsx("div",{className:"detail-msg-content detail-msg-md",children:(()=>{const b=[];let c=0;for(;c<d.segments.length;){const u=d.segments[c];if(u.type==="reasoning_text"){let l="";for(;c<d.segments.length&&d.segments[c].type==="reasoning_text";)l+=d.segments[c].content,c++;l&&b.push(e.jsxs("details",{className:"thinking-block",open:!0,children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(V,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(F,{remarkPlugins:z,rehypePlugins:R,components:_,children:B(l)})})]},`r-${c}`));continue}b.push(e.jsx(ee,{seg:u},c)),c++}return b})()})]})]})]})]})}function ee({seg:s}){return s.type==="text"||s.type==="reasoning_text"?s.content?e.jsx("div",{className:"detail-text-segment",children:e.jsx(F,{remarkPlugins:z,rehypePlugins:R,components:_,children:B(s.content)})}):null:e.jsxs("details",{className:"tool-call-block",children:[e.jsxs("summary",{className:"tool-call-summary",children:[e.jsx(ge,{size:14})," ",s.name,s.result==null?" …":""]}),e.jsxs("div",{className:"tool-call-content",children:[e.jsxs("div",{className:"tool-call-args",children:[e.jsx("strong",{children:"参数"}),e.jsx("pre",{children:JSON.stringify(s.args,null,2)})]}),s.result!=null&&e.jsxs("div",{className:"tool-call-result",children:[e.jsx("strong",{children:"结果"}),e.jsx("pre",{children:s.result})]})]})]})}function be({msg:s}){const h=s.role==="user"?"用户":"助手";if(s.role==="user")return e.jsxs("div",{className:`detail-message ${s.role}`,children:[e.jsx("div",{className:"detail-msg-role",children:h}),e.jsx("div",{className:"detail-msg-content",children:s.content}),s.timestamp>0&&e.jsx("div",{className:"detail-msg-time",children:M(s.timestamp)})]});if(s.role==="assistant"&&s.segments&&s.segments.length>0){const n=[];let o=0;for(;o<s.segments.length;){const d=s.segments[o];if(d.type==="reasoning_text"){let a="";for(;o<s.segments.length&&s.segments[o].type==="reasoning_text";)a+=s.segments[o].content,o++;a&&n.push(e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(V,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(F,{remarkPlugins:z,rehypePlugins:R,components:_,children:B(a)})})]},`r-${o}`));continue}n.push(e.jsx(ee,{seg:d},o)),o++}return e.jsxs("div",{className:`detail-message ${s.role}`,children:[e.jsx("div",{className:"detail-msg-role",children:h}),e.jsx("div",{className:"detail-msg-content detail-msg-md",children:n}),s.timestamp>0&&e.jsx("div",{className:"detail-msg-time",children:M(s.timestamp)})]})}const j=s.role==="assistant"&&s.reasoningContent?e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(V,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx(F,{remarkPlugins:z,rehypePlugins:R,components:_,children:B(s.reasoningContent)})})]}):null;return e.jsxs("div",{className:`detail-message ${s.role}`,children:[e.jsx("div",{className:"detail-msg-role",children:h}),j,e.jsx("div",{className:"detail-msg-content detail-msg-md",children:e.jsx(F,{remarkPlugins:z,rehypePlugins:R,components:_,children:B(s.content)})}),s.timestamp>0&&e.jsx("div",{className:"detail-msg-time",children:M(s.timestamp)})]})}export{we as SessionsPage};
@@ -1 +0,0 @@
1
- import{ai as o,aj as n}from"./mermaid.core-_uubCxEH.js";const t=(a,r)=>o.lang.round(n.parse(a)[r]);export{t as c};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as t,C as e}from"./chunk-727SXJPM-xrA_1fYt.js";import{_ as i}from"./mermaid.core-_uubCxEH.js";import"./chunk-FMBD7UC4-DpTtNcWD.js";import"./chunk-ND2GUHAM-DmI-7NxM.js";import"./chunk-55IACEB6-eTVfuioZ.js";import"./chunk-2J33WTMH-BkC9TJZK.js";import"./index-8Eh5USJy.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-B2G8c9k5.js";var g={parser:t,get db(){return new e},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{g as diagram};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as t,C as e}from"./chunk-727SXJPM-xrA_1fYt.js";import{_ as i}from"./mermaid.core-_uubCxEH.js";import"./chunk-FMBD7UC4-DpTtNcWD.js";import"./chunk-ND2GUHAM-DmI-7NxM.js";import"./chunk-55IACEB6-eTVfuioZ.js";import"./chunk-2J33WTMH-BkC9TJZK.js";import"./index-8Eh5USJy.js";import"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import"./markdown-B2G8c9k5.js";var g={parser:t,get db(){return new e},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{g as diagram};
@@ -1,212 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-_uubCxEH.js","assets/react-vendor-BPQixOLZ.js","assets/PluginConfigPage-Bda8iLH6.js","assets/SchemaForm-BcYxH5r1.js","assets/ConfirmDialog-DbV-E1Nd.js","assets/highlight-DJvvuuwd.js","assets/highlight-BPWJwfct.css","assets/katex-Bq6vt64r.js","assets/katex-CIHdCL6t.css","assets/markdown-B2G8c9k5.js","assets/MarketplacePage-DzmqvEhm.js","assets/clock-AfKIpZ6h.js","assets/PlatformPage-Cl_2WBBf.js","assets/globe-BKJqBqHF.js","assets/AuthorityPage-moleXD4t.js","assets/LogPage-BTvnnjEI.js","assets/SessionsPage-Dmw9u5-k.js","assets/FilesPage-DUh-AYCa.js","assets/DynamicPage-Dmz4Tfnd.js","assets/cytoscape.esm-LDYqcvCF.js","assets/cytoscape-fcose-DXAQNCkb.js"])))=>i.map(i=>d[i]);
2
- import{r as a,j as e,c as st}from"./react-vendor-BPQixOLZ.js";import"./highlight-DJvvuuwd.js";import"./katex-Bq6vt64r.js";import{r as tt,b as nt,a as at,c as rt,d as ot,M as $e}from"./markdown-B2G8c9k5.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const d of i)if(d.type==="childList")for(const u of d.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(i){const d={};return i.integrity&&(d.integrity=i.integrity),i.referrerPolicy&&(d.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?d.credentials="include":i.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function r(i){if(i.ep)return;i.ep=!0;const d=n(i);fetch(i.href,d)}})();const it="modulepreload",lt=function(t){return"/"+t},ds={},fe=function(s,n,r){let i=Promise.resolve();if(n&&n.length>0){let u=function(l){return Promise.all(l.map(y=>Promise.resolve(y).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),f=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));i=u(n.map(l=>{if(l=lt(l),l in ds)return;ds[l]=!0;const y=l.endsWith(".css"),p=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${p}`))return;const j=document.createElement("link");if(j.rel=y?"stylesheet":it,y||(j.as="script"),j.crossOrigin="",j.href=l,f&&j.setAttribute("nonce",f),document.head.appendChild(j),y)return new Promise((b,c)=>{j.addEventListener("load",b),j.addEventListener("error",()=>c(new Error(`Unable to preload CSS for ${l}`)))})}))}function d(u){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=u,window.dispatchEvent(h),!h.defaultPrevented)throw u}return i.then(u=>{for(const h of u||[])h.status==="rejected"&&d(h.reason);return s().catch(d)})};/**
3
- * @license lucide-react v1.7.0 - ISC
4
- *
5
- * This source code is licensed under the ISC license.
6
- * See the LICENSE file in the root directory of this source tree.
7
- */const vs=(...t)=>t.filter((s,n,r)=>!!s&&s.trim()!==""&&r.indexOf(s)===n).join(" ").trim();/**
8
- * @license lucide-react v1.7.0 - ISC
9
- *
10
- * This source code is licensed under the ISC license.
11
- * See the LICENSE file in the root directory of this source tree.
12
- */const ct=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
13
- * @license lucide-react v1.7.0 - ISC
14
- *
15
- * This source code is licensed under the ISC license.
16
- * See the LICENSE file in the root directory of this source tree.
17
- */const dt=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(s,n,r)=>r?r.toUpperCase():n.toLowerCase());/**
18
- * @license lucide-react v1.7.0 - ISC
19
- *
20
- * This source code is licensed under the ISC license.
21
- * See the LICENSE file in the root directory of this source tree.
22
- */const us=t=>{const s=dt(t);return s.charAt(0).toUpperCase()+s.slice(1)};/**
23
- * @license lucide-react v1.7.0 - ISC
24
- *
25
- * This source code is licensed under the ISC license.
26
- * See the LICENSE file in the root directory of this source tree.
27
- */var Ke={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
28
- * @license lucide-react v1.7.0 - ISC
29
- *
30
- * This source code is licensed under the ISC license.
31
- * See the LICENSE file in the root directory of this source tree.
32
- */const ut=t=>{for(const s in t)if(s.startsWith("aria-")||s==="role"||s==="title")return!0;return!1},ht=a.createContext({}),mt=()=>a.useContext(ht),ft=a.forwardRef(({color:t,size:s,strokeWidth:n,absoluteStrokeWidth:r,className:i="",children:d,iconNode:u,...h},f)=>{const{size:l=24,strokeWidth:y=2,absoluteStrokeWidth:p=!1,color:j="currentColor",className:b=""}=mt()??{},c=r??p?Number(n??y)*24/Number(s??l):n??y;return a.createElement("svg",{ref:f,...Ke,width:s??l??Ke.width,height:s??l??Ke.height,stroke:t??j,strokeWidth:c,className:vs("lucide",b,i),...!d&&!ut(h)&&{"aria-hidden":"true"},...h},[...u.map(([S,E])=>a.createElement(S,E)),...Array.isArray(d)?d:[d]])});/**
33
- * @license lucide-react v1.7.0 - ISC
34
- *
35
- * This source code is licensed under the ISC license.
36
- * See the LICENSE file in the root directory of this source tree.
37
- */const B=(t,s)=>{const n=a.forwardRef(({className:r,...i},d)=>a.createElement(ft,{ref:d,iconNode:s,className:vs(`lucide-${ct(us(t))}`,`lucide-${t}`,r),...i}));return n.displayName=us(t),n};/**
38
- * @license lucide-react v1.7.0 - ISC
39
- *
40
- * This source code is licensed under the ISC license.
41
- * See the LICENSE file in the root directory of this source tree.
42
- */const pt=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],ys=B("archive",pt);/**
43
- * @license lucide-react v1.7.0 - ISC
44
- *
45
- * This source code is licensed under the ISC license.
46
- * See the LICENSE file in the root directory of this source tree.
47
- */const xt=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],gt=B("bot",xt);/**
48
- * @license lucide-react v1.7.0 - ISC
49
- *
50
- * This source code is licensed under the ISC license.
51
- * See the LICENSE file in the root directory of this source tree.
52
- */const jt=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M9 13a4.5 4.5 0 0 0 3-4",key:"10igwf"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M12 13h4",key:"1ku699"}],["path",{d:"M12 18h6a2 2 0 0 1 2 2v1",key:"105ag5"}],["path",{d:"M12 8h8",key:"1lhi5i"}],["path",{d:"M16 8V5a2 2 0 0 1 2-2",key:"u6izg6"}],["circle",{cx:"16",cy:"13",r:".5",key:"ry7gng"}],["circle",{cx:"18",cy:"3",r:".5",key:"1aiba7"}],["circle",{cx:"20",cy:"21",r:".5",key:"yhc1fs"}],["circle",{cx:"20",cy:"8",r:".5",key:"1e43v0"}]],hs=B("brain-circuit",jt);/**
53
- * @license lucide-react v1.7.0 - ISC
54
- *
55
- * This source code is licensed under the ISC license.
56
- * See the LICENSE file in the root directory of this source tree.
57
- */const vt=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],ws=B("chevron-down",vt);/**
58
- * @license lucide-react v1.7.0 - ISC
59
- *
60
- * This source code is licensed under the ISC license.
61
- * See the LICENSE file in the root directory of this source tree.
62
- */const yt=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ns=B("chevron-right",yt);/**
63
- * @license lucide-react v1.7.0 - ISC
64
- *
65
- * This source code is licensed under the ISC license.
66
- * See the LICENSE file in the root directory of this source tree.
67
- */const wt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],bs=B("circle-check",wt);/**
68
- * @license lucide-react v1.7.0 - ISC
69
- *
70
- * This source code is licensed under the ISC license.
71
- * See the LICENSE file in the root directory of this source tree.
72
- */const Nt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],bt=B("circle",Nt);/**
73
- * @license lucide-react v1.7.0 - ISC
74
- *
75
- * This source code is licensed under the ISC license.
76
- * See the LICENSE file in the root directory of this source tree.
77
- */const kt=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],Ct=B("command",kt);/**
78
- * @license lucide-react v1.7.0 - ISC
79
- *
80
- * This source code is licensed under the ISC license.
81
- * See the LICENSE file in the root directory of this source tree.
82
- */const St=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],_t=B("download",St);/**
83
- * @license lucide-react v1.7.0 - ISC
84
- *
85
- * This source code is licensed under the ISC license.
86
- * See the LICENSE file in the root directory of this source tree.
87
- */const $t=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],es=B("file-text",$t);/**
88
- * @license lucide-react v1.7.0 - ISC
89
- *
90
- * This source code is licensed under the ISC license.
91
- * See the LICENSE file in the root directory of this source tree.
92
- */const Mt=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],It=B("file",Mt);/**
93
- * @license lucide-react v1.7.0 - ISC
94
- *
95
- * This source code is licensed under the ISC license.
96
- * See the LICENSE file in the root directory of this source tree.
97
- */const Tt=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 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.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],Et=B("folder-open",Tt);/**
98
- * @license lucide-react v1.7.0 - ISC
99
- *
100
- * This source code is licensed under the ISC license.
101
- * See the LICENSE file in the root directory of this source tree.
102
- */const Lt=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Ue=B("history",Lt);/**
103
- * @license lucide-react v1.7.0 - ISC
104
- *
105
- * This source code is licensed under the ISC license.
106
- * See the LICENSE file in the root directory of this source tree.
107
- */const Rt=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],Dt=B("list-todo",Rt);/**
108
- * @license lucide-react v1.7.0 - ISC
109
- *
110
- * This source code is licensed under the ISC license.
111
- * See the LICENSE file in the root directory of this source tree.
112
- */const Pt=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],ss=B("loader",Pt);/**
113
- * @license lucide-react v1.7.0 - ISC
114
- *
115
- * This source code is licensed under the ISC license.
116
- * See the LICENSE file in the root directory of this source tree.
117
- */const At=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],ks=B("menu",At);/**
118
- * @license lucide-react v1.7.0 - ISC
119
- *
120
- * This source code is licensed under the ISC license.
121
- * See the LICENSE file in the root directory of this source tree.
122
- */const zt=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],ze=B("message-square",zt);/**
123
- * @license lucide-react v1.7.0 - ISC
124
- *
125
- * This source code is licensed under the ISC license.
126
- * See the LICENSE file in the root directory of this source tree.
127
- */const Ot=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],Cs=B("paperclip",Ot);/**
128
- * @license lucide-react v1.7.0 - ISC
129
- *
130
- * This source code is licensed under the ISC license.
131
- * See the LICENSE file in the root directory of this source tree.
132
- */const Ft=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Wt=B("refresh-cw",Ft);/**
133
- * @license lucide-react v1.7.0 - ISC
134
- *
135
- * This source code is licensed under the ISC license.
136
- * See the LICENSE file in the root directory of this source tree.
137
- */const Bt=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],qt=B("sparkles",Bt);/**
138
- * @license lucide-react v1.7.0 - ISC
139
- *
140
- * This source code is licensed under the ISC license.
141
- * See the LICENSE file in the root directory of this source tree.
142
- */const Vt=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ht=B("square",Vt);/**
143
- * @license lucide-react v1.7.0 - ISC
144
- *
145
- * This source code is licensed under the ISC license.
146
- * See the LICENSE file in the root directory of this source tree.
147
- */const Jt=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Gt=B("trash-2",Jt);/**
148
- * @license lucide-react v1.7.0 - ISC
149
- *
150
- * This source code is licensed under the ISC license.
151
- * See the LICENSE file in the root directory of this source tree.
152
- */const Kt=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Oe=B("triangle-alert",Kt);/**
153
- * @license lucide-react v1.7.0 - ISC
154
- *
155
- * This source code is licensed under the ISC license.
156
- * See the LICENSE file in the root directory of this source tree.
157
- */const Ut=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],os=B("wrench",Ut);/**
158
- * @license lucide-react v1.7.0 - ISC
159
- *
160
- * This source code is licensed under the ISC license.
161
- * See the LICENSE file in the root directory of this source tree.
162
- */const Yt=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ss=B("x",Yt);/**
163
- * @license lucide-react v1.7.0 - ISC
164
- *
165
- * This source code is licensed under the ISC license.
166
- * See the LICENSE file in the root directory of this source tree.
167
- */const Xt=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],_s=B("zap",Xt),$s="aalis:activeSessionId";function Zt(){try{return window.localStorage.getItem($s)||"__new_chat__"}catch{return"__new_chat__"}}let ts=Zt();const ns=new Set;function ae(){return ts}function Ye(t){if(ts!==t){ts=t;try{window.localStorage.setItem($s,t)}catch{}for(const s of ns)s(t)}}function Qt(t){return ns.add(t),()=>ns.delete(t)}function Ms(t){return t!==401?!1:(window.location.replace("/"),!0)}async function se(t,s){const n=await fetch(t,{headers:{"Content-Type":"application/json"},...s});if(Ms(n.status))throw new Error("会话已失效,正在跳转登录");return n.json()}async function he(t,s,n={}){const r=await fetch(`/api/page-action/${encodeURIComponent(t)}/${encodeURIComponent(s)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(Ms(r.status))throw new Error("会话已失效,正在跳转登录");const i=await r.json();if(!r.ok)throw new Error(i.error||"请求失败");return i.data}function ke(t){return t?t.startsWith("http://")||t.startsWith("https://")?`/api/proxy/image?url=${encodeURIComponent(t)}`:t:""}function en(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})}function sn(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"9",cy:"21",r:"1"}),e.jsx("circle",{cx:"20",cy:"21",r:"1"}),e.jsx("path",{d:"M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"})]})}function tn(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function nn(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14,2 14,8 20,8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("line",{x1:"10",y1:"9",x2:"8",y2:"9"})]})}function an(){return e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function rn(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})})}function on(){return e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function ln(t){const s=a.useRef(t);s.current=t;const n=a.useRef(null),[r,i]=a.useState(!1),d=a.useRef(ae());a.useEffect(()=>{let f,l,y=!1;function p(){if(y)return;const j=location.protocol==="https:"?"wss:":"ws:";f=new WebSocket(`${j}//${location.host}/ws`),n.current=f,f.onopen=()=>{y||(i(!0),f.send(JSON.stringify({type:"subscribe_logs"})),f.send(JSON.stringify({type:"subscribe_session",sessionId:ae()})),d.current=ae())},f.onclose=()=>{y||(i(!1),l=setTimeout(p,3e3))},f.onmessage=b=>{var c,S,E,C,O,q,w,V,K,R,ie,N,L;try{const m=JSON.parse(b.data),x=s.current;m.type==="stream"?(x.onStream(m.contentDelta,m.reasoningDelta,m.done,m.toolLimitReached),m.toolCallProgress&&((c=x.onToolCallProgress)==null||c.call(x,m.toolCallProgress)),m.done&&((S=x.onToolCallProgressClear)==null||S.call(x))):m.type==="message"&&(m.content||(E=m.attachments)!=null&&E.length)?x.onMessage(m.content??"",m.reasoningContent,m.segments,m.attachments,m.modelInfo):m.type==="tool_call"&&m.toolName?x.onToolCall(m.toolName,m.toolArgs??{},m.toolPhase,m.toolResult):m.type==="log"&&m.log?x.onLog(m.log):m.type==="state_changed"?(C=x.onStateChanged)==null||C.call(x):m.type==="restarting"?(O=x.onRestarting)==null||O.call(x):m.type==="reload"?(q=x.onReload)==null||q.call(x):m.type==="sessions_changed"?(w=x.onSessionsChanged)==null||w.call(x):m.type==="todo_updated"&&m.todoItems?(V=x.onTodoUpdated)==null||V.call(x,m.todoItems):m.type==="stream_resume"?(K=x.onStreamResume)==null||K.call(x,m.content??"",m.reasoningContent??"",m.segments??[],!!m.done,m.toolCallsProgress):m.type==="confirm"&&m.content?(R=x.onConfirm)==null||R.call(x,m.content):m.type==="token_usage"&&m.tokenUsage?(ie=x.onTokenUsage)==null||ie.call(x,m.tokenUsage):m.type==="compressing"&&m.sessionId?(N=x.onCompressing)==null||N.call(x,m.sessionId,m.content??"start"):m.type==="history_changed"&&m.sessionId?(L=x.onHistoryChanged)==null||L.call(x,m.sessionId):m.type==="page_refresh"&&window.dispatchEvent(new CustomEvent("aalis:page-refresh",{detail:{pluginName:m.pluginName}}))}catch{}}}return p(),()=>{y=!0,clearTimeout(l),f==null||f.close()}},[]),a.useEffect(()=>Qt(l=>{const y=n.current;(y==null?void 0:y.readyState)===WebSocket.OPEN&&(y.send(JSON.stringify({type:"unsubscribe_session",sessionId:d.current})),y.send(JSON.stringify({type:"subscribe_session",sessionId:l})),d.current=l)}),[]);const u=a.useCallback((f,l)=>{var y;if(((y=n.current)==null?void 0:y.readyState)===WebSocket.OPEN){const p={type:"message",content:f,sessionId:ae()};l&&l.length>0&&(p.attachments=l),n.current.send(JSON.stringify(p))}},[]),h=a.useCallback(f=>{var l;((l=n.current)==null?void 0:l.readyState)===WebSocket.OPEN&&n.current.send(JSON.stringify(f))},[]);return{send:u,sendRaw:h,connected:r}}function cn(){const t=new Date,s=String(t.getMonth()+1).padStart(2,"0"),n=String(t.getDate()).padStart(2,"0"),r=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0");return`会话 ${s}-${n} ${r}:${i}`}function dn(t){const s=[];let n=t.replace(/\n?\[文件: ([^\n(]+?)\s*\(ID:[^)]+\)\]\n--- 文件内容 ---[\s\S]*?--- 文件内容结束 ---/g,(r,i)=>(s.push(i.trim()),""));return n=n.replace(/\n?\[文件: ([^\n(]+?)\s*\(ID:[^,\n)]+[,\n][\s\S]*?\)\]/g,(r,i)=>(s.push(i.trim()),"")),n=n.replace(/\n?\[文件: ([^\]-]+?) - [^\]]+\]/g,(r,i)=>(s.push(i.trim()),"")),n=n.replace(/\n?\[文件: ([^\]]+?)\s*(?:\(ID:[^)]+\))?\]/g,(r,i)=>(s.push(i.trim()),"")),{displayContent:n.trim(),fileNames:s}}function un(t){var r,i,d,u;const s=[];let n=0;for(;n<t.length;){const h=t[n];if(h.role==="user"){const f=h.content??"",l=Array.isArray((r=h.metadata)==null?void 0:r.fileNames)?h.metadata.fileNames:null,{displayContent:y,fileNames:p}=dn(f),j=(l??p).filter(Boolean);s.push({role:"user",content:y,fileNames:j.length>0?j:void 0,timestamp:h.timestamp??0}),n++;continue}if(h.role==="system"){h.kind==="event-marker"&&s.push({role:"system",content:h.content??"",timestamp:h.timestamp??0}),n++;continue}if(h.role==="notice"){s.push({role:"system",content:h.content??"",timestamp:h.timestamp??0}),n++;continue}if(h.role==="assistant"){const f=[],l=[];let y=h.timestamp??0,p="",j=!1,b;for(;n<t.length&&(t[n].role==="assistant"||t[n].role==="tool");){const C=t[n];if(C.role==="assistant"){const O=(i=C.metadata)==null?void 0:i.modelInfo;O&&(b=O)}if(C.role==="assistant"&&C.segments&&C.segments.length>0){j=!0,f.length=0,l.length=0;for(const O of C.segments)f.push(O);y=C.timestamp??y,n++;continue}if(C.role==="assistant"&&C.toolCalls&&C.toolCalls.length>0){C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),C.content&&f.push({type:"text",content:C.content});for(const O of C.toolCalls){let q={};try{q=JSON.parse(O.function.arguments)}catch{}f.push({type:"tool_call",name:O.function.name,args:q})}y=C.timestamp??y,n++}else if(C.role==="tool"&&C.toolCallId){for(let O=f.length-1;O>=0;O--){const q=f[O];if(q.type==="tool_call"&&q.result===void 0){q.result=C.content??"";break}}n++}else if(C.role==="assistant"){if(n===t.length-1||((d=t[n+1])==null?void 0:d.role)==="user"||((u=t[n+1])==null?void 0:u.role)==="system"){C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),p=C.content??"",y=C.timestamp??y,n++;break}C.reasoningContent&&l.push({type:"reasoning_text",content:C.reasoningContent}),C.content&&f.push({type:"text",content:C.content}),y=C.timestamp??y,n++}else break}let c;j?c=f:(c=[...l,...f],p&&c.push({type:"text",content:p}));let S="",E="";for(const C of c)C.type==="reasoning_text"?S+=C.content:C.type==="text"&&(E+=C.content);s.push({role:"assistant",content:E||p||h.content||"",segments:c.length>0?c:void 0,reasoningContent:S||void 0,timestamp:y,modelInfo:b});continue}n++}return s}function hn(t){const[s,n]=a.useState([]),[r,i]=a.useState(ae()),[d,u]=a.useState([]),[h,f]=a.useState(!1),l=a.useRef(!1),y=a.useRef(new Map),p=a.useMemo(()=>{const N=t.find(L=>L.key==="sessions");return(N==null?void 0:N.plugin)??null},[t]),j=a.useRef(p);j.current=p;const b=a.useRef(r);b.current=r;const c=a.useRef(d);c.current=d;const S=a.useRef(s);S.current=s;const E=a.useMemo(()=>p?s.length===0||!s.some(N=>N.id===r):!1,[p,s,r]),C=a.useMemo(()=>{const N=s.find(L=>L.id===r);return(N==null?void 0:N.title)||(N==null?void 0:N.displayTitle)||(N==null?void 0:N.name)||""},[s,r]),O=a.useCallback(()=>{const N=j.current;N&&he(N,"listSessions").then(L=>{Array.isArray(L)&&n(L)}).catch(()=>{})},[]),q=a.useCallback(()=>{c.current.length>0&&y.current.set(b.current,c.current);const N="__new_chat__";i(N),Ye(N),u([]),f(!1),l.current=!1},[]),w=a.useCallback(async N=>{const L=j.current;if(!L)return null;const m=cn();try{const x=await he(L,"createSession",{name:m,...N?{parentId:N}:{}});if(!(x!=null&&x.id))return null;const H=x.id;return n(U=>{if(U.some(_=>_.id===H))return U;const Q={id:H,name:x.name||m,title:x.title,displayTitle:x.title||x.name||m,status:"active",children:[],childCount:0,parentId:N,createdAt:Date.now()};return[...U,Q]}),N&&n(U=>U.map(Q=>Q.id===N?{...Q,children:[...Q.children,H],childCount:Q.childCount+1}:Q)),c.current.length>0&&y.current.set(b.current,c.current),i(H),Ye(H),u([]),f(!1),l.current=!1,he(L,"listSessions").then(U=>{Array.isArray(U)&&n(U)}).catch(()=>{}),H}catch{return null}},[]),V=a.useCallback(async()=>!j.current||S.current.some(m=>m.id===b.current)?b.current:await w()||b.current,[w]),K=a.useCallback((N,L)=>{he(L,"getSessionDetail",{id:N}).then(m=>{if(m!=null&&m.messages&&b.current===N){const x=un(m.messages);if(l.current){for(;x.length>0&&x[x.length-1].role==="assistant";)x.pop();const H=c.current,U=H[H.length-1];U&&U.role==="assistant"&&x.push(U)}u(x),y.current.set(N,x)}}).catch(()=>{})},[]),R=a.useCallback(N=>{const L=N===b.current;if(L&&c.current.length>0)return;!L&&c.current.length>0&&y.current.set(b.current,c.current),i(N),Ye(N),f(!1),l.current=!1;const m=j.current,x=y.current.get(N);u(x??[]),!x&&m&&K(N,m),O()},[K,O]),ie=a.useCallback(N=>{if(N!==b.current)return;const L=j.current;L&&(y.current.delete(N),K(N,L))},[K]);return a.useEffect(()=>{p&&he(p,"listSessions").then(N=>{if(!Array.isArray(N))return;n(N);const L=ae();L&&L!=="__new_chat__"&&N.some(m=>m.id===L)&&(i(L),K(L,p))}).catch(()=>{})},[p,K]),{pluginName:p,sessionList:s,activeSessionId:r,activeSessionTitle:C,isNewChat:E,messages:d,setMessages:u,refresh:O,startNewChat:q,createSession:w,ensureSession:V,switchSession:R,handleHistoryChanged:ie,loading:h,setLoading:f,streamingRef:l}}function Xe({name:t,info:s,onPreferChanged:n}){var j;const[r,i]=a.useState(!1),d=s.providers,u=d.length>0,h=d.length>1,f=s.preferred??((j=d[0])==null?void 0:j.contextId)??"",l=d.find(b=>b.contextId===f),y=async b=>{if(!r){i(!0);try{await se(`/api/services/${encodeURIComponent(t)}/prefer`,{method:"POST",body:JSON.stringify({contextId:b})}),n==null||n()}finally{i(!1)}}},p=async()=>{if(!r){i(!0);try{await se(`/api/services/${encodeURIComponent(t)}/prefer`,{method:"DELETE"}),n==null||n()}finally{i(!1)}}};return e.jsxs("div",{className:"service-slot-card",children:[e.jsxs("div",{className:"service-slot-header",children:[e.jsx("span",{className:"service-slot-name",children:t}),e.jsxs("div",{className:"service-slot-header-badges",children:[s.preferred&&e.jsx("span",{className:"service-winner-badge preferred",children:"偏好"}),e.jsx("span",{className:`badge ${u?"active":"error"}`,children:u?h?`${d.length} 个提供者`:"就绪":"未就绪"})]})]}),u?h?e.jsxs("div",{className:"service-slot-select-row",children:[e.jsx("span",{className:"service-slot-label",children:"活跃提供者"}),e.jsx("select",{className:"service-select",value:f,disabled:r,onChange:b=>y(b.target.value),children:d.map(b=>{const c=b.displayName||b.label||b.contextId,S=c!==b.contextId?`${c} · p${b.priority} (${b.contextId})`:`${b.contextId} · p${b.priority}`;return e.jsx("option",{value:b.contextId,children:S},b.contextId)})}),s.preferred&&e.jsx("button",{type:"button",className:"service-clear-prefer",onClick:p,disabled:r,title:"清除偏好,恢复 priority 默认顺序",children:"恢复默认"})]}):e.jsxs("div",{className:"service-slot-single",children:[e.jsx("span",{className:"service-slot-label",children:"提供者"}),e.jsxs("span",{className:"service-slot-provider-name",children:[(l==null?void 0:l.displayName)||(l==null?void 0:l.label)||(l==null?void 0:l.contextId),((l==null?void 0:l.displayName)||(l==null?void 0:l.label))&&e.jsxs("span",{className:"service-slot-context-id",children:[" ",l==null?void 0:l.contextId]})]})]}):e.jsx("div",{className:"service-slot-single",children:e.jsx("span",{className:"empty-hint",children:"无提供者"})})]})}function mn({status:t,connected:s,plugins:n,servicesData:r,onRefreshServices:i}){var q;const d=n.filter(w=>w.state==="active").length,u=n.filter(w=>w.state==="error").length,h=n.length,[f,l]=a.useState([]),[y,p]=a.useState([]),[j,b]=a.useState([]);a.useEffect(()=>{se("/api/tool-groups").then(w=>l(w.groups??[])).catch(()=>{})},[n]),a.useEffect(()=>{se("/api/service-groups").then(w=>p(w.groups??[])).catch(()=>{})},[n]),a.useEffect(()=>{se("/api/llm-models").then(w=>b(w.models??[])).catch(()=>{})},[n]);const c=r?Object.entries(r):[],S=y.map(w=>({label:w.label,entries:c.filter(([V])=>w.services.includes(V))})),E=S.some(w=>w.entries.length>0),C=new Set(y.flatMap(w=>w.services)),O=c.filter(([w])=>!C.has(w));return e.jsxs("div",{className:"page-content page-dashboard",children:[e.jsx("div",{className:"section-label",children:"概览"}),e.jsxs("div",{className:"overview-grid",children:[e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx("span",{className:`status-dot-lg ${s?"online":"offline"}`})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"连接状态"}),e.jsx("div",{className:"overview-card-value",children:s?"已连接":"离线"})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(qt,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"应用名称"}),e.jsx("div",{className:"overview-card-value",children:(t==null?void 0:t.name)??"-"})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(_s,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"活跃插件"}),e.jsxs("div",{className:"overview-card-value",children:[d," / ",h]})]})]}),u>0&&e.jsxs("div",{className:"overview-card overview-card-error",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(Oe,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"错误插件"}),e.jsx("div",{className:"overview-card-value",children:u})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(os,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"已注册工具"}),e.jsx("div",{className:"overview-card-value",children:(t==null?void 0:t.tools.length)??0})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(Ct,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"已注册指令"}),e.jsx("div",{className:"overview-card-value",children:((q=t==null?void 0:t.commands)==null?void 0:q.length)??0})]})]}),e.jsxs("div",{className:"overview-card",children:[e.jsx("div",{className:"overview-card-icon",children:e.jsx(gt,{size:20})}),e.jsxs("div",{className:"overview-card-body",children:[e.jsx("div",{className:"overview-card-label",children:"可用模型"}),e.jsx("div",{className:"overview-card-value",children:j.length})]})]})]}),E?e.jsxs(e.Fragment,{children:[S.map(w=>w.entries.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"section-label",children:w.label}),e.jsx("div",{className:"services-grid",children:w.entries.map(([V,K])=>e.jsx(Xe,{name:V,info:K,onPreferChanged:i},V))})]},w.label)),O.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"section-label",children:"其他"}),e.jsx("div",{className:"services-grid",children:O.map(([w,V])=>e.jsx(Xe,{name:w,info:V,onPreferChanged:i},w))})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section-label",children:"服务"}),e.jsxs("div",{className:"services-grid",children:[c.length===0&&e.jsx("div",{className:"empty-hint",children:"加载中..."}),c.map(([w,V])=>e.jsx(Xe,{name:w,info:V,onPreferChanged:i},w))]})]}),e.jsx("div",{className:"section-label",children:"工具分组"}),f.length>0?e.jsx("div",{className:"tool-groups-grid",children:f.map(w=>{const V=w.contributingPlugins??[],K=[w.pluginName,...V.filter(R=>R!==w.pluginName)];return e.jsxs("div",{className:"tool-group-card",children:[e.jsxs("div",{className:"tool-group-header",children:[e.jsx("span",{className:"tool-group-name",children:w.label}),e.jsxs("span",{className:"tool-group-count",children:[w.toolCount," 工具"]})]}),w.description&&e.jsx("div",{className:"tool-group-desc",children:w.description}),e.jsxs("div",{className:"tool-group-meta",children:[e.jsx("span",{className:"tool-group-id",children:w.name}),e.jsx("span",{className:"tool-group-plugin",title:K.join(", "),children:K.join(" · ")})]})]},w.name)})}):e.jsx("div",{className:"tools-grid",children:!t||t.tools.length===0?e.jsx("div",{className:"empty-hint",children:"无工具"}):t.tools.map(w=>e.jsx("span",{className:"tool-chip",children:w},w))}),e.jsx("div",{className:"section-label",children:"已注册指令"}),e.jsx("div",{className:"tools-grid",children:!t||!t.commands||t.commands.length===0?e.jsx("div",{className:"empty-hint",children:"无指令"}):t.commands.map(w=>e.jsxs("span",{className:"tool-chip cmd-chip",title:w.description,children:["/",w.name]},w.name))})]})}function ms(t){const n=t.trim().split("|"),r=n[0].trim()===""?1:0,i=n[n.length-1].trim()===""?n.length-1:n.length;return Math.max(0,i-r)}function fn(t,s){const n=t.trim(),r=n.startsWith("|")?"|":"",i=n.endsWith("|")?"|":"",u=n.slice(r.length,i?n.length-1:void 0).split("|").map(h=>h.trim()).filter(h=>/^:?-+:?$/.test(h));for(;u.length<s;)u.push("---");return u.length=s,r+u.join("|")+i}function pn(t){return/^\|?[ \t]*:?-+:?[ \t]*(\|[ \t]*:?-+:?[ \t]*)*\|?\s*$/.test(t)}function xn(t){return t&&t.split(/(```[\s\S]*?```|`[^`\n]*`)/g).map((n,r)=>{if(r%2===1)return n;const i=n.split(`
168
- `),d=[];for(let u=0;u<i.length;u++){const h=i[u];if(u>0&&pn(h)){const f=i[u-1];if(f.includes("|")&&f.trim()){const l=ms(f),y=ms(h);if(l>0&&y>0&&l!==y){d.push(fn(h,l));continue}}}d.push(h)}return d.join(`
169
- `)}).join("")}function Me(t){return t=xn(t),t.split(/(```[\s\S]*?```|`[^`]*`)/g).map((n,r)=>(r%2===1||(n=n.replace(/\\\[([\s\S]*?)\\\]/g,(d,u)=>`$$${u.replace(/\|/g,"\\vert ")}$$`),n=n.replace(/\\\((.*?)\\\)/g,(d,u)=>`$${u.replace(/\|/g,"\\vert ")}$`),n=n.replace(/\$\$([\s\S]+?)\$\$/g,(d,u)=>u.includes(`
170
- `)?`
171
-
172
- $$
173
- ${u.replace(/^[ \t]*\n?/,"").replace(/\n?[ \t]*$/,"")}
174
- $$
175
-
176
- `:d),(n.match(/\$\$/g)??[]).length%2===1&&(n=n.replace(/\$\$((?:(?!\$\$)[\s\S])+)$/,(d,u)=>{const h=u.replace(/^[ \t]*\n?/,"").replace(/\n?[ \t]*$/,"");return!h||!u.includes(`
177
- `)?`$$${u}`:`
178
-
179
- $$
180
- ${h}
181
- $$
182
-
183
- `}))),n)).join("")}function gn(t){if(!t||!Number.isFinite(t))return"";const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const n=new Date,r=f=>f.toString().padStart(2,"0"),i=`${r(s.getHours())}:${r(s.getMinutes())}`,d=s.getFullYear()===n.getFullYear();if(d&&s.getMonth()===n.getMonth()&&s.getDate()===n.getDate())return i;const h=`${s.getMonth()+1}-${s.getDate()} ${i}`;return d?h:`${s.getFullYear()}-${h}`}let Ze=null;function jn(){return Ze||(Ze=fe(()=>import("./mermaid.core-_uubCxEH.js").then(t=>t.bm),__vite__mapDeps([0,1])).then(t=>{var r;const s=t.default,n=typeof window<"u"&&((r=window.matchMedia)==null?void 0:r.call(window,"(prefers-color-scheme: dark)").matches);return s.initialize({startOnLoad:!1,theme:n?"dark":"default",securityLevel:"strict",fontFamily:"inherit"}),s})),Ze}function fs(t){if(!(typeof document>"u"))for(const s of[`#${t}`,`#d${t}`,`#${t}-temp`])document.querySelectorAll(s).forEach(n=>n.remove())}let vn=0;function yn({chart:t}){const[s,n]=a.useState(null),[r,i]=a.useState(null),d=a.useRef(`mermaid-${++vn}`);return a.useEffect(()=>{let u=!1;const h=d.current,f=t.trim();if(!f){n(null),i(null);return}return jn().then(async l=>(await l.parse(f),l.render(h,f))).then(({svg:l})=>{u||(n(l),i(null))}).catch(l=>{if(fs(h),u)return;const y=l instanceof Error?l.message:String(l);i(y),n(null)}),()=>{u=!0,fs(h)}},[t]),r?e.jsxs("div",{className:"mermaid-block mermaid-block-error",children:[e.jsxs("div",{className:"mermaid-error-banner",children:["⚠ Mermaid 渲染失败:",r]}),e.jsx("pre",{children:e.jsx("code",{className:"language-mermaid",children:t})})]}):s?e.jsx("div",{className:"mermaid-block",dangerouslySetInnerHTML:{__html:s}}):e.jsx("pre",{className:"mermaid-block mermaid-block-loading",children:e.jsx("code",{className:"language-mermaid",children:t})})}const wn=a.memo(yn),Ie=[at,rt,ot],Nn={strict:"ignore",throwOnError:!1,errorColor:"inherit",output:"htmlAndMathml"},Te=[tt,[nt,Nn]];function bn({className:t,children:s,...n}){const r=/language-(\w+)/.exec(t??"");if((r==null?void 0:r[1])==="mermaid"){const d=Array.isArray(s)?s.join(""):String(s??"");return e.jsx(wn,{chart:d.replace(/\n$/,"")})}return e.jsx("code",{className:t,...n,children:s})}const Ee={code:bn};function kn(t){if(t===0)return"—";const s=["B","KB","MB","GB"];let n=0,r=t;for(;r>=1024&&n<s.length-1;)r/=1024,n++;return`${r.toFixed(n===0?0:1)} ${s[n]}`}function Cn(t){return new Date(t).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Sn({open:t,onClose:s,sessionId:n}){const[r,i]=a.useState([]),[d,u]=a.useState(!1),[h,f]=a.useState(null),[l,y]=a.useState(null),p=a.useCallback(async()=>{if(!n||n==="__new_chat__"){i([]);return}u(!0),f(null);try{const c=await se(`/api/uploaded-files?sessionId=${encodeURIComponent(n)}`);if(c.error)throw new Error(c.error);i(c.files||[])}catch(c){f(c instanceof Error?c.message:String(c)),i([])}finally{u(!1)}},[n]);a.useEffect(()=>{t&&p()},[t,p]);const j=a.useCallback(async c=>{if(window.confirm(`确定删除文件 "${c.name}"?删除后无法恢复。`)){y(c.id);try{const E=await fetch("/api/uploaded-files/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:c.sessionId,fileId:c.id})}),C=await E.json();if(!E.ok||C.error)throw new Error(C.error||`HTTP ${E.status}`);await p()}catch(E){window.alert(`删除失败:${E instanceof Error?E.message:String(E)}`)}finally{y(null)}}},[p]),b=a.useCallback(c=>{const S=`/api/uploaded-files/download?sessionId=${encodeURIComponent(c.sessionId)}&fileId=${encodeURIComponent(c.id)}`;window.open(S,"_blank")},[]);return t?e.jsxs("div",{className:"uploaded-files-drawer",children:[e.jsxs("div",{className:"uploaded-files-drawer-header",children:[e.jsx("span",{className:"uploaded-files-drawer-title",children:"已上传的文件"}),e.jsxs("div",{className:"uploaded-files-drawer-actions",children:[e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:p,title:"刷新",disabled:d,children:e.jsx(Wt,{size:14,className:d?"spin":""})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:s,title:"关闭",children:e.jsx(Ss,{size:14})})]})]}),e.jsxs("div",{className:"uploaded-files-drawer-body",children:[h&&e.jsxs("div",{className:"uploaded-files-drawer-error",children:["加载失败:",h]}),!h&&r.length===0&&!d&&e.jsx("div",{className:"uploaded-files-drawer-empty",children:"当前会话没有已上传的文件"}),r.map(c=>e.jsxs("div",{className:"uploaded-files-drawer-item",children:[e.jsx(It,{size:16,className:"uploaded-files-drawer-icon"}),e.jsxs("div",{className:"uploaded-files-drawer-info",children:[e.jsx("div",{className:"uploaded-files-drawer-name",title:c.name,children:c.name}),e.jsxs("div",{className:"uploaded-files-drawer-meta",children:[kn(c.size)," · ",c.mimeType," · ",Cn(c.uploadedAt)]}),e.jsxs("div",{className:"uploaded-files-drawer-id",title:c.id,children:["ID: ",c.id]})]}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn",onClick:()=>b(c),title:"下载",children:e.jsx(_t,{size:14})}),e.jsx("button",{type:"button",className:"uploaded-files-drawer-btn danger",onClick:()=>j(c),disabled:l===c.id,title:"删除",children:e.jsx(Gt,{size:14})})]},c.id))]})]}):null}function ps(t){return new Promise((s,n)=>{const r=new FileReader;r.onload=()=>s(r.result),r.onerror=n,r.readAsDataURL(t)})}const _n=a.memo(a.forwardRef(function({loading:s,connected:n,canUpload:r,canUploadImage:i,canUploadFile:d,acceptAttr:u,onSend:h,onAbort:f},l){const[y,p]=a.useState(""),[j,b]=a.useState([]),[c,S]=a.useState([]),E=a.useRef([]),C=a.useRef(null),O=a.useRef(null),q=a.useCallback(()=>{const _=C.current;_&&(_.style.height="auto",_.style.height=`${_.scrollHeight}px`)},[]),w=a.useCallback(async _=>{const M=[],P=[],W=[];for(const J of Array.from(_))if(J.type.startsWith("image/")&&i){if(J.size>10*1024*1024)continue;const Z=await ps(J);M.push(Z),W.push("image")}else if(d){if(J.size>20*1024*1024)continue;const Z=await ps(J);P.push({name:J.name,data:Z,mimeType:J.type||void 0}),W.push("file")}M.length>0&&b(J=>[...J,...M]),P.length>0&&S(J=>[...J,...P]),W.length>0&&(E.current=[...E.current,...W])},[i,d]);a.useImperativeHandle(l,()=>({addFiles:w}),[w]);const V=a.useCallback(async()=>{await h(y,c,j,E.current),p(""),b([]),S([]),E.current=[],C.current&&(C.current.style.height="auto")},[y,c,j,h]),K=_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),V())},R=async _=>{_.target.files&&await w(_.target.files),_.target.value=""},ie=async _=>{var W;if(!i)return;const M=(W=_.clipboardData)==null?void 0:W.items;if(!M)return;const P=[];for(const J of Array.from(M)){if(!J.type.startsWith("image/"))continue;const Z=J.getAsFile();Z&&P.push(Z)}P.length>0&&await w(P)},N=_=>{b(W=>W.filter((J,Z)=>Z!==_));const M=[...E.current];let P=0;for(let W=0;W<M.length;W++)if(M[W]==="image"){if(P===_){M.splice(W,1);break}P++}E.current=M},L=_=>{S(W=>W.filter((J,Z)=>Z!==_));const M=[...E.current];let P=0;for(let W=0;W<M.length;W++)if(M[W]==="file"){if(P===_){M.splice(W,1);break}P++}E.current=M},m=E.current,x=new Array(j.length),H=new Array(c.length);{let _=0,M=0;for(let P=0;P<m.length;P++)m[P]==="image"?(_<x.length&&(x[_]=P+1),_++):m[P]==="file"&&(M<H.length&&(H[M]=P+1),M++)}const U=!!(y.trim()||j.length>0||c.length>0),Q=s&&!U;return e.jsxs(e.Fragment,{children:[j.length>0&&e.jsx("div",{className:"pending-images",children:j.map((_,M)=>e.jsxs("div",{className:"pending-image-item",children:[e.jsx("img",{src:_,alt:`pending-${M}`}),e.jsx("button",{className:"pending-image-remove",onClick:()=>N(M),children:"×"}),x[M]>0&&e.jsxs("span",{className:"pending-order-badge",children:["#",x[M]]})]},M))}),c.length>0&&e.jsx("div",{className:"pending-files",children:c.map((_,M)=>e.jsxs("div",{className:"pending-file-item",children:[H[M]>0&&e.jsxs("span",{className:"pending-file-order",children:["#",H[M]]}),e.jsx("span",{className:"pending-file-icon",children:e.jsx(es,{size:14})}),e.jsx("span",{className:"pending-file-name",children:_.name}),e.jsx("button",{className:"pending-file-remove",onClick:()=>L(M),children:"×"})]},M))}),e.jsxs("div",{className:"input-area",children:[e.jsx("input",{ref:O,type:"file",accept:u,multiple:!0,style:{display:"none"},onChange:R}),r&&e.jsx("button",{className:"upload-btn",onClick:()=>{var _;return(_=O.current)==null?void 0:_.click()},disabled:!n,title:i&&d?"上传图片或文件":i?"上传图片":"上传文件",children:e.jsx(Cs,{size:18})}),e.jsx("textarea",{ref:C,value:y,onChange:_=>{p(_.target.value),q()},onKeyDown:K,onPaste:ie,placeholder:"输入消息... (Enter 发送, Shift+Enter 换行)",disabled:!n,rows:1}),Q?e.jsx("button",{className:"send-btn stop-mode",onClick:f,title:"停止生成",children:e.jsx(Ht,{size:16})}):e.jsx("button",{className:"send-btn",onClick:()=>{V()},disabled:!n||!U,children:"↑"})]})]})}));function $n({startTime:t,endTime:s}){const[n,r]=a.useState(Date.now());if(a.useEffect(()=>{if(s||!t)return;const d=setInterval(()=>r(Date.now()),100);return()=>clearInterval(d)},[t,s]),!t)return null;const i=((s||n)-t)/1e3;return e.jsxs("span",{className:"tool-call-timer",children:[i.toFixed(1),"s"]})}function xs({startTime:t,endTime:s}){const[n,r]=a.useState(Date.now());a.useEffect(()=>{if(s)return;let d;const u=()=>{r(Date.now()),d=requestAnimationFrame(u)};return d=requestAnimationFrame(u),()=>cancelAnimationFrame(d)},[s]);const i=((s||n)-t)/1e3;return e.jsxs("span",{className:"compress-timer",children:[i.toFixed(1),"s"]})}function Mn({seg:t,index:s}){return e.jsxs("details",{className:"tool-call-block",children:[e.jsxs("summary",{className:"tool-call-summary",children:[e.jsx(os,{size:14})," ",t.name,t.result==null?" …":"",e.jsx($n,{startTime:t.startTime,endTime:t.endTime})]}),e.jsxs("div",{className:"tool-call-content",children:[e.jsxs("div",{className:"tool-call-args",children:[e.jsx("strong",{children:"参数"}),e.jsx("pre",{children:JSON.stringify(t.args,null,2)})]}),t.result!=null&&e.jsxs("div",{className:"tool-call-result",children:[e.jsx("strong",{children:"结果"}),e.jsx("pre",{children:t.result})]})]})]},s)}const In=[".txt",".md",".csv",".json",".xml",".html",".htm",".css",".js",".ts",".yaml",".yml",".ini",".cfg",".conf",".log",".sh",".py",".java",".c",".cpp",".h",".rs",".go",".rb",".php",".sql",".pdf",".docx"],Tn=In.join(",")+",text/*,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document";function En(t){const s=t.trim();if(!s.startsWith("{"))return null;try{const n=JSON.parse(s);return typeof n!="object"||n===null||Array.isArray(n)?null:n}catch{return null}}function Ln(t){const s=t.trim();if(!s.startsWith("{"))return null;const n=[];let r=1;const i=()=>{for(;r<s.length&&/[\s,]/.test(s[r]);)r++};for(;r<s.length&&(i(),!(r>=s.length||s[r]==="}"||s[r]!=='"'));){r++;let d="",u=!1;for(;r<s.length;)if(s[r]==="\\"&&r+1<s.length)d+=s[r+1],r+=2;else if(s[r]==='"'){u=!0,r++;break}else d+=s[r],r++;if(!u){n.push({key:d,keyDone:!1,value:"",valueDone:!1,valueType:"unknown"});break}if(i(),r>=s.length||s[r]!==":"){n.push({key:d,keyDone:!0,value:"",valueDone:!1,valueType:"unknown"});break}if(r++,i(),r>=s.length){n.push({key:d,keyDone:!0,value:"",valueDone:!1,valueType:"unknown"});break}if(s[r]==='"'){r++;let h="",f=!1;for(;r<s.length;)if(s[r]==="\\"&&r+1<s.length){const l=s[r+1];h+=l==="n"?`
184
- `:l==="t"?" ":l==='"'?'"':l==="\\"?"\\":l,r+=2}else if(s[r]==='"'){f=!0,r++;break}else h+=s[r],r++;n.push({key:d,keyDone:!0,value:h,valueDone:f,valueType:"string"})}else if(s[r]==="{"||s[r]==="["){const h=s[r],f=h==="{"?"}":"]";let l=1;const y=r;r++;let p=!1;for(;r<s.length&&l>0;)p?s[r]==="\\"?r++:s[r]==='"'&&(p=!1):s[r]==='"'?p=!0:s[r]===h?l++:s[r]===f&&l--,r++;n.push({key:d,keyDone:!0,value:s.slice(y,r),valueDone:l===0,valueType:h==="{"?"object":"array"})}else{let h="";for(;r<s.length&&!/[,\s}]/.test(s[r]);)h+=s[r],r++;const f=r<s.length&&/[,}]/.test(s[r]),l=/^(true|false)$/.test(h)?"boolean":h==="null"?"null":"number";n.push({key:d,keyDone:!0,value:h,valueDone:f,valueType:l})}}return n.length>0?n:null}const Is={mood:"心情",state:"状态",desire:"发言欲望",current_action:"当前动作",think:"思考",message:"回复",response:"回复",reply:"回复",content:"内容",analysis:"分析",file_analysis:"文件分析",image_analysis:"图片分析"},Ts=new Set(["message","response","reply","content","answer","text","msg"]);function Rn({label:t,data:s}){const[n,r]=a.useState(!0);return e.jsxs("div",{className:"json-field json-field-group",children:[e.jsxs("div",{className:"json-field-header json-field-toggle",onClick:()=>r(!n),children:[n?e.jsx(ws,{size:14}):e.jsx(Ns,{size:14}),e.jsx("span",{className:"json-field-label",children:t})]}),n&&e.jsx("div",{className:"json-field-children",children:Object.entries(s).map(([i,d])=>e.jsx(Es,{fieldKey:i,value:d},i))})]})}function Es({fieldKey:t,value:s}){const n=Is[t]||t;if(s==null||s==="")return null;if(typeof s=="object"&&!Array.isArray(s))return e.jsx(Rn,{label:n,data:s});if(Array.isArray(s))return e.jsxs("div",{className:"json-field",children:[e.jsx("span",{className:"json-field-label",children:n}),e.jsx("span",{className:"json-field-value",children:s.map(String).join(", ")})]});const r=String(s),i=Ts.has(t);return e.jsxs("div",{className:`json-field${i?" json-field-reply":""}`,children:[e.jsx("span",{className:"json-field-label",children:n}),i?e.jsx("div",{className:"json-field-value json-field-value-md",children:e.jsx($e,{remarkPlugins:Ie,rehypePlugins:Te,components:Ee,children:Me(r)})}):e.jsx("span",{className:"json-field-value",children:r})]})}function Dn({data:t}){return e.jsx("div",{className:"json-message-view",children:Object.entries(t).map(([s,n])=>e.jsx(Es,{fieldKey:s,value:n},s))})}function Pn({fields:t}){return e.jsx("div",{className:"json-message-view",children:t.map((s,n)=>{const i=n===t.length-1&&(!s.valueDone||!s.keyDone),d=s.keyDone&&Is[s.key]||s.key,u=s.keyDone&&Ts.has(s.key);return e.jsxs("div",{className:`json-field${u?" json-field-reply":""}`,children:[e.jsxs("span",{className:`json-field-label${s.keyDone?"":" json-field-partial"}`,children:[d,!s.keyDone&&i&&e.jsx("span",{className:"streaming-cursor"})]}),s.keyDone&&(u&&s.value?e.jsxs("div",{className:"json-field-value json-field-value-md",children:[e.jsx($e,{remarkPlugins:Ie,rehypePlugins:Te,components:Ee,children:Me(s.value)}),i&&e.jsx("span",{className:"streaming-cursor"})]}):e.jsxs("span",{className:"json-field-value",children:[s.value,i&&e.jsx("span",{className:"streaming-cursor"})]}))]},n)})})}const Qe=a.memo(function({content:s}){const n=En(s);if(n)return e.jsx(Dn,{data:n});if(s.trim().startsWith("{")){const i=Ln(s);return i?e.jsx(Pn,{fields:i}):null}return e.jsx($e,{remarkPlugins:Ie,rehypePlugins:Te,components:Ee,children:Me(s)})});function An(t){if(!t)return"";const s=[];return t.image&&s.push("image/*"),t.file&&s.push(Tn),s.push("audio/*"),s.push("video/*"),s.join(",")}function zn({status:t}){switch(t){case"completed":return e.jsx(bs,{size:14,className:"todo-icon todo-icon-done"});case"in-progress":return e.jsx(ss,{size:14,className:"todo-icon todo-icon-active"});default:return e.jsx(bt,{size:14,className:"todo-icon todo-icon-pending"})}}function On({items:t,onClear:s,loading:n}){const[r,i]=a.useState(!0),d=t.filter(l=>l.status==="completed").length,u=t.length,h=d===u,f=!h&&n;return e.jsxs("div",{className:`todo-bar ${h?"todo-bar-done":""}`,children:[e.jsxs("div",{className:"todo-bar-header",onClick:()=>i(!r),children:[e.jsx(Dt,{size:15,className:"todo-bar-icon"}),e.jsx("span",{className:"todo-bar-title",children:"任务计划"}),e.jsxs("span",{className:"todo-bar-count",children:[d,"/",u]}),e.jsx("div",{className:"todo-bar-progress",children:e.jsx("div",{className:"todo-bar-progress-fill",style:{width:`${u>0?d/u*100:0}%`}})}),e.jsx("button",{className:"todo-bar-toggle",title:r?"收起":"展开",children:r?e.jsx(ws,{size:14}):e.jsx(Ns,{size:14})}),e.jsx("button",{className:"todo-bar-clear",onClick:l=>{l.stopPropagation(),f||s()},disabled:f,title:f?"任务执行中,无法清除":"清除计划",children:e.jsx(Ss,{size:14})})]}),r&&e.jsx("div",{className:"todo-bar-list",children:t.map(l=>e.jsxs("div",{className:`todo-item todo-item-${l.status}`,children:[e.jsx(zn,{status:l.status}),e.jsx("span",{className:"todo-item-title",children:l.title})]},l.id))})]})}const as="aalis:open-lightbox";function gs(t){window.dispatchEvent(new CustomEvent(as,{detail:t}))}const Fn=a.memo(function({msg:s,senderName:n,isLast:r,isGenerating:i,onAbort:d,checkpoint:u,rolledBack:h,onRollback:f,onRollbackWithChat:l,toolCallsProgress:y}){return s.role==="system"?e.jsxs("div",{className:"system-event-separator",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(ys,{size:12})," ",s.content]}),e.jsx("span",{className:"system-event-line"})]}):e.jsxs("div",{className:`message-group ${s.role}`,children:[e.jsxs("div",{className:"message-sender",children:[e.jsx("span",{className:"message-sender-name",children:s.role==="user"?"You":n}),s.timestamp?e.jsx("span",{className:"message-time",title:new Date(s.timestamp).toLocaleString(),children:gn(s.timestamp)}):null,s.role==="assistant"&&s.modelInfo&&(s.modelInfo.model||s.modelInfo.completionTokens!=null)?e.jsxs("span",{className:"message-model-badge",title:[s.modelInfo.provider&&s.modelInfo.model?`${s.modelInfo.provider} / ${s.modelInfo.model}`:s.modelInfo.model,s.modelInfo.completionTokens!=null?`本次生成 ${s.modelInfo.completionTokens} tok`:null,s.modelInfo.promptTokens!=null?`上下文 ${s.modelInfo.promptTokens} tok`:null,s.modelInfo.elapsedMs!=null?`耗时 ${(s.modelInfo.elapsedMs/1e3).toFixed(1)}s`:null].filter(Boolean).join(" · "),children:[s.modelInfo.model??"",s.modelInfo.completionTokens!=null?` · ${(s.modelInfo.completionTokens/1e3).toFixed(1)}k`:"",s.modelInfo.elapsedMs!=null?` · ${(s.modelInfo.elapsedMs/1e3).toFixed(1)}s`:""]}):null]}),s.role==="user"&&s.images&&s.images.length>0&&e.jsx("div",{className:"message-images",children:s.images.map((p,j)=>e.jsx("div",{className:"message-image-wrap",children:e.jsx("img",{src:ke(p),alt:`attached-${j}`,className:"message-image",onClick:()=>gs(ke(p))})},j))}),s.role==="user"&&s.fileNames&&s.fileNames.length>0&&e.jsx("div",{className:"message-files",children:s.fileNames.map((p,j)=>e.jsxs("div",{className:"message-file-item",children:[e.jsx(es,{size:14})," ",p]},j))}),s.role==="assistant"&&s.attachments&&s.attachments.length>0&&e.jsx("div",{className:"message-images",children:s.attachments.map((p,j)=>p.kind==="image"?e.jsx("div",{className:"message-image-wrap",children:e.jsx("img",{src:ke(p.data),alt:p.name??`attachment-${j}`,className:"message-image",onClick:()=>gs(ke(p.data))})},`a-${j}`):p.kind==="video"?e.jsx("video",{controls:!0,src:ke(p.data),className:"message-image"},`a-${j}`):p.kind==="audio"?e.jsx("audio",{controls:!0,src:ke(p.data)},`a-${j}`):e.jsxs("div",{className:"message-file-item",children:[e.jsx(es,{size:14})," ",p.name??"attachment"]},`a-${j}`))}),s.role==="assistant"&&s.segments&&s.segments.length>0?e.jsx("div",{className:"message-bubble",children:(()=>{const p=[];let j=0;for(;j<s.segments.length;){const b=s.segments[j];if(b.type==="reasoning_text"){const c=[];for(;j<s.segments.length&&s.segments[j].type==="reasoning_text";)c.push(s.segments[j]),j++;const S=c.filter(E=>E.type==="reasoning_text").map(E=>E.content).join("");S&&p.push(e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(hs,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx($e,{remarkPlugins:Ie,rehypePlugins:Te,components:Ee,children:Me(S)})})]},`r-${j}`));continue}if(b.type==="text"){b.content&&p.push(e.jsx(Qe,{content:b.content},`t-${j}`)),j++;continue}p.push(e.jsx(Mn,{seg:b,index:j},`tc-${j}`)),j++}return p})()}):s.role==="assistant"&&s.reasoningContent?e.jsxs(e.Fragment,{children:[e.jsxs("details",{className:"thinking-block",children:[e.jsxs("summary",{className:"thinking-summary",children:[e.jsx(hs,{size:14})," 思考过程"]}),e.jsx("div",{className:"thinking-content",children:e.jsx($e,{remarkPlugins:Ie,rehypePlugins:Te,components:Ee,children:Me(s.reasoningContent)})})]}),e.jsx("div",{className:"message-bubble",children:e.jsx(Qe,{content:s.content})})]}):e.jsx("div",{className:"message-bubble",children:s.role==="assistant"?e.jsx(Qe,{content:s.content}):s.content}),s.role==="assistant"&&y&&y.size>0&&e.jsx("div",{className:"tool-call-progress-bubble",children:[...y.entries()].sort((p,j)=>p[0]-j[0]).map(([p,j])=>e.jsx(Ls,{name:j.name,charsAccumulated:j.charsAccumulated,startedAt:j.startedAt},`pending-${p}`))}),r&&i&&s.role==="assistant"&&e.jsx("button",{className:"stop-generate-btn",onClick:d,title:"停止生成",children:"■ 停止生成"}),s.role==="assistant"&&u&&!i&&(h?e.jsxs("span",{className:"checkpoint-rolled-back",children:[e.jsx(Ue,{size:12})," 此次修改已回滚"]}):e.jsxs("div",{className:"checkpoint-rollback-actions",children:[u.fileCount>0&&e.jsxs("button",{className:"checkpoint-rollback-btn",onClick:()=>f==null?void 0:f(u),title:`仅回滚本回合的 ${u.fileCount} 个文件改动(保留对话)${u.execUsed?`
185
- 注意:本回合调用过 exec/shell,命令副作用无法回滚`:""}`,children:[e.jsx(Ue,{size:12})," 回滚文件改动",u.execUsed&&e.jsxs("span",{className:"checkpoint-warn",children:[e.jsx(Oe,{size:11})," exec"]})]}),e.jsxs("button",{className:"checkpoint-rollback-btn",onClick:()=>l==null?void 0:l(u),title:`回滚本轮对话(含 ${u.fileCount} 处文件改动):删除本轮的用户提问、回复和工具调用记录,并恢复文件${u.execUsed?`
186
- 注意:本回合调用过 exec/shell,命令副作用无法回滚`:""}`,children:[e.jsx(Ue,{size:12})," 回滚本轮对话(含文件)",u.execUsed&&e.jsxs("span",{className:"checkpoint-warn",children:[e.jsx(Oe,{size:11})," exec"]})]})]}))]})});function Ls({name:t,charsAccumulated:s,startedAt:n}){const[r,i]=a.useState(Date.now()-n);a.useEffect(()=>{const u=window.setInterval(()=>i(Date.now()-n),100);return()=>window.clearInterval(u)},[n]);const d=(r/1e3).toFixed(1);return e.jsx("div",{className:"tool-call-block tool-call-block-pending","aria-live":"polite",children:e.jsxs("div",{className:"tool-call-summary",children:[e.jsx("span",{className:"tool-call-progress-icon",children:e.jsx(os,{size:14})}),e.jsx("span",{children:t||"正在生成…"}),e.jsxs("span",{className:"tool-call-progress-meta",children:[s," 字符 · ",d,"s"]})]})})}function Wn({messages:t,loading:s,connected:n,status:r,onSend:i,onAbort:d,width:u,sessionTitle:h,onNewSession:f,todoItems:l,onClearTodos:y,toolLimitReached:p,onContinueTools:j,toolCallsProgress:b,tokenUsage:c,compressingStatus:S,onCompress:E,onOpenNav:C}){const O=a.useRef(null),q=a.useRef(null),w=a.useRef(null),V=a.useRef(!1),[K,R]=a.useState([]),[ie,N]=a.useState(new Set),L=a.useRef(s);a.useEffect(()=>{let g=!1;async function D(){try{const F=ae();if(!F||F==="__new_chat__"){g||R([]);return}const Y=await he("@aalis/plugin-checkpoint","listTurns",{sessionId:F});!g&&Array.isArray(Y)&&R(Y)}catch{}}return L.current&&!s?D():t.length===0?R([]):D(),L.current=s,()=>{g=!0}},[s,h,t.length]);const m=a.useMemo(()=>g=>{for(const D of K){const F=D.startedAt-1e3,Y=(D.endedAt??D.startedAt+6e4)+5e3;if(g>=F&&g<=Y)return D}},[K]),x=a.useCallback(async g=>{const D=g.filesPreview.slice(0,3).join(`
187
- `),F=g.fileCount>g.filesPreview.length?`
188
- ... 共 ${g.fileCount} 个文件`:"",Y=g.execUsed?`
189
-
190
- ⚠ 本回合调用过 exec/shell,命令的副作用无法回滚!`:"";if(window.confirm(`将回滚此回合的文件改动:
191
-
192
- ${D}${F}${Y}
193
-
194
- 确定继续?`))try{const de=await he("@aalis/plugin-checkpoint","rollback",{sessionId:ae(),turnId:g.turnId}),ne=`回滚完成:恢复 ${de.restored.length} 个,删除 ${de.deleted.length} 个`;de.errors.length>0?window.alert(`${ne}
195
- 失败 ${de.errors.length} 个(如有新建文件在不可删除的根下,需手动删除):
196
- `+de.errors.map(X=>`${X.uri}: ${X.reason}`).join(`
197
- `)):window.alert(ne),N(X=>new Set([...X,g.turnId]))}catch(de){window.alert(`回滚失败:${de.message}`)}},[]),H=a.useCallback(async g=>{const D=g.filesPreview.slice(0,3).join(`
198
- `),F=g.fileCount>g.filesPreview.length?`
199
- ... 共 ${g.fileCount} 个文件`:"",Y=g.execUsed?`
200
-
201
- ⚠ 本回合调用过 exec/shell,命令的副作用无法回滚!`:"",Ne=g.fileCount>0?`
202
-
203
- 同时恢复以下文件:
204
- ${D}${F}`:"";if(window.confirm(`将回滚本轮对话:
205
-
206
- · 删除本轮的用户提问、AI 回复和工具调用记录
207
- · 清除对应的向量记忆条目${Ne}${Y}
208
-
209
- 此操作不可撤销。确定继续?`))try{const ne=await he("@aalis/plugin-checkpoint","rollbackWithChat",{sessionId:ae(),turnId:g.turnId}),X=[];ne.chatDeleted&&X.push(`删除 ${ne.deletedMessages} 条消息`),g.fileCount>0&&X.push(`恢复 ${ne.restored.length} 个文件,删除 ${ne.deleted.length} 个新建文件`);const Se=X.length>0?`回滚完成:${X.join(";")}`:"回滚完成";ne.errors.length>0&&window.alert(`${Se}
210
- 失败 ${ne.errors.length} 项:
211
- `+ne.errors.map(oe=>`${oe.uri||"(memory)"}: ${oe.reason}`).join(`
212
- `)),N(oe=>new Set([...oe,g.turnId]))}catch(ne){window.alert(`回滚失败:${ne.message}`)}},[]),U=a.useRef(null),Q=a.useRef(!1),[_,M]=a.useState(!1),P=a.useRef(0),[W,J]=a.useState(!1),[Z,Le]=a.useState(!1),[le,ce]=a.useState(null),je=a.useRef(0),ye=a.useRef(0);a.useEffect(()=>{const g=F=>{const Y=F.detail;typeof Y=="string"&&ce(Y)},D=F=>{F.key==="Escape"&&ce(null)};return window.addEventListener(as,g),window.addEventListener("keydown",D),()=>{window.removeEventListener(as,g),window.removeEventListener("keydown",D)}},[]);const re=r==null?void 0:r.uploadCapabilities,ve=(re==null?void 0:re.image)??!1,Re=(re==null?void 0:re.file)??!1,Ce=ve||Re,pe=An(re);a.useEffect(()=>{S==="start"?(je.current=Date.now(),ye.current=0):(S==="done"||S==="error")&&(ye.current=Date.now())},[S]),a.useEffect(()=>{const g=w.current;if(!g)return;const D=()=>{const{scrollTop:F,scrollHeight:Y,clientHeight:Ne}=g;V.current=Y-F-Ne>200,Q.current=!0,U.current&&clearTimeout(U.current),U.current=setTimeout(()=>{Q.current=!1},300)};return g.addEventListener("scroll",D,{passive:!0}),()=>g.removeEventListener("scroll",D)},[]),a.useEffect(()=>{const g=w.current;if(!g)return;const D=new ResizeObserver(()=>{var F;!V.current&&!Q.current&&((F=q.current)==null||F.scrollIntoView({behavior:s?"instant":"smooth"}))});return D.observe(g),()=>D.disconnect()},[t.length]),a.useEffect(()=>{var g;!V.current&&!Q.current&&((g=q.current)==null||g.scrollIntoView({behavior:"smooth"}))},[t]);const De=a.useCallback((g,D,F,Y)=>i(g,D,F,Y),[i]),Pe=g=>{g.preventDefault(),g.stopPropagation(),P.current++,Ce&&g.dataTransfer.types.includes("Files")&&M(!0)},Fe=g=>{g.preventDefault(),g.stopPropagation(),P.current--,P.current<=0&&(P.current=0,M(!1))},We=g=>{g.preventDefault(),g.stopPropagation()},Be=async g=>{var D;g.preventDefault(),g.stopPropagation(),P.current=0,M(!1),!(!Ce||!g.dataTransfer.files.length)&&await((D=O.current)==null?void 0:D.addFiles(g.dataTransfer.files))},me=t[t.length-1],we=(me==null?void 0:me.role)==="assistant"&&s;return e.jsxs("div",{className:`chat-panel${_?" drag-over":""}`,style:{width:u},onDragEnter:Pe,onDragLeave:Fe,onDragOver:We,onDrop:Be,children:[_&&e.jsx("div",{className:"drag-overlay",children:e.jsxs("div",{className:"drag-overlay-content",children:[e.jsx(Cs,{size:16})," 松开以上传文件"]})}),e.jsxs("div",{className:"chat-panel-header",children:[C&&e.jsx("button",{className:"chat-panel-nav-btn",onClick:C,"aria-label":"打开菜单",children:e.jsx(ks,{size:19})}),e.jsxs("span",{className:"chat-panel-title",children:[e.jsx(ze,{size:16})," ",h||(r==null?void 0:r.name)||"Aalis"]}),e.jsxs("div",{className:"chat-panel-header-actions",children:[e.jsxs("div",{className:"token-usage-badge",onMouseEnter:C?void 0:()=>J(!0),onMouseLeave:C?void 0:()=>J(!1),onClick:C?()=>J(g=>!g):void 0,children:[e.jsx(_s,{size:12}),e.jsx("span",{className:`token-usage-number${c&&c.usageRatio>.85?" warn":c&&c.usageRatio>.7?" caution":""}`,children:c?c.used.toLocaleString():"--"}),W&&e.jsxs("div",{className:"token-usage-panel",children:[e.jsx("div",{className:"token-panel-title",children:"Token 使用情况"}),c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"token-panel-bar",children:e.jsx("div",{className:`token-panel-bar-fill${c.usageRatio>.85?" warn":c.usageRatio>.7?" caution":""}`,style:{width:`${Math.min(100,c.usageRatio*100)}%`}})}),e.jsxs("div",{className:"token-panel-ratio",children:[(c.usageRatio*100).toFixed(1),"% 已使用"]}),e.jsxs("div",{className:"token-panel-rows",children:[e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"上下文窗口"}),e.jsx("span",{children:c.contextWindow.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-section-header",children:["系统提示词 ",e.jsx("span",{className:"token-panel-section-total",children:c.breakdown.system.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"人设 / Persona"}),e.jsx("span",{children:c.breakdown.persona.toLocaleString()})]}),c.breakdown.memorySummary>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"对话摘要"}),e.jsx("span",{children:c.breakdown.memorySummary.toLocaleString()})]}),c.breakdown.memoryVector>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"向量记忆"}),e.jsx("span",{children:c.breakdown.memoryVector.toLocaleString()})]}),c.breakdown.skills>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"技能描述"}),e.jsx("span",{children:c.breakdown.skills.toLocaleString()})]}),c.breakdown.platform>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"平台提示"}),e.jsx("span",{children:c.breakdown.platform.toLocaleString()})]}),c.breakdown.subtask>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"子任务上下文"}),e.jsx("span",{children:c.breakdown.subtask.toLocaleString()})]}),c.breakdown.systemOther>0&&e.jsxs("div",{className:"token-panel-row sub",children:[e.jsx("span",{children:"其他系统提示"}),e.jsx("span",{children:c.breakdown.systemOther.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"历史消息"}),e.jsx("span",{children:c.breakdown.history.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"工具结果"}),e.jsx("span",{children:c.breakdown.toolResults.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"工具定义"}),e.jsx("span",{children:c.breakdown.toolDefs.toLocaleString()})]}),e.jsxs("div",{className:"token-panel-row",children:[e.jsx("span",{children:"回复保留量"}),e.jsx("span",{children:c.breakdown.reservedForReply.toLocaleString()})]})]}),E&&e.jsx("button",{className:"token-panel-compress-btn",onClick:g=>{g.stopPropagation(),E()},disabled:S==="start",children:S==="start"?e.jsxs(e.Fragment,{children:[e.jsx(ss,{size:12,className:"compress-spinner"})," 压缩中…"]}):e.jsxs(e.Fragment,{children:[e.jsx(ys,{size:12})," 压缩对话"]})})]}):e.jsx("div",{className:"token-panel-empty",children:"发送消息后将显示 Token 用量统计"})]})]}),f&&e.jsx("button",{className:"chat-panel-new-btn",onClick:f,title:"新对话",children:"+"}),e.jsx("button",{className:"chat-panel-new-btn",onClick:()=>Le(g=>!g),title:"已上传的文件","aria-label":"已上传的文件",children:e.jsx(Et,{size:14})})]})]}),e.jsx(Sn,{open:Z,onClose:()=>Le(!1),sessionId:ae()}),e.jsxs("div",{className:"messages",ref:w,children:[t.length===0&&e.jsxs("div",{className:"empty",children:[e.jsx("div",{className:"empty-icon",children:e.jsx(ze,{size:40})}),"开始和 ",(r==null?void 0:r.name)??"Aalis"," 对话吧"]}),t.map((g,D)=>{const F=D===t.length-1;return e.jsx(Fn,{msg:g,senderName:(r==null?void 0:r.name)??"Aalis",isLast:F,isGenerating:we,onAbort:d,checkpoint:g.role==="assistant"?m(g.timestamp):void 0,rolledBack:g.role==="assistant"?(()=>{const Y=m(g.timestamp);return Y?ie.has(Y.turnId):!1})():!1,onRollback:x,onRollbackWithChat:H,toolCallsProgress:F&&g.role==="assistant"&&we?b:void 0},D)}),s&&(!me||me.role!=="assistant")&&e.jsxs("div",{className:"message-group assistant",children:[e.jsx("div",{className:"message-sender",children:(r==null?void 0:r.name)??"Aalis"}),e.jsx("div",{className:"message-bubble",children:b&&b.size>0?[...b.entries()].sort((g,D)=>g[0]-D[0]).map(([g,D])=>e.jsx(Ls,{name:D.name,charsAccumulated:D.charsAccumulated,startedAt:D.startedAt},`pending-${g}`)):e.jsxs("div",{className:"typing-indicator",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})}),e.jsx("button",{className:"stop-generate-btn",onClick:d,title:"停止生成",children:"■ 停止生成"})]}),p&&!s&&e.jsxs("div",{className:"tool-limit-bar",children:[e.jsx("span",{className:"tool-limit-text",children:"⚠ 工具调用次数已达上限"}),e.jsxs("div",{className:"tool-limit-actions",children:[j&&e.jsx("button",{className:"tool-limit-btn continue",onClick:j,children:"继续迭代"}),e.jsx("span",{className:"tool-limit-hint",children:"或输入新内容引导模型"})]})]}),S==="start"&&e.jsxs("div",{className:"system-event-separator compressing",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(ss,{size:12,className:"compress-spinner"})," 压缩对话中 ",e.jsx(xs,{startTime:je.current})]}),e.jsx("span",{className:"system-event-line"})]}),S==="done"&&e.jsxs("div",{className:"system-event-separator compress-done",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(bs,{size:12})," 已压缩对话 ",e.jsx(xs,{startTime:je.current,endTime:ye.current})]}),e.jsx("span",{className:"system-event-line"})]}),S==="error"&&e.jsxs("div",{className:"system-event-separator compress-error",children:[e.jsx("span",{className:"system-event-line"}),e.jsxs("span",{className:"system-event-text",children:[e.jsx(Oe,{size:12})," 压缩失败"]}),e.jsx("span",{className:"system-event-line"})]}),e.jsx("div",{ref:q})]}),l&&l.length>0&&y&&e.jsx(On,{items:l,onClear:y,loading:s}),e.jsx(_n,{ref:O,loading:s,connected:n,canUpload:Ce,canUploadImage:ve,canUploadFile:Re,acceptAttr:pe,onSend:De,onAbort:d}),le&&e.jsxs("div",{className:"image-lightbox",onClick:()=>ce(null),children:[e.jsx("img",{src:le,alt:"预览",className:"image-lightbox-content",onClick:g=>g.stopPropagation()}),e.jsx("button",{type:"button",className:"image-lightbox-close",onClick:()=>ce(null),"aria-label":"关闭",children:"×"})]})]})}const Bn=a.lazy(()=>fe(()=>import("./PluginConfigPage-Bda8iLH6.js"),__vite__mapDeps([2,1,3,4,5,6,7,8,9])).then(t=>({default:t.PluginConfigPage}))),qn=a.lazy(()=>fe(()=>import("./MarketplacePage-DzmqvEhm.js"),__vite__mapDeps([10,1,4,11,5,6,7,8,9])).then(t=>({default:t.MarketplacePage}))),Vn=a.lazy(()=>fe(()=>import("./PlatformPage-Cl_2WBBf.js"),__vite__mapDeps([12,1,13,5,6,7,8,9])).then(t=>({default:t.PlatformPage}))),Hn=a.lazy(()=>fe(()=>import("./AuthorityPage-moleXD4t.js"),__vite__mapDeps([14,1,11,5,6,7,8,9])).then(t=>({default:t.AuthorityPage}))),Jn=a.lazy(()=>fe(()=>import("./LogPage-BTvnnjEI.js"),__vite__mapDeps([15,1])).then(t=>({default:t.LogPage}))),Gn=a.lazy(()=>fe(()=>import("./SessionsPage-Dmw9u5-k.js"),__vite__mapDeps([16,1,9,7,8,5,6])).then(t=>({default:t.SessionsPage}))),Kn=a.lazy(()=>fe(()=>import("./FilesPage-DUh-AYCa.js"),__vite__mapDeps([17,1,5,6,7,8,9])).then(t=>({default:t.FilesPage}))),Un=a.lazy(()=>fe(()=>import("./DynamicPage-Dmz4Tfnd.js"),__vite__mapDeps([18,1,3,19,20,13,11,9,7,8,5,6])).then(t=>({default:t.DynamicPage}))),js=2e3,rs="(max-width: 768px)";function Yn(){const[t,s]=a.useState(()=>typeof window<"u"&&window.matchMedia(rs).matches);return a.useEffect(()=>{const n=window.matchMedia(rs),r=i=>s(i.matches);return n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}function Xn(){var ls,cs;const[t,s]=a.useState(()=>location.hash.replace("#","")||"dashboard"),n=Yn(),[r,i]=a.useState("chat"),[d,u]=a.useState(!1);a.useEffect(()=>{n||u(!1)},[n]);const[h,f]=a.useState(null),[l,y]=a.useState([]);a.useEffect(()=>{location.hash=t},[t]),a.useEffect(()=>{h&&!h.has(t)&&s("dashboard")},[h,t]);const[p,j]=a.useState([]),[b,c]=a.useState(null),[S,E]=a.useState(null),[C,O]=a.useState(null),[q,w]=a.useState([]),[V,K]=a.useState(null),R=hn(l),{messages:ie,setMessages:N,loading:L,setLoading:m,streamingRef:x}=R,H=a.useRef({pending:[],raf:0}),[U,Q]=a.useState(0),[_,M]=a.useState([]),[P,W]=a.useState(()=>{if(typeof window>"u")return 420;const o=Number(window.localStorage.getItem("aalis:chatWidth"));return Number.isFinite(o)&&o>=280?o:420});a.useEffect(()=>{try{window.localStorage.setItem("aalis:chatWidth",String(P))}catch{}},[P]),a.useEffect(()=>{const o=document.querySelector(".app-layout");if(!o||typeof ResizeObserver>"u")return;const v=360,k=240,T=()=>{var ee;if(window.matchMedia(rs).matches)return;const $=o.clientWidth,z=((ee=document.querySelector(".nav-rail"))==null?void 0:ee.getBoundingClientRect().width)??56,A=Math.max(k,$-z-v);W(G=>Math.min(Math.max(G,k),A))},I=new ResizeObserver(T);return I.observe(o),()=>I.disconnect()},[]);const[J,Z]=a.useState(!1),[Le,le]=a.useState(new Map),[ce,je]=a.useState(!1),[ye,re]=a.useState(!1),[ve,Re]=a.useState(!1),[Ce,pe]=a.useState("正在重启…"),[De,Pe]=a.useState(!1),[Fe,We]=a.useState(null),[Be,me]=a.useState(null),we=(o,v)=>{const k=o?[...o]:[],T=k[k.length-1];return v.type==="text"&&T&&T.type==="text"?k[k.length-1]={type:"text",content:T.content+v.content}:v.type==="reasoning_text"&&T&&T.type==="reasoning_text"?k[k.length-1]={type:"reasoning_text",content:T.content+v.content}:k.push(v),k},g=o=>{let v="",k="";for(const T of o??[])T.type==="text"?v+=T.content:T.type==="reasoning_text"&&(k+=T.content);return{content:v,reasoning:k}},D=a.useCallback((o,v,k,T,I)=>{H.current.raf&&(cancelAnimationFrame(H.current.raf),H.current.raf=0),H.current.pending=[],N($=>{const z=$[$.length-1],A=k&&k.length>0?k:v?[{type:"reasoning_text",content:v},{type:"text",content:o}]:[{type:"text",content:o}];return z&&z.role==="assistant"&&x.current?(x.current=!1,[...$.slice(0,-1),{...z,content:o,reasoningContent:v??z.reasoningContent,segments:A,attachments:T??z.attachments,modelInfo:I??z.modelInfo}]):(x.current=!1,[...$,{role:"assistant",content:o,reasoningContent:v,segments:A,attachments:T,modelInfo:I,timestamp:Date.now()}])}),m(!1)},[]),F=a.useCallback(()=>{const o=H.current;if(o.raf&&(cancelAnimationFrame(o.raf),o.raf=0),o.pending.length===0)return;const v=o.pending;o.pending=[],N(k=>{const T=k[k.length-1];if(T&&T.role==="assistant"&&x.current){let A=T.segments??[];for(const te of v)A=we(A,{type:te.kind==="content"?"text":"reasoning_text",content:te.text});const{content:ee,reasoning:G}=g(A);return[...k.slice(0,-1),{...T,content:ee,reasoningContent:G||void 0,segments:A}]}x.current=!0;let I=[];for(const A of v)I=we(I,{type:A.kind==="content"?"text":"reasoning_text",content:A.text});const{content:$,reasoning:z}=g(I);return[...k,{role:"assistant",content:$,reasoningContent:z||void 0,segments:I,timestamp:Date.now()}]})},[N,x]),Y=a.useCallback((o,v,k,T)=>{if(k){F(),m(!1),Z(!!T),le(new Map);return}(o||v)&&le($=>$.size===0?$:new Map);const I=H.current;v&&I.pending.push({kind:"reasoning",text:v}),o&&I.pending.push({kind:"content",text:o}),!I.raf&&(I.raf=requestAnimationFrame(F))},[F,m]),Ne=a.useCallback(o=>{j(v=>{if(v.length>0&&v[v.length-1].seq>=o.seq&&v.some(T=>T.seq===o.seq))return v;const k=[...v,o];return k.length>js?k.slice(-js):k})},[]),de=a.useCallback(async()=>{const o=p[0];if(!o)return 0;try{const v=await se(`/api/logs/range?before=${o.seq}&limit=200`);return!v||v.length===0?0:(j(k=>{const T=new Set(k.map($=>$.seq));return[...v.filter($=>!T.has($.seq)),...k]}),v.length)}catch{return 0}},[p]),ne=a.useCallback((o,v,k,T)=>{F(),k==="start"&&le(I=>I.size===0?I:new Map),N(I=>{const $=I[I.length-1];if(k==="start"){const z=Date.now();if($&&$.role==="assistant"){const A=we($.segments,{type:"tool_call",name:o,args:v,startTime:z});return[...I.slice(0,-1),{...$,segments:A}]}return x.current=!0,[...I,{role:"assistant",content:"",segments:[{type:"tool_call",name:o,args:v,startTime:z}],timestamp:Date.now()}]}if($&&$.role==="assistant"&&$.segments){const z=Date.now(),A=[...$.segments];for(let ee=A.length-1;ee>=0;ee--){const G=A[ee];if(G.type==="tool_call"&&G.name===o&&G.result==null)return A[ee]={...G,result:T,endTime:z},[...I.slice(0,-1),{...$,segments:A}]}}return I})},[F]),X=a.useCallback(()=>{se("/api/plugins").then(o=>w(o.plugins??[])).catch(()=>{})},[]),Se=a.useCallback(()=>{se("/api/config").then(O).catch(()=>{})},[]),oe=a.useCallback(()=>{se("/api/services").then(o=>K(o.services??null)).catch(()=>{})},[]),be=a.useCallback(()=>{se("/api/pages").then(o=>{y(o),f(new Set(o.map(v=>v.key)))}).catch(()=>{})},[]),Rs=a.useCallback(()=>{X(),oe(),be(),R.refresh(),se("/api/status").then(c).catch(()=>{})},[X,oe,be,R.refresh]),Ds=a.useCallback(()=>{je(!0),re(!1),pe("正在重启…")},[]),Ps=a.useCallback(()=>{Re(!0),pe("正在切换前端,即将刷新…")},[]),As=a.useCallback(()=>{R.refresh(),Q(o=>o+1)},[R.refresh]),zs=a.useCallback(o=>{M(o)},[]),Os=a.useCallback((o,v,k,T,I)=>{N($=>{let z=k&&k.length>0?k:[];z.length===0&&(v&&z.push({type:"reasoning_text",content:v}),o&&z.push({type:"text",content:o}));const A=$[$.length-1];return A&&A.role==="assistant"?[...$.slice(0,-1),{...A,content:o,reasoningContent:v||A.reasoningContent,segments:z}]:[...$,{role:"assistant",content:o,reasoningContent:v||void 0,segments:z,timestamp:Date.now()}]}),T||(x.current=!0,m(!0)),I&&I.length>0?le(new Map(I.map($=>[$.index,{name:$.name,charsAccumulated:$.charsAccumulated,startedAt:$.startedAt}]))):le($=>$.size===0?$:new Map)},[]),Fs=a.useCallback(o=>{le(v=>{const k=new Map(v),T=k.get(o.index);return k.set(o.index,{name:o.name,charsAccumulated:o.charsAccumulated,startedAt:(T==null?void 0:T.startedAt)??Date.now()}),k})},[]),Ws=a.useCallback(()=>{le(o=>o.size===0?o:new Map)},[]),Bs=a.useCallback(o=>{Pe(!0),N(v=>[...v,{role:"assistant",content:o,segments:[{type:"text",content:o}],timestamp:Date.now()}])},[]),qs=a.useCallback(o=>{We(o)},[]),Vs=a.useCallback((o,v)=>{o===ae()&&(me(v),v==="done"?setTimeout(()=>me(null),1500):v==="error"&&setTimeout(()=>me(null),3e3))},[]),{send:_e,sendRaw:Ae,connected:xe}=ln({onMessage:D,onStream:Y,onLog:Ne,onToolCall:ne,onStateChanged:Rs,onRestarting:Ds,onReload:Ps,onSessionsChanged:As,onTodoUpdated:zs,onStreamResume:Os,onConfirm:Bs,onTokenUsage:qs,onCompressing:Vs,onHistoryChanged:R.handleHistoryChanged,onToolCallProgress:Fs,onToolCallProgressClear:Ws}),Hs=a.useCallback(()=>{Ae({type:"compress",sessionId:ae()})},[Ae]);a.useEffect(()=>{ce&&!xe&&(re(!0),pe("等待服务器重启…"))},[ce,xe]),a.useEffect(()=>{if(ce&&ye&&xe){pe("服务器已就绪,即将刷新…");const o=setTimeout(()=>window.location.reload(),800);return()=>clearTimeout(o)}},[ce,ye,xe]),a.useEffect(()=>{if(ve){const o=setTimeout(()=>window.location.reload(),1500);return()=>clearTimeout(o)}},[ve]),a.useEffect(()=>{se("/api/status").then(c).catch(()=>{}),se("/api/auth/status").then(o=>E(o.authed&&o.identity?{identity:o.identity,isOwner:!0}:null)).catch(()=>{}),Se(),X(),oe(),be(),R.refresh(),se("/api/logs/tail?limit=200").then(j).catch(()=>{})},[X,Se,oe,be,R.refresh]),a.useEffect(()=>{const o=R.activeSessionId;if(!o||o==="__new_chat__"){M([]);return}he("@aalis/plugin-todo-list","getTodos",{sessionId:o}).then(v=>M(v??[])).catch(()=>M([]))},[R.activeSessionId]),a.useEffect(()=>{const o=setInterval(()=>{se("/api/status").then(c).catch(()=>{}),X(),oe(),be(),R.refresh()},3e4);return()=>clearInterval(o)},[X,oe,be,R.refresh]);const qe=a.useCallback(()=>{Ae({type:"abort",sessionId:ae()}),m(!1),Z(!1),x.current=!1},[Ae]),Js=a.useCallback(()=>{N(o=>[...o,{role:"user",content:"[请继续执行未完成的工具调用]",timestamp:Date.now()}]),_e("[请继续执行未完成的工具调用]"),Z(!1),m(!0)},[_e]),Gs=a.useCallback(()=>{const o=R.activeSessionId;!o||o==="__new_chat__"||(he("@aalis/plugin-todo-list","clearTodos",{sessionId:o}).catch(()=>{}),M([]))},[R.activeSessionId]),Ks=a.useCallback(async(o,v,k,T)=>{const I=o.trim();if(De){if(!I)return;Pe(!1),N(G=>[...G,{role:"user",content:I,timestamp:Date.now()}]),_e(I);return}if(L&&qe(),!I&&k.length===0&&v.length===0)return;await R.ensureSession();const $=k.length>0?[...k]:void 0,z=[];let A=0,ee=0;if(T.length>0){for(const G of T)if(G==="image"&&A<k.length)z.push({kind:"image",data:k[A++]});else if(G==="file"&&ee<v.length){const te=v[ee++],ge=te.mimeType??"",Ge=ge.startsWith("audio/")?"audio":ge.startsWith("video/")?"video":"file";z.push({kind:Ge,data:te.data,mimeType:ge,name:te.name})}}for(;A<k.length;)z.push({kind:"image",data:k[A++]});for(;ee<v.length;){const G=v[ee++],te=G.mimeType??"",ge=te.startsWith("audio/")?"audio":te.startsWith("video/")?"video":"file";z.push({kind:ge,data:G.data,mimeType:te,name:G.name})}N(G=>[...G,{role:"user",content:I,images:$,fileNames:v.map(te=>te.name),timestamp:Date.now()}]),Z(!1),m(!0),_e(I,z.length>0?z:void 0)},[De,L,_e,qe,R]),Ve={dashboard:e.jsx(en,{}),marketplace:e.jsx(sn,{}),"plugin-config":e.jsx(tn,{}),platforms:e.jsx(an,{}),authority:e.jsx(rn,{}),files:e.jsx(on,{}),logs:e.jsx(nn,{})},Us=e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("path",{d:"M9 3v18M3 9h18"})]}),Ys=(o,v)=>Ve[o]?Ve[o]:v&&v.trimStart().startsWith("<svg")?e.jsx("span",{className:"nav-item-svg",dangerouslySetInnerHTML:{__html:v}}):Us,He=a.useMemo(()=>h?l.filter(o=>h.has(o.key)).map(o=>({key:o.key,label:o.label,pluginDisplayName:o.pluginDisplayName,icon:Ys(o.key,o.icon),order:o.order??99})).sort((o,v)=>o.order-v.order):Object.entries(Ve).map(([o,v],k)=>({key:o,label:o,icon:v,order:(k+1)*10})),[h,l]),Xs=(o,v)=>{switch(o){case"dashboard":return e.jsx(mn,{status:b,connected:xe,plugins:q,servicesData:V,onRefreshServices:oe});case"marketplace":return e.jsx(qn,{plugins:q,onRefresh:X,onRestart:k=>{je(!0),re(!1),pe(k)}});case"plugin-config":return e.jsx(Bn,{plugins:q,config:C,onRefresh:X,onConfigSaved:Se,onRestart:()=>{je(!0),re(!1),pe("正在重启…")}});case"platforms":return e.jsx(Vn,{});case"authority":return e.jsx(Hn,{});case"logs":return e.jsx(Jn,{logs:p,onLoadOlder:de});case"files":return e.jsx(Kn,{});case"sessions":return e.jsx(Gn,{pluginName:v,activeSessionId:R.activeSessionId,onSwitchSession:k=>{R.switchSession(k)},onStartNewChat:()=>R.startNewChat(),refreshSignal:U});default:return null}},ue=l.find(o=>o.key===t),Je=ue!=null&&ue.content?ue:void 0,is=a.useCallback(async()=>{await fetch("/api/auth/logout",{method:"POST"}),window.location.reload()},[]),Zs=o=>{s(o),n&&(i("page"),u(!1))},Qs=o=>n?r==="page"&&t===o:t===o;return e.jsxs("div",{className:`app-layout${n?` mobile mobile-view-${r}`:""}`,children:[n&&r==="page"&&e.jsxs("header",{className:"mobile-topbar",children:[e.jsx("button",{className:"mobile-topbar-btn",onClick:()=>u(!0),"aria-label":"打开菜单",children:e.jsx(ks,{size:20})}),e.jsx("span",{className:"mobile-topbar-title",children:(ls=He.find(o=>o.key===t))==null?void 0:ls.label}),e.jsx("button",{className:"mobile-topbar-btn",onClick:()=>i("chat"),"aria-label":"返回对话",children:e.jsx(ze,{size:19})})]}),n&&d&&e.jsx("div",{className:"nav-backdrop",onClick:()=>u(!1)}),e.jsxs("nav",{className:`nav-rail${d?" drawer-open":""}`,children:[e.jsxs("div",{className:"nav-rail-top",children:[e.jsx("div",{className:"nav-logo",children:"A"}),n&&e.jsxs("button",{className:`nav-item ${r==="chat"?"active":""}`,onClick:()=>{i("chat"),u(!1)},children:[e.jsx("span",{className:"nav-item-icon",children:e.jsx(ze,{size:20})}),e.jsx("span",{className:"nav-item-label",children:"对话"})]}),He.map(o=>e.jsxs("button",{className:`nav-item ${Qs(o.key)?"active":""}`,onClick:()=>Zs(o.key),children:[e.jsx("span",{className:"nav-item-icon",children:o.icon}),e.jsx("span",{className:"nav-item-label",children:o.label})]},o.key))]}),e.jsxs("div",{className:"nav-rail-bottom",children:[n&&S&&e.jsxs("span",{className:"drawer-user",title:`${S.identity.platform}:${S.identity.userId}`,children:[e.jsxs("span",{className:"drawer-user-id",children:[S.identity.platform,":",S.identity.userId]}),S.isOwner&&e.jsx("span",{className:"content-user-level",children:"owner"}),e.jsx("button",{className:"btn-sm",onClick:is,children:"退出"})]}),e.jsx("div",{className:`nav-status ${xe?"online":"offline"}`,title:xe?"已连接":"离线"})]})]}),e.jsxs("main",{className:"content-area",children:[e.jsxs("div",{className:"content-header",children:[e.jsx("span",{className:"content-title",children:(cs=He.find(o=>o.key===t))==null?void 0:cs.label}),S&&e.jsxs("span",{className:"content-user",title:`${S.identity.platform}:${S.identity.userId}`,children:[e.jsxs("span",{style:{fontSize:12,opacity:.7},children:[S.identity.platform,":",S.identity.userId]}),S.isOwner&&e.jsx("span",{className:"content-user-level",children:"owner"}),e.jsx("button",{className:"btn-sm",onClick:is,children:"退出"})]})]}),e.jsx("div",{className:"content-body",children:e.jsxs(a.Suspense,{fallback:e.jsx("div",{className:"empty-hint",style:{padding:24},children:"加载中…"}),children:[Je&&e.jsx(Un,{page:Je}),!Je&&(ue==null?void 0:ue.renderer)&&(Xs(ue.renderer,ue.plugin)||e.jsxs("div",{className:"empty-hint",style:{padding:24},children:["此客户端不支持渲染器「",ue.renderer,"」"]}))]})})]}),!n&&e.jsx("div",{className:"resize-handle",onMouseDown:o=>{var ge;o.preventDefault();const v=o.clientX,k=P,T=((ge=document.querySelector(".app-layout"))==null?void 0:ge.clientWidth)??window.innerWidth,I=document.querySelector(".nav-rail"),$=(I==null?void 0:I.getBoundingClientRect().width)??56,z=360,A=280,ee=Math.max(A,T-$-z);document.body.classList.add("is-dragging-chat");const G=Ge=>{const et=k-(Ge.clientX-v);W(Math.max(A,Math.min(ee,et)))},te=()=>{document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",te),document.body.style.cursor="",document.body.style.userSelect="",document.body.classList.remove("is-dragging-chat")};document.body.style.cursor="col-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",G),document.addEventListener("mouseup",te)}}),e.jsx("div",{className:"chat-column",style:n?void 0:{width:P},children:e.jsx(Wn,{messages:ie,loading:L,connected:xe,status:b,onSend:Ks,onAbort:qe,width:n?void 0:P,onOpenNav:n?()=>u(!0):void 0,sessionTitle:R.isNewChat?"新对话":R.activeSessionTitle,onNewSession:R.pluginName?()=>R.startNewChat():void 0,todoItems:_,onClearTodos:Gs,toolLimitReached:J,onContinueTools:Js,toolCallsProgress:Le,tokenUsage:Fe,compressingStatus:Be,onCompress:Hs})}),(ce||ve)&&e.jsx("div",{className:"restart-overlay",children:e.jsxs("div",{className:"restart-dialog",children:[e.jsx("div",{className:"restart-spinner"}),e.jsx("h3",{children:ve?"切换前端":"正在重启…"}),e.jsx("p",{className:"restart-desc",children:Ce})]})})]})}st.createRoot(document.getElementById("root")).render(e.jsx(Xn,{}));export{hs as B,Ns as C,_t as D,Et as F,Ee as M,Te as R,qt as S,Oe as T,os as W,Ss as X,fe as _,se as a,un as b,B as c,Ie as d,Me as e,Wt as f,It as g,Gt as h,he as p};