@runfusion/fusion 0.14.2 → 0.15.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 (37) hide show
  1. package/dist/bin.js +949 -138
  2. package/dist/client/assets/AgentDetailView-B1zViykq.js +18 -0
  3. package/dist/client/assets/{AgentsView-DkX0tzrN.js → AgentsView-Bl9JH5C8.js} +3 -3
  4. package/dist/client/assets/{ChatView-CEm2Hw6m.js → ChatView-liNErE53.js} +1 -1
  5. package/dist/client/assets/{DevServerView-Bumvo_ge.js → DevServerView-CV_PpbnZ.js} +1 -1
  6. package/dist/client/assets/{DirectoryPicker-CXN11cBp.js → DirectoryPicker-DPfkGnj5.js} +1 -1
  7. package/dist/client/assets/{DocumentsView-B71IqAxA.js → DocumentsView-CESb6RI7.js} +1 -1
  8. package/dist/client/assets/{InsightsView-Bs4Rldu6.js → InsightsView-BKhvyEyQ.js} +1 -1
  9. package/dist/client/assets/{MemoryView-Bs7b_L2Q.js → MemoryView-DB-l2miV.js} +1 -1
  10. package/dist/client/assets/{NodesView-BvAGTXbO.js → NodesView-DgTXO8mm.js} +1 -1
  11. package/dist/client/assets/{PiExtensionsManager-3Kcc4uhA.js → PiExtensionsManager-C4fTzemh.js} +1 -1
  12. package/dist/client/assets/{PluginManager-Ch-Xynlm.js → PluginManager-C2-dExUL.js} +1 -1
  13. package/dist/client/assets/{ResearchView-Bj6Saqf6.js → ResearchView-CkVwRDVA.js} +1 -1
  14. package/dist/client/assets/{RoadmapsView-9qT8Vwd0.js → RoadmapsView-Cu85_XrQ.js} +1 -1
  15. package/dist/client/assets/{SettingsModal-D4ERGQNQ.js → SettingsModal-BGnSAeqa.js} +1 -1
  16. package/dist/client/assets/SettingsModal-C0DokcId.js +31 -0
  17. package/dist/client/assets/{SetupWizardModal-Dv0rX2_o.js → SetupWizardModal-C_d9clJp.js} +1 -1
  18. package/dist/client/assets/{SkillMultiselect-CSkXQzdv.js → SkillMultiselect-DwGWYZi6.js} +1 -1
  19. package/dist/client/assets/{SkillsView-2srXMOzj.js → SkillsView-C096TB7i.js} +1 -1
  20. package/dist/client/assets/{TodoView-CxPPIvw2.js → TodoView-CUiAt2mR.js} +1 -1
  21. package/dist/client/assets/{folder-open-FA1PwpXV.js → folder-open-CKivQd8c.js} +1 -1
  22. package/dist/client/assets/index-B4StE1qN.js +662 -0
  23. package/dist/client/assets/index-DYJk0WDc.css +1 -0
  24. package/dist/client/assets/{list-checks-6EktkUso.js → list-checks-B3oufblU.js} +1 -1
  25. package/dist/client/assets/{star-B6Th07jw.js → star-damu_EYz.js} +1 -1
  26. package/dist/client/assets/{upload-BJwuErhV.js → upload-uH6CHlEw.js} +1 -1
  27. package/dist/client/assets/{users-BrnPTF8H.js → users-CUySbfji.js} +1 -1
  28. package/dist/client/index.html +2 -2
  29. package/dist/client/version.json +1 -1
  30. package/dist/extension.js +722 -120
  31. package/dist/pi-claude-cli/index.ts +2 -2
  32. package/dist/pi-claude-cli/package.json +1 -1
  33. package/package.json +1 -1
  34. package/dist/client/assets/AgentDetailView-C2Iik3Qf.js +0 -18
  35. package/dist/client/assets/SettingsModal-Zo5qDGOq.js +0 -31
  36. package/dist/client/assets/index-CEavim6l.js +0 -662
  37. package/dist/client/assets/index-D1gTSlYB.css +0 -1
@@ -1,4 +1,4 @@
1
- import{r as n,j as e}from"./vendor-react-K0fH_qHe.js";import{c as Y,az as xe,aA as ge,aB as pe,aC as je,aD as Z,aE as Q,A as T,aF as _e,V as Ne,W as be,aG as ee,aH as ve,aI as Ce,X as B,aJ as ke,aK as Se,R as X,J as G,G as we}from"./index-CEavim6l.js";import{U as se}from"./upload-BJwuErhV.js";import"./vendor-xterm-DzcZoU0P.js";/**
1
+ import{r as n,j as e}from"./vendor-react-K0fH_qHe.js";import{c as Y,az as xe,aA as ge,aB as pe,aC as je,aD as Z,aE as Q,A as T,aF as _e,V as Ne,W as be,aG as ee,aH as ve,aI as Ce,X as B,aJ as ke,aK as Se,R as X,J as G,G as we}from"./index-B4StE1qN.js";import{U as se}from"./upload-uH6CHlEw.js";import"./vendor-xterm-DzcZoU0P.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{r as l,j as e}from"./vendor-react-K0fH_qHe.js";import{c as A,d_ as H,d$ as Q,e0 as Y,R as $,dS as y,J as Z,W as T,N as ee,V as se,cr as L,F as _,e1 as ae,e2 as te,e3 as D,X as ie}from"./index-CEavim6l.js";import"./vendor-xterm-DzcZoU0P.js";/**
1
+ import{r as l,j as e}from"./vendor-react-K0fH_qHe.js";import{c as A,d_ as H,d$ as Q,e0 as Y,R as $,dS as y,J as Z,W as T,N as ee,V as se,cr as L,F as _,e1 as ae,e2 as te,e3 as D,X as ie}from"./index-B4StE1qN.js";import"./vendor-xterm-DzcZoU0P.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as o,j as s}from"./vendor-react-K0fH_qHe.js";import{w as T,dQ as ee,s as se,X as A,an as ne,J as O,dR as V,V as M,R as te,dS as ie,aF as ae,ch as le,dT as re,dU as ce,dV as de,dW as ue,dX as _,ce as oe}from"./index-CEavim6l.js";import{D as me}from"./DirectoryPicker-CXN11cBp.js";import"./vendor-xterm-DzcZoU0P.js";import"./folder-open-FA1PwpXV.js";const ge=[{id:"fusion-plugin-agent-browser-runtime",name:"Agent Browser Runtime",path:"./plugins/fusion-plugin-agent-browser-runtime",experimental:!0},{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}],N={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[x,b]=o.useState([]),[S,w]=o.useState(!0),[H,f]=o.useState(!1),[j,v]=o.useState(""),[C,P]=o.useState(!1),[h,R]=o.useState(null),[i,y]=o.useState(null),[a,p]=o.useState({}),[J,$]=o.useState(!1),[I,E]=o.useState(null),{confirm:X}=T(),m=o.useCallback(async()=>{try{w(!0);const e=await ee(c);b(e)}catch(e){l(`Failed to load plugins: ${e instanceof Error?e.message:String(e)}`,"error")}finally{w(!1)}},[c,l]);o.useEffect(()=>{m()},[m]);const G=o.useRef([]);G.current=x,o.useEffect(()=>{const e=c?`?projectId=${encodeURIComponent(c)}`:"",n=d=>{try{const t=JSON.parse(d.data);if(c&&t.projectId&&t.projectId!==c)return;switch(t.transition){case"installing":case"enabled":case"disabled":case"settings-updated":b(u=>{const g=u.findIndex(r=>r.id===t.pluginId);if(g>=0){const r=[...u];return r[g]={...r[g],enabled:t.enabled,state:t.state,settings:t.settings,error:t.error},r}else return m(),u});break;case"uninstalled":b(u=>u.filter(g=>g.id!==t.pluginId));break;case"error":b(u=>{const g=u.findIndex(r=>r.id===t.pluginId);if(g>=0){const r=[...u];return r[g]={...r[g],state:t.state,error:t.error},r}return u});break}}catch{}};return se(`/api/events${e}`,{events:{"plugin:lifecycle":n},onReconnect:()=>{m()}})},[c,m]);const z=async()=>{if(!j.trim()){l("Please enter a plugin path","error");return}try{P(!0),await _({path:j},c),l("Plugin installed successfully","success"),f(!1),v(""),await m()}catch(e){l(`Failed to install plugin: ${e instanceof Error?e.message:String(e)}`,"error")}finally{P(!1)}},K=async e=>{try{E(e.id),await _({path:e.path},c),l(`${e.name} installed successfully`,"success"),await m()}catch(n){l(`Failed to install ${e.name}: ${n instanceof Error?n.message:String(n)}`,"error")}finally{E(null)}},B=async e=>{try{await de(e.id,c),l(`${e.name} enabled`,"success"),await m()}catch(n){l(`Failed to enable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},F=async e=>{try{await ce(e.id,c),l(`${e.name} disabled`,"success"),await m()}catch(n){l(`Failed to disable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},U=async e=>{try{R(e.id),await re(e.id,c),l(`${e.name} reloaded`,"success"),await m()}catch(n){l(`Failed to reload plugin: ${n instanceof Error?n.message:String(n)}`,"error")}finally{R(null)}},L=async e=>{if(await X({title:"Uninstall Plugin",message:`Are you sure you want to uninstall "${e.name}"?`,danger:!0}))try{await ue(e.id,c),l(`${e.name} uninstalled`,"success"),await m(),y(null)}catch(d){l(`Failed to uninstall plugin: ${d instanceof Error?d.message:String(d)}`,"error")}},q=async e=>{y(e);try{$(!0);const n=await oe(e.id,c);p(n)}catch{p({})}finally{$(!1)}},Q=async()=>{if(i)try{await le(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(A,{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:N[i.state]||N.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(ne,{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"}),J?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 d=`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",{className:"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?d:void 0}),n.type==="string"&&n.multiline&&s.jsx("textarea",{className:"input",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?d:void 0}),n.type==="password"&&s.jsx("input",{className:"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?d:void 0}),n.type==="number"&&s.jsx("input",{className:"input",type:"number",id:`setting-${e}`,value:a[e]??"",onChange:t=>p({...a,[e]:Number(t.target.value)}),"aria-describedby":n.description&&!n.required?d: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",{className:"select",id:`setting-${e}`,value:a[e]??"",onChange:t=>p({...a,[e]:t.target.value}),"aria-describedby":n.description&&!n.required?d: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,u)=>s.jsxs("div",{className:"plugin-settings-array-item",children:[s.jsx("input",{className:"input",type:n.itemType==="number"?"number":"text",value:t??"",onChange:g=>{const r=g.target.value,k=[...a[e]||[]];k[u]=n.itemType==="number"?Number(r):r,p({...a,[e]:k})}}),s.jsx("button",{className:"btn-icon",onClick:()=>{const r=[...a[e]||[]];r.splice(u,1),p({...a,[e]:r})},"aria-label":"Remove item",children:s.jsx(A,{size:14})})]},u)),s.jsxs("button",{className:"btn btn-secondary",onClick:()=>{const t=a[e]||[],u=n.itemType==="number"?0:"";p({...a,[e]:[...t,u]})},children:[s.jsx(O,{size:14})," Add Item"]})]}),n.description&&!n.required&&!n.multiline&&s.jsx("span",{id:d,className:"form-help",children:n.description})]},e)}),s.jsx("button",{className:"btn btn-primary",onClick:Q,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:()=>U(i),disabled:h===i.id,children:[s.jsx(V,{size:14,className:h===i.id?"spin":""}),h===i.id?"Reloading...":"Reload"]}),i.enabled?s.jsx("button",{className:"btn btn-secondary",onClick:()=>F(i),children:"Disable"}):s.jsx("button",{className:"btn btn-primary",onClick:()=>B(i),children:"Enable"}),s.jsxs("button",{className:"btn btn-danger",onClick:()=>L(i),children:[s.jsx(M,{size:14})," Uninstall"]})]})]})]});const W=new Set(x.map(e=>e.id)),Y=new Map(x.map(e=>[e.id,e])),D=x,Z=()=>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:ge.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:()=>{if(n){const d=Y.get(e.id);d&&q(d);return}K(e)},disabled:I===e.id,children:n?"Manage":I===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:m,title:"Refresh","aria-label":"Refresh plugin list",children:[s.jsx(te,{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:j,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||!j.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:[D.length===0?s.jsxs("div",{className:"settings-empty-state",children:[s.jsx(ie,{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:D.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:N[e.state]||N.installed},children:e.state})]}),s.jsxs("div",{className:"plugin-actions",children:[e.state==="started"&&s.jsx("button",{className:"btn-icon",onClick:()=>U(e),disabled:h===e.id,title:"Reload",children:s.jsx(V,{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?F(e):B(e)}),s.jsx("span",{className:"toggle-slider"})]}),s.jsx("button",{className:"btn-icon",onClick:()=>q(e),title:"Settings",children:s.jsx(ae,{size:14})}),s.jsx("button",{className:"btn-icon",onClick:()=>L(e),title:"Uninstall",children:s.jsx(M,{size:14})})]})]},e.id))}),Z()]})]})}export{fe as PluginManager,N as STATE_COLORS};
1
+ import{r as o,j as s}from"./vendor-react-K0fH_qHe.js";import{w as T,dQ as ee,s as se,X as A,an as ne,J as O,dR as V,V as M,R as te,dS as ie,aF as ae,ch as le,dT as re,dU as ce,dV as de,dW as ue,dX as _,ce as oe}from"./index-B4StE1qN.js";import{D as me}from"./DirectoryPicker-DPfkGnj5.js";import"./vendor-xterm-DzcZoU0P.js";import"./folder-open-CKivQd8c.js";const ge=[{id:"fusion-plugin-agent-browser-runtime",name:"Agent Browser Runtime",path:"./plugins/fusion-plugin-agent-browser-runtime",experimental:!0},{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}],N={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[x,b]=o.useState([]),[S,w]=o.useState(!0),[H,f]=o.useState(!1),[j,v]=o.useState(""),[C,P]=o.useState(!1),[h,R]=o.useState(null),[i,y]=o.useState(null),[a,p]=o.useState({}),[J,$]=o.useState(!1),[I,E]=o.useState(null),{confirm:X}=T(),m=o.useCallback(async()=>{try{w(!0);const e=await ee(c);b(e)}catch(e){l(`Failed to load plugins: ${e instanceof Error?e.message:String(e)}`,"error")}finally{w(!1)}},[c,l]);o.useEffect(()=>{m()},[m]);const G=o.useRef([]);G.current=x,o.useEffect(()=>{const e=c?`?projectId=${encodeURIComponent(c)}`:"",n=d=>{try{const t=JSON.parse(d.data);if(c&&t.projectId&&t.projectId!==c)return;switch(t.transition){case"installing":case"enabled":case"disabled":case"settings-updated":b(u=>{const g=u.findIndex(r=>r.id===t.pluginId);if(g>=0){const r=[...u];return r[g]={...r[g],enabled:t.enabled,state:t.state,settings:t.settings,error:t.error},r}else return m(),u});break;case"uninstalled":b(u=>u.filter(g=>g.id!==t.pluginId));break;case"error":b(u=>{const g=u.findIndex(r=>r.id===t.pluginId);if(g>=0){const r=[...u];return r[g]={...r[g],state:t.state,error:t.error},r}return u});break}}catch{}};return se(`/api/events${e}`,{events:{"plugin:lifecycle":n},onReconnect:()=>{m()}})},[c,m]);const z=async()=>{if(!j.trim()){l("Please enter a plugin path","error");return}try{P(!0),await _({path:j},c),l("Plugin installed successfully","success"),f(!1),v(""),await m()}catch(e){l(`Failed to install plugin: ${e instanceof Error?e.message:String(e)}`,"error")}finally{P(!1)}},K=async e=>{try{E(e.id),await _({path:e.path},c),l(`${e.name} installed successfully`,"success"),await m()}catch(n){l(`Failed to install ${e.name}: ${n instanceof Error?n.message:String(n)}`,"error")}finally{E(null)}},B=async e=>{try{await de(e.id,c),l(`${e.name} enabled`,"success"),await m()}catch(n){l(`Failed to enable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},F=async e=>{try{await ce(e.id,c),l(`${e.name} disabled`,"success"),await m()}catch(n){l(`Failed to disable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},U=async e=>{try{R(e.id),await re(e.id,c),l(`${e.name} reloaded`,"success"),await m()}catch(n){l(`Failed to reload plugin: ${n instanceof Error?n.message:String(n)}`,"error")}finally{R(null)}},L=async e=>{if(await X({title:"Uninstall Plugin",message:`Are you sure you want to uninstall "${e.name}"?`,danger:!0}))try{await ue(e.id,c),l(`${e.name} uninstalled`,"success"),await m(),y(null)}catch(d){l(`Failed to uninstall plugin: ${d instanceof Error?d.message:String(d)}`,"error")}},q=async e=>{y(e);try{$(!0);const n=await oe(e.id,c);p(n)}catch{p({})}finally{$(!1)}},Q=async()=>{if(i)try{await le(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(A,{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:N[i.state]||N.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(ne,{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"}),J?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 d=`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",{className:"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?d:void 0}),n.type==="string"&&n.multiline&&s.jsx("textarea",{className:"input",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?d:void 0}),n.type==="password"&&s.jsx("input",{className:"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?d:void 0}),n.type==="number"&&s.jsx("input",{className:"input",type:"number",id:`setting-${e}`,value:a[e]??"",onChange:t=>p({...a,[e]:Number(t.target.value)}),"aria-describedby":n.description&&!n.required?d: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",{className:"select",id:`setting-${e}`,value:a[e]??"",onChange:t=>p({...a,[e]:t.target.value}),"aria-describedby":n.description&&!n.required?d: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,u)=>s.jsxs("div",{className:"plugin-settings-array-item",children:[s.jsx("input",{className:"input",type:n.itemType==="number"?"number":"text",value:t??"",onChange:g=>{const r=g.target.value,k=[...a[e]||[]];k[u]=n.itemType==="number"?Number(r):r,p({...a,[e]:k})}}),s.jsx("button",{className:"btn-icon",onClick:()=>{const r=[...a[e]||[]];r.splice(u,1),p({...a,[e]:r})},"aria-label":"Remove item",children:s.jsx(A,{size:14})})]},u)),s.jsxs("button",{className:"btn btn-secondary",onClick:()=>{const t=a[e]||[],u=n.itemType==="number"?0:"";p({...a,[e]:[...t,u]})},children:[s.jsx(O,{size:14})," Add Item"]})]}),n.description&&!n.required&&!n.multiline&&s.jsx("span",{id:d,className:"form-help",children:n.description})]},e)}),s.jsx("button",{className:"btn btn-primary",onClick:Q,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:()=>U(i),disabled:h===i.id,children:[s.jsx(V,{size:14,className:h===i.id?"spin":""}),h===i.id?"Reloading...":"Reload"]}),i.enabled?s.jsx("button",{className:"btn btn-secondary",onClick:()=>F(i),children:"Disable"}):s.jsx("button",{className:"btn btn-primary",onClick:()=>B(i),children:"Enable"}),s.jsxs("button",{className:"btn btn-danger",onClick:()=>L(i),children:[s.jsx(M,{size:14})," Uninstall"]})]})]})]});const W=new Set(x.map(e=>e.id)),Y=new Map(x.map(e=>[e.id,e])),D=x,Z=()=>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:ge.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:()=>{if(n){const d=Y.get(e.id);d&&q(d);return}K(e)},disabled:I===e.id,children:n?"Manage":I===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:m,title:"Refresh","aria-label":"Refresh plugin list",children:[s.jsx(te,{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:j,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||!j.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:[D.length===0?s.jsxs("div",{className:"settings-empty-state",children:[s.jsx(ie,{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:D.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:N[e.state]||N.installed},children:e.state})]}),s.jsxs("div",{className:"plugin-actions",children:[e.state==="started"&&s.jsx("button",{className:"btn-icon",onClick:()=>U(e),disabled:h===e.id,title:"Reload",children:s.jsx(V,{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?F(e):B(e)}),s.jsx("span",{className:"toggle-slider"})]}),s.jsx("button",{className:"btn-icon",onClick:()=>q(e),title:"Settings",children:s.jsx(ae,{size:14})}),s.jsx("button",{className:"btn-icon",onClick:()=>L(e),title:"Uninstall",children:s.jsx(M,{size:14})})]})]},e.id))}),Z()]})]})}export{fe as PluginManager,N as STATE_COLORS};
@@ -1 +1 @@
1
- import{r as a,j as e}from"./vendor-react-K0fH_qHe.js";import{aq as ae,ar as ne,s as ce,as as ie,at as le,au as oe,av as de,aw as ue,ax as he,x as me,ay as be,L as ve,S as pe}from"./index-CEavim6l.js";import"./vendor-xterm-DzcZoU0P.js";const C={webSearch:!0,pageFetch:!0,github:!1,localDocs:!0,llmSynthesis:!0};function z(d){const r=d?.researchGlobalDefaults,o=d?.researchSettings;return{enabled:o?.enabled??d?.researchEnabled??d?.researchGlobalEnabled??!0,searchProvider:o?.searchProvider??r?.searchProvider,synthesisProvider:o?.synthesisProvider??r?.synthesisProvider,synthesisModelId:o?.synthesisModelId??r?.synthesisModelId,enabledSources:{webSearch:o?.enabledSources?.webSearch??r?.enabledSources?.webSearch??C.webSearch,pageFetch:o?.enabledSources?.pageFetch??r?.enabledSources?.pageFetch??C.pageFetch,github:o?.enabledSources?.github??r?.enabledSources?.github??C.github,localDocs:o?.enabledSources?.localDocs??r?.enabledSources?.localDocs??C.localDocs,llmSynthesis:o?.enabledSources?.llmSynthesis??r?.enabledSources?.llmSynthesis??C.llmSynthesis},limits:{maxConcurrentRuns:o?.limits?.maxConcurrentRuns??d?.researchMaxConcurrentRuns??d?.researchGlobalMaxConcurrentRuns??3,maxSourcesPerRun:o?.limits?.maxSourcesPerRun??r?.maxSourcesPerRun??d?.researchMaxSourcesPerRun??d?.researchGlobalMaxSourcesPerRun??20,maxDurationMs:o?.limits?.maxDurationMs??d?.researchDefaultTimeout??d?.researchGlobalDefaultTimeout??3e5,requestTimeoutMs:o?.limits?.requestTimeoutMs??d?.researchFetchTimeoutMs??3e4},defaultExportFormat:r?.defaultExportFormat??"markdown"}}const xe=300,fe=4e3;function ye(d){const r=d?.projectId,[o,D]=a.useState([]),[u,t]=a.useState(null),[q,y]=a.useState(null),[x,R]=a.useState({available:!0}),[w,E]=a.useState(!0),[O,P]=a.useState(null),[S,U]=a.useState(""),_=a.useRef(0),g=a.useRef(0),A=a.useRef(r);a.useEffect(()=>{A.current!==r&&(A.current=r,g.current++)},[r]);const p=a.useCallback(async(n=S)=>{const c=++_.current,i=r;P(null);try{const h=await ae({q:n||void 0,limit:100},i);if(c!==_.current||i!==r)return;D(h.runs),R(h.availability),u&&!h.runs.some(m=>m.id===u)&&(t(null),y(null))}catch(h){if(c!==_.current||i!==r)return;P(h instanceof Error?h.message:"Failed to load research runs")}finally{c===_.current&&E(!1)}},[r,S,u]),f=a.useCallback(async n=>{const c=await ne(n,r);return y(c.run),R(c.availability),c.run},[r]);return a.useEffect(()=>{E(!0);const n=window.setTimeout(()=>{p(S)},xe);return()=>window.clearTimeout(n)},[p,S]),a.useEffect(()=>{if(!u){y(null);return}f(u)},[f,u]),a.useEffect(()=>{const n=g.current,c=()=>g.current!==n,i=r?`?projectId=${encodeURIComponent(r)}`:"";let h=!0;const m=()=>{!h||c()||(p(),u&&f(u))},V=ce(`/api/events${i}`,{events:{"research:run:created":m,"research:run:updated":m,"research:run:completed":m,"research:run:failed":m,"research:run:cancelled":m},onReconnect:m}),M=window.setInterval(m,fe);return()=>{h=!1,V(),window.clearInterval(M)}},[r,p,u,f]),{runs:o,selectedRun:q,selectedRunId:u,setSelectedRunId:t,availability:x,loading:w,error:O,searchQuery:S,setSearchQuery:U,refresh:p,createRun:n=>he(n,r),cancelRun:async n=>{const c=await ue(n,r);return u===n&&y(c.run),await p(),c},retryRun:async n=>{const c=await de(n,r);return u===n&&y(c.run),await p(),c},exportRun:(n,c)=>oe(n,c,r),createTaskFromRun:(n,c)=>le(n,{title:c},r),attachRunToTask:(n,c,i)=>ie(n,{taskId:c,mode:i},r),statusCounts:o.reduce((n,c)=>(n[c.status]+=1,n),{pending:0,running:0,completed:0,failed:0,cancelled:0})}}const Se=["web-search","page-fetch","github","local-docs","llm-synthesis"],je={"web-search":"webSearch","page-fetch":"pageFetch",github:"github","local-docs":"localDocs","llm-synthesis":"llmSynthesis"},Re={"web-search":"Web Search","page-fetch":"Page Fetch",github:"GitHub","local-docs":"Local Docs","llm-synthesis":"LLM Synthesis"};function ke({projectId:d,addToast:r,onOpenSettings:o,readinessVersion:D=0}){const{runs:u,selectedRun:t,selectedRunId:q,setSelectedRunId:y,availability:x,loading:R,error:w,searchQuery:E,setSearchQuery:O,createRun:P,cancelRun:S,retryRun:U,exportRun:_,createTaskFromRun:g,attachRunToTask:A,statusCounts:p,refresh:f}=ye({projectId:d}),[n,c]=a.useState(""),[i,h]=a.useState(()=>z(void 0)),[m,V]=a.useState([]),[M,J]=a.useState(!1),[W,Y]=a.useState([]),[$,ee]=a.useState(""),[j,I]=a.useState(null),G=x.supportedProviders??Se,F=s=>i.enabledSources[je[s]];a.useEffect(()=>{const s=G.filter(l=>F(l));Y(l=>{const b=l.filter(v=>s.includes(v));return b.length>0?b:s})},[i.enabledSources,G]),a.useEffect(()=>{let s=!1;return Promise.all([me(d),be().catch(()=>({providers:[]}))]).then(([l,b])=>{s||(h(z(l)),V(b.providers.filter(v=>v.type==="api_key").map(v=>({id:v.id,authenticated:v.authenticated}))))}).catch(()=>{s||h(z(void 0))}),()=>{s=!0}},[d,D]);const se=a.useMemo(()=>t?t.status:"No run selected",[t]),re=a.useMemo(()=>t?t.status==="pending"?"status-dot status-dot--pending":t.status==="running"?"status-dot status-dot--connecting":t.status==="completed"?"status-dot status-dot--online":t.status==="failed"||t.status==="cancelled"?"status-dot status-dot--error":"status-dot":"status-dot",[t]),Q=x.supportedExportFormats??["markdown","json","html"],L=i.searchProvider,X=i.enabledSources.webSearch&&!L,Z=i.enabledSources.llmSynthesis&&(!i.synthesisProvider||!i.synthesisModelId),B=a.useMemo(()=>new Map(m.map(s=>[s.id,s.authenticated])),[m]),H=a.useMemo(()=>{const s=new Set;return i.enabledSources.webSearch&&L&&s.add(L),i.enabledSources.llmSynthesis&&i.synthesisProvider&&s.add(i.synthesisProvider),[...s].filter(l=>B.has(l))},[i.enabledSources.llmSynthesis,i.enabledSources.webSearch,i.synthesisProvider,L,B]).find(s=>B.get(s)!==!0),N=a.useMemo(()=>x.available?i.enabled?X||Z?{reason:"Research defaults are incomplete.",details:"Select the required provider/model defaults in Research settings.",settingsSection:"research-global"}:H?{reason:`Missing API key for ${H}.`,details:"Add provider credentials in Authentication settings.",settingsSection:"authentication"}:null:{reason:"Research is disabled for this project.",details:"Enable project research settings to create runs.",settingsSection:"research-project"}:{reason:x.reason??"Research is unavailable for this project.",details:x.setupInstructions,settingsSection:"research-project"},[x.available,x.reason,x.setupInstructions,i.enabled,H,X,Z]),T=async(s,l,b)=>{I(s);try{await l(),r?.(b,"success"),await f()}catch(v){r?.(v instanceof Error?v.message:"Action failed","error")}finally{I(null)}},K=async s=>{if(t){I(`export-${s}`);try{const l=await _(t.id,s),b=new Blob([l.content],{type:"text/plain;charset=utf-8"}),v=URL.createObjectURL(b),k=document.createElement("a");k.href=v,k.download=l.filename,document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(v),r?.(`Exported ${l.filename}`,"success")}catch(l){r?.(l instanceof Error?l.message:"Export failed","error")}finally{I(null)}}},te=async()=>{if(n.trim()){J(!0);try{const s=W.filter(b=>F(b));if(s.length===0){r?.("No enabled research sources are available for this project.","error");return}const l=await P({query:n.trim(),providers:s});y(l.run.id),c(""),r?.("Research run created","success"),await f()}catch(s){r?.(s instanceof Error?s.message:"Failed to create run","error")}finally{J(!1)}}};return e.jsxs("section",{className:"research-view","aria-label":"Research view",children:[e.jsxs("header",{className:"research-view__header",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"research-view__title",children:"Research"}),e.jsx("p",{className:"research-view__subtitle",children:"Create and track research runs with cited findings."})]}),e.jsx("button",{className:"btn",type:"button",onClick:()=>void f(),children:"Refresh"})]}),N?e.jsxs("div",{className:"research-view__state research-view__state--error card","data-testid":"research-state-unavailable",children:[e.jsx("p",{children:N.reason}),N.details&&e.jsx("p",{children:N.details}),e.jsxs("p",{children:["Current defaults: provider ",i.searchProvider??"(not set)",", max sources ",i.limits.maxSourcesPerRun]}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:()=>void f(),children:"Refresh"}),e.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>o?.(N.settingsSection),children:"Open Settings"})]})]}):e.jsxs("div",{className:"research-view__layout",children:[e.jsxs("aside",{className:"research-view__sidebar card",children:[e.jsxs("div",{className:"research-view__form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"research-query",children:"Query"}),e.jsx("textarea",{id:"research-query",className:"input research-view__textarea",value:n,onChange:s=>c(s.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Providers"}),e.jsx("div",{className:"research-view__providers",children:G.map(s=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:W.includes(s),disabled:!F(s),onChange:()=>{F(s)&&Y(l=>l.includes(s)?l.filter(b=>b!==s):[...l,s])}}),e.jsx("span",{children:Re[s]??s})]},s))})]}),e.jsxs("button",{className:"btn btn-primary",type:"button",disabled:!n.trim()||M,onClick:()=>void te(),children:[M?e.jsx(ve,{className:"animate-spin",size:14}):null,"Create Run"]})]}),e.jsxs("div",{className:"research-view__history-header form-group",children:[e.jsx("label",{htmlFor:"research-run-search",children:"Search"}),e.jsxs("div",{className:"research-view__history-search-row",children:[e.jsx(pe,{size:14}),e.jsx("input",{id:"research-run-search",className:"input",placeholder:"Search runs",value:E,onChange:s=>O(s.target.value)})]})]}),e.jsx("div",{className:"research-view__history","data-testid":"research-state-running",children:u.map(s=>e.jsxs("button",{type:"button",className:`research-view__history-item${q===s.id?" research-view__history-item--active":""}`,onClick:()=>y(s.id),children:[e.jsx("span",{className:"card-id",children:s.id}),e.jsx("span",{children:s.title})]},s.id))})]}),e.jsxs("div",{className:"research-view__reader card",children:[R&&e.jsx("p",{"data-testid":"research-state-loading",children:"Loading research runs…"}),!R&&w&&e.jsx("p",{"data-testid":"research-state-error",children:w}),!R&&!w&&u.length===0&&e.jsx("p",{"data-testid":"research-state-empty",children:"No research runs yet"}),t&&e.jsxs("div",{children:[e.jsxs("div",{className:"research-view__status-row",children:[e.jsx("span",{className:re}),e.jsx("strong",{children:se})]}),e.jsx("h3",{className:"research-view__run-title",children:t.title}),e.jsx("p",{className:"research-view__run-query",children:t.query}),e.jsx("p",{className:"research-view__run-summary","data-testid":"research-state-results",children:t.results?.summary??"No summary yet."}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",disabled:j==="cancel",onClick:()=>void T("cancel",()=>S(t.id),"Run cancelled"),children:"Cancel"}),e.jsx("button",{className:"btn",type:"button",disabled:j==="retry",onClick:()=>void T("retry",()=>U(t.id),"Run retried"),children:"Retry"}),Q.includes("markdown")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-markdown",onClick:()=>void K("markdown"),children:"Export MD"}),Q.includes("json")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-json",onClick:()=>void K("json"),children:"Export JSON"}),Q.includes("html")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-html",onClick:()=>void K("html"),children:"Export HTML"})]}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn btn-primary",type:"button",disabled:j==="create-task",onClick:()=>void T("create-task",()=>g(t.id,`Research: ${t.title}`),"Task created from research"),children:"Create Task"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"research-task-id",children:"Task ID"}),e.jsx("input",{id:"research-task-id",className:"input",placeholder:"Task ID",value:$,onChange:s=>ee(s.target.value)})]}),e.jsx("button",{className:"btn",type:"button",disabled:!$.trim()||j==="attach-task",onClick:()=>void T("attach-task",()=>A(t.id,$.trim(),"document"),"Attached to task"),children:"Attach to Task"})]}),t.error&&e.jsx("p",{className:"research-view__error",children:t.error}),Array.isArray(t.results?.findings)&&t.results.findings.length>0&&e.jsx("div",{className:"research-view__findings",children:t.results.findings.map(s=>e.jsxs("article",{className:"research-view__finding card",children:[e.jsx("h4",{children:s.heading}),e.jsx("p",{children:s.content})]},s.heading))}),Array.isArray(t.results?.citations)&&t.results.citations.length>0&&e.jsx("ul",{className:"research-view__citations",children:t.results.citations.map(s=>e.jsx("li",{children:e.jsx("a",{href:s,target:"_blank",rel:"noreferrer",children:s})},s))}),t.events.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:"Run history"}),e.jsx("ul",{className:"research-view__events",children:t.events.map(s=>e.jsx("li",{children:s.message},s.id))})]})]}),!t&&u.length>0&&e.jsx("p",{children:"Select a run to view details."}),e.jsxs("div",{className:"research-view__stats",children:[e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:"Running"}),e.jsx("div",{className:"research-view__stat-value",children:p.running})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:"Completed"}),e.jsx("div",{className:"research-view__stat-value",children:p.completed})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:"Failed"}),e.jsx("div",{className:"research-view__stat-value",children:p.failed})]})]})]})]})]})}export{ke as ResearchView};
1
+ import{r as a,j as e}from"./vendor-react-K0fH_qHe.js";import{aq as ae,ar as ne,s as ce,as as ie,at as le,au as oe,av as de,aw as ue,ax as he,x as me,ay as be,L as ve,S as pe}from"./index-B4StE1qN.js";import"./vendor-xterm-DzcZoU0P.js";const C={webSearch:!0,pageFetch:!0,github:!1,localDocs:!0,llmSynthesis:!0};function z(d){const r=d?.researchGlobalDefaults,o=d?.researchSettings;return{enabled:o?.enabled??d?.researchEnabled??d?.researchGlobalEnabled??!0,searchProvider:o?.searchProvider??r?.searchProvider,synthesisProvider:o?.synthesisProvider??r?.synthesisProvider,synthesisModelId:o?.synthesisModelId??r?.synthesisModelId,enabledSources:{webSearch:o?.enabledSources?.webSearch??r?.enabledSources?.webSearch??C.webSearch,pageFetch:o?.enabledSources?.pageFetch??r?.enabledSources?.pageFetch??C.pageFetch,github:o?.enabledSources?.github??r?.enabledSources?.github??C.github,localDocs:o?.enabledSources?.localDocs??r?.enabledSources?.localDocs??C.localDocs,llmSynthesis:o?.enabledSources?.llmSynthesis??r?.enabledSources?.llmSynthesis??C.llmSynthesis},limits:{maxConcurrentRuns:o?.limits?.maxConcurrentRuns??d?.researchMaxConcurrentRuns??d?.researchGlobalMaxConcurrentRuns??3,maxSourcesPerRun:o?.limits?.maxSourcesPerRun??r?.maxSourcesPerRun??d?.researchMaxSourcesPerRun??d?.researchGlobalMaxSourcesPerRun??20,maxDurationMs:o?.limits?.maxDurationMs??d?.researchDefaultTimeout??d?.researchGlobalDefaultTimeout??3e5,requestTimeoutMs:o?.limits?.requestTimeoutMs??d?.researchFetchTimeoutMs??3e4},defaultExportFormat:r?.defaultExportFormat??"markdown"}}const xe=300,fe=4e3;function ye(d){const r=d?.projectId,[o,D]=a.useState([]),[u,t]=a.useState(null),[q,y]=a.useState(null),[x,R]=a.useState({available:!0}),[w,E]=a.useState(!0),[O,P]=a.useState(null),[S,U]=a.useState(""),_=a.useRef(0),g=a.useRef(0),A=a.useRef(r);a.useEffect(()=>{A.current!==r&&(A.current=r,g.current++)},[r]);const p=a.useCallback(async(n=S)=>{const c=++_.current,i=r;P(null);try{const h=await ae({q:n||void 0,limit:100},i);if(c!==_.current||i!==r)return;D(h.runs),R(h.availability),u&&!h.runs.some(m=>m.id===u)&&(t(null),y(null))}catch(h){if(c!==_.current||i!==r)return;P(h instanceof Error?h.message:"Failed to load research runs")}finally{c===_.current&&E(!1)}},[r,S,u]),f=a.useCallback(async n=>{const c=await ne(n,r);return y(c.run),R(c.availability),c.run},[r]);return a.useEffect(()=>{E(!0);const n=window.setTimeout(()=>{p(S)},xe);return()=>window.clearTimeout(n)},[p,S]),a.useEffect(()=>{if(!u){y(null);return}f(u)},[f,u]),a.useEffect(()=>{const n=g.current,c=()=>g.current!==n,i=r?`?projectId=${encodeURIComponent(r)}`:"";let h=!0;const m=()=>{!h||c()||(p(),u&&f(u))},V=ce(`/api/events${i}`,{events:{"research:run:created":m,"research:run:updated":m,"research:run:completed":m,"research:run:failed":m,"research:run:cancelled":m},onReconnect:m}),M=window.setInterval(m,fe);return()=>{h=!1,V(),window.clearInterval(M)}},[r,p,u,f]),{runs:o,selectedRun:q,selectedRunId:u,setSelectedRunId:t,availability:x,loading:w,error:O,searchQuery:S,setSearchQuery:U,refresh:p,createRun:n=>he(n,r),cancelRun:async n=>{const c=await ue(n,r);return u===n&&y(c.run),await p(),c},retryRun:async n=>{const c=await de(n,r);return u===n&&y(c.run),await p(),c},exportRun:(n,c)=>oe(n,c,r),createTaskFromRun:(n,c)=>le(n,{title:c},r),attachRunToTask:(n,c,i)=>ie(n,{taskId:c,mode:i},r),statusCounts:o.reduce((n,c)=>(n[c.status]+=1,n),{pending:0,running:0,completed:0,failed:0,cancelled:0})}}const Se=["web-search","page-fetch","github","local-docs","llm-synthesis"],je={"web-search":"webSearch","page-fetch":"pageFetch",github:"github","local-docs":"localDocs","llm-synthesis":"llmSynthesis"},Re={"web-search":"Web Search","page-fetch":"Page Fetch",github:"GitHub","local-docs":"Local Docs","llm-synthesis":"LLM Synthesis"};function ke({projectId:d,addToast:r,onOpenSettings:o,readinessVersion:D=0}){const{runs:u,selectedRun:t,selectedRunId:q,setSelectedRunId:y,availability:x,loading:R,error:w,searchQuery:E,setSearchQuery:O,createRun:P,cancelRun:S,retryRun:U,exportRun:_,createTaskFromRun:g,attachRunToTask:A,statusCounts:p,refresh:f}=ye({projectId:d}),[n,c]=a.useState(""),[i,h]=a.useState(()=>z(void 0)),[m,V]=a.useState([]),[M,J]=a.useState(!1),[W,Y]=a.useState([]),[$,ee]=a.useState(""),[j,I]=a.useState(null),G=x.supportedProviders??Se,F=s=>i.enabledSources[je[s]];a.useEffect(()=>{const s=G.filter(l=>F(l));Y(l=>{const b=l.filter(v=>s.includes(v));return b.length>0?b:s})},[i.enabledSources,G]),a.useEffect(()=>{let s=!1;return Promise.all([me(d),be().catch(()=>({providers:[]}))]).then(([l,b])=>{s||(h(z(l)),V(b.providers.filter(v=>v.type==="api_key").map(v=>({id:v.id,authenticated:v.authenticated}))))}).catch(()=>{s||h(z(void 0))}),()=>{s=!0}},[d,D]);const se=a.useMemo(()=>t?t.status:"No run selected",[t]),re=a.useMemo(()=>t?t.status==="pending"?"status-dot status-dot--pending":t.status==="running"?"status-dot status-dot--connecting":t.status==="completed"?"status-dot status-dot--online":t.status==="failed"||t.status==="cancelled"?"status-dot status-dot--error":"status-dot":"status-dot",[t]),Q=x.supportedExportFormats??["markdown","json","html"],L=i.searchProvider,X=i.enabledSources.webSearch&&!L,Z=i.enabledSources.llmSynthesis&&(!i.synthesisProvider||!i.synthesisModelId),B=a.useMemo(()=>new Map(m.map(s=>[s.id,s.authenticated])),[m]),H=a.useMemo(()=>{const s=new Set;return i.enabledSources.webSearch&&L&&s.add(L),i.enabledSources.llmSynthesis&&i.synthesisProvider&&s.add(i.synthesisProvider),[...s].filter(l=>B.has(l))},[i.enabledSources.llmSynthesis,i.enabledSources.webSearch,i.synthesisProvider,L,B]).find(s=>B.get(s)!==!0),N=a.useMemo(()=>x.available?i.enabled?X||Z?{reason:"Research defaults are incomplete.",details:"Select the required provider/model defaults in Research settings.",settingsSection:"research-global"}:H?{reason:`Missing API key for ${H}.`,details:"Add provider credentials in Authentication settings.",settingsSection:"authentication"}:null:{reason:"Research is disabled for this project.",details:"Enable project research settings to create runs.",settingsSection:"research-project"}:{reason:x.reason??"Research is unavailable for this project.",details:x.setupInstructions,settingsSection:"research-project"},[x.available,x.reason,x.setupInstructions,i.enabled,H,X,Z]),T=async(s,l,b)=>{I(s);try{await l(),r?.(b,"success"),await f()}catch(v){r?.(v instanceof Error?v.message:"Action failed","error")}finally{I(null)}},K=async s=>{if(t){I(`export-${s}`);try{const l=await _(t.id,s),b=new Blob([l.content],{type:"text/plain;charset=utf-8"}),v=URL.createObjectURL(b),k=document.createElement("a");k.href=v,k.download=l.filename,document.body.appendChild(k),k.click(),k.remove(),URL.revokeObjectURL(v),r?.(`Exported ${l.filename}`,"success")}catch(l){r?.(l instanceof Error?l.message:"Export failed","error")}finally{I(null)}}},te=async()=>{if(n.trim()){J(!0);try{const s=W.filter(b=>F(b));if(s.length===0){r?.("No enabled research sources are available for this project.","error");return}const l=await P({query:n.trim(),providers:s});y(l.run.id),c(""),r?.("Research run created","success"),await f()}catch(s){r?.(s instanceof Error?s.message:"Failed to create run","error")}finally{J(!1)}}};return e.jsxs("section",{className:"research-view","aria-label":"Research view",children:[e.jsxs("header",{className:"research-view__header",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"research-view__title",children:"Research"}),e.jsx("p",{className:"research-view__subtitle",children:"Create and track research runs with cited findings."})]}),e.jsx("button",{className:"btn",type:"button",onClick:()=>void f(),children:"Refresh"})]}),N?e.jsxs("div",{className:"research-view__state research-view__state--error card","data-testid":"research-state-unavailable",children:[e.jsx("p",{children:N.reason}),N.details&&e.jsx("p",{children:N.details}),e.jsxs("p",{children:["Current defaults: provider ",i.searchProvider??"(not set)",", max sources ",i.limits.maxSourcesPerRun]}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:()=>void f(),children:"Refresh"}),e.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>o?.(N.settingsSection),children:"Open Settings"})]})]}):e.jsxs("div",{className:"research-view__layout",children:[e.jsxs("aside",{className:"research-view__sidebar card",children:[e.jsxs("div",{className:"research-view__form",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"research-query",children:"Query"}),e.jsx("textarea",{id:"research-query",className:"input research-view__textarea",value:n,onChange:s=>c(s.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Providers"}),e.jsx("div",{className:"research-view__providers",children:G.map(s=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:W.includes(s),disabled:!F(s),onChange:()=>{F(s)&&Y(l=>l.includes(s)?l.filter(b=>b!==s):[...l,s])}}),e.jsx("span",{children:Re[s]??s})]},s))})]}),e.jsxs("button",{className:"btn btn-primary",type:"button",disabled:!n.trim()||M,onClick:()=>void te(),children:[M?e.jsx(ve,{className:"animate-spin",size:14}):null,"Create Run"]})]}),e.jsxs("div",{className:"research-view__history-header form-group",children:[e.jsx("label",{htmlFor:"research-run-search",children:"Search"}),e.jsxs("div",{className:"research-view__history-search-row",children:[e.jsx(pe,{size:14}),e.jsx("input",{id:"research-run-search",className:"input",placeholder:"Search runs",value:E,onChange:s=>O(s.target.value)})]})]}),e.jsx("div",{className:"research-view__history","data-testid":"research-state-running",children:u.map(s=>e.jsxs("button",{type:"button",className:`research-view__history-item${q===s.id?" research-view__history-item--active":""}`,onClick:()=>y(s.id),children:[e.jsx("span",{className:"card-id",children:s.id}),e.jsx("span",{children:s.title})]},s.id))})]}),e.jsxs("div",{className:"research-view__reader card",children:[R&&e.jsx("p",{"data-testid":"research-state-loading",children:"Loading research runs…"}),!R&&w&&e.jsx("p",{"data-testid":"research-state-error",children:w}),!R&&!w&&u.length===0&&e.jsx("p",{"data-testid":"research-state-empty",children:"No research runs yet"}),t&&e.jsxs("div",{children:[e.jsxs("div",{className:"research-view__status-row",children:[e.jsx("span",{className:re}),e.jsx("strong",{children:se})]}),e.jsx("h3",{className:"research-view__run-title",children:t.title}),e.jsx("p",{className:"research-view__run-query",children:t.query}),e.jsx("p",{className:"research-view__run-summary","data-testid":"research-state-results",children:t.results?.summary??"No summary yet."}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",disabled:j==="cancel",onClick:()=>void T("cancel",()=>S(t.id),"Run cancelled"),children:"Cancel"}),e.jsx("button",{className:"btn",type:"button",disabled:j==="retry",onClick:()=>void T("retry",()=>U(t.id),"Run retried"),children:"Retry"}),Q.includes("markdown")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-markdown",onClick:()=>void K("markdown"),children:"Export MD"}),Q.includes("json")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-json",onClick:()=>void K("json"),children:"Export JSON"}),Q.includes("html")&&e.jsx("button",{className:"btn",type:"button",disabled:j==="export-html",onClick:()=>void K("html"),children:"Export HTML"})]}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn btn-primary",type:"button",disabled:j==="create-task",onClick:()=>void T("create-task",()=>g(t.id,`Research: ${t.title}`),"Task created from research"),children:"Create Task"}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"research-task-id",children:"Task ID"}),e.jsx("input",{id:"research-task-id",className:"input",placeholder:"Task ID",value:$,onChange:s=>ee(s.target.value)})]}),e.jsx("button",{className:"btn",type:"button",disabled:!$.trim()||j==="attach-task",onClick:()=>void T("attach-task",()=>A(t.id,$.trim(),"document"),"Attached to task"),children:"Attach to Task"})]}),t.error&&e.jsx("p",{className:"research-view__error",children:t.error}),Array.isArray(t.results?.findings)&&t.results.findings.length>0&&e.jsx("div",{className:"research-view__findings",children:t.results.findings.map(s=>e.jsxs("article",{className:"research-view__finding card",children:[e.jsx("h4",{children:s.heading}),e.jsx("p",{children:s.content})]},s.heading))}),Array.isArray(t.results?.citations)&&t.results.citations.length>0&&e.jsx("ul",{className:"research-view__citations",children:t.results.citations.map(s=>e.jsx("li",{children:e.jsx("a",{href:s,target:"_blank",rel:"noreferrer",children:s})},s))}),t.events.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:"Run history"}),e.jsx("ul",{className:"research-view__events",children:t.events.map(s=>e.jsx("li",{children:s.message},s.id))})]})]}),!t&&u.length>0&&e.jsx("p",{children:"Select a run to view details."}),e.jsxs("div",{className:"research-view__stats",children:[e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:"Running"}),e.jsx("div",{className:"research-view__stat-value",children:p.running})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:"Completed"}),e.jsx("div",{className:"research-view__stat-value",children:p.completed})]}),e.jsxs("div",{className:"research-view__stat-card",children:[e.jsx("div",{className:"research-view__stat-label",children:"Failed"}),e.jsx("div",{className:"research-view__stat-value",children:p.failed})]})]})]})]})]})}export{ke as ResearchView};
@@ -1,4 +1,4 @@
1
- import{r as a,j as e}from"./vendor-react-K0fH_qHe.js";import{c as Et,b4 as kt,b5 as Ft,b6 as Dt,b7 as Mt,b8 as Rt,b9 as tt,ba as It,bb as $t,bc as at,bd as zt,be as At,bf as Bt,bg as Ht,bh as Ot,bi as Gt,bj as Tt,bk as Pt,w as Lt,aU as Vt,J as Ae,bl as he,X as re,aH as Fe,V as Pe,ad as Ut,aj as pt,aG as rt,aa as Kt,bm as Je,bn as Wt}from"./index-CEavim6l.js";import"./vendor-xterm-DzcZoU0P.js";/**
1
+ import{r as a,j as e}from"./vendor-react-K0fH_qHe.js";import{c as Et,b4 as kt,b5 as Ft,b6 as Dt,b7 as Mt,b8 as Rt,b9 as tt,ba as It,bb as $t,bc as at,bd as zt,be as At,bf as Bt,bg as Ht,bh as Ot,bi as Gt,bj as Tt,bk as Pt,w as Lt,aU as Vt,J as Ae,bl as he,X as re,aH as Fe,V as Pe,ad as Ut,aj as pt,aG as rt,aa as Kt,bm as Je,bn as Wt}from"./index-B4StE1qN.js";import"./vendor-xterm-DzcZoU0P.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as e}from"./vendor-react-K0fH_qHe.js";import{dj as C}from"./index-CEavim6l.js";function x(k={}){const{projectId:d,pollInterval:b=6e4,autoRefresh:p=!1,enabled:t=!0}=k,[S,o]=e.useState(null),[m,l]=e.useState(t),[E,c]=e.useState(null),[R,v]=e.useState(null),r=e.useRef(null),n=e.useRef(null),a=e.useRef(!0),s=e.useCallback(async()=>{if(!t){l(!1),c(null),o(null);return}r.current&&r.current.abort(),r.current=new AbortController,l(!0),c(null),o(null);try{const u=await C(d);if(!a.current)return;o(u),c(null),v(new Date),l(!1)}catch(u){if(u instanceof Error&&u.name==="AbortError"||!a.current)return;const A=u instanceof Error?u.message:"Failed to fetch memory backend status";c(A),l(!1)}},[t,d]);e.useEffect(()=>(a.current=!0,t?(s(),()=>{a.current=!1}):(r.current&&r.current.abort(),o(null),c(null),l(!1),()=>{a.current=!1})),[t,s]),e.useEffect(()=>{if(!(!t||!p))return n.current=setInterval(()=>{s()},b),()=>{n.current&&(clearInterval(n.current),n.current=null)}},[t,p,b,s]),e.useEffect(()=>()=>{a.current=!1,r.current&&r.current.abort(),n.current&&(clearInterval(n.current),n.current=null)},[]);const h=e.useCallback(()=>s(),[s]),f=m?null:S,B=f?.currentBackend??null,i=f?.capabilities??null,y=f?.availableBackends??[],I=i?.readable??!1,g=i?.writable??!1,w=i?.supportsAtomicWrite??!1;return{status:f,currentBackend:B,capabilities:i,availableBackends:y,isReadable:I,isWritable:g,supportsAtomicWrite:w,loading:m,error:E,lastUpdated:R,refresh:h}}export{x as u};
1
+ import{r as e}from"./vendor-react-K0fH_qHe.js";import{dj as C}from"./index-B4StE1qN.js";function x(k={}){const{projectId:d,pollInterval:b=6e4,autoRefresh:p=!1,enabled:t=!0}=k,[S,o]=e.useState(null),[m,l]=e.useState(t),[E,c]=e.useState(null),[R,v]=e.useState(null),r=e.useRef(null),n=e.useRef(null),a=e.useRef(!0),s=e.useCallback(async()=>{if(!t){l(!1),c(null),o(null);return}r.current&&r.current.abort(),r.current=new AbortController,l(!0),c(null),o(null);try{const u=await C(d);if(!a.current)return;o(u),c(null),v(new Date),l(!1)}catch(u){if(u instanceof Error&&u.name==="AbortError"||!a.current)return;const A=u instanceof Error?u.message:"Failed to fetch memory backend status";c(A),l(!1)}},[t,d]);e.useEffect(()=>(a.current=!0,t?(s(),()=>{a.current=!1}):(r.current&&r.current.abort(),o(null),c(null),l(!1),()=>{a.current=!1})),[t,s]),e.useEffect(()=>{if(!(!t||!p))return n.current=setInterval(()=>{s()},b),()=>{n.current&&(clearInterval(n.current),n.current=null)}},[t,p,b,s]),e.useEffect(()=>()=>{a.current=!1,r.current&&r.current.abort(),n.current&&(clearInterval(n.current),n.current=null)},[]);const h=e.useCallback(()=>s(),[s]),f=m?null:S,B=f?.currentBackend??null,i=f?.capabilities??null,y=f?.availableBackends??[],I=i?.readable??!1,g=i?.writable??!1,w=i?.supportsAtomicWrite??!1;return{status:f,currentBackend:B,capabilities:i,availableBackends:y,isReadable:I,isWritable:g,supportsAtomicWrite:w,loading:m,error:E,lastUpdated:R,refresh:h}}export{x as u};