hermium 0.1.9 → 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 (209) 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-BHkmI3j7.js +0 -1
  28. package/dist/public/assets/IconAlertTriangle-wCJudlVg.js +0 -1
  29. package/dist/public/assets/IconCheck-CFuEh_p7.js +0 -1
  30. package/dist/public/assets/IconLoader2-BIx3OuF9.js +0 -1
  31. package/dist/public/assets/IconRefresh-Dgm93w3T.js +0 -1
  32. package/dist/public/assets/geist-cyrillic-wght-normal-CHSlOQsW.woff2 +0 -0
  33. package/dist/public/assets/geist-latin-ext-wght-normal-DMtmJ5ZE.woff2 +0 -0
  34. package/dist/public/assets/geist-latin-wght-normal-Dm3htQBi.woff2 +0 -0
  35. package/dist/public/assets/index-Bbz3abmO.js +0 -14
  36. package/dist/public/assets/index-CWUaRwcE.js +0 -1
  37. package/dist/public/assets/index-CinLq3cd.js +0 -1
  38. package/dist/public/assets/index-CrQs9n6q.js +0 -29
  39. package/dist/public/assets/index-CtacpN3I.js +0 -1
  40. package/dist/public/assets/index-DY7aE-9s.js +0 -2
  41. package/dist/public/assets/index-DkYGodJj.js +0 -94
  42. package/dist/public/assets/index-DvDLadUx.js +0 -1
  43. package/dist/public/assets/index-U6RcWedt.js +0 -1
  44. package/dist/public/assets/index-_6iFZ0fh.js +0 -1
  45. package/dist/public/assets/index-enFS26SU.js +0 -1
  46. package/dist/public/assets/input-eNcwlDHp.js +0 -1
  47. package/dist/public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  48. package/dist/public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  49. package/dist/public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  50. package/dist/public/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  51. package/dist/public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  52. package/dist/public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  53. package/dist/public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  54. package/dist/public/assets/queries-iHRgZzw2.js +0 -1
  55. package/dist/public/assets/styles-KcflDlA_.css +0 -1
  56. package/dist/public/assets/switch-B1DcZLwL.js +0 -1
  57. package/dist/public/assets/syntax-highlighter-DWPF-A_h.js +0 -6
  58. package/dist/public/assets/textarea-Di_syYTS.js +0 -1
  59. package/dist/public/favicon.png +0 -0
  60. package/dist/public/nous-logo.png +0 -0
  61. package/dist/server/index.mjs +0 -244
  62. package/dist/web-server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +0 -6
  63. package/dist/web-server/_chunks/ssr-renderer.mjs +0 -22
  64. package/dist/web-server/_libs/babel__runtime.mjs +0 -237
  65. package/dist/web-server/_libs/bail.mjs +0 -8
  66. package/dist/web-server/_libs/base-ui__react.mjs +0 -9554
  67. package/dist/web-server/_libs/base-ui__utils.mjs +0 -1101
  68. package/dist/web-server/_libs/ccount.mjs +0 -16
  69. package/dist/web-server/_libs/character-entities-legacy.mjs +0 -111
  70. package/dist/web-server/_libs/character-entities.mjs +0 -2130
  71. package/dist/web-server/_libs/character-reference-invalid.mjs +0 -33
  72. package/dist/web-server/_libs/class-variance-authority.mjs +0 -44
  73. package/dist/web-server/_libs/clsx.mjs +0 -16
  74. package/dist/web-server/_libs/comma-separated-tokens.mjs +0 -31
  75. package/dist/web-server/_libs/cookie-es.mjs +0 -44
  76. package/dist/web-server/_libs/croner.mjs +0 -1
  77. package/dist/web-server/_libs/crossws.mjs +0 -1
  78. package/dist/web-server/_libs/decode-named-character-reference+[...].mjs +0 -8
  79. package/dist/web-server/_libs/devlop.mjs +0 -8
  80. package/dist/web-server/_libs/escape-string-regexp.mjs +0 -9
  81. package/dist/web-server/_libs/estree-util-is-identifier-name.mjs +0 -11
  82. package/dist/web-server/_libs/extend.mjs +0 -97
  83. package/dist/web-server/_libs/fault.mjs +0 -1
  84. package/dist/web-server/_libs/floating-ui__core.mjs +0 -663
  85. package/dist/web-server/_libs/floating-ui__dom.mjs +0 -624
  86. package/dist/web-server/_libs/floating-ui__react-dom.mjs +0 -279
  87. package/dist/web-server/_libs/floating-ui__utils.mjs +0 -322
  88. package/dist/web-server/_libs/format.mjs +0 -1
  89. package/dist/web-server/_libs/h3.mjs +0 -408
  90. package/dist/web-server/_libs/hast-util-parse-selector.mjs +0 -39
  91. package/dist/web-server/_libs/hast-util-to-jsx-runtime.mjs +0 -388
  92. package/dist/web-server/_libs/hast-util-whitespace.mjs +0 -10
  93. package/dist/web-server/_libs/hastscript.mjs +0 -200
  94. package/dist/web-server/_libs/highlight.js.mjs +0 -1
  95. package/dist/web-server/_libs/hookable.mjs +0 -1
  96. package/dist/web-server/_libs/html-url-attributes.mjs +0 -26
  97. package/dist/web-server/_libs/inline-style-parser.mjs +0 -142
  98. package/dist/web-server/_libs/is-alphabetical.mjs +0 -7
  99. package/dist/web-server/_libs/is-alphanumerical.mjs +0 -8
  100. package/dist/web-server/_libs/is-decimal.mjs +0 -7
  101. package/dist/web-server/_libs/is-hexadecimal.mjs +0 -7
  102. package/dist/web-server/_libs/is-plain-obj.mjs +0 -10
  103. package/dist/web-server/_libs/isbot.mjs +0 -21
  104. package/dist/web-server/_libs/longest-streak.mjs +0 -25
  105. package/dist/web-server/_libs/lowlight.mjs +0 -1
  106. package/dist/web-server/_libs/markdown-table.mjs +0 -142
  107. package/dist/web-server/_libs/mdast-util-find-and-replace.mjs +0 -109
  108. package/dist/web-server/_libs/mdast-util-from-markdown.mjs +0 -717
  109. package/dist/web-server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +0 -156
  110. package/dist/web-server/_libs/mdast-util-gfm-footnote.mjs +0 -117
  111. package/dist/web-server/_libs/mdast-util-gfm-strikethrough.mjs +0 -54
  112. package/dist/web-server/_libs/mdast-util-gfm-table.mjs +0 -157
  113. package/dist/web-server/_libs/mdast-util-gfm-task-list-item.mjs +0 -77
  114. package/dist/web-server/_libs/mdast-util-gfm.mjs +0 -29
  115. package/dist/web-server/_libs/mdast-util-phrasing.mjs +0 -30
  116. package/dist/web-server/_libs/mdast-util-to-hast.mjs +0 -710
  117. package/dist/web-server/_libs/mdast-util-to-markdown.mjs +0 -798
  118. package/dist/web-server/_libs/mdast-util-to-string.mjs +0 -38
  119. package/dist/web-server/_libs/micromark-core-commonmark.mjs +0 -2259
  120. package/dist/web-server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +0 -344
  121. package/dist/web-server/_libs/micromark-extension-gfm-footnote+[...].mjs +0 -279
  122. package/dist/web-server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +0 -98
  123. package/dist/web-server/_libs/micromark-extension-gfm-table.mjs +0 -491
  124. package/dist/web-server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +0 -1
  125. package/dist/web-server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +0 -77
  126. package/dist/web-server/_libs/micromark-extension-gfm.mjs +0 -18
  127. package/dist/web-server/_libs/micromark-factory-destination.mjs +0 -94
  128. package/dist/web-server/_libs/micromark-factory-label.mjs +0 -63
  129. package/dist/web-server/_libs/micromark-factory-space.mjs +0 -24
  130. package/dist/web-server/_libs/micromark-factory-title.mjs +0 -65
  131. package/dist/web-server/_libs/micromark-factory-whitespace.mjs +0 -22
  132. package/dist/web-server/_libs/micromark-util-character.mjs +0 -44
  133. package/dist/web-server/_libs/micromark-util-chunked.mjs +0 -36
  134. package/dist/web-server/_libs/micromark-util-classify-character+[...].mjs +0 -12
  135. package/dist/web-server/_libs/micromark-util-combine-extensions+[...].mjs +0 -41
  136. package/dist/web-server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +0 -19
  137. package/dist/web-server/_libs/micromark-util-decode-string.mjs +0 -21
  138. package/dist/web-server/_libs/micromark-util-encode.mjs +0 -1
  139. package/dist/web-server/_libs/micromark-util-html-tag-name.mjs +0 -69
  140. package/dist/web-server/_libs/micromark-util-normalize-identifier+[...].mjs +0 -6
  141. package/dist/web-server/_libs/micromark-util-resolve-all.mjs +0 -15
  142. package/dist/web-server/_libs/micromark-util-sanitize-uri.mjs +0 -41
  143. package/dist/web-server/_libs/micromark-util-subtokenize.mjs +0 -346
  144. package/dist/web-server/_libs/micromark.mjs +0 -906
  145. package/dist/web-server/_libs/ocache.mjs +0 -1
  146. package/dist/web-server/_libs/ohash.mjs +0 -1
  147. package/dist/web-server/_libs/parse-entities.mjs +0 -245
  148. package/dist/web-server/_libs/property-information.mjs +0 -1210
  149. package/dist/web-server/_libs/react-dom.mjs +0 -10779
  150. package/dist/web-server/_libs/react-markdown.mjs +0 -147
  151. package/dist/web-server/_libs/react-syntax-highlighter.mjs +0 -941
  152. package/dist/web-server/_libs/react.mjs +0 -513
  153. package/dist/web-server/_libs/refractor.mjs +0 -2425
  154. package/dist/web-server/_libs/remark-gfm.mjs +0 -20
  155. package/dist/web-server/_libs/remark-parse.mjs +0 -19
  156. package/dist/web-server/_libs/remark-rehype.mjs +0 -21
  157. package/dist/web-server/_libs/reselect.mjs +0 -1
  158. package/dist/web-server/_libs/rou3.mjs +0 -8
  159. package/dist/web-server/_libs/seroval-plugins.mjs +0 -58
  160. package/dist/web-server/_libs/seroval.mjs +0 -1775
  161. package/dist/web-server/_libs/space-separated-tokens.mjs +0 -11
  162. package/dist/web-server/_libs/srvx.mjs +0 -781
  163. package/dist/web-server/_libs/style-to-js.mjs +0 -72
  164. package/dist/web-server/_libs/style-to-object.mjs +0 -38
  165. package/dist/web-server/_libs/tabler__icons-react.mjs +0 -230
  166. package/dist/web-server/_libs/tanstack__history.mjs +0 -204
  167. package/dist/web-server/_libs/tanstack__query-core.mjs +0 -2552
  168. package/dist/web-server/_libs/tanstack__react-query.mjs +0 -190
  169. package/dist/web-server/_libs/tanstack__react-router.mjs +0 -1120
  170. package/dist/web-server/_libs/tanstack__react-store.mjs +0 -2
  171. package/dist/web-server/_libs/tanstack__router-core.mjs +0 -4288
  172. package/dist/web-server/_libs/tanstack__store.mjs +0 -1
  173. package/dist/web-server/_libs/trim-lines.mjs +0 -41
  174. package/dist/web-server/_libs/trough.mjs +0 -85
  175. package/dist/web-server/_libs/ufo.mjs +0 -54
  176. package/dist/web-server/_libs/unctx.mjs +0 -1
  177. package/dist/web-server/_libs/ungap__structured-clone.mjs +0 -224
  178. package/dist/web-server/_libs/unified.mjs +0 -661
  179. package/dist/web-server/_libs/unist-util-is.mjs +0 -100
  180. package/dist/web-server/_libs/unist-util-position.mjs +0 -27
  181. package/dist/web-server/_libs/unist-util-stringify-position.mjs +0 -27
  182. package/dist/web-server/_libs/unist-util-visit-parents.mjs +0 -83
  183. package/dist/web-server/_libs/unist-util-visit.mjs +0 -24
  184. package/dist/web-server/_libs/unstorage.mjs +0 -1
  185. package/dist/web-server/_libs/use-sync-external-store.mjs +0 -139
  186. package/dist/web-server/_libs/vfile-message.mjs +0 -138
  187. package/dist/web-server/_libs/vfile.mjs +0 -467
  188. package/dist/web-server/_libs/zod.mjs +0 -3915
  189. package/dist/web-server/_libs/zustand.mjs +0 -343
  190. package/dist/web-server/_libs/zwitch.mjs +0 -1
  191. package/dist/web-server/_ssr/index-0n2Z3BPQ.mjs +0 -369
  192. package/dist/web-server/_ssr/index-6itDALOw.mjs +0 -339
  193. package/dist/web-server/_ssr/index-BIRTrOmp.mjs +0 -449
  194. package/dist/web-server/_ssr/index-BPzfADac.mjs +0 -66
  195. package/dist/web-server/_ssr/index-BQE3bF14.mjs +0 -1870
  196. package/dist/web-server/_ssr/index-C5HpvlUP.mjs +0 -190
  197. package/dist/web-server/_ssr/index-C_ZxnypN.mjs +0 -213
  198. package/dist/web-server/_ssr/index-Ca8JFH8f.mjs +0 -612
  199. package/dist/web-server/_ssr/index-DNVESZiA.mjs +0 -513
  200. package/dist/web-server/_ssr/index.mjs +0 -1558
  201. package/dist/web-server/_ssr/input-CqXjTRQg.mjs +0 -20
  202. package/dist/web-server/_ssr/queries-3H_19mUt.mjs +0 -16
  203. package/dist/web-server/_ssr/router-sbsNus0Y.mjs +0 -2093
  204. package/dist/web-server/_ssr/start-HYkvq4Ni.mjs +0 -4
  205. package/dist/web-server/_ssr/switch-usf2F1UM.mjs +0 -33
  206. package/dist/web-server/_ssr/syntax-highlighter-5vezNTce.mjs +0 -62
  207. package/dist/web-server/_ssr/textarea-DfRheWY0.mjs +0 -18
  208. package/dist/web-server/_tanstack-start-manifest_v-DqW-pKEH.mjs +0 -4
  209. package/dist/web-server/index.mjs +0 -597
@@ -0,0 +1 @@
1
+ import{am as e}from"./index-C0AK45FU.js";import{d as a}from"./router-8uDKazL-.js";import{C as n}from"./ChatInputBlock-Bw7AL70H.js";import"./base-ui-BvQbAt_1.js";function x(){const t=a();return e.jsx("div",{className:"flex flex-1 flex-col items-center justify-center px-4",children:e.jsxs("div",{className:"flex flex-col items-center gap-6 w-full max-w-2xl mx-auto",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-semibold tracking-tight text-foreground text-center",children:"What can I help you with?"}),e.jsx("div",{className:"w-full",children:e.jsx(n,{onCreateSession:s=>{t({to:"/chat/$sessionId",params:{sessionId:s}})}})})]})})}export{x as component};
@@ -0,0 +1,3 @@
1
+ import{aw as y,ar as r,aF as w,am as e,j as g,S as z,D as k,d as j,b as u,p as C,l as I,s as M,r as E}from"./index-C0AK45FU.js";import{M as A}from"./MarkdownMessage-8d7Y6VL-.js";import"./base-ui-BvQbAt_1.js";import"./router-8uDKazL-.js";async function D(){return y("/api/hermes/memory")}async function F(s,o){await y("/api/hermes/memory",{method:"POST",body:JSON.stringify({section:s,content:o})})}const L={memory:{title:"My Notes",icon:e.jsx(E,{className:"size-4"}),empty:"No notes yet. Write down things you want the AI to remember.",placeholder:"Write anything you want the AI to remember about this conversation, context, or preferences..."},user:{title:"User Profile",icon:e.jsx(M,{className:"size-4"}),empty:"No user profile. Add details about yourself.",placeholder:"Describe yourself — your role, expertise, preferences, communication style..."},soul:{title:"Soul",icon:e.jsx(j,{className:"size-4"}),empty:"No soul defined. Set the AI's personality and behavior.",placeholder:"Define the AI's personality, tone, expertise, and how it should behave..."}};function P(s){if(!s)return"";try{return new Date(s).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return""}}function p({section:s,data:o,onSave:f}){const[l,i]=r.useState(!1),[c,m]=r.useState(""),[d,n]=r.useState(!1),a=L[s],t=o[s],x=o[`${s}_mtime`],N=!t.trim(),v=()=>{m(t),i(!0)},b=()=>{i(!1),m("")},S=async()=>{n(!0);try{await f(s,c),i(!1)}catch(h){console.error("Failed to save memory:",h)}finally{n(!1)}};return e.jsxs("div",{className:"flex flex-col border rounded-lg overflow-hidden h-full min-h-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 bg-muted/50 border-b shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:a.icon}),e.jsx("span",{className:"text-sm font-medium",children:a.title}),x?e.jsx("span",{className:"text-[10px] text-muted-foreground/60 ml-1",children:P(x)}):null]}),l?e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(u,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:b,disabled:d,children:"Cancel"}),e.jsx(u,{size:"sm",className:"h-7 px-3 text-xs",onClick:S,disabled:d,children:d?e.jsx(g,{className:"size-3 animate-spin"}):"Save"})]}):e.jsxs(u,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:v,children:[e.jsx(I,{className:"size-3 mr-1"}),"Edit"]})]}),l?e.jsx("textarea",{value:c,onChange:h=>m(h.target.value),placeholder:a.placeholder,spellCheck:!1,className:"flex-1 min-h-0 w-full resize-none border-0 bg-transparent px-3 py-3 text-sm leading-relaxed outline-none focus-visible:ring-0 font-mono"}):e.jsx("div",{className:"flex-1 overflow-y-auto p-3 min-h-0",children:N?e.jsx("p",{className:"text-sm text-muted-foreground italic",children:a.empty}):e.jsx(A,{content:t.replace(/§/g,`
2
+
3
+ `)})})]})}function U(){const[s,o]=r.useState(null),[f,l]=r.useState(!0),[i,c]=r.useState(!1),{state:m}=w(),d=m==="collapsed",n=r.useCallback(async()=>{try{const t=await D();o(t)}catch(t){console.error("Failed to load memory:",t)}},[]);r.useEffect(()=>{l(!0),n().finally(()=>l(!1))},[n]);const a=async(t,x)=>{await F(t,x),await n()};return f?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(g,{className:"size-4 animate-spin"}),"Loading memory…"]})}):s?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-4 py-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx(z,{className:k("mr-1 -ml-1 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0")}),e.jsx(j,{className:"size-5 text-muted-foreground"}),e.jsx("h2",{className:"text-sm font-medium",children:"Memory"})]}),e.jsxs(u,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{c(!0),n().finally(()=>c(!1))},disabled:i,children:[i?e.jsx(g,{className:"size-3 animate-spin"}):e.jsx(C,{className:"size-3"}),"Refresh"]})]}),e.jsx("div",{className:"flex-1 min-h-0 p-4 overflow-hidden",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 h-full min-h-0",children:[e.jsx(p,{section:"memory",data:s,onSave:a}),e.jsx(p,{section:"user",data:s,onSave:a}),e.jsx(p,{section:"soul",data:s,onSave:a})]})})]}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load memory."})})}export{U as component};
@@ -0,0 +1 @@
1
+ import{ar as c,am as i,J as ze,T as q,R as O,aG as g,a8 as k,av as we,a9 as xe,N as Je,au as Re,H as b,Q as Ce,ap as $e,aq as Ge,B as Ve,a as Qe,ae as Ye,ag as J,a1 as Ze,ay as ie,aj as Xe,F as et,ai as tt,Z as z,aC as Ie,A as Le,a5 as rt,E as Pe,y as nt,a6 as ot,K as st,ac as at,W as be,ax as it}from"./index-C0AK45FU.js";var $=c.use,H=typeof window<"u"?c.useLayoutEffect:c.useEffect;function se(e){const t=c.useRef({value:e,prev:null}),r=t.current.value;return e!==r&&(t.current={value:e,prev:r}),t.current.prev}function ct(e,t,r={},n={}){c.useEffect(()=>{if(!e.current||n.disabled||typeof IntersectionObserver!="function")return;const a=new IntersectionObserver(([o])=>{t(o)},r);return a.observe(e.current),()=>{a.disconnect()}},[t,r,n.disabled,e])}function ut(e){const t=c.useRef(null);return c.useImperativeHandle(e,()=>t.current,[]),t}function lt({promise:e}){if($)return $(e);const t=ze(e);if(t[q].status==="pending")throw t;if(t[q].status==="error")throw t[q].error;return t[q].data}function rr(e){const t=i.jsx(dt,{...e});return e.fallback?i.jsx(c.Suspense,{fallback:e.fallback,children:t}):t}function dt(e){const t=lt(e);return e.children(t)}function ce(e){const t=e.errorComponent??ue;return i.jsx(ft,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:r,reset:n})=>r?c.createElement(t,{error:r,reset:n}):e.children})}var ft=class extends c.Component{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromProps(e,t){const r=e.getResetKey();return t.error&&t.resetKey!==r?{resetKey:r,error:null}:{resetKey:r}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.error,reset:()=>{this.reset()}})}};function ue({error:e}){const[t,r]=c.useState(!1);return i.jsxs("div",{style:{padding:".5rem",maxWidth:"100%"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:".5rem"},children:[i.jsx("strong",{style:{fontSize:"1rem"},children:"Something went wrong!"}),i.jsx("button",{style:{appearance:"none",fontSize:".6em",border:"1px solid currentColor",padding:".1rem .2rem",fontWeight:"bold",borderRadius:".25rem"},onClick:()=>r(n=>!n),children:t?"Hide Error":"Show Error"})]}),i.jsx("div",{style:{height:".25rem"}}),t?i.jsx("div",{children:i.jsx("pre",{style:{fontSize:".7em",border:"1px solid red",borderRadius:".25rem",padding:".3rem",color:"red",overflow:"auto"},children:e.message?i.jsx("code",{children:e.message}):null})}):null]})}function ht({children:e,fallback:t=null}){return le()?i.jsx(O.Fragment,{children:e}):i.jsx(O.Fragment,{children:t})}function le(){return O.useSyncExternalStore(pt,()=>!0,()=>!1)}function pt(){return()=>{}}var _e=c.createContext(null);function S(e){return c.useContext(_e)}var G=c.createContext(void 0),mt=c.createContext(void 0),gt={get:()=>{},subscribe:()=>({unsubscribe:()=>{}})};function _(e){const t=S(),r=c.useContext(e.from?mt:G),n=e.from??r,a=n?e.from?t.stores.getRouteMatchStore(n):t.stores.matchStores.get(n):void 0,o=c.useRef(void 0);return g(a??gt,s=>{if((e.shouldThrow??!0)&&!s&&k(),s===void 0)return;const u=e.select?e.select(s):s;if(e.structuralSharing??t.options.defaultStructuralSharing){const h=we(o.current,u);return o.current=h,h}return u})}function Te(e){return _({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function Me(e){const{select:t,...r}=e;return _({...r,select:n=>t?t(n.loaderDeps):n.loaderDeps})}function Ee(e){return _({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{const r=e.strict===!1?t.params:t._strictParams;return e.select?e.select(r):r}})}function ke(e){return _({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function Ae(e){const t=S();return c.useCallback(r=>t.navigate({...r,from:r.from??e?.from}),[e?.from,t])}function Be(e){return _({...e,select:t=>e.select?e.select(t.context):t.context})}function yt(e,t){const r=S(),n=ut(t),{activeProps:a,inactiveProps:o,activeOptions:s,to:u,preload:h,preloadDelay:l,preloadIntentProximity:d,hashScrollIntoView:f,replace:y,startTransition:p,resetScroll:v,viewTransition:I,children:P,target:A,disabled:C,style:W,className:V,onClick:Q,onBlur:Y,onFocus:Z,onMouseEnter:X,onMouseLeave:ee,onTouchStart:te,ignoreBlocker:Oe,params:Jt,search:$t,hash:Gt,state:Vt,mask:Qt,reloadDocument:Yt,unsafeRelative:Zt,from:Xt,_fromLocation:er,...de}=e,re=le(),B=c.useMemo(()=>e,[r,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),j=g(r.stores.location,m=>m,(m,R)=>m.href===R.href),x=c.useMemo(()=>{const m={_fromLocation:j,...B};return r.buildLocation(m)},[r,j,B]),fe=x.maskedLocation?x.maskedLocation.publicHref:x.publicHref,he=x.maskedLocation?x.maskedLocation.external:x.external,F=c.useMemo(()=>It(fe,he,r.history,C),[C,he,fe,r.history]),D=c.useMemo(()=>{if(F?.external)return xe(F.href,r.protocolAllowlist)?void 0:F.href;if(!Pt(u)&&!(typeof u!="string"||u.indexOf(":")===-1))try{return new URL(u),xe(u,r.protocolAllowlist)?void 0:u}catch{}},[u,F,r.protocolAllowlist]),ne=c.useMemo(()=>{if(D)return!1;if(s?.exact){if(!Je(j.pathname,x.pathname,r.basepath))return!1}else{const m=Re(j.pathname,r.basepath),R=Re(x.pathname,r.basepath);if(!(m.startsWith(R)&&(m.length===R.length||m[R.length]==="/")))return!1}return(s?.includeSearch??!0)&&!b(j.search,x.search,{partial:!s?.exact,ignoreUndefined:!s?.explicitUndefined})?!1:s?.includeHash?re&&j.hash===x.hash:!0},[s?.exact,s?.explicitUndefined,s?.includeHash,s?.includeSearch,j,D,re,x.hash,x.pathname,x.search,r.basepath]),K=ne?Ce(a,{})??vt:ae,U=ne?ae:Ce(o,{})??ae,pe=[V,K.className,U.className].filter(Boolean).join(" "),me=(W||K.style||U.style)&&{...W,...K.style,...U.style},[We,ge]=c.useState(!1),ye=c.useRef(!1),T=e.reloadDocument||D?!1:h??r.options.defaultPreload,oe=l??r.options.defaultPreloadDelay??0,w=c.useCallback(()=>{r.preloadRoute({...B,_builtLocation:x}).catch(m=>{console.warn(m),console.warn($e)})},[r,B,x]);ct(n,c.useCallback(m=>{m?.isIntersecting&&w()},[w]),Ct,{disabled:!!C||T!=="viewport"}),c.useEffect(()=>{ye.current||!C&&T==="render"&&(w(),ye.current=!0)},[C,w,T]);const Ke=m=>{const R=m.currentTarget.getAttribute("target"),L=A!==void 0?A:R;if(!C&&!bt(m)&&!m.defaultPrevented&&(!L||L==="_self")&&m.button===0){m.preventDefault(),Ge.flushSync(()=>{ge(!0)});const qe=r.subscribe("onResolved",()=>{qe(),ge(!1)});r.navigate({...B,replace:y,resetScroll:v,hashScrollIntoView:f,startTransition:p,viewTransition:I,ignoreBlocker:Oe})}};if(D)return{...de,ref:n,href:D,...P&&{children:P},...A&&{target:A},...C&&{disabled:C},...W&&{style:W},...V&&{className:V},...Q&&{onClick:Q},...Y&&{onBlur:Y},...Z&&{onFocus:Z},...X&&{onMouseEnter:X},...ee&&{onMouseLeave:ee},...te&&{onTouchStart:te}};const ve=m=>{if(C||T!=="intent")return;if(!oe){w();return}const R=m.currentTarget;if(N.has(R))return;const L=setTimeout(()=>{N.delete(R),w()},oe);N.set(R,L)},Ue=m=>{C||T!=="intent"||w()},Se=m=>{if(C||!T||!oe)return;const R=m.currentTarget,L=N.get(R);L&&(clearTimeout(L),N.delete(R))};return{...de,...K,...U,href:F?.href,ref:n,onClick:M([Q,Ke]),onBlur:M([Y,Se]),onFocus:M([Z,ve]),onMouseEnter:M([X,ve]),onMouseLeave:M([ee,Se]),onTouchStart:M([te,Ue]),disabled:!!C,target:A,...me&&{style:me},...pe&&{className:pe},...C&&St,...ne&&xt,...re&&We&&Rt}}var ae={},vt={className:"active"},St={role:"link","aria-disabled":!0},xt={"data-status":"active","aria-current":"page"},Rt={"data-transitioning":"transitioning"},N=new WeakMap,Ct={rootMargin:"100px"},M=e=>t=>{for(const r of e)if(r){if(t.defaultPrevented)return;r(t)}};function It(e,t,r,n){if(!n)return t?{href:e,external:!0}:{href:r.createHref(e)||"/",external:!1}}function Pt(e){if(typeof e!="string")return!1;const t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var Fe=c.forwardRef((e,t)=>{const{_asChild:r,...n}=e,{type:a,...o}=yt(n,t),s=typeof n.children=="function"?n.children({isActive:o["data-status"]==="active"}):n.children;if(!r){const{disabled:u,...h}=o;return c.createElement("a",h,s)}return c.createElement(r,o,s)});function bt(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var jt=class extends Qe{constructor(e){super(e),this.useMatch=t=>_({select:t?.select,from:this.id,structuralSharing:t?.structuralSharing}),this.useRouteContext=t=>Be({...t,from:this.id}),this.useSearch=t=>ke({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useParams=t=>Ee({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useLoaderDeps=t=>Me({...t,from:this.id}),this.useLoaderData=t=>Te({...t,from:this.id}),this.useNavigate=()=>Ae({from:this.fullPath}),this.Link=O.forwardRef((t,r)=>i.jsx(Fe,{ref:r,from:this.fullPath,...t}))}};function wt(e){return new jt(e)}var Lt=class extends Ve{constructor(e){super(e),this.useMatch=t=>_({select:t?.select,from:this.id,structuralSharing:t?.structuralSharing}),this.useRouteContext=t=>Be({...t,from:this.id}),this.useSearch=t=>ke({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useParams=t=>Ee({select:t?.select,structuralSharing:t?.structuralSharing,from:this.id}),this.useLoaderDeps=t=>Me({...t,from:this.id}),this.useLoaderData=t=>Te({...t,from:this.id}),this.useNavigate=()=>Ae({from:this.fullPath}),this.Link=O.forwardRef((t,r)=>i.jsx(Fe,{ref:r,from:this.fullPath,...t}))}};function nr(e){return new Lt(e)}function or(e){return new _t(e,{silent:!0}).createRoute}var _t=class{constructor(e,t){this.path=e,this.createRoute=r=>{const n=wt(r);return n.isRoot=!1,n},this.silent=t?.silent}};function sr(e,t){let r,n,a,o;const s=()=>(r||(r=e().then(h=>{r=void 0,n=h[t]}).catch(h=>{if(a=h,Ye(a)&&a instanceof Error&&typeof window<"u"&&typeof sessionStorage<"u"){const l=`tanstack_router_reload:${a.message}`;sessionStorage.getItem(l)||(sessionStorage.setItem(l,"1"),o=!0)}})),r),u=function(l){if(o)throw window.location.reload(),new Promise(()=>{});if(a)throw a;if(!n)if($)$(s());else throw s();return c.createElement(n,l)};return u.preload=s,u}function Tt(e){const t=S(),r=`not-found-${g(t.stores.location,n=>n.pathname)}-${g(t.stores.status,n=>n)}`;return i.jsx(ce,{getResetKey:()=>r,onCatch:(n,a)=>{if(J(n))e.onCatch?.(n,a);else throw n},errorComponent:({error:n})=>{if(J(n))return e.fallback?.(n);throw n},children:e.children})}function Mt(){return i.jsx("p",{children:"Not Found"})}function E(e){return i.jsx(i.Fragment,{children:e.children})}function De(e,t,r){return t.options.notFoundComponent?i.jsx(t.options.notFoundComponent,{...r}):e.options.defaultNotFoundComponent?i.jsx(e.options.defaultNotFoundComponent,{...r}):i.jsx(Mt,{})}function Et(){return Ze(S()),null}var Ne=c.memo(function({matchId:t}){const r=S(),n=r.stores.matchStores.get(t);n||k();const a=g(r.stores.loadedAt,s=>s),o=g(n,s=>s);return i.jsx(kt,{router:r,matchId:t,resetKey:a,matchState:c.useMemo(()=>{const s=o.routeId,u=r.routesById[s].parentRoute?.id;return{routeId:s,ssr:o.ssr,_displayPending:o._displayPending,parentRouteId:u}},[o._displayPending,o.routeId,o.ssr,r.routesById])})});function kt({router:e,matchId:t,resetKey:r,matchState:n}){const a=e.routesById[n.routeId],o=a.options.pendingComponent??e.options.defaultPendingComponent,s=o?i.jsx(o,{}):null,u=a.options.errorComponent??e.options.defaultErrorComponent,h=a.options.onCatch??e.options.defaultOnCatch,l=a.isRoot?a.options.notFoundComponent??e.options.notFoundRoute?.options.component:a.options.notFoundComponent,d=n.ssr===!1||n.ssr==="data-only",f=(!a.isRoot||a.options.wrapInSuspense||d)&&(a.options.wrapInSuspense??o??(a.options.errorComponent?.preload||d))?c.Suspense:E,y=u?ce:E,p=l?Tt:E;return i.jsxs(a.isRoot?a.options.shellComponent??E:E,{children:[i.jsx(G.Provider,{value:t,children:i.jsx(f,{fallback:s,children:i.jsx(y,{getResetKey:()=>r,errorComponent:u||ue,onCatch:(v,I)=>{if(J(v))throw v.routeId??=n.routeId,v;h?.(v,I)},children:i.jsx(p,{fallback:v=>{if(v.routeId??=n.routeId,!l||v.routeId&&v.routeId!==n.routeId||!v.routeId&&!a.isRoot)throw v;return c.createElement(l,v)},children:d||n._displayPending?i.jsx(ht,{fallback:s,children:i.jsx(je,{matchId:t})}):i.jsx(je,{matchId:t})})})})}),n.parentRouteId===ie?i.jsxs(i.Fragment,{children:[i.jsx(At,{resetKey:r}),e.options.scrollRestoration&&Xe?i.jsx(Et,{}):null]}):null]})}function At({resetKey:e}){const t=S(),r=c.useRef(void 0);return H(()=>{const n=t.latestLocation.href;(r.current===void 0||r.current!==n)&&(t.emit({type:"onRendered",...z(t.stores.location.get(),t.stores.resolvedLocation.get())}),r.current=n)},[t.latestLocation.state.__TSR_key,e,t]),null}var je=c.memo(function({matchId:t}){const r=S(),n=(d,f)=>r.getMatch(d.id)?._nonReactive[f]??d._nonReactive[f],a=r.stores.matchStores.get(t);a||k();const o=g(a,d=>d),s=o.routeId,u=r.routesById[s],h=c.useMemo(()=>{const d=(r.routesById[s].options.remountDeps??r.options.defaultRemountDeps)?.({routeId:s,loaderDeps:o.loaderDeps,params:o._strictParams,search:o._strictSearch});return d?JSON.stringify(d):void 0},[s,o.loaderDeps,o._strictParams,o._strictSearch,r.options.defaultRemountDeps,r.routesById]),l=c.useMemo(()=>{const d=u.options.component??r.options.defaultComponent;return d?i.jsx(d,{},h):i.jsx(Bt,{})},[h,u.options.component,r.options.defaultComponent]);if(o._displayPending)throw n(o,"displayPendingPromise");if(o._forcePending)throw n(o,"minPendingPromise");if(o.status==="pending"){const d=u.options.pendingMinMs??r.options.defaultPendingMinMs;if(d){const f=r.getMatch(o.id);if(f&&!f._nonReactive.minPendingPromise){const y=et();f._nonReactive.minPendingPromise=y,setTimeout(()=>{y.resolve(),f._nonReactive.minPendingPromise=void 0},d)}}throw n(o,"loadPromise")}if(o.status==="notFound")return J(o.error)||k(),De(r,u,o.error);if(o.status==="redirected")throw tt(o.error)||k(),n(o,"loadPromise");if(o.status==="error")throw o.error;return l}),Bt=c.memo(function(){const t=S(),r=c.useContext(G);let n,a=!1,o;{const l=r?t.stores.matchStores.get(r):void 0;[n,a]=g(l,d=>[d?.routeId,d?.globalNotFound??!1]),o=g(t.stores.matchesId,d=>d[d.findIndex(f=>f===r)+1])}const s=n?t.routesById[n]:void 0,u=t.options.defaultPendingComponent?i.jsx(t.options.defaultPendingComponent,{}):null;if(a)return s||k(),De(t,s,void 0);if(!o)return null;const h=i.jsx(Ne,{matchId:o});return n===ie?i.jsx(c.Suspense,{fallback:u,children:h}):h});function Ft(){const e=S(),t=c.useRef({router:e,mounted:!1}),[r,n]=c.useState(!1),a=g(e.stores.isLoading,f=>f),o=g(e.stores.hasPending,f=>f),s=se(a),u=a||r||o,h=se(u),l=a||o,d=se(l);return e.startTransition=f=>{n(!0),c.startTransition(()=>{f(),n(!1)})},c.useEffect(()=>{const f=e.history.subscribe(e.load),y=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return Ie(e.latestLocation.publicHref)!==Ie(y.publicHref)&&e.commitLocation({...y,replace:!0}),()=>{f()}},[e,e.history]),H(()=>{if(typeof window<"u"&&e.ssr||t.current.router===e&&t.current.mounted)return;t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(y){console.error(y)}})()},[e]),H(()=>{s&&!a&&e.emit({type:"onLoad",...z(e.stores.location.get(),e.stores.resolvedLocation.get())})},[s,e,a]),H(()=>{d&&!l&&e.emit({type:"onBeforeRouteMount",...z(e.stores.location.get(),e.stores.resolvedLocation.get())})},[l,d,e]),H(()=>{if(h&&!u){const f=z(e.stores.location.get(),e.stores.resolvedLocation.get());e.emit({type:"onResolved",...f}),Le(()=>{e.stores.status.set("idle"),e.stores.resolvedLocation.set(e.stores.location.get())}),f.hrefChanged&&rt(e)}},[u,h,e]),null}function Dt(){const e=S(),t=e.routesById[ie].options.pendingComponent??e.options.defaultPendingComponent,r=t?i.jsx(t,{}):null,n=i.jsxs(typeof document<"u"&&e.ssr?E:c.Suspense,{fallback:r,children:[i.jsx(Ft,{}),i.jsx(Nt,{})]});return e.options.InnerWrap?i.jsx(e.options.InnerWrap,{children:n}):n}function Nt(){const e=S(),t=g(e.stores.firstId,a=>a),r=g(e.stores.loadedAt,a=>a),n=t?i.jsx(Ne,{matchId:t}):null;return i.jsx(G.Provider,{value:t,children:e.options.disableGlobalCatchBoundary?n:i.jsx(ce,{getResetKey:()=>r,errorComponent:ue,onCatch:void 0,children:n})})}var Ht=e=>({createMutableStore:Pe,createReadonlyStore:Pe,batch:Le}),ar=e=>new Ot(e),Ot=class extends nt{constructor(e){super(e,Ht)}};function Wt({router:e,children:t,...r}){ot(r)&&e.update({...e.options,...r,context:{...e.options.context,...r.context}});const n=i.jsx(_e.Provider,{value:e,children:t});return e.options.Wrap?i.jsx(e.options.Wrap,{children:n}):n}function ir({router:e,...t}){return i.jsx(Wt,{router:e,...t,children:i.jsx(Dt,{})})}function cr(e){const t=S(),r=c.useRef(void 0);return g(t.stores.location,n=>{const a=n;if(t.options.defaultStructuralSharing){const o=we(r.current,a);return r.current=o,o}return a})}function He(e){const{attrs:t,children:r,nonce:n}=e;switch(e.tag){case"title":return i.jsx("title",{...t,suppressHydrationWarning:!0,children:r});case"meta":return i.jsx("meta",{...t,suppressHydrationWarning:!0});case"link":return i.jsx("link",{...t,precedence:t?.precedence??(t?.rel==="stylesheet"?"default":void 0),nonce:n,suppressHydrationWarning:!0});case"style":return e.inlineCss,i.jsx("style",{...t,dangerouslySetInnerHTML:{__html:r},nonce:n});case"script":return i.jsx(Kt,{attrs:t,children:r});default:return null}}function Kt({attrs:e,children:t}){S();const r=le(),n=typeof e?.type=="string"&&e.type!==""&&e.type!=="text/javascript"&&e.type!=="module";if(c.useEffect(()=>{if(!n){if(e?.src){const a=(()=>{try{const s=document.baseURI||window.location.href;return new URL(e.src,s).href}catch{return e.src}})();if(Array.from(document.querySelectorAll("script[src]")).find(s=>s.src===a))return;const o=document.createElement("script");for(const[s,u]of Object.entries(e))s!=="suppressHydrationWarning"&&u!==void 0&&u!==!1&&o.setAttribute(s,typeof u=="boolean"?"":String(u));return document.head.appendChild(o),()=>{o.parentNode&&o.parentNode.removeChild(o)}}if(typeof t=="string"){const a=typeof e?.type=="string"?e.type:"text/javascript",o=typeof e?.nonce=="string"?e.nonce:void 0;if(Array.from(document.querySelectorAll("script:not([src])")).find(u=>{if(!(u instanceof HTMLScriptElement))return!1;const h=u.getAttribute("type")??"text/javascript",l=u.getAttribute("nonce")??void 0;return u.textContent===t&&h===a&&l===o}))return;const s=document.createElement("script");if(s.textContent=t,e)for(const[u,h]of Object.entries(e))u!=="suppressHydrationWarning"&&h!==void 0&&h!==!1&&s.setAttribute(u,typeof h=="boolean"?"":String(h));return document.head.appendChild(s),()=>{s.parentNode&&s.parentNode.removeChild(s)}}}},[e,t,n]),n&&typeof t=="string")return i.jsx("script",{...e,suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:t}});if(!r){if(e?.src)return i.jsx("script",{...e,suppressHydrationWarning:!0});if(typeof t=="string")return i.jsx("script",{...e,dangerouslySetInnerHTML:{__html:t},suppressHydrationWarning:!0})}return null}var Ut=e=>{const t=S(),r=t.options.ssr?.nonce,n=g(t.stores.matches,l=>l.map(d=>d.meta).filter(Boolean),b),a=c.useMemo(()=>{const l=[],d={};let f;for(let y=n.length-1;y>=0;y--){const p=n[y];for(let v=p.length-1;v>=0;v--){const I=p[v];if(I)if(I.title)f||(f={tag:"title",children:I.title});else if("script:ld+json"in I)try{const P=JSON.stringify(I["script:ld+json"]);l.push({tag:"script",attrs:{type:"application/ld+json"},children:st(P)})}catch{}else{const P=I.name??I.property;if(P){if(d[P])continue;d[P]=!0}l.push({tag:"meta",attrs:{...I,nonce:r}})}}}return f&&l.push(f),r&&l.push({tag:"meta",attrs:{property:"csp-nonce",content:r}}),l.reverse(),l},[n,r]),o=g(t.stores.matches,l=>{const d=l.map(p=>p.links).filter(Boolean).flat(1).map(p=>({tag:"link",attrs:{...p,nonce:r}})),f=t.ssr?.manifest,y=l.map(p=>f?.routes[p.routeId]?.assets??[]).filter(Boolean).flat(1).flatMap(p=>p.tag==="link"?at(f,p)?[]:[{tag:"link",attrs:{...p.attrs,crossOrigin:be(e,"stylesheet")??p.attrs?.crossOrigin,suppressHydrationWarning:!0,nonce:r}}]:p.tag==="style"?[{tag:"style",attrs:{...p.attrs,nonce:r},children:p.children,...p.inlineCss?{inlineCss:!0}:{}}]:[]);return[...d,...y]},b),s=g(t.stores.matches,l=>{const d=[];return l.map(f=>t.looseRoutesById[f.routeId]).forEach(f=>t.ssr?.manifest?.routes[f.id]?.preloads?.filter(Boolean).forEach(y=>{const p=it(y);d.push({tag:"link",attrs:{rel:"modulepreload",href:p.href,crossOrigin:be(e,"modulepreload")??p.crossOrigin,nonce:r}})})),d},b),u=g(t.stores.matches,l=>l.map(d=>d.styles).flat(1).filter(Boolean).map(({children:d,...f})=>({tag:"style",attrs:{...f,nonce:r},children:d})),b),h=g(t.stores.matches,l=>l.map(d=>d.headScripts).flat(1).filter(Boolean).map(({children:d,...f})=>({tag:"script",attrs:{...f,nonce:r},children:d})),b);return qt([...a,...s,...o,...u,...h],l=>JSON.stringify(l))};function qt(e,t){const r=new Set;return e.filter(n=>{const a=t(n);return r.has(a)?!1:(r.add(a),!0)})}function ur(e){const t=Ut(e.assetCrossOrigin),r=S().options.ssr?.nonce;return i.jsx(i.Fragment,{children:t.map(n=>c.createElement(He,{...n,key:`tsr-meta-${JSON.stringify(n)}`,nonce:r}))})}var lr=()=>{const e=S(),t=e.options.ssr?.nonce,r=o=>{const s=[],u=e.ssr?.manifest;return u?(o.map(h=>e.looseRoutesById[h.routeId]).forEach(h=>u.routes[h.id]?.assets?.filter(l=>l.tag==="script").forEach(l=>{s.push({tag:"script",attrs:{...l.attrs,nonce:t},children:l.children})})),s):[]},n=o=>o.map(s=>s.scripts).flat(1).filter(Boolean).map(({children:s,...u})=>({tag:"script",attrs:{...u,suppressHydrationWarning:!0,nonce:t},children:s})),a=g(e.stores.matches,r,b);return zt(e,g(e.stores.matches,n,b),a)};function zt(e,t,r){let n;e.serverSsr&&(n=e.serverSsr.takeBufferedScripts());const a=[...t,...r];return n&&a.unshift(n),i.jsx(i.Fragment,{children:a.map((o,s)=>c.createElement(He,{...o,key:`tsr-scripts-${o.tag}-${s}`}))})}export{rr as A,ur as H,Fe as L,ir as R,lr as S,nr as a,ar as b,or as c,Ae as d,sr as l,cr as u};
@@ -0,0 +1 @@
1
+ import{am as e}from"./index-C0AK45FU.js";import"./base-ui-BvQbAt_1.js";import"./router-8uDKazL-.js";function n(){return e.jsxs("div",{className:"p-6",children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Settings"}),e.jsx("p",{className:"mt-2 text-muted-foreground",children:"Configure profiles, models, and preferences."})]})}export{n as component};
@@ -0,0 +1 @@
1
+ import{aw as j,am as e,D as m,aF as ae,ar as l,S as R,b as z,I as q,j as C,p as B,i as le,t as E,q as re,v as ie,g as K,f as O,n as ne}from"./index-C0AK45FU.js";import{S as oe,n as ce}from"./base-ui-BvQbAt_1.js";import{M as H}from"./MarkdownMessage-8d7Y6VL-.js";import"./router-8uDKazL-.js";async function de(){return j("/api/hermes/skills")}async function F(n){return(await j(`/api/hermes/skills/${n}`)).content}async function J(n,c){return(await j(`/api/hermes/skills/${n}/${c}/files`)).files}async function ue(n,c){await j("/api/hermes/skills/toggle",{method:"PUT",body:JSON.stringify({name:n,enabled:c})})}function me({className:n,size:c="default",...o}){return e.jsx(oe,{"data-slot":"switch","data-size":c,className:m("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",n),...o,children:e.jsx(ce,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"})})}function U({source:n}){const c=n==="builtin"?"bg-muted-foreground":n==="hub"?"bg-blue-400":"bg-emerald-400";return e.jsx("span",{className:m("size-2 rounded-full shrink-0",c)})}function ge(){const{state:n}=ae(),c=n==="collapsed",[o,L]=l.useState(null),[v,x]=l.useState(!0),[d,V]=l.useState(""),[u,W]=l.useState("all"),[I,G]=l.useState(new Set),[k,Q]=l.useState(!0),[r,b]=l.useState(null),[X,h]=l.useState(""),[$,N]=l.useState([]),[P,f]=l.useState(!1),[A,y]=l.useState(null),[Y,p]=l.useState(""),[,D]=l.useState(!1),w=l.useCallback(async()=>{try{const s=await de();L(s)}catch(s){console.error("Failed to load skills:",s)}},[]);l.useEffect(()=>{x(!0),w().finally(()=>x(!1))},[w]),l.useEffect(()=>{if(!r){h(""),N([]),y(null),p("");return}f(!0);const s=`${r.category}/${r.skill}/SKILL.md`;Promise.all([F(s),J(r.category,r.skill)]).then(([t,a])=>{h(t),N(a.filter(i=>!i.isDir))}).catch(t=>{h(`Failed to load skill: ${t.message}`)}).finally(()=>f(!1))},[r]);const M=l.useMemo(()=>{if(!o)return[];let s=o.categories;if(u!=="all"&&(s=s.map(t=>({...t,skills:t.skills.filter(a=>(a.source||"local")===u)})).filter(t=>t.skills.length>0)),d.trim()){const t=d.toLowerCase();s=s.map(a=>({...a,skills:a.skills.filter(i=>i.name.toLowerCase().includes(t)||i.description.toLowerCase().includes(t))})).filter(a=>a.skills.length>0||a.name.toLowerCase().includes(t))}return s},[o,u,d]),T=l.useMemo(()=>{if(!o)return[];let s=o.archived;if(u!=="all"&&(s=s.filter(t=>(t.source||"local")===u)),d.trim()){const t=d.toLowerCase();s=s.filter(a=>a.name.toLowerCase().includes(t)||a.description.toLowerCase().includes(t))}return s},[o,u,d]),Z=s=>{G(t=>{const a=new Set(t);return a.has(s)?a.delete(s):a.add(s),a})},_=async(s,t,a)=>{try{await ue(t,a),L(i=>i&&{...i,categories:i.categories.map(g=>g.name===s?{...g,skills:g.skills.map(S=>S.name===t?{...S,enabled:a}:S)}:g)})}catch(i){console.error("Toggle failed:",i)}},ee=async s=>{if(r){D(!0),y(s);try{const t=`${r.category}/${r.skill}/`,a=await F(`${t}${s}`);p(a)}catch(t){p(`Failed to load file: ${t.message}`)}finally{D(!1)}}},se=()=>{y(null),p("")},te=[{label:"All",value:"all"},{label:"Builtin",value:"builtin"},{label:"Hub",value:"hub"},{label:"Local",value:"local"}];return r?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-4 py-3 shrink-0 relative",children:[e.jsxs("div",{className:"flex items-center gap-2 z-10",children:[c&&e.jsx(R,{className:m("mr-1 -ml-1 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0")}),e.jsxs(z,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>b(null),children:[e.jsx(q,{className:"size-3.5 mr-1"}),"Back"]})]}),e.jsxs("div",{className:"absolute left-1/2 -translate-x-1/2 flex items-center gap-2 max-w-[50%]",children:[e.jsx("span",{className:"text-muted-foreground text-sm truncate",children:r.category}),e.jsx("span",{className:"text-muted-foreground shrink-0",children:"/"}),e.jsx("span",{className:"text-sm font-medium truncate",children:r.skill})]}),e.jsx("div",{className:"z-10",children:e.jsxs(z,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{f(!0);const s=`${r.category}/${r.skill}/SKILL.md`;Promise.all([F(s),J(r.category,r.skill)]).then(([t,a])=>{h(t),N(a.filter(i=>!i.isDir))}).finally(()=>f(!1))},disabled:P,children:[P?e.jsx(C,{className:"size-3 animate-spin"}):e.jsx(B,{className:"size-3"}),"Refresh"]})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.jsx("div",{className:"max-w-3xl mx-auto flex flex-col gap-4",children:A?e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:se,className:"inline-flex items-center gap-1.5 text-xs text-primary hover:underline w-fit",children:[e.jsx(q,{className:"size-3"}),"Back to ",r.skill]}),e.jsx("div",{className:"text-sm text-muted-foreground mb-1",children:A}),e.jsx(H,{content:Y})]}):e.jsxs(e.Fragment,{children:[e.jsx(H,{content:X}),$.length>0&&e.jsxs("div",{className:"border-t pt-4 mt-2",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:"Attached Files"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:$.map(s=>e.jsxs("button",{onClick:()=>ee(s.path),className:"inline-flex items-center gap-1.5 rounded-md border bg-muted/50 px-2.5 py-1.5 text-xs text-foreground hover:bg-muted transition-colors",children:[e.jsx(le,{className:"size-3.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:s.path})]},s.path))})]})]})})})]}):e.jsxs("div",{className:"flex h-full",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col h-full shrink-0",children:[e.jsxs("header",{className:"flex items-center gap-2 border-b px-3 py-3 shrink-0",children:[c&&e.jsx(R,{className:m("mr-1 -ml-1 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors shrink-0")}),e.jsx(E,{className:"size-5 text-muted-foreground"}),e.jsx("h2",{className:"text-sm font-medium",children:"Skills"}),e.jsx(z,{variant:"ghost",size:"sm",className:"ml-auto h-7 px-2 text-xs text-muted-foreground hover:text-foreground",onClick:()=>{x(!0),w().finally(()=>x(!1))},disabled:v,children:v?e.jsx(C,{className:"size-3 animate-spin"}):e.jsx(B,{className:"size-3"})})]}),e.jsxs("div",{className:"px-3 py-2 border-b flex flex-col gap-2 shrink-0",children:[e.jsxs("div",{className:"relative",children:[e.jsx(re,{className:"absolute left-2 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground"}),e.jsx(ie,{value:d,onChange:s=>V(s.target.value),placeholder:"Search skills...",className:"h-8 pl-7 text-xs"})]}),e.jsx("div",{className:"flex items-center gap-1",children:te.map(s=>e.jsx("button",{onClick:()=>W(s.value),className:m("px-2 py-0.5 text-[11px] rounded-sm transition-colors",u===s.value?"bg-primary text-primary-foreground font-medium":"text-muted-foreground hover:text-foreground hover:bg-muted"),children:s.label},s.value))})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:v?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(C,{className:"size-4 animate-spin text-muted-foreground"})}):!o||M.length===0?e.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:d?"No skills match your search.":"No skills found."}):e.jsxs("div",{className:"flex flex-col gap-1",children:[M.map(s=>e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("button",{onClick:()=>Z(s.name),className:"flex items-center gap-1.5 px-2 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider rounded-md hover:bg-muted/50 transition-colors",children:[I.has(s.name)?e.jsx(K,{className:"size-3 shrink-0"}):e.jsx(O,{className:"size-3 shrink-0"}),e.jsx("span",{className:"truncate",children:s.name}),e.jsx("span",{className:"ml-auto text-[10px] bg-muted px-1.5 py-0.5 rounded-full",children:s.skills.length})]}),!I.has(s.name)&&e.jsx("div",{className:"flex flex-col",children:s.skills.map(t=>e.jsxs("div",{className:"group flex items-center gap-2 px-2 py-1.5 pl-7 rounded-md hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>b({category:s.name,skill:t.name}),children:[e.jsx(U,{source:t.source}),e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs font-medium truncate",children:t.name}),t.modified&&e.jsx("span",{className:"text-[10px] text-amber-500",title:"Modified",children:"✎"}),t.pinned&&e.jsx(ne,{className:"size-3 text-amber-500 shrink-0"})]}),t.description&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate",children:t.description})]}),e.jsx(me,{checked:t.enabled!==!1,onCheckedChange:a=>_(s.name,t.name,a),className:"scale-75 shrink-0",onClick:a=>a.stopPropagation()})]},t.name))})]},s.name)),(T.length>0||(o?.archived.length??0)>0)&&e.jsxs("div",{className:"flex flex-col mt-2 pt-2 border-t",children:[e.jsxs("button",{onClick:()=>Q(!k),className:"flex items-center gap-1.5 px-2 py-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wider rounded-md hover:bg-muted/50 transition-colors",children:[k?e.jsx(K,{className:"size-3 shrink-0"}):e.jsx(O,{className:"size-3 shrink-0"}),e.jsx("span",{children:"Archived"}),e.jsx("span",{className:"ml-auto text-[10px] bg-muted px-1.5 py-0.5 rounded-full",children:o?.archived.length??0})]}),!k&&T.map(s=>e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 pl-7 rounded-md hover:bg-muted/50 cursor-pointer transition-colors opacity-60",onClick:()=>b({category:".archive",skill:s.name}),children:[e.jsx(U,{source:s.source}),e.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[e.jsx("span",{className:"text-xs font-medium truncate",children:s.name}),s.description&&e.jsx("span",{className:"text-[10px] text-muted-foreground truncate",children:s.description})]})]},s.name))]})]})})]}),e.jsx("div",{className:"flex-1 flex flex-col items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-muted-foreground",children:[e.jsx(E,{className:"size-12 opacity-20"}),e.jsx("p",{className:"text-sm",children:"Select a skill to view its details"})]})})]})}export{ge as component};
@@ -0,0 +1 @@
1
+ const o="hermium-theme";function n(){try{const e=localStorage.getItem(o);if(e==="dark"||e==="light"||e==="system")return e}catch{}return"system"}function c(e){localStorage.setItem(o,e)}function s(e){return e==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e}function a(e){const r=s(e),t=document.documentElement;r==="dark"?t.classList.add("dark"):t.classList.remove("dark")}function m(){const e=n(),t=s(e)==="dark"?"light":"dark";return c(t),a(t),t}export{a as applyTheme,n as getStoredTheme,s as resolveTheme,c as storeTheme,m as toggleTheme};
@@ -0,0 +1 @@
1
+ import{aw as f,am as e,ar as o}from"./index-C0AK45FU.js";import"./base-ui-BvQbAt_1.js";import"./router-8uDKazL-.js";async function g(t=30){const a=new URLSearchParams({days:String(t)});return f(`/api/hermes/usage/stats?${a}`)}const x=["#4fd1c5","#63b3ed","#f6ad55","#b794f4","#68d391","#fc8181","#f687b3","#90cdf4","#fbd38d","#9ae6b4"];function m(t){return(t||"").trim()||"unknown"}function j(t){const a=m(t);let n=0;for(let s=0;s<a.length;s++)n=(n<<5)-n+a.charCodeAt(s),n|=0;return x[Math.abs(n)%x.length]}function l(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":String(t)}function u(t){return t===0?"$0.00":t<.01?"<$0.01":"$"+t.toFixed(2)}function c(t,a){return a<=0?0:t/a*100}function h(t,a){const n=t+a;return n===0?"--":(a/n*100).toFixed(1)+"%"}function b(t=30){const[a,n]=o.useState(null),[s,r]=o.useState(!1);return o.useEffect(()=>{r(!0),g(t).then(n).catch(console.error).finally(()=>r(!1))},[t]),{stats:a,loading:s}}function d({label:t,value:a,sub:n}){return e.jsxs("div",{className:"rounded-lg border bg-card p-4",children:[e.jsx("div",{className:"text-xs text-muted-foreground mb-1",children:t}),e.jsx("div",{className:"text-xl font-semibold",children:a}),n&&e.jsx("div",{className:"text-[11px] text-muted-foreground mt-1",children:n})]})}function N({stats:t}){const a=t.total_input_tokens+t.total_output_tokens,n=t.total_cache_read_tokens,s=a+n>0?(n/(t.total_input_tokens+n)*100).toFixed(1)+"%":"--",r=t.daily_usage.filter(p=>p.sessions>0).length,i=r>0?(t.total_sessions/r).toFixed(1):"0.0";return e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-5",children:[e.jsx(d,{label:"Total Tokens",value:l(a),sub:`${l(t.total_input_tokens)} input / ${l(t.total_output_tokens)} output`}),e.jsx(d,{label:"Total Sessions",value:String(t.total_sessions),sub:`${i} avg/day`}),e.jsx(d,{label:"Estimated Cost",value:u(t.total_cost??0)}),e.jsx(d,{label:"Cache Hit Rate",value:s,sub:n>0?`${l(n)} tokens`:void 0})]})}function k({stats:t}){const a=o.useMemo(()=>(t.daily_usage??[]).map(s=>{const r=s.input_tokens+s.output_tokens+s.cache_read_tokens;return{...s,visualTokens:r,inputPercent:c(s.input_tokens,r),outputPercent:c(s.output_tokens,r),cachePercent:c(s.cache_read_tokens,r)}}),[t]),n=o.useMemo(()=>Math.max(...a.map(s=>s.visualTokens),1),[a]);return a.length===0?null:e.jsxs("div",{className:"rounded-lg border bg-card p-4 mb-5",children:[e.jsx("h3",{className:"text-sm font-semibold text-secondary-foreground mb-3",children:"Daily Trend"}),e.jsx("div",{className:"flex gap-0.5 mb-2",children:a.map(s=>e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col items-center relative group",children:[e.jsx("div",{className:"w-full h-36 bg-muted/40 rounded-t-sm flex items-end overflow-hidden",children:e.jsxs("div",{className:"w-full flex flex-col-reverse justify-start transition-all",style:{height:`${s.visualTokens/n*100}%`},children:[s.output_tokens>0&&e.jsx("div",{className:"w-full bg-emerald-500/80",style:{height:`${s.outputPercent}%`}}),s.input_tokens>0&&e.jsx("div",{className:"w-full bg-indigo-500/80",style:{height:`${s.inputPercent}%`}}),s.cache_read_tokens>0&&e.jsx("div",{className:"w-full bg-amber-400/80",style:{height:`${s.cachePercent}%`}})]})}),e.jsxs("div",{className:"hidden group-hover:block absolute bottom-[calc(100%+8px)] left-1/2 -translate-x-1/2 bg-popover text-popover-foreground text-[11px] whitespace-nowrap z-10 rounded-md border px-2 py-1.5 shadow-md",children:[e.jsx("div",{className:"font-semibold mb-0.5",children:s.date}),e.jsxs("div",{children:["Input: ",l(s.input_tokens)]}),e.jsxs("div",{children:["Output: ",l(s.output_tokens)]}),e.jsxs("div",{children:["Cache read: ",l(s.cache_read_tokens)]}),e.jsxs("div",{children:["Cache write: ",l(s.cache_write_tokens)]}),e.jsxs("div",{children:["Hit rate: ",h(s.input_tokens,s.cache_read_tokens)]}),e.jsxs("div",{children:["Sessions: ",s.sessions]}),e.jsxs("div",{children:["Cost: ",u(s.cost??0)]})]})]},s.date))}),e.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground mb-3",children:[e.jsx("span",{children:a[0]?.date.slice(5)}),e.jsx("span",{children:a[a.length-1]?.date.slice(5)})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-muted-foreground mb-4",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm bg-indigo-500/80"})," Input"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm bg-emerald-500/80"})," Output"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm bg-amber-400/80"})," Cache read"]})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-[11px] border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-muted-foreground text-left",children:[e.jsx("th",{className:"pb-1.5 pr-2 font-medium",children:"Date"}),e.jsx("th",{className:"pb-1.5 pr-2 font-medium text-right",children:"Input"}),e.jsx("th",{className:"pb-1.5 pr-2 font-medium text-right",children:"Output"}),e.jsx("th",{className:"pb-1.5 pr-2 font-medium text-right",children:"Cache read"}),e.jsx("th",{className:"pb-1.5 pr-2 font-medium text-right",children:"Cache write"}),e.jsx("th",{className:"pb-1.5 pr-2 font-medium text-right",children:"Hit rate"}),e.jsx("th",{className:"pb-1.5 pr-2 font-medium text-right",children:"Sessions"}),e.jsx("th",{className:"pb-1.5 pr-2 font-medium text-right",children:"Cost"})]})}),e.jsx("tbody",{children:[...a].reverse().map(s=>e.jsxs("tr",{className:"border-t",children:[e.jsx("td",{className:"py-1.5 pr-2",children:s.date}),e.jsx("td",{className:"py-1.5 pr-2 text-right",children:l(s.input_tokens)}),e.jsx("td",{className:"py-1.5 pr-2 text-right",children:l(s.output_tokens)}),e.jsx("td",{className:"py-1.5 pr-2 text-right",children:l(s.cache_read_tokens)}),e.jsx("td",{className:"py-1.5 pr-2 text-right",children:l(s.cache_write_tokens)}),e.jsx("td",{className:"py-1.5 pr-2 text-right",children:h(s.input_tokens,s.cache_read_tokens)}),e.jsx("td",{className:"py-1.5 pr-2 text-right",children:s.sessions}),e.jsx("td",{className:"py-1.5 pr-2 text-right",children:u(s.cost??0)})]},s.date))})]})})]})}function v({stats:t}){const a=o.useMemo(()=>(t.model_usage??[]).map(s=>{const r=s.input_tokens+s.output_tokens,i=r+s.cache_read_tokens;return{model:m(s.model),inputTokens:s.input_tokens,outputTokens:s.output_tokens,cacheTokens:s.cache_read_tokens,cacheWriteTokens:s.cache_write_tokens,totalTokens:r,visualTokens:i,sessions:s.sessions,color:j(s.model),inputPercent:c(s.input_tokens,i),outputPercent:c(s.output_tokens,i),cachePercent:c(s.cache_read_tokens,i)}}).sort((s,r)=>r.visualTokens-s.visualTokens),[t]),n=o.useMemo(()=>Math.max(...a.map(s=>s.visualTokens),1),[a]);return a.length===0?null:e.jsxs("div",{className:"rounded-lg border bg-card p-4 mb-5",children:[e.jsx("h3",{className:"text-sm font-semibold text-secondary-foreground mb-3",children:"Model Breakdown"}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-[11px] text-muted-foreground mb-3",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm bg-indigo-500/80"})," Input"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm bg-emerald-500/80"})," Output"]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm bg-amber-400/80"})," Cache read"]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:a.map(s=>e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:s.color}}),e.jsx("span",{className:"text-xs font-mono text-secondary-foreground w-32 shrink-0 truncate",title:s.model,children:s.model}),e.jsx("div",{className:"flex-1 h-4 bg-muted/40 rounded-sm overflow-hidden",children:e.jsxs("div",{className:"h-full flex min-w-[2px] transition-all",style:{width:`${s.visualTokens/n*100}%`},children:[s.inputTokens>0&&e.jsx("div",{className:"h-full bg-indigo-500/80",style:{width:`${s.inputPercent}%`}}),s.outputTokens>0&&e.jsx("div",{className:"h-full bg-emerald-500/80",style:{width:`${s.outputPercent}%`}}),s.cacheTokens>0&&e.jsx("div",{className:"h-full bg-amber-400/80",style:{width:`${s.cachePercent}%`}})]})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-20 text-right shrink-0",children:[l(s.totalTokens),s.cacheTokens>0&&e.jsxs("span",{className:"text-[10px] text-amber-500 ml-1",children:["+",l(s.cacheTokens)]})]})]},s.model))})]})}function T(){const{stats:t,loading:a}=b(30);return e.jsx("div",{className:"flex-1 overflow-y-auto p-4 md:p-6",children:e.jsxs("div",{className:"mx-auto max-w-5xl",children:[e.jsxs("header",{className:"mb-5",children:[e.jsx("h1",{className:"text-lg font-semibold",children:"Usage"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Token consumption and cost estimates over the last 30 days."})]}),a&&e.jsx("div",{className:"text-sm text-muted-foreground py-8",children:"Loading usage stats…"}),!a&&!t&&e.jsx("div",{className:"text-sm text-muted-foreground py-8",children:"Failed to load usage data."}),!a&&t&&t.total_sessions===0&&e.jsx("div",{className:"text-sm text-muted-foreground py-8",children:"No usage data yet."}),!a&&t&&t.total_sessions>0&&e.jsxs(e.Fragment,{children:[e.jsx(N,{stats:t}),e.jsx(v,{stats:t}),e.jsx(k,{stats:t})]})]})})}export{T as component};
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hermium",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "Hermium CLI — self-hosted AI chat dashboard for Hermes Agent",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- import{c as e}from"./index-DkYGodJj.js";const t=[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0",key:"svg-0"}],["path",{d:"M12 8v4",key:"svg-1"}],["path",{d:"M12 16h.01",key:"svg-2"}]],o=e("outline","alert-circle","AlertCircle",t);export{o as I};
@@ -1 +0,0 @@
1
- import{c as e}from"./index-DkYGodJj.js";const t=[["path",{d:"M12 9v4",key:"svg-0"}],["path",{d:"M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87l-8.106 -13.536a1.914 1.914 0 0 0 -3.274 0",key:"svg-1"}],["path",{d:"M12 16h.01",key:"svg-2"}]],o=e("outline","alert-triangle","AlertTriangle",t);export{o as I};
@@ -1 +0,0 @@
1
- import{c}from"./index-DkYGodJj.js";const e=[["path",{d:"M5 12l5 5l10 -10",key:"svg-0"}]],t=c("outline","check","Check",e);export{t as I};
@@ -1 +0,0 @@
1
- import{c as o}from"./index-DkYGodJj.js";const e=[["path",{d:"M12 3a9 9 0 1 0 9 9",key:"svg-0"}]],t=o("outline","loader-2","Loader2",e);export{t as I};
@@ -1 +0,0 @@
1
- import{c as e}from"./index-DkYGodJj.js";const o=[["path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4",key:"svg-0"}],["path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4",key:"svg-1"}]],s=e("outline","refresh","Refresh",o);export{s as I};
@@ -1,14 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/syntax-highlighter-DWPF-A_h.js","assets/index-DkYGodJj.js","assets/index-CrQs9n6q.js"])))=>i.map(i=>d[i]);
2
- import{c as z,V as Ee,r as l,j as e,d as _,m as fe,a as Le,B as I,D as he,e as ge,f as xe,g as K,u as be,v as w,E as te,W as $e,I as Te,X as Ie,Y as Oe,l as ve,Z as ye,_ as Pe,b as se,$ as Ue,a0 as He}from"./index-DkYGodJj.js";import{T as Fe,I as We,a as Be,b as G}from"./textarea-Di_syYTS.js";import{u as Je,a as Ke,b as Ve,I as Ge}from"./queries-iHRgZzw2.js";import{I as F}from"./IconLoader2-BIx3OuF9.js";import{M as qe,r as Xe}from"./index-CrQs9n6q.js";import{I as B}from"./IconCheck-CFuEh_p7.js";import{I as Qe}from"./IconAlertTriangle-wCJudlVg.js";const Ye=[["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"}]],Ze=z("outline","bell","Bell",Ye);const et=[["path",{d:"M4 19l16 0",key:"svg-0"}],["path",{d:"M4 15l4 -6l4 2l4 -5l4 4",key:"svg-1"}]],tt=z("outline","chart-line","ChartLine",et);const st=[["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"}]],nt=z("outline","command","Command",st);const rt=[["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"}]],at=z("outline","file","File",rt);const ot=[["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"}]],it=z("outline","mail","Mail",ot);const lt=[["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"}]],ct=z("outline","paperclip","Paperclip",lt);const dt=[["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"}]],ut=z("outline","photo","Photo",dt);const mt=[["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"}]],pt=z("outline","player-stop","PlayerStop",mt);const ft=[["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"}]],ne=z("outline","shield-check","ShieldCheck",ft),re=t=>Symbol.iterator in t,ae=t=>"entries"in t,oe=(t,s)=>{const n=t instanceof Map?t:new Map(t.entries()),a=s instanceof Map?s:new Map(s.entries());if(n.size!==a.size)return!1;for(const[o,i]of n)if(!a.has(o)||!Object.is(i,a.get(o)))return!1;return!0},ht=(t,s)=>{const n=t[Symbol.iterator](),a=s[Symbol.iterator]();let o=n.next(),i=a.next();for(;!o.done&&!i.done;){if(!Object.is(o.value,i.value))return!1;o=n.next(),i=a.next()}return!!o.done&&!!i.done};function gt(t,s){return Object.is(t,s)?!0:typeof t!="object"||t===null||typeof s!="object"||s===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(s)?!1:re(t)&&re(s)?ae(t)&&ae(s)?oe(t,s):ht(t,s):oe({entries:()=>Object.entries(t)},{entries:()=>Object.entries(s)})}function ie(t){const s=Ee.useRef(void 0);return n=>{const a=t(n);return gt(s.current,a)?s.current:s.current=a}}function xt(t){return t.nativeEvent?.isComposing===!0}const q=[{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 bt(t){if(!t.startsWith("/"))return!1;const s=t.split(/\s+/)[0].toLowerCase();return q.some(n=>n.name===s&&n.local)}function vt({currentInput:t,applyText:s}){const[n,a]=l.useState([]),o=l.useRef(-1),i=l.useRef(""),c=l.useCallback(y=>{a(j=>[...j,y]),o.current=-1,i.current=""},[]),x=l.useCallback(()=>{if(n.length===0)return!1;const y=o.current,j=y===-1?n.length-1:Math.max(0,y-1);return y===-1&&(i.current=t),o.current=j,s(n[j]),!0},[n,t,s]),d=l.useCallback(()=>{const y=o.current;return y===-1?!1:(y<n.length-1?(o.current=y+1,s(n[y+1])):(o.current=-1,s(i.current)),!0)},[n,s]),v=l.useCallback(()=>o.current!==-1,[]),C=l.useCallback(()=>n.length,[n.length]);return{push:c,recallPrev:x,recallNext:d,isNavigating:v,size:C}}function yt(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function wt({attachment:t,onRemove:s}){const n=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:[n&&t.previewUrl?e.jsx("img",{src:t.previewUrl,alt:t.name,className:"h-10 w-10 rounded object-cover"}):n?e.jsx(ut,{className:"size-5 text-muted-foreground"}):e.jsx(at,{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:yt(t.size)})]}),e.jsx("button",{onClick:a=>{a.stopPropagation(),s()},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(fe,{className:"size-2.5"})})]})}function jt({attachments:t,onRemove:s,compact:n=!1}){return t.length===0?null:e.jsx("div",{className:_("flex gap-2 overflow-x-auto","px-3 pt-3"),children:t.map(a=>e.jsx(wt,{attachment:a,onRemove:()=>s(a.id)},a.id))})}function le(t){return t.name&&t.name!==t.id?t.name:(t.id.split("/").pop()||t.id).split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(" ")}function Nt(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}const St=l.forwardRef(function({sessionId:s,model:n,isLoading:a,onSubmit:o,onAbort:i},c){const[x,d]=l.useState(""),[v,C]=l.useState(!1),[y,j]=l.useState(!1),[S,M]=l.useState(""),[g,u]=l.useState(0),[m,p]=l.useState([]),[f,b]=l.useState(!1),h=l.useRef(null),R=l.useRef(null),D=l.useRef(null),{data:E,isLoading:A}=Je(),L=E?.models??[],[$,J]=l.useState("");l.useEffect(()=>{if(!L.length)return;const r=n&&L.some(k=>k.id===n),N=$&&L.some(k=>k.id===$);if(r){$!==n&&J(n);return}if(!N){const k=E?.default_model||L[0]?.id;k&&J(k)}},[L,E?.default_model,n]);const X=L.find(r=>r.id===$),we=l.useCallback(async r=>{J(r);try{await Le({model:r,session_id:s})}catch{}},[s]),U=l.useCallback(()=>{const r=h.current;r&&(r.style.height="auto",r.style.height=`${Math.min(r.scrollHeight,200)}px`)},[]),je=l.useCallback(r=>{d(r),requestAnimationFrame(()=>{U(),h.current?.setSelectionRange(r.length,r.length)})},[U]),O=vt({currentInput:x,applyText:je});l.useImperativeHandle(c,()=>({setText(r){d(r),requestAnimationFrame(()=>{U(),h.current?.focus()})},clear(){d(""),h.current&&(h.current.style.height="auto")},focus(){h.current?.focus()}}),[U]),l.useEffect(()=>{a||h.current?.focus()},[a]),l.useEffect(()=>{if(!y)return;function r(N){R.current&&!R.current.contains(N.target)&&j(!1)}return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[y]),l.useEffect(()=>{if(!y)return;R.current?.querySelector(".slash-item-active")?.scrollIntoView({block:"nearest"})},[g,y]);const P=l.useMemo(()=>y?q.filter(r=>r.name.toLowerCase().startsWith(S.toLowerCase())):[],[y,S]),H=l.useCallback(r=>{const N=Array.from(r).map(k=>({id:Nt(),name:k.name,type:k.type||"application/octet-stream",size:k.size,file:k,previewUrl:k.type.startsWith("image/")?URL.createObjectURL(k):void 0}));p(k=>[...k,...N])},[]),Ne=l.useCallback(r=>{p(N=>{const k=N.find(T=>T.id===r);return k?.previewUrl&&URL.revokeObjectURL(k.previewUrl),N.filter(T=>T.id!==r)})},[]);l.useEffect(()=>()=>{m.forEach(r=>{r.previewUrl&&URL.revokeObjectURL(r.previewUrl)})},[]);const Se=l.useCallback(r=>{r.preventDefault(),r.stopPropagation(),b(!0)},[]),ke=l.useCallback(r=>{r.preventDefault(),r.stopPropagation(),(r.currentTarget===r.target||!r.currentTarget.contains(r.relatedTarget))&&b(!1)},[]),Ce=l.useCallback(r=>{r.preventDefault(),r.stopPropagation(),b(!1),r.dataTransfer.files.length>0&&H(r.dataTransfer.files)},[H]),Re=l.useCallback(r=>{const N=r.clipboardData?.items;if(!N)return;const k=[];for(let T=0;T<N.length;T++){const W=N[T];if(W.type.startsWith("image/")){const ee=W.getAsFile();if(ee){const Ae=W.type.split("/")[1]||"png",ze=new File([ee],`pasted-image-${Date.now()}.${Ae}`,{type:W.type});k.push(ze)}}}k.length>0&&(r.preventDefault(),H(k))},[H]);function _e(r){O.push(r),d(""),h.current&&(h.current.style.height="auto")}function Q(){const r=x.trim();!r||a||(j(!1),_e(r),o(r,$,m),p([]))}function Y(r){if(j(!1),r.local||r.category==="info"){d(""),h.current&&(h.current.style.height="auto"),o(r.name,$);return}d(r.name+" "),h.current?.focus()}function Me(r){const N=r.target.value;d(N),U(),N.startsWith("/")&&!N.includes(" ")?(j(!0),M(N),u(0)):y&&j(!1)}function De(r){if(!xt(r)){if(y&&P.length>0){if(r.key==="ArrowDown"){r.preventDefault(),u(N=>N<P.length-1?N+1:0);return}if(r.key==="ArrowUp"){r.preventDefault(),u(N=>N>0?N-1:P.length-1);return}if(r.key==="Enter"||r.key==="Tab"){r.preventDefault(),Y(P[g]);return}if(r.key==="Escape"){r.preventDefault(),j(!1);return}}if(!y&&(O.isNavigating()||!x.includes(`
3
- `))){if(r.key==="ArrowUp"&&O.size()>0&&O.recallPrev()){r.preventDefault();return}if(r.key==="ArrowDown"&&O.isNavigating()&&O.recallNext()){r.preventDefault();return}}r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),Q())}}const Z=x.trim().length>0;return e.jsxs("div",{className:"w-full max-w-3xl mx-auto flex flex-col gap-2 relative",children:[y&&P.length>0&&e.jsxs("div",{ref:R,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(nt,{className:"size-3"}),"Commands"]}),e.jsx("div",{className:"max-h-[240px] overflow-y-auto py-1",children:P.map((r,N)=>e.jsxs("button",{className:_("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",N===g?"bg-accent text-accent-foreground slash-item-active":"hover:bg-accent/50"),onMouseEnter:()=>u(N),onClick:()=>Y(r),children:[e.jsx("span",{className:"font-mono text-xs text-primary",children:r.name}),e.jsx("span",{className:"text-muted-foreground text-xs",children:r.description})]},r.name))})]}),e.jsxs("div",{className:_("flex min-h-[80px] flex-col rounded-2xl cursor-text bg-card border shadow-lg transition-colors",f?"border-primary border-dashed":"border-border"),onDragOver:Se,onDragLeave:ke,onDrop:Ce,children:[e.jsx(jt,{attachments:m,onRemove:Ne,compact:!0}),e.jsx("div",{className:"flex-1 relative overflow-y-auto max-h-[200px]",children:e.jsx(Fe,{ref:h,value:x,onChange:Me,onKeyDown:De,onPaste:Re,onCompositionStart:()=>C(!0),onCompositionEnd:()=>C(!1),placeholder:"Ask anything…",rows:1,className:_("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(I,{variant:"ghost",size:"icon-sm",className:"text-muted-foreground hover:text-foreground transition-colors",title:"Attach images",onClick:()=>D.current?.click(),children:e.jsx(ct,{className:"h-5 w-5"})}),e.jsxs(he,{children:[e.jsxs(ge,{className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors cursor-pointer outline-none ml-1",children:[e.jsx(Ke,{className:"h-4 w-4 shrink-0"}),A&&e.jsx(F,{className:"h-3.5 w-3.5 animate-spin shrink-0"}),e.jsx("span",{className:_(A&&"opacity-60"),children:A?"Loading…":X?le(X):"Select model"})]}),e.jsx(xe,{align:"start",className:"max-h-[300px] overflow-y-auto min-w-48",children:L.map(r=>e.jsxs(K,{onClick:()=>we(r.id),className:_("flex-col items-start py-2",r.id===$&&"bg-muted"),children:[e.jsx("span",{className:"text-sm",children:le(r)}),e.jsx("span",{className:"text-muted-foreground text-xs",children:r.provider_name})]},r.id))})]}),e.jsx("div",{className:"ml-auto flex items-center gap-2",children:a?e.jsx(I,{variant:"ghost",size:"icon-sm",className:"rounded-full bg-destructive hover:bg-destructive/90 text-destructive-foreground transition-colors cursor-pointer",onClick:i,title:"Stop generating",children:e.jsx(pt,{className:"h-4 w-4"})}):e.jsx(I,{variant:"ghost",size:"icon-sm",className:_("rounded-full transition-colors cursor-pointer",Z?"bg-primary hover:bg-primary/90 text-primary-foreground":"bg-primary text-primary-foreground opacity-40"),disabled:!Z,onClick:Q,title:"Send message",children:e.jsx(Ve,{className:"h-4 w-4"})})})]})]}),e.jsx("input",{ref:D,type:"file",multiple:!0,accept:"image/*",className:"hidden",onChange:r=>{r.target.files?.length&&(H(r.target.files),r.target.value="")}})]})}),kt=l.memo(function({sessionId:s,title:n,hasMessages:a,onNewChat:o,onClear:i}){const c=be(),x=w(v=>v.deleteSession),d=async()=>{try{await Oe(s),x(s),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:n||"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:o,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(We,{className:"size-3.5"})}),a&&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(te,{className:"size-3.5"})}),e.jsxs(he,{children:[e.jsx(ge,{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($e,{className:"size-3.5"})})}),e.jsxs(xe,{align:"end",side:"bottom",sideOffset:4,children:[e.jsxs(K,{className:"gap-2 text-xs",onClick:()=>{const v=prompt("Rename conversation",n||"");v?.trim()&&(Ie(s,v.trim()),w.getState().updateSession(s,{title:v.trim()}))},children:[e.jsx(Te,{className:"size-3"}),"Rename"]}),e.jsxs(K,{className:"gap-2 text-xs text-destructive",onClick:d,children:[e.jsx(te,{className:"size-3"}),"Delete"]})]})]})]})]})}),Ct=[{label:"Search the web",text:"Search the web for today's top tech news",Icon:ve},{label:"Set a reminder",text:"Set a reminder to check emails every day at 9 AM",Icon:Ze},{label:"Read emails",text:"Read my latest emails and summarize them",Icon:it},{label:"Write a script",text:"Write a Python script to rename all files in a folder",Icon:Ge},{label:"Schedule a job",text:"Schedule a cron job to back up my database every night",Icon:Be},{label:"Analyze data",text:"Analyze this CSV file and show key insights",Icon:tt}],Rt=l.memo(function({onSelectSuggestion:s}){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(ve,{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:Ct.map(({text:n,label:a,Icon:o})=>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:()=>s(n),children:[e.jsx(o,{className:"w-4 h-4 shrink-0 text-muted-foreground group-hover:text-foreground transition-colors"}),e.jsx("span",{className:"truncate",children:a})]},n))})]})}),_t=l.lazy(()=>Pe(()=>import("./syntax-highlighter-DWPF-A_h.js"),__vite__mapDeps([0,1,2])).then(t=>({default:t.SyncHighlighter})));function V({text:t}){const[s,n]=l.useState(!1),a=async()=>{await navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),2e3)};return e.jsx("button",{onClick:a,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:s?e.jsx(B,{className:"size-3"}):e.jsx(ye,{className:"size-3"})})}function Mt({text:t}){const[s,n]=l.useState(!1),a=async()=>{await navigator.clipboard.writeText(t),n(!0),setTimeout(()=>n(!1),2e3)};return e.jsxs("button",{onClick:a,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:[s?e.jsx(B,{className:"size-3"}):e.jsx(ye,{className:"size-3"}),s?"Copied":"Copy"]})}function Dt(t){const s=Math.floor(t/1e3);if(s<60)return`${s}s`;const n=Math.floor(s/60),a=s%60;return a===0?`${n}m`:`${n}m ${a}s`}function ce({reasoning:t,isStreaming:s,startedAt:n,endedAt:a}){const[o,i]=l.useState(s??!1);l.useEffect(()=>{i(s??!1)},[s]);const[c,x]=l.useState(Date.now()),d=l.useRef(null);if(l.useEffect(()=>{if(s&&n&&!a)return d.current=setInterval(()=>x(Date.now()),1e3),()=>{d.current&&clearInterval(d.current)};d.current&&(clearInterval(d.current),d.current=null)},[s,n,a]),!t.trim())return null;const v=n?Math.max(0,(a??(s?c:n))-n):null,C=[...t].length,y=s&&n&&!a;return e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>i(!o),className:_("inline-flex items-center gap-1.5 text-[11px] transition-colors",y?"text-amber-500 dark:text-amber-400 font-medium":"text-muted-foreground/70 hover:text-foreground"),children:[e.jsx(G,{className:_("size-3 shrink-0 transition-transform",o&&"rotate-90")}),y?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(F,{className:"size-2.5 animate-spin"}),"thinking…"]}):e.jsx("span",{children:"thought"}),v!==null&&v>0&&e.jsxs("span",{className:"text-muted-foreground/60 tabular-nums",children:["· ",Dt(v)]}),e.jsxs("span",{className:"text-muted-foreground/60",children:["· ",C.toLocaleString()," chars"]})]}),o&&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 At({name:t,content:s}){const[n,a]=l.useState(!1),o=s.length>60?s.slice(0,60)+"...":s;return s?e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>a(!n),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(G,{className:_("size-3 shrink-0 transition-transform",n&&"rotate-90")}),e.jsxs("span",{className:"truncate",children:[t||"tool",': "',o,'"']})]}),n&&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:s})]}):null}function de(t){if(!t)return null;try{const s=JSON.parse(t);return{text:JSON.stringify(s,null,2),isJson:!0}}catch{return{text:t,isJson:!1}}}function ue({tools:t}){const[s,n]=l.useState(!1);if(!t?.length)return null;const a=t.filter(c=>c.status==="running").length,o=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:()=>n(!s),className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground/70 hover:text-foreground transition-colors",children:[e.jsx(G,{className:_("size-3 shrink-0 transition-transform",s&&"rotate-90")}),e.jsxs("span",{children:["used ",t.length," tool",t.length>1?"s":""]}),a>0&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-amber-500",children:[e.jsx(F,{className:"size-2.5 animate-spin"}),a]}),o>0&&e.jsxs("span",{className:"text-emerald-500",children:[o," done"]}),i>0&&e.jsxs("span",{className:"text-red-500",children:[i," error"]}),t.length>0&&a===0&&e.jsxs("span",{className:"text-muted-foreground/50 truncate max-w-[200px]",children:["— ",t.map(c=>c.name).join(", ")]})]}),s&&e.jsx("div",{className:"mt-1 flex flex-col gap-1.5",children:t.map((c,x)=>{const d=de(c.preview),v=de(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(F,{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"})]}),d&&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(V,{text:d.text})]}),e.jsx("div",{className:"px-2.5 pb-1.5",children:e.jsx("pre",{className:_("text-[10px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap max-h-[200px] overflow-y-auto rounded",d.isJson?"bg-slate-900/10 dark:bg-slate-900/40 text-foreground/80 px-2 py-1":"text-muted-foreground/70"),children:d.text})})]}),v&&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(V,{text:v.text})]}),e.jsx("div",{className:"px-2.5 pb-1.5",children:e.jsx("pre",{className:_("text-[10px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap max-h-[200px] overflow-y-auto rounded",v.isJson?"bg-slate-900/10 dark:bg-slate-900/40 text-foreground/80 px-2 py-1":"text-muted-foreground/70"),children:v.text})})]})]},c.callId||`${c.name}-${x}`)})})]})}function zt({language:t,value:s}){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(V,{text:s})]}),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:s})}),children:e.jsx(_t,{language:t,value:s})})]})}const Et={pre({children:t}){return e.jsx("div",{className:"overflow-x-auto max-w-full",children:t})},code({className:t,children:s,...n}){const a=/language-(\w+)/.exec(t||""),o=String(s).replace(/\n$/,"");return a?a[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:o}):e.jsx(zt,{language:a[1],value:o}):e.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-[13px] font-mono text-foreground/90",...n,children:s})},a({href:t,children:s}){return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 underline underline-offset-2",children:s})},img({src:t,alt:s}){return e.jsx("img",{src:t,alt:s,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})}},Lt=/[\u2500-\u257F]/;function $t(t){return Lt.test(t)}function Tt(t){const s=t.split(`
4
- `),n=[];let a=!1;for(let o=0;o<s.length;o++){const i=s[o],c=$t(i);c&&!a?(n.length>0&&n[n.length-1]!==""&&n.push(""),n.push("```plaintext"),a=!0):!c&&a&&(n.push("```"),i!==""&&n.push(""),a=!1),n.push(i)}return a&&n.push("```"),n.join(`
5
- `)}function me({content:t,isStreaming:s}){const n=Tt(t);return s&&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"})]})}):s&&!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(qe,{remarkPlugins:[Xe],components:Et,children:n})})}function It(t){if(!t||isNaN(t))return null;try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return null}}function Ot({message:t}){const s=t.role==="user",n=t.role==="tool",a=!!t.content?.trim(),o=!!t.reasoning?.trim(),i=!!t.toolCalls?.length,c=It(t.timestamp);return n||!s&&!a&&(o||i)?e.jsxs("div",{className:"px-4 py-1",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[o&&e.jsx(ce,{reasoning:t.reasoning,isStreaming:t.isStreaming,startedAt:t.reasoningStartedAt,endedAt:t.reasoningEndedAt}),!n&&i&&e.jsx(ue,{tools:t.toolCalls}),n&&e.jsx(At,{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:_("flex px-4",s?"py-2 justify-end":"py-4 justify-start"),children:e.jsxs("div",{className:_("flex min-w-0 flex-col",s?"max-w-[85%] items-end":"w-full"),children:[t.isStreaming&&!a&&!o?e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground py-1",children:[e.jsx(F,{className:"h-3.5 w-3.5 animate-spin"}),"Thinking..."]}):e.jsxs("div",{className:"flex flex-col gap-1 w-full",children:[o&&e.jsx(ce,{reasoning:t.reasoning,isStreaming:t.isStreaming,startedAt:t.reasoningStartedAt,endedAt:t.reasoningEndedAt}),!n&&!s&&i&&e.jsx(ue,{tools:t.toolCalls}),a&&(s?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(me,{content:t.content,isStreaming:t.isStreaming})}):e.jsx("div",{className:"text-base leading-relaxed",children:e.jsx(me,{content:t.content,isStreaming:t.isStreaming})}))]}),a&&!s&&e.jsx("div",{className:"mt-1 flex items-center gap-2 px-1",children:e.jsx(Mt,{text:t.content})}),c&&e.jsx("span",{className:"mt-1 text-[10px] text-muted-foreground/50 px-1",children:c})]})})}const Pt=l.memo(Ot),Ut=l.memo(function({messages:s,isLoading:n}){const a=l.useMemo(()=>s.map(o=>({id:o.id,role:o.role==="user"?"user":o.role==="tool"?"tool":"assistant",content:o.content,timestamp:o.timestamp,isStreaming:o.isStreaming,reasoning:o.reasoning,reasoningStartedAt:o.reasoningStartedAt,reasoningEndedAt:o.reasoningEndedAt,toolCalls:o.toolCalls})),[s]);return e.jsx(e.Fragment,{children:a.map(o=>e.jsx(Pt,{message:o},o.id))})});function Ht(t){const s=l.useRef(null),n=l.useRef(null),a=l.useRef(!1),o=l.useRef(t.length),i=l.useCallback(x=>{!x&&a.current||n.current?.scrollIntoView({behavior:"smooth"})},[]),c=l.useCallback(()=>{const x=s.current;if(!x)return;const d=x.scrollHeight-x.scrollTop-x.clientHeight<80;a.current=!d},[]);return l.useEffect(()=>{const x=o.current;o.current=t.length,t.length>x&&t[t.length-1]?.role==="user"?(a.current=!1,i(!0)):i()},[t,i]),{containerRef:s,bottomRef:n,onScroll:c}}const Ft="http://localhost:47474";async function*Wt(t){const{input:s,conversation:n,model:a,signal:o}=t,i={input:s};n&&(i.conversation=n),a&&(i.model=a),t.messages&&t.messages.length>0&&(i.messages=t.messages),t.attachments&&t.attachments.length>0&&(i.attachments=t.attachments);const c=await fetch(`${Ft}/api/chat/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:o});if(!c.ok){const C=await c.text().catch(()=>"Stream request failed");throw new Error(C)}if(!c.body)throw new Error("No response body");const x=c.body.getReader(),d=new TextDecoder;let v="";try{for(;;){const{done:C,value:y}=await x.read();if(C)break;v+=d.decode(y,{stream:!0});let j=v.indexOf(`
6
-
7
- `);for(;j>=0;){const S=v.slice(0,j);v=v.slice(j+2);let M="",g="";for(const u of S.split(`
8
- `))u.startsWith("event: ")?M=u.slice(7).trim():u.startsWith("data: ")&&(g+=(g?`
9
- `:"")+u.slice(6));if(g){let u={};try{u=JSON.parse(g)}catch{u={raw:g}}yield{type:M||"unknown",data:u}}j=v.indexOf(`
10
-
11
- `)}}}finally{x.releaseLock()}}let Bt=0;function pe(){return`msg-${++Bt}-${Math.random().toString(36).slice(2,6)}`}function Jt(){const t=l.useRef(null),s=l.useCallback((o,i)=>{w.setState(c=>({streamingSessions:i?new Set([...c.streamingSessions,o]):new Set([...c.streamingSessions].filter(x=>x!==o))}))},[]),n=l.useCallback(()=>{t.current&&(t.current.abort(),t.current=null)},[]);return{sendMessage:l.useCallback(async(o,i,c,x)=>{if(w.getState().streamingSessions.has(i))return;const d={id:pe(),role:"user",content:o,timestamp:Date.now()};w.setState(g=>{if(!g.sessions.find(m=>m.id===i)){const m=Date.now();return{sessions:[{id:i,title:o.slice(0,64),model:c||"",messages:[d],createdAt:m,updatedAt:m},...g.sessions]}}return{sessions:g.sessions.map(m=>m.id===i?{...m,messages:[...m.messages,d],model:c||m.model||"",title:!m.title||m.title==="New Conversation"||m.title==="Untitled"?o.slice(0,64):m.title}:m)}});const v=w.getState().sessions.find(g=>g.id===i)?.messages.slice(0,-1).filter(g=>!g.isStreaming&&g.content).map(g=>({role:g.role,content:g.content}))||[],y={id:pe(),role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0};w.setState(g=>({sessions:g.sessions.map(u=>u.id===i?{...u,messages:[...u.messages,y]}:u)})),s(i,!0);const j=new AbortController;t.current=j;let S=Date.now();const M=setInterval(()=>{Date.now()-S>3e5&&(console.warn("[stream] hang timeout — aborting",i),j.abort())},3e4);try{const g=Wt({input:o,conversation:i,model:c,signal:j.signal,messages:v,attachments:x?.attachments?.map(u=>({id:u.id,name:u.name,type:u.type,size:u.size}))});for await(const u of g)switch(S=Date.now(),u.type){case"token":{const m=u.data.delta||"";if(!m)continue;w.setState(p=>({sessions:p.sessions.map(f=>{if(f.id!==i)return f;const b=f.messages.slice(),h=b[b.length-1];return h&&h.role==="assistant"&&h.isStreaming&&(b[b.length-1]={...h,content:h.content+m}),{...f,messages:b}})}));break}case"reasoning":{const m=u.data.text||"";if(!m)continue;w.setState(p=>({sessions:p.sessions.map(f=>{if(f.id!==i)return f;const b=f.messages.slice(),h=b[b.length-1];if(h&&h.role==="assistant"&&h.isStreaming){const R=h.reasoning||"";b[b.length-1]={...h,reasoning:R+m,reasoningStartedAt:h.reasoningStartedAt||Date.now()}}return{...f,messages:b}})}));break}case"tool_start":{const m=u.data.name||"tool",p=u.data.preview||"",f=u.data.tool_call_id||void 0;w.setState(b=>({sessions:b.sessions.map(h=>{if(h.id!==i)return h;const R=h.messages.slice(),D=R[R.length-1];if(D&&D.role==="assistant"&&D.isStreaming){const E=[...D.toolCalls||[],{name:m,preview:p,callId:f,status:"running"}];R[R.length-1]={...D,toolCalls:E}}return{...h,messages:R}})}));break}case"tool_end":{const m=u.data.tool_call_id,p=u.data.tool,f=u.data.output;w.setState(b=>({sessions:b.sessions.map(h=>{if(h.id!==i)return h;const R=h.messages.slice(),D=R[R.length-1];if(!D?.toolCalls)return h;const E=D.toolCalls.map(A=>m&&A.callId===m?{...A,status:"done",output:f||A.output}:!m&&A.name===p&&A.status==="running"?{...A,status:"done",output:f||A.output}:A);return R[R.length-1]={...D,toolCalls:E},{...h,messages:R}})}));break}case"done":{w.setState(m=>({sessions:m.sessions.map(p=>{if(p.id!==i)return p;const f=p.messages.map(b=>b.role==="assistant"&&b.isStreaming?{...b,isStreaming:!1,reasoningEndedAt:b.reasoning?Date.now():void 0}:b);return{...p,messages:f}})})),s(i,!1);break}case"error":{const m=u.data.error;w.setState(p=>({sessions:p.sessions.map(f=>{if(f.id!==i)return f;const b=f.messages.map(h=>h.role==="assistant"&&h.isStreaming?{...h,isStreaming:!1,content:h.content||`**Error:** ${m||"Run failed"}`}:h);return{...f,messages:b}})})),s(i,!1);break}case"approval":{w.setState(m=>({sessions:m.sessions.map(p=>p.id===i?{...p,pendingApproval:u.data}:p)}));break}case"title":{const m=u.data.title;m&&w.setState(p=>({sessions:p.sessions.map(f=>f.id===i?{...f,title:m}:f)}));break}}}catch(g){const u=g instanceof Error?g.message:"Connection error";w.setState(m=>({sessions:m.sessions.map(p=>{if(p.id!==i)return p;const f=p.messages.map(b=>b.role==="assistant"&&b.isStreaming?{...b,isStreaming:!1,content:b.content||`**Error:** ${u}`}:b);return{...p,messages:f}})})),s(i,!1)}finally{clearInterval(M),t.current=null,s(i,!1),w.setState(g=>({sessions:g.sessions.map(u=>u.id!==i||!u.messages.some(p=>p.role==="assistant"&&p.isStreaming)?u:{...u,messages:u.messages.map(p=>p.role==="assistant"&&p.isStreaming?{...p,isStreaming:!1}:p)})}))}},[s]),abortChat:n}}function Kt({sessionId:t,model:s,isLoading:n,sendMessage:a,abortChat:o}){const i=be(),c=l.useRef(n);c.current=n;const x=l.useCallback(async(S,M,g)=>{const u=S.trim();if(!(!u||c.current)){if(bt(u)){const m=u.split(/\s+/)[0].toLowerCase();if(m==="/new"){const p=await se({model:s});i({to:"/chat/$sessionId",params:{sessionId:p.id}});return}if(m==="/clear"){w.setState(p=>({sessions:p.sessions.map(f=>f.id===t?{...f,messages:[]}:f)}));return}if(m==="/help"){const p=q.map(f=>`\`${f.name}\` — ${f.description}`).join(`
12
- `);w.setState(f=>({sessions:f.sessions.map(b=>b.id===t?{...b,messages:[...b.messages,{id:`agent-${Date.now()}`,role:"assistant",content:`**Available Commands**
13
-
14
- ${p}`,timestamp:Date.now()}]}:b)}));return}w.setState(p=>({sessions:p.sessions.map(f=>f.id===t?{...f,messages:[...f.messages,{id:`agent-${Date.now()}`,role:"assistant",content:`Command \`${m}\` is not yet implemented in the web UI.`,timestamp:Date.now()}]}:f)}));return}await a(u,t,M||s,{attachments:g})}},[t,s,a,i]),d=l.useCallback(()=>{o()},[o]),v=l.useCallback(async()=>{c.current||await a("/approve",t,s)},[t,s,a]),C=l.useCallback(async()=>{c.current||await a("/deny",t,s)},[t,s,a]),y=l.useCallback(async()=>{const S=await se({model:s});i({to:"/chat/$sessionId",params:{sessionId:S.id}})},[s,i]),j=l.useCallback(()=>{c.current&&o(),w.setState(S=>({sessions:S.sessions.map(M=>M.id===t?{...M,messages:[]}:M)}))},[t,o]);return{handleSend:x,handleAbort:d,handleApprove:v,handleDeny:C,handleNewChat:y,handleClear:j}}function Vt({sessionId:t,request:s,onResolved:n}){const[a,o]=l.useState(!1),i=async v=>{o(!0);try{await Ue({session_id:t,choice:v}),n()}catch{}finally{o(!1)}},c=s.tool_name||"unknown tool",x=typeof s.command=="string"?s.command:typeof s.arguments=="string"?s.arguments:null,d=typeof s.description=="string"?s.description:typeof s.preview=="string"?s.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(ne,{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})]}),x&&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:x}),d&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground leading-relaxed",children:d}),s.risk==="high"&&e.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-xs text-red-500",children:[e.jsx(Qe,{className:"h-3.5 w-3.5"}),"High risk operation"]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs(I,{size:"sm",variant:"default",className:"gap-1.5 bg-emerald-600 hover:bg-emerald-700 text-white",disabled:a,onClick:()=>i("once"),children:[e.jsx(B,{className:"h-3.5 w-3.5"}),"Approve once"]}),e.jsxs(I,{size:"sm",variant:"secondary",className:"gap-1.5",disabled:a,onClick:()=>i("session"),children:[e.jsx(B,{className:"h-3.5 w-3.5"}),"Approve all"]}),e.jsxs(I,{size:"sm",variant:"outline",className:"gap-1.5",disabled:a,onClick:()=>i("always"),children:[e.jsx(ne,{className:"h-3.5 w-3.5"}),"Always allow"]}),e.jsxs(I,{size:"sm",variant:"ghost",className:"gap-1.5 text-destructive hover:text-destructive",disabled:a,onClick:()=>i("deny"),children:[e.jsx(fe,{className:"h-3.5 w-3.5"}),"Deny"]})]})]})})}function Gt({sessionId:t,messages:s,title:n,model:a,pendingApproval:o}){const i=l.useRef(null),c=l.useRef(!1),{containerRef:x,bottomRef:d,onScroll:v}=Ht(s),{sendMessage:C,abortChat:y}=Jt(),j=w(g=>g.streamingSessions.has(t)),S=Kt({sessionId:t,model:a,isLoading:j,sendMessage:C,abortChat:y});l.useEffect(()=>{if(!t||c.current)return;const g=`hermium_pending_msg_${t}`,u=`hermium_pending_model_${t}`,m=sessionStorage.getItem(g);if(!m)return;c.current=!0;const p=sessionStorage.getItem(u)||a;sessionStorage.removeItem(g),sessionStorage.removeItem(u),C(m,t,p)},[t,a,C]),l.useEffect(()=>{function g(u){(u.metaKey||u.ctrlKey)&&u.key==="n"&&(u.preventDefault(),S.handleNewChat())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[S]);const M=l.useCallback(g=>{i.current?.setText(g)},[]);return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[e.jsx(kt,{sessionId:t,title:n,hasMessages:s.length>0,onNewChat:S.handleNewChat,onClear:S.handleClear}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-y-auto",ref:x,onScroll:v,children:[s.length===0&&!j?e.jsx(Rt,{onSelectSuggestion:M}):e.jsx("div",{className:"mx-auto max-w-3xl",children:e.jsx(Ut,{messages:s,isLoading:j,onApprove:S.handleApprove,onDeny:S.handleDeny})}),e.jsx("div",{ref:d}),o&&e.jsx("div",{className:"mx-auto max-w-3xl",children:e.jsx(Vt,{sessionId:t,request:o,onResolved:()=>{w.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(St,{ref:i,sessionId:t,model:a,isLoading:j,onSubmit:S.handleSend,onAbort:S.handleAbort})})]})}function ss(){const{sessionId:t}=He.useParams(),s=w(d=>d.switchSession),n=w(d=>d.loadSessions),a=w(d=>d.loadSessionMessages),o=w(d=>d.sessionsLoaded),i=w(d=>d.isLoadingMessages),c=w(ie(d=>{const v=d.sessions.find(C=>C.id===t);return{title:v?.title,model:v?.model||"",pendingApproval:v?.pendingApproval??null}})),x=w(ie(d=>d.sessions.find(C=>C.id===t)?.messages??[]));return l.useEffect(()=>{o||n()},[o,n]),l.useEffect(()=>{if(!t)return;s(t);const d=w.getState().getSession(t);(!d||d.messages.length===0)&&a(t)},[t,s,a]),i&&x.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(d=>e.jsxs("div",{className:"animate-pulse space-y-2",children:[e.jsx("div",{className:`h-4 rounded bg-muted ${d%2===0?"w-2/3":"w-1/2 ml-auto"}`}),e.jsx("div",{className:`h-3 rounded bg-muted ${d%2===0?"w-1/2":"w-1/3 ml-auto"}`})]},d))})})]}):e.jsx(Gt,{sessionId:t,messages:x,title:c.title,model:c.model,pendingApproval:c.pendingApproval})}export{ss as component};
@@ -1 +0,0 @@
1
- import{c as F,h as R,p as D,r as o,t as z,j as e,d as i,m as U,I as k}from"./index-DkYGodJj.js";import{I as w}from"./IconLoader2-BIx3OuF9.js";import{I as C}from"./IconAlertCircle-BHkmI3j7.js";import{I as Y}from"./IconRefresh-Dgm93w3T.js";import{I as B}from"./IconCheck-CFuEh_p7.js";import{M as G,r as O}from"./index-CrQs9n6q.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,r as l,j as e,d as u,x as q,z as C,p as F,A as J,C as L,B as y,y as D,I as A,E as K,h as E}from"./index-DkYGodJj.js";import{I as _}from"./input-eNcwlDHp.js";import{I as Q,T as B,a as P,b as W}from"./textarea-Di_syYTS.js";import{I as H}from"./IconRefresh-Dgm93w3T.js";import{I as U}from"./IconLoader2-BIx3OuF9.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 z(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:()=>E("/api/cron-history/jobs"),refetchInterval:3e4})}function ue(t){return D({queryKey:["cron","runs",t],queryFn:()=>E("/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(P,{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(A,{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(K,{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(P,{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:z(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:()=>E(`/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=q(),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(z(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(P,{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};