hermium 0.1.6 → 0.1.7

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 (52) hide show
  1. package/dist/public/assets/{IconAlertCircle-B7TgWpbP.js → IconAlertCircle-C98Iam1j.js} +1 -1
  2. package/dist/public/assets/{IconAlertTriangle-B7IYa46Q.js → IconAlertTriangle-DdD7_dc8.js} +1 -1
  3. package/dist/public/assets/{IconCheck-B-_pWgtP.js → IconCheck-CYZ4_524.js} +1 -1
  4. package/dist/public/assets/{IconLoader2-ClSf33Yd.js → IconLoader2-DkEhzUxZ.js} +1 -1
  5. package/dist/public/assets/{IconRefresh-D4MZeezY.js → IconRefresh-CCXMrUxO.js} +1 -1
  6. package/dist/public/assets/index-BTiEWEax.js +1 -0
  7. package/dist/public/assets/{index-BuznEPrX.js → index-Bfadg8tB.js} +1 -1
  8. package/dist/public/assets/{index-CsJLc3b2.js → index-C0ivmMuU.js} +1 -1
  9. package/dist/public/assets/index-CQCxtJMS.js +14 -0
  10. package/dist/public/assets/{index-BiFHsDt6.js → index-D6B0cdTJ.js} +1 -1
  11. package/dist/public/assets/{index-D04H-m2p.js → index-DCT13_ZI.js} +1 -1
  12. package/dist/public/assets/{index-B-EALIKE.js → index-DhCVawEl.js} +1 -1
  13. package/dist/public/assets/{index-xH6PhxmS.js → index-KT0CxDFc.js} +1 -1
  14. package/dist/public/assets/index-qsvsww7-.js +1 -0
  15. package/dist/public/assets/{index-DKYPj90W.js → index-twHXYGSY.js} +5 -5
  16. package/dist/public/assets/{index-DmUrSr_K.js → index-zFJdOj6P.js} +1 -1
  17. package/dist/public/assets/input-C_TtyOcH.js +1 -0
  18. package/dist/public/assets/queries-DuZAFrOY.js +1 -0
  19. package/dist/public/assets/styles-Bc7sFPhq.css +1 -0
  20. package/dist/public/assets/{switch-CgWk9YD3.js → switch-BKlJnOab.js} +1 -1
  21. package/dist/public/assets/{syntax-highlighter-CR5pD3DZ.js → syntax-highlighter-BuOqgzbp.js} +1 -1
  22. package/dist/public/assets/textarea-a9VUYAmJ.js +1 -0
  23. package/dist/public/assets/{useQuery-BtGwEPDz.js → useQuery-ByTdbkfi.js} +1 -1
  24. package/dist/server/index.mjs +132 -128
  25. package/dist/web-server/_libs/tabler__icons-react.mjs +3 -3
  26. package/dist/web-server/_ssr/{index-DSIu0x-q.mjs → index-BFCBaZTA.mjs} +3 -3
  27. package/dist/web-server/_ssr/{index-JzLhPyir.mjs → index-BT-fOdbN.mjs} +2 -2
  28. package/dist/web-server/_ssr/{index-Bp9a_nTf.mjs → index-BVtbpy73.mjs} +1 -1
  29. package/dist/web-server/_ssr/{index-BLK6uN4p.mjs → index-B_d-ca5z.mjs} +4 -4
  30. package/dist/web-server/_ssr/{index-EKE8NFy_.mjs → index-ClGONv4K.mjs} +1 -1
  31. package/dist/web-server/_ssr/{index-BkkxTg0a.mjs → index-CmwSlgGR.mjs} +12 -19
  32. package/dist/web-server/_ssr/{index-C8t8AZQG.mjs → index-D4rgpZTm.mjs} +4 -4
  33. package/dist/web-server/_ssr/{index-DqFrn6kj.mjs → index-DxgfsEKM.mjs} +67 -25
  34. package/dist/web-server/_ssr/{index-wTy_4MhH.mjs → index-KGEq7IhY.mjs} +2 -2
  35. package/dist/web-server/_ssr/index.mjs +2 -2
  36. package/dist/web-server/_ssr/{input-BQFduUUo.mjs → input-CZtNKDXd.mjs} +1 -1
  37. package/dist/web-server/_ssr/queries-ixVDom0l.mjs +16 -0
  38. package/dist/web-server/_ssr/{router-59cN5lqo.mjs → router-CrULUyXB.mjs} +21 -21
  39. package/dist/web-server/_ssr/{switch-Bim4kX8N.mjs → switch-Bd3Khe3S.mjs} +1 -1
  40. package/dist/web-server/_ssr/{textarea-CK0ROhfF.mjs → textarea-ClM2KXId.mjs} +1 -1
  41. package/dist/web-server/_tanstack-start-manifest_v-cNUQI9I2.mjs +4 -0
  42. package/dist/web-server/index.mjs +148 -155
  43. package/package.json +1 -1
  44. package/dist/public/assets/IconCode-AzDguzgN.js +0 -1
  45. package/dist/public/assets/IconPlus-BcEAWT5L.js +0 -1
  46. package/dist/public/assets/index-BP5217kc.js +0 -1
  47. package/dist/public/assets/index-DEVyhUPW.js +0 -14
  48. package/dist/public/assets/index-D_8SzN4W.js +0 -1
  49. package/dist/public/assets/input-of658hyw.js +0 -1
  50. package/dist/public/assets/styles-C9Ypt703.css +0 -1
  51. package/dist/public/assets/textarea-xdRt6_lX.js +0 -1
  52. package/dist/web-server/_tanstack-start-manifest_v-DLw6M7p4.mjs +0 -4
@@ -1 +1 @@
1
- import{c as e}from"./index-DKYPj90W.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
+ import{c as e}from"./index-twHXYGSY.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 +1 @@
1
- import{c as e}from"./index-DKYPj90W.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
+ import{c as e}from"./index-twHXYGSY.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 +1 @@
1
- import{c}from"./index-DKYPj90W.js";const e=[["path",{d:"M5 12l5 5l10 -10",key:"svg-0"}]],t=c("outline","check","Check",e);export{t as I};
1
+ import{c}from"./index-twHXYGSY.js";const e=[["path",{d:"M5 12l5 5l10 -10",key:"svg-0"}]],t=c("outline","check","Check",e);export{t as I};
@@ -1 +1 @@
1
- import{c as o}from"./index-DKYPj90W.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
+ import{c as o}from"./index-twHXYGSY.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 +1 @@
1
- import{c as e}from"./index-DKYPj90W.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
+ import{c as e}from"./index-twHXYGSY.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};
@@ -0,0 +1 @@
1
+ import{c as I,r as l,j as e,b as u,E as z,p as P,F as J,G as L,B as y,I as K,H as A,g as D}from"./index-twHXYGSY.js";import{u as E}from"./useQuery-ByTdbkfi.js";import{u as C,I as _}from"./input-C_TtyOcH.js";import{I as Q,T as B,a as F,b as H}from"./textarea-a9VUYAmJ.js";import{I as W}from"./IconRefresh-CCXMrUxO.js";import{I as U}from"./IconLoader2-DkEhzUxZ.js";const O=[["path",{d:"M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12",key:"svg-0"}],["path",{d:"M16 3v4",key:"svg-1"}],["path",{d:"M8 3v4",key:"svg-2"}],["path",{d:"M4 11h16",key:"svg-3"}],["path",{d:"M11 15h1",key:"svg-4"}],["path",{d:"M12 15v3",key:"svg-5"}]],G=I("outline","calendar","Calendar",O);const V=[["path",{d:"M7 4v16l13 -8l-13 -8",key:"svg-0"}]],X=I("outline","player-play","PlayerPlay",V);const Y=[["path",{d:"M7 6a7.75 7.75 0 1 0 10 0",key:"svg-0"}],["path",{d:"M12 4l0 8",key:"svg-1"}]],Z=I("outline","power","Power",Y),T=l.createContext(null);function ee(){const t=l.useContext(T);if(!t)throw new Error("Dialog components must be used within <Dialog>");return t}function te({open:t,onOpenChange:s,children:o}){const a=l.useCallback(r=>s(r),[s]);return l.useEffect(()=>{if(!t)return;const r=d=>{d.key==="Escape"&&a(!1)};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[t,a]),t?e.jsxs(T.Provider,{value:{open:t,setOpen:a},children:[e.jsx("div",{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",onClick:()=>a(!1)}),e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:e.jsx("div",{className:"relative w-full max-w-lg rounded-xl border border-border bg-card shadow-xl",onClick:r=>r.stopPropagation(),children:o})})]}):null}function se({children:t,className:s}){return ee(),e.jsx("div",{className:u("p-5",s),children:t})}function re({children:t,className:s}){return e.jsx("div",{className:u("mb-4",s),children:t})}function ne({children:t,className:s}){return e.jsx("h2",{className:u("text-base font-semibold",s),children:t})}function oe({children:t,className:s}){return e.jsx("div",{className:u("flex items-center justify-end gap-2 mt-4",s),children:t})}function v(t){return t.job_id||t.id||""}function ae(t){return t.name||v(t)||"Untitled"}function R(t){const s=t.trim().split(/\s+/);if(s.length<2)return t;const o=parseInt(s[0],10),a=parseInt(s[1],10);if(isNaN(o)||isNaN(a))return t;if(s[1]==="*")return`At minute ${o} past every hour`;const r=new Date(0,0,0,a,o).toLocaleTimeString([],{hour:"numeric",minute:"2-digit",hour12:!0});if(s.length>=5){const d=s.slice(2,5).join(" ");if(d==="* * 1-5")return`${r} weekdays`;if(d==="* * 0,6")return`${r} weekends`}return`${r} daily`}function q(t){if(!t)return"—";if(typeof t=="string")return R(t);const s=t.display||t.expr||JSON.stringify(t);return R(s)}function ie(t){return t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}function le(t){const s=new Date(t),o=Date.now()-s.getTime(),a=Math.floor(o/6e4);if(a<1)return"just now";if(a<60)return`${a}m ago`;const r=Math.floor(a/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function de(t){return new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ce(){return E({queryKey:["cron","jobs"],queryFn:()=>D("/api/cron-history/jobs"),refetchInterval:3e4})}function ue(t){return E({queryKey:["cron","runs",t],queryFn:()=>D("/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(F,{className:"h-3.5 w-3.5"}),S]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("code",{className:"text-[11px] text-muted-foreground/60 font-mono",children:N}),e.jsx("button",{type:"button",onClick:()=>{b(N),p(!0)},className:"text-[10px] text-muted-foreground/40 hover:text-muted-foreground underline underline-offset-2 transition-colors",children:"Raw cron"})]})]})]})}function pe({status:t}){if(!t)return e.jsx("div",{className:"h-2 w-2 rounded-full bg-muted-foreground/30"});const s=t==="ok"||t==="success"||t==="completed";return e.jsx("div",{className:u("h-2 w-2 rounded-full",s?"bg-emerald-500":"bg-red-500")})}function ge({job:t,onEdit:s,onDelete:o,onToggle:a}){return e.jsxs("div",{className:u("rounded-xl border bg-card p-5 transition-colors group relative",t.enabled!==!1?"border-border hover:border-emerald-500/30":"border-border opacity-60"),children:[e.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx(y,{variant:"ghost",size:"icon-sm",className:"h-7 w-7",onClick:r=>{r.stopPropagation(),a()},title:t.enabled!==!1?"Disable":"Enable",children:e.jsx(Z,{className:u("h-3.5 w-3.5",t.enabled!==!1?"text-emerald-500":"text-muted-foreground")})}),e.jsx(y,{variant:"ghost",size:"icon-sm",className:"h-7 w-7",onClick:r=>{r.stopPropagation(),s()},title:"Edit",children:e.jsx(K,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsx(y,{variant:"ghost",size:"icon-sm",className:"h-7 w-7 hover:text-red-500",onClick:r=>{r.stopPropagation(),o()},title:"Delete",children:e.jsx(A,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("div",{className:u("h-8 w-8 rounded-lg flex items-center justify-center shrink-0",t.enabled!==!1?"bg-emerald-500/10 text-emerald-600":"bg-muted text-muted-foreground"),children:e.jsx(F,{className:"h-4 w-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold truncate pr-20",children:ae(t)}),e.jsx("p",{className:"text-[11px] text-muted-foreground font-mono",children:q(t.schedule)})]})]}),e.jsx(pe,{status:t.last_status})]}),t.prompt&&e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed line-clamp-2 mb-3",children:t.prompt}),e.jsxs("div",{className:"flex items-center gap-4 text-[11px] text-muted-foreground",children:[t.run_count!=null&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(X,{className:"h-3 w-3"}),t.run_count," runs"]}),t.next_run_at&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(G,{className:"h-3 w-3"}),"Next: ",de(t.next_run_at)]}),t.last_run_at&&e.jsx("span",{children:le(t.last_run_at)})]})]})}function be({run:t}){const[s,o]=l.useState(!1),a=E({queryKey:["cron","run",t.jobId,t.fileName],queryFn:()=>D(`/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(H,{className:u("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform",s&&"rotate-90")}),e.jsx("span",{className:"text-xs font-medium text-foreground/80 min-w-[80px]",children:t.jobId}),e.jsx("span",{className:"text-xs text-muted-foreground flex-1",children:t.runTime}),e.jsx("span",{className:"text-[10px] text-muted-foreground/60 font-mono shrink-0",children:ie(t.size)})]}),s&&e.jsx("div",{className:"px-4 pb-4 pl-10",children:a.isLoading?e.jsxs("div",{className:"flex items-center gap-2 py-3 text-muted-foreground text-xs",children:[e.jsx(U,{className:"h-3.5 w-3.5 animate-spin"}),"Loading..."]}):e.jsx("pre",{className:"text-[12px] font-mono leading-relaxed whitespace-pre-wrap text-foreground/80 bg-muted/30 rounded-lg p-3 border border-border/50 max-h-[400px] overflow-auto",children:a.data?.content||"No output"})})]})}function ye(){const t=z(),s=ce(),o=ue(null),[a,r]=l.useState(!1),[d,c]=l.useState(null),[h,f]=l.useState(""),[p,g]=l.useState(""),[b,x]=l.useState(""),w=l.useCallback(()=>{s.refetch(),o.refetch()},[s,o]),N=C({mutationFn:n=>P("/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=>P(`/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(W,{className:u("h-4 w-4",(s.isFetching||o.isFetching)&&"animate-spin")})})]})]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[e.jsx(te,{open:a,onOpenChange:n=>{n||(r(!1),c(null))},children:e.jsxs(se,{children:[e.jsx(re,{children:e.jsx(ne,{children:d?"Edit Cron Job":"New Cron Job"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Name"}),e.jsx(_,{value:h,onChange:n=>f(n.target.value),placeholder:"e.g. Daily weather report",className:"h-9 text-sm"})]}),e.jsx(fe,{value:p,onChange:g}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Prompt"}),e.jsx(B,{value:b,onChange:n=>x(n.target.value),placeholder:"What should the agent do when this job runs?",className:"min-h-[80px] text-sm",rows:4})]})]}),e.jsxs(oe,{children:[e.jsx(y,{size:"sm",variant:"ghost",onClick:()=>{r(!1),c(null)},children:"Cancel"}),e.jsx(y,{size:"sm",disabled:!h.trim()||!p.trim(),onClick:()=>{const n={name:h.trim(),schedule:p.trim(),prompt:b.trim()};d?S.mutate({id:v(d),data:n}):N.mutate(n)},children:d?"Save Changes":"Create Job"})]})]})}),e.jsxs("div",{className:"px-6 pt-5 pb-2",children:[e.jsx("h2",{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-3",children:"Jobs"}),s.isLoading?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[1,2,3].map(n=>e.jsx("div",{className:"rounded-xl border border-border bg-card h-36 animate-pulse",children:e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-1/2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-muted rounded w-full"})]})},n))}):s.data?.jobs?.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:s.data.jobs.map(n=>e.jsx(ge,{job:n,onEdit:()=>{c(n),f(n.name||""),g(q(n.schedule)),x(n.prompt||""),r(!0)},onDelete:()=>M.mutate(v(n)),onToggle:()=>$.mutate(v(n))},v(n)))}):e.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-muted/20 py-12 text-center",children:[e.jsx(F,{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 Se=ye;export{Se as component};
@@ -1 +1 @@
1
- import{c as i,j as e,k as d,l as c,m as l,n as m,o as x,q as u,s as p,t as g,v as h,R as f}from"./index-DKYPj90W.js";const b=[["path",{d:"M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10",key:"svg-0"}],["path",{d:"M7 20h10",key:"svg-1"}],["path",{d:"M9 16v4",key:"svg-2"}],["path",{d:"M15 16v4",key:"svg-3"}]],j=i("outline","device-desktop","DeviceDesktop",b),n={profile:{icon:x,title:"Profile",description:"Your name, email, and avatar",content:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Display Name"}),e.jsx("input",{type:"text",defaultValue:"User",className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/60 outline-none focus:border-primary/50 transition-colors"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Email"}),e.jsx("input",{type:"email",defaultValue:"user@hermium.dev",className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/60 outline-none focus:border-primary/50 transition-colors"})]})]})},appearance:{icon:m,title:"Appearance",description:"Theme, font size, and density",get content(){return e.jsx(y,{})}},notifications:{icon:l,title:"Notifications",description:"Push and in-app notifications",content:e.jsx("div",{className:"space-y-3",children:["Desktop notifications","Sound on new message","Show preview in notification"].map(s=>e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",defaultChecked:!0,className:"rounded border-border accent-primary"}),e.jsx("span",{className:"text-sm text-foreground",children:s})]},s))})},"api-keys":{icon:c,title:"API Keys",description:"Manage providers and keys",content:e.jsxs("div",{className:"space-y-3",children:[[{provider:"OpenAI",key:"sk-••••••••••••••••",status:"active"},{provider:"Anthropic",key:"sk-ant-•••••••••••",status:"active"},{provider:"Groq",key:"gsk-••••••••••••••••",status:"active"}].map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-border px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(u,{className:"size-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:s.provider}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:s.key})]})]}),e.jsx("span",{className:"text-[10px] font-medium text-green-600 dark:text-green-400 uppercase tracking-wider",children:s.status})]},s.provider)),e.jsx("button",{className:"w-full rounded-lg border border-dashed border-border px-3 py-2 text-sm text-muted-foreground hover:text-foreground hover:border-foreground/30 transition-colors",children:"+ Add API Key"})]})},language:{icon:d,title:"Language & Region",description:"Language, timezone, and format preferences",content:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Language"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary/50 transition-colors",children:[e.jsx("option",{children:"English"}),e.jsx("option",{children:"Spanish"}),e.jsx("option",{children:"French"}),e.jsx("option",{children:"German"}),e.jsx("option",{children:"Japanese"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Timezone"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary/50 transition-colors",children:[e.jsx("option",{children:"UTC (Coordinated Universal Time)"}),e.jsx("option",{children:"America/New_York"}),e.jsx("option",{children:"America/Los_Angeles"}),e.jsx("option",{children:"Europe/London"}),e.jsx("option",{children:"Asia/Tokyo"})]})]})]})}};function y(){const{resolvedTheme:s,setTheme:t}=p();return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Theme"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{id:"light",icon:g,label:"Light"},{id:"dark",icon:h,label:"Dark"},{id:"system",icon:j,label:"System"}].map(r=>{const o=r.id===(s==="dark"?"dark":r.id==="system"?"system":"light"),a=r.icon;return e.jsxs("button",{onClick:()=>t(r.id),className:v("flex flex-col items-center gap-1.5 rounded-lg border px-3 py-2.5 text-xs transition-colors",o?"border-primary/50 bg-primary/5 text-foreground":"border-border text-muted-foreground hover:border-foreground/20 hover:text-foreground"),children:[e.jsx(a,{className:"size-5"}),r.label]},r.id)})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Font Size"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"A"}),e.jsx("input",{type:"range",min:"12",max:"20",defaultValue:"14",className:"flex-1 accent-primary"}),e.jsx("span",{className:"text-lg text-muted-foreground",children:"A"})]})]})]})}function v(...s){return s.filter(Boolean).join(" ")}function N({section:s}){const t=s&&s in n?s:"profile",r=n[t];return e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto max-w-2xl px-8 py-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:r.title}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:r.description})]}),e.jsx("div",{className:"rounded-xl border border-border bg-card p-6",children:r.content})]})})}function A(){const{section:s}=f.useSearch();return e.jsx(N,{section:s})}export{A as component};
1
+ import{c as i,j as e,n as d,o as c,q as l,s as m,t as x,v as u,w as p,x as g,y as h,R as f}from"./index-twHXYGSY.js";const b=[["path",{d:"M3 5a1 1 0 0 1 1 -1h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10",key:"svg-0"}],["path",{d:"M7 20h10",key:"svg-1"}],["path",{d:"M9 16v4",key:"svg-2"}],["path",{d:"M15 16v4",key:"svg-3"}]],j=i("outline","device-desktop","DeviceDesktop",b),n={profile:{icon:x,title:"Profile",description:"Your name, email, and avatar",content:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Display Name"}),e.jsx("input",{type:"text",defaultValue:"User",className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/60 outline-none focus:border-primary/50 transition-colors"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Email"}),e.jsx("input",{type:"email",defaultValue:"user@hermium.dev",className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/60 outline-none focus:border-primary/50 transition-colors"})]})]})},appearance:{icon:m,title:"Appearance",description:"Theme, font size, and density",get content(){return e.jsx(y,{})}},notifications:{icon:l,title:"Notifications",description:"Push and in-app notifications",content:e.jsx("div",{className:"space-y-3",children:["Desktop notifications","Sound on new message","Show preview in notification"].map(s=>e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",defaultChecked:!0,className:"rounded border-border accent-primary"}),e.jsx("span",{className:"text-sm text-foreground",children:s})]},s))})},"api-keys":{icon:c,title:"API Keys",description:"Manage providers and keys",content:e.jsxs("div",{className:"space-y-3",children:[[{provider:"OpenAI",key:"sk-••••••••••••••••",status:"active"},{provider:"Anthropic",key:"sk-ant-•••••••••••",status:"active"},{provider:"Groq",key:"gsk-••••••••••••••••",status:"active"}].map(s=>e.jsxs("div",{className:"flex items-center justify-between rounded-lg border border-border px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(u,{className:"size-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:s.provider}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:s.key})]})]}),e.jsx("span",{className:"text-[10px] font-medium text-green-600 dark:text-green-400 uppercase tracking-wider",children:s.status})]},s.provider)),e.jsx("button",{className:"w-full rounded-lg border border-dashed border-border px-3 py-2 text-sm text-muted-foreground hover:text-foreground hover:border-foreground/30 transition-colors",children:"+ Add API Key"})]})},language:{icon:d,title:"Language & Region",description:"Language, timezone, and format preferences",content:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Language"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary/50 transition-colors",children:[e.jsx("option",{children:"English"}),e.jsx("option",{children:"Spanish"}),e.jsx("option",{children:"French"}),e.jsx("option",{children:"German"}),e.jsx("option",{children:"Japanese"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Timezone"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary/50 transition-colors",children:[e.jsx("option",{children:"UTC (Coordinated Universal Time)"}),e.jsx("option",{children:"America/New_York"}),e.jsx("option",{children:"America/Los_Angeles"}),e.jsx("option",{children:"Europe/London"}),e.jsx("option",{children:"Asia/Tokyo"})]})]})]})}};function y(){const{resolvedTheme:s,setTheme:t}=p();return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Theme"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{id:"light",icon:g,label:"Light"},{id:"dark",icon:h,label:"Dark"},{id:"system",icon:j,label:"System"}].map(r=>{const o=r.id===(s==="dark"?"dark":r.id==="system"?"system":"light"),a=r.icon;return e.jsxs("button",{onClick:()=>t(r.id),className:v("flex flex-col items-center gap-1.5 rounded-lg border px-3 py-2.5 text-xs transition-colors",o?"border-primary/50 bg-primary/5 text-foreground":"border-border text-muted-foreground hover:border-foreground/20 hover:text-foreground"),children:[e.jsx(a,{className:"size-5"}),r.label]},r.id)})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-sm font-medium text-foreground",children:"Font Size"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"A"}),e.jsx("input",{type:"range",min:"12",max:"20",defaultValue:"14",className:"flex-1 accent-primary"}),e.jsx("span",{className:"text-lg text-muted-foreground",children:"A"})]})]})]})}function v(...s){return s.filter(Boolean).join(" ")}function N({section:s}){const t=s&&s in n?s:"profile",r=n[t];return e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto max-w-2xl px-8 py-8",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-foreground",children:r.title}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:r.description})]}),e.jsx("div",{className:"rounded-xl border border-border bg-card p-6",children:r.content})]})})}function w(){const{section:s}=f.useSearch();return e.jsx(N,{section:s})}export{w as component};
@@ -1,2 +1,2 @@
1
- import{c as j,g as z,p as Q,r as o,j as e,e as b,f as V,h as B,i as D,b as x}from"./index-DKYPj90W.js";import{S as G}from"./switch-CgWk9YD3.js";import{I as C}from"./IconLoader2-ClSf33Yd.js";import{I as H}from"./IconAlertCircle-B7TgWpbP.js";import{I as K}from"./IconRefresh-D4MZeezY.js";import{M as O,r as W}from"./index-D04H-m2p.js";const X=[["path",{d:"M9 15l6 -6",key:"svg-0"}],["path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464",key:"svg-1"}],["path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463",key:"svg-2"}]],J=j("outline","link","Link",X);const U=[["path",{d:"M6.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3",key:"svg-1"}]],Y=j("outline","tag","Tag",U);const Z=[["path",{d:"M10 7a2 2 0 0 1 2 -2h6a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-6a2 2 0 0 1 -2 -2l0 -10",key:"svg-0"}],["path",{d:"M7 7l0 10",key:"svg-1"}],["path",{d:"M4 8l0 8",key:"svg-2"}]],ee=j("outline","versions","Versions",Z);async function te(){return z("/api/hermes/skills")}async function se(l,a){return z(`/api/hermes/skills/${l}/${a}/SKILL.md`)}async function re(l,a){return Q(`/api/hermes/skills/${l}/${a}/toggle`)}const le={a({href:l,children:a}){return e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 underline underline-offset-2 decoration-blue-400/30 hover:decoration-blue-600/60 transition-colors",children:a})},img({src:l,alt:a}){return e.jsx("img",{src:l,alt:a,className:"rounded-xl max-w-full my-4",loading:"lazy"})},pre({children:l}){return e.jsx("pre",{className:"my-5 rounded-xl bg-muted/50 border border-border/60 px-5 py-4 text-[13px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap",children:l})},code({children:l,className:a}){return a?e.jsx("code",{className:a,children:l}):e.jsx("code",{className:"rounded-md bg-muted/70 px-1.5 py-0.5 text-[13px] font-mono text-foreground/90 border border-border/50",children:l})}};function ne(){const[l,a]=o.useState([]),[p,I]=o.useState(0),[L,k]=o.useState(!0),[N,_]=o.useState(null),[u,y]=o.useState(""),[d,M]=o.useState(null),[i,q]=o.useState(null),[v,E]=o.useState(null),[$,c]=o.useState(""),[R,g]=o.useState(!1),[w,P]=o.useState(new Set),f=o.useCallback(async()=>{k(!0),_(null);try{const t=await te();a(t.categories),I(t.total)}catch(t){_(t instanceof Error?t.message:"Failed to load skills")}finally{k(!1)}},[]);o.useEffect(()=>{f()},[f]),o.useEffect(()=>{if(!d||!i){c("");return}let t=!1;return g(!0),se(d,i).then(s=>{if(!t){const r=s.content;if(r.startsWith("---")){const n=r.indexOf(`
1
+ import{c as j,g as z,p as Q,r as o,j as e,i as b,k as V,l as B,m as D,b as x}from"./index-twHXYGSY.js";import{S as G}from"./switch-BKlJnOab.js";import{I as C}from"./IconLoader2-DkEhzUxZ.js";import{I as H}from"./IconAlertCircle-C98Iam1j.js";import{I as K}from"./IconRefresh-CCXMrUxO.js";import{M as O,r as W}from"./index-DCT13_ZI.js";const X=[["path",{d:"M9 15l6 -6",key:"svg-0"}],["path",{d:"M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464",key:"svg-1"}],["path",{d:"M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463",key:"svg-2"}]],J=j("outline","link","Link",X);const U=[["path",{d:"M6.5 7.5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0",key:"svg-0"}],["path",{d:"M3 6v5.172a2 2 0 0 0 .586 1.414l7.71 7.71a2.41 2.41 0 0 0 3.408 0l5.592 -5.592a2.41 2.41 0 0 0 0 -3.408l-7.71 -7.71a2 2 0 0 0 -1.414 -.586h-5.172a3 3 0 0 0 -3 3",key:"svg-1"}]],Y=j("outline","tag","Tag",U);const Z=[["path",{d:"M10 7a2 2 0 0 1 2 -2h6a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-6a2 2 0 0 1 -2 -2l0 -10",key:"svg-0"}],["path",{d:"M7 7l0 10",key:"svg-1"}],["path",{d:"M4 8l0 8",key:"svg-2"}]],ee=j("outline","versions","Versions",Z);async function te(){return z("/api/hermes/skills")}async function se(l,a){return z(`/api/hermes/skills/${l}/${a}/SKILL.md`)}async function re(l,a){return Q(`/api/hermes/skills/${l}/${a}/toggle`)}const le={a({href:l,children:a}){return e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 underline underline-offset-2 decoration-blue-400/30 hover:decoration-blue-600/60 transition-colors",children:a})},img({src:l,alt:a}){return e.jsx("img",{src:l,alt:a,className:"rounded-xl max-w-full my-4",loading:"lazy"})},pre({children:l}){return e.jsx("pre",{className:"my-5 rounded-xl bg-muted/50 border border-border/60 px-5 py-4 text-[13px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap",children:l})},code({children:l,className:a}){return a?e.jsx("code",{className:a,children:l}):e.jsx("code",{className:"rounded-md bg-muted/70 px-1.5 py-0.5 text-[13px] font-mono text-foreground/90 border border-border/50",children:l})}};function ne(){const[l,a]=o.useState([]),[p,I]=o.useState(0),[L,k]=o.useState(!0),[N,_]=o.useState(null),[u,y]=o.useState(""),[d,M]=o.useState(null),[i,q]=o.useState(null),[v,E]=o.useState(null),[$,c]=o.useState(""),[R,g]=o.useState(!1),[w,P]=o.useState(new Set),f=o.useCallback(async()=>{k(!0),_(null);try{const t=await te();a(t.categories),I(t.total)}catch(t){_(t instanceof Error?t.message:"Failed to load skills")}finally{k(!1)}},[]);o.useEffect(()=>{f()},[f]),o.useEffect(()=>{if(!d||!i){c("");return}let t=!1;return g(!0),se(d,i).then(s=>{if(!t){const r=s.content;if(r.startsWith("---")){const n=r.indexOf(`
2
2
  ---`,3);c(n!==-1?r.slice(n+4).trim():r)}else c(r);g(!1)}}).catch(s=>{t||(c(s instanceof Error?s.message:"Failed to load skill"),g(!1))}),()=>{t=!0}},[d,i]);const m=u.toLowerCase().trim(),S=m?l.map(t=>({...t,skills:(t.skills??[]).filter(s=>s.name.toLowerCase().includes(m)||s.description.toLowerCase().includes(m)||(s.tags??[]).some(r=>r.toLowerCase().includes(m)))})).filter(t=>t.skills.length>0||t.name.toLowerCase().includes(m)):l,T=t=>{P(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},F=(t,s,r)=>{M(t),q(s),E(r)},A=async(t,s)=>{a(r=>r.map(n=>n.name===t?{...n,skills:n.skills.map(h=>h.name===s?{...h,disabled:!h.disabled}:h)}:n));try{await re(t,s)}catch{f()}};return L?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-muted-foreground",children:[e.jsx(C,{className:"size-6 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Loading skills..."})]})}):N?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-muted-foreground",children:[e.jsx(H,{className:"size-8 text-red-500"}),e.jsx("span",{className:"text-sm",children:N}),e.jsxs("button",{onClick:f,className:"inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium bg-muted hover:bg-muted/80 transition-colors",children:[e.jsx(K,{className:"size-3.5"}),"Retry"]})]})}):e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("aside",{className:"flex w-64 shrink-0 flex-col border-r border-border",children:[e.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-3.5 shrink-0",children:[e.jsx(b,{className:"size-5 text-muted-foreground"}),e.jsxs("span",{className:"text-sm font-semibold text-foreground",children:["Skills",p>0&&e.jsxs("span",{className:"ml-1.5 text-[11px] font-normal text-muted-foreground",children:["(",p,")"]})]})]}),e.jsx("div",{className:"px-3 pb-2 shrink-0",children:e.jsxs("div",{className:"relative",children:[e.jsx(V,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground/50"}),e.jsx("input",{value:u,onChange:t=>y(t.target.value),placeholder:"Search skills...",className:"w-full rounded-md border border-border/60 bg-muted/30 pl-8 pr-8 py-1.5 text-xs text-foreground placeholder:text-muted-foreground/40 outline-none focus:ring-1 focus:ring-primary/20 focus:border-primary/30"}),u&&e.jsx("button",{onClick:()=>y(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground/40 hover:text-muted-foreground",children:e.jsx(B,{className:"size-3"})})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0",children:S.length===0?e.jsx("div",{className:"px-4 py-8 text-center",children:e.jsx("p",{className:"text-xs text-muted-foreground",children:u?"No skills match your search":"No skills found"})}):S.map(t=>e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>T(t.name),className:"flex w-full items-center gap-1.5 px-3 py-1.5 text-left hover:bg-muted/40 transition-colors",children:[e.jsx(D,{className:x("size-3 shrink-0 text-muted-foreground/50 transition-transform",w.has(t.name)&&"-rotate-90")}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground truncate",children:t.name.replace(/-/g," ")}),e.jsx("span",{className:"text-[10px] text-muted-foreground/50 ml-auto shrink-0",children:t.skills.length})]}),!w.has(t.name)&&e.jsx("div",{className:"pb-1",children:(t.skills??[]).map(s=>{const r=d===t.name&&i===s.name;return e.jsxs("button",{onClick:()=>F(t.name,s.name,s.name),className:x("flex w-full items-start gap-2 px-3 py-1.5 pl-8 text-left transition-colors",r?"bg-muted text-foreground":s.disabled?"text-muted-foreground/40 hover:bg-muted/20":"text-muted-foreground hover:bg-muted/30 hover:text-foreground"),children:[e.jsxs("div",{className:x("min-w-0 flex-1",s.disabled&&"opacity-50"),children:[e.jsx("div",{className:x("truncate text-xs font-medium",s.disabled&&"line-through"),children:s.name}),s.description&&e.jsx("div",{className:"truncate text-[10px] text-muted-foreground/60 mt-0.5",children:s.description})]}),e.jsx("div",{className:"shrink-0",onClick:n=>n.stopPropagation(),children:e.jsx(G,{checked:!s.disabled,onCheckedChange:()=>A(t.name,s.name)})})]},s.name)})})]},t.name))})]}),e.jsx("div",{className:"flex flex-1 flex-col min-w-0 overflow-y-auto",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"shrink-0 border-b border-border px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex size-8 items-center justify-center rounded-lg bg-muted/50 border border-border/50",children:e.jsx(b,{className:"size-4 text-muted-foreground"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-base font-semibold text-foreground truncate",children:v}),e.jsxs("p",{className:"text-xs text-muted-foreground/60 mt-0.5 flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-muted-foreground/40",children:d?.replace(/-/g," ")}),e.jsx("span",{className:"text-muted-foreground/30",children:"/"}),e.jsx("span",{children:v})]})]})]}),(()=>{const s=l.find(r=>r.name===d)?.skills.find(r=>r.name===i);return s?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-3",children:[s.version&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground/60 bg-muted/40 rounded-full px-2 py-0.5",children:[e.jsx(ee,{className:"size-3"}),"v",s.version]}),(s.tags??[]).map(r=>e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] text-muted-foreground/60 bg-muted/40 rounded-full px-2 py-0.5",children:[e.jsx(Y,{className:"size-3"}),r]},r))]}):null})()]}),e.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 px-6 py-6",children:R?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(C,{className:"size-5 animate-spin text-muted-foreground"})}):e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("div",{className:x("prose-sm max-w-none","[&_h1]:mt-8 [&_h1]:mb-4 [&_h1]:text-2xl [&_h1]:font-bold [&_h1]:tracking-tight [&_h1]:text-foreground","[&_h2]:mt-7 [&_h2]:mb-3 [&_h2]:text-xl [&_h2]:font-semibold [&_h2]:tracking-tight [&_h2]:text-foreground","[&_h3]:mt-6 [&_h3]:mb-2.5 [&_h3]:text-lg [&_h3]:font-semibold [&_h3]:text-foreground","[&_h4]:mt-5 [&_h4]:mb-2 [&_h4]:text-base [&_h4]:font-medium [&_h4]:text-foreground","[&_p]:my-4 [&_p]:leading-[1.75] [&_p]:text-foreground/85","[&_ul]:my-4 [&_ul]:pl-6 [&_ul]:list-disc [&_ul]:space-y-1.5 [&_ul]:marker:text-muted-foreground/40","[&_ol]:my-4 [&_ol]:pl-6 [&_ol]:list-decimal [&_ol]:space-y-1.5 [&_ol]:marker:text-muted-foreground/40","[&_li]:leading-relaxed [&_li]:text-foreground/85","[&_blockquote]:my-5 [&_blockquote]:border-l-[3px] [&_blockquote]:border-amber-400 dark:[&_blockquote]:border-amber-500 [&_blockquote]:pl-4 [&_blockquote]:text-muted-foreground [&_blockquote]:italic [&_blockquote]:leading-relaxed","[&_hr]:my-8 [&_hr]:border-border/40","[&_table]:w-full [&_table]:my-4 [&_table]:text-sm","[&_th]:border [&_th]:border-border [&_th]:bg-muted/60 [&_th]:px-4 [&_th]:py-2.5 [&_th]:text-left [&_th]:font-medium [&_th]:text-foreground/80 [&_th]:text-xs [&_th]:uppercase [&_th]:tracking-wider","[&_td]:border [&_td]:border-border [&_td]:px-4 [&_td]:py-2.5 [&_td]:text-foreground/80","[&>*:first-child]:mt-0 [&>*:last-child]:mb-0"),children:e.jsx(O,{remarkPlugins:[W],components:le,children:$})}),(()=>{const r=l.find(n=>n.name===d)?.skills.find(n=>n.name===i)?.related_skills??[];return r.length?e.jsxs("div",{className:"mt-8 pt-6 border-t border-border",children:[e.jsxs("h4",{className:"flex items-center gap-1.5 text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3",children:[e.jsx(J,{className:"size-3"}),"Related Skills"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.map(n=>e.jsx("span",{className:"rounded-md bg-muted/40 px-2.5 py-1 text-xs text-muted-foreground border border-border/40",children:n},n))})]}):null})()]})})]}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-4 text-muted-foreground max-w-sm text-center",children:[e.jsx("div",{className:"flex size-16 items-center justify-center rounded-2xl bg-muted/50 border border-border/50",children:e.jsx(b,{className:"size-7 text-muted-foreground/25"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground/60",children:"Select a skill to view details"}),e.jsx("p",{className:"text-xs text-muted-foreground/50 mt-1",children:"Browse skills from your Hermes agent library. Each skill provides instructions and context for specific tasks."})]})]})})})]})}const xe=ne;export{xe as component};
@@ -0,0 +1,14 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/syntax-highlighter-BuOqgzbp.js","assets/index-twHXYGSY.js","assets/index-DCT13_ZI.js"])))=>i.map(i=>d[i]);
2
+ import{c as E,a3 as De,r as l,j as e,b as M,l as me,B as I,D as pe,d as fe,e as he,f as W,u as ge,A as y,H as Z,a4 as Ae,I as ze,a5 as Ee,a6 as Le,k as xe,q as Ie,a7 as be,a8 as Te,a as ee,a9 as $e,aa as Oe}from"./index-twHXYGSY.js";import{T as Pe,I as Ue,a as He,b as J}from"./textarea-a9VUYAmJ.js";import{u as Fe,a as We,b as Be,I as Je}from"./queries-DuZAFrOY.js";import{I as U}from"./IconLoader2-DkEhzUxZ.js";import{M as Ke,r as Ge}from"./index-DCT13_ZI.js";import{I as F}from"./IconCheck-CYZ4_524.js";import{I as qe}from"./IconAlertTriangle-DdD7_dc8.js";import"./useQuery-ByTdbkfi.js";const Ve=[["path",{d:"M4 19l16 0",key:"svg-0"}],["path",{d:"M4 15l4 -6l4 2l4 -5l4 4",key:"svg-1"}]],Xe=E("outline","chart-line","ChartLine",Ve);const Qe=[["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"}]],Ye=E("outline","command","Command",Qe);const Ze=[["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"}]],et=E("outline","file","File",Ze);const tt=[["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"}]],st=E("outline","mail","Mail",tt);const nt=[["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"}]],rt=E("outline","paperclip","Paperclip",nt);const at=[["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"}]],ot=E("outline","photo","Photo",at);const it=[["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"}]],lt=E("outline","player-stop","PlayerStop",it);const ct=[["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"}]],te=E("outline","shield-check","ShieldCheck",ct),se=t=>Symbol.iterator in t,ne=t=>"entries"in t,re=(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},dt=(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 ut(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:se(t)&&se(s)?ne(t)&&ne(s)?re(t,s):dt(t,s):re({entries:()=>Object.entries(t)},{entries:()=>Object.entries(s)})}function ae(t){const s=De.useRef(void 0);return n=>{const a=t(n);return ut(s.current,a)?s.current:s.current=a}}function mt(t){return t.nativeEvent?.isComposing===!0}const K=[{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 pt(t){if(!t.startsWith("/"))return!1;const s=t.split(/\s+/)[0].toLowerCase();return K.some(n=>n.name===s&&n.local)}function ft({currentInput:t,applyText:s}){const[n,a]=l.useState([]),o=l.useRef(-1),i=l.useRef(""),c=l.useCallback(N=>{a(k=>[...k,N]),o.current=-1,i.current=""},[]),x=l.useCallback(()=>{if(n.length===0)return!1;const N=o.current,k=N===-1?n.length-1:Math.max(0,N-1);return N===-1&&(i.current=t),o.current=k,s(n[k]),!0},[n,t,s]),u=l.useCallback(()=>{const N=o.current;return N===-1?!1:(N<n.length-1?(o.current=N+1,s(n[N+1])):(o.current=-1,s(i.current)),!0)},[n,s]),f=l.useCallback(()=>o.current!==-1,[]),j=l.useCallback(()=>n.length,[n.length]);return{push:c,recallPrev:x,recallNext:u,isNavigating:f,size:j}}function ht(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function gt({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(ot,{className:"size-5 text-muted-foreground"}):e.jsx(et,{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:ht(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(me,{className:"size-2.5"})})]})}function xt({attachments:t,onRemove:s,compact:n=!1}){return t.length===0?null:e.jsx("div",{className:M("flex gap-2 overflow-x-auto","px-3 pt-3"),children:t.map(a=>e.jsx(gt,{attachment:a,onRemove:()=>s(a.id)},a.id))})}function oe(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 bt(){return Date.now().toString(36)+Math.random().toString(36).slice(2,8)}const vt=l.forwardRef(function({isLoading:s,onSubmit:n,onAbort:a},o){const[i,c]=l.useState(""),[x,u]=l.useState(!1),[f,j]=l.useState(!1),[N,k]=l.useState(""),[S,C]=l.useState(0),[g,d]=l.useState([]),[p,m]=l.useState(!1),h=l.useRef(null),b=l.useRef(null),v=l.useRef(null),{data:R,isLoading:A}=Fe(),z=R?.models??[],[D,G]=l.useState("");l.useEffect(()=>{if(!z.length||D&&z.some(w=>w.id===D))return;const r=R?.default_model||z[0]?.id;r&&G(r)},[z,R?.default_model,D]);const q=z.find(r=>r.id===D),O=l.useCallback(()=>{const r=h.current;r&&(r.style.height="auto",r.style.height=`${Math.min(r.scrollHeight,200)}px`)},[]),ve=l.useCallback(r=>{c(r),requestAnimationFrame(()=>{O(),h.current?.setSelectionRange(r.length,r.length)})},[O]),T=ft({currentInput:i,applyText:ve});l.useImperativeHandle(o,()=>({setText(r){c(r),requestAnimationFrame(()=>{O(),h.current?.focus()})},clear(){c(""),h.current&&(h.current.style.height="auto")},focus(){h.current?.focus()}}),[O]),l.useEffect(()=>{s||h.current?.focus()},[s]),l.useEffect(()=>{if(!f)return;function r(w){b.current&&!b.current.contains(w.target)&&j(!1)}return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[f]),l.useEffect(()=>{if(!f)return;b.current?.querySelector(".slash-item-active")?.scrollIntoView({block:"nearest"})},[S,f]);const $=l.useMemo(()=>f?K.filter(r=>r.name.toLowerCase().startsWith(N.toLowerCase())):[],[f,N]),P=l.useCallback(r=>{const w=Array.from(r).map(_=>({id:bt(),name:_.name,type:_.type||"application/octet-stream",size:_.size,file:_,previewUrl:_.type.startsWith("image/")?URL.createObjectURL(_):void 0}));d(_=>[..._,...w])},[]),ye=l.useCallback(r=>{d(w=>{const _=w.find(L=>L.id===r);return _?.previewUrl&&URL.revokeObjectURL(_.previewUrl),w.filter(L=>L.id!==r)})},[]);l.useEffect(()=>()=>{g.forEach(r=>{r.previewUrl&&URL.revokeObjectURL(r.previewUrl)})},[]);const we=l.useCallback(r=>{r.preventDefault(),r.stopPropagation(),m(!0)},[]),je=l.useCallback(r=>{r.preventDefault(),r.stopPropagation(),(r.currentTarget===r.target||!r.currentTarget.contains(r.relatedTarget))&&m(!1)},[]),Ne=l.useCallback(r=>{r.preventDefault(),r.stopPropagation(),m(!1),r.dataTransfer.files.length>0&&P(r.dataTransfer.files)},[P]),Se=l.useCallback(r=>{const w=r.clipboardData?.items;if(!w)return;const _=[];for(let L=0;L<w.length;L++){const H=w[L];if(H.type.startsWith("image/")){const Y=H.getAsFile();if(Y){const _e=H.type.split("/")[1]||"png",Me=new File([Y],`pasted-image-${Date.now()}.${_e}`,{type:H.type});_.push(Me)}}}_.length>0&&(r.preventDefault(),P(_))},[P]);function ke(r){T.push(r),c(""),h.current&&(h.current.style.height="auto")}function V(){const r=i.trim();!r||s||(j(!1),ke(r),n(r,g),d([]))}function X(r){if(j(!1),r.local||r.category==="info"){c(""),h.current&&(h.current.style.height="auto"),n(r.name);return}c(r.name+" "),h.current?.focus()}function Ce(r){const w=r.target.value;c(w),O(),w.startsWith("/")&&!w.includes(" ")?(j(!0),k(w),C(0)):f&&j(!1)}function Re(r){if(!mt(r)){if(f&&$.length>0){if(r.key==="ArrowDown"){r.preventDefault(),C(w=>w<$.length-1?w+1:0);return}if(r.key==="ArrowUp"){r.preventDefault(),C(w=>w>0?w-1:$.length-1);return}if(r.key==="Enter"||r.key==="Tab"){r.preventDefault(),X($[S]);return}if(r.key==="Escape"){r.preventDefault(),j(!1);return}}if(!f&&(T.isNavigating()||!i.includes(`
3
+ `))){if(r.key==="ArrowUp"&&T.size()>0&&T.recallPrev()){r.preventDefault();return}if(r.key==="ArrowDown"&&T.isNavigating()&&T.recallNext()){r.preventDefault();return}}r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),V())}}const Q=i.trim().length>0;return e.jsxs("div",{className:"w-full max-w-3xl mx-auto flex flex-col gap-2 relative",children:[f&&$.length>0&&e.jsxs("div",{ref:b,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(Ye,{className:"size-3"}),"Commands"]}),e.jsx("div",{className:"max-h-[240px] overflow-y-auto py-1",children:$.map((r,w)=>e.jsxs("button",{className:M("w-full flex items-center gap-2 px-3 py-2 text-sm transition-colors text-left",w===S?"bg-accent text-accent-foreground slash-item-active":"hover:bg-accent/50"),onMouseEnter:()=>C(w),onClick:()=>X(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:M("flex min-h-[80px] flex-col rounded-2xl cursor-text bg-card border shadow-lg transition-colors",p?"border-primary border-dashed":"border-border"),onDragOver:we,onDragLeave:je,onDrop:Ne,children:[e.jsx(xt,{attachments:g,onRemove:ye,compact:!0}),e.jsx("div",{className:"flex-1 relative overflow-y-auto max-h-[200px]",children:e.jsx(Pe,{ref:h,value:i,onChange:Ce,onKeyDown:Re,onPaste:Se,onCompositionStart:()=>u(!0),onCompositionEnd:()=>u(!1),placeholder:"Ask anything…",rows:1,className:M("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:()=>v.current?.click(),children:e.jsx(rt,{className:"h-5 w-5"})}),e.jsxs(pe,{children:[e.jsxs(fe,{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(We,{className:"h-4 w-4 shrink-0"}),A&&e.jsx(U,{className:"h-3.5 w-3.5 animate-spin shrink-0"}),e.jsx("span",{className:M(A&&"opacity-60"),children:A?"Loading…":q?oe(q):"Select model"})]}),e.jsx(he,{align:"start",className:"max-h-[300px] overflow-y-auto min-w-48",children:z.map(r=>e.jsxs(W,{onClick:()=>G(r.id),className:M("flex-col items-start py-2",r.id===D&&"bg-muted"),children:[e.jsx("span",{className:"text-sm",children:oe(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:s?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:a,title:"Stop generating",children:e.jsx(lt,{className:"h-4 w-4"})}):e.jsx(I,{variant:"ghost",size:"icon-sm",className:M("rounded-full transition-colors cursor-pointer",Q?"bg-primary hover:bg-primary/90 text-primary-foreground":"bg-primary text-primary-foreground opacity-40"),disabled:!Q,onClick:V,title:"Send message",children:e.jsx(Be,{className:"h-4 w-4"})})})]})]}),e.jsx("input",{ref:v,type:"file",multiple:!0,accept:"image/*",className:"hidden",onChange:r=>{r.target.files?.length&&(P(r.target.files),r.target.value="")}})]})}),yt=l.memo(function({sessionId:s,title:n,hasMessages:a,onNewChat:o,onClear:i}){const c=ge(),x=y(f=>f.deleteSession),u=async()=>{try{await Le(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(Ue,{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(Z,{className:"size-3.5"})}),e.jsxs(pe,{children:[e.jsx(fe,{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(Ae,{className:"size-3.5"})})}),e.jsxs(he,{align:"end",side:"bottom",sideOffset:4,children:[e.jsxs(W,{className:"gap-2 text-xs",onClick:()=>{const f=prompt("Rename conversation",n||"");f?.trim()&&(Ee(s,f.trim()),y.getState().updateSession(s,{title:f.trim()}))},children:[e.jsx(ze,{className:"size-3"}),"Rename"]}),e.jsxs(W,{className:"gap-2 text-xs text-destructive",onClick:u,children:[e.jsx(Z,{className:"size-3"}),"Delete"]})]})]})]})]})}),wt=[{label:"Search the web",text:"Search the web for today's top tech news",Icon:xe},{label:"Set a reminder",text:"Set a reminder to check emails every day at 9 AM",Icon:Ie},{label:"Read emails",text:"Read my latest emails and summarize them",Icon:st},{label:"Write a script",text:"Write a Python script to rename all files in a folder",Icon:Je},{label:"Schedule a job",text:"Schedule a cron job to back up my database every night",Icon:He},{label:"Analyze data",text:"Analyze this CSV file and show key insights",Icon:Xe}],jt=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(xe,{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:wt.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))})]})}),Nt=l.lazy(()=>Te(()=>import("./syntax-highlighter-BuOqgzbp.js"),__vite__mapDeps([0,1,2])).then(t=>({default:t.SyncHighlighter})));function B({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(F,{className:"size-3"}):e.jsx(be,{className:"size-3"})})}function St({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(F,{className:"size-3"}):e.jsx(be,{className:"size-3"}),s?"Copied":"Copy"]})}function kt(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 ie({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()),u=l.useRef(null);if(l.useEffect(()=>{if(s&&n&&!a)return u.current=setInterval(()=>x(Date.now()),1e3),()=>{u.current&&clearInterval(u.current)};u.current&&(clearInterval(u.current),u.current=null)},[s,n,a]),!t.trim())return null;const f=n?Math.max(0,(a??(s?c:n))-n):null,j=[...t].length,N=s&&n&&!a;return e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{onClick:()=>i(!o),className:M("inline-flex items-center gap-1.5 text-[11px] transition-colors",N?"text-amber-500 dark:text-amber-400 font-medium":"text-muted-foreground/70 hover:text-foreground"),children:[e.jsx(J,{className:M("size-3 shrink-0 transition-transform",o&&"rotate-90")}),N?e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(U,{className:"size-2.5 animate-spin"}),"thinking…"]}):e.jsx("span",{children:"thought"}),f!==null&&f>0&&e.jsxs("span",{className:"text-muted-foreground/60 tabular-nums",children:["· ",kt(f)]}),e.jsxs("span",{className:"text-muted-foreground/60",children:["· ",j.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 Ct({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(J,{className:M("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 le(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 ce({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(J,{className:M("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(U,{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 u=le(c.preview),f=le(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(U,{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"})]}),u&&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(B,{text:u.text})]}),e.jsx("div",{className:"px-2.5 pb-1.5",children:e.jsx("pre",{className:M("text-[10px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap max-h-[200px] overflow-y-auto rounded",u.isJson?"bg-slate-900/10 dark:bg-slate-900/40 text-foreground/80 px-2 py-1":"text-muted-foreground/70"),children:u.text})})]}),f&&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(B,{text:f.text})]}),e.jsx("div",{className:"px-2.5 pb-1.5",children:e.jsx("pre",{className:M("text-[10px] leading-relaxed overflow-x-auto font-mono whitespace-pre-wrap max-h-[200px] overflow-y-auto rounded",f.isJson?"bg-slate-900/10 dark:bg-slate-900/40 text-foreground/80 px-2 py-1":"text-muted-foreground/70"),children:f.text})})]})]},c.callId||`${c.name}-${x}`)})})]})}function Rt({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(B,{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(Nt,{language:t,value:s})})]})}const _t={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(Rt,{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})}},Mt=/[\u2500-\u257F]/;function Dt(t){return Mt.test(t)}function At(t){const s=t.split(`
4
+ `),n=[];let a=!1;for(let o=0;o<s.length;o++){const i=s[o],c=Dt(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 de({content:t,isStreaming:s}){const n=At(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(Ke,{remarkPlugins:[Ge],components:_t,children:n})})}function zt(t){if(!t||isNaN(t))return null;try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return null}}function Et({message:t}){const s=t.role==="user",n=t.role==="tool",a=!!t.content?.trim(),o=!!t.reasoning?.trim(),i=!!t.toolCalls?.length,c=zt(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(ie,{reasoning:t.reasoning,isStreaming:t.isStreaming,startedAt:t.reasoningStartedAt,endedAt:t.reasoningEndedAt}),!n&&i&&e.jsx(ce,{tools:t.toolCalls}),n&&e.jsx(Ct,{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:M("flex px-4",s?"py-2 justify-end":"py-4 justify-start"),children:e.jsxs("div",{className:M("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(U,{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(ie,{reasoning:t.reasoning,isStreaming:t.isStreaming,startedAt:t.reasoningStartedAt,endedAt:t.reasoningEndedAt}),!n&&!s&&i&&e.jsx(ce,{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(de,{content:t.content,isStreaming:t.isStreaming})}):e.jsx("div",{className:"text-base leading-relaxed",children:e.jsx(de,{content:t.content,isStreaming:t.isStreaming})}))]}),a&&!s&&e.jsx("div",{className:"mt-1 flex items-center gap-2 px-1",children:e.jsx(St,{text:t.content})}),c&&e.jsx("span",{className:"mt-1 text-[10px] text-muted-foreground/50 px-1",children:c})]})})}const Lt=l.memo(Et),It=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(Lt,{message:o},o.id))})});function Tt(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 u=x.scrollHeight-x.scrollTop-x.clientHeight<80;a.current=!u},[]);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 $t="http://localhost:8788";async function*Ot(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(`${$t}/api/chat/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:o});if(!c.ok){const j=await c.text().catch(()=>"Stream request failed");throw new Error(j)}if(!c.body)throw new Error("No response body");const x=c.body.getReader(),u=new TextDecoder;let f="";try{for(;;){const{done:j,value:N}=await x.read();if(j)break;f+=u.decode(N,{stream:!0});let k=f.indexOf(`
6
+
7
+ `);for(;k>=0;){const S=f.slice(0,k);f=f.slice(k+2);let C="",g="";for(const d of S.split(`
8
+ `))d.startsWith("event: ")?C=d.slice(7).trim():d.startsWith("data: ")&&(g+=(g?`
9
+ `:"")+d.slice(6));if(g){let d={};try{d=JSON.parse(g)}catch{d={raw:g}}yield{type:C||"unknown",data:d}}k=f.indexOf(`
10
+
11
+ `)}}}finally{x.releaseLock()}}let Pt=0;function ue(){return`msg-${++Pt}-${Math.random().toString(36).slice(2,6)}`}function Ut(){const t=l.useRef(null),s=l.useCallback((o,i)=>{y.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(y.getState().streamingSessions.has(i))return;const u={id:ue(),role:"user",content:o,timestamp:Date.now()};y.setState(g=>{if(!g.sessions.find(p=>p.id===i)){const p=Date.now();return{sessions:[{id:i,title:o.slice(0,64),model:c||"",messages:[u],createdAt:p,updatedAt:p},...g.sessions]}}return{sessions:g.sessions.map(p=>p.id===i?{...p,messages:[...p.messages,u],title:!p.title||p.title==="New Conversation"||p.title==="Untitled"?o.slice(0,64):p.title}:p)}});const f=y.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}))||[],N={id:ue(),role:"assistant",content:"",timestamp:Date.now(),isStreaming:!0};y.setState(g=>({sessions:g.sessions.map(d=>d.id===i?{...d,messages:[...d.messages,N]}:d)})),s(i,!0);const k=new AbortController;t.current=k;let S=Date.now();const C=setInterval(()=>{Date.now()-S>3e5&&(console.warn("[stream] hang timeout — aborting",i),k.abort())},3e4);try{const g=Ot({input:o,conversation:i,model:c,signal:k.signal,messages:f,attachments:x?.attachments?.map(d=>({id:d.id,name:d.name,type:d.type,size:d.size}))});for await(const d of g)switch(S=Date.now(),d.type){case"token":{const p=d.data.delta||"";if(!p)continue;y.setState(m=>({sessions:m.sessions.map(h=>{if(h.id!==i)return h;const b=h.messages.slice(),v=b[b.length-1];return v&&v.role==="assistant"&&v.isStreaming&&(b[b.length-1]={...v,content:v.content+p}),{...h,messages:b}})}));break}case"reasoning":{const p=d.data.text||"";if(!p)continue;y.setState(m=>({sessions:m.sessions.map(h=>{if(h.id!==i)return h;const b=h.messages.slice(),v=b[b.length-1];if(v&&v.role==="assistant"&&v.isStreaming){const R=v.reasoning||"";b[b.length-1]={...v,reasoning:R+p,reasoningStartedAt:v.reasoningStartedAt||Date.now()}}return{...h,messages:b}})}));break}case"tool_start":{const p=d.data.name||"tool",m=d.data.preview||"",h=d.data.tool_call_id||void 0;y.setState(b=>({sessions:b.sessions.map(v=>{if(v.id!==i)return v;const R=v.messages.slice(),A=R[R.length-1];if(A&&A.role==="assistant"&&A.isStreaming){const z=[...A.toolCalls||[],{name:p,preview:m,callId:h,status:"running"}];R[R.length-1]={...A,toolCalls:z}}return{...v,messages:R}})}));break}case"tool_end":{const p=d.data.tool_call_id,m=d.data.tool,h=d.data.output;y.setState(b=>({sessions:b.sessions.map(v=>{if(v.id!==i)return v;const R=v.messages.slice(),A=R[R.length-1];if(!A?.toolCalls)return v;const z=A.toolCalls.map(D=>p&&D.callId===p?{...D,status:"done",output:h||D.output}:!p&&D.name===m&&D.status==="running"?{...D,status:"done",output:h||D.output}:D);return R[R.length-1]={...A,toolCalls:z},{...v,messages:R}})}));break}case"done":{y.setState(p=>({sessions:p.sessions.map(m=>{if(m.id!==i)return m;const h=m.messages.map(b=>b.role==="assistant"&&b.isStreaming?{...b,isStreaming:!1,reasoningEndedAt:b.reasoning?Date.now():void 0}:b);return{...m,messages:h}})})),s(i,!1);break}case"error":{const p=d.data.error;y.setState(m=>({sessions:m.sessions.map(h=>{if(h.id!==i)return h;const b=h.messages.map(v=>v.role==="assistant"&&v.isStreaming?{...v,isStreaming:!1,content:v.content||`**Error:** ${p||"Run failed"}`}:v);return{...h,messages:b}})})),s(i,!1);break}case"approval":{y.setState(p=>({sessions:p.sessions.map(m=>m.id===i?{...m,pendingApproval:d.data}:m)}));break}case"title":{const p=d.data.title;p&&y.setState(m=>({sessions:m.sessions.map(h=>h.id===i?{...h,title:p}:h)}));break}}}catch(g){const d=g instanceof Error?g.message:"Connection error";y.setState(p=>({sessions:p.sessions.map(m=>{if(m.id!==i)return m;const h=m.messages.map(b=>b.role==="assistant"&&b.isStreaming?{...b,isStreaming:!1,content:b.content||`**Error:** ${d}`}:b);return{...m,messages:h}})})),s(i,!1)}finally{clearInterval(C),t.current=null,s(i,!1),y.setState(g=>({sessions:g.sessions.map(d=>d.id!==i||!d.messages.some(m=>m.role==="assistant"&&m.isStreaming)?d:{...d,messages:d.messages.map(m=>m.role==="assistant"&&m.isStreaming?{...m,isStreaming:!1}:m)})}))}},[s]),abortChat:n}}function Ht({sessionId:t,model:s,isLoading:n,sendMessage:a,abortChat:o}){const i=ge(),c=l.useRef(n);c.current=n;const x=l.useCallback(async(S,C)=>{const g=S.trim();if(!(!g||c.current)){if(pt(g)){const d=g.split(/\s+/)[0].toLowerCase();if(d==="/new"){const p=await ee({model:s});i({to:"/chat/$sessionId",params:{sessionId:p.id}});return}if(d==="/clear"){y.setState(p=>({sessions:p.sessions.map(m=>m.id===t?{...m,messages:[]}:m)}));return}if(d==="/help"){const p=K.map(m=>`\`${m.name}\` — ${m.description}`).join(`
12
+ `);y.setState(m=>({sessions:m.sessions.map(h=>h.id===t?{...h,messages:[...h.messages,{id:`agent-${Date.now()}`,role:"assistant",content:`**Available Commands**
13
+
14
+ ${p}`,timestamp:Date.now()}]}:h)}));return}y.setState(p=>({sessions:p.sessions.map(m=>m.id===t?{...m,messages:[...m.messages,{id:`agent-${Date.now()}`,role:"assistant",content:`Command \`${d}\` is not yet implemented in the web UI.`,timestamp:Date.now()}]}:m)}));return}await a(g,t,s,{attachments:C})}},[t,s,a,i]),u=l.useCallback(()=>{o()},[o]),f=l.useCallback(async()=>{c.current||await a("/approve",t,s)},[t,s,a]),j=l.useCallback(async()=>{c.current||await a("/deny",t,s)},[t,s,a]),N=l.useCallback(async()=>{const S=await ee({model:s});i({to:"/chat/$sessionId",params:{sessionId:S.id}})},[s,i]),k=l.useCallback(()=>{c.current&&o(),y.setState(S=>({sessions:S.sessions.map(C=>C.id===t?{...C,messages:[]}:C)}))},[t,o]);return{handleSend:x,handleAbort:u,handleApprove:f,handleDeny:j,handleNewChat:N,handleClear:k}}function Ft({sessionId:t,request:s,onResolved:n}){const[a,o]=l.useState(!1),i=async f=>{o(!0);try{await $e({session_id:t,choice:f}),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,u=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(te,{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}),u&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground leading-relaxed",children:u}),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(F,{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(F,{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(te,{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(me,{className:"h-3.5 w-3.5"}),"Deny"]})]})]})})}function Wt({sessionId:t,messages:s,title:n,model:a,pendingApproval:o}){const i=l.useRef(null),c=l.useRef(!1),{containerRef:x,bottomRef:u,onScroll:f}=Tt(s),{sendMessage:j,abortChat:N}=Ut(),k=y(g=>g.streamingSessions.has(t)),S=Ht({sessionId:t,model:a,isLoading:k,sendMessage:j,abortChat:N});l.useEffect(()=>{if(!t||c.current)return;const g=`hermium_pending_msg_${t}`,d=`hermium_pending_model_${t}`,p=sessionStorage.getItem(g);if(!p)return;c.current=!0;const m=sessionStorage.getItem(d)||a;sessionStorage.removeItem(g),sessionStorage.removeItem(d),j(p,t,m)},[t,a,j]),l.useEffect(()=>{function g(d){(d.metaKey||d.ctrlKey)&&d.key==="n"&&(d.preventDefault(),S.handleNewChat())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[S]);const C=l.useCallback(g=>{i.current?.setText(g)},[]);return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden bg-background",children:[e.jsx(yt,{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:f,children:[s.length===0&&!k?e.jsx(jt,{onSelectSuggestion:C}):e.jsx("div",{className:"mx-auto max-w-3xl",children:e.jsx(It,{messages:s,isLoading:k,onApprove:S.handleApprove,onDeny:S.handleDeny})}),e.jsx("div",{ref:u}),o&&e.jsx("div",{className:"mx-auto max-w-3xl",children:e.jsx(Ft,{sessionId:t,request:o,onResolved:()=>{y.getState().updateSession(t,{pendingApproval:null})}})})]}),e.jsx("div",{className:"shrink-0 px-4 py-3 border-t bg-card/50 backdrop-blur-sm",children:e.jsx(vt,{ref:i,isLoading:k,onSubmit:S.handleSend,onAbort:S.handleAbort})})]})}function Yt(){const{sessionId:t}=Oe.useParams(),s=y(u=>u.switchSession),n=y(u=>u.loadSessions),a=y(u=>u.loadSessionMessages),o=y(u=>u.sessionsLoaded),i=y(u=>u.isLoadingMessages),c=y(ae(u=>{const f=u.sessions.find(j=>j.id===t);return{title:f?.title,model:f?.model||"",pendingApproval:f?.pendingApproval??null}})),x=y(ae(u=>u.sessions.find(j=>j.id===t)?.messages??[]));return l.useEffect(()=>{o||n()},[o,n]),l.useEffect(()=>{if(!t)return;s(t);const u=y.getState().getSession(t);(!u||u.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(u=>e.jsxs("div",{className:"animate-pulse space-y-2",children:[e.jsx("div",{className:`h-4 rounded bg-muted ${u%2===0?"w-2/3":"w-1/2 ml-auto"}`}),e.jsx("div",{className:`h-3 rounded bg-muted ${u%2===0?"w-1/2":"w-1/3 ml-auto"}`})]},u))})})]}):e.jsx(Wt,{sessionId:t,messages:x,title:c.title,model:c.model,pendingApproval:c.pendingApproval})}export{Yt as component};
@@ -1 +1 @@
1
- import{g as F,p as D,r as o,w as z,o as R,j as e,b as i,h as U,I as k}from"./index-DKYPj90W.js";import{I as w}from"./IconLoader2-ClSf33Yd.js";import{I as S}from"./IconAlertCircle-B7TgWpbP.js";import{I as Y}from"./IconRefresh-D4MZeezY.js";import{I as B}from"./IconCheck-B-_pWgtP.js";import{M as G,r as O}from"./index-D04H-m2p.js";async function C(){return F("/api/hermes/memory")}async function T(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:R,desc:"About you & your context",emptyLabel:"No profile yet — click Edit to add details about yourself."}],W={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 X(){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 C();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),N=()=>{b(u),l(null),m(!0)},L=()=>{m(!1),l(null)},q=async()=>{_(!0),l(null);try{await T(n,g);const t=await C();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(S,{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,v=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",v?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[e.jsx(A,{className:i("size-4 shrink-0",v?"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:N,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(S,{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:W,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:N,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 Z=X;export{Z as component};
1
+ import{g as F,p as D,r as o,z as E,t as R,j as e,b as i,l as U,I as k}from"./index-twHXYGSY.js";import{I as w}from"./IconLoader2-DkEhzUxZ.js";import{I as S}from"./IconAlertCircle-C98Iam1j.js";import{I as Y}from"./IconRefresh-CCXMrUxO.js";import{I as B}from"./IconCheck-CYZ4_524.js";import{M as G,r as O}from"./index-DCT13_ZI.js";async function C(){return F("/api/hermes/memory")}async function T(r,s){return D("/api/hermes/memory/write",{section:r,content:s})}const z=[{key:"memory",label:"My Notes",icon:E,desc:"Personal notes & knowledge",emptyLabel:"No notes yet — click Edit to start writing."},{key:"user",label:"User Profile",icon:R,desc:"About you & your context",emptyLabel:"No profile yet — click Edit to add details about yourself."}],W={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 X(){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 C();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=z.find(t=>t.key===n),N=()=>{b(u),l(null),m(!0)},L=()=>{m(!1),l(null)},q=async()=>{_(!0),l(null);try{await T(n,g);const t=await C();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(S,{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(E,{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:z.map(t=>{const A=t.icon,v=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",v?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:[e.jsx(A,{className:i("size-4 shrink-0",v?"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:N,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(S,{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:W,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:N,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 Z=X;export{Z as component};