agentglow 0.1.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.
@@ -0,0 +1,890 @@
1
+ import { jsx as t, jsxs as m } from "react/jsx-runtime";
2
+ import { MeshReflectorMaterial as nt, Grid as rt, Trail as Ze, Stars as st, OrbitControls as at } from "@react-three/drei";
3
+ import { useFrame as te, Canvas as ct } from "@react-three/fiber";
4
+ import { EffectComposer as it, Bloom as lt, Vignette as ut, Noise as ft } from "@react-three/postprocessing";
5
+ import { useRef as S, useMemo as f, useEffect as Se, useState as Ce, useCallback as pt } from "react";
6
+ import { l as he, m as dt, j as ht, h as Fe, C as mt, K as gt, w as k, T as Me, L as _e, G as yt, n as Mt, d as wt, R as vt, S as be, c as St, i as Te, a as xt, e as qe, p as bt, b as At, f as Ct, H as Bt, t as Gt, g as Et } from "./ClusterBall-CPsd6JvJ.js";
7
+ import { r as kt, i as Pt, j as Be, a as He } from "./spread-CWdeDFd9.js";
8
+ import * as r from "three";
9
+ var Ye;
10
+ const pe = typeof window < "u" && !!((Ye = window.matchMedia) != null && Ye.call(window, "(prefers-reduced-motion: reduce)").matches), fe = 2.5, xe = 20, Tt = [0, 2, 4, 1, 3, 5], Pe = 3.4, le = { plan: -5.2, research: 0, write: 5.2 };
11
+ function We(e) {
12
+ return Tt[e % 6] / 6 * Math.PI * 2 + Math.PI / 6 + Math.floor(e / 6) * 0.35;
13
+ }
14
+ function Ke(e) {
15
+ const n = We(e);
16
+ return { x: Math.sin(n) * xe, z: Math.cos(n) * xe, rot: n };
17
+ }
18
+ function Lt(e, n, s, o, i) {
19
+ const a = We(e), c = Math.cos(a), l = Math.sin(a);
20
+ return i.set(Math.sin(a) * xe + n * c + o * l, s, Math.cos(a) * xe - n * l + o * c), i;
21
+ }
22
+ function Je(e) {
23
+ const n = e.type, s = e.id, o = kt(e);
24
+ if (!Pt(n)) {
25
+ const [p, u, d, x] = n === "planner" ? [1.7, 6, le.plan, 0] : n === "researcher" ? [2.1, 8.6, le.research, 0.2] : [1.9, 7, le.write, 0], y = n === "planner" ? -1 : n === "writer" ? 1 : 0, P = d + Be(s, 31) * 0.6 + (o ? y ? y * Math.min(2.2, 0.9 * o) : He(o) * 2.6 : 0), g = x + Be(s, 32) * 0.4 + (o ? y ? -2.6 : 1.5 : 0);
26
+ return { w: p, d: p, h: u * (0.9 + 0.2 * Fe(s, 33)) * (o ? 0.85 : 1), lx: P, lz: g };
27
+ }
28
+ const i = Be(e.run, 34) * 0.7, a = o < 5 ? 0 : 1, c = Math.max(-1.4, Math.min(1.4, He(a ? o - 5 : o) * (a ? 0.5 : 0.62) + i)), l = 2.9 + 0.5 * Fe(e.run, 35) + Be(s, 36) * 0.4 + a * 1.3;
29
+ return { w: 0.95, d: 0.95, h: 2.6 + Fe(s, 37) * 1.4, lx: le.research + Math.sin(c) * l, lz: 0.2 - Math.cos(c) * l };
30
+ }
31
+ const se = /* @__PURE__ */ new Map(), Ue = /* @__PURE__ */ new Map();
32
+ function zt(e, n, s) {
33
+ const o = Je(e);
34
+ return Lt($e(n.id, n.slot), o.lx, 0, o.lz, s);
35
+ }
36
+ const De = { queued: "#3b4256", running: "#fbbf24", done: "#22c55e", failed: "#ef4444" }, _ = (e) => e < 0 ? 0 : e > 1 ? 1 : e, we = (e) => 1 - Math.pow(1 - e, 3), me = (e) => e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2;
37
+ function $e(e, n) {
38
+ return he.grouped ? dt(e) + 6 * ht(e) : n;
39
+ }
40
+ function Rt(e, n, s) {
41
+ const o = We(e), i = he.laneExpanded[e] > 0, a = i ? xe + 3 : xe, c = (i ? 13.5 : 4.6) + Math.sin(s * 0.6 + e) * 0.25;
42
+ return n.set(Math.sin(o) * a, c, Math.cos(o) * a);
43
+ }
44
+ function Ft() {
45
+ return /* @__PURE__ */ t(mt, { place: Rt, radius: 2.3, variant: "swarm", pointSize: 1.05 });
46
+ }
47
+ const It = (
48
+ /* glsl */
49
+ `
50
+ varying vec3 vLocal;
51
+ varying vec3 vN;
52
+ varying float vFogDepth;
53
+ void main() {
54
+ vec4 p = vec4(position, 1.0);
55
+ vec3 n = normal;
56
+ #ifdef USE_INSTANCING
57
+ p = instanceMatrix * p;
58
+ n = mat3(instanceMatrix) * n;
59
+ #endif
60
+ vLocal = p.xyz;
61
+ vN = normalize(n);
62
+ vec4 mv = modelViewMatrix * p;
63
+ vFogDepth = -mv.z;
64
+ gl_Position = projectionMatrix * mv;
65
+ }`
66
+ ), Vt = (
67
+ /* glsl */
68
+ `
69
+ uniform vec3 uColor; // window colour (agent type)
70
+ uniform vec3 uEdge; // neon edge colour (run)
71
+ uniform float uEdgeAmt;
72
+ uniform vec2 uHalf; // half width / depth (object space)
73
+ uniform float uH; // height
74
+ uniform float uTime;
75
+ uniform float uLit; // fraction of windows lit
76
+ uniform float uWork; // 0..1 thinking: scroll band + flicker
77
+ uniform float uEnergy; // LLM pulse
78
+ uniform float uCascade; // 0..1 lights go out from the top
79
+ uniform float uScaffold; // 0..1 birth: glowing grid lines
80
+ uniform float uFiller; // 1 = background skyline (per-window palette, no edges)
81
+ uniform float uOpacity;
82
+ uniform vec3 uFogColor;
83
+ uniform float uFogNear;
84
+ uniform float uFogFar;
85
+ varying vec3 vLocal;
86
+ varying vec3 vN;
87
+ varying float vFogDepth;
88
+
89
+ float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
90
+
91
+ void main() {
92
+ vec3 body = vec3(0.012, 0.016, 0.03);
93
+ vec3 col = body;
94
+ bool roof = vN.y > 0.5;
95
+ float side = abs(vN.x) > 0.5 ? vLocal.z : vLocal.x;
96
+ float faceId = abs(vN.x) > 0.5 ? sign(vN.x) * 3.0 : sign(vN.z) * 7.0;
97
+ vec2 cell = vec2(0.34, 0.46);
98
+ vec2 g = vec2(side, vLocal.y) / cell;
99
+ vec2 id = floor(g) + vec2(faceId * 13.0, 0.0);
100
+ vec2 f = fract(g);
101
+ float win = step(0.2, f.x) * step(f.x, 0.8) * step(0.22, f.y) * step(f.y, 0.74);
102
+ float r = hash(id);
103
+ float tick = floor(uTime * 7.0);
104
+ // flicker while working: a few windows toggle each tick
105
+ float flick = step(hash(id + tick * 0.37), 0.12) * uWork;
106
+ float lit = step(r, uLit);
107
+ lit = abs(lit - flick);
108
+ // scrolling band of light moving up the facade while thinking
109
+ float band = smoothstep(0.82, 1.0, 1.0 - abs(fract(vLocal.y / max(uH, 0.001) * 1.4 - uTime * 0.55) - 0.5) * 2.0) * uWork;
110
+ // lights-out cascade from the top
111
+ float alive = step(vLocal.y, uH * (1.0 - uCascade) + 0.001);
112
+ vec3 wc = uColor;
113
+ if (uFiller > 0.5) {
114
+ wc = mix(vec3(1.0, 0.62, 0.32), vec3(0.45, 0.8, 1.0), step(0.55, hash(id * 1.7 + 3.1)));
115
+ wc = mix(wc, vec3(0.95, 0.4, 0.9), step(0.93, hash(id * 2.3)));
116
+ }
117
+ float bright = (0.55 + 0.9 * r) * (1.0 + uEnergy * 1.6);
118
+ if (!roof && vLocal.y > 0.25) {
119
+ col += win * alive * (lit * bright + band * 2.2) * wc * (uFiller > 0.5 ? 0.6 : 1.6);
120
+ // energy flash: whole facade glows briefly
121
+ col += win * alive * uEnergy * 0.35 * mix(wc, vec3(1.0), 0.4);
122
+ }
123
+ // neon corner edges + rim at the roof line
124
+ vec2 a = abs(vLocal.xz);
125
+ float corner = step(uHalf.x - 0.06, a.x) * step(uHalf.y - 0.06, a.y);
126
+ float rim = roof ? step(uHalf.x - 0.08, a.x) + step(uHalf.y - 0.08, a.y) : 0.0;
127
+ col += uEdge * uEdgeAmt * (corner * 1.6 + min(rim, 1.0) * 1.2) * (0.6 + 0.4 * alive);
128
+ // birth scaffold: glowing floor lines + vertical ribs
129
+ float lines = max(step(0.9, fract(vLocal.y / 0.46)), step(0.88, fract(side / 0.34)));
130
+ col += uScaffold * lines * uColor * 3.0;
131
+ col = mix(col, uColor * 0.25, uScaffold * 0.35);
132
+ float fogF = smoothstep(uFogNear, uFogFar, vFogDepth);
133
+ col = mix(col, uFogColor, fogF);
134
+ gl_FragColor = vec4(col, uOpacity);
135
+ }`
136
+ ), ve = { color: new r.Color("#05040d"), near: 34, far: 110 };
137
+ function Qe(e = {}) {
138
+ return new r.ShaderMaterial({
139
+ vertexShader: It,
140
+ fragmentShader: Vt,
141
+ toneMapped: !1,
142
+ transparent: !1,
143
+ uniforms: {
144
+ uColor: { value: new r.Color(e.color ?? "#ffffff") },
145
+ uEdge: { value: new r.Color(e.edge ?? "#818cf8") },
146
+ uEdgeAmt: { value: e.filler ? 0 : 1 },
147
+ uHalf: { value: new r.Vector2(1, 1) },
148
+ uH: { value: 1 },
149
+ uTime: { value: 0 },
150
+ uLit: { value: e.filler ? 0.32 : 0.5 },
151
+ uWork: { value: 0 },
152
+ uEnergy: { value: 0 },
153
+ uCascade: { value: 0 },
154
+ uScaffold: { value: 0 },
155
+ uFiller: { value: e.filler ? 1 : 0 },
156
+ uOpacity: { value: 1 },
157
+ uFogColor: { value: ve.color },
158
+ uFogNear: { value: ve.near },
159
+ uFogFar: { value: ve.far }
160
+ }
161
+ });
162
+ }
163
+ const et = [11.6, 29];
164
+ function Dt(e) {
165
+ return () => (e = e * 16807 % 2147483647, (e - 1) / 2147483646);
166
+ }
167
+ function Ot() {
168
+ return /* @__PURE__ */ m("group", { children: [
169
+ /* @__PURE__ */ m("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [0, 0, 0], children: [
170
+ /* @__PURE__ */ t("planeGeometry", { args: [320, 320] }),
171
+ /* @__PURE__ */ t(
172
+ nt,
173
+ {
174
+ resolution: 512,
175
+ blur: [400, 120],
176
+ mixBlur: 1,
177
+ mixStrength: 3.2,
178
+ mixContrast: 1.1,
179
+ roughness: 0.85,
180
+ depthScale: 0.6,
181
+ minDepthThreshold: 0.3,
182
+ maxDepthThreshold: 1.4,
183
+ color: "#05060c",
184
+ metalness: 0.7,
185
+ mirror: 0.7
186
+ }
187
+ )
188
+ ] }),
189
+ /* @__PURE__ */ t(
190
+ rt,
191
+ {
192
+ position: [0, 0.012, 0],
193
+ args: [300, 300],
194
+ cellSize: 1.5,
195
+ cellThickness: 0.5,
196
+ cellColor: "#141a36",
197
+ sectionSize: 6,
198
+ sectionThickness: 0.9,
199
+ sectionColor: "#2b2366",
200
+ fadeDistance: 120,
201
+ fadeStrength: 2,
202
+ infiniteGrid: !0
203
+ }
204
+ ),
205
+ et.map((e) => /* @__PURE__ */ m("group", { children: [
206
+ /* @__PURE__ */ m("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [0, 0.015, 0], children: [
207
+ /* @__PURE__ */ t("ringGeometry", { args: [e - 1.1, e + 1.1, 160] }),
208
+ /* @__PURE__ */ t("meshBasicMaterial", { color: "#020308", transparent: !0, opacity: 0.8, depthWrite: !1 })
209
+ ] }),
210
+ [-1.1, 1.1].map((n) => /* @__PURE__ */ m("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [0, 0.02, 0], children: [
211
+ /* @__PURE__ */ t("ringGeometry", { args: [e + n - 0.03, e + n + 0.03, 160] }),
212
+ /* @__PURE__ */ t("meshBasicMaterial", { color: new r.Color("#3b2f8f").multiplyScalar(1.4), toneMapped: !1 })
213
+ ] }, n))
214
+ ] }, e))
215
+ ] });
216
+ }
217
+ function _t() {
218
+ const e = S(null), n = f(() => {
219
+ const i = Qe({ filler: !0 });
220
+ return i.uniforms.uH.value = 999, i.uniforms.uLit.value = 0.2, i;
221
+ }, []), s = f(() => new r.BoxGeometry(1, 1, 1).translate(0, 0.5, 0), []), o = f(() => {
222
+ const i = Dt(42), a = Array.from({ length: 6 }, (l, p) => Ke(p)), c = [];
223
+ for (let l = -78; l <= 78; l += 4.6)
224
+ for (let p = -78; p <= 78; p += 4.6) {
225
+ const u = l + (i() - 0.5) * 1.6, d = p + (i() - 0.5) * 1.6, x = Math.hypot(u, d);
226
+ if (x < 14.5 || x > 80 || et.some((g) => Math.abs(x - g) < 3) || a.some((g) => Math.hypot(u - g.x, d - g.z) < 11.5) || i() < 0.3) continue;
227
+ const y = Wt((x - 14) / 50, 0, 1), P = 1 + Math.pow(i(), 2.2) * (3 + y * 18) + (i() < 0.06 ? 10 : 0);
228
+ c.push({ x: u, z: d, w: 1.6 + i() * 1.8, d: 1.6 + i() * 1.8, h: P, ry: Math.atan2(u, d) });
229
+ }
230
+ return c;
231
+ }, []);
232
+ return Se(() => {
233
+ const i = e.current;
234
+ if (!i) return;
235
+ const a = new r.Object3D();
236
+ o.forEach((c, l) => {
237
+ a.position.set(c.x, 0, c.z), a.rotation.set(0, c.ry, 0), a.scale.set(c.w, c.h, c.d), a.updateMatrix(), i.setMatrixAt(l, a.matrix);
238
+ }), i.instanceMatrix.needsUpdate = !0, i.computeBoundingSphere();
239
+ }, [o]), Se(() => () => (s.dispose(), n.dispose()), [s, n]), /* @__PURE__ */ t("instancedMesh", { ref: e, args: [s, n, o.length] });
240
+ }
241
+ function Wt(e, n, s) {
242
+ return Math.min(s, Math.max(n, e));
243
+ }
244
+ const $t = 200, Ge = 25, Xe = 1.45, je = 1.5, Nt = 2600, ue = 12, Ee = 4, Oe = fe + 0.06;
245
+ function Ht(e) {
246
+ const n = [];
247
+ for (let s = 0; s < e; s++) {
248
+ const o = Math.floor(s / Ge), a = (s * 7 % Ge + o % 2 * 0.5) / Ge * Math.PI * 2, c = je + o * Xe;
249
+ n.push({ p: new r.Vector3(Math.sin(a) * Oe, c, Math.cos(a) * Oe), th: a, y: c });
250
+ }
251
+ return { list: n, height: je + Math.ceil(e / Ge) * Xe };
252
+ }
253
+ function Ut({ galaxy: e }) {
254
+ const n = Math.min($t, e.nodes.length), s = f(() => e.nodes.slice(0, n), [e, n]), { list: o, height: i } = f(() => Ht(n), [n]), a = f(() => s.map((E) => new r.Color(gt[E.kind] ?? "#94a3b8")), [s]), c = f(() => {
255
+ const E = new Map(s.map((h, A) => [h.id, A])), C = [], B = /* @__PURE__ */ new Set();
256
+ for (const h of e.links) {
257
+ const A = E.get(h.source), D = E.get(h.target);
258
+ if (A === void 0 || D === void 0 || A === D) continue;
259
+ const F = A < D ? `${A}-${D}` : `${D}-${A}`;
260
+ B.has(F) || (B.add(F), C.push([A, D]));
261
+ }
262
+ return C;
263
+ }, [e, s]), l = f(() => {
264
+ const E = new Float32Array(c.length * ue * 6), C = (h, A, D, F) => {
265
+ let X = A.th - h.th;
266
+ X > Math.PI && (X -= Math.PI * 2), X < -Math.PI && (X += Math.PI * 2);
267
+ const oe = h.th + X * D, Q = Oe + 0.02 + Math.sin(D * Math.PI) * 0.22;
268
+ E[F] = Math.sin(oe) * Q, E[F + 1] = h.y + (A.y - h.y) * D, E[F + 2] = Math.cos(oe) * Q;
269
+ };
270
+ c.forEach(([h, A], D) => {
271
+ for (let F = 0; F < ue; F++) {
272
+ const X = (D * ue + F) * 6;
273
+ C(o[h], o[A], F / ue, X), C(o[h], o[A], (F + 1) / ue, X + 3);
274
+ }
275
+ });
276
+ const B = new r.BufferGeometry();
277
+ return B.setAttribute("position", new r.BufferAttribute(E, 3)), B.setAttribute("color", new r.BufferAttribute(new Float32Array(E.length), 3)), B;
278
+ }, [c, o]);
279
+ Se(() => () => l.dispose(), [l]);
280
+ const p = S(null), u = S(null), d = S(null), x = S(null), y = S(null), P = S([]), g = S([]), I = S(Array.from({ length: Ee }, () => ({ node: "", key: "" }))), w = f(() => new Float32Array(n), [n]), T = f(() => new Float32Array(n), [n]), R = f(() => /* @__PURE__ */ new Map(), []), M = f(() => new r.Object3D(), []), G = f(() => new r.Color(), []), W = f(() => new r.Color("#5b4fd6"), []), N = f(() => new r.Color(1, 1, 1), []), K = f(() => new r.Vector3(), []), L = f(() => new r.Vector3(), []), V = f(() => new r.Vector3(), []), U = f(() => new r.Vector3(0, 1, 0), []), J = S(!0), ee = 72, ie = 40, ge = (E) => {
281
+ let C = R.get(E);
282
+ return C === void 0 && R.set(E, C = Mt(e, E) % n), C;
283
+ }, O = (E, C, B, h, A, D) => {
284
+ V.subVectors(h, B);
285
+ const F = V.length();
286
+ return F < 1e-3 ? !1 : (M.position.copy(B).addScaledVector(V, 0.5), M.quaternion.setFromUnitVectors(U, V.multiplyScalar(1 / F)), M.scale.set(A, F, A), M.updateMatrix(), E.setMatrixAt(C, M.matrix), E.setColorAt(C, D), !0);
287
+ };
288
+ te(({ clock: E }) => {
289
+ const C = performance.now(), B = E.elapsedTime;
290
+ w.fill(0), T.fill(0);
291
+ const h = u.current, A = d.current;
292
+ let D = 0, F = 0;
293
+ for (const b of k.flares) {
294
+ const v = ge(b.node), H = _((C - b.start) / Nt), q = Math.pow(1 - H, 1.4);
295
+ b.op === "write" ? T[v] = Math.max(T[v], q) : w[v] = Math.max(w[v], q);
296
+ const Z = k.instances.get(b.instance), j = se.get(b.instance), Y = o[v].p;
297
+ if (!(!h || !A)) {
298
+ if (j && D < ee) {
299
+ const ae = we(_((C - b.start) / 250));
300
+ K.copy(j), L.copy(j).lerp(Y, ae), G.set(Z ? Me[Z.type] : "#c7d2fe"), b.op === "write" && G.lerp(N, 0.6), G.multiplyScalar((b.op === "write" ? 3.2 : 2.2) * q), O(h, D, K, L, b.op === "write" ? 0.06 : 0.04, G) && D++;
301
+ const re = _((C - b.start - 200) / 700);
302
+ if (re > 0 && re < 1 && F < ie) {
303
+ const de = we(re);
304
+ b.op === "read" ? K.copy(Y).lerp(j, de) : K.copy(j).lerp(Y, de), M.position.copy(K), M.quaternion.identity(), M.scale.setScalar(1), M.updateMatrix(), A.setMatrixAt(F, M.matrix), G.set(Z ? Me[Z.type] : "#ffffff").lerp(N, 0.5).multiplyScalar(4), A.setColorAt(F, G), F++;
305
+ }
306
+ }
307
+ if (b.op === "write" && D < ee) {
308
+ const ae = we(_((C - b.start) / 450));
309
+ L.copy(Y), L.y += 3 + 80 * ae, G.setRGB(1.6, 1.7, 2.2).multiplyScalar(q * 1.6), O(h, D, Y, L, 0.13, G) && D++;
310
+ }
311
+ }
312
+ }
313
+ h && (h.count = D, h.instanceMatrix.needsUpdate = !0, h.instanceColor && (h.instanceColor.needsUpdate = !0)), A && (A.count = F, A.instanceMatrix.needsUpdate = !0, A.instanceColor && (A.instanceColor.needsUpdate = !0));
314
+ const X = p.current;
315
+ if (X) {
316
+ for (let b = 0; b < n; b++) {
317
+ const v = w[b], H = T[b];
318
+ G.copy(a[b]).multiplyScalar(0.9 + v * 5 + H * 3), H > 0 ? G.lerp(N, Math.min(1, H * 1.3)).multiplyScalar(1 + H * 4) : v > 0 && G.lerp(N, v * 0.25), X.setColorAt(b, G);
319
+ const q = 1 + v * 1.2 + H * 2;
320
+ M.position.copy(o[b].p), M.rotation.set(0, o[b].th, 0), M.scale.set(q, q, 1), M.updateMatrix(), X.setMatrixAt(b, M.matrix);
321
+ }
322
+ X.instanceMatrix.needsUpdate = !0, X.instanceColor && (X.instanceColor.needsUpdate = !0);
323
+ }
324
+ const oe = k.flares.length > 0;
325
+ if (oe || J.current) {
326
+ const b = l.getAttribute("color"), v = b.array;
327
+ for (let H = 0; H < c.length; H++) {
328
+ const [q, Z] = c[H], j = Math.max(w[q], T[q]), Y = Math.max(w[Z], T[Z]), ae = j > 0 || Y > 0;
329
+ for (let re = 0; re < ue; re++)
330
+ for (let de = 0; de < 2; de++) {
331
+ const Ne = (re + de) / ue, ze = ae ? j * (1 - Ne) + Y * Ne : 0, Re = (H * ue + re) * 6 + de * 3;
332
+ v[Re] = W.r * 0.55 + ze * 2.2, v[Re + 1] = W.g * 0.55 + ze * 2, v[Re + 2] = W.b * 0.55 + ze * 2.6;
333
+ }
334
+ }
335
+ b.needsUpdate = !0, J.current = oe;
336
+ }
337
+ const Q = I.current;
338
+ let ne = 0;
339
+ for (let b = k.flares.length - 1; b >= 0 && ne < Ee; b--) {
340
+ const v = k.flares[b];
341
+ if (C - v.start > 1600) break;
342
+ let H = !1;
343
+ for (let j = 0; j < ne; j++) Q[j].node === v.node && (H = !0);
344
+ if (H) continue;
345
+ const q = P.current[ne], Z = g.current[ne];
346
+ if (q && Z) {
347
+ const j = o[ge(v.node)].p;
348
+ q.position.set(j.x * 1.12, j.y + 0.35, j.z * 1.12);
349
+ const Y = `${v.node}|${v.op}`;
350
+ if (Q[ne].key !== Y) {
351
+ const ae = k.instances.get(v.instance);
352
+ Z.setText(v.op === "write" ? `wrote · ${v.node}` : v.node), Z.setColor(v.op === "write" ? "#ffffff" : ae ? Me[ae.type] : "#c7d2fe"), Q[ne].key = Y;
353
+ }
354
+ Z.setOpacity(1 - _((C - v.start - 1100) / 500));
355
+ }
356
+ Q[ne].node = v.node, ne++;
357
+ }
358
+ for (let b = ne; b < Ee; b++) {
359
+ const v = g.current[b];
360
+ v == null || v.setOpacity(0), Q[b].node = "", Q[b].key = "";
361
+ }
362
+ const ce = k.flares.length;
363
+ x.current && x.current.material.color.setRGB(0.55, 0.45, 1.6).multiplyScalar(1.2 + Math.min(3, ce * 0.35) + Math.sin(B * 2) * 0.3), y.current && y.current.material.color.setRGB(0.9, 0.85, 2.4).multiplyScalar(1.5 + Math.min(4, ce * 0.4) + Math.sin(B * 3.1) * 0.4);
364
+ });
365
+ const z = i, $ = f(() => new r.MeshBasicMaterial({ color: new r.Color("#6d5cff").multiplyScalar(1.6), toneMapped: !1 }), []);
366
+ return /* @__PURE__ */ m("group", { children: [
367
+ /* @__PURE__ */ m("mesh", { position: [0, z / 2, 0], children: [
368
+ /* @__PURE__ */ t("cylinderGeometry", { args: [fe, fe, z, 40, 1] }),
369
+ /* @__PURE__ */ t("meshStandardMaterial", { color: "#05060e", roughness: 0.3, metalness: 0.85 })
370
+ ] }),
371
+ [0.03, z].map((E, C) => /* @__PURE__ */ t("mesh", { position: [0, E, 0], rotation: [Math.PI / 2, 0, 0], material: $, children: /* @__PURE__ */ t("torusGeometry", { args: [fe + 0.1, 0.06, 8, 64] }) }, C)),
372
+ /* @__PURE__ */ t("lineSegments", { geometry: l, frustumCulled: !1, children: /* @__PURE__ */ t("lineBasicMaterial", { vertexColors: !0, transparent: !0, blending: r.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) }),
373
+ /* @__PURE__ */ m("instancedMesh", { ref: p, args: [void 0, void 0, Math.max(1, n)], frustumCulled: !1, children: [
374
+ /* @__PURE__ */ t("circleGeometry", { args: [0.13, 16] }),
375
+ /* @__PURE__ */ t("meshBasicMaterial", { toneMapped: !1 })
376
+ ] }),
377
+ /* @__PURE__ */ m("mesh", { position: [0, z + 1.4, 0], children: [
378
+ /* @__PURE__ */ t("cylinderGeometry", { args: [0.15, fe * 0.85, 2.8, 24] }),
379
+ /* @__PURE__ */ t("meshStandardMaterial", { color: "#090b16", roughness: 0.3, metalness: 0.9 })
380
+ ] }),
381
+ /* @__PURE__ */ m("mesh", { ref: x, position: [0, z + 0.6, 0], rotation: [Math.PI / 2, 0, 0], children: [
382
+ /* @__PURE__ */ t("torusGeometry", { args: [fe * 0.95, 0.08, 8, 64] }),
383
+ /* @__PURE__ */ t("meshBasicMaterial", { toneMapped: !1 })
384
+ ] }),
385
+ /* @__PURE__ */ m("mesh", { position: [0, z + 4.6, 0], children: [
386
+ /* @__PURE__ */ t("cylinderGeometry", { args: [0.03, 0.06, 4, 6] }),
387
+ /* @__PURE__ */ t("meshBasicMaterial", { color: "#4c4a7a" })
388
+ ] }),
389
+ /* @__PURE__ */ m("mesh", { ref: y, position: [0, z + 6.7, 0], children: [
390
+ /* @__PURE__ */ t("sphereGeometry", { args: [0.28, 20, 20] }),
391
+ /* @__PURE__ */ t("meshBasicMaterial", { toneMapped: !1 })
392
+ ] }),
393
+ /* @__PURE__ */ m("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [0, 0.03, 0], children: [
394
+ /* @__PURE__ */ t("ringGeometry", { args: [fe + 1.1, fe + 1.25, 64] }),
395
+ /* @__PURE__ */ t("meshBasicMaterial", { color: new r.Color("#7c6cff").multiplyScalar(2), toneMapped: !1 })
396
+ ] }),
397
+ /* @__PURE__ */ m("instancedMesh", { ref: u, args: [void 0, void 0, ee], frustumCulled: !1, children: [
398
+ /* @__PURE__ */ t("cylinderGeometry", { args: [1, 1, 1, 6, 1, !0] }),
399
+ /* @__PURE__ */ t("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: r.AdditiveBlending, depthWrite: !1 })
400
+ ] }),
401
+ /* @__PURE__ */ m("instancedMesh", { ref: d, args: [void 0, void 0, ie], frustumCulled: !1, children: [
402
+ /* @__PURE__ */ t("sphereGeometry", { args: [0.16, 10, 10] }),
403
+ /* @__PURE__ */ t("meshBasicMaterial", { toneMapped: !1 })
404
+ ] }),
405
+ Array.from({ length: Ee }, (E, C) => /* @__PURE__ */ t("group", { ref: (B) => void (P.current[C] = B), children: /* @__PURE__ */ t(_e, { ref: (B) => void (g.current[C] = B), text: "", size: 0.3, opacity: 0, pxRange: [8, 12], renderOrder: 22 }) }, C)),
406
+ /* @__PURE__ */ t(yt, { position: [0, z + 8, 0], color: "#8b7dff", letterSpacing: 0.06, glow: 1.1, size: 0.6, pxRange: [11, 16] })
407
+ ] });
408
+ }
409
+ const Ie = 16, Ve = 9.6, ye = 0.2, Xt = new r.Color(1, 1, 1);
410
+ function jt({ run: e, step: n }) {
411
+ const s = f(
412
+ () => ({
413
+ frame: new r.MeshBasicMaterial({ toneMapped: !1 }),
414
+ pad: new r.MeshBasicMaterial({ toneMapped: !1, transparent: !0, blending: r.AdditiveBlending, depthWrite: !1 }),
415
+ col: new r.MeshBasicMaterial({ toneMapped: !1, transparent: !0, blending: r.AdditiveBlending, depthWrite: !1, side: r.DoubleSide })
416
+ }),
417
+ []
418
+ ), o = S(null), i = f(() => new r.Color(), []);
419
+ te(({ clock: c }) => {
420
+ const l = e.steps[n], p = c.elapsedTime, u = l === "running" ? 1.6 + Math.sin(p * (pe ? 2 : 6)) * 0.7 : l === "done" ? 1.8 : l === "failed" ? 2 : 0.55;
421
+ i.set(De[l] ?? De.queued), s.frame.color.copy(i).multiplyScalar(u), s.pad.color.copy(i).multiplyScalar(l === "queued" ? 0.15 : 0.45 * u), o.current && (o.current.visible = l === "running", s.col.color.copy(i).multiplyScalar(0.09 + 0.04 * Math.sin(p * 6)), o.current.rotation.y += 0.01);
422
+ });
423
+ const a = le[n];
424
+ return /* @__PURE__ */ m("group", { position: [a, 0, Pe], children: [
425
+ /* @__PURE__ */ t("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [0, 0.03, 0], material: s.pad, children: /* @__PURE__ */ t("planeGeometry", { args: [1.9, 1.9] }) }),
426
+ /* @__PURE__ */ t("mesh", { position: [0, 1.1, -1], material: s.frame, children: /* @__PURE__ */ t("boxGeometry", { args: [0.12, 2.2, 0.12] }) }),
427
+ /* @__PURE__ */ t("mesh", { position: [0, 1.1, 1], material: s.frame, children: /* @__PURE__ */ t("boxGeometry", { args: [0.12, 2.2, 0.12] }) }),
428
+ /* @__PURE__ */ t("mesh", { position: [0, 2.2, 0], material: s.frame, children: /* @__PURE__ */ t("boxGeometry", { args: [0.16, 0.16, 2.2] }) }),
429
+ /* @__PURE__ */ t("mesh", { ref: o, position: [0, 4, 0], material: s.col, children: /* @__PURE__ */ t("cylinderGeometry", { args: [0.32, 0.55, 8, 16, 1, !0] }) })
430
+ ] });
431
+ }
432
+ function Yt({ run: e }) {
433
+ const n = $e(e.id, e.slot), s = f(() => Ke(n), [n]), o = f(() => new r.Color(e.color), [e.color]), i = f(() => new r.MeshBasicMaterial({ color: o, transparent: !0, opacity: 0.05, depthWrite: !1, toneMapped: !1 }), [o]), a = f(() => new r.LineBasicMaterial({ color: o.clone().multiplyScalar(1.6), transparent: !0, toneMapped: !1 }), [o]), c = f(() => {
434
+ const g = Ie / 2, I = Ve / 2, w = new r.BufferGeometry().setFromPoints([
435
+ new r.Vector3(-g, 0.04, ye - I),
436
+ new r.Vector3(g, 0.04, ye - I),
437
+ new r.Vector3(g, 0.04, ye + I),
438
+ new r.Vector3(-g, 0.04, ye + I)
439
+ ]);
440
+ return new r.LineLoop(w, a);
441
+ }, [a]), l = S([]), p = f(() => [0, 1].map(() => new r.MeshBasicMaterial({ toneMapped: !1 })), []), u = S(null), d = S(null), x = S(null), y = S(""), P = f(() => new r.Color(), []);
442
+ return te(() => {
443
+ var N, K;
444
+ const g = performance.now(), I = _((g - e.startedAt) / 900), w = e.endedAt ? 1 - _((g - e.endedAt - (vt - 1800)) / 1800) : 1, T = I * w;
445
+ i.opacity = 0.06 * T, a.opacity = T;
446
+ for (let L = 0; L < 2; L++) {
447
+ const V = be[L + 1], J = e.steps[V] !== "queued";
448
+ p[L].color.copy(o).multiplyScalar((J ? 1.6 : 0.25) * T);
449
+ }
450
+ const R = e.handoffAt ? (g - e.handoffAt) / 1300 : 2;
451
+ if (u.current && (u.current.visible = R >= 0 && R < 1, u.current.visible)) {
452
+ const L = le[e.handoffFrom], V = le[e.handoffTo], U = me(R), J = L + (V - L) * U, ee = L + (V - L) * me(Math.max(0, R - 0.22));
453
+ if (u.current.position.set(J, 0.18, Pe + 0.3), d.current) {
454
+ const ie = Math.max(0.05, Math.abs(J - ee));
455
+ d.current.scale.set(ie, 1, 1), d.current.position.x = (ee - J) / 2, P.copy(o).lerp(Xt, 0.2).multiplyScalar(3.2), d.current.material.color.copy(P);
456
+ }
457
+ }
458
+ let M = 0, G = 0;
459
+ k.instances.forEach((L) => {
460
+ L.run === e.id && !L.exitAt && (M++, (L.type === "graph_scout" || L.type === "records_scout") && G++);
461
+ });
462
+ const W = `${e.steps.plan}${e.steps.research}${e.steps.write}${M}${G}${e.status}${Math.round(T * 10)}`;
463
+ if (W !== y.current) {
464
+ y.current = W;
465
+ const L = `${M} agents${G ? ` · fan-out ×${G}` : ""}${e.status !== "started" ? ` · ${e.status}` : ""}`;
466
+ (N = x.current) == null || N.setText(
467
+ [{ text: e.topic, color: "#f8fafc" }, { text: ` ${L}`, color: "#a5b4fc" }],
468
+ be.map((V, U) => ({ text: `${U ? " · " : ""}${V.toUpperCase()}`, color: e.steps[V] === "queued" ? "#64748b" : De[e.steps[V]] }))
469
+ ), (K = x.current) == null || K.setOpacity(T);
470
+ }
471
+ }), /* @__PURE__ */ m("group", { position: [s.x, 0, s.z], rotation: [0, s.rot, 0], children: [
472
+ /* @__PURE__ */ t("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [0, 0.02, ye], material: i, children: /* @__PURE__ */ t("planeGeometry", { args: [Ie, Ve] }) }),
473
+ /* @__PURE__ */ t("primitive", { object: c }),
474
+ /* @__PURE__ */ m("mesh", { rotation: [-Math.PI / 2, 0, 0], position: [0, 0.025, Pe], children: [
475
+ /* @__PURE__ */ t("planeGeometry", { args: [Ie - 0.4, 1.7] }),
476
+ /* @__PURE__ */ t("meshBasicMaterial", { color: "#04050a", transparent: !0, opacity: 0.75, depthWrite: !1 })
477
+ ] }),
478
+ [0, 1].map((g) => {
479
+ const I = le[be[g]], w = le[be[g + 1]];
480
+ return /* @__PURE__ */ t("mesh", { ref: (T) => void (l.current[g] = T), rotation: [-Math.PI / 2, 0, 0], position: [(I + w) / 2, 0.04, Pe], material: p[g], children: /* @__PURE__ */ t("planeGeometry", { args: [Math.abs(w - I) - 1.9, 0.07] }) }, g);
481
+ }),
482
+ be.map((g) => /* @__PURE__ */ t(jt, { run: e, step: g }, g)),
483
+ /* @__PURE__ */ m("group", { ref: u, visible: !1, children: [
484
+ /* @__PURE__ */ m("mesh", { children: [
485
+ /* @__PURE__ */ t("boxGeometry", { args: [0.42, 0.16, 0.26] }),
486
+ /* @__PURE__ */ t("meshBasicMaterial", { color: new r.Color("#fff7d6").multiplyScalar(5), toneMapped: !1 })
487
+ ] }),
488
+ /* @__PURE__ */ m("mesh", { ref: d, children: [
489
+ /* @__PURE__ */ t("boxGeometry", { args: [1, 0.06, 0.14] }),
490
+ /* @__PURE__ */ t("meshBasicMaterial", { transparent: !0, blending: r.AdditiveBlending, depthWrite: !1, toneMapped: !1 })
491
+ ] })
492
+ ] }),
493
+ /* @__PURE__ */ t(
494
+ _e,
495
+ {
496
+ ref: x,
497
+ position: [0, 0.3, ye + Ve / 2 + 0.9],
498
+ text: e.topic,
499
+ secondary: "",
500
+ plate: "box",
501
+ textAlign: "left",
502
+ color: e.color,
503
+ letterSpacing: 0.02,
504
+ size: 0.42,
505
+ secondarySize: 0.3,
506
+ maxWidth: 16,
507
+ opacity: 0,
508
+ fadeMs: 300,
509
+ pxRange: [10, 14]
510
+ }
511
+ )
512
+ ] });
513
+ }
514
+ function Zt() {
515
+ const [e, n] = Ce([]), s = S({ ids: /* @__PURE__ */ new Set(), version: -1 });
516
+ return te(() => {
517
+ const o = s.current;
518
+ let i = o.version !== he.version || o.ids.size !== k.runs.size;
519
+ if (!i) {
520
+ for (const a of k.runs.keys()) if (!o.ids.has(a)) {
521
+ i = !0;
522
+ break;
523
+ }
524
+ }
525
+ i && (o.version = he.version, o.ids = new Set(k.runs.keys()), n([...k.runs.values()].filter((a) => wt(a.id))));
526
+ }), /* @__PURE__ */ t("group", { children: e.map((o) => /* @__PURE__ */ t(Yt, { run: o }, o.id)) });
527
+ }
528
+ const Ae = new r.Vector3();
529
+ function tt(e, n, s, o, i) {
530
+ Ae.copy(e).add(n).multiplyScalar(0.5), Ae.y = Math.max(e.y, n.y) + o;
531
+ const a = 1 - s;
532
+ return i.set(
533
+ a * a * e.x + 2 * a * s * Ae.x + s * s * n.x,
534
+ a * a * e.y + 2 * a * s * Ae.y + s * s * n.y,
535
+ a * a * e.z + 2 * a * s * Ae.z + s * s * n.z
536
+ );
537
+ }
538
+ function ot(e, n = () => !0) {
539
+ const [s, o] = Ce([]), i = S("");
540
+ return te(() => {
541
+ const a = !he.grouped;
542
+ let c = "";
543
+ for (const l of e()) (a || n(l)) && (c += l.id + ",");
544
+ c !== i.current && (i.current = c, o(a ? e().slice() : e().filter(n)));
545
+ }), s;
546
+ }
547
+ function qt({ comet: e }) {
548
+ const n = S(null), s = f(() => (se.get(e.from) ?? new r.Vector3()).clone(), [e.from]), o = f(() => (se.get(e.to) ?? new r.Vector3()).clone(), [e.to]), i = k.instances.get(e.from), a = i ? Me[i.type] : "#ffffff";
549
+ return te(() => {
550
+ const c = _((performance.now() - e.start) / e.dur), l = se.get(e.from), p = se.get(e.to);
551
+ l && s.copy(l), p && o.copy(p), n.current && (tt(s, o, me(c), 2.5 + s.distanceTo(o) * 0.25, n.current.position), n.current.scale.setScalar(c >= 1 ? 1e-3 : 1));
552
+ }), /* @__PURE__ */ t(Ze, { width: 1.6, length: 6, color: new r.Color(a).multiplyScalar(2.2), attenuation: (c) => c * c, decay: 1, children: /* @__PURE__ */ m("mesh", { ref: n, position: s, children: [
553
+ /* @__PURE__ */ t("sphereGeometry", { args: [0.14, 12, 12] }),
554
+ /* @__PURE__ */ t("meshBasicMaterial", { color: new r.Color(a).lerp(new r.Color("#fff"), 0.4).multiplyScalar(4), toneMapped: !1 })
555
+ ] }) });
556
+ }
557
+ function Kt() {
558
+ const e = ot(() => k.comets, (n) => Te(n.from) && Te(n.to));
559
+ return /* @__PURE__ */ t("group", { children: e.map((n) => /* @__PURE__ */ t(qt, { comet: n }, n.id)) });
560
+ }
561
+ const Le = /* @__PURE__ */ new Map(), ke = 27;
562
+ function Jt(e, n) {
563
+ const s = document.createElement("canvas");
564
+ s.width = 512, s.height = 96;
565
+ const o = s.getContext("2d");
566
+ o.fillStyle = "#05030c", o.fillRect(0, 0, 512, 96), o.fillStyle = n, o.globalAlpha = 0.18;
567
+ for (let l = 0; l < 512; l += 6) o.fillRect(l, 0, 2, 96);
568
+ o.globalAlpha = 1, o.font = "700 46px ui-monospace, Menlo, monospace", o.textBaseline = "middle", o.shadowColor = n, o.shadowBlur = 12;
569
+ const i = `${e.toUpperCase()} ◆ MCP ◆ `, a = o.measureText(i).width;
570
+ for (let l = 8; l < 512 + a; l += a) o.fillText(i, l, 50);
571
+ const c = new r.CanvasTexture(s);
572
+ return c.wrapS = r.RepeatWrapping, c.colorSpace = r.SRGBColorSpace, c;
573
+ }
574
+ function Qt({ server: e }) {
575
+ const n = S(null), s = S(null), o = S(null), i = S(null), a = S(null), c = f(() => Jt(e.name, e.color), [e.name, e.color]);
576
+ Se(() => () => c.dispose(), [c]);
577
+ const l = f(() => new r.Color(e.color), [e.color]), p = f(() => {
578
+ const y = new r.Vector3();
579
+ return Le.set(e.name, y), y;
580
+ }, [e.name]), u = e.slot / 5 * Math.PI * 2 + 0.62, d = f(() => performance.now(), []), x = S(0);
581
+ return te(({ clock: y }, P) => {
582
+ const g = performance.now(), I = y.elapsedTime, w = u, T = 17 + e.slot % 2 * 3 + 0, R = n.current;
583
+ R && (R.position.set(Math.sin(w) * ke, T, Math.cos(w) * ke), R.rotation.y = w + Math.PI / 2, R.scale.setScalar(1.35 * me(_((g - d) / 1200)))), p.set(Math.sin(w) * ke, T - 1.1, Math.cos(w) * ke);
584
+ const M = e.inflight > 0, G = Math.exp(-((g - e.activeAt) / 1e3) * 3);
585
+ x.current += P * (M ? 6 : 0.6) * (pe ? 0.2 : 1), o.current && (o.current.rotation.y = x.current), s.current && (s.current.color.setScalar((M ? 2.6 : 1.3) + G * 2.5), pe || (c.offset.x += P * (M ? 0.25 : 0.06))), i.current && (i.current.scale.setScalar(1 + G * 0.5), i.current.material.color.copy(l).multiplyScalar(0.05 + (M ? 0.08 : 0) + G * 0.25)), a.current && a.current.material.color.copy(l).multiplyScalar((M ? 3 + Math.sin(I * 10) * 1.2 : 1.2) + G * 4);
586
+ }), /* @__PURE__ */ m("group", { ref: n, scale: 0, children: [
587
+ /* @__PURE__ */ m("mesh", { scale: [3.4, 1.05, 1.05], children: [
588
+ /* @__PURE__ */ t("sphereGeometry", { args: [1, 32, 20] }),
589
+ /* @__PURE__ */ t("meshStandardMaterial", { color: "#0d0f1c", roughness: 0.45, metalness: 0.6 })
590
+ ] }),
591
+ /* @__PURE__ */ m("mesh", { rotation: [0, 0, 0], scale: [3.42, 1.07, 1.07], children: [
592
+ /* @__PURE__ */ t("torusGeometry", { args: [1, 0.012, 6, 64] }),
593
+ /* @__PURE__ */ t("meshBasicMaterial", { color: l.clone().multiplyScalar(2), toneMapped: !1 })
594
+ ] }),
595
+ [1, -1].map((y) => /* @__PURE__ */ m("mesh", { position: [0, 0, y * 1.08], rotation: [0, y > 0 ? 0 : Math.PI, 0], children: [
596
+ /* @__PURE__ */ t("planeGeometry", { args: [4.2, 0.85] }),
597
+ /* @__PURE__ */ t("meshBasicMaterial", { ref: y > 0 ? s : void 0, map: c, toneMapped: !1 })
598
+ ] }, y)),
599
+ [0, Math.PI / 2, Math.PI, -Math.PI / 2].map((y) => /* @__PURE__ */ m("mesh", { position: [-3.1, 0, 0], rotation: [y, 0, 0], children: [
600
+ /* @__PURE__ */ t("boxGeometry", { args: [0.8, 0.04, 1.3] }),
601
+ /* @__PURE__ */ t("meshStandardMaterial", { color: "#141729", metalness: 0.6, roughness: 0.5 })
602
+ ] }, y)),
603
+ /* @__PURE__ */ m("mesh", { position: [0.3, -1.05, 0], children: [
604
+ /* @__PURE__ */ t("boxGeometry", { args: [1.2, 0.3, 0.45] }),
605
+ /* @__PURE__ */ t("meshStandardMaterial", { color: "#10121f", metalness: 0.6, roughness: 0.4 })
606
+ ] }),
607
+ /* @__PURE__ */ t("group", { ref: o, position: [0.3, -1.35, 0], children: /* @__PURE__ */ m("mesh", { rotation: [0, 0, Math.PI / 2.6], position: [0.25, -0.1, 0], children: [
608
+ /* @__PURE__ */ t("coneGeometry", { args: [0.35, 0.18, 16, 1, !0] }),
609
+ /* @__PURE__ */ t("meshBasicMaterial", { color: l.clone().multiplyScalar(1.6), wireframe: !0, toneMapped: !1 })
610
+ ] }) }),
611
+ /* @__PURE__ */ m("mesh", { ref: a, position: [0.3, -1.3, 0], children: [
612
+ /* @__PURE__ */ t("sphereGeometry", { args: [0.1, 10, 10] }),
613
+ /* @__PURE__ */ t("meshBasicMaterial", { toneMapped: !1 })
614
+ ] }),
615
+ /* @__PURE__ */ m("mesh", { ref: i, scale: [3.9, 1.6, 1.6], children: [
616
+ /* @__PURE__ */ t("sphereGeometry", { args: [1, 24, 16] }),
617
+ /* @__PURE__ */ t("meshBasicMaterial", { transparent: !0, blending: r.AdditiveBlending, depthWrite: !1, toneMapped: !1 })
618
+ ] }),
619
+ /* @__PURE__ */ t(_e, { position: [0, 1.7, 0], text: `mcp · ${e.name}`, font: "mono", color: e.color, size: 0.34, pxRange: [9, 13] })
620
+ ] });
621
+ }
622
+ function eo() {
623
+ const [e, n] = Ce([]), s = S(-1);
624
+ return te(() => {
625
+ k.mcpServers.size !== s.current && (s.current = k.mcpServers.size, n([...k.mcpServers.values()]));
626
+ }), /* @__PURE__ */ t("group", { children: e.map((o) => /* @__PURE__ */ t(Qt, { server: o }, o.name)) });
627
+ }
628
+ function to({ call: e }) {
629
+ var l;
630
+ const n = S(null), s = f(() => new r.Vector3(), []), o = f(() => new r.Vector3(), []), i = ((l = k.mcpServers.get(e.server)) == null ? void 0 : l.color) ?? "#ffffff", a = f(() => {
631
+ var d;
632
+ const p = se.get(e.instance), u = Le.get(e.server);
633
+ return ((d = e.phase === "call" ? p : u) == null ? void 0 : d.clone()) ?? new r.Vector3(0, -50, 0);
634
+ }, [e]);
635
+ te(() => {
636
+ const p = _((performance.now() - e.start) / e.dur), u = se.get(e.instance), d = Le.get(e.server);
637
+ !u || !d || !n.current || (e.phase === "call" ? (s.copy(u), o.copy(d)) : (s.copy(d), o.copy(u)), tt(s, o, me(p), 3, n.current.position), n.current.rotation.y += 0.2, n.current.scale.setScalar(p >= 1 ? 1e-3 : 1));
638
+ });
639
+ const c = new r.Color(i);
640
+ return e.phase === "result" && c.lerp(new r.Color("#ffffff"), 0.45), /* @__PURE__ */ t(Ze, { width: 1.3, length: 5, color: c.clone().multiplyScalar(2), attenuation: (p) => p * p, children: /* @__PURE__ */ m("mesh", { ref: n, position: a, children: [
641
+ /* @__PURE__ */ t("octahedronGeometry", { args: [0.16, 0] }),
642
+ /* @__PURE__ */ t("meshBasicMaterial", { color: c.clone().multiplyScalar(4), toneMapped: !1 })
643
+ ] }) });
644
+ }
645
+ function oo() {
646
+ const e = ot(() => k.mcpCalls, (n) => Te(n.instance));
647
+ return /* @__PURE__ */ t("group", { children: e.map((n) => /* @__PURE__ */ t(to, { call: n }, n.id)) });
648
+ }
649
+ const no = new r.Color("#fbbf24"), ro = new r.Color("#ff2d3d");
650
+ function so() {
651
+ const s = f(() => {
652
+ const u = new r.BufferGeometry();
653
+ return u.setAttribute("position", new r.BufferAttribute(new Float32Array(5760), 3)), u.setAttribute("color", new r.BufferAttribute(new Float32Array(5760), 3)), u;
654
+ }, []), o = f(() => new r.Vector3(), []), i = f(() => new r.Vector3(), []), a = f(() => new r.Vector3(), []), c = f(() => new r.Color(), []), l = f(() => new r.Color(), []), p = (u, d) => (d.copy(o).lerp(i, u), d.y -= Math.sin(u * Math.PI) * 1.2, d);
655
+ return te(({ clock: u }) => {
656
+ const d = s.getAttribute("position"), x = s.getAttribute("color"), y = performance.now(), P = pe ? 0 : u.elapsedTime;
657
+ let g = 0;
658
+ const I = (w, T, R, M, G) => {
659
+ const W = se.get(w), N = Le.get(T), K = k.mcpServers.get(T);
660
+ if (!W || !N || !K || g >= 960) return;
661
+ o.copy(W), i.copy(N), c.set(K.color), M > 0.8 && c.lerp(no, _((M - 0.8) / 1)), M > 1.8 && c.lerp(ro, _((M - 1.8) / 0.8));
662
+ const L = R === "pending" ? me(_((y - G) / 350)) : 1, V = R === "resolved" ? (y - G) / 700 : 0;
663
+ for (let U = 0; U < 40 && g < 960; U++, g++) {
664
+ const J = U / 40 * L, ee = (U + 1) / 40 * L;
665
+ p(J, a), d.setXYZ(g * 2, a.x, a.y, a.z), p(ee, a), d.setXYZ(g * 2 + 1, a.x, a.y, a.z);
666
+ for (let ie = 0; ie < 2; ie++) {
667
+ const ge = ie ? ee : J;
668
+ let O;
669
+ if (R === "pending") {
670
+ const z = Math.pow(0.5 + 0.5 * Math.sin(ge * 46 - P * 9), 6);
671
+ O = (0.25 + 0.2 * Math.min(3, M)) * (0.35 + 1.6 * z), l.copy(c).multiplyScalar(O);
672
+ } else {
673
+ const z = 1 - _(V / 0.55), $ = Math.exp(-Math.pow((ge - z) * 9, 2)) * 5 * (1 - _((V - 0.55) / 0.3));
674
+ O = 0.35 * (1 - _(V / 0.8)), l.copy(c).multiplyScalar(O).addScalar($ * 0.6), l.r += c.r * $, l.g += c.g * $, l.b += c.b * $;
675
+ }
676
+ x.setXYZ(g * 2 + ie, l.r, l.g, l.b);
677
+ }
678
+ }
679
+ };
680
+ k.mcpPending.forEach((w) => I(w.instance, w.server, "pending", St(w, y), w.since));
681
+ for (const w of k.mcpResolved) I(w.instance, w.server, "resolved", 0, w.resolvedAt);
682
+ s.setDrawRange(0, g * 2), d.needsUpdate = !0, x.needsUpdate = !0;
683
+ }), /* @__PURE__ */ t("lineSegments", { geometry: s, frustumCulled: !1, children: /* @__PURE__ */ t("lineBasicMaterial", { vertexColors: !0, transparent: !0, blending: r.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) });
684
+ }
685
+ function ao({ inst: e, selectedRef: n, onSelect: s }) {
686
+ const o = k.runs.get(e.run), i = f(() => Je(e), [e]), a = o ? $e(o.id, o.slot) : 0, c = f(() => o ? zt(e, o, new r.Vector3()) : new r.Vector3(), [e, o, a]), l = Me[e.type], { h: p, w: u, d } = i, x = f(() => new r.BoxGeometry(u, p, d).translate(0, p / 2, 0), [u, p, d]), y = f(() => {
687
+ const O = [], z = u / 2 + 0.04, $ = d / 2 + 0.04, E = (B) => {
688
+ const h = [[-z, -$], [z, -$], [z, $], [-z, $]];
689
+ for (let A = 0; A < 4; A++) O.push(h[A][0], B, h[A][1], h[(A + 1) % 4][0], B, h[(A + 1) % 4][1]);
690
+ };
691
+ for (let B = 0; B <= p + 1e-3; B += 0.92) E(B);
692
+ E(p);
693
+ for (const [B, h] of [[-z, -$], [z, -$], [z, $], [-z, $]]) O.push(B, 0, h, B, p, h);
694
+ for (const [B, h] of [[-z, -$], [z, $]]) O.push(B, 0, h, -B, p, -h);
695
+ const C = new r.BufferGeometry();
696
+ return C.setAttribute("position", new r.Float32BufferAttribute(O, 3)), C;
697
+ }, [u, p, d]), P = f(() => {
698
+ const O = Qe({ color: l, edge: o == null ? void 0 : o.color });
699
+ return O.uniforms.uHalf.value.set(u / 2, d / 2), O.uniforms.uH.value = p, O.uniforms.uLit.value = 0.2, O;
700
+ }, [l, o == null ? void 0 : o.color, u, d, p]);
701
+ Se(() => () => (x.dispose(), y.dispose(), P.dispose()), [x, y, P]);
702
+ const g = S(null), I = S(null), w = S(null), T = S(null), R = S(null), M = S(null), G = S(null), W = f(() => new r.Color(l), [l]), N = f(() => new r.Color("#ffffff"), []), K = f(() => new r.Color("#ff3344"), []), L = f(() => new r.Color("#fbbf24"), []), V = f(() => new r.Color(), []), U = S(0.2), J = S(0);
703
+ Se(() => {
704
+ const O = new r.Vector3(c.x, 0, c.z);
705
+ return se.set(e.id, O), Ue.set(e.id, c), () => {
706
+ window.setTimeout(() => {
707
+ k.instances.has(e.id) || (se.delete(e.id), Ue.delete(e.id));
708
+ }, 1500);
709
+ };
710
+ }, [e.id, c]);
711
+ const ee = S(null);
712
+ return te(({ clock: O }, z) => {
713
+ const $ = performance.now(), E = O.elapsedTime, C = ($ - e.bornAt) / 1e3, B = At();
714
+ ee.current && ee.current.scale.x !== B && ee.current.scale.setScalar(B);
715
+ const h = e.exitAt ? ($ - e.exitAt) / 1e3 * (2500 / xt(e)) : -1, A = we(_((C - 0.25) / 1.25)), D = h >= 0 ? me(_((h - 0.8) / 1.5)) : 0, F = -p * (1 - A) - (p + 0.4) * D;
716
+ g.current && (g.current.position.y = F);
717
+ const X = C < 0.25 ? C / 0.25 : 1 - _((C - 1.1) / 0.7);
718
+ I.current && (I.current.visible = X > 0.01, I.current.material.color.copy(W).multiplyScalar(X * (2.2 + Math.sin(E * 30) * 0.6)));
719
+ let oe = !1;
720
+ for (const Y of k.mcpPending.values()) Y.instance === e.id && (oe = !0);
721
+ const Q = e.status === "thinking" && !oe, ne = e.status === "waiting" || oe, ce = qe(e, $), b = Q ? 0.8 : oe ? 0.22 + 0.12 * Math.sin(E * 2.4) : ne ? 0.12 : e.exitAt ? 0.85 : 0.45;
722
+ U.current += (b - U.current) * Math.min(1, z * 3);
723
+ const v = P.uniforms;
724
+ v.uTime.value = pe ? 0 : E, v.uLit.value = U.current, v.uWork.value = Q && !pe ? 1 : 0, v.uEnergy.value = Math.min(1.6, ce), v.uCascade.value = h >= 0 ? _(h / 0.9) : 0, v.uScaffold.value = C < 1.6 ? Math.max(0, X) * (1 - A * 0.6) : 0, v.uEdgeAmt.value = (0.55 + ce * 0.8) * (h >= 0 ? 1 - _(h / 1.2) * 0.8 : 1);
725
+ const H = p + F, q = Q ? 0.5 + 0.5 * Math.sin(E * 7) : oe ? 0.5 + 0.5 * Math.sin(E * 2.4) : ne ? 0.5 + 0.5 * Math.sin(E * 1.3) : 0.6, Z = h >= 0 ? Math.max(0, 1 - h / 0.5) : 0;
726
+ if (w.current) {
727
+ w.current.position.y = H + 0.75;
728
+ const Y = (ne ? 0.6 + q * 0.8 : 1.4 + q * 2.6) + ce * 4 + Z * 8;
729
+ V.copy(W).lerp(oe ? L : W, oe ? 0.6 : 0).lerp(e.status === "failed" ? K : N, Z * 0.8 + Math.min(0.5, ce * 0.25)).multiplyScalar(h >= 0 ? Y * (1 - _((h - 0.5) / 0.5)) : Y), w.current.material.color.copy(V), w.current.scale.setScalar(1 + ce * 0.6 + Z * 2.5);
730
+ }
731
+ if (T.current && (T.current.position.y = H + 0.75, T.current.scale.setScalar(0.8 + q * (Q ? 0.6 : 0.2) + Math.min(1.2, ce * 0.8) + Z * 3), T.current.material.color.copy(W).multiplyScalar((Q ? 0.22 : 0.08) + Math.min(0.3, ce * 0.15) + Z * 0.5)), J.current += ((Q && h < 0 ? 1 : 0) - J.current) * Math.min(1, z * 4), R.current && (R.current.visible = J.current > 0.02, R.current.position.y = H + 1.6, R.current.scale.setScalar(J.current * (1 + ce * 0.25)), R.current.rotation.y += z * (pe ? 0.3 : 1.8)), M.current) {
732
+ const Y = M.current.material, ae = C / 0.9, re = h >= 0 ? h / 1.1 : -1;
733
+ re >= 0 && re < 1 ? (M.current.visible = !0, M.current.scale.setScalar(1 + re * 6), Y.color.copy(e.status === "failed" ? K : W).lerp(N, 0.4).multiplyScalar(2.5 * (1 - re))) : ae < 1 ? (M.current.visible = !0, M.current.scale.setScalar(0.5 + we(ae) * 3), Y.color.copy(W).multiplyScalar(3 * (1 - ae))) : M.current.visible = !1;
734
+ }
735
+ G.current && (G.current.visible = n.current === e.id, G.current.visible && (G.current.rotation.z += z * 1.2));
736
+ const j = se.get(e.id);
737
+ j && j.set(c.x, Math.max(0.3, (H + 0.75) * B), c.z);
738
+ }), o ? /* @__PURE__ */ m("group", { position: c, ref: ee, children: [
739
+ /* @__PURE__ */ m("group", { ref: g, children: [
740
+ /* @__PURE__ */ t("mesh", { geometry: x, material: P, onClick: (O) => (O.stopPropagation(), s(e.id)), onPointerOver: () => document.body.style.cursor = "pointer", onPointerOut: () => document.body.style.cursor = "" }),
741
+ /* @__PURE__ */ m("mesh", { position: [0, p + 0.35, 0], children: [
742
+ /* @__PURE__ */ t("cylinderGeometry", { args: [0.03, 0.05, 0.7, 6] }),
743
+ /* @__PURE__ */ t("meshBasicMaterial", { color: "#1e2433" })
744
+ ] })
745
+ ] }),
746
+ /* @__PURE__ */ t("lineSegments", { ref: I, geometry: y, children: /* @__PURE__ */ t("lineBasicMaterial", { transparent: !0, blending: r.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) }),
747
+ /* @__PURE__ */ m("mesh", { ref: w, children: [
748
+ /* @__PURE__ */ t("sphereGeometry", { args: [0.13, 14, 14] }),
749
+ /* @__PURE__ */ t("meshBasicMaterial", { toneMapped: !1 })
750
+ ] }),
751
+ /* @__PURE__ */ m("mesh", { ref: T, children: [
752
+ /* @__PURE__ */ t("sphereGeometry", { args: [0.32, 16, 16] }),
753
+ /* @__PURE__ */ t("meshBasicMaterial", { transparent: !0, blending: r.AdditiveBlending, depthWrite: !1, toneMapped: !1 })
754
+ ] }),
755
+ /* @__PURE__ */ m("group", { ref: R, children: [
756
+ /* @__PURE__ */ m("mesh", { rotation: [Math.PI / 2, 0, 0], children: [
757
+ /* @__PURE__ */ t("torusGeometry", { args: [Math.max(0.55, u * 0.42), 0.025, 6, 48] }),
758
+ /* @__PURE__ */ t("meshBasicMaterial", { color: W.clone().multiplyScalar(2.6), toneMapped: !1 })
759
+ ] }),
760
+ /* @__PURE__ */ m("mesh", { children: [
761
+ /* @__PURE__ */ t("octahedronGeometry", { args: [0.32, 0] }),
762
+ /* @__PURE__ */ t("meshBasicMaterial", { color: W.clone().multiplyScalar(2), wireframe: !0, toneMapped: !1 })
763
+ ] }),
764
+ /* @__PURE__ */ m("mesh", { position: [0, 0, Math.max(0.55, u * 0.42)], children: [
765
+ /* @__PURE__ */ t("planeGeometry", { args: [0.7, 0.26] }),
766
+ /* @__PURE__ */ t("meshBasicMaterial", { color: W.clone().multiplyScalar(1.3), transparent: !0, opacity: 0.55, side: r.DoubleSide, blending: r.AdditiveBlending, depthWrite: !1, toneMapped: !1 })
767
+ ] })
768
+ ] }),
769
+ /* @__PURE__ */ m("mesh", { ref: M, rotation: [-Math.PI / 2, 0, 0], position: [0, 0.05, 0], children: [
770
+ /* @__PURE__ */ t("ringGeometry", { args: [Math.max(u, d) * 0.62, Math.max(u, d) * 0.72, 48] }),
771
+ /* @__PURE__ */ t("meshBasicMaterial", { transparent: !0, blending: r.AdditiveBlending, depthWrite: !1, toneMapped: !1 })
772
+ ] }),
773
+ /* @__PURE__ */ m("mesh", { ref: G, rotation: [-Math.PI / 2, 0, 0], position: [0, 0.07, 0], visible: !1, children: [
774
+ /* @__PURE__ */ t("ringGeometry", { args: [Math.max(u, d) * 0.85, Math.max(u, d) * 0.95, 6] }),
775
+ /* @__PURE__ */ t("meshBasicMaterial", { color: new r.Color("#e0f2fe").multiplyScalar(2.5), toneMapped: !1 })
776
+ ] })
777
+ ] }) : null;
778
+ }
779
+ function co() {
780
+ const s = f(() => {
781
+ const u = new r.BufferGeometry();
782
+ return u.setAttribute("position", new r.BufferAttribute(new Float32Array(2400), 3)), u.setAttribute("color", new r.BufferAttribute(new Float32Array(2400), 3)), u;
783
+ }, []), o = f(() => new r.Vector3(), []), i = f(() => new r.Vector3(), []), a = f(() => new r.Vector3(), []), c = f(() => new r.Vector3(), []), l = f(() => new r.Color(), []), p = (u, d) => {
784
+ const x = 1 - u;
785
+ return d.set(x * x * o.x + 2 * x * u * a.x + u * u * i.x, x * x * o.y + 2 * x * u * a.y + u * u * i.y, x * x * o.z + 2 * x * u * a.z + u * u * i.z);
786
+ };
787
+ return te(() => {
788
+ const u = s.getAttribute("position"), d = s.getAttribute("color"), x = performance.now();
789
+ let y = 0;
790
+ k.instances.forEach((P) => {
791
+ if (!P.parent || y >= 400) return;
792
+ const g = se.get(P.parent), I = se.get(P.id);
793
+ if (!g || !I) return;
794
+ const w = bt(P, x);
795
+ if (w < 0.02) return;
796
+ const T = _((x - P.bornAt) / 650);
797
+ o.copy(g), i.copy(I), a.copy(o).add(i).multiplyScalar(0.5), a.y = Math.max(o.y, i.y) + 1.2 + o.distanceTo(i) * 0.12;
798
+ const R = we(T), M = 1 - T, W = (P.type === "graph_scout" || P.type === "records_scout" ? 0.9 : 0.45) * w + M * 2.5 + qe(P, x) * 0.4;
799
+ l.set(Me[P.type]);
800
+ for (let N = 0; N < 10 && y < 400; N++, y++) {
801
+ const K = N / 10 * R, L = (N + 1) / 10 * R;
802
+ p(K, c), u.setXYZ(y * 2, c.x, c.y, c.z), p(L, c), u.setXYZ(y * 2 + 1, c.x, c.y, c.z);
803
+ const V = W * (0.35 + 0.65 * (N / 10)), U = W * (0.35 + 0.65 * ((N + 1) / 10));
804
+ d.setXYZ(y * 2, l.r * V, l.g * V, l.b * V), d.setXYZ(y * 2 + 1, l.r * U, l.g * U, l.b * U);
805
+ }
806
+ }), s.setDrawRange(0, y * 2), u.needsUpdate = !0, d.needsUpdate = !0;
807
+ }), /* @__PURE__ */ t("lineSegments", { geometry: s, frustumCulled: !1, children: /* @__PURE__ */ t("lineBasicMaterial", { vertexColors: !0, transparent: !0, blending: r.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) });
808
+ }
809
+ function io(e) {
810
+ const [n, s] = Ce([]), o = S({ ids: /* @__PURE__ */ new Set(), version: -1 });
811
+ return te(() => {
812
+ const i = o.current;
813
+ let a = i.version !== he.version || i.ids.size !== k.instances.size;
814
+ if (!a) {
815
+ for (const c of k.instances.keys()) if (!i.ids.has(c)) {
816
+ a = !0;
817
+ break;
818
+ }
819
+ }
820
+ a && (i.version = he.version, i.ids = new Set(k.instances.keys()), s([...k.instances.values()].filter((c) => k.runs.has(c.run) && Te(c))));
821
+ }), /* @__PURE__ */ m("group", { children: [
822
+ n.map((i) => /* @__PURE__ */ t(ao, { inst: i, ...e }, i.id)),
823
+ /* @__PURE__ */ t(co, {})
824
+ ] });
825
+ }
826
+ function lo() {
827
+ return te(() => {
828
+ Gt(), Et();
829
+ }), null;
830
+ }
831
+ function uo({ galaxy: e, selectedRef: n, onSelect: s }) {
832
+ return /* @__PURE__ */ m(
833
+ ct,
834
+ {
835
+ camera: { position: [26, 30, 38], fov: 45, near: 0.5, far: 400 },
836
+ dpr: [1, 1.75],
837
+ gl: { antialias: !1, powerPreference: "high-performance" },
838
+ onPointerMissed: () => s(null),
839
+ children: [
840
+ /* @__PURE__ */ t("color", { attach: "background", args: ["#05040d"] }),
841
+ /* @__PURE__ */ t("fog", { attach: "fog", args: [ve.color, ve.near, ve.far] }),
842
+ /* @__PURE__ */ t("ambientLight", { intensity: 0.35, color: "#8a7dff" }),
843
+ /* @__PURE__ */ t("pointLight", { position: [0, 24, 0], intensity: 180, distance: 60, color: "#7c6cff" }),
844
+ /* @__PURE__ */ t("pointLight", { position: [30, 10, -20], intensity: 90, distance: 60, color: "#ff2d95" }),
845
+ /* @__PURE__ */ t(st, { radius: 160, depth: 60, count: pe ? 800 : 2200, factor: 4, saturation: 0.3, fade: !0, speed: 0 }),
846
+ /* @__PURE__ */ t(lo, {}),
847
+ /* @__PURE__ */ t(Ot, {}),
848
+ /* @__PURE__ */ t(_t, {}),
849
+ /* @__PURE__ */ t(Ut, { galaxy: e }),
850
+ /* @__PURE__ */ t(Zt, {}),
851
+ /* @__PURE__ */ t(io, { selectedRef: n, onSelect: s }),
852
+ /* @__PURE__ */ t(Ft, {}),
853
+ /* @__PURE__ */ t(Kt, {}),
854
+ /* @__PURE__ */ t(eo, {}),
855
+ /* @__PURE__ */ t(oo, {}),
856
+ /* @__PURE__ */ t(so, {}),
857
+ /* @__PURE__ */ t(
858
+ at,
859
+ {
860
+ makeDefault: !0,
861
+ target: [0, 5, 0],
862
+ enableDamping: !0,
863
+ dampingFactor: 0.06,
864
+ minDistance: 14,
865
+ maxDistance: 90,
866
+ minPolarAngle: 0.35,
867
+ maxPolarAngle: 1.32
868
+ }
869
+ ),
870
+ /* @__PURE__ */ m(it, { multisampling: 0, children: [
871
+ /* @__PURE__ */ t(lt, { mipmapBlur: !0, intensity: 1.25, luminanceThreshold: 0.22, luminanceSmoothing: 0.25, radius: 0.78 }),
872
+ /* @__PURE__ */ t(ut, { eskil: !1, offset: 0.22, darkness: 0.85 }),
873
+ /* @__PURE__ */ t(ft, { opacity: 0.035 })
874
+ ] })
875
+ ]
876
+ }
877
+ );
878
+ }
879
+ function wo() {
880
+ const e = Ct(), [n, s] = Ce(null), o = S(null), i = pt((a) => {
881
+ o.current = a, s(a);
882
+ }, []);
883
+ return /* @__PURE__ */ m("div", { className: "scene-root city-root", children: [
884
+ /* @__PURE__ */ t(uo, { galaxy: e, selectedRef: o, onSelect: i }),
885
+ /* @__PURE__ */ t(Bt, { title: "city", subtitle: "night city · agents rise as skyscrapers · districts = Hatchet runs · spire = knowledge graph · blimps = MCP", selected: n, onClose: () => i(null) })
886
+ ] });
887
+ }
888
+ export {
889
+ wo as default
890
+ };