adam-agent-server 0.4.0 → 1.0.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 (125) hide show
  1. package/README.md +2 -4
  2. package/dist/App-SCPYTYGQ.js +9 -0
  3. package/dist/adam-tools-FNJJT7AA.js +1 -0
  4. package/dist/{approval-handler-HK7GQPHU.js → approval-handler-UDWAC5MF.js} +2 -2
  5. package/dist/audit-manager-SCX53YJT.js +1 -0
  6. package/dist/bree-engine-2DB2QECM.js +1 -0
  7. package/dist/channels-NAPXRIOX.js +1 -0
  8. package/dist/channels-PQCV74ZI.js +1 -0
  9. package/dist/{chunk-2GXYBWLS.js → chunk-2C5U3CNX.js} +1 -1
  10. package/dist/chunk-2CMR5AG7.js +1 -0
  11. package/dist/chunk-35DBEYMG.js +49 -0
  12. package/dist/chunk-3TIHZZMK.js +1 -0
  13. package/dist/{chunk-VF6GJGD6.js → chunk-42RHY3Q3.js} +1 -1
  14. package/dist/{chunk-742NWPTQ.js → chunk-4TBGFHYX.js} +1 -1
  15. package/dist/chunk-5V36ACKZ.js +1 -0
  16. package/dist/{chunk-PQ7KPALO.js → chunk-64FIXWFL.js} +1 -1
  17. package/dist/chunk-6KLG4APZ.js +1 -0
  18. package/dist/chunk-6VPL5CXB.js +4 -0
  19. package/dist/{chunk-T7WVM27S.js → chunk-7KCBFM2C.js} +6 -6
  20. package/dist/chunk-BCELBB5Q.js +3 -0
  21. package/dist/{chunk-5ASEAZCR.js → chunk-BONI2HUN.js} +1 -1
  22. package/dist/chunk-CFTWJZVX.js +67 -0
  23. package/dist/{chunk-PCSZW2PE.js → chunk-CREHL4BN.js} +7 -7
  24. package/dist/chunk-FXFHGIY6.js +8 -0
  25. package/dist/{chunk-KICPHTI2.js → chunk-GA7GEIXB.js} +1 -1
  26. package/dist/{chunk-HAWA62R2.js → chunk-I5RUEOSQ.js} +1 -1
  27. package/dist/chunk-INNDBLZE.js +1 -0
  28. package/dist/chunk-IZQI6QQ7.js +1 -0
  29. package/dist/{chunk-WXN3PSVX.js → chunk-KHPXEUSY.js} +1 -1
  30. package/dist/{chunk-IXF3XBGX.js → chunk-NFSXJNPD.js} +1 -1
  31. package/dist/chunk-NQHTOFQP.js +1 -0
  32. package/dist/{chunk-B6S2AEOD.js → chunk-PT55643Q.js} +1 -1
  33. package/dist/chunk-QC6QVNKP.js +83 -0
  34. package/dist/chunk-QMKQBU3R.js +2 -0
  35. package/dist/chunk-REKCZ3GY.js +1 -0
  36. package/dist/{chunk-L7426WNY.js → chunk-ROSOI75V.js} +1 -1
  37. package/dist/{chunk-FDWW245P.js → chunk-TEMWI6U5.js} +1 -1
  38. package/dist/{chunk-U36NBCR3.js → chunk-U3XVAAXA.js} +1 -1
  39. package/dist/chunk-VRP4LTHY.js +1 -0
  40. package/dist/chunk-WBAPIPST.js +1 -0
  41. package/dist/{chunk-AXMXXUPO.js → chunk-X26NKAXY.js} +1 -1
  42. package/dist/{chunk-TN6H2WM2.js → chunk-XFTRKHH2.js} +3 -3
  43. package/dist/{chunk-FUGJMHY4.js → chunk-YEV5YTS3.js} +1 -1
  44. package/dist/cli.js +4 -4
  45. package/dist/config-L4R273R3.js +1 -0
  46. package/dist/config-N2GMLTPU.js +1 -0
  47. package/dist/db-S6HDMJ3B.js +1 -0
  48. package/dist/delivery-log-VAI35G5V.js +1 -0
  49. package/dist/engine-E67UAI3G.js +1 -0
  50. package/dist/evolution-audit-KCFDGNSM.js +1 -0
  51. package/dist/external-api-I6CENLIS.js +1 -0
  52. package/dist/index.js +12 -57
  53. package/dist/learner-ABYVK33T.js +1 -0
  54. package/dist/logger-QCJUU7GV.js +1 -0
  55. package/dist/memories-3ZAV55YZ.js +1 -0
  56. package/dist/{memory-extractor-GOISDQTO.js → memory-extractor-BHHKD7X7.js} +2 -2
  57. package/dist/memory-service-5QHTKIUU.js +1 -0
  58. package/dist/outbound-gateway-ZFKSN2UT.js +1 -0
  59. package/dist/role-presets-OTU2M37Y.js +1 -0
  60. package/dist/roles-LXRHEVUK.js +1 -0
  61. package/dist/{runtime-6UTYEONR.js → runtime-UCOE6LNN.js} +1 -1
  62. package/dist/session-manager-RPXFZKMY.js +1 -0
  63. package/dist/task-templates-XQNKAA4U.js +1 -0
  64. package/package.json +1 -1
  65. package/web/dist/assets/{ChannelDetail-dZfZlLgQ.js → ChannelDetail-BajTUEU0.js} +1 -1
  66. package/web/dist/assets/{Channels-Cw04c7YJ.js → Channels-Bhy6rP_t.js} +1 -1
  67. package/web/dist/assets/{Chat-D4PHqHPE.js → Chat-Dvt_Oo7d.js} +1 -1
  68. package/web/dist/assets/{Dashboard-BFewwmAg.js → Dashboard-DlrAor-C.js} +1 -1
  69. package/web/dist/assets/{Evolution-DY1OC6Oc.js → Evolution-Dlsnnr4G.js} +1 -1
  70. package/web/dist/assets/{GoalDetail-DZIEpHs2.js → GoalDetail-BuUxwYdd.js} +1 -1
  71. package/web/dist/assets/{Goals-COCCVLnp.js → Goals-CkPQOev6.js} +1 -1
  72. package/web/dist/assets/{Logs-DsDeimLt.js → Logs-D33PqDAd.js} +1 -1
  73. package/web/dist/assets/{Memories-D5IEEI1u.js → Memories-D31dbUM6.js} +1 -1
  74. package/web/dist/assets/{Plugins-DUwZVjPc.js → Plugins-XlBr07x8.js} +1 -1
  75. package/web/dist/assets/RoleDetail-rZFlgXzh.js +33 -0
  76. package/web/dist/assets/{Roles-JeVjD0Ew.js → Roles-d29AC6Kh.js} +1 -1
  77. package/web/dist/assets/Settings-Bjh_RXYf.js +1 -0
  78. package/web/dist/assets/{Strategies-KAmpqrcQ.js → Strategies-Cf4ghknk.js} +1 -1
  79. package/web/dist/assets/{Switch-Jpdn6Yux.js → Switch-CxzUYL49.js} +1 -1
  80. package/web/dist/assets/{TaskDetail-C4NpqwNT.js → TaskDetail-jMBJbaRU.js} +1 -1
  81. package/web/dist/assets/{Work-DhaxNYnd.js → Work-CCLTkitf.js} +1 -1
  82. package/web/dist/assets/index-CVubgAlC.css +2 -0
  83. package/web/dist/assets/{index-CfKqiQIe.js → index-Ds41VvOC.js} +2 -2
  84. package/web/dist/index.html +2 -2
  85. package/dist/App-XZABZ2AF.js +0 -9
  86. package/dist/adam-tools-PQC7EI3J.js +0 -1
  87. package/dist/bree-engine-25VACELK.js +0 -1
  88. package/dist/channels-JEBBMFUQ.js +0 -1
  89. package/dist/channels-VEUBY2NZ.js +0 -1
  90. package/dist/chunk-3DAK2XWP.js +0 -1
  91. package/dist/chunk-5JLMSNIW.js +0 -1
  92. package/dist/chunk-7SPKRIMZ.js +0 -15
  93. package/dist/chunk-BREBCBG4.js +0 -49
  94. package/dist/chunk-ETQ7KC73.js +0 -1
  95. package/dist/chunk-FYDFMYUP.js +0 -1
  96. package/dist/chunk-HICJBGGJ.js +0 -86
  97. package/dist/chunk-JXD6ZPV7.js +0 -2
  98. package/dist/chunk-MX6AZ7WD.js +0 -1
  99. package/dist/chunk-NSJAV7IH.js +0 -1
  100. package/dist/chunk-NXTTKAQX.js +0 -3
  101. package/dist/chunk-SFUS33SO.js +0 -1
  102. package/dist/chunk-T25NLVMY.js +0 -1
  103. package/dist/chunk-URW2DJQF.js +0 -1
  104. package/dist/chunk-WZOMGJSY.js +0 -1
  105. package/dist/chunk-XNWZZYAV.js +0 -7
  106. package/dist/config-WHXCZCI4.js +0 -1
  107. package/dist/config-Y4QWELO3.js +0 -1
  108. package/dist/db-PNZ3UJOE.js +0 -1
  109. package/dist/delivery-log-VYTYUFCK.js +0 -1
  110. package/dist/engine-DEBMZJBM.js +0 -1
  111. package/dist/evolution-audit-B7WKMOVR.js +0 -1
  112. package/dist/external-api-XGEOKAWR.js +0 -1
  113. package/dist/learner-VMD5NQCD.js +0 -1
  114. package/dist/logger-BEG4WFIM.js +0 -1
  115. package/dist/memories-EFQ4SFZG.js +0 -1
  116. package/dist/memory-service-BKLZIRK6.js +0 -1
  117. package/dist/monitor-K7CGTLA6.js +0 -1
  118. package/dist/outbound-gateway-DZTXBUTP.js +0 -1
  119. package/dist/role-presets-FN2RWUCP.js +0 -1
  120. package/dist/roles-SG2YAR64.js +0 -1
  121. package/dist/session-manager-45LFTPBA.js +0 -1
  122. package/dist/task-templates-7LSQ6OST.js +0 -1
  123. package/web/dist/assets/RoleDetail-B-GKMfMG.js +0 -33
  124. package/web/dist/assets/Settings-CvEyZp5t.js +0 -1
  125. package/web/dist/assets/index-LDFr0VVR.css +0 -2
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-BFewwmAg.js","assets/rolldown-runtime-Dw2cE7zH.js","assets/vendor-react--nRVf2Ep.js","assets/vendor-icons-ZPvC5PUS.js","assets/Card-BecEmnPW.js","assets/dist-HyCSN_hp.js","assets/Table-tkJ-cuiE.js","assets/format-DvtQjPZn.js","assets/Chat-D4PHqHPE.js","assets/vendor-state-CH64feAE.js","assets/Work-DhaxNYnd.js","assets/Switch-Jpdn6Yux.js","assets/EmptyState-DBFJc4PL.js","assets/Goals-COCCVLnp.js","assets/TaskDetail-C4NpqwNT.js","assets/Plugins-DUwZVjPc.js","assets/Strategies-KAmpqrcQ.js","assets/Logs-DsDeimLt.js","assets/Settings-CvEyZp5t.js","assets/Memories-D5IEEI1u.js","assets/Evolution-DY1OC6Oc.js","assets/Channels-Cw04c7YJ.js","assets/GoalDetail-DZIEpHs2.js","assets/ChannelDetail-dZfZlLgQ.js","assets/Roles-JeVjD0Ew.js","assets/RoleDetail-B-GKMfMG.js","assets/NotFound-Cidygwnn.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-DlrAor-C.js","assets/rolldown-runtime-Dw2cE7zH.js","assets/vendor-react--nRVf2Ep.js","assets/vendor-icons-ZPvC5PUS.js","assets/Card-BecEmnPW.js","assets/dist-HyCSN_hp.js","assets/Table-tkJ-cuiE.js","assets/format-DvtQjPZn.js","assets/Chat-Dvt_Oo7d.js","assets/vendor-state-CH64feAE.js","assets/Work-CCLTkitf.js","assets/Switch-CxzUYL49.js","assets/EmptyState-DBFJc4PL.js","assets/Goals-CkPQOev6.js","assets/TaskDetail-jMBJbaRU.js","assets/Plugins-XlBr07x8.js","assets/Strategies-Cf4ghknk.js","assets/Logs-D33PqDAd.js","assets/Settings-Bjh_RXYf.js","assets/Memories-D31dbUM6.js","assets/Evolution-Dlsnnr4G.js","assets/Channels-Bhy6rP_t.js","assets/GoalDetail-BuUxwYdd.js","assets/ChannelDetail-BajTUEU0.js","assets/Roles-d29AC6Kh.js","assets/RoleDetail-rZFlgXzh.js","assets/NotFound-Cidygwnn.js"])))=>i.map(i=>d[i]);
2
2
  import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,D as n,N as r,O as i,Z as a,c as o,h as s,k as c,m as l,n as u,o as d,q as f,r as p,t as m,w as h,z as g}from"./vendor-icons-ZPvC5PUS.js";import{a as _,c as v,f as y,i as b,m as x,n as S,o as C,p as w,s as ee,t as T}from"./vendor-react--nRVf2Ep.js";import{a as te,n as E,r as D,t as O}from"./dist-HyCSN_hp.js";import{t as ne}from"./vendor-state-CH64feAE.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var k=w(),A=e(a(),1),j=T(),re=class extends A.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary] Uncaught error:`,e,t.componentStack)}render(){return this.state.hasError?(0,j.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-slate-950 p-6`,children:(0,j.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-slate-800 bg-slate-900 p-8 text-center`,children:[(0,j.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-red-500/10`,children:(0,j.jsx)(`svg`,{className:`h-6 w-6 text-red-500`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,j.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})})}),(0,j.jsx)(`h1`,{className:`mb-2 text-lg font-semibold text-slate-100`,children:`Something went wrong`}),(0,j.jsx)(`p`,{className:`mb-6 text-sm text-slate-400`,children:`An unexpected error occurred. Try reloading the page.`}),this.state.error&&(0,j.jsx)(`pre`,{className:`mb-6 max-h-32 overflow-auto rounded bg-slate-950 p-3 text-left text-xs text-red-400`,children:this.state.error.message}),(0,j.jsx)(`button`,{onClick:()=>window.location.reload(),className:`rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-slate-900`,children:`Reload`})]})}):this.props.children}},M=[{to:`/`,icon:c,label:`Dashboard`},{to:`/chat`,icon:t,label:`Chat`},{to:`/work`,icon:n,label:`Work`},{to:`/roles`,icon:g,label:`Roles`},{to:`/strategies`,icon:i,label:`Strategies`},{to:`/channels`,icon:l,label:`Channels`},{to:`/memories`,icon:f,label:`Memories`},{to:`/evolution`,icon:r,label:`Evolution`},{to:`/plugins`,icon:s,label:`Plugins`},{to:`/logs`,icon:d,label:`Logs`},{to:`/settings`,icon:o,label:`Settings`}];function N({onNavigate:e}){return(0,j.jsxs)(`aside`,{className:`flex h-full w-60 flex-col border-r border-slate-800 bg-slate-950`,children:[(0,j.jsxs)(`div`,{className:`flex h-14 items-center gap-2.5 border-b border-slate-800 px-5`,children:[(0,j.jsx)(`div`,{className:`flex h-7 w-7 items-center justify-center rounded-md bg-blue-600 text-xs font-bold text-white`,children:`A`}),(0,j.jsx)(`span`,{className:`text-sm font-semibold text-slate-100 tracking-wide`,children:`Adam`}),(0,j.jsx)(`span`,{className:`ml-auto rounded bg-slate-800 px-1.5 py-0.5 font-mono text-[10px] text-slate-500`,children:`v2.0`})]}),(0,j.jsx)(`nav`,{role:`navigation`,"aria-label":`Main navigation`,className:`flex-1 space-y-0.5 px-3 py-4`,children:M.map(({to:t,icon:n,label:r})=>(0,j.jsx)(b,{to:t,end:t===`/`,onClick:e,className:({isActive:e})=>te(`flex items-center gap-2.5 rounded-md px-2.5 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-slate-950`,e?`bg-slate-800 text-slate-100`:`text-slate-400 hover:bg-slate-900 hover:text-slate-200`),children:({isActive:e})=>(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(n,{size:16}),r,e&&(0,j.jsx)(`span`,{className:`sr-only`,children:`(current page)`})]})},t))})]})}var ie=e(x(),1);function ae(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var oe=e=>{switch(e){case`success`:return le;case`info`:return de;case`warning`:return ue;case`error`:return fe;default:return null}},se=Array(12).fill(0),ce=({visible:e,className:t})=>A.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},A.createElement(`div`,{className:`sonner-spinner`},se.map((e,t)=>A.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),le=A.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},A.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),ue=A.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},A.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),de=A.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},A.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),fe=A.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},A.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),pe=A.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},A.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),A.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),me=()=>{let[e,t]=A.useState(document.hidden);return A.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},P=1,F=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:P++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],A.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(he(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!A.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!A.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!A.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!A.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||P++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},I=(e,t)=>{let n=t?.id||P++;return F.addToast({title:e,...t,id:n}),n},he=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,ge=Object.assign(I,{success:F.success,info:F.info,warning:F.warning,error:F.error,custom:F.custom,message:F.message,promise:F.promise,dismiss:F.dismiss,loading:F.loading},{getHistory:()=>F.toasts,getToasts:()=>F.getActiveToasts()});ae(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function _e(e){return e.label!==void 0}var L=3,R=`24px`,ve=`16px`,ye=4e3,be=356,xe=14,Se=45,Ce=200;function z(...e){return e.filter(Boolean).join(` `)}function we(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var Te=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:ee=`Close toast`}=e,[T,te]=A.useState(null),[E,D]=A.useState(null),[O,ne]=A.useState(!1),[k,j]=A.useState(!1),[re,M]=A.useState(!1),[N,ie]=A.useState(!1),[ae,se]=A.useState(!1),[le,ue]=A.useState(0),[de,fe]=A.useState(0),P=A.useRef(n.duration||y||ye),F=A.useRef(null),I=A.useRef(null),he=c===0,ge=c+1<=o,L=n.type,R=n.dismissible!==!1,ve=n.className||``,be=n.descriptionClassName||``,xe=A.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),Te=A.useMemo(()=>n.closeButton??p,[n.closeButton,p]),Ee=A.useMemo(()=>n.duration||y||ye,[n.duration,y]),De=A.useRef(0),B=A.useRef(0),Oe=A.useRef(0),V=A.useRef(null),[H,ke]=b.split(`-`),Ae=A.useMemo(()=>s.reduce((e,t,n)=>n>=xe?e:e+t.height,0),[s,xe]),je=me(),Me=n.invert||t,Ne=L===`loading`;B.current=A.useMemo(()=>xe*x+Ae,[xe,Ae]),A.useEffect(()=>{P.current=Ee},[Ee]),A.useEffect(()=>{ne(!0)},[]),A.useEffect(()=>{let e=I.current;if(e){let t=e.getBoundingClientRect().height;return fe(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),A.useLayoutEffect(()=>{if(!O)return;let e=I.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,fe(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[O,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let U=A.useCallback(()=>{j(!0),ue(B.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},Ce)},[n,d,a,B]);A.useEffect(()=>{if(n.promise&&L===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||je?(()=>{if(Oe.current<De.current){let e=new Date().getTime()-De.current;P.current-=e}Oe.current=new Date().getTime()})():P.current!==1/0&&(De.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),U()},P.current)),()=>clearTimeout(e)},[u,i,n,L,je,U]),A.useEffect(()=>{n.delete&&(U(),n.onDismiss==null||n.onDismiss.call(n,n))},[U,n.delete]);function Pe(){return w?.loading?A.createElement(`div`,{className:z(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":L===`loading`},w.loading):A.createElement(ce,{className:z(C?.loader,n?.classNames?.loader),visible:L===`loading`})}let W=n.icon||w?.[L]||oe(L);return A.createElement(`li`,{tabIndex:0,ref:I,className:z(_,ve,C?.toast,n?.classNames?.toast,C?.default,C?.[L],n?.classNames?.[L]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":O,"data-promise":!!n.promise,"data-swiped":ae,"data-removed":k,"data-visible":ge,"data-y-position":H,"data-x-position":ke,"data-index":c,"data-front":he,"data-swiping":re,"data-dismissible":R,"data-type":L,"data-invert":Me,"data-swipe-out":N,"data-swipe-direction":E,"data-expanded":!!(u||S&&O),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${k?le:B.current}px`,"--initial-height":S?`auto`:`${de}px`,...m,...n.style},onDragEnd:()=>{M(!1),te(null),V.current=null},onPointerDown:e=>{e.button!==2&&(Ne||!R||(F.current=new Date,ue(B.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(M(!0),V.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(N||!R)return;V.current=null;let e=Number(I.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(I.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-F.current?.getTime(),i=T===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=Se||a>.11){ue(B.current),n.onDismiss==null||n.onDismiss.call(n,n),D(T===`x`?e>0?`right`:`left`:t>0?`down`:`up`),U(),ie(!0);return}else{var o,s;(o=I.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=I.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}se(!1),M(!1),te(null)},onPointerMove:t=>{var n,r;if(!V.current||!R||window.getSelection()?.toString().length>0)return;let i=t.clientY-V.current.y,a=t.clientX-V.current.x,o=e.swipeDirections??we(b);!T&&(Math.abs(a)>1||Math.abs(i)>1)&&te(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(T===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(T===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&se(!0),(n=I.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=I.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},Te&&!n.jsx&&L!==`loading`?A.createElement(`button`,{"aria-label":ee,"data-disabled":Ne,"data-close-button":!0,onClick:Ne||!R?()=>{}:()=>{U(),n.onDismiss==null||n.onDismiss.call(n,n)},className:z(C?.closeButton,n?.classNames?.closeButton)},w?.close??pe):null,(L||n.icon||n.promise)&&n.icon!==null&&(w?.[L]!==null||n.icon)?A.createElement(`div`,{"data-icon":``,className:z(C?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||Pe():null,n.type===`loading`?null:W):null,A.createElement(`div`,{"data-content":``,className:z(C?.content,n?.classNames?.content)},A.createElement(`div`,{"data-title":``,className:z(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?A.createElement(`div`,{"data-description":``,className:z(v,be,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),A.isValidElement(n.cancel)?n.cancel:n.cancel&&_e(n.cancel)?A.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{_e(n.cancel)&&R&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),U())},className:z(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,A.isValidElement(n.action)?n.action:n.action&&_e(n.action)?A.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{_e(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&U())},className:z(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function Ee(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function De(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?ve:R;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var B=A.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=L,toastOptions:g,dir:_=Ee(),gap:v=xe,icons:y,containerAriaLabel:b=`Notifications`}=e,[x,S]=A.useState([]),C=A.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),w=A.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[ee,T]=A.useState([]),[te,E]=A.useState(!1),[D,O]=A.useState(!1),[ne,k]=A.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),j=A.useRef(null),re=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),M=A.useRef(null),N=A.useRef(!1),ae=A.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||F.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return A.useEffect(()=>F.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{ie.flushSync(()=>{S(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[x]),A.useEffect(()=>{if(d!==`system`){k(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?k(`dark`):k(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{k(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{k(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),A.useEffect(()=>{x.length<=1&&E(!1)},[x]),A.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;E(!0),(t=j.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===j.current||j.current?.contains(document.activeElement))&&E(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),A.useEffect(()=>{if(j.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,N.current=!1)}},[j.current]),A.createElement(`section`,{ref:t,"aria-label":`${b} ${re}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,n)=>{let[i,a]=t.split(`-`);return C.length?A.createElement(`ol`,{key:t,dir:_===`auto`?Ee():_,tabIndex:-1,ref:j,className:c,"data-sonner-toaster":!0,"data-sonner-theme":ne,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${ee[0]?.height||0}px`,"--width":`${be}px`,"--gap":`${v}px`,...m,...De(l,u)},onBlur:e=>{N.current&&!e.currentTarget.contains(e.relatedTarget)&&(N.current=!1,M.current&&=(M.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||N.current||(N.current=!0,M.current=e.relatedTarget)},onMouseEnter:()=>E(!0),onMouseMove:()=>E(!0),onMouseLeave:()=>{D||E(!1)},onDragEnd:()=>E(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||O(!0)},onPointerUp:()=>O(!1)},C.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>A.createElement(Te,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:D,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:ae,toasts:C.filter(e=>e.position==n.position),heights:ee.filter(e=>e.position==n.position),setHeights:T,expandByDefault:o,gap:v,expanded:te,swipeDirections:e.swipeDirections}))):null}))}),Oe=({...e})=>(0,j.jsx)(B,{theme:`dark`,className:`toaster group`,toastOptions:{classNames:{toast:`group toast group-[.toaster]:bg-slate-900 group-[.toaster]:text-slate-200 group-[.toaster]:border-slate-800 group-[.toaster]:shadow-lg`,description:`group-[.toast]:text-slate-400`,actionButton:`group-[.toast]:bg-blue-600 group-[.toast]:text-white`,cancelButton:`group-[.toast]:bg-slate-800 group-[.toast]:text-slate-200`}},...e}),V=500,H=ne((e,t)=>({tasks:[],goals:[],strategies:[],templates:[],readiness:null,stats:{activeTasks:0,queuedTasks:0,totalCostToday:0},logs:[],configVersion:0,pendingPlanApproval:null,planTimeoutNotice:null,roles:[],executionPool:{active:0,max:5,queued:0},deliveryLog:[],wsConnected:!1,_ws:null,_wsReconnectDelay:1e3,fetchTasks:async t=>{let n=new URLSearchParams({limit:`100`});t&&n.set(`status`,t),e({tasks:(await D(`/tasks?${n}`)).tasks})},fetchGoals:async()=>{e({goals:(await D(`/goals`)).goals})},updateGoal:async(t,n)=>{let r=await D(`/goals/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});return e(e=>({goals:e.goals.map(e=>e.id===t?r.goal:e)})),r.goal},deleteGoal:async t=>{await D(`/goals/${t}`,{method:`DELETE`}),e(e=>({goals:e.goals.filter(e=>e.id!==t)}))},fetchStrategies:async()=>{e({strategies:(await D(`/strategies`)).strategies})},fetchTemplates:async()=>{e({templates:(await D(`/task-templates`)).templates})},fetchExecutionPool:async()=>{try{e({executionPool:(await D(`/stats`)).executionPool})}catch{}},fetchReadiness:async()=>{try{e({readiness:await(await fetch(`/readyz`)).json()})}catch{e({readiness:{status:`not_ready`,checks:{database:!1,config:!1}}})}},connectWebSocket:()=>{let n=t()._ws;if(n&&n.readyState<=1)return;let r=window.location.protocol===`https:`?`wss:`:`ws:`,i=localStorage.getItem(`adam_api_key`),a=new URL(`${r}//${window.location.host}/events`);i&&a.searchParams.set(`api_key`,i);let o=new WebSocket(a.toString());o.onopen=()=>{e({wsConnected:!0,_ws:o,_wsReconnectDelay:1e3})},o.onclose=()=>{let n=t()._wsReconnectDelay;e({wsConnected:!1,_ws:null,_wsReconnectDelay:Math.min(n*2,1e4)}),setTimeout(()=>{t().connectWebSocket()},n)},o.onerror=()=>{o.close()},o.onmessage=n=>{try{ke(JSON.parse(n.data),e,t)}catch{}},e({_ws:o})},disconnectWebSocket:()=>{let n=t()._ws;n&&(n.close(),e({_ws:null,wsConnected:!1}))},addLog:t=>{e(e=>({logs:[...e.logs.slice(-(V-1)),t]}))},addDeliveryLogEntry:t=>{e(e=>({deliveryLog:[t,...e.deliveryLog].slice(0,100)}))},approvePlan:async(t,n,r)=>{await D(`/tasks/${t}/approve-plan`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({planId:n,decision:`allow`,approvalType:r})}),e({pendingPlanApproval:null})},denyPlan:async(t,n,r)=>{await D(`/tasks/${t}/approve-plan`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({planId:n,decision:`deny`,reason:r??`rejected by user`})}),e({pendingPlanApproval:null})},clearPlanTimeoutNotice:()=>{e({planTimeoutNotice:null})},fetchRoles:async()=>{let{roles:t}=await D(`/roles`);e({roles:t})},createRole:async t=>{let n=await D(`/roles`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});return e(e=>({roles:[...e.roles,n.role]})),n.role},updateRole:async(t,n)=>{let r=await D(`/roles/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});return e(e=>({roles:e.roles.map(e=>e.id===t?{...e,...r.role}:e)})),r.role},deleteRole:async t=>{await D(`/roles/${t}`,{method:`DELETE`}),e(e=>({roles:e.roles.filter(e=>e.id!==t)}))}}));function ke(e,t,n){switch(e.type){case`task_status_change`:t(t=>({tasks:t.tasks.map(t=>t.id===e.taskId?{...t,status:e.newStatus}:t)}));break;case`stats_update`:t(()=>({stats:{activeTasks:e.activeTasks,queuedTasks:e.queuedTasks,totalCostToday:e.totalCostToday}}));break;case`log_event`:n().addLog(e);break;case`goal_status_change`:t(t=>({goals:t.goals.map(t=>t.id===e.goalId?{...t,status:e.newStatus}:t)}));break;case`config_changed`:t(e=>({configVersion:e.configVersion+1}));break;case`execution_slot_change`:t(()=>({executionPool:{active:e.active,max:e.max,queued:e.queued}}));break;case`plan_approval_request`:t(()=>({pendingPlanApproval:{taskId:e.taskId,planId:e.planId,plan:e.plan}}));break;case`plan_approval_decision`:n().pendingPlanApproval?.planId===e.planId&&t(()=>({pendingPlanApproval:null}));break;case`delivery_status_change`:n().addDeliveryLogEntry(e);break}}function Ae(){let[e,t]=(0,A.useState)(!1),n=H(e=>e.wsConnected),r=H(e=>e.connectWebSocket),i=H(e=>e.fetchReadiness);(0,A.useEffect)(()=>{r(),i();let e=setInterval(i,3e4);return()=>clearInterval(e)},[r,i]);let a=(0,A.useCallback)(()=>t(!1),[]);return(0,j.jsxs)(`div`,{className:`flex h-screen overflow-hidden bg-slate-950`,children:[(0,j.jsx)(`a`,{href:`#main-content`,className:`sr-only focus:not-sr-only focus:fixed focus:left-4 focus:top-4 focus:z-50 focus:rounded-md focus:bg-blue-600 focus:px-4 focus:py-2 focus:text-sm focus:font-medium focus:text-white focus:outline-none`,children:`Skip to content`}),(0,j.jsx)(`div`,{className:`hidden lg:block`,children:(0,j.jsx)(N,{})}),e&&(0,j.jsxs)(`div`,{className:`fixed inset-0 z-40 lg:hidden`,children:[(0,j.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:a}),(0,j.jsx)(`div`,{className:`relative z-50 h-full w-60`,children:(0,j.jsx)(N,{onNavigate:a})})]}),(0,j.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:[(0,j.jsxs)(`header`,{className:`flex h-14 items-center gap-3 border-b border-slate-800 px-4`,children:[(0,j.jsx)(`button`,{className:`lg:hidden text-slate-400 hover:text-slate-200`,onClick:()=>t(!e),"aria-label":e?`Close menu`:`Open menu`,children:e?(0,j.jsx)(m,{size:20}):(0,j.jsx)(h,{size:20})}),(0,j.jsx)(`div`,{className:`flex-1`}),(0,j.jsx)(`div`,{className:`flex items-center gap-1.5 text-xs`,"aria-live":`polite`,children:n?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(u,{size:14,className:`text-emerald-500`}),(0,j.jsx)(`span`,{className:`text-emerald-400`,children:`Connected`})]}):(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(p,{size:14,className:`text-red-500`}),(0,j.jsx)(`span`,{className:`text-red-400`,children:`Disconnected`})]})})]}),(0,j.jsx)(`main`,{id:`main-content`,role:`main`,className:`flex-1 overflow-y-auto p-4 lg:p-6`,children:(0,j.jsx)(_,{})})]}),(0,j.jsx)(Oe,{position:`bottom-center`})]})}function je(e,t){let n=A.createContext(t),r=e=>{let{children:t,...r}=e,i=A.useMemo(()=>r,Object.values(r));return(0,j.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=A.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function Me(e,t=[]){let n=[];function r(t,r){let i=A.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=A.useMemo(()=>o,Object.values(o));return(0,j.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=A.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>A.createContext(e));return function(n){let r=n?.[e]||t;return A.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Ne(i,...t)]}function Ne(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return A.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function U(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Pe(...e){return t=>{let n=!1,r=e.map(e=>{let r=U(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():U(e[t],null)}}}}function W(...e){return A.useCallback(Pe(...e),e)}typeof window<`u`&&window.document&&window.document.createElement;function G(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var K=globalThis?.document?A.useLayoutEffect:()=>{},Fe=A.useId||(()=>void 0),Ie=0;function Le(e){let[t,n]=A.useState(Fe());return K(()=>{e||n(e=>e??String(Ie++))},[e]),e||(t?`radix-${t}`:``)}var Re=A.useInsertionEffect||K;function ze({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=Be({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=A.useRef(e!==void 0);A.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,A.useCallback(t=>{if(s){let n=Ve(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function Be({defaultProp:e,onChange:t}){let[n,r]=A.useState(e),i=A.useRef(n),a=A.useRef(t);return Re(()=>{a.current=t},[t]),A.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function Ve(e){return typeof e==`function`}function He(e){let t=Ue(e),n=A.forwardRef((e,n)=>{let{children:r,...i}=e,a=A.Children.toArray(r),o=a.find(Ke);if(o){let e=o.props.children,r=a.map(t=>t===o?A.Children.count(e)>1?A.Children.only(null):A.isValidElement(e)?e.props.children:null:t);return(0,j.jsx)(t,{...i,ref:n,children:A.isValidElement(e)?A.cloneElement(e,void 0,r):null})}return(0,j.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Ue(e){let t=A.forwardRef((e,t)=>{let{children:n,...r}=e;if(A.isValidElement(n)){let e=Je(n),i=qe(r,n.props);return n.type!==A.Fragment&&(i.ref=t?Pe(t,e):e),A.cloneElement(n,i)}return A.Children.count(n)>1?A.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var We=Symbol(`radix.slottable`);function Ge(e){let t=({children:e})=>(0,j.jsx)(j.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=We,t}function Ke(e){return A.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===We}function qe(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Je(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var q=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=He(`Primitive.${t}`),r=A.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,j.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Ye(e,t){e&&ie.flushSync(()=>e.dispatchEvent(t))}function Xe(e){let t=A.useRef(e);return A.useEffect(()=>{t.current=e}),A.useMemo(()=>(...e)=>t.current?.(...e),[])}function Ze(e,t=globalThis?.document){let n=Xe(e);A.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var Qe=`DismissableLayer`,$e=`dismissableLayer.update`,et=`dismissableLayer.pointerDownOutside`,tt=`dismissableLayer.focusOutside`,nt,rt=A.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),it=A.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=A.useContext(rt),[u,d]=A.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=A.useState({}),m=W(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,b=v>=_,x=st(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));!b||n||(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=ct(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return Ze(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),A.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(nt=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),lt(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=nt)}},[u,f,n,l]),A.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),lt())},[u,l]),A.useEffect(()=>{let e=()=>p({});return document.addEventListener($e,e),()=>document.removeEventListener($e,e)},[]),(0,j.jsx)(q.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:G(e.onFocusCapture,S.onFocusCapture),onBlurCapture:G(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:G(e.onPointerDownCapture,x.onPointerDownCapture)})});it.displayName=Qe;var at=`DismissableLayerBranch`,ot=A.forwardRef((e,t)=>{let n=A.useContext(rt),r=A.useRef(null),i=W(t,r);return A.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,j.jsx)(q.div,{...e,ref:i})});ot.displayName=at;function st(e,t=globalThis?.document){let n=Xe(e),r=A.useRef(!1),i=A.useRef(()=>{});return A.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){ut(et,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function ct(e,t=globalThis?.document){let n=Xe(e),r=A.useRef(!1);return A.useEffect(()=>{let e=e=>{e.target&&!r.current&&ut(tt,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function lt(){let e=new CustomEvent($e);document.dispatchEvent(e)}function ut(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?Ye(i,a):i.dispatchEvent(a)}var dt=`focusScope.autoFocusOnMount`,ft=`focusScope.autoFocusOnUnmount`,pt={bubbles:!1,cancelable:!0},mt=`FocusScope`,ht=A.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=A.useState(null),l=Xe(i),u=Xe(a),d=A.useRef(null),f=W(t,e=>c(e)),p=A.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;A.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:J(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||J(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&J(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),A.useEffect(()=>{if(s){St.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(dt,pt);s.addEventListener(dt,l),s.dispatchEvent(t),t.defaultPrevented||(gt(Tt(vt(s)),{select:!0}),document.activeElement===e&&J(s))}return()=>{s.removeEventListener(dt,l),setTimeout(()=>{let t=new CustomEvent(ft,pt);s.addEventListener(ft,u),s.dispatchEvent(t),t.defaultPrevented||J(e??document.body,{select:!0}),s.removeEventListener(ft,u),St.remove(p)},0)}}},[s,l,u,p]);let m=A.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=_t(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&J(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&J(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,j.jsx)(q.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});ht.displayName=mt;function gt(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(J(r,{select:t}),document.activeElement!==n)return}function _t(e){let t=vt(e);return[yt(t,e),yt(t.reverse(),e)]}function vt(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function yt(e,t){for(let n of e)if(!bt(n,{upTo:t}))return n}function bt(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function xt(e){return e instanceof HTMLInputElement&&`select`in e}function J(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&xt(e)&&t&&e.select()}}var St=Ct();function Ct(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=wt(e,t),e.unshift(t)},remove(t){e=wt(e,t),e[0]?.resume()}}}function wt(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Tt(e){return e.filter(e=>e.tagName!==`A`)}var Et=`Portal`,Dt=A.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=A.useState(!1);K(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?ie.createPortal((0,j.jsx)(q.div,{...r,ref:t}),o):null});Dt.displayName=Et;function Ot(e,t){return A.useReducer((e,n)=>t[e][n]??e,e)}var kt=e=>{let{present:t,children:n}=e,r=At(t),i=typeof n==`function`?n({present:r.isPresent}):A.Children.only(n),a=W(r.ref,Mt(i));return typeof n==`function`||r.isPresent?A.cloneElement(i,{ref:a}):null};kt.displayName=`Presence`;function At(e){let[t,n]=A.useState(),r=A.useRef(null),i=A.useRef(e),a=A.useRef(`none`),[o,s]=Ot(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return A.useEffect(()=>{let e=jt(r.current);a.current=o===`mounted`?e:`none`},[o]),K(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=jt(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),K(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=jt(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=jt(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:A.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function jt(e){return e?.animationName||`none`}function Mt(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Nt=0;function Pt(){A.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??Ft()),document.body.insertAdjacentElement(`beforeend`,e[1]??Ft()),Nt++,()=>{Nt===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),Nt--}},[])}function Ft(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var Y=function(){return Y=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Y.apply(this,arguments)};function It(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Lt(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Rt=`right-scroll-bar-position`,zt=`width-before-scroll-bar`,Bt=`with-scroll-bars-hidden`,Vt=`--removed-body-scroll-bar-size`;function Ht(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Ut(e,t){var n=(0,A.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Wt=typeof window<`u`?A.useLayoutEffect:A.useEffect,Gt=new WeakMap;function Kt(e,t){var n=Ut(t||null,function(t){return e.forEach(function(e){return Ht(e,t)})});return Wt(function(){var t=Gt.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Ht(e,null)}),i.forEach(function(e){r.has(e)||Ht(e,a)})}Gt.set(n,e)},[e]),n}function qt(e){return e}function Jt(e,t){t===void 0&&(t=qt);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Yt(e){e===void 0&&(e={});var t=Jt(null);return t.options=Y({async:!0,ssr:!1},e),t}var Xt=function(e){var t=e.sideCar,n=It(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return A.createElement(r,Y({},n))};Xt.isSideCarExport=!0;function Zt(e,t){return e.useMedium(t),Xt}var Qt=Yt(),$t=function(){},en=A.forwardRef(function(e,t){var n=A.useRef(null),r=A.useState({onScrollCapture:$t,onWheelCapture:$t,onTouchMoveCapture:$t}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=It(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=Kt([n,t]),C=Y(Y({},b),i);return A.createElement(A.Fragment,null,u&&A.createElement(x,{sideCar:Qt,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?A.cloneElement(A.Children.only(s),Y(Y({},C),{ref:S})):A.createElement(v,Y({},C,{className:c,ref:S}),s))});en.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},en.classNames={fullWidth:zt,zeroRight:Rt};var tn,nn=function(){if(tn)return tn;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function rn(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=nn();return t&&e.setAttribute(`nonce`,t),e}function an(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function on(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var sn=function(){var e=0,t=null;return{add:function(n){e==0&&(t=rn())&&(an(t,n),on(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},cn=function(){var e=sn();return function(t,n){A.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},ln=function(){var e=cn();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},un={left:0,top:0,right:0,gap:0},dn=function(e){return parseInt(e||``,10)||0},fn=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[dn(n),dn(r),dn(i)]},pn=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return un;var t=fn(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},mn=ln(),hn=`data-scroll-locked`,gn=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
3
3
  .${Bt} {
4
4
  overflow: hidden ${r};
@@ -49,4 +49,4 @@ You can add a description to the \`${$}\` by passing a \`${ni}\` component as a
49
49
 
50
50
  Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${$}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
51
51
 
52
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return A.useEffect(()=>{document.getElementById(e.current?.getAttribute(`aria-describedby`))||console.warn(t)},[t,e]),null},li=Ur,ui=Gr,di=qr,fi=Yr,pi=$r,mi=ai,hi=si,gi=ti,_i=ri,vi=Symbol.for(`react.lazy`),yi=A.use;function bi(e){return typeof e==`object`&&!!e&&`then`in e}function xi(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===vi&&`_payload`in e&&bi(e._payload)}function Si(e){let t=wi(e),n=A.forwardRef((e,n)=>{let{children:r,...i}=e;xi(r)&&typeof yi==`function`&&(r=yi(r._payload));let a=A.Children.toArray(r),o=a.find(Ei);if(o){let e=o.props.children,r=a.map(t=>t===o?A.Children.count(e)>1?A.Children.only(null):A.isValidElement(e)?e.props.children:null:t);return(0,j.jsx)(t,{...i,ref:n,children:A.isValidElement(e)?A.cloneElement(e,void 0,r):null})}return(0,j.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var Ci=Si(`Slot`);function wi(e){let t=A.forwardRef((e,t)=>{let{children:n,...r}=e;if(xi(n)&&typeof yi==`function`&&(n=yi(n._payload)),A.isValidElement(n)){let e=Oi(n),i=Di(r,n.props);return n.type!==A.Fragment&&(i.ref=t?Pe(t,e):e),A.cloneElement(n,i)}return A.Children.count(n)>1?A.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ti=Symbol(`radix.slottable`);function Ei(e){return A.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Ti}function Di(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Oi(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ki=O(`inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-slate-950 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{default:`bg-blue-600 text-white hover:bg-blue-500 active:bg-blue-700`,secondary:`bg-slate-800 text-slate-200 hover:bg-slate-700 active:bg-slate-600 border border-slate-700`,destructive:`bg-red-600 text-white hover:bg-red-500 active:bg-red-700`,ghost:`text-slate-400 hover:text-slate-200 hover:bg-slate-800`,outline:`border border-slate-700 bg-transparent text-slate-200 hover:bg-slate-800 hover:text-slate-100`,link:`text-blue-500 underline-offset-4 hover:underline`},size:{default:`px-3.5 py-1.5`,sm:`px-2.5 py-1 text-xs`,lg:`px-5 py-2`,icon:`h-8 w-8`}},defaultVariants:{variant:`default`,size:`default`}}),Ai=A.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},a)=>(0,j.jsx)(r?Ci:`button`,{className:E(ki({variant:t,size:n,className:e})),ref:a,...i}));Ai.displayName=`Button`;var ji=li,Mi=ui,Ni=di,Pi=A.forwardRef(({className:e,...t},n)=>(0,j.jsx)(fi,{ref:n,className:E(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));Pi.displayName=fi.displayName;var Fi=A.forwardRef(({className:e,...t},n)=>(0,j.jsxs)(Ni,{children:[(0,j.jsx)(Pi,{}),(0,j.jsx)(pi,{ref:n,className:E(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-slate-800 bg-slate-900 p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...t})]}));Fi.displayName=pi.displayName;var Ii=({className:e,...t})=>(0,j.jsx)(`div`,{className:E(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});Ii.displayName=`AlertDialogHeader`;var Li=({className:e,...t})=>(0,j.jsx)(`div`,{className:E(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Li.displayName=`AlertDialogFooter`;var Ri=A.forwardRef(({className:e,...t},n)=>(0,j.jsx)(gi,{ref:n,className:E(`text-lg font-semibold text-slate-100`,e),...t}));Ri.displayName=gi.displayName;var zi=A.forwardRef(({className:e,...t},n)=>(0,j.jsx)(_i,{ref:n,className:E(`text-sm text-slate-400`,e),...t}));zi.displayName=_i.displayName;var Bi=A.forwardRef(({className:e,...t},n)=>(0,j.jsx)(mi,{ref:n,className:E(ki(),e),...t}));Bi.displayName=mi.displayName;var Vi=A.forwardRef(({className:e,...t},n)=>(0,j.jsx)(hi,{ref:n,className:E(ki({variant:`ghost`}),`mt-2 sm:mt-0`,e),...t}));Vi.displayName=hi.displayName;var Hi=O(`inline-flex items-center rounded-md px-2 py-0.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2`,{variants:{variant:{default:`bg-slate-700 text-slate-200`,secondary:`bg-slate-800 text-slate-400`,destructive:`bg-red-900/50 text-red-400 border border-red-800`,outline:`border border-slate-700 text-slate-300`,success:`bg-emerald-900/50 text-emerald-400 border border-emerald-800`,warning:`bg-amber-900/50 text-amber-400 border border-amber-800`,info:`bg-blue-900/50 text-blue-400 border border-blue-800`,muted:`bg-slate-800 text-slate-500`}},defaultVariants:{variant:`default`}});function Ui({className:e,variant:t=`default`,...n}){return(0,j.jsx)(`span`,{className:E(Hi({variant:t}),e),...n})}function Wi(e){switch(e){case`completed`:case`ready`:case`idle`:return`success`;case`running`:case`busy`:case`executing`:case`planning`:case`evaluating`:case`replanning`:return`info`;case`pending`:case`queued`:case`paused`:return`warning`;case`failed`:case`cancelled`:case`dead`:case`not_ready`:return`destructive`;default:return`muted`}}var Gi=300;function Ki(e){return e===`high`?`destructive`:e===`medium`?`outline`:`secondary`}function qi(){let e=H(e=>e.pendingPlanApproval),t=H(e=>e.approvePlan),n=H(e=>e.denyPlan),r=H(e=>e.planTimeoutNotice),i=H(e=>e.clearPlanTimeoutNotice),[a,o]=(0,A.useState)(Gi),[s,c]=(0,A.useState)(!1);(0,A.useEffect)(()=>{if(!e){o(Gi),c(!1);return}let t=setInterval(()=>{o(e=>e<=1?(clearInterval(t),0):e-1)},1e3);return()=>clearInterval(t)},[e?.planId]),(0,A.useEffect)(()=>{a===0&&e&&!s&&(c(!0),n(e.taskId,e.planId,`timeout`).catch(()=>{}))},[a,e,s,n]);let l=async n=>{if(e){c(!0);try{await t(e.taskId,e.planId,n)}catch{c(!1)}}},u=async()=>{if(e){c(!0);try{await n(e.taskId,e.planId)}catch{c(!1)}}},d=e?.plan;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ji,{open:!!e,children:(0,j.jsxs)(Fi,{className:`max-w-2xl max-h-[80vh] overflow-y-auto`,children:[(0,j.jsxs)(Ii,{children:[(0,j.jsxs)(Ri,{className:`flex items-center gap-2`,children:[`Execution Plan — Approval Required`,d&&(0,j.jsxs)(Ui,{variant:Ki(d.overallRisk),children:[d.overallRisk.toUpperCase(),` RISK`]})]}),(0,j.jsxs)(zi,{className:`text-xs text-slate-400`,children:[`Plan `,e?.planId,` | Task `,e?.taskId,` | `,a,`s remaining`]})]}),d&&(0,j.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`h4`,{className:`text-sm font-medium text-slate-300 mb-2`,children:[`Plan Steps (`,d.steps.length,`)`]}),(0,j.jsx)(`div`,{className:`space-y-2`,children:d.steps.map(e=>(0,j.jsxs)(`div`,{className:`rounded-md border border-slate-700 bg-slate-800/50 p-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`span`,{className:`text-xs font-mono text-slate-500`,children:[`#`,e.index]}),(0,j.jsx)(`span`,{className:`text-sm text-slate-200`,children:e.description})]}),(0,j.jsx)(Ui,{variant:Ki(e.riskLevel),children:e.riskLevel})]}),(0,j.jsxs)(`div`,{className:`mt-1 text-xs text-slate-400`,children:[`Tools: `,e.toolsNeeded.join(`, `)||`none`]})]},e.index))})]}),Object.keys(d.requiredPermissions).length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h4`,{className:`text-sm font-medium text-slate-300 mb-1`,children:`Required Permissions`}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.keys(d.requiredPermissions).map(e=>(0,j.jsx)(Ui,{variant:`secondary`,children:e},e))})]})]}),(0,j.jsxs)(Li,{children:[(0,j.jsx)(Ai,{variant:`destructive`,onClick:u,disabled:s,children:`Deny`}),(0,j.jsx)(Ai,{variant:`outline`,onClick:()=>l(`permanent`),disabled:s,children:`Allow Permanent`}),(0,j.jsx)(Ai,{onClick:()=>l(`once`),disabled:s,children:`Allow Once`})]})]})}),r&&(0,j.jsxs)(`div`,{className:`fixed bottom-4 right-4 z-50 rounded-md border border-amber-700 bg-amber-950 px-4 py-2 text-sm text-amber-200 shadow-lg`,children:[r,(0,j.jsx)(`button`,{className:`ml-3 text-amber-400 hover:text-amber-200`,onClick:i,children:`Dismiss`})]})]})}var Ji=(0,A.lazy)(()=>y(()=>import(`./Dashboard-BFewwmAg.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([0,1,2,3,4,5,6,7]))),Yi=(0,A.lazy)(()=>y(()=>import(`./Chat-D4PHqHPE.js`).then(e=>({default:e.Chat})),__vite__mapDeps([8,1,2,3,5,9,7]))),Xi=(0,A.lazy)(()=>y(()=>import(`./Work-DhaxNYnd.js`).then(e=>({default:e.Work})),__vite__mapDeps([10,1,2,3,11,5,4,12,13,7,6]))),Zi=(0,A.lazy)(()=>y(()=>import(`./TaskDetail-C4NpqwNT.js`).then(e=>({default:e.TaskDetail})),__vite__mapDeps([14,1,2,3,5,4,7]))),Qi=(0,A.lazy)(()=>y(()=>import(`./Plugins-DUwZVjPc.js`).then(e=>({default:e.Plugins})),__vite__mapDeps([15,1,2,3,5,4,12,6,7]))),$i=(0,A.lazy)(()=>y(()=>import(`./Strategies-KAmpqrcQ.js`).then(e=>({default:e.Strategies})),__vite__mapDeps([16,1,2,3,4,5,12,6,7]))),ea=(0,A.lazy)(()=>y(()=>import(`./Goals-COCCVLnp.js`).then(e=>({default:e.Goals})),__vite__mapDeps([13,1,2,3,5,4,12,7]))),ta=(0,A.lazy)(()=>y(()=>import(`./Logs-DsDeimLt.js`).then(e=>({default:e.Logs})),__vite__mapDeps([17,1,2,3,4,5,12]))),na=(0,A.lazy)(()=>y(()=>import(`./Settings-CvEyZp5t.js`).then(e=>({default:e.Settings})),__vite__mapDeps([18,1,2,3,5,4,12,7]))),ra=(0,A.lazy)(()=>y(()=>import(`./Memories-D5IEEI1u.js`).then(e=>({default:e.Memories})),__vite__mapDeps([19,1,2,3,5,4,12,7]))),ia=(0,A.lazy)(()=>y(()=>import(`./Evolution-DY1OC6Oc.js`).then(e=>({default:e.Evolution})),__vite__mapDeps([20,1,2,3,5,4,12,7]))),aa=(0,A.lazy)(()=>y(()=>import(`./Channels-Cw04c7YJ.js`).then(e=>({default:e.Channels})),__vite__mapDeps([21,1,2,3,5,4,12]))),oa=(0,A.lazy)(()=>y(()=>import(`./GoalDetail-DZIEpHs2.js`).then(e=>({default:e.GoalDetail})),__vite__mapDeps([22,1,2,3,5,4,7]))),sa=(0,A.lazy)(()=>y(()=>import(`./ChannelDetail-dZfZlLgQ.js`).then(e=>({default:e.ChannelDetail})),__vite__mapDeps([23,1,2,3,5,4,7]))),ca=(0,A.lazy)(()=>y(()=>import(`./Roles-JeVjD0Ew.js`).then(e=>({default:e.Roles})),__vite__mapDeps([24,1,2,3,4,5,12,6,7]))),la=(0,A.lazy)(()=>y(()=>import(`./RoleDetail-B-GKMfMG.js`).then(e=>({default:e.RoleDetail})),__vite__mapDeps([25,1,2,3,11,5,4,6,7]))),ua=(0,A.lazy)(()=>y(()=>import(`./NotFound-Cidygwnn.js`),__vite__mapDeps([26,2,1,3])));function da(){return(0,j.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,j.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-slate-700 border-t-blue-500`})})}function fa(){return(0,j.jsxs)(A.Suspense,{fallback:(0,j.jsx)(da,{}),children:[(0,j.jsx)(ee,{children:(0,j.jsxs)(C,{element:(0,j.jsx)(Ae,{}),children:[(0,j.jsx)(C,{index:!0,element:(0,j.jsx)(Ji,{})}),(0,j.jsx)(C,{path:`chat`,element:(0,j.jsx)(Yi,{})}),(0,j.jsx)(C,{path:`work`,element:(0,j.jsx)(Xi,{})}),(0,j.jsx)(C,{path:`tasks/:id`,element:(0,j.jsx)(Zi,{})}),(0,j.jsx)(C,{path:`plugins`,element:(0,j.jsx)(Qi,{})}),(0,j.jsx)(C,{path:`roles`,element:(0,j.jsx)(ca,{})}),(0,j.jsx)(C,{path:`roles/:id`,element:(0,j.jsx)(la,{})}),(0,j.jsx)(C,{path:`channels`,element:(0,j.jsx)(aa,{})}),(0,j.jsx)(C,{path:`channels/:id`,element:(0,j.jsx)(sa,{})}),(0,j.jsx)(C,{path:`strategies`,element:(0,j.jsx)($i,{})}),(0,j.jsx)(C,{path:`goals`,element:(0,j.jsx)(ea,{})}),(0,j.jsx)(C,{path:`goals/:id`,element:(0,j.jsx)(oa,{})}),(0,j.jsx)(C,{path:`logs`,element:(0,j.jsx)(ta,{})}),(0,j.jsx)(C,{path:`settings`,element:(0,j.jsx)(na,{})}),(0,j.jsx)(C,{path:`memories`,element:(0,j.jsx)(ra,{})}),(0,j.jsx)(C,{path:`evolution`,element:(0,j.jsx)(ia,{})}),(0,j.jsx)(C,{path:`*`,element:(0,j.jsx)(ua,{})})]})}),(0,j.jsx)(qi,{})]})}var pa=v([{path:`*`,element:(0,j.jsx)(fa,{})}],{basename:`/ui`});(0,k.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(A.StrictMode,{children:(0,j.jsx)(re,{children:(0,j.jsx)(S,{router:pa})})}));export{H as C,Me as S,ze as _,Vi as a,G as b,Li as c,Mi as d,Ai as f,He as g,q as h,Bi as i,Ii as l,Xe as m,Wi as n,Fi as o,kt as p,ji as r,zi as s,Ui as t,Ri as u,Le as v,ge as w,W as x,K as y};
52
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return A.useEffect(()=>{document.getElementById(e.current?.getAttribute(`aria-describedby`))||console.warn(t)},[t,e]),null},li=Ur,ui=Gr,di=qr,fi=Yr,pi=$r,mi=ai,hi=si,gi=ti,_i=ri,vi=Symbol.for(`react.lazy`),yi=A.use;function bi(e){return typeof e==`object`&&!!e&&`then`in e}function xi(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===vi&&`_payload`in e&&bi(e._payload)}function Si(e){let t=wi(e),n=A.forwardRef((e,n)=>{let{children:r,...i}=e;xi(r)&&typeof yi==`function`&&(r=yi(r._payload));let a=A.Children.toArray(r),o=a.find(Ei);if(o){let e=o.props.children,r=a.map(t=>t===o?A.Children.count(e)>1?A.Children.only(null):A.isValidElement(e)?e.props.children:null:t);return(0,j.jsx)(t,{...i,ref:n,children:A.isValidElement(e)?A.cloneElement(e,void 0,r):null})}return(0,j.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}var Ci=Si(`Slot`);function wi(e){let t=A.forwardRef((e,t)=>{let{children:n,...r}=e;if(xi(n)&&typeof yi==`function`&&(n=yi(n._payload)),A.isValidElement(n)){let e=Oi(n),i=Di(r,n.props);return n.type!==A.Fragment&&(i.ref=t?Pe(t,e):e),A.cloneElement(n,i)}return A.Children.count(n)>1?A.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Ti=Symbol(`radix.slottable`);function Ei(e){return A.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Ti}function Di(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function Oi(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var ki=O(`inline-flex items-center justify-center gap-1.5 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-slate-950 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0`,{variants:{variant:{default:`bg-blue-600 text-white hover:bg-blue-500 active:bg-blue-700`,secondary:`bg-slate-800 text-slate-200 hover:bg-slate-700 active:bg-slate-600 border border-slate-700`,destructive:`bg-red-600 text-white hover:bg-red-500 active:bg-red-700`,ghost:`text-slate-400 hover:text-slate-200 hover:bg-slate-800`,outline:`border border-slate-700 bg-transparent text-slate-200 hover:bg-slate-800 hover:text-slate-100`,link:`text-blue-500 underline-offset-4 hover:underline`},size:{default:`px-3.5 py-1.5`,sm:`px-2.5 py-1 text-xs`,lg:`px-5 py-2`,icon:`h-8 w-8`}},defaultVariants:{variant:`default`,size:`default`}}),Ai=A.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},a)=>(0,j.jsx)(r?Ci:`button`,{className:E(ki({variant:t,size:n,className:e})),ref:a,...i}));Ai.displayName=`Button`;var ji=li,Mi=ui,Ni=di,Pi=A.forwardRef(({className:e,...t},n)=>(0,j.jsx)(fi,{ref:n,className:E(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t}));Pi.displayName=fi.displayName;var Fi=A.forwardRef(({className:e,...t},n)=>(0,j.jsxs)(Ni,{children:[(0,j.jsx)(Pi,{}),(0,j.jsx)(pi,{ref:n,className:E(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-slate-800 bg-slate-900 p-6 shadow-lg duration-200 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-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...t})]}));Fi.displayName=pi.displayName;var Ii=({className:e,...t})=>(0,j.jsx)(`div`,{className:E(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});Ii.displayName=`AlertDialogHeader`;var Li=({className:e,...t})=>(0,j.jsx)(`div`,{className:E(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});Li.displayName=`AlertDialogFooter`;var Ri=A.forwardRef(({className:e,...t},n)=>(0,j.jsx)(gi,{ref:n,className:E(`text-lg font-semibold text-slate-100`,e),...t}));Ri.displayName=gi.displayName;var zi=A.forwardRef(({className:e,...t},n)=>(0,j.jsx)(_i,{ref:n,className:E(`text-sm text-slate-400`,e),...t}));zi.displayName=_i.displayName;var Bi=A.forwardRef(({className:e,...t},n)=>(0,j.jsx)(mi,{ref:n,className:E(ki(),e),...t}));Bi.displayName=mi.displayName;var Vi=A.forwardRef(({className:e,...t},n)=>(0,j.jsx)(hi,{ref:n,className:E(ki({variant:`ghost`}),`mt-2 sm:mt-0`,e),...t}));Vi.displayName=hi.displayName;var Hi=O(`inline-flex items-center rounded-md px-2 py-0.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2`,{variants:{variant:{default:`bg-slate-700 text-slate-200`,secondary:`bg-slate-800 text-slate-400`,destructive:`bg-red-900/50 text-red-400 border border-red-800`,outline:`border border-slate-700 text-slate-300`,success:`bg-emerald-900/50 text-emerald-400 border border-emerald-800`,warning:`bg-amber-900/50 text-amber-400 border border-amber-800`,info:`bg-blue-900/50 text-blue-400 border border-blue-800`,muted:`bg-slate-800 text-slate-500`}},defaultVariants:{variant:`default`}});function Ui({className:e,variant:t=`default`,...n}){return(0,j.jsx)(`span`,{className:E(Hi({variant:t}),e),...n})}function Wi(e){switch(e){case`completed`:case`ready`:case`idle`:return`success`;case`running`:case`busy`:case`executing`:case`planning`:case`evaluating`:case`replanning`:return`info`;case`pending`:case`queued`:case`paused`:return`warning`;case`failed`:case`cancelled`:case`dead`:case`not_ready`:return`destructive`;default:return`muted`}}var Gi=300;function Ki(e){return e===`high`?`destructive`:e===`medium`?`outline`:`secondary`}function qi(){let e=H(e=>e.pendingPlanApproval),t=H(e=>e.approvePlan),n=H(e=>e.denyPlan),r=H(e=>e.planTimeoutNotice),i=H(e=>e.clearPlanTimeoutNotice),[a,o]=(0,A.useState)(Gi),[s,c]=(0,A.useState)(!1);(0,A.useEffect)(()=>{if(!e){o(Gi),c(!1);return}let t=setInterval(()=>{o(e=>e<=1?(clearInterval(t),0):e-1)},1e3);return()=>clearInterval(t)},[e?.planId]),(0,A.useEffect)(()=>{a===0&&e&&!s&&(c(!0),n(e.taskId,e.planId,`timeout`).catch(()=>{}))},[a,e,s,n]);let l=async n=>{if(e){c(!0);try{await t(e.taskId,e.planId,n)}catch{c(!1)}}},u=async()=>{if(e){c(!0);try{await n(e.taskId,e.planId)}catch{c(!1)}}},d=e?.plan;return(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(ji,{open:!!e,children:(0,j.jsxs)(Fi,{className:`max-w-2xl max-h-[80vh] overflow-y-auto`,children:[(0,j.jsxs)(Ii,{children:[(0,j.jsxs)(Ri,{className:`flex items-center gap-2`,children:[`Execution Plan — Approval Required`,d&&(0,j.jsxs)(Ui,{variant:Ki(d.overallRisk),children:[d.overallRisk.toUpperCase(),` RISK`]})]}),(0,j.jsxs)(zi,{className:`text-xs text-slate-400`,children:[`Plan `,e?.planId,` | Task `,e?.taskId,` | `,a,`s remaining`]})]}),d&&(0,j.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`h4`,{className:`text-sm font-medium text-slate-300 mb-2`,children:[`Plan Steps (`,d.steps.length,`)`]}),(0,j.jsx)(`div`,{className:`space-y-2`,children:d.steps.map(e=>(0,j.jsxs)(`div`,{className:`rounded-md border border-slate-700 bg-slate-800/50 p-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsxs)(`span`,{className:`text-xs font-mono text-slate-500`,children:[`#`,e.index]}),(0,j.jsx)(`span`,{className:`text-sm text-slate-200`,children:e.description})]}),(0,j.jsx)(Ui,{variant:Ki(e.riskLevel),children:e.riskLevel})]}),(0,j.jsxs)(`div`,{className:`mt-1 text-xs text-slate-400`,children:[`Tools: `,e.toolsNeeded.join(`, `)||`none`]})]},e.index))})]}),Object.keys(d.requiredPermissions).length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h4`,{className:`text-sm font-medium text-slate-300 mb-1`,children:`Required Permissions`}),(0,j.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.keys(d.requiredPermissions).map(e=>(0,j.jsx)(Ui,{variant:`secondary`,children:e},e))})]})]}),(0,j.jsxs)(Li,{children:[(0,j.jsx)(Ai,{variant:`destructive`,onClick:u,disabled:s,children:`Deny`}),(0,j.jsx)(Ai,{variant:`outline`,onClick:()=>l(`permanent`),disabled:s,children:`Allow Permanent`}),(0,j.jsx)(Ai,{onClick:()=>l(`once`),disabled:s,children:`Allow Once`})]})]})}),r&&(0,j.jsxs)(`div`,{className:`fixed bottom-4 right-4 z-50 rounded-md border border-amber-700 bg-amber-950 px-4 py-2 text-sm text-amber-200 shadow-lg`,children:[r,(0,j.jsx)(`button`,{className:`ml-3 text-amber-400 hover:text-amber-200`,onClick:i,children:`Dismiss`})]})]})}var Ji=(0,A.lazy)(()=>y(()=>import(`./Dashboard-DlrAor-C.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([0,1,2,3,4,5,6,7]))),Yi=(0,A.lazy)(()=>y(()=>import(`./Chat-Dvt_Oo7d.js`).then(e=>({default:e.Chat})),__vite__mapDeps([8,1,2,3,5,9,7]))),Xi=(0,A.lazy)(()=>y(()=>import(`./Work-CCLTkitf.js`).then(e=>({default:e.Work})),__vite__mapDeps([10,1,2,3,11,5,4,12,13,7,6]))),Zi=(0,A.lazy)(()=>y(()=>import(`./TaskDetail-jMBJbaRU.js`).then(e=>({default:e.TaskDetail})),__vite__mapDeps([14,1,2,3,5,4,7]))),Qi=(0,A.lazy)(()=>y(()=>import(`./Plugins-XlBr07x8.js`).then(e=>({default:e.Plugins})),__vite__mapDeps([15,1,2,3,5,4,12,6,7]))),$i=(0,A.lazy)(()=>y(()=>import(`./Strategies-Cf4ghknk.js`).then(e=>({default:e.Strategies})),__vite__mapDeps([16,1,2,3,4,5,12,6,7]))),ea=(0,A.lazy)(()=>y(()=>import(`./Goals-CkPQOev6.js`).then(e=>({default:e.Goals})),__vite__mapDeps([13,1,2,3,5,4,12,7]))),ta=(0,A.lazy)(()=>y(()=>import(`./Logs-D33PqDAd.js`).then(e=>({default:e.Logs})),__vite__mapDeps([17,1,2,3,4,5,12]))),na=(0,A.lazy)(()=>y(()=>import(`./Settings-Bjh_RXYf.js`).then(e=>({default:e.Settings})),__vite__mapDeps([18,1,2,3,5,4,12,7]))),ra=(0,A.lazy)(()=>y(()=>import(`./Memories-D31dbUM6.js`).then(e=>({default:e.Memories})),__vite__mapDeps([19,1,2,3,5,4,12,7]))),ia=(0,A.lazy)(()=>y(()=>import(`./Evolution-Dlsnnr4G.js`).then(e=>({default:e.Evolution})),__vite__mapDeps([20,1,2,3,5,4,12,7]))),aa=(0,A.lazy)(()=>y(()=>import(`./Channels-Bhy6rP_t.js`).then(e=>({default:e.Channels})),__vite__mapDeps([21,1,2,3,5,4,12]))),oa=(0,A.lazy)(()=>y(()=>import(`./GoalDetail-BuUxwYdd.js`).then(e=>({default:e.GoalDetail})),__vite__mapDeps([22,1,2,3,5,4,7]))),sa=(0,A.lazy)(()=>y(()=>import(`./ChannelDetail-BajTUEU0.js`).then(e=>({default:e.ChannelDetail})),__vite__mapDeps([23,1,2,3,5,4,7]))),ca=(0,A.lazy)(()=>y(()=>import(`./Roles-d29AC6Kh.js`).then(e=>({default:e.Roles})),__vite__mapDeps([24,1,2,3,4,5,12,6,7]))),la=(0,A.lazy)(()=>y(()=>import(`./RoleDetail-rZFlgXzh.js`).then(e=>({default:e.RoleDetail})),__vite__mapDeps([25,1,2,3,11,5,4,6,7]))),ua=(0,A.lazy)(()=>y(()=>import(`./NotFound-Cidygwnn.js`),__vite__mapDeps([26,2,1,3])));function da(){return(0,j.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,j.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-slate-700 border-t-blue-500`})})}function fa(){return(0,j.jsxs)(A.Suspense,{fallback:(0,j.jsx)(da,{}),children:[(0,j.jsx)(ee,{children:(0,j.jsxs)(C,{element:(0,j.jsx)(Ae,{}),children:[(0,j.jsx)(C,{index:!0,element:(0,j.jsx)(Ji,{})}),(0,j.jsx)(C,{path:`chat`,element:(0,j.jsx)(Yi,{})}),(0,j.jsx)(C,{path:`work`,element:(0,j.jsx)(Xi,{})}),(0,j.jsx)(C,{path:`tasks/:id`,element:(0,j.jsx)(Zi,{})}),(0,j.jsx)(C,{path:`plugins`,element:(0,j.jsx)(Qi,{})}),(0,j.jsx)(C,{path:`roles`,element:(0,j.jsx)(ca,{})}),(0,j.jsx)(C,{path:`roles/:id`,element:(0,j.jsx)(la,{})}),(0,j.jsx)(C,{path:`channels`,element:(0,j.jsx)(aa,{})}),(0,j.jsx)(C,{path:`channels/:id`,element:(0,j.jsx)(sa,{})}),(0,j.jsx)(C,{path:`strategies`,element:(0,j.jsx)($i,{})}),(0,j.jsx)(C,{path:`goals`,element:(0,j.jsx)(ea,{})}),(0,j.jsx)(C,{path:`goals/:id`,element:(0,j.jsx)(oa,{})}),(0,j.jsx)(C,{path:`logs`,element:(0,j.jsx)(ta,{})}),(0,j.jsx)(C,{path:`settings`,element:(0,j.jsx)(na,{})}),(0,j.jsx)(C,{path:`memories`,element:(0,j.jsx)(ra,{})}),(0,j.jsx)(C,{path:`evolution`,element:(0,j.jsx)(ia,{})}),(0,j.jsx)(C,{path:`*`,element:(0,j.jsx)(ua,{})})]})}),(0,j.jsx)(qi,{})]})}var pa=v([{path:`*`,element:(0,j.jsx)(fa,{})}],{basename:`/ui`});(0,k.createRoot)(document.getElementById(`root`)).render((0,j.jsx)(A.StrictMode,{children:(0,j.jsx)(re,{children:(0,j.jsx)(S,{router:pa})})}));export{H as C,Me as S,ze as _,Vi as a,G as b,Li as c,Mi as d,Ai as f,He as g,q as h,Bi as i,Ii as l,Xe as m,Wi as n,Fi as o,kt as p,ji as r,zi as s,Ui as t,Ri as u,Le as v,ge as w,W as x,K as y};
@@ -5,13 +5,13 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/ui/favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Adam</title>
8
- <script type="module" crossorigin src="/ui/assets/index-CfKqiQIe.js"></script>
8
+ <script type="module" crossorigin src="/ui/assets/index-Ds41VvOC.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/ui/assets/rolldown-runtime-Dw2cE7zH.js">
10
10
  <link rel="modulepreload" crossorigin href="/ui/assets/vendor-icons-ZPvC5PUS.js">
11
11
  <link rel="modulepreload" crossorigin href="/ui/assets/vendor-react--nRVf2Ep.js">
12
12
  <link rel="modulepreload" crossorigin href="/ui/assets/dist-HyCSN_hp.js">
13
13
  <link rel="modulepreload" crossorigin href="/ui/assets/vendor-state-CH64feAE.js">
14
- <link rel="stylesheet" crossorigin href="/ui/assets/index-LDFr0VVR.css">
14
+ <link rel="stylesheet" crossorigin href="/ui/assets/index-CVubgAlC.css">
15
15
  </head>
16
16
  <body class="bg-slate-950 text-slate-100">
17
17
  <div id="root"></div>
@@ -1,9 +0,0 @@
1
- import{b as T,d as Dt,e as mo}from"./chunk-NSJAV7IH.js";import{a as At,e as co,g as uo}from"./chunk-SFUS33SO.js";import"./chunk-3DAK2XWP.js";import"./chunk-FCV2DPZQ.js";import{Box as kt,Text as xt,useInput as Fn}from"ink";import{useState as Wn,useEffect as Ht,useRef as lo}from"react";import{createContext as dr,useContext as ur,useReducer as mr}from"react";import{jsx as pr}from"react/jsx-runtime";var gr={connected:!1,serverInfo:null,activeTasks:0,queuedTasks:0,costToday:0,activeTaskId:null,activeTaskSubmitted:!1,pendingApproval:null,pendingPlanApproval:null,planTimeoutNotice:null,serverUnreachable:!1,view:"chat",configVersion:0,session:null,version:null};function fr(e,t){switch(t.type){case"SET_CONNECTED":return{...e,connected:t.connected};case"SET_SERVER_INFO":return{...e,serverInfo:t.info};case"UPDATE_STATS":return{...e,activeTasks:t.activeTasks,queuedTasks:t.queuedTasks,costToday:t.costToday};case"SET_ACTIVE_TASK":return{...e,activeTaskId:t.taskId,activeTaskSubmitted:!1};case"TASK_SUBMITTED":return{...e,activeTaskSubmitted:!0};case"SET_PENDING_APPROVAL":return{...e,pendingApproval:t.approval};case"SET_SERVER_UNREACHABLE":return{...e,serverUnreachable:t.unreachable};case"SET_VIEW":return{...e,view:t.view};case"CONFIG_CHANGED":return{...e,configVersion:e.configVersion+1};case"SET_SESSION":return{...e,session:t.session};case"SET_PENDING_PLAN_APPROVAL":return{...e,pendingPlanApproval:t.approval};case"SET_PLAN_TIMEOUT_NOTICE":return{...e,pendingPlanApproval:null,planTimeoutNotice:t.planId?{planId:t.planId}:null};case"SET_VERSION":return{...e,version:t.version};default:return e}}var go=dr(null);function fo({children:e}){let[t,o]=mr(fr,gr);return pr(go.Provider,{value:{state:t,dispatch:o},children:e})}function Xe(){let e=ur(go);if(!e)throw new Error("useTuiState must be used within TuiProvider");return e}import{useEffect as po,useRef as xo}from"react";var xr=15e3;function To(){let{state:e,dispatch:t}=Xe(),o=xo(null),d=xo(null);po(()=>{d.current=e.session?.id??null},[e.session?.id]),po(()=>{let u=!0,m=null,l=()=>{o.current&&(clearTimeout(o.current),o.current=null)},i=()=>{l(),o.current=setTimeout(()=>{u&&t({type:"SET_SERVER_UNREACHABLE",unreachable:!0})},xr)};return(()=>{try{m=new Dt("/events"),m.on("task_status_change",()=>{}),m.on("approval_request",r=>{if(!u)return;let a=r;t({type:"SET_PENDING_APPROVAL",approval:{taskId:a.taskId,approvalId:a.approvalId,toolName:a.toolName,toolInput:a.toolInput,matchedPattern:a.matchedPattern}})}),m.on("plan_approval_request",r=>{if(!u)return;let a=r;t({type:"SET_PENDING_PLAN_APPROVAL",approval:{taskId:a.taskId,planId:a.planId,roleId:a.roleId,plan:a.plan}})}),m.on("plan_approval_decision",()=>{u&&t({type:"SET_PENDING_PLAN_APPROVAL",approval:null})}),m.on("config_changed",()=>{u&&t({type:"CONFIG_CHANGED"})}),m.on("execution_task_start",r=>{if(!u)return;let a=r,c=d.current;c&&(async()=>{try{let h=await T(`/tasks/${a.taskId}`);u&&h.sourceSessionId===c&&t({type:"SET_ACTIVE_TASK",taskId:a.taskId})}catch{}})()}),m.on("stats_update",r=>{if(!u)return;let a=r;t({type:"UPDATE_STATS",activeTasks:a.activeTasks,queuedTasks:a.queuedTasks,costToday:a.totalCostToday})}),m.connect().then(async()=>{if(u){l(),t({type:"SET_CONNECTED",connected:!0}),t({type:"SET_SERVER_UNREACHABLE",unreachable:!1});try{let r=await T("/version");t({type:"SET_VERSION",version:r.version})}catch{t({type:"SET_VERSION",version:null})}}}).catch(()=>{u&&(t({type:"SET_CONNECTED",connected:!1}),i())})}catch{u&&(t({type:"SET_CONNECTED",connected:!1}),i())}})(),()=>{u=!1,l(),m?.close()}},[t])}import{useEffect as Tr,useRef as hr,useState as ho,useCallback as yr}from"react";function yo(e){let[t,o]=ho([]),[d,u]=ho(!1),m=hr(null),l=yr(()=>{o([]),u(!1)},[]);return Tr(()=>{if(!e)return;let i=!0;o([]),u(!0);try{let s=new mo(e);return m.current=s,s.on("reasoning",r=>{if(!i)return;let c=r.content??"";o(h=>{let f=h[h.length-1];if(f?.type==="reasoning"){let x=[...h];return x[x.length-1]={...f,content:f.content+c},x}return[...h,{type:"reasoning",content:c,timestamp:Date.now()}]})}),s.on("tool_call",r=>{if(!i)return;let a=r;o(c=>[...c,{type:"tool_call",content:a.toolName??"unknown tool",timestamp:Date.now(),metadata:{toolName:a.toolName}}])}),s.on("tool_result",r=>{if(!i)return;let a=r;o(c=>[...c,{type:"tool_result",content:a.content??"",timestamp:Date.now()}])}),s.on("error",r=>{if(!i)return;let a=r;o(c=>[...c,{type:"error",content:a.error??"unknown error",timestamp:Date.now()}])}),s.on("complete",r=>{if(!i)return;let a=r;o(c=>[...c,{type:"complete",content:a.result??"",timestamp:Date.now(),metadata:{cost:a.costUsd,turns:a.numTurns,duration:a.totalDurationMs}}]),u(!1)}),s.connect().catch(()=>{i&&(o(r=>[...r,{type:"error",content:"Failed to connect to task stream",timestamp:Date.now()}]),u(!1))}),()=>{i=!1,s.close()}}catch{u(!1)}},[e]),{events:t,isStreaming:d,clearEvents:l}}import{useState as Kt,useEffect as br,useCallback as ht}from"react";function jt(e){return{id:e.id,status:e.status,messageCount:e.messageCount,createdAt:e.createdAt,lastActiveAt:e.lastActiveAt,title:e.title}}function bo(){let[e,t]=Kt(null),[o,d]=Kt(!0),[u,m]=Kt(null),l=ht(async()=>{try{let h=(await T("/chat/sessions?status=active")).sessions.find(f=>f.source.type==="tui");return h?jt(h):null}catch{return null}},[]),i=ht(async()=>{try{let c=await T("/chat/sessions",{method:"POST",body:{source:{type:"tui"}}}),h=jt(c.session);return t(h),h}catch{return m("Failed to create session"),null}},[]),s=ht(async c=>{try{let h=await T("/chat/messages",{method:"POST",body:{content:c,source:{type:"tui"}}});return t(f=>f&&{...f,messageCount:f.messageCount+1,lastActiveAt:Date.now()}),h}catch{return null}},[]),r=ht(async()=>{if(!e)return!1;try{return await T(`/chat/sessions/${e.id}/archive`,{method:"POST"}),t(null),!0}catch{return!1}},[e]),a=ht(async()=>{if(e)try{let c=await T(`/chat/sessions/${e.id}`);t(jt(c.session))}catch{t(null)}},[e]);return br(()=>{let c=!1;async function h(){d(!0);let f=await l();c||(f?t(f):await i(),c||d(!1))}return h(),()=>{c=!0}},[]),{session:e,loading:o,error:u,sendMessage:s,createNewSession:i,archiveCurrentSession:r,refreshSession:a,setSession:t}}import{useEffect as So,useRef as Sr,useState as Cr}from"react";function Co(e){let[t,o]=Cr(null),d=Sr(new Set);return So(()=>{if(!e)return;let u=!0,m=null;try{m=new Dt("/chat/stream"),m.on("chat_message",l=>{if(!u)return;let s=l.message;s&&s.sessionId===e&&s.role==="assistant"&&(d.current.has(s.id)||(d.current.add(s.id),o(s)))}),m.connect().catch(()=>{})}catch{}return()=>{u=!1,m?.close()}},[e]),So(()=>{d.current.clear(),o(null)},[e]),{latestMessage:t}}import{Box as Xt,Text as ve}from"ink";import Ce from"chalk";var Qt={connected:Ce.green,disconnected:Ce.red,warning:Ce.yellow,reasoning:Ce.gray,toolCall:Ce.blue,toolResult:Ce.green,error:Ce.red,dim:Ce.dim,bold:Ce.bold,statusUp:Ce.green("\u25CF"),statusDown:Ce.red("\u25CF")};import{Fragment as vr,jsx as tt,jsxs as ze}from"react/jsx-runtime";function vo(){let{state:e}=Xe(),t=e.connected?`${Qt.statusUp} Server: up`:`${Qt.statusDown} Disconnected`,o=e.activeTasks>0?`${e.activeTasks} running, ${e.queuedTasks} queued`:"No active tasks",d=e.session,m=(d?Math.floor((Date.now()-d.lastActiveAt)/6e4):1/0)>=25;return ze(Xt,{flexDirection:"column",borderStyle:"round",borderDimColor:!0,children:[ze(Xt,{children:[tt(ve,{bold:!0,children:e.version?`Adam v${e.version}`:"Adam"}),tt(ve,{children:" \u2502 "}),tt(ve,{children:t}),tt(ve,{children:" \u2502 "}),ze(ve,{children:["Tasks: ",e.activeTasks," active"]}),e.view==="chat"&&d&&ze(vr,{children:[tt(ve,{children:" \u2502 "}),ze(ve,{children:["Session: ",d.messageCount===0?"(new)":`${d.id.slice(0,8)} (${d.messageCount} turns)`]}),m&&tt(ve,{color:"yellow",children:" timeout soon"})]})]}),ze(Xt,{children:[ze(ve,{children:["Tasks: ",o]}),tt(ve,{children:" \u2502 "}),ze(ve,{children:["Cost: $",e.costToday.toFixed(2)," today"]})]})]})}import{Box as Rt,Text as Mt,useInput as wr}from"ink";import{useState as Yt,useMemo as Br}from"react";import Ir from"ink-text-input";var Er=[{name:"work",description:"Tasks, Automations & Goals"},{name:"config",description:"Configuration"},{name:"evolution",description:"Evolution audit"},{name:"webhooks",description:"Webhook triggers"},{name:"memories",description:"Memory browser"},{name:"strategies",description:"Strategy lab"},{name:"plugins",description:"Plugin management"},{name:"roles",description:"Role management"},{name:"settings",description:"Runtime settings"},{name:"back",description:"Return to chat"},{name:"quit",description:"Exit TUI"}];function zt(e){let t=e.toLowerCase();return Er.filter(o=>o.name.startsWith(t))}function Eo(e){let t=zt(e.toLowerCase());return t.length===1?t[0]:void 0}import{jsx as Nt,jsxs as yt}from"react/jsx-runtime";function wo({onSubmit:e}){let[t,o]=Yt(""),[d,u]=Yt(0),[m,l]=Yt(!1),i=t.startsWith("/")&&t.length>=1,s=t.slice(1),r=Br(()=>i?zt(s):[],[i,s]),a=f=>{o(f),f.startsWith("/")?(l(!0),u(0)):l(!1)},c=()=>{let f=t.trim();if(f){if(f.startsWith("/")){let x=f.slice(1),n=Eo(x);e(n?`/${n.name}`:f)}else e(f);o(""),l(!1)}},h=f=>{e(`/${f.name}`),o(""),l(!1)};return wr((f,x)=>{if(!(!m||!i||r.length===0)){if(x.upArrow){u(n=>n<=0?r.length-1:n-1);return}if(x.downArrow){u(n=>n>=r.length-1?0:n+1);return}if(x.tab){let n=r[d];n&&h(n);return}if(x.escape){l(!1),o("");return}}},{isActive:m&&i&&r.length>0}),yt(Rt,{flexDirection:"column",children:[m&&i&&r.length>0&&Nt(Rt,{flexDirection:"column",marginBottom:0,paddingX:1,children:r.map((f,x)=>{let n=x===d;return yt(Rt,{children:[Nt(Mt,{color:n?"cyan":"gray",bold:n,children:n?"\u25B8 ":" "}),yt(Mt,{color:n?"cyan":"white",bold:n,children:["/",f.name]}),yt(Mt,{dimColor:!0,children:[" \u2014 ",f.description]})]},f.name)})}),yt(Rt,{borderStyle:"round",borderDimColor:!0,children:[Nt(Mt,{bold:!0,children:"\u25B8 "}),Nt(Ir,{value:t,onChange:a,onSubmit:c,placeholder:"Type a message or / for commands..."})]})]})}import{Box as it,Text as ge}from"ink";import{useState as kr}from"react";import{jsx as ye,jsxs as Ae}from"react/jsx-runtime";function Pr({content:e}){let[t,o]=kr(!1),d=e.split(`
2
- `);return d.length<=5?ye(ge,{color:"green",children:e}):t?ye(ge,{color:"green",children:e}):Ae(ge,{color:"green",children:[d.slice(0,3).join(`
3
- `),`
4
- `,Ae(ge,{dimColor:!0,children:["(",d.length," lines) \u25B8 \u5C55\u5F00"]})]})}function Ar({event:e}){switch(e.type){case"reasoning":return ye(it,{children:ye(ge,{color:"gray",children:e.content})});case"tool_call":return ye(it,{children:Ae(ge,{color:"blue",children:["[tool] ",e.metadata?.toolName??e.content]})});case"tool_result":return Ae(it,{flexDirection:"column",children:[ye(ge,{color:"blue",dimColor:!0,children:"[result]"}),ye(Pr,{content:e.content})]});case"error":return ye(it,{children:Ae(ge,{color:"red",children:["[error] ",e.content]})});case"complete":return Ae(it,{flexDirection:"column",marginTop:1,children:[e.content&&ye(ge,{children:e.content}),ye(ge,{dimColor:!0,children:"\u2500\u2500\u2500 Task complete \u2500\u2500\u2500"}),e.metadata?.cost!==void 0&&Ae(ge,{dimColor:!0,children:["Cost: $",e.metadata.cost.toFixed(4)]}),e.metadata?.turns!==void 0&&Ae(ge,{dimColor:!0,children:["Turns: ",e.metadata.turns]}),e.metadata?.duration!==void 0&&Ae(ge,{dimColor:!0,children:["Duration: ",(e.metadata.duration/1e3).toFixed(1),"s"]})]});default:return null}}function Bo({events:e,isStreaming:t}){return e.length===0&&!t?null:Ae(it,{flexDirection:"column",children:[t&&e.length===0&&ye(ge,{dimColor:!0,children:"Waiting for response..."}),e.map((o,d)=>ye(Ar,{event:o},d))]})}import{Box as Io,Text as ko}from"ink";import{jsx as Jt,jsxs as Dr}from"react/jsx-runtime";function Po({messages:e}){return e.length===0?null:Jt(Io,{flexDirection:"column",children:e.map((t,o)=>Dr(Io,{flexDirection:"column",marginBottom:1,children:[Jt(ko,{dimColor:!0,bold:!0,children:t.role==="user"?"You:":"Adam:"}),Jt(ko,{children:t.content})]},o))})}import{Box as bt,Text as De,useInput as Rr}from"ink";import{jsx as Re,jsxs as St}from"react/jsx-runtime";function Ao({approval:e,onResolved:t}){return Rr(o=>{o==="a"?T(`/tasks/${e.taskId}/approve`,{method:"POST",body:{approvalId:e.approvalId}}).then(()=>t()).catch(()=>t()):o==="r"&&T(`/tasks/${e.taskId}/reject`,{method:"POST",body:{approvalId:e.approvalId,reason:"rejected by user"}}).then(()=>t()).catch(()=>t())}),St(bt,{flexDirection:"column",borderStyle:"round",borderColor:"yellow",paddingX:1,children:[Re(De,{bold:!0,color:"yellow",children:"\u26A0 APPROVAL REQUIRED"}),St(bt,{marginTop:1,children:[Re(De,{children:"Tool: "}),Re(De,{bold:!0,children:e.toolName})]}),St(bt,{children:[Re(De,{children:"Input: "}),Re(De,{children:JSON.stringify(e.toolInput)})]}),St(bt,{children:[Re(De,{children:"Pattern: "}),Re(De,{dimColor:!0,children:e.matchedPattern})]}),St(bt,{marginTop:1,children:[Re(De,{color:"green",children:"[a] Approve"}),Re(De,{children:" "}),Re(De,{color:"red",children:"[r] Reject"})]})]})}import{Box as Ct,Text as le,useInput as Mr}from"ink";import{useState as Nr,useEffect as Lr}from"react";import{jsx as Oe,jsxs as Ee}from"react/jsx-runtime";var _r=300;function Do({approval:e,onResolved:t,onTimeout:o}){let[d,u]=Nr(_r);Lr(()=>{let l=setInterval(()=>{u(i=>i<=1?(clearInterval(l),o(),0):i-1)},1e3);return()=>clearInterval(l)},[o]),Mr(l=>{l==="a"?T(`/tasks/${e.taskId}/approve-plan`,{method:"POST",body:{planId:e.planId,decision:"allow",approvalType:"once"}}).then(()=>t()).catch(()=>t()):l==="r"?T(`/tasks/${e.taskId}/approve-plan`,{method:"POST",body:{planId:e.planId,decision:"deny",reason:"rejected by user"}}).then(()=>t()).catch(()=>t()):l==="p"&&T(`/tasks/${e.taskId}/approve-plan`,{method:"POST",body:{planId:e.planId,decision:"allow",approvalType:"permanent"}}).then(()=>t()).catch(()=>t())});let m=e.plan.overallRisk==="high"?"red":e.plan.overallRisk==="medium"?"yellow":"green";return Ee(Ct,{flexDirection:"column",borderStyle:"round",borderColor:"cyan",paddingX:1,children:[Oe(le,{bold:!0,color:"cyan",children:"EXECUTION PLAN \u2014 APPROVAL REQUIRED"}),Ee(le,{dimColor:!0,children:["Plan ID: ",e.planId]}),Ee(le,{dimColor:!0,children:["Time remaining: ",d,"s"]}),Ee(Ct,{marginTop:1,children:[Oe(le,{children:"Overall Risk: "}),Oe(le,{bold:!0,color:m,children:e.plan.overallRisk.toUpperCase()})]}),Ee(le,{bold:!0,children:["Steps (",e.plan.steps.length,"):"]}),e.plan.steps.map(l=>{let i=l.riskLevel==="high"?"red":l.riskLevel==="medium"?"yellow":"green";return Ee(Ct,{paddingLeft:2,children:[Ee(le,{children:["[",l.index,"] "]}),Oe(le,{children:l.description}),Ee(le,{dimColor:!0,children:[" (",l.toolsNeeded.join(", "),")"]}),Ee(le,{color:i,children:[" [",l.riskLevel,"]"]})]},l.index)}),Ee(Ct,{marginTop:1,children:[Oe(le,{dimColor:!0,children:"Permissions: "}),Oe(le,{children:Object.keys(e.plan.requiredPermissions).join(", ")||"none"})]}),Ee(Ct,{marginTop:1,children:[Oe(le,{color:"green",children:"[a] Allow once "}),Oe(le,{color:"green",children:"[p] Allow permanent "}),Oe(le,{color:"red",children:"[r] Deny"})]})]})}import{Box as ot,Text as J,useInput as Vr}from"ink";import{useEffect as qr,useState as Ve,useCallback as Mo}from"react";import{Box as Q,Text as D,useInput as $r}from"ink";import{useState as Zt,useEffect as Or}from"react";import{jsx as $,jsxs as U}from"react/jsx-runtime";function Ro({taskId:e,onBack:t}){let[o,d]=Zt(null),[u,m]=Zt([]),[l,i]=Zt(null);if(Or(()=>{T(`/tasks/${e}`).then(r=>d(r)).catch(r=>i(r instanceof Error?r.message:String(r))),T(`/tasks/${e}/plan`).then(r=>m(r.plans)).catch(()=>m([]))},[e]),$r((r,a)=>{(r==="b"||a.escape)&&t()}),l)return U(Q,{flexDirection:"column",children:[U(D,{color:"red",children:["Error: ",l]}),$(D,{dimColor:!0,children:"[b] Back"})]});if(!o)return U(D,{dimColor:!0,children:["Loading task ",e,"..."]});let s=u[0];return U(Q,{flexDirection:"column",children:[$(D,{bold:!0,color:"cyan",children:"Task Detail"}),U(Q,{marginTop:1,flexDirection:"column",children:[U(Q,{children:[$(D,{children:"ID: "}),$(D,{dimColor:!0,children:String(o.id)})]}),U(Q,{children:[$(D,{children:"Status: "}),$(D,{bold:!0,children:String(o.status)})]}),U(Q,{children:[$(D,{children:"Prompt: "}),$(D,{children:String(o.prompt)})]}),o.result?U(Q,{children:[$(D,{children:"Result: "}),$(D,{children:String(o.result).slice(0,200)})]}):null,o.error?U(Q,{children:[$(D,{color:"red",children:"Error: "}),$(D,{children:String(o.error)})]}):null,o.deliverTo?.length?U(Q,{children:[$(D,{children:"DeliverTo: "}),$(D,{dimColor:!0,children:o.deliverTo.map(r=>r.type==="channel"?`channel ${r.channelId?.slice(0,8)}`:`session ${r.sessionId?.slice(0,8)}`).join(", ")})]}):null,o.reportTo?.length?U(Q,{children:[$(D,{children:"ReportTo: "}),$(D,{dimColor:!0,children:o.reportTo.map(r=>r.type==="channel"?`channel ${r.channelId?.slice(0,8)}`:`session ${r.sessionId?.slice(0,8)}`).join(", ")})]}):null]}),s&&U(Q,{marginTop:1,flexDirection:"column",children:[$(D,{bold:!0,color:"cyan",children:"Execution Plan"}),U(Q,{children:[$(D,{children:"Plan ID: "}),$(D,{dimColor:!0,children:s.id})]}),U(Q,{children:[$(D,{children:"Status: "}),$(D,{children:s.status})]}),s.plan.overallRisk&&U(Q,{children:[$(D,{children:"Overall Risk: "}),$(D,{bold:!0,color:s.plan.overallRisk==="high"?"red":s.plan.overallRisk==="medium"?"yellow":"green",children:s.plan.overallRisk.toUpperCase()})]}),U(D,{bold:!0,children:["Steps (",s.plan.steps.length,"):"]}),s.plan.steps.map(r=>{let a=r.riskLevel==="high"?"red":r.riskLevel==="medium"?"yellow":"green";return U(Q,{paddingLeft:2,children:[U(D,{children:["[",r.index,"] ",r.description]}),U(D,{color:a,children:[" [",r.riskLevel,"]"]})]},r.index)}),s.deviationReport&&U(Q,{marginTop:1,flexDirection:"column",children:[$(D,{bold:!0,color:"yellow",children:"Deviation Report"}),U(D,{children:["Planned: ",s.deviationReport.stepsPlanned," | Executed: ",s.deviationReport.stepsExecuted," | Accuracy: ",(s.deviationReport.overallAccuracy*100).toFixed(0),"%"]}),s.deviationReport.deviations.map((r,a)=>U(Q,{paddingLeft:2,children:[U(D,{color:"yellow",children:["[",r.deviationType,"] "]}),U(D,{children:["Step ",r.stepIndex,": ",r.actual]})]},a))]}),s.learnedRules&&s.learnedRules.length>0&&U(Q,{marginTop:1,flexDirection:"column",children:[$(D,{bold:!0,color:"blue",children:"Learned Rules"}),s.learnedRules.map((r,a)=>$(Q,{paddingLeft:2,children:U(D,{children:["* ",r]})},a))]})]}),!s&&u.length===0&&$(Q,{marginTop:1,children:$(D,{dimColor:!0,children:"No execution plan for this task."})}),$(Q,{marginTop:1,children:$(D,{dimColor:!0,children:"[b] Back"})})]})}import{Fragment as Wr,jsx as ce,jsxs as pe}from"react/jsx-runtime";var Ur={pending:"gray",queued:"gray",running:"yellow",paused:"yellow",completed:"green",failed:"red",cancelled:"gray"},Lt=["all","pending","queued","running","completed","failed","cancelled"],eo=15;function _t({onBack:e}){let[t,o]=Ve([]),[d,u]=Ve(!0),[m,l]=Ve("list"),[i,s]=Ve(0),[r,a]=Ve("all"),[c,h]=Ve(0),[f,x]=Ve(0),[n,g]=Ve(null),[R,k]=Ve([]),H=Mo(async()=>{u(!0);try{let B=new URLSearchParams({limit:"100"});r!=="all"&&B.set("status",r);let S=await T(`/tasks?${B}`);o(S.tasks)}catch{o([])}finally{u(!1)}},[r]);qr(()=>{H()},[H]);let W=Math.max(1,Math.ceil(t.length/eo)),I=t.slice(f*eo,(f+1)*eo),te=Mo(async()=>{let B=I[i];if(B)try{await T(`/tasks/${B.id}/cancel`,{method:"POST"}),g(`Cancelled: ${B.id.slice(0,8)}`),l("list"),H()}catch(S){g(`Failed: ${S instanceof Error?S.message:String(S)}`),l("list")}},[I,i,H]);return Vr((B,S)=>{if(m==="detail"){(S.escape||S.return||B==="q")&&l("list");return}if(m==="cancelling"){B==="y"?te():l("list");return}if(m==="filter"){if(S.escape){l("list");return}S.upArrow&&c>0&&h(p=>p-1),S.downArrow&&c<Lt.length-1&&h(p=>p+1),S.return&&(a(Lt[c]),x(0),s(0),l("list"));return}if(S.escape||B==="q"){e();return}if(S.upArrow&&i>0&&s(p=>p-1),S.downArrow&&i<I.length-1&&s(p=>p+1),S.return){let p=I[i];p&&(k([]),l("detail"),T(`/tasks/${p.id}/logs?limit=20`).then(({logs:P})=>k(P)).catch(()=>k([])))}if(B==="x"&&I[i]){let p=I[i];["running","pending","queued","paused"].includes(p.status)?(l("cancelling"),g(null)):g(`Cannot cancel task in status: ${p.status}`)}B==="f"&&(h(Lt.indexOf(r)),l("filter")),B==="r"&&H(),(S.pageDown||B==="n")&&f<W-1&&(x(p=>p+1),s(0)),(S.pageUp||B==="p")&&f>0&&(x(p=>p-1),s(0))}),d?ce(J,{dimColor:!0,children:"Loading tasks..."}):m==="filter"?pe(ot,{flexDirection:"column",children:[ce(J,{bold:!0,children:"Filter by status:"}),Lt.map((B,S)=>ce(ot,{children:pe(J,{color:S===c?"cyan":"white",children:[S===c?"> ":" ",B,B===r?" (current)":""]})},B)),ce(J,{dimColor:!0,children:"Enter: select Esc: cancel"})]}):m==="detail"&&I[i]?ce(Ro,{taskId:I[i].id,onBack:()=>l("list")}):m==="cancelling"&&I[i]?pe(ot,{flexDirection:"column",children:[pe(J,{color:"red",children:['Cancel task "',I[i].id.slice(0,8),'"? (y/n)']}),n&&ce(J,{color:"red",children:n})]}):pe(ot,{flexDirection:"column",children:[pe(ot,{children:[pe(J,{bold:!0,children:["Tasks (",t.length,")"]}),r!=="all"&&pe(J,{dimColor:!0,children:[" [filter: ",r,"]"]}),pe(J,{dimColor:!0,children:[" \u2014 Page ",f+1,"/",W]})]}),n&&ce(J,{color:n.startsWith("Failed")||n.startsWith("Cannot")?"red":"green",children:n}),t.length===0?pe(J,{dimColor:!0,children:["No tasks found",r!=="all"?` with status "${r}"`:"","."]}):pe(Wr,{children:[ce(ot,{marginTop:1,children:pe(J,{bold:!0,children:[" ",Ye("ID",10),Ye("STATUS",12),Ye("PROMPT",40),Ye("DURATION",10),"COST"]})}),I.map((B,S)=>{let p=S===i,P=B.totalDurationMs?`${(B.totalDurationMs/1e3).toFixed(0)}s`:"\u2014",N=B.costUsd!==void 0?`$${B.costUsd.toFixed(4)}`:"\u2014",_e=Ur[B.status]??"white";return pe(ot,{children:[ce(J,{color:p?"cyan":"white",children:p?"> ":" "}),ce(J,{dimColor:!0,children:Ye(B.id.slice(0,8),10)}),ce(J,{color:_e,children:Ye(B.status,12)}),ce(J,{children:Ye(Fr(B.prompt,38),40)}),ce(J,{dimColor:!0,children:Ye(P,10)}),ce(J,{dimColor:!0,children:N})]},B.id)})]}),ce(J,{dimColor:!0,children:"Enter:detail x:cancel f:filter n/p:page r:refresh Esc/q:back"})]})}function Ye(e,t){return e?e.length>=t?e:e+" ".repeat(t-e.length):" ".repeat(t)}function Fr(e,t){return e.length<=t?e:e.slice(0,t-3)+"..."}uo();import{Box as vt,Text as we,useInput as Gr}from"ink";import{useEffect as Hr,useState as No}from"react";import{readFileSync as Kr,existsSync as jr}from"fs";import{parse as Qr}from"yaml";import{Fragment as Xr,jsx as Be,jsxs as Je}from"react/jsx-runtime";function _o({onBack:e}){let[t,o]=No(null),[d,u]=No(null);return Gr((m,l)=>{(l.escape||m==="q")&&e()}),Hr(()=>{try{let m=co;if(!jr(m)){u(`Config file not found: ${m}`);return}let l=Kr(m,"utf-8");o(Qr(l))}catch(m){u(m.message)}},[]),d?Je(vt,{flexDirection:"column",children:[Be(we,{color:"red",children:d}),Be(we,{dimColor:!0,children:"Press Esc to go back"})]}):t?Je(vt,{flexDirection:"column",children:[Be(we,{bold:!0,children:"Configuration (Esc to go back)"}),Be(vt,{marginTop:1,flexDirection:"column",children:Be($o,{obj:t,indent:0})})]}):Be(we,{dimColor:!0,children:"Loading config..."})}function $o({obj:e,indent:t}){let o=" ".repeat(t);return Be(Xr,{children:Object.entries(e).map(([d,u])=>u&&typeof u=="object"&&!Array.isArray(u)?Je(vt,{flexDirection:"column",children:[Je(we,{children:[o,Be(we,{color:"cyan",children:d}),":"]}),Be($o,{obj:u,indent:t+1})]},d):Array.isArray(u)?Je(vt,{flexDirection:"column",children:[Je(we,{children:[o,Be(we,{color:"cyan",children:d}),":"]}),u.map((m,l)=>Je(we,{children:[o," - ",Lo(d,String(m))]},l))]},d):Je(we,{children:[o,Be(we,{color:"cyan",children:d}),": ",Lo(d,String(u))]},d))})}function Lo(e,t){return e.toLowerCase().includes("key")||e.toLowerCase().includes("token")?!t||t.length<8?"****":t.slice(0,4)+"****":t}import{Box as $t,Text as Ie,useInput as zr}from"ink";import{useEffect as Yr,useState as to}from"react";import{jsx as Et,jsxs as Me}from"react/jsx-runtime";function Oo({onBack:e}){let[t,o]=to([]),[d,u]=to(!0),[m,l]=to(null);return zr((i,s)=>{(s.escape||i==="q")&&e()}),Yr(()=>{T("/evolution-audit?limit=20").then(i=>{o(i),u(!1)}).catch(i=>{l(i.message),u(!1)})},[]),d?Et(Ie,{dimColor:!0,children:"Loading evolution log..."}):m?Me($t,{flexDirection:"column",children:[Et(Ie,{color:"red",children:m}),Et(Ie,{dimColor:!0,children:"Press Esc to go back"})]}):t.length===0?Me($t,{flexDirection:"column",children:[Et(Ie,{dimColor:!0,children:"No evolution records yet"}),Et(Ie,{dimColor:!0,children:"Press Esc to go back"})]}):Me($t,{flexDirection:"column",children:[Me(Ie,{bold:!0,children:["Evolution Audit Log (",t.length," records) \u2014 Esc to go back"]}),t.map(i=>Me($t,{flexDirection:"column",marginTop:1,children:[Me(Ie,{bold:!0,children:["[",new Date(i.timestamp).toLocaleString(),"]"]}),i.triggerTaskId&&Me(Ie,{dimColor:!0,children:[" Task: ",i.triggerTaskId.slice(0,8)]}),i.diff.split(`
5
- `).map((s,r)=>s.startsWith("+")?Me(Ie,{color:"green",children:[" ",s]},r):s.startsWith("-")?Me(Ie,{color:"red",children:[" ",s]},r):Me(Ie,{dimColor:!0,children:[" ",s]},r))]},i.id))]})}import{Box as qe,Text as X,useInput as Jr}from"ink";import Zr from"ink-text-input";import{useEffect as en,useState as at}from"react";import{jsx as fe,jsxs as oe}from"react/jsx-runtime";var tn={pending:"gray",planning:"cyan",executing:"yellow",evaluating:"blue",replanning:"magenta",completed:"green",failed:"red",paused:"gray"};function on(e,t=20){let o=Math.round(e*t),d=t-o;return"\u2588".repeat(o)+"\u2591".repeat(d)}function rn(e){let t=Math.max(0,Math.floor((e-Date.now())/864e5));return t===0?"< 1d":`${t}d`}function Ot({onBack:e}){let[t,o]=at([]),[d,u]=at(null),[m,l]=at("list"),[i,s]=at(""),[r,a]=at(!1),[c,h]=at(null);Jr((n,g)=>{if(m==="create"){g.escape&&(l("list"),s(""),h(null));return}(g.escape||n==="q")&&e(),n==="c"&&(l("create"),h(null)),n==="r"&&f()});let f=()=>{T("/goals?limit=20").then(({goals:n})=>o(n)).catch(n=>u(n.message))};en(()=>{f()},[]);let x=async n=>{if(n.trim()){a(!0),h(null);try{let g=await T("/goals",{method:"POST",body:{input:n.trim()}});h(`Goal created: ${g.goal.name}`),s(""),l("list"),f()}catch(g){h(`Failed: ${g instanceof Error?g.message:String(g)}`)}finally{a(!1)}}};return d?oe(qe,{flexDirection:"column",children:[oe(X,{color:"red",children:["Failed to load goals: ",d]}),fe(X,{dimColor:!0,children:"Press Esc or q to return"})]}):m==="create"?oe(qe,{flexDirection:"column",children:[fe(X,{bold:!0,children:"Create Goal"}),fe(X,{dimColor:!0,children:"Describe your SMART goal in natural language:"}),oe(qe,{marginTop:1,children:[fe(X,{color:"cyan",children:"> "}),fe(Zr,{value:i,onChange:s,onSubmit:x})]}),r&&fe(X,{color:"yellow",children:"Creating goal..."}),c&&fe(X,{color:c.startsWith("Failed")?"red":"green",children:c}),fe(X,{dimColor:!0,children:"Press Esc to cancel"})]}):oe(qe,{flexDirection:"column",children:[oe(X,{bold:!0,children:["Goal Dashboard (",t.length,")"]}),t.length===0?fe(X,{dimColor:!0,children:"No goals found. Press c to create one."}):fe(qe,{marginTop:1,flexDirection:"column",children:t.map(n=>{let g=n.targetValue>0?n.currentValue/n.targetValue:0,R=tn[n.status]??"white";return oe(qe,{marginBottom:1,flexDirection:"column",children:[oe(qe,{children:[fe(X,{bold:!0,color:R,children:n.name}),oe(X,{dimColor:!0,children:[" (",n.role,")"]}),fe(X,{dimColor:!0,children:" \u2014 "}),fe(X,{color:R,children:n.status})]}),oe(qe,{children:[oe(X,{dimColor:!0,children:[" ",on(g)," "]}),oe(X,{color:g>=1?"green":"white",children:[Math.round(g*100),"%"]}),oe(X,{dimColor:!0,children:[" (",n.currentValue,"/",n.targetValue," ",n.metricType,")"]})]}),oe(qe,{children:[oe(X,{dimColor:!0,children:[" \u23F0 ",rn(n.deadline)," left"]}),oe(X,{dimColor:!0,children:[" | \u{1F4B0} $",n.budgetUsd]}),oe(X,{dimColor:!0,children:[" | ID: ",n.id.slice(0,8)]})]})]},n.id)})}),fe(X,{dimColor:!0,children:"c:create r:refresh Esc/q:back"})]})}import{Box as lt,Text as be,useInput as nn}from"ink";import{useEffect as sn,useState as Vo}from"react";import{jsx as Fe,jsxs as Ue}from"react/jsx-runtime";function an(e,t,o=15){let d=e/(e+t),u=Math.round(d*o);return"\u2593".repeat(u)+"\u2591".repeat(o-u)}function qo({onBack:e}){let[t,o]=Vo([]),[d,u]=Vo(null);if(nn((l,i)=>{(i.escape||l==="q")&&e()}),sn(()=>{T("/strategies?limit=50").then(l=>o(l.strategies??[])).catch(l=>u(l.message))},[]),d)return Ue(lt,{flexDirection:"column",children:[Ue(be,{color:"red",children:["Failed to load strategies: ",d]}),Fe(be,{dimColor:!0,children:"Press Esc or q to return"})]});if(t.length===0)return Ue(lt,{flexDirection:"column",children:[Fe(be,{dimColor:!0,children:"No strategies yet. Strategies are created when goals are executed."}),Fe(be,{dimColor:!0,children:"Press Esc or q to return"})]});let m=new Map;for(let l of t){let i=`${l.role}/${l.taskType}`,s=m.get(i)??[];s.push(l),m.set(i,s)}return Ue(lt,{flexDirection:"column",children:[Fe(be,{bold:!0,children:"Strategy Lab"}),Fe(be,{dimColor:!0,children:"Thompson Sampling populations \u2014 higher bar = higher selection probability"}),Fe(lt,{marginTop:1,flexDirection:"column",children:Array.from(m.entries()).map(([l,i])=>Ue(lt,{marginBottom:1,flexDirection:"column",children:[Fe(be,{bold:!0,color:"cyan",children:l}),i.sort((s,r)=>{let a=s.alpha/(s.alpha+s.beta);return r.alpha/(r.alpha+r.beta)-a}).map(s=>{let r=s.alpha/(s.alpha+s.beta);return Ue(lt,{children:[Fe(be,{dimColor:!0,children:" "}),Ue(be,{children:[an(s.alpha,s.beta)," "]}),Ue(be,{color:r>.6?"green":r>.4?"yellow":"red",children:[(r*100).toFixed(0),"%"]}),Ue(be,{dimColor:!0,children:[" ",s.name," (\u03B1=",s.alpha.toFixed(1)," \u03B2=",s.beta.toFixed(1)," trials=",s.totalTrials,")"]})]},s.id)})]},l))}),Fe(be,{dimColor:!0,children:"Press Esc or q to return"})]})}import{Box as xe,Text as K,useInput as mn}from"ink";import oo from"ink-text-input";import{useEffect as gn,useState as We,useCallback as ct}from"react";import{CronExpressionParser as fn}from"cron-parser";import{useState as ln,useEffect as cn,useCallback as Uo,useRef as dn}from"react";var un=3e3;function Ze(){let[e,t]=ln(null),o=dn(null),d=Uo(()=>{o.current&&(clearTimeout(o.current),o.current=null),t(null)},[]),u=Uo((m,l)=>{o.current&&(clearTimeout(o.current),o.current=null),t({text:m,type:l}),l==="success"&&(o.current=setTimeout(()=>{t(null),o.current=null},un))},[]);return cn(()=>()=>{o.current&&clearTimeout(o.current)},[]),{message:e,setMessage:u,clearMessage:d}}import{jsx as j,jsxs as se}from"react/jsx-runtime";var ro=["manual","cron","event"],Vt={name:"",triggerType:"manual",cron:"",stepPrompt:""};function pn(e){try{return fn.parse(e).next().toDate().toLocaleString()}catch{return"invalid"}}function Ut({onBack:e}){let[t,o]=We([]),[d,u]=We(!0),[m,l]=We(0),[i,s]=We("list"),[r,a]=We({...Vt}),[c,h]=We("name"),[f,x]=We(null),{message:n,setMessage:g,clearMessage:R}=Ze(),[k,H]=We(!1),[W,I]=We(!1),te=ct(()=>{u(!0),T("/task-templates").then(({templates:b})=>{o(b),u(!1)}).catch(()=>u(!1))},[]);gn(()=>{te()},[te]);let B=i==="create"||i==="edit",S=ct(async()=>{let b=t[m];if(!(!b||k)){H(!0),g(`Triggering ${b.name}...`,"loading");try{let w=await T(`/task-templates/${b.id}/run`,{method:"POST"});g(`Triggered: ${b.name} (${w.executionId})`,"success")}catch(w){g(`Trigger failed: ${w instanceof Error?w.message:String(w)}`,"error")}finally{H(!1)}}},[t,m,k,g]),p=ct(async()=>{let b=t[m];if(!b||W)return;if(b.trigger?.type!=="cron"&&b.trigger?.type!=="event"){g("Toggle not applicable for manual triggers","error");return}let w=!b.enabled;I(!0),g(`${b.name} \u2192 ${w?"enabling":"disabling"}...`,"loading");try{await T(`/task-templates/${b.id}`,{method:"PATCH",body:{enabled:w}}),o(_=>_.map(ne=>ne.id===b.id?{...ne,enabled:w}:ne)),g(`${b.name} ${w?"enabled":"disabled"}`,"success")}catch(_){g(`Toggle failed: ${_ instanceof Error?_.message:String(_)}`,"error")}finally{I(!1)}},[t,m,W,g]),P=ct(async()=>{let b=t[m];if(b)try{await T(`/task-templates/${b.id}`,{method:"DELETE"}),g(`Deleted: ${b.name}`,"success"),te(),l(w=>Math.max(0,Math.min(w,t.length-2)))}catch(w){g(`Delete failed: ${w instanceof Error?w.message:String(w)}`,"error")}},[t,m,te]),N=ct(()=>{let b=t[m];b&&(x(b.id),a({name:b.name,triggerType:b.trigger?.type??"manual",cron:b.trigger?.cron??"",stepPrompt:b.steps?.[0]?.prompt??""}),h("name"),s("edit"))},[t,m]),_e=ct(async()=>{let b={name:r.name,trigger:{type:r.triggerType,...r.triggerType==="cron"?{cron:r.cron}:{}},steps:[{id:"step-1",prompt:r.stepPrompt}],enabled:!0};try{i==="create"?(await T("/task-templates",{method:"POST",body:b}),g(`Created: ${r.name}`,"success")):i==="edit"&&f&&(await T(`/task-templates/${f}`,{method:"PATCH",body:b}),g(`Updated: ${r.name}`,"success"))}catch(w){g(`Save failed: ${w instanceof Error?w.message:String(w)}`,"error")}s("list"),a({...Vt}),x(null),te()},[r,i,f,te]);return mn((b,w)=>{if(B){if(w.escape){s("list"),a({...Vt}),x(null);return}if(w.return){let _=["name","triggerType","cron","stepPrompt"],ne=_.indexOf(c);if(ne<_.length-1){let je=ne+1;if(_[je]==="cron"&&r.triggerType!=="cron"&&je++,je<_.length){h(_[je]);return}}_e();return}if(w.tab&&c==="triggerType"){a(_=>{let ne=ro.indexOf(_.triggerType);return{..._,triggerType:ro[(ne+1)%ro.length]}});return}return}if(w.escape||b==="q"){e();return}if(w.upArrow){l(_=>Math.max(0,_-1));return}if(w.downArrow){l(_=>Math.min(t.length-1,_+1));return}if(b==="t"){S();return}if(b==="d"){P();return}if(b==="e"){N();return}if(b==="c"){a({...Vt}),h("name"),s("create");return}if(b==="s"||b===" "){p();return}b==="r"&&(te(),R())}),d?j(K,{dimColor:!0,children:"Loading templates..."}):B?se(xe,{flexDirection:"column",children:[se(K,{bold:!0,children:[i==="create"?"Create Template":"Edit Template"," (Esc to cancel)"]}),se(xe,{marginTop:1,flexDirection:"column",children:[se(xe,{children:[se(K,{bold:c==="name",color:c==="name"?"cyan":void 0,children:["Name:"," "]}),c==="name"?j(oo,{value:r.name,onChange:b=>a(w=>({...w,name:b})),placeholder:"template name"}):j(K,{children:r.name||"(empty)"})]}),se(xe,{children:[se(K,{bold:c==="triggerType",color:c==="triggerType"?"cyan":void 0,children:["Trigger:"," "]}),j(K,{children:r.triggerType}),c==="triggerType"&&j(K,{dimColor:!0,children:" (Tab to cycle, Enter to continue)"})]}),r.triggerType==="cron"&&se(xe,{children:[se(K,{bold:c==="cron",color:c==="cron"?"cyan":void 0,children:["Cron:"," "]}),c==="cron"?j(oo,{value:r.cron,onChange:b=>a(w=>({...w,cron:b})),placeholder:"*/5 * * * *"}):j(K,{children:r.cron||"(empty)"})]}),se(xe,{children:[se(K,{bold:c==="stepPrompt",color:c==="stepPrompt"?"cyan":void 0,children:["Step Prompt:"," "]}),c==="stepPrompt"?j(oo,{value:r.stepPrompt,onChange:b=>a(w=>({...w,stepPrompt:b})),placeholder:"What should this template do?"}):j(K,{children:r.stepPrompt||"(empty)"})]})]}),j(xe,{marginTop:1,children:j(K,{dimColor:!0,children:"Enter: next field / submit | Esc: cancel"})})]}):se(xe,{flexDirection:"column",children:[se(K,{bold:!0,children:["Automations (",t.length,") (Esc to go back)"]}),n&&j(xe,{marginTop:1,children:se(K,{color:n.type==="success"?"green":n.type==="error"?"red":"gray",children:[n.type==="success"?"\u2713 ":n.type==="error"?"\u2717 ":"\u2192 ",n.text]})}),t.length===0?j(xe,{marginTop:1,children:j(K,{dimColor:!0,children:"No templates found. Press c to create one."})}):j(xe,{marginTop:1,flexDirection:"column",children:t.map((b,w)=>{let _=w===m,ne=b.trigger?.type==="cron"&&b.trigger?.cron?pn(b.trigger.cron):"";return se(xe,{children:[j(K,{color:_?"cyan":void 0,bold:_,children:_?"> ":" "}),j(K,{color:_?"cyan":void 0,bold:_,children:qt(b.name,24)}),j(K,{dimColor:!0,children:qt(b.trigger?.type,10)}),b.trigger?.type!=="cron"&&b.trigger?.type!=="event"?j(K,{dimColor:!0,children:qt("\u2014",6)}):j(K,{color:b.enabled?"green":"gray",children:qt(b.enabled?"on":"off",6)}),ne&&se(K,{dimColor:!0,children:["next: ",ne]})]},b.id)})}),j(xe,{marginTop:1,children:j(K,{dimColor:!0,children:"t:trigger s:toggle d:delete e:edit c:create r:refresh"})})]})}function qt(e,t){return e?e.length>=t?e:e+" ".repeat(t-e.length):" ".repeat(t)}import{Box as et,Text as Te,useInput as xn}from"ink";import Tn from"ink-text-input";import{useEffect as hn,useState as dt,useCallback as Fo}from"react";import{jsx as de,jsxs as rt}from"react/jsx-runtime";function Wo({onBack:e}){let[t,o]=dt([]),[d,u]=dt(""),[m,l]=dt(!0),[i,s]=dt(!1),[r,a]=dt(""),[c,h]=dt(null),f=Fo(()=>{l(!0),T("/webhooks").then(({webhooks:n,auth:g})=>{o(n),u(g),l(!1)}).catch(()=>l(!1))},[]);hn(()=>{f()},[f]);let x=Fo(async n=>{if(n.trim())try{let g=await T(`/webhooks/${encodeURIComponent(n.trim())}`,{method:"POST"});h(`Triggered: ${g.executionId}`)}catch(g){h(`Trigger failed: ${g instanceof Error?g.message:String(g)}`)}},[]);return xn((n,g)=>{if(i){if(g.escape){s(!1),a("");return}if(g.return){x(r),s(!1),a("");return}return}if(g.escape||n==="q"){e();return}if(n==="t"){s(!0),a(""),h(null);return}n==="r"&&(f(),h(null))}),m?de(Te,{dimColor:!0,children:"Loading webhooks..."}):rt(et,{flexDirection:"column",children:[rt(Te,{bold:!0,children:["Webhooks (",t.length,") (Esc to go back)"]}),rt(Te,{dimColor:!0,children:["Auth: ",d]}),c&&de(et,{marginTop:1,children:de(Te,{color:"yellow",children:c})}),i&&rt(et,{marginTop:1,children:[de(Te,{bold:!0,color:"cyan",children:"Trigger webhook: "}),de(Tn,{value:r,onChange:a,placeholder:"webhook name or ID"}),de(Te,{dimColor:!0,children:" (Enter to trigger, Esc to cancel)"})]}),t.length===0?de(et,{marginTop:1,children:de(Te,{dimColor:!0,children:"No webhooks available. Create templates with triggers to expose webhooks."})}):rt(et,{marginTop:1,flexDirection:"column",children:[de(et,{children:rt(Te,{bold:!0,children:[ut("NAME",24),ut("DESCRIPTION",36),ut("TRIGGER",28),"TAGS"]})}),t.map(n=>rt(et,{children:[de(Te,{children:ut(n.displayName,24)}),de(Te,{dimColor:!0,children:ut(yn(n.description??"",34),36)}),de(Te,{dimColor:!0,children:ut(n.trigger,28)}),de(Te,{dimColor:!0,children:n.tags?.join(", ")??""})]},n.name))]}),de(et,{marginTop:1,children:de(Te,{dimColor:!0,children:"t:trigger r:refresh"})})]})}function ut(e,t){return e?e.length>=t?e:e+" ".repeat(t-e.length):" ".repeat(t)}function yn(e,t){return e.length<=t?e:e.slice(0,t-3)+"..."}import{Box as Ne,Text as Z,useInput as bn}from"ink";import Sn from"ink-text-input";import{useEffect as Go,useState as Ge,useCallback as no}from"react";import{jsx as ee,jsxs as ke}from"react/jsx-runtime";function Cn(e){return e>=4?"red":e===3?"yellow":"gray"}function vn(e){return e>=4?"HIGH":e===3?"MED ":"LOW "}function En(e){return new Date(e).toLocaleDateString()}function Ko({onBack:e}){let[t,o]=Ge([]),[d,u]=Ge(0),[m,l]=Ge([]),[i,s]=Ge(!0),[r,a]=Ge(!1),[c,h]=Ge(""),[f,x]=Ge("all"),[n,g]=Ge(null),[R,k]=Ge(!1),H=no(()=>{T("/agents").then(({agents:p})=>{o(p),s(!1)}).catch(()=>s(!1))},[]);Go(()=>{H()},[H]);let W=t[d],I=no(()=>{W&&(k(!1),T(`/memories/${W.id}`).then(({memories:p})=>{l(p),g(null)}).catch(p=>g(`Failed: ${p instanceof Error?p.message:String(p)}`)))},[W]);Go(()=>{W&&I()},[W,I]);let te=no(async p=>{if(!(!W||!p.trim()))try{let P=await T("/memories/query",{method:"POST",body:{agentId:W.id,prompt:p.trim()}});l(P.memories),k(!0),g(`Search: ${P.count} results`)}catch(P){g(`Search failed: ${P instanceof Error?P.message:String(P)}`)}},[W]),B=r,S=m.filter(p=>f==="all"?!0:f==="high"?p.importance>3:f==="medium"?p.importance===3:p.importance<3);return bn((p,P)=>{if(B){if(P.escape){a(!1),h("");return}if(P.return){te(c),a(!1),h("");return}return}if(P.escape||p==="q"){e();return}if(p==="a"){u(N=>(N+1)%Math.max(1,t.length));return}if(P.leftArrow){u(N=>(N-1+t.length)%Math.max(1,t.length));return}if(P.rightArrow){u(N=>(N+1)%Math.max(1,t.length));return}if(p==="s"){a(!0),h(""),g(null);return}if(p==="h"){x(N=>N==="high"?"all":"high");return}if(p==="m"){x(N=>N==="medium"?"all":"medium");return}if(p==="l"){x(N=>N==="low"?"all":"low");return}p==="r"&&I()}),i?ee(Z,{dimColor:!0,children:"Loading agents..."}):t.length===0?ke(Ne,{flexDirection:"column",children:[ee(Z,{dimColor:!0,children:"No agents found"}),ee(Z,{dimColor:!0,children:"Press Esc to go back"})]}):ke(Ne,{flexDirection:"column",children:[ee(Z,{bold:!0,children:"Memories (Esc to go back)"}),ke(Ne,{marginTop:1,children:[ee(Z,{children:"Agent: "}),ee(Z,{bold:!0,color:"cyan",children:W?.name??"?"}),ke(Z,{dimColor:!0,children:[" (",d+1,"/",t.length,") [a/arrows to switch]"]})]}),ee(Ne,{children:ke(Z,{dimColor:!0,children:["Filter: ",f==="all"?"all":f," | ",R?"search results":"all memories"," (",S.length,")"]})}),n&&ee(Ne,{children:ee(Z,{color:"yellow",children:n})}),r&&ke(Ne,{marginTop:1,children:[ee(Z,{bold:!0,color:"cyan",children:"Search: "}),ee(Sn,{value:c,onChange:h,placeholder:"search query..."}),ee(Z,{dimColor:!0,children:" (Enter to search, Esc to cancel)"})]}),S.length===0?ee(Ne,{marginTop:1,children:ke(Z,{dimColor:!0,children:["No memories",f!=="all"?` matching filter '${f}'`:""]})}):ee(Ne,{marginTop:1,flexDirection:"column",children:S.map(p=>ke(Ne,{marginBottom:0,children:[ke(Z,{color:Cn(p.importance),bold:!0,children:[vn(p.importance)," "]}),ee(Z,{dimColor:!0,children:Ho(p.type??"?",12)}),ee(Z,{dimColor:!0,children:Ho(`\xD7${p.retrievedCount??0}`,5)}),ke(Z,{children:[wn(p.content,55)," "]}),ee(Z,{dimColor:!0,children:En(p.createdAt)}),p.score!==void 0&&ke(Z,{dimColor:!0,children:[" (",p.score.toFixed(2),")"]})]},p.id))}),ee(Ne,{marginTop:1,children:ee(Z,{dimColor:!0,children:"s:search h:high m:medium l:low a:agent r:refresh"})})]})}function Ho(e,t){return e?e.length>=t?e:e+" ".repeat(t-e.length):" ".repeat(t)}function wn(e,t){return e.length<=t?e:e.slice(0,t-3)+"..."}import{Box as nt,Text as he,useInput as Bn}from"ink";import In from"ink-text-input";import{useState as He,useEffect as jo,useCallback as Qo}from"react";import{jsx as Pe,jsxs as Le}from"react/jsx-runtime";var Xo={Anthropic:["anthropic.apiKey","anthropic.baseUrl","anthropic.model","anthropic.defaultOpusModel","anthropic.defaultSonnetModel","anthropic.defaultHaikuModel","anthropic.smallFastModel"],Defaults:["defaults.model","defaults.effort","defaults.maxTurns","defaults.maxBudgetUsd","defaults.timeout"],Server:["server.port","server.host","server.apiKey","server.timezone"],Logging:["logging.level"],Evolution:["roles.evolution.triggerEvery","roles.evolution.reflectionThreshold"],Chat:["chat.sessionTimeoutMinutes","chat.maxSessionTurns","chat.autoTitle","chat.archiveExtractMemory"]},kn={"anthropic.apiKey":"API Key","anthropic.baseUrl":"Base URL","anthropic.model":"Model","anthropic.defaultOpusModel":"Default Opus","anthropic.defaultSonnetModel":"Default Sonnet","anthropic.defaultHaikuModel":"Default Haiku","anthropic.smallFastModel":"Small Fast","defaults.model":"Default Model","defaults.effort":"Effort","defaults.maxTurns":"Max Turns","defaults.maxBudgetUsd":"Max Budget (USD)","defaults.timeout":"Timeout (sec)","server.port":"Port","server.host":"Host","server.apiKey":"API Key","server.timezone":"Timezone","logging.level":"Log Level","roles.evolution.triggerEvery":"Evolution Trigger Every","chat.sessionTimeoutMinutes":"Session Timeout (min)","chat.maxSessionTurns":"Max Session Turns","chat.autoTitle":"Auto Title","chat.archiveExtractMemory":"Archive Extract Memory","roles.evolution.reflectionThreshold":"Reflection Threshold"};function zo({onBack:e}){let{state:t}=Xe(),[o,d]=He({}),[u,m]=He([]),[l,i]=He(null),[s,r]=He("view"),[a,c]=He(0),[h,f]=He(""),[x,n]=He(null),[g,R]=He(!1),[k,H]=He([]),W=Object.values(Xo).flat(),I=Qo(()=>{T("/config").then(S=>{d(S.config),m(S.mutable)}).catch(S=>i(S.message)),T("/config/env-diff").then(S=>{H(S.diffs)}).catch(()=>{})},[]);jo(()=>{I()},[I]),jo(()=>{t.configVersion>0&&I()},[t.configVersion,I]);let te=Qo(async()=>{let S=W[a];if(S){R(!0),n(null);try{let p=h,P=o[S];if(P&&typeof P.value=="number"&&(p=Number(h),isNaN(p))){n("Invalid number"),R(!1);return}let N=await T("/config",{method:"PATCH",body:{[S]:p}});N.updated.length>0&&(n(`Updated: ${S}`),I()),N.errors.length>0&&n(N.errors[0]),r("view")}catch(p){n(`Failed: ${p instanceof Error?p.message:String(p)}`)}finally{R(!1)}}},[W,a,h,o,I]);if(Bn((S,p)=>{if(s==="edit"){if(p.escape){r("view");return}return}if(p.escape||S==="q"){e();return}if(p.upArrow&&a>0&&c(P=>P-1),p.downArrow&&a<W.length-1&&c(P=>P+1),p.return||S==="e"){let P=W[a],N=o[P];N&&N.mutable?(f(String(N.value??"")),r("edit"),n(null)):N&&!N.mutable&&n("This setting requires a restart to change")}S==="r"&&(I(),n("Refreshed")),S==="s"&&k.length>0&&T("/config/sync-to-env",{method:"POST"}).then(()=>{n("Synced to .env"),H([]),I()}),S==="l"&&k.length>0&&T("/config/load-from-env",{method:"POST"}).then(()=>{n("Loaded from .env"),I()})}),l)return Le(nt,{flexDirection:"column",children:[Le(he,{color:"red",children:["Failed to load config: ",l]}),Pe(he,{dimColor:!0,children:"Press Esc or q to return"})]});let B=0;return Le(nt,{flexDirection:"column",children:[Pe(he,{bold:!0,children:"Settings"}),x&&Pe(he,{color:x.startsWith("Failed")||x.startsWith("This setting")?"yellow":"green",children:x}),k&&k.length>0&&Le(nt,{flexDirection:"column",marginBottom:1,children:[Le(he,{color:"yellow",children:[".env differs from DB (",k.length," key(s)): ",k.map(S=>S.envKey).join(", ")]}),Pe(he,{dimColor:!0,children:"s:sync DB\u2192.env l:load .env\u2192DB"})]}),Pe(nt,{marginTop:1,flexDirection:"column",children:Object.entries(Xo).map(([S,p])=>Le(nt,{marginBottom:1,flexDirection:"column",children:[Pe(he,{bold:!0,color:"cyan",children:S}),p.map(P=>{let N=o[P],b=B++===a,w=u.includes(P),_=kn[P]??P,ne=N?String(N.value??""):"...";return s==="edit"&&b?Le(nt,{children:[Le(he,{color:"cyan",children:["> ",_,": "]}),Pe(In,{value:h,onChange:f,onSubmit:()=>{te()}}),g&&Pe(he,{color:"yellow",children:" saving..."})]},P):Le(nt,{children:[Le(he,{color:b?"cyan":"white",children:[b?"> ":" ",w?" ":"\u{1F512} ",_,": "," "]}),Pe(he,{color:w?"white":"gray",children:ne}),!w&&Pe(he,{dimColor:!0,children:" (restart required)"})]},P)})]},S))}),Pe(he,{dimColor:!0,children:"Enter/e:edit r:refresh Esc/q:back"})]})}import{Box as st,Text as ue,useInput as Pn}from"ink";import{useEffect as An,useState as so,useCallback as Dn}from"react";import{jsx as ie,jsxs as gt}from"react/jsx-runtime";function Yo({onBack:e}){let[t,o]=so([]),[d,u]=so(!0),[m,l]=so(0),{message:i,setMessage:s,clearMessage:r}=Ze(),a=Dn(()=>{u(!0),T("/plugins").then(({plugins:c})=>{o(c),u(!1)}).catch(()=>u(!1))},[]);return An(()=>{a()},[a]),Pn((c,h)=>{if(h.escape||c==="q"){e();return}if(h.upArrow){l(f=>Math.max(0,f-1));return}if(h.downArrow){l(f=>Math.min(t.length-1,f+1));return}c==="r"&&(a(),r())}),d?ie(ue,{dimColor:!0,children:"Loading plugins..."}):gt(st,{flexDirection:"column",children:[gt(ue,{bold:!0,children:["Plugins (",t.length,") (Esc to go back)"]}),i&&ie(st,{marginTop:1,children:gt(ue,{color:i.type==="success"?"green":i.type==="error"?"red":"gray",children:[i.type==="success"?"\u2713 ":i.type==="error"?"\u2717 ":"\u2192 ",i.text]})}),t.length===0?ie(st,{marginTop:1,children:ie(ue,{dimColor:!0,children:"No plugins installed."})}):gt(st,{marginTop:1,flexDirection:"column",children:[gt(st,{children:[ie(ue,{dimColor:!0,children:" "}),ie(ue,{dimColor:!0,children:mt("Name",24)}),ie(ue,{dimColor:!0,children:mt("Scope",8)}),ie(ue,{dimColor:!0,children:mt("User",6)}),ie(ue,{dimColor:!0,children:"Path"})]}),t.map((c,h)=>{let f=h===m,x=c.id.split("@")[0];return gt(st,{children:[ie(ue,{color:f?"cyan":void 0,bold:f,children:f?"> ":" "}),ie(ue,{color:f?"cyan":void 0,bold:f,children:mt(x,24)}),ie(ue,{color:f?"cyan":void 0,bold:f,children:mt(c.scope,8)}),ie(ue,{color:c.globalEnabled?"green":"gray",children:mt(c.globalEnabled?"on":"off",6)}),ie(ue,{dimColor:!0,children:c.installPath})]},c.id)})]}),ie(st,{marginTop:1,children:ie(ue,{dimColor:!0,children:"r:refresh"})})]})}function mt(e,t){return e?e.length>=t?e:e+" ".repeat(t-e.length):" ".repeat(t)}import{Box as Ft,Text as Jo,useInput as Rn}from"ink";import{useState as Mn}from"react";import{jsx as ft,jsxs as io}from"react/jsx-runtime";var Nn=[{key:"1",id:"tasks",label:"Tasks"},{key:"2",id:"automations",label:"Automations"},{key:"3",id:"goals",label:"Goals"}];function Zo({onBack:e}){let[t,o]=Mn("tasks");return Rn((d,u)=>{if(u.escape||d==="q"){e();return}if(d==="1"){o("tasks");return}if(d==="2"){o("automations");return}if(d==="3"){o("goals");return}}),io(Ft,{flexDirection:"column",children:[io(Ft,{gap:1,marginBottom:1,children:[Nn.map(d=>{let u=t===d.id;return ft(Ft,{children:io(Jo,{color:u?"cyan":"gray",bold:u,underline:u,children:["[",d.key,":",d.label,"]"]})},d.id)}),ft(Ft,{flexGrow:1}),ft(Jo,{dimColor:!0,children:"Esc: back"})]}),t==="tasks"&&ft(_t,{onBack:e}),t==="automations"&&ft(Ut,{onBack:e}),t==="goals"&&ft(Ot,{onBack:e})]})}import{Box as G,Text as O,useInput as Ln}from"ink";import{useEffect as _n,useState as wt}from"react";import{jsx as A,jsxs as re}from"react/jsx-runtime";var er={connected:"green",connecting:"yellow",disconnected:"gray",error:"red"};function tr({onBack:e}){let[t,o]=wt([]),[d,u]=wt(!0),[m,l]=wt(0),[i,s]=wt(null),[r,a]=wt("");_n(()=>{c()},[]);async function c(){try{let x=await T("/channels");o(x.channels)}catch{}u(!1)}async function h(x){if(t.find(g=>g.id===x)?.platform==="wechat")try{a("Starting WeChat QR login...");let g=await T(`/channels/${x}/wechat/qr-start`,{method:"POST"});if(g.qrcodeUrl){a(`Scan QR: ${g.qrcodeUrl}
6
- Waiting for scan...`);let R=await T(`/channels/${x}/wechat/qr-wait`,{method:"POST",body:{sessionKey:g.sessionKey,timeoutMs:12e4}});a(R.message)}else a(g.message);c()}catch{a("WeChat connect failed")}else try{await T(`/channels/${x}/connect`,{method:"POST"}),a("Connecting..."),c()}catch{a("Connect failed")}}async function f(x){try{await T(`/channels/${x}/disconnect`,{method:"POST"}),a("Disconnected"),c()}catch{a("Disconnect failed")}}return Ln((x,n)=>{if(i){if(n.escape||x==="q"){s(null);return}if(x==="c"){h(i.id);return}if(x==="d"){f(i.id);return}return}if(n.escape){e();return}if(n.upArrow){l(g=>Math.max(0,g-1));return}if(n.downArrow){l(g=>Math.min(t.length-1,g+1));return}if(n.return&&t[m]){s(t[m]),a("");return}}),d?A(G,{flexDirection:"column",children:A(O,{dimColor:!0,children:"Loading channels..."})}):i?re(G,{flexDirection:"column",children:[re(G,{marginBottom:1,children:[re(O,{bold:!0,children:["Channel: ",i.name]}),A(O,{dimColor:!0,children:" (Esc to go back)"})]}),re(G,{flexDirection:"column",gap:0,children:[re(O,{children:["ID: ",i.id]}),re(O,{children:["Platform: ",i.platform]}),re(O,{children:["Status: ",A(O,{color:er[i.status]??"white",children:i.status})]}),re(O,{children:["Enabled: ",i.enabled?"yes":"no"]}),re(O,{children:["Messages: ",i.messageCount]}),re(O,{children:["Config: ",JSON.stringify(i.config)]})]}),A(G,{marginTop:1,children:A(O,{dimColor:!0,children:"[c] Connect [d] Disconnect [Esc] Back"})}),r&&A(O,{color:"yellow",children:r})]}):re(G,{flexDirection:"column",children:[re(G,{marginBottom:1,children:[A(O,{bold:!0,children:"Channels"}),re(O,{dimColor:!0,children:[" (",t.length," total) "]}),A(O,{dimColor:!0,children:"Arrow keys to select, Enter for detail, Esc to return"})]}),t.length===0?A(O,{dimColor:!0,children:"No channels configured. Add channels via API or config."}):re(G,{flexDirection:"column",children:[re(G,{children:[A(G,{width:3,children:A(O,{dimColor:!0,children:" "})}),A(G,{width:12,children:A(O,{bold:!0,dimColor:!0,children:"ID"})}),A(G,{width:16,children:A(O,{bold:!0,dimColor:!0,children:"Name"})}),A(G,{width:12,children:A(O,{bold:!0,dimColor:!0,children:"Platform"})}),A(G,{width:14,children:A(O,{bold:!0,dimColor:!0,children:"Status"})}),A(G,{width:10,children:A(O,{bold:!0,dimColor:!0,children:"Enabled"})}),A(G,{width:10,children:A(O,{bold:!0,dimColor:!0,children:"Messages"})})]}),t.map((x,n)=>re(G,{children:[A(G,{width:3,children:A(O,{children:n===m?">":" "})}),A(G,{width:12,children:A(O,{inverse:n===m,children:x.id.slice(0,8)})}),A(G,{width:16,children:A(O,{children:x.name})}),A(G,{width:12,children:A(O,{children:x.platform})}),A(G,{width:14,children:re(O,{color:er[x.status]??"white",children:[x.status==="connected"?"\u25CF":x.status==="error"?"\u2717":"\u25CB"," ",x.status]})}),A(G,{width:10,children:A(O,{color:x.enabled?"green":"gray",children:x.enabled?"yes":"no"})}),A(G,{width:10,children:A(O,{children:x.messageCount})})]},x.id))]})]})}import{Box as pt,Text as Ke,useInput as On}from"ink";import{useEffect as Vn,useState as It,useCallback as qn}from"react";import{Box as V,Text as E,useInput as $n}from"ink";import Wt from"ink-text-input";import{useEffect as or,useState as ae,useCallback as Bt}from"react";uo();import{Fragment as rr,jsx as v,jsxs as M}from"react/jsx-runtime";function nr({roleId:e,onBack:t}){let[o,d]=ae(null),[u,m]=ae([]),[l,i]=ae(!0),[s,r]=ae("view"),[a,c]=ae(""),[h,f]=ae(0),[x,n]=ae(""),[g,R]=ae([]),[k,H]=ae(0),[W,I]=ae(new Set),[te,B]=ae("inline"),[S,p]=ae(""),[P,N]=ae(""),[_e,b]=ae([]),[w,_]=ae(new Set),[ne,je]=ae(0),{message:F,setMessage:z}=Ze(),me=Bt(()=>{i(!0),T(`/roles/${e}`).then(({role:y,boundPlugins:L})=>{d(y),m(L??[]),c(y.cagPrompt??""),I(new Set(y.allowedTools??[])),B(y.executionMode??"inline"),p(y.model??""),N(y.maxBudgetUsd!=null?String(y.maxBudgetUsd):""),i(!1)}).catch(()=>i(!1))},[e]);or(()=>{me()},[me]),or(()=>{B(o?.executionMode??"inline"),p(o?.model??""),N(o?.maxBudgetUsd!=null?String(o?.maxBudgetUsd):"")},[o?.id,o?.executionMode,o?.model,o?.maxBudgetUsd]);let ir=Bt(async()=>{if(o)try{await T(`/roles/${o.id}`,{method:"PATCH",body:{cagPrompt:a}}),z("CAG prompt saved","success"),r("view"),me()}catch(y){z(`Save failed: ${y instanceof Error?y.message:String(y)}`,"error")}},[o,a,me,z]),ar=Bt(async()=>{if(o)try{await T(`/roles/${o.id}`,{method:"PATCH",body:{additionalDirectories:$e}}),z("Directories saved","success"),r("view"),me()}catch(y){z(`Save failed: ${y instanceof Error?y.message:String(y)}`,"error")}},[o,me,z]),lr=Bt(async()=>{if(o)try{await T(`/roles/${o.id}`,{method:"PATCH",body:{allowedTools:Array.from(W)}}),z("Tool permissions saved","success"),r("view"),me()}catch(y){z(`Save failed: ${y instanceof Error?y.message:String(y)}`,"error")}},[o,W,me,z]),cr=Bt(async()=>{if(!o)return;let y={executionMode:te};S!==void 0&&(y.model=S);let L=parseFloat(P);isNaN(L)||(y.maxBudgetUsd=L);try{await T(`/roles/${o.id}`,{method:"PATCH",body:y}),z("Execution config saved","success"),r("view"),me()}catch(C){z(`Save failed: ${C instanceof Error?C.message:String(C)}`,"error")}},[o,te,S,P,me,z]),$e=o?.additionalDirectories??[];return $n((y,L)=>{if(L.escape){r("view");return}if(y==="r"){me();return}switch(s){case"view":{if(y==="c"){r("edit-cag");return}if(y==="d"){r("edit-dirs"),f(0),n("");return}if(y==="t"){r("edit-tools");return}if(y==="x"){r("edit-exec");return}if(y==="h"){T("/channels?enabled=true").then(({channels:C})=>{b(C.map(Y=>({name:Y.name,id:Y.id}))),_(new Set(o?.allowedChannels??[])),je(0),r("edit-channels")}).catch(()=>z("Failed to load channels","error"));return}if(y==="i"){if(!o)return;let C=!o.inheritUserSettings;T(`/roles/${o.id}`,{method:"PATCH",body:{inheritUserSettings:C}}).then(()=>{z(`Inherit user settings: ${C?"ON":"OFF"}`,"success"),me()}).catch(()=>z("Failed to toggle","error"));return}break}case"edit-cag":{if(L.ctrl&&y==="s"){ir();return}break}case"edit-dirs":{if(y==="s"){ar();return}if(y==="a"){r("edit-dirs-add");return}if(y==="x"&&$e.length>0){d(C=>C&&{...C,additionalDirectories:$e.filter((Y,Qe)=>Qe!==h)}),f(C=>Math.max(0,Math.min(C,$e.length-2)));return}if(L.upArrow){f(C=>Math.max(0,C-1));return}if(L.downArrow){f(C=>Math.min($e.length-1,C+1));return}break}case"edit-dirs-add":{if(L.escape){r("edit-dirs"),n(""),R([]);return}if(L.return&&g.length>0){let C=g[k];C&&(n(C.endsWith("/")?C:C+"/"),R([]));return}if(L.return){let C=x.trim();C&&C.startsWith("/")?(d(Y=>Y&&{...Y,additionalDirectories:[...Y.additionalDirectories??[],{path:C}]}),n(""),R([]),r("edit-dirs")):z("Path must be absolute (must start with /)","error");return}if(L.tab){let C=x.trim();if(!C||!C.startsWith("/"))return;T(`/fs/suggest-dirs?prefix=${encodeURIComponent(C)}`).then(({suggestions:Y})=>{Y.length===1?(n(Y[0]+"/"),R([])):Y.length>1&&(R(Y),H(0))}).catch(()=>{R([])});return}if(L.upArrow&&g.length>0){H(C=>Math.max(0,C-1));return}if(L.downArrow&&g.length>0){H(C=>Math.min(g.length-1,C+1));return}break}case"edit-tools":{if(y==="s"){lr();return}let C=parseInt(y,10)-1;if(!isNaN(C)&&C>=0&&C<At.length){let Y=At[C];I(Qe=>{let Pt=new Set(Qe);return Pt.has(Y)?Pt.delete(Y):Pt.add(Y),Pt});return}break}case"edit-exec":{if(y==="s"){cr();return}if(L.tab){B(C=>C==="inline"?"isolated":"inline");return}break}case"edit-channels":{if(y==="s"){if(!o)return;let C=w.size>0?Array.from(w):[];T(`/roles/${o.id}`,{method:"PATCH",body:{allowedChannels:C}}).then(()=>{z("Channels saved","success"),r("view"),me()}).catch(()=>z("Save failed","error"));return}if(y==="u"){if(!o)return;T(`/roles/${o.id}`,{method:"PATCH",body:{allowedChannels:null}}).then(()=>{z("Channels: unrestricted","success"),r("view"),me()}).catch(()=>z("Save failed","error"));return}if(y===" "){let C=_e[ne];C&&_(Y=>{let Qe=new Set(Y);return Qe.has(C.name)?Qe.delete(C.name):Qe.add(C.name),Qe});return}if(L.upArrow){je(C=>Math.max(0,C-1));return}if(L.downArrow){je(C=>Math.min(_e.length-1,C+1));return}break}}}),l?v(E,{dimColor:!0,children:"Loading role..."}):o?s==="edit-cag"?M(V,{flexDirection:"column",children:[v(E,{bold:!0,children:"CAG Prompt \u2014 Edit (Esc cancel, Ctrl+S save)"}),v(Wt,{value:a,onChange:c,placeholder:"Character And Guidance prompt..."}),F&&v(V,{marginTop:1,children:v(E,{color:F.type==="error"?"red":"green",children:F.text})})]}):s==="edit-dirs-add"?M(V,{flexDirection:"column",children:[v(E,{bold:!0,children:"Add Directory (Enter confirm, Esc cancel, Tab:complete)"}),v(Wt,{value:x,onChange:y=>{n(y),R([])},placeholder:"/absolute/path/to/directory"}),g.length>0&&M(V,{flexDirection:"column",marginTop:1,children:[g.map((y,L)=>M(E,{color:L===k?"cyan":void 0,dimColor:L!==k,children:[L===k?"> ":" ",y,"/"]},y)),v(E,{dimColor:!0,children:"\u2191\u2193 navigate, Enter select, Tab:confirm"})]}),F&&v(V,{marginTop:1,children:v(E,{color:F.type==="error"?"red":"green",children:F.text})})]}):s==="edit-dirs"?M(V,{flexDirection:"column",children:[v(E,{bold:!0,children:"Additional Directories (\u2191\u2193 navigate, a:add x:remove s:save Esc:cancel)"}),F&&v(V,{children:v(E,{color:F.type==="error"?"red":F.type==="success"?"green":"gray",children:F.text})}),$e.length===0?v(E,{dimColor:!0,children:"No directories. Press a to add one."}):$e.map((y,L)=>M(V,{children:[v(E,{color:L===h?"cyan":void 0,bold:L===h,children:L===h?"> ":" "}),v(E,{color:L===h?"cyan":void 0,children:y.path})]},y.path))]}):s==="edit-tools"?M(V,{flexDirection:"column",children:[v(E,{bold:!0,children:"Tool Permissions \u2014 toggle with number key (s:save Esc:cancel)"}),F&&v(V,{children:v(E,{color:F.type==="error"?"red":F.type==="success"?"green":"gray",children:F.text})}),At.map((y,L)=>{let C=W.has(y);return M(V,{children:[M(E,{dimColor:!0,children:[L+1,". "]}),v(E,{color:C?"green":"red",children:C?"[ON] ":"[OFF] "}),v(E,{children:y})]},y)})]}):s==="edit-exec"?M(V,{flexDirection:"column",children:[v(E,{bold:!0,children:"Execution Config (Tab:cycle mode, Enter on field, s:save Esc:cancel)"}),M(V,{children:[v(E,{bold:!0,children:" Mode: "}),v(E,{color:"cyan",children:te}),v(E,{dimColor:!0,children:" (Tab to toggle)"})]}),M(V,{children:[v(E,{bold:!0,children:" Model: "}),v(Wt,{value:S,onChange:p,placeholder:"sonnet, opus, haiku, or blank"})]}),M(V,{children:[v(E,{bold:!0,children:" Max Budget (USD): "}),v(Wt,{value:P,onChange:N,placeholder:"0 = unlimited"})]}),F&&v(V,{children:v(E,{color:F.type==="error"?"red":F.type==="success"?"green":"gray",children:F.text})})]}):s==="edit-channels"?M(V,{flexDirection:"column",children:[v(E,{bold:!0,children:"Allowed Channels (Space:toggle, u:unrestricted, s:save, Esc:cancel)"}),_e.length===0?v(E,{dimColor:!0,children:"No channels available"}):_e.map((y,L)=>M(V,{children:[M(E,{children:[L===ne?">":" "," "]}),M(E,{color:w.has(y.name)?"green":"gray",children:["[",w.has(y.name)?"x":" ","] ",y.name]})]},y.id)),M(E,{dimColor:!0,children:["Selected: ",w.size>0?Array.from(w).join(", "):"none (= block all)"]}),F&&v(V,{children:v(E,{color:F.type==="error"?"red":F.type==="success"?"green":"gray",children:F.text})})]}):M(V,{flexDirection:"column",children:[M(E,{bold:!0,children:["Role: ",o.name]}),M(V,{children:[v(E,{dimColor:!0,children:"ID: "}),v(E,{children:o.id})]}),M(V,{children:[v(E,{dimColor:!0,children:"Status: "}),v(E,{color:o.status==="active"?"green":o.status==="probation"?"yellow":"red",children:o.status})]}),o.performanceScore!=null&&M(V,{children:[v(E,{dimColor:!0,children:"Score: "}),M(E,{children:[(o.performanceScore*100).toFixed(0),"%"]})]}),M(V,{children:[v(E,{dimColor:!0,children:"Created: "}),v(E,{children:new Date(o.createdAt).toLocaleString()})]}),M(V,{children:[v(E,{dimColor:!0,children:"Execution: "}),M(E,{children:[o.executionMode??"inline"," / ",o.model??"inherit"," / ",o.maxBudgetUsd!=null?`$${o.maxBudgetUsd}`:"no limit"]})]}),$e.length>0&&M(rr,{children:[v(E,{bold:!0,children:"Additional Directories:"}),$e.map(y=>M(E,{dimColor:!0,children:[" ",y.path]},y.path))]}),M(V,{children:[v(E,{dimColor:!0,children:"Channels: "}),v(E,{children:o.allowedChannels===void 0?"Unrestricted":o.allowedChannels.length===0?"Blocked":o.allowedChannels.join(", ")})]}),M(V,{children:[v(E,{dimColor:!0,children:"Inherit User Settings: "}),v(E,{color:o.inheritUserSettings?"green":"gray",children:o.inheritUserSettings?"Yes":"No"})]}),o.learnedRules.length>0&&M(rr,{children:[v(E,{bold:!0,children:"Learned Rules:"}),o.learnedRules.map(y=>M(E,{dimColor:!0,children:[" - ",y]},y))]}),F&&v(V,{children:v(E,{color:F.type==="error"?"red":F.type==="success"?"green":"gray",children:F.text})}),v(V,{marginTop:1,children:v(E,{dimColor:!0,children:"c:CAG d:dirs t:tools x:exec h:channels i:inherit r:refresh Esc:back"})})]}):v(E,{dimColor:!0,children:"Role not found."})}import{jsx as Se,jsxs as Gt}from"react/jsx-runtime";function sr({onBack:e}){let[t,o]=It([]),[d,u]=It(!0),[m,l]=It(0),[i,s]=It("list"),[r,a]=It(null),{message:c,setMessage:h,clearMessage:f}=Ze(),x=qn(()=>{u(!0),T("/roles").then(({roles:n})=>{o(n.map(g=>({id:g.id,name:g.name,status:g.status,performanceScore:g.performanceScore,createdAt:g.createdAt}))),u(!1)}).catch(()=>u(!1))},[]);return Vn(()=>{x()},[x]),On((n,g)=>{if(g.escape||n==="q"){e();return}if(g.upArrow){l(R=>Math.max(0,R-1));return}if(g.downArrow){l(R=>Math.min(t.length-1,R+1));return}if(n==="r"&&(x(),f()),n===`
7
- `||n==="o"||n==="e"){t.length>0&&(a(t[m].id),s("detail"));return}}),d?Se(Ke,{dimColor:!0,children:"Loading roles..."}):i==="detail"&&r?Se(nr,{roleId:r,onBack:()=>s("list")}):Gt(pt,{flexDirection:"column",children:[Gt(Ke,{bold:!0,children:["Roles (",t.length,") (Esc to go back)"]}),c&&Se(pt,{marginTop:1,children:Gt(Ke,{color:c.type==="success"?"green":c.type==="error"?"red":"gray",children:[c.type==="success"?"\u2713 ":c.type==="error"?"\u2717 ":"\u2192 ",c.text]})}),t.length===0?Se(pt,{marginTop:1,children:Se(Ke,{dimColor:!0,children:"No roles found. Roles define agent behavior and bind plugins."})}):Se(pt,{marginTop:1,flexDirection:"column",children:t.map((n,g)=>{let R=g===m,k=n.performanceScore!=null?`${(n.performanceScore*100).toFixed(0)}%`:"\u2014";return Gt(pt,{children:[Se(Ke,{color:R?"cyan":void 0,bold:R,children:R?"> ":" "}),Se(Ke,{color:R?"cyan":void 0,bold:R,children:ao(n.name,24)}),Se(Ke,{color:Un(n.status),children:ao(n.status,12)}),Se(Ke,{dimColor:!0,children:ao(k,8)})]},n.id)})}),Se(pt,{marginTop:1,children:Se(Ke,{dimColor:!0,children:"Enter/O/E:open Esc:back r:refresh"})})]})}function Un(e){return e==="active"?"green":e==="probation"?"yellow":e==="retired"||e==="dead"?"red":"gray"}function ao(e,t){return e?e.length>=t?e:e+" ".repeat(t-e.length):" ".repeat(t)}import{Fragment as jn,jsx as q,jsxs as Tt}from"react/jsx-runtime";function Gn(){let{state:e,dispatch:t}=Xe(),{session:o,sendMessage:d,createNewSession:u,archiveCurrentSession:m}=bo(),[l,i]=Wn([]);Ht(()=>{t({type:"SET_SESSION",session:o})},[o,t]),To();let{latestMessage:s}=Co(o?.id??null),r=lo(null);Ht(()=>{s&&s.id!==r.current&&(r.current=s.id,i(k=>[...k,{role:"assistant",content:s.content}]))},[s]);let{events:a,isStreaming:c,clearEvents:h}=yo(e.activeTaskId),f=a[a.length-1],x=f?.type==="complete"&&!c,n=lo(null),g=lo("");Ht(()=>{g.current=a.filter(k=>k.type==="reasoning").map(k=>k.content).join("")},[a]),Ht(()=>{if(x&&e.activeTaskId!==n.current){n.current=e.activeTaskId;let k=f?.content||g.current;k&&i(H=>[...H,{role:"assistant",content:k}])}},[x,f,e.activeTaskId]);let R=async k=>{let H=k.trim().toLowerCase();if(["quit","exit","/quit","/exit"].includes(H)&&process.exit(0),k.startsWith("/")){let I=k.slice(1),B={work:"work",tasks:"tasks",config:"config",evolution:"evolution",templates:"templates",memories:"memories",goals:"goals",strategies:"strategies",roles:"roles",settings:"settings",channels:"channels",plugins:"plugins",back:"chat"}[I];if(B){t({type:"SET_VIEW",view:B});return}if(I==="new"){if(await m()){let p=await u();i([]),h(),p&&i([{role:"assistant",content:`Session archived. New session started: ${p.id.slice(0,8)}`}])}return}if(I==="session"){let S=o?`Session: ${o.id}
8
- Turns: ${o.messageCount}
9
- Last active: ${new Date(o.lastActiveAt).toLocaleString()}`:"No active session";i(p=>[...p,{role:"assistant",content:S}]);return}}if(i(I=>[...I,{role:"user",content:k}]),h(),!await d(k)){i(I=>[...I,{role:"assistant",content:"Failed to send message. Server may be disconnected."}]);return}};return Tt(kt,{flexDirection:"column",paddingX:1,children:[q(vo,{}),Tt(kt,{flexGrow:1,flexDirection:"column",paddingY:1,children:[e.view==="chat"&&Tt(jn,{children:[q(Po,{messages:l}),q(Bo,{events:a,isStreaming:c}),!e.connected&&!e.serverUnreachable&&q(kt,{children:q(xt,{color:"red",children:"Server disconnected. Attempting to reconnect..."})}),e.serverUnreachable&&Tt(kt,{flexDirection:"column",children:[q(xt,{color:"red",bold:!0,children:"Server unreachable after 15s."}),q(xt,{dimColor:!0,children:"Check: adam server logs"}),q(xt,{dimColor:!0,children:"Type /quit to exit."})]})]}),e.view==="work"&&q(Zo,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="tasks"&&q(_t,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="config"&&q(_o,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="evolution"&&q(Oo,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="goals"&&q(Ot,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="strategies"&&q(qo,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="templates"&&q(Ut,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="webhooks"&&q(Wo,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="memories"&&q(Ko,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="plugins"&&q(Yo,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="roles"&&q(sr,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="settings"&&q(zo,{onBack:()=>t({type:"SET_VIEW",view:"chat"})}),e.view==="channels"&&q(tr,{onBack:()=>t({type:"SET_VIEW",view:"chat"})})]}),e.pendingPlanApproval?q(Do,{approval:e.pendingPlanApproval,onResolved:()=>t({type:"SET_PENDING_PLAN_APPROVAL",approval:null}),onTimeout:()=>t({type:"SET_PLAN_TIMEOUT_NOTICE",planId:e.pendingPlanApproval.planId})}):e.pendingApproval?q(Ao,{approval:e.pendingApproval,onResolved:()=>t({type:"SET_PENDING_APPROVAL",approval:null})}):q(wo,{onSubmit:R}),e.planTimeoutNotice&&q(Hn,{planId:e.planTimeoutNotice.planId,onDismiss:()=>t({type:"SET_PLAN_TIMEOUT_NOTICE",planId:null})})]})}function Hn({planId:e,onDismiss:t}){return Fn(o=>{o==="d"&&t()}),Tt(kt,{borderStyle:"round",borderColor:"yellow",paddingX:1,children:[Tt(xt,{color:"yellow",children:["Plan ",e," was auto-denied after 300s timeout."]}),q(xt,{dimColor:!0,children:" [d] Dismiss"})]})}function Kn(){return q(fo,{children:q(Gn,{})})}export{Kn as default};
@@ -1 +0,0 @@
1
- import{x as a,y as b}from"./chunk-HICJBGGJ.js";import"./chunk-5JLMSNIW.js";import"./chunk-IXF3XBGX.js";import"./chunk-AXMXXUPO.js";import"./chunk-KICPHTI2.js";import"./chunk-FUGJMHY4.js";import"./chunk-5ASEAZCR.js";import"./chunk-742NWPTQ.js";import"./chunk-PQ7KPALO.js";import"./chunk-2GXYBWLS.js";import"./chunk-WZOMGJSY.js";import"./chunk-WXN3PSVX.js";import"./chunk-L7426WNY.js";import"./chunk-L7JP7DUO.js";import"./chunk-HAWA62R2.js";import"./chunk-VF6GJGD6.js";import"./chunk-T25NLVMY.js";import"./chunk-ETQ7KC73.js";import"./chunk-FYDFMYUP.js";import"./chunk-U36NBCR3.js";import"./chunk-XNWZZYAV.js";import"./chunk-PCSZW2PE.js";import"./chunk-SFUS33SO.js";import"./chunk-3DAK2XWP.js";import"./chunk-FCV2DPZQ.js";export{b as createAdamTools,a as getToolsFingerprint};
@@ -1 +0,0 @@
1
- import{a,b,c}from"./chunk-BREBCBG4.js";import"./chunk-WXN3PSVX.js";import"./chunk-L7426WNY.js";import"./chunk-L7JP7DUO.js";import"./chunk-HAWA62R2.js";import"./chunk-VF6GJGD6.js";import"./chunk-T25NLVMY.js";import"./chunk-ETQ7KC73.js";import"./chunk-FYDFMYUP.js";import"./chunk-XNWZZYAV.js";import"./chunk-PCSZW2PE.js";import"./chunk-SFUS33SO.js";import"./chunk-3DAK2XWP.js";import"./chunk-FCV2DPZQ.js";export{a as BreeEngine,b as getBreeEngine,c as setBreeEngine};
@@ -1 +0,0 @@
1
- import{c as a,d as b,e as c}from"./chunk-URW2DJQF.js";import"./chunk-742NWPTQ.js";import"./chunk-PQ7KPALO.js";import"./chunk-PCSZW2PE.js";import"./chunk-SFUS33SO.js";import"./chunk-3DAK2XWP.js";import"./chunk-FCV2DPZQ.js";export{c as channelRoutes,b as getChannelManager,a as setChannelManager};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f}from"./chunk-PQ7KPALO.js";import"./chunk-PCSZW2PE.js";import"./chunk-SFUS33SO.js";import"./chunk-FCV2DPZQ.js";export{a as createChannel,e as deleteChannel,b as getChannel,d as listChannels,c as updateChannel,f as updateChannelStatus};
@@ -1 +0,0 @@
1
- import{a as m}from"./chunk-FCV2DPZQ.js";import t from"pino";import{Writable as g}from"stream";var d=process.env.ADAM_LOG_LEVEL||"info",r=[];function f(n){r.push(n)}var p=new g({write(n,o,l){try{let s=JSON.parse(n.toString());for(let c of r)c(s)}catch{}l()}}),u=process.env.NODE_ENV!=="production";function h(){if(u)try{return m("pino-pretty")({colorize:!0,translateTime:"HH:MM:ss.l",ignore:"pid,hostname"})}catch{}return process.stdout}var e=t({level:d,timestamp:t.stdTimeFunctions.epochTime,formatters:{level:n=>({level:n}),bindings:n=>({component:n.name})},serializers:{error:t.stdSerializers.err}},t.multistream([{stream:h()},{stream:p}])),i={adam:e.child({name:"adam"}),manager:e.child({name:"manager"}),scheduler:e.child({name:"scheduler"}),api:e.child({name:"api"}),ws:e.child({name:"ws"}),cli:e.child({name:"cli"}),store:e.child({name:"store"}),embedding:e.child({name:"embedding"}),admin:e.child({name:"admin"}),agent:e.child({name:"agent"}),channels:e.child({name:"channels"}),"plugin-sync":e.child({name:"plugin-sync"}),watchdog:e.child({name:"watchdog"}),"chat-manager":e.child({name:"chat-manager"}),execution:e.child({name:"execution"}),"execution-pool":e.child({name:"execution-pool"}),"message-handler":e.child({name:"message-handler"}),"goal-manager":e.child({name:"goal-manager"}),"cli:register-ai-digest":e.child({name:"cli:register-ai-digest"})};function y(n){return i[n]||e}function x(n){e.level=n;for(let o of Object.values(i))o.level=n}function E(){return e.level}var a=null;function S(n){a=n}function b(){return a}export{f as a,e as b,y as c,x as d,E as e,S as f,b as g};
@@ -1 +0,0 @@
1
- import{c as n}from"./chunk-3DAK2XWP.js";import{query as g}from"@anthropic-ai/claude-agent-sdk";import*as i from"fs/promises";import*as a from"path";import*as m from"os";var d=n("manager"),e=a.join(m.homedir(),".adam","llm-eval");async function v(u,t){await i.mkdir(e,{recursive:!0});let o={cwd:e,maxTurns:3,maxBudgetUsd:.05};t&&(o.systemPrompt=t);let c=g({prompt:u,options:o}),s="";for await(let f of c){let r=f;r.type==="result"&&typeof r.result=="string"&&(s=r.result)}return s}export{v as a};
@@ -1,15 +0,0 @@
1
- import{a as D,e as M}from"./chunk-B6S2AEOD.js";import{d as N}from"./chunk-IXF3XBGX.js";import{b as C}from"./chunk-AXMXXUPO.js";import{b as x}from"./chunk-L7426WNY.js";import{f as m,h as S,i as L,l as E}from"./chunk-XNWZZYAV.js";import{b as h,d as W}from"./chunk-PCSZW2PE.js";import{c as g}from"./chunk-3DAK2XWP.js";W();function Y(e){return{id:e.id,roleId:e.role_id,taskId:e.task_id,scores:JSON.parse(e.score_json),emaScore:e.ema_score,createdAt:e.created_at}}function O(e){h().prepare(`
2
- INSERT INTO role_scores (id, role_id, task_id, score_json, ema_score, created_at)
3
- VALUES (?, ?, ?, ?, ?, ?)
4
- `).run(e.id,e.roleId,e.taskId,JSON.stringify(e.scores),e.emaScore,e.createdAt)}function T(e,t=50){return h().prepare("SELECT * FROM role_scores WHERE role_id = ? ORDER BY created_at DESC LIMIT ?").all(e,t).map(Y)}function B(e){return h().prepare("SELECT ema_score FROM role_scores WHERE role_id = ? ORDER BY created_at DESC LIMIT 1").get(e)?.ema_score}function F(e){let n=h().prepare(`
5
- SELECT token_usage FROM tasks
6
- WHERE role_id = ? AND status = 'completed' AND token_usage IS NOT NULL
7
- ORDER BY completed_at DESC LIMIT 50
8
- `).all(e);if(n.length===0)return 1e4;let r=n.map(o=>{let a=JSON.parse(o.token_usage);return(a.input??0)+(a.output??0)}).sort((o,a)=>o-a);return r[Math.floor(r.length/2)]}import{v4 as G}from"uuid";var q=g("admin"),w={taskSuccess:.3,planAccuracy:.25,permissionCompliance:.25,efficiency:.2},H=.3;function V(e,t){let n=x(e),r=n?.status==="completed"?1:0,o=1,a=N(e);a?.deviationReport&&(o=a.deviationReport.overallAccuracy);let i=1,p=C(e,1e3),l=p.filter(u=>u.type==="tool_result"||u.type==="permission_denied").length,c=p.filter(u=>u.type==="permission_denied").length;l>0&&(i=1-c/l);let d=1;if(n?.tokenUsage){let u=n.tokenUsage.input+n.tokenUsage.output,f=t?F(t):1e4;u>f&&(d=Math.max(0,1-(u-f)/f))}let R=r*w.taskSuccess+o*w.planAccuracy+i*w.permissionCompliance+d*w.efficiency;return{taskSuccess:r,planAccuracy:o,permissionCompliance:i,efficiency:d,weighted:R}}function $(e,t){let n=V(t,e),r=B(e),o=r!==void 0?H*n.weighted+(1-H)*r:n.weighted;return O({id:G(),roleId:e,taskId:t,scores:n,emaScore:o,createdAt:Date.now()}),q.debug({roleId:e,taskId:t,scores:{...n,weighted:n.weighted.toFixed(3)},ema:o.toFixed(3)},"Task score recorded"),o}E();E();var z=g("admin");function A(e,t=7){let n=m(e),r=T(e,100),o=Date.now(),a=o-t*24*60*60*1e3,i=r.filter(s=>s.createdAt>=a),p=i.map(s=>s.emaScore),l=i.length>0?i.reduce((s,J)=>s+J.scores.weighted,0)/i.length:1,c=[],d=i.filter(s=>s.scores.taskSuccess<.5);d.length>0&&c.push({category:"task_failures",count:d.length,examples:d.slice(0,3).map(s=>s.taskId)});let R=i.filter(s=>s.scores.planAccuracy<.5);R.length>0&&c.push({category:"plan_deviations",count:R.length,examples:R.slice(0,3).map(s=>s.taskId)});let u=i.filter(s=>s.scores.permissionCompliance<.8);u.length>0&&c.push({category:"permission_violations",count:u.length,examples:u.slice(0,3).map(s=>s.taskId)});let f=i.filter(s=>s.scores.efficiency<.3);f.length>0&&c.push({category:"inefficiency",count:f.length,examples:f.slice(0,3).map(s=>s.taskId)});let b=[],k=[];return d.length>i.length*.3&&(b.push("High task failure rate"),k.push({action:"add_rule",detail:"Add rule: verify task feasibility before execution"})),u.length>0&&(b.push("Permission boundary violations"),k.push({action:"adjust_permission",detail:"Review and expand allowedPaths/allowedTools if tasks legitimately need wider access"})),R.length>i.length*.5&&(b.push("Frequent plan deviations"),k.push({action:"add_rule",detail:"Add rule: follow execution plan steps more closely, request plan revision if steps are unclear"})),z.info({roleId:e,taskCount:i.length,avgScore:l.toFixed(3),failureCategories:c.map(s=>s.category)},"Diagnostic report generated"),{roleId:e,agentName:n?.name??"Unknown",period:{start:a,end:o},taskCount:i.length,avgScore:l,scoreHistory:p,failureBehaviors:c,rootCauses:b,recommendations:k}}var v=g("admin"),P=.4,K=5;function U(e,t,n=P){if(t>=n)return;let r=m(e);if(!r||r.status==="retired"||r.status==="dead")return;v.warn({roleId:e,emaScore:t,threshold:n},"Agent EMA below threshold, retiring");let o=A(e),a=JSON.stringify(r.learnedRules),i=Q(r.learnedRules,o);S(e,{status:"retired",learnedRules:i});let p=[...o.failureBehaviors.map(c=>`${c.category}: ${c.count} occurrences`),...o.rootCauses.map(c=>`Root cause: ${c}`),...o.recommendations.map(c=>`Recommendation [${c.action}]: ${c.detail}`)].join(`
9
- `),l=M(a,JSON.stringify(i));return D({timestamp:Date.now(),oldRules:a,newRules:JSON.stringify(i),diff:p?`--- Diagnostic Report ---
10
- ${p}
11
-
12
- --- Rules Diff ---
13
- ${l}`:l,roleId:e,source:"monitor"}),v.info({roleId:e,oldRulesCount:r.learnedRules.length,newRulesCount:i.length,recommendations:o.recommendations.length},"Agent retired with targeted learnedRules modification"),o}function j(e){let t=m(e);return!t||t.status!=="retired"?!1:(S(e,{status:"probation"}),D({timestamp:Date.now(),oldRules:"status: retired",newRules:"status: probation",diff:`- status: retired
14
- + status: probation`,roleId:e,source:"monitor"}),v.info({roleId:e},"Agent reinstated to probation"),!0)}function I(e,t,n=P,r=K){let o=m(e);return!o||o.status!=="probation"||T(e,r+1).length<r?!1:t>=n?(S(e,{status:"active"}),D({timestamp:Date.now(),oldRules:"status: probation",newRules:"status: idle",diff:`- status: probation
15
- + status: idle (graduated, EMA: ${t.toFixed(3)})`,roleId:e,source:"monitor"}),v.info({roleId:e,emaScore:t},"Agent graduated from probation to active"),!0):!1}function Q(e,t){let n=[...e];for(let r of t.recommendations){let o=`[monitor:${r.action}] ${r.detail}`;n.includes(o)||n.push(o)}if(t.failureBehaviors.length>0){let o=`[monitor:diagnostic] Failure patterns detected: ${t.failureBehaviors.map(a=>`${a.category}(${a.count})`).join(", ")}. Review and adjust behavior accordingly.`;n.includes(o)||n.push(o)}return n}E();E();var _=g("admin"),X=.4,Z=1440*60*1e3,y=null;function Te(e,t,n=X){let r=m(t);if(!r||r.status==="retired"||r.status==="inactive"||r.status==="dead")return;let o=$(t,e);S(t,{performanceScore:o}),I(t,o,n)?_.info({roleId:t,emaScore:o},"Probation role graduated"):o<n&&U(t,o,n)&&j(t)}function we(){y||(y=setInterval(()=>{_.info("Running daily diagnostic reports");let e=L(void 0,1e3);for(let t of e)if(!(t.status==="retired"||t.status==="inactive"))try{A(t.id)}catch(n){_.error({roleId:t.id,error:n},"Daily diagnostic failed")}},Z),_.info("Monitor initialized with daily diagnostic timer"))}function Ae(){y&&(clearInterval(y),y=null,_.info("Monitor stopped"))}export{T as a,B as b,Te as c,we as d,Ae as e};
@@ -1,49 +0,0 @@
1
- import{a as C,b as A}from"./chunk-WXN3PSVX.js";import{a as T,b as p}from"./chunk-L7426WNY.js";import{a as u}from"./chunk-L7JP7DUO.js";import{p as x}from"./chunk-HAWA62R2.js";import{a as I,b as d,d as y,f as P}from"./chunk-VF6GJGD6.js";import{d as h}from"./chunk-T25NLVMY.js";import{i as b,l as J}from"./chunk-XNWZZYAV.js";import{c as k}from"./chunk-3DAK2XWP.js";J();import{v4 as l}from"uuid";import{CronExpressionParser as D}from"cron-parser";import{v4 as M}from"uuid";var m=k("scheduler"),w=class{maxRetries=3;baseDelayMs=1e3;async execute(e,t){let o=h(),r=e.config?.fileAccess,i={timeout:e.config?.timeout??o.timeout,approvalRequired:o.approvalRequired,approvalTimeout:o.approvalTimeout,fileAccess:{allowedPaths:[...o.fileAccess.allowedPaths,...r?.allowedPaths??[]],deniedPaths:[...o.fileAccess.deniedPaths,...r?.deniedPaths??[]]},plugins:e.config?.plugins,mcpServers:e.config?.mcpServers,model:e.config?.model??o.model,maxTurns:e.config?.maxTurns??o.maxTurns,maxBudgetUsd:e.config?.maxBudgetUsd??o.maxBudgetUsd,env:{...o.env,...e.config?.env},claudeCodePath:o.claudeCodePath},s={templateId:e.id,executionId:t,stepResults:new Map,config:i,rolePreference:e.rolePreference,deliverTo:e.deliverTo,reportTo:e.reportTo},a=this.sortSteps(e.steps);for(let c of a){try{await this.executeStep(c,s)}catch(_){m.error({stepId:c.id,error:_},"Workflow step failed");break}if(s.stepResults.get(c.id)?.status==="failed"){m.warn({stepId:c.id},"Workflow step failed, workflow aborted");break}}m.info({executionId:t,completedSteps:s.stepResults.size,totalSteps:a.length},"Workflow completed")}sortSteps(e){let t=new Set,o=[],r=new Map(e.map(s=>[s.id,s])),i=s=>{if(!t.has(s.id)){if(t.add(s.id),s.dependsOn)for(let a of s.dependsOn){let c=r.get(a);c&&i(c)}o.push(s)}};for(let s of e)i(s);return o}async executeStep(e,t){let o=this.resolveVariables(e.prompt,t.stepResults),r=M();T({id:r,status:"pending",prompt:o,config:t.config,createdAt:Date.now(),parentId:t.executionId,templateId:t.templateId,roleId:t.rolePreference,deliverTo:t.deliverTo,reportTo:t.reportTo}),m.debug({stepId:e.id,taskId:r},"Created workflow step as task"),u.emit({type:"task_created",taskId:r});let i=await this.executeWithRetry(r,e.id),s=p(r);t.stepResults.set(e.id,{stepId:e.id,taskId:r,status:i==="completed"?"completed":"failed",result:s?.result,error:s?.error})}resolveVariables(e,t){return e.replace(/\{\{([^}]+)\.result\}\}/g,(o,r)=>t.get(r)?.result??`[no result from ${r}]`)}async executeWithRetry(e,t){let o=0;for(;o<this.maxRetries;){if(o++,await this.waitForTaskCompletion(e)==="completed")return"completed";if(o<this.maxRetries){let i=this.baseDelayMs*Math.pow(2,o-1);m.info({stepId:t,attempt:o,maxRetries:this.maxRetries,delayMs:i},"Workflow step failed, retrying"),await this.sleep(i)}}return"failed"}waitForTaskCompletion(e,t=6e5){return new Promise(o=>{let r=Date.now(),i=()=>{if(Date.now()-r>t){o("failed");return}let s=p(e);if(!s){o("failed");return}if(s.status==="completed"){o("completed");return}if(s.status==="failed"||s.status==="cancelled"){o("failed");return}setTimeout(i,500)};i()})}sleep(e){return new Promise(t=>setTimeout(t,e))}};var n=k("scheduler"),v="ai-hourly-digest";function O(){if(d(v)){n.debug({templateId:v},"Built-in template already exists");return}let e={id:v,name:"AI Hourly Digest",description:"\u6BCF\u5C0F\u65F6\u641C\u7D22 AI \u524D\u6CBF\u6587\u7AE0\uFF0C\u603B\u7ED3\u540E\u4FDD\u5B58\u5230 Omnifocus",trigger:{type:"cron",cron:"0 * * * *"},enabled:!0,steps:[{id:"search_ai_news",prompt:`\u641C\u7D22\u8FC7\u53BB 24 \u5C0F\u65F6\u5185\u5173\u4E8E AI/\u4EBA\u5DE5\u667A\u80FD\u7684\u6700\u65B0\u524D\u6CBF\u6587\u7AE0\u3002
2
-
3
- \u641C\u7D22\u6765\u6E90:
4
- 1. Hacker News AI \u677F\u5757 (https://news.ycombinator.com/front?day=1)
5
- 2. ArXiv cs.AI \u6700\u65B0\u8BBA\u6587 (https://arxiv.org/list/cs.AI/recent)
6
- 3. Reddit r/MachineLearning \u70ED\u95E8\u5E16\u5B50
7
-
8
- \u627E\u51FA\u4E00\u7BC7\u6700\u6709\u4EF7\u503C\u3001\u6700\u6709\u6280\u672F\u6DF1\u5EA6\u7684\u6587\u7AE0\u3002
9
-
10
- \u8F93\u51FA\u683C\u5F0F:
11
- - \u6807\u9898\uFF1A[\u6587\u7AE0\u6807\u9898]
12
- - \u6765\u6E90\uFF1A[\u7F51\u7AD9/\u5E73\u53F0\u540D\u79F0]
13
- - \u94FE\u63A5\uFF1A[\u5B8C\u6574 URL]
14
- - \u6838\u5FC3\u4EF7\u503C\uFF1A[1-2 \u53E5\u8BDD\u8BF4\u660E\u4E3A\u4EC0\u4E48\u8FD9\u7BC7\u6587\u7AE0\u503C\u5F97\u770B]`},{id:"summarize_article",dependsOn:["search_ai_news"],prompt:`\u9605\u8BFB\u5E76\u603B\u7ED3\u8FD9\u7BC7\u6587\u7AE0\u3002
15
-
16
- \u6587\u7AE0\u4FE1\u606F:
17
- {{search_ai_news.result}}
18
-
19
- \u8BF7:
20
- 1. \u7528 WebFetch \u83B7\u53D6\u6587\u7AE0\u5B8C\u6574\u5185\u5BB9
21
- 2. \u63D0\u53D6\u6838\u5FC3\u89C2\u70B9\u548C\u6280\u672F\u7EC6\u8282
22
- 3. \u7528\u4E2D\u6587\u5199\u51FA 300-500 \u5B57\u7684\u603B\u7ED3
23
-
24
- \u603B\u7ED3\u7ED3\u6784:
25
- ## \u6838\u5FC3\u53D1\u73B0
26
- [\u6587\u7AE0\u6700\u91CD\u8981\u7684\u53D1\u73B0/\u521B\u65B0\u70B9]
27
-
28
- ## \u6280\u672F\u7EC6\u8282
29
- [\u5173\u952E\u7684\u6280\u672F\u65B9\u6CD5/\u5B9E\u73B0\u7EC6\u8282]
30
-
31
- ## \u5F71\u54CD/\u610F\u4E49
32
- [\u8FD9\u9879\u5DE5\u4F5C\u7684\u610F\u4E49\u6216\u5BF9\u884C\u4E1A\u7684\u5F71\u54CD]
33
-
34
- ## \u539F\u6587\u94FE\u63A5
35
- [\u6587\u7AE0 URL]`},{id:"save_to_omnifocus",dependsOn:["summarize_article"],prompt:`\u5C06\u6587\u7AE0\u603B\u7ED3\u4FDD\u5B58\u5230 Omnifocus\u3002
36
-
37
- \u603B\u7ED3\u5185\u5BB9:
38
- {{summarize_article.result}}
39
-
40
- \u63D0\u53D6\u6587\u7AE0\u6807\u9898\u548C\u5B8C\u6574\u603B\u7ED3\uFF0C\u7136\u540E\u6267\u884C\u4EE5\u4E0B\u547D\u4EE4\u6DFB\u52A0\u5230 Omnifocus Inbox\uFF1A
41
-
42
- osascript /Users/norvyn/Code/Projects/Adam/scripts/add-to-omnifocus.applescript "[\u6587\u7AE0\u6807\u9898] AI \u524D\u6CBF\u901F\u9012" "[\u5B8C\u6574\u603B\u7ED3\u5185\u5BB9]"
43
-
44
- \u6CE8\u610F\uFF1A
45
- - \u5C06 [\u6587\u7AE0\u6807\u9898] \u66FF\u6362\u4E3A\u5B9E\u9645\u6807\u9898
46
- - \u5C06 [\u5B8C\u6574\u603B\u7ED3\u5185\u5BB9] \u66FF\u6362\u4E3A\u5B8C\u6574\u7684\u603B\u7ED3\u6587\u672C\uFF08\u5305\u542B\u6838\u5FC3\u53D1\u73B0\u3001\u6280\u672F\u7EC6\u8282\u3001\u5F71\u54CD/\u610F\u4E49\u548C\u539F\u6587\u94FE\u63A5\uFF09
47
- - \u603B\u7ED3\u5185\u5BB9\u4F7F\u7528\u6362\u884C\u7B26\u5206\u9694\u5404\u90E8\u5206
48
-
49
- \u5B8C\u6210\u540E\u8F93\u51FA\uFF1A\u5DF2\u4FDD\u5B58\u5230 Omnifocus\uFF1A[\u4EFB\u52A1\u6807\u9898]`}],config:{timeout:300,fileAccess:{allowedPaths:["~/.adam/","/Users/norvyn/Code/Projects/Adam/scripts/"],deniedPaths:[]}},tags:["ai","digest","hourly","automation"],createdAt:Date.now()};I(e),n.info({templateId:v,cron:"0 * * * *"},"Registered built-in AI Hourly Digest template")}var R=class{cronJobs=new Map;workflowExecutor=new w;started=!1;taskCompletionHandler=null;async start(){if(this.started)return;this.started=!0,O();let e=y(!0),t=0;for(let r of e)r.trigger.type==="cron"&&r.trigger.cron&&(this.scheduleCronJob(r),t++);let o=0;for(let r of e)r.trigger.type==="once"&&r.trigger.runAt&&(this.scheduleOnceJob(r.id),o++);this.taskCompletionHandler=r=>{r.newStatus==="completed"&&this.checkEventTriggers(r.taskId).catch(i=>{n.error({taskId:r.taskId,error:i},"Event trigger check failed")})},u.on("task_status_change",this.taskCompletionHandler),this.cronJobs.set("memory-cleanup",setInterval(()=>{this.runMemoryCleanup()},36e5)),n.info({cronCount:t,onceCount:o},"Bree engine started with cron jobs + memory cleanup")}runMemoryCleanup(){try{let e=b(void 0,1e3,0),t=0;for(let o of e)t+=x(o.id);t>0&&n.info({totalCleaned:t},"Memory cleanup completed")}catch(e){n.warn({error:e},"Memory cleanup failed")}}async stop(){for(let[,e]of this.cronJobs)clearTimeout(e),clearInterval(e);this.cronJobs.clear(),this.taskCompletionHandler&&(u.off("task_status_change",this.taskCompletionHandler),this.taskCompletionHandler=null),this.started=!1,n.info("Bree engine stopped")}scheduleCronJob(e){let t=`template-${e.id}`;this.cronJobs.has(t)&&(clearTimeout(this.cronJobs.get(t)),this.cronJobs.delete(t));let o;try{o=D.parse(e.trigger.cron)}catch{n.warn({templateId:e.id,cron:e.trigger.cron},"Invalid cron expression");return}let r=()=>{let f=o.next().getTime()-Date.now();return Math.max(f,1e3)},i=()=>{this.executeCronTrigger(e.id).catch(f=>{n.error({templateId:e.id,error:f},"Cron trigger failed")});let c=setTimeout(i,r());this.cronJobs.set(t,c)},s=r(),a=setTimeout(i,s);this.cronJobs.set(t,a),n.debug({jobName:t,nextRun:new Date(Date.now()+s).toISOString()},"Scheduled cron job")}async executeCronTrigger(e){let t=d(e);!t||!t.enabled||(n.info({templateName:t.name},"Cron triggered"),await this.executeWorkflow(t,l()))}async scheduleJob(e){let t=d(e);t&&t.trigger.type==="cron"&&t.trigger.cron&&this.scheduleCronJob(t)}async unscheduleJob(e){let t=`template-${e}`,o=this.cronJobs.get(t);o&&(clearTimeout(o),this.cronJobs.delete(t))}async runNow(e){let t=d(e);if(!t)throw new Error(`Template ${e} not found`);let o=l();return this.executeWorkflow(t,o).catch(r=>{n.error({templateId:e,error:r},"Workflow execution failed")}),o}async checkEventTriggers(e){let t=p(e);if(!t)return;let o=y(!0),r=o.filter(i=>i.trigger.type==="event"&&i.trigger.event==="task_complete");for(let i of r)n.debug({templateName:i.name},"Event trigger matched"),await this.executeWorkflow(i,l());if(t.templateId){let i=o.filter(s=>s.trigger.type!=="event"||!s.trigger.event?!1:s.trigger.event===`template_complete:${t.templateId}`);for(let s of i)n.info({templateName:s.name,sourceTemplateId:t.templateId},"Template complete trigger matched"),await this.executeWorkflow(s,l())}}async executeWorkflow(e,t){if(n.info({templateName:e.name,executionId:t},"Executing workflow"),e.goalIds&&e.goalIds.length>0){for(let o of e.goalIds){let r=A(o);if(!r){n.warn({goalId:o,templateId:e.id},"Goal reference not found, skipping");continue}let i=l();C({id:i,name:r.name,description:r.description,roleId:r.roleId,metricType:r.metricType,targetValue:r.targetValue,currentValue:0,deadline:r.deadline,budgetUsd:r.budgetUsd,status:"active",createdAt:Date.now(),sourceSessionId:e.sourceSessionId,deliverTo:e.deliverTo,reportTo:e.reportTo});let s=l();T({id:s,status:"pending",prompt:`Decompose and execute goal: ${r.name}. ${r.description??""}`,parentId:i,config:h(),createdAt:Date.now(),templateId:e.id,roleId:e.rolePreference,deliverTo:e.deliverTo,reportTo:e.reportTo}),u.emit({type:"task_created",taskId:s}),n.info({templateId:e.id,sourceGoalId:o,newGoalId:i,taskId:s},"Goal reference triggered, dispatched decomposition task")}return}await this.workflowExecutor.execute(e,t)}scheduleOnceJob(e){let t=d(e);if(!t||!t.enabled||t.trigger.type!=="once")return;let r=(t.trigger.runAt?new Date(t.trigger.runAt).getTime():0)-Date.now();if(r<=0){n.info({templateId:e,runAt:t.trigger.runAt},"Once-shot template past due, executing immediately"),this.executeOnceTrigger(e).catch(a=>{n.error({templateId:e,error:a},"Once trigger execution failed")});return}let i=`template-${e}`;this.cronJobs.has(i)&&clearTimeout(this.cronJobs.get(i));let s=setTimeout(()=>{this.cronJobs.delete(i),this.executeOnceTrigger(e).catch(a=>{n.error({templateId:e,error:a},"Once trigger execution failed")})},r);this.cronJobs.set(i,s),n.info({templateId:e,runAt:t.trigger.runAt,delayMs:r},"Scheduled once-shot job")}async executeOnceTrigger(e){let t=d(e);!t||!t.enabled||(n.info({templateName:t.name},"Once-shot triggered"),await this.executeWorkflow(t,l()),P(e),n.info({templateId:e},"Once-shot template auto-disabled after execution"))}},S=null;function Y(){return S}function Z(g){S=g}export{R as a,Y as b,Z as c};
@@ -1 +0,0 @@
1
- import{c as e,g as t}from"./chunk-SFUS33SO.js";t();var o={defaults:{timeout:600,maxTurns:100,maxBudgetUsd:5,effort:"high",model:"",settingSources:["user","project"],allowedTools:[],disallowedTools:[],fileAccess:{allowedPaths:["./","~/.claude"],deniedPaths:["~/.ssh","~/.aws","~/.config"]},approvalRequired:["rm -rf","git push","git reset","curl.*POST"],approvalTimeout:300,env:{},plugins:[],workspacePath:e,workspaceRetention:"immediate"},externalApis:[],server:{port:7100,host:"0.0.0.0",timezone:"system"},logging:{level:"info"},roles:{presets:[],evolution:{triggerEvery:5,reflectionThreshold:150,retirementThreshold:.4,probationTasks:5}},chat:{sessionTimeoutMinutes:30,maxSessionTurns:20,autoTitle:!0,archiveExtractMemory:!0},watchdog:{enabled:!0,intervalMinutes:5,rules:{managerHealthCheck:{enabled:!0,action:"notify",staleDurationMinutes:15},staleTasks:{enabled:!0,action:"notify",maxPendingMinutes:30},staleRunningTasks:{enabled:!0,action:"notify",maxRunningMinutes:15},dbMaintenance:{enabled:!0,action:"ignore",walCheckpointThresholdMB:100}}},execution:{maxConcurrent:5,maxBudgetPerTaskUsd:5,pollIntervalMs:3e4},anthropic:{apiKey:"",baseUrl:"",model:"",defaultOpusModel:"",defaultSonnetModel:"",defaultHaikuModel:"",smallFastModel:""}};export{o as a};