agent-relay-server 0.67.1 → 0.68.1

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 (92) hide show
  1. package/docs/openapi.json +1 -1
  2. package/package.json +2 -2
  3. package/public/assets/{MessageBubble-CgL7SMC9.js → MessageBubble-DPcJxTJj.js} +2 -2
  4. package/public/assets/{MessageBubble-CgL7SMC9.js.map → MessageBubble-DPcJxTJj.js.map} +1 -1
  5. package/public/assets/{PlanGraphPanel-C9M1YUH3.js → PlanGraphPanel-BYmE8ldg.js} +2 -2
  6. package/public/assets/{PlanGraphPanel-C9M1YUH3.js.map → PlanGraphPanel-BYmE8ldg.js.map} +1 -1
  7. package/public/assets/{activity-C0ki3CXN.js → activity-BzU196gP.js} +2 -2
  8. package/public/assets/{activity-C0ki3CXN.js.map → activity-BzU196gP.js.map} +1 -1
  9. package/public/assets/agent-profiles-CQuoP8Nr.js +2 -0
  10. package/public/assets/agent-profiles-CQuoP8Nr.js.map +1 -0
  11. package/public/assets/{agents-DVTyhojU.js → agents-qH6q44nK.js} +2 -2
  12. package/public/assets/{agents-DVTyhojU.js.map → agents-qH6q44nK.js.map} +1 -1
  13. package/public/assets/{analytics-D6ffu1ji.js → analytics-EJH9GFID.js} +2 -2
  14. package/public/assets/{analytics-D6ffu1ji.js.map → analytics-EJH9GFID.js.map} +1 -1
  15. package/public/assets/{automation-CKLQvSB-.js → automation-Dahmxg07.js} +2 -2
  16. package/public/assets/{automation-CKLQvSB-.js.map → automation-Dahmxg07.js.map} +1 -1
  17. package/public/assets/{branch-state-badge-DrwCnoKR.js → branch-state-badge-C7H8HY22.js} +2 -2
  18. package/public/assets/{branch-state-badge-DrwCnoKR.js.map → branch-state-badge-C7H8HY22.js.map} +1 -1
  19. package/public/assets/{channels-BuqbbyaO.js → channels-VhlwES_A.js} +2 -2
  20. package/public/assets/{channels-BuqbbyaO.js.map → channels-VhlwES_A.js.map} +1 -1
  21. package/public/assets/{chat-XM7zLIrJ.js → chat-DJqvtoFT.js} +2 -2
  22. package/public/assets/{chat-XM7zLIrJ.js.map → chat-DJqvtoFT.js.map} +1 -1
  23. package/public/assets/{connectors-_LpoKQNb.js → connectors-C03pRoXx.js} +2 -2
  24. package/public/assets/{connectors-_LpoKQNb.js.map → connectors-C03pRoXx.js.map} +1 -1
  25. package/public/assets/{formatted-body-impl-BOtgnE2e.js → formatted-body-impl-DhvR8Z-A.js} +2 -2
  26. package/public/assets/{formatted-body-impl-BOtgnE2e.js.map → formatted-body-impl-DhvR8Z-A.js.map} +1 -1
  27. package/public/assets/index-Dh7NjR-l.css +2 -0
  28. package/public/assets/{index-CARLLWss.js → index-VGRP16ua.js} +6 -6
  29. package/public/assets/index-VGRP16ua.js.map +1 -0
  30. package/public/assets/{insights-BuhwfZK_.js → insights-v9noub5E.js} +2 -2
  31. package/public/assets/{insights-BuhwfZK_.js.map → insights-v9noub5E.js.map} +1 -1
  32. package/public/assets/{integrations-DCyxAv8c.js → integrations-BEa3ArUw.js} +2 -2
  33. package/public/assets/{integrations-DCyxAv8c.js.map → integrations-BEa3ArUw.js.map} +1 -1
  34. package/public/assets/{maintenance-FVXyLhl7.js → maintenance-DyRfVkhp.js} +2 -2
  35. package/public/assets/{maintenance-FVXyLhl7.js.map → maintenance-DyRfVkhp.js.map} +1 -1
  36. package/public/assets/{managed-agents-CaeHrwda.js → managed-agents-BSdMoBgG.js} +2 -2
  37. package/public/assets/{managed-agents-CaeHrwda.js.map → managed-agents-BSdMoBgG.js.map} +1 -1
  38. package/public/assets/{markdown-preview-impl-Brm7jSxL.js → markdown-preview-impl-DidsrMmn.js} +2 -2
  39. package/public/assets/{markdown-preview-impl-Brm7jSxL.js.map → markdown-preview-impl-DidsrMmn.js.map} +1 -1
  40. package/public/assets/{memory-Drj5wn76.js → memory-DM8muGVW.js} +2 -2
  41. package/public/assets/{memory-Drj5wn76.js.map → memory-DM8muGVW.js.map} +1 -1
  42. package/public/assets/{messages-CSSnT5X4.js → messages-BqjAkcBF.js} +2 -2
  43. package/public/assets/{messages-CSSnT5X4.js.map → messages-BqjAkcBF.js.map} +1 -1
  44. package/public/assets/{orchestrators-FdF1O-b_.js → orchestrators-C_mjUDZg.js} +2 -2
  45. package/public/assets/{orchestrators-FdF1O-b_.js.map → orchestrators-C_mjUDZg.js.map} +1 -1
  46. package/public/assets/{overview-tqzRF2zO.js → overview-Cpu2plX-.js} +2 -2
  47. package/public/assets/{overview-tqzRF2zO.js.map → overview-Cpu2plX-.js.map} +1 -1
  48. package/public/assets/{pairs-CJiBSa2o.js → pairs--8_0A0lq.js} +2 -2
  49. package/public/assets/{pairs-CJiBSa2o.js.map → pairs--8_0A0lq.js.map} +1 -1
  50. package/public/assets/{projects-DtJmrhI0.js → projects-nCww9PG1.js} +2 -2
  51. package/public/assets/{projects-DtJmrhI0.js.map → projects-nCww9PG1.js.map} +1 -1
  52. package/public/assets/{security-CItvWUwq.js → security-CwgoEvJT.js} +2 -2
  53. package/public/assets/{security-CItvWUwq.js.map → security-CwgoEvJT.js.map} +1 -1
  54. package/public/assets/{select-CXen1oFN.js → select-Bhx6zSZr.js} +2 -2
  55. package/public/assets/{select-CXen1oFN.js.map → select-Bhx6zSZr.js.map} +1 -1
  56. package/public/assets/{settings-Dm2NtIMK.js → settings-BNQBnKXg.js} +2 -2
  57. package/public/assets/{settings-Dm2NtIMK.js.map → settings-BNQBnKXg.js.map} +1 -1
  58. package/public/assets/store-BB-YW24l.js +9 -0
  59. package/public/assets/store-BB-YW24l.js.map +1 -0
  60. package/public/assets/{tasks-DbyJbQLo.js → tasks-C5Kv18N7.js} +2 -2
  61. package/public/assets/{tasks-DbyJbQLo.js.map → tasks-C5Kv18N7.js.map} +1 -1
  62. package/public/assets/{teams-BtjasnAN.js → teams-D_Ttv7qD.js} +2 -2
  63. package/public/assets/{teams-BtjasnAN.js.map → teams-D_Ttv7qD.js.map} +1 -1
  64. package/public/assets/{terminal-viewer-impl-CbVuN1vi.js → terminal-viewer-impl-5y8v9jNx.js} +2 -2
  65. package/public/assets/{terminal-viewer-impl-CbVuN1vi.js.map → terminal-viewer-impl-5y8v9jNx.js.map} +1 -1
  66. package/public/assets/{work-queue-MP7UUAx7.js → work-queue-BB7bYLIK.js} +2 -2
  67. package/public/assets/{work-queue-MP7UUAx7.js.map → work-queue-BB7bYLIK.js.map} +1 -1
  68. package/public/assets/{workspaces-Bu4uVUcu.js → workspaces-CrtAeVnv.js} +2 -2
  69. package/public/assets/{workspaces-Bu4uVUcu.js.map → workspaces-CrtAeVnv.js.map} +1 -1
  70. package/public/index.html +3 -3
  71. package/runner/src/adapter.ts +11 -0
  72. package/src/agent-card-projection.ts +28 -0
  73. package/src/automations/dispatch.ts +2 -2
  74. package/src/bus.ts +5 -1
  75. package/src/config-store.ts +9 -3
  76. package/src/db/agent-search.ts +22 -8
  77. package/src/db/index.ts +1 -0
  78. package/src/db/migrations.ts +17 -0
  79. package/src/db/provisioning-registry.ts +278 -0
  80. package/src/db/schema.ts +16 -0
  81. package/src/managed-policy.ts +2 -1
  82. package/src/mcp/tools-messaging.ts +72 -3
  83. package/src/project-instructions.ts +41 -1
  84. package/src/routes/agent-sessions.ts +2 -2
  85. package/src/services/spawn-agent.ts +13 -17
  86. package/src/sse.ts +3 -4
  87. package/public/assets/agent-profiles-1Nx8ROA_.js +0 -2
  88. package/public/assets/agent-profiles-1Nx8ROA_.js.map +0 -1
  89. package/public/assets/index-CARLLWss.js.map +0 -1
  90. package/public/assets/index-eCpWfoCA.css +0 -2
  91. package/public/assets/store-BeKcuJ2q.js +0 -9
  92. package/public/assets/store-BeKcuJ2q.js.map +0 -1
package/docs/openapi.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "openapi": "3.1.0",
3
3
  "info": {
4
4
  "title": "Agent Relay API",
5
- "version": "0.67.1",
5
+ "version": "0.68.1",
6
6
  "description": "Real-time message bus for inter-agent communication. Agent-first: this spec is designed for machine consumption — agents can self-discover the full API surface via GET /api/spec.",
7
7
  "license": {
8
8
  "name": "MIT",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-relay-server",
3
- "version": "0.67.1",
3
+ "version": "0.68.1",
4
4
  "description": "Lightweight HTTP message relay for inter-agent communication across machines",
5
5
  "module": "src/index.ts",
6
6
  "type": "module",
@@ -33,7 +33,7 @@
33
33
  "CONTRIBUTING.md"
34
34
  ],
35
35
  "dependencies": {
36
- "agent-relay-sdk": "0.2.43",
36
+ "agent-relay-sdk": "0.2.44",
37
37
  "ajv": "^8.20.0"
38
38
  },
39
39
  "scripts": {
@@ -1,3 +1,3 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{An as t,Bn as n,Ct as r,F as i,Hn as a,Pt as o,Qn as s,Qt as c,R as l,Rn as u,St as d,Wt as f,at as p,b as m,bn as h,c as g,cn as _,ct as v,fn as ee,h as y,i as b,jn as x,ln as S,mn as C,nn as te,p as w,pn as T,r as E,tn as D,un as O,y as k,z as A}from"./lucide-react-BbMYCUlW.js";import{g as j,r as M,t as N}from"./store-BeKcuJ2q.js";import{D as P,I as F,M as ne,W as I,at as L,b as re,d as ie,f as ae,j as R,w as z,z as oe}from"./display-LAWaAboe.js";import{C as se,a as ce,i as le,o as ue,t as B}from"./index-CARLLWss.js";var V=e(s(),1),H={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`},de=new Set(Object.keys(H)),fe=3e3;function U(e){return new Date(e.occurredAt??e.createdAt).getTime()}function pe(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:U(e),turnId:typeof t.turnId==`string`?t.turnId:void 0}}function me(e){if(e.kind!==`session`)return null;let t=e.payload?.session;if(t?.type!==`notice`)return null;let n=typeof t.label==`string`&&t.label?t.label:`compacted`;return{id:`notice-${e.id}`,status:n,timestamp:U(e)}}function W(e,t){let n=e.trim();for(let e of t){let t=e.trim();if(t){if(n===t)break;n.startsWith(`${t}\n\n`)&&(n=n.slice(t.length+2).trimStart())}}return n.trim()||e.trim()}function G(e){return e.kind===`system`&&e.from===`system`}var he=new Set([`agent.ready`,`agent.exited`,`agent.spawn_failed`]);function K(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function ge(e){let t=e.filter(e=>de.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)<=fe)||n.push(e);return n}function _e(e,t,n,r=[],i){let a=[];for(let e of r){let t=e.entries.reduce((e,t)=>Math.min(e,I(t.originalCreatedAt)),1/0),n=Number.isFinite(t)?t-1:e.importedAt;a.push({ts:n,entry:{type:`import-boundary`,history:e,timestamp:n}});for(let t of e.entries)a.push({ts:I(t.originalCreatedAt),entry:{type:`imported-message`,history:e,entry:t}})}if(n){let e=new Date(n).getTime();Number.isFinite(e)&&a.push({ts:e,entry:{type:`created`,timestamp:e}})}if(i?.spawnedBy){let e=n?new Date(n).getTime():0,t=Number.isFinite(e)?e:0;a.push({ts:t,entry:{type:`agent-action`,direction:`spawned-by`,agentId:i.spawnedBy.agentId,provider:i.spawnedBy.provider,status:`ready`,timestamp:t}})}let o=i?.spawnedBy?.agentId,s=null,c=1/0;for(let t of e){if(t.kind===`session`||G(t)||z(t)||!(t.from===`user`||o!==void 0&&t.from===o)||!P(t).trim())continue;let e=U(t);e<c&&(c=e,s=t.id)}let l=new Map,u=new Map,d=new Map;for(let t of e){if(t.kind!==`session`)continue;let e=t.payload?.session;if(e?.type===`narration`&&typeof e.turnId==`string`){let n=u.get(e.turnId)??[];n.push({id:t.id,body:t.body.trim()}),u.set(e.turnId,n)}else if(e?.type===`response`&&typeof e.turnId==`string`){let n=l.get(e.turnId)??[];n.push(t.body.trim()),l.set(e.turnId,n)}}let f=new Map;for(let[e,t]of l){let n=(u.get(e)??[]).map(e=>e.body);f.set(e,t.map(e=>W(e,n)))}for(let t of e){if(t.kind!==`session`)continue;let e=t.payload?.session;if(e?.type!==`response`||typeof e.turnId!=`string`)continue;let n=W(t.body,(u.get(e.turnId)??[]).map(e=>e.body));n&&n!==t.body&&d.set(t.id,n)}let p=new Set;for(let[e,t]of f){let n=u.get(e)??[];for(let e of t)for(let t=n.length-1;t>=0;t--){let r=n[t];if(!p.has(r.id)&&oe(e,r.body)){p.add(r.id);break}}}let m=new Map,h=[];for(let t of e){if(G(t)){let e=typeof t.payload?.kind==`string`?t.payload.kind:``;if(he.has(e)){let n=t.payload,r=typeof n.agentId==`string`?n.agentId:``,i=U(t);if(!r){a.push({ts:i,entry:{type:`notice`,msg:t}});continue}let o=e===`agent.ready`?`ready`:e===`agent.exited`?`exited`:`failed`,s=m.get(r);if(s)s.entry.status=o,typeof n.reason==`string`&&(s.entry.reason=n.reason),s.entry.timestamp=i,s.ts=i;else{let e={ts:i,entry:{type:`agent-action`,direction:`spawned-child`,agentId:r,provider:typeof n.provider==`string`?n.provider:void 0,status:o,reason:typeof n.reason==`string`?n.reason:void 0,timestamp:i}};m.set(r,e),a.push(e)}continue}a.push({ts:U(t),entry:{type:`notice`,msg:t}});continue}let e=me(t);if(e){h.push(e);continue}let n=pe(t);if(n){if(n.kind===`narration`&&p.has(n.id))continue;a.push({ts:n.ts,entry:{type:`activity`,steps:[n],timestamp:n.ts}});continue}if(t.kind===`session`){let e=t.payload?.session;if(e?.type===`response`&&typeof e.turnId==`string`){let e=d.get(t.id);if(e&&e!==t.body){a.push({ts:U(t),entry:{type:`message`,msg:{...t,body:e}}});continue}}}let r=t.id===s?`initial-prompt`:`message`;a.push({ts:U(t),entry:{type:r,msg:t}})}for(let e of ge([...t,...h]))a.push({ts:e.timestamp,entry:{type:`status`,event:e}});let g={created:0,date:1,"import-boundary":2,"imported-message":3,"initial-prompt":4,message:4,activity:4,notice:4,"agent-action":4,status:5};a.sort((e,t)=>{let n=e.ts-t.ts;return Math.abs(n)<3e3&&g[e.entry.type]-g[t.entry.type]||n});let _=[],v=``;for(let{ts:e,entry:t}of a){if(t.type===`created`){_.push(t);continue}let n=K(e);if(n!==v&&(_.push({type:`date`,date:n,timestamp:e}),v=n),t.type===`activity`){let e=_[_.length-1];if(e&&e.type===`activity`&&be(e,t)){e.steps.push(...t.steps);continue}}_.push(t)}return _}function ve(e){return e.type===`message`?`msg-${e.msg.id}`:e.type===`initial-prompt`?`initprompt-${e.msg.id}`:e.type===`notice`?`notice-${e.msg.id}`:e.type===`agent-action`?`agent-action-${e.direction}-${e.agentId}`:e.type===`activity`?`act-${e.steps[0]?.id??e.timestamp}`:e.type===`import-boundary`?`import-${e.history.id}`:e.type===`imported-message`?`import-msg-${e.history.id}-${e.entry.originalMessageId}-${e.entry.position}`:e.type===`status`?`status-${e.event.id}`:e.type===`date`?`date-${e.date}`:`created-${e.timestamp}`}function ye(e){return e.type===`message`||e.type===`initial-prompt`||e.type===`notice`?(e.msg.subject?`${e.msg.subject} `:``)+P(e.msg):e.type===`imported-message`?P(e.entry.message):e.type===`activity`?e.steps.map(e=>[e.label,e.text].filter(Boolean).join(` `)).join(`
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{An as t,Bn as n,Ct as r,F as i,Hn as a,Pt as o,Qn as s,Qt as c,R as l,Rn as u,St as d,Wt as f,at as p,b as m,bn as h,c as g,cn as _,ct as v,fn as ee,h as y,i as b,jn as x,ln as S,mn as C,nn as te,p as w,pn as T,r as E,tn as D,un as O,y as k,z as A}from"./lucide-react-BbMYCUlW.js";import{g as j,r as M,t as N}from"./store-BB-YW24l.js";import{D as P,I as F,M as ne,W as I,at as L,b as re,d as ie,f as ae,j as R,w as z,z as oe}from"./display-LAWaAboe.js";import{C as se,a as ce,i as le,o as ue,t as B}from"./index-VGRP16ua.js";var V=e(s(),1),H={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`},de=new Set(Object.keys(H)),fe=3e3;function U(e){return new Date(e.occurredAt??e.createdAt).getTime()}function pe(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:U(e),turnId:typeof t.turnId==`string`?t.turnId:void 0}}function me(e){if(e.kind!==`session`)return null;let t=e.payload?.session;if(t?.type!==`notice`)return null;let n=typeof t.label==`string`&&t.label?t.label:`compacted`;return{id:`notice-${e.id}`,status:n,timestamp:U(e)}}function W(e,t){let n=e.trim();for(let e of t){let t=e.trim();if(t){if(n===t)break;n.startsWith(`${t}\n\n`)&&(n=n.slice(t.length+2).trimStart())}}return n.trim()||e.trim()}function G(e){return e.kind===`system`&&e.from===`system`}var he=new Set([`agent.ready`,`agent.exited`,`agent.spawn_failed`]);function K(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function ge(e){let t=e.filter(e=>de.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)<=fe)||n.push(e);return n}function _e(e,t,n,r=[],i){let a=[];for(let e of r){let t=e.entries.reduce((e,t)=>Math.min(e,I(t.originalCreatedAt)),1/0),n=Number.isFinite(t)?t-1:e.importedAt;a.push({ts:n,entry:{type:`import-boundary`,history:e,timestamp:n}});for(let t of e.entries)a.push({ts:I(t.originalCreatedAt),entry:{type:`imported-message`,history:e,entry:t}})}if(n){let e=new Date(n).getTime();Number.isFinite(e)&&a.push({ts:e,entry:{type:`created`,timestamp:e}})}if(i?.spawnedBy){let e=n?new Date(n).getTime():0,t=Number.isFinite(e)?e:0;a.push({ts:t,entry:{type:`agent-action`,direction:`spawned-by`,agentId:i.spawnedBy.agentId,provider:i.spawnedBy.provider,status:`ready`,timestamp:t}})}let o=i?.spawnedBy?.agentId,s=null,c=1/0;for(let t of e){if(t.kind===`session`||G(t)||z(t)||!(t.from===`user`||o!==void 0&&t.from===o)||!P(t).trim())continue;let e=U(t);e<c&&(c=e,s=t.id)}let l=new Map,u=new Map,d=new Map;for(let t of e){if(t.kind!==`session`)continue;let e=t.payload?.session;if(e?.type===`narration`&&typeof e.turnId==`string`){let n=u.get(e.turnId)??[];n.push({id:t.id,body:t.body.trim()}),u.set(e.turnId,n)}else if(e?.type===`response`&&typeof e.turnId==`string`){let n=l.get(e.turnId)??[];n.push(t.body.trim()),l.set(e.turnId,n)}}let f=new Map;for(let[e,t]of l){let n=(u.get(e)??[]).map(e=>e.body);f.set(e,t.map(e=>W(e,n)))}for(let t of e){if(t.kind!==`session`)continue;let e=t.payload?.session;if(e?.type!==`response`||typeof e.turnId!=`string`)continue;let n=W(t.body,(u.get(e.turnId)??[]).map(e=>e.body));n&&n!==t.body&&d.set(t.id,n)}let p=new Set;for(let[e,t]of f){let n=u.get(e)??[];for(let e of t)for(let t=n.length-1;t>=0;t--){let r=n[t];if(!p.has(r.id)&&oe(e,r.body)){p.add(r.id);break}}}let m=new Map,h=[];for(let t of e){if(G(t)){let e=typeof t.payload?.kind==`string`?t.payload.kind:``;if(he.has(e)){let n=t.payload,r=typeof n.agentId==`string`?n.agentId:``,i=U(t);if(!r){a.push({ts:i,entry:{type:`notice`,msg:t}});continue}let o=e===`agent.ready`?`ready`:e===`agent.exited`?`exited`:`failed`,s=m.get(r);if(s)s.entry.status=o,typeof n.reason==`string`&&(s.entry.reason=n.reason),s.entry.timestamp=i,s.ts=i;else{let e={ts:i,entry:{type:`agent-action`,direction:`spawned-child`,agentId:r,provider:typeof n.provider==`string`?n.provider:void 0,status:o,reason:typeof n.reason==`string`?n.reason:void 0,timestamp:i}};m.set(r,e),a.push(e)}continue}a.push({ts:U(t),entry:{type:`notice`,msg:t}});continue}let e=me(t);if(e){h.push(e);continue}let n=pe(t);if(n){if(n.kind===`narration`&&p.has(n.id))continue;a.push({ts:n.ts,entry:{type:`activity`,steps:[n],timestamp:n.ts}});continue}if(t.kind===`session`){let e=t.payload?.session;if(e?.type===`response`&&typeof e.turnId==`string`){let e=d.get(t.id);if(e&&e!==t.body){a.push({ts:U(t),entry:{type:`message`,msg:{...t,body:e}}});continue}}}let r=t.id===s?`initial-prompt`:`message`;a.push({ts:U(t),entry:{type:r,msg:t}})}for(let e of ge([...t,...h]))a.push({ts:e.timestamp,entry:{type:`status`,event:e}});let g={created:0,date:1,"import-boundary":2,"imported-message":3,"initial-prompt":4,message:4,activity:4,notice:4,"agent-action":4,status:5};a.sort((e,t)=>{let n=e.ts-t.ts;return Math.abs(n)<3e3&&g[e.entry.type]-g[t.entry.type]||n});let _=[],v=``;for(let{ts:e,entry:t}of a){if(t.type===`created`){_.push(t);continue}let n=K(e);if(n!==v&&(_.push({type:`date`,date:n,timestamp:e}),v=n),t.type===`activity`){let e=_[_.length-1];if(e&&e.type===`activity`&&be(e,t)){e.steps.push(...t.steps);continue}}_.push(t)}return _}function ve(e){return e.type===`message`?`msg-${e.msg.id}`:e.type===`initial-prompt`?`initprompt-${e.msg.id}`:e.type===`notice`?`notice-${e.msg.id}`:e.type===`agent-action`?`agent-action-${e.direction}-${e.agentId}`:e.type===`activity`?`act-${e.steps[0]?.id??e.timestamp}`:e.type===`import-boundary`?`import-${e.history.id}`:e.type===`imported-message`?`import-msg-${e.history.id}-${e.entry.originalMessageId}-${e.entry.position}`:e.type===`status`?`status-${e.event.id}`:e.type===`date`?`date-${e.date}`:`created-${e.timestamp}`}function ye(e){return e.type===`message`||e.type===`initial-prompt`||e.type===`notice`?(e.msg.subject?`${e.msg.subject} `:``)+P(e.msg):e.type===`imported-message`?P(e.entry.message):e.type===`activity`?e.steps.map(e=>[e.label,e.text].filter(Boolean).join(` `)).join(`
2
2
  `):``}function be(e,t){let n=e.steps[e.steps.length-1]?.turnId,r=t.steps[0]?.turnId;return n&&r?n===r:!n&&!r}function xe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Se(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 Ce(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>0?t.slice(0,n):`/`}function we(e,t){return e.filter(e=>e.status===`online`&&F(t,e.baseDir)).sort((e,t)=>R(t.baseDir).length-R(e.baseDir).length)[0]||e.find(e=>e.status===`online`)}function Te(){return typeof window<`u`&&window.matchMedia(`(min-width: 1280px)`).matches}function q(){return typeof window<`u`&&!!window.getSelection()?.toString()}function Ee(e){let t=e.payload?.attachments;return Array.isArray(t)?t.filter(e=>!!(e&&typeof e==`object`&&typeof e.artifactId==`string`)):[]}var De=[`👍`,`❤️`,`✅`,`👀`];function Oe(e){let t=new Map;for(let n of e.reactions||[]){let e=ne(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 J(e){return z(e)}function ke(e,t){let n=e.readBy||[],r=e.resolvedToAgent||t||e.to,i=r?n.includes(r):!1,a=n.some(e=>e!==L);if(i||a){let e=i?r:n.find(e=>e!==L);return{label:`read`,title:e?`Read by ${e}`:`Read by agent`,tone:`ok`,icon:C}}if(e.deliveryStatus===`delivered`)return{label:`delivered`,title:`Delivered to agent inbox`,tone:`ok`,icon:C};if(e.deliveryStatus===`queued`)return{label:`queued`,title:`Queued until the target agent is available`,tone:`warn`,icon:c};if(e.deliveryStatus===`failed`||e.deliveryStatus===`dead`){let t=e.deliveryPoisonReason||e.deliveryLastError||e.deliveryStatus;return{label:e.deliveryStatus,title:t,tone:`danger`,icon:_}}return{label:`sent`,title:`Accepted by Relay`,tone:`muted`,icon:T}}function Ae(e){let t=I(e.createdAt);return(e.reactions||[]).reduce((e,t)=>Math.max(e,I(t.updatedAt||t.createdAt)),t)}function je(e){return e?e.messages.reduce((e,t)=>Math.max(e,Ae(t)),0):0}function Me(e,t,n){return(e-t)*n}function Ne(e){if(!e)return 0;let t=0;for(let n of e.messages)re(n)&&(t=Math.max(t,I(n.createdAt)));return t}function Y(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Pe(e){for(let t of e)t.previewUrl&&URL.revokeObjectURL(t.previewUrl)}function Fe(e,t,n,r){if(e?.teamId)return{teamId:e.teamId};let i=[...t];n&&!i.some(e=>e.id===n.id)&&i.push(n);let a=i.filter(e=>e.threadId).reverse(),o=a.find(e=>!!r[M(e.threadId,e.channel)])??a[0];return o?.threadId?{threadId:o.threadId,...o.channel?{channel:o.channel}:{}}:null}var X=n(),Ie={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`};function Le(e){let t=new Date,[n,r,i]=e.split(`-`).map(Number),a=new Date(n,r-1,i);if(e===K(t.getTime()))return`Today`;let o=new Date(t);return o.setDate(o.getDate()-1),e===K(o.getTime())?`Yesterday`:a.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:a.getFullYear()===t.getFullYear()?void 0:`numeric`})}function Re({event:e}){return(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(D,{className:u(`w-2 h-2 fill-current`,Ie[e.status]||`text-zinc-400`)}),(0,X.jsx)(`span`,{children:H[e.status]||e.status}),(0,X.jsx)(`span`,{className:`text-muted-foreground/60`,children:Y(e.timestamp)})]}),(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}var ze={"branch.landed":d,"context.warning":w,"agent.context_threshold":w,"agent.resume_budget_exhausted":w,"agent.rate_limit_resume":A},Be={"branch.landed":`branch landed`,"context.warning":`context warning`,"agent.context_threshold":`context threshold reached`};function Ve(e){return e&&(e.includes(`.`)?e.slice(e.indexOf(`.`)+1):e).replace(/[._-]+/g,` `).trim()||`system signal`}function Z({agentId:e,fallbackLabel:t,className:n}){let r=N(t=>t.agentsById[e])||null,i=N(e=>e.openInboxThread),a=N(e=>e.switchView),o=r?ie(r):t||e;return(0,X.jsxs)(`button`,{type:`button`,className:u(`inline-flex max-w-full items-center gap-1 rounded px-1 text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,n),onClick:t=>{t.stopPropagation(),i(e),a(`chat`)},title:`Open chat for ${o}`,children:[(0,X.jsx)(se,{agent:r,className:`w-4 h-4 text-[10px]`}),(0,X.jsx)(`span`,{className:`max-w-[160px] truncate`,children:o})]})}function He({msg:e}){let t=e.payload??{},n=typeof t.sha==`string`?t.sha:``,r=n?n.slice(0,7):``,i=typeof t.author==`string`?t.author:``,a=typeof t.branch==`string`?t.branch:``,o=typeof t.base==`string`?t.base:``,s=t.pushed;return(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,X.jsxs)(`div`,{className:`flex max-w-full flex-wrap items-center justify-center gap-x-1.5 gap-y-0.5 rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2.5 py-1 text-xs text-emerald-300/90`,children:[(0,X.jsx)(d,{className:`h-3 w-3 shrink-0 text-emerald-400`}),(0,X.jsx)(`span`,{className:`text-emerald-300`,children:`branch landed`}),a&&o&&(0,X.jsxs)(`span`,{className:`font-mono text-emerald-200/70`,title:`${a} → ${o}`,children:[a,(0,X.jsx)(`span`,{className:`opacity-50`,children:` → `}),o]}),r&&(0,X.jsx)(`span`,{className:`rounded bg-emerald-500/15 px-1 font-mono text-emerald-200`,title:n,children:r}),i&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-emerald-300/80`,children:[(0,X.jsx)(`span`,{className:`opacity-70`,children:`by`}),(0,X.jsx)(Z,{agentId:i,className:`text-emerald-300/90 hover:text-emerald-100`})]}),s===!1&&(0,X.jsx)(`span`,{className:`text-amber-300/80`,title:`Local-only land — not pushed to origin`,children:`· local only`}),(0,X.jsx)(`span`,{className:`text-emerald-300/50`,children:Y(e.occurredAt??e.createdAt)})]}),(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Ue({msg:e}){let t=typeof e.payload?.kind==`string`?e.payload.kind:``;if(t===`branch.landed`)return(0,X.jsx)(He,{msg:e});let n=ze[t]??i,r=Be[t]??Ve(t);return(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-full border border-border bg-muted/30 px-2.5 py-1 text-xs text-muted-foreground`,children:[(0,X.jsx)(n,{className:`h-3 w-3`}),(0,X.jsx)(`span`,{children:r}),(0,X.jsx)(`span`,{className:`text-muted-foreground/60`,children:Y(e.occurredAt??e.createdAt)})]}),(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}var We={"spawned-child":{ready:`spawned`,exited:`spawned · exited`,failed:`spawn failed`},"spawned-by":{ready:`spawned by`,exited:`spawned by`,failed:`spawned by`}},Ge={"spawned-child-ready":l,"spawned-child-exited":p,"spawned-child-failed":_,"spawned-by-ready":x,"spawned-by-exited":x,"spawned-by-failed":x},Ke={"spawned-child-ready":`text-emerald-400`,"spawned-child-exited":`text-zinc-400`,"spawned-child-failed":`text-red-400`,"spawned-by-ready":`text-blue-400`,"spawned-by-exited":`text-blue-400`,"spawned-by-failed":`text-blue-400`};function qe({entry:e}){let t=`${e.direction}-${e.status}`,n=We[e.direction]?.[e.status]??e.direction,r=Ge[t]??i,a=Ke[t]??`text-muted-foreground`,o=e.status===`failed`;return(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,X.jsxs)(`div`,{className:u(`flex items-center gap-1.5 rounded-full border bg-muted/30 px-2.5 py-1 text-xs`,o?`border-red-500/30`:`border-border`),children:[(0,X.jsx)(r,{className:u(`h-3 w-3 shrink-0`,a)}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:n}),(0,X.jsx)(Z,{agentId:e.agentId}),e.reason&&o&&(0,X.jsxs)(`span`,{className:`text-red-400/80 max-w-[120px] truncate`,title:e.reason,children:[`— `,e.reason]}),(0,X.jsx)(`span`,{className:`text-muted-foreground/60 shrink-0`,children:Y(e.timestamp)})]}),(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Je({blockedLabel:e,onInterrupt:t}){return e?(0,X.jsx)(`div`,{className:`flex justify-start mb-3 animate-in fade-in slide-in-from-bottom-1 duration-150`,children:(0,X.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-red-500/30 px-4`,children:[(0,X.jsx)(_,{className:`w-3.5 h-3.5 text-red-400`}),(0,X.jsxs)(`span`,{className:`text-xs text-red-300`,children:[`blocked: `,e]})]})}):(0,X.jsx)(`div`,{className:`flex justify-start mb-3 animate-in fade-in slide-in-from-bottom-1 duration-150`,children:(0,X.jsxs)(`div`,{className:`flex h-9 items-center gap-2 rounded-2xl rounded-bl-sm bg-card ring-1 ring-foreground/10 px-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_infinite]`}),(0,X.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,X.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,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`working`}),t&&(0,X.jsxs)(`button`,{onClick:t,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,X.jsx)(te,{className:`w-3.5 h-3.5`}),`Stop`]})]})})}var Q=`agent-relay:chat-hide-tools`,$=(()=>{let e=new Set,t=(()=>{try{return window.localStorage.getItem(Q)===`on`}catch{return!1}})(),n=()=>e.forEach(e=>e());return typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===Q&&(t=e.newValue===`on`,n())}),{subscribe(t){return e.add(t),()=>e.delete(t)},get:()=>t,toggle(){t=!t;try{window.localStorage.setItem(Q,t?`on`:`off`)}catch{}n()}}})();function Ye(){return[(0,V.useSyncExternalStore)($.subscribe,$.get,()=>!1),$.toggle]}function Xe({steps:e,showReasoning:t,issueRepo:n}){let[r,i]=Ye(),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,X.jsx)(`div`,{className:`flex justify-start mb-2`,children:(0,X.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,X.jsx)(B,{text:e.text,issueRepo:n,className:`text-sm leading-relaxed break-words text-foreground/90 min-w-0`},e.id):e.kind===`reasoning`?(0,X.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground/80`,children:[(0,X.jsx)(h,{className:`w-3.5 h-3.5 mt-0.5 shrink-0 opacity-70`}),(0,X.jsx)(B,{text:e.text,issueRepo:n,className:`italic break-words min-w-0`})]},e.id):r?null:(0,X.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(y,{className:`w-3 h-3 mt-0.5 shrink-0 opacity-70`}),(0,X.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.label||`tool`}),e.text&&e.text.trim()&&e.text.trim()!==(e.label??``).trim()?(0,X.jsxs)(`span`,{className:`opacity-70`,children:[` — `,e.text]}):null]})]},e.id)),o>0&&(0,X.jsxs)(`button`,{onClick:i,className:`flex items-center gap-1 text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors text-left`,children:[(0,X.jsx)(O,{className:u(`w-3 h-3 shrink-0 transition-transform`,!r&&`rotate-90`)}),(0,X.jsx)(`span`,{children:r?`show ${o} tool step${o===1?``:`s`}`:`hide tool steps`})]})]})})}function Ze({date:e}){return(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-3 my-1`,children:[(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,X.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:Le(e)}),(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function Qe({timestamp:e}){let t=new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`});return(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground/60`,children:[`created `,t]}),(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function $e({history:e}){let t=e.sourceAgentLabel||e.sourcePeerId,n=e.entries.length;return(0,X.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,X.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,X.jsx)(r,{className:`h-3 w-3`}),(0,X.jsxs)(`span`,{children:[`forked history from `,t]}),(0,X.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[n,` `,n===1?`entry`:`entries`]})]}),(0,X.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function et({entry:e,sourceLabel:t,issueRepo:n}){let r=e.message,i=P(r),a=e.originalFrom===L;return(0,X.jsx)(`div`,{className:u(`flex mb-3 opacity-80`,a?`justify-end`:`justify-start`),children:(0,X.jsx)(`div`,{className:`max-w-[85%] md:max-w-[75%]`,children:(0,X.jsxs)(`div`,{className:u(`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,X.jsxs)(`div`,{className:u(`mb-1 text-[10px] uppercase tracking-normal`,a?`text-primary/70`:`text-muted-foreground`),children:[`forked history · `,a?`you`:t||e.originalFrom]}),(0,X.jsx)(B,{text:i,rawBody:r.body,issueRepo:n,className:`leading-relaxed`}),(0,X.jsxs)(`p`,{className:u(`mt-1 flex items-center justify-end gap-1.5 text-xs`,a?`text-primary/60`:`text-muted-foreground`),children:[(0,X.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.originalMessageId]}),(0,X.jsx)(`span`,{children:Y(e.originalCreatedAt)})]})]})})})}function tt({msg:e,issueRepo:t}){let n=P(e),r=Y(e.occurredAt??e.createdAt);return(0,X.jsx)(`div`,{"data-msg-id":e.id,className:`mb-3`,children:(0,X.jsxs)(`div`,{className:`rounded-xl border border-primary/30 bg-primary/[0.06] px-3.5 py-2.5 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-primary/80`,children:[(0,X.jsx)(k,{className:`h-3.5 w-3.5`}),(0,X.jsx)(`span`,{children:`Initial prompt`}),(0,X.jsx)(`span`,{className:`ml-auto text-[10px] font-normal normal-case text-muted-foreground/60`,children:r})]}),(0,X.jsx)(B,{text:n,rawBody:e.body,issueRepo:t,className:`text-sm leading-relaxed text-foreground`})]})})}function nt({scrollEl:e,timeline:t}){let[n,r]=(0,V.useState)(!0),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1),d=(0,V.useMemo)(()=>{for(let e=t.length-1;e>=0;e--){let n=t[e];if(!(!n||n.type!==`message`&&n.type!==`initial-prompt`)&&n.msg.from===`user`)return{id:n.msg.id,body:P(n.msg)}}return null},[t]);if((0,V.useEffect)(()=>{if(!d||!e){r(!0);return}let t=null,n=null,i=()=>{let i=e.querySelector(`[data-msg-id="${d.id}"]`);if(!i){t?.disconnect(),t=null,n=null,r(!1);return}let a=i.getBoundingClientRect(),o=e.getBoundingClientRect();l(a.top<o.top),i!==n&&(t?.disconnect(),n=i,t=new IntersectionObserver(([e])=>{e&&r(e.isIntersecting)},{root:e,threshold:0}),t.observe(i))};return i(),e.addEventListener(`scroll`,i,{passive:!0}),()=>{t?.disconnect(),e.removeEventListener(`scroll`,i)}},[d?.id,e]),n||!d||!d.body.trim())return null;let f=i?.id===d.id?i.value:!1,p=o?.id===d.id?o.value:!1;function m(){!e||!d||e.querySelector(`[data-msg-id="${d.id}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`})}let h=c?`↑`:`↓`;return p?(0,X.jsx)(`div`,{className:`flex shrink-0 bg-card/45 border-b border-border`,children:(0,X.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 transition-colors`,onClick:()=>s({id:d.id,value:!1}),children:[(0,X.jsx)(`span`,{children:`Your prompt`}),(0,X.jsx)(ee,{className:`w-3 h-3`})]})}):(0,X.jsxs)(`section`,{className:`flex shrink-0 flex-col border-b border-border bg-card/45 px-3 py-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground mb-0.5`,children:[(0,X.jsx)(`span`,{className:`font-medium text-primary/70`,children:`Your prompt`}),(0,X.jsxs)(`button`,{type:`button`,className:`ml-auto hover:text-foreground transition-colors`,onClick:m,children:[h,` scroll to original`]}),(0,X.jsx)(`button`,{type:`button`,className:`hover:text-foreground transition-colors`,onClick:()=>s({id:d.id,value:!0}),title:`Minimize`,children:(0,X.jsx)(S,{className:`w-3 h-3`})})]}),(0,X.jsx)(`p`,{className:u(`text-sm text-foreground leading-snug cursor-pointer`,!f&&`line-clamp-2`),onClick:()=>a({id:d.id,value:!f}),children:d.body})]})}function rt(){return(0,V.useSyncExternalStore)(e=>j.subscribe(e),()=>j.getPlayingKey(),()=>null)}function it({attachment:e,outbound:t}){let n=e.kind===`image`,r=e.title||e.artifactId,[i,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[d,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(!1);(0,V.useEffect)(()=>{let t=!1,n=null;async function r(){p(!0),l(null),s(null);try{let r=await a(`/artifacts/${encodeURIComponent(e.artifactId)}/content`);if(t)return;n=URL.createObjectURL(r),s(n)}catch(e){t||l(e.message)}finally{t||p(!1)}}return r(),()=>{t=!0,n&&URL.revokeObjectURL(n)}},[e.artifactId]);function g(){if(!i)return;let e=document.createElement(`a`);e.href=i,e.download=r,document.body.appendChild(e),e.click(),e.remove()}return n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>i&&h(!0),disabled:!i,className:`group/img mt-2 block overflow-hidden rounded-md border border-foreground/10 bg-black/10 text-left disabled:cursor-default relative`,children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`img`,{src:i,alt:r,loading:`lazy`,className:`block max-h-72 max-w-full object-contain`}),(0,X.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 group-hover/img:bg-black/30 transition-colors`,children:(0,X.jsx)(E,{className:`w-6 h-6 text-white opacity-0 group-hover/img:opacity-100 transition-opacity drop-shadow-md`})})]}):(0,X.jsxs)(`span`,{className:u(`flex min-h-20 items-center gap-2 px-3 py-2 text-xs`,c?`text-red-400`:`text-muted-foreground`),children:[d?(0,X.jsx)(v,{className:`h-4 w-4 animate-spin`}):(0,X.jsx)(_,{className:`h-4 w-4`}),c||`Loading image`]})}),i&&(0,X.jsx)(le,{open:m,onOpenChange:h,children:(0,X.jsxs)(ce,{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,X.jsx)(ue,{className:`sr-only`,children:r}),(0,X.jsxs)(`div`,{className:`relative flex items-center justify-center min-h-[200px]`,children:[(0,X.jsx)(`img`,{src:i,alt:r,className:`max-w-[93vw] max-h-[90vh] object-contain`}),(0,X.jsxs)(`div`,{className:`absolute top-2 right-2 flex gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:g,className:`rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Download`,children:(0,X.jsx)(f,{className:`w-4 h-4`})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>h(!1),className:`rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Close`,children:(0,X.jsx)(b,{className:`w-4 h-4`})})]})]})]})})]}):(0,X.jsxs)(`button`,{type:`button`,onClick:g,disabled:!i,className:u(`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`,t?`border-primary-foreground/20 bg-primary-foreground/10 hover:bg-primary-foreground/15`:`border-border bg-background hover:bg-muted`),children:[d?(0,X.jsx)(v,{className:`h-4 w-4 shrink-0 animate-spin`}):c?(0,X.jsx)(_,{className:`h-4 w-4 shrink-0 text-red-400`}):(0,X.jsx)(o,{className:`h-4 w-4 shrink-0`}),(0,X.jsx)(`span`,{className:u(`min-w-0 flex-1 truncate`,c&&`text-red-400`),children:c||r}),(0,X.jsx)(f,{className:`h-3.5 w-3.5 shrink-0`})]})}function at({open:e,onToggle:t,onReact:n}){return(0,X.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,X.jsx)(`button`,{type:`button`,title:`Add reaction`,onClick:t,className:u(`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,X.jsx)(m,{className:`h-3 w-3`})}),e&&(0,X.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:De.map(e=>(0,X.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 ot({msg:e,peer:n}){let[r,i]=(0,V.useState)(!1),a=N(e=>e.agentsById),o=e.from===n,s=(o?e.to:e.from)||``,c=a[o?n:s]?.issueRepo??a[n]?.issueRepo,l=!s||s===`broadcast`||s.includes(`:`),d=P(e),f=Y(e.occurredAt??e.createdAt),p=o?t:x;return(0,X.jsx)(`div`,{"data-msg-id":e.id,className:`flex justify-center mb-1.5`,children:(0,X.jsxs)(`div`,{className:`w-full max-w-[94%] rounded-md border border-border/50 bg-muted/15 px-2.5 py-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs cursor-pointer select-none`,onClick:()=>i(e=>!e),children:[(0,X.jsx)(O,{className:u(`h-3 w-3 shrink-0 text-muted-foreground/60 transition-transform`,r&&`rotate-90`)}),(0,X.jsx)(p,{className:`h-3 w-3 shrink-0 text-muted-foreground/70`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`Message `,o?`to`:`from`]}),l?(0,X.jsx)(`span`,{className:`shrink-0 font-medium text-muted-foreground`,children:ae(s,a)}):(0,X.jsx)(Z,{agentId:s,className:`shrink-0 px-0.5 text-foreground/80`}),!r&&(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground/50`,children:d}),(0,X.jsx)(`span`,{className:`ml-auto shrink-0 text-muted-foreground/40`,children:f})]}),r&&(0,X.jsx)(`div`,{className:`mt-1.5 pl-5`,children:(0,X.jsx)(B,{text:d,rawBody:e.body,issueRepo:c,className:`text-sm leading-relaxed text-foreground/90`})})]})})}var st=(0,V.memo)(function({msg:e,peer:t,onOpenReferencedPath:n,onPreviewReferencedPath:r,onPreviewReferencedPathEnd:i}){if(e.from!==`user`&&e.to!==`user`)return(0,X.jsx)(ot,{msg:e,peer:t});let a=e.from===L,o=N(e=>e.reactToMessage),s=N(e=>e.voiceTtsEnabled),c=rt(),l=N(e=>{let n=e.agentsById[t]?.meta?.cwd;return typeof n==`string`?n:``}),d=N(e=>e.agentsById[t]?.issueRepo),[f,p]=(0,V.useState)(!1),m=(0,V.useRef)(null),h=(0,V.useRef)(null),_=(0,V.useRef)(!1),v=P(e),ee=Y(e.occurredAt??e.createdAt),y=Ee(e),b=Oe(e),x=a?ke(e,t):null,S=x?.icon,C=c===String(e.id),w=s&&!a&&!J(e)&&v.trim().length>0;function T(t){t.stopPropagation(),C?j.bargeIn():j.speak(e.body,String(e.id))}(0,V.useEffect)(()=>{if(!f)return;function e(e){q()||m.current&&!m.current.contains(e.target)&&p(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[f]);function E(e){return Se(l||`/`,e)}function D(e,t){let r=E(e);n?.(r,t)}function O(e,t,n){let i=E(e);r?.(i,t,n)}function k(t){o(e,t),p(!1)}function A(e){e.button===0&&(h.current={x:e.clientX,y:e.clientY},_.current=!1)}function M(e){let t=h.current;t&&(Math.abs(e.clientX-t.x)>3||Math.abs(e.clientY-t.y)>3)&&(_.current=!0)}function F(t){if(!(J(e)||a)&&!t.target.closest(`a,button,input,textarea,select,[role="button"]`)){if(_.current||q()){_.current=!1;return}p(e=>!e)}}return(0,X.jsx)(`div`,{"data-msg-id":e.id,className:u(`group/msg flex mb-3`,a?`justify-end`:`justify-start`),children:(0,X.jsxs)(`div`,{ref:m,className:`relative max-w-[85%] md:max-w-[75%]`,children:[w&&(0,X.jsx)(`button`,{type:`button`,title:C?`Stop playback`:`Play aloud`,onClick:T,className:u(`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,X.jsx)(te,{className:`h-3.5 w-3.5 animate-pulse`}):(0,X.jsx)(g,{className:`h-3.5 w-3.5`})}),(0,X.jsxs)(`div`,{className:u(`rounded-2xl px-3.5 py-2 text-sm select-text`,!a&&!J(e)&&`cursor-pointer`,a?`bg-primary text-primary-foreground rounded-br-sm`:`bg-card ring-1 ring-foreground/10 rounded-bl-sm`),onPointerDown:A,onPointerMove:M,onClick:F,children:[e.subject&&(0,X.jsx)(`p`,{className:u(`text-xs font-semibold mb-1`,a?`text-primary-foreground/70`:`text-muted-foreground`),children:e.subject}),(0,X.jsx)(B,{text:v,rawBody:e.body,issueRepo:d,className:`leading-relaxed`,onOpenPath:D,onPreviewPath:O,onPreviewPathEnd:i,resolvePathTitle:(e,t)=>`${E(e)}${t?`:${t}`:``}`}),y.map(t=>(0,X.jsx)(it,{attachment:t,outbound:a},`${e.id}-${t.artifactId}-${t.role||``}`)),(0,X.jsxs)(`p`,{className:u(`text-xs mt-1 flex items-center gap-1.5`,a?`justify-end text-primary-foreground/60`:`justify-end text-muted-foreground`),children:[(0,X.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.id]}),(0,X.jsx)(`span`,{children:ee}),x&&S&&(0,X.jsxs)(`span`,{className:u(`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,X.jsx)(S,{className:`h-3 w-3`}),x.label]})]})]}),!J(e)&&b.length>0&&(0,X.jsxs)(`div`,{className:u(`flex flex-wrap items-center gap-0.5 -mt-1 relative z-10`,a?`justify-end pr-2`:`justify-start pl-2`),children:[!a&&(0,X.jsx)(at,{open:f,onToggle:()=>p(e=>!e),onReact:k}),b.map(e=>(0,X.jsxs)(`button`,{type:`button`,title:e.actors.join(`, `),onClick:()=>k(e.emoji),className:u(`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,X.jsx)(`span`,{children:e.emoji}),e.count>1&&(0,X.jsx)(`span`,{children:e.count})]},e.emoji))]}),!J(e)&&!a&&b.length===0&&(0,X.jsx)(`div`,{className:`absolute -bottom-2.5 left-1 z-20`,children:(0,X.jsx)(at,{open:f,onToggle:()=>p(e=>!e),onReact:k})})]})})});export{ve as C,_e as S,Ce as _,Qe as a,Te as b,et as c,Re as d,nt as f,we as g,Ne as h,Je as i,tt as l,xe as m,Xe as n,Ze as o,Me as p,qe as r,$e as s,st as t,Ue as u,Fe as v,ye as w,je as x,Pe as y};
3
- //# sourceMappingURL=MessageBubble-CgL7SMC9.js.map
3
+ //# sourceMappingURL=MessageBubble-DPcJxTJj.js.map