@runfusion/fusion 0.12.0 → 0.14.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 (74) hide show
  1. package/README.md +13 -0
  2. package/dist/bin.js +1707 -610
  3. package/dist/client/assets/AgentDetailView-CBFUveyO.js +18 -0
  4. package/dist/client/assets/AgentsView-DPezXQ-U.js +522 -0
  5. package/dist/client/assets/{AgentsView-Bkk-uBij.css → AgentsView-V5GhlBYu.css} +1 -1
  6. package/dist/client/assets/ChatView-5N4-EuhD.js +1 -0
  7. package/dist/client/assets/{DevServerView-DQrVLbK5.js → DevServerView-Daft4YFc.js} +1 -1
  8. package/dist/client/assets/{DirectoryPicker-DVmy6sLM.js → DirectoryPicker-rew1y6qO.js} +1 -1
  9. package/dist/client/assets/{DocumentsView-DHEv-Q2a.js → DocumentsView-i72qJzwd.js} +1 -1
  10. package/dist/client/assets/{InsightsView-ByyY7GX7.js → InsightsView-BL5eZJ0a.js} +3 -3
  11. package/dist/client/assets/{MemoryView-Udiu0u8R.js → MemoryView-pl8Cdg_p.js} +2 -2
  12. package/dist/client/assets/{NodesView-CupS-GGc.js → NodesView-D6eJ15zc.js} +4 -4
  13. package/dist/client/assets/PiExtensionsManager-ExInwXWP.js +11 -0
  14. package/dist/client/assets/PluginManager-CYhtxHun.js +1 -0
  15. package/dist/client/assets/{ResearchView-BG9Feaeb.js → ResearchView-B_QPUEjB.js} +1 -1
  16. package/dist/client/assets/{RoadmapsView-BTJtmBnF.js → RoadmapsView-DBNLaEsK.js} +2 -2
  17. package/dist/client/assets/SettingsModal-1ET586M3.js +31 -0
  18. package/dist/client/assets/{SettingsModal-eNCZiHa6.js → SettingsModal-CL_gWmOj.js} +1 -1
  19. package/dist/client/assets/SettingsModal-D_AFkDJa.css +1 -0
  20. package/dist/client/assets/{SetupWizardModal-yf79TN1L.js → SetupWizardModal-CLkY9HFL.js} +1 -1
  21. package/dist/client/assets/{SkillMultiselect-DOj5vX4U.js → SkillMultiselect-B0qi32SQ.js} +1 -1
  22. package/dist/client/assets/{SkillsView-CgnCnikX.js → SkillsView-umVjRq6o.js} +1 -1
  23. package/dist/client/assets/TodoView-CFifSvrD.js +6 -0
  24. package/dist/client/assets/TodoView-SeO9o7km.css +1 -0
  25. package/dist/client/assets/{folder-open-D11gjHGK.js → folder-open-nYPrL1W3.js} +1 -1
  26. package/dist/client/assets/index-Bc8nfKeH.js +661 -0
  27. package/dist/client/assets/index-C1prPuSl.css +1 -0
  28. package/dist/client/assets/{list-checks-CBzPc3GA.js → list-checks-sK8xJeH_.js} +1 -1
  29. package/dist/client/assets/{star-BWcRk8nt.js → star-BRtXbYkB.js} +1 -1
  30. package/dist/client/assets/{upload-91TM4ljC.js → upload-BP60eBwN.js} +1 -1
  31. package/dist/client/assets/{users-BAsI___L.js → users-qSGAX2Pf.js} +1 -1
  32. package/dist/client/index.html +2 -2
  33. package/dist/client/sw.js +6 -0
  34. package/dist/client/version.json +1 -1
  35. package/dist/droid-cli/index.ts +127 -0
  36. package/dist/droid-cli/package.json +37 -0
  37. package/dist/droid-cli/src/__tests__/control-handler.test.ts +164 -0
  38. package/dist/droid-cli/src/__tests__/event-bridge.test.ts +1318 -0
  39. package/dist/droid-cli/src/__tests__/mcp-config.test.ts +310 -0
  40. package/dist/droid-cli/src/__tests__/process-manager.test.ts +818 -0
  41. package/dist/droid-cli/src/__tests__/prompt-builder.test.ts +1206 -0
  42. package/dist/droid-cli/src/__tests__/provider.test.ts +1894 -0
  43. package/dist/droid-cli/src/__tests__/setup-test-isolation.test.ts +32 -0
  44. package/dist/droid-cli/src/__tests__/setup-test-isolation.ts +14 -0
  45. package/dist/droid-cli/src/__tests__/stream-parser.test.ts +188 -0
  46. package/dist/droid-cli/src/__tests__/thinking-config.test.ts +141 -0
  47. package/dist/droid-cli/src/__tests__/tool-mapping.test.ts +253 -0
  48. package/dist/droid-cli/src/control-handler.ts +82 -0
  49. package/dist/droid-cli/src/event-bridge.ts +397 -0
  50. package/dist/droid-cli/src/mcp-config.ts +144 -0
  51. package/dist/droid-cli/src/mcp-schema-server.cjs +49 -0
  52. package/dist/droid-cli/src/process-manager.ts +358 -0
  53. package/dist/droid-cli/src/prompt-builder.ts +629 -0
  54. package/dist/droid-cli/src/provider.ts +447 -0
  55. package/dist/droid-cli/src/stream-parser.ts +37 -0
  56. package/dist/droid-cli/src/thinking-config.ts +83 -0
  57. package/dist/droid-cli/src/tool-mapping.ts +147 -0
  58. package/dist/droid-cli/src/types.ts +87 -0
  59. package/dist/extension.js +542 -141
  60. package/dist/pi-claude-cli/package.json +1 -1
  61. package/dist/pi-claude-cli/src/__tests__/prompt-builder.test.ts +36 -0
  62. package/dist/pi-claude-cli/src/prompt-builder.ts +19 -28
  63. package/package.json +2 -1
  64. package/dist/client/assets/AgentDetailView-B20ApPe1.js +0 -18
  65. package/dist/client/assets/AgentsView-ChN1tgQ0.js +0 -522
  66. package/dist/client/assets/ChatView-oPMFwmoc.js +0 -1
  67. package/dist/client/assets/PiExtensionsManager-DXs2xI8K.js +0 -11
  68. package/dist/client/assets/PluginManager-BCpiZf4_.js +0 -1
  69. package/dist/client/assets/SettingsModal-9HS8MnmW.css +0 -1
  70. package/dist/client/assets/SettingsModal-DZ_LaEhd.js +0 -31
  71. package/dist/client/assets/TodoView-67BMyICY.js +0 -6
  72. package/dist/client/assets/TodoView-C1g65hJo.css +0 -1
  73. package/dist/client/assets/index-BLn1R7Ob.css +0 -1
  74. package/dist/client/assets/index-CLAHcGnI.js +0 -656
@@ -1 +0,0 @@
1
- import{r as s,j as t}from"./vendor-react-K0fH_qHe.js";import{i as ze,aN as Dt,g as Et,aO as Pt,a as Ft,aP as Lt,aQ as _t,aR as Ot,aS as It,aT as Ut,aU as zt,s as Ht,aV as Vt,aW as qt,aX as Bt,aY as Gt,ad as it,ae as rt,S as Wt,Y as Xe,M as Ze,aq as Kt,aZ as Yt,B as Ee,aa as lt,ab as ot,a_ as Jt,a$ as Qt,b0 as Xt,b1 as Zt,b2 as es,b3 as ts,b4 as ss,b5 as et,h as ns,u as tt,k as as}from"./index-CLAHcGnI.js";import"./vendor-xterm-DzcZoU0P.js";const Ue="kb-chat-active-session";function is(a){const i=a?.toolCalls;if(!Array.isArray(i))return;const l=i.map(o=>{if(!o||typeof o!="object")return null;const c=o,y=typeof c.toolName=="string"?c.toolName:"";if(!y)return null;const N=c.args;return{toolName:y,...N&&typeof N=="object"?{args:N}:{},isError:!!c.isError,result:c.result,status:"completed"}}).filter(o=>o!==null);return l.length>0?l:void 0}function st(a){return{id:a.id,sessionId:a.sessionId,role:a.role,content:a.content,thinkingOutput:a.thinkingOutput,toolCalls:is(a.metadata),attachments:a.attachments,createdAt:a.createdAt}}function rs(a){const[i,l]=s.useState([]),[o,c]=s.useState(null),[y,N]=s.useState(!0),[$,b]=s.useState([]),[D,z]=s.useState(!1),[p,F]=s.useState(!1),[C,M]=s.useState(""),[g,x]=s.useState(""),[T,k]=s.useState([]),[H,L]=s.useState(""),[ee,K]=s.useState(""),[_,X]=s.useState(!0),[h,j]=s.useState(new Map),v=s.useRef(null),O=s.useRef(!1),V=s.useRef(""),de=s.useRef(null),ue=s.useRef(i),pe=s.useRef(o),xe=s.useRef(p);ue.current=i,pe.current=o,xe.current=p,s.useEffect(()=>{V.current=H},[H]);const ve=s.useRef(new Set),he=s.useRef(0),ye=s.useRef(a);ye.current!==a&&(ye.current=a,he.current++),s.useEffect(()=>{const u=he.current;ze(void 0,a).then(f=>{if(he.current!==u)return;const m=new Map;for(const R of f)m.set(R.id,R);j(m)}).catch(()=>{})},[a]);const Y=s.useCallback(async()=>{N(!0);try{const f=[...(await Dt(a)).sessions].sort((m,R)=>new Date(R.updatedAt).getTime()-new Date(m.updatedAt).getTime());l(f)}catch{}finally{N(!1)}},[a]);s.useEffect(()=>{Y()},[Y]);const se=s.useRef(()=>{});s.useEffect(()=>{if(y)return;const u=Et(Ue,a);u&&i.find(m=>m.id===u)&&se.current(u)},[y,i,a]);const le=s.useCallback(async(u,f)=>{z(!0);try{const m=await Pt(u,{limit:50,...f},a),R=m.messages.map(st);f?.offset&&f.offset>0?b(I=>[...R,...I]):b(R),X(m.messages.length>=50)}catch{}finally{z(!1)}},[a]),ne=s.useCallback((u,f)=>{v.current&&(v.current.close(),v.current=null);const m=f??i.find(R=>R.id===u);c(m||null),M(""),x(""),k([]),F(!1),X(!0),u?le(u):b([]),u?Ft(Ue,u,a):Lt(Ue,a)},[i,le,a]);se.current=ne;const we=s.useCallback(async u=>{const f=await _t(u,a);v.current&&(v.current.close(),v.current=null);const m={id:f.session.id,title:f.session.title,agentId:f.session.agentId,status:f.session.status,modelProvider:f.session.modelProvider,modelId:f.session.modelId,createdAt:f.session.createdAt,updatedAt:f.session.updatedAt};return l(R=>R.some(I=>I.id===m.id)?R:[m,...R]),ne(m.id,m),b([]),m},[a,ne]),me=s.useCallback(async u=>{await Ot(u,{status:"archived"},a),l(f=>f.filter(m=>m.id!==u)),o?.id===u&&(c(null),b([]))},[o,a]),Se=s.useCallback(async u=>{o?.id===u&&v.current&&(v.current.close(),v.current=null),await It(u,a),l(f=>f.filter(m=>m.id!==u)),o?.id===u&&(c(null),b([]))},[o,a]),oe=s.useCallback(async()=>{!o||!_||await le(o.id,{offset:$.length})},[o,_,le,$.length]),te=s.useCallback(()=>{o&&(O.current=!0,de.current?.(),de.current=null,v.current?.close(),v.current=null,Ut(o.id,a).catch(()=>{}),F(!1),M(""),x(""),k([]))},[o,a]),ce=s.useCallback(()=>{V.current="",L("")},[]),fe=s.useCallback((u,f)=>{if(!o)return;if(p){V.current=u,L(u);return}O.current=!1,v.current&&(v.current.close(),v.current=null);const m=`temp-${Date.now()}`,R={id:m,sessionId:o.id,role:"user",content:u,createdAt:new Date().toISOString()};b(w=>[...w,R]),M(""),x(""),k([]),F(!0);let I="",ae="",q=[],J=null,B=null;const G=()=>{J=null,M(I)},E=()=>{B=null,x(ae)},d=()=>{J!==null&&(cancelAnimationFrame(J),J=null),B!==null&&(cancelAnimationFrame(B),B=null)};de.current=d;const U={onThinking:w=>{ae+=w,B===null&&(B=requestAnimationFrame(E))},onText:w=>{I+=w,J===null&&(J=requestAnimationFrame(G))},onToolStart:w=>{q=[...q,{toolName:w.toolName,args:w.args,isError:!1,status:"running"}],k(q)},onToolEnd:w=>{const S=[...q];for(let W=S.length-1;W>=0;W--){const A=S[W];if(A?.toolName===w.toolName&&A.status==="running"){S[W]={...A,status:"completed",isError:w.isError,result:w.result},q=S,k(S);return}}q=[...S,{toolName:w.toolName,isError:w.isError,result:w.result,status:"completed"}],k(q)},onDone:w=>{d();const S={id:w.messageId||`msg-${Date.now()}`,sessionId:o.id,role:"assistant",content:I,thinkingOutput:ae,toolCalls:q.length>0?q:void 0,createdAt:new Date().toISOString()};ve.current.add(S.id),b(A=>[...A,S]),M(""),x(""),k([]),F(!1),v.current=null,setTimeout(()=>{ve.current.delete(S.id)},1e3),Y();const W=V.current.trim();W&&(V.current="",L(""),fe(W))},onError:w=>{if(d(),b(S=>S.filter(W=>W.id!==m)),M(""),x(""),k([]),F(!1),v.current=null,console.error("[useChat] Stream error:",w),!O.current){const S=V.current.trim();S&&(V.current="",L(""),fe(S))}}};v.current=zt(o.id,u,U,f,a)},[o,p,a,Y]),be=ee?i.filter(u=>u.title?.toLowerCase().includes(ee.toLowerCase())||u.agentId.toLowerCase().includes(ee.toLowerCase())):i;return s.useEffect(()=>{const u=he.current,f=a?`?projectId=${encodeURIComponent(a)}`:"",m=()=>he.current!==u,R=G=>{if(m())return;const E=JSON.parse(G.data);l(d=>d.some(U=>U.id===E.id)?d:[E,...d])},I=G=>{if(m())return;const E=JSON.parse(G.data);l(d=>[...d.map(w=>w.id===E.id?E:w)]),pe.current?.id===E.id&&c(E)},ae=G=>{if(m())return;const{id:E}=JSON.parse(G.data);l(d=>d.filter(U=>U.id!==E)),pe.current?.id===E&&(c(null),b([]))},q=G=>{if(m())return;const E=JSON.parse(G.data),d=st(E);ve.current.has(d.id)||pe.current?.id===d.sessionId&&!xe.current&&b(U=>U.some(w=>w.id===d.id)?U:[...U,d])},J=G=>{if(m())return;const{id:E}=JSON.parse(G.data);b(d=>d.filter(U=>U.id!==E))};return Ht(`/api/events${f}`,{events:{"chat:session:created":R,"chat:session:updated":I,"chat:session:deleted":ae,"chat:message:added":q,"chat:message:deleted":J}})},[a]),s.useEffect(()=>()=>{v.current&&(v.current.close(),v.current=null)},[]),{sessions:i,activeSession:o,sessionsLoading:y,messages:$,messagesLoading:D,isStreaming:p,streamingText:C,streamingThinking:g,streamingToolCalls:T,pendingMessage:H,selectSession:ne,createSession:we,archiveSession:me,deleteSession:Se,sendMessage:fe,stopStreaming:te,clearPendingMessage:ce,loadMoreMessages:oe,hasMoreMessages:_,searchQuery:ee,setSearchQuery:K,filteredSessions:be,refreshSessions:Y,agentsMap:h}}function ct(a){const i=new Date(a),o=new Date().getTime()-i.getTime(),c=Math.floor(o/1e3),y=Math.floor(c/60),N=Math.floor(y/60),$=Math.floor(N/24);return c<60?"just now":y<60?`${y}m ago`:N<24?`${N}h ago`:$<7?`${$}d ago`:i.toLocaleDateString()}function nt(a,i){if(!a||!i)return null;const l=i.toLowerCase();if(l.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(l.includes("gpt")||l.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(l.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 o=i.replace(/-/g," ").replace(/^\w/,c=>c.toUpperCase()).replace(/\s+/g," ").trim();return o.length>30?o.slice(0,30)+"…":o}function Re(a,i){return a.length<=i?a:`${a.slice(0,i)}…`}function ls(a){if(!a)return null;const i=Object.entries(a);return i.length===0?null:i.map(([l,o])=>{const c=typeof o=="string"?o:(()=>{try{return JSON.stringify(o)}catch{return String(o)}})();return`${l}=${Re(c,50)}`}).join(", ")}function os(a){if(a===void 0)return null;if(typeof a=="string")return Re(a,200);try{return Re(JSON.stringify(a),200)}catch{return Re(String(a),200)}}function dt(a){if(!a||a.length===0)return null;const i=(p,F)=>{const C=p.status==="running",M=p.status==="completed"&&p.isError,g=ls(p.args),x=os(p.result),T=C?g:x?`result: ${x}`:g?`args: ${g}`:null,k=C?"running":M?"error":"completed";return t.jsxs("details",{className:`chat-tool-call${C?" chat-tool-call--running":""}${M?" chat-tool-call--error":""}`,open:C,children:[t.jsxs("summary",{children:[t.jsx("span",{className:"chat-tool-call-status-dot","aria-hidden":"true"}),t.jsx("span",{className:"chat-tool-call-name",children:p.toolName}),T&&t.jsx("span",{className:"chat-tool-call-preview",title:T,children:T}),t.jsx("span",{className:"chat-tool-call-status-text",children:k})]}),t.jsxs("div",{className:"chat-tool-call-content",children:[g&&t.jsxs("div",{className:"chat-tool-call-row",children:[t.jsx("span",{className:"chat-tool-call-label",children:"args"}),t.jsx("span",{className:"chat-tool-call-value",children:g})]}),x&&t.jsxs("div",{className:`chat-tool-call-row${M?" chat-tool-call-row--error":""}`,children:[t.jsx("span",{className:"chat-tool-call-label",children:"result"}),t.jsx("span",{className:"chat-tool-call-value",children:x})]})]})]},`${p.toolName}-${F}`)},l="chat-tool-calls";if(a.length===1)return t.jsxs("div",{className:l,"data-testid":"chat-tool-calls",children:[t.jsxs("div",{className:"chat-tool-calls-header",children:[t.jsx(et,{size:12,"aria-hidden":"true"}),t.jsx("span",{children:"Tool calls"})]}),i(a[0],0)]});const o=a.filter(p=>p.status==="running").length,c=a.filter(p=>p.status==="completed"&&p.isError).length,y=o>0,N=Array.from(new Set(a.map(p=>p.toolName))),$=N.slice(0,5),b=Math.max(0,N.length-$.length),D=b>0?`${$.join(", ")}, +${b} more`:$.join(", "),z=y?`(${o} running)`:c>0?`(${c} ${c===1?"error":"errors"})`:null;return t.jsx("div",{className:l,"data-testid":"chat-tool-calls",children:t.jsxs("details",{className:"chat-tool-calls-group","data-testid":"chat-tool-calls-group",open:y,children:[t.jsxs("summary",{className:"chat-tool-calls-group-summary",children:[t.jsx(et,{size:12,"aria-hidden":"true"}),t.jsxs("span",{children:[a.length," tool calls"]}),t.jsx("span",{className:"chat-tool-calls-names",title:D,children:D}),z&&t.jsx("span",{className:"chat-tool-calls-group-status",children:z})]}),a.map((p,F)=>i(p,F))]})})}const ut={pre:({children:a,...i})=>t.jsx("pre",{...i,className:"chat-markdown-pre",children:a}),table:({children:a,...i})=>t.jsx("table",{...i,className:"chat-markdown-table",children:a})},De="__fn_agent__",cs=["image/png","image/jpeg","image/gif","image/webp","text/plain","application/json","text/yaml","text/markdown","text/csv","application/xml","text/x-log"];function at(a){const i=/(^|[\s])\/([^\s]*)$/.exec(a);if(!i)return null;const l=i[1]??"",o=i[2]??"",c=i.index+l.length;return{filter:o,start:c,end:a.length}}function ds(a,i){const l=a.slice(0,i),o=/(^|[\s\n])@([\w-]*)$/.exec(l);if(!o)return null;const c=o[2]??"",y=l.length-c.length-1;return{filter:c,start:y,end:i}}function us({projectId:a,onClose:i,onCreate:l}){const[o,c]=s.useState("agent"),[y,N]=s.useState([]),[$,b]=s.useState(!0),[D,z]=s.useState(""),[p,F]=s.useState([]),[C,M]=s.useState(!0),[g,x]=s.useState(""),[T,k]=s.useState([]),[H,L]=s.useState([]);s.useEffect(()=>{let h=!1;return b(!0),ze(void 0,a).then(j=>{h||N(j)}).catch(()=>{h||N([])}).finally(()=>{h||b(!1)}),()=>{h=!0}},[a]),s.useEffect(()=>{M(!0),ns().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 j=T,O=j.includes(h)?j.filter(V=>V!==h):[h,...j];k(O);try{await tt({favoriteProviders:O,favoriteModels:H})}catch{k(j)}},[T,H]),K=s.useCallback(async h=>{const j=H,O=j.includes(h)?j.filter(V=>V!==h):[h,...j];L(O);try{await tt({favoriteProviders:T,favoriteModels:O})}catch{L(j)}},[H,T]),_=h=>{if(h.preventDefault(),o==="agent"){if(!D)return;l({agentId:D});return}if(!g)return;const j=g.indexOf("/");if(j<=0)return;const v=g.slice(0,j),O=g.slice(j+1);l({agentId:De,modelProvider:v,modelId:O})},X=o==="agent"?!D:!g;return t.jsx("div",{className:"chat-new-dialog-backdrop",onClick:i,role:"dialog","aria-modal":"true",children:t.jsxs("div",{className:"chat-new-dialog",onClick:h=>h.stopPropagation(),children:[t.jsx("h3",{children:"New Chat"}),t.jsxs("div",{className:"chat-new-dialog-mode-toggle","data-testid":"chat-new-dialog-mode-toggle",children:[t.jsx("button",{type:"button",className:`chat-new-dialog-mode-btn${o==="agent"?" chat-new-dialog-mode-btn--active":""}`,"data-testid":"chat-new-dialog-mode-agent",onClick:()=>{c("agent"),x("")},children:"Agent"}),t.jsx("button",{type:"button",className:`chat-new-dialog-mode-btn${o==="model"?" chat-new-dialog-mode-btn--active":""}`,"data-testid":"chat-new-dialog-mode-model",onClick:()=>{c("model"),z("")},children:"Model"})]}),t.jsxs("form",{onSubmit:_,children:[o==="agent"&&t.jsxs("label",{className:"chat-new-dialog-model-label",children:["Agent",$?t.jsx("div",{className:"chat-new-dialog-loading",children:"Loading agents..."}):y.length===0?t.jsx("div",{className:"chat-new-dialog-empty",children:"No agents available"}):t.jsx("div",{className:"chat-new-dialog-agent-list",children:y.map(h=>t.jsxs("button",{type:"button",className:`chat-new-dialog-agent-item${D===h.id?" chat-new-dialog-agent-item--selected":""}`,onClick:()=>z(h.id),"data-testid":`agent-option-${h.id}`,children:[t.jsx(Ee,{size:16}),t.jsx("span",{className:"chat-new-dialog-agent-name",children:h.name}),t.jsx("span",{className:"chat-new-dialog-agent-role",children:h.role})]},h.id))})]}),o==="model"&&t.jsx("div",{className:"chat-new-dialog-model-dropdown","data-testid":"chat-new-dialog-model-section",children:C?t.jsx("div",{className:"chat-new-dialog-loading",children:"Loading models..."}):t.jsx(as,{models:p,value:g,onChange:x,label:"Model",placeholder:"Select a model",favoriteProviders:T,onToggleFavorite:ee,favoriteModels:H,onToggleModelFavorite:K})}),t.jsxs("div",{className:"chat-new-dialog-actions",children:[t.jsx("button",{type:"button",className:"btn btn-sm",onClick:i,children:"Cancel"}),t.jsx("button",{type:"submit",className:"btn btn-sm btn-primary",disabled:X,children:"Create"})]})]})]})})}const hs=s.memo(function({message:i,forcePlain:l,agentName:o,showAssistantModelTag:c,activeModelTag:y,activeSessionId:N,mentionAgentsByName:$,onToggleRender:b}){const D=i.role==="assistant",z=s.useMemo(()=>{if(D)return null;const C=i.content,M=/@([\w-]+)/g,g=[];let x=0,T=M.exec(C);for(;T;){const[k,H=""]=T,L=T.index;L>x&&g.push(C.slice(x,L));const ee=H.replace(/_/g," ").toLowerCase(),K=$.get(ee);K?g.push(t.jsxs("span",{className:"chat-mention-chip",children:["@",K.name.replace(/\s+/g,"_")]},`${K.id}-${L}`)):g.push(k),x=L+k.length,T=M.exec(C)}return x<C.length&&g.push(C.slice(x)),g.length===0?C:g},[D,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 t.jsx("div",{className:"chat-message-attachments",children:C.map(g=>{const x=g.mimeType.startsWith("image/"),T=g.id||g.filename,k=`${M}${encodeURIComponent(g.filename)}`;return x?t.jsx("a",{className:"chat-message-attachment-link","data-testid":"chat-message-attachment",href:k,target:"_blank",rel:"noopener noreferrer",children:t.jsx("img",{className:"chat-message-attachment",src:k,alt:g.originalName})},T):t.jsxs("a",{className:"chat-message-attachment-file","data-testid":"chat-message-attachment",href:k,target:"_blank",rel:"noopener noreferrer",children:[t.jsx(ss,{size:14}),t.jsx("span",{children:g.originalName})]},T)})})},[i.attachments,N]),F=s.useMemo(()=>D?l?t.jsx("div",{className:"chat-message-content chat-message-content--plain",children:i.content}):t.jsx("div",{className:"chat-message-content chat-message-content--markdown",children:t.jsx(it,{remarkPlugins:[rt],components:ut,children:i.content})}):null,[D,l,i.content]);return t.jsxs("div",{className:`chat-message chat-message--${i.role}`,"data-testid":`chat-message-${i.id}`,children:[D&&t.jsxs("div",{className:"chat-message-avatar",children:[t.jsx(Ee,{size:14}),t.jsx("span",{children:o}),c&&y&&t.jsx("span",{className:"chat-model-tag",children:y}),t.jsx("button",{type:"button",className:`chat-message-render-toggle${l?" chat-message-render-toggle--plain":""}`,"data-testid":"chat-message-render-toggle","aria-label":l?"Show rendered markdown":"Show plain text",onClick:()=>b(i.id),children:l?t.jsx(lt,{size:14}):t.jsx(ot,{size:14})})]}),D?F:t.jsx("div",{className:"chat-message-content",children:z}),dt(i.toolCalls),i.thinkingOutput&&t.jsxs("details",{className:"chat-message-thinking",children:[t.jsx("summary",{children:"Thinking"}),t.jsx("pre",{className:"chat-message-thinking-content",children:i.thinkingOutput})]}),p,t.jsx("div",{className:"chat-message-time",children:ct(i.createdAt)})]})});function vs({projectId:a,addToast:i}){const{activeSession:l,sessionsLoading:o,messages:c,messagesLoading:y,isStreaming:N,streamingText:$,streamingThinking:b,streamingToolCalls:D,selectSession:z,createSession:p,archiveSession:F,deleteSession:C,sendMessage:M,stopStreaming:g,pendingMessage:x,clearPendingMessage:T,searchQuery:k,setSearchQuery:H,filteredSessions:L}=rs(a),[ee,K]=s.useState(!1),[_,X]=s.useState(""),[h,j]=s.useState(null),[v,O]=s.useState(null),[V,de]=s.useState(!0),[ue,pe]=s.useState(new Map),[xe,ve]=s.useState([]),[he,ye]=s.useState(!0),[Y,se]=s.useState(!1),[le,ne]=s.useState(""),[we,me]=s.useState(0),[Se,oe]=s.useState(""),[te,ce]=s.useState(!1),[fe,be]=s.useState(0),[u,f]=s.useState(-1),[m,R]=s.useState(()=>new Set),[I,ae]=s.useState([]),[q,J]=s.useState(!1),[,B]=s.useState(!1),[G,E]=s.useState({top:0,left:0}),d=Vt({projectId:a}),U=s.useCallback(e=>{if(!e||!d.mentionActive)return;const n=e.getBoundingClientRect();E({top:n.top-260,left:n.left+8})},[d.mentionActive]),w=s.useRef(null),S=s.useRef(null),W=s.useRef(null),A=s.useRef(null),Ce=s.useRef(!1),Me=s.useRef(!1),He=s.useRef(null),Ve=s.useRef([]),Ne=s.useRef(0),ie=qt()==="mobile",{keyboardOverlap:Pe,viewportHeight:qe,viewportOffsetTop:ht,keyboardOpen:Fe}=Bt({enabled:ie&&!!l}),mt=Fe?{"--keyboard-overlap":`${Pe}px`,"--vv-offset-top":`${ht}px`,...qe!==null?{"--vv-height":`${qe}px`}:{}}:{},Z=s.useMemo(()=>{const e=le.trim().toLowerCase();return(e?xe.filter(r=>r.name.toLowerCase().includes(e)):xe).slice(0,10)},[xe,le]),ke=s.useMemo(()=>Array.from(ue.values()),[ue]),ge=s.useMemo(()=>{const e=Se.trim().toLowerCase();return e?ke.filter(n=>n.name.toLowerCase().includes(e)):ke},[ke,Se]),ft=s.useMemo(()=>{const e=new Map;for(const n of ke)e.set(n.name.toLowerCase(),n);return e},[ke]);s.useEffect(()=>{me(0)},[Z]),s.useEffect(()=>{be(0)},[Se,te]),s.useEffect(()=>()=>{S.current!==null&&window.clearTimeout(S.current)},[]),s.useEffect(()=>{const e=W.current;e&&(e.scrollTop=e.scrollHeight)},[c,$]),s.useEffect(()=>{if(Pe<=0)return;const e=W.current;e&&(e.scrollTop=e.scrollHeight)},[Pe]),s.useEffect(()=>{if(!ie||!Fe)return;const e=document.documentElement,n=document.body,r={htmlOverflow:e.style.overflow,bodyOverflow:n.style.overflow};return e.style.overflow="hidden",n.style.overflow="hidden",()=>{e.style.overflow=r.htmlOverflow,n.style.overflow=r.bodyOverflow}},[ie,Fe]),s.useEffect(()=>{const e=()=>j(null);if(h)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[h]),s.useEffect(()=>{let e=!1;const n=a;return ze(void 0,a).then(r=>{if(e||n!==a)return;const P=new Map;for(const Q of r)P.set(Q.id,Q);pe(P)}).catch(()=>{}),()=>{e=!0}},[a]),s.useEffect(()=>{let e=!1;return ye(!0),Gt(a).then(n=>{e||ve(n)}).catch(()=>{e||ve([])}).finally(()=>{e||ye(!1)}),()=>{e=!0}},[a]),s.useEffect(()=>{Ve.current=I},[I]),s.useEffect(()=>()=>{for(const e of Ve.current)e.previewUrl&&URL.revokeObjectURL(e.previewUrl)},[]);const Te=s.useCallback(e=>{if(!e||e.length===0)return;const n=[];for(const r of Array.from(e)){if(!cs.includes(r.type))continue;const P=r.type.startsWith("image/");n.push({file:r,previewUrl:P?URL.createObjectURL(r):""})}n.length>0&&ae(r=>[...r,...n])},[]),gt=s.useCallback(e=>{ae(n=>{const r=n[e];return r?.previewUrl&&URL.revokeObjectURL(r.previewUrl),n.filter((P,Q)=>Q!==e)})},[]),pt=s.useCallback(e=>{const n=e.clipboardData?.files;if(!n||n.length===0)return;const r=Array.from(n).filter(P=>P.type.startsWith("image/"));r.length!==0&&Te(r)},[Te]),xt=s.useCallback(async e=>{try{await p(e),K(!1),ie&&de(!1)}catch{i("Failed to create chat session","error")}},[p,i,ie]),je=s.useCallback(()=>{const e=_.trim(),n=I.map(r=>r.file);!e&&n.length===0||!l||(X(""),se(!1),ne(""),ce(!1),oe(""),f(-1),M(e,n),ae(r=>{for(const P of r)P.previewUrl&&URL.revokeObjectURL(P.previewUrl);return[]}))},[_,I,l,M]),Ae=s.useCallback(()=>{if(typeof window>"u"||window.innerWidth>768)return;const e=A.current;if(!e||e.disabled)return;const n=window.scrollX,r=window.scrollY;e.focus({preventScroll:!0}),window.requestAnimationFrame(()=>{(window.scrollX!==n||window.scrollY!==r)&&window.scrollTo(n,r)})},[]),Be=s.useCallback(()=>{typeof window>"u"||window.innerWidth>768||(Ce.current=!0)},[]),Le=s.useCallback(e=>{X(n=>{const r=at(n);if(!r)return n;const P=`/skill:${e.name} `,Q=n.slice(0,r.start)+P+n.slice(r.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())}),Q}),se(!1),ne(""),me(0)},[]),_e=s.useCallback(e=>{const n=A.current;if(!n||u<0)return;const r=n.selectionStart??Ne.current,P=n.selectionEnd??r,Q=Math.max(r,P),Ye=Math.min(u,Q),Je=`${`@${e.name.replace(/\s+/g,"_")}`} `,Rt=_.slice(0,Ye)+Je+_.slice(Q),Qe=Ye+Je.length;X(Rt),ce(!1),oe(""),be(0),f(-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,_]),vt=s.useCallback(e=>{if(Ne.current=e.currentTarget.selectionStart??Ne.current,d.mentionActive&&d.files.length>0){if(d.handleKeyDown(e,_),e.key==="Enter"||e.key==="Tab"){const n=d.files[d.selectedIndex];if(n){const r=d.selectFile(n,_);X(r),d.dismissMention(),B(!1)}}return}if(te&&e.key==="ArrowDown"){e.preventDefault(),ge.length>0&&be(n=>(n+1)%ge.length);return}if(te&&e.key==="ArrowUp"){e.preventDefault(),ge.length>0&&be(n=>n===0?ge.length-1:n-1);return}if(te&&e.key==="Enter"){e.preventDefault();const n=ge[fe]??ge[0];n&&_e(n);return}if(te&&e.key==="Escape"){e.preventDefault(),ce(!1),oe(""),f(-1);return}if(Y&&e.key==="ArrowDown"){e.preventDefault(),Z.length>0&&me(n=>(n+1)%Z.length);return}if(Y&&e.key==="ArrowUp"){e.preventDefault(),Z.length>0&&me(n=>n===0?Z.length-1:n-1);return}if(Y&&(e.key==="Enter"||e.key==="Tab")&&Z.length>0){e.preventDefault();const n=Z[we]??Z[0];n&&Le(n);return}if(Y&&e.key==="Escape"){e.preventDefault(),se(!1);return}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),je())},[te,ge,fe,_e,Y,Z,we,Le,je,d,_]),$e=s.useCallback((e,n)=>{const r=ds(e,n);if(r){ce(!0),oe(r.filter),f(r.start);return}ce(!1),oe(""),f(-1)},[]),wt=s.useCallback(e=>{const n=e.target,r=n.value,P=n.selectionStart??r.length;Ne.current=P,X(r);const Q=at(r);Q?(se(!0),ne(Q.filter)):(se(!1),ne("")),$e(r,P),d.detectMention(r,P),B(d.mentionActive),d.mentionActive&&U(n),n.style.height="auto",n.style.height=`${Math.min(n.scrollHeight,120)}px`},[$e]),Oe=s.useCallback(e=>{const n=e.currentTarget,r=n.selectionStart??n.value.length;Ne.current=r,$e(n.value,r),d.detectMention(n.value,r),B(d.mentionActive),d.mentionActive&&U(n)},[$e,d,U]),St=s.useCallback(e=>{e.key!=="Escape"&&Oe(e)},[Oe]),bt=s.useCallback(()=>{if(Ce.current){window.requestAnimationFrame(()=>{Ae()});return}S.current!==null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{se(!1),ce(!1),oe(""),f(-1),B(!1),d.dismissMention(),S.current=null},120)},[d,Ae]),kt=s.useCallback(()=>{S.current!==null&&(window.clearTimeout(S.current),S.current=null)},[]),yt=s.useCallback(async e=>{j(null);try{await F(e),i("Conversation archived","success")}catch{i("Failed to archive conversation","error")}},[F,i]),Nt=s.useCallback(async e=>{O(null),j(null);try{await C(e),i("Conversation deleted","success")}catch{i("Failed to delete conversation","error")}},[C,i]),jt=s.useCallback(e=>{z(e),ie&&de(!1)},[z,ie]),Ct=s.useCallback(()=>{z(""),de(!0)},[z]),Mt=()=>t.jsxs("div",{className:"chat-empty-state",children:[t.jsx(ts,{size:48,strokeWidth:1.5}),t.jsx("h2",{children:"Start a new conversation"}),t.jsxs("button",{className:"btn btn-primary",onClick:()=>K(!0),children:[t.jsx(Ze,{size:16}),"New Chat"]})]}),re=nt(l?.modelProvider,l?.modelId),Ge=l?.agentId===De?re??"Fusion":l?.title||ue.get(l?.agentId??"")?.name||l?.agentId||"Chat",Tt=!!(re&&re!==Ge),Ie=ue.get(l?.agentId??"")?.name||(l?.agentId===De?re??"Fusion":l?.agentId?.slice(0,30)??"Fusion"),We=!!(re&&re!==Ie),At=x.length>50?`${x.slice(0,50)}…`:x,Ke=s.useCallback(e=>{R(n=>{const r=new Set(n);return r.has(e)?r.delete(e):r.add(e),r})},[]),$t=s.useCallback((e,n=!1)=>n?t.jsx("div",{className:"chat-message-content chat-message-content--plain",children:e}):t.jsx("div",{className:"chat-message-content chat-message-content--markdown",children:t.jsx(it,{remarkPlugins:[rt],components:ut,children:e})}),[]);return t.jsxs("div",{className:"chat-view",children:[t.jsxs("div",{className:`chat-sidebar${V?"":" chat-sidebar--hidden"}`,children:[t.jsx("div",{className:"chat-sidebar-search",children:t.jsxs("div",{className:"chat-sidebar-search-wrapper",children:[t.jsx(Wt,{size:14,className:"chat-sidebar-search-icon"}),t.jsx("input",{type:"text",className:"chat-sidebar-search",placeholder:"Search conversations...",value:k,onChange:e=>H(e.target.value),"data-testid":"chat-search-input"})]})}),t.jsx("div",{className:"chat-session-list chat-sidebar-list",children:o?t.jsx("div",{style:{padding:"12px",color:"var(--text-secondary)",fontSize:"13px"},children:"Loading..."}):L.length===0?t.jsx("div",{style:{padding:"12px",color:"var(--text-secondary)",fontSize:"13px"},children:"No conversations yet"}):L.map(e=>t.jsxs("div",{className:`chat-session-item${l?.id===e.id?" chat-session-item--active":""}`,onClick:()=>jt(e.id),onContextMenu:n=>{n.preventDefault(),j({sessionId:e.id,x:n.clientX,y:n.clientY})},"data-testid":`chat-session-${e.id}`,children:[t.jsx("button",{className:"chat-session-delete-btn",onClick:n=>{n.stopPropagation(),O(e.id)},"data-testid":"chat-session-delete-btn","aria-label":"Delete conversation",children:t.jsx(Xe,{size:14})}),t.jsx("div",{className:"chat-session-title",children:e.title||"Untitled"}),t.jsx("div",{className:"chat-session-preview",children:e.lastMessagePreview||"No messages"}),t.jsxs("div",{className:"chat-session-meta",children:[t.jsx("span",{children:ue.get(e.agentId)?.name||(e.agentId===De?nt(e.modelProvider,e.modelId)??"Fusion":e.agentId.slice(0,30))}),t.jsx("span",{children:e.updatedAt?ct(e.updatedAt):""})]})]},e.id))}),t.jsx("div",{className:"chat-sidebar-footer",children:t.jsxs("button",{className:"btn btn-sm btn-primary chat-sidebar-footer-btn",onClick:()=>K(!0),"data-testid":"chat-new-btn",children:[t.jsx(Ze,{size:14}),"New Chat"]})})]}),h&&t.jsxs("div",{className:"chat-session-context-menu",style:{top:h.y,left:h.x},onClick:e=>e.stopPropagation(),children:[t.jsxs("button",{onClick:()=>yt(h.sessionId),"data-testid":"chat-context-archive",children:[t.jsx(Kt,{size:14}),"Archive"]}),t.jsxs("button",{onClick:()=>{j(null),O(h.sessionId)},"data-testid":"chat-context-delete",children:[t.jsx(Xe,{size:14}),"Delete"]})]}),v&&t.jsx("div",{className:"chat-new-dialog-backdrop",onClick:()=>O(null),children:t.jsxs("div",{className:"chat-new-dialog",onClick:e=>e.stopPropagation(),children:[t.jsx("h3",{children:"Delete Conversation?"}),t.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."}),t.jsxs("div",{className:"chat-new-dialog-actions",children:[t.jsx("button",{className:"btn btn-sm",onClick:()=>O(null),children:"Cancel"}),t.jsx("button",{className:"btn btn-sm btn-danger",onClick:()=>void Nt(v),children:"Delete"})]})]})}),t.jsxs("div",{className:"chat-thread",style:mt,children:[(l||!ie)&&t.jsxs("div",{className:"chat-thread-header",children:[ie&&l&&t.jsx("button",{className:"btn-icon",onClick:Ct,"data-testid":"chat-back-btn",children:t.jsx(Yt,{size:16})}),t.jsx(Ee,{size:16}),t.jsx("span",{className:"chat-thread-header-title",children:Ge}),Tt&&t.jsx("span",{className:"chat-model-tag",children:re})]}),t.jsxs("div",{className:"chat-messages",ref:W,children:[y?t.jsx("div",{style:{color:"var(--text-secondary)",fontSize:"13px"},children:"Loading messages..."}):c.length===0&&!l?Mt():c.length===0&&l?t.jsx("div",{style:{color:"var(--text-secondary)",fontSize:"13px"},children:"No messages yet. Start the conversation!"}):t.jsxs(t.Fragment,{children:[c.map(e=>t.jsx(hs,{message:e,forcePlain:m.has(e.id),agentName:Ie,showAssistantModelTag:We,activeModelTag:re,activeSessionId:l?.id??null,mentionAgentsByName:ft,onToggleRender:Ke},e.id)),N&&t.jsxs("div",{className:"chat-message chat-message--assistant chat-message--streaming",children:[t.jsxs("div",{className:"chat-message-avatar",children:[t.jsx(Ee,{size:14}),t.jsx("span",{children:Ie}),We&&t.jsx("span",{className:"chat-model-tag",children:re}),t.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:()=>Ke("__streaming__"),children:m.has("__streaming__")?t.jsx(lt,{size:14}):t.jsx(ot,{size:14})})]}),$?$t($,m.has("__streaming__")):t.jsx("div",{className:"chat-message-content chat-message-content--waiting",children:b?"Thinking…":"Connecting…"}),dt(D),b&&t.jsxs("details",{className:"chat-message-thinking",children:[t.jsx("summary",{children:"Thinking"}),t.jsx("pre",{className:"chat-message-thinking-content",children:b})]}),t.jsxs("div",{className:"chat-typing-indicator",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]})]})]}),t.jsx("div",{ref:w})]}),l&&t.jsxs("div",{className:"chat-input-area",children:[t.jsx("input",{ref:He,type:"file",accept:"image/*,.txt,.json,.yaml,.yml,.log,.csv,.xml,.md",multiple:!0,style:{display:"none"},onChange:e=>{Te(e.target.files),e.target.value=""}}),Y&&t.jsx("div",{className:"chat-skill-menu","data-testid":"chat-skill-menu",role:"listbox","aria-label":"Skill suggestions",children:he?t.jsx("div",{className:"chat-skill-menu-empty",children:"Loading skills…"}):Z.length===0?t.jsx("div",{className:"chat-skill-menu-empty",children:le?"No skills found":"No skills available"}):Z.map((e,n)=>t.jsxs("button",{type:"button",role:"option","aria-selected":n===we,className:`chat-skill-menu-item${n===we?" chat-skill-menu-item--highlighted":""}`,onMouseDown:r=>r.preventDefault(),onMouseEnter:()=>me(n),onClick:()=>Le(e),children:[t.jsx("span",{className:"chat-skill-menu-item-name",children:e.name}),t.jsx("span",{className:"chat-skill-menu-item-description",title:e.relativePath,children:e.relativePath})]},e.id))}),I.length>0&&t.jsx("div",{className:"chat-attachment-previews","data-testid":"chat-attachment-previews",children:I.map((e,n)=>t.jsxs("div",{className:"chat-attachment-preview","data-testid":`chat-attachment-preview-${n}`,children:[e.previewUrl?t.jsx("img",{src:e.previewUrl,alt:e.file.name}):t.jsx("span",{className:"chat-attachment-preview-name",children:e.file.name}),t.jsx("button",{type:"button",className:"chat-attachment-remove",onClick:()=>gt(n),"data-testid":`chat-attachment-remove-${n}`,"aria-label":`Remove ${e.file.name}`,children:"×"})]},e.previewUrl||`${e.file.name}-${n}`))}),t.jsxs("div",{className:"chat-input-row",children:[t.jsx("button",{type:"button",className:"btn-icon chat-attach-btn","data-testid":"chat-attach-btn","aria-label":"Attach files",onClick:()=>He.current?.click(),children:t.jsx(Jt,{size:16})}),t.jsxs("div",{className:`chat-input-wrapper${q?" chat-input-wrapper--dragover":""}`,onDragOver:e=>{e.preventDefault(),J(!0)},onDragLeave:()=>J(!1),onDrop:e=>{e.preventDefault(),J(!1),Te(e.dataTransfer.files)},children:[t.jsx("textarea",{ref:A,className:"chat-input-textarea",placeholder:"Type a message...",value:_,onChange:wt,onKeyDown:vt,onKeyUp:St,onClick:Oe,onBlur:bt,onFocus:kt,onPaste:pt,onTouchStart:e=>{typeof window>"u"||window.innerWidth>768||document.activeElement!==e.currentTarget&&(e.preventDefault(),e.currentTarget.focus({preventScroll:!0}))},rows:1,"data-testid":"chat-input"}),t.jsx(Qt,{agents:ke,filter:Se,highlightedIndex:fe,visible:te,onSelect:_e,position:"below"}),t.jsx(Xt,{visible:d.mentionActive&&!te,position:G,files:d.files,selectedIndex:d.selectedIndex,onSelect:e=>{const n=d.selectFile(e,_);X(n),d.dismissMention(),B(!1),A.current?.focus()},loading:d.loading}),x&&t.jsxs("div",{className:"chat-pending-message","data-testid":"chat-pending-indicator",children:[t.jsx("span",{children:`Queued: ${At}`}),t.jsx("button",{type:"button",className:"chat-pending-message-dismiss","aria-label":"Dismiss queued message","data-testid":"chat-pending-dismiss",onClick:T,children:"×"})]})]}),N?t.jsx("button",{className:"chat-input-stop",onClick:g,"aria-label":"Stop generation","data-testid":"chat-stop-btn",children:t.jsx(Zt,{size:14})}):t.jsx("button",{type:"button",className:"chat-input-send",onPointerDown:e=>{typeof window>"u"||window.innerWidth>768||(e.preventDefault(),e.pointerType&&e.pointerType!=="mouse"&&(Me.current=!0,Be(),Ae(),je(),window.setTimeout(()=>{Ce.current=!1},1500)))},onTouchStart:e=>{typeof window>"u"||window.innerWidth>768||(e.preventDefault(),Me.current=!0,Be(),Ae(),je(),window.setTimeout(()=>{Ce.current=!1},1500))},onMouseDown:e=>{typeof window>"u"||window.innerWidth>768||e.preventDefault()},onClick:()=>{if(Me.current){Me.current=!1;return}je()},disabled:!_.trim()&&I.length===0,"data-testid":"chat-send-btn",children:t.jsx(es,{size:16})})]})]})]}),ee&&t.jsx(us,{projectId:a,onClose:()=>K(!1),onCreate:xt})]})}export{vs as ChatView};
@@ -1,11 +0,0 @@
1
- import{r as l,j as e}from"./vendor-react-K0fH_qHe.js";import{c as W,dW as Z,dX as H,dY as J,R as $,dO as y,M as V,_ as T,Q as ee,Y as se,cr as L,F as _,dZ as ae,d_ as te,d$ as D,X as ie}from"./index-CLAHcGnI.js";import"./vendor-xterm-DzcZoU0P.js";/**
2
- * @license lucide-react v1.7.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ne=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],M=W("palette",ne);/**
7
- * @license lucide-react v1.7.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const le=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],O=W("puzzle",le);function ce(t){return t.replace(/-/g,"-")}function re(t){return{"fusion-global":"Fusion Global","pi-global":"Pi Global","fusion-project":"Fusion Project","pi-project":"Pi Project",package:"Package"}[t]??t}function oe(t){return t.startsWith("npm:")?"npm":t.startsWith("git:")?"git":"local"}function de(t){return t.replace(/^(npm:|git:)/,"")}function he({addToast:t,projectId:x}){const[c,A]=l.useState(null),[f,P]=l.useState(!0),[N,S]=l.useState(!1),[E,w]=l.useState(!1),[h,F]=l.useState(""),[G,I]=l.useState(new Set),[p,X]=l.useState([]),[b,z]=l.useState(!0),[Y,C]=l.useState(!1),r=l.useCallback(async()=>{try{P(!0);const s=await Z();A(s)}catch(s){t(`Failed to load Pi settings: ${s instanceof Error?s.message:String(s)}`,"error")}finally{P(!1)}},[t]),m=l.useCallback(async()=>{try{z(!0);const s=await H(x);X(s.extensions)}catch(s){t(`Failed to load extensions: ${s instanceof Error?s.message:String(s)}`,"error")}finally{z(!1)}},[t,x]),q=l.useCallback(async s=>{try{C(!0);const i=s.enabled?[...p.filter(a=>a.enabled&&a.id!==s.id).map(a=>a.id),s.id]:p.filter(a=>a.enabled&&a.id!==s.id).map(a=>a.id);await J(i,x),await m(),t(s.enabled?"Extension disabled":"Extension enabled","success")}catch(i){t(`Failed to update extension: ${i instanceof Error?i.message:String(i)}`,"error")}finally{C(!1)}},[p,x,m,t]);l.useEffect(()=>{r()},[r]),l.useEffect(()=>{m()},[m]);const B=s=>{I(i=>{const a=new Set(i);return a.has(s)?a.delete(s):a.add(s),a})},R=async()=>{if(!h.trim()){t("Please enter a package source","error");return}try{S(!0),await ae(h.trim()),t("Package installed successfully","success"),F(""),await r()}catch(s){t(`Failed to install package: ${s instanceof Error?s.message:String(s)}`,"error")}finally{S(!1)}},K=async()=>{try{w(!0),await te(x),await Promise.all([r(),m()]),t("Fusion skill reinstalled successfully","success")}catch(s){t(`Failed to reinstall Fusion skill: ${s instanceof Error?s.message:String(s)}`,"error")}finally{w(!1)}},Q=async s=>{if(!c)return;const i=c.packages.filter(a=>(typeof a=="string"?a:a.source)!==s);try{await D({packages:i}),t("Package removed","success"),await r()}catch(a){t(`Failed to remove package: ${a instanceof Error?a.message:String(a)}`,"error")}},U=async(s,i)=>{if(!c)return;const a=c[s].filter(n=>n!==i);try{await D({[s]:a}),t(`${s.slice(0,-1)} removed`,"success"),await r()}catch(n){t(`Failed to update settings: ${n instanceof Error?n.message:String(n)}`,"error")}},u=(s,i,a)=>!c||c[a].length===0?null:e.jsxs("div",{className:"pi-ext-section",children:[e.jsxs("div",{className:"pi-ext-section-header",children:[e.jsx(i,{size:14}),e.jsx("span",{children:s}),e.jsx("span",{className:"pi-ext-count",children:c[a].length})]}),e.jsx("div",{className:"pi-ext-resource-list",children:c[a].map((n,g)=>e.jsxs("span",{className:"pi-ext-resource-tag",children:[e.jsx("span",{className:"pi-ext-resource-path",children:n}),e.jsx("button",{className:"btn-icon touch-target pi-ext-resource-remove",onClick:()=>U(a,n),title:`Remove ${n}`,"aria-label":`Remove ${n}`,children:e.jsx(ie,{size:12})})]},g))})]});return e.jsxs("div",{className:"pi-ext-manager",children:[e.jsxs("div",{className:"pi-ext-manager-header",children:[e.jsx("h4",{className:"pi-ext-manager-title",children:"Pi Extensions"}),e.jsx("div",{className:"pi-ext-manager-actions",children:e.jsx("button",{className:"btn-icon",onClick:r,title:"Refresh",disabled:f,children:e.jsx($,{size:16,className:f?"spin":""})})})]}),f?e.jsx("div",{className:"loading-state",children:"Loading Pi settings…"}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pi-ext-add-form",children:[e.jsxs("div",{className:"pi-ext-add-form-row",children:[e.jsx("input",{type:"text",className:"input",placeholder:"npm:pi-extension-name or git:https://github.com/...",value:h,onChange:s=>F(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),R())},disabled:N}),e.jsxs("button",{className:"btn btn-primary",onClick:R,disabled:N||!h.trim(),children:[e.jsx(V,{size:14}),N?"Installing…":"Add"]})]}),e.jsx("div",{className:"pi-ext-add-form-row",children:e.jsx("button",{className:"btn",onClick:K,disabled:E,children:E?"Reinstalling Fusion…":"Reinstall Fusion skill"})})]}),c.packages.length>0?e.jsx("div",{className:"pi-ext-package-list",children:c.packages.map((s,i)=>{const a=typeof s=="string"?s:s.source,n=oe(a),g=de(a),j=typeof s=="object"&&s!==null,v=j&&(s.extensions?.length??0)>0||(s.skills?.length??0)>0||(s.prompts?.length??0)>0||(s.themes?.length??0)>0,k=G.has(i);return e.jsxs("div",{className:"pi-ext-package-card",children:[e.jsxs("div",{className:"pi-ext-package-header",children:[j&&v?e.jsx("button",{className:"pi-ext-expand-btn",onClick:()=>B(i),"aria-expanded":k,children:k?e.jsx(T,{size:14}):e.jsx(ee,{size:14})}):e.jsx("span",{className:"pi-ext-expand-placeholder"}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${n}`,children:n}),e.jsx("span",{className:"pi-ext-package-source",children:g}),e.jsxs("div",{className:"pi-ext-package-actions",children:[j&&v&&e.jsxs("span",{className:"pi-ext-filter-hint",children:[s.extensions?.length??0," ext,"," ",s.skills?.length??0," skill,"," ",s.prompts?.length??0," prompt,"," ",s.themes?.length??0," theme"]}),e.jsx("button",{className:"btn-icon touch-target pi-ext-remove-btn",onClick:()=>Q(a),title:"Remove package","aria-label":`Remove package ${g}`,children:e.jsx(se,{size:14})})]})]}),j&&v&&k&&e.jsxs("div",{className:"pi-ext-filter-list",children:[s.extensions?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(O,{size:12}),e.jsx("span",{className:"pi-ext-filter-label",children:"Extensions:"}),s.extensions.map((o,d)=>e.jsx("span",{className:"pi-ext-filter-tag",children:o},d))]}):null,s.skills?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(L,{size:12}),e.jsx("span",{className:"pi-ext-filter-label",children:"Skills:"}),s.skills.map((o,d)=>e.jsx("span",{className:"pi-ext-filter-tag",children:o},d))]}):null,s.prompts?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(_,{size:12}),e.jsx("span",{className:"pi-ext-filter-label",children:"Prompts:"}),s.prompts.map((o,d)=>e.jsx("span",{className:"pi-ext-filter-tag",children:o},d))]}):null,s.themes?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(M,{size:12}),e.jsx("span",{className:"pi-ext-filter-label",children:"Themes:"}),s.themes.map((o,d)=>e.jsx("span",{className:"pi-ext-filter-tag",children:o},d))]}):null]})]},i)})}):e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:"No packages configured."}),e.jsx("p",{className:"text-muted",children:"Add a package source above to get started."})]}),e.jsxs("div",{className:"pi-ext-top-level",children:[u("Extensions",O,"extensions"),u("Skills",L,"skills"),u("Prompts",_,"prompts"),u("Themes",M,"themes")]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:"Failed to load Pi settings."})]}),e.jsxs("div",{className:"pi-ext-discovered-section",children:[e.jsxs("div",{className:"pi-ext-discovered-header",children:[e.jsx("h4",{children:"Discovered Extensions"}),e.jsx("button",{className:"btn-icon",onClick:m,disabled:b,title:"Refresh extensions",children:e.jsx($,{size:14,className:b?"spin":""})})]}),e.jsx("p",{className:"pi-ext-description",children:"Installed extensions resolved from packages and configured paths."}),b?e.jsx("div",{className:"loading-state",children:"Loading extensions…"}):p.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:"No extensions discovered."})]}):e.jsx("div",{className:"pi-ext-list",children:p.map(s=>e.jsxs("div",{className:"pi-ext-item",children:[e.jsxs("div",{className:"pi-ext-item-content",children:[e.jsxs("div",{className:"pi-ext-info",children:[e.jsx("span",{className:"pi-ext-name",children:s.name}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${ce(s.source)}`,children:re(s.source)})]}),e.jsx("span",{className:"pi-ext-path",children:s.path})]}),e.jsx("div",{className:"pi-ext-actions",children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>void q(s),disabled:Y,"aria-label":`Toggle ${s.name}`}),e.jsx("span",{className:"toggle-slider"})]})})]},s.id))})]})]})}export{he as PiExtensionsManager};
@@ -1 +0,0 @@
1
- import{r as u,j as s}from"./vendor-react-K0fH_qHe.js";import{y as ee,dM as se,s as ne,X as k,ap as te,M as O,dN as A,Y as M,R as ie,dO as ae,aH as le,ch as re,dP as ce,dQ as de,dR as ue,dS as oe,dT as _,ce as ge}from"./index-CLAHcGnI.js";import{D as me}from"./DirectoryPicker-DVmy6sLM.js";import"./vendor-xterm-DzcZoU0P.js";import"./folder-open-D11gjHGK.js";const H=[{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),[V,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({}),[G,R]=u.useState(!1),[$,E]=u.useState(null),{confirm:J}=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 K=u.useRef([]);K.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 _({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 _({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")}},B=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")}},L=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 J({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)}},Y=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"}),G?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:Y,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:()=>L(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:()=>B(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(M,{size:14})," Uninstall"]})]})]})]});const W=new Set(N.map(e=>e.id)),Z=new Set(H.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:H.map(e=>{const n=W.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"]})]})]}),V&&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:()=>L(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?B(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(M,{size:14})})]})]},e.id))}),T()]})]})}export{fe as PluginManager,j as STATE_COLORS};
@@ -1 +0,0 @@
1
- .prompt-manager{display:flex;flex-direction:column;gap:var(--space-md);padding:0 20px;margin-top:var(--space-md)}.prompt-manager-tabs{display:flex;gap:var(--space-xs);border-bottom:1px solid var(--border);padding-bottom:var(--space-sm)}.prompt-manager-tab{display:inline-flex;align-items:center;gap:var(--space-xs);padding:var(--space-sm) var(--space-md);background:none;border:1px solid transparent;border-radius:var(--radius-md);color:var(--text-muted);font-size:13px;cursor:pointer;transition:all var(--transition-fast)}.prompt-manager-tab:hover{color:var(--text);background:var(--surface)}.prompt-manager-tab.active{color:var(--text);background:var(--surface);border-color:var(--border)}.prompt-manager-content{min-height:200px}.prompt-manager-templates-tab,.prompt-manager-assignments-tab,.prompt-manager-overrides-tab{display:flex;flex-direction:column;gap:var(--space-lg)}.prompt-template-section{display:flex;flex-direction:column;gap:var(--space-md)}.prompt-template-section-title{font-size:14px;font-weight:600;color:var(--text);margin:0}.prompt-template-section-desc{font-size:12px;color:var(--text-muted);margin:0}.prompt-template-list{display:flex;flex-direction:column;gap:var(--space-md)}.prompt-template-card{padding:var(--space-md);background:var(--card);border:1px solid var(--border);border-radius:var(--radius-md);transition:border-color var(--transition-fast)}.prompt-template-card:hover{border-color:var(--text-dim)}.prompt-template-card-header{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--space-md);margin-bottom:var(--space-sm)}.prompt-template-card-info{display:flex;align-items:center;flex-wrap:wrap;gap:var(--space-sm)}.prompt-template-card-name{font-weight:600;color:var(--text);font-size:14px}.prompt-template-badge-built-in,.prompt-template-badge-custom,.prompt-template-badge-override{display:inline-flex;align-items:center;padding:2px 6px;font-size:10px;font-weight:500;border-radius:var(--radius-sm);text-transform:uppercase;letter-spacing:.02em}.prompt-template-badge-built-in{background:var(--surface);color:var(--text-muted);border:1px solid var(--border)}.prompt-template-badge-custom{background:color-mix(in srgb,var(--ws-info) 15%,transparent);color:var(--ws-info)}.prompt-template-badge-override{background:color-mix(in srgb,var(--ws-warning) 15%,transparent);color:var(--ws-warning)}.prompt-template-badge-role{display:inline-flex;align-items:center;padding:2px 6px;font-size:10px;font-weight:500;border-radius:var(--radius-sm)}.prompt-template-card-actions{display:flex;gap:var(--space-xs)}.prompt-template-card-actions .btn-icon{padding:var(--space-xs)}.prompt-template-card-description{font-size:12px;color:var(--text-muted);margin:0 0 var(--space-sm) 0;line-height:1.4}.prompt-template-card-preview{background:var(--surface);border-radius:var(--radius-sm);padding:var(--space-sm);overflow:hidden}.prompt-template-card-preview code{font-size:calc(var(--space-sm) + var(--space-xs) * .75);color:var(--text-muted);font-family:var(--font-mono);white-space:pre-wrap;word-break:break-word;display:block;max-height:120px;overflow-y:auto}.prompt-template-empty{padding:var(--space-lg);text-align:center;color:var(--text-muted);font-size:13px;background:var(--surface);border:1px dashed var(--border);border-radius:var(--radius-md)}.prompt-template-add-btn{align-self:flex-start;margin-top:var(--space-sm)}.prompt-template-editor{padding:var(--space-lg);background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);margin-bottom:var(--space-lg)}.prompt-template-editor-title{font-size:14px;font-weight:600;color:var(--text);margin:0 0 var(--space-md) 0}.prompt-template-editor-fields{display:flex;flex-direction:column;gap:var(--space-md)}.prompt-template-field{display:flex;flex-direction:column;gap:var(--space-xs)}.prompt-template-field label{font-size:12px;font-weight:500;color:var(--text-muted)}.prompt-template-field input,.prompt-template-field select,.prompt-template-prompt-textarea{padding:var(--space-sm) var(--space-md);background:var(--bg);border:1px solid var(--border);border-radius:var(--radius-md);color:var(--text);font-size:13px;transition:border-color var(--transition-fast)}.prompt-template-field input:focus,.prompt-template-field select:focus,.prompt-template-prompt-textarea:focus{outline:none;border-color:var(--todo)}.prompt-template-prompt-textarea{font-family:var(--font-mono);font-size:12px;line-height:1.5;resize:vertical;min-height:120px}.prompt-template-error{padding:var(--space-sm);background:color-mix(in srgb,var(--color-error) 10%,transparent);border:1px solid var(--color-error);border-radius:var(--radius-sm);color:var(--color-error);font-size:12px}.prompt-template-editor-actions{display:flex;gap:var(--space-sm);justify-content:flex-end;margin-top:var(--space-sm)}.prompt-template-delete-confirm{padding:var(--space-md);background:color-mix(in srgb,var(--color-error) 10%,transparent);border:1px solid var(--color-error);border-radius:var(--radius-md);display:flex;flex-direction:column;gap:var(--space-sm)}.prompt-template-delete-confirm p{margin:0;font-size:13px;color:var(--text)}.prompt-template-delete-actions{display:flex;gap:var(--space-sm)}.prompt-assignments-desc{font-size:12px;color:var(--text-muted);margin:0}.prompt-role-assignment-list{display:flex;flex-direction:column;gap:var(--space-md)}.prompt-role-assignment-row{display:flex;align-items:center;justify-content:space-between;gap:var(--space-lg);padding:var(--space-md);background:var(--card);border:1px solid var(--border);border-radius:var(--radius-md)}.prompt-role-assignment-label{display:flex;align-items:center;gap:var(--space-md)}.prompt-role-badge{display:inline-flex;align-items:center;padding:var(--space-xs) var(--space-sm);font-size:12px;font-weight:600;border-radius:var(--radius-sm)}.prompt-role-assignment-status{font-size:12px;color:var(--text-muted)}.prompt-role-select{min-width:200px;padding:var(--space-sm) var(--space-md);background:var(--bg);border:1px solid var(--border);border-radius:var(--radius-md);color:var(--text);font-size:13px;cursor:pointer}.prompt-role-select:focus{outline:none;border-color:var(--todo)}.prompt-assignments-note{margin-top:var(--space-md);padding:var(--space-md);background:var(--surface);border-radius:var(--radius-md);font-size:12px;color:var(--text-muted);line-height:1.5}.prompt-assignments-note strong{color:var(--text)}.prompt-overrides-desc{font-size:12px;color:var(--text-muted);margin:0}.prompt-overrides-list{display:flex;flex-direction:column;gap:var(--space-md)}.prompt-override-item{background:var(--card);border:1px solid var(--border);border-radius:var(--radius-md);overflow:hidden}.prompt-override-header{display:flex;align-items:center;justify-content:space-between;padding:var(--space-md);cursor:pointer;transition:background var(--transition-fast)}.prompt-override-header:hover{background:var(--card-hover)}.prompt-override-info{display:flex;align-items:center;flex-wrap:wrap;gap:var(--space-sm)}.prompt-override-name{font-weight:600;color:var(--text);font-size:13px}.prompt-override-key{font-size:11px;font-family:var(--font-mono);color:var(--text-muted);padding:2px 4px;background:var(--surface);border-radius:var(--radius-sm)}.prompt-override-badge{display:inline-flex;align-items:center;padding:2px 6px;font-size:10px;font-weight:500;background:color-mix(in srgb,var(--ws-warning) 15%,transparent);color:var(--ws-warning);border-radius:var(--radius-sm)}.prompt-override-expand-btn{display:flex;align-items:center;justify-content:center;width:24px;height:24px;background:none;border:none;color:var(--text-muted);cursor:pointer;border-radius:var(--radius-sm);transition:color var(--transition-fast),background var(--transition-fast)}.prompt-override-expand-btn:hover{color:var(--text);background:var(--surface)}.prompt-override-description{font-size:12px;color:var(--text-muted);margin:0;padding:0 var(--space-md) var(--space-md);line-height:1.4}.prompt-override-editor{padding:var(--space-md);border-top:1px solid var(--border);background:var(--surface);display:flex;flex-direction:column;gap:var(--space-sm)}.prompt-override-textarea{padding:var(--space-sm) var(--space-md);background:var(--bg);border:1px solid var(--border);border-radius:var(--radius-md);color:var(--text);font-size:12px;font-family:var(--font-mono);line-height:1.5;resize:vertical;min-height:80px;transition:border-color var(--transition-fast)}.prompt-override-textarea:focus{outline:none;border-color:var(--todo)}.prompt-override-footer{display:flex;align-items:center;gap:var(--space-md)}.prompt-override-hint{font-size:calc(var(--space-sm) + var(--space-xs) * .75);color:var(--text-muted)}.prompt-override-header-actions{display:flex;align-items:center;gap:var(--space-xs)}.prompt-override-fullscreen-btn{display:flex;align-items:center;justify-content:center;width:24px;height:24px;background:none;border:none;color:var(--text-muted);cursor:pointer;border-radius:var(--radius-sm);transition:color var(--transition-fast),background var(--transition-fast)}.prompt-override-fullscreen-btn:hover{color:var(--text);background:var(--surface)}.prompt-override-fullscreen{position:fixed;inset:0;z-index:10000;background:var(--surface);padding:max(var(--space-lg),env(safe-area-inset-top,0px)) max(var(--space-lg),env(safe-area-inset-right,0px)) max(var(--space-lg),env(safe-area-inset-bottom,0px)) max(var(--space-lg),env(safe-area-inset-left,0px));display:flex;flex-direction:column}.prompt-override-fullscreen-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:var(--space-md);flex-shrink:0}.prompt-override-fullscreen-title{font-size:13px;font-weight:600;color:var(--text);display:flex;align-items:center;gap:var(--space-sm)}.prompt-override-fullscreen-close{display:flex;align-items:center;justify-content:center;gap:var(--space-xs);padding:var(--space-xs) var(--space-sm);background:none;border:1px solid var(--border);border-radius:var(--radius-md);color:var(--text-muted);cursor:pointer;font-size:12px;transition:all var(--transition-fast)}.prompt-override-fullscreen-close:hover{color:var(--text);border-color:var(--text-muted)}.prompt-override-fullscreen-close:focus-visible{outline:none;box-shadow:var(--focus-ring-strong)}.prompt-override-fullscreen textarea{flex:1;min-height:unset;resize:none;border-radius:var(--radius-md);font-size:14px;line-height:1.6}.prompt-template-fullscreen-pre{flex:1;font-family:var(--font-mono);font-size:13px;line-height:1.6;color:var(--text);white-space:pre-wrap;word-break:break-word;overflow-y:auto;padding:var(--space-md);background:var(--bg);border-radius:var(--radius-md);border:1px solid var(--border);margin:0}.prompt-override-fullscreen .prompt-override-footer{flex-shrink:0;padding-top:var(--space-sm)}.prompt-template-prompt-label-row{display:flex;align-items:center;gap:var(--space-sm);margin-bottom:var(--space-xs)}.prompt-template-prompt-label-row label{display:block}.prompt-template-fullscreen-btn{vertical-align:middle}.prompt-template-prompt-label-row .prompt-template-fullscreen-btn{margin-left:var(--space-xs)}@media(max-width:768px){.prompt-manager{padding:0 14px}.prompt-manager-tabs{flex-wrap:wrap}.prompt-manager-tab{flex:1;justify-content:center;min-width:calc(50% - var(--space-xs))}.prompt-role-assignment-row{flex-direction:column;align-items:stretch;gap:var(--space-sm)}.prompt-role-select{width:100%}.prompt-template-editor-actions{flex-direction:column}.prompt-template-editor-actions .btn{width:100%}.prompt-override-fullscreen{padding:var(--space-md)}.prompt-override-fullscreen textarea{font-size:16px}}.new-task-modal .form-group small{display:block;margin-top:var(--space-sm);font-size:12px;color:var(--text-muted);line-height:1.4}.new-task-modal textarea{min-height:80px;transition:height .1s ease-out}.selected-deps{display:flex;flex-wrap:wrap;gap:6px;margin-top:var(--space-sm);padding:2px 0}.dep-chip{display:inline-flex;align-items:center;gap:var(--space-xs);padding:3px 8px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-lg);font-size:12px;color:var(--text);font-family:var(--font-mono);max-width:100%}.dep-chip-remove{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;background:none;border:none;color:var(--text-muted);cursor:pointer;font-size:12px;line-height:1;padding:0;margin-left:2px;border-radius:50%;transition:background .1s,color .1s}.dep-chip-remove:hover{color:var(--color-error);background:color-mix(in srgb,var(--color-error) 10%,transparent)}.model-select-row{display:flex;align-items:center;gap:var(--space-md);margin-bottom:var(--space-md)}.model-select-row:last-child{margin-bottom:0}.model-select-label{width:70px;flex-shrink:0;font-size:13px;color:var(--text-muted);text-align:right}@media(max-width:768px){.model-select-row{flex-direction:column;align-items:stretch;gap:var(--space-xs)}.model-select-label{width:auto;text-align:left}}.onboarding-disclosure{display:flex;flex-direction:column;margin-top:var(--space-sm)}.onboarding-disclosure-trigger{display:flex;align-items:center;gap:var(--space-xs);background:none;border:none;color:var(--text-muted);font-size:var(--font-size-sm, 12px);cursor:pointer;padding:var(--space-xs) 0;transition:color var(--transition-fast);font-family:inherit}.onboarding-disclosure-trigger:hover{color:var(--text)}.onboarding-disclosure-trigger:focus-visible{outline:var(--focus-ring-strong);border-radius:var(--radius-sm)}.onboarding-disclosure-chevron{width:14px;height:14px;transition:transform var(--transition-fast);flex-shrink:0}.onboarding-disclosure-trigger[aria-expanded=true] .onboarding-disclosure-chevron{transform:rotate(90deg)}.onboarding-disclosure-content{padding:var(--space-sm) 0 var(--space-sm) calc(var(--space-sm) + var(--space-lg) - var(--space-xs));color:var(--text-muted);font-size:var(--font-size-sm, 12px);line-height:1.5;animation:onboarding-disclosure-enter var(--transition-fast) ease-out}@keyframes onboarding-disclosure-enter{0%{opacity:0;transform:translateY(calc(var(--space-xs) * -1))}to{opacity:1;transform:translateY(0)}}@media(max-width:768px){.onboarding-disclosure-trigger{min-height:calc(var(--space-lg) + var(--space-lg) + var(--space-xs));padding:var(--space-sm) 0}}@keyframes custom-provider-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.custom-providers-section .onboarding-disclosure-content{margin-top:var(--space-sm);display:flex;flex-direction:column;gap:var(--space-sm)}.custom-provider-list{display:flex;flex-direction:column;gap:var(--space-sm)}.custom-provider-item{display:flex;align-items:center;justify-content:space-between;padding:var(--space-sm) var(--space-md);background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);transition:border-color var(--transition-fast),box-shadow var(--transition-fast)}.custom-provider-item:hover{border-color:var(--text-dim)}.custom-provider-item-info{display:flex;flex-direction:column;gap:var(--space-xs);min-width:0}.custom-provider-item-name{font-weight:600;color:var(--text)}.custom-provider-item-meta{color:var(--text-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.custom-provider-item-actions{display:flex;gap:var(--space-xs);flex-shrink:0}.custom-provider-badge{display:inline-flex;align-items:center;padding:var(--space-xs);border-radius:var(--radius-pill);background:color-mix(in srgb,var(--color-info) 15%,transparent);color:var(--color-info)}.custom-provider-empty{color:var(--text-muted);padding:var(--space-sm) 0}.custom-provider-add-btn{margin-top:var(--space-sm)}.custom-provider-form{padding:var(--space-md);background:var(--surface);border:1px solid var(--border);border-radius:var(--radius-md);margin-top:var(--space-sm)}.custom-provider-form-row{margin-bottom:var(--space-sm)}.custom-provider-form-actions{display:flex;gap:var(--space-sm);margin-top:var(--space-md)}.custom-provider-form-error{display:flex;align-items:center;gap:var(--space-xs);color:var(--color-error);margin-top:var(--space-xs);background:color-mix(in srgb,var(--color-error) 10%,transparent);padding:var(--space-xs) var(--space-sm);border-radius:var(--radius-sm)}.custom-provider-item-edit-form{margin-top:var(--space-xs)}.spin{animation:custom-provider-spin calc(var(--transition-slow) * 4) linear infinite}@media(max-width:768px){.custom-provider-item{flex-direction:column;align-items:flex-start;gap:var(--space-xs)}.custom-provider-item-meta{max-width:100%}.custom-provider-form{padding:var(--space-sm)}.custom-provider-item-actions{align-self:flex-end;margin-top:var(--space-xs)}}