agentglow 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +38 -3
  2. package/dist/chunks/KitScene-BuFtYuhc.js +2737 -0
  3. package/dist/chunks/index-BPyTLdiF.js +792 -0
  4. package/dist/chunks/index-Bo5HRf-O.js +784 -0
  5. package/dist/chunks/index-C42Ihyo1.js +605 -0
  6. package/dist/chunks/index-C5YqtHnC.js +677 -0
  7. package/dist/chunks/index-Cyv7bII1.js +818 -0
  8. package/dist/chunks/index-D0UvupqM.js +1143 -0
  9. package/dist/chunks/index-D733n3Hf.js +1086 -0
  10. package/dist/chunks/index-DCmhxN8v.js +1010 -0
  11. package/dist/chunks/index-DO9SAG-u.js +753 -0
  12. package/dist/chunks/index-Dn6oRasS.js +887 -0
  13. package/dist/chunks/index-HyfZ0ePz.js +838 -0
  14. package/dist/chunks/index-XMOz-HBf.js +492 -0
  15. package/dist/chunks/index-ZT88hgW-.js +763 -0
  16. package/dist/chunks/index-e6egU2Q6.js +889 -0
  17. package/dist/chunks/index-jLXx_Wgk.js +68 -0
  18. package/dist/chunks/index-tonipLb2.js +980 -0
  19. package/dist/index.js +1 -1
  20. package/dist/style.css +1 -1
  21. package/dist/types/AgentScene.d.ts +14 -1
  22. package/dist/types/world.d.ts +59 -0
  23. package/package.json +1 -1
  24. package/dist/chunks/ClusterBall-CPsd6JvJ.js +0 -1489
  25. package/dist/chunks/index-0Bqa57T_.js +0 -786
  26. package/dist/chunks/index-4JCQqMml.js +0 -831
  27. package/dist/chunks/index-55W5crSg.js +0 -63
  28. package/dist/chunks/index-78lWZCrQ.js +0 -984
  29. package/dist/chunks/index-Bv6_kdaq.js +0 -768
  30. package/dist/chunks/index-Cgb5ir1r.js +0 -688
  31. package/dist/chunks/index-CqVCWpP7.js +0 -796
  32. package/dist/chunks/index-D1O5v601.js +0 -1065
  33. package/dist/chunks/index-DOoA9htC.js +0 -1181
  34. package/dist/chunks/index-K__sPGRy.js +0 -1134
  35. package/dist/chunks/index-N0zWN8NS.js +0 -857
  36. package/dist/chunks/index-NiYqQci9.js +0 -936
  37. package/dist/chunks/index-PQRnbPiJ.js +0 -565
  38. package/dist/chunks/index-VOXn1m-Q.js +0 -848
  39. package/dist/chunks/index-o4vs5msj.js +0 -837
  40. package/dist/chunks/index-yos7IepY.js +0 -890
  41. package/dist/chunks/spread-CWdeDFd9.js +0 -35
@@ -0,0 +1,753 @@
1
+ import { jsxs as G, jsx as s, Fragment as Re } from "react/jsx-runtime";
2
+ import { EffectComposer as ht, Bloom as mt, ChromaticAberration as Mt, Vignette as gt, Noise as yt } from "@react-three/postprocessing";
3
+ import { useMemo as x, useRef as w, useEffect as Je, useState as wt } from "react";
4
+ import * as e from "three";
5
+ import { useFrame as te, useThree as ot } from "@react-three/fiber";
6
+ import { k as Pe, K as st, w as Q, a as he, m as xt, G as bt, L as et, n as St, c as Qe, d as At, T as tt, R as vt, S as Se, x as Le, f as Fe, p as Ct, e as ut, j as Bt, q as Gt } from "./KitScene-BuFtYuhc.js";
7
+ var dt;
8
+ const Ve = typeof window < "u" && !!((dt = window.matchMedia) != null && dt.call(window, "(prefers-reduced-motion: reduce)").matches), $ = Ve ? 0.15 : 1, re = 7, Oe = 1.3, ue = { speed: 1, paused: !1 }, we = { ax: re, ay: re }, xe = /* @__PURE__ */ new Map(), We = (r) => 1 - Math.pow(1 - Math.min(1, Math.max(0, r)), 3);
9
+ let Ie = null;
10
+ function nt() {
11
+ if (Ie) return Ie;
12
+ const r = document.createElement("canvas");
13
+ r.width = r.height = 128;
14
+ const n = r.getContext("2d"), o = n.createRadialGradient(64, 64, 0, 64, 64, 64);
15
+ 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), Ie = new e.CanvasTexture(r), Ie;
16
+ }
17
+ let ze = null;
18
+ function Tt() {
19
+ if (ze) return ze;
20
+ const r = document.createElement("canvas");
21
+ r.width = r.height = 128;
22
+ const n = r.getContext("2d");
23
+ n.translate(64, 64);
24
+ const o = (l, a, u) => {
25
+ n.save(), n.rotate(u);
26
+ const h = n.createLinearGradient(-l, 0, l, 0);
27
+ h.addColorStop(0, "rgba(255,255,255,0)"), h.addColorStop(0.5, "rgba(255,255,255,1)"), h.addColorStop(1, "rgba(255,255,255,0)"), n.fillStyle = h, n.beginPath(), n.moveTo(-l, 0), n.lineTo(0, -a), n.lineTo(l, 0), n.lineTo(0, a), n.closePath(), n.fill(), n.restore();
28
+ };
29
+ o(62, 3.2, 0), o(62, 3.2, Math.PI / 2), o(36, 2, Math.PI / 4), o(36, 2, -Math.PI / 4);
30
+ const i = n.createRadialGradient(0, 0, 0, 0, 0, 20);
31
+ return i.addColorStop(0, "rgba(255,255,255,1)"), i.addColorStop(1, "rgba(255,255,255,0)"), n.fillStyle = i, n.fillRect(-20, -20, 40, 40), ze = new e.CanvasTexture(r), ze;
32
+ }
33
+ const me = -215, pt = () => Te.camZ + 4;
34
+ function Et({ children: r }) {
35
+ const n = w(null), o = ot((l) => l.camera), i = ot((l) => l.scene);
36
+ return te((l, a) => {
37
+ var f;
38
+ const u = Math.min(a, 0.1);
39
+ ue.speed += ((ue.paused ? 0 : 1) - ue.speed) * Math.min(1, u * 2.5);
40
+ const h = Pe.core;
41
+ let c = Math.max(re * 0.85, h.hw + 2.6), y = Math.max(re * 0.85, h.hh + 2.6);
42
+ c = Math.max(c, y * 0.6), y = Math.max(y, c * 0.5), we.ax = c, we.ay = y, (f = n.current) == null || f.scale.set(c / re, y / re, 1), Te.camZ = o.position.z;
43
+ const m = i.fog;
44
+ m && (m.near = Math.max(10, Te.camZ + 8), m.far = Te.camZ + 200);
45
+ }), /* @__PURE__ */ s("group", { ref: n, children: r });
46
+ }
47
+ const Te = { camZ: 30 };
48
+ function Rt() {
49
+ const n = w(null), o = x(() => new e.Object3D(), []), i = x(() => new e.Color(), []), l = x(() => [new e.Color("#4f46e5"), new e.Color("#22d3ee"), new e.Color("#7c3aed")], []), a = w(0);
50
+ return te((u, h) => {
51
+ const c = n.current;
52
+ if (!c) return;
53
+ const y = pt() - me;
54
+ a.current = (a.current + Math.min(h, 0.1) * 3.5 * $ * ue.speed) % y;
55
+ const m = y / 48;
56
+ for (let f = 0; f < 48; f++) {
57
+ const B = me + (f * m + a.current) % y;
58
+ o.position.set(0, 0, B), o.rotation.set(0, 0, 0), o.scale.setScalar(1), o.updateMatrix(), c.setMatrixAt(f, o.matrix);
59
+ const R = f % 4 === 0, v = Math.min(1, Math.max(0, (Te.camZ + 2 - B) / 10));
60
+ i.copy(l[f % 3]).multiplyScalar((R ? 1.5 : 0.55) * v), c.setColorAt(f, i);
61
+ }
62
+ c.instanceMatrix.needsUpdate = !0, c.instanceColor && (c.instanceColor.needsUpdate = !0);
63
+ }), /* @__PURE__ */ G("instancedMesh", { ref: n, args: [void 0, void 0, 48], frustumCulled: !1, children: [
64
+ /* @__PURE__ */ s("torusGeometry", { args: [re, 0.03, 4, 120] }),
65
+ /* @__PURE__ */ s("meshBasicMaterial", { toneMapped: !1, transparent: !0, opacity: 0.85, blending: e.AdditiveBlending, depthWrite: !1 })
66
+ ] });
67
+ }
68
+ function Pt() {
69
+ const r = x(() => {
70
+ const o = new Float32Array(144);
71
+ for (let l = 0; l < 24; l++) {
72
+ const a = l / 24 * Math.PI * 2, u = Math.cos(a) * re, h = Math.sin(a) * re;
73
+ o.set([u, h, 120, u, h, me], l * 6);
74
+ }
75
+ const i = new e.BufferGeometry();
76
+ return i.setAttribute("position", new e.BufferAttribute(o, 3)), i;
77
+ }, []);
78
+ return /* @__PURE__ */ s("lineSegments", { geometry: r, children: /* @__PURE__ */ s("lineBasicMaterial", { color: new e.Color("#3730a3").multiplyScalar(1.1), transparent: !0, opacity: 0.35, toneMapped: !1, blending: e.AdditiveBlending, depthWrite: !1 }) });
79
+ }
80
+ function Ot() {
81
+ const r = Ve ? 120 : 300, n = w(null), o = x(() => {
82
+ const u = new Float32Array(r * 5);
83
+ for (let h = 0; h < r; h++) {
84
+ const c = re * (0.38 + 0.6 * Math.pow(Math.random(), 0.45));
85
+ u.set([Math.random() * Math.PI * 2, c, me + Math.random() * 240, 9 + Math.random() * 12, 1 + Math.random() * 3.5], h * 5);
86
+ }
87
+ return u;
88
+ }, [r]), i = x(() => new e.Object3D(), []), l = x(() => new e.Color(), []), a = x(() => [new e.Color("#a5b4fc"), new e.Color("#67e8f9"), new e.Color("#f0abfc"), new e.Color("#ffffff")], []);
89
+ return te((u, h) => {
90
+ const c = n.current;
91
+ if (!c) return;
92
+ const y = Math.min(h, 0.1), m = pt(), f = m - me;
93
+ for (let B = 0; B < r; B++) {
94
+ const R = B * 5;
95
+ let v = o[R + 2] + y * o[R + 3] * $ * ue.speed;
96
+ v > m && (v -= f), o[R + 2] = v;
97
+ const M = o[R], _ = o[R + 1];
98
+ i.position.set(Math.cos(M) * _, Math.sin(M) * _, v), i.scale.set(0.022, 0.022, o[R + 4] * (Ve ? 0.4 : 1)), i.updateMatrix(), c.setMatrixAt(B, i.matrix);
99
+ const b = Math.min(1, Math.max(0, (v - me) / 60)) * Math.min(1, Math.max(0, (m - v) / 6));
100
+ l.copy(a[B % 4]).multiplyScalar((0.15 + 0.6 * b * (_ / re)) * (0.25 + 0.75 * ue.speed)), c.setColorAt(B, l);
101
+ }
102
+ c.instanceMatrix.needsUpdate = !0, c.instanceColor && (c.instanceColor.needsUpdate = !0);
103
+ }), /* @__PURE__ */ G("instancedMesh", { ref: n, args: [void 0, void 0, r], frustumCulled: !1, children: [
104
+ /* @__PURE__ */ s("boxGeometry", { args: [1, 1, 1] }),
105
+ /* @__PURE__ */ s("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, fog: !1 })
106
+ ] });
107
+ }
108
+ function It() {
109
+ const r = x(() => nt(), []), n = w(null);
110
+ return te(({ clock: o }) => {
111
+ n.current && n.current.scale.setScalar(1 + Math.sin(o.elapsedTime * 0.8) * 0.03 * $);
112
+ }), /* @__PURE__ */ G("group", { position: [0, 0, me + 5], children: [
113
+ /* @__PURE__ */ G("mesh", { ref: n, children: [
114
+ /* @__PURE__ */ s("planeGeometry", { args: [80, 80] }),
115
+ /* @__PURE__ */ s("meshBasicMaterial", { map: r, color: new e.Color("#818cf8").multiplyScalar(1.1), transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1, fog: !1 })
116
+ ] }),
117
+ /* @__PURE__ */ G("mesh", { children: [
118
+ /* @__PURE__ */ s("planeGeometry", { args: [18, 18] }),
119
+ /* @__PURE__ */ s("meshBasicMaterial", { map: r, color: new e.Color("#e0e7ff").multiplyScalar(2), transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1, fog: !1 })
120
+ ] })
121
+ ] });
122
+ }
123
+ const se = 2.3, ne = 5.2, ft = 3.4, oe = 2 * Math.PI * se, rt = new e.Matrix4().makeRotationFromEuler(new e.Euler(0.28, 0.8, 0)), Me = 48, at = 220, je = 3, zt = new e.Vector3(0, 1, 0), _t = new e.Vector3(0, 0, 1), Ae = new e.Vector3();
124
+ function ge(r, n) {
125
+ let o = 2166136261 ^ n;
126
+ for (let i = 0; i < r.length; i++) o = Math.imul(o ^ r.charCodeAt(i), 16777619);
127
+ return (o >>> 0) % 1e5 / 1e5;
128
+ }
129
+ function kt({ galaxy: r }) {
130
+ const n = x(() => {
131
+ const S = r.nodes.slice(0, at), A = new Set(S.map((k) => k.id));
132
+ return { nodes: S, links: r.links.filter((k) => A.has(k.source) && A.has(k.target)) };
133
+ }, [r]), o = n.nodes.length, i = w(null), l = w(null), a = w(null), u = w(null), h = w(/* @__PURE__ */ new Map()), c = x(() => {
134
+ const S = new Float32Array(o), A = new Float32Array(o), k = new Map(n.nodes.map((t, d) => [t.id, d])), V = [];
135
+ for (const t of n.links) {
136
+ const d = k.get(t.source), p = k.get(t.target);
137
+ d !== void 0 && p !== void 0 && d !== p && V.push([d, p]);
138
+ }
139
+ let O = 0;
140
+ n.nodes.forEach((t, d) => {
141
+ const p = h.current.get(t.id);
142
+ p ? (S[d] = p.u, A[d] = p.w) : (S[d] = ge(t.id, 1) * oe, A[d] = ge(t.id, 2) * ne, O++);
143
+ });
144
+ for (const [t, d] of V) {
145
+ const p = !h.current.has(n.nodes[t].id), T = !h.current.has(n.nodes[d].id);
146
+ p && !T && (S[t] = (S[d] + (ge(n.nodes[t].id, 3) - 0.5) * 0.8 + oe) % oe, A[t] = Math.min(ne, Math.max(0, A[d] + (ge(n.nodes[t].id, 4) - 0.5) * 0.8))), T && !p && (S[d] = (S[t] + (ge(n.nodes[d].id, 3) - 0.5) * 0.8 + oe) % oe, A[d] = Math.min(ne, Math.max(0, A[t] + (ge(n.nodes[d].id, 4) - 0.5) * 0.8)));
147
+ }
148
+ const K = h.current.size === 0 ? 90 : O ? 14 : 0, F = new Float32Array(o), D = new Float32Array(o), X = (t) => t > oe / 2 ? t - oe : t < -oe / 2 ? t + oe : t;
149
+ for (let t = 0; t < K; t++) {
150
+ F.fill(0), D.fill(0);
151
+ for (let p = 0; p < o; p++)
152
+ for (let T = p + 1; T < o; T++) {
153
+ const L = X(S[p] - S[T]), j = A[p] - A[T], H = L * L + j * j + 4e-3;
154
+ if (H > 1.4) continue;
155
+ const N = 0.05 / H;
156
+ F[p] += L * N, D[p] += j * N, F[T] -= L * N, D[T] -= j * N;
157
+ }
158
+ for (const [p, T] of V) {
159
+ const L = X(S[T] - S[p]), j = A[T] - A[p];
160
+ F[p] += L * 0.06, D[p] += j * 0.06, F[T] -= L * 0.06, D[T] -= j * 0.06;
161
+ }
162
+ const d = 0.6 * (1 - t / Math.max(1, K)) + 0.05;
163
+ for (let p = 0; p < o; p++)
164
+ S[p] = (S[p] + Math.max(-0.3, Math.min(0.3, F[p])) * d + oe) % oe, A[p] = Math.max(0, Math.min(ne, A[p] + Math.max(-0.3, Math.min(0.3, D[p])) * d));
165
+ }
166
+ const q = new Float32Array(o * 3), Y = /* @__PURE__ */ new Map();
167
+ for (let t = 0; t < o; t++) {
168
+ Y.set(n.nodes[t].id, { u: S[t], w: A[t] });
169
+ const d = S[t] / se, p = se + Math.sin(t * 7.3) * 0.12;
170
+ Ae.set(Math.cos(d) * p, Math.sin(d) * p, ne / 2 - A[t]).applyMatrix4(rt), q.set([Ae.x, Ae.y, Ae.z], t * 3);
171
+ }
172
+ return h.current = Y, q;
173
+ }, [o, n]), y = x(() => n.nodes.map((S) => new e.Color(st[S.kind] ?? "#94a3b8")), [n]), m = x(() => {
174
+ const S = new Map(n.nodes.map((V, O) => [V.id, O])), A = [];
175
+ for (const V of n.links) {
176
+ const O = S.get(V.source), K = S.get(V.target);
177
+ if (O === void 0 || K === void 0 || O === K) continue;
178
+ const F = c[O * 3] - c[K * 3], D = c[O * 3 + 1] - c[K * 3 + 1], X = c[O * 3 + 2] - c[K * 3 + 2];
179
+ F * F + D * D + X * X > 2.6 * 2.6 || A.push(c[O * 3], c[O * 3 + 1], c[O * 3 + 2], c[K * 3], c[K * 3 + 1], c[K * 3 + 2]);
180
+ }
181
+ const k = new e.BufferGeometry();
182
+ return k.setAttribute("position", new e.Float32BufferAttribute(A, 3)), k;
183
+ }, [n, c]), f = x(() => /* @__PURE__ */ new Map(), [n]), B = (S) => {
184
+ let A = f.get(S);
185
+ return A === void 0 && f.set(S, A = St(n, S)), A;
186
+ }, R = x(() => new Float32Array(o), [o]), v = x(() => new Uint8Array(o), [o]), M = x(() => new e.Object3D(), []), _ = x(() => new e.Color(), []), b = x(() => new e.Color("#ffffff"), []), I = x(() => new e.Vector3(), []), g = x(() => new e.Vector3(), []), E = x(() => Tt(), []), z = w([]), P = w([]), C = w([]), U = w([-1, -1, -1]), J = x(() => {
187
+ const S = [];
188
+ for (const V of [-ne / 2, -ne / 6, ne / 6, ne / 2])
189
+ for (let O = 0; O < 48; O++) {
190
+ const K = O / 48 * Math.PI * 2, F = (O + 1) / 48 * Math.PI * 2;
191
+ S.push(Math.cos(K) * se, Math.sin(K) * se, V, Math.cos(F) * se, Math.sin(F) * se, V);
192
+ }
193
+ for (let V = 0; V < 12; V++) {
194
+ const O = V / 12 * Math.PI * 2;
195
+ S.push(Math.cos(O) * se, Math.sin(O) * se, -ne / 2, Math.cos(O) * se, Math.sin(O) * se, ne / 2);
196
+ }
197
+ const k = new e.BufferGeometry();
198
+ return k.setAttribute("position", new e.Float32BufferAttribute(S, 3)), k.applyMatrix4(rt), k;
199
+ }, []);
200
+ return te(({ clock: S }) => {
201
+ var Y;
202
+ const A = i.current;
203
+ if (!A) return;
204
+ const k = 1, V = 0, O = performance.now(), K = S.elapsedTime;
205
+ R.fill(0), v.fill(0);
206
+ let F = 0, D = 0, X = 0;
207
+ for (const t of Q.flares) {
208
+ const d = B(t.node), p = (O - t.start) / 1e3, T = Math.exp(-p * 1.2) * Math.min(1, p * 10);
209
+ T > R[d] && (R[d] = T), t.op === "write" && (v[d] = 1);
210
+ const L = c[d * 3] * k - c[d * 3 + 1] * V, j = c[d * 3] * V + c[d * 3 + 1] * k, H = c[d * 3 + 2], N = t.op === "write", Z = Math.max(0, 1 - p / 2.6);
211
+ l.current && F < Me && (M.position.set(L, j, H), M.quaternion.identity(), M.scale.setScalar(((N ? 0.6 : 0.35) + p * (N ? 2.6 : 1.5)) * 0.18), M.updateMatrix(), l.current.setMatrixAt(F, M.matrix), _.copy(N ? b : y[d]).multiplyScalar((N ? 4 : 2.4) * Z), l.current.setColorAt(F++, _)), N && a.current && D < Me && (M.position.set(L, j, H), M.quaternion.setFromAxisAngle(_t, p * 0.8), M.scale.setScalar((1.5 + 3 * T) * 0.45), M.updateMatrix(), a.current.setMatrixAt(D, M.matrix), _.copy(b).multiplyScalar(3.2 * Z), a.current.setColorAt(D++, _));
212
+ const le = xe.get(t.instance), pe = he(t.instance);
213
+ if (le && pe && u.current && X < Me && le.presence > 0.02) {
214
+ const ae = xt(pe, Ae);
215
+ I.set(L, j, H), g.subVectors(I, ae);
216
+ const ee = g.length();
217
+ M.position.copy(ae).addScaledVector(g, 0.5), M.quaternion.setFromUnitVectors(zt, g.normalize());
218
+ const W = N ? 1.6 : 1;
219
+ M.scale.set(W * (0.5 + T), ee, W * (0.5 + T)), M.updateMatrix(), u.current.setMatrixAt(X, M.matrix), _.copy(N ? b : le.color).multiplyScalar((N ? 3.2 : 2.4) * Z * Z), u.current.setColorAt(X++, _);
220
+ }
221
+ }
222
+ let q = 0;
223
+ for (let t = Q.flares.length - 1; t >= 0 && q < je; t--) {
224
+ const d = Q.flares[t], p = (O - d.start) / 1e3;
225
+ if (p > 1.6) break;
226
+ const T = B(d.node);
227
+ let L = !1;
228
+ for (let N = 0; N < q; N++) U.current[N] === T && (L = !0);
229
+ if (L) continue;
230
+ const j = z.current[q], H = P.current[q];
231
+ j && H && (j.position.set(c[T * 3], c[T * 3 + 1], c[T * 3 + 2]), (U.current[q] !== T || C.current[q] !== d.op) && (H.setText((d.op === "write" ? "wrote · " : "") + d.node), C.current[q] = d.op, H.setColor(d.op === "write" ? "#ffffff" : st[(Y = n.nodes[T]) == null ? void 0 : Y.kind] ?? "#a5b4fc")), H.setOpacity(Math.min(1, (1.6 - p) * 2.5)), U.current[q] = T), q++;
232
+ }
233
+ for (let t = q; t < je; t++) {
234
+ U.current[t] = -1;
235
+ const d = P.current[t];
236
+ d == null || d.setOpacity(0);
237
+ }
238
+ for (const t of [l.current, a.current, u.current])
239
+ t && (t.count = t === l.current ? F : t === a.current ? D : X, t.instanceMatrix.needsUpdate = !0, t.instanceColor && (t.instanceColor.needsUpdate = !0));
240
+ for (let t = 0; t < o; t++) {
241
+ const d = R[t];
242
+ M.position.set(c[t * 3], c[t * 3 + 1], c[t * 3 + 2]), M.quaternion.identity(), M.scale.setScalar(1 + d * 2.4), M.updateMatrix(), A.setMatrixAt(t, M.matrix);
243
+ const p = 0.75 + 0.25 * Math.sin(K * 1.7 * $ + t * 1.3);
244
+ _.copy(y[t]).multiplyScalar(1.1 * p + d * 5), v[t] && _.lerp(b, Math.min(1, d) * 0.6).multiplyScalar(1 + d), A.setColorAt(t, _);
245
+ }
246
+ A.count = o, A.instanceMatrix.needsUpdate = !0, A.instanceColor && (A.instanceColor.needsUpdate = !0);
247
+ }), /* @__PURE__ */ G(Re, { children: [
248
+ /* @__PURE__ */ G("group", { children: [
249
+ /* @__PURE__ */ s("lineSegments", { geometry: J, children: /* @__PURE__ */ s("lineBasicMaterial", { color: new e.Color("#4f46e5").multiplyScalar(0.9), transparent: !0, opacity: 0.35, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) }),
250
+ /* @__PURE__ */ G("instancedMesh", { ref: i, args: [void 0, void 0, at], frustumCulled: !1, children: [
251
+ /* @__PURE__ */ s("icosahedronGeometry", { args: [0.13, 1] }),
252
+ /* @__PURE__ */ s("meshBasicMaterial", { toneMapped: !1 })
253
+ ] }),
254
+ /* @__PURE__ */ s("lineSegments", { geometry: m, children: /* @__PURE__ */ s("lineBasicMaterial", { color: new e.Color("#a5b4fc").multiplyScalar(1.3), transparent: !0, opacity: 0.42, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) })
255
+ ] }),
256
+ /* @__PURE__ */ G("instancedMesh", { ref: l, args: [void 0, void 0, Me], frustumCulled: !1, children: [
257
+ /* @__PURE__ */ s("ringGeometry", { args: [0.82, 1, 40] }),
258
+ /* @__PURE__ */ s("meshBasicMaterial", { transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1, side: e.DoubleSide })
259
+ ] }),
260
+ /* @__PURE__ */ G("instancedMesh", { ref: a, args: [void 0, void 0, Me], frustumCulled: !1, children: [
261
+ /* @__PURE__ */ s("planeGeometry", { args: [1, 1] }),
262
+ /* @__PURE__ */ s("meshBasicMaterial", { map: E, transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1 })
263
+ ] }),
264
+ /* @__PURE__ */ G("instancedMesh", { ref: u, args: [void 0, void 0, Me], frustumCulled: !1, children: [
265
+ /* @__PURE__ */ s("cylinderGeometry", { args: [0.035, 0.035, 1, 6, 1, !0] }),
266
+ /* @__PURE__ */ s("meshBasicMaterial", { transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1 })
267
+ ] }),
268
+ /* @__PURE__ */ s("group", { position: [0, -ft - 0.5, 0], children: /* @__PURE__ */ s(bt, { color: "#a5b4fc", letterSpacing: 0.04, size: 0.32, pxRange: [9, 13] }) }),
269
+ Array.from({ length: je }, (S, A) => /* @__PURE__ */ s("group", { ref: (k) => void (z.current[A] = k), children: /* @__PURE__ */ s(et, { ref: (k) => void (P.current[A] = k), position: [0, 0.45, 0], text: "", size: 0.24, opacity: 0, pxRange: [8, 12] }) }, A))
270
+ ] });
271
+ }
272
+ const _e = 12, ve = 40, Ut = new e.Vector3(0, 1, 0), Ee = new e.Color("#ffffff"), Vt = new e.Color("#f59e0b"), Wt = new e.Color("#ef4444"), Ne = (r, n, o, i) => (1 - i) * (1 - i) * r + 2 * (1 - i) * i * n + i * i * o, Ft = (r) => r < 0.5 ? 2 * r * r : 1 - Math.pow(-2 * r + 2, 2) / 2, Dt = Object.fromEntries(Object.entries(tt).map(([r, n]) => [r, new e.Color(n)]));
273
+ function Lt(r, n, o, i) {
274
+ const l = r / we.ax, a = n / we.ay, u = o / we.ax, h = i / we.ay, c = u - l, y = h - a, m = c * c + y * y, f = 2 * (l * c + a * y), B = l * l + a * a - 1, R = f * f - 4 * m * B;
275
+ if (m < 1e-6 || R < 0) return -1;
276
+ const v = Math.sqrt(R), M = (-f + v) / (2 * m), _ = (-f - v) / (2 * m);
277
+ return M >= 0 && M <= 1 ? M : _ >= 0 && _ <= 1 ? _ : -1;
278
+ }
279
+ function jt() {
280
+ const r = w(null), n = w(null), o = x(() => new e.Object3D(), []), i = x(() => new e.Color(), []), l = x(() => new e.Color(), []), a = x(() => new e.Vector3(), []), u = x(() => new e.Vector3(), []), h = x(() => new e.Vector3(), []), c = x(() => /* @__PURE__ */ new Map(), []);
281
+ return te(() => {
282
+ var _;
283
+ const y = r.current, m = n.current;
284
+ if (!y || !m) return;
285
+ const f = performance.now();
286
+ let B = 0, R = 0, v = 0;
287
+ const M = (b, I, g) => {
288
+ const E = Ft(Math.min(1, Math.max(0, b)));
289
+ for (let z = 0; z < _e; z++) {
290
+ const P = Math.max(0, E - z * 0.028);
291
+ o.position.set(Ne(a.x, h.x, u.x, P), Ne(a.y, h.y, u.y, P), Ne(a.z, h.z, u.z, P)), o.scale.setScalar(I * (1 - z / _e) * (b >= 1 ? 0 : 1)), o.updateMatrix(), y.setMatrixAt(B, o.matrix), i.copy(z === 0 ? Ee : l).lerp(l, z === 0 ? 0.35 : 0).multiplyScalar((z === 0 ? 5 : 3.2) * (1 - z / _e) * g), y.setColorAt(B++, i);
292
+ }
293
+ return E;
294
+ };
295
+ for (const b of Q.comets) {
296
+ if (v >= ve) break;
297
+ const I = he(b.from), g = he(b.to);
298
+ if (!I || !g) continue;
299
+ const E = (f - b.start) / b.dur;
300
+ if (E > 1.05) continue;
301
+ a.copy(I), u.copy(g), h.copy(a).add(u).multiplyScalar(0.5), h.z -= 3 + a.distanceTo(u) * 0.25;
302
+ const z = Q.instances.get(b.from);
303
+ l.copy(z ? Dt[z.type] : Ee), M(E, 0.2, 1), v++;
304
+ }
305
+ for (const b of Q.mcpCalls) {
306
+ if (v >= ve) break;
307
+ const I = he(b.instance), g = Qe(b.server);
308
+ if (!I || !g) continue;
309
+ const E = (f - b.start) / b.dur;
310
+ if (E > 1.05) continue;
311
+ b.phase === "call" ? (a.copy(I), u.copy(g)) : (a.copy(g), u.copy(I)), h.copy(a).add(u).multiplyScalar(0.5), h.z -= 2;
312
+ let z = c.get(b.server);
313
+ z || c.set(b.server, z = new e.Color(((_ = Q.mcpServers.get(b.server)) == null ? void 0 : _.color) ?? "#94a3b8")), l.copy(z);
314
+ const P = M(E, 0.17, 1.1);
315
+ v++;
316
+ const C = Lt(a.x, a.y, u.x, u.y);
317
+ if (C >= 0 && P > C && R < ve) {
318
+ const U = P - C;
319
+ o.position.set(a.x + (u.x - a.x) * C, a.y + (u.y - a.y) * C, a.z + (u.z - a.z) * C), o.scale.setScalar(0.25 + U * 2.4), o.updateMatrix(), m.setMatrixAt(R, o.matrix), i.copy(z).lerp(Ee, 0.4).multiplyScalar(4 * Math.exp(-U * 4)), m.setColorAt(R++, i);
320
+ }
321
+ }
322
+ y.count = B, m.count = R, y.instanceMatrix.needsUpdate = !0, m.instanceMatrix.needsUpdate = !0, y.instanceColor && (y.instanceColor.needsUpdate = !0), m.instanceColor && (m.instanceColor.needsUpdate = !0);
323
+ }), /* @__PURE__ */ G(Re, { children: [
324
+ /* @__PURE__ */ G("instancedMesh", { ref: r, args: [void 0, void 0, ve * _e], frustumCulled: !1, children: [
325
+ /* @__PURE__ */ s("sphereGeometry", { args: [1, 12, 8] }),
326
+ /* @__PURE__ */ s("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: e.AdditiveBlending, depthWrite: !1 })
327
+ ] }),
328
+ /* @__PURE__ */ G("instancedMesh", { ref: n, args: [void 0, void 0, ve], frustumCulled: !1, children: [
329
+ /* @__PURE__ */ s("ringGeometry", { args: [0.7, 1, 32] }),
330
+ /* @__PURE__ */ s("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, side: e.DoubleSide })
331
+ ] })
332
+ ] });
333
+ }
334
+ function Nt() {
335
+ const o = w(null), i = w(null), l = x(() => new e.Object3D(), []), a = x(() => new e.Color(), []), u = x(() => new e.Vector3(), []), h = x(() => /* @__PURE__ */ new Map(), []), c = (y) => {
336
+ var f;
337
+ let m = h.get(y);
338
+ return m || h.set(y, m = new e.Color(((f = Q.mcpServers.get(y)) == null ? void 0 : f.color) ?? "#94a3b8")), m;
339
+ };
340
+ return te(({ clock: y }) => {
341
+ var I;
342
+ const m = o.current, f = i.current;
343
+ if (!m || !f) return;
344
+ const B = performance.now(), R = y.elapsedTime * Math.max(0.25, $);
345
+ let v = 0, M = 0;
346
+ const _ = (g, E, z) => {
347
+ u.subVectors(E, g);
348
+ const P = u.length();
349
+ l.position.copy(g).addScaledVector(u, 0.5), l.quaternion.setFromUnitVectors(Ut, u.normalize()), l.scale.set(z, P, z), l.updateMatrix(), m.setMatrixAt(v, l.matrix), m.setColorAt(v++, a);
350
+ }, b = (g, E, z, P) => {
351
+ l.position.lerpVectors(g, E, z), l.quaternion.identity(), l.scale.setScalar(P), l.updateMatrix(), f.setMatrixAt(M, l.matrix), f.setColorAt(M++, a);
352
+ };
353
+ for (const g of Q.mcpPending.values()) {
354
+ if (v >= 24) break;
355
+ const E = he(g.instance), z = Qe(g.server);
356
+ if (!E || !z || (((I = xe.get(g.instance)) == null ? void 0 : I.presence) ?? 0) < 0.02) continue;
357
+ const P = At(g, B), C = Math.min(1, P / 0.35);
358
+ a.copy(c(g.server)), P > 0.6 && a.lerp(Vt, Math.min(1, (P - 0.6) / 0.9)), P > 1.6 && a.lerp(Wt, Math.min(1, (P - 1.6) / 0.8));
359
+ const U = (0.9 + Math.min(2.2, P * 0.7)) * C * (0.85 + 0.15 * Math.sin(R * 9));
360
+ a.multiplyScalar(U), _(E, z, 0.6 + Math.min(1.4, P * 0.4)), a.multiplyScalar(1.8);
361
+ for (let J = 0; J < 8 && M < 192; J++) {
362
+ const S = (R * (0.7 + Math.min(1.2, P * 0.35)) + J / 8) % 1;
363
+ S > C || b(E, z, S, 0.09 + Math.min(0.08, P * 0.03));
364
+ }
365
+ }
366
+ for (const g of Q.mcpResolved) {
367
+ if (v >= 24) break;
368
+ const E = he(g.instance), z = Qe(g.server);
369
+ if (!E || !z) continue;
370
+ const P = Math.min(1, (B - g.resolvedAt) / 700);
371
+ a.copy(c(g.server)).lerp(Ee, 0.6).multiplyScalar(2.6 * (1 - P)), _(E, z, 1.6 * (1 - P * 0.7)), a.copy(Ee).multiplyScalar(6);
372
+ const C = 1 - Math.pow(1 - P, 2);
373
+ for (let U = 0; U < 5 && M < 192; U++) b(z, E, Math.max(0, C - U * 0.035), 0.26 * (1 - U / 5));
374
+ }
375
+ m.count = v, f.count = M, m.instanceMatrix.needsUpdate = !0, f.instanceMatrix.needsUpdate = !0, m.instanceColor && (m.instanceColor.needsUpdate = !0), f.instanceColor && (f.instanceColor.needsUpdate = !0);
376
+ }), /* @__PURE__ */ G(Re, { children: [
377
+ /* @__PURE__ */ G("instancedMesh", { ref: o, args: [void 0, void 0, 24], frustumCulled: !1, children: [
378
+ /* @__PURE__ */ s("cylinderGeometry", { args: [0.03, 0.03, 1, 6, 1, !0] }),
379
+ /* @__PURE__ */ s("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: e.AdditiveBlending, depthWrite: !1 })
380
+ ] }),
381
+ /* @__PURE__ */ G("instancedMesh", { ref: i, args: [void 0, void 0, 192], frustumCulled: !1, children: [
382
+ /* @__PURE__ */ s("sphereGeometry", { args: [1, 10, 8] }),
383
+ /* @__PURE__ */ s("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: e.AdditiveBlending, depthWrite: !1 })
384
+ ] })
385
+ ] });
386
+ }
387
+ function Kt({ mcp: r }) {
388
+ const n = r.name, o = r.srv, i = x(() => new e.Color((o == null ? void 0 : o.color) ?? "#94a3b8"), [o == null ? void 0 : o.color]), l = w(null), a = x(() => nt(), []), u = w(null), h = w(null), c = w(null), y = w(null), m = w(null), f = w(null);
389
+ return te(({ clock: B }, R) => {
390
+ var E;
391
+ (E = l.current) == null || E.position.copy(r.pos);
392
+ const v = Q.mcpServers.get(n);
393
+ if (!v) return;
394
+ const M = performance.now(), _ = B.elapsedTime, b = Math.exp(-(M - v.activeAt) / 450), I = v.inflight > 0 ? 1 : 0, g = (I * 2.6 + b * 2) * Math.max(0.2, $);
395
+ u.current && (u.current.rotation.z += R * g), h.current && (h.current.rotation.x += R * g * 0.7), c.current && (c.current.material.color.copy(i).multiplyScalar(1.3 + I * 1.4 + b * 3 + (I ? Math.sin(_ * 7) * 0.5 : 0)), c.current.scale.setScalar(1 + b * 0.35)), y.current && (y.current.material.opacity = 0.22 + I * 0.25 + b * 0.45, y.current.scale.setScalar(1 + b * 0.7 + I * 0.2)), m.current && (m.current.visible = Math.sin(_ * 4 + v.slot) > 0.6 || I === 1);
396
+ }), /* @__PURE__ */ G("group", { ref: l, children: [
397
+ /* @__PURE__ */ G("group", { ref: f, children: [
398
+ /* @__PURE__ */ G("mesh", { ref: c, children: [
399
+ /* @__PURE__ */ s("octahedronGeometry", { args: [0.55, 0] }),
400
+ /* @__PURE__ */ s("meshBasicMaterial", { toneMapped: !1 })
401
+ ] }),
402
+ [-1, 1].map((B) => /* @__PURE__ */ G("mesh", { position: [B * 1.55, 0, 0], children: [
403
+ /* @__PURE__ */ s("boxGeometry", { args: [1.5, 0.6, 0.04] }),
404
+ /* @__PURE__ */ s("meshStandardMaterial", { color: "#0f172a", emissive: i, emissiveIntensity: 0.35, metalness: 0.8, roughness: 0.35, toneMapped: !1 })
405
+ ] }, B)),
406
+ /* @__PURE__ */ G("mesh", { position: [0, 0, 0], children: [
407
+ /* @__PURE__ */ s("boxGeometry", { args: [1.6, 0.06, 0.06] }),
408
+ /* @__PURE__ */ s("meshBasicMaterial", { color: i.clone().multiplyScalar(0.8), toneMapped: !1 })
409
+ ] }),
410
+ /* @__PURE__ */ G("mesh", { ref: m, position: [0, 0.85, 0], children: [
411
+ /* @__PURE__ */ s("sphereGeometry", { args: [0.09, 10, 8] }),
412
+ /* @__PURE__ */ s("meshBasicMaterial", { color: new e.Color(4, 3.2, 3.2), toneMapped: !1 })
413
+ ] })
414
+ ] }),
415
+ /* @__PURE__ */ G("mesh", { ref: u, children: [
416
+ /* @__PURE__ */ s("torusGeometry", { args: [1.05, 0.04, 6, 64, Math.PI * 1.6] }),
417
+ /* @__PURE__ */ s("meshBasicMaterial", { color: i.clone().multiplyScalar(2.2), toneMapped: !1 })
418
+ ] }),
419
+ /* @__PURE__ */ G("mesh", { ref: h, rotation: [Math.PI / 2, 0, 0], children: [
420
+ /* @__PURE__ */ s("torusGeometry", { args: [0.8, 0.03, 6, 48] }),
421
+ /* @__PURE__ */ s("meshBasicMaterial", { color: i.clone().multiplyScalar(1.6), toneMapped: !1 })
422
+ ] }),
423
+ /* @__PURE__ */ G("mesh", { ref: y, children: [
424
+ /* @__PURE__ */ s("planeGeometry", { args: [4.2, 4.2] }),
425
+ /* @__PURE__ */ s("meshBasicMaterial", { map: a, color: i, transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1 })
426
+ ] }),
427
+ /* @__PURE__ */ s("group", { position: [0, -1.55, 0], children: /* @__PURE__ */ s(et, { text: `mcp · ${n}`, color: (o == null ? void 0 : o.color) ?? "#94a3b8", size: 0.36, pxRange: [9, 13] }) })
428
+ ] });
429
+ }
430
+ const Xt = new e.Color("#4ade80"), Ke = new e.Color("#fde68a"), qt = new e.Color("#ef4444"), Xe = { plan: "planner", research: "researcher", write: "writer" }, qe = 16, Ze = 7, He = 5, Zt = new e.BoxGeometry(1, 0.035, 0.035), Ht = new e.TorusGeometry(1, 0.03, 6, 64), ce = new e.Object3D(), ie = new e.Color(), ke = new Float64Array(3), $e = new Int8Array(3);
431
+ function $t({ run: r }) {
432
+ const n = x(() => new e.Color(r.color), [r.color]), o = w(null), i = w([]), l = w([]), a = w([]), u = w([]), h = w([]), c = w(null), y = w(null), m = w(null), f = w(null), B = w(-1), R = w(["", "", ""]), v = w([0, 0, 0]), M = w([0, 0.33, 0.66]), _ = x(() => n.clone().lerp(new e.Color("#ffffff"), 0.55).multiplyScalar(5), [n]), b = x(() => {
433
+ const g = new e.InstancedMesh(Ht, new e.MeshBasicMaterial({ toneMapped: !1, transparent: !0, blending: e.AdditiveBlending, depthWrite: !1 }), 3 * Ze);
434
+ return g.frustumCulled = !1, g.setColorAt(0, new e.Color(0, 0, 0)), g.count = 0, g;
435
+ }, []), I = x(
436
+ () => ({
437
+ rail: new e.MeshBasicMaterial({ color: n.clone().multiplyScalar(1.6), toneMapped: !1, transparent: !0, opacity: 0.75 }),
438
+ dash: new e.MeshBasicMaterial({ color: n.clone().multiplyScalar(2.4), toneMapped: !1, transparent: !0, opacity: 0.8, blending: e.AdditiveBlending, depthWrite: !1 })
439
+ }),
440
+ [n]
441
+ );
442
+ return te(({ clock: g }, E) => {
443
+ var Y;
444
+ const z = o.current;
445
+ if (!z) return;
446
+ const P = Math.min(E, 0.1), C = r.run ?? Q.runs.get(r.id), U = performance.now(), J = g.elapsedTime, S = Fe.spread;
447
+ z.position.copy(r.origin).addScaledVector(r.side, -r.cu).addScaledVector(r.axis, -r.cv);
448
+ const A = C ? We((U - C.startedAt) / 1300) : 1, k = C != null && C.endedAt ? Math.max(0, 1 - (U - C.endedAt) / vt) : 1, V = r.cu - r.hu - 0.8 * S, O = V + (r.cu + r.hu + 0.8 * S - V) * Math.max(1e-3, A);
449
+ for (let t = 0; t < 2; t++) {
450
+ const d = i.current[t];
451
+ d && (d.position.set((V + O) / 2, (t ? 0.62 : -0.62) * S, -0.9), d.scale.set(Math.max(0.01, O - V), 1, 1));
452
+ }
453
+ I.rail.opacity = 0.75 * k, I.dash.opacity = 0.8 * k;
454
+ const K = y.current;
455
+ if (K) {
456
+ const t = Math.max(0.5, O - V);
457
+ for (let d = 0; d < qe; d++) {
458
+ const p = V + (d * (t / qe) + J * 3 * $ * ue.speed) % t;
459
+ ce.position.set(p, 0, -0.9), ce.rotation.set(0, 0, 0), ce.scale.set(1, 1, 1), ce.updateMatrix(), K.setMatrixAt(d, ce.matrix);
460
+ }
461
+ K.instanceMatrix.needsUpdate = !0;
462
+ }
463
+ const F = !!(C != null && C.hasSteps);
464
+ let D = 0;
465
+ if (F && C) {
466
+ for (let t = 0; t < 3; t++) {
467
+ const d = C.steps[Se[t]];
468
+ ke[t] = Le(Xe[Se[t]]), $e[t] = d === "queued" ? 0 : d === "running" ? 1 : d === "done" ? 2 : 3;
469
+ }
470
+ D = 3;
471
+ } else
472
+ for (const t of Pe.agents.values()) {
473
+ if (D >= 3) break;
474
+ t.run !== r || t.depth !== 0 || (ke[D] = t.eu, $e[D] = t.inst.exitAt ? 2 : t.inst.status === "thinking" ? 1 : 4, D++);
475
+ }
476
+ let X = 0;
477
+ for (let t = 0; t < 3; t++) {
478
+ const d = l.current[t], p = a.current[t], T = u.current[t], L = h.current[t];
479
+ if (!d || !p || !T || !L || (d.visible = t < D, t >= D)) continue;
480
+ const j = $e[t], H = F ? Se[t] + j : "a" + j;
481
+ R.current[t] !== H && (R.current[t] = H, v.current[t] = U);
482
+ const N = Math.exp(-(U - v.current[t]) / 280), Z = j === 1;
483
+ j === 0 ? ie.copy(n).multiplyScalar(0.32) : Z ? ie.copy(n).lerp(Ke, 0.35).multiplyScalar(1.35 + Math.sin(J * 5) * 0.45 * $) : j === 2 ? ie.copy(F ? Xt : n).multiplyScalar(F ? 1.15 : 0.6) : j === 3 ? ie.copy(qt).multiplyScalar(2.2) : ie.copy(n).multiplyScalar(0.7), ie.multiplyScalar((1 + N * 1.6) * k), d.position.set(ke[t], 0, -0.2), d.scale.setScalar(S * Math.max(1e-3, Math.min(1, (A - 0.2) * 1.6))), p.material.color.copy(ie), p.scale.setScalar(1 + N * 0.45 + (Z ? Math.sin(J * 6) * 0.05 * $ : 0)), T.visible = Z, Z && (T.rotation.z += P * 3.2 * Math.max(0.3, $));
484
+ const le = L.material;
485
+ le.opacity = (j === 0 ? 0.02 : Z ? 0.1 + Math.sin(J * 5) * 0.04 : 0.04) * k, le.color.copy(ie), L.scale.setScalar(1 + N * 0.8), M.current[t] = (M.current[t] + P * (Z ? 1.4 : 0.22) * $ * ue.speed) % 1;
486
+ const pe = M.current[t], ae = j === 0 ? 0.35 : Z ? 1.25 : 0.55;
487
+ for (let ee = 0; ee < Ze; ee++) {
488
+ const W = (ee + 1 - pe) * He, De = Math.min(1, W / He), de = 1 - W / ((Ze + 1) * He);
489
+ ce.position.set(ke[t], 0, -0.2 - W), ce.rotation.set(0, 0, 0), ce.scale.setScalar(Oe * S * (1 + W * 0.012)), ce.updateMatrix(), b.setMatrixAt(X, ce.matrix), ie.copy(n).lerp(Ke, Z ? 0.25 : 0).multiplyScalar(ae * De * de * de * k), b.setColorAt(X, ie), X++;
490
+ }
491
+ }
492
+ b.count = X, b.instanceMatrix.needsUpdate = !0, b.instanceColor && (b.instanceColor.needsUpdate = !0);
493
+ const q = c.current;
494
+ if (q) {
495
+ const t = C != null && C.handoffAt ? (U - C.handoffAt) / 950 : 2;
496
+ if (q.visible = F && t >= 0 && t < 1, q.visible && C) {
497
+ const d = Le(Xe[C.handoffFrom]), p = Le(Xe[C.handoffTo]);
498
+ q.position.set(d + (p - d) * We(t), 0, -0.4), q.scale.set((1 + 9 * Math.sin(Math.PI * t)) * S, S, S);
499
+ }
500
+ }
501
+ if ((Y = m.current) == null || Y.position.set(r.cu - r.hu, r.hv - r.cv + 0.45, 0), C && f.current) {
502
+ let t = 0;
503
+ for (let L = 0; L < 3; L++) C.steps[Se[L]] !== "queued" && (t = L);
504
+ const d = Se[t], p = C.steps[d], T = t * 100 + (p === "queued" ? 0 : p === "running" ? 1 : p === "done" ? 2 : 3) * 10 + (C.status === "completed" ? 1 : C.status === "started" ? 2 : 3);
505
+ T !== B.current && (B.current = T, f.current.setText(C.topic, C.status === "completed" ? "run complete" : C.hasSteps ? `hatchet · ${d} ${p}` : "running…")), f.current.setOpacity(k);
506
+ }
507
+ }), /* @__PURE__ */ G("group", { ref: o, children: [
508
+ [0, 1].map((g) => /* @__PURE__ */ s("mesh", { ref: (E) => void (i.current[g] = E), geometry: Zt, material: I.rail }, g)),
509
+ /* @__PURE__ */ s("instancedMesh", { ref: y, args: [void 0, void 0, qe], material: I.dash, frustumCulled: !1, children: /* @__PURE__ */ s("boxGeometry", { args: [0.9, 0.05, 0.05] }) }),
510
+ /* @__PURE__ */ s("primitive", { object: b }),
511
+ [0, 1, 2].map((g) => /* @__PURE__ */ G("group", { ref: (E) => void (l.current[g] = E), visible: !1, children: [
512
+ /* @__PURE__ */ G("mesh", { ref: (E) => void (a.current[g] = E), children: [
513
+ /* @__PURE__ */ s("torusGeometry", { args: [Oe, 0.075, 10, 64] }),
514
+ /* @__PURE__ */ s("meshBasicMaterial", { toneMapped: !1 })
515
+ ] }),
516
+ /* @__PURE__ */ G("mesh", { ref: (E) => void (u.current[g] = E), visible: !1, children: [
517
+ /* @__PURE__ */ s("torusGeometry", { args: [Oe * 1.23, 0.045, 6, 48, Math.PI * 0.7] }),
518
+ /* @__PURE__ */ s("meshBasicMaterial", { color: Ke.clone().multiplyScalar(1.8), toneMapped: !1 })
519
+ ] }),
520
+ /* @__PURE__ */ G("mesh", { ref: (E) => void (h.current[g] = E), children: [
521
+ /* @__PURE__ */ s("circleGeometry", { args: [Oe * 0.96, 48] }),
522
+ /* @__PURE__ */ s("meshBasicMaterial", { transparent: !0, opacity: 0.05, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1, side: e.DoubleSide })
523
+ ] })
524
+ ] }, g)),
525
+ /* @__PURE__ */ G("mesh", { ref: c, visible: !1, children: [
526
+ /* @__PURE__ */ s("sphereGeometry", { args: [0.2, 16, 12] }),
527
+ /* @__PURE__ */ s("meshBasicMaterial", { color: _, toneMapped: !1 })
528
+ ] }),
529
+ /* @__PURE__ */ s("group", { ref: m, children: /* @__PURE__ */ s(et, { ref: f, text: "", secondary: "", anchorX: "left", anchorY: "bottom", textAlign: "left", color: r.color, letterSpacing: 0.02, size: 0.38, maxWidth: 14, pxRange: [10, 14] }) })
530
+ ] });
531
+ }
532
+ const Yt = new e.Color("#f59e0b"), Jt = new e.Color("#ef4444"), Ue = new e.Color("#ffffff"), Qt = (() => {
533
+ const n = new Float32Array(132);
534
+ for (let i = 0; i < 22; i++) {
535
+ const l = i / 22 * Math.PI * 2 + Math.random() * 0.2, a = (Math.random() - 0.5) * 2.4, u = Math.cos(l), h = Math.sin(l), c = 0.7 + Math.random() * 0.6;
536
+ n.set([u * 0.25, h * 0.25, a * 0.2, u * c, h * c, a * c], i * 6);
537
+ }
538
+ const o = new e.BufferGeometry();
539
+ return o.setAttribute("position", new e.BufferAttribute(n, 3)), o;
540
+ })(), ct = new e.Euler(), fe = {
541
+ capsule: new e.CapsuleGeometry(0.36, 1.15, 6, 18),
542
+ fin: new e.BoxGeometry(0.05, 1.25, 0.5),
543
+ engine: new e.SphereGeometry(0.22, 16, 12),
544
+ halo: new e.PlaneGeometry(2.6, 2.6),
545
+ sel: new e.TorusGeometry(1.05, 0.035, 6, 48),
546
+ hit: new e.SphereGeometry(1.1, 10, 8),
547
+ flash: new e.SphereGeometry(0.45, 16, 12),
548
+ ring: new e.RingGeometry(0.85, 1, 48)
549
+ }, en = 0.78, tn = -0.62;
550
+ function nn({ agent: r, selected: n, onSelect: o }) {
551
+ const i = r.id, l = r.inst.type, a = x(() => new e.Color(tt[l]), [l]), u = x(() => ({ color: a.clone(), energy: 0, active: 0, presence: 0, seed: Math.random() }), [a]);
552
+ Je(() => (xe.set(i, u), () => {
553
+ xe.get(i) === u && xe.delete(i);
554
+ }), [i, u]);
555
+ const h = w(null), c = w(null), y = w(null), m = w(null), f = w(null), B = w(null), R = w(null), v = w(null), M = w(null), _ = w(null), b = w(null), I = w(null), g = x(() => new e.Color(), []), E = x(() => nt(), []), z = x(() => a.clone().lerp(Ue, 0.55), [a]);
556
+ return te(({ clock: P }, C) => {
557
+ const U = r.inst, J = h.current;
558
+ if (!J) return;
559
+ const S = Math.min(C, 0.1), A = performance.now(), k = P.elapsedTime, V = Ct(U, A), O = ut(U, A), K = (A - U.bornAt) / 1e3, F = U.status === "thinking" || U.status === "spawning";
560
+ let D = 0;
561
+ for (const W of Q.mcpPending.values()) W.instance === i && (D = Math.max(D, (A - W.since) / 1e3 + 0.01));
562
+ const X = !F && !U.exitAt, q = Fe.scale;
563
+ if (!b.current) {
564
+ const W = U.parent ? he(U.parent) : void 0;
565
+ b.current = W ? W.clone() : r.pos.clone().setZ(-45);
566
+ }
567
+ const Y = b.current, t = We(K / 1.15), d = Math.sin(k * 1.1 + u.seed * 6) * 0.18 * $ * q;
568
+ let p = Y.x + (r.pos.x - Y.x) * t, T = Y.y + (r.pos.y + d - Y.y) * t, L = Y.z + (r.pos.z - Y.z) * t, j = V, H = V * (1 + 4 * (1 - t)), N = Math.max(0, 1 - K / 0.5) * 2.5, Z = 0;
569
+ if (U.exitAt) {
570
+ if (Z = (A - U.exitAt) / 1e3, I.current || (I.current = new e.Vector3(p, T, L)), p = I.current.x, T = I.current.y, L = I.current.z, U.status === "failed")
571
+ j *= Math.max(0, 1 - Z * 1.3), H = j;
572
+ else {
573
+ const W = Math.max(0, Z - 0.18);
574
+ L -= (6 * W + 120 * W * W) * Math.max(0.3, $), H = V * (1 + 34 * Math.min(1, W * 1.6)), j *= 1 - 0.55 * Math.min(1, W * 2);
575
+ }
576
+ N += Math.max(0, 1 - Z / 0.5) * 4;
577
+ }
578
+ r.live.set(p, T, L);
579
+ const le = X ? (D ? 0.07 * Math.sin(k * 3.2) : 0.05 * Math.sin(k * 1.6)) * $ : 0;
580
+ J.position.set(p, T, L), ct.set(tn, 0, 0), J.quaternion.setFromEuler(ct);
581
+ const pe = r.scale * en;
582
+ J.scale.set(j * (1 + le) * (n ? 1.15 : 1) * pe, j * (1 + le) * (n ? 1.15 : 1) * pe, H * pe), c.current && (c.current.rotation.z += S * (F ? 5.5 : X ? 0.5 : 2) * (1 + O * 1.6) * Math.max(0.25, $));
583
+ const ae = y.current;
584
+ if (ae) {
585
+ const W = F ? 1.7 + Math.sin(k * 5) * 0.45 * $ : X ? D ? 0.55 + 0.35 * Math.sin(k * 3.2) : 0.35 + 0.15 * Math.sin(k * 1.6) : 1.1;
586
+ ae.emissiveIntensity = W * 0.8 + O * 2.6 + N, D ? ae.emissive.copy(a).lerp(Yt, Math.min(0.55, D * 0.3)) : ae.emissive.copy(a), ae.opacity = Math.min(1, V * 1.4);
587
+ }
588
+ if (m.current) {
589
+ const W = (F ? 1 + Math.sin(k * 14) * 0.18 * $ : X ? 0.55 : 0.85) + O * 1.3;
590
+ m.current.scale.setScalar(W), m.current.material.color.copy(z).multiplyScalar((X ? 0.8 : 1.9) + O * 2.5 + N);
591
+ }
592
+ if (f.current) {
593
+ const W = f.current.material;
594
+ W.opacity = Math.min(1, ((X ? 0.1 : 0.24) + O * 0.25 + N * 0.06) * V), f.current.scale.setScalar(1 + O * 0.8);
595
+ }
596
+ B.current && (B.current.visible = n, B.current.rotation.z -= S * 1.5), u.energy = O, u.active = F ? 1 : X ? 0.2 : 0.6, u.presence = U.exitAt ? V * Math.max(0, 1 - Z * 2) : V;
597
+ const ee = R.current;
598
+ if (ee) {
599
+ const W = K / 0.9, De = U.exitAt ? Z / 0.7 : 2, de = W < 1 ? W : De;
600
+ if (ee.visible = de < 1, ee.visible) {
601
+ W < 1 ? ee.position.copy(Y) : I.current && ee.position.copy(I.current);
602
+ const be = 1 - de;
603
+ ee.scale.setScalar((0.35 + de * 1.9) * q), g.copy(W < 1 ? a : U.status === "failed" ? Jt : Ue).lerp(Ue, 0.3).multiplyScalar(2.4 * be), v.current.material.color.copy(g), v.current.material.opacity = be * be, M.current.material.color.copy(g), M.current.material.opacity = be, _.current.material.color.copy(g), _.current.material.opacity = be, _.current.scale.set(1 + de * 1.5, 1 + de * 1.5, 1 + de * 4);
604
+ }
605
+ }
606
+ }), /* @__PURE__ */ G(Re, { children: [
607
+ /* @__PURE__ */ G("group", { ref: h, position: [0, 0, -200], children: [
608
+ /* @__PURE__ */ G("group", { ref: c, children: [
609
+ /* @__PURE__ */ s("mesh", { geometry: fe.capsule, rotation: [Math.PI / 2, 0, 0], children: /* @__PURE__ */ s("meshStandardMaterial", { ref: y, color: a.clone().multiplyScalar(0.35), emissive: a, emissiveIntensity: 1, metalness: 0.5, roughness: 0.3, toneMapped: !1, transparent: !0 }) }),
610
+ [0, 1, 2].map((P) => /* @__PURE__ */ s("mesh", { geometry: fe.fin, rotation: [0, 0, P * Math.PI * 2 / 3], position: [0, 0, 0.45], children: /* @__PURE__ */ s("meshBasicMaterial", { color: a.clone().lerp(Ue, 0.3).multiplyScalar(1.6), toneMapped: !1 }) }, P))
611
+ ] }),
612
+ /* @__PURE__ */ s("mesh", { geometry: fe.engine, ref: m, position: [0, 0, 0.95], children: /* @__PURE__ */ s("meshBasicMaterial", { toneMapped: !1 }) }),
613
+ /* @__PURE__ */ s("mesh", { geometry: fe.halo, ref: f, position: [0, 0, 0.6], children: /* @__PURE__ */ s("meshBasicMaterial", { map: E, color: a.clone().multiplyScalar(1.6), transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) }),
614
+ /* @__PURE__ */ s("mesh", { geometry: fe.sel, ref: B, visible: !1, children: /* @__PURE__ */ s("meshBasicMaterial", { color: new e.Color(3, 3, 3), toneMapped: !1 }) }),
615
+ /* @__PURE__ */ s(
616
+ "mesh",
617
+ {
618
+ geometry: fe.hit,
619
+ onClick: (P) => (P.stopPropagation(), o(i)),
620
+ onPointerOver: () => document.body.style.cursor = "pointer",
621
+ onPointerOut: () => document.body.style.cursor = "",
622
+ children: /* @__PURE__ */ s("meshBasicMaterial", { transparent: !0, opacity: 0, depthWrite: !1, colorWrite: !1 })
623
+ }
624
+ )
625
+ ] }),
626
+ /* @__PURE__ */ G("group", { ref: R, visible: !1, children: [
627
+ /* @__PURE__ */ s("mesh", { geometry: fe.flash, ref: v, children: /* @__PURE__ */ s("meshBasicMaterial", { transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) }),
628
+ /* @__PURE__ */ s("mesh", { geometry: fe.ring, ref: M, children: /* @__PURE__ */ s("meshBasicMaterial", { transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1, side: e.DoubleSide }) }),
629
+ /* @__PURE__ */ s("lineSegments", { ref: _, geometry: Qt, children: /* @__PURE__ */ s("lineBasicMaterial", { transparent: !0, blending: e.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) })
630
+ ] })
631
+ ] });
632
+ }
633
+ function on() {
634
+ const o = w(null), i = x(() => new e.Object3D(), []), l = x(() => new e.Color(), []);
635
+ return te(({ clock: a }) => {
636
+ const u = o.current;
637
+ if (!u) return;
638
+ const h = a.elapsedTime * Math.max(0.2, $), c = Fe.scale;
639
+ let y = 0;
640
+ for (const m of Pe.agents.values()) {
641
+ if (y + 9 > 576) break;
642
+ const f = xe.get(m.id);
643
+ if (!f || f.presence <= 0.01) continue;
644
+ const B = m.live, R = m.scale * 0.75, v = 0.6 + f.active * 1.4 + f.energy * 1.5;
645
+ for (let M = 0; M < 9; M++) {
646
+ const _ = (h * v + M / 9 + f.seed * 7) % 1, b = f.seed * 40 + M * 2.39996, I = (0.25 + 0.55 * ((M * 0.618 + f.seed) % 1)) * R, g = (0.5 + f.active * 0.9 + f.energy * 2.6) * c;
647
+ i.position.set(B.x + Math.cos(b) * I, B.y + Math.sin(b) * I + 0.35 * R, B.z + (1 + _ * (2.5 + f.energy * 4)) * c), i.scale.set(0.035 * c, 0.035 * c, g), i.updateMatrix(), u.setMatrixAt(y, i.matrix), l.copy(f.color).multiplyScalar((0.25 + f.active * 0.9 + f.energy * 2.2) * (1 - _) * f.presence), u.setColorAt(y, l), y++;
648
+ }
649
+ }
650
+ u.count = y, u.instanceMatrix.needsUpdate = !0, u.instanceColor && (u.instanceColor.needsUpdate = !0);
651
+ }), /* @__PURE__ */ G("instancedMesh", { ref: o, args: [void 0, void 0, 576], frustumCulled: !1, children: [
652
+ /* @__PURE__ */ s("boxGeometry", { args: [1, 1, 1] }),
653
+ /* @__PURE__ */ s("meshBasicMaterial", { toneMapped: !1, transparent: !0, blending: e.AdditiveBlending, depthWrite: !1 })
654
+ ] });
655
+ }
656
+ const Ce = 14, it = 64, sn = new e.CylinderGeometry(1, 1, 1, 6, 1, !0), rn = new e.Vector3(0, 1, 0), Be = new e.Vector3(), ye = new e.Vector3(), Ye = new e.Vector3(), Ge = new e.Object3D();
657
+ function lt(r, n, o, i, l, a) {
658
+ const u = 1 - l, h = u * u * u, c = 3 * u * u * l, y = 3 * u * l * l, m = l * l * l;
659
+ return a.copy(r).multiplyScalar(h + c).addScaledVector(n, y + m), a.addScaledVector(o, i * (c - 0.3 * y)), a;
660
+ }
661
+ function an() {
662
+ const r = x(() => {
663
+ const o = new e.InstancedMesh(sn, new e.MeshBasicMaterial({ toneMapped: !1, transparent: !0, blending: e.AdditiveBlending, depthWrite: !1 }), it * Ce);
664
+ return o.frustumCulled = !1, o.setColorAt(0, new e.Color(0, 0, 0)), o.count = 0, o;
665
+ }, []), n = x(() => new e.Color(), []);
666
+ return te(() => {
667
+ const o = performance.now(), i = Fe.scale;
668
+ let l = 0;
669
+ for (const a of Pe.agents.values()) {
670
+ if (l + Ce > it * Ce) break;
671
+ const u = a.inst.parent;
672
+ if (!u) continue;
673
+ const h = he(u);
674
+ if (!h) continue;
675
+ const c = a.inst, y = We((o - c.bornAt) / 1300), m = c.exitAt ? Math.max(0, 1 - (o - c.exitAt) / 700) : 1;
676
+ if (m <= 0) continue;
677
+ const f = ut(c, o);
678
+ n.copy(cn[c.type]).multiplyScalar((1.2 + f * 2 + (c.status === "thinking" ? 0.6 : 0)) * m * 0.8);
679
+ const B = Math.max(1.2, Math.abs(a.live.x - h.x) * 0.9), R = Math.max(1, Math.round(Ce * y));
680
+ lt(h, a.live, a.run.side, B, 0, Be);
681
+ for (let v = 1; v <= R; v++) {
682
+ lt(h, a.live, a.run.side, B, v / Ce, ye), Be.z -= 0.6 * i, ye.z -= 0.6 * i, Ye.subVectors(ye, Be);
683
+ const M = Ye.length();
684
+ Ge.position.copy(Be).add(ye).multiplyScalar(0.5), M > 1e-5 && Ge.quaternion.setFromUnitVectors(rn, Ye.divideScalar(M)), Ge.scale.set(0.05 * i, Math.max(1e-4, M), 0.05 * i), Ge.updateMatrix(), r.setMatrixAt(l, Ge.matrix), r.setColorAt(l, n), l++, Be.copy(ye).setZ(ye.z + 0.6 * i);
685
+ }
686
+ }
687
+ r.count = l, r.instanceMatrix.needsUpdate = !0, r.instanceColor && (r.instanceColor.needsUpdate = !0);
688
+ }), /* @__PURE__ */ s("primitive", { object: r });
689
+ }
690
+ const cn = Object.fromEntries(Object.entries(tt).map(([r, n]) => [r, new e.Color(n)])), ln = new e.Vector2(9e-4, 6e-4), dn = new e.Vector2(), un = new e.Vector3();
691
+ function pn(r) {
692
+ for (const n of Pe.runs.values()) r(Gt(n, n.cu - n.hu + 2.5, n.cv - n.hv - 1, un), 1.6);
693
+ }
694
+ const fn = /* @__PURE__ */ G(Re, { children: [
695
+ /* @__PURE__ */ s("fog", { attach: "fog", args: ["#02030a", 45, 190] }),
696
+ /* @__PURE__ */ s("ambientLight", { intensity: 0.35 }),
697
+ /* @__PURE__ */ s("directionalLight", { position: [0, 4, 10], intensity: 1.2, color: "#c7d2fe" }),
698
+ /* @__PURE__ */ s(It, {}),
699
+ /* @__PURE__ */ G(Et, { children: [
700
+ /* @__PURE__ */ s(Rt, {}),
701
+ /* @__PURE__ */ s(Pt, {}),
702
+ /* @__PURE__ */ s(Ot, {})
703
+ ] })
704
+ ] });
705
+ function wn() {
706
+ const [r, n] = wt(!1);
707
+ return Je(() => {
708
+ ue.paused = r;
709
+ }, [r]), Je(() => {
710
+ const o = (i) => {
711
+ i.code === "Space" && !(i.target instanceof HTMLInputElement) && (i.preventDefault(), n((l) => !l));
712
+ };
713
+ return window.addEventListener("keydown", o), () => window.removeEventListener("keydown", o);
714
+ }, []), /* @__PURE__ */ G(
715
+ Bt,
716
+ {
717
+ title: "tunnel",
718
+ subtitle: "time warp · runs are lanes with hatchet gates · ships = agents · star shell = falkordb · stations = mcp",
719
+ preset: "lanes",
720
+ plane: "xy",
721
+ camera: { position: [0, 0, 24], fov: 62, far: 400 },
722
+ controls: { minPolarAngle: Math.PI * 0.36, maxPolarAngle: Math.PI * 0.64, minAzimuthAngle: -0.45, maxAzimuthAngle: 0.45 },
723
+ bg: "#02030a",
724
+ fit: { nRef: 4, min: 0.62, max: 1.5, minRadius: 5.5 },
725
+ agentRadius: 1.15,
726
+ graph: { natural: ft, radius: 3 },
727
+ peripheryGap: 4.2,
728
+ Background: fn,
729
+ Agent: nn,
730
+ RunMarker: $t,
731
+ McpServer: Kt,
732
+ GraphResource: kt,
733
+ cluster: { radius: 0.95, variant: "swarm", glowGain: 1.1, labelBelow: 1.1 },
734
+ extents: pn,
735
+ PostFX: /* @__PURE__ */ G(ht, { multisampling: 0, children: [
736
+ /* @__PURE__ */ s(mt, { mipmapBlur: !0, intensity: 1.25, luminanceThreshold: 0.2, luminanceSmoothing: 0.25, radius: 0.72 }),
737
+ /* @__PURE__ */ s(Mt, { offset: Ve ? dn : ln, radialModulation: !0, modulationOffset: 0.25 }),
738
+ /* @__PURE__ */ s(gt, { eskil: !1, offset: 0.22, darkness: 0.9 }),
739
+ /* @__PURE__ */ s(yt, { opacity: 0.03 })
740
+ ] }),
741
+ hudInset: /* @__PURE__ */ s("button", { className: "hud tunnel-pause", onClick: () => n((o) => !o), title: "Space", children: r ? "▶ resume warp" : "❚❚ pause warp" }),
742
+ children: [
743
+ /* @__PURE__ */ s(an, {}),
744
+ /* @__PURE__ */ s(on, {}),
745
+ /* @__PURE__ */ s(jt, {}),
746
+ /* @__PURE__ */ s(Nt, {})
747
+ ]
748
+ }
749
+ );
750
+ }
751
+ export {
752
+ wn as default
753
+ };