@runfusion/fusion 0.76.0-beta.3 → 0.77.0-beta.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 (175) hide show
  1. package/dist/bin.js +13802 -9587
  2. package/dist/child-process-worker.js +6472 -4028
  3. package/dist/client/.vite/manifest.json +280 -269
  4. package/dist/client/assets/AgentDetailView-0G9qFd4j.js +13 -0
  5. package/dist/client/assets/{AgentDetailView-Cc3ATg8a.css → AgentDetailView-jzgy1BAS.css} +1 -1
  6. package/dist/client/assets/{AgentPermissionPolicyEditor--u9jyUf2.js → AgentPermissionPolicyEditor-BM68g7wo.js} +1 -1
  7. package/dist/client/assets/AgentsView-DkOUZWw4.js +24 -0
  8. package/dist/client/assets/ChatView-BPSm2JIH.js +13 -0
  9. package/dist/client/assets/{CommandCenter-CSRYoveB.js → CommandCenter-DxRSFWNc.js} +26 -26
  10. package/dist/client/assets/CommandCenter-ilm-DbtI.css +1 -0
  11. package/dist/client/assets/{DevServerView-B9So_oYx.js → DevServerView-DO-bqJFE.js} +1 -1
  12. package/dist/client/assets/{DirectoryPicker-BhyDL_2m.js → DirectoryPicker-Cp2gddTE.js} +1 -1
  13. package/dist/client/assets/DocumentsView-D0E-3G96.js +1 -0
  14. package/dist/client/assets/EvalsView-BoFVq5hw.js +1 -0
  15. package/dist/client/assets/ExperimentalAgentOnboardingModal-CS1Sdogm.js +1 -0
  16. package/dist/client/assets/{GoalsView-B6X5_0Ve.js → GoalsView-sybf7JY4.js} +1 -1
  17. package/dist/client/assets/InsightsView-nHa7aShn.js +11 -0
  18. package/dist/client/assets/{MemoryView-DN_3IFmA.css → MemoryView-CdpQqPJJ.css} +1 -1
  19. package/dist/client/assets/MemoryView-D0IG44za.js +3 -0
  20. package/dist/client/assets/{PiExtensionsManager-B8At6fO8.js → PiExtensionsManager-CU76weJe.js} +2 -2
  21. package/dist/client/assets/PluginManager-DyT8XbcG.js +1 -0
  22. package/dist/client/assets/{PullRequestView-B1hZFrWo.js → PullRequestView-CnxWUSen.js} +2 -2
  23. package/dist/client/assets/{ReportModal-C46V_zEa.js → ReportModal-CMrmMQjD.js} +5 -5
  24. package/dist/client/assets/{ResearchView-D8G85BYN.js → ResearchView-BTytQSgy.js} +2 -2
  25. package/dist/client/assets/{SecretsView-CTri9LRK.js → SecretsView-BuSH5J87.js} +1 -1
  26. package/dist/client/assets/SessionTerminal-D04kYRrT.js +2 -0
  27. package/dist/client/assets/SettingsModal-C0FY8MPW.css +1 -0
  28. package/dist/client/assets/{SettingsModal-rUQcSTJp.js → SettingsModal-Dm-ngbRr.js} +1 -1
  29. package/dist/client/assets/{SettingsModal-DmfMotcd.css → SettingsModal-Ds0Yj47X.css} +1 -1
  30. package/dist/client/assets/SettingsModal-xSLhH7Tr.js +21 -0
  31. package/dist/client/assets/{SettingsTextareaRow-BirlBcem.js → SettingsTextareaRow-CHPgocEp.js} +1 -1
  32. package/dist/client/assets/{SetupWizardModal-xnCBM9EL.js → SetupWizardModal-y88aXNIQ.js} +2 -2
  33. package/dist/client/assets/{SkillsView-O5U0ep50.js → SkillsView-CYyQW1Hv.js} +1 -1
  34. package/dist/client/assets/{WorkflowNodeEditor-BX4d2qqF.js → WorkflowNodeEditor-hYeoz1X8.js} +3 -3
  35. package/dist/client/assets/{agent-import-generation-DnqVkPkz.js → agent-import-generation-CjiYXzCr.js} +1 -1
  36. package/dist/client/assets/agentsOrgChartLayout-C0UP_X3z.js +1 -0
  37. package/dist/client/assets/app-BgpuMvTU.js +13 -0
  38. package/dist/client/assets/app-BlexHhbW.js +13 -0
  39. package/dist/client/assets/app-BsuUOR0P.js +13 -0
  40. package/dist/client/assets/app-DQVOujmO.js +13 -0
  41. package/dist/client/assets/app-DjyTRx1N.js +5 -0
  42. package/dist/client/assets/app-Dniggype.js +13 -0
  43. package/dist/client/assets/app-EV-lyZ0T.js +5 -0
  44. package/dist/client/assets/{architectureDiagram-3BPJPVTR-gi467xY0.js → architectureDiagram-3BPJPVTR-Dd6GPcqM.js} +1 -1
  45. package/dist/client/assets/{blockDiagram-GPEHLZMM-B_gpcYiR.js → blockDiagram-GPEHLZMM-CC6pLxlz.js} +1 -1
  46. package/dist/client/assets/{c4Diagram-AAUBKEIU-DeylEYsQ.js → c4Diagram-AAUBKEIU-DxMP_l6y.js} +1 -1
  47. package/dist/client/assets/channel-DlCEMoEf.js +1 -0
  48. package/dist/client/assets/{chunk-2J33WTMH-BL2WY0HN.js → chunk-2J33WTMH-BKYToL43.js} +1 -1
  49. package/dist/client/assets/{chunk-4BX2VUAB-BkLExGMe.js → chunk-4BX2VUAB-Bg6rjQb3.js} +1 -1
  50. package/dist/client/assets/{chunk-55IACEB6-CSTvCF5T.js → chunk-55IACEB6-CPUwbbGa.js} +1 -1
  51. package/dist/client/assets/{chunk-727SXJPM-9J8pKk4x.js → chunk-727SXJPM-DScQBCvv.js} +1 -1
  52. package/dist/client/assets/{chunk-AQP2D5EJ-DXC1vPWr.js → chunk-AQP2D5EJ-DbX7uaXK.js} +1 -1
  53. package/dist/client/assets/{chunk-FMBD7UC4-CFRUb-zD.js → chunk-FMBD7UC4-DvYKea1c.js} +1 -1
  54. package/dist/client/assets/{chunk-ND2GUHAM-B87HFYS8.js → chunk-ND2GUHAM-CH-Tvw7w.js} +1 -1
  55. package/dist/client/assets/{chunk-QZHKN3VN-CTjHiGbd.js → chunk-QZHKN3VN-CbyEvOoM.js} +1 -1
  56. package/dist/client/assets/classDiagram-4FO5ZUOK-Bc92O8Ks.js +1 -0
  57. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-Bc92O8Ks.js +1 -0
  58. package/dist/client/assets/{cose-bilkent-S5V4N54A-D3Edq3L9.js → cose-bilkent-S5V4N54A-BPB5fV3A.js} +1 -1
  59. package/dist/client/assets/{dagre-BM42HDAG-CwwbeQfN.js → dagre-BM42HDAG-CilYJ3rR.js} +1 -1
  60. package/dist/client/assets/{dashboard-view-QxQwJFLz.js → dashboard-view-BnGe8cWo.js} +1 -1
  61. package/dist/client/assets/{dashboard-view-BLAoW3D4.js → dashboard-view-DnVf3tmI.js} +1 -1
  62. package/dist/client/assets/{dashboard-view-DAlJxqiJ.js → dashboard-view-DoLU6FxZ.js} +1 -1
  63. package/dist/client/assets/{dashboard-view-aPzfv99T.js → dashboard-view-dChSM_So.js} +1 -1
  64. package/dist/client/assets/{diagram-2AECGRRQ-koJWWXE4.js → diagram-2AECGRRQ-m9u1Qhyx.js} +1 -1
  65. package/dist/client/assets/{diagram-5GNKFQAL-Yob5cOKT.js → diagram-5GNKFQAL-DVr7Kf0N.js} +1 -1
  66. package/dist/client/assets/{diagram-KO2AKTUF-DelvFSkK.js → diagram-KO2AKTUF-D7sgJDFx.js} +1 -1
  67. package/dist/client/assets/{diagram-LMA3HP47-CMput2h2.js → diagram-LMA3HP47-DNKNDS6r.js} +1 -1
  68. package/dist/client/assets/{diagram-OG6HWLK6-04VXDl79.js → diagram-OG6HWLK6-1Bff4FWn.js} +1 -1
  69. package/dist/client/assets/{erDiagram-TEJ5UH35-C9iP8Uyp.js → erDiagram-TEJ5UH35-DGua1UHN.js} +1 -1
  70. package/dist/client/assets/{flowDiagram-I6XJVG4X-DENQvu_t.js → flowDiagram-I6XJVG4X-UDfDtwsE.js} +1 -1
  71. package/dist/client/assets/{folder-open-D-554oji.js → folder-open-CteOypVk.js} +1 -1
  72. package/dist/client/assets/{ganttDiagram-6RSMTGT7-BqOttZAT.js → ganttDiagram-6RSMTGT7-COdmD328.js} +1 -1
  73. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-CDcydi-5.js → gitGraphDiagram-PVQCEYII-SUSls7Kw.js} +1 -1
  74. package/dist/client/assets/index-0ovTXt3t.css +1 -0
  75. package/dist/client/assets/index-DpCHwyiD.js +2818 -0
  76. package/dist/client/assets/{infoDiagram-5YYISTIA-B5LQQnxt.js → infoDiagram-5YYISTIA-e_DloXj7.js} +1 -1
  77. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-DpFEt7D2.js → ishikawaDiagram-YF4QCWOH-DVWqihXg.js} +1 -1
  78. package/dist/client/assets/{journeyDiagram-JHISSGLW-MELtgu22.js → journeyDiagram-JHISSGLW-BcPY-XP0.js} +1 -1
  79. package/dist/client/assets/{kanban-definition-UN3LZRKU-h33PLATd.js → kanban-definition-UN3LZRKU-BCFG2Jle.js} +1 -1
  80. package/dist/client/assets/{mermaid.core-Dk2mUPOq.js → mermaid.core-5yPje9Bi.js} +4 -4
  81. package/dist/client/assets/{mindmap-definition-RKZ34NQL-B_T4O2-B.js → mindmap-definition-RKZ34NQL-DDApeT3K.js} +1 -1
  82. package/dist/client/assets/{pieDiagram-4H26LBE5-B1YIFkRl.js → pieDiagram-4H26LBE5-N61_jyeP.js} +1 -1
  83. package/dist/client/assets/{puzzle-hvecxlpJ.js → puzzle-BkaCP30D.js} +1 -1
  84. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-BoGQR_hO.js → quadrantDiagram-W4KKPZXB-C5qHiApF.js} +1 -1
  85. package/dist/client/assets/{requirementDiagram-4Y6WPE33-BSDmUBIx.js → requirementDiagram-4Y6WPE33-C71okgzt.js} +1 -1
  86. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-Dz_GqOa5.js → sankeyDiagram-5OEKKPKP-B2iKyLjB.js} +1 -1
  87. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-B6twjYUH.js → sequenceDiagram-3UESZ5HK-DfdoYKKk.js} +1 -1
  88. package/dist/client/assets/{shield-alert-BX4WRJOv.js → shield-alert-BNSeDB8l.js} +1 -1
  89. package/dist/client/assets/standing-instructions-template-pZtzo1lK.js +20 -0
  90. package/dist/client/assets/standing-instructions-template-w7Ouw_37.css +1 -0
  91. package/dist/client/assets/{stateDiagram-AJRCARHV-DuwqWLx-.js → stateDiagram-AJRCARHV-lS-sUi12.js} +1 -1
  92. package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-Bu8Sk187.js → stateDiagram-v2-BHNVJYJU-DXJNDrV9.js} +1 -1
  93. package/dist/client/assets/{timeline-definition-PNZ67QCA-BS6VnqSI.js → timeline-definition-PNZ67QCA-CCwvX81K.js} +1 -1
  94. package/dist/client/assets/{upload-CaDoyaMW.js → upload-CDovVbu2.js} +1 -1
  95. package/dist/client/assets/useDiscoveredSkillsCache-BYqP-afh.js +1 -0
  96. package/dist/client/assets/{users-C5uCLwVM.js → users-CTqECGLo.js} +1 -1
  97. package/dist/client/assets/{vennDiagram-CIIHVFJN-CUbzqT5Y.js → vennDiagram-CIIHVFJN-DaiR5nv9.js} +1 -1
  98. package/dist/client/assets/{wardley-L42UT6IY-Mv-NotFS.js → wardley-L42UT6IY-hA5IHyPW.js} +1 -1
  99. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-DuYpvLZX.js → wardleyDiagram-YWT4CUSO-CILUNESc.js} +1 -1
  100. package/dist/client/assets/{xychartDiagram-2RQKCTM6-24_7QXdw.js → xychartDiagram-2RQKCTM6-72eNMmjz.js} +1 -1
  101. package/dist/client/index.html +2 -2
  102. package/dist/client/version.json +1 -1
  103. package/dist/droid-cli/package.json +1 -1
  104. package/dist/extension.js +10671 -6904
  105. package/dist/migrations/0059_fn_9037_tasks_source_agent_index.sql +3 -0
  106. package/dist/migrations/0060_fn_9059_workspace_coordination_leases.sql +10 -0
  107. package/dist/pi-claude-cli/package.json +1 -1
  108. package/dist/plugin-sdk/index.d.ts +190 -9
  109. package/dist/plugin-sdk/index.js +74 -28
  110. package/dist/plugins/fusion-plugin-acp-runtime/bundled.js +83 -29
  111. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  112. package/dist/plugins/fusion-plugin-claude-runtime/bundled.js +83 -29
  113. package/dist/plugins/fusion-plugin-claude-runtime/package.json +1 -1
  114. package/dist/plugins/fusion-plugin-cli-printing-press/bundled.js +74 -28
  115. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  116. package/dist/plugins/fusion-plugin-compound-engineering/bundled.js +74 -28
  117. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  118. package/dist/plugins/fusion-plugin-cursor-runtime/bundled.js +1096 -73
  119. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  120. package/dist/plugins/fusion-plugin-dependency-graph/bundled.js +74 -28
  121. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  122. package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +74 -28
  123. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  124. package/dist/plugins/fusion-plugin-grok-runtime/bundled.js +83 -29
  125. package/dist/plugins/fusion-plugin-grok-runtime/package.json +1 -1
  126. package/dist/plugins/fusion-plugin-hermes-runtime/bundled.js +302 -71
  127. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  128. package/dist/plugins/fusion-plugin-linear-import/bundled.js +74 -28
  129. package/dist/plugins/fusion-plugin-linear-import/package.json +1 -1
  130. package/dist/plugins/fusion-plugin-omp-runtime/bundled.js +83 -29
  131. package/dist/plugins/fusion-plugin-omp-runtime/package.json +1 -1
  132. package/dist/plugins/fusion-plugin-openclaw-runtime/bundled.js +74 -28
  133. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  134. package/dist/plugins/fusion-plugin-paperclip-runtime/bundled.js +74 -28
  135. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  136. package/dist/plugins/fusion-plugin-quality/bundled.js +176 -46
  137. package/dist/plugins/fusion-plugin-quality/package.json +1 -1
  138. package/dist/plugins/fusion-plugin-reports/bundled.js +74 -28
  139. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  140. package/dist/plugins/fusion-plugin-roadmap/bundled.js +74 -28
  141. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  142. package/dist/plugins/fusion-plugin-todos/bundled.js +74 -28
  143. package/dist/plugins/fusion-plugin-todos/package.json +1 -1
  144. package/dist/plugins/fusion-plugin-whatsapp-chat/bundled.js +74 -28
  145. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  146. package/package.json +1 -1
  147. package/skill/fusion/references/extension-tools.md +2 -0
  148. package/dist/client/assets/AgentDetailView-T767kKTg.js +0 -13
  149. package/dist/client/assets/AgentsView-6Ifu7qDr.js +0 -24
  150. package/dist/client/assets/ChatView-BV3lixQi.js +0 -13
  151. package/dist/client/assets/CommandCenter-CE4rYjHn.css +0 -1
  152. package/dist/client/assets/DocumentsView-pbERA7O-.js +0 -1
  153. package/dist/client/assets/EvalsView-DJQ4ltCg.js +0 -1
  154. package/dist/client/assets/ExperimentalAgentOnboardingModal-BwJuzkzB.js +0 -1
  155. package/dist/client/assets/InsightsView-CJgI0J7S.js +0 -11
  156. package/dist/client/assets/MemoryView-BHq1AHPu.js +0 -3
  157. package/dist/client/assets/PluginManager-k7hV7_9e.js +0 -1
  158. package/dist/client/assets/SessionTerminal-BRf6r4Vp.js +0 -2
  159. package/dist/client/assets/SettingsModal-B30rPfYC.css +0 -1
  160. package/dist/client/assets/SettingsModal-D0RBeZik.js +0 -21
  161. package/dist/client/assets/agentsOrgChartLayout-CKuzbhFf.js +0 -1
  162. package/dist/client/assets/app-B2FwULu2.js +0 -5
  163. package/dist/client/assets/app-B6nJaqAl.js +0 -13
  164. package/dist/client/assets/app-CGXZeIRc.js +0 -13
  165. package/dist/client/assets/app-CGtkeBF5.js +0 -13
  166. package/dist/client/assets/app-CNzN1Plu.js +0 -13
  167. package/dist/client/assets/app-DLs-f5yM.js +0 -13
  168. package/dist/client/assets/app-DsvtcRUG.js +0 -5
  169. package/dist/client/assets/channel-BoE8DeM4.js +0 -1
  170. package/dist/client/assets/classDiagram-4FO5ZUOK-qnbLX_9_.js +0 -1
  171. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-qnbLX_9_.js +0 -1
  172. package/dist/client/assets/index-CXTd3LAB.css +0 -1
  173. package/dist/client/assets/index-CtYRoouR.js +0 -2818
  174. package/dist/client/assets/standing-instructions-template-BJY317CC.js +0 -20
  175. package/dist/client/assets/standing-instructions-template-Ddi_4TIk.css +0 -1
@@ -0,0 +1 @@
1
+ import{r as n,j as e}from"./vendor-react-SZ_qB27O.js";import{r as Ue,e as qe,S as Ht,au as zt,av as Ot,aw as Ye,b as $t,ax as It,ay as fe,az as Bt,aA as Ve,aB as _t,aC as Ut,aD as qt,aE as Vt,aF as Ae,aG as Qt,aH as Qe,V as Gt,aI as ce,E as Wt,y as Kt,aJ as Yt,X as Xt,R as Jt,aK as ke,A as Ge,D as We,aL as Ke,n as De,o as Ee,aM as Zt,aN as Xe,aO as es,aP as ts,aQ as ss,aR as ns,H as as,aS as cs,aT as os}from"./index-DpCHwyiD.js";import{u as rs}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function is(a){const{projectId:u,searchQuery:m,includeProjectFiles:T=!0}=a??{},g=u?`${Ht.DOCUMENTS_PREFIX}${u}`:null,[w,t]=n.useState(()=>{if(!g)return[];const N=Ue(g,{maxAgeMs:qe});return Array.isArray(N)?N:[]}),[l,i]=n.useState([]),[P,d]=n.useState(()=>w.length===0),[b,k]=n.useState(null),p=n.useRef(null),h=n.useRef(w.length>0),j=n.useRef(null),{capture:C}=zt(u,"useDocuments"),L=n.useCallback(async()=>{const N=C();p.current&&p.current.abort();const M=new AbortController;p.current=M;const J=!h.current;J&&d(!0),k(null);const q=Ot(m?{q:m}:void 0,u),Z=T?Ye(u):Promise.resolve({files:[]}),[S,y]=await Promise.allSettled([q,Z]);if(M.signal.aborted||N.isStale())return;let re=null;if(S.status==="fulfilled"){if(t(S.value),g){const A=S.value.length>500?S.value.slice(0,500):S.value;$t(g,A,{maxBytes:5e5})}h.current=!0}else re=S.reason instanceof Error?S.reason.message:String(S.reason);if(y.status==="fulfilled"){const A=y.value.files,W=m?.trim().toLowerCase(),ie=W?A.filter(ee=>ee.name.toLowerCase().includes(W)||ee.path.toLowerCase().includes(W)):A;i(ie)}k(re),J&&d(!1)},[g,C,T,u,m]);return n.useEffect(()=>{if(i([]),!g){h.current=!1,t([]),d(!0);return}const N=Ue(g,{maxAgeMs:qe});Array.isArray(N)?(t(N),h.current=!0,d(!1)):(h.current=!1,t([]),d(!0))},[g]),n.useEffect(()=>(j.current&&clearTimeout(j.current),j.current=setTimeout(()=>{L()},300),()=>{j.current&&clearTimeout(j.current)}),[L]),n.useEffect(()=>(L(),()=>{p.current&&p.current.abort()}),[]),{documents:w,projectFiles:l,loading:P,error:b,refresh:L}}function ls(a,u){const[m,T]=n.useState([]),[g,w]=n.useState(!0),[t,l]=n.useState(null),i=n.useRef(null),P=n.useRef(!1),d=u?.showHidden??!1,b=n.useCallback(async k=>{i.current&&i.current.abort();const p=new AbortController;i.current=p;const h=!P.current;h&&w(!0),l(null);try{const j=await Ye(a,{showHidden:k?.showHidden??d});if(p.signal.aborted)return;T(j.files),P.current=!0}catch(j){if(p.signal.aborted)return;l(j instanceof Error?j.message:String(j))}finally{!p.signal.aborted&&h&&w(!1)}},[a,d]);return n.useEffect(()=>(P.current=!1,b({showHidden:d}),()=>{i.current&&i.current.abort()}),[b,d]),{files:m,loading:g,error:t,refresh:b}}const ds=768,us={image:ns,doc:ce,pdf:ss,video:ts,audio:es,other:Xe};function oe(a){return a?new Date(a).toLocaleString():""}function ms(a){return a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(a>=10*1024?0:1)} KB`:`${(a/(1024*1024)).toFixed(1)} MB`}function hs(a,u){return u?u.archived?"status-dot status-dot--offline":u.complete?"status-dot status-dot--online":u.intake||u.hold?"status-dot status-dot--pending":"status-dot status-dot--connecting":a==="done"?"status-dot status-dot--online":a==="archived"?"status-dot status-dot--offline":fs.has(a)?"status-dot status-dot--pending":"status-dot status-dot--connecting"}const fs=new Set(["triage","todo"]);function Je(a,u){switch(u){case"image":return a("documents.artifactCategoryImage","Image");case"doc":return a("documents.artifactCategoryDoc","Document");case"pdf":return a("documents.artifactCategoryPdf","PDF");case"video":return a("documents.artifactCategoryVideo","Video");case"audio":return a("documents.artifactCategoryAudioSingle","Audio");case"other":return a("documents.artifactCategoryOtherSingle","Other")}}function ks(a,u){return u?[a.title,a.description,a.taskId,a.taskTitle,a.mimeType,a.authorId].some(m=>m?.toLowerCase().includes(u)):!0}function ps(a){const u=a.mimeType?.toLowerCase().split(";",1)[0]??"";return!!a.content||a.type==="document"||u.startsWith("text/")||u==="application/json"||u==="application/xml"}function js({artifact:a,projectId:u,content:m,loading:T,error:g,renderMarkdown:w,onToggleMarkdown:t,onOpenTask:l,t:i}){const[P,d]=n.useState(null),b=Ae(a),k=Je(i,b),p=a.title||i("documents.untitledArtifact","Untitled artifact"),h=as(a.id,u),j=b==="doc"&&ps(a);n.useEffect(()=>{d(null)},[a.id]);const C=P?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:P}):null,L=b==="image"?e.jsxs(e.Fragment,{children:[C,e.jsx("img",{className:"documents-task-artifact-media",src:h,alt:p,onError:()=>d(i("documents.artifactMediaFailed","Failed to load artifact preview."))})]}):b==="video"?e.jsxs(e.Fragment,{children:[C,e.jsx("video",{className:"documents-task-artifact-media",controls:!0,src:h,"aria-label":i("documents.videoArtifactLabel","Video artifact: {{title}}",{title:p}),onError:()=>d(i("documents.artifactMediaFailed","Failed to load artifact preview."))})]}):b==="audio"?e.jsxs(e.Fragment,{children:[C,e.jsx("audio",{className:"documents-task-artifact-audio",controls:!0,src:h,"aria-label":i("documents.audioArtifactLabel","Audio artifact: {{title}}",{title:p}),onError:()=>d(i("documents.artifactMediaFailed","Failed to load artifact preview."))})]}):b==="pdf"?e.jsxs("div",{className:"documents-task-artifact-pdf",children:[e.jsx("iframe",{title:i("documents.pdfArtifactTitle","PDF artifact: {{title}}",{title:p}),src:h}),e.jsxs("a",{className:"btn btn-sm",href:h,target:"_blank",rel:"noreferrer",children:[e.jsx(cs,{size:14,"aria-hidden":"true"}),i("documents.openInNewTab","Open in new tab")]})]}):b==="doc"&&j?T?e.jsx("p",{className:"documents-content-state",children:e.jsx(ke,{label:i("documents.loadingArtifactContent","Loading artifact content…")})}):g?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:g}):w?e.jsx("div",{className:"documents-content-markdown documents-task-artifact-doc-content",children:e.jsx("div",{className:"markdown-body",children:e.jsx(De,{remarkPlugins:[Ee],children:m??a.content??""})})}):e.jsx("pre",{className:"document-card-content-text documents-content-viewer-text documents-task-artifact-doc-content",children:m??a.content??""}):e.jsxs("div",{className:"documents-task-artifact-download",children:[e.jsx(Xe,{size:24,"aria-hidden":"true"}),e.jsx("p",{children:a.description||i("documents.binaryArtifactFallback","This artifact cannot be previewed inline.")}),e.jsxs("a",{className:"btn btn-sm",href:h,target:"_blank",rel:"noreferrer","data-testid":"task-artifact-open-link",children:[e.jsx(os,{size:14,"aria-hidden":"true"}),i("documents.openArtifact","Open artifact")]})]});return e.jsxs("div",{className:"documents-content-viewer documents-task-artifact-viewer",children:[e.jsxs("div",{className:"documents-content-header documents-task-document-header",children:[e.jsxs("p",{className:"documents-file-path-header",children:[a.taskId," / ",p]}),b==="doc"&&j?e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:t,"aria-label":w?i("documents.switchToPlainText","Switch to plain text"):i("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":w,title:w?i("documents.switchToPlainText","Switch to plain text"):i("documents.switchToMarkdown","Switch to markdown"),children:w?i("documents.markdown","Markdown"):i("documents.plain","Plain")}):null]}),e.jsxs("div",{className:"document-card-meta documents-task-document-meta documents-task-artifact-meta",children:[e.jsx("span",{children:k}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{children:a.authorId||i("documents.unknownAuthor","unknown")}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{children:oe(a.updatedAt)}),a.taskId?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("button",{className:"documents-task-artifact-open-task",onClick:()=>void l(a.taskId),children:i("documents.openTask","Open task")})]}):null]}),a.description?e.jsx("p",{className:"documents-task-artifact-description",children:a.description}):null,e.jsx("div",{className:`documents-task-artifact-preview documents-task-artifact-preview--${b}`,children:L})]})}function Ss({projectId:a,columnFlagsByTaskId:u,addToast:m,onOpenDetail:T,onOpenArtifactTaskDetail:g,onSendSelectionToTask:w}){const{t}=rs("app"),[l,i]=n.useState("artifacts"),P=It(),[d,b]=n.useState(""),[k,p]=n.useState(null),[h,j]=n.useState(null),[C,L]=n.useState(!1),[N,M]=n.useState(null),[J,q]=n.useState(!1),[Z,S]=n.useState(null),[y,re]=n.useState(!1),A=n.useRef(0),W=n.useRef(null),ie=n.useRef(null),ee=n.useRef(null),Le=n.useRef(null),[K,Me]=n.useState(!1),[Ze,Re]=n.useState(new Map),[et,R]=n.useState(null),[pe,D]=n.useState(""),[le,E]=n.useState(null),[V,F]=n.useState(null),[de,je]=n.useState(!1),[tt,H]=n.useState(null),[st,B]=n.useState(!1),[nt,z]=n.useState(null),[at,xe]=n.useState(!0),te=n.useRef(0),[be,Q]=n.useState(!1),[ue,_]=n.useState(""),[we,ve]=n.useState(!1),[me,He]=n.useState(!1),ct=fe(W,{locked:me}),ot=fe(ie,{locked:me}),rt=fe(ee,{locked:me}),it=fe(Le,{locked:me}),ge=K?ct:ot,Ne=l==="tasks"?d.trim():"",lt=l==="artifacts"?d.trim():"",{documents:se,loading:dt,error:ut,refresh:ne}=is({projectId:a,searchQuery:Ne||void 0,includeProjectFiles:!1}),{files:G,loading:mt,error:ht,refresh:ze}=ls(a,{showHidden:C}),{artifacts:O,loading:ft,error:kt,refresh:Se}=Bt({projectId:a,searchQuery:lt||void 0});n.useEffect(()=>{const s=()=>{re(window.innerWidth<=ds)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}},[]),n.useEffect(()=>{i("artifacts"),p(null),j(null),L(!1),M(null),S(null),q(!1),Me(!1),Re(new Map),R(null),D(""),E(null),F(null),je(!1),H(null),B(!1),z(null),xe(!0),Q(!1),_(""),ve(!1)},[a]);const Y=n.useMemo(()=>{const s=Ne.toLowerCase(),c=new Map;for(const o of se){const x=c.get(o.taskId)??{documents:[],artifacts:[]};x.documents.push(o),c.set(o.taskId,x)}for(const o of O){if(!o.taskId||!ks(o,s))continue;const x=c.get(o.taskId)??{documents:[],artifacts:[]};x.artifacts.push(o),c.set(o.taskId,x)}return Array.from(c.entries()).map(([o,x])=>{const I=[...x.documents].sort((v,ae)=>ae.updatedAt.localeCompare(v.updatedAt)),U=[...x.artifacts].sort((v,ae)=>ae.updatedAt.localeCompare(v.updatedAt)),Pe=[I[0]?.updatedAt,U[0]?.updatedAt].filter(Boolean).sort().at(-1)??"",f=I.find(v=>v.taskTitle)?.taskTitle??U.find(v=>v.taskTitle)?.taskTitle;return{taskId:o,taskTitle:f,taskColumn:I.find(v=>v.taskColumn)?.taskColumn??U.find(v=>v.taskColumn)?.taskColumn,documents:I,artifacts:U,latestUpdated:Pe}}).filter(o=>o.documents.length>0||o.artifacts.length>0).sort((o,x)=>x.latestUpdated.localeCompare(o.latestUpdated))},[O,se,Ne]),r=n.useMemo(()=>h?.kind!=="document"?null:se.find(s=>s.id===h.id)??null,[se,h]),$=n.useMemo(()=>h?.kind!=="artifact"?null:O.find(s=>s.id===h.id)??null,[O,h]),he=r??$;n.useEffect(()=>{if(!h)return;Y.some(c=>h.kind==="document"?c.documents.some(o=>o.id===h.id):c.artifacts.some(o=>o.id===h.id))||(j(null),R(null),D(""),E(null),F(null),H(null),B(!1),z(null))},[Y,h]);const Ce=n.useMemo(()=>{const s=d.trim().toLowerCase();return s?G.filter(c=>{const o=c.path.toLowerCase(),x=c.name.toLowerCase();return o.includes(s)||x.includes(s)}):G},[G,d]);n.useEffect(()=>{if(!k)return;G.some(c=>c.path===k.path)||(p(null),M(null),S(null),q(!1))},[G,k]);const pt=n.useCallback(s=>{b(s.target.value)},[]),jt=n.useCallback(()=>{b("")},[]),ye=n.useCallback(s=>{i(s),s!=="tasks"&&(j(null),R(null),D(""),E(null),F(null),H(null),B(!1),z(null)),s!=="project"&&(Q(!1),_(""))},[]),xt=n.useCallback(async s=>{try{const c=await Ve(s,a);T(c)}catch{m(`Failed to open task ${s}`,"error")}},[a,T,m]),Oe=n.useCallback(async s=>{try{const c=await Ve(s,a);(g??T)(c)}catch{m(`Failed to open task ${s}`,"error")}},[a,g,T,m]),bt=n.useCallback(async s=>{p(s),q(!0),S(null),M(null),Q(!1),_("");const c=A.current+1;A.current=c;try{const o=await _t("project",s.path,a);if(A.current!==c)return;M(o.content)}catch(o){if(A.current!==c)return;const x=o instanceof Error?o.message:`Failed to open ${s.path}`;S(x),m(x,"error")}finally{A.current===c&&q(!1)}},[a,m]),wt=n.useCallback(()=>{p(null),M(null),S(null),q(!1),Q(!1),_("")},[]),vt=n.useCallback(()=>{N!==null&&(_(N),Q(!0))},[N]),gt=n.useCallback(()=>{Q(!1),_("")},[]),Nt=n.useCallback(async()=>{if(k){ve(!0);try{await Ut("project",k.path,ue,a),M(ue),Q(!1),_(""),m(t("documents.projectFileSaved","File saved"),"success")}catch(s){m(s instanceof Error?s.message:String(s),"error")}finally{ve(!1)}}},[k,ue,a,m,t]),St=n.useCallback(s=>{j({kind:"document",id:s}),R(null),D(""),E(null),F(null),H(null),B(!1),z(null)},[]),Ct=n.useCallback(s=>{j({kind:"artifact",id:s}),R(null),D(""),E(null),F(null),H(null),z(null),xe(!0)},[]),yt=n.useCallback(()=>{j(null),R(null),D(""),E(null),F(null),H(null),B(!1),z(null)},[]),Tt=n.useCallback(s=>{Re(c=>{const o=new Map(c),x=o.get(s)??!0;return o.set(s,!x),o})},[]),Ft=n.useCallback(()=>{r&&(D(r.content),R(r.id),E({revision:r.revision,contentHash:r.contentHash}),F(null))},[r]),Pt=n.useCallback(()=>{R(null),D(""),E(null),F(null)},[]),At=n.useCallback(()=>{V&&(E(V),F(null))},[V]),Dt=n.useCallback(async()=>{if(!(!r||!le||V)){je(!0);try{await qt(r.taskId,r.key,pe,{expectedRevision:le.revision,expectedContentHash:le.contentHash},a),await ne(),R(null),D(""),E(null),F(null),m(t("documents.taskDocumentSaved","Document saved"),"success")}catch(s){if(typeof s=="object"&&s!==null&&"status"in s&&s.status===409)try{const c=await Vt(r.taskId,r.key,a);await ne(),F({revision:c.revision,contentHash:c.contentHash}),m(t("documents.taskDocumentStale","This document changed since you opened it. Your draft is preserved; review the latest revision, then choose Rebase draft before saving."),"error")}catch(c){m(c instanceof Error?c.message:String(c),"error")}else m(s instanceof Error?s.message:String(s),"error")}finally{je(!1)}}},[r,pe,le,V,a,ne,m,t]);n.useEffect(()=>{if(!$||Ae($)!=="doc"){H(null),B(!1),z(null);return}const s=te.current+1;te.current=s,B(!0),z(null),H(null),Qt($.id,a).then(c=>{te.current===s&&H(c.content??$.content??"")}).catch(c=>{te.current===s&&z(c instanceof Error?c.message:String(c))}).finally(()=>{te.current===s&&B(!1)})},[a,$]);const $e=l==="project"?ht:l==="tasks"?ut:kt,Et=n.useCallback(async()=>{if(l==="project"){await ze();return}if(l==="tasks"){await ne();return}await Se()},[l,Se,ze,ne]),Ie=l==="project"?Ce.length:l==="tasks"?Y.length:O.length,X=r?Ze.get(r.id)??!0:!1,Te=X?rt:it,Fe=r!==null&&et===r.id,Lt=l==="project"&&k&&!be&&w&&ge?e.jsx(Qe,{selectedText:ge.selectedText,anchorRect:ge.anchorRect,filePath:k.path,onSubmit:w,onOpenChange:He}):null,Mt=l==="tasks"&&r&&!Fe&&w&&Te?e.jsx(Qe,{selectedText:Te.selectedText,anchorRect:Te.anchorRect,filePath:`${r.taskId}/${r.key}`,onSubmit:w,onOpenChange:He}):null,Be=l==="project"?t("documents.searchProjectFiles","Search project markdown files…"):l==="tasks"?t("documents.searchTaskDocuments","Search task documents…"):t("documents.searchArtifacts","Search artifacts…");return e.jsxs("div",{className:"documents-view",children:[e.jsxs("div",{className:"documents-view-header",children:[e.jsx(Gt,{icon:ce,title:t("documents.title","Artifacts"),actions:e.jsx("span",{className:"documents-view-count",children:t("documents.resultCount","{{count}} result{{plural}}",{count:Ie,plural:Ie!==1?"s":""})})}),e.jsxs("div",{className:"documents-controls-row",children:[e.jsxs("div",{className:"documents-tab-bar",role:"tablist","aria-label":t("documents.sectionsLabel","Documents sections"),children:[e.jsxs("button",{className:`btn documents-tab${l==="artifacts"?" active":""}`,role:"tab","aria-selected":l==="artifacts","aria-label":t("documents.showArtifacts","Show artifacts"),onClick:()=>ye("artifacts"),children:[t("documents.artifactsTab","Artifacts"),e.jsx("span",{className:"documents-tab-count",children:O.length})]}),e.jsxs("button",{className:`btn documents-tab${l==="project"?" active":""}`,role:"tab","aria-selected":l==="project","aria-label":t("documents.showProjectFiles","Show project markdown files"),onClick:()=>ye("project"),children:[t("documents.projectFilesTab","Project Files"),e.jsx("span",{className:"documents-tab-count",children:G.length})]}),e.jsxs("button",{className:`btn documents-tab${l==="tasks"?" active":""}`,role:"tab","aria-selected":l==="tasks","aria-label":t("documents.showTaskDocuments","Show task documents"),onClick:()=>ye("tasks"),children:[t("documents.taskDocumentsTab","Task Documents"),e.jsx("span",{className:"documents-tab-count",children:Y.length})]})]}),l==="project"&&e.jsxs("button",{className:"btn btn-sm documents-hidden-toggle",onClick:()=>L(s=>!s),"aria-pressed":C,"aria-label":C?t("documents.hideHidden","Hide hidden project files"):t("documents.showHidden","Show hidden project files"),title:C?t("documents.hideHiddenFiles","Hide hidden files"):t("documents.showHiddenFiles","Show hidden files"),children:[C?e.jsx(Wt,{size:14}):e.jsx(Kt,{size:14}),C?t("documents.hideHiddenLabel","Hide Hidden"):t("documents.showHiddenLabel","Show Hidden")]}),e.jsxs("div",{className:"documents-search",children:[e.jsx(Yt,{size:16,className:"documents-search-icon"}),e.jsx("input",{type:"text",className:"documents-search-input",placeholder:Be,value:d,onChange:pt,"aria-label":Be}),d&&e.jsx("button",{className:"documents-search-clear",onClick:jt,"aria-label":t("documents.clearSearch","Clear search"),children:e.jsx(Xt,{size:16})})]})]})]}),e.jsx("div",{className:"documents-view-content",children:$e?e.jsxs("div",{className:"documents-view-error",children:[e.jsx("p",{children:t("documents.failedToLoad","Failed to load {{type}}: {{error}}",{type:l==="project"?t("documents.projectFiles","project files"):l==="tasks"?t("documents.taskDocuments","task documents"):t("documents.artifacts","artifacts"),error:$e})}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void Et(),"aria-label":t("documents.retryLoading","Retry loading documents"),children:[e.jsx(Jt,{size:16}),t("documents.retry","Retry")]})]}):l==="project"?mt&&G.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(ke,{label:t("documents.loadingProjectFiles","Loading project markdown files…")})})}):Ce.length===0?e.jsx("div",{className:"documents-view-empty",children:d.trim()?e.jsx("p",{children:t("documents.noMatchProject",'No project markdown files match "{{query}}".',{query:d.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:t("documents.noMarkdownFiles","No Markdown files found in this project.")})]})}):e.jsxs("div",{className:`documents-project-layout${y?" documents-project-layout--mobile":""}`,children:[(!y||!k)&&e.jsx("aside",{className:"documents-view-sidebar","aria-label":t("documents.projectMarkdownFilesLabel","Project markdown files"),children:e.jsx("ul",{className:"markdown-file-list",children:Ce.map(s=>{const c=k?.path===s.path;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item${c?" markdown-file-item--selected":""}`,onClick:()=>void bt(s),"aria-label":`Open ${s.path}`,"aria-current":c?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:s.name}),e.jsx("span",{className:"markdown-file-item-path",children:s.path}),e.jsxs("span",{className:"markdown-file-item-meta",children:[ms(s.size)," · ",oe(s.mtime)]})]})},s.path)})})}),(!y||k)&&e.jsxs("section",{className:"documents-view-main","aria-label":t("documents.projectFilePreviewLabel","Project file content preview"),children:[y&&k&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:wt,"aria-label":t("documents.backToFilesList","Back to project files list"),children:[e.jsx(Ge,{size:14}),t("documents.backToFiles","Back to files")]}),k?e.jsxs("div",{className:"documents-content-viewer",children:[e.jsxs("div",{className:"documents-content-header",children:[e.jsx("p",{className:"documents-file-path-header",children:k.path}),e.jsx("div",{className:"documents-task-document-actions",children:be?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm",onClick:gt,disabled:we,children:t("documents.cancelEdit","Cancel")}),e.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>void Nt(),disabled:we,children:we?t("documents.saving","Saving…"):t("documents.saveProjectFile","Save")})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>Me(s=>!s),"aria-label":K?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":K,title:K?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),children:K?t("documents.markdown","Markdown"):t("documents.plain","Plain")}),e.jsxs("button",{className:"btn btn-sm",onClick:vt,disabled:J||Z!==null||N===null,"aria-label":t("documents.editProjectFile","Edit project file"),children:[e.jsx(We,{size:14,"aria-hidden":"true"}),t("documents.edit","Edit")]})]})})]}),J?e.jsx("p",{className:"documents-content-state",children:e.jsx(ke,{label:t("documents.loadingFileContent","Loading file content…")})}):Z?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:Z}):be?e.jsx("div",{className:"documents-task-document-editor","aria-label":t("documents.projectFileContentEditor","Project file content editor"),children:e.jsx(Ke,{content:ue,onChange:_,filePath:k.path,forceToolbarActionsVisible:!0})}):K?e.jsx("div",{ref:W,className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(De,{remarkPlugins:[Ee],children:N??""})})}):e.jsx("pre",{ref:ie,className:"document-card-content-text documents-content-viewer-text",children:N??""}),Lt]}):e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:t("documents.selectFile","Select a Markdown file to view its content.")})})]})]}):l==="artifacts"?ft&&O.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:t("documents.loadingArtifacts","Loading artifacts…")})}):O.length===0?e.jsx("div",{className:"documents-view-empty",children:d.trim()?e.jsx("p",{children:t("documents.noMatchArtifacts",'No artifacts match "{{query}}".',{query:d.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:t("documents.noArtifacts","No artifacts yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:t("documents.artifactsCreatedBy","Agents register screenshots, wireframes, mockups, recordings, and documents here as they work on tasks.")})]})}):e.jsx(Zt,{artifacts:O,projectId:a,isMobile:y,addToast:m,onOpenTask:Oe,onArtifactUpdated:()=>void Se()}):dt&&se.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(ke,{label:t("documents.loadingTaskDocuments","Loading task documents…")})})}):Y.length===0?e.jsx("div",{className:"documents-view-empty",children:d.trim()?e.jsx("p",{children:t("documents.noMatchTask",'No task documents match "{{query}}".',{query:d.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:t("documents.noTaskDocuments","No task documents yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:t("documents.documentsCreatedIn","Documents are created in task detail tabs.")})]})}):e.jsxs("div",{className:`documents-project-layout documents-task-documents-layout${y?" documents-project-layout--mobile":""}`,children:[(!y||!he)&&e.jsx("aside",{className:"documents-view-sidebar documents-task-documents-sidebar","aria-label":t("documents.taskDocumentsListLabel","Task documents"),children:Y.map(({taskId:s,taskTitle:c,taskColumn:o,documents:x,artifacts:I})=>{const U=o?P(o):null,Pe=o?hs(o,u?.get(s)):"status-dot";return e.jsxs("section",{className:"documents-task-sidebar-group","aria-labelledby":`documents-task-group-${s}`,children:[e.jsxs("div",{className:"documents-task-sidebar-group-header",children:[e.jsxs("div",{className:"documents-task-sidebar-title-wrap",children:[e.jsxs("h3",{id:`documents-task-group-${s}`,className:"documents-task-sidebar-title",children:[e.jsx("span",{className:"documents-group-task-id",children:s}),e.jsx("span",{className:"documents-group-task-title",children:c||t("documents.untitled","Untitled")})]}),U?e.jsxs("span",{className:"documents-group-status badge","aria-label":t("documents.taskStatusAria","Task status: {{status}}",{status:U}),children:[e.jsx("span",{className:Pe,"aria-hidden":"true"}),e.jsx("span",{children:U})]}):null]}),e.jsxs("div",{className:"documents-task-sidebar-actions",children:[e.jsx("span",{className:"documents-group-count",children:t("documents.taskOutputCount","{{docCount}} doc{{docPlural}} · {{artifactCount}} artifact{{artifactPlural}}",{docCount:x.length,docPlural:x.length!==1?"s":"",artifactCount:I.length,artifactPlural:I.length!==1?"s":""})}),e.jsx("button",{className:"documents-group-task-link",onClick:()=>void xt(s),"aria-label":t("documents.openTaskAria","Open task {{taskId}}: {{title}}",{taskId:s,title:c||t("documents.untitled","Untitled")}),children:t("documents.openTask","Open task")})]})]}),e.jsxs("ul",{className:"markdown-file-list documents-task-document-list",children:[x.map(f=>{const v=r?.id===f.id;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item documents-task-document-item${v?" markdown-file-item--selected":""}`,onClick:()=>St(f.id),"aria-label":t("documents.openTaskDocument","Open {{taskId}} {{key}}",{taskId:f.taskId,key:f.key}),"aria-current":v?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:f.key}),e.jsxs("span",{className:"markdown-file-item-path",children:[f.taskId," · ",f.taskTitle||t("documents.untitled","Untitled")]}),e.jsxs("span",{className:"markdown-file-item-meta",children:[t("documents.revisionShort","v{{revision}}",{revision:f.revision})," · ",f.author," · ",oe(f.updatedAt)]})]})},`document-${f.id}`)}),I.length>0?e.jsxs("li",{className:"documents-task-artifacts-subsection","aria-label":t("documents.taskArtifactsSubsection","Task artifacts"),children:[e.jsx("div",{className:"documents-task-artifacts-label",children:t("documents.taskArtifactsLabel","Artifacts")}),e.jsx("ul",{className:"markdown-file-list documents-task-artifact-list",children:I.map(f=>{const v=Ae(f),ae=us[v],Rt=Je(t,v),_e=$?.id===f.id;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item documents-task-document-item documents-task-artifact-item${_e?" markdown-file-item--selected":""}`,onClick:()=>Ct(f.id),"aria-label":t("documents.openTaskArtifact","Open {{taskId}} artifact {{title}}",{taskId:s,title:f.title||t("documents.untitledArtifact","Untitled artifact")}),"aria-current":_e?"true":void 0,children:[e.jsxs("span",{className:"documents-task-artifact-title-row",children:[e.jsx(ae,{size:14,"aria-hidden":"true"}),e.jsx("span",{className:"markdown-file-item-name",children:f.title||t("documents.untitledArtifact","Untitled artifact")})]}),e.jsxs("span",{className:"markdown-file-item-path",children:[Rt," · ",f.mimeType||f.type]}),e.jsxs("span",{className:"markdown-file-item-meta",children:[f.authorId||t("documents.unknownAuthor","unknown")," · ",oe(f.updatedAt)]})]})},`artifact-${f.id}`)})})]}):null]})]},s)})}),(!y||he)&&e.jsxs("section",{className:"documents-view-main","aria-label":t("documents.taskDocumentPreviewLabel","Task document content preview"),children:[y&&he&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:yt,"aria-label":t("documents.backToTaskDocumentsList","Back to task documents list"),children:[e.jsx(Ge,{size:14}),t("documents.backToTaskDocuments","Back to documents")]}),he?$?e.jsx(js,{artifact:$,projectId:a,content:tt,loading:st,error:nt,renderMarkdown:at,onToggleMarkdown:()=>xe(s=>!s),onOpenTask:Oe,t}):r?e.jsxs("div",{className:"documents-content-viewer documents-task-document-viewer",children:[e.jsxs("div",{className:"documents-content-header documents-task-document-header",children:[e.jsxs("p",{className:"documents-file-path-header",children:[r.taskId," / ",r.key]}),e.jsx("div",{className:"documents-task-document-actions",children:Fe?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm",onClick:Pt,disabled:de,children:t("documents.cancelEdit","Cancel")}),V&&e.jsx("button",{className:"btn btn-sm",onClick:At,disabled:de,children:t("documents.rebaseTaskDocument","Rebase draft")}),e.jsx("button",{className:"btn btn-sm btn-primary",onClick:()=>void Dt(),disabled:de||V!==null,children:de?t("documents.saving","Saving…"):t("documents.saveTaskDocument","Save")})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>Tt(r.id),"aria-label":X?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":X,title:X?t("documents.switchToPlainText","Switch to plain text"):t("documents.switchToMarkdown","Switch to markdown"),children:X?t("documents.markdown","Markdown"):t("documents.plain","Plain")}),e.jsxs("button",{className:"btn btn-sm",onClick:Ft,"aria-label":t("documents.editTaskDocument","Edit task document"),children:[e.jsx(We,{size:14,"aria-hidden":"true"}),t("documents.edit","Edit")]})]})})]}),e.jsxs("div",{className:"document-card-meta documents-task-document-meta",children:[e.jsx("span",{className:"document-card-author",children:r.author}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{children:t("documents.revisionShort","v{{revision}}",{revision:r.revision})}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{className:"document-card-date",children:oe(r.updatedAt)})]}),Fe?e.jsx("div",{className:"documents-task-document-editor","aria-label":t("documents.taskDocumentContentEditor","Task document content editor"),children:e.jsx(Ke,{content:pe,onChange:D,filePath:r.key.includes(".")?r.key:`${r.key}.md`,forceToolbarActionsVisible:!0})}):X?e.jsx("div",{ref:ee,className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(De,{remarkPlugins:[Ee],children:r.content})})}):e.jsx("pre",{ref:Le,className:"document-card-content-text documents-content-viewer-text",children:r.content}),Mt]}):null:e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:t("documents.selectTaskDocument","Select a task document or artifact to view its content.")})})]})]})})]})}export{Ss as DocumentsView,hs as getTaskColumnStatusDotClass};
@@ -0,0 +1 @@
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{r as P,e as L,S as $,aU as J,aV as Q,b as O,aW as Z,aX as ee,aY as se,V as H,T as K,a3 as ae,R as te,aK as le,s as re,q as ne,aS as ie}from"./index-DpCHwyiD.js";import{u as ce}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const oe=300,de=15e3;function X(r){if(!r.trim())return;const a=Number(r);return Number.isFinite(a)?a:void 0}function I(...r){for(const a of r)if(Array.isArray(a))return a;return[]}function f(r){return typeof r=="object"&&r!==null?r:{}}function B(r){const a=f(r),m=f(a.taskSnapshot);return{id:String(a.id??a.evalId??""),runId:String(a.runId??a.batchId??""),taskId:String(a.taskId??m.taskId??""),taskTitle:String(m.title??a.taskTitle??a.title??"Untitled task"),createdAt:String(a.createdAt??a.timestamp??a.updatedAt??new Date(0).toISOString()),overallScore:typeof a.overallScore=="number"?a.overallScore:null,maxScore:typeof a.maxScore=="number"?a.maxScore:null,categoryScores:I(a.categoryScores,f(a.scores).categories)}}function ue(r){const a=f(r);return{...B(a),rationale:String(a.rationale??a.summary??""),evidence:I(a.evidence,f(a.details).evidence),followUps:I(a.followUps,f(a.recommendations).followUps)}}function ve(r){const a=r?.projectId,m=a??"",t=`${$.EVALS_RUNS_PREFIX}${m}`,h=`${$.EVALS_RESULTS_PREFIX}${m}`,p=P(t,{maxAgeMs:L}),v=P(h,{maxAgeMs:L}),S=l.useRef(Array.isArray(p)&&p.length>0||Array.isArray(v)&&v.length>0),[o,g]=l.useState({q:"",runId:"",scoreMin:"",scoreMax:""}),[N,w]=l.useState(()=>Array.isArray(p)?p:[]),[d,C]=l.useState(()=>Array.isArray(v)?v:[]),[u,A]=l.useState(null),[F,R]=l.useState(null),[s,i]=l.useState(0),[y,j]=l.useState(!S.current),[W,V]=l.useState(null),M=l.useRef(0),q=l.useRef(a),T=l.useRef(u);T.current=u;const k=l.useCallback(async()=>{const c=++M.current;S.current||j(!0),V(null);try{const[n,x]=await Promise.all([J({q:o.q||void 0,runId:o.runId||void 0,scoreMin:X(o.scoreMin),scoreMax:X(o.scoreMax),limit:100,offset:0},a),Q(a)]);if(c!==M.current)return;const E=I(n.results,n.evals,n.items).map(B);C(E),O(h,E.length>500?E.slice(0,500):E,{maxBytes:5e5}),i(typeof n.count=="number"?n.count:E.length);const z=I(x.runs,x.items).map(U=>{const b=f(U),D=f(b.counts);return{id:String(b.id??""),createdAt:String(b.createdAt??""),completedAt:typeof b.completedAt=="string"?b.completedAt:void 0,status:String(b.status??"pending"),evaluatedTaskCount:typeof D.totalTasks=="number"?D.totalTasks:0}});w(z),O(t,z,{maxBytes:5e5}),S.current=!0,T.current&&!E.some(U=>U.id===T.current)&&(A(null),R(null))}catch(n){if(c!==M.current)return;V(n instanceof Error?n.message:"Failed to load evals")}finally{c===M.current&&j(!1)}},[o.q,o.runId,o.scoreMax,o.scoreMin,a,h,t]),_=l.useCallback(async c=>{const n=await Z(c,a),x=n.result??n;R(ue(x))},[a]);l.useEffect(()=>{if(q.current===a)return;q.current=a;const c=P(t,{maxAgeMs:L}),n=P(h,{maxAgeMs:L}),x=Array.isArray(c)&&c.length>0||Array.isArray(n)&&n.length>0;w(Array.isArray(c)?c:[]),C(Array.isArray(n)?n:[]),j(!x),S.current=x},[a,h,t]),l.useEffect(()=>{const c=window.setTimeout(()=>{k()},oe);return()=>window.clearTimeout(c)},[k]),l.useEffect(()=>{if(!u){R(null);return}_(u)},[_,u]);const Y=l.useCallback(()=>{k(),u&&_(u)},[_,k,u]);ee(Y,de);const G=l.useCallback(c=>{T.current=c,A(c)},[]);return{loading:y,error:W,results:d,count:s,runs:N,filters:o,setFilters:g,refresh:k,selectedEvalId:u,setSelectedEvalId:G,selectedEval:F}}function je({projectId:r,onOpenSettings:a,onOpenTaskDetail:m}){const{t}=ce("app"),{loading:h,error:p,results:v,runs:S,filters:o,setFilters:g,selectedEvalId:N,setSelectedEvalId:w,selectedEval:d,refresh:C}=ve({projectId:r}),[u,A]=l.useState(!0);l.useEffect(()=>{let s=!1;return se(r).then(i=>{if(s)return;const y=i.evalSettings?.enabled;A(y??!1)}).catch(()=>{s||A(!1)}),()=>{s=!0}},[r]);const F=v.length>0,R=l.useMemo(()=>v.find(s=>s.id===N)??null,[v,N]);return u?e.jsxs("section",{className:"evals-view","data-testid":"evals-view",children:[e.jsx(H,{icon:K,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__body",children:[e.jsxs("div",{className:"evals-list card",children:[e.jsxs("div",{className:"evals-toolbar",children:[e.jsx("input",{className:"input",placeholder:t("evals.searchPlaceholder","Search task or rationale"),value:o.q,onChange:s=>g(i=>({...i,q:s.target.value}))}),e.jsxs("select",{className:"select",value:o.runId,onChange:s=>g(i=>({...i,runId:s.target.value})),children:[e.jsx("option",{value:"",children:t("evals.allRuns","All runs")}),S.map(s=>e.jsx("option",{value:s.id,children:s.id},s.id))]}),e.jsx("input",{className:"input",placeholder:t("evals.minScorePlaceholder","Min score"),value:o.scoreMin,onChange:s=>g(i=>({...i,scoreMin:s.target.value}))}),e.jsx("input",{className:"input",placeholder:t("evals.maxScorePlaceholder","Max score"),value:o.scoreMax,onChange:s=>g(i=>({...i,scoreMax:s.target.value}))}),e.jsx("button",{className:"btn btn-icon",type:"button",onClick:()=>void C(),"aria-label":t("evals.refreshAria","Refresh evals"),children:e.jsx(te,{size:16})})]}),h&&e.jsx("p",{className:"evals-state","data-testid":"evals-loading",children:e.jsx(le,{label:t("evals.loading","Loading evals…")})}),p&&e.jsx("p",{className:"evals-state evals-state--error",children:p}),!h&&!p&&!F&&e.jsx("p",{className:"evals-state",children:t("evals.empty","No evals yet. Scheduled evals review tasks completed since the last run.")}),e.jsx("ul",{className:"evals-results","data-testid":"evals-results",children:v.map(s=>e.jsx("li",{children:e.jsxs("button",{className:`evals-result ${s.id===N?"evals-result--active":""}`,type:"button",onClick:()=>w(s.id),draggable:ne(),onDragStart:i=>{re(i.dataTransfer,{kind:"eval-result",id:s.id,projectId:r})},children:[e.jsx("span",{className:"evals-result-title",children:s.taskTitle}),e.jsxs("span",{className:"evals-result-meta",children:[s.taskId," · ",s.runId," · ",s.overallScore??t("evals.naPlaceholder","n/a")]})]})},s.id))})]}),e.jsxs("div",{className:"evals-detail card","data-testid":"evals-detail",children:[!d&&e.jsx("p",{className:"evals-state",children:t("evals.selectPrompt","Select an evaluation to inspect scores, rationale, and evidence.")}),d&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"evals-detail-title",children:R?.taskTitle??d.taskTitle}),e.jsxs("p",{className:"evals-result-meta",children:[d.taskId," · ",d.runId]}),e.jsx("p",{className:"evals-score",children:t("evals.overallScore","Overall score: {{score}}",{score:d.overallScore??t("evals.naPlaceholder","n/a")})}),e.jsx("ul",{className:"evals-categories",children:d.categoryScores.map(s=>e.jsxs("li",{children:[s.category,": ",s.finalScore]},s.category))}),e.jsx("p",{className:"evals-rationale",children:d.rationale||t("evals.noRationale","No rationale recorded.")}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.evidenceHeading","Evidence")}),e.jsx("ul",{className:"evals-links",children:d.evidence.map((s,i)=>{const y=typeof s.metadata?.taskId=="string"?s.metadata.taskId:void 0,j=typeof s.metadata?.url=="string"?s.metadata.url:void 0;return e.jsx("li",{children:y?e.jsx("button",{type:"button",className:"btn",onClick:()=>m?.(y),children:s.ref}):j?e.jsxs("a",{href:j,target:"_blank",rel:"noreferrer",className:"evals-external-link",children:[s.ref,e.jsx(ie,{size:14})]}):e.jsx("span",{children:s.ref})},`${s.ref}-${i}`)})})]}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.suggestedFollowupsHeading","Suggested follow-up tasks")}),e.jsxs("ul",{className:"evals-follow-ups",children:[d.followUps.length===0&&e.jsx("li",{children:t("evals.noFollowups","None")}),d.followUps.map(s=>e.jsxs("li",{children:[e.jsx("strong",{children:s.title}),e.jsx("p",{children:s.rationale})]},s.suggestionId))]})]})]})]})]})]}):e.jsxs("section",{className:"evals-view","data-testid":"evals-disabled",children:[e.jsx(H,{icon:K,title:t("evals.title","Evals")}),e.jsxs("div",{className:"evals-view__empty",children:[e.jsx("h2",{className:"evals-title",children:t("evals.disabledTitle","Scheduled evals are disabled")}),e.jsx("p",{className:"evals-empty-copy",children:t("evals.enablePrompt","Enable Scheduled Evals to review scored tasks, evidence, and follow-up recommendations.")}),e.jsxs("button",{className:"btn btn-primary",type:"button",onClick:()=>a?.("scheduled-evals"),children:[e.jsx(ae,{size:16}),t("evals.openSettings","Open Scheduled Evals Settings")]})]})]})}export{je as EvalsView};
@@ -0,0 +1 @@
1
+ import{r as s,j as e}from"./vendor-react-SZ_qB27O.js";import{I as F,J as K,K as V,N as W,O as $,Q as z,U}from"./index-DpCHwyiD.js";import{u as J}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function te({isOpen:l,onClose:R,onUseDraft:M,projectId:x,existingAgents:P,mode:w="create",existingAgentConfig:L}){const{t:n}=J("app"),[g,d]=s.useState("initial"),[f,_]=s.useState(""),[c,S]=s.useState(null),[C,I]=s.useState(""),[k,A]=s.useState("answer"),[p,v]=s.useState(""),[t,H]=s.useState(null),[T,h]=s.useState(null),[E,y]=s.useState([]),b=w==="edit",o=s.useRef(l),N=s.useCallback(()=>{d("initial"),_(""),S(null),I(""),A("answer"),v(""),H(null),h(null),y([])},[]),O=s.useMemo(()=>F.map(a=>({id:a.id,label:a.name,description:a.description})),[]);s.useEffect(()=>{if(o.current=l,!c)return;const a=K(c,x,{onThinking:r=>{o.current&&y(G=>{const u=[...G],j=u[u.length-1];return j&&!j.question?(u[u.length-1]={...j,thinkingOutput:`${j.thinkingOutput??""}${r}`},u):[...u,{response:{},thinkingOutput:r}]})},onQuestion:r=>{o.current&&(I(r.question),A(r.id),d("question"))},onSummary:r=>{o.current&&(H(r),d("summary"))},onError:r=>{o.current&&(h(r),d("error"))}});return()=>{o.current=!1,a.close()}},[l,c,x]);const m=async()=>{o.current=!1;try{c&&await $(c,x)}catch{}finally{N(),R()}};if(s.useEffect(()=>{o.current=l,l||N()},[l,N]),!l)return null;const i=a=>a==null||a===""?e.jsx("em",{className:"experimental-agent-onboarding-modal__summary-empty",children:n("agents.onboarding.notSet","Not set")}):e.jsx("span",{children:a}),Q=async()=>{d("loading"),h(null);try{const a=await z(f,{mode:w,existingAgentConfig:L,existingAgents:P.map(r=>({id:r.id,name:r.name,role:r.role})),templates:O},x);if(!o.current)return;S(a.sessionId)}catch(a){if(!o.current)return;h(a.message),d("error")}},q=async()=>{if(c){d("loading"),h(null);try{const a={[k]:p};if(y(r=>[...r,{question:{id:k,type:"text",question:C},response:a}]),await U(c,a,x),!o.current)return;v("")}catch(a){if(!o.current)return;h(a.message),d("error")}}},D=async()=>{t&&(M(t),await m())};return e.jsx(V,{windowKey:"experimental-agent-onboarding",modal:!0,title:n("agents.onboarding.title","AI Interview"),ariaLabel:n("agents.onboarding.dialogLabel","AI Interview"),onClose:()=>void m(),hideHeader:!0,dragHandleSelector:".experimental-agent-onboarding-modal .modal-header",className:"floating-window--experimental-agent-onboarding",defaultSize:{width:720,height:620},minSize:{width:420,height:320},persistGeometryKey:"floating-window:experimental-agent-onboarding",suspendGeometryPersistenceOnMobile:!0,suspendGeometryPersistenceOnShortViewport:!0,children:e.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",children:[e.jsxs("div",{className:"modal-header",children:[e.jsx("h3",{children:n("agents.onboarding.title","AI Interview")}),e.jsx("button",{className:"modal-close",onClick:()=>void m(),"aria-label":n("common.closeAriaLabel","Close"),children:"×"})]}),E.length>0&&e.jsx(W,{entries:E}),g==="initial"&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-intent",children:b?n("agents.onboarding.intentLabelEdit","What should this agent change or improve?"):n("agents.onboarding.intentLabelCreate","What should this new agent own?")}),e.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:f,onChange:a=>_(a.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",disabled:!f.trim(),onClick:()=>void Q(),children:b?n("agents.onboarding.startInterview","Start interview"):n("agents.onboarding.startOnboarding","Start onboarding")})]})]}),(g==="loading"||g==="question")&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"agent-onboarding-answer",children:C||n("agents.onboarding.thinking","Thinking...")}),e.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:p,onChange:a=>v(a.target.value)}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",disabled:g==="loading"||!p.trim(),onClick:()=>void q(),children:n("agents.onboarding.continue","Continue")})]})]}),g==="summary"&&t&&e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:b?n("agents.onboarding.updatedDraftReady","Updated draft ready for review"):n("agents.onboarding.draftReady","Draft ready for review")}),e.jsx("p",{className:"experimental-agent-onboarding-modal__summary-intro",children:n("agents.onboarding.draftIntro","Review this generated draft. Nothing is applied until you confirm.")}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionIdentity","Identity")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldName","Name")}),e.jsx("dd",{children:i(t.name)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldRole","Role")}),e.jsx("dd",{children:i(t.role)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldTitle","Title")}),e.jsx("dd",{children:i(t.title)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldIcon","Icon")}),e.jsx("dd",{children:i(t.icon)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldReportsTo","Reports To")}),e.jsx("dd",{children:i(t.reportsTo)})]})]})]}),e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionConfiguration","Configuration")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldInlineInstructions","Inline Instructions")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.instructionsText)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldSoul","Soul")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.soul)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldAgentMemory","Agent Memory")}),e.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:i(t.memory)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldSkills","Skills")}),e.jsx("dd",{children:i(t.skills?.join(", "))})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldThinkingLevel","Thinking Level")}),e.jsx("dd",{children:i(t.thinkingLevel)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldMaxTurns","Max Turns")}),e.jsx("dd",{children:i(t.maxTurns)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldTemplate","Template")}),e.jsx("dd",{children:i(t.templateId)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldPatternAgent","Pattern Agent")}),e.jsx("dd",{children:i(t.patternAgentId)})]})]})]}),(t.heartbeatProcedurePath||t.heartbeatIntervalMs||t.heartbeatEnabled!==void 0||t.modelHint||t.runtimeHint)&&e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionRuntimeHints","Runtime Hints")}),e.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatPath","Heartbeat Procedure Path")}),e.jsx("dd",{children:i(t.heartbeatProcedurePath)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatInterval","Heartbeat Interval")}),e.jsx("dd",{children:i(t.heartbeatIntervalMs?`${t.heartbeatIntervalMs}ms`:void 0)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldHeartbeatEnabled","Heartbeat Enabled")}),e.jsx("dd",{children:i(t.heartbeatEnabled===void 0?void 0:t.heartbeatEnabled?n("agents.onboarding.yes","yes"):n("agents.onboarding.no","no"))})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldModelHint","Model Hint")}),e.jsx("dd",{children:i(t.modelHint)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:n("agents.onboarding.fieldRuntimeHint","Runtime Hint")}),e.jsx("dd",{children:i(t.runtimeHint)})]})]})]}),t.rationale&&e.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[e.jsx("h4",{children:n("agents.onboarding.sectionRationale","Rationale")}),e.jsx("p",{className:"experimental-agent-onboarding-modal__summary-block",children:t.rationale})]})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.cancel","Cancel")}),e.jsx("button",{className:"btn btn-primary",onClick:()=>void D(),children:b?n("agents.onboarding.applyDraftSettings","Apply draft to settings form"):n("agents.onboarding.applyDraftAgent","Apply draft to agent form")})]})]}),g==="error"&&T&&e.jsxs("div",{className:"form-group",children:[e.jsx("div",{className:"form-error",children:T}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{className:"btn",onClick:()=>void m(),children:n("common.close","Close")})})]})]})})}export{te as ExperimentalAgentOnboardingModal};
@@ -1,2 +1,2 @@
1
- import{r as n,j as t}from"./vendor-react-SZ_qB27O.js";import{V as js,T as ws,P as Ns,S as Es,j as Ss,r as $s,k as Ms,X as Cs,s as Ts,l as As,m as Gs,n as Ls}from"./index-CtYRoouR.js";import{u as Ds}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const Ps=5,Fs=3,Rs=280;function h(d,m){if(!m)return d;const r=d.includes("?")?"&":"?";return`${d}${r}projectId=${encodeURIComponent(m)}`}function is(d){return!!(d&&typeof d=="object"&&"code"in d&&d.code==="ACTIVE_GOAL_LIMIT_EXCEEDED")}function Hs({initialGoals:d,anchorGoalId:m,projectId:r,onNavigateToMission:as}){const{t:a}=Ds("app"),[c,k]=n.useState(()=>d??[]),[ns,j]=n.useState(null),p=n.useRef(null),[w,L]=n.useState(d===void 0),[D,l]=n.useState(null),[os,P]=n.useState(!1),[v,F]=n.useState(""),[R,N]=n.useState(""),[U,u]=n.useState(null),[O,_]=n.useState(!1),[y,E]=n.useState(!1),[S,V]=n.useState(null),[q,$]=n.useState(""),[B,M]=n.useState(""),[H,f]=n.useState(null),[I,z]=n.useState(!1),[ls,rs]=n.useState(()=>new Set),[ds,cs]=n.useState([]),[x,C]=n.useState({}),[T,W]=n.useState({}),[A,K]=n.useState(null),[us,X]=n.useState(null);n.useEffect(()=>{if(d!==void 0)return;let s=!0;return(async()=>{try{L(!0),l(null);const i=await fetch(h("/api/goals",r));if(!i.ok)throw new Error(`Failed to load goals (${i.status})`);const o=await i.json();if(!s)return;k(Array.isArray(o.goals)?o.goals:[])}catch{if(!s)return;l(a("goals.loadError","Unable to load goals right now. Please try again."))}finally{s&&L(!1)}})(),()=>{s=!1}},[d,r]),n.useEffect(()=>{let s=!0;return(async()=>{try{const i=await fetch(h("/api/missions",r));if(!i.ok)throw new Error(`Failed to load missions (${i.status})`);const o=await i.json(),g=Array.isArray(o)?o:Array.isArray(o.missions)?o.missions:[];s&&cs(g.map(b=>({id:b.id,title:b.title,status:b.status})))}catch{s&&l(a("goals.missionsLoadError","Unable to load missions right now. Please try again."))}})(),()=>{s=!1}},[r,a]);const J=async s=>{const e=await fetch(h(`/api/goals/${encodeURIComponent(s)}/missions`,r));if(!e.ok)throw new Error(`Failed to load linked missions (${e.status})`);const i=await e.json();return Array.isArray(i.missions)?i.missions:[]};n.useEffect(()=>{let s=!0;return(async()=>{if(c.length===0){C({});return}try{const i=await Promise.all(c.map(async o=>[o.id,await J(o.id)]));s&&C(Object.fromEntries(i))}catch{s&&l(a("goals.linkedMissionsLoadError","Unable to load linked missions right now. Please try again."))}})(),()=>{s=!1}},[c,a]);const G=n.useMemo(()=>c.filter(s=>s.status==="active").length,[c]),gs=G>=Fs&&G<=Ps;n.useEffect(()=>{if(!m){j(null);return}const s=document.getElementById(`goal-card-${m}`);if(s)return j(m),typeof s.scrollIntoView=="function"&&s.scrollIntoView({behavior:"smooth",block:"center"}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{j(e=>e===m?null:e),p.current=null},1600),()=>{p.current&&(clearTimeout(p.current),p.current=null)}},[m,c]);function ms(){l(null),u(null),P(!0)}function hs(s){V(s.id),$(s.title),M(s.description??""),f(null)}function Q(){V(null),$(""),M(""),f(null)}function Y(){P(!1),F(""),N(""),u(null),E(!1)}async function ps(){const s=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{E(!0),u(null);const e=await Gs(s,r);N(e)}catch(e){u(Ls(e))}finally{E(!1)}}async function fs(){const s=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{_(!0),u(null),l(null);const e=await fetch(h("/api/goals",r),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:R})});if(e.ok){const o=await e.json();k(g=>[...g,o]),Y();return}let i=null;try{i=await e.json()}catch{i=null}if(e.status===409&&is(i)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}u(a("goals.createError","Unable to create goal right now. Please try again."))}catch{u(a("goals.createError","Unable to create goal right now. Please try again."))}finally{_(!1)}}async function bs(){if(!S)return;const s=q.trim();if(!s){f(a("goals.titleRequired","Title is required."));return}try{z(!0),f(null);const e=await fetch(h(`/api/goals/${S}`,r),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:B})});if(!e.ok)throw new Error(`Failed to update goal (${e.status})`);const i=await e.json();k(o=>o.map(g=>g.id===i.id?i:g)),Q()}catch{f(a("goals.saveError","Unable to save goal right now. Please try again."))}finally{z(!1)}}function ks(s){return s.length>Rs||s.includes(`
1
+ import{r as n,j as t}from"./vendor-react-SZ_qB27O.js";import{V as js,T as ws,P as Ns,m as Es,n as Ss,o as $s,p as Ms,X as Cs,s as Ts,q as As,u as Gs,v as Ls}from"./index-DpCHwyiD.js";import{u as Ds}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";const Ps=5,Fs=3,Rs=280;function h(d,m){if(!m)return d;const r=d.includes("?")?"&":"?";return`${d}${r}projectId=${encodeURIComponent(m)}`}function is(d){return!!(d&&typeof d=="object"&&"code"in d&&d.code==="ACTIVE_GOAL_LIMIT_EXCEEDED")}function Hs({initialGoals:d,anchorGoalId:m,projectId:r,onNavigateToMission:as}){const{t:a}=Ds("app"),[c,k]=n.useState(()=>d??[]),[ns,j]=n.useState(null),p=n.useRef(null),[w,L]=n.useState(d===void 0),[D,l]=n.useState(null),[os,P]=n.useState(!1),[v,F]=n.useState(""),[R,N]=n.useState(""),[U,u]=n.useState(null),[O,_]=n.useState(!1),[y,E]=n.useState(!1),[S,V]=n.useState(null),[q,$]=n.useState(""),[B,M]=n.useState(""),[H,f]=n.useState(null),[I,z]=n.useState(!1),[ls,rs]=n.useState(()=>new Set),[ds,cs]=n.useState([]),[x,C]=n.useState({}),[T,W]=n.useState({}),[A,K]=n.useState(null),[us,X]=n.useState(null);n.useEffect(()=>{if(d!==void 0)return;let s=!0;return(async()=>{try{L(!0),l(null);const i=await fetch(h("/api/goals",r));if(!i.ok)throw new Error(`Failed to load goals (${i.status})`);const o=await i.json();if(!s)return;k(Array.isArray(o.goals)?o.goals:[])}catch{if(!s)return;l(a("goals.loadError","Unable to load goals right now. Please try again."))}finally{s&&L(!1)}})(),()=>{s=!1}},[d,r]),n.useEffect(()=>{let s=!0;return(async()=>{try{const i=await fetch(h("/api/missions",r));if(!i.ok)throw new Error(`Failed to load missions (${i.status})`);const o=await i.json(),g=Array.isArray(o)?o:Array.isArray(o.missions)?o.missions:[];s&&cs(g.map(b=>({id:b.id,title:b.title,status:b.status})))}catch{s&&l(a("goals.missionsLoadError","Unable to load missions right now. Please try again."))}})(),()=>{s=!1}},[r,a]);const J=async s=>{const e=await fetch(h(`/api/goals/${encodeURIComponent(s)}/missions`,r));if(!e.ok)throw new Error(`Failed to load linked missions (${e.status})`);const i=await e.json();return Array.isArray(i.missions)?i.missions:[]};n.useEffect(()=>{let s=!0;return(async()=>{if(c.length===0){C({});return}try{const i=await Promise.all(c.map(async o=>[o.id,await J(o.id)]));s&&C(Object.fromEntries(i))}catch{s&&l(a("goals.linkedMissionsLoadError","Unable to load linked missions right now. Please try again."))}})(),()=>{s=!1}},[c,a]);const G=n.useMemo(()=>c.filter(s=>s.status==="active").length,[c]),gs=G>=Fs&&G<=Ps;n.useEffect(()=>{if(!m){j(null);return}const s=document.getElementById(`goal-card-${m}`);if(s)return j(m),typeof s.scrollIntoView=="function"&&s.scrollIntoView({behavior:"smooth",block:"center"}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{j(e=>e===m?null:e),p.current=null},1600),()=>{p.current&&(clearTimeout(p.current),p.current=null)}},[m,c]);function ms(){l(null),u(null),P(!0)}function hs(s){V(s.id),$(s.title),M(s.description??""),f(null)}function Q(){V(null),$(""),M(""),f(null)}function Y(){P(!1),F(""),N(""),u(null),E(!1)}async function ps(){const s=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{E(!0),u(null);const e=await Gs(s,r);N(e)}catch(e){u(Ls(e))}finally{E(!1)}}async function fs(){const s=v.trim();if(!s){u(a("goals.titleRequired","Title is required."));return}try{_(!0),u(null),l(null);const e=await fetch(h("/api/goals",r),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:R})});if(e.ok){const o=await e.json();k(g=>[...g,o]),Y();return}let i=null;try{i=await e.json()}catch{i=null}if(e.status===409&&is(i)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}u(a("goals.createError","Unable to create goal right now. Please try again."))}catch{u(a("goals.createError","Unable to create goal right now. Please try again."))}finally{_(!1)}}async function bs(){if(!S)return;const s=q.trim();if(!s){f(a("goals.titleRequired","Title is required."));return}try{z(!0),f(null);const e=await fetch(h(`/api/goals/${S}`,r),{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:B})});if(!e.ok)throw new Error(`Failed to update goal (${e.status})`);const i=await e.json();k(o=>o.map(g=>g.id===i.id?i:g)),Q()}catch{f(a("goals.saveError","Unable to save goal right now. Please try again."))}finally{z(!1)}}function ks(s){return s.length>Rs||s.includes(`
2
2
  `)}function vs(s){rs(e=>{const i=new Set(e);return i.has(s)?i.delete(s):i.add(s),i})}function Z(s){const e=new Set((x[s]??[]).map(i=>i.id));return ds.filter(i=>!e.has(i.id))}async function ss(s){const e=await J(s);C(i=>({...i,[s]:e})),W(i=>({...i,[s]:""}))}async function ys(s){const e=T[s];if(e)try{K(s),l(null);const i=await fetch(h(`/api/missions/${encodeURIComponent(e)}/goals/${encodeURIComponent(s)}`,r),{method:"POST"});if(!i.ok)throw new Error(`Failed to link mission (${i.status})`);await ss(s)}catch{l(a("goals.linkMissionError","Unable to link mission right now. Please try again."))}finally{K(null)}}async function xs(s,e){try{X(`${s}:${e}`),l(null);const i=await fetch(h(`/api/missions/${encodeURIComponent(e)}/goals/${encodeURIComponent(s)}`,r),{method:"DELETE"});if(!i.ok)throw new Error(`Failed to unlink mission (${i.status})`);await ss(s)}catch{l(a("goals.unlinkMissionError","Unable to unlink mission right now. Please try again."))}finally{X(null)}}async function ts(s){const e=s.status==="active"?`/api/goals/${s.id}/archive`:`/api/goals/${s.id}/unarchive`;try{l(null);const i=await fetch(h(e,r),{method:"POST"});if(i.ok){const g=await i.json();k(b=>b.map(es=>es.id===g.id?g:es));return}let o=null;try{o=await i.json()}catch{o=null}if(i.status===409&&is(o)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}l(a("goals.updateError","Unable to update goal status right now. Please try again."))}catch{l(a("goals.updateError","Unable to update goal status right now. Please try again."))}}return t.jsxs("section",{className:"goals-view","data-testid":"goals-view",children:[t.jsx(js,{icon:ws,title:a("goals.title","Goals"),actions:t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"goals-count","data-testid":"goals-active-count",children:a("goals.activeCount","{{count}} active goals",{count:G})}),t.jsxs("button",{type:"button",className:"btn btn-primary goals-add-button",onClick:ms,"data-testid":"goals-add-button",children:[t.jsx(Ns,{size:18,"aria-hidden":"true"}),a("goals.addGoal","Add Goal")]})]})}),t.jsxs("div",{className:"goals-view__content",children:[os?t.jsxs("div",{className:"card goals-form","data-testid":"goals-form",children:[t.jsx("label",{className:"goals-form-label",htmlFor:"goals-form-title",children:a("goals.labelTitle","Title")}),t.jsx("input",{id:"goals-form-title",className:"input",type:"text",value:v,maxLength:200,onChange:s=>F(s.target.value),"data-testid":"goals-form-title"}),t.jsxs("div",{className:"goals-form-label-row",children:[t.jsx("label",{className:"goals-form-label",htmlFor:"goals-form-description",children:a("goals.labelDescription","Description")}),t.jsxs("button",{type:"button",className:"btn goals-form-draft-button",onClick:()=>void ps(),disabled:!v.trim()||y,"data-testid":"goals-form-draft-ai",children:[t.jsx(Es,{"aria-hidden":"true"}),y?a("goals.drafting","Drafting…"):a("goals.draftWithAi","Draft with AI")]})]}),t.jsx("textarea",{id:"goals-form-description",className:"input",value:R,maxLength:5e3,onChange:s=>N(s.target.value),"data-testid":"goals-form-description"}),U?t.jsx("p",{className:"form-error goals-error",role:"alert",children:U}):null,t.jsxs("div",{className:"goals-form-actions",children:[t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void fs(),disabled:O||y,"data-testid":"goals-form-submit",children:a("actions.save","Save")}),t.jsx("button",{type:"button",className:"btn",onClick:Y,disabled:O||y,"data-testid":"goals-form-cancel",children:a("actions.cancel","Cancel")})]})]}):null,gs?t.jsx("p",{className:"goals-warning",role:"status",children:a("goals.capWarning","Approaching the 5-active goal cap. Keep active goals focused.")}):null,D?t.jsx("p",{className:"form-error goals-error",role:"alert","data-testid":"goals-error",children:D}):null,w?t.jsx("p",{className:"goals-loading",role:"status","data-testid":"goals-loading",children:a("goals.loading","Loading goals…")}):null,!w&&c.length===0?t.jsx("div",{className:"goals-empty card","data-testid":"goals-empty-state",children:a("goals.emptyState","No goals yet. Add one to begin tracking strategic outcomes.")}):null,!w&&c.length>0?t.jsx("div",{className:"goals-list","data-testid":"goals-list",children:c.map(s=>t.jsxs("article",{id:`goal-card-${s.id}`,className:`card goals-card ${s.status==="archived"?"goals-card-archived":""} ${ns===s.id?"goals-card--anchored":""}`.trim(),"data-testid":`goal-card-${s.id}`,draggable:As(),onDragStart:e=>{Ts(e.dataTransfer,{kind:"goal",id:s.id,projectId:r})},children:[S===s.id?t.jsxs("div",{className:"goals-card-main goals-card-edit",children:[t.jsx("label",{className:"goals-form-label",htmlFor:`goal-edit-title-${s.id}`,children:a("goals.labelTitle","Title")}),t.jsx("input",{id:`goal-edit-title-${s.id}`,className:"input",type:"text",value:q,maxLength:200,onChange:e=>$(e.target.value),"data-testid":`goal-edit-title-${s.id}`}),t.jsx("label",{className:"goals-form-label",htmlFor:`goal-edit-description-${s.id}`,children:a("goals.labelDescription","Description")}),t.jsx("textarea",{id:`goal-edit-description-${s.id}`,className:"input",value:B,maxLength:5e3,onChange:e=>M(e.target.value),"data-testid":`goal-edit-description-${s.id}`}),H?t.jsx("p",{className:"form-error goals-error",role:"alert",children:H}):null,t.jsxs("div",{className:"goals-card-actions",children:[t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void bs(),disabled:I,"data-testid":`goal-edit-save-${s.id}`,children:a("actions.save","Save")}),t.jsx("button",{type:"button",className:"btn",onClick:Q,disabled:I,"data-testid":`goal-edit-cancel-${s.id}`,children:a("actions.cancel","Cancel")})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"goals-card-main",children:[t.jsx("h3",{className:"goals-card-title",children:s.title}),s.description?(()=>{const e=ks(s.description),i=ls.has(s.id);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`markdown-body goals-card-description ${e&&!i?"goals-card-description-collapsed":""}`.trim(),children:t.jsx(Ss,{remarkPlugins:[$s],children:s.description})}),e?t.jsx("button",{type:"button",className:"btn goals-card-description-toggle","aria-expanded":i,"data-testid":`goal-description-toggle-${s.id}`,onClick:()=>vs(s.id),children:i?a("actions.showLess","Show less"):a("actions.showMore","Show more")}):null]})})():null,t.jsxs("p",{className:"goals-card-status",children:[a("goals.status","Status"),": ",s.status]})]}),t.jsxs("div",{className:"goals-card-actions",children:[t.jsx("button",{type:"button",className:"btn",onClick:()=>hs(s),"data-testid":`goal-edit-${s.id}`,children:a("actions.edit","Edit")}),s.status==="active"?t.jsx("button",{type:"button",className:"btn goals-activate-button",onClick:()=>void ts(s),"data-testid":`goal-archive-${s.id}`,children:a("goals.archive","Archive")}):t.jsx("button",{type:"button",className:"btn goals-activate-button",onClick:()=>void ts(s),"data-testid":`goal-unarchive-${s.id}`,children:a("goals.unarchive","Unarchive")})]})]}),t.jsxs("section",{className:"goals-linked-missions","aria-label":a("goals.linkedMissions","Linked missions"),children:[t.jsxs("div",{className:"goals-linked-missions-header",children:[t.jsx("h4",{className:"goals-linked-missions-title",children:a("goals.linkedMissionsTitle","Linked Missions")}),t.jsx("span",{className:"goals-linked-missions-count",children:a("goals.linkedMissionsCount",{count:x[s.id]?.length??0,defaultValue_one:"{{count}} linked",defaultValue_other:"{{count}} linked"})})]}),t.jsxs("div",{className:"goals-linked-missions-controls",children:[t.jsxs("select",{className:"input goals-linked-missions-picker","data-testid":`goal-mission-picker-${s.id}`,value:T[s.id]??"",onChange:e=>W(i=>({...i,[s.id]:e.target.value})),"aria-label":a("goals.missionPicker","Mission to link"),disabled:A===s.id||Z(s.id).length===0,children:[t.jsx("option",{value:"",children:a("goals.selectMission","Select a mission")}),Z(s.id).map(e=>t.jsx("option",{value:e.id,children:e.title},e.id))]}),t.jsxs("button",{type:"button",className:"btn btn-primary goals-linked-missions-link-button","data-testid":`goal-mission-link-button-${s.id}`,disabled:!T[s.id]||A===s.id,onClick:()=>void ys(s.id),children:[t.jsx(Ms,{size:16,"aria-hidden":"true"}),A===s.id?a("goals.linkingMission","Linking…"):a("goals.linkMission","Link mission")]})]}),(x[s.id]?.length??0)>0?t.jsx("div",{className:"goals-linked-missions-list",children:(x[s.id]??[]).map(e=>t.jsxs("div",{className:"goals-linked-mission-chip","data-testid":`goal-linked-mission-chip-${e.id}`,children:[t.jsx("button",{type:"button",className:"btn goals-linked-mission-link",onClick:()=>as?.(e.id),children:e.title}),t.jsx("span",{className:"goals-linked-mission-status",children:e.status}),t.jsx("button",{type:"button",className:"btn-icon goals-linked-mission-unlink","data-testid":`goal-linked-mission-unlink-${e.id}`,"aria-label":a("goals.unlinkMission","Unlink mission"),disabled:us===`${s.id}:${e.id}`,onClick:()=>void xs(s.id,e.id),children:t.jsx(Cs,{size:16,"aria-hidden":"true"})})]},e.id))}):t.jsx("p",{className:"goals-linked-missions-empty",children:a("goals.noLinkedMissions","No linked missions.")})]})]},s.id))}):null]})]})}export{Hs as GoalsView};
@@ -0,0 +1,11 @@
1
+ import{r as i,j as e}from"./vendor-react-SZ_qB27O.js";import{c as ze,r as le,e as Ce,S as je,cJ as Me,cK as Ze,b as Ne,cL as es,cM as ss,cN as ts,cO as is,cP as ns,cQ as as,cR as Ie,cS as rs,cT as os,cU as cs,cq as ls,cV as Re,V as hs,m as q,bW as ds,X as Ae,cW as fe,R as K,a3 as gs,cv as us,as as De,l as ae,bF as ve,bE as Te,P as $e,aS as ms,b0 as Pe,cX as fs,s as vs,q as ys}from"./index-DpCHwyiD.js";import{u as Ge}from"./vendor-i18n-Duky4gdQ.js";import{U as Ee}from"./users-CTqECGLo.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";/**
2
+ * @license lucide-react v1.7.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const xs=[["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3",key:"cabbwy"}],["rect",{x:"4",y:"2",width:"16",height:"20",rx:"2",key:"1uxh74"}]],ps=ze("building",xs);/**
7
+ * @license lucide-react v1.7.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const bs=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],ks=ze("chart-line",bs),me=["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 Ss(g,m){const M=Date.parse(g.createdAt),p=Date.parse(m.createdAt),b=Number.isFinite(M),s=Number.isFinite(p);return!b||!s?b?-1:s?1:0:M!==p?p-M:g.id===m.id?0:g.id<m.id?1:-1}function ws(g){const{t:m}=Ge("app"),M=g??"",p=`${je.INSIGHTS_PREFIX}${M}`,b=`${je.INSIGHT_LATEST_RUN_PREFIX}${M}`,s=le(p,{maxAgeMs:Ce}),Y=le(b,{maxAgeMs:Me}),P=i.useRef(Array.isArray(s)&&s.length>0),U=i.useCallback(r=>m(`insights.category.${r}`,Fe[r]??r),[m]),[y,N]=i.useState(()=>Array.isArray(s)?s:[]),[H,Q]=i.useState(()=>me.map(r=>({category:r,label:Fe[r]??r,items:[],isLoading:!1,error:null}))),[O,E]=i.useState(!(Array.isArray(s)&&s.length>0)),[J,F]=i.useState(null),[G,I]=i.useState(Y??null),[L,_]=i.useState(!1),[w,z]=i.useState(null),[T,B]=i.useState(new Map),[Z,l]=i.useState(new Map),[k,u]=i.useState(new Map),[x,h]=i.useState(new Map),[C,R]=i.useState(!1),v=i.useCallback(async()=>{P.current||E(!0),F(null);try{const n=(await Ze({status:void 0,limit:1e3},g)).insights.filter(d=>d.status!=="dismissed");N(n),Ne(p,n.length>500?n.slice(0,500):n,{maxBytes:5e5});const o=await es(g);o.runs.length>0&&(I(o.runs[0]),Ne(b,o.runs[0],{maxBytes:5e5})),P.current=!0}catch(r){const n=r instanceof Error?r.message:"Failed to fetch insights";F(n)}finally{E(!1)}},[p,b,g]),ee=i.useCallback(()=>{R(r=>!r)},[]),j=i.useCallback(async(r,n,o)=>{_(!0),z(null);try{const d=await ss("manual",void 0,g,r,n,o);I(d),d.status==="completed"?await v():d.status==="failed"&&d.error&&z(d.error)}catch(d){if(d instanceof ts&&d.status===409&&d.details?.code==="ACTIVE_RUN_CONFLICT"){const re=typeof d.details.activeRunId=="string"?d.details.activeRunId:null;if(re)try{const ue=await is(re,g);I(ue)}catch{}throw z("Insight generation is already running"),d}const S=d instanceof Error?d.message:"Failed to generate insights";throw z(S),d}finally{_(!1)}},[g,v]),D=i.useCallback(async r=>{B(n=>{const o=new Map(n);return o.set(r,{running:!0,error:null}),o});try{await ns(r,g),N(n=>n.filter(o=>o.id!==r)),B(n=>{const o=new Map(n);return o.set(r,{running:!1,error:null}),o})}catch(n){const o=n instanceof Error?n.message:"Failed to dismiss insight";throw B(d=>{const S=new Map(d);return S.set(r,{running:!1,error:o}),S}),n}},[g]),V=i.useCallback(async r=>{l(n=>{const o=new Map(n);return o.set(r,{running:!0,error:null}),o});try{const n=await as(r,g);return await Ie(r,g),N(o=>o.map(d=>d.id===r?{...d,status:"archived",updatedAt:new Date().toISOString()}:d)),l(o=>{const d=new Map(o);return d.set(r,{running:!1,error:null}),d}),{title:n.suggestedTitle,description:n.suggestedDescription}}catch(n){const o=n instanceof Error?n.message:"Failed to create task";throw l(d=>{const S=new Map(d);return S.set(r,{running:!1,error:o}),S}),n}},[g]);i.useEffect(()=>{const r=new Map;for(const n of me)r.set(n,[]);for(const n of y){if(!C&&n.status==="archived")continue;const o=r.get(n.category)??[];r.set(n.category,[...o,n])}Q(me.map(n=>({category:n,label:U(n),items:[...r.get(n)??[]].sort(Ss),isLoading:!1,error:null})))},[y,C,U]);const he=i.useCallback(async r=>{u(n=>{const o=new Map(n);return o.set(r,{running:!0,error:null}),o});try{await Ie(r,g),N(n=>n.map(o=>o.id===r?{...o,status:"archived",updatedAt:new Date().toISOString()}:o)),u(n=>{const o=new Map(n);return o.set(r,{running:!1,error:null}),o})}catch(n){const o=n instanceof Error?n.message:"Failed to archive insight";throw u(d=>{const S=new Map(d);return S.set(r,{running:!1,error:o}),S}),n}},[g]),de=i.useCallback(async r=>{h(n=>{const o=new Map(n);return o.set(r,{running:!0,error:null}),o});try{await rs(r,g),N(n=>n.map(o=>o.id===r?{...o,status:"confirmed",updatedAt:new Date().toISOString()}:o)),h(n=>{const o=new Map(n);return o.set(r,{running:!1,error:null}),o})}catch(n){const o=n instanceof Error?n.message:"Failed to unarchive insight";throw h(d=>{const S=new Map(d);return S.set(r,{running:!1,error:o}),S}),n}},[g]),ge=i.useMemo(()=>H.reduce((r,n)=>r+n.items.length,0),[H]),A=i.useMemo(()=>0,[]),te=i.useMemo(()=>y.filter(r=>r.status==="archived").length,[y]);return i.useEffect(()=>{const r=le(p,{maxAgeMs:Ce}),n=le(b,{maxAgeMs:Me}),o=Array.isArray(r)&&r.length>0;N(Array.isArray(r)?r:[]),I(n??null),E(!o),P.current=o},[p,b]),i.useEffect(()=>{v()},[v]),{sections:H,loading:O,error:J,latestRun:G,isRunInFlight:L,runError:w,refresh:v,runInsights:j,dismiss:D,createTask:V,archive:he,unarchive:de,toggleShowArchived:ee,dismissStates:T,createTaskStates:Z,archiveStates:k,unarchiveStates:x,totalCount:ge,dismissedCount:A,archivedCount:te,showArchived:C}}const Cs=20,js=50;function Ms(g){const[m,M]=i.useState([]),[p,b]=i.useState(!0),[s,Y]=i.useState(!1),[P,U]=i.useState(null),[y,N]=i.useState(!1),[H,Q]=i.useState(0),[O,E]=i.useState(!1),[J,F]=i.useState(new Map),G=i.useRef(0),I=i.useRef(0),L=i.useRef(!1),_=i.useRef(new Set),w=i.useRef(0),z=i.useRef(g),T=i.useCallback(async k=>{if(L.current)return;L.current=!0;const u=w.current,x=k?0:G.current;k?b(!0):Y(!0),U(null);try{const h=await os(g,{limit:js,offset:x});if(u!==w.current)return;M(v=>{const ee=k?[]:v,j=new Set(ee.map(D=>`${D.taskId}:${D.recommendation.id}`));return[...ee,...h.items.filter(D=>{const V=`${D.taskId}:${D.recommendation.id}`;return j.has(V)?!1:(j.add(V),!0)})]}),G.current=h.rowOffset+h.returnedRowCount,I.current=k?1:I.current+1,Q(h.totalRowCount);const R=I.current>=Cs&&h.hasMore;E(R),N(R?!1:h.hasMore)}catch(h){u===w.current&&U(h instanceof Error?h.message:"Failed to fetch task recommendations")}finally{u===w.current&&(b(!1),Y(!1)),L.current=!1}},[g]),B=i.useCallback(async()=>{G.current=0,I.current=0,E(!1),await T(!0)},[T]);i.useEffect(()=>{z.current=g,w.current+=1,L.current=!1,_.current.clear(),G.current=0,I.current=0,M([]),N(!1),Q(0),E(!1),F(new Map),T(!0)},[T,g]);const Z=i.useCallback(async()=>{!y||O||L.current||await T(!1)},[T,y,O]),l=i.useCallback(async(k,u)=>{const x=`${k}:${u}`;if(_.current.has(x))return;_.current.add(x);const h=w.current;F(C=>new Map(C).set(x,{running:!0,error:null}));try{const C=await cs(k,u,z.current);if(h!==w.current)return;M(R=>R.map(v=>v.taskId===k&&v.recommendation.id===u?{...v,recommendation:{...v.recommendation,createdTaskId:C.task.id}}:v)),F(R=>new Map(R).set(x,{running:!1,error:null}))}catch(C){h===w.current&&F(R=>new Map(R).set(x,{running:!1,error:C instanceof Error?C.message:"Could not create task"}))}finally{h===w.current&&_.current.delete(x)}},[]);return{items:m,loading:p,loadingMore:s,error:P,hasMore:y,totalRowCount:H,truncated:O,refresh:B,loadMore:Z,createTask:l,createStates:J}}const Ue=["Backlog health:","Backlog pressure detected","Stale paused todo","Backlog health: dependency-blocked todos"];function Le(g){return Ue.some(m=>g.title.startsWith(m))}const _e={architecture:ps,quality:De,workflow:Pe,performance:Te,reliability:K,security:ae,ux:Ee,testability:fe,documentation:ms,dependency:$e,features:ve,competitive_analysis:Ee,research:ks,trends:Te,other:q};function Ls({projectId:g,addToast:m,onClose:M,onCreateTask:p,models:b}){const{t:s}=Ge("app"),{sections:Y,loading:P,error:U,latestRun:y,isRunInFlight:N,runError:H,refresh:Q,runInsights:O,dismiss:E,createTask:J,archive:F=async()=>{},unarchive:G=async()=>{},toggleShowArchived:I=()=>{},dismissStates:L,createTaskStates:_,archiveStates:w=new Map,unarchiveStates:z=new Map,totalCount:T,archivedCount:B=0,showArchived:Z=!1}=ws(g),l=Ms(g),[k,u]=i.useState(null),[x,h]=i.useState("info"),[C,R]=i.useState(!1),[v,ee]=i.useState(!1),[j,D]=i.useState(()=>localStorage.getItem("fusion-insight-model")??""),[V,he]=i.useState(()=>localStorage.getItem("fusion-insight-thinking")??""),[de,ge]=i.useState([]),[A,te]=i.useState([]),[r,n]=i.useState([]),[o,d]=i.useState();i.useEffect(()=>{b||ls().then(t=>{ge(t.models),te(t.favoriteProviders),n(t.favoriteModels),d(t.resolvedPlanningProvider);const a=localStorage.getItem("fusion-insight-model");a&&(t.models.some(f=>`${f.provider}/${f.id}`===a)||(localStorage.removeItem("fusion-insight-model"),D("")))}).catch(()=>{})},[b]);const S=b??de,re=i.useMemo(()=>A.length>0?A:o?[o]:[],[A,o]),ue=i.useCallback(async t=>{const c=A.includes(t)?A.filter(f=>f!==t):[t,...A];te(c);try{await Re({favoriteProviders:c,favoriteModels:r})}catch{te(A)}},[A,r]),He=i.useCallback(async t=>{const c=r.includes(t)?r.filter(f=>f!==t):[t,...r];n(c);try{await Re({favoriteProviders:A,favoriteModels:c})}catch{n(r)}},[r,A]),Oe=i.useCallback(t=>{D(t),t?localStorage.setItem("fusion-insight-model",t):localStorage.removeItem("fusion-insight-model")},[]),Be=i.useCallback(t=>{he(t),t?localStorage.setItem("fusion-insight-thinking",t):localStorage.removeItem("fusion-insight-thinking")},[]),ie=i.useMemo(()=>Y.filter(t=>t.items.length>0),[Y]),ye=i.useMemo(()=>ie.reduce((t,a)=>t+a.items.filter(Le).length,0),[ie]),X=i.useMemo(()=>v?ie.map(t=>({...t,items:t.items.filter(Le)})).filter(t=>t.items.length>0):ie,[ie,v]),[$,ne]=i.useState(null);i.useEffect(()=>{if($==="recommendations"&&l.items.length>0)return;if(X.length===0){l.items.length>0?ne("recommendations"):$!==null&&ne(null);return}$&&X.some(a=>a.category===$&&a.items.length>0)||ne(X[0]?.category??(l.items.length>0?"recommendations":null))},[X,$,l.items.length]);const W=i.useMemo(()=>$==="recommendations"?void 0:X.find(t=>t.category===$)??X[0],[X,$]);i.useEffect(()=>{if(k){const t=setTimeout(()=>u(null),5e3);return()=>clearTimeout(t)}},[k]);const xe=i.useCallback(async()=>{try{u(s("insights.generatingInsights","Generating insights...")),h("info");let t,a;if(j){const c=j.indexOf("/");if(c!==-1){const f=j.slice(0,c),oe=j.slice(c+1);f&&oe&&(t=f,a=oe)}}await O(t,a,V||void 0),u(s("insights.generationStarted","Insight generation started")),h("success"),m(s("insights.generationStarted","Insight generation started"),"success")}catch(t){const a=t instanceof Error?t.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.")),h("info"),m(s("insights.alreadyRunningShort","Insight generation is already running"),"info");return}u(a),h("error"),m(a,"error")}},[O,m,j,V,s]),Ve=i.useCallback(async(t,a)=>{try{u(s("insights.dismissing",'Dismissing "{{title}}"...',{title:a})),h("info"),await E(t),u(s("insights.dismissed",'Dismissed "{{title}}"',{title:a})),h("success"),m(s("insights.dismissedMsg","Insight dismissed: {{title}}",{title:a}),"success")}catch(c){const f=c instanceof Error?c.message:s("insights.failedToDismiss","Failed to dismiss insight");u(f),h("error"),m(f,"error")}},[E,m,s]),Xe=i.useCallback(async(t,a)=>{try{u(s("insights.archiving",'Archiving "{{title}}"...',{title:a})),h("info"),await F(t),u(s("insights.archived",'Archived "{{title}}"',{title:a})),h("success"),m(s("insights.archivedMsg","Insight archived: {{title}}",{title:a}),"success")}catch(c){const f=c instanceof Error?c.message:s("insights.failedToArchive","Failed to archive insight");u(f),h("error"),m(f,"error")}},[F,m,s]),We=i.useCallback(async(t,a)=>{try{u(s("insights.unarchiving",'Unarchiving "{{title}}"...',{title:a})),h("info"),await G(t),u(s("insights.unarchived",'Unarchived "{{title}}"',{title:a})),h("success"),m(s("insights.unarchivedMsg","Insight unarchived: {{title}}",{title:a}),"success")}catch(c){const f=c instanceof Error?c.message:s("insights.failedToUnarchive","Failed to unarchive insight");u(f),h("error"),m(f,"error")}},[G,m,s]),qe=i.useCallback(async(t,a)=>{try{if(u(s("insights.creatingTask",'Creating task from "{{title}}"...',{title:a})),h("info"),!p)throw new Error(s("insights.taskCreationUnavailable","Task creation is unavailable in this view"));const c=await J(t);if(!c)throw new Error(s("insights.failedToPreparePayload","Failed to prepare task payload from insight"));await p({insightId:t,title:c.title,description:c.description}),u(s("insights.taskCreated",'Task created from "{{title}}"',{title:a})),h("success"),m(s("insights.taskCreatedMsg","Task created: {{title}}",{title:c.title}),"success")}catch(c){const f=c instanceof Error?c.message:s("insights.failedToCreateTask","Failed to create task");u(f),h("error"),m(f,"error")}},[J,p,m,s]),Ke=t=>{const a=_e[t.category]??q,c=W?.category===t.category;return e.jsx("li",{children:e.jsxs("button",{type:"button",className:`insights-category-item${c?" insights-category-item--active":""}`,onClick:()=>ne(t.category),"aria-current":c?"true":void 0,"data-testid":`insights-category-${t.category}`,children:[e.jsx(a,{size:16,className:"insights-category-icon"}),e.jsx("span",{className:"insights-category-label",children:t.label}),e.jsx("span",{className:"insights-category-count",children:t.items.length})]})},t.category)},Ye=()=>e.jsxs("section",{className:"insights-section insights-recommendations","data-testid":"insights-section-recommendations",children:[e.jsx("div",{className:"insights-section-header",children:e.jsxs("div",{className:"insights-section-title",children:[e.jsx(ve,{size:18,className:"insights-section-icon"}),e.jsx("h3",{children:s("insights.recommendations.title","Task Recommendations")}),e.jsx("span",{className:"insights-section-count",children:l.items.length})]})}),e.jsx("p",{className:"insights-recommendations__count",children:s("insights.recommendations.count","Showing {{shown}} of {{total}} source tasks",{shown:l.items.length,total:l.totalRowCount})}),e.jsx("ul",{className:"insights-list",children:l.items.map(t=>{const a=`${t.taskId}:${t.recommendation.id}`,c=l.createStates.get(a),f=t.recommendation.createdTaskId;return e.jsxs("li",{className:"insight-item insights-recommendations__item","data-testid":`task-recommendation-${a}`,children:[e.jsxs("div",{className:"insight-item-header",children:[e.jsx("h4",{className:"insight-item-title",children:t.recommendation.title}),e.jsx("span",{className:"insights-category-count",children:t.recommendation.category})]}),e.jsx("p",{children:t.recommendation.description}),e.jsx("p",{className:"insights-recommendations__source",children:s("insights.recommendations.source","Source: {{task}}",{task:t.taskTitle?`${t.taskId} — ${t.taskTitle}`:t.taskId})}),f?e.jsx("span",{role:"status",children:s("taskDetail.recommendations.created","Created {{taskId}}",{taskId:f})}):e.jsxs("div",{children:[e.jsx("button",{className:"btn btn-primary",type:"button",disabled:c?.running,onClick:()=>void l.createTask(t.taskId,t.recommendation.id),children:c?.running?s("taskDetail.recommendations.creating","Creating…"):c?.error?s("taskDetail.recommendations.retry","Retry creating task"):s("taskDetail.recommendations.create","Create task")}),c?.error&&e.jsx("span",{role:"status",children:s("taskDetail.recommendations.error","Could not create task. Try again.")})]})]},a)})}),l.truncated?e.jsx("p",{role:"status",children:s("insights.recommendations.truncated","Showing the first 20 pages. Refresh to see the latest recommendations.")}):l.hasMore?e.jsx("button",{className:"btn",type:"button",disabled:l.loadingMore,onClick:()=>void l.loadMore(),children:l.loadingMore?s("insights.recommendations.loadingMore","Loading more…"):s("insights.recommendations.loadMore","Load more")}):null,l.error&&!l.loading&&e.jsxs("div",{role:"status",children:[e.jsx("span",{children:s("insights.recommendations.loadMoreFailed","Could not load more recommendations.")}),e.jsx("button",{className:"btn",type:"button",onClick:()=>void(l.hasMore?l.loadMore():l.refresh()),children:s("actions.retry","Retry")})]})]}),Qe=()=>{if(!W)return null;const t=_e[W.category]??q;return e.jsxs("section",{className:"insights-section","data-testid":`insights-section-${W.category}`,children:[e.jsx("div",{className:"insights-section-header",children:e.jsxs("div",{className:"insights-section-title",children:[e.jsx(t,{size:18,className:"insights-section-icon"}),e.jsx("h3",{children:W.label}),e.jsx("span",{className:"insights-section-count",children:W.items.length})]})}),e.jsx("div",{className:"insights-section-content",children:e.jsx("ul",{className:"insights-list",children:W.items.map(a=>{const c=L.get(a.id),f=_.get(a.id),oe=w.get(a.id),Je=z.get(a.id),pe=c?.running??!1,be=f?.running??!1,ke=oe?.running??!1,Se=Je?.running??!1,we=a.status==="archived",ce=W.items.some(se=>L.get(se.id)?.running||_.get(se.id)?.running||w.get(se.id)?.running||z.get(se.id)?.running);return e.jsxs("li",{className:`insight-item${we?" insight-item--archived":""}`,"data-insight-id":a.id,draggable:ys(),onDragStart:se=>{vs(se.dataTransfer,{kind:"research-finding",id:a.id,projectId:g})},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 We(a.id,a.title),disabled:Se||ce,title:s("insights.unarchiveTitle","Unarchive this insight"),"aria-label":s("insights.unarchiveLabel","Unarchive this insight"),"data-testid":`unarchive-${a.id}`,children:Se?e.jsx(K,{size:16,className:"spin"}):e.jsx(fs,{size:16})}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void qe(a.id,a.title),disabled:be||ce,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:be?e.jsx(K,{size:16,className:"spin"}):e.jsx($e,{size:16})}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Xe(a.id,a.title),disabled:ke||ce,title:s("insights.archiveTitle","Archive this insight"),"aria-label":s("insights.archiveLabel","Archive this insight"),"data-testid":`archive-${a.id}`,children:ke?e.jsx(K,{size:16,className:"spin"}):e.jsx(fe,{size:16})})]}),e.jsx("button",{className:"insight-item-action-btn",onClick:()=>void Ve(a.id,a.title),disabled:pe||ce,title:s("insights.dismissTitle","Dismiss this insight"),"aria-label":s("insights.dismissLabel","Dismiss this insight"),"data-testid":`dismiss-${a.id}`,children:pe?e.jsx(K,{size:16,className:"spin"}):e.jsx(Ae,{size:16})})]})]}),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(Pe,{size:12}),new Date(a.createdAt).toLocaleDateString()]})]})]},a.id)})})})]})};return e.jsxs("div",{className:"insights-view","data-testid":"insights-view",children:[e.jsx(hs,{icon:q,title:s("insights.title","Insights"),actions:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"insights-view-count",children:[T," ",s("common.total","total")]}),ye>0&&e.jsxs("button",{className:`btn btn-sm insights-backlog-health-toggle${v?" btn-icon--active":""}`,onClick:()=>ee(t=>!t),"aria-pressed":v,"aria-label":v?s("insights.showAllInsights","Show all insights"):s("insights.showBacklogHealth","Show only backlog health insights"),"data-testid":"toggle-backlog-health",title:Ue.join(", "),children:[e.jsx(ds,{size:14}),v?s("insights.allInsights","All Insights"):s("insights.backlogHealth","Backlog")," ",e.jsxs("span",{children:["(",ye,")"]})]}),M&&e.jsx("button",{className:"btn btn-sm insights-view-close",onClick:M,"aria-label":s("actions.closeInsightsView","Close insights view"),title:s("actions.close","Close"),children:e.jsx(Ae,{size:16})}),B>0&&e.jsxs("button",{className:"btn btn-sm insights-show-archived-toggle",onClick:I,"aria-label":Z?s("insights.hideArchived","Hide archived insights"):s("insights.showArchived","Show archived insights"),"data-testid":"toggle-archived-insights",children:[e.jsx(fe,{size:14}),Z?s("insights.hideArchivedLabel","Archived"):s("insights.showArchivedLabel","Archived ({{count}})",{count:B})]}),e.jsx("button",{className:"btn btn-icon btn-sm insights-refresh-btn",onClick:()=>void Q(),disabled:P,"aria-label":s("actions.refreshInsights","Refresh insights"),title:s("actions.refreshInsights","Refresh insights"),"data-testid":"refresh-insights",children:e.jsx(K,{size:14,className:P?"spin":""})}),e.jsxs("button",{className:"btn btn-sm insights-model-toggle",onClick:()=>R(t=>!t),"aria-label":s("insights.configureModel","Configure insight generation model"),"aria-expanded":C,"data-testid":"toggle-model-config",title:j?s("insights.modelConfigured","Model: {{model}}",{model:j}):s("insights.configureModelTitle","Configure model"),children:[e.jsx(gs,{size:14}),j&&e.jsx("span",{className:"insights-model-indicator"})]}),e.jsx("button",{className:"btn btn-primary btn-sm",onClick:()=>void xe(),disabled:N,"aria-label":s("insights.generateInsights","Generate new insights"),"data-testid":"run-insights",children:N?e.jsxs(e.Fragment,{children:[e.jsx(K,{size:14,className:"spin"}),s("insights.generating","Generating...")]}):e.jsxs(e.Fragment,{children:[e.jsx(q,{size:14}),s("insights.generateInsightsBtn","Generate Insights")]})})]})}),C&&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(us,{models:S,value:j,onChange:Oe,placeholder:s("insights.usePlanningDefault","Use planning default"),label:s("insights.generationModel","Insight generation model"),disabled:N,id:"insight-model-select",favoriteProviders:re,favoriteModels:r,onToggleFavorite:ue,onToggleModelFavorite:He,showThinkingLevel:!0,thinkingLevel:V,onThinkingLevelChange:Be,defaultThinkingLevel:"off"})]}),e.jsx("div",{className:"insights-status-region","aria-live":"polite","data-testid":"insights-status",children:k&&e.jsxs("div",{className:`insights-status-message insights-status-message--${x}`,role:x==="error"?"alert":void 0,children:[x==="success"&&e.jsx(De,{size:16}),x==="error"&&e.jsx(ae,{size:16}),x==="info"&&e.jsx(q,{size:16}),e.jsx("span",{children:k})]})}),H&&e.jsxs("div",{className:"insights-error-callout",role:"alert","data-testid":"run-error",children:[e.jsx(ae,{size:16}),e.jsx("span",{children:H})]}),y&&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:")," ",y.status,y.status==="completed"&&e.jsxs(e.Fragment,{children:[" — ",s("insights.runCompleted","{{created}} created, {{updated}} updated",{created:y.insightsCreated,updated:y.insightsUpdated})]}),y.status==="failed"&&y.error&&e.jsxs(e.Fragment,{children:[" — ",y.error]})]})}),l.error&&!l.loading&&l.items.length===0&&e.jsxs("div",{className:"insights-error-callout",role:"status","data-testid":"task-recommendations-error",children:[e.jsx(ae,{size:16}),e.jsx("span",{children:s("insights.recommendations.loadMoreFailed","Could not load more recommendations.")}),e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>void l.refresh(),children:s("actions.retry","Retry")})]}),P?e.jsxs("div",{className:"insights-loading","data-testid":"insights-loading",children:[e.jsx(K,{size:24,className:"spin"}),e.jsx("p",{children:s("insights.loading","Loading insights...")})]}):U?e.jsxs("div",{className:"insights-error","data-testid":"insights-error",children:[e.jsx(ae,{size:24}),e.jsx("p",{children:U}),e.jsx("button",{className:"btn btn-sm",onClick:()=>void Q(),children:s("actions.retry","Retry")})]}):T===0&&l.items.length===0?e.jsxs("div",{className:"insights-empty","data-testid":"insights-empty",children:[e.jsx(q,{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 xe(),children:[e.jsx(q,{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.jsxs("ul",{className:"insights-category-list",children:[X.map(Ke),l.items.length>0&&e.jsx("li",{children:e.jsxs("button",{type:"button",className:`insights-category-item${$==="recommendations"?" insights-category-item--active":""}`,onClick:()=>ne("recommendations"),"data-testid":"insights-category-recommendations",children:[e.jsx(ve,{size:16,className:"insights-category-icon"}),e.jsx("span",{className:"insights-category-label",children:s("insights.recommendations.title","Task Recommendations")}),e.jsxs("span",{className:"insights-category-count",children:[l.items.length,l.hasMore?`/${l.totalRowCount}`:""]})]})})]})}),e.jsx("div",{className:"insights-detail",children:$==="recommendations"?Ye():Qe()})]})]})}export{Ls as InsightsView};
@@ -1 +1 @@
1
- .memory-view{display:flex;flex-direction:column;height:100%;overflow:hidden;width:100%;min-width:0;flex:1 1 auto}.memory-view-tabs{display:flex;flex-direction:row;gap:var(--space-xs);border-bottom:1px solid var(--border);margin:var(--space-md) 0 var(--space-lg);padding:0 var(--space-lg);flex-shrink:0}.memory-view-tab{padding:var(--space-sm) var(--space-md);border-radius:var(--radius-sm) var(--radius-sm) 0 0;color:var(--text-muted);background:transparent;border:none;cursor:pointer;font-size:13px;transition:background var(--transition-fast),color var(--transition-fast)}.memory-view-tab:hover{background:var(--card-hover);color:var(--text)}.memory-view-tab:focus-visible{outline:none;box-shadow:var(--focus-ring)}.memory-view-tab--active{color:var(--text);border-bottom:2px solid var(--accent);font-weight:500}.memory-view-content{flex:1;min-height:0;display:flex;flex-direction:column;padding:0 var(--space-lg) var(--space-lg)}.memory-working-tab,.memory-insights-tab,.memory-engines-tab{flex:1;min-height:0;display:flex;flex-direction:column;overflow-y:auto;width:100%}.memory-action-bar,.memory-config-section{flex-shrink:0}.memory-working-tab .memory-editor-section{display:flex;flex-direction:column;flex:0 0 auto;min-height:0}.memory-working-tab .memory-editor-section>.form-group,.memory-working-tab .memory-editor-section>.memory-file-summary{flex:0 0 auto}.memory-working-tab .memory-editor-form-group{display:flex;flex-direction:column;flex:0 0 auto;min-height:0}.memory-editor-container{border:1px solid var(--border);border-radius:var(--radius-md);overflow:hidden;display:flex;flex-direction:column;flex:1 1 auto;min-height:calc(var(--space-xl) * 13 + var(--space-xs) * 2);max-height:60vh}.memory-editor-container .cm-editor{height:100%;min-height:0}.memory-editor-container .cm-scroller{overflow:auto}.memory-insights-editor-layout{display:flex;flex:1;min-height:0;flex-direction:column}.memory-category-section{margin-bottom:var(--space-lg)}.memory-category-header{display:flex;flex-direction:row;justify-content:space-between;align-items:center;cursor:pointer;padding:var(--space-sm) 0;border-bottom:1px solid var(--border);transition:opacity var(--transition-fast)}.memory-category-header:hover{opacity:.8}.memory-category-header h4{font-size:14px;font-weight:500;margin:0;color:var(--text)}.memory-category-count{font-size:.75rem;color:var(--text-muted);background:color-mix(in srgb,var(--text-muted) 15%,transparent);padding:2px 8px;border-radius:var(--radius-pill)}.memory-category-items{padding-top:var(--space-sm);display:flex;flex-direction:column;gap:var(--space-xs)}.memory-insight-item{padding:var(--space-sm) var(--space-md);border:1px solid var(--border);border-left:3px solid color-mix(in srgb,var(--accent) 55%,transparent);border-radius:var(--radius-md);background:var(--card);font-size:13px;color:var(--text);line-height:1.5;white-space:pre-wrap}.memory-engines-tab{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--space-lg);align-content:start;align-items:start}.memory-engines-tab>.memory-action-bar,.memory-engines-tab>.memory-settings-note,.memory-engines-tab>.memory-empty-state{grid-column:1 / -1}.memory-engine-card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius-lg);padding:var(--space-lg);margin-bottom:0}.memory-engine-card h3{font-size:14px;font-weight:600;margin:0 0 var(--space-md) 0;color:var(--text)}.memory-engine-status{display:flex;flex-direction:row;align-items:center;gap:var(--space-sm)}.memory-health-badge{display:inline-block;padding:2px 10px;border-radius:var(--radius-pill);font-size:12px}.memory-health-badge--healthy{background:color-mix(in srgb,var(--color-success) 15%,transparent);color:var(--color-success)}.memory-health-badge--warning{background:color-mix(in srgb,var(--color-warning) 15%,transparent);color:var(--color-warning)}.memory-health-badge--issues{background:color-mix(in srgb,var(--color-error) 15%,transparent);color:var(--color-error)}.memory-action-bar{display:flex;flex-direction:row;gap:var(--space-sm);margin-top:var(--space-md);align-items:center}.memory-empty-extract-button{margin-top:var(--space-md)}.memory-stat-value--updated{font-size:1.125rem}.memory-capability-row{display:flex;gap:var(--space-xs);margin-top:var(--space-sm);flex-wrap:wrap}.memory-emphasis-text{font-weight:500}.memory-health-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:var(--space-md)}.memory-health-grid{display:grid;grid-template-columns:1fr 1fr;gap:var(--space-md)}.memory-health-label{font-size:.6875rem;letter-spacing:.5px;color:var(--text-muted);text-transform:uppercase;margin-bottom:var(--space-xs)}.memory-health-detail{font-size:.8125rem;color:var(--text-muted)}.memory-health-section{margin-top:var(--space-md);padding-top:var(--space-md);border-top:1px solid var(--border)}.memory-status-text--success{color:var(--color-success)}.memory-status-text--error{color:var(--color-error)}.memory-status-text--warning{color:var(--color-warning)}.memory-status-text--muted{color:var(--text-muted)}.memory-audit-check-content{flex:1}.memory-settings-note{margin-top:var(--space-sm);font-size:.8125rem;color:var(--text-muted);display:flex;align-items:center;gap:var(--space-xs);flex-wrap:wrap}.memory-settings-note-button{background:none;border:none;color:inherit;cursor:pointer;font:inherit;padding:0;text-decoration:underline}.memory-settings-note-button:focus-visible{outline:none;border-radius:var(--radius-sm);box-shadow:var(--focus-ring-strong)}.memory-empty-state{color:var(--text-muted);padding:var(--space-2xl);text-align:center;display:flex;flex-direction:column;align-items:center;gap:var(--space-sm)}.memory-stats-row{display:flex;flex-direction:row;gap:var(--space-lg);margin-bottom:var(--space-lg)}.memory-stat-card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-md) var(--space-lg);flex:1}.memory-stat-value{font-size:24px;font-weight:600;color:var(--text);margin-bottom:var(--space-xs)}.memory-stat-label{font-size:12px;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px}.memory-audit-check{display:flex;flex-direction:row;padding:var(--space-sm) 0;border-bottom:1px solid var(--border);gap:var(--space-sm)}.memory-audit-check:last-child{border-bottom:none}.memory-audit-check-passed{color:var(--color-success);font-weight:600}.memory-audit-check-failed{color:var(--color-error);font-weight:600}.memory-capability-badge{font-size:11px;padding:2px 8px;border-radius:var(--radius-pill);background:color-mix(in srgb,var(--todo) 15%,transparent);color:var(--text-muted)}.memory-readonly-banner{background:color-mix(in srgb,var(--color-warning) 10%,transparent);border:1px solid color-mix(in srgb,var(--color-warning) 30%,transparent);border-radius:var(--radius-md);padding:var(--space-md);color:var(--color-warning);font-size:13px;margin-bottom:var(--space-md)}.memory-char-count{font-size:12px;color:var(--text-muted)}.memory-categories-list{margin-top:var(--space-lg)}.memory-config-section{margin-top:var(--space-lg);padding-top:var(--space-lg);border-top:1px solid var(--border);display:flex;flex-direction:column;gap:var(--space-md)}.memory-settings-group{border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface);padding:var(--space-sm) 0}.memory-working-tab .memory-toggle-row .checkbox-label{align-items:center}.memory-working-tab .memory-toggle-row>small{display:block;margin-top:var(--space-xs);margin-left:calc(16px + var(--space-sm));color:var(--text-muted)}.memory-flex-spacer{flex:1}.memory-qmd-card{border-style:solid}.memory-retrieval-card{display:flex;flex-direction:column;gap:var(--space-sm)}.memory-retrieval-input-row{display:flex;align-items:center;gap:var(--space-sm)}.memory-retrieval-input-row .input{flex:1}.memory-retrieval-card .memory-test-result{margin-top:var(--space-sm)}@media(max-width:1100px)and (min-width:769px){.memory-engines-tab{grid-template-columns:1fr}}@media(max-width:768px){.memory-view-tabs{padding-inline:var(--space-md)}.memory-view-content{padding:0 var(--space-md) var(--space-md)}.memory-editor-container{min-height:calc(var(--space-xl) * 10)}.memory-stats-row{flex-wrap:wrap}.memory-stat-card{min-width:calc(50% - var(--space-sm))}.memory-view-tab{min-height:36px;padding:var(--space-sm)}.memory-engines-tab{grid-template-columns:1fr}.memory-engine-card{padding:var(--space-md)}.memory-retrieval-input-row{flex-direction:column;align-items:stretch}.memory-settings-group{padding:var(--space-xs) 0}.memory-health-grid{grid-template-columns:1fr}.memory-config-section{margin-top:var(--space-md);padding-top:var(--space-md)}}
1
+ .memory-view{display:flex;flex-direction:column;height:100%;overflow:hidden;width:100%;min-width:0;flex:1 1 auto}.memory-view-tabs{display:flex;flex-direction:row;gap:var(--space-xs);border-bottom:1px solid var(--border);margin:var(--space-md) 0 var(--space-lg);padding:0 var(--space-lg);flex-shrink:0}.memory-view-tab{padding:var(--space-sm) var(--space-md);border-radius:var(--radius-sm) var(--radius-sm) 0 0;color:var(--text-muted);background:transparent;border:none;cursor:pointer;font-size:13px;transition:background var(--transition-fast),color var(--transition-fast)}.memory-view-tab:hover{background:var(--card-hover);color:var(--text)}.memory-view-tab:focus-visible{outline:none;box-shadow:var(--focus-ring)}.memory-view-tab--active{color:var(--text);border-bottom:2px solid var(--accent);font-weight:500}.memory-view-content{flex:1;min-height:0;display:flex;flex-direction:column;padding:0 var(--space-lg) var(--space-lg)}.memory-working-tab,.memory-insights-tab,.memory-engines-tab{flex:1;min-height:0;display:flex;flex-direction:column;overflow-y:auto;width:100%}.memory-action-bar,.memory-config-section{flex-shrink:0}.memory-working-tab .memory-editor-section{display:flex;flex-direction:column;flex:0 0 auto;min-height:0}.memory-working-tab .memory-editor-section>.form-group,.memory-working-tab .memory-editor-section>.memory-file-summary{flex:0 0 auto}.memory-working-tab .memory-editor-form-group{display:flex;flex-direction:column;flex:0 0 auto;min-height:0}.memory-editor-container{border:1px solid var(--border);border-radius:var(--radius-md);overflow:hidden;display:flex;flex-direction:column;flex:1 1 auto;min-height:calc(var(--space-xl) * 13 + var(--space-xs) * 2);max-height:60vh}.memory-editor-container .cm-editor{height:100%;min-height:0}.memory-editor-container .cm-scroller{overflow:auto}.memory-insights-editor-layout{display:flex;flex:1;min-height:0;flex-direction:column}.memory-category-section{margin-bottom:var(--space-lg)}.memory-category-header{display:flex;flex-direction:row;justify-content:space-between;align-items:center;cursor:pointer;padding:var(--space-sm) 0;border-bottom:1px solid var(--border);transition:opacity var(--transition-fast)}.memory-category-header:hover{opacity:.8}.memory-category-header h4{font-size:14px;font-weight:500;margin:0;color:var(--text)}.memory-category-count{font-size:.75rem;color:var(--text-muted);background:color-mix(in srgb,var(--text-muted) 15%,transparent);padding:2px 8px;border-radius:var(--radius-pill)}.memory-category-items{padding-top:var(--space-sm);display:flex;flex-direction:column;gap:var(--space-xs)}.memory-insight-item{padding:var(--space-sm) var(--space-md);border:1px solid var(--border);border-left:3px solid color-mix(in srgb,var(--accent) 55%,transparent);border-radius:var(--radius-md);background:var(--card);font-size:13px;color:var(--text);line-height:1.5;white-space:pre-wrap}.memory-engines-tab{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--space-lg);align-content:start;align-items:start}.memory-engines-tab>.memory-action-bar,.memory-engines-tab>.memory-settings-note,.memory-engines-tab>.memory-empty-state{grid-column:1 / -1}.memory-engine-card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius-lg);padding:var(--space-lg);margin-bottom:0}.memory-engine-card h3{font-size:14px;font-weight:600;margin:0 0 var(--space-md) 0;color:var(--text)}.memory-engine-status{display:flex;flex-direction:row;align-items:center;gap:var(--space-sm)}.memory-health-badge{display:inline-block;padding:2px 10px;border-radius:var(--radius-pill);font-size:12px}.memory-health-badge--healthy{background:color-mix(in srgb,var(--color-success) 15%,transparent);color:var(--color-success)}.memory-health-badge--warning{background:color-mix(in srgb,var(--color-warning) 15%,transparent);color:var(--color-warning)}.memory-health-badge--issues{background:color-mix(in srgb,var(--color-error) 15%,transparent);color:var(--color-error)}.memory-action-bar{display:flex;flex-direction:row;gap:var(--space-sm);margin-top:var(--space-md);align-items:center}.memory-empty-extract-button{margin-top:var(--space-md)}.memory-stat-value--updated{font-size:1.125rem}.memory-capability-row{display:flex;gap:var(--space-xs);margin-top:var(--space-sm);flex-wrap:wrap}.memory-emphasis-text{font-weight:500}.memory-health-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:var(--space-md)}.memory-health-grid{display:grid;grid-template-columns:1fr 1fr;gap:var(--space-md)}.memory-health-label{font-size:.6875rem;letter-spacing:.5px;color:var(--text-muted);text-transform:uppercase;margin-bottom:var(--space-xs)}.memory-health-detail{font-size:.8125rem;color:var(--text-muted)}.memory-health-section{margin-top:var(--space-md);padding-top:var(--space-md);border-top:1px solid var(--border)}.memory-status-text--success{color:var(--color-success)}.memory-status-text--error{color:var(--color-error)}.memory-status-text--warning{color:var(--color-warning)}.memory-status-text--muted{color:var(--text-muted)}.memory-audit-check-content{flex:1}.memory-settings-note{margin-top:var(--space-sm);font-size:.8125rem;color:var(--text-muted);display:flex;align-items:center;gap:var(--space-xs);flex-wrap:wrap}.memory-settings-note-button{background:none;border:none;color:inherit;cursor:pointer;font:inherit;padding:0;text-decoration:underline}.memory-settings-note-button:focus-visible{outline:none;border-radius:var(--radius-sm);box-shadow:var(--focus-ring-strong)}.memory-empty-state{color:var(--text-muted);padding:var(--space-2xl);text-align:center;display:flex;flex-direction:column;align-items:center;gap:var(--space-sm)}.memory-stats-row{display:flex;flex-direction:row;gap:var(--space-lg);margin-bottom:var(--space-lg)}.memory-stat-card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius-md);padding:var(--space-md) var(--space-lg);flex:1}.memory-stat-value{font-size:24px;font-weight:600;color:var(--text);margin-bottom:var(--space-xs)}.memory-stat-label{font-size:12px;color:var(--text-muted);text-transform:uppercase;letter-spacing:.5px}.memory-audit-check{display:flex;flex-direction:row;padding:var(--space-sm) 0;border-bottom:1px solid var(--border);gap:var(--space-sm)}.memory-audit-check:last-child{border-bottom:none}.memory-audit-check-passed{color:var(--color-success);font-weight:600}.memory-audit-check-failed{color:var(--color-error);font-weight:600}.memory-capability-badge{font-size:11px;padding:2px 8px;border-radius:var(--radius-pill);background:color-mix(in srgb,var(--todo) 15%,transparent);color:var(--text-muted)}.memory-readonly-banner{background:color-mix(in srgb,var(--color-warning) 10%,transparent);border:1px solid color-mix(in srgb,var(--color-warning) 30%,transparent);border-radius:var(--radius-md);padding:var(--space-md);color:var(--color-warning);font-size:13px;margin-bottom:var(--space-md)}.memory-char-count{font-size:12px;color:var(--text-muted)}.memory-categories-list{margin-top:var(--space-lg)}.memory-config-section{margin-top:var(--space-lg);padding-top:var(--space-lg);border-top:1px solid var(--border);display:flex;flex-direction:column;gap:var(--space-md)}.memory-settings-group{border:1px solid var(--border);border-radius:var(--radius-md);background:var(--surface);padding:var(--space-sm) 0}.memory-working-tab .memory-toggle-row .checkbox-label{align-items:center}.memory-working-tab .memory-toggle-row>small{display:block;margin-top:var(--space-xs);margin-left:calc(16px + var(--space-sm));color:var(--text-muted)}.memory-flex-spacer{flex:1}.memory-qmd-card{border-style:solid}.memory-retrieval-card{display:flex;flex-direction:column;gap:var(--space-sm)}.memory-retrieval-input-row{display:flex;align-items:center;gap:var(--space-sm)}.memory-retrieval-input-row .input{flex:1}.memory-retrieval-card .memory-test-result{margin-top:var(--space-sm)}@media(max-width:1100px)and (min-width:769px){.memory-engines-tab{grid-template-columns:1fr}}@media(max-width:768px){.memory-view-tabs{padding-inline:var(--space-md)}.memory-view-content{padding:0 var(--space-md) var(--space-md)}.memory-editor-container{min-height:calc(var(--space-xl) * 10)}.memory-stats-row{flex-wrap:wrap}.memory-stat-card{min-width:calc(50% - var(--space-sm))}.memory-view-tab{min-height:36px;padding:var(--space-sm)}.memory-engines-tab{grid-template-columns:1fr}.memory-engine-card{padding:var(--space-md)}.memory-retrieval-input-row{flex-direction:column;align-items:stretch}.memory-settings-group{padding:var(--space-xs) 0}.memory-health-grid{grid-template-columns:1fr}.memory-config-section{margin-top:var(--space-md);padding-top:var(--space-md)}}.knowledge-graph-panel{display:flex;flex:1;min-height:0;flex-direction:column;gap:var(--space-md);overflow:auto}.knowledge-graph-empty{align-items:center;justify-content:center}.knowledge-graph-status,.knowledge-graph-filters,.knowledge-graph-neighbors,.knowledge-graph-path{display:flex;flex-wrap:wrap;align-items:center;gap:var(--space-sm);padding:var(--space-md)}.knowledge-graph-status>div{display:grid;gap:var(--space-xs);margin-right:auto}.knowledge-graph-status strong{color:var(--text)}.knowledge-graph-status span,.knowledge-graph-muted{color:var(--text-muted)}.knowledge-graph-status dl{display:flex;flex-wrap:wrap;gap:var(--space-sm);margin:0}.knowledge-graph-status dl div{display:grid;gap:0}.knowledge-graph-status dt{color:var(--text-muted);font-size:var(--font-size-xs)}.knowledge-graph-status dd{margin:0;font-size:var(--font-size-xs)}.knowledge-graph-toggle,.knowledge-graph-kind-options{display:flex;flex-wrap:wrap;gap:var(--space-xs);align-items:center}.knowledge-graph-kind-options label{display:inline-flex;gap:var(--space-xs);align-items:center;color:var(--text-muted);font-size:var(--font-size-sm)}.knowledge-graph-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:var(--space-md)}.knowledge-graph-results,.knowledge-graph-detail{min-width:0;padding:var(--space-md)}.knowledge-graph-results h3,.knowledge-graph-detail h3,.knowledge-graph-neighbors h3,.knowledge-graph-path h3{width:100%;margin:0}.knowledge-graph-results ul,.knowledge-graph-edge-list ul,.knowledge-graph-neighbors ul{display:flex;flex-direction:column;gap:var(--space-xs);margin:var(--space-sm) 0;padding:0;list-style:none}.knowledge-graph-results li .btn{display:grid;width:100%;justify-content:start;gap:var(--space-xs);text-align:left}.knowledge-graph-results li span{color:var(--text-muted);font-size:var(--font-size-xs);overflow-wrap:anywhere}.knowledge-graph-pagination{display:flex;justify-content:space-between;gap:var(--space-sm)}.knowledge-graph-edge-list h4{display:flex;justify-content:space-between;margin:var(--space-md) 0 var(--space-xs)}.knowledge-graph-edge-list h4 span{color:var(--text-muted);font-size:var(--font-size-xs);font-weight:400}.knowledge-graph-edge-list li,.knowledge-graph-neighbors li{display:flex;flex-wrap:wrap;align-items:center;gap:var(--space-xs)}.knowledge-graph-provenance{border-radius:var(--radius-full);padding:var(--space-xs) var(--space-xs);font-size:var(--font-size-xs)}.knowledge-graph-provenance--extracted{color:var(--color-success);background:color-mix(in srgb,var(--color-success) 15%,transparent)}.knowledge-graph-provenance--inferred{color:var(--accent);background:color-mix(in srgb,var(--accent) 15%,transparent)}.knowledge-graph-endpoint{max-width:100%;overflow-wrap:anywhere;text-align:left}.knowledge-graph-path-chain{display:flex;flex-wrap:wrap;align-items:center;gap:var(--space-xs);margin-top:var(--space-sm)}.knowledge-graph-path-chain span{display:inline-flex;align-items:center;gap:var(--space-xs)}.knowledge-graph-path-chain em{color:var(--text-muted);font-size:var(--font-size-xs);font-style:normal}.knowledge-graph-error{width:100%;color:var(--color-error)}@media(max-width:768px){.knowledge-graph-layout{grid-template-columns:minmax(0,1fr)}.knowledge-graph-status,.knowledge-graph-filters,.knowledge-graph-neighbors,.knowledge-graph-path{align-items:stretch}.knowledge-graph-status>div{margin-right:0}.knowledge-graph-status dl{display:grid;grid-template-columns:minmax(0,1fr)}}
@@ -0,0 +1,3 @@
1
+ import{r as n,j as e}from"./vendor-react-SZ_qB27O.js";import{u as _e,f as Se,a as ke,s as Ke,i as Ue,t as Be,b as we,c as Ce,d as Ge,e as Qe,g as We,h as Ve}from"./SettingsModal-Dm-ngbRr.js";import{a as ee,w as te,da as Ye,aY as Xe,V as Ze,db as Je,L as U,aL as Ee}from"./index-DpCHwyiD.js";import{u as De}from"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";function pe(i){const s=Object.entries(i).flatMap(([m,t])=>Array.isArray(t)?t.filter(Boolean).map(c=>[m,c]):t===void 0||t===""?[]:[[m,String(t)]]);return s.length?`?${s.map(([m,t])=>`${encodeURIComponent(m)}=${encodeURIComponent(t)}`).join("&")}`:""}function et(i){return ee(te("/knowledge/graph/status",i))}function tt(i,s={}){return ee(te(`/knowledge/graph/nodes${pe(s)}`,i))}function st(i,s){return ee(te(`/knowledge/graph/node${pe({id:s})}`,i))}function Fe(i,s){return ee(te(`/knowledge/graph/neighbors${pe(s)}`,i))}function at(i,s){return ee(te(`/knowledge/graph/path${pe(s)}`,i))}function nt(i,s=!1){return ee(te("/knowledge/graph/build",i),{method:"POST",body:JSON.stringify({force:s})})}const J=".fusion/memory/MEMORY.md",rt=5e4,it="0 3 * * *",lt="0 4 * * *";function ge(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??rt,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??it,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??lt}}function Ae(i,s){return i.some(m=>m.path===s)?s:i.find(m=>m.path===J)?.path??i[0]?.path??J}function ot(i={}){const{projectId:s}=i,[m,t]=n.useState(null),[c,g]=n.useState(!0),[f,M]=n.useState(!1),[E,w]=n.useState(()=>ge({})),[j,k]=n.useState(!0),[o,a]=n.useState(!1),[d,F]=n.useState([]),[B,q]=n.useState(!0),[N,I]=n.useState(J),[D,R]=n.useState(""),[se,G]=n.useState(!1),[p,y]=n.useState(!1),[H,z]=n.useState(!1),[S,P]=n.useState(!1),[Y,$]=n.useState(!1),[x,Q]=n.useState(null),[h,u]=n.useState(!0),[b,W]=n.useState(!1),[ie,ae]=n.useState(!1),{status:ne,loading:be,refresh:_}=_e({projectId:s}),re=n.useCallback(l=>{R(l),y(!0)},[]),X=n.useCallback(async l=>{G(!0);try{const{content:v}=await Se(l,s);I(l),R(v),y(!1)}finally{G(!1)}},[s]),O=n.useCallback(async()=>{q(!0);try{const{files:l}=await ke(s);if(F(l),l.length===0){I(J),R(""),y(!1);return}const v=Ae(l,N);v!==N&&await X(v)}finally{q(!1)}},[s,N,X]);n.useEffect(()=>{let l=!1;async function v(){try{const A=await Ce(s);l||(t(A.content),M(A.exists),g(!1))}catch{l||(t(null),M(!1),g(!1))}}return v(),()=>{l=!0}},[s]),n.useEffect(()=>{let l=!1;async function v(){k(!0);try{const A=await Xe(s);l||w(ge(A))}catch{l||w(ge({}))}finally{l||k(!1)}}return v(),()=>{l=!0}},[s]);const le=n.useRef(N);n.useEffect(()=>{le.current=N},[N]),n.useEffect(()=>{let l=!1;async function v(){q(!0);try{const{files:A}=await ke(s);if(l)return;if(F(A),A.length===0){I(J),R(""),y(!1);return}const ue=Ae(A,le.current),{content:je}=await Se(ue,s);if(l)return;I(ue),R(je),y(!1)}catch{l||(F([]),I(J),R(""),y(!1))}finally{l||q(!1)}}return v(),()=>{l=!0}},[s]),n.useEffect(()=>{let l=!1;async function v(){try{const A=await we(s);l||(Q(A),u(!1))}catch{l||(Q(null),u(!1))}}return v(),()=>{l=!0}},[s]);const oe=n.useCallback(async l=>{a(!0);try{const v=await Ye(l,s);w(ge(v))}finally{a(!1)}},[s]),me=n.useCallback(async l=>{await X(l)},[X]),ce=n.useCallback(async()=>{if(p){z(!0);try{await Ke(N,D,s),y(!1),await O()}finally{z(!1)}}},[D,p,N,s,O]),de=n.useCallback(async()=>{ae(!0);try{const l=await Ue(s);return await _(),l}finally{ae(!1)}},[s,_]),he=n.useCallback(async l=>Be(l,s),[s]),Z=n.useCallback(async()=>{try{const l=await we(s);Q(l)}catch{Q(null)}},[s]),K=n.useCallback(async()=>{try{const l=await Ce(s);t(l.content),M(l.exists)}catch{t(null),M(!1)}},[s]),L=n.useCallback(async l=>{await Ge(l,s),await K()},[s,K]),xe=n.useCallback(async()=>{P(!0);try{const l=await Qe(s);return await Promise.all([K(),Z()]),{success:l.success,summary:l.summary}}finally{P(!1)}},[s,K,Z]),V=n.useCallback(async()=>{$(!0);try{return await We(s)}finally{$(!1)}},[s]),fe=n.useCallback(async l=>{W(!0);try{const v=await Ve(l,s),A=v.path??l;I(A),R(v.content),y(!1),await O()}finally{W(!1)}},[s,O]);return{insightsContent:m,insightsLoading:c,insightsExists:f,refreshInsights:K,saveInsights:L,memorySettings:E,settingsLoading:j,savingMemorySettings:o,saveMemorySettings:oe,memoryFiles:d,memoryFilesLoading:B,selectedFilePath:N,selectedFileContent:D,selectedFileLoading:se,selectedFileDirty:p,setSelectedFileContent:re,selectFile:me,saveSelectedFile:ce,savingSelectedFile:H,reloadMemoryFiles:O,backendStatus:ne,backendLoading:be,extractInsights:xe,extracting:S,triggerDreamNow:V,dreamRunning:Y,auditReport:x,auditLoading:h,refreshAudit:Z,compactMemory:fe,compacting:b,installQmdAction:de,installingQmd:ie,testRetrieval:he}}const Me={limit:50,offset:0};function mt({projectId:i,enabled:s}){const[m,t]=n.useState(null),[c,g]=n.useState(Me),[f,M]=n.useState(null),[E,w]=n.useState(null),[j,k]=n.useState(null),[o,a]=n.useState({direction:"both",depth:1}),[d,F]=n.useState(null),[B,q]=n.useState({fromId:"",toId:"",maxHops:6}),[N,I]=n.useState(null),[D,R]=n.useState(!1),[se,G]=n.useState(!1),[p,y]=n.useState(null),H=n.useRef(0),z=n.useRef(0),S=n.useRef(0),P=n.useCallback(async()=>{try{const h=await et(i);t(h),q(u=>({...u,maxHops:h.pathLimits.defaultMaxHops}))}catch(h){y(h instanceof Error?h.message:String(h))}},[i]);n.useEffect(()=>{P()},[s,P]),n.useEffect(()=>{if(!m?.available)return;const h=++H.current;R(!0);const u=window.setTimeout(()=>void tt(i,c).then(b=>{h===H.current&&M(b)}).catch(b=>{h===H.current&&y(b instanceof Error?b.message:String(b))}).finally(()=>{h===H.current&&R(!1)}),250);return()=>window.clearTimeout(u)},[s,c,i,m?.available]);const Y=n.useCallback(async(h=E)=>{if(!h)return;const u=++z.current;try{const b=await Fe(i,{nodeId:h,...o});u===z.current&&F(b)}catch(b){u===z.current&&y(b instanceof Error?b.message:String(b))}},[o,i,E]),$=n.useCallback(async h=>{const u=++z.current;w(h);try{const[b,W]=await Promise.all([st(i,h),Fe(i,{nodeId:h,...o})]);u===z.current&&(k(b),F(W))}catch(b){u===z.current&&y(b instanceof Error?b.message:String(b))}},[o,i]),x=n.useCallback(async()=>{const h=++S.current;I(null),y(null);try{const u=await at(i,B);h===S.current&&I(u)}catch(u){h===S.current&&y(u instanceof Error?u.message:String(u))}},[B,i]),Q=n.useCallback(async(h=!1)=>{G(!0);try{await nt(i,h),await P()}catch(u){y(u instanceof Error?u.message:String(u))}finally{G(!1)}},[i,P]);return{status:m,filters:c,setFilters:g,nodes:f,loading:D,selectedId:E,detail:j,selectNode:$,neighborOptions:o,setNeighborOptions:a,neighborResults:d,refreshNeighbors:Y,pathInput:B,setPathInput:q,pathResult:N,findPath:x,rebuild:Q,rebuilding:se,refreshStatus:P,error:p,clearFilters:()=>g(Me)}}const ct=["file","module","symbol","doc-concept","rationale"],dt=["function","class","interface","type-alias","enum","variable","namespace","alias"],ht=["contains","imports","re-exports","relates-to","rationale-supports"];function ve({id:i,onSelect:s}){return e.jsx("button",{type:"button",className:"btn btn-ghost knowledge-graph-endpoint",onClick:()=>s(i),children:i})}function Ie({title:i,edges:s,total:m,endpoint:t,onSelect:c}){return e.jsxs("section",{className:"knowledge-graph-edge-list",children:[e.jsxs("h4",{children:[i," ",e.jsxs("span",{children:["showing ",s.length," of ",m]})]}),s.length===0?e.jsx("p",{className:"knowledge-graph-muted",children:"None"}):e.jsx("ul",{children:s.map(g=>e.jsxs("li",{children:[e.jsx("span",{children:g.kind}),e.jsx("span",{className:`knowledge-graph-provenance knowledge-graph-provenance--${g.provenance}`,children:g.provenance}),e.jsx(ve,{id:g[t],onSelect:c})]},g.id))})]})}function ut({projectId:i,addToast:s}){const{t:m}=De("app"),t=mt({projectId:i,enabled:!0}),[c,g]=n.useState(!1);if(n.useEffect(()=>{t.error&&s(t.error,"error")},[s,t.error]),!t.status&&t.error)return e.jsx("div",{className:"knowledge-graph-panel knowledge-graph-error","data-testid":"knowledge-graph-error",children:t.error});if(!t.status)return e.jsx("div",{className:"knowledge-graph-panel","data-testid":"knowledge-graph-loading",children:m("memory.graphLoading","Loading knowledge graph…")});if(!t.status.available)return e.jsxs("div",{className:"knowledge-graph-panel knowledge-graph-empty","data-testid":"knowledge-graph-no-graph",children:[e.jsxs("p",{children:[m("memory.graphUnavailable","Graph unavailable"),": ",t.status.recoveryReason]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void t.rebuild(!1),children:m("memory.graphBuild","Build graph")})]});const f=a=>t.setFilters({...t.filters,...a,offset:0}),M=a=>{const d=t.filters.kinds??[];f({kinds:d.includes(a)?d.filter(F=>F!==a):[...d,a]})},E=a=>{const d=t.neighborOptions.edgeKinds??[];t.setNeighborOptions({...t.neighborOptions,edgeKinds:d.includes(a)?d.filter(F=>F!==a):[...d,a]})},w=t.selectedId,j=t.status.pathLimits,k=t.pathResult?.outcome==="found"?t.pathResult.path:null,o=t.pathResult?.outcome==="found"?t.pathResult.hops:null;return e.jsxs("section",{className:"knowledge-graph-panel","data-testid":"knowledge-graph-panel",children:[e.jsxs("header",{className:"knowledge-graph-status card",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t.status.nodeCount," ",m("memory.graphNodes","nodes")," · ",t.status.edgeCount," ",m("memory.graphEdges","edges")]}),e.jsx("span",{children:t.status.graphDir})]}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Node kinds"}),e.jsx("dd",{children:Object.entries(t.status.nodeKindCounts??{}).map(([a,d])=>`${a}: ${d}`).join(" · ")||"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Edge kinds"}),e.jsx("dd",{children:Object.entries(t.status.edgeKindCounts??{}).map(([a,d])=>`${a}: ${d}`).join(" · ")||"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Provenance"}),e.jsx("dd",{children:Object.entries(t.status.provenanceCounts??{}).map(([a,d])=>`${a}: ${d}`).join(" · ")||"—"})]})]}),e.jsxs("label",{className:"knowledge-graph-toggle",children:[e.jsx("input",{type:"checkbox",checked:c,onChange:a=>g(a.target.checked)})," ",m("memory.graphForce","Force rebuild")]}),e.jsx("button",{type:"button",className:"btn",disabled:t.rebuilding,onClick:()=>void t.rebuild(c),children:t.rebuilding?m("memory.graphRebuilding","Rebuilding…"):m("memory.graphRebuild","Rebuild")})]}),e.jsxs("section",{className:"knowledge-graph-filters card","aria-label":m("memory.graphFilters","Graph filters"),children:[e.jsx("div",{className:"knowledge-graph-kind-options",children:ct.map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:(t.filters.kinds??[]).includes(a),onChange:()=>M(a)})," ",a]},a))}),e.jsx("input",{className:"input","aria-label":"Path prefix",placeholder:"Path prefix",value:t.filters.pathPrefix??"",onChange:a=>f({pathPrefix:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Node id prefix",placeholder:"Node id prefix",value:t.filters.idPrefix??"",onChange:a=>f({idPrefix:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Name regex",placeholder:"Name regex",value:t.filters.namePattern??"",onChange:a=>f({namePattern:a.target.value})}),e.jsxs("select",{className:"select","aria-label":"FNXC area",value:t.filters.fnxcArea??"",onChange:a=>f({fnxcArea:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:"All FNXC areas"}),t.status.fnxcAreas?.map(a=>e.jsx("option",{value:a,children:a},a))]}),e.jsxs("select",{className:"select","aria-label":"Symbol kind",value:t.filters.symbolKind??"",onChange:a=>f({symbolKind:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:"All symbol kinds"}),dt.map(a=>e.jsx("option",{children:a},a))]}),e.jsxs("select",{className:"select","aria-label":"Owner",value:t.filters.owner??"",onChange:a=>f({owner:a.target.value||void 0}),children:[e.jsx("option",{value:"",children:"All owners"}),e.jsx("option",{value:"file",children:"file"}),e.jsx("option",{value:"derived",children:"derived"})]}),e.jsx("select",{className:"select","aria-label":"Result limit",value:t.filters.limit??50,onChange:a=>f({limit:Number(a.target.value)}),children:[25,50,100,200].map(a=>e.jsxs("option",{value:a,children:[a," results"]},a))}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:t.clearFilters,children:m("memory.graphClearFilters","Clear filters")})]}),e.jsxs("div",{className:"knowledge-graph-layout",children:[e.jsxs("section",{className:"card knowledge-graph-results",children:[e.jsxs("h3",{children:[t.nodes?.total??0," ",m("memory.graphResults","results")]}),t.loading?e.jsx("p",{"data-testid":"knowledge-graph-searching",children:"Searching…"}):t.nodes?.nodes.length?e.jsxs(e.Fragment,{children:[e.jsx("ul",{children:t.nodes.nodes.map(a=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"btn btn-ghost",onClick:()=>void t.selectNode(a.id),children:[e.jsxs("strong",{children:[a.kind,": ",a.name]}),e.jsxs("span",{children:[a.id," · ",a.ownerPath,":",a.source.line]})]})},a.id))}),e.jsxs("div",{className:"knowledge-graph-pagination",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:!t.filters.offset,onClick:()=>f({offset:Math.max(0,(t.filters.offset??0)-(t.filters.limit??50))}),children:"Previous"}),e.jsx("button",{type:"button",className:"btn btn-ghost",disabled:(t.filters.offset??0)+(t.filters.limit??50)>=(t.nodes?.total??0),onClick:()=>f({offset:(t.filters.offset??0)+(t.filters.limit??50)}),children:"Next"})]})]}):e.jsx("p",{"data-testid":"knowledge-graph-no-results",children:m("memory.graphNoResults","No matching nodes.")})]}),e.jsx("section",{className:"card knowledge-graph-detail",children:t.detail?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:t.detail.node.name}),e.jsx("p",{children:t.detail.node.id}),e.jsxs("p",{children:[t.detail.node.ownerPath,":",t.detail.node.source.line]}),e.jsx(Ie,{title:"Outgoing",edges:t.detail.outgoing,total:t.detail.outgoingTotal,endpoint:"to",onSelect:a=>void t.selectNode(a)}),e.jsx(Ie,{title:"Incoming",edges:t.detail.incoming,total:t.detail.incomingTotal,endpoint:"from",onSelect:a=>void t.selectNode(a)})]}):e.jsx("p",{className:"knowledge-graph-muted",children:"Select a node to inspect its edges."})})]}),t.detail&&e.jsxs("section",{className:"knowledge-graph-neighbors card",children:[e.jsx("h3",{children:"Neighbors"}),e.jsxs("select",{className:"select","aria-label":"Neighbor direction",value:t.neighborOptions.direction,onChange:a=>t.setNeighborOptions({...t.neighborOptions,direction:a.target.value}),children:[e.jsx("option",{value:"out",children:"Outgoing"}),e.jsx("option",{value:"in",children:"Incoming"}),e.jsx("option",{value:"both",children:"Both directions"})]}),e.jsx("select",{className:"select","aria-label":"Neighbor depth",value:t.neighborOptions.depth,onChange:a=>t.setNeighborOptions({...t.neighborOptions,depth:Number(a.target.value)}),children:[1,2,3].map(a=>e.jsxs("option",{value:a,children:["Depth ",a]},a))}),e.jsx("div",{className:"knowledge-graph-kind-options",children:ht.map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:(t.neighborOptions.edgeKinds??[]).includes(a),onChange:()=>E(a)})," ",a]},a))}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>void t.refreshNeighbors(),children:"Refresh neighbors"}),t.neighborResults?.neighbors.length?e.jsx("ul",{children:t.neighborResults.neighbors.map(a=>e.jsxs("li",{children:[e.jsxs("span",{children:["distance ",a.distance]}),e.jsx(ve,{id:a.node.id,onSelect:d=>void t.selectNode(d)})]},a.node.id))}):e.jsx("p",{className:"knowledge-graph-muted",children:"No neighbors found."})]}),e.jsxs("section",{className:"knowledge-graph-path card",children:[e.jsx("h3",{children:"Shortest path"}),e.jsx("input",{className:"input","aria-label":"From node id",placeholder:"From node id",value:t.pathInput.fromId,onChange:a=>t.setPathInput({...t.pathInput,fromId:a.target.value})}),e.jsx("input",{className:"input","aria-label":"To node id",placeholder:"To node id",value:t.pathInput.toId,onChange:a=>t.setPathInput({...t.pathInput,toId:a.target.value})}),e.jsx("input",{className:"input","aria-label":"Maximum hops",type:"number",min:"1",max:j.maxHops,value:t.pathInput.maxHops,onChange:a=>t.setPathInput({...t.pathInput,maxHops:Number(a.target.value)})}),w&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,fromId:w}),children:"Use selected as from"}),e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,toId:w}),children:"Use selected as to"})]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>void t.findPath(),children:"Find path"}),k&&e.jsxs("div",{"data-testid":"knowledge-graph-path-found",children:[e.jsxs("strong",{children:[o," hops"]}),e.jsx("div",{className:"knowledge-graph-path-chain",children:k.nodes.map((a,d)=>e.jsxs("span",{children:[e.jsx(ve,{id:a.id,onSelect:F=>void t.selectNode(F)}),d<k.edges.length&&e.jsx("em",{children:k.edges[d].kind})]},a.id))})]}),t.pathResult?.outcome==="not-found"&&e.jsx("p",{"data-testid":"knowledge-graph-path-not-found",children:"No path exists between these nodes."}),t.pathResult?.outcome==="limit-reached"&&e.jsxs("div",{"data-testid":"knowledge-graph-path-limit-reached",children:[e.jsxs("p",{children:["No path found within ",t.pathResult.maxHops," hops; ",t.pathResult.limit," was reached."]}),t.pathInput.maxHops<j.maxHops&&e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:()=>t.setPathInput({...t.pathInput,maxHops:Math.min(j.maxHops,t.pathInput.maxHops+1)}),children:"Raise hop limit"})]}),t.error&&e.jsx("p",{"data-testid":"knowledge-graph-path-error",className:"knowledge-graph-error",children:t.error})]})]})}const yt={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},gt=72;function pt(i,s){if(i.length<=s)return i;const m=Math.max(1,s-1),t=Math.ceil(m/2),c=Math.floor(m/2);return`${i.slice(0,t)}…${i.slice(i.length-c)}`}function bt(i){const s=`${i.label} — ${i.path}`;return pt(s,gt)}function xt(i){if(!i)return[];const s=[],m=i.split(/(?=^## )/m);for(const t of m){const c=t.trim();if(!c)continue;const g=c.match(/^##\s+(.+?)(\n|$)/);if(g){const f=g[1].trim(),M=yt[f]??f.toLowerCase(),E=c.slice(g[0].length).replace(/<!--[\s\S]*?-->/g,"").trim(),w=E.split(`
2
+ `).reduce((j,k)=>{const o=k.trim();return/^[-*]\s+/.test(k)?j.push(o.replace(/^[-*]\s+/,"")):o.length>0&&j.length>0&&(j[j.length-1]=`${j[j.length-1]}
3
+ ${k.trimEnd()}`),j},[]);(w.length>0||E.length>0)&&s.push({name:f,key:M,items:w.length>0?w:E.length>0?[E]:[],expanded:!0})}}return s}function ft(i){if(!i)return null;const s=i.match(/##\s+Last\s+Updated:\s*(\d{4}-\d{2}-\d{2})/i);return s?s[1]:null}function jt(i){return i.reduce((s,m)=>s+m.items.length,0)}function Ft({projectId:i,addToast:s,onSendSelectionToTask:m}){const{t}=De("app"),[c,g]=n.useState("working"),[f,M]=n.useState(new Set),[E,w]=n.useState(!1),[j,k]=n.useState(null),[o,a]=n.useState({memoryEnabled:!0,memoryAutoSummarizeEnabled:!1,memoryAutoSummarizeThresholdChars:5e4,memoryAutoSummarizeSchedule:"0 3 * * *",memoryDreamsEnabled:!1,memoryDreamsSchedule:"0 4 * * *"}),[d,F]=n.useState(""),[B,q]=n.useState(!1),[N,I]=n.useState(null),{insightsContent:D,insightsLoading:R,insightsExists:se,saveInsights:G,memorySettings:p,settingsLoading:y,saveMemorySettings:H,savingMemorySettings:z,backendStatus:S,backendLoading:P,extractInsights:Y,extracting:$,auditReport:x,auditLoading:Q,refreshAudit:h,compactMemory:u,compacting:b,installQmdAction:W,installingQmd:ie,testRetrieval:ae,memoryFiles:ne,memoryFilesLoading:be,selectedFilePath:_,selectedFileContent:re,selectedFileLoading:X,selectedFileDirty:O,setSelectedFileContent:le,selectFile:oe,saveSelectedFile:me,savingSelectedFile:ce,reloadMemoryFiles:de,triggerDreamNow:he,dreamRunning:Z}=ot({projectId:i});n.useEffect(()=>{a(p)},[p]);const K=n.useMemo(()=>o.memoryEnabled!==p.memoryEnabled||o.memoryAutoSummarizeEnabled!==p.memoryAutoSummarizeEnabled||o.memoryAutoSummarizeThresholdChars!==p.memoryAutoSummarizeThresholdChars||o.memoryAutoSummarizeSchedule!==p.memoryAutoSummarizeSchedule||o.memoryDreamsEnabled!==p.memoryDreamsEnabled||o.memoryDreamsSchedule!==p.memoryDreamsSchedule,[o,p]),L=n.useMemo(()=>ne.find(r=>r.path===_),[ne,_]),xe=L?L.layer==="long-term"?t("memory.layerDescLongTerm","Curated durable decisions, conventions, constraints, and pitfalls promoted from dreams."):L.layer==="daily"?t("memory.layerDescDaily","Raw daily observations, open loops, and running context for dream processing."):t("memory.layerDescDreams","Synthesized patterns and open loops promoted from daily memory."):t("memory.editorDefaultDescription","Edits the selected memory file."),V=n.useMemo(()=>xt(D),[D]),fe=n.useMemo(()=>jt(V),[V]),l=n.useMemo(()=>ft(D),[D]),v=n.useCallback(r=>{M(C=>{const T=new Set(C);return T.has(r)?T.delete(r):T.add(r),T})},[]),A=n.useCallback(async r=>{try{await oe(r)}catch{s(t("memory.loadFileFailed","Failed to load memory file"),"error")}},[oe,s]),ue=n.useCallback(async()=>{try{await me(),s(t("memory.memorySaved","Memory saved"),"success")}catch{s(t("memory.saveMemoryFailed","Failed to save memory"),"error")}},[me,s]),je=n.useCallback(async()=>{if(!K)return;const r={};o.memoryEnabled!==p.memoryEnabled&&(r.memoryEnabled=o.memoryEnabled),o.memoryAutoSummarizeEnabled!==p.memoryAutoSummarizeEnabled&&(r.memoryAutoSummarizeEnabled=o.memoryAutoSummarizeEnabled),o.memoryAutoSummarizeThresholdChars!==p.memoryAutoSummarizeThresholdChars&&(r.memoryAutoSummarizeThresholdChars=o.memoryAutoSummarizeThresholdChars),o.memoryAutoSummarizeSchedule!==p.memoryAutoSummarizeSchedule&&(r.memoryAutoSummarizeSchedule=o.memoryAutoSummarizeSchedule),o.memoryDreamsEnabled!==p.memoryDreamsEnabled&&(r.memoryDreamsEnabled=o.memoryDreamsEnabled),o.memoryDreamsSchedule!==p.memoryDreamsSchedule&&(r.memoryDreamsSchedule=o.memoryDreamsSchedule);try{await H(r),s(t("memory.settingsSaved","Memory settings saved"),"success")}catch{s(t("memory.saveSettingsFailed","Failed to save memory settings"),"error")}},[K,o,p,H,s]),Re=n.useCallback(async()=>{try{const r=await W();s(r.qmdAvailable?t("memory.qmdInstallSuccess","qmd installed successfully"):t("memory.qmdInstallUnavailable","qmd install finished, but qmd is still unavailable"),r.qmdAvailable?"success":"info")}catch{s(t("memory.installQmdFailed","Failed to install qmd"),"error")}},[W,s]),ze=n.useCallback(async()=>{q(!0),I(null);try{const r=await ae(d);I(r),s(r.qmdAvailable?t("memory.retrievalTestComplete","Memory retrieval test complete"):t("memory.retrievalTestFallback","qmd is not installed; local fallback was used"),r.qmdAvailable?"success":"info")}catch{s(t("memory.retrievalTestFailed","Failed to test memory retrieval"),"error")}finally{q(!1)}},[d,ae,s]),Le=n.useCallback(async()=>{try{await he(),s(t("memory.dreamProcessingComplete","Dream processing completed"),"success"),await de()}catch(r){s(r instanceof Error?r.message:t("memory.dreamProcessingFailed","Failed to run dream processing"),"error")}},[he,de,s]),Pe=n.useCallback(async()=>{try{await u(_),s(t("memory.fileCompacted","Memory file compacted"),"success")}catch{s(t("memory.compactFailed","Failed to compact memory"),"error")}},[u,_,s]),Ne=n.useCallback(async()=>{try{const r=await Y();s(r.summary,"success")}catch(r){s(r instanceof Error?r.message:t("memory.extractInsightsFailed","Failed to extract insights"),"error")}},[Y,s]),qe=n.useCallback(async()=>{if(j!==null)try{await G(j),w(!1),k(null),s(t("memory.insightsSaved","Insights saved"),"success")}catch{s(t("memory.saveInsightsFailed","Failed to save insights"),"error")}},[j,G,s]),Oe=n.useCallback(()=>{k(D??""),w(!0)},[D]),Te=n.useCallback(()=>{w(!1),k(null)},[]),He=!P&&S!==null,ye=S?.capabilities?.writable??!1;return e.jsxs("div",{className:"memory-view",children:[e.jsx(Ze,{icon:Je,title:t("memory.title","Memory")}),e.jsxs("div",{className:"memory-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":c==="working",className:`memory-view-tab${c==="working"?" memory-view-tab--active":""}`,onClick:()=>g("working"),"data-testid":"memory-tab-working",children:t("memory.tabWorking","Working Memory")}),e.jsx("button",{type:"button",role:"tab","aria-selected":c==="insights",className:`memory-view-tab${c==="insights"?" memory-view-tab--active":""}`,onClick:()=>g("insights"),"data-testid":"memory-tab-insights",children:t("memory.tabInsights","Insights")}),e.jsx("button",{type:"button",role:"tab","aria-selected":c==="graph",className:`memory-view-tab${c==="graph"?" memory-view-tab--active":""}`,onClick:()=>g("graph"),"data-testid":"memory-tab-graph",children:t("memory.tabGraph","Knowledge Graph")}),e.jsx("button",{type:"button",role:"tab","aria-selected":c==="engines",className:`memory-view-tab${c==="engines"?" memory-view-tab--active":""}`,onClick:()=>g("engines"),"data-testid":"memory-tab-engines",children:t("memory.tabEngines","Engines")})]}),e.jsxs("div",{className:"memory-view-content",children:[c==="graph"&&e.jsx(ut,{projectId:i,addToast:s}),c==="working"&&e.jsxs("div",{className:"memory-working-tab",children:[He&&!ye&&e.jsx("div",{className:"memory-readonly-banner",children:t("memory.readOnlyBanner","This memory backend is read-only. Changes cannot be saved.")}),be||X?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(U,{size:20,className:"animate-spin"}),e.jsx("span",{children:t("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:t("memory.fileLabel","Memory File")}),e.jsx("select",{id:"memoryViewFilePath",className:"select",value:_,onChange:r=>{A(r.target.value)},disabled:O,children:ne.map(r=>e.jsx("option",{value:r.path,title:`${r.label} — ${r.path}`,children:bt(r)},r.path))}),e.jsx("small",{children:O?t("memory.fileSwitchDirtyHint","Save or discard the current edits before switching files."):t("memory.fileSwitchHint","Choose any project memory file to view or edit.")})]}),L&&e.jsxs("div",{className:"memory-file-summary",children:[e.jsx("span",{children:L.layer==="long-term"?t("memory.layerLongTerm","Long-term"):L.layer==="daily"?t("memory.layerDaily","Daily"):t("memory.layerDreams","Dreams")}),e.jsx("strong",{children:L.path}),e.jsx("small",{children:t("memory.fileSummary","{{size}} bytes · updated {{updatedAt}}",{size:L.size.toLocaleString(),updatedAt:new Date(L.updatedAt).toLocaleString()})})]}),e.jsxs("div",{className:"form-group memory-editor-form-group",children:[e.jsx("label",{children:L?.label||t("memory.editorLabel","Memory Editor")}),e.jsx("small",{children:xe}),e.jsx("div",{className:"memory-editor-container",children:e.jsx(Ee,{content:re,onChange:le,readOnly:!ye,filePath:_,forceToolbarActionsVisible:!0,onSendSelectionToTask:m})})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("span",{className:"memory-char-count",children:t("memory.charCount","{{count}} characters",{count:re.length})}),e.jsx("div",{className:"memory-flex-spacer"}),ye&&re.length>0&&e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Pe,disabled:b||O,children:b?e.jsxs(e.Fragment,{children:[e.jsx(U,{size:14,className:"animate-spin"}),t("memory.compacting","Compacting…")]}):t("memory.compactSelectedFile","Compact Selected File")}),O&&ye&&e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:ue,disabled:ce,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(U,{size:14,className:"animate-spin"}),t("memory.saving","Saving…")]}):t("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 memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryDreamsEnabled",className:"checkbox-label",title:t("memory.dreamsEnabledTooltip","Daily notes are distilled into DREAMS.md and reusable lessons are promoted into MEMORY.md."),children:[e.jsx("input",{id:"memoryDreamsEnabled",type:"checkbox",checked:o.memoryDreamsEnabled,onChange:r=>{a(C=>({...C,memoryDreamsEnabled:r.target.checked}))},disabled:!o.memoryEnabled||y}),t("memory.dreamsEnabledLabel","Process dreams from daily memory")]}),e.jsx("small",{children:t("memory.dreamsEnabledHint","Turns daily notes into DREAMS.md and promotes reusable lessons into MEMORY.md.")})]}),o.memoryEnabled&&o.memoryDreamsEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryDreamsSchedule",children:t("memory.dreamsScheduleLabel","Dream Schedule")}),e.jsx("input",{id:"memoryDreamsSchedule",type:"text",className:"input",value:o.memoryDreamsSchedule,onChange:r=>{a(C=>({...C,memoryDreamsSchedule:r.target.value}))},placeholder:"0 4 * * *",disabled:y}),e.jsx("small",{children:t("memory.dreamsScheduleHint","Cron expression for dream processing.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:Le,disabled:Z||!o.memoryDreamsEnabled,children:Z?e.jsxs(e.Fragment,{children:[e.jsx(U,{size:14,className:"animate-spin"}),t("memory.dreaming","Dreaming…")]}):t("memory.dreamNow","Dream Now")}),e.jsx("small",{children:t("memory.dreamNowHint","Manually trigger dream processing now.")})]})]})]}),e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group memory-toggle-row",children:[e.jsxs("label",{htmlFor:"memoryAutoSummarizeEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryAutoSummarizeEnabled",type:"checkbox",checked:o.memoryAutoSummarizeEnabled,onChange:r=>{a(C=>({...C,memoryAutoSummarizeEnabled:r.target.checked}))},disabled:!o.memoryEnabled||y}),t("memory.autoSummarizeLabel","Auto-summarize memory")]}),e.jsx("small",{children:t("memory.autoSummarizeHint","Automatically compacts memory when it exceeds the threshold on a schedule.")})]}),o.memoryEnabled&&o.memoryAutoSummarizeEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeThresholdChars",children:t("memory.compactionThresholdLabel","Compaction Threshold (chars)")}),e.jsx("input",{id:"memoryAutoSummarizeThresholdChars",type:"number",className:"input",value:o.memoryAutoSummarizeThresholdChars,onChange:r=>{a(C=>({...C,memoryAutoSummarizeThresholdChars:parseInt(r.target.value,10)||5e4}))},min:1e3,disabled:y}),e.jsx("small",{children:t("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:t("memory.autoSummarizeScheduleLabel","Schedule (cron)")}),e.jsx("input",{id:"memoryAutoSummarizeSchedule",type:"text",className:"input",value:o.memoryAutoSummarizeSchedule,onChange:r=>{a(C=>({...C,memoryAutoSummarizeSchedule:r.target.value}))},placeholder:"0 3 * * *",disabled:y}),e.jsx("small",{children:t("memory.autoSummarizeScheduleHint","Cron expression for auto-summarize schedule (default: daily at 3 AM)")})]})]})]}),!o.memoryEnabled&&e.jsx("div",{className:"settings-empty-state memory-status-message",children:t("memory.disabledMessage","Memory is currently disabled. Enable memory tools in Settings to edit these automations.")}),K&&e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:je,disabled:z||y,children:z?e.jsxs(e.Fragment,{children:[e.jsx(U,{size:14,className:"animate-spin"}),t("memory.saving","Saving…")]}):t("memory.saveSettings","Save Settings")})})]})]})]}),c==="insights"&&e.jsx("div",{className:"memory-insights-tab",children:R?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(U,{size:20,className:"animate-spin"}),e.jsx("span",{children:t("memory.loadingInsights","Loading insights…")})]}):E?e.jsxs("div",{className:"memory-insights-editor-layout",children:[e.jsx("div",{className:"memory-editor-container",children:e.jsx(Ee,{content:j??"",onChange:k,readOnly:!1,filePath:".fusion/memory/memory-insights.md",forceToolbarActionsVisible:!0,onSendSelectionToTask:m})}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Te,children:t("memory.cancel","Cancel")}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:qe,children:t("memory.saveInsights","Save Insights")})]})]}):!se||V.length===0?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx("p",{children:t("memory.noInsights","No insights extracted yet.")}),e.jsx("p",{children:t("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:Ne,disabled:$,children:$?e.jsxs(e.Fragment,{children:[e.jsx(U,{size:14,className:"animate-spin"}),t("memory.extracting","Extracting…")]}):t("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:fe}),e.jsx("div",{className:"memory-stat-label",children:t("memory.totalInsights","Total Insights")})]}),e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:V.length}),e.jsx("div",{className:"memory-stat-label",children:t("memory.categories","Categories")})]}),l&&e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value memory-stat-value--updated",children:l}),e.jsx("div",{className:"memory-stat-label",children:t("memory.lastUpdated","Last Updated")})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ne,disabled:$,children:$?e.jsxs(e.Fragment,{children:[e.jsx(U,{size:14,className:"animate-spin"}),t("memory.extracting","Extracting…")]}):t("memory.extractNow","Extract Now")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Oe,children:t("memory.editRaw","Edit Raw")})]}),e.jsx("div",{className:"memory-categories-list",children:V.map(r=>{const C=!f.has(r.key);return e.jsxs("div",{className:"memory-category-section",children:[e.jsxs("div",{className:"memory-category-header",onClick:()=>v(r.key),role:"button",tabIndex:0,onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.preventDefault(),v(r.key))},children:[e.jsx("h4",{children:r.name}),e.jsx("span",{className:"memory-category-count",children:r.items.length})]}),C&&e.jsx("div",{className:"memory-category-items",children:r.items.map((T,$e)=>e.jsx("div",{className:"memory-insight-item",children:T.replace(/^-\s+/,"").replace(/^\*\s+/,"")},$e))})]},r.key)})})]})}),c==="engines"&&e.jsx("div",{className:"memory-engines-tab",children:P||Q?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(U,{size:20,className:"animate-spin"}),e.jsx("span",{children:t("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:t("memory.qmdIntegrationTitle","QMD Integration")}),S?.qmdAvailable===!0?e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge memory-health-badge--healthy",children:t("memory.qmdInstalled","Installed")}),e.jsx("span",{className:"memory-char-count",children:t("memory.qmdAvailableOnPath","qmd is available on PATH.")})]}):S?.qmdAvailable===!1?e.jsxs("div",{className:"settings-empty-state memory-status-message",children:[e.jsxs("span",{children:[t("memory.qmdNotInstalled","qmd is not installed. Search will use local files. Install indexed retrieval:")," ",e.jsx("code",{children:S.qmdInstallCommand||"bun install -g @tobilu/qmd"})]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:Re,disabled:ie,children:ie?t("memory.installing","Installing…"):t("memory.installQmd","Install qmd")})]}):e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge",children:t("memory.qmdChecking","Checking")}),e.jsx("span",{className:"memory-char-count",children:t("memory.qmdCheckingAvailability","Checking qmd availability…")})]})]}),e.jsxs("div",{className:"memory-engine-card memory-retrieval-card",children:[e.jsx("h3",{children:t("memory.testMemorySearchTitle","Test Memory Search")}),e.jsxs("div",{className:"memory-retrieval-input-row",children:[e.jsx("input",{type:"text",className:"input",value:d,onChange:r=>F(r.target.value),placeholder:t("memory.searchPlaceholder","Search memory with qmd")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ze,disabled:B,children:B?t("memory.testing","Testing…"):t("memory.testRetrieval","Test Retrieval")})]}),e.jsx("small",{className:"settings-muted",children:t("memory.testSearchHint","Runs the same qmd-backed memory_search path agents use.")}),N&&e.jsxs("div",{className:"memory-test-result",children:[e.jsx("strong",{children:t("memory.testResultCount",'{{count}} result for "{{query}}"',{count:N.results.length,query:N.query,defaultValue_one:'{{count}} result for "{{query}}"',defaultValue_other:'{{count}} results for "{{query}}"'})}),e.jsx("small",{children:t("memory.testResultStatus","qmd {{qmdStatus}} · {{fallbackStatus}}",{qmdStatus:N.qmdAvailable?t("memory.qmdStatusAvailable","available"):t("memory.qmdStatusMissing","missing"),fallbackStatus:N.usedFallback?t("memory.localFallbackUsed","local fallback used"):t("memory.qmdPathUsed","qmd path used")})}),N.results.length>0?e.jsx("ul",{children:N.results.map((r,C)=>e.jsxs("li",{children:[e.jsxs("span",{children:[r.path,":",r.lineStart]}),e.jsx("p",{children:r.snippet})]},`${r.path}-${r.lineStart}-${C}`))}):e.jsx("small",{children:t("memory.noMatchingMemory","No matching memory found.")})]})]}),e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:t("memory.currentBackendTitle","Current Backend")}),e.jsx("div",{className:"memory-engine-status",children:e.jsx("span",{className:"memory-emphasis-text",children:S?.currentBackend==="file"?t("memory.backendFile","File (.fusion/memory/, agent/<agent-name>/memory/)"):S?.currentBackend==="readonly"?t("memory.backendReadonly","Read-Only"):S?.currentBackend==="qmd"?t("memory.backendQmd","QMD (Quantized Memory Distillation)"):S?.currentBackend??"unknown"})}),e.jsxs("div",{className:"memory-capability-row",children:[S?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capReadable","Readable")}),S?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capWritable","Writable")}),S?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capAtomicWrites","Atomic Writes")}),S?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:t("memory.capPersistent","Persistent")})]})]}),x&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsxs("div",{className:"memory-health-header",children:[e.jsx("h3",{children:t("memory.healthStatusTitle","Health Status")}),e.jsx("span",{className:`memory-health-badge memory-health-badge--${x.health}`,children:x.health==="healthy"?t("memory.healthHealthy","Healthy"):x.health==="warning"?t("memory.healthWarning","Warning"):t("memory.healthIssues","Issues Found")})]}),e.jsxs("div",{className:"memory-health-grid",children:[e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:t("memory.workingMemoryLabel","Working Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:t("memory.sizeChars","{{size}} chars",{size:x.workingMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:t("memory.sectionCount","{{count}} sections",{count:x.workingMemory.sectionCount})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:t("memory.insightsMemoryLabel","Insights Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:t("memory.sizeChars","{{size}} chars",{size:x.insightsMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:t("memory.insightCount","{{count}} insights",{count:x.insightsMemory.insightCount})})]})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:t("memory.lastExtractionLabel","Last Extraction")}),e.jsx("div",{className:"memory-emphasis-text",children:x.extraction.success?e.jsx("span",{className:"memory-status-text memory-status-text--success",children:t("memory.extractionSuccess","Success")}):e.jsx("span",{className:"memory-status-text memory-status-text--error",children:t("memory.extractionFailed","Failed")})}),e.jsx("div",{className:"memory-health-detail",children:x.extraction.summary||t("memory.insightsExtracted","{{count}} insights extracted",{count:x.extraction.insightCount})})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:t("memory.pruningLabel","Pruning")}),e.jsx("div",{className:"memory-emphasis-text",children:x.pruning.applied?e.jsx("span",{className:"memory-status-text memory-status-text--warning",children:t("memory.pruningApplied","Applied")}):e.jsx("span",{className:"memory-status-text memory-status-text--muted",children:t("memory.pruningNotNeeded","Not needed")})}),x.pruning.applied&&e.jsx("div",{className:"memory-health-detail",children:x.pruning.reason})]})]}),x&&x.checks.length>0&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:t("memory.auditChecksTitle","Audit Checks")}),e.jsx("div",{children:x.checks.map(r=>e.jsxs("div",{className:"memory-audit-check",children:[e.jsx("span",{className:r.passed?"memory-audit-check-passed":"memory-audit-check-failed",children:r.passed?"✓":"✗"}),e.jsxs("div",{className:"memory-audit-check-content",children:[e.jsx("div",{className:"memory-emphasis-text",children:r.name}),e.jsx("div",{className:"memory-health-detail",children:r.details})]})]},r.id))})]}),e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:()=>h(),children:t("memory.runAudit","Run Audit")})}),e.jsxs("div",{className:"memory-settings-note",children:[e.jsx("span",{children:t("memory.settingsNote","Note: Change backend type in")}),e.jsx("button",{type:"button",className:"memory-settings-note-button",onClick:()=>{s(t("memory.settingsNoteToast","Open Settings → Memory to change backend type"),"info")},children:t("memory.settingsNoteLink","Settings → Memory")})]})]})})]})]})}export{Ft as MemoryView};
@@ -1,6 +1,6 @@
1
- import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as V,b8 as Y,b9 as Z,ba as T,R as L,aJ as D,aM as P,P as ee,C as se,g as ae,x as ie,aH as B,bb as ne,bc as te,bd as H,X as re}from"./index-CtYRoouR.js";import{u as le}from"./vendor-i18n-Duky4gdQ.js";import{P as $}from"./puzzle-hvecxlpJ.js";import{B as A}from"./AgentPermissionPolicyEditor--u9jyUf2.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";/**
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as V,b8 as Y,b9 as Z,ba as T,R as L,aK as D,aN as P,P as ee,C as se,k as ae,F as ie,aI as B,bb as ne,bc as te,bd as I,X as re}from"./index-DpCHwyiD.js";import{u as le}from"./vendor-i18n-Duky4gdQ.js";import{P as $}from"./puzzle-BkaCP30D.js";import{B as A}from"./AgentPermissionPolicyEditor-BM68g7wo.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.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=V("palette",ce);function oe(n){return n.replace(/-/g,"-")}function de(n){return{"fusion-global":"Fusion Global","pi-global":"Pi Global","fusion-project":"Fusion Project","pi-project":"Pi Project",package:"Package"}[n]??n}function pe(n){return n.startsWith("npm:")?"npm":n.startsWith("git:")?"git":"local"}function xe(n){return n.replace(/^(npm:|git:)/,"")}function ve({addToast:n,projectId:x}){const{t:a}=le("app"),[c,I]=l.useState(null),[b,y]=l.useState(!0),[N,E]=l.useState(!1),[S,F]=l.useState(!1),[h,w]=l.useState(""),[O,W]=l.useState(new Set),[m,_]=l.useState([]),[v,R]=l.useState(!0),[q,C]=l.useState(!1),o=l.useCallback(async()=>{try{y(!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{y(!1)}},[n,a]),g=l.useCallback(async()=>{try{R(!0);const s=await Z(x);_(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]),J=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 K=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)}},U=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)}},X=async s=>{if(!c)return;const t=c.packages.filter(i=>(typeof i=="string"?i:i.source)!==s);try{await H({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")}},Q=async(s,t)=>{if(!c)return;const i=c[s].filter(r=>r!==t);try{await H({[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:()=>Q(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:b,children:e.jsx(L,{size:16,className:b?"spin":""})})})]}),b?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:N}),e.jsxs("button",{className:"btn btn-primary",onClick:z,disabled:N||!h.trim(),children:[e.jsx(ee,{size:14}),N?a("piManager.installing","Installing…"):a("piManager.addButton","Add")]})]}),e.jsx("div",{className:"pi-ext-add-form-row",children:e.jsx("button",{className:"btn",onClick:U,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=pe(i),f=xe(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:()=>K(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:()=>X(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($,{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(A,{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(G,{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(P,{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"),$,"extensions"),u(a("piManager.sectionSkills","Skills"),A,"skills"),u(a("piManager.sectionPrompts","Prompts"),B,"prompts"),u(a("piManager.sectionThemes","Themes"),G,"themes")]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{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(P,{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--${oe(s.source)}`,children:de(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 J(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};
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=V("palette",ce);function oe(n){return n.replace(/-/g,"-")}function de(n){return{"fusion-global":"Fusion Global","pi-global":"Pi Global","fusion-project":"Fusion Project","pi-project":"Pi Project",package:"Package"}[n]??n}function pe(n){return n.startsWith("npm:")?"npm":n.startsWith("git:")?"git":"local"}function xe(n){return n.replace(/^(npm:|git:)/,"")}function ve({addToast:n,projectId:x}){const{t:a}=le("app"),[c,H]=l.useState(null),[b,y]=l.useState(!0),[N,E]=l.useState(!1),[S,F]=l.useState(!1),[h,w]=l.useState(""),[K,O]=l.useState(new Set),[m,W]=l.useState([]),[v,R]=l.useState(!0),[_,C]=l.useState(!1),o=l.useCallback(async()=>{try{y(!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{y(!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]),q=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)}},J=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")}},Q=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:()=>Q(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:b,children:e.jsx(L,{size:16,className:b?"spin":""})})})]}),b?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:N}),e.jsxs("button",{className:"btn btn-primary",onClick:z,disabled:N||!h.trim(),children:[e.jsx(ee,{size:14}),N?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=pe(i),f=xe(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=K.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:()=>J(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($,{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(A,{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(G,{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(P,{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"),$,"extensions"),u(a("piManager.sectionSkills","Skills"),A,"skills"),u(a("piManager.sectionPrompts","Prompts"),B,"prompts"),u(a("piManager.sectionThemes","Themes"),G,"themes")]})]}):e.jsxs("div",{className:"empty-state",children:[e.jsx(P,{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(P,{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--${oe(s.source)}`,children:de(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 q(s),disabled:_,"aria-label":a("piManager.toggleExtension","Toggle {{name}}",{name:s.name})}),e.jsx("span",{className:"toggle-slider"})]})})]},s.id))})]})]})}export{ve as PiExtensionsManager};