monomind 2.1.7 → 2.1.9
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.
- package/package.json +1 -1
- package/packages/@monomind/cli/.claude/helpers/handlers/capture-handler.cjs +68 -11
- package/packages/@monomind/cli/.claude/helpers/handlers/session-restore-handler.cjs +46 -12
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +7 -3
- package/packages/@monomind/cli/dist/src/init/executor.js +9 -24
- package/packages/@monomind/cli/dist/src/init/helpers-generator.d.ts +13 -0
- package/packages/@monomind/cli/dist/src/init/helpers-generator.js +28 -0
- package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +28 -38
- package/packages/@monomind/cli/dist/src/ui/dashboard.html +28 -13
- package/packages/@monomind/cli/dist/src/ui/mastermind-diagram-fallback.html +1069 -0
- package/packages/@monomind/cli/dist/src/ui/orgs.html +36 -2
- package/packages/@monomind/cli/dist/src/ui/server.mjs +78 -31
- package/packages/@monomind/cli/dist/src/utils/input-guards.d.ts +6 -0
- package/packages/@monomind/cli/dist/src/utils/input-guards.js +6 -0
- package/packages/@monomind/cli/package.json +4 -3
|
@@ -0,0 +1,1069 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>MASTERMIND — Live Dashboard</title>
|
|
7
|
+
<style>
|
|
8
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
9
|
+
html, body {
|
|
10
|
+
width: 100%; height: 100%; overflow: hidden;
|
|
11
|
+
background: #07071a;
|
|
12
|
+
font-family: 'Azeret Mono', 'Space Mono', 'Courier New', monospace;
|
|
13
|
+
color: #e0e0ff;
|
|
14
|
+
user-select: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* ── Main layout ── */
|
|
18
|
+
#app { display: flex; height: 100vh; }
|
|
19
|
+
#sidebar {
|
|
20
|
+
width: 220px; flex-shrink: 0;
|
|
21
|
+
background: oklch(9% 0.012 186);
|
|
22
|
+
border-right: 1px solid oklch(62% 0.2 186 / 0.18);
|
|
23
|
+
display: flex; flex-direction: column;
|
|
24
|
+
overflow: hidden; z-index: 10;
|
|
25
|
+
}
|
|
26
|
+
#stage-wrap { flex: 1; position: relative; overflow: hidden; }
|
|
27
|
+
#detail-panel {
|
|
28
|
+
width: 0; flex-shrink: 0; overflow: hidden;
|
|
29
|
+
background: oklch(9% 0.012 186);
|
|
30
|
+
border-left: 1px solid oklch(62% 0.2 186 / 0.18);
|
|
31
|
+
transition: width 0.3s ease;
|
|
32
|
+
display: flex; flex-direction: column;
|
|
33
|
+
z-index: 10;
|
|
34
|
+
}
|
|
35
|
+
#detail-panel.open { width: 280px; }
|
|
36
|
+
#stage { position: absolute; inset: 0; width: 100%; height: 100%; }
|
|
37
|
+
|
|
38
|
+
/* ── Sidebar ── */
|
|
39
|
+
#sb-header {
|
|
40
|
+
padding: 14px 14px 10px;
|
|
41
|
+
border-bottom: 1px solid oklch(62% 0.2 186 / 0.18);
|
|
42
|
+
flex-shrink: 0;
|
|
43
|
+
}
|
|
44
|
+
#sb-title {
|
|
45
|
+
font-size: 8px; letter-spacing: 4px; color: oklch(52% 0.1 186); margin-bottom: 4px;
|
|
46
|
+
}
|
|
47
|
+
.live-row { display: flex; align-items: center; gap: 6px; }
|
|
48
|
+
.l-dot {
|
|
49
|
+
width: 6px; height: 6px; border-radius: 50%;
|
|
50
|
+
background: #252560; flex-shrink: 0;
|
|
51
|
+
transition: background 0.5s;
|
|
52
|
+
}
|
|
53
|
+
.l-dot.on { background: #28c068; }
|
|
54
|
+
@media (prefers-reduced-motion: no-preference) { .l-dot.on { animation: ldp 2s ease-in-out infinite; } }
|
|
55
|
+
@keyframes ldp { 0%,100%{opacity:1} 50%{opacity:0.4} }
|
|
56
|
+
#l-status { font-size: 9px; letter-spacing: 2px; color: oklch(44% 0.08 186); }
|
|
57
|
+
#l-agents { font-size: 8px; color: oklch(40% 0.07 186); margin-left: auto; }
|
|
58
|
+
#sb-sessions {
|
|
59
|
+
flex: 1; overflow-y: auto; padding: 8px 0;
|
|
60
|
+
scrollbar-width: thin; scrollbar-color: oklch(62% 0.2 186 / 0.3) transparent;
|
|
61
|
+
}
|
|
62
|
+
#sb-sessions::-webkit-scrollbar { width: 4px; }
|
|
63
|
+
#sb-sessions::-webkit-scrollbar-thumb { background: oklch(62% 0.2 186 / 0.3); border-radius: 2px; }
|
|
64
|
+
.sess-item {
|
|
65
|
+
padding: 8px 14px; cursor: pointer;
|
|
66
|
+
border-left: 2px solid transparent;
|
|
67
|
+
transition: background 0.15s, border-color 0.15s;
|
|
68
|
+
}
|
|
69
|
+
.sess-item:hover { background: oklch(62% 0.2 186 / 0.09); }
|
|
70
|
+
.sess-item.active { border-left-color: transparent; background: oklch(62% 0.2 186 / 0.14); box-shadow: inset 0 0 0 1px oklch(62% 0.2 186 / 0.32); }
|
|
71
|
+
.sess-item.running { border-left-color: #28c068; }
|
|
72
|
+
.sess-ts { font-size: 10px; color: oklch(42% 0.05 186); margin-bottom: 3px; }
|
|
73
|
+
.sess-prompt {
|
|
74
|
+
font-size: 12px; color: oklch(70% 0.05 186); line-height: 1.4;
|
|
75
|
+
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 188px;
|
|
76
|
+
}
|
|
77
|
+
.sess-badges { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
|
|
78
|
+
.sess-project { font-size: 7px; color: oklch(40% 0.1 186); letter-spacing: 1px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
79
|
+
.sess-badge {
|
|
80
|
+
font-size: 8px; padding: 2px 6px; border-radius: 3px;
|
|
81
|
+
border: 1px solid oklch(62% 0.2 186 / 0.25); color: oklch(62% 0.09 186);
|
|
82
|
+
background: oklch(62% 0.2 186 / 0.08);
|
|
83
|
+
}
|
|
84
|
+
.sess-badge.running-badge { border-color: rgba(40,192,104,0.4); color: #28c068; background: rgba(40,192,104,0.08); }
|
|
85
|
+
#git-user-row {
|
|
86
|
+
display: flex; align-items: center; gap: 5px;
|
|
87
|
+
margin-top: 7px; padding-top: 6px;
|
|
88
|
+
border-top: 1px solid oklch(62% 0.2 186 / 0.12);
|
|
89
|
+
}
|
|
90
|
+
#git-user-icon { font-size: 9px; color: #3a3a70; }
|
|
91
|
+
#git-user-name {
|
|
92
|
+
font-size: 9px; letter-spacing: 0.5px; color: #4a4a90;
|
|
93
|
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
94
|
+
}
|
|
95
|
+
#git-cwd-row {
|
|
96
|
+
display: flex; align-items: center; gap: 5px; margin-top: 4px;
|
|
97
|
+
}
|
|
98
|
+
#git-cwd-icon { font-size: 9px; color: #2a2a58; }
|
|
99
|
+
#git-cwd-name {
|
|
100
|
+
font-size: 9px; letter-spacing: 0.3px; color: #38386a;
|
|
101
|
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
102
|
+
direction: rtl; text-align: left;
|
|
103
|
+
}
|
|
104
|
+
.sess-trace-link {
|
|
105
|
+
font-size: 7px; color: #3a3a70; text-decoration: none; letter-spacing: 0.5px;
|
|
106
|
+
padding: 1px 5px; border: 1px solid oklch(62% 0.2 186 / 0.2); border-radius: 3px;
|
|
107
|
+
margin-left: auto; flex-shrink: 0;
|
|
108
|
+
}
|
|
109
|
+
.sess-trace-link:hover { color: oklch(66% 0.11 186); border-color: oklch(62% 0.2 186 / 0.5); }
|
|
110
|
+
.dp-export-btn {
|
|
111
|
+
font-size: 9px; font-family: inherit; color: oklch(58% 0.09 186); text-decoration: none;
|
|
112
|
+
padding: 4px 8px; border: 1px solid oklch(62% 0.2 186 / 0.25); border-radius: 4px;
|
|
113
|
+
background: oklch(62% 0.2 186 / 0.07); cursor: pointer; letter-spacing: 0.3px;
|
|
114
|
+
}
|
|
115
|
+
.dp-export-btn:hover { color: oklch(72% 0.12 186); border-color: oklch(62% 0.2 186 / 0.5); background: oklch(62% 0.2 186 / 0.15); }
|
|
116
|
+
#sb-no-sessions {
|
|
117
|
+
padding: 20px 14px; font-size: 9px; color: oklch(42% 0.06 186); line-height: 1.7;
|
|
118
|
+
text-align: center;
|
|
119
|
+
}
|
|
120
|
+
#sb-movie-btn {
|
|
121
|
+
margin: 10px 14px;
|
|
122
|
+
background: oklch(62% 0.2 186 / 0.12);
|
|
123
|
+
border: 1px solid oklch(62% 0.2 186 / 0.35);
|
|
124
|
+
color: oklch(56% 0.16 186); font-size: 9px; letter-spacing: 2px;
|
|
125
|
+
border-radius: 6px; padding: 7px; cursor: pointer; width: calc(100% - 28px);
|
|
126
|
+
transition: background 0.15s, color 0.15s;
|
|
127
|
+
font-family: 'Azeret Mono', 'Space Mono', 'Courier New', monospace;
|
|
128
|
+
}
|
|
129
|
+
#sb-movie-btn:hover { background: oklch(62% 0.2 186 / 0.25); color: #d0b0ff; }
|
|
130
|
+
#sb-movie-btn.active { background: oklch(62% 0.2 186 / 0.25); color: #d0b0ff; border-color: oklch(62% 0.2 186 / 0.6); }
|
|
131
|
+
|
|
132
|
+
/* ── SVG title overlay ── */
|
|
133
|
+
#title-wrap {
|
|
134
|
+
position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
|
|
135
|
+
text-align: center; pointer-events: none; z-index: 5;
|
|
136
|
+
}
|
|
137
|
+
#title-h1 {
|
|
138
|
+
font-size: 22px; font-weight: 900; letter-spacing: 0.38em;
|
|
139
|
+
color: oklch(84% 0.14 186);
|
|
140
|
+
}
|
|
141
|
+
#title-sub { font-size: 9px; color: oklch(38% 0.06 186); letter-spacing: 3px; margin-top: 6px; }
|
|
142
|
+
|
|
143
|
+
/* ── Prompt box ── */
|
|
144
|
+
#prompt-box {
|
|
145
|
+
position: absolute; bottom: 76px; left: 50%; transform: translateX(-50%);
|
|
146
|
+
min-width: 340px; max-width: 500px;
|
|
147
|
+
background: rgba(6,4,22,0.96);
|
|
148
|
+
border: 1px solid rgba(130,80,255,0.5);
|
|
149
|
+
border-radius: 12px; padding: 10px 18px;
|
|
150
|
+
z-index: 50; opacity: 0;
|
|
151
|
+
box-shadow: 0 4px 28px rgba(100,50,255,0.16);
|
|
152
|
+
backdrop-filter: blur(18px);
|
|
153
|
+
}
|
|
154
|
+
#p-tag { font-size: 8px; letter-spacing: 3px; color: #48489a; margin-bottom: 4px; }
|
|
155
|
+
#p-line { font-size: 12.5px; color: #90c8ff; display: flex; align-items: center; gap: 2px; min-height: 19px; }
|
|
156
|
+
#p-cursor {
|
|
157
|
+
display: inline-block; width: 2px; height: 14px;
|
|
158
|
+
background: #90c8ff; flex-shrink: 0;
|
|
159
|
+
animation: blink 0.8s step-end infinite;
|
|
160
|
+
}
|
|
161
|
+
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
|
|
162
|
+
|
|
163
|
+
/* ── Activity log ── */
|
|
164
|
+
#activity-log {
|
|
165
|
+
position: absolute; left: 10px; bottom: 76px;
|
|
166
|
+
width: 240px;
|
|
167
|
+
background: rgba(5,3,18,0.93);
|
|
168
|
+
border: 1px solid rgba(70,45,165,0.35);
|
|
169
|
+
border-radius: 10px; padding: 9px 12px;
|
|
170
|
+
z-index: 50; opacity: 0;
|
|
171
|
+
}
|
|
172
|
+
#log-title { font-size: 7.5px; letter-spacing: 3px; color: #282870; margin-bottom: 6px;
|
|
173
|
+
padding-bottom: 5px; border-bottom: 1px solid rgba(70,45,165,0.18); }
|
|
174
|
+
#log-entries { font-size: 9px; line-height: 1.95; max-height: 160px; overflow: hidden; }
|
|
175
|
+
.log-row { display: flex; gap: 5px; opacity: 0; }
|
|
176
|
+
.log-tag { font-weight: bold; min-width: 58px; flex-shrink: 0; }
|
|
177
|
+
.log-msg { color: #525298; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
|
|
178
|
+
|
|
179
|
+
/* ── Mode banner ── */
|
|
180
|
+
#mode-banner {
|
|
181
|
+
position: absolute; top: 14px; right: 10px;
|
|
182
|
+
font-size: 8px; letter-spacing: 3px; color: #303070;
|
|
183
|
+
z-index: 5; pointer-events: none;
|
|
184
|
+
}
|
|
185
|
+
#mode-banner.live-mode { color: #28c068; }
|
|
186
|
+
|
|
187
|
+
/* ── Control bar ── */
|
|
188
|
+
#ctrl {
|
|
189
|
+
position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
|
|
190
|
+
display: flex; align-items: center; gap: 7px;
|
|
191
|
+
background: rgba(8,6,26,0.95);
|
|
192
|
+
border: 1px solid rgba(100,60,220,0.35);
|
|
193
|
+
border-radius: 26px; padding: 6px 16px;
|
|
194
|
+
z-index: 100; backdrop-filter: blur(18px);
|
|
195
|
+
opacity: 0;
|
|
196
|
+
}
|
|
197
|
+
.c-btn {
|
|
198
|
+
background: none; border: 1px solid rgba(100,60,220,0.4);
|
|
199
|
+
color: #7858d0; width: 26px; height: 26px; border-radius: 50%;
|
|
200
|
+
cursor: pointer; font-size: 10px;
|
|
201
|
+
display: flex; align-items: center; justify-content: center;
|
|
202
|
+
transition: background 0.12s, color 0.12s; flex-shrink: 0; line-height: 1;
|
|
203
|
+
}
|
|
204
|
+
.c-btn:hover { background: rgba(100,60,220,0.2); color: #d0b0ff; }
|
|
205
|
+
.c-btn.disabled { opacity: 0.3; pointer-events: none; }
|
|
206
|
+
#scrubber {
|
|
207
|
+
width: 180px; height: 3px; cursor: pointer;
|
|
208
|
+
-webkit-appearance: none; appearance: none;
|
|
209
|
+
background: rgba(100,60,220,0.2); border-radius: 2px; outline: none;
|
|
210
|
+
}
|
|
211
|
+
#scrubber::-webkit-slider-thumb {
|
|
212
|
+
-webkit-appearance: none; width: 11px; height: 11px;
|
|
213
|
+
border-radius: 50%; background: #7858d0; cursor: pointer; border: none;
|
|
214
|
+
}
|
|
215
|
+
#t-disp { font-size: 9px; color: #484888; min-width: 36px; text-align: right; font-variant-numeric: tabular-nums; }
|
|
216
|
+
#spd {
|
|
217
|
+
background: rgba(8,6,26,0.85); border: 1px solid rgba(100,60,220,0.3);
|
|
218
|
+
color: oklch(55% 0.12 186); font-size: 9px; font-family: 'Azeret Mono', 'Space Mono', monospace;
|
|
219
|
+
border-radius: 4px; padding: 2px 4px; cursor: pointer; outline: none;
|
|
220
|
+
}
|
|
221
|
+
#spd option { background: #0d0a20; }
|
|
222
|
+
|
|
223
|
+
/* ── Detail panel ── */
|
|
224
|
+
#dp-header {
|
|
225
|
+
padding: 14px 16px 10px;
|
|
226
|
+
border-bottom: 1px solid oklch(62% 0.2 186 / 0.18); flex-shrink: 0;
|
|
227
|
+
}
|
|
228
|
+
#dp-close {
|
|
229
|
+
float: right; background: none; border: none; color: #404070;
|
|
230
|
+
cursor: pointer; font-size: 13px; padding: 0; line-height: 1;
|
|
231
|
+
}
|
|
232
|
+
#dp-close:hover { color: #a090e0; }
|
|
233
|
+
#dp-title { font-size: 9px; letter-spacing: 3px; color: #5050a0; margin-top: 2px; }
|
|
234
|
+
#dp-emoji { font-size: 22px; display: block; margin-bottom: 4px; }
|
|
235
|
+
#dp-body { flex: 1; overflow-y: auto; padding: 12px 16px; scrollbar-width: thin; scrollbar-color: oklch(62% 0.2 186 / 0.3) transparent; }
|
|
236
|
+
#dp-body::-webkit-scrollbar { width: 4px; }
|
|
237
|
+
#dp-body::-webkit-scrollbar-thumb { background: oklch(62% 0.2 186 / 0.3); border-radius: 2px; }
|
|
238
|
+
.dp-section { margin-bottom: 14px; }
|
|
239
|
+
.dp-section-title { font-size: 7.5px; letter-spacing: 3px; color: oklch(38% 0.07 186); margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid oklch(62% 0.2 186 / 0.15); }
|
|
240
|
+
.dp-event { font-size: 9px; line-height: 1.6; color: #5060a0; margin-bottom: 4px; }
|
|
241
|
+
.dp-event .ev-ts { color: #282855; }
|
|
242
|
+
.dp-event .ev-type { color: inherit; font-weight: bold; }
|
|
243
|
+
.dp-artifact { font-size: 9px; color: #6070a0; padding: 3px 6px; background: oklch(62% 0.2 186 / 0.08); border-radius: 3px; margin-bottom: 3px; }
|
|
244
|
+
.dp-agent { display: inline-block; font-size: 8px; padding: 2px 7px; border-radius: 10px; margin: 2px 3px 2px 0; border: 1px solid oklch(62% 0.2 186 / 0.3); color: oklch(55% 0.09 186); }
|
|
245
|
+
@media (prefers-reduced-motion: reduce) {
|
|
246
|
+
*, *::before, *::after {
|
|
247
|
+
animation-duration: 0.01ms !important;
|
|
248
|
+
animation-iteration-count: 1 !important;
|
|
249
|
+
transition-duration: 0.01ms !important;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
</style>
|
|
253
|
+
</head>
|
|
254
|
+
<body>
|
|
255
|
+
<div id="app">
|
|
256
|
+
<!-- ── Left sidebar: session history ── -->
|
|
257
|
+
<div id="sidebar">
|
|
258
|
+
<div id="sb-header">
|
|
259
|
+
<div id="sb-title">SESSIONS</div>
|
|
260
|
+
<select id="proj-filter" onchange="applyProjectFilter(this.value)" style="width:100%;margin-top:6px;background:oklch(12% 0.015 186);color:oklch(52% 0.1 186);border:1px solid oklch(62% 0.2 186 / 0.18);border-radius:3px;font-size:8px;letter-spacing:1px;padding:3px 4px;cursor:pointer"><option value="">ALL PROJECTS</option></select>
|
|
261
|
+
<div class="live-row">
|
|
262
|
+
<div class="l-dot" id="l-dot"></div>
|
|
263
|
+
<span id="l-status">OFFLINE</span>
|
|
264
|
+
<span id="l-agents">0 agents</span>
|
|
265
|
+
</div>
|
|
266
|
+
<div id="git-user-row">
|
|
267
|
+
<span id="git-user-icon">⬡</span>
|
|
268
|
+
<span id="git-user-name">—</span>
|
|
269
|
+
</div>
|
|
270
|
+
<div id="git-cwd-row">
|
|
271
|
+
<span id="git-cwd-icon">◎</span>
|
|
272
|
+
<span id="git-cwd-name">—</span>
|
|
273
|
+
</div>
|
|
274
|
+
</div>
|
|
275
|
+
<div id="sb-sessions">
|
|
276
|
+
<div id="sb-no-sessions">No sessions yet.<br><br>Describe a goal and<br>Mastermind routes it<br>across specialist agents.<br><br><span style="color:oklch(56% 0.16 186);letter-spacing:1px">/mastermind</span></div>
|
|
277
|
+
</div>
|
|
278
|
+
<button id="sb-movie-btn" onclick="toggleMovieMode(currentSessionObj)">▶ MOVIE MODE</button>
|
|
279
|
+
</div>
|
|
280
|
+
|
|
281
|
+
<!-- ── Stage ── -->
|
|
282
|
+
<div id="stage-wrap">
|
|
283
|
+
<!-- SVG -->
|
|
284
|
+
<svg id="stage" viewBox="0 0 960 720" preserveAspectRatio="xMidYMid meet">
|
|
285
|
+
<defs>
|
|
286
|
+
<filter id="glow" x="-55%" y="-55%" width="210%" height="210%">
|
|
287
|
+
<feGaussianBlur in="SourceGraphic" stdDeviation="5" result="b"/>
|
|
288
|
+
<feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
|
|
289
|
+
</filter>
|
|
290
|
+
<filter id="bloom" x="-100%" y="-100%" width="300%" height="300%">
|
|
291
|
+
<feGaussianBlur in="SourceGraphic" stdDeviation="15" result="b"/>
|
|
292
|
+
<feMerge><feMergeNode in="b"/><feMergeNode in="SourceGraphic"/></feMerge>
|
|
293
|
+
</filter>
|
|
294
|
+
</defs>
|
|
295
|
+
<rect width="960" height="720" fill="#07071a"/>
|
|
296
|
+
<g id="stars"></g>
|
|
297
|
+
<g id="net-edges"></g>
|
|
298
|
+
<g id="net-particles"></g>
|
|
299
|
+
<g id="net-nodes"></g>
|
|
300
|
+
</svg>
|
|
301
|
+
|
|
302
|
+
<!-- Overlays -->
|
|
303
|
+
<div id="title-wrap">
|
|
304
|
+
<div id="title-h1">MASTERMIND</div>
|
|
305
|
+
<div id="title-sub">AUTONOMOUS EXECUTION · 12 DOMAINS · PERSISTENT ORGS</div>
|
|
306
|
+
</div>
|
|
307
|
+
|
|
308
|
+
<div id="mode-banner">LIVE</div>
|
|
309
|
+
|
|
310
|
+
<div id="prompt-box">
|
|
311
|
+
<div id="p-tag">USER PROMPT</div>
|
|
312
|
+
<div id="p-line"><span id="p-text"></span><span id="p-cursor"></span></div>
|
|
313
|
+
</div>
|
|
314
|
+
|
|
315
|
+
<div id="activity-log">
|
|
316
|
+
<div id="log-title">ACTIVITY LOG</div>
|
|
317
|
+
<div id="log-entries"></div>
|
|
318
|
+
</div>
|
|
319
|
+
|
|
320
|
+
<div id="ctrl">
|
|
321
|
+
<button class="c-btn disabled" id="btn-restart" title="Restart">↺</button>
|
|
322
|
+
<button class="c-btn disabled" id="btn-play" title="Play">▶</button>
|
|
323
|
+
<button class="c-btn disabled" id="btn-pause" title="Pause">⏸</button>
|
|
324
|
+
<input type="range" id="scrubber" min="0" max="100" value="0" step="0.1" disabled/>
|
|
325
|
+
<span id="t-disp">—</span>
|
|
326
|
+
<select id="spd">
|
|
327
|
+
<option value="0.5">0.5×</option>
|
|
328
|
+
<option value="1" selected>1×</option>
|
|
329
|
+
<option value="2">2×</option>
|
|
330
|
+
<option value="3">3×</option>
|
|
331
|
+
</select>
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
|
|
335
|
+
<!-- ── Right panel: session/domain detail ── -->
|
|
336
|
+
<div id="detail-panel">
|
|
337
|
+
<div id="dp-header">
|
|
338
|
+
<button id="dp-close" onclick="closeDetail()">✕</button>
|
|
339
|
+
<span id="dp-emoji"></span>
|
|
340
|
+
<div id="dp-title">SELECT A DOMAIN OR SESSION</div>
|
|
341
|
+
</div>
|
|
342
|
+
<div id="dp-body"></div>
|
|
343
|
+
</div>
|
|
344
|
+
</div>
|
|
345
|
+
|
|
346
|
+
<script src="https://cdn.jsdelivr.net/npm/gsap@3/dist/gsap.min.js"></script>
|
|
347
|
+
<script>
|
|
348
|
+
'use strict';
|
|
349
|
+
|
|
350
|
+
// ── Graph constants ──────────────────────────────────────────────────────────
|
|
351
|
+
const CX = 480, CY = 360;
|
|
352
|
+
const DOMAIN_COLORS = {
|
|
353
|
+
build:'#60a5fa', idea:'#fbbf24', marketing:'#f472b6', review:'#34d399',
|
|
354
|
+
research:'#a78bfa', content:'#fb923c', release:'#22d3ee', sales:'#f87171',
|
|
355
|
+
ops:'#4ade80', finance:'#fde68a', orgs:'#c084fc', default:'#00E5C8'
|
|
356
|
+
};
|
|
357
|
+
const DOMAIN_EMOJIS = {
|
|
358
|
+
build:'⚙️', idea:'💡', marketing:'📣', review:'🔍', research:'🔬',
|
|
359
|
+
content:'✍️', release:'🚀', sales:'💼', ops:'⚡', finance:'💰', orgs:'🏛'
|
|
360
|
+
};
|
|
361
|
+
const AGENT_EMOJIS = {
|
|
362
|
+
'coder':'⚙', 'architect':'🏗', 'tester':'🧪', 'reviewer':'🔍',
|
|
363
|
+
'researcher':'🔬', 'frontend-dev':'🎨', 'backend-dev':'⚡',
|
|
364
|
+
'coordinator':'🎯', 'planner':'📋', 'general-purpose':'🤖',
|
|
365
|
+
'frontend':'🎨', 'backend':'⚡', 'ml-developer':'🧠',
|
|
366
|
+
'security-architect':'🔒', 'sparc-coder':'💻', 'default':'◈'
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
// ── Node/edge model ───────────────────────────────────────────────────────────
|
|
370
|
+
const nodes = new Map();
|
|
371
|
+
const edges = [];
|
|
372
|
+
let rootId = null;
|
|
373
|
+
let simActive = false;
|
|
374
|
+
|
|
375
|
+
// ── SVG helpers ───────────────────────────────────────────────────────────────
|
|
376
|
+
const NS = 'http://www.w3.org/2000/svg';
|
|
377
|
+
const mkN = (tag, a) => {
|
|
378
|
+
const el = document.createElementNS(NS, tag);
|
|
379
|
+
if (a) for (const [k,v] of Object.entries(a)) el.setAttribute(k, v);
|
|
380
|
+
return el;
|
|
381
|
+
};
|
|
382
|
+
const starsG = document.getElementById('stars');
|
|
383
|
+
const edgesG = document.getElementById('net-edges');
|
|
384
|
+
const particlesG= document.getElementById('net-particles');
|
|
385
|
+
const nodesG = document.getElementById('net-nodes');
|
|
386
|
+
|
|
387
|
+
// ── Star field ────────────────────────────────────────────────────────────────
|
|
388
|
+
(function buildStars() {
|
|
389
|
+
for (let i = 0; i < 170; i++) {
|
|
390
|
+
starsG.appendChild(mkN('circle', {
|
|
391
|
+
cx: (Math.random()*960).toFixed(1),
|
|
392
|
+
cy: (Math.random()*720).toFixed(1),
|
|
393
|
+
r: (Math.random()<0.1 ? Math.random()*1.5+0.8 : Math.random()*0.8+0.15).toFixed(2),
|
|
394
|
+
fill: `rgba(160,150,255,${(Math.random()*0.35+0.08).toFixed(2)})`
|
|
395
|
+
}));
|
|
396
|
+
}
|
|
397
|
+
if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
398
|
+
gsap.to([...starsG.children], {
|
|
399
|
+
opacity: 'random(0.06,0.6)', duration: 'random(2,5)',
|
|
400
|
+
stagger:{ amount:16, from:'random', repeat:-1, yoyo:true, ease:'sine.inOut' }, delay:1
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
})();
|
|
404
|
+
|
|
405
|
+
// ── Hex helper ────────────────────────────────────────────────────────────────
|
|
406
|
+
function hexPts(r) {
|
|
407
|
+
return Array.from({length:6},(_,i)=>{
|
|
408
|
+
const a=i*Math.PI/3-Math.PI/6;
|
|
409
|
+
return `${(r*Math.cos(a)).toFixed(1)},${(r*Math.sin(a)).toFixed(1)}`;
|
|
410
|
+
}).join(' ');
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// ── Force simulation (Verlet) ─────────────────────────────────────────────────
|
|
414
|
+
const SPRING_K = 0.030;
|
|
415
|
+
const REPULSION = 6000;
|
|
416
|
+
const DAMPING = 0.78;
|
|
417
|
+
const REST_DIST = { root:0, domain:185, agent:68, org:160 };
|
|
418
|
+
|
|
419
|
+
function forceStep() {
|
|
420
|
+
const arr = [...nodes.values()];
|
|
421
|
+
for (const n of arr) { n.ax=0; n.ay=0; }
|
|
422
|
+
for (let i=0; i<arr.length; i++) {
|
|
423
|
+
for (let j=i+1; j<arr.length; j++) {
|
|
424
|
+
const a=arr[i], b=arr[j];
|
|
425
|
+
const dx=b.x-a.x, dy=b.y-a.y;
|
|
426
|
+
const d2=dx*dx+dy*dy+1, d=Math.sqrt(d2);
|
|
427
|
+
const f=REPULSION/(d2*d);
|
|
428
|
+
if (!a.fixed){a.ax-=dx*f; a.ay-=dy*f;}
|
|
429
|
+
if (!b.fixed){b.ax+=dx*f; b.ay+=dy*f;}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
for (const e of edges) {
|
|
433
|
+
const a=nodes.get(e.fromId), b=nodes.get(e.toId);
|
|
434
|
+
if (!a||!b) continue;
|
|
435
|
+
const dx=b.x-a.x, dy=b.y-a.y;
|
|
436
|
+
const d=Math.sqrt(dx*dx+dy*dy)+0.001;
|
|
437
|
+
const rest=REST_DIST[b.type]??110;
|
|
438
|
+
const f=(d-rest)*SPRING_K;
|
|
439
|
+
if (!a.fixed){a.ax+=dx/d*f; a.ay+=dy/d*f;}
|
|
440
|
+
if (!b.fixed){b.ax-=dx/d*f; b.ay-=dy/d*f;}
|
|
441
|
+
}
|
|
442
|
+
for (const n of arr) {
|
|
443
|
+
if (n.fixed) continue;
|
|
444
|
+
n.vx=(n.vx+n.ax)*DAMPING;
|
|
445
|
+
n.vy=(n.vy+n.ay)*DAMPING;
|
|
446
|
+
n.x=Math.max(60,Math.min(900,n.x+n.vx));
|
|
447
|
+
n.y=Math.max(60,Math.min(660,n.y+n.vy));
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// ── Node renderer ─────────────────────────────────────────────────────────────
|
|
452
|
+
function buildNodeEl(n) {
|
|
453
|
+
const g=mkN('g',{transform:`translate(${n.x.toFixed(1)},${n.y.toFixed(1)})`});
|
|
454
|
+
g.style.opacity='0'; g.style.cursor='pointer';
|
|
455
|
+
if (n.type==='root') {
|
|
456
|
+
g.appendChild(mkN('circle',{r:'58',fill:'none',stroke:n.color,'stroke-width':'0.5',opacity:'0.15'}));
|
|
457
|
+
g.appendChild(mkN('circle',{r:'38',fill:'#070620',stroke:n.color,'stroke-width':'2.8',filter:'url(#glow)'}));
|
|
458
|
+
g.appendChild(mkN('circle',{r:'30',fill:'none',stroke:n.color,'stroke-width':'0.8',opacity:'0.35'}));
|
|
459
|
+
const hex=mkN('polygon',{points:hexPts(16),fill:'none',stroke:n.color,'stroke-width':'1.8',opacity:'0.75'});
|
|
460
|
+
g.appendChild(hex);
|
|
461
|
+
gsap.to(hex,{rotate:360,transformOrigin:'0 0',duration:24,repeat:-1,ease:'none'});
|
|
462
|
+
const lbl=mkN('text',{x:'0',y:'58','text-anchor':'middle','font-size':'6.5',fill:n.color,'letter-spacing':'2',
|
|
463
|
+
'font-family':"'Azeret Mono','Space Mono',monospace"});
|
|
464
|
+
lbl.textContent='MASTERMIND'; g.appendChild(lbl);
|
|
465
|
+
} else if (n.type==='domain') {
|
|
466
|
+
g.appendChild(mkN('circle',{r:'44',fill:'none',stroke:n.color,'stroke-width':'0.5',opacity:'0.2'}));
|
|
467
|
+
g.appendChild(mkN('circle',{r:'30',fill:'#09071e',stroke:n.color,'stroke-width':'2.5',filter:'url(#glow)'}));
|
|
468
|
+
const emj=mkN('text',{x:'0',y:'9','text-anchor':'middle','font-size':'17'});
|
|
469
|
+
emj.textContent=n.emoji||'◈'; g.appendChild(emj);
|
|
470
|
+
const lbl=mkN('text',{x:'0',y:'45','text-anchor':'middle','font-size':'7',fill:n.color,'letter-spacing':'1.5',
|
|
471
|
+
'font-family':"'Azeret Mono','Space Mono',monospace"});
|
|
472
|
+
lbl.textContent=n.label; g.appendChild(lbl);
|
|
473
|
+
const ring=mkN('circle',{r:'34',fill:'none',stroke:'#fbbf24','stroke-width':'2',opacity:'0',
|
|
474
|
+
transform:'rotate(-90)','stroke-dasharray':'213.6','stroke-dashoffset':'213.6','stroke-linecap':'round'});
|
|
475
|
+
ring.dataset.cring=n.id;
|
|
476
|
+
g.appendChild(ring);
|
|
477
|
+
} else if (n.type==='agent') {
|
|
478
|
+
g.appendChild(mkN('circle',{r:'20',fill:'#08061a',stroke:n.color,'stroke-width':'1.8',filter:'url(#glow)'}));
|
|
479
|
+
const emj=mkN('text',{x:'0',y:'5','text-anchor':'middle','font-size':'12'});
|
|
480
|
+
emj.textContent=n.emoji||'◈'; g.appendChild(emj);
|
|
481
|
+
const sl=n.label.length>11?n.label.slice(0,10)+'…':n.label;
|
|
482
|
+
const lbl=mkN('text',{x:'0',y:'31','text-anchor':'middle','font-size':'6',fill:n.color,'letter-spacing':'0.6',
|
|
483
|
+
'font-family':"'Azeret Mono','Space Mono',monospace"});
|
|
484
|
+
lbl.textContent=sl; g.appendChild(lbl);
|
|
485
|
+
} else if (n.type==='org') {
|
|
486
|
+
g.appendChild(mkN('polygon',{points:'0,-38 32,0 0,38 -32,0',fill:'#09071e',stroke:n.color,'stroke-width':'2.5',filter:'url(#glow)'}));
|
|
487
|
+
const emj=mkN('text',{x:'0',y:'7','text-anchor':'middle','font-size':'16'});
|
|
488
|
+
emj.textContent='🏛'; g.appendChild(emj);
|
|
489
|
+
const lbl=mkN('text',{x:'0',y:'53','text-anchor':'middle','font-size':'6.5',fill:n.color,'letter-spacing':'1.5',
|
|
490
|
+
'font-family':"'Azeret Mono','Space Mono',monospace"});
|
|
491
|
+
lbl.textContent=n.label; g.appendChild(lbl);
|
|
492
|
+
}
|
|
493
|
+
g.appendChild(mkN('circle',{r:n.type==='agent'?'22':'50',fill:'transparent'}));
|
|
494
|
+
nodesG.appendChild(g);
|
|
495
|
+
n.el=g;
|
|
496
|
+
gsap.to(g,{opacity:1,duration:0.4,ease:'power2.out'});
|
|
497
|
+
gsap.from(g,{scale:0.15,transformOrigin:'0 0',duration:0.55,ease:'back.out(1.7)'});
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// ── Edge renderer ─────────────────────────────────────────────────────────────
|
|
501
|
+
function buildEdgeEl(e) {
|
|
502
|
+
const a=nodes.get(e.fromId), b=nodes.get(e.toId);
|
|
503
|
+
if (!a||!b) return;
|
|
504
|
+
const g=mkN('g'); g.style.opacity='0';
|
|
505
|
+
const isIC=e.type==='intercom';
|
|
506
|
+
const path=mkN('path',{fill:'none',stroke:a.color,opacity:isIC?'0.75':'0.4',
|
|
507
|
+
'stroke-width':isIC?'1.5':'0.9','stroke-dasharray':isIC?'5 3':'none'});
|
|
508
|
+
g.appendChild(path);
|
|
509
|
+
if (isIC&&e.msg) {
|
|
510
|
+
const txt=mkN('text',{'font-size':'6.5',fill:a.color,
|
|
511
|
+
'font-family':"'Azeret Mono','Space Mono',monospace",'letter-spacing':'0.4',opacity:'0.8'});
|
|
512
|
+
txt.textContent=e.msg.length>24?e.msg.slice(0,23)+'…':e.msg;
|
|
513
|
+
g.appendChild(txt); e.msgEl=txt;
|
|
514
|
+
}
|
|
515
|
+
edgesG.insertBefore(g,edgesG.firstChild);
|
|
516
|
+
e.el=g; e.pathEl=path;
|
|
517
|
+
gsap.to(g,{opacity:1,duration:0.6,delay:0.12});
|
|
518
|
+
updateEdge(e);
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
function updateEdge(e) {
|
|
522
|
+
const a=nodes.get(e.fromId), b=nodes.get(e.toId);
|
|
523
|
+
if (!a||!b||!e.pathEl) return;
|
|
524
|
+
if (e.type==='intercom') {
|
|
525
|
+
const mx=(a.x+b.x)/2, my=(a.y+b.y)/2-65;
|
|
526
|
+
e.pathEl.setAttribute('d',`M${a.x.toFixed(1)},${a.y.toFixed(1)} Q${mx.toFixed(1)},${my.toFixed(1)} ${b.x.toFixed(1)},${b.y.toFixed(1)}`);
|
|
527
|
+
if (e.msgEl){e.msgEl.setAttribute('x',(mx-22).toFixed(1));e.msgEl.setAttribute('y',(my-9).toFixed(1));}
|
|
528
|
+
} else {
|
|
529
|
+
e.pathEl.setAttribute('d',`M${a.x.toFixed(1)},${a.y.toFixed(1)} L${b.x.toFixed(1)},${b.y.toFixed(1)}`);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// ── Particle system ───────────────────────────────────────────────────────────
|
|
534
|
+
const PPC = 7;
|
|
535
|
+
function spawnParticles(e) {
|
|
536
|
+
const col=(nodes.get(e.fromId)||{color:'#00E5C8'}).color;
|
|
537
|
+
e.ptcls=Array.from({length:PPC},(_,i)=>{
|
|
538
|
+
const dot=mkN('circle',{r:'2',fill:col,opacity:'0'});
|
|
539
|
+
particlesG.appendChild(dot);
|
|
540
|
+
return {el:dot, t:i/PPC};
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
function tickParticles() {
|
|
544
|
+
for (const e of edges) {
|
|
545
|
+
if (!e.ptcls) continue;
|
|
546
|
+
const a=nodes.get(e.fromId), b=nodes.get(e.toId);
|
|
547
|
+
if (!a||!b) continue;
|
|
548
|
+
for (const p of e.ptcls) {
|
|
549
|
+
p.t=(p.t+0.0045)%1;
|
|
550
|
+
const t=p.t;
|
|
551
|
+
let px,py;
|
|
552
|
+
if (e.type==='intercom') {
|
|
553
|
+
const mx=(a.x+b.x)/2, my=(a.y+b.y)/2-65;
|
|
554
|
+
px=(1-t)*(1-t)*a.x+2*(1-t)*t*mx+t*t*b.x;
|
|
555
|
+
py=(1-t)*(1-t)*a.y+2*(1-t)*t*my+t*t*b.y;
|
|
556
|
+
} else {
|
|
557
|
+
px=a.x+(b.x-a.x)*t; py=a.y+(b.y-a.y)*t;
|
|
558
|
+
}
|
|
559
|
+
p.el.setAttribute('cx',px.toFixed(1));
|
|
560
|
+
p.el.setAttribute('cy',py.toFixed(1));
|
|
561
|
+
p.el.setAttribute('opacity',(Math.sin(t*Math.PI)*0.85).toFixed(2));
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// ── RAF render loop ───────────────────────────────────────────────────────────
|
|
567
|
+
let rafLast=0;
|
|
568
|
+
function rafLoop(ts) {
|
|
569
|
+
if (ts-rafLast>=16) {
|
|
570
|
+
if (simActive) forceStep();
|
|
571
|
+
for (const n of nodes.values()) {
|
|
572
|
+
if (n.el) n.el.setAttribute('transform',`translate(${n.x.toFixed(1)},${n.y.toFixed(1)})`);
|
|
573
|
+
}
|
|
574
|
+
for (const e of edges) updateEdge(e);
|
|
575
|
+
tickParticles();
|
|
576
|
+
rafLast=ts;
|
|
577
|
+
}
|
|
578
|
+
requestAnimationFrame(rafLoop);
|
|
579
|
+
}
|
|
580
|
+
requestAnimationFrame(rafLoop);
|
|
581
|
+
|
|
582
|
+
// ── Graph mutation API ────────────────────────────────────────────────────────
|
|
583
|
+
function gAddNode({id,type,domain,agentSlug,label,emoji,color,parentId,cmd}) {
|
|
584
|
+
if (nodes.has(id)) return nodes.get(id);
|
|
585
|
+
const par=parentId?nodes.get(parentId):null;
|
|
586
|
+
const px=par?par.x:CX, py=par?par.y:CY;
|
|
587
|
+
const ang=Math.random()*Math.PI*2;
|
|
588
|
+
const dist={root:0,domain:175,agent:75,org:155}[type]??120;
|
|
589
|
+
const n={
|
|
590
|
+
id,type,domain,agentSlug,
|
|
591
|
+
label:label||id,
|
|
592
|
+
emoji:emoji||(agentSlug?(AGENT_EMOJIS[agentSlug]||AGENT_EMOJIS.default):'◈'),
|
|
593
|
+
color:color||(domain?(DOMAIN_COLORS[domain]||DOMAIN_COLORS.default):DOMAIN_COLORS.default),
|
|
594
|
+
x:type==='root'?CX:px+Math.cos(ang)*dist+(Math.random()-.5)*28,
|
|
595
|
+
y:type==='root'?CY:py+Math.sin(ang)*dist+(Math.random()-.5)*28,
|
|
596
|
+
vx:0,vy:0,ax:0,ay:0,
|
|
597
|
+
fixed:type==='root',
|
|
598
|
+
parentId:parentId||null,
|
|
599
|
+
cmd:cmd||null,
|
|
600
|
+
done:false,
|
|
601
|
+
state:'active',ts:Date.now()
|
|
602
|
+
};
|
|
603
|
+
nodes.set(id,n);
|
|
604
|
+
simActive=nodes.size>1;
|
|
605
|
+
buildNodeEl(n);
|
|
606
|
+
return n;
|
|
607
|
+
}
|
|
608
|
+
function gAddEdge({id,fromId,toId,type,msg}) {
|
|
609
|
+
const eid=id||`${fromId}→${toId}`;
|
|
610
|
+
if (edges.find(e=>e.id===eid)) return;
|
|
611
|
+
const e={id:eid,fromId,toId,type:type||'activation',msg};
|
|
612
|
+
edges.push(e);
|
|
613
|
+
buildEdgeEl(e);
|
|
614
|
+
spawnParticles(e);
|
|
615
|
+
}
|
|
616
|
+
function gComplete(id) {
|
|
617
|
+
const cn = nodes.get(id); if (cn) cn.done = true;
|
|
618
|
+
const n=nodes.get(id);
|
|
619
|
+
if (!n||!n.el) return;
|
|
620
|
+
n.state='complete';
|
|
621
|
+
const circ=n.el.querySelector('circle[r="30"]')||n.el.querySelector('circle');
|
|
622
|
+
if (circ) gsap.to(circ,{attr:{stroke:'#fbbf24'},duration:0.3,yoyo:true,repeat:2,
|
|
623
|
+
onComplete:()=>gsap.to(n.el,{opacity:0.65,duration:1.5})});
|
|
624
|
+
const ring=n.el.querySelector('[data-cring]');
|
|
625
|
+
if (ring) gsap.to(ring,{opacity:1,'stroke-dashoffset':0,duration:1.6,ease:'power1.inOut'});
|
|
626
|
+
}
|
|
627
|
+
function gClear() {
|
|
628
|
+
nodes.clear(); edges.length=0; rootId=null; simActive=false;
|
|
629
|
+
nodesG.innerHTML=''; edgesG.innerHTML=''; particlesG.innerHTML='';
|
|
630
|
+
}
|
|
631
|
+
function pulseRoot() {
|
|
632
|
+
const n=nodes.get(rootId);
|
|
633
|
+
if (!n||!n.el) return;
|
|
634
|
+
const c=n.el.querySelector('circle[r="38"]');
|
|
635
|
+
if (c) gsap.to(c,{attr:{'stroke-width':6},duration:0.25,yoyo:true,repeat:1});
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// ── Activity log ──────────────────────────────────────────────────────────────
|
|
639
|
+
function addLog(tag,msg,color) {
|
|
640
|
+
const wrap=document.getElementById('log-entries');
|
|
641
|
+
const row=document.createElement('div');
|
|
642
|
+
row.className='log-row';
|
|
643
|
+
row.innerHTML=`<span class="log-tag" style="color:${color}">${tag}</span><span class="log-msg">${msg}</span>`;
|
|
644
|
+
wrap.appendChild(row);
|
|
645
|
+
gsap.fromTo(row,{opacity:0},{opacity:1,duration:0.3});
|
|
646
|
+
const rows=wrap.querySelectorAll('.log-row');
|
|
647
|
+
if (rows.length>10) gsap.to(rows[0],{opacity:0,height:0,duration:0.22,onComplete:()=>rows[0].remove()});
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// ── Movie mode ────────────────────────────────────────────────────────────────
|
|
651
|
+
let isMovieMode=false;
|
|
652
|
+
let movieTl=null;
|
|
653
|
+
|
|
654
|
+
function buildMovieTl(sessionData) {
|
|
655
|
+
gClear();
|
|
656
|
+
document.getElementById('log-entries').innerHTML='';
|
|
657
|
+
document.getElementById('p-text').textContent='';
|
|
658
|
+
const evts=[...(sessionData&&sessionData.events?sessionData.events:[])].sort((a,b)=>(a.ts||0)-(b.ts||0));
|
|
659
|
+
const tl=gsap.timeline({paused:true,defaults:{ease:'power2.out'}});
|
|
660
|
+
if (!evts.length) {
|
|
661
|
+
tl.add(()=>addLog('[DEMO]','Select a session from the sidebar','#00E5C8'),0.2);
|
|
662
|
+
return tl;
|
|
663
|
+
}
|
|
664
|
+
evts.forEach((ev,i)=>{
|
|
665
|
+
const ev2=Object.assign({},ev);
|
|
666
|
+
tl.add(()=>handleGraphEvent(ev2), 0.3+i*0.75);
|
|
667
|
+
});
|
|
668
|
+
tl.duration(0.3+evts.length*0.75+1.5);
|
|
669
|
+
return tl;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function toggleMovieMode(sessionData) {
|
|
673
|
+
isMovieMode=!isMovieMode;
|
|
674
|
+
const btn=document.getElementById('sb-movie-btn');
|
|
675
|
+
const banner=document.getElementById('mode-banner');
|
|
676
|
+
const scrubEl=document.getElementById('scrubber');
|
|
677
|
+
const tDisp=document.getElementById('t-disp');
|
|
678
|
+
if (isMovieMode) {
|
|
679
|
+
btn.classList.add('active'); btn.textContent='■ EXIT MOVIE';
|
|
680
|
+
banner.textContent='MOVIE'; banner.classList.remove('live-mode');
|
|
681
|
+
['btn-restart','btn-play','btn-pause'].forEach(id=>document.getElementById(id).classList.remove('disabled'));
|
|
682
|
+
scrubEl.disabled=false;
|
|
683
|
+
if (movieTl) movieTl.kill();
|
|
684
|
+
movieTl=buildMovieTl(sessionData);
|
|
685
|
+
document.getElementById('btn-play').onclick=()=>movieTl.resume();
|
|
686
|
+
document.getElementById('btn-pause').onclick=()=>movieTl.pause();
|
|
687
|
+
document.getElementById('btn-restart').onclick=()=>{
|
|
688
|
+
gClear(); document.getElementById('log-entries').innerHTML='';
|
|
689
|
+
movieTl=buildMovieTl(sessionData); movieTl.play();
|
|
690
|
+
};
|
|
691
|
+
document.getElementById('spd').onchange=e=>movieTl&&movieTl.timeScale(Number(e.target.value));
|
|
692
|
+
let scrubbing=false;
|
|
693
|
+
scrubEl.addEventListener('mousedown',()=>{scrubbing=true;movieTl&&movieTl.pause();});
|
|
694
|
+
scrubEl.addEventListener('mouseup',()=>{scrubbing=false;});
|
|
695
|
+
scrubEl.addEventListener('input',()=>{if(movieTl)movieTl.progress(Number(scrubEl.value)/100);tDisp.textContent=(movieTl?movieTl.time():0).toFixed(1)+'s';});
|
|
696
|
+
gsap.ticker.add(()=>{
|
|
697
|
+
if (!scrubbing&&movieTl&&movieTl.totalDuration()>0) {
|
|
698
|
+
scrubEl.value=movieTl.progress()*100;
|
|
699
|
+
tDisp.textContent=movieTl.time().toFixed(1)+'s';
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
gsap.to('#ctrl',{opacity:1,duration:0.35});
|
|
703
|
+
movieTl.play();
|
|
704
|
+
} else {
|
|
705
|
+
btn.classList.remove('active'); btn.textContent='▶ MOVIE MODE';
|
|
706
|
+
banner.textContent='LIVE'; banner.classList.add('live-mode');
|
|
707
|
+
['btn-restart','btn-play','btn-pause'].forEach(id=>document.getElementById(id).classList.add('disabled'));
|
|
708
|
+
scrubEl.disabled=true; tDisp.textContent='—';
|
|
709
|
+
if (movieTl){movieTl.kill();movieTl=null;}
|
|
710
|
+
gsap.to('#ctrl',{opacity:0,duration:0.25});
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// ── Core event dispatcher ─────────────────────────────────────────────────────
|
|
715
|
+
function handleGraphEvent(ev) {
|
|
716
|
+
const {type,session,domain,agent,from,to,msg,cmd,prompt,status} = ev;
|
|
717
|
+
if (type==='session:start') {
|
|
718
|
+
gClear(); rootId=session;
|
|
719
|
+
gAddNode({id:session,type:'root',label:'MASTERMIND',color:DOMAIN_COLORS.default});
|
|
720
|
+
if (prompt) {
|
|
721
|
+
document.getElementById('p-tag').textContent='RUNNING';
|
|
722
|
+
document.getElementById('p-text').textContent=prompt;
|
|
723
|
+
gsap.to('#prompt-box',{opacity:1,duration:0.4});
|
|
724
|
+
}
|
|
725
|
+
gsap.to('#activity-log',{opacity:1,duration:0.4,delay:0.2});
|
|
726
|
+
gsap.to('#ctrl',{opacity:1,duration:0.4,delay:0.4});
|
|
727
|
+
addLog('[SESSION]',(prompt||session).slice(0,32),'#00E5C8');
|
|
728
|
+
refreshSessions();
|
|
729
|
+
} else if (type==='domain:dispatch') {
|
|
730
|
+
if (!domain||!rootId) return;
|
|
731
|
+
const domId=`${session}:${domain}`;
|
|
732
|
+
gAddNode({id:domId,type:'domain',domain,parentId:rootId,cmd:cmd||null,
|
|
733
|
+
label:domain.toUpperCase(),emoji:DOMAIN_EMOJIS[domain]||'◈'});
|
|
734
|
+
gAddEdge({fromId:rootId,toId:domId,type:'activation'});
|
|
735
|
+
pulseRoot();
|
|
736
|
+
addLog(`[${domain.toUpperCase()}]`,cmd||domain,DOMAIN_COLORS[domain]||'#00E5C8');
|
|
737
|
+
} else if (type==='agent:spawn') {
|
|
738
|
+
if (!domain||!rootId) return;
|
|
739
|
+
const domId=`${session}:${domain}`;
|
|
740
|
+
const agId=`${session}:${domain}:${agent||'agent'}:${ev._replayIdx!==undefined?ev._replayIdx:Date.now()}`;
|
|
741
|
+
gAddNode({id:agId,type:'agent',domain,agentSlug:agent,parentId:domId,
|
|
742
|
+
label:agent||'agent',emoji:AGENT_EMOJIS[agent]||AGENT_EMOJIS.default});
|
|
743
|
+
gAddEdge({fromId:domId,toId:agId,type:'spawn'});
|
|
744
|
+
addLog(`[${(agent||'agent').slice(0,9)}]`,ev.task||agent||'',DOMAIN_COLORS[domain]||'#00E5C8');
|
|
745
|
+
} else if (type==='intercom') {
|
|
746
|
+
if (!from||!to||!rootId) return;
|
|
747
|
+
gAddEdge({id:`ic-${from}-${to}-${Date.now()}`,fromId:`${session}:${from}`,
|
|
748
|
+
toId:`${session}:${to}`,type:'intercom',msg});
|
|
749
|
+
addLog('[IC]',`${from}→${to}: ${msg||''}`,'#c084fc');
|
|
750
|
+
} else if (type==='domain:complete') {
|
|
751
|
+
gComplete(`${session}:${domain}`);
|
|
752
|
+
pulseRoot();
|
|
753
|
+
addLog(`[${(domain||'').toUpperCase()}]`,`done · ${status||'✓'}`,'#34d399');
|
|
754
|
+
refreshSessions();
|
|
755
|
+
} else if (type==='session:complete') {
|
|
756
|
+
for (const n of nodes.values()) {
|
|
757
|
+
if (n.el) gsap.to(n.el,{opacity:1,duration:0.3,yoyo:true,repeat:2,ease:'power1.inOut'});
|
|
758
|
+
}
|
|
759
|
+
addLog('[✓]',`complete — ${(ev.domains||[]).length||'all'} domains`,'#34d399');
|
|
760
|
+
setTimeout(()=>gsap.to('#prompt-box',{opacity:0,duration:1}),4000);
|
|
761
|
+
refreshSessions();
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
// ── Live event handler ────────────────────────────────────────────────────────
|
|
766
|
+
function handleLiveEvent(ev) {
|
|
767
|
+
if (isMovieMode) return;
|
|
768
|
+
handleGraphEvent(ev);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
// ── Session graph replay ───────────────────────────────────────────────
|
|
773
|
+
function replaySessionGraph(events) {
|
|
774
|
+
if (!events || !events.length) return;
|
|
775
|
+
gClear();
|
|
776
|
+
let skipRefresh = true;
|
|
777
|
+
const origRefresh = window.refreshSessions;
|
|
778
|
+
window.refreshSessions = () => {}; // suppress during replay
|
|
779
|
+
events.forEach((ev, idx) => handleGraphEvent({...ev, _replayIdx: idx}));
|
|
780
|
+
window.refreshSessions = origRefresh;
|
|
781
|
+
gsap.to('#activity-log', {opacity:1, duration:0.4});
|
|
782
|
+
gsap.to('#ctrl', {opacity:1, duration:0.4, delay:0.2});
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
// ── SSE event stream ───────────────────────────────────────────────────────────
|
|
786
|
+
let evtSource = null;
|
|
787
|
+
function connectSSE() {
|
|
788
|
+
if (evtSource) evtSource.close();
|
|
789
|
+
evtSource = new EventSource('/api/mastermind-stream');
|
|
790
|
+
evtSource.onmessage = (e) => {
|
|
791
|
+
try {
|
|
792
|
+
const ev = JSON.parse(e.data);
|
|
793
|
+
handleLiveEvent(ev);
|
|
794
|
+
} catch (_) {}
|
|
795
|
+
};
|
|
796
|
+
evtSource.onerror = () => {
|
|
797
|
+
const dot = document.getElementById('l-dot');
|
|
798
|
+
if (dot) dot.classList.remove('on');
|
|
799
|
+
const st = document.getElementById('l-status');
|
|
800
|
+
if (st) st.textContent = 'RECONNECTING';
|
|
801
|
+
showStatusBanner('SSE disconnected — reconnecting in 4s');
|
|
802
|
+
setTimeout(connectSSE, 4000);
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// ── Session sidebar ────────────────────────────────────────────────────────────
|
|
807
|
+
let currentSessionId = null;
|
|
808
|
+
let currentSessionObj = null;
|
|
809
|
+
|
|
810
|
+
let activeProjectFilter = '';
|
|
811
|
+
|
|
812
|
+
function applyProjectFilter(val) {
|
|
813
|
+
activeProjectFilter = val;
|
|
814
|
+
refreshSessions();
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
async function refreshSessions() {
|
|
818
|
+
try {
|
|
819
|
+
const url = activeProjectFilter
|
|
820
|
+
? `/api/mastermind/sessions?project=${encodeURIComponent(activeProjectFilter)}`
|
|
821
|
+
: '/api/mastermind/sessions';
|
|
822
|
+
const res = await fetch(url);
|
|
823
|
+
const sessions = await res.json();
|
|
824
|
+
// Populate project filter options
|
|
825
|
+
const sel = document.getElementById('proj-filter');
|
|
826
|
+
if (sel) {
|
|
827
|
+
const projects = [...new Set(sessions.map(s => s.project).filter(Boolean))];
|
|
828
|
+
const current = sel.value;
|
|
829
|
+
sel.innerHTML = '<option value="">ALL PROJECTS</option>' +
|
|
830
|
+
projects.map(p => {
|
|
831
|
+
const name = p.split('/').pop();
|
|
832
|
+
return `<option value="${p}" ${p===current?'selected':''}>${name}</option>`;
|
|
833
|
+
}).join('');
|
|
834
|
+
}
|
|
835
|
+
renderSessions(sessions);
|
|
836
|
+
} catch (_) {}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
function renderSessions(sessions) {
|
|
840
|
+
const wrap = document.getElementById('sb-sessions');
|
|
841
|
+
const noSess = document.getElementById('sb-no-sessions');
|
|
842
|
+
if (!sessions || !sessions.length) {
|
|
843
|
+
if (noSess) noSess.style.display = 'block';
|
|
844
|
+
const items = wrap.querySelectorAll('.sess-item');
|
|
845
|
+
items.forEach(i => i.remove());
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
if (noSess) noSess.style.display = 'none';
|
|
849
|
+
// Remove old items
|
|
850
|
+
wrap.querySelectorAll('.sess-item').forEach(el => el.remove());
|
|
851
|
+
sessions.forEach(s => {
|
|
852
|
+
const item = document.createElement('div');
|
|
853
|
+
item.className = 'sess-item' + (s.status === 'running' ? ' running' : '') + (s.id === currentSessionId ? ' active' : '');
|
|
854
|
+
const ts = new Date(s.ts).toLocaleTimeString([], {hour:'2-digit',minute:'2-digit',second:'2-digit'});
|
|
855
|
+
const date = new Date(s.ts).toLocaleDateString([], {month:'short',day:'numeric'});
|
|
856
|
+
const elapsed = s.endTs ? ((s.endTs - s.ts)/1000).toFixed(0)+'s' : (s.status==='running'?'RUNNING…':'?');
|
|
857
|
+
const projName = s.project ? s.project.split('/').pop() : '';
|
|
858
|
+
item.innerHTML = `
|
|
859
|
+
${projName ? `<div class="sess-project">◈ ${projName}</div>` : ''}
|
|
860
|
+
<div class="sess-ts">${date} ${ts} · ${elapsed}</div>
|
|
861
|
+
<div class="sess-prompt">${s.prompt||'(no prompt)'}</div>
|
|
862
|
+
<div class="sess-badges">
|
|
863
|
+
<span class="sess-badge ${s.status==='running'?'running-badge':''}">${s.status||'?'}</span>
|
|
864
|
+
${(s.domains||[]).slice(0,4).map(d=>`<span class="sess-badge">${d}</span>`).join('')}
|
|
865
|
+
${(s.domains||[]).length>4?`<span class="sess-badge">+${s.domains.length-4}</span>`:''}
|
|
866
|
+
<a class="sess-trace-link" href="/api/mastermind/session/${s.id}/trace" target="_blank" title="View raw trace" onclick="event.stopPropagation()">trace↗</a>
|
|
867
|
+
</div>`;
|
|
868
|
+
item.addEventListener('click', () => {
|
|
869
|
+
wrap.querySelectorAll('.sess-item').forEach(x=>x.classList.remove('active'));
|
|
870
|
+
item.classList.add('active');
|
|
871
|
+
currentSessionId = s.id;
|
|
872
|
+
currentSessionObj = s;
|
|
873
|
+
openSessionDetail(s);
|
|
874
|
+
replaySessionGraph(s.events||[]);
|
|
875
|
+
});
|
|
876
|
+
wrap.appendChild(item);
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// ── Detail panel ───────────────────────────────────────────────────────────────
|
|
881
|
+
function openDomainDetail(d) {
|
|
882
|
+
const panel = document.getElementById('detail-panel');
|
|
883
|
+
document.getElementById('dp-emoji').textContent = d.emoji || '◈';
|
|
884
|
+
document.getElementById('dp-title').textContent = `DOMAIN · ${d.label}`;
|
|
885
|
+
const body = document.getElementById('dp-body');
|
|
886
|
+
// Gather events from current session for this domain
|
|
887
|
+
const sessEvts = (currentSessionObj && currentSessionObj.events) ? currentSessionObj.events : [];
|
|
888
|
+
const domEvts = sessEvts.filter(e => e.domain === d.domain || e.domain === (d.label||'').toLowerCase());
|
|
889
|
+
const spawnEvts = domEvts.filter(e => e.type === 'agent:spawn');
|
|
890
|
+
const artifacts = domEvts.flatMap(e => e.artifacts || []);
|
|
891
|
+
// Also collect child agent nodes
|
|
892
|
+
const agentNodes = [];
|
|
893
|
+
nodes.forEach(n => { if (n.parentId === d.id) agentNodes.push(n); });
|
|
894
|
+
body.innerHTML = `
|
|
895
|
+
<div class="dp-section">
|
|
896
|
+
<div class="dp-section-title">DOMAIN INFO</div>
|
|
897
|
+
<div class="dp-event"><span class="ev-type" style="color:${d.color}">${d.emoji||'◈'} ${d.label}</span></div>
|
|
898
|
+
${d.cmd ? `<div class="dp-event">Command: <span style="color:#7080c0">${d.cmd}</span></div>` : ''}
|
|
899
|
+
<div class="dp-event">Status: <span style="color:${d.done?'#40e880':'#28c068'}">${d.done?'COMPLETE':'RUNNING'}</span></div>
|
|
900
|
+
<div class="dp-event">Agents spawned: <span style="color:${d.color}">${agentNodes.length}</span></div>
|
|
901
|
+
</div>
|
|
902
|
+
${agentNodes.length > 0 ? `
|
|
903
|
+
<div class="dp-section">
|
|
904
|
+
<div class="dp-section-title">AGENTS</div>
|
|
905
|
+
${agentNodes.map(a => `<div class="dp-event"><span class="ev-type" style="color:${a.color||d.color}">${a.emoji||'◈'} ${a.label}</span></div>`).join('')}
|
|
906
|
+
</div>` : ''}
|
|
907
|
+
${spawnEvts.length > 0 ? `
|
|
908
|
+
<div class="dp-section">
|
|
909
|
+
<div class="dp-section-title">TASKS</div>
|
|
910
|
+
${spawnEvts.map(e => `<div class="dp-event" style="color:#506080;font-size:8px;white-space:normal;word-break:break-word;line-height:1.5">${e.agent ? '<b>'+e.agent+'</b>: ' : ''}${(e.task||'').slice(0,120)}</div>`).join('')}
|
|
911
|
+
</div>` : ''}
|
|
912
|
+
${artifacts.length > 0 ? `
|
|
913
|
+
<div class="dp-section">
|
|
914
|
+
<div class="dp-section-title">ARTIFACTS</div>
|
|
915
|
+
${artifacts.map(a => `<div class="dp-artifact">📄 ${a}</div>`).join('')}
|
|
916
|
+
</div>` : ''}
|
|
917
|
+
${domEvts.length > 0 ? `
|
|
918
|
+
<div class="dp-section">
|
|
919
|
+
<div class="dp-section-title">RECENT EVENTS</div>
|
|
920
|
+
${domEvts.slice(-8).map(e => {
|
|
921
|
+
const ts = new Date(e.ts).toLocaleTimeString([],{hour:'2-digit',minute:'2-digit',second:'2-digit'});
|
|
922
|
+
return `<div class="dp-event"><span class="ev-ts">${ts}</span> <span class="ev-type" style="color:${d.color}">${e.type}</span>${e.cmd?' '+e.cmd:e.agent?' '+e.agent:''}</div>`;
|
|
923
|
+
}).join('')}
|
|
924
|
+
</div>` : ''}
|
|
925
|
+
`;
|
|
926
|
+
panel.classList.add('open');
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
async function openSessionDetail(s) {
|
|
930
|
+
const panel = document.getElementById('detail-panel');
|
|
931
|
+
document.getElementById('dp-emoji').textContent = '📋';
|
|
932
|
+
document.getElementById('dp-title').textContent = 'SESSION DETAIL';
|
|
933
|
+
const body = document.getElementById('dp-body');
|
|
934
|
+
body.innerHTML = '<div style="color:#303060;font-size:9px;padding:8px">Loading…</div>';
|
|
935
|
+
panel.classList.add('open');
|
|
936
|
+
try {
|
|
937
|
+
const res = await fetch(`/api/mastermind/session/${s.id}`);
|
|
938
|
+
const full = await res.json();
|
|
939
|
+
if (!full) { body.innerHTML = '<div style="color:#303060;font-size:9px">Session not found.</div>'; return; }
|
|
940
|
+
const ts = new Date(full.ts).toLocaleString();
|
|
941
|
+
const elapsed = full.endTs ? ((full.endTs - full.ts)/1000).toFixed(1)+'s' : 'running';
|
|
942
|
+
const evts = full.events || [];
|
|
943
|
+
const domainSet = full.domains || [];
|
|
944
|
+
body.innerHTML = `
|
|
945
|
+
<div class="dp-section">
|
|
946
|
+
<div class="dp-section-title">OVERVIEW</div>
|
|
947
|
+
<div class="dp-event">Started: <span style="color:#6060a0">${ts}</span></div>
|
|
948
|
+
<div class="dp-event">Duration: <span style="color:#6060a0">${elapsed}</span></div>
|
|
949
|
+
<div class="dp-event">Status: <span style="color:${full.status==='complete'?'#40e880':full.status==='running'?'#28c068':'#f87171'}">${full.status||'?'}</span></div>
|
|
950
|
+
<div class="dp-event">Domains: <span style="color:#8080c0">${domainSet.join(', ')||'—'}</span></div>
|
|
951
|
+
</div>
|
|
952
|
+
<div class="dp-section">
|
|
953
|
+
<div class="dp-section-title">PROMPT</div>
|
|
954
|
+
<div class="dp-event" style="color:oklch(58% 0.09 186);word-break:break-all;white-space:normal;line-height:1.6">${full.prompt||'—'}</div>
|
|
955
|
+
</div>
|
|
956
|
+
${domainSet.length ? `
|
|
957
|
+
<div class="dp-section">
|
|
958
|
+
<div class="dp-section-title">ACTIVE DOMAINS</div>
|
|
959
|
+
${domainSet.map(did => {
|
|
960
|
+
const color = DOMAIN_COLORS[did] || '#8080c0';
|
|
961
|
+
const emoji = DOMAIN_EMOJIS[did] || '◈';
|
|
962
|
+
const label = (did||'').toUpperCase();
|
|
963
|
+
return `<div class="dp-event"><span style="color:${color}">${emoji} ${label}</span></div>`;
|
|
964
|
+
}).join('')}
|
|
965
|
+
</div>` : ''}
|
|
966
|
+
<div class="dp-section">
|
|
967
|
+
<div class="dp-section-title">EVENT TIMELINE (${evts.length})</div>
|
|
968
|
+
${evts.map(e => {
|
|
969
|
+
const et = new Date(e.ts).toLocaleTimeString([],{hour:'2-digit',minute:'2-digit',second:'2-digit'});
|
|
970
|
+
const color = e.domain ? (DOMAIN_COLORS[e.domain] || '#6060a0') : '#6060a0';
|
|
971
|
+
let detail = '';
|
|
972
|
+
if (e.type === 'session:start') detail = `<span style="color:#5050a0;font-size:8px;word-break:break-all">${e.prompt||''}</span>`;
|
|
973
|
+
else if (e.type === 'domain:dispatch') detail = `<span style="color:#5060a0;font-size:8px">${e.cmd||''}</span>`;
|
|
974
|
+
else if (e.type === 'agent:spawn') detail = `<span style="color:#507090;font-size:8px">agent: <b>${e.agent||''}</b> — ${(e.task||'').slice(0,50)}</span>`;
|
|
975
|
+
else if (e.type === 'intercom') detail = `<span style="color:#506070;font-size:8px">${e.from||'?'} → ${e.to||'?'}: ${e.msg||''}</span>`;
|
|
976
|
+
else if (e.type === 'domain:complete') {
|
|
977
|
+
const arts = (e.artifacts||[]).map(a=>`<span style="color:#407050;font-size:7px">📄 ${a}</span>`).join(' ');
|
|
978
|
+
detail = `<span style="color:#406050;font-size:8px">status: ${e.status||'?'}</span>${arts?' '+arts:''}`;
|
|
979
|
+
}
|
|
980
|
+
else if (e.type === 'session:complete') detail = `<span style="color:#405080;font-size:8px">domains: ${(e.domains||[]).join(', ')}</span>`;
|
|
981
|
+
return `<div class="dp-event" style="flex-direction:column;align-items:flex-start;gap:1px"><div><span class="ev-ts">${et}</span> <span class="ev-type" style="color:${color}">${e.type}</span>${e.domain?' <span style="color:#404060;font-size:8px">['+e.domain+']</span>':''}</div>${detail?'<div style="padding-left:4px">'+detail+'</div>':''}</div>`;
|
|
982
|
+
}).join('')}
|
|
983
|
+
</div>
|
|
984
|
+
<div class="dp-section">
|
|
985
|
+
<div class="dp-section-title">EXPORT</div>
|
|
986
|
+
<div style="display:flex;gap:6px;flex-wrap:wrap">
|
|
987
|
+
<a class="dp-export-btn" href="/api/mastermind/session/${full.id}/trace" target="_blank">📄 View Trace</a>
|
|
988
|
+
<button class="dp-export-btn" onclick="downloadSession('${full.id}')">⬇ Download JSON</button>
|
|
989
|
+
</div>
|
|
990
|
+
</div>
|
|
991
|
+
`;
|
|
992
|
+
} catch(err) {
|
|
993
|
+
body.innerHTML = `<div style="color:#a03030;font-size:9px">${err.message}</div>`;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
function closeDetail() {
|
|
998
|
+
document.getElementById('detail-panel').classList.remove('open');
|
|
999
|
+
currentSessionId = null;
|
|
1000
|
+
document.querySelectorAll('.sess-item').forEach(x=>x.classList.remove('active'));
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
async function downloadSession(id) {
|
|
1004
|
+
const res = await fetch(`/api/mastermind/session/${id}`);
|
|
1005
|
+
const data = await res.json();
|
|
1006
|
+
const blob = new Blob([JSON.stringify(data, null, 2)], {type:'application/json'});
|
|
1007
|
+
const a = document.createElement('a');
|
|
1008
|
+
a.href = URL.createObjectURL(blob);
|
|
1009
|
+
a.download = `${id}.json`;
|
|
1010
|
+
a.click();
|
|
1011
|
+
URL.revokeObjectURL(a.href);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
// ── Live data polling for status bar ──────────────────────────────────────────
|
|
1015
|
+
async function pollStatus() {
|
|
1016
|
+
try {
|
|
1017
|
+
const res = await fetch('/api/data');
|
|
1018
|
+
if (!res.ok) return;
|
|
1019
|
+
const data = await res.json();
|
|
1020
|
+
const active = !!data?.swarm?.activity?.swarm?.active;
|
|
1021
|
+
const dot = document.getElementById('l-dot');
|
|
1022
|
+
dot.classList.toggle('on', active);
|
|
1023
|
+
document.getElementById('l-status').textContent = active ? 'LIVE' : 'IDLE';
|
|
1024
|
+
const n = data?.swarm?.state?.agentPlan?.length || 0;
|
|
1025
|
+
document.getElementById('l-agents').textContent = n + ' agent' + (n!==1?'s':'');
|
|
1026
|
+
// Highlight last routed domain
|
|
1027
|
+
const route = data?.hooks?.lastRoute || '';
|
|
1028
|
+
if (route && !isMovieMode) {
|
|
1029
|
+
const hit = DOMAINS.find(d => route.toLowerCase().includes(d.id));
|
|
1030
|
+
if (hit) {
|
|
1031
|
+
gsap.to(`#gr-${hit.id}`, { opacity:0.85, attr:{r:52}, duration:0.35 });
|
|
1032
|
+
gsap.to(`#gr-${hit.id}`, { opacity:0.2, attr:{r:44}, duration:1.8, delay:0.35 });
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
} catch (_) {}
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
function showStatusBanner(msg) {
|
|
1040
|
+
let b = document.getElementById('status-banner');
|
|
1041
|
+
if (!b) {
|
|
1042
|
+
b = document.createElement('div'); b.id = 'status-banner';
|
|
1043
|
+
b.style.cssText = 'position:fixed;top:0;left:0;right:0;padding:5px 14px;background:oklch(24% 0.05 186);border-bottom:1px solid oklch(68% 0.18 186 / 0.35);color:oklch(70% 0.05 186);font-size:9px;letter-spacing:1.5px;text-align:center;z-index:9999;transition:opacity 0.5s;pointer-events:none;';
|
|
1044
|
+
document.body.appendChild(b);
|
|
1045
|
+
}
|
|
1046
|
+
b.textContent = msg; b.style.opacity = '1';
|
|
1047
|
+
clearTimeout(b._t); b._t = setTimeout(() => { b.style.opacity = '0'; }, 5000);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// ── Bootstrap ──────────────────────────────────────────────────────────────────
|
|
1051
|
+
connectSSE();
|
|
1052
|
+
refreshSessions();
|
|
1053
|
+
pollStatus();
|
|
1054
|
+
fetch('/api/git-user').then(r=>r.json()).then(u=>{
|
|
1055
|
+
if (u.name) document.getElementById('git-user-name').textContent = u.name;
|
|
1056
|
+
if (u.cwd) {
|
|
1057
|
+
const parts = u.cwd.replace(/\\/g, '/').split('/');
|
|
1058
|
+
document.getElementById('git-cwd-name').textContent = parts.slice(-2).join('/');
|
|
1059
|
+
document.getElementById('git-cwd-name').title = u.cwd;
|
|
1060
|
+
}
|
|
1061
|
+
}).catch(()=>{});
|
|
1062
|
+
setInterval(pollStatus, 4000);
|
|
1063
|
+
setInterval(refreshSessions, 8000);
|
|
1064
|
+
|
|
1065
|
+
// Set initial live mode banner
|
|
1066
|
+
document.getElementById('mode-banner').classList.add('live-mode');
|
|
1067
|
+
</script>
|
|
1068
|
+
</body>
|
|
1069
|
+
</html>
|