hermium 0.1.10 → 0.2.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 (212) hide show
  1. package/README.md +56 -0
  2. package/bin/hermium.mjs +185 -164
  3. package/dist/api.mjs +3513 -0
  4. package/dist/public/assets/css/index-Dfs9RUU9.css +1 -0
  5. package/dist/public/assets/css/styles-B8p6jk5Z.css +1 -0
  6. package/dist/public/assets/js/ChatInputBlock-Bw7AL70H.js +1 -0
  7. package/dist/public/assets/js/MarkdownMessage-8d7Y6VL-.js +1 -0
  8. package/dist/public/assets/js/base-ui-BvQbAt_1.js +1 -0
  9. package/dist/public/assets/js/chat._sessionId-BG6lVraH.js +1 -0
  10. package/dist/public/assets/js/chat.index-D2zdMPTT.js +1 -0
  11. package/dist/public/assets/js/index-C0AK45FU.js +60 -0
  12. package/dist/public/assets/js/index-Cx5En4FK.js +1 -0
  13. package/dist/public/assets/js/memory-CeSRdTkW.js +3 -0
  14. package/dist/public/assets/js/router-8uDKazL-.js +1 -0
  15. package/dist/public/assets/js/settings-Bc3Y5zXO.js +1 -0
  16. package/dist/public/assets/js/skills-DZv7sA_5.js +1 -0
  17. package/dist/public/assets/js/theme-CPkdkpaj.js +1 -0
  18. package/dist/public/assets/js/usage-DXQsT9_b.js +1 -0
  19. package/dist/public/assets/woff2/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  20. package/dist/public/assets/woff2/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  21. package/dist/public/assets/woff2/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  22. package/dist/public/assets/woff2/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  23. package/dist/public/assets/woff2/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  24. package/dist/public/favicon.ico +0 -0
  25. package/dist/public/logo.png +0 -0
  26. package/package.json +1 -1
  27. package/dist/public/assets/IconAlertCircle-BW147gsG.js +0 -1
  28. package/dist/public/assets/IconAlertTriangle-DCoTLVSd.js +0 -1
  29. package/dist/public/assets/IconCheck-DAO7Fpl9.js +0 -1
  30. package/dist/public/assets/IconCode-BqfTl5wU.js +0 -1
  31. package/dist/public/assets/IconLoader2-B_pehSXN.js +0 -1
  32. package/dist/public/assets/IconRefresh-BbMGoMV8.js +0 -1
  33. package/dist/public/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
  34. package/dist/public/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
  35. package/dist/public/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
  36. package/dist/public/assets/index-BL9a2Xg9.js +0 -1
  37. package/dist/public/assets/index-BSwXjgjr.js +0 -1
  38. package/dist/public/assets/index-BWl8tn18.js +0 -1
  39. package/dist/public/assets/index-CQh8SXb2.js +0 -94
  40. package/dist/public/assets/index-Cxd-kSUY.js +0 -1
  41. package/dist/public/assets/index-DA5SH--7.js +0 -2
  42. package/dist/public/assets/index-DCHbvtBS.js +0 -1
  43. package/dist/public/assets/index-DCYXJZEe.js +0 -1
  44. package/dist/public/assets/index-DFDfp0ca.js +0 -1
  45. package/dist/public/assets/index-GuAAqSCJ.js +0 -14
  46. package/dist/public/assets/index-WIDirTHx.js +0 -29
  47. package/dist/public/assets/index-X3XZcAzy.js +0 -1
  48. package/dist/public/assets/input-7TQEEJq6.js +0 -1
  49. package/dist/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  50. package/dist/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  51. package/dist/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  52. package/dist/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  53. package/dist/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  54. package/dist/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  55. package/dist/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  56. package/dist/public/assets/models-BlUb1eaf.js +0 -1
  57. package/dist/public/assets/styles-PHtUFHUr.css +0 -1
  58. package/dist/public/assets/switch-B_iYUUM3.js +0 -1
  59. package/dist/public/assets/syntax-highlighter-DcBYfnEK.js +0 -6
  60. package/dist/public/assets/textarea-Dm4aaRqS.js +0 -1
  61. package/dist/public/favicon.png +0 -0
  62. package/dist/public/nous-logo.png +0 -0
  63. package/dist/server/index.mjs +0 -244
  64. package/dist/web-server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +0 -6
  65. package/dist/web-server/_chunks/ssr-renderer.mjs +0 -22
  66. package/dist/web-server/_libs/babel__runtime.mjs +0 -237
  67. package/dist/web-server/_libs/bail.mjs +0 -8
  68. package/dist/web-server/_libs/base-ui__react.mjs +0 -9554
  69. package/dist/web-server/_libs/base-ui__utils.mjs +0 -1101
  70. package/dist/web-server/_libs/ccount.mjs +0 -16
  71. package/dist/web-server/_libs/character-entities-legacy.mjs +0 -111
  72. package/dist/web-server/_libs/character-entities.mjs +0 -2130
  73. package/dist/web-server/_libs/character-reference-invalid.mjs +0 -33
  74. package/dist/web-server/_libs/class-variance-authority.mjs +0 -44
  75. package/dist/web-server/_libs/clsx.mjs +0 -16
  76. package/dist/web-server/_libs/comma-separated-tokens.mjs +0 -31
  77. package/dist/web-server/_libs/cookie-es.mjs +0 -44
  78. package/dist/web-server/_libs/croner.mjs +0 -1
  79. package/dist/web-server/_libs/crossws.mjs +0 -1
  80. package/dist/web-server/_libs/decode-named-character-reference+[...].mjs +0 -8
  81. package/dist/web-server/_libs/devlop.mjs +0 -8
  82. package/dist/web-server/_libs/escape-string-regexp.mjs +0 -9
  83. package/dist/web-server/_libs/estree-util-is-identifier-name.mjs +0 -11
  84. package/dist/web-server/_libs/extend.mjs +0 -97
  85. package/dist/web-server/_libs/fault.mjs +0 -1
  86. package/dist/web-server/_libs/floating-ui__core.mjs +0 -663
  87. package/dist/web-server/_libs/floating-ui__dom.mjs +0 -624
  88. package/dist/web-server/_libs/floating-ui__react-dom.mjs +0 -279
  89. package/dist/web-server/_libs/floating-ui__utils.mjs +0 -322
  90. package/dist/web-server/_libs/format.mjs +0 -1
  91. package/dist/web-server/_libs/h3.mjs +0 -408
  92. package/dist/web-server/_libs/hast-util-parse-selector.mjs +0 -39
  93. package/dist/web-server/_libs/hast-util-to-jsx-runtime.mjs +0 -388
  94. package/dist/web-server/_libs/hast-util-whitespace.mjs +0 -10
  95. package/dist/web-server/_libs/hastscript.mjs +0 -200
  96. package/dist/web-server/_libs/highlight.js.mjs +0 -1
  97. package/dist/web-server/_libs/hookable.mjs +0 -1
  98. package/dist/web-server/_libs/html-url-attributes.mjs +0 -26
  99. package/dist/web-server/_libs/inline-style-parser.mjs +0 -142
  100. package/dist/web-server/_libs/is-alphabetical.mjs +0 -7
  101. package/dist/web-server/_libs/is-alphanumerical.mjs +0 -8
  102. package/dist/web-server/_libs/is-decimal.mjs +0 -7
  103. package/dist/web-server/_libs/is-hexadecimal.mjs +0 -7
  104. package/dist/web-server/_libs/is-plain-obj.mjs +0 -10
  105. package/dist/web-server/_libs/isbot.mjs +0 -21
  106. package/dist/web-server/_libs/longest-streak.mjs +0 -25
  107. package/dist/web-server/_libs/lowlight.mjs +0 -1
  108. package/dist/web-server/_libs/markdown-table.mjs +0 -142
  109. package/dist/web-server/_libs/mdast-util-find-and-replace.mjs +0 -109
  110. package/dist/web-server/_libs/mdast-util-from-markdown.mjs +0 -717
  111. package/dist/web-server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +0 -156
  112. package/dist/web-server/_libs/mdast-util-gfm-footnote.mjs +0 -117
  113. package/dist/web-server/_libs/mdast-util-gfm-strikethrough.mjs +0 -54
  114. package/dist/web-server/_libs/mdast-util-gfm-table.mjs +0 -157
  115. package/dist/web-server/_libs/mdast-util-gfm-task-list-item.mjs +0 -77
  116. package/dist/web-server/_libs/mdast-util-gfm.mjs +0 -29
  117. package/dist/web-server/_libs/mdast-util-phrasing.mjs +0 -30
  118. package/dist/web-server/_libs/mdast-util-to-hast.mjs +0 -710
  119. package/dist/web-server/_libs/mdast-util-to-markdown.mjs +0 -798
  120. package/dist/web-server/_libs/mdast-util-to-string.mjs +0 -38
  121. package/dist/web-server/_libs/micromark-core-commonmark.mjs +0 -2259
  122. package/dist/web-server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +0 -344
  123. package/dist/web-server/_libs/micromark-extension-gfm-footnote+[...].mjs +0 -279
  124. package/dist/web-server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +0 -98
  125. package/dist/web-server/_libs/micromark-extension-gfm-table.mjs +0 -491
  126. package/dist/web-server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +0 -1
  127. package/dist/web-server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +0 -77
  128. package/dist/web-server/_libs/micromark-extension-gfm.mjs +0 -18
  129. package/dist/web-server/_libs/micromark-factory-destination.mjs +0 -94
  130. package/dist/web-server/_libs/micromark-factory-label.mjs +0 -63
  131. package/dist/web-server/_libs/micromark-factory-space.mjs +0 -24
  132. package/dist/web-server/_libs/micromark-factory-title.mjs +0 -65
  133. package/dist/web-server/_libs/micromark-factory-whitespace.mjs +0 -22
  134. package/dist/web-server/_libs/micromark-util-character.mjs +0 -44
  135. package/dist/web-server/_libs/micromark-util-chunked.mjs +0 -36
  136. package/dist/web-server/_libs/micromark-util-classify-character+[...].mjs +0 -12
  137. package/dist/web-server/_libs/micromark-util-combine-extensions+[...].mjs +0 -41
  138. package/dist/web-server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +0 -19
  139. package/dist/web-server/_libs/micromark-util-decode-string.mjs +0 -21
  140. package/dist/web-server/_libs/micromark-util-encode.mjs +0 -1
  141. package/dist/web-server/_libs/micromark-util-html-tag-name.mjs +0 -69
  142. package/dist/web-server/_libs/micromark-util-normalize-identifier+[...].mjs +0 -6
  143. package/dist/web-server/_libs/micromark-util-resolve-all.mjs +0 -15
  144. package/dist/web-server/_libs/micromark-util-sanitize-uri.mjs +0 -41
  145. package/dist/web-server/_libs/micromark-util-subtokenize.mjs +0 -346
  146. package/dist/web-server/_libs/micromark.mjs +0 -906
  147. package/dist/web-server/_libs/ocache.mjs +0 -1
  148. package/dist/web-server/_libs/ohash.mjs +0 -1
  149. package/dist/web-server/_libs/parse-entities.mjs +0 -245
  150. package/dist/web-server/_libs/property-information.mjs +0 -1210
  151. package/dist/web-server/_libs/react-dom.mjs +0 -10779
  152. package/dist/web-server/_libs/react-markdown.mjs +0 -147
  153. package/dist/web-server/_libs/react-syntax-highlighter.mjs +0 -941
  154. package/dist/web-server/_libs/react.mjs +0 -513
  155. package/dist/web-server/_libs/refractor.mjs +0 -2425
  156. package/dist/web-server/_libs/remark-gfm.mjs +0 -20
  157. package/dist/web-server/_libs/remark-parse.mjs +0 -19
  158. package/dist/web-server/_libs/remark-rehype.mjs +0 -21
  159. package/dist/web-server/_libs/reselect.mjs +0 -1
  160. package/dist/web-server/_libs/rou3.mjs +0 -8
  161. package/dist/web-server/_libs/seroval-plugins.mjs +0 -58
  162. package/dist/web-server/_libs/seroval.mjs +0 -1775
  163. package/dist/web-server/_libs/space-separated-tokens.mjs +0 -11
  164. package/dist/web-server/_libs/srvx.mjs +0 -781
  165. package/dist/web-server/_libs/style-to-js.mjs +0 -72
  166. package/dist/web-server/_libs/style-to-object.mjs +0 -38
  167. package/dist/web-server/_libs/tabler__icons-react.mjs +0 -233
  168. package/dist/web-server/_libs/tanstack__history.mjs +0 -204
  169. package/dist/web-server/_libs/tanstack__query-core.mjs +0 -2552
  170. package/dist/web-server/_libs/tanstack__react-query.mjs +0 -190
  171. package/dist/web-server/_libs/tanstack__react-router.mjs +0 -1120
  172. package/dist/web-server/_libs/tanstack__react-store.mjs +0 -2
  173. package/dist/web-server/_libs/tanstack__router-core.mjs +0 -4288
  174. package/dist/web-server/_libs/tanstack__store.mjs +0 -1
  175. package/dist/web-server/_libs/trim-lines.mjs +0 -41
  176. package/dist/web-server/_libs/trough.mjs +0 -85
  177. package/dist/web-server/_libs/ufo.mjs +0 -54
  178. package/dist/web-server/_libs/unctx.mjs +0 -1
  179. package/dist/web-server/_libs/ungap__structured-clone.mjs +0 -224
  180. package/dist/web-server/_libs/unified.mjs +0 -661
  181. package/dist/web-server/_libs/unist-util-is.mjs +0 -100
  182. package/dist/web-server/_libs/unist-util-position.mjs +0 -27
  183. package/dist/web-server/_libs/unist-util-stringify-position.mjs +0 -27
  184. package/dist/web-server/_libs/unist-util-visit-parents.mjs +0 -83
  185. package/dist/web-server/_libs/unist-util-visit.mjs +0 -24
  186. package/dist/web-server/_libs/unstorage.mjs +0 -1
  187. package/dist/web-server/_libs/use-sync-external-store.mjs +0 -139
  188. package/dist/web-server/_libs/vfile-message.mjs +0 -138
  189. package/dist/web-server/_libs/vfile.mjs +0 -467
  190. package/dist/web-server/_libs/zod.mjs +0 -3915
  191. package/dist/web-server/_libs/zustand.mjs +0 -343
  192. package/dist/web-server/_libs/zwitch.mjs +0 -1
  193. package/dist/web-server/_ssr/index--Bo2_ipW.mjs +0 -277
  194. package/dist/web-server/_ssr/index-BEvygh5x.mjs +0 -612
  195. package/dist/web-server/_ssr/index-BFaKxYfN.mjs +0 -40
  196. package/dist/web-server/_ssr/index-BdrMzRTd.mjs +0 -513
  197. package/dist/web-server/_ssr/index-CoDfv1vI.mjs +0 -66
  198. package/dist/web-server/_ssr/index-Cwp8Gyl1.mjs +0 -1812
  199. package/dist/web-server/_ssr/index-DQsfKYjV.mjs +0 -449
  200. package/dist/web-server/_ssr/index-Dbs9k8Ea.mjs +0 -251
  201. package/dist/web-server/_ssr/index-Dk93oyZD.mjs +0 -213
  202. package/dist/web-server/_ssr/index-KNJ7huw_.mjs +0 -369
  203. package/dist/web-server/_ssr/index.mjs +0 -1558
  204. package/dist/web-server/_ssr/input-BV1DMASc.mjs +0 -20
  205. package/dist/web-server/_ssr/models-MzrvbL2i.mjs +0 -43
  206. package/dist/web-server/_ssr/router-CS6Zq3md.mjs +0 -2134
  207. package/dist/web-server/_ssr/start-HYkvq4Ni.mjs +0 -4
  208. package/dist/web-server/_ssr/switch-Bd-Sg0HG.mjs +0 -33
  209. package/dist/web-server/_ssr/syntax-highlighter-5vezNTce.mjs +0 -62
  210. package/dist/web-server/_ssr/textarea-CB4kQp9w.mjs +0 -18
  211. package/dist/web-server/_tanstack-start-manifest_v-m5lY48LR.mjs +0 -4
  212. package/dist/web-server/index.mjs +0 -611
@@ -1 +0,0 @@
1
- import{c as h,u as f,r as n,a as g,j as e,I as x,B as p,b as m}from"./index-CQh8SXb2.js";import{I as b,a as y}from"./IconCode-BqfTl5wU.js";const w=[["path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0",key:"svg-0"}],["path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0",key:"svg-1"}],["path",{d:"M3 6l0 13",key:"svg-2"}],["path",{d:"M12 6l0 13",key:"svg-3"}],["path",{d:"M21 6l0 13",key:"svg-4"}]],v=h("outline","book","Book",w);const k=[["path",{d:"M15 6l-6 6l6 6",key:"svg-0"}]],j=h("outline","chevron-left","ChevronLeft",k);const N=[["path",{d:"M6.657 18c-2.572 0 -4.657 -2.007 -4.657 -4.483c0 -2.475 2.085 -4.482 4.657 -4.482c.393 -1.762 1.794 -3.2 3.675 -3.773c1.88 -.572 3.956 -.193 5.444 1c1.488 1.19 2.162 3.007 1.77 4.769h.99c1.913 0 3.464 1.56 3.464 3.486c0 1.927 -1.551 3.487 -3.465 3.487h-11.878",key:"svg-0"}]],I=h("outline","cloud","Cloud",N);const S=[["path",{d:"M19.5 12.572l-7.5 7.428l-7.5 -7.428a5 5 0 1 1 7.5 -6.566a5 5 0 1 1 7.5 6.572",key:"svg-0"}]],C=h("outline","heart","Heart",S),R=[{icon:x,label:"Write",title:"Write",description:"Articles, stories, documentation, and all kinds of written content.",prompts:["Write a short story about a robot learning to paint — make it emotional and reflective, around 500 words.","Draft a professional email template for following up with clients after a meeting.","Write a persuasive blog post on why companies should adopt a 4-day work week.","Create a product description for a smart water bottle that tracks hydration, 3 sentences max per feature.","Rewrite this paragraph to be more concise and impactful: [paste text]"]},{icon:v,label:"Learn",title:"Learn",description:"Explore new topics, get clear explanations, and dive deep into any subject.",prompts:["Explain quantum computing like I'm 10 years old — simple but accurate with fun analogies.","Teach me the basics of investing: stocks, bonds, ETFs, and how to start with $500.","Give me a 5-minute summary of the French Revolution — key dates, people, and outcomes.","Explain how large language models like you actually work under the hood.","Walk me through the core principles of color theory for UI design."]},{icon:b,label:"Code",title:"Code",description:"Build, debug, refactor, and architect software with AI assistance.",prompts:["Build a Python script that monitors a directory for new files and uploads them to S3. Include error handling, logging, and a config file.","Review this code for performance bottlenecks and suggest specific improvements: [paste code]","Create a React hook that debounces a value and returns loading/error states.","Write a SQL query to find the top 5 customers by revenue this month, with their last order date.","Explain the difference between REST and GraphQL — when would you choose one over the other, with a real example."]},{icon:C,label:"Life stuff",title:"Life Stuff",description:"Productivity, habits, health, relationships, and everyday advice.",prompts:["Give me a daily routine that balances deep work, exercise, social time, and rest. I work from home and tend to overwork.","How do I start a regular meditation practice? Suggest a beginner-friendly 10-minute routine.","I want to read more books — help me set up a sustainable reading habit and pick my first 5.","What are 3 evidence-backed techniques to reduce anxiety before a big presentation?","Help me plan a weekly meal prep routine that's healthy, affordable, and takes under 2 hours on Sunday."]},{icon:I,label:"Weather",title:"Weather",description:"Forecasts, climate insights, and weather patterns anywhere in the world.",prompts:["What's the weather like today in my area? Give me a detailed forecast with temperature, humidity, and chance of rain.","What's the best time of year to visit Tokyo for mild weather and fewer crowds?","Explain how hurricanes form and how their intensity is categorized.","Compare the climates of San Francisco and New York — which one has milder winters?","What does 'dew point' actually mean and why does it matter for comfort?"]}];function E(){const[i,a]=n.useState("");return n.useEffect(()=>{const r=new Date().getHours();r<12?a("Good morning"):r<17?a("Good afternoon"):r<21?a("Good evening"):a("Good night")},[]),i}function W({onSubmit:i,disabled:a}){const[r,c]=n.useState(""),s=n.useRef(null),d=n.useCallback(()=>{const t=s.current;t&&(t.style.height="auto",t.style.height=`${Math.min(t.scrollHeight,200)}px`)},[]);n.useEffect(()=>{d()},[r,d]),n.useEffect(()=>{s.current?.focus()},[]);const l=n.useCallback(()=>{const t=r.trim();!t||a||(c(""),s.current&&(s.current.style.height="auto"),i(t))},[r,a,i]);function u(t){t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),l())}const o=r.trim().length>0;return e.jsxs("div",{className:"flex min-h-[80px] flex-col rounded-2xl border border-border bg-card shadow-sm transition-colors cursor-text hover:border-border/80",children:[e.jsx("textarea",{ref:s,value:r,onChange:t=>c(t.target.value),onKeyDown:u,placeholder:"Ask anything…",rows:1,disabled:a,className:m("w-full rounded-none border-0 p-4 text-[15px] text-foreground resize-none shadow-none outline-none bg-transparent whitespace-pre-wrap break-words placeholder:text-muted-foreground disabled:opacity-50","min-h-[56px] max-h-[200px]")}),e.jsx("div",{className:"flex min-h-[40px] items-center justify-end p-2 pb-1",children:e.jsx(p,{variant:"ghost",size:"icon-sm",className:m("rounded-full transition-colors cursor-pointer",o&&!a?"bg-primary hover:bg-primary/90 text-primary-foreground":"bg-primary text-primary-foreground opacity-40"),disabled:!o||a,onClick:l,title:"Send message",children:e.jsx(y,{className:"h-4 w-4"})})})]})}function _(){const i=f(),a=E(),[r,c]=n.useState(null),[s,d]=n.useState(!1),l=n.useRef(!1),u=n.useCallback(async o=>{if(!l.current){l.current=!0,d(!0);try{const t=await g();o&&sessionStorage.setItem(`hermium_pending_msg_${t.id}`,o),i({to:"/chat/$sessionId",params:{sessionId:t.id}})}catch{l.current=!1,d(!1)}}},[i]);return e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-4 overflow-hidden",children:[e.jsx("div",{className:"mb-10 text-center",children:e.jsx("h1",{className:"text-5xl font-semibold tracking-tight",children:a})}),e.jsx("div",{className:"w-full max-w-3xl",children:e.jsx(W,{onSubmit:u,disabled:s})}),e.jsx("div",{className:"mt-6 w-full max-w-3xl",children:r?e.jsxs("div",{className:"rounded-2xl border bg-card p-6",style:{animation:"fadeSlideIn 0.2s ease-out"},children:[e.jsxs("button",{disabled:s,onClick:()=>c(null),className:"mb-4 flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:[e.jsx(j,{className:"size-3.5"}),"Back to suggestions"]}),e.jsx("ul",{className:"space-y-2",children:r.prompts.map((o,t)=>e.jsx("li",{children:e.jsxs("button",{disabled:s,onClick:()=>u(o),className:"group w-full rounded-xl border border-border bg-muted/30 px-4 py-3 text-left text-sm leading-relaxed text-foreground transition-colors hover:bg-muted/60 hover:border-foreground/20 disabled:opacity-50",children:[e.jsxs("span",{className:"mr-2 text-xs font-medium text-muted-foreground",children:[t+1,"."]}),o]})},t))})]},"prompt-card"):e.jsx("div",{className:"flex flex-wrap justify-center gap-2",style:{animation:"fadeSlideIn 0.2s ease-out"},children:R.map(o=>{const t=o.icon;return e.jsxs(p,{variant:"ghost",disabled:s,className:"group flex items-center gap-2 rounded-lg border border-border bg-muted/40 dark:bg-muted/40 px-3 py-1.5 text-sm text-foreground transition-colors duration-200 ease-out hover:bg-muted/60 h-auto disabled:opacity-50",onClick:()=>c(o),children:[e.jsx(t,{className:"h-5 w-5 text-muted-foreground transition-colors group-hover:text-foreground"}),e.jsx("span",{className:"text-[15px]",children:o.label})]},o.label)})},"chips")})]})}const D=_;export{D as component};
@@ -1,2 +0,0 @@
1
- import{c as j,g as z,p as Q,r as o,j as e,e as b,f as V,h as B,i as D,b as x}from"./index-CQh8SXb2.js";import{S as G}from"./switch-B_iYUUM3.js";import{I as C}from"./IconLoader2-B_pehSXN.js";import{I as H}from"./IconAlertCircle-BW147gsG.js";import{I as K}from"./IconRefresh-BbMGoMV8.js";import{M as O,r as W}from"./index-WIDirTHx.js";const X=[["path",{d:"M9 15l6 -6",key:"svg-0"}],["path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464",key:"svg-1"}],["path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463",key:"svg-2"}]],J=j("outline","link","Link",X);const U=[["path",{d:"M6.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3",key:"svg-1"}]],Y=j("outline","tag","Tag",U);const Z=[["path",{d:"M10 7a2 2 0 0 1 2 -2h6a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-6a2 2 0 0 1 -2 -2l0 -10",key:"svg-0"}],["path",{d:"M7 7l0 10",key:"svg-1"}],["path",{d:"M4 8l0 8",key:"svg-2"}]],ee=j("outline","versions","Versions",Z);async function te(){return z("/api/hermes/skills")}async function se(l,a){return z(`/api/hermes/skills/${l}/${a}/SKILL.md`)}async function re(l,a){return Q(`/api/hermes/skills/${l}/${a}/toggle`)}const le={a({href:l,children:a}){return e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 underline underline-offset-2 decoration-blue-400/30 hover:decoration-blue-600/60 transition-colors",children:a})},img({src:l,alt:a}){return e.jsx("img",{src:l,alt:a,className:"rounded-xl max-w-full my-4",loading:"lazy"})},pre({children:l}){return e.jsx("pre",{className:"my-5 rounded-xl bg-muted/50 border border-border/60 px-5 py-4 text-[13px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap",children:l})},code({children:l,className:a}){return a?e.jsx("code",{className:a,children:l}):e.jsx("code",{className:"rounded-md bg-muted/70 px-1.5 py-0.5 text-[13px] font-mono text-foreground/90 border border-border/50",children:l})}};function ne(){const[l,a]=o.useState([]),[p,I]=o.useState(0),[L,k]=o.useState(!0),[N,_]=o.useState(null),[u,y]=o.useState(""),[d,M]=o.useState(null),[i,q]=o.useState(null),[v,E]=o.useState(null),[$,c]=o.useState(""),[R,g]=o.useState(!1),[w,P]=o.useState(new Set),f=o.useCallback(async()=>{k(!0),_(null);try{const t=await te();a(t.categories),I(t.total)}catch(t){_(t instanceof Error?t.message:"Failed to load skills")}finally{k(!1)}},[]);o.useEffect(()=>{f()},[f]),o.useEffect(()=>{if(!d||!i){c("");return}let t=!1;return g(!0),se(d,i).then(s=>{if(!t){const r=s.content;if(r.startsWith("---")){const n=r.indexOf(`
2
- ---`,3);c(n!==-1?r.slice(n+4).trim():r)}else c(r);g(!1)}}).catch(s=>{t||(c(s instanceof Error?s.message:"Failed to load skill"),g(!1))}),()=>{t=!0}},[d,i]);const m=u.toLowerCase().trim(),S=m?l.map(t=>({...t,skills:(t.skills??[]).filter(s=>s.name.toLowerCase().includes(m)||s.description.toLowerCase().includes(m)||(s.tags??[]).some(r=>r.toLowerCase().includes(m)))})).filter(t=>t.skills.length>0||t.name.toLowerCase().includes(m)):l,T=t=>{P(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},F=(t,s,r)=>{M(t),q(s),E(r)},A=async(t,s)=>{a(r=>r.map(n=>n.name===t?{...n,skills:n.skills.map(h=>h.name===s?{...h,disabled:!h.disabled}:h)}:n));try{await re(t,s)}catch{f()}};return L?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-muted-foreground",children:[e.jsx(C,{className:"size-6 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading skills..."})]})}):N?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-muted-foreground",children:[e.jsx(H,{className:"size-8 text-red-500"}),e.jsx("span",{className:"text-sm",children:N}),e.jsxs("button",{onClick:f,className:"inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium bg-muted hover:bg-muted/80 transition-colors",children:[e.jsx(K,{className:"size-3.5"}),"Retry"]})]})}):e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("aside",{className:"flex w-64 shrink-0 flex-col border-r border-border",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-3.5 shrink-0",children:[e.jsx(b,{className:"size-5 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-semibold text-foreground",children:["Skills",p>0&&e.jsxs("span",{className:"ml-1.5 text-[11px] font-normal text-muted-foreground",children:["(",p,")"]})]})]}),e.jsx("div",{className:"px-3 pb-2 shrink-0",children:e.jsxs("div",{className:"relative",children:[e.jsx(V,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground/50"}),e.jsx("input",{value:u,onChange:t=>y(t.target.value),placeholder:"Search skills...",className:"w-full rounded-md border border-border/60 bg-muted/30 pl-8 pr-8 py-1.5 text-xs text-foreground placeholder:text-muted-foreground/40 outline-none focus:ring-1 focus:ring-primary/20 focus:border-primary/30"}),u&&e.jsx("button",{onClick:()=>y(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground/40 hover:text-muted-foreground",children:e.jsx(B,{className:"size-3"})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:S.length===0?e.jsx("div",{className:"px-4 py-8 text-center",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:u?"No skills match your search":"No skills found"})}):S.map(t=>e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>T(t.name),className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-left hover:bg-muted/40 transition-colors",children:[e.jsx(D,{className:x("size-3 shrink-0 text-muted-foreground/50 transition-transform",w.has(t.name)&&"-rotate-90")}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground truncate",children:t.name.replace(/-/g," ")}),e.jsx("span",{className:"text-[10px] text-muted-foreground/50 ml-auto shrink-0",children:t.skills.length})]}),!w.has(t.name)&&e.jsx("div",{className:"pb-1",children:(t.skills??[]).map(s=>{const r=d===t.name&&i===s.name;return e.jsxs("button",{onClick:()=>F(t.name,s.name,s.name),className:x("flex w-full items-start gap-2 px-3 py-1.5 pl-8 text-left transition-colors",r?"bg-muted text-foreground":s.disabled?"text-muted-foreground/40 hover:bg-muted/20":"text-muted-foreground hover:bg-muted/30 hover:text-foreground"),children:[e.jsxs("div",{className:x("min-w-0 flex-1",s.disabled&&"opacity-50"),children:[e.jsx("div",{className:x("truncate text-xs font-medium",s.disabled&&"line-through"),children:s.name}),s.description&&e.jsx("div",{className:"truncate text-[10px] text-muted-foreground/60 mt-0.5",children:s.description})]}),e.jsx("div",{className:"shrink-0",onClick:n=>n.stopPropagation(),children:e.jsx(G,{checked:!s.disabled,onCheckedChange:()=>A(t.name,s.name)})})]},s.name)})})]},t.name))})]}),e.jsx("div",{className:"flex flex-1 flex-col min-w-0 overflow-y-auto",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-border px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex size-8 items-center justify-center rounded-lg bg-muted/50 border border-border/50",children:e.jsx(b,{className:"size-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground truncate",children:v}),e.jsxs("p",{className:"text-xs text-muted-foreground/60 mt-0.5 flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/40",children:d?.replace(/-/g," ")}),e.jsx("span",{className:"text-muted-foreground/30",children:"/"}),e.jsx("span",{children:v})]})]})]}),(()=>{const s=l.find(r=>r.name===d)?.skills.find(r=>r.name===i);return s?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-3",children:[s.version&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground/60 bg-muted/40 rounded-full px-2 py-0.5",children:[e.jsx(ee,{className:"size-3"}),"v",s.version]}),(s.tags??[]).map(r=>e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground/60 bg-muted/40 rounded-full px-2 py-0.5",children:[e.jsx(Y,{className:"size-3"}),r]},r))]}):null})()]}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 py-6",children:R?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(C,{className:"size-5 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("div",{className:x("prose-sm max-w-none","[&_h1]:mt-8 [&_h1]:mb-4 [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:tracking-tight [&_h1]:text-foreground","[&_h2]:mt-7 [&_h2]:mb-3 [&_h2]:text-xl [&_h2]:font-semibold [&_h2]:tracking-tight [&_h2]:text-foreground","[&_h3]:mt-6 [&_h3]:mb-2.5 [&_h3]:text-lg [&_h3]:font-semibold [&_h3]:text-foreground","[&_h4]:mt-5 [&_h4]:mb-2 [&_h4]:text-base [&_h4]:font-medium [&_h4]:text-foreground","[&_p]:my-4 [&_p]:leading-[1.75] [&_p]:text-foreground/85","[&_ul]:my-4 [&_ul]:pl-6 [&_ul]:list-disc [&_ul]:space-y-1.5 [&_ul]:marker:text-muted-foreground/40","[&_ol]:my-4 [&_ol]:pl-6 [&_ol]:list-decimal [&_ol]:space-y-1.5 [&_ol]:marker:text-muted-foreground/40","[&_li]:leading-relaxed [&_li]:text-foreground/85","[&_blockquote]:my-5 [&_blockquote]:border-l-[3px] [&_blockquote]:border-amber-400 dark:[&_blockquote]:border-amber-500 [&_blockquote]:pl-4 [&_blockquote]:text-muted-foreground [&_blockquote]:italic [&_blockquote]:leading-relaxed","[&_hr]:my-8 [&_hr]:border-border/40","[&_table]:w-full [&_table]:my-4 [&_table]:text-sm","[&_th]:border [&_th]:border-border [&_th]:bg-muted/60 [&_th]:px-4 [&_th]:py-2.5 [&_th]:text-left [&_th]:font-medium [&_th]:text-foreground/80 [&_th]:text-xs [&_th]:uppercase [&_th]:tracking-wider","[&_td]:border [&_td]:border-border [&_td]:px-4 [&_td]:py-2.5 [&_td]:text-foreground/80","[&>*:first-child]:mt-0 [&>*:last-child]:mb-0"),children:e.jsx(O,{remarkPlugins:[W],components:le,children:$})}),(()=>{const r=l.find(n=>n.name===d)?.skills.find(n=>n.name===i)?.related_skills??[];return r.length?e.jsxs("div",{className:"mt-8 pt-6 border-t border-border",children:[e.jsxs("h4",{className:"flex items-center gap-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:[e.jsx(J,{className:"size-3"}),"Related Skills"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(n=>e.jsx("span",{className:"rounded-md bg-muted/40 px-2.5 py-1 text-xs text-muted-foreground border border-border/40",children:n},n))})]}):null})()]})})]}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-muted-foreground max-w-sm text-center",children:[e.jsx("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-muted/50 border border-border/50",children:e.jsx(b,{className:"size-7 text-muted-foreground/25"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground/60",children:"Select a skill to view details"}),e.jsx("p",{className:"text-xs text-muted-foreground/50 mt-1",children:"Browse skills from your Hermes agent library. Each skill provides instructions and context for specific tasks."})]})]})})})]})}const xe=ne;export{xe as component};
@@ -1 +0,0 @@
1
- import{c as I,r as l,j as e,b as u,n as z,q as C,p as F,s as J,t as L,B as y,o as D,I as K,v as A,g as P}from"./index-CQh8SXb2.js";import{I as _}from"./input-7TQEEJq6.js";import{I as Q,T as B,a as E,b as W}from"./textarea-Dm4aaRqS.js";import{I as H}from"./IconRefresh-BbMGoMV8.js";import{I as U}from"./IconLoader2-B_pehSXN.js";const O=[["path",{d:"M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12",key:"svg-0"}],["path",{d:"M16 3v4",key:"svg-1"}],["path",{d:"M8 3v4",key:"svg-2"}],["path",{d:"M4 11h16",key:"svg-3"}],["path",{d:"M11 15h1",key:"svg-4"}],["path",{d:"M12 15v3",key:"svg-5"}]],G=I("outline","calendar","Calendar",O);const V=[["path",{d:"M7 4v16l13 -8l-13 -8",key:"svg-0"}]],X=I("outline","player-play","PlayerPlay",V);const Y=[["path",{d:"M7 6a7.75 7.75 0 1 0 10 0",key:"svg-0"}],["path",{d:"M12 4l0 8",key:"svg-1"}]],Z=I("outline","power","Power",Y),T=l.createContext(null);function ee(){const t=l.useContext(T);if(!t)throw new Error("Dialog components must be used within <Dialog>");return t}function te({open:t,onOpenChange:s,children:o}){const a=l.useCallback(r=>s(r),[s]);return l.useEffect(()=>{if(!t)return;const r=d=>{d.key==="Escape"&&a(!1)};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[t,a]),t?e.jsxs(T.Provider,{value:{open:t,setOpen:a},children:[e.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",onClick:()=>a(!1)}),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:e.jsx("div",{className:"relative w-full max-w-lg rounded-xl border border-border bg-card shadow-xl",onClick:r=>r.stopPropagation(),children:o})})]}):null}function se({children:t,className:s}){return ee(),e.jsx("div",{className:u("p-5",s),children:t})}function re({children:t,className:s}){return e.jsx("div",{className:u("mb-4",s),children:t})}function ne({children:t,className:s}){return e.jsx("h2",{className:u("text-base font-semibold",s),children:t})}function oe({children:t,className:s}){return e.jsx("div",{className:u("flex items-center justify-end gap-2 mt-4",s),children:t})}function v(t){return t.job_id||t.id||""}function ae(t){return t.name||v(t)||"Untitled"}function R(t){const s=t.trim().split(/\s+/);if(s.length<2)return t;const o=parseInt(s[0],10),a=parseInt(s[1],10);if(isNaN(o)||isNaN(a))return t;if(s[1]==="*")return`At minute ${o} past every hour`;const r=new Date(0,0,0,a,o).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0});if(s.length>=5){const d=s.slice(2,5).join(" ");if(d==="* * 1-5")return`${r} weekdays`;if(d==="* * 0,6")return`${r} weekends`}return`${r} daily`}function q(t){if(!t)return"—";if(typeof t=="string")return R(t);const s=t.display||t.expr||JSON.stringify(t);return R(s)}function ie(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}function le(t){const s=new Date(t),o=Date.now()-s.getTime(),a=Math.floor(o/6e4);if(a<1)return"just now";if(a<60)return`${a}m ago`;const r=Math.floor(a/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function de(t){return new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ce(){return D({queryKey:["cron","jobs"],queryFn:()=>P("/api/cron-history/jobs"),refetchInterval:3e4})}function ue(t){return D({queryKey:["cron","runs",t],queryFn:()=>P("/api/cron-history"),refetchInterval:15e3})}function me(t,s,o){if(o==="hourly")return`${s} * * * *`;const a=`${s} ${t}`;return o==="weekdays"?`${a} * * 1-5`:o==="weekends"?`${a} * * 0,6`:`${a} * * *`}function xe(t,s,o){return o==="hourly"?`At minute ${s} past every hour`:`Runs ${new Date(0,0,0,t,s).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0})} ${o==="weekdays"?"on weekdays":o==="weekends"?"on weekends":"daily"}`}const he=[{label:"Every hour",dayMode:"hourly",hour:0,minute:0},{label:"Daily 9AM",dayMode:"daily",hour:9,minute:0},{label:"Daily noon",dayMode:"daily",hour:12,minute:0},{label:"Daily 6PM",dayMode:"daily",hour:18,minute:0},{label:"Weekdays 9AM",dayMode:"weekdays",hour:9,minute:0},{label:"Weekdays noon",dayMode:"weekdays",hour:12,minute:0}];function fe({value:t,onChange:s}){const[o,a]=l.useState("daily"),[r,d]=l.useState(9),[c,h]=l.useState(0),[f,p]=l.useState(!1),[g,b]=l.useState(t||""),x=l.useMemo(()=>{if(!t)return null;const i=t.trim().split(/\s+/);if(i.length<2)return null;const m=parseInt(i[0],10),j=parseInt(i[1],10);return isNaN(m)||isNaN(j)?null:{hour:j,minute:m}},[]),w=l.useRef(!1);l.useEffect(()=>{if(w.current||!x)return;w.current=!0,d(x.hour),h(x.minute);const i=t.trim().split(/\s+/);if(i.length>=5){const m=i.slice(2,5).join(" ");m==="* * 1-5"?a("weekdays"):m==="* * 0,6"?a("weekends"):(m==="* * *"||i[2]==="*")&&a("daily"),i[1]==="*"&&a("hourly")}b(t)},[x,t]);const N=l.useMemo(()=>me(r,c,o),[r,c,o]),S=l.useMemo(()=>xe(r,c,o),[r,c,o]),M=i=>{const[m,j]=i.target.value.split(":").map(Number);isNaN(m)||d(m),isNaN(j)||h(j),o==="hourly"&&a("daily")},$=i=>{d(i.hour),h(i.minute),a(i.dayMode)},n=i=>{b(i.target.value)},k=f?g:N;return l.useEffect(()=>{s(k)},[k]),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Schedule"}),f?e.jsxs("div",{className:"space-y-2",children:[e.jsx(_,{value:g,onChange:n,placeholder:"0 9 * * *",className:"h-9 text-sm font-mono"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground flex items-center gap-1.5",children:["minute hour day month weekday",e.jsx("button",{type:"button",onClick:()=>p(!1),className:"underline underline-offset-2 hover:text-foreground ml-auto transition-colors",children:"Use time picker"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"time",value:`${String(r).padStart(2,"0")}:${String(c).padStart(2,"0")}`,onChange:M,className:"flex h-10 w-full rounded-lg border border-input bg-background px-3 py-2 text-sm shadow-xs focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"}),e.jsx("div",{className:"flex rounded-lg border border-border overflow-hidden text-xs font-medium",children:[{value:"daily",label:"Every day"},{value:"weekdays",label:"Weekdays"},{value:"weekends",label:"Weekends"}].map((i,m)=>e.jsx("button",{type:"button",onClick:()=>a(i.value),className:u("flex-1 px-3 py-1.5 transition-colors text-center",m>0&&"border-l border-border",o===i.value?"bg-primary text-primary-foreground font-semibold":"bg-background text-muted-foreground hover:bg-muted"),children:i.label},i.value))}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:he.map(i=>e.jsx("button",{type:"button",onClick:()=>$(i),className:u("px-2.5 py-1 rounded-md text-[11px] font-medium transition-colors",r===i.hour&&c===i.minute&&o===i.dayMode?"bg-emerald-500/10 text-emerald-600 border border-emerald-500/20 shadow-xs":"bg-muted/50 text-muted-foreground border border-border/50 hover:bg-muted hover:text-foreground"),children:i.label},i.label))}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[e.jsx(E,{className:"h-3.5 w-3.5"}),S]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("code",{className:"text-[11px] text-muted-foreground/60 font-mono",children:N}),e.jsx("button",{type:"button",onClick:()=>{b(N),p(!0)},className:"text-[10px] text-muted-foreground/40 hover:text-muted-foreground underline underline-offset-2 transition-colors",children:"Raw cron"})]})]})]})}function pe({status:t}){if(!t)return e.jsx("div",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"});const s=t==="ok"||t==="success"||t==="completed";return e.jsx("div",{className:u("h-2 w-2 rounded-full",s?"bg-emerald-500":"bg-red-500")})}function ge({job:t,onEdit:s,onDelete:o,onToggle:a}){return e.jsxs("div",{className:u("rounded-xl border bg-card p-5 transition-colors group relative",t.enabled!==!1?"border-border hover:border-emerald-500/30":"border-border opacity-60"),children:[e.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(y,{variant:"ghost",size:"icon-sm",className:"h-7 w-7",onClick:r=>{r.stopPropagation(),a()},title:t.enabled!==!1?"Disable":"Enable",children:e.jsx(Z,{className:u("h-3.5 w-3.5",t.enabled!==!1?"text-emerald-500":"text-muted-foreground")})}),e.jsx(y,{variant:"ghost",size:"icon-sm",className:"h-7 w-7",onClick:r=>{r.stopPropagation(),s()},title:"Edit",children:e.jsx(K,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx(y,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 hover:text-red-500",onClick:r=>{r.stopPropagation(),o()},title:"Delete",children:e.jsx(A,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("div",{className:u("h-8 w-8 rounded-lg flex items-center justify-center shrink-0",t.enabled!==!1?"bg-emerald-500/10 text-emerald-600":"bg-muted text-muted-foreground"),children:e.jsx(E,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold truncate pr-20",children:ae(t)}),e.jsx("p",{className:"text-[11px] text-muted-foreground font-mono",children:q(t.schedule)})]})]}),e.jsx(pe,{status:t.last_status})]}),t.prompt&&e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed line-clamp-2 mb-3",children:t.prompt}),e.jsxs("div",{className:"flex items-center gap-4 text-[11px] text-muted-foreground",children:[t.run_count!=null&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"h-3 w-3"}),t.run_count," runs"]}),t.next_run_at&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(G,{className:"h-3 w-3"}),"Next: ",de(t.next_run_at)]}),t.last_run_at&&e.jsx("span",{children:le(t.last_run_at)})]})]})}function be({run:t}){const[s,o]=l.useState(!1),a=D({queryKey:["cron","run",t.jobId,t.fileName],queryFn:()=>P(`/api/cron-history/${encodeURIComponent(t.jobId)}/${encodeURIComponent(t.fileName)}`),enabled:s});return e.jsxs("div",{className:"border-b border-border/50 last:border-b-0",children:[e.jsxs("button",{onClick:()=>o(!s),className:"flex w-full items-center gap-3 px-4 py-2.5 text-left hover:bg-muted/30 transition-colors group",children:[e.jsx(W,{className:u("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",s&&"rotate-90")}),e.jsx("span",{className:"text-xs font-medium text-foreground/80 min-w-[80px]",children:t.jobId}),e.jsx("span",{className:"text-xs text-muted-foreground flex-1",children:t.runTime}),e.jsx("span",{className:"text-[10px] text-muted-foreground/60 font-mono shrink-0",children:ie(t.size)})]}),s&&e.jsx("div",{className:"px-4 pb-4 pl-10",children:a.isLoading?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-muted-foreground text-xs",children:[e.jsx(U,{className:"h-3.5 w-3.5 animate-spin"}),"Loading..."]}):e.jsx("pre",{className:"text-[12px] font-mono leading-relaxed whitespace-pre-wrap text-foreground/80 bg-muted/30 rounded-lg p-3 border border-border/50 max-h-[400px] overflow-auto",children:a.data?.content||"No output"})})]})}function ye(){const t=z(),s=ce(),o=ue(null),[a,r]=l.useState(!1),[d,c]=l.useState(null),[h,f]=l.useState(""),[p,g]=l.useState(""),[b,x]=l.useState(""),w=l.useCallback(()=>{s.refetch(),o.refetch()},[s,o]),N=C({mutationFn:n=>F("/api/cron-history/jobs",n),onSuccess:()=>{t.invalidateQueries({queryKey:["cron","jobs"]}),r(!1)}}),S=C({mutationFn:({id:n,data:k})=>J(`/api/cron-history/jobs/${n}`,k),onSuccess:()=>{t.invalidateQueries({queryKey:["cron","jobs"]}),c(null),r(!1)}}),M=C({mutationFn:n=>L(`/api/cron-history/jobs/${n}`),onSuccess:()=>t.invalidateQueries({queryKey:["cron","jobs"]})}),$=C({mutationFn:n=>F(`/api/cron-history/jobs/${n}/toggle`,{}),onSuccess:()=>t.invalidateQueries({queryKey:["cron","jobs"]})});return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("div",{className:"shrink-0 border-b px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold",children:"Automations"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Scheduled cron jobs managed by the Hermes agent"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(y,{size:"sm",variant:"outline",className:"gap-1.5",onClick:()=>{c(null),f(""),g(""),x(""),r(!0)},children:[e.jsx(Q,{className:"h-4 w-4"}),"New Job"]}),e.jsx("button",{onClick:w,className:"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(H,{className:u("h-4 w-4",(s.isFetching||o.isFetching)&&"animate-spin")})})]})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx(te,{open:a,onOpenChange:n=>{n||(r(!1),c(null))},children:e.jsxs(se,{children:[e.jsx(re,{children:e.jsx(ne,{children:d?"Edit Cron Job":"New Cron Job"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Name"}),e.jsx(_,{value:h,onChange:n=>f(n.target.value),placeholder:"e.g. Daily weather report",className:"h-9 text-sm"})]}),e.jsx(fe,{value:p,onChange:g}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Prompt"}),e.jsx(B,{value:b,onChange:n=>x(n.target.value),placeholder:"What should the agent do when this job runs?",className:"min-h-[80px] text-sm",rows:4})]})]}),e.jsxs(oe,{children:[e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>{r(!1),c(null)},children:"Cancel"}),e.jsx(y,{size:"sm",disabled:!h.trim()||!p.trim(),onClick:()=>{const n={name:h.trim(),schedule:p.trim(),prompt:b.trim()};d?S.mutate({id:v(d),data:n}):N.mutate(n)},children:d?"Save Changes":"Create Job"})]})]})}),e.jsxs("div",{className:"px-6 pt-5 pb-2",children:[e.jsx("h2",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3",children:"Jobs"}),s.isLoading?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(n=>e.jsx("div",{className:"rounded-xl border border-border bg-card h-36 animate-pulse",children:e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-1/2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-muted rounded w-full"})]})},n))}):s.data?.jobs?.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:s.data.jobs.map(n=>e.jsx(ge,{job:n,onEdit:()=>{c(n),f(n.name||""),g(q(n.schedule)),x(n.prompt||""),r(!0)},onDelete:()=>M.mutate(v(n)),onToggle:()=>$.mutate(v(n))},v(n)))}):e.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/20 py-12 text-center",children:[e.jsx(E,{className:"h-8 w-8 text-muted-foreground/40 mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-medium text-foreground",children:"No cron jobs yet"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Click ",e.jsx("span",{className:"font-medium",children:"New Job"})," to create one"]})]})]}),e.jsxs("div",{className:"px-6 pb-6",children:[e.jsx("h2",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3 mt-6",children:"Run History"}),o.isLoading?e.jsx("div",{className:"space-y-1",children:[1,2,3,4,5].map(n=>e.jsx("div",{className:"h-10 bg-muted/30 rounded animate-pulse"},n))}):o.data?.runs?.length?e.jsx("div",{className:"rounded-xl border border-border bg-card overflow-hidden",children:o.data.runs.slice(0,50).map(n=>e.jsx(be,{run:n},`${n.jobId}/${n.fileName}`))}):e.jsx("div",{className:"rounded-xl border border-dashed border-border bg-muted/20 py-10 text-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No runs yet"})})]})]})]})}const Ce=ye;export{Ce as component};
@@ -1 +0,0 @@
1
- import{c as F,g as R,p as D,r as o,k as z,j as e,b as i,h as U,I as k}from"./index-CQh8SXb2.js";import{I as w}from"./IconLoader2-B_pehSXN.js";import{I as C}from"./IconAlertCircle-BW147gsG.js";import{I as Y}from"./IconRefresh-BbMGoMV8.js";import{I as B}from"./IconCheck-DAO7Fpl9.js";import{M as G,r as O}from"./index-WIDirTHx.js";const T=[["path",{d:"M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0",key:"svg-0"}],["path",{d:"M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2",key:"svg-1"}]],W=F("outline","user","User",T);async function S(){return R("/api/hermes/memory")}async function X(r,s){return D("/api/hermes/memory/write",{section:r,content:s})}const E=[{key:"memory",label:"My Notes",icon:z,desc:"Personal notes & knowledge",emptyLabel:"No notes yet — click Edit to start writing."},{key:"user",label:"User Profile",icon:W,desc:"About you & your context",emptyLabel:"No profile yet — click Edit to add details about yourself."}],$={a({href:r,children:s}){return e.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 underline underline-offset-2 decoration-blue-400/30 hover:decoration-blue-600/60 transition-colors",children:s})},img({src:r,alt:s}){return e.jsx("img",{src:r,alt:s,className:"rounded-xl max-w-full my-4",loading:"lazy"})}};function H(){const[r,s]=o.useState(null),[I,f]=o.useState(!0),[p,h]=o.useState(null),[n,M]=o.useState("memory"),[c,m]=o.useState(!1),[g,b]=o.useState(""),[a,_]=o.useState(!1),[y,l]=o.useState(null),x=o.useCallback(async()=>{f(!0),h(null);try{const t=await S();s(t)}catch(t){h(t instanceof Error?t.message:"Failed to load memory")}finally{f(!1)}},[]);o.useEffect(()=>{x()},[x]);const u=r?n==="memory"?r.memory:r.user:"",j=r?n==="memory"?r.memory_mtime:r.user_mtime:null,d=E.find(t=>t.key===n),v=()=>{b(u),l(null),m(!0)},L=()=>{m(!1),l(null)},q=async()=>{_(!0),l(null);try{await X(n,g);const t=await S();s(t),m(!1)}catch(t){l(t instanceof Error?t.message:"Failed to save")}finally{_(!1)}},P=t=>{if(c){if(!confirm("You have unsaved changes. Discard them?"))return;m(!1)}M(t),l(null)};return I?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-muted-foreground",children:[e.jsx(w,{className:"size-6 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading memory..."})]})}):p?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-muted-foreground",children:[e.jsx(C,{className:"size-8 text-red-500"}),e.jsx("span",{className:"text-sm",children:p}),e.jsxs("button",{onClick:x,className:"inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium bg-muted hover:bg-muted/80 transition-colors",children:[e.jsx(Y,{className:"size-3.5"}),"Retry"]})]})}):e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("aside",{className:"flex w-56 shrink-0 flex-col border-r border-border",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-3.5",children:[e.jsx(z,{className:"size-5 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-semibold text-foreground",children:"Memory"})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto space-y-1 px-2 py-1",children:E.map(t=>{const A=t.icon,N=n===t.key;return e.jsxs("button",{onClick:()=>P(t.key),className:i("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2.5 text-left transition-colors",N?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[e.jsx(A,{className:i("size-4 shrink-0",N?"text-foreground":"text-muted-foreground/60")}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:t.label}),e.jsx("div",{className:"truncate text-[10px] text-muted-foreground/70",children:t.desc})]})]},t.key)})})]}),e.jsx("div",{className:"flex flex-1 flex-col min-w-0 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto w-full max-w-3xl px-8 py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:d.label}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:d.desc}),j&&!c&&e.jsxs("p",{className:"text-[11px] text-muted-foreground/60 mt-1",children:["Last modified ",new Date(j*1e3).toLocaleString()]})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:c?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:L,disabled:a,className:"inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[e.jsx(U,{className:"size-4"}),"Cancel"]}),e.jsxs("button",{onClick:q,disabled:a,className:i("inline-flex items-center gap-1.5 rounded-lg px-4 py-1.5 text-sm font-medium transition-colors","bg-primary text-primary-foreground hover:bg-primary/90",a&&"opacity-60 cursor-not-allowed"),children:[a?e.jsx(w,{className:"size-4 animate-spin"}):e.jsx(B,{className:"size-4"}),a?"Saving...":"Save"]})]}):e.jsxs("button",{onClick:v,className:"inline-flex items-center gap-1.5 rounded-lg px-4 py-1.5 text-sm font-medium bg-muted text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors",children:[e.jsx(k,{className:"size-4"}),"Edit"]})})]})}),y&&e.jsx("div",{className:"mb-6 rounded-lg border border-red-200 dark:border-red-800/40 bg-red-50 dark:bg-red-950/20 px-4 py-2.5",children:e.jsxs("p",{className:"text-xs text-red-700 dark:text-red-300 flex items-center gap-1.5",children:[e.jsx(C,{className:"size-3.5 shrink-0"}),y]})}),e.jsx("div",{className:"rounded-xl border border-border bg-card p-8",children:c?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("textarea",{value:g,onChange:t=>b(t.target.value),className:i("w-full min-h-[420px] rounded-lg border border-border bg-background p-4 font-mono text-sm leading-relaxed","focus:outline-none focus:ring-2 focus:ring-primary/15 focus:border-primary/40","resize-y placeholder:text-muted-foreground/30"),placeholder:`Write your ${d.label.toLowerCase()} using Markdown...`,spellCheck:!1,autoFocus:!0}),e.jsx("p",{className:"text-[11px] text-muted-foreground/50",children:"Markdown formatting is supported — headers, lists, code blocks, links, and more."})]}):u?e.jsx("div",{className:i("max-w-none","[&_h1]:mt-8 [&_h1]:mb-4 [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:tracking-tight [&_h1]:text-foreground","[&_h2]:mt-7 [&_h2]:mb-3 [&_h2]:text-xl [&_h2]:font-semibold [&_h2]:tracking-tight [&_h2]:text-foreground","[&_h3]:mt-6 [&_h3]:mb-2.5 [&_h3]:text-lg [&_h3]:font-semibold [&_h3]:text-foreground","[&_h4]:mt-5 [&_h4]:mb-2 [&_h4]:text-base [&_h4]:font-medium [&_h4]:text-foreground","[&_h5]:mt-4 [&_h5]:mb-1.5 [&_h5]:text-sm [&_h5]:font-medium [&_h5]:text-foreground/90","[&_h6]:mt-4 [&_h6]:mb-1.5 [&_h6]:text-sm [&_h6]:font-medium [&_h6]:text-muted-foreground","[&_p]:my-4 [&_p]:leading-[1.75] [&_p]:text-foreground/85","[&_ul]:my-4 [&_ul]:pl-6 [&_ul]:list-disc [&_ul]:space-y-1.5 [&_ul]:marker:text-muted-foreground/40","[&_ol]:my-4 [&_ol]:pl-6 [&_ol]:list-decimal [&_ol]:space-y-1.5 [&_ol]:marker:text-muted-foreground/40","[&_li]:leading-relaxed [&_li]:text-foreground/85","[&_:not(pre)>code]:rounded-md [&_:not(pre)>code]:bg-muted/70 [&_:not(pre)>code]:px-1.5 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:text-[13px] [&_:not(pre)>code]:font-mono [&_:not(pre)>code]:text-foreground/90 [&_:not(pre)>code]:border [&_:not(pre)>code]:border-border/50","[&_pre]:my-5 [&_pre]:rounded-xl [&_pre]:bg-muted/50 [&_pre]:border [&_pre]:border-border/60 [&_pre]:px-5 [&_pre]:py-4 [&_pre]:text-[13px] [&_pre]:leading-relaxed [&_pre]:overflow-x-auto [&_pre]:font-mono [&_pre]:whitespace-pre-wrap","[&_blockquote]:my-5 [&_blockquote]:border-l-[3px] [&_blockquote]:border-amber-400 dark:[&_blockquote]:border-amber-500 [&_blockquote]:pl-4 [&_blockquote]:text-muted-foreground [&_blockquote]:italic [&_blockquote]:leading-relaxed","[&_hr]:my-8 [&_hr]:border-border/40","[&_table]:w-full [&_table]:my-4 [&_table]:text-sm","[&_th]:border [&_th]:border-border [&_th]:bg-muted/60 [&_th]:px-4 [&_th]:py-2.5 [&_th]:text-left [&_th]:font-medium [&_th]:text-foreground/80 [&_th]:text-xs [&_th]:uppercase [&_th]:tracking-wider","[&_td]:border [&_td]:border-border [&_td]:px-4 [&_td]:py-2.5 [&_td]:text-foreground/80","[&_img]:rounded-xl [&_img]:my-5 [&_img]:max-w-full","[&>*:first-child]:mt-0 [&>*:last-child]:mb-0"),children:e.jsx(G,{remarkPlugins:[O],components:$,children:u})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 gap-4",children:[e.jsx("div",{className:"flex size-14 items-center justify-center rounded-2xl bg-muted/50 border border-border/50",children:e.jsx(d.icon,{className:"size-6 text-muted-foreground/30"})}),e.jsxs("div",{className:"text-center max-w-xs",children:[e.jsx("p",{className:"text-sm font-medium text-foreground/70",children:d.emptyLabel}),e.jsx("p",{className:"text-xs text-muted-foreground/50 mt-1.5",children:"You can format your content with Markdown — headers, lists, code blocks, and more."})]}),e.jsxs("button",{onClick:v,className:"inline-flex items-center gap-1.5 rounded-lg px-4 py-2 text-sm font-medium bg-muted hover:bg-muted/80 text-foreground/80 transition-colors",children:[e.jsx(k,{className:"size-3.5"}),"Start Editing"]})]})})]})})]})}const te=H;export{te as component};
@@ -1 +0,0 @@
1
- import{c as I,m as W,g as H,r as l,j as e,b as k,i as G,n as Q,o as z,q as P}from"./index-CQh8SXb2.js";import{S as Y}from"./switch-B_iYUUM3.js";import{I as B}from"./input-7TQEEJq6.js";import{I as J}from"./IconAlertTriangle-DCoTLVSd.js";import{I as V}from"./IconLoader2-B_pehSXN.js";import{I as Z}from"./IconCheck-DAO7Fpl9.js";const ee=[["path",{d:"M7 12l5 5l-1.5 1.5a3.536 3.536 0 1 1 -5 -5l1.5 -1.5",key:"svg-0"}],["path",{d:"M17 12l-5 -5l1.5 -1.5a3.536 3.536 0 1 1 5 5l-1.5 1.5",key:"svg-1"}],["path",{d:"M3 21l2.5 -2.5",key:"svg-2"}],["path",{d:"M18.5 5.5l2.5 -2.5",key:"svg-3"}],["path",{d:"M10 11l-2 2",key:"svg-4"}],["path",{d:"M13 14l-2 2",key:"svg-5"}]],te=I("outline","plug-connected","PlugConnected",ee);const ae=[["path",{d:"M9.785 6l8.215 8.215l-2.054 2.054a5.81 5.81 0 1 1 -8.215 -8.215l2.054 -2.054",key:"svg-0"}],["path",{d:"M4 20l3.5 -3.5",key:"svg-1"}],["path",{d:"M15 4l-3.5 3.5",key:"svg-2"}],["path",{d:"M20 9l-3.5 3.5",key:"svg-3"}]],se=I("outline","plug","Plug",ae);const ne=[["path",{d:"M16 18a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m0 -12a2 2 0 0 1 2 2a2 2 0 0 1 2 -2a2 2 0 0 1 -2 -2a2 2 0 0 1 -2 2m-7 12a6 6 0 0 1 6 -6a6 6 0 0 1 -6 -6a6 6 0 0 1 -6 6a6 6 0 0 1 6 6",key:"svg-0"}]],re=I("outline","sparkles","Sparkles",ne);async function oe(){return H("/api/config")}async function le(){return H("/api/env")}async function ie(r){return W("/api/config",{config:r})}async function ce(r,o){return W("/api/env",{key:r,value:o})}function de({name:r,icon:o,color:b,configured:i,hasCreds:x,exclusive:y,children:f}){const[d,w]=l.useState(!0);return e.jsxs("div",{className:k("group relative rounded-xl border bg-card transition-all duration-200","hover:shadow-md hover:shadow-black/5 dark:hover:shadow-black/20","hover:border-border/80",i&&x?"border-emerald-500/30 dark:border-emerald-500/20 bg-emerald-500/[0.02]":i?"border-amber-500/30 dark:border-amber-500/20 bg-amber-500/[0.02]":"border-border"),children:[e.jsx("div",{className:k("absolute left-0 top-0 bottom-0 w-0.5 rounded-l-xl transition-colors",i&&x?"bg-emerald-500/50":i?"bg-amber-500/50":"bg-border")}),e.jsxs("button",{onClick:()=>w(!d),className:"flex items-center justify-between w-full px-4 py-3.5 text-left",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:k("flex items-center justify-center size-9 rounded-lg shrink-0 transition-colors",i?"bg-foreground/5 dark:bg-foreground/10":"bg-muted"),children:e.jsx("span",{className:k("size-[18px] flex items-center justify-center",i?"text-foreground/70":"text-muted-foreground/50"),dangerouslySetInnerHTML:{__html:o}})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-sm font-semibold text-foreground truncate",children:r})}),e.jsx("div",{className:"flex items-center gap-1.5 mt-0.5",children:i&&x?e.jsxs(e.Fragment,{children:[e.jsx(te,{className:"size-3 text-emerald-500"}),e.jsx("span",{className:"text-[11px] font-medium text-emerald-600 dark:text-emerald-400",children:"Connected"})]}):i?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"size-3 text-amber-500"}),e.jsx("span",{className:"text-[11px] font-medium text-amber-600 dark:text-amber-400",children:"Needs credentials"})]}):e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"size-3 text-muted-foreground/50"}),e.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"Not connected"})]})})]})]}),e.jsx(G,{className:k("size-4 text-muted-foreground/50 transition-transform duration-200",d&&"rotate-180")})]}),d&&e.jsxs("div",{className:"px-4 pb-4 border-t border-border/40",children:[y&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-lg bg-amber-500/5 border border-amber-500/20 px-3 py-2 text-[11px] text-amber-600 dark:text-amber-400 leading-relaxed",children:[e.jsxs("svg",{className:"size-3.5 shrink-0 mt-0.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),"This platform requires an exclusive/shared token. Ensure only one bot instance uses this token."]}),e.jsx("div",{className:"mt-3 space-y-0.5",children:f})]})]})}function K({label:r,hint:o,children:b}){return e.jsxs("div",{className:"flex items-center justify-between py-2 px-2 -mx-2 rounded-lg hover:bg-muted/40 transition-colors",children:[e.jsxs("div",{className:"flex-1 mr-3 min-w-0",children:[e.jsx("span",{className:"text-[12px] font-medium text-foreground/80 block",children:r}),o&&e.jsx("p",{className:"text-[10px] text-muted-foreground mt-0.5 leading-snug",children:o})]}),e.jsx("div",{className:"shrink-0",children:b})]})}const me=[{key:"telegram",name:"Telegram",exclusive:!0,color:"#26A5E4",icon:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.479.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/></svg>',primaryCred:"TELEGRAM_BOT_TOKEN",envFields:[{key:"TELEGRAM_BOT_TOKEN",label:"Bot Token",hint:"Get it from @BotFather",password:!0},{key:"TELEGRAM_ALLOWED_USERS",label:"Allowed Users",hint:"Comma-separated user IDs"},{key:"TELEGRAM_PROXY",label:"Proxy",hint:"Optional proxy URL"}],configFields:[{key:"reactions",label:"Reactions",hint:"Add emoji reactions during processing",type:"switch"},{key:"allowed_chats",label:"Allowed Chats",hint:"Comma-separated chat IDs (whitelist)",type:"input"}]},{key:"discord",name:"Discord",exclusive:!0,color:"#5865F2",icon:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189z"/></svg>',primaryCred:"DISCORD_BOT_TOKEN",envFields:[{key:"DISCORD_BOT_TOKEN",label:"Bot Token",hint:"From Discord Developer Portal",password:!0},{key:"DISCORD_ALLOWED_USERS",label:"Allowed Users",hint:"Comma-separated user IDs"},{key:"DISCORD_REPLY_TO_MODE",label:"Reply Mode",hint:"off / first / all",type:"select",options:["off","first","all"]}],configFields:[{key:"require_mention",label:"Require Mention",hint:"Only respond when @mentioned",type:"switch"},{key:"auto_thread",label:"Auto-thread",hint:"Create threads for long conversations",type:"switch"},{key:"reactions",label:"Reactions",hint:"Add emoji reactions during processing",type:"switch"},{key:"free_response_channels",label:"Free-response Channels",hint:"Comma-separated channel IDs",type:"input"},{key:"allowed_channels",label:"Allowed Channels",hint:"Comma-separated channel IDs (whitelist)",type:"input"}]},{key:"slack",name:"Slack",exclusive:!0,color:"#4A154B",icon:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zm1.271 0a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zm0 1.271a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zm10.122 0a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V5.042zm-1.27 0a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zm0-1.27a2.527 2.527 0 0 1 2.523-2.52h6.313A2.528 2.528 0 0 1 24 18.956a2.528 2.528 0 0 1-2.522 2.523h-6.313z"/></svg>',primaryCred:"SLACK_BOT_TOKEN",envFields:[{key:"SLACK_BOT_TOKEN",label:"Bot Token",hint:"xoxb-... from Slack API",password:!0},{key:"SLACK_APP_TOKEN",label:"App Token",hint:"xapp-... for Socket Mode",password:!0},{key:"SLACK_ALLOWED_USERS",label:"Allowed Users",hint:"Comma-separated user IDs"}],configFields:[{key:"require_mention",label:"Require Mention",hint:"Only respond when @mentioned",type:"switch"},{key:"free_response_channels",label:"Free-response Channels",hint:"Comma-separated channel IDs",type:"input"},{key:"allowed_channels",label:"Allowed Channels",hint:"Comma-separated channel IDs (whitelist)",type:"input"}]},{key:"whatsapp",name:"WhatsApp",exclusive:!0,color:"#25D366",icon:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>',primaryCred:"WHATSAPP_ENABLED",envFields:[{key:"WHATSAPP_ENABLED",label:"Enabled",hint:"Set to true to enable WhatsApp",type:"select",options:["true","false"]},{key:"WHATSAPP_MODE",label:"Mode",hint:"self-chat or bot",type:"select",options:["self-chat","bot"]},{key:"WHATSAPP_ALLOWED_USERS",label:"Allowed Users",hint:"Comma-separated phone numbers"}],configFields:[{key:"require_mention",label:"Require Mention",hint:"Only respond when mentioned",type:"switch"},{key:"free_response_chats",label:"Free-response Chats",hint:"Comma-separated chat IDs",type:"input"}]},{key:"matrix",name:"Matrix",color:"#000000",icon:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M.632.55v22.9H2.28V24H0V0h2.28v.55zm7.043 7.26v1.157h.033c.309-.443.683-.784 1.117-1.024.433-.245.936-.365 1.5-.365.54 0 1.033.107 1.48.324.448.217.786.619 1.017 1.205.24-.376.558-.702.956-.98.398-.277.872-.414 1.424-.414.41 0 .784.065 1.122.194.34.13.629.325.87.588.241.263.428.59.56.984.132.393.198.85.198 1.368v5.89h-2.49v-4.893c0-.268-.016-.525-.048-.77a1.627 1.627 0 00-.2-.63 1.028 1.028 0 00-.392-.426 1.294 1.294 0 00-.616-.134c-.277 0-.508.05-.693.15a1.043 1.043 0 00-.43.41 1.768 1.768 0 00-.214.616 4.15 4.15 0 00-.06.74v4.937H9.29v-4.937c0-.25-.01-.498-.032-.742a1.84 1.84 0 00-.166-.638.998.998 0 00-.363-.448 1.206 1.206 0 00-.624-.154c-.26 0-.483.048-.67.144a1.055 1.055 0 00-.436.402 1.744 1.744 0 00-.227.616 4.108 4.108 0 00-.063.74v4.937H5.21V7.81zm15.693 15.64V.55H21.72V0H24v24h-2.28v-.55z"/></svg>',primaryCred:"MATRIX_ACCESS_TOKEN",envFields:[{key:"MATRIX_HOMESERVER",label:"Homeserver",hint:"e.g. https://matrix.org"},{key:"MATRIX_ACCESS_TOKEN",label:"Access Token",hint:"From Element settings",password:!0},{key:"MATRIX_USER_ID",label:"User ID",hint:"e.g. @hermes:matrix.org"},{key:"MATRIX_ALLOWED_USERS",label:"Allowed Users",hint:"Comma-separated user IDs"}],configFields:[{key:"require_mention",label:"Require Mention",hint:"Only respond when mentioned",type:"switch"},{key:"free_response_rooms",label:"Free-response Rooms",hint:"Comma-separated room IDs",type:"input"},{key:"allowed_rooms",label:"Allowed Rooms",hint:"Comma-separated room IDs (whitelist)",type:"input"}]},{key:"feishu",name:"Feishu",exclusive:!0,color:"#3370FF",icon:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M6.59 3.41a2.25 2.25 0 0 1 3.182 0L13.5 7.14l-3.182 3.182L6.59 7.59a2.25 2.25 0 0 1 0-3.182zm5.303 5.303L15.075 5.53a2.25 2.25 0 0 1 3.182 3.182L15.075 11.894 11.893 8.713zM3.41 6.59a2.25 2.25 0 0 1 3.182 0l3.182 3.182-3.182 3.182a2.25 2.25 0 0 1-3.182-3.182L3.41 6.59zm5.303 5.303L11.894 15.075a2.25 2.25 0 0 1-3.182 3.182L5.53 15.075 8.713 11.893zm5.303-5.303L17.478 9.778a2.25 2.25 0 0 1-3.182 3.182L10.53 10.075l3.182-3.182 0 .023z"/></svg>',primaryCred:"FEISHU_APP_ID",envFields:[{key:"FEISHU_APP_ID",label:"App ID",hint:"From Feishu Open Platform"},{key:"FEISHU_APP_SECRET",label:"App Secret",hint:"From Feishu Open Platform",password:!0},{key:"FEISHU_ENCRYPT_KEY",label:"Encrypt Key",hint:"Optional encrypt key",password:!0},{key:"FEISHU_VERIFICATION_TOKEN",label:"Verification Token",hint:"Optional verification token"}],configFields:[]},{key:"weixin",name:"WeChat",exclusive:!0,color:"#07C160",icon:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 01.213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 00.167-.054l1.903-1.114a.864.864 0 01.717-.098 10.16 10.16 0 002.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.596-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 01-1.162 1.178A1.17 1.17 0 014.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 01-1.162 1.178 1.17 1.17 0 01-1.162-1.178c0-.651.52-1.18 1.162-1.18zm3.68 4.025c-3.694 0-6.69 2.462-6.69 5.496 0 3.034 2.996 5.496 6.69 5.496.753 0 1.477-.1 2.158-.28a.66.66 0 01.548.074l1.46.854a.25.25 0 00.127.041.224.224 0 00.221-.225c0-.055-.022-.109-.037-.162l-.298-1.131a.453.453 0 01.163-.509C21.81 18.613 22.77 16.973 22.77 15.512c0-3.034-2.996-5.496-6.69-5.496h.198zm-2.454 3.347c.491 0 .889.404.889.902a.896.896 0 01-.889.903.896.896 0 01-.889-.903c0-.498.398-.902.889-.902zm4.912 0c.491 0 .889.404.889.902a.896.896 0 01-.889.903.896.896 0 01-.889-.903c0-.498.398-.902.889-.902z"/></svg>',primaryCred:"WEIXIN_TOKEN",envFields:[{key:"WEIXIN_ACCOUNT_ID",label:"Account ID",hint:"Official account ID"},{key:"WEIXIN_TOKEN",label:"Token",hint:"WeChat verification token",password:!0},{key:"WEIXIN_BASE_URL",label:"Base URL",hint:"WeChat API base URL"},{key:"WEIXIN_CDN_BASE_URL",label:"CDN Base URL",hint:"Optional CDN base URL"}],configFields:[]},{key:"wecom",name:"WeCom",color:"#1677FF",icon:'<svg viewBox="0 0 24 24" fill="currentColor"><path d="M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 01.213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 00.167-.054l1.903-1.114a.864.864 0 01.717-.098 10.16 10.16 0 002.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.596-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 01-1.162 1.178A1.17 1.17 0 014.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 01-1.162 1.178 1.17 1.17 0 01-1.162-1.178c0-.651.52-1.18 1.162-1.18zm3.68 4.025c-3.694 0-6.69 2.462-6.69 5.496 0 3.034 2.996 5.496 6.69 5.496.753 0 1.477-.1 2.158-.28a.66.66 0 01.548.074l1.46.854a.25.25 0 00.127.041.224.224 0 00.221-.225c0-.055-.022-.109-.037-.162l-.298-1.131a.453.453 0 01.163-.509C21.81 18.613 22.77 16.973 22.77 15.512c0-3.034-2.996-5.496-6.69-5.496h.198zm-2.454 3.347c.491 0 .889.404.889.902a.896.896 0 01-.889.903.896.896 0 01-.889-.903c0-.498.398-.902.889-.902zm4.912 0c.491 0 .889.404.889.902a.896.896 0 01-.889.903.896.896 0 01-.889-.903c0-.498.398-.902.889-.902z"/></svg>',primaryCred:"WECOM_BOT_ID",envFields:[{key:"WECOM_BOT_ID",label:"Bot ID",hint:"WeCom Bot identifier"},{key:"WECOM_SECRET",label:"Secret",hint:"WeCom application secret",password:!0}],configFields:[]}];function U({saving:r,saved:o}){return r?e.jsx(V,{className:"size-3 animate-spin text-muted-foreground"}):o?e.jsx(Z,{className:"size-3 text-emerald-500"}):null}function ue(){const r=Q(),{data:o,isLoading:b}=z({queryKey:["config"],queryFn:oe,staleTime:3e4}),{data:i,isLoading:x}=z({queryKey:["env-vars"],queryFn:le,staleTime:3e4}),[y,f]=l.useState({}),[d,w]=l.useState({}),[q,C]=l.useState(new Set),[X,E]=l.useState(new Set),_=l.useCallback(t=>{C(s=>new Set(s).add(t)),E(s=>{const n=new Set(s);return n.delete(t),n})},[]),S=l.useCallback(t=>{C(s=>{const n=new Set(s);return n.delete(t),n}),E(s=>new Set(s).add(t)),setTimeout(()=>{E(s=>{const n=new Set(s);return n.delete(t),n})},2e3)},[]),M=P({mutationFn:async t=>{await ie(t)},onSuccess:()=>{r.invalidateQueries({queryKey:["config"]})}}),T=P({mutationFn:async({key:t,value:s})=>{await ce(t,s)},onSuccess:()=>{r.invalidateQueries({queryKey:["env-vars"]})}}),A=l.useCallback((t,s,n)=>{w(c=>({...c,[t]:{...c[t]||{},[s]:n}}))},[]),N=l.useCallback((t,s)=>{const n=`cfg.${t}.${s}`,c=r.getQueryData(["config"])||{},h=c[t]||{},a=d[t]?.[s];if(a===void 0)return;const v={...h,[s]:a},p={...c,[t]:v};_(n),M.mutate(p,{onSuccess:()=>S(n),onError:()=>{C(m=>{const g=new Set(m);return g.delete(n),g})}})},[d,r,M,_,S]),$=l.useCallback((t,s,n)=>{A(t,s,n),N(t,s)},[A,N]),O=l.useCallback(t=>{const s=y[t];if(s===void 0)return;const n=`env.${t}`;_(n),T.mutate({key:t,value:s},{onSuccess:()=>S(n),onError:()=>{C(c=>{const h=new Set(c);return h.delete(n),h})}})},[y,T,_,S]),D=l.useCallback((t,s)=>d[t]?.[s]??o?.[t]?.[s],[d,o]),L=t=>q.has(t),F=t=>X.has(t);if(b||x)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx(V,{className:"size-5 animate-spin text-muted-foreground"})});const R=i||{};return e.jsxs("div",{className:"flex flex-1 flex-col h-full overflow-hidden",children:[e.jsx("div",{className:"shrink-0 border-b px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(re,{className:"size-5 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-base font-semibold text-foreground",children:"Channels"}),e.jsx("p",{className:"text-[12px] text-muted-foreground mt-0.5",children:"Connect messaging platforms so Hermium can respond on Telegram, Discord, Slack, and more."})]})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsx("div",{className:"p-6",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:me.map(t=>{const n=R[t.primaryCred]?.is_set??!1,c=o?.[t.key]||{},h=n||Object.keys(c).length>0;return e.jsxs(de,{name:t.name,icon:t.icon,color:t.color,configured:h,hasCreds:n,exclusive:t.exclusive,children:[t.envFields.map(a=>{const p=R[a.key]?.is_set??!1,m=`env.${a.key}`,g=y[a.key]??"";return e.jsx(K,{label:a.label,hint:a.hint,children:e.jsxs("div",{className:"flex items-center gap-2",children:[a.type==="select"&&a.options?e.jsxs("select",{className:"w-[220px] h-8 text-xs rounded-md border border-input bg-background px-2",value:g||String(D(t.key,a.key)??""),onChange:u=>{f(j=>({...j,[a.key]:u.target.value})),O(a.key)},children:[e.jsx("option",{value:"",children:"— Select —"}),a.options.map(u=>e.jsx("option",{value:u,children:u},u))]}):e.jsx(B,{className:"w-[220px] h-8 text-xs font-mono",type:a.password?"password":"text",placeholder:p?"Already set (enter to overwrite)":a.hint,value:g,onChange:u=>f(j=>({...j,[a.key]:u.target.value})),onBlur:()=>O(a.key)}),e.jsx(U,{saving:L(m),saved:F(m)})]})},a.key)}),t.configFields.map(a=>{const v=`cfg.${t.key}.${a.key}`,p=D(t.key,a.key);return e.jsx(K,{label:a.label,hint:a.hint,children:a.type==="switch"?e.jsx(Y,{checked:!!p,onCheckedChange:m=>$(t.key,a.key,m)}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{className:"w-[220px] h-8 text-xs",value:String(p??""),onChange:m=>A(t.key,a.key,m.target.value),onBlur:()=>N(t.key,a.key)}),e.jsx(U,{saving:L(v),saved:F(v)})]})},a.key)})]},t.key)})})})})]})}const ke=ue;export{ke as component};
@@ -1,14 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/syntax-highlighter-DcBYfnEK.js","assets/index-CQh8SXb2.js","assets/index-WIDirTHx.js"])))=>i.map(i=>d[i]);
2
- import{c as z,T as we,r as l,j as e,b as A,h as ie,B as T,u as le,l as y,v as V,U as je,V as Ne,W as Se,X as ke,Y as q,I as Ce,Z as Re,_ as _e,f as ce,$ as de,a0 as Me,a as X,a1 as De,a2 as Ae}from"./index-CQh8SXb2.js";import{T as ze,I as Ee,a as Te,b as F}from"./textarea-Dm4aaRqS.js";import{a as $e,I as Le}from"./IconCode-BqfTl5wU.js";import{I as P}from"./IconLoader2-B_pehSXN.js";import{M as Ie,r as Oe}from"./index-WIDirTHx.js";import{I as U}from"./IconCheck-DAO7Fpl9.js";import{I as Pe}from"./IconAlertTriangle-DCoTLVSd.js";const Ue=[["path",{d:"M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6",key:"svg-0"}],["path",{d:"M9 17v1a3 3 0 0 0 6 0v-1",key:"svg-1"}]],He=z("outline","bell","Bell",Ue);const Fe=[["path",{d:"M4 19l16 0",key:"svg-0"}],["path",{d:"M4 15l4 -6l4 2l4 -5l4 4",key:"svg-1"}]],We=z("outline","chart-line","ChartLine",Fe);const Be=[["path",{d:"M7 9a2 2 0 1 1 2 -2v10a2 2 0 1 1 -2 -2h10a2 2 0 1 1 -2 2v-10a2 2 0 1 1 2 2h-10",key:"svg-0"}]],Je=z("outline","command","Command",Be);const Ke=[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}]],Ge=z("outline","file","File",Ke);const Ve=[["path",{d:"M3 7a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-10",key:"svg-0"}],["path",{d:"M3 7l9 6l9 -6",key:"svg-1"}]],qe=z("outline","mail","Mail",Ve);const Xe=[["path",{d:"M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5",key:"svg-0"}]],Qe=z("outline","paperclip","Paperclip",Xe);const Ye=[["path",{d:"M15 8h.01",key:"svg-0"}],["path",{d:"M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3v-12",key:"svg-1"}],["path",{d:"M3 16l5 -5c.928 -.893 2.072 -.893 3 0l5 5",key:"svg-2"}],["path",{d:"M14 14l1 -1c.928 -.893 2.072 -.893 3 0l3 3",key:"svg-3"}]],Ze=z("outline","photo","Photo",Ye);const et=[["path",{d:"M5 7a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2l0 -10",key:"svg-0"}]],tt=z("outline","player-stop","PlayerStop",et);const nt=[["path",{d:"M11.46 20.846a12 12 0 0 1 -7.96 -14.846a12 12 0 0 0 8.5 -3a12 12 0 0 0 8.5 3a12 12 0 0 1 -.09 7.06",key:"svg-0"}],["path",{d:"M15 19l2 2l4 -4",key:"svg-1"}]],Q=z("outline","shield-check","ShieldCheck",nt),Y=t=>Symbol.iterator in t,Z=t=>"entries"in t,ee=(t,n)=>{const s=t instanceof Map?t:new Map(t.entries()),r=n instanceof Map?n:new Map(n.entries());if(s.size!==r.size)return!1;for(const[a,i]of s)if(!r.has(a)||!Object.is(i,r.get(a)))return!1;return!0},st=(t,n)=>{const s=t[Symbol.iterator](),r=n[Symbol.iterator]();let a=s.next(),i=r.next();for(;!a.done&&!i.done;){if(!Object.is(a.value,i.value))return!1;a=s.next(),i=r.next()}return!!a.done&&!!i.done};function rt(t,n){return Object.is(t,n)?!0:typeof t!="object"||t===null||typeof n!="object"||n===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(n)?!1:Y(t)&&Y(n)?Z(t)&&Z(n)?ee(t,n):st(t,n):ee({entries:()=>Object.entries(t)},{entries:()=>Object.entries(n)})}function te(t){const n=we.useRef(void 0);return s=>{const r=t(s);return rt(n.current,r)?n.current:n.current=r}}function at(t){return t.nativeEvent?.isComposing===!0}const W=[{name:"/new",description:"Start a new chat",category:"chat",local:!0},{name:"/clear",description:"Clear conversation history",category:"chat",local:!0},{name:"/btw",description:"Ask a side question without affecting context",category:"agent"},{name:"/approve",description:"Approve a pending action",category:"agent"},{name:"/deny",description:"Deny a pending action",category:"agent"},{name:"/status",description:"Show current agent status",category:"agent"},{name:"/reset",description:"Reset conversation context",category:"agent"},{name:"/compact",description:"Compact and summarize the conversation",category:"agent"},{name:"/undo",description:"Undo the last action",category:"agent"},{name:"/retry",description:"Retry the last failed action",category:"agent"},{name:"/compress",description:"Compress conversation with optional focus topic",category:"agent"},{name:"/debug",description:"Show diagnostics and debug info",category:"agent"},{name:"/goal",description:"Lock the agent onto a persistent cross-turn goal",category:"agent"},{name:"/steer",description:"Steer the in-flight agent without interrupting it",category:"agent"},{name:"/queue",description:"Queue a follow-up to run after the current turn",category:"agent"},{name:"/web",description:"Search the web",category:"tools"},{name:"/image",description:"Generate an image",category:"tools"},{name:"/browse",description:"Browse a URL",category:"tools"},{name:"/code",description:"Write or execute code",category:"tools"},{name:"/file",description:"Read or write files",category:"tools"},{name:"/shell",description:"Run a shell command",category:"tools"},{name:"/help",description:"Show available commands and help",category:"info",local:!0},{name:"/model",description:"Show or switch the current model",category:"info",local:!0},{name:"/memory",description:"Show agent memory",category:"info",local:!0},{name:"/persona",description:"Show current persona",category:"info",local:!0},{name:"/version",description:"Show Hermes version",category:"info",local:!0},{name:"/usage",description:"Show token usage and cost",category:"info",local:!0},{name:"/tools",description:"List available tools",category:"info",local:!0},{name:"/skills",description:"List installed skills",category:"info",local:!0}];function ot(t){if(!t.startsWith("/"))return!1;const n=t.split(/\s+/)[0].toLowerCase();return W.some(s=>s.name===n&&s.local)}function it({currentInput:t,applyText:n}){const[s,r]=l.useState([]),a=l.useRef(-1),i=l.useRef(""),c=l.useCallback(j=>{r(S=>[...S,j]),a.current=-1,i.current=""},[]),h=l.useCallback(()=>{if(s.length===0)return!1;const j=a.current,S=j===-1?s.length-1:Math.max(0,j-1);return j===-1&&(i.current=t),a.current=S,n(s[S]),!0},[s,t,n]),m=l.useCallback(()=>{const j=a.current;return j===-1?!1:(j<s.length-1?(a.current=j+1,n(s[j+1])):(a.current=-1,n(i.current)),!0)},[s,n]),x=l.useCallback(()=>a.current!==-1,[]),w=l.useCallback(()=>s.length,[s.length]);return{push:c,recallPrev:h,recallNext:m,isNavigating:x,size:w}}function lt(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function ct({attachment:t,onRemove:n}){const s=t.type.startsWith("image/");return e.jsxs("div",{className:"group relative flex shrink-0 items-center gap-2 rounded-lg border border-border bg-muted/40 px-2 py-1.5 text-xs",children:[s&&t.previewUrl?e.jsx("img",{src:t.previewUrl,alt:t.name,className:"h-10 w-10 rounded object-cover"}):s?e.jsx(Ze,{className:"size-5 text-muted-foreground"}):e.jsx(Ge,{className:"size-5 text-muted-foreground"}),e.jsxs("div",{className:"flex flex-col min-w-0",children:[e.jsx("span",{className:"truncate max-w-[120px] font-medium text-foreground",children:t.name}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:lt(t.size)})]}),e.jsx("button",{onClick:r=>{r.stopPropagation(),n()},className:"absolute -top-1.5 -right-1.5 flex size-4 items-center justify-center rounded-full bg-muted-foreground/20 text-muted-foreground opacity-0 group-hover:opacity-100 hover:bg-destructive hover:text-destructive-foreground transition-all","aria-label":`Remove ${t.name}`,children:e.jsx(ie,{className:"size-2.5"})})]})}function dt({attachments:t,onRemove:n,compact:s=!1}){return t.length===0?null:e.jsx("div",{className:A("flex gap-2 overflow-x-auto","px-3 pt-3"),children:t.map(r=>e.jsx(ct,{attachment:r,onRemove:()=>n(r.id)},r.id))})}function ut(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}const mt=l.forwardRef(function({sessionId:n,isLoading:s,onSubmit:r,onAbort:a},i){const[c,h]=l.useState(""),[m,x]=l.useState(!1),[w,j]=l.useState(!1),[S,k]=l.useState(""),[C,f]=l.useState(0),[d,u]=l.useState([]),[p,b]=l.useState(!1),g=l.useRef(null),v=l.useRef(null),R=l.useRef(null),_=l.useCallback(()=>{const o=g.current;o&&(o.style.height="auto",o.style.height=`${Math.min(o.scrollHeight,200)}px`)},[]),L=l.useCallback(o=>{h(o),requestAnimationFrame(()=>{_(),g.current?.setSelectionRange(o.length,o.length)})},[_]),M=it({currentInput:c,applyText:L});l.useImperativeHandle(i,()=>({setText(o){h(o),requestAnimationFrame(()=>{_(),g.current?.focus()})},clear(){h(""),g.current&&(g.current.style.height="auto")},focus(){g.current?.focus()}}),[_]),l.useEffect(()=>{s||g.current?.focus()},[s]),l.useEffect(()=>{if(!w)return;function o(N){v.current&&!v.current.contains(N.target)&&j(!1)}return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[w]),l.useEffect(()=>{if(!w)return;v.current?.querySelector(".slash-item-active")?.scrollIntoView({block:"nearest"})},[C,w]);const $=l.useMemo(()=>w?W.filter(o=>o.name.toLowerCase().startsWith(S.toLowerCase())):[],[w,S]),I=l.useCallback(o=>{const N=Array.from(o).map(D=>({id:ut(),name:D.name,type:D.type||"application/octet-stream",size:D.size,file:D,previewUrl:D.type.startsWith("image/")?URL.createObjectURL(D):void 0}));u(D=>[...D,...N])},[]),ue=l.useCallback(o=>{u(N=>{const D=N.find(E=>E.id===o);return D?.previewUrl&&URL.revokeObjectURL(D.previewUrl),N.filter(E=>E.id!==o)})},[]);l.useEffect(()=>()=>{d.forEach(o=>{o.previewUrl&&URL.revokeObjectURL(o.previewUrl)})},[]);const me=l.useCallback(o=>{o.preventDefault(),o.stopPropagation(),b(!0)},[]),pe=l.useCallback(o=>{o.preventDefault(),o.stopPropagation(),(o.currentTarget===o.target||!o.currentTarget.contains(o.relatedTarget))&&b(!1)},[]),fe=l.useCallback(o=>{o.preventDefault(),o.stopPropagation(),b(!1),o.dataTransfer.files.length>0&&I(o.dataTransfer.files)},[I]),ge=l.useCallback(o=>{const N=o.clipboardData?.items;if(!N)return;const D=[];for(let E=0;E<N.length;E++){const O=N[E];if(O.type.startsWith("image/")){const G=O.getAsFile();if(G){const ve=O.type.split("/")[1]||"png",ye=new File([G],`pasted-image-${Date.now()}.${ve}`,{type:O.type});D.push(ye)}}}D.length>0&&(o.preventDefault(),I(D))},[I]);function he(o){M.push(o),h(""),g.current&&(g.current.style.height="auto")}function B(){const o=c.trim();!o||s||(j(!1),he(o),r(o,d),u([]))}function J(o){if(j(!1),o.local||o.category==="info"){h(""),g.current&&(g.current.style.height="auto"),r(o.name);return}h(o.name+" "),g.current?.focus()}function xe(o){const N=o.target.value;h(N),_(),N.startsWith("/")&&!N.includes(" ")?(j(!0),k(N),f(0)):w&&j(!1)}function be(o){if(!at(o)){if(w&&$.length>0){if(o.key==="ArrowDown"){o.preventDefault(),f(N=>N<$.length-1?N+1:0);return}if(o.key==="ArrowUp"){o.preventDefault(),f(N=>N>0?N-1:$.length-1);return}if(o.key==="Enter"||o.key==="Tab"){o.preventDefault(),J($[C]);return}if(o.key==="Escape"){o.preventDefault(),j(!1);return}}if(!w&&(M.isNavigating()||!c.includes(`
3
- `))){if(o.key==="ArrowUp"&&M.size()>0&&M.recallPrev()){o.preventDefault();return}if(o.key==="ArrowDown"&&M.isNavigating()&&M.recallNext()){o.preventDefault();return}}o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),B())}}const K=c.trim().length>0;return e.jsxs("div",{className:"w-full max-w-3xl mx-auto flex flex-col gap-2 relative",children:[w&&$.length>0&&e.jsxs("div",{ref:v,className:"absolute bottom-full left-0 right-0 mb-1 rounded-xl border border-border bg-card shadow-lg z-50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-[11px] font-medium text-muted-foreground border-b border-border/60 bg-muted/30",children:[e.jsx(Je,{className:"size-3"}),"Commands"]}),e.jsx("div",{className:"max-h-[240px] overflow-y-auto py-1",children:$.map((o,N)=>e.jsxs("button",{className:A("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",N===C?"bg-accent text-accent-foreground slash-item-active":"hover:bg-accent/50"),onMouseEnter:()=>f(N),onClick:()=>J(o),children:[e.jsx("span",{className:"font-mono text-xs text-primary",children:o.name}),e.jsx("span",{className:"text-muted-foreground text-xs",children:o.description})]},o.name))})]}),e.jsxs("div",{className:A("flex min-h-[80px] flex-col rounded-2xl cursor-text bg-card border shadow-lg transition-colors",p?"border-primary border-dashed":"border-border"),onDragOver:me,onDragLeave:pe,onDrop:fe,children:[e.jsx(dt,{attachments:d,onRemove:ue,compact:!0}),e.jsx("div",{className:"flex-1 relative overflow-y-auto max-h-[200px]",children:e.jsx(ze,{ref:g,value:c,onChange:xe,onKeyDown:be,onPaste:ge,onCompositionStart:()=>x(!0),onCompositionEnd:()=>x(!1),placeholder:"Ask anything…",rows:1,className:A("w-full !rounded-none border-0 p-3 outline-none text-[15px] text-foreground resize-none shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:border-transparent bg-transparent whitespace-pre-wrap break-words","min-h-[48px] max-h-[200px]")})}),e.jsxs("div",{className:"flex min-h-[40px] items-center gap-2 p-2 pb-1",children:[e.jsx(T,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground transition-colors",title:"Attach images",onClick:()=>R.current?.click(),children:e.jsx(Qe,{className:"h-5 w-5"})}),e.jsx("div",{className:"ml-auto flex items-center gap-2",children:s?e.jsx(T,{variant:"ghost",size:"icon-sm",className:"rounded-full bg-destructive hover:bg-destructive/90 text-destructive-foreground transition-colors cursor-pointer",onClick:a,title:"Stop generating",children:e.jsx(tt,{className:"h-4 w-4"})}):e.jsx(T,{variant:"ghost",size:"icon-sm",className:A("rounded-full transition-colors cursor-pointer",K?"bg-primary hover:bg-primary/90 text-primary-foreground":"bg-primary text-primary-foreground opacity-40"),disabled:!K,onClick:B,title:"Send message",children:e.jsx($e,{className:"h-4 w-4"})})})]})]}),e.jsx("input",{ref:R,type:"file",multiple:!0,accept:"image/*",className:"hidden",onChange:o=>{o.target.files?.length&&(I(o.target.files),o.target.value="")}})]})}),pt=l.memo(function({sessionId:n,title:s,hasMessages:r,onNewChat:a,onClear:i}){const c=le(),h=y(x=>x.deleteSession),m=async()=>{try{await _e(n),h(n),c({to:"/chat"})}catch{}};return e.jsxs("div",{className:"group/header shrink-0 px-2 py-1 flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground truncate flex-1 select-none",children:s||"Conversation"}),e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 group-hover/header:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:a,className:"flex items-center justify-center rounded-lg p-1 text-muted-foreground hover:bg-sidebar-muted hover:text-foreground transition-colors",title:"New chat",children:e.jsx(Ee,{className:"size-3.5"})}),r&&e.jsx("button",{onClick:i,className:"flex items-center justify-center rounded-lg p-1 text-muted-foreground hover:bg-sidebar-muted hover:text-foreground transition-colors",title:"Clear chat",children:e.jsx(V,{className:"size-3.5"})}),e.jsxs(je,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx("button",{className:"flex items-center justify-center rounded-lg p-1 text-muted-foreground hover:bg-sidebar-muted hover:text-foreground transition-colors",children:e.jsx(Se,{className:"size-3.5"})})}),e.jsxs(ke,{align:"end",side:"bottom",sideOffset:4,children:[e.jsxs(q,{className:"gap-2 text-xs",onClick:()=>{const x=prompt("Rename conversation",s||"");x?.trim()&&(Re(n,x.trim()),y.getState().updateSession(n,{title:x.trim()}))},children:[e.jsx(Ce,{className:"size-3"}),"Rename"]}),e.jsxs(q,{className:"gap-2 text-xs text-destructive",onClick:m,children:[e.jsx(V,{className:"size-3"}),"Delete"]})]})]})]})]})}),ft=[{label:"Search the web",text:"Search the web for today's top tech news",Icon:ce},{label:"Set a reminder",text:"Set a reminder to check emails every day at 9 AM",Icon:He},{label:"Read emails",text:"Read my latest emails and summarize them",Icon:qe},{label:"Write a script",text:"Write a Python script to rename all files in a folder",Icon:Le},{label:"Schedule a job",text:"Schedule a cron job to back up my database every night",Icon:Te},{label:"Analyze data",text:"Analyze this CSV file and show key insights",Icon:We}],gt=l.memo(function({onSelectSuggestion:n}){return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-6 py-12",children:[e.jsx("div",{className:"mb-6 flex items-center justify-center w-16 h-16 rounded-2xl bg-gradient-to-br from-primary/20 to-primary/5 text-primary",children:e.jsx(ce,{className:"w-8 h-8",strokeWidth:1.5})}),e.jsx("h2",{className:"text-xl font-semibold text-foreground mb-2",children:"How can I help?"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-8 max-w-sm text-center",children:"Ask anything or pick a suggestion to get started."}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 w-full max-w-lg",children:ft.map(({text:s,label:r,Icon:a})=>e.jsxs("button",{className:"flex items-center gap-3 rounded-xl border border-border/60 bg-card px-4 py-3 text-left text-sm text-foreground hover:bg-accent hover:border-accent transition-colors group",onClick:()=>n(s),children:[e.jsx(a,{className:"w-4 h-4 shrink-0 text-muted-foreground group-hover:text-foreground transition-colors"}),e.jsx("span",{className:"truncate",children:r})]},s))})]})}),ht=l.lazy(()=>Me(()=>import("./syntax-highlighter-DcBYfnEK.js"),__vite__mapDeps([0,1,2])).then(t=>({default:t.SyncHighlighter})));function H({text:t}){const[n,s]=l.useState(!1),r=async()=>{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),2e3)};return e.jsx("button",{onClick:r,className:"absolute right-2 top-2 flex items-center gap-1 rounded px-1.5 py-1 text-xs text-muted-foreground/60 hover:text-foreground hover:bg-muted transition-colors","aria-label":"Copy code",children:n?e.jsx(U,{className:"size-3"}):e.jsx(de,{className:"size-3"})})}function xt({text:t}){const[n,s]=l.useState(!1),r=async()=>{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),2e3)};return e.jsxs("button",{onClick:r,className:"inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground/50 hover:text-foreground hover:bg-muted transition-colors","aria-label":"Copy message",children:[n?e.jsx(U,{className:"size-3"}):e.jsx(de,{className:"size-3"}),n?"Copied":"Copy"]})}function bt(t){const n=Math.floor(t/1e3);if(n<60)return`${n}s`;const s=Math.floor(n/60),r=n%60;return r===0?`${s}m`:`${s}m ${r}s`}function ne({reasoning:t,isStreaming:n,startedAt:s,endedAt:r}){const[a,i]=l.useState(n??!1);l.useEffect(()=>{i(n??!1)},[n]);const[c,h]=l.useState(Date.now()),m=l.useRef(null);if(l.useEffect(()=>{if(n&&s&&!r)return m.current=setInterval(()=>h(Date.now()),1e3),()=>{m.current&&clearInterval(m.current)};m.current&&(clearInterval(m.current),m.current=null)},[n,s,r]),!t.trim())return null;const x=s?Math.max(0,(r??(n?c:s))-s):null,w=[...t].length,j=n&&s&&!r;return e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>i(!a),className:A("inline-flex items-center gap-1.5 text-[11px] transition-colors",j?"text-amber-500 dark:text-amber-400 font-medium":"text-muted-foreground/70 hover:text-foreground"),children:[e.jsx(F,{className:A("size-3 shrink-0 transition-transform",a&&"rotate-90")}),j?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(P,{className:"size-2.5 animate-spin"}),"thinking…"]}):e.jsx("span",{children:"thought"}),x!==null&&x>0&&e.jsxs("span",{className:"text-muted-foreground/60 tabular-nums",children:["· ",bt(x)]}),e.jsxs("span",{className:"text-muted-foreground/60",children:["· ",w.toLocaleString()," chars"]})]}),a&&e.jsx("div",{className:"mt-1 rounded-md bg-amber-50 dark:bg-amber-950/20 px-2.5 py-1.5 text-[11px] text-muted-foreground leading-relaxed whitespace-pre-wrap font-mono border border-amber-200 dark:border-amber-800/30",children:t})]})}function vt({name:t,content:n}){const[s,r]=l.useState(!1),a=n.length>60?n.slice(0,60)+"...":n;return n?e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>r(!s),className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground/70 hover:text-foreground transition-colors truncate max-w-full",children:[e.jsx(F,{className:A("size-3 shrink-0 transition-transform",s&&"rotate-90")}),e.jsxs("span",{className:"truncate",children:[t||"tool",': "',a,'"']})]}),s&&e.jsx("div",{className:"mt-1 rounded-md bg-muted/40 px-2.5 py-1.5 text-[11px] text-muted-foreground leading-relaxed whitespace-pre-wrap font-mono border border-border/50 max-h-[300px] overflow-auto",children:n})]}):null}function se(t){if(!t)return null;try{const n=JSON.parse(t);return{text:JSON.stringify(n,null,2),isJson:!0}}catch{return{text:t,isJson:!1}}}function re({tools:t}){const[n,s]=l.useState(!1);if(!t?.length)return null;const r=t.filter(c=>c.status==="running").length,a=t.filter(c=>c.status==="done").length,i=t.filter(c=>c.status==="error").length;return e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>s(!n),className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground/70 hover:text-foreground transition-colors",children:[e.jsx(F,{className:A("size-3 shrink-0 transition-transform",n&&"rotate-90")}),e.jsxs("span",{children:["used ",t.length," tool",t.length>1?"s":""]}),r>0&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-amber-500",children:[e.jsx(P,{className:"size-2.5 animate-spin"}),r]}),a>0&&e.jsxs("span",{className:"text-emerald-500",children:[a," done"]}),i>0&&e.jsxs("span",{className:"text-red-500",children:[i," error"]}),t.length>0&&r===0&&e.jsxs("span",{className:"text-muted-foreground/50 truncate max-w-[200px]",children:["— ",t.map(c=>c.name).join(", ")]})]}),n&&e.jsx("div",{className:"mt-1 flex flex-col gap-1.5",children:t.map((c,h)=>{const m=se(c.preview),x=se(c.output);return e.jsxs("div",{className:"rounded-md bg-muted/40 border border-border/50 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold text-foreground/80 font-mono",children:c.name}),c.status==="running"&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-amber-500",children:[e.jsx(P,{className:"size-2.5 animate-spin"}),"running"]}),c.status==="done"&&e.jsx("span",{className:"text-[10px] text-emerald-500",children:"✓ done"}),c.status==="error"&&e.jsx("span",{className:"text-[10px] text-red-500",children:"✗ error"})]}),m&&e.jsxs("div",{className:"border-t border-border/30",children:[e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-0.5",children:[e.jsx("span",{className:"text-[9px] uppercase tracking-wider text-muted-foreground/60",children:"Arguments"}),e.jsx(H,{text:m.text})]}),e.jsx("div",{className:"px-2.5 pb-1.5",children:e.jsx("pre",{className:A("text-[10px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap max-h-[200px] overflow-y-auto rounded",m.isJson?"bg-slate-900/10 dark:bg-slate-900/40 text-foreground/80 px-2 py-1":"text-muted-foreground/70"),children:m.text})})]}),x&&e.jsxs("div",{className:"border-t border-border/30",children:[e.jsxs("div",{className:"flex items-center justify-between px-2.5 py-0.5",children:[e.jsx("span",{className:"text-[9px] uppercase tracking-wider text-muted-foreground/60",children:"Result"}),e.jsx(H,{text:x.text})]}),e.jsx("div",{className:"px-2.5 pb-1.5",children:e.jsx("pre",{className:A("text-[10px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap max-h-[200px] overflow-y-auto rounded",x.isJson?"bg-slate-900/10 dark:bg-slate-900/40 text-foreground/80 px-2 py-1":"text-muted-foreground/70"),children:x.text})})]})]},c.callId||`${c.name}-${h}`)})})]})}function yt({language:t,value:n}){return e.jsxs("div",{className:"relative group/code my-2",children:[e.jsxs("div",{className:"flex items-center justify-between rounded-t-lg bg-muted/80 px-3 py-1.5 border border-border border-b-0",children:[e.jsx("span",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wide",children:t||"text"}),e.jsx(H,{text:n})]}),e.jsx(l.Suspense,{fallback:e.jsx("pre",{className:"bg-[#282c34] text-gray-300 rounded-b-lg px-4 py-3 text-[13px] leading-relaxed overflow-x-auto font-mono",children:e.jsx("code",{children:n})}),children:e.jsx(ht,{language:t,value:n})})]})}const wt={pre({children:t}){return e.jsx("div",{className:"overflow-x-auto max-w-full",children:t})},code({className:t,children:n,...s}){const r=/language-(\w+)/.exec(t||""),a=String(n).replace(/\n$/,"");return r?r[1]==="plaintext"?e.jsx("pre",{className:"rounded-lg bg-muted/50 border border-border/50 px-4 py-3 text-[13px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap",children:a}):e.jsx(yt,{language:r[1],value:a}):e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-[13px] font-mono text-foreground/90",...s,children:n})},a({href:t,children:n}){return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 underline underline-offset-2",children:n})},img({src:t,alt:n}){return e.jsx("img",{src:t,alt:n,className:"rounded-lg max-w-full my-2",loading:"lazy"})},table({children:t}){return e.jsx("div",{className:"overflow-x-auto my-2",children:e.jsx("table",{className:"w-full text-sm border-collapse border border-border rounded-lg overflow-hidden",children:t})})},th({children:t}){return e.jsx("th",{className:"border border-border bg-muted px-3 py-1.5 text-left font-medium",children:t})},td({children:t}){return e.jsx("td",{className:"border border-border px-3 py-1.5",children:t})},blockquote({children:t}){return e.jsx("blockquote",{className:"border-l-2 border-amber-400 dark:border-amber-600 pl-3 my-2 text-muted-foreground italic",children:t})}},jt=/[\u2500-\u257F]/;function Nt(t){return jt.test(t)}function St(t){const n=t.split(`
4
- `),s=[];let r=!1;for(let a=0;a<n.length;a++){const i=n[a],c=Nt(i);c&&!r?(s.length>0&&s[s.length-1]!==""&&s.push(""),s.push("```plaintext"),r=!0):!c&&r&&(s.push("```"),i!==""&&s.push(""),r=!1),s.push(i)}return r&&s.push("```"),s.join(`
5
- `)}function ae({content:t,isStreaming:n}){const s=St(t);return n&&t?e.jsx("div",{className:"max-w-none leading-relaxed",children:e.jsxs("div",{className:"whitespace-pre-wrap text-base leading-relaxed",children:[t,e.jsx("span",{className:"inline-block w-0.5 h-4 bg-foreground/70 ml-0.5 align-text-bottom animate-pulse"})]})}):n&&!t?e.jsx("span",{className:"inline-block w-0.5 h-4 bg-foreground/70 ml-0.5 align-text-bottom animate-pulse"}):e.jsx("div",{className:"max-w-none leading-relaxed [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_p]:my-3 [&_p]:leading-relaxed [&_ul]:my-3 [&_ul]:pl-5 [&_ul]:list-disc [&_ol]:my-3 [&_ol]:pl-5 [&_ol]:list-decimal [&_li]:my-1 [&_li]:leading-relaxed [&_h1]:mt-6 [&_h1]:mb-3 [&_h2]:mt-5 [&_h2]:mb-2 [&_h3]:mt-4 [&_h3]:mb-1.5 [&_h4]:mt-3 [&_h4]:mb-1 [&_blockquote]:my-3 [&_hr]:my-6 [&_table]:my-4 [&_pre]:my-3",children:e.jsx(Ie,{remarkPlugins:[Oe],components:wt,children:s})})}function kt(t){if(!t||isNaN(t))return null;try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return null}}function Ct({message:t}){const n=t.role==="user",s=t.role==="tool",r=!!t.content?.trim(),a=!!t.reasoning?.trim(),i=!!t.toolCalls?.length,c=kt(t.timestamp);return s||!n&&!r&&(a||i)?e.jsxs("div",{className:"px-4 py-1",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[a&&e.jsx(ne,{reasoning:t.reasoning,isStreaming:t.isStreaming,startedAt:t.reasoningStartedAt,endedAt:t.reasoningEndedAt}),!s&&i&&e.jsx(re,{tools:t.toolCalls}),s&&e.jsx(vt,{name:t.toolName||"",content:t.content})]}),c&&e.jsx("span",{className:"mt-0.5 text-[10px] text-muted-foreground/40",children:c})]}):e.jsx("div",{className:A("flex px-4",n?"py-2 justify-end":"py-4 justify-start"),children:e.jsxs("div",{className:A("flex min-w-0 flex-col",n?"max-w-[85%] items-end":"w-full"),children:[t.isStreaming&&!r&&!a?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground py-1",children:[e.jsx(P,{className:"h-3.5 w-3.5 animate-spin"}),"Thinking..."]}):e.jsxs("div",{className:"flex flex-col gap-1 w-full",children:[a&&e.jsx(ne,{reasoning:t.reasoning,isStreaming:t.isStreaming,startedAt:t.reasoningStartedAt,endedAt:t.reasoningEndedAt}),!s&&!n&&i&&e.jsx(re,{tools:t.toolCalls}),r&&(n?e.jsx("div",{className:"rounded-2xl px-4 py-2.5 text-sm leading-relaxed overflow-x-auto bg-primary text-primary-foreground",children:e.jsx(ae,{content:t.content,isStreaming:t.isStreaming})}):e.jsx("div",{className:"text-base leading-relaxed",children:e.jsx(ae,{content:t.content,isStreaming:t.isStreaming})}))]}),r&&!n&&e.jsx("div",{className:"mt-1 flex items-center gap-2 px-1",children:e.jsx(xt,{text:t.content})}),c&&e.jsx("span",{className:"mt-1 text-[10px] text-muted-foreground/50 px-1",children:c})]})})}const Rt=l.memo(Ct),_t=l.memo(function({messages:n,isLoading:s}){const r=l.useMemo(()=>n.map(a=>({id:a.id,role:a.role==="user"?"user":a.role==="tool"?"tool":"assistant",content:a.content,timestamp:a.timestamp,isStreaming:a.isStreaming,reasoning:a.reasoning,reasoningStartedAt:a.reasoningStartedAt,reasoningEndedAt:a.reasoningEndedAt,toolCalls:a.toolCalls})),[n]);return e.jsx(e.Fragment,{children:r.map(a=>e.jsx(Rt,{message:a},a.id))})});function Mt(t){const n=l.useRef(null),s=l.useRef(null),r=l.useRef(!1),a=l.useRef(t.length),i=l.useCallback(h=>{!h&&r.current||s.current?.scrollIntoView({behavior:"smooth"})},[]),c=l.useCallback(()=>{const h=n.current;if(!h)return;const m=h.scrollHeight-h.scrollTop-h.clientHeight<80;r.current=!m},[]);return l.useEffect(()=>{const h=a.current;a.current=t.length,t.length>h&&t[t.length-1]?.role==="user"?(r.current=!1,i(!0)):i()},[t,i]),{containerRef:n,bottomRef:s,onScroll:c}}const Dt="http://localhost:47474";async function*At(t){const{input:n,conversation:s,model:r,signal:a}=t,i={input:n};s&&(i.conversation=s),r&&(i.model=r),t.messages&&t.messages.length>0&&(i.messages=t.messages),t.attachments&&t.attachments.length>0&&(i.attachments=t.attachments);const c=await fetch(`${Dt}/api/chat/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:a});if(!c.ok){const w=await c.text().catch(()=>"Stream request failed");throw new Error(w)}if(!c.body)throw new Error("No response body");const h=c.body.getReader(),m=new TextDecoder;let x="";try{for(;;){const{done:w,value:j}=await h.read();if(w)break;x+=m.decode(j,{stream:!0});let S=x.indexOf(`
6
-
7
- `);for(;S>=0;){const k=x.slice(0,S);x=x.slice(S+2);let C="",f="";for(const d of k.split(`
8
- `))d.startsWith("event: ")?C=d.slice(7).trim():d.startsWith("data: ")&&(f+=(f?`
9
- `:"")+d.slice(6));if(f){let d={};try{d=JSON.parse(f)}catch{d={raw:f}}yield{type:C||"unknown",data:d}}S=x.indexOf(`
10
-
11
- `)}}}finally{h.releaseLock()}}let zt=0;function oe(){return`msg-${++zt}-${Math.random().toString(36).slice(2,6)}`}function Et(){const t=l.useRef(null),n=l.useCallback((a,i)=>{y.setState(c=>({streamingSessions:i?new Set([...c.streamingSessions,a]):new Set([...c.streamingSessions].filter(h=>h!==a))}))},[]),s=l.useCallback(()=>{t.current&&(t.current.abort(),t.current=null)},[]);return{sendMessage:l.useCallback(async(a,i,c,h)=>{if(y.getState().streamingSessions.has(i))return;const m={id:oe(),role:"user",content:a,timestamp:Date.now()};y.setState(f=>{if(!f.sessions.find(u=>u.id===i)){const u=Date.now();return{sessions:[{id:i,title:a.slice(0,64),model:c||"",messages:[m],createdAt:u,updatedAt:u},...f.sessions]}}return{sessions:f.sessions.map(u=>u.id===i?{...u,messages:[...u.messages,m],model:c||u.model||"",title:!u.title||u.title==="New Conversation"||u.title==="Untitled"?a.slice(0,64):u.title}:u)}});const x=y.getState().sessions.find(f=>f.id===i)?.messages.slice(0,-1).filter(f=>!f.isStreaming&&f.content).map(f=>({role:f.role,content:f.content}))||[],j={id:oe(),role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0};y.setState(f=>({sessions:f.sessions.map(d=>d.id===i?{...d,messages:[...d.messages,j]}:d)})),n(i,!0);const S=new AbortController;t.current=S;let k=Date.now();const C=setInterval(()=>{Date.now()-k>3e5&&(console.warn("[stream] hang timeout — aborting",i),S.abort())},3e4);try{const f=At({input:a,conversation:i,model:c,signal:S.signal,messages:x,attachments:h?.attachments?.map(d=>({id:d.id,name:d.name,type:d.type,size:d.size}))});for await(const d of f)switch(k=Date.now(),d.type){case"token":{const u=d.data.delta||"";if(!u)continue;y.setState(p=>({sessions:p.sessions.map(b=>{if(b.id!==i)return b;const g=b.messages.slice(),v=g[g.length-1];return v&&v.role==="assistant"&&v.isStreaming&&(g[g.length-1]={...v,content:v.content+u}),{...b,messages:g}})}));break}case"reasoning":{const u=d.data.text||"";if(!u)continue;y.setState(p=>({sessions:p.sessions.map(b=>{if(b.id!==i)return b;const g=b.messages.slice(),v=g[g.length-1];if(v&&v.role==="assistant"&&v.isStreaming){const R=v.reasoning||"";g[g.length-1]={...v,reasoning:R+u,reasoningStartedAt:v.reasoningStartedAt||Date.now()}}return{...b,messages:g}})}));break}case"tool_start":{const u=d.data.name||"tool",p=d.data.preview||"",b=d.data.tool_call_id||void 0;y.setState(g=>({sessions:g.sessions.map(v=>{if(v.id!==i)return v;const R=v.messages.slice(),_=R[R.length-1];if(_&&_.role==="assistant"&&_.isStreaming){const L=[..._.toolCalls||[],{name:u,preview:p,callId:b,status:"running"}];R[R.length-1]={..._,toolCalls:L}}return{...v,messages:R}})}));break}case"tool_end":{const u=d.data.tool_call_id,p=d.data.tool,b=d.data.output;y.setState(g=>({sessions:g.sessions.map(v=>{if(v.id!==i)return v;const R=v.messages.slice(),_=R[R.length-1];if(!_?.toolCalls)return v;const L=_.toolCalls.map(M=>u&&M.callId===u?{...M,status:"done",output:b||M.output}:!u&&M.name===p&&M.status==="running"?{...M,status:"done",output:b||M.output}:M);return R[R.length-1]={..._,toolCalls:L},{...v,messages:R}})}));break}case"done":{y.setState(u=>({sessions:u.sessions.map(p=>{if(p.id!==i)return p;const b=p.messages.map(g=>g.role==="assistant"&&g.isStreaming?{...g,isStreaming:!1,reasoningEndedAt:g.reasoning?Date.now():void 0}:g);return{...p,messages:b}})})),n(i,!1);break}case"error":{const u=d.data.error;y.setState(p=>({sessions:p.sessions.map(b=>{if(b.id!==i)return b;const g=b.messages.map(v=>v.role==="assistant"&&v.isStreaming?{...v,isStreaming:!1,content:v.content||`**Error:** ${u||"Run failed"}`}:v);return{...b,messages:g}})})),n(i,!1);break}case"approval":{y.setState(u=>({sessions:u.sessions.map(p=>p.id===i?{...p,pendingApproval:d.data}:p)}));break}case"title":{const u=d.data.title;u&&y.setState(p=>({sessions:p.sessions.map(b=>b.id===i?{...b,title:u}:b)}));break}}}catch(f){const d=f instanceof Error?f.message:"Connection error";y.setState(u=>({sessions:u.sessions.map(p=>{if(p.id!==i)return p;const b=p.messages.map(g=>g.role==="assistant"&&g.isStreaming?{...g,isStreaming:!1,content:g.content||`**Error:** ${d}`}:g);return{...p,messages:b}})})),n(i,!1)}finally{clearInterval(C),t.current=null,n(i,!1),y.setState(f=>({sessions:f.sessions.map(d=>d.id!==i||!d.messages.some(p=>p.role==="assistant"&&p.isStreaming)?d:{...d,messages:d.messages.map(p=>p.role==="assistant"&&p.isStreaming?{...p,isStreaming:!1}:p)})}))}},[n]),abortChat:s}}function Tt({sessionId:t,model:n,isLoading:s,sendMessage:r,abortChat:a}){const i=le(),c=l.useRef(s);c.current=s;const h=l.useCallback(async(k,C)=>{const f=k.trim();if(!(!f||c.current)){if(ot(f)){const d=f.split(/\s+/)[0].toLowerCase();if(d==="/new"){const u=await X({model:n});i({to:"/chat/$sessionId",params:{sessionId:u.id}});return}if(d==="/clear"){y.setState(u=>({sessions:u.sessions.map(p=>p.id===t?{...p,messages:[]}:p)}));return}if(d==="/help"){const u=W.map(p=>`\`${p.name}\` — ${p.description}`).join(`
12
- `);y.setState(p=>({sessions:p.sessions.map(b=>b.id===t?{...b,messages:[...b.messages,{id:`agent-${Date.now()}`,role:"assistant",content:`**Available Commands**
13
-
14
- ${u}`,timestamp:Date.now()}]}:b)}));return}y.setState(u=>({sessions:u.sessions.map(p=>p.id===t?{...p,messages:[...p.messages,{id:`agent-${Date.now()}`,role:"assistant",content:`Command \`${d}\` is not yet implemented in the web UI.`,timestamp:Date.now()}]}:p)}));return}await r(f,t,n,{attachments:C})}},[t,n,r,i]),m=l.useCallback(()=>{a()},[a]),x=l.useCallback(async()=>{c.current||await r("/approve",t,n)},[t,n,r]),w=l.useCallback(async()=>{c.current||await r("/deny",t,n)},[t,n,r]),j=l.useCallback(async()=>{const k=await X({model:n});i({to:"/chat/$sessionId",params:{sessionId:k.id}})},[n,i]),S=l.useCallback(()=>{c.current&&a(),y.setState(k=>({sessions:k.sessions.map(C=>C.id===t?{...C,messages:[]}:C)}))},[t,a]);return{handleSend:h,handleAbort:m,handleApprove:x,handleDeny:w,handleNewChat:j,handleClear:S}}function $t({sessionId:t,request:n,onResolved:s}){const[r,a]=l.useState(!1),i=async x=>{a(!0);try{await De({session_id:t,choice:x}),s()}catch{}finally{a(!1)}},c=n.tool_name||"unknown tool",h=typeof n.command=="string"?n.command:typeof n.arguments=="string"?n.arguments:null,m=typeof n.description=="string"?n.description:typeof n.preview=="string"?n.preview:null;return e.jsx("div",{className:"mx-auto max-w-3xl px-4 py-3",children:e.jsxs("div",{className:"rounded-2xl border border-amber-500/30 bg-amber-500/5 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Q,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"text-sm font-medium text-amber-600 dark:text-amber-400",children:"Approval Required"})]}),e.jsxs("p",{className:"text-sm text-foreground mb-1",children:["The agent wants to use ",e.jsx("span",{className:"font-medium",children:c})]}),h&&e.jsx("div",{className:"mt-2 rounded-lg bg-muted/60 border border-border px-3 py-2 text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all max-h-32 overflow-y-auto",children:h}),m&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground leading-relaxed",children:m}),n.risk==="high"&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-red-500",children:[e.jsx(Pe,{className:"h-3.5 w-3.5"}),"High risk operation"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(T,{size:"sm",variant:"default",className:"gap-1.5 bg-emerald-600 hover:bg-emerald-700 text-white",disabled:r,onClick:()=>i("once"),children:[e.jsx(U,{className:"h-3.5 w-3.5"}),"Approve once"]}),e.jsxs(T,{size:"sm",variant:"secondary",className:"gap-1.5",disabled:r,onClick:()=>i("session"),children:[e.jsx(U,{className:"h-3.5 w-3.5"}),"Approve all"]}),e.jsxs(T,{size:"sm",variant:"outline",className:"gap-1.5",disabled:r,onClick:()=>i("always"),children:[e.jsx(Q,{className:"h-3.5 w-3.5"}),"Always allow"]}),e.jsxs(T,{size:"sm",variant:"ghost",className:"gap-1.5 text-destructive hover:text-destructive",disabled:r,onClick:()=>i("deny"),children:[e.jsx(ie,{className:"h-3.5 w-3.5"}),"Deny"]})]})]})})}function Lt({sessionId:t,messages:n,title:s,model:r,pendingApproval:a}){const i=l.useRef(null),c=l.useRef(!1),{containerRef:h,bottomRef:m,onScroll:x}=Mt(n),{sendMessage:w,abortChat:j}=Et(),S=y(f=>f.streamingSessions.has(t)),k=Tt({sessionId:t,model:r,isLoading:S,sendMessage:w,abortChat:j});l.useEffect(()=>{if(!t||c.current)return;const f=`hermium_pending_msg_${t}`,d=`hermium_pending_model_${t}`,u=sessionStorage.getItem(f);if(!u)return;c.current=!0;const p=sessionStorage.getItem(d)||r;sessionStorage.removeItem(f),sessionStorage.removeItem(d),w(u,t,p)},[t,r,w]),l.useEffect(()=>{function f(d){(d.metaKey||d.ctrlKey)&&d.key==="n"&&(d.preventDefault(),k.handleNewChat())}return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[k]);const C=l.useCallback(f=>{i.current?.setText(f)},[]);return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[e.jsx(pt,{sessionId:t,title:s,hasMessages:n.length>0,onNewChat:k.handleNewChat,onClear:k.handleClear}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-y-auto",ref:h,onScroll:x,children:[n.length===0&&!S?e.jsx(gt,{onSelectSuggestion:C}):e.jsx("div",{className:"mx-auto max-w-3xl",children:e.jsx(_t,{messages:n,isLoading:S,onApprove:k.handleApprove,onDeny:k.handleDeny})}),e.jsx("div",{ref:m}),a&&e.jsx("div",{className:"mx-auto max-w-3xl",children:e.jsx($t,{sessionId:t,request:a,onResolved:()=>{y.getState().updateSession(t,{pendingApproval:null})}})})]}),e.jsx("div",{className:"shrink-0 px-4 py-3 border-t bg-card/50 backdrop-blur-sm",children:e.jsx(mt,{ref:i,sessionId:t,isLoading:S,onSubmit:k.handleSend,onAbort:k.handleAbort})})]})}function Bt(){const{sessionId:t}=Ae.useParams(),n=y(m=>m.switchSession),s=y(m=>m.loadSessions),r=y(m=>m.loadSessionMessages),a=y(m=>m.sessionsLoaded),i=y(m=>m.isLoadingMessages),c=y(te(m=>{const x=m.sessions.find(w=>w.id===t);return{title:x?.title,model:x?.model||"",pendingApproval:x?.pendingApproval??null}})),h=y(te(m=>m.sessions.find(w=>w.id===t)?.messages??[]));return l.useEffect(()=>{a||s()},[a,s]),l.useEffect(()=>{if(!t)return;n(t);const m=y.getState().getSession(t);(!m||m.messages.length===0)&&r(t)},[t,n,r]),i&&h.length===0?e.jsxs("div",{className:"flex flex-1 flex-col h-full overflow-hidden",children:[e.jsx("div",{className:"shrink-0 border-b px-4 py-2.5 flex items-center gap-2 min-w-0",children:e.jsx("span",{className:"text-sm text-muted-foreground truncate flex-1",children:"Loading…"})}),e.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:e.jsx("div",{className:"space-y-4 p-4 mx-auto max-w-3xl",children:[1,2,3].map(m=>e.jsxs("div",{className:"animate-pulse space-y-2",children:[e.jsx("div",{className:`h-4 rounded bg-muted ${m%2===0?"w-2/3":"w-1/2 ml-auto"}`}),e.jsx("div",{className:`h-3 rounded bg-muted ${m%2===0?"w-1/2":"w-1/3 ml-auto"}`})]},m))})})]}):e.jsx(Lt,{sessionId:t,messages:h,title:c.title,model:c.model,pendingApproval:c.pendingApproval})}export{Bt as component};