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,837 +0,0 @@
1
- var bt = Object.defineProperty;
2
- var Mt = (e, t, o) => t in e ? bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
- var j = (e, t, o) => Mt(e, typeof t != "symbol" ? t + "" : t, o);
4
- import { jsx as f, jsxs as _, Fragment as Z } from "react/jsx-runtime";
5
- import { OrbitControls as St } from "@react-three/drei";
6
- import { useFrame as Y, Canvas as Ct } from "@react-three/fiber";
7
- import { EffectComposer as At, Bloom as xt, Vignette as Pt } from "@react-three/postprocessing";
8
- import { useState as Ce, useRef as V, useMemo as P, useEffect as Vt } from "react";
9
- import * as n from "three";
10
- import { T as ft, w as B, h as L, x as pt, l as fe, o as zt, C as Et, L as Ae, c as Ft, i as Gt, r as Rt, a as Bt, F as Tt, p as Ot, e as kt, s as _t, b as It, G as Lt, n as Ut, d as Dt, S as _e, R as Nt, u as Xt, k as Ht, f as qt, H as Kt, t as Wt, g as jt } from "./ClusterBall-CPsd6JvJ.js";
11
- import { s as tt } from "./spread-CWdeDFd9.js";
12
- var ut;
13
- const X = typeof window < "u" && !!((ut = window.matchMedia) != null && ut.call(window, "(prefers-reduced-motion: reduce)").matches), mt = new n.Color("#3db8ff"), ue = new n.Color("#9fdcff"), Re = new n.Color("#ff4fa8"), ot = new n.Color("#ff9ccf"), te = new n.Color(1, 1, 1), ye = new n.Color("#ffc24a"), Yt = new n.Color("#ff2d55"), $t = new n.Color("#3a4560"), Je = Object.fromEntries(Object.entries(ft).map(([e, t]) => [e, new n.Color(t)])), N = (e) => e < 0 ? 0 : e > 1 ? 1 : e, ke = (e) => 1 - Math.pow(1 - N(e), 3), Me = (e) => (e = N(e), e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2);
14
- let Pe = null;
15
- function dt() {
16
- if (Pe) return Pe;
17
- const e = document.createElement("canvas");
18
- e.width = e.height = 128;
19
- const t = e.getContext("2d"), o = t.createRadialGradient(64, 64, 0, 64, 64, 64);
20
- return o.addColorStop(0, "rgba(255,255,255,1)"), o.addColorStop(0.12, "rgba(255,255,255,0.7)"), o.addColorStop(0.4, "rgba(255,255,255,0.15)"), o.addColorStop(1, "rgba(255,255,255,0)"), t.fillStyle = o, t.fillRect(0, 0, 128, 128), Pe = new n.CanvasTexture(e), Pe;
21
- }
22
- function $(e = "#fff") {
23
- return new n.SpriteMaterial({ map: dt(), color: e, blending: n.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 });
24
- }
25
- function ee(e = "#fff") {
26
- return new n.MeshBasicMaterial({ color: e, blending: n.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 });
27
- }
28
- function le(e = "#fff", t = !1) {
29
- return new n.LineBasicMaterial({ color: e, vertexColors: t, transparent: !0, blending: n.AdditiveBlending, depthWrite: !1, toneMapped: !1 });
30
- }
31
- const Ie = new n.SphereGeometry(1, 24, 18), et = new n.ConeGeometry(1, 1, 12).translate(0, 0.5, 0), nt = new n.TorusGeometry(1, 0.03, 6, 72);
32
- function Zt(e = 48, t = 6) {
33
- const o = [], r = [];
34
- for (let s = 0; s <= e; s++)
35
- for (let c = 0; c < t; c++) {
36
- const l = c / t * Math.PI * 2;
37
- o.push(s / e, Math.cos(l), Math.sin(l));
38
- }
39
- for (let s = 0; s < e; s++)
40
- for (let c = 0; c < t; c++) {
41
- const l = s * t + c, u = s * t + (c + 1) % t;
42
- r.push(l, l + t, u, u, l + t, u + t);
43
- }
44
- const a = new n.BufferGeometry();
45
- return a.setAttribute("position", new n.Float32BufferAttribute(o, 3)), a.setIndex(r), a.boundingSphere = new n.Sphere(new n.Vector3(), 1e4), a;
46
- }
47
- const ht = Zt();
48
- function gt(e, t = 0.04) {
49
- return new n.ShaderMaterial({
50
- uniforms: {
51
- uP0: { value: new n.Vector3() },
52
- uP1: { value: new n.Vector3() },
53
- uP2: { value: new n.Vector3() },
54
- uRadius: { value: t },
55
- uOpacity: { value: 1 },
56
- uGrow: { value: 1 },
57
- uTime: { value: 0 },
58
- uFlow: { value: 0 },
59
- uHead: { value: -1 },
60
- uColor: { value: new n.Color(e) },
61
- uHeadColor: { value: new n.Color(3, 3, 3) }
62
- },
63
- vertexShader: (
64
- /* glsl */
65
- `
66
- uniform vec3 uP0; uniform vec3 uP1; uniform vec3 uP2; uniform float uRadius;
67
- varying float vT; varying float vRim;
68
- void main(){
69
- float t = position.x; float a = 1.0 - t;
70
- vec3 p = a*a*uP0 + 2.0*a*t*uP1 + t*t*uP2;
71
- vec3 tg = 2.0*a*(uP1-uP0) + 2.0*t*(uP2-uP1);
72
- tg = length(tg) > 1e-5 ? normalize(tg) : vec3(1.0,0.0,0.0);
73
- vec3 up = abs(tg.y) > 0.92 ? vec3(1.0,0.0,0.0) : vec3(0.0,1.0,0.0);
74
- vec3 n = normalize(cross(tg, up)); vec3 b = cross(tg, n);
75
- vec3 off = n*position.y + b*position.z;
76
- vec4 mv = modelViewMatrix * vec4(p + off * uRadius * mix(1.0, 0.45, t), 1.0);
77
- vRim = abs(dot(normalize(normalMatrix * off), normalize(-mv.xyz)));
78
- vT = t;
79
- gl_Position = projectionMatrix * mv;
80
- }`
81
- ),
82
- fragmentShader: (
83
- /* glsl */
84
- `
85
- uniform vec3 uColor; uniform vec3 uHeadColor; uniform float uOpacity; uniform float uGrow; uniform float uTime; uniform float uFlow; uniform float uHead;
86
- varying float vT; varying float vRim;
87
- void main(){
88
- if (vT > uGrow) discard;
89
- float core = 0.2 + 0.8 * vRim * vRim;
90
- // field quanta travelling parent (t=0) -> child (t=1)
91
- float flow = uFlow * pow(max(0.0, sin((vT * 6.0 - uTime * 0.8) * 3.14159)), 10.0);
92
- float head = uHead >= 0.0 ? exp(-pow((vT - uHead) / 0.05, 2.0)) : 0.0;
93
- gl_FragColor = vec4(uColor * uOpacity * (core + flow * 2.6) + uHeadColor * head, 1.0);
94
- }`
95
- ),
96
- transparent: !0,
97
- depthWrite: !1,
98
- blending: n.AdditiveBlending
99
- });
100
- }
101
- function oe(e, t, o, r, a) {
102
- const s = 1 - r;
103
- return a.set(s * s * e.x + 2 * s * r * t.x + r * r * o.x, s * s * e.y + 2 * s * r * t.y + r * r * o.y, s * s * e.z + 2 * s * r * t.z + r * r * o.z);
104
- }
105
- function Be(e, t, o, r) {
106
- r.copy(e).add(t).multiplyScalar(0.5);
107
- const a = r.length() || 1;
108
- return r.multiplyScalar(1 + o / a), r.z += o * 0.4, r;
109
- }
110
- const Oe = class Oe {
111
- constructor(t) {
112
- j(this, "mesh");
113
- j(this, "colors");
114
- j(this, "n", 0);
115
- j(this, "o", new n.Object3D());
116
- j(this, "a", new n.Vector3());
117
- j(this, "b", new n.Vector3());
118
- this.max = t, this.colors = new Float32Array(t * 3), this.mesh = new n.InstancedMesh(et, new n.MeshBasicMaterial({ blending: n.AdditiveBlending, depthWrite: !1, transparent: !0, toneMapped: !1 }), t), this.mesh.instanceColor = new n.InstancedBufferAttribute(this.colors, 3), this.mesh.frustumCulled = !1, this.mesh.count = 0;
119
- }
120
- begin() {
121
- this.n = 0;
122
- }
123
- add(t, o, r, a, s, c, l, u = 1) {
124
- this.n >= this.max || u <= 0.01 || (oe(t, o, r, a, this.a), oe(t, o, r, N(a + 0.02 * s), this.b), this.b.sub(this.a), !(this.b.lengthSq() < 1e-8) && (this.o.position.copy(this.a), this.o.quaternion.setFromUnitVectors(Oe.UP, this.b.normalize()), this.o.scale.set(c * 0.38, c, c * 0.38), this.o.updateMatrix(), this.mesh.setMatrixAt(this.n, this.o.matrix), this.colors[this.n * 3] = l.r * u, this.colors[this.n * 3 + 1] = l.g * u, this.colors[this.n * 3 + 2] = l.b * u, this.n++));
125
- }
126
- end() {
127
- this.mesh.count = this.n, this.mesh.instanceMatrix.needsUpdate = !0, this.mesh.instanceColor.needsUpdate = !0;
128
- }
129
- };
130
- j(Oe, "UP", new n.Vector3(0, 1, 0));
131
- let Te = Oe;
132
- class wt {
133
- constructor(t, o) {
134
- j(this, "geo", new n.BufferGeometry());
135
- j(this, "P");
136
- j(this, "C");
137
- j(this, "n", 0);
138
- this.max = t, this.seg = o, this.P = new n.BufferAttribute(new Float32Array(t * o * 6), 3), this.C = new n.BufferAttribute(new Float32Array(t * o * 6), 3), this.geo.setAttribute("position", this.P), this.geo.setAttribute("color", this.C), this.geo.boundingSphere = new n.Sphere(new n.Vector3(), 1e4);
139
- }
140
- begin() {
141
- this.n = 0;
142
- }
143
- /** Returns the base vertex index for curve slot, or -1 if full. Caller writes seg*2 vertices. */
144
- next() {
145
- return this.n < this.max ? this.n++ * this.seg * 2 : -1;
146
- }
147
- end() {
148
- this.geo.setDrawRange(0, this.n * this.seg * 2), this.P.needsUpdate = !0, this.C.needsUpdate = !0;
149
- }
150
- }
151
- const he = 2.15, vt = (e) => 5.6 + e * 1.25, ge = /* @__PURE__ */ new Map();
152
- function yt(e) {
153
- let t = ge.get(e);
154
- if (t) return t;
155
- const o = B.runs.get(e), r = o ? o.slot : Math.floor(L(e, 9) * 6), a = L(e, 1) * Math.PI + r * 1.05, s = 1 + L(e, 2) * 0.32, c = new n.Quaternion().setFromEuler(new n.Euler(s, 0, a, "ZXY"));
156
- if (t = {
157
- r: vt(fe.grouped ? zt(r) : r) + L(e, 3) * 0.45,
158
- q: c,
159
- u: new n.Vector3(1, 0, 0).applyQuaternion(c),
160
- v: new n.Vector3(0, 1, 0).applyQuaternion(c),
161
- n: new n.Vector3(0, 0, 1).applyQuaternion(c),
162
- dir: L(e, 4) < 0.5 ? 1 : -1,
163
- phase: L(e, 5) * Math.PI * 2
164
- }, ge.set(e, t), ge.size > 64)
165
- for (const u of ge.keys()) !B.runs.has(u) && u !== e && ge.delete(u);
166
- return t;
167
- }
168
- function Le(e, t, o, r) {
169
- return r.copy(e.u).multiplyScalar(Math.cos(t) * o).addScaledVector(e.v, Math.sin(t) * o);
170
- }
171
- const Qt = X ? 0 : 0.085, Jt = X ? 0 : 0.42, we = /* @__PURE__ */ new Map();
172
- function eo(e) {
173
- let t = we.get(e.id);
174
- if (t) return t;
175
- if (e.subagent && e.parent) {
176
- const o = tt(e, "atom-sub"), r = new n.Quaternion().setFromEuler(new n.Euler(0.7 + L(e.id, 1) * 1.2, L(e.id, 2) * Math.PI, o * 0.9, "ZXY"));
177
- t = { phase: o * 2.39996 + L(e.id, 3) * 0.6, w: Jt * (0.85 + L(e.id, 4) * 0.3), r: 1.7 + o % 3 * 0.45, u: new n.Vector3(1, 0, 0).applyQuaternion(r), v: new n.Vector3(0, 1, 0).applyQuaternion(r) };
178
- } else {
179
- const o = yt(e.run), r = tt(e, "atom-top");
180
- t = { phase: o.phase + r * 2.39996 + (L(e.id, 3) - 0.5) * 0.35, w: Qt * o.dir, r: o.r, u: o.u, v: o.v };
181
- }
182
- if (we.set(e.id, t), we.size > 400)
183
- for (const o of we.keys()) pt(o) || we.delete(o);
184
- return t;
185
- }
186
- const to = Array.from({ length: 6 }, () => new n.Vector3());
187
- function Ze(e, t, o, r = 0) {
188
- const a = eo(e), s = e.bornAt / 1e3, c = e.exitAt ? e.exitAt / 1e3 : 0, l = c && t > c ? t - c : 0, u = a.phase + a.w * (t - s) + l * 0.9, b = a.r * (1 + l * l * 0.07);
189
- o.copy(a.u).multiplyScalar(Math.cos(u) * b).addScaledVector(a.v, Math.sin(u) * b);
190
- const d = e.subagent && e.parent && r < 5 ? pt(e.parent) : void 0, g = ke((t - s) / 1.1);
191
- if (d) {
192
- const v = to[r];
193
- Ze(d, t, v, r + 1), o.add(v), g < 1 && o.lerp(v, 1 - g);
194
- } else g < 1 && o.multiplyScalar(0.3 + 0.7 * g);
195
- return o;
196
- }
197
- const re = /* @__PURE__ */ new Map(), Ue = [
198
- [-19, -1.5, -3],
199
- [17.5, -3.5, -3],
200
- [0, 11.5, -4],
201
- [0, -12, -3],
202
- [-16, 8, -5],
203
- [16, -10, -4],
204
- [-16, -9.5, -4],
205
- [17, 7, -5]
206
- ];
207
- function Se(e, t) {
208
- const o = Ue[e % Ue.length], r = Math.floor(e / Ue.length);
209
- return t.set(o[0] * (1 + r * 0.12), o[1] * (1 + r * 0.12), o[2] - r * 3);
210
- }
211
- function oo(e, t, o, r) {
212
- return Se(e, r), Math.abs(r.x) < 4 ? (r.x += (t % 2 ? 1 : -1) * (3.4 + Math.floor(t / 2) * 3.2), r.y += Math.sign(r.y || 1) * 0.6) : (r.x += Math.sign(r.x) * 3.6, r.y += (t - (o - 1) / 2) * 2.3), r.z -= 0.6, r;
213
- }
214
- function no(e, t, o) {
215
- return e.r += t.r * o, e.g += t.g * o, e.b += t.b * o, e;
216
- }
217
- const ro = Math.PI / 180, so = [200, 20, 100, 290, 150, 340];
218
- function ao(e, t) {
219
- const o = fe.laneExpanded[e] > 0, r = (so[e] + (o ? 38 : 0)) * ro, a = vt(e) + (o ? 1.2 : 0);
220
- return t.set(Math.cos(r) * a, Math.sin(r) * a, o ? -1.5 : -0.5);
221
- }
222
- function co() {
223
- return /* @__PURE__ */ f(Et, { place: ao, radius: 1.3, variant: "orb" });
224
- }
225
- const lo = new n.Vector3(), io = new n.Vector3(0, 1, 0);
226
- function uo() {
227
- const e = [], t = (s, c) => e.push(...s, ...c), r = (s, c, l = 48) => {
228
- for (let u = 0; u < l; u++) {
229
- const b = u / l * Math.PI * 2, d = (u + 1) / l * Math.PI * 2;
230
- t([Math.cos(b) * s, Math.sin(b) * s, c], [Math.cos(d) * s, Math.sin(d) * s, c]);
231
- }
232
- };
233
- for (const s of [-0.7, 0.7])
234
- r(1, s), r(0.62, s), r(0.3, s * 1.15);
235
- r(1, 0);
236
- for (let s = 0; s < 16; s++) {
237
- const c = s / 16 * Math.PI * 2, l = Math.cos(c), u = Math.sin(c);
238
- t([l * 1, u * 1, -0.7], [l * 1, u * 1, 0.7]);
239
- for (const b of [-0.7, 0.7]) t([l * 0.62, u * 0.62, b], [l * 1, u * 1, b]);
240
- s % 2 === 0 && t([l * 0.3, u * 0.3, -0.8], [l * 0.3, u * 0.3, 0.8]);
241
- }
242
- const a = new n.BufferGeometry();
243
- return a.setAttribute("position", new n.Float32BufferAttribute(e, 3)), a;
244
- }
245
- const fo = uo(), po = new n.CylinderGeometry(1, 1, 1.4, 32, 1, !0).rotateX(Math.PI / 2), ie = (e, t, o) => ({ geo: e, edges: new n.EdgesGeometry(e, 25), pos: t, rot: o }), Ve = {
246
- db: () => [ie(new n.CylinderGeometry(0.4, 0.4, 0.66, 24)), ie(new n.TorusGeometry(0.4, 0.01, 4, 40), [0, 0.11, 0], [Math.PI / 2, 0, 0])],
247
- warehouse: () => [-0.28, 0, 0.28].map((e) => ie(new n.BoxGeometry(0.9, 0.18, 0.55), [0, e, 0])),
248
- spark: () => [ie(new n.IcosahedronGeometry(0.42, 0))],
249
- api: () => [ie(new n.TorusGeometry(0.38, 0.09, 8, 6))],
250
- storage: () => [ie(new n.BoxGeometry(0.66, 0.66, 0.66), void 0, [0.4, 0.6, 0])],
251
- queue: () => [ie(new n.CapsuleGeometry(0.18, 0.7, 4, 12), void 0, [0, 0, Math.PI / 2])]
252
- };
253
- function mo({ srv: e, res: t, k: o, n: r }) {
254
- const a = P(() => oo(e.slot, o, r, new n.Vector3()), [e.slot, o, r]), s = P(() => Se(e.slot, new n.Vector3()), [e.slot]), c = P(() => {
255
- var p;
256
- return ((p = Ve[t.kind]) == null ? void 0 : p.call(Ve)) ?? Ve.api();
257
- }, [t.kind]), l = P(() => new n.Color(e.color).lerp(te, 0.3), [e.color]), u = P(() => {
258
- const p = gt(e.color, 0.03);
259
- return p.uniforms.uP0.value.copy(s), p.uniforms.uP2.value.copy(a), p.uniforms.uP1.value.copy(s).add(a).multiplyScalar(0.5), { edge: p, fill: ee(l), line: le(l), halo: $(l), arrow: ee(l) };
260
- }, [e.color, s, a, l]), b = V(null), d = V(null), g = V(null), v = V(null), y = V("");
261
- return Y(({ clock: p }) => {
262
- var k;
263
- const M = performance.now(), i = p.elapsedTime, m = t.inflight > 0, w = Math.exp(-((M - t.activeAt) / 1e3) * 1.5), A = m && !X ? 0.5 + 0.5 * Math.sin(i * 5) : m ? 0.5 : 0, S = m ? 1.5 + A * 0.8 : 0.14 + w * 0.9;
264
- u.fill.color.copy(l).multiplyScalar(S * 0.22), u.line.color.copy(l).multiplyScalar(S * 1.3), u.halo.color.copy(l).multiplyScalar(m ? 0.4 + A * 0.2 : 0.02 + w * 0.22), (k = d.current) == null || k.scale.setScalar(m ? 3.6 + A * 0.6 : 2.2 + w), b.current && (b.current.scale.setScalar(m ? 1.18 + A * 0.06 : 1 + w * 0.08), b.current.rotation.y = X ? 0.4 : i * (m ? 0.7 : 0.12));
265
- let z = null;
266
- for (const T of B.mcpCalls) T.server === e.name && T.resource === t.name && (!z || T.start > z.start) && (z = T);
267
- let C = t.name;
268
- if (m) {
269
- let T = "";
270
- for (const O of B.mcpPending.values()) O.server === e.name && O.resource === t.name && (T = O.tool);
271
- C = `${t.name} ▸ ${T || "query"}()`;
272
- } else z && z.phase === "result" && M - z.start < 1800 && (C = `${t.name} ✓ returned`);
273
- v.current && (C !== y.current && (v.current.setText(C), y.current = C), v.current.setOpacity(m ? 1 : 0.5 + w * 0.5));
274
- const h = u.edge.uniforms;
275
- h.uTime.value = X ? 0 : i;
276
- const E = z && z.phase === "result" ? (M - z.start) / z.dur : 9, G = g.current;
277
- E < 1 ? (h.uRadius.value = 0.055, h.uOpacity.value = 0.8 * (1 - E * 0.6), h.uFlow.value = 0, h.uHead.value = 1 - Me(E), h.uHeadColor.value.copy(l).multiplyScalar(3), G && (G.visible = !0, rt(G, h.uP0.value, h.uP1.value, h.uP2.value, 0.14, -1, 0.5), u.arrow.color.copy(l).multiplyScalar(2 * (1 - E * 0.7)))) : m ? (h.uRadius.value = 0.03, h.uOpacity.value = 0.5, h.uFlow.value = 1, h.uHead.value = -1, G && (G.visible = !0, rt(G, h.uP0.value, h.uP1.value, h.uP2.value, 0.82, 1, 0.4), u.arrow.color.copy(l).multiplyScalar(1.2))) : (h.uRadius.value = 0.025, h.uOpacity.value = 0.14 + w * 0.4, h.uFlow.value = 0, h.uHead.value = -1, G && (G.visible = !1));
278
- }), /* @__PURE__ */ _(Z, { children: [
279
- /* @__PURE__ */ f("mesh", { geometry: ht, material: u.edge, frustumCulled: !1 }),
280
- /* @__PURE__ */ f("mesh", { ref: g, geometry: et, material: u.arrow, visible: !1 }),
281
- /* @__PURE__ */ _("group", { position: a, children: [
282
- /* @__PURE__ */ f("sprite", { ref: d, material: u.halo }),
283
- /* @__PURE__ */ f("group", { ref: b, children: c.map((p, M) => /* @__PURE__ */ _("group", { position: p.pos, rotation: p.rot, children: [
284
- /* @__PURE__ */ f("mesh", { geometry: p.geo, material: u.fill }),
285
- /* @__PURE__ */ f("lineSegments", { geometry: p.edges, material: u.line })
286
- ] }, M)) }),
287
- /* @__PURE__ */ f(Ae, { ref: v, position: [0, -0.9, 0], text: t.name, font: "mono", color: e.color, size: 0.2, opacity: 0.5, pxRange: [7.5, 11] })
288
- ] })
289
- ] });
290
- }
291
- const De = new n.Vector3(), ze = new n.Vector3();
292
- function rt(e, t, o, r, a, s, c) {
293
- oe(t, o, r, a, De), oe(t, o, r, N(a + 0.02 * s), ze), e.position.copy(De), ze.sub(De), ze.lengthSq() > 1e-8 && e.quaternion.setFromUnitVectors(io, ze.normalize()), e.scale.set(c * 0.38, c, c * 0.38);
294
- }
295
- function ho({ srv: e }) {
296
- const t = P(() => Se(e.slot, new n.Vector3()), [e.slot]), o = P(() => new n.Color(e.color), [e.color]), r = P(() => ({ line: le(o), fill: ee(o), core: $("#fff"), halo: $(o), hit: $("#fff") }), [o]), a = V(null), s = V(null), c = V(null), l = V(null), [u, b] = Ce([]), d = V(0), g = V(e.calls), v = V(-1e9);
297
- return Y(({ clock: y }) => {
298
- var A;
299
- e.resources.size !== d.current && (d.current = e.resources.size, b([...e.resources.values()]));
300
- const p = performance.now();
301
- e.calls !== g.current && (g.current = e.calls, v.current = p), a.current && !a.current.userData.aimed && (a.current.lookAt(lo), a.current.userData.aimed = !0);
302
- const M = e.inflight > 0, i = Math.exp(-((p - e.activeAt) / 1e3) * 1.4), m = (M ? 0.8 : 0.32) + i * 0.5;
303
- r.line.color.copy(o).multiplyScalar(m * 1.4), r.fill.color.copy(o).multiplyScalar(m * 0.05), r.core.color.setScalar(M ? 0.7 : 0.18), r.halo.color.copy(o).multiplyScalar(M ? 0.24 : 0.06 + i * 0.12), (A = c.current) == null || A.scale.setScalar(5 + (M ? 0.8 : 0)), s.current && (s.current.rotation.z = X ? 0 : y.elapsedTime * (M ? 0.55 : 0.08));
304
- const w = (p - v.current) / 700;
305
- l.current && (l.current.visible = w < 1, l.current.scale.setScalar(1 + w * 4), r.hit.color.copy(o).lerp(te, 0.5).multiplyScalar((1 - w) * (1 - w) * 1.2));
306
- }), /* @__PURE__ */ _(Z, { children: [
307
- /* @__PURE__ */ _("group", { position: t, children: [
308
- /* @__PURE__ */ f("sprite", { ref: c, material: r.halo }),
309
- /* @__PURE__ */ f("group", { ref: a, children: /* @__PURE__ */ _("group", { ref: s, children: [
310
- /* @__PURE__ */ f("lineSegments", { geometry: fo, material: r.line }),
311
- /* @__PURE__ */ f("mesh", { geometry: po, material: r.fill })
312
- ] }) }),
313
- /* @__PURE__ */ f("sprite", { material: r.core, scale: 0.9 }),
314
- /* @__PURE__ */ f("sprite", { ref: l, material: r.hit, visible: !1 }),
315
- /* @__PURE__ */ f(Ae, { position: [0, 1.65, 0], text: `MCP · ${e.name}`, color: e.color, size: 0.28, pxRange: [9, 13] })
316
- ] }),
317
- u.map((y, p) => /* @__PURE__ */ f(mo, { srv: e, res: y, k: p, n: u.length }, y.name))
318
- ] });
319
- }
320
- const st = 28, Ne = 40, Xe = 24;
321
- function go() {
322
- const e = P(() => new wt(st * 2, Ne), []), t = P(() => le("#fff", !0), []), o = P(() => new Te(st), []), r = P(() => Array.from({ length: Xe }, () => $("#fff")), []), a = V([]), s = P(() => ({ a: new n.Vector3(), b: new n.Vector3(), c: new n.Vector3(), p: new n.Vector3(), col: new n.Color(), k: new n.Color() }), []);
323
- return Y(({ clock: c }) => {
324
- const l = performance.now(), u = X ? 0 : c.elapsedTime;
325
- e.begin(), o.begin();
326
- const { a: b, b: d, c: g, p: v, col: y, k: p } = s, M = (m, w, A, S) => {
327
- const z = re.get(m), C = B.mcpServers.get(w);
328
- if (!z || !C) return;
329
- b.copy(z), Se(C.slot, d), Be(b, d, 1.2, g), y.set(C.color);
330
- let h;
331
- A === 0 ? (y.lerp(ye, N(S / 1.2)), S > 1.2 && y.lerp(Yt, N((S - 1.2) / 1)), h = (0.25 + Math.min(0.6, S * 0.25)) * ke(S / 0.3)) : (y.lerp(te, 0.35), h = 1.2 * (S < 0.75 ? 1 : 1 - (S - 0.75) / 0.25));
332
- const E = 1 - Me(S / 0.75);
333
- for (let G = 0; G < 2; G++) {
334
- const k = e.next();
335
- if (k < 0) return;
336
- const T = G ? 0.045 : 0;
337
- for (let O = 0; O < Ne; O++)
338
- for (let H = 0; H < 2; H++) {
339
- const q = (O + H) / Ne;
340
- oe(b, g, d, q, v), e.P.setXYZ(k + O * 2 + H, v.x + T, v.y + T, v.z);
341
- let K;
342
- A === 0 ? K = h * (0.22 + Math.pow(Math.max(0, Math.sin(q * 26 - u * 3)), 10) * 1.8) * (G ? 0.3 : 1) : K = h * (0.18 + Math.exp(-(((q - E) / 0.05) ** 2)) * 3.4 * (S < 0.8 ? 1 : 0)) * (G ? 0.5 : 1), e.C.setXYZ(k + O * 2 + H, y.r * K, y.g * K, y.b * K);
343
- }
344
- }
345
- p.copy(y), A === 0 ? o.add(b, g, d, 0.93, 1, 0.45, p, 0.5 + h * 1.3) : o.add(b, g, d, 0.07, -1, 0.6, p, h * 1.5);
346
- };
347
- for (const m of B.mcpPending.values()) M(m.instance, m.server, 0, Ft(m, l));
348
- for (const m of B.mcpCalls) m.phase === "result" && M(m.instance, m.server, 1, N((l - m.start) / m.dur));
349
- e.end(), o.end();
350
- let i = 0;
351
- for (const m of B.mcpCalls) {
352
- if (m.phase !== "call" || i >= Xe) continue;
353
- const w = re.get(m.instance), A = B.mcpServers.get(m.server), S = a.current[i], z = N((l - m.start) / m.dur);
354
- !w || !A || !S || z >= 1 || (b.copy(w), Se(A.slot, d), Be(b, d, 1.2, g), oe(b, g, d, Me(z), v), S.visible = !0, S.position.copy(v), S.scale.setScalar(0.85), r[i].color.set(A.color).lerp(te, 0.4).multiplyScalar(1.5), i++);
355
- }
356
- for (let m = i; m < Xe; m++) a.current[m] && (a.current[m].visible = !1);
357
- }), /* @__PURE__ */ _(Z, { children: [
358
- /* @__PURE__ */ f("lineSegments", { geometry: e.geo, material: t, frustumCulled: !1 }),
359
- /* @__PURE__ */ f("primitive", { object: o.mesh }),
360
- r.map((c, l) => /* @__PURE__ */ f("sprite", { ref: (u) => void (a.current[l] = u), material: c, visible: !1 }, l))
361
- ] });
362
- }
363
- function wo() {
364
- const [e, t] = Ce([]), o = V(-1);
365
- return Y(() => {
366
- B.mcpServers.size !== o.current && (o.current = B.mcpServers.size, t([...B.mcpServers.values()]));
367
- }), /* @__PURE__ */ _(Z, { children: [
368
- e.map((r) => /* @__PURE__ */ f(ho, { srv: r }, r.name)),
369
- /* @__PURE__ */ f(go, {})
370
- ] });
371
- }
372
- const ve = 48, vo = new n.MeshBasicMaterial({ transparent: !0, opacity: 0, depthWrite: !1, colorWrite: !1 }), yo = new n.Vector3(0, 1, 0), He = new n.Vector3(), at = new n.Vector3(), qe = new n.Vector3(), be = 40, Qe = Array.from({ length: be }, () => ({ on: !1, start: 0, size: 1, o: new n.Vector3(), dir: new n.Vector3(), perp: new n.Vector3(), c: new n.Color() }));
373
- let Ke = 0;
374
- function bo(e, t, o, r) {
375
- const a = Qe[Ke];
376
- Ke = (Ke + 1) % be, a.on = !0, a.start = performance.now(), a.size = t, a.o.copy(e), a.dir.copy(e).normalize(), a.dir.lengthSq() < 0.5 && a.dir.set(0, 1, 0), a.dir.x += Math.sin(r * 12.9) * 0.6, a.dir.y += Math.cos(r * 7.3) * 0.6, a.dir.z += 0.35, a.dir.normalize(), a.perp.set(0, 0, 1).cross(a.dir).normalize(), a.perp.lengthSq() < 0.5 && a.perp.set(1, 0, 0), a.c.copy(o).lerp(te, 0.35);
377
- }
378
- function Mo({ inst: e, selected: t, onSelect: o }) {
379
- const r = V(null), a = V(null), s = V(null), c = V(null), l = V(null), u = V(null), b = V(null), d = V(null), g = Je[e.type], v = Rt(e), y = P(
380
- () => ({
381
- core: ee("#fff"),
382
- shell: ee(g),
383
- halo: $(g),
384
- ring: ee(ye),
385
- sel: ee(ue),
386
- flash: $("#fff"),
387
- arrow: ee(g),
388
- field: gt(g, e.subagent ? 0.028 : 0.04),
389
- trail: le("#fff", !0)
390
- }),
391
- [g, e.subagent]
392
- ), p = P(() => {
393
- const w = new n.BufferGeometry();
394
- return w.setAttribute("position", new n.BufferAttribute(new Float32Array(ve * 3), 3)), w.setAttribute("color", new n.BufferAttribute(new Float32Array(ve * 3), 3)), w.boundingSphere = new n.Sphere(new n.Vector3(), 1e4), w;
395
- }, []), M = P(() => Object.assign(new n.Line(p, y.trail), { frustumCulled: !1 }), [p, y.trail]), i = P(() => ({ live: new n.Vector3(), p: new n.Vector3(), ctrl: new n.Vector3(), par: new n.Vector3(), c: new n.Color(), llm: e.llmCalls, ringK: 0, linkK: 0, labelK: 1, seed: e.bornAt % 997 / 997 }), [e]);
396
- Vt(() => (re.set(e.id, i.live), () => {
397
- re.get(e.id) === i.live && re.delete(e.id);
398
- }), [e.id, i]), Y(({ clock: w, camera: A }) => {
399
- var xe, ae;
400
- const S = performance.now(), z = S / 1e3, C = w.elapsedTime;
401
- Ze(e, z, i.live), (xe = r.current) == null || xe.position.copy(i.live);
402
- const h = e.exitAt ? (S - e.exitAt) / 1e3 / (Bt(e) / Tt) : -1, E = It(), G = Ot(e, S), k = h >= 0 ? N(h / 0.8) : 0, T = h < 0 && (e.status === "thinking" || e.status === "spawning"), O = kt(e, S);
403
- let H = !1;
404
- for (const R of B.mcpPending.values()) R.instance === e.id && (H = !0);
405
- const q = X ? 0.5 : 0.5 + 0.5 * Math.sin(C * (T ? 6 : 1.6) + i.seed * 30);
406
- e.llmCalls !== i.llm && (i.llm = e.llmCalls, h < 0 && bo(i.live, e.pulse, g, i.seed + e.llmCalls * 0.37));
407
- const K = ke((S - e.bornAt) / 700), Q = 0.3 * v * E * K * (1 - k * 0.9) * (1 + O * 0.12);
408
- if ((ae = a.current) == null || ae.scale.setScalar(Math.max(1e-4, Q)), i.c.copy(g).multiplyScalar((T ? 1 + q * 0.4 : 0.55 + q * 0.15) + O * 0.5), h >= 0 && i.c.lerp($t, k), y.shell.color.copy(i.c), y.core.color.setScalar((T ? 0.9 : 0.45) * (1 - k) + O * 0.4), s.current && (s.current.scale.setScalar(Math.max(1e-4, E * ((T ? 2.4 : 1.7) * v * K * (1 - k * 0.7) + O * 0.9))), y.halo.color.copy(g).multiplyScalar(((T ? 0.32 : 0.16) + O * 0.25) * G)), u.current) {
409
- const R = h >= 0 && h < 0.9 ? 1 - h / 0.9 : 0;
410
- u.current.visible = R > 0, u.current.scale.setScalar(Math.max(1e-4, E * v * (1.2 + (1 - R) * 3.5))), y.flash.color.copy(e.status === "failed" ? ye : te).multiplyScalar(R * R * 0.9);
411
- }
412
- if (i.ringK += ((H && h < 0 ? 1 : 0) - i.ringK) * 0.1, c.current && (c.current.visible = i.ringK > 0.02, c.current.rotation.set(1.2 + Math.sin(C * 0.8) * 0.3, C * 1.4, 0), c.current.scale.setScalar(Math.max(1e-4, 0.62 * v * E * i.ringK)), y.ring.color.copy(ye).multiplyScalar(1.1 * i.ringK * (0.7 + q * 0.3))), l.current && (l.current.visible = t, l.current.quaternion.copy(A.quaternion), l.current.scale.setScalar(E * (0.8 * v + (X ? 0 : Math.sin(C * 3) * 0.04)))), d.current) {
413
- i.labelK += ((_t(e.id) ? 1 : 0) - i.labelK) * 0.12;
414
- const R = N((S - e.bornAt) / 600) * (1 - N(h / 1.2)) * 0.95 * i.labelK;
415
- d.current.setOpacity(R);
416
- }
417
- const x = p.getAttribute("position"), F = p.getAttribute("color"), U = e.subagent ? 2.2 : 9.5, ne = e.bornAt / 1e3 + (e.subagent ? 0.6 : 1.1), J = (T ? 0.55 : 0.35) * (h >= 0 ? (1 - N((h - 0.4) / 2)) * 1.6 : 1);
418
- for (let R = 0; R < ve; R++) {
419
- const ce = Math.max(Math.min(ne, z), z - R / (ve - 1) * (h >= 0 ? Math.min(U, 1.2 + h) : U));
420
- Ze(e, ce, i.p), x.setXYZ(R, i.p.x, i.p.y, i.p.z);
421
- const de = Math.pow(1 - R / (ve - 1), 1.8) * J;
422
- F.setXYZ(R, (h >= 0 ? ue.r : g.r) * de, (h >= 0 ? ue.g : g.g) * de, (h >= 0 ? ue.b : g.b) * de);
423
- }
424
- x.needsUpdate = !0, F.needsUpdate = !0;
425
- const D = e.parent ? re.get(e.parent) : void 0, me = e.parent ? B.instances.get(e.parent) : void 0, se = !!D && !!me && !me.exitAt && !e.exitAt;
426
- i.linkK += ((se ? 1 : 0) - i.linkK) * (se ? 0.06 : 0.05), D && i.par.copy(D);
427
- const I = y.field.uniforms;
428
- I.uP0.value.copy(i.par), I.uP2.value.copy(i.live), Be(i.par, i.live, e.subagent ? 0.35 : 1.4, i.ctrl), I.uP1.value.copy(i.ctrl);
429
- const W = Me((S - e.bornAt) / 900);
430
- if (I.uGrow.value = e.parent && i.linkK > 0.01 ? W : 0, I.uOpacity.value = (T ? 0.7 : 0.45) * i.linkK, I.uFlow.value = i.linkK, I.uTime.value = X ? 0 : C, I.uHead.value = W < 1 ? W : -1, b.current) {
431
- const R = e.parent && i.linkK > 0.05 && W >= 1;
432
- if (b.current.visible = !!R, R) {
433
- oe(i.par, i.ctrl, i.live, 0.74, He), oe(i.par, i.ctrl, i.live, 0.8, at), b.current.position.copy(He), qe.subVectors(at, He), qe.lengthSq() > 1e-8 && b.current.quaternion.setFromUnitVectors(yo, qe.normalize());
434
- const ce = e.subagent ? 0.11 : 0.15;
435
- b.current.scale.set(ce, ce * 2.6, ce), y.arrow.color.copy(g).multiplyScalar(1.5 * i.linkK);
436
- }
437
- }
438
- });
439
- const m = e.id.split(":")[2];
440
- return /* @__PURE__ */ _(Z, { children: [
441
- /* @__PURE__ */ f("mesh", { geometry: ht, material: y.field, frustumCulled: !1 }),
442
- /* @__PURE__ */ f("mesh", { ref: b, geometry: et, material: y.arrow, visible: !1 }),
443
- /* @__PURE__ */ f("primitive", { object: M }),
444
- /* @__PURE__ */ _("group", { ref: r, children: [
445
- /* @__PURE__ */ _("group", { ref: a, scale: 1e-4, children: [
446
- /* @__PURE__ */ f("mesh", { geometry: Ie, material: y.shell }),
447
- /* @__PURE__ */ f("mesh", { geometry: Ie, material: y.core, scale: 0.55 })
448
- ] }),
449
- /* @__PURE__ */ f(
450
- "mesh",
451
- {
452
- geometry: Ie,
453
- material: vo,
454
- scale: Math.max(0.55, 0.62 * v),
455
- onClick: (w) => {
456
- w.stopPropagation(), o(e.id);
457
- },
458
- onPointerOver: () => document.body.style.cursor = "pointer",
459
- onPointerOut: () => document.body.style.cursor = ""
460
- }
461
- ),
462
- /* @__PURE__ */ f("sprite", { ref: s, material: y.halo }),
463
- /* @__PURE__ */ f("sprite", { ref: u, material: y.flash, visible: !1 }),
464
- /* @__PURE__ */ f("mesh", { ref: c, geometry: nt, material: y.ring, visible: !1 }),
465
- /* @__PURE__ */ f("mesh", { ref: l, geometry: nt, material: y.sel, visible: !1 }),
466
- /* @__PURE__ */ f(
467
- Ae,
468
- {
469
- ref: d,
470
- position: e.subagent ? [0.22, 0, 0] : [0, 0.62 * v + 0.2, 0],
471
- anchorX: e.subagent ? "left" : "center",
472
- offset: e.subagent ? [0.1, 0] : void 0,
473
- text: `${e.name}${m !== void 0 ? ` ${Number(m) + 1}` : ""}`,
474
- color: ft[e.type],
475
- size: e.subagent ? 0.22 : 0.28,
476
- opacity: 0,
477
- pxRange: e.subagent ? [8, 11.5] : [9, 13]
478
- }
479
- )
480
- ] })
481
- ] });
482
- }
483
- function So({ selected: e, onSelect: t }) {
484
- const [o, r] = Ce([]), a = V(/* @__PURE__ */ new Set()), s = V(-1);
485
- return Y(() => {
486
- const c = B.instances;
487
- let l = c.size !== a.current.size || s.current !== fe.version;
488
- if (!l)
489
- for (const u of c.keys()) a.current.has(u) || (l = !0);
490
- l && (a.current = new Set(c.keys()), s.current = fe.version, r([...c.values()].filter(Gt)));
491
- }), /* @__PURE__ */ f(Z, { children: o.map((c) => /* @__PURE__ */ f(Mo, { inst: c, selected: e === c.id, onSelect: t }, c.id)) });
492
- }
493
- const pe = 36, ct = 1.5;
494
- function Co() {
495
- const e = P(() => {
496
- const s = new n.BufferGeometry();
497
- return s.setAttribute("position", new n.BufferAttribute(new Float32Array(be * pe * 6), 3)), s.setAttribute("color", new n.BufferAttribute(new Float32Array(be * pe * 6), 3)), s.boundingSphere = new n.Sphere(new n.Vector3(), 1e4), s;
498
- }, []), t = P(() => le("#fff", !0), []), o = P(() => Qe.map(() => $("#fff")), []), r = V([]), a = P(() => new n.Vector3(), []);
499
- return Y(() => {
500
- const s = performance.now(), c = e.getAttribute("position"), l = e.getAttribute("color");
501
- let u = 0;
502
- for (let b = 0; b < be; b++) {
503
- const d = Qe[b], g = r.current[b], v = (s - d.start) / 1e3;
504
- if (!d.on || v > ct) {
505
- d.on = !1, g && (g.visible = !1);
506
- continue;
507
- }
508
- if (g) {
509
- const w = Math.max(0, 1 - v / 0.55);
510
- g.visible = w > 0, g.position.copy(d.o), g.scale.setScalar(Math.max(1e-4, (0.8 + d.size * 1.5) * (0.6 + (1 - w) * 0.8))), o[b].color.copy(d.c).multiplyScalar(w * w * 1.1);
511
- }
512
- const y = 1 - v / ct, p = 0.4 + v * 7.5, M = 1.2 + d.size * 1.1, i = 0.1 + d.size * 0.07, m = u * pe * 2;
513
- for (let w = 0; w < pe; w++)
514
- for (let A = 0; A < 2; A++) {
515
- const S = (w + A) / pe, z = Math.max(0, p - M * (1 - S)), C = Math.sin(Math.PI * S), h = Math.sin(S * Math.PI * 2 * (3 + d.size)) * i * C;
516
- a.copy(d.o).addScaledVector(d.dir, z).addScaledVector(d.perp, h), c.setXYZ(m + w * 2 + A, a.x, a.y, a.z);
517
- const E = C * y * 1.4;
518
- l.setXYZ(m + w * 2 + A, d.c.r * E, d.c.g * E, d.c.b * E);
519
- }
520
- u++;
521
- }
522
- e.setDrawRange(0, u * pe * 2), c.needsUpdate = !0, l.needsUpdate = !0;
523
- }), /* @__PURE__ */ _(Z, { children: [
524
- /* @__PURE__ */ f("lineSegments", { geometry: e, material: t, frustumCulled: !1 }),
525
- o.map((s, c) => /* @__PURE__ */ f("sprite", { ref: (l) => void (r.current[c] = l), material: s, visible: !1 }, c))
526
- ] });
527
- }
528
- const We = 24;
529
- function Ao() {
530
- const e = P(() => Array.from({ length: We }, () => $("#fff")), []), t = V([]), o = P(() => ({ c: new n.Vector3(), h: new n.Vector3() }), []);
531
- return Y(() => {
532
- const r = performance.now();
533
- let a = 0;
534
- for (const s of B.comets) {
535
- if (a >= We) break;
536
- const c = re.get(s.from), l = re.get(s.to), u = t.current[a];
537
- if (!c || !l || !u) continue;
538
- const b = N((r - s.start) / s.dur);
539
- if (b >= 1) continue;
540
- Be(c, l, 1, o.c), oe(c, o.c, l, Me(b), o.h), u.visible = !0, u.position.copy(o.h), u.scale.setScalar(0.9);
541
- const d = B.instances.get(s.from);
542
- e[a].color.copy(d ? Je[d.type] : ue).lerp(te, 0.4).multiplyScalar(1.4 * Math.sin(Math.PI * b) + 0.2), a++;
543
- }
544
- for (let s = a; s < We; s++) t.current[s] && (t.current[s].visible = !1);
545
- }), /* @__PURE__ */ f(Z, { children: e.map((r, a) => /* @__PURE__ */ f("sprite", { ref: (s) => void (t.current[a] = s), material: r, visible: !1 }, a)) });
546
- }
547
- const xo = 140, je = 0.31, lt = 40, Ye = 18, $e = 5, Ee = 4, Po = (
548
- /* glsl */
549
- `
550
- attribute vec3 aCol; attribute float aFire;
551
- varying vec3 vN; varying vec3 vV; varying vec3 vC; varying float vF;
552
- void main(){
553
- vec4 mv = modelViewMatrix * instanceMatrix * vec4(position, 1.0);
554
- vN = normalize(normalMatrix * mat3(instanceMatrix) * normal);
555
- vV = normalize(-mv.xyz); vC = aCol; vF = aFire;
556
- gl_Position = projectionMatrix * mv;
557
- }`
558
- ), Vo = (
559
- /* glsl */
560
- `
561
- varying vec3 vN; varying vec3 vV; varying vec3 vC; varying float vF;
562
- void main(){
563
- vec3 n = normalize(vN);
564
- vec3 L = normalize(vec3(-0.45, 0.65, 0.6));
565
- float d = max(dot(n, L), 0.0);
566
- float rim = pow(1.0 - abs(dot(n, normalize(vV))), 2.4);
567
- float spec = pow(max(dot(reflect(-L, n), normalize(vV)), 0.0), 28.0);
568
- vec3 col = vC * (0.10 + 0.55 * d) + vC * rim * 0.75 + vec3(spec) * 0.35;
569
- col += vC * vF * 1.8 + vec3(1.0) * vF * vF * 0.9;
570
- gl_FragColor = vec4(col, 1.0);
571
- }`
572
- ), zo = () => new n.ShaderMaterial({
573
- uniforms: { uColor: { value: new n.Color() } },
574
- vertexShader: (
575
- /* glsl */
576
- `varying vec3 vN; varying vec3 vV;
577
- void main(){ vec4 mv = modelViewMatrix * vec4(position,1.0); vN = normalize(normalMatrix*normal); vV = normalize(-mv.xyz); gl_Position = projectionMatrix*mv; }`
578
- ),
579
- fragmentShader: (
580
- /* glsl */
581
- `uniform vec3 uColor; varying vec3 vN; varying vec3 vV;
582
- void main(){ float f = pow(1.0 - abs(dot(normalize(vN), normalize(vV))), 3.0); gl_FragColor = vec4(uColor * f, 1.0); }`
583
- ),
584
- transparent: !0,
585
- depthWrite: !1,
586
- blending: n.AdditiveBlending
587
- }), Eo = new n.SphereGeometry(1, 48, 32);
588
- function Fo({ galaxy: e }) {
589
- const t = P(() => ({ nodes: e.nodes.slice(0, xo), links: [] }), [e]), o = t.nodes.length, r = P(() => {
590
- const p = new Float32Array(o * 3), M = Math.PI * (3 - Math.sqrt(5));
591
- for (let C = 0; C < o; C++) {
592
- const h = (he - je * 0.6) * Math.cbrt(1 - C / o), E = 1 - 2 * (C + 0.5) / o, G = Math.sqrt(1 - E * E);
593
- p.set([Math.cos(C * M) * G * h, E * h, Math.sin(C * M) * G * h], C * 3);
594
- }
595
- const i = t.nodes.map((C, h) => {
596
- let E = 7;
597
- for (const k of C.kind) E = E * 31 + k.charCodeAt(0) >>> 0;
598
- return ((E + h) % 2 === 0 ? Re : mt).clone().lerp(te, 0.08 + h * 37 % 10 / 70).multiplyScalar(0.85);
599
- }), m = new n.SphereGeometry(1, 20, 14), w = new n.InstancedBufferAttribute(new Float32Array(o * 3), 3), A = new n.InstancedBufferAttribute(new Float32Array(o), 1);
600
- m.setAttribute("aCol", w), m.setAttribute("aFire", A);
601
- const S = new n.InstancedMesh(m, new n.ShaderMaterial({ vertexShader: Po, fragmentShader: Vo }), o);
602
- S.frustumCulled = !1;
603
- const z = new n.Object3D();
604
- for (let C = 0; C < o; C++)
605
- z.position.set(p[C * 3], p[C * 3 + 1], p[C * 3 + 2]), z.scale.setScalar(je), z.updateMatrix(), S.setMatrixAt(C, z.matrix), w.setXYZ(C, i[C].r, i[C].g, i[C].b);
606
- return { pos: p, base: i, mesh: S, aCol: w, aFire: A, o: z, fire: new Float32Array(o), fireC: Array.from({ length: o }, () => new n.Color()) };
607
- }, [t, o]), a = P(
608
- () => ({
609
- beam: le("#fff", !0),
610
- core: $(new n.Color("#7a5cff").multiplyScalar(0.35)),
611
- cloud: $(new n.Color("#1d4ed8").multiplyScalar(0.22)),
612
- waves: Array.from({ length: $e }, zo)
613
- }),
614
- []
615
- ), s = P(() => new wt(lt, Ye), []), c = P(() => new Te(lt), []), l = V([]), u = V([]), b = V([]), d = V(Array(Ee).fill("")), g = P(() => /* @__PURE__ */ new Map(), [t]), v = P(() => ({ v: new n.Vector3(), mid: new n.Vector3(), p: new n.Vector3(), c: new n.Color(), c2: new n.Color() }), []), y = (p) => {
616
- let M = g.get(p);
617
- return M === void 0 && g.set(p, M = Ut(e, p) % o), M;
618
- };
619
- return Y(({ clock: p }) => {
620
- if (!o) return;
621
- const M = performance.now(), i = p.elapsedTime, { pos: m, base: w, fire: A, fireC: S, mesh: z, aCol: C, aFire: h, o: E } = r;
622
- A.fill(0);
623
- const { v: G, mid: k, p: T, c: O, c2: H } = v;
624
- s.begin(), c.begin();
625
- let q = 0;
626
- for (const x of B.flares) {
627
- const F = y(x.node), U = (M - x.start) / 1e3, ne = B.instances.get(x.instance), J = x.op === "write", D = J ? ot : ne ? Je[ne.type] : ue, me = U < 0.3 ? U / 0.3 : Math.exp(-(U - 0.3) * 1.3);
628
- if (me > A[F] && (A[F] = me, S[F].copy(J ? te : D)), J && U < 1.6 && q < $e) {
629
- const I = l.current[q];
630
- if (I) {
631
- const W = U / 1.6;
632
- I.visible = !0, I.scale.setScalar(he * (1.05 + W * 1.9)), I.material.uniforms.uColor.value.copy(Re).lerp(te, 0.3).multiplyScalar(0.9 * (1 - W) * (1 - W));
633
- }
634
- q++;
635
- }
636
- const se = re.get(x.instance);
637
- if (se && U < 2) {
638
- const I = s.next();
639
- if (I < 0) continue;
640
- G.set(m[F * 3], m[F * 3 + 1], m[F * 3 + 2]), k.copy(se).add(G).multiplyScalar(0.5), k.z += 0.8;
641
- const W = Math.min(1, U / 0.2) * Math.pow(1 - U / 2, 1.6), xe = J ? Math.min(1, U * 1.1) : 1 - Math.min(1, U * 1.1);
642
- for (let ae = 0; ae < Ye; ae++)
643
- for (let R = 0; R < 2; R++) {
644
- const ce = (ae + R) / Ye;
645
- oe(se, k, G, ce, T), s.P.setXYZ(I + ae * 2 + R, T.x, T.y, T.z);
646
- const de = Math.exp(-(((ce - xe) / 0.07) ** 2)) * 2.2;
647
- H.copy(D).multiplyScalar(W * (0.18 + de) * 0.8), s.C.setXYZ(I + ae * 2 + R, H.r, H.g, H.b);
648
- }
649
- J ? c.add(se, k, G, 0.86, 1, 0.38, ot, W * 1.4) : c.add(se, k, G, 0.12, -1, 0.38, D, W * 1.4);
650
- }
651
- }
652
- for (let x = q; x < $e; x++) l.current[x] && (l.current[x].visible = !1);
653
- s.end(), c.end();
654
- const K = X ? 0 : 0.025;
655
- for (let x = 0; x < o; x++) {
656
- const F = A[x];
657
- O.copy(w[x]), F > 0.01 && no(O.multiplyScalar(1 - F * 0.5), S[x], F * 0.9), C.setXYZ(x, O.r, O.g, O.b), h.setX(x, F), E.position.set(m[x * 3] + Math.sin(i * 2.1 + x * 1.7) * K, m[x * 3 + 1] + Math.cos(i * 1.8 + x * 2.3) * K, m[x * 3 + 2] + Math.sin(i * 1.6 + x) * K), E.scale.setScalar(je * (1 + F * 0.35)), E.updateMatrix(), z.setMatrixAt(x, E.matrix);
658
- }
659
- z.instanceMatrix.needsUpdate = !0, C.needsUpdate = !0, h.needsUpdate = !0;
660
- let Q = 0;
661
- for (let x = B.flares.length - 1; x >= 0 && Q < Ee; x--) {
662
- const F = B.flares[x];
663
- if (M - F.start > 2200) break;
664
- let U = !1;
665
- for (let D = 0; D < Q; D++) d.current[D] === F.node && (U = !0);
666
- if (U) continue;
667
- const ne = u.current[Q], J = b.current[Q];
668
- if (ne && J) {
669
- const D = y(F.node);
670
- J.position.set(m[D * 3], m[D * 3 + 1], m[D * 3 + 2]), d.current[Q] !== F.node && (ne.setText(`${F.op === "write" ? "wrote" : "read"} · ${F.node}`), ne.setColor(F.op === "write" ? "#ff9ccf" : "#7dd3fc")), ne.setOpacity(1);
671
- }
672
- d.current[Q] = F.node, Q++;
673
- }
674
- for (let x = Q; x < Ee; x++) {
675
- const F = u.current[x];
676
- F == null || F.setOpacity(0), d.current[x] = "";
677
- }
678
- }), /* @__PURE__ */ _(Z, { children: [
679
- /* @__PURE__ */ f("sprite", { material: a.cloud, scale: he * 7, position: [0, 0, -1] }),
680
- /* @__PURE__ */ f("sprite", { material: a.core, scale: he * 3.2 }),
681
- /* @__PURE__ */ f("primitive", { object: r.mesh }),
682
- a.waves.map((p, M) => /* @__PURE__ */ f("mesh", { ref: (i) => void (l.current[M] = i), geometry: Eo, material: p, visible: !1 }, M)),
683
- /* @__PURE__ */ f("lineSegments", { geometry: s.geo, material: a.beam, frustumCulled: !1 }),
684
- /* @__PURE__ */ f("primitive", { object: c.mesh }),
685
- Array.from({ length: Ee }, (p, M) => /* @__PURE__ */ f("group", { ref: (i) => void (b.current[M] = i), children: /* @__PURE__ */ f(Ae, { ref: (i) => void (u.current[M] = i), text: "", font: "mono", anchorX: "left", offset: [0.9, 0.35], size: 0.24, opacity: 0, fadeMs: 250, pxRange: [8, 11.5] }) }, M)),
686
- /* @__PURE__ */ f(Lt, { position: [0, -he - 0.85, 0], prefix: "nucleus · ", font: "mono", color: "#ff4fa8", letterSpacing: 0.04, size: 0.26, opacity: 0.75, pxRange: [8.5, 12] })
687
- ] });
688
- }
689
- const Fe = 200, it = 420, Ge = /* @__PURE__ */ new Map(), Go = new n.OctahedronGeometry(0.2, 0);
690
- function Ro({ run: e }) {
691
- const t = yt(e.id), o = P(() => new n.Color(e.color).lerp(e.slot % 2 ? Re : mt, 0.45), [e.color, e.slot]), r = P(() => {
692
- const d = new n.BufferGeometry(), g = new Float32Array((Fe + 1) * 3);
693
- for (let p = 0; p <= Fe; p++) {
694
- const M = p / Fe * Math.PI * 2;
695
- g.set([Math.cos(M), Math.sin(M), 0], p * 3);
696
- }
697
- d.setAttribute("position", new n.BufferAttribute(g, 3));
698
- const v = new Float32Array(it * 3);
699
- for (let p = 0; p < it; p++) {
700
- const M = L(e.id, 100 + p) * Math.PI * 2, i = L(e.id, 900 + p) + L(e.id, 1700 + p) - 1, m = L(e.id, 2500 + p) + L(e.id, 3300 + p) - 1, w = 1 + i * 0.07;
701
- v.set([Math.cos(M) * w, Math.sin(M) * w, m * 0.06], p * 3);
702
- }
703
- const y = new n.BufferGeometry();
704
- return y.setAttribute("position", new n.BufferAttribute(v, 3)), { loop: d, cloud: y, glow: new n.TorusGeometry(1, 35e-4, 4, 220) };
705
- }, [e.id]), a = P(
706
- () => ({
707
- line: le(o),
708
- glow: ee(o),
709
- cloud: new n.PointsMaterial({ map: dt(), color: o, size: 0.22, sizeAttenuation: !0, transparent: !0, depthWrite: !1, blending: n.AdditiveBlending, toneMapped: !1 }),
710
- beads: _e.map(() => ee("#fff"))
711
- }),
712
- [o]
713
- ), s = V(null), c = V(null), l = V([]), u = P(() => {
714
- const d = e.slot * 1.05 + 0.5 + L(e.id, 6) * 0.4, g = new n.Vector2(Math.cos(d), Math.sin(d)), v = new n.Vector3();
715
- for (const i of Ge.keys()) B.runs.has(i) || Ge.delete(i);
716
- let y = -1e9, p = 0;
717
- for (let i = 0; i < 120; i++) {
718
- const m = i / 120 * Math.PI * 2;
719
- Le(t, m, t.r, v);
720
- let w = (v.x * g.x + v.y * g.y) / t.r + v.z * 0.02;
721
- for (const [A, S] of Ge) A !== e.id && (w -= 3 * Math.max(0, 1 - Math.hypot((v.x - S.x) / 9, (v.y - S.y) / 2.4)));
722
- v.y > 6 && Math.abs(v.x) > 7 && (w -= 1.5), w > y && (y = w, p = m);
723
- }
724
- const M = Le(t, p, t.r, new n.Vector3());
725
- return Ge.set(e.id, M), { angle: p, pos: M };
726
- }, [e.id, e.slot, t]), b = P(() => _e.map((d, g) => Le(t, u.angle + (g - 1) * (0.5 / Math.max(1, t.r / 6)), t.r, new n.Vector3())), [t, u]);
727
- return Y(({ clock: d }) => {
728
- const g = performance.now(), v = ke((g - e.startedAt) / 1400), y = e.endedAt ? N(1 - (g - e.endedAt - (Nt - 2600)) / 2600) : 1, p = X ? 1 : 0.88 + 0.12 * Math.sin(d.elapsedTime * 0.7 + e.slot), M = e.status === "started" ? 1 : 0.55;
729
- r.loop.setDrawRange(0, Math.max(2, Math.floor((Fe + 1) * v))), a.line.color.copy(o).multiplyScalar(0.75 * y * M * p), a.glow.color.copy(o).multiplyScalar(0.35 * y * M), a.cloud.color.copy(o).multiplyScalar(0.3 * y * v * p), c.current && (c.current.rotation.z = X ? 0 : d.elapsedTime * 0.02 * t.dir), s.current && s.current.scale.setScalar(t.r * (0.94 + 0.06 * v)), _e.forEach((i, m) => {
730
- const w = l.current[m];
731
- if (!w || (w.visible = e.hasSteps, !e.hasSteps)) return;
732
- const A = e.steps[i], S = 0.5 + 0.5 * Math.sin(d.elapsedTime * 4);
733
- w.scale.setScalar(A === "running" ? 1.25 + S * 0.3 : 1), w.rotation.y = X ? 0 : d.elapsedTime * 0.8, a.beads[m].color.copy(A === "running" ? ye : A === "done" ? ue : A === "failed" ? Re : o).multiplyScalar((A === "queued" ? 0.35 : A === "running" ? 1.2 + S * 0.6 : 0.9) * y);
734
- });
735
- }), /* @__PURE__ */ _(Z, { children: [
736
- /* @__PURE__ */ f("group", { quaternion: t.q, children: /* @__PURE__ */ _("group", { ref: s, scale: t.r, children: [
737
- /* @__PURE__ */ f("lineLoop", { geometry: r.loop, material: a.line }),
738
- /* @__PURE__ */ f("mesh", { geometry: r.glow, material: a.glow }),
739
- /* @__PURE__ */ f("points", { ref: c, geometry: r.cloud, material: a.cloud })
740
- ] }) }),
741
- b.map((d, g) => /* @__PURE__ */ f("mesh", { ref: (v) => void (l.current[g] = v), geometry: Go, material: a.beads[g], position: d, visible: !1 }, g)),
742
- /* @__PURE__ */ f(Bo, { run: e, pos: u.pos, color: `#${o.getHexString()}` })
743
- ] });
744
- }
745
- function Bo({ run: e, pos: t, color: o }) {
746
- Xt();
747
- const r = e.status !== "started";
748
- let a = 0;
749
- for (const c of B.instances.values()) c.run === e.id && !c.exitAt && a++;
750
- const s = e.hasSteps ? [...Ht(e, { base: "#9fb3d1", current: "#ffc24a", done: "#cfe9ff" })] : [{ text: `shell n=${(fe.grouped ? e.slot % 6 : e.slot) + 1}`, color: "#9fb3d1" }];
751
- return s.push({ text: r ? " · complete" : ` · ${a} e-`, color: "#9fb3d1" }), /* @__PURE__ */ f(
752
- Ae,
753
- {
754
- position: t,
755
- offset: [0, 0.55],
756
- text: e.topic,
757
- secondary: s,
758
- color: o,
759
- size: 0.32,
760
- secondarySize: 0.25,
761
- maxWidth: 10,
762
- opacity: r ? 0.5 : 0.95,
763
- fadeMs: 400,
764
- pxRange: [10, 14]
765
- }
766
- );
767
- }
768
- function To() {
769
- const [e, t] = Ce([]), o = V(/* @__PURE__ */ new Set()), r = V(-1);
770
- return Y(() => {
771
- const a = B.runs;
772
- let s = a.size !== o.current.size || r.current !== fe.version;
773
- if (!s)
774
- for (const c of a.keys()) o.current.has(c) || (s = !0);
775
- s && (o.current = new Set(a.keys()), r.current = fe.version, t([...a.values()].filter((c) => Dt(c.id))));
776
- }), /* @__PURE__ */ f(Z, { children: e.map((a) => /* @__PURE__ */ f(Ro, { run: a }, a.id)) });
777
- }
778
- function Oo() {
779
- return Y(() => {
780
- Wt(), jt();
781
- }), null;
782
- }
783
- function ko() {
784
- const e = P(() => {
785
- const o = [], r = (s, c) => o.push(...s, ...c);
786
- for (const s of [4, 8, 12, 16, 20, 24])
787
- for (let l = 0; l < 160; l++) {
788
- if (s > 4 && l % 4 === 3) continue;
789
- const u = l / 160 * Math.PI * 2, b = (l + 1) / 160 * Math.PI * 2;
790
- r([Math.cos(u) * s, Math.sin(u) * s, 0], [Math.cos(b) * s, Math.sin(b) * s, 0]);
791
- }
792
- for (let s = 0; s < 72; s++) {
793
- const c = s / 72 * Math.PI * 2, l = 24, u = s % 6 === 0 ? 25.2 : 24.5;
794
- r([Math.cos(c) * l, Math.sin(c) * l, 0], [Math.cos(c) * u, Math.sin(c) * u, 0]), s % 6 === 0 && r([Math.cos(c) * 3, Math.sin(c) * 3, 0], [Math.cos(c) * 24, Math.sin(c) * 24, 0]);
795
- }
796
- const a = new n.BufferGeometry();
797
- return a.setAttribute("position", new n.Float32BufferAttribute(o, 3)), a;
798
- }, []), t = P(() => le(new n.Color("#3db8ff").multiplyScalar(0.075)), []);
799
- return /* @__PURE__ */ f("lineSegments", { geometry: e, material: t, position: [0, 0, -9] });
800
- }
801
- function qo() {
802
- const e = qt(), [t, o] = Ce(null);
803
- return /* @__PURE__ */ _("div", { className: "scene-root", style: { background: "#02040c" }, children: [
804
- /* @__PURE__ */ f("style", { children: '.atom-mono{font-family:"JetBrains Mono","SF Mono",ui-monospace,Menlo,monospace;}' }),
805
- /* @__PURE__ */ _(Ct, { camera: { position: [0, 3.5, 36], fov: 46 }, dpr: [1, 2], gl: { antialias: !0, powerPreference: "high-performance" }, onPointerMissed: () => o(null), children: [
806
- /* @__PURE__ */ f("color", { attach: "background", args: ["#02040c"] }),
807
- /* @__PURE__ */ f(Oo, {}),
808
- /* @__PURE__ */ _("group", { position: [-2.4, 0, 0], children: [
809
- /* @__PURE__ */ f(ko, {}),
810
- /* @__PURE__ */ f(Fo, { galaxy: e }),
811
- /* @__PURE__ */ f(To, {}),
812
- /* @__PURE__ */ f(So, { selected: t, onSelect: o }),
813
- /* @__PURE__ */ f(Co, {}),
814
- /* @__PURE__ */ f(Ao, {}),
815
- /* @__PURE__ */ f(wo, {}),
816
- /* @__PURE__ */ f(co, {})
817
- ] }),
818
- /* @__PURE__ */ f(St, { makeDefault: !0, enablePan: !1, enableDamping: !0, dampingFactor: 0.07, minDistance: 12, maxDistance: 70 }),
819
- /* @__PURE__ */ _(At, { multisampling: 0, children: [
820
- /* @__PURE__ */ f(xt, { mipmapBlur: !0, intensity: 1.05, luminanceThreshold: 0.22, luminanceSmoothing: 0.25, radius: 0.7 }),
821
- /* @__PURE__ */ f(Pt, { eskil: !1, offset: 0.25, darkness: 0.85 })
822
- ] })
823
- ] }),
824
- /* @__PURE__ */ f(
825
- Kt,
826
- {
827
- title: "atom · agent orbitals",
828
- subtitle: "Knowledge graph = nucleus (nucleons light on read/write) · each run is an orbital shell · agents are electrons, subagents orbit their parent · LLM calls emit photons sized by tokens · ◎ MCP detectors with backend sensors · exit = decay",
829
- selected: t,
830
- onClose: () => o(null)
831
- }
832
- )
833
- ] });
834
- }
835
- export {
836
- qo as default
837
- };