@alook/app 0.0.115 → 0.0.116

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 (77) hide show
  1. package/bundled/email-worker/index.js +1 -4
  2. package/bundled/web/.open-next/.build/durable-objects/queue.js +5 -5
  3. package/bundled/web/.open-next/assets/BUILD_ID +1 -1
  4. package/bundled/web/.open-next/assets/_next/static/chunks/{0feon~hbkd1t8.js → 042a4jeudcp22.js} +1 -1
  5. package/bundled/web/.open-next/assets/_next/static/chunks/{0fk-wipqnt2ce.css → 05fixgtx_-ze-.css} +1 -1
  6. package/bundled/web/.open-next/assets/_next/static/chunks/0h8.l2~vkjfpw.js +3 -0
  7. package/bundled/web/.open-next/assets/_next/static/chunks/{13ogh4gvbsvjk.js → 0j5gd-ljh6ao_.js} +8 -8
  8. package/bundled/web/.open-next/cache/{ksu9gbgScKyxMGC1tp9YU → LCMVDfuuzs8SMP0bLdwOY}/_global-error.cache +1 -1
  9. package/bundled/web/.open-next/cache/{ksu9gbgScKyxMGC1tp9YU → LCMVDfuuzs8SMP0bLdwOY}/_not-found.cache +1 -1
  10. package/bundled/web/.open-next/cache/{ksu9gbgScKyxMGC1tp9YU → LCMVDfuuzs8SMP0bLdwOY}/device.cache +1 -1
  11. package/bundled/web/.open-next/cache/{ksu9gbgScKyxMGC1tp9YU → LCMVDfuuzs8SMP0bLdwOY}/privacy.cache +1 -1
  12. package/bundled/web/.open-next/cache/{ksu9gbgScKyxMGC1tp9YU → LCMVDfuuzs8SMP0bLdwOY}/sitemap.xml.cache +1 -1
  13. package/bundled/web/.open-next/cloudflare/cache-assets-manifest.sql +1 -1
  14. package/bundled/web/.open-next/cloudflare/init.js +1 -1
  15. package/bundled/web/.open-next/dynamodb-provider/dynamodb-cache.json +1 -1
  16. package/bundled/web/.open-next/middleware/handler.mjs +4 -4
  17. package/bundled/web/.open-next/server-functions/default/src/web/.next/BUILD_ID +1 -1
  18. package/bundled/web/.open-next/server-functions/default/src/web/.next/build-manifest.json +3 -3
  19. package/bundled/web/.open-next/server-functions/default/src/web/.next/prerender-manifest.json +3 -3
  20. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/invite/[token]/page_client-reference-manifest.js +1 -1
  21. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/studio/new/page_client-reference-manifest.js +1 -1
  22. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/activity/page_client-reference-manifest.js +1 -1
  23. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/chat/[convId]/page_client-reference-manifest.js +1 -1
  24. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/chat/page_client-reference-manifest.js +1 -1
  25. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/email/page_client-reference-manifest.js +1 -1
  26. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/files/page_client-reference-manifest.js +1 -1
  27. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/meetings/page_client-reference-manifest.js +1 -1
  28. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/[id]/page_client-reference-manifest.js +1 -1
  29. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/new/page_client-reference-manifest.js +1 -1
  30. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/page_client-reference-manifest.js +1 -1
  31. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/calendar/page_client-reference-manifest.js +1 -1
  32. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/flags/page_client-reference-manifest.js +1 -1
  33. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/help/email-setup/page_client-reference-manifest.js +1 -1
  34. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/home/page_client-reference-manifest.js +1 -1
  35. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/issues/page_client-reference-manifest.js +1 -1
  36. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/page_client-reference-manifest.js +1 -1
  37. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/runtimes/page_client-reference-manifest.js +1 -1
  38. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/settings/page_client-reference-manifest.js +1 -1
  39. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/threads/[traceId]/page_client-reference-manifest.js +1 -1
  40. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/threads/page_client-reference-manifest.js +1 -1
  41. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/unread/page_client-reference-manifest.js +1 -1
  42. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/workspaces/page_client-reference-manifest.js +1 -1
  43. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(auth)/sign-in/page_client-reference-manifest.js +1 -1
  44. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  45. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/device/page_client-reference-manifest.js +1 -1
  46. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/page_client-reference-manifest.js +1 -1
  47. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
  48. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/templates/[id]/page_client-reference-manifest.js +1 -1
  49. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/templates/page_client-reference-manifest.js +1 -1
  50. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[root-of-the-server]__0bzc7r~._.js +1 -4
  51. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0jj44iu._.js +1 -1
  52. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0m4uqwa._.js +1 -1
  53. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0mibx4k._.js +1 -1
  54. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0r0h9so._.js +3 -5
  55. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/src_web_src_lib_templates_index_ts_11-ty8l._.js +14 -14
  56. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0_.06ux._.js +1 -1
  57. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0sby7nn._.js +1 -1
  58. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0vtcof8._.js +1 -1
  59. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_0~23g-y._.js +1 -1
  60. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_lib_templates_index_ts_13n9_2e._.js +14 -14
  61. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-build-manifest.js +3 -3
  62. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-manifest.json +5 -5
  63. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.js +1 -1
  64. package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.json +1 -1
  65. package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs +121 -56
  66. package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs.meta.json +44 -44
  67. package/bundled/web/.open-next/server-functions/default/src/web/index.mjs +3 -3
  68. package/bundled/ws-do/index.js +1 -4
  69. package/dist/cli/index.js +1 -4
  70. package/dist/cli/session-runner.js +1 -4
  71. package/dist/index.js +1 -4
  72. package/package.json +1 -1
  73. package/bundled/web/.open-next/assets/_next/static/chunks/0oui29jtw.z4u.js +0 -3
  74. /package/bundled/web/.open-next/assets/_next/static/{ksu9gbgScKyxMGC1tp9YU → LCMVDfuuzs8SMP0bLdwOY}/_buildManifest.js +0 -0
  75. /package/bundled/web/.open-next/assets/_next/static/{ksu9gbgScKyxMGC1tp9YU → LCMVDfuuzs8SMP0bLdwOY}/_clientMiddlewareManifest.js +0 -0
  76. /package/bundled/web/.open-next/assets/_next/static/{ksu9gbgScKyxMGC1tp9YU → LCMVDfuuzs8SMP0bLdwOY}/_ssgManifest.js +0 -0
  77. /package/bundled/web/.open-next/cache/{ksu9gbgScKyxMGC1tp9YU → LCMVDfuuzs8SMP0bLdwOY}/robots.txt.cache +0 -0
@@ -1,4 +1,4 @@
1
- module.exports=[831893,896393,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(588339),e=a.i(752792),f=a.i(506180),g=a.i(626806);let h=["user_dm_message"],i=["user_dm_message"];function j(){return h}a.s(["INBOX_FILTER_LABELS",0,{user_dm_message:"DM",calendar_event:"Calendar",email_notification:"Email"},"INBOX_FILTER_TYPES",0,["user_dm_message","calendar_event","email_notification"],"MANDATORY_INBOX_TYPES",0,i,"getInboxFilterTypes",0,j,"setInboxFilterTypes",0,function(a){let b=[...a];for(let a of i)b.includes(a)||b.unshift(a);localStorage.setItem("inbox-filter-types",JSON.stringify(b))}],896393);let k=(0,c.createContext)(null),l={count:0,notificationToken:0,refresh:()=>{},decrement:()=>{}};a.s(["InboxCountProvider",0,function({children:a}){let{workspaceId:h}=(0,f.useWorkspace)(),{subscribeWs:i,agents:l}=(0,e.useAgentContext)(),[m,n]=(0,c.useState)(0),[o,p]=(0,c.useState)(0),q=(0,c.useRef)(null),r=(0,c.useRef)(null),s=(0,c.useRef)(l);(0,c.useEffect)(()=>{s.current=l});let t=(0,c.useCallback)(()=>{let a=j();(0,d.getInboxCount)(h,{types:a}).then(a=>{let b=q.current;if(q.current=a.count,n(a.count),null!==b&&a.count>b){p(a=>a+1);let a=r.current?s.current.find(a=>a.id===r.current):void 0;(0,g.sendTaskNotification)("completed",a?.name)}r.current=null}).catch(()=>{})},[h]),u=(0,c.useCallback)(()=>{n(a=>Math.max(0,a-1))},[]);return(0,c.useEffect)(()=>{t()},[t]),(0,c.useEffect)(()=>i(a=>{"task.updated"===a.type&&("completed"===a.status||"failed"===a.status)&&(r.current=a.agentId,t())}),[i,t]),(0,c.useEffect)(()=>{let a=setInterval(t,6e4);return()=>clearInterval(a)},[t]),(0,b.jsx)(k.Provider,{value:{count:m,notificationToken:o,refresh:t,decrement:u},children:a})},"useInboxCount",0,function(){return(0,c.useContext)(k)??l}],831893)},70813,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(588339),e=a.i(506180);let f=(0,c.createContext)(null);a.s(["FlagCountProvider",0,function({children:a}){let{workspaceId:g}=(0,e.useWorkspace)(),[h,i]=(0,c.useState)(0),j=(0,c.useCallback)(()=>{(0,d.getFlaggedCount)(g).then(a=>i(a.count)).catch(()=>{})},[g]),k=(0,c.useCallback)(()=>{i(a=>a+1)},[]),l=(0,c.useCallback)(()=>{i(a=>Math.max(0,a-1))},[]);return(0,c.useEffect)(()=>{j()},[j]),(0,b.jsx)(f.Provider,{value:{count:h,refresh:j,increment:k,decrement:l},children:a})},"useFlagCount",0,function(){let a=(0,c.useContext)(f);if(!a)throw Error("useFlagCount must be used within FlagCountProvider");return a}])},781418,a=>{"use strict";var b=a.i(749314),c=a.i(437199);a.i(974936);var d=a.i(911509),e=a.i(549931),f=a.i(584126),g=a.i(921584);a.i(735132);var h=a.i(253260),i=a.i(325848),j=a.i(191525),k=a.i(75118);a.s(["AgentPreviewCard",0,function({agent:a,isOnline:l,activeTaskCount:m,variant:n="default",isHovered:o}){let[p,q]=(0,c.useState)(!1),r=a.email_handle?(0,d.toAlookAddress)(a.email_handle):null,s=(0,c.useCallback)(async()=>{if(r)try{await navigator.clipboard.writeText(r),q(!0),g.toast.success("Email copied to clipboard"),setTimeout(()=>q(!1),2e3)}catch{g.toast.error("Failed to copy email")}},[r]);if("compact"===n){let c;return(0,b.jsxs)("div",{className:"flex items-center gap-2 p-0",children:[(c=(0,i.parseAvatarUrl)(a.avatar_url))?(0,b.jsx)(h.AnimatedAvatar,{config:c,size:32,className:"shrink-0 rounded-xl",isHovered:o??!1,isWorking:!!l&&(m??0)>0}):(0,b.jsx)("div",{className:"flex items-center justify-center size-8 rounded-xl bg-secondary text-secondary-foreground text-xs font-medium shrink-0",children:a.name.charAt(0).toUpperCase()}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)("p",{className:"text-sm font-medium truncate max-w-35",children:a.name}),r&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:r})]}),void 0!==l&&(0,b.jsx)("div",{className:"pointer-events-none mt-0.5",children:(0,b.jsx)(j.AgentStatusBadge,{isOnline:l,taskCount:m??0,agentId:a.id})})]})]})}return(0,b.jsxs)("div",{className:"flex flex-col gap-1.5 p-1",children:[(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)("p",{className:"text-sm font-medium truncate",children:a.name}),(0,b.jsx)("span",{className:"flex-1"}),void 0!==l&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,b.jsx)("span",{className:(0,k.cn)("size-1.5 rounded-full",l?"bg-status-online":"bg-status-offline")}),l?(m??0)>0?"Working":null:"Offline"]})]}),r&&(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:r}),(0,b.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),s()},className:"shrink-0 p-0.5 rounded-sm text-muted-foreground/60 hover:text-foreground transition-colors cursor-pointer",children:p?(0,b.jsx)(e.Check,{className:"size-3 text-green-500"}):(0,b.jsx)(f.Copy,{className:"size-3"})})]}),a.description&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2",children:a.description})]})}])},127026,40924,a=>{"use strict";a.s(["AgentChatView",()=>aK,"getEventIconType",()=>aD],127026);var b=a.i(749314),c=a.i(437199),d=a.i(131675),e=a.i(207058),f=a.i(506180),g=a.i(732254),h=a.i(464830),i=a.i(75118),j=a.i(143984),k=a.i(16831);a.i(343563);var l=a.i(347788),m=a.i(415725),n=a.i(748410),o=a.i(123047),p=a.i(723127);let q={claude:"Claude Code",codex:"Codex",opencode:"OpenCode"},r="the agent runtime";function s({provider:a,message:d,onRetry:e,retrying:f}){let[g,h]=(0,c.useState)(!1),i=f??g,j=async()=>{if(e){h(!0);try{await e()}finally{h(!1)}}};return(0,b.jsxs)("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-2 max-w-full overflow-hidden",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)("p",{className:"flex items-center gap-1.5 text-sm font-semibold text-destructive min-w-0",children:[(0,b.jsx)(o.AlertCircle,{className:"size-3.5 shrink-0"}),(0,b.jsxs)("span",{children:["Error from ",a?q[a]??r:r]})]}),e&&(0,b.jsxs)("button",{type:"button",onClick:j,disabled:i,className:"ml-auto shrink-0 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1",children:[i?(0,b.jsx)(k.Loader2,{className:"size-3 animate-spin"}):(0,b.jsx)(p.RotateCw,{className:"size-3"}),"Retry"]})]}),(0,b.jsx)("p",{className:"mt-1.5 text-sm text-destructive/90 wrap-anywhere whitespace-pre-wrap",children:d}),(0,b.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:"This came from the agent runtime on your machine, not from Alook."})]})}function t({value:a}){let d=(0,c.useRef)(a),[e,f]=(0,c.useState)({current:a,previous:null}),[g,h]=(0,c.useState)("idle");return(0,c.useEffect)(()=>{if(a===d.current)return;let b=d.current;d.current=a,f({current:a,previous:b}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{h("animating")})});let c=setTimeout(()=>{h("idle"),f(a=>({...a,previous:null}))},300);return()=>clearTimeout(c)},[a]),(0,b.jsxs)("span",{style:{display:"inline-block",position:"relative",overflow:"hidden",height:"1.2em",lineHeight:"1.2em",verticalAlign:"bottom"},children:[null!==e.previous&&(0,b.jsx)("span",{style:{display:"block",position:"absolute",inset:"0",transition:"animating"===g?"transform 250ms ease-out, opacity 250ms ease-out":"none",transform:"animating"===g?"translateY(-100%)":"translateY(0)",opacity:+("animating"!==g)},children:e.previous}),(0,b.jsx)("span",{style:{display:"block",transition:"animating"===g?"transform 250ms ease-out, opacity 250ms ease-out":"none",transform:null!==e.previous&&"animating"!==g?"translateY(100%)":"translateY(0)",opacity:+(null===e.previous||"animating"===g)},children:e.current})]})}function u({task:a,messages:d,connectionLost:e,onRetry:f,thinkingCountHint:g,onExpandThinking:o,thinkingLoading:p,provider:q}){let r=(0,c.useMemo)(()=>(function(a){let b=[];for(let c of a){let a=c.id||`seq-${c.seq}`;"text"===c.type?b.push({kind:"text",id:a,content:c.content}):"error"===c.type&&b.push({kind:"error",id:a,content:c.content||c.output})}return b})(d),[d]),v="completed"!==a.status&&"failed"!==a.status&&"cancelled"!==a.status&&"superseded"!==a.status,w=r.filter(a=>"text"===a.kind),x=r.filter(a=>"error"===a.kind),y=w.length>0?w[w.length-1]:null,z=(0,c.useRef)(null),A=(0,c.useRef)(!1);(0,c.useEffect)(()=>{v&&z.current&&(z.current.scrollTop=z.current.scrollHeight)},[w.length,v]);let B=v?w:w.slice(0,-1),C=!v&&null!==y,D=B.length>0||g&&g>0,E=B.length>0?B.length:g??0;return(0,b.jsxs)("div",{className:"space-y-3 min-w-0 max-w-full",children:[!o&&(0,b.jsx)("div",{className:"flex items-center gap-2",children:"running"===a.status?(0,b.jsxs)(h.Badge,{variant:"secondary",className:"gap-1.5 relative overflow-hidden",children:[(0,b.jsx)("span",{className:"size-1.5 rounded-full bg-primary animate-pulse"}),"Working",(0,b.jsx)("div",{className:"pointer-events-none absolute inset-0 -translate-x-full animate-[shimmer_2s_ease-in-out_infinite]",style:{background:"linear-gradient(90deg, transparent 0%, var(--shimmer) 40%, var(--shimmer-peak) 50%, var(--shimmer) 60%, transparent 100%)"}})]}):v?(0,b.jsxs)(h.Badge,{variant:"secondary",className:"relative overflow-hidden",children:[a.status,(0,b.jsx)("div",{className:"pointer-events-none absolute inset-0 -translate-x-full animate-[shimmer_2s_ease-in-out_infinite]",style:{background:"linear-gradient(90deg, transparent 0%, var(--shimmer) 40%, var(--shimmer-peak) 50%, var(--shimmer) 60%, transparent 100%)"}})]}):(0,b.jsx)(h.Badge,{variant:"secondary",children:a.status})}),D&&(0,b.jsxs)("details",{className:"group/midtext pl-1",open:!C&&!o||void 0,onToggle:a=>{a.currentTarget.open&&!A.current&&o&&(A.current=!0,o())},children:[(0,b.jsxs)("summary",{className:(0,i.cn)("flex items-center gap-1.5 py-1 cursor-pointer select-none","text-xs text-muted-foreground transition-colors duration-150","hover:text-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,b.jsx)(j.ChevronRight,{className:"size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/midtext:rotate-90"}),(0,b.jsxs)("span",{children:[(0,b.jsx)(t,{value:E})," thinking"]})]}),(0,b.jsxs)("div",{ref:z,className:"mt-1 pl-1",children:[p&&0===B.length&&(0,b.jsxs)("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[(0,b.jsx)(k.Loader2,{className:"size-3 animate-spin"}),(0,b.jsx)("span",{children:"Loading..."})]}),B.map(a=>(0,b.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 text-sm text-muted-foreground",children:(0,b.jsx)(l.Streamdown,{plugins:{mermaid:m.mermaid,cjk:n.cjk},controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},children:a.content})},a.id))]})]}),C&&!o&&(0,b.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground",children:(0,b.jsx)(l.Streamdown,{plugins:{mermaid:m.mermaid,cjk:n.cjk},controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},children:y.content})}),x.length>0&&(0,b.jsx)("div",{className:"space-y-1 mt-1",children:x.map(a=>(0,b.jsx)(s,{provider:q,message:a.content},a.id))}),"failed"===a.status&&a.error&&(0,b.jsx)("div",{className:"mt-2",children:(0,b.jsx)(s,{provider:q,message:a.error,onRetry:f})}),e&&(0,b.jsx)("p",{className:"text-sm text-muted-foreground animate-pulse mt-1",children:"Connection lost — retrying..."})]})}var v=a.i(588339),w=a.i(562706),x=a.i(752792),y=a.i(831893),z=a.i(70813),A=a.i(452906),B=a.i(921584),C=a.i(25668),D=a.i(525132),E=a.i(540858),F=a.i(647651);let G=(0,F.default)("bed-double",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]);var H=a.i(510698),I=a.i(606896);let J=(0,F.default)("message-square-quote",[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]]);var K=a.i(945081),L=a.i(546257),M=a.i(484573),N=a.i(518828);function O({skill:a,isSelected:c,onSelect:d}){return(0,b.jsxs)("button",{type:"button","data-slash-item":!0,className:(0,i.cn)("flex w-full flex-col gap-0.5 px-3 py-1.5 text-left text-sm transition-colors",c?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onMouseDown:b=>{b.preventDefault(),d(a)},children:[(0,b.jsxs)("span",{className:"flex w-full items-center gap-2",children:[(0,b.jsxs)("span",{className:"min-w-0 flex-1 truncate font-medium",children:["/",a.name]}),a.isGlobal&&(0,b.jsx)("span",{className:"shrink-0 rounded px-1 py-0.5 text-[10px] font-medium bg-muted text-muted-foreground",children:"Global"})]}),a.description&&(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:a.description.slice(0,80)})]})}function P({isOpen:a,skills:d,selectedIndex:e,onSelect:f,anchorPos:g}){let h=(0,c.useRef)(null);if((0,c.useEffect)(()=>{if(!h.current)return;let a=h.current.querySelectorAll("[data-slash-item]")[e];a?.scrollIntoView({block:"nearest"})},[e]),!a||0===d.length)return null;let i=g.left,j=Math.min(g.left,i);return(0,b.jsx)("div",{className:"fixed z-100 w-70 rounded-lg border border-border bg-popover text-popover-foreground shadow-md transition-opacity duration-150",style:{top:g.top-4,left:j,transform:"translateY(-100%)"},children:(0,b.jsx)("div",{ref:h,className:"max-h-60 overflow-y-auto py-1 thin-scrollbar",children:d.map((a,c)=>(0,b.jsx)(O,{skill:a,isSelected:c===e,onSelect:f},a.name))})})}var Q=a.i(623789),R=a.i(892236),S=a.i(807820),T=a.i(717132);function U(a,b){if(!b)return a;let c=b.toLowerCase(),d=[],e=[];for(let b of a){let a=b.name.toLowerCase();a.startsWith(c)?d.push(b):a.includes(c)&&e.push(b)}return[...d,...e]}var V=a.i(388126);function W(a){return a.replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}a.i(974936);var X=a.i(911509);let Y={items:[],selectedIndex:0,command:null,rect:null};function Z({state:a}){let e=(0,c.useRef)(null),{items:f,selectedIndex:g,command:h,rect:j}=a;if((0,c.useEffect)(()=>{if(!e.current)return;let a=e.current.children[g];a?.scrollIntoView({block:"nearest"})},[g]),!j||0===f.length||!h)return null;let k=j.left,l=Math.min(j.left,k);return(0,d.createPortal)((0,b.jsx)("div",{className:"fixed z-100 w-64 rounded-lg border border-border bg-popover text-popover-foreground shadow-md",style:{top:j.top-4,left:l,transform:"translateY(-100%)"},children:(0,b.jsx)("div",{ref:e,className:"max-h-50 overflow-y-auto py-1 thin-scrollbar",children:f.map((a,c)=>(0,b.jsxs)("button",{type:"button",className:(0,i.cn)("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition-colors",c===g?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onMouseDown:b=>{b.preventDefault(),h({id:a.id,label:a.name})},children:[(0,b.jsx)("span",{className:"truncate font-medium",children:a.name}),a.email_handle&&(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,X.toAlookAddress)(a.email_handle)})]},a.id))})}),document.body)}let $=(0,c.forwardRef)(function({value:a,onChange:d,onEditorState:e,onSend:f,placeholder:g,disabled:h,onMultiLineChange:i,onFiles:j,agents:k,agentLinks:l,currentAgentId:m,slashIsOpen:n,onSlashKeyDown:o},p){var q;let[r,s]=(0,c.useState)(Y),t=(0,c.useRef)(r);(0,c.useEffect)(()=>{t.current=r},[r]);let u=(0,c.useRef)(k),v=(0,c.useRef)(l),w=(0,c.useRef)(m),x=(0,c.useRef)(f),y=(0,c.useRef)(e),z=(0,c.useRef)(d),A=(0,c.useRef)(j),B=(0,c.useRef)(n),C=(0,c.useRef)(o);(0,c.useEffect)(()=>{u.current=k},[k]),(0,c.useEffect)(()=>{v.current=l},[l]),(0,c.useEffect)(()=>{w.current=m},[m]),(0,c.useEffect)(()=>{x.current=f},[f]),(0,c.useEffect)(()=>{y.current=e},[e]),(0,c.useEffect)(()=>{z.current=d},[d]),(0,c.useEffect)(()=>{A.current=j},[j]),(0,c.useEffect)(()=>{B.current=n},[n]),(0,c.useEffect)(()=>{C.current=o},[o]);let D=a=>{y.current(a.getText(),a.state.selection.from-1)},[E]=(0,c.useState)(()=>V.default.extend({markdownName:"mention",renderMarkdown:a=>`@${a.attrs.label??a.attrs.id}`}).configure({HTMLAttributes:{class:"mention-highlight"},renderText:({node:a})=>`@${a.attrs.label??a.attrs.id}`,suggestion:{char:"@",items:({query:a})=>(function(a,b,c,d,e=20){let f=function(a,b){let c=new Set;for(let d of a)d.source_agent_id===b&&c.add(d.target_agent_id),d.target_agent_id===b&&c.add(d.source_agent_id);return c}(b,c),g=[],h=[];for(let b of a)f.has(b.id)?g.push(b):h.push(b);return[...U(g,d),...U(h,d)].slice(0,e)})(u.current,v.current,w.current,a),render:()=>({onStart:a=>{s({items:a.items??[],selectedIndex:0,command:a.command,rect:a.clientRect?.()??null})},onUpdate:a=>{s(b=>({items:a.items??[],selectedIndex:b.selectedIndex<(a.items?.length??0)?b.selectedIndex:0,command:a.command,rect:a.clientRect?.()??null}))},onKeyDown:({event:a})=>{if(a.isComposing)return!1;let b=t.current;if(0===b.items.length)return!1;if("ArrowDown"===a.key)return a.preventDefault(),s(a=>({...a,selectedIndex:(a.selectedIndex+1)%a.items.length})),!0;if("ArrowUp"===a.key)return a.preventDefault(),s(a=>({...a,selectedIndex:(a.selectedIndex-1+a.items.length)%a.items.length})),!0;if("Enter"===a.key){a.preventDefault();let c=b.items[b.selectedIndex];return c&&b.command&&b.command({id:c.id,label:c.name}),s(Y),!0}return"Escape"===a.key&&(s(Y),!0)},onExit:()=>s(Y)})}})),F=(0,Q.useEditor)({immediatelyRender:!1,content:a?a.replaceAll("\n","<br>"):void 0,editable:!h,extensions:[R.default.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,bold:!1,italic:!1,strike:!1,code:!1,link:!1,bulletList:!1,orderedList:!1,listItem:!1,listKeymap:!1}),S.default.configure({placeholder:g??""}),T.Markdown,E],editorProps:{attributes:{class:"outline-none",enterkeyhint:"send"},handleKeyDown:(a,b)=>(!(t.current.items.length>0)||null===t.current.command)&&(!!(B.current&&C.current({key:b.key,isComposing:b.isComposing,preventDefault:()=>b.preventDefault()}))||"Enter"===b.key&&!b.shiftKey&&!b.isComposing&&!B.current&&(b.preventDefault(),x.current(),!0)),handlePaste:(a,b)=>{let c=b.clipboardData?.items;if(!c)return!1;let d=[];for(let a=0;a<c.length;a++)if("file"===c[a].kind){let b=c[a].getAsFile();b&&d.push(b)}if(d.length>0)return b.preventDefault(),A.current?.(d),!0;let e=b.clipboardData?.getData("text/plain");return!!e&&(b.preventDefault(),a.dispatch(a.state.tr.insertText(e)),!0)},handleDrop:()=>!1},onUpdate:({editor:a})=>{z.current(W(a.getMarkdown())),D(a)},onSelectionUpdate:({editor:a})=>{D(a)}});(0,c.useEffect)(()=>{F?.setEditable(!h)},[F,h]),(0,c.useEffect)(()=>{if(!F)return;let b=(a||"").trim();b!==W(F.getMarkdown()||"").trim()&&(b?F.commands.setContent((a||"").replaceAll("\n","<br>"),{emitUpdate:!1}):F.commands.clearContent(),y.current(F.getText(),F.state.selection.from-1))},[a,F]);let G=(0,c.useRef)(null);return(0,c.useEffect)(()=>{if(!F||!i)return;let a=G.current?.querySelector(".ProseMirror");if(!a)return;let b=()=>i(a.scrollHeight>32);b();let c=new ResizeObserver(b);return c.observe(a),()=>c.disconnect()},[F,i]),q=!!F?.isFocused,(0,c.useEffect)(()=>{},[G,q]),(0,c.useImperativeHandle)(p,()=>({focus:()=>F?.commands.focus(),clear:()=>F?.commands.clearContent(),isEmpty:()=>F?.isEmpty??!0,coordsAtTextIndex:a=>{if(!F)return null;try{let b=F.view.coordsAtPos(a+1);return{top:b.top,left:b.left}}catch{return null}}}),[F]),(0,b.jsxs)("div",{ref:G,className:"chat-composer relative",children:[(0,b.jsx)(Q.EditorContent,{editor:F,className:"max-h-44 overflow-y-auto thin-scrollbar pr-2 text-base chat-input-line-height"}),(0,b.jsx)(Z,{state:r})]})});var _=a.i(207461),aa=a.i(596174),ab=a.i(7455),ac=a.i(390759),ad=a.i(135510);function ae({open:a,onOpenChange:d,emailId:e,workspaceId:f}){let[h,i]=(0,c.useState)(null),[j,l]=(0,c.useState)(null),[m,n]=(0,c.useState)(!1),{width:o,onPointerDown:p,onPointerMove:q,onPointerUp:r}=(0,aa.useSheetResize)({defaultWidth:500,minWidth:320,maxWidthRatio:.8}),s=(0,c.useRef)(d);(0,c.useEffect)(()=>{s.current=d}),(0,c.useEffect)(()=>{a&&e&&(n(!0),i(null),l(null),Promise.all([(0,v.getEmail)(e,f),(0,v.getEmailBody)(e,f)]).then(([a,b])=>{i(a),l(b)}).catch(()=>{B.toast.error("Email not found"),s.current(!1)}).finally(()=>n(!1)))},[a,e,f]);let t=a=>{d(a),a||setTimeout(()=>{i(null),l(null)},300)};return(0,b.jsx)(ab.Sheet,{open:a,onOpenChange:t,children:(0,b.jsxs)(ab.SheetContent,{side:"right",showCloseButton:!1,style:{width:`min(${o}px, 100vw)`,maxWidth:"none"},className:"data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border",children:[(0,b.jsx)(aa.SheetResizeHandle,{onPointerDown:p,onPointerMove:q,onPointerUp:r}),(0,b.jsx)(ab.SheetHeader,{children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(I.Mail,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,b.jsx)(ab.SheetTitle,{className:"truncate flex-1",children:m?"Loading...":h?.subject||"Email"}),(0,b.jsx)(g.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>t(!1),children:(0,b.jsx)(N.X,{className:"h-4 w-4"})})]})}),(0,b.jsx)(ab.SheetBody,{className:"flex-1 overflow-y-auto thin-scrollbar",children:m?(0,b.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,b.jsx)(k.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):h?(0,b.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,b.jsxs)("div",{className:"text-sm space-y-1 border-b pb-3",children:[(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:"From:"}),(0,b.jsx)("span",{className:"truncate",children:h.from_email})]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:"To:"}),(0,b.jsx)("span",{className:"truncate",children:h.to_email})]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:"Date:"}),(0,b.jsx)("span",{children:new Date(h.created_at).toLocaleString()})]})]}),j?.isHtml?(0,b.jsx)(ad.EmailBodyFrame,{html:j.content,className:"max-w-full"}):(0,b.jsx)("pre",{className:"whitespace-pre-wrap text-sm font-mono",children:j?.content}),h.attachments&&h.attachments.length>0&&(0,b.jsxs)("div",{className:"border-t pt-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-1.5 mb-2 text-xs text-muted-foreground",children:[(0,b.jsx)(L.Paperclip,{className:"size-3"}),h.attachments.length," attachment",h.attachments.length>1?"s":""]}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h.attachments.map((a,c)=>(0,b.jsxs)("a",{href:`/api/email/${h.id}/attachment/${c}?workspace_id=${f}`,target:"_blank",rel:"noopener noreferrer",download:a.filename,className:"flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/50 px-2.5 py-1.5 text-xs hover:bg-muted transition-colors cursor-pointer",children:[(0,b.jsx)(ac.File,{className:"size-3 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-45",children:a.filename}),(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:a.size<1024?`${a.size} B`:a.size<1048576?`${(a.size/1024).toFixed(1)} KB`:`${(a.size/1048576).toFixed(1)} MB`})]},a.key))})]})]}):null})]})})}var af=a.i(276163),ag=a.i(963744),ah=a.i(698824);function ai({bufferedMessages:a,onDelete:d}){let[e,f]=(0,c.useState)(!1),g=a.length;if(0===g)return null;let h=Math.min(g,3);return(0,b.jsx)("div",{className:"relative px-5 pb-1",children:(0,b.jsx)("div",{className:"mx-auto max-w-2xl flex justify-center",children:(0,b.jsxs)("div",{className:"relative w-full max-w-lg transition-[height] duration-200 ease-out",style:{height:e?32*g+(g-1)*4:32+(h-1)*6},onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[a.map((a,c)=>{var f;let j=g-1-c,k=c>=g-h;return(0,b.jsx)("div",{className:"absolute right-0 left-0 transition-all duration-200 ease-out",style:{height:32,zIndex:c+1,bottom:e?36*j:k?6*j:0,transform:e?"scale(1)":`scale(${k?1-.03*j:.91})`,opacity:e?1:k?1-.2*j:0,pointerEvents:e||k?"auto":"none"},children:(0,b.jsxs)("div",{className:"h-full rounded-lg border bg-background/95 backdrop-blur-sm shadow-sm flex items-center gap-2 px-3",children:[(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-primary/60 tabular-nums w-4 text-center",children:c+1}),(0,b.jsxs)("div",{className:"min-w-0 flex-1 flex items-center gap-1.5",children:[(0,b.jsx)("p",{className:"text-[13px] text-muted-foreground leading-snug truncate",children:(f=a.content).length<=80?f:f.slice(0,80).trimEnd()+"…"}),a.attachment_ids&&a.attachment_ids.length>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 shrink-0 text-[11px] text-muted-foreground/50",children:[(0,b.jsx)(L.Paperclip,{className:"size-2.5"}),a.attachment_ids.length]})]}),(0,b.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation(),d(a.id)},className:(0,i.cn)("shrink-0 rounded-sm p-0.5 transition-all duration-150","text-muted-foreground/30 hover:text-foreground hover:bg-muted",e?"opacity-100":"opacity-0"),tabIndex:e?0:-1,children:(0,b.jsx)(N.X,{className:"size-3"})})]})},a.id)}),!e&&g>h&&(0,b.jsxs)("span",{className:"absolute -top-4 right-1 text-[10px] text-muted-foreground/40 tabular-nums",children:["+",g-h," more"]})]})})})}var aj=a.i(389660);function ak(a,b){if(b>=a.length)return!0;let c=a.charCodeAt(b);return(!(c>=48)||!(c<=57))&&(!(c>=65)||!(c<=90))&&(!(c>=97)||!(c<=122))&&95!==c}function al(a,b){if(!a||0===b.length||!a.includes("@"))return a;let c=b.slice().sort((a,b)=>b.name.length-a.name.length),d=[];for(let b=0;b<a.length;b++){if("@"!==a[b]||!function(a,b){if(0===b)return!0;let c=a.charCodeAt(b-1);return(!(c>=48)||!(c<=57))&&(!(c>=65)||!(c<=90))&&(!(c>=97)||!(c<=122))&&95!==c}(a,b))continue;let e=b+1;for(let f of c){let c=e+f.name.length;if(c>a.length||a.slice(e,c).toLowerCase()!==f.name.toLowerCase())continue;let g=c,h=a.slice(c).match(/^ \([a-zA-Z0-9-]+@alook\.ai\)/);if(h&&(g=c+h[0].length),(h||ak(a,c))&&(!h||ak(a,g))){if(d.some(a=>b>=a.start&&b<a.end))break;d.push({start:b,end:c,name:f.name,agentId:f.id});break}}}let e=a;for(let a=d.length-1;a>=0;a--){let b=d[a],c=e.slice(b.start,b.end);e=e.slice(0,b.start)+`<mention data-agent-id="${b.agentId}">${c}</mention>`+e.slice(b.end)}return e}let am={id:"",agent_id:"",runtime_id:"",conversation_id:"",workspace_id:"",prompt:"",status:"completed",priority:0,dispatched_at:null,started_at:null,completed_at:null,result:null,error:null,created_at:"",type:""};function an({taskId:a,thinkingCount:d,workspaceId:e,provider:f}){let[g,h]=(0,c.useState)([]),[i,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(!1),m=(0,c.useCallback)(async()=>{if(!k&&!i){j(!0);try{let b=await (0,v.getTaskMessages)(a,e);h(b)}catch{h([])}finally{j(!1),l(!0)}}},[k,i,a,e]);return(0,b.jsx)(u,{task:am,messages:g,thinkingCountHint:d,onExpandThinking:m,thinkingLoading:i,provider:f})}var ao=a.i(560893),ap=a.i(307992);let aq=(0,F.default)("flag",[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]]);a.s(["Flag",0,aq],40924);var ar=a.i(584126),as=a.i(549931);let at={mention:["data-agent-id"]},au=["mention"];function av({content:a,conversationType:c}){let d=aD(a,c),e="h-4 w-4 mt-0.5 shrink-0";return"issue"===d?(0,b.jsx)(ap.CircleDot,{className:e}):"email"===d?(0,b.jsx)(I.Mail,{className:e}):(0,b.jsx)(ao.Calendar,{className:e})}function aw({attachmentIds:a,artifacts:c,onArtifactClick:d}){let e=a.map(a=>c.find(b=>b.id===a)).filter(a=>!!a);return 0===e.length?null:(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:e.map(a=>(0,b.jsxs)("button",{type:"button",onClick:b=>{b.stopPropagation(),d(a)},className:"inline-flex items-center gap-1 rounded-md bg-primary-foreground/10 border border-primary-foreground/20 px-2 py-0.5 text-xs text-primary-foreground/80 hover:bg-primary-foreground/20 transition-colors cursor-pointer",children:[(0,b.jsx)(H.FileText,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-37.5",children:a.filename})]},a.id))})}function ax({pendingFiles:a,messageId:c}){let d=a.get(c);return d&&0!==d.length?(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:d.map((a,c)=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary-foreground/10 border border-primary-foreground/20 px-2 py-0.5 text-xs text-primary-foreground/80",children:[(0,b.jsx)(H.FileText,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-37.5",children:a.name})]},c))}):null}let ay={solo:"rounded-2xl",first:"rounded-tl-2xl rounded-tr-2xl rounded-bl-2xl rounded-br-md",middle:"rounded-tl-2xl rounded-tr-md rounded-bl-2xl rounded-br-md",last:"rounded-tl-2xl rounded-tr-md rounded-bl-2xl rounded-br-2xl"},az=(0,c.memo)(function({msg:a,agents:d,artifacts:e,activeTask:f,taskMessages:h,connectionLost:j,isLastMessage:k,thinkingCount:o,targetConvId:p,workspaceId:q,conversationType:r,pendingFilesByMessage:t,onArtifactClick:v,onEmailClick:w,onIssueClick:x,onCalendarEventClick:y,onRetry:z,mentionComponents:A,isFlagged:C,onToggleFlag:E,groupPosition:F="solo",provider:G}){let H,I,J,K,L,M,N,{copy:O,copied:P}=function(a=2e3){let[b,d]=(0,c.useState)(!1),e=(0,c.useRef)(void 0),f=(0,c.useCallback)(async b=>{try{return await navigator.clipboard.writeText(b),d(!0),clearTimeout(e.current),e.current=setTimeout(()=>d(!1),a),!0}catch{return!1}},[a]);return(0,c.useEffect)(()=>()=>clearTimeout(e.current),[]),{copy:f,copied:b}}(),Q=f&&"assistant"===a.role&&a.task_id===f.id&&a.conversation_id===f.conversation_id&&h.length>0,R=Q&&f&&["completed","failed","cancelled","superseded"].includes(f.status),S="assistant"===a.role?(0,b.jsxs)("div",{className:"flex flex-row items-center gap-1",children:[(0,b.jsxs)(D.Tooltip,{children:[(0,b.jsx)(D.TooltipTrigger,{render:(0,b.jsx)(g.Button,{variant:"ghost",size:"icon-xs","aria-label":P?"Copied":"Copy message",onClick:async b=>{b.stopPropagation(),await O(a.content)?B.toast.success("Copied to clipboard"):B.toast.error("Failed to copy")},className:(0,i.cn)("self-start mb-1",P?"text-green-500 opacity-100":"text-muted-foreground md:opacity-0 md:group-hover/msg:opacity-100")}),children:P?(0,b.jsx)(as.Check,{className:"size-3.5"}):(0,b.jsx)(ar.Copy,{className:"size-3.5"})}),(0,b.jsx)(D.TooltipContent,{children:P?"Copied":"Copy"})]}),E&&(0,b.jsxs)(D.Tooltip,{children:[(0,b.jsx)(D.TooltipTrigger,{render:(0,b.jsx)(g.Button,{variant:"ghost",size:"icon-xs",onClick:()=>E(a.id),className:(0,i.cn)("self-start mb-1",C?"text-primary opacity-100":"text-muted-foreground md:opacity-0 md:group-hover/msg:opacity-100")}),children:(0,b.jsx)(aq,{className:(0,i.cn)("size-3.5",C&&"fill-current")})}),(0,b.jsx)(D.TooltipContent,{children:C?"Unflag":"Flag"})]})]}):null;return(0,b.jsxs)(c.default.Fragment,{children:[Q&&(0,b.jsxs)("div",{className:(0,i.cn)("group/msg",C&&"bg-muted/30 rounded-lg px-2 -mx-2"),...R?{"data-quote-source":!0}:{},children:[(0,b.jsx)(u,{task:f,messages:h,connectionLost:j,onRetry:z,provider:G}),R&&S]}),"user"===a.role?(H=k&&!!f&&"running"!==f.status&&!["completed","failed","cancelled","superseded"].includes(f.status),I=a.content.match(/^\/(\S+)\s?([\s\S]*)$/),J=I?.[1]??null,K=I?I[2]||"":a.content,(0,b.jsx)("div",{className:"flex justify-end","data-message-id":a.id,...a.task_id?{"data-task-id":a.task_id}:{},children:(0,b.jsxs)("div",{className:(0,i.cn)("max-w-[80%] px-4 py-2 bg-primary text-primary-foreground text-base relative",ay[F]),children:[H&&(0,b.jsx)("div",{className:(0,i.cn)("absolute inset-0 animate-pulse pointer-events-none",ay[F]),style:{boxShadow:"0 0 0 2px var(--bubble-glow)"}}),J&&(0,b.jsxs)("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium bg-primary-foreground/15 text-primary-foreground mb-1",children:["/",J]}),K&&(0,b.jsx)("div",{className:"markdown markdown-user",children:(0,b.jsx)(l.Streamdown,{plugins:{mermaid:m.mermaid,cjk:n.cjk},controls:{code:{copy:!0,download:!1},table:{copy:!1,download:!1,fullscreen:!1}},linkSafety:{enabled:!1},allowedTags:at,literalTagContent:au,components:A,children:al(K,d)})}),a.attachment_ids&&a.attachment_ids.length>0&&(0,b.jsx)(aw,{attachmentIds:a.attachment_ids,artifacts:e,onArtifactClick:v}),!a.attachment_ids&&(0,b.jsx)(ax,{pendingFiles:t,messageId:a.id})]})})):"event"===a.role?(L=a.metadata?.emailId,M=a.metadata?.issueId,N=a.metadata?.calendarEventId,(0,b.jsx)("div",{className:"flex justify-start","data-message-id":a.id,...a.task_id?{"data-task-id":a.task_id}:{},children:(0,b.jsxs)("div",{className:(0,i.cn)("w-full rounded-md border bg-muted/50 text-muted-foreground text-sm px-3 py-2 flex items-start gap-2",(!!L||!!M||!!N)&&"cursor-pointer hover:bg-muted transition-colors"),onClick:L?()=>w(L):M?()=>x(M):N?()=>y(N):void 0,children:[(0,b.jsx)(av,{content:a.content,conversationType:r}),(0,b.jsx)("span",{className:"min-w-0 wrap-anywhere",children:a.content})]})})):Q?null:(0,b.jsxs)("div",{className:(0,i.cn)("group/msg flex flex-col justify-start min-w-0 overflow-x-clip",C&&"bg-muted/30 rounded-lg px-2 -mx-2"),"data-message-id":a.id,"data-quote-source":!0,...a.task_id?{"data-task-id":a.task_id}:{},children:[p&&"assistant"===a.role&&a.task_id&&o>1&&(0,b.jsx)(an,{taskId:a.task_id,thinkingCount:o-1,workspaceId:q,provider:G}),a.metadata?.error_source==="runtime"?(0,b.jsx)("div",{className:"px-1 py-1",children:(0,b.jsx)(s,{provider:a.metadata.provider??G,message:a.content})}):(0,b.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground",children:(0,b.jsx)(l.Streamdown,{plugins:{mermaid:m.mermaid,cjk:n.cjk},controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},allowedTags:at,literalTagContent:au,components:A,children:al(a.content,d)})}),S]})]})});var aA=a.i(781418),aB=a.i(722393);let aC={mention:function(a){let{children:c,...d}=a,{agents:e}=(0,x.useAgentContext)(),f=d["data-agent-id"]??d.dataAgentId,g=f?e.find(a=>a.id===f):void 0;if(!g&&"string"==typeof c){let a=c.startsWith("@")?c.slice(1):c;g=e.find(b=>b.name.toLowerCase()===a.toLowerCase())}return g?(0,b.jsxs)(aB.Popover,{children:[(0,b.jsx)(aB.PopoverTrigger,{openOnHover:!0,delay:300,nativeButton:!1,render:(0,b.jsx)("span",{className:"mention-highlight cursor-pointer"}),children:c}),(0,b.jsx)(aB.PopoverContent,{side:"top",className:"w-fit max-w-80",children:(0,b.jsx)(aA.AgentPreviewCard,{agent:g})})]}):(0,b.jsx)("span",{className:"mention-highlight",children:c})},p:({children:a,node:c,...d})=>(0,b.jsx)("div",{"data-md-p":"",...d,children:a})};function aD(a,b){if("issue_event"===b)return"issue";if("email_notification"===b)return"email";if("calendar_event"===b)return"calendar";let c=a.toLowerCase();return c.startsWith("issue ")||c.startsWith("issue:")?"issue":c.includes("email")?"email":"calendar"}function aE(a){return a.slice().sort((a,b)=>{let c=a.created_at.localeCompare(b.created_at);return 0!==c?c:a.id.localeCompare(b.id)})}function aF(a,b){let c=new Map;for(let b of a)c.set(b.id,b);for(let a of b)c.set(a.id,a);return aE([...c.values()])}function aG(a){let b=[],c=[],d=!1;for(let e of a)"message"===e.kind&&"user"===e.data.role?(d=!0,b.push(e)):"message"===e.kind&&"assistant"===e.data.role?(b.push(e),b.push(...c),c=[],d=!1):d&&"artifact"===e.kind?c.push(e):b.push(e);return b.push(...c),b}function aH(a){let b=(0,c.useRef)(a);return(0,c.useEffect)(()=>{b.current=a},[a]),b}function aI({agentName:a}){return(0,b.jsxs)("div",{className:"flex items-center gap-3 py-4 select-none","aria-hidden":!0,children:[(0,b.jsx)("div",{className:"flex-1 border-t border-border/40"}),(0,b.jsxs)("span",{className:"text-xs text-muted-foreground/60 whitespace-nowrap",children:[a," took a nap 💤"]}),(0,b.jsx)("div",{className:"flex-1 border-t border-border/40"})]})}function aJ({artifact:a,version:c,hasDuplicates:d,onClick:e}){return(0,b.jsxs)("button",{onClick:()=>e(a),className:(0,i.cn)("flex items-center gap-3 w-full max-w-sm rounded-lg border border-border/60 bg-muted/30","px-3.5 py-2.5 text-left transition-colors duration-150","hover:bg-muted/60 hover:border-border"),children:[(0,b.jsx)(H.FileText,{className:"size-4 shrink-0 text-muted-foreground"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("p",{className:"text-sm font-medium truncate",children:[a.filename,d&&(0,b.jsxs)("span",{className:"ml-1.5 text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5 font-normal",children:["v",c]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,_.formatSize)(a.size)})]})]})}function aK({agentId:a,targetConvId:h,scrollToTaskId:j,scrollToMessageId:l}){let m,n,o,p=(0,e.useParams)(),q=(0,e.useSearchParams)(),{workspaceId:r,slug:s}=(0,f.useWorkspace)(),{agents:t,runtimes:F,agentLinks:O,activeTaskCounts:Q,subscribeWs:R,subscribeReconnect:S}=(0,x.useAgentContext)(),{refresh:T}=(0,y.useInboxCount)(),{activeChannel:U,loading:V,setAgentId:W}=(0,A.useChannel)(),X=a??p.id,Y=t.find(a=>a.id===X),Z=Y?.runtime_id?F.find(a=>a.id===Y.runtime_id):null,aa=Z?.provider??null,ab=void 0!==j?j:q.get("task"),ac=void 0!==l?l:q.get("msg"),ad=void 0!==h?h:q.get("conv"),[ak,al]=(0,c.useState)(null),[am,an]=(0,c.useState)([]),[ao,ap]=(0,c.useState)(()=>""),[aq,ar]=(0,c.useState)(!1),[as,at]=(0,c.useState)(!1),[au,av]=(0,c.useState)(null),[aw,ax]=(0,c.useState)([]),[ay,aA]=(0,c.useState)(!0),[aD,aL]=(0,c.useState)(!1),[aM,aN]=(0,c.useState)(!1),[aO,aP]=(0,c.useState)(!1),[aQ,aR]=(0,c.useState)([]),[aS,aT]=(0,c.useState)(!1),[aU,aV]=(0,c.useState)(null),[aW,aX]=(0,c.useState)(!1),[aY,aZ]=(0,c.useState)(null),[a$,a_]=(0,c.useState)(!1),[a0,a1]=(0,c.useState)(null),[a2,a3]=(0,c.useState)(!1),[a4,a5]=(0,c.useState)(null),[a6,a7]=(0,c.useState)(null),[a8,a9]=(0,c.useState)(!1),[ba,bb]=(0,c.useState)(null),[bc,bd]=(0,c.useState)(null),[be,bf]=(0,c.useState)([]),[bg,bh]=(0,c.useState)([]),[bi,bj]=(0,c.useState)(null),[bk,bl]=(0,c.useState)([]),[bm,bn]=(0,c.useState)(!1),[bo,bp]=(0,c.useState)([]),[bq,br]=(0,c.useState)({}),[bs]=(0,c.useState)(()=>Date.now()),[bt,bu]=(0,c.useState)(()=>new Map),[bv,bw]=(0,c.useState)(()=>null),[bx,by]=(0,c.useState)(!1),[bz,bA]=(0,c.useState)(null),[bB,bC]=(0,c.useState)(new Set),bD=(0,c.useRef)(bB);(0,c.useEffect)(()=>{bD.current=bB});let{increment:bE,decrement:bF,refresh:bG}=(0,z.useFlagCount)(),{writeToCache:bH}=function(a,b){let[d,e]=(0,c.useState)(null),[f,g]=(0,c.useState)(!1),h=(0,c.useRef)(a);return(0,c.useEffect)(()=>{if(h.current=a,!a||!b){e(null),g(!1);return}(0,w.openCacheDB)(b);let c=!1;return(0,w.getCachedMessages)(a,b).then(b=>{c||h.current!==a||(b&&b.length>0?(e(b),g(!0)):(e(null),g(!1)))}),()=>{c=!0}},[a,b]),{cachedMessages:d,isFromCache:f,writeToCache:(0,c.useCallback)(async(a,c,d)=>{h.current&&b&&await (0,w.mergeCachedMessages)(h.current,a,c,b,d)},[b])}}(ad??null,r),bI=(0,c.useRef)(bH);(0,c.useEffect)(()=>{bI.current=bH},[bH]),(0,c.useEffect)(()=>{W(X)},[X,W]);let bJ=(0,c.useMemo)(()=>aQ.filter(a=>"agent"===a.source),[aQ]),{versionMap:bK,duplicateFilenames:bL}=(0,c.useMemo)(()=>(0,ah.computeArtifactVersions)(bJ),[bJ]),bM=(0,c.useMemo)(()=>(function(a,b,c,d){if(!d||0===c.length){let d=[...a.map(a=>({kind:"message",data:a})),...b.map(a=>({kind:"artifact",data:a})),...c.map(a=>({kind:"nap",data:a}))];return d.sort((a,b)=>{let c=a.data.created_at.localeCompare(b.data.created_at);if(0!==c)return c;if("nap"===a.kind||"nap"===b.kind){if("nap"===a.kind&&"nap"!==b.kind)return 1;if("nap"!==a.kind&&"nap"===b.kind)return -1}return a.kind!==b.kind?"message"===a.kind?-1:1:a.data.id.localeCompare(b.data.id)}),aG(d)}let e=new Set(c.map(a=>a.id.replace(/^nap-/,""))),f=[...c].sort((a,b)=>a.created_at.localeCompare(b.created_at)),g=c=>aG([...a.filter(a=>a.conversation_id===c).map(a=>({kind:"message",data:a})),...b.filter(a=>a.conversation_id===c).map(a=>({kind:"artifact",data:a}))].sort((a,b)=>{let c=a.data.created_at.localeCompare(b.data.created_at);return 0!==c?c:a.kind!==b.kind?"message"===a.kind?-1:1:a.data.id.localeCompare(b.data.id)})),h=[];for(let a of f){let b=a.id.replace(/^nap-/,"");h.push(...g(b)),h.push({kind:"nap",data:a})}h.push(...g(d));let i=new Set([...e,d]),j=a.filter(a=>!i.has(a.conversation_id)),k=b.filter(a=>!i.has(a.conversation_id));if(j.length>0||k.length>0){let a=[...j.map(a=>({kind:"message",data:a})),...k.map(a=>({kind:"artifact",data:a}))];a.sort((a,b)=>{let c=a.data.created_at.localeCompare(b.data.created_at);return 0!==c?c:a.kind!==b.kind?"message"===a.kind?-1:1:a.data.id.localeCompare(b.data.id)});let b=aG(a),c=h.findIndex(a=>"nap"===a.kind);c>=0?h.splice(c,0,...b):h.push(...b)}return h})(am,bJ,bo,ak?.id),[am,bJ,bo,ak?.id]),bN=(0,c.useMemo)(()=>(function(a){let b=Array(a.length).fill(null),c=a=>"user"===a.role||"assistant"===a.role;for(let d=0;d<a.length;d++){let e=a[d];if("message"!==e.kind)continue;let f=e.data;if(!c(f))continue;let g=d>0?a[d-1]:null,h=d<a.length-1?a[d+1]:null,i=g?.kind==="message"&&c(g.data)&&g.data.role===f.role&&(!f.created_at||!g.data.created_at||6e4>Math.abs(new Date(f.created_at).getTime()-new Date(g.data.created_at).getTime())),j=h?.kind==="message"&&c(h.data)&&h.data.role===f.role&&(!f.created_at||!h.data.created_at||6e4>Math.abs(new Date(h.data.created_at).getTime()-new Date(f.created_at).getTime()));i&&j?b[d]="middle":i&&!j?b[d]="last":!i&&j?b[d]="first":b[d]="solo"}return b})(bM),[bM]),bO=(0,c.useCallback)(a=>{(0,ah.isPreviewable)(a)?(aV(a),aT(!0)):window.open((0,ah.getArtifactUrl)(a.id,r,!0),"_blank")},[r]),bP=(0,c.useCallback)(a=>{(0,ah.isPreviewable)(a)?(aV(a),aT(!0)):window.open((0,ah.getArtifactUrl)(a.id,r,!0),"_blank")},[r]),bQ=(0,c.useRef)(null),bR=(0,c.useRef)(null),bS=(0,c.useRef)(null),bT=(0,c.useRef)(null),bU=(0,c.useRef)(0),bV=(0,c.useRef)(0),bW=(0,c.useRef)(!1),bX=(0,c.useRef)(!1),bY=(0,c.useRef)(!0),bZ=(0,c.useRef)(!1),b$=(0,c.useRef)(null),b_=(0,c.useRef)(null),b0=(0,c.useRef)(0),b1=(0,c.useRef)(void 0),b2=(0,c.useRef)(null),b3=(0,c.useRef)({completedKey:null}),b4=(0,c.useRef)(null),b5=(0,c.useRef)(null),[b6,b7]=(0,c.useState)(""),b8=(0,c.useMemo)(()=>t.filter(a=>a.id!==X),[t,X]),[b9,ca]=(0,c.useState)([]),cb=(0,c.useRef)(!1),cc=(0,c.useRef)(!1);(0,c.useEffect)(()=>{cb.current||(cb.current=!0,(0,v.getAgentSkills)(X,r).then(a=>ca(a.skills)).catch(()=>{}))},[X,r]);let[cd]=(0,c.useState)(()=>null),ce=function({input:a,caretIndex:b,skills:d,onInputChange:e,initialActiveSkill:f,getAnchorPos:g,onAfterSelect:h}){let[i,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(""),[m,n]=(0,c.useState)(0),[o,p]=(0,c.useState)({top:0,left:0}),q=(0,c.useRef)(null),r=(0,c.useMemo)(()=>{if(!i)return[];if(!k)return d;let a=k.toLowerCase(),b=[],c=[];for(let e of d){let d=e.name.toLowerCase();d.startsWith(a)?b.push(e):d.includes(a)&&c.push(e)}return[...b,...c]},[i,k,d]);(0,c.useEffect)(()=>{n(0)},[r.length,k]);let[s,t]=(0,c.useState)(f??null);(0,c.useEffect)(()=>{if(s||null===b)return void j(!1);let c=function(a,b){if(!a.startsWith("/")||0===b)return null;let c=b-1;for(;c>=0&&b-c<=30;){let d=a.charCodeAt(c);if(47===d&&0===c)return{start:0,query:a.slice(1,b)};if(10===d||13===d||32===d)break;c--}return null}(a,b);if(c){q.current=c.start,l(c.query),j(!0);let a=g(c.start);a&&p(a)}else j(!1),q.current=null},[a,b,g,s]);let u=(0,c.useCallback)(a=>{t(a),e(""),j(!1),h?.()},[e,h]),v=(0,c.useCallback)(()=>{t(null)},[]),w=(0,c.useCallback)(a=>!!i&&0!==r.length&&!a.isComposing&&("ArrowDown"===a.key?(a.preventDefault(),n(a=>(a+1)%r.length),!0):"ArrowUp"===a.key?(a.preventDefault(),n(a=>(a-1+r.length)%r.length),!0):"Enter"===a.key||"Tab"===a.key?(a.preventDefault(),u(r[m]),!0):"Escape"===a.key&&(a.preventDefault(),j(!1),!0)),[i,r,m,u]);return{isOpen:i,query:k,selectedIndex:m,anchorPos:o,skills:r,activeSkill:s,handleSlashKeyDown:w,selectSkill:u,clearActiveSkill:v,setActiveSkill:t}}({input:b6,caretIndex:bi,skills:b9,onInputChange:()=>b5.current?.clear(),initialActiveSkill:cd,getAnchorPos:(0,c.useCallback)(a=>b5.current?.coordsAtTextIndex(a)??null,[]),onAfterSelect:(0,c.useCallback)(()=>{requestAnimationFrame(()=>b5.current?.focus())},[])});(0,c.useEffect)(()=>{0===b9.length||!ce.activeSkill||b9.some(a=>a.name===ce.activeSkill.name)||ce.setActiveSkill(null)},[b9]),(0,c.useEffect)(()=>{let a=`chat-draft:${X}:${ad??"default"}`;ao?localStorage.setItem(a,ao):localStorage.removeItem(a)},[ao,X,ad]),(0,c.useEffect)(()=>{if(!cc.current)return;let a=`chat-draft-meta:${X}:${ad??"default"}`,b={};ce.activeSkill&&(b.skill={name:ce.activeSkill.name,description:ce.activeSkill.description}),bv&&(b.quote=bv),b.skill||b.quote?localStorage.setItem(a,JSON.stringify(b)):localStorage.removeItem(a)},[ce.activeSkill,bv,X,ad]),(0,c.useEffect)(()=>{aq||b5.current?.focus()},[aq]);let cf=(0,c.useCallback)(()=>{bY.current=!0,setTimeout(()=>{bQ.current?.scrollTo({top:bQ.current.scrollHeight,behavior:"smooth"})},50)},[]);(0,c.useEffect)(()=>{var a,b;if(!ad&&V)return;let c=(a={workspaceId:r,agentId:X,targetConvId:ad,scrollToTaskId:ab}).targetConvId?`${a.workspaceId}::${a.agentId}::${a.targetConvId}::${a.scrollToTaskId??""}`:null;if(b=b3.current,c&&b.completedKey===c||(b.completedKey=null,0))return;bR.current&&clearInterval(bR.current),bR.current=null,bT.current=null,b2.current=null;let d=!1;aA(!0),bW.current=!1,av(null),ax([]),bh([]),bu(new Map),bp([]),br({}),bl([]),bn(!1),b_.current=null,ap(localStorage.getItem(`chat-draft:${X}:${ad??"default"}`)??"");let e=localStorage.getItem(`chat-draft-meta:${X}:${ad??"default"}`);if(e)try{let a=JSON.parse(e);bw(a.quote??null),ce.setActiveSkill(a.skill?a.skill:null)}catch{bw(null),ce.setActiveSkill(null)}else bw(null),ce.setActiveSkill(null);async function f(a){let b=await (0,w.getCacheMeta)(a,r);if(b?.newestMessageId){let c=await (0,w.getCachedMessages)(a,r);if(d)return{painted:!1,cacheMeta:b};if(c&&c.length>0)return an(c),aN(b.hasMore),aA(!1),{painted:!0,cacheMeta:b}}return{painted:!1,cacheMeta:b}}return cc.current=!0,an([]),async function(){let a=!1;try{let b=null,c=null,e=null;if(ad){b=ad;let e=await f(b);if(d)return;c=e.cacheMeta,a=e.painted}else{let g=await (0,w.getLastOpenConversation)(X,U,r);if(d)return;if(g?.conversation_id&&g.serverMessageCount>0){let b=await f(g.conversation_id);if(d)return;b.painted&&(a=!0,e=g.conversation_id,c=b.cacheMeta)}try{let g=await (0,v.checkFreshness)({agentId:X,channel:U},r);if(d)return;if(b=g.conversation_id,e&&b!==e){bW.current=!1,bY.current=!0;let e=await f(b);if(d)return;c=e.cacheMeta,a=e.painted,e.painted||(an([]),aA(!0))}else if(!e){let e=await f(b);if(d)return;c=e.cacheMeta,a=e.painted}}catch{}}if(b){b2.current=b;let e=await (0,v.conversationInit)(b,r,{newestMessageId:c?.newestMessageId??void 0,messageCount:c?.serverMessageCount||void 0});if(d)return;if(al(e.conversation),bn(e.has_more_conversations),!e.cache_valid&&e.messages){let c=bY.current;an(a=>aF(a,e.messages)),b2.current===b&&(0,w.mergeCachedMessages)(b,e.messages,e.has_more_messages,r,e.message_count).catch(()=>{}),aN(e.has_more_messages),a&&bW.current&&c&&cf()}else c&&aN(c.hasMore);if(b2.current===b&&!ad){let a=await (0,w.getCacheMeta)(b,r);if(d)return;(0,w.setLastOpenConversation)(X,U,{conversation_id:b,newestMessageId:a?.newestMessageId??c?.newestMessageId??null,serverMessageCount:e.message_count},r).catch(()=>{})}if(br(e.thinking_counts),aR(e.artifacts),bh(e.buffered_messages),bC(new Set(e.flagged_message_ids)),e.active_task&&(av(e.active_task),ax(e.task_messages),e.task_messages.length>0&&(bU.current=Math.max(...e.task_messages.map(a=>a.seq))),b$.current?.(e.active_task.id,b,bU.current)),ab){let a=await (0,v.getTask)(ab,r).catch(()=>null);if(d)return;if(a&&!["completed","failed","cancelled","superseded"].includes(a.status)){av(a);let c=await (0,v.getTaskMessages)(ab,r).catch(()=>[]);if(d)return;ax(c),c.length>0&&(bU.current=Math.max(...c.map(a=>a.seq))),b$.current?.(a.id,b,bU.current)}}}else{let b=await (0,v.chatInit)(X,r,U);if(d)return;b2.current=b.conversation.id,al(b.conversation);let c=bY.current;an(a=>a.length>0?aF(a,b.messages):b.messages),aN(b.has_more_messages),aR(b.artifacts),bh(b.buffered_messages),bn(b.has_more_conversations),(0,w.mergeCachedMessages)(b.conversation.id,b.messages,b.has_more_messages,r).catch(()=>{}),(0,w.setLastOpenConversation)(X,U,{conversation_id:b.conversation.id,newestMessageId:b.messages.length>0?b.messages[b.messages.length-1].id:null,serverMessageCount:b.has_more_messages?0:b.messages.length},r).catch(()=>{}),a&&bW.current&&c&&cf(),(0,v.listFlaggedMessageIds)(r,b.conversation.id).then(a=>{d||bC(new Set(a.message_ids))}).catch(()=>{}),b.active_task&&(av(b.active_task),b.task_messages.length>0&&(ax(b.task_messages),bU.current=Math.max(...b.task_messages.map(a=>a.seq))),["completed","failed","cancelled","superseded"].includes(b.active_task.status)||b$.current?.(b.active_task.id,b.conversation.id,bU.current))}}catch{a?B.toast.error("Couldn't refresh conversation"):B.toast.error("Failed to load conversation")}finally{if(!d){var b;aA(!1),b=b3.current,c&&(b.completedKey=c)}}}(),()=>{d=!0}},[X,r,ad,ab,U,V]);let cg=(0,c.useRef)(T);(0,c.useEffect)(()=>{cg.current=T},[T]);let ch=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(!ak?.id||!r||ch.current===ak.id)return;ch.current=ak.id;let a=setTimeout(()=>{(0,v.markInboxRead)(ak.id,r).then(()=>cg.current()).catch(()=>{})},1e3);return()=>{ch.current=null,clearTimeout(a)}},[ak?.id,r]),(0,c.useEffect)(()=>{ay||!(am.length>0)||bW.current||(bW.current=!0,ab||ac?bY.current=!1:h?setTimeout(()=>{let a=bQ.current?.querySelectorAll("[data-quote-source]");a&&a.length>0?a[a.length-1].scrollIntoView({behavior:"instant",block:"start"}):bQ.current?.scrollTo({top:bQ.current.scrollHeight})},50):setTimeout(()=>{bQ.current?.scrollTo({top:bQ.current.scrollHeight})},50))},[ay,am.length,ab,ac,h]),(0,c.useEffect)(()=>{let a;if(!ab||ay||!ak)return;bY.current=!1,bZ.current=!0;let b=!1,c=()=>{if(b)return!1;let c=document.querySelector(`[data-task-id="${CSS.escape(ab)}"]`);return!!c&&(c.scrollIntoView({behavior:"smooth",block:"start"}),c.classList.add("task-highlight"),a=setTimeout(()=>{c.classList.remove("task-highlight"),b||(bZ.current=!1)},1500),!0)},d=setTimeout(async()=>{if(!b&&!c())try{let a=await (0,v.listMessagesAroundTask)(ak.id,r,ab);if(b)return;a.length>0?(an(b=>aF(b,a)),requestAnimationFrame(()=>{setTimeout(()=>{c()||(bZ.current=!1)},100)})):bZ.current=!1}catch{b||(bZ.current=!1)}},100);return()=>{b=!0,clearTimeout(d),a&&clearTimeout(a)}},[ab,ay,ak,r]),(0,c.useEffect)(()=>{let a;if(!ac||ab||ay||!ak)return;bY.current=!1,bZ.current=!0;let b=!1,c=setTimeout(()=>{!b&&((()=>{if(b)return!1;let c=document.querySelector(`[data-message-id="${CSS.escape(ac)}"]`);return!!c&&(c.scrollIntoView({behavior:"smooth",block:"start"}),c.classList.add("task-highlight"),a=setTimeout(()=>{c.classList.remove("task-highlight"),b||(bZ.current=!1)},1500),!0)})()||(bQ.current?.scrollTo({top:bQ.current.scrollHeight}),bZ.current=!1))},100);return()=>{b=!0,clearTimeout(c),a&&clearTimeout(a)}},[ac,ab,ay,ak]);let ci=au?.status;(0,c.useEffect)(()=>{bZ.current||("running"===ci||"queued"===ci)&&bY.current&&cf()},[aw.length,ci,cf]);let cj=(0,c.useMemo)(()=>t.find(a=>a.id===X)?.name??"Agent",[t,X]),ck=aH(am),cl=aH(aM),cm=aH(bk),cn=aH(bm),co=aH(cj),cp=aH(U),cq=(0,c.useCallback)(async(a=!1)=>{if(!ak||bX.current)return;bX.current=!0;let b=ck.current,c=cl.current,e=cn.current,f=co.current,g=cp.current,h=!!ad,i=b[0],j=b_.current?.id??ak.id,k=c&&i,l=cm.current;if(!h&&!k&&0===l.length&&e){let a=b_.current??{id:ak.id,created_at:ak.created_at};try{let b=await (0,v.listPreviousConversations)(X,r,{exclude:ak.id,before:a.created_at,channel:g});l=b.conversations,bl(b.conversations),bn(b.has_more)}catch{bn(!1)}}let m=!h&&l.length>0;if(!k&&!m){bX.current=!1;return}aP(!0);let n=bQ.current;n&&(n.style.overflowAnchor="none");let o=n?.scrollHeight??0;try{let b=[],c=[],m=20,p=!1,q=[],s=!1;if(k){let a=j===ak.id?await (0,w.getCachedMessagesBefore)(j,i.created_at,i.id,20,r):null;if(a)b=a.messages,m-=a.messages.length,p=a.hasMore;else{let a=await (0,v.listMessages)(j,r,{limit:20,before:i.created_at,beforeId:i.id});b=a.messages,m-=a.messages.length,p=a.has_more}s=p}if(!h&&!p&&m>0){if(0===l.length&&e){let a=b_.current??{id:ak.id,created_at:ak.created_at};try{let b=await (0,v.listPreviousConversations)(X,r,{exclude:ak.id,before:a.created_at,channel:g});l=b.conversations,bl(b.conversations),bn(b.has_more)}catch{bn(!1)}}let a=0,b=0;for(;a<l.length&&m>0&&b<5;){let d=l[a];a++,b++;let e=await (0,v.listMessages)(d.id,r,{limit:m});if(0===e.messages.length){b_.current=d;continue}let g=b_.current?.created_at??ak.created_at;q.push({agentName:f,created_at:g,id:`nap-${d.id}`}),c=[...e.messages,...c],m-=e.messages.length,p=e.has_more,b_.current=d}a>0&&bl(b=>b.slice(a))}let t=[...c,...b];if((0,d.flushSync)(()=>{t.length>0?(q.length>0&&bp(a=>{let b=new Set(a.map(a=>a.id)),c=q.filter(a=>!b.has(a.id));return[...a,...c]}),aN(p),an(a=>{let b=new Set(a.map(a=>a.id));return[...t.filter(a=>!b.has(a.id)),...a]})):aN(!1)}),t.length>0&&ak){let a=t.filter(a=>a.conversation_id===ak.id);a.length>0&&(0,w.mergeCachedMessages)(ak.id,a,s,r).catch(()=>{})}if(bX.current=!1,(0,d.flushSync)(()=>aP(!1)),n)if(a)n.scrollTop=n.scrollHeight;else{let a=n.scrollHeight;n.scrollTop=a-o}}catch{B.toast.error("Failed to load older messages")}finally{bX.current=!1,aP(!1),bQ.current&&(bQ.current.style.overflowAnchor="")}},[ak,r,X,ad,ck,cl,cn,co,cp,cm]),cr=ad?aM:aM||bk.length>0||bm;(0,c.useEffect)(()=>{ak?.id!==b1.current&&(b1.current=ak?.id,b0.current=0)},[ak?.id]),(0,c.useEffect)(()=>{ay||!ak||ab||ad||am.length>=10||!cr||aO||b0.current>=3||(b0.current+=1,cq(!0))},[ay,am.length,cr,aO,ak,cq,ab,ad]);let cs=(0,c.useCallback)(()=>{let a=bQ.current;a&&(bY.current=a.scrollHeight-a.scrollTop-a.clientHeight<100)},[]),ct=(0,c.useCallback)((a,b,c)=>{bR.current&&clearInterval(bR.current),bU.current=c??0,bV.current=0,aL(!1),bT.current=a,bR.current=setInterval(async()=>{if(bT.current===a)try{let[c,d]=await Promise.all([(0,v.getTask)(a,r),(0,v.getTaskMessages)(a,r,bU.current||void 0)]),e=bT.current!==a;if(bV.current=0,aL(!1),d.length>0&&!e&&(ax(a=>{let b=new Set(a.map(a=>a.seq)),c=d.filter(a=>!b.has(a.seq));return c.length>0?[...a,...c]:a}),bU.current=Math.max(...d.map(a=>a.seq),bU.current)),"completed"===c.status||"failed"===c.status||"cancelled"===c.status||"superseded"===c.status){if(e)return void(0,v.listMessages)(b,r).then(({messages:a})=>{an(b=>aF(b,a)),(0,w.mergeCachedMessages)(b,a,null,r).catch(()=>{})}).catch(()=>{});bR.current&&clearInterval(bR.current),bR.current=null,bS.current&&clearTimeout(bS.current),bS.current=setTimeout(()=>{(0,v.markInboxRead)(b,r).then(()=>cg.current()).catch(()=>{})},1e3);let d=!bZ.current&&bY.current;try{let[a,d]=await Promise.all([(0,v.listMessages)(b,r),(0,v.listArtifacts)(b,r).catch(()=>null)]);an(b=>aF(b,a.messages)),(0,w.mergeCachedMessages)(b,a.messages,null,r).catch(()=>{}),d&&aR(d),av(c)}catch{av(c),B.toast.error("Failed to refresh messages")}d&&requestAnimationFrame(()=>{bQ.current?.scrollTo({top:bQ.current.scrollHeight,behavior:"smooth"})}),setTimeout(async()=>{if(!bR.current)try{let[c,d]=await Promise.all([(0,v.getActiveTask)(b,r),(0,v.listBufferedMessages)(b,r)]);if(bh(d),c&&c.id!==a){let{messages:a}=await (0,v.listMessages)(b,r);an(b=>aF(b,a)),(0,w.mergeCachedMessages)(b,a,null,r).catch(()=>{}),av(c),ax([]),b$.current?.(c.id,b)}}catch{}},1e3)}else e||av(c)}catch{if(bT.current!==a)return;bV.current+=1,bV.current>=3&&aL(!0),bV.current>=10&&(bR.current&&clearInterval(bR.current),bR.current=null,B.toast.error("Lost connection to agent"))}},3e3)},[r]);(0,c.useEffect)(()=>{b$.current=ct},[ct]),(0,c.useEffect)(()=>()=>{bR.current&&clearInterval(bR.current),bS.current&&clearTimeout(bS.current)},[]);let cu=(0,c.useRef)(null);(0,c.useEffect)(()=>{cu.current=au?.id??null},[au]),(0,c.useEffect)(()=>R(a=>{if("task.messages"===a.type&&a.taskId===cu.current){let b=a.messages.filter(a=>a.seq>bU.current);b.length>0&&(ax(a=>{let c=new Set(a.map(a=>a.seq)),d=b.filter(a=>!c.has(a.seq));return d.length>0?[...a,...d]:a}),bU.current=Math.max(...b.map(a=>a.seq),bU.current))}if("task.created"===a.type&&a.conversationId===ak?.id){(0,v.listMessages)(a.conversationId,r).then(({messages:b})=>{an(a=>aF(a,b)),(0,w.mergeCachedMessages)(a.conversationId,b,null,r).catch(()=>{})}).catch(()=>{});let b=a.task;cu.current=b.id,av(b),ax([]),bU.current=0,b$.current?.(b.id,a.conversationId)}if("task.created"===a.type){let b=a.task,c=cp.current;(0,w.getLastOpenConversation)(X,c,r).then(a=>{let d=function(a){let{task:b,agentId:c,activeChannel:d,currentPointerConvId:e}=a;return b.agent_id!==c||(b.channel??"default")!==d||b.conversation_id===e?null:b.conversation_id}({task:b,agentId:X,activeChannel:c,currentPointerConvId:a?.conversation_id??null});if(d)return(0,w.getCacheMeta)(d,r).then(a=>(0,w.setLastOpenConversation)(X,c,{conversation_id:d,newestMessageId:a?.newestMessageId??null,serverMessageCount:a?.messageCount??0},r))}).catch(()=>{})}if("conversation.message"===a.type&&(a.conversationId===b2.current&&(0,w.appendCachedMessage)(a.conversationId,a.message,r).catch(()=>{}),a.conversationId===ak?.id&&an(b=>{let c=new Date(a.message.created_at).getTime(),d=b.findIndex(b=>b.id.startsWith("temp-")&&b.role===a.message.role&&b.content===a.message.content&&2e3>Math.abs(new Date(b.created_at).getTime()-c));if(-1!==d){let c=[...b];return c[d]=a.message,c}return aF(b,[a.message])})),"task.updated"===a.type&&a.taskId===cu.current&&av(b=>b?{...b,status:a.status}:b),"artifact.uploaded"===a.type&&a.conversationId===ak?.id&&aR(b=>b.some(b=>b.id===a.artifact.id)?b:[...b,a.artifact]),"followup.dispatched"===a.type&&a.conversationId===ak?.id){bh(b=>b.filter(b=>b.id!==a.message.id)),(0,v.listBufferedMessages)(a.conversationId,r).then(bh).catch(()=>{}),(0,v.listMessages)(a.conversationId,r).then(({messages:b})=>{an(a=>aF(a,b)),(0,w.mergeCachedMessages)(a.conversationId,b,null,r).catch(()=>{})}).catch(()=>{});let b=a.task;cu.current=b.id,av(b),ax([]),b$.current?.(b.id,a.conversationId)}"followup.created"===a.type&&a.conversationId===ak?.id&&bh(b=>(function(a,b){if(a.some(a=>a.id===b.id))return a;let c=new Date(b.created_at).getTime();return a.some(a=>a.id.startsWith("temp-")&&2e3>Math.abs(new Date(a.created_at).getTime()-c))?a:[...a,b]})(b,a.message)),"followup.deleted"===a.type&&a.conversationId===ak?.id&&bh(b=>b.filter(b=>b.id!==a.messageId)),"followup.dispatch_failed"===a.type&&a.conversationId===ak?.id&&B.toast.error(a.error||"Failed to dispatch follow-up")}),[R,ak?.id,r,X]),(0,c.useEffect)(()=>S(()=>{ak?.id&&(0,w.getCacheMeta)(ak.id,r).then(a=>{(0,v.conversationInit)(ak.id,r,{newestMessageId:a?.newestMessageId??void 0,messageCount:a?.serverMessageCount??void 0}).then(a=>{!a.cache_valid&&a.messages&&(an(b=>aF(b,a.messages)),bI.current(a.messages,a.has_more_messages,a.message_count).catch(()=>{}))}).catch(()=>{})})}),[S,ak?.id,r]);let cv=(0,c.useCallback)(a=>{let b=[];for(let c of a)c.size>0xa00000?B.toast.error(`"${c.name}" exceeds 10 MB limit`):b.push(c);b.length>0&&bf(a=>[...a,...b])},[]),cw=(0,c.useCallback)(a=>{let b=a.target.files;b&&(cv(Array.from(b)),a.target.value="")},[cv]),cx=(0,c.useCallback)(a=>{bf(b=>b.filter((b,c)=>c!==a))},[]),cy=(0,c.useCallback)(()=>{let a=window.getSelection();if(!a||a.isCollapsed||!a.rangeCount)return void bA(null);let b=a.toString().trim();if(!b)return void bA(null);let c=a.getRangeAt(0),d=c.commonAncestorContainer instanceof HTMLElement?c.commonAncestorContainer:c.commonAncestorContainer.parentElement;if(!d?.closest("[data-quote-source]"))return void bA(null);let e=c.getClientRects(),f=e[e.length-1]||c.getBoundingClientRect();bA({text:b,x:f.right,y:f.top-4})},[]);(0,c.useEffect)(()=>(document.addEventListener("selectionchange",cy),()=>document.removeEventListener("selectionchange",cy)),[cy]);let cz=(0,c.useCallback)(()=>{bz&&(bw(bz.text),bA(null),window.getSelection()?.removeAllRanges(),b5.current?.focus())},[bz]),[cA,cB]=(0,c.useState)(!1),cC=(0,c.useRef)(0),cD=(0,c.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),cC.current++,a.dataTransfer.types.includes("Files")&&cB(!0)},[]),cE=(0,c.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),cC.current--,0===cC.current&&cB(!1)},[]),cF=(0,c.useCallback)(a=>{a.preventDefault(),a.stopPropagation()},[]),cG=(0,c.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),cB(!1),cC.current=0,cv(Array.from(a.dataTransfer.files))},[cv]),cH=async()=>{if(ak&&!as){at(!0);try{let a=await (0,v.cancelActiveTask)(ak.id,r);if(a){if(cu.current&&cu.current!==a.id)return;bR.current&&clearInterval(bR.current),bR.current=null;let[b,c]=await Promise.all([(0,v.listMessages)(ak.id,r),(0,v.listBufferedMessages)(ak.id,r)]);an(a=>aF(a,b.messages)),(0,w.mergeCachedMessages)(ak.id,b.messages,null,r).catch(()=>{}),bh(c),av(a),ax([])}}catch{B.toast.error("Failed to cancel task")}finally{at(!1)}}},cI=async()=>{let a=ao.trim();if(!a&&0===be.length||aq||!ak)return;if(!a)return void B.toast.error("Please type a message");let b=bv?`> ${bv.split("\n").join("\n> ")}
1
+ module.exports=[831893,896393,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(588339),e=a.i(752792),f=a.i(506180),g=a.i(626806);let h=["user_dm_message"],i=["user_dm_message"];function j(){return h}a.s(["INBOX_FILTER_LABELS",0,{user_dm_message:"DM",calendar_event:"Calendar",email_notification:"Email"},"INBOX_FILTER_TYPES",0,["user_dm_message","calendar_event","email_notification"],"MANDATORY_INBOX_TYPES",0,i,"getInboxFilterTypes",0,j,"setInboxFilterTypes",0,function(a){let b=[...a];for(let a of i)b.includes(a)||b.unshift(a);localStorage.setItem("inbox-filter-types",JSON.stringify(b))}],896393);let k=(0,c.createContext)(null),l={count:0,notificationToken:0,refresh:()=>{},decrement:()=>{}};a.s(["InboxCountProvider",0,function({children:a}){let{workspaceId:h}=(0,f.useWorkspace)(),{subscribeWs:i,agents:l}=(0,e.useAgentContext)(),[m,n]=(0,c.useState)(0),[o,p]=(0,c.useState)(0),q=(0,c.useRef)(null),r=(0,c.useRef)(null),s=(0,c.useRef)(l);(0,c.useEffect)(()=>{s.current=l});let t=(0,c.useCallback)(()=>{let a=j();(0,d.getInboxCount)(h,{types:a}).then(a=>{let b=q.current;if(q.current=a.count,n(a.count),null!==b&&a.count>b){p(a=>a+1);let a=r.current?s.current.find(a=>a.id===r.current):void 0;(0,g.sendTaskNotification)("completed",a?.name)}r.current=null}).catch(()=>{})},[h]),u=(0,c.useCallback)(()=>{n(a=>Math.max(0,a-1))},[]);return(0,c.useEffect)(()=>{t()},[t]),(0,c.useEffect)(()=>i(a=>{"task.updated"===a.type&&("completed"===a.status||"failed"===a.status)&&(r.current=a.agentId,t())}),[i,t]),(0,c.useEffect)(()=>{let a=setInterval(t,6e4);return()=>clearInterval(a)},[t]),(0,b.jsx)(k.Provider,{value:{count:m,notificationToken:o,refresh:t,decrement:u},children:a})},"useInboxCount",0,function(){return(0,c.useContext)(k)??l}],831893)},70813,a=>{"use strict";var b=a.i(749314),c=a.i(437199),d=a.i(588339),e=a.i(506180);let f=(0,c.createContext)(null);a.s(["FlagCountProvider",0,function({children:a}){let{workspaceId:g}=(0,e.useWorkspace)(),[h,i]=(0,c.useState)(0),j=(0,c.useCallback)(()=>{(0,d.getFlaggedCount)(g).then(a=>i(a.count)).catch(()=>{})},[g]),k=(0,c.useCallback)(()=>{i(a=>a+1)},[]),l=(0,c.useCallback)(()=>{i(a=>Math.max(0,a-1))},[]);return(0,c.useEffect)(()=>{j()},[j]),(0,b.jsx)(f.Provider,{value:{count:h,refresh:j,increment:k,decrement:l},children:a})},"useFlagCount",0,function(){let a=(0,c.useContext)(f);if(!a)throw Error("useFlagCount must be used within FlagCountProvider");return a}])},781418,a=>{"use strict";var b=a.i(749314),c=a.i(437199);a.i(974936);var d=a.i(911509),e=a.i(549931),f=a.i(584126),g=a.i(921584);a.i(735132);var h=a.i(253260),i=a.i(325848),j=a.i(191525),k=a.i(75118);a.s(["AgentPreviewCard",0,function({agent:a,isOnline:l,activeTaskCount:m,variant:n="default",isHovered:o}){let[p,q]=(0,c.useState)(!1),r=a.email_handle?(0,d.toAlookAddress)(a.email_handle):null,s=(0,c.useCallback)(async()=>{if(r)try{await navigator.clipboard.writeText(r),q(!0),g.toast.success("Email copied to clipboard"),setTimeout(()=>q(!1),2e3)}catch{g.toast.error("Failed to copy email")}},[r]);if("compact"===n){let c;return(0,b.jsxs)("div",{className:"flex items-center gap-2 p-0",children:[(c=(0,i.parseAvatarUrl)(a.avatar_url))?(0,b.jsx)(h.AnimatedAvatar,{config:c,size:32,className:"shrink-0 rounded-xl",isHovered:o??!1,isWorking:!!l&&(m??0)>0}):(0,b.jsx)("div",{className:"flex items-center justify-center size-8 rounded-xl bg-secondary text-secondary-foreground text-xs font-medium shrink-0",children:a.name.charAt(0).toUpperCase()}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)("p",{className:"text-sm font-medium truncate max-w-35",children:a.name}),r&&(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:r})]}),void 0!==l&&(0,b.jsx)("div",{className:"pointer-events-none mt-0.5",children:(0,b.jsx)(j.AgentStatusBadge,{isOnline:l,taskCount:m??0,agentId:a.id})})]})]})}return(0,b.jsxs)("div",{className:"flex flex-col gap-1.5 p-1",children:[(0,b.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,b.jsx)("p",{className:"text-sm font-medium truncate",children:a.name}),(0,b.jsx)("span",{className:"flex-1"}),void 0!==l&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,b.jsx)("span",{className:(0,k.cn)("size-1.5 rounded-full",l?"bg-status-online":"bg-status-offline")}),l?(m??0)>0?"Working":null:"Offline"]})]}),r&&(0,b.jsxs)("div",{className:"flex items-center gap-1",children:[(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:r}),(0,b.jsx)("button",{type:"button",onClick:a=>{a.stopPropagation(),s()},className:"shrink-0 p-0.5 rounded-sm text-muted-foreground/60 hover:text-foreground transition-colors cursor-pointer",children:p?(0,b.jsx)(e.Check,{className:"size-3 text-green-500"}):(0,b.jsx)(f.Copy,{className:"size-3"})})]}),a.description&&(0,b.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2",children:a.description})]})}])},127026,40924,a=>{"use strict";a.s(["AgentChatView",()=>aK,"getEventIconType",()=>aD],127026);var b=a.i(749314),c=a.i(437199),d=a.i(131675),e=a.i(207058),f=a.i(506180),g=a.i(732254),h=a.i(464830),i=a.i(75118),j=a.i(143984),k=a.i(16831);a.i(343563);var l=a.i(347788),m=a.i(415725),n=a.i(748410),o=a.i(123047),p=a.i(723127);let q={claude:"Claude Code",codex:"Codex",opencode:"OpenCode"},r="the agent runtime";function s({provider:a,message:d,onRetry:e,retrying:f}){let[g,h]=(0,c.useState)(!1),i=f??g,j=async()=>{if(e){h(!0);try{await e()}finally{h(!1)}}};return(0,b.jsxs)("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-2 max-w-full overflow-hidden",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsxs)("p",{className:"flex items-center gap-1.5 text-sm font-semibold text-destructive min-w-0",children:[(0,b.jsx)(o.AlertCircle,{className:"size-3.5 shrink-0"}),(0,b.jsxs)("span",{children:["Error from ",a?q[a]??r:r]})]}),e&&(0,b.jsxs)("button",{type:"button",onClick:j,disabled:i,className:"ml-auto shrink-0 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1",children:[i?(0,b.jsx)(k.Loader2,{className:"size-3 animate-spin"}):(0,b.jsx)(p.RotateCw,{className:"size-3"}),"Retry"]})]}),(0,b.jsx)("p",{className:"mt-1.5 text-sm text-destructive/90 wrap-anywhere whitespace-pre-wrap",children:d}),(0,b.jsx)("p",{className:"mt-1.5 text-xs text-muted-foreground",children:"This came from the agent runtime on your machine, not from Alook."})]})}function t({value:a}){let d=(0,c.useRef)(a),[e,f]=(0,c.useState)({current:a,previous:null}),[g,h]=(0,c.useState)("idle");return(0,c.useEffect)(()=>{if(a===d.current)return;let b=d.current;d.current=a,f({current:a,previous:b}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{h("animating")})});let c=setTimeout(()=>{h("idle"),f(a=>({...a,previous:null}))},300);return()=>clearTimeout(c)},[a]),(0,b.jsxs)("span",{style:{display:"inline-block",position:"relative",overflow:"hidden",height:"1.2em",lineHeight:"1.2em",verticalAlign:"bottom"},children:[null!==e.previous&&(0,b.jsx)("span",{style:{display:"block",position:"absolute",inset:"0",transition:"animating"===g?"transform 250ms ease-out, opacity 250ms ease-out":"none",transform:"animating"===g?"translateY(-100%)":"translateY(0)",opacity:+("animating"!==g)},children:e.previous}),(0,b.jsx)("span",{style:{display:"block",transition:"animating"===g?"transform 250ms ease-out, opacity 250ms ease-out":"none",transform:null!==e.previous&&"animating"!==g?"translateY(100%)":"translateY(0)",opacity:+(null===e.previous||"animating"===g)},children:e.current})]})}function u({task:a,messages:d,connectionLost:e,onRetry:f,thinkingCountHint:g,onExpandThinking:o,thinkingLoading:p,provider:q}){let r=(0,c.useMemo)(()=>(function(a){let b=[];for(let c of a){let a=c.id||`seq-${c.seq}`;"text"===c.type?b.push({kind:"text",id:a,content:c.content}):"error"===c.type&&b.push({kind:"error",id:a,content:c.content||c.output})}return b})(d),[d]),v="completed"!==a.status&&"failed"!==a.status&&"cancelled"!==a.status&&"superseded"!==a.status,w=r.filter(a=>"text"===a.kind),x=r.filter(a=>"error"===a.kind),y=w.length>0?w[w.length-1]:null,z=(0,c.useRef)(null),A=(0,c.useRef)(!1);(0,c.useEffect)(()=>{v&&z.current&&(z.current.scrollTop=z.current.scrollHeight)},[w.length,v]);let B=v?w:w.slice(0,-1),C=!v&&null!==y,D=B.length>0||g&&g>0,E=B.length>0?B.length:g??0;return(0,b.jsxs)("div",{className:"space-y-3 min-w-0 max-w-full",children:[!o&&(0,b.jsx)("div",{className:"flex items-center gap-2",children:"running"===a.status?(0,b.jsxs)(h.Badge,{variant:"secondary",className:"gap-1.5 relative overflow-hidden",children:[(0,b.jsx)("span",{className:"size-1.5 rounded-full bg-primary animate-pulse"}),"Working",(0,b.jsx)("div",{className:"pointer-events-none absolute inset-0 -translate-x-full animate-[shimmer_2s_ease-in-out_infinite]",style:{background:"linear-gradient(90deg, transparent 0%, var(--shimmer) 40%, var(--shimmer-peak) 50%, var(--shimmer) 60%, transparent 100%)"}})]}):v?(0,b.jsxs)(h.Badge,{variant:"secondary",className:"relative overflow-hidden",children:[a.status,(0,b.jsx)("div",{className:"pointer-events-none absolute inset-0 -translate-x-full animate-[shimmer_2s_ease-in-out_infinite]",style:{background:"linear-gradient(90deg, transparent 0%, var(--shimmer) 40%, var(--shimmer-peak) 50%, var(--shimmer) 60%, transparent 100%)"}})]}):(0,b.jsx)(h.Badge,{variant:"secondary",children:a.status})}),D&&(0,b.jsxs)("details",{className:"group/midtext pl-1",open:!C&&!o||void 0,onToggle:a=>{a.currentTarget.open&&!A.current&&o&&(A.current=!0,o())},children:[(0,b.jsxs)("summary",{className:(0,i.cn)("flex items-center gap-1.5 py-1 cursor-pointer select-none","text-xs text-muted-foreground transition-colors duration-150","hover:text-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,b.jsx)(j.ChevronRight,{className:"size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/midtext:rotate-90"}),(0,b.jsxs)("span",{children:[(0,b.jsx)(t,{value:E})," thinking"]})]}),(0,b.jsxs)("div",{ref:z,className:"mt-1 pl-1",children:[p&&0===B.length&&(0,b.jsxs)("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[(0,b.jsx)(k.Loader2,{className:"size-3 animate-spin"}),(0,b.jsx)("span",{children:"Loading..."})]}),B.map(a=>(0,b.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 text-sm text-muted-foreground",children:(0,b.jsx)(l.Streamdown,{plugins:{mermaid:m.mermaid,cjk:n.cjk},controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},children:a.content})},a.id))]})]}),C&&!o&&(0,b.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground",children:(0,b.jsx)(l.Streamdown,{plugins:{mermaid:m.mermaid,cjk:n.cjk},controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},children:y.content})}),x.length>0&&(0,b.jsx)("div",{className:"space-y-1 mt-1",children:x.map(a=>(0,b.jsx)(s,{provider:q,message:a.content},a.id))}),"failed"===a.status&&a.error&&(0,b.jsx)("div",{className:"mt-2",children:(0,b.jsx)(s,{provider:q,message:a.error,onRetry:f})}),e&&(0,b.jsx)("p",{className:"text-sm text-muted-foreground animate-pulse mt-1",children:"Connection lost — retrying..."})]})}var v=a.i(588339),w=a.i(562706),x=a.i(752792),y=a.i(831893),z=a.i(70813),A=a.i(452906),B=a.i(921584),C=a.i(25668),D=a.i(525132),E=a.i(540858),F=a.i(647651);let G=(0,F.default)("bed-double",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]);var H=a.i(510698),I=a.i(606896);let J=(0,F.default)("message-square-quote",[["path",{d:"M14 14a2 2 0 0 0 2-2V8h-2",key:"1r06pg"}],["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M8 14a2 2 0 0 0 2-2V8H8",key:"1jzu5j"}]]);var K=a.i(945081),L=a.i(546257),M=a.i(484573),N=a.i(518828);function O({skill:a,isSelected:c,onSelect:d}){return(0,b.jsxs)("button",{type:"button","data-slash-item":!0,className:(0,i.cn)("flex w-full flex-col gap-0.5 px-3 py-1.5 text-left text-sm transition-colors",c?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onMouseDown:b=>{b.preventDefault(),d(a)},children:[(0,b.jsxs)("span",{className:"flex w-full items-center gap-2",children:[(0,b.jsxs)("span",{className:"min-w-0 flex-1 truncate font-medium",children:["/",a.name]}),a.isGlobal&&(0,b.jsx)("span",{className:"shrink-0 rounded px-1 py-0.5 text-[10px] font-medium bg-muted text-muted-foreground",children:"Global"})]}),a.description&&(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:a.description.slice(0,80)})]})}function P({isOpen:a,skills:d,selectedIndex:e,onSelect:f,anchorPos:g}){let h=(0,c.useRef)(null);if((0,c.useEffect)(()=>{if(!h.current)return;let a=h.current.querySelectorAll("[data-slash-item]")[e];a?.scrollIntoView({block:"nearest"})},[e]),!a||0===d.length)return null;let i=g.left,j=Math.min(g.left,i);return(0,b.jsx)("div",{className:"fixed z-100 w-70 rounded-lg border border-border bg-popover text-popover-foreground shadow-md transition-opacity duration-150",style:{top:g.top-4,left:j,transform:"translateY(-100%)"},children:(0,b.jsx)("div",{ref:h,className:"max-h-60 overflow-y-auto py-1 thin-scrollbar",children:d.map((a,c)=>(0,b.jsx)(O,{skill:a,isSelected:c===e,onSelect:f},a.name))})})}var Q=a.i(623789),R=a.i(892236),S=a.i(807820),T=a.i(717132);function U(a,b){if(!b)return a;let c=b.toLowerCase(),d=[],e=[];for(let b of a){let a=b.name.toLowerCase();a.startsWith(c)?d.push(b):a.includes(c)&&e.push(b)}return[...d,...e]}var V=a.i(388126);function W(a){return a.replaceAll("&lt;","<").replaceAll("&gt;",">").replaceAll("&amp;","&")}a.i(974936);var X=a.i(911509);let Y={items:[],selectedIndex:0,command:null,rect:null};function Z({state:a}){let e=(0,c.useRef)(null),{items:f,selectedIndex:g,command:h,rect:j}=a;if((0,c.useEffect)(()=>{if(!e.current)return;let a=e.current.children[g];a?.scrollIntoView({block:"nearest"})},[g]),!j||0===f.length||!h)return null;let k=j.left,l=Math.min(j.left,k);return(0,d.createPortal)((0,b.jsx)("div",{className:"fixed z-100 w-64 rounded-lg border border-border bg-popover text-popover-foreground shadow-md",style:{top:j.top-4,left:l,transform:"translateY(-100%)"},children:(0,b.jsx)("div",{ref:e,className:"max-h-50 overflow-y-auto py-1 thin-scrollbar",children:f.map((a,c)=>(0,b.jsxs)("button",{type:"button",className:(0,i.cn)("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition-colors",c===g?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onMouseDown:b=>{b.preventDefault(),h({id:a.id,label:a.name})},children:[(0,b.jsx)("span",{className:"truncate font-medium",children:a.name}),a.email_handle&&(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,X.toAlookAddress)(a.email_handle)})]},a.id))})}),document.body)}let $=(0,c.forwardRef)(function({value:a,onChange:d,onEditorState:e,onSend:f,placeholder:g,disabled:h,onMultiLineChange:i,onFiles:j,agents:k,agentLinks:l,currentAgentId:m,slashIsOpen:n,onSlashKeyDown:o},p){let[q,r]=(0,c.useState)(!1),[s,t]=(0,c.useState)(Y),u=(0,c.useRef)(s);(0,c.useEffect)(()=>{u.current=s},[s]);let v=(0,c.useRef)(k),w=(0,c.useRef)(l),x=(0,c.useRef)(m),y=(0,c.useRef)(f),z=(0,c.useRef)(e),A=(0,c.useRef)(d),B=(0,c.useRef)(j),C=(0,c.useRef)(n),D=(0,c.useRef)(o);(0,c.useEffect)(()=>{v.current=k},[k]),(0,c.useEffect)(()=>{w.current=l},[l]),(0,c.useEffect)(()=>{x.current=m},[m]),(0,c.useEffect)(()=>{y.current=f},[f]),(0,c.useEffect)(()=>{z.current=e},[e]),(0,c.useEffect)(()=>{A.current=d},[d]),(0,c.useEffect)(()=>{B.current=j},[j]),(0,c.useEffect)(()=>{C.current=n},[n]),(0,c.useEffect)(()=>{D.current=o},[o]);let E=a=>{z.current(a.getText(),a.state.selection.from-1)},[F]=(0,c.useState)(()=>V.default.extend({markdownName:"mention",renderMarkdown:a=>`@${a.attrs.label??a.attrs.id}`}).configure({HTMLAttributes:{class:"mention-highlight"},renderText:({node:a})=>`@${a.attrs.label??a.attrs.id}`,suggestion:{char:"@",items:({query:a})=>(function(a,b,c,d,e=20){let f=function(a,b){let c=new Set;for(let d of a)d.source_agent_id===b&&c.add(d.target_agent_id),d.target_agent_id===b&&c.add(d.source_agent_id);return c}(b,c),g=[],h=[];for(let b of a)f.has(b.id)?g.push(b):h.push(b);return[...U(g,d),...U(h,d)].slice(0,e)})(v.current,w.current,x.current,a),render:()=>({onStart:a=>{t({items:a.items??[],selectedIndex:0,command:a.command,rect:a.clientRect?.()??null})},onUpdate:a=>{t(b=>({items:a.items??[],selectedIndex:b.selectedIndex<(a.items?.length??0)?b.selectedIndex:0,command:a.command,rect:a.clientRect?.()??null}))},onKeyDown:({event:a})=>{if(a.isComposing)return!1;let b=u.current;if(0===b.items.length)return!1;if("ArrowDown"===a.key)return a.preventDefault(),t(a=>({...a,selectedIndex:(a.selectedIndex+1)%a.items.length})),!0;if("ArrowUp"===a.key)return a.preventDefault(),t(a=>({...a,selectedIndex:(a.selectedIndex-1+a.items.length)%a.items.length})),!0;if("Enter"===a.key){a.preventDefault();let c=b.items[b.selectedIndex];return c&&b.command&&b.command({id:c.id,label:c.name}),t(Y),!0}return"Escape"===a.key&&(t(Y),!0)},onExit:()=>t(Y)})}})),G=(0,Q.useEditor)({immediatelyRender:!1,content:a?a.replaceAll("\n","<br>"):void 0,editable:!h,extensions:[R.default.configure({heading:!1,blockquote:!1,codeBlock:!1,horizontalRule:!1,bold:!1,italic:!1,strike:!1,code:!1,link:!1,bulletList:!1,orderedList:!1,listItem:!1,listKeymap:!1}),S.default.configure({placeholder:g??""}),T.Markdown,F],editorProps:{attributes:{class:"outline-none",enterkeyhint:"send"},handleKeyDown:(a,b)=>(!(u.current.items.length>0)||null===u.current.command)&&(!!(C.current&&D.current({key:b.key,isComposing:b.isComposing,preventDefault:()=>b.preventDefault()}))||"Enter"===b.key&&!b.shiftKey&&!b.isComposing&&!C.current&&(b.preventDefault(),y.current(),!0)),handlePaste:(a,b)=>{let c=b.clipboardData?.items;if(!c)return!1;let d=[];for(let a=0;a<c.length;a++)if("file"===c[a].kind){let b=c[a].getAsFile();b&&d.push(b)}if(d.length>0)return b.preventDefault(),B.current?.(d),!0;let e=b.clipboardData?.getData("text/plain");return!!e&&(b.preventDefault(),a.dispatch(a.state.tr.insertText(e)),!0)},handleDrop:()=>!1},onFocus:()=>r(!0),onBlur:()=>r(!1),onUpdate:({editor:a})=>{A.current(W(a.getMarkdown())),E(a)},onSelectionUpdate:({editor:a})=>{E(a)}});(0,c.useEffect)(()=>{G?.setEditable(!h)},[G,h]),(0,c.useEffect)(()=>{if(!G)return;let b=(a||"").trim();b!==W(G.getMarkdown()||"").trim()&&(b?G.commands.setContent((a||"").replaceAll("\n","<br>"),{emitUpdate:!1}):G.commands.clearContent(),z.current(G.getText(),G.state.selection.from-1))},[a,G]);let H=(0,c.useRef)(null);return(0,c.useEffect)(()=>{if(!G||!i)return;let a=H.current?.querySelector(".ProseMirror");if(!a)return;let b=()=>i(a.scrollHeight>32);b();let c=new ResizeObserver(b);return c.observe(a),()=>c.disconnect()},[G,i]),(0,c.useEffect)(()=>{},[H,q]),(0,c.useImperativeHandle)(p,()=>({focus:()=>G?.commands.focus(),clear:()=>G?.commands.clearContent(),isEmpty:()=>G?.isEmpty??!0,coordsAtTextIndex:a=>{if(!G)return null;try{let b=G.view.coordsAtPos(a+1);return{top:b.top,left:b.left}}catch{return null}}}),[G]),(0,b.jsxs)("div",{ref:H,className:"chat-composer relative",children:[(0,b.jsx)(Q.EditorContent,{editor:G,className:"max-h-44 overflow-y-auto thin-scrollbar pr-2 text-base chat-input-line-height"}),(0,b.jsx)(Z,{state:s})]})});var _=a.i(207461),aa=a.i(596174),ab=a.i(7455),ac=a.i(390759),ad=a.i(135510);function ae({open:a,onOpenChange:d,emailId:e,workspaceId:f}){let[h,i]=(0,c.useState)(null),[j,l]=(0,c.useState)(null),[m,n]=(0,c.useState)(!1),{width:o,onPointerDown:p,onPointerMove:q,onPointerUp:r}=(0,aa.useSheetResize)({defaultWidth:500,minWidth:320,maxWidthRatio:.8}),s=(0,c.useRef)(d);(0,c.useEffect)(()=>{s.current=d}),(0,c.useEffect)(()=>{a&&e&&(n(!0),i(null),l(null),Promise.all([(0,v.getEmail)(e,f),(0,v.getEmailBody)(e,f)]).then(([a,b])=>{i(a),l(b)}).catch(()=>{B.toast.error("Email not found"),s.current(!1)}).finally(()=>n(!1)))},[a,e,f]);let t=a=>{d(a),a||setTimeout(()=>{i(null),l(null)},300)};return(0,b.jsx)(ab.Sheet,{open:a,onOpenChange:t,children:(0,b.jsxs)(ab.SheetContent,{side:"right",showCloseButton:!1,style:{width:`min(${o}px, 100vw)`,maxWidth:"none"},className:"data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border",children:[(0,b.jsx)(aa.SheetResizeHandle,{onPointerDown:p,onPointerMove:q,onPointerUp:r}),(0,b.jsx)(ab.SheetHeader,{children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(I.Mail,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,b.jsx)(ab.SheetTitle,{className:"truncate flex-1",children:m?"Loading...":h?.subject||"Email"}),(0,b.jsx)(g.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>t(!1),children:(0,b.jsx)(N.X,{className:"h-4 w-4"})})]})}),(0,b.jsx)(ab.SheetBody,{className:"flex-1 overflow-y-auto thin-scrollbar",children:m?(0,b.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,b.jsx)(k.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):h?(0,b.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,b.jsxs)("div",{className:"text-sm space-y-1 border-b pb-3",children:[(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:"From:"}),(0,b.jsx)("span",{className:"truncate",children:h.from_email})]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:"To:"}),(0,b.jsx)("span",{className:"truncate",children:h.to_email})]}),(0,b.jsxs)("div",{className:"flex gap-2",children:[(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:"Date:"}),(0,b.jsx)("span",{children:new Date(h.created_at).toLocaleString()})]})]}),j?.isHtml?(0,b.jsx)(ad.EmailBodyFrame,{html:j.content,className:"max-w-full"}):(0,b.jsx)("pre",{className:"whitespace-pre-wrap text-sm font-mono",children:j?.content}),h.attachments&&h.attachments.length>0&&(0,b.jsxs)("div",{className:"border-t pt-3",children:[(0,b.jsxs)("div",{className:"flex items-center gap-1.5 mb-2 text-xs text-muted-foreground",children:[(0,b.jsx)(L.Paperclip,{className:"size-3"}),h.attachments.length," attachment",h.attachments.length>1?"s":""]}),(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5",children:h.attachments.map((a,c)=>(0,b.jsxs)("a",{href:`/api/email/${h.id}/attachment/${c}?workspace_id=${f}`,target:"_blank",rel:"noopener noreferrer",download:a.filename,className:"flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/50 px-2.5 py-1.5 text-xs hover:bg-muted transition-colors cursor-pointer",children:[(0,b.jsx)(ac.File,{className:"size-3 text-muted-foreground shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-45",children:a.filename}),(0,b.jsx)("span",{className:"text-muted-foreground shrink-0",children:a.size<1024?`${a.size} B`:a.size<1048576?`${(a.size/1024).toFixed(1)} KB`:`${(a.size/1048576).toFixed(1)} MB`})]},a.key))})]})]}):null})]})})}var af=a.i(276163),ag=a.i(963744),ah=a.i(698824);function ai({bufferedMessages:a,onDelete:d}){let[e,f]=(0,c.useState)(!1),g=a.length;if(0===g)return null;let h=Math.min(g,3);return(0,b.jsx)("div",{className:"relative px-5 pb-1",children:(0,b.jsx)("div",{className:"mx-auto max-w-2xl flex justify-center",children:(0,b.jsxs)("div",{className:"relative w-full max-w-lg transition-[height] duration-200 ease-out",style:{height:e?32*g+(g-1)*4:32+(h-1)*6},onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[a.map((a,c)=>{var f;let j=g-1-c,k=c>=g-h;return(0,b.jsx)("div",{className:"absolute right-0 left-0 transition-all duration-200 ease-out",style:{height:32,zIndex:c+1,bottom:e?36*j:k?6*j:0,transform:e?"scale(1)":`scale(${k?1-.03*j:.91})`,opacity:e?1:k?1-.2*j:0,pointerEvents:e||k?"auto":"none"},children:(0,b.jsxs)("div",{className:"h-full rounded-lg border bg-background/95 backdrop-blur-sm shadow-sm flex items-center gap-2 px-3",children:[(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-primary/60 tabular-nums w-4 text-center",children:c+1}),(0,b.jsxs)("div",{className:"min-w-0 flex-1 flex items-center gap-1.5",children:[(0,b.jsx)("p",{className:"text-[13px] text-muted-foreground leading-snug truncate",children:(f=a.content).length<=80?f:f.slice(0,80).trimEnd()+"…"}),a.attachment_ids&&a.attachment_ids.length>0&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 shrink-0 text-[11px] text-muted-foreground/50",children:[(0,b.jsx)(L.Paperclip,{className:"size-2.5"}),a.attachment_ids.length]})]}),(0,b.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation(),d(a.id)},className:(0,i.cn)("shrink-0 rounded-sm p-0.5 transition-all duration-150","text-muted-foreground/30 hover:text-foreground hover:bg-muted",e?"opacity-100":"opacity-0"),tabIndex:e?0:-1,children:(0,b.jsx)(N.X,{className:"size-3"})})]})},a.id)}),!e&&g>h&&(0,b.jsxs)("span",{className:"absolute -top-4 right-1 text-[10px] text-muted-foreground/40 tabular-nums",children:["+",g-h," more"]})]})})})}var aj=a.i(389660);function ak(a,b){if(b>=a.length)return!0;let c=a.charCodeAt(b);return(!(c>=48)||!(c<=57))&&(!(c>=65)||!(c<=90))&&(!(c>=97)||!(c<=122))&&95!==c}function al(a,b){if(!a||0===b.length||!a.includes("@"))return a;let c=b.slice().sort((a,b)=>b.name.length-a.name.length),d=[];for(let b=0;b<a.length;b++){if("@"!==a[b]||!function(a,b){if(0===b)return!0;let c=a.charCodeAt(b-1);return(!(c>=48)||!(c<=57))&&(!(c>=65)||!(c<=90))&&(!(c>=97)||!(c<=122))&&95!==c}(a,b))continue;let e=b+1;for(let f of c){let c=e+f.name.length;if(c>a.length||a.slice(e,c).toLowerCase()!==f.name.toLowerCase())continue;let g=c,h=a.slice(c).match(/^ \([a-zA-Z0-9-]+@alook\.ai\)/);if(h&&(g=c+h[0].length),(h||ak(a,c))&&(!h||ak(a,g))){if(d.some(a=>b>=a.start&&b<a.end))break;d.push({start:b,end:c,name:f.name,agentId:f.id});break}}}let e=a;for(let a=d.length-1;a>=0;a--){let b=d[a],c=e.slice(b.start,b.end);e=e.slice(0,b.start)+`<mention data-agent-id="${b.agentId}">${c}</mention>`+e.slice(b.end)}return e}let am={id:"",agent_id:"",runtime_id:"",conversation_id:"",workspace_id:"",prompt:"",status:"completed",priority:0,dispatched_at:null,started_at:null,completed_at:null,result:null,error:null,created_at:"",type:""};function an({taskId:a,thinkingCount:d,workspaceId:e,provider:f}){let[g,h]=(0,c.useState)([]),[i,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(!1),m=(0,c.useCallback)(async()=>{if(!k&&!i){j(!0);try{let b=await (0,v.getTaskMessages)(a,e);h(b)}catch{h([])}finally{j(!1),l(!0)}}},[k,i,a,e]);return(0,b.jsx)(u,{task:am,messages:g,thinkingCountHint:d,onExpandThinking:m,thinkingLoading:i,provider:f})}var ao=a.i(560893),ap=a.i(307992);let aq=(0,F.default)("flag",[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]]);a.s(["Flag",0,aq],40924);var ar=a.i(584126),as=a.i(549931);let at={mention:["data-agent-id"]},au=["mention"];function av({content:a,conversationType:c}){let d=aD(a,c),e="h-4 w-4 mt-0.5 shrink-0";return"issue"===d?(0,b.jsx)(ap.CircleDot,{className:e}):"email"===d?(0,b.jsx)(I.Mail,{className:e}):(0,b.jsx)(ao.Calendar,{className:e})}function aw({attachmentIds:a,artifacts:c,onArtifactClick:d}){let e=a.map(a=>c.find(b=>b.id===a)).filter(a=>!!a);return 0===e.length?null:(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:e.map(a=>(0,b.jsxs)("button",{type:"button",onClick:b=>{b.stopPropagation(),d(a)},className:"inline-flex items-center gap-1 rounded-md bg-primary-foreground/10 border border-primary-foreground/20 px-2 py-0.5 text-xs text-primary-foreground/80 hover:bg-primary-foreground/20 transition-colors cursor-pointer",children:[(0,b.jsx)(H.FileText,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-37.5",children:a.filename})]},a.id))})}function ax({pendingFiles:a,messageId:c}){let d=a.get(c);return d&&0!==d.length?(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:d.map((a,c)=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-primary-foreground/10 border border-primary-foreground/20 px-2 py-0.5 text-xs text-primary-foreground/80",children:[(0,b.jsx)(H.FileText,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-37.5",children:a.name})]},c))}):null}let ay={solo:"rounded-2xl",first:"rounded-tl-2xl rounded-tr-2xl rounded-bl-2xl rounded-br-md",middle:"rounded-tl-2xl rounded-tr-md rounded-bl-2xl rounded-br-md",last:"rounded-tl-2xl rounded-tr-md rounded-bl-2xl rounded-br-2xl"},az=(0,c.memo)(function({msg:a,agents:d,artifacts:e,activeTask:f,taskMessages:h,connectionLost:j,isLastMessage:k,thinkingCount:o,targetConvId:p,workspaceId:q,conversationType:r,pendingFilesByMessage:t,onArtifactClick:v,onEmailClick:w,onIssueClick:x,onCalendarEventClick:y,onRetry:z,mentionComponents:A,isFlagged:C,onToggleFlag:E,groupPosition:F="solo",provider:G}){let H,I,J,K,L,M,N,{copy:O,copied:P}=function(a=2e3){let[b,d]=(0,c.useState)(!1),e=(0,c.useRef)(void 0),f=(0,c.useCallback)(async b=>{try{return await navigator.clipboard.writeText(b),d(!0),clearTimeout(e.current),e.current=setTimeout(()=>d(!1),a),!0}catch{return!1}},[a]);return(0,c.useEffect)(()=>()=>clearTimeout(e.current),[]),{copy:f,copied:b}}(),Q=f&&"assistant"===a.role&&a.task_id===f.id&&a.conversation_id===f.conversation_id&&h.length>0,R=Q&&f&&["completed","failed","cancelled","superseded"].includes(f.status),S="assistant"===a.role?(0,b.jsxs)("div",{className:"flex flex-row items-center gap-1",children:[(0,b.jsxs)(D.Tooltip,{children:[(0,b.jsx)(D.TooltipTrigger,{render:(0,b.jsx)(g.Button,{variant:"ghost",size:"icon-xs","aria-label":P?"Copied":"Copy message",onClick:async b=>{b.stopPropagation(),await O(a.content)?B.toast.success("Copied to clipboard"):B.toast.error("Failed to copy")},className:(0,i.cn)("self-start mb-1",P?"text-green-500 opacity-100":"text-muted-foreground md:opacity-0 md:group-hover/msg:opacity-100")}),children:P?(0,b.jsx)(as.Check,{className:"size-3.5"}):(0,b.jsx)(ar.Copy,{className:"size-3.5"})}),(0,b.jsx)(D.TooltipContent,{children:P?"Copied":"Copy"})]}),E&&(0,b.jsxs)(D.Tooltip,{children:[(0,b.jsx)(D.TooltipTrigger,{render:(0,b.jsx)(g.Button,{variant:"ghost",size:"icon-xs",onClick:()=>E(a.id),className:(0,i.cn)("self-start mb-1",C?"text-primary opacity-100":"text-muted-foreground md:opacity-0 md:group-hover/msg:opacity-100")}),children:(0,b.jsx)(aq,{className:(0,i.cn)("size-3.5",C&&"fill-current")})}),(0,b.jsx)(D.TooltipContent,{children:C?"Unflag":"Flag"})]})]}):null;return(0,b.jsxs)(c.default.Fragment,{children:[Q&&(0,b.jsxs)("div",{className:(0,i.cn)("group/msg",C&&"bg-muted/30 rounded-lg px-2 -mx-2"),...R?{"data-quote-source":!0}:{},children:[(0,b.jsx)(u,{task:f,messages:h,connectionLost:j,onRetry:z,provider:G}),R&&S]}),"user"===a.role?(H=k&&!!f&&"running"!==f.status&&!["completed","failed","cancelled","superseded"].includes(f.status),I=a.content.match(/^\/(\S+)\s?([\s\S]*)$/),J=I?.[1]??null,K=I?I[2]||"":a.content,(0,b.jsx)("div",{className:"flex justify-end","data-message-id":a.id,...a.task_id?{"data-task-id":a.task_id}:{},children:(0,b.jsxs)("div",{className:(0,i.cn)("max-w-[80%] px-4 py-2 bg-primary text-primary-foreground text-base relative",ay[F]),children:[H&&(0,b.jsx)("div",{className:(0,i.cn)("absolute inset-0 animate-pulse pointer-events-none",ay[F]),style:{boxShadow:"0 0 0 2px var(--bubble-glow)"}}),J&&(0,b.jsxs)("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium bg-primary-foreground/15 text-primary-foreground mb-1",children:["/",J]}),K&&(0,b.jsx)("div",{className:"markdown markdown-user",children:(0,b.jsx)(l.Streamdown,{plugins:{mermaid:m.mermaid,cjk:n.cjk},controls:{code:{copy:!0,download:!1},table:{copy:!1,download:!1,fullscreen:!1}},linkSafety:{enabled:!1},allowedTags:at,literalTagContent:au,components:A,children:al(K,d)})}),a.attachment_ids&&a.attachment_ids.length>0&&(0,b.jsx)(aw,{attachmentIds:a.attachment_ids,artifacts:e,onArtifactClick:v}),!a.attachment_ids&&(0,b.jsx)(ax,{pendingFiles:t,messageId:a.id})]})})):"event"===a.role?(L=a.metadata?.emailId,M=a.metadata?.issueId,N=a.metadata?.calendarEventId,(0,b.jsx)("div",{className:"flex justify-start","data-message-id":a.id,...a.task_id?{"data-task-id":a.task_id}:{},children:(0,b.jsxs)("div",{className:(0,i.cn)("w-full rounded-md border bg-muted/50 text-muted-foreground text-sm px-3 py-2 flex items-start gap-2",(!!L||!!M||!!N)&&"cursor-pointer hover:bg-muted transition-colors"),onClick:L?()=>w(L):M?()=>x(M):N?()=>y(N):void 0,children:[(0,b.jsx)(av,{content:a.content,conversationType:r}),(0,b.jsx)("span",{className:"min-w-0 wrap-anywhere",children:a.content})]})})):Q?null:(0,b.jsxs)("div",{className:(0,i.cn)("group/msg flex flex-col justify-start min-w-0 overflow-x-clip",C&&"bg-muted/30 rounded-lg px-2 -mx-2"),"data-message-id":a.id,"data-quote-source":!0,...a.task_id?{"data-task-id":a.task_id}:{},children:[p&&"assistant"===a.role&&a.task_id&&o>1&&(0,b.jsx)(an,{taskId:a.task_id,thinkingCount:o-1,workspaceId:q,provider:G}),a.metadata?.error_source==="runtime"?(0,b.jsx)("div",{className:"px-1 py-1",children:(0,b.jsx)(s,{provider:a.metadata.provider??G,message:a.content})}):(0,b.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground",children:(0,b.jsx)(l.Streamdown,{plugins:{mermaid:m.mermaid,cjk:n.cjk},controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},allowedTags:at,literalTagContent:au,components:A,children:al(a.content,d)})}),S]})]})});var aA=a.i(781418),aB=a.i(722393);let aC={mention:function(a){let{children:c,...d}=a,{agents:e}=(0,x.useAgentContext)(),f=d["data-agent-id"]??d.dataAgentId,g=f?e.find(a=>a.id===f):void 0;if(!g&&"string"==typeof c){let a=c.startsWith("@")?c.slice(1):c;g=e.find(b=>b.name.toLowerCase()===a.toLowerCase())}return g?(0,b.jsxs)(aB.Popover,{children:[(0,b.jsx)(aB.PopoverTrigger,{openOnHover:!0,delay:300,nativeButton:!1,render:(0,b.jsx)("span",{className:"mention-highlight cursor-pointer"}),children:c}),(0,b.jsx)(aB.PopoverContent,{side:"top",className:"w-fit max-w-80",children:(0,b.jsx)(aA.AgentPreviewCard,{agent:g})})]}):(0,b.jsx)("span",{className:"mention-highlight",children:c})},p:({children:a,node:c,...d})=>(0,b.jsx)("div",{"data-md-p":"",...d,children:a})};function aD(a,b){if("issue_event"===b)return"issue";if("email_notification"===b)return"email";if("calendar_event"===b)return"calendar";let c=a.toLowerCase();return c.startsWith("issue ")||c.startsWith("issue:")?"issue":c.includes("email")?"email":"calendar"}function aE(a){return a.slice().sort((a,b)=>{let c=a.created_at.localeCompare(b.created_at);return 0!==c?c:a.id.localeCompare(b.id)})}function aF(a,b){let c=new Map;for(let b of a)c.set(b.id,b);for(let a of b)c.set(a.id,a);return aE([...c.values()])}function aG(a){let b=[],c=[],d=!1;for(let e of a)"message"===e.kind&&"user"===e.data.role?(d=!0,b.push(e)):"message"===e.kind&&"assistant"===e.data.role?(b.push(e),b.push(...c),c=[],d=!1):d&&"artifact"===e.kind?c.push(e):b.push(e);return b.push(...c),b}function aH(a){let b=(0,c.useRef)(a);return(0,c.useEffect)(()=>{b.current=a},[a]),b}function aI({agentName:a}){return(0,b.jsxs)("div",{className:"flex items-center gap-3 py-4 select-none","aria-hidden":!0,children:[(0,b.jsx)("div",{className:"flex-1 border-t border-border/40"}),(0,b.jsxs)("span",{className:"text-xs text-muted-foreground/60 whitespace-nowrap",children:[a," took a nap 💤"]}),(0,b.jsx)("div",{className:"flex-1 border-t border-border/40"})]})}function aJ({artifact:a,version:c,hasDuplicates:d,onClick:e}){return(0,b.jsxs)("button",{onClick:()=>e(a),className:(0,i.cn)("flex items-center gap-3 w-full max-w-sm rounded-lg border border-border/60 bg-muted/30","px-3.5 py-2.5 text-left transition-colors duration-150","hover:bg-muted/60 hover:border-border"),children:[(0,b.jsx)(H.FileText,{className:"size-4 shrink-0 text-muted-foreground"}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("p",{className:"text-sm font-medium truncate",children:[a.filename,d&&(0,b.jsxs)("span",{className:"ml-1.5 text-xs text-muted-foreground bg-muted rounded-full px-1.5 py-0.5 font-normal",children:["v",c]})]}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,_.formatSize)(a.size)})]})]})}function aK({agentId:a,targetConvId:h,scrollToTaskId:j,scrollToMessageId:l}){let m,n,o,p=(0,e.useParams)(),q=(0,e.useSearchParams)(),{workspaceId:r,slug:s}=(0,f.useWorkspace)(),{agents:t,runtimes:F,agentLinks:O,activeTaskCounts:Q,subscribeWs:R,subscribeReconnect:S}=(0,x.useAgentContext)(),{refresh:T}=(0,y.useInboxCount)(),{activeChannel:U,loading:V,setAgentId:W}=(0,A.useChannel)(),X=a??p.id,Y=t.find(a=>a.id===X),Z=Y?.runtime_id?F.find(a=>a.id===Y.runtime_id):null,aa=Z?.provider??null,ab=void 0!==j?j:q.get("task"),ac=void 0!==l?l:q.get("msg"),ad=void 0!==h?h:q.get("conv"),[ak,al]=(0,c.useState)(null),[am,an]=(0,c.useState)([]),[ao,ap]=(0,c.useState)(()=>""),[aq,ar]=(0,c.useState)(!1),[as,at]=(0,c.useState)(!1),[au,av]=(0,c.useState)(null),[aw,ax]=(0,c.useState)([]),[ay,aA]=(0,c.useState)(!0),[aD,aL]=(0,c.useState)(!1),[aM,aN]=(0,c.useState)(!1),[aO,aP]=(0,c.useState)(!1),[aQ,aR]=(0,c.useState)([]),[aS,aT]=(0,c.useState)(!1),[aU,aV]=(0,c.useState)(null),[aW,aX]=(0,c.useState)(!1),[aY,aZ]=(0,c.useState)(null),[a$,a_]=(0,c.useState)(!1),[a0,a1]=(0,c.useState)(null),[a2,a3]=(0,c.useState)(!1),[a4,a5]=(0,c.useState)(null),[a6,a7]=(0,c.useState)(null),[a8,a9]=(0,c.useState)(!1),[ba,bb]=(0,c.useState)(null),[bc,bd]=(0,c.useState)(null),[be,bf]=(0,c.useState)([]),[bg,bh]=(0,c.useState)([]),[bi,bj]=(0,c.useState)(null),[bk,bl]=(0,c.useState)([]),[bm,bn]=(0,c.useState)(!1),[bo,bp]=(0,c.useState)([]),[bq,br]=(0,c.useState)({}),[bs]=(0,c.useState)(()=>Date.now()),[bt,bu]=(0,c.useState)(()=>new Map),[bv,bw]=(0,c.useState)(()=>null),[bx,by]=(0,c.useState)(!1),[bz,bA]=(0,c.useState)(null),[bB,bC]=(0,c.useState)(new Set),bD=(0,c.useRef)(bB);(0,c.useEffect)(()=>{bD.current=bB});let{increment:bE,decrement:bF,refresh:bG}=(0,z.useFlagCount)(),{writeToCache:bH}=function(a,b){let[d,e]=(0,c.useState)(null),[f,g]=(0,c.useState)(!1),h=(0,c.useRef)(a);return(0,c.useEffect)(()=>{if(h.current=a,!a||!b){e(null),g(!1);return}(0,w.openCacheDB)(b);let c=!1;return(0,w.getCachedMessages)(a,b).then(b=>{c||h.current!==a||(b&&b.length>0?(e(b),g(!0)):(e(null),g(!1)))}),()=>{c=!0}},[a,b]),{cachedMessages:d,isFromCache:f,writeToCache:(0,c.useCallback)(async(a,c,d)=>{h.current&&b&&await (0,w.mergeCachedMessages)(h.current,a,c,b,d)},[b])}}(ad??null,r),bI=(0,c.useRef)(bH);(0,c.useEffect)(()=>{bI.current=bH},[bH]),(0,c.useEffect)(()=>{W(X)},[X,W]);let bJ=(0,c.useMemo)(()=>aQ.filter(a=>"agent"===a.source),[aQ]),{versionMap:bK,duplicateFilenames:bL}=(0,c.useMemo)(()=>(0,ah.computeArtifactVersions)(bJ),[bJ]),bM=(0,c.useMemo)(()=>(function(a,b,c,d){if(!d||0===c.length){let d=[...a.map(a=>({kind:"message",data:a})),...b.map(a=>({kind:"artifact",data:a})),...c.map(a=>({kind:"nap",data:a}))];return d.sort((a,b)=>{let c=a.data.created_at.localeCompare(b.data.created_at);if(0!==c)return c;if("nap"===a.kind||"nap"===b.kind){if("nap"===a.kind&&"nap"!==b.kind)return 1;if("nap"!==a.kind&&"nap"===b.kind)return -1}return a.kind!==b.kind?"message"===a.kind?-1:1:a.data.id.localeCompare(b.data.id)}),aG(d)}let e=new Set(c.map(a=>a.id.replace(/^nap-/,""))),f=[...c].sort((a,b)=>a.created_at.localeCompare(b.created_at)),g=c=>aG([...a.filter(a=>a.conversation_id===c).map(a=>({kind:"message",data:a})),...b.filter(a=>a.conversation_id===c).map(a=>({kind:"artifact",data:a}))].sort((a,b)=>{let c=a.data.created_at.localeCompare(b.data.created_at);return 0!==c?c:a.kind!==b.kind?"message"===a.kind?-1:1:a.data.id.localeCompare(b.data.id)})),h=[];for(let a of f){let b=a.id.replace(/^nap-/,"");h.push(...g(b)),h.push({kind:"nap",data:a})}h.push(...g(d));let i=new Set([...e,d]),j=a.filter(a=>!i.has(a.conversation_id)),k=b.filter(a=>!i.has(a.conversation_id));if(j.length>0||k.length>0){let a=[...j.map(a=>({kind:"message",data:a})),...k.map(a=>({kind:"artifact",data:a}))];a.sort((a,b)=>{let c=a.data.created_at.localeCompare(b.data.created_at);return 0!==c?c:a.kind!==b.kind?"message"===a.kind?-1:1:a.data.id.localeCompare(b.data.id)});let b=aG(a),c=h.findIndex(a=>"nap"===a.kind);c>=0?h.splice(c,0,...b):h.push(...b)}return h})(am,bJ,bo,ak?.id),[am,bJ,bo,ak?.id]),bN=(0,c.useMemo)(()=>(function(a){let b=Array(a.length).fill(null),c=a=>"user"===a.role||"assistant"===a.role;for(let d=0;d<a.length;d++){let e=a[d];if("message"!==e.kind)continue;let f=e.data;if(!c(f))continue;let g=d>0?a[d-1]:null,h=d<a.length-1?a[d+1]:null,i=g?.kind==="message"&&c(g.data)&&g.data.role===f.role&&(!f.created_at||!g.data.created_at||6e4>Math.abs(new Date(f.created_at).getTime()-new Date(g.data.created_at).getTime())),j=h?.kind==="message"&&c(h.data)&&h.data.role===f.role&&(!f.created_at||!h.data.created_at||6e4>Math.abs(new Date(h.data.created_at).getTime()-new Date(f.created_at).getTime()));i&&j?b[d]="middle":i&&!j?b[d]="last":!i&&j?b[d]="first":b[d]="solo"}return b})(bM),[bM]),bO=(0,c.useCallback)(a=>{(0,ah.isPreviewable)(a)?(aV(a),aT(!0)):window.open((0,ah.getArtifactUrl)(a.id,r,!0),"_blank")},[r]),bP=(0,c.useCallback)(a=>{(0,ah.isPreviewable)(a)?(aV(a),aT(!0)):window.open((0,ah.getArtifactUrl)(a.id,r,!0),"_blank")},[r]),bQ=(0,c.useRef)(null),bR=(0,c.useRef)(null),bS=(0,c.useRef)(null),bT=(0,c.useRef)(null),bU=(0,c.useRef)(0),bV=(0,c.useRef)(0),bW=(0,c.useRef)(!1),bX=(0,c.useRef)(!1),bY=(0,c.useRef)(!0),bZ=(0,c.useRef)(!1),b$=(0,c.useRef)(null),b_=(0,c.useRef)(null),b0=(0,c.useRef)(0),b1=(0,c.useRef)(void 0),b2=(0,c.useRef)(null),b3=(0,c.useRef)({completedKey:null}),b4=(0,c.useRef)(null),b5=(0,c.useRef)(null),[b6,b7]=(0,c.useState)(""),b8=(0,c.useMemo)(()=>t.filter(a=>a.id!==X),[t,X]),[b9,ca]=(0,c.useState)([]),cb=(0,c.useRef)(!1),cc=(0,c.useRef)(!1);(0,c.useEffect)(()=>{cb.current||(cb.current=!0,(0,v.getAgentSkills)(X,r).then(a=>ca(a.skills)).catch(()=>{}))},[X,r]);let[cd]=(0,c.useState)(()=>null),ce=function({input:a,caretIndex:b,skills:d,onInputChange:e,initialActiveSkill:f,getAnchorPos:g,onAfterSelect:h}){let[i,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(""),[m,n]=(0,c.useState)(0),[o,p]=(0,c.useState)({top:0,left:0}),q=(0,c.useRef)(null),r=(0,c.useMemo)(()=>{if(!i)return[];if(!k)return d;let a=k.toLowerCase(),b=[],c=[];for(let e of d){let d=e.name.toLowerCase();d.startsWith(a)?b.push(e):d.includes(a)&&c.push(e)}return[...b,...c]},[i,k,d]);(0,c.useEffect)(()=>{n(0)},[r.length,k]);let[s,t]=(0,c.useState)(f??null);(0,c.useEffect)(()=>{if(s||null===b)return void j(!1);let c=function(a,b){if(!a.startsWith("/")||0===b)return null;let c=b-1;for(;c>=0&&b-c<=30;){let d=a.charCodeAt(c);if(47===d&&0===c)return{start:0,query:a.slice(1,b)};if(10===d||13===d||32===d)break;c--}return null}(a,b);if(c){q.current=c.start,l(c.query),j(!0);let a=g(c.start);a&&p(a)}else j(!1),q.current=null},[a,b,g,s]);let u=(0,c.useCallback)(a=>{t(a),e(""),j(!1),h?.()},[e,h]),v=(0,c.useCallback)(()=>{t(null)},[]),w=(0,c.useCallback)(a=>!!i&&0!==r.length&&!a.isComposing&&("ArrowDown"===a.key?(a.preventDefault(),n(a=>(a+1)%r.length),!0):"ArrowUp"===a.key?(a.preventDefault(),n(a=>(a-1+r.length)%r.length),!0):"Enter"===a.key||"Tab"===a.key?(a.preventDefault(),u(r[m]),!0):"Escape"===a.key&&(a.preventDefault(),j(!1),!0)),[i,r,m,u]);return{isOpen:i,query:k,selectedIndex:m,anchorPos:o,skills:r,activeSkill:s,handleSlashKeyDown:w,selectSkill:u,clearActiveSkill:v,setActiveSkill:t}}({input:b6,caretIndex:bi,skills:b9,onInputChange:()=>b5.current?.clear(),initialActiveSkill:cd,getAnchorPos:(0,c.useCallback)(a=>b5.current?.coordsAtTextIndex(a)??null,[]),onAfterSelect:(0,c.useCallback)(()=>{requestAnimationFrame(()=>b5.current?.focus())},[])});(0,c.useEffect)(()=>{0===b9.length||!ce.activeSkill||b9.some(a=>a.name===ce.activeSkill.name)||ce.setActiveSkill(null)},[b9]),(0,c.useEffect)(()=>{let a=`chat-draft:${X}:${ad??"default"}`;ao?localStorage.setItem(a,ao):localStorage.removeItem(a)},[ao,X,ad]),(0,c.useEffect)(()=>{if(!cc.current)return;let a=`chat-draft-meta:${X}:${ad??"default"}`,b={};ce.activeSkill&&(b.skill={name:ce.activeSkill.name,description:ce.activeSkill.description}),bv&&(b.quote=bv),b.skill||b.quote?localStorage.setItem(a,JSON.stringify(b)):localStorage.removeItem(a)},[ce.activeSkill,bv,X,ad]),(0,c.useEffect)(()=>{aq||b5.current?.focus()},[aq]);let cf=(0,c.useCallback)(()=>{bY.current=!0,setTimeout(()=>{bQ.current?.scrollTo({top:bQ.current.scrollHeight,behavior:"smooth"})},50)},[]);(0,c.useEffect)(()=>{var a,b;if(!ad&&V)return;let c=(a={workspaceId:r,agentId:X,targetConvId:ad,scrollToTaskId:ab}).targetConvId?`${a.workspaceId}::${a.agentId}::${a.targetConvId}::${a.scrollToTaskId??""}`:null;if(b=b3.current,c&&b.completedKey===c||(b.completedKey=null,0))return;bR.current&&clearInterval(bR.current),bR.current=null,bT.current=null,b2.current=null;let d=!1;aA(!0),bW.current=!1,av(null),ax([]),bh([]),bu(new Map),bp([]),br({}),bl([]),bn(!1),b_.current=null,ap(localStorage.getItem(`chat-draft:${X}:${ad??"default"}`)??"");let e=localStorage.getItem(`chat-draft-meta:${X}:${ad??"default"}`);if(e)try{let a=JSON.parse(e);bw(a.quote??null),ce.setActiveSkill(a.skill?a.skill:null)}catch{bw(null),ce.setActiveSkill(null)}else bw(null),ce.setActiveSkill(null);async function f(a){let b=await (0,w.getCacheMeta)(a,r);if(b?.newestMessageId){let c=await (0,w.getCachedMessages)(a,r);if(d)return{painted:!1,cacheMeta:b};if(c&&c.length>0)return an(c),aN(b.hasMore),aA(!1),{painted:!0,cacheMeta:b}}return{painted:!1,cacheMeta:b}}return cc.current=!0,an([]),async function(){let a=!1;try{let b=null,c=null,e=null;if(ad){b=ad;let e=await f(b);if(d)return;c=e.cacheMeta,a=e.painted}else{let g=await (0,w.getLastOpenConversation)(X,U,r);if(d)return;if(g?.conversation_id&&g.serverMessageCount>0){let b=await f(g.conversation_id);if(d)return;b.painted&&(a=!0,e=g.conversation_id,c=b.cacheMeta)}try{let g=await (0,v.checkFreshness)({agentId:X,channel:U},r);if(d)return;if(b=g.conversation_id,e&&b!==e){bW.current=!1,bY.current=!0;let e=await f(b);if(d)return;c=e.cacheMeta,a=e.painted,e.painted||(an([]),aA(!0))}else if(!e){let e=await f(b);if(d)return;c=e.cacheMeta,a=e.painted}}catch{}}if(b){b2.current=b;let e=await (0,v.conversationInit)(b,r,{newestMessageId:c?.newestMessageId??void 0,messageCount:c?.serverMessageCount||void 0});if(d)return;if(al(e.conversation),bn(e.has_more_conversations),!e.cache_valid&&e.messages){let c=bY.current;an(a=>aF(a,e.messages)),b2.current===b&&(0,w.mergeCachedMessages)(b,e.messages,e.has_more_messages,r,e.message_count).catch(()=>{}),aN(e.has_more_messages),a&&bW.current&&c&&cf()}else c&&aN(c.hasMore);if(b2.current===b&&!ad){let a=await (0,w.getCacheMeta)(b,r);if(d)return;(0,w.setLastOpenConversation)(X,U,{conversation_id:b,newestMessageId:a?.newestMessageId??c?.newestMessageId??null,serverMessageCount:e.message_count},r).catch(()=>{})}if(br(e.thinking_counts),aR(e.artifacts),bh(e.buffered_messages),bC(new Set(e.flagged_message_ids)),e.active_task&&(av(e.active_task),ax(e.task_messages),e.task_messages.length>0&&(bU.current=Math.max(...e.task_messages.map(a=>a.seq))),b$.current?.(e.active_task.id,b,bU.current)),ab){let a=await (0,v.getTask)(ab,r).catch(()=>null);if(d)return;if(a&&!["completed","failed","cancelled","superseded"].includes(a.status)){av(a);let c=await (0,v.getTaskMessages)(ab,r).catch(()=>[]);if(d)return;ax(c),c.length>0&&(bU.current=Math.max(...c.map(a=>a.seq))),b$.current?.(a.id,b,bU.current)}}}else{let b=await (0,v.chatInit)(X,r,U);if(d)return;b2.current=b.conversation.id,al(b.conversation);let c=bY.current;an(a=>a.length>0?aF(a,b.messages):b.messages),aN(b.has_more_messages),aR(b.artifacts),bh(b.buffered_messages),bn(b.has_more_conversations),(0,w.mergeCachedMessages)(b.conversation.id,b.messages,b.has_more_messages,r).catch(()=>{}),(0,w.setLastOpenConversation)(X,U,{conversation_id:b.conversation.id,newestMessageId:b.messages.length>0?b.messages[b.messages.length-1].id:null,serverMessageCount:b.has_more_messages?0:b.messages.length},r).catch(()=>{}),a&&bW.current&&c&&cf(),(0,v.listFlaggedMessageIds)(r,b.conversation.id).then(a=>{d||bC(new Set(a.message_ids))}).catch(()=>{}),b.active_task&&(av(b.active_task),b.task_messages.length>0&&(ax(b.task_messages),bU.current=Math.max(...b.task_messages.map(a=>a.seq))),["completed","failed","cancelled","superseded"].includes(b.active_task.status)||b$.current?.(b.active_task.id,b.conversation.id,bU.current))}}catch{a?B.toast.error("Couldn't refresh conversation"):B.toast.error("Failed to load conversation")}finally{if(!d){var b;aA(!1),b=b3.current,c&&(b.completedKey=c)}}}(),()=>{d=!0}},[X,r,ad,ab,U,V]);let cg=(0,c.useRef)(T);(0,c.useEffect)(()=>{cg.current=T},[T]);let ch=(0,c.useRef)(null);(0,c.useEffect)(()=>{if(!ak?.id||!r||ch.current===ak.id)return;ch.current=ak.id;let a=setTimeout(()=>{(0,v.markInboxRead)(ak.id,r).then(()=>cg.current()).catch(()=>{})},1e3);return()=>{ch.current=null,clearTimeout(a)}},[ak?.id,r]),(0,c.useEffect)(()=>{ay||!(am.length>0)||bW.current||(bW.current=!0,ab||ac?bY.current=!1:h?setTimeout(()=>{let a=bQ.current?.querySelectorAll("[data-quote-source]");a&&a.length>0?a[a.length-1].scrollIntoView({behavior:"instant",block:"start"}):bQ.current?.scrollTo({top:bQ.current.scrollHeight})},50):setTimeout(()=>{bQ.current?.scrollTo({top:bQ.current.scrollHeight})},50))},[ay,am.length,ab,ac,h]),(0,c.useEffect)(()=>{let a;if(!ab||ay||!ak)return;bY.current=!1,bZ.current=!0;let b=!1,c=()=>{if(b)return!1;let c=document.querySelector(`[data-task-id="${CSS.escape(ab)}"]`);return!!c&&(c.scrollIntoView({behavior:"smooth",block:"start"}),c.classList.add("task-highlight"),a=setTimeout(()=>{c.classList.remove("task-highlight"),b||(bZ.current=!1)},1500),!0)},d=setTimeout(async()=>{if(!b&&!c())try{let a=await (0,v.listMessagesAroundTask)(ak.id,r,ab);if(b)return;a.length>0?(an(b=>aF(b,a)),requestAnimationFrame(()=>{setTimeout(()=>{c()||(bZ.current=!1)},100)})):bZ.current=!1}catch{b||(bZ.current=!1)}},100);return()=>{b=!0,clearTimeout(d),a&&clearTimeout(a)}},[ab,ay,ak,r]),(0,c.useEffect)(()=>{let a;if(!ac||ab||ay||!ak)return;bY.current=!1,bZ.current=!0;let b=!1,c=setTimeout(()=>{!b&&((()=>{if(b)return!1;let c=document.querySelector(`[data-message-id="${CSS.escape(ac)}"]`);return!!c&&(c.scrollIntoView({behavior:"smooth",block:"start"}),c.classList.add("task-highlight"),a=setTimeout(()=>{c.classList.remove("task-highlight"),b||(bZ.current=!1)},1500),!0)})()||(bQ.current?.scrollTo({top:bQ.current.scrollHeight}),bZ.current=!1))},100);return()=>{b=!0,clearTimeout(c),a&&clearTimeout(a)}},[ac,ab,ay,ak]);let ci=au?.status;(0,c.useEffect)(()=>{bZ.current||("running"===ci||"queued"===ci)&&bY.current&&cf()},[aw.length,ci,cf]);let cj=(0,c.useMemo)(()=>t.find(a=>a.id===X)?.name??"Agent",[t,X]),ck=aH(am),cl=aH(aM),cm=aH(bk),cn=aH(bm),co=aH(cj),cp=aH(U),cq=(0,c.useCallback)(async(a=!1)=>{if(!ak||bX.current)return;bX.current=!0;let b=ck.current,c=cl.current,e=cn.current,f=co.current,g=cp.current,h=!!ad,i=b[0],j=b_.current?.id??ak.id,k=c&&i,l=cm.current;if(!h&&!k&&0===l.length&&e){let a=b_.current??{id:ak.id,created_at:ak.created_at};try{let b=await (0,v.listPreviousConversations)(X,r,{exclude:ak.id,before:a.created_at,channel:g});l=b.conversations,bl(b.conversations),bn(b.has_more)}catch{bn(!1)}}let m=!h&&l.length>0;if(!k&&!m){bX.current=!1;return}aP(!0);let n=bQ.current;n&&(n.style.overflowAnchor="none");let o=n?.scrollHeight??0;try{let b=[],c=[],m=20,p=!1,q=[],s=!1;if(k){let a=j===ak.id?await (0,w.getCachedMessagesBefore)(j,i.created_at,i.id,20,r):null;if(a)b=a.messages,m-=a.messages.length,p=a.hasMore;else{let a=await (0,v.listMessages)(j,r,{limit:20,before:i.created_at,beforeId:i.id});b=a.messages,m-=a.messages.length,p=a.has_more}s=p}if(!h&&!p&&m>0){if(0===l.length&&e){let a=b_.current??{id:ak.id,created_at:ak.created_at};try{let b=await (0,v.listPreviousConversations)(X,r,{exclude:ak.id,before:a.created_at,channel:g});l=b.conversations,bl(b.conversations),bn(b.has_more)}catch{bn(!1)}}let a=0,b=0;for(;a<l.length&&m>0&&b<5;){let d=l[a];a++,b++;let e=await (0,v.listMessages)(d.id,r,{limit:m});if(0===e.messages.length){b_.current=d;continue}let g=b_.current?.created_at??ak.created_at;q.push({agentName:f,created_at:g,id:`nap-${d.id}`}),c=[...e.messages,...c],m-=e.messages.length,p=e.has_more,b_.current=d}a>0&&bl(b=>b.slice(a))}let t=[...c,...b];if((0,d.flushSync)(()=>{t.length>0?(q.length>0&&bp(a=>{let b=new Set(a.map(a=>a.id)),c=q.filter(a=>!b.has(a.id));return[...a,...c]}),aN(p),an(a=>{let b=new Set(a.map(a=>a.id));return[...t.filter(a=>!b.has(a.id)),...a]})):aN(!1)}),t.length>0&&ak){let a=t.filter(a=>a.conversation_id===ak.id);a.length>0&&(0,w.mergeCachedMessages)(ak.id,a,s,r).catch(()=>{})}if(bX.current=!1,(0,d.flushSync)(()=>aP(!1)),n)if(a)n.scrollTop=n.scrollHeight;else{let a=n.scrollHeight;n.scrollTop=a-o}}catch{B.toast.error("Failed to load older messages")}finally{bX.current=!1,aP(!1),bQ.current&&(bQ.current.style.overflowAnchor="")}},[ak,r,X,ad,ck,cl,cn,co,cp,cm]),cr=ad?aM:aM||bk.length>0||bm;(0,c.useEffect)(()=>{ak?.id!==b1.current&&(b1.current=ak?.id,b0.current=0)},[ak?.id]),(0,c.useEffect)(()=>{ay||!ak||ab||ad||am.length>=10||!cr||aO||b0.current>=3||(b0.current+=1,cq(!0))},[ay,am.length,cr,aO,ak,cq,ab,ad]);let cs=(0,c.useCallback)(()=>{let a=bQ.current;a&&(bY.current=a.scrollHeight-a.scrollTop-a.clientHeight<100)},[]),ct=(0,c.useCallback)((a,b,c)=>{bR.current&&clearInterval(bR.current),bU.current=c??0,bV.current=0,aL(!1),bT.current=a,bR.current=setInterval(async()=>{if(bT.current===a)try{let[c,d]=await Promise.all([(0,v.getTask)(a,r),(0,v.getTaskMessages)(a,r,bU.current||void 0)]),e=bT.current!==a;if(bV.current=0,aL(!1),d.length>0&&!e&&(ax(a=>{let b=new Set(a.map(a=>a.seq)),c=d.filter(a=>!b.has(a.seq));return c.length>0?[...a,...c]:a}),bU.current=Math.max(...d.map(a=>a.seq),bU.current)),"completed"===c.status||"failed"===c.status||"cancelled"===c.status||"superseded"===c.status){if(e)return void(0,v.listMessages)(b,r).then(({messages:a})=>{an(b=>aF(b,a)),(0,w.mergeCachedMessages)(b,a,null,r).catch(()=>{})}).catch(()=>{});bR.current&&clearInterval(bR.current),bR.current=null,bS.current&&clearTimeout(bS.current),bS.current=setTimeout(()=>{(0,v.markInboxRead)(b,r).then(()=>cg.current()).catch(()=>{})},1e3);let d=!bZ.current&&bY.current;try{let[a,d]=await Promise.all([(0,v.listMessages)(b,r),(0,v.listArtifacts)(b,r).catch(()=>null)]);an(b=>aF(b,a.messages)),(0,w.mergeCachedMessages)(b,a.messages,null,r).catch(()=>{}),d&&aR(d),av(c)}catch{av(c),B.toast.error("Failed to refresh messages")}d&&requestAnimationFrame(()=>{bQ.current?.scrollTo({top:bQ.current.scrollHeight,behavior:"smooth"})}),setTimeout(async()=>{if(!bR.current)try{let[c,d]=await Promise.all([(0,v.getActiveTask)(b,r),(0,v.listBufferedMessages)(b,r)]);if(bh(d),c&&c.id!==a){let{messages:a}=await (0,v.listMessages)(b,r);an(b=>aF(b,a)),(0,w.mergeCachedMessages)(b,a,null,r).catch(()=>{}),av(c),ax([]),b$.current?.(c.id,b)}}catch{}},1e3)}else e||av(c)}catch{if(bT.current!==a)return;bV.current+=1,bV.current>=3&&aL(!0),bV.current>=10&&(bR.current&&clearInterval(bR.current),bR.current=null,B.toast.error("Lost connection to agent"))}},3e3)},[r]);(0,c.useEffect)(()=>{b$.current=ct},[ct]),(0,c.useEffect)(()=>()=>{bR.current&&clearInterval(bR.current),bS.current&&clearTimeout(bS.current)},[]);let cu=(0,c.useRef)(null);(0,c.useEffect)(()=>{cu.current=au?.id??null},[au]),(0,c.useEffect)(()=>R(a=>{if("task.messages"===a.type&&a.taskId===cu.current){let b=a.messages.filter(a=>a.seq>bU.current);b.length>0&&(ax(a=>{let c=new Set(a.map(a=>a.seq)),d=b.filter(a=>!c.has(a.seq));return d.length>0?[...a,...d]:a}),bU.current=Math.max(...b.map(a=>a.seq),bU.current))}if("task.created"===a.type&&a.conversationId===ak?.id){(0,v.listMessages)(a.conversationId,r).then(({messages:b})=>{an(a=>aF(a,b)),(0,w.mergeCachedMessages)(a.conversationId,b,null,r).catch(()=>{})}).catch(()=>{});let b=a.task;cu.current=b.id,av(b),ax([]),bU.current=0,b$.current?.(b.id,a.conversationId)}if("task.created"===a.type){let b=a.task,c=cp.current;(0,w.getLastOpenConversation)(X,c,r).then(a=>{let d=function(a){let{task:b,agentId:c,activeChannel:d,currentPointerConvId:e}=a;return b.agent_id!==c||(b.channel??"default")!==d||b.conversation_id===e?null:b.conversation_id}({task:b,agentId:X,activeChannel:c,currentPointerConvId:a?.conversation_id??null});if(d)return(0,w.getCacheMeta)(d,r).then(a=>(0,w.setLastOpenConversation)(X,c,{conversation_id:d,newestMessageId:a?.newestMessageId??null,serverMessageCount:a?.messageCount??0},r))}).catch(()=>{})}if("conversation.message"===a.type&&(a.conversationId===b2.current&&(0,w.appendCachedMessage)(a.conversationId,a.message,r).catch(()=>{}),a.conversationId===ak?.id&&an(b=>{let c=new Date(a.message.created_at).getTime(),d=b.findIndex(b=>b.id.startsWith("temp-")&&b.role===a.message.role&&b.content===a.message.content&&2e3>Math.abs(new Date(b.created_at).getTime()-c));if(-1!==d){let c=[...b];return c[d]=a.message,c}return aF(b,[a.message])})),"task.updated"===a.type&&a.taskId===cu.current&&av(b=>b?{...b,status:a.status}:b),"artifact.uploaded"===a.type&&a.conversationId===ak?.id&&aR(b=>b.some(b=>b.id===a.artifact.id)?b:[...b,a.artifact]),"followup.dispatched"===a.type&&a.conversationId===ak?.id){bh(b=>b.filter(b=>b.id!==a.message.id)),(0,v.listBufferedMessages)(a.conversationId,r).then(bh).catch(()=>{}),(0,v.listMessages)(a.conversationId,r).then(({messages:b})=>{an(a=>aF(a,b)),(0,w.mergeCachedMessages)(a.conversationId,b,null,r).catch(()=>{})}).catch(()=>{});let b=a.task;cu.current=b.id,av(b),ax([]),b$.current?.(b.id,a.conversationId)}"followup.created"===a.type&&a.conversationId===ak?.id&&bh(b=>(function(a,b){if(a.some(a=>a.id===b.id))return a;let c=new Date(b.created_at).getTime();return a.some(a=>a.id.startsWith("temp-")&&2e3>Math.abs(new Date(a.created_at).getTime()-c))?a:[...a,b]})(b,a.message)),"followup.deleted"===a.type&&a.conversationId===ak?.id&&bh(b=>b.filter(b=>b.id!==a.messageId)),"followup.dispatch_failed"===a.type&&a.conversationId===ak?.id&&B.toast.error(a.error||"Failed to dispatch follow-up")}),[R,ak?.id,r,X]),(0,c.useEffect)(()=>S(()=>{ak?.id&&(0,w.getCacheMeta)(ak.id,r).then(a=>{(0,v.conversationInit)(ak.id,r,{newestMessageId:a?.newestMessageId??void 0,messageCount:a?.serverMessageCount??void 0}).then(a=>{!a.cache_valid&&a.messages&&(an(b=>aF(b,a.messages)),bI.current(a.messages,a.has_more_messages,a.message_count).catch(()=>{}))}).catch(()=>{})})}),[S,ak?.id,r]);let cv=(0,c.useCallback)(a=>{let b=[];for(let c of a)c.size>0xa00000?B.toast.error(`"${c.name}" exceeds 10 MB limit`):b.push(c);b.length>0&&bf(a=>[...a,...b])},[]),cw=(0,c.useCallback)(a=>{let b=a.target.files;b&&(cv(Array.from(b)),a.target.value="")},[cv]),cx=(0,c.useCallback)(a=>{bf(b=>b.filter((b,c)=>c!==a))},[]),cy=(0,c.useCallback)(()=>{let a=window.getSelection();if(!a||a.isCollapsed||!a.rangeCount)return void bA(null);let b=a.toString().trim();if(!b)return void bA(null);let c=a.getRangeAt(0),d=c.commonAncestorContainer instanceof HTMLElement?c.commonAncestorContainer:c.commonAncestorContainer.parentElement;if(!d?.closest("[data-quote-source]"))return void bA(null);let e=c.getClientRects(),f=e[e.length-1]||c.getBoundingClientRect();bA({text:b,x:f.right,y:f.top-4})},[]);(0,c.useEffect)(()=>(document.addEventListener("selectionchange",cy),()=>document.removeEventListener("selectionchange",cy)),[cy]);let cz=(0,c.useCallback)(()=>{bz&&(bw(bz.text),bA(null),window.getSelection()?.removeAllRanges(),b5.current?.focus())},[bz]),[cA,cB]=(0,c.useState)(!1),cC=(0,c.useRef)(0),cD=(0,c.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),cC.current++,a.dataTransfer.types.includes("Files")&&cB(!0)},[]),cE=(0,c.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),cC.current--,0===cC.current&&cB(!1)},[]),cF=(0,c.useCallback)(a=>{a.preventDefault(),a.stopPropagation()},[]),cG=(0,c.useCallback)(a=>{a.preventDefault(),a.stopPropagation(),cB(!1),cC.current=0,cv(Array.from(a.dataTransfer.files))},[cv]),cH=async()=>{if(ak&&!as){at(!0);try{let a=await (0,v.cancelActiveTask)(ak.id,r);if(a){if(cu.current&&cu.current!==a.id)return;bR.current&&clearInterval(bR.current),bR.current=null;let[b,c]=await Promise.all([(0,v.listMessages)(ak.id,r),(0,v.listBufferedMessages)(ak.id,r)]);an(a=>aF(a,b.messages)),(0,w.mergeCachedMessages)(ak.id,b.messages,null,r).catch(()=>{}),bh(c),av(a),ax([])}}catch{B.toast.error("Failed to cancel task")}finally{at(!1)}}},cI=async()=>{let a=ao.trim();if(!a&&0===be.length||aq||!ak)return;if(!a)return void B.toast.error("Please type a message");let b=bv?`> ${bv.split("\n").join("\n> ")}
2
2
 
3
3
  ${a}`:a;ce.activeSkill&&(b=`/${ce.activeSkill.name} ${b}`);let c=[...be];if(ap(""),bf([]),bw(null),ce.clearActiveSkill(),ar(!0),au&&!["completed","failed","cancelled","superseded"].includes(au.status)){let a=`temp-${Date.now()}`,d={id:a,conversation_id:ak.id,role:"user",content:b,task_id:null,attachment_ids:null,status:"buffered",created_at:new Date().toISOString()};bh(a=>[...a,d]);try{let{message:d}=await (0,v.createBufferedMessage)(ak.id,b,r,c.length>0?c:void 0);bh(b=>b.some(a=>a.id===d.id)?b.filter(b=>b.id!==a):b.map(b=>b.id===a?d:b))}catch(d){bh(b=>b.filter(b=>b.id!==a)),ap(b),bf(c),B.toast.error(d instanceof Error?d.message:"Failed to queue follow-up")}finally{ar(!1)}return}let d=`temp-${Date.now()}`,e={id:d,conversation_id:ak.id,role:"user",content:b,task_id:null,attachment_ids:null,created_at:new Date().toISOString()};c.length>0&&bu(a=>{let b=new Map(a);return b.set(d,c),b}),an(a=>[...a,e]),cf();try{let{message:a,task:f}=await (0,v.sendMessage)(ak.id,b,r,c.length>0?c:void 0);bu(a=>{if(!a.has(d))return a;let b=new Map(a);return b.delete(d),b}),an(b=>{if(!b.some(a=>a.id===e.id))return b.some(b=>b.id===a.id)?b:aE([...b,a]);let c=b.filter(b=>b.id!==e.id&&b.id!==a.id);return aE([...c,a])}),(0,w.appendCachedMessage)(ak.id,a,r).catch(()=>{}),a.attachment_ids&&a.attachment_ids.length>0&&(0,v.listArtifacts)(ak.id,r).then(a=>aR(a)).catch(()=>{}),av(f),ax([]),ct(f.id,ak.id)}catch(a){bu(a=>{if(!a.has(d))return a;let b=new Map(a);return b.delete(d),b}),an(a=>a.filter(a=>a.id!==e.id)),ap(b),bf(c),B.toast.error(a instanceof Error?a.message:"Failed to send message")}finally{ar(!1),b5.current?.focus()}},cJ=(0,c.useCallback)(async()=>{if(!au||!ak)return;let a=await (0,v.retryTask)(au.id,r);av(a),ax([]),ct(a.id,ak.id)},[au,ak,r,ct]),cK=(0,c.useCallback)(async a=>{let b=bD.current.has(a);bC(c=>{let d=new Set(c);return b?d.delete(a):d.add(a),d}),b?(bF(),(0,v.unflagMessage)(r,a).then(()=>{bG()}).catch(()=>{bC(b=>new Set(b).add(a)),bE()})):(bE(),(0,v.flagMessage)(r,a).then(()=>{bG()}).catch(()=>{bC(b=>{let c=new Set(b);return c.delete(a),c}),bF()}))},[r,bE,bF,bG]),cL=(0,c.useCallback)(async a=>{a5(a),a3(!0),a9(!0),bb(null),bd(null);try{let b=await (0,v.getIssue)(r,a);a7(b),b.issue.latest_task_id&&(0,v.getTask)(b.issue.latest_task_id,r).then(a=>bd(a)).catch(()=>bd(null)),b.issue.trace_id&&(0,v.getTrace)(b.issue.trace_id,r).then(a=>bb(a.tasks)).catch(()=>bb(null))}catch(a){B.toast.error(a instanceof Error?a.message:"Failed to load issue"),a3(!1)}finally{a9(!1)}},[r]),cM=a6?.issue?.conversation_id??null,cN=a6?.issue?.latest_task_id??null;(0,c.useEffect)(()=>{if(a2&&a4)return R(a=>{if("task.updated"===a.type&&cN&&a.taskId===cN&&(0,v.getTask)(cN,r).then(a=>bd(a)).catch(()=>{}),"conversation.message"===a.type&&cM&&a.conversationId===cM&&(a7(b=>!b||b.messages.some(b=>b.id===a.message.id)?b:{...b,messages:[...b.messages,a.message]}),"event"===a.message.role&&a.message.content.startsWith("Issue status changed:"))){let b=a.message.content.match(/-> (\w+)/);b&&a7(a=>a?{...a,issue:{...a.issue,status:b[1]}}:a)}"issue.comment"===a.type&&a.issueId===a4&&a7(b=>!b||b.comments.some(b=>b.id===a.comment.id)?b:{...b,comments:[...b.comments,a.comment]})})},[a2,a4,cM,cN,r,R]);let[cO,cP]=(0,c.useState)(!1),[cQ,cR]=(0,c.useState)(!1),cS=(0,c.useMemo)(()=>!!ak&&am.some(a=>a.conversation_id===ak.id),[ak,am]),cT=async()=>{if(ak&&cS&&!cO){cP(!0);try{bR.current&&(clearInterval(bR.current),bR.current=null);let a=await (0,v.createConversation)(X,r,U);bp(b=>[...b,{agentName:cj,created_at:a.created_at,id:`nap-${ak.id}`}]),bl(a=>[{id:ak.id,created_at:ak.created_at},...a]),al(a),av(null),ax([]),aR([]),bh([]),bf([]),bu(new Map),bU.current=0,aL(!1),aN(!1),b_.current=null,cf()}catch{B.toast.error("Failed to start new conversation")}finally{cP(!1)}}},cU=!!au&&!["completed","failed","cancelled","superseded"].includes(au.status);return ay?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"flex-1 overflow-y-auto px-3 md:px-5",children:(0,b.jsxs)("div",{className:"mx-auto max-w-2xl py-6 space-y-4",children:[(0,b.jsx)("div",{className:"flex justify-end",children:(0,b.jsx)(C.Skeleton,{className:"h-10 w-48 rounded-lg"})}),(0,b.jsx)("div",{className:"flex justify-start",children:(0,b.jsxs)("div",{className:"space-y-2 px-1 py-1",children:[(0,b.jsx)(C.Skeleton,{className:"h-4 w-72"}),(0,b.jsx)(C.Skeleton,{className:"h-4 w-56"}),(0,b.jsx)(C.Skeleton,{className:"h-4 w-64"})]})}),(0,b.jsx)("div",{className:"flex justify-end",children:(0,b.jsx)(C.Skeleton,{className:"h-10 w-36 rounded-lg"})}),(0,b.jsx)("div",{className:"flex justify-start",children:(0,b.jsxs)("div",{className:"space-y-2 px-1 py-1",children:[(0,b.jsx)(C.Skeleton,{className:"h-4 w-64"}),(0,b.jsx)(C.Skeleton,{className:"h-4 w-48"})]})})]})}),(0,b.jsx)("div",{className:"px-3 md:px-5 pt-3 pb-5 md:pb-6",children:(0,b.jsx)("div",{className:"mx-auto max-w-2xl",children:(0,b.jsx)(C.Skeleton,{className:"h-12 w-full rounded-3xl"})})})]}):ay||ak||0!==am.length?(0,b.jsxs)(b.Fragment,{children:[bz&&(0,b.jsxs)("button",{type:"button",className:"fixed z-50 flex items-center gap-1 px-2 py-1 rounded-md bg-popover border shadow-md text-xs text-popover-foreground hover:bg-accent transition-colors",style:{left:bz.x,top:bz.y,transform:"translate(-100%, -100%)"},onMouseDown:a=>a.preventDefault(),onClick:cz,children:[(0,b.jsx)(J,{className:"size-3"}),"Quote"]}),(0,b.jsxs)("div",{className:"relative flex-1 min-h-0",children:[(0,b.jsx)("div",{className:"h-full overflow-y-auto overflow-x-hidden px-3 md:px-5 thin-scrollbar",ref:bQ,onScroll:cs,onClick:a=>{a.target.closest('[data-streamdown="code-block-actions"] button')&&B.toast.success("Copied to clipboard")},children:(0,b.jsxs)("div",{className:"mx-auto max-w-2xl pt-6 pb-15 min-w-0",children:[ak&&cr&&!aO&&(0,b.jsx)("div",{className:"flex justify-center py-2",children:(0,b.jsx)("button",{onClick:()=>cq(),className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Load earlier messages"})}),aO&&(0,b.jsx)("div",{className:"flex justify-center py-2",children:(0,b.jsx)(k.Loader2,{className:"size-4 animate-spin text-muted-foreground"})}),0===am.length&&!au&&(m=t.find(a=>a.id===X),n=m?.created_at&&bs-new Date(m.created_at).getTime()<3e5,o=(Q[X]??0)>0,n&&o&&"default"===U?(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 gap-3 animate-[fade-up_400ms_ease-out_both]",children:[(0,b.jsxs)("div",{className:"relative animate-bounce",children:[(0,b.jsx)(I.Mail,{className:"size-8 text-primary"}),(0,b.jsxs)("span",{className:"absolute -top-1 -right-1 flex size-3",children:[(0,b.jsx)("span",{className:"animate-ping absolute inline-flex size-full rounded-full bg-primary/60"}),(0,b.jsx)("span",{className:"relative inline-flex size-3 rounded-full bg-primary"})]})]}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground text-center max-w-xs",children:"Your agent is sending you a welcome email."}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground/60 text-center max-w-xs",children:"Wait for the email task in the top-left to complete, then check your inbox. Or send a message below to start chatting."})]}):(0,b.jsx)("p",{className:"text-center text-muted-foreground py-20 text-sm",children:"Send a message to start chatting with the agent."})),bM.map((a,c)=>{let d=bN[c],e="first"===d||"solo"===d||null===d,f=0===c?"":e?"mt-4":"mt-0.5";if("nap"===a.kind)return(0,b.jsx)("div",{className:f,children:(0,b.jsx)(aI,{agentName:cj})},a.data.id);if("artifact"===a.kind)return(0,b.jsx)("div",{className:f,children:(0,b.jsx)(aJ,{artifact:a.data,version:bK.get(a.data.id)??1,hasDuplicates:bL.has(a.data.filename),onClick:bO})},`artifact-${a.data.id}`);let g=a.data;return(0,b.jsx)("div",{className:f,children:(0,b.jsx)(az,{msg:g,agents:t,artifacts:aQ,activeTask:au,taskMessages:aw,connectionLost:aD,isLastMessage:am.length>0&&am[am.length-1].id===g.id,thinkingCount:g.task_id?bq[g.task_id]??0:0,targetConvId:ad,workspaceId:r,conversationType:ak?.type,pendingFilesByMessage:bt,onArtifactClick:bO,onEmailClick:a=>{aZ(a),aX(!0)},onCalendarEventClick:a=>{a1(a),a_(!0)},onIssueClick:a=>cL(a),onRetry:cJ,mentionComponents:aC,isFlagged:bB.has(g.id),onToggleFlag:"assistant"===g.role?cK:void 0,groupPosition:d??"solo",provider:aa})},g.id)}),au&&au.conversation_id===ak?.id&&!["completed","failed","cancelled","superseded"].includes(au.status)&&(0,b.jsx)("div",{className:"mt-4",children:(0,b.jsx)(u,{task:au,messages:aw,connectionLost:aD,provider:aa})})]})}),(0,b.jsx)(aj.ScrollToBottomButton,{scrollRef:bQ})]}),ak&&(0,b.jsx)(ai,{bufferedMessages:bg,onDelete:a=>{bh(b=>b.filter(b=>b.id!==a)),(0,v.deleteBufferedMessage)(ak.id,a,r).catch(()=>{bh(bg),B.toast.error("Failed to delete follow-up")})}}),(0,b.jsx)("div",{"data-keyboard-offset":!0,className:"relative z-10 px-3 md:px-5 pt-3 pb-[max(1.25rem,env(safe-area-inset-bottom))] md:pb-6",children:(0,b.jsx)("div",{className:"mx-auto max-w-2xl relative",children:(0,b.jsxs)("div",{className:"flex items-end gap-2",children:[!ad&&(0,b.jsxs)(aB.Popover,{open:cQ,onOpenChange:cR,children:[(0,b.jsx)(aB.PopoverTrigger,{render:(0,b.jsx)(g.Button,{variant:"ghost",size:"icon-sm",className:"shrink-0 self-end mb-2.5 size-8 rounded-full text-muted-foreground/60 hover:text-foreground transition-colors duration-200"}),children:(0,b.jsx)(K.MoreHorizontal,{className:"size-4"})}),(0,b.jsx)(aB.PopoverContent,{side:"top",align:"start",className:"w-auto p-1.5 flex flex-col gap-0.5",children:(0,b.jsxs)(D.Tooltip,{children:[(0,b.jsx)(D.TooltipTrigger,{render:a=>(0,b.jsx)("span",{...a,className:(0,i.cn)("inline-flex",a.className),children:(0,b.jsxs)(g.Button,{variant:"ghost",size:"sm",onClick:()=>{cR(!1),cT()},disabled:cO||!ak||!cS||cU,className:"w-full justify-start gap-2 rounded-md text-muted-foreground hover:text-foreground",children:[cO?(0,b.jsx)(k.Loader2,{className:"size-3.5 animate-spin"}):(0,b.jsx)(G,{className:"size-3.5"}),(0,b.jsx)("span",{className:"text-xs",children:"Nap"})]})})}),(0,b.jsx)(D.TooltipContent,{side:"right",children:cU?"Wait for the task to finish":cS?"Take a nap":`${cj} is well-rested and ready to go`})]})})]}),(0,b.jsxs)("div",{className:(0,i.cn)("relative flex-1 min-w-0 flex flex-col rounded-3xl border border-border/50 bg-background/90 transition-[border-radius] duration-200","focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50",(bx||bv||ce.activeSkill)&&"rounded-2xl",aq&&"opacity-50",cA&&"border-ring ring-3 ring-ring/50"),onDragEnter:cD,onDragLeave:cE,onDragOver:cF,onDrop:cG,children:[cA&&(0,b.jsx)("div",{className:(0,i.cn)("absolute inset-0 z-10 flex items-center justify-center bg-background/80 border-2 border-dashed border-ring pointer-events-none",bx||bv||ce.activeSkill?"rounded-2xl":"rounded-3xl"),children:(0,b.jsx)("p",{className:"text-sm text-muted-foreground font-medium",children:"Drop files here"})}),ce.activeSkill&&(0,b.jsxs)("div",{className:"flex items-center gap-2 px-3.5 pt-2.5 pb-1 border-b border-border/50",children:[(0,b.jsxs)("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[(0,b.jsxs)("span",{className:"shrink-0 text-xs font-medium text-primary",children:["/",ce.activeSkill.name]}),ce.activeSkill.isGlobal&&(0,b.jsx)("span",{className:"text-[10px] font-medium text-muted-foreground bg-muted rounded px-1 py-0.5",children:"Global"}),(0,b.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:ce.activeSkill.description})]}),(0,b.jsx)("button",{type:"button",onClick:ce.clearActiveSkill,className:"shrink-0 p-0.5 rounded-sm hover:bg-muted-foreground/20 transition-colors text-muted-foreground",children:(0,b.jsx)(N.X,{className:"size-3.5"})})]}),bv&&(0,b.jsxs)("div",{className:"flex items-center gap-2 px-3.5 pt-2.5 pb-1 border-b border-border/50",children:[(0,b.jsxs)("div",{className:"flex-1 min-w-0 flex items-start gap-2",children:[(0,b.jsx)(J,{className:"size-3.5 shrink-0 mt-0.5 text-muted-foreground"}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:[bv.slice(0,120),bv.length>120?"...":""]})]}),(0,b.jsx)("button",{type:"button",onClick:()=>bw(null),className:"shrink-0 p-0.5 rounded-sm hover:bg-muted-foreground/20 transition-colors text-muted-foreground",children:(0,b.jsx)(N.X,{className:"size-3.5"})})]}),(0,b.jsx)(P,{isOpen:ce.isOpen,skills:ce.skills,selectedIndex:ce.selectedIndex,onSelect:ce.selectSkill,anchorPos:ce.anchorPos}),be.length>0&&(0,b.jsx)("div",{className:"flex flex-wrap gap-1.5 px-3.5 pt-3 pb-0.5",children:be.map((a,c)=>(0,b.jsxs)("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-muted px-2 py-1 text-xs text-muted-foreground",children:[(0,b.jsx)(H.FileText,{className:"size-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-30",children:a.name}),(0,b.jsx)("span",{className:"text-muted-foreground/60",children:(0,_.formatSize)(a.size)}),(0,b.jsx)("button",{type:"button",onClick:()=>cx(c),className:"ml-0.5 rounded-sm p-0.5 hover:bg-muted-foreground/20 transition-colors",children:(0,b.jsx)(N.X,{className:"size-3"})})]},`${a.name}-${c}`))}),(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("input",{ref:b4,type:"file",multiple:!0,className:"hidden",onChange:cw}),(0,b.jsx)("div",{className:"px-13 py-3",children:(0,b.jsx)($,{ref:b5,value:ao,onChange:ap,onEditorState:(a,b)=>{b7(a),bj(b)},onSend:cI,placeholder:cU?"Type a follow-up...":"Type a task...",disabled:aq,onMultiLineChange:by,onFiles:cv,agents:b8,agentLinks:O,currentAgentId:X,slashIsOpen:ce.isOpen,onSlashKeyDown:ce.handleSlashKeyDown})}),(0,b.jsxs)(D.Tooltip,{children:[(0,b.jsx)(D.TooltipTrigger,{render:(0,b.jsx)(g.Button,{variant:"ghost",size:"icon-sm",onPointerDown:a=>a.preventDefault(),onClick:()=>b4.current?.click(),disabled:aq,className:"absolute left-2 bottom-2 size-8 rounded-full text-muted-foreground/60 hover:text-foreground transition-colors duration-200"}),children:(0,b.jsx)(L.Paperclip,{className:"size-3.5"})}),(0,b.jsx)(D.TooltipContent,{side:"top",children:"Attach files"})]}),!cU||ao.trim()||aq?(0,b.jsxs)(D.Tooltip,{children:[(0,b.jsx)(D.TooltipTrigger,{render:(0,b.jsx)(g.Button,{size:"icon-sm",onClick:cI,disabled:!ao.trim()||aq,className:(0,i.cn)("absolute right-2 bottom-2 size-8 rounded-full bg-primary text-primary-foreground transition-opacity duration-200",!ao.trim()&&"opacity-30")}),children:aq?(0,b.jsx)(k.Loader2,{className:"size-3.5 animate-spin"}):(0,b.jsx)(E.ArrowUp,{className:"size-3.5"})}),(0,b.jsx)(D.TooltipContent,{side:"top",children:"Send"})]}):(0,b.jsxs)(D.Tooltip,{children:[(0,b.jsx)(D.TooltipTrigger,{render:(0,b.jsx)(g.Button,{size:"icon-sm",onClick:cH,disabled:as,className:"absolute right-2 bottom-2 size-8 rounded-full bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-colors duration-200"}),children:as?(0,b.jsx)(k.Loader2,{className:"size-3.5 animate-spin"}):(0,b.jsx)(M.Square,{className:"size-3.5 fill-current"})}),(0,b.jsx)(D.TooltipContent,{side:"top",children:"Stop task"})]})]})]}),!ad&&(0,b.jsx)("div",{className:"shrink-0 self-end mb-2.5 size-8","aria-hidden":"true"})]})})}),(0,b.jsx)(_.ArtifactSheet,{open:aS,onOpenChange:a=>{aT(a),a||setTimeout(()=>{aV(null)},300)},artifacts:aU?[aU]:bJ,workspaceId:r,initialArtifact:aU,versionMap:bK,duplicateFilenames:bL}),(0,b.jsx)(ae,{open:aW,onOpenChange:a=>{aX(a),a||setTimeout(()=>aZ(null),300)},emailId:aY,workspaceId:r}),(0,b.jsx)(af.CalendarEventSheet,{readonly:!0,open:a$,onOpenChange:a=>{a_(a),a||setTimeout(()=>a1(null),300)},calendarEventId:a0,workspaceId:r}),(0,b.jsx)(ag.IssueSheet,{open:a2,onOpenChange:a=>{a3(a),a||setTimeout(()=>{a5(null),a7(null),bd(null)},300)},agents:t,issue:a6?.issue??null,detail:a6?{messages:a6.messages,comments:a6.comments,artifacts:a6.artifacts,traceId:a6.issue.trace_id}:null,detailLoading:a8,activeTask:bc,traceTasks:ba,slug:s,workspaceId:r,onUpdate:async(a,b)=>{try{let c=await (0,v.updateIssue)(r,a,b);a7(d=>d&&d.issue.id===a?{...d,issue:{...d.issue,...b,updated_at:c.updated_at}}:d)}catch(a){B.toast.error(a instanceof Error?a.message:"Failed to update issue")}},onStatusChange:async(a,b)=>{try{await (0,v.updateIssue)(r,a,{status:b}),a7(c=>c&&c.issue.id===a?{...c,issue:{...c.issue,status:b}}:c)}catch(a){B.toast.error(a instanceof Error?a.message:"Failed to update status")}},onCommented:()=>{a4&&cL(a4)},onArtifactClick:bP})]}):(0,b.jsx)("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Failed to load conversation"})}}];
4
4
 
@@ -12,7 +12,7 @@ module.exports=[458682,a=>{"use strict";let b=[{id:"open-source-maintainer",name
12
12
  - When fixing bugs: reproduce first, identify root cause, implement a minimal fix, verify with tests.
13
13
  - For releases: verify all changes, update version numbers, generate changelog entries.
14
14
  - Include specific file paths and line numbers in all findings.
15
- - Ship quality. If something looks off, flag it — don't let it slide.`,relationship:{leaderSees:"Delegate code review or fix with: PR/issue link, affected files, what to check or fix, and acceptance criteria.",memberSees:"Report back with: review findings (approve/request changes), fix implemented with test results, or release checklist status."}},{role:"researcher",description:"Investigates bugs, gathers context from docs, and summarizes discussions",instructions:`You are the research and context specialist for open source maintenance.
15
+ - Ship quality. If something looks off, flag it — don't let it slide.`,relationship:"Delegate code review or fix with: PR/issue link, affected files, what to check or fix, and acceptance criteria.\n\nReport back with: review findings (approve/request changes), fix implemented with test results, or release checklist status."},{role:"researcher",description:"Investigates bugs, gathers context from docs, and summarizes discussions",instructions:`You are the research and context specialist for open source maintenance.
16
16
 
17
17
  ## Principles
18
18
  - For bugs: reproduce the issue, trace affected code paths, check for duplicates.
@@ -20,7 +20,7 @@ module.exports=[458682,a=>{"use strict";let b=[{id:"open-source-maintainer",name
20
20
  - For dependency updates: identify breaking changes, check compatibility, outline migration steps.
21
21
  - Always cite sources (file paths, issue numbers, doc URLs). Distinguish confirmed facts from hypotheses.
22
22
  - Include reproduction steps for bugs and flag confidence level for each finding.
23
- - Lead with your recommendation, then supporting evidence.`,relationship:{leaderSees:"Delegate investigation with: issue/PR link, what to research (bug repro, prior art, dependency compat), and scope boundary.",memberSees:"Report back with: reproduction steps, root cause analysis, relevant prior issues, and confidence level per finding."}}]},{id:"indie-hacker-ship-crew",name:"Indie Hacker Ship Crew",category:"Developer",icon:"🚀",description:"Build features, handle user feedback emails, write docs, and manage releases for your indie product.",longDescription:"Ship faster as a solo founder. Your leader manages the product backlog and user communications, your engineer writes code and runs tests, and your assistant handles user feedback emails, drafts documentation, and manages release announcements. Think of it as a tiny startup team that never sleeps.",tags:["indie hacker","SaaS","product","shipping"],features:["Feature implementation from spec to deployed code","User feedback email processing and prioritization","Documentation writing and maintenance","Release notes and announcement drafting","Bug fix triage from user reports","Deployment coordination and monitoring"],useCases:[{title:"Solo founders",description:"Multiply your output by delegating implementation, docs, and user comms to your AI company."},{title:"Weekend projects",description:"Keep your side project moving forward even when you only have a few hours per week."},{title:"Early-stage startups",description:"Move fast before you can afford to hire, with AI handling the repetitive work."}],baseScenario:"software-dev",members:[{role:"leader",description:"Manages product backlog, user comms, and coordinates shipping",instructions:`You are the product lead for an indie hacker's product. You coordinate building features, responding to users, and shipping releases.
23
+ - Lead with your recommendation, then supporting evidence.`,relationship:"Delegate investigation with: issue/PR link, what to research (bug repro, prior art, dependency compat), and scope boundary.\n\nReport back with: reproduction steps, root cause analysis, relevant prior issues, and confidence level per finding."}]},{id:"indie-hacker-ship-crew",name:"Indie Hacker Ship Crew",category:"Developer",icon:"🚀",description:"Build features, handle user feedback emails, write docs, and manage releases for your indie product.",longDescription:"Ship faster as a solo founder. Your leader manages the product backlog and user communications, your engineer writes code and runs tests, and your assistant handles user feedback emails, drafts documentation, and manages release announcements. Think of it as a tiny startup team that never sleeps.",tags:["indie hacker","SaaS","product","shipping"],features:["Feature implementation from spec to deployed code","User feedback email processing and prioritization","Documentation writing and maintenance","Release notes and announcement drafting","Bug fix triage from user reports","Deployment coordination and monitoring"],useCases:[{title:"Solo founders",description:"Multiply your output by delegating implementation, docs, and user comms to your AI company."},{title:"Weekend projects",description:"Keep your side project moving forward even when you only have a few hours per week."},{title:"Early-stage startups",description:"Move fast before you can afford to hire, with AI handling the repetitive work."}],baseScenario:"software-dev",members:[{role:"leader",description:"Manages product backlog, user comms, and coordinates shipping",instructions:`You are the product lead for an indie hacker's product. You coordinate building features, responding to users, and shipping releases.
24
24
 
25
25
  ## Principles
26
26
  - Prioritize ruthlessly: user-facing bugs > new features > refactoring. Revenue-impacting issues are always urgent.
@@ -34,14 +34,14 @@ module.exports=[458682,a=>{"use strict";let b=[{id:"open-source-maintainer",name
34
34
  - Small changes that do one thing well. Handle error cases in user-facing code.
35
35
  - Self-review before reporting: check for bugs, security issues, and performance problems.
36
36
  - Include basic tests for new features. Verify everything runs before calling it done.
37
- - If requirements are unclear, ask before coding.`,relationship:{leaderSees:"Delegate feature or bugfix with: requirement, affected files, user impact, and acceptance criteria.",memberSees:"Report back with: files changed, tests passing, self-review findings, and any concerns about edge cases."}},{role:"assistant",description:"Handles user emails, writes docs, and drafts announcements",instructions:`You are the operations assistant for an indie product. You handle user communications, documentation, and publishing tasks.
37
+ - If requirements are unclear, ask before coding.`,relationship:"Delegate feature or bugfix with: requirement, affected files, user impact, and acceptance criteria.\n\nReport back with: files changed, tests passing, self-review findings, and any concerns about edge cases."},{role:"assistant",description:"Handles user emails, writes docs, and drafts announcements",instructions:`You are the operations assistant for an indie product. You handle user communications, documentation, and publishing tasks.
38
38
 
39
39
  ## Principles
40
40
  - Keep users happy and docs current. Friendly but professional tone — short paragraphs, bullet points for lists.
41
41
  - For user emails: acknowledge their specific issue first, then provide the solution. Include relevant docs links.
42
42
  - For documentation: clear, concise, with code examples and common gotchas.
43
43
  - For announcements: highlight user-facing changes in plain language.
44
- - Track outstanding items and remind the leader when things are overdue.`,relationship:{leaderSees:"Delegate user reply, docs update, or announcement with: context, tone, and target audience.",memberSees:"Report back with: draft ready for review, docs updated, or announcement prepared with publish timing."}}]},{id:"devops-monitor",name:"DevOps Monitor",category:"Developer",icon:"📡",description:"Monitor services, handle alert emails, coordinate incident response, and automate deployments.",longDescription:"Keep your infrastructure healthy around the clock. Your leader processes incoming alert emails and decides how to respond, while your engineer investigates issues, runs diagnostics, and executes fixes. Together they handle the on-call burden — triaging alerts, investigating incidents, and coordinating deployments so you can sleep.",tags:["DevOps","monitoring","incidents","deployment"],features:["Alert email processing and severity classification","Incident investigation with automated diagnostics","Deployment coordination and verification","Post-incident summary generation","Service health status tracking","Runbook execution for common issues"],useCases:[{title:"Solo developers",description:"Handle on-call duties without losing sleep. Your AI team triages alerts and handles routine incidents."},{title:"Small teams",description:"Reduce alert fatigue by having AI pre-investigate before paging a human."},{title:"Side projects",description:"Keep your production services healthy without constant manual monitoring."}],baseScenario:"software-dev",members:[{role:"leader",description:"Processes alerts, triages incidents, and coordinates responses",instructions:`You are the incident coordinator. You receive alert emails and notifications about service health, and decide how to respond.
44
+ - Track outstanding items and remind the leader when things are overdue.`,relationship:"Delegate user reply, docs update, or announcement with: context, tone, and target audience.\n\nReport back with: draft ready for review, docs updated, or announcement prepared with publish timing."}]},{id:"devops-monitor",name:"DevOps Monitor",category:"Developer",icon:"📡",description:"Monitor services, handle alert emails, coordinate incident response, and automate deployments.",longDescription:"Keep your infrastructure healthy around the clock. Your leader processes incoming alert emails and decides how to respond, while your engineer investigates issues, runs diagnostics, and executes fixes. Together they handle the on-call burden — triaging alerts, investigating incidents, and coordinating deployments so you can sleep.",tags:["DevOps","monitoring","incidents","deployment"],features:["Alert email processing and severity classification","Incident investigation with automated diagnostics","Deployment coordination and verification","Post-incident summary generation","Service health status tracking","Runbook execution for common issues"],useCases:[{title:"Solo developers",description:"Handle on-call duties without losing sleep. Your AI team triages alerts and handles routine incidents."},{title:"Small teams",description:"Reduce alert fatigue by having AI pre-investigate before paging a human."},{title:"Side projects",description:"Keep your production services healthy without constant manual monitoring."}],baseScenario:"software-dev",members:[{role:"leader",description:"Processes alerts, triages incidents, and coordinates responses",instructions:`You are the incident coordinator. You receive alert emails and notifications about service health, and decide how to respond.
45
45
 
46
46
  ## Principles
47
47
  - Classify alerts by severity and act accordingly:
@@ -56,7 +56,7 @@ module.exports=[458682,a=>{"use strict";let b=[{id:"open-source-maintainer",name
56
56
  - Prefer rollback over forward-fix when possible. Always verify service health after applying a fix.
57
57
  - For known issues: execute the runbook (restart, clear cache, rollback). For unknown: investigate systematically — recent deploys, dependency status, resource utilization.
58
58
  - Document what happened: root cause, action taken, verification method, and prevention recommendation.
59
- - If unsure about impact, ask before executing.`,relationship:{leaderSees:"Delegate investigation with: alert context, affected service, severity, and recent changes to check.",memberSees:"Report back with: root cause, action taken, verification method, and prevention recommendation."}}]},{id:"daily-newsletter-operator",name:"Daily Newsletter Operator",category:"Content Creator",icon:"📰",description:"Curate trending topics, write newsletter issues, and send daily emails to your subscribers.",longDescription:"Run a daily newsletter on autopilot. Your researcher scans sources for trending topics and curates the best stories, your assistant formats and prepares the email, and your leader shapes the editorial voice and coordinates the daily publishing cycle. From topic selection to subscriber delivery — all handled by your AI team.",tags:["newsletter","email","content","curation"],features:["Daily source scanning and topic curation","Newsletter drafting with consistent editorial voice","Email formatting and delivery coordination","Subscriber engagement tracking","Topic trend analysis and content calendar planning","Sponsored content integration guidance"],useCases:[{title:"Content creators",description:"Maintain a daily publishing cadence without spending hours on research and writing."},{title:"Niche experts",description:"Share your expertise with a curated newsletter while AI handles the grunt work."},{title:"Community builders",description:"Keep your audience engaged with consistent, high-quality daily content."}],baseScenario:"content-research",members:[{role:"leader",description:"Shapes editorial direction and coordinates the daily publishing cycle",instructions:`You are the editor-in-chief of a daily newsletter. You coordinate the pipeline from curation to delivery.
59
+ - If unsure about impact, ask before executing.`,relationship:"Delegate investigation with: alert context, affected service, severity, and recent changes to check.\n\nReport back with: root cause, action taken, verification method, and prevention recommendation."}]},{id:"daily-newsletter-operator",name:"Daily Newsletter Operator",category:"Content Creator",icon:"📰",description:"Curate trending topics, write newsletter issues, and send daily emails to your subscribers.",longDescription:"Run a daily newsletter on autopilot. Your researcher scans sources for trending topics and curates the best stories, your assistant formats and prepares the email, and your leader shapes the editorial voice and coordinates the daily publishing cycle. From topic selection to subscriber delivery — all handled by your AI team.",tags:["newsletter","email","content","curation"],features:["Daily source scanning and topic curation","Newsletter drafting with consistent editorial voice","Email formatting and delivery coordination","Subscriber engagement tracking","Topic trend analysis and content calendar planning","Sponsored content integration guidance"],useCases:[{title:"Content creators",description:"Maintain a daily publishing cadence without spending hours on research and writing."},{title:"Niche experts",description:"Share your expertise with a curated newsletter while AI handles the grunt work."},{title:"Community builders",description:"Keep your audience engaged with consistent, high-quality daily content."}],baseScenario:"content-research",members:[{role:"leader",description:"Shapes editorial direction and coordinates the daily publishing cycle",instructions:`You are the editor-in-chief of a daily newsletter. You coordinate the pipeline from curation to delivery.
60
60
 
61
61
  ## Principles
62
62
  - Every issue needs a clear theme connecting 3-5 stories. Lead with the most interesting/actionable item.
@@ -70,14 +70,14 @@ module.exports=[458682,a=>{"use strict";let b=[{id:"open-source-maintainer",name
70
70
  - Curation criteria: timeliness (last 24h preferred), relevance to audience, uniqueness (skip what everyone covered yesterday), actionability.
71
71
  - For each story: summarize key facts, provide context, assess reader interest. Include compelling data points or quotes.
72
72
  - Scan broadly: news sites, social media, industry blogs, RSS feeds. Look for under-the-radar gems.
73
- - Flag emerging themes worth watching across multiple stories.`,relationship:{leaderSees:"Delegate curation with: today's theme or angle, audience focus, and number of stories needed.",memberSees:"Report back with: ranked story candidates (headline, summary, source, reader-interest score) and emerging themes spotted."}},{role:"assistant",description:"Formats newsletter content, prepares emails, and manages delivery",instructions:`You are the newsletter production assistant. You turn approved stories into a polished, ready-to-send email.
73
+ - Flag emerging themes worth watching across multiple stories.`,relationship:"Delegate curation with: today's theme or angle, audience focus, and number of stories needed.\n\nReport back with: ranked story candidates (headline, summary, source, reader-interest score) and emerging themes spotted."},{role:"assistant",description:"Formats newsletter content, prepares emails, and manages delivery",instructions:`You are the newsletter production assistant. You turn approved stories into a polished, ready-to-send email.
74
74
 
75
75
  ## Principles
76
76
  - Structure each story as: headline → summary → key takeaway → source link. Short paragraphs (2-3 sentences max).
77
77
  - Include a brief personal intro and sign-off. Use bullet points for lists and key facts.
78
78
  - Subject line: specific, curiosity-driving, under 50 characters. Provide 2-3 options for A/B testing.
79
79
  - Never publish without final review from the leader.
80
- - Flag production concerns (broken links, missing context) proactively.`,relationship:{leaderSees:"Delegate formatting with: approved stories, issue theme, intro angle, and delivery deadline.",memberSees:"Report back with: formatted issue ready for review, subject line options, and any production concerns (broken links, missing context)."}}]},{id:"technical-blog-pipeline",name:"Technical Blog Pipeline",category:"Content Creator",icon:"✍️",description:"Research topics, write technical articles, optimize for SEO, and maintain a consistent publishing schedule.",longDescription:"Produce high-quality technical blog posts at scale. Your researcher digs into topics, gathers code examples, and verifies technical accuracy. Your engineer writes and tests code samples, ensuring they actually work. Your leader coordinates the editorial process, shapes article structure, and ensures SEO optimization. From topic ideation to published post — a complete content pipeline.",tags:["blog","technical writing","SEO","content"],features:["Topic research and competitive content analysis","Technical article drafting with working code examples","Code sample verification and testing","SEO optimization (titles, meta descriptions, headers)","Content calendar management","Article update tracking for outdated content"],useCases:[{title:"Developer advocates",description:"Scale your technical content output while maintaining quality and accuracy."},{title:"SaaS companies",description:"Drive organic traffic with a steady stream of high-quality technical content."},{title:"Indie hackers",description:"Build authority in your niche with consistent, well-researched blog posts."}],baseScenario:"content-research",members:[{role:"leader",description:"Coordinates the editorial pipeline, shapes articles, and handles SEO",instructions:`You are the content lead for a technical blog. You manage the pipeline from topic selection to published post.
80
+ - Flag production concerns (broken links, missing context) proactively.`,relationship:"Delegate formatting with: approved stories, issue theme, intro angle, and delivery deadline.\n\nReport back with: formatted issue ready for review, subject line options, and any production concerns (broken links, missing context)."}]},{id:"technical-blog-pipeline",name:"Technical Blog Pipeline",category:"Content Creator",icon:"✍️",description:"Research topics, write technical articles, optimize for SEO, and maintain a consistent publishing schedule.",longDescription:"Produce high-quality technical blog posts at scale. Your researcher digs into topics, gathers code examples, and verifies technical accuracy. Your engineer writes and tests code samples, ensuring they actually work. Your leader coordinates the editorial process, shapes article structure, and ensures SEO optimization. From topic ideation to published post — a complete content pipeline.",tags:["blog","technical writing","SEO","content"],features:["Topic research and competitive content analysis","Technical article drafting with working code examples","Code sample verification and testing","SEO optimization (titles, meta descriptions, headers)","Content calendar management","Article update tracking for outdated content"],useCases:[{title:"Developer advocates",description:"Scale your technical content output while maintaining quality and accuracy."},{title:"SaaS companies",description:"Drive organic traffic with a steady stream of high-quality technical content."},{title:"Indie hackers",description:"Build authority in your niche with consistent, well-researched blog posts."}],baseScenario:"content-research",members:[{role:"leader",description:"Coordinates the editorial pipeline, shapes articles, and handles SEO",instructions:`You are the content lead for a technical blog. You manage the pipeline from topic selection to published post.
81
81
 
82
82
  ## Principles
83
83
  - Every article must teach something actionable. Code examples must actually work (verified by engineer).
@@ -91,14 +91,14 @@ module.exports=[458682,a=>{"use strict";let b=[{id:"open-source-maintainer",name
91
91
  - Cite official documentation over blog posts. Note version numbers for all libraries/frameworks.
92
92
  - Verify technical accuracy of all claims. Flag areas of uncertainty or rapidly changing info.
93
93
  - Identify common misconceptions in the topic area — these make great article hooks.
94
- - Present findings structured for article drafting: key points, competing content gaps, unique angle, and sources.`,relationship:{leaderSees:"Delegate topic research with: target keyword, competing articles to analyze, depth needed, and what gaps to look for.",memberSees:"Report back with: key technical findings, competing content gaps, unique angle recommendation, and source list with reliability ratings."}},{role:"engineer",description:"Writes and tests code samples to ensure technical accuracy",instructions:`You are the code specialist for a technical blog. You write, test, and verify all code examples used in articles.
94
+ - Present findings structured for article drafting: key points, competing content gaps, unique angle, and sources.`,relationship:"Delegate topic research with: target keyword, competing articles to analyze, depth needed, and what gaps to look for.\n\nReport back with: key technical findings, competing content gaps, unique angle recommendation, and source list with reliability ratings."},{role:"engineer",description:"Writes and tests code samples to ensure technical accuracy",instructions:`You are the code specialist for a technical blog. You write, test, and verify all code examples used in articles.
95
95
 
96
96
  ## Principles
97
97
  - Every code sample must be complete and runnable — no missing imports or setup steps. Readers lose trust when examples break.
98
98
  - Progressive complexity: start simple, build up. Comment the "why" not just the "what."
99
99
  - Test each sample to verify it works. Provide setup instructions (dependencies, environment).
100
100
  - Use modern patterns and current best practices. Include error handling where relevant.
101
- - Note common pitfalls readers might encounter.`,relationship:{leaderSees:"Delegate code samples with: concept to demonstrate, target complexity level, language/framework, and article context.",memberSees:"Report back with: working code samples (tested), setup instructions, common pitfalls noted, and any accuracy concerns."}}]},{id:"social-media-manager",name:"Social Media Manager",category:"Content Creator",icon:"📱",description:"Write posts, track trends, schedule publishing reminders, and maintain your social presence.",longDescription:"Keep your social media presence active and engaging without spending hours on it. Your leader develops content strategy and shapes your voice, while your assistant writes posts, tracks trending topics, and sets up calendar reminders for optimal publishing times. Consistent social presence — handled by your AI team.",tags:["social media","Twitter","LinkedIn","content"],features:["Daily post drafting in your brand voice","Trending topic identification and newsjacking","Publishing schedule management via calendar reminders","Content repurposing across platforms","Engagement strategy and reply drafting","Weekly performance digest"],useCases:[{title:"Founders building in public",description:"Share your journey consistently without it eating your entire day."},{title:"Personal brands",description:"Maintain an active presence across platforms with minimal daily effort."},{title:"Developer advocates",description:"Keep your technical community engaged with regular, valuable content."}],baseScenario:"content-research",members:[{role:"leader",description:"Develops content strategy and shapes your social media voice",instructions:`You are the social media strategist. You define content direction, maintain brand voice consistency, and keep the publishing cadence on track.
101
+ - Note common pitfalls readers might encounter.`,relationship:"Delegate code samples with: concept to demonstrate, target complexity level, language/framework, and article context.\n\nReport back with: working code samples (tested), setup instructions, common pitfalls noted, and any accuracy concerns."}]},{id:"social-media-manager",name:"Social Media Manager",category:"Content Creator",icon:"📱",description:"Write posts, track trends, schedule publishing reminders, and maintain your social presence.",longDescription:"Keep your social media presence active and engaging without spending hours on it. Your leader develops content strategy and shapes your voice, while your assistant writes posts, tracks trending topics, and sets up calendar reminders for optimal publishing times. Consistent social presence — handled by your AI team.",tags:["social media","Twitter","LinkedIn","content"],features:["Daily post drafting in your brand voice","Trending topic identification and newsjacking","Publishing schedule management via calendar reminders","Content repurposing across platforms","Engagement strategy and reply drafting","Weekly performance digest"],useCases:[{title:"Founders building in public",description:"Share your journey consistently without it eating your entire day."},{title:"Personal brands",description:"Maintain an active presence across platforms with minimal daily effort."},{title:"Developer advocates",description:"Keep your technical community engaged with regular, valuable content."}],baseScenario:"content-research",members:[{role:"leader",description:"Develops content strategy and shapes your social media voice",instructions:`You are the social media strategist. You define content direction, maintain brand voice consistency, and keep the publishing cadence on track.
102
102
 
103
103
  ## Principles
104
104
  - Content mix: 80% evergreen value, 20% timely/trend-based. Each post must educate, entertain, or engage.
@@ -112,7 +112,7 @@ module.exports=[458682,a=>{"use strict";let b=[{id:"open-source-maintainer",name
112
112
  - Include a call-to-action or conversation starter. Vary formats: tips, stories, opinions, questions, lists.
113
113
  - Track trending topics and identify newsjacking opportunities (industry news + your take). Flag viral formats worth adapting.
114
114
  - Repurpose existing content (blogs, threads) into platform-specific formats.
115
- - Set calendar reminders for optimal publishing times.`,relationship:{leaderSees:"Delegate post creation with: topic or content to repurpose, target platform, tone, and publish timing.",memberSees:"Report back with: post drafts ready for review, trending topics spotted, and calendar reminders set for publishing."}}]},{id:"executive-assistant",name:"Executive Assistant",category:"Knowledge Worker",icon:"💼",description:"Filter and prioritize emails, manage calendar reminders, and prepare meeting briefs.",longDescription:"Reclaim your time with an AI executive assistant team. Your leader triages incoming emails by priority and urgency, while your assistant handles responses, sets calendar reminders, and prepares briefing documents before meetings. Think of it as a chief of staff that keeps your information flow organized and your schedule on track.",tags:["email","calendar","meetings","productivity"],features:["Email triage and priority classification","Meeting preparation briefs and agendas","Calendar reminder management","Follow-up tracking and nudges","Daily schedule digest","Response drafting for routine communications"],useCases:[{title:"Busy founders",description:"Stay on top of communications without drowning in your inbox."},{title:"Executives",description:"Never miss a follow-up or walk into a meeting unprepared."},{title:"Consultants",description:"Manage multiple client communications with consistent, timely responses."}],baseScenario:"personal-assistant",members:[{role:"leader",description:"Triages emails by priority and coordinates your daily workflow",instructions:`You are the executive coordinator. You manage information flow and ensure nothing important falls through the cracks.
115
+ - Set calendar reminders for optimal publishing times.`,relationship:"Delegate post creation with: topic or content to repurpose, target platform, tone, and publish timing.\n\nReport back with: post drafts ready for review, trending topics spotted, and calendar reminders set for publishing."}]},{id:"executive-assistant",name:"Executive Assistant",category:"Knowledge Worker",icon:"💼",description:"Filter and prioritize emails, manage calendar reminders, and prepare meeting briefs.",longDescription:"Reclaim your time with an AI executive assistant team. Your leader triages incoming emails by priority and urgency, while your assistant handles responses, sets calendar reminders, and prepares briefing documents before meetings. Think of it as a chief of staff that keeps your information flow organized and your schedule on track.",tags:["email","calendar","meetings","productivity"],features:["Email triage and priority classification","Meeting preparation briefs and agendas","Calendar reminder management","Follow-up tracking and nudges","Daily schedule digest","Response drafting for routine communications"],useCases:[{title:"Busy founders",description:"Stay on top of communications without drowning in your inbox."},{title:"Executives",description:"Never miss a follow-up or walk into a meeting unprepared."},{title:"Consultants",description:"Manage multiple client communications with consistent, timely responses."}],baseScenario:"personal-assistant",members:[{role:"leader",description:"Triages emails by priority and coordinates your daily workflow",instructions:`You are the executive coordinator. You manage information flow and ensure nothing important falls through the cracks.
116
116
 
117
117
  ## Principles
118
118
  - Protect the user's time. Only escalate what truly needs their input — handle everything else autonomously or via delegation.
@@ -128,7 +128,7 @@ module.exports=[458682,a=>{"use strict";let b=[{id:"open-source-maintainer",name
128
128
  - Meeting briefs: attendees + context, purpose, background (2-3 sentences), user's goals, and prep needed.
129
129
  - Track follow-ups: flag items with no response after 48 hours. Maintain a running list of pending commitments.
130
130
  - Be concise and precise — respect everyone's time.
131
- - Never send without leader review for anything beyond routine acknowledgments.`,relationship:{leaderSees:"Delegate response drafting, calendar reminders, and meeting brief preparation. Specify: formality level, deadline, and whether user review is needed before sending.",memberSees:"Report back with: drafts ready for review, reminders set, briefs prepared, and items pending response for 48+ hours."}}]},{id:"research-analyst",name:"Research Analyst",category:"Knowledge Worker",icon:"🔬",description:"Monitor competitors, analyze industry trends, and deliver weekly research digests via email.",longDescription:"Stay ahead of your market with an AI research team. Your researcher continuously monitors competitors, tracks industry trends, and gathers intelligence from public sources. Your leader synthesizes findings into actionable insights and delivers structured reports via email. From daily monitoring to weekly deep-dives — systematic intelligence gathering on autopilot.",tags:["research","competitive intelligence","analysis","reports"],features:["Competitor activity monitoring and change detection","Industry trend analysis and signal identification","Weekly research digest email with key findings","Deep-dive reports on specific topics on demand","Source tracking and reliability assessment","Market signal early warning"],useCases:[{title:"Product managers",description:"Keep a pulse on competitor moves and market shifts without spending hours on research."},{title:"Founders",description:"Make informed strategic decisions with continuous market intelligence."},{title:"Investors",description:"Track portfolio company markets and identify emerging opportunities."}],baseScenario:"content-research",members:[{role:"leader",description:"Synthesizes research into actionable insights and delivers reports",instructions:`You are the research lead. You direct research priorities, synthesize findings, and deliver actionable intelligence.
131
+ - Never send without leader review for anything beyond routine acknowledgments.`,relationship:"Delegate response drafting, calendar reminders, and meeting brief preparation. Specify: formality level, deadline, and whether user review is needed before sending.\n\nReport back with: drafts ready for review, reminders set, briefs prepared, and items pending response for 48+ hours."}]},{id:"research-analyst",name:"Research Analyst",category:"Knowledge Worker",icon:"🔬",description:"Monitor competitors, analyze industry trends, and deliver weekly research digests via email.",longDescription:"Stay ahead of your market with an AI research team. Your researcher continuously monitors competitors, tracks industry trends, and gathers intelligence from public sources. Your leader synthesizes findings into actionable insights and delivers structured reports via email. From daily monitoring to weekly deep-dives — systematic intelligence gathering on autopilot.",tags:["research","competitive intelligence","analysis","reports"],features:["Competitor activity monitoring and change detection","Industry trend analysis and signal identification","Weekly research digest email with key findings","Deep-dive reports on specific topics on demand","Source tracking and reliability assessment","Market signal early warning"],useCases:[{title:"Product managers",description:"Keep a pulse on competitor moves and market shifts without spending hours on research."},{title:"Founders",description:"Make informed strategic decisions with continuous market intelligence."},{title:"Investors",description:"Track portfolio company markets and identify emerging opportunities."}],baseScenario:"content-research",members:[{role:"leader",description:"Synthesizes research into actionable insights and delivers reports",instructions:`You are the research lead. You direct research priorities, synthesize findings, and deliver actionable intelligence.
132
132
 
133
133
  ## Principles
134
134
  - Lead with "So what?" — why should the user care? Don't report facts; interpret them, connect dots, recommend actions.
@@ -142,7 +142,7 @@ module.exports=[458682,a=>{"use strict";let b=[{id:"open-source-maintainer",name
142
142
  - Always include source URL and date. Distinguish confirmed facts from rumors/speculation.
143
143
  - Cross-reference important claims with multiple sources. Flag outdated or unreliable info.
144
144
  - Identify signals: unusual activity, pattern breaks, emerging trends.
145
- - Organize findings categorized for the leader to synthesize: discoveries, notable signals, sources, and confidence assessment.`,relationship:{leaderSees:"Delegate monitoring with: competitors to track, signals to watch for, sources to check, and reporting cadence.",memberSees:"Report back with: categorized findings (discoveries, signals, sources), confidence per claim, and items flagged for urgency."}}]},{id:"client-ops",name:"Client Ops",category:"Freelancer",icon:"🤝",description:"Auto-reply to client inquiries, schedule meetings, send follow-ups, and manage project communications.",longDescription:"Never miss a client email again. Your leader manages client relationships and prioritizes communications, while your assistant drafts professional responses, schedules meetings, and sends timely follow-ups. Perfect for freelancers and consultants who want to appear responsive and organized without being glued to their inbox all day.",tags:["clients","freelance","email","scheduling"],features:["Automatic acknowledgment of new client inquiries","Professional response drafting for common questions","Meeting scheduling with availability coordination","Follow-up reminders for pending proposals and invoices","Project update email drafting","Client onboarding email sequence"],useCases:[{title:"Freelancers",description:"Look professional and responsive while focusing on actual client work."},{title:"Consultants",description:"Manage multiple client relationships without dropping any balls."},{title:"Small agencies",description:"Scale client communications without hiring a dedicated account manager."}],baseScenario:"personal-assistant",members:[{role:"leader",description:"Manages client relationships and prioritizes communications",instructions:`You are the client relationship coordinator. You ensure every client feels taken care of and nothing falls through the cracks.
145
+ - Organize findings categorized for the leader to synthesize: discoveries, notable signals, sources, and confidence assessment.`,relationship:"Delegate monitoring with: competitors to track, signals to watch for, sources to check, and reporting cadence.\n\nReport back with: categorized findings (discoveries, signals, sources), confidence per claim, and items flagged for urgency."}]},{id:"client-ops",name:"Client Ops",category:"Freelancer",icon:"🤝",description:"Auto-reply to client inquiries, schedule meetings, send follow-ups, and manage project communications.",longDescription:"Never miss a client email again. Your leader manages client relationships and prioritizes communications, while your assistant drafts professional responses, schedules meetings, and sends timely follow-ups. Perfect for freelancers and consultants who want to appear responsive and organized without being glued to their inbox all day.",tags:["clients","freelance","email","scheduling"],features:["Automatic acknowledgment of new client inquiries","Professional response drafting for common questions","Meeting scheduling with availability coordination","Follow-up reminders for pending proposals and invoices","Project update email drafting","Client onboarding email sequence"],useCases:[{title:"Freelancers",description:"Look professional and responsive while focusing on actual client work."},{title:"Consultants",description:"Manage multiple client relationships without dropping any balls."},{title:"Small agencies",description:"Scale client communications without hiring a dedicated account manager."}],baseScenario:"personal-assistant",members:[{role:"leader",description:"Manages client relationships and prioritizes communications",instructions:`You are the client relationship coordinator. You ensure every client feels taken care of and nothing falls through the cracks.
146
146
 
147
147
  ## Principles
148
148
  - Never leave a client waiting: acknowledge every email within 4 hours (even just "received, will respond by X").
@@ -156,7 +156,7 @@ module.exports=[458682,a=>{"use strict";let b=[{id:"open-source-maintainer",name
156
156
  - Always include a clear next step or timeline. For scheduling: offer 3 specific time options.
157
157
  - For follow-ups: be helpful, not pushy — "Checking in on X, let me know if you need anything."
158
158
  - For updates: lead with progress, then next steps, then blockers.
159
- - Set calendar reminders for all follow-up actions. Never let a commitment drop silently.`,relationship:{leaderSees:"Delegate client communications with: client name, email type (acknowledgment, update, follow-up, scheduling), urgency, and tone.",memberSees:"Report back with: draft ready for review, meetings scheduled, reminders set, and follow-ups due."}}]},{id:"weekly-report-bot",name:"Weekly Report Bot",category:"Freelancer",icon:"📊",description:"Summarize your week's work from git, emails, and calendar into a structured report delivered to your inbox.",longDescription:"End every week with a clear picture of what happened. Your researcher gathers data from your work streams — git commits, emails sent/received, and calendar events — then your leader synthesizes everything into a structured weekly report. Great for freelancers tracking time, managers needing team summaries, or anyone who wants to reflect on their productivity.",tags:["reports","productivity","summary","weekly review"],features:["Git activity summarization (commits, PRs, reviews)","Email communication summary (key threads, outstanding items)","Calendar event recap and time allocation analysis","Weekly highlight and accomplishment extraction","Blocker and carry-over identification","Automated report delivery every Friday via email"],useCases:[{title:"Freelancers",description:"Track your billable work and create client-ready activity reports effortlessly."},{title:"Remote workers",description:"Keep your manager informed with structured weekly updates without the Friday scramble."},{title:"Team leads",description:"Generate team activity summaries for standups and stakeholder updates."}],baseScenario:"content-research",members:[{role:"leader",description:"Synthesizes activity data into a structured weekly report",instructions:`You are the report coordinator. You turn raw activity data into a clear, insightful weekly summary.
159
+ - Set calendar reminders for all follow-up actions. Never let a commitment drop silently.`,relationship:"Delegate client communications with: client name, email type (acknowledgment, update, follow-up, scheduling), urgency, and tone.\n\nReport back with: draft ready for review, meetings scheduled, reminders set, and follow-ups due."}]},{id:"weekly-report-bot",name:"Weekly Report Bot",category:"Freelancer",icon:"📊",description:"Summarize your week's work from git, emails, and calendar into a structured report delivered to your inbox.",longDescription:"End every week with a clear picture of what happened. Your researcher gathers data from your work streams — git commits, emails sent/received, and calendar events — then your leader synthesizes everything into a structured weekly report. Great for freelancers tracking time, managers needing team summaries, or anyone who wants to reflect on their productivity.",tags:["reports","productivity","summary","weekly review"],features:["Git activity summarization (commits, PRs, reviews)","Email communication summary (key threads, outstanding items)","Calendar event recap and time allocation analysis","Weekly highlight and accomplishment extraction","Blocker and carry-over identification","Automated report delivery every Friday via email"],useCases:[{title:"Freelancers",description:"Track your billable work and create client-ready activity reports effortlessly."},{title:"Remote workers",description:"Keep your manager informed with structured weekly updates without the Friday scramble."},{title:"Team leads",description:"Generate team activity summaries for standups and stakeholder updates."}],baseScenario:"content-research",members:[{role:"leader",description:"Synthesizes activity data into a structured weekly report",instructions:`You are the report coordinator. You turn raw activity data into a clear, insightful weekly summary.
160
160
 
161
161
  ## Principles
162
162
  - Report structure: Highlights (top 3-5 wins), Work completed (by project), In progress, Blockers (with next steps), Next week priorities, Time allocation.
@@ -170,6 +170,6 @@ module.exports=[458682,a=>{"use strict";let b=[{id:"open-source-maintainer",name
170
170
  - Email: focus on decision-bearing threads, not noise. Track important decisions and outstanding items.
171
171
  - Calendar: note meeting purposes (not just titles), total meeting time, productive vs. overhead estimate.
172
172
  - Include: feature work, bug fixes, reviews, important decisions, client comms. Exclude: automated notifications, spam.
173
- - Flag data gaps (e.g., calendar empty on a day — PTO or just no meetings?). Highlight completed milestones.`,relationship:{leaderSees:"Delegate data gathering with: time range, sources to check (git, email, calendar), and focus areas or projects to highlight.",memberSees:"Report back with: raw activity data organized by source, milestones completed, data gaps flagged, and items needing interpretation."}}]}];a.s(["TEMPLATES",0,b,"getTemplateById",0,function(a){return b.find(b=>b.id===a)}],458682)}];
173
+ - Flag data gaps (e.g., calendar empty on a day — PTO or just no meetings?). Highlight completed milestones.`,relationship:"Delegate data gathering with: time range, sources to check (git, email, calendar), and focus areas or projects to highlight.\n\nReport back with: raw activity data organized by source, milestones completed, data gaps flagged, and items needing interpretation."}]}];a.s(["TEMPLATES",0,b,"getTemplateById",0,function(a){return b.find(b=>b.id===a)}],458682)}];
174
174
 
175
175
  //# sourceMappingURL=src_web_src_lib_templates_index_ts_13n9_2e._.js.map