agent-relay-server 0.98.0 → 0.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/openapi.json +70 -1
- package/package.json +2 -2
- package/public/assets/{MessageBubble-C4AeEHdz.js → MessageBubble-DiorZXyB.js} +2 -2
- package/public/assets/{MessageBubble-C4AeEHdz.js.map → MessageBubble-DiorZXyB.js.map} +1 -1
- package/public/assets/{PlanGraphPanel-cwPUGFXA.js → PlanGraphPanel-DY1p8v4p.js} +2 -2
- package/public/assets/{PlanGraphPanel-cwPUGFXA.js.map → PlanGraphPanel-DY1p8v4p.js.map} +1 -1
- package/public/assets/{activity-BWGwnSg5.js → activity-rIxqUtFC.js} +2 -2
- package/public/assets/{activity-BWGwnSg5.js.map → activity-rIxqUtFC.js.map} +1 -1
- package/public/assets/{agent-profiles-C6N9cTJg.js → agent-profiles-Cu-VkJm4.js} +2 -2
- package/public/assets/{agent-profiles-C6N9cTJg.js.map → agent-profiles-Cu-VkJm4.js.map} +1 -1
- package/public/assets/{agents-FUBxhCEU.js → agents-dRHOBDUe.js} +2 -2
- package/public/assets/{agents-FUBxhCEU.js.map → agents-dRHOBDUe.js.map} +1 -1
- package/public/assets/{automation-CMketzfB.js → automation-B0cyCT5l.js} +2 -2
- package/public/assets/{automation-CMketzfB.js.map → automation-B0cyCT5l.js.map} +1 -1
- package/public/assets/{chat-BV_pnRhk.js → chat-jit-e6S_.js} +2 -2
- package/public/assets/{chat-BV_pnRhk.js.map → chat-jit-e6S_.js.map} +1 -1
- package/public/assets/{formatted-body-impl-DzHQTBmn.js → formatted-body-impl-ZwgTH3jh.js} +2 -2
- package/public/assets/{formatted-body-impl-DzHQTBmn.js.map → formatted-body-impl-ZwgTH3jh.js.map} +1 -1
- package/public/assets/index-B95vV-dd.css +2 -0
- package/public/assets/index-GoC6YrKn.js +23 -0
- package/public/assets/index-GoC6YrKn.js.map +1 -0
- package/public/assets/{insights-C_pJNcFD.js → insights-C3mlXZdd.js} +2 -2
- package/public/assets/{insights-C_pJNcFD.js.map → insights-C3mlXZdd.js.map} +1 -1
- package/public/assets/{maintenance-Ckz5BAor.js → maintenance-DL1lnqmG.js} +2 -2
- package/public/assets/{maintenance-Ckz5BAor.js.map → maintenance-DL1lnqmG.js.map} +1 -1
- package/public/assets/{managed-agents-BbZclnqP.js → managed-agents-7A6WH4Rn.js} +2 -2
- package/public/assets/{managed-agents-BbZclnqP.js.map → managed-agents-7A6WH4Rn.js.map} +1 -1
- package/public/assets/{markdown-preview-impl-CtuHw6Mm.js → markdown-preview-impl-THat8xv0.js} +2 -2
- package/public/assets/{markdown-preview-impl-CtuHw6Mm.js.map → markdown-preview-impl-THat8xv0.js.map} +1 -1
- package/public/assets/{memory-C5DK3rhW.js → memory-C349UJe9.js} +2 -2
- package/public/assets/{memory-C5DK3rhW.js.map → memory-C349UJe9.js.map} +1 -1
- package/public/assets/{messages-CsjtiFEb.js → messages-DXoLFj2P.js} +2 -2
- package/public/assets/{messages-CsjtiFEb.js.map → messages-DXoLFj2P.js.map} +1 -1
- package/public/assets/{orchestrators-D9fMiBRy.js → orchestrators-CTXu4jAn.js} +2 -2
- package/public/assets/{orchestrators-D9fMiBRy.js.map → orchestrators-CTXu4jAn.js.map} +1 -1
- package/public/assets/{overview-BLWoCnNQ.js → overview-dWiN6TyN.js} +2 -2
- package/public/assets/{overview-BLWoCnNQ.js.map → overview-dWiN6TyN.js.map} +1 -1
- package/public/assets/{pairs-HnvpLz4C.js → pairs-KIXektDv.js} +2 -2
- package/public/assets/{pairs-HnvpLz4C.js.map → pairs-KIXektDv.js.map} +1 -1
- package/public/assets/{registry-BqAS3ADV.js → registry-C-Y41yGB.js} +2 -2
- package/public/assets/{registry-BqAS3ADV.js.map → registry-C-Y41yGB.js.map} +1 -1
- package/public/assets/{security-CWgtcQ2X.js → security-BUymkwuj.js} +2 -2
- package/public/assets/{security-CWgtcQ2X.js.map → security-BUymkwuj.js.map} +1 -1
- package/public/assets/{select-UdIYiKFs.js → select-DV25WRP5.js} +2 -2
- package/public/assets/{select-UdIYiKFs.js.map → select-DV25WRP5.js.map} +1 -1
- package/public/assets/{settings-ruDxPuza.js → settings-C1En58bx.js} +2 -2
- package/public/assets/{settings-ruDxPuza.js.map → settings-C1En58bx.js.map} +1 -1
- package/public/assets/{tasks-DomQFwZP.js → tasks-BkpnKA63.js} +2 -2
- package/public/assets/{tasks-DomQFwZP.js.map → tasks-BkpnKA63.js.map} +1 -1
- package/public/assets/{teams-CXNp0U3B.js → teams-D-UYp7yH.js} +2 -2
- package/public/assets/{teams-CXNp0U3B.js.map → teams-D-UYp7yH.js.map} +1 -1
- package/public/assets/{terminal-viewer-impl-DiWBtzvZ.js → terminal-viewer-impl-Bif-tkvD.js} +2 -2
- package/public/assets/{terminal-viewer-impl-DiWBtzvZ.js.map → terminal-viewer-impl-Bif-tkvD.js.map} +1 -1
- package/public/assets/{user-avatar-DBs9Koqp.js → user-avatar--czLv_AJ.js} +2 -2
- package/public/assets/{user-avatar-DBs9Koqp.js.map → user-avatar--czLv_AJ.js.map} +1 -1
- package/public/assets/{work-queue-BD29QuLd.js → work-queue-DN4oTe7w.js} +2 -2
- package/public/assets/{work-queue-BD29QuLd.js.map → work-queue-DN4oTe7w.js.map} +1 -1
- package/public/index.html +2 -2
- package/runner/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/src/db/provider-quotas.ts +22 -6
- package/src/notification-types.ts +3 -1
- package/src/quota-advisory.ts +2 -0
- package/src/quota-band-transition.ts +147 -0
- package/src/quota.ts +1 -1
- package/src/routes/index.ts +2 -1
- package/src/routes/provider-quotas.ts +18 -0
- package/src/routing-policy-push.ts +1 -1
- package/src/security.ts +2 -0
- package/src/spawn-targets.ts +41 -1
- package/public/assets/index-CYLrIuJT.css +0 -2
- package/public/assets/index-CdEAo41I.js +0 -23
- package/public/assets/index-CdEAo41I.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.
|
|
5
|
+
"version": "0.99.0",
|
|
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",
|
|
@@ -1068,6 +1068,75 @@
|
|
|
1068
1068
|
]
|
|
1069
1069
|
}
|
|
1070
1070
|
},
|
|
1071
|
+
"/api/provider-quotas/advisory": {
|
|
1072
|
+
"get": {
|
|
1073
|
+
"operationId": "getProviderQuotaAdvisoryRoute",
|
|
1074
|
+
"summary": "Provider quota burn advisories",
|
|
1075
|
+
"tags": [
|
|
1076
|
+
"Agents"
|
|
1077
|
+
],
|
|
1078
|
+
"description": "Returns the per-provider quota burn band and penalty, computed from the routing policy thresholds. Used by the dashboard quota widget to display a band badge alongside per-account burn projections already available in the quota matrix. Only providers with active quota records appear in the map.",
|
|
1079
|
+
"responses": {
|
|
1080
|
+
"200": {
|
|
1081
|
+
"description": "Advisory map keyed by provider id.",
|
|
1082
|
+
"content": {
|
|
1083
|
+
"application/json": {
|
|
1084
|
+
"schema": {
|
|
1085
|
+
"type": "object",
|
|
1086
|
+
"required": [
|
|
1087
|
+
"advisories"
|
|
1088
|
+
],
|
|
1089
|
+
"properties": {
|
|
1090
|
+
"advisories": {
|
|
1091
|
+
"type": "object",
|
|
1092
|
+
"additionalProperties": {
|
|
1093
|
+
"type": "object",
|
|
1094
|
+
"required": [
|
|
1095
|
+
"quotaPenaltyBand",
|
|
1096
|
+
"quotaPenalty",
|
|
1097
|
+
"blockedNow"
|
|
1098
|
+
],
|
|
1099
|
+
"properties": {
|
|
1100
|
+
"quotaPenaltyBand": {
|
|
1101
|
+
"type": "string",
|
|
1102
|
+
"enum": [
|
|
1103
|
+
"normal",
|
|
1104
|
+
"caution",
|
|
1105
|
+
"avoid-large",
|
|
1106
|
+
"hard-avoid"
|
|
1107
|
+
],
|
|
1108
|
+
"description": "Derived burn band across all recognized quota windows for this provider."
|
|
1109
|
+
},
|
|
1110
|
+
"quotaPenalty": {
|
|
1111
|
+
"type": "number",
|
|
1112
|
+
"description": "Aggregate quota penalty score (0 = no pressure)."
|
|
1113
|
+
},
|
|
1114
|
+
"blockedNow": {
|
|
1115
|
+
"type": "boolean",
|
|
1116
|
+
"description": "True when at least one quota window has reached the hard-backstop utilization."
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
},
|
|
1127
|
+
"security": [
|
|
1128
|
+
{
|
|
1129
|
+
"bearerAuth": []
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
"tokenHeader": []
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
"tokenQuery": []
|
|
1136
|
+
}
|
|
1137
|
+
]
|
|
1138
|
+
}
|
|
1139
|
+
},
|
|
1071
1140
|
"/api/provider-quotas": {
|
|
1072
1141
|
"get": {
|
|
1073
1142
|
"operationId": "getProviderQuotasRoute",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-relay-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.99.0",
|
|
4
4
|
"description": "Lightweight HTTP message relay for inter-agent communication across machines",
|
|
5
5
|
"module": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"CONTRIBUTING.md"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"agent-relay-sdk": "0.2.
|
|
37
|
+
"agent-relay-sdk": "0.2.80",
|
|
38
38
|
"ajv": "^8.20.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./chunk-CilyBKbf.js";import{$t as t,An as n,B as r,Cn as i,Dt as a,Fn as o,Hn as s,L as c,Ot as l,Qn as u,Qt as d,Sn as f,Un as p,V as m,Vt as h,Xn as g,_n as _,a as v,b as y,c as ee,dr as b,er as x,ft as S,g as C,hn as te,i as ne,ln as w,lt as T,m as E,on as D,r as re,un as O,vn as ie,x as k,xn as ae,yn as A}from"./lucide-react-BYZuAhQs.js";import{g as j,r as M,t as N}from"./store-pKbf_WYd.js";import{E as P,H as oe,N as F,P as I,R as se,S as ce,V as le,_ as ue,d as de,f as fe,k as L,q as R,rt as z,v as pe}from"./display-DRiGi1zj.js";import{t as B}from"./types-Tv67voFu.js";import{D as V,a as me,i as he,l as ge,t as H}from"./index-
|
|
1
|
+
import{r as e}from"./chunk-CilyBKbf.js";import{$t as t,An as n,B as r,Cn as i,Dt as a,Fn as o,Hn as s,L as c,Ot as l,Qn as u,Qt as d,Sn as f,Un as p,V as m,Vt as h,Xn as g,_n as _,a as v,b as y,c as ee,dr as b,er as x,ft as S,g as C,hn as te,i as ne,ln as w,lt as T,m as E,on as D,r as re,un as O,vn as ie,x as k,xn as ae,yn as A}from"./lucide-react-BYZuAhQs.js";import{g as j,r as M,t as N}from"./store-pKbf_WYd.js";import{E as P,H as oe,N as F,P as I,R as se,S as ce,V as le,_ as ue,d as de,f as fe,k as L,q as R,rt as z,v as pe}from"./display-DRiGi1zj.js";import{t as B}from"./types-Tv67voFu.js";import{D as V,a as me,i as he,l as ge,t as H}from"./index-GoC6YrKn.js";import{t as _e}from"./user-avatar--czLv_AJ.js";var U=e(b(),1),ve={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`},ye=new Set(Object.keys(ve)),be=3e3;function W(e){return new Date(e.occurredAt??e.createdAt).getTime()}function xe(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:W(e),turnId:typeof t.turnId==`string`?t.turnId:void 0}}function Se(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:W(e)}}function Ce(e){if(e.kind!==`session`)return null;let t=e.payload?.session;if(t?.type!==`relay-injection`)return null;let n=t.relayInjection&&typeof t.relayInjection==`object`&&!Array.isArray(t.relayInjection)?t.relayInjection:{},r=typeof n.category==`string`&&[`memory`,`instructions`,`tools`,`comms`,`knowledge`,`context`].includes(n.category)?n.category:`context`,i=typeof n.timestamp==`number`&&Number.isFinite(n.timestamp)?n.timestamp:W(e),a=n.detail&&typeof n.detail==`object`&&!Array.isArray(n.detail)?n.detail:{};return{id:e.id,category:r,summary:typeof n.summary==`string`&&n.summary.trim()?n.summary:e.body,detail:a,agentId:typeof n.agentId==`string`&&n.agentId?n.agentId:e.from,timestamp:i}}function we(e){if(e.kind!==`session`)return null;let t=e.payload?.session;if(t?.type!==`prompt-resolution`)return null;let n=t.promptResolution&&typeof t.promptResolution==`object`&&!Array.isArray(t.promptResolution)?t.promptResolution:{},r=n.kind===`questions`||n.kind===`plan`||n.kind===`command`||n.kind===`tool`?n.kind:`tool`,i=typeof n.title==`string`&&n.title.trim()?n.title:`Prompt resolved`,a=typeof n.decisionLabel==`string`&&n.decisionLabel.trim()?n.decisionLabel:typeof t.label==`string`&&t.label.trim()?t.label:`Resolved`,o=n.answers&&typeof n.answers==`object`&&!Array.isArray(n.answers)?n.answers:{};return{id:e.id,title:i,kind:r,body:typeof n.promptBody==`string`?n.promptBody:typeof n.body==`string`?n.body:e.body,toolName:typeof n.toolName==`string`&&n.toolName.trim()?n.toolName:i,decisionLabel:a,questions:Te(n.questions,o,a),timestamp:W(e)}}function Te(e,t,n){let r=(Array.isArray(e)?e:[]).map((e,r)=>{let i=e&&typeof e==`object`&&!Array.isArray(e)?e:{},a=typeof i.question==`string`&&i.question.trim()?i.question.trim():typeof i.header==`string`&&i.header.trim()?i.header.trim():`Question ${r+1}`,o=t[a]??t[String(i.question??``)]??t[String(i.header??``)];return{question:a,answer:typeof o==`string`&&o.trim()?o.trim():n}});return r.length?r:Object.entries(t).map(([e,t])=>({question:e,answer:t}))}function Ee(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 De(e){return e.kind===`system`&&e.from===`system`}var Oe=new Set([`agent.ready`,`agent.exited`,`agent.spawn_failed`]);function G(e){let t=new Date(e);return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}function ke(e){let t=e.filter(e=>ye.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)<=be)||n.push(e);return n}function Ae(e,t,n,r=[],i){let a=[];for(let e of r){let t=e.entries.reduce((e,t)=>Math.min(e,R(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:R(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`||De(t)||P(t)||!(t.from===`user`||o!==void 0&&t.from===o)||!L(t).trim())continue;let e=W(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=>Ee(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=Ee(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(De(t)){let e=typeof t.payload?.kind==`string`?t.payload.kind:``;if(Oe.has(e)){let n=t.payload,r=typeof n.agentId==`string`?n.agentId:``,i=W(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:W(t),entry:{type:`notice`,msg:t}});continue}let e=Se(t);if(e){h.push(e);continue}let n=xe(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}let r=Ce(t);if(r){a.push({ts:r.timestamp,entry:{type:`relay-injection`,event:r}});continue}let i=we(t);if(i){a.push({ts:i.timestamp,entry:{type:`prompt-resolution`,event:i}});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:W(t),entry:{type:`message`,msg:{...t,body:e}}});continue}}}let o=t.id===s?`initial-prompt`:`message`;a.push({ts:W(t),entry:{type:o,msg:t}})}for(let e of ke([...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,"relay-injection":4,"prompt-resolution":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=G(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`&&Ne(e,t)){e.steps.push(...t.steps);continue}}_.push(t)}return _}function je(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===`relay-injection`?`relay-injection-${e.event.id}`:e.type===`prompt-resolution`?`prompt-resolution-${e.event.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 Me(e){return e.type===`message`||e.type===`initial-prompt`||e.type===`notice`?(e.msg.subject?`${e.msg.subject} `:``)+L(e.msg):e.type===`imported-message`?L(e.entry.message):e.type===`activity`?e.steps.map(e=>[e.label,e.text].filter(Boolean).join(` `)).join(`
|
|
2
2
|
`):e.type===`relay-injection`?`${e.event.category} ${e.event.summary}\n${JSON.stringify(e.event.detail)}`:e.type===`prompt-resolution`?[e.event.title,e.event.decisionLabel,e.event.body,...e.event.questions.map(e=>`${e.question} ${e.answer}`)].filter(Boolean).join(`
|
|
3
3
|
`):``}function Ne(e,t){let n=e.steps[e.steps.length-1]?.turnId,r=t.steps[0]?.turnId;return n&&r?n===r:!n&&!r}function Pe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Fe(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 Ie(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>0?t.slice(0,n):`/`}function Le(e,t){return e.filter(e=>e.status===`online`&&se(t,e.baseDir)).sort((e,t)=>F(t.baseDir).length-F(e.baseDir).length)[0]||e.find(e=>e.status===`online`)}function Re(){return typeof window<`u`&&window.matchMedia(`(min-width: 1280px)`).matches}function ze(){return typeof window<`u`&&!!window.getSelection()?.toString()}function Be(e){let t=e.payload?.attachments;return Array.isArray(t)?t.filter(e=>!!(e&&typeof e==`object`&&typeof e.artifactId==`string`)):[]}var Ve=[`👍`,`❤️`,`✅`,`👀`];function He(e){let t=new Map;for(let n of e.reactions||[]){let e=I(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 K(e){return P(e)}function Ue(e,t){let n=e.readBy||[],r=e.resolvedToAgent||t||e.to,a=r?n.includes(r):!1,o=n.some(e=>e!==z);if(a||o){let e=a?r:n.find(e=>e!==z);return{label:`read`,title:e?`Read by ${e}`:`Read by agent`,tone:`ok`,icon:i}}if(e.deliveryStatus===`delivered`)return{label:`delivered`,title:`Delivered to agent inbox`,tone:`ok`,icon:i};if(e.deliveryStatus===`queued`)return{label:`queued`,title:`Queued until the target agent is available`,tone:`warn`,icon:D};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:f}}function We(e){let t=R(e.createdAt);return(e.reactions||[]).reduce((e,t)=>Math.max(e,R(t.updatedAt||t.createdAt)),t)}function Ge(e){return e?e.messages.reduce((e,t)=>Math.max(e,We(t)),0):0}function Ke(e,t,n){return(e-t)*n}function qe(e){if(!e)return 0;let t=0;for(let n of e.messages)ce(n)&&(t=Math.max(t,R(n.createdAt)));return t}function q(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function Je(e){for(let t of e)t.previewUrl&&URL.revokeObjectURL(t.previewUrl)}function Ye(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 J=u(),Xe={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 Ze(e){let t=new Date,[n,r,i]=e.split(`-`).map(Number),a=new Date(n,r-1,i);if(e===G(t.getTime()))return`Today`;let o=new Date(t);return o.setDate(o.getDate()-1),e===G(o.getTime())?`Yesterday`:a.toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`,year:a.getFullYear()===t.getFullYear()?void 0:`numeric`})}function Qe({event:e}){return(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,J.jsx)(w,{className:g(`w-2 h-2 fill-current`,Xe[e.status]||`text-zinc-400`)}),(0,J.jsx)(`span`,{children:ve[e.status]||e.status}),(0,J.jsx)(`span`,{className:`text-muted-foreground/60`,children:q(e.timestamp)})]}),(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}var $e={"branch.landed":a,"context.warning":E,"agent.context_threshold":E,"agent.resume_budget_exhausted":E,"agent.rate_limit_resume":m},et={"branch.landed":`branch landed`,"context.warning":`context warning`,"agent.context_threshold":`context threshold reached`};function tt(e){return e&&(e.includes(`.`)?e.slice(e.indexOf(`.`)+1):e).replace(/[._-]+/g,` `).trim()||`system signal`}function Y({agentId:e,fallbackLabel:t,className:n,noIcon:r}){let i=N(t=>t.agentsById[e])||null,a=N(e=>e.openInboxThread),o=N(e=>e.switchView),s=i?de(i):t||e;return(0,J.jsxs)(`button`,{type:`button`,className:g(`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(),a(e),o(`chat`)},title:`Open chat for ${s}`,children:[!r&&(0,J.jsx)(V,{agent:i,className:`w-4 h-4 text-[10px]`}),(0,J.jsx)(`span`,{className:`max-w-[160px] truncate`,children:s})]})}function nt({msg:e}){let t=e.payload??{},n=it(e),r=typeof t.sha==`string`?t.sha:``,i=r?r.slice(0,7):``,o=typeof t.author==`string`?t.author:``,s=typeof t.branch==`string`?t.branch:``,c=typeof t.base==`string`?t.base:``,l=t.pushed;return(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,J.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-600/35 bg-emerald-500/10 px-2.5 py-1 text-xs text-emerald-700 dark:border-emerald-500/25 dark:text-emerald-300/90`,children:[(0,J.jsx)(a,{className:`h-3 w-3 shrink-0 text-emerald-600 dark:text-emerald-400`}),(0,J.jsx)(`span`,{className:`text-emerald-700 dark:text-emerald-300`,children:`branch landed`}),s&&c&&(0,J.jsxs)(`span`,{className:`font-mono text-emerald-700/80 dark:text-emerald-200/70`,title:`${s} → ${c}`,children:[s,(0,J.jsx)(`span`,{className:`opacity-50`,children:` → `}),c]}),i&&(0,J.jsx)(`span`,{className:`rounded bg-emerald-500/15 px-1 font-mono text-emerald-800 dark:text-emerald-200`,title:r,children:i}),o&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-emerald-700/80 dark:text-emerald-300/80`,children:[(0,J.jsx)(`span`,{className:`opacity-70`,children:`by`}),(0,J.jsx)(Y,{agentId:o,className:`text-emerald-700 hover:text-emerald-900 dark:text-emerald-300/90 dark:hover:text-emerald-100`})]}),l===!1&&(0,J.jsx)(`span`,{className:`text-amber-600 dark:text-amber-300/80`,title:`Local-only land — not pushed to origin`,children:`· local only`}),n&&(0,J.jsxs)(`span`,{className:`max-w-[220px] truncate text-emerald-700/70 dark:text-emerald-300/70`,title:n,children:[`· because `,n]}),(0,J.jsx)(`span`,{className:`text-emerald-700/60 dark:text-emerald-300/50`,children:q(e.occurredAt??e.createdAt)})]}),(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function rt({msg:e}){let t=typeof e.payload?.kind==`string`?e.payload.kind:``;if(t===`branch.landed`)return(0,J.jsx)(nt,{msg:e});let n=$e[t]??c,r=et[t]??tt(t),i=it(e);return(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,J.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,J.jsx)(n,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:r}),i&&(0,J.jsxs)(`span`,{className:`max-w-[220px] truncate text-muted-foreground/80`,title:i,children:[`· because `,i]}),(0,J.jsx)(`span`,{className:`text-muted-foreground/60`,children:q(e.occurredAt??e.createdAt)})]}),(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function it(e){let t=e.payload?.routing;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.reason;return typeof n==`string`?n:``}var at={"spawned-child":{ready:`spawned`,exited:`spawned · exited`,failed:`spawn failed`},"spawned-by":{ready:`spawned by`,exited:`spawned by`,failed:`spawned by`}},ot={"spawned-child-ready":r,"spawned-child-exited":T,"spawned-child-failed":_,"spawned-by-ready":p,"spawned-by-exited":p,"spawned-by-failed":p},st={"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 ct({entry:e}){let t=`${e.direction}-${e.status}`,n=at[e.direction]?.[e.status]??e.direction,r=ot[t]??c,i=st[t]??`text-muted-foreground`,a=e.status===`failed`;return(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,J.jsxs)(`div`,{className:g(`flex items-center gap-1.5 rounded-full border bg-muted/30 px-2.5 py-1 text-xs`,a?`border-red-500/30`:`border-border`),children:[(0,J.jsx)(r,{className:g(`h-3 w-3 shrink-0`,i)}),(0,J.jsx)(`span`,{className:`text-muted-foreground`,children:n}),(0,J.jsx)(Y,{agentId:e.agentId}),e.reason&&a&&(0,J.jsxs)(`span`,{className:`text-red-400/80 max-w-[120px] truncate`,title:e.reason,children:[`— `,e.reason]}),(0,J.jsx)(`span`,{className:`text-muted-foreground/60 shrink-0`,children:q(e.timestamp)})]}),(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}var lt={memory:n,instructions:h,tools:v,comms:c,knowledge:o,context:t},ut={memory:`border-emerald-500/25 bg-emerald-500/10 text-emerald-300`,instructions:`border-sky-500/25 bg-sky-500/10 text-sky-300`,tools:`border-amber-500/25 bg-amber-500/10 text-amber-300`,comms:`border-violet-500/25 bg-violet-500/10 text-violet-300`,knowledge:`border-cyan-500/25 bg-cyan-500/10 text-cyan-300`,context:`border-zinc-500/25 bg-zinc-500/10 text-zinc-300`};function dt(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function ft({entry:e}){let[t,n]=(0,U.useState)(!1),r=e.event,i=lt[r.category]??y;return(0,J.jsx)(`div`,{className:`flex justify-center py-2 my-1`,children:(0,J.jsxs)(`div`,{className:g(`w-full max-w-[85%] md:max-w-[75%] rounded-lg border px-2.5 py-1.5 text-xs shadow-sm`,ut[r.category]??ut.context),children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex w-full min-w-0 items-center gap-1.5 text-left`,onClick:()=>n(e=>!e),children:[(0,J.jsx)(i,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`shrink-0 font-medium`,children:r.category}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground/80`,children:r.summary}),(0,J.jsx)(`span`,{className:`shrink-0 text-muted-foreground/60`,children:q(r.timestamp)}),(0,J.jsx)(A,{className:g(`h-3.5 w-3.5 shrink-0 transition-transform`,t&&`rotate-90`)})]}),t&&(0,J.jsx)(`pre`,{className:`mt-2 max-h-72 overflow-auto rounded-md border border-border/60 bg-background/75 p-2 font-mono text-[11px] leading-relaxed text-muted-foreground whitespace-pre-wrap break-words`,children:dt(r.detail)})]})})}function pt({blockedLabel:e,onInterrupt:t}){return e?(0,J.jsx)(`div`,{className:`flex justify-start mb-3 animate-in fade-in slide-in-from-bottom-1 duration-150`,children:(0,J.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,J.jsx)(_,{className:`w-3.5 h-3.5 text-red-400`}),(0,J.jsxs)(`span`,{className:`text-xs text-red-300`,children:[`blocked: `,e]})]})}):(0,J.jsx)(`div`,{className:`flex justify-start mb-3 animate-in fade-in slide-in-from-bottom-1 duration-150`,children:(0,J.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,J.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,J.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-yellow-400 animate-[pulse_1.4s_ease-in-out_infinite]`}),(0,J.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,J.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,J.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`working`}),t&&(0,J.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,J.jsx)(O,{className:`w-3.5 h-3.5`}),`Stop`]})]})})}var X=`agent-relay:chat-hide-tools`,Z=(()=>{let e=new Set,t=(()=>{try{return window.localStorage.getItem(X)===`on`}catch{return!1}})(),n=()=>e.forEach(e=>e());return typeof window<`u`&&window.addEventListener(`storage`,e=>{e.key===X&&(t=e.newValue===`on`,n())}),{subscribe(t){return e.add(t),()=>e.delete(t)},get:()=>t,toggle(){t=!t;try{window.localStorage.setItem(X,t?`on`:`off`)}catch{}n()}}})();function mt(){return[(0,U.useSyncExternalStore)(Z.subscribe,Z.get,()=>!1),Z.toggle]}function ht({steps:e,showReasoning:t,issueRepo:r}){let[i,a]=mt(),o=t?e:e.filter(e=>e.kind!==`reasoning`);if(!o.length)return null;let s=o.filter(e=>e.kind===`tool`).length;return(0,J.jsx)(`div`,{className:`flex justify-start mb-2`,children:(0,J.jsxs)(`div`,{className:`max-w-[85%] md:max-w-[75%] min-w-0 space-y-1.5`,children:[o.map(e=>e.kind===`narration`?(0,J.jsx)(H,{text:e.text,issueRepo:r,className:`text-sm leading-relaxed break-words text-foreground/90 min-w-0`},e.id):e.kind===`reasoning`?(0,J.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground/80`,children:[(0,J.jsx)(n,{className:`w-3.5 h-3.5 mt-0.5 shrink-0 opacity-70`}),(0,J.jsx)(H,{text:e.text,issueRepo:r,className:`italic break-words min-w-0`})]},e.id):i?null:(0,J.jsxs)(`div`,{className:`flex items-start gap-1.5 text-xs leading-relaxed text-muted-foreground`,children:[(0,J.jsx)(C,{className:`w-3 h-3 mt-0.5 shrink-0 opacity-70`}),(0,J.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,J.jsx)(`span`,{className:`font-medium`,children:e.label||`tool`}),e.text&&e.text.trim()&&e.text.trim()!==(e.label??``).trim()?(0,J.jsxs)(`span`,{className:`opacity-70`,children:[` — `,e.text]}):null]})]},e.id)),s>0&&(0,J.jsxs)(`button`,{onClick:a,className:`flex items-center gap-1 text-[11px] text-muted-foreground/50 hover:text-muted-foreground transition-colors text-left`,children:[(0,J.jsx)(A,{className:g(`w-3 h-3 shrink-0 transition-transform`,!i&&`rotate-90`)}),(0,J.jsx)(`span`,{children:i?`show ${s} tool step${s===1?``:`s`}`:`hide tool steps`})]})]})})}function gt({entry:e}){let{event:t}=e,n=t.kind===`questions`,r=n?t.title:t.kind===`plan`?`Plan prompt`:`${t.toolName} permission`;return(0,J.jsx)(`div`,{className:`flex justify-center py-1.5`,children:(0,J.jsxs)(`div`,{className:`w-full max-w-2xl rounded-md border border-border bg-muted/20 px-3 py-2 text-sm`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(te,{className:`h-3.5 w-3.5 text-emerald-500`}),(0,J.jsx)(`span`,{className:`font-medium text-foreground`,children:r}),(0,J.jsx)(`span`,{children:t.decisionLabel}),(0,J.jsx)(`span`,{className:`ml-auto shrink-0 text-muted-foreground/60`,children:q(t.timestamp)})]}),n&&t.questions.length>0?(0,J.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:t.questions.map((e,t)=>(0,J.jsxs)(`div`,{className:`grid gap-0.5`,children:[(0,J.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:e.question}),(0,J.jsx)(`div`,{className:`text-sm text-foreground`,children:e.answer})]},`${e.question}-${t}`))}):t.body.trim()?(0,J.jsx)(`div`,{className:`mt-2 max-h-48 overflow-auto rounded border border-border/70 bg-background/40 px-2 py-1.5 text-sm`,children:(0,J.jsx)(H,{text:t.body})}):null]})})}function _t({date:e}){return(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-3 my-1`,children:[(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,J.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:Ze(e)}),(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function vt({timestamp:e}){let t=new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,year:`numeric`,hour:`2-digit`,minute:`2-digit`});return(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,J.jsxs)(`span`,{className:`text-xs text-muted-foreground/60`,children:[`created `,t]}),(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function yt({history:e}){let t=e.sourceAgentLabel||e.sourcePeerId,n=e.entries.length;return(0,J.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-2 my-1`,children:[(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`}),(0,J.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,J.jsx)(l,{className:`h-3 w-3`}),(0,J.jsxs)(`span`,{children:[`forked history from `,t]}),(0,J.jsxs)(`span`,{className:`text-muted-foreground/60`,children:[n,` `,n===1?`entry`:`entries`]})]}),(0,J.jsx)(`div`,{className:`h-px flex-1 bg-border`})]})}function bt({entry:e,sourceLabel:t,issueRepo:n}){let r=e.message,i=L(r),a=e.originalFrom===z;return(0,J.jsx)(`div`,{className:g(`flex mb-3 opacity-80`,a?`justify-end`:`justify-start`),children:(0,J.jsx)(`div`,{className:`max-w-[85%] md:max-w-[75%]`,children:(0,J.jsxs)(`div`,{className:g(`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,J.jsxs)(`div`,{className:g(`mb-1 text-[10px] uppercase tracking-normal`,a?`text-primary/70`:`text-muted-foreground`),children:[`forked history · `,a?`you`:t||e.originalFrom]}),(0,J.jsx)(H,{text:i,rawBody:r.body,issueRepo:n,className:`leading-relaxed`}),(0,J.jsxs)(`p`,{className:g(`mt-1 flex items-center justify-end gap-1.5 text-xs`,a?`text-primary/60`:`text-muted-foreground`),children:[(0,J.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.originalMessageId]}),(0,J.jsx)(`span`,{children:q(e.originalCreatedAt)})]})]})})})}function Q({msg:e,issueRepo:t}){let n=L(e),r=q(e.occurredAt??e.createdAt);return(0,J.jsx)(`div`,{"data-msg-id":e.id,className:`mb-3`,children:(0,J.jsxs)(`div`,{className:`rounded-xl border border-primary/30 bg-primary/[0.06] px-3.5 py-2.5 shadow-sm`,children:[(0,J.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide text-primary/80`,children:[(0,J.jsx)(y,{className:`h-3.5 w-3.5`}),(0,J.jsx)(`span`,{children:`Initial prompt`}),(0,J.jsx)(`span`,{className:`ml-auto text-[10px] font-normal normal-case text-muted-foreground/60`,children:r})]}),(0,J.jsx)(H,{text:n,rawBody:e.body,issueRepo:t,className:`text-sm leading-relaxed text-foreground`})]})})}function xt({scrollEl:e,timeline:t}){let[n,r]=(0,U.useState)(!0),[i,a]=(0,U.useState)(null),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(!1),u=(0,U.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:L(n.msg)}}return null},[t]);if((0,U.useEffect)(()=>{if(!u||!e){r(!0);return}let t=null,n=null,i=()=>{let i=e.querySelector(`[data-msg-id="${u.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)}},[u?.id,e]),n||!u||!u.body.trim())return null;let d=i?.id===u.id?i.value:!1,f=o?.id===u.id?o.value:!1;function p(){!e||!u||e.querySelector(`[data-msg-id="${u.id}"]`)?.scrollIntoView({behavior:`smooth`,block:`center`})}let m=c?`↑`:`↓`;return f?(0,J.jsx)(`div`,{className:`flex shrink-0 bg-card/45 border-b border-border`,children:(0,J.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:u.id,value:!1}),children:[(0,J.jsx)(`span`,{children:`Your prompt`}),(0,J.jsx)(ae,{className:`w-3 h-3`})]})}):(0,J.jsxs)(`section`,{className:`flex shrink-0 flex-col border-b border-border bg-card/45 px-3 py-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground mb-0.5`,children:[(0,J.jsx)(`span`,{className:`font-medium text-primary/70`,children:`Your prompt`}),(0,J.jsxs)(`button`,{type:`button`,className:`ml-auto hover:text-foreground transition-colors`,onClick:p,children:[m,` scroll to original`]}),(0,J.jsx)(`button`,{type:`button`,className:`hover:text-foreground transition-colors`,onClick:()=>s({id:u.id,value:!0}),title:`Minimize`,children:(0,J.jsx)(ie,{className:`w-3 h-3`})})]}),(0,J.jsx)(`p`,{className:g(`text-sm text-foreground leading-snug cursor-pointer`,!d&&`line-clamp-2`),onClick:()=>a({id:u.id,value:!d}),children:u.body})]})}function St(){return(0,U.useSyncExternalStore)(e=>j.subscribe(e),()=>j.getPlayingKey(),()=>null)}function Ct({msg:e,peer:t}){return(0,J.jsx)(Q,{msg:e,issueRepo:N(e=>e.agentsById[t]?.issueRepo)})}function wt({agent:e,onClick:t}){let n=!!(t&&e);return(0,J.jsx)(`button`,{type:`button`,title:e?e.label||e.name||e.id:void 0,onClick:t,disabled:!n,className:g(`shrink-0 self-end transition-opacity`,n?`cursor-pointer hover:opacity-80`:`cursor-default opacity-60`),children:(0,J.jsx)(V,{agent:e})})}function Tt({agentId:e,onOpen:t}){let n=N(t=>t.agentsById[e]??null);return(0,J.jsx)(wt,{agent:n,onClick:n?()=>t(n):void 0})}function Et({attachment:e,outbound:t}){let n=e.kind===`image`,r=e.title||e.artifactId,[i,a]=(0,U.useState)(null),[o,s]=(0,U.useState)(null),[c,l]=(0,U.useState)(!1),[u,f]=(0,U.useState)(!1);(0,U.useEffect)(()=>{let t=!1,n=null;async function r(){l(!0),s(null),a(null);try{let r=await x(`/artifacts/${encodeURIComponent(e.artifactId)}/content`);if(t)return;n=URL.createObjectURL(r),a(n)}catch(e){t||s(e.message)}finally{t||l(!1)}}return r(),()=>{t=!0,n&&URL.revokeObjectURL(n)}},[e.artifactId]);function p(){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,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>i&&f(!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,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`img`,{src:i,alt:r,loading:`lazy`,className:`block max-h-72 max-w-full object-contain`}),(0,J.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 group-hover/img:bg-black/30 transition-colors`,children:(0,J.jsx)(re,{className:`w-6 h-6 text-white opacity-0 group-hover/img:opacity-100 transition-opacity drop-shadow-md`})})]}):(0,J.jsxs)(`span`,{className:g(`flex min-h-20 items-center gap-2 px-3 py-2 text-xs`,o?`text-red-400`:`text-muted-foreground`),children:[c?(0,J.jsx)(S,{className:`h-4 w-4 animate-spin`}):(0,J.jsx)(_,{className:`h-4 w-4`}),o||`Loading image`]})}),i&&(0,J.jsx)(he,{open:u,onOpenChange:f,children:(0,J.jsxs)(me,{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,J.jsx)(ge,{className:`sr-only`,children:r}),(0,J.jsxs)(`div`,{className:`relative flex items-center justify-center min-h-[200px]`,children:[(0,J.jsx)(`img`,{src:i,alt:r,className:`max-w-[93vw] max-h-[90vh] object-contain`}),(0,J.jsxs)(`div`,{className:`absolute top-2 right-2 flex gap-1`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:p,className:`rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Download`,children:(0,J.jsx)(d,{className:`w-4 h-4`})}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>f(!1),className:`rounded-md bg-black/60 hover:bg-black/80 p-2 text-white transition-colors`,title:`Close`,children:(0,J.jsx)(ne,{className:`w-4 h-4`})})]})]})]})})]}):(0,J.jsxs)(`button`,{type:`button`,onClick:p,disabled:!i,className:g(`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:[c?(0,J.jsx)(S,{className:`h-4 w-4 shrink-0 animate-spin`}):o?(0,J.jsx)(_,{className:`h-4 w-4 shrink-0 text-red-400`}):(0,J.jsx)(h,{className:`h-4 w-4 shrink-0`}),(0,J.jsx)(`span`,{className:g(`min-w-0 flex-1 truncate`,o&&`text-red-400`),children:o||r}),(0,J.jsx)(d,{className:`h-3.5 w-3.5 shrink-0`})]})}function $({open:e,onToggle:t,onReact:n}){return(0,J.jsxs)(`div`,{className:`relative shrink-0`,children:[(0,J.jsx)(`button`,{type:`button`,title:`Add reaction`,onClick:t,className:g(`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,J.jsx)(k,{className:`h-3 w-3`})}),e&&(0,J.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:Ve.map(e=>(0,J.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 Dt({msg:e,peer:t}){let[n,r]=(0,U.useState)(!1),i=N(e=>e.agentsById),a=N(e=>e.openAgentDetail),o=e.from===t,c=(o?e.to:e.from)||``,l=i[o?t:c]?.issueRepo??i[t]?.issueRepo,u=!c||c===`broadcast`||c.includes(`:`),d=L(e),f=q(e.occurredAt??e.createdAt),m=o?s:p,h=i[e.from??``]??null;function _(e){e.stopPropagation(),h&&a(h)}return(0,J.jsx)(`div`,{"data-msg-id":e.id,className:`flex justify-center mb-1.5`,children:(0,J.jsxs)(`div`,{className:`w-full max-w-[94%] rounded-md border border-border/50 bg-muted/15 px-2.5 py-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs cursor-pointer select-none`,onClick:()=>r(e=>!e),children:[(0,J.jsx)(A,{className:g(`h-3 w-3 shrink-0 text-muted-foreground/60 transition-transform`,n&&`rotate-90`)}),(0,J.jsx)(`button`,{type:`button`,title:h?h.label||h.name||h.id:void 0,disabled:!h,onClick:_,className:g(`shrink-0 transition-opacity`,h?`cursor-pointer hover:opacity-80`:`cursor-default opacity-60`),children:(0,J.jsx)(V,{agent:h,className:`!w-4 !h-4 !rounded-sm opacity-70`})}),(0,J.jsx)(m,{className:`h-3 w-3 shrink-0 text-muted-foreground/70`}),(0,J.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`Message `,o?`to`:`from`]}),u?(0,J.jsx)(`span`,{className:`shrink-0 font-medium text-muted-foreground`,children:fe(c,i)}):(0,J.jsx)(Y,{agentId:c,className:`shrink-0 px-0.5 text-foreground/80`,noIcon:!0}),!n&&(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground/50`,children:d}),(0,J.jsx)(`span`,{className:`ml-auto shrink-0 text-muted-foreground/40`,children:f})]}),n&&(0,J.jsx)(`div`,{className:`mt-1.5 pl-5`,children:(0,J.jsx)(H,{text:d,rawBody:e.body,issueRepo:l,className:`text-sm leading-relaxed text-foreground/90`})})]})})}var Ot=(0,U.memo)(function({msg:e,peer:t,showAvatar:n=!1,onOpenReferencedPath:r,onPreviewReferencedPath:i,onPreviewReferencedPathEnd:a}){if(!B(e.from)&&!B(e.to))return(0,J.jsx)(Dt,{msg:e,peer:t});let o=e.kind===`session`?e.payload?.session:void 0;if(o?.type===`prompt`&&o?.origin===`provider`)return(0,J.jsx)(Ct,{msg:e,peer:t});let s=B(e.from),c=N(e=>e.reactToMessage),l=N(e=>e.voiceTtsEnabled),u=St(),d=N(e=>{let n=e.agentsById[t]?.meta?.cwd;return typeof n==`string`?n:``}),f=N(e=>e.agentsById[t]?.issueRepo),p=N(e=>e.usersById),m=N(e=>e.users.length>1),h=s?le(e.from,p):void 0,_=N(e=>e.openAgentDetail),[v,y]=(0,U.useState)(!1),b=(0,U.useRef)(null),x=(0,U.useRef)(null),S=(0,U.useRef)(!1),C=L(e),te=q(e.occurredAt??e.createdAt),ne=Be(e),w=He(e),T=s?Ue(e,t):null,E=T?.icon,D=u===String(e.id),re=l&&!s&&!K(e)&&C.trim().length>0;function ie(t){t.stopPropagation(),D?j.bargeIn():j.speak(e.body,String(e.id))}(0,U.useEffect)(()=>{if(!v)return;function e(e){ze()||b.current&&!b.current.contains(e.target)&&y(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e)}},[v]);function k(e){return Fe(d||`/`,e)}function ae(e,t){let n=k(e);r?.(n,t)}function A(e,t,n){let r=k(e);i?.(r,t,n)}function M(t){c(e,t),y(!1)}function P(e){e.button===0&&(x.current={x:e.clientX,y:e.clientY},S.current=!1)}function oe(e){let t=x.current;t&&(Math.abs(e.clientX-t.x)>3||Math.abs(e.clientY-t.y)>3)&&(S.current=!0)}function F(t){if(!(K(e)||s)&&!t.target.closest(`a,button,input,textarea,select,[role="button"]`)){if(S.current||ze()){S.current=!1;return}y(e=>!e)}}let I=n&&!K(e);return(0,J.jsxs)(`div`,{"data-msg-id":e.id,className:g(`group/msg flex mb-3 items-end`,s?`justify-end`:`justify-start`,I&&`gap-1.5`),children:[!s&&I&&(0,J.jsx)(Tt,{agentId:t,onOpen:_}),(0,J.jsxs)(`div`,{ref:b,className:g(`relative`,I?`max-w-[calc(85%-2rem)] md:max-w-[calc(75%-2rem)]`:`max-w-[85%] md:max-w-[75%]`),children:[re&&(0,J.jsx)(`button`,{type:`button`,title:D?`Stop playback`:`Play aloud`,onClick:ie,className:g(`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`,D?`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:D?(0,J.jsx)(O,{className:`h-3.5 w-3.5 animate-pulse`}):(0,J.jsx)(ee,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(`div`,{className:g(`rounded-2xl px-3.5 py-2 text-sm select-text`,!s&&!K(e)&&`cursor-pointer`,s?`bg-primary text-primary-foreground rounded-br-sm`:`bg-card ring-1 ring-foreground/10 rounded-bl-sm`),onPointerDown:P,onPointerMove:oe,onClick:F,children:[s&&m&&(0,J.jsx)(`p`,{className:g(`text-[11px] font-semibold mb-0.5 text-right`,ue(e.from)),children:pe(e.from,p)}),e.subject&&(0,J.jsx)(`p`,{className:g(`text-xs font-semibold mb-1`,s?`text-primary-foreground/70`:`text-muted-foreground`),children:e.subject}),(0,J.jsx)(H,{text:C,rawBody:e.body,issueRepo:f,className:`leading-relaxed`,onPrimary:s,onOpenPath:ae,onPreviewPath:A,onPreviewPathEnd:a,resolvePathTitle:(e,t)=>`${k(e)}${t?`:${t}`:``}`}),ne.map(t=>(0,J.jsx)(Et,{attachment:t,outbound:s},`${e.id}-${t.artifactId}-${t.role||``}`)),(0,J.jsxs)(`p`,{className:g(`text-xs mt-1 flex items-center gap-1.5`,s?`justify-end text-primary-foreground/60`:`justify-end text-muted-foreground`),children:[(0,J.jsxs)(`span`,{className:`opacity-40`,children:[`#`,e.id]}),(0,J.jsx)(`span`,{children:te}),T&&E&&(0,J.jsxs)(`span`,{className:g(`inline-flex items-center gap-1`,T.tone===`ok`&&`text-emerald-300`,T.tone===`warn`&&`text-amber-200`,T.tone===`danger`&&`text-red-200`),title:T.title,children:[(0,J.jsx)(E,{className:`h-3 w-3`}),T.label]})]})]}),!K(e)&&w.length>0&&(0,J.jsxs)(`div`,{className:g(`flex flex-wrap items-center gap-0.5 -mt-1 relative z-10`,s?`justify-end pr-2`:`justify-start pl-2`),children:[!s&&(0,J.jsx)($,{open:v,onToggle:()=>y(e=>!e),onReact:M}),w.map(e=>(0,J.jsxs)(`button`,{type:`button`,title:e.actors.join(`, `),onClick:()=>M(e.emoji),className:g(`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,J.jsx)(`span`,{children:e.emoji}),e.count>1&&(0,J.jsx)(`span`,{children:e.count})]},e.emoji))]}),!K(e)&&!s&&w.length===0&&(0,J.jsx)(`div`,{className:`absolute -bottom-2.5 left-1 z-20`,children:(0,J.jsx)($,{open:v,onToggle:()=>y(e=>!e),onReact:M})})]}),s&&I&&(0,J.jsx)(`span`,{className:`shrink-0 self-end opacity-60`,children:(0,J.jsx)(_e,{user:h,address:e.from,distinct:m})})]})});export{Ge as C,Me as E,Re as S,je as T,qe as _,vt as a,Ye as b,bt as c,gt as d,ft as f,Pe as g,Ke as h,pt as i,Q as l,xt as m,ht as n,_t as o,Qe as p,ct as r,yt as s,Ot as t,rt as u,Le as v,Ae as w,Je as x,Ie as y};
|
|
4
|
-
//# sourceMappingURL=MessageBubble-
|
|
4
|
+
//# sourceMappingURL=MessageBubble-DiorZXyB.js.map
|