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