@runfusion/fusion 0.30.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/bin.js +72183 -52586
  2. package/dist/client/.vite/manifest.json +549 -0
  3. package/dist/client/assets/{AgentDetailView-Cu4TgvBn.js → AgentDetailView-CnFf_eBZ.js} +3 -3
  4. package/dist/client/assets/AgentPermissionPolicyEditor-CGxjOr6G.css +1 -0
  5. package/dist/client/assets/AgentPermissionPolicyEditor-Cmkt9Z01.js +6 -0
  6. package/dist/client/assets/{AgentsView-CIH4Acck.js → AgentsView-LkVv9hph.js} +3 -3
  7. package/dist/client/assets/ChatView-DYjECCRG.js +1 -0
  8. package/dist/client/assets/{DevServerView-Bd8JZ-3C.js → DevServerView-D7legPr1.js} +1 -1
  9. package/dist/client/assets/{DevServerView-DlZpuAnj.css → DevServerView-VTQY28P7.css} +1 -1
  10. package/dist/client/assets/{DirectoryPicker-BOGqZNiq.js → DirectoryPicker-DctpCNrd.js} +1 -1
  11. package/dist/client/assets/DocumentsView-DORp5JjC.js +1 -0
  12. package/dist/client/assets/EvalsView-CYVJ1pbc.js +1 -0
  13. package/dist/client/assets/{ExperimentalAgentOnboardingModal-BM7EnSvJ.js → ExperimentalAgentOnboardingModal-BULVNAiq.js} +1 -1
  14. package/dist/client/assets/GoalsView-Cg136Jcn.css +1 -0
  15. package/dist/client/assets/GoalsView-bmpZKOI_.js +1 -0
  16. package/dist/client/assets/{InsightsView-B0J4mhzV.css → InsightsView-C9-mqVvf.css} +1 -1
  17. package/dist/client/assets/InsightsView-mmtem0RU.js +11 -0
  18. package/dist/client/assets/{MemoryView-CE1D9euM.js → MemoryView-HVpO1fCH.js} +2 -2
  19. package/dist/client/assets/{NodesView-Zxusnhxu.js → NodesView-CM0eoCP8.js} +3 -3
  20. package/dist/client/assets/{PiExtensionsManager-BlMmxtLZ.js → PiExtensionsManager-Cyfas2VT.js} +2 -2
  21. package/dist/client/assets/{PluginManager-D4eZ0zA4.js → PluginManager-C7QDE3Lk.js} +1 -1
  22. package/dist/client/assets/ReliabilityView-C1C1j1SD.js +1 -0
  23. package/dist/client/assets/ReliabilityView-D9AsVv5l.css +1 -0
  24. package/dist/client/assets/ResearchView-Bn2WxwnQ.js +1 -0
  25. package/dist/client/assets/SecretsView-BFhVwJu6.css +1 -0
  26. package/dist/client/assets/SecretsView-DgrrgzFc.js +1 -0
  27. package/dist/client/assets/SettingsModal-BCZrCLl3.js +31 -0
  28. package/dist/client/assets/{SettingsModal-sp7SNwS9.css → SettingsModal-BZBV2kLr.css} +1 -1
  29. package/dist/client/assets/{SettingsModal-BAx4gt2A.css → SettingsModal-DZrJ5PFH.css} +1 -1
  30. package/dist/client/assets/{SettingsModal-DRnZ6eBW.js → SettingsModal-YCJM5is3.js} +1 -1
  31. package/dist/client/assets/{SetupWizardModal-BmmRM3g-.js → SetupWizardModal-BT-mj3VD.js} +1 -1
  32. package/dist/client/assets/{SkillsView-DWVtT2-8.js → SkillsView-Db7dYpqd.js} +1 -1
  33. package/dist/client/assets/{StashRecoveryView-CKkaWzzc.js → StashRecoveryView-CSYYcWux.js} +1 -1
  34. package/dist/client/assets/TodoView-zqCqfy26.js +6 -0
  35. package/dist/client/assets/dashboard-view-PpcsMDvN.js +21 -0
  36. package/dist/client/assets/{folder-open-BTN2_Wuv.js → folder-open-mxsFQlAX.js} +1 -1
  37. package/dist/client/assets/index-Ba-F8c1g.js +732 -0
  38. package/dist/client/assets/index-D4HhaIOp.css +1 -0
  39. package/dist/client/assets/{upload-euJEs_N2.js → upload-j7JjaJzG.js} +1 -1
  40. package/dist/client/assets/{users-B7miEHCZ.js → users-DZ_0WcB6.js} +1 -1
  41. package/dist/client/index.html +15 -27
  42. package/dist/client/version.json +1 -1
  43. package/dist/droid-cli/package.json +1 -1
  44. package/dist/extension.js +52863 -36171
  45. package/dist/pi-claude-cli/package.json +1 -1
  46. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  47. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  48. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  49. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  50. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  51. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  52. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  53. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  54. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  55. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  56. package/package.json +1 -1
  57. package/skill/fusion/SKILL.md +2 -2
  58. package/skill/fusion/references/cli-commands.md +1 -1
  59. package/skill/fusion/references/engine-tools.md +1 -0
  60. package/skill/fusion/references/extension-tools.md +23 -2
  61. package/skill/fusion/references/fusion-capabilities.md +4 -2
  62. package/skill/fusion/workflows/task-management.md +1 -1
  63. package/dist/client/assets/AgentPermissionPolicyEditor-Ceg2Dszn.js +0 -6
  64. package/dist/client/assets/AgentPermissionPolicyEditor-CthjqUL_.css +0 -1
  65. package/dist/client/assets/ChatView-DqJoFquZ.js +0 -1
  66. package/dist/client/assets/DocumentsView-B-ELcw4o.js +0 -1
  67. package/dist/client/assets/EvalsView-Ccl9QBYN.js +0 -1
  68. package/dist/client/assets/InsightsView-DLF49bzu.js +0 -11
  69. package/dist/client/assets/ReliabilityView-KmH60I_5.js +0 -1
  70. package/dist/client/assets/ReliabilityView-rxA_HgEG.css +0 -1
  71. package/dist/client/assets/ResearchView-C14Zh7c9.js +0 -1
  72. package/dist/client/assets/SettingsModal-c1QwWno0.js +0 -31
  73. package/dist/client/assets/TodoView-hbD0NOCY.js +0 -6
  74. package/dist/client/assets/dashboard-view-VNPB3ca0.js +0 -21
  75. package/dist/client/assets/index-CZFBq256.css +0 -1
  76. package/dist/client/assets/index-DzSLVOnp.js +0 -695
@@ -1 +0,0 @@
1
- import{r as i,j as e}from"./vendor-react-K0fH_qHe.js";import{ax as ce,ay as le,s as oe,az as de,aA as ue,aB as he,aC as me,aD as be,aE as fe,ai as ve,u as xe,aF as pe,x as ye,aG as je,L as ge,S as _e}from"./index-DzSLVOnp.js";import"./vendor-xterm-DzcZoU0P.js";import"./vendor-codemirror-jBKmHyH0.js";const Re="builtin",H={pageFetch:!0,github:!1,localDocs:!0,llmSynthesis:!0};function X(n){const t=n?.researchGlobalDefaults,c=n?.researchSettings;return{enabled:c?.enabled??n?.researchEnabled??n?.researchGlobalEnabled??!0,searchProvider:c?.searchProvider??t?.searchProvider??n?.researchGlobalWebSearchProvider??Re,synthesisProvider:c?.synthesisProvider??t?.synthesisProvider,synthesisModelId:c?.synthesisModelId??t?.synthesisModelId,enabledSources:{webSearch:!0,pageFetch:c?.enabledSources?.pageFetch??t?.enabledSources?.pageFetch??H.pageFetch,github:c?.enabledSources?.github??t?.enabledSources?.github??H.github,localDocs:c?.enabledSources?.localDocs??t?.enabledSources?.localDocs??H.localDocs,llmSynthesis:c?.enabledSources?.llmSynthesis??t?.enabledSources?.llmSynthesis??H.llmSynthesis},limits:{maxConcurrentRuns:c?.limits?.maxConcurrentRuns??n?.researchMaxConcurrentRuns??n?.researchGlobalMaxConcurrentRuns??3,maxSourcesPerRun:c?.limits?.maxSourcesPerRun??t?.maxSourcesPerRun??n?.researchMaxSourcesPerRun??n?.researchGlobalMaxSourcesPerRun??20,maxDurationMs:c?.limits?.maxDurationMs??n?.researchDefaultTimeout??n?.researchGlobalDefaultTimeout??3e5,requestTimeoutMs:c?.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 c=n;return{message:n.message,status:n.status,code:c.researchCode??"INTERNAL_ERROR",setupHint:c.setupHint,retryable:c.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),c=n.status==="queued"||n.status==="running",f=n.lifecycle?.retryable,h=n.status==="failed"||n.status==="timed_out",a=!!(h&&f);let p;return!c&&t?p="Run is already transitioning":!c&&n.status==="completed"?p="Completed runs cannot be cancelled":!c&&n.status==="cancelled"?p="Run is already cancelled":!c&&n.status==="retry_exhausted"?p="Retry attempts exhausted":!c&&n.status==="failed"?p="Failed runs cannot be cancelled":!c&&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:c,retryable:a,isTransitioning:t,blockingReason:p}}function Ee(n){const t=n?.projectId,[c,f]=i.useState([]),[h,a]=i.useState(null),[p,_]=i.useState(null),[j,N]=i.useState({available:!0}),[E,T]=i.useState(!0),[L,P]=i.useState(null),[F,g]=i.useState(null),[R,D]=i.useState(""),C=i.useRef(0),k=i.useRef(0),S=i.useRef(t);i.useEffect(()=>{S.current!==t&&(S.current=t,k.current++)},[t]);const v=i.useCallback(async(l=R)=>{const r=++C.current,o=t;P(null),g(null);try{const y=await ce({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),_(null))}catch(y){if(r!==C.current||o!==t)return;const b=Z(y,"Failed to load research runs");P(b.message),g(b)}finally{r===C.current&&T(!1)}},[t,R,h]),x=i.useCallback(async l=>{const r=await le(l,t);return _(r.run),N(r.availability),r.run},[t]);return i.useEffect(()=>{T(!0);const l=window.setTimeout(()=>{v(R)},Se);return()=>window.clearTimeout(l)},[v,R]),i.useEffect(()=>{if(!h){_(null);return}x(h)},[x,h]),i.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:c,selectedRun:p,selectedRunId:h,setSelectedRunId:a,availability:j,loading:E,error:L,searchQuery:R,setSearchQuery:D,refresh:v,createRun:l=>fe(l,t),cancelRun:async l=>{try{g(null);const r=await be(l,t);return h===l&&_(r.run),await v(),r}catch(r){const o=Z(r,"Failed to cancel run");throw g(o),o}},retryRun:async l=>{try{g(null);const r=await me(l,t);return h===l&&_(r.run),await v(),r}catch(r){const o=Z(r,"Failed to retry run");throw g(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:c.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:c,finding:f,projectId:h,onClose:a,onConfirm:p}){xe(n);const[_,j]=i.useState(!1),[N,E]=i.useState(""),[T,L]=i.useState(""),[P,F]=i.useState("normal"),[g,R]=i.useState(""),[D,C]=i.useState([]),[k,S]=i.useState(!1),[v,x]=i.useState(!1),l=i.useMemo(()=>{const r=(f.content??"").split(/(?<=[.!?])\s+/)[0]??"";return`${f.heading||"Research finding"} — ${r}`.trim()},[f.content,f.heading]);return i.useEffect(()=>{n&&(j(!1),E(`Research: ${f.heading||c.title}`),L(l),F("normal"),R(""),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,c.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:"})," ",c.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:g,placeholder:k?"Loading tasks…":"Enter task ID",onChange:r=>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:_,onChange:r=>j(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"&&!g,onClick:()=>{x(!0),p({taskId:t==="enrich"?g:void 0,title:t==="create"?N.trim():void 0,description:t==="create"?T.trim():void 0,priority:t==="create"?P:void 0,attachExport:_}).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 qe({projectId:n,addToast:t,onOpenSettings:c,readinessVersion:f=0}){const{runs:h,selectedRun:a,selectedRunId:p,setSelectedRunId:_,availability:j,loading:N,error:E,searchQuery:T,setSearchQuery:L,createRun:P,cancelRun:F,retryRun:g,exportRun:R,createTaskFromRun:D,attachRunToTask:C,statusCounts:k,refresh:S,uiError:v,runActionState:x}=Ee({projectId:n}),[l,r]=i.useState(""),[o,y]=i.useState(()=>X(void 0)),[b,M]=i.useState([]),[O,V]=i.useState(!1),[ee,se]=i.useState([]),[A,U]=i.useState(null),[I,$]=i.useState(null),z=j.supportedProviders??Te,B=o.searchProvider,Q=s=>s==="web-search"?!0:o.enabledSources[Pe[s]];i.useEffect(()=>{const s=z.filter(d=>Q(d));se(d=>{const m=d.filter(u=>s.includes(u));return m.length>0?m:s})},[o.enabledSources,z]),i.useEffect(()=>{let s=!1;return Promise.all([ye(n),je().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=i.useMemo(()=>a?a.status:"No run selected",[a]),ne=i.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=j.supportedExportFormats??["markdown","json","html"],W=i.useMemo(()=>new Map(b.map(s=>[s.id,s.authenticated])),[b]),Y=i.useMemo(()=>{const s=new Set;return o.enabledSources.webSearch&&B&&s.add(B),o.enabledSources.llmSynthesis&&o.synthesisProvider&&s.add(o.synthesisProvider),[...s].filter(d=>W.has(d))},[o.enabledSources.llmSynthesis,o.enabledSources.webSearch,o.synthesisProvider,B,W]).find(s=>W.get(s)!==!0),q=i.useMemo(()=>j.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:j.reason??"Research is unavailable for this project.",details:j.setupInstructions,settingsSection:"research-project"},[j.available,j.reason,j.setupInstructions,o.enabled,Y]),G=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 R(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)}}},ie=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});_(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:"Cited search and synthesis runs: gather sources, fetch content, and synthesize findings."})]}),e.jsx("div",{className:"research-view__header-actions",children: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:()=>c?.(q.settingsSection),children:"Open Settings"})]})]}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"research-view__layout",children:[e.jsx("aside",{className:"research-view__sidebar card",children:e.jsxs("div",{className:"research-view__sidebar-content",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:z.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 ie(),children:[O?e.jsx(ge,{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(_e,{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:()=>_(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 G("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 G("retry",()=>g(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:()=>c?.("authentication"),children:"Open Authentication Settings"}),v.code==="FEATURE_DISABLED"&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>c?.("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 G("create-task",()=>D(a.id,u,I.findingId,w,te,re),"Task created from research"):m&&await G("attach-task",()=>C(a.id,m,I.findingId,re),"Task enriched from research"),$(null)}}):null})()]})}export{qe as ResearchView};