agentglow 0.1.0 → 0.2.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.
Files changed (41) hide show
  1. package/README.md +38 -3
  2. package/dist/chunks/KitScene-BuFtYuhc.js +2737 -0
  3. package/dist/chunks/index-BPyTLdiF.js +792 -0
  4. package/dist/chunks/index-Bo5HRf-O.js +784 -0
  5. package/dist/chunks/index-C42Ihyo1.js +605 -0
  6. package/dist/chunks/index-C5YqtHnC.js +677 -0
  7. package/dist/chunks/index-Cyv7bII1.js +818 -0
  8. package/dist/chunks/index-D0UvupqM.js +1143 -0
  9. package/dist/chunks/index-D733n3Hf.js +1086 -0
  10. package/dist/chunks/index-DCmhxN8v.js +1010 -0
  11. package/dist/chunks/index-DO9SAG-u.js +753 -0
  12. package/dist/chunks/index-Dn6oRasS.js +887 -0
  13. package/dist/chunks/index-HyfZ0ePz.js +838 -0
  14. package/dist/chunks/index-XMOz-HBf.js +492 -0
  15. package/dist/chunks/index-ZT88hgW-.js +763 -0
  16. package/dist/chunks/index-e6egU2Q6.js +889 -0
  17. package/dist/chunks/index-jLXx_Wgk.js +68 -0
  18. package/dist/chunks/index-tonipLb2.js +980 -0
  19. package/dist/index.js +1 -1
  20. package/dist/style.css +1 -1
  21. package/dist/types/AgentScene.d.ts +14 -1
  22. package/dist/types/world.d.ts +59 -0
  23. package/package.json +1 -1
  24. package/dist/chunks/ClusterBall-CPsd6JvJ.js +0 -1489
  25. package/dist/chunks/index-0Bqa57T_.js +0 -786
  26. package/dist/chunks/index-4JCQqMml.js +0 -831
  27. package/dist/chunks/index-55W5crSg.js +0 -63
  28. package/dist/chunks/index-78lWZCrQ.js +0 -984
  29. package/dist/chunks/index-Bv6_kdaq.js +0 -768
  30. package/dist/chunks/index-Cgb5ir1r.js +0 -688
  31. package/dist/chunks/index-CqVCWpP7.js +0 -796
  32. package/dist/chunks/index-D1O5v601.js +0 -1065
  33. package/dist/chunks/index-DOoA9htC.js +0 -1181
  34. package/dist/chunks/index-K__sPGRy.js +0 -1134
  35. package/dist/chunks/index-N0zWN8NS.js +0 -857
  36. package/dist/chunks/index-NiYqQci9.js +0 -936
  37. package/dist/chunks/index-PQRnbPiJ.js +0 -565
  38. package/dist/chunks/index-VOXn1m-Q.js +0 -848
  39. package/dist/chunks/index-o4vs5msj.js +0 -837
  40. package/dist/chunks/index-yos7IepY.js +0 -890
  41. package/dist/chunks/spread-CWdeDFd9.js +0 -35
@@ -0,0 +1,1086 @@
1
+ var Rt = Object.defineProperty;
2
+ var Vt = (e, a, t) => a in e ? Rt(e, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[a] = t;
3
+ var me = (e, a, t) => Vt(e, typeof a != "symbol" ? a + "" : a, t);
4
+ import { jsxs as H, Fragment as de, jsx as w } from "react/jsx-runtime";
5
+ import { EffectComposer as _t, Bloom as Ot, Vignette as Et } from "@react-three/postprocessing";
6
+ import { useFrame as fe, useThree as pt } from "@react-three/fiber";
7
+ import { useMemo as R, useRef as F, useState as mt, useEffect as Lt } from "react";
8
+ import * as n from "three";
9
+ import { T as dt, k as ge, h as Ie, w as W, L as Re, d as It, a as We, c as Wt, K as Xt, m as kt, G as Dt, n as Yt, C as Ht, p as Nt, e as Kt, s as jt, q as Ut, f as nt, R as qt, u as $t, o as Zt, j as Jt } from "./KitScene-BuFtYuhc.js";
10
+ var ft;
11
+ const ne = typeof window < "u" && !!((ft = window.matchMedia) != null && ft.call(window, "(prefers-reduced-motion: reduce)").matches), vt = new n.Color("#a855f7"), Ye = new n.Color("#2dd4bf"), ue = new n.Color(1, 1, 1), ht = new n.Color("#fbbf24"), gt = new n.Color("#ff3b5c"), Qt = new n.Color("#3b3346"), Pe = Object.fromEntries(
12
+ Object.entries(dt).map(([e, a]) => {
13
+ const t = new n.Color(a);
14
+ return [e, t.lerp(e === "graph_scout" || e === "writer" ? Ye : vt, 0.18)];
15
+ })
16
+ ), re = (e) => e < 0 ? 0 : e > 1 ? 1 : e, ye = (e) => 1 - Math.pow(1 - re(e), 3), He = (e) => (e = re(e), e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2), eo = (e) => {
17
+ e = re(e);
18
+ const a = 1.9;
19
+ return 1 + (a + 1) * Math.pow(e - 1, 3) + a * Math.pow(e - 1, 2);
20
+ };
21
+ function at(e, a, t) {
22
+ return e.r += a.r * t, e.g += a.g * t, e.b += a.b * t, e;
23
+ }
24
+ let Oe = null;
25
+ function wt() {
26
+ if (Oe) return Oe;
27
+ const e = document.createElement("canvas");
28
+ e.width = e.height = 128;
29
+ const a = e.getContext("2d"), t = a.createRadialGradient(64, 64, 0, 64, 64, 64);
30
+ return t.addColorStop(0, "rgba(255,255,255,1)"), t.addColorStop(0.18, "rgba(255,255,255,0.55)"), t.addColorStop(0.5, "rgba(255,255,255,0.12)"), t.addColorStop(1, "rgba(255,255,255,0)"), a.fillStyle = t, a.fillRect(0, 0, 128, 128), Oe = new n.CanvasTexture(e), Oe;
31
+ }
32
+ function Fe(e = "#fff") {
33
+ return new n.SpriteMaterial({ map: wt(), color: e, blending: n.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 });
34
+ }
35
+ function et(e = "#fff") {
36
+ return new n.MeshBasicMaterial({ map: wt(), color: e, blending: n.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 });
37
+ }
38
+ function Xe(e = "#fff") {
39
+ return new n.MeshBasicMaterial({ color: e, blending: n.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 });
40
+ }
41
+ const tt = new n.PlaneGeometry(1, 1).rotateX(-Math.PI / 2);
42
+ new n.SphereGeometry(1, 24, 16);
43
+ const yt = new n.ConeGeometry(1, 1, 12).translate(0, 0.5, 0), bt = new n.RingGeometry(0.86, 1, 64, 1).rotateX(-Math.PI / 2), rt = new n.LatheGeometry(
44
+ [
45
+ [0.86, -0.07],
46
+ [0.97, -0.02],
47
+ [1, 0.06],
48
+ [0.96, 0.18],
49
+ [0.86, 0.31],
50
+ [0.7, 0.43],
51
+ [0.5, 0.51],
52
+ [0.27, 0.555],
53
+ [0, 0.57]
54
+ ].map(([e, a]) => new n.Vector2(e, a)),
55
+ 48
56
+ ), to = new n.RingGeometry(0.1, 0.9, 64, 3).rotateX(Math.PI / 2).translate(0, -0.035, 0), st = new n.LatheGeometry(
57
+ [
58
+ [0, 0],
59
+ [0.26, 0],
60
+ [0.19, 0.05],
61
+ [0.14, 0.18],
62
+ [0.115, 0.45],
63
+ [0.1, 0.75],
64
+ [0.095, 1],
65
+ [0, 1]
66
+ ].map(([e, a]) => new n.Vector2(e, a)),
67
+ 20
68
+ );
69
+ function oo(e = 72, a = 6) {
70
+ const t = [], o = [];
71
+ for (let r = 0; r <= e; r++) {
72
+ const u = r / e;
73
+ for (let m = 0; m < a; m++) {
74
+ const f = m / a * Math.PI * 2;
75
+ t.push(u, Math.cos(f), Math.sin(f));
76
+ }
77
+ }
78
+ for (let r = 0; r < e; r++)
79
+ for (let u = 0; u < a; u++) {
80
+ const m = r * a + u, f = r * a + (u + 1) % a, g = (r + 1) * a + u, v = (r + 1) * a + (u + 1) % a;
81
+ o.push(m, g, f, f, g, v);
82
+ }
83
+ const s = new n.BufferGeometry();
84
+ return s.setAttribute("position", new n.Float32BufferAttribute(t, 3)), s.setIndex(o), s.boundingSphere = new n.Sphere(new n.Vector3(), 1e4), s;
85
+ }
86
+ const Ne = oo(), no = (
87
+ /* glsl */
88
+ `
89
+ uniform vec3 uP0; uniform vec3 uP1; uniform vec3 uP2; uniform float uWob; uniform float uSeed;
90
+ vec3 hyphaAt(float t){
91
+ float a = 1.0 - t;
92
+ vec3 p = a*a*uP0 + 2.0*a*t*uP1 + t*t*uP2;
93
+ vec3 tg = 2.0*a*(uP1-uP0) + 2.0*t*(uP2-uP1);
94
+ vec3 side = normalize(vec3(-tg.z, 0.0, tg.x) + vec3(1e-5));
95
+ float w = sin(t * 9.0 + uSeed * 6.283) * 0.6 + sin(t * 17.0 + uSeed * 3.1) * 0.4;
96
+ return p + side * w * uWob * sin(3.14159 * t);
97
+ }`
98
+ ), je = new n.Vector3();
99
+ function Ge(e, a, t, o, s, r, u) {
100
+ const m = 1 - r;
101
+ if (u.set(m * m * e.x + 2 * m * r * a.x + r * r * t.x, m * m * e.y + 2 * m * r * a.y + r * r * t.y, m * m * e.z + 2 * m * r * a.z + r * r * t.z), o === 0) return u;
102
+ je.set(2 * m * (a.x - e.x) + 2 * r * (t.x - a.x), 0, 2 * m * (a.z - e.z) + 2 * r * (t.z - a.z));
103
+ const f = -je.z + 1e-5, g = je.x + 1e-5, v = Math.hypot(f, 1e-5, g) || 1, i = (Math.sin(r * 9 + s * 6.283) * 0.6 + Math.sin(r * 17 + s * 3.1) * 0.4) * o * Math.sin(Math.PI * r);
104
+ return u.x += f / v * i, u.z += g / v * i, u;
105
+ }
106
+ const ao = (
107
+ /* glsl */
108
+ `
109
+ uniform float uRadius; uniform float uTaper;
110
+ varying float vT; varying float vRim;
111
+ ${no}
112
+ void main(){
113
+ float t = position.x;
114
+ vec3 p = hyphaAt(t);
115
+ vec3 tg = hyphaAt(min(1.0, t + 0.01)) - hyphaAt(max(0.0, t - 0.01));
116
+ tg = length(tg) > 1e-6 ? normalize(tg) : vec3(1.0, 0.0, 0.0);
117
+ vec3 up = abs(tg.y) > 0.92 ? vec3(1.0, 0.0, 0.0) : vec3(0.0, 1.0, 0.0);
118
+ vec3 n = normalize(cross(tg, up)); vec3 b = cross(tg, n);
119
+ vec3 off = n * position.y + b * position.z;
120
+ float r = uRadius * mix(1.0, uTaper, t) * (0.85 + 0.15 * sin(t * 40.0 + uSeed * 9.0));
121
+ vec4 mv = modelViewMatrix * vec4(p + off * r, 1.0);
122
+ vRim = abs(dot(normalize(normalMatrix * off), normalize(-mv.xyz)));
123
+ vT = t;
124
+ gl_Position = projectionMatrix * mv;
125
+ }`
126
+ ), ro = (
127
+ /* glsl */
128
+ `
129
+ uniform vec3 uColor; uniform float uOpacity; uniform float uGrow; uniform float uStart; uniform float uTime;
130
+ uniform float uFlow; uniform float uFlowDir; uniform float uBeads; uniform float uSpeed;
131
+ uniform float uHead; uniform float uTail; uniform vec3 uHeadColor;
132
+ varying float vT; varying float vRim;
133
+ void main(){
134
+ if (vT > uGrow || vT < uStart) discard;
135
+ float core = 0.3 + 0.7 * vRim * vRim;
136
+ float tip = smoothstep(uGrow - 0.06, uGrow, vT) * step(uGrow, 0.995);
137
+ // nutrient beads travelling along the hypha (uFlowDir +1: start → end)
138
+ float ph = vT * uBeads - uTime * uSpeed * uFlowDir;
139
+ float beads = uFlow * pow(max(0.0, sin(ph * 3.14159)), 22.0);
140
+ float head = 0.0;
141
+ if (uHead >= 0.0) {
142
+ float d = vT - uHead;
143
+ head = d > 0.0 ? exp(-d * d / 0.0008) : exp(d / max(uTail, 0.001));
144
+ }
145
+ float endFade = smoothstep(0.0, 0.03, vT - uStart);
146
+ vec3 col = uColor * uOpacity * endFade * (core + tip * 3.0 + beads * 3.2) + uHeadColor * head * (0.5 + vRim);
147
+ gl_FragColor = vec4(col, 1.0);
148
+ }`
149
+ );
150
+ function Ke(e = "#fff", a = 0.06, t = 0.45, o = 0, s = 0.25) {
151
+ return new n.ShaderMaterial({
152
+ uniforms: {
153
+ uP0: { value: new n.Vector3() },
154
+ uP1: { value: new n.Vector3() },
155
+ uP2: { value: new n.Vector3() },
156
+ uWob: { value: s },
157
+ uSeed: { value: o },
158
+ uRadius: { value: a },
159
+ uTaper: { value: t },
160
+ uColor: { value: new n.Color(e) },
161
+ uOpacity: { value: 1 },
162
+ uGrow: { value: 1 },
163
+ uStart: { value: 0 },
164
+ uTime: { value: 0 },
165
+ uFlow: { value: 0 },
166
+ uFlowDir: { value: 1 },
167
+ uBeads: { value: 6 },
168
+ uSpeed: { value: 1.1 },
169
+ uHead: { value: -1 },
170
+ uTail: { value: 0.12 },
171
+ uHeadColor: { value: new n.Color(3, 3, 3) }
172
+ },
173
+ vertexShader: ao,
174
+ fragmentShader: ro,
175
+ transparent: !0,
176
+ depthWrite: !1,
177
+ blending: n.AdditiveBlending
178
+ });
179
+ }
180
+ function so() {
181
+ return new n.ShaderMaterial({
182
+ uniforms: {
183
+ uColor: { value: new n.Color() },
184
+ uGlow: { value: 0.5 },
185
+ uOpacity: { value: 1 },
186
+ uSpots: { value: 0 }
187
+ },
188
+ vertexShader: (
189
+ /* glsl */
190
+ `
191
+ varying vec3 vN; varying vec3 vV; varying vec3 vP;
192
+ void main(){
193
+ vec4 mv = modelViewMatrix * vec4(position, 1.0);
194
+ vN = normalize(normalMatrix * normal); vV = normalize(-mv.xyz); vP = position;
195
+ gl_Position = projectionMatrix * mv;
196
+ }`
197
+ ),
198
+ fragmentShader: (
199
+ /* glsl */
200
+ `
201
+ uniform vec3 uColor; uniform float uGlow; uniform float uOpacity; uniform float uSpots;
202
+ varying vec3 vN; varying vec3 vV; varying vec3 vP;
203
+ void main(){
204
+ float f = 1.0 - abs(dot(normalize(vN), normalize(vV)));
205
+ float rim = pow(f, 2.2);
206
+ float h = clamp(vP.y / 0.57, 0.0, 1.0);
207
+ float ang = atan(vP.z, vP.x);
208
+ float ribs = 0.88 + 0.12 * sin(ang * 26.0);
209
+ float lip = smoothstep(0.25, 0.0, h); // the rim edge glows strongest
210
+ // soft round spots on the crown (seeded by uSpots)
211
+ vec2 q = vec2(ang * 2.2 + uSpots * 7.0, h * 5.0);
212
+ vec2 cell = fract(q) - 0.5;
213
+ float spots = smoothstep(0.22, 0.08, length(cell)) * step(0.35, h) * step(0.5, fract(sin(dot(floor(q), vec2(12.9898, 78.233)) + uSpots) * 43758.5453));
214
+ vec3 body = uColor * (0.12 + 0.22 * (1.0 - h)) * ribs;
215
+ vec3 col = body + uColor * (rim * 1.3 + lip * 0.9) * uGlow + vec3(0.85, 0.95, 1.0) * spots * 0.35 * uGlow;
216
+ gl_FragColor = vec4(col, uOpacity * (0.82 + 0.18 * rim));
217
+ }`
218
+ ),
219
+ transparent: !0
220
+ });
221
+ }
222
+ function io() {
223
+ return new n.ShaderMaterial({
224
+ uniforms: { uColor: { value: new n.Color() }, uGlow: { value: 0.5 }, uTime: { value: 0 } },
225
+ vertexShader: (
226
+ /* glsl */
227
+ `
228
+ varying vec3 vP;
229
+ void main(){ vP = position; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }`
230
+ ),
231
+ fragmentShader: (
232
+ /* glsl */
233
+ `
234
+ uniform vec3 uColor; uniform float uGlow; uniform float uTime;
235
+ varying vec3 vP;
236
+ void main(){
237
+ float r = length(vP.xz);
238
+ float a = atan(vP.z, vP.x);
239
+ float lam = pow(abs(sin(a * 34.0)), 6.0);
240
+ float wave = 0.75 + 0.25 * sin(r * 14.0 - uTime * 3.0);
241
+ float fall = smoothstep(0.9, 0.55, r) * smoothstep(0.08, 0.2, r);
242
+ gl_FragColor = vec4(uColor * uGlow * (0.25 + lam * 1.4) * wave * fall, 1.0);
243
+ }`
244
+ ),
245
+ transparent: !0,
246
+ depthWrite: !1,
247
+ side: n.DoubleSide,
248
+ blending: n.AdditiveBlending
249
+ });
250
+ }
251
+ function lo() {
252
+ return new n.ShaderMaterial({
253
+ uniforms: { uColor: { value: new n.Color() }, uGlow: { value: 0.5 }, uOpacity: { value: 1 }, uBend: { value: 0 } },
254
+ vertexShader: (
255
+ /* glsl */
256
+ `
257
+ uniform float uBend;
258
+ varying vec3 vN; varying vec3 vV; varying float vY;
259
+ void main(){
260
+ vec3 p = position;
261
+ p.x += uBend * p.y * p.y;
262
+ vec4 mv = modelViewMatrix * vec4(p, 1.0);
263
+ vN = normalize(normalMatrix * normal); vV = normalize(-mv.xyz); vY = position.y;
264
+ gl_Position = projectionMatrix * mv;
265
+ }`
266
+ ),
267
+ fragmentShader: (
268
+ /* glsl */
269
+ `
270
+ uniform vec3 uColor; uniform float uGlow; uniform float uOpacity;
271
+ varying vec3 vN; varying vec3 vV; varying float vY;
272
+ void main(){
273
+ float f = 1.0 - abs(dot(normalize(vN), normalize(vV)));
274
+ vec3 pale = mix(uColor, vec3(0.92, 0.9, 1.0), 0.45);
275
+ float fibre = 0.9 + 0.1 * sin(vY * 60.0);
276
+ vec3 col = pale * (0.1 + 0.3 * vY + pow(f, 2.0) * 0.9) * uGlow * fibre;
277
+ gl_FragColor = vec4(col, uOpacity);
278
+ }`
279
+ ),
280
+ transparent: !0
281
+ });
282
+ }
283
+ const he = 3.8, Mt = 1.75, St = new n.Vector3();
284
+ function xt(e, a = St) {
285
+ const t = ge.agents.get(e);
286
+ if (t)
287
+ return a.copy(t.live), a.y += (Mt + 0.12) * t.scale, Ue.p = a, Ue.r = t.scale, Ue;
288
+ }
289
+ const Ue = { p: St, r: 0 }, De = class De {
290
+ constructor(a) {
291
+ me(this, "mesh");
292
+ me(this, "colors");
293
+ me(this, "n", 0);
294
+ me(this, "max");
295
+ me(this, "o", new n.Object3D());
296
+ me(this, "a", new n.Vector3());
297
+ me(this, "b", new n.Vector3());
298
+ this.max = a, this.colors = new Float32Array(a * 3), this.mesh = new n.InstancedMesh(yt, new n.MeshBasicMaterial({ blending: n.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 }), a), this.mesh.instanceColor = new n.InstancedBufferAttribute(this.colors, 3), this.mesh.frustumCulled = !1, this.mesh.count = 0;
299
+ }
300
+ begin() {
301
+ this.n = 0;
302
+ }
303
+ /** Arrow at curve parameter t, pointing toward the end (dir=+1) or the start (dir=-1). */
304
+ add(a, t, o, s, r, u, m, f, g, v = 1) {
305
+ this.n >= this.max || v <= 0.01 || (Ge(a, t, o, s, r, u, this.a), Ge(a, t, o, s, r, Math.min(1, Math.max(0, u + 0.025 * m)), this.b), this.b.sub(this.a), !(this.b.lengthSq() < 1e-8) && (this.o.position.copy(this.a), this.o.quaternion.setFromUnitVectors(De.UP, this.b.normalize()), this.o.scale.set(f * 0.42, f, f * 0.42), this.o.updateMatrix(), this.mesh.setMatrixAt(this.n, this.o.matrix), this.colors[this.n * 3] = g.r * v, this.colors[this.n * 3 + 1] = g.g * v, this.colors[this.n * 3 + 2] = g.b * v, this.n++));
306
+ }
307
+ end() {
308
+ this.mesh.count = this.n, this.mesh.instanceMatrix.needsUpdate = !0, this.mesh.instanceColor && (this.mesh.instanceColor.needsUpdate = !0);
309
+ }
310
+ };
311
+ me(De, "UP", new n.Vector3(0, 1, 0));
312
+ let ke = De;
313
+ function At() {
314
+ return new n.ShaderMaterial({
315
+ uniforms: { uScale: { value: 400 } },
316
+ vertexShader: (
317
+ /* glsl */
318
+ `
319
+ attribute float aSize; attribute vec3 aColor; varying vec3 vC; uniform float uScale;
320
+ void main(){
321
+ vec4 mv = modelViewMatrix * vec4(position, 1.0);
322
+ gl_PointSize = aSize * uScale / -mv.z; vC = aColor; gl_Position = projectionMatrix * mv;
323
+ }`
324
+ ),
325
+ fragmentShader: (
326
+ /* glsl */
327
+ `
328
+ varying vec3 vC;
329
+ void main(){
330
+ float r = length(gl_PointCoord - 0.5) * 2.0; if (r > 1.0) discard;
331
+ float core = smoothstep(0.42, 0.0, r); float halo = pow(1.0 - r, 2.4);
332
+ gl_FragColor = vec4(vC * (core * 1.25 + halo * 0.5), 1.0);
333
+ }`
334
+ ),
335
+ transparent: !0,
336
+ depthWrite: !1,
337
+ blending: n.AdditiveBlending
338
+ });
339
+ }
340
+ function Pt(e, a, t) {
341
+ return e * a / (2 * Math.tan(t * Math.PI / 360));
342
+ }
343
+ const Ct = 0.9, it = 0.7, be = new ke(64);
344
+ function co(e, a) {
345
+ const t = new n.IcosahedronGeometry(e, 3), o = t.getAttribute("position"), s = new n.Vector3();
346
+ for (let r = 0; r < o.count; r++) {
347
+ s.fromBufferAttribute(o, r);
348
+ const u = s.clone().normalize(), m = 1 + 0.13 * Math.sin(u.x * 5 + a) * Math.cos(u.y * 4 + a * 2) + 0.07 * Math.sin(u.z * 9 + a * 3);
349
+ s.multiplyScalar(m), o.setXYZ(r, s.x, s.y * 0.85, s.z);
350
+ }
351
+ return t.computeVertexNormals(), t;
352
+ }
353
+ const uo = co(0.85, 1.7);
354
+ function fo(e) {
355
+ return new n.ShaderMaterial({
356
+ uniforms: { uColor: { value: e.clone() }, uK: { value: 1 } },
357
+ vertexShader: (
358
+ /* glsl */
359
+ `varying vec3 vN; varying vec3 vV; varying vec3 vP;
360
+ void main(){ vec4 mv = modelViewMatrix * vec4(position, 1.0); vN = normalize(normalMatrix * normal); vV = normalize(-mv.xyz); vP = position;
361
+ gl_Position = projectionMatrix * mv; }`
362
+ ),
363
+ fragmentShader: (
364
+ /* glsl */
365
+ `uniform vec3 uColor; uniform float uK; varying vec3 vN; varying vec3 vV; varying vec3 vP;
366
+ void main(){ float f = 1.0 - abs(dot(normalize(vN), normalize(vV)));
367
+ float veins = 0.7 + 0.3 * sin(vP.x * 11.0 + sin(vP.y * 7.0) * 2.0) * sin(vP.z * 9.0);
368
+ gl_FragColor = vec4(uColor * uK * (0.12 + pow(f, 2.0) * 1.5) * veins, 1.0); }`
369
+ ),
370
+ transparent: !0,
371
+ depthWrite: !1,
372
+ blending: n.AdditiveBlending
373
+ });
374
+ }
375
+ const lt = /* @__PURE__ */ new Map();
376
+ function po(e) {
377
+ const a = lt.get(e);
378
+ if (a) return a;
379
+ const t = (s, r, u) => ({ geo: s, edges: new n.EdgesGeometry(s, 25), pos: r, rot: u });
380
+ let o;
381
+ switch (e) {
382
+ case "db":
383
+ o = [t(new n.CylinderGeometry(0.42, 0.42, 0.75, 28)), t(new n.TorusGeometry(0.42, 0.015, 6, 40), [0, 0.13, 0], [Math.PI / 2, 0, 0]), t(new n.TorusGeometry(0.42, 0.015, 6, 40), [0, -0.13, 0], [Math.PI / 2, 0, 0])];
384
+ break;
385
+ case "warehouse":
386
+ o = [-0.3, 0, 0.3].map((s) => t(new n.BoxGeometry(0.95, 0.2, 0.6), [0, s, 0]));
387
+ break;
388
+ case "spark": {
389
+ o = [{ geo: new n.SphereGeometry(0.18, 16, 12) }];
390
+ for (let s = 0; s < 6; s++) {
391
+ const r = s / 6 * Math.PI * 2;
392
+ o.push({ geo: new n.SphereGeometry(0.1, 12, 10), pos: [Math.cos(r) * 0.46, Math.sin(r) * 0.46, (s % 2 ? 1 : -1) * 0.12] });
393
+ }
394
+ break;
395
+ }
396
+ case "api":
397
+ o = [t(new n.TorusGeometry(0.4, 0.1, 10, 36))];
398
+ break;
399
+ case "storage":
400
+ o = [t(new n.BoxGeometry(0.7, 0.7, 0.7), void 0, [0.4, 0.6, 0])];
401
+ break;
402
+ case "queue":
403
+ o = [t(new n.CapsuleGeometry(0.2, 0.75, 6, 16), void 0, [0, 0, Math.PI / 2])];
404
+ break;
405
+ }
406
+ return lt.set(e, o), o;
407
+ }
408
+ function zt(e, a) {
409
+ let t = null;
410
+ for (const o of W.mcpCalls) o.server === e && (a === void 0 || o.resource === a) && (!t || o.start > t.start) && (t = o);
411
+ return t;
412
+ }
413
+ function Gt(e, a, t, o, s, r, u) {
414
+ if (e.uTime.value = r, t < 1) {
415
+ const m = He(t);
416
+ e.uFlow.value = 0, e.uHead.value = 1 - m, e.uTail.value = 0.18, e.uHeadColor.value.copy(s).lerp(ue, 0.4).multiplyScalar(3), e.uOpacity.value = 0.9 * (1 - t * 0.5);
417
+ } else a ? (e.uFlow.value = 1, e.uFlowDir.value = 1, e.uHead.value = -1, e.uOpacity.value = 0.6) : (e.uFlow.value = o * 0.6, e.uFlowDir.value = 1, e.uHead.value = -1, e.uOpacity.value = u + o * 0.4);
418
+ }
419
+ function mo({ mcp: e, backend: a }) {
420
+ const t = e.srv, o = a.res, s = R(() => po(o.kind), [o.kind]), r = R(() => new n.Color(t.color).lerp(Ye, 0.2).lerp(ue, 0.25), [t.color]), u = R(() => Ie(`${t.name}:${o.name}`, 3), [t.name, o.name]), m = R(() => {
421
+ const h = Ke(t.color, 0.1, 0.55, u, 0.3);
422
+ return h.uniforms.uBeads.value = 4, { edge: h, fill: Xe(r), line: new n.LineBasicMaterial({ color: r, transparent: !0, blending: n.AdditiveBlending, depthWrite: !1, toneMapped: !1 }), halo: Fe(r) };
423
+ }, [t.color, r, u]), f = F(null), g = F(null), v = F(null), i = F(null), y = F("");
424
+ return fe(({ clock: h }) => {
425
+ var _, V;
426
+ const c = m.edge.uniforms;
427
+ c.uP0.value.copy(e.pos).setY(Ct), c.uP2.value.copy(a.pos).setY(it), c.uP1.value.copy(c.uP0.value).add(c.uP2.value).multiplyScalar(0.5).setY(0.2), (_ = f.current) == null || _.position.set(a.pos.x, it, a.pos.z);
428
+ const p = performance.now(), l = ne ? 0 : h.elapsedTime, b = o.inflight > 0, M = Math.exp(-((p - o.activeAt) / 1e3) * 1.5), d = b ? 0.5 + 0.5 * Math.sin(h.elapsedTime * 5) : 0, S = b ? 1.6 + d * 0.9 : 0.14 + M * 0.9;
429
+ m.fill.color.copy(r).multiplyScalar(S * 0.5), m.line.color.copy(r).multiplyScalar(S * 1.5), m.halo.color.copy(r).multiplyScalar(b ? 0.4 + d * 0.2 : 0.03 + M * 0.25), (V = v.current) == null || V.scale.setScalar(b ? 4 + d * 0.8 : 2.4 + M * 1.2), g.current && (g.current.scale.setScalar(b ? 1.18 + d * 0.08 : 1 + M * 0.1), g.current.rotation.y = o.kind === "spark" || o.kind === "api" ? l * (b ? 0.6 : 0.15) : Math.sin(l * 0.2 + u) * 0.3);
430
+ const C = zt(t.name, o.name), ee = C && C.phase === "result" ? (p - C.start) / C.dur : 9;
431
+ Gt(m.edge.uniforms, b, ee, M, r, l, 0.22);
432
+ const O = m.edge.uniforms;
433
+ ee < 1 ? be.add(O.uP0.value, O.uP1.value, O.uP2.value, O.uWob.value, u, 0.1, -1, 0.5, r, 2 * (1 - ee * 0.7)) : b && be.add(O.uP0.value, O.uP1.value, O.uP2.value, O.uWob.value, u, 0.86, 1, 0.42, r, 1.2);
434
+ let j = o.name;
435
+ if (b) {
436
+ let L = "";
437
+ for (const E of W.mcpPending.values()) E.server === t.name && E.resource === o.name && (L = E.tool);
438
+ j = `${o.name} ▶ ${L || "query"}()`;
439
+ } else C && C.phase === "result" && p - C.start < 1800 && (j = `${o.name} ✓ returned`);
440
+ i.current && (j !== y.current && (i.current.setText(j), y.current = j), i.current.setOpacity(b ? 1 : 0.6 + M * 0.4), i.current.setEmphasis(b));
441
+ }), /* @__PURE__ */ H(de, { children: [
442
+ /* @__PURE__ */ w("mesh", { geometry: Ne, material: m.edge, frustumCulled: !1 }),
443
+ /* @__PURE__ */ H("group", { ref: f, children: [
444
+ /* @__PURE__ */ w("sprite", { ref: v, material: m.halo }),
445
+ /* @__PURE__ */ w("group", { ref: g, children: s.map((h, c) => /* @__PURE__ */ H("group", { position: h.pos, rotation: h.rot, children: [
446
+ /* @__PURE__ */ w("mesh", { geometry: h.geo, material: m.fill }),
447
+ h.edges && /* @__PURE__ */ w("lineSegments", { geometry: h.edges, material: m.line })
448
+ ] }, c)) }),
449
+ /* @__PURE__ */ w(Re, { ref: i, position: [0, -0.95, 0], text: o.name, color: t.color, size: 0.2, opacity: 0.6, pxRange: [7.5, 11.5] })
450
+ ] })
451
+ ] });
452
+ }
453
+ const Te = new n.Vector3();
454
+ function vo({ mcp: e }) {
455
+ const a = e.srv, t = R(() => new n.Color(a.color).lerp(Ye, 0.15), [a.color]), o = R(() => Ie(a.name, 5), [a.name]), s = R(() => {
456
+ const g = Ke(t, 0.17, 0.5, o, 0.6);
457
+ return g.uniforms.uBeads.value = 9, g.uniforms.uSpeed.value = 0.8, { body: fo(t), core: Fe(t), halo: Fe(t), trunk: g };
458
+ }, [t, o]), r = F(null), u = F(null), m = F(null), f = F(performance.now());
459
+ return fe(({ clock: g }) => {
460
+ var C, ee;
461
+ const v = e.pos;
462
+ (C = r.current) == null || C.position.set(v.x, Ct, v.z);
463
+ const i = s.trunk.uniforms;
464
+ Te.set(v.x, 0, v.z);
465
+ const y = Te.length();
466
+ y > 1e-3 && Te.multiplyScalar(1 / y);
467
+ const h = Math.max(0, Math.min(y - 2.5, ge.core.r * 0.8));
468
+ i.uP0.value.set(Te.x * h, 0.08, Te.z * h), i.uP2.value.set(v.x, 0.15, v.z), i.uP1.value.copy(i.uP0.value).add(i.uP2.value).multiplyScalar(0.5).setY(0.1), i.uBeads.value = Math.max(4, (y - h) / 1.2);
469
+ const c = performance.now(), p = ne ? 0 : g.elapsedTime, l = a.inflight > 0, b = Math.exp(-((c - a.activeAt) / 1e3) * 1.5), M = 0.5 + 0.5 * Math.sin(g.elapsedTime * (l ? 4 : 1.2) + o * 5);
470
+ s.body.uniforms.uK.value = (l ? 1.1 + M * 0.4 : 0.5 + M * 0.1) + b * 0.5, s.core.color.copy(t).lerp(ue, 0.4).multiplyScalar((l ? 0.55 : 0.18) + b * 0.3), s.halo.color.copy(t).multiplyScalar((l ? 0.22 : 0.07) + b * 0.12), (ee = m.current) == null || ee.scale.setScalar(5.2 + (l ? M * 0.8 : 0)), u.current && (u.current.rotation.y = p * (l ? 0.5 : 0.1), u.current.scale.setScalar(ye((c - f.current) / 1200) * (1 + (l ? M * 0.06 : 0))));
471
+ const d = zt(a.name), S = d && d.phase === "result" ? (c - d.start) / d.dur : 9;
472
+ Gt(i, l, 9, b, t, p, 0.3), i.uGrow.value = ye((c - f.current) / 2e3), S < 1 && (i.uOpacity.value = 0.5 + (1 - S) * 0.4);
473
+ }), /* @__PURE__ */ H(de, { children: [
474
+ /* @__PURE__ */ w("mesh", { geometry: Ne, material: s.trunk, frustumCulled: !1 }),
475
+ /* @__PURE__ */ H("group", { ref: r, children: [
476
+ /* @__PURE__ */ w("sprite", { ref: m, material: s.halo }),
477
+ /* @__PURE__ */ H("group", { ref: u, children: [
478
+ /* @__PURE__ */ w("mesh", { geometry: uo, material: s.body }),
479
+ /* @__PURE__ */ w("sprite", { material: s.core, scale: 1.6 })
480
+ ] }),
481
+ /* @__PURE__ */ w(Re, { position: [0, 1.55, 0], text: `MCP · ${a.name}`, color: a.color, size: 0.28, pxRange: [9, 13] })
482
+ ] })
483
+ ] });
484
+ }
485
+ const qe = 20;
486
+ function ho() {
487
+ const e = F([]), a = R(() => Array.from({ length: qe }, (o, s) => Ke("#fff", 0.07, 0.6, s * 0.173, 0.45)), []), t = R(() => ({ col: new n.Color(), sp: new n.Vector3() }), []);
488
+ return fe(({ clock: o }) => {
489
+ const s = performance.now(), r = ne ? 0 : o.elapsedTime;
490
+ let u = 0;
491
+ const m = (f, g, v, i) => {
492
+ if (u >= qe) return;
493
+ const y = We(f), h = W.mcpServers.get(g), c = Wt(g), p = e.current[u];
494
+ if (!y || !h || !c || !p) return;
495
+ const l = a[u].uniforms;
496
+ t.sp.copy(c), l.uP0.value.copy(y).setY(0.06), l.uP2.value.copy(t.sp).setY(0.35), l.uP1.value.copy(l.uP0.value).add(l.uP2.value).multiplyScalar(0.5), l.uP1.value.y = 0.9;
497
+ const b = l.uP0.value.distanceTo(l.uP2.value);
498
+ l.uBeads.value = b / 1.3, l.uTime.value = r, t.col.set(h.color), v === 0 ? (t.col.lerp(ht, re(i / 1.2)), i > 1.2 && t.col.lerp(gt, re((i - 1.2) / 1.2)), l.uColor.value.copy(t.col), l.uGrow.value = ye(i / 0.45), l.uHead.value = i < 0.45 ? l.uGrow.value : -1, l.uHeadColor.value.copy(t.col).multiplyScalar(2.5), l.uFlow.value = 1, l.uFlowDir.value = 1, l.uSpeed.value = 1.6, l.uOpacity.value = 0.45 + Math.min(0.4, i * 0.15), be.add(l.uP0.value, l.uP1.value, l.uP2.value, l.uWob.value, l.uSeed.value, 0.9, 1, 0.42, t.col, 0.5 + Math.min(1, i * 0.5))) : (t.col.lerp(ue, 0.3), l.uColor.value.copy(t.col), l.uGrow.value = 1, l.uFlow.value = 0, l.uHead.value = 1 - He(i / 0.8), l.uTail.value = 0.2, l.uHeadColor.value.copy(t.col).multiplyScalar(3.2), l.uOpacity.value = 0.7 * (1 - i), be.add(l.uP0.value, l.uP1.value, l.uP2.value, l.uWob.value, l.uSeed.value, 0.08, -1, 0.55, t.col, 1.8 * (1 - i))), p.visible = !0, u++;
499
+ };
500
+ for (const f of W.mcpPending.values()) m(f.instance, f.server, 0, It(f, s));
501
+ for (const f of W.mcpCalls) f.phase === "result" && m(f.instance, f.server, 1, re((s - f.start) / f.dur));
502
+ for (let f = u; f < qe; f++) {
503
+ const g = e.current[f];
504
+ g && (g.visible = !1);
505
+ }
506
+ }), /* @__PURE__ */ w(de, { children: a.map((o, s) => /* @__PURE__ */ w("mesh", { ref: (r) => void (e.current[s] = r), geometry: Ne, material: o, frustumCulled: !1, visible: !1 }, s)) });
507
+ }
508
+ function go() {
509
+ return /* @__PURE__ */ H(de, { children: [
510
+ /* @__PURE__ */ w(ho, {}),
511
+ /* @__PURE__ */ w(wo, {}),
512
+ /* @__PURE__ */ w("primitive", { object: be.mesh })
513
+ ] });
514
+ }
515
+ function wo() {
516
+ return fe(() => {
517
+ be.end(), be.begin();
518
+ }, 0.5), null;
519
+ }
520
+ const Ce = 36, yo = (
521
+ /* glsl */
522
+ `
523
+ uniform float uTime;
524
+ varying vec2 vXZ;
525
+ float h(vec2 p){ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
526
+ float n2(vec2 p){ vec2 i = floor(p), f = fract(p); f = f*f*(3.0-2.0*f);
527
+ return mix(mix(h(i), h(i+vec2(1,0)), f.x), mix(h(i+vec2(0,1)), h(i+vec2(1,1)), f.x), f.y); }
528
+ float fbm(vec2 p){ float s = 0.0, a = 0.5; for (int i = 0; i < 5; i++){ s += a * n2(p); p *= 2.03; a *= 0.5; } return s; }
529
+ void main(){
530
+ float r = length(vXZ);
531
+ float m = fbm(vXZ * 0.22) * 0.6 + fbm(vXZ * 0.9 + 7.0) * 0.4; // static mottling (leaf litter / soil)
532
+ vec3 soil = mix(vec3(0.010, 0.008, 0.020), vec3(0.030, 0.020, 0.050), m);
533
+ vec3 col = soil;
534
+ col += vec3(0.20, 0.08, 0.36) * exp(-r * r / 60.0) * 0.32; // violet heart under the mat
535
+ col += vec3(0.03, 0.16, 0.16) * exp(-pow((r - 15.0) / 7.0, 2.0)) * 0.10; // teal haze toward the edge
536
+ float edge = smoothstep(${Ce.toFixed(1)}, ${(Ce * 0.55).toFixed(1)}, r);
537
+ gl_FragColor = vec4(col, edge);
538
+ }`
539
+ );
540
+ function bo(e = 110, a = 9e3) {
541
+ let t = 1337;
542
+ const o = () => (t = t * 16807 % 2147483647) / 2147483647, s = [], r = [], u = [], m = [], f = [];
543
+ for (let i = 0; i < e; i++) {
544
+ const y = i / e * Math.PI * 2 + o() * 0.2, h = he * (0.7 + o() * 0.3);
545
+ f.push({ x: Math.cos(y) * h, z: Math.sin(y) * h, h: y + (o() - 0.5) * 0.6, d: h, w: 1, sd: o(), life: 40 + o() * 60 });
546
+ }
547
+ let g = 0;
548
+ for (; f.length && g < a; ) {
549
+ const i = f.shift();
550
+ for (let y = 0; y < i.life && g < a; y++) {
551
+ const h = 0.32 + o() * 0.18, c = Math.atan2(i.z, i.x);
552
+ let p = i.h - c;
553
+ p = Math.atan2(Math.sin(p), Math.cos(p)), i.h += (o() - 0.5) * 0.55 - p * 0.05;
554
+ const l = i.x + Math.cos(i.h) * h, b = i.z + Math.sin(i.h) * h, M = i.d + h;
555
+ if (s.push(i.x, 0.02, i.z, l, 0.02, b), r.push(i.d, M), u.push(i.sd, i.sd), m.push(i.w, i.w), g++, i.x = l, i.z = b, i.d = M, Math.hypot(l, b) > Ce * 0.8) break;
556
+ o() < 0.055 && i.w > 0.3 && f.push({ x: l, z: b, h: i.h + (o() < 0.5 ? 1 : -1) * (0.5 + o() * 0.6), d: M, w: i.w * 0.72, sd: o(), life: (i.life - y) * (0.5 + o() * 0.5) });
557
+ }
558
+ }
559
+ const v = new n.BufferGeometry();
560
+ return v.setAttribute("position", new n.Float32BufferAttribute(s, 3)), v.setAttribute("aDist", new n.Float32BufferAttribute(r, 1)), v.setAttribute("aSeed", new n.Float32BufferAttribute(u, 1)), v.setAttribute("aW", new n.Float32BufferAttribute(m, 1)), v.boundingSphere = new n.Sphere(new n.Vector3(), 1e4), v;
561
+ }
562
+ function Mo() {
563
+ const e = R(
564
+ () => new n.ShaderMaterial({
565
+ uniforms: { uTime: { value: 0 } },
566
+ vertexShader: (
567
+ /* glsl */
568
+ "varying vec2 vXZ; void main(){ vXZ = position.xz; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }"
569
+ ),
570
+ fragmentShader: yo,
571
+ transparent: !0,
572
+ depthWrite: !1
573
+ }),
574
+ []
575
+ ), a = R(() => new n.CircleGeometry(Ce, 96).rotateX(-Math.PI / 2), []), t = R(() => bo(), []), o = R(
576
+ () => new n.ShaderMaterial({
577
+ uniforms: { uTime: { value: 0 }, uAct: { value: 0 } },
578
+ vertexShader: (
579
+ /* glsl */
580
+ `
581
+ attribute float aDist; attribute float aSeed; attribute float aW;
582
+ varying float vD; varying float vS; varying float vW; varying float vR;
583
+ void main(){ vD = aDist; vS = aSeed; vW = aW; vR = length(position.xz);
584
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }`
585
+ ),
586
+ fragmentShader: (
587
+ /* glsl */
588
+ `
589
+ uniform float uTime; uniform float uAct;
590
+ varying float vD; varying float vS; varying float vW; varying float vR;
591
+ void main(){
592
+ vec3 base = mix(vec3(0.55, 0.30, 0.95), vec3(0.18, 0.85, 0.78), smoothstep(0.25, 0.85, vS));
593
+ float fade = smoothstep(${(Ce * 0.72).toFixed(1)}, 5.0, vR);
594
+ float pulse = pow(max(0.0, sin(vD * 0.55 - uTime * (0.9 + uAct * 0.8) + vS * 6.283)), 26.0);
595
+ float k = (0.035 + 0.045 * vW) + pulse * (0.35 + 0.45 * uAct) * vW;
596
+ gl_FragColor = vec4(base * k * fade, 1.0);
597
+ }`
598
+ ),
599
+ transparent: !0,
600
+ depthWrite: !1,
601
+ blending: n.AdditiveBlending
602
+ }),
603
+ []
604
+ ), s = F(null);
605
+ return fe(({ clock: r }) => {
606
+ var f;
607
+ (f = s.current) == null || f.scale.setScalar(Math.max(1, (ge.core.r + 12) / (Ce * 0.62)));
608
+ let u = 0;
609
+ for (const g of W.instances.values()) !g.exitAt && g.status === "thinking" && u++;
610
+ const m = o.uniforms;
611
+ m.uAct.value += (Math.min(1, u / 5) - m.uAct.value) * 0.03, m.uTime.value = ne ? 0 : r.elapsedTime;
612
+ }), /* @__PURE__ */ H("group", { ref: s, children: [
613
+ /* @__PURE__ */ w("mesh", { geometry: a, material: e, position: [0, -0.02, 0], renderOrder: -10 }),
614
+ /* @__PURE__ */ w("lineSegments", { geometry: t, material: o, frustumCulled: !1 })
615
+ ] });
616
+ }
617
+ const So = 260, Ee = 40, xe = 20, $e = 10, Le = 3;
618
+ function xo(e) {
619
+ const a = e.nodes.slice(0, So), t = new Set(a.map((o) => o.id));
620
+ return { nodes: a, links: e.links.filter((o) => t.has(o.source) && t.has(o.target)) };
621
+ }
622
+ const Ao = (e) => 0.42 * Math.max(0, 1 - (e / he) ** 2) + 0.06, Po = 64;
623
+ function Co({ galaxy: e }) {
624
+ const [a, t] = mt("center"), o = R(() => xo(e), [e]), s = o.nodes.length, { size: r, gl: u, camera: m } = pt(), f = F([]), g = F([]), v = F(Array(Le).fill("")), i = F([]), y = R(() => {
625
+ const M = new Float32Array(s * 3), d = Math.PI * (3 - Math.sqrt(5));
626
+ let S = 91;
627
+ const C = () => (S = S * 16807 % 2147483647) / 2147483647;
628
+ for (let x = 0; x < s; x++) {
629
+ const z = he * Math.sqrt((x + 0.5) / s) * (0.94 + C() * 0.08), G = x * d + (C() - 0.5) * 0.25;
630
+ M.set([Math.cos(G) * z, Ao(z) + (C() - 0.5) * 0.05, Math.sin(G) * z], x * 3);
631
+ }
632
+ const ee = o.nodes.map((x, z) => new n.Color(Xt[x.kind] ?? "#94a3b8").lerp(z % 3 ? vt : Ye, 0.45).multiplyScalar(0.5)), O = new n.BufferGeometry();
633
+ O.setAttribute("position", new n.BufferAttribute(M, 3)), O.setAttribute("aSize", new n.BufferAttribute(new Float32Array(s), 1)), O.setAttribute("aColor", new n.BufferAttribute(new Float32Array(s * 3), 3));
634
+ const j = (x, z) => (M[x * 3] - M[z * 3]) ** 2 + (M[x * 3 + 2] - M[z * 3 + 2]) ** 2, _ = [], V = /* @__PURE__ */ new Set(), L = (x, z, G) => {
635
+ const J = Math.min(x, z) * 4096 + Math.max(x, z);
636
+ x === z || V.has(J) || (V.add(J), _.push([x, z, G]));
637
+ }, E = new Map(o.nodes.map((x, z) => [x.id, z]));
638
+ for (const x of o.links) {
639
+ const z = E.get(x.source), G = E.get(x.target);
640
+ z !== void 0 && G !== void 0 && j(z, G) < 2.2 * 2.2 && L(z, G, 1);
641
+ }
642
+ for (let x = 0; x < s; x++) {
643
+ const z = [];
644
+ for (let G = 0; G < s; G++) G !== x && z.push([j(x, G), G]);
645
+ z.sort((G, J) => G[0] - J[0]);
646
+ for (let G = 0; G < 3 && G < z.length; G++) L(x, z[G][1], 0);
647
+ }
648
+ const N = 3, U = new Float32Array(_.length * N * 2 * 3), we = new Float32Array(_.length * N * 2 * 3), pe = new Int32Array(_.length * 2), q = new Uint8Array(_.length);
649
+ _.forEach(([x, z, G], J) => {
650
+ pe[J * 2] = x, pe[J * 2 + 1] = z, q[J] = G;
651
+ for (let se = 0; se < N; se++)
652
+ for (let k = 0; k < 2; k++) {
653
+ const A = (se + k) / N, P = (J * N + se) * 2 + k;
654
+ for (let B = 0; B < 3; B++) U[P * 3 + B] = M[x * 3 + B] * (1 - A) + M[z * 3 + B] * A;
655
+ U[P * 3 + 1] -= Math.sin(Math.PI * A) * 0.05;
656
+ }
657
+ });
658
+ const X = new n.BufferGeometry();
659
+ X.setAttribute("position", new n.BufferAttribute(U, 3)), X.setAttribute("color", new n.BufferAttribute(we, 3));
660
+ const Z = new n.BufferGeometry();
661
+ return Z.setAttribute("position", new n.BufferAttribute(new Float32Array(Ee * xe * 2 * 3), 3)), Z.setAttribute("color", new n.BufferAttribute(new Float32Array(Ee * xe * 2 * 3), 3)), Z.boundingSphere = new n.Sphere(new n.Vector3(), 1e4), { pos: M, base: ee, ngeo: O, ageo: X, bgeo: Z, owner: pe, strong: q, nPairs: _.length, SEG: N, fire: new Float32Array(s), white: new Float32Array(s), fireC: Array.from({ length: s }, () => new n.Color()) };
662
+ }, [o, s]), h = R(
663
+ () => ({
664
+ nodes: At(),
665
+ arcs: new n.LineBasicMaterial({ vertexColors: !0, transparent: !0, blending: n.AdditiveBlending, depthWrite: !1, toneMapped: !1 }),
666
+ beam: new n.LineBasicMaterial({ vertexColors: !0, transparent: !0, blending: n.AdditiveBlending, depthWrite: !1, toneMapped: !1 }),
667
+ pool: et(new n.Color("#7c3aed").multiplyScalar(0.55)),
668
+ core: et(new n.Color("#c4b5fd").multiplyScalar(0.25)),
669
+ ripple: Array.from({ length: $e }, () => Xe("#ffffff"))
670
+ }),
671
+ []
672
+ ), c = R(() => /* @__PURE__ */ new Map(), [o]), p = R(() => new ke(Ee), []), l = R(() => ({ v: new n.Vector3(), v2: new n.Vector3(), mid: new n.Vector3(), sp: new n.Vector3(), c: new n.Color(), c2: new n.Color() }), []), b = (M) => {
673
+ let d = c.get(M);
674
+ return d === void 0 && c.set(M, d = Yt(o, M)), d;
675
+ };
676
+ return fe(({ clock: M }) => {
677
+ const d = ge.graph.out.x < -0.5 ? "left" : "center";
678
+ d !== a && t(d);
679
+ const S = performance.now(), { pos: C, base: ee, fire: O, white: j, fireC: _ } = y;
680
+ h.nodes.uniforms.uScale.value = Pt(r.height, u.getPixelRatio(), m.fov) * ge.graph.scale, O.fill(0), j.fill(0);
681
+ const { v: V, v2: L, mid: E, c: N, c2: U } = l, we = y.bgeo.getAttribute("position"), pe = y.bgeo.getAttribute("color");
682
+ let q = 0, X = 0;
683
+ p.begin();
684
+ const Z = W.flares;
685
+ for (let A = Math.max(0, Z.length - Po); A < Z.length; A++) {
686
+ const P = Z[A], B = b(P.node), I = (S - P.start) / 1e3, te = W.instances.get(P.instance), K = te ? Pe[te.type] : ue, D = P.op === "write", $ = I < 0.3 ? I / 0.3 : Math.exp(-(I - 0.3) * 1.3);
687
+ if ($ > O[B] && (O[B] = $, _[B].copy(D ? ue : K), j[B] = D ? 1 : 0), D && I < 1.6 && X < $e) {
688
+ const T = i.current[X];
689
+ if (T) {
690
+ T.visible = !0, T.position.set(C[B * 3], C[B * 3 + 1] + 0.02, C[B * 3 + 2]);
691
+ const Y = I / 1.6;
692
+ T.scale.setScalar(0.15 + Y * 1.6), h.ripple[X].color.setScalar((1 - Y) * (1 - Y) * 0.9);
693
+ }
694
+ X++;
695
+ }
696
+ const ie = xt(P.instance), le = ie ? kt(ie.p, l.sp) : void 0;
697
+ if (le && I < 2.2 && q < Ee) {
698
+ V.set(C[B * 3], C[B * 3 + 1], C[B * 3 + 2]), E.copy(le).add(V).multiplyScalar(0.5), E.y += 1.6;
699
+ const T = Math.min(1, I / 0.25) * (1 - I / 2.2) ** 1.5, Y = D ? Math.min(1, I * 0.9) : 1 - Math.min(1, I * 0.9);
700
+ for (let ve = 0; ve < xe; ve++)
701
+ for (let Me = 0; Me < 2; Me++) {
702
+ const Q = (ve + Me) / xe, ae = 1 - Q;
703
+ L.set(ae * ae * le.x + 2 * ae * Q * E.x + Q * Q * V.x, ae * ae * le.y + 2 * ae * Q * E.y + Q * Q * V.y, ae * ae * le.z + 2 * ae * Q * E.z + Q * Q * V.z);
704
+ const Ve = (q * xe + ve) * 2 + Me;
705
+ we.setXYZ(Ve, L.x, L.y, L.z);
706
+ const _e = Math.exp(-(((Q - Y) / 0.08) ** 2)) * 1.5;
707
+ U.copy(D ? ue : K).multiplyScalar(T * ((D ? 0.35 : 0.16) + _e) * 0.8), pe.setXYZ(Ve, U.r, U.g, U.b);
708
+ }
709
+ D ? p.add(le, E, V, 0, 0, 0.9, 1, 0.34, ue, T * 1.1) : p.add(le, E, V, 0, 0, 0.1, -1, 0.34, K, T * 1.3), q++;
710
+ }
711
+ }
712
+ for (let A = X; A < $e; A++) {
713
+ const P = i.current[A];
714
+ P && (P.visible = !1);
715
+ }
716
+ y.bgeo.setDrawRange(0, q * xe * 2), we.needsUpdate = !0, pe.needsUpdate = !0, p.end();
717
+ const x = ne ? 0 : M.elapsedTime, z = y.ngeo.getAttribute("aSize"), G = y.ngeo.getAttribute("aColor");
718
+ for (let A = 0; A < s; A++) {
719
+ const P = O[A], B = 0.85 + 0.15 * Math.sin(x * 0.8 + A * 1.7);
720
+ z.setX(A, 0.17 + P * (0.42 + j[A] * 0.22)), N.copy(ee[A]).multiplyScalar(B), P > 0.01 && at(at(N, _[A], P * 1.7), ue, P * (0.25 + j[A] * 1.1)), G.setXYZ(A, N.r, N.g, N.b);
721
+ }
722
+ z.needsUpdate = !0, G.needsUpdate = !0;
723
+ const J = y.ageo.getAttribute("color"), se = y.SEG * 2;
724
+ for (let A = 0; A < y.nPairs; A++) {
725
+ const P = Math.max(O[y.owner[A * 2]], O[y.owner[A * 2 + 1]]), B = y.strong[A] ? 0.2 : 0.11, I = 0.55 * B + P * 0.35, te = 0.4 * B + P * 0.45, K = 0.95 * B + P * 0.5;
726
+ for (let D = 0; D < se; D++) J.setXYZ(A * se + D, I, te, K);
727
+ }
728
+ J.needsUpdate = !0;
729
+ let k = 0;
730
+ for (let A = W.flares.length - 1; A >= 0 && k < Le; A--) {
731
+ const P = W.flares[A];
732
+ if (S - P.start > 2200) break;
733
+ let B = !1;
734
+ for (let $ = 0; $ < k; $++) v.current[$] === P.node && (B = !0);
735
+ if (B) continue;
736
+ const I = b(P.node);
737
+ let te = !1;
738
+ for (let $ = 0; $ < k; $++) {
739
+ const ie = g.current[$];
740
+ ie && Math.abs(ie.position.z - C[I * 3 + 2]) * ge.graph.scale < 1.1 && Math.abs(ie.position.x - C[I * 3]) * ge.graph.scale < 4 && (te = !0);
741
+ }
742
+ if (te) continue;
743
+ const K = f.current[k], D = g.current[k];
744
+ K && D && (D.position.set(C[I * 3], C[I * 3 + 1] + 0.35, C[I * 3 + 2]), v.current[k] !== P.node && (K.setText(`${P.op === "write" ? "wrote" : "read"} · ${P.node}`), K.setColor(P.op === "write" ? "#ffffff" : "#5eead4")), K.setOpacity(1)), v.current[k] = P.node, k++;
745
+ }
746
+ for (let A = k; A < Le; A++) {
747
+ const P = f.current[A];
748
+ P == null || P.setOpacity(0), v.current[A] = "";
749
+ }
750
+ }), /* @__PURE__ */ H(de, { children: [
751
+ /* @__PURE__ */ w("mesh", { geometry: tt, material: h.pool, scale: he * 3.2, position: [0, 0.01, 0] }),
752
+ /* @__PURE__ */ w("mesh", { geometry: tt, material: h.core, scale: he * 1.8, position: [0, 0.03, 0] }),
753
+ /* @__PURE__ */ w("lineSegments", { geometry: y.ageo, material: h.arcs, frustumCulled: !1 }),
754
+ /* @__PURE__ */ w("points", { geometry: y.ngeo, material: h.nodes, frustumCulled: !1 }),
755
+ /* @__PURE__ */ w("lineSegments", { geometry: y.bgeo, material: h.beam, frustumCulled: !1 }),
756
+ /* @__PURE__ */ w("primitive", { object: p.mesh }),
757
+ h.ripple.map((M, d) => /* @__PURE__ */ w("mesh", { ref: (S) => void (i.current[d] = S), geometry: bt, material: M, visible: !1 }, d)),
758
+ Array.from({ length: Le }, (M, d) => /* @__PURE__ */ w("group", { ref: (S) => void (g.current[d] = S), children: /* @__PURE__ */ w(Re, { ref: (S) => void (f.current[d] = S), text: "", offset: [0, 0.34], anchorX: a, size: 0.24, opacity: 0, fadeMs: 250, pxRange: [8, 12] }) }, d)),
759
+ /* @__PURE__ */ w(Dt, { position: [a === "left" ? -he : 0, 0.2, -he - 0.7], anchorX: a, suffix: " · mycelial mat", color: "#c084fc", size: 0.28, opacity: 0.75, pxRange: [8, 12] })
760
+ ] });
761
+ }
762
+ const Be = /* @__PURE__ */ new Map(), zo = new n.Vector3(0, 1, 0), Ze = new n.Vector3(), ct = new n.Vector3(), Je = [
763
+ // angle, distance (x size), scale (x size)
764
+ [2.2, 0.62, 0.26],
765
+ [3.6, 0.5, 0.18],
766
+ [4.9, 0.7, 0.21]
767
+ ];
768
+ function Go({ agent: e, onSelect: a }) {
769
+ const t = e.inst, o = F(null), s = F(null), r = F(null), u = F(null), m = F(null), f = F(null), g = F(null), v = F(null), i = F(null), y = F([]), h = R(() => Ie(t.id, 21), [t.id]), c = Pe[t.type], p = Ht(t), l = Mt * p, b = F(null), M = R(() => {
770
+ const _ = e.target.x - e.run.target.x, V = e.target.z - e.run.target.z;
771
+ return (_ * _ + V * V > 0.01 ? -Math.atan2(V, _) : -Math.PI / 2) + (Ie(t.id, 22) - 0.5) * 1.6;
772
+ }, [e, t.id]), d = R(
773
+ () => ({
774
+ cap: so(),
775
+ gill: io(),
776
+ stem: lo(),
777
+ pool: et("#000"),
778
+ halo: Fe("#000"),
779
+ sel: Xe("#ffffff"),
780
+ arrow: Xe(c),
781
+ hypha: Ke(c, t.parent ? t.subagent ? 0.06 : 0.085 : 0.075, 0.42, h, 0.35)
782
+ }),
783
+ [c, t.parent, t.subagent, h]
784
+ );
785
+ d.cap.uniforms.uSpots.value = h * 10;
786
+ const S = R(() => ({ c: new n.Color(), parentK: 0, ringK: 0, open: 0, curve: { p0: new n.Vector3(), p1: new n.Vector3(), p2: new n.Vector3(), wob: 0.35, seed: h } }), [h]);
787
+ Lt(() => (Be.set(t.id, S.curve), () => {
788
+ Be.get(t.id) === S.curve && Be.delete(t.id);
789
+ }), [t.id, S]), fe(({ clock: _ }) => {
790
+ var _e;
791
+ const V = performance.now(), L = ne ? 0 : _.elapsedTime, E = (V - t.bornAt) / 1e3, N = t.parent ? 0.9 : 0.75, U = ye(E / N), we = ye((E - N + 0.12) / 0.6), pe = eo((E - N - 0.2) / 0.75), q = t.exitAt ? (V - t.exitAt) / 1e3 : -1, X = q >= 0 ? re(q / 2.2) : 0, Z = Nt(t, V), x = Kt(t, V);
792
+ let z = !1;
793
+ for (const oe of W.mcpPending.values()) oe.instance === t.id && (z = !0);
794
+ const G = q < 0 && (t.status === "thinking" || t.status === "spawning"), J = 0.5 + 0.5 * Math.sin(L * 2.2 + h * 9), se = 0.5 + 0.5 * Math.sin(L * 0.9 + h * 5);
795
+ S.ringK += ((z && q < 0 ? 1 : 0) - S.ringK) * 0.08, S.open += ((G ? 1 : 0) - S.open) * 0.05;
796
+ const k = Math.max(1e-3, l * we * (1 - X * 0.4)), A = ne ? 0 : Math.sin(L * 0.7 + h * 12) * 0.035, P = 0.07 + h * 0.08 + A + X * X * 1.05, B = P * p, I = Math.atan(2 * P * p / Math.max(k, 0.3));
797
+ s.current && (s.current.scale.set(p * (1 + x * 0.04), k, p * (1 + x * 0.04)), d.stem.uniforms.uBend.value = P);
798
+ const te = p * Math.max(1e-4, pe) * (1 + x * 0.07 + (G ? J * 0.025 : se * 0.02));
799
+ r.current && (r.current.position.set(B, k - 0.05 * p, 0), r.current.rotation.z = -(I + X * 0.75), r.current.scale.set(te * (0.94 + S.open * 0.08), te * (1.18 - S.open * 0.25) * (1 - X * 0.35), te * (0.94 + S.open * 0.08))), o.current && (o.current.rotation.y = M);
800
+ const K = e.live, D = e.scale / p;
801
+ b.current && (b.current.position.copy(K), b.current.scale.setScalar(Math.max(1e-4, D))), S.c.copy(c), q >= 0 && S.c.lerp(t.status === "failed" ? gt : Qt, X * 0.85);
802
+ const $ = ((G ? 0.95 + J * 0.3 : 0.42 + se * 0.12) + x * 0.45) * (1 - X * 0.7);
803
+ d.cap.uniforms.uColor.value.copy(S.c), d.cap.uniforms.uGlow.value = $, d.cap.uniforms.uOpacity.value = Z, d.stem.uniforms.uColor.value.copy(S.c), d.stem.uniforms.uGlow.value = 0.55 + $ * 0.45, d.stem.uniforms.uOpacity.value = Z, d.gill.uniforms.uColor.value.copy(S.c).lerp(ht, S.ringK * 0.75), d.gill.uniforms.uGlow.value = ($ * 1.1 + x * 0.9) * Z, d.gill.uniforms.uTime.value = L, u.current && (u.current.scale.setScalar(Math.max(1e-4, p * (3.2 + $ * 1.2) * we)), d.pool.color.copy(S.c).multiplyScalar((0.06 + $ * 0.1 + x * 0.07) * Z)), m.current && (m.current.position.copy(r.current ? r.current.position : m.current.position), m.current.scale.setScalar(Math.max(1e-4, te * (2.6 + x * 0.6))), d.halo.color.copy(S.c).multiplyScalar((G ? 0.13 : 0.05) * Z + x * 0.05));
804
+ for (let oe = 0; oe < Je.length; oe++) {
805
+ const Se = y.current[oe];
806
+ if (!Se) continue;
807
+ const Ft = Je[oe][2] * p * ye((E - N - 0.6 - oe * 0.25) / 0.8) * (1 - X * 0.6);
808
+ Se.scale.setScalar(Math.max(1e-4, Ft));
809
+ }
810
+ if (f.current) {
811
+ const oe = W.selected === t.id;
812
+ f.current.visible = oe, oe && (f.current.scale.setScalar(p * (1.25 + 0.08 * Math.sin(L * 3))), d.sel.color.setScalar(0.7 * Z));
813
+ }
814
+ v.current && v.current.position.set(K.x + B * Math.cos(M) * D, K.y + (k + te * 0.75) * D + 0.32, K.z - B * Math.sin(M) * D), (_e = i.current) == null || _e.setOpacity(jt(t.id) ? re(pe) * (1 - X) * 0.95 : 0);
815
+ const ie = t.parent ? W.instances.get(t.parent) : void 0, le = t.parent ? We(t.parent) : void 0, T = S.curve;
816
+ le && ie ? T.p0.copy(le) : t.parent ? T.p0.lengthSq() === 0 && T.p0.copy(K) : Ut(e.run, 0, -2.4 * nt.spread, T.p0).setY(0.05), T.p2.copy(K), T.p1.copy(T.p0).add(T.p2).multiplyScalar(0.5), T.p1.y += 0.35;
817
+ const Y = d.hypha.uniforms;
818
+ Y.uP0.value.copy(T.p0), Y.uP1.value.copy(T.p1), Y.uP2.value.copy(T.p2);
819
+ const ve = !!t.parent && !!ie, Me = ve && !ie.exitAt, Q = q < 0 && (!t.parent || Me) ? 1 : 0;
820
+ S.parentK += (Q - S.parentK) * (Q ? 0.08 : 0.035);
821
+ const ae = q >= 0 ? He(q / 1.6) : 0;
822
+ Y.uGrow.value = U * (1 - ae), Y.uHead.value = U < 1 ? U : -1, Y.uTail.value = 0.12, Y.uHeadColor.value.copy(c).multiplyScalar(2.2);
823
+ const Ve = T.p0.distanceTo(T.p2);
824
+ if (Y.uBeads.value = Math.max(2, Ve / 1.1), Y.uTime.value = L, Y.uFlow.value = U >= 1 ? S.parentK * (G ? 1 : 0.45) : 0, Y.uOpacity.value = (ve ? G ? 0.85 : 0.55 : 0.38) * Math.max(S.parentK, U < 1 ? 1 : 0) + (U < 1 ? 0.3 : 0), g.current) {
825
+ const oe = ve && U >= 1 && S.parentK > 0.05 && Y.uGrow.value > 0.95;
826
+ if (g.current.visible = oe, oe) {
827
+ Ge(T.p0, T.p1, T.p2, T.wob, T.seed, 0.8, Ze), Ge(T.p0, T.p1, T.p2, T.wob, T.seed, 0.83, ct), g.current.position.copy(Ze), g.current.quaternion.setFromUnitVectors(zo, ct.sub(Ze).normalize());
828
+ const Se = (t.subagent ? 0.8 : 1) * Math.min(1.3, nt.scale);
829
+ g.current.scale.set(0.13 * Se, 0.36 * Se, 0.13 * Se), d.arrow.color.copy(c).multiplyScalar(1.5 * S.parentK);
830
+ }
831
+ }
832
+ });
833
+ const C = (_) => {
834
+ _.stopPropagation(), a(t.id);
835
+ }, ee = () => document.body.style.cursor = "pointer", O = () => document.body.style.cursor = "", j = t.id.split(":")[2];
836
+ return /* @__PURE__ */ H(de, { children: [
837
+ /* @__PURE__ */ w("mesh", { geometry: Ne, material: d.hypha, frustumCulled: !1 }),
838
+ /* @__PURE__ */ w("mesh", { ref: g, geometry: yt, material: d.arrow, visible: !1 }),
839
+ /* @__PURE__ */ H("group", { ref: b, children: [
840
+ /* @__PURE__ */ w("mesh", { ref: u, geometry: tt, material: d.pool, position: [0, 0.04, 0], scale: 1e-4 }),
841
+ /* @__PURE__ */ w("mesh", { ref: f, geometry: bt, material: d.sel, position: [0, 0.06, 0], visible: !1 }),
842
+ /* @__PURE__ */ H("group", { ref: o, children: [
843
+ /* @__PURE__ */ w("mesh", { ref: s, geometry: st, material: d.stem, scale: 1e-4, onClick: C, onPointerOver: ee, onPointerOut: O }),
844
+ /* @__PURE__ */ H("group", { ref: r, scale: 1e-4, children: [
845
+ /* @__PURE__ */ w("mesh", { geometry: rt, material: d.cap, onClick: C, onPointerOver: ee, onPointerOut: O }),
846
+ /* @__PURE__ */ w("mesh", { geometry: to, material: d.gill })
847
+ ] }),
848
+ /* @__PURE__ */ w("sprite", { ref: m, material: d.halo }),
849
+ !t.subagent && Je.map(([_, V], L) => /* @__PURE__ */ H("group", { ref: (E) => void (y.current[L] = E), position: [Math.cos(_) * V * p, 0, Math.sin(_) * V * p], scale: 1e-4, children: [
850
+ /* @__PURE__ */ w("mesh", { geometry: st, material: d.stem, scale: [1, 1.5, 1] }),
851
+ /* @__PURE__ */ w("mesh", { geometry: rt, material: d.cap, position: [0.08, 1.45, 0], scale: [0.75, 0.95, 0.75] })
852
+ ] }, L))
853
+ ] })
854
+ ] }),
855
+ /* @__PURE__ */ w("group", { ref: v, children: /* @__PURE__ */ w(
856
+ Re,
857
+ {
858
+ ref: i,
859
+ offset: [0, 0.22],
860
+ text: `${t.name}${j !== void 0 ? ` ${Number(j) + 1}` : ""}`,
861
+ color: dt[t.type],
862
+ size: t.subagent ? 0.22 : 0.28,
863
+ opacity: 0,
864
+ fit: !0,
865
+ pxRange: t.subagent ? [8, 11.5] : [9, 13.5]
866
+ }
867
+ ) })
868
+ ] });
869
+ }
870
+ const Qe = 24, Ae = 3;
871
+ function To() {
872
+ const e = F([]), a = R(() => Array.from({ length: Qe * Ae }, () => Fe("#fff")), []), t = R(() => ({ a: new n.Vector3(), b: new n.Vector3(), c: new n.Vector3(), p: new n.Vector3(), col: new n.Color() }), []);
873
+ return fe(() => {
874
+ const o = performance.now();
875
+ let s = 0;
876
+ for (const r of W.comets) {
877
+ if (s >= Qe) break;
878
+ const u = W.instances.get(r.from), m = W.instances.get(r.to), f = We(r.from), g = We(r.to);
879
+ if (!u || !m || !f || !g) continue;
880
+ const v = re((o - r.start) / r.dur);
881
+ if (v >= 1) continue;
882
+ let i, y = !0;
883
+ m.parent === r.from ? i = Be.get(r.to) : u.parent === r.to && (i = Be.get(r.from), y = !1), t.col.copy(Pe[u.type]).multiplyScalar(1.6).addScalar(0.25);
884
+ for (let h = 0; h < Ae; h++) {
885
+ const c = e.current[s * Ae + h];
886
+ if (!c) continue;
887
+ const p = re(He(v) - h * 0.035), l = y ? p : 1 - p;
888
+ i ? Ge(i.p0, i.p1, i.p2, i.wob, i.seed, l, t.p) : (t.c.copy(f).add(g).multiplyScalar(0.5), t.c.y += 2.4, Ge(f, t.c, g, 0, 0, l, t.p)), c.visible = !0, c.position.set(t.p.x, t.p.y + 0.12, t.p.z), c.scale.setScalar((h === 0 ? 1 : 0.7 - h * 0.15) * (0.6 + 0.4 * Math.sin(Math.PI * v))), a[s * Ae + h].color.copy(t.col).multiplyScalar(h === 0 ? 1 : 0.5 / h);
889
+ }
890
+ s++;
891
+ }
892
+ for (let r = s * Ae; r < Qe * Ae; r++) {
893
+ const u = e.current[r];
894
+ u && (u.visible = !1);
895
+ }
896
+ }), /* @__PURE__ */ w(de, { children: a.map((o, s) => /* @__PURE__ */ w("sprite", { ref: (r) => void (e.current[s] = r), material: o, visible: !1 }, s)) });
897
+ }
898
+ const Bo = new n.RingGeometry(0.88, 1.12, 160, 1).rotateX(-Math.PI / 2), ut = 1.1, Fo = 0.9;
899
+ function Tt(e, a) {
900
+ return a.a = e.hu * 1.12 + ut, a.b = Math.max(a.a * 0.45, e.hv * 1.12 + ut), a;
901
+ }
902
+ const ze = { a: 0, b: 0 }, ot = (e) => e.target.z < -0.5 ? -1 : 1;
903
+ function Bt(e, a, t = ot(e)) {
904
+ Tt(e, ze);
905
+ const o = Math.abs(e.side.z) * ze.a + Math.abs(e.axis.z) * ze.b;
906
+ return a.set(e.origin.x, 0.3, e.origin.z + t * (o + Fo));
907
+ }
908
+ const Ro = new n.Vector3();
909
+ function Vo(e) {
910
+ for (const a of ge.runs.values()) e(Bt(a, Ro), 1.6);
911
+ }
912
+ function _o(e) {
913
+ return new n.ShaderMaterial({
914
+ uniforms: { uColor: { value: e.clone() }, uK: { value: 0 }, uSweep: { value: 0 }, uStart: { value: 0 }, uSteps: { value: new n.Vector3(1, 1, 1) }, uTime: { value: 0 }, uGaps: { value: 0 } },
915
+ vertexShader: (
916
+ /* glsl */
917
+ "varying vec3 vP; void main(){ vP = position; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }"
918
+ ),
919
+ fragmentShader: (
920
+ /* glsl */
921
+ `
922
+ uniform vec3 uColor; uniform float uK; uniform float uSweep; uniform float uStart; uniform vec3 uSteps; uniform float uTime; uniform float uGaps;
923
+ varying vec3 vP;
924
+ void main(){
925
+ float r = length(vP.xz);
926
+ float a = fract((atan(vP.z, vP.x) - uStart) / 6.28318 + 1.0);
927
+ if (a > uSweep) discard;
928
+ float band = exp(-pow((r - 1.0) / 0.05, 2.0));
929
+ float caps = pow(max(0.0, sin(a * 6.28318 * 30.0)), 10.0) * exp(-pow((r - 1.0) / 0.035, 2.0));
930
+ float seg = a * 3.0;
931
+ float s = seg < 1.0 ? uSteps.x : seg < 2.0 ? uSteps.y : uSteps.z;
932
+ float gap = smoothstep(0.0, 0.015, fract(seg)) * smoothstep(1.0, 0.985, fract(seg));
933
+ float k = (band * 0.25 + caps * 1.6) * s * mix(1.0, gap, uGaps);
934
+ gl_FragColor = vec4(uColor * k * uK, 1.0);
935
+ }`
936
+ ),
937
+ transparent: !0,
938
+ depthWrite: !1,
939
+ blending: n.AdditiveBlending
940
+ });
941
+ }
942
+ function Oo({ run: e }) {
943
+ const a = R(() => new n.Color(e.color), [e.color]), t = R(() => _o(a), [a]), o = F(null), s = F(null), [r, u] = mt(() => ot(e));
944
+ return fe(({ clock: m }) => {
945
+ const f = performance.now(), g = ne ? 0 : m.elapsedTime, v = e.run ?? W.runs.get(e.id), i = v != null && v.endedAt ? re(1 - (f - v.endedAt - (qt - 2500)) / 2500) : 1, y = t.uniforms;
946
+ if (y.uSweep.value = v ? ye((f - v.startedAt) / 1800) : 1, y.uK.value = 0.55 * i * (!v || v.status === "started" ? 1 : 0.6), v != null && v.hasSteps) {
947
+ const c = (p) => p === "running" ? 1.5 + 0.5 * Math.sin(g * 3) : p === "done" ? 0.9 : p === "failed" ? 0.5 : 0.22;
948
+ y.uSteps.value.set(c(v.steps.plan), c(v.steps.research), c(v.steps.write));
949
+ } else y.uSteps.value.set(1, 1, 1);
950
+ y.uGaps.value = v != null && v.hasSteps ? 1 : 0, y.uStart.value = Math.atan2(-e.axis.z, -e.axis.x) - Math.atan2(e.side.z, e.side.x), o.current && (Tt(e, ze), o.current.position.set(e.origin.x, 0.05, e.origin.z), o.current.rotation.set(0, Math.atan2(-e.side.z, e.side.x), 0), o.current.scale.set(ze.a, 1, ze.b));
951
+ const h = ot(e);
952
+ h !== r && u(h), s.current && Bt(e, s.current.position, r);
953
+ }), /* @__PURE__ */ H(de, { children: [
954
+ /* @__PURE__ */ w("mesh", { ref: o, geometry: Bo, material: t }),
955
+ /* @__PURE__ */ w("group", { ref: s, children: e.run && /* @__PURE__ */ w(Eo, { run: e.run, anchorY: r > 0 ? "top" : "bottom" }) })
956
+ ] });
957
+ }
958
+ function Eo({ run: e, anchorY: a }) {
959
+ $t();
960
+ const t = e.status !== "started";
961
+ return /* @__PURE__ */ w(
962
+ Re,
963
+ {
964
+ text: e.topic,
965
+ secondary: Zt(e, { base: "#a1a1c2", current: "#f5d0fe", done: "#cbd5e1" }, ["colony growing…", "colony complete"]),
966
+ color: e.color,
967
+ size: 0.34,
968
+ maxWidth: 9,
969
+ opacity: t ? 0.5 : 0.95,
970
+ fadeMs: 400,
971
+ anchorY: a,
972
+ pxRange: [10, 14.5]
973
+ }
974
+ );
975
+ }
976
+ const ce = 2600;
977
+ function Lo() {
978
+ const { size: e, gl: a, camera: t } = pt(), o = R(() => {
979
+ const u = new n.BufferGeometry(), m = new Float32Array(ce * 3);
980
+ return u.setAttribute("position", new n.BufferAttribute(m, 3)), u.setAttribute("aSize", new n.BufferAttribute(new Float32Array(ce), 1)), u.setAttribute("aColor", new n.BufferAttribute(new Float32Array(ce * 3), 3)), u.boundingSphere = new n.Sphere(new n.Vector3(), 1e4), {
981
+ geo: u,
982
+ pos: m,
983
+ vel: new Float32Array(ce * 3),
984
+ life: new Float32Array(ce),
985
+ // remaining seconds (<=0 = free)
986
+ max: new Float32Array(ce),
987
+ sz: new Float32Array(ce),
988
+ col: new Float32Array(ce * 3),
989
+ next: 0,
990
+ seenLlm: /* @__PURE__ */ new Map(),
991
+ seenExit: /* @__PURE__ */ new Set(),
992
+ acc: /* @__PURE__ */ new Map(),
993
+ c: new n.Color()
994
+ };
995
+ }, []), s = R(() => At(), []), r = (u, m, f, g, v, i, y, h, c, p) => {
996
+ for (let l = 0; l < v; l++) {
997
+ const b = o.next;
998
+ o.next = (o.next + 1) % ce;
999
+ const M = Math.random() * Math.PI * 2, d = g * (0.2 + Math.random() * 0.75);
1000
+ o.pos[b * 3] = u + Math.cos(M) * d, o.pos[b * 3 + 1] = m - 0.08, o.pos[b * 3 + 2] = f + Math.sin(M) * d;
1001
+ const S = y * (0.4 + Math.random() * 0.8);
1002
+ o.vel[b * 3] = Math.cos(M) * S, o.vel[b * 3 + 1] = p * (0.3 + Math.random() * 0.9) - 0.15, o.vel[b * 3 + 2] = Math.sin(M) * S, o.life[b] = o.max[b] = c * (0.6 + Math.random() * 0.6), o.sz[b] = i * (0.55 + Math.random() * 0.8);
1003
+ const C = Math.random() * 0.45;
1004
+ o.col[b * 3] = h.r * (1 - C) + C, o.col[b * 3 + 1] = h.g * (1 - C) + C, o.col[b * 3 + 2] = h.b * (1 - C) + C;
1005
+ }
1006
+ };
1007
+ return fe(({ clock: u }, m) => {
1008
+ const f = Math.min(0.05, m);
1009
+ s.uniforms.uScale.value = Pt(e.height, a.getPixelRatio(), t.fov);
1010
+ for (const c of W.instances.values()) {
1011
+ const p = xt(c.id);
1012
+ if (!p || p.r < 0.05) continue;
1013
+ const l = p.p, b = p.r, M = o.seenLlm.get(c.id);
1014
+ if (M === void 0) o.seenLlm.set(c.id, c.llmCalls);
1015
+ else if (c.llmCalls !== M) {
1016
+ o.seenLlm.set(c.id, c.llmCalls);
1017
+ const d = c.pulse;
1018
+ r(l.x, l.y, l.z, b, Math.round((ne ? 6 : 16) + d * (ne ? 8 : 34)), 0.12 + d * 0.09, 0.9 + d * 0.5, Pe[c.type], 2.6 + d * 0.5, 0.9);
1019
+ }
1020
+ if (c.exitAt)
1021
+ o.seenExit.has(c.id) || (o.seenExit.add(c.id), o.c.copy(Pe[c.type]).multiplyScalar(0.45), r(l.x, l.y, l.z, b, ne ? 6 : 22, 0.1, 0.35, o.c, 2.2, -0.2));
1022
+ else if (!ne && c.status === "thinking") {
1023
+ const d = (o.acc.get(c.id) ?? 0) + f * 5 * (c.subagent ? 0.6 : 1);
1024
+ d >= 1 && r(l.x, l.y, l.z, b, 1, 0.08, 0.25, o.c.copy(Pe[c.type]).lerp(ue, 0.2), 3.2, 0.7), o.acc.set(c.id, d % 1);
1025
+ }
1026
+ }
1027
+ if (o.seenLlm.size > W.instances.size + 64)
1028
+ for (const c of o.seenLlm.keys()) W.instances.has(c) || (o.seenLlm.delete(c), o.seenExit.delete(c), o.acc.delete(c));
1029
+ const g = o.geo.getAttribute("position"), v = o.geo.getAttribute("aSize"), i = o.geo.getAttribute("aColor"), y = u.elapsedTime, h = Math.pow(0.35, f);
1030
+ for (let c = 0; c < ce; c++) {
1031
+ if (o.life[c] <= 0) {
1032
+ v.array[c] !== 0 && v.setX(c, 0);
1033
+ continue;
1034
+ }
1035
+ o.life[c] -= f;
1036
+ const p = c * 3, l = o.pos[p], b = o.pos[p + 2];
1037
+ o.vel[p] = o.vel[p] * h + Math.sin(b * 0.9 + y * 0.7) * 0.25 * f, o.vel[p + 1] = o.vel[p + 1] * h + 0.32 * f, o.vel[p + 2] = o.vel[p + 2] * h + Math.cos(l * 0.9 + y * 0.6) * 0.25 * f, o.pos[p] += o.vel[p] * f, o.pos[p + 1] += o.vel[p + 1] * f, o.pos[p + 2] += o.vel[p + 2] * f;
1038
+ const M = o.life[c] / o.max[c], d = Math.min(1, (1 - M) * 8) * M;
1039
+ g.setXYZ(c, o.pos[p], o.pos[p + 1], o.pos[p + 2]), v.setX(c, o.sz[c] * (0.6 + 0.4 * M)), i.setXYZ(c, o.col[p] * d * 1.3, o.col[p + 1] * d * 1.3, o.col[p + 2] * d * 1.3);
1040
+ }
1041
+ g.needsUpdate = !0, v.needsUpdate = !0, i.needsUpdate = !0;
1042
+ }), /* @__PURE__ */ w("points", { geometry: o.geo, material: s, frustumCulled: !1 });
1043
+ }
1044
+ const Io = ["#a855f7", "#2dd4bf"], Wo = { radius: 1.4, variant: "swarm", color: (e) => Io[e % 2] }, Xo = [0, 1.6, 0], ko = /* @__PURE__ */ H(de, { children: [
1045
+ /* @__PURE__ */ w("fog", { attach: "fog", args: ["#040309", 55, 140] }),
1046
+ /* @__PURE__ */ w(Mo, {})
1047
+ ] });
1048
+ function Uo() {
1049
+ return /* @__PURE__ */ H(
1050
+ Jt,
1051
+ {
1052
+ title: "mycelium · fungal network",
1053
+ subtitle: "Agents bloom as mushrooms (big cap = parent) on hyphae grown from their parent · spores = LLM calls (sized by tokens) · MCP servers + backends feed the network's edge · the mat on the side is graph memory",
1054
+ preset: "radial",
1055
+ plane: "xz",
1056
+ camera: { position: [0, 34, 29], fov: 46 },
1057
+ controls: { minPolarAngle: 0.25, maxPolarAngle: 1.38 },
1058
+ bg: "#040309",
1059
+ fit: { nRef: 4, min: 0.62, max: 1.6, minRadius: 5.5 },
1060
+ agentRadius: 1.5,
1061
+ graph: { natural: he + 0.4, radius: 2.6 },
1062
+ peripheryGap: 3.8,
1063
+ Background: ko,
1064
+ Agent: Go,
1065
+ RunMarker: Oo,
1066
+ McpServer: vo,
1067
+ Backend: mo,
1068
+ GraphResource: Co,
1069
+ cluster: Wo,
1070
+ clusterOffset: Xo,
1071
+ extents: Vo,
1072
+ PostFX: /* @__PURE__ */ H(_t, { multisampling: 0, children: [
1073
+ /* @__PURE__ */ w(Ot, { mipmapBlur: !0, intensity: 1.15, luminanceThreshold: 0.18, luminanceSmoothing: 0.3, radius: 0.78 }),
1074
+ /* @__PURE__ */ w(Et, { eskil: !1, offset: 0.2, darkness: 0.92 })
1075
+ ] }),
1076
+ children: [
1077
+ /* @__PURE__ */ w(To, {}),
1078
+ /* @__PURE__ */ w(go, {}),
1079
+ /* @__PURE__ */ w(Lo, {})
1080
+ ]
1081
+ }
1082
+ );
1083
+ }
1084
+ export {
1085
+ Uo as default
1086
+ };