@runfusion/fusion 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/bin.js +1122 -356
  2. package/dist/client/assets/{AgentDetailView-DQBjJSPJ.js → AgentDetailView-B20ApPe1.js} +3 -3
  3. package/dist/client/assets/{AgentsView-xm_3NO4M.css → AgentsView-Bkk-uBij.css} +1 -1
  4. package/dist/client/assets/{AgentsView-DlA0yHBg.js → AgentsView-ChN1tgQ0.js} +17 -17
  5. package/dist/client/assets/ChatView-oPMFwmoc.js +1 -0
  6. package/dist/client/assets/{DevServerView-BVixhlF0.js → DevServerView-DQrVLbK5.js} +1 -1
  7. package/dist/client/assets/{DirectoryPicker-tvBgHxa7.js → DirectoryPicker-DVmy6sLM.js} +1 -1
  8. package/dist/client/assets/{DocumentsView-DVw_wT6V.js → DocumentsView-DHEv-Q2a.js} +1 -1
  9. package/dist/client/assets/{InsightsView-G3MZhwSx.js → InsightsView-ByyY7GX7.js} +2 -2
  10. package/dist/client/assets/{MemoryView-Bl9gx2Dw.js → MemoryView-Udiu0u8R.js} +1 -1
  11. package/dist/client/assets/{NodesView-dwVhD4V2.js → NodesView-CupS-GGc.js} +4 -4
  12. package/dist/client/assets/{PiExtensionsManager-CEHp6_Mj.js → PiExtensionsManager-DXs2xI8K.js} +2 -2
  13. package/dist/client/assets/PluginManager-BCpiZf4_.js +1 -0
  14. package/dist/client/assets/{ResearchView-BvlLYC_1.js → ResearchView-BG9Feaeb.js} +1 -1
  15. package/dist/client/assets/ResearchView-BzRdUzNq.css +1 -0
  16. package/dist/client/assets/{RoadmapsView-DdYXssP2.js → RoadmapsView-BTJtmBnF.js} +2 -2
  17. package/dist/client/assets/SettingsModal-DZ_LaEhd.js +31 -0
  18. package/dist/client/assets/{SettingsModal-CriZP5Lp.css → SettingsModal-DcGFm6NR.css} +1 -1
  19. package/dist/client/assets/{SettingsModal-CGWipm3s.js → SettingsModal-eNCZiHa6.js} +1 -1
  20. package/dist/client/assets/{SetupWizardModal-CKsJduYM.js → SetupWizardModal-yf79TN1L.js} +1 -1
  21. package/dist/client/assets/SkillMultiselect-DDHJnrkn.css +1 -0
  22. package/dist/client/assets/SkillMultiselect-DOj5vX4U.js +1 -0
  23. package/dist/client/assets/SkillsView-CgnCnikX.js +1 -0
  24. package/dist/client/assets/{TodoView-ByXJ90yL.js → TodoView-67BMyICY.js} +2 -2
  25. package/dist/client/assets/{folder-open-CxOUgHDf.js → folder-open-D11gjHGK.js} +1 -1
  26. package/dist/client/assets/index-BLn1R7Ob.css +1 -0
  27. package/dist/client/assets/index-CLAHcGnI.js +656 -0
  28. package/dist/client/assets/{list-checks--sf9u9ox.js → list-checks-CBzPc3GA.js} +1 -1
  29. package/dist/client/assets/{star-CF1f2iPu.js → star-BWcRk8nt.js} +1 -1
  30. package/dist/client/assets/{upload-rOBd4OhB.js → upload-91TM4ljC.js} +1 -1
  31. package/dist/client/assets/{users-De-vFat1.js → users-BAsI___L.js} +1 -1
  32. package/dist/client/index.html +2 -2
  33. package/dist/client/theme-data.css +1 -1
  34. package/dist/client/version.json +1 -1
  35. package/dist/extension.js +479 -74
  36. package/dist/pi-claude-cli/package.json +1 -1
  37. package/package.json +1 -1
  38. package/skill/fusion/references/cli-commands.md +14 -0
  39. package/skill/fusion/references/engine-tools.md +1 -0
  40. package/dist/client/assets/ChatView-DK5CmiAk.js +0 -1
  41. package/dist/client/assets/PluginManager-Dx0mcwat.js +0 -1
  42. package/dist/client/assets/ResearchView-BVJFgfat.css +0 -1
  43. package/dist/client/assets/SettingsModal-Bgjg_4CD.js +0 -31
  44. package/dist/client/assets/SkillsView-C4Tz7CxC.js +0 -1
  45. package/dist/client/assets/index-BCz4ye4p.css +0 -1
  46. package/dist/client/assets/index-D7gT6mCr.js +0 -656
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fusion/pi-claude-cli",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Fusion vendored fork: pi coding-agent extension that routes LLM calls through the Claude Code CLI. Forked from rchern/pi-claude-cli (MIT). See UPSTREAM.md.",
5
5
  "license": "MIT",
6
6
  "private": true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runfusion/fusion",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "license": "MIT",
5
5
  "description": "Fusion CLI: HTTP API server, daemon, dashboard launcher, and task tooling for the Fusion AI coding agent.",
6
6
  "homepage": "https://github.com/Runfusion/Fusion#readme",
@@ -40,6 +40,20 @@ fn task logs FN-001 --limit 50 # Limit log lines
40
40
  fn task logs FN-001 --type tool # Filter by log type
41
41
  ```
42
42
 
43
+ ## Research
44
+
45
+ ```bash
46
+ fn research create --query "question" # Create research run
47
+ fn research create --query "question" --wait # Wait for completion
48
+ fn research list # List runs
49
+ fn research ls --status failed --limit 20 # Filter by status
50
+ fn research show RR-001 # Show one run
51
+ fn research export RR-001 --format json # Export to JSON
52
+ fn research export RR-001 --output ./run.md # Export to specific path
53
+ fn research cancel RR-001 # Cancel active run
54
+ fn research retry RR-001 # Retry failed/cancelled run
55
+ ```
56
+
43
57
  ## Mission Management
44
58
 
45
59
  ```bash
@@ -55,4 +55,5 @@ These tools are **not** part of the pi extension's user-invokable `extension.ts`
55
55
 
56
56
  | Tool | Purpose | Parameters |
57
57
  |---|---|---|
58
+ | `fn_identity` | Return loaded soul/instructions/memory summary for this heartbeat tick (must be called first) | none |
58
59
  | `fn_heartbeat_done` | Signal end of heartbeat run with optional summary | `summary?` (string) |
@@ -1 +0,0 @@
1
- import{r as s,j as e}from"./vendor-react-K0fH_qHe.js";import{j as _e,aO as Mt,g as Tt,aP as At,a as $t,aQ as Rt,aR as Pt,aS as Dt,aT as Et,aU as Ft,aV as Lt,s as _t,aW as It,aX as Ot,aY as Ut,h as zt,ae as et,af as tt,S as Ht,_ as Ke,N as Je,ar as Vt,aZ as Bt,B as Ae,ab as st,ac as nt,a_ as Gt,a$ as qt,b0 as Kt,b1 as Jt,b2 as Wt,b3 as Qt,b4 as Yt,b5 as We,i as Xt,u as Qe,l as Zt}from"./index-D7gT6mCr.js";import"./vendor-xterm-DzcZoU0P.js";const Le="kb-chat-active-session";function es(a){const i=a?.toolCalls;if(!Array.isArray(i))return;const r=i.map(l=>{if(!l||typeof l!="object")return null;const c=l,j=typeof c.toolName=="string"?c.toolName:"";if(!j)return null;const N=c.args;return{toolName:j,...N&&typeof N=="object"?{args:N}:{},isError:!!c.isError,result:c.result,status:"completed"}}).filter(l=>l!==null);return r.length>0?r:void 0}function Ye(a){return{id:a.id,sessionId:a.sessionId,role:a.role,content:a.content,thinkingOutput:a.thinkingOutput,toolCalls:es(a.metadata),attachments:a.attachments,createdAt:a.createdAt}}function ts(a){const[i,r]=s.useState([]),[l,c]=s.useState(null),[j,N]=s.useState(!0),[$,w]=s.useState([]),[P,z]=s.useState(!1),[p,F]=s.useState(!1),[C,M]=s.useState(""),[f,x]=s.useState(""),[T,k]=s.useState([]),[H,L]=s.useState(""),[ee,K]=s.useState(""),[_,X]=s.useState(!0),[h,y]=s.useState(new Map),v=s.useRef(null),I=s.useRef(!1),V=s.useRef(""),oe=s.useRef(null),de=s.useRef(i),pe=s.useRef(l),xe=s.useRef(p);de.current=i,pe.current=l,xe.current=p,s.useEffect(()=>{V.current=H},[H]);const ve=s.useRef(new Set),ue=s.useRef(0),je=s.useRef(a);je.current!==a&&(je.current=a,ue.current++),s.useEffect(()=>{const u=ue.current;_e(void 0,a).then(g=>{if(ue.current!==u)return;const m=new Map;for(const R of g)m.set(R.id,R);y(m)}).catch(()=>{})},[a]);const J=s.useCallback(async()=>{N(!0);try{const g=[...(await Mt(a)).sessions].sort((m,R)=>new Date(R.updatedAt).getTime()-new Date(m.updatedAt).getTime());r(g)}catch{}finally{N(!1)}},[a]);s.useEffect(()=>{J()},[J]);const se=s.useRef(()=>{});s.useEffect(()=>{if(j)return;const u=Tt(Le,a);u&&i.find(m=>m.id===u)&&se.current(u)},[j,i,a]);const re=s.useCallback(async(u,g)=>{z(!0);try{const m=await At(u,{limit:50,...g},a),R=m.messages.map(Ye);g?.offset&&g.offset>0?w(O=>[...R,...O]):w(R),X(m.messages.length>=50)}catch{}finally{z(!1)}},[a]),ne=s.useCallback((u,g)=>{v.current&&(v.current.close(),v.current=null);const m=g??i.find(R=>R.id===u);c(m||null),M(""),x(""),k([]),F(!1),X(!0),u?re(u):w([]),u?$t(Le,u,a):Rt(Le,a)},[i,re,a]);se.current=ne;const Se=s.useCallback(async u=>{const g=await Pt(u,a);v.current&&(v.current.close(),v.current=null);const m={id:g.session.id,title:g.session.title,agentId:g.session.agentId,status:g.session.status,modelProvider:g.session.modelProvider,modelId:g.session.modelId,createdAt:g.session.createdAt,updatedAt:g.session.updatedAt};return r(R=>R.some(O=>O.id===m.id)?R:[m,...R]),ne(m.id,m),w([]),m},[a,ne]),he=s.useCallback(async u=>{await Dt(u,{status:"archived"},a),r(g=>g.filter(m=>m.id!==u)),l?.id===u&&(c(null),w([]))},[l,a]),be=s.useCallback(async u=>{l?.id===u&&v.current&&(v.current.close(),v.current=null),await Et(u,a),r(g=>g.filter(m=>m.id!==u)),l?.id===u&&(c(null),w([]))},[l,a]),le=s.useCallback(async()=>{!l||!_||await re(l.id,{offset:$.length})},[l,_,re,$.length]),te=s.useCallback(()=>{l&&(I.current=!0,oe.current?.(),oe.current=null,v.current?.close(),v.current=null,Ft(l.id,a).catch(()=>{}),F(!1),M(""),x(""),k([]))},[l,a]),ce=s.useCallback(()=>{V.current="",L("")},[]),me=s.useCallback((u,g)=>{if(!l)return;if(p){V.current=u,L(u);return}I.current=!1,v.current&&(v.current.close(),v.current=null);const m=`temp-${Date.now()}`,R={id:m,sessionId:l.id,role:"user",content:u,createdAt:new Date().toISOString()};w(S=>[...S,R]),M(""),x(""),k([]),F(!0);let O="",ae="",B=[],W=null,G=null;const q=()=>{W=null,M(O)},D=()=>{G=null,x(ae)},d=()=>{W!==null&&(cancelAnimationFrame(W),W=null),G!==null&&(cancelAnimationFrame(G),G=null)};oe.current=d;const U={onThinking:S=>{ae+=S,G===null&&(G=requestAnimationFrame(D))},onText:S=>{O+=S,W===null&&(W=requestAnimationFrame(q))},onToolStart:S=>{B=[...B,{toolName:S.toolName,args:S.args,isError:!1,status:"running"}],k(B)},onToolEnd:S=>{const b=[...B];for(let Q=b.length-1;Q>=0;Q--){const A=b[Q];if(A?.toolName===S.toolName&&A.status==="running"){b[Q]={...A,status:"completed",isError:S.isError,result:S.result},B=b,k(b);return}}B=[...b,{toolName:S.toolName,isError:S.isError,result:S.result,status:"completed"}],k(B)},onDone:S=>{d();const b={id:S.messageId||`msg-${Date.now()}`,sessionId:l.id,role:"assistant",content:O,thinkingOutput:ae,toolCalls:B.length>0?B:void 0,createdAt:new Date().toISOString()};ve.current.add(b.id),w(A=>[...A,b]),M(""),x(""),k([]),F(!1),v.current=null,setTimeout(()=>{ve.current.delete(b.id)},1e3),J();const Q=V.current.trim();Q&&(V.current="",L(""),me(Q))},onError:S=>{if(d(),w(b=>b.filter(Q=>Q.id!==m)),M(""),x(""),k([]),F(!1),v.current=null,console.error("[useChat] Stream error:",S),!I.current){const b=V.current.trim();b&&(V.current="",L(""),me(b))}}};v.current=Lt(l.id,u,U,g,a)},[l,p,a,J]),we=ee?i.filter(u=>u.title?.toLowerCase().includes(ee.toLowerCase())||u.agentId.toLowerCase().includes(ee.toLowerCase())):i;return s.useEffect(()=>{const u=ue.current,g=a?`?projectId=${encodeURIComponent(a)}`:"",m=()=>ue.current!==u,R=q=>{if(m())return;const D=JSON.parse(q.data);r(d=>d.some(U=>U.id===D.id)?d:[D,...d])},O=q=>{if(m())return;const D=JSON.parse(q.data);r(d=>[...d.map(S=>S.id===D.id?D:S)]),pe.current?.id===D.id&&c(D)},ae=q=>{if(m())return;const{id:D}=JSON.parse(q.data);r(d=>d.filter(U=>U.id!==D)),pe.current?.id===D&&(c(null),w([]))},B=q=>{if(m())return;const D=JSON.parse(q.data),d=Ye(D);ve.current.has(d.id)||pe.current?.id===d.sessionId&&!xe.current&&w(U=>U.some(S=>S.id===d.id)?U:[...U,d])},W=q=>{if(m())return;const{id:D}=JSON.parse(q.data);w(d=>d.filter(U=>U.id!==D))};return _t(`/api/events${g}`,{events:{"chat:session:created":R,"chat:session:updated":O,"chat:session:deleted":ae,"chat:message:added":B,"chat:message:deleted":W}})},[a]),s.useEffect(()=>()=>{v.current&&(v.current.close(),v.current=null)},[]),{sessions:i,activeSession:l,sessionsLoading:j,messages:$,messagesLoading:P,isStreaming:p,streamingText:C,streamingThinking:f,streamingToolCalls:T,pendingMessage:H,selectSession:ne,createSession:Se,archiveSession:he,deleteSession:be,sendMessage:me,stopStreaming:te,clearPendingMessage:ce,loadMoreMessages:le,hasMoreMessages:_,searchQuery:ee,setSearchQuery:K,filteredSessions:we,refreshSessions:J,agentsMap:h}}function at(a){const i=new Date(a),l=new Date().getTime()-i.getTime(),c=Math.floor(l/1e3),j=Math.floor(c/60),N=Math.floor(j/60),$=Math.floor(N/24);return c<60?"just now":j<60?`${j}m ago`:N<24?`${N}h ago`:$<7?`${$}d ago`:i.toLocaleDateString()}function Xe(a,i){if(!a||!i)return null;const r=i.toLowerCase();if(r.includes("claude")){let c=i.replace(/^claude[- ]/i,"Claude ").replace(/sonnet[- ](\d+)[- ](\d+)/i,"Sonnet $1.$2").replace(/sonnet[- ](\d+)/i,"Sonnet $1").replace(/haiku[- ](\d+)/i,"Haiku $1").replace(/opus[- ](\d+)/i,"Opus $1").replace(/sonnet/i,"Sonnet").replace(/haiku/i,"Haiku").replace(/opus/i,"Opus").replace(/-/g," ").trim();return c=c.replace(/\s+/g," "),c.length>30?c.slice(0,30)+"…":c}if(r.includes("gpt")||r.includes("openai")){const c=i.replace(/^gpt-4-turbo$/i,"GPT-4 Turbo").replace(/^gpt-4o-mini$/i,"GPT-4o Mini").replace(/^gpt-4o$/i,"GPT-4o").replace(/^gpt-4$/i,"GPT-4").replace(/^gpt-o1-preview$/i,"GPT-o1 Preview").replace(/^gpt-o1-mini$/i,"GPT-o1 Mini").replace(/^gpt-o1$/i,"GPT-o1").replace(/^gpt/i,"GPT").trim();return c.length>30?c.slice(0,30)+"…":c}if(r.includes("gemini")){const c=i.replace(/^gemini[- ]/i,"Gemini ").replace(/pro[- ](\d+)[- ](\d+)/i,"Pro $1.$2").replace(/pro[- ](\d+)/i,"Pro $1").replace(/-/g," ").replace(/\s+/g," ").trim();return c.length>30?c.slice(0,30)+"…":c}const l=i.replace(/-/g," ").replace(/^\w/,c=>c.toUpperCase()).replace(/\s+/g," ").trim();return l.length>30?l.slice(0,30)+"…":l}function Me(a,i){return a.length<=i?a:`${a.slice(0,i)}…`}function ss(a){if(!a)return null;const i=Object.entries(a);return i.length===0?null:i.map(([r,l])=>{const c=typeof l=="string"?l:(()=>{try{return JSON.stringify(l)}catch{return String(l)}})();return`${r}=${Me(c,50)}`}).join(", ")}function ns(a){if(a===void 0)return null;if(typeof a=="string")return Me(a,200);try{return Me(JSON.stringify(a),200)}catch{return Me(String(a),200)}}function it(a){if(!a||a.length===0)return null;const i=(p,F)=>{const C=p.status==="running",M=p.status==="completed"&&p.isError,f=ss(p.args),x=ns(p.result),T=C?f:x?`result: ${x}`:f?`args: ${f}`:null,k=C?"running":M?"error":"completed";return e.jsxs("details",{className:`chat-tool-call${C?" chat-tool-call--running":""}${M?" chat-tool-call--error":""}`,open:C,children:[e.jsxs("summary",{children:[e.jsx("span",{className:"chat-tool-call-status-dot","aria-hidden":"true"}),e.jsx("span",{className:"chat-tool-call-name",children:p.toolName}),T&&e.jsx("span",{className:"chat-tool-call-preview",title:T,children:T}),e.jsx("span",{className:"chat-tool-call-status-text",children:k})]}),e.jsxs("div",{className:"chat-tool-call-content",children:[f&&e.jsxs("div",{className:"chat-tool-call-row",children:[e.jsx("span",{className:"chat-tool-call-label",children:"args"}),e.jsx("span",{className:"chat-tool-call-value",children:f})]}),x&&e.jsxs("div",{className:`chat-tool-call-row${M?" chat-tool-call-row--error":""}`,children:[e.jsx("span",{className:"chat-tool-call-label",children:"result"}),e.jsx("span",{className:"chat-tool-call-value",children:x})]})]})]},`${p.toolName}-${F}`)},r="chat-tool-calls";if(a.length===1)return e.jsxs("div",{className:r,"data-testid":"chat-tool-calls",children:[e.jsxs("div",{className:"chat-tool-calls-header",children:[e.jsx(We,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:"Tool calls"})]}),i(a[0],0)]});const l=a.filter(p=>p.status==="running").length,c=a.filter(p=>p.status==="completed"&&p.isError).length,j=l>0,N=Array.from(new Set(a.map(p=>p.toolName))),$=N.slice(0,5),w=Math.max(0,N.length-$.length),P=w>0?`${$.join(", ")}, +${w} more`:$.join(", "),z=j?`(${l} running)`:c>0?`(${c} ${c===1?"error":"errors"})`:null;return e.jsx("div",{className:r,"data-testid":"chat-tool-calls",children:e.jsxs("details",{className:"chat-tool-calls-group","data-testid":"chat-tool-calls-group",open:j,children:[e.jsxs("summary",{className:"chat-tool-calls-group-summary",children:[e.jsx(We,{size:12,"aria-hidden":"true"}),e.jsxs("span",{children:[a.length," tool calls"]}),e.jsx("span",{className:"chat-tool-calls-names",title:P,children:P}),z&&e.jsx("span",{className:"chat-tool-calls-group-status",children:z})]}),a.map((p,F)=>i(p,F))]})})}const rt={pre:({children:a,...i})=>e.jsx("pre",{...i,className:"chat-markdown-pre",children:a}),table:({children:a,...i})=>e.jsx("table",{...i,className:"chat-markdown-table",children:a})},Te="__fn_agent__",as=["image/png","image/jpeg","image/gif","image/webp","text/plain","application/json","text/yaml","text/markdown","text/csv","application/xml","text/x-log"];function Ze(a){const i=/(^|[\s])\/([^\s]*)$/.exec(a);if(!i)return null;const r=i[1]??"",l=i[2]??"",c=i.index+r.length;return{filter:l,start:c,end:a.length}}function is(a,i){const r=a.slice(0,i),l=/(^|[\s\n])@([\w-]*)$/.exec(r);if(!l)return null;const c=l[2]??"",j=r.length-c.length-1;return{filter:c,start:j,end:i}}function rs({projectId:a,onClose:i,onCreate:r}){const[l,c]=s.useState("agent"),[j,N]=s.useState([]),[$,w]=s.useState(!0),[P,z]=s.useState(""),[p,F]=s.useState([]),[C,M]=s.useState(!0),[f,x]=s.useState(""),[T,k]=s.useState([]),[H,L]=s.useState([]);s.useEffect(()=>{let h=!1;return w(!0),_e(void 0,a).then(y=>{h||N(y)}).catch(()=>{h||N([])}).finally(()=>{h||w(!1)}),()=>{h=!0}},[a]),s.useEffect(()=>{M(!0),Xt().then(h=>{F(h.models),k(h.favoriteProviders),L(h.favoriteModels)}).catch(()=>{F([]),k([]),L([])}).finally(()=>{M(!1)})},[]);const ee=s.useCallback(async h=>{const y=T,I=y.includes(h)?y.filter(V=>V!==h):[h,...y];k(I);try{await Qe({favoriteProviders:I,favoriteModels:H})}catch{k(y)}},[T,H]),K=s.useCallback(async h=>{const y=H,I=y.includes(h)?y.filter(V=>V!==h):[h,...y];L(I);try{await Qe({favoriteProviders:T,favoriteModels:I})}catch{L(y)}},[H,T]),_=h=>{if(h.preventDefault(),l==="agent"){if(!P)return;r({agentId:P});return}if(!f)return;const y=f.indexOf("/");if(y<=0)return;const v=f.slice(0,y),I=f.slice(y+1);r({agentId:Te,modelProvider:v,modelId:I})},X=l==="agent"?!P:!f;return e.jsx("div",{className:"chat-new-dialog-backdrop",onClick:i,role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:"chat-new-dialog",onClick:h=>h.stopPropagation(),children:[e.jsx("h3",{children:"New Chat"}),e.jsxs("div",{className:"chat-new-dialog-mode-toggle","data-testid":"chat-new-dialog-mode-toggle",children:[e.jsx("button",{type:"button",className:`chat-new-dialog-mode-btn${l==="agent"?" chat-new-dialog-mode-btn--active":""}`,"data-testid":"chat-new-dialog-mode-agent",onClick:()=>{c("agent"),x("")},children:"Agent"}),e.jsx("button",{type:"button",className:`chat-new-dialog-mode-btn${l==="model"?" chat-new-dialog-mode-btn--active":""}`,"data-testid":"chat-new-dialog-mode-model",onClick:()=>{c("model"),z("")},children:"Model"})]}),e.jsxs("form",{onSubmit:_,children:[l==="agent"&&e.jsxs("label",{className:"chat-new-dialog-model-label",children:["Agent",$?e.jsx("div",{className:"chat-new-dialog-loading",children:"Loading agents..."}):j.length===0?e.jsx("div",{className:"chat-new-dialog-empty",children:"No agents available"}):e.jsx("div",{className:"chat-new-dialog-agent-list",children:j.map(h=>e.jsxs("button",{type:"button",className:`chat-new-dialog-agent-item${P===h.id?" chat-new-dialog-agent-item--selected":""}`,onClick:()=>z(h.id),"data-testid":`agent-option-${h.id}`,children:[e.jsx(Ae,{size:16}),e.jsx("span",{className:"chat-new-dialog-agent-name",children:h.name}),e.jsx("span",{className:"chat-new-dialog-agent-role",children:h.role})]},h.id))})]}),l==="model"&&e.jsx("div",{className:"chat-new-dialog-model-dropdown","data-testid":"chat-new-dialog-model-section",children:C?e.jsx("div",{className:"chat-new-dialog-loading",children:"Loading models..."}):e.jsx(Zt,{models:p,value:f,onChange:x,label:"Model",placeholder:"Select a model",favoriteProviders:T,onToggleFavorite:ee,favoriteModels:H,onToggleModelFavorite:K})}),e.jsxs("div",{className:"chat-new-dialog-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:i,children:"Cancel"}),e.jsx("button",{type:"submit",className:"btn btn-sm btn-primary",disabled:X,children:"Create"})]})]})]})})}const ls=s.memo(function({message:i,forcePlain:r,agentName:l,showAssistantModelTag:c,activeModelTag:j,activeSessionId:N,mentionAgentsByName:$,onToggleRender:w}){const P=i.role==="assistant",z=s.useMemo(()=>{if(P)return null;const C=i.content,M=/@([\w-]+)/g,f=[];let x=0,T=M.exec(C);for(;T;){const[k,H=""]=T,L=T.index;L>x&&f.push(C.slice(x,L));const ee=H.replace(/_/g," ").toLowerCase(),K=$.get(ee);K?f.push(e.jsxs("span",{className:"chat-mention-chip",children:["@",K.name.replace(/\s+/g,"_")]},`${K.id}-${L}`)):f.push(k),x=L+k.length,T=M.exec(C)}return x<C.length&&f.push(C.slice(x)),f.length===0?C:f},[P,i.content,$]),p=s.useMemo(()=>{const C=i.attachments;if(!C||C.length===0||!N)return null;const M=`/api/chat/sessions/${encodeURIComponent(N)}/attachments/`;return e.jsx("div",{className:"chat-message-attachments",children:C.map(f=>{const x=f.mimeType.startsWith("image/"),T=f.id||f.filename,k=`${M}${encodeURIComponent(f.filename)}`;return x?e.jsx("a",{className:"chat-message-attachment-link","data-testid":"chat-message-attachment",href:k,target:"_blank",rel:"noopener noreferrer",children:e.jsx("img",{className:"chat-message-attachment",src:k,alt:f.originalName})},T):e.jsxs("a",{className:"chat-message-attachment-file","data-testid":"chat-message-attachment",href:k,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Yt,{size:14}),e.jsx("span",{children:f.originalName})]},T)})})},[i.attachments,N]),F=s.useMemo(()=>P?r?e.jsx("div",{className:"chat-message-content chat-message-content--plain",children:i.content}):e.jsx("div",{className:"chat-message-content chat-message-content--markdown",children:e.jsx(et,{remarkPlugins:[tt],components:rt,children:i.content})}):null,[P,r,i.content]);return e.jsxs("div",{className:`chat-message chat-message--${i.role}`,"data-testid":`chat-message-${i.id}`,children:[P&&e.jsxs("div",{className:"chat-message-avatar",children:[e.jsx(Ae,{size:14}),e.jsx("span",{children:l}),c&&j&&e.jsx("span",{className:"chat-model-tag",children:j}),e.jsx("button",{type:"button",className:`chat-message-render-toggle${r?" chat-message-render-toggle--plain":""}`,"data-testid":"chat-message-render-toggle","aria-label":r?"Show rendered markdown":"Show plain text",onClick:()=>w(i.id),children:r?e.jsx(st,{size:14}):e.jsx(nt,{size:14})})]}),P?F:e.jsx("div",{className:"chat-message-content",children:z}),it(i.toolCalls),i.thinkingOutput&&e.jsxs("details",{className:"chat-message-thinking",children:[e.jsx("summary",{children:"Thinking"}),e.jsx("pre",{className:"chat-message-thinking-content",children:i.thinkingOutput})]}),p,e.jsx("div",{className:"chat-message-time",children:at(i.createdAt)})]})});function ms({projectId:a,addToast:i}){const{activeSession:r,sessionsLoading:l,messages:c,messagesLoading:j,isStreaming:N,streamingText:$,streamingThinking:w,streamingToolCalls:P,selectSession:z,createSession:p,archiveSession:F,deleteSession:C,sendMessage:M,stopStreaming:f,pendingMessage:x,clearPendingMessage:T,searchQuery:k,setSearchQuery:H,filteredSessions:L}=ts(a),[ee,K]=s.useState(!1),[_,X]=s.useState(""),[h,y]=s.useState(null),[v,I]=s.useState(null),[V,oe]=s.useState(!0),[de,pe]=s.useState(new Map),[xe,ve]=s.useState([]),[ue,je]=s.useState(!0),[J,se]=s.useState(!1),[re,ne]=s.useState(""),[Se,he]=s.useState(0),[be,le]=s.useState(""),[te,ce]=s.useState(!1),[me,we]=s.useState(0),[u,g]=s.useState(-1),[m,R]=s.useState(()=>new Set),[O,ae]=s.useState([]),[B,W]=s.useState(!1),[,G]=s.useState(!1),[q,D]=s.useState({top:0,left:0}),d=It({projectId:a}),U=s.useCallback(t=>{if(!t||!d.mentionActive)return;const n=t.getBoundingClientRect();D({top:n.top-260,left:n.left+8})},[d.mentionActive]),S=s.useRef(null),b=s.useRef(null),Q=s.useRef(null),A=s.useRef(null),Ie=s.useRef(null),Oe=s.useRef([]),Ne=s.useRef(0),ge=Ot()==="mobile",{keyboardOverlap:$e,viewportHeight:Ue,keyboardOpen:lt}=Ut({enabled:ge&&!!r}),ct=lt?{"--keyboard-overlap":`${$e}px`,...Ue!==null?{"--vv-height":`${Ue}px`}:{}}:{},Z=s.useMemo(()=>{const t=re.trim().toLowerCase();return(t?xe.filter(o=>o.name.toLowerCase().includes(t)):xe).slice(0,10)},[xe,re]),ke=s.useMemo(()=>Array.from(de.values()),[de]),fe=s.useMemo(()=>{const t=be.trim().toLowerCase();return t?ke.filter(n=>n.name.toLowerCase().includes(t)):ke},[ke,be]),ot=s.useMemo(()=>{const t=new Map;for(const n of ke)t.set(n.name.toLowerCase(),n);return t},[ke]);s.useEffect(()=>{he(0)},[Z]),s.useEffect(()=>{we(0)},[be,te]),s.useEffect(()=>()=>{b.current!==null&&window.clearTimeout(b.current)},[]),s.useEffect(()=>{S.current?.scrollIntoView({behavior:"smooth"})},[c,$]),s.useEffect(()=>{if($e<=0)return;const t=Q.current;t&&(t.scrollTop=t.scrollHeight)},[$e]),s.useEffect(()=>{const t=()=>y(null);if(h)return document.addEventListener("click",t),()=>document.removeEventListener("click",t)},[h]),s.useEffect(()=>{let t=!1;const n=a;return _e(void 0,a).then(o=>{if(t||n!==a)return;const E=new Map;for(const Y of o)E.set(Y.id,Y);pe(E)}).catch(()=>{}),()=>{t=!0}},[a]),s.useEffect(()=>{let t=!1;return je(!0),zt(a).then(n=>{t||ve(n)}).catch(()=>{t||ve([])}).finally(()=>{t||je(!1)}),()=>{t=!0}},[a]),s.useEffect(()=>{Oe.current=O},[O]),s.useEffect(()=>()=>{for(const t of Oe.current)t.previewUrl&&URL.revokeObjectURL(t.previewUrl)},[]);const ye=s.useCallback(t=>{if(!t||t.length===0)return;const n=[];for(const o of Array.from(t)){if(!as.includes(o.type))continue;const E=o.type.startsWith("image/");n.push({file:o,previewUrl:E?URL.createObjectURL(o):""})}n.length>0&&ae(o=>[...o,...n])},[]),dt=s.useCallback(t=>{ae(n=>{const o=n[t];return o?.previewUrl&&URL.revokeObjectURL(o.previewUrl),n.filter((E,Y)=>Y!==t)})},[]),ut=s.useCallback(t=>{const n=t.clipboardData?.files;if(!n||n.length===0)return;const o=Array.from(n).filter(E=>E.type.startsWith("image/"));o.length!==0&&ye(o)},[ye]),ht=s.useCallback(async t=>{try{await p(t),K(!1),ge&&oe(!1)}catch{i("Failed to create chat session","error")}},[p,i,ge]),Re=s.useCallback(()=>{const t=_.trim(),n=O.map(o=>o.file);!t&&n.length===0||!r||(X(""),se(!1),ne(""),ce(!1),le(""),g(-1),M(t,n),ae(o=>{for(const E of o)E.previewUrl&&URL.revokeObjectURL(E.previewUrl);return[]}))},[_,O,r,M]),Pe=s.useCallback(t=>{X(n=>{const o=Ze(n);if(!o)return n;const E=`/skill:${t.name} `,Y=n.slice(0,o.start)+E+n.slice(o.end);return window.requestAnimationFrame(()=>{A.current&&(A.current.style.height="auto",A.current.style.height=`${Math.min(A.current.scrollHeight,120)}px`,A.current.focus())}),Y}),se(!1),ne(""),he(0)},[]),De=s.useCallback(t=>{const n=A.current;if(!n||u<0)return;const o=n.selectionStart??Ne.current,E=n.selectionEnd??o,Y=Math.max(o,E),Be=Math.min(u,Y),Ge=`${`@${t.name.replace(/\s+/g,"_")}`} `,Ct=_.slice(0,Be)+Ge+_.slice(Y),qe=Be+Ge.length;X(Ct),ce(!1),le(""),we(0),g(-1),window.requestAnimationFrame(()=>{A.current&&(A.current.style.height="auto",A.current.style.height=`${Math.min(A.current.scrollHeight,120)}px`,A.current.focus(),A.current.setSelectionRange(qe,qe))})},[u,_]),mt=s.useCallback(t=>{if(Ne.current=t.currentTarget.selectionStart??Ne.current,d.mentionActive&&d.files.length>0){if(d.handleKeyDown(t,_),t.key==="Enter"||t.key==="Tab"){const n=d.files[d.selectedIndex];if(n){const o=d.selectFile(n,_);X(o),d.dismissMention(),G(!1)}}return}if(te&&t.key==="ArrowDown"){t.preventDefault(),fe.length>0&&we(n=>(n+1)%fe.length);return}if(te&&t.key==="ArrowUp"){t.preventDefault(),fe.length>0&&we(n=>n===0?fe.length-1:n-1);return}if(te&&t.key==="Enter"){t.preventDefault();const n=fe[me]??fe[0];n&&De(n);return}if(te&&t.key==="Escape"){t.preventDefault(),ce(!1),le(""),g(-1);return}if(J&&t.key==="ArrowDown"){t.preventDefault(),Z.length>0&&he(n=>(n+1)%Z.length);return}if(J&&t.key==="ArrowUp"){t.preventDefault(),Z.length>0&&he(n=>n===0?Z.length-1:n-1);return}if(J&&(t.key==="Enter"||t.key==="Tab")&&Z.length>0){t.preventDefault();const n=Z[Se]??Z[0];n&&Pe(n);return}if(J&&t.key==="Escape"){t.preventDefault(),se(!1);return}t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),Re())},[te,fe,me,De,J,Z,Se,Pe,Re,d,_]),Ce=s.useCallback((t,n)=>{const o=is(t,n);if(o){ce(!0),le(o.filter),g(o.start);return}ce(!1),le(""),g(-1)},[]),gt=s.useCallback(t=>{const n=t.target,o=n.value,E=n.selectionStart??o.length;Ne.current=E,X(o);const Y=Ze(o);Y?(se(!0),ne(Y.filter)):(se(!1),ne("")),Ce(o,E),d.detectMention(o,E),G(d.mentionActive),d.mentionActive&&U(n),n.style.height="auto",n.style.height=`${Math.min(n.scrollHeight,120)}px`},[Ce]),Ee=s.useCallback(t=>{const n=t.currentTarget,o=n.selectionStart??n.value.length;Ne.current=o,Ce(n.value,o),d.detectMention(n.value,o),G(d.mentionActive),d.mentionActive&&U(n)},[Ce,d,U]),ft=s.useCallback(t=>{t.key!=="Escape"&&Ee(t)},[Ee]),pt=s.useCallback(()=>{b.current!==null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{se(!1),ce(!1),le(""),g(-1),G(!1),d.dismissMention(),b.current=null},120)},[d]),xt=s.useCallback(()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null)},[]),vt=s.useCallback(async t=>{y(null);try{await F(t),i("Conversation archived","success")}catch{i("Failed to archive conversation","error")}},[F,i]),St=s.useCallback(async t=>{I(null),y(null);try{await C(t),i("Conversation deleted","success")}catch{i("Failed to delete conversation","error")}},[C,i]),bt=s.useCallback(t=>{z(t),ge&&oe(!1)},[z,ge]),wt=s.useCallback(()=>{z(""),oe(!0)},[z]),kt=()=>e.jsxs("div",{className:"chat-empty-state",children:[e.jsx(Qt,{size:48,strokeWidth:1.5}),e.jsx("h2",{children:"Start a new conversation"}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>K(!0),children:[e.jsx(Je,{size:16}),"New Chat"]})]}),ie=Xe(r?.modelProvider,r?.modelId),ze=r?.agentId===Te?ie??"Fusion":r?.title||de.get(r?.agentId??"")?.name||r?.agentId||"Chat",jt=!!(ie&&ie!==ze),Fe=de.get(r?.agentId??"")?.name||(r?.agentId===Te?ie??"Fusion":r?.agentId?.slice(0,30)??"Fusion"),He=!!(ie&&ie!==Fe),Nt=x.length>50?`${x.slice(0,50)}…`:x,Ve=s.useCallback(t=>{R(n=>{const o=new Set(n);return o.has(t)?o.delete(t):o.add(t),o})},[]),yt=s.useCallback((t,n=!1)=>n?e.jsx("div",{className:"chat-message-content chat-message-content--plain",children:t}):e.jsx("div",{className:"chat-message-content chat-message-content--markdown",children:e.jsx(et,{remarkPlugins:[tt],components:rt,children:t})}),[]);return e.jsxs("div",{className:"chat-view",children:[e.jsxs("div",{className:`chat-sidebar${V?"":" chat-sidebar--hidden"}`,children:[e.jsx("div",{className:"chat-sidebar-search",children:e.jsxs("div",{className:"chat-sidebar-search-wrapper",children:[e.jsx(Ht,{size:14,className:"chat-sidebar-search-icon"}),e.jsx("input",{type:"text",className:"chat-sidebar-search",placeholder:"Search conversations...",value:k,onChange:t=>H(t.target.value),"data-testid":"chat-search-input"})]})}),e.jsx("div",{className:"chat-session-list chat-sidebar-list",children:l?e.jsx("div",{style:{padding:"12px",color:"var(--text-secondary)",fontSize:"13px"},children:"Loading..."}):L.length===0?e.jsx("div",{style:{padding:"12px",color:"var(--text-secondary)",fontSize:"13px"},children:"No conversations yet"}):L.map(t=>e.jsxs("div",{className:`chat-session-item${r?.id===t.id?" chat-session-item--active":""}`,onClick:()=>bt(t.id),onContextMenu:n=>{n.preventDefault(),y({sessionId:t.id,x:n.clientX,y:n.clientY})},"data-testid":`chat-session-${t.id}`,children:[e.jsx("button",{className:"chat-session-delete-btn",onClick:n=>{n.stopPropagation(),I(t.id)},"data-testid":"chat-session-delete-btn","aria-label":"Delete conversation",children:e.jsx(Ke,{size:14})}),e.jsx("div",{className:"chat-session-title",children:t.title||"Untitled"}),e.jsx("div",{className:"chat-session-preview",children:t.lastMessagePreview||"No messages"}),e.jsxs("div",{className:"chat-session-meta",children:[e.jsx("span",{children:de.get(t.agentId)?.name||(t.agentId===Te?Xe(t.modelProvider,t.modelId)??"Fusion":t.agentId.slice(0,30))}),e.jsx("span",{children:t.updatedAt?at(t.updatedAt):""})]})]},t.id))}),e.jsx("div",{className:"chat-sidebar-footer",children:e.jsxs("button",{className:"btn btn-sm btn-primary chat-sidebar-footer-btn",onClick:()=>K(!0),"data-testid":"chat-new-btn",children:[e.jsx(Je,{size:14}),"New Chat"]})})]}),h&&e.jsxs("div",{className:"chat-session-context-menu",style:{top:h.y,left:h.x},onClick:t=>t.stopPropagation(),children:[e.jsxs("button",{onClick:()=>vt(h.sessionId),"data-testid":"chat-context-archive",children:[e.jsx(Vt,{size:14}),"Archive"]}),e.jsxs("button",{onClick:()=>{y(null),I(h.sessionId)},"data-testid":"chat-context-delete",children:[e.jsx(Ke,{size:14}),"Delete"]})]}),v&&e.jsx("div",{className:"chat-new-dialog-backdrop",onClick:()=>I(null),children:e.jsxs("div",{className:"chat-new-dialog",onClick:t=>t.stopPropagation(),children:[e.jsx("h3",{children:"Delete Conversation?"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--text-secondary)",marginBottom:"16px"},children:"This action cannot be undone. All messages in this conversation will be permanently deleted."}),e.jsxs("div",{className:"chat-new-dialog-actions",children:[e.jsx("button",{className:"btn btn-sm",onClick:()=>I(null),children:"Cancel"}),e.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>void St(v),children:"Delete"})]})]})}),e.jsxs("div",{className:"chat-thread",style:ct,children:[(r||!ge)&&e.jsxs("div",{className:"chat-thread-header",children:[ge&&r&&e.jsx("button",{className:"btn-icon",onClick:wt,"data-testid":"chat-back-btn",children:e.jsx(Bt,{size:16})}),e.jsx(Ae,{size:16}),e.jsx("span",{className:"chat-thread-header-title",children:ze}),jt&&e.jsx("span",{className:"chat-model-tag",children:ie})]}),e.jsxs("div",{className:"chat-messages",ref:Q,children:[j?e.jsx("div",{style:{color:"var(--text-secondary)",fontSize:"13px"},children:"Loading messages..."}):c.length===0&&!r?kt():c.length===0&&r?e.jsx("div",{style:{color:"var(--text-secondary)",fontSize:"13px"},children:"No messages yet. Start the conversation!"}):e.jsxs(e.Fragment,{children:[c.map(t=>e.jsx(ls,{message:t,forcePlain:m.has(t.id),agentName:Fe,showAssistantModelTag:He,activeModelTag:ie,activeSessionId:r?.id??null,mentionAgentsByName:ot,onToggleRender:Ve},t.id)),N&&e.jsxs("div",{className:"chat-message chat-message--assistant chat-message--streaming",children:[e.jsxs("div",{className:"chat-message-avatar",children:[e.jsx(Ae,{size:14}),e.jsx("span",{children:Fe}),He&&e.jsx("span",{className:"chat-model-tag",children:ie}),e.jsx("button",{type:"button",className:`chat-message-render-toggle${m.has("__streaming__")?" chat-message-render-toggle--plain":""}`,"data-testid":"chat-message-render-toggle","aria-label":m.has("__streaming__")?"Show rendered markdown":"Show plain text",onClick:()=>Ve("__streaming__"),children:m.has("__streaming__")?e.jsx(st,{size:14}):e.jsx(nt,{size:14})})]}),$?yt($,m.has("__streaming__")):e.jsx("div",{className:"chat-message-content chat-message-content--waiting",children:w?"Thinking…":"Connecting…"}),it(P),w&&e.jsxs("details",{className:"chat-message-thinking",children:[e.jsx("summary",{children:"Thinking"}),e.jsx("pre",{className:"chat-message-thinking-content",children:w})]}),e.jsxs("div",{className:"chat-typing-indicator",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})]})]}),e.jsx("div",{ref:S})]}),r&&e.jsxs("div",{className:"chat-input-area",children:[e.jsx("input",{ref:Ie,type:"file",accept:"image/*,.txt,.json,.yaml,.yml,.log,.csv,.xml,.md",multiple:!0,style:{display:"none"},onChange:t=>{ye(t.target.files),t.target.value=""}}),J&&e.jsx("div",{className:"chat-skill-menu","data-testid":"chat-skill-menu",role:"listbox","aria-label":"Skill suggestions",children:ue?e.jsx("div",{className:"chat-skill-menu-empty",children:"Loading skills…"}):Z.length===0?e.jsx("div",{className:"chat-skill-menu-empty",children:re?"No skills found":"No skills available"}):Z.map((t,n)=>e.jsxs("button",{type:"button",role:"option","aria-selected":n===Se,className:`chat-skill-menu-item${n===Se?" chat-skill-menu-item--highlighted":""}`,onMouseDown:o=>o.preventDefault(),onMouseEnter:()=>he(n),onClick:()=>Pe(t),children:[e.jsx("span",{className:"chat-skill-menu-item-name",children:t.name}),e.jsx("span",{className:"chat-skill-menu-item-description",title:t.relativePath,children:t.relativePath})]},t.id))}),O.length>0&&e.jsx("div",{className:"chat-attachment-previews","data-testid":"chat-attachment-previews",children:O.map((t,n)=>e.jsxs("div",{className:"chat-attachment-preview","data-testid":`chat-attachment-preview-${n}`,children:[t.previewUrl?e.jsx("img",{src:t.previewUrl,alt:t.file.name}):e.jsx("span",{className:"chat-attachment-preview-name",children:t.file.name}),e.jsx("button",{type:"button",className:"chat-attachment-remove",onClick:()=>dt(n),"data-testid":`chat-attachment-remove-${n}`,"aria-label":`Remove ${t.file.name}`,children:"×"})]},t.previewUrl||`${t.file.name}-${n}`))}),e.jsxs("div",{className:"chat-input-row",children:[e.jsx("button",{type:"button",className:"btn-icon chat-attach-btn","data-testid":"chat-attach-btn","aria-label":"Attach files",onClick:()=>Ie.current?.click(),children:e.jsx(Gt,{size:16})}),e.jsxs("div",{className:`chat-input-wrapper${B?" chat-input-wrapper--dragover":""}`,onDragOver:t=>{t.preventDefault(),W(!0)},onDragLeave:()=>W(!1),onDrop:t=>{t.preventDefault(),W(!1),ye(t.dataTransfer.files)},children:[e.jsx("textarea",{ref:A,className:"chat-input-textarea",placeholder:"Type a message...",value:_,onChange:gt,onKeyDown:mt,onKeyUp:ft,onClick:Ee,onBlur:pt,onFocus:xt,onPaste:ut,rows:1,"data-testid":"chat-input"}),e.jsx(qt,{agents:ke,filter:be,highlightedIndex:me,visible:te,onSelect:De,position:"below"}),e.jsx(Kt,{visible:d.mentionActive&&!te,position:q,files:d.files,selectedIndex:d.selectedIndex,onSelect:t=>{const n=d.selectFile(t,_);X(n),d.dismissMention(),G(!1),A.current?.focus()},loading:d.loading}),x&&e.jsxs("div",{className:"chat-pending-message","data-testid":"chat-pending-indicator",children:[e.jsx("span",{children:`Queued: ${Nt}`}),e.jsx("button",{type:"button",className:"chat-pending-message-dismiss","aria-label":"Dismiss queued message","data-testid":"chat-pending-dismiss",onClick:T,children:"×"})]})]}),N?e.jsx("button",{className:"chat-input-stop",onClick:f,"aria-label":"Stop generation","data-testid":"chat-stop-btn",children:e.jsx(Jt,{size:14})}):e.jsx("button",{className:"chat-input-send",onClick:()=>void Re(),disabled:!_.trim()&&O.length===0,"data-testid":"chat-send-btn",children:e.jsx(Wt,{size:16})})]})]})]}),ee&&e.jsx(rs,{projectId:a,onClose:()=>K(!1),onCreate:ht})]})}export{ms as ChatView};
@@ -1 +0,0 @@
1
- import{r as u,j as s}from"./vendor-react-K0fH_qHe.js";import{z as ee,dK as se,s as ne,X as k,aq as te,N as O,dL as A,_,R as ie,dM as ae,aI as le,ch as re,dN as ce,dO as de,dP as ue,dQ as oe,dR as M,ce as ge}from"./index-D7gT6mCr.js";import{D as me}from"./DirectoryPicker-tvBgHxa7.js";import"./vendor-xterm-DzcZoU0P.js";import"./folder-open-CxOUgHDf.js";const V=[{id:"fusion-plugin-hermes-runtime",name:"Hermes Runtime",path:"./plugins/fusion-plugin-hermes-runtime",experimental:!0},{id:"fusion-plugin-paperclip-runtime",name:"Paperclip Runtime",path:"./plugins/fusion-plugin-paperclip-runtime"},{id:"fusion-plugin-openclaw-runtime",name:"OpenClaw Runtime",path:"./plugins/fusion-plugin-openclaw-runtime",experimental:!0}],j={started:"var(--color-success)",loaded:"var(--color-warning)",error:"var(--color-error)",stopped:"var(--color-muted)",installed:"var(--color-info)"};function fe({addToast:l,projectId:c}){const[N,x]=u.useState([]),[S,w]=u.useState(!0),[H,f]=u.useState(!1),[b,v]=u.useState(""),[C,P]=u.useState(!1),[h,I]=u.useState(null),[i,y]=u.useState(null),[a,p]=u.useState({}),[K,R]=u.useState(!1),[$,E]=u.useState(null),{confirm:G}=ee(),o=u.useCallback(async()=>{try{w(!0);const e=await se(c);x(e)}catch(e){l(`Failed to load plugins: ${e instanceof Error?e.message:String(e)}`,"error")}finally{w(!1)}},[c,l]);u.useEffect(()=>{o()},[o]);const J=u.useRef([]);J.current=N,u.useEffect(()=>{const e=c?`?projectId=${encodeURIComponent(c)}`:"",n=g=>{try{const t=JSON.parse(g.data);if(c&&t.projectId&&t.projectId!==c)return;switch(t.transition){case"installing":case"enabled":case"disabled":case"settings-updated":x(d=>{const m=d.findIndex(r=>r.id===t.pluginId);if(m>=0){const r=[...d];return r[m]={...r[m],enabled:t.enabled,state:t.state,settings:t.settings,error:t.error},r}else return o(),d});break;case"uninstalled":x(d=>d.filter(m=>m.id!==t.pluginId));break;case"error":x(d=>{const m=d.findIndex(r=>r.id===t.pluginId);if(m>=0){const r=[...d];return r[m]={...r[m],state:t.state,error:t.error},r}return d});break}}catch{}};return ne(`/api/events${e}`,{events:{"plugin:lifecycle":n},onReconnect:()=>{o()}})},[c,o]);const z=async()=>{if(!b.trim()){l("Please enter a plugin path","error");return}try{P(!0),await M({path:b},c),l("Plugin installed successfully","success"),f(!1),v(""),await o()}catch(e){l(`Failed to install plugin: ${e instanceof Error?e.message:String(e)}`,"error")}finally{P(!1)}},Q=async e=>{try{E(e.id),await M({path:e.path},c),l(`${e.name} installed successfully`,"success"),await o()}catch(n){l(`Failed to install ${e.name}: ${n instanceof Error?n.message:String(n)}`,"error")}finally{E(null)}},F=async e=>{try{await ue(e.id,c),l(`${e.name} enabled`,"success"),await o()}catch(n){l(`Failed to enable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},L=async e=>{try{await de(e.id,c),l(`${e.name} disabled`,"success"),await o()}catch(n){l(`Failed to disable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},B=async e=>{try{I(e.id),await ce(e.id,c),l(`${e.name} reloaded`,"success"),await o()}catch(n){l(`Failed to reload plugin: ${n instanceof Error?n.message:String(n)}`,"error")}finally{I(null)}},U=async e=>{if(await G({title:"Uninstall Plugin",message:`Are you sure you want to uninstall "${e.name}"?`,danger:!0}))try{await oe(e.id,c),l(`${e.name} uninstalled`,"success"),await o(),y(null)}catch(g){l(`Failed to uninstall plugin: ${g instanceof Error?g.message:String(g)}`,"error")}},X=async e=>{y(e);try{R(!0);const n=await ge(e.id,c);p(n)}catch{p({})}finally{R(!1)}},W=async()=>{if(i)try{await re(i.id,a,c),l("Settings saved","success")}catch(e){l(`Failed to save settings: ${e instanceof Error?e.message:String(e)}`,"error")}};if(i)return s.jsxs("div",{className:"plugin-manager-detail","data-testid":"plugin-manager-detail",children:[s.jsxs("div",{className:"plugin-manager-detail-header",children:[s.jsx("button",{className:"btn-icon",onClick:()=>y(null),"aria-label":"Back to plugin list",children:s.jsx(k,{size:16})}),s.jsxs("div",{className:"plugin-detail-title",children:[s.jsx("h4",{className:"plugin-detail-name",children:i.name}),s.jsx("span",{className:"plugin-state-badge",style:{color:j[i.state]||j.installed},children:i.state})]})]}),s.jsxs("div",{className:"plugin-detail-content",children:[s.jsxs("div",{className:"plugin-detail-card",children:[i.description&&s.jsx("p",{className:"plugin-description",children:i.description}),i.author&&s.jsxs("p",{className:"plugin-detail-meta-row",children:[s.jsx("span",{className:"text-muted",children:"Author:"}),i.author]}),i.homepage&&s.jsxs("p",{className:"plugin-detail-meta-row plugin-homepage",children:[s.jsx("span",{className:"text-muted",children:"Homepage:"}),s.jsxs("a",{href:i.homepage,target:"_blank",rel:"noopener noreferrer",children:[i.homepage,s.jsx(te,{size:12})]})]}),s.jsxs("p",{className:"plugin-detail-meta-row",children:[s.jsx("span",{className:"text-muted",children:"Version:"}),i.version]})]}),s.jsxs("div",{className:"plugin-detail-card",children:[s.jsx("h5",{className:"plugin-detail-section-heading",children:"Settings"}),K?s.jsx("p",{className:"text-muted",children:"Loading..."}):i.settingsSchema&&Object.keys(i.settingsSchema).length>0?s.jsxs("div",{className:"plugin-settings-form",children:[Object.entries(i.settingsSchema).map(([e,n])=>{const g=`setting-${e}-help`;return s.jsxs("div",{className:"form-group",children:[s.jsxs("label",{htmlFor:`setting-${e}`,children:[n.label||e,n.required&&" *"]}),n.type==="string"&&!n.multiline&&s.jsx("input",{type:"text",id:`setting-${e}`,value:a[e]??"",onChange:t=>p({...a,[e]:t.target.value}),placeholder:n.description,"aria-describedby":n.description&&!n.required?g:void 0}),n.type==="string"&&n.multiline&&s.jsx("textarea",{id:`setting-${e}`,rows:4,value:a[e]??"",onChange:t=>p({...a,[e]:t.target.value}),placeholder:n.description,"aria-describedby":n.description&&!n.required?g:void 0}),n.type==="password"&&s.jsx("input",{type:"password",id:`setting-${e}`,value:a[e]??"",onChange:t=>p({...a,[e]:t.target.value}),placeholder:n.description,"aria-describedby":n.description&&!n.required?g:void 0}),n.type==="number"&&s.jsx("input",{type:"number",id:`setting-${e}`,value:a[e]??"",onChange:t=>p({...a,[e]:Number(t.target.value)}),"aria-describedby":n.description&&!n.required?g:void 0}),n.type==="boolean"&&s.jsxs("label",{className:"checkbox-label",children:[s.jsx("input",{type:"checkbox",checked:a[e]??!1,onChange:t=>p({...a,[e]:t.target.checked})}),n.description]}),n.type==="enum"&&s.jsxs("select",{id:`setting-${e}`,value:a[e]??"",onChange:t=>p({...a,[e]:t.target.value}),"aria-describedby":n.description&&!n.required?g:void 0,children:[s.jsx("option",{value:"",children:"Select..."}),n.enumValues?.map(t=>s.jsx("option",{value:t,children:t},t))]}),n.type==="array"&&s.jsxs("div",{className:"plugin-settings-array",children:[a[e]?.map((t,d)=>s.jsxs("div",{className:"plugin-settings-array-item",children:[s.jsx("input",{type:n.itemType==="number"?"number":"text",value:t??"",onChange:m=>{const r=m.target.value,D=[...a[e]||[]];D[d]=n.itemType==="number"?Number(r):r,p({...a,[e]:D})}}),s.jsx("button",{className:"btn-icon",onClick:()=>{const r=[...a[e]||[]];r.splice(d,1),p({...a,[e]:r})},"aria-label":"Remove item",children:s.jsx(k,{size:14})})]},d)),s.jsxs("button",{className:"btn btn-secondary",onClick:()=>{const t=a[e]||[],d=n.itemType==="number"?0:"";p({...a,[e]:[...t,d]})},children:[s.jsx(O,{size:14})," Add Item"]})]}),n.description&&!n.required&&!n.multiline&&s.jsx("span",{id:g,className:"form-help",children:n.description})]},e)}),s.jsx("button",{className:"btn btn-primary",onClick:W,children:"Save Settings"})]}):s.jsx("p",{className:"text-muted",children:"No configurable settings."})]}),s.jsxs("div",{className:"plugin-detail-actions",children:[i.state==="started"&&s.jsxs("button",{className:"btn btn-secondary",onClick:()=>B(i),disabled:h===i.id,children:[s.jsx(A,{size:14,className:h===i.id?"spin":""}),h===i.id?"Reloading...":"Reload"]}),i.enabled?s.jsx("button",{className:"btn btn-secondary",onClick:()=>L(i),children:"Disable"}):s.jsx("button",{className:"btn btn-primary",onClick:()=>F(i),children:"Enable"}),s.jsxs("button",{className:"btn btn-danger",onClick:()=>U(i),children:[s.jsx(_,{size:14})," Uninstall"]})]})]})]});const Y=new Set(N.map(e=>e.id)),Z=new Set(V.map(e=>e.id)),q=N.filter(e=>!Z.has(e.id)),T=()=>s.jsxs("section",{className:"plugin-bundled-runtime-section","aria-label":"Bundled Runtime Plugins",children:[s.jsxs("div",{className:"plugin-bundled-runtime-header",children:[s.jsx("h4",{className:"plugin-bundled-runtime-heading",children:"Bundled Runtime Plugins"}),s.jsx("p",{className:"plugin-bundled-runtime-description",children:"Install Fusion's bundled runtimes directly from this screen."})]}),s.jsx("div",{className:"plugin-bundled-runtime-list","aria-label":"Bundled runtime plugin recommendations",children:V.map(e=>{const n=Y.has(e.id);return s.jsxs("div",{className:"plugin-bundled-runtime-item",children:[s.jsxs("div",{className:"plugin-bundled-runtime-meta",children:[s.jsx("span",{className:"plugin-bundled-runtime-name",children:e.name}),e.experimental&&s.jsx("span",{className:"plugin-bundled-runtime-badge",children:"Experimental"}),s.jsx("span",{className:`plugin-bundled-runtime-status ${n?"plugin-bundled-runtime-status--installed":"plugin-bundled-runtime-status--available"}`,children:n?"Installed":"Not installed"})]}),s.jsx("button",{className:`btn ${n?"btn-secondary":"btn-primary"} btn-sm`,onClick:()=>Q(e),disabled:n||$===e.id,children:n?"Installed":$===e.id?"Installing...":`Install ${e.name}`})]},e.id)})})]});return s.jsxs("div",{className:"plugin-manager","data-testid":"plugin-manager",children:[s.jsxs("div",{className:"plugin-manager-header",children:[s.jsx("span",{className:"plugin-manager-header-title",children:"Installed Plugins"}),s.jsxs("div",{className:"plugin-manager-actions",children:[s.jsxs("button",{className:"btn btn-sm btn-ghost",onClick:o,title:"Refresh","aria-label":"Refresh plugin list",children:[s.jsx(ie,{size:14,className:S?"spin":""}),"Refresh"]}),s.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>f(!0),children:[s.jsx(O,{size:14})," Install"]})]})]}),H&&s.jsxs("div",{className:"plugin-install-form",children:[s.jsxs("p",{className:"plugin-install-hint",children:["Browse to a plugin package root (contains ",s.jsx("code",{children:"manifest.json"}),") or a built ",s.jsx("code",{children:"dist"})," directory."]}),s.jsx(me,{value:b,onChange:v,placeholder:"Absolute path to plugin directory or dist folder",onInputKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),z())}}),s.jsxs("div",{className:"plugin-install-actions",children:[s.jsx("button",{className:"btn btn-primary",onClick:z,disabled:C||!b.trim(),children:C?"Installing...":"Install Plugin"}),s.jsx("button",{className:"btn btn-secondary",onClick:()=>{f(!1),v("")},children:"Cancel"})]})]}),S?s.jsx("div",{className:"settings-empty-state",children:"Loading plugins..."}):s.jsxs(s.Fragment,{children:[q.length===0?s.jsxs("div",{className:"settings-empty-state",children:[s.jsx(ae,{size:32,className:"text-muted"}),s.jsx("p",{children:"No plugins installed."}),s.jsx("p",{className:"text-muted",children:"Install a plugin to get started, or use a bundled runtime below."})]}):s.jsx("div",{className:"plugin-list",children:q.map(e=>s.jsxs("div",{className:"plugin-item",children:[s.jsxs("div",{className:"plugin-info",children:[s.jsx("span",{className:"plugin-name",children:e.name}),s.jsxs("span",{className:"plugin-version text-muted",children:["v",e.version]}),s.jsx("span",{className:"plugin-state-badge",style:{color:j[e.state]||j.installed},children:e.state})]}),s.jsxs("div",{className:"plugin-actions",children:[e.state==="started"&&s.jsx("button",{className:"btn-icon",onClick:()=>B(e),disabled:h===e.id,title:"Reload",children:s.jsx(A,{size:14,className:h===e.id?"spin":""})}),s.jsxs("label",{className:"toggle-switch",children:[s.jsx("input",{type:"checkbox",checked:e.enabled,onChange:()=>e.enabled?L(e):F(e)}),s.jsx("span",{className:"toggle-slider"})]}),s.jsx("button",{className:"btn-icon",onClick:()=>X(e),title:"Settings",children:s.jsx(le,{size:14})}),s.jsx("button",{className:"btn-icon",onClick:()=>U(e),title:"Uninstall",children:s.jsx(_,{size:14})})]})]},e.id))}),T()]})]})}export{fe as PluginManager,j as STATE_COLORS};
@@ -1 +0,0 @@
1
- .research-view{display:flex;flex-direction:column;gap:var(--space-md);height:100%;min-height:0;padding:var(--space-lg)}.research-view__header{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--space-md)}.research-view__title{margin:0}.research-view__subtitle{margin:var(--space-xs) 0 0;color:var(--text-muted)}.research-view__layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,2fr);gap:var(--space-md);min-height:0;flex:1}.research-view__sidebar,.research-view__reader{padding:var(--space-md);display:flex;flex-direction:column;gap:var(--space-md);min-height:0}.research-view__form{display:flex;flex-direction:column;gap:var(--space-sm)}.research-view__form .form-group,.research-view__history-header.form-group,.research-view__actions .form-group{margin:0;padding:0}.research-view__textarea{min-height:calc(var(--space-2xl) * 3);resize:vertical}.research-view__providers{display:grid;gap:var(--space-xs)}.research-view__history-header{display:flex;flex-direction:column;align-items:stretch;gap:var(--space-xs)}.research-view__history-search-row{display:flex;align-items:center;gap:var(--space-xs)}.research-view__history{display:flex;flex-direction:column;gap:var(--space-xs);overflow:auto}.research-view__history-item{border:var(--btn-border-width) solid var(--border);border-radius:var(--radius-sm);background:var(--surface);color:var(--text);text-align:left;padding:var(--space-sm);min-height:calc(var(--space-lg) * 2 + var(--space-xs));display:flex;flex-direction:column;justify-content:center;gap:var(--space-xs);transition:border-color var(--transition-fast),box-shadow var(--transition-fast),background-color var(--transition-fast)}.research-view__history-item:hover{background:var(--card-hover);border-color:var(--todo)}.research-view__history-item:focus-visible{outline:none;border-color:var(--todo);box-shadow:var(--focus-ring-strong)}.research-view__history-item--active{border-color:var(--todo);box-shadow:var(--focus-ring)}.research-view__status-row{display:flex;align-items:center;gap:var(--space-xs);text-transform:capitalize}.research-view__run-title,.research-view__run-query,.research-view__run-summary{margin:0}.research-view__run-query{color:var(--text-muted)}.research-view__actions{display:flex;flex-wrap:wrap;gap:var(--space-xs);margin-top:var(--space-sm)}.research-view__citations{margin:var(--space-sm) 0 0;padding-left:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-xs)}.research-view__citations a{color:var(--text)}.research-view__error{color:var(--color-error)}.research-view__findings{display:flex;flex-direction:column;gap:var(--space-sm)}.research-view__finding{padding:var(--space-sm)}.research-view__finding h4,.research-view__finding p{margin:0}.research-view__events{margin:var(--space-sm) 0 0;padding-left:var(--space-lg)}.research-view__stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--space-sm)}.research-view__stat-card{border:var(--btn-border-width) solid var(--border);border-radius:var(--radius-sm);padding:var(--space-sm);background:var(--surface)}.research-view__stat-label{color:var(--text-muted);text-transform:uppercase;font-size:.75rem}.research-view__stat-value{font-family:var(--font-mono);font-size:1rem}.research-view__state--error{border-color:var(--color-error)}@media(max-width:768px){.research-view{padding:var(--space-md)}.research-view__layout{grid-template-columns:minmax(0,1fr)}.research-view__header{flex-direction:column}.research-view__stats{grid-template-columns:minmax(0,1fr)}.research-view__history-item{min-height:calc(var(--space-lg) * 2 + var(--space-sm))}}