@runfusion/fusion 0.27.1 → 0.28.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 (65) hide show
  1. package/dist/bin.js +3418 -864
  2. package/dist/client/assets/AgentDetailView-DSpIqBOs.css +1 -0
  3. package/dist/client/assets/{AgentDetailView-shgiiUb4.js → AgentDetailView-V32TpEe1.js} +3 -3
  4. package/dist/client/assets/{AgentsView-CpwqOVDz.js → AgentsView-CxITZE-U.js} +3 -3
  5. package/dist/client/assets/ChatView-7WPHyB_7.js +1 -0
  6. package/dist/client/assets/DevServerView-Diw4hjw0.js +1 -0
  7. package/dist/client/assets/{DirectoryPicker-C0kmRv0u.js → DirectoryPicker-CWSApoLU.js} +1 -1
  8. package/dist/client/assets/{DocumentsView-B94U9ijs.js → DocumentsView-1kr0dhsV.js} +1 -1
  9. package/dist/client/assets/{EvalsView-O_4YWy--.js → EvalsView-cDfXYiK6.js} +1 -1
  10. package/dist/client/assets/{ExperimentalAgentOnboardingModal-CkEiF85-.js → ExperimentalAgentOnboardingModal-lNSf6UtY.js} +1 -1
  11. package/dist/client/assets/{InsightsView-D-Qe0tRr.js → InsightsView-D2AjxOnu.js} +1 -1
  12. package/dist/client/assets/{MemoryView-CoRUmRvb.js → MemoryView-Dq4yjIPI.js} +1 -1
  13. package/dist/client/assets/{NodesView-DQzXjcLc.js → NodesView-Cpmkze7n.js} +4 -4
  14. package/dist/client/assets/{PiExtensionsManager-Dn1LmFbq.js → PiExtensionsManager-oi9FHT0y.js} +2 -2
  15. package/dist/client/assets/PluginManager-C4UoLv4U.css +1 -0
  16. package/dist/client/assets/PluginManager-o12KG4e8.js +1 -0
  17. package/dist/client/assets/ResearchView-C7uXon3o.css +1 -0
  18. package/dist/client/assets/ResearchView-C9bjVB7-.js +1 -0
  19. package/dist/client/assets/{SettingsModal-Bg1-3JO_.js → SettingsModal-CT01a5Rh.js} +1 -1
  20. package/dist/client/assets/SettingsModal-Cu93Jjho.js +31 -0
  21. package/dist/client/assets/{SetupWizardModal-DuzYPbuJ.js → SetupWizardModal-Agi3XNtZ.js} +1 -1
  22. package/dist/client/assets/{SkillsView-BIFoVNUf.js → SkillsView-DmZfbGLs.js} +1 -1
  23. package/dist/client/assets/{StashRecoveryView-C52KsV7f.js → StashRecoveryView-BwKJQaUW.js} +1 -1
  24. package/dist/client/assets/{TodoView-sS_mT0Y7.js → TodoView-uJRg4Cnl.js} +2 -2
  25. package/dist/client/assets/dashboard-view-C7Snlgow.js +21 -0
  26. package/dist/client/assets/dashboard-view-DqWnXEbq.css +1 -0
  27. package/dist/client/assets/{folder-open-B9cwJ-OX.js → folder-open-DU-Ec_iC.js} +1 -1
  28. package/dist/client/assets/index-CD0_dkME.css +1 -0
  29. package/dist/client/assets/index-DiewofJh.js +692 -0
  30. package/dist/client/assets/{star-BDn04UYV.js → star-Qi0GspVN.js} +1 -1
  31. package/dist/client/assets/{upload-zdPPycKQ.js → upload-Dx_l9Vbu.js} +1 -1
  32. package/dist/client/assets/{users-CPYZjK2g.js → users-3Qw_TMah.js} +1 -1
  33. package/dist/client/index.html +2 -2
  34. package/dist/client/version.json +1 -1
  35. package/dist/droid-cli/package.json +1 -1
  36. package/dist/extension.js +2628 -573
  37. package/dist/pi-claude-cli/package.json +1 -1
  38. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  39. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/registration.test.ts +2 -4
  40. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/runtime-availability.test.ts +5 -2
  41. package/dist/plugins/fusion-plugin-cli-printing-press/src/__tests__/workflow-integration.test.ts +7 -4
  42. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  43. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  44. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  45. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  46. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  47. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  48. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  49. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  50. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  51. package/package.json +1 -1
  52. package/skill/fusion/references/engine-tools.md +1 -0
  53. package/skill/fusion/references/extension-tools.md +3 -1
  54. package/dist/client/assets/AgentDetailView-B7QRcHJH.css +0 -1
  55. package/dist/client/assets/ChatView-DyRBOIKL.js +0 -1
  56. package/dist/client/assets/DevServerView-Cdelj9-m.js +0 -1
  57. package/dist/client/assets/PluginManager-DtRQXia5.css +0 -1
  58. package/dist/client/assets/PluginManager-Y0fs-6No.js +0 -1
  59. package/dist/client/assets/ResearchView-BEI4ZSGs.css +0 -1
  60. package/dist/client/assets/ResearchView-CjOxKhdS.js +0 -1
  61. package/dist/client/assets/SettingsModal-DL7tjJQa.js +0 -31
  62. package/dist/client/assets/dashboard-view-BoTzlP8b.css +0 -1
  63. package/dist/client/assets/dashboard-view-MB-86hAu.js +0 -21
  64. package/dist/client/assets/index-BOjPRqEk.js +0 -692
  65. package/dist/client/assets/index-BmSEq8Rb.css +0 -1
@@ -1 +0,0 @@
1
- import{r as g,j as e}from"./vendor-react-K0fH_qHe.js";import{v as fe,ei as ye,ej as Y,s as je,X as Z,at as Ne,aR as Se,I as T,aY as ee,W as se,R as ve,ek as we,ap as Ce,el as Ie,em as $e,cu as Pe,en as Re,eo as ke,ep as Ee,eq as Be,er as te,cr as Le,es as Ae}from"./index-BOjPRqEk.js";import{D as Fe}from"./DirectoryPicker-C0kmRv0u.js";import"./vendor-xterm-DzcZoU0P.js";import"./folder-open-B9cwJ-OX.js";const ie="fusion-plugin-agent-browser",ne={enabled:{type:"boolean",label:"Enable Agent Browser",group:"General"},installChannel:{type:"enum",label:"Install Channel",enumValues:["stable","beta","nightly"],defaultValue:"stable",group:"General"},commandTimeoutMs:{type:"number",label:"Command Timeout (ms)",defaultValue:12e4,group:"General"},headlessMode:{type:"boolean",label:"Headless Mode",defaultValue:!0,group:"Browser"},allowedDomains:{type:"array",label:"Allowed Domains",itemType:"string",group:"Browser"},promptExecutorSystem:{type:"string",label:"Executor System Prompt",multiline:!0,group:"Prompt Contributions"},promptExecutorTask:{type:"string",label:"Executor Task Prompt",multiline:!0,group:"Prompt Contributions"},promptTriage:{type:"string",label:"Triage Prompt",multiline:!0,group:"Prompt Contributions"},promptReviewer:{type:"string",label:"Reviewer Prompt",multiline:!0,group:"Prompt Contributions"},promptHeartbeat:{type:"string",label:"Heartbeat Prompt",multiline:!0,group:"Prompt Contributions"},skillExposure:{type:"enum",label:"Skill Exposure",enumValues:["none","selected","all"],defaultValue:"selected",group:"Skills"}},ae=[{id:"fusion-plugin-hermes-runtime",name:"Hermes Runtime",description:"Runtime provider for Hermes CLI-backed execution.",category:"runtime",path:"./plugins/fusion-plugin-hermes-runtime",experimental:!0},{id:"fusion-plugin-paperclip-runtime",name:"Paperclip Runtime",description:"Runtime provider for Paperclip agent connections.",category:"runtime",path:"./plugins/fusion-plugin-paperclip-runtime"},{id:"fusion-plugin-openclaw-runtime",name:"OpenClaw Runtime",description:"Runtime provider for OpenClaw execution.",category:"runtime",path:"./plugins/fusion-plugin-openclaw-runtime",experimental:!0},{id:"fusion-plugin-droid-runtime",name:"Droid Runtime",description:"Runtime provider for Droid CLI execution.",category:"runtime",path:"./plugins/fusion-plugin-droid-runtime",experimental:!0},{id:"fusion-plugin-dependency-graph",name:"Dependency Graph",description:"Dashboard plugin for task dependency graph visualization.",category:"integration",path:"./plugins/fusion-plugin-dependency-graph"},{id:"fusion-plugin-reports",name:"Reports",description:"View report history, compare runs side-by-side, and export standalone HTML summaries.",category:"integration",path:"./plugins/fusion-plugin-reports"},{id:"fusion-plugin-whatsapp-chat",name:"WhatsApp Chat",description:"Pairs to WhatsApp Web (multi-device) with QR or pairing code, then bridges direct chats to a Fusion agent.",category:"integration",path:"./plugins/fusion-plugin-whatsapp-chat"},{id:"fusion-plugin-cli-printing-press",name:"CLI Printing Press",description:"Guided wizard for drafting external service CLI definitions.",category:"integration",path:"./plugins/fusion-plugin-cli-printing-press"},{id:ie,name:"Agent Browser",description:"Built-in integration metadata. Package install support lands in FN-3101.",category:"integration",hasSetup:!0}],I={started:"var(--color-success)",loaded:"var(--color-warning)",error:"var(--color-error)",stopped:"var(--color-muted)",installed:"var(--color-info)"};function De(r){const o=r.settingsSchema,h=o&&Object.keys(o).length>0;return r.id!==ie?h?o:void 0:h?{...ne,...o}:ne}function ze(r){const o=new Map,h=[];for(const[x,f]of Object.entries(r))if(f.group){const N=o.get(f.group)??[];N.push([x,f]),o.set(f.group,N)}else h.push([x,f]);return{grouped:o,ungrouped:h}}function _e({addToast:r,projectId:o}){const[h,x]=g.useState([]),[f,N]=g.useState(!0),[le,$]=g.useState(!1),[w,P]=g.useState(""),[B,L]=g.useState(!1),[A,F]=g.useState(!1),[S,D]=g.useState(null),[l,R]=g.useState(null),[p,b]=g.useState({}),[re,z]=g.useState(!1),[O,G]=g.useState(null),[ce,k]=g.useState({}),[oe,U]=g.useState(null),[C,q]=g.useState(null),{confirm:ue}=fe(),m=g.useCallback(async()=>{try{N(!0);const s=await ye(o);x(s)}catch(s){r(`Failed to load plugins: ${s instanceof Error?s.message:String(s)}`,"error")}finally{N(!1)}},[o,r]);g.useEffect(()=>{m()},[m]),g.useEffect(()=>{const s=ae.filter(c=>c.hasSetup&&h.some(i=>i.id===c.id));if(s.length===0)return;let n=!1;return Promise.all(s.map(async c=>{try{const i=await Y(c.id,o);if(n)return;k(u=>({...u,[c.id]:i}))}catch{if(n)return;k(i=>({...i,[c.id]:{hasSetup:!0,setupCheckDeferred:!0,deferredReason:"plugin-not-started",pluginState:"installed"}}))}})),()=>{n=!0}},[h,o]);const de=g.useRef([]);de.current=h,g.useEffect(()=>{const s=o?`?projectId=${encodeURIComponent(o)}`:"",n=c=>{try{const i=JSON.parse(c.data);if(i.scope==="project"&&(i.projectId??o)!==o)return;switch(i.transition){case"installing":case"enabled":case"disabled":case"settings-updated":x(u=>{const a=u.findIndex(t=>t.id===i.pluginId);if(a>=0){const t=[...u];return t[a]={...t[a],enabled:i.enabled,state:i.state,settings:i.settings,error:i.error},t}else return m(),u});break;case"state-changed":x(u=>{const a=u.findIndex(t=>t.id===i.pluginId);if(a>=0){const t=[...u];return t[a]={...t[a],state:i.state,error:i.error},t}return u});break;case"uninstalled":x(u=>u.filter(a=>a.id!==i.pluginId));break;case"error":x(u=>{const a=u.findIndex(t=>t.id===i.pluginId);if(a>=0){const t=[...u];return t[a]={...t[a],state:i.state,error:i.error},t}return u});break}}catch{}};return je(`/api/events${s}`,{events:{"plugin:lifecycle":n},onReconnect:()=>{m()}})},[o,m]);const M=async()=>{if(!w.trim()){r("Please enter a plugin path","error");return}try{L(!0),await te({path:w,...A?{aiScanOnLoad:!0}:{}},o),r("Plugin installed globally","success"),$(!1),P(""),F(!1),await m()}catch(s){r(`Failed to install plugin: ${s instanceof Error?s.message:String(s)}`,"error")}finally{L(!1)}},pe=async s=>{if(!s.path){r(`${s.name} is built in and does not have an installable package yet`,"warning");return}try{G(s.id),await te({path:s.path},o),r(`${s.name} installed globally`,"success"),await m()}catch(n){r(`Failed to install ${s.name}: ${n instanceof Error?n.message:String(n)}`,"error")}finally{G(null)}},V=async s=>{try{q(s.id);const n=await Ae(s.id,o);if(!n.success){r(`Failed to install ${s.name} setup: ${n.error??"unknown error"}`,"error");return}r(`${s.name} setup installed`,"success"),U(s.id);const c=await Y(s.id,o);k(i=>({...i,[s.id]:c}))}catch(n){r(`Failed to install ${s.name} setup: ${n instanceof Error?n.message:String(n)}`,"error")}finally{q(null),U(null)}},_=async s=>{try{const n=await Ee(s.id,o);if(n.state==="error"){r(`Failed to enable ${s.name}: ${n.error??"Unknown error"}`,"error"),await m();return}r(`${s.name} enabled for this project`,"success"),await m()}catch(n){r(`Failed to enable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},H=async s=>{try{await ke(s.id,o),r(`${s.name} disabled for this project`,"success"),await m()}catch(n){r(`Failed to disable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},W=async s=>{try{D(s.id),await Re(s.id,o),r(`${s.name} reloaded`,"success"),await m()}catch(n){r(`Failed to reload plugin: ${n instanceof Error?n.message:String(n)}`,"error")}finally{D(null)}},J=async s=>{if(await ue({title:"Uninstall Plugin Globally",message:`Are you sure you want to uninstall "${s.name}" globally (all projects)?`,danger:!0}))try{await Be(s.id,o),r(`${s.name} uninstalled globally`,"success"),await m(),R(null)}catch(c){r(`Failed to uninstall plugin: ${c instanceof Error?c.message:String(c)}`,"error")}},ge=async(s,n)=>{try{await Ie(s.id,{aiScanOnLoad:n},o),r(`AI scan on load ${n?"enabled":"disabled"}`,"success"),await m()}catch(c){r(`Failed to update plugin: ${c instanceof Error?c.message:String(c)}`,"error")}},me=async s=>{try{await $e(s.id,o),r(`${s.name} rescanned`,"success"),await m()}catch(n){r(`Failed to rescan plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},E=async s=>{R(s);try{z(!0);const n=await Le(s.id,o);b(n)}catch{b({})}finally{z(!1)}},he=async()=>{if(l)try{await Pe(l.id,p,o),r("Settings saved","success")}catch(s){r(`Failed to save settings: ${s instanceof Error?s.message:String(s)}`,"error")}};if(l)return e.jsxs("div",{className:"plugin-manager-detail","data-testid":"plugin-manager-detail",children:[e.jsxs("div",{className:"plugin-manager-detail-header",children:[e.jsx("button",{className:"btn-icon",onClick:()=>R(null),"aria-label":"Back to plugin list",children:e.jsx(Z,{size:16})}),e.jsxs("div",{className:"plugin-detail-title",children:[e.jsx("h4",{className:"plugin-detail-name",children:l.name}),e.jsx("span",{className:"plugin-state-badge",style:{color:I[l.state]||I.installed},children:l.state})]})]}),e.jsxs("div",{className:"plugin-detail-content",children:[e.jsxs("div",{className:"plugin-detail-card",children:[l.description&&e.jsx("p",{className:"plugin-description",children:l.description}),l.author&&e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:"Author:"}),l.author]}),l.homepage&&e.jsxs("p",{className:"plugin-detail-meta-row plugin-homepage",children:[e.jsx("span",{className:"text-muted",children:"Homepage:"}),e.jsxs("a",{href:l.homepage,target:"_blank",rel:"noopener noreferrer",children:[l.homepage,e.jsx(Ne,{size:12})]})]}),e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:"Version:"}),l.version]})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:"Security Scan"}),e.jsxs("div",{className:"plugin-security-row",children:[e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:!!l.aiScanOnLoad,onChange:s=>void ge(l,s.target.checked)}),"Enable AI scan before load/reload"]}),e.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:()=>void me(l),children:[e.jsx(Se,{size:14})," Rescan and Reload"]})]}),e.jsx("p",{className:"text-muted",children:"Turning this on only updates configuration. Use Rescan and Reload to run it now."}),l.lastSecurityScan?e.jsxs("div",{className:"plugin-security-results",children:[e.jsxs("div",{className:"plugin-security-header",children:[e.jsx("span",{className:`plugin-state-badge plugin-security-badge plugin-security-badge--${l.lastSecurityScan.verdict}`,children:l.lastSecurityScan.verdict}),e.jsx("span",{className:"text-muted",children:l.lastSecurityScan.scannedAt})]}),e.jsx("p",{className:"plugin-security-summary",children:l.lastSecurityScan.summary}),e.jsxs("details",{children:[e.jsxs("summary",{children:["Findings (",l.lastSecurityScan.findings.length,")"]}),e.jsx("ul",{className:"plugin-security-findings",children:l.lastSecurityScan.findings.map((s,n)=>e.jsxs("li",{children:[e.jsx("strong",{children:s.severity})," ",s.category," — ",s.file,": ",s.reason]},`${s.file}-${n}`))})]})]}):e.jsx("p",{className:"text-muted",children:"No security scan has been run yet."})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:"Settings"}),re?e.jsx("p",{className:"text-muted",children:"Loading..."}):(()=>{const s=De(l);return s&&Object.keys(s).length>0?e.jsxs("div",{className:"plugin-settings-form",children:[(()=>{const{grouped:n,ungrouped:c}=ze(s),i=[];c.length>0&&i.push({title:null,entries:c});for(const[u,a]of n.entries())i.push({title:u,entries:a});return i.map(u=>e.jsxs("div",{className:u.title?"plugin-settings-group":void 0,children:[u.title&&e.jsx("h6",{className:"plugin-settings-group-heading",children:u.title}),u.entries.map(([a,t])=>{const y=`setting-${a}-help`;return e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:`setting-${a}`,children:[t.label||a,t.required&&" *"]}),t.type==="string"&&!t.multiline&&e.jsx("input",{className:"input",type:"text",id:`setting-${a}`,value:p[a]??"",onChange:d=>b({...p,[a]:d.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?y:void 0}),t.type==="string"&&t.multiline&&e.jsx("textarea",{className:"input",id:`setting-${a}`,rows:4,value:p[a]??"",onChange:d=>b({...p,[a]:d.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?y:void 0}),t.type==="password"&&e.jsx("input",{className:"input",type:"password",id:`setting-${a}`,value:p[a]??"",onChange:d=>b({...p,[a]:d.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?y:void 0}),t.type==="number"&&e.jsx("input",{className:"input",type:"number",id:`setting-${a}`,value:p[a]??"",onChange:d=>b({...p,[a]:Number(d.target.value)}),"aria-describedby":t.description&&!t.required?y:void 0}),t.type==="boolean"&&e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:p[a]??!1,onChange:d=>b({...p,[a]:d.target.checked})}),t.description]}),t.type==="enum"&&e.jsxs("select",{className:"select",id:`setting-${a}`,value:p[a]??"",onChange:d=>b({...p,[a]:d.target.value}),"aria-describedby":t.description&&!t.required?y:void 0,children:[e.jsx("option",{value:"",children:"Select..."}),t.enumValues?.map(d=>e.jsx("option",{value:d,children:d},d))]}),t.type==="array"&&e.jsxs("div",{className:"plugin-settings-array",children:[p[a]?.map((d,j)=>e.jsxs("div",{className:"plugin-settings-array-item",children:[e.jsx("input",{className:"input",type:t.itemType==="number"?"number":"text",value:d??"",onChange:Q=>{const v=Q.target.value,X=[...p[a]||[]];X[j]=t.itemType==="number"?Number(v):v,b({...p,[a]:X})}}),e.jsx("button",{className:"btn-icon",onClick:()=>{const v=[...p[a]||[]];v.splice(j,1),b({...p,[a]:v})},"aria-label":"Remove item",children:e.jsx(Z,{size:14})})]},j)),e.jsxs("button",{className:"btn btn-secondary",onClick:()=>{const d=p[a]||[],j=t.itemType==="number"?0:"";b({...p,[a]:[...d,j]})},children:[e.jsx(T,{size:14})," Add Item"]})]}),t.description&&!t.required&&!t.multiline&&e.jsx("span",{id:y,className:"form-help",children:t.description})]},a)})]},u.title??"ungrouped"))})(),e.jsx("button",{className:"btn btn-primary",onClick:he,children:"Save Settings"})]}):e.jsx("p",{className:"text-muted",children:"No configurable settings."})})()]}),e.jsxs("div",{className:"plugin-detail-actions",children:[l.state==="started"&&e.jsxs("button",{className:"btn btn-secondary",onClick:()=>W(l),disabled:S===l.id,children:[e.jsx(ee,{size:14,className:S===l.id?"spin":""}),S===l.id?"Reloading...":"Reload"]}),l.enabled?e.jsx("button",{className:"btn btn-secondary",onClick:()=>H(l),children:"Disable in Project"}):e.jsx("button",{className:"btn btn-primary",onClick:()=>_(l),children:"Enable in Project"}),e.jsxs("button",{className:"btn btn-danger",onClick:()=>J(l),children:[e.jsx(se,{size:14})," Uninstall Globally"]})]})]})]});const be=new Map(h.map(s=>[s.id,s])),K=h,xe=()=>e.jsxs("section",{className:"plugin-builtins-section","aria-label":"Built-in Plugins",children:[e.jsxs("div",{className:"plugin-builtins-header",children:[e.jsx("h4",{className:"plugin-builtins-heading",children:"Built-in Plugins"}),e.jsx("p",{className:"plugin-builtins-description",children:"Built-in plugin catalog for runtimes and integrations."})]}),e.jsx("div",{className:"plugin-builtins-list","aria-label":"Built-in plugin recommendations",children:ae.map(s=>{const n=be.get(s.id),c=!!n,i=ce[s.id],u=!!(i&&"setupCheckDeferred"in i&&i.setupCheckDeferred),a=i&&"status"in i?i.status:void 0,t=c&&s.hasSetup&&i?.hasSetup&&!u&&n?.state==="started"&&(a==="not-installed"||a==="error"),y=c&&i?.hasSetup&&a==="installed",d=oe===s.id,j=!s.path;return e.jsxs("div",{className:"plugin-builtins-item",children:[e.jsxs("div",{className:"plugin-builtins-meta",children:[e.jsx("span",{className:"plugin-builtins-name",children:s.name}),s.experimental&&e.jsx("span",{className:"plugin-builtins-runtime-badge",children:"Experimental"}),e.jsx("span",{className:"plugin-builtins-runtime-badge",children:s.category}),e.jsx("span",{className:`plugin-builtins-status ${c?"plugin-builtins-status--installed":"plugin-builtins-status--available"}`,children:c?"Installed":j?"Built in":"Not installed"}),t&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--warning",children:"Setup required"}),y&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--ready",children:"Setup ready"}),d&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--pending",children:"Checking setup..."}),u&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--deferred",children:"Start plugin to check setup"}),e.jsx("span",{className:"plugin-builtins-description-text",children:s.description})]}),j?c&&t?e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void V(s),disabled:C===s.id||d,children:C===s.id?"Setting up...":"Install Setup"}):c&&n?e.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>void E(n),children:"Manage"}):e.jsx("span",{className:"plugin-builtins-metadata-only",children:"Built-in metadata only"}):e.jsx("button",{className:`btn ${c&&!t?"btn-secondary":"btn-primary"} btn-sm`,onClick:()=>{if(!c){pe(s);return}if(t){V(s);return}n&&E(n)},disabled:O===s.id||C===s.id||d,children:c?t?C===s.id?"Setting up...":"Install Setup":"Manage":O===s.id?"Installing...":`Install ${s.name}`})]},s.id)})})]});return e.jsxs("div",{className:"plugin-manager","data-testid":"plugin-manager",children:[e.jsxs("div",{className:"plugin-manager-header",children:[e.jsx("span",{className:"plugin-manager-header-title",children:"Installed Plugins"}),e.jsxs("div",{className:"plugin-manager-actions",children:[e.jsxs("button",{className:"btn btn-sm",onClick:m,title:"Refresh","aria-label":"Refresh plugin list",children:[e.jsx(ve,{size:14,className:f?"spin":""}),"Refresh"]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>$(!0),children:[e.jsx(T,{size:14})," Install"]})]})]}),le&&e.jsxs("div",{className:"plugin-install-form",children:[e.jsxs("p",{className:"plugin-install-hint",children:["Browse to a plugin package root (contains ",e.jsx("code",{children:"manifest.json"}),") or a built ",e.jsx("code",{children:"dist"})," directory."]}),e.jsx(Fe,{value:w,onChange:P,placeholder:"Absolute path to plugin directory or dist folder",onInputKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),M())}}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:A,onChange:s=>F(s.target.checked)}),"Enable AI security scan on load"]}),e.jsxs("div",{className:"plugin-install-actions",children:[e.jsx("button",{className:"btn btn-primary",onClick:M,disabled:B||!w.trim(),children:B?"Installing...":"Install Plugin Globally"}),e.jsx("button",{className:"btn btn-secondary",onClick:()=>{$(!1),P("")},children:"Cancel"})]})]}),f?e.jsx("div",{className:"settings-empty-state",children:"Loading plugins..."}):e.jsxs(e.Fragment,{children:[K.length===0?e.jsxs("div",{className:"settings-empty-state",children:[e.jsx(we,{size:32,className:"text-muted"}),e.jsx("p",{children:"No plugins installed."}),e.jsx("p",{className:"text-muted",children:"Install a plugin to get started, or use the built-in catalog below."})]}):e.jsx("div",{className:"plugin-list",children:K.map(s=>e.jsxs("div",{className:"plugin-item",children:[e.jsxs("div",{className:"plugin-info",children:[e.jsx("span",{className:"plugin-name",children:s.name}),e.jsxs("span",{className:"plugin-version text-muted",children:["v",s.version]}),e.jsx("span",{className:"plugin-state-badge",style:{color:I[s.state]||I.installed},children:s.state})]}),e.jsxs("div",{className:"plugin-actions",children:[s.state==="started"&&e.jsx("button",{className:"btn-icon",onClick:()=>W(s),disabled:S===s.id,title:"Reload",children:e.jsx(ee,{size:14,className:S===s.id?"spin":""})}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>s.enabled?H(s):_(s),"aria-label":`${s.enabled?"Disable":"Enable"} ${s.name}`}),e.jsx("span",{className:"toggle-slider"})]}),e.jsx("button",{className:"btn-icon",onClick:()=>E(s),title:"Settings",children:e.jsx(Ce,{size:14})}),e.jsx("button",{className:"btn-icon",onClick:()=>J(s),title:"Uninstall globally",children:e.jsx(se,{size:14})})]})]},s.id))}),xe()]})]})}export{ne as AGENT_BROWSER_SETTINGS_SCHEMA,ie as BUILTIN_AGENT_BROWSER_PLUGIN_ID,_e as PluginManager,I as STATE_COLORS};
@@ -1 +0,0 @@
1
- .research-task-action-modal__body{display:flex;flex-direction:column;gap:var(--space-md)}.research-task-action-modal__preview{display:flex;flex-direction:column;gap:var(--space-xs);padding:var(--space-md)}.research-task-action-modal__preview p{margin:0}.research-task-action-modal__field{display:flex;flex-direction:column;gap:var(--space-xs);color:var(--text-muted);text-transform:uppercase}.research-task-action-modal__textarea{min-height:calc(var(--space-2xl) * 2);resize:vertical}@media(max-width:768px){.research-task-action-modal{width:min(100%,calc(100vw - (var(--space-md) * 2)))}.research-task-action-modal__body{gap:var(--space-lg)}.research-task-action-modal__preview{padding:var(--space-lg)}.research-task-action-modal .modal-actions{flex-direction:column;align-items:stretch;gap:var(--space-sm)}.research-task-action-modal .modal-actions .btn{min-height:calc(var(--space-lg) * 2 + var(--space-xs))}}.research-view{display:flex;flex-direction:column;gap:var(--space-md);height:100%;min-height:0;padding:var(--space-lg);padding-bottom:var(--space-lg)}.research-view__header{display:flex;align-items:flex-start;justify-content:space-between;gap:var(--space-md)}.research-view__title{margin:0}.research-view__subtitle{margin:var(--space-xs) 0 0;color:var(--text-muted)}.research-view__layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,2fr);gap:var(--space-md);min-height:0;flex:1}.research-view__sidebar,.research-view__reader{padding:var(--space-md);display:flex;flex-direction:column;gap:var(--space-md);min-height:0}.research-view__form{display:flex;flex-direction:column;gap:var(--space-sm)}.research-view__form .form-group,.research-view__history-header.form-group,.research-view__actions .form-group{margin:0;padding:0}.research-view__textarea{min-height:calc(var(--space-2xl) * 3);resize:vertical}.research-view__providers{display:grid;gap:var(--space-xs)}.research-view__history-header{display:flex;flex-direction:column;align-items:stretch;gap:var(--space-xs)}.research-view__history-search-row{display:flex;align-items:center;gap:var(--space-xs)}.research-view__history-search-row .input{flex:1;min-width:0}.research-view__history{display:flex;flex-direction:column;gap:var(--space-xs);flex:1;min-height:0;overflow:auto}.research-view__history-item{text-align:left;padding:var(--space-sm);min-height:calc(var(--space-lg) * 2 + var(--space-xs));display:flex;flex-direction:column;justify-content:center;gap:var(--space-xs);cursor:pointer}.research-view__history-item--active{border-color:var(--todo);box-shadow:var(--focus-ring)}.research-view__status-row{display:flex;align-items:center;gap:var(--space-xs);text-transform:capitalize}.research-view__run-title,.research-view__run-query,.research-view__run-summary{margin:0}.research-view__run-query{color:var(--text-muted)}.research-view__actions{display:flex;flex-wrap:wrap;gap:var(--space-xs);margin-top:var(--space-sm)}.research-view__citations{margin:var(--space-sm) 0 0;padding-left:var(--space-lg);display:flex;flex-direction:column;gap:var(--space-xs)}.research-view__citations a{color:var(--text)}.research-view__error{color:var(--color-error)}.research-view__findings{display:flex;flex-direction:column;gap:var(--space-sm)}.research-view__finding{padding:var(--space-sm)}.research-view__finding h4,.research-view__finding p{margin:0}.research-view__finding-actions{margin-top:var(--space-sm)}.research-view__events{margin:var(--space-sm) 0 0;padding-left:var(--space-lg)}.research-view__stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--space-sm)}.research-view__stat-card{border:var(--btn-border-width) solid var(--border);border-radius:var(--radius-sm);padding:var(--space-sm);background:var(--surface)}.research-view__stat-label{color:var(--text-muted);text-transform:uppercase}.research-view__stat-value{font-family:var(--font-mono)}.research-view__state--error{border-color:var(--color-error)}@media(max-width:768px){.research-view{overflow-y:auto;-webkit-overflow-scrolling:touch;padding:var(--space-md);padding-bottom:calc(var(--space-md) + var(--mobile-nav-height) + env(safe-area-inset-bottom,0px) + var(--standalone-bottom-gap))}.research-view__layout{display:flex;flex-direction:column;grid-template-columns:minmax(0,1fr);flex:initial}.research-view__history{flex:initial;min-height:initial;overflow:visible}.research-view__header{flex-direction:column}.research-view__stats{grid-template-columns:minmax(0,1fr)}.research-view__history-item{min-height:calc(var(--space-lg) * 2 + var(--space-sm))}}
@@ -1 +0,0 @@
1
- import{r as c,j as e}from"./vendor-react-K0fH_qHe.js";import{aw as de,ax as ue,s as he,ay as me,az as be,aA as fe,aB as xe,aC as ve,aD as pe,ah as ye,u as ge,aE as je,x as Re,aF as _e,L as Se,S as we}from"./index-BOjPRqEk.js";import"./vendor-xterm-DzcZoU0P.js";const Ne="builtin",U={webSearch:!0,pageFetch:!0,github:!1,localDocs:!0,llmSynthesis:!0};function Z(n){const t=n?.researchGlobalDefaults,i=n?.researchSettings;return{enabled:i?.enabled??n?.researchEnabled??n?.researchGlobalEnabled??!0,searchProvider:i?.searchProvider??t?.searchProvider??n?.researchGlobalWebSearchProvider??Ne,synthesisProvider:i?.synthesisProvider??t?.synthesisProvider,synthesisModelId:i?.synthesisModelId??t?.synthesisModelId,enabledSources:{webSearch:i?.enabledSources?.webSearch??t?.enabledSources?.webSearch??U.webSearch,pageFetch:i?.enabledSources?.pageFetch??t?.enabledSources?.pageFetch??U.pageFetch,github:i?.enabledSources?.github??t?.enabledSources?.github??U.github,localDocs:i?.enabledSources?.localDocs??t?.enabledSources?.localDocs??U.localDocs,llmSynthesis:i?.enabledSources?.llmSynthesis??t?.enabledSources?.llmSynthesis??U.llmSynthesis},limits:{maxConcurrentRuns:i?.limits?.maxConcurrentRuns??n?.researchMaxConcurrentRuns??n?.researchGlobalMaxConcurrentRuns??3,maxSourcesPerRun:i?.limits?.maxSourcesPerRun??t?.maxSourcesPerRun??n?.researchMaxSourcesPerRun??n?.researchGlobalMaxSourcesPerRun??20,maxDurationMs:i?.limits?.maxDurationMs??n?.researchDefaultTimeout??n?.researchGlobalDefaultTimeout??3e5,requestTimeoutMs:i?.limits?.requestTimeoutMs??n?.researchGlobalFetchTimeoutMs??3e4},defaultExportFormat:t?.defaultExportFormat??"markdown"}}const ke=300,Ee=4e3,Ce=["queued","running","cancelling","retry_waiting"];function ee(n,t){if(n instanceof ye){const i=n;return{message:n.message,status:n.status,code:i.researchCode??"INTERNAL_ERROR",setupHint:i.setupHint,retryable:i.retryable}}return n instanceof Error?{message:n.message,code:"INTERNAL_ERROR"}:{message:t,code:"INTERNAL_ERROR"}}function Pe(n){if(!n)return{cancelable:!1,retryable:!1,isTransitioning:!1,blockingReason:"No run selected"};const t=Ce.includes(n.status),i=n.status==="queued"||n.status==="running",b=n.lifecycle?.retryable,u=n.status==="failed"||n.status==="timed_out",r=!!(u&&b);let p;return!i&&t?p="Run is already transitioning":!i&&n.status==="completed"?p="Completed runs cannot be cancelled":!i&&n.status==="cancelled"?p="Run is already cancelled":!i&&n.status==="retry_exhausted"?p="Retry attempts exhausted":!i&&n.status==="failed"?p="Failed runs cannot be cancelled":!i&&n.status==="timed_out"&&(p="Timed out runs cannot be cancelled"),!r&&u&&b===!1&&(p=n.lifecycle?.errorCode==="RETRY_EXHAUSTED"?"Retry attempts exhausted":"Run is not retryable"),{cancelable:i,retryable:r,isTransitioning:t,blockingReason:p}}function Te(n){const t=n?.projectId,[i,b]=c.useState([]),[u,r]=c.useState(null),[p,R]=c.useState(null),[g,w]=c.useState({available:!0}),[k,P]=c.useState(!0),[L,T]=c.useState(null),[F,j]=c.useState(null),[_,D]=c.useState(""),E=c.useRef(0),N=c.useRef(0),S=c.useRef(t);c.useEffect(()=>{S.current!==t&&(S.current=t,N.current++)},[t]);const f=c.useCallback(async(l=_)=>{const a=++E.current,o=t;T(null),j(null);try{const y=await de({q:l||void 0,limit:100},o);if(a!==E.current||o!==t)return;b(y.runs),w(y.availability),u&&!y.runs.some(v=>v.id===u)&&(r(null),R(null))}catch(y){if(a!==E.current||o!==t)return;const v=ee(y,"Failed to load research runs");T(v.message),j(v)}finally{a===E.current&&P(!1)}},[t,_,u]),x=c.useCallback(async l=>{const a=await ue(l,t);return R(a.run),w(a.availability),a.run},[t]);return c.useEffect(()=>{P(!0);const l=window.setTimeout(()=>{f(_)},ke);return()=>window.clearTimeout(l)},[f,_]),c.useEffect(()=>{if(!u){R(null);return}x(u)},[x,u]),c.useEffect(()=>{const l=N.current,a=()=>N.current!==l,o=t?`?projectId=${encodeURIComponent(t)}`:"";let y=!0;const v=()=>{!y||a()||(f(),u&&x(u))},M=he(`/api/events${o}`,{events:{"research:run:created":v,"research:run:updated":v,"research:run:completed":v,"research:run:failed":v,"research:run:cancelled":v},onReconnect:v}),G=window.setInterval(v,Ee);return()=>{y=!1,M(),window.clearInterval(G)}},[t,f,u,x]),{runs:i,selectedRun:p,selectedRunId:u,setSelectedRunId:r,availability:g,loading:k,error:L,searchQuery:_,setSearchQuery:D,refresh:f,createRun:l=>pe(l,t),cancelRun:async l=>{try{j(null);const a=await ve(l,t);return u===l&&R(a.run),await f(),a}catch(a){const o=ee(a,"Failed to cancel run");throw j(o),o}},retryRun:async l=>{try{j(null);const a=await xe(l,t);return u===l&&R(a.run),await f(),a}catch(a){const o=ee(a,"Failed to retry run");throw j(o),o}},exportRun:(l,a)=>fe(l,a,t),createTaskFromRun:(l,a,o,y,v,M)=>be(l,{title:a,findingId:o,description:y,priority:v,attachExport:M},t),attachRunToTask:(l,a,o,y)=>me(l,{taskId:a,findingId:o,attachExport:y},t),uiError:F,runActionState:Pe(p),statusCounts:i.reduce((l,a)=>(l[a.status]+=1,l),{queued:0,running:0,cancelling:0,retry_waiting:0,completed:0,failed:0,cancelled:0,timed_out:0,retry_exhausted:0})}}function Ae({open:n,mode:t,run:i,finding:b,projectId:u,onClose:r,onConfirm:p}){ge(n);const[R,g]=c.useState(!1),[w,k]=c.useState(""),[P,L]=c.useState(""),[T,F]=c.useState("normal"),[j,_]=c.useState(""),[D,E]=c.useState([]),[N,S]=c.useState(!1),[f,x]=c.useState(!1),l=c.useMemo(()=>{const a=(b.content??"").split(/(?<=[.!?])\s+/)[0]??"";return`${b.heading||"Research finding"} — ${a}`.trim()},[b.content,b.heading]);return c.useEffect(()=>{n&&(g(!1),k(`Research: ${b.heading||i.title}`),L(l),F("normal"),_(""),t==="enrich"&&(S(!0),je(50,0,u).then(a=>E(a.filter(o=>o.column!=="archived"))).finally(()=>S(!1))))},[n,t,u,b.heading,l,i.title]),n?e.jsx("div",{className:"modal-overlay open",role:"presentation",onClick:r,children:e.jsxs("div",{className:"modal modal-lg research-task-action-modal",role:"dialog","aria-modal":"true",onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:t==="create"?"Create task from finding":"Enrich existing task"}),e.jsx("button",{className:"modal-close",type:"button","aria-label":"Close",onClick:r,children:"×"})]}),e.jsxs("div",{className:"research-task-action-modal__body",children:[e.jsxs("div",{className:"card research-task-action-modal__preview",children:[e.jsxs("p",{children:[e.jsx("strong",{children:"Run:"})," ",i.id]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Finding:"})," ",b.id,b.heading?` — ${b.heading}`:""]}),e.jsx("p",{children:l||"No preview available."})]}),t==="create"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"research-task-action-modal__field",children:["Title",e.jsx("input",{className:"input",value:w,onChange:a=>k(a.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:["Description",e.jsx("textarea",{className:"input research-task-action-modal__textarea",value:P,onChange:a=>L(a.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:["Priority",e.jsxs("select",{className:"select",value:T,onChange:a=>F(a.target.value),children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"urgent",children:"Urgent"})]})]})]}):e.jsxs("label",{className:"research-task-action-modal__field",children:["Target task",e.jsx("input",{className:"input",list:"research-task-action-task-list",value:j,placeholder:N?"Loading tasks…":"Enter task ID",onChange:a=>_(a.target.value)}),e.jsx("datalist",{id:"research-task-action-task-list",children:D.map(a=>e.jsx("option",{value:a.id,children:a.title},a.id))})]}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:R,onChange:a=>g(a.target.checked)}),e.jsx("span",{children:"Attach markdown export artifact"})]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:r,children:"Cancel"}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:f||t==="enrich"&&!j,onClick:()=>{x(!0),p({taskId:t==="enrich"?j:void 0,title:t==="create"?w.trim():void 0,description:t==="create"?P.trim():void 0,priority:t==="create"?T:void 0,attachExport:R}).finally(()=>x(!1))},children:t==="create"?"Create Task":"Enrich Task"})]})]})}):null}const Ie=["web-search","page-fetch","github","local-docs","llm-synthesis"],Le={"web-search":"webSearch","page-fetch":"pageFetch",github:"github","local-docs":"localDocs","llm-synthesis":"llmSynthesis"},Fe={"web-search":"Web Search","page-fetch":"Page Fetch",github:"GitHub","local-docs":"Local Docs","llm-synthesis":"LLM Synthesis"};function Ue({projectId:n,addToast:t,onOpenSettings:i,readinessVersion:b=0}){const{runs:u,selectedRun:r,selectedRunId:p,setSelectedRunId:R,availability:g,loading:w,error:k,searchQuery:P,setSearchQuery:L,createRun:T,cancelRun:F,retryRun:j,exportRun:_,createTaskFromRun:D,attachRunToTask:E,statusCounts:N,refresh:S,uiError:f,runActionState:x}=Te({projectId:n}),[l,a]=c.useState(""),[o,y]=c.useState(()=>Z(void 0)),[v,M]=c.useState({}),[G,ce]=c.useState([]),[se,z]=c.useState(!1),[te,ae]=c.useState([]),[A,H]=c.useState(null),[I,$]=c.useState(null),Q=g.supportedProviders??Ie,q=o.searchProvider,V=s=>s==="web-search"&&q==="none"?!1:o.enabledSources[Le[s]];c.useEffect(()=>{const s=Q.filter(d=>V(d));ae(d=>{const m=d.filter(h=>s.includes(h));return m.length>0?m:s})},[o.enabledSources,Q]),c.useEffect(()=>{let s=!1;return Promise.all([Re(n),_e().catch(()=>({providers:[]}))]).then(([d,m])=>{s||(M(d),y(Z(d)),ce(m.providers.filter(h=>h.type==="api_key").map(h=>({id:h.id,authenticated:h.authenticated}))))}).catch(()=>{s||y(Z(void 0))}),()=>{s=!0}},[n,b]);const ie=c.useMemo(()=>r?r.status:"No run selected",[r]),le=c.useMemo(()=>r?r.status==="queued"||r.status==="retry_waiting"?"status-dot status-dot--pending":r.status==="running"?"status-dot status-dot--connecting":r.status==="completed"?"status-dot status-dot--online":r.status==="failed"||r.status==="cancelled"?"status-dot status-dot--error":"status-dot":"status-dot",[r]),W=g.supportedExportFormats??["markdown","json","html"],K=v.researchGlobalWebSearchProvider==="none"||q==="none",Y=c.useMemo(()=>new Map(G.map(s=>[s.id,s.authenticated])),[G]),J=c.useMemo(()=>{const s=new Set;return o.enabledSources.webSearch&&q&&s.add(q),o.enabledSources.llmSynthesis&&o.synthesisProvider&&s.add(o.synthesisProvider),[...s].filter(d=>Y.has(d))},[o.enabledSources.llmSynthesis,o.enabledSources.webSearch,o.synthesisProvider,q,Y]).find(s=>Y.get(s)!==!0),O=c.useMemo(()=>g.available?o.enabled?K?null:J?{reason:`Missing API key for ${J}.`,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:g.reason??"Research is unavailable for this project.",details:g.setupInstructions,settingsSection:"research-project"},[g.available,g.reason,g.setupInstructions,o.enabled,J,K]),B=async(s,d,m)=>{H(s);try{await d(),t?.(m,"success"),await S()}catch(h){t?.(h instanceof Error?h.message:"Action failed","error")}finally{H(null)}},X=async s=>{if(r){H(`export-${s}`);try{const d=await _(r.id,s),m=new Blob([d.content],{type:"text/plain;charset=utf-8"}),h=URL.createObjectURL(m),C=document.createElement("a");C.href=h,C.download=d.filename,document.body.appendChild(C),C.click(),C.remove(),URL.revokeObjectURL(h),t?.(`Exported ${d.filename}`,"success")}catch(d){t?.(d instanceof Error?d.message:"Export failed","error")}finally{H(null)}}},oe=async()=>{if(l.trim()){z(!0);try{const s=te.filter(m=>V(m));if(s.length===0){z(!1),t?.("No enabled research sources are available for this project.","error");return}const d=await T({query:l.trim(),providers:s});R(d.run.id),a(""),t?.("Research run created","success"),await S()}catch(s){t?.(s instanceof Error?s.message:"Failed to create run","error")}finally{z(!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 S(),children:"Refresh"})]}),O?e.jsxs("div",{className:"research-view__state research-view__state--error card","data-testid":"research-state-unavailable",children:[e.jsx("p",{children:O.reason}),O.details&&e.jsx("p",{children:O.details}),e.jsxs("p",{children:["Current defaults: provider ",o.searchProvider??"(not set)",", max sources ",o.limits.maxSourcesPerRun]}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",onClick:()=>void S(),children:"Refresh"}),e.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>i?.(O.settingsSection),children:"Open Settings"})]})]}):e.jsxs(e.Fragment,{children:[K?e.jsxs("div",{className:"research-view__state card","data-testid":"research-state-web-search-disabled",children:[e.jsx("p",{children:"Web search is disabled. Page Fetch, Local Docs, GitHub and LLM Synthesis still work."}),e.jsx("div",{className:"research-view__actions",children:e.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>i?.("research-global"),children:"Re-enable Web Search"})})]}):null,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:l,onChange:s=>a(s.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Providers"}),e.jsx("div",{className:"research-view__providers",children:Q.map(s=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:te.includes(s),disabled:!V(s),onChange:()=>{V(s)&&ae(d=>d.includes(s)?d.filter(m=>m!==s):[...d,s])}}),e.jsx("span",{children:Fe[s]??s})]},s))})]}),e.jsxs("button",{className:"btn btn-primary",type:"button",disabled:!l.trim()||se,onClick:()=>void oe(),children:[se?e.jsx(Se,{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(we,{size:14}),e.jsx("input",{id:"research-run-search",className:"input",placeholder:"Search runs",value:P,onChange:s=>L(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 card${p===s.id?" research-view__history-item--active":""}`,onClick:()=>R(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:[w&&e.jsx("p",{"data-testid":"research-state-loading",children:"Loading research runs…"}),!w&&k&&e.jsx("p",{"data-testid":"research-state-error",children:k}),!w&&!k&&u.length===0&&e.jsx("p",{"data-testid":"research-state-empty",children:"No research runs yet"}),r&&e.jsxs("div",{children:[e.jsxs("div",{className:"research-view__status-row",children:[e.jsx("span",{className:le}),e.jsx("strong",{children:ie})]}),e.jsx("h3",{className:"research-view__run-title",children:r.title}),e.jsx("p",{className:"research-view__run-query",children:r.query}),e.jsx("p",{className:"research-view__run-summary","data-testid":"research-state-results",children:r.results?.summary??"No summary yet."}),e.jsxs("div",{className:"research-view__actions",children:[e.jsx("button",{className:"btn",type:"button",title:x.cancelable?void 0:x.blockingReason,disabled:A==="cancel"||A==="retry"||!x.cancelable,onClick:()=>void B("cancel",()=>F(r.id),"Run cancelled"),children:"Cancel"}),e.jsx("button",{className:"btn",type:"button",title:x.retryable?void 0:x.blockingReason,disabled:A==="cancel"||A==="retry"||!x.retryable,onClick:()=>void B("retry",()=>j(r.id),"Run retried"),children:"Retry"}),W.includes("markdown")&&e.jsx("button",{className:"btn",type:"button",disabled:A==="export-markdown",onClick:()=>void X("markdown"),children:"Export MD"}),W.includes("json")&&e.jsx("button",{className:"btn",type:"button",disabled:A==="export-json",onClick:()=>void X("json"),children:"Export JSON"}),W.includes("html")&&e.jsx("button",{className:"btn",type:"button",disabled:A==="export-html",onClick:()=>void X("html"),children:"Export HTML"})]}),r.error&&e.jsx("p",{className:"research-view__error",children:r.error}),f&&e.jsxs("div",{className:"form-error",role:"alert",children:[e.jsx("p",{children:f.message}),f.setupHint&&e.jsx("p",{children:f.setupHint}),f.code==="MISSING_CREDENTIALS"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>i?.("authentication"),children:"Open Authentication Settings"}),f.code==="FEATURE_DISABLED"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>i?.("research-project"),children:"Open Research Settings"})]}),x.blockingReason&&e.jsx("p",{className:"research-view__run-query",children:x.blockingReason}),Array.isArray(r.results?.findings)&&r.results.findings.length>0&&e.jsx("div",{className:"research-view__findings",children:r.results.findings.map((s,d)=>{const h=s.id?.trim()||`finding-${d+1}`;return e.jsxs("article",{className:"research-view__finding card",children:[e.jsx("h4",{children:s.heading}),e.jsx("p",{children:s.content}),e.jsxs("div",{className:"research-view__actions research-view__finding-actions",children:[e.jsx("button",{className:"btn btn-primary btn-sm",type:"button",onClick:()=>$({mode:"create",findingId:h}),children:"Create Task"}),e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>$({mode:"enrich",findingId:h}),children:"Enrich Task"})]})]},h)})}),Array.isArray(r.results?.citations)&&r.results.citations.length>0&&e.jsx("ul",{className:"research-view__citations",children:r.results.citations.map(s=>e.jsx("li",{children:e.jsx("a",{href:s,target:"_blank",rel:"noreferrer",children:s})},s))}),r.events.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:"Run history"}),e.jsx("ul",{className:"research-view__events",children:r.events.map(s=>e.jsx("li",{children:s.message},s.id))})]})]}),!r&&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:N.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:N.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:N.failed})]})]})]})]})]}),r&&I&&(()=>{const s=r.results?.findings?.findIndex((m,h)=>(m.id?.trim()||`finding-${h+1}`)===I.findingId)??-1,d=s>=0?r.results.findings[s]:null;return d?e.jsx(Ae,{open:!0,mode:I.mode,run:r,finding:{id:I.findingId,heading:d.heading,content:d.content},projectId:n,onClose:()=>$(null),onConfirm:async({taskId:m,title:h,description:C,priority:re,attachExport:ne})=>{I.mode==="create"?await B("create-task",()=>D(r.id,h,I.findingId,C,re,ne),"Task created from research"):m&&await B("attach-task",()=>E(r.id,m,I.findingId,ne),"Task enriched from research"),$(null)}}):null})()]})}export{Ue as ResearchView};