heyhank 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/assets/{AgentsPage-B-AAmsMK.js → AgentsPage-DqjDAcIw.js} +1 -1
  2. package/dist/assets/{AssistantPage-BV1Mfwdt.js → AssistantPage-C50CQFSB.js} +1 -1
  3. package/dist/assets/{BusinessPage-tLpNEz19.js → BusinessPage-AY70tf1k.js} +1 -1
  4. package/dist/assets/{CronManager-B-K_n3Jg.js → CronManager-Dt7LLuRr.js} +1 -1
  5. package/dist/assets/{HelpPage-Bhf_j6Xr.js → HelpPage-tlGx7fQF.js} +1 -1
  6. package/dist/assets/{IntegrationsPage-DAMjs9tM.js → IntegrationsPage-B4XOuHXu.js} +1 -1
  7. package/dist/assets/{JarvisHUD-C_TGXCCn.js → JarvisHUD-BDvuRd0I.js} +1 -1
  8. package/dist/assets/{MediaPage-C48HTTrt.js → MediaPage-CofV9Rd-.js} +1 -1
  9. package/dist/assets/{MemoryPage-JkC-qtgp.js → MemoryPage-Cj7FeqmJ.js} +1 -1
  10. package/dist/assets/{PlatformDashboard-AUo7tNnE.js → PlatformDashboard-B9kXAlH1.js} +1 -1
  11. package/dist/assets/{Playground-AzNMsRBL.js → Playground-Cka-pRkP.js} +1 -1
  12. package/dist/assets/{ProcessPanel-DpE_2sX3.js → ProcessPanel-BqhQgfYj.js} +1 -1
  13. package/dist/assets/{PromptsPage-C2RQOs6p.js → PromptsPage-VveKc9uX.js} +1 -1
  14. package/dist/assets/RunsPage-DXVEk0AZ.js +1 -0
  15. package/dist/assets/{SandboxManager-jHvYjwfh.js → SandboxManager-DACcwfDF.js} +1 -1
  16. package/dist/assets/{SettingsPage-BBJax6gt.js → SettingsPage-jfuQh8Tu.js} +1 -1
  17. package/dist/assets/{SkillsMarketplace-IjmjfdjD.js → SkillsMarketplace-DrigiApe.js} +1 -1
  18. package/dist/assets/{SocialMediaPage-DoPZHhr2.js → SocialMediaPage-DOh3IPe8.js} +1 -1
  19. package/dist/assets/{TailscalePage-DDEY7ckO.js → TailscalePage-DLhJWATT.js} +1 -1
  20. package/dist/assets/{TelephonyPage-OPNBZYKt.js → TelephonyPage-9C4C3_ot.js} +1 -1
  21. package/dist/assets/{TerminalPage-BjMbHHW3.js → TerminalPage-ChX-8Wu7.js} +1 -1
  22. package/dist/assets/index-C6Q5UQHD.js +229 -0
  23. package/dist/assets/index-ZxGXgiV3.css +32 -0
  24. package/dist/assets/sw-register-BBYuk-kw.js +1 -0
  25. package/dist/assets/workbox-window.prod.es5-BBnX5xw4.js +2 -0
  26. package/dist/index.html +2 -2
  27. package/dist/sw.js +1 -1
  28. package/dist/{workbox-d2a0910a.js → workbox-080c8b91.js} +1 -1
  29. package/package.json +1 -1
  30. package/server/agent-executor.ts +65 -0
  31. package/server/execution-store.ts +54 -1
  32. package/server/routes/agent-routes.ts +42 -0
  33. package/dist/assets/RunsPage-B9UOyO79.js +0 -1
  34. package/dist/assets/index-BgYM4wXw.js +0 -205
  35. package/dist/assets/index-BkjSoVgn.css +0 -32
  36. package/dist/assets/sw-register-C7NOHtIu.js +0 -1
  37. package/dist/assets/workbox-window.prod.es5-BIl4cyR9.js +0 -2
@@ -1 +1 @@
1
- import{r as s,b as $,j as e}from"./index-BgYM4wXw.js";function m(){const b=localStorage.getItem("heyhank_auth_token");return b?{Authorization:`Bearer ${b}`,"Content-Type":"application/json"}:{"Content-Type":"application/json"}}function ce({embedded:b=!1}){const[C,y]=s.useState([]),[z,I]=s.useState(!0),[r,E]=s.useState(""),[x,P]=s.useState(""),[M,A]=s.useState(!1),[O,R]=s.useState("local"),[i,j]=s.useState(null),[u,p]=s.useState(""),[h,T]=s.useState(""),[D,G]=s.useState(!1),[U,v]=s.useState(!1),[N,H]=s.useState(!1),[l,L]=s.useState(null),[w,Q]=s.useState("auto"),[V,g]=s.useState(!1),[ee,J]=s.useState(null),[te,se]=s.useState(!1),[f,S]=s.useState(null),[B,o]=s.useState(null),d=s.useCallback(async()=>{I(!0);try{const t=r?`/api/memory/search?q=${encodeURIComponent(r)}`:"/api/memory",a=await(await fetch(t,{headers:m()})).json();y(a.memories||[]),a.backend&&R(a.backend)}catch{}I(!1)},[r]);s.useEffect(()=>{d()},[d]),s.useEffect(()=>{$.getSettings().then(t=>{t.obsidianVaultPath&&T(t.obsidianVaultPath)}).catch(()=>{})},[]);const F=async()=>{if(x.trim()){A(!0);try{await fetch("/api/memory",{method:"POST",headers:m(),body:JSON.stringify({content:x})}),P(""),d()}catch{}A(!1)}},_=async t=>{try{await fetch(`/api/memory/${t}`,{method:"DELETE",headers:m()}),y(c=>c.filter(a=>a.id!==t))}catch{}},q=t=>{j(t.id),p(t.content)},K=()=>{j(null),p("")},W=async()=>{if(!(!i||!u.trim())){try{(await fetch(`/api/memory/${i}`,{method:"PUT",headers:m(),body:JSON.stringify({content:u.trim()})})).ok&&y(c=>c.map(a=>a.id===i?{...a,content:u.trim()}:a))}catch{}j(null),p("")}},X=async()=>{var t;if(l){g(!0),o(null),J(null);try{const c=await l.text();let a;try{a=JSON.parse(c)}catch{o("Could not parse file. Please upload a JSON file (conversations.json, memories.json, or conversation.json from your AI platform export)."),g(!1);return}const k=await fetch("/api/memory/import",{method:"POST",headers:m(),body:JSON.stringify({data:a,platform:w==="auto"?void 0:w,options:{mode:"both",extractFacts:!0,maxConversations:500}})});if(!k.ok){const Z=await k.json().catch(()=>({error:"Import failed"}));o(Z.error||"Import failed"),g(!1);return}const n=await k.json();((t=n.errors)==null?void 0:t.length)>0&&n.saved===0?o(n.errors.join(", ")):(S({saved:n.saved,platform:n.platform,message:n.message}),d())}catch(c){o(c instanceof Error?c.message:"Import failed")}g(!1)}},Y=()=>{L(null),J(null),S(null),o(null),H(!1)};return e.jsx("div",{className:"h-full overflow-y-auto bg-cc-bg",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Memory"}),e.jsxs("p",{className:"text-sm text-cc-muted mt-1",children:["What Hank remembers about you.",O==="semantic"&&e.jsx("span",{className:"ml-1 text-green-500 text-xs",children:"(Semantic search ✓)"}),O==="local-keyword"&&e.jsx("span",{className:"ml-1 text-yellow-500 text-xs",children:"(Keyword search — model loading...)"})]})]}),e.jsx("button",{type:"button",onClick:()=>H(!N),className:"px-3 py-1.5 text-xs font-medium rounded-md bg-cc-hover text-cc-muted hover:text-cc-fg border border-cc-border hover:border-cc-fg/30 transition-colors",children:N?"Cancel":"Import"})]}),N&&e.jsxs("div",{className:"p-4 rounded-lg border border-cc-border bg-cc-card space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-cc-fg mb-1",children:"Import Memories"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Import from Claude, ChatGPT, or Gemini. Upload your exported JSON file (conversations.json, memories.json, etc.)"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{className:"text-xs text-cc-muted",children:"Platform:"}),e.jsx("div",{className:"flex gap-1",children:["auto","chatgpt","claude","gemini"].map(t=>e.jsx("button",{type:"button",onClick:()=>Q(t),className:`px-2.5 py-1 text-xs rounded-md transition-colors ${w===t?"bg-cc-accent text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t==="auto"?"Auto-detect":t==="chatgpt"?"ChatGPT":t==="claude"?"Claude":"Gemini"},t))})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("label",{className:"flex-1 flex items-center gap-2 px-3 py-2.5 rounded-lg border border-dashed border-cc-border hover:border-cc-fg/30 cursor-pointer transition-colors",children:[e.jsxs("svg",{className:"w-4 h-4 text-cc-muted",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),e.jsx("span",{className:"text-xs text-cc-muted",children:l?l.name:"Choose JSON file..."}),e.jsx("input",{type:"file",accept:".json",className:"hidden",onChange:t=>{var c;L(((c=t.target.files)==null?void 0:c[0])||null),S(null),o(null)}})]}),e.jsx("button",{type:"button",onClick:X,disabled:!l||V,className:"px-4 py-2 text-xs font-medium rounded-md bg-cc-accent text-white hover:bg-cc-accent/80 disabled:opacity-30 transition-colors",children:V?"Importing...":"Import"})]}),B&&e.jsx("div",{className:"px-3 py-2 rounded-md bg-red-500/10 border border-red-500/20 text-xs text-red-400",children:B}),f&&e.jsxs("div",{className:"px-3 py-2 rounded-md bg-green-500/10 border border-green-500/20 text-xs text-green-400",children:[e.jsxs("p",{className:"font-medium",children:[f.saved," memories imported from ",f.platform]}),e.jsx("p",{className:"mt-1 text-green-400/70",children:f.message}),e.jsx("button",{type:"button",onClick:Y,className:"mt-2 text-xs text-cc-muted hover:text-cc-fg transition-colors",children:"Close"})]}),e.jsxs("div",{className:"text-[11px] text-cc-muted space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-cc-fg/70",children:"ChatGPT:"})," Settings → Data Controls → Export → upload ",e.jsx("code",{className:"text-cc-primary/70",children:"conversations.json"})," or ",e.jsx("code",{className:"text-cc-primary/70",children:"memories.json"})]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-cc-fg/70",children:"Claude:"})," Settings → Account → Export Data → upload ",e.jsx("code",{className:"text-cc-primary/70",children:"conversations.json"})]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-cc-fg/70",children:"Gemini:"})," Google Takeout → Gemini Apps → upload ",e.jsx("code",{className:"text-cc-primary/70",children:"conversation.json"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:t=>E(t.target.value),placeholder:"Search memories...",className:"flex-1 px-3 py-2 text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-primary",onKeyDown:t=>{t.key==="Enter"&&d()}}),r&&e.jsx("button",{type:"button",onClick:()=>{E("")},className:"px-3 py-2 text-sm rounded-lg bg-cc-hover text-cc-muted hover:text-cc-fg transition-colors",children:"Clear"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:x,onChange:t=>P(t.target.value),placeholder:"Add a memory... (e.g. 'I prefer dark mode' or 'My timezone is CET')",className:"flex-1 px-3 py-2 text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-primary",onKeyDown:t=>{t.key==="Enter"&&F()}}),e.jsx("button",{type:"button",onClick:F,disabled:!x.trim()||M,className:"px-4 py-2 text-sm rounded-lg bg-cc-primary text-white font-medium disabled:opacity-30 hover:bg-cc-primary/90 transition-colors",children:M?"...":"Add"})]}),z?e.jsx("div",{className:"text-center py-8 text-sm text-cc-muted",children:"Loading..."}):C.length===0?e.jsxs("div",{className:"text-center py-12 space-y-3",children:[e.jsx("svg",{className:"w-10 h-10 mx-auto text-cc-muted/40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"})}),e.jsx("p",{className:"text-sm text-cc-muted",children:r?"No memories found for this search.":"No memories yet"}),!r&&e.jsx("p",{className:"text-xs text-cc-muted/70 max-w-xs mx-auto",children:"Add a memory above, or chat with Hank — it will remember things about you automatically."})]}):e.jsx("div",{className:"space-y-2",children:C.map(t=>{var c;return e.jsxs("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg border border-cc-border bg-cc-card group",children:[e.jsx("div",{className:"flex-1 min-w-0",children:i===t.id?e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{value:u,onChange:a=>p(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),W()),a.key==="Escape"&&K()},className:"w-full px-2 py-1.5 text-sm bg-cc-bg rounded border border-cc-primary/40 text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary resize-none",rows:2,autoFocus:!0}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:W,className:"px-2.5 py-1 text-xs rounded bg-cc-primary text-white hover:bg-cc-primary/90 transition-colors",children:"Save"}),e.jsx("button",{type:"button",onClick:K,className:"px-2.5 py-1 text-xs rounded text-cc-muted hover:text-cc-fg transition-colors",children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-cc-fg",children:t.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.createdAt&&e.jsxs("span",{className:"text-xs text-cc-muted",children:[new Date(t.createdAt).toLocaleDateString()," ",new Date(t.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]}),((c=t.metadata)==null?void 0:c.source)==="auto-extracted"&&e.jsx("span",{className:"text-[10px] text-cc-primary/70 bg-cc-primary/10 px-1.5 py-0.5 rounded",children:"auto"})]})]})}),i!==t.id&&e.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{type:"button",onClick:()=>q(t),className:"text-cc-muted hover:text-cc-fg transition-colors p-1",title:"Edit memory",children:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),e.jsx("button",{type:"button",onClick:()=>_(t.id),className:"text-cc-muted hover:text-red-400 transition-colors p-1",title:"Delete memory",children:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]},t.id)})}),e.jsxs("div",{className:"border-t border-cc-border pt-4 mt-6",children:[e.jsx("h3",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider mb-3",children:"Obsidian Vault Sync"}),e.jsx("p",{className:"text-[11px] text-cc-muted mb-3",children:"Sync memories as Markdown files to your Obsidian vault. Changes in Obsidian are synced back automatically."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:h,onChange:t=>{T(t.target.value),v(!1)},placeholder:"/path/to/your/obsidian/vault",className:"flex-1 px-3 py-2 text-sm bg-cc-input border border-cc-border rounded-md text-cc-fg placeholder-cc-muted focus:outline-none focus:border-cc-accent"}),e.jsx("button",{type:"button",disabled:D,onClick:async()=>{G(!0);try{await $.updateSettings({obsidianVaultPath:h.trim()}),v(!0),setTimeout(()=>v(!1),3e3)}catch{}G(!1)},className:"px-4 py-2 text-xs font-medium rounded-md bg-cc-accent text-white hover:bg-cc-accent/80 disabled:opacity-50 cursor-pointer",children:D?"Saving...":U?"Saved!":"Save"})]}),h&&e.jsxs("p",{className:"text-[10px] text-cc-muted mt-2",children:["Memories will be synced to: ",e.jsxs("code",{className:"text-cc-fg",children:[h,"/HeyHank/"]})]})]})]})})}export{ce as MemoryPage};
1
+ import{r as s,b as $,j as e}from"./index-C6Q5UQHD.js";function m(){const b=localStorage.getItem("heyhank_auth_token");return b?{Authorization:`Bearer ${b}`,"Content-Type":"application/json"}:{"Content-Type":"application/json"}}function ce({embedded:b=!1}){const[C,y]=s.useState([]),[z,I]=s.useState(!0),[r,E]=s.useState(""),[x,P]=s.useState(""),[M,A]=s.useState(!1),[O,R]=s.useState("local"),[i,j]=s.useState(null),[u,p]=s.useState(""),[h,T]=s.useState(""),[D,G]=s.useState(!1),[U,v]=s.useState(!1),[N,H]=s.useState(!1),[l,L]=s.useState(null),[w,Q]=s.useState("auto"),[V,g]=s.useState(!1),[ee,J]=s.useState(null),[te,se]=s.useState(!1),[f,S]=s.useState(null),[B,o]=s.useState(null),d=s.useCallback(async()=>{I(!0);try{const t=r?`/api/memory/search?q=${encodeURIComponent(r)}`:"/api/memory",a=await(await fetch(t,{headers:m()})).json();y(a.memories||[]),a.backend&&R(a.backend)}catch{}I(!1)},[r]);s.useEffect(()=>{d()},[d]),s.useEffect(()=>{$.getSettings().then(t=>{t.obsidianVaultPath&&T(t.obsidianVaultPath)}).catch(()=>{})},[]);const F=async()=>{if(x.trim()){A(!0);try{await fetch("/api/memory",{method:"POST",headers:m(),body:JSON.stringify({content:x})}),P(""),d()}catch{}A(!1)}},_=async t=>{try{await fetch(`/api/memory/${t}`,{method:"DELETE",headers:m()}),y(c=>c.filter(a=>a.id!==t))}catch{}},q=t=>{j(t.id),p(t.content)},K=()=>{j(null),p("")},W=async()=>{if(!(!i||!u.trim())){try{(await fetch(`/api/memory/${i}`,{method:"PUT",headers:m(),body:JSON.stringify({content:u.trim()})})).ok&&y(c=>c.map(a=>a.id===i?{...a,content:u.trim()}:a))}catch{}j(null),p("")}},X=async()=>{var t;if(l){g(!0),o(null),J(null);try{const c=await l.text();let a;try{a=JSON.parse(c)}catch{o("Could not parse file. Please upload a JSON file (conversations.json, memories.json, or conversation.json from your AI platform export)."),g(!1);return}const k=await fetch("/api/memory/import",{method:"POST",headers:m(),body:JSON.stringify({data:a,platform:w==="auto"?void 0:w,options:{mode:"both",extractFacts:!0,maxConversations:500}})});if(!k.ok){const Z=await k.json().catch(()=>({error:"Import failed"}));o(Z.error||"Import failed"),g(!1);return}const n=await k.json();((t=n.errors)==null?void 0:t.length)>0&&n.saved===0?o(n.errors.join(", ")):(S({saved:n.saved,platform:n.platform,message:n.message}),d())}catch(c){o(c instanceof Error?c.message:"Import failed")}g(!1)}},Y=()=>{L(null),J(null),S(null),o(null),H(!1)};return e.jsx("div",{className:"h-full overflow-y-auto bg-cc-bg",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-cc-fg",children:"Memory"}),e.jsxs("p",{className:"text-sm text-cc-muted mt-1",children:["What Hank remembers about you.",O==="semantic"&&e.jsx("span",{className:"ml-1 text-green-500 text-xs",children:"(Semantic search ✓)"}),O==="local-keyword"&&e.jsx("span",{className:"ml-1 text-yellow-500 text-xs",children:"(Keyword search — model loading...)"})]})]}),e.jsx("button",{type:"button",onClick:()=>H(!N),className:"px-3 py-1.5 text-xs font-medium rounded-md bg-cc-hover text-cc-muted hover:text-cc-fg border border-cc-border hover:border-cc-fg/30 transition-colors",children:N?"Cancel":"Import"})]}),N&&e.jsxs("div",{className:"p-4 rounded-lg border border-cc-border bg-cc-card space-y-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-semibold text-cc-fg mb-1",children:"Import Memories"}),e.jsx("p",{className:"text-xs text-cc-muted",children:"Import from Claude, ChatGPT, or Gemini. Upload your exported JSON file (conversations.json, memories.json, etc.)"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("label",{className:"text-xs text-cc-muted",children:"Platform:"}),e.jsx("div",{className:"flex gap-1",children:["auto","chatgpt","claude","gemini"].map(t=>e.jsx("button",{type:"button",onClick:()=>Q(t),className:`px-2.5 py-1 text-xs rounded-md transition-colors ${w===t?"bg-cc-accent text-white":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t==="auto"?"Auto-detect":t==="chatgpt"?"ChatGPT":t==="claude"?"Claude":"Gemini"},t))})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("label",{className:"flex-1 flex items-center gap-2 px-3 py-2.5 rounded-lg border border-dashed border-cc-border hover:border-cc-fg/30 cursor-pointer transition-colors",children:[e.jsxs("svg",{className:"w-4 h-4 text-cc-muted",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),e.jsx("span",{className:"text-xs text-cc-muted",children:l?l.name:"Choose JSON file..."}),e.jsx("input",{type:"file",accept:".json",className:"hidden",onChange:t=>{var c;L(((c=t.target.files)==null?void 0:c[0])||null),S(null),o(null)}})]}),e.jsx("button",{type:"button",onClick:X,disabled:!l||V,className:"px-4 py-2 text-xs font-medium rounded-md bg-cc-accent text-white hover:bg-cc-accent/80 disabled:opacity-30 transition-colors",children:V?"Importing...":"Import"})]}),B&&e.jsx("div",{className:"px-3 py-2 rounded-md bg-red-500/10 border border-red-500/20 text-xs text-red-400",children:B}),f&&e.jsxs("div",{className:"px-3 py-2 rounded-md bg-green-500/10 border border-green-500/20 text-xs text-green-400",children:[e.jsxs("p",{className:"font-medium",children:[f.saved," memories imported from ",f.platform]}),e.jsx("p",{className:"mt-1 text-green-400/70",children:f.message}),e.jsx("button",{type:"button",onClick:Y,className:"mt-2 text-xs text-cc-muted hover:text-cc-fg transition-colors",children:"Close"})]}),e.jsxs("div",{className:"text-[11px] text-cc-muted space-y-1",children:[e.jsxs("p",{children:[e.jsx("strong",{className:"text-cc-fg/70",children:"ChatGPT:"})," Settings → Data Controls → Export → upload ",e.jsx("code",{className:"text-cc-primary/70",children:"conversations.json"})," or ",e.jsx("code",{className:"text-cc-primary/70",children:"memories.json"})]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-cc-fg/70",children:"Claude:"})," Settings → Account → Export Data → upload ",e.jsx("code",{className:"text-cc-primary/70",children:"conversations.json"})]}),e.jsxs("p",{children:[e.jsx("strong",{className:"text-cc-fg/70",children:"Gemini:"})," Google Takeout → Gemini Apps → upload ",e.jsx("code",{className:"text-cc-primary/70",children:"conversation.json"})]})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r,onChange:t=>E(t.target.value),placeholder:"Search memories...",className:"flex-1 px-3 py-2 text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-primary",onKeyDown:t=>{t.key==="Enter"&&d()}}),r&&e.jsx("button",{type:"button",onClick:()=>{E("")},className:"px-3 py-2 text-sm rounded-lg bg-cc-hover text-cc-muted hover:text-cc-fg transition-colors",children:"Clear"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:x,onChange:t=>P(t.target.value),placeholder:"Add a memory... (e.g. 'I prefer dark mode' or 'My timezone is CET')",className:"flex-1 px-3 py-2 text-sm bg-cc-bg rounded-lg border border-cc-border text-cc-fg placeholder:text-cc-muted/60 focus:outline-none focus:ring-1 focus:ring-cc-primary",onKeyDown:t=>{t.key==="Enter"&&F()}}),e.jsx("button",{type:"button",onClick:F,disabled:!x.trim()||M,className:"px-4 py-2 text-sm rounded-lg bg-cc-primary text-white font-medium disabled:opacity-30 hover:bg-cc-primary/90 transition-colors",children:M?"...":"Add"})]}),z?e.jsx("div",{className:"text-center py-8 text-sm text-cc-muted",children:"Loading..."}):C.length===0?e.jsxs("div",{className:"text-center py-12 space-y-3",children:[e.jsx("svg",{className:"w-10 h-10 mx-auto text-cc-muted/40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25"})}),e.jsx("p",{className:"text-sm text-cc-muted",children:r?"No memories found for this search.":"No memories yet"}),!r&&e.jsx("p",{className:"text-xs text-cc-muted/70 max-w-xs mx-auto",children:"Add a memory above, or chat with Hank — it will remember things about you automatically."})]}):e.jsx("div",{className:"space-y-2",children:C.map(t=>{var c;return e.jsxs("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg border border-cc-border bg-cc-card group",children:[e.jsx("div",{className:"flex-1 min-w-0",children:i===t.id?e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{value:u,onChange:a=>p(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),W()),a.key==="Escape"&&K()},className:"w-full px-2 py-1.5 text-sm bg-cc-bg rounded border border-cc-primary/40 text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary resize-none",rows:2,autoFocus:!0}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:W,className:"px-2.5 py-1 text-xs rounded bg-cc-primary text-white hover:bg-cc-primary/90 transition-colors",children:"Save"}),e.jsx("button",{type:"button",onClick:K,className:"px-2.5 py-1 text-xs rounded text-cc-muted hover:text-cc-fg transition-colors",children:"Cancel"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-cc-fg",children:t.content}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.createdAt&&e.jsxs("span",{className:"text-xs text-cc-muted",children:[new Date(t.createdAt).toLocaleDateString()," ",new Date(t.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]}),((c=t.metadata)==null?void 0:c.source)==="auto-extracted"&&e.jsx("span",{className:"text-[10px] text-cc-primary/70 bg-cc-primary/10 px-1.5 py-0.5 rounded",children:"auto"})]})]})}),i!==t.id&&e.jsxs("div",{className:"flex gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{type:"button",onClick:()=>q(t),className:"text-cc-muted hover:text-cc-fg transition-colors p-1",title:"Edit memory",children:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),e.jsx("button",{type:"button",onClick:()=>_(t.id),className:"text-cc-muted hover:text-red-400 transition-colors p-1",title:"Delete memory",children:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]},t.id)})}),e.jsxs("div",{className:"border-t border-cc-border pt-4 mt-6",children:[e.jsx("h3",{className:"text-xs font-semibold text-cc-muted uppercase tracking-wider mb-3",children:"Obsidian Vault Sync"}),e.jsx("p",{className:"text-[11px] text-cc-muted mb-3",children:"Sync memories as Markdown files to your Obsidian vault. Changes in Obsidian are synced back automatically."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:h,onChange:t=>{T(t.target.value),v(!1)},placeholder:"/path/to/your/obsidian/vault",className:"flex-1 px-3 py-2 text-sm bg-cc-input border border-cc-border rounded-md text-cc-fg placeholder-cc-muted focus:outline-none focus:border-cc-accent"}),e.jsx("button",{type:"button",disabled:D,onClick:async()=>{G(!0);try{await $.updateSettings({obsidianVaultPath:h.trim()}),v(!0),setTimeout(()=>v(!1),3e3)}catch{}G(!1)},className:"px-4 py-2 text-xs font-medium rounded-md bg-cc-accent text-white hover:bg-cc-accent/80 disabled:opacity-50 cursor-pointer",children:D?"Saving...":U?"Saved!":"Save"})]}),h&&e.jsxs("p",{className:"text-[10px] text-cc-muted mt-2",children:["Memories will be synced to: ",e.jsxs("code",{className:"text-cc-fg",children:[h,"/HeyHank/"]})]})]})]})})}export{ce as MemoryPage};
@@ -1 +1 @@
1
- import{j as e,r as a,b as n}from"./index-BgYM4wXw.js";function y(){const[s,l]=a.useState(null),[t,m]=a.useState([]),[i,d]=a.useState(!0),o=a.useCallback(async()=>{try{const[c,x]=await Promise.all([n.getCostSummary(),n.getCosts(20)]);l(c),m(x)}catch{}finally{d(!1)}},[]);return a.useEffect(()=>{o()},[o]),i?e.jsx("div",{className:"text-cc-text-secondary text-sm",children:"Loading costs..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-text-primary",children:"Cost Tracking"}),e.jsx("button",{onClick:o,className:"text-xs text-cc-text-secondary hover:text-cc-text-primary",children:"Refresh"})]}),s&&e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsx(h,{label:"Total Cost",value:`$${s.allTimeCost.toFixed(4)}`}),e.jsx(h,{label:"Tokens In",value:u(s.allTimeTokensIn)}),e.jsx(h,{label:"Tokens Out",value:u(s.allTimeTokensOut)}),e.jsx(h,{label:"Records",value:String(s.totalRecords)})]}),t.length>0&&e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-cc-text-secondary border-b border-cc-border",children:[e.jsx("th",{className:"pb-2 text-left font-medium",children:"Agent"}),e.jsx("th",{className:"pb-2 text-left font-medium",children:"Model"}),e.jsx("th",{className:"pb-2 text-right font-medium",children:"Tokens"}),e.jsx("th",{className:"pb-2 text-right font-medium",children:"Cost"})]})}),e.jsx("tbody",{children:t.map(c=>e.jsxs("tr",{className:"border-b border-cc-border/50",children:[e.jsx("td",{className:"py-1.5 text-cc-text-primary",children:c.agentName}),e.jsx("td",{className:"py-1.5 text-cc-text-secondary",children:c.model}),e.jsx("td",{className:"py-1.5 text-right text-cc-text-secondary",children:u(c.tokensIn+c.tokensOut)}),e.jsxs("td",{className:"py-1.5 text-right text-cc-text-primary",children:["$",c.estimatedCost.toFixed(4)]})]},c.agentId))})]})})]})}function b(){const[s,l]=a.useState({killed:!1}),[t,m]=a.useState(""),[i,d]=a.useState(!1);a.useEffect(()=>{n.getKillSwitch().then(l).catch(()=>{})},[]);const o=async()=>{d(!0);try{const x=await n.activateKillSwitch(t||"Manual activation from dashboard");l(x),m("")}finally{d(!1)}},c=async()=>{d(!0);try{const x=await n.deactivateKillSwitch();l(x)}finally{d(!1)}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-text-primary",children:"Kill Switch"}),e.jsxs("div",{className:`rounded-lg p-3 text-sm ${s.killed?"bg-red-500/10 border border-red-500/30":"bg-green-500/10 border border-green-500/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block h-2.5 w-2.5 rounded-full ${s.killed?"bg-red-500":"bg-green-500"}`}),e.jsx("span",{className:s.killed?"text-red-400 font-medium":"text-green-400",children:s.killed?"KILLED — All agents stopped":"Active — Agents running normally"})]}),s.killed&&s.reason&&e.jsxs("p",{className:"mt-1 text-xs text-red-300/70",children:["Reason: ",s.reason]}),s.killed&&s.activatedAt&&e.jsxs("p",{className:"mt-0.5 text-xs text-red-300/50",children:["Since: ",new Date(s.activatedAt).toLocaleString()]})]}),s.killed?e.jsx("button",{onClick:c,disabled:i,className:"rounded-lg bg-green-600 px-4 py-2 text-sm font-medium text-white hover:bg-green-500 disabled:opacity-50",children:i?"Deactivating...":"Deactivate Kill Switch"}):e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:x=>m(x.target.value),placeholder:"Reason (optional)",className:"flex-1 rounded-lg border border-cc-border bg-cc-bg-secondary px-3 py-1.5 text-sm text-cc-text-primary"}),e.jsx("button",{onClick:o,disabled:i,className:"rounded-lg bg-red-600 px-4 py-1.5 text-sm font-medium text-white hover:bg-red-500 disabled:opacity-50",children:i?"...":"KILL"})]})]})}function f(){const[s,l]=a.useState([]),[t,m]=a.useState(null),[i,d]=a.useState(""),[o,c]=a.useState(!1);a.useEffect(()=>{n.listSharedContext().then(l).catch(()=>{})},[]);const x=async r=>{try{const p=await n.getSharedContext(r);m(r),d(p.content),c(!1)}catch{}},g=async()=>{if(t)try{await n.writeSharedContext(t,i),c(!1);const r=await n.listSharedContext();l(r)}catch{}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-text-primary",children:"Shared Context"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.map(r=>e.jsx("button",{onClick:()=>x(r.filename),className:`rounded-md px-2.5 py-1 text-xs ${t===r.filename?"bg-cc-accent text-white":"bg-cc-bg-secondary text-cc-text-secondary hover:text-cc-text-primary"}`,children:r.filename},r.filename))}),t&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-cc-text-secondary",children:t}),e.jsx("div",{className:"flex gap-2",children:o?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:g,className:"text-xs text-green-400 hover:text-green-300",children:"Save"}),e.jsx("button",{onClick:()=>c(!1),className:"text-xs text-cc-text-secondary hover:text-cc-text-primary",children:"Cancel"})]}):e.jsx("button",{onClick:()=>c(!0),className:"text-xs text-cc-text-secondary hover:text-cc-text-primary",children:"Edit"})})]}),o?e.jsx("textarea",{value:i,onChange:r=>d(r.target.value),rows:10,className:"w-full rounded-lg border border-cc-border bg-cc-bg-secondary p-3 font-mono text-xs text-cc-text-primary"}):e.jsx("pre",{className:"max-h-64 overflow-auto rounded-lg bg-cc-bg-secondary p-3 text-xs text-cc-text-secondary",children:i})]})]})}function j(){const[s,l]=a.useState([]);return a.useEffect(()=>{n.listMessages({limit:20}).then(l).catch(()=>{})},[]),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-text-primary",children:"Agent Messages"}),e.jsxs("span",{className:"text-xs text-cc-text-secondary",children:[s.length," messages"]})]}),s.length===0?e.jsx("p",{className:"text-xs text-cc-text-secondary",children:"No messages yet."}):e.jsx("div",{className:"space-y-2 max-h-64 overflow-auto",children:s.map(t=>e.jsxs("div",{className:"rounded-lg bg-cc-bg-secondary p-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium text-cc-text-primary",children:[t.fromName||t.from," → ",t.to||"broadcast"]}),e.jsx("span",{className:"text-cc-text-secondary",children:new Date(t.createdAt).toLocaleTimeString()})]}),e.jsx("span",{className:`inline-block mt-1 rounded px-1.5 py-0.5 text-[10px] ${t.type==="task"?"bg-blue-500/20 text-blue-400":t.type==="result"?"bg-green-500/20 text-green-400":t.type==="interrupt"?"bg-red-500/20 text-red-400":"bg-cc-bg-tertiary text-cc-text-secondary"}`,children:t.type}),e.jsx("p",{className:"mt-1 text-cc-text-secondary line-clamp-2",children:t.content})]},t.id))})]})}function N(){const[s,l]=a.useState([]);return a.useEffect(()=>{n.getLLMProviders().then(t=>l(t.providers)).catch(()=>{})},[]),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-text-primary",children:"LLM Providers"}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:s.map(t=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-cc-bg-secondary p-2.5",children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${t.status==="available"||t.status==="configured"?"bg-green-500":t.status==="needs_api_key"?"bg-yellow-500":"bg-red-500"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-xs font-medium text-cc-text-primary capitalize",children:t.name}),e.jsx("span",{className:"ml-2 text-[10px] text-cc-text-secondary",children:t.status})]}),t.models&&t.models.length>0&&e.jsxs("span",{className:"text-[10px] text-cc-text-secondary",children:[t.models.length," models"]})]},t.name))})]})}function h({label:s,value:l}){return e.jsxs("div",{className:"rounded-lg bg-cc-bg-secondary p-3",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-cc-text-secondary",children:s}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-cc-text-primary",children:l})]})}function u(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:String(s)}function w(){return e.jsx("div",{className:"h-full overflow-y-auto bg-cc-bg",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe space-y-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-text-primary",children:"HeyHank Dashboard"}),e.jsx("p",{className:"text-xs text-cc-text-secondary",children:"Multi-Agent Platform"})]}),e.jsx(b,{}),e.jsx(y,{}),e.jsx(N,{}),e.jsx(j,{}),e.jsx(f,{})]})})}export{w as default};
1
+ import{j as e,r as a,b as n}from"./index-C6Q5UQHD.js";function y(){const[s,l]=a.useState(null),[t,m]=a.useState([]),[i,d]=a.useState(!0),o=a.useCallback(async()=>{try{const[c,x]=await Promise.all([n.getCostSummary(),n.getCosts(20)]);l(c),m(x)}catch{}finally{d(!1)}},[]);return a.useEffect(()=>{o()},[o]),i?e.jsx("div",{className:"text-cc-text-secondary text-sm",children:"Loading costs..."}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-text-primary",children:"Cost Tracking"}),e.jsx("button",{onClick:o,className:"text-xs text-cc-text-secondary hover:text-cc-text-primary",children:"Refresh"})]}),s&&e.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[e.jsx(h,{label:"Total Cost",value:`$${s.allTimeCost.toFixed(4)}`}),e.jsx(h,{label:"Tokens In",value:u(s.allTimeTokensIn)}),e.jsx(h,{label:"Tokens Out",value:u(s.allTimeTokensOut)}),e.jsx(h,{label:"Records",value:String(s.totalRecords)})]}),t.length>0&&e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-cc-text-secondary border-b border-cc-border",children:[e.jsx("th",{className:"pb-2 text-left font-medium",children:"Agent"}),e.jsx("th",{className:"pb-2 text-left font-medium",children:"Model"}),e.jsx("th",{className:"pb-2 text-right font-medium",children:"Tokens"}),e.jsx("th",{className:"pb-2 text-right font-medium",children:"Cost"})]})}),e.jsx("tbody",{children:t.map(c=>e.jsxs("tr",{className:"border-b border-cc-border/50",children:[e.jsx("td",{className:"py-1.5 text-cc-text-primary",children:c.agentName}),e.jsx("td",{className:"py-1.5 text-cc-text-secondary",children:c.model}),e.jsx("td",{className:"py-1.5 text-right text-cc-text-secondary",children:u(c.tokensIn+c.tokensOut)}),e.jsxs("td",{className:"py-1.5 text-right text-cc-text-primary",children:["$",c.estimatedCost.toFixed(4)]})]},c.agentId))})]})})]})}function b(){const[s,l]=a.useState({killed:!1}),[t,m]=a.useState(""),[i,d]=a.useState(!1);a.useEffect(()=>{n.getKillSwitch().then(l).catch(()=>{})},[]);const o=async()=>{d(!0);try{const x=await n.activateKillSwitch(t||"Manual activation from dashboard");l(x),m("")}finally{d(!1)}},c=async()=>{d(!0);try{const x=await n.deactivateKillSwitch();l(x)}finally{d(!1)}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-text-primary",children:"Kill Switch"}),e.jsxs("div",{className:`rounded-lg p-3 text-sm ${s.killed?"bg-red-500/10 border border-red-500/30":"bg-green-500/10 border border-green-500/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`inline-block h-2.5 w-2.5 rounded-full ${s.killed?"bg-red-500":"bg-green-500"}`}),e.jsx("span",{className:s.killed?"text-red-400 font-medium":"text-green-400",children:s.killed?"KILLED — All agents stopped":"Active — Agents running normally"})]}),s.killed&&s.reason&&e.jsxs("p",{className:"mt-1 text-xs text-red-300/70",children:["Reason: ",s.reason]}),s.killed&&s.activatedAt&&e.jsxs("p",{className:"mt-0.5 text-xs text-red-300/50",children:["Since: ",new Date(s.activatedAt).toLocaleString()]})]}),s.killed?e.jsx("button",{onClick:c,disabled:i,className:"rounded-lg bg-green-600 px-4 py-2 text-sm font-medium text-white hover:bg-green-500 disabled:opacity-50",children:i?"Deactivating...":"Deactivate Kill Switch"}):e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:x=>m(x.target.value),placeholder:"Reason (optional)",className:"flex-1 rounded-lg border border-cc-border bg-cc-bg-secondary px-3 py-1.5 text-sm text-cc-text-primary"}),e.jsx("button",{onClick:o,disabled:i,className:"rounded-lg bg-red-600 px-4 py-1.5 text-sm font-medium text-white hover:bg-red-500 disabled:opacity-50",children:i?"...":"KILL"})]})]})}function f(){const[s,l]=a.useState([]),[t,m]=a.useState(null),[i,d]=a.useState(""),[o,c]=a.useState(!1);a.useEffect(()=>{n.listSharedContext().then(l).catch(()=>{})},[]);const x=async r=>{try{const p=await n.getSharedContext(r);m(r),d(p.content),c(!1)}catch{}},g=async()=>{if(t)try{await n.writeSharedContext(t,i),c(!1);const r=await n.listSharedContext();l(r)}catch{}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-text-primary",children:"Shared Context"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.map(r=>e.jsx("button",{onClick:()=>x(r.filename),className:`rounded-md px-2.5 py-1 text-xs ${t===r.filename?"bg-cc-accent text-white":"bg-cc-bg-secondary text-cc-text-secondary hover:text-cc-text-primary"}`,children:r.filename},r.filename))}),t&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-cc-text-secondary",children:t}),e.jsx("div",{className:"flex gap-2",children:o?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:g,className:"text-xs text-green-400 hover:text-green-300",children:"Save"}),e.jsx("button",{onClick:()=>c(!1),className:"text-xs text-cc-text-secondary hover:text-cc-text-primary",children:"Cancel"})]}):e.jsx("button",{onClick:()=>c(!0),className:"text-xs text-cc-text-secondary hover:text-cc-text-primary",children:"Edit"})})]}),o?e.jsx("textarea",{value:i,onChange:r=>d(r.target.value),rows:10,className:"w-full rounded-lg border border-cc-border bg-cc-bg-secondary p-3 font-mono text-xs text-cc-text-primary"}):e.jsx("pre",{className:"max-h-64 overflow-auto rounded-lg bg-cc-bg-secondary p-3 text-xs text-cc-text-secondary",children:i})]})]})}function j(){const[s,l]=a.useState([]);return a.useEffect(()=>{n.listMessages({limit:20}).then(l).catch(()=>{})},[]),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-text-primary",children:"Agent Messages"}),e.jsxs("span",{className:"text-xs text-cc-text-secondary",children:[s.length," messages"]})]}),s.length===0?e.jsx("p",{className:"text-xs text-cc-text-secondary",children:"No messages yet."}):e.jsx("div",{className:"space-y-2 max-h-64 overflow-auto",children:s.map(t=>e.jsxs("div",{className:"rounded-lg bg-cc-bg-secondary p-2.5 text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium text-cc-text-primary",children:[t.fromName||t.from," → ",t.to||"broadcast"]}),e.jsx("span",{className:"text-cc-text-secondary",children:new Date(t.createdAt).toLocaleTimeString()})]}),e.jsx("span",{className:`inline-block mt-1 rounded px-1.5 py-0.5 text-[10px] ${t.type==="task"?"bg-blue-500/20 text-blue-400":t.type==="result"?"bg-green-500/20 text-green-400":t.type==="interrupt"?"bg-red-500/20 text-red-400":"bg-cc-bg-tertiary text-cc-text-secondary"}`,children:t.type}),e.jsx("p",{className:"mt-1 text-cc-text-secondary line-clamp-2",children:t.content})]},t.id))})]})}function N(){const[s,l]=a.useState([]);return a.useEffect(()=>{n.getLLMProviders().then(t=>l(t.providers)).catch(()=>{})},[]),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h3",{className:"text-sm font-medium text-cc-text-primary",children:"LLM Providers"}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:s.map(t=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-cc-bg-secondary p-2.5",children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${t.status==="available"||t.status==="configured"?"bg-green-500":t.status==="needs_api_key"?"bg-yellow-500":"bg-red-500"}`}),e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-xs font-medium text-cc-text-primary capitalize",children:t.name}),e.jsx("span",{className:"ml-2 text-[10px] text-cc-text-secondary",children:t.status})]}),t.models&&t.models.length>0&&e.jsxs("span",{className:"text-[10px] text-cc-text-secondary",children:[t.models.length," models"]})]},t.name))})]})}function h({label:s,value:l}){return e.jsxs("div",{className:"rounded-lg bg-cc-bg-secondary p-3",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-cc-text-secondary",children:s}),e.jsx("div",{className:"mt-1 text-lg font-semibold text-cc-text-primary",children:l})]})}function u(s){return s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:String(s)}function w(){return e.jsx("div",{className:"h-full overflow-y-auto bg-cc-bg",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe space-y-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-text-primary",children:"HeyHank Dashboard"}),e.jsx("p",{className:"text-xs text-cc-text-secondary",children:"Multi-Agent Platform"})]}),e.jsx(b,{}),e.jsx(y,{}),e.jsx(N,{}),e.jsx(j,{}),e.jsx(f,{})]})})}export{w as default};
@@ -1,4 +1,4 @@
1
- import{r as p,j as e,u as j,n as ce,a as le,P as f,C as de,A as q,M as v,g as w,G as I,D as T,S as D,h as M,i as P,l as $,m as J,o as me,p as pe,q as xe,U as ue,s as he,v as Q,w as X,b as ge,x as be,y as N,z as fe}from"./index-BgYM4wXw.js";const je=new Set(["pulling_image","running_init_script","building_image"]);function R({steps:t,error:o}){const[n,a]=p.useState({}),[r,h]=p.useState(new Set),l=p.useRef(new Map),x=p.useCallback(i=>d=>{d?l.current.set(i,d):l.current.delete(i)},[]);return p.useEffect(()=>{for(const i of t)i.detail&&je.has(i.step)&&(a(d=>{const u=d[i.step]||[];return u.length===0||u[u.length-1]!==i.detail?{...d,[i.step]:[...u,i.detail]}:d}),h(d=>{if(d.has(i.step))return d;const u=new Set(d);return u.add(i.step),u}))},[t]),p.useEffect(()=>{var i;for(const d of l.current.values())(i=d.scrollTo)==null||i.call(d,{top:d.scrollHeight})},[n]),t.length===0?null:e.jsxs("div",{className:"w-full max-w-md mx-auto mt-4 mb-2",children:[e.jsx("div",{className:"space-y-1.5",children:t.map(i=>{const d=n[i.step],u=d&&d.length>0,S=r.has(i.step);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 py-1",children:[e.jsxs("div",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:[i.status==="in_progress"&&e.jsx("span",{className:"w-3.5 h-3.5 border-2 border-cc-primary/30 border-t-cc-primary rounded-full animate-spin"}),i.status==="done"&&e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5 text-cc-success",children:e.jsx("path",{d:"M13.25 4.75L6 12 2.75 8.75",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),i.status==="error"&&e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5 text-cc-error",children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]}),e.jsx("span",{className:`text-sm flex-1 ${i.status==="in_progress"?"text-cc-fg font-medium":i.status==="done"?"text-cc-muted":"text-cc-error"}`,children:i.label}),u&&e.jsx("button",{onClick:()=>h(C=>{const m=new Set(C);return m.has(i.step)?m.delete(i.step):m.add(i.step),m}),className:"text-[10px] text-cc-muted hover:text-cc-fg transition-colors cursor-pointer",children:S?"Hide logs":"Show logs"})]}),u&&S&&e.jsx("pre",{ref:x(i.step),className:"ml-[26px] mt-1 mb-1 px-3 py-2 text-[10px] font-mono-code bg-black/20 border border-cc-border rounded-md text-cc-muted max-h-[150px] overflow-auto whitespace-pre-wrap",children:d.slice(-30).join(`
1
+ import{r as p,j as e,u as j,n as ce,a as le,P as f,C as de,A as q,M as v,g as w,G as I,D as T,S as D,h as M,i as P,l as $,m as J,o as me,p as pe,q as xe,U as ue,s as he,v as Q,w as X,b as ge,x as be,y as N,z as fe}from"./index-C6Q5UQHD.js";const je=new Set(["pulling_image","running_init_script","building_image"]);function R({steps:t,error:o}){const[n,a]=p.useState({}),[r,h]=p.useState(new Set),l=p.useRef(new Map),x=p.useCallback(i=>d=>{d?l.current.set(i,d):l.current.delete(i)},[]);return p.useEffect(()=>{for(const i of t)i.detail&&je.has(i.step)&&(a(d=>{const u=d[i.step]||[];return u.length===0||u[u.length-1]!==i.detail?{...d,[i.step]:[...u,i.detail]}:d}),h(d=>{if(d.has(i.step))return d;const u=new Set(d);return u.add(i.step),u}))},[t]),p.useEffect(()=>{var i;for(const d of l.current.values())(i=d.scrollTo)==null||i.call(d,{top:d.scrollHeight})},[n]),t.length===0?null:e.jsxs("div",{className:"w-full max-w-md mx-auto mt-4 mb-2",children:[e.jsx("div",{className:"space-y-1.5",children:t.map(i=>{const d=n[i.step],u=d&&d.length>0,S=r.has(i.step);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5 py-1",children:[e.jsxs("div",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:[i.status==="in_progress"&&e.jsx("span",{className:"w-3.5 h-3.5 border-2 border-cc-primary/30 border-t-cc-primary rounded-full animate-spin"}),i.status==="done"&&e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5 text-cc-success",children:e.jsx("path",{d:"M13.25 4.75L6 12 2.75 8.75",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),i.status==="error"&&e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",className:"w-3.5 h-3.5 text-cc-error",children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})})]}),e.jsx("span",{className:`text-sm flex-1 ${i.status==="in_progress"?"text-cc-fg font-medium":i.status==="done"?"text-cc-muted":"text-cc-error"}`,children:i.label}),u&&e.jsx("button",{onClick:()=>h(C=>{const m=new Set(C);return m.has(i.step)?m.delete(i.step):m.add(i.step),m}),className:"text-[10px] text-cc-muted hover:text-cc-fg transition-colors cursor-pointer",children:S?"Hide logs":"Show logs"})]}),u&&S&&e.jsx("pre",{ref:x(i.step),className:"ml-[26px] mt-1 mb-1 px-3 py-2 text-[10px] font-mono-code bg-black/20 border border-cc-border rounded-md text-cc-muted max-h-[150px] overflow-auto whitespace-pre-wrap",children:d.slice(-30).join(`
2
2
  `)})]},i.step)})}),o&&e.jsx("div",{className:"mt-2.5 px-3 py-2 rounded-lg bg-cc-error/5 border border-cc-error/20",children:e.jsx("p",{className:"text-xs text-cc-error whitespace-pre-wrap",children:o})})]})}const b="playground-session";function g(t){return{request_id:`perm-${Math.random().toString(36).slice(2,8)}`,tool_use_id:`tu-${Math.random().toString(36).slice(2,8)}`,timestamp:Date.now(),...t}}const Z=g({tool_name:"Bash",input:{command:"git log --oneline -20 && npm run build",description:"View recent commits and build the project"},permission_suggestions:[{type:"addRules",rules:[{toolName:"Bash",ruleContent:"git log --oneline -20 && npm run build"}],behavior:"allow",destination:"session"},{type:"addRules",rules:[{toolName:"Bash",ruleContent:"git log --oneline -20 && npm run build"}],behavior:"allow",destination:"projectSettings"}]}),ve=g({tool_name:"Edit",input:{file_path:"/Users/stan/Dev/project/src/utils/format.ts",old_string:`export function formatDate(d: Date) {
3
3
  return d.toISOString();
4
4
  }`,new_string:`export function formatDate(d: Date, locale = "en-US") {
@@ -1,2 +1,2 @@
1
- import{u as E,r as d,b as C,j as e}from"./index-BgYM4wXw.js";const te=[],se=15e3;function T(t){const r=Math.floor(t/1e3);if(r<60)return`${r}s`;const s=Math.floor(r/60),c=r%60;if(s<60)return`${s}m ${c}s`;const i=Math.floor(s/60),l=s%60;return`${i}h ${l}m`}function re(t){const r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<5)return"just now";if(r<60)return`${r}s ago`;const s=Math.floor(r/60);return s<60?`${s}m ago`:`${Math.floor(s/60)}h ago`}function D(t,r=60){const s=t.split(`
1
+ import{u as E,r as d,b as C,j as e}from"./index-C6Q5UQHD.js";const te=[],se=15e3;function T(t){const r=Math.floor(t/1e3);if(r<60)return`${r}s`;const s=Math.floor(r/60),c=r%60;if(s<60)return`${s}m ${c}s`;const i=Math.floor(s/60),l=s%60;return`${i}h ${l}m`}function re(t){const r=Math.max(0,Math.floor((Date.now()-t)/1e3));if(r<5)return"just now";if(r<60)return`${r}s ago`;const s=Math.floor(r/60);return s<60?`${s}m ago`:`${Math.floor(s/60)}h ago`}function D(t,r=60){const s=t.split(`
2
2
  `)[0];return s.length<=r?s:s.slice(0,r-3)+"..."}function ne(t){const r=t.replace(/\/+$/,""),s=r.split("/").filter(Boolean);return s[s.length-1]||r||"/"}function ae(t){const r=t.replace(/\/+$/,""),s=r.lastIndexOf("/");return s<=0?"/":r.slice(0,s)}function P(t){if(!t)return;const r=t.trim();if(r)return r.replace(/\/+$/,"")||"/"}function ce(t,r){const s=P(t),c=P(r);return!s||!c?!1:s===c?!0:s.startsWith(`${c}/`)}function ie(t,r=68){if(t.length<=r)return t;const s=t.split("/").filter(Boolean);if(s.length<=2)return`...${t.slice(-(r-3))}`;const c=s.slice(-2).join("/"),l=`${t.startsWith("/")?"/":""}.../${c}`;return l.length<=r?l:`...${t.slice(-(r-3))}`}function le(t){const r=[...t.matchAll(/\/[^\s"'`]+/g)].map(c=>c[0]);if(r.length===0)return;let s=null;for(const c of r){let i=c,l=0;const m=i.indexOf("/node_modules/");m>0&&(i=i.slice(0,m),l+=4),/\/\.[^/]+/.test(i)&&(l-=1),(/\/\.nvm\//.test(c)||/\/bin\/(?:node|bun|python3?|ruby|php)$/.test(c))&&(l-=3),/\.(mjs|cjs|js|ts|tsx|py|rb|php|go)$/i.test(i)&&(i=ae(i),l+=2),/\/Users\/|\/home\/|\/workspace\//.test(i)&&(l+=1);const x=P(i);x&&(!s||l>s.score||l===s.score&&x.length>s.path.length)&&(s={path:x,score:l})}return s==null?void 0:s.path}function oe(t){try{return new Date(t).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}catch{return""}}function de({expanded:t}){return e.jsx("svg",{viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.75,className:`w-3 h-3 text-cc-muted shrink-0 transition-transform duration-150 ${t?"rotate-90":""}`,"aria-hidden":"true",children:e.jsx("path",{d:"M7 4l6 6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})})}function ue(t,r){const s=new Map;for(const c of t){const i=P(c.cwd)||le(c.fullCommand),l=ce(i,r),m=i||"__unknown__",x=s.get(m);if(x){x.processes.push(c),x.isCurrentRepo=x.isCurrentRepo||l;continue}const f=i?ne(i):"Unknown project";s.set(m,{key:m,label:f,path:i,isCurrentRepo:l,processes:[c]})}return[...s.values()].sort((c,i)=>c.isCurrentRepo!==i.isCurrentRepo?c.isCurrentRepo?-1:1:!!c.path!=!!i.path?c.path?-1:1:(c.path||c.label).localeCompare(i.path||i.label))}function me(t){const r=(t.fullCommand||t.command||"").trim(),s=r.toLowerCase();if(/\bnext(\s+dev|\b)/.test(s)||s.includes("/next/dist/bin/next"))return"Next.js dev server";if(/\bvite\b/.test(s))return"Vite dev server";if(/\bnuxt\b/.test(s))return"Nuxt dev server";if(/\bastro\b/.test(s))return"Astro dev server";if(/\bremix\b/.test(s))return"Remix dev server";if(/\bwebpack(-dev-server)?\b/.test(s))return"Webpack dev server";if(/\bphp\s+artisan\s+serve\b/.test(s))return"Laravel dev server";if(/\buvicorn\b/.test(s))return"Uvicorn server";if(/\bgunicorn\b/.test(s))return"Gunicorn server";if(/\bpython(?:3)?\s+-m\s+http\.server\b/.test(s))return"Python http.server";if(/\b(?:bin\/rails|rails\s+server|puma)\b/.test(s))return"Rails app server";const c=r.match(/(?:^|\s)([^\s"'`]+\.(?:mjs|cjs|js|ts|tsx|py|rb|php|go))(?=\s|$)/i);if(c){const i=c[1].split("/").pop();if(i)return i}return D(r||t.command,64)}function W({process:t,killing:r,onKill:s}){const[c,i]=d.useState(!1),[l,m]=d.useState(Date.now());d.useEffect(()=>{if(t.status!=="running")return;const v=setInterval(()=>m(Date.now()),1e3);return()=>clearInterval(v)},[t.status]);const x={running:"bg-cc-primary",completed:"bg-cc-success",failed:"bg-cc-error",stopped:"bg-cc-muted"},f=t.completedAt?T(t.completedAt-t.startedAt):T(l-t.startedAt);return e.jsx("div",{role:"listitem",className:`px-4 py-2.5 hover:bg-cc-hover/50 transition-colors ${t.status!=="running"?"opacity-60":""}`,"data-testid":"process-row",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 mt-1.5 ${x[t.status]||"bg-cc-muted"} ${t.status==="running"?"animate-pulse":""}`,"data-testid":"process-status-dot"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>i(!c),className:"text-[12px] text-cc-fg font-medium truncate text-left cursor-pointer hover:underline flex-1 min-w-0",title:t.description||t.command,children:t.description||D(t.command)}),e.jsx("span",{className:"text-[10px] text-cc-muted tabular-nums shrink-0",children:f})]}),e.jsxs("div",{className:"text-[10px] text-cc-muted mt-0.5",children:["ID: ",t.taskId||"pending..."]}),c&&e.jsxs("div",{className:"mt-1.5 space-y-1",children:[e.jsx("pre",{className:"text-[10px] text-cc-muted bg-cc-hover rounded px-2 py-1 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:t.command}),t.summary&&e.jsx("div",{className:"text-[11px] text-cc-muted italic",children:t.summary})]})]}),s&&t.status==="running"&&e.jsx("button",{type:"button",onClick:s,disabled:r,className:"shrink-0 text-[11px] text-cc-error hover:text-red-500 disabled:opacity-50 transition-colors cursor-pointer px-2.5 py-1.5 min-h-[44px] rounded hover:bg-cc-hover",title:"Kill process","aria-label":`Kill process ${t.taskId}`,children:r?"...":"Kill"})]})})}function xe({proc:t,killing:r,onKill:s}){const[c,i]=d.useState(!1),[l,m]=d.useState(Date.now()),x=me(t),f=D(t.fullCommand,110),v=f&&f!==x,j=t.startedAt?T(Math.max(0,l-t.startedAt)):null,g=t.startedAt?oe(t.startedAt):null;return d.useEffect(()=>{if(!t.startedAt)return;const p=setInterval(()=>m(Date.now()),1e3);return()=>clearInterval(p)},[t.startedAt]),e.jsx("div",{role:"listitem",className:"px-4 py-2.5 hover:bg-cc-hover/50 transition-colors","data-testid":"system-process-row",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0 mt-1.5 bg-green-500 animate-pulse"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("button",{type:"button",onClick:()=>i(!c),className:"text-[12px] text-cc-fg font-medium truncate text-left cursor-pointer hover:underline flex-1 min-w-0",title:t.fullCommand,children:x})}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5 flex-wrap text-[10px] text-cc-muted",children:[e.jsx("span",{className:"rounded px-1 py-0.5 bg-cc-active/60 text-[9px] font-mono text-cc-fg/80",children:t.command}),e.jsxs("span",{children:["PID: ",t.pid]}),j&&e.jsxs("span",{children:["Up ",j]}),g&&e.jsxs("span",{children:["Started ",g]}),t.ports.map(p=>e.jsxs("a",{href:`http://localhost:${p}`,target:"_blank",rel:"noreferrer","aria-label":`Open http://localhost:${p}`,className:"inline-flex items-center gap-0.5 text-[9px] rounded px-1 py-0.5 bg-cc-primary/10 text-cc-primary hover:bg-cc-primary/20 transition-colors tabular-nums font-mono underline decoration-cc-primary/30 underline-offset-2",children:["localhost:",p,e.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"w-2.5 h-2.5 shrink-0","aria-hidden":"true",children:e.jsx("path",{d:"M4.5 2.5h-2v7h7v-2M7 2.5h2.5V5M5.5 6.5l4-4",strokeLinecap:"round",strokeLinejoin:"round"})})]},p))]}),v&&!c&&e.jsx("div",{className:"mt-1 text-[10px] text-cc-muted font-mono truncate",title:t.fullCommand,children:f}),c&&e.jsx("pre",{className:"mt-1.5 text-[10px] text-cc-muted bg-cc-hover rounded px-2 py-1 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:t.fullCommand})]}),e.jsx("button",{type:"button",onClick:s,disabled:r,className:"shrink-0 text-[11px] text-cc-error hover:text-red-500 disabled:opacity-50 transition-colors cursor-pointer px-2.5 py-1.5 min-h-[44px] rounded hover:bg-cc-hover",title:"Kill process","aria-label":`Kill system process ${t.pid}`,children:r?"...":"Kill"})]})})}function z({title:t,count:r,action:s}){return e.jsxs("div",{className:"shrink-0 px-4 py-2 flex items-center justify-between bg-cc-bg",children:[e.jsxs("span",{className:"text-[11px] text-cc-muted uppercase tracking-wider",children:[t,r!==void 0&&r>0?` (${r})`:""]}),s]})}function _({text:t,spinning:r=!1,tone:s="muted"}){return e.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[9px] ${s==="error"?"bg-cc-error/10 text-cc-error":"bg-cc-hover text-cc-muted"}`,children:[r&&e.jsx("span",{className:"inline-block w-2 h-2 rounded-full border border-current border-t-transparent animate-spin","aria-hidden":"true"}),t]})}function R({size:t="sm",className:r=""}){const s=t==="lg"?"w-8 h-8":t==="md"?"w-4 h-4":"w-3 h-3";return e.jsx("span",{className:`inline-block ${s} rounded-full border-2 border-current border-t-transparent animate-spin ${r}`,"aria-hidden":"true"})}function pe({label:t,state:r}){return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`inline-flex items-center justify-center w-4 h-4 rounded-full border ${r==="done"?"border-emerald-400/50 bg-emerald-400/10 text-emerald-300":r==="active"?"border-cc-primary/50 bg-cc-primary/10 text-cc-primary":"border-cc-border text-cc-muted/70"}`,"aria-hidden":"true",children:r==="active"?e.jsx(R,{size:"sm",className:"text-current"}):r==="done"?e.jsx("svg",{viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"w-3 h-3",children:e.jsx("path",{d:"M2.5 6.2l2.1 2.1 4.9-4.9",strokeLinecap:"round",strokeLinejoin:"round"})}):e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current/60"})}),e.jsx("span",{className:r==="active"?"text-cc-fg":"text-cc-muted",children:t})]})}function he({title:t,subtitle:r}){const s=["Scanning listening ports","Resolving process commands","Grouping by project folder"],[c,i]=d.useState(0);return d.useEffect(()=>{const l=setInterval(()=>{i(m=>(m+1)%s.length)},850);return()=>clearInterval(l)},[s.length]),e.jsxs("div",{className:"h-full flex flex-col items-center justify-center px-6 text-center bg-cc-bg","aria-live":"polite",children:[e.jsxs("div",{className:"relative w-16 h-16 mb-3 text-cc-muted/60",children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"w-full h-full",children:e.jsx("path",{d:"M8 9h8m-8 4h6m-2-10h2.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2H7a2 2 0 01-2-2V5a2 2 0 012-2z",strokeLinecap:"round",strokeLinejoin:"round"})}),e.jsx("span",{className:"absolute inset-0 rounded-full border border-cc-primary/20 motion-safe:animate-ping","aria-hidden":"true"})]}),e.jsxs("div",{className:"mb-3 flex items-center gap-3 rounded-full border border-cc-border bg-cc-hover/20 px-3 py-2",children:[e.jsx(R,{size:"lg",className:"text-cc-primary"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"text-xs font-medium text-cc-fg",children:t}),e.jsx("div",{className:"text-[10px] text-cc-muted",children:"This can take a second on larger machines."})]})]}),e.jsx("p",{className:"text-xs text-cc-muted max-w-[320px] mb-4",children:r}),e.jsxs("div",{className:"w-full max-w-[360px] rounded-lg border border-cc-border bg-cc-hover/10 p-3 text-left",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wide text-cc-muted mb-2",children:"Scan progress"}),e.jsx("div",{className:"space-y-2",children:s.map((l,m)=>{const x=m<c?"done":m===c?"active":"pending";return e.jsx(pe,{label:l,state:x},l)})})]})]})}function fe({message:t,onRetry:r,retrying:s}){return e.jsxs("div",{className:"h-full flex flex-col items-center justify-center px-6 text-center bg-cc-bg",children:[e.jsx("div",{className:"w-12 h-12 mb-3 text-cc-error/60",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{d:"M12 9v4m0 4h.01M10.29 3.86l-7.4 12.82A1 1 0 003.76 18h16.48a1 1 0 00.87-1.5l-7.4-12.82a1 1 0 00-1.74 0z",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("h3",{className:"text-sm font-medium text-cc-fg mb-1",children:"Couldn't scan dev servers"}),e.jsx("p",{className:"text-xs text-cc-muted max-w-[320px]",children:t}),e.jsx("button",{type:"button",onClick:r,disabled:s,className:"mt-3 text-[11px] text-cc-muted hover:text-cc-fg disabled:opacity-50 transition-colors cursor-pointer px-3 py-2 rounded border border-cc-border hover:bg-cc-hover",children:s?"Retrying...":"Retry scan"})]})}function be({sessionId:t}){const r=E(n=>n.sessions.get(t)),s=E(n=>n.sessionProcesses.get(t))||te,[c,i]=d.useState(new Set),[l,m]=d.useState([]),[x,f]=d.useState(new Set),[v,j]=d.useState(new Set),g=d.useRef(new Set),[p,$]=d.useState("not_started"),[S,G]=d.useState("initial"),[V,I]=d.useState(null),[L,K]=d.useState(!1),[B,O]=d.useState(null),A=d.useRef(0),k=d.useRef(!1),b=s.filter(n=>n.status==="running"),U=s.filter(n=>n.status!=="running"),F=(r==null?void 0:r.repo_root)||(r==null?void 0:r.cwd),N=ue(l,F);d.useEffect(()=>{j(n=>{let o=!1;const a=new Set(n),u=new Set(N.map(h=>h.key));for(const h of N)g.current.has(h.key)||(h.isCurrentRepo?a.delete(h.key)&&(o=!0):a.has(h.key)||(a.add(h.key),o=!0));for(const h of[...a])u.has(h)||(a.delete(h),o=!0);for(const h of[...g.current])u.has(h)||g.current.delete(h);return o?a:n})},[N]);const y=d.useCallback(async n=>{const o=++A.current;G(n),I(null),$(a=>!L||a==="not_started"?"initial_loading":"refreshing");try{const a=await C.getSystemProcesses(t);if(k.current||o!==A.current)return;a.processes&&m(a.processes),K(!0),O(Date.now()),$("loaded")}catch(a){if(k.current||o!==A.current)return;const u=a instanceof Error?a.message:String(a);I(u),K(!0),$("error"),console.warn("[ProcessPanel] System process scan failed:",a instanceof Error?a.message:a)}},[L,t]);d.useEffect(()=>{k.current=!1,y("initial");const n=setInterval(()=>{y("poll")},se);return()=>{k.current=!0,clearInterval(n)}},[y]);const M=d.useCallback(async()=>{await y("manual")},[y]),H=d.useCallback(async n=>{i(o=>new Set([...o,n]));try{await C.killProcess(t,n),setTimeout(()=>{const o=E.getState(),a=o.sessionProcesses.get(t),u=a==null?void 0:a.find(h=>h.taskId===n);u&&u.status==="running"&&o.updateProcess(t,n,{status:"stopped",completedAt:Date.now()})},3e3)}catch{}finally{i(o=>{const a=new Set(o);return a.delete(n),a})}},[t]),q=d.useCallback(async()=>{const n=b.map(o=>o.taskId).filter(Boolean);i(new Set(n));try{await C.killAllProcesses(t,n)}catch{}finally{i(new Set)}},[t,b]),Y=d.useCallback(async n=>{f(o=>new Set([...o,n]));try{await C.killSystemProcess(t,n),setTimeout(()=>{m(o=>o.filter(a=>a.pid!==n))},1e3)}catch{}finally{f(o=>{const a=new Set(o);return a.delete(n),a})}},[t]),J=d.useCallback(n=>{g.current.add(n),j(o=>{const a=new Set(o);return a.has(n)?a.delete(n):a.add(n),a})},[]),Q=s.length>0||l.length>0,w=p==="initial_loading"||p==="refreshing",X=!L&&(p==="not_started"||p==="initial_loading"),Z=s.length===0&&X,ee=s.length===0&&l.length===0&&p==="error";if(Z){const n=S==="manual"?"Refreshing process list...":"Searching for running dev servers...",o=S==="manual"?"Updating the process list and resolving active ports.":"Checking listening ports and resolving process details.";return e.jsx(he,{title:n,subtitle:o})}return ee?e.jsx(fe,{message:V||"The dev server scan failed before any results were loaded.",onRetry:M,retrying:w}):Q?e.jsx("div",{className:"h-full flex flex-col overflow-hidden bg-cc-bg",children:e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(z,{title:"Claude Tasks",count:b.length,action:b.length>1?e.jsx("button",{type:"button",onClick:q,className:"text-[11px] px-2.5 py-1.5 text-cc-error hover:text-red-500 transition-colors cursor-pointer","aria-label":"Kill all running processes",children:"Kill All"}):void 0}),e.jsxs("div",{role:"list","aria-label":"Background processes",children:[b.map(n=>e.jsx(W,{process:n,killing:c.has(n.taskId),onKill:()=>H(n.taskId)},n.taskId||n.toolUseId)),U.length>0&&b.length>0&&e.jsx("div",{role:"presentation",className:"px-4 py-1.5 text-[10px] text-cc-muted uppercase tracking-wider",children:"Completed"}),U.map(n=>e.jsx(W,{process:n,killing:!1,onKill:null},n.taskId||n.toolUseId))]})]}),l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(z,{title:"Dev Servers",count:l.length,action:e.jsxs("div",{className:"flex items-center gap-2",children:[p==="refreshing"&&e.jsx(_,{text:S==="manual"?"Refreshing...":"Updating...",spinning:!0}),p==="error"&&l.length>0&&e.jsx(_,{text:"Refresh failed",tone:"error"}),B&&p!=="refreshing"&&e.jsx(_,{text:`Updated ${re(B)}`}),e.jsxs("button",{type:"button",onClick:M,disabled:w,className:"text-[11px] px-2 py-1.5 text-cc-muted hover:text-cc-fg disabled:opacity-50 transition-colors cursor-pointer inline-flex items-center gap-1.5","aria-label":"Refresh system processes",children:[p==="refreshing"&&e.jsx(R,{size:"sm",className:"text-current"}),p==="refreshing"&&S==="manual"?"Refreshing...":"Refresh"]})]})}),N.map(n=>{const o=v.has(n.key),a=[...new Set(n.processes.flatMap(u=>u.ports))].sort((u,h)=>u-h);return e.jsxs("div",{children:[e.jsx("div",{className:"px-4 py-2.5 bg-cc-hover/30",children:e.jsxs("button",{type:"button",onClick:()=>J(n.key),className:"w-full flex items-start justify-between gap-3 text-left cursor-pointer rounded px-2 py-1.5 hover:bg-cc-hover/60 transition-colors","aria-expanded":!o,"aria-label":`Toggle process group ${n.label}`,children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(de,{expanded:!o}),e.jsx("span",{className:"text-[9px] rounded px-1 py-0.5 bg-cc-active/60 text-cc-muted uppercase tracking-wide",children:"Folder"}),e.jsx("span",{className:"text-[12px] text-cc-fg font-medium",children:n.label}),e.jsxs("span",{className:"text-[9px] rounded px-1.5 py-0.5 bg-cc-active/60 text-cc-fg/80",children:[n.processes.length," running"]}),a.length>0&&e.jsxs("span",{className:"text-[9px] rounded px-1.5 py-0.5 bg-cc-active/60 text-cc-muted",children:[a.length," port",a.length===1?"":"s"]}),n.isCurrentRepo&&e.jsx("span",{className:"text-[9px] rounded px-1.5 py-0.5 bg-cc-primary/20 text-cc-primary",children:"Current repo"})]}),n.path&&e.jsx("div",{className:"mt-1 text-[10px] text-cc-muted font-mono truncate",title:n.path,children:ie(n.path,96)})]}),e.jsxs("div",{className:"shrink-0 hidden md:flex items-center gap-1.5 flex-wrap justify-end max-w-[40%]",children:[a.slice(0,4).map(u=>e.jsxs("span",{className:"text-[9px] rounded px-1 py-0.5 bg-cc-active/60 text-cc-muted tabular-nums font-mono",children:[":",u]},`${n.key}-port-${u}`)),a.length>4&&e.jsxs("span",{className:"text-[9px] text-cc-muted",children:["+",a.length-4]})]})]})}),!o&&e.jsx("div",{role:"list","aria-label":`System dev processes for ${n.label}`,className:"ml-4 border-l border-cc-border/40",children:n.processes.map(u=>e.jsx(xe,{proc:u,killing:x.has(u.pid),onKill:()=>Y(u.pid)},u.pid))})]},n.key)})]})]})}):e.jsxs("div",{className:"h-full flex flex-col items-center justify-center px-6 text-center bg-cc-bg",children:[e.jsx("div",{className:"w-12 h-12 mb-3 text-cc-muted/40",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{d:"M8 9h8m-8 4h6m-2-10h2.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2H7a2 2 0 01-2-2V5a2 2 0 012-2z",strokeLinecap:"round",strokeLinejoin:"round"})})}),e.jsx("h3",{className:"text-sm font-medium text-cc-fg mb-1",children:"No background processes"}),e.jsx("p",{className:"text-xs text-cc-muted max-w-[260px]",children:"Background tasks spawned by Claude and dev servers listening on ports will appear here."}),e.jsxs("button",{type:"button",onClick:M,disabled:w,className:"mt-3 text-[11px] text-cc-muted hover:text-cc-fg disabled:opacity-50 transition-colors cursor-pointer px-3 py-2 rounded border border-cc-border hover:bg-cc-hover inline-flex items-center gap-2","aria-label":"Scan for dev servers",children:[w&&e.jsx(R,{size:"sm",className:"text-current"}),w?"Scanning...":"Scan for dev servers"]})]})}export{be as ProcessPanel};
@@ -1,4 +1,4 @@
1
- import{r as c,u as X,b as z,j as e,n as ne,a as ae,F as Y}from"./index-BgYM4wXw.js";function de({embedded:o=!1}){const[a,i]=c.useState([]),[h,b]=c.useState(!0),[l,M]=c.useState(!1),[$,d]=c.useState(""),[u,I]=c.useState(""),[g,B]=c.useState(""),[y,R]=c.useState("global"),[p,L]=c.useState([]),[te,V]=c.useState(!1),[W,S]=c.useState(null),[A,f]=c.useState(""),[D,j]=c.useState(""),[k,v]=c.useState("global"),[N,m]=c.useState([]),[se,G]=c.useState(!1),[Z,re]=c.useState(""),[C,q]=c.useState(!1),J=X(t=>t.currentSessionId),x=X(t=>{var s,r;return t.currentSessionId&&(((s=t.sessions.get(t.currentSessionId))==null?void 0:s.cwd)||((r=t.sdkSessions.find(n=>n.sessionId===t.currentSessionId))==null?void 0:r.cwd))||""}),P=c.useMemo(()=>{const t=Z.trim().toLowerCase();return t?a.filter(s=>`${s.name}
1
+ import{r as c,u as X,b as z,j as e,n as ne,a as ae,F as Y}from"./index-C6Q5UQHD.js";function de({embedded:o=!1}){const[a,i]=c.useState([]),[h,b]=c.useState(!0),[l,M]=c.useState(!1),[$,d]=c.useState(""),[u,I]=c.useState(""),[g,B]=c.useState(""),[y,R]=c.useState("global"),[p,L]=c.useState([]),[te,V]=c.useState(!1),[W,S]=c.useState(null),[A,f]=c.useState(""),[D,j]=c.useState(""),[k,v]=c.useState("global"),[N,m]=c.useState([]),[se,G]=c.useState(!1),[Z,re]=c.useState(""),[C,q]=c.useState(!1),J=X(t=>t.currentSessionId),x=X(t=>{var s,r;return t.currentSessionId&&(((s=t.sessions.get(t.currentSessionId))==null?void 0:s.cwd)||((r=t.sdkSessions.find(n=>n.sessionId===t.currentSessionId))==null?void 0:r.cwd))||""}),P=c.useMemo(()=>{const t=Z.trim().toLowerCase();return t?a.filter(s=>`${s.name}
2
2
  ${s.content}
3
3
  ${s.scope}`.toLowerCase().includes(t)):a},[a,Z]),H=a.length,K=P.length,T=c.useMemo(()=>{const t=P.filter(n=>n.scope==="global"),s=P.filter(n=>n.scope==="project"),r=new Map;for(const n of s){const w=n.projectPaths??(n.projectPath?[n.projectPath]:[]),F=w.length>0?w.slice().sort().join(`
4
4
  `):"(no folder)",oe=w.length>0?w.map(U=>U.split("/").pop()||U).join(", "):"(no folder)";r.has(F)||r.set(F,{label:oe,prompts:[]}),r.get(F).prompts.push(n)}return{globalPrompts:t,folderGroups:r}},[P]),E=c.useCallback(async()=>{b(!0),d("");try{const t=await z.listPrompts();i(t)}catch(t){d(t instanceof Error?t.message:String(t))}finally{b(!1)}},[]);c.useEffect(()=>{E()},[E]);async function ce(t){if(t.preventDefault(),!(!u.trim()||!g.trim())){if(y==="project"&&p.length===0){d("Select at least one project folder");return}M(!0),d("");try{await z.createPrompt({name:u.trim(),content:g.trim(),scope:y,projectPaths:y==="project"?p:void 0}),I(""),B(""),R("global"),L([]),q(!1),await E()}catch(s){d(s instanceof Error?s.message:String(s))}finally{M(!1)}}}async function O(t){try{await z.deletePrompt(t),await E()}catch(s){d(s instanceof Error?s.message:String(s))}}async function Q(){if(!(!W||!A.trim()||!D.trim())){if(k==="project"&&N.length===0){d("Select at least one project folder");return}try{await z.updatePrompt(W,{name:A.trim(),content:D.trim(),scope:k,projectPaths:k==="project"?N:void 0}),S(null),f(""),j(""),v("global"),m([]),await E()}catch(t){d(t instanceof Error?t.message:String(t))}}}return e.jsxs("div",{className:`${o?"h-full":"h-[100dvh]"} bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto`,children:[e.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-8 py-6 sm:py-10 pb-safe",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Saved Prompts"}),e.jsxs("p",{className:"mt-0.5 text-[13px] text-cc-muted leading-relaxed",children:["Create reusable prompts — insert with ",e.jsx("code",{className:"text-cc-fg text-xs bg-cc-hover rounded px-1 py-0.5",children:"@title"})," in the composer."]})]}),!o&&e.jsx("button",{onClick:()=>{J?ne(J):ae()},className:"px-3 py-2.5 min-h-[44px] rounded-lg text-sm text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer shrink-0",children:"Back"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-4 mb-5",children:[e.jsxs("div",{className:"relative flex-1 min-w-0",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-cc-muted pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"m21 21-4.35-4.35"})]}),e.jsx("input",{value:Z,onChange:t=>re(t.target.value),placeholder:"Search by title or content...",className:"w-full pl-9 pr-3 py-2.5 min-h-[44px] text-sm bg-cc-card rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"})]}),e.jsxs("button",{onClick:()=>q(!C),className:`flex items-center gap-1.5 px-3.5 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer shrink-0 ${C?"bg-cc-active text-cc-fg":"bg-cc-primary hover:bg-cc-primary-hover text-white"}`,children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-4 h-4",children:C?e.jsx("path",{d:"M18 6 6 18M6 6l12 12"}):e.jsx("path",{d:"M12 5v14M5 12h14"})}),e.jsx("span",{className:"hidden sm:inline",children:C?"Cancel":"New Prompt"})]})]}),C&&e.jsxs("form",{onSubmit:ce,className:"mb-6 rounded-xl bg-cc-card p-4 sm:p-5 space-y-3",style:{animation:"fadeSlideIn 150ms ease-out"},children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-cc-muted mb-1",htmlFor:"prompt-name",children:"Title"}),e.jsx("input",{id:"prompt-name",type:"text",value:u,onChange:t=>I(t.target.value),placeholder:"review-pr",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-cc-muted mb-1",htmlFor:"prompt-content",children:"Content"}),e.jsx("textarea",{id:"prompt-content",value:g,onChange:t=>B(t.target.value),placeholder:"Review this PR and summarize risks, regressions, and missing tests.",rows:4,className:"w-full px-3 py-2.5 text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 resize-y transition-shadow"})]}),e.jsx(ee,{scope:y,onScopeChange:t=>{R(t),t==="project"&&p.length===0&&x&&L([x])},folders:p,onRemoveFolder:t=>L(s=>s.filter(r=>r!==t)),onAddFolder:()=>V(!0)}),$&&e.jsx("div",{className:"px-3 py-2 rounded-lg bg-cc-error/10 text-xs text-cc-error",children:$}),e.jsxs("div",{className:"flex items-center justify-between pt-1",children:[e.jsxs("p",{className:"text-[11px] text-cc-muted",children:["Stored in ",e.jsx("code",{className:"text-[10px]",children:"~/.heyhank/prompts.json"})]}),e.jsx("button",{type:"submit",disabled:l||!u.trim()||!g.trim(),className:`px-4 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors ${l||!u.trim()||!g.trim()?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer"}`,children:l?"Saving...":"Create Prompt"})]})]}),e.jsx("div",{className:"flex items-center gap-2 mb-3 text-[12px] text-cc-muted",children:e.jsx("span",{children:K===H?`${H} prompt${H!==1?"s":""}`:`${K} of ${H}`})}),h?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"Loading prompts..."}):a.length===0?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"No prompts yet."}):P.length===0?e.jsx("div",{className:"py-12 text-center text-sm text-cc-muted",children:"No prompts match your search."}):e.jsxs("div",{className:"space-y-4",children:[T.globalPrompts.length>0&&e.jsxs("div",{children:[e.jsx("h2",{className:"text-[11px] uppercase tracking-wider text-cc-muted font-semibold mb-1.5 px-1",children:"Global"}),e.jsx("div",{className:"space-y-1",children:T.globalPrompts.map(t=>e.jsx(_,{prompt:t,isEditing:W===t.id,editName:A,editContent:D,editScope:k,editFolders:N,cwd:x,onEditNameChange:f,onEditContentChange:j,onEditScopeChange:s=>{v(s),s==="project"&&N.length===0&&x&&m([x])},onEditRemoveFolder:s=>m(r=>r.filter(n=>n!==s)),onEditAddFolder:()=>G(!0),onStartEdit:()=>{S(t.id),f(t.name),j(t.content),v(t.scope),m(t.projectPaths??(t.projectPath?[t.projectPath]:[]))},onCancelEdit:()=>{S(null),f(""),j(""),v("global"),m([])},onSaveEdit:()=>void Q(),onDelete:()=>void O(t.id)},t.id))})]}),Array.from(T.folderGroups.entries()).map(([t,s])=>e.jsxs("div",{children:[e.jsx("h2",{className:"text-[11px] uppercase tracking-wider text-cc-muted font-semibold mb-1.5 px-1",children:s.label}),e.jsx("div",{className:"space-y-1",children:s.prompts.map(r=>e.jsx(_,{prompt:r,isEditing:W===r.id,editName:A,editContent:D,editScope:k,editFolders:N,cwd:x,onEditNameChange:f,onEditContentChange:j,onEditScopeChange:n=>{v(n),n==="project"&&N.length===0&&x&&m([x])},onEditRemoveFolder:n=>m(w=>w.filter(F=>F!==n)),onEditAddFolder:()=>G(!0),onStartEdit:()=>{S(r.id),f(r.name),j(r.content),v(r.scope),m(r.projectPaths??(r.projectPath?[r.projectPath]:[]))},onCancelEdit:()=>{S(null),f(""),j(""),v("global"),m([])},onSaveEdit:()=>void Q(),onDelete:()=>void O(r.id)},r.id))})]},t))]})]}),te&&e.jsx(Y,{initialPath:x||"/",onSelect:t=>{L(s=>s.includes(t)?s:[...s,t]),V(!1)},onClose:()=>V(!1)}),se&&e.jsx(Y,{initialPath:x||"/",onSelect:t=>{m(s=>s.includes(t)?s:[...s,t]),G(!1)},onClose:()=>G(!1)})]})}function ee({scope:o,onScopeChange:a,folders:i,onRemoveFolder:h,onAddFolder:b}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"block text-xs font-medium text-cc-muted",children:"Scope"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button","aria-pressed":o==="global",onClick:()=>a("global"),className:`px-3 py-1.5 text-xs rounded-md border transition-colors cursor-pointer ${o==="global"?"border-cc-primary/40 text-cc-primary bg-cc-primary/8":"border-cc-border text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:"Global"}),e.jsx("button",{type:"button","aria-pressed":o==="project",onClick:()=>a("project"),className:`px-3 py-1.5 text-xs rounded-md border transition-colors cursor-pointer ${o==="project"?"border-cc-primary/40 text-cc-primary bg-cc-primary/8":"border-cc-border text-cc-muted hover:text-cc-fg hover:bg-cc-hover"}`,children:"Project folders"})]}),o==="project"&&e.jsxs("div",{className:"space-y-1.5",children:[i.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(l=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-md bg-cc-hover text-xs font-mono-code text-cc-fg",children:[e.jsx("span",{className:"truncate max-w-[200px]",title:l,children:l.split("/").pop()||l}),e.jsx("button",{type:"button",onClick:()=>h(l),className:"text-cc-muted hover:text-cc-error cursor-pointer shrink-0","aria-label":`Remove folder ${l}`,children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:e.jsx("path",{d:"M4 4l8 8M12 4l-8 8",strokeLinecap:"round"})})})]},l))}),e.jsxs("button",{type:"button",onClick:b,className:"inline-flex items-center gap-1 px-2 py-1 text-xs text-cc-muted hover:text-cc-fg hover:bg-cc-hover rounded-md border border-dashed border-cc-border transition-colors cursor-pointer",children:[e.jsx("svg",{viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3 h-3",children:e.jsx("path",{d:"M8 3v10M3 8h10",strokeLinecap:"round"})}),"Add folder"]})]})]})}function ie({prompt:o}){if(o.scope==="global")return e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-cc-muted opacity-60",children:"global"});const a=o.projectPaths??(o.projectPath?[o.projectPath]:[]);return a.length===0?null:e.jsx("span",{className:"inline-flex items-center gap-1 flex-wrap",children:a.map(i=>e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-cc-primary/8 text-cc-primary/70 font-mono-code",title:i,children:i.split("/").pop()||i},i))})}function _({prompt:o,isEditing:a,editName:i,editContent:h,editScope:b,editFolders:l,onEditNameChange:M,onEditContentChange:$,onEditScopeChange:d,onEditRemoveFolder:u,onEditAddFolder:I,onStartEdit:g,onCancelEdit:B,onSaveEdit:y,onDelete:R}){return a?e.jsxs("div",{className:"rounded-xl bg-cc-card p-4 space-y-3",style:{animation:"fadeSlideIn 150ms ease-out"},children:[e.jsx("input",{value:i,onChange:p=>M(p.target.value),placeholder:"Prompt title",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow"}),e.jsx("textarea",{value:h,onChange:p=>$(p.target.value),rows:4,className:"w-full px-3 py-2.5 text-sm bg-cc-bg rounded-lg text-cc-fg focus:outline-none focus:ring-1 focus:ring-cc-primary/40 resize-y transition-shadow"}),e.jsx(ee,{scope:b,onScopeChange:d,folders:l,onRemoveFolder:u,onAddFolder:I}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:B,className:"px-3 py-2.5 min-h-[44px] text-sm rounded-lg text-cc-muted hover:text-cc-fg hover:bg-cc-hover transition-colors cursor-pointer",children:"Cancel"}),e.jsx("button",{onClick:y,disabled:!i.trim()||!h.trim(),className:`px-4 py-2.5 min-h-[44px] text-sm rounded-lg font-medium transition-colors ${i.trim()&&h.trim()?"bg-cc-primary hover:bg-cc-primary-hover text-white cursor-pointer":"bg-cc-hover text-cc-muted cursor-not-allowed"}`,children:"Save"})]})]}):e.jsxs("div",{className:"group flex items-start gap-3 px-3 py-3 min-h-[44px] rounded-lg hover:bg-cc-hover/60 transition-colors",children:[e.jsx("div",{className:"shrink-0 mt-0.5 w-7 h-7 rounded-md bg-cc-primary/10 flex items-center justify-center",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5 text-cc-primary",children:e.jsx("path",{d:"M7 8h10M7 12h6M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H8l-4 4V5Z"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-cc-fg truncate",children:o.name}),e.jsx(ie,{prompt:o})]}),e.jsx("p",{className:"mt-0.5 text-xs text-cc-muted line-clamp-2 leading-relaxed",children:o.content})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-0.5 opacity-100 sm:opacity-0 sm:group-hover:opacity-100 transition-opacity",children:[e.jsx("button",{onClick:g,className:"p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md text-cc-muted hover:text-cc-fg hover:bg-cc-active transition-colors cursor-pointer","aria-label":"Edit",children:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5Z"})]})}),e.jsx("button",{onClick:R,className:"p-2 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0 sm:p-1.5 rounded-md text-cc-muted hover:text-cc-error hover:bg-cc-error/10 transition-colors cursor-pointer","aria-label":"Delete",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2m3 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6h14Z"})})})]})]})}export{de as PromptsPage};
@@ -0,0 +1 @@
1
+ import{r as c,b as d,j as e}from"./index-C6Q5UQHD.js";import{t as L}from"./time-ago-B6r_l9u1.js";function j(l){switch(l){case"manual":return"Manual";case"webhook":return"Webhook";case"schedule":return"Schedule";default:return l}}function k(l){switch(l){case"manual":return"bg-blue-500/10 text-blue-600 dark:text-blue-400";case"webhook":return"bg-purple-500/10 text-purple-600 dark:text-purple-400";case"schedule":return"bg-amber-500/10 text-amber-600 dark:text-amber-400";default:return"bg-cc-hover text-cc-muted"}}function M(l){return l.error?{label:"Error",color:"text-cc-error"}:l.success?{label:"Success",color:"text-cc-success"}:l.completedAt?{label:"Unknown",color:"text-cc-muted"}:{label:"Running",color:"text-cc-warning"}}function A(l,h){const o=(h||Date.now())-l;if(o<1e3)return"<1s";if(o<6e4)return`${Math.round(o/1e3)}s`;const g=Math.floor(o/6e4),f=Math.round(o%6e4/1e3);return`${g}m ${f}s`}function V(){const[l,h]=c.useState([]),[p,o]=c.useState([]),[g,f]=c.useState(0),[S,C]=c.useState(!0),[x,I]=c.useState("all"),[m,$]=c.useState("all"),[u,E]=c.useState(""),[r,i]=c.useState(null),[N,v]=c.useState(new Set),n=c.useCallback(async()=>{try{const t={limit:100};x!=="all"&&(t.triggerType=x),m!=="all"&&(t.status=m),u&&(t.agentId=u);const s=await d.listExecutions(t);h(s.executions),f(s.total)}catch(t){console.error("[runs] Failed to fetch executions:",t)}finally{C(!1)}},[x,m,u]),y=c.useCallback(async()=>{try{const t=await d.listAgents();o(t)}catch(t){console.error("[runs] Failed to fetch agents:",t)}},[]);c.useEffect(()=>{y()},[y]),c.useEffect(()=>{n();const t=setInterval(n,5e3);return()=>clearInterval(t)},[n]);const D=c.useCallback(async t=>{if(window.confirm("Delete this execution record?"))try{await d.deleteExecution(t),i(s=>(s==null?void 0:s.sessionId)===t?null:s),await n()}catch(s){console.error("[runs] Failed to delete execution:",s)}},[n]),F=c.useCallback(async t=>{const s=t==="error"?"errored":"successful";if(window.confirm(`Delete ALL ${s} executions? This cannot be undone.`))try{await d.bulkDeleteExecutions({status:t}),i(null),await n()}catch(a){console.error("[runs] Failed to bulk-delete executions:",a)}},[n]),T=c.useCallback(async t=>{v(s=>{const a=new Set(s);return a.add(t),a});try{await d.cancelExecution(t),await n(),i(s=>(s==null?void 0:s.sessionId)===t?null:s)}catch(s){console.error("[runs] Failed to cancel execution:",s)}finally{v(s=>{const a=new Set(s);return a.delete(t),a})}},[n]),w=t=>{const s=p.find(a=>a.id===t);return(s==null?void 0:s.name)||t};return e.jsxs("div",{className:"h-full flex flex-col bg-cc-bg",children:[e.jsx("div",{className:"shrink-0 border-b border-cc-border",children:e.jsxs("div",{className:"max-w-4xl mx-auto w-full px-4 sm:px-8 py-4",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Runs"}),e.jsx("p",{className:"text-sm text-cc-muted mt-1",children:"Monitor agent executions across all triggers"})]})}),e.jsx("div",{className:"shrink-0 border-b border-cc-border",children:e.jsxs("div",{className:"max-w-4xl mx-auto w-full px-4 sm:px-8 py-3 flex items-center gap-4 flex-wrap",children:[e.jsxs("select",{value:u,onChange:t=>E(t.target.value),className:"text-sm rounded-md border border-cc-border bg-cc-input-bg text-cc-fg px-2 py-1","aria-label":"Filter by agent",children:[e.jsx("option",{value:"",children:"All agents"}),p.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]}),e.jsx("div",{className:"flex items-center gap-1",children:["all","manual","webhook","schedule"].map(t=>e.jsx("button",{onClick:()=>I(t),className:`text-xs px-2.5 py-1 rounded-full transition-colors ${x===t?"bg-cc-fg text-cc-bg":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t==="all"?"All triggers":j(t)},t))}),e.jsx("div",{className:"flex items-center gap-1",children:["all","running","success","error"].map(t=>e.jsx("button",{onClick:()=>$(t),className:`text-xs px-2.5 py-1 rounded-full transition-colors ${m===t?"bg-cc-fg text-cc-bg":"bg-cc-hover text-cc-muted hover:text-cc-fg"}`,children:t==="all"?"All statuses":t.charAt(0).toUpperCase()+t.slice(1)},t))}),e.jsxs("div",{className:"ml-auto flex items-center gap-3",children:[e.jsxs("span",{className:"text-xs text-cc-muted",children:[g," total"]}),l.some(t=>t.error)&&e.jsx("button",{onClick:()=>F("error"),className:"text-xs px-2.5 py-1 rounded-md bg-cc-error/10 text-cc-error hover:bg-cc-error/20 transition-colors","aria-label":"Delete all errored executions",children:"Clear errors"})]})]})}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"max-w-4xl mx-auto w-full px-4 sm:px-8 py-6 pb-safe",children:S?e.jsx("div",{className:"text-sm text-cc-muted text-center py-12",children:"Loading..."}):l.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"mb-3 flex justify-center text-cc-muted",children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-8 h-8",children:e.jsx("path",{d:"M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 3.5a.75.75 0 011.5 0v3.19l2.03 2.03a.75.75 0 01-1.06 1.06l-2.25-2.25A.75.75 0 017.25 8V4.5z"})})}),e.jsx("p",{className:"text-sm text-cc-muted",children:"No executions found"}),e.jsx("p",{className:"text-xs text-cc-muted mt-1",children:"Run an agent to see executions here"})]}):e.jsxs("table",{className:"w-full text-sm",role:"table",children:[e.jsx("thead",{className:"sticky top-0 bg-cc-card backdrop-blur",children:e.jsxs("tr",{className:"text-left text-xs text-cc-muted uppercase tracking-wider",children:[e.jsx("th",{className:"px-6 py-2 font-medium",children:"Agent"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Trigger"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Started"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Duration"}),e.jsx("th",{className:"px-4 py-2 font-medium",children:"Session"}),e.jsx("th",{className:"px-2 py-2 font-medium sr-only",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-cc-border/50",children:l.map(t=>{const s=M(t),a=(r==null?void 0:r.sessionId)===t.sessionId;return e.jsxs("tr",{onClick:()=>i(a?null:t),className:`cursor-pointer transition-colors ${a?"bg-cc-active":"hover:bg-cc-hover"}`,children:[e.jsx("td",{className:"px-6 py-3",children:e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-cc-fg font-medium",children:w(t.agentId)})})}),e.jsx("td",{className:"px-4 py-3",children:e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${k(t.triggerType)}`,children:j(t.triggerType)})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("span",{className:`font-medium ${s.color}`,children:[!t.completedAt&&!t.error&&e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-cc-warning mr-1.5 animate-pulse"}),s.label]})}),e.jsx("td",{className:"px-4 py-3 text-cc-muted",children:L(t.startedAt)}),e.jsx("td",{className:"px-4 py-3 text-cc-muted font-mono text-xs",children:A(t.startedAt,t.completedAt)}),e.jsx("td",{className:"px-4 py-3",children:t.sessionId&&e.jsx("a",{href:`#/session/${t.sessionId}`,onClick:b=>b.stopPropagation(),className:"text-cc-primary hover:text-cc-primary-hover text-xs font-mono underline",children:"Open"})}),e.jsx("td",{className:"px-2 py-3 text-right",children:t.completedAt&&e.jsx("button",{onClick:b=>{b.stopPropagation(),D(t.sessionId)},className:"text-cc-muted hover:text-cc-error transition-colors p-1","aria-label":`Delete execution ${t.sessionId}`,title:"Delete",children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor",className:"w-3.5 h-3.5",children:e.jsx("path",{d:"M6.5 1a1 1 0 00-1 1V3H3a.5.5 0 000 1h.092l.806 9.673A2 2 0 005.89 15.5h4.22a2 2 0 001.991-1.827L12.908 4H13a.5.5 0 000-1h-2.5V2a1 1 0 00-1-1h-3zm0 1h3V3h-3V2zM5.107 13.595L4.31 4h7.38l-.797 9.595a1 1 0 01-.997.905H6.104a1 1 0 01-.997-.905z"})})})})]},`${t.sessionId}-${t.startedAt}`)})})]})})}),r&&e.jsxs("div",{className:"shrink-0 border-t border-cc-border bg-cc-card px-6 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-cc-fg",children:"Execution Details"}),e.jsxs("div",{className:"flex items-center gap-3",children:[!r.completedAt&&e.jsx("button",{onClick:()=>T(r.sessionId),disabled:N.has(r.sessionId),className:"text-xs px-3 py-1 rounded-md bg-cc-error/10 text-cc-error hover:bg-cc-error/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors","aria-label":"Stop execution",children:N.has(r.sessionId)?"Stopping…":"Stop"}),e.jsx("button",{onClick:()=>i(null),className:"text-cc-muted hover:text-cc-fg text-sm transition-colors","aria-label":"Close details",children:"Close"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Agent"}),e.jsx("p",{className:"text-cc-fg font-medium",children:w(r.agentId)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Trigger"}),e.jsx("p",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${k(r.triggerType)}`,children:j(r.triggerType)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Started"}),e.jsx("p",{className:"text-cc-fg",children:new Date(r.startedAt).toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-cc-muted",children:"Duration"}),e.jsx("p",{className:"text-cc-fg font-mono",children:A(r.startedAt,r.completedAt)})]})]}),r.error&&e.jsx("div",{className:"mt-3 p-2 bg-cc-error/10 rounded text-sm text-cc-error font-mono whitespace-pre-wrap",children:r.error}),r.sessionId&&e.jsx("a",{href:`#/session/${r.sessionId}`,className:"mt-3 inline-flex items-center gap-1 text-sm text-cc-primary hover:text-cc-primary-hover",children:"Open session to view live output"})]})]})}export{V as RunsPage};
@@ -1,4 +1,4 @@
1
- import{r as n,b as c,j as e}from"./index-BgYM4wXw.js";function X({embedded:f=!1}){const[u,k]=n.useState([]),[V,W]=n.useState(!0),[v,l]=n.useState(""),[o,M]=n.useState(!1),[C,R]=n.useState(!1),[b,B]=n.useState(null),[s,E]=n.useState(null),i=n.useRef(null),[p,I]=n.useState(""),[T,D]=n.useState(""),[j,y]=n.useState(null),[P,$]=n.useState(""),[N,H]=n.useState(""),[h,w]=n.useState(null),[m,d]=n.useState(null),x=n.useRef({}),[S,z]=n.useState(""),g=n.useCallback(()=>{c.listSandboxes().then(k).catch(()=>{}).finally(()=>W(!1))},[]);n.useEffect(()=>{g(),c.getContainerStatus().then(t=>B(t.available)).catch(()=>B(!1)),c.getImageStatus("heyhank:latest").then(t=>E(t)).catch(()=>{}),c.getHome().then(({cwd:t})=>z(t)).catch(()=>{})},[g]),n.useEffect(()=>{if(!s||s.status!=="pulling"){i.current&&(clearInterval(i.current),i.current=null);return}return i.current||(i.current=setInterval(()=>{c.getImageStatus("heyhank:latest").then(t=>E(t)).catch(()=>{})},2e3)),()=>{i.current&&(clearInterval(i.current),i.current=null)}},[s]);function L(){c.pullImage("heyhank:latest").then(t=>{t.state&&E(t.state)}).catch(()=>{})}async function A(){const t=p.trim();if(t){R(!0);try{await c.createSandbox(t,{initScript:T||void 0}),I(""),D(""),M(!1),l(""),g()}catch(r){l(r instanceof Error?r.message:String(r))}finally{R(!1)}}}function Z(t){x.current={},y(t.slug),$(t.name),H(t.initScript||""),d(null),l("")}function q(){x.current={},y(null),d(null),w(null),l("")}async function K(){if(j){x.current={},w(null);try{await c.updateSandbox(j,{name:P.trim()||void 0,initScript:N||void 0}),y(null),d(null),l(""),g()}catch(t){l(t instanceof Error?t.message:String(t))}}}async function U(t){try{await c.deleteSandbox(t),j===t&&y(null),g()}catch(r){l(r instanceof Error?r.message:String(r))}}async function F(t){if(!S)return;const r={};x.current=r,w(t),d(null);try{const a=await c.testInitScript(t,S,N);if(x.current!==r)return;d(a)}catch(a){if(x.current!==r)return;d({success:!1,exitCode:-1,output:a instanceof Error?a.message:String(a)})}finally{x.current===r&&w(null)}}const G=b===null?null:b?e.jsx("span",{className:"text-[10px] px-2 py-1 rounded-md bg-green-500/10 text-green-500 font-medium",children:"Docker"}):e.jsx("span",{className:"text-[10px] px-2 py-1 rounded-md bg-amber-500/10 text-amber-500 font-medium",children:"No Docker"});function J(){if(!b)return null;const t=(s==null?void 0:s.status)==="pulling";return e.jsxs("div",{className:"rounded-xl bg-cc-card p-3 sm:p-4 mb-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-[11px] font-medium text-cc-muted",children:"Base Image"}),e.jsx("code",{className:"text-[10px] font-mono-code text-cc-fg",children:"heyhank:latest"}),(s==null?void 0:s.status)==="ready"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-green-500/10 text-green-500",children:"Ready"}),(s==null?void 0:s.status)==="pulling"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-500 flex items-center gap-1",children:[e.jsx("span",{className:"w-2.5 h-2.5 border border-amber-500/30 border-t-amber-500 rounded-full animate-spin"}),"Pulling..."]}),(s==null?void 0:s.status)==="error"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-cc-error/10 text-cc-error",children:"Pull failed"}),(!s||s.status==="idle")&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-cc-hover text-cc-muted",children:"Not downloaded"})]}),(s==null?void 0:s.status)!=="ready"&&e.jsx("button",{onClick:L,disabled:t,className:`text-xs px-3 py-2 min-h-[36px] rounded-lg transition-colors shrink-0 ${t?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 cursor-pointer"}`,children:t?"Pulling...":"Pull"})]}),t&&(s==null?void 0:s.progress)&&s.progress.length>0&&e.jsx("pre",{className:"mt-2 px-3 py-2 text-[10px] font-mono-code bg-cc-code-bg rounded-lg text-cc-muted max-h-[120px] overflow-auto whitespace-pre-wrap",children:s.progress.slice(-20).join(`
1
+ import{r as n,b as c,j as e}from"./index-C6Q5UQHD.js";function X({embedded:f=!1}){const[u,k]=n.useState([]),[V,W]=n.useState(!0),[v,l]=n.useState(""),[o,M]=n.useState(!1),[C,R]=n.useState(!1),[b,B]=n.useState(null),[s,E]=n.useState(null),i=n.useRef(null),[p,I]=n.useState(""),[T,D]=n.useState(""),[j,y]=n.useState(null),[P,$]=n.useState(""),[N,H]=n.useState(""),[h,w]=n.useState(null),[m,d]=n.useState(null),x=n.useRef({}),[S,z]=n.useState(""),g=n.useCallback(()=>{c.listSandboxes().then(k).catch(()=>{}).finally(()=>W(!1))},[]);n.useEffect(()=>{g(),c.getContainerStatus().then(t=>B(t.available)).catch(()=>B(!1)),c.getImageStatus("heyhank:latest").then(t=>E(t)).catch(()=>{}),c.getHome().then(({cwd:t})=>z(t)).catch(()=>{})},[g]),n.useEffect(()=>{if(!s||s.status!=="pulling"){i.current&&(clearInterval(i.current),i.current=null);return}return i.current||(i.current=setInterval(()=>{c.getImageStatus("heyhank:latest").then(t=>E(t)).catch(()=>{})},2e3)),()=>{i.current&&(clearInterval(i.current),i.current=null)}},[s]);function L(){c.pullImage("heyhank:latest").then(t=>{t.state&&E(t.state)}).catch(()=>{})}async function A(){const t=p.trim();if(t){R(!0);try{await c.createSandbox(t,{initScript:T||void 0}),I(""),D(""),M(!1),l(""),g()}catch(r){l(r instanceof Error?r.message:String(r))}finally{R(!1)}}}function Z(t){x.current={},y(t.slug),$(t.name),H(t.initScript||""),d(null),l("")}function q(){x.current={},y(null),d(null),w(null),l("")}async function K(){if(j){x.current={},w(null);try{await c.updateSandbox(j,{name:P.trim()||void 0,initScript:N||void 0}),y(null),d(null),l(""),g()}catch(t){l(t instanceof Error?t.message:String(t))}}}async function U(t){try{await c.deleteSandbox(t),j===t&&y(null),g()}catch(r){l(r instanceof Error?r.message:String(r))}}async function F(t){if(!S)return;const r={};x.current=r,w(t),d(null);try{const a=await c.testInitScript(t,S,N);if(x.current!==r)return;d(a)}catch(a){if(x.current!==r)return;d({success:!1,exitCode:-1,output:a instanceof Error?a.message:String(a)})}finally{x.current===r&&w(null)}}const G=b===null?null:b?e.jsx("span",{className:"text-[10px] px-2 py-1 rounded-md bg-green-500/10 text-green-500 font-medium",children:"Docker"}):e.jsx("span",{className:"text-[10px] px-2 py-1 rounded-md bg-amber-500/10 text-amber-500 font-medium",children:"No Docker"});function J(){if(!b)return null;const t=(s==null?void 0:s.status)==="pulling";return e.jsxs("div",{className:"rounded-xl bg-cc-card p-3 sm:p-4 mb-5",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-[11px] font-medium text-cc-muted",children:"Base Image"}),e.jsx("code",{className:"text-[10px] font-mono-code text-cc-fg",children:"heyhank:latest"}),(s==null?void 0:s.status)==="ready"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-green-500/10 text-green-500",children:"Ready"}),(s==null?void 0:s.status)==="pulling"&&e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-500 flex items-center gap-1",children:[e.jsx("span",{className:"w-2.5 h-2.5 border border-amber-500/30 border-t-amber-500 rounded-full animate-spin"}),"Pulling..."]}),(s==null?void 0:s.status)==="error"&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-cc-error/10 text-cc-error",children:"Pull failed"}),(!s||s.status==="idle")&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-cc-hover text-cc-muted",children:"Not downloaded"})]}),(s==null?void 0:s.status)!=="ready"&&e.jsx("button",{onClick:L,disabled:t,className:`text-xs px-3 py-2 min-h-[36px] rounded-lg transition-colors shrink-0 ${t?"bg-cc-hover text-cc-muted cursor-not-allowed":"bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 cursor-pointer"}`,children:t?"Pulling...":"Pull"})]}),t&&(s==null?void 0:s.progress)&&s.progress.length>0&&e.jsx("pre",{className:"mt-2 px-3 py-2 text-[10px] font-mono-code bg-cc-code-bg rounded-lg text-cc-muted max-h-[120px] overflow-auto whitespace-pre-wrap",children:s.progress.slice(-20).join(`
2
2
  `)}),(s==null?void 0:s.status)==="error"&&s.error&&e.jsx("p",{className:"mt-2 text-[10px] text-cc-error",children:s.error})]})}return f?e.jsx("div",{className:"h-full bg-cc-bg text-cc-fg font-sans-ui antialiased overflow-y-auto overflow-x-hidden",children:e.jsxs("div",{className:"max-w-2xl mx-auto px-4 sm:px-6 py-6 sm:py-10 pb-safe",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-lg font-semibold text-cc-fg",children:"Sandboxes"}),e.jsx("p",{className:"mt-0.5 text-[13px] text-cc-muted leading-relaxed",children:"Reusable sandbox configurations for containerized sessions."})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:G})]}),J(),e.jsxs("div",{className:"flex items-center gap-2 mt-4 mb-5",children:[e.jsx("div",{className:"flex-1"}),e.jsxs("button",{onClick:()=>M(!o),className:`flex items-center gap-1.5 px-3.5 py-2.5 min-h-[44px] rounded-lg text-sm font-medium transition-colors cursor-pointer shrink-0 ${o?"bg-cc-active text-cc-fg":"bg-cc-primary hover:bg-cc-primary-hover text-white"}`,children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-4 h-4",children:o?e.jsx("path",{d:"M18 6 6 18M6 6l12 12"}):e.jsx("path",{d:"M12 5v14M5 12h14"})}),e.jsx("span",{className:"hidden sm:inline",children:o?"Cancel":"New Sandbox"})]})]}),o&&e.jsxs("div",{className:"mb-6 rounded-xl bg-cc-card p-4 sm:p-5 space-y-3",style:{animation:"fadeSlideIn 150ms ease-out"},children:[e.jsx("input",{type:"text",value:p,onChange:t=>I(t.target.value),placeholder:"Sandbox name (e.g. node-project)",className:"w-full px-3 py-2.5 min-h-[44px] text-sm bg-cc-bg rounded-lg text-cc-fg placeholder:text-cc-muted focus:outline-none focus:ring-1 focus:ring-cc-primary/40 transition-shadow",onKeyDown:t=>{t.key==="Enter"&&p.trim()&&A()}}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-medium text-cc-muted mb-1",children:"Init Script (optional)"}),e.jsx("textarea",{value:T,onChange:t=>D(t.target.value),placeholder:`# Runs inside the container before Claude starts
3
3
  # Example:
4
4
  bun install