@runfusion/fusion 0.46.0 → 0.48.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 (121) hide show
  1. package/dist/bin.js +16689 -14379
  2. package/dist/client/.vite/manifest.json +241 -241
  3. package/dist/client/assets/{AgentDetailView-D1cA9Bfj.js → AgentDetailView-CF6isJ51.js} +1 -1
  4. package/dist/client/assets/{AgentPermissionPolicyEditor-DE0wv8-L.js → AgentPermissionPolicyEditor-DFldf6aS.js} +1 -1
  5. package/dist/client/assets/{AgentsView-Bm_FA_1w.js → AgentsView-DiGseTuo.js} +3 -3
  6. package/dist/client/assets/{ChatView-CHEkov6q.js → ChatView-BjQBbDyo.js} +3 -3
  7. package/dist/client/assets/{CommandCenter-Cfgek-dC.js → CommandCenter-DwpiADSX.js} +1 -1
  8. package/dist/client/assets/DevServerView-D6RFaGPU.js +1 -0
  9. package/dist/client/assets/DevServerView-iBondC7z.css +1 -0
  10. package/dist/client/assets/{DirectoryPicker-etVwa-6X.js → DirectoryPicker-DNBB-viz.js} +1 -1
  11. package/dist/client/assets/{DocumentsView-e8ZTdPIZ.js → DocumentsView-DXG-sctG.js} +1 -1
  12. package/dist/client/assets/{EvalsView-CjDRQFMQ.js → EvalsView-Ol6ECKz5.js} +1 -1
  13. package/dist/client/assets/{ExperimentalAgentOnboardingModal-DXR0OAsR.js → ExperimentalAgentOnboardingModal-BQc3GaE_.js} +1 -1
  14. package/dist/client/assets/{GoalsView-WWDKVslN.js → GoalsView-C_m90anC.js} +1 -1
  15. package/dist/client/assets/{InsightsView-DxIfxOzx.js → InsightsView-BbFgPsDH.js} +2 -2
  16. package/dist/client/assets/{MemoryView-BVW2hkWf.js → MemoryView-CRS7AjWK.js} +1 -1
  17. package/dist/client/assets/{PiExtensionsManager-CpSfMok2.js → PiExtensionsManager-BEj5xu45.js} +3 -3
  18. package/dist/client/assets/{PluginManager-CpBCy656.js → PluginManager-CzCM3XUY.js} +1 -1
  19. package/dist/client/assets/{PullRequestView-BMspX1ga.js → PullRequestView-9yNYCunb.js} +2 -2
  20. package/dist/client/assets/{ResearchView--YEtcv_s.js → ResearchView-BKdirpiw.js} +1 -1
  21. package/dist/client/assets/{SecretsView-CC6QDMWN.js → SecretsView-qGjo-0Cp.js} +1 -1
  22. package/dist/client/assets/SessionTerminal-C7YlkdGJ.js +2 -0
  23. package/dist/client/assets/SettingsModal-CvbiSIHS.css +1 -0
  24. package/dist/client/assets/{SettingsModal-4d_p8D7W.js → SettingsModal-DihNd7g8.js} +1 -1
  25. package/dist/client/assets/SettingsModal-DpaptT6t.js +21 -0
  26. package/dist/client/assets/SetupWizardModal-MovTj5pY.js +2 -0
  27. package/dist/client/assets/{ShadcnColorPicker-HX3j1v66.js → ShadcnColorPicker-Bnf5n5R4.js} +1 -1
  28. package/dist/client/assets/{SkillsView-mdFVTX-r.js → SkillsView-Br2LkA3x.js} +1 -1
  29. package/dist/client/assets/{TodoView-DQVugDpW.js → TodoView-BEdk6FTU.js} +2 -2
  30. package/dist/client/assets/WorkflowNodeEditor-BOouksjw.css +1 -0
  31. package/dist/client/assets/WorkflowNodeEditor-e-eR6yzw.js +8 -0
  32. package/dist/client/assets/{agentSkills-C2v1wbxh.js → agentSkills-D5nDZPRY.js} +1 -1
  33. package/dist/client/assets/{app-BJGkp7Tt.js → app-BM6bAO0b.js} +1 -1
  34. package/dist/client/assets/{app-CZQ_fFNf.js → app-BglOELbc.js} +1 -1
  35. package/dist/client/assets/{app-BaoNC9zg.js → app-ChkCVQpq.js} +1 -1
  36. package/dist/client/assets/{app-DgezOJub.js → app-DMn7Jt9g.js} +1 -1
  37. package/dist/client/assets/{app-DAu3AzsS.js → app-D_IT9Buz.js} +1 -1
  38. package/dist/client/assets/{app-BKLUvvm8.js → app-S8fehQv8.js} +1 -1
  39. package/dist/client/assets/{architectureDiagram-3BPJPVTR-CGEhhgX_.js → architectureDiagram-3BPJPVTR-BbkXWBni.js} +1 -1
  40. package/dist/client/assets/{blockDiagram-GPEHLZMM-D0DTo0HT.js → blockDiagram-GPEHLZMM-DhaqpHqZ.js} +1 -1
  41. package/dist/client/assets/{c4Diagram-AAUBKEIU-DNykNaRb.js → c4Diagram-AAUBKEIU-qC0WSHMZ.js} +1 -1
  42. package/dist/client/assets/channel-CCKvUami.js +1 -0
  43. package/dist/client/assets/{chunk-2J33WTMH-5oQfAhmr.js → chunk-2J33WTMH-Dah9zMeT.js} +1 -1
  44. package/dist/client/assets/{chunk-4BX2VUAB-BqLZXgFw.js → chunk-4BX2VUAB-epHwnUb_.js} +1 -1
  45. package/dist/client/assets/{chunk-55IACEB6-C1oIjX3T.js → chunk-55IACEB6-DpYBy44g.js} +1 -1
  46. package/dist/client/assets/{chunk-727SXJPM-BaovQTgk.js → chunk-727SXJPM-B9b8698e.js} +1 -1
  47. package/dist/client/assets/{chunk-AQP2D5EJ-B4ikBK42.js → chunk-AQP2D5EJ-DrM8nnhR.js} +1 -1
  48. package/dist/client/assets/{chunk-FMBD7UC4-5zgtNnG2.js → chunk-FMBD7UC4-jyT6Scwe.js} +1 -1
  49. package/dist/client/assets/{chunk-ND2GUHAM-ByrypRna.js → chunk-ND2GUHAM-EoPfF-PK.js} +1 -1
  50. package/dist/client/assets/{chunk-QZHKN3VN-B7D1exsu.js → chunk-QZHKN3VN-qMwLVfgJ.js} +1 -1
  51. package/dist/client/assets/classDiagram-4FO5ZUOK-C_HqY7AI.js +1 -0
  52. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-C_HqY7AI.js +1 -0
  53. package/dist/client/assets/{cose-bilkent-S5V4N54A-CQmiNzGr.js → cose-bilkent-S5V4N54A-DmPFKoVD.js} +1 -1
  54. package/dist/client/assets/{dagre-BM42HDAG-BH8Uk0Up.js → dagre-BM42HDAG-DeHxd-ej.js} +1 -1
  55. package/dist/client/assets/{dashboard-view-D3PWY2PH.js → dashboard-view-Cw5mMJay.js} +1 -1
  56. package/dist/client/assets/{dashboard-view-CWJ-b59n.js → dashboard-view-DXjNQ5IF.js} +1 -1
  57. package/dist/client/assets/{diagram-2AECGRRQ-CDoHfkxY.js → diagram-2AECGRRQ-C04A2mhr.js} +1 -1
  58. package/dist/client/assets/{diagram-5GNKFQAL-DARILCuD.js → diagram-5GNKFQAL-DqtOwADI.js} +1 -1
  59. package/dist/client/assets/{diagram-KO2AKTUF-CNP-qi0y.js → diagram-KO2AKTUF-CH0har-Z.js} +1 -1
  60. package/dist/client/assets/{diagram-LMA3HP47-SCiVmkcf.js → diagram-LMA3HP47-CxN-U-0W.js} +1 -1
  61. package/dist/client/assets/{diagram-OG6HWLK6-iTJLXH61.js → diagram-OG6HWLK6-42A7wpwF.js} +1 -1
  62. package/dist/client/assets/{erDiagram-TEJ5UH35-ByMpiPIa.js → erDiagram-TEJ5UH35-CnZI5YlN.js} +1 -1
  63. package/dist/client/assets/{flowDiagram-I6XJVG4X-DW3m3ZpM.js → flowDiagram-I6XJVG4X-BKfQhMVF.js} +1 -1
  64. package/dist/client/assets/{folder-open-G-9vPAdv.js → folder-open-STXgbemw.js} +1 -1
  65. package/dist/client/assets/{ganttDiagram-6RSMTGT7-BJeYH7Ol.js → ganttDiagram-6RSMTGT7-BfA0pME8.js} +1 -1
  66. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-CK_Chj4m.js → gitGraphDiagram-PVQCEYII-BgDFB7PS.js} +1 -1
  67. package/dist/client/assets/index-BnfnLXyO.css +1 -0
  68. package/dist/client/assets/index-CHy0WNjH.js +1301 -0
  69. package/dist/client/assets/{infoDiagram-5YYISTIA-D8Wg1IgN.js → infoDiagram-5YYISTIA-Bb5F155s.js} +1 -1
  70. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-DWROR2aX.js → ishikawaDiagram-YF4QCWOH-8Oati7l_.js} +1 -1
  71. package/dist/client/assets/{journeyDiagram-JHISSGLW-Bns9774_.js → journeyDiagram-JHISSGLW-DhHTHXTM.js} +1 -1
  72. package/dist/client/assets/{kanban-definition-UN3LZRKU-QtURfAoI.js → kanban-definition-UN3LZRKU-BWB9EtUX.js} +1 -1
  73. package/dist/client/assets/{mermaid.core-DqgrgWWm.js → mermaid.core-BD-L2gUQ.js} +4 -4
  74. package/dist/client/assets/{mindmap-definition-RKZ34NQL-jLaDb5_X.js → mindmap-definition-RKZ34NQL-BSKGd7LE.js} +1 -1
  75. package/dist/client/assets/{pieDiagram-4H26LBE5-CjbHuIje.js → pieDiagram-4H26LBE5-BtBFPvSW.js} +1 -1
  76. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-xgHbylQr.js → quadrantDiagram-W4KKPZXB-aWQWYPto.js} +1 -1
  77. package/dist/client/assets/{requirementDiagram-4Y6WPE33-CHdD7W41.js → requirementDiagram-4Y6WPE33-CprlEpIa.js} +1 -1
  78. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-C3me87g9.js → sankeyDiagram-5OEKKPKP-Cw-AcRAV.js} +1 -1
  79. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-DSHfs1kU.js → sequenceDiagram-3UESZ5HK-BMW5slyv.js} +1 -1
  80. package/dist/client/assets/{shield-alert-DkGlhVjI.js → shield-alert-Bzf8yNOc.js} +1 -1
  81. package/dist/client/assets/{stateDiagram-AJRCARHV-C08n7sMP.js → stateDiagram-AJRCARHV-CcxvIVwM.js} +1 -1
  82. package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-BosoAbfO.js → stateDiagram-v2-BHNVJYJU-awOfoFOB.js} +1 -1
  83. package/dist/client/assets/{timeline-definition-PNZ67QCA-C21h9Zqh.js → timeline-definition-PNZ67QCA-DIEAc2YP.js} +1 -1
  84. package/dist/client/assets/{upload-B9B-tYt9.js → upload-DuwyPTKe.js} +1 -1
  85. package/dist/client/assets/{users-C_BA3C7E.js → users-D1Qhfyro.js} +1 -1
  86. package/dist/client/assets/{vennDiagram-CIIHVFJN-Bv3G0dwI.js → vennDiagram-CIIHVFJN-DOkqg5Wi.js} +1 -1
  87. package/dist/client/assets/{wardley-L42UT6IY-WX0hHKcN.js → wardley-L42UT6IY-DoPK1Q6d.js} +1 -1
  88. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-CMwIPWm7.js → wardleyDiagram-YWT4CUSO-l1vun-m2.js} +1 -1
  89. package/dist/client/assets/{xychartDiagram-2RQKCTM6-CZvFdt6j.js → xychartDiagram-2RQKCTM6-DcUOUKvl.js} +1 -1
  90. package/dist/client/index.html +2 -2
  91. package/dist/client/version.json +1 -1
  92. package/dist/droid-cli/package.json +1 -1
  93. package/dist/extension.js +16363 -14192
  94. package/dist/pi-claude-cli/package.json +1 -1
  95. package/dist/plugin-sdk/index.d.ts +11 -6
  96. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  97. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  98. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  99. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  100. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  101. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  102. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  103. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  104. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  105. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  106. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  107. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  108. package/package.json +1 -1
  109. package/dist/client/assets/DevServerView-DgDksVH2.css +0 -1
  110. package/dist/client/assets/DevServerView-_or2KLVw.js +0 -1
  111. package/dist/client/assets/SessionTerminal-DJGtgIls.js +0 -2
  112. package/dist/client/assets/SettingsModal-BESN59Ao.css +0 -1
  113. package/dist/client/assets/SettingsModal-wABa7xmZ.js +0 -21
  114. package/dist/client/assets/SetupWizardModal-DHe2tXzx.js +0 -2
  115. package/dist/client/assets/WorkflowNodeEditor-CeERQHHu.js +0 -8
  116. package/dist/client/assets/WorkflowNodeEditor-f_XPV5Jd.css +0 -1
  117. package/dist/client/assets/channel-Dwf1FoGU.js +0 -1
  118. package/dist/client/assets/classDiagram-4FO5ZUOK-WqSUwcK_.js +0 -1
  119. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-WqSUwcK_.js +0 -1
  120. package/dist/client/assets/index-BZBQ_KsL.css +0 -1
  121. package/dist/client/assets/index-ccFe_1av.js +0 -1459
@@ -1,4 +1,4 @@
1
- import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{c as Le,ax as ce,ay as Se,az as ke,bA as Ce,bB as Ve,aC as je,bC as We,bD as qe,bE as Ye,bF as Qe,bG as Je,bH as Ze,bI as Me,bJ as es,bK as ss,bL as Ie,V as ts,S as A,bM as is,X as Ae,bN as me,R as N,a1 as ns,bO as as,f as ze,p as le,bP as Ne,bs as rs,P as _e,ai as cs,b8 as De,bQ as ls}from"./index-ccFe_1av.js";import{u as Pe}from"./vendor-i18n-GF3RlKbq.js";import{U as Ee}from"./users-C_BA3C7E.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
1
+ import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{c as Le,ay as ce,az as Se,aA as ke,bB as Ce,bC as Ke,aD as je,bD as Ve,bE as We,bF as Ye,bG as Qe,bH as Je,bI as Ze,bJ as Me,bK as es,bL as ss,bM as Ie,V as ts,S as A,bN as is,X as Ae,bO as me,R as N,a2 as ns,bP as as,h as ze,q as le,bQ as Ne,bt as rs,P as _e,aj as cs,b9 as De,bR as ls}from"./index-CHy0WNjH.js";import{u as Pe}from"./vendor-i18n-GF3RlKbq.js";import{U as Ee}from"./users-D1Qhfyro.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,4 +8,4 @@ import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{c as Le,ax as ce,ay
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const gs=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],ds=Le("chart-line",gs),ue=["architecture","quality","workflow","performance","reliability","security","ux","testability","documentation","dependency","features","competitive_analysis","research","trends","other"],Fe={quality:"Quality",performance:"Performance",architecture:"Architecture",security:"Security",reliability:"Reliability",ux:"User Experience",testability:"Testability",documentation:"Documentation",dependency:"Dependencies",workflow:"Workflow",other:"Other",features:"Features",competitive_analysis:"Competitive Analysis",research:"Research",trends:"Trends"};function us(g){const{t:h}=Pe("app"),$=g??"",w=`${ke.INSIGHTS_PREFIX}${$}`,S=`${ke.INSIGHT_LATEST_RUN_PREFIX}${$}`,s=ce(w,{maxAgeMs:Se}),W=ce(S,{maxAgeMs:Ce}),E=c.useRef(Array.isArray(s)&&s.length>0),G=c.useCallback(r=>h(`insights.category.${r}`,Fe[r]??r),[h]),[v,x]=c.useState(()=>Array.isArray(s)?s:[]),[T,q]=c.useState(()=>ue.map(r=>({category:r,label:Fe[r]??r,items:[],isLoading:!1,error:null}))),[Y,L]=c.useState(!(Array.isArray(s)&&s.length>0)),[Q,U]=c.useState(null),[J,z]=c.useState(W??null),[Z,H]=c.useState(!1),[ee,F]=c.useState(null),[se,_]=c.useState(new Map),[te,C]=c.useState(new Map),[u,k]=c.useState(new Map),[m,D]=c.useState(new Map),[B,j]=c.useState(!1),R=c.useCallback(async()=>{E.current||L(!0),U(null);try{const i=(await Ve({status:void 0,limit:1e3},g)).insights.filter(d=>d.status!=="dismissed");x(i),je(w,i.length>500?i.slice(0,500):i,{maxBytes:5e5});const t=await We(g);t.runs.length>0&&(z(t.runs[0]),je(S,t.runs[0],{maxBytes:5e5})),E.current=!0}catch(r){const i=r instanceof Error?r.message:"Failed to fetch insights";U(i)}finally{L(!1)}},[w,S,g]),y=c.useCallback(()=>{j(r=>!r)},[]),ie=c.useCallback(async(r,i)=>{H(!0),F(null);try{const t=await qe("manual",void 0,g,r,i);z(t),t.status==="completed"?await R():t.status==="failed"&&t.error&&F(t.error)}catch(t){if(t instanceof Ye&&t.status===409&&t.details?.code==="ACTIVE_RUN_CONFLICT"){const f=typeof t.details.activeRunId=="string"?t.details.activeRunId:null;if(f)try{const ge=await Qe(f,g);z(ge)}catch{}throw F("Insight generation is already running"),t}const d=t instanceof Error?t.message:"Failed to generate insights";throw F(d),t}finally{H(!1)}},[g,R]),oe=c.useCallback(async r=>{_(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await Je(r,g),x(i=>i.filter(t=>t.id!==r)),_(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to dismiss insight";throw _(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),he=c.useCallback(async r=>{C(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{const i=await Ze(r,g);return await Me(r,g),x(t=>t.map(d=>d.id===r?{...d,status:"archived",updatedAt:new Date().toISOString()}:d)),C(t=>{const d=new Map(t);return d.set(r,{running:!1,error:null}),d}),{title:i.suggestedTitle,description:i.suggestedDescription}}catch(i){const t=i instanceof Error?i.message:"Failed to create task";throw C(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]);c.useEffect(()=>{const r=new Map;for(const i of ue)r.set(i,[]);for(const i of v){if(!B&&i.status==="archived")continue;const t=r.get(i.category)??[];r.set(i.category,[...t,i])}q(ue.map(i=>({category:i,label:G(i),items:r.get(i)??[],isLoading:!1,error:null})))},[v,B,G]);const b=c.useCallback(async r=>{k(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await Me(r,g),x(i=>i.map(t=>t.id===r?{...t,status:"archived",updatedAt:new Date().toISOString()}:t)),k(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to archive insight";throw k(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),O=c.useCallback(async r=>{D(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await es(r,g),x(i=>i.map(t=>t.id===r?{...t,status:"confirmed",updatedAt:new Date().toISOString()}:t)),D(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to unarchive insight";throw D(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),p=c.useMemo(()=>T.reduce((r,i)=>r+i.items.length,0),[T]),X=c.useMemo(()=>0,[]),K=c.useMemo(()=>v.filter(r=>r.status==="archived").length,[v]);return c.useEffect(()=>{const r=ce(w,{maxAgeMs:Se}),i=ce(S,{maxAgeMs:Ce}),t=Array.isArray(r)&&r.length>0;x(Array.isArray(r)?r:[]),z(i??null),L(!t),E.current=t},[w,S]),c.useEffect(()=>{R()},[R]),{sections:T,loading:Y,error:Q,latestRun:J,isRunInFlight:Z,runError:ee,refresh:R,runInsights:ie,dismiss:oe,createTask:he,archive:b,unarchive:O,toggleShowArchived:y,dismissStates:se,createTaskStates:te,archiveStates:u,unarchiveStates:m,totalCount:p,dismissedCount:X,archivedCount:K,showArchived:B}}const $e=["Backlog health:","Backlog pressure detected","Stale paused todo","Backlog health: dependency-blocked todos"];function Re(g){return $e.some(h=>g.title.startsWith(h))}const Te={architecture:hs,quality:ze,workflow:De,performance:Ne,reliability:N,security:le,ux:Ee,testability:me,documentation:cs,dependency:_e,features:rs,competitive_analysis:Ee,research:ds,trends:Ne,other:A};function ws({projectId:g,addToast:h,onClose:$,onCreateTask:w,models:S}){const{t:s}=Pe("app"),{sections:W,loading:E,error:G,latestRun:v,isRunInFlight:x,runError:T,refresh:q,runInsights:Y,dismiss:L,createTask:Q,archive:U=async()=>{},unarchive:J=async()=>{},toggleShowArchived:z=()=>{},dismissStates:Z,createTaskStates:H,archiveStates:ee=new Map,unarchiveStates:F=new Map,totalCount:se,archivedCount:_=0,showArchived:te=!1}=us(g),[C,u]=c.useState(null),[k,m]=c.useState("info"),[D,B]=c.useState(!1),[j,R]=c.useState(!1),[y,ie]=c.useState(()=>localStorage.getItem("fusion-insight-model")??""),[oe,he]=c.useState([]),[b,O]=c.useState([]),[p,X]=c.useState([]),[K,r]=c.useState();c.useEffect(()=>{S||ss().then(n=>{he(n.models),O(n.favoriteProviders),X(n.favoriteModels),r(n.resolvedPlanningProvider);const a=localStorage.getItem("fusion-insight-model");a&&(n.models.some(o=>`${o.provider}/${o.id}`===a)||(localStorage.removeItem("fusion-insight-model"),ie("")))}).catch(()=>{})},[S]);const i=S??oe,t=c.useMemo(()=>b.length>0?b:K?[K]:[],[b,K]),d=c.useCallback(async n=>{const l=b.includes(n)?b.filter(o=>o!==n):[n,...b];O(l);try{await Ie({favoriteProviders:l,favoriteModels:p})}catch{O(b)}},[b,p]),f=c.useCallback(async n=>{const l=p.includes(n)?p.filter(o=>o!==n):[n,...p];X(l);try{await Ie({favoriteProviders:b,favoriteModels:l})}catch{X(p)}},[p,b]),ge=c.useCallback(n=>{ie(n),n?localStorage.setItem("fusion-insight-model",n):localStorage.removeItem("fusion-insight-model")},[]),V=c.useMemo(()=>W.filter(n=>n.items.length>0),[W]),fe=c.useMemo(()=>V.reduce((n,a)=>n+a.items.filter(Re).length,0),[V]),M=c.useMemo(()=>j?V.map(n=>({...n,items:n.items.filter(Re)})).filter(n=>n.items.length>0):V,[V,j]),[P,de]=c.useState(null);c.useEffect(()=>{if(M.length===0){P!==null&&de(null);return}P&&M.some(a=>a.category===P&&a.items.length>0)||de(M[0].category)},[M,P]);const I=c.useMemo(()=>M.find(n=>n.category===P)??M[0],[M,P]);c.useEffect(()=>{if(C){const n=setTimeout(()=>u(null),5e3);return()=>clearTimeout(n)}},[C]);const ve=c.useCallback(async()=>{try{u(s("insights.generatingInsights","Generating insights...")),m("info");let n,a;if(y){const l=y.indexOf("/");if(l!==-1){const o=y.slice(0,l),ne=y.slice(l+1);o&&ne&&(n=o,a=ne)}}await Y(n,a),u(s("insights.generationStarted","Insight generation started")),m("success"),h(s("insights.generationStarted","Insight generation started"),"success")}catch(n){const a=n instanceof Error?n.message:s("insights.failedToStart","Failed to start generation");if(a==="Insight generation is already running"){u(s("insights.alreadyRunning","Insight generation is already running. Showing the active run.")),m("info"),h(s("insights.alreadyRunningShort","Insight generation is already running"),"info");return}u(a),m("error"),h(a,"error")}},[Y,h,y,s]),Ge=c.useCallback(async(n,a)=>{try{u(s("insights.dismissing",'Dismissing "{{title}}"...',{title:a})),m("info"),await L(n),u(s("insights.dismissed",'Dismissed "{{title}}"',{title:a})),m("success"),h(s("insights.dismissedMsg","Insight dismissed: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToDismiss","Failed to dismiss insight");u(o),m("error"),h(o,"error")}},[L,h,s]),Ue=c.useCallback(async(n,a)=>{try{u(s("insights.archiving",'Archiving "{{title}}"...',{title:a})),m("info"),await U(n),u(s("insights.archived",'Archived "{{title}}"',{title:a})),m("success"),h(s("insights.archivedMsg","Insight archived: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToArchive","Failed to archive insight");u(o),m("error"),h(o,"error")}},[U,h,s]),He=c.useCallback(async(n,a)=>{try{u(s("insights.unarchiving",'Unarchiving "{{title}}"...',{title:a})),m("info"),await J(n),u(s("insights.unarchived",'Unarchived "{{title}}"',{title:a})),m("success"),h(s("insights.unarchivedMsg","Insight unarchived: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToUnarchive","Failed to unarchive insight");u(o),m("error"),h(o,"error")}},[J,h,s]),Be=c.useCallback(async(n,a)=>{try{if(u(s("insights.creatingTask",'Creating task from "{{title}}"...',{title:a})),m("info"),!w)throw new Error(s("insights.taskCreationUnavailable","Task creation is unavailable in this view"));const l=await Q(n);if(!l)throw new Error(s("insights.failedToPreparePayload","Failed to prepare task payload from insight"));await w({insightId:n,title:l.title,description:l.description}),u(s("insights.taskCreated",'Task created from "{{title}}"',{title:a})),m("success"),h(s("insights.taskCreatedMsg","Task created: {{title}}",{title:l.title}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToCreateTask","Failed to create task");u(o),m("error"),h(o,"error")}},[Q,w,h,s]),Oe=n=>{const a=Te[n.category]??A,l=I?.category===n.category;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:`insights-category-item${l?" insights-category-item--active":""}`,onClick:()=>de(n.category),"aria-current":l?"true":void 0,"data-testid":`insights-category-${n.category}`,children:[e.jsx(a,{size:16,className:"insights-category-icon"}),e.jsx("span",{className:"insights-category-label",children:n.label}),e.jsx("span",{className:"insights-category-count",children:n.items.length})]})},n.category)},Xe=()=>{if(!I)return null;const n=Te[I.category]??A;return e.jsxs("section",{className:"insights-section","data-testid":`insights-section-${I.category}`,children:[e.jsx("div",{className:"insights-section-header",children:e.jsxs("div",{className:"insights-section-title",children:[e.jsx(n,{size:20,className:"insights-section-icon"}),e.jsx("h3",{children:I.label}),e.jsx("span",{className:"insights-section-count",children:I.items.length})]})}),e.jsx("div",{className:"insights-section-content",children:e.jsx("ul",{className:"insights-list",children:I.items.map(a=>{const l=Z.get(a.id),o=H.get(a.id),ne=ee.get(a.id),Ke=F.get(a.id),be=l?.running??!1,ye=o?.running??!1,xe=ne?.running??!1,pe=Ke?.running??!1,we=a.status==="archived",ae=I.items.some(re=>Z.get(re.id)?.running||H.get(re.id)?.running||ee.get(re.id)?.running||F.get(re.id)?.running);return e.jsxs("li",{className:`insight-item${we?" insight-item--archived":""}`,"data-insight-id":a.id,children:[e.jsxs("div",{className:"insight-item-header",children:[e.jsx("h4",{className:"insight-item-title",children:a.title}),e.jsxs("div",{className:"insight-item-actions",children:[we?e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void He(a.id,a.title),disabled:pe||ae,title:s("insights.unarchiveTitle","Unarchive this insight"),"aria-label":s("insights.unarchiveLabel","Unarchive this insight"),"data-testid":`unarchive-${a.id}`,children:pe?e.jsx(N,{size:20,className:"spin"}):e.jsx(ls,{size:20})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Be(a.id,a.title),disabled:ye||ae,title:s("insights.createTaskTitle","Create task from this insight"),"aria-label":s("insights.createTaskLabel","Create task from this insight"),"data-testid":`create-task-${a.id}`,children:ye?e.jsx(N,{size:20,className:"spin"}):e.jsx(_e,{size:20})}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Ue(a.id,a.title),disabled:xe||ae,title:s("insights.archiveTitle","Archive this insight"),"aria-label":s("insights.archiveLabel","Archive this insight"),"data-testid":`archive-${a.id}`,children:xe?e.jsx(N,{size:20,className:"spin"}):e.jsx(me,{size:20})})]}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Ge(a.id,a.title),disabled:be||ae,title:s("insights.dismissTitle","Dismiss this insight"),"aria-label":s("insights.dismissLabel","Dismiss this insight"),"data-testid":`dismiss-${a.id}`,children:be?e.jsx(N,{size:20,className:"spin"}):e.jsx(Ae,{size:20})})]})]}),a.content&&e.jsx("p",{className:"insight-item-content",children:a.content}),e.jsxs("div",{className:"insight-item-meta",children:[e.jsx("span",{className:`insight-item-status insight-item-status--${a.status}`,children:a.status}),a.createdAt&&e.jsxs("span",{className:"insight-item-date",children:[e.jsx(De,{size:12}),new Date(a.createdAt).toLocaleDateString()]})]})]},a.id)})})})]})};return e.jsxs("div",{className:"insights-view","data-testid":"insights-view",children:[e.jsx(ts,{icon:A,title:s("insights.title","Insights"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"insights-view-count",children:[se," ",s("common.total","total")]}),fe>0&&e.jsxs("button",{className:`btn btn-sm insights-backlog-health-toggle${j?" btn-icon--active":""}`,onClick:()=>R(n=>!n),"aria-pressed":j,"aria-label":j?s("insights.showAllInsights","Show all insights"):s("insights.showBacklogHealth","Show only backlog health insights"),"data-testid":"toggle-backlog-health",title:$e.join(", "),children:[e.jsx(is,{size:14}),j?s("insights.allInsights","All Insights"):s("insights.backlogHealth","Backlog")," ",e.jsxs("span",{children:["(",fe,")"]})]}),$&&e.jsx("button",{className:"btn btn-sm insights-view-close",onClick:$,"aria-label":s("actions.closeInsightsView","Close insights view"),title:s("actions.close","Close"),children:e.jsx(Ae,{size:16})}),_>0&&e.jsxs("button",{className:"btn btn-sm insights-show-archived-toggle",onClick:z,"aria-label":te?s("insights.hideArchived","Hide archived insights"):s("insights.showArchived","Show archived insights"),"data-testid":"toggle-archived-insights",children:[e.jsx(me,{size:14}),te?s("insights.hideArchivedLabel","Archived"):s("insights.showArchivedLabel","Archived ({{count}})",{count:_})]}),e.jsx("button",{className:"btn btn-icon btn-sm insights-refresh-btn",onClick:()=>void q(),disabled:E,"aria-label":s("actions.refreshInsights","Refresh insights"),title:s("actions.refreshInsights","Refresh insights"),"data-testid":"refresh-insights",children:e.jsx(N,{size:14,className:E?"spin":""})}),e.jsxs("button",{className:"btn btn-sm insights-model-toggle",onClick:()=>B(n=>!n),"aria-label":s("insights.configureModel","Configure insight generation model"),"aria-expanded":D,"data-testid":"toggle-model-config",title:y?s("insights.modelConfigured","Model: {{model}}",{model:y}):s("insights.configureModelTitle","Configure model"),children:[e.jsx(ns,{size:14}),y&&e.jsx("span",{className:"insights-model-indicator"})]}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void ve(),disabled:x,"aria-label":s("insights.generateInsights","Generate new insights"),"data-testid":"run-insights",children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:14,className:"spin"}),s("insights.generating","Generating...")]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{size:14}),s("insights.generateInsightsBtn","Generate Insights")]})})]})}),D&&e.jsxs("div",{className:"insights-model-config","data-testid":"model-config",children:[e.jsx("label",{htmlFor:"insight-model-select",className:"insights-model-label",children:s("insights.model","Model")}),e.jsx(as,{models:i,value:y,onChange:ge,placeholder:s("insights.usePlanningDefault","Use planning default"),label:s("insights.generationModel","Insight generation model"),disabled:x,id:"insight-model-select",favoriteProviders:t,favoriteModels:p,onToggleFavorite:d,onToggleModelFavorite:f})]}),e.jsx("div",{className:"insights-status-region","aria-live":"polite","data-testid":"insights-status",children:C&&e.jsxs("div",{className:`insights-status-message insights-status-message--${k}`,role:k==="error"?"alert":void 0,children:[k==="success"&&e.jsx(ze,{size:16}),k==="error"&&e.jsx(le,{size:16}),k==="info"&&e.jsx(A,{size:16}),e.jsx("span",{children:C})]})}),T&&e.jsxs("div",{className:"insights-error-callout",role:"alert","data-testid":"run-error",children:[e.jsx(le,{size:16}),e.jsx("span",{children:T})]}),v&&e.jsx("div",{className:"insights-run-info","data-testid":"latest-run",children:e.jsxs("span",{className:"insights-run-status",children:[s("insights.latestRun","Latest run:")," ",v.status,v.status==="completed"&&e.jsxs(e.Fragment,{children:[" — ",s("insights.runCompleted","{{created}} created, {{updated}} updated",{created:v.insightsCreated,updated:v.insightsUpdated})]}),v.status==="failed"&&v.error&&e.jsxs(e.Fragment,{children:[" — ",v.error]})]})}),E?e.jsxs("div",{className:"insights-loading","data-testid":"insights-loading",children:[e.jsx(N,{size:24,className:"spin"}),e.jsx("p",{children:s("insights.loading","Loading insights...")})]}):G?e.jsxs("div",{className:"insights-error","data-testid":"insights-error",children:[e.jsx(le,{size:24}),e.jsx("p",{children:G}),e.jsx("button",{className:"btn btn-sm",onClick:()=>void q(),children:s("actions.retry","Retry")})]}):se===0?e.jsxs("div",{className:"insights-empty","data-testid":"insights-empty",children:[e.jsx(A,{size:48}),e.jsx("h3",{children:s("insights.noInsightsYet","No insights yet")}),e.jsx("p",{children:s("insights.generateDescription","Generate insights to get AI-powered recommendations for your project.")}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void ve(),children:[e.jsx(A,{size:14}),s("insights.generateFirst","Generate First Insights")]})]}):e.jsxs("div",{className:"insights-body",children:[e.jsx("aside",{className:"insights-sidebar","aria-label":s("insights.categoriesLabel","Insight categories"),children:e.jsx("ul",{className:"insights-category-list",children:M.map(Oe)})}),e.jsx("div",{className:"insights-detail",children:Xe()})]})]})}export{ws as InsightsView};
11
+ */const gs=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],ds=Le("chart-line",gs),ue=["architecture","quality","workflow","performance","reliability","security","ux","testability","documentation","dependency","features","competitive_analysis","research","trends","other"],Fe={quality:"Quality",performance:"Performance",architecture:"Architecture",security:"Security",reliability:"Reliability",ux:"User Experience",testability:"Testability",documentation:"Documentation",dependency:"Dependencies",workflow:"Workflow",other:"Other",features:"Features",competitive_analysis:"Competitive Analysis",research:"Research",trends:"Trends"};function us(g){const{t:h}=Pe("app"),$=g??"",w=`${ke.INSIGHTS_PREFIX}${$}`,S=`${ke.INSIGHT_LATEST_RUN_PREFIX}${$}`,s=ce(w,{maxAgeMs:Se}),V=ce(S,{maxAgeMs:Ce}),E=c.useRef(Array.isArray(s)&&s.length>0),G=c.useCallback(r=>h(`insights.category.${r}`,Fe[r]??r),[h]),[v,x]=c.useState(()=>Array.isArray(s)?s:[]),[T,W]=c.useState(()=>ue.map(r=>({category:r,label:Fe[r]??r,items:[],isLoading:!1,error:null}))),[Y,L]=c.useState(!(Array.isArray(s)&&s.length>0)),[Q,U]=c.useState(null),[J,z]=c.useState(V??null),[Z,H]=c.useState(!1),[ee,F]=c.useState(null),[se,_]=c.useState(new Map),[te,C]=c.useState(new Map),[u,k]=c.useState(new Map),[m,D]=c.useState(new Map),[B,j]=c.useState(!1),R=c.useCallback(async()=>{E.current||L(!0),U(null);try{const i=(await Ke({status:void 0,limit:1e3},g)).insights.filter(d=>d.status!=="dismissed");x(i),je(w,i.length>500?i.slice(0,500):i,{maxBytes:5e5});const t=await Ve(g);t.runs.length>0&&(z(t.runs[0]),je(S,t.runs[0],{maxBytes:5e5})),E.current=!0}catch(r){const i=r instanceof Error?r.message:"Failed to fetch insights";U(i)}finally{L(!1)}},[w,S,g]),y=c.useCallback(()=>{j(r=>!r)},[]),ie=c.useCallback(async(r,i)=>{H(!0),F(null);try{const t=await We("manual",void 0,g,r,i);z(t),t.status==="completed"?await R():t.status==="failed"&&t.error&&F(t.error)}catch(t){if(t instanceof Ye&&t.status===409&&t.details?.code==="ACTIVE_RUN_CONFLICT"){const f=typeof t.details.activeRunId=="string"?t.details.activeRunId:null;if(f)try{const ge=await Qe(f,g);z(ge)}catch{}throw F("Insight generation is already running"),t}const d=t instanceof Error?t.message:"Failed to generate insights";throw F(d),t}finally{H(!1)}},[g,R]),oe=c.useCallback(async r=>{_(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await Je(r,g),x(i=>i.filter(t=>t.id!==r)),_(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to dismiss insight";throw _(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),he=c.useCallback(async r=>{C(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{const i=await Ze(r,g);return await Me(r,g),x(t=>t.map(d=>d.id===r?{...d,status:"archived",updatedAt:new Date().toISOString()}:d)),C(t=>{const d=new Map(t);return d.set(r,{running:!1,error:null}),d}),{title:i.suggestedTitle,description:i.suggestedDescription}}catch(i){const t=i instanceof Error?i.message:"Failed to create task";throw C(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]);c.useEffect(()=>{const r=new Map;for(const i of ue)r.set(i,[]);for(const i of v){if(!B&&i.status==="archived")continue;const t=r.get(i.category)??[];r.set(i.category,[...t,i])}W(ue.map(i=>({category:i,label:G(i),items:r.get(i)??[],isLoading:!1,error:null})))},[v,B,G]);const b=c.useCallback(async r=>{k(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await Me(r,g),x(i=>i.map(t=>t.id===r?{...t,status:"archived",updatedAt:new Date().toISOString()}:t)),k(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to archive insight";throw k(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),O=c.useCallback(async r=>{D(i=>{const t=new Map(i);return t.set(r,{running:!0,error:null}),t});try{await es(r,g),x(i=>i.map(t=>t.id===r?{...t,status:"confirmed",updatedAt:new Date().toISOString()}:t)),D(i=>{const t=new Map(i);return t.set(r,{running:!1,error:null}),t})}catch(i){const t=i instanceof Error?i.message:"Failed to unarchive insight";throw D(d=>{const f=new Map(d);return f.set(r,{running:!1,error:t}),f}),i}},[g]),p=c.useMemo(()=>T.reduce((r,i)=>r+i.items.length,0),[T]),X=c.useMemo(()=>0,[]),q=c.useMemo(()=>v.filter(r=>r.status==="archived").length,[v]);return c.useEffect(()=>{const r=ce(w,{maxAgeMs:Se}),i=ce(S,{maxAgeMs:Ce}),t=Array.isArray(r)&&r.length>0;x(Array.isArray(r)?r:[]),z(i??null),L(!t),E.current=t},[w,S]),c.useEffect(()=>{R()},[R]),{sections:T,loading:Y,error:Q,latestRun:J,isRunInFlight:Z,runError:ee,refresh:R,runInsights:ie,dismiss:oe,createTask:he,archive:b,unarchive:O,toggleShowArchived:y,dismissStates:se,createTaskStates:te,archiveStates:u,unarchiveStates:m,totalCount:p,dismissedCount:X,archivedCount:q,showArchived:B}}const $e=["Backlog health:","Backlog pressure detected","Stale paused todo","Backlog health: dependency-blocked todos"];function Re(g){return $e.some(h=>g.title.startsWith(h))}const Te={architecture:hs,quality:ze,workflow:De,performance:Ne,reliability:N,security:le,ux:Ee,testability:me,documentation:cs,dependency:_e,features:rs,competitive_analysis:Ee,research:ds,trends:Ne,other:A};function ws({projectId:g,addToast:h,onClose:$,onCreateTask:w,models:S}){const{t:s}=Pe("app"),{sections:V,loading:E,error:G,latestRun:v,isRunInFlight:x,runError:T,refresh:W,runInsights:Y,dismiss:L,createTask:Q,archive:U=async()=>{},unarchive:J=async()=>{},toggleShowArchived:z=()=>{},dismissStates:Z,createTaskStates:H,archiveStates:ee=new Map,unarchiveStates:F=new Map,totalCount:se,archivedCount:_=0,showArchived:te=!1}=us(g),[C,u]=c.useState(null),[k,m]=c.useState("info"),[D,B]=c.useState(!1),[j,R]=c.useState(!1),[y,ie]=c.useState(()=>localStorage.getItem("fusion-insight-model")??""),[oe,he]=c.useState([]),[b,O]=c.useState([]),[p,X]=c.useState([]),[q,r]=c.useState();c.useEffect(()=>{S||ss().then(n=>{he(n.models),O(n.favoriteProviders),X(n.favoriteModels),r(n.resolvedPlanningProvider);const a=localStorage.getItem("fusion-insight-model");a&&(n.models.some(o=>`${o.provider}/${o.id}`===a)||(localStorage.removeItem("fusion-insight-model"),ie("")))}).catch(()=>{})},[S]);const i=S??oe,t=c.useMemo(()=>b.length>0?b:q?[q]:[],[b,q]),d=c.useCallback(async n=>{const l=b.includes(n)?b.filter(o=>o!==n):[n,...b];O(l);try{await Ie({favoriteProviders:l,favoriteModels:p})}catch{O(b)}},[b,p]),f=c.useCallback(async n=>{const l=p.includes(n)?p.filter(o=>o!==n):[n,...p];X(l);try{await Ie({favoriteProviders:b,favoriteModels:l})}catch{X(p)}},[p,b]),ge=c.useCallback(n=>{ie(n),n?localStorage.setItem("fusion-insight-model",n):localStorage.removeItem("fusion-insight-model")},[]),K=c.useMemo(()=>V.filter(n=>n.items.length>0),[V]),fe=c.useMemo(()=>K.reduce((n,a)=>n+a.items.filter(Re).length,0),[K]),M=c.useMemo(()=>j?K.map(n=>({...n,items:n.items.filter(Re)})).filter(n=>n.items.length>0):K,[K,j]),[P,de]=c.useState(null);c.useEffect(()=>{if(M.length===0){P!==null&&de(null);return}P&&M.some(a=>a.category===P&&a.items.length>0)||de(M[0].category)},[M,P]);const I=c.useMemo(()=>M.find(n=>n.category===P)??M[0],[M,P]);c.useEffect(()=>{if(C){const n=setTimeout(()=>u(null),5e3);return()=>clearTimeout(n)}},[C]);const ve=c.useCallback(async()=>{try{u(s("insights.generatingInsights","Generating insights...")),m("info");let n,a;if(y){const l=y.indexOf("/");if(l!==-1){const o=y.slice(0,l),ne=y.slice(l+1);o&&ne&&(n=o,a=ne)}}await Y(n,a),u(s("insights.generationStarted","Insight generation started")),m("success"),h(s("insights.generationStarted","Insight generation started"),"success")}catch(n){const a=n instanceof Error?n.message:s("insights.failedToStart","Failed to start generation");if(a==="Insight generation is already running"){u(s("insights.alreadyRunning","Insight generation is already running. Showing the active run.")),m("info"),h(s("insights.alreadyRunningShort","Insight generation is already running"),"info");return}u(a),m("error"),h(a,"error")}},[Y,h,y,s]),Ge=c.useCallback(async(n,a)=>{try{u(s("insights.dismissing",'Dismissing "{{title}}"...',{title:a})),m("info"),await L(n),u(s("insights.dismissed",'Dismissed "{{title}}"',{title:a})),m("success"),h(s("insights.dismissedMsg","Insight dismissed: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToDismiss","Failed to dismiss insight");u(o),m("error"),h(o,"error")}},[L,h,s]),Ue=c.useCallback(async(n,a)=>{try{u(s("insights.archiving",'Archiving "{{title}}"...',{title:a})),m("info"),await U(n),u(s("insights.archived",'Archived "{{title}}"',{title:a})),m("success"),h(s("insights.archivedMsg","Insight archived: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToArchive","Failed to archive insight");u(o),m("error"),h(o,"error")}},[U,h,s]),He=c.useCallback(async(n,a)=>{try{u(s("insights.unarchiving",'Unarchiving "{{title}}"...',{title:a})),m("info"),await J(n),u(s("insights.unarchived",'Unarchived "{{title}}"',{title:a})),m("success"),h(s("insights.unarchivedMsg","Insight unarchived: {{title}}",{title:a}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToUnarchive","Failed to unarchive insight");u(o),m("error"),h(o,"error")}},[J,h,s]),Be=c.useCallback(async(n,a)=>{try{if(u(s("insights.creatingTask",'Creating task from "{{title}}"...',{title:a})),m("info"),!w)throw new Error(s("insights.taskCreationUnavailable","Task creation is unavailable in this view"));const l=await Q(n);if(!l)throw new Error(s("insights.failedToPreparePayload","Failed to prepare task payload from insight"));await w({insightId:n,title:l.title,description:l.description}),u(s("insights.taskCreated",'Task created from "{{title}}"',{title:a})),m("success"),h(s("insights.taskCreatedMsg","Task created: {{title}}",{title:l.title}),"success")}catch(l){const o=l instanceof Error?l.message:s("insights.failedToCreateTask","Failed to create task");u(o),m("error"),h(o,"error")}},[Q,w,h,s]),Oe=n=>{const a=Te[n.category]??A,l=I?.category===n.category;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:`insights-category-item${l?" insights-category-item--active":""}`,onClick:()=>de(n.category),"aria-current":l?"true":void 0,"data-testid":`insights-category-${n.category}`,children:[e.jsx(a,{size:16,className:"insights-category-icon"}),e.jsx("span",{className:"insights-category-label",children:n.label}),e.jsx("span",{className:"insights-category-count",children:n.items.length})]})},n.category)},Xe=()=>{if(!I)return null;const n=Te[I.category]??A;return e.jsxs("section",{className:"insights-section","data-testid":`insights-section-${I.category}`,children:[e.jsx("div",{className:"insights-section-header",children:e.jsxs("div",{className:"insights-section-title",children:[e.jsx(n,{size:20,className:"insights-section-icon"}),e.jsx("h3",{children:I.label}),e.jsx("span",{className:"insights-section-count",children:I.items.length})]})}),e.jsx("div",{className:"insights-section-content",children:e.jsx("ul",{className:"insights-list",children:I.items.map(a=>{const l=Z.get(a.id),o=H.get(a.id),ne=ee.get(a.id),qe=F.get(a.id),be=l?.running??!1,ye=o?.running??!1,xe=ne?.running??!1,pe=qe?.running??!1,we=a.status==="archived",ae=I.items.some(re=>Z.get(re.id)?.running||H.get(re.id)?.running||ee.get(re.id)?.running||F.get(re.id)?.running);return e.jsxs("li",{className:`insight-item${we?" insight-item--archived":""}`,"data-insight-id":a.id,children:[e.jsxs("div",{className:"insight-item-header",children:[e.jsx("h4",{className:"insight-item-title",children:a.title}),e.jsxs("div",{className:"insight-item-actions",children:[we?e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void He(a.id,a.title),disabled:pe||ae,title:s("insights.unarchiveTitle","Unarchive this insight"),"aria-label":s("insights.unarchiveLabel","Unarchive this insight"),"data-testid":`unarchive-${a.id}`,children:pe?e.jsx(N,{size:20,className:"spin"}):e.jsx(ls,{size:20})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Be(a.id,a.title),disabled:ye||ae,title:s("insights.createTaskTitle","Create task from this insight"),"aria-label":s("insights.createTaskLabel","Create task from this insight"),"data-testid":`create-task-${a.id}`,children:ye?e.jsx(N,{size:20,className:"spin"}):e.jsx(_e,{size:20})}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Ue(a.id,a.title),disabled:xe||ae,title:s("insights.archiveTitle","Archive this insight"),"aria-label":s("insights.archiveLabel","Archive this insight"),"data-testid":`archive-${a.id}`,children:xe?e.jsx(N,{size:20,className:"spin"}):e.jsx(me,{size:20})})]}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Ge(a.id,a.title),disabled:be||ae,title:s("insights.dismissTitle","Dismiss this insight"),"aria-label":s("insights.dismissLabel","Dismiss this insight"),"data-testid":`dismiss-${a.id}`,children:be?e.jsx(N,{size:20,className:"spin"}):e.jsx(Ae,{size:20})})]})]}),a.content&&e.jsx("p",{className:"insight-item-content",children:a.content}),e.jsxs("div",{className:"insight-item-meta",children:[e.jsx("span",{className:`insight-item-status insight-item-status--${a.status}`,children:a.status}),a.createdAt&&e.jsxs("span",{className:"insight-item-date",children:[e.jsx(De,{size:12}),new Date(a.createdAt).toLocaleDateString()]})]})]},a.id)})})})]})};return e.jsxs("div",{className:"insights-view","data-testid":"insights-view",children:[e.jsx(ts,{icon:A,title:s("insights.title","Insights"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"insights-view-count",children:[se," ",s("common.total","total")]}),fe>0&&e.jsxs("button",{className:`btn btn-sm insights-backlog-health-toggle${j?" btn-icon--active":""}`,onClick:()=>R(n=>!n),"aria-pressed":j,"aria-label":j?s("insights.showAllInsights","Show all insights"):s("insights.showBacklogHealth","Show only backlog health insights"),"data-testid":"toggle-backlog-health",title:$e.join(", "),children:[e.jsx(is,{size:14}),j?s("insights.allInsights","All Insights"):s("insights.backlogHealth","Backlog")," ",e.jsxs("span",{children:["(",fe,")"]})]}),$&&e.jsx("button",{className:"btn btn-sm insights-view-close",onClick:$,"aria-label":s("actions.closeInsightsView","Close insights view"),title:s("actions.close","Close"),children:e.jsx(Ae,{size:16})}),_>0&&e.jsxs("button",{className:"btn btn-sm insights-show-archived-toggle",onClick:z,"aria-label":te?s("insights.hideArchived","Hide archived insights"):s("insights.showArchived","Show archived insights"),"data-testid":"toggle-archived-insights",children:[e.jsx(me,{size:14}),te?s("insights.hideArchivedLabel","Archived"):s("insights.showArchivedLabel","Archived ({{count}})",{count:_})]}),e.jsx("button",{className:"btn btn-icon btn-sm insights-refresh-btn",onClick:()=>void W(),disabled:E,"aria-label":s("actions.refreshInsights","Refresh insights"),title:s("actions.refreshInsights","Refresh insights"),"data-testid":"refresh-insights",children:e.jsx(N,{size:14,className:E?"spin":""})}),e.jsxs("button",{className:"btn btn-sm insights-model-toggle",onClick:()=>B(n=>!n),"aria-label":s("insights.configureModel","Configure insight generation model"),"aria-expanded":D,"data-testid":"toggle-model-config",title:y?s("insights.modelConfigured","Model: {{model}}",{model:y}):s("insights.configureModelTitle","Configure model"),children:[e.jsx(ns,{size:14}),y&&e.jsx("span",{className:"insights-model-indicator"})]}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void ve(),disabled:x,"aria-label":s("insights.generateInsights","Generate new insights"),"data-testid":"run-insights",children:x?e.jsxs(e.Fragment,{children:[e.jsx(N,{size:14,className:"spin"}),s("insights.generating","Generating...")]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{size:14}),s("insights.generateInsightsBtn","Generate Insights")]})})]})}),D&&e.jsxs("div",{className:"insights-model-config","data-testid":"model-config",children:[e.jsx("label",{htmlFor:"insight-model-select",className:"insights-model-label",children:s("insights.model","Model")}),e.jsx(as,{models:i,value:y,onChange:ge,placeholder:s("insights.usePlanningDefault","Use planning default"),label:s("insights.generationModel","Insight generation model"),disabled:x,id:"insight-model-select",favoriteProviders:t,favoriteModels:p,onToggleFavorite:d,onToggleModelFavorite:f})]}),e.jsx("div",{className:"insights-status-region","aria-live":"polite","data-testid":"insights-status",children:C&&e.jsxs("div",{className:`insights-status-message insights-status-message--${k}`,role:k==="error"?"alert":void 0,children:[k==="success"&&e.jsx(ze,{size:16}),k==="error"&&e.jsx(le,{size:16}),k==="info"&&e.jsx(A,{size:16}),e.jsx("span",{children:C})]})}),T&&e.jsxs("div",{className:"insights-error-callout",role:"alert","data-testid":"run-error",children:[e.jsx(le,{size:16}),e.jsx("span",{children:T})]}),v&&e.jsx("div",{className:"insights-run-info","data-testid":"latest-run",children:e.jsxs("span",{className:"insights-run-status",children:[s("insights.latestRun","Latest run:")," ",v.status,v.status==="completed"&&e.jsxs(e.Fragment,{children:[" — ",s("insights.runCompleted","{{created}} created, {{updated}} updated",{created:v.insightsCreated,updated:v.insightsUpdated})]}),v.status==="failed"&&v.error&&e.jsxs(e.Fragment,{children:[" — ",v.error]})]})}),E?e.jsxs("div",{className:"insights-loading","data-testid":"insights-loading",children:[e.jsx(N,{size:24,className:"spin"}),e.jsx("p",{children:s("insights.loading","Loading insights...")})]}):G?e.jsxs("div",{className:"insights-error","data-testid":"insights-error",children:[e.jsx(le,{size:24}),e.jsx("p",{children:G}),e.jsx("button",{className:"btn btn-sm",onClick:()=>void W(),children:s("actions.retry","Retry")})]}):se===0?e.jsxs("div",{className:"insights-empty","data-testid":"insights-empty",children:[e.jsx(A,{size:48}),e.jsx("h3",{children:s("insights.noInsightsYet","No insights yet")}),e.jsx("p",{children:s("insights.generateDescription","Generate insights to get AI-powered recommendations for your project.")}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void ve(),children:[e.jsx(A,{size:14}),s("insights.generateFirst","Generate First Insights")]})]}):e.jsxs("div",{className:"insights-body",children:[e.jsx("aside",{className:"insights-sidebar","aria-label":s("insights.categoriesLabel","Insight categories"),children:e.jsx("ul",{className:"insights-category-list",children:M.map(Oe)})}),e.jsx("div",{className:"insights-detail",children:Xe()})]})]})}export{ws as InsightsView};
@@ -1,2 +1,2 @@
1
- import{r,j as e}from"./vendor-react-SZ_qB27O.js";import{u as Re}from"./SettingsModal-4d_p8D7W.js";import{aR as Me,aS as we,aT as qe,aU as Te,aV as Pe,aW as We,aX as He,aY as Ae,aZ as Fe,a_ as _e,a$ as Ue,b0 as Oe,b1 as De,b2 as Qe,aQ as $e,b3 as Be,V as Ve,b4 as Ye,L as F,b5 as ze}from"./index-ccFe_1av.js";import{u as Ge}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const B=".fusion/memory/MEMORY.md",Ze=5e4,Xe="0 3 * * *",Ke="0 4 * * *";function ge(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??Ze,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??Xe,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??Ke}}function Le(i,t){return i.some(h=>h.path===t)?t:i.find(h=>h.path===B)?.path??i[0]?.path??B}function Je(i={}){const{projectId:t}=i,[h,s]=r.useState(""),[u,S]=r.useState(!0),[k,I]=r.useState(!1),[D,j]=r.useState(!1),[p,E]=r.useState(null),[n,M]=r.useState(!0),[V,_]=r.useState(!1),[re,U]=r.useState(()=>ge({})),[w,Y]=r.useState(!0),[z,me]=r.useState(!1),[be,O]=r.useState([]),[d,x]=r.useState(!0),[f,A]=r.useState(B),[o,v]=r.useState(""),[ne,R]=r.useState(!1),[c,N]=r.useState(!1),[pe,G]=r.useState(!1),[ie,Z]=r.useState(!1),[le,X]=r.useState(!1),[K,Q]=r.useState(null),[L,$]=r.useState(!0),[xe,q]=r.useState(!1),[fe,J]=r.useState(!1),[oe,ee]=r.useState(null),{status:ce,loading:de,refresh:se}=Re({projectId:t}),te=r.useCallback(m=>{v(m),N(!0)},[]),g=r.useCallback(async m=>{R(!0);try{const{content:l}=await Me(m,t);A(m),v(l),N(!1)}finally{R(!1)}},[t]),T=r.useCallback(async()=>{x(!0);try{const{files:m}=await we(t);if(O(m),m.length===0){A(B),v(""),N(!1);return}const l=Le(m,f);l!==f&&await g(l)}finally{x(!1)}},[t,f,g]);r.useEffect(()=>{let m=!1;async function l(){try{const y=await Qe(t);m||(s(y.content),S(!1))}catch{m||(s(""),S(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Fe(t);m||(E(y.content),_(y.exists),M(!1))}catch{m||(E(null),_(!1),M(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){Y(!0);try{const y=await $e(t);m||U(ge(y))}catch{m||U(ge({}))}finally{m||Y(!1)}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){x(!0);try{const{files:y}=await we(t);if(m)return;if(O(y),y.length===0){A(B),v(""),N(!1);return}const H=Le(y,f),{content:a}=await Me(H,t);if(m)return;A(H),v(a),N(!1)}catch{m||(O([]),A(B),v(""),N(!1))}finally{m||x(!1)}}return l(),()=>{m=!0}},[t,f]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Ae(t);m||(Q(y),$(!1))}catch{m||(Q(null),$(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Be(t);m||ee(y)}catch{m||ee(null)}}return l(),()=>{m=!0}},[t]);const P=r.useCallback(m=>{s(m),I(!0)},[]),Se=r.useCallback(async()=>{if(k){j(!0);try{await qe(h,t),I(!1)}finally{j(!1)}}},[h,k,t]),ye=r.useCallback(async m=>{me(!0);try{const l=await Te(m,t);U(ge(l))}finally{me(!1)}},[t]),he=r.useCallback(async m=>{await g(m)},[g]),je=r.useCallback(async()=>{if(c){G(!0);try{await Pe(f,o,t),N(!1),await T()}finally{G(!1)}}},[o,c,f,t,T]),ve=r.useCallback(async()=>{J(!0);try{const m=await We(t);return await se(),m}finally{J(!1)}},[t,se]),Ne=r.useCallback(async m=>He(m,t),[t]),ae=r.useCallback(async()=>{try{const m=await Ae(t);Q(m)}catch{Q(null)}},[t]),W=r.useCallback(async()=>{try{const m=await Fe(t);E(m.content),_(m.exists)}catch{E(null),_(!1)}},[t]),Ce=r.useCallback(async m=>{await _e(m,t),await W()},[t,W]),ke=r.useCallback(async()=>{Z(!0);try{const m=await Ue(t);return await Promise.all([W(),ae()]),{success:m.success,summary:m.summary}}finally{Z(!1)}},[t,W,ae]),ue=r.useCallback(async()=>{X(!0);try{return await Oe(t)}finally{X(!1)}},[t]),Ee=r.useCallback(async m=>{q(!0);try{const l=m?await De(m,t):await De(t);if(m){const y=l.path??m;A(y),v(l.content),N(!1),await T();return}s(l.content),I(!0)}finally{q(!1)}},[t,T]);return{workingMemory:h,workingMemoryLoading:u,workingMemoryDirty:k,setWorkingMemory:P,saveWorkingMemory:Se,savingWorkingMemory:D,insightsContent:p,insightsLoading:n,insightsExists:V,refreshInsights:W,saveInsights:Ce,memorySettings:re,settingsLoading:w,savingMemorySettings:z,saveMemorySettings:ye,memoryFiles:be,memoryFilesLoading:d,selectedFilePath:f,selectedFileContent:o,selectedFileLoading:ne,selectedFileDirty:c,setSelectedFileContent:te,selectFile:he,saveSelectedFile:je,savingSelectedFile:pe,reloadMemoryFiles:T,backendStatus:ce,backendLoading:de,extractInsights:ke,extracting:ie,triggerDreamNow:ue,dreamRunning:le,auditReport:K,auditLoading:L,refreshAudit:ae,compactMemory:Ee,compacting:xe,installQmdAction:ve,installingQmd:fe,testRetrieval:Ne,stats:oe}}const es={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},ss=72;function ts(i,t){if(i.length<=t)return i;const h=Math.max(1,t-1),s=Math.ceil(h/2),u=Math.floor(h/2);return`${i.slice(0,s)}…${i.slice(i.length-u)}`}function as(i){const t=`${i.label} — ${i.path}`;return ts(t,ss)}function rs(i){if(!i)return[];const t=[],h=i.split(/(?=^## )/m);for(const s of h){const u=s.trim();if(!u)continue;const S=u.match(/^##\s+(.+?)(\n|$)/);if(S){const k=S[1].trim(),I=es[k]??k.toLowerCase(),D=u.slice(S[0].length).trim(),j=D.split(`
1
+ import{r,j as e}from"./vendor-react-SZ_qB27O.js";import{u as Re}from"./SettingsModal-DihNd7g8.js";import{aS as Me,aT as we,aU as qe,aV as Te,aW as Pe,aX as We,aY as He,aZ as Ae,a_ as Fe,a$ as _e,b0 as Ue,b1 as Oe,b2 as De,b3 as Qe,aR as $e,b4 as Be,V as Ve,b5 as Ye,L as F,b6 as ze}from"./index-CHy0WNjH.js";import{u as Ge}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const B=".fusion/memory/MEMORY.md",Ze=5e4,Xe="0 3 * * *",Ke="0 4 * * *";function ge(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??Ze,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??Xe,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??Ke}}function Le(i,t){return i.some(h=>h.path===t)?t:i.find(h=>h.path===B)?.path??i[0]?.path??B}function Je(i={}){const{projectId:t}=i,[h,s]=r.useState(""),[u,S]=r.useState(!0),[k,I]=r.useState(!1),[D,j]=r.useState(!1),[p,E]=r.useState(null),[n,M]=r.useState(!0),[V,_]=r.useState(!1),[re,U]=r.useState(()=>ge({})),[w,Y]=r.useState(!0),[z,me]=r.useState(!1),[be,O]=r.useState([]),[d,x]=r.useState(!0),[f,A]=r.useState(B),[o,v]=r.useState(""),[ne,R]=r.useState(!1),[c,N]=r.useState(!1),[pe,G]=r.useState(!1),[ie,Z]=r.useState(!1),[le,X]=r.useState(!1),[K,Q]=r.useState(null),[L,$]=r.useState(!0),[xe,q]=r.useState(!1),[fe,J]=r.useState(!1),[oe,ee]=r.useState(null),{status:ce,loading:de,refresh:se}=Re({projectId:t}),te=r.useCallback(m=>{v(m),N(!0)},[]),g=r.useCallback(async m=>{R(!0);try{const{content:l}=await Me(m,t);A(m),v(l),N(!1)}finally{R(!1)}},[t]),T=r.useCallback(async()=>{x(!0);try{const{files:m}=await we(t);if(O(m),m.length===0){A(B),v(""),N(!1);return}const l=Le(m,f);l!==f&&await g(l)}finally{x(!1)}},[t,f,g]);r.useEffect(()=>{let m=!1;async function l(){try{const y=await Qe(t);m||(s(y.content),S(!1))}catch{m||(s(""),S(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Fe(t);m||(E(y.content),_(y.exists),M(!1))}catch{m||(E(null),_(!1),M(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){Y(!0);try{const y=await $e(t);m||U(ge(y))}catch{m||U(ge({}))}finally{m||Y(!1)}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){x(!0);try{const{files:y}=await we(t);if(m)return;if(O(y),y.length===0){A(B),v(""),N(!1);return}const H=Le(y,f),{content:a}=await Me(H,t);if(m)return;A(H),v(a),N(!1)}catch{m||(O([]),A(B),v(""),N(!1))}finally{m||x(!1)}}return l(),()=>{m=!0}},[t,f]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Ae(t);m||(Q(y),$(!1))}catch{m||(Q(null),$(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Be(t);m||ee(y)}catch{m||ee(null)}}return l(),()=>{m=!0}},[t]);const P=r.useCallback(m=>{s(m),I(!0)},[]),Se=r.useCallback(async()=>{if(k){j(!0);try{await qe(h,t),I(!1)}finally{j(!1)}}},[h,k,t]),ye=r.useCallback(async m=>{me(!0);try{const l=await Te(m,t);U(ge(l))}finally{me(!1)}},[t]),he=r.useCallback(async m=>{await g(m)},[g]),je=r.useCallback(async()=>{if(c){G(!0);try{await Pe(f,o,t),N(!1),await T()}finally{G(!1)}}},[o,c,f,t,T]),ve=r.useCallback(async()=>{J(!0);try{const m=await We(t);return await se(),m}finally{J(!1)}},[t,se]),Ne=r.useCallback(async m=>He(m,t),[t]),ae=r.useCallback(async()=>{try{const m=await Ae(t);Q(m)}catch{Q(null)}},[t]),W=r.useCallback(async()=>{try{const m=await Fe(t);E(m.content),_(m.exists)}catch{E(null),_(!1)}},[t]),Ce=r.useCallback(async m=>{await _e(m,t),await W()},[t,W]),ke=r.useCallback(async()=>{Z(!0);try{const m=await Ue(t);return await Promise.all([W(),ae()]),{success:m.success,summary:m.summary}}finally{Z(!1)}},[t,W,ae]),ue=r.useCallback(async()=>{X(!0);try{return await Oe(t)}finally{X(!1)}},[t]),Ee=r.useCallback(async m=>{q(!0);try{const l=m?await De(m,t):await De(t);if(m){const y=l.path??m;A(y),v(l.content),N(!1),await T();return}s(l.content),I(!0)}finally{q(!1)}},[t,T]);return{workingMemory:h,workingMemoryLoading:u,workingMemoryDirty:k,setWorkingMemory:P,saveWorkingMemory:Se,savingWorkingMemory:D,insightsContent:p,insightsLoading:n,insightsExists:V,refreshInsights:W,saveInsights:Ce,memorySettings:re,settingsLoading:w,savingMemorySettings:z,saveMemorySettings:ye,memoryFiles:be,memoryFilesLoading:d,selectedFilePath:f,selectedFileContent:o,selectedFileLoading:ne,selectedFileDirty:c,setSelectedFileContent:te,selectFile:he,saveSelectedFile:je,savingSelectedFile:pe,reloadMemoryFiles:T,backendStatus:ce,backendLoading:de,extractInsights:ke,extracting:ie,triggerDreamNow:ue,dreamRunning:le,auditReport:K,auditLoading:L,refreshAudit:ae,compactMemory:Ee,compacting:xe,installQmdAction:ve,installingQmd:fe,testRetrieval:Ne,stats:oe}}const es={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},ss=72;function ts(i,t){if(i.length<=t)return i;const h=Math.max(1,t-1),s=Math.ceil(h/2),u=Math.floor(h/2);return`${i.slice(0,s)}…${i.slice(i.length-u)}`}function as(i){const t=`${i.label} — ${i.path}`;return ts(t,ss)}function rs(i){if(!i)return[];const t=[],h=i.split(/(?=^## )/m);for(const s of h){const u=s.trim();if(!u)continue;const S=u.match(/^##\s+(.+?)(\n|$)/);if(S){const k=S[1].trim(),I=es[k]??k.toLowerCase(),D=u.slice(S[0].length).trim(),j=D.split(`
2
2
  `).map(p=>p.replace(/^-\s+/,"").trim()).filter(p=>p.length>0&&(p.startsWith("- ")||p.startsWith("* ")));(j.length>0||D.length>0)&&t.push({name:k,key:I,items:j.length>0?j:D.length>0?[D]:[],expanded:!0})}}return t}function ms(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 ns(i){return i.reduce((t,h)=>t+h.items.length,0)}function us({projectId:i,addToast:t,onSendSelectionToTask:h}){const{t:s}=Ge("app"),[u,S]=r.useState("working"),[k,I]=r.useState(new Set),[D,j]=r.useState(!1),[p,E]=r.useState(null),[n,M]=r.useState({memoryEnabled:!0,memoryAutoSummarizeEnabled:!1,memoryAutoSummarizeThresholdChars:5e4,memoryAutoSummarizeSchedule:"0 3 * * *",memoryDreamsEnabled:!1,memoryDreamsSchedule:"0 4 * * *"}),[V,_]=r.useState(""),[re,U]=r.useState(!1),[w,Y]=r.useState(null),{insightsContent:z,insightsLoading:me,insightsExists:be,saveInsights:O,memorySettings:d,settingsLoading:x,saveMemorySettings:f,savingMemorySettings:A,backendStatus:o,backendLoading:v,extractInsights:ne,extracting:R,auditReport:c,auditLoading:N,refreshAudit:pe,compactMemory:G,compacting:ie,installQmdAction:Z,installingQmd:le,testRetrieval:X,memoryFiles:K,memoryFilesLoading:Q,selectedFilePath:L,selectedFileContent:$,selectedFileLoading:xe,selectedFileDirty:q,setSelectedFileContent:fe,selectFile:J,saveSelectedFile:oe,savingSelectedFile:ee,reloadMemoryFiles:ce,triggerDreamNow:de,dreamRunning:se}=Je({projectId:i});r.useEffect(()=>{M(d)},[d]);const te=r.useMemo(()=>n.memoryEnabled!==d.memoryEnabled||n.memoryAutoSummarizeEnabled!==d.memoryAutoSummarizeEnabled||n.memoryAutoSummarizeThresholdChars!==d.memoryAutoSummarizeThresholdChars||n.memoryAutoSummarizeSchedule!==d.memoryAutoSummarizeSchedule||n.memoryDreamsEnabled!==d.memoryDreamsEnabled||n.memoryDreamsSchedule!==d.memoryDreamsSchedule,[n,d]),g=r.useMemo(()=>K.find(a=>a.path===L),[K,L]),T=g?g.layer==="long-term"?s("memory.layerDescLongTerm","Curated durable decisions, conventions, constraints, and pitfalls promoted from dreams."):g.layer==="daily"?s("memory.layerDescDaily","Raw daily observations, open loops, and running context for dream processing."):s("memory.layerDescDreams","Synthesized patterns and open loops promoted from daily memory."):s("memory.editorDefaultDescription","Edits the selected memory file."),P=r.useMemo(()=>rs(z),[z]),Se=r.useMemo(()=>ns(P),[P]),ye=r.useMemo(()=>ms(z),[z]),he=r.useCallback(a=>{I(b=>{const C=new Set(b);return C.has(a)?C.delete(a):C.add(a),C})},[]),je=r.useCallback(async a=>{try{await J(a)}catch{t(s("memory.loadFileFailed","Failed to load memory file"),"error")}},[J,t]),ve=r.useCallback(async()=>{try{await oe(),t(s("memory.memorySaved","Memory saved"),"success")}catch{t(s("memory.saveMemoryFailed","Failed to save memory"),"error")}},[oe,t]),Ne=r.useCallback(async()=>{if(!te)return;const a={};n.memoryEnabled!==d.memoryEnabled&&(a.memoryEnabled=n.memoryEnabled),n.memoryAutoSummarizeEnabled!==d.memoryAutoSummarizeEnabled&&(a.memoryAutoSummarizeEnabled=n.memoryAutoSummarizeEnabled),n.memoryAutoSummarizeThresholdChars!==d.memoryAutoSummarizeThresholdChars&&(a.memoryAutoSummarizeThresholdChars=n.memoryAutoSummarizeThresholdChars),n.memoryAutoSummarizeSchedule!==d.memoryAutoSummarizeSchedule&&(a.memoryAutoSummarizeSchedule=n.memoryAutoSummarizeSchedule),n.memoryDreamsEnabled!==d.memoryDreamsEnabled&&(a.memoryDreamsEnabled=n.memoryDreamsEnabled),n.memoryDreamsSchedule!==d.memoryDreamsSchedule&&(a.memoryDreamsSchedule=n.memoryDreamsSchedule);try{await f(a),t(s("memory.settingsSaved","Memory settings saved"),"success")}catch{t(s("memory.saveSettingsFailed","Failed to save memory settings"),"error")}},[te,n,d,f,t]),ae=r.useCallback(async()=>{try{const a=await Z();t(a.qmdAvailable?s("memory.qmdInstallSuccess","qmd installed successfully"):s("memory.qmdInstallUnavailable","qmd install finished, but qmd is still unavailable"),a.qmdAvailable?"success":"info")}catch{t(s("memory.installQmdFailed","Failed to install qmd"),"error")}},[Z,t]),W=r.useCallback(async()=>{U(!0),Y(null);try{const a=await X(V);Y(a),t(a.qmdAvailable?s("memory.retrievalTestComplete","Memory retrieval test complete"):s("memory.retrievalTestFallback","qmd is not installed; local fallback was used"),a.qmdAvailable?"success":"info")}catch{t(s("memory.retrievalTestFailed","Failed to test memory retrieval"),"error")}finally{U(!1)}},[V,X,t]),Ce=r.useCallback(async()=>{try{await de(),t(s("memory.dreamProcessingComplete","Dream processing completed"),"success"),await ce()}catch(a){t(a instanceof Error?a.message:s("memory.dreamProcessingFailed","Failed to run dream processing"),"error")}},[de,ce,t]),ke=r.useCallback(async()=>{try{await G(L),t(s("memory.fileCompacted","Memory file compacted"),"success")}catch{t(s("memory.compactFailed","Failed to compact memory"),"error")}},[G,L,t]),ue=r.useCallback(async()=>{try{const a=await ne();t(a.summary,"success")}catch(a){t(a instanceof Error?a.message:s("memory.extractInsightsFailed","Failed to extract insights"),"error")}},[ne,t]),Ee=r.useCallback(async()=>{if(p!==null)try{await O(p),j(!1),E(null),t(s("memory.insightsSaved","Insights saved"),"success")}catch{t(s("memory.saveInsightsFailed","Failed to save insights"),"error")}},[p,O,t]),m=r.useCallback(()=>{E(z??""),j(!0)},[z]),l=r.useCallback(()=>{j(!1),E(null)},[]),y=!v&&o!==null,H=o?.capabilities?.writable??!1;return e.jsxs("div",{className:"memory-view",children:[e.jsx(Ve,{icon:Ye,title:s("memory.title","Memory")}),e.jsxs("div",{className:"memory-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":u==="working",className:`memory-view-tab${u==="working"?" memory-view-tab--active":""}`,onClick:()=>S("working"),"data-testid":"memory-tab-working",children:s("memory.tabWorking","Working Memory")}),e.jsx("button",{type:"button",role:"tab","aria-selected":u==="insights",className:`memory-view-tab${u==="insights"?" memory-view-tab--active":""}`,onClick:()=>S("insights"),"data-testid":"memory-tab-insights",children:s("memory.tabInsights","Insights")}),e.jsx("button",{type:"button",role:"tab","aria-selected":u==="engines",className:`memory-view-tab${u==="engines"?" memory-view-tab--active":""}`,onClick:()=>S("engines"),"data-testid":"memory-tab-engines",children:s("memory.tabEngines","Engines")})]}),e.jsxs("div",{className:"memory-view-content",children:[u==="working"&&e.jsxs("div",{className:"memory-working-tab",children:[y&&!H&&e.jsx("div",{className:"memory-readonly-banner",children:s("memory.readOnlyBanner","This memory backend is read-only. Changes cannot be saved.")}),Q||xe?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(F,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingFile","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:s("memory.fileLabel","Memory File")}),e.jsx("select",{id:"memoryViewFilePath",className:"select",value:L,onChange:a=>{je(a.target.value)},disabled:q,children:K.map(a=>e.jsx("option",{value:a.path,title:`${a.label} — ${a.path}`,children:as(a)},a.path))}),e.jsx("small",{children:q?s("memory.fileSwitchDirtyHint","Save or discard the current edits before switching files."):s("memory.fileSwitchHint","Choose any project memory file to view or edit.")})]}),g&&e.jsxs("div",{className:"memory-file-summary",children:[e.jsx("span",{children:g.layer==="long-term"?s("memory.layerLongTerm","Long-term"):g.layer==="daily"?s("memory.layerDaily","Daily"):s("memory.layerDreams","Dreams")}),e.jsx("strong",{children:g.path}),e.jsx("small",{children:s("memory.fileSummary","{{size}} bytes · updated {{updatedAt}}",{size:g.size.toLocaleString(),updatedAt:new Date(g.updatedAt).toLocaleString()})})]}),e.jsxs("div",{className:"form-group memory-editor-form-group",children:[e.jsx("label",{children:g?.label||s("memory.editorLabel","Memory Editor")}),e.jsx("small",{children:T}),e.jsx("div",{className:"memory-editor-container",children:e.jsx(ze,{content:$,onChange:fe,readOnly:!H,filePath:L,onSendSelectionToTask:h})})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("span",{className:"memory-char-count",children:s("memory.charCount","{{count}} characters",{count:$.length})}),e.jsx("div",{className:"memory-flex-spacer"}),H&&$.length>0&&e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ke,disabled:ie||q,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.compacting","Compacting…")]}):s("memory.compactSelectedFile","Compact Selected File")}),q&&H&&e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:ve,disabled:ee,children:ee?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.saving","Saving…")]}):s("memory.save","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:n.memoryDreamsEnabled,onChange:a=>{M(b=>({...b,memoryDreamsEnabled:a.target.checked}))},disabled:!n.memoryEnabled||x}),s("memory.dreamsEnabledLabel","Process dreams from daily memory")]}),e.jsx("small",{children:s("memory.dreamsEnabledHint","Turns daily notes into DREAMS.md and promotes reusable lessons into MEMORY.md.")})]}),n.memoryEnabled&&n.memoryDreamsEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryDreamsSchedule",children:s("memory.dreamsScheduleLabel","Dream Schedule")}),e.jsx("input",{id:"memoryDreamsSchedule",type:"text",className:"input",value:n.memoryDreamsSchedule,onChange:a=>{M(b=>({...b,memoryDreamsSchedule:a.target.value}))},placeholder:"0 4 * * *",disabled:x}),e.jsx("small",{children:s("memory.dreamsScheduleHint","Cron expression for dream processing.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:Ce,disabled:se||!n.memoryDreamsEnabled,children:se?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.dreaming","Dreaming…")]}):s("memory.dreamNow","Dream Now")}),e.jsx("small",{children:s("memory.dreamNowHint","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:n.memoryAutoSummarizeEnabled,onChange:a=>{M(b=>({...b,memoryAutoSummarizeEnabled:a.target.checked}))},disabled:!n.memoryEnabled||x}),s("memory.autoSummarizeLabel","Auto-Summarize Memory")]}),e.jsx("small",{children:s("memory.autoSummarizeHint","Automatically compact memory when it exceeds the threshold on a schedule")})]}),n.memoryEnabled&&n.memoryAutoSummarizeEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeThresholdChars",children:s("memory.compactionThresholdLabel","Compaction Threshold (chars)")}),e.jsx("input",{id:"memoryAutoSummarizeThresholdChars",type:"number",className:"input",value:n.memoryAutoSummarizeThresholdChars,onChange:a=>{M(b=>({...b,memoryAutoSummarizeThresholdChars:parseInt(a.target.value,10)||5e4}))},min:1e3,disabled:x}),e.jsx("small",{children:s("memory.compactionThresholdHint","Memory will be compacted when it exceeds this character count")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeSchedule",children:s("memory.autoSummarizeScheduleLabel","Schedule (cron)")}),e.jsx("input",{id:"memoryAutoSummarizeSchedule",type:"text",className:"input",value:n.memoryAutoSummarizeSchedule,onChange:a=>{M(b=>({...b,memoryAutoSummarizeSchedule:a.target.value}))},placeholder:"0 3 * * *",disabled:x}),e.jsx("small",{children:s("memory.autoSummarizeScheduleHint","Cron expression for auto-summarize schedule (default: daily at 3 AM)")})]})]})]}),!n.memoryEnabled&&e.jsx("div",{className:"settings-empty-state memory-status-message",children:s("memory.disabledMessage","Memory is currently disabled. Enable memory tools in Settings to edit these automations.")}),te&&e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ne,disabled:A||x,children:A?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.saving","Saving…")]}):s("memory.saveSettings","Save Settings")})})]})]})]}),u==="insights"&&e.jsx("div",{className:"memory-insights-tab",children:me?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(F,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingInsights","Loading insights…")})]}):D?e.jsxs("div",{className:"memory-insights-editor-layout",children:[e.jsx("div",{className:"memory-editor-container",children:e.jsx(ze,{content:p??"",onChange:E,readOnly:!1,filePath:".fusion/memory/INSIGHTS.md",onSendSelectionToTask:h})}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:l,children:s("memory.cancel","Cancel")}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ee,children:s("memory.saveInsights","Save Insights")})]})]}):!be||P.length===0?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx("p",{children:s("memory.noInsights","No insights extracted yet.")}),e.jsx("p",{children:s("memory.noInsightsHint",'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:ue,disabled:R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.extracting","Extracting…")]}):s("memory.extractNow","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:Se}),e.jsx("div",{className:"memory-stat-label",children:s("memory.totalInsights","Total Insights")})]}),e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:P.length}),e.jsx("div",{className:"memory-stat-label",children:s("memory.categories","Categories")})]}),ye&&e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value memory-stat-value--updated",children:ye}),e.jsx("div",{className:"memory-stat-label",children:s("memory.lastUpdated","Last Updated")})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:ue,disabled:R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.extracting","Extracting…")]}):s("memory.extractNow","Extract Now")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:m,children:s("memory.editRaw","Edit Raw")})]}),e.jsx("div",{className:"memory-categories-list",children:P.map(a=>{const b=!k.has(a.key);return e.jsxs("div",{className:"memory-category-section",children:[e.jsxs("div",{className:"memory-category-header",onClick:()=>he(a.key),role:"button",tabIndex:0,onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),he(a.key))},children:[e.jsx("h4",{children:a.name}),e.jsx("span",{className:"memory-category-count",children:a.items.length})]}),b&&e.jsx("div",{className:"memory-category-items",children:a.items.map((C,Ie)=>e.jsx("div",{className:"memory-insight-item",children:C.replace(/^-\s+/,"").replace(/^\*\s+/,"")},Ie))})]},a.key)})})]})}),u==="engines"&&e.jsx("div",{className:"memory-engines-tab",children:v||N?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(F,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingEngineStatus","Loading engine status…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-engine-card memory-qmd-card",children:[e.jsx("h3",{children:s("memory.qmdIntegrationTitle","QMD Integration")}),o?.qmdAvailable===!0?e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge memory-health-badge--healthy",children:s("memory.qmdInstalled","Installed")}),e.jsx("span",{className:"memory-char-count",children:s("memory.qmdAvailableOnPath","qmd is available on PATH.")})]}):o?.qmdAvailable===!1?e.jsxs("div",{className:"settings-empty-state memory-status-message",children:[e.jsxs("span",{children:[s("memory.qmdNotInstalled","qmd is not installed. Search will use local files. Install indexed retrieval:")," ",e.jsx("code",{children:o.qmdInstallCommand||"bun install -g @tobilu/qmd"})]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ae,disabled:le,children:le?s("memory.installing","Installing…"):s("memory.installQmd","Install qmd")})]}):e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge",children:s("memory.qmdChecking","Checking")}),e.jsx("span",{className:"memory-char-count",children:s("memory.qmdCheckingAvailability","Checking qmd availability…")})]}),e.jsxs("div",{className:"memory-capability-row",children:[o?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capReadable","Readable")}),o?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capWritable","Writable")}),o?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capAtomicWrites","Atomic Writes")}),o?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capPersistent","Persistent")})]})]}),e.jsxs("div",{className:"memory-engine-card memory-retrieval-card",children:[e.jsx("h3",{children:s("memory.testMemorySearchTitle","Test Memory Search")}),e.jsxs("div",{className:"memory-retrieval-input-row",children:[e.jsx("input",{type:"text",className:"input",value:V,onChange:a=>_(a.target.value),placeholder:s("memory.searchPlaceholder","Search memory with qmd")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:W,disabled:re,children:re?s("memory.testing","Testing…"):s("memory.testRetrieval","Test Retrieval")})]}),e.jsx("small",{className:"settings-muted",children:s("memory.testSearchHint","Runs the same qmd-backed memory_search path agents use.")}),w&&e.jsxs("div",{className:"memory-test-result",children:[e.jsx("strong",{children:s("memory.testResultCount",'{{count}} result for "{{query}}"',{count:w.results.length,query:w.query,defaultValue_one:'{{count}} result for "{{query}}"',defaultValue_other:'{{count}} results for "{{query}}"'})}),e.jsx("small",{children:s("memory.testResultStatus","qmd {{qmdStatus}} · {{fallbackStatus}}",{qmdStatus:w.qmdAvailable?s("memory.qmdStatusAvailable","available"):s("memory.qmdStatusMissing","missing"),fallbackStatus:w.usedFallback?s("memory.localFallbackUsed","local fallback used"):s("memory.qmdPathUsed","qmd path used")})}),w.results.length>0?e.jsx("ul",{children:w.results.map((a,b)=>e.jsxs("li",{children:[e.jsxs("span",{children:[a.path,":",a.lineStart]}),e.jsx("p",{children:a.snippet})]},`${a.path}-${a.lineStart}-${b}`))}):e.jsx("small",{children:s("memory.noMatchingMemory","No matching memory found.")})]})]}),e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:s("memory.currentBackendTitle","Current Backend")}),e.jsx("div",{className:"memory-engine-status",children:e.jsx("span",{className:"memory-emphasis-text",children:o?.currentBackend==="file"?s("memory.backendFile","File (.fusion/memory/, agent/<agent-name>/memory/)"):o?.currentBackend==="readonly"?s("memory.backendReadonly","Read-Only"):o?.currentBackend==="qmd"?s("memory.backendQmd","QMD (Quantized Memory Distillation)"):o?.currentBackend??"unknown"})}),e.jsxs("div",{className:"memory-capability-row",children:[o?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capReadable","Readable")}),o?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capWritable","Writable")}),o?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capAtomicWrites","Atomic Writes")}),o?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capPersistent","Persistent")})]})]}),c&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsxs("div",{className:"memory-health-header",children:[e.jsx("h3",{children:s("memory.healthStatusTitle","Health Status")}),e.jsx("span",{className:`memory-health-badge memory-health-badge--${c.health}`,children:c.health==="healthy"?s("memory.healthHealthy","Healthy"):c.health==="warning"?s("memory.healthWarning","Warning"):s("memory.healthIssues","Issues Found")})]}),e.jsxs("div",{className:"memory-health-grid",children:[e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:s("memory.workingMemoryLabel","Working Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:s("memory.sizeChars","{{size}} chars",{size:c.workingMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:s("memory.sectionCount","{{count}} sections",{count:c.workingMemory.sectionCount})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:s("memory.insightsMemoryLabel","Insights Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:s("memory.sizeChars","{{size}} chars",{size:c.insightsMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:s("memory.insightCount","{{count}} insights",{count:c.insightsMemory.insightCount})})]})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:s("memory.lastExtractionLabel","Last Extraction")}),e.jsx("div",{className:"memory-emphasis-text",children:c.extraction.success?e.jsx("span",{className:"memory-status-text memory-status-text--success",children:s("memory.extractionSuccess","Success")}):e.jsx("span",{className:"memory-status-text memory-status-text--error",children:s("memory.extractionFailed","Failed")})}),e.jsx("div",{className:"memory-health-detail",children:c.extraction.summary||s("memory.insightsExtracted","{{count}} insights extracted",{count:c.extraction.insightCount})})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:s("memory.pruningLabel","Pruning")}),e.jsx("div",{className:"memory-emphasis-text",children:c.pruning.applied?e.jsx("span",{className:"memory-status-text memory-status-text--warning",children:s("memory.pruningApplied","Applied")}):e.jsx("span",{className:"memory-status-text memory-status-text--muted",children:s("memory.pruningNotNeeded","Not needed")})}),c.pruning.applied&&e.jsx("div",{className:"memory-health-detail",children:c.pruning.reason})]})]}),c&&c.checks.length>0&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:s("memory.auditChecksTitle","Audit Checks")}),e.jsx("div",{children:c.checks.map(a=>e.jsxs("div",{className:"memory-audit-check",children:[e.jsx("span",{className:a.passed?"memory-audit-check-passed":"memory-audit-check-failed",children:a.passed?"✓":"✗"}),e.jsxs("div",{className:"memory-audit-check-content",children:[e.jsx("div",{className:"memory-emphasis-text",children:a.name}),e.jsx("div",{className:"memory-health-detail",children:a.details})]})]},a.id))})]}),e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:()=>pe(),children:s("memory.runAudit","Run Audit")})}),e.jsxs("div",{className:"memory-settings-note",children:[e.jsx("span",{children:s("memory.settingsNote","Note: Change backend type in")}),e.jsx("button",{type:"button",className:"memory-settings-note-button",onClick:()=>{t(s("memory.settingsNoteToast","Open Settings → Memory to change backend type"),"info")},children:s("memory.settingsNoteLink","Settings → Memory")})]})]})})]})]})}export{us as MemoryView};
@@ -1,11 +1,11 @@
1
- import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as G,bu as Y,bv as Z,bw as T,R as L,ak as D,am as y,P as ee,n as se,C as ae,I as ie,aI as B,bx as ne,by as te,bz as I,X as re}from"./index-ccFe_1av.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import{B as _}from"./AgentPermissionPolicyEditor-DE0wv8-L.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as H,bv as Y,bw as Z,bx as T,R as L,al as D,an as y,P as ee,o as se,C as ae,J as ie,aJ as B,by as ne,bz as te,bA as _,X as re}from"./index-CHy0WNjH.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import{B as $}from"./AgentPermissionPolicyEditor-DFldf6aS.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const ce=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],$=G("palette",ce);/**
6
+ */const ce=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],A=H("palette",ce);/**
7
7
  * @license lucide-react v1.7.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const oe=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],A=G("puzzle",oe);function de(n){return n.replace(/-/g,"-")}function pe(n){return{"fusion-global":"Fusion Global","pi-global":"Pi Global","fusion-project":"Fusion Project","pi-project":"Pi Project",package:"Package"}[n]??n}function xe(n){return n.startsWith("npm:")?"npm":n.startsWith("git:")?"git":"local"}function ge(n){return n.replace(/^(npm:|git:)/,"")}function ve({addToast:n,projectId:x}){const{t:a}=le("app"),[c,H]=l.useState(null),[N,P]=l.useState(!0),[b,E]=l.useState(!1),[S,F]=l.useState(!1),[h,w]=l.useState(""),[O,W]=l.useState(new Set),[m,q]=l.useState([]),[v,R]=l.useState(!0),[K,C]=l.useState(!1),o=l.useCallback(async()=>{try{P(!0);const s=await Y();H(s)}catch(s){n(a("piManager.loadSettingsFailed","Failed to load Pi settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{P(!1)}},[n,a]),g=l.useCallback(async()=>{try{R(!0);const s=await Z(x);q(s.extensions)}catch(s){n(a("piManager.loadExtensionsFailed","Failed to load extensions: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{R(!1)}},[n,x,a]),U=l.useCallback(async s=>{try{C(!0);const t=s.enabled?[...m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id),s.id]:m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id);await T(t,x),await g(),n(s.enabled?a("piManager.extensionDisabled","Extension disabled"):a("piManager.extensionEnabled","Extension enabled"),"success")}catch(t){n(a("piManager.updateFailed","Failed to update extension: {{error}}",{error:t instanceof Error?t.message:String(t)}),"error")}finally{C(!1)}},[m,x,g,n,a]);l.useEffect(()=>{o()},[o]),l.useEffect(()=>{g()},[g]);const X=s=>{W(t=>{const i=new Set(t);return i.has(s)?i.delete(s):i.add(s),i})},z=async()=>{if(!h.trim()){n(a("piManager.enterSource","Please enter a package source"),"error");return}try{E(!0),await ne(h.trim()),n(a("piManager.installSuccess","Package installed successfully"),"success"),w(""),await o()}catch(s){n(a("piManager.installFailed","Failed to install package: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{E(!1)}},J=async()=>{try{F(!0),await te(x),await Promise.all([o(),g()]),n(a("piManager.reinstallSuccess","Fusion skill reinstalled successfully"),"success")}catch(s){n(a("piManager.reinstallFailed","Failed to reinstall Fusion skill: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{F(!1)}},Q=async s=>{if(!c)return;const t=c.packages.filter(i=>(typeof i=="string"?i:i.source)!==s);try{await I({packages:t}),n(a("piManager.packageRemoved","Package removed"),"success"),await o()}catch(i){n(a("piManager.removeFailed","Failed to remove package: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},V=async(s,t)=>{if(!c)return;const i=c[s].filter(r=>r!==t);try{await I({[s]:i});const r=a(`piManager.resourceType.${s.slice(0,-1)}`,s.slice(0,-1));n(a("piManager.resourceRemoved","{{resource}} removed",{resource:r}),"success"),await o()}catch(r){n(a("piManager.updateSettingsFailed","Failed to update settings: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}},u=(s,t,i)=>!c||c[i].length===0?null:e.jsxs("div",{className:"pi-ext-section",children:[e.jsxs("div",{className:"pi-ext-section-header",children:[e.jsx(t,{size:14}),e.jsx("span",{children:s}),e.jsx("span",{className:"pi-ext-count",children:c[i].length})]}),e.jsx("div",{className:"pi-ext-resource-list",children:c[i].map((r,f)=>e.jsxs("span",{className:"pi-ext-resource-tag",children:[e.jsx("span",{className:"pi-ext-resource-path",children:r}),e.jsx("button",{className:"btn-icon touch-target pi-ext-resource-remove",onClick:()=>V(i,r),title:a("piManager.removeResource","Remove {{path}}",{path:r}),"aria-label":a("piManager.removeResource","Remove {{path}}",{path:r}),children:e.jsx(re,{})})]},f))})]});return e.jsxs("div",{className:"pi-ext-manager",children:[e.jsxs("div",{className:"pi-ext-manager-header",children:[e.jsx("h4",{className:"pi-ext-manager-title",children:a("piManager.title","Pi Extensions")}),e.jsx("div",{className:"pi-ext-manager-actions",children:e.jsx("button",{className:"btn-icon",onClick:o,title:a("piManager.refreshButton","Refresh"),disabled:N,children:e.jsx(L,{size:16,className:N?"spin":""})})})]}),N?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loading","Loading Pi settings…")})}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pi-ext-add-form",children:[e.jsxs("div",{className:"pi-ext-add-form-row",children:[e.jsx("input",{type:"text",className:"input",placeholder:a("piManager.packagePlaceholder","npm:pi-extension-name or git:https://github.com/..."),value:h,onChange:s=>w(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),z())},disabled:b}),e.jsxs("button",{className:"btn btn-primary",onClick:z,disabled:b||!h.trim(),children:[e.jsx(ee,{size:14}),b?a("piManager.installing","Installing…"):a("piManager.addButton","Add")]})]}),e.jsx("div",{className:"pi-ext-add-form-row",children:e.jsx("button",{className:"btn",onClick:J,disabled:S,children:S?a("piManager.reinstalling","Reinstalling Fusion…"):a("piManager.reinstallButton","Reinstall Fusion skill")})})]}),c.packages.length>0?e.jsx("div",{className:"pi-ext-package-list",children:c.packages.map((s,t)=>{const i=typeof s=="string"?s:s.source,r=xe(i),f=ge(i),j=typeof s=="object"&&s!==null,k=j&&(s.extensions?.length??0)>0||(s.skills?.length??0)>0||(s.prompts?.length??0)>0||(s.themes?.length??0)>0,M=O.has(t);return e.jsxs("div",{className:"pi-ext-package-card",children:[e.jsxs("div",{className:"pi-ext-package-header",children:[j&&k?e.jsx("button",{className:"pi-ext-expand-btn",onClick:()=>X(t),"aria-expanded":M,children:M?e.jsx(se,{size:14}):e.jsx(ae,{size:14})}):e.jsx("span",{className:"pi-ext-expand-placeholder"}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${r}`,children:r}),e.jsx("span",{className:"pi-ext-package-source",children:f}),e.jsxs("div",{className:"pi-ext-package-actions",children:[j&&k&&e.jsx("span",{className:"pi-ext-filter-hint",children:a("piExtensions.filterHint","{{extensions}} ext, {{skills}} skill, {{prompts}} prompt, {{themes}} theme",{extensions:s.extensions?.length??0,skills:s.skills?.length??0,prompts:s.prompts?.length??0,themes:s.themes?.length??0})}),e.jsx("button",{className:"btn-icon touch-target pi-ext-remove-btn",onClick:()=>Q(i),title:a("piManager.removePackage","Remove package"),"aria-label":a("piManager.removePackageLabel","Remove package {{label}}",{label:f}),children:e.jsx(ie,{size:14})})]})]}),j&&k&&M&&e.jsxs("div",{className:"pi-ext-filter-list",children:[s.extensions?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(A,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterExtensions","Extensions:")," "]}),s.extensions.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.skills?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(_,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterSkills","Skills:")," "]}),s.skills.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.prompts?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(B,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterPrompts","Prompts:")," "]}),s.prompts.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.themes?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx($,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterThemes","Themes:")," "]}),s.themes.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null]})]},t)})}):e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noPackages","No packages configured.")}),e.jsx("p",{className:"text-muted",children:a("piManager.noPackagesHelp","Add a package source above to get started.")})]}),e.jsxs("div",{className:"pi-ext-top-level",children:[u(a("piManager.sectionExtensions","Extensions"),A,"extensions"),u(a("piManager.sectionSkills","Skills"),_,"skills"),u(a("piManager.sectionPrompts","Prompts"),B,"prompts"),u(a("piManager.sectionThemes","Themes"),$,"themes")]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.loadingFailed","Failed to load Pi settings.")})]}),e.jsxs("div",{className:"pi-ext-discovered-section",children:[e.jsxs("div",{className:"pi-ext-discovered-header",children:[e.jsx("h4",{children:a("piManager.discoveredTitle","Discovered Extensions")}),e.jsx("button",{className:"btn-icon",onClick:g,disabled:v,title:a("piManager.refreshExtensions","Refresh extensions"),children:e.jsx(L,{className:v?"spin":""})})]}),e.jsx("p",{className:"pi-ext-description",children:a("piManager.discoveredDescription","Installed extensions resolved from packages and configured paths.")}),v?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loadingExtensions","Loading extensions…")})}):m.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noExtensions","No extensions discovered.")})]}):e.jsx("div",{className:"pi-ext-list",children:m.map(s=>e.jsxs("div",{className:"pi-ext-item",children:[e.jsxs("div",{className:"pi-ext-item-content",children:[e.jsxs("div",{className:"pi-ext-info",children:[e.jsx("span",{className:"pi-ext-name",children:s.name}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${de(s.source)}`,children:pe(s.source)})]}),e.jsx("span",{className:"pi-ext-path",children:s.path})]}),e.jsx("div",{className:"pi-ext-actions",children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>void U(s),disabled:K,"aria-label":a("piManager.toggleExtension","Toggle {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]})})]},s.id))})]})]})}export{ve as PiExtensionsManager};
11
+ */const oe=[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]],G=H("puzzle",oe);function de(n){return n.replace(/-/g,"-")}function pe(n){return{"fusion-global":"Fusion Global","pi-global":"Pi Global","fusion-project":"Fusion Project","pi-project":"Pi Project",package:"Package"}[n]??n}function xe(n){return n.startsWith("npm:")?"npm":n.startsWith("git:")?"git":"local"}function ge(n){return n.replace(/^(npm:|git:)/,"")}function ve({addToast:n,projectId:x}){const{t:a}=le("app"),[c,I]=l.useState(null),[N,P]=l.useState(!0),[b,E]=l.useState(!1),[S,F]=l.useState(!1),[h,w]=l.useState(""),[J,O]=l.useState(new Set),[m,W]=l.useState([]),[v,R]=l.useState(!0),[q,C]=l.useState(!1),o=l.useCallback(async()=>{try{P(!0);const s=await Y();I(s)}catch(s){n(a("piManager.loadSettingsFailed","Failed to load Pi settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{P(!1)}},[n,a]),g=l.useCallback(async()=>{try{R(!0);const s=await Z(x);W(s.extensions)}catch(s){n(a("piManager.loadExtensionsFailed","Failed to load extensions: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{R(!1)}},[n,x,a]),K=l.useCallback(async s=>{try{C(!0);const t=s.enabled?[...m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id),s.id]:m.filter(i=>i.enabled&&i.id!==s.id).map(i=>i.id);await T(t,x),await g(),n(s.enabled?a("piManager.extensionDisabled","Extension disabled"):a("piManager.extensionEnabled","Extension enabled"),"success")}catch(t){n(a("piManager.updateFailed","Failed to update extension: {{error}}",{error:t instanceof Error?t.message:String(t)}),"error")}finally{C(!1)}},[m,x,g,n,a]);l.useEffect(()=>{o()},[o]),l.useEffect(()=>{g()},[g]);const U=s=>{O(t=>{const i=new Set(t);return i.has(s)?i.delete(s):i.add(s),i})},z=async()=>{if(!h.trim()){n(a("piManager.enterSource","Please enter a package source"),"error");return}try{E(!0),await ne(h.trim()),n(a("piManager.installSuccess","Package installed successfully"),"success"),w(""),await o()}catch(s){n(a("piManager.installFailed","Failed to install package: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{E(!1)}},X=async()=>{try{F(!0),await te(x),await Promise.all([o(),g()]),n(a("piManager.reinstallSuccess","Fusion skill reinstalled successfully"),"success")}catch(s){n(a("piManager.reinstallFailed","Failed to reinstall Fusion skill: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{F(!1)}},Q=async s=>{if(!c)return;const t=c.packages.filter(i=>(typeof i=="string"?i:i.source)!==s);try{await _({packages:t}),n(a("piManager.packageRemoved","Package removed"),"success"),await o()}catch(i){n(a("piManager.removeFailed","Failed to remove package: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},V=async(s,t)=>{if(!c)return;const i=c[s].filter(r=>r!==t);try{await _({[s]:i});const r=a(`piManager.resourceType.${s.slice(0,-1)}`,s.slice(0,-1));n(a("piManager.resourceRemoved","{{resource}} removed",{resource:r}),"success"),await o()}catch(r){n(a("piManager.updateSettingsFailed","Failed to update settings: {{error}}",{error:r instanceof Error?r.message:String(r)}),"error")}},u=(s,t,i)=>!c||c[i].length===0?null:e.jsxs("div",{className:"pi-ext-section",children:[e.jsxs("div",{className:"pi-ext-section-header",children:[e.jsx(t,{size:14}),e.jsx("span",{children:s}),e.jsx("span",{className:"pi-ext-count",children:c[i].length})]}),e.jsx("div",{className:"pi-ext-resource-list",children:c[i].map((r,f)=>e.jsxs("span",{className:"pi-ext-resource-tag",children:[e.jsx("span",{className:"pi-ext-resource-path",children:r}),e.jsx("button",{className:"btn-icon touch-target pi-ext-resource-remove",onClick:()=>V(i,r),title:a("piManager.removeResource","Remove {{path}}",{path:r}),"aria-label":a("piManager.removeResource","Remove {{path}}",{path:r}),children:e.jsx(re,{})})]},f))})]});return e.jsxs("div",{className:"pi-ext-manager",children:[e.jsxs("div",{className:"pi-ext-manager-header",children:[e.jsx("h4",{className:"pi-ext-manager-title",children:a("piManager.title","Pi Extensions")}),e.jsx("div",{className:"pi-ext-manager-actions",children:e.jsx("button",{className:"btn-icon",onClick:o,title:a("piManager.refreshButton","Refresh"),disabled:N,children:e.jsx(L,{size:16,className:N?"spin":""})})})]}),N?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loading","Loading Pi settings…")})}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"pi-ext-add-form",children:[e.jsxs("div",{className:"pi-ext-add-form-row",children:[e.jsx("input",{type:"text",className:"input",placeholder:a("piManager.packagePlaceholder","npm:pi-extension-name or git:https://github.com/..."),value:h,onChange:s=>w(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),z())},disabled:b}),e.jsxs("button",{className:"btn btn-primary",onClick:z,disabled:b||!h.trim(),children:[e.jsx(ee,{size:14}),b?a("piManager.installing","Installing…"):a("piManager.addButton","Add")]})]}),e.jsx("div",{className:"pi-ext-add-form-row",children:e.jsx("button",{className:"btn",onClick:X,disabled:S,children:S?a("piManager.reinstalling","Reinstalling Fusion…"):a("piManager.reinstallButton","Reinstall Fusion skill")})})]}),c.packages.length>0?e.jsx("div",{className:"pi-ext-package-list",children:c.packages.map((s,t)=>{const i=typeof s=="string"?s:s.source,r=xe(i),f=ge(i),j=typeof s=="object"&&s!==null,k=j&&(s.extensions?.length??0)>0||(s.skills?.length??0)>0||(s.prompts?.length??0)>0||(s.themes?.length??0)>0,M=J.has(t);return e.jsxs("div",{className:"pi-ext-package-card",children:[e.jsxs("div",{className:"pi-ext-package-header",children:[j&&k?e.jsx("button",{className:"pi-ext-expand-btn",onClick:()=>U(t),"aria-expanded":M,children:M?e.jsx(se,{size:14}):e.jsx(ae,{size:14})}):e.jsx("span",{className:"pi-ext-expand-placeholder"}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${r}`,children:r}),e.jsx("span",{className:"pi-ext-package-source",children:f}),e.jsxs("div",{className:"pi-ext-package-actions",children:[j&&k&&e.jsx("span",{className:"pi-ext-filter-hint",children:a("piExtensions.filterHint","{{extensions}} ext, {{skills}} skill, {{prompts}} prompt, {{themes}} theme",{extensions:s.extensions?.length??0,skills:s.skills?.length??0,prompts:s.prompts?.length??0,themes:s.themes?.length??0})}),e.jsx("button",{className:"btn-icon touch-target pi-ext-remove-btn",onClick:()=>Q(i),title:a("piManager.removePackage","Remove package"),"aria-label":a("piManager.removePackageLabel","Remove package {{label}}",{label:f}),children:e.jsx(ie,{size:14})})]})]}),j&&k&&M&&e.jsxs("div",{className:"pi-ext-filter-list",children:[s.extensions?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(G,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterExtensions","Extensions:")," "]}),s.extensions.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.skills?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx($,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterSkills","Skills:")," "]}),s.skills.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.prompts?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(B,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterPrompts","Prompts:")," "]}),s.prompts.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null,s.themes?.length?e.jsxs("div",{className:"pi-ext-filter-section",children:[e.jsx(A,{size:12}),e.jsxs("span",{className:"pi-ext-filter-label",children:[a("piManager.filterThemes","Themes:")," "]}),s.themes.map((d,p)=>e.jsx("span",{className:"pi-ext-filter-tag",children:d},p))]}):null]})]},t)})}):e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noPackages","No packages configured.")}),e.jsx("p",{className:"text-muted",children:a("piManager.noPackagesHelp","Add a package source above to get started.")})]}),e.jsxs("div",{className:"pi-ext-top-level",children:[u(a("piManager.sectionExtensions","Extensions"),G,"extensions"),u(a("piManager.sectionSkills","Skills"),$,"skills"),u(a("piManager.sectionPrompts","Prompts"),B,"prompts"),u(a("piManager.sectionThemes","Themes"),A,"themes")]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.loadingFailed","Failed to load Pi settings.")})]}),e.jsxs("div",{className:"pi-ext-discovered-section",children:[e.jsxs("div",{className:"pi-ext-discovered-header",children:[e.jsx("h4",{children:a("piManager.discoveredTitle","Discovered Extensions")}),e.jsx("button",{className:"btn-icon",onClick:g,disabled:v,title:a("piManager.refreshExtensions","Refresh extensions"),children:e.jsx(L,{className:v?"spin":""})})]}),e.jsx("p",{className:"pi-ext-description",children:a("piManager.discoveredDescription","Installed extensions resolved from packages and configured paths.")}),v?e.jsx("div",{className:"loading-state",children:e.jsx(D,{label:a("piManager.loadingExtensions","Loading extensions…")})}):m.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx(y,{size:32,className:"text-muted"}),e.jsx("p",{children:a("piManager.noExtensions","No extensions discovered.")})]}):e.jsx("div",{className:"pi-ext-list",children:m.map(s=>e.jsxs("div",{className:"pi-ext-item",children:[e.jsxs("div",{className:"pi-ext-item-content",children:[e.jsxs("div",{className:"pi-ext-info",children:[e.jsx("span",{className:"pi-ext-name",children:s.name}),e.jsx("span",{className:`pi-ext-source-badge pi-ext-source-badge--${de(s.source)}`,children:pe(s.source)})]}),e.jsx("span",{className:"pi-ext-path",children:s.path})]}),e.jsx("div",{className:"pi-ext-actions",children:e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>void K(s),disabled:q,"aria-label":a("piManager.toggleExtension","Toggle {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]})})]},s.id))})]})]})}export{ve as PiExtensionsManager};
@@ -1 +1 @@
1
- import{r as d,j as e}from"./vendor-react-SZ_qB27O.js";import{ad as Me,ae as Ue,af as $e,ag as ce,ah as qe,X as ge,ai as Ve,aj as Te,ak as de,P as pe,al as me,I as he,R as be,am as We,a1 as Ke,an as Qe,ao as Ye,ap as Je,aq as Xe,ar as Ze,as as es,at as ss,au as O,av as ns,aw as is}from"./index-ccFe_1av.js";import{D as ts}from"./DirectoryPicker-etVwa-6X.js";import{u as as}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";import"./folder-open-G-9vPAdv.js";const Ne="fusion-plugin-agent-browser",ye={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"}},xe={General:"plugins.agentBrowser.groupGeneral",Browser:"plugins.agentBrowser.groupBrowser","Prompt Contributions":"plugins.agentBrowser.groupPromptContributions",Skills:"plugins.agentBrowser.groupSkills"},fe={"Enable Agent Browser":"plugins.agentBrowser.labelEnabled","Install Channel":"plugins.agentBrowser.labelInstallChannel","Command Timeout (ms)":"plugins.agentBrowser.labelCommandTimeoutMs","Headless Mode":"plugins.agentBrowser.labelHeadlessMode","Allowed Domains":"plugins.agentBrowser.labelAllowedDomains","Executor System Prompt":"plugins.agentBrowser.labelPromptExecutorSystem","Executor Task Prompt":"plugins.agentBrowser.labelPromptExecutorTask","Triage Prompt":"plugins.agentBrowser.labelPromptTriage","Reviewer Prompt":"plugins.agentBrowser.labelPromptReviewer","Heartbeat Prompt":"plugins.agentBrowser.labelPromptHeartbeat","Skill Exposure":"plugins.agentBrowser.labelSkillExposure"},je=[{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:"fusion-plugin-compound-engineering",name:"Compound Engineering",description:"A dedicated dashboard surface for compound-engineering artifacts and interactive ce-* sessions.",category:"integration",path:"./plugins/fusion-plugin-compound-engineering"},{id:Ne,name:"Agent Browser",description:"Built-in integration metadata. Package install support lands in FN-3101.",category:"integration",hasSetup:!0}],F={started:"var(--color-success)",loaded:"var(--color-warning)",error:"var(--color-error)",stopped:"var(--color-muted)",installed:"var(--color-info)"};function ls(r){const o=r.settingsSchema,n=o&&Object.keys(o).length>0;return r.id!==Ne?n?o:void 0:n?{...ye,...o}:ye}function rs(r){const o=new Map,n=[];for(const[j,y]of Object.entries(r))if(y.group){const v=o.get(y.group)??[];v.push([j,y]),o.set(y.group,v)}else n.push([j,y]);return{grouped:o,ungrouped:n}}function Se(r,o="plugin-error-text"){return r.state!=="error"||!r.error?null:e.jsx("p",{className:o,title:r.error,children:r.error})}function ys({addToast:r,projectId:o}){const{t:n}=as("app"),[j,y]=d.useState([]),[v,z]=d.useState(!0),[ve,A]=d.useState(!1),[E,L]=d.useState(""),[_,H]=d.useState(!1),[M,U]=d.useState(!1),[w,$]=d.useState(null),[c,G]=d.useState(null),[m,x]=d.useState({}),[we,q]=d.useState(!1),[V,T]=d.useState(null),[W,Pe]=d.useState([]),[Ce,K]=d.useState(!0),[Q,Y]=d.useState(null),[b,Re]=d.useState(""),[f,Ie]=d.useState(""),[Ee,J]=d.useState(null),P=d.useRef(null),[Be,D]=d.useState({}),[ke,X]=d.useState(null),[B,Z]=d.useState(null),{confirm:Fe}=Me(),h=d.useCallback(async()=>{try{z(!0);const s=await Ue(o);y(s)}catch(s){r(n("plugins.loadFailed","Failed to load plugins: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{z(!1)}},[o,r]),S=d.useCallback(async(s=b,i=f)=>{try{K(!0),Y(null);const l=await $e(s,i||void 0,o);Pe(l)}catch(l){const u=l instanceof Error?l.message:String(l);Y(u)}finally{K(!1)}},[o,f,b]);d.useEffect(()=>{h()},[h]),d.useEffect(()=>(P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{S(b,f)},300),()=>{P.current&&clearTimeout(P.current)}),[S,f,b]),d.useEffect(()=>{const s=je.filter(l=>l.hasSetup&&j.some(u=>u.id===l.id));if(s.length===0)return;let i=!1;return Promise.all(s.map(async l=>{try{const u=await ce(l.id,o);if(i)return;D(g=>({...g,[l.id]:u}))}catch{if(i)return;D(u=>({...u,[l.id]:{hasSetup:!0,setupCheckDeferred:!0,deferredReason:"plugin-not-started",pluginState:"installed"}}))}})),()=>{i=!0}},[j,o]);const Ae=d.useRef([]);Ae.current=j,d.useEffect(()=>{const s=o?`?projectId=${encodeURIComponent(o)}`:"",i=l=>{try{const u=JSON.parse(l.data);if(u.scope==="project"&&(u.projectId??o)!==o)return;switch(u.transition){case"installing":case"enabled":case"disabled":case"settings-updated":S(b,f),y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],enabled:u.enabled,state:u.state,settings:u.settings,error:u.error},t}else return h(),g});break;case"state-changed":y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],state:u.state,error:u.error},t}return g});break;case"uninstalled":y(g=>g.filter(a=>a.id!==u.pluginId)),S(b,f);break;case"error":y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],state:u.state,error:u.error},t}return g});break}}catch{}};return qe(`/api/events${s}`,{events:{"plugin:lifecycle":i},onReconnect:()=>{h(),S(b,f)}})},[o,h,S,f,b]);const ee=async()=>{if(!E.trim()){r(n("plugins.installPathRequired","Please enter a plugin path"),"error");return}try{H(!0),await O({path:E,...M?{aiScanOnLoad:!0}:{}},o),r(n("plugins.installedGlobally","Plugin installed globally"),"success"),A(!1),L(""),U(!1),await h()}catch(s){r(n("plugins.installFailed","Failed to install plugin: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{H(!1)}},Le=async s=>{if(!s.path){r(n("plugins.builtinNoPackage","{{name}} is built in and does not have an installable package yet",{name:s.name}),"warning");return}try{T(s.id),await O({path:s.path},o),r(n("plugins.builtinInstalledGlobally","{{name}} installed globally",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.builtinInstallFailed","Failed to install {{name}}: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{T(null)}},Ge=async s=>{if(!s.path){r(n("plugins.registryNotInstallable","{{name}} is not available for one-click install yet",{name:s.name}),"warning");return}try{J(s.id),await O({path:s.path},o),r(n("plugins.registryInstalled","{{name}} installed and enabled",{name:s.name}),"success"),await h(),await S(b,f)}catch(i){r(n("plugins.registryInstallFailed","Failed to install {{name}}: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{J(null)}},se=async s=>{try{Z(s.id);const i=await is(s.id,o);if(!i.success){r(n("plugins.setupInstallFailed","Failed to install {{name}} setup: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error");return}r(n("plugins.setupInstalled","{{name}} setup installed",{name:s.name}),"success"),X(s.id);const l=await ce(s.id,o);D(u=>({...u,[s.id]:l}))}catch(i){r(n("plugins.setupInstallFailed","Failed to install {{name}} setup: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{Z(null),X(null)}},ne=async s=>{try{const i=await es(s.id,o);if(i.state==="error"){r(n("plugins.enableFailed","Failed to enable {{name}}: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error"),await h();return}r(n("plugins.enabledForProject","{{name}} enabled for this project",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.enablePluginFailed","Failed to enable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},ie=async s=>{try{await Ze(s.id,o),r(n("plugins.disabledForProject","{{name}} disabled for this project",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.disablePluginFailed","Failed to disable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},te=async s=>{try{$(s.id),await Xe(s.id,o),r(n("plugins.reloaded","{{name}} reloaded",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.reloadFailed","Failed to reload plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}finally{$(null)}},ae=async s=>{if(await Fe({title:n("plugins.uninstallTitle","Uninstall Plugin Globally"),message:n("plugins.uninstallConfirm",'Are you sure you want to uninstall "{{name}}" globally (all projects)?',{name:s.name}),danger:!0}))try{await ss(s.id,o),r(n("plugins.uninstalledGlobally","{{name}} uninstalled globally",{name:s.name}),"success"),await h(),G(null)}catch(l){r(n("plugins.uninstallFailed","Failed to uninstall plugin: {{error}}",{error:l instanceof Error?l.message:String(l)}),"error")}},De=async(s,i)=>{try{await Qe(s.id,{aiScanOnLoad:i},o),r(i?n("plugins.aiScanEnabled","AI scan on load enabled"):n("plugins.aiScanDisabled","AI scan on load disabled"),"success"),await h()}catch(l){r(n("plugins.updateFailed","Failed to update plugin: {{error}}",{error:l instanceof Error?l.message:String(l)}),"error")}},Oe=async s=>{try{await Ye(s.id,o),r(n("plugins.rescanned","{{name}} rescanned",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.rescanFailed","Failed to rescan plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},k=async s=>{G(s);try{q(!0);const i=await ns(s.id,o);x(i)}catch{x({})}finally{q(!1)}},ze=async()=>{if(c)try{await Je(c.id,m,o),r(n("plugins.settingsSaved","Settings saved"),"success")}catch(s){r(n("plugins.saveSettingsFailed","Failed to save settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}};if(c)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:()=>G(null),"aria-label":n("plugins.backToList","Back to plugin list"),children:e.jsx(ge,{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:c.name}),Se(c,"plugin-error-text plugin-error-text--detail")]}),e.jsx("span",{className:"plugin-state-badge",style:{color:F[c.state]||F.installed},children:c.state})]})]}),e.jsxs("div",{className:"plugin-detail-content",children:[e.jsxs("div",{className:"plugin-detail-card",children:[c.description&&e.jsx("p",{className:"plugin-description",children:c.description}),c.author&&e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.author","Author:")}),c.author]}),c.homepage&&e.jsxs("p",{className:"plugin-detail-meta-row plugin-homepage",children:[e.jsx("span",{className:"text-muted",children:n("plugins.homepage","Homepage:")}),e.jsxs("a",{href:c.homepage,target:"_blank",rel:"noopener noreferrer",children:[c.homepage,e.jsx(Ve,{size:12})]})]}),e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.version","Version:")}),c.version]})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:n("plugins.securityScan","Security Scan")}),e.jsxs("div",{className:"plugin-security-row",children:[e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:!!c.aiScanOnLoad,onChange:s=>void De(c,s.target.checked)}),n("plugins.enableAiScanBeforeLoad","Enable AI scan before load/reload")]}),e.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:()=>void Oe(c),children:[e.jsx(Te,{size:14})," ",n("plugins.rescanAndReload","Rescan and Reload")]})]}),e.jsx("p",{className:"text-muted",children:n("plugins.aiScanHint","Turning this on only updates configuration. Use Rescan and Reload to run it now.")}),c.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--${c.lastSecurityScan.verdict}`,children:c.lastSecurityScan.verdict}),e.jsx("span",{className:"text-muted",children:c.lastSecurityScan.scannedAt})]}),e.jsx("p",{className:"plugin-security-summary",children:c.lastSecurityScan.summary}),e.jsxs("details",{children:[e.jsx("summary",{children:n("plugins.findings","Findings ({{count}})",{count:c.lastSecurityScan.findings.length})}),e.jsx("ul",{className:"plugin-security-findings",children:c.lastSecurityScan.findings.map((s,i)=>e.jsxs("li",{children:[e.jsx("strong",{children:s.severity})," ",s.category," — ",s.file,": ",s.reason]},`${s.file}-${i}`))})]})]}):e.jsx("p",{className:"text-muted",children:n("plugins.noSecurityScan","No security scan has been run yet.")})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:n("plugins.settings","Settings")}),we?e.jsx("p",{className:"text-muted",children:e.jsx(de,{label:n("plugins.loading","Loading...")})}):(()=>{const s=ls(c);return s&&Object.keys(s).length>0?e.jsxs("div",{className:"plugin-settings-form",children:[(()=>{const{grouped:i,ungrouped:l}=rs(s),u=[];l.length>0&&u.push({title:null,entries:l});for(const[g,a]of i.entries())u.push({title:g,entries:a});return u.map(g=>e.jsxs("div",{className:g.title?"plugin-settings-group":void 0,children:[g.title&&e.jsx("h6",{className:"plugin-settings-group-heading",children:xe[g.title]?n(xe[g.title],g.title):g.title}),g.entries.map(([a,t])=>{const N=`setting-${a}-help`,C=t.label?fe[t.label]?n(fe[t.label],t.label):t.label:a;return e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:`setting-${a}`,children:[C,t.required&&" *"]}),t.type==="string"&&!t.multiline&&e.jsx("input",{className:"input",type:"text",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="string"&&t.multiline&&e.jsx("textarea",{className:"input",id:`setting-${a}`,rows:4,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="password"&&e.jsx("input",{className:"input",type:"password",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="number"&&e.jsx("input",{className:"input",type:"number",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:Number(p.target.value)}),"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="boolean"&&e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:m[a]??!1,onChange:p=>x({...m,[a]:p.target.checked})}),t.description]}),t.type==="enum"&&e.jsxs("select",{className:"select",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),"aria-describedby":t.description&&!t.required?N:void 0,children:[e.jsx("option",{value:"",children:n("plugins.selectOption","Select...")}),t.enumValues?.map(p=>e.jsx("option",{value:p,children:p},p))]}),t.type==="array"&&e.jsxs("div",{className:"plugin-settings-array",children:[m[a]?.map((p,R)=>e.jsxs("div",{className:"plugin-settings-array-item",children:[e.jsx("input",{className:"input",type:t.itemType==="number"?"number":"text",value:p??"",onChange:ue=>{const I=ue.target.value,oe=[...m[a]||[]];oe[R]=t.itemType==="number"?Number(I):I,x({...m,[a]:oe})}}),e.jsx("button",{className:"btn-icon",onClick:()=>{const I=[...m[a]||[]];I.splice(R,1),x({...m,[a]:I})},"aria-label":n("plugins.removeItem","Remove item"),children:e.jsx(ge,{size:14})})]},R)),e.jsxs("button",{className:"btn btn-secondary",onClick:()=>{const p=m[a]||[],R=t.itemType==="number"?0:"";x({...m,[a]:[...p,R]})},children:[e.jsx(pe,{size:14})," ",n("plugins.addItem","Add Item")]})]}),t.description&&!t.required&&!t.multiline&&e.jsx("span",{id:N,className:"form-help",children:t.description})]},a)})]},g.title??"ungrouped"))})(),e.jsx("button",{className:"btn btn-primary",onClick:ze,children:n("plugins.saveSettings","Save Settings")})]}):e.jsx("p",{className:"text-muted",children:n("plugins.noConfigurableSettings","No configurable settings.")})})()]}),e.jsxs("div",{className:"plugin-detail-actions",children:[c.state==="started"&&e.jsxs("button",{className:"btn btn-secondary",onClick:()=>te(c),disabled:w===c.id,children:[e.jsx(me,{size:14,className:w===c.id?"spin":""}),w===c.id?n("plugins.reloading","Reloading..."):n("plugins.reload","Reload")]}),c.enabled?e.jsx("button",{className:"btn btn-secondary",onClick:()=>ie(c),children:n("plugins.disableInProject","Disable in Project")}):e.jsx("button",{className:"btn btn-primary",onClick:()=>ne(c),children:n("plugins.enableInProject","Enable in Project")}),e.jsxs("button",{className:"btn btn-danger",onClick:()=>ae(c),children:[e.jsx(he,{size:14})," ",n("plugins.uninstallGlobally","Uninstall Globally")]})]})]})]});const le=new Map(j.map(s=>[s.id,s])),re=j,_e=()=>e.jsxs("section",{className:"plugin-registry-section","aria-label":n("plugins.browseRegistry","Browse Registry"),children:[e.jsxs("div",{className:"plugin-registry-header",children:[e.jsxs("div",{className:"plugin-registry-heading-copy",children:[e.jsx("h4",{className:"plugin-registry-heading",children:n("plugins.browseRegistry","Browse Registry")}),e.jsx("p",{className:"plugin-registry-description",children:n("plugins.registryDescription","Discover curated runtimes and integrations that can be added to this Fusion workspace.")})]}),e.jsxs("div",{className:"plugin-registry-controls",children:[e.jsxs("label",{className:"plugin-registry-category-label",children:[e.jsx("span",{className:"sr-only",children:n("plugins.registryCategory","Registry category")}),e.jsxs("select",{className:"select plugin-registry-category-select",value:f,onChange:s=>Ie(s.target.value),"aria-label":n("plugins.registryCategory","Registry category"),children:[e.jsx("option",{value:"",children:n("plugins.registryCategoryAll","All Categories")}),e.jsx("option",{value:"runtime",children:n("plugins.registryCategoryRuntime","Runtime")}),e.jsx("option",{value:"integration",children:n("plugins.registryCategoryIntegration","Integration")})]})]}),e.jsxs("label",{className:"plugin-registry-search-label",children:[e.jsx("span",{className:"sr-only",children:n("plugins.searchRegistry","Search registry")}),e.jsx("input",{className:"input plugin-registry-search-input",type:"search",value:b,onChange:s=>Re(s.target.value),placeholder:n("plugins.searchRegistryPlaceholder","Search registry plugins")})]})]})]}),Ce?e.jsxs("div",{className:"plugin-registry-state",role:"status",children:[e.jsx(be,{size:14,className:"spin"}),n("plugins.registryLoading","Loading registry...")]}):Q?e.jsxs("div",{className:"plugin-registry-state plugin-registry-state--error",role:"alert",children:[e.jsx("span",{children:n("plugins.registryLoadFailed","Failed to load registry: {{error}}",{error:Q})}),e.jsx("button",{className:"btn btn-secondary btn-sm plugin-registry-retry",onClick:()=>void S(b,f),children:n("plugins.retry","Retry")})]}):W.length===0?e.jsx("div",{className:"plugin-registry-state",children:b.trim()?n("plugins.registryEmptySearch","No registry plugins match your search."):n("plugins.registryEmpty","No registry plugins are available.")}):e.jsx("div",{className:"plugin-registry-list","aria-label":n("plugins.registryPluginResults","Registry plugin results"),children:W.map(s=>{const i=le.get(s.id),l=Ee===s.id;return e.jsxs("div",{className:"plugin-registry-item",children:[e.jsxs("div",{className:"plugin-registry-meta",children:[e.jsxs("div",{className:"plugin-registry-title-row",children:[e.jsx("span",{className:"plugin-registry-name",children:s.name}),e.jsxs("span",{className:"plugin-registry-version",children:["v",s.version]}),e.jsx("span",{className:"plugin-registry-badge",children:s.category}),s.installed&&e.jsxs("span",{className:"plugin-registry-status plugin-registry-status--installed",children:[n("plugins.statusInstalled","Installed"),s.installedVersion&&s.installedVersion!==s.version?` · v${s.installedVersion}`:""]})]}),e.jsx("span",{className:"plugin-registry-description-text",children:s.description}),e.jsx("span",{className:"plugin-registry-author",children:n("plugins.registryByAuthor","By {{author}}",{author:s.author})})]}),e.jsx("div",{className:"plugin-registry-actions",children:s.installed?e.jsx("button",{className:"btn btn-secondary btn-sm plugin-registry-action",onClick:()=>{i?k(i):h()},children:n("plugins.manage","Manage")}):s.canInstall?e.jsx("button",{className:"btn btn-primary btn-sm plugin-registry-action",onClick:()=>void Ge(s),disabled:l,children:l?n("plugins.installing","Installing..."):n("plugins.installFromRegistry","Install")}):e.jsx("span",{className:"plugin-registry-coming-soon",children:n("plugins.registryComingSoon","Coming Soon")})})]},s.id)})})]}),He=()=>e.jsxs("section",{className:"plugin-builtins-section","aria-label":n("plugins.builtinPlugins","Built-in Plugins"),children:[e.jsxs("div",{className:"plugin-builtins-header",children:[e.jsx("h4",{className:"plugin-builtins-heading",children:n("plugins.builtinPlugins","Built-in Plugins")}),e.jsx("p",{className:"plugin-builtins-description",children:n("plugins.builtinPluginsCatalog","Built-in plugin catalog for runtimes and integrations.")})]}),e.jsx("div",{className:"plugin-builtins-list","aria-label":n("plugins.builtinPluginRecommendations","Built-in plugin recommendations"),children:je.map(s=>{const i=le.get(s.id),l=!!i,u=Be[s.id],g=!!(u&&"setupCheckDeferred"in u&&u.setupCheckDeferred),a=u&&"status"in u?u.status:void 0,t=l&&s.hasSetup&&u?.hasSetup&&!g&&i?.state==="started"&&(a==="not-installed"||a==="error"),N=l&&u?.hasSetup&&a==="installed",C=ke===s.id,p=!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:n("plugins.experimental","Experimental")}),e.jsx("span",{className:"plugin-builtins-runtime-badge",children:s.category}),e.jsx("span",{className:`plugin-builtins-status ${l?"plugin-builtins-status--installed":"plugin-builtins-status--available"}`,children:l?n("plugins.statusInstalled","Installed"):p?n("plugins.statusBuiltIn","Built in"):n("plugins.statusNotInstalled","Not installed")}),t&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--warning",children:n("plugins.setupRequired","Setup required")}),N&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--ready",children:n("plugins.setupReady","Setup ready")}),C&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--pending",children:n("plugins.checkingSetup","Checking setup...")}),g&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--deferred",children:n("plugins.startPluginToCheckSetup","Start plugin to check setup")}),e.jsx("span",{className:"plugin-builtins-description-text",children:s.description})]}),p?l&&t?e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void se(s),disabled:B===s.id||C,children:B===s.id?n("plugins.settingUp","Setting up..."):n("plugins.installSetup","Install Setup")}):l&&i?e.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>void k(i),children:n("plugins.manage","Manage")}):e.jsx("span",{className:"plugin-builtins-metadata-only",children:n("plugins.builtinMetadataOnly","Built-in metadata only")}):e.jsx("button",{className:`btn ${l&&!t?"btn-secondary":"btn-primary"} btn-sm`,onClick:()=>{if(!l){Le(s);return}if(t){se(s);return}i&&k(i)},disabled:V===s.id||B===s.id||C,children:l?t?B===s.id?n("plugins.settingUp","Setting up..."):n("plugins.installSetup","Install Setup"):n("plugins.manage","Manage"):V===s.id?n("plugins.installing","Installing..."):n("plugins.installNamed","Install {{name}}",{name: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:n("plugins.installedPlugins","Installed Plugins")}),e.jsxs("div",{className:"plugin-manager-actions",children:[e.jsxs("button",{className:"btn btn-sm",onClick:h,title:n("plugins.refresh","Refresh"),"aria-label":n("plugins.refreshPluginList","Refresh plugin list"),children:[e.jsx(be,{size:14,className:v?"spin":""}),n("plugins.refresh","Refresh")]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>A(!0),children:[e.jsx(pe,{size:14})," ",n("plugins.install","Install")]})]})]}),ve&&e.jsxs("div",{className:"plugin-install-form",children:[e.jsx("p",{className:"plugin-install-hint",children:n("plugins.installHint","Browse to a plugin package root (contains manifest.json) or a built dist directory.")}),e.jsx(ts,{value:E,onChange:L,placeholder:n("plugins.installPathPlaceholder","Absolute path to plugin directory or dist folder"),onInputKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),ee())}}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:s=>U(s.target.checked)}),n("plugins.enableAiSecurityScan","Enable AI security scan on load")]}),e.jsxs("div",{className:"plugin-install-actions",children:[e.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:_||!E.trim(),children:_?n("plugins.installing","Installing..."):n("plugins.installPluginGlobally","Install Plugin Globally")}),e.jsx("button",{className:"btn btn-secondary",onClick:()=>{A(!1),L("")},children:n("plugins.cancel","Cancel")})]})]}),v?e.jsx("div",{className:"settings-empty-state",children:e.jsx(de,{label:n("plugins.loadingPlugins","Loading plugins...")})}):e.jsxs(e.Fragment,{children:[re.length===0?e.jsxs("div",{className:"settings-empty-state",children:[e.jsx(We,{size:32,className:"text-muted"}),e.jsx("p",{children:n("plugins.noPluginsInstalled","No plugins installed.")}),e.jsx("p",{className:"text-muted",children:n("plugins.noPluginsHint","Install a plugin to get started, or use the built-in catalog below.")})]}):e.jsx("div",{className:"plugin-list",children:re.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:F[s.state]||F.installed},children:s.state})]}),Se(s)]})}),e.jsxs("div",{className:"plugin-actions",children:[s.state==="started"&&e.jsx("button",{className:"btn-icon",onClick:()=>te(s),disabled:w===s.id,title:n("plugins.reload","Reload"),children:e.jsx(me,{size:14,className:w===s.id?"spin":""})}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>s.enabled?ie(s):ne(s),"aria-label":s.enabled?n("plugins.disablePlugin","Disable {{name}}",{name:s.name}):n("plugins.enablePlugin","Enable {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]}),e.jsx("button",{className:"btn-icon",onClick:()=>k(s),title:n("plugins.settings","Settings"),children:e.jsx(Ke,{size:14})}),e.jsx("button",{className:"btn-icon",onClick:()=>ae(s),title:n("plugins.uninstallGloballyTitle","Uninstall globally"),children:e.jsx(he,{size:14})})]})]},s.id))}),He(),_e()]})]})}export{ye as AGENT_BROWSER_SETTINGS_SCHEMA,Ne as BUILTIN_AGENT_BROWSER_PLUGIN_ID,je as BUILTIN_PLUGINS,ys as PluginManager,F as STATE_COLORS};
1
+ import{r as d,j as e}from"./vendor-react-SZ_qB27O.js";import{ae as Me,af as Ue,ag as $e,ah as ce,ai as qe,X as ge,aj as Ve,ak as Te,al as de,P as pe,am as me,J as he,R as be,an as We,a2 as Ke,ao as Qe,ap as Je,aq as Ye,ar as Xe,as as Ze,at as es,au as ss,av as O,aw as ns,ax as is}from"./index-CHy0WNjH.js";import{D as ts}from"./DirectoryPicker-DNBB-viz.js";import{u as as}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";import"./folder-open-STXgbemw.js";const Ne="fusion-plugin-agent-browser",ye={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"}},xe={General:"plugins.agentBrowser.groupGeneral",Browser:"plugins.agentBrowser.groupBrowser","Prompt Contributions":"plugins.agentBrowser.groupPromptContributions",Skills:"plugins.agentBrowser.groupSkills"},fe={"Enable Agent Browser":"plugins.agentBrowser.labelEnabled","Install Channel":"plugins.agentBrowser.labelInstallChannel","Command Timeout (ms)":"plugins.agentBrowser.labelCommandTimeoutMs","Headless Mode":"plugins.agentBrowser.labelHeadlessMode","Allowed Domains":"plugins.agentBrowser.labelAllowedDomains","Executor System Prompt":"plugins.agentBrowser.labelPromptExecutorSystem","Executor Task Prompt":"plugins.agentBrowser.labelPromptExecutorTask","Triage Prompt":"plugins.agentBrowser.labelPromptTriage","Reviewer Prompt":"plugins.agentBrowser.labelPromptReviewer","Heartbeat Prompt":"plugins.agentBrowser.labelPromptHeartbeat","Skill Exposure":"plugins.agentBrowser.labelSkillExposure"},je=[{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:"fusion-plugin-compound-engineering",name:"Compound Engineering",description:"A dedicated dashboard surface for compound-engineering artifacts and interactive ce-* sessions.",category:"integration",path:"./plugins/fusion-plugin-compound-engineering"},{id:Ne,name:"Agent Browser",description:"Built-in integration metadata. Package install support lands in FN-3101.",category:"integration",hasSetup:!0}],F={started:"var(--color-success)",loaded:"var(--color-warning)",error:"var(--color-error)",stopped:"var(--color-muted)",installed:"var(--color-info)"};function ls(r){const o=r.settingsSchema,n=o&&Object.keys(o).length>0;return r.id!==Ne?n?o:void 0:n?{...ye,...o}:ye}function rs(r){const o=new Map,n=[];for(const[j,y]of Object.entries(r))if(y.group){const v=o.get(y.group)??[];v.push([j,y]),o.set(y.group,v)}else n.push([j,y]);return{grouped:o,ungrouped:n}}function Se(r,o="plugin-error-text"){return r.state!=="error"||!r.error?null:e.jsx("p",{className:o,title:r.error,children:r.error})}function ys({addToast:r,projectId:o}){const{t:n}=as("app"),[j,y]=d.useState([]),[v,z]=d.useState(!0),[ve,A]=d.useState(!1),[E,L]=d.useState(""),[_,H]=d.useState(!1),[M,U]=d.useState(!1),[w,$]=d.useState(null),[c,G]=d.useState(null),[m,x]=d.useState({}),[we,q]=d.useState(!1),[V,T]=d.useState(null),[W,Pe]=d.useState([]),[Ce,K]=d.useState(!0),[Q,J]=d.useState(null),[b,Re]=d.useState(""),[f,Ie]=d.useState(""),[Ee,Y]=d.useState(null),P=d.useRef(null),[Be,D]=d.useState({}),[ke,X]=d.useState(null),[B,Z]=d.useState(null),{confirm:Fe}=Me(),h=d.useCallback(async()=>{try{z(!0);const s=await Ue(o);y(s)}catch(s){r(n("plugins.loadFailed","Failed to load plugins: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{z(!1)}},[o,r]),S=d.useCallback(async(s=b,i=f)=>{try{K(!0),J(null);const l=await $e(s,i||void 0,o);Pe(l)}catch(l){const u=l instanceof Error?l.message:String(l);J(u)}finally{K(!1)}},[o,f,b]);d.useEffect(()=>{h()},[h]),d.useEffect(()=>(P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{S(b,f)},300),()=>{P.current&&clearTimeout(P.current)}),[S,f,b]),d.useEffect(()=>{const s=je.filter(l=>l.hasSetup&&j.some(u=>u.id===l.id));if(s.length===0)return;let i=!1;return Promise.all(s.map(async l=>{try{const u=await ce(l.id,o);if(i)return;D(g=>({...g,[l.id]:u}))}catch{if(i)return;D(u=>({...u,[l.id]:{hasSetup:!0,setupCheckDeferred:!0,deferredReason:"plugin-not-started",pluginState:"installed"}}))}})),()=>{i=!0}},[j,o]);const Ae=d.useRef([]);Ae.current=j,d.useEffect(()=>{const s=o?`?projectId=${encodeURIComponent(o)}`:"",i=l=>{try{const u=JSON.parse(l.data);if(u.scope==="project"&&(u.projectId??o)!==o)return;switch(u.transition){case"installing":case"enabled":case"disabled":case"settings-updated":S(b,f),y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],enabled:u.enabled,state:u.state,settings:u.settings,error:u.error},t}else return h(),g});break;case"state-changed":y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],state:u.state,error:u.error},t}return g});break;case"uninstalled":y(g=>g.filter(a=>a.id!==u.pluginId)),S(b,f);break;case"error":y(g=>{const a=g.findIndex(t=>t.id===u.pluginId);if(a>=0){const t=[...g];return t[a]={...t[a],state:u.state,error:u.error},t}return g});break}}catch{}};return qe(`/api/events${s}`,{events:{"plugin:lifecycle":i},onReconnect:()=>{h(),S(b,f)}})},[o,h,S,f,b]);const ee=async()=>{if(!E.trim()){r(n("plugins.installPathRequired","Please enter a plugin path"),"error");return}try{H(!0),await O({path:E,...M?{aiScanOnLoad:!0}:{}},o),r(n("plugins.installedGlobally","Plugin installed globally"),"success"),A(!1),L(""),U(!1),await h()}catch(s){r(n("plugins.installFailed","Failed to install plugin: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}finally{H(!1)}},Le=async s=>{if(!s.path){r(n("plugins.builtinNoPackage","{{name}} is built in and does not have an installable package yet",{name:s.name}),"warning");return}try{T(s.id),await O({path:s.path},o),r(n("plugins.builtinInstalledGlobally","{{name}} installed globally",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.builtinInstallFailed","Failed to install {{name}}: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{T(null)}},Ge=async s=>{if(!s.path){r(n("plugins.registryNotInstallable","{{name}} is not available for one-click install yet",{name:s.name}),"warning");return}try{Y(s.id),await O({path:s.path},o),r(n("plugins.registryInstalled","{{name}} installed and enabled",{name:s.name}),"success"),await h(),await S(b,f)}catch(i){r(n("plugins.registryInstallFailed","Failed to install {{name}}: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{Y(null)}},se=async s=>{try{Z(s.id);const i=await is(s.id,o);if(!i.success){r(n("plugins.setupInstallFailed","Failed to install {{name}} setup: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error");return}r(n("plugins.setupInstalled","{{name}} setup installed",{name:s.name}),"success"),X(s.id);const l=await ce(s.id,o);D(u=>({...u,[s.id]:l}))}catch(i){r(n("plugins.setupInstallFailed","Failed to install {{name}} setup: {{error}}",{name:s.name,error:i instanceof Error?i.message:String(i)}),"error")}finally{Z(null),X(null)}},ne=async s=>{try{const i=await es(s.id,o);if(i.state==="error"){r(n("plugins.enableFailed","Failed to enable {{name}}: {{error}}",{name:s.name,error:i.error??n("plugins.unknownError","unknown error")}),"error"),await h();return}r(n("plugins.enabledForProject","{{name}} enabled for this project",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.enablePluginFailed","Failed to enable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},ie=async s=>{try{await Ze(s.id,o),r(n("plugins.disabledForProject","{{name}} disabled for this project",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.disablePluginFailed","Failed to disable plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},te=async s=>{try{$(s.id),await Xe(s.id,o),r(n("plugins.reloaded","{{name}} reloaded",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.reloadFailed","Failed to reload plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}finally{$(null)}},ae=async s=>{if(await Fe({title:n("plugins.uninstallTitle","Uninstall Plugin Globally"),message:n("plugins.uninstallConfirm",'Are you sure you want to uninstall "{{name}}" globally (all projects)?',{name:s.name}),danger:!0}))try{await ss(s.id,o),r(n("plugins.uninstalledGlobally","{{name}} uninstalled globally",{name:s.name}),"success"),await h(),G(null)}catch(l){r(n("plugins.uninstallFailed","Failed to uninstall plugin: {{error}}",{error:l instanceof Error?l.message:String(l)}),"error")}},De=async(s,i)=>{try{await Qe(s.id,{aiScanOnLoad:i},o),r(i?n("plugins.aiScanEnabled","AI scan on load enabled"):n("plugins.aiScanDisabled","AI scan on load disabled"),"success"),await h()}catch(l){r(n("plugins.updateFailed","Failed to update plugin: {{error}}",{error:l instanceof Error?l.message:String(l)}),"error")}},Oe=async s=>{try{await Je(s.id,o),r(n("plugins.rescanned","{{name}} rescanned",{name:s.name}),"success"),await h()}catch(i){r(n("plugins.rescanFailed","Failed to rescan plugin: {{error}}",{error:i instanceof Error?i.message:String(i)}),"error")}},k=async s=>{G(s);try{q(!0);const i=await ns(s.id,o);x(i)}catch{x({})}finally{q(!1)}},ze=async()=>{if(c)try{await Ye(c.id,m,o),r(n("plugins.settingsSaved","Settings saved"),"success")}catch(s){r(n("plugins.saveSettingsFailed","Failed to save settings: {{error}}",{error:s instanceof Error?s.message:String(s)}),"error")}};if(c)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:()=>G(null),"aria-label":n("plugins.backToList","Back to plugin list"),children:e.jsx(ge,{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:c.name}),Se(c,"plugin-error-text plugin-error-text--detail")]}),e.jsx("span",{className:"plugin-state-badge",style:{color:F[c.state]||F.installed},children:c.state})]})]}),e.jsxs("div",{className:"plugin-detail-content",children:[e.jsxs("div",{className:"plugin-detail-card",children:[c.description&&e.jsx("p",{className:"plugin-description",children:c.description}),c.author&&e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.author","Author:")}),c.author]}),c.homepage&&e.jsxs("p",{className:"plugin-detail-meta-row plugin-homepage",children:[e.jsx("span",{className:"text-muted",children:n("plugins.homepage","Homepage:")}),e.jsxs("a",{href:c.homepage,target:"_blank",rel:"noopener noreferrer",children:[c.homepage,e.jsx(Ve,{size:12})]})]}),e.jsxs("p",{className:"plugin-detail-meta-row",children:[e.jsx("span",{className:"text-muted",children:n("plugins.version","Version:")}),c.version]})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:n("plugins.securityScan","Security Scan")}),e.jsxs("div",{className:"plugin-security-row",children:[e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:!!c.aiScanOnLoad,onChange:s=>void De(c,s.target.checked)}),n("plugins.enableAiScanBeforeLoad","Enable AI scan before load/reload")]}),e.jsxs("button",{className:"btn btn-secondary btn-sm",onClick:()=>void Oe(c),children:[e.jsx(Te,{size:14})," ",n("plugins.rescanAndReload","Rescan and Reload")]})]}),e.jsx("p",{className:"text-muted",children:n("plugins.aiScanHint","Turning this on only updates configuration. Use Rescan and Reload to run it now.")}),c.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--${c.lastSecurityScan.verdict}`,children:c.lastSecurityScan.verdict}),e.jsx("span",{className:"text-muted",children:c.lastSecurityScan.scannedAt})]}),e.jsx("p",{className:"plugin-security-summary",children:c.lastSecurityScan.summary}),e.jsxs("details",{children:[e.jsx("summary",{children:n("plugins.findings","Findings ({{count}})",{count:c.lastSecurityScan.findings.length})}),e.jsx("ul",{className:"plugin-security-findings",children:c.lastSecurityScan.findings.map((s,i)=>e.jsxs("li",{children:[e.jsx("strong",{children:s.severity})," ",s.category," — ",s.file,": ",s.reason]},`${s.file}-${i}`))})]})]}):e.jsx("p",{className:"text-muted",children:n("plugins.noSecurityScan","No security scan has been run yet.")})]}),e.jsxs("div",{className:"plugin-detail-card",children:[e.jsx("h5",{className:"plugin-detail-section-heading",children:n("plugins.settings","Settings")}),we?e.jsx("p",{className:"text-muted",children:e.jsx(de,{label:n("plugins.loading","Loading...")})}):(()=>{const s=ls(c);return s&&Object.keys(s).length>0?e.jsxs("div",{className:"plugin-settings-form",children:[(()=>{const{grouped:i,ungrouped:l}=rs(s),u=[];l.length>0&&u.push({title:null,entries:l});for(const[g,a]of i.entries())u.push({title:g,entries:a});return u.map(g=>e.jsxs("div",{className:g.title?"plugin-settings-group":void 0,children:[g.title&&e.jsx("h6",{className:"plugin-settings-group-heading",children:xe[g.title]?n(xe[g.title],g.title):g.title}),g.entries.map(([a,t])=>{const N=`setting-${a}-help`,C=t.label?fe[t.label]?n(fe[t.label],t.label):t.label:a;return e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:`setting-${a}`,children:[C,t.required&&" *"]}),t.type==="string"&&!t.multiline&&e.jsx("input",{className:"input",type:"text",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="string"&&t.multiline&&e.jsx("textarea",{className:"input",id:`setting-${a}`,rows:4,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="password"&&e.jsx("input",{className:"input",type:"password",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),placeholder:t.description,"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="number"&&e.jsx("input",{className:"input",type:"number",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:Number(p.target.value)}),"aria-describedby":t.description&&!t.required?N:void 0}),t.type==="boolean"&&e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:m[a]??!1,onChange:p=>x({...m,[a]:p.target.checked})}),t.description]}),t.type==="enum"&&e.jsxs("select",{className:"select",id:`setting-${a}`,value:m[a]??"",onChange:p=>x({...m,[a]:p.target.value}),"aria-describedby":t.description&&!t.required?N:void 0,children:[e.jsx("option",{value:"",children:n("plugins.selectOption","Select...")}),t.enumValues?.map(p=>e.jsx("option",{value:p,children:p},p))]}),t.type==="array"&&e.jsxs("div",{className:"plugin-settings-array",children:[m[a]?.map((p,R)=>e.jsxs("div",{className:"plugin-settings-array-item",children:[e.jsx("input",{className:"input",type:t.itemType==="number"?"number":"text",value:p??"",onChange:ue=>{const I=ue.target.value,oe=[...m[a]||[]];oe[R]=t.itemType==="number"?Number(I):I,x({...m,[a]:oe})}}),e.jsx("button",{className:"btn-icon",onClick:()=>{const I=[...m[a]||[]];I.splice(R,1),x({...m,[a]:I})},"aria-label":n("plugins.removeItem","Remove item"),children:e.jsx(ge,{size:14})})]},R)),e.jsxs("button",{className:"btn btn-secondary",onClick:()=>{const p=m[a]||[],R=t.itemType==="number"?0:"";x({...m,[a]:[...p,R]})},children:[e.jsx(pe,{size:14})," ",n("plugins.addItem","Add Item")]})]}),t.description&&!t.required&&!t.multiline&&e.jsx("span",{id:N,className:"form-help",children:t.description})]},a)})]},g.title??"ungrouped"))})(),e.jsx("button",{className:"btn btn-primary",onClick:ze,children:n("plugins.saveSettings","Save Settings")})]}):e.jsx("p",{className:"text-muted",children:n("plugins.noConfigurableSettings","No configurable settings.")})})()]}),e.jsxs("div",{className:"plugin-detail-actions",children:[c.state==="started"&&e.jsxs("button",{className:"btn btn-secondary",onClick:()=>te(c),disabled:w===c.id,children:[e.jsx(me,{size:14,className:w===c.id?"spin":""}),w===c.id?n("plugins.reloading","Reloading..."):n("plugins.reload","Reload")]}),c.enabled?e.jsx("button",{className:"btn btn-secondary",onClick:()=>ie(c),children:n("plugins.disableInProject","Disable in Project")}):e.jsx("button",{className:"btn btn-primary",onClick:()=>ne(c),children:n("plugins.enableInProject","Enable in Project")}),e.jsxs("button",{className:"btn btn-danger",onClick:()=>ae(c),children:[e.jsx(he,{size:14})," ",n("plugins.uninstallGlobally","Uninstall Globally")]})]})]})]});const le=new Map(j.map(s=>[s.id,s])),re=j,_e=()=>e.jsxs("section",{className:"plugin-registry-section","aria-label":n("plugins.browseRegistry","Browse Registry"),children:[e.jsxs("div",{className:"plugin-registry-header",children:[e.jsxs("div",{className:"plugin-registry-heading-copy",children:[e.jsx("h4",{className:"plugin-registry-heading",children:n("plugins.browseRegistry","Browse Registry")}),e.jsx("p",{className:"plugin-registry-description",children:n("plugins.registryDescription","Discover curated runtimes and integrations that can be added to this Fusion workspace.")})]}),e.jsxs("div",{className:"plugin-registry-controls",children:[e.jsxs("label",{className:"plugin-registry-category-label",children:[e.jsx("span",{className:"sr-only",children:n("plugins.registryCategory","Registry category")}),e.jsxs("select",{className:"select plugin-registry-category-select",value:f,onChange:s=>Ie(s.target.value),"aria-label":n("plugins.registryCategory","Registry category"),children:[e.jsx("option",{value:"",children:n("plugins.registryCategoryAll","All Categories")}),e.jsx("option",{value:"runtime",children:n("plugins.registryCategoryRuntime","Runtime")}),e.jsx("option",{value:"integration",children:n("plugins.registryCategoryIntegration","Integration")})]})]}),e.jsxs("label",{className:"plugin-registry-search-label",children:[e.jsx("span",{className:"sr-only",children:n("plugins.searchRegistry","Search registry")}),e.jsx("input",{className:"input plugin-registry-search-input",type:"search",value:b,onChange:s=>Re(s.target.value),placeholder:n("plugins.searchRegistryPlaceholder","Search registry plugins")})]})]})]}),Ce?e.jsxs("div",{className:"plugin-registry-state",role:"status",children:[e.jsx(be,{size:14,className:"spin"}),n("plugins.registryLoading","Loading registry...")]}):Q?e.jsxs("div",{className:"plugin-registry-state plugin-registry-state--error",role:"alert",children:[e.jsx("span",{children:n("plugins.registryLoadFailed","Failed to load registry: {{error}}",{error:Q})}),e.jsx("button",{className:"btn btn-secondary btn-sm plugin-registry-retry",onClick:()=>void S(b,f),children:n("plugins.retry","Retry")})]}):W.length===0?e.jsx("div",{className:"plugin-registry-state",children:b.trim()?n("plugins.registryEmptySearch","No registry plugins match your search."):n("plugins.registryEmpty","No registry plugins are available.")}):e.jsx("div",{className:"plugin-registry-list","aria-label":n("plugins.registryPluginResults","Registry plugin results"),children:W.map(s=>{const i=le.get(s.id),l=Ee===s.id;return e.jsxs("div",{className:"plugin-registry-item",children:[e.jsxs("div",{className:"plugin-registry-meta",children:[e.jsxs("div",{className:"plugin-registry-title-row",children:[e.jsx("span",{className:"plugin-registry-name",children:s.name}),e.jsxs("span",{className:"plugin-registry-version",children:["v",s.version]}),e.jsx("span",{className:"plugin-registry-badge",children:s.category}),s.installed&&e.jsxs("span",{className:"plugin-registry-status plugin-registry-status--installed",children:[n("plugins.statusInstalled","Installed"),s.installedVersion&&s.installedVersion!==s.version?` · v${s.installedVersion}`:""]})]}),e.jsx("span",{className:"plugin-registry-description-text",children:s.description}),e.jsx("span",{className:"plugin-registry-author",children:n("plugins.registryByAuthor","By {{author}}",{author:s.author})})]}),e.jsx("div",{className:"plugin-registry-actions",children:s.installed?e.jsx("button",{className:"btn btn-secondary btn-sm plugin-registry-action",onClick:()=>{i?k(i):h()},children:n("plugins.manage","Manage")}):s.canInstall?e.jsx("button",{className:"btn btn-primary btn-sm plugin-registry-action",onClick:()=>void Ge(s),disabled:l,children:l?n("plugins.installing","Installing..."):n("plugins.installFromRegistry","Install")}):e.jsx("span",{className:"plugin-registry-coming-soon",children:n("plugins.registryComingSoon","Coming Soon")})})]},s.id)})})]}),He=()=>e.jsxs("section",{className:"plugin-builtins-section","aria-label":n("plugins.builtinPlugins","Built-in Plugins"),children:[e.jsxs("div",{className:"plugin-builtins-header",children:[e.jsx("h4",{className:"plugin-builtins-heading",children:n("plugins.builtinPlugins","Built-in Plugins")}),e.jsx("p",{className:"plugin-builtins-description",children:n("plugins.builtinPluginsCatalog","Built-in plugin catalog for runtimes and integrations.")})]}),e.jsx("div",{className:"plugin-builtins-list","aria-label":n("plugins.builtinPluginRecommendations","Built-in plugin recommendations"),children:je.map(s=>{const i=le.get(s.id),l=!!i,u=Be[s.id],g=!!(u&&"setupCheckDeferred"in u&&u.setupCheckDeferred),a=u&&"status"in u?u.status:void 0,t=l&&s.hasSetup&&u?.hasSetup&&!g&&i?.state==="started"&&(a==="not-installed"||a==="error"),N=l&&u?.hasSetup&&a==="installed",C=ke===s.id,p=!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:n("plugins.experimental","Experimental")}),e.jsx("span",{className:"plugin-builtins-runtime-badge",children:s.category}),e.jsx("span",{className:`plugin-builtins-status ${l?"plugin-builtins-status--installed":"plugin-builtins-status--available"}`,children:l?n("plugins.statusInstalled","Installed"):p?n("plugins.statusBuiltIn","Built in"):n("plugins.statusNotInstalled","Not installed")}),t&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--warning",children:n("plugins.setupRequired","Setup required")}),N&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--ready",children:n("plugins.setupReady","Setup ready")}),C&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--pending",children:n("plugins.checkingSetup","Checking setup...")}),g&&e.jsx("span",{className:"plugin-builtins-setup-status plugin-builtins-setup-status--deferred",children:n("plugins.startPluginToCheckSetup","Start plugin to check setup")}),e.jsx("span",{className:"plugin-builtins-description-text",children:s.description})]}),p?l&&t?e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void se(s),disabled:B===s.id||C,children:B===s.id?n("plugins.settingUp","Setting up..."):n("plugins.installSetup","Install Setup")}):l&&i?e.jsx("button",{className:"btn btn-secondary btn-sm",onClick:()=>void k(i),children:n("plugins.manage","Manage")}):e.jsx("span",{className:"plugin-builtins-metadata-only",children:n("plugins.builtinMetadataOnly","Built-in metadata only")}):e.jsx("button",{className:`btn ${l&&!t?"btn-secondary":"btn-primary"} btn-sm`,onClick:()=>{if(!l){Le(s);return}if(t){se(s);return}i&&k(i)},disabled:V===s.id||B===s.id||C,children:l?t?B===s.id?n("plugins.settingUp","Setting up..."):n("plugins.installSetup","Install Setup"):n("plugins.manage","Manage"):V===s.id?n("plugins.installing","Installing..."):n("plugins.installNamed","Install {{name}}",{name: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:n("plugins.installedPlugins","Installed Plugins")}),e.jsxs("div",{className:"plugin-manager-actions",children:[e.jsxs("button",{className:"btn btn-sm",onClick:h,title:n("plugins.refresh","Refresh"),"aria-label":n("plugins.refreshPluginList","Refresh plugin list"),children:[e.jsx(be,{size:14,className:v?"spin":""}),n("plugins.refresh","Refresh")]}),e.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>A(!0),children:[e.jsx(pe,{size:14})," ",n("plugins.install","Install")]})]})]}),ve&&e.jsxs("div",{className:"plugin-install-form",children:[e.jsx("p",{className:"plugin-install-hint",children:n("plugins.installHint","Browse to a plugin package root (contains manifest.json) or a built dist directory.")}),e.jsx(ts,{value:E,onChange:L,placeholder:n("plugins.installPathPlaceholder","Absolute path to plugin directory or dist folder"),onInputKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),ee())}}),e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:M,onChange:s=>U(s.target.checked)}),n("plugins.enableAiSecurityScan","Enable AI security scan on load")]}),e.jsxs("div",{className:"plugin-install-actions",children:[e.jsx("button",{className:"btn btn-primary",onClick:ee,disabled:_||!E.trim(),children:_?n("plugins.installing","Installing..."):n("plugins.installPluginGlobally","Install Plugin Globally")}),e.jsx("button",{className:"btn btn-secondary",onClick:()=>{A(!1),L("")},children:n("plugins.cancel","Cancel")})]})]}),v?e.jsx("div",{className:"settings-empty-state",children:e.jsx(de,{label:n("plugins.loadingPlugins","Loading plugins...")})}):e.jsxs(e.Fragment,{children:[re.length===0?e.jsxs("div",{className:"settings-empty-state",children:[e.jsx(We,{size:32,className:"text-muted"}),e.jsx("p",{children:n("plugins.noPluginsInstalled","No plugins installed.")}),e.jsx("p",{className:"text-muted",children:n("plugins.noPluginsHint","Install a plugin to get started, or use the built-in catalog below.")})]}):e.jsx("div",{className:"plugin-list",children:re.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:F[s.state]||F.installed},children:s.state})]}),Se(s)]})}),e.jsxs("div",{className:"plugin-actions",children:[s.state==="started"&&e.jsx("button",{className:"btn-icon",onClick:()=>te(s),disabled:w===s.id,title:n("plugins.reload","Reload"),children:e.jsx(me,{size:14,className:w===s.id?"spin":""})}),e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:()=>s.enabled?ie(s):ne(s),"aria-label":s.enabled?n("plugins.disablePlugin","Disable {{name}}",{name:s.name}):n("plugins.enablePlugin","Enable {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]}),e.jsx("button",{className:"btn-icon",onClick:()=>k(s),title:n("plugins.settings","Settings"),children:e.jsx(Ke,{size:14})}),e.jsx("button",{className:"btn-icon",onClick:()=>ae(s),title:n("plugins.uninstallGloballyTitle","Uninstall globally"),children:e.jsx(he,{size:14})})]})]},s.id))}),He(),_e()]})]})}export{ye as AGENT_BROWSER_SETTINGS_SCHEMA,Ne as BUILTIN_AGENT_BROWSER_PLUGIN_ID,je as BUILTIN_PLUGINS,ys as PluginManager,F as STATE_COLORS};
@@ -1,6 +1,6 @@
1
- import{r as n,j as e}from"./vendor-react-SZ_qB27O.js";import{c as _,b6 as R,b7 as z,V as O,b8 as j,al as E,b9 as C,ba as D,bb as $,ai as L,f as S,a5 as T}from"./index-ccFe_1av.js";import{u as V}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
1
+ import{r as n,j as e}from"./vendor-react-SZ_qB27O.js";import{c as _,b7 as R,b8 as z,V as O,b9 as j,am as E,ba as C,bb as D,bc as $,aj as L,h as S,a6 as T}from"./index-CHy0WNjH.js";import{u as V}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const B=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],F=_("thumbs-up",B);function J(t){return async r=>{const a=t?`?projectId=${encodeURIComponent(t)}`:"";return(await T(`/pull-requests/${r}${a}`)).pullRequest}}function X(t){return async(r,a,d)=>(await T(`/pull-requests/${a}/${r==="automerge"?"automerge":r}`,{method:"POST",body:JSON.stringify({...d??{},...t?{projectId:t}:{}}),headers:{"content-type":"application/json"}})).pullRequest}function Z({rollup:t}){return t==="success"?e.jsx(S,{size:14,className:"pr-icon-success"}):t==="failure"?e.jsx($,{size:14,className:"pr-icon-failure"}):t==="pending"?e.jsx(j,{size:14,className:"pr-icon-pending"}):e.jsx("span",{className:"pr-icon-none",children:"—"})}function se(t){const{t:r}=V("app"),{detail:a,pullRequestId:d,projectId:b,onAction:k,loadPullRequest:I}=t,[i,h]=n.useState(a??null),[p,m]=n.useState(null),[o,P]=n.useState(null),[G,M]=n.useState(!1),[H,w]=n.useState(!1),q=I??J(b),A=k??X(b),v=n.useCallback(async()=>{if(a){h(a);return}if(!d){m(null),w(!1),h(null);return}try{m(null),w(!0);const s=15e3,N=new Promise((g,U)=>setTimeout(()=>U(new Error("Timed out loading pull request")),s));h(await Promise.race([q(d),N]))}catch(s){m(s instanceof Error?s.message:"Failed to load PR")}finally{w(!1)}},[a,d,q]);n.useEffect(()=>{v()},[v]),n.useEffect(()=>{if(a||!d)return;const s=()=>void v();return window.addEventListener("fusion:store-changed",s),()=>window.removeEventListener("fusion:store-changed",s)},[a,d,v]);const u=n.useCallback(async(s,N)=>{if(i)try{P(s),m(null);const g=await A(s,i.id,N);h(g)}catch(g){m(g instanceof Error?g.message:`Action ${s} failed`)}finally{P(null),M(!1)}},[i,A]);if(p&&!i)return e.jsxs("div",{className:"pr-view pr-view--error","data-testid":"pr-view-error",children:[e.jsx(R,{size:16})," ",p]});if(!i)return H?e.jsx("div",{className:"pr-view pr-view--loading","data-testid":"pr-view-loading",children:r("pr.view.loading","Loading PR…")}):e.jsxs("div",{className:"pr-view pr-view--empty","data-testid":"pr-view-empty",children:[e.jsx(z,{size:16})," ",r("pr.view.empty","No pull request to show.")]});const{state:c,summary:l}=i,x=e.jsx(O,{icon:z,title:r("pr.view.title","Pull Requests")});if(c==="creating")return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"creating",children:[x,e.jsx(f,{detail:i}),e.jsxs("div",{className:"pr-placeholder","data-testid":"pr-creating",children:[e.jsx(j,{size:16})," ",r("pr.view.creating","Creating PR…")]})]});if(c==="failed")return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"failed",children:[x,e.jsx(f,{detail:i}),e.jsxs("div",{className:"pr-error-reason","data-testid":"pr-failed",children:[e.jsx(R,{size:16,className:"pr-icon-failure"}),e.jsx("span",{children:i.failureReason??r("pr.view.creationFailed","PR creation failed")})]}),e.jsx("div",{className:"pr-action-bar",children:e.jsxs("button",{type:"button",className:"pr-action pr-action--retry","data-testid":"pr-retry-create",disabled:o==="retry-create",onClick:()=>void u("retry-create"),children:[e.jsx(E,{size:14})," ",r("pr.view.retryCreation","Retry PR creation")]})}),p&&e.jsx("div",{className:"pr-inline-error",children:p})]});if(i.unverified)return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"unverified",children:[x,e.jsx(f,{detail:i}),e.jsxs("div",{className:"pr-notice pr-notice--unverified","data-testid":"pr-unverified",children:[e.jsx(j,{size:16})," ",r("pr.view.verifyingGithub","Verifying with GitHub…")]}),e.jsx("div",{className:"pr-action-bar",children:e.jsxs("button",{type:"button",className:"pr-action","data-testid":"pr-merge",disabled:!0,title:r("pr.view.mergeDisabledUntilVerified","Merge is disabled until GitHub verifies this PR"),children:[e.jsx(C,{size:14})," ",r("pr.view.merge","Merge")]})})]});const y=l.conflicting;return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":c,children:[x,e.jsx(f,{detail:i}),c==="responding"&&e.jsxs("div",{className:"pr-banner pr-banner--responding","data-testid":"pr-responding",children:[e.jsx(D,{size:16})," ",r("pr.view.responsePending","Response run in progress — {{count}} threads pending",{count:l.pendingThreads})]}),e.jsxs("div",{className:"pr-action-bar","data-testid":"pr-action-bar",children:[e.jsxs("button",{type:"button",className:"pr-action pr-action--approve","data-testid":"pr-approve",disabled:c==="responding"||o==="approve",onClick:()=>void u("approve"),children:[e.jsx(F,{size:14})," ",r("pr.view.approve","Approve")]}),e.jsxs("button",{type:"button",className:"pr-action pr-action--retry","data-testid":"pr-retry",disabled:c==="responding"||o==="retry",title:c==="responding"?r("pr.view.responseAlreadyInProgress","A response run is already in progress"):void 0,onClick:()=>void u("retry"),children:[e.jsx(E,{size:14})," ",r("pr.view.requestRetry","Request retry")]}),G?e.jsxs("button",{type:"button",className:"pr-action pr-action--merge-confirm","data-testid":"pr-merge-confirm",disabled:o==="merge",onClick:()=>void u("merge"),children:[e.jsx(C,{size:14})," ",r("pr.view.confirmMerge","Confirm merge")]}):e.jsxs("button",{type:"button",className:"pr-action pr-action--merge","data-testid":"pr-merge",disabled:y||c==="responding"||o==="merge",title:y?r("pr.view.resolveConflictsBeforeMerge","Resolve conflicts on GitHub before merging"):void 0,onClick:()=>M(!0),children:[e.jsx(C,{size:14})," ",r("pr.view.merge","Merge")]}),e.jsxs("button",{type:"button",className:"pr-action pr-action--close","data-testid":"pr-close",disabled:o==="close",onClick:()=>void u("close"),children:[e.jsx($,{size:14})," ",r("pr.view.close","Close")]}),e.jsxs("label",{className:"pr-automerge-toggle","data-testid":"pr-automerge",children:[e.jsx("input",{type:"checkbox",checked:i.autoMerge,disabled:o==="automerge",onChange:s=>void u("automerge",{enabled:s.target.checked})}),e.jsx("span",{children:r("pr.view.autoMerge","Auto-merge")}),e.jsx("span",{className:"pr-automerge-gate","data-testid":"pr-automerge-gate",children:l.autoMergeReason})]})]}),y&&i.prUrl&&e.jsxs("a",{className:"pr-conflict-link","data-testid":"pr-conflict-link",href:i.prUrl,target:"_blank",rel:"noopener noreferrer",children:[r("pr.view.resolveConflictsOnGithub","Resolve conflicts on GitHub")," ",e.jsx(L,{size:12})]}),e.jsxs("div",{className:"pr-summary","data-testid":"pr-summary",children:[e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-mergeable",children:[r("pr.view.mergeableLabel","Mergeable:")," ",l.mergeable]}),e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-review",children:[r("pr.view.reviewLabel","Review:")," ",l.reviewDecision??r("pr.view.none","none")]}),e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-checks",children:[e.jsx(Z,{rollup:l.checksRollup})," ",l.checksRollup]})]}),e.jsx("div",{className:"pr-threads","data-testid":"pr-threads",children:i.threads.length===0?e.jsx("div",{className:"pr-threads-empty",children:r("pr.view.noReviewThreads","No review threads.")}):i.threads.map(s=>e.jsxs("div",{className:`pr-thread pr-thread--${s.outcome} ${s.outcome==="disagreed"?"pr-thread--agent-disagreement":""}`,"data-testid":`pr-thread-${s.outcome}`,"data-agent-disagreement":s.outcome==="disagreed"?"true":"false",children:[e.jsxs("div",{className:"pr-thread-head",children:[s.outcome==="pending"&&e.jsxs("span",{className:"pr-thread-pending",children:[e.jsx(j,{size:12})," ",r("pr.view.threadPending","pending")]}),s.outcome==="disagreed"&&e.jsxs("span",{className:"pr-thread-disagreed",children:[e.jsx(R,{size:12})," ",r("pr.view.agentDisagreed","agent disagreed")]}),s.outcome==="fixed"&&e.jsxs("span",{className:"pr-thread-fixed",children:[e.jsx(S,{size:12})," ",r("pr.view.threadFixed","fixed")]}),e.jsx("span",{className:"pr-thread-id",children:s.threadId})]}),s.fixCommitSha&&e.jsx("div",{className:"pr-thread-reply","data-testid":"pr-thread-reply",children:r("pr.view.agentReplyFix","Agent reply — fix {{sha}}",{sha:s.fixCommitSha.slice(0,8)})})]},`${s.threadId}:${s.headOid}`))}),p&&e.jsx("div",{className:"pr-inline-error",children:p})]})}function f({detail:t}){return e.jsxs("div",{className:"pr-identity","data-testid":"pr-identity",children:[e.jsx(z,{size:16}),e.jsx("span",{className:"pr-identity-repo",children:t.repo}),t.prNumber!=null?t.prUrl?e.jsxs("a",{className:"pr-identity-number",href:t.prUrl,target:"_blank",rel:"noopener noreferrer",children:["#",t.prNumber," ",e.jsx(L,{size:12})]}):e.jsxs("span",{className:"pr-identity-number",children:["#",t.prNumber]}):null,e.jsx("span",{className:"pr-identity-branch",children:t.headBranch}),e.jsx("span",{className:`pr-identity-state pr-identity-state--${t.state}`,children:t.state})]})}export{se as PullRequestView};
6
+ */const B=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],F=_("thumbs-up",B);function J(t){return async r=>{const a=t?`?projectId=${encodeURIComponent(t)}`:"";return(await T(`/pull-requests/${r}${a}`)).pullRequest}}function X(t){return async(r,a,d)=>(await T(`/pull-requests/${a}/${r==="automerge"?"automerge":r}`,{method:"POST",body:JSON.stringify({...d??{},...t?{projectId:t}:{}}),headers:{"content-type":"application/json"}})).pullRequest}function Z({rollup:t}){return t==="success"?e.jsx(S,{size:14,className:"pr-icon-success"}):t==="failure"?e.jsx($,{size:14,className:"pr-icon-failure"}):t==="pending"?e.jsx(j,{size:14,className:"pr-icon-pending"}):e.jsx("span",{className:"pr-icon-none",children:"—"})}function se(t){const{t:r}=V("app"),{detail:a,pullRequestId:d,projectId:b,onAction:k,loadPullRequest:I}=t,[i,g]=n.useState(a??null),[p,m]=n.useState(null),[o,P]=n.useState(null),[G,M]=n.useState(!1),[H,w]=n.useState(!1),q=I??J(b),A=k??X(b),v=n.useCallback(async()=>{if(a){g(a);return}if(!d){m(null),w(!1),g(null);return}try{m(null),w(!0);const s=15e3,N=new Promise((h,U)=>setTimeout(()=>U(new Error("Timed out loading pull request")),s));g(await Promise.race([q(d),N]))}catch(s){m(s instanceof Error?s.message:"Failed to load PR")}finally{w(!1)}},[a,d,q]);n.useEffect(()=>{v()},[v]),n.useEffect(()=>{if(a||!d)return;const s=()=>void v();return window.addEventListener("fusion:store-changed",s),()=>window.removeEventListener("fusion:store-changed",s)},[a,d,v]);const u=n.useCallback(async(s,N)=>{if(i)try{P(s),m(null);const h=await A(s,i.id,N);g(h)}catch(h){m(h instanceof Error?h.message:`Action ${s} failed`)}finally{P(null),M(!1)}},[i,A]);if(p&&!i)return e.jsxs("div",{className:"pr-view pr-view--error","data-testid":"pr-view-error",children:[e.jsx(R,{size:16})," ",p]});if(!i)return H?e.jsx("div",{className:"pr-view pr-view--loading","data-testid":"pr-view-loading",children:r("pr.view.loading","Loading PR…")}):e.jsxs("div",{className:"pr-view pr-view--empty","data-testid":"pr-view-empty",children:[e.jsx(z,{size:16})," ",r("pr.view.empty","No pull request to show.")]});const{state:c,summary:l}=i,x=e.jsx(O,{icon:z,title:r("pr.view.title","Pull Requests")});if(c==="creating")return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"creating",children:[x,e.jsx(f,{detail:i}),e.jsxs("div",{className:"pr-placeholder","data-testid":"pr-creating",children:[e.jsx(j,{size:16})," ",r("pr.view.creating","Creating PR…")]})]});if(c==="failed")return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"failed",children:[x,e.jsx(f,{detail:i}),e.jsxs("div",{className:"pr-error-reason","data-testid":"pr-failed",children:[e.jsx(R,{size:16,className:"pr-icon-failure"}),e.jsx("span",{children:i.failureReason??r("pr.view.creationFailed","PR creation failed")})]}),e.jsx("div",{className:"pr-action-bar",children:e.jsxs("button",{type:"button",className:"pr-action pr-action--retry","data-testid":"pr-retry-create",disabled:o==="retry-create",onClick:()=>void u("retry-create"),children:[e.jsx(E,{size:14})," ",r("pr.view.retryCreation","Retry PR creation")]})}),p&&e.jsx("div",{className:"pr-inline-error",children:p})]});if(i.unverified)return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":"unverified",children:[x,e.jsx(f,{detail:i}),e.jsxs("div",{className:"pr-notice pr-notice--unverified","data-testid":"pr-unverified",children:[e.jsx(j,{size:16})," ",r("pr.view.verifyingGithub","Verifying with GitHub…")]}),e.jsx("div",{className:"pr-action-bar",children:e.jsxs("button",{type:"button",className:"pr-action","data-testid":"pr-merge",disabled:!0,title:r("pr.view.mergeDisabledUntilVerified","Merge is disabled until GitHub verifies this PR"),children:[e.jsx(C,{size:14})," ",r("pr.view.merge","Merge")]})})]});const y=l.conflicting;return e.jsxs("div",{className:"pr-view","data-testid":"pr-view","data-state":c,children:[x,e.jsx(f,{detail:i}),c==="responding"&&e.jsxs("div",{className:"pr-banner pr-banner--responding","data-testid":"pr-responding",children:[e.jsx(D,{size:16})," ",r("pr.view.responsePending","Response run in progress — {{count}} threads pending",{count:l.pendingThreads})]}),e.jsxs("div",{className:"pr-action-bar","data-testid":"pr-action-bar",children:[e.jsxs("button",{type:"button",className:"pr-action pr-action--approve","data-testid":"pr-approve",disabled:c==="responding"||o==="approve",onClick:()=>void u("approve"),children:[e.jsx(F,{size:14})," ",r("pr.view.approve","Approve")]}),e.jsxs("button",{type:"button",className:"pr-action pr-action--retry","data-testid":"pr-retry",disabled:c==="responding"||o==="retry",title:c==="responding"?r("pr.view.responseAlreadyInProgress","A response run is already in progress"):void 0,onClick:()=>void u("retry"),children:[e.jsx(E,{size:14})," ",r("pr.view.requestRetry","Request retry")]}),G?e.jsxs("button",{type:"button",className:"pr-action pr-action--merge-confirm","data-testid":"pr-merge-confirm",disabled:o==="merge",onClick:()=>void u("merge"),children:[e.jsx(C,{size:14})," ",r("pr.view.confirmMerge","Confirm merge")]}):e.jsxs("button",{type:"button",className:"pr-action pr-action--merge","data-testid":"pr-merge",disabled:y||c==="responding"||o==="merge",title:y?r("pr.view.resolveConflictsBeforeMerge","Resolve conflicts on GitHub before merging"):void 0,onClick:()=>M(!0),children:[e.jsx(C,{size:14})," ",r("pr.view.merge","Merge")]}),e.jsxs("button",{type:"button",className:"pr-action pr-action--close","data-testid":"pr-close",disabled:o==="close",onClick:()=>void u("close"),children:[e.jsx($,{size:14})," ",r("pr.view.close","Close")]}),e.jsxs("label",{className:"pr-automerge-toggle","data-testid":"pr-automerge",children:[e.jsx("input",{type:"checkbox",checked:i.autoMerge,disabled:o==="automerge",onChange:s=>void u("automerge",{enabled:s.target.checked})}),e.jsx("span",{children:r("pr.view.autoMerge","Auto-merge")}),e.jsx("span",{className:"pr-automerge-gate","data-testid":"pr-automerge-gate",children:l.autoMergeReason})]})]}),y&&i.prUrl&&e.jsxs("a",{className:"pr-conflict-link","data-testid":"pr-conflict-link",href:i.prUrl,target:"_blank",rel:"noopener noreferrer",children:[r("pr.view.resolveConflictsOnGithub","Resolve conflicts on GitHub")," ",e.jsx(L,{size:12})]}),e.jsxs("div",{className:"pr-summary","data-testid":"pr-summary",children:[e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-mergeable",children:[r("pr.view.mergeableLabel","Mergeable:")," ",l.mergeable]}),e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-review",children:[r("pr.view.reviewLabel","Review:")," ",l.reviewDecision??r("pr.view.none","none")]}),e.jsxs("span",{className:"pr-summary-item","data-testid":"pr-summary-checks",children:[e.jsx(Z,{rollup:l.checksRollup})," ",l.checksRollup]})]}),e.jsx("div",{className:"pr-threads","data-testid":"pr-threads",children:i.threads.length===0?e.jsx("div",{className:"pr-threads-empty",children:r("pr.view.noReviewThreads","No review threads.")}):i.threads.map(s=>e.jsxs("div",{className:`pr-thread pr-thread--${s.outcome} ${s.outcome==="disagreed"?"pr-thread--agent-disagreement":""}`,"data-testid":`pr-thread-${s.outcome}`,"data-agent-disagreement":s.outcome==="disagreed"?"true":"false",children:[e.jsxs("div",{className:"pr-thread-head",children:[s.outcome==="pending"&&e.jsxs("span",{className:"pr-thread-pending",children:[e.jsx(j,{size:12})," ",r("pr.view.threadPending","pending")]}),s.outcome==="disagreed"&&e.jsxs("span",{className:"pr-thread-disagreed",children:[e.jsx(R,{size:12})," ",r("pr.view.agentDisagreed","agent disagreed")]}),s.outcome==="fixed"&&e.jsxs("span",{className:"pr-thread-fixed",children:[e.jsx(S,{size:12})," ",r("pr.view.threadFixed","fixed")]}),e.jsx("span",{className:"pr-thread-id",children:s.threadId})]}),s.fixCommitSha&&e.jsx("div",{className:"pr-thread-reply","data-testid":"pr-thread-reply",children:r("pr.view.agentReplyFix","Agent reply — fix {{sha}}",{sha:s.fixCommitSha.slice(0,8)})})]},`${s.threadId}:${s.headOid}`))}),p&&e.jsx("div",{className:"pr-inline-error",children:p})]})}function f({detail:t}){return e.jsxs("div",{className:"pr-identity","data-testid":"pr-identity",children:[e.jsx(z,{size:16}),e.jsx("span",{className:"pr-identity-repo",children:t.repo}),t.prNumber!=null?t.prUrl?e.jsxs("a",{className:"pr-identity-number",href:t.prUrl,target:"_blank",rel:"noopener noreferrer",children:["#",t.prNumber," ",e.jsx(L,{size:12})]}):e.jsxs("span",{className:"pr-identity-number",children:["#",t.prNumber]}):null,e.jsx("span",{className:"pr-identity-branch",children:t.headBranch}),e.jsx("span",{className:`pr-identity-state pr-identity-state--${t.state}`,children:t.state})]})}export{se as PullRequestView};