@alook/app 0.0.100 → 0.0.101
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.
- package/bundled/web/.open-next/.build/durable-objects/queue.js +5 -5
- package/bundled/web/.open-next/assets/BUILD_ID +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/{0tvembqw.e82g.js → 01yvpio9kzobl.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0hyshwdxcbwbq.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/{0dhez0ocwb1sn.js → 0r775oyts5ozc.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/10rvnbe-gw6a7.js +3 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/10ux4o4nkn.sj.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/171xnnpyz4y3d.css +1 -0
- package/bundled/web/.open-next/cache/{stPDLxY2tICyNcpCDMCz4 → P6QBCMByXCOFPEUBvhHF6}/_global-error.cache +1 -1
- package/bundled/web/.open-next/cache/{stPDLxY2tICyNcpCDMCz4 → P6QBCMByXCOFPEUBvhHF6}/_not-found.cache +1 -1
- package/bundled/web/.open-next/cache/{stPDLxY2tICyNcpCDMCz4 → P6QBCMByXCOFPEUBvhHF6}/privacy.cache +1 -1
- package/bundled/web/.open-next/cache/{stPDLxY2tICyNcpCDMCz4 → P6QBCMByXCOFPEUBvhHF6}/sitemap.xml.cache +1 -1
- package/bundled/web/.open-next/cloudflare/cache-assets-manifest.sql +1 -1
- package/bundled/web/.open-next/cloudflare/init.js +1 -1
- package/bundled/web/.open-next/dynamodb-provider/dynamodb-cache.json +1 -1
- package/bundled/web/.open-next/middleware/handler.mjs +3 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/BUILD_ID +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/build-manifest.json +3 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/prerender-manifest.json +3 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/invite/[token]/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/studio/new/page_client-reference-manifest.js +1 -1
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/agents/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/calendar/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/flags/page_client-reference-manifest.js +1 -1
- 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
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/home/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/issues/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/runtimes/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/settings/page_client-reference-manifest.js +1 -1
- 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
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/threads/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/w/[slug]/unread/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(app)/workspaces/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/(auth)/sign-in/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/privacy/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/templates/[id]/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/app/templates/page_client-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[turbopack]_runtime.js +4 -4
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{[root-of-the-server]__0r7fdlr._.js → [root-of-the-server]__05g0phj._.js} +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[turbopack]_runtime.js +4 -4
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_02.xen~._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{_0.q_x36._.js → _06a692f._.js} +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{_0a8f3fa._.js → _0c-ma68._.js} +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0xhx.5_._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{_0wtsjmd._.js → _0~twhbc._.js} +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_0~23g-y._.js +2 -2
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_app_(app)_w_[slug]_calendar_page_tsx_01geiyd._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_components_home_home-page_tsx_0to84tv._.js +1 -37
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-build-manifest.js +3 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/middleware-manifest.json +5 -5
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/server-reference-manifest.json +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs +17 -53
- package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs.meta.json +90 -90
- package/bundled/web/.open-next/server-functions/default/src/web/index.mjs +3 -3
- package/package.json +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/01mduafj8.t03.js +0 -37
- package/bundled/web/.open-next/assets/_next/static/chunks/051._099hez6h.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/09m73_4eia.5a.css +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/09tp3dnnhv6a0.js +0 -3
- /package/bundled/web/.open-next/assets/_next/static/{stPDLxY2tICyNcpCDMCz4 → P6QBCMByXCOFPEUBvhHF6}/_buildManifest.js +0 -0
- /package/bundled/web/.open-next/assets/_next/static/{stPDLxY2tICyNcpCDMCz4 → P6QBCMByXCOFPEUBvhHF6}/_clientMiddlewareManifest.js +0 -0
- /package/bundled/web/.open-next/assets/_next/static/{stPDLxY2tICyNcpCDMCz4 → P6QBCMByXCOFPEUBvhHF6}/_ssgManifest.js +0 -0
- /package/bundled/web/.open-next/cache/{stPDLxY2tICyNcpCDMCz4 → P6QBCMByXCOFPEUBvhHF6}/robots.txt.cache +0 -0
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,74348,e=>{"use strict";var t=e.i(368075),s=e.i(298699),a=e.i(222862),n=e.i(500324);let r=(0,s.createContext)(null);e.s(["FlagCountProvider",0,function({children:e}){let{workspaceId:l}=(0,n.useWorkspace)(),[i,o]=(0,s.useState)(0),c=(0,s.useCallback)(()=>{(0,a.getFlaggedCount)(l).then(e=>o(e.count)).catch(()=>{})},[l]),d=(0,s.useCallback)(()=>{o(e=>e+1)},[]),u=(0,s.useCallback)(()=>{o(e=>Math.max(0,e-1))},[]);return(0,s.useEffect)(()=>{c()},[c]),(0,t.jsx)(r.Provider,{value:{count:i,refresh:c,increment:d,decrement:u},children:e})},"useFlagCount",0,function(){let e=(0,s.useContext)(r);if(!e)throw Error("useFlagCount must be used within FlagCountProvider");return e}])},49879,618615,844010,e=>{"use strict";e.s(["AgentChatView",()=>eC,"getEventIconType",()=>ey],49879);var t=e.i(368075),s=e.i(298699),a=e.i(550008),n=e.i(208020),r=e.i(500324),l=e.i(186339),i=e.i(875061),o=e.i(613349),c=e.i(541544),d=e.i(64873),u=e.i(309493),m=e.i(108281),h=e.i(140483),p=e.i(371522);e.i(112946);var f=e.i(164300);function g(e){return e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}let x=new Set(["status","log"]);function v({item:e,isRunning:a,isLast:n}){let r=(0,s.useMemo)(()=>{if(!e.input)return null;try{return JSON.stringify(e.input,null,2)}catch{return String(e.input)}},[e.input]);return r?(0,t.jsxs)("details",{className:"group/tool",children:[(0,t.jsxs)("summary",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md cursor-pointer select-none","text-sm text-muted-foreground transition-colors duration-150","hover:bg-muted/60 hover:text-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,t.jsx)(d.ChevronRight,{className:"size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/tool:rotate-90"}),(0,t.jsx)("span",{className:"font-medium text-foreground/80",children:g(e.tool)}),a&&n&&(0,t.jsx)("span",{className:"ml-auto size-1.5 rounded-full bg-primary/60 animate-pulse"}),a&&!n&&(0,t.jsx)(c.Check,{className:"ml-auto size-3 text-emerald-500"})]}),(0,t.jsx)("div",{className:"mt-1 mb-2 ml-5",children:(0,t.jsx)("pre",{className:"task-stream-pre overflow-x-auto rounded-md bg-muted/40 p-2.5 font-mono text-xs leading-relaxed text-muted-foreground max-h-48 max-w-full min-w-0 overflow-y-auto",children:r})})]}):(0,t.jsxs)("div",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md","text-sm text-muted-foreground"),children:[(0,t.jsx)("span",{className:"font-medium text-foreground/80",children:g(e.tool)}),a&&n&&(0,t.jsx)("span",{className:"ml-auto size-1.5 rounded-full bg-primary/60 animate-pulse"}),a&&!n&&(0,t.jsx)(c.Check,{className:"ml-auto size-3 text-emerald-500"})]})}function k({item:e}){return e.content?(0,t.jsxs)("details",{className:"group/think",children:[(0,t.jsxs)("summary",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md cursor-pointer select-none","text-sm text-muted-foreground/60 italic transition-colors duration-150","hover:bg-muted/60 hover:text-muted-foreground","[&::-webkit-details-marker]:hidden [&::marker]:hidden"),children:[(0,t.jsx)(d.ChevronRight,{className:"size-3 shrink-0 text-muted-foreground/40 transition-transform duration-150 group-open/think:rotate-90"}),(0,t.jsx)(u.Brain,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Thinking..."})]}),(0,t.jsx)("div",{className:"mt-1 mb-2 ml-5",children:(0,t.jsx)("p",{className:"text-sm italic text-muted-foreground/60 whitespace-pre-wrap",children:e.content})})]}):(0,t.jsxs)("div",{className:(0,o.cn)("flex items-center gap-2 py-1 px-2 -mx-2 rounded-md","text-sm text-muted-foreground/60 italic"),children:[(0,t.jsx)(u.Brain,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Thinking..."})]})}function y({value:e}){let a=(0,s.useRef)(e),[n,r]=(0,s.useState)({current:e,previous:null}),[l,i]=(0,s.useState)("idle");return(0,s.useEffect)(()=>{if(e===a.current)return;let t=a.current;a.current=e,r({current:e,previous:t}),requestAnimationFrame(()=>{requestAnimationFrame(()=>{i("animating")})});let s=setTimeout(()=>{i("idle"),r(e=>({...e,previous:null}))},300);return()=>clearTimeout(s)},[e]),(0,t.jsxs)("span",{style:{display:"inline-block",position:"relative",overflow:"hidden",height:"1.2em",lineHeight:"1.2em",verticalAlign:"bottom"},children:[null!==n.previous&&(0,t.jsx)("span",{style:{display:"block",position:"absolute",inset:"0",transition:"animating"===l?"transform 250ms ease-out, opacity 250ms ease-out":"none",transform:"animating"===l?"translateY(-100%)":"translateY(0)",opacity:+("animating"!==l)},children:n.previous}),(0,t.jsx)("span",{style:{display:"block",transition:"animating"===l?"transform 250ms ease-out, opacity 250ms ease-out":"none",transform:null!==n.previous&&"animating"!==l?"translateY(100%)":"translateY(0)",opacity:+(null===n.previous||"animating"===l)},children:n.current})]})}function j({task:e,messages:a,connectionLost:n,onRetry:r,stepCountHint:l,onExpandSteps:c,stepsLoading:u}){let[g,b]=(0,s.useState)(!1),w=(0,s.useMemo)(()=>(function(e){let t=[],s=new Map;for(let a of e){if(x.has(a.type))continue;let e=a.id||`seq-${a.seq}`;switch(a.type){case"tool-use":{let n=a.call_id,r={kind:"tool-call",id:e,tool:a.tool,input:a.input};n&&s.set(n,r),t.push(r);break}case"tool-result":break;case"text":t.push({kind:"text",id:e,content:a.content});break;case"thinking":t.push({kind:"thinking",id:e,content:a.content});break;case"error":t.push({kind:"status",id:e,content:a.content||a.output,type:"error"})}}return t})(a),[a]),N="completed"!==e.status&&"failed"!==e.status&&"cancelled"!==e.status&&"superseded"!==e.status,S=w.filter(e=>"text"!==e.kind),C=w.filter(e=>"text"===e.kind),_=C.length>0?C[C.length-1]:null,T=(0,s.useRef)(null),M=(0,s.useRef)(null),I=(0,s.useRef)(!1);(0,s.useEffect)(()=>{N&&T.current&&(T.current.scrollTop=T.current.scrollHeight)},[S.length,N]),(0,s.useEffect)(()=>{N&&M.current&&(M.current.scrollTop=M.current.scrollHeight)},[C.length,N]);let A=N?C:C.slice(0,-1),z=!N&&null!==_,E=S.length>0?S.length:l??0,R=S.length>0||l&&l>0;return(0,t.jsxs)("div",{className:"space-y-3 min-w-0 max-w-full",children:[(0,t.jsx)("div",{className:"flex items-center gap-2",children:"running"===e.status?(0,t.jsxs)(i.Badge,{variant:"secondary",className:"gap-1.5 relative overflow-hidden",children:[(0,t.jsx)("span",{className:"size-1.5 rounded-full bg-primary animate-pulse"}),"Working",(0,t.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%)"}})]}):N?(0,t.jsxs)(i.Badge,{variant:"secondary",className:"relative overflow-hidden",children:[e.status,(0,t.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,t.jsx)(i.Badge,{variant:"secondary",children:e.status})}),R&&(0,t.jsxs)("details",{className:"group/stream pl-1",onToggle:e=>{e.currentTarget.open&&!I.current&&c&&(I.current=!0,c())},children:[(0,t.jsxs)("summary",{className:(0,o.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,t.jsx)(d.ChevronRight,{className:(0,o.cn)("size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/stream:rotate-90",N&&"animate-pulse text-primary")}),(0,t.jsxs)("span",{children:[(0,t.jsx)(y,{value:E})," ",1===E?"step":"steps"]})]}),(0,t.jsxs)("div",{ref:T,className:"mt-1 max-h-80 overflow-y-auto overflow-x-hidden thin-scrollbar space-y-0.5 pl-1",children:[u&&0===S.length&&(0,t.jsxs)("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[(0,t.jsx)(p.Loader2,{className:"size-3 animate-spin"}),(0,t.jsx)("span",{children:"Loading steps..."})]}),S.map((e,s)=>{switch(e.kind){case"tool-call":return(0,t.jsx)(v,{item:e,isRunning:N,isLast:s===S.length-1},e.id);case"thinking":return(0,t.jsx)(k,{item:e},e.id);case"status":return(0,t.jsxs)("p",{className:"text-xs text-muted-foreground px-1 wrap-anywhere",children:["error"===e.type&&(0,t.jsx)(m.AlertCircle,{className:"inline size-3 mr-1 -mt-0.5 text-destructive"}),e.content]},e.id);default:return null}})]})]}),A.length>0&&(0,t.jsxs)("details",{className:"group/midtext pl-1",open:!z||void 0,children:[(0,t.jsxs)("summary",{className:(0,o.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,t.jsx)(d.ChevronRight,{className:"size-3 shrink-0 text-muted-foreground/60 transition-transform duration-150 group-open/midtext:rotate-90"}),(0,t.jsxs)("span",{children:[(0,t.jsx)(y,{value:A.length})," thinking"]})]}),(0,t.jsx)("div",{ref:M,className:"mt-1 space-y-2 pl-1",children:A.map(e=>(0,t.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-0.5 text-sm text-muted-foreground",children:(0,t.jsx)(f.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},children:e.content})},e.id))})]}),z&&!c&&(0,t.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground",children:(0,t.jsx)(f.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},children:_.content})}),"failed"===e.status&&e.error&&(0,t.jsxs)("div",{className:"flex items-start gap-2 mt-2 max-w-full overflow-hidden",children:[(0,t.jsxs)("p",{className:"text-sm text-destructive flex items-start gap-1.5 min-w-0",children:[(0,t.jsx)(m.AlertCircle,{className:"size-3.5 shrink-0 mt-0.5"}),(0,t.jsx)("span",{className:"wrap-anywhere",children:e.error})]}),r&&(0,t.jsxs)("button",{type:"button",onClick:async()=>{b(!0);try{await r()}finally{b(!1)}},disabled:g,className:"shrink-0 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1",children:[g?(0,t.jsx)(p.Loader2,{className:"size-3 animate-spin"}):(0,t.jsx)(h.RotateCw,{className:"size-3"}),"Retry"]})]}),n&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground animate-pulse mt-1",children:"Connection lost — retrying..."})]})}var b=e.i(222862),w=e.i(275351),N=e.i(355578),S=e.i(875494),C=e.i(74348),_=e.i(872937),T=e.i(880932),M=e.i(728886),I=e.i(329686),A=e.i(36303),z=e.i(406963);let E=(0,z.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"}]]),R=(0,z.default)("box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);var F=e.i(872057),D=e.i(6131);let q=(0,z.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 L=e.i(554468),$=e.i(745925),P=e.i(937091);function B({agent:e,isSelected:s,onSelect:a}){return(0,t.jsxs)("button",{type:"button","data-mention-item":!0,className:(0,o.cn)("flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm transition-colors",s?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,t.jsx)("span",{className:"truncate font-medium",children:e.name}),e.email_handle&&(0,t.jsxs)("span",{className:"truncate text-xs text-muted-foreground",children:[e.email_handle,"@alook.ai"]})]})}function W({isOpen:e,relatedAgents:a,otherAgents:n,selectedIndex:r,onSelect:l,anchorPos:i}){let o=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!o.current)return;let e=o.current.querySelectorAll("[data-mention-item]")[r];e?.scrollIntoView({block:"nearest"})},[r]);let c=a.length+n.length;if(!e||0===c)return null;let d=a.length>0&&n.length>0;return(0,t.jsx)("div",{className:"absolute z-50 w-64 rounded-lg border border-border bg-popover text-popover-foreground shadow-md transition-opacity duration-150",style:{top:i.top-4,left:i.left,transform:"translateY(-100%)"},children:(0,t.jsxs)("div",{ref:o,className:"max-h-50 overflow-y-auto py-1 thin-scrollbar",children:[a.map((e,s)=>(0,t.jsx)(B,{agent:e,isSelected:s===r,onSelect:l},e.id)),d&&(0,t.jsx)("div",{className:"mx-3 my-1 border-t border-border"}),n.map((e,s)=>(0,t.jsx)(B,{agent:e,isSelected:a.length+s===r,onSelect:l},e.id))]})})}function H({skill:e,isSelected:s,onSelect:a}){return(0,t.jsxs)("button",{type:"button","data-slash-item":!0,className:(0,o.cn)("flex w-full flex-col gap-0.5 px-3 py-1.5 text-left text-sm transition-colors",s?"bg-accent text-accent-foreground":"hover:bg-accent/50"),onMouseDown:t=>{t.preventDefault(),a(e)},children:[(0,t.jsxs)("span",{className:"flex w-full items-center gap-2",children:[(0,t.jsxs)("span",{className:"min-w-0 flex-1 truncate font-medium",children:["/",e.name]}),e.isGlobal&&(0,t.jsx)("span",{className:"shrink-0 rounded px-1 py-0.5 text-[10px] font-medium bg-muted text-muted-foreground",children:"Global"})]}),e.description&&(0,t.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:e.description.slice(0,80)})]})}function O({isOpen:e,skills:a,selectedIndex:n,onSelect:r,anchorPos:l}){let i=(0,s.useRef)(null);return((0,s.useEffect)(()=>{if(!i.current)return;let e=i.current.querySelectorAll("[data-slash-item]")[n];e?.scrollIntoView({block:"nearest"})},[n]),e&&0!==a.length)?(0,t.jsx)("div",{className:"absolute z-50 w-70 rounded-lg border border-border bg-popover text-popover-foreground shadow-md transition-opacity duration-150",style:{top:l.top-4,left:l.left,transform:"translateY(-100%)"},children:(0,t.jsx)("div",{ref:i,className:"max-h-60 overflow-y-auto py-1 thin-scrollbar",children:a.map((e,s)=>(0,t.jsx)(H,{skill:e,isSelected:s===n,onSelect:r},e.name))})}):null}function V(e,t){if(t>=e.length)return!0;let s=e.charCodeAt(t);return(!(s>=48)||!(s<=57))&&(!(s>=65)||!(s<=90))&&(!(s>=97)||!(s<=122))&&95!==s}function U(e,t){if(!e||0===t.length||!e.includes("@"))return e;let s=t.slice().sort((e,t)=>t.name.length-e.name.length),a=[];for(let t=0;t<e.length;t++){if("@"!==e[t]||!function(e,t){if(0===t)return!0;let s=e.charCodeAt(t-1);return(!(s>=48)||!(s<=57))&&(!(s>=65)||!(s<=90))&&(!(s>=97)||!(s<=122))&&95!==s}(e,t))continue;let n=t+1;for(let r of s){let s=n+r.name.length;if(s>e.length||e.slice(n,s).toLowerCase()!==r.name.toLowerCase())continue;let l=s,i=e.slice(s).match(/^ \([a-zA-Z0-9-]+@alook\.ai\)/);if(i&&(l=s+i[0].length),(i||V(e,s))&&(!i||V(e,l))){if(a.some(e=>t>=e.start&&t<e.end))break;a.push({start:t,end:s,name:r.name,agentId:r.id});break}}}let n=e;for(let e=a.length-1;e>=0;e--){let t=a[e],s=n.slice(t.start,t.end);n=n.slice(0,t.start)+`<mention data-agent-id="${t.agentId}">${s}</mention>`+n.slice(t.end)}return n}var K=e.i(721387),Y=e.i(332680),X=e.i(940931);function J({open:e,onOpenChange:a,emailId:n,workspaceId:r}){let[i,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(null),[u,m]=(0,s.useState)(!1),[h,f]=(0,s.useState)(500),g=(0,s.useRef)(!1),x=(0,s.useRef)(a);(0,s.useEffect)(()=>{x.current=a}),(0,s.useEffect)(()=>{e&&n&&(m(!0),o(null),d(null),Promise.all([(0,b.getEmail)(n,r),(0,b.getEmailBody)(n,r)]).then(([e,t])=>{o(e),d(t)}).catch(()=>{T.toast.error("Email not found"),x.current(!1)}).finally(()=>m(!1)))},[e,n,r]);let v=e=>{a(e),e||setTimeout(()=>{o(null),d(null)},300)},k=(0,s.useCallback)(e=>{e.preventDefault(),g.current=!0,e.target.setPointerCapture(e.pointerId)},[]),y=(0,s.useCallback)(e=>{g.current&&f(Math.min(.8*window.innerWidth,Math.max(320,window.innerWidth-e.clientX)))},[]),j=(0,s.useCallback)(()=>{g.current=!1},[]);return(0,t.jsx)(Y.Sheet,{open:e,onOpenChange:v,children:(0,t.jsxs)(Y.SheetContent,{side:"right",showCloseButton:!1,style:{width:`min(${h}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,t.jsx)("div",{onPointerDown:k,onPointerMove:y,onPointerUp:j,className:"hidden sm:block absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 hover:bg-primary/20 active:bg-primary/30 transition-colors rounded-l-xl"}),(0,t.jsx)(Y.SheetHeader,{children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(D.Mail,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,t.jsx)(Y.SheetTitle,{className:"truncate flex-1",children:u?"Loading...":i?.subject||"Email"}),(0,t.jsx)(l.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>v(!1),children:(0,t.jsx)(P.X,{className:"h-4 w-4"})})]})}),(0,t.jsx)(Y.SheetBody,{className:"flex-1 overflow-y-auto thin-scrollbar",children:u?(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsx)(p.Loader2,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):i?(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"text-sm space-y-1 border-b pb-3",children:[(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:"From:"}),(0,t.jsx)("span",{className:"truncate",children:i.from_email})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:"To:"}),(0,t.jsx)("span",{className:"truncate",children:i.to_email})]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:"Date:"}),(0,t.jsx)("span",{children:new Date(i.created_at).toLocaleString()})]})]}),c?.isHtml?(0,t.jsx)(X.EmailBodyFrame,{html:c.content,className:"max-w-full"}):(0,t.jsx)("pre",{className:"whitespace-pre-wrap text-sm font-mono",children:c?.content}),i.attachments&&i.attachments.length>0&&(0,t.jsxs)("div",{className:"border-t pt-3",children:[(0,t.jsxs)("p",{className:"text-xs text-muted-foreground mb-2",children:[i.attachments.length," attachment",i.attachments.length>1?"s":""]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:i.attachments.map(e=>(0,t.jsx)("span",{className:"inline-flex items-center gap-1 text-xs bg-muted rounded px-2 py-1",children:e.filename},e.key))})]})]}):null})]})})}var G=e.i(781360),Z=e.i(169678),Q=e.i(364079);function ee({bufferedMessages:e,onDelete:a}){let[n,r]=(0,s.useState)(!1),l=e.length;if(0===l)return null;let i=Math.min(l,3);return(0,t.jsx)("div",{className:"relative px-5 pb-1",children:(0,t.jsx)("div",{className:"mx-auto max-w-2xl flex justify-center",children:(0,t.jsxs)("div",{className:"relative w-full max-w-lg transition-[height] duration-200 ease-out",style:{height:n?32*l+(l-1)*4:32+(i-1)*6},onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e.map((e,s)=>{var r;let c=l-1-s,d=s>=l-i;return(0,t.jsx)("div",{className:"absolute right-0 left-0 transition-all duration-200 ease-out",style:{height:32,zIndex:s+1,bottom:n?36*c:d?6*c:0,transform:n?"scale(1)":`scale(${d?1-.03*c:.91})`,opacity:n?1:d?1-.2*c:0,pointerEvents:n||d?"auto":"none"},children:(0,t.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,t.jsx)("span",{className:"shrink-0 text-[11px] text-primary/60 tabular-nums w-4 text-center",children:s+1}),(0,t.jsxs)("div",{className:"min-w-0 flex-1 flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-[13px] text-muted-foreground leading-snug truncate",children:(r=e.content).length<=80?r:r.slice(0,80).trimEnd()+"…"}),e.attachment_ids&&e.attachment_ids.length>0&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 shrink-0 text-[11px] text-muted-foreground/50",children:[(0,t.jsx)(L.Paperclip,{className:"size-2.5"}),e.attachment_ids.length]})]}),(0,t.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),a(e.id)},className:(0,o.cn)("shrink-0 rounded-sm p-0.5 transition-all duration-150","text-muted-foreground/30 hover:text-foreground hover:bg-muted",n?"opacity-100":"opacity-0"),tabIndex:n?0:-1,children:(0,t.jsx)(P.X,{className:"size-3"})})]})},e.id)}),!n&&l>i&&(0,t.jsxs)("span",{className:"absolute -top-4 right-1 text-[10px] text-muted-foreground/40 tabular-nums",children:["+",l-i," more"]})]})})})}var et=e.i(219658);let es={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 ea({taskId:e,stepCount:a,workspaceId:n}){let[r,l]=(0,s.useState)([]),[i,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(!1),u=(0,s.useCallback)(async()=>{if(!c&&!i){o(!0);try{let t=await (0,b.getTaskMessages)(e,n);l(t)}catch{l([])}finally{o(!1),d(!0)}}},[c,i,e,n]);return(0,t.jsx)(j,{task:es,messages:r,stepCountHint:a,onExpandSteps:u,stepsLoading:i})}var en=e.i(983453),er=e.i(251638);let el=(0,z.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"}]]);e.s(["Flag",0,el],618615);var ei=e.i(89440);let eo={mention:["data-agent-id"]},ec=["mention"];function ed({content:e,conversationType:s}){let a=ey(e,s),n="h-4 w-4 mt-0.5 shrink-0";return"issue"===a?(0,t.jsx)(er.CircleDot,{className:n}):"email"===a?(0,t.jsx)(D.Mail,{className:n}):(0,t.jsx)(en.Calendar,{className:n})}function eu({attachmentIds:e,artifacts:s,onArtifactClick:a}){let n=e.map(e=>s.find(t=>t.id===e)).filter(e=>!!e);return 0===n.length?null:(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:n.map(e=>(0,t.jsxs)("button",{type:"button",onClick:t=>{t.stopPropagation(),a(e)},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,t.jsx)(F.FileText,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-37.5",children:e.filename})]},e.id))})}function em({pendingFiles:e,messageId:s}){let a=e.get(s);return a&&0!==a.length?(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:a.map((e,s)=>(0,t.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,t.jsx)(F.FileText,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-37.5",children:e.name})]},s))}):null}let eh=(0,s.memo)(function({msg:e,agents:a,artifacts:n,activeTask:r,taskMessages:i,connectionLost:d,isLastMessage:u,stepCount:m,targetConvId:h,workspaceId:p,conversationType:g,pendingFilesByMessage:x,onArtifactClick:v,onEmailClick:k,onIssueClick:y,onCalendarEventClick:b,onRetry:w,mentionComponents:N,isFlagged:S,onToggleFlag:C}){let _,M,A,z,E,R,F,[D,q]=(0,s.useState)(!1),L=r&&"assistant"===e.role&&e.task_id===r.id&&e.conversation_id===r.conversation_id&&i.length>0,$=!L&&h&&"assistant"===e.role&&e.task_id&&m>0?m:0,P=L&&r&&["completed","failed","cancelled","superseded"].includes(r.status),B="assistant"===e.role?(0,t.jsxs)("div",{className:"flex flex-row items-center gap-1",children:[(0,t.jsxs)(I.Tooltip,{children:[(0,t.jsx)(I.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-xs","aria-label":D?"Copied":"Copy message",onClick:async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e.content),q(!0),T.toast.success("Copied to clipboard"),setTimeout(()=>q(!1),2e3)}catch{T.toast.error("Failed to copy")}},className:(0,o.cn)("self-start mb-1",D?"text-green-500 opacity-100":"text-muted-foreground md:opacity-0 md:group-hover/msg:opacity-100")}),children:D?(0,t.jsx)(c.Check,{className:"size-3.5"}):(0,t.jsx)(ei.Copy,{className:"size-3.5"})}),(0,t.jsx)(I.TooltipContent,{children:D?"Copied":"Copy"})]}),C&&(0,t.jsxs)(I.Tooltip,{children:[(0,t.jsx)(I.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-xs",onClick:()=>C(e.id),className:(0,o.cn)("self-start mb-1",S?"text-primary opacity-100":"text-muted-foreground md:opacity-0 md:group-hover/msg:opacity-100")}),children:(0,t.jsx)(el,{className:(0,o.cn)("size-3.5",S&&"fill-current")})}),(0,t.jsx)(I.TooltipContent,{children:S?"Unflag":"Flag"})]})]}):null;return(0,t.jsxs)(s.default.Fragment,{children:[L&&(0,t.jsxs)("div",{className:(0,o.cn)("group/msg",S&&"bg-muted/30 rounded-lg px-2 -mx-2"),...P?{"data-quote-source":!0}:{},children:[(0,t.jsx)(j,{task:r,messages:i,connectionLost:d,onRetry:w}),P&&B]}),$>0&&e.task_id&&(0,t.jsx)(ea,{taskId:e.task_id,stepCount:$,workspaceId:p}),"user"===e.role?(_=u&&!!r&&"running"!==r.status&&!["completed","failed","cancelled","superseded"].includes(r.status),M=e.content.match(/^\/(\S+)\s?([\s\S]*)$/),A=M?.[1]??null,z=M?M[2]||"":e.content,(0,t.jsx)("div",{className:"flex justify-end","data-message-id":e.id,...e.task_id?{"data-task-id":e.task_id}:{},children:(0,t.jsxs)("div",{className:(0,o.cn)("max-w-[80%] rounded-lg px-4 py-2 bg-primary text-primary-foreground text-base relative"),children:[_&&(0,t.jsx)("div",{className:"absolute inset-0 rounded-lg animate-pulse pointer-events-none",style:{boxShadow:"0 0 0 2px var(--bubble-glow)"}}),A&&(0,t.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:["/",A]}),z&&(0,t.jsx)("div",{className:"markdown markdown-user",children:(0,t.jsx)(f.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!1,download:!1,fullscreen:!1}},linkSafety:{enabled:!1},allowedTags:eo,literalTagContent:ec,components:N,children:U(z,a)})}),e.attachment_ids&&e.attachment_ids.length>0&&(0,t.jsx)(eu,{attachmentIds:e.attachment_ids,artifacts:n,onArtifactClick:v}),!e.attachment_ids&&(0,t.jsx)(em,{pendingFiles:x,messageId:e.id})]})})):"event"===e.role?(E=e.metadata?.emailId,R=e.metadata?.issueId,F=e.metadata?.calendarEventId,(0,t.jsx)("div",{className:"flex justify-start","data-message-id":e.id,...e.task_id?{"data-task-id":e.task_id}:{},children:(0,t.jsxs)("div",{className:(0,o.cn)("w-full rounded-md border bg-muted/50 text-muted-foreground text-sm px-3 py-2 flex items-start gap-2",(!!E||!!R||!!F)&&"cursor-pointer hover:bg-muted transition-colors"),onClick:E?()=>k(E):R?()=>y(R):F?()=>b(F):void 0,children:[(0,t.jsx)(ed,{content:e.content,conversationType:g}),(0,t.jsx)("span",{className:"min-w-0 wrap-anywhere",children:e.content})]})})):L?null:(0,t.jsxs)("div",{className:(0,o.cn)("group/msg flex flex-col justify-start min-w-0 overflow-hidden",S&&"bg-muted/30 rounded-lg px-2 -mx-2"),"data-message-id":e.id,"data-quote-source":!0,...e.task_id?{"data-task-id":e.task_id}:{},children:[(0,t.jsx)("div",{className:"markdown max-w-full min-w-0 px-1 py-1 text-base text-foreground",children:(0,t.jsx)(f.Streamdown,{controls:{code:{copy:!0,download:!1},table:{copy:!0,download:!1,fullscreen:!0}},linkSafety:{enabled:!1},allowedTags:eo,literalTagContent:ec,components:N,children:U(e.content,a)})}),B]})]})});e.i(400175);var ep=e.i(819748),ef=e.i(126366),eg=e.i(309475);function ex({agent:e,isOnline:a,activeTaskCount:n,variant:r="default",isHovered:l}){let[i,d]=(0,s.useState)(!1),u=e.email_handle?`${e.email_handle}@alook.ai`:null,m=(0,s.useCallback)(async()=>{if(u)try{await navigator.clipboard.writeText(u),d(!0),T.toast.success("Email copied to clipboard"),setTimeout(()=>d(!1),2e3)}catch{T.toast.error("Failed to copy email")}},[u]);if("compact"===r){let s;return(0,t.jsxs)("div",{className:"flex items-center gap-2 p-0",children:[(s=(0,ef.parseAvatarUrl)(e.avatar_url))?(0,t.jsx)(ep.AnimatedAvatar,{config:s,size:32,className:"shrink-0 rounded-xl",isHovered:l??!1,isWorking:!!a&&(n??0)>0}):(0,t.jsx)("div",{className:"flex items-center justify-center size-8 rounded-xl bg-secondary text-secondary-foreground text-xs font-medium shrink-0",children:e.name.charAt(0).toUpperCase()}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate max-w-35",children:e.name}),u&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:u})]}),void 0!==a&&(0,t.jsx)("div",{className:"pointer-events-none mt-0.5",children:(0,t.jsx)(eg.AgentStatusBadge,{isOnline:a,taskCount:n??0,agentId:e.id})})]})]})}return(0,t.jsxs)("div",{className:"flex flex-col gap-1.5 p-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("p",{className:"text-sm font-medium truncate",children:e.name}),(0,t.jsx)("span",{className:"flex-1"}),void 0!==a&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-[11px] text-muted-foreground",children:[(0,t.jsx)("span",{className:(0,o.cn)("size-1.5 rounded-full",a?"bg-status-online":"bg-status-offline")}),a?(n??0)>0?"Working":null:"Offline"]})]}),u&&(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:u}),(0,t.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),m()},className:"shrink-0 p-0.5 rounded-sm text-muted-foreground/60 hover:text-foreground transition-colors cursor-pointer",children:i?(0,t.jsx)(c.Check,{className:"size-3 text-green-500"}):(0,t.jsx)(ei.Copy,{className:"size-3"})})]}),e.description&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-2",children:e.description})]})}e.s(["AgentPreviewCard",0,ex],844010);var ev=e.i(224950);let ek={mention:function(e){let{children:s,...a}=e,{agents:n}=(0,N.useAgentContext)(),r=a["data-agent-id"]??a.dataAgentId,l=r?n.find(e=>e.id===r):void 0;if(!l&&"string"==typeof s){let e=s.startsWith("@")?s.slice(1):s;l=n.find(t=>t.name.toLowerCase()===e.toLowerCase())}return l?(0,t.jsxs)(ev.Popover,{children:[(0,t.jsx)(ev.PopoverTrigger,{openOnHover:!0,delay:300,nativeButton:!1,render:(0,t.jsx)("span",{className:"mention-highlight cursor-pointer"}),children:s}),(0,t.jsx)(ev.PopoverContent,{side:"top",className:"w-fit max-w-80",children:(0,t.jsx)(ex,{agent:l})})]}):(0,t.jsx)("span",{className:"mention-highlight",children:s})},p:({children:e,node:s,...a})=>(0,t.jsx)("div",{"data-md-p":"",...a,children:e})};function ey(e,t){if("issue_event"===t)return"issue";if("email_notification"===t)return"email";if("calendar_event"===t)return"calendar";let s=e.toLowerCase();return s.startsWith("issue ")||s.startsWith("issue:")?"issue":s.includes("email")?"email":"calendar"}function ej(e,t){let s=new Map;for(let t of e)s.set(t.id,t);for(let e of t)s.set(e.id,e);return[...s.values()].slice().sort((e,t)=>{let s=e.created_at.localeCompare(t.created_at);return 0!==s?s:e.id.localeCompare(t.id)})}function eb(e){let t=[],s=[],a=!1;for(let n of e)"message"===n.kind&&"user"===n.data.role?(a=!0,t.push(n)):"message"===n.kind&&"assistant"===n.data.role?(t.push(n),t.push(...s),s=[],a=!1):a&&"artifact"===n.kind?s.push(n):t.push(n);return t.push(...s),t}function ew(e){let t=(0,s.useRef)(e);return(0,s.useEffect)(()=>{t.current=e},[e]),t}function eN({agentName:e}){return(0,t.jsxs)("div",{className:"flex items-center gap-3 py-4 select-none","aria-hidden":!0,children:[(0,t.jsx)("div",{className:"flex-1 border-t border-border/40"}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground/60 whitespace-nowrap",children:[e," took a nap 💤"]}),(0,t.jsx)("div",{className:"flex-1 border-t border-border/40"})]})}function eS({artifact:e,version:s,hasDuplicates:a,onClick:n}){return(0,t.jsxs)("button",{onClick:()=>n(e),className:(0,o.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,t.jsx)(F.FileText,{className:"size-4 shrink-0 text-muted-foreground"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("p",{className:"text-sm font-medium truncate",children:[e.filename,a&&(0,t.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",s]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:(0,K.formatSize)(e.size)})]})]})}function eC({agentId:e,targetConvId:i,scrollToTaskId:c,scrollToMessageId:d}){let u,m,h,f=(0,n.useParams)(),g=(0,n.useSearchParams)(),{workspaceId:x,slug:v}=(0,r.useWorkspace)(),{agents:k,agentLinks:y,activeTaskCounts:z,subscribeWs:B}=(0,N.useAgentContext)(),{refresh:H}=(0,S.useInboxCount)(),{activeChannel:V,loading:Y,setAgentId:X}=(0,_.useChannel)(),es=e??f.id,ea=void 0!==c?c:g.get("task"),en=void 0!==d?d:g.get("msg"),er=void 0!==i?i:g.get("conv"),[el,ei]=(0,s.useState)(null),[eo,ec]=(0,s.useState)([]),[ed,eu]=(0,s.useState)(()=>localStorage.getItem(`chat-draft:${es}:${er??"default"}`)??""),[em,ep]=(0,s.useState)(!1),[ef,eg]=(0,s.useState)(!1),[ex,ev]=(0,s.useState)(null),[ey,e_]=(0,s.useState)([]),[eT,eM]=(0,s.useState)(!0),[eI,eA]=(0,s.useState)(!1),[ez,eE]=(0,s.useState)(!1),[eR,eF]=(0,s.useState)(!1),[eD,eq]=(0,s.useState)([]),[eL,e$]=(0,s.useState)(!1),[eP,eB]=(0,s.useState)(null),[eW,eH]=(0,s.useState)(null),[eO,eV]=(0,s.useState)(!1),[eU,eK]=(0,s.useState)(null),[eY,eX]=(0,s.useState)(!1),[eJ,eG]=(0,s.useState)(null),[eZ,eQ]=(0,s.useState)(!1),[e0,e1]=(0,s.useState)(null),[e2,e5]=(0,s.useState)(null),[e3,e4]=(0,s.useState)(!1),[e6,e8]=(0,s.useState)(null),[e9,e7]=(0,s.useState)(null),[te,tt]=(0,s.useState)(448),[ts,ta]=(0,s.useState)([]),[tn,tr]=(0,s.useState)([]),[tl,ti]=(0,s.useState)(null),[to,tc]=(0,s.useState)([]),[td,tu]=(0,s.useState)(!1),[tm,th]=(0,s.useState)([]),[tp,tf]=(0,s.useState)({}),[tg]=(0,s.useState)(()=>Date.now()),[tx,tv]=(0,s.useState)(()=>new Map),[tk,ty]=(0,s.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(`chat-draft-meta:${es}:${er??"default"}`)??"null");return e?.quote??null}catch{return null}}),[tj,tb]=(0,s.useState)(null),[tw,tN]=(0,s.useState)(new Set),tS=(0,s.useRef)(tw);(0,s.useEffect)(()=>{tS.current=tw});let{increment:tC,decrement:t_,refresh:tT}=(0,C.useFlagCount)(),{writeToCache:tM}=function(e,t){let[a,n]=(0,s.useState)(null),[r,l]=(0,s.useState)(!1),i=(0,s.useRef)(e);return(0,s.useEffect)(()=>{if(i.current=e,!e||!t){n(null),l(!1);return}(0,w.openCacheDB)(t);let s=!1;return(0,w.getCachedMessages)(e,t).then(t=>{s||i.current!==e||(t&&t.length>0?(n(t),l(!0)):(n(null),l(!1)))}),()=>{s=!0}},[e,t]),{cachedMessages:a,isFromCache:r,writeToCache:(0,s.useCallback)(async(e,s)=>{i.current&&t&&await (0,w.mergeCachedMessages)(i.current,e,s,t)},[t])}}(er??null,x),tI=(0,s.useRef)(tM);(0,s.useEffect)(()=>{tI.current=tM},[tM]),(0,s.useEffect)(()=>{X(es)},[es,X]);let tA=(0,s.useMemo)(()=>eD.filter(e=>"agent"===e.source),[eD]),{versionMap:tz,duplicateFilenames:tE}=(0,s.useMemo)(()=>(0,Q.computeArtifactVersions)(tA),[tA]),tR=(0,s.useMemo)(()=>"agent"===eW?tA:"issue"===eW?e2?.artifacts??[]:[],[eW,tA,e2?.artifacts]),{versionMap:tF,duplicateFilenames:tD}=(0,s.useMemo)(()=>(0,Q.computeArtifactVersions)(tR),[tR]),tq=(0,s.useMemo)(()=>(function(e,t,s,a){if(!a||0===s.length){let a=[...e.map(e=>({kind:"message",data:e})),...t.map(e=>({kind:"artifact",data:e})),...s.map(e=>({kind:"nap",data:e}))];return a.sort((e,t)=>{let s=e.data.created_at.localeCompare(t.data.created_at);if(0!==s)return s;if("nap"===e.kind||"nap"===t.kind){if("nap"===e.kind&&"nap"!==t.kind)return 1;if("nap"!==e.kind&&"nap"===t.kind)return -1}return e.kind!==t.kind?"message"===e.kind?-1:1:e.data.id.localeCompare(t.data.id)}),eb(a)}let n=new Set(s.map(e=>e.id.replace(/^nap-/,""))),r=[...s].sort((e,t)=>e.created_at.localeCompare(t.created_at)),l=s=>eb([...e.filter(e=>e.conversation_id===s).map(e=>({kind:"message",data:e})),...t.filter(e=>e.conversation_id===s).map(e=>({kind:"artifact",data:e}))].sort((e,t)=>{let s=e.data.created_at.localeCompare(t.data.created_at);return 0!==s?s:e.kind!==t.kind?"message"===e.kind?-1:1:e.data.id.localeCompare(t.data.id)})),i=[];for(let e of r){let t=e.id.replace(/^nap-/,"");i.push(...l(t)),i.push({kind:"nap",data:e})}i.push(...l(a));let o=new Set([...n,a]),c=e.filter(e=>!o.has(e.conversation_id)),d=t.filter(e=>!o.has(e.conversation_id));if(c.length>0||d.length>0){let e=[...c.map(e=>({kind:"message",data:e})),...d.map(e=>({kind:"artifact",data:e}))];e.sort((e,t)=>{let s=e.data.created_at.localeCompare(t.data.created_at);return 0!==s?s:e.kind!==t.kind?"message"===e.kind?-1:1:e.data.id.localeCompare(t.data.id)});let t=eb(e),s=i.findIndex(e=>"nap"===e.kind);s>=0?i.splice(s,0,...t):i.push(...t)}return i})(eo,tA,tm,el?.id),[eo,tA,tm,el?.id]),tL=(0,s.useCallback)(e=>{(0,Q.isPreviewable)(e)?(eB(e),eH("agent"),e$(!0)):window.open((0,Q.getArtifactUrl)(e.id,x,!0),"_blank")},[x]),t$=(0,s.useCallback)(e=>{(0,Q.isPreviewable)(e)?(eB(e),eH("issue"),e$(!0)):window.open((0,Q.getArtifactUrl)(e.id,x,!0),"_blank")},[x]),tP=(0,s.useRef)(null),tB=(0,s.useRef)(null),tW=(0,s.useRef)(null),tH=(0,s.useRef)(null),tO=(0,s.useRef)(0),tV=(0,s.useRef)(0),tU=(0,s.useRef)(!1),tK=(0,s.useRef)(!1),tY=(0,s.useRef)(!0),tX=(0,s.useRef)(!1),tJ=(0,s.useRef)(null),tG=(0,s.useRef)(null),tZ=(0,s.useRef)(0),tQ=(0,s.useRef)(void 0),t0=(0,s.useRef)(null),t1=(0,s.useRef)(null),t2=function({input:e,caretIndex:t,textareaRef:a,agents:n,agentLinks:r,currentAgentId:l,onInputChange:i}){let[o,c]=(0,s.useState)(!1),[d,u]=(0,s.useState)(""),[m,h]=(0,s.useState)(0),[p,f]=(0,s.useState)({top:0,left:0}),g=(0,s.useRef)(null),x=(0,s.useMemo)(()=>{let e=new Set;for(let t of r)t.source_agent_id===l&&e.add(t.target_agent_id),t.target_agent_id===l&&e.add(t.source_agent_id);return e},[r,l]),{relatedAgents:v,otherAgents:k,allAgents:y}=(0,s.useMemo)(()=>{if(!o)return{relatedAgents:[],otherAgents:[],allAgents:[]};let e=e=>{if(!d)return e.slice(0,20);let t=d.toLowerCase(),s=[],a=[];for(let n of e){let e=n.name.toLowerCase();e.startsWith(t)?s.push(n):e.includes(t)&&a.push(n)}return[...s,...a]},t=[],s=[];for(let e of n)x.has(e.id)?t.push(e):s.push(e);let a=e(t),r=e(s);return{relatedAgents:a,otherAgents:r,allAgents:[...a,...r]}},[o,d,n,x]);(0,s.useEffect)(()=>{h(0)},[y.length,d]),(0,s.useEffect)(()=>{if(null===t)return void c(!1);let s=function(e,t){let s=t-1;for(;s>=0&&t-s<=30;){let a=e.charCodeAt(s);if(64===a)return{start:s,query:e.slice(s+1,t)};if(10===a||13===a)break;s--}return null}(e,t);s?(g.current=s.start,u(s.query),c(!0),a.current&&f(function(e,t){let s=document.createElement("div"),a=window.getComputedStyle(e);for(let t of(s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.visibility="hidden",s.style.overflow="hidden",s.style.width=`${e.offsetWidth}px`,["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","lineHeight","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","boxSizing","whiteSpace","wordWrap","overflowWrap"]))s.style[t]=a.getPropertyValue(t.replace(/([A-Z])/g,"-$1").toLowerCase());s.textContent=e.value.slice(0,t);let n=document.createElement("span");n.textContent="",s.appendChild(n),document.body.appendChild(s);let r=n.offsetTop-e.scrollTop,l=Math.max(0,Math.min(n.offsetLeft,e.offsetWidth-256));return document.body.removeChild(s),{top:r,left:l}}(a.current,s.start))):(c(!1),g.current=null)},[e,t,a]);let j=(0,s.useCallback)(s=>{if(null===t||null===g.current)return;let n=e.slice(0,g.current),r=e.slice(t);i(`${n}@${s.name} ${r}`),c(!1);let l=n.length+1+s.name.length+1;requestAnimationFrame(()=>{let e=a.current;e&&(e.focus(),e.setSelectionRange(l,l))})},[e,t,a,i]),b=(0,s.useCallback)(e=>!!o&&0!==y.length&&!e.nativeEvent.isComposing&&("ArrowDown"===e.key?(e.preventDefault(),h(e=>(e+1)%y.length),!0):"ArrowUp"===e.key?(e.preventDefault(),h(e=>(e-1+y.length)%y.length),!0):"Enter"===e.key?(e.preventDefault(),j(y[m]),!0):"Escape"===e.key&&(e.preventDefault(),c(!1),!0)),[o,y,m,j]);return{isOpen:o,query:d,selectedIndex:m,anchorPos:p,relatedAgents:v,otherAgents:k,allAgents:y,handleMentionKeyDown:b,selectAgent:j}}({input:ed,caretIndex:tl,textareaRef:t1,agents:(0,s.useMemo)(()=>k.filter(e=>e.id!==es),[k,es]),agentLinks:y,currentAgentId:es,onInputChange:eu}),[t5,t3]=(0,s.useState)([]),t4=(0,s.useRef)(!1),t6=(0,s.useRef)(!1);(0,s.useEffect)(()=>{t4.current||(t4.current=!0,(0,b.getAgentSkills)(es,x).then(e=>t3(e.skills)).catch(()=>{}))},[es,x]);let[t8]=(0,s.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(`chat-draft-meta:${es}:${er??"default"}`)??"null");return e?.skill??null}catch{return null}}),t9=function({input:e,caretIndex:t,textareaRef:a,skills:n,onInputChange:r,initialActiveSkill:l}){let[i,o]=(0,s.useState)(!1),[c,d]=(0,s.useState)(""),[u,m]=(0,s.useState)(0),[h,p]=(0,s.useState)({top:0,left:0}),f=(0,s.useRef)(null),g=(0,s.useMemo)(()=>{if(!i)return[];if(!c)return n;let e=c.toLowerCase(),t=[],s=[];for(let a of n){let n=a.name.toLowerCase();n.startsWith(e)?t.push(a):n.includes(e)&&s.push(a)}return[...t,...s]},[i,c,n]);(0,s.useEffect)(()=>{m(0)},[g.length,c]);let[x,v]=(0,s.useState)(l??null);(0,s.useEffect)(()=>{if(x||null===t)return void o(!1);let s=function(e,t){if(!e.startsWith("/")||0===t)return null;let s=t-1;for(;s>=0&&t-s<=30;){let a=e.charCodeAt(s);if(47===a&&0===s)return{start:0,query:e.slice(1,t)};if(10===a||13===a||32===a)break;s--}return null}(e,t);s?(f.current=s.start,d(s.query),o(!0),a.current&&p(function(e,t){let s=document.createElement("div"),a=window.getComputedStyle(e);for(let t of(s.style.position="absolute",s.style.top="-9999px",s.style.left="-9999px",s.style.visibility="hidden",s.style.overflow="hidden",s.style.width=`${e.offsetWidth}px`,["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent","lineHeight","paddingTop","paddingRight","paddingBottom","paddingLeft","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","boxSizing","whiteSpace","wordWrap","overflowWrap"]))s.style[t]=a.getPropertyValue(t.replace(/([A-Z])/g,"-$1").toLowerCase());s.textContent=e.value.slice(0,t);let n=document.createElement("span");n.textContent="",s.appendChild(n),document.body.appendChild(s);let r=n.offsetTop-e.scrollTop,l=Math.max(0,Math.min(n.offsetLeft,e.offsetWidth-280));return document.body.removeChild(s),{top:r,left:l}}(a.current,s.start))):(o(!1),f.current=null)},[e,t,a,x]);let k=(0,s.useCallback)(e=>{v(e),r(""),o(!1),requestAnimationFrame(()=>{let e=a.current;e&&(e.focus(),e.setSelectionRange(0,0))})},[a,r]),y=(0,s.useCallback)(()=>{v(null)},[]),j=(0,s.useCallback)(e=>!!i&&0!==g.length&&!e.nativeEvent.isComposing&&("ArrowDown"===e.key?(e.preventDefault(),m(e=>(e+1)%g.length),!0):"ArrowUp"===e.key?(e.preventDefault(),m(e=>(e-1+g.length)%g.length),!0):"Enter"===e.key||"Tab"===e.key?(e.preventDefault(),k(g[u]),!0):"Escape"===e.key&&(e.preventDefault(),o(!1),!0)),[i,g,u,k]);return{isOpen:i,query:c,selectedIndex:u,anchorPos:h,skills:g,activeSkill:x,handleSlashKeyDown:j,selectSkill:k,clearActiveSkill:y,setActiveSkill:v}}({input:ed,caretIndex:tl,textareaRef:t1,skills:t5,onInputChange:eu,initialActiveSkill:t8});(0,s.useEffect)(()=>{0===t5.length||!t9.activeSkill||t5.some(e=>e.name===t9.activeSkill.name)||t9.setActiveSkill(null)},[t5]),(0,s.useEffect)(()=>{let e=`chat-draft:${es}:${er??"default"}`;ed?localStorage.setItem(e,ed):localStorage.removeItem(e)},[ed,es,er]),(0,s.useEffect)(()=>{if(!t6.current)return;let e=`chat-draft-meta:${es}:${er??"default"}`,t={};t9.activeSkill&&(t.skill={name:t9.activeSkill.name,description:t9.activeSkill.description}),tk&&(t.quote=tk),t.skill||t.quote?localStorage.setItem(e,JSON.stringify(t)):localStorage.removeItem(e)},[t9.activeSkill,tk,es,er]),(0,s.useEffect)(()=>{em||t1.current?.focus()},[em]);let t7=(0,s.useCallback)(()=>{tY.current=!0,setTimeout(()=>{tP.current?.scrollTo({top:tP.current.scrollHeight,behavior:"smooth"})},50)},[]);(0,s.useEffect)(()=>{if(Y)return;tB.current&&clearInterval(tB.current),tB.current=null,tH.current=null;let e=!1;eM(!0),tU.current=!1,ev(null),e_([]),tr([]),tv(new Map),th([]),tf({}),tc([]),tu(!1),tG.current=null,eu(localStorage.getItem(`chat-draft:${es}:${er??"default"}`)??"");let t=localStorage.getItem(`chat-draft-meta:${es}:${er??"default"}`);if(t)try{let e=JSON.parse(t);ty(e.quote??null),t9.setActiveSkill(e.skill?e.skill:null)}catch{ty(null),t9.setActiveSkill(null)}else ty(null),t9.setActiveSkill(null);return t6.current=!0,ec([]),async function(){let t=!1;try{let s=null,a=null;if(er){if(s=er,a=await (0,w.getCacheMeta)(s,x),a?.newestMessageId){let n=await (0,w.getCachedMessages)(s,x);if(e)return;n&&n.length>0&&(t=!0,ec(n),eE(a.hasMore),eM(!1))}}else try{let n=await (0,b.checkFreshness)({agentId:es,channel:V},x);if(e)return;if(s=n.conversation_id,a=await (0,w.getCacheMeta)(s,x),a?.newestMessageId&&a.newestMessageId===n.newest_message_id){let n=await (0,w.getCachedMessages)(s,x);if(e)return;n&&n.length>0&&(t=!0,ec(n),eE(a.hasMore),eM(!1))}}catch{}if(s){let t=await (0,b.conversationInit)(s,x,{newestMessageId:a?.newestMessageId??void 0});if(e)return;if(ei(t.conversation),tu(t.has_more_conversations),!t.cache_valid&&t.messages?(ec(e=>ej(e,t.messages)),tI.current(t.messages,t.has_more_messages).catch(()=>{}),eE(t.has_more_messages)):a&&eE(a.hasMore),tf(t.step_counts),eq(t.artifacts),tr(t.buffered_messages),tN(new Set(t.flagged_message_ids)),t.active_task&&(ev(t.active_task),e_(t.task_messages),t.task_messages.length>0&&(tO.current=Math.max(...t.task_messages.map(e=>e.seq))),tJ.current?.(t.active_task.id,s,tO.current)),ea){let t=await (0,b.getTask)(ea,x).catch(()=>null);if(e)return;if(t&&!["completed","failed","cancelled","superseded"].includes(t.status)){ev(t);let a=await (0,b.getTaskMessages)(ea,x).catch(()=>[]);if(e)return;e_(a),a.length>0&&(tO.current=Math.max(...a.map(e=>e.seq))),tJ.current?.(t.id,s,tO.current)}}}else{let t=await (0,b.chatInit)(es,x,V);if(e)return;ei(t.conversation),ec(e=>e.length>0?ej(e,t.messages):t.messages),eE(t.has_more_messages),eq(t.artifacts),tr(t.buffered_messages),tu(t.has_more_conversations),tI.current(t.messages,t.has_more_messages).catch(()=>{}),(0,b.listFlaggedMessageIds)(x,t.conversation.id).then(t=>{e||tN(new Set(t.message_ids))}).catch(()=>{}),t.active_task&&(ev(t.active_task),t.task_messages.length>0&&(e_(t.task_messages),tO.current=Math.max(...t.task_messages.map(e=>e.seq))),["completed","failed","cancelled","superseded"].includes(t.active_task.status)||tJ.current?.(t.active_task.id,t.conversation.id,tO.current))}}catch{t?T.toast.error("Couldn't refresh conversation"):T.toast.error("Failed to load conversation")}finally{e||eM(!1)}}(),()=>{e=!0}},[es,x,er,ea,V,Y]);let se=(0,s.useRef)(H);(0,s.useEffect)(()=>{se.current=H},[H]);let st=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!el?.id||!x||st.current===el.id)return;st.current=el.id;let e=setTimeout(()=>{(0,b.markInboxRead)(el.id,x).then(()=>se.current()).catch(()=>{})},1e3);return()=>{st.current=null,clearTimeout(e)}},[el?.id,x]),(0,s.useEffect)(()=>{eT||!(eo.length>0)||tU.current||(tU.current=!0,ea||en?tY.current=!1:i?setTimeout(()=>{let e=tP.current?.querySelectorAll("[data-quote-source]");e&&e.length>0?e[e.length-1].scrollIntoView({behavior:"instant",block:"start"}):tP.current?.scrollTo({top:tP.current.scrollHeight})},50):setTimeout(()=>{tP.current?.scrollTo({top:tP.current.scrollHeight})},50))},[eT,eo.length,ea,en,i]),(0,s.useEffect)(()=>{let e;if(!ea||eT||!el)return;tY.current=!1,tX.current=!0;let t=!1,s=()=>{if(t)return!1;let s=document.querySelector(`[data-task-id="${CSS.escape(ea)}"]`);return!!s&&(s.scrollIntoView({behavior:"smooth",block:"start"}),s.classList.add("task-highlight"),e=setTimeout(()=>{s.classList.remove("task-highlight"),t||(tX.current=!1)},1500),!0)},a=setTimeout(async()=>{if(!t&&!s())try{let e=await (0,b.listMessagesAroundTask)(el.id,x,ea);if(t)return;e.length>0?(ec(t=>ej(t,e)),requestAnimationFrame(()=>{setTimeout(()=>{s()||(tX.current=!1)},100)})):tX.current=!1}catch{t||(tX.current=!1)}},100);return()=>{t=!0,clearTimeout(a),e&&clearTimeout(e)}},[ea,eT,el,x]),(0,s.useEffect)(()=>{let e;if(!en||ea||eT||!el)return;tY.current=!1,tX.current=!0;let t=!1,s=setTimeout(()=>{!t&&((()=>{if(t)return!1;let s=document.querySelector(`[data-message-id="${CSS.escape(en)}"]`);return!!s&&(s.scrollIntoView({behavior:"smooth",block:"start"}),s.classList.add("task-highlight"),e=setTimeout(()=>{s.classList.remove("task-highlight"),t||(tX.current=!1)},1500),!0)})()||(tP.current?.scrollTo({top:tP.current.scrollHeight}),tX.current=!1))},100);return()=>{t=!0,clearTimeout(s),e&&clearTimeout(e)}},[en,ea,eT,el]);let ss=ex?.status;(0,s.useEffect)(()=>{tX.current||("running"===ss||"queued"===ss)&&tY.current&&t7()},[ey.length,ss,t7]);let sa=(0,s.useMemo)(()=>k.find(e=>e.id===es)?.name??"Agent",[k,es]),sn=ew(eo),sr=ew(ez),sl=ew(to),si=ew(td),so=ew(sa),sc=ew(V),sd=(0,s.useCallback)(async(e=!1)=>{if(!el||tK.current)return;tK.current=!0;let t=sn.current,s=sr.current,n=si.current,r=so.current,l=sc.current,i=!!er,o=t[0],c=tG.current?.id??el.id,d=s&&o,u=sl.current;if(!i&&!d&&0===u.length&&n){let e=tG.current??{id:el.id,created_at:el.created_at};try{let t=await (0,b.listPreviousConversations)(es,x,{exclude:el.id,before:e.created_at,channel:l});u=t.conversations,tc(t.conversations),tu(t.has_more)}catch{tu(!1)}}let m=!i&&u.length>0;if(!d&&!m){tK.current=!1;return}eF(!0);let h=tP.current;h&&(h.style.overflowAnchor="none");let p=h?.scrollHeight??0;try{let t=[],s=[],m=20,f=!1,g=[],v=!1;if(d){let e=c===el.id?await (0,w.getCachedMessagesBefore)(c,o.created_at,o.id,20,x):null;if(e)t=e.messages,m-=e.messages.length,f=e.hasMore;else{let e=await (0,b.listMessages)(c,x,{limit:20,before:o.created_at,beforeId:o.id});t=e.messages,m-=e.messages.length,f=e.has_more}v=f}if(!i&&!f&&m>0){if(0===u.length&&n){let e=tG.current??{id:el.id,created_at:el.created_at};try{let t=await (0,b.listPreviousConversations)(es,x,{exclude:el.id,before:e.created_at,channel:l});u=t.conversations,tc(t.conversations),tu(t.has_more)}catch{tu(!1)}}let e=0,t=0;for(;e<u.length&&m>0&&t<5;){let a=u[e];e++,t++;let n=await (0,b.listMessages)(a.id,x,{limit:m});if(0===n.messages.length){tG.current=a;continue}let l=tG.current?.created_at??el.created_at;g.push({agentName:r,created_at:l,id:`nap-${a.id}`}),s=[...n.messages,...s],m-=n.messages.length,f=n.has_more,tG.current=a}e>0&&tc(t=>t.slice(e))}let k=[...s,...t];if((0,a.flushSync)(()=>{k.length>0?(g.length>0&&th(e=>{let t=new Set(e.map(e=>e.id)),s=g.filter(e=>!t.has(e.id));return[...e,...s]}),eE(f),ec(e=>{let t=new Set(e.map(e=>e.id));return[...k.filter(e=>!t.has(e.id)),...e]})):eE(!1)}),k.length>0&&el){let e=k.filter(e=>e.conversation_id===el.id);e.length>0&&(0,w.mergeCachedMessages)(el.id,e,v,x).catch(()=>{})}if(tK.current=!1,(0,a.flushSync)(()=>eF(!1)),h)if(e)h.scrollTop=h.scrollHeight;else{let e=h.scrollHeight;h.scrollTop=e-p}}catch{T.toast.error("Failed to load older messages")}finally{tK.current=!1,eF(!1),tP.current&&(tP.current.style.overflowAnchor="")}},[el,x,es,er,sn,sr,si,so,sc,sl]),su=er?ez:ez||to.length>0||td;(0,s.useEffect)(()=>{el?.id!==tQ.current&&(tQ.current=el?.id,tZ.current=0)},[el?.id]),(0,s.useEffect)(()=>{eT||!el||ea||er||eo.length>=10||!su||eR||tZ.current>=3||(tZ.current+=1,sd(!0))},[eT,eo.length,su,eR,el,sd,ea,er]);let sm=(0,s.useCallback)(()=>{let e=tP.current;e&&(tY.current=e.scrollHeight-e.scrollTop-e.clientHeight<100)},[]),sh=(0,s.useCallback)((e,t,s)=>{tB.current&&clearInterval(tB.current),tO.current=s??0,tV.current=0,eA(!1),tH.current=e,tB.current=setInterval(async()=>{if(tH.current===e)try{let[s,a]=await Promise.all([(0,b.getTask)(e,x),(0,b.getTaskMessages)(e,x,tO.current||void 0)]),n=tH.current!==e;if(tV.current=0,eA(!1),a.length>0&&!n&&(e_(e=>{let t=new Set(e.map(e=>e.seq)),s=a.filter(e=>!t.has(e.seq));return s.length>0?[...e,...s]:e}),tO.current=Math.max(...a.map(e=>e.seq),tO.current)),"completed"===s.status||"failed"===s.status||"cancelled"===s.status||"superseded"===s.status){if(n)return void(0,b.listMessages)(t,x).then(({messages:e})=>{ec(t=>ej(t,e)),(0,w.mergeCachedMessages)(t,e,null,x).catch(()=>{})}).catch(()=>{});tB.current&&clearInterval(tB.current),tB.current=null,tW.current&&clearTimeout(tW.current),tW.current=setTimeout(()=>{(0,b.markInboxRead)(t,x).then(()=>se.current()).catch(()=>{})},1e3);let a=!tX.current&&tY.current;try{let[e,a]=await Promise.all([(0,b.listMessages)(t,x),(0,b.listArtifacts)(t,x).catch(()=>null)]);ec(t=>ej(t,e.messages)),(0,w.mergeCachedMessages)(t,e.messages,null,x).catch(()=>{}),a&&eq(a),ev(s)}catch{ev(s),T.toast.error("Failed to refresh messages")}a&&requestAnimationFrame(()=>{tP.current?.scrollTo({top:tP.current.scrollHeight,behavior:"smooth"})}),setTimeout(async()=>{if(!tB.current)try{let[s,a]=await Promise.all([(0,b.getActiveTask)(t,x),(0,b.listBufferedMessages)(t,x)]);if(tr(a),s&&s.id!==e){let{messages:e}=await (0,b.listMessages)(t,x);ec(t=>ej(t,e)),(0,w.mergeCachedMessages)(t,e,null,x).catch(()=>{}),ev(s),e_([]),tJ.current?.(s.id,t)}}catch{}},1e3)}else n||ev(s)}catch{if(tH.current!==e)return;tV.current+=1,tV.current>=3&&eA(!0),tV.current>=10&&(tB.current&&clearInterval(tB.current),tB.current=null,T.toast.error("Lost connection to agent"))}},3e3)},[x]);(0,s.useEffect)(()=>{tJ.current=sh},[sh]),(0,s.useEffect)(()=>()=>{tB.current&&clearInterval(tB.current),tW.current&&clearTimeout(tW.current)},[]);let sp=(0,s.useRef)(null);(0,s.useEffect)(()=>{sp.current=ex?.id??null},[ex]),(0,s.useEffect)(()=>B(e=>{if("task.messages"===e.type&&e.taskId===sp.current){let t=e.messages.filter(e=>e.seq>tO.current);t.length>0&&(e_(e=>{let s=new Set(e.map(e=>e.seq)),a=t.filter(e=>!s.has(e.seq));return a.length>0?[...e,...a]:e}),tO.current=Math.max(...t.map(e=>e.seq),tO.current))}if("task.created"===e.type&&e.conversationId===el?.id){(0,b.listMessages)(e.conversationId,x).then(({messages:t})=>{ec(e=>ej(e,t)),(0,w.mergeCachedMessages)(e.conversationId,t,null,x).catch(()=>{})}).catch(()=>{});let t=e.task;sp.current=t.id,ev(t),e_([]),tO.current=0,tJ.current?.(t.id,e.conversationId)}if("conversation.message"===e.type&&e.conversationId===el?.id&&(ec(t=>ej(t,[e.message])),(0,w.appendCachedMessage)(e.conversationId,e.message,x).catch(()=>{})),"task.updated"===e.type&&e.taskId===sp.current&&ev(t=>t?{...t,status:e.status}:t),"artifact.uploaded"===e.type&&e.conversationId===el?.id&&eq(t=>t.some(t=>t.id===e.artifact.id)?t:[...t,e.artifact]),"followup.dispatched"===e.type&&e.conversationId===el?.id){tr(t=>t.filter(t=>t.id!==e.message.id)),(0,b.listBufferedMessages)(e.conversationId,x).then(tr).catch(()=>{}),(0,b.listMessages)(e.conversationId,x).then(({messages:t})=>{ec(e=>ej(e,t)),(0,w.mergeCachedMessages)(e.conversationId,t,null,x).catch(()=>{})}).catch(()=>{});let t=e.task;sp.current=t.id,ev(t),e_([]),tJ.current?.(t.id,e.conversationId)}"followup.created"===e.type&&e.conversationId===el?.id&&tr(t=>(function(e,t){if(e.some(e=>e.id===t.id))return e;let s=new Date(t.created_at).getTime();return e.some(e=>e.id.startsWith("temp-")&&2e3>Math.abs(new Date(e.created_at).getTime()-s))?e:[...e,t]})(t,e.message)),"followup.deleted"===e.type&&e.conversationId===el?.id&&tr(t=>t.filter(t=>t.id!==e.messageId)),"followup.dispatch_failed"===e.type&&e.conversationId===el?.id&&T.toast.error(e.error||"Failed to dispatch follow-up")}),[B,el?.id,x]);let sf=(0,s.useCallback)(e=>{let t=e.target.files;if(!t)return;let s=[];for(let e of Array.from(t))e.size>0xa00000?T.toast.error(`"${e.name}" exceeds 10 MB limit`):s.push(e);s.length>0&&ta(e=>[...e,...s]),e.target.value=""},[]),sg=(0,s.useCallback)(e=>{ta(t=>t.filter((t,s)=>s!==e))},[]),sx=(0,s.useCallback)(()=>{let e=window.getSelection();if(!e||e.isCollapsed||!e.rangeCount)return void tb(null);let t=e.toString().trim();if(!t)return void tb(null);let s=e.getRangeAt(0),a=s.commonAncestorContainer instanceof HTMLElement?s.commonAncestorContainer:s.commonAncestorContainer.parentElement;if(!a?.closest("[data-quote-source]"))return void tb(null);let n=s.getClientRects(),r=n[n.length-1]||s.getBoundingClientRect();tb({text:t,x:r.right,y:r.top-4})},[]);(0,s.useEffect)(()=>(document.addEventListener("selectionchange",sx),()=>document.removeEventListener("selectionchange",sx)),[sx]);let sv=(0,s.useCallback)(()=>{tj&&(ty(tj.text),tb(null),window.getSelection()?.removeAllRanges(),t1.current?.focus())},[tj]),[sk,sy]=(0,s.useState)(!1),sj=(0,s.useRef)(0),sb=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sj.current++,e.dataTransfer.types.includes("Files")&&sy(!0)},[]),sw=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sj.current--,0===sj.current&&sy(!1)},[]),sN=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),sS=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sy(!1),sj.current=0;let t=Array.from(e.dataTransfer.files),s=[];for(let e of t)e.size>0xa00000?T.toast.error(`"${e.name}" exceeds 10 MB limit`):s.push(e);s.length>0&&ta(e=>[...e,...s])},[]),sC=(0,s.useCallback)(e=>{let t=e.clipboardData?.items;if(!t)return;let s=[];for(let e=0;e<t.length;e++){let a=t[e];if("file"===a.kind){let e=a.getAsFile();e&&s.push(e)}}if(0===s.length)return;e.preventDefault();let a=[];for(let e of s)e.size>0xa00000?T.toast.error(`"${e.name}" exceeds 10 MB limit`):a.push(e);a.length>0&&ta(e=>[...e,...a])},[]),s_=async()=>{if(el&&!ef){eg(!0);try{let e=await (0,b.cancelActiveTask)(el.id,x);if(e){if(sp.current&&sp.current!==e.id)return;tB.current&&clearInterval(tB.current),tB.current=null;let[t,s]=await Promise.all([(0,b.listMessages)(el.id,x),(0,b.listBufferedMessages)(el.id,x)]);ec(e=>ej(e,t.messages)),(0,w.mergeCachedMessages)(el.id,t.messages,null,x).catch(()=>{}),tr(s),ev(e),e_([])}}catch{T.toast.error("Failed to cancel task")}finally{eg(!1)}}},sT=async()=>{let e=ed.trim();if(!e&&0===ts.length||em||!el)return;if(!e)return void T.toast.error("Please type a message");let t=tk?`> ${tk.split("\n").join("\n> ")}
|
|
2
|
-
|
|
3
|
-
${e}`:e;t9.activeSkill&&(t=`/${t9.activeSkill.name} ${t}`);let s=[...ts];if(eu(""),ta([]),ty(null),t9.clearActiveSkill(),ep(!0),ex&&!["completed","failed","cancelled","superseded"].includes(ex.status)){let e=`temp-${Date.now()}`,a={id:e,conversation_id:el.id,role:"user",content:t,task_id:null,attachment_ids:null,status:"buffered",created_at:new Date().toISOString()};tr(e=>[...e,a]);try{let{message:a}=await (0,b.createBufferedMessage)(el.id,t,x,s.length>0?s:void 0);tr(t=>t.some(e=>e.id===a.id)?t.filter(t=>t.id!==e):t.map(t=>t.id===e?a:t))}catch(a){tr(t=>t.filter(t=>t.id!==e)),eu(t),ta(s),T.toast.error(a instanceof Error?a.message:"Failed to queue follow-up")}finally{ep(!1)}return}let a=`temp-${Date.now()}`,n={id:a,conversation_id:el.id,role:"user",content:t,task_id:null,attachment_ids:null,created_at:new Date().toISOString()};s.length>0&&tv(e=>{let t=new Map(e);return t.set(a,s),t}),ec(e=>[...e,n]),t7();try{let{message:e,task:r}=await (0,b.sendMessage)(el.id,t,x,s.length>0?s:void 0);tv(e=>{if(!e.has(a))return e;let t=new Map(e);return t.delete(a),t}),ec(t=>t.map(t=>t.id===n.id?e:t)),e.attachment_ids&&e.attachment_ids.length>0&&(0,b.listArtifacts)(el.id,x).then(e=>eq(e)).catch(()=>{}),ev(r),e_([]),sh(r.id,el.id)}catch(e){tv(e=>{if(!e.has(a))return e;let t=new Map(e);return t.delete(a),t}),ec(e=>e.filter(e=>e.id!==n.id)),eu(t),ta(s),T.toast.error(e instanceof Error?e.message:"Failed to send message")}finally{ep(!1),t1.current?.focus()}},sM=(0,s.useCallback)(async()=>{if(!ex||!el)return;let e=await (0,b.retryTask)(ex.id,x);ev(e),e_([]),sh(e.id,el.id)},[ex,el,x,sh]),sI=(0,s.useCallback)(async e=>{let t=tS.current.has(e);tN(s=>{let a=new Set(s);return t?a.delete(e):a.add(e),a}),t?(t_(),(0,b.unflagMessage)(x,e).then(()=>{tT()}).catch(()=>{tN(t=>new Set(t).add(e)),tC()})):(tC(),(0,b.flagMessage)(x,e).then(()=>{tT()}).catch(()=>{tN(t=>{let s=new Set(t);return s.delete(e),s}),t_()}))},[x,tC,t_,tT]),sA=(0,s.useCallback)(async e=>{e1(e),eQ(!0),e4(!0),e8(null),e7(null);try{let t=await (0,b.getIssue)(x,e);e5(t),t.issue.latest_task_id&&(0,b.getTask)(t.issue.latest_task_id,x).then(e=>e7(e)).catch(()=>e7(null)),t.issue.trace_id&&(0,b.getTrace)(t.issue.trace_id,x).then(e=>e8(e.tasks)).catch(()=>e8(null))}catch(e){T.toast.error(e instanceof Error?e.message:"Failed to load issue"),eQ(!1)}finally{e4(!1)}},[x]),sz=e2?.issue?.conversation_id??null,sE=e2?.issue?.latest_task_id??null;(0,s.useEffect)(()=>{if(eZ&&e0)return B(e=>{if("task.updated"===e.type&&sE&&e.taskId===sE&&(0,b.getTask)(sE,x).then(e=>e7(e)).catch(()=>{}),"conversation.message"===e.type&&sz&&e.conversationId===sz&&(e5(t=>!t||t.messages.some(t=>t.id===e.message.id)?t:{...t,messages:[...t.messages,e.message]}),"event"===e.message.role&&e.message.content.startsWith("Issue status changed:"))){let t=e.message.content.match(/-> (\w+)/);t&&e5(e=>e?{...e,issue:{...e.issue,status:t[1]}}:e)}"issue.comment"===e.type&&e.issueId===e0&&e5(t=>!t||t.comments.some(t=>t.id===e.comment.id)?t:{...t,comments:[...t.comments,e.comment]})})},[eZ,e0,sz,sE,x,B]);let[sR,sF]=(0,s.useState)(!1),sD=(0,s.useMemo)(()=>!!el&&eo.some(e=>e.conversation_id===el.id),[el,eo]),sq=async()=>{if(el&&sD&&!sR){sF(!0);try{tB.current&&(clearInterval(tB.current),tB.current=null);let e=await (0,b.createConversation)(es,x,V);th(t=>[...t,{agentName:sa,created_at:e.created_at,id:`nap-${el.id}`}]),tc(e=>[{id:el.id,created_at:el.created_at},...e]),ei(e),ev(null),e_([]),eq([]),tr([]),ta([]),tv(new Map),tO.current=0,eA(!1),eE(!1),tG.current=null,t7()}catch{T.toast.error("Failed to start new conversation")}finally{sF(!1)}}},sL=!!ex&&!["completed","failed","cancelled","superseded"].includes(ex.status);return eT?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"flex-1 overflow-y-auto px-3 md:px-5",children:(0,t.jsxs)("div",{className:"mx-auto max-w-2xl py-6 space-y-4",children:[(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(M.Skeleton,{className:"h-10 w-48 rounded-lg"})}),(0,t.jsx)("div",{className:"flex justify-start",children:(0,t.jsxs)("div",{className:"space-y-2 px-1 py-1",children:[(0,t.jsx)(M.Skeleton,{className:"h-4 w-72"}),(0,t.jsx)(M.Skeleton,{className:"h-4 w-56"}),(0,t.jsx)(M.Skeleton,{className:"h-4 w-64"})]})}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(M.Skeleton,{className:"h-10 w-36 rounded-lg"})}),(0,t.jsx)("div",{className:"flex justify-start",children:(0,t.jsxs)("div",{className:"space-y-2 px-1 py-1",children:[(0,t.jsx)(M.Skeleton,{className:"h-4 w-64"}),(0,t.jsx)(M.Skeleton,{className:"h-4 w-48"})]})})]})}),(0,t.jsx)("div",{className:"px-3 md:px-5 py-3",children:(0,t.jsx)("div",{className:"mx-auto max-w-2xl",children:(0,t.jsx)(M.Skeleton,{className:"h-18 w-full rounded-xl"})})})]}):eT||el||0!==eo.length?(0,t.jsxs)(t.Fragment,{children:[tj&&(0,t.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:tj.x,top:tj.y,transform:"translate(-100%, -100%)"},onMouseDown:e=>e.preventDefault(),onClick:sv,children:[(0,t.jsx)(q,{className:"size-3"}),"Quote"]}),(0,t.jsxs)("div",{className:"relative flex-1 min-h-0",children:[(0,t.jsx)("div",{className:"h-full overflow-y-auto overflow-x-hidden px-3 md:px-5 thin-scrollbar",ref:tP,onScroll:sm,onClick:e=>{e.target.closest('[data-streamdown="code-block-actions"] button')&&T.toast.success("Copied to clipboard")},children:(0,t.jsxs)("div",{className:"mx-auto max-w-2xl py-6 space-y-4 min-w-0",children:[el&&su&&!eR&&(0,t.jsx)("div",{className:"flex justify-center py-2",children:(0,t.jsx)("button",{onClick:()=>sd(),className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Load earlier messages"})}),eR&&(0,t.jsx)("div",{className:"flex justify-center py-2",children:(0,t.jsx)(p.Loader2,{className:"size-4 animate-spin text-muted-foreground"})}),0===eo.length&&!ex&&(u=k.find(e=>e.id===es),m=u?.created_at&&tg-new Date(u.created_at).getTime()<3e5,h=(z[es]??0)>0,m&&h&&"default"===V?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 gap-3 animate-[fade-up_400ms_ease-out_both]",children:[(0,t.jsxs)("div",{className:"relative animate-bounce",children:[(0,t.jsx)(D.Mail,{className:"size-8 text-primary"}),(0,t.jsxs)("span",{className:"absolute -top-1 -right-1 flex size-3",children:[(0,t.jsx)("span",{className:"animate-ping absolute inline-flex size-full rounded-full bg-primary/60"}),(0,t.jsx)("span",{className:"relative inline-flex size-3 rounded-full bg-primary"})]})]}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center max-w-xs",children:"Your agent is sending you a welcome email."}),(0,t.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,t.jsx)("p",{className:"text-center text-muted-foreground py-20 text-sm",children:"Send a message to start chatting with the agent."})),tq.map(e=>{if("nap"===e.kind)return(0,t.jsx)(eN,{agentName:sa},e.data.id);if("artifact"===e.kind)return(0,t.jsx)(eS,{artifact:e.data,version:tz.get(e.data.id)??1,hasDuplicates:tE.has(e.data.filename),onClick:tL},`artifact-${e.data.id}`);let s=e.data;return(0,t.jsx)(eh,{msg:s,agents:k,artifacts:eD,activeTask:ex,taskMessages:ey,connectionLost:eI,isLastMessage:eo.length>0&&eo[eo.length-1].id===s.id,stepCount:s.task_id?tp[s.task_id]??0:0,targetConvId:er,workspaceId:x,conversationType:el?.type,pendingFilesByMessage:tx,onArtifactClick:tL,onEmailClick:e=>{eK(e),eV(!0)},onCalendarEventClick:e=>{eG(e),eX(!0)},onIssueClick:e=>sA(e),onRetry:sM,mentionComponents:ek,isFlagged:tw.has(s.id),onToggleFlag:"assistant"===s.role?sI:void 0},s.id)}),ex&&ex.conversation_id===el?.id&&!["completed","failed","cancelled","superseded"].includes(ex.status)&&(0,t.jsx)(j,{task:ex,messages:ey,connectionLost:eI})]})}),(0,t.jsx)(et.ScrollToBottomButton,{scrollRef:tP})]}),el&&(0,t.jsx)(ee,{bufferedMessages:tn,onDelete:e=>{tr(t=>t.filter(t=>t.id!==e)),(0,b.deleteBufferedMessage)(el.id,e,x).catch(()=>{tr(tn),T.toast.error("Failed to delete follow-up")})}}),(0,t.jsx)("div",{className:"px-3 md:px-5 py-3",children:(0,t.jsx)("div",{className:"mx-auto max-w-2xl relative",children:(0,t.jsxs)("div",{className:(0,o.cn)("relative flex flex-col rounded-xl border bg-background/60 transition-colors duration-200","focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50",em&&"opacity-50",sk&&"border-ring ring-3 ring-ring/50"),onDragEnter:sb,onDragLeave:sw,onDragOver:sN,onDrop:sS,children:[sk&&(0,t.jsx)("div",{className:"absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/80 border-2 border-dashed border-ring pointer-events-none",children:(0,t.jsx)("p",{className:"text-sm text-muted-foreground font-medium",children:"Drop files here"})}),t9.activeSkill&&(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3.5 pt-2.5 pb-1 border-b border-border/50",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"shrink-0 text-xs font-medium text-primary",children:["/",t9.activeSkill.name]}),t9.activeSkill.isGlobal&&(0,t.jsx)("span",{className:"text-[10px] font-medium text-muted-foreground bg-muted rounded px-1 py-0.5",children:"Global"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground truncate",children:t9.activeSkill.description})]}),(0,t.jsx)("button",{type:"button",onClick:t9.clearActiveSkill,className:"shrink-0 p-0.5 rounded-sm hover:bg-muted-foreground/20 transition-colors text-muted-foreground",children:(0,t.jsx)(P.X,{className:"size-3.5"})})]}),tk&&(0,t.jsxs)("div",{className:"flex items-center gap-2 px-3.5 pt-2.5 pb-1 border-b border-border/50",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex items-start gap-2",children:[(0,t.jsx)(q,{className:"size-3.5 shrink-0 mt-0.5 text-muted-foreground"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:[tk.slice(0,120),tk.length>120?"...":""]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>ty(null),className:"shrink-0 p-0.5 rounded-sm hover:bg-muted-foreground/20 transition-colors text-muted-foreground",children:(0,t.jsx)(P.X,{className:"size-3.5"})})]}),(0,t.jsx)(W,{isOpen:t2.isOpen,relatedAgents:t2.relatedAgents,otherAgents:t2.otherAgents,selectedIndex:t2.selectedIndex,onSelect:t2.selectAgent,anchorPos:t2.anchorPos}),(0,t.jsx)(O,{isOpen:t9.isOpen,skills:t9.skills,selectedIndex:t9.selectedIndex,onSelect:t9.selectSkill,anchorPos:t9.anchorPos}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{"aria-hidden":!0,className:"mention-backdrop absolute inset-0 px-3.5 py-2.5 text-base chat-input-line-height whitespace-pre-wrap wrap-break-word pointer-events-none overflow-y-auto thin-scrollbar",dangerouslySetInnerHTML:{__html:ed?U(ed.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),k).replace(/<mention[^>]*>/g,'<span class="mention-highlight">').replace(/<\/mention>/g,"</span>")+(ed.endsWith("\n")?"\n":""):""}}),(0,t.jsx)("textarea",{ref:t1,value:ed,enterKeyHint:"send",onChange:e=>{eu(e.target.value),ti(e.target.selectionStart),requestAnimationFrame(()=>{let t=e.target.previousElementSibling;t&&(t.scrollTop=e.target.scrollTop)})},onKeyDown:e=>{t2.handleMentionKeyDown(e)||!t9.handleSlashKeyDown(e)&&("Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),sT()))},onPaste:sC,onKeyUp:e=>ti(e.target.selectionStart),onClick:e=>ti(e.target.selectionStart),onSelect:e=>ti(e.target.selectionStart),onScroll:e=>{let t=e.target.previousElementSibling;t&&(t.scrollTop=e.target.scrollTop)},placeholder:sL?"Type a follow-up...":"Type a message or / for skills...",rows:1,disabled:em,className:(0,o.cn)("relative field-sizing-content w-full resize-none bg-transparent px-3.5 py-2.5 text-base chat-input-line-height outline-none","placeholder:text-muted-foreground disabled:cursor-not-allowed","min-h-9.5 max-h-50 thin-scrollbar","caret-foreground textarea-text-hidden")})]}),ts.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 px-3.5 pb-1",children:ts.map((e,s)=>(0,t.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,t.jsx)(F.FileText,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-30",children:e.name}),(0,t.jsx)("span",{className:"text-muted-foreground/60",children:(0,K.formatSize)(e.size)}),(0,t.jsx)("button",{type:"button",onClick:()=>sg(s),className:"ml-0.5 rounded-sm p-0.5 hover:bg-muted-foreground/20 transition-colors",children:(0,t.jsx)(P.X,{className:"size-3"})})]},`${e.name}-${s}`))}),(0,t.jsxs)("div",{className:"flex items-center justify-between px-2 pb-2 pt-0.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[!er&&(0,t.jsxs)(I.Tooltip,{children:[(0,t.jsx)(I.TooltipTrigger,{render:e=>(0,t.jsx)("span",{...e,className:(0,o.cn)("inline-flex",e.className),children:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onClick:sq,disabled:sR||!el||!sD||sL,className:"rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200",children:sR?(0,t.jsx)(p.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(E,{className:"size-3.5"})})})}),(0,t.jsx)(I.TooltipContent,{side:"top",children:sL?"Wait for the task to finish":sD?"Take a nap":`${sa} is well-rested and ready to go`})]}),(0,t.jsxs)(I.Tooltip,{children:[(0,t.jsxs)(I.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onClick:()=>{eH("agent"),e$(!0)},className:"relative rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200"}),children:[(0,t.jsx)(R,{className:"size-3.5"}),tA.length>0&&(0,t.jsx)("span",{className:"absolute -top-0.5 -right-0.5 flex size-3.5 items-center justify-center rounded-full bg-primary text-[9px] font-medium text-primary-foreground",children:tA.length})]}),(0,t.jsx)(I.TooltipContent,{side:"top",children:"Artifacts"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("input",{ref:t0,type:"file",multiple:!0,className:"hidden",onChange:sf}),(0,t.jsxs)(I.Tooltip,{children:[(0,t.jsx)(I.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onPointerDown:e=>e.preventDefault(),onClick:()=>t0.current?.click(),disabled:em,className:"rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200"}),children:(0,t.jsx)(L.Paperclip,{className:"size-3.5"})}),(0,t.jsx)(I.TooltipContent,{side:"top",children:"Attach files"})]}),!sL||ed.trim()||em?(0,t.jsxs)(I.Tooltip,{children:[(0,t.jsx)(I.TooltipTrigger,{render:(0,t.jsx)(l.Button,{size:"icon-sm",onClick:sT,disabled:!ed.trim()||em,className:(0,o.cn)("rounded-lg transition-opacity duration-200",!ed.trim()&&"opacity-40")}),children:em?(0,t.jsx)(p.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(A.ArrowUp,{className:"size-3.5"})}),(0,t.jsx)(I.TooltipContent,{side:"top",children:"Send"})]}):(0,t.jsxs)(I.Tooltip,{children:[(0,t.jsx)(I.TooltipTrigger,{render:(0,t.jsx)(l.Button,{size:"icon-sm",onClick:s_,disabled:ef,className:"rounded-lg bg-red-500/10 text-red-500 hover:bg-red-500/20 transition-colors duration-200"}),children:ef?(0,t.jsx)(p.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)($.Square,{className:"size-3.5 fill-current"})}),(0,t.jsx)(I.TooltipContent,{side:"top",children:"Stop task"})]})]})]})]})})}),(0,t.jsx)(K.ArtifactSheet,{open:eL,onOpenChange:e=>{e$(e),e||setTimeout(()=>{eB(null),eH(null)},300)},artifacts:tR,workspaceId:x,initialArtifact:eP,versionMap:tF,duplicateFilenames:tD}),(0,t.jsx)(J,{open:eO,onOpenChange:e=>{eV(e),e||setTimeout(()=>eK(null),300)},emailId:eU,workspaceId:x}),(0,t.jsx)(G.CalendarEventSheet,{readonly:!0,open:eY,onOpenChange:e=>{eX(e),e||setTimeout(()=>eG(null),300)},calendarEventId:eJ,workspaceId:x}),(0,t.jsx)(Z.IssueSheet,{open:eZ,onOpenChange:e=>{eQ(e),e||setTimeout(()=>{e1(null),e5(null),e7(null)},300)},agents:k,issue:e2?.issue??null,detail:e2?{messages:e2.messages,comments:e2.comments,artifacts:e2.artifacts,traceId:e2.issue.trace_id}:null,detailLoading:e3,activeTask:e9,traceTasks:e6,slug:v,workspaceId:x,width:te,onWidthChange:tt,onUpdate:async(e,t)=>{try{let s=await (0,b.updateIssue)(x,e,t);e5(a=>a&&a.issue.id===e?{...a,issue:{...a.issue,...t,updated_at:s.updated_at}}:a)}catch(e){T.toast.error(e instanceof Error?e.message:"Failed to update issue")}},onStatusChange:async(e,t)=>{try{await (0,b.updateIssue)(x,e,{status:t}),e5(s=>s&&s.issue.id===e?{...s,issue:{...s.issue,status:t}}:s)}catch(e){T.toast.error(e instanceof Error?e.message:"Failed to update status")}},onCommented:()=>{e0&&sA(e0)},onArtifactClick:t$})]}):(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Failed to load conversation"})}}]);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|