@runfusion/fusion 0.28.0 → 0.28.1
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.
- package/dist/bin.js +0 -27
- package/dist/client/assets/{AgentDetailView-V32TpEe1.js → AgentDetailView-DG01uRND.js} +1 -1
- package/dist/client/assets/{AgentsView-CxITZE-U.js → AgentsView-B6IKroR1.js} +3 -3
- package/dist/client/assets/{ChatView-7WPHyB_7.js → ChatView-DKstOyUm.js} +1 -1
- package/dist/client/assets/{DevServerView-Diw4hjw0.js → DevServerView-DQQcGd2N.js} +1 -1
- package/dist/client/assets/{DirectoryPicker-CWSApoLU.js → DirectoryPicker-BfShQutV.js} +1 -1
- package/dist/client/assets/{DocumentsView-1kr0dhsV.js → DocumentsView-C4Ky-ZkQ.js} +1 -1
- package/dist/client/assets/{EvalsView-cDfXYiK6.js → EvalsView-B-z_KLLW.js} +1 -1
- package/dist/client/assets/{ExperimentalAgentOnboardingModal-lNSf6UtY.js → ExperimentalAgentOnboardingModal-CtR7eRBv.js} +1 -1
- package/dist/client/assets/{InsightsView-D2AjxOnu.js → InsightsView-BGbXkJpz.js} +1 -1
- package/dist/client/assets/{MemoryView-Dq4yjIPI.js → MemoryView-CRbaCcG_.js} +1 -1
- package/dist/client/assets/{NodesView-Cpmkze7n.js → NodesView-Hjxwv7rE.js} +1 -1
- package/dist/client/assets/{PiExtensionsManager-oi9FHT0y.js → PiExtensionsManager-ckNj1Wvv.js} +1 -1
- package/dist/client/assets/{PluginManager-o12KG4e8.js → PluginManager-CpY9rYNq.js} +1 -1
- package/dist/client/assets/{ResearchView-C9bjVB7-.js → ResearchView-BMxwiVk9.js} +1 -1
- package/dist/client/assets/{SettingsModal-Cu93Jjho.js → SettingsModal-3Jxv4PMI.js} +3 -3
- package/dist/client/assets/{SettingsModal-CT01a5Rh.js → SettingsModal-Bqfq-gnu.js} +1 -1
- package/dist/client/assets/{SetupWizardModal-Agi3XNtZ.js → SetupWizardModal-SVUr5Mpm.js} +1 -1
- package/dist/client/assets/{SkillsView-DmZfbGLs.js → SkillsView-COs7muvr.js} +1 -1
- package/dist/client/assets/{StashRecoveryView-BwKJQaUW.js → StashRecoveryView-BhB_6Fvq.js} +1 -1
- package/dist/client/assets/{TodoView-uJRg4Cnl.js → TodoView-CDtkPdrq.js} +1 -1
- package/dist/client/assets/{dashboard-view-C7Snlgow.js → dashboard-view-Czurx3BJ.js} +1 -1
- package/dist/client/assets/{folder-open-DU-Ec_iC.js → folder-open-D8Qfxakh.js} +1 -1
- package/dist/client/assets/{index-DiewofJh.js → index-u6AOHWO5.js} +5 -5
- package/dist/client/assets/{star-Qi0GspVN.js → star-BkCn1oUu.js} +1 -1
- package/dist/client/assets/{upload-Dx_l9Vbu.js → upload-BHiYszS2.js} +1 -1
- package/dist/client/assets/{users-3Qw_TMah.js → users-Ch_Fnf5M.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/version.json +1 -1
- package/dist/droid-cli/package.json +1 -1
- package/dist/extension.js +0 -27
- package/dist/pi-claude-cli/package.json +1 -1
- package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
- package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
- package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
- package/dist/plugins/fusion-plugin-reports/package.json +1 -1
- package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
- package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as e}from"./vendor-react-K0fH_qHe.js";import{a5 as oe,a6 as K,f as le,a7 as ie,F as z,a8 as de,a9 as ue,S as me,X as he,R as pe,aa as fe,ab as W,ac as V,a as X,b as je,ad as xe}from"./index-DiewofJh.js";import"./vendor-xterm-DzcZoU0P.js";function we(n){const{projectId:c,searchQuery:u,includeProjectFiles:a=!0}=n??{},[x,l]=s.useState([]),[h,i]=s.useState([]),[o,p]=s.useState(!0),[k,b]=s.useState(null),f=s.useRef(null),g=s.useRef(!1),m=s.useRef(null),j=s.useCallback(async()=>{f.current&&f.current.abort();const C=new AbortController;f.current=C;const E=!g.current;E&&p(!0),b(null);const L=oe(u?{q:u}:void 0,c),y=a?K(c):Promise.resolve({files:[]}),[v,F]=await Promise.allSettled([L,y]);if(C.signal.aborted)return;let R=null;if(v.status==="fulfilled"?(l(v.value),g.current=!0):R=v.reason instanceof Error?v.reason.message:String(v.reason),F.status==="fulfilled"){const M=F.value.files,P=u?.trim().toLowerCase(),T=P?M.filter(N=>N.name.toLowerCase().includes(P)||N.path.toLowerCase().includes(P)):M;i(T)}b(R),E&&p(!1)},[a,c,u]);return s.useEffect(()=>(m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{j()},300),()=>{m.current&&clearTimeout(m.current)}),[j]),s.useEffect(()=>(j(),()=>{f.current&&f.current.abort()}),[]),{documents:x,projectFiles:h,loading:o,error:k,refresh:j}}function ke(n,c){const[u,a]=s.useState([]),[x,l]=s.useState(!0),[h,i]=s.useState(null),o=s.useRef(null),p=s.useRef(!1),k=c?.showHidden??!1,b=s.useCallback(async f=>{o.current&&o.current.abort();const g=new AbortController;o.current=g;const m=!p.current;m&&l(!0),i(null);try{const j=await K(n,{showHidden:f?.showHidden??k});if(g.signal.aborted)return;a(j.files),p.current=!0}catch(j){if(g.signal.aborted)return;i(j instanceof Error?j.message:String(j))}finally{!g.signal.aborted&&m&&l(!1)}},[n,k]);return s.useEffect(()=>(p.current=!1,b({showHidden:k}),()=>{o.current&&o.current.abort()}),[b,k]),{files:u,loading:x,error:h,refresh:b}}const be=768;function _(n){return n?new Date(n).toLocaleString():""}function ge(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(n>=10*1024?0:1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function ve(n,c=200){return n.length<=c?n:`${n.substring(0,c)}…`}function Ne({document:n,renderMarkdown:c,onToggleMarkdown:u}){const[a,x]=s.useState(!1),l=ve(n.content),h=n.content.length>200;return e.jsxs("div",{className:"document-card",children:[e.jsxs("div",{className:"document-card-header",children:[e.jsxs("div",{className:"document-card-key",children:[e.jsx(z,{size:14}),e.jsx("span",{className:"document-card-key-text",children:n.key}),e.jsxs("span",{className:"document-card-revision-badge",children:["v",n.revision]})]}),e.jsx("div",{className:"document-card-actions",children:e.jsx("button",{className:"btn btn-sm document-card-expand-btn",onClick:()=>x(i=>!i),title:a?"Collapse":"Expand","aria-label":a?"Collapse content":"Expand content",children:a?e.jsx(xe,{size:14}):e.jsx(X,{size:14})})})]}),e.jsxs("div",{className:"document-card-meta",children:[e.jsx("span",{className:"document-card-author",children:n.author}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{className:"document-card-date",children:_(n.updatedAt)})]}),e.jsxs("div",{className:`document-card-content${a?" document-card-content--expanded":""}`,children:[a?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"document-card-content-header",children:e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:u,"aria-label":c?"Switch to plain text":"Switch to markdown","aria-pressed":c,title:c?"Switch to plain text":"Switch to markdown",children:c?"Markdown":"Plain"})}),c?e.jsx("div",{className:"document-card-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(W,{remarkPlugins:[V],children:n.content})})}):e.jsx("pre",{className:"document-card-content-text",children:n.content})]}):e.jsx("p",{className:"document-card-preview",children:l}),h&&!a&&e.jsx("p",{className:"document-card-preview-truncated",children:"…"})]})]})}function Se({taskId:n,taskTitle:c,documents:u,onOpenTask:a,renderMarkdownStates:x,onToggleMarkdown:l}){const[h,i]=s.useState(!1);return e.jsxs("div",{className:"documents-group",children:[e.jsxs("div",{className:"documents-group-header",children:[e.jsxs("button",{className:"documents-group-toggle-btn",onClick:()=>i(o=>!o),"aria-expanded":h,"aria-label":`${h?"Collapse":"Expand"} documents for task ${n}`,children:[e.jsx("span",{className:"documents-group-toggle","aria-hidden":"true",children:h?e.jsx(X,{size:16}):e.jsx(je,{size:16})}),e.jsx("span",{className:"documents-group-task-id",children:n}),e.jsx("span",{className:"documents-group-task-title",children:c||"Untitled"})]}),e.jsxs("span",{className:"documents-group-count",children:[u.length," doc",u.length!==1?"s":""]}),e.jsx("button",{className:"documents-group-task-link",onClick:()=>a(n),"aria-label":`Open task ${n}: ${c||"Untitled"}`,children:"Open task"})]}),h&&e.jsx("div",{className:"documents-group-content",children:u.map(o=>e.jsx(Ne,{document:o,renderMarkdown:x.get(o.id)??!1,onToggleMarkdown:()=>l(o.id)},o.id))})]})}function ye({projectId:n,addToast:c,onOpenDetail:u}){const[a,x]=s.useState("project"),[l,h]=s.useState(""),[i,o]=s.useState(null),[p,k]=s.useState(!1),[b,f]=s.useState(null),[g,m]=s.useState(!1),[j,C]=s.useState(null),[E,L]=s.useState(!1),y=s.useRef(0),v=s.useRef(!1),[F,R]=s.useState(!1),[M,P]=s.useState(new Map),T=a==="tasks"?l.trim():"",{documents:N,loading:D,error:J,refresh:B}=we({projectId:n,searchQuery:T||void 0,includeProjectFiles:!1}),{files:S,loading:$,error:Y,refresh:O}=ke(n,{showHidden:p});s.useEffect(()=>{const t=()=>{L(window.innerWidth<=be)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),s.useEffect(()=>{v.current=!1,x("project"),o(null),k(!1),f(null),C(null),m(!1),R(!1),P(new Map)},[n]),s.useEffect(()=>{v.current||D||$||(S.length>0?x("project"):N.length>0&&x("tasks"),v.current=!0)},[N.length,D,S.length,$]);const H=s.useMemo(()=>{const t=new Map;for(const r of N){const d=t.get(r.taskId)||[];t.set(r.taskId,[...d,r])}return Array.from(t.entries()).map(([r,d])=>{const w=[...d].sort((re,ce)=>ce.updatedAt.localeCompare(re.updatedAt));return{taskId:r,taskTitle:w[0]?.taskTitle,documents:w,latestUpdated:w[0]?.updatedAt??""}}).sort((r,d)=>d.latestUpdated.localeCompare(r.latestUpdated))},[N]),A=s.useMemo(()=>{const t=l.trim().toLowerCase();return t?S.filter(r=>{const d=r.path.toLowerCase(),w=r.name.toLowerCase();return d.includes(t)||w.includes(t)}):S},[S,l]);s.useEffect(()=>{if(!i)return;S.some(r=>r.path===i.path)||(o(null),f(null),C(null),m(!1))},[S,i]);const Z=s.useCallback(t=>{h(t.target.value)},[]),I=s.useCallback(()=>{h("")},[]),Q=s.useCallback(t=>{x(t)},[]),ee=s.useCallback(async t=>{try{const r=await le(t,n);u(r)}catch{c(`Failed to open task ${t}`,"error")}},[n,u,c]),se=s.useCallback(async t=>{o(t),m(!0),C(null),f(null);const r=y.current+1;y.current=r;try{const d=await ie("project",t.path,n);if(y.current!==r)return;f(d.content)}catch(d){if(y.current!==r)return;const w=d instanceof Error?d.message:`Failed to open ${t.path}`;C(w),c(w,"error")}finally{y.current===r&&m(!1)}},[n,c]),te=s.useCallback(()=>{o(null),f(null),C(null),m(!1)},[]),ne=s.useCallback(t=>{P(r=>{const d=new Map(r),w=d.get(t)??!1;return d.set(t,!w),d})},[]),U=a==="project"?Y:J,ae=s.useCallback(async()=>{if(a==="project"){await O();return}await B()},[a,O,B]),q=a==="project"?A.length:N.length,G=a==="project"?"Search project markdown files…":"Search task documents…";return e.jsxs("div",{className:"documents-view",children:[e.jsxs("div",{className:"documents-view-header",children:[e.jsxs("div",{className:"documents-view-title-row",children:[e.jsxs("h2",{className:"documents-view-title",children:[e.jsx(z,{size:20}),"Documents"]}),e.jsxs("span",{className:"documents-view-count",children:[q," result",q!==1?"s":""]})]}),e.jsxs("div",{className:"documents-controls-row",children:[e.jsxs("div",{className:"documents-tab-bar",role:"tablist","aria-label":"Documents sections",children:[e.jsxs("button",{className:`btn documents-tab${a==="project"?" active":""}`,role:"tab","aria-selected":a==="project","aria-label":"Show project markdown files",onClick:()=>Q("project"),children:["Project Files",e.jsx("span",{className:"documents-tab-count",children:S.length})]}),e.jsxs("button",{className:`btn documents-tab${a==="tasks"?" active":""}`,role:"tab","aria-selected":a==="tasks","aria-label":"Show task documents",onClick:()=>Q("tasks"),children:["Task Documents",e.jsx("span",{className:"documents-tab-count",children:H.length})]})]}),a==="project"&&e.jsxs("button",{className:"btn btn-sm documents-hidden-toggle",onClick:()=>k(t=>!t),"aria-pressed":p,"aria-label":p?"Hide hidden project files":"Show hidden project files",title:p?"Hide hidden files":"Show hidden files",children:[p?e.jsx(de,{size:14}):e.jsx(ue,{size:14}),p?"Hide Hidden":"Show Hidden"]}),e.jsxs("div",{className:"documents-search",children:[e.jsx(me,{size:16,className:"documents-search-icon"}),e.jsx("input",{type:"text",className:"documents-search-input",placeholder:G,value:l,onChange:Z,"aria-label":G}),l&&e.jsx("button",{className:"documents-search-clear",onClick:I,"aria-label":"Clear search",children:e.jsx(he,{size:16})})]})]})]}),e.jsx("div",{className:"documents-view-content",children:U?e.jsxs("div",{className:"documents-view-error",children:[e.jsxs("p",{children:["Failed to load ",a==="project"?"project files":"task documents",": ",U]}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void ae(),"aria-label":"Retry loading documents",children:[e.jsx(pe,{size:16}),"Retry"]})]}):a==="project"?$&&S.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:"Loading project markdown files…"})}):A.length===0?e.jsx("div",{className:"documents-view-empty",children:l.trim()?e.jsxs("p",{children:['No project markdown files match "',l.trim(),'".']}):e.jsxs(e.Fragment,{children:[e.jsx(z,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:"No Markdown files found in this project."})]})}):e.jsxs("div",{className:`documents-project-layout${E?" documents-project-layout--mobile":""}`,children:[(!E||!i)&&e.jsx("aside",{className:"documents-view-sidebar","aria-label":"Project markdown files",children:e.jsx("ul",{className:"markdown-file-list",children:A.map(t=>{const r=i?.path===t.path;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item${r?" markdown-file-item--selected":""}`,onClick:()=>void se(t),"aria-label":`Open ${t.path}`,"aria-current":r?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:t.name}),e.jsx("span",{className:"markdown-file-item-path",children:t.path}),e.jsxs("span",{className:"markdown-file-item-meta",children:[ge(t.size)," · ",_(t.mtime)]})]})},t.path)})})}),(!E||i)&&e.jsxs("section",{className:"documents-view-main","aria-label":"Project file content preview",children:[E&&i&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:te,"aria-label":"Back to project files list",children:[e.jsx(fe,{size:14}),"Back to files"]}),i?e.jsxs("div",{className:"documents-content-viewer",children:[e.jsxs("div",{className:"documents-content-header",children:[e.jsx("p",{className:"documents-file-path-header",children:i.path}),e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>R(t=>!t),"aria-label":F?"Switch to plain text":"Switch to markdown","aria-pressed":F,title:F?"Switch to plain text":"Switch to markdown",children:F?"Markdown":"Plain"})]}),g?e.jsx("p",{className:"documents-content-state",children:"Loading file content…"}):j?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:j}):F?e.jsx("div",{className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(W,{remarkPlugins:[V],children:b??""})})}):e.jsx("pre",{className:"document-card-content-text documents-content-viewer-text",children:b??""})]}):e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:"Select a Markdown file to view its content."})})]})]}):D&&N.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:"Loading task documents…"})}):H.length===0?e.jsx("div",{className:"documents-view-empty",children:l.trim()?e.jsxs("p",{children:['No task documents match "',l.trim(),'".']}):e.jsxs(e.Fragment,{children:[e.jsx(z,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:"No task documents yet."}),e.jsx("p",{className:"documents-view-empty-hint",children:"Documents are created in task detail tabs."})]})}):e.jsx("div",{className:"documents-task-list-wrap",children:e.jsx("div",{className:"documents-view-list",children:H.map(({taskId:t,taskTitle:r,documents:d})=>e.jsx(Se,{taskId:t,taskTitle:r,documents:d,onOpenTask:ee,renderMarkdownStates:M,onToggleMarkdown:ne},t))})})})]})}export{ye as DocumentsView};
|
|
1
|
+
import{r as s,j as e}from"./vendor-react-K0fH_qHe.js";import{a5 as oe,a6 as K,f as le,a7 as ie,F as z,a8 as de,a9 as ue,S as me,X as he,R as pe,aa as fe,ab as W,ac as V,a as X,b as je,ad as xe}from"./index-u6AOHWO5.js";import"./vendor-xterm-DzcZoU0P.js";function we(n){const{projectId:c,searchQuery:u,includeProjectFiles:a=!0}=n??{},[x,l]=s.useState([]),[h,i]=s.useState([]),[o,p]=s.useState(!0),[k,b]=s.useState(null),f=s.useRef(null),g=s.useRef(!1),m=s.useRef(null),j=s.useCallback(async()=>{f.current&&f.current.abort();const C=new AbortController;f.current=C;const E=!g.current;E&&p(!0),b(null);const L=oe(u?{q:u}:void 0,c),y=a?K(c):Promise.resolve({files:[]}),[v,F]=await Promise.allSettled([L,y]);if(C.signal.aborted)return;let R=null;if(v.status==="fulfilled"?(l(v.value),g.current=!0):R=v.reason instanceof Error?v.reason.message:String(v.reason),F.status==="fulfilled"){const M=F.value.files,P=u?.trim().toLowerCase(),T=P?M.filter(N=>N.name.toLowerCase().includes(P)||N.path.toLowerCase().includes(P)):M;i(T)}b(R),E&&p(!1)},[a,c,u]);return s.useEffect(()=>(m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{j()},300),()=>{m.current&&clearTimeout(m.current)}),[j]),s.useEffect(()=>(j(),()=>{f.current&&f.current.abort()}),[]),{documents:x,projectFiles:h,loading:o,error:k,refresh:j}}function ke(n,c){const[u,a]=s.useState([]),[x,l]=s.useState(!0),[h,i]=s.useState(null),o=s.useRef(null),p=s.useRef(!1),k=c?.showHidden??!1,b=s.useCallback(async f=>{o.current&&o.current.abort();const g=new AbortController;o.current=g;const m=!p.current;m&&l(!0),i(null);try{const j=await K(n,{showHidden:f?.showHidden??k});if(g.signal.aborted)return;a(j.files),p.current=!0}catch(j){if(g.signal.aborted)return;i(j instanceof Error?j.message:String(j))}finally{!g.signal.aborted&&m&&l(!1)}},[n,k]);return s.useEffect(()=>(p.current=!1,b({showHidden:k}),()=>{o.current&&o.current.abort()}),[b,k]),{files:u,loading:x,error:h,refresh:b}}const be=768;function _(n){return n?new Date(n).toLocaleString():""}function ge(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(n>=10*1024?0:1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function ve(n,c=200){return n.length<=c?n:`${n.substring(0,c)}…`}function Ne({document:n,renderMarkdown:c,onToggleMarkdown:u}){const[a,x]=s.useState(!1),l=ve(n.content),h=n.content.length>200;return e.jsxs("div",{className:"document-card",children:[e.jsxs("div",{className:"document-card-header",children:[e.jsxs("div",{className:"document-card-key",children:[e.jsx(z,{size:14}),e.jsx("span",{className:"document-card-key-text",children:n.key}),e.jsxs("span",{className:"document-card-revision-badge",children:["v",n.revision]})]}),e.jsx("div",{className:"document-card-actions",children:e.jsx("button",{className:"btn btn-sm document-card-expand-btn",onClick:()=>x(i=>!i),title:a?"Collapse":"Expand","aria-label":a?"Collapse content":"Expand content",children:a?e.jsx(xe,{size:14}):e.jsx(X,{size:14})})})]}),e.jsxs("div",{className:"document-card-meta",children:[e.jsx("span",{className:"document-card-author",children:n.author}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{className:"document-card-date",children:_(n.updatedAt)})]}),e.jsxs("div",{className:`document-card-content${a?" document-card-content--expanded":""}`,children:[a?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"document-card-content-header",children:e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:u,"aria-label":c?"Switch to plain text":"Switch to markdown","aria-pressed":c,title:c?"Switch to plain text":"Switch to markdown",children:c?"Markdown":"Plain"})}),c?e.jsx("div",{className:"document-card-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(W,{remarkPlugins:[V],children:n.content})})}):e.jsx("pre",{className:"document-card-content-text",children:n.content})]}):e.jsx("p",{className:"document-card-preview",children:l}),h&&!a&&e.jsx("p",{className:"document-card-preview-truncated",children:"…"})]})]})}function Se({taskId:n,taskTitle:c,documents:u,onOpenTask:a,renderMarkdownStates:x,onToggleMarkdown:l}){const[h,i]=s.useState(!1);return e.jsxs("div",{className:"documents-group",children:[e.jsxs("div",{className:"documents-group-header",children:[e.jsxs("button",{className:"documents-group-toggle-btn",onClick:()=>i(o=>!o),"aria-expanded":h,"aria-label":`${h?"Collapse":"Expand"} documents for task ${n}`,children:[e.jsx("span",{className:"documents-group-toggle","aria-hidden":"true",children:h?e.jsx(X,{size:16}):e.jsx(je,{size:16})}),e.jsx("span",{className:"documents-group-task-id",children:n}),e.jsx("span",{className:"documents-group-task-title",children:c||"Untitled"})]}),e.jsxs("span",{className:"documents-group-count",children:[u.length," doc",u.length!==1?"s":""]}),e.jsx("button",{className:"documents-group-task-link",onClick:()=>a(n),"aria-label":`Open task ${n}: ${c||"Untitled"}`,children:"Open task"})]}),h&&e.jsx("div",{className:"documents-group-content",children:u.map(o=>e.jsx(Ne,{document:o,renderMarkdown:x.get(o.id)??!1,onToggleMarkdown:()=>l(o.id)},o.id))})]})}function ye({projectId:n,addToast:c,onOpenDetail:u}){const[a,x]=s.useState("project"),[l,h]=s.useState(""),[i,o]=s.useState(null),[p,k]=s.useState(!1),[b,f]=s.useState(null),[g,m]=s.useState(!1),[j,C]=s.useState(null),[E,L]=s.useState(!1),y=s.useRef(0),v=s.useRef(!1),[F,R]=s.useState(!1),[M,P]=s.useState(new Map),T=a==="tasks"?l.trim():"",{documents:N,loading:D,error:J,refresh:B}=we({projectId:n,searchQuery:T||void 0,includeProjectFiles:!1}),{files:S,loading:$,error:Y,refresh:O}=ke(n,{showHidden:p});s.useEffect(()=>{const t=()=>{L(window.innerWidth<=be)};return t(),window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t)}},[]),s.useEffect(()=>{v.current=!1,x("project"),o(null),k(!1),f(null),C(null),m(!1),R(!1),P(new Map)},[n]),s.useEffect(()=>{v.current||D||$||(S.length>0?x("project"):N.length>0&&x("tasks"),v.current=!0)},[N.length,D,S.length,$]);const H=s.useMemo(()=>{const t=new Map;for(const r of N){const d=t.get(r.taskId)||[];t.set(r.taskId,[...d,r])}return Array.from(t.entries()).map(([r,d])=>{const w=[...d].sort((re,ce)=>ce.updatedAt.localeCompare(re.updatedAt));return{taskId:r,taskTitle:w[0]?.taskTitle,documents:w,latestUpdated:w[0]?.updatedAt??""}}).sort((r,d)=>d.latestUpdated.localeCompare(r.latestUpdated))},[N]),A=s.useMemo(()=>{const t=l.trim().toLowerCase();return t?S.filter(r=>{const d=r.path.toLowerCase(),w=r.name.toLowerCase();return d.includes(t)||w.includes(t)}):S},[S,l]);s.useEffect(()=>{if(!i)return;S.some(r=>r.path===i.path)||(o(null),f(null),C(null),m(!1))},[S,i]);const Z=s.useCallback(t=>{h(t.target.value)},[]),I=s.useCallback(()=>{h("")},[]),Q=s.useCallback(t=>{x(t)},[]),ee=s.useCallback(async t=>{try{const r=await le(t,n);u(r)}catch{c(`Failed to open task ${t}`,"error")}},[n,u,c]),se=s.useCallback(async t=>{o(t),m(!0),C(null),f(null);const r=y.current+1;y.current=r;try{const d=await ie("project",t.path,n);if(y.current!==r)return;f(d.content)}catch(d){if(y.current!==r)return;const w=d instanceof Error?d.message:`Failed to open ${t.path}`;C(w),c(w,"error")}finally{y.current===r&&m(!1)}},[n,c]),te=s.useCallback(()=>{o(null),f(null),C(null),m(!1)},[]),ne=s.useCallback(t=>{P(r=>{const d=new Map(r),w=d.get(t)??!1;return d.set(t,!w),d})},[]),U=a==="project"?Y:J,ae=s.useCallback(async()=>{if(a==="project"){await O();return}await B()},[a,O,B]),q=a==="project"?A.length:N.length,G=a==="project"?"Search project markdown files…":"Search task documents…";return e.jsxs("div",{className:"documents-view",children:[e.jsxs("div",{className:"documents-view-header",children:[e.jsxs("div",{className:"documents-view-title-row",children:[e.jsxs("h2",{className:"documents-view-title",children:[e.jsx(z,{size:20}),"Documents"]}),e.jsxs("span",{className:"documents-view-count",children:[q," result",q!==1?"s":""]})]}),e.jsxs("div",{className:"documents-controls-row",children:[e.jsxs("div",{className:"documents-tab-bar",role:"tablist","aria-label":"Documents sections",children:[e.jsxs("button",{className:`btn documents-tab${a==="project"?" active":""}`,role:"tab","aria-selected":a==="project","aria-label":"Show project markdown files",onClick:()=>Q("project"),children:["Project Files",e.jsx("span",{className:"documents-tab-count",children:S.length})]}),e.jsxs("button",{className:`btn documents-tab${a==="tasks"?" active":""}`,role:"tab","aria-selected":a==="tasks","aria-label":"Show task documents",onClick:()=>Q("tasks"),children:["Task Documents",e.jsx("span",{className:"documents-tab-count",children:H.length})]})]}),a==="project"&&e.jsxs("button",{className:"btn btn-sm documents-hidden-toggle",onClick:()=>k(t=>!t),"aria-pressed":p,"aria-label":p?"Hide hidden project files":"Show hidden project files",title:p?"Hide hidden files":"Show hidden files",children:[p?e.jsx(de,{size:14}):e.jsx(ue,{size:14}),p?"Hide Hidden":"Show Hidden"]}),e.jsxs("div",{className:"documents-search",children:[e.jsx(me,{size:16,className:"documents-search-icon"}),e.jsx("input",{type:"text",className:"documents-search-input",placeholder:G,value:l,onChange:Z,"aria-label":G}),l&&e.jsx("button",{className:"documents-search-clear",onClick:I,"aria-label":"Clear search",children:e.jsx(he,{size:16})})]})]})]}),e.jsx("div",{className:"documents-view-content",children:U?e.jsxs("div",{className:"documents-view-error",children:[e.jsxs("p",{children:["Failed to load ",a==="project"?"project files":"task documents",": ",U]}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void ae(),"aria-label":"Retry loading documents",children:[e.jsx(pe,{size:16}),"Retry"]})]}):a==="project"?$&&S.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:"Loading project markdown files…"})}):A.length===0?e.jsx("div",{className:"documents-view-empty",children:l.trim()?e.jsxs("p",{children:['No project markdown files match "',l.trim(),'".']}):e.jsxs(e.Fragment,{children:[e.jsx(z,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:"No Markdown files found in this project."})]})}):e.jsxs("div",{className:`documents-project-layout${E?" documents-project-layout--mobile":""}`,children:[(!E||!i)&&e.jsx("aside",{className:"documents-view-sidebar","aria-label":"Project markdown files",children:e.jsx("ul",{className:"markdown-file-list",children:A.map(t=>{const r=i?.path===t.path;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item${r?" markdown-file-item--selected":""}`,onClick:()=>void se(t),"aria-label":`Open ${t.path}`,"aria-current":r?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:t.name}),e.jsx("span",{className:"markdown-file-item-path",children:t.path}),e.jsxs("span",{className:"markdown-file-item-meta",children:[ge(t.size)," · ",_(t.mtime)]})]})},t.path)})})}),(!E||i)&&e.jsxs("section",{className:"documents-view-main","aria-label":"Project file content preview",children:[E&&i&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:te,"aria-label":"Back to project files list",children:[e.jsx(fe,{size:14}),"Back to files"]}),i?e.jsxs("div",{className:"documents-content-viewer",children:[e.jsxs("div",{className:"documents-content-header",children:[e.jsx("p",{className:"documents-file-path-header",children:i.path}),e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>R(t=>!t),"aria-label":F?"Switch to plain text":"Switch to markdown","aria-pressed":F,title:F?"Switch to plain text":"Switch to markdown",children:F?"Markdown":"Plain"})]}),g?e.jsx("p",{className:"documents-content-state",children:"Loading file content…"}):j?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:j}):F?e.jsx("div",{className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(W,{remarkPlugins:[V],children:b??""})})}):e.jsx("pre",{className:"document-card-content-text documents-content-viewer-text",children:b??""})]}):e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:"Select a Markdown file to view its content."})})]})]}):D&&N.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:"Loading task documents…"})}):H.length===0?e.jsx("div",{className:"documents-view-empty",children:l.trim()?e.jsxs("p",{children:['No task documents match "',l.trim(),'".']}):e.jsxs(e.Fragment,{children:[e.jsx(z,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:"No task documents yet."}),e.jsx("p",{className:"documents-view-empty-hint",children:"Documents are created in task detail tabs."})]})}):e.jsx("div",{className:"documents-task-list-wrap",children:e.jsx("div",{className:"documents-view-list",children:H.map(({taskId:t,taskTitle:r,documents:d})=>e.jsx(Se,{taskId:t,taskTitle:r,documents:d,onOpenTask:ee,renderMarkdownStates:M,onToggleMarkdown:ne},t))})})})]})}export{ye as DocumentsView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as e}from"./vendor-react-K0fH_qHe.js";import{aG as z,aH as F,aI as O,x as U,ap as _,R as D,at as V}from"./index-
|
|
1
|
+
import{r as l,j as e}from"./vendor-react-K0fH_qHe.js";import{aG as z,aH as F,aI as O,x as U,ap as _,R as D,at as V}from"./index-u6AOHWO5.js";import"./vendor-xterm-DzcZoU0P.js";const $=300,P=15e3;function T(a){if(!a.trim())return;const t=Number(a);return Number.isFinite(t)?t:void 0}function j(...a){for(const t of a)if(Array.isArray(t))return t;return[]}function v(a){return typeof a=="object"&&a!==null?a:{}}function q(a){const t=v(a),r=v(t.taskSnapshot);return{id:String(t.id??t.evalId??""),runId:String(t.runId??t.batchId??""),taskId:String(t.taskId??r.taskId??""),taskTitle:String(r.title??t.taskTitle??t.title??"Untitled task"),createdAt:String(t.createdAt??t.timestamp??t.updatedAt??new Date(0).toISOString()),overallScore:typeof t.overallScore=="number"?t.overallScore:null,maxScore:typeof t.maxScore=="number"?t.maxScore:null,categoryScores:j(t.categoryScores,v(t.scores).categories)}}function B(a){const t=v(a);return{...q(t),rationale:String(t.rationale??t.summary??""),evidence:j(t.evidence,v(t.details).evidence),followUps:j(t.followUps,v(t.recommendations).followUps)}}function G(a){const t=a?.projectId,[r,g]=l.useState({q:"",runId:"",scoreMin:"",scoreMax:""}),[S,h]=l.useState([]),[I,p]=l.useState([]),[i,f]=l.useState(null),[k,c]=l.useState(null),[E,w]=l.useState(0),[N,b]=l.useState(!0),[R,s]=l.useState(null),n=l.useRef(0),d=l.useCallback(async()=>{const u=++n.current;b(!0),s(null);try{const[o,y]=await Promise.all([z({q:r.q||void 0,runId:r.runId||void 0,scoreMin:T(r.scoreMin),scoreMax:T(r.scoreMax),limit:100,offset:0},t),F(t)]);if(u!==n.current)return;const M=j(o.results,o.evals,o.items).map(q);p(M),w(typeof o.count=="number"?o.count:M.length);const L=j(y.runs,y.items);h(L.map(C=>{const x=v(C),A=v(x.counts);return{id:String(x.id??""),createdAt:String(x.createdAt??""),completedAt:typeof x.completedAt=="string"?x.completedAt:void 0,status:String(x.status??"pending"),evaluatedTaskCount:typeof A.totalTasks=="number"?A.totalTasks:0}})),i&&!M.some(C=>C.id===i)&&(f(null),c(null))}catch(o){if(u!==n.current)return;s(o instanceof Error?o.message:"Failed to load evals")}finally{u===n.current&&b(!1)}},[r.q,r.runId,r.scoreMax,r.scoreMin,t,i]),m=l.useCallback(async u=>{const o=await O(u,t),y=o.result??o;c(B(y))},[t]);return l.useEffect(()=>{const u=window.setTimeout(()=>{d()},$);return()=>window.clearTimeout(u)},[d]),l.useEffect(()=>{if(!i){c(null);return}m(i)},[m,i]),l.useEffect(()=>{const u=window.setInterval(()=>{d(),i&&m(i)},P);return()=>window.clearInterval(u)},[m,d,i]),{loading:N,error:R,results:I,count:E,runs:S,filters:r,setFilters:g,refresh:d,selectedEvalId:i,setSelectedEvalId:f,selectedEval:k}}function W({projectId:a,onOpenSettings:t,onOpenTaskDetail:r}){const{loading:g,error:S,results:h,runs:I,filters:p,setFilters:i,selectedEvalId:f,setSelectedEvalId:k,selectedEval:c,refresh:E}=G({projectId:a}),[w,N]=l.useState(!0);l.useEffect(()=>{let s=!1;return U(a).then(n=>{if(s)return;const d=n.evalSettings?.enabled;N(d??!1)}).catch(()=>{s||N(!1)}),()=>{s=!0}},[a]);const b=h.length>0,R=l.useMemo(()=>h.find(s=>s.id===f)??null,[h,f]);return w?e.jsxs("section",{className:"evals-view","data-testid":"evals-view",children:[e.jsxs("div",{className:"evals-list card",children:[e.jsxs("div",{className:"evals-toolbar",children:[e.jsx("input",{className:"input",placeholder:"Search task or rationale",value:p.q,onChange:s=>i(n=>({...n,q:s.target.value}))}),e.jsxs("select",{className:"select",value:p.runId,onChange:s=>i(n=>({...n,runId:s.target.value})),children:[e.jsx("option",{value:"",children:"All runs"}),I.map(s=>e.jsx("option",{value:s.id,children:s.id},s.id))]}),e.jsx("input",{className:"input",placeholder:"Min score",value:p.scoreMin,onChange:s=>i(n=>({...n,scoreMin:s.target.value}))}),e.jsx("input",{className:"input",placeholder:"Max score",value:p.scoreMax,onChange:s=>i(n=>({...n,scoreMax:s.target.value}))}),e.jsx("button",{className:"btn btn-icon",type:"button",onClick:()=>void E(),"aria-label":"Refresh evals",children:e.jsx(D,{size:16})})]}),g&&e.jsx("p",{className:"evals-state","data-testid":"evals-loading",children:"Loading evals…"}),S&&e.jsx("p",{className:"evals-state evals-state--error",children:S}),!g&&!S&&!b&&e.jsx("p",{className:"evals-state",children:"No evals yet. Scheduled evals review tasks completed since the last run."}),e.jsx("ul",{className:"evals-results","data-testid":"evals-results",children:h.map(s=>e.jsx("li",{children:e.jsxs("button",{className:`evals-result ${s.id===f?"evals-result--active":""}`,type:"button",onClick:()=>k(s.id),children:[e.jsx("span",{className:"evals-result-title",children:s.taskTitle}),e.jsxs("span",{className:"evals-result-meta",children:[s.taskId," · ",s.runId," · ",s.overallScore??"n/a"]})]})},s.id))})]}),e.jsxs("div",{className:"evals-detail card","data-testid":"evals-detail",children:[!c&&e.jsx("p",{className:"evals-state",children:"Select an evaluation to inspect scores, rationale, and evidence."}),c&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"evals-detail-title",children:R?.taskTitle??c.taskTitle}),e.jsxs("p",{className:"evals-result-meta",children:[c.taskId," · ",c.runId]}),e.jsxs("p",{className:"evals-score",children:["Overall score: ",c.overallScore??"n/a"]}),e.jsx("ul",{className:"evals-categories",children:c.categoryScores.map(s=>e.jsxs("li",{children:[s.category,": ",s.finalScore]},s.category))}),e.jsx("p",{className:"evals-rationale",children:c.rationale||"No rationale recorded."}),e.jsxs("div",{children:[e.jsx("h4",{children:"Evidence"}),e.jsx("ul",{className:"evals-links",children:c.evidence.map((s,n)=>{const d=typeof s.metadata?.taskId=="string"?s.metadata.taskId:void 0,m=typeof s.metadata?.url=="string"?s.metadata.url:void 0;return e.jsx("li",{children:d?e.jsx("button",{type:"button",className:"btn",onClick:()=>r?.(d),children:s.ref}):m?e.jsxs("a",{href:m,target:"_blank",rel:"noreferrer",className:"evals-external-link",children:[s.ref,e.jsx(V,{size:14})]}):e.jsx("span",{children:s.ref})},`${s.ref}-${n}`)})})]}),e.jsxs("div",{children:[e.jsx("h4",{children:"Suggested follow-up tasks"}),e.jsxs("ul",{className:"evals-follow-ups",children:[c.followUps.length===0&&e.jsx("li",{children:"None"}),c.followUps.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:s.title}),e.jsx("p",{children:s.rationale})]},s.suggestionId))]})]})]})]})]}):e.jsxs("section",{className:"evals-view card","data-testid":"evals-disabled",children:[e.jsx("h2",{className:"evals-title",children:"Scheduled evals are disabled"}),e.jsx("p",{className:"evals-empty-copy",children:"Enable Scheduled Evals to review scored tasks, evidence, and follow-up recommendations."}),e.jsxs("button",{className:"btn btn-primary",type:"button",onClick:()=>t?.("scheduled-evals"),children:[e.jsx(_,{size:16}),"Open Scheduled Evals Settings"]})]})}export{W as EvalsView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as s,j as e}from"./vendor-react-K0fH_qHe.js";import{bq as L,eg as F,eh as H,ei as V,ej as U,ek as K}from"./index-
|
|
1
|
+
import{r as s,j as e}from"./vendor-react-K0fH_qHe.js";import{bq as L,eg as F,eh as H,ei as V,ej as U,ek as K}from"./index-u6AOHWO5.js";function fe({value:o,onChange:u,projectId:h,disabled:m=!1,id:g,label:w="Skills"}){const[k,l]=s.useState([]),[c,f]=s.useState(!0);s.useEffect(()=>{let n=!1;return f(!0),L(h).then(p=>{n||l(p)}).catch(()=>{n||l([])}).finally(()=>{n||f(!1)}),()=>{n=!0}},[h]);const j=n=>{o.includes(n)||u([...o,n])},d=n=>{u(o.filter(p=>p!==n))},I=n=>k.find(S=>S.id===n)?.name??n,x=k.filter(n=>!o.includes(n.id));return e.jsxs("div",{className:"skill-multiselect","data-testid":"skill-multiselect",children:[w&&e.jsx("label",{htmlFor:g?`${g}-select`:void 0,className:"skill-multiselect-label",children:w}),o.length>0&&e.jsx("div",{className:"skill-multiselect-chips","data-testid":"skill-chips",children:o.map(n=>e.jsxs("span",{className:"skill-chip","data-testid":`skill-chip-${n}`,children:[e.jsx("span",{className:"skill-chip-name",children:I(n)}),e.jsx("button",{type:"button",className:"skill-chip-remove",onClick:()=>d(n),disabled:m,"aria-label":`Remove ${I(n)}`,"data-testid":`remove-skill-${n}`,children:"×"})]},n))}),e.jsx("div",{className:"skill-multiselect-add",children:c?e.jsx("span",{className:"skill-multiselect-loading","data-testid":"skills-loading",children:"Loading skills…"}):x.length===0?e.jsx("span",{className:"skill-multiselect-empty","data-testid":"skills-empty",children:o.length===0?"No skills discovered":"All skills selected"}):e.jsxs("select",{id:g?`${g}-select`:void 0,className:"select skill-multiselect-dropdown",value:"",onChange:n=>{n.target.value&&(j(n.target.value),n.target.value="")},disabled:m,"data-testid":"skill-dropdown",children:[e.jsx("option",{value:"",children:"Add a skill…"}),x.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id))]})})]})}const B=/(?:^|\/)skills\/([^/]+)\/SKILL\.md$/i;function ye(o){const u=o.trim();if(!u)return o;const h=u.match(B);return h?.[1]?h[1]:u}const Q=`# Soul: Chief Executive Officer
|
|
2
2
|
|
|
3
3
|
I am a strategic leader who connects every decision to business outcomes.
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r,j as e}from"./vendor-react-K0fH_qHe.js";import{c as ye,ae as $e,af as De,ag as Le,ah as Pe,ai as Ue,aj as Te,ak as _e,al as de,am as Ge,h as Oe,j as ue,an as w,X as ge,ao as ne,R as j,ap as qe,m as Be,C as pe,aq as X,ar as me,as as He,I as be,at as Ve,au as we,av as Ye}from"./index-
|
|
1
|
+
import{r,j as e}from"./vendor-react-K0fH_qHe.js";import{c as ye,ae as $e,af as De,ag as Le,ah as Pe,ai as Ue,aj as Te,ak as _e,al as de,am as Ge,h as Oe,j as ue,an as w,X as ge,ao as ne,R as j,ap as qe,m as Be,C as pe,aq as X,ar as me,as as He,I as be,at as Ve,au as we,av as Ye}from"./index-u6AOHWO5.js";import{U as ve}from"./users-Ch_Fnf5M.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,2 +1,2 @@
|
|
|
1
|
-
import{r as a,j as e}from"./vendor-react-K0fH_qHe.js";import{u as Le}from"./SettingsModal-
|
|
1
|
+
import{r as a,j as e}from"./vendor-react-K0fH_qHe.js";import{u as Le}from"./SettingsModal-Bqfq-gnu.js";import{bF as Ee,bG as Me,bH as Ie,y as Re,bI as qe,bJ as Pe,bK as _e,bL as ke,bM as we,bN as We,bO as Oe,bP as Te,bQ as Ae,bR as $e,x as Ue,bS as He,L as w,bT as Fe}from"./index-u6AOHWO5.js";import"./vendor-xterm-DzcZoU0P.js";const O=".fusion/memory/MEMORY.md",Qe=5e4,Ye="0 3 * * *",Be="0 4 * * *";function he(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??Qe,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??Ye,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??Be}}function De(i,t){return i.some(m=>m.path===t)?t:i.find(m=>m.path===O)?.path??i[0]?.path??O}function Ge(i={}){const{projectId:t}=i,[m,u]=a.useState(""),[C,A]=a.useState(!0),[E,M]=a.useState(!1),[b,x]=a.useState(!1),[r,p]=a.useState(null),[T,J]=a.useState(!0),[X,L]=a.useState(!1),[S,_]=a.useState(()=>he({})),[F,ee]=a.useState(!0),[ue,$]=a.useState(!1),[o,v]=a.useState([]),[se,I]=a.useState(!0),[c,k]=a.useState(O),[W,y]=a.useState(""),[d,te]=a.useState(!1),[U,f]=a.useState(!1),[ae,H]=a.useState(!1),[ne,Q]=a.useState(!1),[Y,re]=a.useState(!1),[D,z]=a.useState(null),[ye,R]=a.useState(!0),[ge,B]=a.useState(!1),[ie,G]=a.useState(!1),[le,V]=a.useState(null),{status:me,loading:K,refresh:j}=Le({projectId:t}),be=a.useCallback(n=>{y(n),f(!0)},[]),N=a.useCallback(async n=>{te(!0);try{const{content:l}=await Ee(n,t);k(n),y(l),f(!1)}finally{te(!1)}},[t]),q=a.useCallback(async()=>{I(!0);try{const{files:n}=await Me(t);if(v(n),n.length===0){k(O),y(""),f(!1);return}const l=De(n,c);l!==c&&await N(l)}finally{I(!1)}},[t,c,N]);a.useEffect(()=>{let n=!1;async function l(){try{const s=await $e(t);n||(u(s.content),A(!1))}catch{n||(u(""),A(!1))}}return l(),()=>{n=!0}},[t]),a.useEffect(()=>{let n=!1;async function l(){try{const s=await we(t);n||(p(s.content),L(s.exists),J(!1))}catch{n||(p(null),L(!1),J(!1))}}return l(),()=>{n=!0}},[t]),a.useEffect(()=>{let n=!1;async function l(){ee(!0);try{const s=await Ue(t);n||_(he(s))}catch{n||_(he({}))}finally{n||ee(!1)}}return l(),()=>{n=!0}},[t]),a.useEffect(()=>{let n=!1;async function l(){I(!0);try{const{files:s}=await Me(t);if(n)return;if(v(s),s.length===0){k(O),y(""),f(!1);return}const h=De(s,c),{content:g}=await Ee(h,t);if(n)return;k(h),y(g),f(!1)}catch{n||(v([]),k(O),y(""),f(!1))}finally{n||I(!1)}}return l(),()=>{n=!0}},[t,c]),a.useEffect(()=>{let n=!1;async function l(){try{const s=await ke(t);n||(z(s),R(!1))}catch{n||(z(null),R(!1))}}return l(),()=>{n=!0}},[t]),a.useEffect(()=>{let n=!1;async function l(){try{const s=await He(t);n||V(s)}catch{n||V(null)}}return l(),()=>{n=!0}},[t]);const ce=a.useCallback(n=>{u(n),M(!0)},[]),oe=a.useCallback(async()=>{if(E){x(!0);try{await Ie(m,t),M(!1)}finally{x(!1)}}},[m,E,t]),xe=a.useCallback(async n=>{$(!0);try{const l=await Re(n,t);_(he(l))}finally{$(!1)}},[t]),pe=a.useCallback(async n=>{await N(n)},[N]),fe=a.useCallback(async()=>{if(U){H(!0);try{await qe(c,W,t),f(!1),await q()}finally{H(!1)}}},[W,U,c,t,q]),je=a.useCallback(async()=>{G(!0);try{const n=await Pe(t);return await j(),n}finally{G(!1)}},[t,j]),Se=a.useCallback(async n=>_e(n,t),[t]),Z=a.useCallback(async()=>{try{const n=await ke(t);z(n)}catch{z(null)}},[t]),P=a.useCallback(async()=>{try{const n=await we(t);p(n.content),L(n.exists)}catch{p(null),L(!1)}},[t]),de=a.useCallback(async n=>{await We(n,t),await P()},[t,P]),ve=a.useCallback(async()=>{Q(!0);try{const n=await Oe(t);return await Promise.all([P(),Z()]),{success:n.success,summary:n.summary}}finally{Q(!1)}},[t,P,Z]),Ne=a.useCallback(async()=>{re(!0);try{return await Te(t)}finally{re(!1)}},[t]),Ce=a.useCallback(async n=>{B(!0);try{const l=n?await Ae(n,t):await Ae(t);if(n){const s=l.path??n;k(s),y(l.content),f(!1),await q();return}u(l.content),M(!0)}finally{B(!1)}},[t,q]);return{workingMemory:m,workingMemoryLoading:C,workingMemoryDirty:E,setWorkingMemory:ce,saveWorkingMemory:oe,savingWorkingMemory:b,insightsContent:r,insightsLoading:T,insightsExists:X,refreshInsights:P,saveInsights:de,memorySettings:S,settingsLoading:F,savingMemorySettings:ue,saveMemorySettings:xe,memoryFiles:o,memoryFilesLoading:se,selectedFilePath:c,selectedFileContent:W,selectedFileLoading:d,selectedFileDirty:U,setSelectedFileContent:be,selectFile:pe,saveSelectedFile:fe,savingSelectedFile:ae,reloadMemoryFiles:q,backendStatus:me,backendLoading:K,extractInsights:ve,extracting:ne,triggerDreamNow:Ne,dreamRunning:Y,auditReport:D,auditLoading:ye,refreshAudit:Z,compactMemory:Ce,compacting:ge,installQmdAction:je,installingQmd:ie,testRetrieval:Se,stats:le}}const Ve={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},Ke={"long-term":"Long-term",daily:"Daily",dreams:"Dreams"},Ze={"long-term":"Curated durable decisions, conventions, constraints, and pitfalls promoted from dreams.",daily:"Raw daily observations, open loops, and running context for dream processing.",dreams:"Synthesized patterns and open loops promoted from daily memory."},Je=72;function Xe(i,t){if(i.length<=t)return i;const m=Math.max(1,t-1),u=Math.ceil(m/2),C=Math.floor(m/2);return`${i.slice(0,u)}…${i.slice(i.length-C)}`}function es(i){const t=`${i.label} — ${i.path}`;return Xe(t,Je)}function ss(i){if(!i)return[];const t=[],m=i.split(/(?=^## )/m);for(const u of m){const C=u.trim();if(!C)continue;const A=C.match(/^##\s+(.+?)(\n|$)/);if(A){const E=A[1].trim(),M=Ve[E]??E.toLowerCase(),b=C.slice(A[0].length).trim(),x=b.split(`
|
|
2
2
|
`).map(r=>r.replace(/^-\s+/,"").trim()).filter(r=>r.length>0&&(r.startsWith("- ")||r.startsWith("* ")));(x.length>0||b.length>0)&&t.push({name:E,key:M,items:x.length>0?x:b.length>0?[b]:[],expanded:!0})}}return t}function ts(i){if(!i)return null;const t=i.match(/##\s+Last\s+Updated:\s*(\d{4}-\d{2}-\d{2})/i);return t?t[1]:null}function as(i){return i.reduce((t,m)=>t+m.items.length,0)}function ns(i){switch(i){case"file":return"File (.fusion/memory/, agent/<agent-name>/memory/)";case"readonly":return"Read-Only";case"qmd":return"QMD (Quantized Memory Distillation)";default:return i}}function rs(i){switch(i){case"healthy":return"Healthy";case"warning":return"Warning";case"issues":return"Issues Found"}}function os({projectId:i,addToast:t}){const[m,u]=a.useState("working"),[C,A]=a.useState(new Set),[E,M]=a.useState(!1),[b,x]=a.useState(null),[r,p]=a.useState({memoryEnabled:!0,memoryAutoSummarizeEnabled:!1,memoryAutoSummarizeThresholdChars:5e4,memoryAutoSummarizeSchedule:"0 3 * * *",memoryDreamsEnabled:!1,memoryDreamsSchedule:"0 4 * * *"}),[T,J]=a.useState(""),[X,L]=a.useState(!1),[S,_]=a.useState(null),{insightsContent:F,insightsLoading:ee,insightsExists:ue,saveInsights:$,memorySettings:o,settingsLoading:v,saveMemorySettings:se,savingMemorySettings:I,backendStatus:c,backendLoading:k,extractInsights:W,extracting:y,auditReport:d,auditLoading:te,refreshAudit:U,compactMemory:f,compacting:ae,installQmdAction:H,installingQmd:ne,testRetrieval:Q,memoryFiles:Y,memoryFilesLoading:re,selectedFilePath:D,selectedFileContent:z,selectedFileLoading:ye,selectedFileDirty:R,setSelectedFileContent:ge,selectFile:B,saveSelectedFile:ie,savingSelectedFile:G,reloadMemoryFiles:le,triggerDreamNow:V,dreamRunning:me}=Ge({projectId:i});a.useEffect(()=>{p(o)},[o]);const K=a.useMemo(()=>r.memoryEnabled!==o.memoryEnabled||r.memoryAutoSummarizeEnabled!==o.memoryAutoSummarizeEnabled||r.memoryAutoSummarizeThresholdChars!==o.memoryAutoSummarizeThresholdChars||r.memoryAutoSummarizeSchedule!==o.memoryAutoSummarizeSchedule||r.memoryDreamsEnabled!==o.memoryDreamsEnabled||r.memoryDreamsSchedule!==o.memoryDreamsSchedule,[r,o]),j=a.useMemo(()=>Y.find(s=>s.path===D),[Y,D]),be=j?Ze[j.layer]:"Edits the selected memory file.",N=a.useMemo(()=>ss(F),[F]),q=a.useMemo(()=>as(N),[N]),ce=a.useMemo(()=>ts(F),[F]),oe=a.useCallback(s=>{A(h=>{const g=new Set(h);return g.has(s)?g.delete(s):g.add(s),g})},[]),xe=a.useCallback(async s=>{try{await B(s)}catch{t("Failed to load memory file","error")}},[B,t]),pe=a.useCallback(async()=>{try{await ie(),t("Memory saved","success")}catch{t("Failed to save memory","error")}},[ie,t]),fe=a.useCallback(async()=>{if(!K)return;const s={};r.memoryEnabled!==o.memoryEnabled&&(s.memoryEnabled=r.memoryEnabled),r.memoryAutoSummarizeEnabled!==o.memoryAutoSummarizeEnabled&&(s.memoryAutoSummarizeEnabled=r.memoryAutoSummarizeEnabled),r.memoryAutoSummarizeThresholdChars!==o.memoryAutoSummarizeThresholdChars&&(s.memoryAutoSummarizeThresholdChars=r.memoryAutoSummarizeThresholdChars),r.memoryAutoSummarizeSchedule!==o.memoryAutoSummarizeSchedule&&(s.memoryAutoSummarizeSchedule=r.memoryAutoSummarizeSchedule),r.memoryDreamsEnabled!==o.memoryDreamsEnabled&&(s.memoryDreamsEnabled=r.memoryDreamsEnabled),r.memoryDreamsSchedule!==o.memoryDreamsSchedule&&(s.memoryDreamsSchedule=r.memoryDreamsSchedule);try{await se(s),t("Memory settings saved","success")}catch{t("Failed to save memory settings","error")}},[K,r,o,se,t]),je=a.useCallback(async()=>{try{const s=await H();t(s.qmdAvailable?"qmd installed successfully":"qmd install finished, but qmd is still unavailable",s.qmdAvailable?"success":"info")}catch{t("Failed to install qmd","error")}},[H,t]),Se=a.useCallback(async()=>{L(!0),_(null);try{const s=await Q(T);_(s),t(s.qmdAvailable?"Memory retrieval test complete":"qmd is not installed; local fallback was used",s.qmdAvailable?"success":"info")}catch{t("Failed to test memory retrieval","error")}finally{L(!1)}},[T,Q,t]),Z=a.useCallback(async()=>{try{await V(),t("Dream processing completed","success"),await le()}catch(s){t(s instanceof Error?s.message:"Failed to run dream processing","error")}},[V,le,t]),P=a.useCallback(async()=>{try{await f(D),t("Memory file compacted","success")}catch{t("Failed to compact memory","error")}},[f,D,t]),de=a.useCallback(async()=>{try{const s=await W();t(s.summary,"success")}catch(s){t(s instanceof Error?s.message:"Failed to extract insights","error")}},[W,t]),ve=a.useCallback(async()=>{if(b!==null)try{await $(b),M(!1),x(null),t("Insights saved","success")}catch{t("Failed to save insights","error")}},[b,$,t]),Ne=a.useCallback(()=>{x(F??""),M(!0)},[F]),Ce=a.useCallback(()=>{M(!1),x(null)},[]),n=!k&&c!==null,l=c?.capabilities?.writable??!1;return e.jsxs("div",{className:"memory-view",children:[e.jsx("div",{className:"memory-view-header",children:e.jsxs("div",{children:[e.jsx("h2",{children:"Memory"}),e.jsx("p",{className:"memory-view-description",children:"Working memory, long-term insights, and engine status"})]})}),e.jsxs("div",{className:"memory-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":m==="working",className:`memory-view-tab${m==="working"?" memory-view-tab--active":""}`,onClick:()=>u("working"),"data-testid":"memory-tab-working",children:"Working Memory"}),e.jsx("button",{type:"button",role:"tab","aria-selected":m==="insights",className:`memory-view-tab${m==="insights"?" memory-view-tab--active":""}`,onClick:()=>u("insights"),"data-testid":"memory-tab-insights",children:"Insights"}),e.jsx("button",{type:"button",role:"tab","aria-selected":m==="engines",className:`memory-view-tab${m==="engines"?" memory-view-tab--active":""}`,onClick:()=>u("engines"),"data-testid":"memory-tab-engines",children:"Engines"})]}),e.jsxs("div",{className:"memory-view-content",children:[m==="working"&&e.jsxs("div",{className:"memory-working-tab",children:[n&&!l&&e.jsx("div",{className:"memory-readonly-banner",children:"This memory backend is read-only. Changes cannot be saved."}),re||ye?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(w,{size:20,className:"animate-spin"}),e.jsx("span",{children:"Loading memory file…"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-editor-section",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryViewFilePath",children:"Memory File"}),e.jsx("select",{id:"memoryViewFilePath",className:"select",value:D,onChange:s=>{xe(s.target.value)},disabled:R,children:Y.map(s=>e.jsx("option",{value:s.path,title:`${s.label} — ${s.path}`,children:es(s)},s.path))}),e.jsx("small",{children:R?"Save or discard the current edits before switching files.":"Choose any project memory file to view or edit."})]}),j&&e.jsxs("div",{className:"memory-file-summary",children:[e.jsx("span",{children:Ke[j.layer]}),e.jsx("strong",{children:j.path}),e.jsxs("small",{children:[j.size.toLocaleString()," bytes · updated ",new Date(j.updatedAt).toLocaleString()]})]}),e.jsxs("div",{className:"form-group memory-editor-form-group",children:[e.jsx("label",{children:j?.label||"Memory Editor"}),e.jsx("small",{children:be}),e.jsx("div",{className:"memory-editor-container",children:e.jsx(Fe,{content:z,onChange:ge,readOnly:!l,filePath:D})})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsxs("span",{className:"memory-char-count",children:[z.length," characters"]}),e.jsx("div",{className:"memory-flex-spacer"}),l&&z.length>0&&e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:P,disabled:ae||R,children:ae?e.jsxs(e.Fragment,{children:[e.jsx(w,{size:14,className:"animate-spin"}),"Compacting…"]}):"Compact Selected File"}),R&&l&&e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:pe,disabled:G,children:G?e.jsxs(e.Fragment,{children:[e.jsx(w,{size:14,className:"animate-spin"}),"Saving…"]}):"Save"})]}),e.jsxs("div",{className:"memory-config-section",children:[e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"memoryDreamsEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryDreamsEnabled",type:"checkbox",checked:r.memoryDreamsEnabled,onChange:s=>{p(h=>({...h,memoryDreamsEnabled:s.target.checked}))},disabled:!r.memoryEnabled||v}),"Process dreams from daily memory"]}),e.jsx("small",{children:"Turns daily notes into DREAMS.md and promotes reusable lessons into MEMORY.md."})]}),r.memoryEnabled&&r.memoryDreamsEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryDreamsSchedule",children:"Dream Schedule"}),e.jsx("input",{id:"memoryDreamsSchedule",type:"text",className:"input",value:r.memoryDreamsSchedule,onChange:s=>{p(h=>({...h,memoryDreamsSchedule:s.target.value}))},placeholder:"0 4 * * *",disabled:v}),e.jsx("small",{children:"Cron expression for dream processing."})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:Z,disabled:me||!r.memoryDreamsEnabled,children:me?e.jsxs(e.Fragment,{children:[e.jsx(w,{size:14,className:"animate-spin"}),"Dreaming…"]}):"Dream Now"}),e.jsx("small",{children:"Manually trigger dream processing now."})]})]})]}),e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"memoryAutoSummarizeEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryAutoSummarizeEnabled",type:"checkbox",checked:r.memoryAutoSummarizeEnabled,onChange:s=>{p(h=>({...h,memoryAutoSummarizeEnabled:s.target.checked}))},disabled:!r.memoryEnabled||v}),"Auto-Summarize Memory"]}),e.jsx("small",{children:"Automatically compact memory when it exceeds the threshold on a schedule"})]}),r.memoryEnabled&&r.memoryAutoSummarizeEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeThresholdChars",children:"Compaction Threshold (chars)"}),e.jsx("input",{id:"memoryAutoSummarizeThresholdChars",type:"number",className:"input",value:r.memoryAutoSummarizeThresholdChars,onChange:s=>{p(h=>({...h,memoryAutoSummarizeThresholdChars:parseInt(s.target.value,10)||5e4}))},min:1e3,disabled:v}),e.jsx("small",{children:"Memory will be compacted when it exceeds this character count"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeSchedule",children:"Schedule (cron)"}),e.jsx("input",{id:"memoryAutoSummarizeSchedule",type:"text",className:"input",value:r.memoryAutoSummarizeSchedule,onChange:s=>{p(h=>({...h,memoryAutoSummarizeSchedule:s.target.value}))},placeholder:"0 3 * * *",disabled:v}),e.jsx("small",{children:"Cron expression for auto-summarize schedule (default: daily at 3 AM)"})]})]})]}),!r.memoryEnabled&&e.jsx("div",{className:"settings-empty-state memory-status-message",children:"Memory is currently disabled. Enable memory tools in Settings to edit these automations."}),K&&e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:fe,disabled:I||v,children:I?e.jsxs(e.Fragment,{children:[e.jsx(w,{size:14,className:"animate-spin"}),"Saving…"]}):"Save Settings"})})]})]})]}),m==="insights"&&e.jsx("div",{className:"memory-insights-tab",children:ee?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(w,{size:20,className:"animate-spin"}),e.jsx("span",{children:"Loading insights…"})]}):E?e.jsxs("div",{className:"memory-insights-editor-layout",children:[e.jsx("div",{className:"memory-editor-container",children:e.jsx(Fe,{content:b??"",onChange:x,readOnly:!1,filePath:".fusion/memory/INSIGHTS.md"})}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Ce,children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:ve,children:"Save Insights"})]})]}):!ue||N.length===0?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx("p",{children:"No insights extracted yet."}),e.jsx("p",{children:'Insights are automatically extracted from working memory. Click "Extract Now" to trigger extraction manually.'}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm memory-empty-extract-button",onClick:de,disabled:y,children:y?e.jsxs(e.Fragment,{children:[e.jsx(w,{size:14,className:"animate-spin"}),"Extracting…"]}):"Extract Now"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-stats-row",children:[e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:q}),e.jsx("div",{className:"memory-stat-label",children:"Total Insights"})]}),e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:N.length}),e.jsx("div",{className:"memory-stat-label",children:"Categories"})]}),ce&&e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value memory-stat-value--updated",children:ce}),e.jsx("div",{className:"memory-stat-label",children:"Last Updated"})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:de,disabled:y,children:y?e.jsxs(e.Fragment,{children:[e.jsx(w,{size:14,className:"animate-spin"}),"Extracting…"]}):"Extract Now"}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Ne,children:"Edit Raw"})]}),e.jsx("div",{className:"memory-categories-list",children:N.map(s=>{const h=!C.has(s.key);return e.jsxs("div",{className:"memory-category-section",children:[e.jsxs("div",{className:"memory-category-header",onClick:()=>oe(s.key),role:"button",tabIndex:0,onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),oe(s.key))},children:[e.jsx("h4",{children:s.name}),e.jsx("span",{className:"memory-category-count",children:s.items.length})]}),h&&e.jsx("div",{className:"memory-category-items",children:s.items.map((g,ze)=>e.jsx("div",{className:"memory-insight-item",children:g.replace(/^-\s+/,"").replace(/^\*\s+/,"")},ze))})]},s.key)})})]})}),m==="engines"&&e.jsx("div",{className:"memory-engines-tab",children:k||te?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(w,{size:20,className:"animate-spin"}),e.jsx("span",{children:"Loading engine status…"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-engine-card memory-qmd-card",children:[e.jsx("h3",{children:"QMD Integration"}),c?.qmdAvailable===!0?e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge memory-health-badge--healthy",children:"Installed"}),e.jsx("span",{className:"memory-char-count",children:"qmd is available on PATH."})]}):c?.qmdAvailable===!1?e.jsxs("div",{className:"settings-empty-state memory-status-message",children:[e.jsxs("span",{children:["qmd is not installed. Search will use local files. Install indexed retrieval: ",e.jsx("code",{children:c.qmdInstallCommand||"bun install -g @tobilu/qmd"})]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:je,disabled:ne,children:ne?"Installing…":"Install qmd"})]}):e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge",children:"Checking"}),e.jsx("span",{className:"memory-char-count",children:"Checking qmd availability…"})]}),e.jsxs("div",{className:"memory-capability-row",children:[c?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:"Readable"}),c?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:"Writable"}),c?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:"Atomic Writes"}),c?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:"Persistent"})]})]}),e.jsxs("div",{className:"memory-engine-card memory-retrieval-card",children:[e.jsx("h3",{children:"Test Memory Search"}),e.jsxs("div",{className:"memory-retrieval-input-row",children:[e.jsx("input",{type:"text",className:"input",value:T,onChange:s=>J(s.target.value),placeholder:"Search memory with qmd"}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Se,disabled:X,children:X?"Testing…":"Test Retrieval"})]}),e.jsx("small",{className:"settings-muted",children:"Runs the same qmd-backed memory_search path agents use."}),S&&e.jsxs("div",{className:"memory-test-result",children:[e.jsxs("strong",{children:[S.results.length," result",S.results.length===1?"":"s"," ",'for "',S.query,'"']}),e.jsxs("small",{children:["qmd ",S.qmdAvailable?"available":"missing"," · ",S.usedFallback?"local fallback used":"qmd path used"]}),S.results.length>0?e.jsx("ul",{children:S.results.map((s,h)=>e.jsxs("li",{children:[e.jsxs("span",{children:[s.path,":",s.lineStart]}),e.jsx("p",{children:s.snippet})]},`${s.path}-${s.lineStart}-${h}`))}):e.jsx("small",{children:"No matching memory found."})]})]}),e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:"Current Backend"}),e.jsx("div",{className:"memory-engine-status",children:e.jsx("span",{className:"memory-emphasis-text",children:ns(c?.currentBackend??"unknown")})}),e.jsxs("div",{className:"memory-capability-row",children:[c?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:"Readable"}),c?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:"Writable"}),c?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:"Atomic Writes"}),c?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:"Persistent"})]})]}),d&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsxs("div",{className:"memory-health-header",children:[e.jsx("h3",{children:"Health Status"}),e.jsx("span",{className:`memory-health-badge memory-health-badge--${d.health}`,children:rs(d.health)})]}),e.jsxs("div",{className:"memory-health-grid",children:[e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:"Working Memory"}),e.jsxs("div",{className:"memory-emphasis-text",children:[d.workingMemory.size," chars"]}),e.jsxs("div",{className:"memory-health-detail",children:[d.workingMemory.sectionCount," sections"]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:"Insights Memory"}),e.jsxs("div",{className:"memory-emphasis-text",children:[d.insightsMemory.size," chars"]}),e.jsxs("div",{className:"memory-health-detail",children:[d.insightsMemory.insightCount," insights"]})]})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:"Last Extraction"}),e.jsx("div",{className:"memory-emphasis-text",children:d.extraction.success?e.jsx("span",{className:"memory-status-text memory-status-text--success",children:"Success"}):e.jsx("span",{className:"memory-status-text memory-status-text--error",children:"Failed"})}),e.jsx("div",{className:"memory-health-detail",children:d.extraction.summary||`${d.extraction.insightCount} insights extracted`})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:"Pruning"}),e.jsx("div",{className:"memory-emphasis-text",children:d.pruning.applied?e.jsx("span",{className:"memory-status-text memory-status-text--warning",children:"Applied"}):e.jsx("span",{className:"memory-status-text memory-status-text--muted",children:"Not needed"})}),d.pruning.applied&&e.jsx("div",{className:"memory-health-detail",children:d.pruning.reason})]})]}),d&&d.checks.length>0&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:"Audit Checks"}),e.jsx("div",{children:d.checks.map(s=>e.jsxs("div",{className:"memory-audit-check",children:[e.jsx("span",{className:s.passed?"memory-audit-check-passed":"memory-audit-check-failed",children:s.passed?"✓":"✗"}),e.jsxs("div",{className:"memory-audit-check-content",children:[e.jsx("div",{className:"memory-emphasis-text",children:s.name}),e.jsx("div",{className:"memory-health-detail",children:s.details})]})]},s.id))})]}),e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:()=>U(),children:"Run Audit"})}),e.jsxs("div",{className:"memory-settings-note",children:[e.jsx("span",{children:"Note: Change backend type in"}),e.jsx("button",{type:"button",className:"memory-settings-note-button",onClick:()=>{t("Open Settings → Memory to change backend type","info")},children:"Settings → Memory"})]})]})})]})]})}export{os as MemoryView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as s,j as e}from"./vendor-react-K0fH_qHe.js";import{c as ze,aJ as ls,aK as os,aL as cs,aM as is,aN as Le,aO as be,aP as Ve,aQ as ye,aR as Fe,A as Oe,ap as ds,U as Ke,aS as Ue,aT as us,W as _e,u as ms,R as Ne,a as we,I as he,aU as Te,aV as hs,aW as fs,aX as gs,aY as $e,X as me,a8 as xs,a9 as ps,aZ as De,F as js,a_ as Ie,a$ as vs,b0 as bs,b1 as ys,b2 as _s,b3 as Ns,G as ks}from"./index-
|
|
1
|
+
import{r as s,j as e}from"./vendor-react-K0fH_qHe.js";import{c as ze,aJ as ls,aK as os,aL as cs,aM as is,aN as Le,aO as be,aP as Ve,aQ as ye,aR as Fe,A as Oe,ap as ds,U as Ke,aS as Ue,aT as us,W as _e,u as ms,R as Ne,a as we,I as he,aU as Te,aV as hs,aW as fs,aX as gs,aY as $e,X as me,a8 as xs,a9 as ps,aZ as De,F as js,a_ as Ie,a$ as vs,b0 as bs,b1 as ys,b2 as _s,b3 as Ns,G as ks}from"./index-u6AOHWO5.js";import{v as Cs}from"./projectDetection-G3XuxD2X.js";import{U as Be}from"./upload-BHiYszS2.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.
|
package/dist/client/assets/{PiExtensionsManager-oi9FHT0y.js → PiExtensionsManager-ckNj1Wvv.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,j as e}from"./vendor-react-K0fH_qHe.js";import{c as J,ey as Q,ez as V,eA as Y,R as $,en as y,I as Z,a as T,b as ee,W as se,eB as L,cH as D,F as A,eC as ae,eD as te,eE as I,X as ie}from"./index-
|
|
1
|
+
import{r as l,j as e}from"./vendor-react-K0fH_qHe.js";import{c as J,ey as Q,ez as V,eA as Y,R as $,en as y,I as Z,a as T,b as ee,W as se,eB as L,cH as D,F as A,eC as ae,eD as te,eE as I,X as ie}from"./index-u6AOHWO5.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 g,j as e}from"./vendor-react-K0fH_qHe.js";import{v as ye,el as je,em as Z,s as Ne,X as Y,at as Se,aR as ve,I as T,aZ as ee,W as se,R as we,en as Ce,ap as Ie,eo as $e,ep as Pe,cx as Re,eq as Ee,er as ke,es as Be,et as Le,eu as te,cu as Ae,ev as Fe}from"./index-DiewofJh.js";import{D as De}from"./DirectoryPicker-CWSApoLU.js";import"./vendor-xterm-DzcZoU0P.js";import"./folder-open-DU-Ec_iC.js";const le="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:le,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 ze(i){const c=i.settingsSchema,h=c&&Object.keys(c).length>0;return i.id!==le?h?c:void 0:h?{...ne,...c}:ne}function Oe(i){const c=new Map,h=[];for(const[x,f]of Object.entries(i))if(f.group){const N=c.get(f.group)??[];N.push([x,f]),c.set(f.group,N)}else h.push([x,f]);return{grouped:c,ungrouped:h}}function ie(i,c="plugin-error-text"){return i.state!=="error"||!i.error?null:e.jsx("p",{className:c,title:i.error,children:i.error})}function He({addToast:i,projectId:c}){const[h,x]=g.useState([]),[f,N]=g.useState(!0),[re,$]=g.useState(!1),[w,P]=g.useState(""),[B,L]=g.useState(!1),[A,F]=g.useState(!1),[S,D]=g.useState(null),[r,R]=g.useState(null),[p,b]=g.useState({}),[ce,z]=g.useState(!1),[O,G]=g.useState(null),[oe,E]=g.useState({}),[ue,U]=g.useState(null),[C,q]=g.useState(null),{confirm:de}=ye(),m=g.useCallback(async()=>{try{N(!0);const s=await je(c);x(s)}catch(s){i(`Failed to load plugins: ${s instanceof Error?s.message:String(s)}`,"error")}finally{N(!1)}},[c,i]);g.useEffect(()=>{m()},[m]),g.useEffect(()=>{const s=ae.filter(o=>o.hasSetup&&h.some(l=>l.id===o.id));if(s.length===0)return;let n=!1;return Promise.all(s.map(async o=>{try{const l=await Z(o.id,c);if(n)return;E(u=>({...u,[o.id]:l}))}catch{if(n)return;E(l=>({...l,[o.id]:{hasSetup:!0,setupCheckDeferred:!0,deferredReason:"plugin-not-started",pluginState:"installed"}}))}})),()=>{n=!0}},[h,c]);const pe=g.useRef([]);pe.current=h,g.useEffect(()=>{const s=c?`?projectId=${encodeURIComponent(c)}`:"",n=o=>{try{const l=JSON.parse(o.data);if(l.scope==="project"&&(l.projectId??c)!==c)return;switch(l.transition){case"installing":case"enabled":case"disabled":case"settings-updated":x(u=>{const a=u.findIndex(t=>t.id===l.pluginId);if(a>=0){const t=[...u];return t[a]={...t[a],enabled:l.enabled,state:l.state,settings:l.settings,error:l.error},t}else return m(),u});break;case"state-changed":x(u=>{const a=u.findIndex(t=>t.id===l.pluginId);if(a>=0){const t=[...u];return t[a]={...t[a],state:l.state,error:l.error},t}return u});break;case"uninstalled":x(u=>u.filter(a=>a.id!==l.pluginId));break;case"error":x(u=>{const a=u.findIndex(t=>t.id===l.pluginId);if(a>=0){const t=[...u];return t[a]={...t[a],state:l.state,error:l.error},t}return u});break}}catch{}};return Ne(`/api/events${s}`,{events:{"plugin:lifecycle":n},onReconnect:()=>{m()}})},[c,m]);const M=async()=>{if(!w.trim()){i("Please enter a plugin path","error");return}try{L(!0),await te({path:w,...A?{aiScanOnLoad:!0}:{}},c),i("Plugin installed globally","success"),$(!1),P(""),F(!1),await m()}catch(s){i(`Failed to install plugin: ${s instanceof Error?s.message:String(s)}`,"error")}finally{L(!1)}},ge=async s=>{if(!s.path){i(`${s.name} is built in and does not have an installable package yet`,"warning");return}try{G(s.id),await te({path:s.path},c),i(`${s.name} installed globally`,"success"),await m()}catch(n){i(`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 Fe(s.id,c);if(!n.success){i(`Failed to install ${s.name} setup: ${n.error??"unknown error"}`,"error");return}i(`${s.name} setup installed`,"success"),U(s.id);const o=await Z(s.id,c);E(l=>({...l,[s.id]:o}))}catch(n){i(`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 Be(s.id,c);if(n.state==="error"){i(`Failed to enable ${s.name}: ${n.error??"Unknown error"}`,"error"),await m();return}i(`${s.name} enabled for this project`,"success"),await m()}catch(n){i(`Failed to enable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},H=async s=>{try{await ke(s.id,c),i(`${s.name} disabled for this project`,"success"),await m()}catch(n){i(`Failed to disable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},W=async s=>{try{D(s.id),await Ee(s.id,c),i(`${s.name} reloaded`,"success"),await m()}catch(n){i(`Failed to reload plugin: ${n instanceof Error?n.message:String(n)}`,"error")}finally{D(null)}},J=async s=>{if(await de({title:"Uninstall Plugin Globally",message:`Are you sure you want to uninstall "${s.name}" globally (all projects)?`,danger:!0}))try{await Le(s.id,c),i(`${s.name} uninstalled globally`,"success"),await m(),R(null)}catch(o){i(`Failed to uninstall plugin: ${o instanceof Error?o.message:String(o)}`,"error")}},me=async(s,n)=>{try{await $e(s.id,{aiScanOnLoad:n},c),i(`AI scan on load ${n?"enabled":"disabled"}`,"success"),await m()}catch(o){i(`Failed to update plugin: ${o instanceof Error?o.message:String(o)}`,"error")}},he=async s=>{try{await Pe(s.id,c),i(`${s.name} rescanned`,"success"),await m()}catch(n){i(`Failed to rescan plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},k=async s=>{R(s);try{z(!0);const n=await Ae(s.id,c);b(n)}catch{b({})}finally{z(!1)}},be=async()=>{if(r)try{await Re(r.id,p,c),i("Settings saved","success")}catch(s){i(`Failed to save settings: ${s instanceof Error?s.message:String(s)}`,"error")}};if(r)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(Y,{size:16})}),e.jsxs("div",{className:"plugin-detail-title",children:[e.jsxs("div",{className:"plugin-detail-title-copy",children:[e.jsx("h4",{className:"plugin-detail-name",children:r.name}),ie(r,"plugin-error-text plugin-error-text--detail")]}),e.jsx("span",{className:"plugin-state-badge",style:{color:I[r.state]||I.installed},children:r.state})]})]}),e.jsxs("div",{className:"plugin-detail-content",children:[e.jsxs("div",{className:"plugin-detail-card",children:[r.description&&e.jsx("p",{className:"plugin-description",children:r.description}),r.author&&e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:"Author:"}),r.author]}),r.homepage&&e.jsxs("p",{className:"plugin-detail-meta-row plugin-homepage",children:[e.jsx("span",{className:"text-muted",children:"Homepage:"}),e.jsxs("a",{href:r.homepage,target:"_blank",rel:"noopener noreferrer",children:[r.homepage,e.jsx(Se,{size:12})]})]}),e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:"Version:"}),r.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:!!r.aiScanOnLoad,onChange:s=>void me(r,s.target.checked)}),"Enable AI scan before load/reload"]}),e.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:()=>void he(r),children:[e.jsx(ve,{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."}),r.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--${r.lastSecurityScan.verdict}`,children:r.lastSecurityScan.verdict}),e.jsx("span",{className:"text-muted",children:r.lastSecurityScan.scannedAt})]}),e.jsx("p",{className:"plugin-security-summary",children:r.lastSecurityScan.summary}),e.jsxs("details",{children:[e.jsxs("summary",{children:["Findings (",r.lastSecurityScan.findings.length,")"]}),e.jsx("ul",{className:"plugin-security-findings",children:r.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"}),ce?e.jsx("p",{className:"text-muted",children:"Loading..."}):(()=>{const s=ze(r);return s&&Object.keys(s).length>0?e.jsxs("div",{className:"plugin-settings-form",children:[(()=>{const{grouped:n,ungrouped:o}=Oe(s),l=[];o.length>0&&l.push({title:null,entries:o});for(const[u,a]of n.entries())l.push({title:u,entries:a});return l.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(Y,{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:be,children:"Save Settings"})]}):e.jsx("p",{className:"text-muted",children:"No configurable settings."})})()]}),e.jsxs("div",{className:"plugin-detail-actions",children:[r.state==="started"&&e.jsxs("button",{className:"btn btn-secondary",onClick:()=>W(r),disabled:S===r.id,children:[e.jsx(ee,{size:14,className:S===r.id?"spin":""}),S===r.id?"Reloading...":"Reload"]}),r.enabled?e.jsx("button",{className:"btn btn-secondary",onClick:()=>H(r),children:"Disable in Project"}):e.jsx("button",{className:"btn btn-primary",onClick:()=>_(r),children:"Enable in Project"}),e.jsxs("button",{className:"btn btn-danger",onClick:()=>J(r),children:[e.jsx(se,{size:14})," Uninstall Globally"]})]})]})]});const xe=new Map(h.map(s=>[s.id,s])),K=h,fe=()=>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=xe.get(s.id),o=!!n,l=oe[s.id],u=!!(l&&"setupCheckDeferred"in l&&l.setupCheckDeferred),a=l&&"status"in l?l.status:void 0,t=o&&s.hasSetup&&l?.hasSetup&&!u&&n?.state==="started"&&(a==="not-installed"||a==="error"),y=o&&l?.hasSetup&&a==="installed",d=ue===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 ${o?"plugin-builtins-status--installed":"plugin-builtins-status--available"}`,children:o?"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?o&&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"}):o&&n?e.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>void k(n),children:"Manage"}):e.jsx("span",{className:"plugin-builtins-metadata-only",children:"Built-in metadata only"}):e.jsx("button",{className:`btn ${o&&!t?"btn-secondary":"btn-primary"} btn-sm`,onClick:()=>{if(!o){ge(s);return}if(t){V(s);return}n&&k(n)},disabled:O===s.id||C===s.id||d,children:o?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(we,{size:14,className:f?"spin":""}),"Refresh"]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>$(!0),children:[e.jsx(T,{size:14})," Install"]})]})]}),re&&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(De,{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(Ce,{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.jsx("div",{className:"plugin-info",children:e.jsxs("div",{className:"plugin-copy",children:[e.jsxs("div",{className:"plugin-copy-header",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})]}),ie(s)]})}),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:()=>k(s),title:"Settings",children:e.jsx(Ie,{size:14})}),e.jsx("button",{className:"btn-icon",onClick:()=>J(s),title:"Uninstall globally",children:e.jsx(se,{size:14})})]})]},s.id))}),fe()]})]})}export{ne as AGENT_BROWSER_SETTINGS_SCHEMA,le as BUILTIN_AGENT_BROWSER_PLUGIN_ID,He as PluginManager,I as STATE_COLORS};
|
|
1
|
+
import{r as g,j as e}from"./vendor-react-K0fH_qHe.js";import{v as ye,el as je,em as Z,s as Ne,X as Y,at as Se,aR as ve,I as T,aZ as ee,W as se,R as we,en as Ce,ap as Ie,eo as $e,ep as Pe,cx as Re,eq as Ee,er as ke,es as Be,et as Le,eu as te,cu as Ae,ev as Fe}from"./index-u6AOHWO5.js";import{D as De}from"./DirectoryPicker-BfShQutV.js";import"./vendor-xterm-DzcZoU0P.js";import"./folder-open-D8Qfxakh.js";const le="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:le,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 ze(i){const c=i.settingsSchema,h=c&&Object.keys(c).length>0;return i.id!==le?h?c:void 0:h?{...ne,...c}:ne}function Oe(i){const c=new Map,h=[];for(const[x,f]of Object.entries(i))if(f.group){const N=c.get(f.group)??[];N.push([x,f]),c.set(f.group,N)}else h.push([x,f]);return{grouped:c,ungrouped:h}}function ie(i,c="plugin-error-text"){return i.state!=="error"||!i.error?null:e.jsx("p",{className:c,title:i.error,children:i.error})}function He({addToast:i,projectId:c}){const[h,x]=g.useState([]),[f,N]=g.useState(!0),[re,$]=g.useState(!1),[w,P]=g.useState(""),[B,L]=g.useState(!1),[A,F]=g.useState(!1),[S,D]=g.useState(null),[r,R]=g.useState(null),[p,b]=g.useState({}),[ce,z]=g.useState(!1),[O,G]=g.useState(null),[oe,E]=g.useState({}),[ue,U]=g.useState(null),[C,q]=g.useState(null),{confirm:de}=ye(),m=g.useCallback(async()=>{try{N(!0);const s=await je(c);x(s)}catch(s){i(`Failed to load plugins: ${s instanceof Error?s.message:String(s)}`,"error")}finally{N(!1)}},[c,i]);g.useEffect(()=>{m()},[m]),g.useEffect(()=>{const s=ae.filter(o=>o.hasSetup&&h.some(l=>l.id===o.id));if(s.length===0)return;let n=!1;return Promise.all(s.map(async o=>{try{const l=await Z(o.id,c);if(n)return;E(u=>({...u,[o.id]:l}))}catch{if(n)return;E(l=>({...l,[o.id]:{hasSetup:!0,setupCheckDeferred:!0,deferredReason:"plugin-not-started",pluginState:"installed"}}))}})),()=>{n=!0}},[h,c]);const pe=g.useRef([]);pe.current=h,g.useEffect(()=>{const s=c?`?projectId=${encodeURIComponent(c)}`:"",n=o=>{try{const l=JSON.parse(o.data);if(l.scope==="project"&&(l.projectId??c)!==c)return;switch(l.transition){case"installing":case"enabled":case"disabled":case"settings-updated":x(u=>{const a=u.findIndex(t=>t.id===l.pluginId);if(a>=0){const t=[...u];return t[a]={...t[a],enabled:l.enabled,state:l.state,settings:l.settings,error:l.error},t}else return m(),u});break;case"state-changed":x(u=>{const a=u.findIndex(t=>t.id===l.pluginId);if(a>=0){const t=[...u];return t[a]={...t[a],state:l.state,error:l.error},t}return u});break;case"uninstalled":x(u=>u.filter(a=>a.id!==l.pluginId));break;case"error":x(u=>{const a=u.findIndex(t=>t.id===l.pluginId);if(a>=0){const t=[...u];return t[a]={...t[a],state:l.state,error:l.error},t}return u});break}}catch{}};return Ne(`/api/events${s}`,{events:{"plugin:lifecycle":n},onReconnect:()=>{m()}})},[c,m]);const M=async()=>{if(!w.trim()){i("Please enter a plugin path","error");return}try{L(!0),await te({path:w,...A?{aiScanOnLoad:!0}:{}},c),i("Plugin installed globally","success"),$(!1),P(""),F(!1),await m()}catch(s){i(`Failed to install plugin: ${s instanceof Error?s.message:String(s)}`,"error")}finally{L(!1)}},ge=async s=>{if(!s.path){i(`${s.name} is built in and does not have an installable package yet`,"warning");return}try{G(s.id),await te({path:s.path},c),i(`${s.name} installed globally`,"success"),await m()}catch(n){i(`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 Fe(s.id,c);if(!n.success){i(`Failed to install ${s.name} setup: ${n.error??"unknown error"}`,"error");return}i(`${s.name} setup installed`,"success"),U(s.id);const o=await Z(s.id,c);E(l=>({...l,[s.id]:o}))}catch(n){i(`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 Be(s.id,c);if(n.state==="error"){i(`Failed to enable ${s.name}: ${n.error??"Unknown error"}`,"error"),await m();return}i(`${s.name} enabled for this project`,"success"),await m()}catch(n){i(`Failed to enable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},H=async s=>{try{await ke(s.id,c),i(`${s.name} disabled for this project`,"success"),await m()}catch(n){i(`Failed to disable plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},W=async s=>{try{D(s.id),await Ee(s.id,c),i(`${s.name} reloaded`,"success"),await m()}catch(n){i(`Failed to reload plugin: ${n instanceof Error?n.message:String(n)}`,"error")}finally{D(null)}},J=async s=>{if(await de({title:"Uninstall Plugin Globally",message:`Are you sure you want to uninstall "${s.name}" globally (all projects)?`,danger:!0}))try{await Le(s.id,c),i(`${s.name} uninstalled globally`,"success"),await m(),R(null)}catch(o){i(`Failed to uninstall plugin: ${o instanceof Error?o.message:String(o)}`,"error")}},me=async(s,n)=>{try{await $e(s.id,{aiScanOnLoad:n},c),i(`AI scan on load ${n?"enabled":"disabled"}`,"success"),await m()}catch(o){i(`Failed to update plugin: ${o instanceof Error?o.message:String(o)}`,"error")}},he=async s=>{try{await Pe(s.id,c),i(`${s.name} rescanned`,"success"),await m()}catch(n){i(`Failed to rescan plugin: ${n instanceof Error?n.message:String(n)}`,"error")}},k=async s=>{R(s);try{z(!0);const n=await Ae(s.id,c);b(n)}catch{b({})}finally{z(!1)}},be=async()=>{if(r)try{await Re(r.id,p,c),i("Settings saved","success")}catch(s){i(`Failed to save settings: ${s instanceof Error?s.message:String(s)}`,"error")}};if(r)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(Y,{size:16})}),e.jsxs("div",{className:"plugin-detail-title",children:[e.jsxs("div",{className:"plugin-detail-title-copy",children:[e.jsx("h4",{className:"plugin-detail-name",children:r.name}),ie(r,"plugin-error-text plugin-error-text--detail")]}),e.jsx("span",{className:"plugin-state-badge",style:{color:I[r.state]||I.installed},children:r.state})]})]}),e.jsxs("div",{className:"plugin-detail-content",children:[e.jsxs("div",{className:"plugin-detail-card",children:[r.description&&e.jsx("p",{className:"plugin-description",children:r.description}),r.author&&e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:"Author:"}),r.author]}),r.homepage&&e.jsxs("p",{className:"plugin-detail-meta-row plugin-homepage",children:[e.jsx("span",{className:"text-muted",children:"Homepage:"}),e.jsxs("a",{href:r.homepage,target:"_blank",rel:"noopener noreferrer",children:[r.homepage,e.jsx(Se,{size:12})]})]}),e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:"Version:"}),r.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:!!r.aiScanOnLoad,onChange:s=>void me(r,s.target.checked)}),"Enable AI scan before load/reload"]}),e.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:()=>void he(r),children:[e.jsx(ve,{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."}),r.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--${r.lastSecurityScan.verdict}`,children:r.lastSecurityScan.verdict}),e.jsx("span",{className:"text-muted",children:r.lastSecurityScan.scannedAt})]}),e.jsx("p",{className:"plugin-security-summary",children:r.lastSecurityScan.summary}),e.jsxs("details",{children:[e.jsxs("summary",{children:["Findings (",r.lastSecurityScan.findings.length,")"]}),e.jsx("ul",{className:"plugin-security-findings",children:r.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"}),ce?e.jsx("p",{className:"text-muted",children:"Loading..."}):(()=>{const s=ze(r);return s&&Object.keys(s).length>0?e.jsxs("div",{className:"plugin-settings-form",children:[(()=>{const{grouped:n,ungrouped:o}=Oe(s),l=[];o.length>0&&l.push({title:null,entries:o});for(const[u,a]of n.entries())l.push({title:u,entries:a});return l.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(Y,{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:be,children:"Save Settings"})]}):e.jsx("p",{className:"text-muted",children:"No configurable settings."})})()]}),e.jsxs("div",{className:"plugin-detail-actions",children:[r.state==="started"&&e.jsxs("button",{className:"btn btn-secondary",onClick:()=>W(r),disabled:S===r.id,children:[e.jsx(ee,{size:14,className:S===r.id?"spin":""}),S===r.id?"Reloading...":"Reload"]}),r.enabled?e.jsx("button",{className:"btn btn-secondary",onClick:()=>H(r),children:"Disable in Project"}):e.jsx("button",{className:"btn btn-primary",onClick:()=>_(r),children:"Enable in Project"}),e.jsxs("button",{className:"btn btn-danger",onClick:()=>J(r),children:[e.jsx(se,{size:14})," Uninstall Globally"]})]})]})]});const xe=new Map(h.map(s=>[s.id,s])),K=h,fe=()=>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=xe.get(s.id),o=!!n,l=oe[s.id],u=!!(l&&"setupCheckDeferred"in l&&l.setupCheckDeferred),a=l&&"status"in l?l.status:void 0,t=o&&s.hasSetup&&l?.hasSetup&&!u&&n?.state==="started"&&(a==="not-installed"||a==="error"),y=o&&l?.hasSetup&&a==="installed",d=ue===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 ${o?"plugin-builtins-status--installed":"plugin-builtins-status--available"}`,children:o?"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?o&&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"}):o&&n?e.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>void k(n),children:"Manage"}):e.jsx("span",{className:"plugin-builtins-metadata-only",children:"Built-in metadata only"}):e.jsx("button",{className:`btn ${o&&!t?"btn-secondary":"btn-primary"} btn-sm`,onClick:()=>{if(!o){ge(s);return}if(t){V(s);return}n&&k(n)},disabled:O===s.id||C===s.id||d,children:o?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(we,{size:14,className:f?"spin":""}),"Refresh"]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>$(!0),children:[e.jsx(T,{size:14})," Install"]})]})]}),re&&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(De,{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(Ce,{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.jsx("div",{className:"plugin-info",children:e.jsxs("div",{className:"plugin-copy",children:[e.jsxs("div",{className:"plugin-copy-header",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})]}),ie(s)]})}),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:()=>k(s),title:"Settings",children:e.jsx(Ie,{size:14})}),e.jsx("button",{className:"btn-icon",onClick:()=>J(s),title:"Uninstall globally",children:e.jsx(se,{size:14})})]})]},s.id))}),fe()]})]})}export{ne as AGENT_BROWSER_SETTINGS_SCHEMA,le as BUILTIN_AGENT_BROWSER_PLUGIN_ID,He as PluginManager,I as STATE_COLORS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e}from"./vendor-react-K0fH_qHe.js";import{aw as ie,ax as le,s as oe,ay as de,az as ue,aA as he,aB as me,aC as be,aD as fe,ah as ve,u as xe,aE as pe,x as ye,aF as ge,L as je,S as Re}from"./index-DiewofJh.js";import"./vendor-xterm-DzcZoU0P.js";const _e="builtin",G={pageFetch:!0,github:!1,localDocs:!0,llmSynthesis:!0};function X(n){const t=n?.researchGlobalDefaults,i=n?.researchSettings;return{enabled:i?.enabled??n?.researchEnabled??n?.researchGlobalEnabled??!0,searchProvider:i?.searchProvider??t?.searchProvider??n?.researchGlobalWebSearchProvider??_e,synthesisProvider:i?.synthesisProvider??t?.synthesisProvider,synthesisModelId:i?.synthesisModelId??t?.synthesisModelId,enabledSources:{webSearch:!0,pageFetch:i?.enabledSources?.pageFetch??t?.enabledSources?.pageFetch??G.pageFetch,github:i?.enabledSources?.github??t?.enabledSources?.github??G.github,localDocs:i?.enabledSources?.localDocs??t?.enabledSources?.localDocs??G.localDocs,llmSynthesis:i?.enabledSources?.llmSynthesis??t?.enabledSources?.llmSynthesis??G.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 Se=300,we=4e3,Ne=["queued","running","cancelling","retry_waiting"];function Z(n,t){if(n instanceof ve){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 ke(n){if(!n)return{cancelable:!1,retryable:!1,isTransitioning:!1,blockingReason:"No run selected"};const t=Ne.includes(n.status),i=n.status==="queued"||n.status==="running",f=n.lifecycle?.retryable,h=n.status==="failed"||n.status==="timed_out",a=!!(h&&f);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"),!a&&h&&f===!1&&(p=n.lifecycle?.errorCode==="RETRY_EXHAUSTED"?"Retry attempts exhausted":"Run is not retryable"),{cancelable:i,retryable:a,isTransitioning:t,blockingReason:p}}function Ee(n){const t=n?.projectId,[i,f]=c.useState([]),[h,a]=c.useState(null),[p,R]=c.useState(null),[g,N]=c.useState({available:!0}),[E,T]=c.useState(!0),[L,P]=c.useState(null),[F,j]=c.useState(null),[_,D]=c.useState(""),C=c.useRef(0),k=c.useRef(0),S=c.useRef(t);c.useEffect(()=>{S.current!==t&&(S.current=t,k.current++)},[t]);const v=c.useCallback(async(l=_)=>{const r=++C.current,o=t;P(null),j(null);try{const y=await ie({q:l||void 0,limit:100},o);if(r!==C.current||o!==t)return;f(y.runs),N(y.availability),h&&!y.runs.some(b=>b.id===h)&&(a(null),R(null))}catch(y){if(r!==C.current||o!==t)return;const b=Z(y,"Failed to load research runs");P(b.message),j(b)}finally{r===C.current&&T(!1)}},[t,_,h]),x=c.useCallback(async l=>{const r=await le(l,t);return R(r.run),N(r.availability),r.run},[t]);return c.useEffect(()=>{T(!0);const l=window.setTimeout(()=>{v(_)},Se);return()=>window.clearTimeout(l)},[v,_]),c.useEffect(()=>{if(!h){R(null);return}x(h)},[x,h]),c.useEffect(()=>{const l=k.current,r=()=>k.current!==l,o=t?`?projectId=${encodeURIComponent(t)}`:"";let y=!0;const b=()=>{!y||r()||(v(),h&&x(h))},M=oe(`/api/events${o}`,{events:{"research:run:created":b,"research:run:updated":b,"research:run:completed":b,"research:run:failed":b,"research:run:cancelled":b},onReconnect:b}),O=window.setInterval(b,we);return()=>{y=!1,M(),window.clearInterval(O)}},[t,v,h,x]),{runs:i,selectedRun:p,selectedRunId:h,setSelectedRunId:a,availability:g,loading:E,error:L,searchQuery:_,setSearchQuery:D,refresh:v,createRun:l=>fe(l,t),cancelRun:async l=>{try{j(null);const r=await be(l,t);return h===l&&R(r.run),await v(),r}catch(r){const o=Z(r,"Failed to cancel run");throw j(o),o}},retryRun:async l=>{try{j(null);const r=await me(l,t);return h===l&&R(r.run),await v(),r}catch(r){const o=Z(r,"Failed to retry run");throw j(o),o}},exportRun:(l,r)=>he(l,r,t),createTaskFromRun:(l,r,o,y,b,M)=>ue(l,{title:r,findingId:o,description:y,priority:b,attachExport:M},t),attachRunToTask:(l,r,o,y)=>de(l,{taskId:r,findingId:o,attachExport:y},t),uiError:F,runActionState:ke(p),statusCounts:i.reduce((l,r)=>(l[r.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 Ce({open:n,mode:t,run:i,finding:f,projectId:h,onClose:a,onConfirm:p}){xe(n);const[R,g]=c.useState(!1),[N,E]=c.useState(""),[T,L]=c.useState(""),[P,F]=c.useState("normal"),[j,_]=c.useState(""),[D,C]=c.useState([]),[k,S]=c.useState(!1),[v,x]=c.useState(!1),l=c.useMemo(()=>{const r=(f.content??"").split(/(?<=[.!?])\s+/)[0]??"";return`${f.heading||"Research finding"} — ${r}`.trim()},[f.content,f.heading]);return c.useEffect(()=>{n&&(g(!1),E(`Research: ${f.heading||i.title}`),L(l),F("normal"),_(""),t==="enrich"&&(S(!0),pe(50,0,h).then(r=>C(r.filter(o=>o.column!=="archived"))).finally(()=>S(!1))))},[n,t,h,f.heading,l,i.title]),n?e.jsx("div",{className:"modal-overlay open",role:"presentation",onClick:a,children:e.jsxs("div",{className:"modal modal-lg research-task-action-modal",role:"dialog","aria-modal":"true",onClick:r=>r.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:a,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:"})," ",f.id,f.heading?` — ${f.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:N,onChange:r=>E(r.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:["Description",e.jsx("textarea",{className:"input research-task-action-modal__textarea",value:T,onChange:r=>L(r.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:["Priority",e.jsxs("select",{className:"select",value:P,onChange:r=>F(r.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:k?"Loading tasks…":"Enter task ID",onChange:r=>_(r.target.value)}),e.jsx("datalist",{id:"research-task-action-task-list",children:D.map(r=>e.jsx("option",{value:r.id,children:r.title},r.id))})]}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:R,onChange:r=>g(r.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:a,children:"Cancel"}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:v||t==="enrich"&&!j,onClick:()=>{x(!0),p({taskId:t==="enrich"?j:void 0,title:t==="create"?N.trim():void 0,description:t==="create"?T.trim():void 0,priority:t==="create"?P:void 0,attachExport:R}).finally(()=>x(!1))},children:t==="create"?"Create Task":"Enrich Task"})]})]})}):null}const Te=["web-search","page-fetch","github","local-docs","llm-synthesis"],Pe={"web-search":"webSearch","page-fetch":"pageFetch",github:"github","local-docs":"localDocs","llm-synthesis":"llmSynthesis"},Ae={"web-search":"Web Search","page-fetch":"Page Fetch",github:"GitHub","local-docs":"Local Docs","llm-synthesis":"LLM Synthesis"};function Me({projectId:n,addToast:t,onOpenSettings:i,readinessVersion:f=0}){const{runs:h,selectedRun:a,selectedRunId:p,setSelectedRunId:R,availability:g,loading:N,error:E,searchQuery:T,setSearchQuery:L,createRun:P,cancelRun:F,retryRun:j,exportRun:_,createTaskFromRun:D,attachRunToTask:C,statusCounts:k,refresh:S,uiError:v,runActionState:x}=Ee({projectId:n}),[l,r]=c.useState(""),[o,y]=c.useState(()=>X(void 0)),[b,M]=c.useState([]),[O,V]=c.useState(!1),[ee,se]=c.useState([]),[A,U]=c.useState(null),[I,$]=c.useState(null),B=g.supportedProviders??Te,z=o.searchProvider,Q=s=>s==="web-search"?!0:o.enabledSources[Pe[s]];c.useEffect(()=>{const s=B.filter(d=>Q(d));se(d=>{const m=d.filter(u=>s.includes(u));return m.length>0?m:s})},[o.enabledSources,B]),c.useEffect(()=>{let s=!1;return Promise.all([ye(n),ge().catch(()=>({providers:[]}))]).then(([d,m])=>{s||(y(X(d)),M(m.providers.filter(u=>u.type==="api_key").map(u=>({id:u.id,authenticated:u.authenticated}))))}).catch(()=>{s||y(X(void 0))}),()=>{s=!0}},[n,f]);const ae=c.useMemo(()=>a?a.status:"No run selected",[a]),ne=c.useMemo(()=>a?a.status==="queued"||a.status==="retry_waiting"?"status-dot status-dot--pending":a.status==="running"?"status-dot status-dot--connecting":a.status==="completed"?"status-dot status-dot--online":a.status==="failed"||a.status==="cancelled"?"status-dot status-dot--error":"status-dot":"status-dot",[a]),K=g.supportedExportFormats??["markdown","json","html"],W=c.useMemo(()=>new Map(b.map(s=>[s.id,s.authenticated])),[b]),Y=c.useMemo(()=>{const s=new Set;return o.enabledSources.webSearch&&z&&s.add(z),o.enabledSources.llmSynthesis&&o.synthesisProvider&&s.add(o.synthesisProvider),[...s].filter(d=>W.has(d))},[o.enabledSources.llmSynthesis,o.enabledSources.webSearch,o.synthesisProvider,z,W]).find(s=>W.get(s)!==!0),q=c.useMemo(()=>g.available?o.enabled?Y?{reason:`Missing API key for ${Y}.`,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,Y]),H=async(s,d,m)=>{U(s);try{await d(),t?.(m,"success"),await S()}catch(u){t?.(u instanceof Error?u.message:"Action failed","error")}finally{U(null)}},J=async s=>{if(a){U(`export-${s}`);try{const d=await _(a.id,s),m=new Blob([d.content],{type:"text/plain;charset=utf-8"}),u=URL.createObjectURL(m),w=document.createElement("a");w.href=u,w.download=d.filename,document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(u),t?.(`Exported ${d.filename}`,"success")}catch(d){t?.(d instanceof Error?d.message:"Export failed","error")}finally{U(null)}}},ce=async()=>{if(l.trim()){V(!0);try{const s=ee.filter(m=>Q(m));if(s.length===0){V(!1),t?.("No enabled research sources are available for this project.","error");return}const d=await P({query:l.trim(),providers:s});R(d.run.id),r(""),t?.("Research run created","success"),await S()}catch(s){t?.(s instanceof Error?s.message:"Failed to create run","error")}finally{V(!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"})]}),q?e.jsxs("div",{className:"research-view__state research-view__state--error card","data-testid":"research-state-unavailable",children:[e.jsx("p",{children:q.reason}),q.details&&e.jsx("p",{children:q.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?.(q.settingsSection),children:"Open Settings"})]})]}):e.jsx(e.Fragment,{children: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=>r(s.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Providers"}),e.jsx("div",{className:"research-view__providers",children:B.map(s=>{const d=Q(s),m=s==="web-search";return e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:m||ee.includes(s),disabled:m||!d,onChange:()=>{m||!d||se(u=>u.includes(s)?u.filter(w=>w!==s):[...u,s])}}),e.jsxs("span",{children:[Ae[s]??s,m?e.jsx("span",{className:"research-view__provider-lock",children:"Always on"}):null]})]},s)})})]}),e.jsxs("button",{className:"btn btn-primary",type:"button",disabled:!l.trim()||O,onClick:()=>void ce(),children:[O?e.jsx(je,{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(Re,{size:14}),e.jsx("input",{id:"research-run-search",className:"input",placeholder:"Search runs",value:T,onChange:s=>L(s.target.value)})]})]}),e.jsx("div",{className:"research-view__history","data-testid":"research-state-running",children:h.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:[N&&e.jsx("p",{"data-testid":"research-state-loading",children:"Loading research runs…"}),!N&&E&&e.jsx("p",{"data-testid":"research-state-error",children:E}),!N&&!E&&h.length===0&&e.jsx("p",{"data-testid":"research-state-empty",children:"No research runs yet"}),e.jsxs("div",{className:"research-view__reader-content",children:[a&&e.jsxs("div",{className:"research-view__run-detail",children:[e.jsxs("div",{className:"research-view__status-row",children:[e.jsx("span",{className:ne}),e.jsx("strong",{children:ae})]}),e.jsx("h3",{className:"research-view__run-title",children:a.title}),e.jsx("p",{className:"research-view__run-query",children:a.query}),e.jsx("p",{className:"research-view__run-summary","data-testid":"research-state-results",children:a.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 H("cancel",()=>F(a.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 H("retry",()=>j(a.id),"Run retried"),children:"Retry"}),K.includes("markdown")&&e.jsx("button",{className:"btn",type:"button",disabled:A==="export-markdown",onClick:()=>void J("markdown"),children:"Export MD"}),K.includes("json")&&e.jsx("button",{className:"btn",type:"button",disabled:A==="export-json",onClick:()=>void J("json"),children:"Export JSON"}),K.includes("html")&&e.jsx("button",{className:"btn",type:"button",disabled:A==="export-html",onClick:()=>void J("html"),children:"Export HTML"})]}),a.error&&e.jsx("p",{className:"research-view__error",children:a.error}),v&&e.jsxs("div",{className:"form-error",role:"alert",children:[e.jsx("p",{children:v.message}),v.setupHint&&e.jsx("p",{children:v.setupHint}),v.code==="MISSING_CREDENTIALS"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>i?.("authentication"),children:"Open Authentication Settings"}),v.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(a.results?.findings)&&a.results.findings.length>0&&e.jsx("div",{className:"research-view__findings",children:a.results.findings.map((s,d)=>{const u=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:u}),children:"Create Task"}),e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>$({mode:"enrich",findingId:u}),children:"Enrich Task"})]})]},u)})}),Array.isArray(a.results?.citations)&&a.results.citations.length>0&&e.jsx("ul",{className:"research-view__citations",children:a.results.citations.map(s=>e.jsx("li",{children:e.jsx("a",{href:s,target:"_blank",rel:"noreferrer",children:s})},s))}),a.events.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:"Run history"}),e.jsx("ul",{className:"research-view__events",children:a.events.map(s=>e.jsx("li",{children:s.message},s.id))})]})]}),!a&&h.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:k.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:k.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:k.failed})]})]})]})]})]})}),a&&I&&(()=>{const s=a.results?.findings?.findIndex((m,u)=>(m.id?.trim()||`finding-${u+1}`)===I.findingId)??-1,d=s>=0?a.results.findings[s]:null;return d?e.jsx(Ce,{open:!0,mode:I.mode,run:a,finding:{id:I.findingId,heading:d.heading,content:d.content},projectId:n,onClose:()=>$(null),onConfirm:async({taskId:m,title:u,description:w,priority:te,attachExport:re})=>{I.mode==="create"?await H("create-task",()=>D(a.id,u,I.findingId,w,te,re),"Task created from research"):m&&await H("attach-task",()=>C(a.id,m,I.findingId,re),"Task enriched from research"),$(null)}}):null})()]})}export{Me as ResearchView};
|
|
1
|
+
import{r as c,j as e}from"./vendor-react-K0fH_qHe.js";import{aw as ie,ax as le,s as oe,ay as de,az as ue,aA as he,aB as me,aC as be,aD as fe,ah as ve,u as xe,aE as pe,x as ye,aF as ge,L as je,S as Re}from"./index-u6AOHWO5.js";import"./vendor-xterm-DzcZoU0P.js";const _e="builtin",G={pageFetch:!0,github:!1,localDocs:!0,llmSynthesis:!0};function X(n){const t=n?.researchGlobalDefaults,i=n?.researchSettings;return{enabled:i?.enabled??n?.researchEnabled??n?.researchGlobalEnabled??!0,searchProvider:i?.searchProvider??t?.searchProvider??n?.researchGlobalWebSearchProvider??_e,synthesisProvider:i?.synthesisProvider??t?.synthesisProvider,synthesisModelId:i?.synthesisModelId??t?.synthesisModelId,enabledSources:{webSearch:!0,pageFetch:i?.enabledSources?.pageFetch??t?.enabledSources?.pageFetch??G.pageFetch,github:i?.enabledSources?.github??t?.enabledSources?.github??G.github,localDocs:i?.enabledSources?.localDocs??t?.enabledSources?.localDocs??G.localDocs,llmSynthesis:i?.enabledSources?.llmSynthesis??t?.enabledSources?.llmSynthesis??G.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 Se=300,we=4e3,Ne=["queued","running","cancelling","retry_waiting"];function Z(n,t){if(n instanceof ve){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 ke(n){if(!n)return{cancelable:!1,retryable:!1,isTransitioning:!1,blockingReason:"No run selected"};const t=Ne.includes(n.status),i=n.status==="queued"||n.status==="running",f=n.lifecycle?.retryable,h=n.status==="failed"||n.status==="timed_out",a=!!(h&&f);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"),!a&&h&&f===!1&&(p=n.lifecycle?.errorCode==="RETRY_EXHAUSTED"?"Retry attempts exhausted":"Run is not retryable"),{cancelable:i,retryable:a,isTransitioning:t,blockingReason:p}}function Ee(n){const t=n?.projectId,[i,f]=c.useState([]),[h,a]=c.useState(null),[p,R]=c.useState(null),[g,N]=c.useState({available:!0}),[E,T]=c.useState(!0),[L,P]=c.useState(null),[F,j]=c.useState(null),[_,D]=c.useState(""),C=c.useRef(0),k=c.useRef(0),S=c.useRef(t);c.useEffect(()=>{S.current!==t&&(S.current=t,k.current++)},[t]);const v=c.useCallback(async(l=_)=>{const r=++C.current,o=t;P(null),j(null);try{const y=await ie({q:l||void 0,limit:100},o);if(r!==C.current||o!==t)return;f(y.runs),N(y.availability),h&&!y.runs.some(b=>b.id===h)&&(a(null),R(null))}catch(y){if(r!==C.current||o!==t)return;const b=Z(y,"Failed to load research runs");P(b.message),j(b)}finally{r===C.current&&T(!1)}},[t,_,h]),x=c.useCallback(async l=>{const r=await le(l,t);return R(r.run),N(r.availability),r.run},[t]);return c.useEffect(()=>{T(!0);const l=window.setTimeout(()=>{v(_)},Se);return()=>window.clearTimeout(l)},[v,_]),c.useEffect(()=>{if(!h){R(null);return}x(h)},[x,h]),c.useEffect(()=>{const l=k.current,r=()=>k.current!==l,o=t?`?projectId=${encodeURIComponent(t)}`:"";let y=!0;const b=()=>{!y||r()||(v(),h&&x(h))},M=oe(`/api/events${o}`,{events:{"research:run:created":b,"research:run:updated":b,"research:run:completed":b,"research:run:failed":b,"research:run:cancelled":b},onReconnect:b}),O=window.setInterval(b,we);return()=>{y=!1,M(),window.clearInterval(O)}},[t,v,h,x]),{runs:i,selectedRun:p,selectedRunId:h,setSelectedRunId:a,availability:g,loading:E,error:L,searchQuery:_,setSearchQuery:D,refresh:v,createRun:l=>fe(l,t),cancelRun:async l=>{try{j(null);const r=await be(l,t);return h===l&&R(r.run),await v(),r}catch(r){const o=Z(r,"Failed to cancel run");throw j(o),o}},retryRun:async l=>{try{j(null);const r=await me(l,t);return h===l&&R(r.run),await v(),r}catch(r){const o=Z(r,"Failed to retry run");throw j(o),o}},exportRun:(l,r)=>he(l,r,t),createTaskFromRun:(l,r,o,y,b,M)=>ue(l,{title:r,findingId:o,description:y,priority:b,attachExport:M},t),attachRunToTask:(l,r,o,y)=>de(l,{taskId:r,findingId:o,attachExport:y},t),uiError:F,runActionState:ke(p),statusCounts:i.reduce((l,r)=>(l[r.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 Ce({open:n,mode:t,run:i,finding:f,projectId:h,onClose:a,onConfirm:p}){xe(n);const[R,g]=c.useState(!1),[N,E]=c.useState(""),[T,L]=c.useState(""),[P,F]=c.useState("normal"),[j,_]=c.useState(""),[D,C]=c.useState([]),[k,S]=c.useState(!1),[v,x]=c.useState(!1),l=c.useMemo(()=>{const r=(f.content??"").split(/(?<=[.!?])\s+/)[0]??"";return`${f.heading||"Research finding"} — ${r}`.trim()},[f.content,f.heading]);return c.useEffect(()=>{n&&(g(!1),E(`Research: ${f.heading||i.title}`),L(l),F("normal"),_(""),t==="enrich"&&(S(!0),pe(50,0,h).then(r=>C(r.filter(o=>o.column!=="archived"))).finally(()=>S(!1))))},[n,t,h,f.heading,l,i.title]),n?e.jsx("div",{className:"modal-overlay open",role:"presentation",onClick:a,children:e.jsxs("div",{className:"modal modal-lg research-task-action-modal",role:"dialog","aria-modal":"true",onClick:r=>r.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:a,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:"})," ",f.id,f.heading?` — ${f.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:N,onChange:r=>E(r.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:["Description",e.jsx("textarea",{className:"input research-task-action-modal__textarea",value:T,onChange:r=>L(r.target.value)})]}),e.jsxs("label",{className:"research-task-action-modal__field",children:["Priority",e.jsxs("select",{className:"select",value:P,onChange:r=>F(r.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:k?"Loading tasks…":"Enter task ID",onChange:r=>_(r.target.value)}),e.jsx("datalist",{id:"research-task-action-task-list",children:D.map(r=>e.jsx("option",{value:r.id,children:r.title},r.id))})]}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:R,onChange:r=>g(r.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:a,children:"Cancel"}),e.jsx("button",{className:"btn btn-primary",type:"button",disabled:v||t==="enrich"&&!j,onClick:()=>{x(!0),p({taskId:t==="enrich"?j:void 0,title:t==="create"?N.trim():void 0,description:t==="create"?T.trim():void 0,priority:t==="create"?P:void 0,attachExport:R}).finally(()=>x(!1))},children:t==="create"?"Create Task":"Enrich Task"})]})]})}):null}const Te=["web-search","page-fetch","github","local-docs","llm-synthesis"],Pe={"web-search":"webSearch","page-fetch":"pageFetch",github:"github","local-docs":"localDocs","llm-synthesis":"llmSynthesis"},Ae={"web-search":"Web Search","page-fetch":"Page Fetch",github:"GitHub","local-docs":"Local Docs","llm-synthesis":"LLM Synthesis"};function Me({projectId:n,addToast:t,onOpenSettings:i,readinessVersion:f=0}){const{runs:h,selectedRun:a,selectedRunId:p,setSelectedRunId:R,availability:g,loading:N,error:E,searchQuery:T,setSearchQuery:L,createRun:P,cancelRun:F,retryRun:j,exportRun:_,createTaskFromRun:D,attachRunToTask:C,statusCounts:k,refresh:S,uiError:v,runActionState:x}=Ee({projectId:n}),[l,r]=c.useState(""),[o,y]=c.useState(()=>X(void 0)),[b,M]=c.useState([]),[O,V]=c.useState(!1),[ee,se]=c.useState([]),[A,U]=c.useState(null),[I,$]=c.useState(null),B=g.supportedProviders??Te,z=o.searchProvider,Q=s=>s==="web-search"?!0:o.enabledSources[Pe[s]];c.useEffect(()=>{const s=B.filter(d=>Q(d));se(d=>{const m=d.filter(u=>s.includes(u));return m.length>0?m:s})},[o.enabledSources,B]),c.useEffect(()=>{let s=!1;return Promise.all([ye(n),ge().catch(()=>({providers:[]}))]).then(([d,m])=>{s||(y(X(d)),M(m.providers.filter(u=>u.type==="api_key").map(u=>({id:u.id,authenticated:u.authenticated}))))}).catch(()=>{s||y(X(void 0))}),()=>{s=!0}},[n,f]);const ae=c.useMemo(()=>a?a.status:"No run selected",[a]),ne=c.useMemo(()=>a?a.status==="queued"||a.status==="retry_waiting"?"status-dot status-dot--pending":a.status==="running"?"status-dot status-dot--connecting":a.status==="completed"?"status-dot status-dot--online":a.status==="failed"||a.status==="cancelled"?"status-dot status-dot--error":"status-dot":"status-dot",[a]),K=g.supportedExportFormats??["markdown","json","html"],W=c.useMemo(()=>new Map(b.map(s=>[s.id,s.authenticated])),[b]),Y=c.useMemo(()=>{const s=new Set;return o.enabledSources.webSearch&&z&&s.add(z),o.enabledSources.llmSynthesis&&o.synthesisProvider&&s.add(o.synthesisProvider),[...s].filter(d=>W.has(d))},[o.enabledSources.llmSynthesis,o.enabledSources.webSearch,o.synthesisProvider,z,W]).find(s=>W.get(s)!==!0),q=c.useMemo(()=>g.available?o.enabled?Y?{reason:`Missing API key for ${Y}.`,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,Y]),H=async(s,d,m)=>{U(s);try{await d(),t?.(m,"success"),await S()}catch(u){t?.(u instanceof Error?u.message:"Action failed","error")}finally{U(null)}},J=async s=>{if(a){U(`export-${s}`);try{const d=await _(a.id,s),m=new Blob([d.content],{type:"text/plain;charset=utf-8"}),u=URL.createObjectURL(m),w=document.createElement("a");w.href=u,w.download=d.filename,document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(u),t?.(`Exported ${d.filename}`,"success")}catch(d){t?.(d instanceof Error?d.message:"Export failed","error")}finally{U(null)}}},ce=async()=>{if(l.trim()){V(!0);try{const s=ee.filter(m=>Q(m));if(s.length===0){V(!1),t?.("No enabled research sources are available for this project.","error");return}const d=await P({query:l.trim(),providers:s});R(d.run.id),r(""),t?.("Research run created","success"),await S()}catch(s){t?.(s instanceof Error?s.message:"Failed to create run","error")}finally{V(!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"})]}),q?e.jsxs("div",{className:"research-view__state research-view__state--error card","data-testid":"research-state-unavailable",children:[e.jsx("p",{children:q.reason}),q.details&&e.jsx("p",{children:q.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?.(q.settingsSection),children:"Open Settings"})]})]}):e.jsx(e.Fragment,{children: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=>r(s.target.value)})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Providers"}),e.jsx("div",{className:"research-view__providers",children:B.map(s=>{const d=Q(s),m=s==="web-search";return e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:m||ee.includes(s),disabled:m||!d,onChange:()=>{m||!d||se(u=>u.includes(s)?u.filter(w=>w!==s):[...u,s])}}),e.jsxs("span",{children:[Ae[s]??s,m?e.jsx("span",{className:"research-view__provider-lock",children:"Always on"}):null]})]},s)})})]}),e.jsxs("button",{className:"btn btn-primary",type:"button",disabled:!l.trim()||O,onClick:()=>void ce(),children:[O?e.jsx(je,{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(Re,{size:14}),e.jsx("input",{id:"research-run-search",className:"input",placeholder:"Search runs",value:T,onChange:s=>L(s.target.value)})]})]}),e.jsx("div",{className:"research-view__history","data-testid":"research-state-running",children:h.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:[N&&e.jsx("p",{"data-testid":"research-state-loading",children:"Loading research runs…"}),!N&&E&&e.jsx("p",{"data-testid":"research-state-error",children:E}),!N&&!E&&h.length===0&&e.jsx("p",{"data-testid":"research-state-empty",children:"No research runs yet"}),e.jsxs("div",{className:"research-view__reader-content",children:[a&&e.jsxs("div",{className:"research-view__run-detail",children:[e.jsxs("div",{className:"research-view__status-row",children:[e.jsx("span",{className:ne}),e.jsx("strong",{children:ae})]}),e.jsx("h3",{className:"research-view__run-title",children:a.title}),e.jsx("p",{className:"research-view__run-query",children:a.query}),e.jsx("p",{className:"research-view__run-summary","data-testid":"research-state-results",children:a.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 H("cancel",()=>F(a.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 H("retry",()=>j(a.id),"Run retried"),children:"Retry"}),K.includes("markdown")&&e.jsx("button",{className:"btn",type:"button",disabled:A==="export-markdown",onClick:()=>void J("markdown"),children:"Export MD"}),K.includes("json")&&e.jsx("button",{className:"btn",type:"button",disabled:A==="export-json",onClick:()=>void J("json"),children:"Export JSON"}),K.includes("html")&&e.jsx("button",{className:"btn",type:"button",disabled:A==="export-html",onClick:()=>void J("html"),children:"Export HTML"})]}),a.error&&e.jsx("p",{className:"research-view__error",children:a.error}),v&&e.jsxs("div",{className:"form-error",role:"alert",children:[e.jsx("p",{children:v.message}),v.setupHint&&e.jsx("p",{children:v.setupHint}),v.code==="MISSING_CREDENTIALS"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>i?.("authentication"),children:"Open Authentication Settings"}),v.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(a.results?.findings)&&a.results.findings.length>0&&e.jsx("div",{className:"research-view__findings",children:a.results.findings.map((s,d)=>{const u=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:u}),children:"Create Task"}),e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>$({mode:"enrich",findingId:u}),children:"Enrich Task"})]})]},u)})}),Array.isArray(a.results?.citations)&&a.results.citations.length>0&&e.jsx("ul",{className:"research-view__citations",children:a.results.citations.map(s=>e.jsx("li",{children:e.jsx("a",{href:s,target:"_blank",rel:"noreferrer",children:s})},s))}),a.events.length>0&&e.jsxs("details",{children:[e.jsx("summary",{children:"Run history"}),e.jsx("ul",{className:"research-view__events",children:a.events.map(s=>e.jsx("li",{children:s.message},s.id))})]})]}),!a&&h.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:k.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:k.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:k.failed})]})]})]})]})]})}),a&&I&&(()=>{const s=a.results?.findings?.findIndex((m,u)=>(m.id?.trim()||`finding-${u+1}`)===I.findingId)??-1,d=s>=0?a.results.findings[s]:null;return d?e.jsx(Ce,{open:!0,mode:I.mode,run:a,finding:{id:I.findingId,heading:d.heading,content:d.content},projectId:n,onClose:()=>$(null),onConfirm:async({taskId:m,title:u,description:w,priority:te,attachExport:re})=>{I.mode==="create"?await H("create-task",()=>D(a.id,u,I.findingId,w,te,re),"Task created from research"):m&&await H("attach-task",()=>C(a.id,m,I.findingId,re),"Task enriched from research"),$(null)}}):null})()]})}export{Me as ResearchView};
|