adam-agent-server 1.17.0 → 1.18.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 (141) hide show
  1. package/dist/approval-handler-BWA7UIKN.js +1 -0
  2. package/dist/{artifacts-DMY2MI2F.js → artifacts-MAYKOTA2.js} +1 -1
  3. package/dist/audit-diagnostics-K3LUWXTI.js +1 -0
  4. package/dist/audit-manager-6WL2V6JG.js +1 -0
  5. package/dist/bree-engine-KYD4GKQK.js +1 -0
  6. package/dist/{channels-VYNJFXDD.js → channels-2TWTBE6Y.js} +1 -1
  7. package/dist/channels-PWDSTYNR.js +1 -0
  8. package/dist/{chat-tool-calls-WQGFYTUV.js → chat-tool-calls-WJDFQ54U.js} +1 -1
  9. package/dist/{chunk-P76VP2UH.js → chunk-2A2TXYT3.js} +5 -5
  10. package/dist/chunk-2CE2WUUZ.js +1 -0
  11. package/dist/{chunk-YEBC67DJ.js → chunk-2JIQT2CI.js} +1 -1
  12. package/dist/chunk-3MROEPGR.js +1 -0
  13. package/dist/{chunk-725BGAO2.js → chunk-3UFEOB6P.js} +1 -1
  14. package/dist/{chunk-VVBN35YG.js → chunk-47HJPIUA.js} +1 -1
  15. package/dist/{chunk-PBKZDNNV.js → chunk-4JHACUZY.js} +1 -1
  16. package/dist/{chunk-D5PAJ3CB.js → chunk-6WQFYV3N.js} +1 -1
  17. package/dist/{chunk-BRUHXRKK.js → chunk-AUSR5JYV.js} +1 -1
  18. package/dist/{chunk-ED2JAMEN.js → chunk-BE653A45.js} +1 -1
  19. package/dist/{chunk-3RITIMKB.js → chunk-BMCNQGUH.js} +1 -1
  20. package/dist/{chunk-32D5GWJD.js → chunk-HRPMRWHD.js} +1 -1
  21. package/dist/{chunk-QWIBCFPC.js → chunk-IEBAOZED.js} +2 -2
  22. package/dist/{chunk-OII5SDMS.js → chunk-JROGEBP5.js} +1 -1
  23. package/dist/{chunk-DCTNMUQ5.js → chunk-JYZTIE2J.js} +1 -1
  24. package/dist/{chunk-5WBFQMJL.js → chunk-JZBXLN7M.js} +1 -1
  25. package/dist/{chunk-A2S67EQG.js → chunk-KS24764D.js} +2 -2
  26. package/dist/{chunk-WDSCTXT7.js → chunk-LCD5DVS6.js} +1 -1
  27. package/dist/{chunk-3GK65T2V.js → chunk-LKGYQJMS.js} +1 -1
  28. package/dist/{chunk-FMJVKJJE.js → chunk-MTRLUW7Z.js} +1 -1
  29. package/dist/{chunk-3VUEB67V.js → chunk-NSUXJ2VA.js} +1 -1
  30. package/dist/{chunk-73GP6K5S.js → chunk-NUOTFUNF.js} +1 -1
  31. package/dist/chunk-NXGR3PRY.js +1 -0
  32. package/dist/{chunk-4WJ2VSEJ.js → chunk-O6L4UVLV.js} +1 -1
  33. package/dist/{chunk-UUJ24BNJ.js → chunk-OBD4245G.js} +1 -1
  34. package/dist/{chunk-TNBQFCXR.js → chunk-QTGAK62Z.js} +2 -2
  35. package/dist/{chunk-K3HWZBE5.js → chunk-QYI44EP6.js} +1 -1
  36. package/dist/{chunk-MQTK4Q6M.js → chunk-SGLZAIVL.js} +1 -1
  37. package/dist/chunk-SKHMWKJT.js +80 -0
  38. package/dist/{chunk-TO27F23C.js → chunk-T2Z2JDPY.js} +1 -1
  39. package/dist/chunk-TA5PFK5C.js +5 -0
  40. package/dist/{chunk-UAF4KNXE.js → chunk-TWOJVEO7.js} +2 -2
  41. package/dist/{chunk-NV5ZXKKF.js → chunk-UCUELFCS.js} +1 -1
  42. package/dist/{chunk-2WPUKCDA.js → chunk-V2MMQ3SH.js} +1 -1
  43. package/dist/{chunk-7IXYCDUF.js → chunk-VPMHZJS2.js} +1 -1
  44. package/dist/{chunk-3R7VGMAK.js → chunk-VWX2B6OM.js} +1 -1
  45. package/dist/{chunk-VARIYH6K.js → chunk-WY5BOCQP.js} +98 -37
  46. package/dist/{chunk-2RBYM3X7.js → chunk-XAPJJAJQ.js} +1 -1
  47. package/dist/{chunk-A57SY3E4.js → chunk-Z2APBKIT.js} +1 -1
  48. package/dist/chunk-ZJ3TS4FL.js +182 -0
  49. package/dist/{chunk-VSSKQAG5.js → chunk-ZQN6JZIJ.js} +1 -1
  50. package/dist/cli.js +1 -1
  51. package/dist/{config-ZDKMTZJC.js → config-U624HJKI.js} +1 -1
  52. package/dist/config-X7A6NA73.js +1 -0
  53. package/dist/{db-LIKGSZCL.js → db-XODNIJSJ.js} +1 -1
  54. package/dist/{delivery-log-2ILFP673.js → delivery-log-QMQQHES4.js} +1 -1
  55. package/dist/engine-OQXDHA2R.js +1 -0
  56. package/dist/{evolution-audit-BDQM6NAX.js → evolution-audit-XF4KZZMP.js} +1 -1
  57. package/dist/execution-tools-BR4T4MMW.js +1 -0
  58. package/dist/{external-api-7GB3U775.js → external-api-435WH6V3.js} +1 -1
  59. package/dist/index.js +65 -45
  60. package/dist/{learner-V2HBTRAE.js → learner-4CJ7BSCN.js} +1 -1
  61. package/dist/{memories-B3QGTYLX.js → memories-NJFKSOL5.js} +1 -1
  62. package/dist/{memory-extractor-RYZ3VU7A.js → memory-extractor-UQI75BBK.js} +1 -1
  63. package/dist/{memory-gc-5AYND3RL.js → memory-gc-NTZVUGJX.js} +1 -1
  64. package/dist/memory-service-3RLVOF2C.js +1 -0
  65. package/dist/outbound-gateway-NJNSN2ZX.js +1 -0
  66. package/dist/presets-SUJRFRJC.js +1 -0
  67. package/dist/{reflection-job-P6GIQVQN.js → reflection-job-F4BZA2E3.js} +1 -1
  68. package/dist/role-presets-VEYTGYA4.js +1 -0
  69. package/dist/role-workspace-AIVHPX5P.js +1 -0
  70. package/dist/{roles-B6YC4GDC.js → roles-WDMUBWQP.js} +1 -1
  71. package/dist/runtime-OMLPOMCA.js +1 -0
  72. package/dist/session-manager-XFUKWEC7.js +1 -0
  73. package/dist/skill-registry-LARMNUT5.js +1 -0
  74. package/dist/{task-templates-MNCF7JON.js → task-templates-BIVCRNXA.js} +1 -1
  75. package/dist/template-dispatch-6FPJQN6A.js +1 -0
  76. package/package.json +1 -1
  77. package/web/dist/assets/{ArtifactDetail-Dt_xkaYJ.js → ArtifactDetail-DDTEAl2E.js} +1 -1
  78. package/web/dist/assets/{Artifacts-DlPMk9VQ.js → Artifacts-BrhnC1Ef.js} +1 -1
  79. package/web/dist/assets/{ChannelDetail-kYtMmy6P.js → ChannelDetail-D0FBZoAX.js} +1 -1
  80. package/web/dist/assets/{Channels-BppR0Qc_.js → Channels-Cztxvsa2.js} +1 -1
  81. package/web/dist/assets/{Chat-BLVREMCu.js → Chat-Ce72TtUi.js} +2 -2
  82. package/web/dist/assets/Cost-K8-4xqBe.js +4 -0
  83. package/web/dist/assets/{Dashboard-XURc0f15.js → Dashboard-BXqFb_Vr.js} +1 -1
  84. package/web/dist/assets/{EnvVarEditor-DR-bSU0w.js → EnvVarEditor-FiiJazzp.js} +1 -1
  85. package/web/dist/assets/{EventDefDetail-DtkbGbQ0.js → EventDefDetail-C3S1G0K8.js} +1 -1
  86. package/web/dist/assets/{Events-C_J4jvDh.js → Events-BKxqZ9j6.js} +1 -1
  87. package/web/dist/assets/{Evolution-CEaSpRAm.js → Evolution-DFcSm6Rw.js} +1 -1
  88. package/web/dist/assets/{ExtensionDetail-D5Qfq-W4.js → ExtensionDetail-C8aPpyLv.js} +1 -1
  89. package/web/dist/assets/Extensions-MLZk05j0.js +1 -0
  90. package/web/dist/assets/{FeatureRequests-D8WEYtoU.js → FeatureRequests-D_4XaQ7F.js} +1 -1
  91. package/web/dist/assets/{GoalDetail-DnMS_WWw.js → GoalDetail-DVU7c0aR.js} +1 -1
  92. package/web/dist/assets/{Goals-BeKwpAss.js → Goals-D3h4WMjU.js} +1 -1
  93. package/web/dist/assets/LineChart-Ck1vfYHs.js +33 -0
  94. package/web/dist/assets/{Logs-BfXBv-dV.js → Logs-D5MQv6Yw.js} +1 -1
  95. package/web/dist/assets/{Memories-QRH7O8qP.js → Memories-Dls71I2i.js} +1 -1
  96. package/web/dist/assets/{Mistakes-mXU9PXft.js → Mistakes-BZcTg0vP.js} +1 -1
  97. package/web/dist/assets/{Plugins-C8v4AsvM.js → Plugins-CwCHGzI6.js} +1 -1
  98. package/web/dist/assets/RoleDetail-B2M6ALSl.js +3 -0
  99. package/web/dist/assets/{Roles-B8dQCKuS.js → Roles-FEHqm_Jf.js} +1 -1
  100. package/web/dist/assets/Settings-rdVQMfqX.js +1 -0
  101. package/web/dist/assets/{Strategies-DFUWEKfU.js → Strategies-CwJ9JQ-X.js} +1 -1
  102. package/web/dist/assets/{Switch-BcS5rOWb.js → Switch-1JjR4Imr.js} +1 -1
  103. package/web/dist/assets/{TaskDetail-BdhBhvKg.js → TaskDetail-h12WxjfG.js} +1 -1
  104. package/web/dist/assets/{Work-D-t80Ekv.js → Work-CfzFRSZX.js} +1 -1
  105. package/web/dist/assets/api-BP4ZP9kk.js +1 -0
  106. package/web/dist/assets/index-CXEJd-0s.js +12 -0
  107. package/web/dist/assets/index-CarTGiGO.css +2 -0
  108. package/web/dist/assets/{usePluginsWithUsage-DE13JW16.js → usePluginsWithUsage-4iLJAPjH.js} +1 -1
  109. package/web/dist/index.html +3 -3
  110. package/dist/approval-handler-FONN2EGB.js +0 -1
  111. package/dist/audit-diagnostics-D4M4SA5O.js +0 -1
  112. package/dist/audit-manager-YEOJRE6K.js +0 -1
  113. package/dist/bree-engine-RGTBKKFE.js +0 -1
  114. package/dist/channels-WFU4CVGW.js +0 -1
  115. package/dist/chunk-2V2H5PG5.js +0 -182
  116. package/dist/chunk-4G2OZPP5.js +0 -1
  117. package/dist/chunk-CFPXWGFD.js +0 -1
  118. package/dist/chunk-FJ3DUJXO.js +0 -1
  119. package/dist/chunk-OH6VBBDV.js +0 -1
  120. package/dist/chunk-SJTIMT5U.js +0 -5
  121. package/dist/config-GRL6O2ZY.js +0 -1
  122. package/dist/engine-JVPM3XE5.js +0 -1
  123. package/dist/execution-tools-7MK257DY.js +0 -1
  124. package/dist/memory-service-XI3JZQ4E.js +0 -1
  125. package/dist/outbound-gateway-O27KKVOI.js +0 -1
  126. package/dist/presets-UAH3OG3C.js +0 -1
  127. package/dist/role-presets-RVYTO5FS.js +0 -1
  128. package/dist/role-workspace-KOTVFJD3.js +0 -1
  129. package/dist/runtime-C3XN33A3.js +0 -1
  130. package/dist/session-manager-HO2ZCB47.js +0 -1
  131. package/dist/skill-registry-X2GY7SMI.js +0 -1
  132. package/dist/template-dispatch-BAMKX3QH.js +0 -1
  133. package/web/dist/assets/Extensions-B_egkUP1.js +0 -1
  134. package/web/dist/assets/RoleDetail-Ct-k3uoK.js +0 -35
  135. package/web/dist/assets/Settings-CqtCBP6I.js +0 -1
  136. package/web/dist/assets/api-BRfbZQSW.js +0 -1
  137. package/web/dist/assets/index-DWU9AURw.css +0 -2
  138. package/web/dist/assets/index-PIFMZAPo.js +0 -12
  139. /package/web/dist/assets/{NotFound-DuH6sFz7.js → NotFound-t66RIvqO.js} +0 -0
  140. /package/web/dist/assets/{Table-D2K039zr.js → Table-CvSmzzkm.js} +0 -0
  141. /package/web/dist/assets/{Tabs-BwyLSH2c.js → Tabs-DWk9HyNd.js} +0 -0
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,M as n,et as r,p as i,xt as a}from"./vendor-icons-Bc_e_XXa.js";import{t as o}from"./vendor-react-bQ_cvNuA.js";import{t as s}from"./Button-CRNb8sD3.js";import{f as c}from"./index-PIFMZAPo.js";import{t as l}from"./Card-Cwvv0An8.js";import{t as u}from"./PageHeader-acLQTYct.js";import{t as d}from"./EmptyState-BvQA1o5K.js";import{t as f}from"./ui-D1crlGpt.js";var p=e(a(),1),m=o(),h={debug:`text-[var(--app-text-subtle)]`,info:`text-[var(--app-accent)]`,warn:`text-[var(--app-warning)]`,error:`text-[var(--app-danger)]`},g={adam:`text-[var(--app-log-adam)]`,manager:`text-[var(--app-log-manager)]`,worker:`text-[var(--app-success)]`,scheduler:`text-[var(--app-log-scheduler)]`,api:`text-[var(--app-accent)]`,ws:`text-[var(--app-log-ws)]`,store:`text-[var(--app-log-store)]`,embedding:`text-[var(--app-log-embedding)]`},_=[`adam`,`manager`,`worker`,`scheduler`,`api`,`ws`,`store`,`embedding`],v=[`debug`,`info`,`warn`,`error`];function y(){let e=c(e=>e.logs),a=(0,p.useRef)(null),[o,y]=(0,p.useState)(!0),[x,S]=(0,p.useState)(null),[C,w]=(0,p.useState)(null),T=(0,p.useMemo)(()=>e.filter(e=>!(x&&e.level!==x||C&&e.component!==C)),[e,x,C]);return(0,p.useEffect)(()=>{o&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},[T,o]),(0,m.jsxs)(`div`,{className:`flex h-full flex-col gap-5`,children:[(0,m.jsx)(u,{title:`Logs`,compact:!0,description:`Backend events with inline filters and a stable reading surface.`,metrics:[{label:`Visible`,value:T.length},{label:`Total`,value:e.length},{label:`Mode`,value:o?`Live`:`Paused`}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>y(!o),title:o?`Pause auto-scroll`:`Resume auto-scroll`,children:o?(0,m.jsx)(n,{size:f.sm}):(0,m.jsx)(t,{size:f.sm})}),(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>{c.setState({logs:[]})},title:`Clear logs`,children:(0,m.jsx)(r,{size:f.sm})})]})}),(0,m.jsx)(l,{className:`surface-panel-muted py-3`,children:(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Level:`}),(0,m.jsxs)(`div`,{className:`flex gap-1`,children:[(0,m.jsx)(b,{active:x===null,onClick:()=>S(null),children:`All`}),v.map(e=>(0,m.jsx)(b,{active:x===e,onClick:()=>S(x===e?null:e),children:e},e))]})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Component:`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,m.jsx)(b,{active:C===null,onClick:()=>w(null),children:`All`}),_.map(e=>(0,m.jsx)(b,{active:C===e,onClick:()=>w(C===e?null:e),children:e},e))]})]})]})}),(0,m.jsx)(l,{padding:!1,className:`flex-1 min-h-0`,children:T.length===0?(0,m.jsx)(`div`,{className:`p-4`,children:(0,m.jsx)(d,{icon:(0,m.jsx)(i,{size:32}),title:`No log entries`,description:`Log events will appear here in real-time via WebSocket.`,compact:!0,className:`min-h-[10rem]`})}):(0,m.jsx)(`div`,{ref:a,className:`h-full max-h-[calc(100vh-280px)] overflow-y-auto p-3 font-mono text-xs leading-5`,children:T.map((e,t)=>{let n=new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,fractionalSecondDigits:3}),r=h[e.level]??`text-[var(--app-text-muted)]`,i=g[e.component]??`text-[var(--app-text-muted)]`;return(0,m.jsxs)(`div`,{className:`flex gap-2 hover:bg-[var(--app-panel-elevated)]/30 px-1 rounded`,children:[(0,m.jsx)(`span`,{className:`text-[var(--app-text-subtle)] shrink-0`,children:n}),(0,m.jsx)(`span`,{className:`w-12 shrink-0 uppercase ${r}`,children:e.level.padEnd(5)}),(0,m.jsxs)(`span`,{className:`w-20 shrink-0 ${i}`,children:[`[`,e.component,`]`]}),(0,m.jsx)(`span`,{className:`text-[var(--app-text)] break-all`,children:e.msg})]},t)})})}),(0,m.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,m.jsxs)(`span`,{children:[T.length,` entries `,T.length!==e.length&&`(${e.length} total)`]}),(0,m.jsx)(`span`,{children:o?`Following live feed`:`Scroll paused`})]})]})}function b({active:e,onClick:t,children:n}){return(0,m.jsx)(`button`,{onClick:t,className:`rounded px-2 py-0.5 text-xs transition-colors ${e?`bg-[var(--app-panel-muted)] text-[var(--app-text)]`:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n})}export{y as Logs};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,M as n,et as r,p as i,xt as a}from"./vendor-icons-Bc_e_XXa.js";import{t as o}from"./vendor-react-bQ_cvNuA.js";import{t as s}from"./Button-CRNb8sD3.js";import{f as c}from"./index-CXEJd-0s.js";import{t as l}from"./Card-Cwvv0An8.js";import{t as u}from"./PageHeader-acLQTYct.js";import{t as d}from"./EmptyState-BvQA1o5K.js";import{t as f}from"./ui-D1crlGpt.js";var p=e(a(),1),m=o(),h={debug:`text-[var(--app-text-subtle)]`,info:`text-[var(--app-accent)]`,warn:`text-[var(--app-warning)]`,error:`text-[var(--app-danger)]`},g={adam:`text-[var(--app-log-adam)]`,manager:`text-[var(--app-log-manager)]`,worker:`text-[var(--app-success)]`,scheduler:`text-[var(--app-log-scheduler)]`,api:`text-[var(--app-accent)]`,ws:`text-[var(--app-log-ws)]`,store:`text-[var(--app-log-store)]`,embedding:`text-[var(--app-log-embedding)]`},_=[`adam`,`manager`,`worker`,`scheduler`,`api`,`ws`,`store`,`embedding`],v=[`debug`,`info`,`warn`,`error`];function y(){let e=c(e=>e.logs),a=(0,p.useRef)(null),[o,y]=(0,p.useState)(!0),[x,S]=(0,p.useState)(null),[C,w]=(0,p.useState)(null),T=(0,p.useMemo)(()=>e.filter(e=>!(x&&e.level!==x||C&&e.component!==C)),[e,x,C]);return(0,p.useEffect)(()=>{o&&a.current&&(a.current.scrollTop=a.current.scrollHeight)},[T,o]),(0,m.jsxs)(`div`,{className:`flex h-full flex-col gap-5`,children:[(0,m.jsx)(u,{title:`Logs`,compact:!0,description:`Backend events with inline filters and a stable reading surface.`,metrics:[{label:`Visible`,value:T.length},{label:`Total`,value:e.length},{label:`Mode`,value:o?`Live`:`Paused`}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,m.jsxs)(`div`,{className:`flex gap-2`,children:[(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>y(!o),title:o?`Pause auto-scroll`:`Resume auto-scroll`,children:o?(0,m.jsx)(n,{size:f.sm}):(0,m.jsx)(t,{size:f.sm})}),(0,m.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>{c.setState({logs:[]})},title:`Clear logs`,children:(0,m.jsx)(r,{size:f.sm})})]})}),(0,m.jsx)(l,{className:`surface-panel-muted py-3`,children:(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Level:`}),(0,m.jsxs)(`div`,{className:`flex gap-1`,children:[(0,m.jsx)(b,{active:x===null,onClick:()=>S(null),children:`All`}),v.map(e=>(0,m.jsx)(b,{active:x===e,onClick:()=>S(x===e?null:e),children:e},e))]})]}),(0,m.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Component:`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,m.jsx)(b,{active:C===null,onClick:()=>w(null),children:`All`}),_.map(e=>(0,m.jsx)(b,{active:C===e,onClick:()=>w(C===e?null:e),children:e},e))]})]})]})}),(0,m.jsx)(l,{padding:!1,className:`flex-1 min-h-0`,children:T.length===0?(0,m.jsx)(`div`,{className:`p-4`,children:(0,m.jsx)(d,{icon:(0,m.jsx)(i,{size:32}),title:`No log entries`,description:`Log events will appear here in real-time via WebSocket.`,compact:!0,className:`min-h-[10rem]`})}):(0,m.jsx)(`div`,{ref:a,className:`h-full max-h-[calc(100vh-280px)] overflow-y-auto p-3 font-mono text-xs leading-5`,children:T.map((e,t)=>{let n=new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,fractionalSecondDigits:3}),r=h[e.level]??`text-[var(--app-text-muted)]`,i=g[e.component]??`text-[var(--app-text-muted)]`;return(0,m.jsxs)(`div`,{className:`flex gap-2 hover:bg-[var(--app-panel-elevated)]/30 px-1 rounded`,children:[(0,m.jsx)(`span`,{className:`text-[var(--app-text-subtle)] shrink-0`,children:n}),(0,m.jsx)(`span`,{className:`w-12 shrink-0 uppercase ${r}`,children:e.level.padEnd(5)}),(0,m.jsxs)(`span`,{className:`w-20 shrink-0 ${i}`,children:[`[`,e.component,`]`]}),(0,m.jsx)(`span`,{className:`text-[var(--app-text)] break-all`,children:e.msg})]},t)})})}),(0,m.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-[var(--app-text-subtle)]`,children:[(0,m.jsxs)(`span`,{children:[T.length,` entries `,T.length!==e.length&&`(${e.length} total)`]}),(0,m.jsx)(`span`,{children:o?`Following live feed`:`Scroll paused`})]})]})}function b({active:e,onClick:t,children:n}){return(0,m.jsx)(`button`,{onClick:t,className:`rounded px-2 py-0.5 text-xs transition-colors ${e?`bg-[var(--app-panel-muted)] text-[var(--app-text)]`:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n})}export{y as Logs};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{gt as t,w as n,x as r,xt as i}from"./vendor-icons-Bc_e_XXa.js";import{t as a}from"./vendor-react-bQ_cvNuA.js";import{t as o}from"./Button-CRNb8sD3.js";import{t as s}from"./api-BRfbZQSW.js";import{f as c,t as l}from"./index-PIFMZAPo.js";import{t as u}from"./Card-Cwvv0An8.js";import{t as d}from"./PageHeader-acLQTYct.js";import{t as f}from"./SectionHeader-NZWZgoOs.js";import{a as p}from"./format-ZWN4JNj-.js";import{t as m}from"./EmptyState-BvQA1o5K.js";var h=e(i(),1),g=a();function _(){let e=c(e=>e.roles),i=c(e=>e.fetchRoles),[a,_]=(0,h.useState)(``),[v,y]=(0,h.useState)([]),[b,x]=(0,h.useState)(!1),[S,C]=(0,h.useState)(``),[w,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(`all`),[O,k]=(0,h.useState)(new Set);(0,h.useEffect)(()=>{i()},[i]),(0,h.useEffect)(()=>{!a&&e.length>0&&_(e[0].id)},[e,a]);let A=(0,h.useCallback)(async()=>{if(a){x(!0);try{y((await s(`/memories/${a}?limit=100`)).memories)}catch{y([])}finally{x(!1)}}},[a]);(0,h.useEffect)(()=>{a&&A()},[a,A]);let j=async()=>{if(!(!S.trim()||!a)){T(!0);try{y((await s(`/memories/query`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentId:a,prompt:S.trim(),topK:20})})).memories)}catch{y([])}finally{T(!1)}}},M=()=>{C(``),A()},N=v.filter(e=>E===`high`?e.importance>3:E===`medium`?e.importance===3:E===`low`?e.importance<3:!0),P=e=>e>=4?`text-[var(--app-danger)]`:e===3?`text-[var(--app-warning)]`:`text-[var(--app-text-subtle)]`;return(0,g.jsxs)(`div`,{className:`space-y-5`,children:[(0,g.jsx)(d,{eyebrow:`Knowledge`,title:`Memories`,compact:!0,description:`What each role is retaining and how retrieval changes the visible recall set.`,metrics:[{label:`Role`,value:e.find(e=>e.id===a)?.name??`None`},{label:`Visible`,value:N.length},{label:`High Importance`,value:v.filter(e=>e.importance>3).length}],actions:(0,g.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>void A(),children:(0,g.jsx)(n,{size:14})})}),(0,g.jsx)(f,{title:`Recall Controls`,compact:!0,description:`Switch role context, run a retrieval query, or narrow by importance.`}),(0,g.jsx)(u,{className:`surface-panel-muted`,children:(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(`select`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:a,onChange:e=>_(e.target.value),children:e.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(`input`,{className:`w-64 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder-slate-600 focus:border-[var(--app-accent)] focus:outline-none`,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>e.key===`Enter`&&void j(),placeholder:`Search memories...`}),(0,g.jsx)(o,{size:`sm`,variant:`ghost`,onClick:()=>void j(),disabled:w,children:(0,g.jsx)(r,{size:14})}),S&&(0,g.jsx)(o,{size:`sm`,variant:`ghost`,onClick:M,children:`Clear`})]}),(0,g.jsx)(`div`,{className:`flex gap-1`,children:[`all`,`high`,`medium`,`low`].map(e=>(0,g.jsx)(`button`,{className:`rounded px-2 py-1 text-xs transition-colors ${E===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:bg-[var(--app-panel-muted)]`}`,onClick:()=>D(e),children:e},e))})]})}),(0,g.jsx)(u,{children:b||w?(0,g.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,g.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):N.length===0?(0,g.jsx)(m,{icon:(0,g.jsx)(t,{size:32}),title:`No memories`,description:S?`No results for this query`:`This agent has no memories yet`,className:`py-8`}):(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[N.length,` memories`]}),N.map(e=>(0,g.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,g.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,g.jsx)(l,{variant:e.type===`reflection`?`info`:e.type===`thought`?`warning`:`muted`,children:e.type}),(0,g.jsx)(l,{variant:`muted`,children:e.sourceType}),(0,g.jsx)(`span`,{className:`text-xs font-medium ${P(e.importance)}`,children:`*`.repeat(e.importance)}),e.score!=null&&(0,g.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`score: `,e.score.toFixed(3)]})]}),(0,g.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-[var(--app-text)]`,children:e.content}),(0,g.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:e.keywords.map(e=>(0,g.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-subtle)]`,children:e},e))}),e.type===`reflection`&&e.evidence&&e.evidence.length>0&&(0,g.jsxs)(`div`,{className:`mt-2`,children:[(0,g.jsxs)(`button`,{className:`text-[10px] text-[var(--app-accent)] hover:text-[var(--app-accent)]`,onClick:()=>k(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),children:[O.has(e.id)?`Hide`:`Show`,` evidence (`,e.evidence.length,` memories)`]}),O.has(e.id)&&(0,g.jsx)(`div`,{className:`mt-1.5 space-y-1 border-l-2 border-[var(--app-border)] pl-2`,children:e.evidence.map(e=>{let t=v.find(t=>t.id===e);return(0,g.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t?t.content.slice(0,120)+(t.content.length>120?`...`:``):(0,g.jsxs)(`span`,{className:`italic`,children:[`Memory `,e.slice(0,8),` (not in current view)`]})},e)})})]}),(0,g.jsxs)(`p`,{className:`mt-1.5 text-[10px] text-[var(--app-text-subtle)]`,children:[p(e.createdAt),` | accessed `,e.retrievedCount,`x | last: `,p(e.lastAccessed)]})]},e.id))]})})]})}export{_ as Memories};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{gt as t,w as n,x as r,xt as i}from"./vendor-icons-Bc_e_XXa.js";import{t as a}from"./vendor-react-bQ_cvNuA.js";import{t as o}from"./Button-CRNb8sD3.js";import{t as s}from"./api-BP4ZP9kk.js";import{f as c,t as l}from"./index-CXEJd-0s.js";import{t as u}from"./Card-Cwvv0An8.js";import{t as d}from"./PageHeader-acLQTYct.js";import{t as f}from"./SectionHeader-NZWZgoOs.js";import{a as p}from"./format-ZWN4JNj-.js";import{t as m}from"./EmptyState-BvQA1o5K.js";var h=e(i(),1),g=a();function _(){let e=c(e=>e.roles),i=c(e=>e.fetchRoles),[a,_]=(0,h.useState)(``),[v,y]=(0,h.useState)([]),[b,x]=(0,h.useState)(!1),[S,C]=(0,h.useState)(``),[w,T]=(0,h.useState)(!1),[E,D]=(0,h.useState)(`all`),[O,k]=(0,h.useState)(new Set);(0,h.useEffect)(()=>{i()},[i]),(0,h.useEffect)(()=>{!a&&e.length>0&&_(e[0].id)},[e,a]);let A=(0,h.useCallback)(async()=>{if(a){x(!0);try{y((await s(`/memories/${a}?limit=100`)).memories)}catch{y([])}finally{x(!1)}}},[a]);(0,h.useEffect)(()=>{a&&A()},[a,A]);let j=async()=>{if(!(!S.trim()||!a)){T(!0);try{y((await s(`/memories/query`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentId:a,prompt:S.trim(),topK:20})})).memories)}catch{y([])}finally{T(!1)}}},M=()=>{C(``),A()},N=v.filter(e=>E===`high`?e.importance>3:E===`medium`?e.importance===3:E===`low`?e.importance<3:!0),P=e=>e>=4?`text-[var(--app-danger)]`:e===3?`text-[var(--app-warning)]`:`text-[var(--app-text-subtle)]`;return(0,g.jsxs)(`div`,{className:`space-y-5`,children:[(0,g.jsx)(d,{eyebrow:`Knowledge`,title:`Memories`,compact:!0,description:`What each role is retaining and how retrieval changes the visible recall set.`,metrics:[{label:`Role`,value:e.find(e=>e.id===a)?.name??`None`},{label:`Visible`,value:N.length},{label:`High Importance`,value:v.filter(e=>e.importance>3).length}],actions:(0,g.jsx)(o,{variant:`ghost`,size:`sm`,onClick:()=>void A(),children:(0,g.jsx)(n,{size:14})})}),(0,g.jsx)(f,{title:`Recall Controls`,compact:!0,description:`Switch role context, run a retrieval query, or narrow by importance.`}),(0,g.jsx)(u,{className:`surface-panel-muted`,children:(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,g.jsx)(`select`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:a,onChange:e=>_(e.target.value),children:e.map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,g.jsx)(`input`,{className:`w-64 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder-slate-600 focus:border-[var(--app-accent)] focus:outline-none`,value:S,onChange:e=>C(e.target.value),onKeyDown:e=>e.key===`Enter`&&void j(),placeholder:`Search memories...`}),(0,g.jsx)(o,{size:`sm`,variant:`ghost`,onClick:()=>void j(),disabled:w,children:(0,g.jsx)(r,{size:14})}),S&&(0,g.jsx)(o,{size:`sm`,variant:`ghost`,onClick:M,children:`Clear`})]}),(0,g.jsx)(`div`,{className:`flex gap-1`,children:[`all`,`high`,`medium`,`low`].map(e=>(0,g.jsx)(`button`,{className:`rounded px-2 py-1 text-xs transition-colors ${E===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:bg-[var(--app-panel-muted)]`}`,onClick:()=>D(e),children:e},e))})]})}),(0,g.jsx)(u,{children:b||w?(0,g.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,g.jsx)(`div`,{className:`h-6 w-6 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):N.length===0?(0,g.jsx)(m,{icon:(0,g.jsx)(t,{size:32}),title:`No memories`,description:S?`No results for this query`:`This agent has no memories yet`,className:`py-8`}):(0,g.jsxs)(`div`,{className:`space-y-3`,children:[(0,g.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[N.length,` memories`]}),N.map(e=>(0,g.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,g.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,g.jsx)(l,{variant:e.type===`reflection`?`info`:e.type===`thought`?`warning`:`muted`,children:e.type}),(0,g.jsx)(l,{variant:`muted`,children:e.sourceType}),(0,g.jsx)(`span`,{className:`text-xs font-medium ${P(e.importance)}`,children:`*`.repeat(e.importance)}),e.score!=null&&(0,g.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`score: `,e.score.toFixed(3)]})]}),(0,g.jsx)(`p`,{className:`whitespace-pre-wrap text-sm text-[var(--app-text)]`,children:e.content}),(0,g.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:e.keywords.map(e=>(0,g.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-subtle)]`,children:e},e))}),e.type===`reflection`&&e.evidence&&e.evidence.length>0&&(0,g.jsxs)(`div`,{className:`mt-2`,children:[(0,g.jsxs)(`button`,{className:`text-[10px] text-[var(--app-accent)] hover:text-[var(--app-accent)]`,onClick:()=>k(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),children:[O.has(e.id)?`Hide`:`Show`,` evidence (`,e.evidence.length,` memories)`]}),O.has(e.id)&&(0,g.jsx)(`div`,{className:`mt-1.5 space-y-1 border-l-2 border-[var(--app-border)] pl-2`,children:e.evidence.map(e=>{let t=v.find(t=>t.id===e);return(0,g.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:t?t.content.slice(0,120)+(t.content.length>120?`...`:``):(0,g.jsxs)(`span`,{className:`italic`,children:[`Memory `,e.slice(0,8),` (not in current view)`]})},e)})})]}),(0,g.jsxs)(`p`,{className:`mt-1.5 text-[10px] text-[var(--app-text-subtle)]`,children:[p(e.createdAt),` | accessed `,e.retrievedCount,`x | last: `,p(e.lastAccessed)]})]},e.id))]})})]})}export{_ as Memories};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{t as r}from"./Button-CRNb8sD3.js";import{b as i,f as a}from"./api-BRfbZQSW.js";import{t as o}from"./index-PIFMZAPo.js";import{t as s}from"./Card-Cwvv0An8.js";import{t as c}from"./SectionHeader-NZWZgoOs.js";import{t as l}from"./EmptyState-BvQA1o5K.js";var u=e(t(),1),d=n(),f={new:`muted`,acknowledged:`success`,dismissed:`secondary`};function p(e){let t=Date.now()-e;if(Math.floor(t/6e4)<1)return`just now`;let n=Math.floor(t/36e5);return n<24?`${n}h ago`:`${Math.floor(t/864e5)}d ago`}function m(e){return new Date(e).toLocaleString()}function h(){let[e,t]=(0,u.useState)([]),[n,h]=(0,u.useState)(!0),[g,_]=(0,u.useState)(`all`),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(null),S=(0,u.useCallback)(async()=>{h(!0);try{t(await a(g===`all`?void 0:g))}catch{t([])}finally{h(!1)}},[g]);(0,u.useEffect)(()=>{S()},[S]);let C=async(e,t)=>{x(e);try{await i(e,t),await S()}finally{x(null)}};return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsx)(c,{title:`Mistake Patterns`,description:`Cross-role failure patterns extracted from audit data.`,compact:!0,action:(0,d.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>void S(),children:`Refresh`})}),(0,d.jsx)(`div`,{className:`flex gap-2`,children:[`all`,`new`,`acknowledged`,`dismissed`].map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>_(e),className:`rounded px-3 py-1.5 text-xs font-medium transition-colors ${g===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:e===`all`?`All`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),n?(0,d.jsx)(s,{children:(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:`Loading...`})}):e.length===0?(0,d.jsx)(s,{children:(0,d.jsx)(l,{title:`No mistake patterns`,description:`Run the Mistake Digest template to aggregate failure signals from audit data.`})}):(0,d.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,d.jsxs)(s,{padding:!1,children:[(0,d.jsx)(`div`,{className:`p-4 cursor-pointer hover:bg-black/[0.02]`,onClick:()=>y(v===e.id?null:e.id),role:`button`,tabIndex:0,onKeyDown:t=>{t.key===`Enter`&&y(v===e.id?null:e.id)},children:(0,d.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,d.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,d.jsx)(o,{variant:f[e.status],children:e.status}),(0,d.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:p(e.lastSeen)}),(0,d.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-muted)] font-mono`,children:e.dimensionType})]}),(0,d.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.dimensionValue}),(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-muted)]`,children:[e.count,` occurrence`,e.count===1?``:`s`,` across `,e.roleIds.length,` role`,e.roleIds.length===1?``:`s`]})]})})}),v===e.id&&(0,d.jsxs)(`div`,{className:`border-t border-[var(--app-border)] p-4 space-y-3`,children:[(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Dimension`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)] font-mono`,children:e.dimensionType})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Dimension Value`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)] font-mono break-all`,children:e.dimensionValue})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Affected Roles`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.roleIds.length>0?e.roleIds.join(`, `):`—`})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Evidence Items`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.sampleEvidenceIds.length>0?(0,d.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[e.sampleEvidenceIds.slice(0,5).map(e=>(0,d.jsxs)(`span`,{className:`text-xs`,children:[(0,d.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1 py-0.5 text-[10px] font-mono`,children:e.source}),` `,e.id]},e.id)),e.sampleEvidenceIds.length>5&&(0,d.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`+`,e.sampleEvidenceIds.length-5,` more`]})]}):`—`})]})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-4 pt-1`,children:[(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`First seen: `,m(e.firstSeen)]}),(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Last seen: `,m(e.lastSeen)]})]}),(0,d.jsx)(`div`,{className:`flex gap-2 pt-1`,children:[`new`,`acknowledged`,`dismissed`].map(t=>(0,d.jsx)(r,{variant:e.status===t?`default`:`ghost`,size:`sm`,disabled:b===e.id||e.status===t,onClick:n=>{n.stopPropagation(),C(e.id,t)},children:t.charAt(0).toUpperCase()+t.slice(1)},t))})]})]},e.id))})]})}export{h as Mistakes};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{t as r}from"./Button-CRNb8sD3.js";import{S as i,m as a}from"./api-BP4ZP9kk.js";import{t as o}from"./index-CXEJd-0s.js";import{t as s}from"./Card-Cwvv0An8.js";import{t as c}from"./SectionHeader-NZWZgoOs.js";import{t as l}from"./EmptyState-BvQA1o5K.js";var u=e(t(),1),d=n(),f={new:`muted`,acknowledged:`success`,dismissed:`secondary`};function p(e){let t=Date.now()-e;if(Math.floor(t/6e4)<1)return`just now`;let n=Math.floor(t/36e5);return n<24?`${n}h ago`:`${Math.floor(t/864e5)}d ago`}function m(e){return new Date(e).toLocaleString()}function h(){let[e,t]=(0,u.useState)([]),[n,h]=(0,u.useState)(!0),[g,_]=(0,u.useState)(`all`),[v,y]=(0,u.useState)(null),[b,x]=(0,u.useState)(null),S=(0,u.useCallback)(async()=>{h(!0);try{t(await a(g===`all`?void 0:g))}catch{t([])}finally{h(!1)}},[g]);(0,u.useEffect)(()=>{S()},[S]);let C=async(e,t)=>{x(e);try{await i(e,t),await S()}finally{x(null)}};return(0,d.jsxs)(`div`,{className:`space-y-5`,children:[(0,d.jsx)(c,{title:`Mistake Patterns`,description:`Cross-role failure patterns extracted from audit data.`,compact:!0,action:(0,d.jsx)(r,{variant:`ghost`,size:`sm`,onClick:()=>void S(),children:`Refresh`})}),(0,d.jsx)(`div`,{className:`flex gap-2`,children:[`all`,`new`,`acknowledged`,`dismissed`].map(e=>(0,d.jsx)(`button`,{type:`button`,onClick:()=>_(e),className:`rounded px-3 py-1.5 text-xs font-medium transition-colors ${g===e?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:e===`all`?`All`:e.charAt(0).toUpperCase()+e.slice(1)},e))}),n?(0,d.jsx)(s,{children:(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:`Loading...`})}):e.length===0?(0,d.jsx)(s,{children:(0,d.jsx)(l,{title:`No mistake patterns`,description:`Run the Mistake Digest template to aggregate failure signals from audit data.`})}):(0,d.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,d.jsxs)(s,{padding:!1,children:[(0,d.jsx)(`div`,{className:`p-4 cursor-pointer hover:bg-black/[0.02]`,onClick:()=>y(v===e.id?null:e.id),role:`button`,tabIndex:0,onKeyDown:t=>{t.key===`Enter`&&y(v===e.id?null:e.id)},children:(0,d.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,d.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,d.jsx)(o,{variant:f[e.status],children:e.status}),(0,d.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:p(e.lastSeen)}),(0,d.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1.5 py-0.5 text-[10px] text-[var(--app-text-muted)] font-mono`,children:e.dimensionType})]}),(0,d.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.dimensionValue}),(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-muted)]`,children:[e.count,` occurrence`,e.count===1?``:`s`,` across `,e.roleIds.length,` role`,e.roleIds.length===1?``:`s`]})]})})}),v===e.id&&(0,d.jsxs)(`div`,{className:`border-t border-[var(--app-border)] p-4 space-y-3`,children:[(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Dimension`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)] font-mono`,children:e.dimensionType})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Dimension Value`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)] font-mono break-all`,children:e.dimensionValue})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Affected Roles`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.roleIds.length>0?e.roleIds.join(`, `):`—`})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)] uppercase tracking-[0.14em] mb-1`,children:`Evidence Items`}),(0,d.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e.sampleEvidenceIds.length>0?(0,d.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[e.sampleEvidenceIds.slice(0,5).map(e=>(0,d.jsxs)(`span`,{className:`text-xs`,children:[(0,d.jsx)(`span`,{className:`rounded border border-[var(--app-border)] px-1 py-0.5 text-[10px] font-mono`,children:e.source}),` `,e.id]},e.id)),e.sampleEvidenceIds.length>5&&(0,d.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`+`,e.sampleEvidenceIds.length-5,` more`]})]}):`—`})]})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-4 pt-1`,children:[(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`First seen: `,m(e.firstSeen)]}),(0,d.jsxs)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Last seen: `,m(e.lastSeen)]})]}),(0,d.jsx)(`div`,{className:`flex gap-2 pt-1`,children:[`new`,`acknowledged`,`dismissed`].map(t=>(0,d.jsx)(r,{variant:e.status===t?`default`:`ghost`,size:`sm`,disabled:b===e.id||e.status===t,onClick:n=>{n.stopPropagation(),C(e.id,t)},children:t.charAt(0).toUpperCase()+t.slice(1)},t))})]})]},e.id))})]})}export{h as Mistakes};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,E as n,K as r,ft as i,ht as a,mt as o,n as s,nt as c,pt as l,st as u,tt as d,w as f,x as ee,xt as p,z as m}from"./vendor-icons-Bc_e_XXa.js";import{t as te}from"./vendor-react-bQ_cvNuA.js";import{n as h}from"./dist-CgGno8kE.js";import{_ as g,a as ne,c as _,d as v,f as y,i as re,m as b,n as ie,o as x,p as S,r as C,s as w,t as ae,u as oe,v as T}from"./es2015-BkFSNOYE.js";import{i as E,r as D,t as O}from"./Button-CRNb8sD3.js";import{t as k}from"./api-BRfbZQSW.js";import{S as A,_ as se,b as ce,g as j,h as M,m as le,p as N,t as P,v as ue,x as F,y as de}from"./index-PIFMZAPo.js";import{t as I}from"./Card-Cwvv0An8.js";import{t as fe}from"./PageHeader-acLQTYct.js";import{t as pe}from"./SectionHeader-NZWZgoOs.js";import{a as me}from"./format-ZWN4JNj-.js";import{t as he}from"./EmptyState-BvQA1o5K.js";import{t as L}from"./ui-D1crlGpt.js";import{a as ge,i as R,n as _e,o as z,r as B,t as ve}from"./Table-D2K039zr.js";import{n as ye,r as be,t as xe}from"./usePluginsWithUsage-DE13JW16.js";import{a as Se,c as Ce,i as we,l as Te,n as Ee,o as De,r as Oe,s as ke,t as Ae}from"./Tabs-BwyLSH2c.js";var V=e(p(),1),H=te();function je(){let[e,t]=(0,V.useState)(!1),[n,r]=(0,V.useState)([]),o=(0,V.useCallback)(async()=>{try{r((await k(`/plugins/stats?limit=20`)).stats)}catch{r([])}},[]);return(0,H.jsxs)(I,{children:[(0,H.jsxs)(`button`,{className:`flex w-full items-center gap-2 text-sm font-semibold text-[var(--app-text)]`,onClick:()=>{!e&&n.length===0&&o(),t(e=>!e)},children:[(0,H.jsx)(a,{size:L.sm,className:`text-[var(--app-text-muted)]`}),`Usage Stats`,e?(0,H.jsx)(l,{size:L.xs,className:`ml-auto`}):(0,H.jsx)(i,{size:L.xs,className:`ml-auto`})]}),e?(0,H.jsx)(`div`,{className:`mt-3`,children:n.length===0?(0,H.jsx)(`p`,{className:`py-2 text-center text-xs text-[var(--app-text-subtle)]`,children:`No usage data yet`}):(0,H.jsxs)(ve,{children:[(0,H.jsx)(ge,{children:(0,H.jsxs)(z,{children:[(0,H.jsx)(R,{children:`Plugin`}),(0,H.jsx)(R,{children:`Usage Count`}),(0,H.jsx)(R,{children:`Last Used`})]})}),(0,H.jsx)(_e,{children:n.map(e=>(0,H.jsxs)(z,{children:[(0,H.jsx)(B,{className:`text-xs font-medium text-[var(--app-text)]`,children:e.pluginName}),(0,H.jsx)(B,{className:`font-mono text-xs text-[var(--app-text-muted)]`,children:e.usageCount}),(0,H.jsx)(B,{className:`text-xs text-[var(--app-text-muted)]`,children:e.lastUsed?me(e.lastUsed):`—`})]},e.pluginPath))})]})}):null]})}var Me=[`Enter`,` `],Ne=[`ArrowDown`,`PageUp`,`Home`],Pe=[`ArrowUp`,`PageDown`,`End`],Fe=[...Ne,...Pe],Ie={ltr:[...Me,`ArrowRight`],rtl:[...Me,`ArrowLeft`]},Le={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},U=`Menu`,[W,Re,ze]=Te(U),[G,Be]=g(U,[ze,A,ke]),K=A(),Ve=ke(),[He,q]=G(U),[Ue,J]=G(U),We=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=K(t),[c,l]=V.useState(null),u=V.useRef(!1),d=v(a),f=Ce(i);return V.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,H.jsx)(F,{...s,children:(0,H.jsx)(He,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,H.jsx)(Ue,{scope:t,onClose:V.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};We.displayName=U;var Ge=`MenuAnchor`,Ke=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=K(n);return(0,H.jsx)(ue,{...i,...r,ref:t})});Ke.displayName=Ge;var qe=`MenuPortal`,[Je,Ye]=G(qe,{forceMount:void 0}),Xe=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=q(qe,t);return(0,H.jsx)(Je,{scope:t,forceMount:n,children:(0,H.jsx)(x,{present:n||a.open,children:(0,H.jsx)(w,{asChild:!0,container:i,children:r})})})};Xe.displayName=qe;var Y=`MenuContent`,[Ze,Qe]=G(Y),$e=V.forwardRef((e,t)=>{let n=Ye(Y,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeMenu),o=J(Y,e.__scopeMenu);return(0,H.jsx)(W.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(x,{present:r||a.open,children:(0,H.jsx)(W.Slot,{scope:e.__scopeMenu,children:o.modal?(0,H.jsx)(et,{...i,ref:t}):(0,H.jsx)(tt,{...i,ref:t})})})})}),et=V.forwardRef((e,t)=>{let n=q(Y,e.__scopeMenu),r=V.useRef(null),i=E(t,r);return V.useEffect(()=>{let e=r.current;if(e)return ae(e)},[]),(0,H.jsx)(rt,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:T(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),tt=V.forwardRef((e,t)=>{let n=q(Y,e.__scopeMenu);return(0,H.jsx)(rt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),nt=b(`MenuContent.ScrollLock`),rt=V.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:ee,disableOutsideScroll:p,...m}=e,te=q(Y,n),h=J(Y,n),g=K(n),ne=Ve(n),_=Re(n),[v,y]=V.useState(null),b=V.useRef(null),x=E(t,b,te.onContentChange),S=V.useRef(0),w=V.useRef(``),ae=V.useRef(0),D=V.useRef(null),O=V.useRef(`right`),k=V.useRef(0),A=p?ie:V.Fragment,se=p?{as:nt,allowPinchZoom:!0}:void 0,j=e=>{let t=w.current+e,n=_().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Bt(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){w.current=t,window.clearTimeout(S.current),t!==``&&(S.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};V.useEffect(()=>()=>window.clearTimeout(S.current),[]),C();let M=V.useCallback(e=>O.current===D.current?.side&&Ht(e,D.current?.area),[]);return(0,H.jsx)(Ze,{scope:n,searchRef:w,onItemEnter:V.useCallback(e=>{M(e)&&e.preventDefault()},[M]),onItemLeave:V.useCallback(e=>{M(e)||(b.current?.focus(),y(null))},[M]),onTriggerLeave:V.useCallback(e=>{M(e)&&e.preventDefault()},[M]),pointerGraceTimerRef:ae,onPointerGraceIntentChange:V.useCallback(e=>{D.current=e},[]),children:(0,H.jsx)(A,{...se,children:(0,H.jsx)(re,{asChild:!0,trapped:i,onMountAutoFocus:T(a,e=>{e.preventDefault(),b.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,H.jsx)(oe,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:ee,children:(0,H.jsx)(De,{asChild:!0,...ne,dir:h.dir,orientation:`vertical`,loop:r,currentTabStopId:v,onCurrentTabStopIdChange:y,onEntryFocus:T(c,e=>{h.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,H.jsx)(ce,{role:`menu`,"aria-orientation":`vertical`,"data-state":Ft(te.open),"data-radix-menu-content":``,dir:h.dir,...g,...m,ref:x,style:{outline:`none`,...m.style},onKeyDown:T(m.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&j(e.key));let i=b.current;if(e.target!==i||!Fe.includes(e.key))return;e.preventDefault();let a=_().filter(e=>!e.disabled).map(e=>e.ref.current);Pe.includes(e.key)&&a.reverse(),Rt(a)}),onBlur:T(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(S.current),w.current=``)}),onPointerMove:T(e.onPointerMove,Z(e=>{let t=e.target,n=k.current!==e.clientX;e.currentTarget.contains(t)&&n&&(O.current=e.clientX>k.current?`right`:`left`,k.current=e.clientX)}))})})})})})})});$e.displayName=Y;var it=`MenuGroup`,at=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{role:`group`,...r,ref:t})});at.displayName=it;var ot=`MenuLabel`,st=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{...r,ref:t})});st.displayName=ot;var ct=`MenuItem`,lt=`menu.itemSelect`,ut=V.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=V.useRef(null),o=J(ct,e.__scopeMenu),s=Qe(ct,e.__scopeMenu),c=E(t,a),l=V.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(lt,{bubbles:!0,cancelable:!0});e.addEventListener(lt,e=>r?.(e),{once:!0}),S(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,H.jsx)(dt,{...i,ref:c,disabled:n,onClick:T(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:T(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:T(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||Me.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ut.displayName=ct;var dt=V.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Qe(ct,n),s=Ve(n),c=V.useRef(null),l=E(t,c),[u,d]=V.useState(!1),[f,ee]=V.useState(``);return V.useEffect(()=>{let e=c.current;e&&ee((e.textContent??``).trim())},[a.children]),(0,H.jsx)(W.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,H.jsx)(Se,{asChild:!0,...s,focusable:!r,children:(0,H.jsx)(y.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:T(e.onPointerMove,Z(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:T(e.onPointerLeave,Z(e=>o.onItemLeave(e))),onFocus:T(e.onFocus,()=>d(!0)),onBlur:T(e.onBlur,()=>d(!1))})})})}),ft=`MenuCheckboxItem`,pt=V.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,H.jsx)(xt,{scope:e.__scopeMenu,checked:n,children:(0,H.jsx)(ut,{role:`menuitemcheckbox`,"aria-checked":It(n)?`mixed`:n,...i,ref:t,"data-state":Lt(n),onSelect:T(i.onSelect,()=>r?.(It(n)?!0:!n),{checkForDefaultPrevented:!1})})})});pt.displayName=ft;var mt=`MenuRadioGroup`,[ht,gt]=G(mt,{value:void 0,onValueChange:()=>{}}),_t=V.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=v(r);return(0,H.jsx)(ht,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,H.jsx)(at,{...i,ref:t})})});_t.displayName=mt;var vt=`MenuRadioItem`,yt=V.forwardRef((e,t)=>{let{value:n,...r}=e,i=gt(vt,e.__scopeMenu),a=n===i.value;return(0,H.jsx)(xt,{scope:e.__scopeMenu,checked:a,children:(0,H.jsx)(ut,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Lt(a),onSelect:T(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});yt.displayName=vt;var bt=`MenuItemIndicator`,[xt,St]=G(bt,{checked:!1}),Ct=V.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=St(bt,n);return(0,H.jsx)(x,{present:r||It(a.checked)||a.checked===!0,children:(0,H.jsx)(y.span,{...i,ref:t,"data-state":Lt(a.checked)})})});Ct.displayName=bt;var wt=`MenuSeparator`,Tt=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Tt.displayName=wt;var Et=`MenuArrow`,Dt=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=K(n);return(0,H.jsx)(de,{...i,...r,ref:t})});Dt.displayName=Et;var Ot=`MenuSub`,[kt,At]=G(Ot),jt=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=q(Ot,t),o=K(t),[s,c]=V.useState(null),[l,u]=V.useState(null),d=v(i);return V.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,H.jsx)(F,{...o,children:(0,H.jsx)(He,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,H.jsx)(kt,{scope:t,contentId:_(),triggerId:_(),trigger:s,onTriggerChange:c,children:n})})})};jt.displayName=Ot;var X=`MenuSubTrigger`,Mt=V.forwardRef((e,t)=>{let n=q(X,e.__scopeMenu),r=J(X,e.__scopeMenu),i=At(X,e.__scopeMenu),a=Qe(X,e.__scopeMenu),o=V.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=V.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return V.useEffect(()=>u,[u]),V.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,H.jsx)(Ke,{asChild:!0,...l,children:(0,H.jsx)(dt,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Ft(n.open),...e,ref:D(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:T(e.onPointerMove,Z(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:T(e.onPointerLeave,Z(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:T(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Ie[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Mt.displayName=X;var Nt=`MenuSubContent`,Pt=V.forwardRef((e,t)=>{let n=Ye(Y,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeMenu),o=J(Y,e.__scopeMenu),s=At(Nt,e.__scopeMenu),c=V.useRef(null),l=E(t,c);return(0,H.jsx)(W.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(x,{present:r||a.open,children:(0,H.jsx)(W.Slot,{scope:e.__scopeMenu,children:(0,H.jsx)(rt,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:T(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:T(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:T(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Le[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Pt.displayName=Nt;function Ft(e){return e?`open`:`closed`}function It(e){return e===`indeterminate`}function Lt(e){return It(e)?`indeterminate`:e?`checked`:`unchecked`}function Rt(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function zt(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Bt(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=zt(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Vt(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Ht(e,t){return t?Vt({x:e.clientX,y:e.clientY},t):!1}function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Ut=We,Wt=Ke,Gt=Xe,Kt=$e,qt=at,Jt=st,Yt=ut,Xt=pt,Zt=_t,Qt=yt,$t=Ct,en=Tt,tn=Dt,nn=Mt,rn=Pt,an=`DropdownMenu`,[on,sn]=g(an,[Be]),Q=Be(),[cn,ln]=on(an),un=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Q(t),l=V.useRef(null),[u,d]=ne({prop:i,defaultProp:a??!1,onChange:o,caller:an});return(0,H.jsx)(cn,{scope:t,triggerId:_(),triggerRef:l,contentId:_(),open:u,onOpenChange:d,onOpenToggle:V.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,H.jsx)(Ut,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};un.displayName=an;var dn=`DropdownMenuTrigger`,fn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ln(dn,n),o=Q(n);return(0,H.jsx)(Wt,{asChild:!0,...o,children:(0,H.jsx)(y.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:D(t,a.triggerRef),onPointerDown:T(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:T(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});fn.displayName=dn;var pn=`DropdownMenuPortal`,mn=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Q(t);return(0,H.jsx)(Gt,{...r,...n})};mn.displayName=pn;var hn=`DropdownMenuContent`,gn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ln(hn,n),a=Q(n),o=V.useRef(!1);return(0,H.jsx)(Kt,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:T(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:T(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});gn.displayName=hn;var _n=`DropdownMenuGroup`,vn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(qt,{...i,...r,ref:t})});vn.displayName=_n;var yn=`DropdownMenuLabel`,bn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Jt,{...i,...r,ref:t})});bn.displayName=yn;var xn=`DropdownMenuItem`,Sn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Yt,{...i,...r,ref:t})});Sn.displayName=xn;var Cn=`DropdownMenuCheckboxItem`,wn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Xt,{...i,...r,ref:t})});wn.displayName=Cn;var Tn=`DropdownMenuRadioGroup`,En=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Zt,{...i,...r,ref:t})});En.displayName=Tn;var Dn=`DropdownMenuRadioItem`,On=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Qt,{...i,...r,ref:t})});On.displayName=Dn;var kn=`DropdownMenuItemIndicator`,An=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)($t,{...i,...r,ref:t})});An.displayName=kn;var jn=`DropdownMenuSeparator`,Mn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(en,{...i,...r,ref:t})});Mn.displayName=jn;var Nn=`DropdownMenuArrow`,Pn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(tn,{...i,...r,ref:t})});Pn.displayName=Nn;var Fn=`DropdownMenuSubTrigger`,In=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(nn,{...i,...r,ref:t})});In.displayName=Fn;var Ln=`DropdownMenuSubContent`,Rn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(rn,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Rn.displayName=Ln;var zn=un,Bn=fn,Vn=mn,Hn=gn,Un=bn,Wn=Sn,Gn=wn,Kn=On,qn=An,Jn=Mn,Yn=In,Xn=Rn,Zn=zn,Qn=Bn,$n=V.forwardRef(({className:e,inset:t,children:n,...r},a)=>(0,H.jsxs)(Yn,{ref:a,className:h(`flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-[var(--app-panel-elevated)] data-[state=open]:bg-[var(--app-panel-elevated)] [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...r,children:[n,(0,H.jsx)(i,{className:`ml-auto`})]}));$n.displayName=Yn.displayName;var er=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Xn,{ref:n,className:h(`z-50 min-w-[8rem] overflow-hidden rounded-md border border-[var(--app-border)] bg-[var(--app-panel)] p-1 text-[var(--app-text)] shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));er.displayName=Xn.displayName;var tr=V.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,H.jsx)(Vn,{children:(0,H.jsx)(Hn,{ref:r,sideOffset:t,className:h(`z-50 min-w-[8rem] overflow-hidden rounded-md border border-[var(--app-border)] bg-[var(--app-panel)] p-1 text-[var(--app-text)] shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));tr.displayName=Hn.displayName;var $=V.forwardRef(({className:e,inset:t,...n},r)=>(0,H.jsx)(Wn,{ref:r,className:h(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...n}));$.displayName=Wn.displayName;var nr=V.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,H.jsxs)(Gn,{ref:i,className:h(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,H.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,H.jsx)(qn,{children:(0,H.jsx)(o,{className:`h-4 w-4`})})}),t]}));nr.displayName=Gn.displayName;var rr=V.forwardRef(({className:e,children:t,...n},r)=>(0,H.jsxs)(Kn,{ref:r,className:h(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,H.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,H.jsx)(qn,{children:(0,H.jsx)(u,{className:`h-2 w-2 fill-current`})})}),t]}));rr.displayName=Kn.displayName;var ir=V.forwardRef(({className:e,inset:t,...n},r)=>(0,H.jsx)(Un,{ref:r,className:h(`px-2 py-1.5 text-sm font-semibold text-[var(--app-text)]`,t&&`pl-8`,e),...n}));ir.displayName=Un.displayName;var ar=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Jn,{ref:n,className:h(`-mx-1 my-1 h-px bg-[var(--app-panel-elevated)]`,e),...t}));ar.displayName=Jn.displayName;var or=({className:e,...t})=>(0,H.jsx)(`span`,{className:h(`ml-auto text-xs tracking-widest text-[var(--app-text-subtle)]`,e),...t});or.displayName=`DropdownMenuShortcut`;function sr({plugin:e}){let t=e.manifest;if(!t)return null;let n=[];return t.skills.length>0&&n.push({label:`Skill(${t.skills.length})`,variant:`info`}),t.agents.length>0&&n.push({label:`Agent(${t.agents.length})`,variant:`success`}),t.mcpServers.length>0&&n.push({label:`MCP(${t.mcpServers.length})`,variant:`warning`}),t.hooks.length>0&&n.push({label:`Hook(${t.hooks.length})`,variant:`default`}),t.lspServers.length>0&&n.push({label:`LSP(${t.lspServers.length})`,variant:`default`}),n.length===0?null:(0,H.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:n.map(e=>(0,H.jsx)(P,{variant:e.variant,children:e.label},e.label))})}function cr({plugin:e,roles:t,onInstallToRole:n,onToggleGlobal:r,onUninstallUser:i,projectOperatingKey:a,userOperatingId:o}){let s=o===e.id;return(0,H.jsxs)(Zn,{modal:!1,children:[(0,H.jsx)(Qn,{asChild:!0,children:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-7 w-7 px-0`,"aria-label":`Manage ${e.name}`,children:s?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):(0,H.jsx)(d,{size:L.sm})})}),(0,H.jsxs)(tr,{align:`end`,className:`min-w-[200px]`,children:[t.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ir,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Add to Role`}),t.map(t=>{let r=e.usedByRoles.some(e=>e.roleId===t.id),i=a===`${e.id}:${t.workspacePath}`;return(0,H.jsxs)($,{disabled:i||r,onSelect:()=>{n(e.id,t.workspacePath)},children:[(0,H.jsx)(`span`,{className:`flex-1`,children:t.name}),i?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):r?(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`installed`}):null]},t.id)}),(0,H.jsx)(ar,{})]}):null,(0,H.jsx)($,{disabled:s,onSelect:()=>{r(e.id,!e.globalEnabled)},children:e.globalEnabled?`Disable`:`Enable`}),(0,H.jsx)($,{disabled:s,className:`text-[var(--app-danger)] focus:text-[var(--app-danger)]`,onSelect:()=>{i(e.id)},children:`Uninstall`})]})]})}function lr({plugin:e,roles:t,expandedContent:n,onInstallToRole:r,onToggleGlobal:a,onUninstallUser:o,projectOperatingKey:s,userOperatingId:c}){let[u,d]=(0,V.useState)(!1),f=e.usedByRoles.map(e=>`${e.roleName} (v${e.version})`).join(`, `)||`No Roles`;return(0,H.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`button`,{className:`mt-0.5 text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>d(e=>!e),"aria-label":u?`Collapse ${e.name}`:`Expand ${e.name}`,children:u?(0,H.jsx)(l,{size:L.xs}):(0,H.jsx)(i,{size:L.xs})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`v`,e.version]}),e.marketplace?(0,H.jsx)(P,{variant:`muted`,className:`text-[10px]`,children:e.marketplace}):null,(0,H.jsx)(j,{delayDuration:150,children:(0,H.jsxs)(le,{children:[(0,H.jsx)(se,{asChild:!0,children:(0,H.jsxs)(`button`,{className:`text-xs text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,title:f,children:[e.usedByRoles.length,` `,e.usedByRoles.length===1?`Role`:`Roles`]})}),(0,H.jsx)(M,{children:f})]})})]}),(0,H.jsx)(sr,{plugin:e})]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,H.jsx)(P,{variant:e.globalEnabled?`success`:`destructive`,children:e.globalEnabled?`User On`:`User Off`}),(0,H.jsx)(cr,{plugin:e,roles:t,onInstallToRole:r,onToggleGlobal:a,onUninstallUser:o,projectOperatingKey:s,userOperatingId:c})]})]}),u?(0,H.jsx)(`div`,{className:`mt-4 rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:n}):null]})}function ur({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:e}),(0,H.jsx)(`p`,{className:`mt-1 text-sm font-medium text-[var(--app-text)]`,children:t})]})}function dr({plugin:e}){return e.manifest?(0,H.jsxs)(`div`,{className:`space-y-4 text-xs`,children:[e.manifest.description?(0,H.jsx)(`p`,{className:`text-[var(--app-text-muted)]`,children:e.manifest.description}):null,(0,H.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-4`,children:[(0,H.jsx)(ur,{label:`Version`,value:e.version?`v${e.version}`:`—`}),(0,H.jsx)(ur,{label:`Scope`,value:e.scope}),(0,H.jsx)(ur,{label:`Capability Count`,value:e.manifest.skills.length+e.manifest.agents.length+e.manifest.mcpServers.length+e.manifest.hooks.length+e.manifest.lspServers.length}),(0,H.jsx)(ur,{label:`Activation`,value:e.globalEnabled?`User On`:`User Off`})]}),(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Install Path`}),(0,H.jsx)(`p`,{className:`mt-1 truncate font-mono text-[11px] text-[var(--app-text-muted)]`,title:e.installPath,children:e.installPath})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[e.manifest.skills.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Skills`}),e.manifest.skills.map(e=>(0,H.jsxs)(`div`,{className:`inline-flex items-baseline gap-1 text-[var(--app-text-muted)]`,children:[(0,H.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),e.description?(0,H.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`; `,e.description]}):null]},e.name))]}):null,e.manifest.agents.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Agents`}),e.manifest.agents.map(e=>(0,H.jsxs)(`div`,{className:`inline-flex items-baseline gap-1 text-[var(--app-text-muted)]`,children:[(0,H.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),e.description?(0,H.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`; `,e.description]}):null]},e.name))]}):null,e.manifest.mcpServers.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`MCP Servers`}),e.manifest.mcpServers.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null,e.manifest.hooks.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Hooks`}),e.manifest.hooks.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null,e.manifest.lspServers.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`LSP Servers`}),e.manifest.lspServers.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null]})]}):(0,H.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading manifest...`})}function fr(){let{userScope:e,projectScope:i,loading:a,error:o,refresh:u,rawPlugins:d,roles:p}=xe(),[te,h]=(0,V.useState)(`installed`),[g,ne]=(0,V.useState)([]),[_,v]=(0,V.useState)([]),[y,re]=(0,V.useState)(new Set),[b,ie]=(0,V.useState)(!1),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(``),[ae,oe]=(0,V.useState)(!1),[T,E]=(0,V.useState)(``),[D,A]=(0,V.useState)(null),[se,ce]=(0,V.useState)(null),{operatingKey:j,installToRole:M,uninstallFromRole:le,updateRoleVersion:ue}=ye(u),F=(0,V.useCallback)(async()=>{ie(!0),S(null);try{let[e,t]=await Promise.all([k(`/plugins/marketplace`).catch(()=>({available:[],installed:[]})),k(`/plugins/marketplaces`)]);v(e.available),re(new Set(e.installed.map(e=>e.id))),ne(t.sources)}catch(e){S(e instanceof Error?e.message:`Failed to load marketplace`)}finally{ie(!1)}},[]);(0,V.useEffect)(()=>{F()},[F]);let de=(0,V.useCallback)(async(e,t)=>{A(e);try{await k(`/plugins/${encodeURIComponent(e)}/${t?`enable`:`disable`}`,{method:`POST`}),N.success(`${e} ${t?`enabled`:`disabled`} globally`)}catch(e){N.error(e instanceof Error?e.message:`Failed to ${t?`enable`:`disable`} plugin`)}finally{await u(),A(null)}},[u]),me=(0,V.useCallback)(async e=>{A(e);try{await k(`/plugins/uninstall/${encodeURIComponent(e)}`,{method:`POST`}),N.success(`Plugin uninstalled`)}catch(e){N.error(e instanceof Error?e.message:`Uninstall failed`)}finally{await Promise.all([u(),F()]),A(null)}},[F,u]),Se=(0,V.useCallback)(async()=>{let e=T.trim();if(e)try{await k(`/plugins/marketplaces`,{method:`POST`,body:JSON.stringify({url:e})}),N.success(`Marketplace added`),E(``),oe(!1),await F()}catch(e){N.error(e instanceof Error?e.message:`Failed to add marketplace`)}},[F,T]),Ce=(0,V.useCallback)(async(e,t=`user`,n)=>{ce(e);try{await k(`/plugins/install/${encodeURIComponent(e)}`,{method:`POST`,body:JSON.stringify({scope:t,cwd:n})});let r=t===`project`&&n?`${e.split(`@`)[0]} for ${n.split(`/`).pop()}`:e.split(`@`)[0];N.success(`Installed ${r}`)}catch(e){N.error(e instanceof Error?e.message:`Install failed`)}finally{await Promise.all([u(),F()]),ce(null)}},[F,u]),Te=C?_.filter(e=>e.name.toLowerCase().includes(C.toLowerCase())||e.description.toLowerCase().includes(C.toLowerCase())):_,De=d.filter(e=>e.scope===`project`).length;return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsx)(fe,{eyebrow:`Capabilities`,title:`Plugins`,compact:!0,description:`Installed capabilities, scope, and activation.`,metrics:[{label:`Total`,value:d.length},{label:`Project Scope`,value:De},{label:`Catalog`,value:_.length}],actions:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>void Promise.all([u(),F()]),children:(0,H.jsx)(f,{size:L.sm})})}),(0,H.jsx)(pe,{title:`Plugin Library`,compact:!0,description:`Installed plugins and marketplace discovery live in separate tabs.`}),(0,H.jsxs)(Ae,{value:te,onValueChange:e=>h(e),children:[(0,H.jsxs)(Oe,{children:[(0,H.jsxs)(we,{value:`installed`,children:[`Installed (`,e.length,`)`]}),(0,H.jsxs)(we,{value:`marketplace`,children:[`Marketplace (`,_.length,`)`]})]}),(0,H.jsx)(Ee,{value:`installed`,className:`space-y-5`,children:a?(0,H.jsx)(I,{children:(0,H.jsx)(`div`,{className:`py-8 text-center text-sm text-[var(--app-text-subtle)]`,children:`Loading...`})}):o?(0,H.jsx)(I,{children:(0,H.jsx)(`div`,{className:`py-8 text-center text-sm text-[var(--app-danger)]`,children:o})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(pe,{title:`User scope`,compact:!0,description:`Global defaults. Available to all Roles unless overridden.`}),e.length===0?(0,H.jsx)(I,{children:(0,H.jsx)(he,{icon:(0,H.jsx)(n,{size:L.hero}),title:`No user-scope plugins`,description:`Install a plugin once here to make it available as the default for every Role.`,className:`py-8`})}):(0,H.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,H.jsx)(lr,{plugin:e,roles:p,expandedContent:(0,H.jsx)(dr,{plugin:e}),onInstallToRole:M,onToggleGlobal:de,onUninstallUser:me,projectOperatingKey:j,userOperatingId:D},e.id))})]}),(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(pe,{title:`Project scope`,compact:!0,description:`Role-specific overrides. Only plugins that differ from user scope are shown here.`}),(0,H.jsx)(be,{groups:i,layout:`full`,onUninstall:le,onUpdate:ue,operatingKey:j})]}),(0,H.jsx)(je,{})]})}),(0,H.jsxs)(Ee,{value:`marketplace`,className:`space-y-4`,children:[(0,H.jsxs)(I,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(r,{size:L.sm,className:`flex-shrink-0 text-[var(--app-text-muted)]`}),g.map(e=>(0,H.jsx)(P,{variant:`muted`,className:`text-xs`,children:e.name},e.name)),(0,H.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[b?(0,H.jsx)(m,{size:L.xs,className:`animate-spin text-[var(--app-text-subtle)]`}):null,(0,H.jsxs)(O,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>oe(e=>!e),children:[ae?(0,H.jsx)(s,{size:L.xs}):(0,H.jsx)(t,{size:L.xs}),`Source`]})]})]}),ae?(0,H.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,H.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:T,onChange:e=>E(e.target.value),placeholder:`https://github.com/org/marketplace-repo`,onKeyDown:e=>{e.key===`Enter`&&Se()}}),(0,H.jsx)(O,{size:`sm`,onClick:()=>void Se(),disabled:!T.trim(),children:`Add`})]}):null]}),(0,H.jsx)(I,{children:(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(ee,{size:L.sm,className:`absolute left-2.5 top-2 text-[var(--app-text-subtle)]`}),(0,H.jsx)(`input`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] py-1.5 pl-8 pr-3 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,value:C,onChange:e=>w(e.target.value),placeholder:`Search available plugins...`})]})}),b?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-text-subtle)]`,children:`Loading marketplace...`})}):x?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-danger)]`,children:x})}):Te.length===0?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-text-subtle)]`,children:C?`No plugins match your search`:`No marketplace plugins available`})}):(0,H.jsx)(I,{padding:!1,children:(0,H.jsxs)(ve,{children:[(0,H.jsx)(ge,{children:(0,H.jsxs)(z,{children:[(0,H.jsx)(R,{children:`Name`}),(0,H.jsx)(R,{children:`Description`}),(0,H.jsx)(R,{children:`Source`}),(0,H.jsx)(R,{children:`Action`})]})}),(0,H.jsx)(_e,{children:Te.map(e=>{let t=y.has(e.pluginId),n=se===e.pluginId;return(0,H.jsxs)(z,{children:[(0,H.jsx)(B,{className:`text-xs font-medium text-[var(--app-text)]`,children:e.name}),(0,H.jsx)(B,{className:`max-w-[300px] truncate text-xs text-[var(--app-text-muted)]`,title:e.description,children:e.description}),(0,H.jsx)(B,{children:(0,H.jsx)(P,{variant:`muted`,className:`text-[10px]`,children:e.marketplaceName})}),(0,H.jsx)(B,{children:t?(0,H.jsx)(P,{variant:`success`,className:`text-[10px]`,children:`Installed`}):(0,H.jsxs)(Zn,{modal:!1,children:[(0,H.jsx)(Qn,{asChild:!0,children:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,disabled:n,children:n?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(c,{size:L.xs}),`Install`,(0,H.jsx)(l,{size:L.xs})]})})}),(0,H.jsxs)(tr,{align:`end`,className:`min-w-[200px]`,children:[(0,H.jsx)($,{disabled:n,onSelect:()=>{Ce(e.pluginId)},children:`Install globally (User scope)`}),p.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ar,{}),p.map(t=>(0,H.jsxs)($,{disabled:n,onSelect:()=>{Ce(e.pluginId,`project`,t.workspacePath)},children:[`Install to `,t.name]},t.id))]}):null]})]})})]},e.pluginId)})})]})})]})]})]})}export{fr as Plugins};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,E as n,K as r,ft as i,ht as a,mt as o,n as s,nt as c,pt as l,st as u,tt as d,w as f,x as ee,xt as p,z as m}from"./vendor-icons-Bc_e_XXa.js";import{t as te}from"./vendor-react-bQ_cvNuA.js";import{n as h}from"./dist-CgGno8kE.js";import{_ as g,a as ne,c as _,d as v,f as y,i as re,m as b,n as ie,o as x,p as S,r as C,s as w,t as ae,u as oe,v as T}from"./es2015-BkFSNOYE.js";import{i as E,r as D,t as O}from"./Button-CRNb8sD3.js";import{t as k}from"./api-BP4ZP9kk.js";import{S as A,_ as se,b as ce,g as j,h as M,m as le,p as N,t as P,v as ue,x as F,y as de}from"./index-CXEJd-0s.js";import{t as I}from"./Card-Cwvv0An8.js";import{t as fe}from"./PageHeader-acLQTYct.js";import{t as pe}from"./SectionHeader-NZWZgoOs.js";import{a as me}from"./format-ZWN4JNj-.js";import{t as he}from"./EmptyState-BvQA1o5K.js";import{t as L}from"./ui-D1crlGpt.js";import{a as ge,i as R,n as _e,o as z,r as B,t as ve}from"./Table-CvSmzzkm.js";import{n as ye,r as be,t as xe}from"./usePluginsWithUsage-4iLJAPjH.js";import{a as Se,c as Ce,i as we,l as Te,n as Ee,o as De,r as Oe,s as ke,t as Ae}from"./Tabs-DWk9HyNd.js";var V=e(p(),1),H=te();function je(){let[e,t]=(0,V.useState)(!1),[n,r]=(0,V.useState)([]),o=(0,V.useCallback)(async()=>{try{r((await k(`/plugins/stats?limit=20`)).stats)}catch{r([])}},[]);return(0,H.jsxs)(I,{children:[(0,H.jsxs)(`button`,{className:`flex w-full items-center gap-2 text-sm font-semibold text-[var(--app-text)]`,onClick:()=>{!e&&n.length===0&&o(),t(e=>!e)},children:[(0,H.jsx)(a,{size:L.sm,className:`text-[var(--app-text-muted)]`}),`Usage Stats`,e?(0,H.jsx)(l,{size:L.xs,className:`ml-auto`}):(0,H.jsx)(i,{size:L.xs,className:`ml-auto`})]}),e?(0,H.jsx)(`div`,{className:`mt-3`,children:n.length===0?(0,H.jsx)(`p`,{className:`py-2 text-center text-xs text-[var(--app-text-subtle)]`,children:`No usage data yet`}):(0,H.jsxs)(ve,{children:[(0,H.jsx)(ge,{children:(0,H.jsxs)(z,{children:[(0,H.jsx)(R,{children:`Plugin`}),(0,H.jsx)(R,{children:`Usage Count`}),(0,H.jsx)(R,{children:`Last Used`})]})}),(0,H.jsx)(_e,{children:n.map(e=>(0,H.jsxs)(z,{children:[(0,H.jsx)(B,{className:`text-xs font-medium text-[var(--app-text)]`,children:e.pluginName}),(0,H.jsx)(B,{className:`font-mono text-xs text-[var(--app-text-muted)]`,children:e.usageCount}),(0,H.jsx)(B,{className:`text-xs text-[var(--app-text-muted)]`,children:e.lastUsed?me(e.lastUsed):`—`})]},e.pluginPath))})]})}):null]})}var Me=[`Enter`,` `],Ne=[`ArrowDown`,`PageUp`,`Home`],Pe=[`ArrowUp`,`PageDown`,`End`],Fe=[...Ne,...Pe],Ie={ltr:[...Me,`ArrowRight`],rtl:[...Me,`ArrowLeft`]},Le={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},U=`Menu`,[W,Re,ze]=Te(U),[G,Be]=g(U,[ze,A,ke]),K=A(),Ve=ke(),[He,q]=G(U),[Ue,J]=G(U),We=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=K(t),[c,l]=V.useState(null),u=V.useRef(!1),d=v(a),f=Ce(i);return V.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),(0,H.jsx)(F,{...s,children:(0,H.jsx)(He,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,H.jsx)(Ue,{scope:t,onClose:V.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};We.displayName=U;var Ge=`MenuAnchor`,Ke=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=K(n);return(0,H.jsx)(ue,{...i,...r,ref:t})});Ke.displayName=Ge;var qe=`MenuPortal`,[Je,Ye]=G(qe,{forceMount:void 0}),Xe=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=q(qe,t);return(0,H.jsx)(Je,{scope:t,forceMount:n,children:(0,H.jsx)(x,{present:n||a.open,children:(0,H.jsx)(w,{asChild:!0,container:i,children:r})})})};Xe.displayName=qe;var Y=`MenuContent`,[Ze,Qe]=G(Y),$e=V.forwardRef((e,t)=>{let n=Ye(Y,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeMenu),o=J(Y,e.__scopeMenu);return(0,H.jsx)(W.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(x,{present:r||a.open,children:(0,H.jsx)(W.Slot,{scope:e.__scopeMenu,children:o.modal?(0,H.jsx)(et,{...i,ref:t}):(0,H.jsx)(tt,{...i,ref:t})})})})}),et=V.forwardRef((e,t)=>{let n=q(Y,e.__scopeMenu),r=V.useRef(null),i=E(t,r);return V.useEffect(()=>{let e=r.current;if(e)return ae(e)},[]),(0,H.jsx)(rt,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:T(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),tt=V.forwardRef((e,t)=>{let n=q(Y,e.__scopeMenu);return(0,H.jsx)(rt,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),nt=b(`MenuContent.ScrollLock`),rt=V.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:ee,disableOutsideScroll:p,...m}=e,te=q(Y,n),h=J(Y,n),g=K(n),ne=Ve(n),_=Re(n),[v,y]=V.useState(null),b=V.useRef(null),x=E(t,b,te.onContentChange),S=V.useRef(0),w=V.useRef(``),ae=V.useRef(0),D=V.useRef(null),O=V.useRef(`right`),k=V.useRef(0),A=p?ie:V.Fragment,se=p?{as:nt,allowPinchZoom:!0}:void 0,j=e=>{let t=w.current+e,n=_().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Bt(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){w.current=t,window.clearTimeout(S.current),t!==``&&(S.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};V.useEffect(()=>()=>window.clearTimeout(S.current),[]),C();let M=V.useCallback(e=>O.current===D.current?.side&&Ht(e,D.current?.area),[]);return(0,H.jsx)(Ze,{scope:n,searchRef:w,onItemEnter:V.useCallback(e=>{M(e)&&e.preventDefault()},[M]),onItemLeave:V.useCallback(e=>{M(e)||(b.current?.focus(),y(null))},[M]),onTriggerLeave:V.useCallback(e=>{M(e)&&e.preventDefault()},[M]),pointerGraceTimerRef:ae,onPointerGraceIntentChange:V.useCallback(e=>{D.current=e},[]),children:(0,H.jsx)(A,{...se,children:(0,H.jsx)(re,{asChild:!0,trapped:i,onMountAutoFocus:T(a,e=>{e.preventDefault(),b.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,H.jsx)(oe,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:ee,children:(0,H.jsx)(De,{asChild:!0,...ne,dir:h.dir,orientation:`vertical`,loop:r,currentTabStopId:v,onCurrentTabStopIdChange:y,onEntryFocus:T(c,e=>{h.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,H.jsx)(ce,{role:`menu`,"aria-orientation":`vertical`,"data-state":Ft(te.open),"data-radix-menu-content":``,dir:h.dir,...g,...m,ref:x,style:{outline:`none`,...m.style},onKeyDown:T(m.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&j(e.key));let i=b.current;if(e.target!==i||!Fe.includes(e.key))return;e.preventDefault();let a=_().filter(e=>!e.disabled).map(e=>e.ref.current);Pe.includes(e.key)&&a.reverse(),Rt(a)}),onBlur:T(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(S.current),w.current=``)}),onPointerMove:T(e.onPointerMove,Z(e=>{let t=e.target,n=k.current!==e.clientX;e.currentTarget.contains(t)&&n&&(O.current=e.clientX>k.current?`right`:`left`,k.current=e.clientX)}))})})})})})})});$e.displayName=Y;var it=`MenuGroup`,at=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{role:`group`,...r,ref:t})});at.displayName=it;var ot=`MenuLabel`,st=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{...r,ref:t})});st.displayName=ot;var ct=`MenuItem`,lt=`menu.itemSelect`,ut=V.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=V.useRef(null),o=J(ct,e.__scopeMenu),s=Qe(ct,e.__scopeMenu),c=E(t,a),l=V.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(lt,{bubbles:!0,cancelable:!0});e.addEventListener(lt,e=>r?.(e),{once:!0}),S(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,H.jsx)(dt,{...i,ref:c,disabled:n,onClick:T(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:T(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:T(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||Me.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});ut.displayName=ct;var dt=V.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Qe(ct,n),s=Ve(n),c=V.useRef(null),l=E(t,c),[u,d]=V.useState(!1),[f,ee]=V.useState(``);return V.useEffect(()=>{let e=c.current;e&&ee((e.textContent??``).trim())},[a.children]),(0,H.jsx)(W.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,H.jsx)(Se,{asChild:!0,...s,focusable:!r,children:(0,H.jsx)(y.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:T(e.onPointerMove,Z(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:T(e.onPointerLeave,Z(e=>o.onItemLeave(e))),onFocus:T(e.onFocus,()=>d(!0)),onBlur:T(e.onBlur,()=>d(!1))})})})}),ft=`MenuCheckboxItem`,pt=V.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,H.jsx)(xt,{scope:e.__scopeMenu,checked:n,children:(0,H.jsx)(ut,{role:`menuitemcheckbox`,"aria-checked":It(n)?`mixed`:n,...i,ref:t,"data-state":Lt(n),onSelect:T(i.onSelect,()=>r?.(It(n)?!0:!n),{checkForDefaultPrevented:!1})})})});pt.displayName=ft;var mt=`MenuRadioGroup`,[ht,gt]=G(mt,{value:void 0,onValueChange:()=>{}}),_t=V.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=v(r);return(0,H.jsx)(ht,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,H.jsx)(at,{...i,ref:t})})});_t.displayName=mt;var vt=`MenuRadioItem`,yt=V.forwardRef((e,t)=>{let{value:n,...r}=e,i=gt(vt,e.__scopeMenu),a=n===i.value;return(0,H.jsx)(xt,{scope:e.__scopeMenu,checked:a,children:(0,H.jsx)(ut,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Lt(a),onSelect:T(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});yt.displayName=vt;var bt=`MenuItemIndicator`,[xt,St]=G(bt,{checked:!1}),Ct=V.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=St(bt,n);return(0,H.jsx)(x,{present:r||It(a.checked)||a.checked===!0,children:(0,H.jsx)(y.span,{...i,ref:t,"data-state":Lt(a.checked)})})});Ct.displayName=bt;var wt=`MenuSeparator`,Tt=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,H.jsx)(y.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Tt.displayName=wt;var Et=`MenuArrow`,Dt=V.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=K(n);return(0,H.jsx)(de,{...i,...r,ref:t})});Dt.displayName=Et;var Ot=`MenuSub`,[kt,At]=G(Ot),jt=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=q(Ot,t),o=K(t),[s,c]=V.useState(null),[l,u]=V.useState(null),d=v(i);return V.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,H.jsx)(F,{...o,children:(0,H.jsx)(He,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,H.jsx)(kt,{scope:t,contentId:_(),triggerId:_(),trigger:s,onTriggerChange:c,children:n})})})};jt.displayName=Ot;var X=`MenuSubTrigger`,Mt=V.forwardRef((e,t)=>{let n=q(X,e.__scopeMenu),r=J(X,e.__scopeMenu),i=At(X,e.__scopeMenu),a=Qe(X,e.__scopeMenu),o=V.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=V.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return V.useEffect(()=>u,[u]),V.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,H.jsx)(Ke,{asChild:!0,...l,children:(0,H.jsx)(dt,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":Ft(n.open),...e,ref:D(t,i.onTriggerChange),onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:T(e.onPointerMove,Z(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:T(e.onPointerLeave,Z(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:T(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||Ie[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Mt.displayName=X;var Nt=`MenuSubContent`,Pt=V.forwardRef((e,t)=>{let n=Ye(Y,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=q(Y,e.__scopeMenu),o=J(Y,e.__scopeMenu),s=At(Nt,e.__scopeMenu),c=V.useRef(null),l=E(t,c);return(0,H.jsx)(W.Provider,{scope:e.__scopeMenu,children:(0,H.jsx)(x,{present:r||a.open,children:(0,H.jsx)(W.Slot,{scope:e.__scopeMenu,children:(0,H.jsx)(rt,{id:s.contentId,"aria-labelledby":s.triggerId,...i,ref:l,align:`start`,side:o.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{o.isUsingKeyboardRef.current&&c.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:T(e.onFocusOutside,e=>{e.target!==s.trigger&&a.onOpenChange(!1)}),onEscapeKeyDown:T(e.onEscapeKeyDown,e=>{o.onClose(),e.preventDefault()}),onKeyDown:T(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Le[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Pt.displayName=Nt;function Ft(e){return e?`open`:`closed`}function It(e){return e===`indeterminate`}function Lt(e){return It(e)?`indeterminate`:e?`checked`:`unchecked`}function Rt(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function zt(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Bt(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=zt(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Vt(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Ht(e,t){return t?Vt({x:e.clientX,y:e.clientY},t):!1}function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}var Ut=We,Wt=Ke,Gt=Xe,Kt=$e,qt=at,Jt=st,Yt=ut,Xt=pt,Zt=_t,Qt=yt,$t=Ct,en=Tt,tn=Dt,nn=Mt,rn=Pt,an=`DropdownMenu`,[on,sn]=g(an,[Be]),Q=Be(),[cn,ln]=on(an),un=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Q(t),l=V.useRef(null),[u,d]=ne({prop:i,defaultProp:a??!1,onChange:o,caller:an});return(0,H.jsx)(cn,{scope:t,triggerId:_(),triggerRef:l,contentId:_(),open:u,onOpenChange:d,onOpenToggle:V.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,H.jsx)(Ut,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};un.displayName=an;var dn=`DropdownMenuTrigger`,fn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ln(dn,n),o=Q(n);return(0,H.jsx)(Wt,{asChild:!0,...o,children:(0,H.jsx)(y.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:D(t,a.triggerRef),onPointerDown:T(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:T(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});fn.displayName=dn;var pn=`DropdownMenuPortal`,mn=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Q(t);return(0,H.jsx)(Gt,{...r,...n})};mn.displayName=pn;var hn=`DropdownMenuContent`,gn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ln(hn,n),a=Q(n),o=V.useRef(!1);return(0,H.jsx)(Kt,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:T(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:T(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});gn.displayName=hn;var _n=`DropdownMenuGroup`,vn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(qt,{...i,...r,ref:t})});vn.displayName=_n;var yn=`DropdownMenuLabel`,bn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Jt,{...i,...r,ref:t})});bn.displayName=yn;var xn=`DropdownMenuItem`,Sn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Yt,{...i,...r,ref:t})});Sn.displayName=xn;var Cn=`DropdownMenuCheckboxItem`,wn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Xt,{...i,...r,ref:t})});wn.displayName=Cn;var Tn=`DropdownMenuRadioGroup`,En=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Zt,{...i,...r,ref:t})});En.displayName=Tn;var Dn=`DropdownMenuRadioItem`,On=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(Qt,{...i,...r,ref:t})});On.displayName=Dn;var kn=`DropdownMenuItemIndicator`,An=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)($t,{...i,...r,ref:t})});An.displayName=kn;var jn=`DropdownMenuSeparator`,Mn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(en,{...i,...r,ref:t})});Mn.displayName=jn;var Nn=`DropdownMenuArrow`,Pn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(tn,{...i,...r,ref:t})});Pn.displayName=Nn;var Fn=`DropdownMenuSubTrigger`,In=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(nn,{...i,...r,ref:t})});In.displayName=Fn;var Ln=`DropdownMenuSubContent`,Rn=V.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,H.jsx)(rn,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Rn.displayName=Ln;var zn=un,Bn=fn,Vn=mn,Hn=gn,Un=bn,Wn=Sn,Gn=wn,Kn=On,qn=An,Jn=Mn,Yn=In,Xn=Rn,Zn=zn,Qn=Bn,$n=V.forwardRef(({className:e,inset:t,children:n,...r},a)=>(0,H.jsxs)(Yn,{ref:a,className:h(`flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-[var(--app-panel-elevated)] data-[state=open]:bg-[var(--app-panel-elevated)] [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...r,children:[n,(0,H.jsx)(i,{className:`ml-auto`})]}));$n.displayName=Yn.displayName;var er=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Xn,{ref:n,className:h(`z-50 min-w-[8rem] overflow-hidden rounded-md border border-[var(--app-border)] bg-[var(--app-panel)] p-1 text-[var(--app-text)] shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));er.displayName=Xn.displayName;var tr=V.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,H.jsx)(Vn,{children:(0,H.jsx)(Hn,{ref:r,sideOffset:t,className:h(`z-50 min-w-[8rem] overflow-hidden rounded-md border border-[var(--app-border)] bg-[var(--app-panel)] p-1 text-[var(--app-text)] shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));tr.displayName=Hn.displayName;var $=V.forwardRef(({className:e,inset:t,...n},r)=>(0,H.jsx)(Wn,{ref:r,className:h(`relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,t&&`pl-8`,e),...n}));$.displayName=Wn.displayName;var nr=V.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,H.jsxs)(Gn,{ref:i,className:h(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),checked:n,...r,children:[(0,H.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,H.jsx)(qn,{children:(0,H.jsx)(o,{className:`h-4 w-4`})})}),t]}));nr.displayName=Gn.displayName;var rr=V.forwardRef(({className:e,children:t,...n},r)=>(0,H.jsxs)(Kn,{ref:r,className:h(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-[var(--app-panel-elevated)] focus:text-[var(--app-text)] data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,e),...n,children:[(0,H.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,H.jsx)(qn,{children:(0,H.jsx)(u,{className:`h-2 w-2 fill-current`})})}),t]}));rr.displayName=Kn.displayName;var ir=V.forwardRef(({className:e,inset:t,...n},r)=>(0,H.jsx)(Un,{ref:r,className:h(`px-2 py-1.5 text-sm font-semibold text-[var(--app-text)]`,t&&`pl-8`,e),...n}));ir.displayName=Un.displayName;var ar=V.forwardRef(({className:e,...t},n)=>(0,H.jsx)(Jn,{ref:n,className:h(`-mx-1 my-1 h-px bg-[var(--app-panel-elevated)]`,e),...t}));ar.displayName=Jn.displayName;var or=({className:e,...t})=>(0,H.jsx)(`span`,{className:h(`ml-auto text-xs tracking-widest text-[var(--app-text-subtle)]`,e),...t});or.displayName=`DropdownMenuShortcut`;function sr({plugin:e}){let t=e.manifest;if(!t)return null;let n=[];return t.skills.length>0&&n.push({label:`Skill(${t.skills.length})`,variant:`info`}),t.agents.length>0&&n.push({label:`Agent(${t.agents.length})`,variant:`success`}),t.mcpServers.length>0&&n.push({label:`MCP(${t.mcpServers.length})`,variant:`warning`}),t.hooks.length>0&&n.push({label:`Hook(${t.hooks.length})`,variant:`default`}),t.lspServers.length>0&&n.push({label:`LSP(${t.lspServers.length})`,variant:`default`}),n.length===0?null:(0,H.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:n.map(e=>(0,H.jsx)(P,{variant:e.variant,children:e.label},e.label))})}function cr({plugin:e,roles:t,onInstallToRole:n,onToggleGlobal:r,onUninstallUser:i,projectOperatingKey:a,userOperatingId:o}){let s=o===e.id;return(0,H.jsxs)(Zn,{modal:!1,children:[(0,H.jsx)(Qn,{asChild:!0,children:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-7 w-7 px-0`,"aria-label":`Manage ${e.name}`,children:s?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):(0,H.jsx)(d,{size:L.sm})})}),(0,H.jsxs)(tr,{align:`end`,className:`min-w-[200px]`,children:[t.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ir,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Add to Role`}),t.map(t=>{let r=e.usedByRoles.some(e=>e.roleId===t.id),i=a===`${e.id}:${t.workspacePath}`;return(0,H.jsxs)($,{disabled:i||r,onSelect:()=>{n(e.id,t.workspacePath)},children:[(0,H.jsx)(`span`,{className:`flex-1`,children:t.name}),i?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):r?(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`installed`}):null]},t.id)}),(0,H.jsx)(ar,{})]}):null,(0,H.jsx)($,{disabled:s,onSelect:()=>{r(e.id,!e.globalEnabled)},children:e.globalEnabled?`Disable`:`Enable`}),(0,H.jsx)($,{disabled:s,className:`text-[var(--app-danger)] focus:text-[var(--app-danger)]`,onSelect:()=>{i(e.id)},children:`Uninstall`})]})]})}function lr({plugin:e,roles:t,expandedContent:n,onInstallToRole:r,onToggleGlobal:a,onUninstallUser:o,projectOperatingKey:s,userOperatingId:c}){let[u,d]=(0,V.useState)(!1),f=e.usedByRoles.map(e=>`${e.roleName} (v${e.version})`).join(`, `)||`No Roles`;return(0,H.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,H.jsx)(`button`,{className:`mt-0.5 text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>d(e=>!e),"aria-label":u?`Collapse ${e.name}`:`Expand ${e.name}`,children:u?(0,H.jsx)(l,{size:L.xs}):(0,H.jsx)(i,{size:L.xs})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`v`,e.version]}),e.marketplace?(0,H.jsx)(P,{variant:`muted`,className:`text-[10px]`,children:e.marketplace}):null,(0,H.jsx)(j,{delayDuration:150,children:(0,H.jsxs)(le,{children:[(0,H.jsx)(se,{asChild:!0,children:(0,H.jsxs)(`button`,{className:`text-xs text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,title:f,children:[e.usedByRoles.length,` `,e.usedByRoles.length===1?`Role`:`Roles`]})}),(0,H.jsx)(M,{children:f})]})})]}),(0,H.jsx)(sr,{plugin:e})]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,H.jsx)(P,{variant:e.globalEnabled?`success`:`destructive`,children:e.globalEnabled?`User On`:`User Off`}),(0,H.jsx)(cr,{plugin:e,roles:t,onInstallToRole:r,onToggleGlobal:a,onUninstallUser:o,projectOperatingKey:s,userOperatingId:c})]})]}),u?(0,H.jsx)(`div`,{className:`mt-4 rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:n}):null]})}function ur({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:e}),(0,H.jsx)(`p`,{className:`mt-1 text-sm font-medium text-[var(--app-text)]`,children:t})]})}function dr({plugin:e}){return e.manifest?(0,H.jsxs)(`div`,{className:`space-y-4 text-xs`,children:[e.manifest.description?(0,H.jsx)(`p`,{className:`text-[var(--app-text-muted)]`,children:e.manifest.description}):null,(0,H.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-4`,children:[(0,H.jsx)(ur,{label:`Version`,value:e.version?`v${e.version}`:`—`}),(0,H.jsx)(ur,{label:`Scope`,value:e.scope}),(0,H.jsx)(ur,{label:`Capability Count`,value:e.manifest.skills.length+e.manifest.agents.length+e.manifest.mcpServers.length+e.manifest.hooks.length+e.manifest.lspServers.length}),(0,H.jsx)(ur,{label:`Activation`,value:e.globalEnabled?`User On`:`User Off`})]}),(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,H.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Install Path`}),(0,H.jsx)(`p`,{className:`mt-1 truncate font-mono text-[11px] text-[var(--app-text-muted)]`,title:e.installPath,children:e.installPath})]}),(0,H.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[e.manifest.skills.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Skills`}),e.manifest.skills.map(e=>(0,H.jsxs)(`div`,{className:`inline-flex items-baseline gap-1 text-[var(--app-text-muted)]`,children:[(0,H.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),e.description?(0,H.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`; `,e.description]}):null]},e.name))]}):null,e.manifest.agents.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Agents`}),e.manifest.agents.map(e=>(0,H.jsxs)(`div`,{className:`inline-flex items-baseline gap-1 text-[var(--app-text-muted)]`,children:[(0,H.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),e.description?(0,H.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`; `,e.description]}):null]},e.name))]}):null,e.manifest.mcpServers.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`MCP Servers`}),e.manifest.mcpServers.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null,e.manifest.hooks.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Hooks`}),e.manifest.hooks.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null,e.manifest.lspServers.length>0?(0,H.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,H.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`LSP Servers`}),e.manifest.lspServers.map(e=>(0,H.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null]})]}):(0,H.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading manifest...`})}function fr(){let{userScope:e,projectScope:i,loading:a,error:o,refresh:u,rawPlugins:d,roles:p}=xe(),[te,h]=(0,V.useState)(`installed`),[g,ne]=(0,V.useState)([]),[_,v]=(0,V.useState)([]),[y,re]=(0,V.useState)(new Set),[b,ie]=(0,V.useState)(!1),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(``),[ae,oe]=(0,V.useState)(!1),[T,E]=(0,V.useState)(``),[D,A]=(0,V.useState)(null),[se,ce]=(0,V.useState)(null),{operatingKey:j,installToRole:M,uninstallFromRole:le,updateRoleVersion:ue}=ye(u),F=(0,V.useCallback)(async()=>{ie(!0),S(null);try{let[e,t]=await Promise.all([k(`/plugins/marketplace`).catch(()=>({available:[],installed:[]})),k(`/plugins/marketplaces`)]);v(e.available),re(new Set(e.installed.map(e=>e.id))),ne(t.sources)}catch(e){S(e instanceof Error?e.message:`Failed to load marketplace`)}finally{ie(!1)}},[]);(0,V.useEffect)(()=>{F()},[F]);let de=(0,V.useCallback)(async(e,t)=>{A(e);try{await k(`/plugins/${encodeURIComponent(e)}/${t?`enable`:`disable`}`,{method:`POST`}),N.success(`${e} ${t?`enabled`:`disabled`} globally`)}catch(e){N.error(e instanceof Error?e.message:`Failed to ${t?`enable`:`disable`} plugin`)}finally{await u(),A(null)}},[u]),me=(0,V.useCallback)(async e=>{A(e);try{await k(`/plugins/uninstall/${encodeURIComponent(e)}`,{method:`POST`}),N.success(`Plugin uninstalled`)}catch(e){N.error(e instanceof Error?e.message:`Uninstall failed`)}finally{await Promise.all([u(),F()]),A(null)}},[F,u]),Se=(0,V.useCallback)(async()=>{let e=T.trim();if(e)try{await k(`/plugins/marketplaces`,{method:`POST`,body:JSON.stringify({url:e})}),N.success(`Marketplace added`),E(``),oe(!1),await F()}catch(e){N.error(e instanceof Error?e.message:`Failed to add marketplace`)}},[F,T]),Ce=(0,V.useCallback)(async(e,t=`user`,n)=>{ce(e);try{await k(`/plugins/install/${encodeURIComponent(e)}`,{method:`POST`,body:JSON.stringify({scope:t,cwd:n})});let r=t===`project`&&n?`${e.split(`@`)[0]} for ${n.split(`/`).pop()}`:e.split(`@`)[0];N.success(`Installed ${r}`)}catch(e){N.error(e instanceof Error?e.message:`Install failed`)}finally{await Promise.all([u(),F()]),ce(null)}},[F,u]),Te=C?_.filter(e=>e.name.toLowerCase().includes(C.toLowerCase())||e.description.toLowerCase().includes(C.toLowerCase())):_,De=d.filter(e=>e.scope===`project`).length;return(0,H.jsxs)(`div`,{className:`space-y-5`,children:[(0,H.jsx)(fe,{eyebrow:`Capabilities`,title:`Plugins`,compact:!0,description:`Installed capabilities, scope, and activation.`,metrics:[{label:`Total`,value:d.length},{label:`Project Scope`,value:De},{label:`Catalog`,value:_.length}],actions:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>void Promise.all([u(),F()]),children:(0,H.jsx)(f,{size:L.sm})})}),(0,H.jsx)(pe,{title:`Plugin Library`,compact:!0,description:`Installed plugins and marketplace discovery live in separate tabs.`}),(0,H.jsxs)(Ae,{value:te,onValueChange:e=>h(e),children:[(0,H.jsxs)(Oe,{children:[(0,H.jsxs)(we,{value:`installed`,children:[`Installed (`,e.length,`)`]}),(0,H.jsxs)(we,{value:`marketplace`,children:[`Marketplace (`,_.length,`)`]})]}),(0,H.jsx)(Ee,{value:`installed`,className:`space-y-5`,children:a?(0,H.jsx)(I,{children:(0,H.jsx)(`div`,{className:`py-8 text-center text-sm text-[var(--app-text-subtle)]`,children:`Loading...`})}):o?(0,H.jsx)(I,{children:(0,H.jsx)(`div`,{className:`py-8 text-center text-sm text-[var(--app-danger)]`,children:o})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(pe,{title:`User scope`,compact:!0,description:`Global defaults. Available to all Roles unless overridden.`}),e.length===0?(0,H.jsx)(I,{children:(0,H.jsx)(he,{icon:(0,H.jsx)(n,{size:L.hero}),title:`No user-scope plugins`,description:`Install a plugin once here to make it available as the default for every Role.`,className:`py-8`})}):(0,H.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,H.jsx)(lr,{plugin:e,roles:p,expandedContent:(0,H.jsx)(dr,{plugin:e}),onInstallToRole:M,onToggleGlobal:de,onUninstallUser:me,projectOperatingKey:j,userOperatingId:D},e.id))})]}),(0,H.jsxs)(`section`,{className:`space-y-3`,children:[(0,H.jsx)(pe,{title:`Project scope`,compact:!0,description:`Role-specific overrides. Only plugins that differ from user scope are shown here.`}),(0,H.jsx)(be,{groups:i,layout:`full`,onUninstall:le,onUpdate:ue,operatingKey:j})]}),(0,H.jsx)(je,{})]})}),(0,H.jsxs)(Ee,{value:`marketplace`,className:`space-y-4`,children:[(0,H.jsxs)(I,{children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(r,{size:L.sm,className:`flex-shrink-0 text-[var(--app-text-muted)]`}),g.map(e=>(0,H.jsx)(P,{variant:`muted`,className:`text-xs`,children:e.name},e.name)),(0,H.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[b?(0,H.jsx)(m,{size:L.xs,className:`animate-spin text-[var(--app-text-subtle)]`}):null,(0,H.jsxs)(O,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>oe(e=>!e),children:[ae?(0,H.jsx)(s,{size:L.xs}):(0,H.jsx)(t,{size:L.xs}),`Source`]})]})]}),ae?(0,H.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,H.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:T,onChange:e=>E(e.target.value),placeholder:`https://github.com/org/marketplace-repo`,onKeyDown:e=>{e.key===`Enter`&&Se()}}),(0,H.jsx)(O,{size:`sm`,onClick:()=>void Se(),disabled:!T.trim(),children:`Add`})]}):null]}),(0,H.jsx)(I,{children:(0,H.jsxs)(`div`,{className:`relative`,children:[(0,H.jsx)(ee,{size:L.sm,className:`absolute left-2.5 top-2 text-[var(--app-text-subtle)]`}),(0,H.jsx)(`input`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] py-1.5 pl-8 pr-3 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,value:C,onChange:e=>w(e.target.value),placeholder:`Search available plugins...`})]})}),b?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-text-subtle)]`,children:`Loading marketplace...`})}):x?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-danger)]`,children:x})}):Te.length===0?(0,H.jsx)(I,{children:(0,H.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-text-subtle)]`,children:C?`No plugins match your search`:`No marketplace plugins available`})}):(0,H.jsx)(I,{padding:!1,children:(0,H.jsxs)(ve,{children:[(0,H.jsx)(ge,{children:(0,H.jsxs)(z,{children:[(0,H.jsx)(R,{children:`Name`}),(0,H.jsx)(R,{children:`Description`}),(0,H.jsx)(R,{children:`Source`}),(0,H.jsx)(R,{children:`Action`})]})}),(0,H.jsx)(_e,{children:Te.map(e=>{let t=y.has(e.pluginId),n=se===e.pluginId;return(0,H.jsxs)(z,{children:[(0,H.jsx)(B,{className:`text-xs font-medium text-[var(--app-text)]`,children:e.name}),(0,H.jsx)(B,{className:`max-w-[300px] truncate text-xs text-[var(--app-text-muted)]`,title:e.description,children:e.description}),(0,H.jsx)(B,{children:(0,H.jsx)(P,{variant:`muted`,className:`text-[10px]`,children:e.marketplaceName})}),(0,H.jsx)(B,{children:t?(0,H.jsx)(P,{variant:`success`,className:`text-[10px]`,children:`Installed`}):(0,H.jsxs)(Zn,{modal:!1,children:[(0,H.jsx)(Qn,{asChild:!0,children:(0,H.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,disabled:n,children:n?(0,H.jsx)(m,{size:L.xs,className:`animate-spin`}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(c,{size:L.xs}),`Install`,(0,H.jsx)(l,{size:L.xs})]})})}),(0,H.jsxs)(tr,{align:`end`,className:`min-w-[200px]`,children:[(0,H.jsx)($,{disabled:n,onSelect:()=>{Ce(e.pluginId)},children:`Install globally (User scope)`}),p.length>0?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ar,{}),p.map(t=>(0,H.jsxs)($,{disabled:n,onSelect:()=>{Ce(e.pluginId,`project`,t.workspacePath)},children:[`Install to `,t.name]},t.id))]}):null]})]})})]},e.pluginId)})})]})})]})]})]})}export{fr as Plugins};
@@ -0,0 +1,3 @@
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,R as n,vt as r,xt as i}from"./vendor-icons-Bc_e_XXa.js";import{d as a,f as o,r as s,t as c}from"./vendor-react-bQ_cvNuA.js";import{r as l}from"./dist-CgGno8kE.js";import"./es2015-BkFSNOYE.js";import{t as u}from"./Button-CRNb8sD3.js";import{f as d,g as f,h as p,r as m,t as h,x as g}from"./api-BP4ZP9kk.js";import{a as _,c as v,d as y,f as b,i as x,l as S,o as C,p as w,r as T,s as E,t as D,u as O}from"./index-CXEJd-0s.js";import{a as k,i as A,n as j,t as M}from"./Card-Cwvv0An8.js";import{t as N}from"./PageHeader-acLQTYct.js";import{t as P}from"./SectionHeader-NZWZgoOs.js";import{a as F,n as I,t as ee}from"./format-ZWN4JNj-.js";import"./EmptyState-BvQA1o5K.js";import{t as L}from"./ui-D1crlGpt.js";import{t as te}from"./useIsMobileLayout-BogOiFTv.js";import{$ as ne,C as R,D as z,Et as re,F as ie,L as ae,P as oe,Q as se,T as ce,a as B,bt as V,d as H,dt as le,et as ue,f as de,ft as U,i as fe,k as W,l as pe,mt as me,r as he,st as G,t as ge,u as _e,w as ve,wt as ye}from"./LineChart-Ck1vfYHs.js";import{a as be,i as K,n as xe,o as q,r as J,t as Se}from"./Table-CvSmzzkm.js";import{t as Y}from"./Switch-1JjR4Imr.js";import{n as X,r as Ce,t as we}from"./usePluginsWithUsage-4iLJAPjH.js";import{t as Te}from"./EnvVarEditor-FiiJazzp.js";var Ee=class{constructor(e){var{x:t,y:n}=e;this.xAxisScale=t,this.yAxisScale=n}map(e,t){var{position:n}=t;return{x:this.xAxisScale.map(e.x,{position:n})??0,y:this.yAxisScale.map(e.y,{position:n})??0}}mapWithFallback(e,t){var{position:n,fallback:r}=t,i=r===`rangeMin`?this.yAxisScale.rangeMin():r===`rangeMax`?this.yAxisScale.rangeMax():0,a=r===`rangeMin`?this.xAxisScale.rangeMin():r===`rangeMax`?this.xAxisScale.rangeMax():0;return{x:this.xAxisScale.map(e.x,{position:n})??a,y:this.yAxisScale.map(e.y,{position:n})??i}}isInRange(e){var{x:t,y:n}=e,r=t==null||this.xAxisScale.isInRange(t),i=n==null||this.yAxisScale.isInRange(n);return r&&i}},Z=e(i());function De(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?De(Object(n),!0).forEach(function(t){Oe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):De(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Oe(e,t,n){return(t=ke(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ke(e){var t=Ae(e,`string`);return typeof t==`symbol`?t:t+``}function Ae(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function je(){return je=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},je.apply(null,arguments)}var Me=(e,t)=>{var n;if(Z.isValidElement(e))n=Z.cloneElement(e,t);else if(typeof e==`function`)n=e(t);else{if(!G(t.x1)||!G(t.y1)||!G(t.x2)||!G(t.y2))return null;n=Z.createElement(`line`,je({},t,{className:`recharts-reference-line-line`}))}return n},Ne=(e,t,n,r,i,a)=>{var{x:o,width:s}=a,c=i.map(e,{position:n});if(!G(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:o+s,y:c},{x:o,y:c}];return r===`left`?l.reverse():l},Pe=(e,t,n,r,i,a)=>{var{y:o,height:s}=a,c=i.map(e,{position:n});if(!G(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:c,y:o+s},{x:c,y:o}];return r===`top`?l.reverse():l},Fe=(e,t,n,r)=>{var i=[r.mapWithFallback(e[0],{position:n,fallback:`rangeMin`}),r.mapWithFallback(e[1],{position:n,fallback:`rangeMax`})];return t===`discard`&&i.some(e=>!r.isInRange(e))?null:i},Ie=(e,t,n,r,i,a,o)=>{var{x:s,y:c,segment:l,ifOverflow:u}=o,d=V(s);return V(c)?Ne(c,u,r,a,t,n):d?Pe(s,u,r,i,e,n):l!=null&&l.length===2?Fe(l,u,r,new Ee({x:e,y:t})):null};function Le(e){var t=le();return(0,Z.useEffect)(()=>(t(_e(e)),()=>{t(H(e))})),null}function Re(e){var{xAxisId:t,yAxisId:n,shape:r,className:i,ifOverflow:a}=e,o=ue(),s=pe(),c=U(e=>oe(e,t)),u=U(e=>ie(e,n)),d=U(e=>W(e,`xAxis`,t,o)),f=U(e=>W(e,`yAxis`,n,o)),p=se();if(!s||!p||c==null||u==null||d==null||f==null)return null;var m=Ie(d,f,p,e.position,c.orientation,u.orientation,e);if(!m)return null;var h=m[0],g=m[1];if(h==null||g==null)return null;var{x:_,y:v}=h,{x:y,y:b}=g,x=Q(Q({clipPath:a===`hidden`?`url(#${s})`:void 0},re(e)),{},{x1:_,y1:v,x2:y,y2:b}),S=de({x1:_,y1:v,x2:y,y2:b});return Z.createElement(z,{zIndex:e.zIndex},Z.createElement(ye,{className:l(`recharts-reference-line`,i)},Me(r,x),Z.createElement(R,je({},S,{lowerWidth:S.width,upperWidth:S.width}),Z.createElement(ve,{label:e.label}),e.children)))}var ze={ifOverflow:`discard`,xAxisId:0,yAxisId:0,fill:`none`,label:!1,stroke:`#ccc`,fillOpacity:1,strokeWidth:1,position:`middle`,zIndex:ae.line};function Be(e){var t=me(e,ze);return Z.createElement(Z.Fragment,null,Z.createElement(Le,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x:t.x,y:t.y,segment:t.segment}),Z.createElement(Re,t))}Be.displayName=`ReferenceLine`;var Ve=[`Read`,`Write`,`Edit`,`Bash`,`Grep`,`Glob`,`WebSearch`,`WebFetch`,`LSP`,`NotebookEdit`,`Agent`],$=c(),He=/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/;function Ue(){let[e,t]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>{h(`/config`).then(({sandbox:e})=>{e&&t(e)}).catch(()=>{})},[]),!e)return null;let n=e.platform===`sandbox-exec`?`macOS sandbox-exec`:e.platform===`landlock`?`Linux Landlock`:`unavailable`,r=e.available;return(0,$.jsxs)(`div`,{className:`px-4 py-2 text-xs font-medium border-b ${r?`border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] text-[var(--app-success-soft-text)]`:`border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] text-[var(--app-warning-soft-text)]`}`,children:[r?`🔒`:`⚠️`,` Sandbox:`,` `,r?`active (${n})`:`${n} — filesystem isolation not enforced`]})}function We(){let{id:e}=o(),t=a(),n=te(),[i,c]=(0,Z.useState)(null),[l,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)([]),[m,g]=(0,Z.useState)([]),[j,L]=(0,Z.useState)([]),[ne,R]=(0,Z.useState)([]),[z,re]=(0,Z.useState)([]),[ie,ae]=(0,Z.useState)(null),[oe,se]=(0,Z.useState)(null),[ce,B]=(0,Z.useState)(!1),[V,H]=(0,Z.useState)(``),[le,ue]=(0,Z.useState)(!1),[de,U]=(0,Z.useState)(!1),[fe,W]=(0,Z.useState)(!1),pe=b(e=>e.updateRole),me=b(e=>e.deleteRole),{rawPlugins:he}=we(),G=(0,Z.useCallback)(async()=>{if(e)try{let t=await h(`/roles/${e}`);c(t.role),H(t.role.cagPrompt),d(t.workspacePath),se(null)}catch(e){se(e instanceof Error?e.message:`Failed to load role`)}},[e]),ge=(0,Z.useCallback)(async()=>{if(e)try{p((await h(`/memories/${e}`)).memories??[])}catch{p([])}},[e]),_e=(0,Z.useCallback)(async()=>{if(e)try{g((await h(`/roles/${e}/beliefs`)).beliefs??[])}catch{g([])}},[e]),ve=(0,Z.useCallback)(async()=>{if(e)try{let t=await h(`/evolution-audit?roleId=${e}`);L(Array.isArray(t)?t:t.entries??[])}catch{L([])}},[e]),ye=(0,Z.useCallback)(async()=>{if(e)try{let t=await h(`/roles/${e}/scores?limit=50`);re(t.scores??[]),ae(t.contractCompliance??null)}catch{re([]),ae(null)}},[e]),Y=(0,Z.useCallback)(async()=>{try{R((await h(`/tasks`)).tasks??[])}catch{R([])}},[]);(0,Z.useEffect)(()=>{G()},[G]),(0,Z.useEffect)(()=>{ge(),_e(),ve(),Y(),ye()},[ge,_e,ve,Y,ye]);let X=ne.filter(t=>t.roleId===e),Ce=he.filter(e=>e.scope===`project`&&e.projectPath===l).length,Ee=async()=>{if(e){ue(!0);try{await pe(e,{cagPrompt:V}),await G(),B(!1),w.success(`CAG prompt updated`)}catch(e){w.error(e instanceof Error?e.message:`Failed to save`)}finally{ue(!1)}}},[De,Q]=(0,Z.useState)(!1),Oe=async()=>{if(e){U(!0);try{await me(e),t(`/roles`)}catch(e){if(e.status===409){U(!1),Q(!0);return}w.error(e instanceof Error?e.message:`Failed to delete role`),U(!1)}}},ke=async()=>{if(e){U(!0),Q(!1);try{await me(e,!0),t(`/roles`)}catch(e){w.error(e instanceof Error?e.message:`Failed to delete role`),U(!1)}}},Ae=async()=>{if(!(!e||!i?.presetId)){W(!0);try{await h(`/presets/role/${i.presetId}/restore`,{method:`POST`}),w.success(`Preset restored`),await G()}catch(e){w.error(e instanceof Error?e.message:`Failed to restore preset`)}finally{W(!1)}}};return oe?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(s,{to:`/roles`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,$.jsx)(r,{size:14}),` Back to Roles`]}),(0,$.jsx)(M,{className:`text-center text-[var(--app-danger)]`,children:oe})]}):i?(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(s,{to:`/roles`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,$.jsx)(r,{size:14}),` Back to Roles`]}),(0,$.jsx)(N,{eyebrow:`Role`,title:i.name,compact:!0,description:`Behavior, permissions, plugins, and execution history.`,metrics:[{label:`Status`,value:(0,$.jsx)(D,{variant:(e=>e===`active`?`success`:e===`inactive`?`secondary`:e===`retired`?`destructive`:e===`probation`?`warning`:`secondary`)(i.status),children:i.status})},{label:`Performance`,value:i.performanceScore==null?`—`:`${(i.performanceScore*100).toFixed(0)}%`},{label:`Tasks`,value:X.length},{label:`Stored`,value:f.length},...i.presetId?[{label:`Preset`,value:(0,$.jsx)(D,{variant:`info`,children:i.presetId})}]:[]],actions:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i.presetId&&(0,$.jsx)(u,{variant:`outline`,size:`sm`,onClick:Ae,disabled:fe,children:fe?`Restoring...`:`Restore Preset`}),(0,$.jsxs)(T,{children:[(0,$.jsx)(y,{asChild:!0,children:(0,$.jsx)(u,{variant:`ghost`,className:`text-[var(--app-danger-soft-text)] hover:text-[var(--app-danger)]`,children:`Delete`})}),(0,$.jsxs)(C,{children:[(0,$.jsxs)(S,{children:[(0,$.jsx)(O,{children:`Delete Role`}),De?(0,$.jsx)(E,{children:`This role has active tasks (running or pending). Deleting it now will remove the role workspace while tasks continue running — they may fail. Proceed?`}):(0,$.jsxs)(E,{children:[`Are you sure you want to delete "`,i.name,`"? This action cannot be undone.`]})]}),(0,$.jsxs)(v,{children:[(0,$.jsx)(_,{onClick:()=>Q(!1),children:`Cancel`}),(0,$.jsx)(x,{className:`bg-[var(--app-danger)] text-white hover:bg-[var(--app-danger-strong)]`,onClick:()=>void(De?ke():Oe()),disabled:de,children:de?`Deleting...`:`Delete Anyway`})]})]})]})]})}),(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-4`,children:[(0,$.jsxs)(M,{className:`surface-panel-muted`,children:[(0,$.jsx)(`p`,{className:`text-section-label`,children:`Role ID`}),(0,$.jsx)(`p`,{className:`mt-2 truncate font-mono text-sm text-[var(--app-text)]`,children:i.id})]}),(0,$.jsxs)(M,{className:`surface-panel-muted`,children:[(0,$.jsx)(`p`,{className:`text-section-label`,children:`Learned rules`}),(0,$.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:i.learnedRules.stylePreferences.length+i.learnedRules.avoidedActions.length+i.learnedRules.pinnedParameters.length})]}),(0,$.jsxs)(M,{className:`surface-panel-muted`,children:[(0,$.jsx)(`p`,{className:`text-section-label`,children:`Bound plugins`}),(0,$.jsx)(`p`,{className:`mt-2 text-2xl font-semibold text-[var(--app-text)]`,children:Ce})]}),(0,$.jsxs)(M,{className:`surface-panel-muted`,children:[(0,$.jsx)(`p`,{className:`text-section-label`,children:`Last updated`}),(0,$.jsx)(`p`,{className:`mt-2 text-sm font-medium text-[var(--app-text)]`,children:F(i.updatedAt??i.createdAt)})]})]}),(0,$.jsx)(P,{title:`Behavior`,compact:!0,description:`Prompting, learned rules, and scoring signal stay visible before runtime controls.`}),(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsx)(k,{children:`CAG Prompt`})}),ce?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`textarea`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-2 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,rows:8,value:V,onChange:e=>H(e.target.value)}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(u,{variant:`ghost`,className:`scale-75`,onClick:()=>{B(!1),H(i.cagPrompt)},children:`Cancel`}),V!==i.cagPrompt&&(0,$.jsx)(u,{className:`scale-75`,onClick:()=>void Ee(),disabled:le,children:le?`Saving...`:`Save`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`pre`,{className:`whitespace-pre-wrap text-sm text-[var(--app-text)]`,children:i.cagPrompt||`(no CAG prompt)`}),(0,$.jsx)(u,{variant:`ghost`,className:`scale-75`,onClick:()=>B(!0),children:`Edit`})]})]}),(0,$.jsx)(Ge,{roleId:i.id,learnedRules:i.learnedRules,onSave:()=>void G()}),(0,$.jsx)(Ke,{scores:z,currentEma:i.performanceScore}),(0,$.jsx)(qe,{compliance:ie}),(0,$.jsx)(P,{title:`Access & Runtime`,compact:!0,description:`Permissions, OS capabilities, plugins, execution policy, directories, and inherited settings stay grouped.`}),(0,$.jsx)(Je,{role:i,onSave:()=>void G()}),(0,$.jsx)(Xe,{role:i,onSave:()=>void G()}),(0,$.jsx)(Ze,{roleId:e,workspacePath:l,onChanged:()=>void G()}),(0,$.jsx)(et,{roleId:e}),(0,$.jsx)(at,{role:i,onSave:()=>void G()}),(0,$.jsx)(tt,{role:i,onSave:()=>void G()}),(0,$.jsx)(nt,{role:i,onSave:()=>void G()}),(0,$.jsx)(rt,{role:i,onSave:()=>void G()}),i&&(0,$.jsx)(Te,{envVars:i.envVars??{},onSave:()=>void G(),mode:`role`,roleId:i.id,title:`Environment Variables`}),(0,$.jsx)(it,{role:i,onSave:()=>void G()}),(0,$.jsx)(P,{title:`Knowledge & History`,compact:!0,description:`Knowledge records, evolution, and execution history stay readable as one audit trail.`}),(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(k,{children:[`Memories (`,f.length,`)`]})}),f.length===0?(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No memories for this role.`}):(0,$.jsx)(`div`,{className:`space-y-2`,children:f.slice(0,10).map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-all text-sm text-[var(--app-text)]`,children:e.content}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-[var(--app-text-subtle)]`,children:[e.importance!=null&&(0,$.jsxs)(`span`,{children:[`Importance: `,e.importance.toFixed(2)]}),(0,$.jsx)(`span`,{children:I(e.createdAt)})]})]},e.id))})]}),(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(k,{children:[`Beliefs (`,m.length,`)`]})}),m.length===0?(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No beliefs for this role.`}):(0,$.jsx)(`div`,{className:`space-y-2`,children:m.slice(0,100).map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-all text-sm text-[var(--app-text)] flex-1`,children:e.content}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.isAnti&&(0,$.jsx)(D,{variant:`destructive`,children:`anti-pattern`}),(0,$.jsx)(D,{variant:e.status===`archived`?`secondary`:`outline`,children:e.status})]})]}),(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-3 text-xs text-[var(--app-text-subtle)]`,children:[(0,$.jsxs)(`span`,{children:[`近期成功率: `,e.successEma==null?`—`:`${(e.successEma*100).toFixed(0)}%`]}),(0,$.jsxs)(`span`,{children:[`已注入 `,e.injectCount,` 次`]}),(0,$.jsxs)(`span`,{children:[`Last used: seq #`,e.lastUsedAt]})]})]},e.id))})]}),(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(k,{children:[`Evolution History (`,j.length,`)`]})}),j.length===0?(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No evolution history for this role.`}):n?(0,$.jsx)(`div`,{className:`space-y-3`,children:j.slice(0,10).map(e=>(0,$.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-[var(--app-canvas)]/40 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(D,{variant:`secondary`,children:e.source}),(0,$.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:F(e.createdAt)})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-[var(--app-text-muted)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Score`}),(0,$.jsx)(`span`,{className:`text-right font-mono text-[var(--app-text)]`,children:e.previousScore!=null&&e.newScore!=null?`${(e.previousScore*100).toFixed(0)}% → ${(e.newScore*100).toFixed(0)}%`:`—`})]}),(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Summary`}),(0,$.jsx)(`span`,{className:`max-w-[70%] text-right text-[var(--app-text)]`,children:e.diffSummary??`—`})]})]})]},e.id))}):(0,$.jsxs)(Se,{children:[(0,$.jsx)(be,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{children:`When`}),(0,$.jsx)(K,{children:`Source`}),(0,$.jsx)(K,{children:`Score Change`}),(0,$.jsx)(K,{children:`Summary`})]})}),(0,$.jsx)(xe,{children:j.slice(0,10).map(e=>(0,$.jsxs)(q,{children:[(0,$.jsx)(J,{className:`text-xs text-[var(--app-text-subtle)]`,children:F(e.createdAt)}),(0,$.jsx)(J,{children:(0,$.jsx)(D,{variant:`secondary`,children:e.source})}),(0,$.jsx)(J,{children:e.previousScore!=null&&e.newScore!=null?(0,$.jsxs)(`span`,{className:`font-mono text-xs`,children:[(e.previousScore*100).toFixed(0),`% → `,(e.newScore*100).toFixed(0),`%`]}):(0,$.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`—`})}),(0,$.jsx)(J,{className:`text-sm text-[var(--app-text-muted)]`,children:e.diffSummary??`—`})]},e.id))})]})]}),(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(k,{children:[`Execution History (`,X.length,`)`]})}),X.length===0?(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No tasks executed with this role.`}):n?(0,$.jsx)(`div`,{className:`space-y-3`,children:(()=>{let e=new Map(z.map(e=>[e.taskId,e]));return X.slice(0,20).map(t=>{let n=e.get(t.id);return(0,$.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-[var(--app-canvas)]/40 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsx)(s,{to:`/tasks/${t.id}`,className:`break-all font-mono text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:t.id.slice(0,8)}),(0,$.jsx)(D,{variant:t.status===`completed`?`success`:t.status===`failed`?`destructive`:`secondary`,children:t.status})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs text-[var(--app-text-muted)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Duration`}),(0,$.jsx)(`span`,{className:`text-right text-[var(--app-text)]`,children:t.totalDurationMs==null?`—`:`${(t.totalDurationMs/1e3).toFixed(1)}s`})]}),(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Cost`}),(0,$.jsx)(`span`,{className:`text-right font-mono text-[var(--app-text)]`,children:t.costUsd==null?`—`:ee(t.costUsd)})]}),(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Score`}),(0,$.jsx)(`span`,{className:`text-right font-mono ${n&&n.scores.weighted<.4?`text-[var(--app-danger)]`:`text-[var(--app-text)]`}`,children:n?`${(n.scores.weighted*100).toFixed(0)}%`:`—`})]})]})]},t.id)})})()}):(0,$.jsxs)(Se,{children:[(0,$.jsx)(be,{children:(0,$.jsxs)(q,{children:[(0,$.jsx)(K,{children:`Task ID`}),(0,$.jsx)(K,{children:`Status`}),(0,$.jsx)(K,{children:`Duration`}),(0,$.jsx)(K,{children:`Cost`}),(0,$.jsx)(K,{children:`Score`})]})}),(0,$.jsx)(xe,{children:(()=>{let e=new Map(z.map(e=>[e.taskId,e]));return X.slice(0,20).map(t=>(0,$.jsxs)(q,{children:[(0,$.jsx)(J,{children:(0,$.jsx)(s,{to:`/tasks/${t.id}`,className:`font-mono text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:t.id.slice(0,8)})}),(0,$.jsx)(J,{children:(0,$.jsx)(D,{variant:t.status===`completed`?`success`:t.status===`failed`?`destructive`:`secondary`,children:t.status})}),(0,$.jsx)(J,{className:`text-xs text-[var(--app-text-subtle)]`,children:t.totalDurationMs==null?`—`:`${(t.totalDurationMs/1e3).toFixed(1)}s`}),(0,$.jsx)(J,{className:`text-xs text-[var(--app-text-subtle)]`,children:t.costUsd==null?`—`:ee(t.costUsd)}),(0,$.jsx)(J,{children:(()=>{let n=e.get(t.id);return n?(0,$.jsxs)(`span`,{className:`font-mono text-xs ${n.scores.weighted<.4?`text-[var(--app-danger)]`:`text-[var(--app-text)]`}`,children:[(n.scores.weighted*100).toFixed(0),`%`]}):(0,$.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`—`})})()})]},t.id))})()})]})]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(s,{to:`/roles`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,$.jsx)(r,{size:14}),` Back to Roles`]}),(0,$.jsx)(M,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]})}function Ge({roleId:e,learnedRules:t,onSave:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(``);function m(e){let n=t.pinnedParameters[e];i(e),c(n.tool),d(JSON.stringify(n.params,null,2)),p(n.condition??``)}function g(){i(-1),c(``),d(`{
2
+ "": ""
3
+ }`),p(``)}function _(){i(null)}async function v(){o(!0);try{let i;try{i=JSON.parse(l)}catch{i={}}let a=[...t.pinnedParameters],o={tool:s,params:i,condition:f||void 0,pinnedAt:Date.now()};r!==null&&r>=0?a[r]=o:a.push(o);let c={...t,pinnedParameters:a};await h(`/roles/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({learnedRules:c})}),_(),n()}catch{}finally{o(!1)}}function y(e){return new Date(e).toLocaleString()}let b=e=>e.startsWith(`[+]`)?{text:`positive`,variant:`success`}:e.startsWith(`[-]`)?{text:`negative`,variant:`destructive`}:e.startsWith(`[~]`)?{text:`deviation`,variant:`warning`}:e.startsWith(`[monitor:`)?{text:`monitor`,variant:`secondary`}:{text:`rule`,variant:`muted`},{stylePreferences:x,avoidedActions:S,pinnedParameters:C}=t;return(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(k,{children:`Learned Rules`}),(0,$.jsx)(u,{variant:`outline`,size:`sm`,onClick:g,children:`Add Pin`})]})}),(0,$.jsxs)(j,{className:`space-y-2`,children:[(0,$.jsx)(`h4`,{className:`text-sm font-medium text-[var(--app-text-subtle)]`,children:`风格偏好`}),x.length===0?(0,$.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`(none yet)`}):(0,$.jsx)(`div`,{className:`space-y-2`,children:x.map((e,t)=>{let n=b(e);return(0,$.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-2`,children:[(0,$.jsx)(`div`,{className:`mb-1`,children:(0,$.jsx)(D,{variant:n.variant,className:`text-[10px]`,children:n.text})}),(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text)]`,children:e})]},t)})}),(0,$.jsx)(`h4`,{className:`pt-3 text-sm font-medium text-[var(--app-text-subtle)]`,children:`应避免的操作`}),S.length===0?(0,$.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`(none yet)`}):(0,$.jsx)(`div`,{className:`space-y-2`,children:S.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-2`,children:[(0,$.jsx)(D,{variant:`destructive`,className:`text-[10px]`,children:`avoid`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-[var(--app-text)]`,children:e})]},t))}),(0,$.jsx)(`h4`,{className:`pt-3 text-sm font-medium text-[var(--app-text-subtle)]`,children:`固定参数`}),C.length===0?(0,$.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`(none yet)`}):(0,$.jsx)(`div`,{className:`space-y-2`,children:C.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(D,{variant:`outline`,className:`text-[10px] font-mono`,children:e.tool}),e.condition&&(0,$.jsxs)(`span`,{className:`ml-2 text-xs text-[var(--app-text-subtle)]`,children:[`[`,e.condition,`]`]})]}),(0,$.jsx)(u,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>m(t),children:`Edit`})]}),(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(`table`,{className:`w-full text-xs`,children:(0,$.jsx)(`tbody`,{children:Object.entries(e.params).map(([e,t])=>(0,$.jsxs)(`tr`,{className:`border-t border-[var(--app-border)]`,children:[(0,$.jsx)(`td`,{className:`pr-3 font-mono text-[var(--app-text-subtle)]`,children:e}),(0,$.jsx)(`td`,{className:`font-mono text-[var(--app-text)]`,children:JSON.stringify(t)})]},e))})})}),(0,$.jsxs)(`p`,{className:`mt-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`Pinned: `,y(e.pinnedAt)]})]},t))}),r!==null&&(0,$.jsxs)(`div`,{className:`rounded border border-[var(--app-accent)] bg-[var(--app-panel)] p-3 space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Tool pattern`}),(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-[var(--app-border)] bg-[var(--app-bg)] px-2 py-1 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:s,onChange:e=>c(e.target.value),placeholder:`e.g. Bash:generate_voice.sh`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Params (JSON)`}),(0,$.jsx)(`textarea`,{className:`mt-1 w-full rounded border border-[var(--app-border)] bg-[var(--app-bg)] px-2 py-1 text-xs font-mono text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,rows:4,value:l,onChange:e=>d(e.target.value),placeholder:`{"-v": "male-qn-qing-xx"}`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Condition (optional)`}),(0,$.jsx)(`input`,{className:`mt-1 w-full rounded border border-[var(--app-border)] bg-[var(--app-bg)] px-2 py-1 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:f,onChange:e=>p(e.target.value),placeholder:`e.g. 给卞旸生成播客时`})]}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(u,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:_,disabled:a,children:`Cancel`}),(0,$.jsx)(u,{size:`sm`,className:`scale-75`,onClick:()=>void v(),disabled:a,children:a?`Saving...`:`Save Pin`})]})]})]})]})}function Ke({scores:e,currentEma:t}){let n=.4,r=[...e].reverse().map((e,t)=>({index:t+1,ema:+(e.emaScore*100).toFixed(1),weighted:+(e.scores.weighted*100).toFixed(1),taskId:e.taskId.slice(0,8)}));return r.length===0?(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsx)(k,{children:`Performance Trend`})}),(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No score data yet. Scores are recorded after task completion.`})]}):(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(k,{children:`Performance Trend`}),t!=null&&(0,$.jsxs)(`span`,{className:`font-mono text-sm ${t<n?`text-[var(--app-danger)]`:`text-[var(--app-success)]`}`,children:[`EMA: `,(t*100).toFixed(0),`%`]})]})}),(0,$.jsx)(ne,{width:`100%`,height:180,children:(0,$.jsxs)(ge,{data:r,margin:{top:8,right:12,left:-10,bottom:4},children:[(0,$.jsx)(fe,{dataKey:`index`,tick:{fontSize:10,fill:`#64748b`}}),(0,$.jsx)(he,{domain:[0,100],tick:{fontSize:10,fill:`#64748b`},tickFormatter:e=>`${e}%`}),(0,$.jsx)(Be,{y:n*100,stroke:`#ef4444`,strokeDasharray:`4 3`,label:{value:`Retire`,fill:`#ef4444`,fontSize:9,position:`right`}}),(0,$.jsx)(ce,{contentStyle:{background:`#1e293b`,border:`1px solid #1e293b`,borderRadius:6,fontSize:12},labelFormatter:e=>`Task #${e}`,formatter:(e,t)=>[`${e}%`,t===`ema`?`EMA`:`Task Score`]}),(0,$.jsx)(B,{type:`monotone`,dataKey:`ema`,stroke:`#3b82f6`,strokeWidth:2,dot:{r:3},name:`ema`}),(0,$.jsx)(B,{type:`monotone`,dataKey:`weighted`,stroke:`#94a3b8`,strokeWidth:1,strokeDasharray:`3 3`,dot:!1,name:`weighted`})]})}),(0,$.jsxs)(`p`,{className:`sr-only`,children:[`Performance trend: `,r.length,` data points, latest EMA `,t?`${(t*100).toFixed(0)}%`:`N/A`,`, retirement threshold 40%`]}),(0,$.jsxs)(`p`,{className:`mt-1 text-center text-[10px] text-[var(--app-text-subtle)]`,children:[`Last `,r.length,` tasks — blue: EMA, gray dashed: per-task score, red: retirement threshold (40%)`]})]})}function qe({compliance:e}){let t=e?.emaScore==null?`—`:`${(e.emaScore*100).toFixed(0)}%`;return(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(k,{children:`契约合规率`}),(0,$.jsx)(`span`,{className:`font-mono text-sm text-[var(--app-text)]`,children:t})]})}),e?.recentViolations&&e.recentViolations.length>0?(0,$.jsxs)(`div`,{className:`space-y-1 px-4 pb-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-subtle)]`,children:`最近违反`}),(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:e.recentViolations.slice(0,10).map(e=>(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs text-[var(--app-text-muted)]`,children:[(0,$.jsx)(`span`,{className:`shrink-0 text-[var(--app-text-subtle)]`,children:new Date(e.createdAt).toLocaleString(`zh-CN`,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`})}),(0,$.jsx)(`span`,{className:`shrink-0 rounded bg-[var(--app-warning-soft-bg)] px-1 text-[10px] font-medium text-[var(--app-warning-soft-text)]`,children:e.contractField}),(0,$.jsx)(`span`,{className:`truncate`,children:e.message})]},e.id))})]}):(0,$.jsx)(`p`,{className:`px-4 pb-3 text-sm text-[var(--app-text-subtle)]`,children:`暂无违反记录`})]})}function Je({role:e,onSave:t}){let[n,r]=(0,Z.useState)(new Set(e?.allowedTools??[])),[i,a]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{r(new Set(e?.allowedTools??[]))},[e]);let o=async o=>{if(!e||i)return;let s=new Set(n),c=new Set(n);c.has(o)?c.delete(o):c.add(o),r(c),a(o);try{await h(`/roles/${e.id}`,{method:`PATCH`,body:JSON.stringify({allowedTools:Array.from(c)})}),t()}catch(e){r(s),w.error(e instanceof Error?e.message:`Failed to save`)}finally{a(null)}};return(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsx)(k,{children:`Tool Permissions`})}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 md:grid-cols-5`,children:Ve.map(e=>(0,$.jsxs)(`label`,{className:`flex min-w-0 cursor-pointer items-center gap-2 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-2 text-sm text-[var(--app-text)] hover:border-[var(--app-border-strong)]`,children:[(0,$.jsx)(Y,{checked:n.has(e),onCheckedChange:()=>void o(e),disabled:i!==null,"aria-label":`Toggle ${e}`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words leading-5`,children:e})]},e))})]})}function Ye(e){if(!e?.length)return;let t=new Map;for(let n of e){if(!n?.id)continue;let e={id:n.id};n.targets&&(e.targets=Array.from(new Set(n.targets.map(e=>e.trim()).filter(Boolean)))),t.set(n.id,e)}return Array.from(t.values()).sort((e,t)=>e.id.localeCompare(t.id))}function Xe({role:e,onSave:t}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(e?.osCapabilities??[]),[l,d]=(0,Z.useState)(!1);if((0,Z.useEffect)(()=>{c(e?.osCapabilities??[])},[e]),(0,Z.useEffect)(()=>{h(`/config`).then(e=>{i(e.sandbox),o(e.osCapabilities.registry??[])}).catch(()=>{i(null),o([])})},[]),!e)return null;let f=e=>s?.find(t=>t.id===e),p=(e,t)=>{c(n=>{let r=n??[];return t?r.some(t=>t.id===e)?r:[...r,{id:e,targets:e===`automation`?[]:void 0}]:r.filter(t=>t.id!==e)})},m=(e,t)=>{let n=t.split(`,`).map(e=>e.trim()).filter(Boolean);c(t=>(t??[]).map(t=>t.id===e?{...t,targets:n}:t))},g=Ye(s),_=Ye(e.osCapabilities),v=JSON.stringify(g??[])!==JSON.stringify(_??[]),y=g?.find(e=>e.id===`automation`?!e.targets?.length||e.targets.some(e=>!He.test(e)):!1),b=async()=>{if(!(!e||l||y)){d(!0);try{await h(`/roles/${e.id}`,{method:`PATCH`,body:JSON.stringify({osCapabilities:g??[]})}),w.success(`OS capabilities updated`),await t()}catch(e){w.error(e instanceof Error?e.message:`Failed to save`)}finally{d(!1)}}},x=r?r.platform===`sandbox-exec`?`macOS sandbox-exec`:r.platform===`landlock`?`Linux Landlock`:`No OS sandbox`:null;return(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:`OS Capabilities`}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-[var(--app-text-subtle)]`,children:`Adam-level system capability controls. Registry is complete; only runtime-enforced items are editable.`})]}),v&&(0,$.jsx)(u,{className:`scale-75`,onClick:()=>void b(),disabled:l||!!y,children:l?`Saving...`:`Save`})]})}),x&&(0,$.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs text-[var(--app-text-subtle)]`,children:[(0,$.jsx)(D,{variant:`secondary`,children:x}),!r?.available&&(0,$.jsx)(`span`,{children:`Filesystem sandbox unavailable on this host.`})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=!!f(e.id),r=(f(e.id)?.targets??[]).join(`, `),i=!e.editable||l;return(0,$.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.label}),(0,$.jsx)(D,{variant:e.availability===`editable`?`success`:`secondary`,children:e.availability}),!e.editable&&(0,$.jsx)(n,{size:12,className:`text-[var(--app-text-subtle)]`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:e.description}),e.effectiveDisabledReason&&!e.editable&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-subtle)]`,children:e.effectiveDisabledReason})]}),(0,$.jsx)(Y,{checked:t,onCheckedChange:t=>p(e.id,t),disabled:i,"aria-label":`Toggle OS capability ${e.label}`})]}),t&&e.supportsTargets&&(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-[var(--app-text)]`,children:`Automation targets (bundle ids)`}),(0,$.jsx)(`input`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-canvas)] px-3 py-2 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:r,onChange:t=>m(e.id,t.target.value),placeholder:`com.apple.mail, com.apple.systemevents`,disabled:l}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--app-text-subtle)]`,children:[`Comma-separated bundle ids. Example: `,(0,$.jsx)(`code`,{children:`com.apple.mail`}),`, `,(0,$.jsx)(`code`,{children:`com.apple.systemevents`})]}),e.id===`automation`&&y?.id===`automation`&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-danger)]`,children:`Automation requires at least one valid bundle id target.`})]})]},e.id)})})]})}function Ze({roleId:e,workspacePath:n,onChanged:r}){let{rawPlugins:i,projectScope:a,refresh:o}=we(),{operatingKey:s,installToRole:c,uninstallFromRole:l,updateRoleVersion:d}=X(async()=>{await o(),await r?.()}),[f,p]=(0,Z.useState)(!1),m=new Set(i.filter(e=>e.scope===`project`&&e.projectPath===n).map(e=>e.id)),h=[...new Set(i.map(e=>e.id))].filter(e=>!m.has(e)).map(e=>{let t=i.find(t=>t.id===e);return{id:e,name:e.split(`@`)[0],version:t?.version??``}});return(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(k,{children:`Role Plugins`}),(0,$.jsx)(u,{variant:`ghost`,size:`sm`,"aria-label":`Add plugin to role`,onClick:()=>p(e=>!e),children:(0,$.jsx)(t,{size:L.sm})})]})}),f?(0,$.jsxs)(`div`,{className:`mb-3 rounded border border-[var(--app-border)] bg-[var(--app-panel)] p-3`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-[var(--app-text)]`,children:`Install plugin for this Role (project-scope)`}),h.length===0?(0,$.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No plugins available to install. Install plugins from a marketplace first.`}):(0,$.jsx)(`div`,{className:`space-y-1 max-h-48 overflow-y-auto`,children:h.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded px-2 py-1 hover:bg-[var(--app-panel-elevated)]`,children:[(0,$.jsxs)(`span`,{className:`text-xs text-[var(--app-text)]`,children:[e.name,` `,(0,$.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`v`,e.version]})]}),(0,$.jsx)(u,{size:`sm`,className:`h-5 px-2 text-[10px]`,disabled:s===`${e.id}:${n}`,onClick:async()=>{await c(e.id,n),p(!1)},children:`Install`})]},e.id))})]}):null,(0,$.jsx)(Ce,{groups:a,layout:`single-role`,singleRoleId:e,onUninstall:l,onUpdate:d,operatingKey:s})]})}function Qe({binding:e,extension:t,onClose:n,onSave:r}){let i=(()=>{try{return JSON.parse(t.manifestJson)}catch{return{}}})().user_config??{},a=(()=>{try{return t.defaultConfigJson?JSON.parse(t.defaultConfigJson):{}}catch{return{}}})(),o=e.configOverride??{},[s,c]=(0,Z.useState)(()=>{let e={};for(let t of Object.keys(i)){let n=t in o?o[t]:void 0;e[t]=n===void 0?a[t]===void 0?``:String(a[t]):String(n)}return e}),[l,d]=(0,Z.useState)(!1),f=async()=>{d(!0);try{let e={};for(let[t,n]of Object.entries(i)){let r=s[t]??``,i=a[t]===void 0?``:String(a[t]);n.sensitive?r!==``&&(e[t]=r):r!==i&&(e[t]=r)}await r(e),n()}finally{d(!1)}};return(0,$.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-[var(--app-border)] bg-[var(--app-bg)] p-6 shadow-xl`,children:[(0,$.jsxs)(`h2`,{className:`mb-4 text-sm font-semibold text-[var(--app-text)]`,children:[`Override Config — `,t.name]}),Object.keys(i).length===0?(0,$.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`This extension has no user-configurable fields.`}):(0,$.jsx)(`div`,{className:`space-y-3 max-h-80 overflow-y-auto`,children:Object.entries(i).map(([e,t])=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-[var(--app-text)]`,children:[e,t.description&&(0,$.jsxs)(`span`,{className:`ml-1 text-[var(--app-text-subtle)]`,children:[`— `,t.description]})]}),(0,$.jsx)(`input`,{type:t.sensitive?`password`:`text`,className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:outline-none`,value:s[e]??``,placeholder:t.sensitive?`(leave empty to clear override)`:String(t.default??``),onChange:t=>c(n=>({...n,[e]:t.target.value}))})]},e))}),(0,$.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,$.jsx)(u,{variant:`ghost`,size:`sm`,onClick:n,disabled:l,children:`取消`}),(0,$.jsx)(u,{size:`sm`,onClick:()=>void f(),disabled:l,children:l?`保存中…`:`保存`})]})]})})}function $e({health:e}){return e?e.lastStatus===`success`?(0,$.jsx)(`span`,{title:`Last ok ${e.lastRunAt?new Date(e.lastRunAt).toLocaleString():``}`,className:`text-green-500 text-xs`,children:`✅`}):(0,$.jsx)(`span`,{title:e.lastError??`Failed`,className:`text-red-500 text-xs`,children:`❌`}):(0,$.jsx)(`span`,{title:`Never run`,className:`text-gray-500 text-xs`,children:`⏳`})}function et({roleId:e}){let[n,r]=(0,Z.useState)([]),[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[h,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!0),[b,x]=(0,Z.useState)(null),S=(0,Z.useCallback)(async()=>{y(!0);try{let[t,n]=await Promise.all([p(e),d()]);r(t);let i=new Set(t.map(e=>e.extensionId));a(n.filter(e=>!i.has(e.id)))}finally{y(!1)}},[e]);(0,Z.useEffect)(()=>{S()},[S]);let C=async t=>{x(t.id);try{await m(e,t.name),await S(),s(!1),w.success(`Extension "${t.name}" bound`)}catch{w.error(`Failed to bind extension`)}finally{x(null)}},T=async t=>{if(confirm(`解绑 "${t.extensionName}"?此操作不可撤销。`)){x(t.id);try{await g(e,t.id),await S(),w.success(`Extension "${t.extensionName}" unbound`)}catch{w.error(`Failed to unbind extension`)}finally{x(null)}}},E=async t=>{x(t.id);try{await f(e,t.id,{enabled:!t.enabled}),await S()}catch{w.error(`Failed to update extension`)}finally{x(null)}},O=async e=>{_((await d()).find(t=>t.id===e.extensionId)??null),l(e)},N=async t=>{c&&(await f(e,c.id,{configOverride:t}),await S(),w.success(`Override saved`))};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(k,{children:`Role Extensions`}),(0,$.jsx)(u,{variant:`ghost`,size:`sm`,"aria-label":`Add extension to role`,onClick:()=>s(e=>!e),children:(0,$.jsx)(t,{size:L.sm})})]})}),o&&(0,$.jsxs)(`div`,{className:`mb-3 rounded border border-[var(--app-border)] bg-[var(--app-panel)] p-3`,children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-[var(--app-text)]`,children:`Bind extension to this Role`}),i.length===0?(0,$.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`所有已安装的 Extension 都已绑定,或尚未安装任何 Extension。`}):(0,$.jsx)(`div`,{className:`space-y-1 max-h-48 overflow-y-auto`,children:i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded px-2 py-1 hover:bg-[var(--app-panel-elevated)]`,children:[(0,$.jsxs)(`span`,{className:`text-xs text-[var(--app-text)]`,children:[e.name,` `,(0,$.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`v`,e.version]})]}),(0,$.jsx)(u,{size:`sm`,className:`h-5 px-2 text-[10px]`,disabled:b===e.id,onClick:()=>void C(e),children:`Bind`})]},e.id))})]}),(0,$.jsx)(j,{children:v?(0,$.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`加载中…`}):n.length===0?(0,$.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`还没绑任何 extension`}):(0,$.jsx)(`div`,{className:`space-y-2`,children:n.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-[var(--app-border)] px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)($e,{health:e.health}),(0,$.jsx)(`span`,{className:`truncate text-xs font-medium text-[var(--app-text)]`,children:e.extensionName}),(0,$.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`v`,e.version]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[e.toolsCount,` tools`]}),e.configOverride!==null&&(0,$.jsx)(D,{variant:`secondary`,className:`text-[10px] px-1 py-0`,children:`已覆盖`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`span`,{title:`Will affect task execution in next phase`,children:(0,$.jsx)(Y,{checked:e.enabled,onCheckedChange:()=>void E(e),disabled:b===e.id,"aria-label":`Toggle extension enabled`})}),(0,$.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-[10px]`,onClick:()=>void O(e),children:`覆盖 config`}),(0,$.jsx)(u,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-[10px] text-red-500 hover:text-red-600`,disabled:b===e.id,onClick:()=>void T(e),children:`解绑`})]})]},e.id))})})]}),c!==null&&h!==null&&(0,$.jsx)(Qe,{binding:c,extension:h,onClose:()=>{l(null),_(null)},onSave:N})]})}function tt({role:e,onSave:n}){let{id:r}=o(),[i,a]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(()=>(e?.additionalDirectories??[]).map(e=>typeof e==`string`?{path:e}:e)),[l,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(!1),[m,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)({}),[y,b]=(0,Z.useState)([]),[x,S]=(0,Z.useState)(-1),[C,T]=(0,Z.useState)(!1),E=(0,Z.useRef)(null),D=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{c((e?.additionalDirectories??[]).map(e=>typeof e==`string`?{path:e}:e))},[e]);let O=(0,Z.useCallback)(async e=>{if(!e||!e.startsWith(`/`)){b([]),T(!1);return}T(!0);try{b((await h(`/fs/suggest-dirs?prefix=${encodeURIComponent(e)}`)).suggestions??[]),S(-1)}catch{b([])}finally{T(!1)}},[]),j=e=>{if(d(e),S(-1),E.current&&clearTimeout(E.current),!e||!e.startsWith(`/`)){b([]),T(!1);return}T(!0),E.current=setTimeout(()=>{O(e)},300)},N=e=>{d(e.endsWith(`/`)?e.slice(0,-1):e),b([]),S(-1),O(e.endsWith(`/`)?e:e+`/`)},P=()=>{let e=l.trim();if(e){if(!e.startsWith(`/`)){w.error(`Path must be absolute (must start with /)`);return}if(s.some(t=>t.path===e)){w.error(`Directory already in list`);return}c(t=>[...t,{path:e,mode:`rw`}]),d(``),b([]),p(!1)}},F=e=>{c(t=>t.filter(t=>t.path!==e)),v(t=>{let n={...t};return delete n[e],n})},I=(e,t)=>{c(n=>n.map(n=>n.path===e?{...n,[t]:!n[t]}:n))},ee=e=>{c(t=>t.map(t=>t.path===e?{...t,mode:t.mode===`ro`?`rw`:`ro`}:t))},L=async e=>{if(r){g(e);try{let t=await h(`/roles/${r}/scan-directory`,{method:`POST`,body:JSON.stringify({path:e})});v(n=>({...n,[e]:t}))}catch(e){w.error(e instanceof Error?e.message:`Failed to scan directory`)}finally{g(null)}}},te=async()=>{if(e){a(!0);try{await h(`/roles/${e.id}`,{method:`PATCH`,body:JSON.stringify({additionalDirectories:s})}),w.success(`Additional directories saved`),n()}catch(e){w.error(e instanceof Error?e.message:`Failed to save`)}finally{a(!1)}}},ne=()=>{p(!1),d(``),b([]),S(-1)},R=JSON.stringify(s)!==JSON.stringify(e?.additionalDirectories??[]);return(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{children:`Additional Directories`}),(0,$.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mt-0.5`,children:`Extra directories this Role can access. Configure read/write mode and inheritance per directory.`})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(u,{variant:`ghost`,className:`scale-75`,onClick:()=>{p(!f),b([]),S(-1)},children:[(0,$.jsx)(t,{size:14}),` Add Directory`]}),R&&(0,$.jsx)(u,{className:`scale-75`,onClick:()=>void te(),disabled:i,children:i?`Saving...`:`Save`})]})]})}),(0,$.jsx)(Ue,{}),f&&(0,$.jsxs)(`div`,{className:`relative mb-3 flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(`input`,{ref:D,className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:l,onChange:e=>j(e.target.value),placeholder:`/absolute/path/to/directory`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),S(e=>Math.min(y.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),S(e=>Math.max(0,e-1))):e.key===`Tab`&&x>=0?(e.preventDefault(),N(y[x])):e.key===`Enter`?x>=0?N(y[x]):P():e.key===`Escape`&&(b([]),S(-1))},autoFocus:!0}),y.length>0&&(0,$.jsx)(`div`,{className:`absolute z-10 mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] py-1 shadow-lg`,children:y.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>N(e),onMouseEnter:()=>S(t),className:`w-full px-3 py-1.5 text-left text-sm ${t===x?`bg-[var(--app-accent)] text-white`:`text-[var(--app-text)] hover:bg-[var(--app-panel-muted)]`}`,children:[e,`/`]},e))}),C&&y.length===0&&l&&(0,$.jsx)(`div`,{className:`absolute z-10 mt-1 w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text-subtle)] shadow-lg`,children:`Loading...`})]}),(0,$.jsx)(u,{className:`scale-75`,onClick:()=>void P(),children:`Add`}),(0,$.jsx)(u,{variant:`ghost`,className:`scale-75`,onClick:ne,children:`Cancel`})]}),s.length===0?(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No additional directories configured.`}):(0,$.jsx)(`div`,{className:`space-y-3`,children:s.map(e=>{let t=_[e.path],n=m===e.path;return(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] p-3 space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-1`,children:[(0,$.jsx)(`button`,{onClick:()=>ee(e.path),className:`flex-shrink-0 cursor-pointer text-xs font-mono px-1.5 py-0.5 rounded border ${e.mode===`ro`?`text-[var(--app-warning)] border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] hover:bg-[var(--app-warning-soft-bg-subtle)]`:`text-[var(--app-success)] border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] hover:bg-[var(--app-success-soft-bg-subtle)]`}`,title:e.mode===`ro`?`Read-only — click to toggle to RW`:`Read-write — click to toggle to RO`,children:e.mode===`ro`?`RO`:`RW`}),(0,$.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text)] truncate`,title:e.path,children:e.path})]}),(0,$.jsx)(`button`,{onClick:()=>F(e.path),className:`flex-shrink-0 cursor-pointer text-[var(--app-text-muted)] hover:text-[var(--app-danger)] ml-2`,"aria-label":`Remove ${e.path}`,children:`×`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-[var(--app-text)] cursor-pointer`,children:[(0,$.jsx)(Y,{checked:!!e.inheritPlugins,onCheckedChange:()=>I(e.path,`inheritPlugins`),className:`scale-75`}),`Plugins`]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-[var(--app-text)] cursor-pointer`,children:[(0,$.jsx)(Y,{checked:!!e.inheritMcp,onCheckedChange:()=>I(e.path,`inheritMcp`),className:`scale-75`}),`MCP`]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs text-[var(--app-text)] cursor-pointer`,children:[(0,$.jsx)(Y,{checked:!!e.inheritPermissions,onCheckedChange:()=>I(e.path,`inheritPermissions`),className:`scale-75`}),`Permissions`]}),(0,$.jsx)(`button`,{className:`text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)] ml-auto disabled:opacity-50`,onClick:()=>void L(e.path),disabled:n,children:n?`Scanning...`:`Scan`})]}),t&&(0,$.jsxs)(`div`,{className:`rounded bg-[var(--app-panel)] p-2 space-y-1`,children:[Object.keys(t.enabledPlugins).length>0&&(0,$.jsxs)(`div`,{className:`text-xs text-[var(--app-text-muted)]`,children:[(0,$.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Plugins: `}),Object.entries(t.enabledPlugins).filter(([,e])=>e).map(([e])=>e).join(`, `)||`none enabled`]}),Object.keys(t.mcpServers).length>0&&(0,$.jsxs)(`div`,{className:`text-xs text-[var(--app-text-muted)]`,children:[(0,$.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`MCP: `}),Object.keys(t.mcpServers).join(`, `)]}),t.allowedTools.length>0&&(0,$.jsxs)(`div`,{className:`text-xs text-[var(--app-text-muted)]`,children:[(0,$.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Tools: `}),t.allowedTools.join(`, `)]})]})]},e.path)})})]})}function nt({role:e,onSave:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e?.allowedChannels??[]),[o,s]=(0,Z.useState)(e?.allowedChannels===void 0?`unrestricted`:e.allowedChannels.length===0?`block-all`:`whitelist`),[c,l]=(0,Z.useState)([]),[d,f]=(0,Z.useState)(!1);(0,Z.useEffect)(()=>{a(e?.allowedChannels??[]),s(e?.allowedChannels===void 0?`unrestricted`:e.allowedChannels.length===0?`block-all`:`whitelist`)},[e]);let p=(0,Z.useCallback)(async()=>{f(!0);try{l((await h(`/channels?enabled=true`)).channels??[])}catch{l([])}finally{f(!1)}},[]),m=async n=>{if(e){r(!0);try{let r=n===`unrestricted`?{allowedChannels:null}:{allowedChannels:[]};await h(`/roles/${e.id}`,{method:`PATCH`,body:JSON.stringify(r)}),s(n),a([]),t()}catch(e){w.error(e instanceof Error?e.message:`Failed to save`)}finally{r(!1)}}},g=async()=>{if(e){r(!0);try{await h(`/roles/${e.id}`,{method:`PATCH`,body:JSON.stringify({allowedChannels:i})}),t()}catch(e){w.error(e instanceof Error?e.message:`Failed to save`)}finally{r(!1)}}},_=e=>{o!==`whitelist`&&(s(`whitelist`),p()),a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},v=e?.allowedChannels??[],y=o===`whitelist`&&(i.length!==v.length||i.some(e=>!v.includes(e)));return(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsx)(k,{children:`Allowed Channels`}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,$.jsx)(u,{variant:o===`unrestricted`?`default`:`ghost`,size:`sm`,disabled:n,onClick:()=>{o!==`unrestricted`&&m(`unrestricted`)},children:`Unrestricted`}),(0,$.jsx)(u,{variant:o===`block-all`?`default`:`ghost`,size:`sm`,disabled:n,onClick:()=>{o!==`block-all`&&m(`block-all`)},children:`Block All`}),(0,$.jsx)(u,{variant:o===`whitelist`?`default`:`ghost`,size:`sm`,disabled:n,onClick:()=>{o!==`whitelist`&&(s(`whitelist`),p())},children:`Whitelist`})]})]})}),o===`unrestricted`?(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`This role can use all channels.`}):o===`block-all`?(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`This role is blocked from using any channel.`}):(0,$.jsxs)($.Fragment,{children:[d?(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`Loading channels...`}):c.length===0?(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No enabled channels found.`}):(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:c.map(e=>(0,$.jsx)(D,{variant:i.includes(e.name)?`default`:`outline`,className:`cursor-pointer px-3 py-1.5 text-xs`,onClick:()=>_(e.name),children:e.name},e.id))}),y&&(0,$.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,$.jsx)(u,{className:`scale-75`,onClick:()=>void g(),disabled:n,children:n?`Saving...`:`Save`})})]})]})}function rt({role:e,onSave:t}){let[n,r]=(0,Z.useState)(!1),i=e?.inheritUserSettings??!1,a=async()=>{if(e){r(!0);try{await h(`/roles/${e.id}`,{method:`PATCH`,body:JSON.stringify({inheritUserSettings:!i})}),t()}catch(e){w.error(e instanceof Error?e.message:`Failed to update`)}finally{r(!1)}}};return(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(k,{children:`Inherit User Settings`}),(0,$.jsx)(Y,{checked:i,onCheckedChange:()=>void a(),disabled:n})]})}),(0,$.jsx)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:`When enabled, this role has access to all globally installed plugins and MCP servers.`}),i&&(0,$.jsx)(`p`,{className:`mt-2 text-xs text-[var(--app-warning)]`,children:`Warning: This role will inherit user-level settings. Ensure the role is trusted.`})]})}function it({role:e,onSave:t}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(e?.permissionMode??`default`),[s,c]=(0,Z.useState)(e?.allowedBashPatterns??[]),[l,d]=(0,Z.useState)(e?.deniedBashPatterns??[]),[f,p]=(0,Z.useState)(``),[m,g]=(0,Z.useState)(``);(0,Z.useEffect)(()=>{o(e?.permissionMode??`default`),c(e?.allowedBashPatterns??[]),d(e?.deniedBashPatterns??[])},[e]);let _=a!==(e?.permissionMode??`default`)||JSON.stringify(s)!==JSON.stringify(e?.allowedBashPatterns??[])||JSON.stringify(l)!==JSON.stringify(e?.deniedBashPatterns??[]),v=async()=>{if(e){i(!0);try{await h(`/roles/${e.id}`,{method:`PATCH`,body:JSON.stringify({permissionMode:a,allowedBashPatterns:s,deniedBashPatterns:l})}),w.success(`Permission settings saved`),t()}catch(e){w.error(e instanceof Error?e.message:`Failed to save`)}finally{i(!1)}}},y=()=>{let e=f.trim();!e||s.includes(e)||(c(t=>[...t,e]),p(``))},b=()=>{let e=m.trim();!e||l.includes(e)||(d(t=>[...t,e]),g(``))},x=e=>c(t=>t.filter(t=>t!==e)),S=e=>d(t=>t.filter(t=>t!==e)),C=[{value:`default`,label:`Default`,description:`Normal permission checks, user prompted for elevated operations`},{value:`acceptEdits`,label:`Accept Edits`,description:`Allow file edits without prompts (but respect deniedPaths)`},{value:`dontAsk`,label:`Don't Ask`,description:`Skip permission prompts; auto-deny Bash, Write unless explicitly allowed`},{value:`bypassPermissions`,label:`Bypass All`,description:`Skip all permission checks — OS sandbox is the only defense`},{value:`plan`,label:`Plan Only`,description:`Only plan operations; don't execute tools directly`},{value:`auto`,label:`Auto`,description:`Let Claude Code CLI decide based on project settings`}];return(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(k,{children:`Permission & Execution`}),_&&(0,$.jsx)(u,{className:`scale-75`,onClick:()=>void v(),disabled:r,children:r?`Saving...`:`Save`})]})}),(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsx)(`label`,{className:`mb-1.5 block text-xs font-medium text-[var(--app-text-muted)]`,children:`Permission Mode`}),(0,$.jsx)(`select`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-2 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:a,onChange:e=>o(e.target.value),children:C.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-subtle)]`,children:C.find(e=>e.value===a)?.description??``}),a===`bypassPermissions`&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-warning)]`,children:`Warning: All permission checks are bypassed. OS sandbox is the only defense.`})]}),(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsx)(`label`,{className:`mb-1.5 block text-xs font-medium text-[var(--app-text-muted)]`,children:`Bash Auto-Allow Patterns`}),(0,$.jsxs)(`p`,{className:`mb-2 text-xs text-[var(--app-text-subtle)]`,children:[`Glob patterns for Bash commands executed automatically without approval. Use `,(0,$.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`*`}),` as wildcard (e.g., `,(0,$.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`git add *`}),`).`]}),(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:[s.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] px-2 py-0.5 text-xs text-[var(--app-success-soft-text)]`,children:[e,(0,$.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-success)] hover:text-[var(--app-success-soft-text)]`,onClick:()=>x(e),children:`×`})]},e)),s.length===0&&(0,$.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No patterns — all Bash requires approval`})]}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`e.g. "git add *"`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),y())}}),(0,$.jsx)(u,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>y(),children:`Add`})]})]}),(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsx)(`label`,{className:`mb-1.5 block text-xs font-medium text-[var(--app-text-muted)]`,children:`Bash Deny Patterns`}),(0,$.jsx)(`p`,{className:`mb-2 text-xs text-[var(--app-text-subtle)]`,children:`Glob patterns for Bash commands that are auto-rejected (cannot be overridden by approval).`}),(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:[l.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] px-2 py-0.5 text-xs text-[var(--app-danger-soft-text)]`,children:[e,(0,$.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>S(e),children:`×`})]},e)),l.length===0&&(0,$.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No patterns — Bash only controlled by approvalRequired`})]}),(0,$.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,$.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`e.g. "rm -rf *"`,value:m,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),b())}}),(0,$.jsx)(u,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>b(),children:`Add`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`mb-1.5 block text-xs font-medium text-[var(--app-text-muted)]`,children:`Denied Read Paths`}),(0,$.jsx)(`p`,{className:`mb-2 text-xs text-[var(--app-text-subtle)]`,children:`Configured in Settings → Advanced. These paths are blocked at both the SDK and OS layer for all roles — cannot be overridden by approval.`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:[`~/.ssh`,`~/.aws`,`~/.gnupg`,`/etc/shadow`].map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-0.5 text-xs text-[var(--app-text-muted)]`,children:[(0,$.jsx)(n,{size:L.xs}),e]},e))})]})]})}function at({role:e,onSave:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e?.executionMode??`inline`),[o,s]=(0,Z.useState)(e?.model??``),[c,l]=(0,Z.useState)(e?.effortTier??``),[d,f]=(0,Z.useState)(e?.maxBudgetUsd??``);(0,Z.useEffect)(()=>{a(e?.executionMode??`inline`),s(e?.model??``),l(e?.effortTier??``),f(e?.maxBudgetUsd??``)},[e]);let p=async()=>{if(e){r(!0);try{let n={};i&&(n.executionMode=i),o!==void 0&&(n.model=o),c!==(e?.effortTier??``)&&(n.effortTier=c===``?null:c),d!==``&&(n.maxBudgetUsd=Number(d)),await h(`/roles/${e.id}`,{method:`PATCH`,body:JSON.stringify(n)}),w.success(`Execution config saved`),t()}catch(e){w.error(e instanceof Error?e.message:`Failed to save`)}finally{r(!1)}}},m=i!==(e?.executionMode??`inline`)||o!==(e?.model??``)||c!==(e?.effortTier??``)||String(d)!==String(e?.maxBudgetUsd??``);return(0,$.jsxs)(M,{children:[(0,$.jsx)(A,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(k,{children:`Execution Config`}),m&&(0,$.jsx)(u,{className:`scale-75`,onClick:()=>void p(),disabled:n,children:n?`Saving...`:`Save`})]})}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsx)(`label`,{className:`w-28 text-sm text-[var(--app-text-muted)]`,children:`Mode`}),(0,$.jsxs)(`select`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:i,onChange:e=>a(e.target.value),children:[(0,$.jsx)(`option`,{value:`inline`,children:`inline`}),(0,$.jsx)(`option`,{value:`isolated`,children:`isolated`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsx)(`label`,{className:`w-28 text-sm text-[var(--app-text-muted)]`,children:`Model`}),(0,$.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:o,onChange:e=>s(e.target.value),placeholder:`sonnet, opus, haiku, or blank to inherit`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsx)(`label`,{className:`w-28 text-sm text-[var(--app-text-muted)]`,children:`Effort Tier`}),(0,$.jsxs)(`select`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:c,onChange:e=>l(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`(inherit / use Model)`}),(0,$.jsx)(`option`,{value:`low`,children:`low (Haiku)`}),(0,$.jsx)(`option`,{value:`medium`,children:`medium (Sonnet)`}),(0,$.jsx)(`option`,{value:`high`,children:`high (Opus)`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsx)(`label`,{className:`w-28 text-sm text-[var(--app-text-muted)]`,children:`Max Budget (USD)`}),(0,$.jsx)(`input`,{type:`number`,className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:d,onChange:e=>f(e.target.value===``?``:Number(e.target.value)),placeholder:`0 = unlimited`,min:0,step:.1})]})]})]})}export{We as RoleDetail};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,n,w as r,xt as i}from"./vendor-icons-Bc_e_XXa.js";import{r as a,t as o}from"./vendor-react-bQ_cvNuA.js";import{t as s}from"./Button-CRNb8sD3.js";import{f as c,p as l,t as u}from"./index-PIFMZAPo.js";import{t as d}from"./Card-Cwvv0An8.js";import{t as f}from"./PageHeader-acLQTYct.js";import{t as p}from"./SectionHeader-NZWZgoOs.js";import{a as m}from"./format-ZWN4JNj-.js";import{t as h}from"./EmptyState-BvQA1o5K.js";import{t as g}from"./useIsMobileLayout-BogOiFTv.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./Table-D2K039zr.js";var C=e(i(),1),w=o();function T(){let e=c(e=>e.roles),i=c(e=>e.fetchRoles),o=c(e=>e.createRole),[T,E]=(0,C.useState)(!1),[D,O]=(0,C.useState)(!1),[k,A]=(0,C.useState)(``),[j,M]=(0,C.useState)(``),[N,P]=(0,C.useState)(!1),[F,I]=(0,C.useState)(null),L=g(),R=(0,C.useCallback)(async()=>{E(!0),await i(),E(!1)},[i]),z=()=>{A(``),M(``),I(null),P(!1)},B=async()=>{let e=k.trim();if(!e){I(`Name is required.`);return}P(!0),I(null);try{await o({name:e,cagPrompt:j.trim()}),await i(),O(!1),z(),l.success(`Role created`)}catch(e){I(e instanceof Error?e.message:`Failed to create role`)}finally{P(!1)}};(0,C.useEffect)(()=>{R()},[R]);let V=e=>e===`active`?`success`:e===`inactive`?`secondary`:e===`retired`?`destructive`:e===`probation`?`warning`:`secondary`,H=e.filter(e=>e.status===`active`).length,U=e.filter(e=>e.status===`probation`).length,W=e.filter(e=>e.memoryStreamId).length;return(0,w.jsxs)(`div`,{className:`space-y-5`,children:[(0,w.jsx)(f,{eyebrow:`Identities`,title:`Roles`,description:`Registry for role status, memory linkage, and edit actions.`,metrics:[{label:`Active`,value:H},{label:`Probation`,value:U},{label:`Linked Memory`,value:W}],compact:!0,actions:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void R(),disabled:T,children:(0,w.jsx)(r,{size:14,className:T?`animate-spin`:``})}),(0,w.jsxs)(s,{size:`sm`,onClick:()=>O(!0),children:[(0,w.jsx)(t,{size:14}),`New Role`]})]})}),(0,w.jsx)(p,{title:`Registry`,description:`Open a role to inspect prompts, performance, and bindings.`,compact:!0,action:(0,w.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[e.length,` role`,e.length===1?``:`s`]})}),e.length===0&&!T?(0,w.jsx)(d,{children:(0,w.jsx)(h,{title:`No roles yet`,description:`Create a role to define agent behavior and bind plugins.`})}):L?(0,w.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,w.jsxs)(d,{children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,w.jsx)(a,{to:`/roles/${e.id}`,className:`font-medium text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.name}),e.presetId&&(0,w.jsx)(u,{variant:`info`,children:`Preset`}),(0,w.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:m(e.createdAt)})]}),(0,w.jsx)(u,{variant:V(e.status),children:e.status})]}),(0,w.jsxs)(`div`,{className:`mt-4 grid gap-2 text-xs text-[var(--app-text-subtle)] sm:grid-cols-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Score`}),(0,w.jsx)(`div`,{className:`mt-1 font-mono text-[var(--app-text)]`,children:e.performanceScore==null?`—`:`${(e.performanceScore*100).toFixed(0)}%`})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Memory`}),(0,w.jsx)(`div`,{className:`mt-1 text-[var(--app-text)]`,children:e.memoryStreamId?e.memoryStreamId.slice(0,8):`—`})]})]})]},e.id))}):(0,w.jsx)(d,{padding:!1,children:(0,w.jsxs)(S,{children:[(0,w.jsx)(_,{children:(0,w.jsxs)(b,{children:[(0,w.jsx)(v,{children:`Name`}),(0,w.jsx)(v,{children:`Status`}),(0,w.jsx)(v,{children:`Score`}),(0,w.jsx)(v,{children:`Memories`}),(0,w.jsx)(v,{children:`Created`})]})}),(0,w.jsx)(y,{children:e.map(e=>(0,w.jsxs)(b,{children:[(0,w.jsx)(x,{children:(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(a,{to:`/roles/${e.id}`,className:`font-medium text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.name}),e.presetId&&(0,w.jsx)(u,{variant:`info`,children:`Preset`})]})}),(0,w.jsx)(x,{children:(0,w.jsx)(u,{variant:V(e.status),children:e.status})}),(0,w.jsx)(x,{children:e.performanceScore==null?(0,w.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`—`}):(0,w.jsxs)(`span`,{className:`font-mono text-xs text-[var(--app-text)]`,children:[(e.performanceScore*100).toFixed(0),`%`]})}),(0,w.jsx)(x,{children:(0,w.jsx)(`span`,{className:`text-sm text-[var(--app-text-muted)]`,children:e.memoryStreamId?e.memoryStreamId.slice(0,8):`—`})}),(0,w.jsx)(x,{className:`text-xs text-[var(--app-text-subtle)]`,children:m(e.createdAt)})]},e.id))})]})}),D&&(0,w.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,onClick:e=>{e.target===e.currentTarget&&(O(!1),z())},children:(0,w.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-[var(--app-border)] bg-[var(--app-panel)] p-6 shadow-lg`,children:[(0,w.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,w.jsx)(`h2`,{className:`text-lg font-semibold text-[var(--app-text)]`,children:`Create Role`}),(0,w.jsx)(`button`,{className:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,onClick:()=>{O(!1),z()},children:(0,w.jsx)(n,{size:16})})]}),(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`label`,{className:`mb-1 block text-sm font-medium text-[var(--app-text)]`,htmlFor:`role-name`,children:[`Name `,(0,w.jsx)(`span`,{className:`text-[var(--app-danger)]`,children:`*`})]}),(0,w.jsx)(`input`,{id:`role-name`,className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder-slate-500 focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`e.g. Engineer, Reviewer`,value:k,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Enter`&&B()},autoFocus:!0})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-[var(--app-text)]`,htmlFor:`role-cag-prompt`,children:`CAG Prompt`}),(0,w.jsx)(`textarea`,{id:`role-cag-prompt`,className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder-slate-500 focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Character and Guidance prompt for this role...`,rows:5,value:j,onChange:e=>M(e.target.value)})]}),F&&(0,w.jsx)(`p`,{className:`text-sm text-[var(--app-danger)]`,children:F}),(0,w.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,w.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>{O(!1),z()},children:`Cancel`}),(0,w.jsx)(s,{size:`sm`,onClick:()=>void B(),disabled:N,children:N?`Creating...`:`Create`})]})]})]})})]})}export{T as Roles};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{D as t,n,w as r,xt as i}from"./vendor-icons-Bc_e_XXa.js";import{r as a,t as o}from"./vendor-react-bQ_cvNuA.js";import{t as s}from"./Button-CRNb8sD3.js";import{f as c,p as l,t as u}from"./index-CXEJd-0s.js";import{t as d}from"./Card-Cwvv0An8.js";import{t as f}from"./PageHeader-acLQTYct.js";import{t as p}from"./SectionHeader-NZWZgoOs.js";import{a as m}from"./format-ZWN4JNj-.js";import{t as h}from"./EmptyState-BvQA1o5K.js";import{t as g}from"./useIsMobileLayout-BogOiFTv.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./Table-CvSmzzkm.js";var C=e(i(),1),w=o();function T(){let e=c(e=>e.roles),i=c(e=>e.fetchRoles),o=c(e=>e.createRole),[T,E]=(0,C.useState)(!1),[D,O]=(0,C.useState)(!1),[k,A]=(0,C.useState)(``),[j,M]=(0,C.useState)(``),[N,P]=(0,C.useState)(!1),[F,I]=(0,C.useState)(null),L=g(),R=(0,C.useCallback)(async()=>{E(!0),await i(),E(!1)},[i]),z=()=>{A(``),M(``),I(null),P(!1)},B=async()=>{let e=k.trim();if(!e){I(`Name is required.`);return}P(!0),I(null);try{await o({name:e,cagPrompt:j.trim()}),await i(),O(!1),z(),l.success(`Role created`)}catch(e){I(e instanceof Error?e.message:`Failed to create role`)}finally{P(!1)}};(0,C.useEffect)(()=>{R()},[R]);let V=e=>e===`active`?`success`:e===`inactive`?`secondary`:e===`retired`?`destructive`:e===`probation`?`warning`:`secondary`,H=e.filter(e=>e.status===`active`).length,U=e.filter(e=>e.status===`probation`).length,W=e.filter(e=>e.memoryStreamId).length;return(0,w.jsxs)(`div`,{className:`space-y-5`,children:[(0,w.jsx)(f,{eyebrow:`Identities`,title:`Roles`,description:`Registry for role status, memory linkage, and edit actions.`,metrics:[{label:`Active`,value:H},{label:`Probation`,value:U},{label:`Linked Memory`,value:W}],compact:!0,actions:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void R(),disabled:T,children:(0,w.jsx)(r,{size:14,className:T?`animate-spin`:``})}),(0,w.jsxs)(s,{size:`sm`,onClick:()=>O(!0),children:[(0,w.jsx)(t,{size:14}),`New Role`]})]})}),(0,w.jsx)(p,{title:`Registry`,description:`Open a role to inspect prompts, performance, and bindings.`,compact:!0,action:(0,w.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[e.length,` role`,e.length===1?``:`s`]})}),e.length===0&&!T?(0,w.jsx)(d,{children:(0,w.jsx)(h,{title:`No roles yet`,description:`Create a role to define agent behavior and bind plugins.`})}):L?(0,w.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,w.jsxs)(d,{children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,w.jsx)(a,{to:`/roles/${e.id}`,className:`font-medium text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.name}),e.presetId&&(0,w.jsx)(u,{variant:`info`,children:`Preset`}),(0,w.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:m(e.createdAt)})]}),(0,w.jsx)(u,{variant:V(e.status),children:e.status})]}),(0,w.jsxs)(`div`,{className:`mt-4 grid gap-2 text-xs text-[var(--app-text-subtle)] sm:grid-cols-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Score`}),(0,w.jsx)(`div`,{className:`mt-1 font-mono text-[var(--app-text)]`,children:e.performanceScore==null?`—`:`${(e.performanceScore*100).toFixed(0)}%`})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Memory`}),(0,w.jsx)(`div`,{className:`mt-1 text-[var(--app-text)]`,children:e.memoryStreamId?e.memoryStreamId.slice(0,8):`—`})]})]})]},e.id))}):(0,w.jsx)(d,{padding:!1,children:(0,w.jsxs)(S,{children:[(0,w.jsx)(_,{children:(0,w.jsxs)(b,{children:[(0,w.jsx)(v,{children:`Name`}),(0,w.jsx)(v,{children:`Status`}),(0,w.jsx)(v,{children:`Score`}),(0,w.jsx)(v,{children:`Memories`}),(0,w.jsx)(v,{children:`Created`})]})}),(0,w.jsx)(y,{children:e.map(e=>(0,w.jsxs)(b,{children:[(0,w.jsx)(x,{children:(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(a,{to:`/roles/${e.id}`,className:`font-medium text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.name}),e.presetId&&(0,w.jsx)(u,{variant:`info`,children:`Preset`})]})}),(0,w.jsx)(x,{children:(0,w.jsx)(u,{variant:V(e.status),children:e.status})}),(0,w.jsx)(x,{children:e.performanceScore==null?(0,w.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`—`}):(0,w.jsxs)(`span`,{className:`font-mono text-xs text-[var(--app-text)]`,children:[(e.performanceScore*100).toFixed(0),`%`]})}),(0,w.jsx)(x,{children:(0,w.jsx)(`span`,{className:`text-sm text-[var(--app-text-muted)]`,children:e.memoryStreamId?e.memoryStreamId.slice(0,8):`—`})}),(0,w.jsx)(x,{className:`text-xs text-[var(--app-text-subtle)]`,children:m(e.createdAt)})]},e.id))})]})}),D&&(0,w.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,onClick:e=>{e.target===e.currentTarget&&(O(!1),z())},children:(0,w.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-[var(--app-border)] bg-[var(--app-panel)] p-6 shadow-lg`,children:[(0,w.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,w.jsx)(`h2`,{className:`text-lg font-semibold text-[var(--app-text)]`,children:`Create Role`}),(0,w.jsx)(`button`,{className:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,onClick:()=>{O(!1),z()},children:(0,w.jsx)(n,{size:16})})]}),(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`label`,{className:`mb-1 block text-sm font-medium text-[var(--app-text)]`,htmlFor:`role-name`,children:[`Name `,(0,w.jsx)(`span`,{className:`text-[var(--app-danger)]`,children:`*`})]}),(0,w.jsx)(`input`,{id:`role-name`,className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder-slate-500 focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`e.g. Engineer, Reviewer`,value:k,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Enter`&&B()},autoFocus:!0})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-[var(--app-text)]`,htmlFor:`role-cag-prompt`,children:`CAG Prompt`}),(0,w.jsx)(`textarea`,{id:`role-cag-prompt`,className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder-slate-500 focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Character and Guidance prompt for this role...`,rows:5,value:j,onChange:e=>M(e.target.value)})]}),F&&(0,w.jsx)(`p`,{className:`text-sm text-[var(--app-danger)]`,children:F}),(0,w.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,w.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>{O(!1),z()},children:`Cancel`}),(0,w.jsx)(s,{size:`sm`,onClick:()=>void B(),disabled:N,children:N?`Creating...`:`Create`})]})]})]})})]})}export{T as Roles};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{R as t,S as n,b as r,f as i,n as a,w as o,xt as s,y as c}from"./vendor-icons-Bc_e_XXa.js";import{l,t as u}from"./vendor-react-bQ_cvNuA.js";import"./es2015-BkFSNOYE.js";import{t as d}from"./Button-CRNb8sD3.js";import{C as f,a as p,b as m,d as h,t as g,v as _,y as v}from"./api-BP4ZP9kk.js";import{a as y,c as b,f as x,i as S,l as C,o as w,r as T,s as E,u as D}from"./index-CXEJd-0s.js";import{t as O}from"./Card-Cwvv0An8.js";import{t as k}from"./PageHeader-acLQTYct.js";import{t as A}from"./SectionHeader-NZWZgoOs.js";import{i as j}from"./format-ZWN4JNj-.js";import{t as ee}from"./EmptyState-BvQA1o5K.js";import{t as M}from"./ui-D1crlGpt.js";import{t as te}from"./EnvVarEditor-FiiJazzp.js";var N=e(s(),1),P=u(),ne={emailGateway:{label:`Email Gateway`,paths:[`emailGateway.enabled`,`emailGateway.address`,`emailGateway.displayName`,`emailGateway.imap.host`,`emailGateway.imap.port`,`emailGateway.imap.secure`,`emailGateway.imap.auth.user`,`emailGateway.imap.auth.pass`,`emailGateway.imap.mailbox`,`emailGateway.smtp.host`,`emailGateway.smtp.port`,`emailGateway.smtp.secure`,`emailGateway.smtp.auth.user`,`emailGateway.smtp.auth.pass`,`emailGateway.smtp.from`,`emailGateway.subjectPrefix`]},anthropic:{label:`Anthropic`,paths:[`anthropic.apiKey`,`anthropic.baseUrl`,`anthropic.model`,`anthropic.defaultOpusModel`,`anthropic.defaultSonnetModel`,`anthropic.defaultHaikuModel`,`anthropic.smallFastModel`]},defaults:{label:`Defaults`,paths:[`defaults.model`,`defaults.effort`,`defaults.maxTurns`,`defaults.maxBudgetUsd`,`defaults.timeout`,`defaults.approvalTimeout`]},server:{label:`Server`,paths:[`server.port`,`server.host`],mutablePaths:[`server.timezone`]},logging:{label:`Logging`,paths:[`logging.level`]},evolution:{label:`Evolution`,paths:[`roles.evolution.triggerEvery`,`roles.evolution.reflectionThreshold`]},chat:{label:`Chat`,paths:[`chat.sessionTimeoutMinutes`,`chat.maxSessionTurns`,`chat.autoTitle`,`chat.archiveExtractMemory`]},templateExecutionArtifacts:{label:`Execution Artifacts`,paths:[`watchdog.rules.artifactCleanup.enabled`,`watchdog.rules.artifactCleanup.ttlDays`,`watchdog.rules.artifactCleanup.orphanGcMinAgeHours`]},memory:{label:`Memory`,paths:[],mutablePaths:[`memory.embeddingModel`]},cost:{label:`Cost`,paths:[],mutablePaths:[`cost.dailyThresholdUsd`]}},re={emailGateway:`Central mailbox used by Mail channels for inbound and outbound delivery.`,anthropic:`Model endpoints and provider-specific defaults.`,defaults:`Global execution defaults applied when a role does not override them.`,server:`Network surface and host-level configuration.`,logging:`Verbosity and runtime observability controls.`,evolution:`Thresholds that govern role adaptation over time.`,chat:`Session lifecycle and archive behavior for chat mode.`,templateExecutionArtifacts:`Cleanup rules and artifact retention for TemplateExecution files.`,memory:`Embedding model used for belief and memory vector search.`,cost:`Absolute daily LLM spend limit; the Cost page turns red when today's spend exceeds it. Empty/0 = disabled.`},ie=[`defaults.deniedReadPaths`,`defaults.approvalRequired`],F=new Set([`anthropic.apiKey`,`server.apiKey`,`emailGateway.imap.auth.pass`,`emailGateway.smtp.auth.pass`]),I={"anthropic.apiKey":`API Key`,"anthropic.baseUrl":`Base URL`,"anthropic.model":`Model`,"anthropic.defaultOpusModel":`Default Opus Model`,"anthropic.defaultSonnetModel":`Default Sonnet Model`,"anthropic.defaultHaikuModel":`Default Haiku Model`,"anthropic.smallFastModel":`Small Fast Model`,"defaults.model":`Default Model`,"defaults.effort":`Effort Level`,"defaults.maxTurns":`Max Turns`,"defaults.maxBudgetUsd":`Max Budget (USD)`,"defaults.timeout":`Timeout (seconds)`,"defaults.approvalTimeout":`Approval Timeout (seconds)`,"server.port":`Port`,"server.host":`Host`,"server.apiKey":`API Key (server auth)`,"server.timezone":`Timezone`,"logging.level":`Log Level`,"roles.evolution.triggerEvery":`Evolution Trigger Every (tasks)`,"roles.evolution.reflectionThreshold":`Reflection Threshold (tokens)`,"chat.sessionTimeoutMinutes":`Session Timeout (minutes)`,"chat.maxSessionTurns":`Max Session Turns`,"chat.autoTitle":`Auto-generate Session Title`,"chat.archiveExtractMemory":`Extract Memory on Archive`,"watchdog.rules.artifactCleanup.enabled":`Template Execution Artifact Cleanup Enabled`,"watchdog.rules.artifactCleanup.ttlDays":`Artifact Retention (days)`,"watchdog.rules.artifactCleanup.orphanGcMinAgeHours":`Orphan File GC Min Age (hours)`,"memory.embeddingModel":`Embedding Model`,"cost.dailyThresholdUsd":`Daily Spend Limit (USD)`,"emailGateway.enabled":`Enabled`,"emailGateway.address":`Central Email Address`,"emailGateway.displayName":`Display Name`,"emailGateway.imap.host":`IMAP Host`,"emailGateway.imap.port":`IMAP Port`,"emailGateway.imap.secure":`IMAP Secure`,"emailGateway.imap.auth.user":`IMAP User`,"emailGateway.imap.auth.pass":`IMAP Password`,"emailGateway.imap.mailbox":`IMAP Mailbox`,"emailGateway.smtp.host":`SMTP Host`,"emailGateway.smtp.port":`SMTP Port`,"emailGateway.smtp.secure":`SMTP Secure`,"emailGateway.smtp.auth.user":`SMTP User`,"emailGateway.smtp.auth.pass":`SMTP Password`,"emailGateway.smtp.from":`SMTP From Address`,"emailGateway.subjectPrefix":`Subject Prefix`},ae={"defaults.effort":[`low`,`medium`,`high`,`max`],"logging.level":[`debug`,`info`,`warn`,`error`],"memory.embeddingModel":[`bge-small-zh-v1.5`,`paraphrase-multilingual-MiniLM-L12-v2`],"server.timezone":[`system`,`Asia/Shanghai`,`Asia/Tokyo`,`Asia/Singapore`,`America/New_York`,`America/Los_Angeles`,`America/Chicago`,`Europe/London`,`Europe/Berlin`,`Europe/Paris`,`UTC`]};function L(e){return e?e.enabled?e.configured?e.lastStatus===`stopped`?`disconnected`:e.lastStatus===`error`?`failed`:e.lastStatus:`not_configured`:`disabled`:`not_checked`}function R(e){let t=`inline-flex rounded-full border px-2 py-0.5 text-xs font-medium`;return e===`connected`?`${t} border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] text-[var(--app-success-soft-text)]`:e===`degraded`||e===`starting`||e===`connecting`?`${t} border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] text-[var(--app-warning-soft-text)]`:e===`failed`?`${t} border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`:`${t} border-[var(--app-border)] bg-black/10 text-[var(--app-text-muted)]`}function z(){let[e,a]=(0,N.useState)({}),[s,u]=(0,N.useState)([]),[f,p]=(0,N.useState)({}),[m,h]=(0,N.useState)(new Set),[_,v]=(0,N.useState)(!1),[M,z]=(0,N.useState)(null),[le,ue]=(0,N.useState)(!0),[B,V]=(0,N.useState)(null),[H,U]=(0,N.useState)({}),[W,G]=(0,N.useState)(new Set),[de,fe]=(0,N.useState)({}),[K,q]=(0,N.useState)(null),[J,pe]=(0,N.useState)(null),[Y,me]=(0,N.useState)(null),he=x(e=>e.configVersion);(0,N.useEffect)(()=>{if(m.size===0)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[m.size]);let X=l(({currentLocation:e,nextLocation:t})=>m.size>0&&e.pathname!==t.pathname),Z=(0,N.useCallback)(async()=>{try{let e=await g(`/config`);a(e.config),u(e.mutable);let t={};for(let[n,r]of Object.entries(e.config))t[n]=String(r.value??``);p(t),h(new Set);let n=e.config[`server.timezone`]?.value;n&&j(n);let r={};for(let t of ie){let n=e.config[t];n&&(r[t]=Array.isArray(n.value)?n.value:[])}U(r),G(new Set),V(await g(`/config/env-diff`)),fe((await g(`/config/env`)).env),pe(await g(`/config/email-gateway/status`))}catch(e){z({type:`error`,text:e instanceof Error?e.message:`Failed to load config`})}finally{ue(!1)}},[]);(0,N.useEffect)(()=>{Z()},[Z]),(0,N.useEffect)(()=>{he>0&&Z()},[he,Z]);let ge=async()=>{await g(`/config/sync-to-env`,{method:`POST`}),z({type:`success`,text:`Synced DB values to .env`}),V(null)},_e=async()=>{await g(`/config/load-from-env`,{method:`POST`}),z({type:`success`,text:`Loaded .env values to DB`}),Z()},Q=(e,t)=>{p(n=>({...n,[e]:t})),h(t=>new Set(t).add(e)),z(null)},$=async e=>{let t=e===`imap`?`/config/email-gateway/test-imap`:e===`smtp`?`/config/email-gateway/test-smtp`:`/config/email-gateway/test-roundtrip`;me(e),z(null);try{q(await g(t,{method:`POST`}))}catch(t){q({ok:!1,stage:e,code:`unknown_error`,message:t instanceof Error?t.message:`Email Gateway test failed`})}finally{me(null)}},ve=async()=>{if(m.size!==0){v(!0),z(null);try{let t={};for(let n of m){let r=e[n],i=f[n];if(r&&typeof r.value==`number`){if(i=Number(i),isNaN(i)){z({type:`error`,text:`"${I[n]??n}" must be a number`}),v(!1);return}}else r&&typeof r.value==`boolean`&&n.startsWith(`emailGateway.`)&&(i=i===`true`);t[n]=i}let n=await g(`/config`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...Object.fromEntries(Array.from(W).map(e=>[e,H[e]??[]]))})});if(n.updated.length>0&&(z({type:`success`,text:`Updated ${n.updated.length} setting(s)`}),n.updated.includes(`server.timezone`))){let e=f[`server.timezone`];j(e)}n.errors.length>0&&z({type:`error`,text:n.errors.join(`; `)}),h(new Set),Z()}catch(e){z({type:`error`,text:e instanceof Error?e.message:`Save failed`})}finally{v(!1)}}};return le?(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,P.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):Object.keys(e).length===0?(0,P.jsx)(ee,{icon:(0,P.jsx)(c,{size:32}),title:`No configuration`,description:`Config API not available`}):(0,P.jsxs)(`div`,{className:`space-y-5`,children:[(0,P.jsx)(k,{eyebrow:`Configuration`,title:`Settings`,compact:!0,description:`Mutable fields, pending edits, and environment drift.`,metrics:[{label:`Editable`,value:s.length},{label:`Pending`,value:m.size+W.size},{label:`Env Drift`,value:B?.diffs.length??0}],actions:(0,P.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,P.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void Z(),children:(0,P.jsx)(o,{size:14})}),m.size>0&&(0,P.jsxs)(d,{size:`sm`,onClick:()=>void ve(),disabled:_,children:[(0,P.jsx)(n,{size:14}),_?`Saving...`:`Save (${m.size})`]})]})}),(0,P.jsx)(A,{title:`Configuration Groups`,compact:!0,description:`Fields stay in place while changeable, restart-required, and pending state are clarified.`}),M&&(0,P.jsx)(`div`,{className:`rounded-lg border px-4 py-3 text-sm ${M.type===`success`?`border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] text-[var(--app-success-soft-text)]`:`border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`}`,children:M.text}),B&&B.diffs.length>0&&(0,P.jsx)(O,{className:`surface-accent`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:[`.env and DB have `,B.diffs.length,` different value(s)`]}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:B.diffs.map(e=>e.envKey).join(`, `)})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2 md:justify-end`,children:[(0,P.jsx)(d,{variant:`ghost`,size:`sm`,onClick:ge,children:`Sync DB → .env`}),(0,P.jsx)(d,{variant:`ghost`,size:`sm`,onClick:_e,children:`Load .env → DB`})]})]})}),Object.entries(ne).map(([n,{label:a,paths:o,mutablePaths:c}])=>{let l=[...o,...c??[]],u=l.filter(e=>s.includes(e)).length;return(0,P.jsxs)(O,{children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:a}),(0,P.jsx)(`p`,{className:`mt-1 text-sm text-[var(--app-text-muted)]`,children:re[n]??`Configuration values for this system area.`})]}),(0,P.jsxs)(`div`,{className:`rounded-full border border-[var(--app-border)] bg-black/10 px-3 py-1.5 text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:[u,`/`,l.length,` editable`]})]}),(0,P.jsx)(`div`,{className:`space-y-3`,children:l.map(n=>{let r=e[n];if(!r)return null;let i=s.includes(n),a=I[n]??n,o=f[n]??String(r.value??``),c=m.has(n),l=ae[n],u=n.startsWith(`emailGateway.`)&&typeof r.value==`boolean`,d=`setting-${n.replace(/[^A-Za-z0-9_-]/g,`-`)}`;return(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-[var(--app-border)] bg-black/10 px-3 py-3 md:flex-row md:items-center md:gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 md:w-56 md:shrink-0`,children:[!i&&(0,P.jsx)(t,{size:12,className:`text-[var(--app-text-subtle)]`}),(0,P.jsx)(`label`,{htmlFor:d,className:`text-sm text-[var(--app-text-muted)]`,children:a}),!i&&(0,P.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`restart required`})]}),(0,P.jsx)(`div`,{className:`min-w-0 flex-1`,children:l?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`select`,{id:d,className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none disabled:opacity-50`,value:o,onChange:e=>Q(n,e.target.value),disabled:!i,children:l.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))}),n===`memory.embeddingModel`&&o===`paraphrase-multilingual-MiniLM-L12-v2`&&(0,P.jsx)(`p`,{className:`mt-1 text-[11px] text-[var(--app-warning)]`,children:`切换模型后建议清空候选 belief 的 embedding 重算(384 维与现存 512 维向量混用会导致余弦计算维度不匹配)`})]}):u?(0,P.jsxs)(`select`,{id:d,className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none disabled:opacity-50`,value:o,onChange:e=>Q(n,e.target.value),disabled:!i,children:[(0,P.jsx)(`option`,{value:`true`,children:`true`}),(0,P.jsx)(`option`,{value:`false`,children:`false`})]}):(0,P.jsx)(`input`,{id:d,className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none disabled:opacity-50`,type:F.has(n)?`password`:`text`,value:o,onChange:e=>Q(n,e.target.value),disabled:!i,placeholder:F.has(n)?`Enter to update`:void 0})}),(0,P.jsx)(`div`,{className:`text-left md:w-16 md:text-right`,children:c&&i&&(0,P.jsx)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:`modified`})})]},n)})}),n===`emailGateway`&&(0,P.jsxs)(`div`,{className:`mt-4 border-t border-[var(--app-border)] pt-4`,children:[(0,P.jsxs)(`div`,{className:`mb-3 grid gap-2 text-sm md:grid-cols-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Runtime status`}),(0,P.jsx)(`p`,{children:(0,P.jsx)(`span`,{className:R(L(J)),children:L(J)})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Last test`}),(0,P.jsx)(`p`,{children:K?(0,P.jsxs)(`span`,{className:R(K.ok?`connected`:`failed`),children:[K.stage,` `,K.code??``,`: `,K.message]}):(0,P.jsx)(`span`,{className:R(`not_checked`),children:`Not checked`})})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Last checked`}),(0,P.jsx)(`p`,{className:`text-[var(--app-text-muted)]`,children:J?.lastCheckedAt?new Date(J.lastCheckedAt).toLocaleString():`Never`})]})]}),(0,P.jsxs)(`div`,{className:`mb-3 text-sm`,children:[(0,P.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Last error`}),(0,P.jsx)(`p`,{className:`text-[var(--app-danger-soft-text)]`,children:J?.lastError??`None`})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>void $(`imap`),disabled:Y!==null,children:[(0,P.jsx)(i,{size:14}),Y===`imap`?`Testing IMAP...`:`Test IMAP`]}),(0,P.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>void $(`smtp`),disabled:Y!==null,children:[(0,P.jsx)(i,{size:14}),Y===`smtp`?`Testing SMTP...`:`Test SMTP`]}),(0,P.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>void $(`roundtrip`),disabled:Y!==null,children:[(0,P.jsx)(r,{size:14}),Y===`roundtrip`?`Sending probe...`:`Send test email`]})]})]})]},n)}),(0,P.jsx)(te,{envVars:de,onSave:()=>void Z(),mode:`global`,title:`Environment Variables`}),(0,P.jsx)(ce,{}),(0,P.jsx)(oe,{mutablePaths:s,listValues:H,listDirty:W,setListValues:U,setListDirty:e=>G(e),dirty:m}),(0,P.jsx)(se,{}),(0,P.jsx)(T,{open:X.state===`blocked`,children:(0,P.jsxs)(w,{children:[(0,P.jsxs)(C,{children:[(0,P.jsx)(D,{children:`Unsaved Changes`}),(0,P.jsxs)(E,{children:[`You have `,m.size+W.size,` unsaved change(s). Discard and leave?`]})]}),(0,P.jsxs)(b,{children:[(0,P.jsx)(y,{onClick:()=>X.reset?.(),children:`Stay`}),(0,P.jsx)(S,{onClick:()=>X.proceed?.(),children:`Discard`})]})]})})]})}function oe({mutablePaths:e,listValues:n,listDirty:r,setListValues:i,setListDirty:o,dirty:s}){let[c,l]=(0,N.useState)(``),[u,f]=(0,N.useState)(``),p=e.includes(`defaults.deniedReadPaths`),m=e.includes(`defaults.approvalRequired`),h=n[`defaults.deniedReadPaths`]??[],g=n[`defaults.approvalRequired`]??[],_=[`~/.ssh`,`~/.aws`,`~/.gnupg`,`/etc/shadow`],v=[`rm -rf *`,`git push*`,`git reset*`,`curl * -X POST*`,`curl * --request POST*`],y=e=>_.some(t=>e===(t.startsWith(`~/`),t)||e===t),b=e=>v.includes(e),x=()=>{let e=c.trim();!e||h.includes(e)||(i(t=>({...t,"defaults.deniedReadPaths":[...h,e]})),o(e=>new Set(e).add(`defaults.deniedReadPaths`)),l(``))},S=e=>{y(e)||(i(t=>({...t,"defaults.deniedReadPaths":h.filter(t=>t!==e)})),o(e=>new Set(e).add(`defaults.deniedReadPaths`)))},C=()=>{let e=u.trim();!e||g.includes(e)||(i(t=>({...t,"defaults.approvalRequired":[...g,e]})),o(e=>new Set(e).add(`defaults.approvalRequired`)),f(``))},w=e=>{b(e)||(i(t=>({...t,"defaults.approvalRequired":g.filter(t=>t!==e)})),o(e=>new Set(e).add(`defaults.approvalRequired`)))},T=s.size+r.size;return(0,P.jsxs)(O,{children:[(0,P.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Advanced`}),T>0&&(0,P.jsxs)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:[r.size,` modified`]})]}),(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,P.jsx)(`h3`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Denied Read Paths`}),!p&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[(0,P.jsx)(t,{size:M.xs}),` restart required`]})]}),(0,P.jsxs)(`p`,{className:`mb-2 text-xs text-[var(--app-text-subtle)]`,children:[`Paths blocked at both the SDK and OS layer for all roles. System defaults (locked) cannot be removed. Uses `,(0,P.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`*`}),` as wildcard.`]}),(0,P.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:h.map(e=>{let n=y(e);return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-xs ${n?`border-[var(--app-border)] bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)]`:`border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`}`,children:[n&&(0,P.jsx)(t,{size:M.xs}),e,!n&&p&&(0,P.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>S(e),children:(0,P.jsx)(a,{size:M.xs})})]},e)})}),p&&(0,P.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,P.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`/absolute/path or ~/path`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),x())}}),(0,P.jsx)(d,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>x(),children:`Add`})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,P.jsx)(`h3`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Approval Required Patterns`}),!m&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[(0,P.jsx)(t,{size:M.xs}),` restart required`]})]}),(0,P.jsxs)(`p`,{className:`mb-2 text-xs text-[var(--app-text-subtle)]`,children:[`Operations matching these glob patterns require user approval before execution. Uses SDK Permission Rule glob syntax (`,(0,P.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`*`}),` = wildcard, e.g.,`,` `,(0,P.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`rm -rf *`}),`).`]}),(0,P.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:g.map(e=>{let n=b(e);return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-xs ${n?`border-[var(--app-border)] bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)]`:`border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] text-[var(--app-warning-soft-text)]`}`,children:[n&&(0,P.jsx)(t,{size:M.xs}),e,!n&&m&&(0,P.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-warning)] hover:text-[var(--app-warning-soft-text)]`,onClick:()=>w(e),children:(0,P.jsx)(a,{size:M.xs})})]},e)})}),m&&(0,P.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,P.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`e.g. "curl * --request POST *"`,value:u,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),C())}}),(0,P.jsx)(d,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>C(),children:`Add`})]})]})]})}function se(){let[e,t]=(0,N.useState)([]),[n,r]=(0,N.useState)(!0),[i,a]=(0,N.useState)(!1),[o,s]=(0,N.useState)(null),[c,l]=(0,N.useState)(15),[u,p]=(0,N.useState)(30),[m,h]=(0,N.useState)(500),[_,v]=(0,N.useState)(!1),y=2e3,b=e.find(e=>e.presetId===`feature-mining`)?.id;(0,N.useEffect)(()=>{(async()=>{try{let e=(await g(`/task-templates`)).templates.find(e=>e.presetId===`feature-mining`);e&&(t([e]),l(e.config?.max_sessions??15),p(e.config?.max_messages_per_session??30),h(e.config?.message_char_cap??500))}catch{}finally{r(!1)}})()},[]);let x=async()=>{if(b){a(!0),s(null);try{await f(b,{max_sessions:c,max_messages_per_session:u,message_char_cap:m}),s({type:`success`,text:`Feature Miner limits saved`}),v(!1)}catch(e){s({type:`error`,text:e instanceof Error?e.message:`Save failed`})}finally{a(!1)}}};if(n||!b)return null;let S=c*u*Math.min(m,100)/4,C=`~${Math.round(S).toLocaleString()} tokens (worst case)`;return(0,P.jsxs)(O,{children:[(0,P.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Feature Miner Pre-fetch Limits`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:`Controls how many chat sessions and messages the Feature Miner scans per run. Hard ceilings prevent prompt size from exceeding the model's context window.`})]}),_&&(0,P.jsx)(d,{size:`sm`,onClick:()=>void x(),disabled:i,children:i?`Saving...`:`Save`})]}),o&&(0,P.jsx)(`div`,{className:`mb-3 rounded px-3 py-2 text-xs ${o.type===`success`?`border border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] text-[var(--app-success-soft-text)]`:`border border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`}`,children:o.text}),(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`label`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,htmlFor:`fm-max-sessions`,children:`Max Sessions`}),(0,P.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`ceiling: `,50]})]}),(0,P.jsx)(`input`,{id:`fm-max-sessions`,type:`number`,min:1,max:50,value:c,onChange:e=>{l(Math.min(50,Math.max(1,parseInt(e.target.value)||1))),v(!0)},className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`}),(0,P.jsx)(`p`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`Sessions to scan (most recent first). Default: 15.`})]}),(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`label`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,htmlFor:`fm-max-messages`,children:`Max Messages / Session`}),(0,P.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`ceiling: `,100]})]}),(0,P.jsx)(`input`,{id:`fm-max-messages`,type:`number`,min:1,max:100,value:u,onChange:e=>{p(Math.min(100,Math.max(1,parseInt(e.target.value)||1))),v(!0)},className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`}),(0,P.jsx)(`p`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`Most recent messages per session. Default: 30.`})]}),(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`label`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,htmlFor:`fm-char-cap`,children:`Message Char Cap`}),(0,P.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`ceiling: `,y]})]}),(0,P.jsx)(`input`,{id:`fm-char-cap`,type:`number`,min:10,max:y,value:m,onChange:e=>{h(Math.min(y,Math.max(10,parseInt(e.target.value)||10))),v(!0)},className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`}),(0,P.jsx)(`p`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`Max characters per message. Default: 500.`})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Estimated worst-case prompt size`}),(0,P.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:C})]}),S>15e4&&(0,P.jsx)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:`Near context window limit`})]})]})]})}function ce(){let e=h()??``,[t,n]=(0,N.useState)(!1),[r,i]=(0,N.useState)(!1),[s,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(null),[f,g]=(0,N.useState)(null),x=e.length>12?e.slice(0,4)+`****`+e.slice(-4):`(no key in localStorage)`;async function k(){i(!0),g(null);try{let e=await v();m(e),u(e),c(!1)}catch(e){g(e instanceof Error?e.message:String(e)),c(!1)}finally{i(!1)}}function j(){p(),_()}return(0,P.jsxs)(O,{children:[(0,P.jsx)(A,{title:`Adam API Key`,description:`Rotate or sign out`}),(0,P.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`code`,{className:`flex-1 rounded bg-[var(--app-bg)] px-3 py-2 font-mono text-sm`,children:t?e||`(no key)`:x}),(0,P.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>n(e=>!e),children:t?`Hide`:`Show`})]}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>c(!0),disabled:r,children:[(0,P.jsx)(o,{size:M.xs,className:`mr-1`}),`Rotate key`]}),(0,P.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:j,children:[(0,P.jsx)(a,{size:M.xs,className:`mr-1`}),`Log out`]})]}),f&&(0,P.jsx)(`div`,{className:`rounded border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-400`,children:f}),(0,P.jsxs)(`p`,{className:`text-xs text-[var(--app-muted)]`,children:[`Rotating generates a new key, writes it to `,(0,P.jsx)(`code`,{children:`~/.adam/adam.key`}),`, and invalidates the old key on every device that uses the Adam API (Web UI, TUI, other browsers). Channel adapters (WeChat, Telegram, Discord) keep their own credentials and are NOT affected. Only external callers of your `,(0,P.jsx)(`code`,{children:`/webhooks/:name`}),` endpoints need the new key.`]})]}),(0,P.jsx)(T,{open:s,children:(0,P.jsxs)(w,{children:[(0,P.jsxs)(C,{children:[(0,P.jsx)(D,{children:`Rotate API key?`}),(0,P.jsxs)(E,{children:[`The old key stops working immediately. Other browsers/TUI sessions and any external callers of `,(0,P.jsx)(`code`,{children:`/webhooks/:name`}),` will return 401 until updated. Channel adapters (WeChat, Telegram, Discord) use their own credentials and are not affected.`]})]}),(0,P.jsxs)(b,{children:[(0,P.jsx)(y,{onClick:()=>c(!1),children:`Cancel`}),(0,P.jsx)(S,{onClick:k,disabled:r,children:r?`Rotating...`:`Rotate`})]})]})}),(0,P.jsx)(T,{open:!!l,children:(0,P.jsxs)(w,{children:[(0,P.jsxs)(C,{children:[(0,P.jsx)(D,{children:`New API key`}),(0,P.jsx)(E,{children:`Save this somewhere safe. Other devices and channels need to be updated with this key.`})]}),(0,P.jsx)(`code`,{className:`mt-2 block break-all rounded bg-[var(--app-bg)] p-3 font-mono text-xs`,children:l}),(0,P.jsxs)(b,{children:[(0,P.jsx)(S,{onClick:()=>{l&&navigator.clipboard.writeText(l)},children:`Copy`}),(0,P.jsx)(S,{onClick:()=>u(null),children:`Done`})]})]})})]})}export{z as Settings};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{V as t,w as n,xt as r}from"./vendor-icons-Bc_e_XXa.js";import{t as i}from"./vendor-react-bQ_cvNuA.js";import{t as a}from"./Button-CRNb8sD3.js";import{f as o,t as s}from"./index-PIFMZAPo.js";import{t as c}from"./Card-Cwvv0An8.js";import{t as l}from"./PageHeader-acLQTYct.js";import{a as u}from"./format-ZWN4JNj-.js";import{t as d}from"./EmptyState-BvQA1o5K.js";import{a as f,i as p,n as m,o as h,r as g,t as _}from"./Table-D2K039zr.js";var v=e(r(),1),y=i(),b={engineer:`info`,analyst:`warning`,content_creator:`success`,reviewer:`muted`};function x(){let e=o(e=>e.strategies),r=o(e=>e.fetchStrategies);(0,v.useEffect)(()=>{r()},[r]);let i=new Map;for(let t of e){let e=i.get(t.roleId)??[];e.push(t),i.set(t.roleId,e)}return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsx)(l,{compact:!0,title:`Strategies`,description:`Bandit strategies grouped by role.`,metrics:[{label:`Catalog`,value:e.length},{label:`Roles`,value:i.size},{label:`Mature`,value:e.filter(e=>e.totalTrials>=10).length}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,y.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void r(),children:(0,y.jsx)(n,{size:14})})}),e.length===0?(0,y.jsx)(c,{className:`p-4`,children:(0,y.jsx)(d,{icon:(0,y.jsx)(t,{size:32}),title:`No strategies`,description:`Strategies are created by the Thompson Sampling engine as agents process tasks.`,compact:!0})}):Array.from(i.entries()).map(([e,t])=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(s,{variant:b[e]??`muted`,children:e}),(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[t.length,` strategies`]})]}),(0,y.jsx)(c,{padding:!1,children:(0,y.jsxs)(_,{children:[(0,y.jsx)(f,{children:(0,y.jsxs)(h,{children:[(0,y.jsx)(p,{children:`Name`}),(0,y.jsx)(p,{children:`Task Type`}),(0,y.jsx)(p,{children:`Alpha`}),(0,y.jsx)(p,{children:`Beta`}),(0,y.jsx)(p,{children:`Trials`}),(0,y.jsx)(p,{children:`Avg Reward`}),(0,y.jsx)(p,{children:`Created`})]})}),(0,y.jsx)(m,{children:t.map(e=>(0,y.jsxs)(h,{children:[(0,y.jsx)(g,{className:`font-medium text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(g,{children:(0,y.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--app-text-muted)]`,children:e.taskType})}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.alpha.toFixed(2)}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.beta.toFixed(2)}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.totalTrials}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.avgReward==null?`—`:e.avgReward.toFixed(3)}),(0,y.jsx)(g,{className:`text-xs text-[var(--app-text-subtle)]`,children:u(e.createdAt)})]},e.id))})]})})]},e))]})}export{x as Strategies};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{V as t,w as n,xt as r}from"./vendor-icons-Bc_e_XXa.js";import{t as i}from"./vendor-react-bQ_cvNuA.js";import{t as a}from"./Button-CRNb8sD3.js";import{f as o,t as s}from"./index-CXEJd-0s.js";import{t as c}from"./Card-Cwvv0An8.js";import{t as l}from"./PageHeader-acLQTYct.js";import{a as u}from"./format-ZWN4JNj-.js";import{t as d}from"./EmptyState-BvQA1o5K.js";import{a as f,i as p,n as m,o as h,r as g,t as _}from"./Table-CvSmzzkm.js";var v=e(r(),1),y=i(),b={engineer:`info`,analyst:`warning`,content_creator:`success`,reviewer:`muted`};function x(){let e=o(e=>e.strategies),r=o(e=>e.fetchStrategies);(0,v.useEffect)(()=>{r()},[r]);let i=new Map;for(let t of e){let e=i.get(t.roleId)??[];e.push(t),i.set(t.roleId,e)}return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsx)(l,{compact:!0,title:`Strategies`,description:`Bandit strategies grouped by role.`,metrics:[{label:`Catalog`,value:e.length},{label:`Roles`,value:i.size},{label:`Mature`,value:e.filter(e=>e.totalTrials>=10).length}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,y.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void r(),children:(0,y.jsx)(n,{size:14})})}),e.length===0?(0,y.jsx)(c,{className:`p-4`,children:(0,y.jsx)(d,{icon:(0,y.jsx)(t,{size:32}),title:`No strategies`,description:`Strategies are created by the Thompson Sampling engine as agents process tasks.`,compact:!0})}):Array.from(i.entries()).map(([e,t])=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(s,{variant:b[e]??`muted`,children:e}),(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[t.length,` strategies`]})]}),(0,y.jsx)(c,{padding:!1,children:(0,y.jsxs)(_,{children:[(0,y.jsx)(f,{children:(0,y.jsxs)(h,{children:[(0,y.jsx)(p,{children:`Name`}),(0,y.jsx)(p,{children:`Task Type`}),(0,y.jsx)(p,{children:`Alpha`}),(0,y.jsx)(p,{children:`Beta`}),(0,y.jsx)(p,{children:`Trials`}),(0,y.jsx)(p,{children:`Avg Reward`}),(0,y.jsx)(p,{children:`Created`})]})}),(0,y.jsx)(m,{children:t.map(e=>(0,y.jsxs)(h,{children:[(0,y.jsx)(g,{className:`font-medium text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(g,{children:(0,y.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--app-text-muted)]`,children:e.taskType})}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.alpha.toFixed(2)}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.beta.toFixed(2)}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.totalTrials}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.avgReward==null?`—`:e.avgReward.toFixed(3)}),(0,y.jsx)(g,{className:`text-xs text-[var(--app-text-subtle)]`,children:u(e.createdAt)})]},e.id))})]})})]},e))]})}export{x as Strategies};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{n as r}from"./dist-CgGno8kE.js";import{_ as i,a,f as o,v as s}from"./es2015-BkFSNOYE.js";import{i as c}from"./Button-CRNb8sD3.js";import{C as l}from"./index-PIFMZAPo.js";var u=e(t(),1);function d(e){let t=u.useRef({value:e,previous:e});return u.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var f=n(),p=`Switch`,[m,h]=i(p),[g,_]=m(p),v=u.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:l,required:d,disabled:m,value:h=`on`,onCheckedChange:_,form:v,...y}=e,[b,x]=u.useState(null),w=c(t,e=>x(e)),T=u.useRef(!1),E=b?v||!!b.closest(`form`):!0,[D,O]=a({prop:i,defaultProp:l??!1,onChange:_,caller:p});return(0,f.jsxs)(g,{scope:n,checked:D,disabled:m,children:[(0,f.jsx)(o.button,{type:`button`,role:`switch`,"aria-checked":D,"aria-required":d,"data-state":C(D),"data-disabled":m?``:void 0,disabled:m,value:h,...y,ref:w,onClick:s(e.onClick,e=>{O(e=>!e),E&&(T.current=e.isPropagationStopped(),T.current||e.stopPropagation())})}),E&&(0,f.jsx)(S,{control:b,bubbles:!T.current,name:r,value:h,checked:D,required:d,disabled:m,form:v,style:{transform:`translateX(-100%)`}})]})});v.displayName=p;var y=`SwitchThumb`,b=u.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=_(y,n);return(0,f.jsx)(o.span,{"data-state":C(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});b.displayName=y;var x=`SwitchBubbleInput`,S=u.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=u.useRef(null),s=c(o,a),p=d(n),m=l(t);return u.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(p!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[p,n,r]),(0,f.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...m,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});S.displayName=x;function C(e){return e?`checked`:`unchecked`}var w=v,T=b,E=u.forwardRef(({className:e,...t},n)=>(0,f.jsx)(w,{className:r(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--app-canvas)] disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-[var(--app-accent)] data-[state=unchecked]:bg-[var(--app-panel-muted)]`,e),...t,ref:n,children:(0,f.jsx)(T,{className:r(`pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})}));E.displayName=w.displayName;export{E as t};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{xt as t}from"./vendor-icons-Bc_e_XXa.js";import{t as n}from"./vendor-react-bQ_cvNuA.js";import{n as r}from"./dist-CgGno8kE.js";import{_ as i,a,f as o,v as s}from"./es2015-BkFSNOYE.js";import{i as c}from"./Button-CRNb8sD3.js";import{C as l}from"./index-CXEJd-0s.js";var u=e(t(),1);function d(e){let t=u.useRef({value:e,previous:e});return u.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var f=n(),p=`Switch`,[m,h]=i(p),[g,_]=m(p),v=u.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:l,required:d,disabled:m,value:h=`on`,onCheckedChange:_,form:v,...y}=e,[b,x]=u.useState(null),w=c(t,e=>x(e)),T=u.useRef(!1),E=b?v||!!b.closest(`form`):!0,[D,O]=a({prop:i,defaultProp:l??!1,onChange:_,caller:p});return(0,f.jsxs)(g,{scope:n,checked:D,disabled:m,children:[(0,f.jsx)(o.button,{type:`button`,role:`switch`,"aria-checked":D,"aria-required":d,"data-state":C(D),"data-disabled":m?``:void 0,disabled:m,value:h,...y,ref:w,onClick:s(e.onClick,e=>{O(e=>!e),E&&(T.current=e.isPropagationStopped(),T.current||e.stopPropagation())})}),E&&(0,f.jsx)(S,{control:b,bubbles:!T.current,name:r,value:h,checked:D,required:d,disabled:m,form:v,style:{transform:`translateX(-100%)`}})]})});v.displayName=p;var y=`SwitchThumb`,b=u.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=_(y,n);return(0,f.jsx)(o.span,{"data-state":C(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});b.displayName=y;var x=`SwitchBubbleInput`,S=u.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=u.useRef(null),s=c(o,a),p=d(n),m=l(t);return u.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(p!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[p,n,r]),(0,f.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...m,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});S.displayName=x;function C(e){return e?`checked`:`unchecked`}var w=v,T=b,E=u.forwardRef(({className:e,...t},n)=>(0,f.jsx)(w,{className:r(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--app-canvas)] disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-[var(--app-accent)] data-[state=unchecked]:bg-[var(--app-panel-muted)]`,e),...t,ref:n,children:(0,f.jsx)(T,{className:r(`pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})}));E.displayName=w.displayName;export{E as t};