agentglow 0.4.1 → 0.4.2

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,590 @@
1
+ var Ye = Object.defineProperty;
2
+ var $e = (e, o, n) => o in e ? Ye(e, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[o] = n;
3
+ var ee = (e, o, n) => $e(e, typeof o != "symbol" ? o + "" : o, n);
4
+ import { jsxs as ne, Fragment as he, jsx as f } from "react/jsx-runtime";
5
+ import { Stars as Ze } from "@react-three/drei";
6
+ import { EffectComposer as Qe, Bloom as Je, Vignette as et } from "@react-three/postprocessing";
7
+ import { useFrame as ie, useThree as tt } from "@react-three/fiber";
8
+ import { useRef as L, useMemo as B, useEffect as nt, useState as Le } from "react";
9
+ import * as t from "three";
10
+ import { T as Ne, w as H, a as de, p as ot, e as rt, s as st, y as fe, f as ke, L as Ee, j as at, n as it, o as ct, l as lt, m as ut, c as je, g as pt, z as ft, K as dt, A as mt, B as ht, G as gt, C as vt, R as wt, u as yt, D as bt, E as Mt, d as De, k as St, x as At } from "./KitScene-D8qiflCw.js";
11
+ const oe = (e) => e < 0 ? 0 : e > 1 ? 1 : e, Fe = (e) => 1 - Math.pow(1 - oe(e), 3), ze = (e) => (e = oe(e), e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2), Ct = (e) => {
12
+ e = oe(e);
13
+ const o = 2.2;
14
+ return 1 + (o + 1) * Math.pow(e - 1, 3) + o * Math.pow(e - 1, 2);
15
+ }, Ve = Object.fromEntries(Object.entries(Ne).map(([e, o]) => [e, new t.Color(o)])), Be = (e) => e === "graph_scout" || e === "records_scout" || e === "data_scout";
16
+ let Se = null;
17
+ function xt() {
18
+ if (Se) return Se;
19
+ const e = document.createElement("canvas");
20
+ e.width = e.height = 128;
21
+ const o = e.getContext("2d"), n = o.createRadialGradient(64, 64, 0, 64, 64, 64);
22
+ return n.addColorStop(0, "rgba(255,255,255,1)"), n.addColorStop(0.15, "rgba(255,255,255,0.6)"), n.addColorStop(0.45, "rgba(255,255,255,0.14)"), n.addColorStop(1, "rgba(255,255,255,0)"), o.fillStyle = n, o.fillRect(0, 0, 128, 128), Se = new t.CanvasTexture(e), Se;
23
+ }
24
+ function me(e = "#fff") {
25
+ return new t.SpriteMaterial({ map: xt(), color: e, blending: t.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 });
26
+ }
27
+ function ge(e = "#fff") {
28
+ return new t.MeshBasicMaterial({ color: e, blending: t.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 });
29
+ }
30
+ function Vt(e = 64, o = 7) {
31
+ const n = [], r = [];
32
+ for (let s = 0; s <= e; s++) {
33
+ const u = s / e;
34
+ for (let l = 0; l < o; l++) {
35
+ const h = l / o * Math.PI * 2;
36
+ n.push(u, Math.cos(h), Math.sin(h));
37
+ }
38
+ }
39
+ for (let s = 0; s < e; s++)
40
+ for (let u = 0; u < o; u++) {
41
+ const l = s * o + u, h = s * o + (u + 1) % o, m = (s + 1) * o + u, x = (s + 1) * o + (u + 1) % o;
42
+ r.push(l, m, h, h, m, x);
43
+ }
44
+ const a = new t.BufferGeometry();
45
+ return a.setAttribute("position", new t.Float32BufferAttribute(n, 3)), a.setIndex(r), a.boundingSphere = new t.Sphere(new t.Vector3(), 1e4), a;
46
+ }
47
+ const Rt = Vt(), Ge = new t.SphereGeometry(1, 32, 24);
48
+ new t.SphereGeometry(1, 40, 28);
49
+ new t.IcosahedronGeometry(1, 1);
50
+ const He = new t.ConeGeometry(1, 1, 14).translate(0, 0.5, 0), Tt = new t.ConeGeometry(1, 1, 6, 1, !0).translate(0, 0.5, 0), zt = (
51
+ /* glsl */
52
+ `
53
+ uniform vec3 uP0; uniform vec3 uP1; uniform vec3 uP2; uniform float uRadius; uniform float uTaper;
54
+ varying float vT; varying float vRim;
55
+ void main(){
56
+ float t = position.x; float a = 1.0 - t;
57
+ vec3 p = a*a*uP0 + 2.0*a*t*uP1 + t*t*uP2;
58
+ vec3 tg = 2.0*a*(uP1-uP0) + 2.0*t*(uP2-uP1);
59
+ tg = length(tg) > 1e-5 ? normalize(tg) : vec3(1.0,0.0,0.0);
60
+ vec3 up = abs(tg.y) > 0.92 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,0.0);
61
+ vec3 n = normalize(cross(tg, up)); vec3 b = cross(tg, n);
62
+ vec3 off = n*position.y + b*position.z;
63
+ vec4 mv = modelViewMatrix * vec4(p + off * uRadius * mix(1.0, uTaper, t), 1.0);
64
+ vec3 vn = normalize(normalMatrix * off);
65
+ vRim = abs(dot(vn, normalize(-mv.xyz)));
66
+ vT = t;
67
+ gl_Position = projectionMatrix * mv;
68
+ }`
69
+ ), Pt = (
70
+ /* glsl */
71
+ `
72
+ uniform vec3 uColor; uniform float uOpacity; uniform float uGrow; uniform float uTime; uniform float uSpark; uniform float uFlow;
73
+ uniform float uHead; uniform float uTail; uniform vec3 uHeadColor;
74
+ varying float vT; varying float vRim;
75
+ void main(){
76
+ if (vT > uGrow) discard;
77
+ float core = 0.25 + 0.75 * vRim * vRim;
78
+ float tip = smoothstep(uGrow - 0.1, uGrow, vT) * step(uGrow, 0.995);
79
+ float spark = uSpark * pow(max(0.0, sin(vT * 16.0 - uTime * 10.0)), 14.0);
80
+ float head = 0.0;
81
+ if (uHead >= 0.0) {
82
+ float d = vT - uHead;
83
+ head = d > 0.0 ? exp(-d * d / 0.0006) : exp(d / max(uTail, 0.001));
84
+ }
85
+ // directional flow: soft dashes travelling from start (parent, vT=0) to end (child, vT=1)
86
+ float flow = uFlow * pow(max(0.0, sin((vT * 7.0 - uTime * 0.9) * 3.14159)), 6.0);
87
+ vec3 col = uColor * uOpacity * (core + spark * 3.5 + tip * 3.0 + flow * 2.2) + uHeadColor * head * (0.6 + vRim);
88
+ gl_FragColor = vec4(col, 1.0);
89
+ }`
90
+ );
91
+ function Bt(e = "#fff", o = 0.06, n = 0.4) {
92
+ return new t.ShaderMaterial({
93
+ uniforms: {
94
+ uP0: { value: new t.Vector3() },
95
+ uP1: { value: new t.Vector3() },
96
+ uP2: { value: new t.Vector3() },
97
+ uRadius: { value: o },
98
+ uTaper: { value: n },
99
+ uColor: { value: new t.Color(e) },
100
+ uOpacity: { value: 1 },
101
+ uGrow: { value: 1 },
102
+ uTime: { value: 0 },
103
+ uFlow: { value: 0 },
104
+ uSpark: { value: 0 },
105
+ uHead: { value: -1 },
106
+ uTail: { value: 0.12 },
107
+ uHeadColor: { value: new t.Color(4, 4, 4) }
108
+ },
109
+ vertexShader: zt,
110
+ fragmentShader: Pt,
111
+ transparent: !0,
112
+ depthWrite: !1,
113
+ blending: t.AdditiveBlending
114
+ });
115
+ }
116
+ function ae(e, o, n, r, a) {
117
+ const s = 1 - r;
118
+ return a.set(s * s * e.x + 2 * s * r * o.x + r * r * n.x, s * s * e.y + 2 * s * r * o.y + r * r * n.y, s * s * e.z + 2 * s * r * o.z + r * r * n.z);
119
+ }
120
+ function Pe(e, o, n, r) {
121
+ r.copy(e).add(o).multiplyScalar(0.5);
122
+ const a = Math.hypot(r.x, r.y) || 1;
123
+ return r.x += r.x / a * n, r.y += r.y / a * n, r.z += n * 0.9, r;
124
+ }
125
+ function Ie(e, o, n) {
126
+ return e.r += o.r * n, e.g += o.g * n, e.b += o.b * n, e;
127
+ }
128
+ const Te = class Te {
129
+ constructor(o) {
130
+ ee(this, "mesh");
131
+ ee(this, "colors");
132
+ ee(this, "n", 0);
133
+ ee(this, "max");
134
+ ee(this, "o", new t.Object3D());
135
+ ee(this, "a", new t.Vector3());
136
+ ee(this, "b", new t.Vector3());
137
+ ee(this, "d", new t.Vector3());
138
+ this.max = o, this.colors = new Float32Array(o * 3), this.mesh = new t.InstancedMesh(He, new t.MeshBasicMaterial({ blending: t.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 }), o), this.mesh.instanceColor = new t.InstancedBufferAttribute(this.colors, 3), this.mesh.frustumCulled = !1, this.mesh.count = 0;
139
+ }
140
+ begin() {
141
+ this.n = 0;
142
+ }
143
+ /** Arrow at curve parameter t, pointing toward p2 (dir=+1) or toward p0 (dir=-1). */
144
+ add(o, n, r, a, s, u, l, h = 1) {
145
+ this.n >= this.max || (ae(o, n, r, a, this.a), ae(o, n, r, Math.min(1, Math.max(0, a + 0.02 * s)), this.b), this.d.subVectors(this.b, this.a), !(this.d.lengthSq() < 1e-8) && (this.o.position.copy(this.a), this.o.quaternion.setFromUnitVectors(Te.UP, this.d.normalize()), this.o.scale.set(u * 0.4, u, u * 0.4), this.o.updateMatrix(), this.mesh.setMatrixAt(this.n, this.o.matrix), this.colors[this.n * 3] = l.r * h, this.colors[this.n * 3 + 1] = l.g * h, this.colors[this.n * 3 + 2] = l.b * h, this.n++));
146
+ }
147
+ end() {
148
+ this.mesh.count = this.n, this.mesh.instanceMatrix.needsUpdate = !0, this.mesh.instanceColor && (this.mesh.instanceColor.needsUpdate = !0);
149
+ }
150
+ };
151
+ ee(Te, "UP", new t.Vector3(0, 1, 0));
152
+ let Re = Te;
153
+ new t.Vector3();
154
+ new t.Vector3();
155
+ new t.Vector3(0, 1, 0);
156
+ const Ot = new t.Color("#4b4a63"), Ke = new t.Color("#fbbf24"), ye = /* @__PURE__ */ new Map();
157
+ function Gt(e) {
158
+ const o = [], n = new t.Vector3(0, 1, 0), r = 10;
159
+ for (let a = 0; a < r; a++) {
160
+ const s = 1 - 2 * (a + 0.5) / r, u = Math.sqrt(1 - s * s), l = a * 2.39996 + e * 6.28;
161
+ o.push(new t.Quaternion().setFromUnitVectors(n, new t.Vector3(Math.cos(l) * u, s, Math.sin(l) * u)));
162
+ }
163
+ return o;
164
+ }
165
+ const Et = new t.TorusGeometry(1.25, 0.05, 8, 64);
166
+ function Ft({ agent: e, onSelect: o }) {
167
+ const n = e.inst, r = L(null), a = L(null), s = L(null), u = L(null), l = L(null), h = L(null), m = L(null), x = L(null), S = B(() => [...n.id].reduce((E, A) => (E * 31 + A.charCodeAt(0)) % 9973, 7) / 9973, [n.id]), q = B(() => Gt(S), [S]), V = Ve[n.type], w = B(
168
+ () => ({
169
+ core: ge(V),
170
+ hot: ge("#ffffff"),
171
+ spike: ge(V),
172
+ ring: ge(Ke),
173
+ halo: me(V),
174
+ syn: Bt(V, Be(n.type) ? 0.08 : 0.11, 0.8),
175
+ arrow: ge(V)
176
+ }),
177
+ [V, n.type]
178
+ ), i = B(() => ({ p0: new t.Vector3(), p1: new t.Vector3(), seedP: new t.Vector3(), p0set: !1, labelK: 1, spik: 0, ringK: 0, parentK: 1, c: new t.Color() }), []);
179
+ nt(() => (ye.set(n.id, i.p1), () => {
180
+ ye.get(n.id) === i.p1 && ye.delete(n.id);
181
+ }), [n.id, i]), ie(({ clock: E }) => {
182
+ var _, Y, $;
183
+ const A = performance.now(), O = E.elapsedTime, Z = fe ? 0 : 0.08 * ke.spread;
184
+ e.live.set(e.pos.x + Math.sin(O * 0.35 + S * 20) * Z, e.pos.y + Math.cos(O * 0.3 + S * 13) * Z, e.pos.z);
185
+ const F = e.live, G = n.parent ? H.instances.get(n.parent) : void 0, j = n.parent ? de(n.parent) : void 0;
186
+ j ? (i.p0.copy(j), i.p0set = !0) : i.p0set || (i.p0.copy(F), i.p0set = !0), Pe(i.p0, F, Be(n.type) || n.subagent ? 0.25 : 0.6, i.p1);
187
+ const R = (A - n.bornAt) / 1e3, T = n.parent ? Fe(R / 0.9) : 1, I = Ct((R - (n.parent ? 0.85 : 0.1)) / 0.7), N = n.exitAt ? (A - n.exitAt) / 1e3 : -1, X = lt(n) / 1e3, K = N >= 0 ? oe(N / (X * 0.92)) : 0, Q = ot(n, A);
188
+ let D = !1;
189
+ for (const k of H.mcpPending.values()) k.instance === n.id && (D = !0);
190
+ const C = N < 0 && (n.status === "thinking" || n.status === "spawning"), W = rt(n, A), d = fe ? 0 : 1, y = 0.5 + 0.5 * Math.sin(O * 2 + S * 9) * d, z = 0.5 + 0.5 * Math.sin(O * 1 + S * 5) * d;
191
+ i.spik += ((C ? 1 : 0) - i.spik) * 0.06, i.ringK += ((D && N < 0 ? 1 : 0) - i.ringK) * 0.08, r.current && (T < 1 ? r.current.position.copy(ae(i.p0, i.p1, F, T, i.seedP)) : r.current.position.copy(F));
192
+ const M = T < 1 ? 0.18 : 0, c = Math.max(M, 0.18 + 0.82 * I) * (1 - K * K * 0.95) * e.scale;
193
+ (_ = a.current) == null || _.scale.setScalar(Math.max(1e-4, c * (0.55 + W * 0.06 + (C ? y * 0.05 : z * 0.04)))), (Y = s.current) == null || Y.scale.setScalar(Math.max(1e-4, i.spik * (0.85 + y * 0.15)));
194
+ const p = C ? 0.75 + y * 0.35 : 0.3 + z * 0.15;
195
+ if (i.c.copy(V).multiplyScalar(p + W * 0.35), N >= 0 && i.c.lerp(Ot, K).multiplyScalar(1 - K * 0.75), w.core.color.copy(i.c), w.spike.color.copy(i.c).multiplyScalar(0.9), w.hot.color.setScalar((C ? 0.35 + y * 0.25 : 0.08) * (1 - K) + W * 0.2), u.current && (u.current.visible = i.ringK > 0.02, u.current.rotation.z = O * 0.9, u.current.rotation.x = 1.1 + Math.sin(O * 0.5) * 0.2, u.current.scale.setScalar(Math.max(1e-4, c * 0.55 * i.ringK)), w.ring.color.copy(Ke).multiplyScalar(0.9 * i.ringK * (0.75 + z * 0.25))), h.current && (h.current.scale.setScalar(Math.max(1e-4, c * (C ? 2.3 + y * 0.3 : 1.6) + W * 0.35)), w.halo.color.copy(V).multiplyScalar((C ? 0.22 : 0.09) * (1 - K) + W * 0.06)), ($ = x.current) == null || $.position.set(0, -0.78 * e.scale - 0.25, 0), m.current) {
196
+ const k = st(n.id);
197
+ i.labelK += ((k ? 1 : 0) - i.labelK) * 0.12, m.current.setOpacity(oe(I) * (1 - K) * 0.95 * i.labelK);
198
+ }
199
+ const v = !!G && !G.exitAt;
200
+ i.parentK += ((n.parent && !n.exitAt && v ? 1 : 0) - i.parentK) * (v ? 0.05 : 0.035);
201
+ const g = w.syn.uniforms;
202
+ g.uP0.value.copy(i.p0), g.uP1.value.copy(i.p1), g.uP2.value.copy(F);
203
+ const U = N >= 0 ? ze(N / (X * 0.64)) : 0;
204
+ if (g.uGrow.value = n.parent ? T * (1 - U) : 0, g.uSpark.value = 0, g.uHead.value = T < 1 ? T : -1, g.uTail.value = 0.1, g.uHeadColor.value.copy(V).multiplyScalar(1.5), g.uOpacity.value = (C ? 1.1 : 0.75) * Math.max(0, Math.min(i.parentK, Q > 0 ? 1 : 0)) + (T < 1 ? 0.4 : 0), g.uTime.value = fe ? 0 : O, g.uFlow.value = T >= 1 ? i.parentK : 0, l.current) {
205
+ const k = n.parent && T >= 1 && i.parentK > 0.05 && g.uGrow.value > 0.9;
206
+ if (l.current.visible = !!k, k) {
207
+ ae(i.p0, i.p1, F, 0.8, Oe), ae(i.p0, i.p1, F, 0.86, We), l.current.position.copy(Oe), Ue.subVectors(We, Oe).normalize(), l.current.quaternion.setFromUnitVectors(_t, Ue);
208
+ const ce = (Be(n.type) ? 0.75 : 1) * Math.min(1.3, ke.scale);
209
+ l.current.scale.set(0.16 * ce, 0.42 * ce, 0.16 * ce), w.arrow.color.copy(V).multiplyScalar(1.6 * i.parentK);
210
+ }
211
+ }
212
+ });
213
+ const b = (E) => {
214
+ E.stopPropagation(), o(n.id);
215
+ }, P = n.id.split(":")[2];
216
+ return /* @__PURE__ */ ne(he, { children: [
217
+ /* @__PURE__ */ f("mesh", { geometry: Rt, material: w.syn, frustumCulled: !1 }),
218
+ /* @__PURE__ */ f("mesh", { ref: l, geometry: He, material: w.arrow, visible: !1 }),
219
+ /* @__PURE__ */ ne("group", { ref: r, children: [
220
+ /* @__PURE__ */ ne("group", { ref: a, scale: 1e-4, children: [
221
+ /* @__PURE__ */ f("mesh", { geometry: Ge, material: w.core, onClick: b, onPointerOver: () => document.body.style.cursor = "pointer", onPointerOut: () => document.body.style.cursor = "" }),
222
+ /* @__PURE__ */ f("mesh", { geometry: Ge, material: w.hot, scale: 0.5 }),
223
+ /* @__PURE__ */ f("group", { ref: s, scale: 1e-4, children: q.map((E, A) => /* @__PURE__ */ f("mesh", { geometry: Tt, material: w.spike, quaternion: E, scale: [0.2, 1.9, 0.2] }, A)) })
224
+ ] }),
225
+ /* @__PURE__ */ f("mesh", { ref: u, geometry: Et, material: w.ring, visible: !1 }),
226
+ /* @__PURE__ */ f("sprite", { ref: h, material: w.halo }),
227
+ /* @__PURE__ */ f("group", { ref: x, children: /* @__PURE__ */ f(
228
+ Ee,
229
+ {
230
+ ref: m,
231
+ text: `${n.name}${P !== void 0 ? ` ${Number(P) + 1}` : ""}`,
232
+ live: n.job ? () => at(n) : null,
233
+ color: Ne[n.type],
234
+ size: n.subagent ? 0.22 : 0.3,
235
+ opacity: 0,
236
+ fit: !0,
237
+ pxRange: n.subagent ? [8, 12] : [9, 14]
238
+ }
239
+ ) })
240
+ ] })
241
+ ] });
242
+ }
243
+ const Oe = new t.Vector3(), We = new t.Vector3(), Ue = new t.Vector3(), _t = new t.Vector3(0, 1, 0);
244
+ function kt({ comet: e }) {
245
+ const o = L(null), n = H.instances.get(e.from), r = n ? Ve[n.type] : Ve.planner, a = B(() => me(new t.Color(r).multiplyScalar(1.8).addScalar(0.3)), [r]), s = B(() => ({ a: new t.Vector3(), b: new t.Vector3(), c: new t.Vector3(), h: new t.Vector3() }), []);
246
+ return ie(() => {
247
+ const u = de(e.from), l = de(e.to);
248
+ if (!u || !l || !o.current) {
249
+ o.current && (o.current.visible = !1);
250
+ return;
251
+ }
252
+ const h = H.instances.get(e.to), m = (h == null ? void 0 : h.parent) === e.from ? ye.get(e.to) : (n == null ? void 0 : n.parent) === e.to ? ye.get(e.from) : void 0;
253
+ s.a.copy(u), s.b.copy(l), m ? s.c.copy(m) : Pe(s.a, s.b, 1.2, s.c);
254
+ const x = it(e);
255
+ ae(s.a, s.c, s.b, ze(x), s.h), o.current.visible = ct(e), o.current.position.copy(s.h), o.current.scale.setScalar(1.1);
256
+ }), /* @__PURE__ */ f("sprite", { ref: o, material: a, visible: !1 });
257
+ }
258
+ function jt() {
259
+ const [e, o] = Le([]), n = L({ n: -1, last: -1, first: -1 });
260
+ return ie(() => {
261
+ const r = H.comets, a = n.current, s = r.length ? r[0].id : -1, u = r.length ? r[r.length - 1].id : -1;
262
+ (r.length !== a.n || s !== a.first || u !== a.last) && (a.n = r.length, a.first = s, a.last = u, o(r.filter((l) => !(l.from.startsWith("svc:") && l.to.startsWith("svc:") && !l.failed) && (!ut.grouped || je(l.from) && je(l.to)))));
263
+ }), /* @__PURE__ */ f(he, { children: e.map((r) => /* @__PURE__ */ f(kt, { comet: r }, r.id)) });
264
+ }
265
+ const te = 3.3, It = 200, se = 14, Ae = 48, ue = 16, le = 8, Ce = 4, ve = new t.Color(1, 1, 1), Kt = new t.Color("#a78bfa"), Wt = (
266
+ /* glsl */
267
+ `
268
+ attribute float aSize; attribute vec3 aColor; varying vec3 vC; varying float vFacing; uniform float uScale;
269
+ void main(){
270
+ vec4 mv = modelViewMatrix * vec4(position, 1.0);
271
+ vec3 n = normalize(normalMatrix * normalize(position));
272
+ vFacing = 0.35 + 0.65 * smoothstep(-0.4, 0.5, dot(n, normalize(-mv.xyz))); // back side dimmer → depth
273
+ gl_PointSize = aSize * uScale / -mv.z; vC = aColor; gl_Position = projectionMatrix * mv; }`
274
+ ), Ut = (
275
+ /* glsl */
276
+ `
277
+ varying vec3 vC; varying float vFacing;
278
+ void main(){ float r = length(gl_PointCoord - 0.5) * 2.0; if (r > 1.0) discard;
279
+ float core = smoothstep(0.45, 0.0, r); float halo = pow(1.0 - r, 2.2);
280
+ gl_FragColor = vec4(vC * vFacing * (core * 1.2 + halo * 0.45), 1.0); }`
281
+ ), Lt = (
282
+ /* glsl */
283
+ `
284
+ varying vec3 vN; varying vec3 vV; varying vec3 vObj;
285
+ void main(){ vec4 mv = modelViewMatrix * vec4(position, 1.0); vN = normalize(normalMatrix * normal); vV = normalize(-mv.xyz); vObj = normalize(position);
286
+ gl_Position = projectionMatrix * mv; }`
287
+ ), Nt = (
288
+ /* glsl */
289
+ `
290
+ uniform vec3 uRim; uniform vec3 uInner; uniform float uTime;
291
+ uniform vec3 uRipC[${le}]; uniform float uRipA[${le}];
292
+ varying vec3 vN; varying vec3 vV; varying vec3 vObj;
293
+ void main(){
294
+ float f = 1.0 - abs(dot(normalize(vN), normalize(vV)));
295
+ float rim = pow(f, 3.0);
296
+ float body = pow(1.0 - f, 2.0) * 0.12; // faint glassy fill toward the center
297
+ float shimmer = 0.92 + 0.08 * sin(uTime * 0.25 + vObj.y * 3.0 + vObj.x * 2.0);
298
+ vec3 col = uRim * rim * 1.1 * shimmer + uInner * body;
299
+ float rip = 0.0;
300
+ for (int i = 0; i < ${le}; i++) {
301
+ float a = uRipA[i];
302
+ if (a < 0.0 || a > 1.0) continue;
303
+ float d = acos(clamp(dot(vObj, uRipC[i]), -1.0, 1.0));
304
+ float ring = a * 2.2;
305
+ rip += exp(-pow((d - ring) / 0.06, 2.0)) * (1.0 - a) * (1.0 - a);
306
+ }
307
+ col += vec3(1.0) * rip * 0.6;
308
+ gl_FragColor = vec4(col, 1.0);
309
+ }`
310
+ );
311
+ function Dt({ galaxy: e }) {
312
+ const o = B(() => pt(e, It), [e]), n = o.nodes.length, { size: r, gl: a, camera: s } = tt(), u = L([]), l = L([]), h = L(Array(Ce).fill("")), m = B(() => {
313
+ const i = new Float32Array(n * 3), b = [], P = Math.PI * (3 - Math.sqrt(5)), E = o.ns, A = [0, 0, 0];
314
+ for (let d = 0; d < n; d++) {
315
+ const y = 1 - 2 * (d + 0.5) / Math.max(1, E), z = Math.sqrt(Math.max(0, 1 - y * y)), M = d < E ? new t.Vector3(Math.cos(d * P) * z, y, Math.sin(d * P) * z) : new t.Vector3(...ft(o.nodes[d].id, A));
316
+ b.push(M), i.set([M.x * te, M.y * te, M.z * te], d * 3);
317
+ }
318
+ const O = o.nodes.map((d) => new t.Color(dt[d.kind] ?? "#94a3b8").lerp(Kt, 0.2).multiplyScalar(0.62)), Z = new Float32Array(n), F = new Float32Array(n * 3), G = new t.BufferGeometry();
319
+ G.setAttribute("position", new t.BufferAttribute(i, 3)), G.setAttribute("aSize", new t.BufferAttribute(Z, 1)), G.setAttribute("aColor", new t.BufferAttribute(F, 3));
320
+ const j = new Map(o.nodes.map((d, y) => [d.id, y])), R = [], T = [];
321
+ for (const d of o.links) {
322
+ const y = j.get(d.source), z = j.get(d.target);
323
+ y !== void 0 && z !== void 0 && y !== z && b[y].angleTo(b[z]) < 1.25 && (R.push([y, z]), T.push(1));
324
+ }
325
+ for (let d = 0; d < n; d++) {
326
+ let y = -1, z = -1, M = 9, c = 9;
327
+ for (let p = 0; p < n; p++) {
328
+ if (p === d) continue;
329
+ const v = b[d].distanceToSquared(b[p]);
330
+ v < M ? (z = y, c = M, y = p, M = v) : v < c && (z = p, c = v);
331
+ }
332
+ y > d && (R.push([d, y]), T.push(0)), z > d && (R.push([d, z]), T.push(0));
333
+ }
334
+ const I = new Float32Array(R.length * se * 2 * 3), N = new Float32Array(R.length * se * 2 * 3), X = new Int32Array(R.length * se * 2 * 2), K = new Uint8Array(R.length * se * 2), Q = new t.Quaternion(), D = new t.Vector3();
335
+ R.forEach(([d, y], z) => {
336
+ const M = b[d], c = b[y], p = M.angleTo(c), v = new t.Vector3().crossVectors(M, c);
337
+ v.lengthSq() < 1e-6 && v.set(0, 1, 0), v.normalize();
338
+ for (let g = 0; g < se; g++)
339
+ for (let U = 0; U < 2; U++) {
340
+ const _ = (g + U) / se;
341
+ Q.setFromAxisAngle(v, p * _), D.copy(M).applyQuaternion(Q).multiplyScalar(te * (1 + 0.06 * Math.sin(Math.PI * _) * Math.min(1, p)));
342
+ const Y = (z * se + g) * 2 + U;
343
+ I.set([D.x, D.y, D.z], Y * 3), X[Y * 2] = d, X[Y * 2 + 1] = y, K[Y] = T[z];
344
+ }
345
+ });
346
+ const C = new t.BufferGeometry();
347
+ C.setAttribute("position", new t.BufferAttribute(I, 3)), C.setAttribute("color", new t.BufferAttribute(N, 3));
348
+ const W = new t.BufferGeometry();
349
+ return W.setAttribute("position", new t.BufferAttribute(new Float32Array(Ae * ue * 2 * 3), 3)), W.setAttribute("color", new t.BufferAttribute(new Float32Array(Ae * ue * 2 * 3), 3)), W.boundingSphere = new t.Sphere(new t.Vector3(), 1e4), { pos: i, unit: b, base: O, ngeo: G, ageo: C, owner: X, kindOf: K, nArcV: R.length * se * 2, bgeo: W, fire: new Float32Array(n), white: new Float32Array(n), fireC: Array.from({ length: n }, () => new t.Color()) };
350
+ }, [o, n]), x = B(
351
+ () => ({
352
+ nodes: new t.ShaderMaterial({ uniforms: { uScale: { value: 400 } }, vertexShader: Wt, fragmentShader: Ut, transparent: !0, depthWrite: !1, blending: t.AdditiveBlending }),
353
+ arcs: new t.LineBasicMaterial({ vertexColors: !0, transparent: !0, blending: t.AdditiveBlending, depthWrite: !1, toneMapped: !1 }),
354
+ beam: new t.LineBasicMaterial({ vertexColors: !0, transparent: !0, blending: t.AdditiveBlending, depthWrite: !1, toneMapped: !1 }),
355
+ orb: new t.ShaderMaterial({
356
+ uniforms: {
357
+ uRim: { value: new t.Color("#8b7cff").multiplyScalar(0.7) },
358
+ uInner: { value: new t.Color("#5b8cff").multiplyScalar(0.6) },
359
+ uTime: { value: 0 },
360
+ uRipC: { value: Array.from({ length: le }, () => new t.Vector3(0, 1, 0)) },
361
+ uRipA: { value: new Array(le).fill(-1) }
362
+ },
363
+ vertexShader: Lt,
364
+ fragmentShader: Nt,
365
+ transparent: !0,
366
+ depthWrite: !1,
367
+ blending: t.AdditiveBlending
368
+ }),
369
+ core: me(new t.Color("#8b7cff").multiplyScalar(0.22)),
370
+ aura: me(new t.Color("#4c1d95").multiplyScalar(0.28))
371
+ }),
372
+ []
373
+ ), S = B(() => /* @__PURE__ */ new Map(), [o]), q = B(() => new Re(Ae), []), V = B(() => ({ v: new t.Vector3(), v2: new t.Vector3(), mid: new t.Vector3(), sp: new t.Vector3(), c: new t.Color(), c2: new t.Color() }), []), w = (i) => {
374
+ let b = S.get(i);
375
+ return b === void 0 && S.set(i, b = vt(o, i)), b;
376
+ };
377
+ return ie(({ clock: i }) => {
378
+ const b = performance.now(), { pos: P, base: E, fire: A, white: O, fireC: Z, unit: F } = m;
379
+ x.nodes.uniforms.uScale.value = r.height * a.getPixelRatio() / (2 * Math.tan(s.fov * Math.PI / 360)) * mt.graph.scale, x.orb.uniforms.uTime.value = fe ? 0 : i.elapsedTime, A.fill(0), O.fill(0);
380
+ const { v: G, v2: j, mid: R, c: T, c2: I } = V, N = m.bgeo.getAttribute("position"), X = m.bgeo.getAttribute("color"), K = x.orb.uniforms.uRipC.value, Q = x.orb.uniforms.uRipA.value;
381
+ let D = 0;
382
+ q.begin();
383
+ let C = 0;
384
+ for (const c of H.flares) {
385
+ const p = w(c.node), v = (b - c.start) / 1e3, g = H.instances.get(c.instance), U = g ? Ve[g.type] : ve, _ = c.op === "write", Y = v < 0.35 ? v / 0.35 : Math.exp(-(v - 0.35) * 1.2);
386
+ Y > A[p] && (A[p] = Y, Z[p].copy(_ ? ve : U), O[p] = _ ? 1 : 0), _ && v < 1.8 && C < le && (K[C].copy(F[p]), Q[C] = v / 1.8, C++);
387
+ const $ = de(c.instance), k = $ ? ht($, V.sp) : void 0;
388
+ if (k && v < 2.2 && D < Ae) {
389
+ G.set(P[p * 3], P[p * 3 + 1], P[p * 3 + 2]), R.copy(k).add(G).multiplyScalar(0.5), R.z += 1;
390
+ const ce = Math.min(1, v / 0.3) * (1 - v / 2.2) ** 1.5, Xe = _ ? Math.min(1, v * 0.85) : 1 - Math.min(1, v * 0.85);
391
+ for (let be = 0; be < ue; be++)
392
+ for (let Me = 0; Me < 2; Me++) {
393
+ const J = (be + Me) / ue, re = 1 - J;
394
+ j.set(re * re * k.x + 2 * re * J * R.x + J * J * G.x, re * re * k.y + 2 * re * J * R.y + J * J * G.y, re * re * k.z + 2 * re * J * R.z + J * J * G.z);
395
+ const _e = (D * ue + be) * 2 + Me;
396
+ N.setXYZ(_e, j.x, j.y, j.z);
397
+ const qe = Math.exp(-(((J - Xe) / 0.1) ** 2)) * 1.3;
398
+ I.copy(_ ? ve : U).multiplyScalar(ce * ((_ ? 0.5 : 0.2) + qe) * 0.75), X.setXYZ(_e, I.r, I.g, I.b);
399
+ }
400
+ _ ? q.add(k, R, G, 0.9, 1, 0.42, ve, ce * 1.1) : q.add(k, R, G, 0.1, -1, 0.42, U, ce * 1.3), D++;
401
+ }
402
+ }
403
+ for (let c = C; c < le; c++) Q[c] = -1;
404
+ m.bgeo.setDrawRange(0, D * ue * 2), q.end(), N.needsUpdate = !0, X.needsUpdate = !0;
405
+ const W = m.ngeo.getAttribute("aSize"), d = m.ngeo.getAttribute("aColor");
406
+ for (let c = 0; c < n; c++) {
407
+ const p = A[c];
408
+ W.setX(c, 0.21 + p * (0.55 + O[c] * 0.25)), T.copy(E[c]), p > 0.01 && Ie(Ie(T, Z[c], p * 1.6), ve, p * (0.3 + O[c] * 1.2)), d.setXYZ(c, T.r, T.g, T.b);
409
+ }
410
+ W.needsUpdate = !0, d.needsUpdate = !0;
411
+ const y = m.ageo.getAttribute("color"), z = m.owner;
412
+ for (let c = 0; c < m.nArcV; c++) {
413
+ const p = z[c * 2], v = z[c * 2 + 1], g = Math.max(A[p], A[v]), U = m.kindOf[c] ? 0.16 : 0.07;
414
+ y.setXYZ(c, 0.42 * U + g * 0.3, 0.36 * U + g * 0.3, 0.85 * U + g * 0.4);
415
+ }
416
+ y.needsUpdate = !0;
417
+ let M = 0;
418
+ for (let c = H.flares.length - 1; c >= 0 && M < Ce; c--) {
419
+ const p = H.flares[c];
420
+ if (b - p.start > 2200) break;
421
+ if (p.area) continue;
422
+ let v = !1;
423
+ for (let $ = 0; $ < M; $++) h.current[$] === p.node && (v = !0);
424
+ if (v) continue;
425
+ const g = w(p.node);
426
+ let U = !1;
427
+ for (let $ = 0; $ < M; $++) {
428
+ const k = l.current[$];
429
+ k && Math.abs(k.position.y - P[g * 3 + 1]) < 0.55 && Math.abs(k.position.x - P[g * 3]) < 3.2 && (U = !0);
430
+ }
431
+ if (U) continue;
432
+ const _ = u.current[M], Y = l.current[M];
433
+ _ && Y && (Y.position.set(P[g * 3], P[g * 3 + 1], P[g * 3 + 2]), h.current[M] !== p.node && (_.setText(`${p.op === "write" ? "wrote" : "read"} · ${p.node}`), _.setColor(p.op === "write" ? "#ffffff" : "#22d3ee")), _.setOpacity(1)), h.current[M] = p.node, M++;
434
+ }
435
+ for (let c = M; c < Ce; c++) {
436
+ const p = u.current[c];
437
+ p == null || p.setOpacity(0), h.current[c] = "";
438
+ }
439
+ }), /* @__PURE__ */ ne(he, { children: [
440
+ /* @__PURE__ */ ne("group", { children: [
441
+ /* @__PURE__ */ f("sprite", { material: x.aura, scale: te * 4.2, position: [0, 0, -te] }),
442
+ /* @__PURE__ */ f("sprite", { material: x.core, scale: te * 1.5 }),
443
+ /* @__PURE__ */ f("mesh", { geometry: Ge, material: x.orb, scale: te * 1.02 }),
444
+ /* @__PURE__ */ f("lineSegments", { geometry: m.ageo, material: x.arcs, frustumCulled: !1 }),
445
+ /* @__PURE__ */ f("points", { geometry: m.ngeo, material: x.nodes, frustumCulled: !1 })
446
+ ] }),
447
+ /* @__PURE__ */ f("lineSegments", { geometry: m.bgeo, material: x.beam, frustumCulled: !1 }),
448
+ /* @__PURE__ */ f("primitive", { object: q.mesh }),
449
+ Array.from({ length: Ce }, (i, b) => /* @__PURE__ */ f("group", { ref: (P) => void (l.current[b] = P), children: /* @__PURE__ */ f(Ee, { ref: (P) => void (u.current[b] = P), text: "", offset: [0, 0.42], size: 0.24, opacity: 0, fadeMs: 250, pxRange: [8, 12] }) }, b)),
450
+ /* @__PURE__ */ f(gt, { position: [0, -te - 0.9, 0], color: "#a78bfa", size: 0.28, opacity: 0.7, pxRange: [8, 12] })
451
+ ] });
452
+ }
453
+ function Ht({ run: e }) {
454
+ const o = B(() => new t.Color(e.color), [e.color]), n = B(() => me("#000"), []), r = L(null), a = L(null);
455
+ return ie(({ clock: s }) => {
456
+ var V;
457
+ const u = performance.now(), l = e.run ?? H.runs.get(e.id), h = l ? Fe((u - l.startedAt) / 1200) : 1, m = l != null && l.endedAt ? oe(1 - (u - l.endedAt - (wt - 2500)) / 2500) : 1, x = 0.9 + 0.1 * Math.sin(s.elapsedTime * 0.6 + e.index);
458
+ n.color.copy(o).multiplyScalar(0.16 * h * m * x);
459
+ const S = Math.abs(e.side.x) * e.hu + Math.abs(e.axis.x) * e.hv, q = Math.abs(e.side.y) * e.hu + Math.abs(e.axis.y) * e.hv;
460
+ r.current && (r.current.position.set(e.origin.x, e.origin.y, -1.5), r.current.scale.set(S * 2.6 + 3, q * 2.6 + 3, 1)), (V = a.current) == null || V.position.set(e.origin.x, e.origin.y + q + 0.6, 0.5);
461
+ }), /* @__PURE__ */ ne(he, { children: [
462
+ /* @__PURE__ */ f("sprite", { ref: r, material: n }),
463
+ /* @__PURE__ */ f("group", { ref: a, children: e.run && /* @__PURE__ */ f(Xt, { run: e.run }) })
464
+ ] });
465
+ }
466
+ function Xt({ run: e }) {
467
+ yt();
468
+ const o = e.status !== "started" || bt(e);
469
+ return /* @__PURE__ */ f(
470
+ Ee,
471
+ {
472
+ text: e.topic,
473
+ secondary: Mt(e, { base: "#94a3b8", current: "#fde68a", done: "#cbd5e1" }, ["running…", "run complete"]),
474
+ color: e.color,
475
+ size: 0.34,
476
+ maxWidth: 10,
477
+ opacity: o ? 0.5 : 1,
478
+ fadeMs: 400,
479
+ anchorY: "bottom",
480
+ pxRange: [10, 15]
481
+ }
482
+ );
483
+ }
484
+ const qt = new t.Color("#fbbf24"), Yt = new t.Color("#ff2d3d"), $t = new t.Color(1, 1, 1), Zt = new t.OctahedronGeometry(0.8, 0);
485
+ new t.EdgesGeometry(Zt);
486
+ function Qt({ call: e }) {
487
+ const o = H.mcpServers.get(e.server), n = B(() => new t.Color((o == null ? void 0 : o.color) ?? "#fff"), [o]), r = B(() => me(n.clone().multiplyScalar(1.8).addScalar(0.3)), [n]), a = L(null), s = B(() => ({ a: new t.Vector3(), b: new t.Vector3(), c: new t.Vector3(), h: new t.Vector3() }), []);
488
+ return ie(() => {
489
+ const u = de(e.instance), l = De(e.server);
490
+ if (!a.current) return;
491
+ if (!u || !o || !l) {
492
+ a.current.visible = !1;
493
+ return;
494
+ }
495
+ s.a.copy(u), s.b.copy(l), Pe(s.a, s.b, 1, s.c);
496
+ const h = oe((performance.now() - e.start) / (e.phase === "call" ? e.dur : e.dur * 0.75)), m = ze(h);
497
+ ae(s.a, s.c, s.b, e.phase === "call" ? m : 1 - m, s.h), a.current.visible = h < 1, a.current.position.copy(s.h), a.current.scale.setScalar(1);
498
+ }), /* @__PURE__ */ f("sprite", { ref: a, material: r, visible: !1 });
499
+ }
500
+ const xe = 24, pe = 40, we = 3;
501
+ function Jt() {
502
+ const e = B(() => {
503
+ const a = new t.BufferGeometry();
504
+ return a.setAttribute("position", new t.BufferAttribute(new Float32Array(xe * we * pe * 2 * 3), 3)), a.setAttribute("color", new t.BufferAttribute(new Float32Array(xe * we * pe * 2 * 3), 3)), a.boundingSphere = new t.Sphere(new t.Vector3(), 1e4), a;
505
+ }, []), o = B(() => new t.LineBasicMaterial({ vertexColors: !0, transparent: !0, blending: t.AdditiveBlending, depthWrite: !1, toneMapped: !1 }), []), n = B(() => new Re(xe), []), r = B(() => ({ a: new t.Vector3(), b: new t.Vector3(), c: new t.Vector3(), p: new t.Vector3(), col: new t.Color(), k: new t.Color() }), []);
506
+ return ie(({ clock: a }) => {
507
+ const s = performance.now(), u = fe ? 0 : a.elapsedTime, l = e.getAttribute("position"), h = e.getAttribute("color");
508
+ let m = 0;
509
+ n.begin();
510
+ const x = (S, q, V, w) => {
511
+ if (m >= xe) return;
512
+ const i = de(S), b = H.mcpServers.get(q), P = De(q);
513
+ if (!i || !b || !P) return;
514
+ const { a: E, b: A, c: O, p: Z, col: F, k: G } = r;
515
+ E.copy(i), A.copy(P), Pe(E, A, 1, O), F.set(b.color);
516
+ let j;
517
+ V === 0 ? (F.lerp(qt, oe(w / 1.2)), w > 1.2 && F.lerp(Yt, oe((w - 1.2) / 1)), j = (0.22 + Math.min(0.6, w * 0.25)) * Fe(w / 0.3)) : (G.copy(F).lerp($t, 0.35), j = 1.3 * (w < 0.75 ? 1 : 1 - (w - 0.75) / 0.25));
518
+ const R = 1 - ze(w / 0.75), T = V === 0 ? 0.025 : 0.07;
519
+ for (let I = 0; I < we; I++) {
520
+ const N = (I - 1) * T;
521
+ for (let X = 0; X < pe; X++)
522
+ for (let K = 0; K < 2; K++) {
523
+ const Q = (X + K) / pe;
524
+ ae(E, O, A, Q, Z);
525
+ const D = ((m * we + I) * pe + X) * 2 + K;
526
+ l.setXYZ(D, Z.x + N, Z.y - N, Z.z + N * 0.5);
527
+ let C;
528
+ if (V === 0) {
529
+ const d = Math.pow(Math.max(0, Math.sin(Q * 20 - u * 2.2)), 8);
530
+ C = j * (0.3 + d * 1.5) * (I === 1 ? 1 : 0.25);
531
+ } else
532
+ C = j * (0.3 + Math.exp(-(((Q - R) / 0.07) ** 2)) * 3.2 * (w < 0.8 ? 1 : 0)) * (I === 1 ? 1 : 0.65);
533
+ const W = V === 0 ? F : G;
534
+ h.setXYZ(D, W.r * C, W.g * C, W.b * C);
535
+ }
536
+ }
537
+ V === 0 ? n.add(E, O, A, 0.92, 1, 0.48, F, 0.4 + j * 1.4) : n.add(E, O, A, 0.08, -1, 0.66, G, j * 1.6), m++;
538
+ };
539
+ for (const S of H.mcpPending.values()) x(S.instance, S.server, 0, St(S, s));
540
+ for (const S of H.mcpCalls) S.phase === "result" && x(S.instance, S.server, 1, oe((s - S.start) / S.dur));
541
+ e.setDrawRange(0, m * we * pe * 2), l.needsUpdate = !0, h.needsUpdate = !0, n.end();
542
+ }), /* @__PURE__ */ ne(he, { children: [
543
+ /* @__PURE__ */ f("lineSegments", { geometry: e, material: o, frustumCulled: !1 }),
544
+ /* @__PURE__ */ f("primitive", { object: n.mesh })
545
+ ] });
546
+ }
547
+ function en() {
548
+ const [e, o] = Le([]), n = L({ n: -1, first: -1, last: -1 });
549
+ return ie(() => {
550
+ const r = n.current, a = H.mcpCalls, s = a.length ? a[0].id : -1, u = a.length ? a[a.length - 1].id : -1;
551
+ (a.length !== r.n || s !== r.first || u !== r.last) && (r.n = a.length, r.first = s, r.last = u, o(a.slice()));
552
+ }), /* @__PURE__ */ ne(he, { children: [
553
+ e.map((r) => /* @__PURE__ */ f(Qt, { call: r }, r.id)),
554
+ /* @__PURE__ */ f(Jt, {})
555
+ ] });
556
+ }
557
+ const tn = { tint: "#c084fc", tintAmt: 0.2, gain: 0.9 };
558
+ function un() {
559
+ return /* @__PURE__ */ ne(
560
+ At,
561
+ {
562
+ title: "neural · living brain",
563
+ subtitle: "Agents are neurons (spiky = thinking, smooth = waiting, amber ring = waiting on MCP) · ⬢ MCP servers wire to their backends · graph memory lights up on reads/writes",
564
+ preset: "radial",
565
+ plane: "xy",
566
+ camera: { position: [0, -0.2, 31], fov: 47 },
567
+ bg: "#030208",
568
+ fit: { nRef: 4, min: 0.62, max: 1.6, minRadius: 5.5 },
569
+ agentRadius: 1.25,
570
+ graph: { natural: te * 1.08, radius: 2.1 },
571
+ Background: /* @__PURE__ */ f(Ze, { radius: 80, depth: 40, count: fe ? 1200 : 3500, factor: 2.6, saturation: 0.6, fade: !0, speed: 0.4 }),
572
+ Agent: Ft,
573
+ RunMarker: Ht,
574
+ mcpStyle: tn,
575
+ GraphResource: Dt,
576
+ cluster: { radius: 1.45, variant: "orb" },
577
+ PostFX: /* @__PURE__ */ ne(Qe, { multisampling: 0, children: [
578
+ /* @__PURE__ */ f(Je, { mipmapBlur: !0, intensity: 1.1, luminanceThreshold: 0.2, luminanceSmoothing: 0.3, radius: 0.75 }),
579
+ /* @__PURE__ */ f(et, { eskil: !1, offset: 0.22, darkness: 0.9 })
580
+ ] }),
581
+ children: [
582
+ /* @__PURE__ */ f(jt, {}),
583
+ /* @__PURE__ */ f(en, {})
584
+ ]
585
+ }
586
+ );
587
+ }
588
+ export {
589
+ un as default
590
+ };