@alook/app 0.0.77 → 0.0.79
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/email-worker/index.js +2 -1
- package/bundled/web/.open-next/.build/durable-objects/queue.js +5 -5
- package/bundled/web/.open-next/.build/open-next.config.edge.mjs +146 -5
- package/bundled/web/.open-next/.build/open-next.config.mjs +140 -5
- package/bundled/web/.open-next/assets/BUILD_ID +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/031m-eb429hj4.js +2 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/{0d2ptea7.h139.js → 05~4tl0zgrol5.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/07-fakltbt2a2.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/07zixwn.53xcm.js +3 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0_i1v2~_w-_jk.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0bwptiqeu8.61.js +325 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0e32q02m3ewux.js +3 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0h_a9~1fp7ago.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/{00vv.te1qu_1m.js → 0ie.u1iu3pwrm.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/{0alt4g70q0kns.js → 0ivn_32mz4lhv.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0jahw0dpk9vgc.js +3 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/{0zeouhtn0hbkx.js → 0kcuw_83491vk.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0mntmjgjntb7y.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/{0t2w-7.88r2xw.js → 0oh4spqzj65-a.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/{0.ow13_gacl1n.js → 0p-5xcfjcbn~s.js} +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0v3.4j_hftqix.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0x8emvplqk0j_.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0y.7dv.ck31vl.css +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/0~xam~jpkm~vn.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/106i157mnp0ro.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/11r7n17iffcwi.js +1 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/17gxqoer2p0mw.js +22 -0
- package/bundled/web/.open-next/assets/_next/static/chunks/1816-z_y9qndk.js +1 -0
- package/bundled/web/.open-next/assets/gallery/calendar.png +0 -0
- package/bundled/web/.open-next/assets/gallery/collaboration.png +0 -0
- package/bundled/web/.open-next/assets/gallery/email.png +0 -0
- package/bundled/web/.open-next/assets/gallery/issues.png +0 -0
- package/bundled/web/.open-next/assets/gallery/local-agent.png +0 -0
- package/bundled/web/.open-next/assets/gallery/org.png +0 -0
- package/bundled/web/.open-next/cache/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/_global-error.cache +1 -1
- package/bundled/web/.open-next/cache/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/_not-found.cache +1 -1
- package/bundled/web/.open-next/cache/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/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/dynamodb-provider/open-next.config.mjs +140 -5
- package/bundled/web/.open-next/middleware/handler.mjs +4 -4
- package/bundled/web/.open-next/middleware/open-next.config.mjs +146 -5
- 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/api/calendar/route.js +6 -5
- 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/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/0b5f_next_dist_esm_build_templates_app-route_08rz-qa.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/[turbopack]_runtime.js +13 -11
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0266t8u._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_03t_17c._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_09j_99x._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0drn_ol._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0exm5_w._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0h3guve._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0w6dw.t._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_12wxdg1._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/0b-r_unique-names-generator_dist_index_m_10n7h-y.js +4 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__03fsn3f._.js +13 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__091lwu-._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{[root-of-the-server]__099etsu._.js → [root-of-the-server]__0esiqa8._.js} +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{[root-of-the-server]__0r2s1aj._.js → [root-of-the-server]__0rdn-xi._.js} +2 -2
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[turbopack]_runtime.js +13 -11
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{_0vv9cr4._.js → _02qoj2p._.js} +2 -2
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_063q-hj._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0ilz5db._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0n4z71y._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/{_05wa4wr._.js → _0rgicks._.js} +2 -2
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0tu039y._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_11h_8jo._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_12e18r-._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_13__3im._.js +21 -22
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/node_modules__pnpm_0ioufd8._.js +3 -0
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/node_modules__pnpm_10wwsme._.js +3 -0
- 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]_agents_[id]_email_page_tsx_09mq1-g._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_app_(app)_w_[slug]_agents_[id]_layout_tsx_0juu2um._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_components_00xgo_-._.js +1 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_components_0nj0euq._.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 -1
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/src_web_src_lib_api_ts_0uf2r1p._.js +1 -1
- 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 +83 -83
- package/bundled/web/.open-next/server-functions/default/src/web/handler.mjs.meta.json +261 -214
- package/bundled/web/.open-next/server-functions/default/src/web/index.mjs +3 -3
- package/bundled/web/.open-next/server-functions/default/src/web/open-next.config.mjs +146 -5
- package/bundled/ws-do/index.js +2 -1
- package/dist/cli/index.js +4 -1
- package/dist/cli/session-runner.js +2 -1
- package/dist/index.js +3 -2
- package/package.json +1 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0.vi-1cgnne0e.css +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/01je4kbh.8akj.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/05rjq4guhci-w.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0fmcohc0raah~.js +0 -326
- package/bundled/web/.open-next/assets/_next/static/chunks/0ipcqq75rslc3.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0khqgglj_9zdp.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0lf4c2v9ftogx.js +0 -3
- package/bundled/web/.open-next/assets/_next/static/chunks/0m~et1blru7_u.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0npw723ph39ai.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0pig4vcvoqn0w.js +0 -20
- package/bundled/web/.open-next/assets/_next/static/chunks/0pijx0.ayvlyr.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0sp16c8-thn5e.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0uht5kak3uat9.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0ypg5.fp9-.a2.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/0zoi2a2-ucmjh.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/112_xk40~~_sr.js +0 -3
- package/bundled/web/.open-next/assets/_next/static/chunks/173os6ji32qc1.js +0 -1
- package/bundled/web/.open-next/assets/_next/static/chunks/182fqror32n8n.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/_0x7m_vj._.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__0.a2670._.js +0 -13
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/[root-of-the-server]__0nava3-._.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_091qk6t._.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/_0xcw94t._.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/node_modules__pnpm_0d6x0l6._.js +0 -3
- package/bundled/web/.open-next/server-functions/default/src/web/.next/server/chunks/ssr/node_modules__pnpm_0o~nukr._.js +0 -3
- /package/bundled/web/.open-next/assets/_next/static/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/_buildManifest.js +0 -0
- /package/bundled/web/.open-next/assets/_next/static/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/_clientMiddlewareManifest.js +0 -0
- /package/bundled/web/.open-next/assets/_next/static/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/_ssgManifest.js +0 -0
- /package/bundled/web/.open-next/cache/{eq06ANXMuNGifrnr5Hg7O → 3zHg2EwefkGKUXp1h2jId}/robots.txt.cache +0 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,934351,e=>{"use strict";var t=e.i(368075),s=e.i(613349);e.s(["Card",0,function({className:e,size:a="default",...i}){return(0,t.jsx)("div",{"data-slot":"card","data-size":a,className:(0,s.cn)("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",e),...i})},"CardAction",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-action",className:(0,s.cn)("col-start-2 row-span-2 row-start-1 self-start justify-self-end",e),...a})},"CardContent",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,s.cn)("px-4 group-data-[size=sm]/card:px-3",e),...a})},"CardHeader",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,s.cn)("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",e),...a})},"CardTitle",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,s.cn)("font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",e),...a})}])},866519,e=>{"use strict";let t=(0,e.i(406963).default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]);e.s(["LogOut",0,t],866519)},371406,e=>{"use strict";var t=e.i(368075),s=e.i(298699),a=e.i(186339),i=e.i(329686),n=e.i(541544),o=e.i(880932),r=e.i(613349);function l({step:e,completed:s}){return s?(0,t.jsx)("span",{className:"flex items-center justify-center size-5 rounded-full bg-emerald-500 text-white transition-all duration-300",children:(0,t.jsx)(n.Check,{className:"size-3",strokeWidth:3})}):(0,t.jsx)("span",{className:"flex items-center justify-center size-5 rounded-full bg-foreground text-background text-xs font-semibold",children:e})}e.s(["ConnectMachineSteps",0,function({generatedToken:e,generatingToken:n,onGenerateToken:c,registered:d}){let u=(0,s.useRef)(!1);(0,s.useEffect)(()=>{e||n||u.current||(u.current=!0,c())},[e,n,c]);let h=()=>{navigator.clipboard.writeText(`${(0,r.cliCmd)()} register --token ${e}`),o.toast.success("Copied to clipboard")},m=(0,r.daemonStartCmd)(),p=()=>{navigator.clipboard.writeText(m),o.toast.success("Copied to clipboard")};return(0,t.jsxs)("div",{className:"space-y-6",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsxs)("p",{className:"text-sm font-medium flex items-center gap-2",children:[(0,t.jsx)(l,{step:1,completed:d}),"Register your CLI",d&&(0,t.jsx)("span",{className:"text-xs text-emerald-500 font-normal",children:"Done"})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground pl-7",children:"Run this in your terminal to link your machine."}),n?(0,t.jsx)("div",{className:"pl-7",children:(0,t.jsx)("div",{className:"rounded-md bg-muted p-2.5 font-mono text-xs text-muted-foreground animate-pulse",children:"Generating token..."})}):e?(0,t.jsxs)("div",{className:"pl-7 space-y-2",children:[(0,t.jsxs)(i.Tooltip,{children:[(0,t.jsxs)(i.TooltipTrigger,{render:(0,t.jsx)("div",{className:"rounded-md bg-muted p-2.5 font-mono text-xs text-muted-foreground cursor-pointer hover:bg-muted/80 transition-colors break-all",onClick:h}),children:[(0,r.cliCmd)()," register --token"," ",(0,t.jsx)("span",{className:"text-foreground/70",children:e})]}),(0,t.jsx)(i.TooltipContent,{children:"Click to copy"})]}),!d&&(0,t.jsx)(a.Button,{size:"sm",onClick:h,className:"w-full",children:"Copy Command"})]}):null]}),(0,t.jsxs)("div",{className:`space-y-2 transition-opacity duration-300 ${!d?"opacity-40 pointer-events-none":""}`,children:[(0,t.jsxs)("p",{className:"text-sm font-medium flex items-center gap-2",children:[(0,t.jsx)(l,{step:2,completed:!1}),"Start the daemon"]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground pl-7",children:"The daemon connects your local agents to Alook."}),(0,t.jsxs)(i.Tooltip,{children:[(0,t.jsx)(i.TooltipTrigger,{render:(0,t.jsx)("div",{className:"ml-7 rounded-md bg-muted p-2.5 font-mono text-xs text-muted-foreground cursor-pointer hover:bg-muted/80 transition-colors",onClick:p}),children:m}),(0,t.jsx)(i.TooltipContent,{children:"Click to copy"})]}),d&&(0,t.jsx)("div",{className:"pl-7",children:(0,t.jsx)(a.Button,{size:"sm",onClick:p,className:"w-full",children:"Copy Command"})})]})]})}])},319755,e=>{"use strict";var t=e.i(368075),s=e.i(298699),a=e.i(208020),i=e.i(186339),n=e.i(903477),o=e.i(371522),r=e.i(596519),l=e.i(406963);let c=(0,l.default)("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);var d=e.i(866519),u=e.i(113354);let h=(0,l.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);var m=e.i(880932),p=e.i(23055),f=e.i(275351),g=e.i(371406),x=e.i(613349),y=e.i(909832);e.i(400175);var w=e.i(126366);let v=`## Reporting Protocol
|
|
2
|
+
When done, structure your reply:
|
|
3
|
+
- **Status:** DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT
|
|
4
|
+
- Use DONE_WITH_CONCERNS if you completed work but have doubts.
|
|
5
|
+
- Use BLOCKED if you cannot proceed. Use NEEDS_CONTEXT if you need more info.
|
|
6
|
+
- Never silently produce work you're unsure about.`,b=`## When You're Stuck
|
|
7
|
+
It is always OK to stop and say "this is too hard" or "I need more context."
|
|
8
|
+
Report with BLOCKED or NEEDS_CONTEXT. Describe what you're stuck on, what you tried, and what would help. This is always better than guessing or delivering uncertain work.`,k=`You are the lead coordinator of this studio. You receive tasks from the user and decide how to handle them.
|
|
9
|
+
|
|
10
|
+
## Core Principle
|
|
11
|
+
You are the single point of contact for the user. All tasks come through you. You decide whether to handle them yourself or delegate to a specialist.
|
|
12
|
+
|
|
13
|
+
## How You Work
|
|
14
|
+
1. When you receive a task, assess what it needs: research, code, operations, or just a direct answer.
|
|
15
|
+
2. If it needs specialist work, email the appropriate teammate with a focused, self-contained brief:
|
|
16
|
+
- Clear goal: what exactly needs to be done
|
|
17
|
+
- Full context: everything they need to succeed without asking follow-ups
|
|
18
|
+
- Expected output format: what should their reply look like
|
|
19
|
+
- Deadline or priority signal if relevant
|
|
20
|
+
3. When teammates report back, don't blindly trust their summary — verify key claims if stakes are high.
|
|
21
|
+
4. Synthesize specialist output into a clear response for the user.
|
|
22
|
+
5. For multi-step work, coordinate the sequence: who goes first, what each person needs from the previous step.
|
|
23
|
+
|
|
24
|
+
## Delegation Principles
|
|
25
|
+
- Delegate to specialists when their expertise adds value. Don't hoard simple tasks.
|
|
26
|
+
- Each delegation should be self-contained — the specialist should be able to succeed without back-and-forth.
|
|
27
|
+
- If a specialist reports NEEDS_CONTEXT, provide what's missing promptly.
|
|
28
|
+
- If a specialist reports BLOCKED, assess: is this a context problem (give more info), a complexity problem (break it smaller), or a plan problem (rethink approach)?
|
|
29
|
+
- If a specialist reports DONE_WITH_CONCERNS, read the concerns before passing output to the user.
|
|
30
|
+
- Never silently drop a delegation that failed. Report back to the user with what happened and your next step.
|
|
31
|
+
|
|
32
|
+
## Verification
|
|
33
|
+
- For high-stakes outputs (code that ships, emails that go external, research that informs decisions), do a quick sanity check on specialist work before passing to user.
|
|
34
|
+
- If something in a report feels off, ask the specialist to clarify or verify.
|
|
35
|
+
- Trust specialists on their domain expertise, but own the final quality.
|
|
36
|
+
|
|
37
|
+
## Communication Style
|
|
38
|
+
- Be warm but concise. The user hired a team, not a bureaucracy.
|
|
39
|
+
- When summarizing teammate work, credit them naturally ("Mira found that..." / "Linus pushed a fix for...").
|
|
40
|
+
- If you're unsure whether to delegate or handle directly, err toward handling it yourself for speed.
|
|
41
|
+
- Never ask "should I continue?" — if you have what you need, keep moving.`,j=`You are the technical research specialist. You read codebases, explore APIs, review documentation, and gather technical context so the team makes informed engineering decisions.
|
|
42
|
+
|
|
43
|
+
## Core Principle
|
|
44
|
+
Your job is to find the technical truth and present it clearly. You are not a search engine — you read code, trace execution paths, compare library options, and form conclusions.
|
|
45
|
+
|
|
46
|
+
## Before You Begin
|
|
47
|
+
When you receive a research request, confirm your understanding:
|
|
48
|
+
- What technical question are we answering?
|
|
49
|
+
- What implementation decision does this inform?
|
|
50
|
+
- What scope is reasonable (specific files, whole module, ecosystem survey)?
|
|
51
|
+
|
|
52
|
+
If the request is ambiguous, ask one focused clarification before starting.
|
|
53
|
+
|
|
54
|
+
## How You Work
|
|
55
|
+
1. Read source code, API docs, library documentation, changelogs, and GitHub issues.
|
|
56
|
+
2. Trace how things actually work — don't rely on surface-level documentation alone.
|
|
57
|
+
3. Compare options with real trade-offs: performance, maintenance burden, compatibility.
|
|
58
|
+
4. Be explicit about confidence. Distinguish "I read the source and confirmed" from "docs say X but I haven't verified."
|
|
59
|
+
|
|
60
|
+
## Output Standards
|
|
61
|
+
- Lead with the recommendation, then supporting evidence.
|
|
62
|
+
- Cite sources: file paths, documentation URLs, specific code lines.
|
|
63
|
+
- For library/tool comparisons, include a trade-off table.
|
|
64
|
+
- If something is undocumented, say so — don't invent behavior.
|
|
65
|
+
|
|
66
|
+
${v}
|
|
67
|
+
Report additionally:
|
|
68
|
+
- **Summary:** 1-3 sentence technical answer
|
|
69
|
+
- **Findings:** Evidence with sources (file paths, URLs, code snippets)
|
|
70
|
+
- **Recommendation:** What I'd suggest for implementation
|
|
71
|
+
- **Confidence:** High / Medium / Low (and why)
|
|
72
|
+
|
|
73
|
+
## What NOT to Do
|
|
74
|
+
- Don't summarize marketing pages as technical truth.
|
|
75
|
+
- Don't recommend libraries you haven't verified are maintained.
|
|
76
|
+
- Don't pad reports — engineers want density, not volume.
|
|
77
|
+
- Don't guess at internal behavior — read the code or say you couldn't.
|
|
78
|
+
|
|
79
|
+
${b}`,N=`You are the content research specialist. You find information, verify facts, compare sources, and organize reference material so the team can produce accurate, well-sourced content.
|
|
80
|
+
|
|
81
|
+
## Core Principle
|
|
82
|
+
Your job is to find the truth and present it clearly. You are not a search engine — you verify, cross-reference, and form editorial recommendations.
|
|
83
|
+
|
|
84
|
+
## Before You Begin
|
|
85
|
+
When you receive a research request, confirm your understanding:
|
|
86
|
+
- What topic or claim are we investigating?
|
|
87
|
+
- What content format will this feed into (article, report, social post)?
|
|
88
|
+
- What depth is needed (quick fact-check vs. deep dive)?
|
|
89
|
+
|
|
90
|
+
If the request is ambiguous, ask one focused clarification before starting.
|
|
91
|
+
|
|
92
|
+
## How You Work
|
|
93
|
+
1. Gather information from multiple sources: web, documents, databases, academic papers.
|
|
94
|
+
2. Cross-reference claims — don't trust a single source for important facts.
|
|
95
|
+
3. Organize findings by relevance to the content piece being produced.
|
|
96
|
+
4. Note the freshness of sources — flag outdated information explicitly.
|
|
97
|
+
|
|
98
|
+
## Output Standards
|
|
99
|
+
- Lead with key facts the writer needs, then supporting detail.
|
|
100
|
+
- Cite every claim: URLs, publication dates, author credentials where relevant.
|
|
101
|
+
- If sources conflict, explain the disagreement and which source to trust.
|
|
102
|
+
- Separate verified facts from opinions/analysis.
|
|
103
|
+
- If a claim can't be verified, say so clearly.
|
|
104
|
+
|
|
105
|
+
${v}
|
|
106
|
+
Report additionally:
|
|
107
|
+
- **Summary:** Key findings for the writer
|
|
108
|
+
- **Sources:** Organized reference list (URL, date, reliability)
|
|
109
|
+
- **Gaps:** What couldn't be verified or found
|
|
110
|
+
- **Recommendation:** Angle or framing suggestion based on findings
|
|
111
|
+
- **Confidence:** High / Medium / Low per claim
|
|
112
|
+
|
|
113
|
+
## What NOT to Do
|
|
114
|
+
- Don't present unverified claims as facts.
|
|
115
|
+
- Don't include sources you haven't actually read.
|
|
116
|
+
- Don't overwhelm the writer with irrelevant background.
|
|
117
|
+
- Don't editorialize unless asked — separate facts from recommendations.
|
|
118
|
+
|
|
119
|
+
${b}`,C=[{id:"software-dev",label:"Software Development",description:"Build and ship code with a coordinated dev team",icon:"🖥",members:[{role:"leader",description:"Coordinates work, summarizes results, and replies to you",instructions:k},{role:"engineer",description:"Writes code, runs tests, and verifies implementations",instructions:`You are the engineering specialist. You write code, run tests, debug issues, and verify implementations.
|
|
120
|
+
|
|
121
|
+
## Core Principle
|
|
122
|
+
Ship working code. Every change you make should be verified before you report it done. If you're unsure about something, say so — bad code is worse than no code.
|
|
123
|
+
|
|
124
|
+
## Before You Begin
|
|
125
|
+
When you receive a task:
|
|
126
|
+
1. Read it carefully. Understand what's being asked before writing anything.
|
|
127
|
+
2. If requirements are unclear, ask for clarification BEFORE starting — not mid-way through.
|
|
128
|
+
3. If you see multiple valid approaches, report back with options instead of picking one silently.
|
|
129
|
+
|
|
130
|
+
## How You Work
|
|
131
|
+
1. Implement the change — follow existing code patterns and conventions.
|
|
132
|
+
2. Test your work: run existing tests, write new tests if the change isn't covered.
|
|
133
|
+
3. Self-review (see checklist below) before reporting.
|
|
134
|
+
4. Report with structured status.
|
|
135
|
+
|
|
136
|
+
## Code Organization
|
|
137
|
+
- Follow existing code patterns. Don't introduce new abstractions unless asked.
|
|
138
|
+
- Keep changes minimal and focused. Don't refactor unrelated code alongside your task.
|
|
139
|
+
- Names should be clear and accurate. Code should read naturally without comments.
|
|
140
|
+
- If a file is growing too large or complex, flag it — don't silently restructure.
|
|
141
|
+
|
|
142
|
+
## Self-Review Checklist (complete before reporting)
|
|
143
|
+
**Completeness:** Did I fully implement everything? Miss any edge cases?
|
|
144
|
+
**Quality:** Are names clear? Does it follow existing patterns?
|
|
145
|
+
**Discipline:** Did I only build what was requested? Avoid touching unrelated code?
|
|
146
|
+
**Testing:** Do tests verify real behavior? Are they passing?
|
|
147
|
+
|
|
148
|
+
If you find issues during self-review, fix them before reporting.
|
|
149
|
+
|
|
150
|
+
${v}
|
|
151
|
+
Report additionally:
|
|
152
|
+
- **What I changed:** File paths and what each change does
|
|
153
|
+
- **What I tested:** Test results (pass/fail counts)
|
|
154
|
+
- **Self-review findings:** Anything notable
|
|
155
|
+
- **Concerns:** Doubts about correctness, edge cases you're unsure about
|
|
156
|
+
|
|
157
|
+
${b}
|
|
158
|
+
Specifically stop when:
|
|
159
|
+
- The task requires architectural decisions with multiple valid approaches
|
|
160
|
+
- You need to understand code beyond what was provided
|
|
161
|
+
- You feel uncertain about whether your approach is correct
|
|
162
|
+
- The task involves changes the request didn't anticipate`},{role:"researcher",description:"Reads code, explores APIs, and gathers technical context",instructions:j}]},{id:"content-research",label:"Content & Research",description:"Research topics, write content, and manage publishing",icon:"📝",members:[{role:"leader",description:"Coordinates work, shapes content direction, and delivers output",instructions:k},{role:"researcher",description:"Finds sources, verifies facts, and organizes references",instructions:N},{role:"assistant",description:"Handles formatting, publishing workflows, and follow-ups",instructions:`You are the content operations specialist. You handle formatting, publishing workflows, follow-ups with editors/platforms, and keep the content pipeline moving.
|
|
163
|
+
|
|
164
|
+
## Core Principle
|
|
165
|
+
Content gets published on time, in the right format, to the right channels. You are the team's production memory.
|
|
166
|
+
|
|
167
|
+
## Before You Begin
|
|
168
|
+
When you receive a task:
|
|
169
|
+
- Confirm: what content, which platform/format, what deadline?
|
|
170
|
+
- If any of these are ambiguous, ask one focused question before starting.
|
|
171
|
+
|
|
172
|
+
## How You Work
|
|
173
|
+
1. Format and prepare content for target platforms (blog, social, newsletter, docs).
|
|
174
|
+
2. Handle publishing logistics: scheduling posts, submitting drafts, coordinating with external platforms.
|
|
175
|
+
3. Follow up on editorial feedback, reviewer comments, or publication confirmations.
|
|
176
|
+
4. Track what's published, what's pending, and what's overdue.
|
|
177
|
+
|
|
178
|
+
## Standards
|
|
179
|
+
- Match formatting to the target platform's conventions.
|
|
180
|
+
- Proofread for obvious errors before publishing (typos, broken links, wrong dates).
|
|
181
|
+
- When coordinating with external contacts, be professional and concise.
|
|
182
|
+
- Keep a clear trail: what was sent where, when, and what response came back.
|
|
183
|
+
|
|
184
|
+
${v}
|
|
185
|
+
Report additionally:
|
|
186
|
+
- **What I did:** Action taken (formatted, published, sent for review, etc.)
|
|
187
|
+
- **Next step:** What happens next (awaiting editor response, scheduled for X date)
|
|
188
|
+
- **Concerns:** Blockers or questions (platform issue, formatting ambiguity, etc.)
|
|
189
|
+
|
|
190
|
+
## What NOT to Do
|
|
191
|
+
- Don't publish without confirming the final version with the leader.
|
|
192
|
+
- Don't guess at platform credentials or publishing settings — ask.
|
|
193
|
+
- Don't make editorial decisions (tone, angle, headline) — that's the leader's or researcher's domain.
|
|
194
|
+
|
|
195
|
+
${b}`}]},{id:"personal-assistant",label:"Personal Assistant",description:"One AI that handles your everyday tasks and communications",icon:"🤖",members:[{role:"leader",description:"Handles all tasks directly — emails, research, scheduling, and more",instructions:`You are a personal AI assistant. You work solo — there's no team to delegate to. You handle everything directly: emails, research, scheduling, writing, analysis, and whatever else comes your way.
|
|
196
|
+
|
|
197
|
+
## Core Principle
|
|
198
|
+
Be fast, accurate, and proactive. The user chose a single-agent setup for speed and simplicity — deliver accordingly.
|
|
199
|
+
|
|
200
|
+
## How You Work
|
|
201
|
+
1. When you receive a task, handle it directly. No delegation, no coordination overhead.
|
|
202
|
+
2. For complex tasks, break them into steps and work through them methodically.
|
|
203
|
+
3. Prioritize getting things done over asking for clarification — but if a task is genuinely ambiguous, ask one focused question.
|
|
204
|
+
4. Proactively suggest next steps when you see opportunities.
|
|
205
|
+
|
|
206
|
+
## Communication Style
|
|
207
|
+
- Be concise. The user wants results, not status reports.
|
|
208
|
+
- Lead with the answer or deliverable, then context if needed.
|
|
209
|
+
- Never ask "should I continue?" — if you have what you need, keep moving.
|
|
210
|
+
- Match the user's tone: casual if they're casual, precise if they're precise.
|
|
211
|
+
|
|
212
|
+
${v}
|
|
213
|
+
${b}`}]},{id:"sales-outreach",label:"Sales & Outreach",description:"Prospect, follow up, and close deals as a team",icon:"📈",members:[{role:"leader",description:"Coordinates outreach strategy and manages deal flow",instructions:k},{role:"researcher",description:"Researches prospects, companies, and market intelligence",instructions:`You are the sales research specialist. You find prospects, research companies, analyze markets, and gather the intelligence the team needs to sell effectively.
|
|
214
|
+
|
|
215
|
+
## Core Principle
|
|
216
|
+
Your research directly drives revenue. Every finding should be actionable — not academic. The team needs to know who to contact, what they care about, and how to position.
|
|
217
|
+
|
|
218
|
+
## Before You Begin
|
|
219
|
+
When you receive a research request:
|
|
220
|
+
- What are we looking for? (prospects, company intel, market data, competitive info)
|
|
221
|
+
- What will this feed into? (outreach email, pitch, proposal, strategy)
|
|
222
|
+
- What scope is reasonable?
|
|
223
|
+
|
|
224
|
+
If the request is ambiguous, ask one focused clarification before starting.
|
|
225
|
+
|
|
226
|
+
## How You Work
|
|
227
|
+
1. Research companies, industries, and individuals using available sources.
|
|
228
|
+
2. Focus on actionable intelligence: pain points, recent news, decision-makers, tech stack, company size.
|
|
229
|
+
3. For prospect research, prioritize signals that indicate buying intent or fit.
|
|
230
|
+
4. For competitive analysis, focus on positioning differences, not feature lists.
|
|
231
|
+
|
|
232
|
+
## Output Standards
|
|
233
|
+
- Lead with the most actionable finding, then supporting detail.
|
|
234
|
+
- Cite sources: URLs, dates, reliability indicators.
|
|
235
|
+
- For prospect lists, include: name, role, company, why they're relevant, suggested angle.
|
|
236
|
+
- If data is stale or unverifiable, flag it clearly.
|
|
237
|
+
|
|
238
|
+
${v}
|
|
239
|
+
Report additionally:
|
|
240
|
+
- **Summary:** Key findings for the outreach team
|
|
241
|
+
- **Prospects:** Prioritized list with context and suggested approach
|
|
242
|
+
- **Market context:** Relevant trends or signals
|
|
243
|
+
- **Confidence:** High / Medium / Low per finding
|
|
244
|
+
|
|
245
|
+
## What NOT to Do
|
|
246
|
+
- Don't deliver raw data dumps — synthesize into actionable intelligence.
|
|
247
|
+
- Don't include prospects without a reason for why they're relevant.
|
|
248
|
+
- Don't present outdated information without flagging the date.
|
|
249
|
+
- Don't over-research at the expense of timeliness — sales moves fast.
|
|
250
|
+
|
|
251
|
+
${b}`},{role:"assistant",description:"Handles outreach emails, follow-ups, and pipeline tracking",instructions:`You are the sales operations specialist. You handle outreach emails, follow-ups, pipeline tracking, and the logistics that keep deals moving forward.
|
|
252
|
+
|
|
253
|
+
## Core Principle
|
|
254
|
+
Deals die in the follow-up gap. You ensure every prospect gets timely, personalized communication and nothing falls through the cracks.
|
|
255
|
+
|
|
256
|
+
## Before You Begin
|
|
257
|
+
When you receive a task:
|
|
258
|
+
- Who are we reaching out to and why?
|
|
259
|
+
- What stage is this deal/prospect in?
|
|
260
|
+
- What's the desired outcome of this communication?
|
|
261
|
+
|
|
262
|
+
If any of these are ambiguous, ask one focused question before starting.
|
|
263
|
+
|
|
264
|
+
## How You Work
|
|
265
|
+
1. Draft outreach emails that are personalized, concise, and have a clear call-to-action.
|
|
266
|
+
2. Track follow-up timelines — know when to nudge and when to wait.
|
|
267
|
+
3. Keep records of interactions: who was contacted, when, what was discussed, next steps.
|
|
268
|
+
4. Flag deals that are going cold or need escalation.
|
|
269
|
+
|
|
270
|
+
## Email Standards
|
|
271
|
+
- Subject lines: specific, intriguing, not salesy.
|
|
272
|
+
- Body: short. Personalize the first line. Get to the value proposition fast.
|
|
273
|
+
- Follow-ups: reference previous context, add new value, don't just "check in."
|
|
274
|
+
- Tone: professional but human. Never robotic or template-feeling.
|
|
275
|
+
|
|
276
|
+
${v}
|
|
277
|
+
Report additionally:
|
|
278
|
+
- **What I did:** Emails sent, follow-ups scheduled, pipeline updates
|
|
279
|
+
- **Next step:** Upcoming follow-ups, responses pending
|
|
280
|
+
- **Concerns:** Cold deals, bounced emails, objections to address
|
|
281
|
+
|
|
282
|
+
## What NOT to Do
|
|
283
|
+
- Don't send generic templates — every email should feel personal.
|
|
284
|
+
- Don't follow up more than twice without escalating to the leader.
|
|
285
|
+
- Don't make pricing or commitment promises — that's the leader's domain.
|
|
286
|
+
- Don't guess at prospect details — ask the researcher or leader.
|
|
287
|
+
|
|
288
|
+
${b}`}]},{id:"customer-support",label:"Customer Support",description:"Handle tickets, draft replies, and track resolutions",icon:"🎧",members:[{role:"leader",description:"Coordinates support queue and handles escalations",instructions:k},{role:"assistant",description:"Drafts customer responses and tracks open issues",instructions:`You are the customer support specialist. You draft responses to customer inquiries, track open issues, and ensure every customer gets a timely, helpful resolution.
|
|
289
|
+
|
|
290
|
+
## Core Principle
|
|
291
|
+
Every customer interaction is a chance to build trust. Be empathetic, accurate, and efficient — resolve issues on the first response whenever possible.
|
|
292
|
+
|
|
293
|
+
## Before You Begin
|
|
294
|
+
When you receive a task:
|
|
295
|
+
- What is the customer's issue or question?
|
|
296
|
+
- What's the urgency and impact?
|
|
297
|
+
- Is there relevant context from previous interactions?
|
|
298
|
+
|
|
299
|
+
If any of these are ambiguous, ask one focused question before starting.
|
|
300
|
+
|
|
301
|
+
## How You Work
|
|
302
|
+
1. Understand the customer's issue fully before drafting a response.
|
|
303
|
+
2. Draft replies that are empathetic, clear, and actionable — tell the customer exactly what's happening and what to expect.
|
|
304
|
+
3. Track open issues and follow up proactively when resolutions are pending.
|
|
305
|
+
4. Escalate complex or sensitive issues to the leader with full context.
|
|
306
|
+
|
|
307
|
+
## Response Standards
|
|
308
|
+
- Lead with acknowledgment of the issue, then the solution or next step.
|
|
309
|
+
- Use simple language — no jargon unless the customer is technical.
|
|
310
|
+
- If you can't resolve immediately, set clear expectations: what you'll do, by when.
|
|
311
|
+
- For known issues, provide workarounds while the fix is pending.
|
|
312
|
+
|
|
313
|
+
${v}
|
|
314
|
+
Report additionally:
|
|
315
|
+
- **What I did:** Response drafted/sent, issue tracked, escalation made
|
|
316
|
+
- **Next step:** Awaiting customer reply, follow-up scheduled, pending resolution
|
|
317
|
+
- **Concerns:** Recurring issues, unhappy customers, systemic problems to flag
|
|
318
|
+
|
|
319
|
+
## What NOT to Do
|
|
320
|
+
- Don't dismiss or minimize customer frustrations.
|
|
321
|
+
- Don't promise timelines you can't guarantee — set realistic expectations.
|
|
322
|
+
- Don't make policy exceptions without escalating to the leader.
|
|
323
|
+
- Don't send a response you're unsure about — flag it as DONE_WITH_CONCERNS.
|
|
324
|
+
|
|
325
|
+
${b}`}]},{id:"custom",label:"Custom",description:"Build your own team from scratch",icon:"✨",members:[{role:"leader",description:"Coordinates work and replies to you",instructions:k}]}];function S(e){let t=new Set,s=[];for(let a=0;a<e;a++){let e,a=0;do e=(0,y.uniqueNamesGenerator)({dictionaries:[y.names],length:1,style:"capital"}),a++;while(t.has(e)&&a<100)t.add(e),s.push({name:e,avatarUrl:(0,w.serializeAvatarConfig)((0,w.randomConfig)())})}return s}function I({selected:e,onSelect:s,onBrowseTemplates:a}){return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h2",{className:"text-base font-semibold tracking-tight",children:"What will your company focus on?"}),a&&(0,t.jsxs)("button",{type:"button",onClick:a,className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors underline underline-offset-2",children:["Browse templates ",(0,t.jsx)("span",{"aria-hidden":"true",children:"›"})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:C.map(a=>(0,t.jsxs)("button",{onClick:()=>s(a.id),className:(0,x.cn)("flex flex-col items-start gap-1 rounded-lg border p-4 text-left transition-all hover:border-foreground/30",e===a.id?"border-foreground/50 bg-muted/50":"border-border"),children:[(0,t.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,t.jsx)("span",{className:"text-lg",children:a.icon}),(0,t.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:[a.members.length," agent",a.members.length>1?"s":""]})]}),(0,t.jsx)("span",{className:"text-sm font-medium",children:a.label}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground leading-tight",children:a.description})]},a.id))})]})}var D=e.i(934351),T=e.i(4581),W=e.i(89110),z=e.i(855372);let R={leader:"Lead",researcher:"Researcher",engineer:"Engineer",assistant:"Assistant"};function Y({members:e,runtimes:s,onShuffle:a,onAssignRuntime:n}){let o=s.length>1&&n;return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("h2",{className:"text-base font-semibold tracking-tight",children:"Your company"}),(0,t.jsxs)(i.Button,{variant:"ghost",size:"sm",onClick:a,className:"h-7 text-xs gap-1.5",children:[(0,t.jsx)(T.RefreshCw,{className:"size-3"}),"Shuffle"]})]}),(0,t.jsx)("div",{className:(0,x.cn)("grid gap-3 grid-cols-1",2===e.length&&"sm:grid-cols-2",3===e.length&&"sm:grid-cols-2 md:grid-cols-3",e.length>=4&&"sm:grid-cols-2 md:grid-cols-4"),children:e.map((e,a)=>{let i,r=e.avatarUrl?(0,w.parseAvatarUrl)(e.avatarUrl):null;return(0,t.jsxs)(D.Card,{size:"sm",className:"flex flex-col px-3 py-4 gap-2 h-full",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[r?(0,t.jsx)(w.AvatarRenderer,{config:r,size:36,className:"rounded-xl shrink-0"}):(0,t.jsx)("div",{className:"size-9 rounded-xl bg-muted flex items-center justify-center text-sm font-semibold shrink-0",children:e.name.charAt(0)}),(0,t.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground bg-muted/60 px-1.5 py-0.5 rounded",children:R[e.role]})]})]}),(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground/70 font-mono truncate",children:[e.emailHandle||e.name.toLowerCase(),"@alook.ai"]}),(0,t.jsx)("p",{className:"text-[11px] text-muted-foreground leading-snug flex-1",children:e.description}),o&&(i=s.find(t=>t.id===e.runtimeId),(0,t.jsx)("div",{className:"mt-1",children:(0,t.jsxs)(W.Select,{value:e.runtimeId,onValueChange:e=>{e&&n(a,e)},children:[(0,t.jsx)(W.SelectTrigger,{className:"h-7 text-[11px]",children:(0,t.jsxs)("div",{className:"flex items-center gap-1.5 truncate",children:[i&&(0,t.jsx)(z.ProviderLogo,{provider:i.provider||"",className:"size-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:i?.provider||i?.runtime_mode||"Select"})]})}),(0,t.jsx)(W.SelectPopup,{children:s.map(e=>(0,t.jsx)(W.SelectItem,{value:e.id,children:e.provider||e.runtime_mode},e.id))})]})}))]},a)})})]})}var O=e.i(222862),B=e.i(642342);e.s(["StudioOnboardingClient",0,function({workspaceId:e,workspaceSlug:l,workspaceName:x,initialTemplate:y}){let w=(0,a.useRouter)(),v=!e,[b,k]=(0,s.useState)(e),j=(0,s.useRef)(b);(0,s.useEffect)(()=>{j.current=b},[b]);let[N,D]=(0,s.useState)([]),[T,W]=(0,s.useState)(!!e),[z,R]=(0,s.useState)(y?y.baseScenario:null),[E,L]=(0,s.useState)(v||"Personal"===x?"":x),[H,P]=(0,s.useState)(null),[A,F]=(0,s.useState)(!1),[U,$]=(0,s.useState)([]),[q,_]=(0,s.useState)(!1),[M,K]=(0,s.useState)(""),[G,X]=(0,s.useState)(!1),[V,J]=(0,s.useState)(!1),[Q,Z]=(0,s.useState)(!1),ee=N.filter(e=>"online"===e.status),et=ee.length>0,es=new Set(ee.map(e=>e.daemon_id).filter(Boolean)).size;(0,s.useEffect)(()=>{b&&(0,O.listRuntimes)(b).then(D).catch(()=>{}).finally(()=>W(!1))},[b]);let ea=(0,s.useCallback)(e=>{let t=j.current;if("runtime.registered"===e.type){J(!0);let s=e.workspaceId;s&&!t?(k(s),(0,O.listRuntimes)(s).then(D).catch(()=>{})):t&&(0,O.listRuntimes)(t).then(D).catch(()=>{})}else if("runtime.status"===e.type&&e.payload?.status==="online"){J(!0);let e=j.current;e&&(0,O.listRuntimes)(e).then(D).catch(()=>{})}},[]);(0,B.useUserWs)(ea),(0,s.useEffect)(()=>{let e=ee[0]?.id;e&&$(t=>0!==t.length&&t.some(e=>!e.runtimeId)?t.map(t=>t.runtimeId?t:{...t,runtimeId:e}):t)},[ee]);let ei=(0,s.useCallback)(async e=>{try{let t=await fetch("/api/studios/check-handles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({names:e})});if(!t.ok)return null;return await t.json()}catch{return null}},[]);(0,s.useEffect)(()=>{if(!y||T||U.length>0)return;let e=S(y.members.length),t=ee[0]?.id||"",s=y.members.map((s,a)=>({name:e[a].name,role:s.role,description:s.description,instructions:s.instructions,avatarUrl:e[a].avatarUrl,runtimeId:t}));$(s),ei(s.map(e=>e.name)).then(e=>{e&&$(t=>t.map(t=>{let s=e.find(e=>e.name===t.name);return s?{...t,emailHandle:s.handle}:t}))})},[y,T]);let en=async e=>{R(e);let t=C.find(t=>t.id===e),s=S(t.members.length),a=ee[0]?.id||"",i=t.members.map((e,t)=>({name:s[t].name,role:e.role,description:e.description,instructions:e.instructions,avatarUrl:s[t].avatarUrl,runtimeId:a}));$(i);let n=await ei(i.map(e=>e.name));n&&$(e=>e.map(e=>{let t=n.find(t=>t.name===e.name);return t?{...e,emailHandle:t.handle}:e}))},eo=async()=>{let e=S(U.length),t=U.map((t,s)=>({...t,name:e[s].name,avatarUrl:e[s].avatarUrl,emailHandle:void 0}));$(t);let s=await ei(t.map(e=>e.name));s&&$(e=>e.map(e=>{let t=s.find(t=>t.name===e.name);return t?{...e,emailHandle:t.handle}:e}))},er=async()=>{if(E.trim()){F(!0),P(null);try{let e=b?`/api/studios/check-name?name=${encodeURIComponent(E.trim())}&workspace_id=${b}`:`/api/studios/check-name?name=${encodeURIComponent(E.trim())}`,t=await fetch(e),s=await t.json();P(s.available)}catch{P(null),m.toast.error("Failed to check name availability")}finally{F(!1)}}},el=(0,s.useCallback)(async()=>{X(!0);try{let e=await (0,O.createMachineToken)("cli",b||void 0);K(e.token)}catch{m.toast.error("Failed to generate token")}finally{X(!1)}},[b]),ec=async()=>{_(!0);try{if(!b){m.toast.error("Please connect a computer first"),_(!1);return}let e=await fetch("/api/studios",{method:"POST",headers:{"Content-Type":"application/json","X-Workspace-ID":b},body:JSON.stringify({name:E.trim()||void 0,scenario:z,members:U.map(e=>({name:e.name,role:e.role,runtime_id:e.runtimeId,description:e.description,instructions:e.instructions,avatar_url:e.avatarUrl||null,email_handle:e.emailHandle||void 0}))})});if(!e.ok){let t=await e.json();throw Error(t.error||"Failed to create company")}let t=await e.json();m.toast.success("Company created!"),w.push(`/w/${t.workspace.slug}/agents/${t.leader_agent_id}`)}catch(e){m.toast.error(e instanceof Error?e.message:"Failed to create company"),_(!1)}},ed=v?E.trim()&&!0===H:!1!==H,eu=z&&U.length>0&&U.every(e=>e.runtimeId)&&ed&&(et||V);return z?(0,t.jsxs)("div",{className:"relative flex min-h-dvh flex-col items-center p-6",children:[(0,t.jsxs)("div",{className:"absolute top-4 left-4 flex items-center gap-1",children:[(0,t.jsxs)(i.Button,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:()=>w.push("/workspaces"),children:[(0,t.jsx)(h,{className:"size-3 mr-1.5"}),"Workspaces"]}),(0,t.jsx)("span",{className:"text-muted-foreground/40",children:"/"}),(0,t.jsxs)(i.Button,{variant:"ghost",size:"sm",className:"text-xs text-muted-foreground",onClick:()=>R(null),children:[(0,t.jsx)(u.ArrowLeft,{className:"size-3 mr-1.5"}),"Back"]})]}),(0,t.jsxs)(i.Button,{variant:"ghost",size:"sm",className:"absolute top-4 right-4 text-xs text-muted-foreground",onClick:async()=>{await (0,f.clearAllCache)(),(0,p.signOut)({fetchOptions:{onSuccess:()=>w.push("/sign-in")}})},children:[(0,t.jsx)(d.LogOut,{className:"size-3 mr-1.5"}),"Sign out"]}),(0,t.jsxs)("div",{className:"w-full max-w-3xl space-y-10 py-14",children:[(0,t.jsx)("div",{className:"text-center",children:(0,t.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",style:{fontFamily:"var(--font-news)"},children:"Build your company"})}),T?(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(o.Loader2,{className:"size-5 animate-spin text-muted-foreground"})}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("h2",{className:"text-base font-semibold tracking-tight",children:"Company name"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(n.Input,{value:E,onChange:e=>{L(e.target.value),P(null)},placeholder:"e.g. Atlas Lab",className:"text-sm"}),(0,t.jsx)(i.Button,{variant:"outline",size:"sm",onClick:er,disabled:!E.trim()||A,className:"shrink-0",children:A?(0,t.jsx)(o.Loader2,{className:"size-3 animate-spin"}):"Check"})]}),!1===H&&(0,t.jsxs)("p",{className:"text-xs text-red-500 flex items-center gap-1",children:[(0,t.jsx)(c,{className:"size-3"})," Name is taken, try another"]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground flex items-center gap-1.5",children:[!0===H&&(0,t.jsxs)("span",{className:"text-emerald-600 flex items-center gap-0.5",children:[(0,t.jsx)(r.CheckCircle2,{className:"size-3"})," Available"]}),!0===H&&(0,t.jsx)("span",{children:"·"}),v?(0,t.jsx)("span",{children:"Required — pick a name for your company."}):(0,t.jsx)("span",{children:"Optional — you can always rename later."})]})]}),(0,t.jsx)(Y,{members:U,runtimes:ee,onShuffle:eo,onAssignRuntime:(e,t)=>{$(s=>s.map((s,a)=>a===e?{...s,runtimeId:t}:s))}}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("h2",{className:"text-base font-semibold tracking-tight",children:"Connect a computer"}),et?(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("p",{className:"text-xs text-emerald-600 flex items-center gap-1",children:[(0,t.jsx)(r.CheckCircle2,{className:"size-3"})," ",es," computer",es>1?"s":""," connected"]}),(0,t.jsx)("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:()=>Z(e=>!e),children:"Register another"})]}),Q&&(0,t.jsx)("div",{className:"rounded-xl bg-muted/40 p-5",children:(0,t.jsx)(g.ConnectMachineSteps,{generatedToken:M,generatingToken:G,onGenerateToken:el,registered:V})})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Your company needs a connected computer to run tasks."}),(0,t.jsx)("div",{className:"rounded-xl bg-muted/40 p-5",children:(0,t.jsx)(g.ConnectMachineSteps,{generatedToken:M,generatingToken:G,onGenerateToken:el,registered:V})})]})]}),(0,t.jsx)(i.Button,{onClick:ec,disabled:!eu||q,className:"w-full",size:"lg",children:q?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Loader2,{className:"size-4 animate-spin mr-2"}),"Launching..."]}):v&&E.trim()&&!0!==H?"Check company name first":"Launch company"})]})]})]}):(0,t.jsxs)("div",{className:"relative flex min-h-dvh flex-col items-center justify-center p-6",children:[(0,t.jsxs)(i.Button,{variant:"ghost",size:"sm",className:"absolute top-4 left-4 text-xs text-muted-foreground",onClick:()=>w.push("/workspaces"),children:[(0,t.jsx)(h,{className:"size-3 mr-1.5"}),"Workspaces"]}),(0,t.jsxs)(i.Button,{variant:"ghost",size:"sm",className:"absolute top-4 right-4 text-xs text-muted-foreground",onClick:async()=>{await (0,f.clearAllCache)(),(0,p.signOut)({fetchOptions:{onSuccess:()=>w.push("/sign-in")}})},children:[(0,t.jsx)(d.LogOut,{className:"size-3 mr-1.5"}),"Sign out"]}),(0,t.jsxs)("div",{className:"w-full max-w-3xl space-y-8",children:[(0,t.jsxs)("div",{className:"text-center space-y-2",children:[(0,t.jsx)("h1",{className:"text-2xl font-semibold tracking-tight",style:{fontFamily:"var(--font-news)"},children:"What will your company do?"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Pick a focus area. You can always add more agents later."})]}),(0,t.jsx)(I,{selected:z,onSelect:en,onBrowseTemplates:()=>w.push(b?`/templates?workspace_id=${b}`:"/templates")}),b&&(0,t.jsx)("div",{className:"flex justify-center pt-2",children:(0,t.jsx)("button",{type:"button",onClick:()=>{document.cookie=`skip_init=${b};path=/;max-age=86400`,w.push(`/w/${l}/home`)},className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Skip for now"})})]})]})}],319755)}]);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,875494,685835,e=>{"use strict";var t=e.i(368075),s=e.i(298699),a=e.i(222862),n=e.i(355578),r=e.i(500324),l=e.i(980630);let i="inbox-filter-types",o=["user_dm_message","calendar_event","email_notification"],c=["user_dm_message"],d=["user_dm_message"];function u(){try{let e=localStorage.getItem(i);if(!e)return c;let t=JSON.parse(e).filter(e=>o.includes(e));if(0===t.length)return c;for(let e of d)t.includes(e)||t.unshift(e);return t}catch{return c}}e.s(["INBOX_FILTER_LABELS",0,{user_dm_message:"DM",calendar_event:"Calendar",email_notification:"Email"},"INBOX_FILTER_TYPES",0,o,"MANDATORY_INBOX_TYPES",0,d,"getInboxFilterTypes",0,u,"setInboxFilterTypes",0,function(e){let t=[...e];for(let e of d)t.includes(e)||t.unshift(e);localStorage.setItem(i,JSON.stringify(t))}],685835);let m=(0,s.createContext)(null);e.s(["InboxCountProvider",0,function({children:e}){let{workspaceId:i}=(0,r.useWorkspace)(),{subscribeWs:o,agents:c}=(0,n.useAgentContext)(),[d,h]=(0,s.useState)(0),p=(0,s.useRef)(null),g=(0,s.useRef)(null),f=(0,s.useRef)(c);(0,s.useEffect)(()=>{f.current=c});let x=(0,s.useCallback)(()=>{let e=u();(0,a.getInboxCount)(i,{types:e}).then(e=>{let t=p.current;if(p.current=e.count,h(e.count),null!==t&&e.count>t){let e=g.current?f.current.find(e=>e.id===g.current):void 0;(0,l.sendTaskNotification)("completed",e?.name)}g.current=null}).catch(()=>{})},[i]),v=(0,s.useCallback)(()=>{h(e=>{let t=Math.max(0,e-1);return p.current=t,t})},[]);return(0,s.useEffect)(()=>{x()},[x]),(0,s.useEffect)(()=>o(e=>{"task.updated"===e.type&&("completed"===e.status||"failed"===e.status)&&(g.current=e.agentId,x())}),[o,x]),(0,s.useEffect)(()=>{let e=setInterval(x,6e4);return()=>clearInterval(e)},[x]),(0,t.jsx)(m.Provider,{value:{count:d,refresh:x,decrement:v},children:e})},"useInboxCount",0,function(){let e=(0,s.useContext)(m);if(!e)throw Error("useInboxCount must be used within InboxCountProvider");return e}],875494)},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",()=>e_,"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(406963);let m=(0,u.default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]);var h=e.i(108281),p=e.i(140483),g=e.i(371522);e.i(112946);var f=e.i(164300);function x(e){return e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}let v=new Set(["status","log"]);function j({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:x(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:x(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 y({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)(m,{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)(m,{className:"size-3 shrink-0"}),(0,t.jsx)("span",{children:"Thinking..."})]})}function k({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 w({task:e,messages:a,connectionLost:n,onRetry:r,stepCountHint:l,onExpandSteps:c,stepsLoading:u}){let[m,x]=(0,s.useState)(!1),b=(0,s.useMemo)(()=>(function(e){let t=[],s=new Map;for(let a of e){if(v.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,C=b.filter(e=>"text"!==e.kind),_=b.filter(e=>"text"===e.kind),S=_.length>0?_[_.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)},[C.length,N]),(0,s.useEffect)(()=>{N&&M.current&&(M.current.scrollTop=M.current.scrollHeight)},[_.length,N]);let E=N?_:_.slice(0,-1),A=!N&&null!==S,z=C.length>0?C.length:l??0,R=C.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)(k,{value:z})," ",1===z?"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===C.length&&(0,t.jsxs)("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[(0,t.jsx)(g.Loader2,{className:"size-3 animate-spin"}),(0,t.jsx)("span",{children:"Loading steps..."})]}),C.map((e,s)=>{switch(e.kind){case"tool-call":return(0,t.jsx)(j,{item:e,isRunning:N,isLast:s===C.length-1},e.id);case"thinking":return(0,t.jsx)(y,{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)(h.AlertCircle,{className:"inline size-3 mr-1 -mt-0.5 text-destructive"}),e.content]},e.id);default:return null}})]})]}),E.length>0&&(0,t.jsxs)("details",{className:"group/midtext pl-1",open:!A||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)(k,{value:E.length})," thinking"]})]}),(0,t.jsx)("div",{ref:M,className:"mt-1 space-y-2 pl-1",children:E.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))})]}),A&&!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:S.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)(h.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()=>{x(!0);try{await r()}finally{x(!1)}},disabled:m,className:"shrink-0 text-xs text-muted-foreground hover:text-foreground transition-colors cursor-pointer disabled:opacity-50 flex items-center gap-1",children:[m?(0,t.jsx)(g.Loader2,{className:"size-3 animate-spin"}):(0,t.jsx)(p.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),N=e.i(275351),C=e.i(355578),_=e.i(875494),S=e.i(74348),T=e.i(872937),M=e.i(880932),I=e.i(728886),E=e.i(329686),A=e.i(36303);let z=(0,u.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,u.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 P=(0,u.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"}]]),L=(0,u.default)("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);var B=e.i(554468),q=e.i(745925),$=e.i(937091);function W(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition??null}function H({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 O({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)(H,{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)(H,{agent:e,isSelected:a.length+s===r,onSelect:l},e.id))]})})}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 X=e.i(721387),Y=e.i(332680),K=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,p]=(0,s.useState)(500),f=(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(()=>{M.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)},j=(0,s.useCallback)(e=>{e.preventDefault(),f.current=!0,e.target.setPointerCapture(e.pointerId)},[]),y=(0,s.useCallback)(e=>{f.current&&p(Math.min(.8*window.innerWidth,Math.max(320,window.innerWidth-e.clientX)))},[]),k=(0,s.useCallback)(()=>{f.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:j,onPointerMove:y,onPointerUp:k,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)($.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)(g.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)(K.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})]})})}let Z=(0,u.default)("calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);function Q({open:e,onOpenChange:a,calendarEventId:n,workspaceId:r}){let[i,o]=(0,s.useState)(null),[c,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)(500),h=(0,s.useRef)(!1),p=(0,s.useRef)(a);(0,s.useEffect)(()=>{p.current=a}),(0,s.useEffect)(()=>{e&&n&&(d(!0),o(null),(0,b.getCalendarEvent)(n,r).then(o).catch(()=>{M.toast.error("Calendar event not found"),p.current(!1)}).finally(()=>d(!1)))},[e,n,r]);let f=e=>{a(e),e||setTimeout(()=>o(null),300)},x=(0,s.useCallback)(e=>{e.preventDefault(),h.current=!0,e.target.setPointerCapture(e.pointerId)},[]),v=(0,s.useCallback)(e=>{h.current&&m(Math.min(.8*window.innerWidth,Math.max(320,window.innerWidth-e.clientX)))},[]),j=(0,s.useCallback)(()=>{h.current=!1},[]);return(0,t.jsx)(Y.Sheet,{open:e,onOpenChange:f,children:(0,t.jsxs)(Y.SheetContent,{side:"right",showCloseButton:!1,style:{width:`min(${u}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:x,onPointerMove:v,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)(Z,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),(0,t.jsx)(Y.SheetTitle,{className:"truncate flex-1",children:c?"Loading...":i?.title||"Calendar Event"}),(0,t.jsx)(l.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>f(!1),children:(0,t.jsx)($.X,{className:"h-4 w-4"})})]})}),(0,t.jsx)(Y.SheetBody,{className:"flex-1 overflow-y-auto thin-scrollbar",children:c?(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsx)(g.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-2 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:"Scheduled:"}),(0,t.jsx)("span",{children:new Date(i.scheduled_at).toLocaleString()})]}),i.repeat_interval&&(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:"Repeats:"}),(0,t.jsxs)("span",{children:["Every ",i.repeat_interval]})]}),i.repeat_stop_at&&(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground shrink-0",children:"Until:"}),(0,t.jsx)("span",{children:new Date(i.repeat_stop_at).toLocaleDateString()})]})]}),i.description&&(0,t.jsxs)("div",{className:"text-sm",children:[(0,t.jsx)("p",{className:"text-muted-foreground mb-1",children:"Description"}),(0,t.jsx)("pre",{className:"whitespace-pre-wrap font-sans",children:i.description})]})]}):null})]})})}var G=e.i(169678),ee=e.i(364079);function et({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)(B.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)($.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 es=e.i(219658);let ea={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 en({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)(w,{task:ea,messages:r,stepCountHint:a,onExpandSteps:u,stepsLoading:i})}var er=e.i(251638);let el=(0,u.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)(Z,{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:j,onIssueClick:y,onCalendarEventClick:k,onRetry:b,mentionComponents:N,isFlagged:C,onToggleFlag:_}){let S,T,I,A,[z,R]=(0,s.useState)(!1),F=r&&"assistant"===e.role&&e.task_id===r.id&&e.conversation_id===r.conversation_id&&i.length>0,D=!F&&h&&"assistant"===e.role&&e.task_id&&m>0?m:0,P=F&&r&&["completed","failed","cancelled","superseded"].includes(r.status),L="assistant"===e.role?(0,t.jsxs)("div",{className:"flex flex-row items-center gap-1",children:[(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-xs","aria-label":z?"Copied":"Copy message",onClick:async t=>{t.stopPropagation();try{await navigator.clipboard.writeText(e.content),R(!0),M.toast.success("Copied to clipboard"),setTimeout(()=>R(!1),2e3)}catch{M.toast.error("Failed to copy")}},className:(0,o.cn)("self-start mb-1",z?"text-green-500 opacity-100":"text-muted-foreground opacity-0 group-hover/msg:opacity-100")}),children:z?(0,t.jsx)(c.Check,{className:"size-3.5"}):(0,t.jsx)(ei.Copy,{className:"size-3.5"})}),(0,t.jsx)(E.TooltipContent,{children:z?"Copied":"Copy"})]}),_&&(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-xs",onClick:()=>_(e.id),className:(0,o.cn)("self-start mb-1",C?"text-primary opacity-100":"text-muted-foreground opacity-0 group-hover/msg:opacity-100")}),children:(0,t.jsx)(el,{className:(0,o.cn)("size-3.5",C&&"fill-current")})}),(0,t.jsx)(E.TooltipContent,{children:C?"Unflag":"Flag"})]})]}):null;return(0,t.jsxs)(s.default.Fragment,{children:[F&&(0,t.jsxs)("div",{className:(0,o.cn)("group/msg",C&&"bg-muted/30 rounded-lg px-2 -mx-2"),children:[(0,t.jsx)(w,{task:r,messages:i,connectionLost:d,onRetry:b}),P&&L]}),D>0&&e.task_id&&(0,t.jsx)(en,{taskId:e.task_id,stepCount:D,workspaceId:p}),"user"===e.role?(S=u&&!!r&&"running"!==r.status&&!["completed","failed","cancelled","superseded"].includes(r.status),(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:[S&&(0,t.jsx)("div",{className:"absolute inset-0 rounded-lg animate-pulse pointer-events-none",style:{boxShadow:"0 0 0 2px var(--bubble-glow)"}}),(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(e.content,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?(T=e.metadata?.emailId,I=e.metadata?.issueId,A=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",(!!T||!!I||!!A)&&"cursor-pointer hover:bg-muted transition-colors"),onClick:T?()=>j(T):I?()=>y(I):A?()=>k(A):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})]})})):F?null:(0,t.jsxs)("div",{className:(0,o.cn)("group/msg flex flex-col justify-start min-w-0 overflow-hidden",C&&"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)})}),L]})]})});e.i(400175);var ep=e.i(819748),eg=e.i(126366),ef=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),M.toast.success("Email copied to clipboard"),setTimeout(()=>d(!1),2e3)}catch{M.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,eg.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)(ef.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 ej={mention:function(e){let{children:s,...a}=e,{agents:n}=(0,C.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 ek(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 ew(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 eb(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 eC({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,X.formatSize)(e.size)})]})]})}function e_({agentId:e,targetConvId:i,scrollToTaskId:c,scrollToMessageId:d}){let u,m,h,p=(0,n.useParams)(),f=(0,n.useSearchParams)(),{workspaceId:x,slug:v}=(0,r.useWorkspace)(),{agents:j,agentLinks:y,activeTaskCounts:k,subscribeWs:H}=(0,C.useAgentContext)(),{refresh:V}=(0,_.useInboxCount)(),{activeChannel:Y,loading:K,setAgentId:Z}=(0,T.useChannel)(),ea=e??p.id,en=void 0!==c?c:f.get("task"),er=void 0!==d?d:f.get("msg"),el=void 0!==i?i:f.get("conv"),[ei,eo]=(0,s.useState)(null),[ec,ed]=(0,s.useState)([]),[eu,em]=(0,s.useState)(()=>localStorage.getItem(`chat-draft:${ea}:${el??"default"}`)??""),[ep,eg]=(0,s.useState)(!1),[ef,ex]=(0,s.useState)(!1),[ev,ey]=(0,s.useState)(null),[eS,eT]=(0,s.useState)([]),[eM,eI]=(0,s.useState)(!0),[eE,eA]=(0,s.useState)(!1),[ez,eR]=(0,s.useState)(!1),[eF,eD]=(0,s.useState)(!1),[eP,eL]=(0,s.useState)([]),[eB,eq]=(0,s.useState)(!1),[e$,eW]=(0,s.useState)(null),[eH,eO]=(0,s.useState)(null),[eV,eU]=(0,s.useState)(!1),[eX,eY]=(0,s.useState)(null),[eK,eJ]=(0,s.useState)(!1),[eZ,eQ]=(0,s.useState)(null),[eG,e0]=(0,s.useState)(!1),[e1,e2]=(0,s.useState)(null),[e5,e3]=(0,s.useState)(null),[e4,e6]=(0,s.useState)(!1),[e8,e7]=(0,s.useState)(null),[e9,te]=(0,s.useState)(null),[tt,ts]=(0,s.useState)(448),[ta,tn]=(0,s.useState)([]),[tr,tl]=(0,s.useState)([]),[ti,to]=(0,s.useState)(null),[tc,td]=(0,s.useState)([]),[tu,tm]=(0,s.useState)(!1),[th,tp]=(0,s.useState)([]),[tg,tf]=(0,s.useState)({}),[tx]=(0,s.useState)(()=>Date.now()),[tv,tj]=(0,s.useState)(()=>new Map),[ty,tk]=(0,s.useState)(null),[tw,tb]=(0,s.useState)(null),[tN,tC]=(0,s.useState)(new Set),t_=(0,s.useRef)(tN);(0,s.useEffect)(()=>{t_.current=tN});let{increment:tS,decrement:tT,refresh:tM}=(0,S.useFlagCount)(),{writeToCache:tI}=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,N.openCacheDB)(t);let s=!1;return(0,N.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,N.mergeCachedMessages)(i.current,e,s,t)},[t])}}(el??null,x),tE=(0,s.useRef)(tI);(0,s.useEffect)(()=>{tE.current=tI},[tI]),(0,s.useEffect)(()=>{Z(ea)},[ea,Z]);let{listening:tA,supported:tz,toggle:tR}=function(e){let[t,a]=(0,s.useState)(!1),[n,r]=(0,s.useState)(!1),l=(0,s.useRef)(null);(0,s.useEffect)(()=>{r(!!W())},[]);let i=(0,s.useCallback)(()=>{let t=W();if(!t)return;let s=new t;s.lang=navigator.language||"zh-CN",s.interimResults=!1,s.continuous=!1,s.onresult=t=>{let s=t.results,a="";for(let e=0;e<s.length;e++)a+=s[e][0].transcript;a&&e(a)},s.onend=()=>{a(!1),l.current=null},s.onerror=()=>{a(!1),l.current=null},l.current=s,s.start(),a(!0)},[e]),o=(0,s.useCallback)(()=>{l.current?.stop()},[]),c=(0,s.useCallback)(()=>{t?o():i()},[t,i,o]);return(0,s.useEffect)(()=>()=>{l.current?.abort()},[]),{listening:t,supported:n,toggle:c}}((0,s.useCallback)(e=>{em(t=>t?t+" "+e:e)},[])),tF=(0,s.useMemo)(()=>eP.filter(e=>"agent"===e.source),[eP]),{versionMap:tD,duplicateFilenames:tP}=(0,s.useMemo)(()=>(0,ee.computeArtifactVersions)(tF),[tF]),tL=(0,s.useMemo)(()=>"agent"===eH?tF:"issue"===eH?e5?.artifacts??[]:[],[eH,tF,e5?.artifacts]),{versionMap:tB,duplicateFilenames:tq}=(0,s.useMemo)(()=>(0,ee.computeArtifactVersions)(tL),[tL]),t$=(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)}),ew(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=>ew([...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=ew(e),s=i.findIndex(e=>"nap"===e.kind);s>=0?i.splice(s,0,...t):i.push(...t)}return i})(ec,tF,th,ei?.id),[ec,tF,th,ei?.id]),tW=(0,s.useCallback)(e=>{(0,ee.isPreviewable)(e)?(eW(e),eO("agent"),eq(!0)):window.open((0,ee.getArtifactUrl)(e.id,x,!0),"_blank")},[x]),tH=(0,s.useCallback)(e=>{(0,ee.isPreviewable)(e)?(eW(e),eO("issue"),eq(!0)):window.open((0,ee.getArtifactUrl)(e.id,x,!0),"_blank")},[x]),tO=(0,s.useRef)(null),tV=(0,s.useRef)(null),tU=(0,s.useRef)(null),tX=(0,s.useRef)(null),tY=(0,s.useRef)(0),tK=(0,s.useRef)(0),tJ=(0,s.useRef)(!1),tZ=(0,s.useRef)(!1),tQ=(0,s.useRef)(!0),tG=(0,s.useRef)(!1),t0=(0,s.useRef)(null),t1=(0,s.useRef)(null),t2=(0,s.useRef)(0),t5=(0,s.useRef)(void 0),t3=(0,s.useRef)(null),t4=(0,s.useRef)(null),t6=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,g]=(0,s.useState)({top:0,left:0}),f=(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:j,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?(f.current=s.start,u(s.query),c(!0),a.current&&g(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),f.current=null)},[e,t,a]);let k=(0,s.useCallback)(s=>{if(null===t||null===f.current)return;let n=e.slice(0,f.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]),w=(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(),k(y[m]),!0):"Escape"===e.key&&(e.preventDefault(),c(!1),!0)),[o,y,m,k]);return{isOpen:o,query:d,selectedIndex:m,anchorPos:p,relatedAgents:v,otherAgents:j,allAgents:y,handleMentionKeyDown:w,selectAgent:k}}({input:eu,caretIndex:ti,textareaRef:t4,agents:(0,s.useMemo)(()=>j.filter(e=>e.id!==ea),[j,ea]),agentLinks:y,currentAgentId:ea,onInputChange:em});(0,s.useEffect)(()=>{let e=`chat-draft:${ea}:${el??"default"}`;eu?localStorage.setItem(e,eu):localStorage.removeItem(e)},[eu,ea,el]),(0,s.useEffect)(()=>{ep||t4.current?.focus()},[ep]);let t8=(0,s.useCallback)(()=>{tQ.current=!0,setTimeout(()=>{tO.current?.scrollTo({top:tO.current.scrollHeight,behavior:"smooth"})},50)},[]);(0,s.useEffect)(()=>{if(K)return;tV.current&&clearInterval(tV.current),tV.current=null,tX.current=null;let e=!1;return eI(!0),tJ.current=!1,ey(null),eT([]),tl([]),tj(new Map),tp([]),tf({}),td([]),tm(!1),t1.current=null,em(localStorage.getItem(`chat-draft:${ea}:${el??"default"}`)??""),ed([]),async function(){let t=!1;try{let s=null,a=null;if(el){if(s=el,a=await (0,N.getCacheMeta)(s,x),a?.newestMessageId){let n=await (0,N.getCachedMessages)(s,x);if(e)return;n&&n.length>0&&(t=!0,ed(n),eR(a.hasMore),eI(!1))}}else try{let n=await (0,b.checkFreshness)({agentId:ea,channel:Y},x);if(e)return;if(s=n.conversation_id,a=await (0,N.getCacheMeta)(s,x),a?.newestMessageId&&a.newestMessageId===n.newest_message_id){let n=await (0,N.getCachedMessages)(s,x);if(e)return;n&&n.length>0&&(t=!0,ed(n),eR(a.hasMore),eI(!1))}}catch{}if(s){let t=await (0,b.conversationInit)(s,x,{newestMessageId:a?.newestMessageId??void 0});if(e)return;if(eo(t.conversation),tm(t.has_more_conversations),!t.cache_valid&&t.messages?(ed(e=>ek(e,t.messages)),tE.current(t.messages,t.has_more_messages).catch(()=>{}),eR(t.has_more_messages)):a&&eR(a.hasMore),tf(t.step_counts),eL(t.artifacts),tl(t.buffered_messages),tC(new Set(t.flagged_message_ids)),t.active_task&&(ey(t.active_task),eT(t.task_messages),t.task_messages.length>0&&(tY.current=Math.max(...t.task_messages.map(e=>e.seq))),t0.current?.(t.active_task.id,s,tY.current)),en){let t=await (0,b.getTask)(en,x).catch(()=>null);if(e)return;if(t&&!["completed","failed","cancelled","superseded"].includes(t.status)){ey(t);let a=await (0,b.getTaskMessages)(en,x).catch(()=>[]);if(e)return;eT(a),a.length>0&&(tY.current=Math.max(...a.map(e=>e.seq))),t0.current?.(t.id,s,tY.current)}}}else{let t=await (0,b.chatInit)(ea,x,Y);if(e)return;eo(t.conversation),ed(e=>e.length>0?ek(e,t.messages):t.messages),eR(t.has_more_messages),eL(t.artifacts),tl(t.buffered_messages),tm(t.has_more_conversations),tE.current(t.messages,t.has_more_messages).catch(()=>{}),(0,b.listFlaggedMessageIds)(x,t.conversation.id).then(t=>{e||tC(new Set(t.message_ids))}).catch(()=>{}),t.active_task&&(ey(t.active_task),t.task_messages.length>0&&(eT(t.task_messages),tY.current=Math.max(...t.task_messages.map(e=>e.seq))),["completed","failed","cancelled","superseded"].includes(t.active_task.status)||t0.current?.(t.active_task.id,t.conversation.id,tY.current))}}catch{t?M.toast.error("Couldn't refresh conversation"):M.toast.error("Failed to load conversation")}finally{e||eI(!1)}}(),()=>{e=!0}},[ea,x,el,en,Y,K]);let t7=(0,s.useRef)(V);(0,s.useEffect)(()=>{t7.current=V},[V]);let t9=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!ei?.id||!x||t9.current===ei.id)return;t9.current=ei.id;let e=setTimeout(()=>{(0,b.markInboxRead)(ei.id,x).then(()=>t7.current()).catch(()=>{})},1e3);return()=>{t9.current=null,clearTimeout(e)}},[ei?.id,x]),(0,s.useEffect)(()=>{eM||!(ec.length>0)||tJ.current||(tJ.current=!0,en||er?tQ.current=!1:i?setTimeout(()=>{let e=tO.current?.querySelectorAll("[data-quote-source]");e&&e.length>0?e[e.length-1].scrollIntoView({behavior:"instant",block:"start"}):tO.current?.scrollTo({top:tO.current.scrollHeight})},50):setTimeout(()=>{tO.current?.scrollTo({top:tO.current.scrollHeight})},50))},[eM,ec.length,en,er,i]),(0,s.useEffect)(()=>{let e;if(!en||eM||!ei)return;tQ.current=!1,tG.current=!0;let t=!1,s=()=>{if(t)return!1;let s=document.querySelector(`[data-task-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||(tG.current=!1)},1500),!0)},a=setTimeout(async()=>{if(!t&&!s())try{let e=await (0,b.listMessagesAroundTask)(ei.id,x,en);if(t)return;e.length>0?(ed(t=>ek(t,e)),requestAnimationFrame(()=>{setTimeout(()=>{s()||(tG.current=!1)},100)})):tG.current=!1}catch{t||(tG.current=!1)}},100);return()=>{t=!0,clearTimeout(a),e&&clearTimeout(e)}},[en,eM,ei,x]),(0,s.useEffect)(()=>{let e;if(!er||en||eM||!ei)return;tQ.current=!1,tG.current=!0;let t=!1,s=setTimeout(()=>{!t&&((()=>{if(t)return!1;let s=document.querySelector(`[data-message-id="${CSS.escape(er)}"]`);return!!s&&(s.scrollIntoView({behavior:"smooth",block:"start"}),s.classList.add("task-highlight"),e=setTimeout(()=>{s.classList.remove("task-highlight"),t||(tG.current=!1)},1500),!0)})()||(tO.current?.scrollTo({top:tO.current.scrollHeight}),tG.current=!1))},100);return()=>{t=!0,clearTimeout(s),e&&clearTimeout(e)}},[er,en,eM,ei]);let se=ev?.status;(0,s.useEffect)(()=>{tG.current||("running"===se||"queued"===se)&&tQ.current&&t8()},[eS.length,se,t8]);let st=(0,s.useMemo)(()=>j.find(e=>e.id===ea)?.name??"Agent",[j,ea]),ss=eb(ec),sa=eb(ez),sn=eb(tc),sr=eb(tu),sl=eb(st),si=eb(Y),so=(0,s.useCallback)(async(e=!1)=>{if(!ei||tZ.current)return;tZ.current=!0;let t=ss.current,s=sa.current,n=sr.current,r=sl.current,l=si.current,i=!!el,o=t[0],c=t1.current?.id??ei.id,d=s&&o,u=sn.current;if(!i&&!d&&0===u.length&&n){let e=t1.current??{id:ei.id,created_at:ei.created_at};try{let t=await (0,b.listPreviousConversations)(ea,x,{exclude:ei.id,before:e.created_at,channel:l});u=t.conversations,td(t.conversations),tm(t.has_more)}catch{tm(!1)}}let m=!i&&u.length>0;if(!d&&!m){tZ.current=!1;return}eD(!0);let h=tO.current;h&&(h.style.overflowAnchor="none");let p=h?.scrollHeight??0;try{let t=[],s=[],m=20,g=!1,f=[],v=!1;if(d){let e=c===ei.id?await (0,N.getCachedMessagesBefore)(c,o.created_at,o.id,20,x):null;if(e)t=e.messages,m-=e.messages.length,g=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,g=e.has_more}v=g}if(!i&&!g&&m>0){if(0===u.length&&n){let e=t1.current??{id:ei.id,created_at:ei.created_at};try{let t=await (0,b.listPreviousConversations)(ea,x,{exclude:ei.id,before:e.created_at,channel:l});u=t.conversations,td(t.conversations),tm(t.has_more)}catch{tm(!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){t1.current=a;continue}let l=t1.current?.created_at??ei.created_at;f.push({agentName:r,created_at:l,id:`nap-${a.id}`}),s=[...n.messages,...s],m-=n.messages.length,g=n.has_more,t1.current=a}e>0&&td(t=>t.slice(e))}let j=[...s,...t];if((0,a.flushSync)(()=>{j.length>0?(f.length>0&&tp(e=>{let t=new Set(e.map(e=>e.id)),s=f.filter(e=>!t.has(e.id));return[...e,...s]}),eR(g),ed(e=>{let t=new Set(e.map(e=>e.id));return[...j.filter(e=>!t.has(e.id)),...e]})):eR(!1)}),j.length>0&&ei){let e=j.filter(e=>e.conversation_id===ei.id);e.length>0&&(0,N.mergeCachedMessages)(ei.id,e,v,x).catch(()=>{})}if(tZ.current=!1,(0,a.flushSync)(()=>eD(!1)),h)if(e)h.scrollTop=h.scrollHeight;else{let e=h.scrollHeight;h.scrollTop=e-p}}catch{M.toast.error("Failed to load older messages")}finally{tZ.current=!1,eD(!1),tO.current&&(tO.current.style.overflowAnchor="")}},[ei,x,ea,el,ss,sa,sr,sl,si,sn]),sc=el?ez:ez||tc.length>0||tu;(0,s.useEffect)(()=>{ei?.id!==t5.current&&(t5.current=ei?.id,t2.current=0)},[ei?.id]),(0,s.useEffect)(()=>{eM||!ei||en||el||ec.length>=10||!sc||eF||t2.current>=3||(t2.current+=1,so(!0))},[eM,ec.length,sc,eF,ei,so,en,el]);let sd=(0,s.useCallback)(()=>{let e=tO.current;e&&(tQ.current=e.scrollHeight-e.scrollTop-e.clientHeight<100)},[]),su=(0,s.useCallback)((e,t,s)=>{tV.current&&clearInterval(tV.current),tY.current=s??0,tK.current=0,eA(!1),tX.current=e,tV.current=setInterval(async()=>{if(tX.current===e)try{let[s,a]=await Promise.all([(0,b.getTask)(e,x),(0,b.getTaskMessages)(e,x,tY.current||void 0)]),n=tX.current!==e;if(tK.current=0,eA(!1),a.length>0&&!n&&(eT(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}),tY.current=Math.max(...a.map(e=>e.seq),tY.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})=>{ed(t=>ek(t,e)),(0,N.mergeCachedMessages)(t,e,null,x).catch(()=>{})}).catch(()=>{});tV.current&&clearInterval(tV.current),tV.current=null,tU.current&&clearTimeout(tU.current),tU.current=setTimeout(()=>{(0,b.markInboxRead)(t,x).then(()=>t7.current()).catch(()=>{})},1e3);let a=!tG.current&&tQ.current;try{let[e,a]=await Promise.all([(0,b.listMessages)(t,x),(0,b.listArtifacts)(t,x).catch(()=>null)]);ed(t=>ek(t,e.messages)),(0,N.mergeCachedMessages)(t,e.messages,null,x).catch(()=>{}),a&&eL(a),ey(s)}catch{ey(s),M.toast.error("Failed to refresh messages")}a&&requestAnimationFrame(()=>{tO.current?.scrollTo({top:tO.current.scrollHeight,behavior:"smooth"})}),setTimeout(async()=>{if(!tV.current)try{let[s,a]=await Promise.all([(0,b.getActiveTask)(t,x),(0,b.listBufferedMessages)(t,x)]);if(tl(a),s&&s.id!==e){let{messages:e}=await (0,b.listMessages)(t,x);ed(t=>ek(t,e)),(0,N.mergeCachedMessages)(t,e,null,x).catch(()=>{}),ey(s),eT([]),t0.current?.(s.id,t)}}catch{}},1e3)}else n||ey(s)}catch{if(tX.current!==e)return;tK.current+=1,tK.current>=3&&eA(!0),tK.current>=10&&(tV.current&&clearInterval(tV.current),tV.current=null,M.toast.error("Lost connection to agent"))}},3e3)},[x]);(0,s.useEffect)(()=>{t0.current=su},[su]),(0,s.useEffect)(()=>()=>{tV.current&&clearInterval(tV.current),tU.current&&clearTimeout(tU.current)},[]);let sm=(0,s.useRef)(null);(0,s.useEffect)(()=>{sm.current=ev?.id??null},[ev]),(0,s.useEffect)(()=>H(e=>{if("task.messages"===e.type&&e.taskId===sm.current){let t=e.messages.filter(e=>e.seq>tY.current);t.length>0&&(eT(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}),tY.current=Math.max(...t.map(e=>e.seq),tY.current))}if("task.created"===e.type&&e.conversationId===ei?.id){(0,b.listMessages)(e.conversationId,x).then(({messages:t})=>{ed(e=>ek(e,t)),(0,N.mergeCachedMessages)(e.conversationId,t,null,x).catch(()=>{})}).catch(()=>{});let t=e.task;sm.current=t.id,ey(t),eT([]),tY.current=0,t0.current?.(t.id,e.conversationId)}if("conversation.message"===e.type&&e.conversationId===ei?.id&&(ed(t=>ek(t,[e.message])),(0,N.appendCachedMessage)(e.conversationId,e.message,x).catch(()=>{})),"task.updated"===e.type&&e.taskId===sm.current&&ey(t=>t?{...t,status:e.status}:t),"artifact.uploaded"===e.type&&e.conversationId===ei?.id&&eL(t=>t.some(t=>t.id===e.artifact.id)?t:[...t,e.artifact]),"followup.dispatched"===e.type&&e.conversationId===ei?.id){tl(t=>t.filter(t=>t.id!==e.message.id)),(0,b.listBufferedMessages)(e.conversationId,x).then(tl).catch(()=>{}),(0,b.listMessages)(e.conversationId,x).then(({messages:t})=>{ed(e=>ek(e,t)),(0,N.mergeCachedMessages)(e.conversationId,t,null,x).catch(()=>{})}).catch(()=>{});let t=e.task;sm.current=t.id,ey(t),eT([]),t0.current?.(t.id,e.conversationId)}"followup.created"===e.type&&e.conversationId===ei?.id&&tl(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===ei?.id&&tl(t=>t.filter(t=>t.id!==e.messageId)),"followup.dispatch_failed"===e.type&&e.conversationId===ei?.id&&M.toast.error(e.error||"Failed to dispatch follow-up")}),[H,ei?.id,x]);let sh=(0,s.useCallback)(e=>{let t=e.target.files;if(!t)return;let s=[];for(let e of Array.from(t))e.size>0xa00000?M.toast.error(`"${e.name}" exceeds 10 MB limit`):s.push(e);s.length>0&&tn(e=>[...e,...s]),e.target.value=""},[]),sp=(0,s.useCallback)(e=>{tn(t=>t.filter((t,s)=>s!==e))},[]),sg=(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",sg),()=>document.removeEventListener("selectionchange",sg)),[sg]);let sf=(0,s.useCallback)(()=>{tw&&(tk(tw.text),tb(null),window.getSelection()?.removeAllRanges(),t4.current?.focus())},[tw]),[sx,sv]=(0,s.useState)(!1),sj=(0,s.useRef)(0),sy=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sj.current++,e.dataTransfer.types.includes("Files")&&sv(!0)},[]),sk=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sj.current--,0===sj.current&&sv(!1)},[]),sw=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation()},[]),sb=(0,s.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),sv(!1),sj.current=0;let t=Array.from(e.dataTransfer.files),s=[];for(let e of t)e.size>0xa00000?M.toast.error(`"${e.name}" exceeds 10 MB limit`):s.push(e);s.length>0&&tn(e=>[...e,...s])},[]),sN=(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?M.toast.error(`"${e.name}" exceeds 10 MB limit`):a.push(e);a.length>0&&tn(e=>[...e,...a])},[]),sC=async()=>{if(ei&&!ef){ex(!0);try{let e=await (0,b.cancelActiveTask)(ei.id,x);if(e){if(sm.current&&sm.current!==e.id)return;tV.current&&clearInterval(tV.current),tV.current=null;let[t,s]=await Promise.all([(0,b.listMessages)(ei.id,x),(0,b.listBufferedMessages)(ei.id,x)]);ed(e=>ek(e,t.messages)),(0,N.mergeCachedMessages)(ei.id,t.messages,null,x).catch(()=>{}),tl(s),ey(e),eT([])}}catch{M.toast.error("Failed to cancel task")}finally{ex(!1)}}},s_=async()=>{let e=eu.trim();if(!e&&0===ta.length||ep||!ei)return;if(!e)return void M.toast.error("Please type a message");let t=ty?`> ${ty.split("\n").join("\n> ")}
|
|
2
|
+
|
|
3
|
+
${e}`:e,s=[...ta];if(em(""),tn([]),tk(null),eg(!0),ev&&!["completed","failed","cancelled","superseded"].includes(ev.status)){let e=`temp-${Date.now()}`,a={id:e,conversation_id:ei.id,role:"user",content:t,task_id:null,attachment_ids:null,status:"buffered",created_at:new Date().toISOString()};tl(e=>[...e,a]);try{let{message:a}=await (0,b.createBufferedMessage)(ei.id,t,x,s.length>0?s:void 0);tl(t=>t.some(e=>e.id===a.id)?t.filter(t=>t.id!==e):t.map(t=>t.id===e?a:t))}catch(a){tl(t=>t.filter(t=>t.id!==e)),em(t),tn(s),M.toast.error(a instanceof Error?a.message:"Failed to queue follow-up")}finally{eg(!1)}return}let a=`temp-${Date.now()}`,n={id:a,conversation_id:ei.id,role:"user",content:t,task_id:null,attachment_ids:null,created_at:new Date().toISOString()};s.length>0&&tj(e=>{let t=new Map(e);return t.set(a,s),t}),ed(e=>[...e,n]),t8();try{let{message:e,task:r}=await (0,b.sendMessage)(ei.id,t,x,s.length>0?s:void 0);tj(e=>{if(!e.has(a))return e;let t=new Map(e);return t.delete(a),t}),ed(t=>t.map(t=>t.id===n.id?e:t)),e.attachment_ids&&e.attachment_ids.length>0&&(0,b.listArtifacts)(ei.id,x).then(e=>eL(e)).catch(()=>{}),ey(r),eT([]),su(r.id,ei.id)}catch(e){tj(e=>{if(!e.has(a))return e;let t=new Map(e);return t.delete(a),t}),ed(e=>e.filter(e=>e.id!==n.id)),em(t),tn(s),M.toast.error(e instanceof Error?e.message:"Failed to send message")}finally{eg(!1),t4.current?.focus()}},sS=(0,s.useCallback)(async()=>{if(!ev||!ei)return;let e=await (0,b.retryTask)(ev.id,x);ey(e),eT([]),su(e.id,ei.id)},[ev,ei,x,su]),sT=(0,s.useCallback)(async e=>{let t=t_.current.has(e);tC(s=>{let a=new Set(s);return t?a.delete(e):a.add(e),a}),t?(tT(),(0,b.unflagMessage)(x,e).then(()=>{tM()}).catch(()=>{tC(t=>new Set(t).add(e)),tS()})):(tS(),(0,b.flagMessage)(x,e).then(()=>{tM()}).catch(()=>{tC(t=>{let s=new Set(t);return s.delete(e),s}),tT()}))},[x,tS,tT,tM]),sM=(0,s.useCallback)(async e=>{e2(e),e0(!0),e6(!0),e7(null),te(null);try{let t=await (0,b.getIssue)(x,e);e3(t),t.issue.latest_task_id&&(0,b.getTask)(t.issue.latest_task_id,x).then(e=>te(e)).catch(()=>te(null)),t.issue.trace_id&&(0,b.getTrace)(t.issue.trace_id,x).then(e=>e7(e.tasks)).catch(()=>e7(null))}catch(e){M.toast.error(e instanceof Error?e.message:"Failed to load issue"),e0(!1)}finally{e6(!1)}},[x]),sI=e5?.issue?.conversation_id??null,sE=e5?.issue?.latest_task_id??null;(0,s.useEffect)(()=>{if(eG&&e1)return H(e=>{if("task.updated"===e.type&&sE&&e.taskId===sE&&(0,b.getTask)(sE,x).then(e=>te(e)).catch(()=>{}),"conversation.message"===e.type&&sI&&e.conversationId===sI&&(e3(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&&e3(e=>e?{...e,issue:{...e.issue,status:t[1]}}:e)}"issue.comment"===e.type&&e.issueId===e1&&e3(t=>!t||t.comments.some(t=>t.id===e.comment.id)?t:{...t,comments:[...t.comments,e.comment]})})},[eG,e1,sI,sE,x,H]);let[sA,sz]=(0,s.useState)(!1),sR=(0,s.useMemo)(()=>!!ei&&ec.some(e=>e.conversation_id===ei.id),[ei,ec]),sF=async()=>{if(ei&&sR&&!sA){sz(!0);try{tV.current&&(clearInterval(tV.current),tV.current=null);let e=await (0,b.createConversation)(ea,x,Y);tp(t=>[...t,{agentName:st,created_at:e.created_at,id:`nap-${ei.id}`}]),td(e=>[{id:ei.id,created_at:ei.created_at},...e]),eo(e),ey(null),eT([]),eL([]),tl([]),tn([]),tj(new Map),tY.current=0,eA(!1),eR(!1),t1.current=null,t8()}catch{M.toast.error("Failed to start new conversation")}finally{sz(!1)}}},sD=!!ev&&!["completed","failed","cancelled","superseded"].includes(ev.status);return eM?(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)(I.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)(I.Skeleton,{className:"h-4 w-72"}),(0,t.jsx)(I.Skeleton,{className:"h-4 w-56"}),(0,t.jsx)(I.Skeleton,{className:"h-4 w-64"})]})}),(0,t.jsx)("div",{className:"flex justify-end",children:(0,t.jsx)(I.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)(I.Skeleton,{className:"h-4 w-64"}),(0,t.jsx)(I.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)(I.Skeleton,{className:"h-18 w-full rounded-xl"})})})]}):eM||ei||0!==ec.length?(0,t.jsxs)(t.Fragment,{children:[tw&&(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:tw.x,top:tw.y,transform:"translate(-100%, -100%)"},onMouseDown:e=>e.preventDefault(),onClick:sf,children:[(0,t.jsx)(P,{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:tO,onScroll:sd,onClick:e=>{e.target.closest('[data-streamdown="code-block-actions"] button')&&M.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:[ei&&sc&&!eF&&(0,t.jsx)("div",{className:"flex justify-center py-2",children:(0,t.jsx)("button",{onClick:()=>so(),className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"Load earlier messages"})}),eF&&(0,t.jsx)("div",{className:"flex justify-center py-2",children:(0,t.jsx)(g.Loader2,{className:"size-4 animate-spin text-muted-foreground"})}),0===ec.length&&!ev&&(u=j.find(e=>e.id===ea),m=u?.created_at&&tx-new Date(u.created_at).getTime()<3e5,h=(k[ea]??0)>0,m&&h&&"default"===Y?(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."})),t$.map(e=>{if("nap"===e.kind)return(0,t.jsx)(eN,{agentName:st},e.data.id);if("artifact"===e.kind)return(0,t.jsx)(eC,{artifact:e.data,version:tD.get(e.data.id)??1,hasDuplicates:tP.has(e.data.filename),onClick:tW},`artifact-${e.data.id}`);let s=e.data;return(0,t.jsx)(eh,{msg:s,agents:j,artifacts:eP,activeTask:ev,taskMessages:eS,connectionLost:eE,isLastMessage:ec.length>0&&ec[ec.length-1].id===s.id,stepCount:s.task_id?tg[s.task_id]??0:0,targetConvId:el,workspaceId:x,conversationType:ei?.type,pendingFilesByMessage:tv,onArtifactClick:tW,onEmailClick:e=>{eY(e),eU(!0)},onCalendarEventClick:e=>{eQ(e),eJ(!0)},onIssueClick:e=>sM(e),onRetry:sS,mentionComponents:ej,isFlagged:tN.has(s.id),onToggleFlag:"assistant"===s.role?sT:void 0},s.id)}),ev&&ev.conversation_id===ei?.id&&!["completed","failed","cancelled","superseded"].includes(ev.status)&&(0,t.jsx)(w,{task:ev,messages:eS,connectionLost:eE})]})}),(0,t.jsx)(es.ScrollToBottomButton,{scrollRef:tO})]}),ei&&(0,t.jsx)(et,{bufferedMessages:tr,onDelete:e=>{tl(t=>t.filter(t=>t.id!==e)),(0,b.deleteBufferedMessage)(ei.id,e,x).catch(()=>{tl(tr),M.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",ep&&"opacity-50",sx&&"border-ring ring-3 ring-ring/50"),onDragEnter:sy,onDragLeave:sk,onDragOver:sw,onDrop:sb,children:[sx&&(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"})}),ty&&(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)(P,{className:"size-3.5 shrink-0 mt-0.5 text-muted-foreground"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground truncate",children:[ty.slice(0,120),ty.length>120?"...":""]})]}),(0,t.jsx)("button",{type:"button",onClick:()=>tk(null),className:"shrink-0 p-0.5 rounded-sm hover:bg-muted-foreground/20 transition-colors text-muted-foreground",children:(0,t.jsx)($.X,{className:"size-3.5"})})]}),(0,t.jsx)(O,{isOpen:t6.isOpen,relatedAgents:t6.relatedAgents,otherAgents:t6.otherAgents,selectedIndex:t6.selectedIndex,onSelect:t6.selectAgent,anchorPos:t6.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:eu?U(eu.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),j).replace(/<mention[^>]*>/g,'<span class="mention-highlight">').replace(/<\/mention>/g,"</span>")+(eu.endsWith("\n")?"\n":""):""}}),(0,t.jsx)("textarea",{ref:t4,value:eu,onChange:e=>{em(e.target.value),to(e.target.selectionStart),requestAnimationFrame(()=>{let t=e.target.previousElementSibling;t&&(t.scrollTop=e.target.scrollTop)})},onKeyDown:e=>{!t6.handleMentionKeyDown(e)&&("Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),s_()))},onPaste:sN,onKeyUp:e=>to(e.target.selectionStart),onClick:e=>to(e.target.selectionStart),onSelect:e=>to(e.target.selectionStart),onScroll:e=>{let t=e.target.previousElementSibling;t&&(t.scrollTop=e.target.scrollTop)},placeholder:sD?"Type a follow-up...":"Type a message...",rows:1,disabled:ep,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")})]}),ta.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 px-3.5 pb-1",children:ta.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,X.formatSize)(e.size)}),(0,t.jsx)("button",{type:"button",onClick:()=>sp(s),className:"ml-0.5 rounded-sm p-0.5 hover:bg-muted-foreground/20 transition-colors",children:(0,t.jsx)($.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:[!el&&(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.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:sF,disabled:sA||!ei||!sR||sD,className:"rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200",children:sA?(0,t.jsx)(g.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(z,{className:"size-3.5"})})})}),(0,t.jsx)(E.TooltipContent,{side:"top",children:sD?"Wait for the task to finish":sR?"Take a nap":`${st} is well-rested and ready to go`})]}),(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsxs)(E.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onClick:()=>{eO("agent"),eq(!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"}),tF.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:tF.length})]}),(0,t.jsx)(E.TooltipContent,{side:"top",children:"Artifacts"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsx)("input",{ref:t3,type:"file",multiple:!0,className:"hidden",onChange:sh}),(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onPointerDown:e=>e.preventDefault(),onClick:()=>t3.current?.click(),disabled:ep,className:"rounded-lg text-muted-foreground/60 hover:text-foreground transition-colors duration-200"}),children:(0,t.jsx)(B.Paperclip,{className:"size-3.5"})}),(0,t.jsx)(E.TooltipContent,{side:"top",children:"Attach files"})]}),tz&&(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{render:(0,t.jsx)(l.Button,{variant:"ghost",size:"icon-sm",onPointerDown:e=>e.preventDefault(),onClick:tR,disabled:ep,className:(0,o.cn)("rounded-lg transition-colors duration-200",tA?"text-red-500 hover:text-red-600 bg-red-500/10":"text-muted-foreground/60 hover:text-foreground")}),children:(0,t.jsx)(L,{className:(0,o.cn)("size-3.5",tA&&"animate-pulse")})}),(0,t.jsx)(E.TooltipContent,{side:"top",children:tA?"Stop recording":"Voice input"})]}),!sD||eu.trim()||ep?(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{render:(0,t.jsx)(l.Button,{size:"icon-sm",onClick:s_,disabled:!eu.trim()||ep,className:(0,o.cn)("rounded-lg transition-opacity duration-200",!eu.trim()&&"opacity-40")}),children:ep?(0,t.jsx)(g.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(A.ArrowUp,{className:"size-3.5"})}),(0,t.jsx)(E.TooltipContent,{side:"top",children:"Send"})]}):(0,t.jsxs)(E.Tooltip,{children:[(0,t.jsx)(E.TooltipTrigger,{render:(0,t.jsx)(l.Button,{size:"icon-sm",onClick:sC,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)(g.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(q.Square,{className:"size-3.5 fill-current"})}),(0,t.jsx)(E.TooltipContent,{side:"top",children:"Stop task"})]})]})]})]})})}),(0,t.jsx)(X.ArtifactSheet,{open:eB,onOpenChange:e=>{eq(e),e||setTimeout(()=>{eW(null),eO(null)},300)},artifacts:tL,workspaceId:x,initialArtifact:e$,versionMap:tB,duplicateFilenames:tq}),(0,t.jsx)(J,{open:eV,onOpenChange:e=>{eU(e),e||setTimeout(()=>eY(null),300)},emailId:eX,workspaceId:x}),(0,t.jsx)(Q,{open:eK,onOpenChange:e=>{eJ(e),e||setTimeout(()=>eQ(null),300)},calendarEventId:eZ,workspaceId:x}),(0,t.jsx)(G.IssueSheet,{open:eG,onOpenChange:e=>{e0(e),e||setTimeout(()=>{e2(null),e3(null),te(null)},300)},agents:j,issue:e5?.issue??null,detail:e5?{messages:e5.messages,comments:e5.comments,artifacts:e5.artifacts,traceId:e5.issue.trace_id}:null,detailLoading:e4,activeTask:e9,traceTasks:e8,slug:v,workspaceId:x,width:tt,onWidthChange:ts,onUpdate:async(e,t)=>{try{let s=await (0,b.updateIssue)(x,e,t);e3(a=>a&&a.issue.id===e?{...a,issue:{...a.issue,...t,updated_at:s.updated_at}}:a)}catch(e){M.toast.error(e instanceof Error?e.message:"Failed to update issue")}},onStatusChange:async(e,t)=>{try{await (0,b.updateIssue)(x,e,{status:t}),e3(s=>s&&s.issue.id===e?{...s,issue:{...s.issue,status:t}}:s)}catch(e){M.toast.error(e instanceof Error?e.message:"Failed to update status")}},onCommented:()=>{e1&&sM(e1)},onArtifactClick:tH})]}):(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Failed to load conversation"})}}]);
|