agentglow 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,436 @@
1
+ import { jsxs as W, jsx as l, Fragment as ce } from "react/jsx-runtime";
2
+ import { Trail as ge, Sparkles as Ze, Stars as He } from "@react-three/drei";
3
+ import { EffectComposer as Ne, Bloom as je, Vignette as Ke, Noise as Qe } from "@react-three/postprocessing";
4
+ import { useFrame as K } from "@react-three/fiber";
5
+ import { useRef as A, useMemo as E, useEffect as Je, useState as Xe } from "react";
6
+ import * as t from "three";
7
+ import { h as oe, i as et, T as ae, f as tt, a as H, p as nt, e as ot, l as rt, j as st, s as at, L as Ge, w as G, g as ct, b as it, K as lt, G as ut, c as J, d as Ce, k as pt, m as he, n as ft, o as dt, S as fe, R as ht, q as mt, u as yt, r as gt, t as Oe, v as Pe, x as Mt } from "./KitScene-D8qiflCw.js";
8
+ var Fe;
9
+ const U = typeof window < "u" && !!((Fe = window.matchMedia) != null && Fe.call(window, "(prefers-reduced-motion: reduce)").matches), Le = Math.PI * 2, Ae = [Math.PI * 0.5, Math.PI * 0.5 + Le / 3, Math.PI * 0.5 + Le * 2 / 3], Ye = et, wt = (e) => (oe(e, 11) - 0.5) * 2.4, Z = {
10
+ /** the galaxy's inner (tilted) group; its matrixWorld includes the kit's side placement + scale */
11
+ group: null,
12
+ pos: [],
13
+ index: /* @__PURE__ */ new Map()
14
+ };
15
+ function Be(e) {
16
+ const s = e.toLowerCase();
17
+ let a = Z.index.get(s);
18
+ if (a === void 0) {
19
+ const n = Math.max(1, Z.pos.length);
20
+ let u = 7;
21
+ for (let y = 0; y < s.length; y++) u = u * 31 + s.charCodeAt(y) >>> 0;
22
+ a = u % n, Z.index.set(s, a);
23
+ }
24
+ return a;
25
+ }
26
+ function bt(e, s) {
27
+ const a = Z.group;
28
+ return !a || !Z.pos.length ? !1 : (s.copy(Z.pos[Be(e)]).applyMatrix4(a.matrixWorld), !0);
29
+ }
30
+ const xt = new t.Color("#ef4444"), vt = new t.Color("#f59e0b"), St = new t.Color("#ffffff"), At = new t.SphereGeometry(1, 32, 32), Ct = new t.SphereGeometry(1, 24, 24), Bt = new t.SphereGeometry(0.06, 10, 10), Gt = new t.RingGeometry(0.85, 1, 48), Rt = new t.RingGeometry(0.92, 1, 48), Et = new t.Vector3();
31
+ function Tt(e) {
32
+ for (const s of G.mcpPending.values()) if (s.instance === e) return !0;
33
+ return !1;
34
+ }
35
+ function Ot({ agent: e, selected: s, onSelect: a }) {
36
+ const n = e.inst, u = n.id, y = n.type, c = ae[y], C = Ye(y), o = C ? 0.46 : 0.35, g = A(null), d = A(null), b = A(null), v = A(null), p = A(null), h = A(null), S = A(null), m = A(null), B = A(""), _ = A(1), F = E(() => new t.Color(c), [c]), q = E(() => new t.Color(), []), k = E(
37
+ () => ({
38
+ core: new t.MeshBasicMaterial({ toneMapped: !1 }),
39
+ halo: new t.MeshBasicMaterial({ color: c, transparent: !0, opacity: 0.1, blending: t.AdditiveBlending, depthWrite: !1, toneMapped: !1 }),
40
+ electron: new t.MeshBasicMaterial({ color: new t.Color(4, 4, 4), toneMapped: !1 }),
41
+ shock: new t.MeshBasicMaterial({ transparent: !0, blending: t.AdditiveBlending, depthWrite: !1, toneMapped: !1, side: t.DoubleSide }),
42
+ sel: new t.MeshBasicMaterial({ color: new t.Color(3, 3, 3), transparent: !0, opacity: 0.8, depthWrite: !1, toneMapped: !1, side: t.DoubleSide })
43
+ }),
44
+ [c]
45
+ ), M = E(() => ({ phase: oe(u, 12) * Math.PI * 2, rr: 0.75 + oe(u, 13) * 0.5, tilt: 0.25 + oe(u, 14) * 0.5, seed: oe(u, 15) * Math.PI * 2, last: -1, born: new t.Vector3(), bornSet: !1 }), [u]);
46
+ K(({ clock: w, camera: z }) => {
47
+ var Ee;
48
+ const Y = g.current;
49
+ if (!Y) return;
50
+ const $ = performance.now(), f = w.elapsedTime, r = M.last < 0 ? 0 : Math.min(0.1, f - M.last);
51
+ M.last = f;
52
+ const i = n.status, L = i === "thinking" ? C ? 1.5 : 0.75 : i === "waiting" ? C ? 0.35 : 0.18 : C ? 0.8 : 0.4;
53
+ M.phase += r * L * (U ? 0.3 : 1);
54
+ const O = (C ? 0.42 : 0.24) * tt.spread * M.rr * (U ? 0.4 : 1), x = e.live;
55
+ x.copy(e.pos), x.x += Math.cos(M.phase) * O, x.z += Math.sin(M.phase) * O, x.y += Math.sin(M.phase * 2 + M.seed) * O * M.tilt + (U ? 0 : Math.sin(f * 0.9 + M.seed) * 0.12);
56
+ const X = Math.min(1, ($ - n.bornAt) / 950);
57
+ if (X < 1) {
58
+ const T = n.parent ? H(n.parent) : void 0;
59
+ M.bornSet || (M.born.copy(T ?? x), M.bornSet = !0), T && M.born.copy(T);
60
+ const Se = 1 - Math.pow(1 - X, 3);
61
+ x.lerpVectors(Et.copy(M.born), x, Se);
62
+ }
63
+ Y.position.copy(x);
64
+ const D = nt(n, $), N = ot(n, $), ee = ($ - n.bornAt) / 1e3, j = n.exitAt ? ($ - n.exitAt) / rt(n) : 0, te = o * e.scale, ie = !n.exitAt && i === "thinking", Me = !n.exitAt && i === "waiting", Re = !n.exitAt && Tt(u), le = U ? 0.3 : 1, we = ie ? 0.5 + 0.5 * Math.sin(f * 7 * le) : 0, be = Me || Re ? 0.5 + 0.5 * Math.sin(f * 1.7 * le) : 0;
65
+ let ue = ie ? 2.4 + we * 1.8 : Me ? 0.35 + be * 0.55 : 1.3;
66
+ ue += N * 5;
67
+ const xe = ee < 0.6 ? 1 - ee / 0.6 : 0;
68
+ ue += xe * 3.5;
69
+ let ve = D * (1 + N * 0.35 + we * 0.12 + be * 0.08), re = 0;
70
+ if (n.exitAt && (re = j < 0.1 ? 1 - j / 0.1 : 0, ve = j < 0.1 ? 1 + j * 4 : 1.4 * Math.pow(Math.max(0, 1 - (j - 0.1) / 0.75), 2), ue = 2 + re * 5), d.current && (d.current.scale.setScalar(Math.max(1e-3, te * ve)), q.copy(F), Re && q.lerp(vt, 0.25 + be * 0.25), i === "failed" && q.lerp(xt, 0.8), re > 0 && q.lerp(St, re * 0.7), k.core.color.copy(q).multiplyScalar(ue)), b.current && (b.current.scale.setScalar(Math.max(1e-3, te * ve * (1.45 + N * 0.6 + we * 0.2 + xe * 1))), k.halo.opacity = (ie ? 0.09 : Me ? 0.04 : 0.06) + N * 0.06 + xe * 0.15 + re * 0.25), v.current && (v.current.visible = ie, v.current.scale.setScalar(Math.max(1e-3, te * 2.2 * D)), v.current.rotation.y += 0.07 * le, v.current.rotation.x += 0.03 * le), p.current) {
71
+ let T = -1;
72
+ ee < 0.9 ? (T = ee / 0.9, k.shock.color.copy(F).multiplyScalar(2.2 * (1 - T) * (1 - T))) : n.exitAt && j < 0.5 && (T = j / 0.5, k.shock.color.set(i === "failed" ? "#ef4444" : "#ffffff").multiplyScalar(2.5 * (1 - T) * (1 - T))), p.current.visible = T >= 0, T >= 0 && (p.current.quaternion.copy(z.quaternion), p.current.scale.setScalar(te * (1.2 + T * 2.6)));
73
+ }
74
+ if (h.current && (h.current.visible = s, h.current.quaternion.copy(z.quaternion), h.current.scale.setScalar(te * 2.6 * Math.max(0.2, D))), (Ee = m.current) == null || Ee.position.set(0, -te * 1.5 - 0.35, 0), S.current) {
75
+ const T = n.exitAt ? i === "failed" ? "failed" : "done" : ee < 2.4 ? "born" : "name";
76
+ if (T !== B.current) {
77
+ B.current = T;
78
+ const Te = u.split(":")[2], pe = `${n.name}${Te !== void 0 ? ` ${Number(Te) + 1}` : ""}`;
79
+ S.current.setText(T === "born" ? `+ ${pe}` : T === "done" ? `${pe} done` : T === "failed" ? `× ${pe}` : pe);
80
+ } else T === "name" && n.job && S.current.setText(st(n));
81
+ const Se = T === "born" ? 1 : T === "name" ? 0.85 : Math.max(0, 1 - j * 1.6);
82
+ _.current += ((at(u) ? 1 : 0) - _.current) * 0.12, S.current.setOpacity(Se * _.current * Math.min(1, ee / 0.4));
83
+ }
84
+ });
85
+ const R = (w) => (w.stopPropagation(), a(u));
86
+ return /* @__PURE__ */ W("group", { ref: g, position: e.pos, children: [
87
+ /* @__PURE__ */ l(ge, { width: C ? 1.5 : 2.6, length: C ? 3 : 5, color: c, attenuation: (w) => w * w, decay: 1, children: /* @__PURE__ */ l("mesh", { ref: d, geometry: At, material: k.core, scale: 1e-3, onClick: R, onPointerOver: () => document.body.style.cursor = "pointer", onPointerOut: () => document.body.style.cursor = "" }) }),
88
+ /* @__PURE__ */ l("mesh", { ref: b, geometry: Ct, material: k.halo, scale: 1e-3, onClick: R }),
89
+ /* @__PURE__ */ l("group", { ref: v, visible: !1, children: [0, 1, 2].map((w) => /* @__PURE__ */ l("mesh", { geometry: Bt, material: k.electron, position: [Math.cos(w * Math.PI * 2 / 3), Math.sin(w * 2.1) * 0.35, Math.sin(w * Math.PI * 2 / 3)] }, w)) }),
90
+ /* @__PURE__ */ l("mesh", { ref: p, geometry: Gt, material: k.shock, visible: !1, raycast: () => null }),
91
+ /* @__PURE__ */ l("mesh", { ref: h, geometry: Rt, material: k.sel, visible: !1, raycast: () => null }),
92
+ /* @__PURE__ */ l("group", { ref: m, children: /* @__PURE__ */ l(Ge, { ref: S, text: "", color: c, size: C ? 0.24 : 0.3, opacity: 0, fit: !0, pxRange: C ? [8, 11.5] : [9, 13] }) })
93
+ ] });
94
+ }
95
+ function Pt(e) {
96
+ const s = [];
97
+ for (let n = 0; n < e; n++) {
98
+ const u = n / e, y = 0.45 + 4.1 * Math.sqrt(u) + (Math.random() - 0.5) * 0.4, C = n % 3 / 3 * Math.PI * 2 + y * 1.3 + (Math.random() - 0.5) * 0.5;
99
+ s.push(new t.Vector3(Math.cos(C) * y, (Math.random() - 0.5) * 0.5 * (1.4 - u), Math.sin(C) * y));
100
+ }
101
+ return s;
102
+ }
103
+ const _e = 32, ze = new t.Color(5, 5, 5), Lt = 200, De = 1.35, Ue = 4.75 * De + 0.6, de = 6;
104
+ function _t({ galaxy: e }) {
105
+ const s = E(() => ct(e, Lt), [e]), a = A([]), n = A([]), u = A([]), y = A(Array(de).fill(-1)), c = A(null), C = A(null), o = A(null), g = A(null), d = s.nodes.length, b = s.ns, v = E(() => Pt(b), [b]), p = E(() => {
106
+ if (d === b) return v;
107
+ const M = new Float32Array(d * 3);
108
+ return v.forEach((R, w) => R.toArray(M, w * 3)), it(s, M, 0.55), Array.from({ length: d }, (R, w) => w < b ? v[w] : new t.Vector3().fromArray(M, w * 3));
109
+ }, [v, s, d, b]), h = E(() => s.nodes.map((M) => new t.Color(lt[M.kind] ?? "#94a3b8")), [s]), S = E(() => new Float32Array(Math.max(1, d)), [d]), m = E(() => new Uint8Array(Math.max(1, d)), [d]), B = E(() => new t.Object3D(), []), _ = E(() => new t.Color(), []), F = E(() => new t.Vector3(), []), q = E(() => {
110
+ const M = new Map(s.nodes.map((f, r) => [f.id, r])), R = [], w = [], z = /* @__PURE__ */ new Set(), Y = (f, r) => {
111
+ const i = f < r ? `${f}-${r}` : `${r}-${f}`;
112
+ f === r || z.has(i) || (z.add(i), R.push(p[f].x, p[f].y, p[f].z, p[r].x, p[r].y, p[r].z), w.push(h[f].r, h[f].g, h[f].b, h[r].r, h[r].g, h[r].b));
113
+ };
114
+ for (const f of s.links) {
115
+ const r = M.get(f.source), i = M.get(f.target);
116
+ r !== void 0 && i !== void 0 && p[r].distanceTo(p[i]) < 3 && Y(r, i);
117
+ }
118
+ for (let f = 0; f < d; f++) {
119
+ let r = -1, i = -1, L = 1e9, O = 1e9;
120
+ for (let x = 0; x < d; x++) {
121
+ if (x === f) continue;
122
+ const X = p[f].distanceToSquared(p[x]);
123
+ X < L ? (i = r, O = L, r = x, L = X) : X < O && (i = x, O = X);
124
+ }
125
+ r >= 0 && Y(f, r), i >= 0 && O < 1.2 && Y(f, i);
126
+ }
127
+ const $ = new t.BufferGeometry();
128
+ return $.setAttribute("position", new t.Float32BufferAttribute(R, 3)), $.setAttribute("color", new t.Float32BufferAttribute(w, 3)), $;
129
+ }, [s, p, h, d]);
130
+ Je(() => (Z.pos = p, Z.index = new Map(s.nodes.map((M, R) => [M.name.toLowerCase(), R])), Z.group = c.current, () => void (Z.group = null)), [s, p]), K(({ camera: M, clock: R }) => {
131
+ const w = c.current, z = C.current;
132
+ if (!w || !z) return;
133
+ w.updateMatrixWorld();
134
+ const Y = performance.now();
135
+ S.fill(0), m.fill(0);
136
+ let $ = 0;
137
+ for (const r of G.flares) {
138
+ const i = (Y - r.start) / 1e3, L = Be(r.node), O = Math.exp(-i * 1.3);
139
+ if (O > S[L] && (S[L] = O), r.op === "write" && (m[L] = 1), o.current && $ < _e && i < 1.6) {
140
+ F.copy(p[L]).applyMatrix4(w.matrix), B.position.copy(F), B.quaternion.copy(M.quaternion);
141
+ const x = i / 1.6;
142
+ B.scale.setScalar((r.op === "write" ? 0.6 + x * 3.2 : 0.3 + x * 1.4) * (1 - x * 0.2)), B.updateMatrix(), o.current.setMatrixAt($, B.matrix), r.op === "write" ? _.copy(ze).multiplyScalar(1 - x) : _.copy(h[L]).multiplyScalar(3 * (1 - x)), o.current.setColorAt($, _), $++;
143
+ }
144
+ }
145
+ o.current && (o.current.count = $, o.current.instanceMatrix.needsUpdate = !0, o.current.instanceColor && (o.current.instanceColor.needsUpdate = !0));
146
+ let f = 0;
147
+ for (let r = G.flares.length - 1; r >= 0 && f < de; r--) {
148
+ const i = G.flares[r], L = (Y - i.start) / 1e3;
149
+ if (L > 1.8 || i.area) continue;
150
+ const O = Be(i.node);
151
+ let x = !1;
152
+ for (let N = 0; N < f; N++) y.current[N] === O && (x = !0);
153
+ if (x) continue;
154
+ const X = a.current[f], D = n.current[f];
155
+ X && D && (X.position.copy(p[O]), (y.current[f] !== O || u.current[f] !== i.op) && (D.setText(`${i.op === "write" ? "wrote · " : ""}${i.node}`), u.current[f] = i.op, D.setColor(i.op === "write" ? "#ffffff" : `#${h[O].getHexString()}`)), D.setOpacity(Math.min(1, (1.8 - L) / 0.5)), X.visible = !0), y.current[f] = O, f++;
156
+ }
157
+ for (let r = f; r < de; r++)
158
+ y.current[r] = -1, a.current[r] && (a.current[r].visible = !1);
159
+ for (let r = 0; r < d; r++) {
160
+ const i = S[r];
161
+ B.position.copy(p[r]), B.quaternion.identity(), B.scale.setScalar(1 + i * (m[r] ? 4.5 : 3)), B.updateMatrix(), z.setMatrixAt(r, B.matrix), _.copy(h[r]).multiplyScalar(0.85 + i * 5), m[r] && _.lerp(ze, i * 0.7), z.setColorAt(r, _);
162
+ }
163
+ z.instanceMatrix.needsUpdate = !0, z.instanceColor && (z.instanceColor.needsUpdate = !0), g.current && g.current.scale.setScalar(1 + Math.sin(R.elapsedTime * 1.3) * 0.06);
164
+ });
165
+ const k = E(() => new t.Color("#c7d2fe").multiplyScalar(2.4), []);
166
+ return /* @__PURE__ */ W(ce, { children: [
167
+ /* @__PURE__ */ W("group", { ref: c, rotation: [0.3, 0, 0.08], scale: De, children: [
168
+ /* @__PURE__ */ W("instancedMesh", { ref: C, args: [void 0, void 0, Math.max(1, d)], frustumCulled: !1, children: [
169
+ /* @__PURE__ */ l("sphereGeometry", { args: [0.065, 10, 10] }),
170
+ /* @__PURE__ */ l("meshBasicMaterial", { toneMapped: !1 })
171
+ ] }),
172
+ /* @__PURE__ */ l("lineSegments", { geometry: q, children: /* @__PURE__ */ l("lineBasicMaterial", { vertexColors: !0, transparent: !0, opacity: 0.4, blending: t.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) }),
173
+ /* @__PURE__ */ W("mesh", { ref: g, children: [
174
+ /* @__PURE__ */ l("sphereGeometry", { args: [0.38, 32, 32] }),
175
+ /* @__PURE__ */ l("meshBasicMaterial", { color: k, toneMapped: !1 })
176
+ ] }),
177
+ /* @__PURE__ */ W("mesh", { children: [
178
+ /* @__PURE__ */ l("sphereGeometry", { args: [1.1, 32, 32] }),
179
+ /* @__PURE__ */ l("meshBasicMaterial", { color: "#818cf8", transparent: !0, opacity: 0.07, blending: t.AdditiveBlending, depthWrite: !1, toneMapped: !1 })
180
+ ] }),
181
+ Array.from({ length: de }, (M, R) => /* @__PURE__ */ l("group", { ref: (w) => void (a.current[R] = w), visible: !1, children: /* @__PURE__ */ l(Ge, { ref: (w) => void (n.current[R] = w), position: [0, 0.32, 0], text: "", size: 0.2, opacity: 0, pxRange: [8, 11.5] }) }, R)),
182
+ /* @__PURE__ */ l(Ze, { count: U ? 30 : 110, scale: [9, 1.3, 9], size: 0.7, speed: U ? 0.05 : 0.3, color: "#a5b4fc", opacity: 0.6 })
183
+ ] }),
184
+ /* @__PURE__ */ W("instancedMesh", { ref: o, args: [void 0, void 0, _e], frustumCulled: !1, children: [
185
+ /* @__PURE__ */ l("ringGeometry", { args: [0.2, 0.26, 40] }),
186
+ /* @__PURE__ */ l("meshBasicMaterial", { transparent: !0, blending: t.AdditiveBlending, depthWrite: !1, toneMapped: !1, side: t.DoubleSide })
187
+ ] }),
188
+ /* @__PURE__ */ l(ut, { position: [0, -0.6, Ue * 0.78], color: "#a5b4fc", size: 0.42, pxRange: [10, 15] })
189
+ ] });
190
+ }
191
+ const I = new t.Vector3(), V = new t.Vector3(), P = new t.Color(), Q = new t.Color(), Ie = new t.Color("#f59e0b"), zt = new t.Color("#ef4444"), se = 900, ne = 22;
192
+ function It() {
193
+ const e = E(() => {
194
+ const s = new t.BufferGeometry();
195
+ return s.setAttribute("position", new t.BufferAttribute(new Float32Array(se * 6), 3)), s.setAttribute("color", new t.BufferAttribute(new Float32Array(se * 6), 3)), s;
196
+ }, []);
197
+ return K(({ clock: s }) => {
198
+ const a = e.getAttribute("position"), n = e.getAttribute("color"), u = performance.now(), y = s.elapsedTime;
199
+ let c = 0;
200
+ const C = (o, g, d, b) => {
201
+ c >= se || (a.setXYZ(c * 2, o.x, o.y, o.z), a.setXYZ(c * 2 + 1, g.x, g.y, g.z), n.setXYZ(c * 2, d.r, d.g, d.b), n.setXYZ(c * 2 + 1, b.r, b.g, b.b), c++);
202
+ };
203
+ for (const o of G.flares) {
204
+ const g = (u - o.start) / 1900;
205
+ if (g >= 1 || !J(o.instance)) continue;
206
+ const d = H(o.instance);
207
+ if (!d || !bt(o.node, V)) continue;
208
+ const b = G.instances.get(o.instance), v = 1 - g;
209
+ o.op === "write" ? (P.setRGB(3, 3, 3.4).multiplyScalar(v), Q.setRGB(5, 5, 5).multiplyScalar(v)) : (P.set(b ? ae[b.type] : "#c7d2fe").multiplyScalar(1.6 * v), Q.copy(P).multiplyScalar(1.6)), C(d, V, P, Q);
210
+ }
211
+ for (const o of G.instances.values()) {
212
+ if (!o.parent || !J(o)) continue;
213
+ const g = G.instances.get(o.parent);
214
+ if (!g) continue;
215
+ const d = (u - o.bornAt) / 1e3, b = d < 1.4 ? 1 - d / 1.4 : 0, v = Ye(o.type) && !o.exitAt ? 0.35 : 0, p = Math.max(b * 3, v);
216
+ if (p <= 0.01) continue;
217
+ const h = H(o.parent), S = H(o.id);
218
+ !h || !S || (P.set(ae[g.type]).multiplyScalar(p), Q.set(ae[o.type]).multiplyScalar(p * 1.4), C(h, S, P, Q));
219
+ }
220
+ for (const o of G.mcpPending.values()) {
221
+ if (!J(o.instance)) continue;
222
+ const g = H(o.instance), d = G.mcpServers.get(o.server), b = Ce(o.server);
223
+ if (!g || !d || !b) continue;
224
+ V.copy(b), V.y += me(d.slot);
225
+ const v = pt(o, u), p = Math.min(1, v / 2.2), h = Q.set(d.color);
226
+ p < 0.5 ? h.lerp(Ie, p * 2) : h.copy(Ie).lerp(zt, (p - 0.5) * 2);
227
+ const S = 0.8 + Math.min(2.5, v * 0.9), m = y * (U ? 0.3 : 1.4);
228
+ for (let B = 0; B < ne; B++) {
229
+ const _ = B / ne, F = (B + 0.55) / ne, q = ((_ - m) % 1 + 1) % 1, k = 0.25 + Math.pow(1 - q, 6) * 2.2 + ((_ * 3 - m * 3) % 1 + 1) % 1 * 0.15;
230
+ P.copy(h).multiplyScalar(k * S), I.copy(g).lerp(V, _);
231
+ const M = I.x, R = I.y, w = I.z;
232
+ if (I.copy(g).lerp(V, F), c >= se) break;
233
+ a.setXYZ(c * 2, M, R, w), a.setXYZ(c * 2 + 1, I.x, I.y, I.z), n.setXYZ(c * 2, P.r, P.g, P.b), n.setXYZ(c * 2 + 1, P.r, P.g, P.b), c++;
234
+ }
235
+ }
236
+ for (const o of G.mcpResolved) {
237
+ const g = (u - o.resolvedAt) / 700;
238
+ if (g >= 1 || !J(o.instance)) continue;
239
+ const d = H(o.instance), b = G.mcpServers.get(o.server), v = Ce(o.server);
240
+ if (!d || !b || !v) continue;
241
+ V.copy(v), V.y += me(b.slot);
242
+ const p = 1 - g;
243
+ for (let h = 0; h < ne; h++) {
244
+ const S = h / ne, m = (h + 1) / ne, B = Math.abs(S - p), _ = (1 - g) * (0.15 + Math.exp(-B * 18) * 5);
245
+ P.set(b.color).lerp(Q.setRGB(1, 1, 1), 0.6).multiplyScalar(_), I.copy(d).lerp(V, S);
246
+ const F = I.x, q = I.y, k = I.z;
247
+ if (I.copy(d).lerp(V, m), c >= se) break;
248
+ a.setXYZ(c * 2, F, q, k), a.setXYZ(c * 2 + 1, I.x, I.y, I.z), n.setXYZ(c * 2, P.r, P.g, P.b), n.setXYZ(c * 2 + 1, P.r, P.g, P.b), c++;
249
+ }
250
+ }
251
+ e.setDrawRange(0, c * 2), a.needsUpdate = !0, n.needsUpdate = !0;
252
+ }), /* @__PURE__ */ l("lineSegments", { geometry: e, frustumCulled: !1, children: /* @__PURE__ */ l("lineBasicMaterial", { vertexColors: !0, transparent: !0, opacity: 0.95, blending: t.AdditiveBlending, depthWrite: !1, toneMapped: !1 }) });
253
+ }
254
+ function kt(e, s, a, n, u) {
255
+ const y = (e.x + s.x) / 2, c = (e.y + s.y) / 2 + n, C = (e.z + s.z) / 2, o = 1 - a;
256
+ return u.set(o * o * e.x + 2 * o * a * y + a * a * s.x, o * o * e.y + 2 * o * a * c + a * a * s.y, o * o * e.z + 2 * o * a * C + a * a * s.z);
257
+ }
258
+ function $t({ comet: e }) {
259
+ const s = A(null), a = G.instances.get(e.from), n = a ? ae[a.type] : "#ffffff", u = E(() => new t.Color(n).multiplyScalar(4), [n]);
260
+ return K(() => {
261
+ const y = performance.now(), c = ft(e, y), C = c < 0.5 ? 2 * c * c : 1 - Math.pow(-2 * c + 2, 2) / 2, o = H(e.from), g = H(e.to);
262
+ !s.current || !o || !g || (V.copy(o), kt(V, g, C, 1.2 + o.distanceTo(g) * 0.15, s.current.position), s.current.scale.setScalar(dt(e, y) ? 1 : 1e-3));
263
+ }), /* @__PURE__ */ l(ge, { width: 2.2, length: 7, color: n, attenuation: (y) => y * y, decay: 1.2, children: /* @__PURE__ */ W("mesh", { ref: s, scale: 1e-3, children: [
264
+ /* @__PURE__ */ l("sphereGeometry", { args: [0.13, 14, 14] }),
265
+ /* @__PURE__ */ l("meshBasicMaterial", { color: u, toneMapped: !1 })
266
+ ] }) });
267
+ }
268
+ function qt() {
269
+ const [e, s] = Xe([]), a = A(-1);
270
+ return K(() => {
271
+ let n = G.comets.length * 7919 + he.version * 104729;
272
+ for (const u of G.comets) n += u.id;
273
+ n !== a.current && (a.current = n, s(he.grouped ? G.comets.filter((u) => J(u.from) && J(u.to)) : G.comets.slice()));
274
+ }), /* @__PURE__ */ l(ce, { children: e.map((n) => /* @__PURE__ */ l($t, { comet: n }, n.id)) });
275
+ }
276
+ const Vt = new t.Vector3(0, 1, 0);
277
+ function Wt({ call: e }) {
278
+ var u;
279
+ const s = A(null), a = ((u = G.mcpServers.get(e.server)) == null ? void 0 : u.color) ?? "#e5e7eb", n = E(() => new t.Color(a).lerp(new t.Color("#ffffff"), 0.35).multiplyScalar(6), [a]);
280
+ return K(() => {
281
+ var v;
282
+ const y = performance.now(), c = Math.min(1, (y - e.start) / e.dur), C = c * c * (3 - 2 * c), o = H(e.instance), g = Ce(e.server);
283
+ if (!s.current || !o || !g) return;
284
+ V.copy(g), V.y += me(((v = G.mcpServers.get(e.server)) == null ? void 0 : v.slot) ?? 0);
285
+ const d = e.phase === "call" ? o : V, b = e.phase === "call" ? V : o;
286
+ s.current.position.copy(d).lerp(b, C), I.copy(b).sub(d).normalize(), s.current.quaternion.setFromUnitVectors(Vt, I), s.current.scale.set(c >= 1 ? 1e-3 : 1, c >= 1 ? 1e-3 : 1, c >= 1 ? 1e-3 : 1);
287
+ }), /* @__PURE__ */ l(ge, { width: 1.4, length: 10, color: a, attenuation: (y) => y * y * y, decay: 1.5, children: /* @__PURE__ */ W("mesh", { ref: s, scale: 1e-3, children: [
288
+ /* @__PURE__ */ l("capsuleGeometry", { args: [0.05, 0.7, 4, 8] }),
289
+ /* @__PURE__ */ l("meshBasicMaterial", { color: n, toneMapped: !1 })
290
+ ] }) });
291
+ }
292
+ function Ft() {
293
+ const [e, s] = Xe([]), a = A(-1);
294
+ return K(() => {
295
+ let n = G.mcpCalls.length * 7919 + he.version * 104729;
296
+ for (const u of G.mcpCalls) n += u.id;
297
+ n !== a.current && (a.current = n, s(he.grouped ? G.mcpCalls.filter((u) => J(u.instance)) : G.mcpCalls.slice()));
298
+ }), /* @__PURE__ */ l(ce, { children: e.map((n) => /* @__PURE__ */ l(Wt, { call: n }, n.id)) });
299
+ }
300
+ new t.CylinderGeometry(0.22, 0.22, 0.75, 12);
301
+ new t.TorusGeometry(0.5, 0.04, 8, 40);
302
+ new t.BoxGeometry(0.3, 0.03, 0.03);
303
+ new t.BoxGeometry(0.75, 0.02, 0.42);
304
+ new t.SphereGeometry(0.55, 20, 20);
305
+ const me = (e) => e % 2 ? 0.9 : 1.6, Xt = new t.OctahedronGeometry(0.3, 0);
306
+ new t.EdgesGeometry(Xt);
307
+ new t.Vector3();
308
+ new t.Vector3();
309
+ const ye = { queued: "#64748b", running: "#fbbf24", done: "#22c55e", failed: "#ef4444" }, Yt = new t.TorusGeometry(1, 1, 6, 320);
310
+ function Dt() {
311
+ return new t.ShaderMaterial({
312
+ uniforms: { uA: { value: 4 }, uB: { value: 3 }, uTube: { value: 0.03 }, uColor: { value: new t.Color() }, uOpacity: { value: 0 } },
313
+ vertexShader: (
314
+ /* glsl */
315
+ `
316
+ uniform float uA; uniform float uB; uniform float uTube;
317
+ void main(){
318
+ float th = atan(position.y, position.x);
319
+ vec3 c = vec3(cos(th), sin(th), 0.0);
320
+ vec3 off = position - c * 1.0; // torus radius 1, tube radius 1
321
+ vec3 p = vec3(cos(th) * uA, sin(th) * uB, 0.0) + off * uTube;
322
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(p, 1.0);
323
+ }`
324
+ ),
325
+ fragmentShader: (
326
+ /* glsl */
327
+ `
328
+ uniform vec3 uColor; uniform float uOpacity;
329
+ void main(){ gl_FragColor = vec4(uColor * uOpacity, 1.0); }`
330
+ ),
331
+ transparent: !0,
332
+ depthWrite: !1,
333
+ blending: t.AdditiveBlending
334
+ });
335
+ }
336
+ const Ut = new t.OctahedronGeometry(0.26, 0), Zt = new t.RingGeometry(0.34, 0.42, 40), Ht = new t.SphereGeometry(0.16, 12, 12), ke = new t.Matrix4(), $e = new t.Vector3(), qe = new t.Quaternion(), Ve = new t.Quaternion(), Nt = new t.Vector3(1, 0, 0), We = (e, s, a, n) => n.set(Math.cos(a) * e, Math.sin(a) * s, 0);
337
+ function jt({ run: e, color: s }) {
338
+ yt();
339
+ const a = e.status !== "started", n = [{ text: "hatchet ", color: s }];
340
+ if (e.hasSteps) {
341
+ const { shown: u, more: y } = gt(e);
342
+ for (const c of u) n.push({ text: ` ${e.steps[c] === "running" ? "›" : "·"}${c}`, color: ye[e.steps[c]] });
343
+ y && n.push({ text: ` +${y}`, color: ye.queued });
344
+ } else n.push({ text: a ? "complete" : Oe(e) ? Pe(e) : "running…", color: "#94a3b8" });
345
+ return e.hasSteps && !a && Oe(e) && n.push({ text: ` ${Pe(e)}`, color: "#94a3b8" }), a && n.push({ text: " brief ready", color: "#4ade80" }), /* @__PURE__ */ l(Ge, { text: e.topic, secondary: n, textColor: "#f1f5f9", color: s, size: 0.32, maxWidth: 9, opacity: a ? 0.65 : 1, fadeMs: 300, anchorY: "bottom", pxRange: [9.5, 14] });
346
+ }
347
+ function Kt({ run: e }) {
348
+ const s = e.id, a = e.color, n = E(() => wt(s), [s]), u = E(() => (oe(s, 16) - 0.5) * 0.24, [s]), y = A(null), c = A([]), C = A([]), o = A([]), g = A(null), d = A(null), b = E(() => new t.Color(), []), v = E(() => new t.Color(a), [a]), p = E(
349
+ () => ({
350
+ orbit: Dt(),
351
+ beads: fe.map(() => new t.MeshBasicMaterial({ transparent: !0, toneMapped: !1 })),
352
+ halos: fe.map(() => new t.MeshBasicMaterial({ transparent: !0, blending: t.AdditiveBlending, depthWrite: !1, toneMapped: !1, side: t.DoubleSide })),
353
+ runner: new t.MeshBasicMaterial({ color: new t.Color("#fde68a").multiplyScalar(5), toneMapped: !1 })
354
+ }),
355
+ []
356
+ );
357
+ return K(({ clock: h }) => {
358
+ var f;
359
+ const S = y.current;
360
+ if (!S) return;
361
+ const m = e.run ?? G.runs.get(s), B = performance.now(), _ = h.elapsedTime;
362
+ $e.crossVectors(e.side, e.axis), ke.makeBasis(e.side, e.axis, $e), qe.setFromRotationMatrix(ke), Ve.setFromAxisAngle(Nt, u), S.quaternion.copy(qe).multiply(Ve), S.position.copy(e.origin);
363
+ const F = e.hu + 0.35, q = e.hv + 0.35, k = m ? Math.min(1, (B - m.startedAt) / 900) : 1, M = m != null && m.endedAt ? Math.max(0, 1 - (B - m.endedAt) / ht) : 1, R = k * M, w = m != null && m.endedAt ? Math.exp(-((B - m.endedAt) / 1e3) * 2.5) : 0, z = p.orbit.uniforms;
364
+ z.uA.value = F, z.uB.value = q, z.uOpacity.value = R * 0.75, z.uColor.value.copy(v).multiplyScalar(1.1 + w * 3), (m == null ? void 0 : m.status) === "completed" && z.uColor.value.lerp(b.set("#4ade80"), w);
365
+ for (let r = 0; r < fe.length; r++) {
366
+ const i = m ? mt(m, r) : "queued", L = !!(m != null && m.hasSteps), O = C.current[r];
367
+ if (O && (O.visible = L, We(F, q, Ae[r] + n, O.position)), !L) continue;
368
+ const x = i === "running" ? 0.5 + 0.5 * Math.sin(_ * (U ? 2 : 6)) : 0, X = c.current[r];
369
+ X && (b.set(ye[i]).multiplyScalar(i === "queued" ? 0.7 : i === "running" ? 2 + x * 2 : 2.4), p.beads[r].color.copy(b), p.beads[r].opacity = R, X.scale.setScalar((i === "running" ? 1.3 + x * 0.25 : i === "done" ? 1.05 : 0.8) * Math.max(0.01, R)));
370
+ const D = o.current[r];
371
+ D && (D.visible = i !== "queued", p.halos[r].color.set(ye[i]), p.halos[r].opacity = R * (i === "running" ? 0.35 + x * 0.4 : 0.18), D.scale.setScalar(i === "running" ? 1.6 + x * 0.9 : 1.3));
372
+ }
373
+ const Y = m != null && m.handoffAt ? (B - m.handoffAt) / 1400 : 2;
374
+ if (g.current && m) {
375
+ const r = Ae[m.handoffFrom] + n;
376
+ let i = Ae[m.handoffTo] + n;
377
+ i < r && (i += Math.PI * 2);
378
+ const L = Y >= 1 ? 1 : 1 - Math.pow(1 - Math.max(0, Y), 3);
379
+ We(F, q, r + (i - r) * L, g.current.position), g.current.scale.setScalar(Y < 1 ? 1 : 1e-3);
380
+ }
381
+ const $ = Math.hypot(e.side.z * F, e.axis.z * q);
382
+ (f = d.current) == null || f.position.set(e.origin.x, 0.4, e.origin.z - $ - 0.5);
383
+ }), /* @__PURE__ */ W(ce, { children: [
384
+ /* @__PURE__ */ W("group", { ref: y, children: [
385
+ /* @__PURE__ */ l("mesh", { geometry: Yt, material: p.orbit, frustumCulled: !1 }),
386
+ fe.map((h) => /* @__PURE__ */ W("group", { ref: (S) => void (C.current[h] = S), visible: !1, children: [
387
+ /* @__PURE__ */ l("mesh", { ref: (S) => void (c.current[h] = S), geometry: Ut, material: p.beads[h] }),
388
+ /* @__PURE__ */ l("mesh", { ref: (S) => void (o.current[h] = S), geometry: Zt, material: p.halos[h] })
389
+ ] }, h)),
390
+ /* @__PURE__ */ l(ge, { width: 3.2, length: 9, color: "#fde68a", attenuation: (h) => h * h, children: /* @__PURE__ */ l("mesh", { ref: g, geometry: Ht, material: p.runner, scale: 1e-3 }) })
391
+ ] }),
392
+ /* @__PURE__ */ l("group", { ref: d, children: e.run && /* @__PURE__ */ l(jt, { run: e.run, color: a }) })
393
+ ] });
394
+ }
395
+ const Qt = { tint: "#93c5fd", tintAmt: 0.15, size: 0.8, lift: me }, Jt = /* @__PURE__ */ W(ce, { children: [
396
+ /* @__PURE__ */ l("fog", { attach: "fog", args: ["#03050b", 70, 170] }),
397
+ /* @__PURE__ */ l(He, { radius: 130, depth: 50, count: U ? 1500 : 5e3, factor: 3.4, saturation: 0.4, fade: !0, speed: U ? 0 : 0.2 })
398
+ ] });
399
+ function an() {
400
+ return /* @__PURE__ */ W(
401
+ Mt,
402
+ {
403
+ title: "orbit · planetary system",
404
+ subtitle: "agents orbit at the centre · each Hatchet run is an orbit · agents are born, work and implode · MCP stations on the rim · knowledge-graph galaxy on the side",
405
+ preset: "radial",
406
+ plane: "xz",
407
+ camera: { position: [0, 25, 21], fov: 50 },
408
+ controls: { maxPolarAngle: Math.PI * 0.42 },
409
+ bg: "#03050b",
410
+ fit: { nRef: 4, min: 0.62, max: 1.6, minRadius: 5.5 },
411
+ agentRadius: 0.85,
412
+ graph: { natural: Ue, radius: 2.6 },
413
+ peripheryGap: 3.8,
414
+ Background: Jt,
415
+ Agent: Ot,
416
+ RunMarker: Kt,
417
+ mcpStyle: Qt,
418
+ GraphResource: _t,
419
+ cluster: { radius: 1.35, variant: "stars" },
420
+ clusterOffset: [0, 1.2, 0],
421
+ PostFX: /* @__PURE__ */ W(Ne, { multisampling: 0, children: [
422
+ /* @__PURE__ */ l(je, { mipmapBlur: !0, intensity: 1.3, luminanceThreshold: 0.2, luminanceSmoothing: 0.25, radius: 0.78 }),
423
+ /* @__PURE__ */ l(Ke, { eskil: !1, offset: 0.25, darkness: 0.85 }),
424
+ /* @__PURE__ */ l(Qe, { opacity: 0.025 })
425
+ ] }),
426
+ children: [
427
+ /* @__PURE__ */ l(It, {}),
428
+ /* @__PURE__ */ l(qt, {}),
429
+ /* @__PURE__ */ l(Ft, {})
430
+ ]
431
+ }
432
+ );
433
+ }
434
+ export {
435
+ an as default
436
+ };