agent-relay-server 0.35.2 → 0.35.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/docs/openapi.json +1 -1
  2. package/package.json +1 -1
  3. package/public/assets/{activity-WjOShx3N.js → activity-CPuZGkeP.js} +2 -2
  4. package/public/assets/{activity-WjOShx3N.js.map → activity-CPuZGkeP.js.map} +1 -1
  5. package/public/assets/{agents-Cihuuoxa.js → agents-Bz4eJ4zH.js} +2 -2
  6. package/public/assets/{agents-Cihuuoxa.js.map → agents-Bz4eJ4zH.js.map} +1 -1
  7. package/public/assets/{analytics-B5_HS2Lt.js → analytics-inmkBD_j.js} +2 -2
  8. package/public/assets/{analytics-B5_HS2Lt.js.map → analytics-inmkBD_j.js.map} +1 -1
  9. package/public/assets/{automation-CoOe2nEA.js → automation-DRN2lcqQ.js} +2 -2
  10. package/public/assets/{automation-CoOe2nEA.js.map → automation-DRN2lcqQ.js.map} +1 -1
  11. package/public/assets/chat-Dn3TEhl0.js +2 -0
  12. package/public/assets/chat-Dn3TEhl0.js.map +1 -0
  13. package/public/assets/display-Bebqs1qu.js.map +1 -1
  14. package/public/assets/{formatted-body-impl-DhCblnWM.js → formatted-body-impl-DP9iZsd4.js} +2 -2
  15. package/public/assets/{formatted-body-impl-DhCblnWM.js.map → formatted-body-impl-DP9iZsd4.js.map} +1 -1
  16. package/public/assets/{index-CvSlyTSI.js → index-BL8r94_U.js} +5 -5
  17. package/public/assets/{index-CvSlyTSI.js.map → index-BL8r94_U.js.map} +1 -1
  18. package/public/assets/{maintenance-CUxxVXsc.js → maintenance-DtfpsMZa.js} +2 -2
  19. package/public/assets/{maintenance-CUxxVXsc.js.map → maintenance-DtfpsMZa.js.map} +1 -1
  20. package/public/assets/{managed-agents-VZEeMMSP.js → managed-agents-C5pzetBh.js} +2 -2
  21. package/public/assets/{managed-agents-VZEeMMSP.js.map → managed-agents-C5pzetBh.js.map} +1 -1
  22. package/public/assets/{markdown-preview-impl-Bbwmbxvn.js → markdown-preview-impl-4s9YDGM7.js} +2 -2
  23. package/public/assets/{markdown-preview-impl-Bbwmbxvn.js.map → markdown-preview-impl-4s9YDGM7.js.map} +1 -1
  24. package/public/assets/{memory-BQAC3YmR.js → memory-BWfDbph3.js} +2 -2
  25. package/public/assets/{memory-BQAC3YmR.js.map → memory-BWfDbph3.js.map} +1 -1
  26. package/public/assets/{messages-_sdHV42k.js → messages-C8cP25kp.js} +2 -2
  27. package/public/assets/{messages-_sdHV42k.js.map → messages-C8cP25kp.js.map} +1 -1
  28. package/public/assets/{orchestrators-BkHHgd83.js → orchestrators-Clu8MNKo.js} +2 -2
  29. package/public/assets/{orchestrators-BkHHgd83.js.map → orchestrators-Clu8MNKo.js.map} +1 -1
  30. package/public/assets/{overview-CYAHOUyA.js → overview-CXcGh2D6.js} +2 -2
  31. package/public/assets/{overview-CYAHOUyA.js.map → overview-CXcGh2D6.js.map} +1 -1
  32. package/public/assets/{pairs-BvMH1CS7.js → pairs-eOZl_lQn.js} +2 -2
  33. package/public/assets/{pairs-BvMH1CS7.js.map → pairs-eOZl_lQn.js.map} +1 -1
  34. package/public/assets/{security-Dsdr3lSX.js → security-CA03sHyP.js} +2 -2
  35. package/public/assets/{security-Dsdr3lSX.js.map → security-CA03sHyP.js.map} +1 -1
  36. package/public/assets/{settings-DlovIWdE.js → settings-KTOwGJiW.js} +2 -2
  37. package/public/assets/{settings-DlovIWdE.js.map → settings-KTOwGJiW.js.map} +1 -1
  38. package/public/assets/{tasks-Cgan8Oqb.js → tasks-D6jbr2y6.js} +2 -2
  39. package/public/assets/{tasks-Cgan8Oqb.js.map → tasks-D6jbr2y6.js.map} +1 -1
  40. package/public/assets/{terminal-viewer-impl-DVW-LRbz.js → terminal-viewer-impl-DFODXxpG.js} +2 -2
  41. package/public/assets/{terminal-viewer-impl-DVW-LRbz.js.map → terminal-viewer-impl-DFODXxpG.js.map} +1 -1
  42. package/public/assets/{work-queue-B4CifZKH.js → work-queue-BWWckTVy.js} +2 -2
  43. package/public/assets/{work-queue-B4CifZKH.js.map → work-queue-BWWckTVy.js.map} +1 -1
  44. package/public/index.html +1 -1
  45. package/runner/src/adapter.ts +3 -1
  46. package/src/mcp.ts +28 -8
  47. package/public/assets/chat-0ZbxHlDu.js +0 -2
  48. package/public/assets/chat-0ZbxHlDu.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{Zt as e,at as t,cn as n,i as r,kn as i}from"./lucide-react-CD8Xl2U3.js";import{i as a,t as o}from"./store-CICRhg1m.js";import{at as s,u as c,z as l}from"./display-Bebqs1qu.js";import{t as u}from"./badge-t8zAwHW9.js";import{t as d}from"./button-DDA5P2YQ.js";import{M as f,R as p,s as m}from"./index-CvSlyTSI.js";import{n as h,t as g}from"./card-CggxP1h9.js";var _=i(),v={open:`bg-blue-500/10 text-blue-400 border-blue-500/20`,blocked:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,claimed:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,in_progress:`bg-purple-500/10 text-purple-400 border-purple-500/20`};function y(){let e=a(),n=o(e=>e.agentsById),r=o(e=>e.compose),i=o(e=>e.set),s=o(e=>e.doClaimTask),l=o(e=>e.doClaim),d=o(e=>e.openTaskEvents),h=o(e=>e.showError),g=o(e=>e.openConfirm),v=o(e=>e.doDeleteMessage),y=o(e=>e.doUpdateTaskStatus),x=f(),S=p(),C=S.filter(e=>e.claimable).length;function w(e){if(!r.from){h(`Validation`,`Select a "Claim as" agent first.`);return}e.sourceType===`task`&&e.task?s(e.task.id):e.sourceType===`message`&&e.message&&l(e.message.id)}function T(e){g(`Cancel Item`,`Cancel "${e.title||(e.sourceType===`task`?`Task #${e.id}`:`Message #${e.id}`)}"? This cannot be undone.`,()=>{e.sourceType===`task`&&e.task?y(e.task,`canceled`):e.sourceType===`message`&&e.message&&v(e.message.id)})}function E(e){e.task&&d(e.task)}return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(t,{className:`w-5 h-5 text-muted-foreground`}),(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Work Queue`}),C>0&&(0,_.jsxs)(u,{className:`bg-orange-500/20 text-orange-400 border-orange-500/30 border`,children:[C,` claimable`]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`label`,{className:`text-xs text-muted-foreground shrink-0`,children:`Claim as`}),(0,_.jsxs)(`select`,{className:`rounded-md border border-input bg-background px-3 py-1.5 text-sm`,value:r.from,onChange:e=>i({compose:{...r,from:e.target.value}}),children:[(0,_.jsx)(`option`,{value:``,children:`Select agent...`}),x.map(e=>(0,_.jsx)(`option`,{value:e.id,children:c(e)},e.id))]})]})]}),(0,_.jsx)(m,{className:`h-[calc(100dvh-11rem)]`,children:(0,_.jsxs)(`div`,{className:`space-y-2 pr-2`,children:[S.length===0&&(0,_.jsx)(`div`,{className:`text-center text-muted-foreground py-16 text-sm`,children:`Work queue is empty`}),S.map(t=>(0,_.jsx)(b,{item:t,now:e,agentName:e=>n[e]?c(n[e]):e.slice(-10),onClaim:()=>w(t),onCancel:()=>T(t),onEvents:t.task?()=>E(t):void 0},t.id))]})})]})}function b({item:t,now:i,agentName:a,onClaim:o,onCancel:c,onEvents:f}){let p=s[t.severity]||s.info,m=v[t.status]||`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`;return(0,_.jsx)(g,{className:t.claimable?`ring-1 ring-orange-500/30`:``,children:(0,_.jsx)(h,{className:`p-3`,children:(0,_.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1`,children:[(0,_.jsx)(`span`,{className:`font-medium text-sm truncate`,children:t.title}),(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border ${p}`,children:t.severity}),(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border ${m}`,children:t.status}),t.sourceType===`message`&&(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border border-zinc-500/20 text-zinc-400`,children:`msg`})]}),t.body&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2 mb-2`,children:t.body}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[t.owner&&(0,_.jsxs)(`span`,{title:`Owner`,children:[(0,_.jsx)(e,{className:`w-3 h-3 inline mr-1`}),a(t.owner)]}),t.source&&(0,_.jsx)(`span`,{className:`font-mono`,children:t.source}),(0,_.jsxs)(`span`,{title:String(t.updatedAt),children:[(0,_.jsx)(n,{className:`w-3 h-3 inline mr-1`}),l(i,t.updatedAt)]})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-1 shrink-0`,children:[t.claimable&&(0,_.jsxs)(d,{size:`sm`,className:`h-7 text-xs bg-orange-600 hover:bg-orange-700 text-white`,onClick:o,children:[(0,_.jsx)(e,{className:`w-3.5 h-3.5 mr-1`}),` Claim`]}),f&&(0,_.jsx)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:f,children:`Events`}),(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 border-red-500/20`,onClick:c,children:[(0,_.jsx)(r,{className:`w-3.5 h-3.5 mr-1`}),` Cancel`]})]})]})})})}export{y as WorkQueueView};
2
- //# sourceMappingURL=work-queue-B4CifZKH.js.map
1
+ import{Zt as e,at as t,cn as n,i as r,kn as i}from"./lucide-react-CD8Xl2U3.js";import{i as a,t as o}from"./store-CICRhg1m.js";import{at as s,u as c,z as l}from"./display-Bebqs1qu.js";import{t as u}from"./badge-t8zAwHW9.js";import{t as d}from"./button-DDA5P2YQ.js";import{M as f,R as p,s as m}from"./index-BL8r94_U.js";import{n as h,t as g}from"./card-CggxP1h9.js";var _=i(),v={open:`bg-blue-500/10 text-blue-400 border-blue-500/20`,blocked:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,claimed:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,in_progress:`bg-purple-500/10 text-purple-400 border-purple-500/20`};function y(){let e=a(),n=o(e=>e.agentsById),r=o(e=>e.compose),i=o(e=>e.set),s=o(e=>e.doClaimTask),l=o(e=>e.doClaim),d=o(e=>e.openTaskEvents),h=o(e=>e.showError),g=o(e=>e.openConfirm),v=o(e=>e.doDeleteMessage),y=o(e=>e.doUpdateTaskStatus),x=f(),S=p(),C=S.filter(e=>e.claimable).length;function w(e){if(!r.from){h(`Validation`,`Select a "Claim as" agent first.`);return}e.sourceType===`task`&&e.task?s(e.task.id):e.sourceType===`message`&&e.message&&l(e.message.id)}function T(e){g(`Cancel Item`,`Cancel "${e.title||(e.sourceType===`task`?`Task #${e.id}`:`Message #${e.id}`)}"? This cannot be undone.`,()=>{e.sourceType===`task`&&e.task?y(e.task,`canceled`):e.sourceType===`message`&&e.message&&v(e.message.id)})}function E(e){e.task&&d(e.task)}return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(t,{className:`w-5 h-5 text-muted-foreground`}),(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Work Queue`}),C>0&&(0,_.jsxs)(u,{className:`bg-orange-500/20 text-orange-400 border-orange-500/30 border`,children:[C,` claimable`]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`label`,{className:`text-xs text-muted-foreground shrink-0`,children:`Claim as`}),(0,_.jsxs)(`select`,{className:`rounded-md border border-input bg-background px-3 py-1.5 text-sm`,value:r.from,onChange:e=>i({compose:{...r,from:e.target.value}}),children:[(0,_.jsx)(`option`,{value:``,children:`Select agent...`}),x.map(e=>(0,_.jsx)(`option`,{value:e.id,children:c(e)},e.id))]})]})]}),(0,_.jsx)(m,{className:`h-[calc(100dvh-11rem)]`,children:(0,_.jsxs)(`div`,{className:`space-y-2 pr-2`,children:[S.length===0&&(0,_.jsx)(`div`,{className:`text-center text-muted-foreground py-16 text-sm`,children:`Work queue is empty`}),S.map(t=>(0,_.jsx)(b,{item:t,now:e,agentName:e=>n[e]?c(n[e]):e.slice(-10),onClaim:()=>w(t),onCancel:()=>T(t),onEvents:t.task?()=>E(t):void 0},t.id))]})})]})}function b({item:t,now:i,agentName:a,onClaim:o,onCancel:c,onEvents:f}){let p=s[t.severity]||s.info,m=v[t.status]||`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`;return(0,_.jsx)(g,{className:t.claimable?`ring-1 ring-orange-500/30`:``,children:(0,_.jsx)(h,{className:`p-3`,children:(0,_.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1`,children:[(0,_.jsx)(`span`,{className:`font-medium text-sm truncate`,children:t.title}),(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border ${p}`,children:t.severity}),(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border ${m}`,children:t.status}),t.sourceType===`message`&&(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border border-zinc-500/20 text-zinc-400`,children:`msg`})]}),t.body&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2 mb-2`,children:t.body}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[t.owner&&(0,_.jsxs)(`span`,{title:`Owner`,children:[(0,_.jsx)(e,{className:`w-3 h-3 inline mr-1`}),a(t.owner)]}),t.source&&(0,_.jsx)(`span`,{className:`font-mono`,children:t.source}),(0,_.jsxs)(`span`,{title:String(t.updatedAt),children:[(0,_.jsx)(n,{className:`w-3 h-3 inline mr-1`}),l(i,t.updatedAt)]})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-1 shrink-0`,children:[t.claimable&&(0,_.jsxs)(d,{size:`sm`,className:`h-7 text-xs bg-orange-600 hover:bg-orange-700 text-white`,onClick:o,children:[(0,_.jsx)(e,{className:`w-3.5 h-3.5 mr-1`}),` Claim`]}),f&&(0,_.jsx)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:f,children:`Events`}),(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 border-red-500/20`,onClick:c,children:[(0,_.jsx)(r,{className:`w-3.5 h-3.5 mr-1`}),` Cancel`]})]})]})})})}export{y as WorkQueueView};
2
+ //# sourceMappingURL=work-queue-BWWckTVy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"work-queue-B4CifZKH.js","names":[],"sources":["../../dashboard/src/components/views/work-queue.tsx"],"sourcesContent":["import { useRelayStore, useNow } from '@/store'\nimport { useWorkQueueItems, useComposeAgents } from '@/hooks/use-selectors'\nimport { Card, CardContent } from '@/components/ui/card'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { ScrollArea } from '@/components/ui/scroll-area'\nimport { ListChecks, CheckCircle2, Calendar, X } from 'lucide-react'\nimport { displayName, timeAgo } from '@/lib/display'\nimport { SEVERITY_COLORS } from '@/lib/constants'\nimport type { WorkQueueItem } from '@/types'\n\nconst STATUS_COLORS: Record<string, string> = {\n open: 'bg-blue-500/10 text-blue-400 border-blue-500/20',\n blocked: 'bg-yellow-500/10 text-yellow-400 border-yellow-500/20',\n claimed: 'bg-emerald-500/10 text-emerald-400 border-emerald-500/20',\n in_progress: 'bg-purple-500/10 text-purple-400 border-purple-500/20',\n}\n\nexport function WorkQueueView() {\n const now = useNow()\n const agentsById = useRelayStore((s) => s.agentsById)\n const compose = useRelayStore((s) => s.compose)\n const set = useRelayStore((s) => s.set)\n const doClaimTask = useRelayStore((s) => s.doClaimTask)\n const doClaim = useRelayStore((s) => s.doClaim)\n const openTaskEvents = useRelayStore((s) => s.openTaskEvents)\n const showError = useRelayStore((s) => s.showError)\n const openConfirm = useRelayStore((s) => s.openConfirm)\n const doDeleteMessage = useRelayStore((s) => s.doDeleteMessage)\n const doUpdateTaskStatus = useRelayStore((s) => s.doUpdateTaskStatus)\n\n const composeAgents = useComposeAgents()\n const items = useWorkQueueItems()\n\n const claimableCount = items.filter((i) => i.claimable).length\n\n function handleClaim(item: WorkQueueItem) {\n if (!compose.from) { showError('Validation', 'Select a \"Claim as\" agent first.'); return }\n if (item.sourceType === 'task' && item.task) doClaimTask(item.task.id)\n else if (item.sourceType === 'message' && item.message) doClaim(item.message.id)\n }\n\n function handleCancel(item: WorkQueueItem) {\n const label = item.title || (item.sourceType === 'task' ? `Task #${item.id}` : `Message #${item.id}`)\n openConfirm('Cancel Item', `Cancel \"${label}\"? This cannot be undone.`, () => {\n if (item.sourceType === 'task' && item.task) doUpdateTaskStatus(item.task, 'canceled')\n else if (item.sourceType === 'message' && item.message) doDeleteMessage(item.message.id)\n })\n }\n\n function handleEvents(item: WorkQueueItem) {\n if (item.task) openTaskEvents(item.task)\n }\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex items-center justify-between flex-wrap gap-2\">\n <div className=\"flex items-center gap-2\">\n <ListChecks className=\"w-5 h-5 text-muted-foreground\" />\n <h2 className=\"text-lg font-semibold\">Work Queue</h2>\n {claimableCount > 0 && (\n <Badge className=\"bg-orange-500/20 text-orange-400 border-orange-500/30 border\">\n {claimableCount} claimable\n </Badge>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n <label className=\"text-xs text-muted-foreground shrink-0\">Claim as</label>\n <select\n className=\"rounded-md border border-input bg-background px-3 py-1.5 text-sm\"\n value={compose.from}\n onChange={(e) => set({ compose: { ...compose, from: e.target.value } })}\n >\n <option value=\"\">Select agent...</option>\n {composeAgents.map((a) => <option key={a.id} value={a.id}>{displayName(a)}</option>)}\n </select>\n </div>\n </div>\n\n <ScrollArea className=\"h-[calc(100dvh-11rem)]\">\n <div className=\"space-y-2 pr-2\">\n {items.length === 0 && (\n <div className=\"text-center text-muted-foreground py-16 text-sm\">Work queue is empty</div>\n )}\n {items.map((item) => (\n <WorkQueueCard\n key={item.id}\n item={item}\n now={now}\n agentName={(id) => agentsById[id] ? displayName(agentsById[id]) : id.slice(-10)}\n onClaim={() => handleClaim(item)}\n onCancel={() => handleCancel(item)}\n onEvents={item.task ? () => handleEvents(item) : undefined}\n />\n ))}\n </div>\n </ScrollArea>\n </div>\n )\n}\n\nfunction WorkQueueCard({\n item, now, agentName, onClaim, onCancel, onEvents,\n}: {\n item: WorkQueueItem\n now: number\n agentName: (id: string) => string\n onClaim: () => void\n onCancel: () => void\n onEvents?: () => void\n}) {\n const severityClass = SEVERITY_COLORS[item.severity] || SEVERITY_COLORS.info\n const statusClass = STATUS_COLORS[item.status] || 'bg-zinc-500/10 text-zinc-400 border-zinc-500/20'\n\n return (\n <Card className={item.claimable ? 'ring-1 ring-orange-500/30' : ''}>\n <CardContent className=\"p-3\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2 flex-wrap mb-1\">\n <span className=\"font-medium text-sm truncate\">{item.title}</span>\n <Badge variant=\"outline\" className={`text-xs px-1.5 py-0 border ${severityClass}`}>{item.severity}</Badge>\n <Badge variant=\"outline\" className={`text-xs px-1.5 py-0 border ${statusClass}`}>{item.status}</Badge>\n {item.sourceType === 'message' && (\n <Badge variant=\"outline\" className=\"text-xs px-1.5 py-0 border border-zinc-500/20 text-zinc-400\">msg</Badge>\n )}\n </div>\n {item.body && (\n <p className=\"text-xs text-muted-foreground line-clamp-2 mb-2\">{item.body}</p>\n )}\n <div className=\"flex items-center gap-3 text-xs text-muted-foreground flex-wrap\">\n {item.owner && (\n <span title=\"Owner\">\n <CheckCircle2 className=\"w-3 h-3 inline mr-1\" />{agentName(item.owner)}\n </span>\n )}\n {item.source && (\n <span className=\"font-mono\">{item.source}</span>\n )}\n <span title={String(item.updatedAt)}>\n <Calendar className=\"w-3 h-3 inline mr-1\" />{timeAgo(now, item.updatedAt)}\n </span>\n </div>\n </div>\n <div className=\"flex flex-col gap-1 shrink-0\">\n {item.claimable && (\n <Button size=\"sm\" className=\"h-7 text-xs bg-orange-600 hover:bg-orange-700 text-white\" onClick={onClaim}>\n <CheckCircle2 className=\"w-3.5 h-3.5 mr-1\" /> Claim\n </Button>\n )}\n {onEvents && (\n <Button size=\"sm\" variant=\"outline\" className=\"h-7 text-xs\" onClick={onEvents}>\n Events\n </Button>\n )}\n <Button size=\"sm\" variant=\"outline\" className=\"h-7 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 border-red-500/20\" onClick={onCancel}>\n <X className=\"w-3.5 h-3.5 mr-1\" /> Cancel\n </Button>\n </div>\n </div>\n </CardContent>\n </Card>\n )\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"work-queue-BWWckTVy.js","names":[],"sources":["../../dashboard/src/components/views/work-queue.tsx"],"sourcesContent":["import { useRelayStore, useNow } from '@/store'\nimport { useWorkQueueItems, useComposeAgents } from '@/hooks/use-selectors'\nimport { Card, CardContent } from '@/components/ui/card'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { ScrollArea } from '@/components/ui/scroll-area'\nimport { ListChecks, CheckCircle2, Calendar, X } from 'lucide-react'\nimport { displayName, timeAgo } from '@/lib/display'\nimport { SEVERITY_COLORS } from '@/lib/constants'\nimport type { WorkQueueItem } from '@/types'\n\nconst STATUS_COLORS: Record<string, string> = {\n open: 'bg-blue-500/10 text-blue-400 border-blue-500/20',\n blocked: 'bg-yellow-500/10 text-yellow-400 border-yellow-500/20',\n claimed: 'bg-emerald-500/10 text-emerald-400 border-emerald-500/20',\n in_progress: 'bg-purple-500/10 text-purple-400 border-purple-500/20',\n}\n\nexport function WorkQueueView() {\n const now = useNow()\n const agentsById = useRelayStore((s) => s.agentsById)\n const compose = useRelayStore((s) => s.compose)\n const set = useRelayStore((s) => s.set)\n const doClaimTask = useRelayStore((s) => s.doClaimTask)\n const doClaim = useRelayStore((s) => s.doClaim)\n const openTaskEvents = useRelayStore((s) => s.openTaskEvents)\n const showError = useRelayStore((s) => s.showError)\n const openConfirm = useRelayStore((s) => s.openConfirm)\n const doDeleteMessage = useRelayStore((s) => s.doDeleteMessage)\n const doUpdateTaskStatus = useRelayStore((s) => s.doUpdateTaskStatus)\n\n const composeAgents = useComposeAgents()\n const items = useWorkQueueItems()\n\n const claimableCount = items.filter((i) => i.claimable).length\n\n function handleClaim(item: WorkQueueItem) {\n if (!compose.from) { showError('Validation', 'Select a \"Claim as\" agent first.'); return }\n if (item.sourceType === 'task' && item.task) doClaimTask(item.task.id)\n else if (item.sourceType === 'message' && item.message) doClaim(item.message.id)\n }\n\n function handleCancel(item: WorkQueueItem) {\n const label = item.title || (item.sourceType === 'task' ? `Task #${item.id}` : `Message #${item.id}`)\n openConfirm('Cancel Item', `Cancel \"${label}\"? This cannot be undone.`, () => {\n if (item.sourceType === 'task' && item.task) doUpdateTaskStatus(item.task, 'canceled')\n else if (item.sourceType === 'message' && item.message) doDeleteMessage(item.message.id)\n })\n }\n\n function handleEvents(item: WorkQueueItem) {\n if (item.task) openTaskEvents(item.task)\n }\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex items-center justify-between flex-wrap gap-2\">\n <div className=\"flex items-center gap-2\">\n <ListChecks className=\"w-5 h-5 text-muted-foreground\" />\n <h2 className=\"text-lg font-semibold\">Work Queue</h2>\n {claimableCount > 0 && (\n <Badge className=\"bg-orange-500/20 text-orange-400 border-orange-500/30 border\">\n {claimableCount} claimable\n </Badge>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n <label className=\"text-xs text-muted-foreground shrink-0\">Claim as</label>\n <select\n className=\"rounded-md border border-input bg-background px-3 py-1.5 text-sm\"\n value={compose.from}\n onChange={(e) => set({ compose: { ...compose, from: e.target.value } })}\n >\n <option value=\"\">Select agent...</option>\n {composeAgents.map((a) => <option key={a.id} value={a.id}>{displayName(a)}</option>)}\n </select>\n </div>\n </div>\n\n <ScrollArea className=\"h-[calc(100dvh-11rem)]\">\n <div className=\"space-y-2 pr-2\">\n {items.length === 0 && (\n <div className=\"text-center text-muted-foreground py-16 text-sm\">Work queue is empty</div>\n )}\n {items.map((item) => (\n <WorkQueueCard\n key={item.id}\n item={item}\n now={now}\n agentName={(id) => agentsById[id] ? displayName(agentsById[id]) : id.slice(-10)}\n onClaim={() => handleClaim(item)}\n onCancel={() => handleCancel(item)}\n onEvents={item.task ? () => handleEvents(item) : undefined}\n />\n ))}\n </div>\n </ScrollArea>\n </div>\n )\n}\n\nfunction WorkQueueCard({\n item, now, agentName, onClaim, onCancel, onEvents,\n}: {\n item: WorkQueueItem\n now: number\n agentName: (id: string) => string\n onClaim: () => void\n onCancel: () => void\n onEvents?: () => void\n}) {\n const severityClass = SEVERITY_COLORS[item.severity] || SEVERITY_COLORS.info\n const statusClass = STATUS_COLORS[item.status] || 'bg-zinc-500/10 text-zinc-400 border-zinc-500/20'\n\n return (\n <Card className={item.claimable ? 'ring-1 ring-orange-500/30' : ''}>\n <CardContent className=\"p-3\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2 flex-wrap mb-1\">\n <span className=\"font-medium text-sm truncate\">{item.title}</span>\n <Badge variant=\"outline\" className={`text-xs px-1.5 py-0 border ${severityClass}`}>{item.severity}</Badge>\n <Badge variant=\"outline\" className={`text-xs px-1.5 py-0 border ${statusClass}`}>{item.status}</Badge>\n {item.sourceType === 'message' && (\n <Badge variant=\"outline\" className=\"text-xs px-1.5 py-0 border border-zinc-500/20 text-zinc-400\">msg</Badge>\n )}\n </div>\n {item.body && (\n <p className=\"text-xs text-muted-foreground line-clamp-2 mb-2\">{item.body}</p>\n )}\n <div className=\"flex items-center gap-3 text-xs text-muted-foreground flex-wrap\">\n {item.owner && (\n <span title=\"Owner\">\n <CheckCircle2 className=\"w-3 h-3 inline mr-1\" />{agentName(item.owner)}\n </span>\n )}\n {item.source && (\n <span className=\"font-mono\">{item.source}</span>\n )}\n <span title={String(item.updatedAt)}>\n <Calendar className=\"w-3 h-3 inline mr-1\" />{timeAgo(now, item.updatedAt)}\n </span>\n </div>\n </div>\n <div className=\"flex flex-col gap-1 shrink-0\">\n {item.claimable && (\n <Button size=\"sm\" className=\"h-7 text-xs bg-orange-600 hover:bg-orange-700 text-white\" onClick={onClaim}>\n <CheckCircle2 className=\"w-3.5 h-3.5 mr-1\" /> Claim\n </Button>\n )}\n {onEvents && (\n <Button size=\"sm\" variant=\"outline\" className=\"h-7 text-xs\" onClick={onEvents}>\n Events\n </Button>\n )}\n <Button size=\"sm\" variant=\"outline\" className=\"h-7 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 border-red-500/20\" onClick={onCancel}>\n <X className=\"w-3.5 h-3.5 mr-1\" /> Cancel\n </Button>\n </div>\n </div>\n </CardContent>\n </Card>\n )\n}\n"],"mappings":"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"}
package/public/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='6' fill='%2309090b'/%3E%3Ccircle cx='16' cy='16' r='4.5' fill='%2358a6ff'/%3E%3Ccircle cx='6' cy='8' r='2.5' fill='%233fb950'/%3E%3Ccircle cx='26' cy='8' r='2.5' fill='%233fb950'/%3E%3Ccircle cx='6' cy='24' r='2.5' fill='%233fb950'/%3E%3Ccircle cx='26' cy='24' r='2.5' fill='%233fb950'/%3E%3Cline x1='8' y1='9.5' x2='13' y2='14' stroke='%2330363d' stroke-width='1.5'/%3E%3Cline x1='24' y1='9.5' x2='19' y2='14' stroke='%2330363d' stroke-width='1.5'/%3E%3Cline x1='8' y1='22.5' x2='13' y2='18' stroke='%2330363d' stroke-width='1.5'/%3E%3Cline x1='24' y1='22.5' x2='19' y2='18' stroke='%2330363d' stroke-width='1.5'/%3E%3C/svg%3E">
13
13
  <link rel="manifest" href="manifest.webmanifest">
14
14
  <link rel="apple-touch-icon" href="icons/agent-relay-192.png">
15
- <script type="module" crossorigin src="./assets/index-CvSlyTSI.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-BL8r94_U.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="./assets/chunk-CilyBKbf.js">
17
17
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-DQVmg1Zk.js">
18
18
  <link rel="modulepreload" crossorigin href="./assets/lucide-react-CD8Xl2U3.js">
@@ -154,7 +154,9 @@ export interface ProviderAdapter {
154
154
  probeActivity?(process: ManagedProcess): Promise<"busy" | "idle" | "unknown">;
155
155
  terminalAttachSpec?(process: ManagedProcess): Promise<TerminalAttachSpec>;
156
156
  respondToPermissionDecision?(process: ManagedProcess, input: ProviderPermissionDecisionInput): Promise<Record<string, unknown> | void>;
157
- deliverInitialPrompt?(process: ManagedProcess, prompt: string): Promise<void>;
157
+ // `options.readyTimeoutMs` lets the runner widen the provider-ready wait for the
158
+ // first (cold-start) delivery vs. a fast re-attempt after a ready signal (#329).
159
+ deliverInitialPrompt?(process: ManagedProcess, prompt: string, options?: { readyTimeoutMs?: number }): Promise<void>;
158
160
  deliver(process: ManagedProcess, messages: Message[]): Promise<void>;
159
161
  onStatusChange(cb: (status: ProviderStatusUpdate) => void): void;
160
162
  // Subscribe to session-mirror events from providers that emit them directly
package/src/mcp.ts CHANGED
@@ -50,7 +50,7 @@ import type { ActivityKind, AgentCard, ArtifactKind, ArtifactSensitivity, Attach
50
50
  import { LAND_STRATEGIES, applyWorkspaceAction, waitForWorkspaceStatus, type WorkspaceAction } from "./workspace-actions";
51
51
  import { describeWorkspacePhase, landReceipt, readyContract, worktreeMcpInstructions } from "./workspace-phase";
52
52
  import { type ProviderEffort } from "agent-relay-sdk/provider-catalog";
53
- import { errMessage, isRecord, SPAWN_PROVIDERS, APPROVAL_MODES, VALID_EFFORTS, VALID_WORKSPACE_MODES } from "agent-relay-sdk";
53
+ import { errMessage, isRecord, stringValue, SPAWN_PROVIDERS, APPROVAL_MODES, VALID_EFFORTS, VALID_WORKSPACE_MODES } from "agent-relay-sdk";
54
54
  import { runnerRuntimeTokenEnv } from "./runtime-tokens";
55
55
 
56
56
  type JsonRpcId = string | number | null;
@@ -257,11 +257,11 @@ const TOOLS: ToolDefinition[] = [
257
257
  properties: {
258
258
  provider: { type: "string", enum: SPAWN_PROVIDERS },
259
259
  orchestratorId: { type: "string", description: "Target host. Defaults to the host that owns cwd, else YOUR OWN host — only set it to spawn onto a different machine." },
260
- cwd: { type: "string", description: "Working directory for the agent. Must resolve within the target orchestrator's base directory (enforced server-side)." },
260
+ cwd: { type: "string", description: "Working directory for the agent. Defaults to YOUR OWN cwd (the repo you're working in) when omitted, else the orchestrator's base dir. Must resolve within the target orchestrator's base directory (enforced server-side). NOTE: workspaceMode `isolated` requires a git repo — the resolved cwd must be inside one or the spawn is rejected." },
261
261
  label: { type: "string" },
262
262
  model: { type: "string" },
263
263
  effort: { type: "string", enum: VALID_EFFORTS },
264
- approvalMode: { type: "string", enum: APPROVAL_MODES },
264
+ approvalMode: { type: "string", enum: APPROVAL_MODES, description: "Permission posture for the worker. Defaults to YOUR OWN approval mode when omitted (a headless `guarded` worker wedges on the first approval prompt), so a coordinator running `open` spawns workers that can act autonomously. Pass an explicit value to narrow a child (e.g. `read-only` reviewer)." },
265
265
  prompt: { type: "string", description: "Initial task/message delivered to the agent on launch — spawn and hand it its first instruction in one call (no separate follow-up message needed)." },
266
266
  systemPromptAppend: { type: "string" },
267
267
  profile: { type: "string", description: "Agent profile name to apply (env, instructions, permissions, MCP/skills, spawn quota)." },
@@ -791,16 +791,37 @@ async function relaySpawnAgent(auth: McpAuthContext, args: Record<string, unknow
791
791
  const provider = enumField(args.provider, "provider", SPAWN_PROVIDERS) as SpawnProvider;
792
792
  const cwd = optionalString(args.cwd, "cwd", 500);
793
793
  const callerId = callerAgentId(auth);
794
- const preferHost = callerId ? getAgent(callerId)?.machine : undefined;
794
+ // One caller-record lookup, reused for host preference (#221), the cwd default (#328) and the
795
+ // approvalMode default (#331) — an agent spawning a helper inherits its own context instead of
796
+ // falling back to hardcoded values.
797
+ const caller = callerId ? getAgent(callerId) : undefined;
798
+ const preferHost = caller?.machine;
795
799
  const orchestrator = selectSpawnOrchestrator(provider, optionalString(args.orchestratorId, "orchestratorId", 200), cwd, preferHost);
796
- const resolvedCwd = cwd || orchestrator.baseDir;
800
+ // #328 default cwd to the caller's OWN cwd (the repo it's working in), not the orchestrator
801
+ // base dir, so "agent spawns a helper for its current task" Just Works — especially isolated mode,
802
+ // which needs a git repo (the base dir usually isn't one, so it silently downgraded to shared).
803
+ // Only adopt the caller's cwd when it resolves within the TARGET host's base dir (preferHost
804
+ // already biases the target to the caller's host; a cross-host path may not exist there). Non-agent
805
+ // callers (no caller record) keep the base-dir fallback. Precedence: explicit cwd > caller cwd > base dir.
806
+ const callerCwd = stringValue(caller?.meta?.cwd);
807
+ const inheritedCwd = callerCwd && isPathWithinBase(callerCwd, orchestrator.baseDir) ? callerCwd : undefined;
808
+ const resolvedCwd = cwd || inheritedCwd || orchestrator.baseDir;
797
809
  // #308 §3 — cwd must resolve within the TARGET host's base dir. A path valid on your own host
798
810
  // may not exist on a different orchestrator, so validate against the chosen host and say which.
799
811
  if (cwd && !isPathWithinBase(cwd, orchestrator.baseDir)) {
800
812
  throw new ValidationError(`cwd '${cwd}' is not within ${orchestrator.id} (host ${orchestrator.hostname})'s base dir '${orchestrator.baseDir}' — a path valid on your host may not exist on the target. Pass a cwd under that base dir, or omit cwd to default to it.`);
801
813
  }
802
814
  const selection = providerSelection(provider, args);
803
- const approvalMode = optionalEnum(args.approvalMode, "approvalMode", APPROVAL_MODES) as SpawnApprovalMode | undefined ?? "guarded";
815
+ // #331 default the child's approval mode to the CALLER's, not a hardcoded `guarded`. A headless
816
+ // `guarded` child wedges on the first tool-call approval prompt (no human at the TUI — it can't even
817
+ // read its own spawn message). A trusted coordinator running `open` spawns workers that can actually
818
+ // work in their isolated worktrees; an explicit arg always wins and can NARROW a child (e.g. a
819
+ // read-only reviewer); non-agent/admin callers (no caller record) keep the safe `guarded` default.
820
+ // Precedence: explicit approvalMode > caller mode > guarded.
821
+ const callerApprovalMode = optionalEnum(stringValue(caller?.meta?.approvalMode), "approvalMode", APPROVAL_MODES) as SpawnApprovalMode | undefined;
822
+ const approvalMode = (optionalEnum(args.approvalMode, "approvalMode", APPROVAL_MODES) as SpawnApprovalMode | undefined)
823
+ ?? callerApprovalMode
824
+ ?? "guarded";
804
825
  const spawnRequestId = optionalString(args.spawnRequestId, "spawnRequestId", 160) ?? generateSpawnRequestId();
805
826
  const label = optionalString(args.label, "label", 120);
806
827
  const policyName = optionalString(args.policyName, "policyName", 120);
@@ -815,8 +836,7 @@ async function relaySpawnAgent(auth: McpAuthContext, args: Record<string, unknow
815
836
  // granted only to agents whose profile sets maxSpawnedAgents>0 and never to children).
816
837
  // Server/admin tokens have no caller identity → unrestricted by design.
817
838
  if (callerId) {
818
- const me = getAgent(callerId);
819
- if (me?.spawnedBy) {
839
+ if (caller?.spawnedBy) {
820
840
  throw new McpAuthError("spawned agents cannot spawn further agents (no grandchildren)");
821
841
  }
822
842
  const quota = auth.component?.constraints?.maxSpawnedAgents ?? 0;
@@ -1,2 +0,0 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{$t as t,An as n,D as r,Dn as i,Dt as a,E as o,Et as s,Ft as c,G as l,H as u,I as d,It as f,J as p,Jt as m,K as h,Lt as g,P as _,Pn as v,Vn as y,Wt as b,Z as x,an as S,at as C,b as w,c as T,dn as ee,en as E,et as te,g as ne,i as D,in as re,it as O,jn as ie,kn as ae,kt as oe,mn as k,nn as se,qt as ce,r as le,rn as ue,s as de,tn as fe,tt as pe,wn as A,x as me,xn as he,yn as ge,yt as _e}from"./lucide-react-CD8Xl2U3.js";import{t as ve}from"./react-dom-CX8inunm.js";import{d as ye,i as be,l as xe,s as Se,t as j,u as Ce}from"./store-CICRhg1m.js";import{B as M,D as we,E as Te,F as Ee,H as De,J as Oe,L as ke,M as N,N as Ae,O as je,S as Me,U as Ne,a as P,et as F,g as Pe,i as Fe,m as Ie,u as I,w as Le,z as L}from"./display-Bebqs1qu.js";import{t as Re}from"./badge-t8zAwHW9.js";import{t as R}from"./button-DDA5P2YQ.js";import{t as ze}from"./input-BW9UD3FM.js";import{t as Be}from"./copy-button-CE8e2c-F.js";import{C as Ve,E as He,I as Ue,S as We,T as Ge,_ as Ke,a as qe,d as Je,g as Ye,h as Xe,i as z,k as B,l as Ze,m as Qe,o as $e,p as et,r as V,t as tt,v as nt,w as H,y as rt}from"./index-CvSlyTSI.js";import{t as U}from"./use-keyboard-viewport-DxY_xJV5.js";import{n as it,t as at}from"./branch-state-badge-EliCEAQI.js";var W=e(y(),1),ot=e(ve(),1),st=[{name:`/reply`,source:`skill`,description:`Reply to a relay message by id`,argumentHint:`<messageId> <body>`},{name:`/message`,source:`skill`,description:`Send a relay message to an agent, label, tag, or broadcast`,argumentHint:`<target> <body>`},{name:`/pair`,source:`skill`,description:`Start or manage a two-agent pair session`},{name:`/react`,source:`skill`,description:`Add a reaction to a relay message`,argumentHint:`<messageId> <emoji>`},{name:`/read-message`,source:`skill`,description:`Fetch a full relay message by id`,argumentHint:`<messageId>`},{name:`/send-claimable`,source:`skill`,description:`Enqueue a claimable work item for one agent to claim`},{name:`/status`,source:`skill`,description:`Show this agent's relay status`},{name:`/tags`,source:`skill`,description:`List or update this agent's relay tags`},{name:`/label`,source:`skill`,description:`Read, set, or clear this agent's relay label`},{name:`/disconnect`,source:`skill`,description:`End the current relay pair session`}],ct=[{name:`/clear`,source:`builtin`,description:`Clear conversation history and free up context`},{name:`/compact`,source:`builtin`,description:`Compact the conversation to reclaim context`,argumentHint:`[instructions]`},{name:`/model`,source:`builtin`,description:`Switch the active model`,argumentHint:`[model]`},{name:`/help`,source:`builtin`,description:`Show help`}],lt=[{name:`/compact`,source:`builtin`,description:`Compact the conversation to reclaim context`},{name:`/new`,source:`builtin`,description:`Start a new thread`}];function ut(e){return[...e===`claude`?ct:e===`codex`?lt:[],...st]}var G=ae();function dt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function ft(e,t){if(t.startsWith(`/`))return t;let n=`${e.replace(/\/+$/,``)}/${t}`.split(`/`),r=[];for(let e of n)!e||e===`.`||(e===`..`?r.pop():r.push(e));return`/`+r.join(`/`)}function pt(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>0?t.slice(0,n):`/`}function mt(e,t){return e.filter(e=>e.status===`online`&&N(t,e.baseDir)).sort((e,t)=>we(t.baseDir).length-we(e.baseDir).length)[0]||e.find(e=>e.status===`online`)}function ht(){return typeof window<`u`&&window.matchMedia(`(min-width: 1280px)`).matches}function gt(){return typeof window<`u`&&!!window.getSelection()?.toString()}function K(e){let t=e.payload?.attachments;return Array.isArray(t)?t.filter(e=>!!(e&&typeof e==`object`&&typeof e.artifactId==`string`)):[]}var _t=[`👍`,`❤️`,`✅`,`👀`];function vt(e){let t=new Map;for(let n of e.reactions||[]){let e=je(n.emoji),r=t.get(e)??{emoji:e,count:0,mine:!1,actors:[]};r.count+=1,r.mine=r.mine||n.actorId===`user`,r.actors.push(n.actorId),t.set(e,r)}return[...t.values()].sort((e,t)=>t.count-e.count||e.emoji.localeCompare(t.emoji))}function q(e){return Me(e)}function J(e,n){let r=e.readBy||[],i=e.resolvedToAgent||n||e.to,a=i?r.includes(i):!1,o=r.some(e=>e!==F);if(a||o){let e=a?i:r.find(e=>e!==F);return{label:`read`,title:e?`Read by ${e}`:`Read by agent`,tone:`ok`,icon:S}}if(e.deliveryStatus===`delivered`)return{label:`delivered`,title:`Delivered to agent inbox`,tone:`ok`,icon:S};if(e.deliveryStatus===`queued`)return{label:`queued`,title:`Queued until the target agent is available`,tone:`warn`,icon:b};if(e.deliveryStatus===`failed`||e.deliveryStatus===`dead`){let n=e.deliveryPoisonReason||e.deliveryLastError||e.deliveryStatus;return{label:e.deliveryStatus,title:n,tone:`danger`,icon:t}}return{label:`sent`,title:`Accepted by Relay`,tone:`muted`,icon:re}}function yt(e){let t=M(e.createdAt);return(e.reactions||[]).reduce((e,t)=>Math.max(e,M(t.updatedAt||t.createdAt)),t)}function bt(e){return e?e.messages.reduce((e,t)=>Math.max(e,yt(t)),0):0}function xt(){let e=j(e=>e.agents),t=j(e=>e.showBuiltIns),n=j(e=>e.showOffline),r=j(e=>e.chatAgentSearch),i=j(e=>e.chatAgentProviderFilter),a=j(e=>e.chatAgentStatusFilter),o=j(e=>e.chatAgentTagFilter),s=j(e=>e.chatAgentCapFilter),c=j(e=>e.chatAgentHostFilter),l=j(e=>e.chatAgentSort),u=j(e=>e.chatAgentSortDir),d=j(e=>e.managedPolicies);return(0,W.useMemo)(()=>{let f=Ne(e,t,d);if(n||(f=f.filter(e=>e.status!==`offline`)),r){let e=r.toLowerCase();f=f.filter(t=>t.id.toLowerCase().includes(e)||(t.name||``).toLowerCase().includes(e)||(t.label||``).toLowerCase().includes(e)||(t.tags||[]).some(t=>t.toLowerCase().includes(e))||(t.capabilities||[]).some(t=>t.toLowerCase().includes(e)))}i&&(f=f.filter(e=>P(e)===i)),a&&(f=f.filter(e=>e.status===a)),o&&(f=f.filter(e=>(e.tags||[]).includes(o))),s&&(f=f.filter(e=>(e.capabilities||[]).includes(s))),c&&(f=f.filter(e=>(e.machine||``)===c));let p=u===`desc`?-1:1;return[...f].sort((e,t)=>l===`name`?I(e).localeCompare(I(t))*p:l===`lastSeen`?(M(t.lastSeen)-M(e.lastSeen))*p||I(e).localeCompare(I(t)):((Oe[e.status]??9)-(Oe[t.status]??9))*p||I(e).localeCompare(I(t)))},[e,t,n,d,r,i,a,o,s,c,l,u])}var St=[],Ct=[];function wt(e){return j(t=>t.chatStatusEvents[e]??St)}function Tt(e,t){let n=(0,W.useRef)(!1);(0,W.useEffect)(()=>{if(!e)return;n.current||=(window.history.pushState({chatGuard:!0},``),!0);function r(e){(e.state?.chatGuard!==void 0||!n.current)&&(window.history.pushState({chatGuard:!0},``),t())}function i(e){e.preventDefault()}return window.addEventListener(`popstate`,r),window.addEventListener(`beforeunload`,i),()=>{window.removeEventListener(`popstate`,r),window.removeEventListener(`beforeunload`,i)}},[e,t]),(0,W.useEffect)(()=>{!e&&n.current&&(n.current=!1)},[e])}function Et(){let e=j(e=>e.inboxDrafts),t=j(e=>e.agentsById),n=j(e=>e.set);(0,W.useEffect)(()=>{let r=Object.keys(e);if(r.length===0)return;let i=r.filter(e=>!t[e]&&e!==`user`);if(i.length===0)return;let a=setTimeout(()=>{let e=j.getState().agentsById,t={...j.getState().inboxDrafts},r=!1;for(let n of i)e[n]||(delete t[n],r=!0);r&&n({inboxDrafts:t})},3e4);return()=>clearTimeout(a)},[])}function Dt({value:e,onChange:t,onKeyDown:n,onPaste:r,placeholder:a,className:o}){let s=(0,W.useRef)(null);return(0,W.useEffect)(()=>{let e=s.current;e&&(e.style.height=`auto`,e.style.height=Math.min(e.scrollHeight,200)+`px`)},[e]),(0,W.useEffect)(()=>{let e=window.visualViewport;if(!e)return;function t(){let e=s.current;!e||document.activeElement!==e||requestAnimationFrame(()=>{e.scrollIntoView({block:`nearest`,behavior:`smooth`})})}return e.addEventListener(`resize`,t),()=>e.removeEventListener(`resize`,t)},[]),(0,G.jsx)(`textarea`,{ref:s,value:e,onChange:t,onKeyDown:n,onPaste:r,placeholder:a,rows:1,className:i(`w-full resize-none rounded-xl border border-border bg-background px-3.5 py-2.5 text-sm`,`placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,`min-h-[42px] max-h-[200px] overflow-y-auto`,o)})}function Ot({threads:e,onSelectAgent:t}){let n=j(e=>e.set),a=j(e=>e.openInboxThread),o=j(e=>e.openAgentSpawn),s=j(e=>e.selectedInboxThread),c=j(e=>e.chatAgentSearch),l=j(e=>e.chatAgentSort),u=j(e=>e.chatAgentSortDir),f=j(e=>e.chatAgentProviderFilter),p=j(e=>e.chatAgentStatusFilter),m=j(e=>e.chatAgentTagFilter),h=j(e=>e.chatAgentCapFilter),g=j(e=>e.chatAgentHostFilter),_=j(e=>e.chatAgentGroupBy),v=j(e=>e.chatAgentFiltersCollapsed),y=be(),b=xt(),x=(0,W.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.peer,n);return t},[e]),S=(0,W.useMemo)(()=>{if(l!==`lastMessage`)return b;let e=u===`desc`?-1:1;return[...b].sort((t,n)=>{let r=bt(x.get(t.id));return(bt(x.get(n.id))-r)*e||I(t).localeCompare(I(n))})},[b,l,u,x]),C=(0,W.useMemo)(()=>[...new Set(b.flatMap(e=>e.tags||[]))],[b]),w=(0,W.useMemo)(()=>[...new Set(b.flatMap(e=>De(e.capabilities||[])))],[b]),T=Ue(),ee=(0,W.useMemo)(()=>{if(_!==`project`)return null;let e=new Map;for(let t of S){let n=Qe(t)||`No project`,r=e.get(n);r?r.push(t):e.set(n,[t])}return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[S,_]),te=[f,p,m,h,g].filter(Boolean).length;function ne(e){a(e,x.get(e)?.messages),t?.(e)}function D(e){let t=x.get(e.id),n=t?.attention.unread||0,r=t?.previewMessage,a=bt(t),o=s===e.id,c=Xe(e),l=Qe(e),u=c.Icon;return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{className:i(`w-full text-left px-3 py-2.5 flex items-start gap-2.5 hover:bg-muted/50 transition-colors border-b border-border/50`,o&&`bg-muted/60`),onClick:()=>ne(e.id),children:[(0,G.jsxs)(`div`,{className:`relative shrink-0 mt-0.5`,children:[(0,G.jsx)(Ye,{agent:e}),(0,G.jsx)(Ke,{agent:e,now:y,className:`absolute -bottom-0.5 -right-0.5 w-2 h-2`})]}),(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-0.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium truncate`,children:I(e)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[a>0&&(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,title:Ie(a),children:L(y,a)}),n>0&&(0,G.jsx)(Re,{className:`bg-red-500 text-white text-xs min-w-[18px] h-[18px] flex items-center justify-center shrink-0 px-1`,children:n})]})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-0.5 text-[10px] text-muted-foreground`,children:[(0,G.jsx)(`span`,{title:c.title,className:`inline-flex shrink-0`,children:(0,G.jsx)(u,{className:i(`h-3 w-3`,c.iconColor)})}),(0,G.jsx)(`span`,{className:`truncate`,children:l||c.label}),e.context&&(0,G.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,G.jsx)(et,{utilization:e.context.utilization,size:18})})]}),r&&(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate leading-tight`,children:[r.from===`user`?`You: `:``,Te(r)]}),e.status!==`offline`&&(0,G.jsx)(`div`,{className:`mt-1`,children:(0,G.jsx)(`span`,{className:i(`text-xs`,e.status===`busy`?`text-yellow-400`:`text-emerald-400`),children:e.status})})]})]})},e.id)}return(0,G.jsxs)(`div`,{className:`flex flex-col h-full border-r border-border min-w-0`,children:[(0,G.jsxs)(`div`,{className:`p-3 border-b border-border space-y-2`,children:[(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(r,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none`}),(0,G.jsx)(ze,{placeholder:`Search agents...`,value:c,onChange:e=>n({chatAgentSearch:e.target.value}),className:`pl-8 h-7 text-xs`})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n({chatAgentFiltersCollapsed:!v}),className:`sm:hidden flex w-full items-center justify-between h-6 px-1.5 text-xs rounded-md border border-border bg-background text-muted-foreground`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(me,{className:`w-3.5 h-3.5`}),`Filters & sort`,te>0&&(0,G.jsx)(Re,{className:`bg-primary/20 text-primary text-[10px] h-4 min-w-4 px-1 flex items-center justify-center`,children:te})]}),v?(0,G.jsx)(ue,{className:`w-3.5 h-3.5`}):(0,G.jsx)(E,{className:`w-3.5 h-3.5`})]}),(0,G.jsxs)(`div`,{className:i(`space-y-2`,v?`hidden`:`block`,`sm:block`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,G.jsxs)(`select`,{value:l,onChange:e=>n({chatAgentSort:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,G.jsx)(`option`,{value:`status`,children:`By status`}),(0,G.jsx)(`option`,{value:`name`,children:`By name`}),(0,G.jsx)(`option`,{value:`lastSeen`,children:`By last seen`}),(0,G.jsx)(`option`,{value:`lastMessage`,children:`By last activity`})]}),(0,G.jsx)(R,{variant:`ghost`,size:`icon-xs`,onClick:()=>n({chatAgentSortDir:u===`asc`?`desc`:`asc`}),children:u===`asc`?(0,G.jsx)(ge,{className:`w-3.5 h-3.5`}):(0,G.jsx)(A,{className:`w-3.5 h-3.5`})})]}),(0,G.jsxs)(`select`,{value:_,onChange:e=>n({chatAgentGroupBy:e.target.value}),className:`w-full h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,G.jsx)(`option`,{value:``,children:`No grouping`}),(0,G.jsx)(`option`,{value:`project`,children:`Group by project`})]}),(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[(0,G.jsxs)(`select`,{value:f,onChange:e=>n({chatAgentProviderFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,G.jsx)(`option`,{value:``,children:`All types`}),(0,G.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,G.jsx)(`option`,{value:`codex`,children:`Codex`}),(0,G.jsx)(`option`,{value:`agent`,children:`Agent`}),(0,G.jsx)(`option`,{value:`user`,children:`User`})]}),(0,G.jsxs)(`select`,{value:p,onChange:e=>n({chatAgentStatusFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,G.jsx)(`option`,{value:``,children:`All status`}),(0,G.jsx)(`option`,{value:`online`,children:`Online`}),(0,G.jsx)(`option`,{value:`idle`,children:`Idle`}),(0,G.jsx)(`option`,{value:`busy`,children:`Busy`}),(0,G.jsx)(`option`,{value:`offline`,children:`Offline`})]}),T.length>1&&(0,G.jsxs)(`select`,{value:g,onChange:e=>n({chatAgentHostFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,G.jsx)(`option`,{value:``,children:`All hosts`}),T.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]})]}),(C.length>0||w.length>0)&&(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[C.length>0&&(0,G.jsxs)(`select`,{value:m,onChange:e=>n({chatAgentTagFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,G.jsx)(`option`,{value:``,children:`All tags`}),C.map(e=>(0,G.jsxs)(`option`,{value:e,children:[`#`,e]},e))]}),w.length>0&&(0,G.jsxs)(`select`,{value:h,onChange:e=>n({chatAgentCapFilter:e.target.value}),className:`flex-1 h-6 text-xs rounded-md border border-border bg-background px-1.5 text-foreground`,children:[(0,G.jsx)(`option`,{value:``,children:`All caps`}),w.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))]})]})]})]}),(0,G.jsxs)(`button`,{type:`button`,className:`flex w-full shrink-0 items-center gap-2.5 border-b border-border px-3 py-2 text-left transition-colors hover:bg-muted/50`,onClick:o,children:[(0,G.jsx)(`div`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full border border-dashed border-primary/50 bg-primary/10 text-primary`,children:(0,G.jsx)(d,{className:`h-3.5 w-3.5`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium`,children:`New Agent`}),(0,G.jsx)(`div`,{className:`truncate text-[10px] text-muted-foreground`,children:`Spawn a fresh chat agent`})]})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:S.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 text-center px-4`,children:[(0,G.jsx)(k,{className:`w-8 h-8 text-zinc-600 mb-2`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No agents match filters`})]}):ee?ee.map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-1.5 border-b border-border/50 bg-background/95 px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-muted-foreground backdrop-blur`,children:[(0,G.jsx)(`span`,{className:`truncate`,children:e}),(0,G.jsx)(`span`,{className:`text-muted-foreground/50`,children:t.length})]}),(0,G.jsx)(`ul`,{children:t.map(D)})]},e)):(0,G.jsx)(`ul`,{children:S.map(D)})})]})}function kt(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function At(e){return new Date(e.occurredAt??e.createdAt).getTime()}function jt(e){let t=new Date,[n,r,i]=e.split(`-`).map(Number),a=new Date(n,r-1,i);if(e===Z(t.getTime()))return`Today`;let o=new Date(t);return o.setDate(o.getDate()-1),e===Z(o.getTime())?`Yesterday`:a.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:a.getFullYear()===t.getFullYear()?void 0:`numeric`})}var Mt={online:`text-emerald-400`,offline:`text-zinc-400`,shutdown:`text-zinc-400`,restarted:`text-blue-400`,"compaction-requested":`text-zinc-400`,compacting:`text-amber-400`,compacted:`text-amber-400`,"compaction-stalled":`text-red-400`,"clear-requested":`text-zinc-400`,"clearing-context":`text-amber-400`,"context-cleared":`text-amber-400`,"clear-stalled":`text-red-400`,"shutting-down":`text-zinc-400`},Nt={online:`came online`,offline:`went offline`,shutdown:`shut down`,restarted:`restarted`,"compaction-requested":`compaction requested`,compacting:`compaction started`,compacted:`context compacted`,"compaction-stalled":`compaction stalled — may need manual intervention`,"clear-requested":`clear requested`,"clearing-context":`clear started`,"context-cleared":`context cleared`,"clear-stalled":`context clear stalled — may need manual intervention`,"shutting-down":`shutting down`},Pt=new Set(Object.keys(Nt)),Ft=3e3,It=96;function Lt({event:e}){return(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,G.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,G.jsx)(ce,{className:i(`w-2 h-2 fill-current`,Mt[e.status]||`text-zinc-400`)}),(0,G.jsx)(`span`,{children:Nt[e.status]||e.status}),(0,G.jsx)(`span`,{className:`text-muted-foreground/60`,children:kt(e.timestamp)})]}),(0,G.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Rt({blockedLabel:e,onInterrupt:n}){return e?(0,G.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-red-500/30 px-4 py-2.5`,children:[(0,G.jsx)(t,{className:`w-3.5 h-3.5 text-red-400`}),(0,G.jsxs)(`span`,{className:`text-xs text-red-300`,children:[`blocked: `,e]})]})}):(0,G.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-foreground/10 px-4 py-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_infinite]`}),(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.2s_infinite]`}),(0,G.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_0.4s_infinite]`})]}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`working`}),n&&(0,G.jsxs)(`button`,{onClick:n,title:`Interrupt`,className:`ml-1 flex items-center gap-1 rounded-full px-1.5 py-0.5 text-xs text-muted-foreground hover:text-red-300 hover:bg-red-500/10 transition-colors`,children:[(0,G.jsx)(m,{className:`w-3.5 h-3.5`}),`Stop`]})]})})}var zt=`agent-relay:chat-hide-tools`,Y=(()=>{let e=new Set,t=(()=>{try{return window.localStorage.getItem(zt)===`on`}catch{return!1}})(),n=()=>e.forEach(e=>e());return typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===zt&&(t=e.newValue===`on`,n())}),{subscribe(t){return e.add(t),()=>e.delete(t)},get:()=>t,toggle(){t=!t;try{window.localStorage.setItem(zt,t?`on`:`off`)}catch{}n()}}})();function Bt(){return[(0,W.useSyncExternalStore)(Y.subscribe,Y.get,()=>!1),Y.toggle]}function Vt({steps:e,showReasoning:t}){let[n,r]=Bt(),a=t?e:e.filter(e=>e.kind!==`reasoning`);if(!a.length)return null;let o=a.filter(e=>e.kind===`tool`).length;return(0,G.jsx)(`div`,{className:`flex justify-start mb-2`,children:(0,G.jsxs)(`div`,{className:`max-w-[85%] md:max-w-[75%] min-w-0 space-y-1.5`,children:[a.map(e=>e.kind===`narration`?(0,G.jsx)(`div`,{className:`text-sm leading-relaxed whitespace-pre-wrap break-words text-foreground/90 min-w-0`,children:e.text},e.id):e.kind===`reasoning`?(0,G.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground/80`,children:[(0,G.jsx)(ee,{className:`w-3.5 h-3.5 mt-0.5 shrink-0 opacity-70`}),(0,G.jsx)(`span`,{className:`italic whitespace-pre-wrap break-words min-w-0`,children:e.text})]},e.id):n?null:(0,G.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground`,children:[(0,G.jsx)(ne,{className:`w-3 h-3 mt-0.5 shrink-0 opacity-70`}),(0,G.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:e.label||`tool`}),e.text?(0,G.jsxs)(`span`,{className:`opacity-70`,children:[` — `,e.text]}):null]})]},e.id)),o>0&&(0,G.jsxs)(`button`,{onClick:r,className:`flex items-center gap-1 text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors text-left`,children:[(0,G.jsx)(fe,{className:i(`w-3 h-3 shrink-0 transition-transform`,!n&&`rotate-90`)}),(0,G.jsx)(`span`,{children:n?`show ${o} tool step${o===1?``:`s`}`:`hide tool steps`})]})]})})}function Ht({agentId:e,approval:n}){let r=j(e=>e.sendPermissionDecision),[i,a]=(0,W.useState)(null);if(!n)return null;if(n.questions&&n.questions.length)return(0,G.jsx)(Gt,{agentId:e,approval:n,questions:n.questions});let o=n,s=n.choices.length?n.choices:[{id:`approve`,label:`Approve`},{id:`deny`,label:`Deny`}];async function c(t){if(!i){a(t.id);try{await r(e,o.id,t.id)}finally{a(null)}}}let l=n.kind===`plan`;return(0,G.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,G.jsx)(`div`,{className:`max-w-[92%] md:max-w-[78%] rounded-2xl rounded-bl-sm bg-card ring-1 ring-amber-500/35 px-3.5 py-3 text-sm`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-2`,children:[l?(0,G.jsx)(C,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-400`}):(0,G.jsx)(t,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-400`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-amber-100`,children:n.title}),n.body&&(l?(0,G.jsx)(`div`,{className:`mt-2 max-h-72 overflow-auto rounded-md bg-background/60 p-2.5 text-xs leading-relaxed`,children:(0,G.jsx)(tt,{text:n.body,rawBody:n.body,className:`leading-relaxed`})}):(0,G.jsx)(`pre`,{className:`mt-2 max-h-44 overflow-auto whitespace-pre-wrap break-words rounded-md bg-background/80 p-2 font-mono text-xs leading-relaxed text-muted-foreground`,children:n.body})),(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:s.map(e=>(0,G.jsxs)(R,{size:`sm`,variant:e.id===`deny`||e.id===`abort`?`outline`:`default`,disabled:!!i,onClick:()=>void c(e),className:`h-7 px-2 text-xs`,children:[i===e.id&&(0,G.jsx)(O,{className:`mr-1.5 h-3 w-3 animate-spin`}),e.label]},e.id))})]})]})})})}function Ut(e){return e?e.otherActive&&e.other.trim()?!0:e.labels.length>0:!1}function Wt(e){let t=[...e.labels];return e.otherActive&&e.other.trim()&&t.push(e.other.trim()),t.join(`, `)}function Gt({agentId:e,approval:t,questions:n}){let r=j(e=>e.sendPermissionDecision),[a,o]=(0,W.useState)(0),[s,c]=(0,W.useState)({}),[l,u]=(0,W.useState)(null),d=n[Math.min(a,n.length-1)],f=s[a];if(!d)return null;let p=!!d.multiSelect,m=n.length,h=a===m-1,g=Ut(f),_=n.every((e,t)=>Ut(s[t])),v=!!l;function y(e){c(t=>{let n=t[a]??{labels:[],other:``,otherActive:!1};return{...t,[a]:{...n,...e}}})}function b(e){if(p){let t=f?.labels.includes(e);y({labels:t?(f?.labels??[]).filter(t=>t!==e):[...f?.labels??[],e]})}else y({labels:[e],otherActive:!1})}function S(){y(p?{otherActive:!f?.otherActive}:{labels:[],otherActive:!0})}async function C(){if(!(!_||v)){u(`answer`);try{let i={};n.forEach((e,t)=>{let n=s[t];n&&(i[e.question]=Wt(n))}),await r(e,t.id,`answer`,i)}finally{u(null)}}}async function w(){if(!v){u(`dismiss`);try{await r(e,t.id,`deny`)}finally{u(null)}}}let T=!!f?.otherActive;return(0,G.jsx)(`div`,{className:`flex justify-start mb-3`,children:(0,G.jsxs)(`div`,{className:`w-full max-w-[92%] md:max-w-[78%] rounded-2xl rounded-bl-sm bg-card ring-1 ring-amber-500/35 px-3.5 py-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(x,{className:`h-4 w-4 shrink-0 text-amber-400`}),(0,G.jsx)(`div`,{className:`text-sm font-medium text-amber-100`,children:t.title}),m>1&&(0,G.jsxs)(Re,{variant:`outline`,className:`ml-auto h-5 px-1.5 text-[10px] text-muted-foreground`,children:[a+1,` / `,m]})]}),(0,G.jsxs)(`div`,{className:`mt-3`,children:[d.header&&(0,G.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-amber-300/80`,children:d.header}),(0,G.jsx)(`div`,{className:`mt-0.5 text-sm text-foreground whitespace-pre-wrap break-words`,children:d.question}),p&&(0,G.jsx)(`div`,{className:`mt-0.5 text-[11px] text-muted-foreground`,children:`Select all that apply`}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:[d.options.map(e=>{let t=!!f?.labels.includes(e.label);return(0,G.jsxs)(`button`,{type:`button`,disabled:v,onClick:()=>b(e.label),className:i(`flex items-start gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors`,t?`border-amber-500/60 bg-amber-500/10`:`border-border bg-background/60 hover:bg-background`,v&&`opacity-60`),children:[(0,G.jsx)(`span`,{className:i(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center border text-amber-300`,p?`rounded`:`rounded-full`,t?`border-amber-400 bg-amber-400/20`:`border-muted-foreground/40`),children:t&&(0,G.jsx)(re,{className:`h-3 w-3`})}),(0,G.jsxs)(`span`,{className:`min-w-0`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground`,children:e.label}),e.description&&(0,G.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description})]})]},e.label)}),(0,G.jsxs)(`button`,{type:`button`,disabled:v,onClick:S,className:i(`flex items-start gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors`,T?`border-amber-500/60 bg-amber-500/10`:`border-border bg-background/60 hover:bg-background`,v&&`opacity-60`),children:[(0,G.jsx)(`span`,{className:i(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center border text-amber-300`,p?`rounded`:`rounded-full`,T?`border-amber-400 bg-amber-400/20`:`border-muted-foreground/40`),children:T&&(0,G.jsx)(re,{className:`h-3 w-3`})}),(0,G.jsx)(`span`,{className:`text-sm text-foreground`,children:`Other…`})]}),T&&(0,G.jsx)(V,{autoFocus:!0,rows:2,disabled:v,value:f?.other??``,onChange:e=>y({other:e.target.value,otherActive:!0}),placeholder:`Type your answer`,className:`mt-1 text-sm`})]})]}),(0,G.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[a>0&&(0,G.jsxs)(R,{size:`sm`,variant:`outline`,disabled:v,onClick:()=>o(e=>e-1),className:`h-7 px-2 text-xs`,children:[(0,G.jsx)(se,{className:`mr-1 h-3 w-3`}),`Back`]}),h?(0,G.jsxs)(R,{size:`sm`,disabled:v||!_,onClick:()=>void C(),className:`h-7 px-2 text-xs`,children:[l===`answer`&&(0,G.jsx)(O,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Send answer`,m>1?`s`:``]}):(0,G.jsxs)(R,{size:`sm`,disabled:v||!g,onClick:()=>o(e=>e+1),className:`h-7 px-2 text-xs`,children:[`Next`,(0,G.jsx)(fe,{className:`ml-1 h-3 w-3`})]}),(0,G.jsxs)(R,{size:`sm`,variant:`ghost`,disabled:v,onClick:()=>void w(),className:`ml-auto h-7 px-2 text-xs text-muted-foreground`,children:[l===`dismiss`&&(0,G.jsx)(O,{className:`mr-1.5 h-3 w-3 animate-spin`}),`Dismiss`]})]})]})})}function Kt({date:e}){return(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-3 my-1`,children:[(0,G.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:jt(e)}),(0,G.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function qt({timestamp:e}){let t=new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`});return(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,G.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground/60`,children:[`created `,t]}),(0,G.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Jt({history:e}){let t=e.sourceAgentLabel||e.sourcePeerId,n=e.entries.length;return(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,G.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-full border border-dashed border-border bg-muted/30 px-2 py-1 text-[11px] text-muted-foreground`,children:[(0,G.jsx)(_e,{className:`h-3 w-3`}),(0,G.jsxs)(`span`,{children:[`forked history from `,t]}),(0,G.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[n,` `,n===1?`entry`:`entries`]})]}),(0,G.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Yt({entry:e,sourceLabel:t}){let n=e.message,r=Le(n),a=e.originalFrom===F;return(0,G.jsx)(`div`,{className:i(`flex mb-3 opacity-80`,a?`justify-end`:`justify-start`),children:(0,G.jsx)(`div`,{className:`max-w-[85%] md:max-w-[75%]`,children:(0,G.jsxs)(`div`,{className:i(`rounded-2xl border border-dashed px-3.5 py-2 text-sm select-text`,a?`border-primary/25 bg-primary/10 text-foreground rounded-br-sm`:`border-border bg-card/70 rounded-bl-sm`),children:[(0,G.jsxs)(`div`,{className:i(`mb-1 text-[10px] uppercase tracking-normal`,a?`text-primary/70`:`text-muted-foreground`),children:[`forked history · `,a?`you`:t||e.originalFrom]}),(0,G.jsx)(tt,{text:r,rawBody:n.body,className:`leading-relaxed`}),(0,G.jsxs)(`p`,{className:i(`mt-1 flex items-center justify-end gap-1.5 text-xs`,a?`text-primary/60`:`text-muted-foreground`),children:[(0,G.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.originalMessageId]}),(0,G.jsx)(`span`,{children:kt(e.originalCreatedAt)})]})]})})})}function X({attachment:e,outbound:n}){let r=e.kind===`image`,a=e.title||e.artifactId,[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(null),[u,d]=(0,W.useState)(!1),[f,p]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let t=!1,n=null;async function r(){d(!0),l(null),s(null);try{let r=await ie(`/artifacts/${encodeURIComponent(e.artifactId)}/content`);if(t)return;n=URL.createObjectURL(r),s(n)}catch(e){t||l(e.message)}finally{t||d(!1)}}return r(),()=>{t=!0,n&&URL.revokeObjectURL(n)}},[e.artifactId]);function m(){if(!o)return;let e=document.createElement(`a`);e.href=o,e.download=a,document.body.appendChild(e),e.click(),e.remove()}return r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>o&&p(!0),disabled:!o,className:`group/img mt-2 block overflow-hidden rounded-md border border-foreground/10 bg-black/10 text-left disabled:cursor-default relative`,children:o?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`img`,{src:o,alt:a,loading:`lazy`,className:`block max-h-72 max-w-full object-contain`}),(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 group-hover/img:bg-black/30 transition-colors`,children:(0,G.jsx)(le,{className:`w-6 h-6 text-white opacity-0 group-hover/img:opacity-100 transition-opacity drop-shadow-md`})})]}):(0,G.jsxs)(`span`,{className:i(`flex min-h-20 items-center gap-2 px-3 py-2 text-xs`,c?`text-red-400`:`text-muted-foreground`),children:[u?(0,G.jsx)(O,{className:`h-4 w-4 animate-spin`}):(0,G.jsx)(t,{className:`h-4 w-4`}),c||`Loading image`]})}),o&&(0,G.jsx)(z,{open:f,onOpenChange:p,children:(0,G.jsxs)(qe,{className:`max-w-[95vw] max-h-[95vh] w-auto p-0 bg-black/95 border-zinc-800 gap-0 overflow-hidden`,showCloseButton:!1,children:[(0,G.jsx)($e,{className:`sr-only`,children:a}),(0,G.jsxs)(`div`,{className:`relative flex items-center justify-center min-h-[200px]`,children:[(0,G.jsx)(`img`,{src:o,alt:a,className:`max-w-[93vw] max-h-[90vh] object-contain`}),(0,G.jsxs)(`div`,{className:`absolute top-2 right-2 flex gap-1`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:m,className:`rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Download`,children:(0,G.jsx)(g,{className:`w-4 h-4`})}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>p(!1),className:`rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Close`,children:(0,G.jsx)(D,{className:`w-4 h-4`})})]})]})]})})]}):(0,G.jsxs)(`button`,{type:`button`,onClick:m,disabled:!o,className:i(`mt-2 flex w-full items-center gap-2 rounded-md border px-2.5 py-2 text-left text-xs transition-colors disabled:cursor-default disabled:opacity-70`,n?`border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/15`:`border-border bg-background hover:bg-muted`),children:[u?(0,G.jsx)(O,{className:`h-4 w-4 shrink-0 animate-spin`}):c?(0,G.jsx)(t,{className:`h-4 w-4 shrink-0 text-red-400`}):(0,G.jsx)(oe,{className:`h-4 w-4 shrink-0`}),(0,G.jsx)(`span`,{className:i(`min-w-0 flex-1 truncate`,c&&`text-red-400`),children:c||a}),(0,G.jsx)(g,{className:`h-3.5 w-3.5 shrink-0`})]})}function Xt({item:e,onRemove:n}){let[r,a]=(0,W.useState)(!1),o=!!(e.previewUrl&&!e.error);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 text-xs`,children:[(0,G.jsx)(`button`,{type:`button`,disabled:!o,onClick:()=>a(!0),className:`group/pending relative flex h-9 w-9 shrink-0 items-center justify-center overflow-hidden rounded bg-muted disabled:cursor-default`,title:o?`Preview image`:e.fileName,children:e.previewUrl?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`img`,{src:e.previewUrl,alt:e.fileName,className:`h-full w-full object-cover`}),(0,G.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 group-hover/pending:bg-black/30 transition-colors`,children:(0,G.jsx)(le,{className:`h-3.5 w-3.5 text-white opacity-0 group-hover/pending:opacity-100 transition-opacity drop-shadow-md`})})]}):e.error?(0,G.jsx)(t,{className:`h-4 w-4 text-red-400`}):e.uploading?(0,G.jsx)(O,{className:`h-4 w-4 animate-spin text-muted-foreground`}):(0,G.jsx)(oe,{className:`h-4 w-4 text-muted-foreground`})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`p`,{className:`truncate font-medium`,children:e.fileName}),(0,G.jsx)(`p`,{className:i(`truncate text-muted-foreground`,e.error&&`text-red-400`),children:e.error||(e.uploading?`Uploading`:dt(e.size))})]}),(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,title:`Remove attachment`,onClick:n,children:(0,G.jsx)(D,{className:`h-3.5 w-3.5`})})]}),e.previewUrl&&(0,G.jsx)(z,{open:r,onOpenChange:a,children:(0,G.jsxs)(qe,{className:`max-w-[95vw] max-h-[95vh] w-auto p-0 bg-black/95 border-zinc-800 gap-0 overflow-hidden`,showCloseButton:!1,children:[(0,G.jsx)($e,{className:`sr-only`,children:e.fileName}),(0,G.jsxs)(`div`,{className:`relative flex items-center justify-center min-h-[200px]`,children:[(0,G.jsx)(`img`,{src:e.previewUrl,alt:e.fileName,className:`max-w-[93vw] max-h-[90vh] object-contain`}),(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(!1),className:`absolute top-2 right-2 rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Close`,children:(0,G.jsx)(D,{className:`w-4 h-4`})})]})]})})]})}function Zt({preview:e,error:t,onReadError:n,onMouseEnter:r,onMouseLeave:i}){let{anchor:a}=e,o=Math.min(560,window.innerWidth-24),s=Math.min(380,window.innerHeight-24),c=Math.max(12,Math.min(a.left,window.innerWidth-o-12));return(0,ot.createPortal)((0,G.jsxs)(`div`,{className:`fixed z-50 flex flex-col overflow-hidden rounded-lg border border-border bg-background shadow-xl`,style:{top:window.innerHeight-a.bottom>=s+8?a.bottom+8:a.top-8-s>=12?a.top-8-s:Math.max(12,window.innerHeight-s-12),left:c,width:o,height:s},onMouseEnter:r,onMouseLeave:i,children:[(0,G.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b border-border px-2.5`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] font-medium text-muted-foreground`,children:e.path}),t&&(0,G.jsx)(`span`,{className:`max-w-[12rem] truncate text-[11px] text-red-400`,children:t}),(0,G.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground/70`,children:`click to pin`})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:e.type===`directory`?(0,G.jsx)(nt,{orchestratorId:e.orchestratorId,selectedPath:e.path,onReadError:n}):(0,G.jsx)(rt,{orchestratorId:e.orchestratorId,selectedPath:e.path,line:e.line,onReadError:n})})]}),document.body)}function Qt({open:e,onToggle:t,onReact:n}){return(0,G.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,G.jsx)(`button`,{type:`button`,title:`Add reaction`,onClick:t,className:i(`inline-flex h-5 w-6 items-center justify-center rounded-full border border-border bg-popover text-muted-foreground shadow-sm transition hover:bg-muted hover:text-foreground`,e?`opacity-100`:`opacity-0 pointer-events-none md:group-hover/msg:opacity-100 md:group-hover/msg:pointer-events-auto`),children:(0,G.jsx)(w,{className:`h-3 w-3`})}),e&&(0,G.jsx)(`div`,{className:`absolute bottom-full left-0 z-30 mb-1 flex gap-0.5 rounded-full border border-border bg-popover p-0.5 shadow-md`,children:_t.map(e=>(0,G.jsx)(`button`,{type:`button`,title:`React ${e}`,onClick:()=>n(e),className:`inline-flex h-6 w-7 items-center justify-center rounded-full text-xs transition-colors hover:bg-muted`,children:e},e))})]})}function $t(){return(0,W.useSyncExternalStore)(e=>ye.subscribe(e),()=>ye.getPlayingKey(),()=>null)}var en=(0,W.memo)(function({msg:e,peer:t,onOpenReferencedPath:n,onPreviewReferencedPath:r,onPreviewReferencedPathEnd:a}){let o=e.from===F,s=j(e=>e.reactToMessage),c=j(e=>e.voiceTtsEnabled),l=$t(),u=j(e=>{let n=e.agentsById[t]?.meta?.cwd;return typeof n==`string`?n:``}),[d,f]=(0,W.useState)(!1),p=(0,W.useRef)(null),h=(0,W.useRef)(null),g=(0,W.useRef)(!1),_=Le(e),v=kt(e.occurredAt??e.createdAt),y=K(e),b=vt(e),x=o?J(e,t):null,S=x?.icon,C=l===String(e.id),w=c&&!o&&!q(e)&&_.trim().length>0;function ee(t){t.stopPropagation(),C?ye.bargeIn():ye.speak(e.body,String(e.id))}(0,W.useEffect)(()=>{if(!d)return;function e(e){gt()||p.current&&!p.current.contains(e.target)&&f(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[d]);function E(e){return ft(u||`/`,e)}function te(e,t){let r=E(e);n?.(r,t)}function ne(e,t,n){let i=E(e);r?.(i,t,n)}function D(t){s(e,t),f(!1)}function re(e){e.button===0&&(h.current={x:e.clientX,y:e.clientY},g.current=!1)}function O(e){let t=h.current;t&&(Math.abs(e.clientX-t.x)>3||Math.abs(e.clientY-t.y)>3)&&(g.current=!0)}function ie(t){if(!(q(e)||o)&&!t.target.closest(`a,button,input,textarea,select,[role="button"]`)){if(g.current||gt()){g.current=!1;return}f(e=>!e)}}return(0,G.jsx)(`div`,{"data-msg-id":e.id,className:i(`group/msg flex mb-3`,o?`justify-end`:`justify-start`),children:(0,G.jsxs)(`div`,{ref:p,className:`relative max-w-[85%] md:max-w-[75%]`,children:[w&&(0,G.jsx)(`button`,{type:`button`,title:C?`Stop playback`:`Play aloud`,onClick:ee,className:i(`absolute -top-2 -right-2 z-20 inline-flex h-6 w-6 items-center justify-center rounded-full border bg-popover shadow-sm transition`,C?`border-primary/50 text-primary opacity-100`:`border-border text-muted-foreground opacity-70 hover:bg-muted hover:text-foreground hover:opacity-100 [@media(hover:hover)]:md:opacity-0 [@media(hover:hover)]:md:group-hover/msg:opacity-100`),children:C?(0,G.jsx)(m,{className:`h-3.5 w-3.5 animate-pulse`}):(0,G.jsx)(T,{className:`h-3.5 w-3.5`})}),(0,G.jsxs)(`div`,{className:i(`rounded-2xl px-3.5 py-2 text-sm select-text`,!o&&!q(e)&&`cursor-pointer`,o?`bg-primary text-primary-foreground rounded-br-sm`:`bg-card ring-1 ring-foreground/10 rounded-bl-sm`),onPointerDown:re,onPointerMove:O,onClick:ie,children:[e.subject&&(0,G.jsx)(`p`,{className:i(`text-xs font-semibold mb-1`,o?`text-primary-foreground/70`:`text-muted-foreground`),children:e.subject}),(0,G.jsx)(tt,{text:_,rawBody:e.body,className:`leading-relaxed`,onOpenPath:te,onPreviewPath:ne,onPreviewPathEnd:a,resolvePathTitle:(e,t)=>`${E(e)}${t?`:${t}`:``}`}),y.map(t=>(0,G.jsx)(X,{attachment:t,outbound:o},`${e.id}-${t.artifactId}-${t.role||``}`)),(0,G.jsxs)(`p`,{className:i(`text-xs mt-1 flex items-center gap-1.5`,o?`justify-end text-primary-foreground/60`:`justify-end text-muted-foreground`),children:[(0,G.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.id]}),(0,G.jsx)(`span`,{children:v}),x&&S&&(0,G.jsxs)(`span`,{className:i(`inline-flex items-center gap-1`,x.tone===`ok`&&`text-emerald-300`,x.tone===`warn`&&`text-amber-200`,x.tone===`danger`&&`text-red-200`),title:x.title,children:[(0,G.jsx)(S,{className:`h-3 w-3`}),x.label]})]})]}),!q(e)&&b.length>0&&(0,G.jsxs)(`div`,{className:i(`flex flex-wrap items-center gap-0.5 -mt-1 relative z-10`,o?`justify-end pr-2`:`justify-start pl-2`),children:[!o&&(0,G.jsx)(Qt,{open:d,onToggle:()=>f(e=>!e),onReact:D}),b.map(e=>(0,G.jsxs)(`button`,{type:`button`,title:e.actors.join(`, `),onClick:()=>D(e.emoji),className:i(`inline-flex h-5 items-center gap-0.5 rounded-full border px-1.5 text-[11px] shadow-sm transition-colors`,e.mine?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-background hover:bg-muted text-foreground`),children:[(0,G.jsx)(`span`,{children:e.emoji}),e.count>1&&(0,G.jsx)(`span`,{children:e.count})]},e.emoji))]}),!q(e)&&!o&&b.length===0&&(0,G.jsx)(`div`,{className:`absolute -bottom-2.5 left-1 z-20`,children:(0,G.jsx)(Qt,{open:d,onToggle:()=>f(e=>!e),onReact:D})})]})})});function tn(e){if(e.kind!==`session`)return null;let t=e.payload?.session;return!t||t.type!==`narration`&&t.type!==`reasoning`&&t.type!==`tool`?null:{id:e.id,kind:t.type,label:typeof t.label==`string`?t.label:void 0,text:e.body,ts:At(e),turnId:typeof t.turnId==`string`?t.turnId:void 0}}function Z(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function Q(e){let t=e.filter(e=>Pt.has(e.status)).slice().sort((e,t)=>e.timestamp-t.timestamp),n=[];for(let e of t)n.some(t=>t.id===e.id)||n.some(t=>t.status===e.status&&Math.abs(t.timestamp-e.timestamp)<=Ft)||n.push(e);return n}function nn(e){return e.scrollHeight-e.scrollTop-e.clientHeight<=It}function rn(e,t){let n=(0,W.useRef)(null),r=(0,W.useRef)(!0),i=(0,W.useRef)(null),a=(0,W.useCallback)(()=>{let e=n.current;e&&(r.current=nn(e))},[]);return(0,W.useLayoutEffect)(()=>{let t=n.current;t&&(i.current!==e&&(i.current=e,r.current=!0),r.current&&(t.scrollTop=t.scrollHeight))},[e,...t]),{ref:n,onScroll:a}}function an(e){for(let t of e)t.previewUrl&&URL.revokeObjectURL(t.previewUrl)}function on(e,t,n,r=[]){let i=[];for(let e of r){let t=e.entries.reduce((e,t)=>Math.min(e,M(t.originalCreatedAt)),1/0),n=Number.isFinite(t)?t-1:e.importedAt;i.push({ts:n,entry:{type:`import-boundary`,history:e,timestamp:n}});for(let t of e.entries)i.push({ts:M(t.originalCreatedAt),entry:{type:`imported-message`,history:e,entry:t}})}if(n){let e=new Date(n).getTime();Number.isFinite(e)&&i.push({ts:e,entry:{type:`created`,timestamp:e}})}let a=new Map;for(let t of e){if(t.kind!==`session`)continue;let e=t.payload?.session;if(e?.type===`response`&&typeof e.turnId==`string`){let n=a.get(e.turnId)??[];n.push(t.body.trim()),a.set(e.turnId,n)}}for(let t of e){if(q(t))continue;let e=tn(t);if(e){if(e.kind===`narration`&&e.turnId&&a.get(e.turnId)?.some(t=>Ee(t,e.text)))continue;i.push({ts:e.ts,entry:{type:`activity`,steps:[e],timestamp:e.ts}});continue}i.push({ts:At(t),entry:{type:`message`,msg:t}})}for(let e of Q(t))i.push({ts:e.timestamp,entry:{type:`status`,event:e}});let o={created:0,date:1,"import-boundary":2,"imported-message":3,message:4,activity:4,status:5};i.sort((e,t)=>{let n=e.ts-t.ts;return Math.abs(n)<3e3&&o[e.entry.type]-o[t.entry.type]||n});let s=[],c=``;for(let{ts:e,entry:t}of i){if(t.type===`created`){s.push(t);continue}let n=Z(e);if(n!==c&&(s.push({type:`date`,date:n,timestamp:e}),c=n),t.type===`activity`){let e=s[s.length-1];if(e&&e.type===`activity`&&$(e,t)){e.steps.push(...t.steps);continue}}s.push(t)}return s}function $(e,t){let n=e.steps[e.steps.length-1]?.turnId,r=t.steps[0]?.turnId;return n&&r?n===r:!n&&!r}function sn({scrollRef:e,timeline:t}){let[n,r]=(0,W.useState)(!0),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(!1),[l,u]=(0,W.useState)(!0),d=(0,W.useMemo)(()=>{for(let e=t.length-1;e>=0;e--){let n=t[e];if(!(!n||n.type!==`message`)&&n.msg.from===`user`)return{id:n.msg.id,body:Le(n.msg)}}return null},[t]);if((0,W.useEffect)(()=>{let t=e.current;if(!d||!t){r(!0);return}let n=t.querySelector(`[data-msg-id="${d.id}"]`);if(!n){r(!0);return}let i=new IntersectionObserver(([e])=>{if(e&&(r(e.isIntersecting),!e.isIntersecting)){let n=e.rootBounds?.top??t.getBoundingClientRect().top;u(e.boundingClientRect.top<n)}},{root:t,threshold:0});i.observe(n);let a=()=>{let e=n.getBoundingClientRect(),r=t.getBoundingClientRect();u(e.top<r.top)};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{i.disconnect(),t.removeEventListener(`scroll`,a)}},[d?.id,e]),(0,W.useEffect)(()=>{o(!1),c(!1)},[d?.id]),n||!d||!d.body.trim())return null;function f(){let t=e.current;!t||!d||t.querySelector(`[data-msg-id="${d.id}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`})}let p=l?`↑`:`↓`;return s?(0,G.jsx)(`div`,{className:`sticky top-0 z-10 -mx-3 md:-mx-4 -mt-3 md:-mt-4 bg-background`,children:(0,G.jsxs)(`button`,{type:`button`,className:`w-full flex items-center justify-center gap-1.5 py-1 text-[11px] text-primary/60 hover:text-primary border-b border-primary/10 transition-colors`,onClick:()=>c(!1),children:[(0,G.jsx)(`span`,{children:`Your prompt`}),(0,G.jsx)(ue,{className:`w-3 h-3`})]})}):(0,G.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-3 md:-mx-4 -mt-3 md:-mt-4 px-2 md:px-3 pt-2 pb-1.5 bg-background border-b border-primary/10`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground mb-0.5`,children:[(0,G.jsx)(`span`,{className:`font-medium text-primary/70`,children:`Your prompt`}),(0,G.jsxs)(`button`,{type:`button`,className:`ml-auto hover:text-foreground transition-colors`,onClick:f,children:[p,` scroll to original`]}),(0,G.jsx)(`button`,{type:`button`,className:`hover:text-foreground transition-colors`,onClick:()=>c(!0),title:`Minimize`,children:(0,G.jsx)(E,{className:`w-3 h-3`})})]}),(0,G.jsx)(`p`,{className:i(`text-sm text-foreground leading-snug cursor-pointer`,!a&&`line-clamp-2`),onClick:()=>o(e=>!e),children:d.body})]})}function cn({threads:e,onBack:t,showBackButton:r}){let d=j(e=>e.selectedInboxThread),y=j(e=>e.agentsById),b=j(e=>e.inboxDrafts),x=be(),S=j(e=>e.sendChatMessage),C=j(e=>e.openFilesAt),w=j(e=>e.openFilesForAgent),ee=j(e=>e.openAgentDetail),E=j(e=>e.chatSending),re=j(e=>e.markInboxThreadRead),ie=j(e=>e.markInboxThreadUnread),ae=j(e=>e.setReplyDraft),oe=j(e=>e.exportThread),k=j(e=>e.doAgentAction),se=j(e=>e.workspaceAction),ce=j(e=>e.openWorkspaceFocus),le=j(e=>e.forkFromAgent),ue=j(e=>e.chatHistoryImports),fe=j(e=>e.threadHistory[e.selectedInboxThread]??Ct),A=j(e=>e.openConfirm),me=j(e=>e.showError),ge=j(e=>e.orchestrators),ve=j(e=>e.fetchOrchestrators),M=j(e=>e.showReasoning),we=j(e=>e.voiceTtsEnabled),Te=j(e=>e.setVoiceTtsEnabled),Ee=j(e=>e.voiceInputMode),De=(0,W.useRef)(null),Oe=(0,W.useRef)(null),[N,je]=(0,W.useState)(`idle`),Ne=(0,W.useRef)([]),[P,F]=(0,W.useState)([]),[Ie,Le]=(0,W.useState)(!1),[L,ze]=(0,W.useState)(null),[Ue,qe]=(0,W.useState)(null),[Xe,z]=(0,W.useState)(``),B=(0,W.useRef)(null),Qe=(0,W.useRef)(0),$e=wt(d),V=(0,W.useMemo)(()=>e.find(e=>e.peer===d)||null,[e,d]),tt=(0,W.useMemo)(()=>{let e=V?.messages??[];if(fe.length===0)return e;let t=new Map;for(let e of fe)Pe(e)===d&&!Me(e)&&t.set(e.id,e);for(let n of e)t.set(n.id,n);return[...t.values()].sort((e,t)=>e.id-t.id)},[V?.messages,fe,d]),U=y[d]||null,ot=typeof U?.meta?.lifecycleAction==`string`&&U.meta.lifecycleAction.startsWith(`finalizing-`),{terminalOpen:st,terminalTarget:ct,terminalOpening:lt,openTerminal:dt,closeTerminal:ft}=it(U?.id),gt=typeof U?.meta?.spawnRequestId==`string`?U.meta.spawnRequestId:``,K=(0,W.useMemo)(()=>ue.filter(e=>e.targetAgentId===d||!!(gt&&e.targetSpawnRequestId===gt)),[gt,ue,d]),_t=Ae(U),vt=_t?.pendingApproval,q=V||(K.length>0?{peer:d,messages:[],importedHistory:K}:null),J=b[d]||``,yt=K.reduce((e,t)=>e+t.entries.length,0),bt=rn(d,[tt.length,$e.length,yt,vt?.id,U?.status]),xt=typeof U?.meta?.tmuxSession==`string`&&U.meta.tmuxSession.trim()?U.meta.tmuxSession:null,St=xt?ge.find(e=>e.managedAgents?.some(e=>e.agentId===U.id||e.tmuxSession===xt))??null:null,Et=!!(xt&&St?.status===`online`&&U?.providerCapabilities?.terminal?.live?.read),Ot=U?.providerCapabilities?.model?.provider??(typeof U?.meta?.provider==`string`?U.meta.provider:void 0),kt=!!(Et&&(U?.providerCapabilities?.terminal?.live?.write||Ot===`claude`)),At=U?.providerCapabilities?.terminal?.attach?.create===!0,jt=Et||At,Mt=Fe(U,`compact`),Nt=Fe(U,`clearContext`),Pt=Fe(U,`shutdown`),Ft=Fe(U,`interrupt`),It=()=>{U&&k(U,`interrupt`)},[zt,Y]=(0,W.useState)(0),[Bt,Ut]=(0,W.useState)(!1),Wt=U?.providerCapabilities?.liveSession?.slashCommands===!0,Gt=U?.providerCapabilities?.model?.provider??(typeof U?.meta?.provider==`string`?U.meta.provider:void 0),X=Wt&&!Bt&&/^\/\S*$/.test(J)?ut(Gt).filter(e=>e.name.toLowerCase().startsWith(J.toLowerCase())):[],Qt=X.length?Math.min(zt,X.length-1):0;function $t(e){ae(d,`${e.name} `),Y(0)}function tn(e){ae(d,e),Bt&&Ut(!1),Y(0)}let Z=P.some(e=>e.uploading),Q=P.filter(e=>e.artifact);Tt(J.trim().length>0||P.length>0,(0,W.useCallback)(()=>{},[])),Ne.current=P,(0,W.useEffect)(()=>()=>{an(Ne.current)},[]),(0,W.useEffect)(()=>{U?.meta?.tmuxSession&&ge.length===0&&ve()},[U?.id,U?.meta?.tmuxSession,ge.length]),(0,W.useEffect)(()=>()=>{B.current!==null&&window.clearTimeout(B.current)},[]);let nn=(0,W.useMemo)(()=>on(tt,$e,U?.createdAt,K),[tt,$e,U?.createdAt,K]),$=(0,W.useCallback)(()=>{B.current!==null&&(window.clearTimeout(B.current),B.current=null)},[]),cn=(0,W.useCallback)(async e=>{let t=mt(ge,e);if(!t)return null;try{let r=await n(`GET`,`/orchestrators/${encodeURIComponent(t.id)}/files/stat?path=${encodeURIComponent(e)}`);return{orchestratorId:t.id,path:r.path,type:r.type}}catch{return null}},[ge]),ln=(0,W.useCallback)((e,t,n)=>{if(!ht()||!n)return;let r=++Qe.current;cn(e).then(e=>{Qe.current===r&&e&&($(),qe({...e,line:t||0,anchor:n}),z(``))})},[$,cn]),un=(0,W.useCallback)(()=>{Qe.current+=1,$(),B.current=window.setTimeout(()=>{qe(null)},250)},[$]),dn=(0,W.useCallback)((e,t)=>{cn(e).then(n=>{if(!n){me(`File Not Found`,e);return}if(ht()){Qe.current+=1,$(),qe(null),ze({...n,line:t||0}),z(``);return}n.type===`directory`?C({orchestratorId:n.orchestratorId,path:n.path,overlay:!0}):C({orchestratorId:n.orchestratorId,path:pt(n.path),selectedPath:n.path,line:t,overlay:!0})})},[$,C,cn,me]);function fn(){ze(null),z(``)}async function pn(e){let t=Array.from(e).filter(e=>e.size>0);if(!t.length)return;let n=t.map(e=>({id:`${Date.now()}-${e.name}-${Math.random().toString(16).slice(2)}`,fileName:e.name,size:e.size,previewUrl:e.type.startsWith(`image/`)?URL.createObjectURL(e):void 0,uploading:!0}));F(e=>[...e,...n]);for(let e=0;e<t.length;e+=1){let r=t[e],i=n[e];try{let e=await v(`/artifacts`,r,{filename:r.name,sensitivity:`normal`});F(t=>t.map(t=>t.id===i.id?{...t,artifact:e,uploading:!1}:t))}catch(e){F(t=>t.map(t=>t.id===i.id?{...t,error:e.message,uploading:!1}:t))}}}function mn(e){F(t=>{let n=t.find(t=>t.id===e);return n?.previewUrl&&URL.revokeObjectURL(n.previewUrl),t.filter(t=>t.id!==e)})}function hn(){an(P),F([])}function gn(){if(!J.trim()&&Q.length===0||!d||E||Z||ot)return;let e=Q.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));S(J,{peer:d,lastMessage:V?.lastMessage||null},e),hn()}function _n(e){if(X.length){if(e.key===`ArrowDown`){e.preventDefault(),Y(e=>Math.min(e+1,X.length-1));return}if(e.key===`ArrowUp`){e.preventDefault(),Y(e=>Math.max(e-1,0));return}if(e.key===`Escape`){e.preventDefault(),Ut(!0);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault();let t=X[Qt];t&&$t(t);return}}e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),gn())}function vn(e){let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),pn(t))}async function yn(){if(!xe||N!==`idle`||!d)return;ye.bargeIn();let e=new Se;try{await e.start(),Oe.current=e,je(`recording`)}catch(e){Oe.current=null,je(`idle`),me(`Microphone unavailable`,e?.message||`Could not access the microphone.`)}}async function bn(){let e=Oe.current;if(!(!e||N!==`recording`)){Oe.current=null,je(`transcribing`);try{let t=await e.stop();if(!t)return;let n=await Ce(t);if(!n)return;let r=J?`${J} ${n}`:n;if(Ee===`autosend`&&!E&&!Z){let e=Q.map(e=>({artifactId:e.artifact.id,kind:e.artifact.kind,role:`media`,title:e.artifact.filename||e.fileName}));S(r,{peer:d,lastMessage:V?.lastMessage||null},e),hn()}else ae(d,r)}catch(e){me(`Transcription failed`,e?.message||`Could not transcribe audio.`)}finally{je(`idle`)}}}return d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex h-full min-w-0`,children:[(0,G.jsxs)(`div`,{className:`@container/chat flex h-full min-w-0 flex-1 flex-col`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between px-3 md:px-4 py-2.5 md:py-3 border-b border-border shrink-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 md:gap-2.5 min-w-0`,children:[r&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,onClick:t,className:`shrink-0 -ml-1`,children:(0,G.jsx)(he,{className:`w-4 h-4`})}),(0,G.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 md:gap-2.5 min-w-0 hover:opacity-80 transition-opacity`,onClick:()=>U&&ee(U),disabled:!U,children:[(0,G.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,G.jsx)(Ye,{agent:U}),(0,G.jsx)(Ke,{agent:U,now:x,className:`absolute -bottom-0.5 -right-0.5 w-2 h-2`})]}),(0,G.jsxs)(`div`,{className:`min-w-0 text-left`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium truncate`,children:U?I(U):d}),U&&(0,G.jsxs)(`p`,{className:`text-xs text-muted-foreground truncate`,children:[_t?`blocked: ${_t.label}`:U.status,U.machine&&` · ${U.machine}`,typeof U.meta?.cwd==`string`&&U.meta.cwd&&` · ${ke(U.meta.cwd,1)}`]})]})]}),U&&(0,G.jsx)(Je,{agent:U,compact:!0,className:`hidden @4xl/chat:flex shrink-0`}),U?.context&&(0,G.jsx)(et,{utilization:U.context.utilization}),U?.branchState&&U.branchWorkspaceId&&(0,G.jsx)(at,{state:U.branchState,className:`shrink-0`,onClick:()=>void ce(U.branchWorkspaceId)}),V?.attention.unread?(0,G.jsxs)(Re,{className:`bg-red-500/20 text-red-400 text-xs shrink-0 hidden @2xl/chat:flex`,children:[V.attention.unread,` unread`]}):null]}),(0,G.jsx)(`div`,{className:`flex items-center gap-0.5 md:gap-1 shrink-0`,children:U&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Be,{value:U.id,label:`Copy agent ID`,size:`icon-sm`}),ye.available&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,title:we?`Speaking agent responses aloud — click to mute (engine & voice in Settings)`:`Speak agent responses aloud (active chat) — engine & voice in Settings`,className:we?`text-primary`:``,onClick:()=>Te(!we),children:we?(0,G.jsx)(T,{className:`w-3.5 h-3.5`}):(0,G.jsx)(de,{className:`w-3.5 h-3.5`})}),jt&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,disabled:lt,title:`Terminal`,onClick:()=>void dt(),children:(0,G.jsx)(ne,{className:`w-3.5 h-3.5`})}),Ft&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`text-red-400 hover:text-red-300`,title:`Interrupt`,onClick:It,children:(0,G.jsx)(m,{className:`w-3.5 h-3.5`})}),(U.branchState===`changes`||U.branchState===`idle`)&&U.branchWorkspaceId&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex text-amber-400 hover:text-amber-300`,title:`Mark workspace ready — hand off to the auto-merge`,onClick:()=>A(`Mark Workspace Ready`,`Mark ${I(U)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>se(U.branchWorkspaceId,`ready`)),children:(0,G.jsx)(a,{className:`w-3.5 h-3.5`})}),Mt&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Compact`,onClick:()=>A(`Compact Agent`,`Compact context for ${I(U)}?`,()=>k(U,`compact`)),children:(0,G.jsx)(l,{className:`w-3.5 h-3.5`})}),Nt&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Clear context`,onClick:()=>A(`Clear Context`,`Clear context for ${I(U)}?`,()=>k(U,`clearContext`)),children:(0,G.jsx)(c,{className:`w-3.5 h-3.5`})}),Pt&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Shutdown`,onClick:()=>A(`Shutdown Agent`,`Shutdown ${I(U)}?`,()=>k(U,`shutdown`)),children:(0,G.jsx)(_,{className:`w-3.5 h-3.5`})}),U&&typeof U.meta?.cwd==`string`&&U.meta.cwd&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Open ${U.meta.cwd} in Files`,onClick:()=>void w(U),children:(0,G.jsx)(s,{className:`w-3.5 h-3.5`})}),U&&V&&V.messages.length>0&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Fork — spawn new agent with this chat history`,onClick:()=>le(U.id,V.messages),children:(0,G.jsx)(_e,{className:`w-3.5 h-3.5`})}),V&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark unread`,onClick:()=>ie(d),children:(0,G.jsx)(te,{className:`w-3.5 h-3.5`})}),V&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Mark read`,onClick:()=>re(V.peer,V.messages),children:(0,G.jsx)(pe,{className:`w-3.5 h-3.5`})}),q&&(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`hidden @4xl/chat:inline-flex`,title:`Export thread`,onClick:()=>oe({...q,importedHistory:K},`json`),children:(0,G.jsx)(g,{className:`w-3.5 h-3.5`})}),(0,G.jsxs)(We,{children:[(0,G.jsx)(He,{asChild:!0,children:(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,className:`@4xl/chat:hidden`,children:(0,G.jsx)(f,{className:`w-3.5 h-3.5`})})}),(0,G.jsxs)(Ve,{align:`end`,children:[jt&&(0,G.jsxs)(H,{disabled:lt,onClick:()=>void dt(),children:[(0,G.jsx)(ne,{className:`w-3.5 h-3.5`}),`Terminal`]}),Ft&&(0,G.jsxs)(H,{onClick:It,children:[(0,G.jsx)(m,{className:`w-3.5 h-3.5`}),`Interrupt`]}),(U.branchState===`changes`||U.branchState===`idle`)&&U.branchWorkspaceId&&(0,G.jsxs)(H,{onClick:()=>A(`Mark Workspace Ready`,`Mark ${I(U)}'s branch ready to land? The relay auto-merge will rebase and land it.`,()=>se(U.branchWorkspaceId,`ready`)),children:[(0,G.jsx)(a,{className:`w-3.5 h-3.5`}),`Mark Ready`]}),Mt&&(0,G.jsxs)(H,{onClick:()=>A(`Compact Agent`,`Compact context for ${I(U)}?`,()=>k(U,`compact`)),children:[(0,G.jsx)(l,{className:`w-3.5 h-3.5`}),`Compact`]}),Nt&&(0,G.jsxs)(H,{onClick:()=>A(`Clear Context`,`Clear context for ${I(U)}?`,()=>k(U,`clearContext`)),children:[(0,G.jsx)(c,{className:`w-3.5 h-3.5`}),`Clear Context`]}),Pt&&(0,G.jsxs)(H,{onClick:()=>A(`Shutdown Agent`,`Shutdown ${I(U)}?`,()=>k(U,`shutdown`)),children:[(0,G.jsx)(_,{className:`w-3.5 h-3.5`}),`Shutdown`]}),U&&typeof U.meta?.cwd==`string`&&U.meta.cwd&&(0,G.jsxs)(H,{onClick:()=>void w(U),children:[(0,G.jsx)(s,{className:`w-3.5 h-3.5`}),`Open Files`]}),U&&V&&V.messages.length>0&&(0,G.jsxs)(H,{onClick:()=>le(U.id,V.messages),children:[(0,G.jsx)(_e,{className:`w-3.5 h-3.5`}),`Fork`]}),(jt||Mt||Nt||Pt)&&(0,G.jsx)(Ge,{}),V&&(0,G.jsxs)(H,{onClick:()=>ie(d),children:[(0,G.jsx)(te,{className:`w-3.5 h-3.5`}),`Mark Unread`]}),V&&(0,G.jsxs)(H,{onClick:()=>re(V.peer,V.messages),children:[(0,G.jsx)(pe,{className:`w-3.5 h-3.5`}),`Mark Read`]}),q&&(0,G.jsxs)(H,{onClick:()=>oe({...q,importedHistory:K},`json`),children:[(0,G.jsx)(g,{className:`w-3.5 h-3.5`}),`Download`]})]})]})]})})]}),(0,G.jsx)(`div`,{ref:bt.ref,onScroll:bt.onScroll,className:`flex-1 overflow-y-auto px-3 md:px-4 py-3 md:py-4`,style:{minHeight:0},children:nn.length===0?(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center`,children:[(0,G.jsx)(p,{className:`w-8 h-8 text-zinc-600 mb-2`}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No messages yet`})]}):(0,G.jsxs)(`div`,{children:[(0,G.jsx)(sn,{scrollRef:bt.ref,timeline:nn}),nn.map(e=>e.type===`message`?(0,G.jsx)(en,{msg:e.msg,peer:d,onOpenReferencedPath:dn,onPreviewReferencedPath:ln,onPreviewReferencedPathEnd:un},e.msg.id):e.type===`activity`?(0,G.jsx)(Vt,{steps:e.steps,showReasoning:M},`act-${e.steps[0]?.id??e.timestamp}`):e.type===`import-boundary`?(0,G.jsx)(Jt,{history:e.history},`import-${e.history.id}`):e.type===`imported-message`?(0,G.jsx)(Yt,{entry:e.entry,sourceLabel:e.history.sourceAgentLabel||e.history.sourcePeerId},`import-${e.history.id}-${e.entry.originalMessageId}-${e.entry.position}`):e.type===`status`?(0,G.jsx)(Lt,{event:e.event},e.event.id):e.type===`date`?(0,G.jsx)(Kt,{date:e.date},`d-${e.date}`):e.type===`created`?(0,G.jsx)(qt,{timestamp:e.timestamp},`created`):null),vt&&U&&(0,G.jsx)(Ht,{agentId:U.id,approval:vt}),U?.status===`busy`&&!vt&&(0,G.jsx)(Rt,{blockedLabel:_t?.label,onInterrupt:Ft?It:void 0})]})}),(0,G.jsxs)(`div`,{className:i(`relative shrink-0 border-t border-border px-3 md:px-4 py-2.5 md:py-3 safe-area-bottom`,Ie&&`bg-primary/5 ring-1 ring-primary/40`),onDragOver:e=>{e.preventDefault(),Le(!0)},onDragLeave:()=>Le(!1),onDrop:e=>{e.preventDefault(),Le(!1),pn(e.dataTransfer.files)},children:[P.length>0&&(0,G.jsx)(`div`,{className:`mb-2 grid gap-2 sm:grid-cols-2`,children:P.map(e=>(0,G.jsx)(Xt,{item:e,onRemove:()=>mn(e.id)},e.id))}),(0,G.jsx)(`input`,{ref:De,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&pn(e.target.files),e.currentTarget.value=``}}),X.length>0&&(0,G.jsx)(`div`,{className:`absolute bottom-full left-3 right-3 md:left-4 md:right-4 mb-2 z-20 max-h-64 overflow-auto rounded-xl border border-border bg-popover shadow-lg`,children:X.map((e,t)=>(0,G.jsxs)(`button`,{onMouseDown:t=>{t.preventDefault(),$t(e)},onMouseEnter:()=>Y(t),className:i(`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-sm`,t===Qt?`bg-accent`:`hover:bg-accent/50`),children:[(0,G.jsx)(`span`,{className:`font-medium shrink-0`,children:e.name}),e.argumentHint&&(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground shrink-0`,children:e.argumentHint}),e.description&&(0,G.jsx)(`span`,{className:`ml-auto truncate text-xs text-muted-foreground/70`,children:e.description})]},e.name))}),(0,G.jsxs)(`div`,{className:`hidden md:flex items-end gap-2`,children:[(0,G.jsx)(R,{variant:`ghost`,size:`icon`,title:`Attach files`,disabled:E,onClick:()=>De.current?.click(),className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px]`,children:(0,G.jsx)(u,{className:`w-4 h-4`})}),(0,G.jsx)(Dt,{value:J,onChange:e=>tn(e.target.value),onKeyDown:_n,onPaste:vn,placeholder:`Message ${U?I(U):d}…`,className:`flex-1`}),xe&&(0,G.jsx)(R,{variant:`ghost`,size:`icon`,title:N===`recording`?`Release to transcribe`:`Hold to talk`,disabled:E||N===`transcribing`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),yn()},onPointerUp:e=>{e.preventDefault();try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}bn()},className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px] ${N===`recording`?`text-red-400 animate-pulse`:``}`,children:N===`transcribing`?(0,G.jsx)(O,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(h,{className:`w-4 h-4`})}),(0,G.jsx)(R,{size:`icon`,disabled:!J.trim()&&Q.length===0||Z||E||ot,onClick:gn,className:`shrink-0 mb-0.5 rounded-xl h-[42px] w-[42px]`,children:(0,G.jsx)(o,{className:`w-4 h-4`})})]}),(0,G.jsxs)(`div`,{className:`md:hidden space-y-2`,children:[(0,G.jsx)(Dt,{value:J,onChange:e=>tn(e.target.value),onKeyDown:_n,onPaste:vn,placeholder:`Message ${U?I(U):d}…`,className:`w-full`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(R,{variant:`ghost`,size:`icon`,title:`Attach files`,disabled:E,onClick:()=>De.current?.click(),className:`rounded-xl h-9 w-9`,children:(0,G.jsx)(u,{className:`w-4 h-4`})}),xe&&(0,G.jsx)(R,{variant:`ghost`,size:`icon`,title:N===`recording`?`Release to transcribe`:`Hold to talk`,disabled:E||N===`transcribing`,onPointerDown:e=>{e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),yn()},onPointerUp:e=>{e.preventDefault();try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}bn()},className:`rounded-xl h-9 w-9 ${N===`recording`?`text-red-400 animate-pulse`:``}`,children:N===`transcribing`?(0,G.jsx)(O,{className:`w-4 h-4 animate-spin`}):(0,G.jsx)(h,{className:`w-4 h-4`})})]}),(0,G.jsx)(R,{size:`icon`,disabled:!J.trim()&&Q.length===0||Z||E||ot,onClick:gn,className:`rounded-xl h-9 w-9`,children:(0,G.jsx)(o,{className:`w-4 h-4`})})]})]}),(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1.5 hidden md:block`,children:ot?`${U?I(U):`Agent`} is wrapping up (${(U?.meta?.lifecycleAction).slice(11)}) — messaging paused`:`Enter to send · Shift+Enter for newline`})]})]}),L&&(0,G.jsxs)(`aside`,{className:`hidden h-full w-[min(44vw,720px)] min-w-[360px] shrink-0 flex-col border-l border-border bg-background xl:flex`,children:[(0,G.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,G.jsx)(`span`,{className:`min-w-0 flex-1 text-xs font-medium text-muted-foreground`,children:`File preview`}),Xe&&(0,G.jsx)(`span`,{className:`max-w-[18rem] truncate text-xs text-red-400`,children:Xe}),(0,G.jsx)(R,{variant:`ghost`,size:`icon-sm`,title:`Close preview`,onClick:fn,children:(0,G.jsx)(D,{className:`h-3.5 w-3.5`})})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:L.type===`directory`?(0,G.jsx)(nt,{orchestratorId:L.orchestratorId,selectedPath:L.path,onReadError:z}):(0,G.jsx)(rt,{orchestratorId:L.orchestratorId,selectedPath:L.path,line:L.line,onReadError:z})})]})]}),Ue&&(0,G.jsx)(Zt,{preview:Ue,error:Xe,onReadError:z,onMouseEnter:$,onMouseLeave:un}),ct&&(0,G.jsx)(Ze,{open:st,onOpenChange:ft,orchestratorId:ct.orchestratorId,session:ct.session,interactive:ct.interactive||kt})]}):(0,G.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4`,children:[(0,G.jsx)(p,{className:`w-12 h-12 text-zinc-600 mb-3`}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Select an agent to start chatting`})]})}function ln(){let e=B(),t=j(e=>e.selectedInboxThread),n=j(e=>e.set),r=xt(),i=!!t;Et(),(0,W.useEffect)(()=>{t&&(r.some(e=>e.id===t)||n({selectedInboxThread:``}))},[t,r,n]);function a(){n({selectedInboxThread:``})}return(0,G.jsxs)(`div`,{className:`flex -m-4 md:-m-6`,style:{height:`calc(100dvh - var(--header-h) - var(--sat))`},children:[(0,G.jsxs)(`div`,{className:`hidden md:flex w-full`,children:[(0,G.jsx)(`div`,{className:`w-1/3 min-w-[240px] max-w-xs flex flex-col overflow-hidden`,children:(0,G.jsx)(Ot,{threads:e})}),(0,G.jsx)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:(0,G.jsx)(cn,{threads:e},t||`empty`)})]}),(0,G.jsx)(`div`,{className:`md:hidden flex w-full overflow-hidden`,children:i?(0,G.jsx)(un,{children:(0,G.jsx)(cn,{threads:e,onBack:a,showBackButton:!0},t||`empty`)}):(0,G.jsx)(`div`,{className:`w-full flex flex-col overflow-hidden`,children:(0,G.jsx)(Ot,{threads:e})})})]})}function un({children:e}){let t=U();return(0,G.jsx)(`div`,{className:`fixed inset-x-0 top-0 z-40 flex flex-col bg-background pt-[var(--sat)]`,style:{height:t?`${t}px`:`100dvh`},children:e})}export{ln as ChatView};
2
- //# sourceMappingURL=chat-0ZbxHlDu.js.map