@runfusion/fusion 0.45.0 → 0.46.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 (116) hide show
  1. package/dist/bin.js +531 -99
  2. package/dist/client/.vite/manifest.json +244 -244
  3. package/dist/client/assets/{AgentDetailView-DJTi6hKC.js → AgentDetailView-D1cA9Bfj.js} +1 -1
  4. package/dist/client/assets/{AgentPermissionPolicyEditor-C5DR9dUS.js → AgentPermissionPolicyEditor-DE0wv8-L.js} +1 -1
  5. package/dist/client/assets/{AgentsView-BNd90PSx.js → AgentsView-Bm_FA_1w.js} +3 -3
  6. package/dist/client/assets/{ChatView-B7JaZCL_.js → ChatView-CHEkov6q.js} +1 -1
  7. package/dist/client/assets/CommandCenter-Cfgek-dC.js +71 -0
  8. package/dist/client/assets/{CommandCenter-Xs5Ftv8s.css → CommandCenter-DDjpYkPe.css} +1 -1
  9. package/dist/client/assets/DevServerView-DgDksVH2.css +1 -0
  10. package/dist/client/assets/DevServerView-_or2KLVw.js +1 -0
  11. package/dist/client/assets/{DirectoryPicker-DegxT8ia.js → DirectoryPicker-etVwa-6X.js} +1 -1
  12. package/dist/client/assets/{DocumentsView-kVVQYISc.js → DocumentsView-e8ZTdPIZ.js} +1 -1
  13. package/dist/client/assets/{EvalsView-C9-iTSat.js → EvalsView-CjDRQFMQ.js} +1 -1
  14. package/dist/client/assets/{ExperimentalAgentOnboardingModal-DjP_xNkc.js → ExperimentalAgentOnboardingModal-DXR0OAsR.js} +1 -1
  15. package/dist/client/assets/{GoalsView-VoIHJJ5l.js → GoalsView-WWDKVslN.js} +1 -1
  16. package/dist/client/assets/{InsightsView-BIZaUcpd.js → InsightsView-DxIfxOzx.js} +1 -1
  17. package/dist/client/assets/{MemoryView-7v7rv6ns.js → MemoryView-BVW2hkWf.js} +1 -1
  18. package/dist/client/assets/{PiExtensionsManager-CB89rV4U.js → PiExtensionsManager-CpSfMok2.js} +1 -1
  19. package/dist/client/assets/{PluginManager-BNSuW_R4.js → PluginManager-CpBCy656.js} +1 -1
  20. package/dist/client/assets/{PullRequestView-CI5jdKBL.js → PullRequestView-BMspX1ga.js} +1 -1
  21. package/dist/client/assets/{ResearchView-BT5dR_m8.js → ResearchView--YEtcv_s.js} +1 -1
  22. package/dist/client/assets/{SecretsView-WPYI58Uo.js → SecretsView-CC6QDMWN.js} +1 -1
  23. package/dist/client/assets/{SessionTerminal-C6gyOWLt.js → SessionTerminal-DJGtgIls.js} +1 -1
  24. package/dist/client/assets/{SettingsModal-Bq_3AbaB.js → SettingsModal-4d_p8D7W.js} +1 -1
  25. package/dist/client/assets/SettingsModal-ino68pI2.css +1 -0
  26. package/dist/client/assets/SettingsModal-wABa7xmZ.js +21 -0
  27. package/dist/client/assets/{SetupWizardModal-CrgbnR_d.js → SetupWizardModal-DHe2tXzx.js} +2 -2
  28. package/dist/client/assets/{ShadcnColorPicker-1icHuwhC.js → ShadcnColorPicker-HX3j1v66.js} +1 -1
  29. package/dist/client/assets/{SkillsView-byuSe3e0.js → SkillsView-mdFVTX-r.js} +1 -1
  30. package/dist/client/assets/{TodoView-CQ9GjYBg.js → TodoView-DQVugDpW.js} +1 -1
  31. package/dist/client/assets/{WorkflowNodeEditor-DW7sJZUX.js → WorkflowNodeEditor-CeERQHHu.js} +1 -1
  32. package/dist/client/assets/{agentSkills-CeytXLHF.js → agentSkills-C2v1wbxh.js} +1 -1
  33. package/dist/client/assets/{app-7-5DWLtg.js → app-BJGkp7Tt.js} +3 -3
  34. package/dist/client/assets/{app-CZ2LTFce.js → app-BKLUvvm8.js} +3 -3
  35. package/dist/client/assets/{app-Cv9xEnll.js → app-BaoNC9zg.js} +1 -1
  36. package/dist/client/assets/{app-x_yPcO5Y.js → app-CZQ_fFNf.js} +3 -3
  37. package/dist/client/assets/{app-CSvE5Noc.js → app-DAu3AzsS.js} +3 -3
  38. package/dist/client/assets/{app-3wbZ08YC.js → app-DgezOJub.js} +1 -1
  39. package/dist/client/assets/{architectureDiagram-3BPJPVTR-BRI0QwDf.js → architectureDiagram-3BPJPVTR-CGEhhgX_.js} +1 -1
  40. package/dist/client/assets/{blockDiagram-GPEHLZMM-BXkN8Hv_.js → blockDiagram-GPEHLZMM-D0DTo0HT.js} +1 -1
  41. package/dist/client/assets/{c4Diagram-AAUBKEIU-C_Kcokep.js → c4Diagram-AAUBKEIU-DNykNaRb.js} +1 -1
  42. package/dist/client/assets/channel-Dwf1FoGU.js +1 -0
  43. package/dist/client/assets/{chunk-2J33WTMH-BGeuCz9C.js → chunk-2J33WTMH-5oQfAhmr.js} +1 -1
  44. package/dist/client/assets/{chunk-4BX2VUAB-DcVdctr0.js → chunk-4BX2VUAB-BqLZXgFw.js} +1 -1
  45. package/dist/client/assets/{chunk-55IACEB6-Dg6gDigQ.js → chunk-55IACEB6-C1oIjX3T.js} +1 -1
  46. package/dist/client/assets/{chunk-727SXJPM-B9B-vlEb.js → chunk-727SXJPM-BaovQTgk.js} +1 -1
  47. package/dist/client/assets/{chunk-AQP2D5EJ-LrWQ-2yi.js → chunk-AQP2D5EJ-B4ikBK42.js} +1 -1
  48. package/dist/client/assets/{chunk-FMBD7UC4-Bnd6hAED.js → chunk-FMBD7UC4-5zgtNnG2.js} +1 -1
  49. package/dist/client/assets/{chunk-ND2GUHAM-nAw93UB5.js → chunk-ND2GUHAM-ByrypRna.js} +1 -1
  50. package/dist/client/assets/{chunk-QZHKN3VN-CgprKcZo.js → chunk-QZHKN3VN-B7D1exsu.js} +1 -1
  51. package/dist/client/assets/classDiagram-4FO5ZUOK-WqSUwcK_.js +1 -0
  52. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-WqSUwcK_.js +1 -0
  53. package/dist/client/assets/{cose-bilkent-S5V4N54A-Bhn0g_iK.js → cose-bilkent-S5V4N54A-CQmiNzGr.js} +1 -1
  54. package/dist/client/assets/{dagre-BM42HDAG-CP4kfwqd.js → dagre-BM42HDAG-BH8Uk0Up.js} +1 -1
  55. package/dist/client/assets/{dashboard-view-CM6Xin_H.js → dashboard-view-CWJ-b59n.js} +1 -1
  56. package/dist/client/assets/{dashboard-view-DV1nEhh9.js → dashboard-view-D3PWY2PH.js} +1 -1
  57. package/dist/client/assets/{diagram-2AECGRRQ-DPhzVEUf.js → diagram-2AECGRRQ-CDoHfkxY.js} +1 -1
  58. package/dist/client/assets/{diagram-5GNKFQAL-8QOC3K_L.js → diagram-5GNKFQAL-DARILCuD.js} +1 -1
  59. package/dist/client/assets/{diagram-KO2AKTUF-C1twgEch.js → diagram-KO2AKTUF-CNP-qi0y.js} +1 -1
  60. package/dist/client/assets/{diagram-LMA3HP47-3bEegSuf.js → diagram-LMA3HP47-SCiVmkcf.js} +1 -1
  61. package/dist/client/assets/{diagram-OG6HWLK6-BJ_x0rm6.js → diagram-OG6HWLK6-iTJLXH61.js} +1 -1
  62. package/dist/client/assets/{erDiagram-TEJ5UH35-DNiiS5q6.js → erDiagram-TEJ5UH35-ByMpiPIa.js} +1 -1
  63. package/dist/client/assets/{flowDiagram-I6XJVG4X-DoouPklt.js → flowDiagram-I6XJVG4X-DW3m3ZpM.js} +1 -1
  64. package/dist/client/assets/{folder-open-CuUs2W7f.js → folder-open-G-9vPAdv.js} +1 -1
  65. package/dist/client/assets/{ganttDiagram-6RSMTGT7-BrR6VnP5.js → ganttDiagram-6RSMTGT7-BJeYH7Ol.js} +1 -1
  66. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-BV8_J6Ee.js → gitGraphDiagram-PVQCEYII-CK_Chj4m.js} +1 -1
  67. package/dist/client/assets/index-ccFe_1av.js +1459 -0
  68. package/dist/client/assets/{infoDiagram-5YYISTIA-DGwIIFkR.js → infoDiagram-5YYISTIA-D8Wg1IgN.js} +1 -1
  69. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-D5dEH4RE.js → ishikawaDiagram-YF4QCWOH-DWROR2aX.js} +1 -1
  70. package/dist/client/assets/{journeyDiagram-JHISSGLW-BuuSWPw5.js → journeyDiagram-JHISSGLW-Bns9774_.js} +1 -1
  71. package/dist/client/assets/{kanban-definition-UN3LZRKU-DA34uUla.js → kanban-definition-UN3LZRKU-QtURfAoI.js} +1 -1
  72. package/dist/client/assets/{mermaid.core-Ch4HatqA.js → mermaid.core-DqgrgWWm.js} +4 -4
  73. package/dist/client/assets/{mindmap-definition-RKZ34NQL-DUCG-qD3.js → mindmap-definition-RKZ34NQL-jLaDb5_X.js} +1 -1
  74. package/dist/client/assets/{pieDiagram-4H26LBE5-DWvFGiLa.js → pieDiagram-4H26LBE5-CjbHuIje.js} +1 -1
  75. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-OPTVW3WT.js → quadrantDiagram-W4KKPZXB-xgHbylQr.js} +1 -1
  76. package/dist/client/assets/{requirementDiagram-4Y6WPE33-D7feZvlU.js → requirementDiagram-4Y6WPE33-CHdD7W41.js} +1 -1
  77. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-AtnSsEX1.js → sankeyDiagram-5OEKKPKP-C3me87g9.js} +1 -1
  78. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-BZjHUeI5.js → sequenceDiagram-3UESZ5HK-DSHfs1kU.js} +1 -1
  79. package/dist/client/assets/{shield-alert-CzaF9ROV.js → shield-alert-DkGlhVjI.js} +1 -1
  80. package/dist/client/assets/{stateDiagram-AJRCARHV-C8j23Pvn.js → stateDiagram-AJRCARHV-C08n7sMP.js} +1 -1
  81. package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-CiZR_S5-.js → stateDiagram-v2-BHNVJYJU-BosoAbfO.js} +1 -1
  82. package/dist/client/assets/{timeline-definition-PNZ67QCA-DvfNz25n.js → timeline-definition-PNZ67QCA-C21h9Zqh.js} +1 -1
  83. package/dist/client/assets/{upload-DTsYywhN.js → upload-B9B-tYt9.js} +1 -1
  84. package/dist/client/assets/{users-yAd09tKP.js → users-C_BA3C7E.js} +1 -1
  85. package/dist/client/assets/{vennDiagram-CIIHVFJN-CG2aMt3v.js → vennDiagram-CIIHVFJN-Bv3G0dwI.js} +1 -1
  86. package/dist/client/assets/{wardley-L42UT6IY-BnhBteen.js → wardley-L42UT6IY-WX0hHKcN.js} +1 -1
  87. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-DwqTzM3T.js → wardleyDiagram-YWT4CUSO-CMwIPWm7.js} +1 -1
  88. package/dist/client/assets/{xychartDiagram-2RQKCTM6-5Cv2ZKMV.js → xychartDiagram-2RQKCTM6-CZvFdt6j.js} +1 -1
  89. package/dist/client/index.html +1 -1
  90. package/dist/client/version.json +1 -1
  91. package/dist/droid-cli/package.json +1 -1
  92. package/dist/extension.js +472 -94
  93. package/dist/pi-claude-cli/package.json +1 -1
  94. package/dist/plugin-sdk/index.d.ts +11 -0
  95. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  96. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  97. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  98. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  99. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  100. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  101. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  102. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  103. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  104. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  105. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  106. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  107. package/package.json +1 -1
  108. package/dist/client/assets/CommandCenter-CHO21xEW.js +0 -74
  109. package/dist/client/assets/DevServerView-B_p91Mj_.css +0 -1
  110. package/dist/client/assets/DevServerView-H9OkT1ld.js +0 -1
  111. package/dist/client/assets/SettingsModal-BZokaNyx.css +0 -1
  112. package/dist/client/assets/SettingsModal-JHACoQJe.js +0 -21
  113. package/dist/client/assets/channel-Clzpzu32.js +0 -1
  114. package/dist/client/assets/classDiagram-4FO5ZUOK-CzYHP-af.js +0 -1
  115. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-CzYHP-af.js +0 -1
  116. package/dist/client/assets/index-CZcWjLAb.js +0 -1459
@@ -1 +1 @@
1
- import{r as a,j as e}from"./vendor-react-SZ_qB27O.js";import{ax as le,ay as ie,az as Oe,aA as qe,aB as he,aC as Ke,aD as de,aE as Qe,aF as ue,aG as _e,aH as Ve,V as Ge,aI as U,B as We,D as Xe,aJ as Ie,X as me,R as Je,ak as I,o as Ye,q as fe,s as pe,aK as J,aL as Ze,aM as et,n as xe,C as tt,ac as st}from"./index-CZcWjLAb.js";import{u as B}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";function at(t){const{projectId:i,searchQuery:h,includeProjectFiles:d=!0}=t??{},o=i?`${Oe.DOCUMENTS_PREFIX}${i}`:null,[s,c]=a.useState(()=>{if(!o)return[];const w=le(o,{maxAgeMs:ie});return Array.isArray(w)?w:[]}),[f,r]=a.useState([]),[p,u]=a.useState(()=>s.length===0),[j,b]=a.useState(null),k=a.useRef(null),g=a.useRef(s.length>0),x=a.useRef(null),P=a.useCallback(async()=>{k.current&&k.current.abort();const w=new AbortController;k.current=w;const z=!g.current;z&&u(!0),b(null);const E=qe(h?{q:h}:void 0,i),T=d?he(i):Promise.resolve({files:[]}),[v,S]=await Promise.allSettled([E,T]);if(w.signal.aborted)return;let M=null;if(v.status==="fulfilled"){if(c(v.value),o){const A=v.value.length>500?v.value.slice(0,500):v.value;Ke(o,A,{maxBytes:5e5})}g.current=!0}else M=v.reason instanceof Error?v.reason.message:String(v.reason);if(S.status==="fulfilled"){const A=S.value.files,R=h?.trim().toLowerCase(),F=R?A.filter(H=>H.name.toLowerCase().includes(R)||H.path.toLowerCase().includes(R)):A;r(F)}b(M),z&&u(!1)},[o,d,i,h]);return a.useEffect(()=>{if(!o){g.current=!1,c([]),u(!0);return}const w=le(o,{maxAgeMs:ie});Array.isArray(w)?(c(w),g.current=!0,u(!1)):(g.current=!1,c([]),u(!0))},[o]),a.useEffect(()=>(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{P()},300),()=>{x.current&&clearTimeout(x.current)}),[P]),a.useEffect(()=>(P(),()=>{k.current&&k.current.abort()}),[]),{documents:s,projectFiles:f,loading:p,error:j,refresh:P}}function nt(t,i){const[h,d]=a.useState([]),[o,s]=a.useState(!0),[c,f]=a.useState(null),r=a.useRef(null),p=a.useRef(!1),u=i?.showHidden??!1,j=a.useCallback(async b=>{r.current&&r.current.abort();const k=new AbortController;r.current=k;const g=!p.current;g&&s(!0),f(null);try{const x=await he(t,{showHidden:b?.showHidden??u});if(k.signal.aborted)return;d(x.files),p.current=!0}catch(x){if(k.signal.aborted)return;f(x instanceof Error?x.message:String(x))}finally{!k.signal.aborted&&g&&s(!1)}},[t,u]);return a.useEffect(()=>(p.current=!1,j({showHidden:u}),()=>{r.current&&r.current.abort()}),[j,u]),{files:h,loading:o,error:c,refresh:j}}const ct=768;function Y(t){return t?new Date(t).toLocaleString():""}function je(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t>=10*1024?0:1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function we(t,i=200){return t.length<=i?t:`${t.substring(0,i)}…`}function ot({document:t,renderMarkdown:i,onToggleMarkdown:h}){const{t:d}=B("app"),[o,s]=a.useState(!1),c=we(t.content),f=t.content.length>200;return e.jsxs("div",{className:"document-card",children:[e.jsxs("div",{className:"document-card-header",children:[e.jsxs("div",{className:"document-card-key",children:[e.jsx(U,{size:14}),e.jsx("span",{className:"document-card-key-text",children:t.key}),e.jsxs("span",{className:"document-card-revision-badge",children:["v",t.revision]})]}),e.jsx("div",{className:"document-card-actions",children:e.jsx("button",{className:"btn btn-sm document-card-expand-btn",onClick:()=>s(r=>!r),title:o?d("documents.collapse","Collapse"):d("documents.expand","Expand"),"aria-label":o?d("documents.collapseContent","Collapse content"):d("documents.expandContent","Expand content"),children:o?e.jsx(st,{size:14}):e.jsx(xe,{size:14})})})]}),e.jsxs("div",{className:"document-card-meta",children:[e.jsx("span",{className:"document-card-author",children:t.author}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{className:"document-card-date",children:Y(t.updatedAt)})]}),e.jsxs("div",{className:`document-card-content${o?" document-card-content--expanded":""}`,children:[o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"document-card-content-header",children:e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:h,"aria-label":i?d("documents.switchToPlainText","Switch to plain text"):d("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":i,title:i?d("documents.switchToPlainText","Switch to plain text"):d("documents.switchToMarkdown","Switch to markdown"),children:i?d("documents.markdown","Markdown"):d("documents.plain","Plain")})}),i?e.jsx("div",{className:"document-card-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(fe,{remarkPlugins:[pe],children:t.content})})}):e.jsx("pre",{className:"document-card-content-text",children:t.content})]}):e.jsx("p",{className:"document-card-preview",children:c}),f&&!o&&e.jsx("p",{className:"document-card-preview-truncated",children:"…"})]})]})}function rt({taskId:t,taskTitle:i,documents:h,onOpenTask:d,renderMarkdownStates:o,onToggleMarkdown:s}){const{t:c}=B("app"),[f,r]=a.useState(!1);return e.jsxs("div",{className:"documents-group",children:[e.jsxs("div",{className:"documents-group-header",children:[e.jsxs("button",{className:"documents-group-toggle-btn",onClick:()=>r(p=>!p),"aria-expanded":f,"aria-label":`${f?c("documents.collapse","Collapse"):c("documents.expand","Expand")} documents for task ${t}`,children:[e.jsx("span",{className:"documents-group-toggle","aria-hidden":"true",children:f?e.jsx(xe,{size:16}):e.jsx(tt,{size:16})}),e.jsx("span",{className:"documents-group-task-id",children:t}),e.jsx("span",{className:"documents-group-task-title",children:i||c("documents.untitled","Untitled")})]}),e.jsx("span",{className:"documents-group-count",children:c("documents.docCount","{{count}} doc{{plural}}",{count:h.length,plural:h.length!==1?"s":""})}),e.jsx("button",{className:"documents-group-task-link",onClick:()=>d(t),"aria-label":c("documents.openTaskAria","Open task {{taskId}}: {{title}}",{taskId:t,title:i||c("documents.untitled","Untitled")}),children:c("documents.openTask","Open task")})]}),f&&e.jsx("div",{className:"documents-group-content",children:h.map(p=>e.jsx(ot,{document:p,renderMarkdown:o.get(p.id)??!1,onToggleMarkdown:()=>s(p.id)},p.id))})]})}function lt({artifact:t,projectId:i,onOpenTask:h,onExpandMedia:d}){const{t:o}=B("app"),s=J(t.id,i),c=Ze(o,t.type),f=t.content?we(t.content,320):t.description,r=t.title||o("documents.untitledArtifact","Untitled artifact"),p=t.type==="image"||t.type==="video",u=a.useCallback(j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),d(t))},[t,d]);return e.jsxs("article",{className:"document-card documents-artifact-card","aria-label":o("documents.artifactCardLabel","Artifact {{title}}",{title:r}),children:[p?e.jsxs("div",{className:"documents-artifact-preview documents-artifact-preview--expandable",role:"button",tabIndex:0,"aria-label":o("documents.expandArtifact","Expand {{title}}",{title:r}),onClick:()=>d(t),onKeyDown:u,children:[t.type==="image"?e.jsx("img",{className:"documents-artifact-media",src:s,alt:r,loading:"lazy"}):e.jsx("video",{className:"documents-artifact-media",src:s,muted:!0,preload:"metadata","aria-label":o("documents.artifactVideoLabel","Video artifact: {{title}}",{title:r})}),e.jsx("span",{className:"documents-artifact-expand-hint",children:o("documents.expandArtifactHint","Click to expand")})]}):e.jsx("div",{className:"documents-artifact-preview",children:e.jsx(et,{artifact:t,mediaUrl:s,title:r,preview:f,t:o})}),e.jsxs("div",{className:"documents-artifact-body",children:[e.jsxs("div",{className:"documents-artifact-header",children:[e.jsx("span",{className:"documents-artifact-type-badge",children:c}),e.jsx("span",{className:"documents-artifact-author",children:t.authorId})]}),e.jsx("h3",{className:"documents-artifact-title",children:r}),t.description&&e.jsx("p",{className:"documents-artifact-description",children:t.description}),e.jsxs("div",{className:"documents-artifact-meta",children:[e.jsx("span",{children:Y(t.createdAt)}),t.sizeBytes!==void 0&&e.jsx("span",{children:je(t.sizeBytes)})]}),t.taskId&&e.jsx("button",{className:"documents-group-task-link documents-artifact-task-link",onClick:()=>h(t.taskId),"aria-label":o("documents.openTaskAria","Open task {{taskId}}: {{title}}",{taskId:t.taskId,title:t.taskTitle||o("documents.untitled","Untitled")}),children:o("documents.openTask","Open task")})]})]})}function pt({projectId:t,addToast:i,onOpenDetail:h,onOpenArtifactTaskDetail:d,onSendSelectionToTask:o}){const{t:s}=B("app"),[c,f]=a.useState("project"),[r,p]=a.useState(""),[u,j]=a.useState(null),[b,k]=a.useState(!1),[g,x]=a.useState(null),[P,w]=a.useState(!1),[z,E]=a.useState(null),[T,v]=a.useState(!1),S=a.useRef(0),M=a.useRef(!1),A=a.useRef(null),R=a.useRef(null),[F,H]=a.useState(!1),[ke,Z]=a.useState(new Map),[y,O]=a.useState(null),ee=a.useRef(null),q=a.useRef(null),[te,be]=a.useState(!1),ge=de(A,{locked:te}),ve=de(R,{locked:te}),K=F?ge:ve,Ne=c==="tasks"?r.trim():"",ye=c==="artifacts"?r.trim():"",{documents:D,loading:Q,error:Ce,refresh:se}=at({projectId:t,searchQuery:Ne||void 0,includeProjectFiles:!1}),{files:C,loading:_,error:Se,refresh:ae}=nt(t,{showHidden:b}),{artifacts:L,loading:V,error:Fe,refresh:ne}=Qe({projectId:t,searchQuery:ye||void 0});a.useEffect(()=>{const n=()=>{v(window.innerWidth<=ct)};return n(),window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n)}},[]),a.useEffect(()=>{M.current=!1,f("project"),j(null),k(!1),x(null),E(null),w(!1),H(!1),Z(new Map),O(null)},[t]),a.useEffect(()=>{M.current||Q||_||V||(C.length>0?f("project"):D.length>0?f("tasks"):L.length>0&&f("artifacts"),M.current=!0)},[L.length,V,D.length,Q,C.length,_]);const G=a.useMemo(()=>{const n=new Map;for(const l of D){const m=n.get(l.taskId)||[];n.set(l.taskId,[...m,l])}return Array.from(n.entries()).map(([l,m])=>{const N=[...m].sort((Ue,Be)=>Be.updatedAt.localeCompare(Ue.updatedAt));return{taskId:l,taskTitle:N[0]?.taskTitle,documents:N,latestUpdated:N[0]?.updatedAt??""}}).sort((l,m)=>m.latestUpdated.localeCompare(l.latestUpdated))},[D]),W=a.useMemo(()=>{const n=r.trim().toLowerCase();return n?C.filter(l=>{const m=l.path.toLowerCase(),N=l.name.toLowerCase();return m.includes(n)||N.includes(n)}):C},[C,r]);a.useEffect(()=>{if(!u)return;C.some(l=>l.path===u.path)||(j(null),x(null),E(null),w(!1))},[C,u]);const Ee=a.useCallback(n=>{p(n.target.value)},[]),Te=a.useCallback(()=>{p("")},[]),X=a.useCallback(n=>{f(n)},[]),Ae=a.useCallback(async n=>{try{const l=await ue(n,t);h(l)}catch{i(`Failed to open task ${n}`,"error")}},[t,h,i]),Le=a.useCallback(async n=>{try{const l=await ue(n,t);(d??h)(l)}catch{i(`Failed to open task ${n}`,"error")}},[t,d,h,i]),Pe=a.useCallback(async n=>{j(n),w(!0),E(null),x(null);const l=S.current+1;S.current=l;try{const m=await _e("project",n.path,t);if(S.current!==l)return;x(m.content)}catch(m){if(S.current!==l)return;const N=m instanceof Error?m.message:`Failed to open ${n.path}`;E(N),i(N,"error")}finally{S.current===l&&w(!1)}},[t,i]),Me=a.useCallback(()=>{j(null),x(null),E(null),w(!1)},[]),Re=a.useCallback(n=>{Z(l=>{const m=new Map(l),N=m.get(n)??!1;return m.set(n,!N),m})},[]),De=a.useCallback(n=>{q.current=document.activeElement instanceof HTMLElement?document.activeElement:null,O(n)},[]),$=a.useCallback(()=>{O(null),q.current?.focus(),q.current=null},[]);a.useEffect(()=>{if(!y)return;const n=document.body.style.overflow;document.body.style.overflow="hidden",ee.current?.focus();const l=m=>{m.key==="Escape"&&(m.preventDefault(),$())};return document.addEventListener("keydown",l),()=>{document.body.style.overflow=n,document.removeEventListener("keydown",l)}},[$,y]);const ze=a.useCallback(n=>{n.target===n.currentTarget&&$()},[$]),ce=c==="project"?Se:c==="tasks"?Ce:Fe,He=a.useCallback(async()=>{if(c==="project"){await ae();return}if(c==="tasks"){await se();return}await ne()},[c,ne,ae,se]),oe=c==="project"?W.length:c==="tasks"?D.length:L.length,$e=u&&o&&K?e.jsx(Ve,{selectedText:K.selectedText,anchorRect:K.anchorRect,filePath:u.path,onSubmit:o,onOpenChange:be}):null,re=c==="project"?s("documents.searchProjectFiles","Search project markdown files…"):c==="tasks"?s("documents.searchTaskDocuments","Search task documents…"):s("documents.searchArtifacts","Search artifacts…");return e.jsxs("div",{className:"documents-view",children:[e.jsxs("div",{className:"documents-view-header",children:[e.jsx(Ge,{icon:U,title:s("documents.title","Artifacts"),actions:e.jsx("span",{className:"documents-view-count",children:s("documents.resultCount","{{count}} result{{plural}}",{count:oe,plural:oe!==1?"s":""})})}),e.jsxs("div",{className:"documents-controls-row",children:[e.jsxs("div",{className:"documents-tab-bar",role:"tablist","aria-label":s("documents.sectionsLabel","Documents sections"),children:[e.jsxs("button",{className:`btn documents-tab${c==="project"?" active":""}`,role:"tab","aria-selected":c==="project","aria-label":s("documents.showProjectFiles","Show project markdown files"),onClick:()=>X("project"),children:[s("documents.projectFilesTab","Project Files"),e.jsx("span",{className:"documents-tab-count",children:C.length})]}),e.jsxs("button",{className:`btn documents-tab${c==="tasks"?" active":""}`,role:"tab","aria-selected":c==="tasks","aria-label":s("documents.showTaskDocuments","Show task documents"),onClick:()=>X("tasks"),children:[s("documents.taskDocumentsTab","Task Documents"),e.jsx("span",{className:"documents-tab-count",children:G.length})]}),e.jsxs("button",{className:`btn documents-tab${c==="artifacts"?" active":""}`,role:"tab","aria-selected":c==="artifacts","aria-label":s("documents.showArtifacts","Show artifacts"),onClick:()=>X("artifacts"),children:[s("documents.artifactsTab","Artifacts"),e.jsx("span",{className:"documents-tab-count",children:L.length})]})]}),c==="project"&&e.jsxs("button",{className:"btn btn-sm documents-hidden-toggle",onClick:()=>k(n=>!n),"aria-pressed":b,"aria-label":b?s("documents.hideHidden","Hide hidden project files"):s("documents.showHidden","Show hidden project files"),title:b?s("documents.hideHiddenFiles","Hide hidden files"):s("documents.showHiddenFiles","Show hidden files"),children:[b?e.jsx(We,{size:14}):e.jsx(Xe,{size:14}),b?s("documents.hideHiddenLabel","Hide Hidden"):s("documents.showHiddenLabel","Show Hidden")]}),e.jsxs("div",{className:"documents-search",children:[e.jsx(Ie,{size:16,className:"documents-search-icon"}),e.jsx("input",{type:"text",className:"documents-search-input",placeholder:re,value:r,onChange:Ee,"aria-label":re}),r&&e.jsx("button",{className:"documents-search-clear",onClick:Te,"aria-label":s("documents.clearSearch","Clear search"),children:e.jsx(me,{size:16})})]})]})]}),e.jsx("div",{className:"documents-view-content",children:ce?e.jsxs("div",{className:"documents-view-error",children:[e.jsx("p",{children:s("documents.failedToLoad","Failed to load {{type}}: {{error}}",{type:c==="project"?s("documents.projectFiles","project files"):c==="tasks"?s("documents.taskDocuments","task documents"):s("documents.artifacts","artifacts"),error:ce})}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void He(),"aria-label":s("documents.retryLoading","Retry loading documents"),children:[e.jsx(Je,{size:16}),s("documents.retry","Retry")]})]}):c==="project"?_&&C.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(I,{label:s("documents.loadingProjectFiles","Loading project markdown files…")})})}):W.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchProject",'No project markdown files match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(U,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noMarkdownFiles","No Markdown files found in this project.")})]})}):e.jsxs("div",{className:`documents-project-layout${T?" documents-project-layout--mobile":""}`,children:[(!T||!u)&&e.jsx("aside",{className:"documents-view-sidebar","aria-label":s("documents.projectMarkdownFilesLabel","Project markdown files"),children:e.jsx("ul",{className:"markdown-file-list",children:W.map(n=>{const l=u?.path===n.path;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item${l?" markdown-file-item--selected":""}`,onClick:()=>void Pe(n),"aria-label":`Open ${n.path}`,"aria-current":l?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:n.name}),e.jsx("span",{className:"markdown-file-item-path",children:n.path}),e.jsxs("span",{className:"markdown-file-item-meta",children:[je(n.size)," · ",Y(n.mtime)]})]})},n.path)})})}),(!T||u)&&e.jsxs("section",{className:"documents-view-main","aria-label":s("documents.projectFilePreviewLabel","Project file content preview"),children:[T&&u&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:Me,"aria-label":s("documents.backToFilesList","Back to project files list"),children:[e.jsx(Ye,{size:14}),s("documents.backToFiles","Back to files")]}),u?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:u.path}),e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>H(n=>!n),"aria-label":F?s("documents.switchToPlainText","Switch to plain text"):s("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":F,title:F?s("documents.switchToPlainText","Switch to plain text"):s("documents.switchToMarkdown","Switch to markdown"),children:F?s("documents.markdown","Markdown"):s("documents.plain","Plain")})]}),P?e.jsx("p",{className:"documents-content-state",children:e.jsx(I,{label:s("documents.loadingFileContent","Loading file content…")})}):z?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:z}):F?e.jsx("div",{ref:A,className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(fe,{remarkPlugins:[pe],children:g??""})})}):e.jsx("pre",{ref:R,className:"document-card-content-text documents-content-viewer-text",children:g??""}),$e]}):e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:s("documents.selectFile","Select a Markdown file to view its content.")})})]})]}):c==="artifacts"?V&&L.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:s("documents.loadingArtifacts","Loading artifacts…")})}):L.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchArtifacts",'No artifacts match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(U,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noArtifacts","No artifacts yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:s("documents.artifactsCreatedBy","Artifacts are created by agents, users, and system tools.")})]})}):e.jsx("div",{className:`documents-artifact-gallery${T?" documents-artifact-gallery--mobile":""}`,children:L.map(n=>e.jsx(lt,{artifact:n,projectId:t,onOpenTask:Le,onExpandMedia:De},n.id))}):Q&&D.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(I,{label:s("documents.loadingTaskDocuments","Loading task documents…")})})}):G.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchTask",'No task documents match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(U,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noTaskDocuments","No task documents yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:s("documents.documentsCreatedIn","Documents are created in task detail tabs.")})]})}):e.jsx("div",{className:"documents-task-list-wrap",children:e.jsx("div",{className:"documents-view-list",children:G.map(({taskId:n,taskTitle:l,documents:m})=>e.jsx(rt,{taskId:n,taskTitle:l,documents:m,onOpenTask:Ae,renderMarkdownStates:ke,onToggleMarkdown:Re},n))})})}),y&&e.jsx("div",{className:"modal-overlay open documents-artifact-lightbox-overlay",role:"dialog","aria-modal":"true","aria-label":s("documents.lightboxLabel","Artifact media preview"),onClick:ze,children:e.jsxs("div",{className:"documents-artifact-lightbox",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"documents-artifact-lightbox-header",children:[e.jsx("h3",{className:"documents-artifact-lightbox-title",children:y.title||s("documents.untitledArtifact","Untitled artifact")}),e.jsx("button",{ref:ee,className:"modal-close",onClick:$,"aria-label":s("documents.closeLightbox","Close artifact preview"),children:e.jsx(me,{size:20})})]}),e.jsx("div",{className:"documents-artifact-lightbox-media-frame",children:y.type==="image"?e.jsx("img",{className:"documents-artifact-lightbox-media",src:J(y.id,t),alt:y.title||s("documents.untitledArtifact","Untitled artifact")}):e.jsx("video",{className:"documents-artifact-lightbox-media",src:J(y.id,t),controls:!0,autoPlay:!0,"aria-label":s("documents.artifactVideoLabel","Video artifact: {{title}}",{title:y.title||s("documents.untitledArtifact","Untitled artifact")})})})]})})]})}export{pt as DocumentsView};
1
+ import{r as a,j as e}from"./vendor-react-SZ_qB27O.js";import{ax as le,ay as ie,az as Oe,aA as qe,aB as he,aC as Ke,aD as de,aE as Qe,aF as ue,aG as _e,aH as Ve,V as Ge,aI as U,B as We,D as Xe,aJ as Ie,X as me,R as Je,ak as I,o as Ye,q as fe,s as pe,aK as J,aL as Ze,aM as et,n as xe,C as tt,ac as st}from"./index-ccFe_1av.js";import{u as B}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";function at(t){const{projectId:i,searchQuery:h,includeProjectFiles:d=!0}=t??{},o=i?`${Oe.DOCUMENTS_PREFIX}${i}`:null,[s,c]=a.useState(()=>{if(!o)return[];const w=le(o,{maxAgeMs:ie});return Array.isArray(w)?w:[]}),[f,r]=a.useState([]),[p,u]=a.useState(()=>s.length===0),[j,b]=a.useState(null),k=a.useRef(null),g=a.useRef(s.length>0),x=a.useRef(null),P=a.useCallback(async()=>{k.current&&k.current.abort();const w=new AbortController;k.current=w;const z=!g.current;z&&u(!0),b(null);const E=qe(h?{q:h}:void 0,i),T=d?he(i):Promise.resolve({files:[]}),[v,S]=await Promise.allSettled([E,T]);if(w.signal.aborted)return;let M=null;if(v.status==="fulfilled"){if(c(v.value),o){const A=v.value.length>500?v.value.slice(0,500):v.value;Ke(o,A,{maxBytes:5e5})}g.current=!0}else M=v.reason instanceof Error?v.reason.message:String(v.reason);if(S.status==="fulfilled"){const A=S.value.files,R=h?.trim().toLowerCase(),F=R?A.filter(H=>H.name.toLowerCase().includes(R)||H.path.toLowerCase().includes(R)):A;r(F)}b(M),z&&u(!1)},[o,d,i,h]);return a.useEffect(()=>{if(!o){g.current=!1,c([]),u(!0);return}const w=le(o,{maxAgeMs:ie});Array.isArray(w)?(c(w),g.current=!0,u(!1)):(g.current=!1,c([]),u(!0))},[o]),a.useEffect(()=>(x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{P()},300),()=>{x.current&&clearTimeout(x.current)}),[P]),a.useEffect(()=>(P(),()=>{k.current&&k.current.abort()}),[]),{documents:s,projectFiles:f,loading:p,error:j,refresh:P}}function nt(t,i){const[h,d]=a.useState([]),[o,s]=a.useState(!0),[c,f]=a.useState(null),r=a.useRef(null),p=a.useRef(!1),u=i?.showHidden??!1,j=a.useCallback(async b=>{r.current&&r.current.abort();const k=new AbortController;r.current=k;const g=!p.current;g&&s(!0),f(null);try{const x=await he(t,{showHidden:b?.showHidden??u});if(k.signal.aborted)return;d(x.files),p.current=!0}catch(x){if(k.signal.aborted)return;f(x instanceof Error?x.message:String(x))}finally{!k.signal.aborted&&g&&s(!1)}},[t,u]);return a.useEffect(()=>(p.current=!1,j({showHidden:u}),()=>{r.current&&r.current.abort()}),[j,u]),{files:h,loading:o,error:c,refresh:j}}const ct=768;function Y(t){return t?new Date(t).toLocaleString():""}function je(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(t>=10*1024?0:1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function we(t,i=200){return t.length<=i?t:`${t.substring(0,i)}…`}function ot({document:t,renderMarkdown:i,onToggleMarkdown:h}){const{t:d}=B("app"),[o,s]=a.useState(!1),c=we(t.content),f=t.content.length>200;return e.jsxs("div",{className:"document-card",children:[e.jsxs("div",{className:"document-card-header",children:[e.jsxs("div",{className:"document-card-key",children:[e.jsx(U,{size:14}),e.jsx("span",{className:"document-card-key-text",children:t.key}),e.jsxs("span",{className:"document-card-revision-badge",children:["v",t.revision]})]}),e.jsx("div",{className:"document-card-actions",children:e.jsx("button",{className:"btn btn-sm document-card-expand-btn",onClick:()=>s(r=>!r),title:o?d("documents.collapse","Collapse"):d("documents.expand","Expand"),"aria-label":o?d("documents.collapseContent","Collapse content"):d("documents.expandContent","Expand content"),children:o?e.jsx(st,{size:14}):e.jsx(xe,{size:14})})})]}),e.jsxs("div",{className:"document-card-meta",children:[e.jsx("span",{className:"document-card-author",children:t.author}),e.jsx("span",{className:"document-card-separator",children:"·"}),e.jsx("span",{className:"document-card-date",children:Y(t.updatedAt)})]}),e.jsxs("div",{className:`document-card-content${o?" document-card-content--expanded":""}`,children:[o?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"document-card-content-header",children:e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:h,"aria-label":i?d("documents.switchToPlainText","Switch to plain text"):d("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":i,title:i?d("documents.switchToPlainText","Switch to plain text"):d("documents.switchToMarkdown","Switch to markdown"),children:i?d("documents.markdown","Markdown"):d("documents.plain","Plain")})}),i?e.jsx("div",{className:"document-card-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(fe,{remarkPlugins:[pe],children:t.content})})}):e.jsx("pre",{className:"document-card-content-text",children:t.content})]}):e.jsx("p",{className:"document-card-preview",children:c}),f&&!o&&e.jsx("p",{className:"document-card-preview-truncated",children:"…"})]})]})}function rt({taskId:t,taskTitle:i,documents:h,onOpenTask:d,renderMarkdownStates:o,onToggleMarkdown:s}){const{t:c}=B("app"),[f,r]=a.useState(!1);return e.jsxs("div",{className:"documents-group",children:[e.jsxs("div",{className:"documents-group-header",children:[e.jsxs("button",{className:"documents-group-toggle-btn",onClick:()=>r(p=>!p),"aria-expanded":f,"aria-label":`${f?c("documents.collapse","Collapse"):c("documents.expand","Expand")} documents for task ${t}`,children:[e.jsx("span",{className:"documents-group-toggle","aria-hidden":"true",children:f?e.jsx(xe,{size:16}):e.jsx(tt,{size:16})}),e.jsx("span",{className:"documents-group-task-id",children:t}),e.jsx("span",{className:"documents-group-task-title",children:i||c("documents.untitled","Untitled")})]}),e.jsx("span",{className:"documents-group-count",children:c("documents.docCount","{{count}} doc{{plural}}",{count:h.length,plural:h.length!==1?"s":""})}),e.jsx("button",{className:"documents-group-task-link",onClick:()=>d(t),"aria-label":c("documents.openTaskAria","Open task {{taskId}}: {{title}}",{taskId:t,title:i||c("documents.untitled","Untitled")}),children:c("documents.openTask","Open task")})]}),f&&e.jsx("div",{className:"documents-group-content",children:h.map(p=>e.jsx(ot,{document:p,renderMarkdown:o.get(p.id)??!1,onToggleMarkdown:()=>s(p.id)},p.id))})]})}function lt({artifact:t,projectId:i,onOpenTask:h,onExpandMedia:d}){const{t:o}=B("app"),s=J(t.id,i),c=Ze(o,t.type),f=t.content?we(t.content,320):t.description,r=t.title||o("documents.untitledArtifact","Untitled artifact"),p=t.type==="image"||t.type==="video",u=a.useCallback(j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),d(t))},[t,d]);return e.jsxs("article",{className:"document-card documents-artifact-card","aria-label":o("documents.artifactCardLabel","Artifact {{title}}",{title:r}),children:[p?e.jsxs("div",{className:"documents-artifact-preview documents-artifact-preview--expandable",role:"button",tabIndex:0,"aria-label":o("documents.expandArtifact","Expand {{title}}",{title:r}),onClick:()=>d(t),onKeyDown:u,children:[t.type==="image"?e.jsx("img",{className:"documents-artifact-media",src:s,alt:r,loading:"lazy"}):e.jsx("video",{className:"documents-artifact-media",src:s,muted:!0,preload:"metadata","aria-label":o("documents.artifactVideoLabel","Video artifact: {{title}}",{title:r})}),e.jsx("span",{className:"documents-artifact-expand-hint",children:o("documents.expandArtifactHint","Click to expand")})]}):e.jsx("div",{className:"documents-artifact-preview",children:e.jsx(et,{artifact:t,mediaUrl:s,title:r,preview:f,t:o})}),e.jsxs("div",{className:"documents-artifact-body",children:[e.jsxs("div",{className:"documents-artifact-header",children:[e.jsx("span",{className:"documents-artifact-type-badge",children:c}),e.jsx("span",{className:"documents-artifact-author",children:t.authorId})]}),e.jsx("h3",{className:"documents-artifact-title",children:r}),t.description&&e.jsx("p",{className:"documents-artifact-description",children:t.description}),e.jsxs("div",{className:"documents-artifact-meta",children:[e.jsx("span",{children:Y(t.createdAt)}),t.sizeBytes!==void 0&&e.jsx("span",{children:je(t.sizeBytes)})]}),t.taskId&&e.jsx("button",{className:"documents-group-task-link documents-artifact-task-link",onClick:()=>h(t.taskId),"aria-label":o("documents.openTaskAria","Open task {{taskId}}: {{title}}",{taskId:t.taskId,title:t.taskTitle||o("documents.untitled","Untitled")}),children:o("documents.openTask","Open task")})]})]})}function pt({projectId:t,addToast:i,onOpenDetail:h,onOpenArtifactTaskDetail:d,onSendSelectionToTask:o}){const{t:s}=B("app"),[c,f]=a.useState("project"),[r,p]=a.useState(""),[u,j]=a.useState(null),[b,k]=a.useState(!1),[g,x]=a.useState(null),[P,w]=a.useState(!1),[z,E]=a.useState(null),[T,v]=a.useState(!1),S=a.useRef(0),M=a.useRef(!1),A=a.useRef(null),R=a.useRef(null),[F,H]=a.useState(!1),[ke,Z]=a.useState(new Map),[y,O]=a.useState(null),ee=a.useRef(null),q=a.useRef(null),[te,be]=a.useState(!1),ge=de(A,{locked:te}),ve=de(R,{locked:te}),K=F?ge:ve,Ne=c==="tasks"?r.trim():"",ye=c==="artifacts"?r.trim():"",{documents:D,loading:Q,error:Ce,refresh:se}=at({projectId:t,searchQuery:Ne||void 0,includeProjectFiles:!1}),{files:C,loading:_,error:Se,refresh:ae}=nt(t,{showHidden:b}),{artifacts:L,loading:V,error:Fe,refresh:ne}=Qe({projectId:t,searchQuery:ye||void 0});a.useEffect(()=>{const n=()=>{v(window.innerWidth<=ct)};return n(),window.addEventListener("resize",n),()=>{window.removeEventListener("resize",n)}},[]),a.useEffect(()=>{M.current=!1,f("project"),j(null),k(!1),x(null),E(null),w(!1),H(!1),Z(new Map),O(null)},[t]),a.useEffect(()=>{M.current||Q||_||V||(C.length>0?f("project"):D.length>0?f("tasks"):L.length>0&&f("artifacts"),M.current=!0)},[L.length,V,D.length,Q,C.length,_]);const G=a.useMemo(()=>{const n=new Map;for(const l of D){const m=n.get(l.taskId)||[];n.set(l.taskId,[...m,l])}return Array.from(n.entries()).map(([l,m])=>{const N=[...m].sort((Ue,Be)=>Be.updatedAt.localeCompare(Ue.updatedAt));return{taskId:l,taskTitle:N[0]?.taskTitle,documents:N,latestUpdated:N[0]?.updatedAt??""}}).sort((l,m)=>m.latestUpdated.localeCompare(l.latestUpdated))},[D]),W=a.useMemo(()=>{const n=r.trim().toLowerCase();return n?C.filter(l=>{const m=l.path.toLowerCase(),N=l.name.toLowerCase();return m.includes(n)||N.includes(n)}):C},[C,r]);a.useEffect(()=>{if(!u)return;C.some(l=>l.path===u.path)||(j(null),x(null),E(null),w(!1))},[C,u]);const Ee=a.useCallback(n=>{p(n.target.value)},[]),Te=a.useCallback(()=>{p("")},[]),X=a.useCallback(n=>{f(n)},[]),Ae=a.useCallback(async n=>{try{const l=await ue(n,t);h(l)}catch{i(`Failed to open task ${n}`,"error")}},[t,h,i]),Le=a.useCallback(async n=>{try{const l=await ue(n,t);(d??h)(l)}catch{i(`Failed to open task ${n}`,"error")}},[t,d,h,i]),Pe=a.useCallback(async n=>{j(n),w(!0),E(null),x(null);const l=S.current+1;S.current=l;try{const m=await _e("project",n.path,t);if(S.current!==l)return;x(m.content)}catch(m){if(S.current!==l)return;const N=m instanceof Error?m.message:`Failed to open ${n.path}`;E(N),i(N,"error")}finally{S.current===l&&w(!1)}},[t,i]),Me=a.useCallback(()=>{j(null),x(null),E(null),w(!1)},[]),Re=a.useCallback(n=>{Z(l=>{const m=new Map(l),N=m.get(n)??!1;return m.set(n,!N),m})},[]),De=a.useCallback(n=>{q.current=document.activeElement instanceof HTMLElement?document.activeElement:null,O(n)},[]),$=a.useCallback(()=>{O(null),q.current?.focus(),q.current=null},[]);a.useEffect(()=>{if(!y)return;const n=document.body.style.overflow;document.body.style.overflow="hidden",ee.current?.focus();const l=m=>{m.key==="Escape"&&(m.preventDefault(),$())};return document.addEventListener("keydown",l),()=>{document.body.style.overflow=n,document.removeEventListener("keydown",l)}},[$,y]);const ze=a.useCallback(n=>{n.target===n.currentTarget&&$()},[$]),ce=c==="project"?Se:c==="tasks"?Ce:Fe,He=a.useCallback(async()=>{if(c==="project"){await ae();return}if(c==="tasks"){await se();return}await ne()},[c,ne,ae,se]),oe=c==="project"?W.length:c==="tasks"?D.length:L.length,$e=u&&o&&K?e.jsx(Ve,{selectedText:K.selectedText,anchorRect:K.anchorRect,filePath:u.path,onSubmit:o,onOpenChange:be}):null,re=c==="project"?s("documents.searchProjectFiles","Search project markdown files…"):c==="tasks"?s("documents.searchTaskDocuments","Search task documents…"):s("documents.searchArtifacts","Search artifacts…");return e.jsxs("div",{className:"documents-view",children:[e.jsxs("div",{className:"documents-view-header",children:[e.jsx(Ge,{icon:U,title:s("documents.title","Artifacts"),actions:e.jsx("span",{className:"documents-view-count",children:s("documents.resultCount","{{count}} result{{plural}}",{count:oe,plural:oe!==1?"s":""})})}),e.jsxs("div",{className:"documents-controls-row",children:[e.jsxs("div",{className:"documents-tab-bar",role:"tablist","aria-label":s("documents.sectionsLabel","Documents sections"),children:[e.jsxs("button",{className:`btn documents-tab${c==="project"?" active":""}`,role:"tab","aria-selected":c==="project","aria-label":s("documents.showProjectFiles","Show project markdown files"),onClick:()=>X("project"),children:[s("documents.projectFilesTab","Project Files"),e.jsx("span",{className:"documents-tab-count",children:C.length})]}),e.jsxs("button",{className:`btn documents-tab${c==="tasks"?" active":""}`,role:"tab","aria-selected":c==="tasks","aria-label":s("documents.showTaskDocuments","Show task documents"),onClick:()=>X("tasks"),children:[s("documents.taskDocumentsTab","Task Documents"),e.jsx("span",{className:"documents-tab-count",children:G.length})]}),e.jsxs("button",{className:`btn documents-tab${c==="artifacts"?" active":""}`,role:"tab","aria-selected":c==="artifacts","aria-label":s("documents.showArtifacts","Show artifacts"),onClick:()=>X("artifacts"),children:[s("documents.artifactsTab","Artifacts"),e.jsx("span",{className:"documents-tab-count",children:L.length})]})]}),c==="project"&&e.jsxs("button",{className:"btn btn-sm documents-hidden-toggle",onClick:()=>k(n=>!n),"aria-pressed":b,"aria-label":b?s("documents.hideHidden","Hide hidden project files"):s("documents.showHidden","Show hidden project files"),title:b?s("documents.hideHiddenFiles","Hide hidden files"):s("documents.showHiddenFiles","Show hidden files"),children:[b?e.jsx(We,{size:14}):e.jsx(Xe,{size:14}),b?s("documents.hideHiddenLabel","Hide Hidden"):s("documents.showHiddenLabel","Show Hidden")]}),e.jsxs("div",{className:"documents-search",children:[e.jsx(Ie,{size:16,className:"documents-search-icon"}),e.jsx("input",{type:"text",className:"documents-search-input",placeholder:re,value:r,onChange:Ee,"aria-label":re}),r&&e.jsx("button",{className:"documents-search-clear",onClick:Te,"aria-label":s("documents.clearSearch","Clear search"),children:e.jsx(me,{size:16})})]})]})]}),e.jsx("div",{className:"documents-view-content",children:ce?e.jsxs("div",{className:"documents-view-error",children:[e.jsx("p",{children:s("documents.failedToLoad","Failed to load {{type}}: {{error}}",{type:c==="project"?s("documents.projectFiles","project files"):c==="tasks"?s("documents.taskDocuments","task documents"):s("documents.artifacts","artifacts"),error:ce})}),e.jsxs("button",{className:"btn btn-primary",onClick:()=>void He(),"aria-label":s("documents.retryLoading","Retry loading documents"),children:[e.jsx(Je,{size:16}),s("documents.retry","Retry")]})]}):c==="project"?_&&C.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(I,{label:s("documents.loadingProjectFiles","Loading project markdown files…")})})}):W.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchProject",'No project markdown files match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(U,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noMarkdownFiles","No Markdown files found in this project.")})]})}):e.jsxs("div",{className:`documents-project-layout${T?" documents-project-layout--mobile":""}`,children:[(!T||!u)&&e.jsx("aside",{className:"documents-view-sidebar","aria-label":s("documents.projectMarkdownFilesLabel","Project markdown files"),children:e.jsx("ul",{className:"markdown-file-list",children:W.map(n=>{const l=u?.path===n.path;return e.jsx("li",{className:"markdown-file-list-item",children:e.jsxs("button",{className:`markdown-file-item${l?" markdown-file-item--selected":""}`,onClick:()=>void Pe(n),"aria-label":`Open ${n.path}`,"aria-current":l?"true":void 0,children:[e.jsx("span",{className:"markdown-file-item-name",children:n.name}),e.jsx("span",{className:"markdown-file-item-path",children:n.path}),e.jsxs("span",{className:"markdown-file-item-meta",children:[je(n.size)," · ",Y(n.mtime)]})]})},n.path)})})}),(!T||u)&&e.jsxs("section",{className:"documents-view-main","aria-label":s("documents.projectFilePreviewLabel","Project file content preview"),children:[T&&u&&e.jsxs("button",{className:"btn btn-sm documents-mobile-back",onClick:Me,"aria-label":s("documents.backToFilesList","Back to project files list"),children:[e.jsx(Ye,{size:14}),s("documents.backToFiles","Back to files")]}),u?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:u.path}),e.jsx("button",{className:"btn btn-sm document-mode-toggle",onClick:()=>H(n=>!n),"aria-label":F?s("documents.switchToPlainText","Switch to plain text"):s("documents.switchToMarkdown","Switch to markdown"),"aria-pressed":F,title:F?s("documents.switchToPlainText","Switch to plain text"):s("documents.switchToMarkdown","Switch to markdown"),children:F?s("documents.markdown","Markdown"):s("documents.plain","Plain")})]}),P?e.jsx("p",{className:"documents-content-state",children:e.jsx(I,{label:s("documents.loadingFileContent","Loading file content…")})}):z?e.jsx("p",{className:"documents-content-state documents-content-state--error",children:z}):F?e.jsx("div",{ref:A,className:"documents-content-markdown",children:e.jsx("div",{className:"markdown-body",children:e.jsx(fe,{remarkPlugins:[pe],children:g??""})})}):e.jsx("pre",{ref:R,className:"document-card-content-text documents-content-viewer-text",children:g??""}),$e]}):e.jsx("div",{className:"documents-view-empty",children:e.jsx("p",{children:s("documents.selectFile","Select a Markdown file to view its content.")})})]})]}):c==="artifacts"?V&&L.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:s("documents.loadingArtifacts","Loading artifacts…")})}):L.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchArtifacts",'No artifacts match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(U,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noArtifacts","No artifacts yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:s("documents.artifactsCreatedBy","Artifacts are created by agents, users, and system tools.")})]})}):e.jsx("div",{className:`documents-artifact-gallery${T?" documents-artifact-gallery--mobile":""}`,children:L.map(n=>e.jsx(lt,{artifact:n,projectId:t,onOpenTask:Le,onExpandMedia:De},n.id))}):Q&&D.length===0?e.jsx("div",{className:"documents-view-loading",children:e.jsx("p",{children:e.jsx(I,{label:s("documents.loadingTaskDocuments","Loading task documents…")})})}):G.length===0?e.jsx("div",{className:"documents-view-empty",children:r.trim()?e.jsx("p",{children:s("documents.noMatchTask",'No task documents match "{{query}}".',{query:r.trim()})}):e.jsxs(e.Fragment,{children:[e.jsx(U,{size:48,className:"documents-view-empty-icon"}),e.jsx("p",{children:s("documents.noTaskDocuments","No task documents yet.")}),e.jsx("p",{className:"documents-view-empty-hint",children:s("documents.documentsCreatedIn","Documents are created in task detail tabs.")})]})}):e.jsx("div",{className:"documents-task-list-wrap",children:e.jsx("div",{className:"documents-view-list",children:G.map(({taskId:n,taskTitle:l,documents:m})=>e.jsx(rt,{taskId:n,taskTitle:l,documents:m,onOpenTask:Ae,renderMarkdownStates:ke,onToggleMarkdown:Re},n))})})}),y&&e.jsx("div",{className:"modal-overlay open documents-artifact-lightbox-overlay",role:"dialog","aria-modal":"true","aria-label":s("documents.lightboxLabel","Artifact media preview"),onClick:ze,children:e.jsxs("div",{className:"documents-artifact-lightbox",onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"documents-artifact-lightbox-header",children:[e.jsx("h3",{className:"documents-artifact-lightbox-title",children:y.title||s("documents.untitledArtifact","Untitled artifact")}),e.jsx("button",{ref:ee,className:"modal-close",onClick:$,"aria-label":s("documents.closeLightbox","Close artifact preview"),children:e.jsx(me,{size:20})})]}),e.jsx("div",{className:"documents-artifact-lightbox-media-frame",children:y.type==="image"?e.jsx("img",{className:"documents-artifact-lightbox-media",src:J(y.id,t),alt:y.title||s("documents.untitledArtifact","Untitled artifact")}):e.jsx("video",{className:"documents-artifact-lightbox-media",src:J(y.id,t),controls:!0,autoPlay:!0,"aria-label":s("documents.artifactVideoLabel","Video artifact: {{title}}",{title:y.title||s("documents.untitledArtifact","Untitled artifact")})})})]})})]})}export{pt as DocumentsView};
@@ -1 +1 @@
1
- import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{ax as P,ay as L,az as $,aN as Q,aO as Y,aC as D,aP as J,aQ as Z,V as H,T as B,a1 as ee,R as se,ak as ae,ai as te}from"./index-CZcWjLAb.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const re=300,ne=15e3;function K(r){if(!r.trim())return;const s=Number(r);return Number.isFinite(s)?s:void 0}function k(...r){for(const s of r)if(Array.isArray(s))return s;return[]}function f(r){return typeof r=="object"&&r!==null?r:{}}function X(r){const s=f(r),m=f(s.taskSnapshot);return{id:String(s.id??s.evalId??""),runId:String(s.runId??s.batchId??""),taskId:String(s.taskId??m.taskId??""),taskTitle:String(m.title??s.taskTitle??s.title??"Untitled task"),createdAt:String(s.createdAt??s.timestamp??s.updatedAt??new Date(0).toISOString()),overallScore:typeof s.overallScore=="number"?s.overallScore:null,maxScore:typeof s.maxScore=="number"?s.maxScore:null,categoryScores:k(s.categoryScores,f(s.scores).categories)}}function ce(r){const s=f(r);return{...X(s),rationale:String(s.rationale??s.summary??""),evidence:k(s.evidence,f(s.details).evidence),followUps:k(s.followUps,f(s.recommendations).followUps)}}function ie(r){const s=r?.projectId,m=s??"",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),[i,g]=l.useState({q:"",runId:"",scoreMin:"",scoreMax:""}),[A,w]=l.useState(()=>Array.isArray(p)?p:[]),[o,C]=l.useState(()=>Array.isArray(v)?v:[]),[u,R]=l.useState(null),[F,b]=l.useState(null),[a,d]=l.useState(0),[y,j]=l.useState(!S.current),[W,z]=l.useState(null),M=l.useRef(0),q=l.useRef(s),_=l.useRef(u);_.current=u;const I=l.useCallback(async()=>{const n=++M.current;S.current||j(!0),z(null);try{const[c,x]=await Promise.all([Q({q:i.q||void 0,runId:i.runId||void 0,scoreMin:K(i.scoreMin),scoreMax:K(i.scoreMax),limit:100,offset:0},s),Y(s)]);if(n!==M.current)return;const E=k(c.results,c.evals,c.items).map(X);C(E),D(h,E.length>500?E.slice(0,500):E,{maxBytes:5e5}),d(typeof c.count=="number"?c.count:E.length);const O=k(x.runs,x.items).map(U=>{const N=f(U),V=f(N.counts);return{id:String(N.id??""),createdAt:String(N.createdAt??""),completedAt:typeof N.completedAt=="string"?N.completedAt:void 0,status:String(N.status??"pending"),evaluatedTaskCount:typeof V.totalTasks=="number"?V.totalTasks:0}});w(O),D(t,O,{maxBytes:5e5}),S.current=!0,_.current&&!E.some(U=>U.id===_.current)&&(R(null),b(null))}catch(c){if(n!==M.current)return;z(c instanceof Error?c.message:"Failed to load evals")}finally{n===M.current&&j(!1)}},[i.q,i.runId,i.scoreMax,i.scoreMin,s,h,t]),T=l.useCallback(async n=>{const c=await J(n,s),x=c.result??c;b(ce(x))},[s]);l.useEffect(()=>{if(q.current===s)return;q.current=s;const n=P(t,{maxAgeMs:L}),c=P(h,{maxAgeMs:L}),x=Array.isArray(n)&&n.length>0||Array.isArray(c)&&c.length>0;w(Array.isArray(n)?n:[]),C(Array.isArray(c)?c:[]),j(!x),S.current=x},[s,h,t]),l.useEffect(()=>{const n=window.setTimeout(()=>{I()},re);return()=>window.clearTimeout(n)},[I]),l.useEffect(()=>{if(!u){b(null);return}T(u)},[T,u]),l.useEffect(()=>{const n=window.setInterval(()=>{I(),u&&T(u)},ne);return()=>window.clearInterval(n)},[T,I,u]);const G=l.useCallback(n=>{_.current=n,R(n)},[]);return{loading:y,error:W,results:o,count:a,runs:A,filters:i,setFilters:g,refresh:I,selectedEvalId:u,setSelectedEvalId:G,selectedEval:F}}function xe({projectId:r,onOpenSettings:s,onOpenTaskDetail:m}){const{t}=le("app"),{loading:h,error:p,results:v,runs:S,filters:i,setFilters:g,selectedEvalId:A,setSelectedEvalId:w,selectedEval:o,refresh:C}=ie({projectId:r}),[u,R]=l.useState(!0);l.useEffect(()=>{let a=!1;return Z(r).then(d=>{if(a)return;const y=d.evalSettings?.enabled;R(y??!1)}).catch(()=>{a||R(!1)}),()=>{a=!0}},[r]);const F=v.length>0,b=l.useMemo(()=>v.find(a=>a.id===A)??null,[v,A]);return u?e.jsxs("section",{className:"evals-view","data-testid":"evals-view",children:[e.jsx(H,{icon:B,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:i.q,onChange:a=>g(d=>({...d,q:a.target.value}))}),e.jsxs("select",{className:"select",value:i.runId,onChange:a=>g(d=>({...d,runId:a.target.value})),children:[e.jsx("option",{value:"",children:t("evals.allRuns","All runs")}),S.map(a=>e.jsx("option",{value:a.id,children:a.id},a.id))]}),e.jsx("input",{className:"input",placeholder:t("evals.minScorePlaceholder","Min score"),value:i.scoreMin,onChange:a=>g(d=>({...d,scoreMin:a.target.value}))}),e.jsx("input",{className:"input",placeholder:t("evals.maxScorePlaceholder","Max score"),value:i.scoreMax,onChange:a=>g(d=>({...d,scoreMax:a.target.value}))}),e.jsx("button",{className:"btn btn-icon",type:"button",onClick:()=>void C(),"aria-label":t("evals.refreshAria","Refresh evals"),children:e.jsx(se,{size:16})})]}),h&&e.jsx("p",{className:"evals-state","data-testid":"evals-loading",children:e.jsx(ae,{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(a=>e.jsx("li",{children:e.jsxs("button",{className:`evals-result ${a.id===A?"evals-result--active":""}`,type:"button",onClick:()=>w(a.id),children:[e.jsx("span",{className:"evals-result-title",children:a.taskTitle}),e.jsxs("span",{className:"evals-result-meta",children:[a.taskId," · ",a.runId," · ",a.overallScore??t("evals.naPlaceholder","n/a")]})]})},a.id))})]}),e.jsxs("div",{className:"evals-detail card","data-testid":"evals-detail",children:[!o&&e.jsx("p",{className:"evals-state",children:t("evals.selectPrompt","Select an evaluation to inspect scores, rationale, and evidence.")}),o&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"evals-detail-title",children:b?.taskTitle??o.taskTitle}),e.jsxs("p",{className:"evals-result-meta",children:[o.taskId," · ",o.runId]}),e.jsx("p",{className:"evals-score",children:t("evals.overallScore","Overall score: {{score}}",{score:o.overallScore??t("evals.naPlaceholder","n/a")})}),e.jsx("ul",{className:"evals-categories",children:o.categoryScores.map(a=>e.jsxs("li",{children:[a.category,": ",a.finalScore]},a.category))}),e.jsx("p",{className:"evals-rationale",children:o.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:o.evidence.map((a,d)=>{const y=typeof a.metadata?.taskId=="string"?a.metadata.taskId:void 0,j=typeof a.metadata?.url=="string"?a.metadata.url:void 0;return e.jsx("li",{children:y?e.jsx("button",{type:"button",className:"btn",onClick:()=>m?.(y),children:a.ref}):j?e.jsxs("a",{href:j,target:"_blank",rel:"noreferrer",className:"evals-external-link",children:[a.ref,e.jsx(te,{size:14})]}):e.jsx("span",{children:a.ref})},`${a.ref}-${d}`)})})]}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.suggestedFollowupsHeading","Suggested follow-up tasks")}),e.jsxs("ul",{className:"evals-follow-ups",children:[o.followUps.length===0&&e.jsx("li",{children:t("evals.noFollowups","None")}),o.followUps.map(a=>e.jsxs("li",{children:[e.jsx("strong",{children:a.title}),e.jsx("p",{children:a.rationale})]},a.suggestionId))]})]})]})]})]})]}):e.jsxs("section",{className:"evals-view","data-testid":"evals-disabled",children:[e.jsx(H,{icon:B,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:()=>s?.("scheduled-evals"),children:[e.jsx(ee,{size:16}),t("evals.openSettings","Open Scheduled Evals Settings")]})]})]})}export{xe as EvalsView};
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{ax as P,ay as L,az as $,aN as Q,aO as Y,aC as D,aP as J,aQ as Z,V as H,T as B,a1 as ee,R as se,ak as ae,ai as te}from"./index-ccFe_1av.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const re=300,ne=15e3;function K(r){if(!r.trim())return;const s=Number(r);return Number.isFinite(s)?s:void 0}function k(...r){for(const s of r)if(Array.isArray(s))return s;return[]}function f(r){return typeof r=="object"&&r!==null?r:{}}function X(r){const s=f(r),m=f(s.taskSnapshot);return{id:String(s.id??s.evalId??""),runId:String(s.runId??s.batchId??""),taskId:String(s.taskId??m.taskId??""),taskTitle:String(m.title??s.taskTitle??s.title??"Untitled task"),createdAt:String(s.createdAt??s.timestamp??s.updatedAt??new Date(0).toISOString()),overallScore:typeof s.overallScore=="number"?s.overallScore:null,maxScore:typeof s.maxScore=="number"?s.maxScore:null,categoryScores:k(s.categoryScores,f(s.scores).categories)}}function ce(r){const s=f(r);return{...X(s),rationale:String(s.rationale??s.summary??""),evidence:k(s.evidence,f(s.details).evidence),followUps:k(s.followUps,f(s.recommendations).followUps)}}function ie(r){const s=r?.projectId,m=s??"",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),[i,g]=l.useState({q:"",runId:"",scoreMin:"",scoreMax:""}),[A,w]=l.useState(()=>Array.isArray(p)?p:[]),[o,C]=l.useState(()=>Array.isArray(v)?v:[]),[u,R]=l.useState(null),[F,b]=l.useState(null),[a,d]=l.useState(0),[y,j]=l.useState(!S.current),[W,z]=l.useState(null),M=l.useRef(0),q=l.useRef(s),_=l.useRef(u);_.current=u;const I=l.useCallback(async()=>{const n=++M.current;S.current||j(!0),z(null);try{const[c,x]=await Promise.all([Q({q:i.q||void 0,runId:i.runId||void 0,scoreMin:K(i.scoreMin),scoreMax:K(i.scoreMax),limit:100,offset:0},s),Y(s)]);if(n!==M.current)return;const E=k(c.results,c.evals,c.items).map(X);C(E),D(h,E.length>500?E.slice(0,500):E,{maxBytes:5e5}),d(typeof c.count=="number"?c.count:E.length);const O=k(x.runs,x.items).map(U=>{const N=f(U),V=f(N.counts);return{id:String(N.id??""),createdAt:String(N.createdAt??""),completedAt:typeof N.completedAt=="string"?N.completedAt:void 0,status:String(N.status??"pending"),evaluatedTaskCount:typeof V.totalTasks=="number"?V.totalTasks:0}});w(O),D(t,O,{maxBytes:5e5}),S.current=!0,_.current&&!E.some(U=>U.id===_.current)&&(R(null),b(null))}catch(c){if(n!==M.current)return;z(c instanceof Error?c.message:"Failed to load evals")}finally{n===M.current&&j(!1)}},[i.q,i.runId,i.scoreMax,i.scoreMin,s,h,t]),T=l.useCallback(async n=>{const c=await J(n,s),x=c.result??c;b(ce(x))},[s]);l.useEffect(()=>{if(q.current===s)return;q.current=s;const n=P(t,{maxAgeMs:L}),c=P(h,{maxAgeMs:L}),x=Array.isArray(n)&&n.length>0||Array.isArray(c)&&c.length>0;w(Array.isArray(n)?n:[]),C(Array.isArray(c)?c:[]),j(!x),S.current=x},[s,h,t]),l.useEffect(()=>{const n=window.setTimeout(()=>{I()},re);return()=>window.clearTimeout(n)},[I]),l.useEffect(()=>{if(!u){b(null);return}T(u)},[T,u]),l.useEffect(()=>{const n=window.setInterval(()=>{I(),u&&T(u)},ne);return()=>window.clearInterval(n)},[T,I,u]);const G=l.useCallback(n=>{_.current=n,R(n)},[]);return{loading:y,error:W,results:o,count:a,runs:A,filters:i,setFilters:g,refresh:I,selectedEvalId:u,setSelectedEvalId:G,selectedEval:F}}function xe({projectId:r,onOpenSettings:s,onOpenTaskDetail:m}){const{t}=le("app"),{loading:h,error:p,results:v,runs:S,filters:i,setFilters:g,selectedEvalId:A,setSelectedEvalId:w,selectedEval:o,refresh:C}=ie({projectId:r}),[u,R]=l.useState(!0);l.useEffect(()=>{let a=!1;return Z(r).then(d=>{if(a)return;const y=d.evalSettings?.enabled;R(y??!1)}).catch(()=>{a||R(!1)}),()=>{a=!0}},[r]);const F=v.length>0,b=l.useMemo(()=>v.find(a=>a.id===A)??null,[v,A]);return u?e.jsxs("section",{className:"evals-view","data-testid":"evals-view",children:[e.jsx(H,{icon:B,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:i.q,onChange:a=>g(d=>({...d,q:a.target.value}))}),e.jsxs("select",{className:"select",value:i.runId,onChange:a=>g(d=>({...d,runId:a.target.value})),children:[e.jsx("option",{value:"",children:t("evals.allRuns","All runs")}),S.map(a=>e.jsx("option",{value:a.id,children:a.id},a.id))]}),e.jsx("input",{className:"input",placeholder:t("evals.minScorePlaceholder","Min score"),value:i.scoreMin,onChange:a=>g(d=>({...d,scoreMin:a.target.value}))}),e.jsx("input",{className:"input",placeholder:t("evals.maxScorePlaceholder","Max score"),value:i.scoreMax,onChange:a=>g(d=>({...d,scoreMax:a.target.value}))}),e.jsx("button",{className:"btn btn-icon",type:"button",onClick:()=>void C(),"aria-label":t("evals.refreshAria","Refresh evals"),children:e.jsx(se,{size:16})})]}),h&&e.jsx("p",{className:"evals-state","data-testid":"evals-loading",children:e.jsx(ae,{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(a=>e.jsx("li",{children:e.jsxs("button",{className:`evals-result ${a.id===A?"evals-result--active":""}`,type:"button",onClick:()=>w(a.id),children:[e.jsx("span",{className:"evals-result-title",children:a.taskTitle}),e.jsxs("span",{className:"evals-result-meta",children:[a.taskId," · ",a.runId," · ",a.overallScore??t("evals.naPlaceholder","n/a")]})]})},a.id))})]}),e.jsxs("div",{className:"evals-detail card","data-testid":"evals-detail",children:[!o&&e.jsx("p",{className:"evals-state",children:t("evals.selectPrompt","Select an evaluation to inspect scores, rationale, and evidence.")}),o&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{className:"evals-detail-title",children:b?.taskTitle??o.taskTitle}),e.jsxs("p",{className:"evals-result-meta",children:[o.taskId," · ",o.runId]}),e.jsx("p",{className:"evals-score",children:t("evals.overallScore","Overall score: {{score}}",{score:o.overallScore??t("evals.naPlaceholder","n/a")})}),e.jsx("ul",{className:"evals-categories",children:o.categoryScores.map(a=>e.jsxs("li",{children:[a.category,": ",a.finalScore]},a.category))}),e.jsx("p",{className:"evals-rationale",children:o.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:o.evidence.map((a,d)=>{const y=typeof a.metadata?.taskId=="string"?a.metadata.taskId:void 0,j=typeof a.metadata?.url=="string"?a.metadata.url:void 0;return e.jsx("li",{children:y?e.jsx("button",{type:"button",className:"btn",onClick:()=>m?.(y),children:a.ref}):j?e.jsxs("a",{href:j,target:"_blank",rel:"noreferrer",className:"evals-external-link",children:[a.ref,e.jsx(te,{size:14})]}):e.jsx("span",{children:a.ref})},`${a.ref}-${d}`)})})]}),e.jsxs("div",{children:[e.jsx("h4",{children:t("evals.suggestedFollowupsHeading","Suggested follow-up tasks")}),e.jsxs("ul",{className:"evals-follow-ups",children:[o.followUps.length===0&&e.jsx("li",{children:t("evals.noFollowups","None")}),o.followUps.map(a=>e.jsxs("li",{children:[e.jsx("strong",{children:a.title}),e.jsx("p",{children:a.rationale})]},a.suggestionId))]})]})]})]})]})]}):e.jsxs("section",{className:"evals-view","data-testid":"evals-disabled",children:[e.jsx(H,{icon:B,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:()=>s?.("scheduled-evals"),children:[e.jsx(ee,{size:16}),t("evals.openSettings","Open Scheduled Evals Settings")]})]})]})}export{xe as EvalsView};
@@ -1 +1 @@
1
- import{r as s,j as n}from"./vendor-react-SZ_qB27O.js";import{A as F,J as V,K as W,N as G,O as J,Q as K}from"./index-CZcWjLAb.js";import{u as U}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";function en({isOpen:l,onClose:R,onUseDraft:M,projectId:x,existingAgents:P,mode:_="create",existingAgentConfig:L}){const{t:e}=U("app"),[m,d]=s.useState("initial"),[f,S]=s.useState(""),[c,k]=s.useState(null),[C,I]=s.useState(""),[w,A]=s.useState("answer"),[v,p]=s.useState(""),[t,T]=s.useState(null),[H,g]=s.useState(null),[E,y]=s.useState([]),b=_==="edit",o=s.useRef(l),N=s.useCallback(()=>{d("initial"),S(""),k(null),I(""),A("answer"),p(""),T(null),g(null),y([])},[]),Q=s.useMemo(()=>F.map(a=>({id:a.id,label:a.name,description:a.description})),[]);s.useEffect(()=>{if(o.current=l,!c)return;const a=V(c,x,{onThinking:i=>{o.current&&y($=>{const h=[...$],j=h[h.length-1];return j&&!j.question?(h[h.length-1]={...j,thinkingOutput:`${j.thinkingOutput??""}${i}`},h):[...h,{response:{},thinkingOutput:i}]})},onQuestion:i=>{o.current&&(I(i.question),A(i.id),d("question"))},onSummary:i=>{o.current&&(T(i),d("summary"))},onError:i=>{o.current&&(g(i),d("error"))}});return()=>{o.current=!1,a.close()}},[l,c,x]);const u=async()=>{o.current=!1;try{c&&await G(c,x)}catch{}finally{N(),R()}};if(s.useEffect(()=>{o.current=l,l||N()},[l,N]),!l)return null;const r=a=>a==null||a===""?n.jsx("em",{className:"experimental-agent-onboarding-modal__summary-empty",children:e("agents.onboarding.notSet","Not set")}):n.jsx("span",{children:a}),q=async()=>{d("loading"),g(null);try{const a=await J(f,{mode:_,existingAgentConfig:L,existingAgents:P.map(i=>({id:i.id,name:i.name,role:i.role})),templates:Q},x);if(!o.current)return;k(a.sessionId)}catch(a){if(!o.current)return;g(a.message),d("error")}},D=async()=>{if(c){d("loading"),g(null);try{const a={[w]:v};if(y(i=>[...i,{question:{id:w,type:"text",question:C},response:a}]),await K(c,a,x),!o.current)return;p("")}catch(a){if(!o.current)return;g(a.message),d("error")}}},O=async()=>{t&&(M(t),await u())};return n.jsx("div",{className:"modal-overlay open",role:"presentation",children:n.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",role:"dialog","aria-modal":"true","aria-label":e("agents.onboarding.dialogLabel","AI Interview"),children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{children:e("agents.onboarding.title","AI Interview")}),n.jsx("button",{className:"modal-close",onClick:()=>void u(),"aria-label":e("common.closeAriaLabel","Close"),children:"×"})]}),E.length>0&&n.jsx(W,{entries:E}),m==="initial"&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{htmlFor:"agent-onboarding-intent",children:b?e("agents.onboarding.intentLabelEdit","What should this agent change or improve?"):e("agents.onboarding.intentLabelCreate","What should this new agent own?")}),n.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:f,onChange:a=>S(a.target.value)}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",disabled:!f.trim(),onClick:()=>void q(),children:b?e("agents.onboarding.startInterview","Start interview"):e("agents.onboarding.startOnboarding","Start onboarding")})]})]}),(m==="loading"||m==="question")&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{htmlFor:"agent-onboarding-answer",children:C||e("agents.onboarding.thinking","Thinking...")}),n.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:v,onChange:a=>p(a.target.value)}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",disabled:m==="loading"||!v.trim(),onClick:()=>void D(),children:e("agents.onboarding.continue","Continue")})]})]}),m==="summary"&&t&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{children:b?e("agents.onboarding.updatedDraftReady","Updated draft ready for review"):e("agents.onboarding.draftReady","Draft ready for review")}),n.jsx("p",{className:"experimental-agent-onboarding-modal__summary-intro",children:e("agents.onboarding.draftIntro","Review this generated draft. Nothing is applied until you confirm.")}),n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionIdentity","Identity")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldName","Name")}),n.jsx("dd",{children:r(t.name)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldRole","Role")}),n.jsx("dd",{children:r(t.role)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldTitle","Title")}),n.jsx("dd",{children:r(t.title)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldIcon","Icon")}),n.jsx("dd",{children:r(t.icon)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldReportsTo","Reports To")}),n.jsx("dd",{children:r(t.reportsTo)})]})]})]}),n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionConfiguration","Configuration")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldInlineInstructions","Inline Instructions")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.instructionsText)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldSoul","Soul")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.soul)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldAgentMemory","Agent Memory")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.memory)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldSkills","Skills")}),n.jsx("dd",{children:r(t.skills?.join(", "))})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldThinkingLevel","Thinking Level")}),n.jsx("dd",{children:r(t.thinkingLevel)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldMaxTurns","Max Turns")}),n.jsx("dd",{children:r(t.maxTurns)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldTemplate","Template")}),n.jsx("dd",{children:r(t.templateId)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldPatternAgent","Pattern Agent")}),n.jsx("dd",{children:r(t.patternAgentId)})]})]})]}),(t.heartbeatProcedurePath||t.heartbeatIntervalMs||t.heartbeatEnabled!==void 0||t.modelHint||t.runtimeHint)&&n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionRuntimeHints","Runtime Hints")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatPath","Heartbeat Procedure Path")}),n.jsx("dd",{children:r(t.heartbeatProcedurePath)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatInterval","Heartbeat Interval")}),n.jsx("dd",{children:r(t.heartbeatIntervalMs?`${t.heartbeatIntervalMs}ms`:void 0)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatEnabled","Heartbeat Enabled")}),n.jsx("dd",{children:r(t.heartbeatEnabled===void 0?void 0:t.heartbeatEnabled?e("agents.onboarding.yes","yes"):e("agents.onboarding.no","no"))})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldModelHint","Model Hint")}),n.jsx("dd",{children:r(t.modelHint)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldRuntimeHint","Runtime Hint")}),n.jsx("dd",{children:r(t.runtimeHint)})]})]})]}),t.rationale&&n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionRationale","Rationale")}),n.jsx("p",{className:"experimental-agent-onboarding-modal__summary-block",children:t.rationale})]})]}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",onClick:()=>void O(),children:b?e("agents.onboarding.applyDraftSettings","Apply draft to settings form"):e("agents.onboarding.applyDraftAgent","Apply draft to agent form")})]})]}),m==="error"&&H&&n.jsxs("div",{className:"form-group",children:[n.jsx("div",{className:"form-error",children:H}),n.jsx("div",{className:"modal-actions",children:n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.close","Close")})})]})]})})}export{en as ExperimentalAgentOnboardingModal};
1
+ import{r as s,j as n}from"./vendor-react-SZ_qB27O.js";import{A as F,J as V,K as W,N as G,O as J,Q as K}from"./index-ccFe_1av.js";import{u as U}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";function en({isOpen:l,onClose:R,onUseDraft:M,projectId:x,existingAgents:P,mode:_="create",existingAgentConfig:L}){const{t:e}=U("app"),[m,d]=s.useState("initial"),[f,S]=s.useState(""),[c,k]=s.useState(null),[C,I]=s.useState(""),[w,A]=s.useState("answer"),[v,p]=s.useState(""),[t,T]=s.useState(null),[H,g]=s.useState(null),[E,y]=s.useState([]),b=_==="edit",o=s.useRef(l),N=s.useCallback(()=>{d("initial"),S(""),k(null),I(""),A("answer"),p(""),T(null),g(null),y([])},[]),Q=s.useMemo(()=>F.map(a=>({id:a.id,label:a.name,description:a.description})),[]);s.useEffect(()=>{if(o.current=l,!c)return;const a=V(c,x,{onThinking:i=>{o.current&&y($=>{const h=[...$],j=h[h.length-1];return j&&!j.question?(h[h.length-1]={...j,thinkingOutput:`${j.thinkingOutput??""}${i}`},h):[...h,{response:{},thinkingOutput:i}]})},onQuestion:i=>{o.current&&(I(i.question),A(i.id),d("question"))},onSummary:i=>{o.current&&(T(i),d("summary"))},onError:i=>{o.current&&(g(i),d("error"))}});return()=>{o.current=!1,a.close()}},[l,c,x]);const u=async()=>{o.current=!1;try{c&&await G(c,x)}catch{}finally{N(),R()}};if(s.useEffect(()=>{o.current=l,l||N()},[l,N]),!l)return null;const r=a=>a==null||a===""?n.jsx("em",{className:"experimental-agent-onboarding-modal__summary-empty",children:e("agents.onboarding.notSet","Not set")}):n.jsx("span",{children:a}),q=async()=>{d("loading"),g(null);try{const a=await J(f,{mode:_,existingAgentConfig:L,existingAgents:P.map(i=>({id:i.id,name:i.name,role:i.role})),templates:Q},x);if(!o.current)return;k(a.sessionId)}catch(a){if(!o.current)return;g(a.message),d("error")}},D=async()=>{if(c){d("loading"),g(null);try{const a={[w]:v};if(y(i=>[...i,{question:{id:w,type:"text",question:C},response:a}]),await K(c,a,x),!o.current)return;p("")}catch(a){if(!o.current)return;g(a.message),d("error")}}},O=async()=>{t&&(M(t),await u())};return n.jsx("div",{className:"modal-overlay open",role:"presentation",children:n.jsxs("div",{className:"modal modal-lg experimental-agent-onboarding-modal",role:"dialog","aria-modal":"true","aria-label":e("agents.onboarding.dialogLabel","AI Interview"),children:[n.jsxs("div",{className:"modal-header",children:[n.jsx("h3",{children:e("agents.onboarding.title","AI Interview")}),n.jsx("button",{className:"modal-close",onClick:()=>void u(),"aria-label":e("common.closeAriaLabel","Close"),children:"×"})]}),E.length>0&&n.jsx(W,{entries:E}),m==="initial"&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{htmlFor:"agent-onboarding-intent",children:b?e("agents.onboarding.intentLabelEdit","What should this agent change or improve?"):e("agents.onboarding.intentLabelCreate","What should this new agent own?")}),n.jsx("textarea",{id:"agent-onboarding-intent",className:"input experimental-agent-onboarding-modal__textarea",value:f,onChange:a=>S(a.target.value)}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",disabled:!f.trim(),onClick:()=>void q(),children:b?e("agents.onboarding.startInterview","Start interview"):e("agents.onboarding.startOnboarding","Start onboarding")})]})]}),(m==="loading"||m==="question")&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{htmlFor:"agent-onboarding-answer",children:C||e("agents.onboarding.thinking","Thinking...")}),n.jsx("textarea",{id:"agent-onboarding-answer",className:"input experimental-agent-onboarding-modal__textarea",value:v,onChange:a=>p(a.target.value)}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",disabled:m==="loading"||!v.trim(),onClick:()=>void D(),children:e("agents.onboarding.continue","Continue")})]})]}),m==="summary"&&t&&n.jsxs("div",{className:"form-group",children:[n.jsx("label",{children:b?e("agents.onboarding.updatedDraftReady","Updated draft ready for review"):e("agents.onboarding.draftReady","Draft ready for review")}),n.jsx("p",{className:"experimental-agent-onboarding-modal__summary-intro",children:e("agents.onboarding.draftIntro","Review this generated draft. Nothing is applied until you confirm.")}),n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary card",children:[n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionIdentity","Identity")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldName","Name")}),n.jsx("dd",{children:r(t.name)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldRole","Role")}),n.jsx("dd",{children:r(t.role)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldTitle","Title")}),n.jsx("dd",{children:r(t.title)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldIcon","Icon")}),n.jsx("dd",{children:r(t.icon)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldReportsTo","Reports To")}),n.jsx("dd",{children:r(t.reportsTo)})]})]})]}),n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionConfiguration","Configuration")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldInlineInstructions","Inline Instructions")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.instructionsText)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldSoul","Soul")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.soul)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldAgentMemory","Agent Memory")}),n.jsx("dd",{className:"experimental-agent-onboarding-modal__summary-block",children:r(t.memory)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldSkills","Skills")}),n.jsx("dd",{children:r(t.skills?.join(", "))})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldThinkingLevel","Thinking Level")}),n.jsx("dd",{children:r(t.thinkingLevel)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldMaxTurns","Max Turns")}),n.jsx("dd",{children:r(t.maxTurns)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldTemplate","Template")}),n.jsx("dd",{children:r(t.templateId)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldPatternAgent","Pattern Agent")}),n.jsx("dd",{children:r(t.patternAgentId)})]})]})]}),(t.heartbeatProcedurePath||t.heartbeatIntervalMs||t.heartbeatEnabled!==void 0||t.modelHint||t.runtimeHint)&&n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionRuntimeHints","Runtime Hints")}),n.jsxs("dl",{className:"experimental-agent-onboarding-modal__summary-list",children:[n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatPath","Heartbeat Procedure Path")}),n.jsx("dd",{children:r(t.heartbeatProcedurePath)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatInterval","Heartbeat Interval")}),n.jsx("dd",{children:r(t.heartbeatIntervalMs?`${t.heartbeatIntervalMs}ms`:void 0)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldHeartbeatEnabled","Heartbeat Enabled")}),n.jsx("dd",{children:r(t.heartbeatEnabled===void 0?void 0:t.heartbeatEnabled?e("agents.onboarding.yes","yes"):e("agents.onboarding.no","no"))})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldModelHint","Model Hint")}),n.jsx("dd",{children:r(t.modelHint)})]}),n.jsxs("div",{children:[n.jsx("dt",{children:e("agents.onboarding.fieldRuntimeHint","Runtime Hint")}),n.jsx("dd",{children:r(t.runtimeHint)})]})]})]}),t.rationale&&n.jsxs("div",{className:"experimental-agent-onboarding-modal__summary-section",children:[n.jsx("h4",{children:e("agents.onboarding.sectionRationale","Rationale")}),n.jsx("p",{className:"experimental-agent-onboarding-modal__summary-block",children:t.rationale})]})]}),n.jsxs("div",{className:"modal-actions",children:[n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.cancel","Cancel")}),n.jsx("button",{className:"btn btn-primary",onClick:()=>void O(),children:b?e("agents.onboarding.applyDraftSettings","Apply draft to settings form"):e("agents.onboarding.applyDraftAgent","Apply draft to agent form")})]})]}),m==="error"&&H&&n.jsxs("div",{className:"form-group",children:[n.jsx("div",{className:"form-error",children:H}),n.jsx("div",{className:"modal-actions",children:n.jsx("button",{className:"btn",onClick:()=>void u(),children:e("common.close","Close")})})]})]})})}export{en as ExperimentalAgentOnboardingModal};
@@ -1,2 +1,2 @@
1
- import{r as n,j as t}from"./vendor-react-SZ_qB27O.js";import{V as vs,T as xs,P as js,S as ws,q as Ns,s as Es,v as Ss,X as Ms,w as $s,x as Cs}from"./index-CZcWjLAb.js";import{u as Ts}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const As=5,Gs=3,Ls=280;function ts(r){return!!(r&&typeof r=="object"&&"code"in r&&r.code==="ACTIVE_GOAL_LIMIT_EXCEEDED")}function Os({initialGoals:r,anchorGoalId:m,onNavigateToMission:es}){const{t:a}=Ts("app"),[d,f]=n.useState(()=>r??[]),[is,v]=n.useState(null),g=n.useRef(null),[x,A]=n.useState(r===void 0),[G,l]=n.useState(null),[as,L]=n.useState(!1),[b,D]=n.useState(""),[P,j]=n.useState(""),[F,c]=n.useState(null),[U,R]=n.useState(!1),[k,w]=n.useState(!1),[N,I]=n.useState(null),[O,E]=n.useState(""),[_,S]=n.useState(""),[V,h]=n.useState(null),[q,B]=n.useState(!1),[ns,os]=n.useState(()=>new Set),[ls,rs]=n.useState([]),[y,M]=n.useState({}),[$,H]=n.useState({}),[C,W]=n.useState(null),[ds,z]=n.useState(null);n.useEffect(()=>{if(r!==void 0)return;let s=!0;return(async()=>{try{A(!0),l(null);const i=await fetch("/api/goals");if(!i.ok)throw new Error(`Failed to load goals (${i.status})`);const o=await i.json();if(!s)return;f(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&&A(!1)}})(),()=>{s=!1}},[r]),n.useEffect(()=>{let s=!0;return(async()=>{try{const i=await fetch("/api/missions");if(!i.ok)throw new Error(`Failed to load missions (${i.status})`);const o=await i.json(),u=Array.isArray(o)?o:Array.isArray(o.missions)?o.missions:[];s&&rs(u.map(p=>({id:p.id,title:p.title,status:p.status})))}catch{s&&l(a("goals.missionsLoadError","Unable to load missions right now. Please try again."))}})(),()=>{s=!1}},[a]);const K=async s=>{const e=await fetch(`/api/goals/${encodeURIComponent(s)}/missions`);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(d.length===0){M({});return}try{const i=await Promise.all(d.map(async o=>[o.id,await K(o.id)]));s&&M(Object.fromEntries(i))}catch{s&&l(a("goals.linkedMissionsLoadError","Unable to load linked missions right now. Please try again."))}})(),()=>{s=!1}},[d,a]);const T=n.useMemo(()=>d.filter(s=>s.status==="active").length,[d]),cs=T>=Gs&&T<=As;n.useEffect(()=>{if(!m){v(null);return}const s=document.getElementById(`goal-card-${m}`);if(s)return v(m),typeof s.scrollIntoView=="function"&&s.scrollIntoView({behavior:"smooth",block:"center"}),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{v(e=>e===m?null:e),g.current=null},1600),()=>{g.current&&(clearTimeout(g.current),g.current=null)}},[m,d]);function us(){l(null),c(null),L(!0)}function gs(s){I(s.id),E(s.title),S(s.description??""),h(null)}function X(){I(null),E(""),S(""),h(null)}function J(){L(!1),D(""),j(""),c(null),w(!1)}async function ms(){const s=b.trim();if(!s){c(a("goals.titleRequired","Title is required."));return}try{w(!0),c(null);const e=await $s(s);j(e)}catch(e){c(Cs(e))}finally{w(!1)}}async function hs(){const s=b.trim();if(!s){c(a("goals.titleRequired","Title is required."));return}try{R(!0),c(null),l(null);const e=await fetch("/api/goals",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:P})});if(e.ok){const o=await e.json();f(u=>[...u,o]),J();return}let i=null;try{i=await e.json()}catch{i=null}if(e.status===409&&ts(i)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}c(a("goals.createError","Unable to create goal right now. Please try again."))}catch{c(a("goals.createError","Unable to create goal right now. Please try again."))}finally{R(!1)}}async function ps(){if(!N)return;const s=O.trim();if(!s){h(a("goals.titleRequired","Title is required."));return}try{B(!0),h(null);const e=await fetch(`/api/goals/${N}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:_})});if(!e.ok)throw new Error(`Failed to update goal (${e.status})`);const i=await e.json();f(o=>o.map(u=>u.id===i.id?i:u)),X()}catch{h(a("goals.saveError","Unable to save goal right now. Please try again."))}finally{B(!1)}}function fs(s){return s.length>Ls||s.includes(`
1
+ import{r as n,j as t}from"./vendor-react-SZ_qB27O.js";import{V as vs,T as xs,P as js,S as ws,q as Ns,s as Es,v as Ss,X as Ms,w as $s,x as Cs}from"./index-ccFe_1av.js";import{u as Ts}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const As=5,Gs=3,Ls=280;function ts(r){return!!(r&&typeof r=="object"&&"code"in r&&r.code==="ACTIVE_GOAL_LIMIT_EXCEEDED")}function Os({initialGoals:r,anchorGoalId:m,onNavigateToMission:es}){const{t:a}=Ts("app"),[d,f]=n.useState(()=>r??[]),[is,v]=n.useState(null),g=n.useRef(null),[x,A]=n.useState(r===void 0),[G,l]=n.useState(null),[as,L]=n.useState(!1),[b,D]=n.useState(""),[P,j]=n.useState(""),[F,c]=n.useState(null),[U,R]=n.useState(!1),[k,w]=n.useState(!1),[N,I]=n.useState(null),[O,E]=n.useState(""),[_,S]=n.useState(""),[V,h]=n.useState(null),[q,B]=n.useState(!1),[ns,os]=n.useState(()=>new Set),[ls,rs]=n.useState([]),[y,M]=n.useState({}),[$,H]=n.useState({}),[C,W]=n.useState(null),[ds,z]=n.useState(null);n.useEffect(()=>{if(r!==void 0)return;let s=!0;return(async()=>{try{A(!0),l(null);const i=await fetch("/api/goals");if(!i.ok)throw new Error(`Failed to load goals (${i.status})`);const o=await i.json();if(!s)return;f(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&&A(!1)}})(),()=>{s=!1}},[r]),n.useEffect(()=>{let s=!0;return(async()=>{try{const i=await fetch("/api/missions");if(!i.ok)throw new Error(`Failed to load missions (${i.status})`);const o=await i.json(),u=Array.isArray(o)?o:Array.isArray(o.missions)?o.missions:[];s&&rs(u.map(p=>({id:p.id,title:p.title,status:p.status})))}catch{s&&l(a("goals.missionsLoadError","Unable to load missions right now. Please try again."))}})(),()=>{s=!1}},[a]);const K=async s=>{const e=await fetch(`/api/goals/${encodeURIComponent(s)}/missions`);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(d.length===0){M({});return}try{const i=await Promise.all(d.map(async o=>[o.id,await K(o.id)]));s&&M(Object.fromEntries(i))}catch{s&&l(a("goals.linkedMissionsLoadError","Unable to load linked missions right now. Please try again."))}})(),()=>{s=!1}},[d,a]);const T=n.useMemo(()=>d.filter(s=>s.status==="active").length,[d]),cs=T>=Gs&&T<=As;n.useEffect(()=>{if(!m){v(null);return}const s=document.getElementById(`goal-card-${m}`);if(s)return v(m),typeof s.scrollIntoView=="function"&&s.scrollIntoView({behavior:"smooth",block:"center"}),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{v(e=>e===m?null:e),g.current=null},1600),()=>{g.current&&(clearTimeout(g.current),g.current=null)}},[m,d]);function us(){l(null),c(null),L(!0)}function gs(s){I(s.id),E(s.title),S(s.description??""),h(null)}function X(){I(null),E(""),S(""),h(null)}function J(){L(!1),D(""),j(""),c(null),w(!1)}async function ms(){const s=b.trim();if(!s){c(a("goals.titleRequired","Title is required."));return}try{w(!0),c(null);const e=await $s(s);j(e)}catch(e){c(Cs(e))}finally{w(!1)}}async function hs(){const s=b.trim();if(!s){c(a("goals.titleRequired","Title is required."));return}try{R(!0),c(null),l(null);const e=await fetch("/api/goals",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:P})});if(e.ok){const o=await e.json();f(u=>[...u,o]),J();return}let i=null;try{i=await e.json()}catch{i=null}if(e.status===409&&ts(i)){l(a("goals.capError","Cannot activate more than 5 goals. Resolve an active goal before activating another."));return}c(a("goals.createError","Unable to create goal right now. Please try again."))}catch{c(a("goals.createError","Unable to create goal right now. Please try again."))}finally{R(!1)}}async function ps(){if(!N)return;const s=O.trim();if(!s){h(a("goals.titleRequired","Title is required."));return}try{B(!0),h(null);const e=await fetch(`/api/goals/${N}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({title:s,description:_})});if(!e.ok)throw new Error(`Failed to update goal (${e.status})`);const i=await e.json();f(o=>o.map(u=>u.id===i.id?i:u)),X()}catch{h(a("goals.saveError","Unable to save goal right now. Please try again."))}finally{B(!1)}}function fs(s){return s.length>Ls||s.includes(`
2
2
  `)}function bs(s){os(e=>{const i=new Set(e);return i.has(s)?i.delete(s):i.add(s),i})}function Q(s){const e=new Set((y[s]??[]).map(i=>i.id));return ls.filter(i=>!e.has(i.id))}async function Y(s){const e=await K(s);M(i=>({...i,[s]:e})),H(i=>({...i,[s]:""}))}async function ks(s){const e=$[s];if(e)try{W(s),l(null);const i=await fetch(`/api/missions/${encodeURIComponent(e)}/goals/${encodeURIComponent(s)}`,{method:"POST"});if(!i.ok)throw new Error(`Failed to link mission (${i.status})`);await Y(s)}catch{l(a("goals.linkMissionError","Unable to link mission right now. Please try again."))}finally{W(null)}}async function ys(s,e){try{z(`${s}:${e}`),l(null);const i=await fetch(`/api/missions/${encodeURIComponent(e)}/goals/${encodeURIComponent(s)}`,{method:"DELETE"});if(!i.ok)throw new Error(`Failed to unlink mission (${i.status})`);await Y(s)}catch{l(a("goals.unlinkMissionError","Unable to unlink mission right now. Please try again."))}finally{z(null)}}async function Z(s){const e=s.status==="active"?`/api/goals/${s.id}/archive`:`/api/goals/${s.id}/unarchive`;try{l(null);const i=await fetch(e,{method:"POST"});if(i.ok){const u=await i.json();f(p=>p.map(ss=>ss.id===u.id?u:ss));return}let o=null;try{o=await i.json()}catch{o=null}if(i.status===409&&ts(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(vs,{icon:xs,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:T})}),t.jsxs("button",{type:"button",className:"btn btn-primary goals-add-button",onClick:us,"data-testid":"goals-add-button",children:[t.jsx(js,{size:18,"aria-hidden":"true"}),a("goals.addGoal","Add Goal")]})]})}),t.jsxs("div",{className:"goals-view__content",children:[as?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:b,maxLength:200,onChange:s=>D(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 ms(),disabled:!b.trim()||k,"data-testid":"goals-form-draft-ai",children:[t.jsx(ws,{"aria-hidden":"true"}),k?a("goals.drafting","Drafting…"):a("goals.draftWithAi","Draft with AI")]})]}),t.jsx("textarea",{id:"goals-form-description",className:"input",value:P,maxLength:5e3,onChange:s=>j(s.target.value),"data-testid":"goals-form-description"}),F?t.jsx("p",{className:"form-error goals-error",role:"alert",children:F}):null,t.jsxs("div",{className:"goals-form-actions",children:[t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void hs(),disabled:U||k,"data-testid":"goals-form-submit",children:a("actions.save","Save")}),t.jsx("button",{type:"button",className:"btn",onClick:J,disabled:U||k,"data-testid":"goals-form-cancel",children:a("actions.cancel","Cancel")})]})]}):null,cs?t.jsx("p",{className:"goals-warning",role:"status",children:a("goals.capWarning","Approaching the 5-active goal cap. Keep active goals focused.")}):null,G?t.jsx("p",{className:"form-error goals-error",role:"alert","data-testid":"goals-error",children:G}):null,x?t.jsx("p",{className:"goals-loading",role:"status","data-testid":"goals-loading",children:a("goals.loading","Loading goals…")}):null,!x&&d.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,!x&&d.length>0?t.jsx("div",{className:"goals-list","data-testid":"goals-list",children:d.map(s=>t.jsxs("article",{id:`goal-card-${s.id}`,className:`card goals-card ${s.status==="archived"?"goals-card-archived":""} ${is===s.id?"goals-card--anchored":""}`.trim(),"data-testid":`goal-card-${s.id}`,children:[N===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:O,maxLength:200,onChange:e=>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:_,maxLength:5e3,onChange:e=>S(e.target.value),"data-testid":`goal-edit-description-${s.id}`}),V?t.jsx("p",{className:"form-error goals-error",role:"alert",children:V}):null,t.jsxs("div",{className:"goals-card-actions",children:[t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>void ps(),disabled:q,"data-testid":`goal-edit-save-${s.id}`,children:a("actions.save","Save")}),t.jsx("button",{type:"button",className:"btn",onClick:X,disabled:q,"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=fs(s.description),i=ns.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(Ns,{remarkPlugins:[Es],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:()=>bs(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:()=>gs(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 Z(s),"data-testid":`goal-archive-${s.id}`,children:a("goals.archive","Archive")}):t.jsx("button",{type:"button",className:"btn goals-activate-button",onClick:()=>void Z(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:y[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:$[s.id]??"",onChange:e=>H(i=>({...i,[s.id]:e.target.value})),"aria-label":a("goals.missionPicker","Mission to link"),disabled:C===s.id||Q(s.id).length===0,children:[t.jsx("option",{value:"",children:a("goals.selectMission","Select a mission")}),Q(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:!$[s.id]||C===s.id,onClick:()=>void ks(s.id),children:[t.jsx(Ss,{size:16,"aria-hidden":"true"}),C===s.id?a("goals.linkingMission","Linking…"):a("goals.linkMission","Link mission")]})]}),(y[s.id]?.length??0)>0?t.jsx("div",{className:"goals-linked-missions-list",children:(y[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:()=>es?.(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:ds===`${s.id}:${e.id}`,onClick:()=>void ys(s.id,e.id),children:t.jsx(Ms,{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{Os as GoalsView};
@@ -1,4 +1,4 @@
1
- import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{c as Le,ax as ce,ay as Se,az as ke,bA as Ce,bB as Ve,aC as je,bC as We,bD as qe,bE as Ye,bF as Qe,bG as Je,bH as Ze,bI as Me,bJ as es,bK as ss,bL as Ie,V as ts,S as A,bM as is,X as Ae,bN as me,R as N,a1 as ns,bO as as,f as ze,p as le,bP as Ne,bs as rs,P as _e,ai as cs,b8 as De,bQ as ls}from"./index-CZcWjLAb.js";import{u as Pe}from"./vendor-i18n-GF3RlKbq.js";import{U as Ee}from"./users-yAd09tKP.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
1
+ import{r as c,j as e}from"./vendor-react-SZ_qB27O.js";import{c as Le,ax as ce,ay as Se,az as ke,bA as Ce,bB as Ve,aC as je,bC as We,bD as qe,bE as Ye,bF as Qe,bG as Je,bH as Ze,bI as Me,bJ as es,bK as ss,bL as Ie,V as ts,S as A,bM as is,X as Ae,bN as me,R as N,a1 as ns,bO as as,f as ze,p as le,bP as Ne,bs as rs,P as _e,ai as cs,b8 as De,bQ as ls}from"./index-ccFe_1av.js";import{u as Pe}from"./vendor-i18n-GF3RlKbq.js";import{U as Ee}from"./users-C_BA3C7E.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,2 +1,2 @@
1
- import{r,j as e}from"./vendor-react-SZ_qB27O.js";import{u as Re}from"./SettingsModal-Bq_3AbaB.js";import{aR as Me,aS as we,aT as qe,aU as Te,aV as Pe,aW as We,aX as He,aY as Ae,aZ as Fe,a_ as _e,a$ as Ue,b0 as Oe,b1 as De,b2 as Qe,aQ as $e,b3 as Be,V as Ve,b4 as Ye,L as F,b5 as ze}from"./index-CZcWjLAb.js";import{u as Ge}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const B=".fusion/memory/MEMORY.md",Ze=5e4,Xe="0 3 * * *",Ke="0 4 * * *";function ge(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??Ze,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??Xe,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??Ke}}function Le(i,t){return i.some(h=>h.path===t)?t:i.find(h=>h.path===B)?.path??i[0]?.path??B}function Je(i={}){const{projectId:t}=i,[h,s]=r.useState(""),[u,S]=r.useState(!0),[k,I]=r.useState(!1),[D,j]=r.useState(!1),[p,E]=r.useState(null),[n,M]=r.useState(!0),[V,_]=r.useState(!1),[re,U]=r.useState(()=>ge({})),[w,Y]=r.useState(!0),[z,me]=r.useState(!1),[be,O]=r.useState([]),[d,x]=r.useState(!0),[f,A]=r.useState(B),[o,v]=r.useState(""),[ne,R]=r.useState(!1),[c,N]=r.useState(!1),[pe,G]=r.useState(!1),[ie,Z]=r.useState(!1),[le,X]=r.useState(!1),[K,Q]=r.useState(null),[L,$]=r.useState(!0),[xe,q]=r.useState(!1),[fe,J]=r.useState(!1),[oe,ee]=r.useState(null),{status:ce,loading:de,refresh:se}=Re({projectId:t}),te=r.useCallback(m=>{v(m),N(!0)},[]),g=r.useCallback(async m=>{R(!0);try{const{content:l}=await Me(m,t);A(m),v(l),N(!1)}finally{R(!1)}},[t]),T=r.useCallback(async()=>{x(!0);try{const{files:m}=await we(t);if(O(m),m.length===0){A(B),v(""),N(!1);return}const l=Le(m,f);l!==f&&await g(l)}finally{x(!1)}},[t,f,g]);r.useEffect(()=>{let m=!1;async function l(){try{const y=await Qe(t);m||(s(y.content),S(!1))}catch{m||(s(""),S(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Fe(t);m||(E(y.content),_(y.exists),M(!1))}catch{m||(E(null),_(!1),M(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){Y(!0);try{const y=await $e(t);m||U(ge(y))}catch{m||U(ge({}))}finally{m||Y(!1)}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){x(!0);try{const{files:y}=await we(t);if(m)return;if(O(y),y.length===0){A(B),v(""),N(!1);return}const H=Le(y,f),{content:a}=await Me(H,t);if(m)return;A(H),v(a),N(!1)}catch{m||(O([]),A(B),v(""),N(!1))}finally{m||x(!1)}}return l(),()=>{m=!0}},[t,f]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Ae(t);m||(Q(y),$(!1))}catch{m||(Q(null),$(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Be(t);m||ee(y)}catch{m||ee(null)}}return l(),()=>{m=!0}},[t]);const P=r.useCallback(m=>{s(m),I(!0)},[]),Se=r.useCallback(async()=>{if(k){j(!0);try{await qe(h,t),I(!1)}finally{j(!1)}}},[h,k,t]),ye=r.useCallback(async m=>{me(!0);try{const l=await Te(m,t);U(ge(l))}finally{me(!1)}},[t]),he=r.useCallback(async m=>{await g(m)},[g]),je=r.useCallback(async()=>{if(c){G(!0);try{await Pe(f,o,t),N(!1),await T()}finally{G(!1)}}},[o,c,f,t,T]),ve=r.useCallback(async()=>{J(!0);try{const m=await We(t);return await se(),m}finally{J(!1)}},[t,se]),Ne=r.useCallback(async m=>He(m,t),[t]),ae=r.useCallback(async()=>{try{const m=await Ae(t);Q(m)}catch{Q(null)}},[t]),W=r.useCallback(async()=>{try{const m=await Fe(t);E(m.content),_(m.exists)}catch{E(null),_(!1)}},[t]),Ce=r.useCallback(async m=>{await _e(m,t),await W()},[t,W]),ke=r.useCallback(async()=>{Z(!0);try{const m=await Ue(t);return await Promise.all([W(),ae()]),{success:m.success,summary:m.summary}}finally{Z(!1)}},[t,W,ae]),ue=r.useCallback(async()=>{X(!0);try{return await Oe(t)}finally{X(!1)}},[t]),Ee=r.useCallback(async m=>{q(!0);try{const l=m?await De(m,t):await De(t);if(m){const y=l.path??m;A(y),v(l.content),N(!1),await T();return}s(l.content),I(!0)}finally{q(!1)}},[t,T]);return{workingMemory:h,workingMemoryLoading:u,workingMemoryDirty:k,setWorkingMemory:P,saveWorkingMemory:Se,savingWorkingMemory:D,insightsContent:p,insightsLoading:n,insightsExists:V,refreshInsights:W,saveInsights:Ce,memorySettings:re,settingsLoading:w,savingMemorySettings:z,saveMemorySettings:ye,memoryFiles:be,memoryFilesLoading:d,selectedFilePath:f,selectedFileContent:o,selectedFileLoading:ne,selectedFileDirty:c,setSelectedFileContent:te,selectFile:he,saveSelectedFile:je,savingSelectedFile:pe,reloadMemoryFiles:T,backendStatus:ce,backendLoading:de,extractInsights:ke,extracting:ie,triggerDreamNow:ue,dreamRunning:le,auditReport:K,auditLoading:L,refreshAudit:ae,compactMemory:Ee,compacting:xe,installQmdAction:ve,installingQmd:fe,testRetrieval:Ne,stats:oe}}const es={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},ss=72;function ts(i,t){if(i.length<=t)return i;const h=Math.max(1,t-1),s=Math.ceil(h/2),u=Math.floor(h/2);return`${i.slice(0,s)}…${i.slice(i.length-u)}`}function as(i){const t=`${i.label} — ${i.path}`;return ts(t,ss)}function rs(i){if(!i)return[];const t=[],h=i.split(/(?=^## )/m);for(const s of h){const u=s.trim();if(!u)continue;const S=u.match(/^##\s+(.+?)(\n|$)/);if(S){const k=S[1].trim(),I=es[k]??k.toLowerCase(),D=u.slice(S[0].length).trim(),j=D.split(`
1
+ import{r,j as e}from"./vendor-react-SZ_qB27O.js";import{u as Re}from"./SettingsModal-4d_p8D7W.js";import{aR as Me,aS as we,aT as qe,aU as Te,aV as Pe,aW as We,aX as He,aY as Ae,aZ as Fe,a_ as _e,a$ as Ue,b0 as Oe,b1 as De,b2 as Qe,aQ as $e,b3 as Be,V as Ve,b4 as Ye,L as F,b5 as ze}from"./index-ccFe_1av.js";import{u as Ge}from"./vendor-i18n-GF3RlKbq.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";const B=".fusion/memory/MEMORY.md",Ze=5e4,Xe="0 3 * * *",Ke="0 4 * * *";function ge(i){return{memoryEnabled:i.memoryEnabled!==!1,memoryAutoSummarizeEnabled:i.memoryAutoSummarizeEnabled??!1,memoryAutoSummarizeThresholdChars:i.memoryAutoSummarizeThresholdChars??Ze,memoryAutoSummarizeSchedule:i.memoryAutoSummarizeSchedule??Xe,memoryDreamsEnabled:i.memoryDreamsEnabled??!1,memoryDreamsSchedule:i.memoryDreamsSchedule??Ke}}function Le(i,t){return i.some(h=>h.path===t)?t:i.find(h=>h.path===B)?.path??i[0]?.path??B}function Je(i={}){const{projectId:t}=i,[h,s]=r.useState(""),[u,S]=r.useState(!0),[k,I]=r.useState(!1),[D,j]=r.useState(!1),[p,E]=r.useState(null),[n,M]=r.useState(!0),[V,_]=r.useState(!1),[re,U]=r.useState(()=>ge({})),[w,Y]=r.useState(!0),[z,me]=r.useState(!1),[be,O]=r.useState([]),[d,x]=r.useState(!0),[f,A]=r.useState(B),[o,v]=r.useState(""),[ne,R]=r.useState(!1),[c,N]=r.useState(!1),[pe,G]=r.useState(!1),[ie,Z]=r.useState(!1),[le,X]=r.useState(!1),[K,Q]=r.useState(null),[L,$]=r.useState(!0),[xe,q]=r.useState(!1),[fe,J]=r.useState(!1),[oe,ee]=r.useState(null),{status:ce,loading:de,refresh:se}=Re({projectId:t}),te=r.useCallback(m=>{v(m),N(!0)},[]),g=r.useCallback(async m=>{R(!0);try{const{content:l}=await Me(m,t);A(m),v(l),N(!1)}finally{R(!1)}},[t]),T=r.useCallback(async()=>{x(!0);try{const{files:m}=await we(t);if(O(m),m.length===0){A(B),v(""),N(!1);return}const l=Le(m,f);l!==f&&await g(l)}finally{x(!1)}},[t,f,g]);r.useEffect(()=>{let m=!1;async function l(){try{const y=await Qe(t);m||(s(y.content),S(!1))}catch{m||(s(""),S(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Fe(t);m||(E(y.content),_(y.exists),M(!1))}catch{m||(E(null),_(!1),M(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){Y(!0);try{const y=await $e(t);m||U(ge(y))}catch{m||U(ge({}))}finally{m||Y(!1)}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){x(!0);try{const{files:y}=await we(t);if(m)return;if(O(y),y.length===0){A(B),v(""),N(!1);return}const H=Le(y,f),{content:a}=await Me(H,t);if(m)return;A(H),v(a),N(!1)}catch{m||(O([]),A(B),v(""),N(!1))}finally{m||x(!1)}}return l(),()=>{m=!0}},[t,f]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Ae(t);m||(Q(y),$(!1))}catch{m||(Q(null),$(!1))}}return l(),()=>{m=!0}},[t]),r.useEffect(()=>{let m=!1;async function l(){try{const y=await Be(t);m||ee(y)}catch{m||ee(null)}}return l(),()=>{m=!0}},[t]);const P=r.useCallback(m=>{s(m),I(!0)},[]),Se=r.useCallback(async()=>{if(k){j(!0);try{await qe(h,t),I(!1)}finally{j(!1)}}},[h,k,t]),ye=r.useCallback(async m=>{me(!0);try{const l=await Te(m,t);U(ge(l))}finally{me(!1)}},[t]),he=r.useCallback(async m=>{await g(m)},[g]),je=r.useCallback(async()=>{if(c){G(!0);try{await Pe(f,o,t),N(!1),await T()}finally{G(!1)}}},[o,c,f,t,T]),ve=r.useCallback(async()=>{J(!0);try{const m=await We(t);return await se(),m}finally{J(!1)}},[t,se]),Ne=r.useCallback(async m=>He(m,t),[t]),ae=r.useCallback(async()=>{try{const m=await Ae(t);Q(m)}catch{Q(null)}},[t]),W=r.useCallback(async()=>{try{const m=await Fe(t);E(m.content),_(m.exists)}catch{E(null),_(!1)}},[t]),Ce=r.useCallback(async m=>{await _e(m,t),await W()},[t,W]),ke=r.useCallback(async()=>{Z(!0);try{const m=await Ue(t);return await Promise.all([W(),ae()]),{success:m.success,summary:m.summary}}finally{Z(!1)}},[t,W,ae]),ue=r.useCallback(async()=>{X(!0);try{return await Oe(t)}finally{X(!1)}},[t]),Ee=r.useCallback(async m=>{q(!0);try{const l=m?await De(m,t):await De(t);if(m){const y=l.path??m;A(y),v(l.content),N(!1),await T();return}s(l.content),I(!0)}finally{q(!1)}},[t,T]);return{workingMemory:h,workingMemoryLoading:u,workingMemoryDirty:k,setWorkingMemory:P,saveWorkingMemory:Se,savingWorkingMemory:D,insightsContent:p,insightsLoading:n,insightsExists:V,refreshInsights:W,saveInsights:Ce,memorySettings:re,settingsLoading:w,savingMemorySettings:z,saveMemorySettings:ye,memoryFiles:be,memoryFilesLoading:d,selectedFilePath:f,selectedFileContent:o,selectedFileLoading:ne,selectedFileDirty:c,setSelectedFileContent:te,selectFile:he,saveSelectedFile:je,savingSelectedFile:pe,reloadMemoryFiles:T,backendStatus:ce,backendLoading:de,extractInsights:ke,extracting:ie,triggerDreamNow:ue,dreamRunning:le,auditReport:K,auditLoading:L,refreshAudit:ae,compactMemory:Ee,compacting:xe,installQmdAction:ve,installingQmd:fe,testRetrieval:Ne,stats:oe}}const es={Patterns:"pattern",Principles:"principle",Conventions:"convention",Pitfalls:"pitfall",Context:"context"},ss=72;function ts(i,t){if(i.length<=t)return i;const h=Math.max(1,t-1),s=Math.ceil(h/2),u=Math.floor(h/2);return`${i.slice(0,s)}…${i.slice(i.length-u)}`}function as(i){const t=`${i.label} — ${i.path}`;return ts(t,ss)}function rs(i){if(!i)return[];const t=[],h=i.split(/(?=^## )/m);for(const s of h){const u=s.trim();if(!u)continue;const S=u.match(/^##\s+(.+?)(\n|$)/);if(S){const k=S[1].trim(),I=es[k]??k.toLowerCase(),D=u.slice(S[0].length).trim(),j=D.split(`
2
2
  `).map(p=>p.replace(/^-\s+/,"").trim()).filter(p=>p.length>0&&(p.startsWith("- ")||p.startsWith("* ")));(j.length>0||D.length>0)&&t.push({name:k,key:I,items:j.length>0?j:D.length>0?[D]:[],expanded:!0})}}return t}function ms(i){if(!i)return null;const t=i.match(/##\s+Last\s+Updated:\s*(\d{4}-\d{2}-\d{2})/i);return t?t[1]:null}function ns(i){return i.reduce((t,h)=>t+h.items.length,0)}function us({projectId:i,addToast:t,onSendSelectionToTask:h}){const{t:s}=Ge("app"),[u,S]=r.useState("working"),[k,I]=r.useState(new Set),[D,j]=r.useState(!1),[p,E]=r.useState(null),[n,M]=r.useState({memoryEnabled:!0,memoryAutoSummarizeEnabled:!1,memoryAutoSummarizeThresholdChars:5e4,memoryAutoSummarizeSchedule:"0 3 * * *",memoryDreamsEnabled:!1,memoryDreamsSchedule:"0 4 * * *"}),[V,_]=r.useState(""),[re,U]=r.useState(!1),[w,Y]=r.useState(null),{insightsContent:z,insightsLoading:me,insightsExists:be,saveInsights:O,memorySettings:d,settingsLoading:x,saveMemorySettings:f,savingMemorySettings:A,backendStatus:o,backendLoading:v,extractInsights:ne,extracting:R,auditReport:c,auditLoading:N,refreshAudit:pe,compactMemory:G,compacting:ie,installQmdAction:Z,installingQmd:le,testRetrieval:X,memoryFiles:K,memoryFilesLoading:Q,selectedFilePath:L,selectedFileContent:$,selectedFileLoading:xe,selectedFileDirty:q,setSelectedFileContent:fe,selectFile:J,saveSelectedFile:oe,savingSelectedFile:ee,reloadMemoryFiles:ce,triggerDreamNow:de,dreamRunning:se}=Je({projectId:i});r.useEffect(()=>{M(d)},[d]);const te=r.useMemo(()=>n.memoryEnabled!==d.memoryEnabled||n.memoryAutoSummarizeEnabled!==d.memoryAutoSummarizeEnabled||n.memoryAutoSummarizeThresholdChars!==d.memoryAutoSummarizeThresholdChars||n.memoryAutoSummarizeSchedule!==d.memoryAutoSummarizeSchedule||n.memoryDreamsEnabled!==d.memoryDreamsEnabled||n.memoryDreamsSchedule!==d.memoryDreamsSchedule,[n,d]),g=r.useMemo(()=>K.find(a=>a.path===L),[K,L]),T=g?g.layer==="long-term"?s("memory.layerDescLongTerm","Curated durable decisions, conventions, constraints, and pitfalls promoted from dreams."):g.layer==="daily"?s("memory.layerDescDaily","Raw daily observations, open loops, and running context for dream processing."):s("memory.layerDescDreams","Synthesized patterns and open loops promoted from daily memory."):s("memory.editorDefaultDescription","Edits the selected memory file."),P=r.useMemo(()=>rs(z),[z]),Se=r.useMemo(()=>ns(P),[P]),ye=r.useMemo(()=>ms(z),[z]),he=r.useCallback(a=>{I(b=>{const C=new Set(b);return C.has(a)?C.delete(a):C.add(a),C})},[]),je=r.useCallback(async a=>{try{await J(a)}catch{t(s("memory.loadFileFailed","Failed to load memory file"),"error")}},[J,t]),ve=r.useCallback(async()=>{try{await oe(),t(s("memory.memorySaved","Memory saved"),"success")}catch{t(s("memory.saveMemoryFailed","Failed to save memory"),"error")}},[oe,t]),Ne=r.useCallback(async()=>{if(!te)return;const a={};n.memoryEnabled!==d.memoryEnabled&&(a.memoryEnabled=n.memoryEnabled),n.memoryAutoSummarizeEnabled!==d.memoryAutoSummarizeEnabled&&(a.memoryAutoSummarizeEnabled=n.memoryAutoSummarizeEnabled),n.memoryAutoSummarizeThresholdChars!==d.memoryAutoSummarizeThresholdChars&&(a.memoryAutoSummarizeThresholdChars=n.memoryAutoSummarizeThresholdChars),n.memoryAutoSummarizeSchedule!==d.memoryAutoSummarizeSchedule&&(a.memoryAutoSummarizeSchedule=n.memoryAutoSummarizeSchedule),n.memoryDreamsEnabled!==d.memoryDreamsEnabled&&(a.memoryDreamsEnabled=n.memoryDreamsEnabled),n.memoryDreamsSchedule!==d.memoryDreamsSchedule&&(a.memoryDreamsSchedule=n.memoryDreamsSchedule);try{await f(a),t(s("memory.settingsSaved","Memory settings saved"),"success")}catch{t(s("memory.saveSettingsFailed","Failed to save memory settings"),"error")}},[te,n,d,f,t]),ae=r.useCallback(async()=>{try{const a=await Z();t(a.qmdAvailable?s("memory.qmdInstallSuccess","qmd installed successfully"):s("memory.qmdInstallUnavailable","qmd install finished, but qmd is still unavailable"),a.qmdAvailable?"success":"info")}catch{t(s("memory.installQmdFailed","Failed to install qmd"),"error")}},[Z,t]),W=r.useCallback(async()=>{U(!0),Y(null);try{const a=await X(V);Y(a),t(a.qmdAvailable?s("memory.retrievalTestComplete","Memory retrieval test complete"):s("memory.retrievalTestFallback","qmd is not installed; local fallback was used"),a.qmdAvailable?"success":"info")}catch{t(s("memory.retrievalTestFailed","Failed to test memory retrieval"),"error")}finally{U(!1)}},[V,X,t]),Ce=r.useCallback(async()=>{try{await de(),t(s("memory.dreamProcessingComplete","Dream processing completed"),"success"),await ce()}catch(a){t(a instanceof Error?a.message:s("memory.dreamProcessingFailed","Failed to run dream processing"),"error")}},[de,ce,t]),ke=r.useCallback(async()=>{try{await G(L),t(s("memory.fileCompacted","Memory file compacted"),"success")}catch{t(s("memory.compactFailed","Failed to compact memory"),"error")}},[G,L,t]),ue=r.useCallback(async()=>{try{const a=await ne();t(a.summary,"success")}catch(a){t(a instanceof Error?a.message:s("memory.extractInsightsFailed","Failed to extract insights"),"error")}},[ne,t]),Ee=r.useCallback(async()=>{if(p!==null)try{await O(p),j(!1),E(null),t(s("memory.insightsSaved","Insights saved"),"success")}catch{t(s("memory.saveInsightsFailed","Failed to save insights"),"error")}},[p,O,t]),m=r.useCallback(()=>{E(z??""),j(!0)},[z]),l=r.useCallback(()=>{j(!1),E(null)},[]),y=!v&&o!==null,H=o?.capabilities?.writable??!1;return e.jsxs("div",{className:"memory-view",children:[e.jsx(Ve,{icon:Ye,title:s("memory.title","Memory")}),e.jsxs("div",{className:"memory-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":u==="working",className:`memory-view-tab${u==="working"?" memory-view-tab--active":""}`,onClick:()=>S("working"),"data-testid":"memory-tab-working",children:s("memory.tabWorking","Working Memory")}),e.jsx("button",{type:"button",role:"tab","aria-selected":u==="insights",className:`memory-view-tab${u==="insights"?" memory-view-tab--active":""}`,onClick:()=>S("insights"),"data-testid":"memory-tab-insights",children:s("memory.tabInsights","Insights")}),e.jsx("button",{type:"button",role:"tab","aria-selected":u==="engines",className:`memory-view-tab${u==="engines"?" memory-view-tab--active":""}`,onClick:()=>S("engines"),"data-testid":"memory-tab-engines",children:s("memory.tabEngines","Engines")})]}),e.jsxs("div",{className:"memory-view-content",children:[u==="working"&&e.jsxs("div",{className:"memory-working-tab",children:[y&&!H&&e.jsx("div",{className:"memory-readonly-banner",children:s("memory.readOnlyBanner","This memory backend is read-only. Changes cannot be saved.")}),Q||xe?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(F,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingFile","Loading memory file…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-editor-section",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryViewFilePath",children:s("memory.fileLabel","Memory File")}),e.jsx("select",{id:"memoryViewFilePath",className:"select",value:L,onChange:a=>{je(a.target.value)},disabled:q,children:K.map(a=>e.jsx("option",{value:a.path,title:`${a.label} — ${a.path}`,children:as(a)},a.path))}),e.jsx("small",{children:q?s("memory.fileSwitchDirtyHint","Save or discard the current edits before switching files."):s("memory.fileSwitchHint","Choose any project memory file to view or edit.")})]}),g&&e.jsxs("div",{className:"memory-file-summary",children:[e.jsx("span",{children:g.layer==="long-term"?s("memory.layerLongTerm","Long-term"):g.layer==="daily"?s("memory.layerDaily","Daily"):s("memory.layerDreams","Dreams")}),e.jsx("strong",{children:g.path}),e.jsx("small",{children:s("memory.fileSummary","{{size}} bytes · updated {{updatedAt}}",{size:g.size.toLocaleString(),updatedAt:new Date(g.updatedAt).toLocaleString()})})]}),e.jsxs("div",{className:"form-group memory-editor-form-group",children:[e.jsx("label",{children:g?.label||s("memory.editorLabel","Memory Editor")}),e.jsx("small",{children:T}),e.jsx("div",{className:"memory-editor-container",children:e.jsx(ze,{content:$,onChange:fe,readOnly:!H,filePath:L,onSendSelectionToTask:h})})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("span",{className:"memory-char-count",children:s("memory.charCount","{{count}} characters",{count:$.length})}),e.jsx("div",{className:"memory-flex-spacer"}),H&&$.length>0&&e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ke,disabled:ie||q,children:ie?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.compacting","Compacting…")]}):s("memory.compactSelectedFile","Compact Selected File")}),q&&H&&e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:ve,disabled:ee,children:ee?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.saving","Saving…")]}):s("memory.save","Save")})]}),e.jsxs("div",{className:"memory-config-section",children:[e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"memoryDreamsEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryDreamsEnabled",type:"checkbox",checked:n.memoryDreamsEnabled,onChange:a=>{M(b=>({...b,memoryDreamsEnabled:a.target.checked}))},disabled:!n.memoryEnabled||x}),s("memory.dreamsEnabledLabel","Process dreams from daily memory")]}),e.jsx("small",{children:s("memory.dreamsEnabledHint","Turns daily notes into DREAMS.md and promotes reusable lessons into MEMORY.md.")})]}),n.memoryEnabled&&n.memoryDreamsEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryDreamsSchedule",children:s("memory.dreamsScheduleLabel","Dream Schedule")}),e.jsx("input",{id:"memoryDreamsSchedule",type:"text",className:"input",value:n.memoryDreamsSchedule,onChange:a=>{M(b=>({...b,memoryDreamsSchedule:a.target.value}))},placeholder:"0 4 * * *",disabled:x}),e.jsx("small",{children:s("memory.dreamsScheduleHint","Cron expression for dream processing.")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("button",{type:"button",className:"btn btn-sm",onClick:Ce,disabled:se||!n.memoryDreamsEnabled,children:se?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.dreaming","Dreaming…")]}):s("memory.dreamNow","Dream Now")}),e.jsx("small",{children:s("memory.dreamNowHint","Manually trigger dream processing now.")})]})]})]}),e.jsxs("div",{className:"memory-settings-group",children:[e.jsxs("div",{className:"form-group",children:[e.jsxs("label",{htmlFor:"memoryAutoSummarizeEnabled",className:"checkbox-label",children:[e.jsx("input",{id:"memoryAutoSummarizeEnabled",type:"checkbox",checked:n.memoryAutoSummarizeEnabled,onChange:a=>{M(b=>({...b,memoryAutoSummarizeEnabled:a.target.checked}))},disabled:!n.memoryEnabled||x}),s("memory.autoSummarizeLabel","Auto-Summarize Memory")]}),e.jsx("small",{children:s("memory.autoSummarizeHint","Automatically compact memory when it exceeds the threshold on a schedule")})]}),n.memoryEnabled&&n.memoryAutoSummarizeEnabled&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeThresholdChars",children:s("memory.compactionThresholdLabel","Compaction Threshold (chars)")}),e.jsx("input",{id:"memoryAutoSummarizeThresholdChars",type:"number",className:"input",value:n.memoryAutoSummarizeThresholdChars,onChange:a=>{M(b=>({...b,memoryAutoSummarizeThresholdChars:parseInt(a.target.value,10)||5e4}))},min:1e3,disabled:x}),e.jsx("small",{children:s("memory.compactionThresholdHint","Memory will be compacted when it exceeds this character count")})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{htmlFor:"memoryAutoSummarizeSchedule",children:s("memory.autoSummarizeScheduleLabel","Schedule (cron)")}),e.jsx("input",{id:"memoryAutoSummarizeSchedule",type:"text",className:"input",value:n.memoryAutoSummarizeSchedule,onChange:a=>{M(b=>({...b,memoryAutoSummarizeSchedule:a.target.value}))},placeholder:"0 3 * * *",disabled:x}),e.jsx("small",{children:s("memory.autoSummarizeScheduleHint","Cron expression for auto-summarize schedule (default: daily at 3 AM)")})]})]})]}),!n.memoryEnabled&&e.jsx("div",{className:"settings-empty-state memory-status-message",children:s("memory.disabledMessage","Memory is currently disabled. Enable memory tools in Settings to edit these automations.")}),te&&e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ne,disabled:A||x,children:A?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.saving","Saving…")]}):s("memory.saveSettings","Save Settings")})})]})]})]}),u==="insights"&&e.jsx("div",{className:"memory-insights-tab",children:me?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(F,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingInsights","Loading insights…")})]}):D?e.jsxs("div",{className:"memory-insights-editor-layout",children:[e.jsx("div",{className:"memory-editor-container",children:e.jsx(ze,{content:p??"",onChange:E,readOnly:!1,filePath:".fusion/memory/INSIGHTS.md",onSendSelectionToTask:h})}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:l,children:s("memory.cancel","Cancel")}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:Ee,children:s("memory.saveInsights","Save Insights")})]})]}):!be||P.length===0?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx("p",{children:s("memory.noInsights","No insights extracted yet.")}),e.jsx("p",{children:s("memory.noInsightsHint",'Insights are automatically extracted from working memory. Click "Extract Now" to trigger extraction manually.')}),e.jsx("button",{type:"button",className:"btn btn-primary btn-sm memory-empty-extract-button",onClick:ue,disabled:R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.extracting","Extracting…")]}):s("memory.extractNow","Extract Now")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-stats-row",children:[e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:Se}),e.jsx("div",{className:"memory-stat-label",children:s("memory.totalInsights","Total Insights")})]}),e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value",children:P.length}),e.jsx("div",{className:"memory-stat-label",children:s("memory.categories","Categories")})]}),ye&&e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-value memory-stat-value--updated",children:ye}),e.jsx("div",{className:"memory-stat-label",children:s("memory.lastUpdated","Last Updated")})]})]}),e.jsxs("div",{className:"memory-action-bar",children:[e.jsx("button",{type:"button",className:"btn btn-primary btn-sm",onClick:ue,disabled:R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(F,{size:14,className:"animate-spin"}),s("memory.extracting","Extracting…")]}):s("memory.extractNow","Extract Now")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:m,children:s("memory.editRaw","Edit Raw")})]}),e.jsx("div",{className:"memory-categories-list",children:P.map(a=>{const b=!k.has(a.key);return e.jsxs("div",{className:"memory-category-section",children:[e.jsxs("div",{className:"memory-category-header",onClick:()=>he(a.key),role:"button",tabIndex:0,onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),he(a.key))},children:[e.jsx("h4",{children:a.name}),e.jsx("span",{className:"memory-category-count",children:a.items.length})]}),b&&e.jsx("div",{className:"memory-category-items",children:a.items.map((C,Ie)=>e.jsx("div",{className:"memory-insight-item",children:C.replace(/^-\s+/,"").replace(/^\*\s+/,"")},Ie))})]},a.key)})})]})}),u==="engines"&&e.jsx("div",{className:"memory-engines-tab",children:v||N?e.jsxs("div",{className:"memory-empty-state",children:[e.jsx(F,{size:20,className:"animate-spin"}),e.jsx("span",{children:s("memory.loadingEngineStatus","Loading engine status…")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"memory-engine-card memory-qmd-card",children:[e.jsx("h3",{children:s("memory.qmdIntegrationTitle","QMD Integration")}),o?.qmdAvailable===!0?e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge memory-health-badge--healthy",children:s("memory.qmdInstalled","Installed")}),e.jsx("span",{className:"memory-char-count",children:s("memory.qmdAvailableOnPath","qmd is available on PATH.")})]}):o?.qmdAvailable===!1?e.jsxs("div",{className:"settings-empty-state memory-status-message",children:[e.jsxs("span",{children:[s("memory.qmdNotInstalled","qmd is not installed. Search will use local files. Install indexed retrieval:")," ",e.jsx("code",{children:o.qmdInstallCommand||"bun install -g @tobilu/qmd"})]}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:ae,disabled:le,children:le?s("memory.installing","Installing…"):s("memory.installQmd","Install qmd")})]}):e.jsxs("div",{className:"memory-engine-status",children:[e.jsx("span",{className:"memory-health-badge",children:s("memory.qmdChecking","Checking")}),e.jsx("span",{className:"memory-char-count",children:s("memory.qmdCheckingAvailability","Checking qmd availability…")})]}),e.jsxs("div",{className:"memory-capability-row",children:[o?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capReadable","Readable")}),o?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capWritable","Writable")}),o?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capAtomicWrites","Atomic Writes")}),o?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capPersistent","Persistent")})]})]}),e.jsxs("div",{className:"memory-engine-card memory-retrieval-card",children:[e.jsx("h3",{children:s("memory.testMemorySearchTitle","Test Memory Search")}),e.jsxs("div",{className:"memory-retrieval-input-row",children:[e.jsx("input",{type:"text",className:"input",value:V,onChange:a=>_(a.target.value),placeholder:s("memory.searchPlaceholder","Search memory with qmd")}),e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:W,disabled:re,children:re?s("memory.testing","Testing…"):s("memory.testRetrieval","Test Retrieval")})]}),e.jsx("small",{className:"settings-muted",children:s("memory.testSearchHint","Runs the same qmd-backed memory_search path agents use.")}),w&&e.jsxs("div",{className:"memory-test-result",children:[e.jsx("strong",{children:s("memory.testResultCount",'{{count}} result for "{{query}}"',{count:w.results.length,query:w.query,defaultValue_one:'{{count}} result for "{{query}}"',defaultValue_other:'{{count}} results for "{{query}}"'})}),e.jsx("small",{children:s("memory.testResultStatus","qmd {{qmdStatus}} · {{fallbackStatus}}",{qmdStatus:w.qmdAvailable?s("memory.qmdStatusAvailable","available"):s("memory.qmdStatusMissing","missing"),fallbackStatus:w.usedFallback?s("memory.localFallbackUsed","local fallback used"):s("memory.qmdPathUsed","qmd path used")})}),w.results.length>0?e.jsx("ul",{children:w.results.map((a,b)=>e.jsxs("li",{children:[e.jsxs("span",{children:[a.path,":",a.lineStart]}),e.jsx("p",{children:a.snippet})]},`${a.path}-${a.lineStart}-${b}`))}):e.jsx("small",{children:s("memory.noMatchingMemory","No matching memory found.")})]})]}),e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:s("memory.currentBackendTitle","Current Backend")}),e.jsx("div",{className:"memory-engine-status",children:e.jsx("span",{className:"memory-emphasis-text",children:o?.currentBackend==="file"?s("memory.backendFile","File (.fusion/memory/, agent/<agent-name>/memory/)"):o?.currentBackend==="readonly"?s("memory.backendReadonly","Read-Only"):o?.currentBackend==="qmd"?s("memory.backendQmd","QMD (Quantized Memory Distillation)"):o?.currentBackend??"unknown"})}),e.jsxs("div",{className:"memory-capability-row",children:[o?.capabilities?.readable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capReadable","Readable")}),o?.capabilities?.writable&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capWritable","Writable")}),o?.capabilities?.supportsAtomicWrite&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capAtomicWrites","Atomic Writes")}),o?.capabilities?.persistent&&e.jsx("span",{className:"memory-capability-badge",children:s("memory.capPersistent","Persistent")})]})]}),c&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsxs("div",{className:"memory-health-header",children:[e.jsx("h3",{children:s("memory.healthStatusTitle","Health Status")}),e.jsx("span",{className:`memory-health-badge memory-health-badge--${c.health}`,children:c.health==="healthy"?s("memory.healthHealthy","Healthy"):c.health==="warning"?s("memory.healthWarning","Warning"):s("memory.healthIssues","Issues Found")})]}),e.jsxs("div",{className:"memory-health-grid",children:[e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:s("memory.workingMemoryLabel","Working Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:s("memory.sizeChars","{{size}} chars",{size:c.workingMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:s("memory.sectionCount","{{count}} sections",{count:c.workingMemory.sectionCount})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"memory-health-label",children:s("memory.insightsMemoryLabel","Insights Memory")}),e.jsx("div",{className:"memory-emphasis-text",children:s("memory.sizeChars","{{size}} chars",{size:c.insightsMemory.size})}),e.jsx("div",{className:"memory-health-detail",children:s("memory.insightCount","{{count}} insights",{count:c.insightsMemory.insightCount})})]})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:s("memory.lastExtractionLabel","Last Extraction")}),e.jsx("div",{className:"memory-emphasis-text",children:c.extraction.success?e.jsx("span",{className:"memory-status-text memory-status-text--success",children:s("memory.extractionSuccess","Success")}):e.jsx("span",{className:"memory-status-text memory-status-text--error",children:s("memory.extractionFailed","Failed")})}),e.jsx("div",{className:"memory-health-detail",children:c.extraction.summary||s("memory.insightsExtracted","{{count}} insights extracted",{count:c.extraction.insightCount})})]}),e.jsxs("div",{className:"memory-health-section",children:[e.jsx("div",{className:"memory-health-label",children:s("memory.pruningLabel","Pruning")}),e.jsx("div",{className:"memory-emphasis-text",children:c.pruning.applied?e.jsx("span",{className:"memory-status-text memory-status-text--warning",children:s("memory.pruningApplied","Applied")}):e.jsx("span",{className:"memory-status-text memory-status-text--muted",children:s("memory.pruningNotNeeded","Not needed")})}),c.pruning.applied&&e.jsx("div",{className:"memory-health-detail",children:c.pruning.reason})]})]}),c&&c.checks.length>0&&e.jsxs("div",{className:"memory-engine-card",children:[e.jsx("h3",{children:s("memory.auditChecksTitle","Audit Checks")}),e.jsx("div",{children:c.checks.map(a=>e.jsxs("div",{className:"memory-audit-check",children:[e.jsx("span",{className:a.passed?"memory-audit-check-passed":"memory-audit-check-failed",children:a.passed?"✓":"✗"}),e.jsxs("div",{className:"memory-audit-check-content",children:[e.jsx("div",{className:"memory-emphasis-text",children:a.name}),e.jsx("div",{className:"memory-health-detail",children:a.details})]})]},a.id))})]}),e.jsx("div",{className:"memory-action-bar",children:e.jsx("button",{type:"button",className:"btn btn-secondary btn-sm",onClick:()=>pe(),children:s("memory.runAudit","Run Audit")})}),e.jsxs("div",{className:"memory-settings-note",children:[e.jsx("span",{children:s("memory.settingsNote","Note: Change backend type in")}),e.jsx("button",{type:"button",className:"memory-settings-note-button",onClick:()=>{t(s("memory.settingsNoteToast","Open Settings → Memory to change backend type"),"info")},children:s("memory.settingsNoteLink","Settings → Memory")})]})]})})]})]})}export{us as MemoryView};
@@ -1,4 +1,4 @@
1
- import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as G,bu as Y,bv as Z,bw as T,R as L,ak as D,am as y,P as ee,n as se,C as ae,I as ie,aI as B,bx as ne,by as te,bz as I,X as re}from"./index-CZcWjLAb.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import{B as _}from"./AgentPermissionPolicyEditor-C5DR9dUS.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
1
+ import{r as l,j as e}from"./vendor-react-SZ_qB27O.js";import{c as G,bu as Y,bv as Z,bw as T,R as L,ak as D,am as y,P as ee,n as se,C as ae,I as ie,aI as B,bx as ne,by as te,bz as I,X as re}from"./index-ccFe_1av.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import{B as _}from"./AgentPermissionPolicyEditor-DE0wv8-L.js";import"./vendor-reactflow-Bg-Qjzh8.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.