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