@tangle-network/sandbox-ui 7.0.3 → 7.0.5
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/README.md +10 -14
- package/dist/{AgentTree-Dzy6lrfP.js → AgentTree-B1iTTYNe.js} +1 -1
- package/dist/{use-follow-tail-Df965WQi.js → ConversationRowView-C4TXICBT.js} +2 -2
- package/dist/{ResearchReport-DKWDmzdK.js → ResearchReport-kYGwgHC7.js} +2 -2
- package/dist/{dashboard-CYWLMJEA.js → dashboard-C7QJJw7-.js} +1 -1
- package/dist/dashboard.js +1 -1
- package/dist/globals.css +19 -0
- package/dist/{index-DpzFSqjG.d.ts → index-Bm3Narea.d.ts} +1 -1
- package/dist/{index-PolYo7h9.d.ts → index-CGHJonni.d.ts} +65 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/dist/record/ResearchReport.js +1 -1
- package/dist/{record-Cc_WNtG8.js → record-Dmyq0jfl.js} +2 -2
- package/dist/record.js +1 -1
- package/dist/report-viewer.js +75 -75
- package/dist/run/live.js +1 -1
- package/dist/run/record.js +3 -3
- package/dist/run-CcyjQN7y.js +238 -0
- package/dist/run.d.ts +2 -2
- package/dist/run.js +6 -6
- package/dist/runtime-viewer/AgentGraphCanvas-P_PFS2Ko-XoCELgxL.js +563 -0
- package/dist/runtime-viewer/{latest-events-CMbdBLcT-uhVN4JLh.js → latest-events-wofY6ifW-4IMNEe7c.js} +576 -107
- package/dist/styles.css +19 -0
- package/dist/terminal.js +1 -1
- package/dist/{trace-workspace-EArXc0uP.js → trace-workspace-HCTpp-qw.js} +77 -37
- package/dist/{workbench-LcgsEw_H.js → workbench-CugraIbl.js} +3 -2
- package/dist/workbench.js +1 -1
- package/dist/{workspace-CJD7oOEa.js → workspace-BGMyR5uW.js} +3 -3
- package/dist/workspace-viewer.js +10510 -10366
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.js +1 -1
- package/package.json +6 -4
- package/tests/visual/content-share.mjs +35 -0
- package/dist/run-CpJ_COuz.js +0 -5
- package/dist/runtime-viewer/AgentGraphCanvas-xHVW-YRV-Ch1fnK9k.js +0 -957
- /package/dist/{terminal-nUCznZRj.js → terminal-view-nUCznZRj.js} +0 -0
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
import { i as e } from "./rolldown-runtime-CwxnZyOB.js";
|
|
2
|
+
import { A as t, C as n, Ct as r, D as i, E as a, I as o, It as s, M as c, P as l, S as u, T as d, Vt as f, X as p, _ as ee, a as te, d as m, f as ne, h, i as re, it as ie, k as ae, l as oe, m as se, n as ce, nt as le, p as ue, r as g, s as _, st as de, t as fe, u as pe, ut as me, v, w as he, wt as y, x as b, y as ge } from "./latest-events-wofY6ifW-4IMNEe7c.js";
|
|
3
|
+
// node_modules/.pnpm/@tangle-network+charts@4.0.21_@tangle-network+brand@1.31.3_react@19.3.1__@tangle-networ_60b8ccd982157f40d51e28cd98298320/node_modules/@tangle-network/charts/dist/AgentGraphCanvas-P_PFS2Ko.js
|
|
4
|
+
var x = s(), S = /* @__PURE__ */ e(f(), 1), _e = {
|
|
5
|
+
agent: g,
|
|
6
|
+
liveAgent: m,
|
|
7
|
+
agentFrame: te
|
|
8
|
+
}, ve = { agentMessage: _ }, C = 16, w = 24, T = .8;
|
|
9
|
+
function ye() {
|
|
10
|
+
let [e, t] = (0, S.useState)(null), n = (0, S.useRef)(null);
|
|
11
|
+
return [e, (0, S.useCallback)((e) => {
|
|
12
|
+
if (n.current?.disconnect(), n.current = null, !e || typeof ResizeObserver > "u") return;
|
|
13
|
+
let r = e.querySelector(".ag-graph-viewport") ?? e, i = () => {
|
|
14
|
+
let e = r.getBoundingClientRect();
|
|
15
|
+
e.width !== 0 && e.height !== 0 && t((t) => t && Math.abs(t.width - e.width) < 1 && Math.abs(t.height - e.height) < 1 ? t : {
|
|
16
|
+
width: e.width,
|
|
17
|
+
height: e.height
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
n.current = new ResizeObserver(i), n.current.observe(r), i();
|
|
21
|
+
}, [])];
|
|
22
|
+
}
|
|
23
|
+
function be(e, t, n) {
|
|
24
|
+
let r = e.getInternalNode(n), i = t?.querySelector(".ag-graph-viewport")?.getBoundingClientRect(), a = r?.measured.width ?? r?.width, o = r?.measured.height ?? r?.height;
|
|
25
|
+
if (!r || !i || !a || !o) return;
|
|
26
|
+
let s = e.getViewport(), c = r.internals.positionAbsolute, l = s.zoom, u = Math.max(C - c.x * l, Math.min(i.width - C - (c.x + a) * l, s.x)), d = Math.max(C - c.y * l, Math.min(i.height - C - (c.y + o) * l, s.y));
|
|
27
|
+
(u !== s.x || d !== s.y || l !== s.zoom) && e.setViewport({
|
|
28
|
+
x: u,
|
|
29
|
+
y: d,
|
|
30
|
+
zoom: l
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function E({ nodes: e, edges: s, selectedId: c, onSelect: u, direction: f = "TB", className: p, emptyState: te, live: m = !1, renderEventIcon: h, showLatestEvents: ie = !0, now: g }) {
|
|
34
|
+
let _ = me(g), v = de(), y = (0, S.useId)(), b = (0, S.useRef)(null), E = (0, S.useRef)(!1), [D, O] = (0, S.useState)(null), k = () => O(null), [A, j] = (0, S.useState)(/* @__PURE__ */ new Set()), [Se, M] = (0, S.useState)(0), [N, Ce] = (0, S.useState)(null), P = (0, S.useRef)(null), F = (0, S.useMemo)(() => D && ae(D.anchor, P.current?.querySelector(".ag-graph-viewport") ?? null), [D]), [I, we] = ye(), Te = l(P, e.length > 0), L = I !== null && I.width < 600, R = ge(e, s), z = (0, S.useRef)(R);
|
|
35
|
+
z.current.key !== R.key && (z.current = R);
|
|
36
|
+
let B = z.current, Ee = (0, S.useRef)(!1);
|
|
37
|
+
(0, S.useEffect)(() => {
|
|
38
|
+
if (Ee.current || !e.length) return;
|
|
39
|
+
Ee.current = !0;
|
|
40
|
+
let t = new Set(e.filter((e) => e.status === "done").map((e) => e.id));
|
|
41
|
+
j(new Set(B.groups.filter((e) => e.memberIds.every((e) => t.has(e))).map((e) => e.id)));
|
|
42
|
+
}, [B]);
|
|
43
|
+
let De = `${m}:${B.key}`, Oe = (0, S.useRef)({
|
|
44
|
+
key: "",
|
|
45
|
+
size: m ? oe : fe
|
|
46
|
+
});
|
|
47
|
+
Oe.current.key !== De && (Oe.current = {
|
|
48
|
+
key: De,
|
|
49
|
+
size: m && e.every((e) => [
|
|
50
|
+
"done",
|
|
51
|
+
"stopped",
|
|
52
|
+
"failed"
|
|
53
|
+
].includes(e.status)) ? {
|
|
54
|
+
width: 256,
|
|
55
|
+
height: 88
|
|
56
|
+
} : m ? oe : fe
|
|
57
|
+
});
|
|
58
|
+
let V = Oe.current.size, ke = `${f}:${m}:${B.key}`, H = (0, S.useRef)(null);
|
|
59
|
+
I && !L && H.current?.key !== ke && (H.current = {
|
|
60
|
+
key: ke,
|
|
61
|
+
columns: Math.max(1, Math.min(6, Math.floor((I.width - 32 - (!m && f === "LR" ? V.width + 70 : 0)) / (V.width + 10))))
|
|
62
|
+
});
|
|
63
|
+
let U = H.current?.columns ?? 1, W = JSON.stringify([
|
|
64
|
+
f,
|
|
65
|
+
m,
|
|
66
|
+
B.key,
|
|
67
|
+
U,
|
|
68
|
+
[...A]
|
|
69
|
+
]), [Ae, je] = (0, S.useState)(null);
|
|
70
|
+
(0, S.useEffect)(() => {
|
|
71
|
+
if (L) return;
|
|
72
|
+
let e = !0;
|
|
73
|
+
return (async () => {
|
|
74
|
+
let t = await n(B, f, U, V, A, m);
|
|
75
|
+
for (let e = U - 1; f === "TB" && e >= 2 && I && t.width * T > I.width - 32; e--) t = await n(B, f, e, V, A, m);
|
|
76
|
+
e && je({
|
|
77
|
+
key: W,
|
|
78
|
+
layout: t
|
|
79
|
+
});
|
|
80
|
+
})(), () => {
|
|
81
|
+
e = !1;
|
|
82
|
+
};
|
|
83
|
+
}, [W, L]);
|
|
84
|
+
let G = Ae?.key === W ? Ae.layout : null;
|
|
85
|
+
(0, S.useEffect)(() => {
|
|
86
|
+
let e = c && B.groupOf.get(c);
|
|
87
|
+
e && j((t) => {
|
|
88
|
+
if (!t.has(e)) return t;
|
|
89
|
+
let n = new Set(t);
|
|
90
|
+
return n.delete(e), n;
|
|
91
|
+
});
|
|
92
|
+
}, [c, B.key]);
|
|
93
|
+
let K = (0, S.useMemo)(() => new Map(e.map((e) => [e.id, e])), [e]), q = (0, S.useRef)(null), Me = (0, S.useMemo)(() => {
|
|
94
|
+
if (!G) return [];
|
|
95
|
+
let e = G.frames.map((e) => ({
|
|
96
|
+
id: e.group.id,
|
|
97
|
+
type: "agentFrame",
|
|
98
|
+
position: {
|
|
99
|
+
x: e.x,
|
|
100
|
+
y: e.y
|
|
101
|
+
},
|
|
102
|
+
width: e.width,
|
|
103
|
+
height: e.height,
|
|
104
|
+
measured: q.current?.getInternalNode(e.group.id)?.measured,
|
|
105
|
+
zIndex: -1,
|
|
106
|
+
selectable: !1,
|
|
107
|
+
focusable: !1,
|
|
108
|
+
draggable: !1,
|
|
109
|
+
data: {
|
|
110
|
+
frame: e,
|
|
111
|
+
direction: f,
|
|
112
|
+
groupParents: m,
|
|
113
|
+
label: K.get(e.group.parentId)?.label ?? "Agent",
|
|
114
|
+
onToggle: () => {
|
|
115
|
+
!e.collapsed && c && e.group.memberIds.includes(c) && u?.(e.group.parentId), j((t) => {
|
|
116
|
+
let n = new Set(t);
|
|
117
|
+
return n.has(e.group.id) ? n.delete(e.group.id) : n.add(e.group.id), n;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
})), t = [];
|
|
122
|
+
for (let e of B.agentIds) {
|
|
123
|
+
let n = K.get(e), r = G.positions.get(e);
|
|
124
|
+
if (!n || !r) continue;
|
|
125
|
+
let i = c === e, a = m && G.frames.find((t) => t.group.parentId === e), o = a ? a.width - 64 : V.width, s = a ? 64 : V.height, l = q.current?.getInternalNode(e)?.measured;
|
|
126
|
+
t.push({
|
|
127
|
+
id: e,
|
|
128
|
+
type: m ? "liveAgent" : "agent",
|
|
129
|
+
position: r,
|
|
130
|
+
width: o,
|
|
131
|
+
height: s,
|
|
132
|
+
measured: l?.width === o && l.height === s ? l : void 0,
|
|
133
|
+
className: `${ce}${a ? " ag-frame-owner" : ""}`,
|
|
134
|
+
draggable: !1,
|
|
135
|
+
ariaRole: "button",
|
|
136
|
+
ariaLabel: ee(n),
|
|
137
|
+
domAttributes: {
|
|
138
|
+
"aria-pressed": i,
|
|
139
|
+
"aria-describedby": D?.id === e ? y : void 0
|
|
140
|
+
},
|
|
141
|
+
data: {
|
|
142
|
+
agent: n,
|
|
143
|
+
selected: i,
|
|
144
|
+
direction: f,
|
|
145
|
+
now: _,
|
|
146
|
+
onOpen: u ? () => u(n.id) : void 0,
|
|
147
|
+
renderEventIcon: h
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return [...e, ...t];
|
|
152
|
+
}, [
|
|
153
|
+
G,
|
|
154
|
+
B,
|
|
155
|
+
K,
|
|
156
|
+
c,
|
|
157
|
+
f,
|
|
158
|
+
m,
|
|
159
|
+
V,
|
|
160
|
+
_,
|
|
161
|
+
u,
|
|
162
|
+
h,
|
|
163
|
+
D
|
|
164
|
+
]), Ne = (0, S.useMemo)(() => {
|
|
165
|
+
if (!G) return [];
|
|
166
|
+
let e = [], n = /* @__PURE__ */ new Set();
|
|
167
|
+
for (let r of B.spawns) {
|
|
168
|
+
let i = m && B.groups.find((e) => e.parentId === r.from)?.id || r.from, a = B.groupOf.get(r.to) ?? r.to;
|
|
169
|
+
if (i === a) continue;
|
|
170
|
+
let o = `spawn:${i}:${a}`;
|
|
171
|
+
n.has(o) || (n.add(o), e.push({
|
|
172
|
+
id: o,
|
|
173
|
+
source: i,
|
|
174
|
+
target: a,
|
|
175
|
+
type: "smoothstep",
|
|
176
|
+
pathOptions: { borderRadius: 14 },
|
|
177
|
+
selectable: !1,
|
|
178
|
+
focusable: !1,
|
|
179
|
+
style: {
|
|
180
|
+
stroke: t(void 0),
|
|
181
|
+
strokeWidth: 1.5
|
|
182
|
+
}
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
let r = new Set(G.positions.keys()), a = /* @__PURE__ */ new Map();
|
|
186
|
+
for (let e of s) {
|
|
187
|
+
if (e.kind === "spawn" || e.from === e.to || !r.has(e.from) || !r.has(e.to) || ![c, D?.id].some((t) => t === e.from || t === e.to)) continue;
|
|
188
|
+
let t = `${e.kind}:${e.from}:${e.to}`, n = a.get(t), o = (n?.data?.count ?? 0) + Math.max(1, e.count ?? 1), s = ue[e.kind] ?? ue.message;
|
|
189
|
+
a.set(t, {
|
|
190
|
+
id: t,
|
|
191
|
+
source: e.from,
|
|
192
|
+
target: e.to,
|
|
193
|
+
type: "agentMessage",
|
|
194
|
+
selectable: !1,
|
|
195
|
+
focusable: !1,
|
|
196
|
+
zIndex: 0,
|
|
197
|
+
markerEnd: {
|
|
198
|
+
type: i.ArrowClosed,
|
|
199
|
+
width: 12,
|
|
200
|
+
height: 12,
|
|
201
|
+
color: s
|
|
202
|
+
},
|
|
203
|
+
ariaLabel: `${e.kind === "delegation" ? "Delegation" : "Message"} from ${K.get(e.from)?.label ?? e.from} to ${K.get(e.to)?.label ?? e.to}${o > 1 ? `, ${o} times` : ""}`,
|
|
204
|
+
data: {
|
|
205
|
+
kind: e.kind,
|
|
206
|
+
count: o,
|
|
207
|
+
label: e.label ?? n?.data?.label
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return [...e, ...a.values()];
|
|
212
|
+
}, [
|
|
213
|
+
G,
|
|
214
|
+
B,
|
|
215
|
+
s,
|
|
216
|
+
K,
|
|
217
|
+
c,
|
|
218
|
+
D
|
|
219
|
+
]), [Pe, Fe] = (0, S.useState)(!1), [Ie, Le] = (0, S.useState)(!1), J = (0, S.useRef)(c);
|
|
220
|
+
J.current = c;
|
|
221
|
+
let Y = (0, S.useRef)(null);
|
|
222
|
+
(0, S.useEffect)(() => {
|
|
223
|
+
L && (q.current = null, Fe(!1), Le(!1), Y.current = null);
|
|
224
|
+
}, [L]);
|
|
225
|
+
let Re = G ? `${W}:${G.columns}` : null, ze = `${f}:${B.key}`, Be = G && I ? Math.max(.02, Math.min(1, (I.width - 32) / G.width, (I.height - 32) / G.height)) : .2;
|
|
226
|
+
(0, S.useEffect)(() => {
|
|
227
|
+
let e = q.current;
|
|
228
|
+
if (!Pe || !e || !Re || !I) return;
|
|
229
|
+
let t = Y.current !== ze, n = !t;
|
|
230
|
+
if (n && !J.current) return;
|
|
231
|
+
let r = Y.current !== null && t && v;
|
|
232
|
+
Y.current = ze;
|
|
233
|
+
let i = requestAnimationFrame(() => {
|
|
234
|
+
if (n) be(e, P.current, J.current);
|
|
235
|
+
else {
|
|
236
|
+
let t = Math.min(1, Math.max(T, Math.min((I.width - 32) / G.width, (I.height - 32) / G.height))), n = G.width * t, i = G.height * t;
|
|
237
|
+
e.setViewport({
|
|
238
|
+
x: n <= I.width - 32 ? (I.width - n) / 2 : C,
|
|
239
|
+
y: i <= I.height - 32 ? (I.height - i) / 2 : C,
|
|
240
|
+
zoom: t
|
|
241
|
+
}, { duration: r ? le("--duration-base", P.current) : 0 });
|
|
242
|
+
}
|
|
243
|
+
Le(!0);
|
|
244
|
+
});
|
|
245
|
+
return () => cancelAnimationFrame(i);
|
|
246
|
+
}, [
|
|
247
|
+
Pe,
|
|
248
|
+
Re,
|
|
249
|
+
ze,
|
|
250
|
+
I,
|
|
251
|
+
Be,
|
|
252
|
+
v,
|
|
253
|
+
c
|
|
254
|
+
]);
|
|
255
|
+
let X = (0, S.useCallback)((e) => {
|
|
256
|
+
K.has(e) && (u?.(e), P.current?.querySelector(`[data-agent-id="${CSS.escape(e)}"]`)?.scrollIntoView({ block: "nearest" }));
|
|
257
|
+
}, [K, u]), Ve = (0, S.useCallback)((e, t) => X(t.id), [X]), He = (0, S.useCallback)((e) => {
|
|
258
|
+
if (!(e.target instanceof HTMLElement)) return;
|
|
259
|
+
let t = e.target.closest(".react-flow__node")?.getAttribute("data-id");
|
|
260
|
+
if (!t || !K.has(t)) return;
|
|
261
|
+
if (e.key === "Escape") {
|
|
262
|
+
e.preventDefault(), e.stopPropagation(), P.current?.focus();
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (!e.target.classList.contains("react-flow__node")) return;
|
|
266
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
267
|
+
e.preventDefault(), e.stopPropagation(), X(t);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
let n = G?.positions.get(t), r = {
|
|
271
|
+
ArrowLeft: [-1, 0],
|
|
272
|
+
ArrowRight: [1, 0],
|
|
273
|
+
ArrowUp: [0, -1],
|
|
274
|
+
ArrowDown: [0, 1]
|
|
275
|
+
}[e.key], i = e.key === "Home" ? B.agentIds[0] : n && r ? [...G?.positions ?? []].filter(([e, i]) => K.has(e) && e !== t && (i.x - n.x) * r[0] + (i.y - n.y) * r[1] > 0).sort((e, t) => Math.hypot(e[1].x - n.x, e[1].y - n.y) - Math.hypot(t[1].x - n.x, t[1].y - n.y))[0]?.[0] : null;
|
|
276
|
+
if (!i) return;
|
|
277
|
+
e.preventDefault(), e.stopPropagation();
|
|
278
|
+
let a = G?.positions.get(i), o = q.current?.getInternalNode(i)?.measured;
|
|
279
|
+
a && q.current?.setCenter(a.x + (o?.width ?? V.width) / 2, a.y + (o?.height ?? V.height) / 2, { zoom: 1 });
|
|
280
|
+
let s = () => P.current?.querySelector(`.react-flow__node[data-id="${CSS.escape(i)}"]`), c = s();
|
|
281
|
+
c ? c.focus() : requestAnimationFrame(() => requestAnimationFrame(() => s()?.focus()));
|
|
282
|
+
}, [
|
|
283
|
+
K,
|
|
284
|
+
X,
|
|
285
|
+
G,
|
|
286
|
+
B,
|
|
287
|
+
V,
|
|
288
|
+
v
|
|
289
|
+
]), Ue = (e) => e.status === "needs-you" ? 0 : e.status === "failed" ? 1 : o(e, _) ? 2 : e.status === "waiting" ? 3 : e.status === "running" ? 4 : 5, Z = new Map(s.filter((e) => e.kind === "spawn").map((e) => [e.to, e.from])), We = (e) => {
|
|
290
|
+
let t = /* @__PURE__ */ new Set([e]), n = 0;
|
|
291
|
+
for (; Z.has(e) && !t.has(Z.get(e));) e = Z.get(e), t.add(e), n++;
|
|
292
|
+
return n;
|
|
293
|
+
}, Q = (0, S.useRef)([]), Ge = new Set(Q.current);
|
|
294
|
+
Q.current = [...Q.current.filter((e) => K.has(e)), ...e.filter((e) => !Ge.has(e.id)).sort((e, t) => Ue(e) - Ue(t)).map((e) => e.id)];
|
|
295
|
+
let Ke = Q.current.map((e) => K.get(e));
|
|
296
|
+
(0, S.useEffect)(() => {
|
|
297
|
+
let e = Ke.findIndex((e) => e.id === c);
|
|
298
|
+
e >= 0 && M(Math.floor(e / w));
|
|
299
|
+
}, [c]), (0, S.useEffect)(() => {
|
|
300
|
+
if (!L || !c) return;
|
|
301
|
+
let e = requestAnimationFrame(() => P.current?.querySelector(`[data-agent-id="${CSS.escape(c)}"]`)?.scrollIntoView({ block: "nearest" }));
|
|
302
|
+
return () => cancelAnimationFrame(e);
|
|
303
|
+
}, [
|
|
304
|
+
c,
|
|
305
|
+
Se,
|
|
306
|
+
L
|
|
307
|
+
]);
|
|
308
|
+
let $ = Math.min(Se * w, Math.max(0, Math.ceil(e.length / w) - 1) * w), qe = /* @__PURE__ */ (0, x.jsx)(se, {
|
|
309
|
+
nodes: e,
|
|
310
|
+
now: _,
|
|
311
|
+
highlight: N,
|
|
312
|
+
onHighlight: (t) => {
|
|
313
|
+
if (N === t) {
|
|
314
|
+
Ce(null);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
Ce(t);
|
|
318
|
+
let n = e.filter((e) => t === "quiet" ? o(e, _) : e.status === t).map((e) => e.id), r = new Set(n.flatMap((e) => B.groupOf.get(e) ?? []));
|
|
319
|
+
r.size && j((e) => [...r].some((t) => e.has(t)) ? new Set([...e].filter((e) => !r.has(e))) : e), requestAnimationFrame(() => requestAnimationFrame(() => {
|
|
320
|
+
L ? P.current?.querySelector(`[data-agent-id="${CSS.escape(n[0] ?? "")}"]`)?.scrollIntoView({ block: "nearest" }) : q.current?.fitView({
|
|
321
|
+
nodes: n.map((e) => ({ id: e })),
|
|
322
|
+
padding: "64px",
|
|
323
|
+
minZoom: T,
|
|
324
|
+
maxZoom: 1,
|
|
325
|
+
duration: v ? le("--duration-base", P.current) : 0
|
|
326
|
+
});
|
|
327
|
+
}));
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
return e.length === 0 ? /* @__PURE__ */ (0, x.jsx)("div", {
|
|
331
|
+
className: `agent-graph flex items-center justify-center rounded-lg border border-border border-dashed p-4 text-center text-muted-foreground text-xs ${p ?? ""}`,
|
|
332
|
+
children: te ?? "No agents yet"
|
|
333
|
+
}) : /* @__PURE__ */ (0, x.jsx)(r, {
|
|
334
|
+
anchor: F?.anchor,
|
|
335
|
+
open: !!D,
|
|
336
|
+
onOpenChange: (e) => {
|
|
337
|
+
e || k();
|
|
338
|
+
},
|
|
339
|
+
children: /* @__PURE__ */ (0, x.jsxs)("div", {
|
|
340
|
+
ref: (e) => {
|
|
341
|
+
P.current = e, we(e);
|
|
342
|
+
},
|
|
343
|
+
className: `agent-graph ag-live${m ? "" : " ag-topology"} relative flex flex-col ${p ?? ""}`,
|
|
344
|
+
tabIndex: -1,
|
|
345
|
+
onKeyDownCapture: (e) => {
|
|
346
|
+
e.target instanceof HTMLElement && e.target.closest("[data-agent-metrics]") || (e.key === "Tab" && !e.shiftKey && D ? (e.preventDefault(), document.getElementById(y)?.focus()) : (e.key === "Escape" && k(), He(e)));
|
|
347
|
+
},
|
|
348
|
+
onFocusCapture: (e) => {
|
|
349
|
+
if (!(e.target instanceof HTMLElement) || E.current || e.target.closest("[data-agent-metrics]")) return;
|
|
350
|
+
if (!e.target.matches(":focus-visible")) {
|
|
351
|
+
k();
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
let t = e.target.closest(".react-flow__node, [data-agent-id]"), n = t?.dataset.id ?? t?.dataset.agentId;
|
|
355
|
+
b.current = t ?? null, O(n && K.has(n) ? {
|
|
356
|
+
id: n,
|
|
357
|
+
anchor: t
|
|
358
|
+
} : null);
|
|
359
|
+
},
|
|
360
|
+
onBlurCapture: (e) => {
|
|
361
|
+
!e.currentTarget.contains(e.relatedTarget) && e.relatedTarget?.id !== y && k();
|
|
362
|
+
},
|
|
363
|
+
"data-layout": L ? "list" : G && Ie ? "ready" : "pending",
|
|
364
|
+
"data-highlight": N ?? void 0,
|
|
365
|
+
"data-columns": G?.columns,
|
|
366
|
+
children: [
|
|
367
|
+
qe,
|
|
368
|
+
ie && m && /* @__PURE__ */ (0, x.jsx)(pe, {
|
|
369
|
+
agents: e,
|
|
370
|
+
now: g,
|
|
371
|
+
live: m,
|
|
372
|
+
selectedId: c,
|
|
373
|
+
onSelect: u ? X : void 0
|
|
374
|
+
}),
|
|
375
|
+
L ? /* @__PURE__ */ (0, x.jsxs)("ul", {
|
|
376
|
+
className: "ag-graph-viewport ag-phone-list overflow-auto",
|
|
377
|
+
"aria-label": "Agents by attention",
|
|
378
|
+
children: [Ke.slice($, $ + w).map((e) => /* @__PURE__ */ (0, x.jsx)("li", {
|
|
379
|
+
style: { "--depth": We(e.id) },
|
|
380
|
+
children: /* @__PURE__ */ (0, x.jsx)("div", {
|
|
381
|
+
role: "button",
|
|
382
|
+
tabIndex: 0,
|
|
383
|
+
"aria-pressed": c === e.id,
|
|
384
|
+
"aria-label": ee(e),
|
|
385
|
+
"data-agent-id": e.id,
|
|
386
|
+
className: "ag-phone-select",
|
|
387
|
+
onClick: () => X(e.id),
|
|
388
|
+
onKeyDown: (t) => {
|
|
389
|
+
(t.key === "Enter" || t.key === " ") && t.target === t.currentTarget && (t.preventDefault(), X(e.id));
|
|
390
|
+
},
|
|
391
|
+
children: m ? /* @__PURE__ */ (0, x.jsx)(ne, {
|
|
392
|
+
agent: e,
|
|
393
|
+
parentLabel: K.get(Z.get(e.id) ?? "")?.label,
|
|
394
|
+
selected: c === e.id,
|
|
395
|
+
now: _,
|
|
396
|
+
renderEventIcon: h,
|
|
397
|
+
onOpen: u ? () => X(e.id) : void 0
|
|
398
|
+
}) : /* @__PURE__ */ (0, x.jsx)(re, {
|
|
399
|
+
agent: e,
|
|
400
|
+
parentLabel: K.get(Z.get(e.id) ?? "")?.label,
|
|
401
|
+
selected: c === e.id,
|
|
402
|
+
now: _,
|
|
403
|
+
direction: f,
|
|
404
|
+
onOpen: u ? () => X(e.id) : void 0
|
|
405
|
+
})
|
|
406
|
+
})
|
|
407
|
+
}, e.id)), e.length > w && /* @__PURE__ */ (0, x.jsxs)("li", {
|
|
408
|
+
className: "flex items-center justify-between gap-2 border-t border-border pt-3 text-sm",
|
|
409
|
+
"aria-label": "Agent pages",
|
|
410
|
+
children: [
|
|
411
|
+
/* @__PURE__ */ (0, x.jsx)("button", {
|
|
412
|
+
type: "button",
|
|
413
|
+
className: "rounded px-2 py-1 hover:bg-muted disabled:opacity-40 focus-visible:outline",
|
|
414
|
+
disabled: !$,
|
|
415
|
+
onClick: () => {
|
|
416
|
+
M((e) => e - 1), P.current?.querySelector(".ag-phone-list")?.scrollTo({ top: 0 });
|
|
417
|
+
},
|
|
418
|
+
children: "Previous"
|
|
419
|
+
}),
|
|
420
|
+
/* @__PURE__ */ (0, x.jsxs)("span", { children: [
|
|
421
|
+
$ + 1,
|
|
422
|
+
"–",
|
|
423
|
+
Math.min(e.length, $ + w),
|
|
424
|
+
" of ",
|
|
425
|
+
e.length
|
|
426
|
+
] }),
|
|
427
|
+
/* @__PURE__ */ (0, x.jsx)("button", {
|
|
428
|
+
type: "button",
|
|
429
|
+
className: "rounded px-2 py-1 hover:bg-muted disabled:opacity-40 focus-visible:outline",
|
|
430
|
+
disabled: $ + w >= e.length,
|
|
431
|
+
onClick: () => {
|
|
432
|
+
M((e) => e + 1), P.current?.querySelector(".ag-phone-list")?.scrollTo({ top: 0 });
|
|
433
|
+
},
|
|
434
|
+
children: "Next"
|
|
435
|
+
})
|
|
436
|
+
]
|
|
437
|
+
})]
|
|
438
|
+
}) : /* @__PURE__ */ (0, x.jsx)("div", {
|
|
439
|
+
className: "ag-graph-viewport min-h-0 flex-1",
|
|
440
|
+
style: { opacity: +!!Ie },
|
|
441
|
+
children: /* @__PURE__ */ (0, x.jsxs)(a, {
|
|
442
|
+
nodes: Me,
|
|
443
|
+
edges: Ne,
|
|
444
|
+
nodeTypes: _e,
|
|
445
|
+
edgeTypes: ve,
|
|
446
|
+
colorMode: Te,
|
|
447
|
+
onInit: (e) => {
|
|
448
|
+
q.current = e, Fe(!0);
|
|
449
|
+
},
|
|
450
|
+
onNodeClick: Ve,
|
|
451
|
+
onNodeMouseEnter: (e, t) => {
|
|
452
|
+
b.current = e.target.closest(".react-flow__node"), b.current && O({
|
|
453
|
+
id: t.id,
|
|
454
|
+
anchor: b.current
|
|
455
|
+
});
|
|
456
|
+
},
|
|
457
|
+
proOptions: { hideAttribution: !0 },
|
|
458
|
+
onlyRenderVisibleElements: !0,
|
|
459
|
+
nodesDraggable: !1,
|
|
460
|
+
nodesConnectable: !1,
|
|
461
|
+
elementsSelectable: !1,
|
|
462
|
+
nodesFocusable: !0,
|
|
463
|
+
edgesFocusable: !1,
|
|
464
|
+
deleteKeyCode: null,
|
|
465
|
+
panOnScroll: !0,
|
|
466
|
+
zoomOnScroll: !1,
|
|
467
|
+
zoomOnPinch: !0,
|
|
468
|
+
zoomOnDoubleClick: !1,
|
|
469
|
+
panOnDrag: !0,
|
|
470
|
+
minZoom: Be,
|
|
471
|
+
maxZoom: 1.75,
|
|
472
|
+
"aria-label": "Agent topology",
|
|
473
|
+
children: [/* @__PURE__ */ (0, x.jsx)(he, {
|
|
474
|
+
bgColor: "var(--bg-root)",
|
|
475
|
+
gap: 16,
|
|
476
|
+
size: 1,
|
|
477
|
+
color: "hsl(var(--foreground) / 0.06)"
|
|
478
|
+
}), /* @__PURE__ */ (0, x.jsx)(d, {
|
|
479
|
+
showInteractive: !1,
|
|
480
|
+
position: "bottom-right",
|
|
481
|
+
fitViewOptions: {
|
|
482
|
+
padding: `${C}px`,
|
|
483
|
+
minZoom: Be,
|
|
484
|
+
maxZoom: 1
|
|
485
|
+
}
|
|
486
|
+
})]
|
|
487
|
+
})
|
|
488
|
+
}),
|
|
489
|
+
D && F && K.has(D.id) && /* @__PURE__ */ (0, x.jsx)(xe, {
|
|
490
|
+
container: P.current,
|
|
491
|
+
place: F,
|
|
492
|
+
mode: Te,
|
|
493
|
+
id: y,
|
|
494
|
+
agent: K.get(D.id),
|
|
495
|
+
onClose: () => {
|
|
496
|
+
k(), E.current = !0, b.current?.focus({ preventScroll: !0 }), E.current = !1;
|
|
497
|
+
}
|
|
498
|
+
})
|
|
499
|
+
]
|
|
500
|
+
})
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
function xe({ container: e, place: t, mode: n, id: r, agent: i, onClose: a }) {
|
|
504
|
+
let o = [
|
|
505
|
+
i.model ? p(i.model) : void 0,
|
|
506
|
+
u(i.costUsd),
|
|
507
|
+
c(i.tokens)
|
|
508
|
+
].filter(Boolean).join(" · "), s = i.status === "failed" ? b(i) : void 0, l = s ? void 0 : i.turn ?? i.events?.at(-1)?.label;
|
|
509
|
+
return /* @__PURE__ */ (0, x.jsxs)(y, {
|
|
510
|
+
container: e,
|
|
511
|
+
side: t.side,
|
|
512
|
+
align: t.align,
|
|
513
|
+
sideOffset: 0,
|
|
514
|
+
avoidCollisions: !1,
|
|
515
|
+
id: r,
|
|
516
|
+
"data-agent-metrics": !0,
|
|
517
|
+
role: "tooltip",
|
|
518
|
+
tabIndex: 0,
|
|
519
|
+
onWheel: (e) => e.stopPropagation(),
|
|
520
|
+
onEscapeKeyDown: (e) => {
|
|
521
|
+
e.preventDefault(), a();
|
|
522
|
+
},
|
|
523
|
+
className: `${n} rounded-xl border border-border bg-card px-3 py-2 text-sm text-foreground shadow-xl`,
|
|
524
|
+
style: {
|
|
525
|
+
colorScheme: n,
|
|
526
|
+
width: "min(320px, calc(100vw - 24px))"
|
|
527
|
+
},
|
|
528
|
+
children: [
|
|
529
|
+
/* @__PURE__ */ (0, x.jsxs)("div", {
|
|
530
|
+
className: "flex items-center gap-2",
|
|
531
|
+
children: [
|
|
532
|
+
/* @__PURE__ */ (0, x.jsx)("span", {
|
|
533
|
+
className: "flex shrink-0",
|
|
534
|
+
style: { color: v(i.status).color },
|
|
535
|
+
children: /* @__PURE__ */ (0, x.jsx)(h, {
|
|
536
|
+
status: i.status,
|
|
537
|
+
size: 14
|
|
538
|
+
})
|
|
539
|
+
}),
|
|
540
|
+
/* @__PURE__ */ (0, x.jsx)("strong", {
|
|
541
|
+
className: "min-w-0 flex-1 truncate",
|
|
542
|
+
children: i.label
|
|
543
|
+
}),
|
|
544
|
+
/* @__PURE__ */ (0, x.jsx)("span", {
|
|
545
|
+
className: "sr-only",
|
|
546
|
+
children: v(i.status).label
|
|
547
|
+
})
|
|
548
|
+
]
|
|
549
|
+
}),
|
|
550
|
+
o && /* @__PURE__ */ (0, x.jsx)("p", {
|
|
551
|
+
className: "m-0 truncate text-[13px] text-muted-foreground",
|
|
552
|
+
children: o
|
|
553
|
+
}),
|
|
554
|
+
(s || l) && /* @__PURE__ */ (0, x.jsx)("p", {
|
|
555
|
+
className: "m-0 truncate text-[13px]",
|
|
556
|
+
style: s ? { color: v("failed").color } : { color: "hsl(var(--muted-foreground))" },
|
|
557
|
+
title: s ?? l,
|
|
558
|
+
children: ie(s ?? l)
|
|
559
|
+
})
|
|
560
|
+
]
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
export { E as AgentGraphCanvas };
|