adam-agent-server 1.16.0 → 1.17.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 (191) hide show
  1. package/dist/App-SIQUVFJY.js +14 -0
  2. package/dist/approval-handler-FONN2EGB.js +1 -0
  3. package/dist/{artifacts-S2KD6W76.js → artifacts-DMY2MI2F.js} +1 -1
  4. package/dist/audit-diagnostics-D4M4SA5O.js +1 -0
  5. package/dist/audit-manager-YEOJRE6K.js +1 -0
  6. package/dist/bree-engine-RGTBKKFE.js +1 -0
  7. package/dist/channels-VYNJFXDD.js +1 -0
  8. package/dist/channels-WFU4CVGW.js +1 -0
  9. package/dist/chat-tool-calls-WQGFYTUV.js +1 -0
  10. package/dist/{chunk-TCBGUVVU.js → chunk-2RBYM3X7.js} +1 -1
  11. package/dist/chunk-2V2H5PG5.js +182 -0
  12. package/dist/{chunk-TJTH7LHX.js → chunk-2WPUKCDA.js} +1 -1
  13. package/dist/{chunk-6Y2DN2UH.js → chunk-32D5GWJD.js} +1 -1
  14. package/dist/chunk-3GK65T2V.js +6 -0
  15. package/dist/chunk-3R7VGMAK.js +6 -0
  16. package/dist/{chunk-OXGWWSKT.js → chunk-3RITIMKB.js} +1 -1
  17. package/dist/{chunk-3UR2PN5N.js → chunk-3VUEB67V.js} +1 -1
  18. package/dist/{chunk-P5Q2UINT.js → chunk-4G2OZPP5.js} +1 -1
  19. package/dist/{chunk-NUJSTEV4.js → chunk-4N5G7ND2.js} +1 -1
  20. package/dist/{chunk-YNS5LQX5.js → chunk-4WJ2VSEJ.js} +1 -1
  21. package/dist/{chunk-TLMG5W3L.js → chunk-5G64P4KE.js} +1 -1
  22. package/dist/{chunk-245WE5AF.js → chunk-5M6IGE5G.js} +1 -1
  23. package/dist/chunk-5PELJRUQ.js +1 -0
  24. package/dist/{chunk-I44JKROJ.js → chunk-5WBFQMJL.js} +1 -1
  25. package/dist/chunk-725BGAO2.js +143 -0
  26. package/dist/{chunk-OGY42NUN.js → chunk-73GP6K5S.js} +1 -1
  27. package/dist/{chunk-HC34HJFF.js → chunk-7IXYCDUF.js} +1 -1
  28. package/dist/{chunk-H4MMEULK.js → chunk-A2S67EQG.js} +2 -2
  29. package/dist/{chunk-HXDS4NWI.js → chunk-A57SY3E4.js} +1 -1
  30. package/dist/{chunk-N2OLEUAQ.js → chunk-BRUHXRKK.js} +1 -1
  31. package/dist/{chunk-XYZVMTNN.js → chunk-CFPXWGFD.js} +1 -1
  32. package/dist/{chunk-VVQ532U2.js → chunk-D5PAJ3CB.js} +1 -1
  33. package/dist/{chunk-LQVBWVLE.js → chunk-DCTNMUQ5.js} +1 -1
  34. package/dist/{chunk-LVHLUAZW.js → chunk-ED2JAMEN.js} +8 -7
  35. package/dist/{chunk-BLCNUT53.js → chunk-EZLBMUQD.js} +1 -1
  36. package/dist/{chunk-ASPPM7TQ.js → chunk-FJ3DUJXO.js} +1 -1
  37. package/dist/chunk-FMJVKJJE.js +1 -0
  38. package/dist/{chunk-NLTYJUQG.js → chunk-HL373H4P.js} +1 -1
  39. package/dist/chunk-K3HWZBE5.js +10 -0
  40. package/dist/{chunk-R24YRJRG.js → chunk-MQTK4Q6M.js} +1 -1
  41. package/dist/chunk-NV5ZXKKF.js +61 -0
  42. package/dist/chunk-OH6VBBDV.js +1 -0
  43. package/dist/{chunk-SCUPWMI5.js → chunk-OII5SDMS.js} +1 -1
  44. package/dist/{chunk-MTQI6B7T.js → chunk-P76VP2UH.js} +3 -3
  45. package/dist/{chunk-AQAHVNNG.js → chunk-PBKZDNNV.js} +5 -5
  46. package/dist/{chunk-HJICGOD4.js → chunk-QWIBCFPC.js} +1 -1
  47. package/dist/{chunk-AG5SADAI.js → chunk-SJTIMT5U.js} +1 -1
  48. package/dist/chunk-TNBQFCXR.js +14 -0
  49. package/dist/chunk-TO27F23C.js +2 -0
  50. package/dist/chunk-UAF4KNXE.js +32 -0
  51. package/dist/{chunk-FYULPPFR.js → chunk-UUJ24BNJ.js} +1 -1
  52. package/dist/{chunk-QL2ZOLMC.js → chunk-VARIYH6K.js} +92 -6
  53. package/dist/{chunk-WBAPIPST.js → chunk-VO24C673.js} +1 -1
  54. package/dist/{chunk-52FETPCI.js → chunk-VSSKQAG5.js} +1 -1
  55. package/dist/{chunk-VKKDSXMR.js → chunk-VVBN35YG.js} +1 -1
  56. package/dist/chunk-WDSCTXT7.js +1 -0
  57. package/dist/chunk-YEBC67DJ.js +1 -0
  58. package/dist/cli.js +2 -2
  59. package/dist/config-GRL6O2ZY.js +1 -0
  60. package/dist/config-ZDKMTZJC.js +1 -0
  61. package/dist/db-LIKGSZCL.js +1 -0
  62. package/dist/{delivery-log-3O3OHKY4.js → delivery-log-2ILFP673.js} +1 -1
  63. package/dist/engine-JVPM3XE5.js +1 -0
  64. package/dist/evolution-audit-BDQM6NAX.js +1 -0
  65. package/dist/execution-tools-7MK257DY.js +1 -0
  66. package/dist/{external-api-YMEFVZGG.js → external-api-7GB3U775.js} +1 -1
  67. package/dist/index.js +41 -41
  68. package/dist/learner-V2HBTRAE.js +1 -0
  69. package/dist/logger-TEZSHFTZ.js +1 -0
  70. package/dist/{memories-2DY5G6ZN.js → memories-B3QGTYLX.js} +1 -1
  71. package/dist/memory-extractor-RYZ3VU7A.js +1 -0
  72. package/dist/memory-gc-5AYND3RL.js +1 -0
  73. package/dist/memory-service-XI3JZQ4E.js +1 -0
  74. package/dist/outbound-gateway-O27KKVOI.js +1 -0
  75. package/dist/presets-UAH3OG3C.js +1 -0
  76. package/dist/reflection-job-P6GIQVQN.js +23 -0
  77. package/dist/role-presets-RVYTO5FS.js +1 -0
  78. package/dist/role-workspace-KOTVFJD3.js +1 -0
  79. package/dist/roles-B6YC4GDC.js +1 -0
  80. package/dist/{runtime-TWLGJSL6.js → runtime-C3XN33A3.js} +1 -1
  81. package/dist/server-bus-6QGH2AVL.js +1 -0
  82. package/dist/session-manager-HO2ZCB47.js +1 -0
  83. package/dist/skill-registry-X2GY7SMI.js +1 -0
  84. package/dist/target-resolution-RLNUCT6M.js +1 -0
  85. package/dist/{task-templates-4YPKFFKG.js → task-templates-MNCF7JON.js} +1 -1
  86. package/dist/template-dispatch-BAMKX3QH.js +1 -0
  87. package/dist/trace-context-NVCN6UPC.js +1 -0
  88. package/package.json +2 -1
  89. package/web/dist/assets/{ArtifactDetail-9DJdEqCz.js → ArtifactDetail-Dt_xkaYJ.js} +2 -2
  90. package/web/dist/assets/{Artifacts-CQ6SAemH.js → Artifacts-DlPMk9VQ.js} +1 -1
  91. package/web/dist/assets/{Button-xVc-P0vm.js → Button-CRNb8sD3.js} +1 -1
  92. package/web/dist/assets/{Card-WUD1cwG6.js → Card-Cwvv0An8.js} +1 -1
  93. package/web/dist/assets/{ChannelDetail-B21nBQwi.js → ChannelDetail-kYtMmy6P.js} +1 -1
  94. package/web/dist/assets/{Channels-CAeGE1r7.js → Channels-BppR0Qc_.js} +2 -2
  95. package/web/dist/assets/{Chat-KpFWchPp.js → Chat-BLVREMCu.js} +2 -2
  96. package/web/dist/assets/{Dashboard-DkRwHNmr.js → Dashboard-XURc0f15.js} +1 -1
  97. package/web/dist/assets/{EmptyState-BLB33cKG.js → EmptyState-BvQA1o5K.js} +1 -1
  98. package/web/dist/assets/{EnvVarEditor-BchUNrmz.js → EnvVarEditor-DR-bSU0w.js} +1 -1
  99. package/web/dist/assets/{EventDefDetail-DnBwWWfT.js → EventDefDetail-DtkbGbQ0.js} +1 -1
  100. package/web/dist/assets/{Events-ByIzPIs2.js → Events-C_J4jvDh.js} +1 -1
  101. package/web/dist/assets/{Evolution-Vh9RKdma.js → Evolution-CEaSpRAm.js} +1 -1
  102. package/web/dist/assets/{ExtensionDetail-0CtJh5rF.js → ExtensionDetail-D5Qfq-W4.js} +1 -1
  103. package/web/dist/assets/{Extensions--O1ulwlC.js → Extensions-B_egkUP1.js} +1 -1
  104. package/web/dist/assets/{FeatureRequests-XhQbGg_q.js → FeatureRequests-D8WEYtoU.js} +1 -1
  105. package/web/dist/assets/{GoalDetail-DIOxf7ES.js → GoalDetail-DnMS_WWw.js} +1 -1
  106. package/web/dist/assets/{Goals-CZnHu9qC.js → Goals-BeKwpAss.js} +1 -1
  107. package/web/dist/assets/Logs-BfXBv-dV.js +1 -0
  108. package/web/dist/assets/{Memories-D-EAODUg.js → Memories-QRH7O8qP.js} +1 -1
  109. package/web/dist/assets/{Mistakes-wW78K3cP.js → Mistakes-mXU9PXft.js} +1 -1
  110. package/web/dist/assets/{NotFound-BsxIP-Xm.js → NotFound-DuH6sFz7.js} +1 -1
  111. package/web/dist/assets/{PageHeader-D8pqg_wk.js → PageHeader-acLQTYct.js} +1 -1
  112. package/web/dist/assets/Plugins-C8v4AsvM.js +1 -0
  113. package/web/dist/assets/{RoleDetail-CU3G9j_q.js → RoleDetail-Ct-k3uoK.js} +3 -3
  114. package/web/dist/assets/Roles-B8dQCKuS.js +1 -0
  115. package/web/dist/assets/{SectionHeader-DZo4QVWr.js → SectionHeader-NZWZgoOs.js} +1 -1
  116. package/web/dist/assets/Settings-CqtCBP6I.js +1 -0
  117. package/web/dist/assets/{Strategies-Bg4qlLei.js → Strategies-DFUWEKfU.js} +1 -1
  118. package/web/dist/assets/{Switch-WWPXnSOG.js → Switch-BcS5rOWb.js} +1 -1
  119. package/web/dist/assets/{Table-XjSmrOyn.js → Table-D2K039zr.js} +1 -1
  120. package/web/dist/assets/{Tabs-CSbcG_5T.js → Tabs-BwyLSH2c.js} +1 -1
  121. package/web/dist/assets/TaskDetail-BdhBhvKg.js +2 -0
  122. package/web/dist/assets/Work-D-t80Ekv.js +1 -0
  123. package/web/dist/assets/api-BRfbZQSW.js +1 -0
  124. package/web/dist/assets/{es2015-BgPT8VkR.js → es2015-BkFSNOYE.js} +1 -1
  125. package/web/dist/assets/index-DWU9AURw.css +2 -0
  126. package/web/dist/assets/index-PIFMZAPo.js +12 -0
  127. package/web/dist/assets/{useIsMobileLayout-DF2fEEM9.js → useIsMobileLayout-BogOiFTv.js} +1 -1
  128. package/web/dist/assets/{usePluginsWithUsage-CjU8Lkdn.js → usePluginsWithUsage-DE13JW16.js} +1 -1
  129. package/web/dist/assets/{vendor-icons-H7p0EuQJ.js → vendor-icons-Bc_e_XXa.js} +1 -1
  130. package/web/dist/assets/{vendor-react-C1yKjxEP.js → vendor-react-bQ_cvNuA.js} +1 -1
  131. package/web/dist/assets/{vendor-state-D0TNAbOY.js → vendor-state-BMVR_B0I.js} +1 -1
  132. package/web/dist/index.html +8 -8
  133. package/dist/App-Z2GJAMX3.js +0 -14
  134. package/dist/approval-handler-6NPN24UN.js +0 -1
  135. package/dist/audit-diagnostics-2MDM3IQT.js +0 -1
  136. package/dist/audit-manager-QG7CMBV2.js +0 -1
  137. package/dist/bree-engine-3QSLZF3W.js +0 -1
  138. package/dist/channels-S4AAOOTN.js +0 -1
  139. package/dist/channels-TYXSSI7D.js +0 -1
  140. package/dist/chat-tool-calls-2C7O4B2X.js +0 -1
  141. package/dist/chunk-32LOJEHE.js +0 -32
  142. package/dist/chunk-3UZIEE2D.js +0 -6
  143. package/dist/chunk-4234WJJD.js +0 -178
  144. package/dist/chunk-C2XFPUFV.js +0 -1
  145. package/dist/chunk-DRO3DG7X.js +0 -1
  146. package/dist/chunk-EWYXVBOG.js +0 -61
  147. package/dist/chunk-FCV2DPZQ.js +0 -1
  148. package/dist/chunk-FHESRUJY.js +0 -9
  149. package/dist/chunk-K2TZW4DU.js +0 -132
  150. package/dist/chunk-K4IE6DPX.js +0 -6
  151. package/dist/chunk-MNSZE3NV.js +0 -1
  152. package/dist/chunk-WVHN54MA.js +0 -14
  153. package/dist/chunk-Z6LHGA27.js +0 -1
  154. package/dist/config-HDAAV5FV.js +0 -1
  155. package/dist/config-VHWLMFIN.js +0 -1
  156. package/dist/db-HFBXO2O5.js +0 -1
  157. package/dist/dist-HCSYRPJU.js +0 -1
  158. package/dist/engine-J43ECCH7.js +0 -1
  159. package/dist/evolution-audit-BSGPFGFK.js +0 -1
  160. package/dist/execution-tools-HHUPWLCF.js +0 -1
  161. package/dist/learner-TQQZKRSB.js +0 -1
  162. package/dist/logger-PAMNFWI3.js +0 -1
  163. package/dist/memory-extractor-TUOOFST2.js +0 -1
  164. package/dist/memory-gc-MRO53MEY.js +0 -1
  165. package/dist/memory-service-23WVAW7T.js +0 -1
  166. package/dist/onnxruntime_binding-2BPLI7ZQ.node +0 -0
  167. package/dist/onnxruntime_binding-5J67DTMJ.node +0 -0
  168. package/dist/onnxruntime_binding-7ZZLEQ2F.node +0 -0
  169. package/dist/onnxruntime_binding-KDCXAPN5.node +0 -0
  170. package/dist/onnxruntime_binding-R73P2IQW.node +0 -0
  171. package/dist/outbound-gateway-VXODXSQR.js +0 -1
  172. package/dist/presets-KJV6SNNB.js +0 -1
  173. package/dist/reflection-job-EFFW3WOR.js +0 -23
  174. package/dist/role-presets-PHHL3OEN.js +0 -1
  175. package/dist/role-workspace-USY47ZPQ.js +0 -1
  176. package/dist/roles-3JXNHL7K.js +0 -1
  177. package/dist/server-bus-GEGVMSCA.js +0 -1
  178. package/dist/session-manager-PI3JEINK.js +0 -1
  179. package/dist/skill-registry-ROGU2WED.js +0 -1
  180. package/dist/target-resolution-PSSBM4LX.js +0 -1
  181. package/dist/template-dispatch-46TN534D.js +0 -1
  182. package/dist/trace-context-UR7DI5ME.js +0 -1
  183. package/web/dist/assets/Logs-DdeG3GiY.js +0 -1
  184. package/web/dist/assets/Plugins-DDUdX51_.js +0 -1
  185. package/web/dist/assets/Roles-BCoSzDBg.js +0 -1
  186. package/web/dist/assets/Settings-K3usfV-2.js +0 -1
  187. package/web/dist/assets/TaskDetail-C5roukcV.js +0 -2
  188. package/web/dist/assets/Work-DGTWSgtc.js +0 -1
  189. package/web/dist/assets/api-BkdixMz9.js +0 -1
  190. package/web/dist/assets/index-KNUbHDLy.css +0 -2
  191. package/web/dist/assets/index-iD-HOtIu.js +0 -12
@@ -1 +0,0 @@
1
- import{g as a,h as b,i as c,j as d}from"./chunk-H4MMEULK.js";import"./chunk-SCUPWMI5.js";import"./chunk-NUJSTEV4.js";import"./chunk-HJICGOD4.js";import"./chunk-NNMQGISW.js";import"./chunk-32LOJEHE.js";import"./chunk-LQVBWVLE.js";import"./chunk-6Y2DN2UH.js";import"./chunk-VVQ532U2.js";import"./chunk-AG5SADAI.js";import"./chunk-FYULPPFR.js";import"./chunk-AQAHVNNG.js";import"./chunk-K4IE6DPX.js";import"./chunk-L7JP7DUO.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-ASPPM7TQ.js";import"./chunk-Z6LHGA27.js";import"./chunk-LVHLUAZW.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as DeliveryEngine,b as getDeliveryEngine,c as initDeliveryEngine,d as stopDeliveryEngine};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e}from"./chunk-R24YRJRG.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as createEvolutionAudit,e as generateDiff,d as getLatestRoleEvolution,b as listEvolutionAudit,c as listEvolutionAuditByRole};
@@ -1 +0,0 @@
1
- import{d as a,e as b,f as c,g as d,h as e,i as f,j as g}from"./chunk-WVHN54MA.js";import"./chunk-C2XFPUFV.js";import"./chunk-HXDS4NWI.js";import"./chunk-AQAHVNNG.js";import"./chunk-3UR2PN5N.js";import"./chunk-K4IE6DPX.js";import"./chunk-L7JP7DUO.js";import"./chunk-3UZIEE2D.js";import"./chunk-FHESRUJY.js";import"./chunk-DRO3DG7X.js";import"./chunk-TJTH7LHX.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-Z6LHGA27.js";import"./chunk-LVHLUAZW.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{e as EXECUTION_TOOLS_ALL_TOOL_NAMES,a as EXECUTION_TOOLS_MCP_NAME,c as EXECUTION_TOOLS_MUTATION_TOOLS,d as EXECUTION_TOOLS_READONLY_TOOLS,b as EXECUTION_TOOLS_TOOL_PREFIX,f as KEY_REGEX,g as createExecutionTools};
@@ -1 +0,0 @@
1
- import{d as c,e as S,f as $,g as P}from"./chunk-TCBGUVVU.js";import{b as R}from"./chunk-HXDS4NWI.js";import{e as T,g as D,i as N}from"./chunk-3UR2PN5N.js";import{C as x,E as k,I as L,b as f,o as E}from"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import{c as p,h}from"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";h();var w=p("agent");function I(n){let o=c(n);if(!o){w.debug({taskId:n},"No plan found for task, skipping review");return}let i=R(n,1e3),a=o.plan.steps,s=i.filter(e=>e.type==="tool_result"||e.type==="permission_denied").map(e=>({toolName:e.toolName??"unknown",output:e.content,planStepIndex:e.planStepIndex,permissionDenied:e.type==="permission_denied"})),t=[],r=new Set(s.map(e=>e.planStepIndex).filter(e=>e!==void 0));for(let e of a)r.has(e.index)||t.push({stepIndex:e.index,planned:e.description,actual:"Not executed",deviationType:"skipped"});let d=s.filter(e=>e.planStepIndex===void 0);for(let e of d)t.push({stepIndex:-1,planned:"",actual:`${e.toolName}: ${e.output.slice(0,200)}`,deviationType:"added"});let u=s.filter(e=>e.permissionDenied);for(let e of u)t.push({stepIndex:e.planStepIndex??-1,planned:e.planStepIndex!==void 0?a.find(b=>b.index===e.planStepIndex)?.description??"Unknown":"",actual:`PERMISSION DENIED: ${e.toolName}`,deviationType:"failed"});let l=a.length,g=s.length,v=l>0?Math.max(0,1-t.filter(e=>e.deviationType!=="added").length/l):1,y={stepsPlanned:l,stepsExecuted:g,deviations:t,overallAccuracy:v};return $(o.id,y),w.info({taskId:n,planId:o.id,stepsPlanned:l,stepsExecuted:g,deviationCount:t.length,accuracy:v},"Deviation report generated"),y}function A(n){return n.deviations.filter(i=>i.deviationType==="failed"||i.deviationType==="skipped").length===0&&n.overallAccuracy>=.7}E();L();N();h();var m=p("agent");function C(n){let o=[],i=[];for(let a of n)a.startsWith("[-]")?i.push(a):o.push(a);return{stylePreferences:o,avoidedActions:i}}function U(n,o){let i=[],s=f(n)?.prompt.slice(0,100)??"unknown task";A(o)&&i.push(`[+] Task "${s}" completed successfully with ${o.overallAccuracy*100}% plan accuracy (${o.stepsExecuted} steps). [sourceTaskId:${n}]`);for(let t of o.deviations)switch(t.deviationType){case"skipped":i.push(`[-] Planned step "${t.planned}" was skipped during "${s}". Consider if this step is necessary for similar tasks. [sourceTaskId:${n}]`);break;case"failed":i.push(`[-] Step failed: "${t.actual}" during "${s}". Check permissions and tool availability. [sourceTaskId:${n}]`);break;case"added":i.push(`[~] Unplanned action: "${t.actual}" during "${s}". Consider adding to plan for similar tasks. [sourceTaskId:${n}]`);break;case"modified":i.push(`[~] Step modified: planned "${t.planned}" but did "${t.actual}" during "${s}". [sourceTaskId:${n}]`);break}return i}async function H(n){let o=c(n);if(!o){m.debug({taskId:n},"No plan for task, skipping review/learn");return}let i=I(n);if(!i)return;let a=U(n,i);if(a.length===0)return;P(o.id,a);let s=f(n);if(s?.roleId){let t=x(s.roleId);if(t){let r=C(a),d={stylePreferences:[...t.learnedRules.stylePreferences,...r.stylePreferences],avoidedActions:[...t.learnedRules.avoidedActions,...r.avoidedActions],pinnedParameters:t.learnedRules.pinnedParameters};k(s.roleId,{learnedRules:d});let u=T(t.name);D(u,{...t,learnedRules:d}),m.info({roleId:s.roleId,newRulesCount:a.length},"Role learnedRules updated and CLAUDE.md written")}}S(o.id,"completed"),m.info({taskId:n,planId:o.id,rulesExtracted:a.length,accuracy:i.overallAccuracy},"Task review and learning completed")}export{U as extractRulesFromDeviation,H as processTaskReview};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h}from"./chunk-BLCNUT53.js";import"./chunk-FCV2DPZQ.js";h();export{g as getComponentFilter,e as getLogLevel,c as getLogger,b as logger,a as onLogEvent,f as setComponentFilter,d as setLogLevel};
@@ -1 +0,0 @@
1
- import{b as i}from"./chunk-HXDS4NWI.js";import{a as p}from"./chunk-DRO3DG7X.js";import{a}from"./chunk-TJTH7LHX.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";import{v4 as u}from"uuid";function l(o){let r=o.toolName,e=o.toolOutput||o.content;if(r==="Write"||r==="Edit")return{content:`Modified file via ${r}: ${e.slice(0,400)}`,importance:4,type:"event"};if(r==="Bash"){let t=o.toolInput?.command?.slice(0,100)||"Bash";return e.includes("FAIL")||e.includes("error:")||e.includes("Error:")?{content:`Command failed: ${t} ${e.slice(0,300)}`,importance:4,type:"event"}:e.includes("success")||e.includes("done")||e.includes("OK")?{content:`Command succeeded: ${t}`,importance:2,type:"event"}:{content:`Executed: ${t}`,importance:1,type:"event"}}return null}function y(o){let r=i(o,500,0),e=[];for(let t of r)if((t.type==="tool_result"||t.type==="tool_call")&&t.toolName){let n=l(t);n&&e.push(n)}else t.type==="error"&&e.push({content:`Error occurred: ${t.content.slice(0,400)}`,importance:4,type:"event"});return{facts:e}}function f(o){let r=o.toLowerCase().replace(/[^\w\s]/g," ").split(/\s+/).filter(e=>e.length>2);return[...new Set(r)].slice(0,20)}async function M(o,r){let{facts:e}=y(o);for(let n of e)if(n.type!=="event")throw new Error(`extractKeyFacts produced non-event fact (type=${n.type}) \u2014 GAP-08 invariant violated`);let t=0;for(let n of e){let c=n.content.slice(0,500),s;try{s=await p(c)}catch{}let m=f(c),d={id:u(),roleId:r,type:n.type,content:c,embedding:s,keywords:m,importance:n.importance,sourceType:"task_complete",sourceTaskId:o,createdAt:Date.now(),lastAccessed:Date.now(),retrievedCount:0,tier:"episodic"};a(d),t++}return t}export{y as extractKeyFacts,M as processTaskCompletion};
@@ -1 +0,0 @@
1
- import{n as l,p as c}from"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import{c as a,h as b}from"./chunk-BLCNUT53.js";import"./chunk-FCV2DPZQ.js";c();b();var f=a("manager");function E(e){let o=l(),t=Date.now(),n=t-e.observationTtlDays*864e5,r=t-e.beliefStaleDays*864e5,s=o.prepare("DELETE FROM memories WHERE created_at < ? AND kind = 'observation'").run(n).changes,i=o.prepare("DELETE FROM beliefs WHERE confidence < ? AND last_used_at < ? AND is_anti = 0").run(e.beliefConfidenceMin,r).changes;return o.prepare("UPDATE server_state SET last_memory_gc_at = ? WHERE id = 1").run(t),f.info({observationsDeleted:s,beliefsDeleted:i,obsCutoff:n,beliefCutoff:r},"Memory GC completed"),{observationsDeleted:s,beliefsDeleted:i}}export{E as memoryGcTick};
@@ -1 +0,0 @@
1
- import{a,b,c,d}from"./chunk-3UZIEE2D.js";import"./chunk-FHESRUJY.js";import"./chunk-DRO3DG7X.js";import"./chunk-TJTH7LHX.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-Z6LHGA27.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{c as getRelevantMemoryContext,a as queryMemory,d as queryMemoryByTier,b as selectBeliefsForContext};
@@ -1 +0,0 @@
1
- import{e as a,f as b,g as c,h as d}from"./chunk-32LOJEHE.js";import"./chunk-LQVBWVLE.js";import"./chunk-6Y2DN2UH.js";import"./chunk-VVQ532U2.js";import"./chunk-AG5SADAI.js";import"./chunk-FYULPPFR.js";import"./chunk-AQAHVNNG.js";import"./chunk-K4IE6DPX.js";import"./chunk-L7JP7DUO.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-ASPPM7TQ.js";import"./chunk-Z6LHGA27.js";import"./chunk-LVHLUAZW.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as OutboundGateway,b as _resetChannelManagerModuleCache,c as getOutboundGateway,d as isRecentlySent};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-YNS5LQX5.js";import"./chunk-WVHN54MA.js";import"./chunk-C2XFPUFV.js";import"./chunk-HXDS4NWI.js";import"./chunk-AQAHVNNG.js";import"./chunk-3UR2PN5N.js";import"./chunk-K4IE6DPX.js";import"./chunk-L7JP7DUO.js";import"./chunk-3UZIEE2D.js";import"./chunk-FHESRUJY.js";import"./chunk-DRO3DG7X.js";import"./chunk-TJTH7LHX.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-Z6LHGA27.js";import"./chunk-LVHLUAZW.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as ADAM_AUTOMATOR_PRESET,d as CHAT_MANAGER_ROLE_ID,e as PRESET_ROLE_NAMES,b as ROLE_PRESETS,c as TEMPLATE_PRESETS,h as ensureAdamAutomatorRole,g as ensureChatManagerRole,l as getPresetRole,j as getPresetRoles,m as getPresetTemplate,k as getPresetTemplates,i as initializeDefaultRoles,f as isPresetRole,o as restorePreset,n as seedPresets};
@@ -1,23 +0,0 @@
1
- import{a as B}from"./chunk-XYZVMTNN.js";import{a as M}from"./chunk-R24YRJRG.js";import{a as O}from"./chunk-L7JP7DUO.js";import{a as y,c as T,d as A,e as x}from"./chunk-FHESRUJY.js";import{a as I}from"./chunk-DRO3DG7X.js";import{g as k}from"./chunk-TJTH7LHX.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import{d as g}from"./chunk-Z6LHGA27.js";import{n as R,p as $}from"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import{c as p,h as v}from"./chunk-BLCNUT53.js";import{c as N,e as L}from"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";$();v();L();import{v4 as E}from"uuid";v();var U=5;function C(){try{let e=g().memory?.reflection?.maxBudgetUsd;if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e}catch{}return U}var P=p("manager");function D(e){let n=e.trim(),l=n.match(/^```(\w*)\s*/);return l&&(n=n.slice(l[0].length)),n.endsWith("```")&&(n=n.slice(0,n.length-3)),n.trim()}function j(e,n){let l=D(e),a;try{a=JSON.parse(l)}catch{return{action:"coexist"}}if(!a||typeof a!="object")return{action:"coexist"};let t=a;if(t.action==="coexist")return{action:"coexist"};if(t.action==="merge"){let o=typeof t.intoBeliefId=="string"?t.intoBeliefId.trim():"",i=typeof t.mergedContent=="string"?t.mergedContent.trim():"";return o.length>0&&i.length>0&&n.some(r=>r.id===o)?{action:"merge",intoBeliefId:o,mergedContent:i}:{action:"coexist"}}if(t.action==="supersede"){let o=typeof t.oldBeliefId=="string"?t.oldBeliefId.trim():"";return o.length>0&&n.some(i=>i.id===o)?{action:"supersede",oldBeliefId:o}:{action:"coexist"}}return{action:"coexist"}}async function S(e,n){if(n.length===0)return{action:"coexist"};let a=g().anthropic?.defaultHaikuModel||"claude-haiku-4-5",o=`You are a belief conflict resolver.
2
-
3
- Existing beliefs for this role:
4
- ${n.map((i,r)=>`${r+1}. id=${i.id} (conf=${i.confidence.toFixed(2)}, used=${i.useCount}) ${i.content}`).join(`
5
- `)}
6
-
7
- New candidate belief: "${e.content}"
8
-
9
- Choose ONE of three actions and output exactly one JSON object on one line with no code fences:
10
- - "coexist": candidate is meaningfully different from existing beliefs; keep both.
11
- - "merge": candidate overlaps significantly with one existing belief; merge into it with the "intoBeliefId" field pointing to the existing belief's id, and "mergedContent" being the combined text.
12
- - "supersede": candidate directly contradicts an existing belief; "oldBeliefId" is the existing belief's id.
13
-
14
- Examples:
15
- {"action":"coexist"}
16
- {"action":"merge","intoBeliefId":"bid-123","mergedContent":"Merged belief text."}
17
- {"action":"supersede","oldBeliefId":"bid-456"}
18
-
19
- Respond with only the JSON object.`;try{let i=await B(o,{systemPrompt:"You output exactly one JSON line classifying a belief conflict. No prose.",model:a,maxBudgetUsd:C(),maxTurns:10});return j(i,n)}catch(i){return P.warn({err:i,content:e.content},"Haiku failed for belief conflict resolution; coexisting"),{action:"coexist"}}}var f=p("manager");function H(e){let n=e.trim(),l=n.match(/^```(\w*)\s*/);l&&(n=n.slice(l[0].length)),n.endsWith("```")&&(n=n.slice(0,n.length-3)),n=n.trim();let a;try{a=JSON.parse(n)}catch{return[]}return Array.isArray(a)?a.filter(t=>t!==null&&typeof t=="object").map(t=>{let o=typeof t.content=="string"?t.content.trim():"";if(!o)return null;let i=typeof t.confidence=="number"?Math.max(0,Math.min(1,t.confidence)):.5,r=Array.isArray(t.evidence_indices)?t.evidence_indices.filter(c=>Number.isInteger(c)).map(Number):[];return{content:o,confidence:i,evidence_indices:r}}).filter(t=>t!==null&&t.content.length>0):[]}async function V(e,n){let a=g().anthropic?.defaultHaikuModel||"claude-haiku-4-5",o=n.slice(0,30).map((r,c)=>`${c}. (importance:${r.importance}) ${r.content}`).join(`
20
- `),i=`Below are recent observations from agent ${e}. Extract 1 to 4 structured beliefs a future task would benefit from knowing. Each belief should be a single concrete actionable sentence, NOT a count or summary statistic. Cite which observation indices support each belief. Return ONLY a JSON array on one line. Each item: {"content": "<belief>", "confidence": <0..1>, "evidence_indices": [<int>, ...]}. Example: [{"content":"TTS audio must pass an audibility check before delivery","confidence":0.7,"evidence_indices":[2,5]}]
21
-
22
- Observations:
23
- ${o}`;try{let r=await B(i,{systemPrompt:"You output exactly one JSON array of belief candidates. No prose. No code fences.",model:a,maxBudgetUsd:C(),maxTurns:10}),c=H(r);return f.info({roleId:e,rawLen:r.length,rawHead:r.slice(0,400),rawTail:r.length>400?r.slice(-200):"",parsedCount:c.length},"reflection_haiku_result"),c}catch(r){return f.warn({err:r,roleId:e},"reflection_haiku_failed"),O.emit({type:"log_event",timestamp:Date.now(),level:"warn",component:"reflection",msg:"reflection_haiku_failed",metadata:{roleId:e,err:String(r)}}),[]}}async function F(e){let t=k(e,500,0).filter(c=>c.importance>=3);if(t.length===0)return f.info({roleId:e,written:0,reason:"no_recent_observations"},"reflection_completed"),{written:0};let o=await V(e,t);if(o.length===0)return f.info({roleId:e,written:0,recentCount:t.length,reason:"no_candidates_parsed"},"reflection_completed"),{written:0};let i=0,r=0;for(let c of o){let _=c.evidence_indices.filter(s=>s>=0&&s<t.length).map(s=>t[s].id);if(_.length===0){r++,f.debug({roleId:e,content:c.content.slice(0,120),evidenceIndices:c.evidence_indices,recentRange:[0,t.length-1]},"reflection_candidate_skipped_empty_evidence");continue}let u;try{u=await I(c.content)}catch(s){f.debug({roleId:e,err:s.message},"reflection_embedding_failed")}let h=[];u?h=A(e,u,5).map(s=>s.node):h=T(e).slice(0,5);let m=await S({content:c.content},h),d=Date.now();if(m.action==="coexist")y({id:E(),roleId:e,content:c.content,confidence:c.confidence??.5,useCount:0,successCount:0,isAnti:!1,evidenceObsIds:_,embedding:u,createdAt:d,lastUsedAt:d,lastValidatedAt:d}),i++;else if(m.action==="merge"){let s=h.find(w=>w.id===m.intoBeliefId),b=E();y({id:b,roleId:e,content:m.mergedContent,confidence:Math.min(1,s.confidence+.1),useCount:s.useCount,successCount:s.successCount,isAnti:!1,evidenceObsIds:[...s.evidenceObsIds,..._],embedding:u,createdAt:d,lastUsedAt:d,lastValidatedAt:d}),x(s.id,b),i++}else if(m.action==="supersede"){let s=h.find(w=>w.id===m.oldBeliefId),b=E();y({id:b,roleId:e,content:c.content,confidence:c.confidence??.6,useCount:s.useCount,successCount:s.successCount,isAnti:!1,evidenceObsIds:_,embedding:u,createdAt:d,lastUsedAt:d,lastValidatedAt:d}),x(s.id,b),i++}}try{M({timestamp:Date.now(),oldRules:"",newRules:`reflection: wrote ${i} belief(s) for role ${e}`,diff:`written=${i}`,roleId:e,source:"reflection",traceId:N()})}catch{}return f.info({roleId:e,written:i,observed:t.length,candidatesCount:o.length,skippedNoEvidence:r},"reflection_completed"),{written:i}}v();var J=p("manager");async function ge(e){let n=R(),l=Date.now()-e*6e4,a=n.prepare("SELECT id, last_reflection_at FROM roles WHERE last_reflection_at IS NULL OR last_reflection_at < ?").all(l),t=[];for(let o of a){n.prepare("UPDATE roles SET last_reflection_at = ? WHERE id = ?").run(Date.now(),o.id);try{await F(o.id),t.push(o.id)}catch(i){J.warn({err:i,roleId:o.id},"Reflection tick: role failed; slot remains claimed")}}return t}export{ge as reflectionTick};
@@ -1 +0,0 @@
1
- import"./chunk-QMW7VEPC.js";import{a,d as b,e as c,f as d,g as e,h as f,i as g}from"./chunk-YNS5LQX5.js";import"./chunk-WVHN54MA.js";import"./chunk-C2XFPUFV.js";import"./chunk-HXDS4NWI.js";import"./chunk-AQAHVNNG.js";import"./chunk-3UR2PN5N.js";import"./chunk-K4IE6DPX.js";import"./chunk-L7JP7DUO.js";import"./chunk-3UZIEE2D.js";import"./chunk-FHESRUJY.js";import"./chunk-DRO3DG7X.js";import"./chunk-TJTH7LHX.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-Z6LHGA27.js";import"./chunk-LVHLUAZW.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as ADAM_AUTOMATOR_PRESET,b as CHAT_MANAGER_ROLE_ID,c as PRESET_ROLE_NAMES,f as ensureAdamAutomatorRole,e as ensureChatManagerRole,g as initializeDefaultRoles,d as isPresetRole};
@@ -1 +0,0 @@
1
- import{e as a,f as b,g as c,h as d,i as e}from"./chunk-3UR2PN5N.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";e();export{b as ensureRoleWorkspace,a as getRoleWorkspacePath,d as syncRoleSettings,c as writeRoleCLAUDEmd};
@@ -1 +0,0 @@
1
- import{A as a,B as b,C as c,D as d,E as e,F as f,G as g,H as h,I as i}from"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";i();export{b as createRole,h as deleteRole,c as getRole,d as getRoleByName,g as hasActiveTasks,f as listRoles,e as updateRole,a as validateAdditionalDirectories};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-L7JP7DUO.js";import"./chunk-FCV2DPZQ.js";export{a as serverBus};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-P5Q2UINT.js";import"./chunk-HJICGOD4.js";import"./chunk-AG5SADAI.js";import"./chunk-L7JP7DUO.js";import"./chunk-DRO3DG7X.js";import"./chunk-TJTH7LHX.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-VKKDSXMR.js";import"./chunk-ASPPM7TQ.js";import"./chunk-TLMG5W3L.js";import"./chunk-Z6LHGA27.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{p as _resetForTest,e as archiveSession,b as createSession,g as deleteSession,c as getActiveSession,d as getSession,m as getTimeoutPollerInterval,i as incrementMessageCount,n as initSessionManager,j as listSessions,f as restoreSession,o as shutdownSessionManager,k as startTimeoutPoller,l as stopTimeoutPoller,h as touchSession,a as warmCache};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-52FETPCI.js";import"./chunk-MNSZE3NV.js";import"./chunk-3UR2PN5N.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as SkillRegistry};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-NUJSTEV4.js";import"./chunk-NNMQGISW.js";import"./chunk-BLCNUT53.js";import"./chunk-FCV2DPZQ.js";export{a as getDefaultChatIdForChannel};
@@ -1 +0,0 @@
1
- import{s as a}from"./chunk-K2TZW4DU.js";import"./chunk-EWYXVBOG.js";import"./chunk-TCBGUVVU.js";import"./chunk-XYZVMTNN.js";import"./chunk-MNSZE3NV.js";import"./chunk-P5Q2UINT.js";import"./chunk-NUJSTEV4.js";import"./chunk-HJICGOD4.js";import"./chunk-NNMQGISW.js";import"./chunk-32LOJEHE.js";import"./chunk-LQVBWVLE.js";import"./chunk-6Y2DN2UH.js";import"./chunk-VVQ532U2.js";import"./chunk-AG5SADAI.js";import"./chunk-FYULPPFR.js";import"./chunk-C2XFPUFV.js";import"./chunk-HXDS4NWI.js";import"./chunk-AQAHVNNG.js";import"./chunk-3UR2PN5N.js";import"./chunk-K4IE6DPX.js";import"./chunk-L7JP7DUO.js";import"./chunk-DRO3DG7X.js";import"./chunk-TJTH7LHX.js";import"./chunk-MTQI6B7T.js";import"./chunk-OGY42NUN.js";import"./chunk-VKKDSXMR.js";import"./chunk-ASPPM7TQ.js";import"./chunk-TLMG5W3L.js";import"./chunk-Z6LHGA27.js";import"./chunk-LVHLUAZW.js";import"./chunk-QL2ZOLMC.js";import"./chunk-WBAPIPST.js";import"./chunk-BLCNUT53.js";import"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";export{a as dispatchTemplate};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e}from"./chunk-245WE5AF.js";import"./chunk-FCV2DPZQ.js";e();export{c as getCurrentTraceId,d as getTraceStore,a as withNewTrace,b as withTrace};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,O as n,Q as r,d as i,yt as a}from"./vendor-icons-H7p0EuQJ.js";import{t as o}from"./vendor-react-C1yKjxEP.js";import{t as s}from"./Button-xVc-P0vm.js";import{f as c}from"./index-iD-HOtIu.js";import{t as l}from"./Card-WUD1cwG6.js";import{t as u}from"./PageHeader-D8pqg_wk.js";import{t as d}from"./EmptyState-BLB33cKG.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)(t,{size:f.sm}):(0,m.jsx)(n,{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 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{$ as t,L as n,S as r,T as i,W as a,at as o,dt as s,et as c,ft as l,n as u,pt as d,ut as f,w as ee,y as te,yt as p}from"./vendor-icons-H7p0EuQJ.js";import{t as m}from"./vendor-react-C1yKjxEP.js";import{n as h}from"./dist-CgGno8kE.js";import{_ as ne,a as re,c as g,d as _,f as v,i as ie,m as y,n as ae,o as b,p as x,r as S,s as C,t as w,u as oe,v as T}from"./es2015-BgPT8VkR.js";import{i as E,r as D,t as O}from"./Button-xVc-P0vm.js";import{t as k}from"./api-BkdixMz9.js";import{S as A,_ as se,b as ce,g as le,h as j,m as ue,p as M,t as N,v as de,x as P,y as fe}from"./index-iD-HOtIu.js";import{t as F}from"./Card-WUD1cwG6.js";import{t as pe}from"./PageHeader-D8pqg_wk.js";import{t as me}from"./SectionHeader-DZo4QVWr.js";import{a as he}from"./format-ZWN4JNj-.js";import{t as ge}from"./EmptyState-BLB33cKG.js";import{t as I}from"./ui-D1crlGpt.js";import{a as _e,i as L,n as ve,o as ye,r as R,t as be}from"./Table-XjSmrOyn.js";import{n as xe,r as Se,t as Ce}from"./usePluginsWithUsage-CjU8Lkdn.js";import{a as we,c as Te,i as Ee,l as De,n as Oe,o as ke,r as Ae,s as je,t as Me}from"./Tabs-CSbcG_5T.js";var z=e(p(),1),B=m();function Ne(){let[e,t]=(0,z.useState)(!1),[n,r]=(0,z.useState)([]),i=(0,z.useCallback)(async()=>{try{r((await k(`/plugins/stats?limit=20`)).stats)}catch{r([])}},[]);return(0,B.jsxs)(F,{children:[(0,B.jsxs)(`button`,{className:`flex w-full items-center gap-2 text-sm font-semibold text-[var(--app-text)]`,onClick:()=>{!e&&n.length===0&&i(),t(e=>!e)},children:[(0,B.jsx)(d,{size:I.sm,className:`text-[var(--app-text-muted)]`}),`Usage Stats`,e?(0,B.jsx)(s,{size:I.xs,className:`ml-auto`}):(0,B.jsx)(f,{size:I.xs,className:`ml-auto`})]}),e?(0,B.jsx)(`div`,{className:`mt-3`,children:n.length===0?(0,B.jsx)(`p`,{className:`py-2 text-center text-xs text-[var(--app-text-subtle)]`,children:`No usage data yet`}):(0,B.jsxs)(be,{children:[(0,B.jsx)(_e,{children:(0,B.jsxs)(ye,{children:[(0,B.jsx)(L,{children:`Plugin`}),(0,B.jsx)(L,{children:`Usage Count`}),(0,B.jsx)(L,{children:`Last Used`})]})}),(0,B.jsx)(ve,{children:n.map(e=>(0,B.jsxs)(ye,{children:[(0,B.jsx)(R,{className:`text-xs font-medium text-[var(--app-text)]`,children:e.pluginName}),(0,B.jsx)(R,{className:`font-mono text-xs text-[var(--app-text-muted)]`,children:e.usageCount}),(0,B.jsx)(R,{className:`text-xs text-[var(--app-text-muted)]`,children:e.lastUsed?he(e.lastUsed):`—`})]},e.pluginPath))})]})}):null]})}var Pe=[`Enter`,` `],Fe=[`ArrowDown`,`PageUp`,`Home`],Ie=[`ArrowUp`,`PageDown`,`End`],Le=[...Fe,...Ie],Re={ltr:[...Pe,`ArrowRight`],rtl:[...Pe,`ArrowLeft`]},ze={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},V=`Menu`,[H,Be,Ve]=De(V),[U,He]=ne(V,[Ve,A,je]),W=A(),Ue=je(),[We,G]=U(V),[Ge,K]=U(V),Ke=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=W(t),[c,l]=z.useState(null),u=z.useRef(!1),d=_(a),f=Te(i);return z.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,B.jsx)(P,{...s,children:(0,B.jsx)(We,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,B.jsx)(Ge,{scope:t,onClose:z.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Ke.displayName=V;var qe=`MenuAnchor`,Je=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=W(n);return(0,B.jsx)(de,{...i,...r,ref:t})});Je.displayName=qe;var Ye=`MenuPortal`,[Xe,Ze]=U(Ye,{forceMount:void 0}),Qe=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=G(Ye,t);return(0,B.jsx)(Xe,{scope:t,forceMount:n,children:(0,B.jsx)(b,{present:n||a.open,children:(0,B.jsx)(C,{asChild:!0,container:i,children:r})})})};Qe.displayName=Ye;var q=`MenuContent`,[$e,et]=U(q),tt=z.forwardRef((e,t)=>{let n=Ze(q,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=G(q,e.__scopeMenu),o=K(q,e.__scopeMenu);return(0,B.jsx)(H.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(b,{present:r||a.open,children:(0,B.jsx)(H.Slot,{scope:e.__scopeMenu,children:o.modal?(0,B.jsx)(nt,{...i,ref:t}):(0,B.jsx)(rt,{...i,ref:t})})})})}),nt=z.forwardRef((e,t)=>{let n=G(q,e.__scopeMenu),r=z.useRef(null),i=E(t,r);return z.useEffect(()=>{let e=r.current;if(e)return w(e)},[]),(0,B.jsx)(at,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:T(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),rt=z.forwardRef((e,t)=>{let n=G(q,e.__scopeMenu);return(0,B.jsx)(at,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),it=y(`MenuContent.ScrollLock`),at=z.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:te,...p}=e,m=G(q,n),h=K(q,n),ne=W(n),re=Ue(n),g=Be(n),[_,v]=z.useState(null),y=z.useRef(null),b=E(t,y,m.onContentChange),x=z.useRef(0),C=z.useRef(``),w=z.useRef(0),D=z.useRef(null),O=z.useRef(`right`),k=z.useRef(0),A=te?ae:z.Fragment,se=te?{as:it,allowPinchZoom:!0}:void 0,le=e=>{let t=C.current+e,n=g().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){C.current=t,window.clearTimeout(x.current),t!==``&&(x.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};z.useEffect(()=>()=>window.clearTimeout(x.current),[]),S();let j=z.useCallback(e=>O.current===D.current?.side&&Ht(e,D.current?.area),[]);return(0,B.jsx)($e,{scope:n,searchRef:C,onItemEnter:z.useCallback(e=>{j(e)&&e.preventDefault()},[j]),onItemLeave:z.useCallback(e=>{j(e)||(y.current?.focus(),v(null))},[j]),onTriggerLeave:z.useCallback(e=>{j(e)&&e.preventDefault()},[j]),pointerGraceTimerRef:w,onPointerGraceIntentChange:z.useCallback(e=>{D.current=e},[]),children:(0,B.jsx)(A,{...se,children:(0,B.jsx)(ie,{asChild:!0,trapped:i,onMountAutoFocus:T(a,e=>{e.preventDefault(),y.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,B.jsx)(oe,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:ee,children:(0,B.jsx)(ke,{asChild:!0,...re,dir:h.dir,orientation:`vertical`,loop:r,currentTabStopId:_,onCurrentTabStopIdChange:v,onEntryFocus:T(c,e=>{h.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,B.jsx)(ce,{role:`menu`,"aria-orientation":`vertical`,"data-state":It(m.open),"data-radix-menu-content":``,dir:h.dir,...ne,...p,ref:b,style:{outline:`none`,...p.style},onKeyDown:T(p.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&&le(e.key));let i=y.current;if(e.target!==i||!Le.includes(e.key))return;e.preventDefault();let a=g().filter(e=>!e.disabled).map(e=>e.ref.current);Ie.includes(e.key)&&a.reverse(),Rt(a)}),onBlur:T(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(x.current),C.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)}))})})})})})})});tt.displayName=q;var ot=`MenuGroup`,st=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(v.div,{role:`group`,...r,ref:t})});st.displayName=ot;var ct=`MenuLabel`,lt=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(v.div,{...r,ref:t})});lt.displayName=ct;var ut=`MenuItem`,dt=`menu.itemSelect`,J=z.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=z.useRef(null),o=K(ut,e.__scopeMenu),s=et(ut,e.__scopeMenu),c=E(t,a),l=z.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(dt,{bubbles:!0,cancelable:!0});e.addEventListener(dt,e=>r?.(e),{once:!0}),x(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,B.jsx)(ft,{...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===` `||Pe.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});J.displayName=ut;var ft=z.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=et(ut,n),s=Ue(n),c=z.useRef(null),l=E(t,c),[u,d]=z.useState(!1),[f,ee]=z.useState(``);return z.useEffect(()=>{let e=c.current;e&&ee((e.textContent??``).trim())},[a.children]),(0,B.jsx)(H.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,B.jsx)(we,{asChild:!0,...s,focusable:!r,children:(0,B.jsx)(v.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))})})})}),pt=`MenuCheckboxItem`,mt=z.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,B.jsx)(St,{scope:e.__scopeMenu,checked:n,children:(0,B.jsx)(J,{role:`menuitemcheckbox`,"aria-checked":X(n)?`mixed`:n,...i,ref:t,"data-state":Lt(n),onSelect:T(i.onSelect,()=>r?.(X(n)?!0:!n),{checkForDefaultPrevented:!1})})})});mt.displayName=pt;var ht=`MenuRadioGroup`,[gt,_t]=U(ht,{value:void 0,onValueChange:()=>{}}),vt=z.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=_(r);return(0,B.jsx)(gt,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,B.jsx)(st,{...i,ref:t})})});vt.displayName=ht;var yt=`MenuRadioItem`,bt=z.forwardRef((e,t)=>{let{value:n,...r}=e,i=_t(yt,e.__scopeMenu),a=n===i.value;return(0,B.jsx)(St,{scope:e.__scopeMenu,checked:a,children:(0,B.jsx)(J,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Lt(a),onSelect:T(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});bt.displayName=yt;var xt=`MenuItemIndicator`,[St,Ct]=U(xt,{checked:!1}),wt=z.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=Ct(xt,n);return(0,B.jsx)(b,{present:r||X(a.checked)||a.checked===!0,children:(0,B.jsx)(v.span,{...i,ref:t,"data-state":Lt(a.checked)})})});wt.displayName=xt;var Tt=`MenuSeparator`,Et=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,B.jsx)(v.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});Et.displayName=Tt;var Dt=`MenuArrow`,Ot=z.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=W(n);return(0,B.jsx)(fe,{...i,...r,ref:t})});Ot.displayName=Dt;var kt=`MenuSub`,[At,jt]=U(kt),Mt=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=G(kt,t),o=W(t),[s,c]=z.useState(null),[l,u]=z.useState(null),d=_(i);return z.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,B.jsx)(P,{...o,children:(0,B.jsx)(We,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,B.jsx)(At,{scope:t,contentId:g(),triggerId:g(),trigger:s,onTriggerChange:c,children:n})})})};Mt.displayName=kt;var Y=`MenuSubTrigger`,Nt=z.forwardRef((e,t)=>{let n=G(Y,e.__scopeMenu),r=K(Y,e.__scopeMenu),i=jt(Y,e.__scopeMenu),a=et(Y,e.__scopeMenu),o=z.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=z.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return z.useEffect(()=>u,[u]),z.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]),(0,B.jsx)(Je,{asChild:!0,...l,children:(0,B.jsx)(ft,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":i.contentId,"data-state":It(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===` `||Re[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});Nt.displayName=Y;var Pt=`MenuSubContent`,Ft=z.forwardRef((e,t)=>{let n=Ze(q,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=G(q,e.__scopeMenu),o=K(q,e.__scopeMenu),s=jt(Pt,e.__scopeMenu),c=z.useRef(null),l=E(t,c);return(0,B.jsx)(H.Provider,{scope:e.__scopeMenu,children:(0,B.jsx)(b,{present:r||a.open,children:(0,B.jsx)(H.Slot,{scope:e.__scopeMenu,children:(0,B.jsx)(at,{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=ze[o.dir].includes(e.key);t&&n&&(a.onOpenChange(!1),s.trigger?.focus(),e.preventDefault())})})})})})});Ft.displayName=Pt;function It(e){return e?`open`:`closed`}function X(e){return e===`indeterminate`}function Lt(e){return X(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=Ke,Wt=Je,Gt=Qe,Kt=tt,qt=st,Jt=lt,Yt=J,Xt=mt,Zt=vt,Qt=bt,$t=wt,en=Et,tn=Ot,nn=Nt,rn=Ft,an=`DropdownMenu`,[on,sn]=ne(an,[He]),Q=He(),[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=z.useRef(null),[u,d]=re({prop:i,defaultProp:a??!1,onChange:o,caller:an});return(0,B.jsx)(cn,{scope:t,triggerId:g(),triggerRef:l,contentId:g(),open:u,onOpenChange:d,onOpenToggle:z.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,B.jsx)(Ut,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};un.displayName=an;var dn=`DropdownMenuTrigger`,fn=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ln(dn,n),o=Q(n);return(0,B.jsx)(Wt,{asChild:!0,...o,children:(0,B.jsx)(v.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,B.jsx)(Gt,{...r,...n})};mn.displayName=pn;var hn=`DropdownMenuContent`,gn=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=ln(hn,n),a=Q(n),o=z.useRef(!1);return(0,B.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=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,B.jsx)(qt,{...i,...r,ref:t})});vn.displayName=_n;var yn=`DropdownMenuLabel`,bn=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,B.jsx)(Jt,{...i,...r,ref:t})});bn.displayName=yn;var xn=`DropdownMenuItem`,Sn=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,B.jsx)(Yt,{...i,...r,ref:t})});Sn.displayName=xn;var Cn=`DropdownMenuCheckboxItem`,wn=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,B.jsx)(Xt,{...i,...r,ref:t})});wn.displayName=Cn;var Tn=`DropdownMenuRadioGroup`,En=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,B.jsx)(Zt,{...i,...r,ref:t})});En.displayName=Tn;var Dn=`DropdownMenuRadioItem`,On=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,B.jsx)(Qt,{...i,...r,ref:t})});On.displayName=Dn;var kn=`DropdownMenuItemIndicator`,An=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,B.jsx)($t,{...i,...r,ref:t})});An.displayName=kn;var jn=`DropdownMenuSeparator`,Mn=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,B.jsx)(en,{...i,...r,ref:t})});Mn.displayName=jn;var Nn=`DropdownMenuArrow`,Pn=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,B.jsx)(tn,{...i,...r,ref:t})});Pn.displayName=Nn;var Fn=`DropdownMenuSubTrigger`,In=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,B.jsx)(nn,{...i,...r,ref:t})});In.displayName=Fn;var Ln=`DropdownMenuSubContent`,Rn=z.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Q(n);return(0,B.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=z.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,B.jsxs)(Yn,{ref:i,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,B.jsx)(f,{className:`ml-auto`})]}));$n.displayName=Yn.displayName;var er=z.forwardRef(({className:e,...t},n)=>(0,B.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=z.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,B.jsx)(Vn,{children:(0,B.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 $=z.forwardRef(({className:e,inset:t,...n},r)=>(0,B.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=z.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,B.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,B.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,B.jsx)(qn,{children:(0,B.jsx)(l,{className:`h-4 w-4`})})}),t]}));nr.displayName=Gn.displayName;var rr=z.forwardRef(({className:e,children:t,...n},r)=>(0,B.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,B.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,B.jsx)(qn,{children:(0,B.jsx)(o,{className:`h-2 w-2 fill-current`})})}),t]}));rr.displayName=Kn.displayName;var ir=z.forwardRef(({className:e,inset:t,...n},r)=>(0,B.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=z.forwardRef(({className:e,...t},n)=>(0,B.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,B.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,B.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:n.map(e=>(0,B.jsx)(N,{variant:e.variant,children:e.label},e.label))})}function cr({plugin:e,roles:r,onInstallToRole:i,onToggleGlobal:a,onUninstallUser:o,projectOperatingKey:s,userOperatingId:c}){let l=c===e.id;return(0,B.jsxs)(Zn,{modal:!1,children:[(0,B.jsx)(Qn,{asChild:!0,children:(0,B.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-7 w-7 px-0`,"aria-label":`Manage ${e.name}`,children:l?(0,B.jsx)(n,{size:I.xs,className:`animate-spin`}):(0,B.jsx)(t,{size:I.sm})})}),(0,B.jsxs)(tr,{align:`end`,className:`min-w-[200px]`,children:[r.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ir,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Add to Role`}),r.map(t=>{let r=e.usedByRoles.some(e=>e.roleId===t.id),a=s===`${e.id}:${t.workspacePath}`;return(0,B.jsxs)($,{disabled:a||r,onSelect:()=>{i(e.id,t.workspacePath)},children:[(0,B.jsx)(`span`,{className:`flex-1`,children:t.name}),a?(0,B.jsx)(n,{size:I.xs,className:`animate-spin`}):r?(0,B.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`installed`}):null]},t.id)}),(0,B.jsx)(ar,{})]}):null,(0,B.jsx)($,{disabled:l,onSelect:()=>{a(e.id,!e.globalEnabled)},children:e.globalEnabled?`Disable`:`Enable`}),(0,B.jsx)($,{disabled:l,className:`text-[var(--app-danger)] focus:text-[var(--app-danger)]`,onSelect:()=>{o(e.id)},children:`Uninstall`})]})]})}function lr({plugin:e,roles:t,expandedContent:n,onInstallToRole:r,onToggleGlobal:i,onUninstallUser:a,projectOperatingKey:o,userOperatingId:c}){let[l,u]=(0,z.useState)(!1),d=e.usedByRoles.map(e=>`${e.roleName} (v${e.version})`).join(`, `)||`No Roles`;return(0,B.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] px-3 py-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsx)(`button`,{className:`mt-0.5 text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,onClick:()=>u(e=>!e),"aria-label":l?`Collapse ${e.name}`:`Expand ${e.name}`,children:l?(0,B.jsx)(s,{size:I.xs}):(0,B.jsx)(f,{size:I.xs})}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:e.name}),(0,B.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`v`,e.version]}),e.marketplace?(0,B.jsx)(N,{variant:`muted`,className:`text-[10px]`,children:e.marketplace}):null,(0,B.jsx)(le,{delayDuration:150,children:(0,B.jsxs)(ue,{children:[(0,B.jsx)(se,{asChild:!0,children:(0,B.jsxs)(`button`,{className:`text-xs text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,title:d,children:[e.usedByRoles.length,` `,e.usedByRoles.length===1?`Role`:`Roles`]})}),(0,B.jsx)(j,{children:d})]})})]}),(0,B.jsx)(sr,{plugin:e})]}),(0,B.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,B.jsx)(N,{variant:e.globalEnabled?`success`:`destructive`,children:e.globalEnabled?`User On`:`User Off`}),(0,B.jsx)(cr,{plugin:e,roles:t,onInstallToRole:r,onToggleGlobal:i,onUninstallUser:a,projectOperatingKey:o,userOperatingId:c})]})]}),l?(0,B.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,B.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,B.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:e}),(0,B.jsx)(`p`,{className:`mt-1 text-sm font-medium text-[var(--app-text)]`,children:t})]})}function dr({plugin:e}){return e.manifest?(0,B.jsxs)(`div`,{className:`space-y-4 text-xs`,children:[e.manifest.description?(0,B.jsx)(`p`,{className:`text-[var(--app-text-muted)]`,children:e.manifest.description}):null,(0,B.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-4`,children:[(0,B.jsx)(ur,{label:`Version`,value:e.version?`v${e.version}`:`—`}),(0,B.jsx)(ur,{label:`Scope`,value:e.scope}),(0,B.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,B.jsx)(ur,{label:`Activation`,value:e.globalEnabled?`User On`:`User Off`})]}),(0,B.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 px-3 py-2`,children:[(0,B.jsx)(`p`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Install Path`}),(0,B.jsx)(`p`,{className:`mt-1 truncate font-mono text-[11px] text-[var(--app-text-muted)]`,title:e.installPath,children:e.installPath})]}),(0,B.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[e.manifest.skills.length>0?(0,B.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,B.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Skills`}),e.manifest.skills.map(e=>(0,B.jsxs)(`div`,{className:`inline-flex items-baseline gap-1 text-[var(--app-text-muted)]`,children:[(0,B.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),e.description?(0,B.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`; `,e.description]}):null]},e.name))]}):null,e.manifest.agents.length>0?(0,B.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,B.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Agents`}),e.manifest.agents.map(e=>(0,B.jsxs)(`div`,{className:`inline-flex items-baseline gap-1 text-[var(--app-text-muted)]`,children:[(0,B.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.name}),e.description?(0,B.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`; `,e.description]}):null]},e.name))]}):null,e.manifest.mcpServers.length>0?(0,B.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,B.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`MCP Servers`}),e.manifest.mcpServers.map(e=>(0,B.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null,e.manifest.hooks.length>0?(0,B.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,B.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`Hooks`}),e.manifest.hooks.map(e=>(0,B.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null,e.manifest.lspServers.length>0?(0,B.jsxs)(`div`,{className:`rounded-xl border border-[var(--app-border)] bg-black/10 p-3`,children:[(0,B.jsx)(`div`,{className:`mb-2 font-semibold text-[var(--app-text)]`,children:`LSP Servers`}),e.manifest.lspServers.map(e=>(0,B.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:e},e))]}):null]})]}):(0,B.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading manifest...`})}function fr(){let{userScope:e,projectScope:t,loading:o,error:l,refresh:d,rawPlugins:f,roles:p}=Ce(),[m,h]=(0,z.useState)(`installed`),[ne,re]=(0,z.useState)([]),[g,_]=(0,z.useState)([]),[v,ie]=(0,z.useState)(new Set),[y,ae]=(0,z.useState)(!1),[b,x]=(0,z.useState)(null),[S,C]=(0,z.useState)(``),[w,oe]=(0,z.useState)(!1),[T,E]=(0,z.useState)(``),[D,A]=(0,z.useState)(null),[se,ce]=(0,z.useState)(null),{operatingKey:le,installToRole:j,uninstallFromRole:ue,updateRoleVersion:de}=xe(d),P=(0,z.useCallback)(async()=>{ae(!0),x(null);try{let[e,t]=await Promise.all([k(`/plugins/marketplace`).catch(()=>({available:[],installed:[]})),k(`/plugins/marketplaces`)]);_(e.available),ie(new Set(e.installed.map(e=>e.id))),re(t.sources)}catch(e){x(e instanceof Error?e.message:`Failed to load marketplace`)}finally{ae(!1)}},[]);(0,z.useEffect)(()=>{P()},[P]);let fe=(0,z.useCallback)(async(e,t)=>{A(e);try{await k(`/plugins/${encodeURIComponent(e)}/${t?`enable`:`disable`}`,{method:`POST`}),M.success(`${e} ${t?`enabled`:`disabled`} globally`)}catch(e){M.error(e instanceof Error?e.message:`Failed to ${t?`enable`:`disable`} plugin`)}finally{await d(),A(null)}},[d]),he=(0,z.useCallback)(async e=>{A(e);try{await k(`/plugins/uninstall/${encodeURIComponent(e)}`,{method:`POST`}),M.success(`Plugin uninstalled`)}catch(e){M.error(e instanceof Error?e.message:`Uninstall failed`)}finally{await Promise.all([d(),P()]),A(null)}},[P,d]),we=(0,z.useCallback)(async()=>{let e=T.trim();if(e)try{await k(`/plugins/marketplaces`,{method:`POST`,body:JSON.stringify({url:e})}),M.success(`Marketplace added`),E(``),oe(!1),await P()}catch(e){M.error(e instanceof Error?e.message:`Failed to add marketplace`)}},[P,T]),Te=(0,z.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];M.success(`Installed ${r}`)}catch(e){M.error(e instanceof Error?e.message:`Install failed`)}finally{await Promise.all([d(),P()]),ce(null)}},[P,d]),De=S?g.filter(e=>e.name.toLowerCase().includes(S.toLowerCase())||e.description.toLowerCase().includes(S.toLowerCase())):g,ke=f.filter(e=>e.scope===`project`).length;return(0,B.jsxs)(`div`,{className:`space-y-5`,children:[(0,B.jsx)(pe,{eyebrow:`Capabilities`,title:`Plugins`,compact:!0,description:`Installed capabilities, scope, and activation.`,metrics:[{label:`Total`,value:f.length},{label:`Project Scope`,value:ke},{label:`Catalog`,value:g.length}],actions:(0,B.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>void Promise.all([d(),P()]),children:(0,B.jsx)(r,{size:I.sm})})}),(0,B.jsx)(me,{title:`Plugin Library`,compact:!0,description:`Installed plugins and marketplace discovery live in separate tabs.`}),(0,B.jsxs)(Me,{value:m,onValueChange:e=>h(e),children:[(0,B.jsxs)(Ae,{children:[(0,B.jsxs)(Ee,{value:`installed`,children:[`Installed (`,e.length,`)`]}),(0,B.jsxs)(Ee,{value:`marketplace`,children:[`Marketplace (`,g.length,`)`]})]}),(0,B.jsx)(Oe,{value:`installed`,className:`space-y-5`,children:o?(0,B.jsx)(F,{children:(0,B.jsx)(`div`,{className:`py-8 text-center text-sm text-[var(--app-text-subtle)]`,children:`Loading...`})}):l?(0,B.jsx)(F,{children:(0,B.jsx)(`div`,{className:`py-8 text-center text-sm text-[var(--app-danger)]`,children:l})}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`section`,{className:`space-y-3`,children:[(0,B.jsx)(me,{title:`User scope`,compact:!0,description:`Global defaults. Available to all Roles unless overridden.`}),e.length===0?(0,B.jsx)(F,{children:(0,B.jsx)(ge,{icon:(0,B.jsx)(ee,{size:I.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,B.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,B.jsx)(lr,{plugin:e,roles:p,expandedContent:(0,B.jsx)(dr,{plugin:e}),onInstallToRole:j,onToggleGlobal:fe,onUninstallUser:he,projectOperatingKey:le,userOperatingId:D},e.id))})]}),(0,B.jsxs)(`section`,{className:`space-y-3`,children:[(0,B.jsx)(me,{title:`Project scope`,compact:!0,description:`Role-specific overrides. Only plugins that differ from user scope are shown here.`}),(0,B.jsx)(Se,{groups:t,layout:`full`,onUninstall:ue,onUpdate:de,operatingKey:le})]}),(0,B.jsx)(Ne,{})]})}),(0,B.jsxs)(Oe,{value:`marketplace`,className:`space-y-4`,children:[(0,B.jsxs)(F,{children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(a,{size:I.sm,className:`flex-shrink-0 text-[var(--app-text-muted)]`}),ne.map(e=>(0,B.jsx)(N,{variant:`muted`,className:`text-xs`,children:e.name},e.name)),(0,B.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[y?(0,B.jsx)(n,{size:I.xs,className:`animate-spin text-[var(--app-text-subtle)]`}):null,(0,B.jsxs)(O,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>oe(e=>!e),children:[w?(0,B.jsx)(u,{size:I.xs}):(0,B.jsx)(i,{size:I.xs}),`Source`]})]})]}),w?(0,B.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,B.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`&&we()}}),(0,B.jsx)(O,{size:`sm`,onClick:()=>void we(),disabled:!T.trim(),children:`Add`})]}):null]}),(0,B.jsx)(F,{children:(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(te,{size:I.sm,className:`absolute left-2.5 top-2 text-[var(--app-text-subtle)]`}),(0,B.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:S,onChange:e=>C(e.target.value),placeholder:`Search available plugins...`})]})}),y?(0,B.jsx)(F,{children:(0,B.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-text-subtle)]`,children:`Loading marketplace...`})}):b?(0,B.jsx)(F,{children:(0,B.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-danger)]`,children:b})}):De.length===0?(0,B.jsx)(F,{children:(0,B.jsx)(`p`,{className:`py-8 text-center text-xs text-[var(--app-text-subtle)]`,children:S?`No plugins match your search`:`No marketplace plugins available`})}):(0,B.jsx)(F,{padding:!1,children:(0,B.jsxs)(be,{children:[(0,B.jsx)(_e,{children:(0,B.jsxs)(ye,{children:[(0,B.jsx)(L,{children:`Name`}),(0,B.jsx)(L,{children:`Description`}),(0,B.jsx)(L,{children:`Source`}),(0,B.jsx)(L,{children:`Action`})]})}),(0,B.jsx)(ve,{children:De.map(e=>{let t=v.has(e.pluginId),r=se===e.pluginId;return(0,B.jsxs)(ye,{children:[(0,B.jsx)(R,{className:`text-xs font-medium text-[var(--app-text)]`,children:e.name}),(0,B.jsx)(R,{className:`max-w-[300px] truncate text-xs text-[var(--app-text-muted)]`,title:e.description,children:e.description}),(0,B.jsx)(R,{children:(0,B.jsx)(N,{variant:`muted`,className:`text-[10px]`,children:e.marketplaceName})}),(0,B.jsx)(R,{children:t?(0,B.jsx)(N,{variant:`success`,className:`text-[10px]`,children:`Installed`}):(0,B.jsxs)(Zn,{modal:!1,children:[(0,B.jsx)(Qn,{asChild:!0,children:(0,B.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,disabled:r,children:r?(0,B.jsx)(n,{size:I.xs,className:`animate-spin`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(c,{size:I.xs}),`Install`,(0,B.jsx)(s,{size:I.xs})]})})}),(0,B.jsxs)(tr,{align:`end`,className:`min-w-[200px]`,children:[(0,B.jsx)($,{disabled:r,onSelect:()=>{Te(e.pluginId)},children:`Install globally (User scope)`}),p.length>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ar,{}),p.map(t=>(0,B.jsxs)($,{disabled:r,onSelect:()=>{Te(e.pluginId,`project`,t.workspacePath)},children:[`Install to `,t.name]},t.id))]}):null]})]})})]},e.pluginId)})})]})})]})]})]})}export{fr as Plugins};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{S as t,T as n,n as r,yt as i}from"./vendor-icons-H7p0EuQJ.js";import{r as a,t as o}from"./vendor-react-C1yKjxEP.js";import{t as s}from"./Button-xVc-P0vm.js";import{f as c,p as l,t as u}from"./index-iD-HOtIu.js";import{t as d}from"./Card-WUD1cwG6.js";import{t as f}from"./PageHeader-D8pqg_wk.js";import{t as p}from"./SectionHeader-DZo4QVWr.js";import{a as m}from"./format-ZWN4JNj-.js";import{t as h}from"./EmptyState-BLB33cKG.js";import{t as g}from"./useIsMobileLayout-DF2fEEM9.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./Table-XjSmrOyn.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)(t,{size:14,className:T?`animate-spin`:``})}),(0,w.jsxs)(s,{size:`sm`,onClick:()=>O(!0),children:[(0,w.jsx)(n,{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)(r,{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 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{I as t,S as n,_ as r,b as i,n as a,u as o,v as s,yt as c}from"./vendor-icons-H7p0EuQJ.js";import{l,t as u}from"./vendor-react-C1yKjxEP.js";import"./es2015-BgPT8VkR.js";import{t as d}from"./Button-xVc-P0vm.js";import{_ as f,a as p,b as m,g as h,h as g,l as _,t as v}from"./api-BkdixMz9.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-iD-HOtIu.js";import{t as O}from"./Card-WUD1cwG6.js";import{t as k}from"./PageHeader-D8pqg_wk.js";import{t as ee}from"./SectionHeader-DZo4QVWr.js";import{i as A}from"./format-ZWN4JNj-.js";import{t as te}from"./EmptyState-BLB33cKG.js";import{t as j}from"./ui-D1crlGpt.js";import{t as ne}from"./EnvVarEditor-BchUNrmz.js";var M=e(c(),1),N=u(),re={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`]}},ie={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.`},ae=[`defaults.deniedReadPaths`,`defaults.approvalRequired`],oe=new Set([`anthropic.apiKey`,`server.apiKey`,`emailGateway.imap.auth.pass`,`emailGateway.smtp.auth.pass`]),P={"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)`,"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`},se={"defaults.effort":[`low`,`medium`,`high`,`max`],"logging.level":[`debug`,`info`,`warn`,`error`],"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 F(e){return e?e.enabled?e.configured?e.lastStatus===`stopped`?`disconnected`:e.lastStatus===`error`?`failed`:e.lastStatus:`not_configured`:`disabled`:`not_checked`}function I(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 L(){let[e,a]=(0,M.useState)({}),[c,u]=(0,M.useState)([]),[f,p]=(0,M.useState)({}),[m,h]=(0,M.useState)(new Set),[g,_]=(0,M.useState)(!1),[j,L]=(0,M.useState)(null),[de,fe]=(0,M.useState)(!0),[R,z]=(0,M.useState)(null),[B,V]=(0,M.useState)({}),[H,U]=(0,M.useState)(new Set),[pe,me]=(0,M.useState)({}),[W,G]=(0,M.useState)(null),[K,he]=(0,M.useState)(null),[q,J]=(0,M.useState)(null),Y=x(e=>e.configVersion);(0,M.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,M.useCallback)(async()=>{try{let e=await v(`/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&&A(n);let r={};for(let t of ae){let n=e.config[t];n&&(r[t]=Array.isArray(n.value)?n.value:[])}V(r),U(new Set),z(await v(`/config/env-diff`)),me((await v(`/config/env`)).env),he(await v(`/config/email-gateway/status`))}catch(e){L({type:`error`,text:e instanceof Error?e.message:`Failed to load config`})}finally{fe(!1)}},[]);(0,M.useEffect)(()=>{Z()},[Z]),(0,M.useEffect)(()=>{Y>0&&Z()},[Y,Z]);let ge=async()=>{await v(`/config/sync-to-env`,{method:`POST`}),L({type:`success`,text:`Synced DB values to .env`}),z(null)},_e=async()=>{await v(`/config/load-from-env`,{method:`POST`}),L({type:`success`,text:`Loaded .env values to DB`}),Z()},Q=(e,t)=>{p(n=>({...n,[e]:t})),h(t=>new Set(t).add(e)),L(null)},$=async e=>{let t=e===`imap`?`/config/email-gateway/test-imap`:e===`smtp`?`/config/email-gateway/test-smtp`:`/config/email-gateway/test-roundtrip`;J(e),L(null);try{G(await v(t,{method:`POST`}))}catch(t){G({ok:!1,stage:e,code:`unknown_error`,message:t instanceof Error?t.message:`Email Gateway test failed`})}finally{J(null)}},ve=async()=>{if(m.size!==0){_(!0),L(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)){L({type:`error`,text:`"${P[n]??n}" must be a number`}),_(!1);return}}else r&&typeof r.value==`boolean`&&n.startsWith(`emailGateway.`)&&(i=i===`true`);t[n]=i}let n=await v(`/config`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...Object.fromEntries(Array.from(H).map(e=>[e,B[e]??[]]))})});if(n.updated.length>0&&(L({type:`success`,text:`Updated ${n.updated.length} setting(s)`}),n.updated.includes(`server.timezone`))){let e=f[`server.timezone`];A(e)}n.errors.length>0&&L({type:`error`,text:n.errors.join(`; `)}),h(new Set),Z()}catch(e){L({type:`error`,text:e instanceof Error?e.message:`Save failed`})}finally{_(!1)}}};return de?(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,N.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,N.jsx)(te,{icon:(0,N.jsx)(r,{size:32}),title:`No configuration`,description:`Config API not available`}):(0,N.jsxs)(`div`,{className:`space-y-5`,children:[(0,N.jsx)(k,{eyebrow:`Configuration`,title:`Settings`,compact:!0,description:`Mutable fields, pending edits, and environment drift.`,metrics:[{label:`Editable`,value:c.length},{label:`Pending`,value:m.size+H.size},{label:`Env Drift`,value:R?.diffs.length??0}],actions:(0,N.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,N.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>void Z(),children:(0,N.jsx)(n,{size:14})}),m.size>0&&(0,N.jsxs)(d,{size:`sm`,onClick:()=>void ve(),disabled:g,children:[(0,N.jsx)(i,{size:14}),g?`Saving...`:`Save (${m.size})`]})]})}),(0,N.jsx)(ee,{title:`Configuration Groups`,compact:!0,description:`Fields stay in place while changeable, restart-required, and pending state are clarified.`}),j&&(0,N.jsx)(`div`,{className:`rounded-lg border px-4 py-3 text-sm ${j.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:j.text}),R&&R.diffs.length>0&&(0,N.jsx)(O,{className:`surface-accent`,children:(0,N.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:[`.env and DB have `,R.diffs.length,` different value(s)`]}),(0,N.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:R.diffs.map(e=>e.envKey).join(`, `)})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-2 md:justify-end`,children:[(0,N.jsx)(d,{variant:`ghost`,size:`sm`,onClick:ge,children:`Sync DB → .env`}),(0,N.jsx)(d,{variant:`ghost`,size:`sm`,onClick:_e,children:`Load .env → DB`})]})]})}),Object.entries(re).map(([n,{label:r,paths:i,mutablePaths:a}])=>{let l=[...i,...a??[]],u=l.filter(e=>c.includes(e)).length;return(0,N.jsxs)(O,{children:[(0,N.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-4`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:r}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-[var(--app-text-muted)]`,children:ie[n]??`Configuration values for this system area.`})]}),(0,N.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,N.jsx)(`div`,{className:`space-y-3`,children:l.map(n=>{let r=e[n];if(!r)return null;let i=c.includes(n),a=P[n]??n,o=f[n]??String(r.value??``),s=m.has(n),l=se[n],u=n.startsWith(`emailGateway.`)&&typeof r.value==`boolean`,d=`setting-${n.replace(/[^A-Za-z0-9_-]/g,`-`)}`;return(0,N.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,N.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 md:w-56 md:shrink-0`,children:[!i&&(0,N.jsx)(t,{size:12,className:`text-[var(--app-text-subtle)]`}),(0,N.jsx)(`label`,{htmlFor:d,className:`text-sm text-[var(--app-text-muted)]`,children:a}),!i&&(0,N.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`restart required`})]}),(0,N.jsx)(`div`,{className:`min-w-0 flex-1`,children:l?(0,N.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,N.jsx)(`option`,{value:e,children:e},e))}):u?(0,N.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,N.jsx)(`option`,{value:`true`,children:`true`}),(0,N.jsx)(`option`,{value:`false`,children:`false`})]}):(0,N.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:oe.has(n)?`password`:`text`,value:o,onChange:e=>Q(n,e.target.value),disabled:!i,placeholder:oe.has(n)?`Enter to update`:void 0})}),(0,N.jsx)(`div`,{className:`text-left md:w-16 md:text-right`,children:s&&i&&(0,N.jsx)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:`modified`})})]},n)})}),n===`emailGateway`&&(0,N.jsxs)(`div`,{className:`mt-4 border-t border-[var(--app-border)] pt-4`,children:[(0,N.jsxs)(`div`,{className:`mb-3 grid gap-2 text-sm md:grid-cols-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Runtime status`}),(0,N.jsx)(`p`,{children:(0,N.jsx)(`span`,{className:I(F(K)),children:F(K)})})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Last test`}),(0,N.jsx)(`p`,{children:W?(0,N.jsxs)(`span`,{className:I(W.ok?`connected`:`failed`),children:[W.stage,` `,W.code??``,`: `,W.message]}):(0,N.jsx)(`span`,{className:I(`not_checked`),children:`Not checked`})})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Last checked`}),(0,N.jsx)(`p`,{className:`text-[var(--app-text-muted)]`,children:K?.lastCheckedAt?new Date(K.lastCheckedAt).toLocaleString():`Never`})]})]}),(0,N.jsxs)(`div`,{className:`mb-3 text-sm`,children:[(0,N.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Last error`}),(0,N.jsx)(`p`,{className:`text-[var(--app-danger-soft-text)]`,children:K?.lastError??`None`})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,N.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>void $(`imap`),disabled:q!==null,children:[(0,N.jsx)(o,{size:14}),q===`imap`?`Testing IMAP...`:`Test IMAP`]}),(0,N.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>void $(`smtp`),disabled:q!==null,children:[(0,N.jsx)(o,{size:14}),q===`smtp`?`Testing SMTP...`:`Test SMTP`]}),(0,N.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:()=>void $(`roundtrip`),disabled:q!==null,children:[(0,N.jsx)(s,{size:14}),q===`roundtrip`?`Sending probe...`:`Send test email`]})]})]})]},n)}),(0,N.jsx)(ne,{envVars:pe,onSave:()=>void Z(),mode:`global`,title:`Environment Variables`}),(0,N.jsx)(ue,{}),(0,N.jsx)(ce,{mutablePaths:c,listValues:B,listDirty:H,setListValues:V,setListDirty:e=>U(e),dirty:m}),(0,N.jsx)(le,{}),(0,N.jsx)(T,{open:X.state===`blocked`,children:(0,N.jsxs)(w,{children:[(0,N.jsxs)(C,{children:[(0,N.jsx)(D,{children:`Unsaved Changes`}),(0,N.jsxs)(E,{children:[`You have `,m.size+H.size,` unsaved change(s). Discard and leave?`]})]}),(0,N.jsxs)(b,{children:[(0,N.jsx)(y,{onClick:()=>X.reset?.(),children:`Stay`}),(0,N.jsx)(S,{onClick:()=>X.proceed?.(),children:`Discard`})]})]})})]})}function ce({mutablePaths:e,listValues:n,listDirty:r,setListValues:i,setListDirty:o,dirty:s}){let[c,l]=(0,M.useState)(``),[u,f]=(0,M.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,N.jsxs)(O,{children:[(0,N.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Advanced`}),T>0&&(0,N.jsxs)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:[r.size,` modified`]})]}),(0,N.jsxs)(`div`,{className:`mb-6`,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,N.jsx)(`h3`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Denied Read Paths`}),!p&&(0,N.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[(0,N.jsx)(t,{size:j.xs}),` restart required`]})]}),(0,N.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,N.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`*`}),` as wildcard.`]}),(0,N.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:h.map(e=>{let n=y(e);return(0,N.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,N.jsx)(t,{size:j.xs}),e,!n&&p&&(0,N.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>S(e),children:(0,N.jsx)(a,{size:j.xs})})]},e)})}),p&&(0,N.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,N.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,N.jsx)(d,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>x(),children:`Add`})]})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,N.jsx)(`h3`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Approval Required Patterns`}),!m&&(0,N.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[(0,N.jsx)(t,{size:j.xs}),` restart required`]})]}),(0,N.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,N.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`*`}),` = wildcard, e.g.,`,` `,(0,N.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`rm -rf *`}),`).`]}),(0,N.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:g.map(e=>{let n=b(e);return(0,N.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,N.jsx)(t,{size:j.xs}),e,!n&&m&&(0,N.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-warning)] hover:text-[var(--app-warning-soft-text)]`,onClick:()=>w(e),children:(0,N.jsx)(a,{size:j.xs})})]},e)})}),m&&(0,N.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,N.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,N.jsx)(d,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>C(),children:`Add`})]})]})]})}function le(){let[e,t]=(0,M.useState)([]),[n,r]=(0,M.useState)(!0),[i,a]=(0,M.useState)(!1),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(15),[u,f]=(0,M.useState)(30),[p,h]=(0,M.useState)(500),[g,_]=(0,M.useState)(!1),y=2e3,b=e.find(e=>e.presetId===`feature-mining`)?.id;(0,M.useEffect)(()=>{(async()=>{try{let e=(await v(`/task-templates`)).templates.find(e=>e.presetId===`feature-mining`);e&&(t([e]),l(e.config?.max_sessions??15),f(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 m(b,{max_sessions:c,max_messages_per_session:u,message_char_cap:p}),s({type:`success`,text:`Feature Miner limits saved`}),_(!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(p,100)/4,C=`~${Math.round(S).toLocaleString()} tokens (worst case)`;return(0,N.jsxs)(O,{children:[(0,N.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Feature Miner Pre-fetch Limits`}),(0,N.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.`})]}),g&&(0,N.jsx)(d,{size:`sm`,onClick:()=>void x(),disabled:i,children:i?`Saving...`:`Save`})]}),o&&(0,N.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,N.jsxs)(`div`,{className:`space-y-4`,children:[(0,N.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`label`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,htmlFor:`fm-max-sessions`,children:`Max Sessions`}),(0,N.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`ceiling: `,50]})]}),(0,N.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))),_(!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,N.jsx)(`p`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`Sessions to scan (most recent first). Default: 15.`})]}),(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`label`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,htmlFor:`fm-max-messages`,children:`Max Messages / Session`}),(0,N.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`ceiling: `,100]})]}),(0,N.jsx)(`input`,{id:`fm-max-messages`,type:`number`,min:1,max:100,value:u,onChange:e=>{f(Math.min(100,Math.max(1,parseInt(e.target.value)||1))),_(!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,N.jsx)(`p`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`Most recent messages per session. Default: 30.`})]}),(0,N.jsxs)(`div`,{className:`space-y-1`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsx)(`label`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,htmlFor:`fm-char-cap`,children:`Message Char Cap`}),(0,N.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`ceiling: `,y]})]}),(0,N.jsx)(`input`,{id:`fm-char-cap`,type:`number`,min:10,max:y,value:p,onChange:e=>{h(Math.min(y,Math.max(10,parseInt(e.target.value)||10))),_(!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,N.jsx)(`p`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`Max characters per message. Default: 500.`})]})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Estimated worst-case prompt size`}),(0,N.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:C})]}),S>15e4&&(0,N.jsx)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:`Near context window limit`})]})]})]})}function ue(){let e=_()??``,[t,r]=(0,M.useState)(!1),[i,o]=(0,M.useState)(!1),[s,c]=(0,M.useState)(!1),[l,u]=(0,M.useState)(null),[m,v]=(0,M.useState)(null),x=e.length>12?e.slice(0,4)+`****`+e.slice(-4):`(no key in localStorage)`;async function k(){o(!0),v(null);try{let e=await h();f(e),u(e),c(!1)}catch(e){v(e instanceof Error?e.message:String(e)),c(!1)}finally{o(!1)}}function A(){p(),g()}return(0,N.jsxs)(O,{children:[(0,N.jsx)(ee,{title:`Adam API Key`,description:`Rotate or sign out`}),(0,N.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.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,N.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>r(e=>!e),children:t?`Hide`:`Show`})]}),(0,N.jsxs)(`div`,{className:`flex gap-2`,children:[(0,N.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>c(!0),disabled:i,children:[(0,N.jsx)(n,{size:j.xs,className:`mr-1`}),`Rotate key`]}),(0,N.jsxs)(d,{variant:`ghost`,size:`sm`,onClick:A,children:[(0,N.jsx)(a,{size:j.xs,className:`mr-1`}),`Log out`]})]}),m&&(0,N.jsx)(`div`,{className:`rounded border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-400`,children:m}),(0,N.jsxs)(`p`,{className:`text-xs text-[var(--app-muted)]`,children:[`Rotating generates a new key, writes it to `,(0,N.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,N.jsx)(`code`,{children:`/webhooks/:name`}),` endpoints need the new key.`]})]}),(0,N.jsx)(T,{open:s,children:(0,N.jsxs)(w,{children:[(0,N.jsxs)(C,{children:[(0,N.jsx)(D,{children:`Rotate API key?`}),(0,N.jsxs)(E,{children:[`The old key stops working immediately. Other browsers/TUI sessions and any external callers of `,(0,N.jsx)(`code`,{children:`/webhooks/:name`}),` will return 401 until updated. Channel adapters (WeChat, Telegram, Discord) use their own credentials and are not affected.`]})]}),(0,N.jsxs)(b,{children:[(0,N.jsx)(y,{onClick:()=>c(!1),children:`Cancel`}),(0,N.jsx)(S,{onClick:k,disabled:i,children:i?`Rotating...`:`Rotate`})]})]})}),(0,N.jsx)(T,{open:!!l,children:(0,N.jsxs)(w,{children:[(0,N.jsxs)(C,{children:[(0,N.jsx)(D,{children:`New API key`}),(0,N.jsx)(E,{children:`Save this somewhere safe. Other devices and channels need to be updated with this key.`})]}),(0,N.jsx)(`code`,{className:`mt-2 block break-all rounded bg-[var(--app-bg)] p-3 font-mono text-xs`,children:l}),(0,N.jsxs)(b,{children:[(0,N.jsx)(S,{onClick:()=>{l&&navigator.clipboard.writeText(l)},children:`Copy`}),(0,N.jsx)(S,{onClick:()=>u(null),children:`Done`})]})]})})]})}export{L as Settings};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{U as t,V as n,at as r,g as i,gt as a,ht as o,o as s,q as c,rt as l,tt as u,yt as d}from"./vendor-icons-H7p0EuQJ.js";import{f as ee,r as f,t as p}from"./vendor-react-C1yKjxEP.js";import{t as m}from"./Button-xVc-P0vm.js";import{s as te,t as h}from"./api-BkdixMz9.js";import{n as ne,t as g}from"./index-iD-HOtIu.js";import{i as re,t as ie}from"./ArtifactDetail-9DJdEqCz.js";import{a as _,i as v,r as y,t as b}from"./Card-WUD1cwG6.js";import{t as x}from"./PageHeader-D8pqg_wk.js";import{t as ae}from"./SectionHeader-DZo4QVWr.js";import{a as S,n as C,r as w,t as T}from"./format-ZWN4JNj-.js";import{t as E}from"./ui-D1crlGpt.js";var D=e(d(),1),O=p(),k={reasoning:`text-[var(--app-accent)]`,tool_call:`text-[var(--app-accent-strong)]`,tool_result:`text-[var(--app-success)]`,approval_request:`text-[var(--app-warning)]`,approval_response:`text-[var(--app-warning-strong)]`,permission_denied:`text-[var(--app-indicator-alert)]`,error:`text-[var(--app-danger)]`,plugin_error:`text-[var(--app-danger)]`};function oe({logs:e}){let[t,n]=(0,D.useState)(new Set);return e.length===0?(0,O.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No execution steps yet.`}):(0,O.jsx)(`div`,{className:`space-y-0`,children:e.map((i,a)=>{let o=a>0?e[a-1].timestamp:null,s=o?i.timestamp-o:null,c=i.type===`plugin_error`,l=t.has(a)?i.content:i.content.length>200?i.content.slice(0,200)+`...`:i.content;return(0,O.jsxs)(`div`,{className:`flex gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,O.jsx)(r,{size:10,className:`mt-1.5 flex-shrink-0 fill-current ${k[i.type]??`text-[var(--app-text-subtle)]`} ${c?`rounded-full ring-2 ring-[var(--app-danger)]`:``}`}),a<e.length-1&&(0,O.jsx)(`div`,{className:`mt-0.5 w-0.5 flex-1 bg-[var(--app-border)]`})]}),(0,O.jsxs)(`div`,{className:`flex-1 pb-4 ${c?`rounded-lg border border-[var(--app-danger)]/40 bg-[var(--app-danger-soft-bg-subtle)] p-3`:``}`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,O.jsxs)(`span`,{className:`text-xs font-mono text-[var(--app-text-subtle)]`,children:[`#`,i.index]}),(0,O.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:i.toolName??i.type}),c&&(0,O.jsx)(g,{variant:`destructive`,children:`Plugin Error`}),(0,O.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:S(i.timestamp)}),s!=null&&s>0&&(0,O.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`+`,s,`ms`]}),i.truncated&&(0,O.jsx)(g,{variant:`outline`,children:`truncated`})]}),l&&(0,O.jsx)(`button`,{className:`mt-2 w-full rounded-lg border border-[var(--app-border)] bg-white/[0.03] px-3 py-3 text-left font-mono text-xs text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)] hover:text-[var(--app-text)]`,onClick:()=>{n(e=>{let t=new Set(e);return t.has(a)?t.delete(a):t.add(a),t})},children:l})]})]},i.id)})})}function A(){let{id:e}=ee(),[r,d]=(0,D.useState)(null),[p,S]=(0,D.useState)([]),[k,A]=(0,D.useState)([]),[M,N]=(0,D.useState)([]),[P,F]=(0,D.useState)(null),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(!1),[B,ce]=(0,D.useState)(!1),[V,H]=(0,D.useState)(!1),[U,W]=(0,D.useState)(!1),[G,K]=(0,D.useState)(`overview`),[q,J]=(0,D.useState)([]),[Y,X]=(0,D.useState)(!1),[le,Z]=(0,D.useState)(null),[Q,$]=(0,D.useState)(null),ue=(0,D.useMemo)(()=>{if(!r)return`No diagnostics yet`;let e=[];return r.error&&e.push(`error`),k.length>0&&e.push(`${k.length} steps`),M.length>0&&e.push(`${M.length} delivery events`),e.length>0?e.join(` · `):`No diagnostics yet`},[M.length,k.length,r]);(0,D.useEffect)(()=>{if(!e)return;let t=!1,n=async()=>{if(!t)try{let n=await h(`/tasks/${e}`);if(t)return;d(n.task),L(null)}catch(e){if(t)return;L(e instanceof Error?e.message:`Failed to load task`)}};n(),h(`/tasks/${e}/plan`).then(e=>{t||S(e.plans)}).catch(()=>{t||S([])}),h(`/tasks/${e}/logs?limit=200`).then(e=>{t||A(e.logs)}).catch(()=>{t||A([])}),te(e).then(e=>{t||N(e)}).catch(()=>{t||N([])});let r=setInterval(n,3e3);return()=>{t=!0,clearInterval(r)}},[e]),(0,D.useEffect)(()=>{if(!e||G!==`artifacts`)return;let t=!1;return X(!0),Z(null),h(`/tasks/${e}/artifacts`).then(e=>{t||(J(e.artifacts),X(!1))}).catch(e=>{t||(Z(e instanceof Error?e.message:`Failed to load artifacts`),X(!1))}),()=>{t=!0}},[e,G]),(0,D.useEffect)(()=>{if(!r?.roleId||!e)return;let t=!1;return h(`/roles/${r.roleId}/scores?limit=100`).then(n=>{t||F(n.scores.find(t=>t.taskId===e)??null)}).catch(()=>{t||F(null)}),()=>{t=!0}},[r?.roleId,e]);let de=async()=>{if(e){z(!0);try{await h(`/tasks/${e}/cancel`,{method:`POST`}),d(e=>e&&{...e,status:`cancelled`})}finally{z(!1)}}};if(I)return(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsxs)(f,{to:`/work`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,O.jsx)(a,{size:E.sm}),` Back to Tasks`]}),(0,O.jsx)(b,{className:`text-center text-[var(--app-danger)]`,children:I})]});if(!r)return(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsxs)(f,{to:`/work`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,O.jsx)(a,{size:E.sm}),` Back to Tasks`]}),(0,O.jsx)(b,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let fe=[`running`,`queued`,`pending`,`paused`].includes(r.status);return(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsx)(x,{eyebrow:`Task`,title:`Task Detail`,compact:!0,description:`Summary, execution, result, and diagnostics.`,metrics:[{label:`Status`,value:(0,O.jsx)(g,{variant:ne(r.status),children:r.status})},{label:`Task`,value:r.id.slice(0,8)},{label:`Elapsed`,value:r.totalDurationMs?w(r.totalDurationMs):r.startedAt?w(Date.now()-r.startedAt):`—`},{label:`Spend`,value:r.costUsd==null?`—`:T(r.costUsd)}],actions:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(f,{to:`/work`,className:`inline-flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,O.jsx)(a,{size:E.sm}),` Back to Tasks`]}),fe&&(0,O.jsxs)(m,{variant:`destructive`,size:`sm`,onClick:()=>void de(),disabled:R,children:[(0,O.jsx)(o,{size:E.sm}),R?`Cancelling...`:`Cancel Task`]})]})}),(0,O.jsxs)(`div`,{className:`flex gap-1 border-b border-[var(--app-border)]`,"data-testid":`task-detail-tabs`,children:[(0,O.jsx)(`button`,{type:`button`,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${G===`overview`?`border-[var(--app-accent)] text-[var(--app-accent)]`:`border-transparent text-[var(--app-muted)] hover:text-[var(--app-fg)]`}`,onClick:()=>K(`overview`),"data-testid":`tab-overview`,children:`Overview`}),(0,O.jsx)(`button`,{type:`button`,className:`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${G===`artifacts`?`border-[var(--app-accent)] text-[var(--app-accent)]`:`border-transparent text-[var(--app-muted)] hover:text-[var(--app-fg)]`}`,onClick:()=>K(`artifacts`),"data-testid":`tab-artifacts`,children:`Artifacts`})]}),G===`artifacts`&&(0,O.jsxs)(`div`,{"data-testid":`artifacts-tab-content`,children:[(0,O.jsx)(re,{artifacts:q,selectedId:Q,onSelect:$,loading:Y,error:le}),Q&&(()=>{let e=q.find(e=>e.id===Q);return e?(0,O.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,"data-testid":`artifact-modal-backdrop`,onClick:()=>$(null),children:(0,O.jsx)(`div`,{className:`bg-[var(--app-bg)] rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-[90vh] overflow-auto`,onClick:e=>e.stopPropagation(),children:(0,O.jsx)(ie,{artifact:e,onDeleted:()=>{$(null),J(e=>e.filter(e=>e.id!==Q))},onRedelivered:()=>{}})})}):null})()]}),G===`overview`&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(b,{className:`surface-accent text-white`,children:(0,O.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-kicker text-white/70`,children:`Summary`}),(0,O.jsx)(`p`,{className:`mt-2 text-base leading-7 text-white`,children:r.prompt.length>220&&!B?`${r.prompt.slice(0,220)}…`:r.prompt})]}),(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[r.prompt.length>220?(0,O.jsxs)(m,{variant:`secondary`,size:`sm`,onClick:()=>ce(e=>!e),children:[(0,O.jsx)(c,{size:E.sm}),B?`Collapse prompt`:`Show full prompt`]}):null,(0,O.jsxs)(m,{variant:`secondary`,size:`sm`,onClick:()=>W(e=>!e),children:[(0,O.jsx)(i,{size:E.sm}),U?`Hide diagnostics`:`Show diagnostics`]})]})]})}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,O.jsx)(j,{icon:l,label:`Created`,value:C(r.createdAt)}),(0,O.jsx)(j,{icon:l,label:`Duration`,value:r.totalDurationMs?w(r.totalDurationMs):r.startedAt?w(Date.now()-r.startedAt):`—`}),(0,O.jsx)(j,{icon:u,label:`Cost`,value:r.costUsd==null?`—`:T(r.costUsd)}),(0,O.jsx)(j,{icon:t,label:`Turns`,value:String(r.numTurns??`—`)})]}),(0,O.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,O.jsx)(j,{icon:s,label:`Role`,value:r.roleId??`—`,mono:!0}),(0,O.jsx)(j,{icon:n,label:`Parent`,value:r.parentId??`—`,mono:!0}),r.templateId?(0,O.jsxs)(f,{to:`/work`,className:`block`,children:[(0,O.jsx)(j,{icon:n,label:`Template`,value:r.templateId,mono:!0}),(0,O.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:`View in Automations →`})]}):(0,O.jsx)(j,{icon:n,label:`Template`,value:`—`,mono:!0}),r.sourceSessionId&&(0,O.jsx)(j,{icon:t,label:`Source Session`,value:r.sourceSessionId.slice(0,8),mono:!0})]}),(r.deliverTo||r.reportTo)&&(0,O.jsxs)(b,{children:[(0,O.jsx)(v,{children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{children:`Delivery Targets`}),(0,O.jsx)(y,{children:`Where results and status updates are sent after execution.`})]})}),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[r.deliverTo&&r.deliverTo.length>0&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mb-1`,children:`Output`}),(0,O.jsx)(`div`,{className:`space-y-1`,children:r.deliverTo.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:[(0,O.jsx)(g,{variant:`outline`,children:e.type===`channel`?`Channel`:`Session`}),e.type===`channel`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,O.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,O.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`session `,e.sessionId?.slice(0,8)]})]},`d-${t}`))})]}),r.reportTo&&r.reportTo.length>0&&(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mb-1`,children:`Status Reports`}),(0,O.jsx)(`div`,{className:`space-y-1`,children:r.reportTo.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:[(0,O.jsx)(g,{variant:`outline`,children:e.type===`channel`?`Channel`:`Session`}),e.type===`channel`?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,O.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,O.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`session `,e.sessionId?.slice(0,8)]})]},`r-${t}`))})]})]})]}),P&&(r.status===`completed`||r.status===`failed`)&&(0,O.jsx)(se,{score:P}),r.tokenUsage&&(0,O.jsxs)(b,{children:[(0,O.jsx)(v,{children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{children:`Token Usage`}),(0,O.jsx)(y,{children:`Input and output token totals for this execution.`})]})}),(0,O.jsxs)(`div`,{className:`flex gap-6 text-sm`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Input:`}),` `,(0,O.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:r.tokenUsage.input.toLocaleString()})]}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Output:`}),` `,(0,O.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:r.tokenUsage.output.toLocaleString()})]})]})]}),p.length>0&&(()=>{let e=p[0],t=e.plan.overallRisk===`high`?`destructive`:e.plan.overallRisk===`medium`?`warning`:`secondary`;return(0,O.jsxs)(b,{children:[(0,O.jsx)(v,{children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{children:`Execution Plan`}),(0,O.jsx)(y,{children:`Expected steps, risk, and permissions before execution.`})]}),(0,O.jsxs)(g,{variant:t,children:[e.plan.overallRisk.toUpperCase(),` RISK`]}),(0,O.jsx)(g,{variant:`outline`,children:e.status})]})}),(0,O.jsxs)(`h4`,{className:`text-sm font-medium text-[var(--app-text)] mb-2`,children:[`Plan Steps (`,e.plan.steps.length,`)`]}),(0,O.jsx)(`div`,{className:`space-y-2`,children:e.plan.steps.map(e=>(0,O.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)]/50 p-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`span`,{className:`text-xs font-mono text-[var(--app-text-subtle)]`,children:[`#`,e.index]}),(0,O.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:e.description})]}),(0,O.jsx)(g,{variant:e.riskLevel===`high`?`destructive`:e.riskLevel===`medium`?`warning`:`secondary`,children:e.riskLevel})]}),(0,O.jsxs)(`div`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:[`Tools: `,e.toolsNeeded.join(`, `)||`none`]}),e.expectedOutput&&(0,O.jsxs)(`div`,{className:`mt-0.5 text-xs text-[var(--app-text-subtle)]`,children:[`Expected: `,e.expectedOutput]})]},e.index))}),Object.keys(e.plan.requiredPermissions).length>0&&(0,O.jsxs)(`div`,{className:`mt-2`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)] mb-1`,children:`Required Permissions`}),(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.keys(e.plan.requiredPermissions).map(e=>(0,O.jsx)(g,{variant:`secondary`,children:e},e))})]}),e.deviationReport&&(0,O.jsxs)(`div`,{className:`mt-3 rounded-md border border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg-subtle)] p-3`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-warning)] mb-2`,children:`Deviation Report`}),(0,O.jsxs)(`div`,{className:`text-xs text-[var(--app-text-muted)] mb-2`,children:[`Planned: `,e.deviationReport.stepsPlanned,` | Executed: `,e.deviationReport.stepsExecuted,` | Accuracy: `,(e.deviationReport.overallAccuracy*100).toFixed(0),`%`]}),e.deviationReport.deviations.length>0&&(0,O.jsx)(`div`,{className:`space-y-1`,children:e.deviationReport.deviations.map((e,t)=>(0,O.jsxs)(`div`,{className:`text-xs`,children:[(0,O.jsxs)(`span`,{className:`text-[var(--app-warning)] font-mono`,children:[`[`,e.deviationType,`]`]}),(0,O.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[` Step `,e.stepIndex,`: `]}),(0,O.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.actual})]},t))})]}),e.learnedRules&&e.learnedRules.length>0&&(0,O.jsxs)(`div`,{className:`mt-3`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)] mb-2`,children:`Learned Rules`}),(0,O.jsx)(`ul`,{className:`space-y-1`,children:e.learnedRules.map((e,t)=>(0,O.jsxs)(`li`,{className:`text-xs text-[var(--app-text-muted)] flex items-start gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-[var(--app-accent)] mt-0.5`,children:`*`}),e]},t))})]})]})})(),k.length>0&&(0,O.jsxs)(b,{children:[(0,O.jsx)(v,{children:(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(_,{children:[`Execution Timeline (`,k.length,` steps)`]}),(0,O.jsx)(y,{children:`Ordered execution events, tool calls, and error markers.`})]})}),(0,O.jsx)(oe,{logs:k})]}),r.result&&(0,O.jsxs)(b,{children:[(0,O.jsx)(v,{children:(0,O.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{children:`Result`}),(0,O.jsx)(y,{children:`The final task output. Raw text stays collapsed until needed.`})]}),r.result.length>360?(0,O.jsx)(m,{variant:`ghost`,size:`sm`,onClick:()=>H(e=>!e),children:V?`Collapse`:`Expand`}):null]})}),(0,O.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-panel-elevated)] p-3 font-mono text-xs text-[var(--app-text)]`,children:r.result.length>360&&!V?`${r.result.slice(0,360)}…`:r.result})]}),r.error&&(()=>{let e=[`plugin`,`--plugin-dir`,`failed to load plugin`],t=r.error.toLowerCase(),n=e.some(e=>t.includes(e)),i=n?r.error.split(`
2
- `).find(t=>e.some(e=>t.toLowerCase().includes(e))):null;return(0,O.jsxs)(b,{className:n?`border-[var(--app-danger)]`:``,children:[(0,O.jsx)(v,{children:(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{children:`Error`}),(0,O.jsx)(y,{children:`Execution failed or returned an error condition.`})]}),n&&(0,O.jsx)(g,{variant:`warning`,children:`Plugin Issue`})]})}),n&&i&&(0,O.jsx)(`div`,{className:`mb-2 rounded bg-[var(--app-warning-soft-bg-subtle)] px-2 py-1 text-xs text-[var(--app-warning)]`,children:i}),(0,O.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-danger-soft-bg-subtle)] p-3 font-mono text-xs text-[var(--app-danger)]`,children:r.error})]})})(),(0,O.jsxs)(b,{children:[(0,O.jsx)(v,{children:(0,O.jsxs)(`div`,{children:[(0,O.jsx)(_,{children:`Diagnostics`}),(0,O.jsx)(y,{children:ue})]})}),U?M.length>0?(0,O.jsxs)(`div`,{className:`space-y-4`,children:[(0,O.jsx)(ae,{title:`Delivery Log`,description:`Recent delivery attempts and outcomes.`}),(0,O.jsx)(`div`,{className:`space-y-2`,children:M.map(e=>{let t=e.status===`delivered`?`success`:e.status===`pending`?`secondary`:`destructive`,n=e.target.type===`webhook`?e.target.webhookUrl:e.target.type===`channel`?`channel ${e.target.channelId.slice(0,8)}`:`session ${e.target.sessionId?.slice(0,8)}`;return(0,O.jsxs)(`div`,{className:`surface-panel-muted rounded-lg px-3 py-3 text-sm`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(g,{variant:t,children:e.status}),(0,O.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:n}),e.messageType?(0,O.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`(`,e.messageType,`)`]}):null]}),e.error?(0,O.jsx)(`p`,{className:`mt-2 text-xs text-[var(--app-danger-soft-text)]`,children:e.error}):null,(0,O.jsxs)(`p`,{className:`mt-2 text-xs text-[var(--app-text-subtle)]`,children:[C(e.createdAt),e.deliveredAt&&` \u2192 ${C(e.deliveredAt)}`]})]},e.id)})})]}):(0,O.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-4 text-sm text-[var(--app-text-subtle)]`,children:`No delivery events recorded yet.`}):(0,O.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-4 text-sm text-[var(--app-text-subtle)]`,children:`Diagnostics are hidden by default because this section can contain raw execution details and operational data.`})]})]})]})}function se({score:e}){let t=[{label:`Task Success`,value:e.scores.taskSuccess,weight:`25%`},{label:`Plan Accuracy`,value:e.scores.planAccuracy,weight:`20%`},{label:`Permission Compliance`,value:e.scores.permissionCompliance,weight:`20%`},{label:`Efficiency`,value:e.scores.efficiency,weight:`15%`},{label:`Intent Fulfillment`,value:e.scores.intentFulfillment,weight:`20%`,pending:e.scores.intentFulfillment==null}];return(0,O.jsxs)(b,{children:[(0,O.jsx)(v,{children:(0,O.jsx)(_,{children:`Quality Score`})}),(0,O.jsxs)(`div`,{className:`space-y-3`,children:[t.map(e=>(0,O.jsxs)(`div`,{children:[(0,O.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-xs`,children:[(0,O.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[e.label,` `,(0,O.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`(`,e.weight,`)`]})]}),e.pending?(0,O.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,title:`Intent eval pending or failed`,children:`—`}):(0,O.jsxs)(`span`,{className:`font-mono text-[var(--app-text)]`,children:[((e.value??0)*100).toFixed(0),`%`]})]}),!e.pending&&e.value!=null&&(0,O.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-[var(--app-panel-elevated)]`,children:(0,O.jsx)(`div`,{className:`h-full rounded-full ${e.value<.4?`bg-[var(--app-danger)]`:`bg-[var(--app-accent)]`}`,style:{width:`${e.value*100}%`}})})]},e.label)),(0,O.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-[var(--app-border)] pt-2`,children:[(0,O.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:`Weighted Score`}),(0,O.jsxs)(`span`,{className:`font-mono text-sm font-semibold text-[var(--app-text)]`,children:[(e.scores.weighted*100).toFixed(0),`%`]})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:`EMA (after this task)`}),(0,O.jsxs)(`span`,{className:`font-mono text-sm font-semibold ${e.emaScore<.4?`text-[var(--app-danger)]`:`text-[var(--app-success)]`}`,children:[(e.emaScore*100).toFixed(0),`%`]})]})]})]})}function j({icon:e,label:t,value:n,mono:r}){return(0,O.jsxs)(b,{className:`flex flex-col gap-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,O.jsx)(e,{size:12}),(0,O.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,O.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{A as TaskDetail};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{J as t,O as n,R as r,S as i,T as a,dt as o,ft as s,ht as ee,k as c,l,ut as u,yt as d}from"./vendor-icons-H7p0EuQJ.js";import{r as f,t as p}from"./vendor-react-C1yKjxEP.js";import"./es2015-BgPT8VkR.js";import{t as m}from"./Button-xVc-P0vm.js";import{t as h}from"./vendor-state-D0TNAbOY.js";import{t as g}from"./api-BkdixMz9.js";import{a as _,c as v,f as y,i as te,l as ne,n as b,o as re,p as x,r as S,s as C,t as w,u as ie}from"./index-iD-HOtIu.js";import{t as T}from"./Card-WUD1cwG6.js";import{t as E}from"./PageHeader-D8pqg_wk.js";import{t as ae}from"./SectionHeader-DZo4QVWr.js";import{a as oe,o as D,t as se}from"./format-ZWN4JNj-.js";import{t as ce}from"./EmptyState-BLB33cKG.js";import{t as O}from"./ui-D1crlGpt.js";import{t as le}from"./useIsMobileLayout-DF2fEEM9.js";import{a as ue,i as k,n as de,o as A,r as j,t as fe}from"./Table-XjSmrOyn.js";import{t as M}from"./Switch-WWPXnSOG.js";import{Goals as N,t as pe}from"./Goals-CZnHu9qC.js";import{i as P,n as F,r as me,t as I}from"./Tabs-CSbcG_5T.js";var L=e(d(),1),R=p(),z=[{label:`All`,value:`all`},{label:`Running`,value:`running`},{label:`Pending`,value:`pending`},{label:`Completed`,value:`completed`},{label:`Failed`,value:`failed`},{label:`Cancelled`,value:`cancelled`},{label:`Blocked`,value:`blocked`}],B=new Set([`pending`,`queued`,`running`,`paused`]);function he(){let e=y(e=>e.tasks),t=y(e=>e.fetchTasks),[n,o]=(0,L.useState)(`all`),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(``),[p,h]=(0,L.useState)(!1),[_,v]=(0,L.useState)(new Set),[te,ne]=(0,L.useState)(!1),re=le();(0,L.useEffect)(()=>{let e=n===`all`?void 0:n;t(e);let r=setInterval(()=>void t(e),5e3);return()=>clearInterval(r)},[t,n]),(0,L.useEffect)(()=>{v(new Set)},[n]);let x=async()=>{if(u.trim()){h(!0);try{await g(`/tasks`,{method:`POST`,body:JSON.stringify({prompt:u.trim()})}),d(``),l(!1),t(n===`all`?void 0:n)}finally{h(!1)}}},S=e=>{v(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},C=()=>{let e=E.filter(e=>B.has(e.status)).map(e=>e.id);v(new Set(e))},ie=async()=>{if(_.size!==0){ne(!0);try{await g(`/tasks/batch-cancel`,{method:`POST`,body:JSON.stringify({taskIds:Array.from(_)})}),v(new Set),t(n===`all`?void 0:n)}finally{ne(!1)}}},E=[...e].sort((e,t)=>t.createdAt-e.createdAt),M=Array.from(_).filter(t=>{let n=e.find(e=>e.id===t);return n&&B.has(n.status)});return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsx)(ae,{title:`Tasks`,description:`Review active execution, cancel work, or create the next task.`,compact:!0,action:(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[_.size>0&&(0,R.jsxs)(m,{variant:`destructive`,size:`sm`,onClick:()=>void ie(),disabled:te||M.length===0,children:[(0,R.jsx)(ee,{size:O.sm}),te?`Cancelling...`:`Cancel ${M.length} task${M.length===1?``:`s`}`]}),(0,R.jsx)(m,{variant:`ghost`,size:`sm`,onClick:()=>void t(n===`all`?void 0:n),children:(0,R.jsx)(i,{size:O.sm})}),(0,R.jsxs)(m,{size:`sm`,onClick:()=>l(!c),children:[(0,R.jsx)(a,{size:O.sm}),`New Task`]})]})}),c&&(0,R.jsxs)(T,{className:`flex gap-2`,children:[(0,R.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Enter task prompt...`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&x()}}),(0,R.jsx)(m,{onClick:()=>void x(),disabled:p||!u.trim(),children:p?`Creating...`:`Create`}),(0,R.jsx)(m,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center md:justify-between`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:z.map(e=>(0,R.jsx)(`button`,{onClick:()=>o(e.value),className:`rounded-md px-2.5 py-1 text-xs font-medium transition-colors ${n===e.value?`bg-[var(--app-panel-elevated)] text-[var(--app-text)]`:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:e.label},e.value))}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[E.some(e=>B.has(e.status))&&(0,R.jsx)(`button`,{onClick:C,className:`text-xs text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,children:`Select all cancellable`}),_.size>0&&(0,R.jsxs)(`button`,{onClick:()=>v(new Set),className:`text-xs text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,children:[`Clear selection (`,_.size,`)`]})]})]}),E.length===0?(0,R.jsx)(T,{padding:!1,children:(0,R.jsx)(ce,{icon:(0,R.jsx)(r,{size:32}),title:`No tasks found`,description:n===`all`?`Create a task to get started`:`No tasks with status "${n}"`})}):re?(0,R.jsx)(`div`,{className:`space-y-3`,children:E.map(e=>(0,R.jsx)(T,{className:_.has(e.id)?`border-[var(--app-accent)]/40 bg-[var(--app-accent)]/8`:``,children:(0,R.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,R.jsx)(`div`,{className:`pt-1`,children:B.has(e.status)?(0,R.jsx)(`button`,{onClick:()=>S(e.id),className:`flex h-4 w-4 items-center justify-center rounded border transition-colors ${_.has(e.id)?`border-[var(--app-accent-strong)] bg-[var(--app-accent)] text-white`:`border-[var(--app-border-strong)] bg-transparent hover:border-[var(--app-text-muted)]`}`,children:_.has(e.id)&&(0,R.jsx)(s,{size:12})}):(0,R.jsx)(`span`,{className:`inline-block h-4 w-4`})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,R.jsx)(f,{to:`/tasks/${e.id}`,className:`break-all font-mono text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.id.slice(0,8)}),(0,R.jsx)(`p`,{className:`break-words text-sm font-medium leading-6 text-[var(--app-text)]`,children:D(e.prompt,140)})]}),(0,R.jsx)(w,{variant:b(e.status),children:e.status})]}),(0,R.jsxs)(`div`,{className:`grid gap-2 text-xs text-[var(--app-text-subtle)] sm:grid-cols-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Role`}),(0,R.jsx)(`div`,{className:`mt-1 font-mono text-[var(--app-text)]`,children:e.roleId?e.roleId.slice(0,12):`—`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Cost`}),(0,R.jsx)(`div`,{className:`mt-1 font-mono text-[var(--app-text)]`,children:e.costUsd==null?`—`:se(e.costUsd)})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Created`}),(0,R.jsx)(`div`,{className:`mt-1 text-[var(--app-text)]`,children:oe(e.createdAt)})]})]})]})]})},e.id))}):(0,R.jsx)(T,{padding:!1,children:(0,R.jsxs)(fe,{children:[(0,R.jsx)(ue,{children:(0,R.jsxs)(A,{children:[(0,R.jsx)(k,{className:`w-8`,children:(0,R.jsx)(`button`,{onClick:()=>{_.size>0&&_.size===E.filter(e=>B.has(e.status)).length?v(new Set):C()},className:`flex h-4 w-4 items-center justify-center rounded border transition-colors ${_.size>0&&_.size===E.filter(e=>B.has(e.status)).length?`border-[var(--app-accent-strong)] bg-[var(--app-accent)] text-white`:`border-[var(--app-border-strong)] bg-transparent hover:border-[var(--app-text-muted)]`}`,children:_.size>0&&_.size===E.filter(e=>B.has(e.status)).length&&(0,R.jsx)(s,{size:12})})}),(0,R.jsx)(k,{children:`ID`}),(0,R.jsx)(k,{children:`Prompt`}),(0,R.jsx)(k,{children:`Status`}),(0,R.jsx)(k,{children:`Role`}),(0,R.jsx)(k,{children:`Cost`}),(0,R.jsx)(k,{children:`Created`})]})}),(0,R.jsx)(de,{children:E.map(e=>(0,R.jsxs)(A,{className:_.has(e.id)?`bg-[var(--app-panel-elevated)]/50`:``,children:[(0,R.jsx)(j,{children:B.has(e.status)?(0,R.jsx)(`button`,{onClick:()=>S(e.id),className:`flex h-4 w-4 items-center justify-center rounded border transition-colors ${_.has(e.id)?`border-[var(--app-accent-strong)] bg-[var(--app-accent)] text-white`:`border-[var(--app-border-strong)] bg-transparent hover:border-[var(--app-text-muted)]`}`,children:_.has(e.id)&&(0,R.jsx)(s,{size:12})}):(0,R.jsx)(`span`,{className:`inline-block w-4`})}),(0,R.jsx)(j,{children:(0,R.jsx)(f,{to:`/tasks/${e.id}`,className:`font-mono text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.id.slice(0,8)})}),(0,R.jsx)(j,{children:(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`div`,{className:`break-words font-medium text-[var(--app-text)]`,children:D(e.prompt,120)}),(0,R.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[e.totalDurationMs?se(e.costUsd??0):`Awaiting completion`,` · `,oe(e.createdAt)]})]})}),(0,R.jsx)(j,{children:(0,R.jsx)(w,{variant:b(e.status),children:e.status})}),(0,R.jsx)(j,{children:(0,R.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:e.roleId?e.roleId.slice(0,12):`—`})}),(0,R.jsx)(j,{className:`font-mono text-xs`,children:e.costUsd==null?`—`:se(e.costUsd)}),(0,R.jsx)(j,{className:`text-xs text-[var(--app-text-subtle)]`,children:oe(e.createdAt)})]},e.id))})]})})]})}function V(e,t){return e.find(e=>e.contractField===t)?.message??null}function H({label:e,status:t,tooltip:n}){let[r,i]=(0,L.useState)(!1),a=t===`pass`?`text-[var(--app-success-soft-text)]`:t===`fail`?`text-[var(--app-danger-soft-text)]`:`text-[var(--app-text-subtle)]`,o=t===`pass`?`✓`:t===`fail`?`✗`:`—`;return(0,R.jsxs)(`span`,{className:`relative inline-flex items-center gap-0.5`,children:[(0,R.jsxs)(`span`,{className:`cursor-default text-xs font-medium ${a}`,onClick:()=>i(e=>!e),title:n??void 0,children:[e,`:`,o]}),r&&n&&(0,R.jsx)(`span`,{className:`absolute bottom-full left-0 z-50 mb-1 w-48 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] shadow-md`,children:n})]})}function ge({contract:e,retried:t}){let{violations:n,layerCPassed:r}=e,i=V(n,`lengthTarget`),a=V(n,`persona.speakAs`),o=V(n,`mustReferenceArtifacts`),s=V(n,`customAssertions`);return(0,R.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,R.jsx)(H,{label:`长度`,status:i?`fail`:`pass`,tooltip:i}),(0,R.jsx)(H,{label:`身份`,status:a?`fail`:`pass`,tooltip:a}),(0,R.jsx)(H,{label:`上游引用`,status:o?`fail`:`pass`,tooltip:o}),(0,R.jsx)(H,{label:`自定义`,status:r===null?`na`:r?`pass`:`fail`,tooltip:s}),t&&(0,R.jsx)(`span`,{className:`ml-1 rounded-full bg-[var(--app-warning-soft-bg)] px-1.5 py-0.5 text-[10px] font-medium text-[var(--app-warning-soft-text)]`,children:`重试 #1`})]})}function U(e){return`step-${e+1}`}function W(e,t,n){if(!(e===`concat-step-results`||!e)&&e===`primary-artifact`)return t?{mode:`primary-artifact`,primaryArtifact:{stepId:t,...n?{key:n}:{}}}:void 0}function _e(e,t){return{...e??{},...t}}function ve(){let e=y(e=>e.templates),r=y(e=>e.fetchTemplates),s=y(e=>e.goals),ee=y(e=>e.fetchGoals),d=y(e=>e.roles),f=y(e=>e.fetchRoles),[p,h]=(0,L.useState)(!1),[b,E]=(0,L.useState)(``),[D,se]=(0,L.useState)(`manual`),[O,le]=(0,L.useState)(``),[N,P]=(0,L.useState)(``),[F,me]=(0,L.useState)(``),[I,z]=(0,L.useState)([{id:`step-1`,prompt:``}]),[B,he]=(0,L.useState)(!1),[V,H]=(0,L.useState)(!1),[ve,ye]=(0,L.useState)(null),[G,be]=(0,L.useState)(null),[xe,Se]=(0,L.useState)(null),[K,q]=(0,L.useState)(null),[Ce,J]=(0,L.useState)(`template_only`),[we,Te]=(0,L.useState)(!1),[Y,Ee]=(0,L.useState)(null),[De,Oe]=(0,L.useState)(``),[X,ke]=(0,L.useState)(`manual`),[Ae,je]=(0,L.useState)(``),[Me,Ne]=(0,L.useState)(``),[Pe,Fe]=(0,L.useState)(``),[Ie,Le]=(0,L.useState)(``),[Re,ze]=(0,L.useState)(``),[Be,Ve]=(0,L.useState)([]),[Z,Q]=(0,L.useState)([]),[He,Ue]=(0,L.useState)(!1),[We,Ge]=(0,L.useState)(!1),[$,Ke]=(0,L.useState)([]),[qe,Je]=(0,L.useState)([]),[Ye,Xe]=(0,L.useState)([]),[Ze,Qe]=(0,L.useState)(`concat-step-results`),[$e,et]=(0,L.useState)(``),[tt,nt]=(0,L.useState)(``),[rt,it]=(0,L.useState)(``),[at,ot]=(0,L.useState)(`concat-step-results`),[st,ct]=(0,L.useState)(``),[lt,ut]=(0,L.useState)(``),[dt,ft]=(0,L.useState)(``),[pt,mt]=(0,L.useState)(null),[ht,gt]=(0,L.useState)([]),[_t,vt]=(0,L.useState)(!1),yt=(0,L.useCallback)(async e=>{vt(!0);try{let t=await g(`/template-executions?templateId=${e}&limit=5`);gt(await Promise.all(t.executions.map(async e=>{try{let t=await g(`/template-executions/${e.id}`);return{...t.execution,stepTasks:t.stepTasks}}catch{return{...e,stepTasks:[]}}})))}catch{gt([])}finally{vt(!1)}},[]),bt=(0,L.useCallback)(e=>{pt===e?(mt(null),gt([])):(mt(e),yt(e))},[pt,yt]),xt=(0,L.useMemo)(()=>Object.fromEntries(e.map(e=>[e.id,e.name])),[e]),St=e=>e.type===`cron`?`Cron: ${e.cron??`—`}`:e.type===`once`?`Once at ${e.runAt?new Date(e.runAt).toLocaleString():`—`}`:e.type===`template_complete`?`When template '${xt[e.event?.split(`:`)[1]??``]??`[deleted template]`}' completes`:e.type===`event`?`On event '${Be.find(t=>t.id===e.eventDefId)?.name??`[deleted event]`}'`:e.type;(0,L.useEffect)(()=>{r(),ee(),f(),(async()=>{try{Ve(await g(`/event-defs`))}catch{}})()},[r,ee,f]);let Ct=async()=>{if(b.trim()&&!I.every(e=>!e.prompt.trim())){H(!0);try{let e={name:b.trim(),trigger:{type:D,...D===`cron`&&N?{cron:N}:{},...D===`once`&&F?{runAt:new Date(F).toISOString()}:{},...D===`template_complete`&&O?{event:`template_complete:${O}`}:{},...D===`event`&&Ie?{eventDefId:Ie}:{}},enabled:!0,...qe.length>0?{deliverTo:qe}:{},...(()=>{let e=_e(void 0,{...B?{continueOnError:!0}:{},...W(Ze,$e,tt)?{delivery:W(Ze,$e,tt)}:{}});return Object.keys(e).length>0?{config:e}:{}})()};e.steps=I.filter(e=>e.prompt.trim()).map((e,t)=>({id:e.id||U(t),prompt:e.prompt.trim(),...e.roleId?{roleId:e.roleId}:{},...e.dependsOn&&e.dependsOn.length>0?{dependsOn:e.dependsOn}:{},...e.config&&(e.config.timeout!==void 0||e.config.maxTurns!==void 0)?{config:e.config}:{},...e.consumesFrom?.length?{consumesFrom:e.consumesFrom}:{},...e.consumesFromOptional?.length?{consumesFromOptional:e.consumesFromOptional}:{},...e.persona?{persona:e.persona}:{},...e.outputContract?{outputContract:e.outputContract}:{}})),$.length>0&&(e.goalIds=$),await g(`/task-templates`,{method:`POST`,body:JSON.stringify(e)}),E(``),z([{id:`step-1`,prompt:``}]),P(``),me(``),le(``),Le(``),Ke([]),Je([]),Qe(`concat-step-results`),et(``),nt(``),it(``),h(!1),r()}finally{H(!1)}}},wt=async t=>{let n=e.find(e=>e.id===t);ye(t);try{await g(`/task-templates/${t}/run`,{method:`POST`}),x.success(`Triggered: ${n?.name??t}`)}catch(e){let t=e instanceof Error?e.message:`Failed to trigger template`;x.error(`Trigger failed: ${t}`)}finally{ye(null)}},Tt=async e=>{Se(e),J(`template_only`),q(null);try{q((await g(`/task-templates/${e}/dependents`)).dependents)}catch{q({executionCount:0,taskCount:0})}},Et=async(t,n)=>{let i=e.find(e=>e.id===t);Te(!0);try{let e=await g(`/task-templates/${t}?mode=${n}`,{method:`DELETE`}),a=[];e.deletedCounts.templateExecutions>0&&a.push(`${e.deletedCounts.templateExecutions} template execution${e.deletedCounts.templateExecutions===1?``:`s`}`),e.deletedCounts.tasks>0&&a.push(`${e.deletedCounts.tasks} task${e.deletedCounts.tasks===1?``:`s`}`);let o=a.length?` (+ ${a.join(`, `)})`:``;x.success(`Deleted: ${i?.name??t}${o}`),r()}catch(e){let t=e instanceof Error?e.message:`Failed to delete template`;x.error(`Delete failed: ${t}`)}finally{Te(!1)}},Dt=async t=>{let n=e.find(e=>e.id===t);if(!n)return;if(![`cron`,`once`,`template_complete`].includes(n.trigger.type)){x.error(`Toggle not applicable for manual triggers`);return}let i=!n.enabled;try{await g(`/task-templates/${t}`,{method:`PATCH`,body:JSON.stringify({enabled:i})}),x.success(`${n.name} ${i?`enabled`:`disabled`}`),r()}catch(e){let t=e instanceof Error?e.message:`Failed to toggle template`;x.error(`Toggle failed: ${t}`)}},Ot=e=>{Ee(e.id),Oe(e.name),ke(e.trigger.type),je(e.trigger.cron??``),Ne(e.trigger.runAt?new Date(e.trigger.runAt).toISOString().slice(0,16):``),Q(e.steps.map(e=>({id:e.id,prompt:e.prompt,roleId:e.roleId,dependsOn:e.dependsOn,config:e.config,consumesFrom:e.consumesFrom,consumesFromOptional:e.consumesFromOptional,persona:e.persona,outputContract:e.outputContract,outputAs:e.outputAs}))),Ue(e.config?.continueOnError??!1),ot(e.config?.delivery?.mode??`concat-step-results`),ct(e.config?.delivery?.primaryArtifact?.stepId??``),ut(e.config?.delivery?.primaryArtifact?.key??``),ft(e.config?.delivery?.primaryArtifact?.stepId?e.steps.find(t=>t.id===e.config?.delivery?.primaryArtifact?.stepId)?.outputAs??``:``),Xe(e.deliverTo??[]),Fe(e.trigger.type===`template_complete`?e.trigger.event?.split(`:`)[1]??``:``),ze(e.trigger.eventDefId??``)},kt=async()=>{if(!(!Y||!De.trim()||Z.every(e=>!e.prompt.trim()))){Ge(!0);try{await g(`/task-templates/${Y}`,{method:`PATCH`,body:JSON.stringify({name:De.trim(),trigger:{type:X,...X===`cron`&&Ae?{cron:Ae}:{},...X===`once`&&Me?{runAt:new Date(Me).toISOString()}:{},...X===`template_complete`&&Pe?{event:`template_complete:${Pe}`}:{},...X===`event`&&Re?{eventDefId:Re}:{}},steps:Z.filter(e=>e.prompt.trim()).map((e,t)=>({id:e.id||U(t),prompt:e.prompt.trim(),...e.roleId?{roleId:e.roleId}:{},...e.dependsOn&&e.dependsOn.length>0?{dependsOn:e.dependsOn}:{},...e.config&&(e.config.timeout!==void 0||e.config.maxTurns!==void 0)?{config:e.config}:{},...e.consumesFrom?.length?{consumesFrom:e.consumesFrom}:{},...e.consumesFromOptional?.length?{consumesFromOptional:e.consumesFromOptional}:{},...e.persona?{persona:e.persona}:{},...e.outputContract?{outputContract:e.outputContract}:{}})),enabled:e.find(e=>e.id===Y)?.enabled??!0,...(()=>{let t=e.find(e=>e.id===Y)?.config;return{config:_e(t,{...He?{continueOnError:!0}:{continueOnError:!1},...W(at,st,lt)?{delivery:W(at,st,lt)}:{delivery:void 0}})}})(),deliverTo:Ye.length>0?Ye:void 0})}),Ee(null),r(),x.success(`Template updated`)}catch(e){let t=e instanceof Error?e.message:`Failed to update template`;x.error(t)}finally{Ge(!1)}}},At=e.find(e=>e.id===G),jt=e.find(e=>e.id===xe);return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsx)(ae,{title:`Automations`,description:`Reusable templates, manual triggers, and recent template executions.`,compact:!0,action:(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(m,{variant:`ghost`,size:`sm`,onClick:()=>void r(),children:(0,R.jsx)(i,{size:14})}),(0,R.jsxs)(m,{size:`sm`,onClick:()=>h(!p),children:[(0,R.jsx)(a,{size:14}),`New Automation`]})]})}),p&&(0,R.jsxs)(T,{className:`space-y-3`,children:[(0,R.jsx)(`input`,{className:`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)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Template name`,value:b,onChange:e=>E(e.target.value)}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Triggered by:`}),(0,R.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:D,onChange:e=>se(e.target.value),children:[(0,R.jsx)(`option`,{value:`manual`,children:`Manual`}),(0,R.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,R.jsx)(`option`,{value:`once`,children:`One-time`}),(0,R.jsx)(`option`,{value:`template_complete`,children:`Template completion`}),(0,R.jsx)(`option`,{value:`event`,children:`Event (definition)`})]}),D===`template_complete`&&(0,R.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:O,onChange:e=>le(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`-- Select target template --`}),e.filter(e=>e.id!==Y).map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),D===`event`&&(0,R.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:Ie,onChange:e=>Le(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`-- Select event --`}),Be.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),D===`cron`&&(0,R.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Cron expression (e.g. */5 * * * *)`,value:N,onChange:e=>P(e.target.value)}),D===`once`&&(0,R.jsx)(`input`,{type:`datetime-local`,className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:F,onChange:e=>me(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Steps`}),(0,R.jsxs)(m,{variant:`ghost`,size:`sm`,onClick:()=>z([...I,{id:U(I.length),prompt:``}]),children:[(0,R.jsx)(a,{size:12}),` Add Step`]})]}),I.map((e,t)=>(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] p-2 space-y-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--app-text-subtle)]`,children:e.id}),(0,R.jsxs)(`select`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)]`,value:e.roleId??``,onChange:n=>{let r=[...I];r[t]={...e,roleId:n.target.value||void 0},z(r)},children:[(0,R.jsx)(`option`,{value:``,children:`Role (template default)`}),d.filter(e=>e.source!==`system`).map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),I.length>1&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>z(I.filter((e,n)=>n!==t)),className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,R.jsx)(l,{size:12})})]}),(0,R.jsx)(`textarea`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Step ${t+1} prompt${t>0?` (use {{`+I[t-1].id+`.result}} for prev output)`:``}`,rows:2,value:e.prompt,onChange:n=>{let r=[...I];r[t]={...e,prompt:n.target.value},z(r)}}),t>0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`depends on:`}),I.slice(0,t).map(n=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let r=e.dependsOn??[],i=[...I];i[t]={...e,dependsOn:r.includes(n.id)?r.filter(e=>e!==n.id):[...r,n.id]},z(i)},className:`rounded px-1.5 py-0.5 text-[10px] ${(e.dependsOn??[]).includes(n.id)?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n.id},n.id))]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`timeout(s):`,(0,R.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.timeout??``,onChange:n=>{let r=[...I],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,timeout:i}},z(r)}})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`max turns:`,(0,R.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.maxTurns??``,onChange:n=>{let r=[...I],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,maxTurns:i}},z(r)}})]})]}),t>0&&(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-1 items-center`,children:[(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)] shrink-0`,children:`Consumes:`}),I.slice(0,t).map(n=>(0,R.jsx)(`button`,{type:`button`,"aria-label":`consumes ${n.id}`,onClick:()=>{let r=e.consumesFrom??[],i=[...I];i[t]={...e,consumesFrom:r.includes(n.id)?r.filter(e=>e!==n.id):[...r,n.id]},z(i)},className:`rounded px-1.5 py-0.5 text-[10px] ${(e.consumesFrom??[]).includes(n.id)?`bg-[var(--app-danger)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n.id},n.id)),(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)] shrink-0 ml-1`,children:`(opt)`}),I.slice(0,t).map(n=>(0,R.jsxs)(`button`,{type:`button`,"aria-label":`optional-consumes ${n.id}`,onClick:()=>{let r=e.consumesFromOptional??[],i=[...I];i[t]={...e,consumesFromOptional:r.includes(n.id)?r.filter(e=>e!==n.id):[...r,n.id]},z(i)},className:`rounded px-1.5 py-0.5 text-[10px] ${(e.consumesFromOptional??[]).includes(n.id)?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:[n.id,`?`]},`${n.id}-opt`))]}),(0,R.jsxs)(`div`,{className:`flex gap-1 items-center`,children:[(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)] shrink-0`,children:`Speak as:`}),(0,R.jsx)(`input`,{type:`text`,placeholder:`e.g. 卞旸`,className:`flex-1 min-w-0 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)]`,value:e.persona?.speakAs??``,onChange:n=>{let r=[...I];r[t]={...e,persona:n.target.value?{speakAs:n.target.value,voiceConstraints:e.persona?.voiceConstraints}:void 0},z(r)}}),(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)] shrink-0`,children:`Voice:`}),(0,R.jsx)(`input`,{type:`text`,placeholder:`optional`,className:`flex-1 min-w-0 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)]`,value:e.persona?.voiceConstraints??``,onChange:n=>{let r=[...I];r[t]={...e,persona:e.persona?.speakAs?{speakAs:e.persona.speakAs,voiceConstraints:n.target.value||void 0}:void 0},z(r)}})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-1 items-center`,children:[(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)] shrink-0`,children:`Contract:`}),(0,R.jsx)(`input`,{type:`number`,min:0,placeholder:`min`,className:`w-16 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.outputContract?.lengthTarget?.min??``,onChange:n=>{let r=[...I],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,outputContract:{...e.outputContract,lengthTarget:{min:i??0,max:e.outputContract?.lengthTarget?.max??0,unit:e.outputContract?.lengthTarget?.unit??`characters`}}},z(r)}}),(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`—`}),(0,R.jsx)(`input`,{type:`number`,min:0,placeholder:`max`,className:`w-16 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.outputContract?.lengthTarget?.max??``,onChange:n=>{let r=[...I],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,outputContract:{...e.outputContract,lengthTarget:{min:e.outputContract?.lengthTarget?.min??0,max:i??0,unit:e.outputContract?.lengthTarget?.unit??`characters`}}},z(r)}}),(0,R.jsxs)(`select`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.outputContract?.lengthTarget?.unit??`characters`,onChange:n=>{let r=[...I];r[t]={...e,outputContract:{...e.outputContract,lengthTarget:{min:e.outputContract?.lengthTarget?.min??0,max:e.outputContract?.lengthTarget?.max??0,unit:n.target.value}}},z(r)},children:[(0,R.jsx)(`option`,{value:`characters`,children:`chars`}),(0,R.jsx)(`option`,{value:`words`,children:`words`}),(0,R.jsx)(`option`,{value:`bytes`,children:`bytes`})]}),(0,R.jsxs)(`select`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.outputContract?.format??``,onChange:n=>{let r=[...I],i=n.target.value;r[t]={...e,outputContract:{...e.outputContract,format:i||void 0}},z(r)},children:[(0,R.jsx)(`option`,{value:``,children:`fmt?`}),(0,R.jsx)(`option`,{value:`markdown`,children:`md`}),(0,R.jsx)(`option`,{value:`text`,children:`txt`}),(0,R.jsx)(`option`,{value:`json`,children:`json`})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-0.5 text-[10px] text-[var(--app-text-subtle)] cursor-pointer`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--app-accent)]`,checked:e.outputContract?.mustReferenceArtifacts??!1,onChange:n=>{let r=[...I];r[t]={...e,outputContract:{...e.outputContract,mustReferenceArtifacts:n.target.checked}},z(r)}}),`ref artifacts`]})]})]},e.id))]}),(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Goals`}),s.length===0?(0,R.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No goals available`}):s.map(e=>(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] hover:text-[var(--app-text)] cursor-pointer`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:$.includes(e.id),onChange:t=>{t.target.checked?Ke([...$,e.id]):Ke($.filter(t=>t!==e.id))},className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-elevated)]`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name}),(0,R.jsx)(w,{variant:`muted`,className:`text-[10px]`,children:e.status})]},e.id))]}),I.length>1&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] cursor-pointer`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:B,onChange:e=>he(e.target.checked),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-elevated)]`}),`Continue on error (skip failed step dependents, run independent steps)`]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`label`,{className:`text-xs font-medium text-[var(--app-text)]`,children:`投递格式`}),(0,R.jsxs)(`select`,{value:Ze,onChange:e=>Qe(e.target.value),className:`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)] focus:border-[var(--app-accent)] focus:outline-none`,children:[(0,R.jsx)(`option`,{value:`concat-step-results`,children:`拼接每步结果(默认)`}),(0,R.jsx)(`option`,{value:`primary-artifact`,children:`指定主产物`}),(0,R.jsx)(`option`,{value:`custom`,disabled:!0,children:`自定义(即将推出)`})]}),Ze===`primary-artifact`&&(0,R.jsxs)(`div`,{className:`space-y-2 rounded border border-[var(--app-border)] p-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:`来源 step`}),(0,R.jsxs)(`select`,{value:$e,onChange:e=>{let t=I.find(t=>t.id===e.target.value);et(e.target.value),it(t?.outputAs??``)},className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,children:[(0,R.jsx)(`option`,{value:``,children:`选择 step...`}),I.filter(e=>e.prompt.trim()).map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.id},e.id))]})]}),rt&&(0,R.jsxs)(`div`,{className:`text-xs text-[var(--app-accent)]`,children:[`Will use step's output: `,(0,R.jsx)(`span`,{className:`font-mono`,children:rt})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:rt?`Or specify custom key:`:`artifact key`}),(0,R.jsx)(`input`,{type:`text`,value:tt,onChange:e=>nt(e.target.value),placeholder:rt?`留空使用上面的自动解析值`:`手动输入 key`,className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-muted)] focus:border-[var(--app-accent)] focus:outline-none`})]})]})]}),(0,R.jsx)(pe,{value:qe,onChange:Je}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(m,{onClick:()=>void Ct(),disabled:V||!b.trim()||I.every(e=>!e.prompt.trim())||D===`template_complete`&&!O,children:V?`Creating...`:`Create`}),(0,R.jsx)(m,{variant:`ghost`,onClick:()=>h(!1),children:`Cancel`})]})]}),Y!==null&&(0,R.jsxs)(T,{className:`space-y-3`,children:[(0,R.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Edit Automation`}),(0,R.jsx)(`input`,{className:`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)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Template name`,value:De,onChange:e=>Oe(e.target.value)}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Triggered by:`}),(0,R.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:X,onChange:e=>ke(e.target.value),children:[(0,R.jsx)(`option`,{value:`manual`,children:`Manual`}),(0,R.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,R.jsx)(`option`,{value:`once`,children:`One-time`}),(0,R.jsx)(`option`,{value:`template_complete`,children:`Template completion`}),(0,R.jsx)(`option`,{value:`event`,children:`Event (definition)`})]}),X===`template_complete`&&(0,R.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:Pe,onChange:e=>Fe(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`-- Select target template --`}),e.filter(e=>e.id!==Y).map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),X===`event`&&(0,R.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:Re,onChange:e=>ze(e.target.value),children:[(0,R.jsx)(`option`,{value:``,children:`-- Select event --`}),Be.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),X===`cron`&&(0,R.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Cron expression`,value:Ae,onChange:e=>je(e.target.value)}),X===`once`&&(0,R.jsx)(`input`,{type:`datetime-local`,className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:Me,onChange:e=>Ne(e.target.value)})]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Steps`}),(0,R.jsxs)(m,{variant:`ghost`,size:`sm`,onClick:()=>Q([...Z,{id:U(Z.length),prompt:``}]),children:[(0,R.jsx)(a,{size:12}),` Add Step`]})]}),Z.map((e,t)=>(0,R.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] p-2 space-y-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--app-text-subtle)]`,children:e.id}),(0,R.jsxs)(`select`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)]`,value:e.roleId??``,onChange:n=>{let r=[...Z];r[t]={...e,roleId:n.target.value||void 0},Q(r)},children:[(0,R.jsx)(`option`,{value:``,children:`Role (template default)`}),d.filter(e=>e.source!==`system`).map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),Z.length>1&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>Q(Z.filter((e,n)=>n!==t)),className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,R.jsx)(l,{size:12})})]}),(0,R.jsx)(`textarea`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Step ${t+1} prompt`,rows:2,value:e.prompt,onChange:n=>{let r=[...Z];r[t]={...e,prompt:n.target.value},Q(r)}}),t>0&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`depends on:`}),Z.slice(0,t).map(n=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let r=e.dependsOn??[],i=[...Z];i[t]={...e,dependsOn:r.includes(n.id)?r.filter(e=>e!==n.id):[...r,n.id]},Q(i)},className:`rounded px-1.5 py-0.5 text-[10px] ${(e.dependsOn??[]).includes(n.id)?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n.id},n.id))]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`timeout(s):`,(0,R.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.timeout??``,onChange:n=>{let r=[...Z],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,timeout:i}},Q(r)}})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`max turns:`,(0,R.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.maxTurns??``,onChange:n=>{let r=[...Z],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,maxTurns:i}},Q(r)}})]})]}),t>0&&(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-1 items-center`,children:[(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)] shrink-0`,children:`Consumes:`}),Z.slice(0,t).map(n=>(0,R.jsx)(`button`,{type:`button`,"aria-label":`consumes ${n.id}`,onClick:()=>{let r=e.consumesFrom??[],i=[...Z];i[t]={...e,consumesFrom:r.includes(n.id)?r.filter(e=>e!==n.id):[...r,n.id]},Q(i)},className:`rounded px-1.5 py-0.5 text-[10px] ${(e.consumesFrom??[]).includes(n.id)?`bg-[var(--app-danger)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n.id},n.id)),(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)] shrink-0 ml-1`,children:`(opt)`}),Z.slice(0,t).map(n=>(0,R.jsxs)(`button`,{type:`button`,"aria-label":`optional-consumes ${n.id}`,onClick:()=>{let r=e.consumesFromOptional??[],i=[...Z];i[t]={...e,consumesFromOptional:r.includes(n.id)?r.filter(e=>e!==n.id):[...r,n.id]},Q(i)},className:`rounded px-1.5 py-0.5 text-[10px] ${(e.consumesFromOptional??[]).includes(n.id)?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:[n.id,`?`]},`${n.id}-opt`))]}),(0,R.jsxs)(`div`,{className:`flex gap-1 items-center`,children:[(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)] shrink-0`,children:`Speak as:`}),(0,R.jsx)(`input`,{type:`text`,placeholder:`e.g. 卞旸`,className:`flex-1 min-w-0 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)]`,value:e.persona?.speakAs??``,onChange:n=>{let r=[...Z];r[t]={...e,persona:n.target.value?{speakAs:n.target.value,voiceConstraints:e.persona?.voiceConstraints}:void 0},Q(r)}}),(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)] shrink-0`,children:`Voice:`}),(0,R.jsx)(`input`,{type:`text`,placeholder:`optional`,className:`flex-1 min-w-0 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)]`,value:e.persona?.voiceConstraints??``,onChange:n=>{let r=[...Z];r[t]={...e,persona:e.persona?.speakAs?{speakAs:e.persona.speakAs,voiceConstraints:n.target.value||void 0}:void 0},Q(r)}})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-1 items-center`,children:[(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)] shrink-0`,children:`Contract:`}),(0,R.jsx)(`input`,{type:`number`,min:0,placeholder:`min`,className:`w-16 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.outputContract?.lengthTarget?.min??``,onChange:n=>{let r=[...Z],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,outputContract:{...e.outputContract,lengthTarget:{min:i??0,max:e.outputContract?.lengthTarget?.max??0,unit:e.outputContract?.lengthTarget?.unit??`characters`}}},Q(r)}}),(0,R.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`—`}),(0,R.jsx)(`input`,{type:`number`,min:0,placeholder:`max`,className:`w-16 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.outputContract?.lengthTarget?.max??``,onChange:n=>{let r=[...Z],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,outputContract:{...e.outputContract,lengthTarget:{min:e.outputContract?.lengthTarget?.min??0,max:i??0,unit:e.outputContract?.lengthTarget?.unit??`characters`}}},Q(r)}}),(0,R.jsxs)(`select`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.outputContract?.lengthTarget?.unit??`characters`,onChange:n=>{let r=[...Z];r[t]={...e,outputContract:{...e.outputContract,lengthTarget:{min:e.outputContract?.lengthTarget?.min??0,max:e.outputContract?.lengthTarget?.max??0,unit:n.target.value}}},Q(r)},children:[(0,R.jsx)(`option`,{value:`characters`,children:`chars`}),(0,R.jsx)(`option`,{value:`words`,children:`words`}),(0,R.jsx)(`option`,{value:`bytes`,children:`bytes`})]}),(0,R.jsxs)(`select`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.outputContract?.format??``,onChange:n=>{let r=[...Z],i=n.target.value;r[t]={...e,outputContract:{...e.outputContract,format:i||void 0}},Q(r)},children:[(0,R.jsx)(`option`,{value:``,children:`fmt?`}),(0,R.jsx)(`option`,{value:`markdown`,children:`md`}),(0,R.jsx)(`option`,{value:`text`,children:`txt`}),(0,R.jsx)(`option`,{value:`json`,children:`json`})]}),(0,R.jsxs)(`label`,{className:`flex items-center gap-0.5 text-[10px] text-[var(--app-text-subtle)] cursor-pointer`,children:[(0,R.jsx)(`input`,{type:`checkbox`,className:`accent-[var(--app-accent)]`,checked:e.outputContract?.mustReferenceArtifacts??!1,onChange:n=>{let r=[...Z];r[t]={...e,outputContract:{...e.outputContract,mustReferenceArtifacts:n.target.checked}},Q(r)}}),`ref artifacts`]})]})]},e.id))]}),Z.length>1&&(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] cursor-pointer`,children:[(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`continue on error`,checked:He,onChange:e=>Ue(e.target.checked),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-elevated)]`}),`Continue on error`]}),(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`label`,{className:`text-xs font-medium text-[var(--app-text)]`,children:`投递格式`}),(0,R.jsxs)(`select`,{value:at,onChange:e=>ot(e.target.value),className:`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)] focus:border-[var(--app-accent)] focus:outline-none`,children:[(0,R.jsx)(`option`,{value:`concat-step-results`,children:`拼接每步结果(默认)`}),(0,R.jsx)(`option`,{value:`primary-artifact`,children:`指定主产物`}),(0,R.jsx)(`option`,{value:`custom`,disabled:!0,children:`自定义(即将推出)`})]}),at===`primary-artifact`&&(0,R.jsxs)(`div`,{className:`space-y-2 rounded border border-[var(--app-border)] p-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:`来源 step`}),(0,R.jsxs)(`select`,{value:st,onChange:e=>{let t=Z.find(t=>t.id===e.target.value);ct(e.target.value),ft(t?.outputAs??``)},className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,children:[(0,R.jsx)(`option`,{value:``,children:`选择 step...`}),Z.filter(e=>e.prompt.trim()).map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.id},e.id))]})]}),dt&&(0,R.jsxs)(`div`,{className:`text-xs text-[var(--app-accent)]`,children:[`Will use step's output: `,(0,R.jsx)(`span`,{className:`font-mono`,children:dt})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{className:`text-xs text-[var(--app-text-muted)]`,children:dt?`Or specify custom key:`:`artifact key`}),(0,R.jsx)(`input`,{type:`text`,value:lt,onChange:e=>ut(e.target.value),placeholder:dt?`留空使用上面的自动解析值`:`手动输入 key`,className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-muted)] focus:border-[var(--app-accent)] focus:outline-none`})]})]})]}),(0,R.jsx)(pe,{value:Ye,onChange:Xe}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(m,{onClick:()=>void kt(),disabled:We||!De.trim()||Z.every(e=>!e.prompt.trim()),children:We?`Saving...`:`Save`}),(0,R.jsx)(m,{variant:`ghost`,onClick:()=>Ee(null),children:`Cancel`})]})]}),(0,R.jsx)(T,{padding:!1,children:e.length===0?(0,R.jsx)(ce,{icon:(0,R.jsx)(t,{size:32}),title:`No automations`,description:`Create an automation to run recurring tasks`}):(0,R.jsxs)(fe,{children:[(0,R.jsx)(ue,{children:(0,R.jsxs)(A,{children:[(0,R.jsx)(k,{children:`Name`}),(0,R.jsx)(k,{children:`Trigger`}),(0,R.jsx)(k,{children:`Schedule`}),(0,R.jsx)(k,{children:`Steps`}),(0,R.jsx)(k,{children:`Enabled`}),(0,R.jsx)(k,{children:`Created`}),(0,R.jsx)(k,{children:`Webhook URL`}),(0,R.jsx)(k,{children:`Actions`})]})}),(0,R.jsx)(de,{children:e.map(e=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsxs)(A,{children:[(0,R.jsxs)(j,{className:`font-medium text-[var(--app-text)]`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>bt(e.id),className:`flex items-center gap-1 hover:text-[var(--app-accent)] transition-colors`,children:[pt===e.id?(0,R.jsx)(o,{size:12}):(0,R.jsx)(u,{size:12}),e.name]}),(e.isPreset||e.presetId)&&(0,R.jsx)(w,{variant:`info`,className:`ml-2`,children:`Preset`})]}),(0,R.jsx)(j,{children:(0,R.jsx)(w,{variant:e.trigger.type===`cron`?`info`:(e.trigger.type,`muted`),children:St(e.trigger)})}),(0,R.jsx)(j,{className:`font-mono text-xs`,children:e.trigger.type===`once`&&e.trigger.runAt?new Date(e.trigger.runAt).toLocaleString():e.trigger.cron??`—`}),(0,R.jsx)(j,{className:`font-mono text-xs`,children:(()=>{let t=new Set(e.steps.filter(e=>e.roleId).map(e=>e.roleId)),n=t.size>0?`${e.steps.length} steps / ${t.size} roles`:`${e.steps.length} steps`;return e.goalIds&&e.goalIds.length>0?`${n} / ${e.goalIds.length} goals`:n})()}),(0,R.jsx)(j,{children:[`cron`,`once`,`template_complete`].every(t=>e.trigger.type!==t)?(0,R.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`—`}):(0,R.jsx)(M,{checked:e.enabled,onCheckedChange:()=>void Dt(e.id),"aria-label":`Toggle ${e.name}`})}),(0,R.jsx)(j,{className:`text-xs text-[var(--app-text-subtle)]`,children:e.createdAt?oe(e.createdAt):`—`}),(0,R.jsx)(j,{className:`font-mono text-xs text-[var(--app-text-muted)]`,children:e.enabled?`POST /webhooks/${e.id}`:`—`}),(0,R.jsx)(j,{children:(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(m,{variant:`ghost`,size:`sm`,onClick:()=>Ot(e),title:`Edit`,children:(0,R.jsx)(c,{size:12})}),(0,R.jsx)(m,{variant:`ghost`,size:`sm`,onClick:()=>be(e.id),disabled:ve===e.id,title:`Run now`,children:(0,R.jsx)(n,{size:12})}),(0,R.jsx)(m,{variant:`ghost`,size:`sm`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>{Tt(e.id)},title:`Delete`,children:(0,R.jsx)(l,{size:12})})]})})]}),pt===e.id&&(0,R.jsx)(A,{children:(0,R.jsxs)(j,{colSpan:8,className:`bg-[var(--app-panel)]/50 p-3`,children:[(0,R.jsx)(`div`,{className:`text-xs text-[var(--app-text-muted)] mb-2 font-medium`,children:`Recent Template Executions`}),_t?(0,R.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading...`}):ht.length===0?(0,R.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No template executions yet`}):(0,R.jsx)(`div`,{className:`space-y-1.5`,children:ht.map(t=>{let n=Object.entries(t.stepStatuses),r=n.filter(([,e])=>e.status===`completed`).length,i=n.filter(([,e])=>e.status===`failed`).length,a=n.filter(([,e])=>e.status===`skipped`).length,o=n.filter(([,e])=>e.status===`cancelled`).length,s=n.length,ee=new Map(t.stepTasks.filter(e=>e.stepId).map(e=>[e.stepId,e])),c=[...e.steps.map(e=>e.id),...Object.keys(t.stepStatuses).filter(t=>!e.steps.some(e=>e.id===t))];return(0,R.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-canvas)]/50 p-2.5 space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,R.jsx)(w,{variant:t.status===`completed`?`success`:t.status===`failed`?`destructive`:t.status===`partial`?`warning`:t.status===`cancelled`?`secondary`:`muted`,children:t.status}),(0,R.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:new Date(t.startedAt).toLocaleString()}),s>0&&(0,R.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[r,`/`,s,` steps`,(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[i>0&&(0,R.jsxs)(`span`,{className:`text-[var(--app-danger)]`,children:[i,` failed`]}),a>0&&(0,R.jsxs)(`span`,{className:`text-[var(--app-warning)]`,children:[a,` skipped`]}),o>0&&(0,R.jsxs)(`span`,{className:`text-[var(--app-text)]`,children:[o,` cancelled`]})]})]}),t.completedAt&&(0,R.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[Math.round((t.completedAt-t.startedAt)/1e3),`s`]}),(0,R.jsx)(`span`,{className:`font-mono text-[var(--app-text-subtle)] truncate max-w-[120px]`,children:t.id.slice(0,8)})]}),(0,R.jsx)(`div`,{className:`space-y-1.5`,children:c.map(n=>{let r=t.stepStatuses[n];if(!r)return null;let i=e.steps.find(e=>e.id===n),a=ee.get(n),o=a?.roleId??r.roleId??i?.roleId,s=d.find(e=>e.id===o)?.name??o,c=a?.error??r.error??a?.result??r.result;return(0,R.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] gap-2 rounded bg-[var(--app-panel)]/60 px-2 py-1.5 text-xs`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:n}),s&&(0,R.jsxs)(`span`,{className:`text-[var(--app-warning-soft-text)]`,children:[`@`,s]}),i?.dependsOn&&i.dependsOn.length>0&&(0,R.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`after `,i.dependsOn.join(`, `)]})]}),c&&(0,R.jsx)(`div`,{className:`mt-1 truncate ${r.status===`failed`?`text-[var(--app-danger-soft-text)]`:r.status===`skipped`?`text-[var(--app-warning-soft-text)]`:r.status===`cancelled`?`text-[var(--app-text)]`:`text-[var(--app-text-muted)]`}`,children:c})]}),(0,R.jsx)(w,{variant:r.status===`completed`?`success`:r.status===`failed`?`destructive`:r.status===`skipped`?`warning`:r.status===`cancelled`?`secondary`:`muted`,children:r.status}),r.contract&&(0,R.jsx)(ge,{contract:r.contract,retried:r.contractRetried}),(0,R.jsxs)(`div`,{className:`text-right text-[var(--app-text-subtle)]`,children:[a?.completedAt&&(0,R.jsxs)(`div`,{children:[Math.max(0,Math.round((a.completedAt-a.createdAt)/1e3)),`s`]}),a?.id&&(0,R.jsx)(`div`,{className:`font-mono`,children:a.id.slice(0,8)})]})]},`${t.id}-${n}`)})})]},t.id)})})]})})]},e.id))})]})}),(0,R.jsx)(S,{open:G!==null,onOpenChange:e=>{e||be(null)},children:(0,R.jsxs)(re,{children:[(0,R.jsxs)(ne,{children:[(0,R.jsx)(ie,{children:`Run Template`}),(0,R.jsxs)(C,{children:[`Run “`,At?.name,`” now? This will execute the template immediately.`]})]}),(0,R.jsxs)(v,{children:[(0,R.jsx)(_,{children:`Cancel`}),(0,R.jsx)(te,{onClick:()=>{G&&wt(G),be(null)},children:`Run Now`})]})]})}),(0,R.jsx)(S,{open:xe!==null,onOpenChange:e=>{e||(Se(null),q(null),J(`template_only`))},children:(0,R.jsxs)(re,{children:[(0,R.jsxs)(ne,{children:[(0,R.jsx)(ie,{children:`Delete Template`}),(0,R.jsx)(C,{children:K===null?(0,R.jsx)(R.Fragment,{children:`Loading…`}):K.taskCount===0&&K.executionCount===0?(0,R.jsxs)(R.Fragment,{children:[`Delete “`,jt?.name,`”? This action cannot be undone.`]}):K.taskCount===0?(0,R.jsxs)(R.Fragment,{children:[`“`,jt?.name,`” has `,K.executionCount,` template execution`,K.executionCount===1?``:`s`,` which will be removed. Delete?`]}):(0,R.jsxs)(R.Fragment,{children:[`“`,jt?.name,`” has`,` `,K.executionCount>0&&(0,R.jsxs)(R.Fragment,{children:[K.executionCount,` template execution`,K.executionCount===1?``:`s`]}),K.executionCount>0&&K.taskCount>0&&` and `,K.taskCount,` task`,K.taskCount===1?``:`s`,`. Choose what to delete:`]})})]}),K!==null&&K.taskCount>0&&(0,R.jsxs)(`div`,{className:`space-y-2 px-1`,children:[(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[(0,R.jsx)(`input`,{type:`radio`,name:`deleteMode`,value:`template_only`,checked:Ce===`template_only`,onChange:()=>J(`template_only`),className:`mt-1`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-sm font-medium`,children:`Template only`}),(0,R.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Removes the automation. Tasks remain under the Tasks tab as history.`})]})]}),(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[(0,R.jsx)(`input`,{type:`radio`,name:`deleteMode`,value:`with_tasks`,checked:Ce===`with_tasks`,onChange:()=>J(`with_tasks`),className:`mt-1`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-sm font-medium`,children:`Template and its tasks`}),(0,R.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Also deletes `,K.taskCount,` task`,K.taskCount===1?``:`s`,` and their score history. Cannot be undone.`]})]})]})]}),(0,R.jsxs)(v,{children:[(0,R.jsx)(_,{disabled:we,children:`Cancel`}),(0,R.jsx)(te,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger)]`,disabled:we||K===null,onClick:()=>{xe&&Et(xe,K&&K.taskCount>0?Ce:`template_only`),Se(null),q(null),J(`template_only`)},children:`Delete`})]})]})})]})}function ye(){let{tasks:e,templates:t,goals:n}=y(h(e=>({tasks:e.tasks,templates:e.templates,goals:e.goals}))),r=y(e=>e.fetchTasks),i=y(e=>e.fetchTemplates),a=y(e=>e.fetchGoals);return(0,L.useEffect)(()=>{r(),i(),a()},[r,i,a]),(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsx)(E,{eyebrow:`Operations`,title:`Work`,description:`Tasks, automations, and goals in one place.`,metrics:[{label:`Running`,value:e.filter(e=>e.status===`running`).length},{label:`Automations`,value:t.length},{label:`Goals`,value:n.length}],compact:!0}),(0,R.jsxs)(I,{defaultValue:`tasks`,children:[(0,R.jsxs)(me,{children:[(0,R.jsx)(P,{value:`tasks`,children:`Tasks`}),(0,R.jsx)(P,{value:`automations`,children:`Automations`}),(0,R.jsx)(P,{value:`goals`,children:`Goals`})]}),(0,R.jsx)(F,{value:`tasks`,children:(0,R.jsx)(he,{})}),(0,R.jsx)(F,{value:`automations`,children:(0,R.jsx)(ve,{})}),(0,R.jsx)(F,{value:`goals`,children:(0,R.jsx)(N,{})})]})]})}export{ye as Work};
@@ -1 +0,0 @@
1
- import{n as e}from"./rolldown-runtime-Dw2cE7zH.js";var t=e({AUTH_STORAGE_KEY:()=>r,ApiError:()=>n,api:()=>c,bindRoleExtension:()=>S,clearLegacyMcpServers:()=>b,clearStoredApiKey:()=>o,deleteExtension:()=>v,fetchDeliveryLog:()=>l,getExtension:()=>g,getStoredApiKey:()=>i,listExtensions:()=>h,listLegacyMcpServers:()=>y,listMistakePatterns:()=>f,listRoleExtensions:()=>x,patchRoleExtension:()=>w,redirectToLogin:()=>s,rotateApiKey:()=>d,setStoredApiKey:()=>a,unbindRoleExtension:()=>C,updateMistakePattern:()=>p,updateTaskTemplateConfig:()=>m,uploadExtension:()=>_,verifyApiKey:()=>u}),n=class extends Error{status;code;constructor(e,t,n){super(n),this.name=`ApiError`,this.status=e,this.code=t}},r=`adam_api_key`;function i(){return typeof localStorage<`u`?localStorage.getItem(r):null}function a(e){localStorage.setItem(r,e)}function o(){localStorage.removeItem(r)}function s(){if(typeof window>`u`||window.location.pathname===`/ui/login`)return;let e=encodeURIComponent(window.location.pathname+window.location.search);window.location.href=`/ui/login?returnTo=${e}`}async function c(e,t){let r=i(),a={...t?.headers,...r?{"x-api-key":r}:{}};t?.body&&(a[`Content-Type`]??=`application/json`);let c=await fetch(e,{...t,headers:a});if(!c.ok){let e=`UNKNOWN_ERROR`,t=c.statusText;try{let n=await c.json();e=n.code??e,t=n.message??t}catch{}throw c.status===401&&(o(),s()),new n(c.status,e,t)}if(c.status!==204)return c.json()}async function l(e,t=50){return(await c(`/tasks/${e}/delivery-log?limit=${t}`)).logs}async function u(e){return(await fetch(`/auth/verify`,{headers:{"x-api-key":e}})).ok}async function d(){return(await c(`/auth/rotate`,{method:`POST`})).apiKey}async function f(e){let t=new URLSearchParams;e&&t.set(`status`,e);let n=t.toString();return(await c(`/mistake-patterns${n?`?${n}`:``}`)).mistakePatterns}async function p(e,t){await c(`/mistake-patterns/${e}`,{method:`PATCH`,body:JSON.stringify({status:t})})}async function m(e,t){return c(`/task-templates/${e}`,{method:`PATCH`,body:JSON.stringify({config:t})})}async function h(){return(await c(`/extensions`)).extensions}async function g(e){return(await c(`/extensions/${e}`)).extension}async function _(e){let t=new FormData;t.append(`file`,e);let r=i(),a=await fetch(`/extensions`,{method:`POST`,headers:r?{"x-api-key":r}:{},body:t});if(!a.ok){let e=`UNKNOWN_ERROR`,t=a.statusText;try{let n=await a.json();e=n.code??e,t=n.message??t}catch{}throw new n(a.status,e,t)}return(await a.json()).extension}async function v(e){await c(`/extensions/${e}`,{method:`DELETE`})}async function y(){return c(`/extensions/legacy`)}async function b(e){await c(`/extensions/legacy/clear/${e}`,{method:`POST`})}async function x(e){return(await c(`/roles/${e}/extensions`)).bindings}async function S(e,t,n){return c(`/roles/${e}/extensions`,{method:`POST`,body:JSON.stringify({extension_name:t,config_override:n})})}async function C(e,t){await c(`/roles/${e}/extensions/${t}`,{method:`DELETE`})}async function w(e,t,n){return c(`/roles/${e}/extensions/${t}`,{method:`PATCH`,body:JSON.stringify({config_override:n.configOverride,enabled:n.enabled})})}export{u as S,a as _,o as a,m as b,g as c,y as d,f,d as g,s as h,b as i,i as l,w as m,t as n,v as o,x as p,S as r,l as s,c as t,h as u,C as v,_ as x,p as y};