@speakquery/mycel 0.0.0-stage → 0.1.1
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/LICENSE +202 -0
- package/README.md +415 -2
- package/dashboard/index.html +1595 -0
- package/dist/a2a-client.d.ts +104 -0
- package/dist/a2a-client.js +108 -0
- package/dist/a2a-client.js.map +1 -0
- package/dist/a2a-server.d.ts +32 -0
- package/dist/a2a-server.js +218 -0
- package/dist/a2a-server.js.map +1 -0
- package/dist/adapter.d.ts +44 -0
- package/dist/adapter.js +61 -0
- package/dist/adapter.js.map +1 -0
- package/dist/bench.d.ts +40 -0
- package/dist/bench.js +208 -0
- package/dist/bench.js.map +1 -0
- package/dist/catalog.d.ts +69 -0
- package/dist/catalog.js +206 -0
- package/dist/catalog.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +365 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +290 -0
- package/dist/config.js +177 -0
- package/dist/config.js.map +1 -0
- package/dist/contracts.d.ts +26 -0
- package/dist/contracts.js +67 -0
- package/dist/contracts.js.map +1 -0
- package/dist/core.d.ts +210 -0
- package/dist/core.js +491 -0
- package/dist/core.js.map +1 -0
- package/dist/http.d.ts +22 -0
- package/dist/http.js +264 -0
- package/dist/http.js.map +1 -0
- package/dist/importer.d.ts +31 -0
- package/dist/importer.js +116 -0
- package/dist/importer.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs.d.ts +97 -0
- package/dist/jobs.js +263 -0
- package/dist/jobs.js.map +1 -0
- package/dist/meta.d.ts +13 -0
- package/dist/meta.js +120 -0
- package/dist/meta.js.map +1 -0
- package/dist/models.d.ts +38 -0
- package/dist/models.js +75 -0
- package/dist/models.js.map +1 -0
- package/dist/oauth.d.ts +69 -0
- package/dist/oauth.js +160 -0
- package/dist/oauth.js.map +1 -0
- package/dist/policy.d.ts +90 -0
- package/dist/policy.js +205 -0
- package/dist/policy.js.map +1 -0
- package/dist/recorder.d.ts +88 -0
- package/dist/recorder.js +194 -0
- package/dist/recorder.js.map +1 -0
- package/dist/refs.d.ts +128 -0
- package/dist/refs.js +455 -0
- package/dist/refs.js.map +1 -0
- package/dist/sandbox.d.ts +30 -0
- package/dist/sandbox.js +176 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/secrets.d.ts +20 -0
- package/dist/secrets.js +81 -0
- package/dist/secrets.js.map +1 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.js +100 -0
- package/dist/server.js.map +1 -0
- package/dist/tokens.d.ts +45 -0
- package/dist/tokens.js +84 -0
- package/dist/tokens.js.map +1 -0
- package/dist/upstream.d.ts +90 -0
- package/dist/upstream.js +149 -0
- package/dist/upstream.js.map +1 -0
- package/package.json +61 -4
|
@@ -0,0 +1,1595 @@
|
|
|
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">
|
|
6
|
+
<meta name="mycel-token" content="__MYCEL_TOKEN__">
|
|
7
|
+
<meta name="color-scheme" content="dark">
|
|
8
|
+
<title>Mycel Dashboard</title>
|
|
9
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
10
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
11
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
|
|
12
|
+
<style>
|
|
13
|
+
:root {
|
|
14
|
+
--bg: #07110D;
|
|
15
|
+
--bg-2: #091610;
|
|
16
|
+
--panel: #0D1C16;
|
|
17
|
+
--panel-2: #10231B;
|
|
18
|
+
--panel-3: #142B21;
|
|
19
|
+
--line: #1B3328;
|
|
20
|
+
--line-2: #24433A;
|
|
21
|
+
--text: #E4F2EA;
|
|
22
|
+
--text-2: #B9CEC3;
|
|
23
|
+
--muted: #8FA89C;
|
|
24
|
+
--faint: #5E7A6D;
|
|
25
|
+
--accent: #3DFFB0;
|
|
26
|
+
--accent-dim: rgba(61, 255, 176, .12);
|
|
27
|
+
--accent-glow: rgba(61, 255, 176, .35);
|
|
28
|
+
--amber: #FFB547;
|
|
29
|
+
--amber-dim: rgba(255, 181, 71, .12);
|
|
30
|
+
--red: #FF6B6B;
|
|
31
|
+
--red-dim: rgba(255, 107, 107, .12);
|
|
32
|
+
--blue: #7CC4FF;
|
|
33
|
+
--blue-dim: rgba(124, 196, 255, .12);
|
|
34
|
+
--violet: #C6A7FF;
|
|
35
|
+
--violet-dim: rgba(198, 167, 255, .12);
|
|
36
|
+
--radius: 12px;
|
|
37
|
+
--radius-sm: 8px;
|
|
38
|
+
--mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
39
|
+
--sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
40
|
+
--shadow: 0 1px 0 rgba(255,255,255,.02) inset, 0 12px 32px -18px rgba(0,0,0,.8);
|
|
41
|
+
}
|
|
42
|
+
* { box-sizing: border-box; }
|
|
43
|
+
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
|
|
44
|
+
body {
|
|
45
|
+
margin: 0; background: var(--bg); color: var(--text);
|
|
46
|
+
font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
|
|
47
|
+
background-image:
|
|
48
|
+
radial-gradient(1200px 500px at 10% -10%, rgba(61,255,176,.06), transparent 60%),
|
|
49
|
+
radial-gradient(900px 400px at 100% 0%, rgba(61,255,176,.035), transparent 60%);
|
|
50
|
+
background-attachment: fixed;
|
|
51
|
+
min-height: 100vh;
|
|
52
|
+
}
|
|
53
|
+
button, input, select { font: inherit; color: inherit; }
|
|
54
|
+
a { color: var(--accent); }
|
|
55
|
+
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
|
|
56
|
+
.mono { font-family: var(--mono); font-size: 12.5px; }
|
|
57
|
+
.muted { color: var(--muted); }
|
|
58
|
+
.faint { color: var(--faint); }
|
|
59
|
+
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
|
|
60
|
+
.skip { position: absolute; left: 12px; top: -40px; background: var(--accent); color: #04130C; padding: 8px 12px; border-radius: 8px; z-index: 100; font-weight: 600; text-decoration: none; }
|
|
61
|
+
.skip:focus { top: 12px; }
|
|
62
|
+
|
|
63
|
+
/* ---------- header ---------- */
|
|
64
|
+
header.top {
|
|
65
|
+
position: sticky; top: 0; z-index: 20;
|
|
66
|
+
display: flex; align-items: center; gap: 16px;
|
|
67
|
+
padding: 12px 24px; border-bottom: 1px solid var(--line);
|
|
68
|
+
background: rgba(7, 17, 13, .82); backdrop-filter: blur(12px);
|
|
69
|
+
}
|
|
70
|
+
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
|
|
71
|
+
.brand svg { filter: drop-shadow(0 0 6px var(--accent-glow)); }
|
|
72
|
+
.brand b { font-weight: 650; letter-spacing: -.02em; font-size: 17px; }
|
|
73
|
+
nav.sections { display: flex; gap: 2px; margin-left: 8px; overflow-x: auto; scrollbar-width: none; }
|
|
74
|
+
nav.sections a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 7px; font-size: 13px; white-space: nowrap; }
|
|
75
|
+
nav.sections a:hover { color: var(--text); background: var(--panel); }
|
|
76
|
+
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
|
|
77
|
+
.chip {
|
|
78
|
+
display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
|
|
79
|
+
border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap;
|
|
80
|
+
border: 1px solid var(--line-2); color: var(--text-2); background: var(--panel);
|
|
81
|
+
}
|
|
82
|
+
.chip.accent { color: var(--accent); border-color: rgba(61,255,176,.3); background: var(--accent-dim); }
|
|
83
|
+
.chip.amber { color: var(--amber); border-color: rgba(255,181,71,.35); background: var(--amber-dim); }
|
|
84
|
+
.chip.red { color: var(--red); border-color: rgba(255,107,107,.35); background: var(--red-dim); }
|
|
85
|
+
.chip.blue { color: var(--blue); border-color: rgba(124,196,255,.3); background: var(--blue-dim); }
|
|
86
|
+
.chip.violet { color: var(--violet); border-color: rgba(198,167,255,.3); background: var(--violet-dim); }
|
|
87
|
+
.chip.ghost { background: transparent; }
|
|
88
|
+
.chip.mono { font-family: var(--mono); font-size: 11px; }
|
|
89
|
+
.conn { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
|
|
90
|
+
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
|
|
91
|
+
.dot.live { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim), 0 0 10px var(--accent-glow); animation: pulse 2.4s ease-in-out infinite; }
|
|
92
|
+
.dot.warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-dim); }
|
|
93
|
+
.dot.err { background: var(--red); box-shadow: 0 0 0 3px var(--red-dim); }
|
|
94
|
+
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(61,255,176,.05), 0 0 14px var(--accent-glow); } }
|
|
95
|
+
@media (prefers-reduced-motion: reduce) { .dot.live { animation: none; } html { scroll-behavior: auto; } * { transition: none !important; } }
|
|
96
|
+
|
|
97
|
+
/* ---------- layout ---------- */
|
|
98
|
+
main { max-width: 1440px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 24px; }
|
|
99
|
+
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
|
|
100
|
+
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); min-height: 52px; flex-wrap: wrap; }
|
|
101
|
+
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
|
|
102
|
+
.panel-head .count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
|
|
103
|
+
.panel-head .spacer { flex: 1; }
|
|
104
|
+
.panel-body { padding: 12px 16px 16px; }
|
|
105
|
+
.grid-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(320px, 1fr); gap: 24px; align-items: start; }
|
|
106
|
+
.stack { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
|
|
107
|
+
|
|
108
|
+
/* ---------- buttons ---------- */
|
|
109
|
+
.btn {
|
|
110
|
+
display: inline-flex; align-items: center; justify-content: center; gap: 6px;
|
|
111
|
+
height: 30px; padding: 0 12px; border-radius: 8px; cursor: pointer;
|
|
112
|
+
border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text);
|
|
113
|
+
font-size: 12.5px; font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s, opacity .12s;
|
|
114
|
+
}
|
|
115
|
+
.btn:hover { background: var(--panel-3); border-color: #2E5546; }
|
|
116
|
+
.btn:disabled { opacity: .45; cursor: not-allowed; }
|
|
117
|
+
.btn.primary { background: var(--accent); border-color: var(--accent); color: #03140C; font-weight: 600; }
|
|
118
|
+
.btn.primary:hover { background: #6BFFC4; }
|
|
119
|
+
.btn.danger { color: var(--red); border-color: rgba(255,107,107,.35); background: transparent; }
|
|
120
|
+
.btn.danger:hover { background: var(--red-dim); }
|
|
121
|
+
.btn.amber { color: #1A1003; background: var(--amber); border-color: var(--amber); font-weight: 600; }
|
|
122
|
+
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
|
|
123
|
+
.btn.ghost:hover { color: var(--text); background: var(--panel-2); }
|
|
124
|
+
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
|
|
125
|
+
.btn.icon { width: 30px; padding: 0; }
|
|
126
|
+
.btn svg { width: 14px; height: 14px; }
|
|
127
|
+
|
|
128
|
+
/* ---------- KPIs ---------- */
|
|
129
|
+
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
|
|
130
|
+
.kpi { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; text-align: left; }
|
|
131
|
+
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }
|
|
132
|
+
.kpi .value { font-size: 30px; font-weight: 650; letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
|
|
133
|
+
.kpi .value small { font-size: 15px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
|
|
134
|
+
.kpi .sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
135
|
+
.kpi .sub b { color: var(--text-2); font-weight: 500; }
|
|
136
|
+
.kpi.hero { background: linear-gradient(160deg, rgba(61,255,176,.10), rgba(61,255,176,0) 55%), var(--panel); border-color: rgba(61,255,176,.22); }
|
|
137
|
+
.kpi.hero .value { color: var(--accent); text-shadow: 0 0 24px rgba(61,255,176,.25); }
|
|
138
|
+
.kpi.approvals { cursor: pointer; font: inherit; color: inherit; border: 1px solid var(--line); }
|
|
139
|
+
.kpi.approvals:hover { border-color: var(--line-2); }
|
|
140
|
+
.kpi.approvals.has { border-color: rgba(255,181,71,.4); background: linear-gradient(160deg, rgba(255,181,71,.10), rgba(255,181,71,0) 60%), var(--panel); }
|
|
141
|
+
.kpi.approvals.has .value { color: var(--amber); }
|
|
142
|
+
.bar { height: 6px; border-radius: 999px; background: var(--panel-3); overflow: hidden; margin-top: 4px; }
|
|
143
|
+
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
|
|
144
|
+
.bar.amber > i { background: var(--amber); }
|
|
145
|
+
.bar.red > i { background: var(--red); }
|
|
146
|
+
.bar.indet > i { width: 35% !important; animation: indet 1.4s ease-in-out infinite; }
|
|
147
|
+
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
|
|
148
|
+
.ctxbars { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
|
|
149
|
+
.ctxbars .bar { height: 4px; margin: 0; }
|
|
150
|
+
.ctxbars .bar.direct > i { background: var(--faint); }
|
|
151
|
+
|
|
152
|
+
/* ---------- banner ---------- */
|
|
153
|
+
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid rgba(255,181,71,.35); background: var(--amber-dim); color: var(--text); flex-wrap: wrap; }
|
|
154
|
+
.banner svg { color: var(--amber); flex-shrink: 0; }
|
|
155
|
+
.banner .txt { flex: 1; min-width: 200px; }
|
|
156
|
+
.banner .txt b { color: var(--amber); }
|
|
157
|
+
.banner .ids { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
|
|
158
|
+
|
|
159
|
+
/* ---------- feed ---------- */
|
|
160
|
+
.feed { list-style: none; margin: 0; padding: 4px 0; max-height: 560px; overflow-y: auto; }
|
|
161
|
+
.feed li { padding: 0 8px; }
|
|
162
|
+
.row-btn {
|
|
163
|
+
width: 100%; display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center;
|
|
164
|
+
padding: 8px 8px; border-radius: 8px; border: 0; background: transparent; text-align: left; cursor: pointer; color: inherit;
|
|
165
|
+
}
|
|
166
|
+
.row-btn:hover { background: var(--panel-2); }
|
|
167
|
+
.feed li.fresh .row-btn { animation: fresh 1.6s ease-out; }
|
|
168
|
+
@keyframes fresh { from { background: rgba(61,255,176,.10); } to { background: transparent; } }
|
|
169
|
+
.kicon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--panel-3); color: var(--text-2); border: 1px solid var(--line); }
|
|
170
|
+
.kicon svg { width: 15px; height: 15px; }
|
|
171
|
+
.kicon.call { color: var(--accent); }
|
|
172
|
+
.kicon.run { color: var(--violet); }
|
|
173
|
+
.kicon.job { color: var(--blue); }
|
|
174
|
+
.kicon.approval, .kicon.policy, .kicon.drift { color: var(--amber); }
|
|
175
|
+
.kicon.err { color: var(--red); border-color: rgba(255,107,107,.3); background: var(--red-dim); }
|
|
176
|
+
.feed .main-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
|
177
|
+
.feed .tool { font-family: var(--mono); font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
178
|
+
.feed .meta-line { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
|
|
179
|
+
.feed .meta-line .saved { color: var(--accent); }
|
|
180
|
+
.feed .meta-line .errtxt { color: var(--red); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }
|
|
181
|
+
.feed .right { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 11.5px; font-variant-numeric: tabular-nums; }
|
|
182
|
+
.seg { display: inline-flex; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
|
|
183
|
+
.seg button { border: 0; background: transparent; color: var(--muted); padding: 3px 9px; border-radius: 6px; font-size: 12px; cursor: pointer; }
|
|
184
|
+
.seg button[aria-pressed="true"] { background: var(--panel-3); color: var(--text); }
|
|
185
|
+
|
|
186
|
+
/* ---------- empty ---------- */
|
|
187
|
+
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 32px 16px; color: var(--muted); }
|
|
188
|
+
.empty svg { color: var(--faint); margin-bottom: 4px; }
|
|
189
|
+
.empty b { color: var(--text-2); font-weight: 600; font-size: 13.5px; }
|
|
190
|
+
.empty span { font-size: 12.5px; max-width: 420px; }
|
|
191
|
+
.empty code { font-family: var(--mono); font-size: 12px; background: var(--panel-3); padding: 1px 6px; border-radius: 5px; color: var(--text-2); }
|
|
192
|
+
|
|
193
|
+
/* ---------- approvals ---------- */
|
|
194
|
+
.cards { display: flex; flex-direction: column; gap: 10px; }
|
|
195
|
+
.acard { border: 1px solid rgba(255,181,71,.3); border-radius: 10px; background: linear-gradient(180deg, rgba(255,181,71,.06), transparent 70%), var(--panel-2); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; transition: opacity .2s; }
|
|
196
|
+
.acard.busy { opacity: .5; pointer-events: none; }
|
|
197
|
+
.acard .head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
|
198
|
+
.acard .tool { font-family: var(--mono); font-size: 13px; font-weight: 500; }
|
|
199
|
+
.acard .reason { font-size: 12.5px; color: var(--text-2); }
|
|
200
|
+
.acard .actions { display: flex; gap: 8px; justify-content: flex-end; }
|
|
201
|
+
.acard .when { margin-left: auto; font-size: 11.5px; color: var(--muted); }
|
|
202
|
+
|
|
203
|
+
/* ---------- jobs ---------- */
|
|
204
|
+
.jobs { display: flex; flex-direction: column; }
|
|
205
|
+
.job { padding: 10px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
|
|
206
|
+
.job:first-child { border-top: 0; }
|
|
207
|
+
.job .head { display: flex; align-items: center; gap: 8px; min-width: 0; }
|
|
208
|
+
.job .tool { font-family: var(--mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
209
|
+
.job .info { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; font-variant-numeric: tabular-nums; }
|
|
210
|
+
.job .acts { margin-left: auto; display: flex; gap: 6px; flex-shrink: 0; }
|
|
211
|
+
.job .err { color: var(--red); font-size: 12px; font-family: var(--mono); word-break: break-word; }
|
|
212
|
+
|
|
213
|
+
/* ---------- tables ---------- */
|
|
214
|
+
.tbl-wrap { overflow-x: auto; }
|
|
215
|
+
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
216
|
+
.tbl th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
|
|
217
|
+
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
|
|
218
|
+
.tbl tr:last-child td { border-bottom: 0; }
|
|
219
|
+
.tbl tbody tr.click { cursor: pointer; }
|
|
220
|
+
.tbl tbody tr.click:hover td { background: var(--panel-2); }
|
|
221
|
+
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
222
|
+
.tbl .ell { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
223
|
+
.linkbtn { background: none; border: 0; padding: 0; color: var(--text); cursor: pointer; text-align: left; font: inherit; }
|
|
224
|
+
.linkbtn:hover { color: var(--accent); }
|
|
225
|
+
|
|
226
|
+
/* ---------- servers ---------- */
|
|
227
|
+
.servers { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
|
|
228
|
+
.scard { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--panel-2); display: flex; flex-direction: column; gap: 6px; }
|
|
229
|
+
.scard .head { display: flex; align-items: center; gap: 8px; }
|
|
230
|
+
.scard .name { font-weight: 600; font-family: var(--mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
|
|
231
|
+
.scard .stat { font-size: 12px; color: var(--muted); display: flex; gap: 10px; }
|
|
232
|
+
.scard .err { font-size: 11.5px; color: var(--red); font-family: var(--mono); word-break: break-word; }
|
|
233
|
+
.search { position: relative; flex: 1; max-width: 360px; min-width: 180px; }
|
|
234
|
+
.search input { width: 100%; height: 32px; padding: 0 10px 0 32px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); outline: none; }
|
|
235
|
+
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
|
|
236
|
+
.search svg { position: absolute; left: 10px; top: 9px; width: 14px; height: 14px; color: var(--faint); }
|
|
237
|
+
.subhead { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 10px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
|
|
238
|
+
.kv-chips { display: flex; gap: 6px; flex-wrap: wrap; }
|
|
239
|
+
|
|
240
|
+
/* ---------- drawer ---------- */
|
|
241
|
+
.backdrop { position: fixed; inset: 0; background: rgba(2, 8, 5, .6); backdrop-filter: blur(2px); z-index: 40; opacity: 0; pointer-events: none; transition: opacity .18s; }
|
|
242
|
+
.backdrop.open { opacity: 1; pointer-events: auto; }
|
|
243
|
+
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(780px, 100vw); background: var(--bg-2); border-left: 1px solid var(--line-2); z-index: 41; transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0,0,0,.5); visibility: hidden; }
|
|
244
|
+
.drawer.open { transform: none; visibility: visible; }
|
|
245
|
+
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
|
|
246
|
+
.drawer-head h2 { margin: 0; font-size: 16px; font-weight: 600; font-family: var(--mono); word-break: break-all; }
|
|
247
|
+
.drawer-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
|
|
248
|
+
.drawer-body { overflow-y: auto; padding: 16px 20px 32px; flex: 1; }
|
|
249
|
+
.stats-row { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 8px; margin-bottom: 16px; }
|
|
250
|
+
.stat-box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
|
|
251
|
+
.stat-box .l { font-size: 11px; color: var(--muted); }
|
|
252
|
+
.stat-box .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
|
|
253
|
+
|
|
254
|
+
/* waterfall */
|
|
255
|
+
.wf { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
|
|
256
|
+
.wf-axis { display: grid; grid-template-columns: minmax(180px, 38%) 1fr 64px; font-size: 11px; color: var(--faint); border-bottom: 1px solid var(--line); padding: 6px 10px; font-variant-numeric: tabular-nums; }
|
|
257
|
+
.wf-axis .ticks { display: flex; justify-content: space-between; }
|
|
258
|
+
.wf-row { border-bottom: 1px solid var(--line); }
|
|
259
|
+
.wf-row:last-child { border-bottom: 0; }
|
|
260
|
+
.wf-btn { width: 100%; display: grid; grid-template-columns: minmax(180px, 38%) 1fr 64px; align-items: center; gap: 0; padding: 6px 10px; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
|
|
261
|
+
.wf-btn:hover, .wf-btn[aria-expanded="true"] { background: var(--panel-2); }
|
|
262
|
+
.wf-label { display: flex; align-items: center; gap: 7px; min-width: 0; padding-right: 10px; }
|
|
263
|
+
.wf-label .kicon { width: 22px; height: 22px; border-radius: 6px; flex-shrink: 0; }
|
|
264
|
+
.wf-label .kicon svg { width: 12px; height: 12px; }
|
|
265
|
+
.wf-label .t { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
266
|
+
.wf-label .caret { color: var(--faint); width: 10px; flex-shrink: 0; transition: transform .15s; }
|
|
267
|
+
.wf-btn[aria-expanded="true"] .caret { transform: rotate(90deg); }
|
|
268
|
+
.wf-track { position: relative; height: 18px; background: repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), var(--line) calc(25% - 1px) 25%); border-radius: 4px; }
|
|
269
|
+
.wf-bar { position: absolute; top: 4px; height: 10px; border-radius: 3px; background: var(--accent); min-width: 3px; box-shadow: 0 0 8px rgba(61,255,176,.25); }
|
|
270
|
+
.wf-bar.run { background: var(--violet); box-shadow: none; }
|
|
271
|
+
.wf-bar.job { background: var(--blue); box-shadow: none; }
|
|
272
|
+
.wf-bar.amber { background: var(--amber); box-shadow: none; }
|
|
273
|
+
.wf-bar.err { background: var(--red); box-shadow: none; }
|
|
274
|
+
.wf-bar.point { width: 8px !important; min-width: 8px; height: 8px; top: 5px; transform: rotate(45deg); border-radius: 2px; margin-left: -4px; }
|
|
275
|
+
.wf-dur { text-align: right; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
276
|
+
.wf-detail { padding: 10px 14px 14px; background: var(--bg-2); border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 10px; }
|
|
277
|
+
.kvs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 14px; font-size: 12px; }
|
|
278
|
+
.kvs div { min-width: 0; }
|
|
279
|
+
.kvs .k { color: var(--faint); font-size: 11px; }
|
|
280
|
+
.kvs .v { font-family: var(--mono); font-size: 12px; word-break: break-all; color: var(--text-2); }
|
|
281
|
+
.block-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
|
|
282
|
+
pre.code, .json { margin: 0; font-family: var(--mono); font-size: 12px; line-height: 1.55; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow: auto; max-height: 360px; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
|
|
283
|
+
pre.code.err { color: var(--red); border-color: rgba(255,107,107,.3); background: var(--red-dim); }
|
|
284
|
+
.json details { margin-left: 0; }
|
|
285
|
+
.json details > div { padding-left: 16px; border-left: 1px solid var(--line); margin-left: 4px; }
|
|
286
|
+
.json summary { cursor: pointer; list-style: none; color: var(--muted); }
|
|
287
|
+
.json summary::-webkit-details-marker { display: none; }
|
|
288
|
+
.json summary::before { content: "▸"; display: inline-block; width: 12px; color: var(--faint); transition: transform .12s; }
|
|
289
|
+
.json details[open] > summary::before { transform: rotate(90deg); }
|
|
290
|
+
.json .k { color: var(--blue); }
|
|
291
|
+
.json .s { color: #B8F5D6; }
|
|
292
|
+
.json .n { color: var(--amber); }
|
|
293
|
+
.json .b { color: var(--violet); }
|
|
294
|
+
.json .z { color: var(--faint); }
|
|
295
|
+
.json .more { color: var(--faint); font-style: italic; }
|
|
296
|
+
.warnbox { border: 1px solid rgba(255,181,71,.35); background: var(--amber-dim); color: var(--amber); border-radius: 8px; padding: 8px 10px; font-size: 12px; }
|
|
297
|
+
|
|
298
|
+
/* refs preview */
|
|
299
|
+
.preview-media { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); background: repeating-conic-gradient(#0f1f18 0 25%, #0b1712 0 50%) 0 0/16px 16px; image-rendering: auto; }
|
|
300
|
+
.keyframes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
|
|
301
|
+
.keyframes img { width: 100%; border-radius: 6px; border: 1px solid var(--line); }
|
|
302
|
+
.thumb { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; border: 1px solid var(--line); background: var(--panel-3); display: block; }
|
|
303
|
+
.thumb.ph { display: grid; place-items: center; color: var(--faint); }
|
|
304
|
+
.thumb.ph svg { width: 14px; height: 14px; }
|
|
305
|
+
|
|
306
|
+
/* toasts */
|
|
307
|
+
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 40px)); }
|
|
308
|
+
.toast { background: var(--panel-3); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 14px; font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.5); display: flex; gap: 8px; align-items: flex-start; animation: tin .2s ease-out; }
|
|
309
|
+
.toast.err { border-color: rgba(255,107,107,.4); }
|
|
310
|
+
.toast.ok .dot { background: var(--accent); margin-top: 6px; }
|
|
311
|
+
.toast.err .dot { background: var(--red); margin-top: 6px; }
|
|
312
|
+
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
|
|
313
|
+
|
|
314
|
+
footer { max-width: 1440px; margin: 0 auto; padding: 8px 24px 32px; color: var(--faint); font-size: 12px; display: flex; gap: 16px; flex-wrap: wrap; }
|
|
315
|
+
footer .mono { font-size: 11.5px; }
|
|
316
|
+
|
|
317
|
+
/* ---------- responsive ---------- */
|
|
318
|
+
@media (max-width: 1280px) {
|
|
319
|
+
.kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
|
|
320
|
+
.kpis > * { grid-column: span 2; }
|
|
321
|
+
.kpis > :nth-child(n+4) { grid-column: span 3; }
|
|
322
|
+
}
|
|
323
|
+
@media (max-width: 1100px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }
|
|
324
|
+
@media (max-width: 900px) {
|
|
325
|
+
header.top { padding: 10px 16px; gap: 10px; flex-wrap: wrap; }
|
|
326
|
+
nav.sections { order: 3; width: 100%; margin-left: 0; }
|
|
327
|
+
main { padding: 16px; gap: 16px; }
|
|
328
|
+
.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
|
|
329
|
+
.kpis > *, .kpis > :nth-child(n+4) { grid-column: span 1; }
|
|
330
|
+
.kpis > :first-child { grid-column: span 2; }
|
|
331
|
+
.stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
332
|
+
.wf-axis, .wf-btn { grid-template-columns: minmax(140px, 42%) 1fr 56px; }
|
|
333
|
+
}
|
|
334
|
+
@media (max-width: 560px) {
|
|
335
|
+
.kpis { grid-template-columns: minmax(0, 1fr); }
|
|
336
|
+
.kpis > :first-child { grid-column: span 1; }
|
|
337
|
+
.top-right .ver { display: none; }
|
|
338
|
+
}
|
|
339
|
+
</style>
|
|
340
|
+
</head>
|
|
341
|
+
<body>
|
|
342
|
+
<a class="skip" href="#main">Skip to content</a>
|
|
343
|
+
<header class="top">
|
|
344
|
+
<a class="brand" href="#" aria-label="Mycel dashboard home">
|
|
345
|
+
<svg width="26" height="26" viewBox="0 0 32 32" fill="none" aria-hidden="true">
|
|
346
|
+
<g stroke="#3DFFB0" stroke-width="1.6" stroke-linecap="round">
|
|
347
|
+
<path d="M16 16 L7 8 M16 16 L26 7 M16 16 L27 21 M16 16 L9 26 M16 16 L18 28 M7 8 L4 13 M26 7 L29 11 M9 26 L4 24" opacity=".85"/>
|
|
348
|
+
</g>
|
|
349
|
+
<g fill="#3DFFB0">
|
|
350
|
+
<circle cx="16" cy="16" r="3.4"/>
|
|
351
|
+
<circle cx="7" cy="8" r="2"/><circle cx="26" cy="7" r="2"/><circle cx="27" cy="21" r="2"/>
|
|
352
|
+
<circle cx="9" cy="26" r="2"/><circle cx="18" cy="28" r="1.6"/>
|
|
353
|
+
<circle cx="4" cy="13" r="1.2" opacity=".7"/><circle cx="29" cy="11" r="1.2" opacity=".7"/><circle cx="4" cy="24" r="1.2" opacity=".7"/>
|
|
354
|
+
</g>
|
|
355
|
+
</svg>
|
|
356
|
+
<b>Mycel</b>
|
|
357
|
+
</a>
|
|
358
|
+
<nav class="sections" aria-label="Sections">
|
|
359
|
+
<a href="#activity">Activity</a>
|
|
360
|
+
<a href="#approvals">Approvals</a>
|
|
361
|
+
<a href="#jobs">Jobs</a>
|
|
362
|
+
<a href="#traces">Traces</a>
|
|
363
|
+
<a href="#servers">Servers</a>
|
|
364
|
+
<a href="#refs">Refs</a>
|
|
365
|
+
</nav>
|
|
366
|
+
<div class="top-right">
|
|
367
|
+
<span class="chip accent" id="router-chip" title="Router mode">router: —</span>
|
|
368
|
+
<span class="conn" id="conn" role="status" aria-live="polite"><span class="dot" id="conn-dot"></span><span id="conn-label">Connecting…</span></span>
|
|
369
|
+
<span class="chip ghost mono ver" id="version">v—</span>
|
|
370
|
+
</div>
|
|
371
|
+
</header>
|
|
372
|
+
|
|
373
|
+
<main id="main" tabindex="-1">
|
|
374
|
+
<section class="kpis" aria-label="Key metrics">
|
|
375
|
+
<div class="panel kpi hero">
|
|
376
|
+
<div class="label">Tokens saved <span class="faint">· 30 days</span></div>
|
|
377
|
+
<div class="value" id="k-saved">—</div>
|
|
378
|
+
<div class="sub" id="k-saved-sub"> </div>
|
|
379
|
+
</div>
|
|
380
|
+
<div class="panel kpi">
|
|
381
|
+
<div class="label">Context footprint</div>
|
|
382
|
+
<div class="value" id="k-ctx">—</div>
|
|
383
|
+
<div class="sub" id="k-ctx-sub"> </div>
|
|
384
|
+
<div class="ctxbars" aria-hidden="true">
|
|
385
|
+
<div class="bar direct"><i id="k-ctx-bar-direct" style="width:100%"></i></div>
|
|
386
|
+
<div class="bar"><i id="k-ctx-bar-mycel"></i></div>
|
|
387
|
+
</div>
|
|
388
|
+
</div>
|
|
389
|
+
<div class="panel kpi">
|
|
390
|
+
<div class="label">Calls <span class="faint">· 30 days</span></div>
|
|
391
|
+
<div class="value" id="k-calls">—</div>
|
|
392
|
+
<div class="sub" id="k-calls-sub"> </div>
|
|
393
|
+
</div>
|
|
394
|
+
<div class="panel kpi">
|
|
395
|
+
<div class="label">Spend today</div>
|
|
396
|
+
<div class="value" id="k-spend">—</div>
|
|
397
|
+
<div class="sub" id="k-spend-sub"> </div>
|
|
398
|
+
<div class="bar" id="k-spend-barwrap" role="progressbar" aria-label="Daily budget used" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0"><i id="k-spend-bar"></i></div>
|
|
399
|
+
</div>
|
|
400
|
+
<button type="button" class="panel kpi approvals" id="k-apv-btn" aria-describedby="k-apv-sub">
|
|
401
|
+
<span class="label">Pending approvals</span>
|
|
402
|
+
<span class="value" id="k-apv">—</span>
|
|
403
|
+
<span class="sub" id="k-apv-sub"> </span>
|
|
404
|
+
</button>
|
|
405
|
+
</section>
|
|
406
|
+
|
|
407
|
+
<div id="auth-slot"></div>
|
|
408
|
+
<div id="drift-slot"></div>
|
|
409
|
+
|
|
410
|
+
<div class="grid-main">
|
|
411
|
+
<section class="panel" id="activity" aria-labelledby="h-activity">
|
|
412
|
+
<div class="panel-head">
|
|
413
|
+
<h2 id="h-activity">Live activity</h2>
|
|
414
|
+
<span class="count" id="feed-count"></span>
|
|
415
|
+
<span class="spacer"></span>
|
|
416
|
+
<div class="seg" role="group" aria-label="Filter activity" id="feed-filter">
|
|
417
|
+
<button type="button" data-f="all" aria-pressed="true">All</button>
|
|
418
|
+
<button type="button" data-f="call" aria-pressed="false">Calls</button>
|
|
419
|
+
<button type="button" data-f="run" aria-pressed="false">Runs</button>
|
|
420
|
+
<button type="button" data-f="guard" aria-pressed="false">Policy</button>
|
|
421
|
+
<button type="button" data-f="err" aria-pressed="false">Errors</button>
|
|
422
|
+
</div>
|
|
423
|
+
<button type="button" class="btn sm" id="feed-pause" aria-pressed="false">Pause</button>
|
|
424
|
+
</div>
|
|
425
|
+
<ul class="feed" id="feed" aria-live="polite" aria-relevant="additions" aria-label="Live activity feed"></ul>
|
|
426
|
+
</section>
|
|
427
|
+
|
|
428
|
+
<div class="stack">
|
|
429
|
+
<section class="panel" id="approvals" aria-labelledby="h-approvals" tabindex="-1">
|
|
430
|
+
<div class="panel-head">
|
|
431
|
+
<h2 id="h-approvals">Approvals</h2>
|
|
432
|
+
<span class="count" id="apv-count"></span>
|
|
433
|
+
<span class="spacer"></span>
|
|
434
|
+
<button type="button" class="btn ghost sm" id="apv-refresh">Refresh</button>
|
|
435
|
+
</div>
|
|
436
|
+
<div class="panel-body"><div class="cards" id="apv-list"></div></div>
|
|
437
|
+
</section>
|
|
438
|
+
<section class="panel" id="jobs" aria-labelledby="h-jobs">
|
|
439
|
+
<div class="panel-head">
|
|
440
|
+
<h2 id="h-jobs">Jobs</h2>
|
|
441
|
+
<span class="count" id="jobs-count"></span>
|
|
442
|
+
<span class="spacer"></span>
|
|
443
|
+
<button type="button" class="btn ghost sm" id="jobs-refresh">Refresh</button>
|
|
444
|
+
</div>
|
|
445
|
+
<div class="panel-body"><div class="jobs" id="jobs-list"></div></div>
|
|
446
|
+
</section>
|
|
447
|
+
</div>
|
|
448
|
+
</div>
|
|
449
|
+
|
|
450
|
+
<section class="panel" id="traces" aria-labelledby="h-traces">
|
|
451
|
+
<div class="panel-head">
|
|
452
|
+
<h2 id="h-traces">Traces</h2>
|
|
453
|
+
<span class="count" id="traces-count"></span>
|
|
454
|
+
<span class="spacer"></span>
|
|
455
|
+
<span class="faint" style="font-size:12px">Last 7 days</span>
|
|
456
|
+
<button type="button" class="btn ghost sm" id="traces-refresh">Refresh</button>
|
|
457
|
+
</div>
|
|
458
|
+
<div id="traces-body"></div>
|
|
459
|
+
</section>
|
|
460
|
+
|
|
461
|
+
<section class="panel" id="servers" aria-labelledby="h-servers">
|
|
462
|
+
<div class="panel-head">
|
|
463
|
+
<h2 id="h-servers">Servers & catalog</h2>
|
|
464
|
+
<span class="count" id="servers-count"></span>
|
|
465
|
+
</div>
|
|
466
|
+
<div class="panel-body">
|
|
467
|
+
<div class="servers" id="servers-list"></div>
|
|
468
|
+
<div id="models-peers"></div>
|
|
469
|
+
<div class="subhead" style="justify-content:space-between;flex-wrap:wrap">
|
|
470
|
+
<span>Tool catalog <span class="faint" id="catalog-count" style="text-transform:none;letter-spacing:0"></span></span>
|
|
471
|
+
<label class="search">
|
|
472
|
+
<span class="sr-only">Search the tool catalog</span>
|
|
473
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M20 20l-4-4"/></svg>
|
|
474
|
+
<input type="search" id="catalog-q" placeholder="Search tools (BM25)…" autocomplete="off" spellcheck="false">
|
|
475
|
+
</label>
|
|
476
|
+
</div>
|
|
477
|
+
<div class="tbl-wrap" id="catalog-body"></div>
|
|
478
|
+
</div>
|
|
479
|
+
</section>
|
|
480
|
+
|
|
481
|
+
<section class="panel" id="refs" aria-labelledby="h-refs">
|
|
482
|
+
<div class="panel-head">
|
|
483
|
+
<h2 id="h-refs">Refs</h2>
|
|
484
|
+
<span class="count" id="refs-count"></span>
|
|
485
|
+
<span class="spacer"></span>
|
|
486
|
+
<button type="button" class="btn ghost sm" id="refs-refresh">Refresh</button>
|
|
487
|
+
</div>
|
|
488
|
+
<div class="tbl-wrap" id="refs-body"></div>
|
|
489
|
+
</section>
|
|
490
|
+
</main>
|
|
491
|
+
|
|
492
|
+
<footer>
|
|
493
|
+
<span>Mycel · local-first, no telemetry</span>
|
|
494
|
+
<span>session <span class="mono" id="f-session">—</span></span>
|
|
495
|
+
<span id="f-updated"></span>
|
|
496
|
+
</footer>
|
|
497
|
+
|
|
498
|
+
<div class="backdrop" id="backdrop"></div>
|
|
499
|
+
<aside class="drawer" id="drawer" role="dialog" aria-modal="true" aria-labelledby="drawer-title" aria-hidden="true">
|
|
500
|
+
<div class="drawer-head">
|
|
501
|
+
<div style="flex:1;min-width:0">
|
|
502
|
+
<h2 id="drawer-title">—</h2>
|
|
503
|
+
<div class="sub" id="drawer-sub"></div>
|
|
504
|
+
</div>
|
|
505
|
+
<button type="button" class="btn icon ghost" id="drawer-close" aria-label="Close panel">
|
|
506
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>
|
|
507
|
+
</button>
|
|
508
|
+
</div>
|
|
509
|
+
<div class="drawer-body" id="drawer-body"></div>
|
|
510
|
+
</aside>
|
|
511
|
+
<div class="toasts" id="toasts" role="status" aria-live="polite"></div>
|
|
512
|
+
|
|
513
|
+
<script>
|
|
514
|
+
"use strict";
|
|
515
|
+
(() => {
|
|
516
|
+
// ------------------------------------------------------------------ basics
|
|
517
|
+
const TOKEN = document.querySelector('meta[name="mycel-token"]').getAttribute("content") || "";
|
|
518
|
+
const $ = (id) => document.getElementById(id);
|
|
519
|
+
|
|
520
|
+
/** Build DOM safely. Strings are always inserted as text, never parsed as HTML. */
|
|
521
|
+
function h(tag, props, ...kids) {
|
|
522
|
+
const el = document.createElement(tag);
|
|
523
|
+
if (props) {
|
|
524
|
+
for (const [k, v] of Object.entries(props)) {
|
|
525
|
+
if (v === undefined || v === null || v === false) continue;
|
|
526
|
+
if (k === "class") el.className = v;
|
|
527
|
+
else if (k === "text") el.textContent = String(v);
|
|
528
|
+
else if (k === "style") el.setAttribute("style", v);
|
|
529
|
+
else if (k.startsWith("on") && typeof v === "function") el.addEventListener(k.slice(2), v);
|
|
530
|
+
else el.setAttribute(k, v === true ? "" : String(v));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
for (const kid of kids.flat(Infinity)) {
|
|
534
|
+
if (kid === undefined || kid === null || kid === false) continue;
|
|
535
|
+
el.append(kid instanceof Node ? kid : document.createTextNode(String(kid)));
|
|
536
|
+
}
|
|
537
|
+
return el;
|
|
538
|
+
}
|
|
539
|
+
/** Icons are static, trusted markup defined in this file. */
|
|
540
|
+
const ICON_PATHS = {
|
|
541
|
+
call: "M7 17L17 7M9 7h8v8",
|
|
542
|
+
run: "M8 7l-5 5 5 5M16 7l5 5-5 5M13.5 5l-3 14",
|
|
543
|
+
search: "M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14zM20 20l-4-4",
|
|
544
|
+
describe: "M6 3h9l4 4v14H6zM14 3v5h5M9 13h6M9 17h6",
|
|
545
|
+
job: "M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18zM12 7v5l3 2",
|
|
546
|
+
approval: "M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6zM9 12l2 2 4-4",
|
|
547
|
+
policy: "M6 11h12v9H6zM8.5 11V8a3.5 3.5 0 0 1 7 0v3",
|
|
548
|
+
ref: "M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1",
|
|
549
|
+
a2a: "M5 6a2 2 0 1 0 0 .01M19 6a2 2 0 1 0 0 .01M12 19a2 2 0 1 0 0 .01M6.5 7.5l4.5 9.5M17.5 7.5L13 17M7 6h10",
|
|
550
|
+
ask: "M12 3v4M12 17v4M3 12h4M17 12h4M6.3 6.3l2.5 2.5M15.2 15.2l2.5 2.5M6.3 17.7l2.5-2.5M15.2 8.8l2.5-2.5",
|
|
551
|
+
drift: "M12 3l10 18H2zM12 10v5M12 18v.01",
|
|
552
|
+
session: "M12 3v7M6.3 6.8a8 8 0 1 0 11.4 0",
|
|
553
|
+
inbox: "M3 13l3-8h12l3 8v6H3zM3 13h5l1 3h6l1-3h5",
|
|
554
|
+
image: "M4 5h16v14H4zM4 16l5-5 4 4 3-3 4 4M15 9h.01",
|
|
555
|
+
file: "M6 3h9l4 4v14H6zM14 3v5h5",
|
|
556
|
+
check: "M5 12l5 5 9-10",
|
|
557
|
+
x: "M6 6l12 12M18 6L6 18",
|
|
558
|
+
warn: "M12 3l10 18H2zM12 10v5M12 18v.01",
|
|
559
|
+
pulse: "M3 12h4l3-7 4 14 3-7h4",
|
|
560
|
+
server: "M4 4h16v6H4zM4 14h16v6H4zM8 7h.01M8 17h.01",
|
|
561
|
+
};
|
|
562
|
+
function icon(name, size = 15) {
|
|
563
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
564
|
+
svg.setAttribute("viewBox", "0 0 24 24");
|
|
565
|
+
svg.setAttribute("width", size); svg.setAttribute("height", size);
|
|
566
|
+
svg.setAttribute("fill", "none"); svg.setAttribute("stroke", "currentColor");
|
|
567
|
+
svg.setAttribute("stroke-width", "1.8"); svg.setAttribute("stroke-linecap", "round"); svg.setAttribute("stroke-linejoin", "round");
|
|
568
|
+
svg.setAttribute("aria-hidden", "true");
|
|
569
|
+
const p = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
570
|
+
p.setAttribute("d", ICON_PATHS[name] || ICON_PATHS.pulse);
|
|
571
|
+
svg.append(p);
|
|
572
|
+
return svg;
|
|
573
|
+
}
|
|
574
|
+
const clear = (el) => { while (el.firstChild) el.removeChild(el.firstChild); return el; };
|
|
575
|
+
const setKids = (el, ...kids) => { clear(el); for (const k of kids.flat(Infinity)) if (k) el.append(k); return el; };
|
|
576
|
+
|
|
577
|
+
// ------------------------------------------------------------------ formatting
|
|
578
|
+
const nf = new Intl.NumberFormat("en-US");
|
|
579
|
+
const num = (n) => nf.format(Math.round(Number(n) || 0));
|
|
580
|
+
function compact(n) {
|
|
581
|
+
n = Number(n) || 0;
|
|
582
|
+
const a = Math.abs(n);
|
|
583
|
+
if (a >= 1e9) return (n / 1e9).toFixed(a >= 1e10 ? 0 : 1).replace(/\.0$/, "") + "B";
|
|
584
|
+
if (a >= 1e6) return (n / 1e6).toFixed(a >= 1e7 ? 0 : 1).replace(/\.0$/, "") + "M";
|
|
585
|
+
if (a >= 1e4) return (n / 1e3).toFixed(a >= 1e5 ? 0 : 1).replace(/\.0$/, "") + "k";
|
|
586
|
+
return num(n);
|
|
587
|
+
}
|
|
588
|
+
function usd(n) {
|
|
589
|
+
n = Number(n) || 0;
|
|
590
|
+
if (n === 0) return "$0";
|
|
591
|
+
if (Math.abs(n) < 0.01) return "$" + n.toFixed(4).replace(/0+$/, "");
|
|
592
|
+
if (Math.abs(n) < 1) return "$" + n.toFixed(3).replace(/0$/, "");
|
|
593
|
+
return "$" + n.toFixed(2);
|
|
594
|
+
}
|
|
595
|
+
function ms(n) {
|
|
596
|
+
if (n === undefined || n === null || isNaN(n)) return "—";
|
|
597
|
+
n = Number(n);
|
|
598
|
+
if (n < 1) return "<1ms";
|
|
599
|
+
if (n < 1000) return Math.round(n) + "ms";
|
|
600
|
+
if (n < 60000) return (n / 1000).toFixed(n < 10000 ? 2 : 1) + "s";
|
|
601
|
+
const m = Math.floor(n / 60000);
|
|
602
|
+
return m + "m " + Math.round((n % 60000) / 1000) + "s";
|
|
603
|
+
}
|
|
604
|
+
function bytes(n) {
|
|
605
|
+
n = Number(n) || 0;
|
|
606
|
+
if (n < 1024) return n + " B";
|
|
607
|
+
const u = ["KB", "MB", "GB", "TB"]; let i = -1;
|
|
608
|
+
do { n /= 1024; i++; } while (n >= 1024 && i < u.length - 1);
|
|
609
|
+
return n.toFixed(n < 10 ? 1 : 0) + " " + u[i];
|
|
610
|
+
}
|
|
611
|
+
function ago(iso) {
|
|
612
|
+
const t = Date.parse(iso);
|
|
613
|
+
if (isNaN(t)) return "—";
|
|
614
|
+
const s = Math.round((Date.now() - t) / 1000);
|
|
615
|
+
if (s < 5) return "just now";
|
|
616
|
+
if (s < 60) return s + "s ago";
|
|
617
|
+
if (s < 3600) return Math.floor(s / 60) + "m ago";
|
|
618
|
+
if (s < 86400) return Math.floor(s / 3600) + "h ago";
|
|
619
|
+
return Math.floor(s / 86400) + "d ago";
|
|
620
|
+
}
|
|
621
|
+
const clock = (iso) => { const d = new Date(iso); return isNaN(d) ? "" : d.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" }); };
|
|
622
|
+
const fullTime = (iso) => { const d = new Date(iso); return isNaN(d) ? "" : d.toLocaleString(); };
|
|
623
|
+
const str = (v) => (v === undefined || v === null ? "" : String(v));
|
|
624
|
+
const shortId = (id, n = 8) => { id = str(id); return id.length > n + 2 ? id.slice(0, n) + "…" : id; };
|
|
625
|
+
const REF_RE = /^ref:\/\/([a-f0-9]{24})$/;
|
|
626
|
+
const refUrl = (id) => { const m = REF_RE.exec(str(id)); return m ? "/refs/" + m[1] + "?token=" + encodeURIComponent(TOKEN) : null; };
|
|
627
|
+
|
|
628
|
+
// ------------------------------------------------------------------ api
|
|
629
|
+
async function api(path, opts = {}) {
|
|
630
|
+
const init = { method: opts.method || "GET", headers: { "x-mycel-token": TOKEN } };
|
|
631
|
+
if (opts.body !== undefined) { init.headers["content-type"] = "application/json"; init.body = JSON.stringify(opts.body); }
|
|
632
|
+
const res = await fetch(path, init);
|
|
633
|
+
let data = null;
|
|
634
|
+
try { data = await res.json(); } catch { /* non-JSON */ }
|
|
635
|
+
if (res.status === 401) authFailed();
|
|
636
|
+
if (!res.ok) throw new Error((data && data.error) || ("HTTP " + res.status));
|
|
637
|
+
return data;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/** The token is per process: after a Mycel restart this page's token is stale. */
|
|
641
|
+
let authBroken = false;
|
|
642
|
+
function authFailed() {
|
|
643
|
+
if (authBroken) return;
|
|
644
|
+
authBroken = true;
|
|
645
|
+
if (currentES) currentES.close();
|
|
646
|
+
setConn("err", "Session expired");
|
|
647
|
+
const reload = h("button", { type: "button", class: "btn amber sm" }, "Reload dashboard");
|
|
648
|
+
reload.addEventListener("click", () => location.reload());
|
|
649
|
+
setKids($("auth-slot"), h("div", { class: "banner", role: "alert" }, icon("warn", 20),
|
|
650
|
+
h("div", { class: "txt" }, h("b", { text: "Dashboard token rejected." }), " Mycel was probably restarted; each process issues a new token. Reload to reconnect."), reload));
|
|
651
|
+
}
|
|
652
|
+
function toast(msg, kind = "ok") {
|
|
653
|
+
const t = h("div", { class: "toast " + kind }, h("span", { class: "dot" }), h("span", { text: msg }));
|
|
654
|
+
$("toasts").append(t);
|
|
655
|
+
setTimeout(() => t.remove(), kind === "err" ? 7000 : 4000);
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/** Re-render a container without losing keyboard focus on an element with the same data-fkey. */
|
|
659
|
+
function keepFocus(container, render) {
|
|
660
|
+
const a = document.activeElement;
|
|
661
|
+
const key = a && container.contains(a) ? a.getAttribute("data-fkey") : null;
|
|
662
|
+
render();
|
|
663
|
+
if (key) {
|
|
664
|
+
const n = [...container.querySelectorAll("[data-fkey]")].find((x) => x.getAttribute("data-fkey") === key);
|
|
665
|
+
if (n) n.focus({ preventScroll: true });
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
function debounce(fn, wait) {
|
|
669
|
+
let t;
|
|
670
|
+
return (...a) => { clearTimeout(t); t = setTimeout(() => fn(...a), wait); };
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
function emptyState(iconName, title, text, extra) {
|
|
674
|
+
return h("div", { class: "empty" }, icon(iconName, 28), h("b", { text: title }), text ? h("span", null, text) : null, extra || null);
|
|
675
|
+
}
|
|
676
|
+
const code = (t) => h("code", { text: t });
|
|
677
|
+
|
|
678
|
+
// ------------------------------------------------------------------ JSON viewer (safe, lazy)
|
|
679
|
+
function jsonView(value, opts = {}) {
|
|
680
|
+
const root = h("div", { class: "json" });
|
|
681
|
+
root.append(jsonNode(value, null, 0, opts.openDepth ?? 1));
|
|
682
|
+
return root;
|
|
683
|
+
}
|
|
684
|
+
function jsonNode(v, key, depth, openDepth) {
|
|
685
|
+
const keyEl = key !== null ? [h("span", { class: "k", text: JSON.stringify(String(key)) }), ": "] : [];
|
|
686
|
+
if (v === null || typeof v !== "object") {
|
|
687
|
+
let cls = "z", txt = "null";
|
|
688
|
+
if (typeof v === "string") { cls = "s"; txt = JSON.stringify(v); }
|
|
689
|
+
else if (typeof v === "number") { cls = "n"; txt = String(v); }
|
|
690
|
+
else if (typeof v === "boolean") { cls = "b"; txt = String(v); }
|
|
691
|
+
else if (v === undefined) { cls = "z"; txt = "undefined"; }
|
|
692
|
+
if (typeof v === "string" && txt.length > 3000) txt = txt.slice(0, 3000) + "… (" + num(v.length) + " chars)";
|
|
693
|
+
return h("div", null, keyEl, h("span", { class: cls, text: txt }));
|
|
694
|
+
}
|
|
695
|
+
const isArr = Array.isArray(v);
|
|
696
|
+
const entries = isArr ? v.map((x, i) => [i, x]) : Object.entries(v);
|
|
697
|
+
const label = isArr ? "[" + entries.length + "]" : "{" + entries.length + "}";
|
|
698
|
+
if (!entries.length) return h("div", null, keyEl, h("span", { class: "z", text: isArr ? "[]" : "{}" }));
|
|
699
|
+
const det = h("details");
|
|
700
|
+
const sum = h("summary", null, keyEl, h("span", { class: "z", text: label }));
|
|
701
|
+
det.append(sum);
|
|
702
|
+
const body = h("div");
|
|
703
|
+
let filled = false;
|
|
704
|
+
const fill = () => {
|
|
705
|
+
if (filled) return; filled = true;
|
|
706
|
+
const LIMIT = 100;
|
|
707
|
+
for (const [k, x] of entries.slice(0, LIMIT)) body.append(jsonNode(x, isArr ? k : k, depth + 1, openDepth));
|
|
708
|
+
if (entries.length > LIMIT) body.append(h("div", { class: "more", text: "… " + (entries.length - LIMIT) + " more" }));
|
|
709
|
+
};
|
|
710
|
+
det.append(body);
|
|
711
|
+
det.addEventListener("toggle", () => { if (det.open) fill(); });
|
|
712
|
+
if (depth < openDepth) { det.open = true; fill(); }
|
|
713
|
+
return det;
|
|
714
|
+
}
|
|
715
|
+
/** Values the recorder clipped come back as strings; try to show them as JSON when possible. */
|
|
716
|
+
function valueBlock(title, v) {
|
|
717
|
+
if (v === undefined) return null;
|
|
718
|
+
let parsed = v, note = null;
|
|
719
|
+
if (typeof v === "string") {
|
|
720
|
+
const t = v.trim();
|
|
721
|
+
if ((t.startsWith("{") || t.startsWith("[")) && !t.endsWith("…")) { try { parsed = JSON.parse(t); } catch { parsed = v; } }
|
|
722
|
+
if (t.endsWith("…")) note = "Truncated by the flight recorder (redaction limit 2 KB).";
|
|
723
|
+
}
|
|
724
|
+
const untrusted = parsed && typeof parsed === "object" && parsed.provenance === "untrusted";
|
|
725
|
+
const content = typeof parsed === "string" ? h("pre", { class: "code", text: parsed }) : jsonView(parsed, { openDepth: 1 });
|
|
726
|
+
return h("div", null,
|
|
727
|
+
h("div", { class: "block-title" }, title, untrusted ? h("span", { class: "chip amber", text: "untrusted" }) : null),
|
|
728
|
+
untrusted ? h("div", { class: "warnbox", style: "margin-bottom:6px", text: "Content from an untrusted source. Displayed as inert text only." }) : null,
|
|
729
|
+
note ? h("div", { class: "faint", style: "font-size:11.5px;margin-bottom:4px", text: note }) : null,
|
|
730
|
+
content);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
// ------------------------------------------------------------------ chips
|
|
734
|
+
const EFFECT_CLASS = { read: "accent", write: "blue", external: "violet", destructive: "red" };
|
|
735
|
+
const effectChip = (e) => h("span", { class: "chip " + (EFFECT_CLASS[e] || ""), text: str(e) || "unknown" });
|
|
736
|
+
const JOB_CLASS = { queued: "", running: "blue", succeeded: "accent", failed: "red", cancelled: "ghost", interrupted: "amber" };
|
|
737
|
+
const jobChip = (s) => h("span", { class: "chip " + (JOB_CLASS[s] ?? ""), text: str(s) });
|
|
738
|
+
function decisionChip(d) {
|
|
739
|
+
if (!d || d === "allow") return null;
|
|
740
|
+
let cls = "amber";
|
|
741
|
+
if (d === "deny" || d === "denied-by-human" || d === "block") cls = "red";
|
|
742
|
+
else if (d === "approved") cls = "accent";
|
|
743
|
+
return h("span", { class: "chip " + cls, text: d });
|
|
744
|
+
}
|
|
745
|
+
const taintChip = () => h("span", { class: "chip amber", title: "Inputs derived from untrusted content", text: "tainted" });
|
|
746
|
+
|
|
747
|
+
// ------------------------------------------------------------------ state
|
|
748
|
+
const S = {
|
|
749
|
+
overview: null,
|
|
750
|
+
feed: [], // TraceEvent, newest first
|
|
751
|
+
feedFilter: "all",
|
|
752
|
+
paused: false,
|
|
753
|
+
pausedBuffer: [],
|
|
754
|
+
traces: [],
|
|
755
|
+
jobs: new Map(),
|
|
756
|
+
approvals: [],
|
|
757
|
+
pendingDecisions: new Set(),
|
|
758
|
+
catalog: [],
|
|
759
|
+
catalogById: new Map(),
|
|
760
|
+
catalogQ: "",
|
|
761
|
+
refs: [],
|
|
762
|
+
drawer: null, // { type: 'trace', id, events } | { type: 'ref', id }
|
|
763
|
+
lastFocus: null,
|
|
764
|
+
seen: new Set(),
|
|
765
|
+
};
|
|
766
|
+
const evKey = (e) => e.spanId + ":" + e.kind + ":" + e.ts + ":" + (e.decision || "");
|
|
767
|
+
|
|
768
|
+
// ------------------------------------------------------------------ overview / KPIs
|
|
769
|
+
async function loadOverview() {
|
|
770
|
+
try {
|
|
771
|
+
const o = await api("/api/overview");
|
|
772
|
+
S.overview = o;
|
|
773
|
+
renderOverview();
|
|
774
|
+
$("f-updated").textContent = "updated " + clock(new Date().toISOString());
|
|
775
|
+
if (o.approvals !== S.approvals.length && !S.pendingDecisions.size) loadApprovals();
|
|
776
|
+
if (!sseOpen) setConn("warn", "Polling (live stream offline)");
|
|
777
|
+
} catch (e) {
|
|
778
|
+
if (!authBroken) setConn("err", "Offline");
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
function renderOverview() {
|
|
783
|
+
const o = S.overview; if (!o) return;
|
|
784
|
+
$("router-chip").textContent = "router: " + str(o.router);
|
|
785
|
+
$("version").textContent = "v" + str(o.version);
|
|
786
|
+
$("f-session").textContent = shortId(o.session, 12);
|
|
787
|
+
$("f-session").title = str(o.session);
|
|
788
|
+
|
|
789
|
+
const hist = o.history || {}, live = o.live || {};
|
|
790
|
+
$("k-saved").textContent = compact(hist.tokensSaved);
|
|
791
|
+
$("k-saved").title = num(hist.tokensSaved) + " tokens";
|
|
792
|
+
setKids($("k-saved-sub"), "this session ", h("b", { text: "+" + compact(live.tokensSaved) }), " · offloaded ", h("b", { text: bytes(hist.bytesOffloaded) }));
|
|
793
|
+
|
|
794
|
+
const fp = o.footprint || {};
|
|
795
|
+
const pct = fp.directTokens > 0 ? Math.round((1 - fp.mycelTokens / fp.directTokens) * 100) : 0;
|
|
796
|
+
if (fp.tools) setKids($("k-ctx"), compact(fp.directTokens), h("small", { text: " → " }), compact(fp.mycelTokens));
|
|
797
|
+
else setKids($("k-ctx"), h("span", { class: "faint", text: "—" }));
|
|
798
|
+
$("k-ctx").setAttribute("aria-label", num(fp.directTokens) + " tokens direct, " + num(fp.mycelTokens) + " tokens through Mycel");
|
|
799
|
+
const toolsTxt = num(fp.tools) + " tool" + (fp.tools === 1 ? "" : "s");
|
|
800
|
+
if (!fp.tools) setKids($("k-ctx-sub"), "No tools connected yet");
|
|
801
|
+
else if (pct > 0) setKids($("k-ctx-sub"), h("b", { style: "color:var(--accent)", text: "−" + pct + "%" }), " · " + toolsTxt + " behind meta-tools");
|
|
802
|
+
else setKids($("k-ctx-sub"), h("b", { text: "+" + compact(fp.mycelTokens - fp.directTokens) + " overhead" }), " · " + toolsTxt + "; the router pays off as servers grow");
|
|
803
|
+
const max = fp.tools ? Math.max(fp.directTokens || 0, fp.mycelTokens || 0, 1) : Infinity;
|
|
804
|
+
$("k-ctx-bar-direct").style.width = ((fp.directTokens || 0) / max * 100) + "%";
|
|
805
|
+
$("k-ctx-bar-mycel").style.width = ((fp.mycelTokens || 0) / max * 100) + "%";
|
|
806
|
+
$("k-ctx").parentElement.title = "Tool-definition tokens loaded into the model's context: direct MCP (grey) vs through Mycel (green)";
|
|
807
|
+
|
|
808
|
+
$("k-calls").textContent = compact(hist.calls);
|
|
809
|
+
const errRate = hist.calls ? Math.round((hist.errors / Math.max(hist.calls, 1)) * 1000) / 10 : 0;
|
|
810
|
+
setKids($("k-calls-sub"),
|
|
811
|
+
h("b", { style: hist.errors ? "color:var(--red)" : "", text: num(hist.errors) + (hist.errors === 1 ? " error" : " errors") }),
|
|
812
|
+
hist.calls ? " (" + errRate + "%)" : "", " · " + num(hist.runs) + (hist.runs === 1 ? " run" : " runs"));
|
|
813
|
+
|
|
814
|
+
const spent = (o.budget && o.budget.spent && o.budget.spent.day) || 0;
|
|
815
|
+
const limit = o.budget && o.budget.limits && o.budget.limits.perDayUsd;
|
|
816
|
+
$("k-spend").textContent = usd(spent);
|
|
817
|
+
const barWrap = $("k-spend-barwrap");
|
|
818
|
+
if (limit) {
|
|
819
|
+
const p = Math.min(100, (spent / limit) * 100);
|
|
820
|
+
setKids($("k-spend-sub"), "of ", h("b", { text: usd(limit) }), " daily cap · " + Math.round(p) + "%");
|
|
821
|
+
$("k-spend-bar").style.width = p + "%";
|
|
822
|
+
barWrap.className = "bar" + (p >= 100 ? " red" : p >= 80 ? " amber" : "");
|
|
823
|
+
barWrap.setAttribute("aria-valuenow", String(Math.round(p)));
|
|
824
|
+
barWrap.hidden = false;
|
|
825
|
+
} else {
|
|
826
|
+
setKids($("k-spend-sub"), "No daily cap set", o.budget && o.budget.limits && o.budget.limits.perTaskUsd ? " · " + usd(o.budget.limits.perTaskUsd) + "/task" : "");
|
|
827
|
+
barWrap.hidden = true;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
const apv = Number(o.approvals) || 0;
|
|
831
|
+
$("k-apv").textContent = String(apv);
|
|
832
|
+
$("k-apv-btn").classList.toggle("has", apv > 0);
|
|
833
|
+
$("k-apv-sub").textContent = apv ? "Waiting for a human · review" : "Nothing waiting";
|
|
834
|
+
$("k-apv-btn").setAttribute("aria-label", apv + " pending approvals. Go to approvals.");
|
|
835
|
+
|
|
836
|
+
renderServers();
|
|
837
|
+
renderDrift();
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// ------------------------------------------------------------------ drift
|
|
841
|
+
function renderDrift() {
|
|
842
|
+
const slot = $("drift-slot");
|
|
843
|
+
const d = (S.overview && S.overview.drift) || { changed: [] };
|
|
844
|
+
const changed = d.changed || [];
|
|
845
|
+
if (!changed.length) { clear(slot); return; }
|
|
846
|
+
const btn = h("button", { type: "button", class: "btn amber sm" }, "Review & re-pin");
|
|
847
|
+
btn.addEventListener("click", () => openDrift(changed));
|
|
848
|
+
setKids(slot, h("div", { class: "banner", role: "alert" },
|
|
849
|
+
icon("warn", 20),
|
|
850
|
+
h("div", { class: "txt" },
|
|
851
|
+
h("b", { text: changed.length + (changed.length === 1 ? " tool definition changed" : " tool definitions changed") }),
|
|
852
|
+
" since it was pinned. This can indicate a rug pull; changed tools may be blocked until a human re-pins them.",
|
|
853
|
+
h("div", { class: "ids" }, changed.slice(0, 8).map((id) => h("span", { class: "chip amber mono", text: id })), changed.length > 8 ? h("span", { class: "chip ghost", text: "+" + (changed.length - 8) }) : null)),
|
|
854
|
+
btn));
|
|
855
|
+
}
|
|
856
|
+
function openDrift(changed) {
|
|
857
|
+
const d = (S.overview && S.overview.drift) || {};
|
|
858
|
+
const list = h("div", { class: "cards" });
|
|
859
|
+
const checks = [];
|
|
860
|
+
for (const id of changed) {
|
|
861
|
+
const t = S.catalogById.get(id);
|
|
862
|
+
const cb = h("input", { type: "checkbox", checked: true, value: id, id: "pin-" + id.replace(/[^a-z0-9]/gi, "_") });
|
|
863
|
+
checks.push(cb);
|
|
864
|
+
list.append(h("label", { class: "acard", for: cb.id, style: "flex-direction:row;align-items:flex-start;gap:10px;cursor:pointer" }, cb,
|
|
865
|
+
h("div", { style: "min-width:0" }, h("div", { class: "tool mono", text: id }),
|
|
866
|
+
t ? h("div", { class: "reason", text: t.description || "" }) : h("div", { class: "faint", text: "Not in current catalog" }))));
|
|
867
|
+
}
|
|
868
|
+
const accept = h("button", { type: "button", class: "btn amber" }, "Accept selected definitions");
|
|
869
|
+
accept.addEventListener("click", async () => {
|
|
870
|
+
const ids = checks.filter((c) => c.checked).map((c) => c.value);
|
|
871
|
+
if (!ids.length) return toast("Select at least one tool", "err");
|
|
872
|
+
accept.disabled = true;
|
|
873
|
+
try {
|
|
874
|
+
const r = await api("/api/pin/accept", { method: "POST", body: { ids } });
|
|
875
|
+
if (S.overview) S.overview.drift = r.drift;
|
|
876
|
+
renderDrift();
|
|
877
|
+
toast("Re-pinned " + ids.length + " tool" + (ids.length === 1 ? "" : "s"));
|
|
878
|
+
closeDrawer();
|
|
879
|
+
loadCatalog();
|
|
880
|
+
} catch (e) { toast("Re-pin failed: " + e.message, "err"); accept.disabled = false; }
|
|
881
|
+
});
|
|
882
|
+
openDrawer("Manifest drift", "Review changed tool definitions before trusting them again", [
|
|
883
|
+
h("div", { class: "warnbox", style: "margin-bottom:14px", text: "Only accept if you expected these servers to change their tools. Accepting records the new definitions in mycel.lock." }),
|
|
884
|
+
list,
|
|
885
|
+
(d.added && d.added.length) ? h("div", { class: "subhead", text: "Added: " + d.added.length }) : null,
|
|
886
|
+
(d.removed && d.removed.length) ? h("div", { class: "subhead", text: "Removed: " + d.removed.length }) : null,
|
|
887
|
+
h("div", { style: "margin-top:16px;display:flex;justify-content:flex-end" }, accept),
|
|
888
|
+
], { type: "drift" });
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
// ------------------------------------------------------------------ feed
|
|
892
|
+
function feedMatch(e) {
|
|
893
|
+
switch (S.feedFilter) {
|
|
894
|
+
case "call": return e.kind === "call" || e.kind === "job";
|
|
895
|
+
case "run": return e.kind === "run";
|
|
896
|
+
case "guard": return e.kind === "policy" || e.kind === "approval" || e.kind === "drift" || !!(e.decision && e.decision !== "allow");
|
|
897
|
+
case "err": return !e.ok;
|
|
898
|
+
default: return true;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
function feedRow(e, fresh) {
|
|
902
|
+
const failed = !e.ok && e.kind !== "approval";
|
|
903
|
+
const label = e.tool || e.kind;
|
|
904
|
+
const metas = [];
|
|
905
|
+
metas.push(h("span", { text: e.kind }));
|
|
906
|
+
if (e.durationMs !== undefined) metas.push(h("span", { text: ms(e.durationMs) }));
|
|
907
|
+
if (e.tokensSaved) metas.push(h("span", { class: "saved", text: "−" + compact(e.tokensSaved) + " tok" }));
|
|
908
|
+
if (e.costUsd) metas.push(h("span", { text: usd(e.costUsd) }));
|
|
909
|
+
if (e.kind === "search" && e.meta && e.meta.query !== undefined) metas.push(h("span", { text: "“" + str(e.meta.query).slice(0, 60) + "” · " + str(e.meta.hits) + " hits" }));
|
|
910
|
+
if (e.kind === "run" && e.meta && e.meta.toolCalls !== undefined) metas.push(h("span", { text: e.meta.toolCalls + " tool calls" }));
|
|
911
|
+
if (e.agent) metas.push(h("span", { text: "agent " + e.agent }));
|
|
912
|
+
if (e.error) metas.push(h("span", { class: "errtxt", text: e.error, title: e.error }));
|
|
913
|
+
const btn = h("button", { type: "button", class: "row-btn", "aria-label": label + ", " + e.kind + (failed ? ", failed" : "") + ". Open trace." },
|
|
914
|
+
h("span", { class: "kicon " + (failed ? "err" : e.kind) }, icon(failed ? "x" : e.kind)),
|
|
915
|
+
h("span", { style: "min-width:0;display:flex;flex-direction:column;gap:2px" },
|
|
916
|
+
h("span", { class: "main-line" }, h("span", { class: "tool", text: label, title: label }), decisionChip(e.decision), e.tainted ? taintChip() : null),
|
|
917
|
+
h("span", { class: "meta-line" }, metas)),
|
|
918
|
+
h("span", { class: "right" }, h("time", { datetime: e.ts, title: fullTime(e.ts), text: clock(e.ts) })));
|
|
919
|
+
btn.addEventListener("click", () => openTrace(e.traceId, btn));
|
|
920
|
+
return h("li", { class: fresh ? "fresh" : "" }, btn);
|
|
921
|
+
}
|
|
922
|
+
function renderFeed() {
|
|
923
|
+
const ul = $("feed");
|
|
924
|
+
const items = S.feed.filter(feedMatch).slice(0, 150);
|
|
925
|
+
$("feed-count").textContent = S.feed.length ? num(S.feed.length) + (S.feed.length === 1 ? " event" : " events") : "";
|
|
926
|
+
if (!items.length) {
|
|
927
|
+
setKids(ul, h("li", null, S.feed.length
|
|
928
|
+
? emptyState("pulse", "No matching events", "Nothing matches this filter yet.")
|
|
929
|
+
: emptyState("pulse", "Waiting for activity", h("span", null, "Connect a client to Mycel (", code("mycel serve"), ") and tool calls, code-mode runs and policy decisions will stream in here live."))));
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
setKids(ul, items.map((e) => feedRow(e, false)));
|
|
933
|
+
}
|
|
934
|
+
function pushEvent(e, fresh) {
|
|
935
|
+
const k = evKey(e);
|
|
936
|
+
if (S.seen.has(k)) return false;
|
|
937
|
+
S.seen.add(k);
|
|
938
|
+
S.feed.unshift(e);
|
|
939
|
+
if (S.feed.length > 400) S.feed.length = 400;
|
|
940
|
+
if (!fresh) return true;
|
|
941
|
+
const ul = $("feed");
|
|
942
|
+
if (S.paused) { S.pausedBuffer.push(e); updatePauseLabel(); return true; }
|
|
943
|
+
if (!feedMatch(e)) { $("feed-count").textContent = num(S.feed.length) + (S.feed.length === 1 ? " event" : " events"); return true; }
|
|
944
|
+
if (ul.querySelector(".empty")) clear(ul);
|
|
945
|
+
ul.prepend(feedRow(e, true));
|
|
946
|
+
while (ul.children.length > 150) ul.lastChild.remove();
|
|
947
|
+
$("feed-count").textContent = num(S.feed.length) + (S.feed.length === 1 ? " event" : " events");
|
|
948
|
+
return true;
|
|
949
|
+
}
|
|
950
|
+
function updatePauseLabel() {
|
|
951
|
+
const b = $("feed-pause");
|
|
952
|
+
b.textContent = S.paused ? (S.pausedBuffer.length ? "Resume (" + S.pausedBuffer.length + " new)" : "Resume") : "Pause";
|
|
953
|
+
b.setAttribute("aria-pressed", S.paused ? "true" : "false");
|
|
954
|
+
}
|
|
955
|
+
async function seedFeed() {
|
|
956
|
+
// Fill the feed with the most recent traces so a reload isn't empty.
|
|
957
|
+
try {
|
|
958
|
+
const top = S.traces.slice(0, 25);
|
|
959
|
+
const all = await Promise.all(top.map((t) => api("/api/trace/" + encodeURIComponent(t.traceId)).catch(() => [])));
|
|
960
|
+
const evs = all.flat().sort((a, b) => str(a.ts).localeCompare(str(b.ts)));
|
|
961
|
+
for (const e of evs) pushEvent(e, false);
|
|
962
|
+
S.feed.sort((a, b) => str(b.ts).localeCompare(str(a.ts)));
|
|
963
|
+
} catch { /* ignore */ }
|
|
964
|
+
renderFeed();
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// ------------------------------------------------------------------ approvals
|
|
968
|
+
async function loadApprovals() {
|
|
969
|
+
try {
|
|
970
|
+
const list = await api("/api/approvals");
|
|
971
|
+
const next = (list || []).filter((a) => !S.pendingDecisions.has(a.id));
|
|
972
|
+
const sig = (l) => l.map((a) => a.id).sort().join(",");
|
|
973
|
+
const changed = sig(next) !== sig(S.approvals) || !approvalsRendered;
|
|
974
|
+
S.approvals = next;
|
|
975
|
+
if (changed) renderApprovals();
|
|
976
|
+
} catch (e) { /* keep last */ }
|
|
977
|
+
}
|
|
978
|
+
let approvalsRendered = false;
|
|
979
|
+
function renderApprovals() {
|
|
980
|
+
approvalsRendered = true;
|
|
981
|
+
const el = $("apv-list");
|
|
982
|
+
const list = [...S.approvals].sort((a, b) => str(b.createdAt).localeCompare(str(a.createdAt)));
|
|
983
|
+
$("apv-count").textContent = list.length ? String(list.length) + " pending" : "";
|
|
984
|
+
if (!list.length) {
|
|
985
|
+
setKids(el, emptyState("approval", "No pending approvals", "Destructive actions, tainted side effects and approval rules will wait here for a human decision."));
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
keepFocus(el, () => setKids(el, list.map(approvalCard)));
|
|
989
|
+
}
|
|
990
|
+
function approvalCard(a) {
|
|
991
|
+
const t = S.catalogById.get(a.tool);
|
|
992
|
+
const approve = h("button", { type: "button", class: "btn primary sm", "data-fkey": "a:" + a.id + ":y" }, icon("check", 13), "Approve");
|
|
993
|
+
const deny = h("button", { type: "button", class: "btn danger sm", "data-fkey": "a:" + a.id + ":n" }, icon("x", 13), "Deny");
|
|
994
|
+
const card = h("article", { class: "acard", "aria-label": "Approval for " + a.tool },
|
|
995
|
+
h("div", { class: "head" },
|
|
996
|
+
h("span", { class: "tool", text: a.tool }),
|
|
997
|
+
t ? effectChip(t.contract && t.contract.effect) : null,
|
|
998
|
+
t && t.trust === "untrusted" ? h("span", { class: "chip amber", text: "untrusted" }) : null,
|
|
999
|
+
h("span", { class: "when", title: fullTime(a.createdAt), "data-ago": a.createdAt, text: ago(a.createdAt) })),
|
|
1000
|
+
h("div", { class: "reason", text: a.reason }),
|
|
1001
|
+
a.args !== undefined ? h("div", null, h("div", { class: "block-title", text: "Arguments" }), jsonView(a.args, { openDepth: 2 })) : null,
|
|
1002
|
+
h("div", { class: "faint mono", style: "font-size:11px", text: a.id }),
|
|
1003
|
+
h("div", { class: "actions" }, deny, approve));
|
|
1004
|
+
approve.addEventListener("click", () => decide(a, true, card));
|
|
1005
|
+
deny.addEventListener("click", () => decide(a, false, card));
|
|
1006
|
+
return card;
|
|
1007
|
+
}
|
|
1008
|
+
async function decide(a, approve, card) {
|
|
1009
|
+
// Optimistic: remove immediately, restore on failure.
|
|
1010
|
+
S.pendingDecisions.add(a.id);
|
|
1011
|
+
card.classList.add("busy");
|
|
1012
|
+
const prev = S.approvals;
|
|
1013
|
+
S.approvals = S.approvals.filter((x) => x.id !== a.id);
|
|
1014
|
+
if (S.overview) { S.overview.approvals = Math.max(0, (S.overview.approvals || 0) - 1); renderOverview(); }
|
|
1015
|
+
setTimeout(renderApprovals, 120);
|
|
1016
|
+
try {
|
|
1017
|
+
await api("/api/approvals/" + encodeURIComponent(a.id), { method: "POST", body: { approve } });
|
|
1018
|
+
toast((approve ? "Approved " : "Denied ") + a.tool + (approve ? ". The agent can retry with approval " + a.id + "." : "."));
|
|
1019
|
+
} catch (e) {
|
|
1020
|
+
S.approvals = prev;
|
|
1021
|
+
if (S.overview) S.overview.approvals = prev.length;
|
|
1022
|
+
renderApprovals(); renderOverview();
|
|
1023
|
+
toast("Could not " + (approve ? "approve" : "deny") + ": " + e.message, "err");
|
|
1024
|
+
} finally {
|
|
1025
|
+
S.pendingDecisions.delete(a.id);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
// ------------------------------------------------------------------ jobs
|
|
1030
|
+
async function loadJobs() {
|
|
1031
|
+
try {
|
|
1032
|
+
const list = await api("/api/jobs");
|
|
1033
|
+
S.jobs = new Map((list || []).map((j) => [j.id, j]));
|
|
1034
|
+
renderJobs();
|
|
1035
|
+
} catch { /* keep */ }
|
|
1036
|
+
}
|
|
1037
|
+
const loadJobsSoon = debounce(loadJobs, 400);
|
|
1038
|
+
function onJobEvent(v) {
|
|
1039
|
+
const prev = S.jobs.get(v.id);
|
|
1040
|
+
if (!prev) { S.jobs.set(v.id, { ...v, createdAt: new Date().toISOString() }); loadJobsSoon(); }
|
|
1041
|
+
else {
|
|
1042
|
+
const next = { ...prev, ...v };
|
|
1043
|
+
if (["succeeded", "failed", "cancelled", "interrupted"].includes(v.status) && !prev.finishedAt) next.finishedAt = new Date().toISOString();
|
|
1044
|
+
if (v.status === "queued" || v.status === "running") next.finishedAt = undefined;
|
|
1045
|
+
S.jobs.set(v.id, next);
|
|
1046
|
+
}
|
|
1047
|
+
renderJobs();
|
|
1048
|
+
}
|
|
1049
|
+
const ACTIVE = (s) => s === "running" || s === "queued";
|
|
1050
|
+
const jobEls = new Map(); // id -> { el, sig } (keyed rows: progress ticks patch in place, focus survives)
|
|
1051
|
+
function renderJobs() {
|
|
1052
|
+
const el = $("jobs-list");
|
|
1053
|
+
const list = [...S.jobs.values()].sort((a, b) => (ACTIVE(b.status) - ACTIVE(a.status)) || str(b.createdAt).localeCompare(str(a.createdAt))).slice(0, 30);
|
|
1054
|
+
const running = list.filter((j) => j.status === "running").length, queued = list.filter((j) => j.status === "queued").length;
|
|
1055
|
+
$("jobs-count").textContent = S.jobs.size ? (running + " running" + (queued ? " · " + queued + " queued" : "")) : "";
|
|
1056
|
+
if (!list.length) {
|
|
1057
|
+
jobEls.clear();
|
|
1058
|
+
setKids(el, emptyState("job", "No jobs yet", "Long-running tools (video, renders, training) become jobs with progress, cancel and retry."));
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
if (el.querySelector(".empty")) clear(el);
|
|
1062
|
+
const keep = new Set();
|
|
1063
|
+
list.forEach((j, i) => {
|
|
1064
|
+
const sig = j.status + "|" + (j.result !== undefined) + "|" + str(j.error) + "|" + str(j.usedTool || j.tool);
|
|
1065
|
+
let rec = jobEls.get(j.id);
|
|
1066
|
+
if (!rec || rec.sig !== sig) {
|
|
1067
|
+
const row = jobRow(j);
|
|
1068
|
+
const hadFocus = rec && rec.el.contains(document.activeElement);
|
|
1069
|
+
if (rec) rec.el.replaceWith(row);
|
|
1070
|
+
rec = { el: row, sig };
|
|
1071
|
+
jobEls.set(j.id, rec);
|
|
1072
|
+
if (hadFocus) (row.querySelector("button") || row).focus?.();
|
|
1073
|
+
} else rec.el._patch(j);
|
|
1074
|
+
keep.add(j.id);
|
|
1075
|
+
if (el.children[i] !== rec.el) el.insertBefore(rec.el, el.children[i] || null);
|
|
1076
|
+
});
|
|
1077
|
+
for (const [id, rec] of jobEls) if (!keep.has(id)) { rec.el.remove(); jobEls.delete(id); }
|
|
1078
|
+
for (const x of [...el.children]) if (![...jobEls.values()].some((r) => r.el === x)) x.remove();
|
|
1079
|
+
}
|
|
1080
|
+
function jobRow(j) {
|
|
1081
|
+
const tool = j.usedTool || j.tool || "job";
|
|
1082
|
+
const fill = h("i");
|
|
1083
|
+
const bar = h("div", { role: "progressbar", "aria-label": "Progress of " + tool, "aria-valuemin": "0", "aria-valuemax": "100" }, fill);
|
|
1084
|
+
const infoEl = h("div", { class: "info" });
|
|
1085
|
+
const acts = h("div", { class: "acts" });
|
|
1086
|
+
if (ACTIVE(j.status)) {
|
|
1087
|
+
const c = h("button", { type: "button", class: "btn danger sm", "aria-label": "Cancel job " + j.id }, "Cancel");
|
|
1088
|
+
c.addEventListener("click", () => jobAction(j, "cancel", c));
|
|
1089
|
+
acts.append(c);
|
|
1090
|
+
}
|
|
1091
|
+
if (["failed", "interrupted", "cancelled"].includes(j.status)) {
|
|
1092
|
+
const r = h("button", { type: "button", class: "btn sm", "aria-label": "Retry job " + j.id }, "Retry");
|
|
1093
|
+
r.addEventListener("click", () => jobAction(j, "retry", r));
|
|
1094
|
+
acts.append(r);
|
|
1095
|
+
}
|
|
1096
|
+
const row = h("div", { class: "job", "data-job": j.id },
|
|
1097
|
+
h("div", { class: "head" }, jobChip(j.status), h("span", { class: "tool", text: tool, title: tool }), acts),
|
|
1098
|
+
bar,
|
|
1099
|
+
infoEl,
|
|
1100
|
+
j.error ? h("div", { class: "err", text: j.error }) : null);
|
|
1101
|
+
row._patch = (j) => {
|
|
1102
|
+
const hasTotal = typeof j.total === "number" && j.total > 0;
|
|
1103
|
+
const p = hasTotal ? Math.min(100, ((j.progress || 0) / j.total) * 100) : (j.status === "succeeded" ? 100 : 0);
|
|
1104
|
+
bar.className = "bar" + (j.status === "failed" ? " red" : j.status === "interrupted" || j.status === "cancelled" ? " amber" : "") + (j.status === "running" && !hasTotal ? " indet" : "");
|
|
1105
|
+
bar.setAttribute("aria-valuenow", String(Math.round(p)));
|
|
1106
|
+
fill.style.width = p + "%";
|
|
1107
|
+
const elapsed = j.createdAt ? ((j.finishedAt ? Date.parse(j.finishedAt) : Date.now()) - Date.parse(j.createdAt)) : NaN;
|
|
1108
|
+
setKids(infoEl,
|
|
1109
|
+
h("span", { class: "mono", style: "font-size:11px", text: j.id }),
|
|
1110
|
+
hasTotal ? h("span", { text: num(j.progress || 0) + " / " + num(j.total) }) : null,
|
|
1111
|
+
j.message ? h("span", { text: j.message }) : null,
|
|
1112
|
+
!isNaN(elapsed) ? h("span", { text: ms(elapsed) }) : null,
|
|
1113
|
+
j.costUsd ? h("span", { text: usd(j.costUsd) }) : null,
|
|
1114
|
+
j.attempts > 1 ? h("span", { text: j.attempts + " attempts" }) : null);
|
|
1115
|
+
};
|
|
1116
|
+
row._patch(j);
|
|
1117
|
+
if (j.status === "succeeded" && j.result !== undefined) {
|
|
1118
|
+
const det = h("details", null, h("summary", { class: "faint", style: "cursor:pointer;font-size:12px", text: "Result" }));
|
|
1119
|
+
let done = false;
|
|
1120
|
+
det.addEventListener("toggle", () => { if (det.open && !done) { done = true; det.append(valueBlock("", j.result)); } });
|
|
1121
|
+
row.append(det);
|
|
1122
|
+
}
|
|
1123
|
+
return row;
|
|
1124
|
+
}
|
|
1125
|
+
async function jobAction(j, action, btn) {
|
|
1126
|
+
// Not `disabled`: that would drop keyboard focus. The row is replaced optimistically and focus moves to its new action.
|
|
1127
|
+
if (btn.getAttribute("aria-busy") === "true") return;
|
|
1128
|
+
btn.setAttribute("aria-busy", "true");
|
|
1129
|
+
const prev = S.jobs.get(j.id);
|
|
1130
|
+
if (action === "cancel") S.jobs.set(j.id, { ...prev, status: "cancelled", finishedAt: new Date().toISOString() });
|
|
1131
|
+
else S.jobs.set(j.id, { ...prev, status: "queued", error: undefined, finishedAt: undefined, progress: 0 });
|
|
1132
|
+
renderJobs();
|
|
1133
|
+
try {
|
|
1134
|
+
const v = await api("/api/jobs/" + encodeURIComponent(j.id) + "/" + action, { method: "POST" });
|
|
1135
|
+
S.jobs.set(j.id, { ...S.jobs.get(j.id), ...v });
|
|
1136
|
+
renderJobs();
|
|
1137
|
+
toast((action === "cancel" ? "Cancelled " : "Retrying ") + (j.usedTool || j.tool || j.id));
|
|
1138
|
+
} catch (e) {
|
|
1139
|
+
S.jobs.set(j.id, prev); renderJobs();
|
|
1140
|
+
toast("Could not " + action + " job: " + e.message, "err");
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
// ------------------------------------------------------------------ traces
|
|
1145
|
+
async function loadTraces() {
|
|
1146
|
+
try {
|
|
1147
|
+
const next = (await api("/api/traces?limit=50")) || [];
|
|
1148
|
+
if (JSON.stringify(next) === JSON.stringify(S.traces) && $("traces-body").firstChild) return;
|
|
1149
|
+
S.traces = next;
|
|
1150
|
+
renderTraces();
|
|
1151
|
+
} catch { /* keep */ }
|
|
1152
|
+
}
|
|
1153
|
+
const loadTracesSoon = debounce(loadTraces, 1500);
|
|
1154
|
+
function renderTraces() {
|
|
1155
|
+
const el = $("traces-body");
|
|
1156
|
+
$("traces-count").textContent = S.traces.length ? num(S.traces.length) : "";
|
|
1157
|
+
if (!S.traces.length) {
|
|
1158
|
+
setKids(el, emptyState("pulse", "No traces recorded", h("span", null, "Every task is traced by the flight recorder. Replay one with ", code("mycel replay <traceId>"), ".")));
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
const shown = S.tracesAll ? S.traces : S.traces.slice(0, 15);
|
|
1162
|
+
const rows = shown.map((t) => {
|
|
1163
|
+
const open = h("button", { type: "button", class: "linkbtn mono", text: t.title, title: "Open trace " + t.traceId, "data-fkey": "t:" + t.traceId });
|
|
1164
|
+
const tr = h("tr", { class: "click" },
|
|
1165
|
+
h("td", { class: "ell" }, open),
|
|
1166
|
+
h("td", { class: "muted", title: fullTime(t.start), "data-ago": t.start, text: ago(t.start) }),
|
|
1167
|
+
h("td", { class: "muted", text: t.agent || "—" }),
|
|
1168
|
+
h("td", { class: "num", text: num(t.steps) }),
|
|
1169
|
+
h("td", { class: "num", style: t.errors ? "color:var(--red)" : "color:var(--faint)", text: num(t.errors) }),
|
|
1170
|
+
h("td", { class: "num", style: t.tokensSaved ? "color:var(--accent)" : "color:var(--faint)", text: t.tokensSaved ? compact(t.tokensSaved) : "—" }),
|
|
1171
|
+
h("td", { class: "num", text: t.costUsd ? usd(t.costUsd) : "—" }),
|
|
1172
|
+
h("td", { class: "mono faint", text: shortId(t.traceId, 10) }));
|
|
1173
|
+
const go = () => openTrace(t.traceId, open);
|
|
1174
|
+
open.addEventListener("click", (ev) => { ev.stopPropagation(); go(); });
|
|
1175
|
+
tr.addEventListener("click", go);
|
|
1176
|
+
return tr;
|
|
1177
|
+
});
|
|
1178
|
+
keepFocus(el, () => setKids(el, h("div", { class: "tbl-wrap" }, h("table", { class: "tbl" },
|
|
1179
|
+
h("thead", null, h("tr", null,
|
|
1180
|
+
h("th", { scope: "col", text: "Task" }), h("th", { scope: "col", text: "Started" }), h("th", { scope: "col", text: "Agent" }),
|
|
1181
|
+
h("th", { scope: "col", class: "num", text: "Steps" }), h("th", { scope: "col", class: "num", text: "Errors" }),
|
|
1182
|
+
h("th", { scope: "col", class: "num", text: "Saved" }), h("th", { scope: "col", class: "num", text: "Cost" }), h("th", { scope: "col", text: "Trace" }))),
|
|
1183
|
+
h("tbody", null, rows))),
|
|
1184
|
+
S.traces.length > 15 ? h("div", { style: "padding:10px 16px;border-top:1px solid var(--line)" },
|
|
1185
|
+
(() => { const b = h("button", { type: "button", class: "btn ghost sm", "data-fkey": "traces-more", text: S.tracesAll ? "Show fewer" : "Show all " + S.traces.length }); b.addEventListener("click", () => { S.tracesAll = !S.tracesAll; renderTraces(); }); return b; })()) : null));
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
async function openTrace(traceId, opener) {
|
|
1189
|
+
S.lastFocus = opener || document.activeElement;
|
|
1190
|
+
openDrawer(shortId(traceId, 16), "Loading trace…", [h("div", { class: "empty" }, h("span", { text: "Loading…" }))], { type: "trace", id: traceId, events: [] });
|
|
1191
|
+
try {
|
|
1192
|
+
const evs = (await api("/api/trace/" + encodeURIComponent(traceId))) || [];
|
|
1193
|
+
if (!S.drawer || S.drawer.id !== traceId) return;
|
|
1194
|
+
S.drawer.events = evs;
|
|
1195
|
+
renderTraceDrawer();
|
|
1196
|
+
} catch (e) {
|
|
1197
|
+
setKids($("drawer-body"), emptyState("warn", "Could not load trace", e.message));
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
function buildTree(evs) {
|
|
1202
|
+
const items = evs.map((e, i) => {
|
|
1203
|
+
const end = Date.parse(e.ts);
|
|
1204
|
+
const dur = Number(e.durationMs) || 0;
|
|
1205
|
+
return { e, i, end, start: end - dur, dur, children: [] };
|
|
1206
|
+
});
|
|
1207
|
+
// Events in the same span (e.g. approval + call) inherit a parent from their siblings.
|
|
1208
|
+
const parentOfSpan = new Map();
|
|
1209
|
+
for (const it of items) if (it.e.parentSpanId) parentOfSpan.set(it.e.spanId, it.e.parentSpanId);
|
|
1210
|
+
const owner = new Map(); // spanId -> item that owns children (prefer run / longest)
|
|
1211
|
+
for (const it of items) {
|
|
1212
|
+
const cur = owner.get(it.e.spanId);
|
|
1213
|
+
if (!cur || it.e.kind === "run" || (cur.e.kind !== "run" && it.dur > cur.dur)) owner.set(it.e.spanId, it);
|
|
1214
|
+
}
|
|
1215
|
+
const roots = [];
|
|
1216
|
+
for (const it of items) {
|
|
1217
|
+
const pid = it.e.parentSpanId || parentOfSpan.get(it.e.spanId);
|
|
1218
|
+
const parent = pid && pid !== it.e.spanId ? owner.get(pid) : null;
|
|
1219
|
+
if (parent && parent !== it) parent.children.push(it); else roots.push(it);
|
|
1220
|
+
}
|
|
1221
|
+
const byStart = (a, b) => (a.start - b.start) || (a.i - b.i);
|
|
1222
|
+
const out = []; const seen = new Set();
|
|
1223
|
+
const walk = (list, depth) => {
|
|
1224
|
+
for (const it of list.sort(byStart)) {
|
|
1225
|
+
if (seen.has(it)) continue; seen.add(it);
|
|
1226
|
+
out.push({ ...it, depth });
|
|
1227
|
+
walk(it.children, depth + 1);
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
walk(roots, 0);
|
|
1231
|
+
return out;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
function renderTraceDrawer() {
|
|
1235
|
+
const d = S.drawer; if (!d || d.type !== "trace") return;
|
|
1236
|
+
const evs = d.events;
|
|
1237
|
+
const body = $("drawer-body");
|
|
1238
|
+
const openSet = new Set([...body.querySelectorAll(".wf-btn[aria-expanded=true]")].map((b) => b.dataset.key));
|
|
1239
|
+
const scroll = body.scrollTop;
|
|
1240
|
+
if (!evs.length) { setKids(body, emptyState("pulse", "Empty trace", "No events were recorded for this trace.")); return; }
|
|
1241
|
+
const rows = buildTree(evs);
|
|
1242
|
+
const t0 = Math.min(...rows.map((r) => r.start)), t1 = Math.max(...rows.map((r) => r.end));
|
|
1243
|
+
const span = Math.max(1, t1 - t0);
|
|
1244
|
+
const root = rows[0].e;
|
|
1245
|
+
const title = root.kind === "run" ? "Code-mode run" : root.kind === "session" ? "Session start" : (root.tool || (evs.find((e) => e.tool) || root).tool || root.kind);
|
|
1246
|
+
$("drawer-title").textContent = title;
|
|
1247
|
+
$("drawer-sub").textContent = d.id + " · " + fullTime(evs[0].ts);
|
|
1248
|
+
const sum = (k) => evs.reduce((a, e) => a + (Number(e[k]) || 0), 0);
|
|
1249
|
+
const errors = evs.filter((e) => !e.ok && e.kind !== "approval").length;
|
|
1250
|
+
const tainted = evs.some((e) => e.tainted);
|
|
1251
|
+
const statBox = (l, v, style) => h("div", { class: "stat-box" }, h("div", { class: "l", text: l }), h("div", { class: "v", style, text: v }));
|
|
1252
|
+
const stats = h("div", { class: "stats-row" },
|
|
1253
|
+
statBox("Steps", num(evs.length)), statBox("Wall time", ms(span)), statBox("Cost", usd(sum("costUsd"))),
|
|
1254
|
+
statBox("Tokens saved", compact(sum("tokensSaved")), "color:var(--accent)"), statBox("Errors", num(errors), errors ? "color:var(--red)" : ""));
|
|
1255
|
+
const ticks = h("div", { class: "ticks" }, [0, .25, .5, .75, 1].map((f) => h("span", { text: f === 0 ? "0" : span < 20 ? +(span * f).toFixed(span * f < 1 ? 2 : 1) + "ms" : ms(span * f) })));
|
|
1256
|
+
const wf = h("div", { class: "wf", role: "list", "aria-label": "Trace timeline" },
|
|
1257
|
+
h("div", { class: "wf-axis", "aria-hidden": "true" }, h("span", { text: "Step" }), ticks, h("span", { style: "text-align:right", text: "Duration" })));
|
|
1258
|
+
rows.forEach((r, idx) => {
|
|
1259
|
+
const e = r.e;
|
|
1260
|
+
const failed = !e.ok && e.kind !== "approval";
|
|
1261
|
+
const key = e.spanId + ":" + idx;
|
|
1262
|
+
const left = ((r.start - t0) / span) * 100;
|
|
1263
|
+
const width = (r.dur / span) * 100;
|
|
1264
|
+
const guard = e.kind === "policy" || e.kind === "approval" || e.kind === "drift";
|
|
1265
|
+
const barCls = "wf-bar " + (failed ? "err" : guard ? "amber" : e.kind === "run" ? "run" : e.kind === "job" ? "job" : "") + (r.dur === 0 ? " point" : "");
|
|
1266
|
+
const btn = h("button", { type: "button", class: "wf-btn", "aria-expanded": "false", "data-key": key },
|
|
1267
|
+
h("span", { class: "wf-label", style: "padding-left:" + (r.depth * 16) + "px" },
|
|
1268
|
+
h("span", { class: "caret", "aria-hidden": "true", text: "›" }),
|
|
1269
|
+
h("span", { class: "kicon " + (failed ? "err" : e.kind) }, icon(failed ? "x" : e.kind, 12)),
|
|
1270
|
+
h("span", { class: "t", text: e.tool || e.kind, title: (e.tool || e.kind) + " (" + e.kind + ")" }),
|
|
1271
|
+
decisionChip(e.decision), e.tainted ? taintChip() : null),
|
|
1272
|
+
h("span", { class: "wf-track", "aria-hidden": "true" }, h("span", { class: barCls, style: "left:" + left.toFixed(3) + "%;width:" + Math.max(width, 0).toFixed(3) + "%" })),
|
|
1273
|
+
h("span", { class: "wf-dur", text: e.durationMs !== undefined ? ms(e.durationMs) : "·" }));
|
|
1274
|
+
const row = h("div", { class: "wf-row", role: "listitem" }, btn);
|
|
1275
|
+
let detail = null;
|
|
1276
|
+
const toggle = () => {
|
|
1277
|
+
const open = btn.getAttribute("aria-expanded") !== "true";
|
|
1278
|
+
btn.setAttribute("aria-expanded", open ? "true" : "false");
|
|
1279
|
+
if (open) { detail = eventDetail(e); row.append(detail); } else if (detail) { detail.remove(); detail = null; }
|
|
1280
|
+
};
|
|
1281
|
+
btn.addEventListener("click", toggle);
|
|
1282
|
+
wf.append(row);
|
|
1283
|
+
if (openSet.has(key)) toggle();
|
|
1284
|
+
});
|
|
1285
|
+
setKids(body, stats,
|
|
1286
|
+
tainted ? h("div", { class: "warnbox", style: "margin-bottom:12px", text: "This trace touched untrusted content. Tainted steps are marked." }) : null,
|
|
1287
|
+
wf,
|
|
1288
|
+
h("div", { class: "faint", style: "font-size:11.5px;margin-top:8px", text: "Click a step for arguments, result and metadata. Indentation shows parent/child spans (e.g. calls inside a code-mode run)." }));
|
|
1289
|
+
body.scrollTop = scroll;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
function eventDetail(e) {
|
|
1293
|
+
const kv = (k, v) => (v === undefined || v === null || v === "" ? null : h("div", null, h("div", { class: "k", text: k }), h("div", { class: "v", text: String(v) })));
|
|
1294
|
+
const meta = e.meta && typeof e.meta === "object" ? { ...e.meta } : null;
|
|
1295
|
+
const scriptCode = meta && typeof meta.code === "string" ? meta.code : null;
|
|
1296
|
+
if (scriptCode) delete meta.code;
|
|
1297
|
+
return h("div", { class: "wf-detail" },
|
|
1298
|
+
h("div", { class: "kvs" },
|
|
1299
|
+
kv("Kind", e.kind), kv("Status", e.ok ? "ok" : "failed"), kv("Server", e.server), kv("Time", fullTime(e.ts)),
|
|
1300
|
+
kv("Duration", e.durationMs !== undefined ? ms(e.durationMs) : undefined), kv("Decision", e.decision),
|
|
1301
|
+
kv("Cost", e.costUsd ? usd(e.costUsd) : undefined), kv("Tokens to model", e.tokensToModel !== undefined ? num(e.tokensToModel) : undefined),
|
|
1302
|
+
kv("Tokens saved", e.tokensSaved ? num(e.tokensSaved) : undefined), kv("Bytes offloaded", e.bytesOffloaded ? bytes(e.bytesOffloaded) : undefined),
|
|
1303
|
+
kv("Tainted", e.tainted ? "yes" : undefined), kv("Agent", e.agent), kv("Span", e.spanId), kv("Parent span", e.parentSpanId)),
|
|
1304
|
+
e.error ? h("div", null, h("div", { class: "block-title", text: "Error" }), h("pre", { class: "code err", text: e.error })) : null,
|
|
1305
|
+
scriptCode ? h("div", null, h("div", { class: "block-title", text: "Script" }), h("pre", { class: "code", text: scriptCode })) : null,
|
|
1306
|
+
valueBlock("Arguments", e.args),
|
|
1307
|
+
valueBlock("Result", e.result),
|
|
1308
|
+
meta && Object.keys(meta).length ? valueBlock("Meta", meta) : null);
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
// ------------------------------------------------------------------ servers & catalog
|
|
1312
|
+
function renderServers() {
|
|
1313
|
+
const o = S.overview; if (!o) return;
|
|
1314
|
+
const el = $("servers-list");
|
|
1315
|
+
const servers = o.servers || [];
|
|
1316
|
+
$("servers-count").textContent = servers.length ? servers.length + " server" + (servers.length === 1 ? "" : "s") + " · " + num(servers.reduce((a, s) => a + (s.tools || 0), 0)) + " tools" : "";
|
|
1317
|
+
if (!servers.length) {
|
|
1318
|
+
setKids(el, h("div", { style: "grid-column:1/-1" }, emptyState("server", "No servers connected", h("span", null, "Import your existing MCP setup with ", code("mycel init"), ", or add servers to ", code("mycel.yaml"), "."))));
|
|
1319
|
+
} else {
|
|
1320
|
+
const DOT = { ready: "live", connecting: "warn", error: "err", disabled: "" };
|
|
1321
|
+
setKids(el, servers.map((s) => h("div", { class: "scard" },
|
|
1322
|
+
h("div", { class: "head" }, h("span", { class: "dot " + (DOT[s.status] ?? ""), "aria-hidden": "true" }), h("span", { class: "name", text: s.name, title: s.name }),
|
|
1323
|
+
h("span", { style: "margin-left:auto" }, s.trust === "untrusted" ? h("span", { class: "chip amber", title: "Output is labelled as untrusted data", text: "untrusted" }) : h("span", { class: "chip ghost", text: "trusted" }))),
|
|
1324
|
+
h("div", { class: "stat" }, h("span", { text: str(s.status) }), h("span", { text: num(s.tools) + " tools" })),
|
|
1325
|
+
s.error ? h("div", { class: "err", text: s.error }) : null)));
|
|
1326
|
+
}
|
|
1327
|
+
const models = o.models || [], peers = o.peers || [];
|
|
1328
|
+
const mp = $("models-peers");
|
|
1329
|
+
if (models.length || peers.length) {
|
|
1330
|
+
setKids(mp,
|
|
1331
|
+
models.length ? [h("div", { class: "subhead", text: "Model router" }), h("div", { class: "kv-chips" }, models.map((m) => h("span", { class: "chip", title: str(m.provider) }, h("b", { style: "color:var(--accent);font-weight:600", text: str(m.tier) }), h("span", { class: "mono", text: str(m.model) }))))] : null,
|
|
1332
|
+
peers.length ? [h("div", { class: "subhead", text: "A2A peers" }), h("div", { class: "kv-chips" }, peers.map((p) => h("span", { class: "chip violet mono", text: str(p) })))] : null);
|
|
1333
|
+
} else clear(mp);
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
let catalogSeq = 0;
|
|
1337
|
+
async function loadCatalog() {
|
|
1338
|
+
const q = S.catalogQ.trim();
|
|
1339
|
+
const seq = ++catalogSeq;
|
|
1340
|
+
try {
|
|
1341
|
+
const list = (await api("/api/catalog" + (q ? "?q=" + encodeURIComponent(q) : ""))) || [];
|
|
1342
|
+
if (seq !== catalogSeq) return;
|
|
1343
|
+
S.catalog = list;
|
|
1344
|
+
if (!q) { S.catalogById = new Map(list.map((t) => [t.id, t])); renderApprovals(); }
|
|
1345
|
+
renderCatalog();
|
|
1346
|
+
} catch (e) {
|
|
1347
|
+
setKids($("catalog-body"), emptyState("warn", "Catalog unavailable", e.message));
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
function renderCatalog() {
|
|
1351
|
+
const el = $("catalog-body");
|
|
1352
|
+
const q = S.catalogQ.trim();
|
|
1353
|
+
$("catalog-count").textContent = q ? "· " + S.catalog.length + " matches" : S.catalog.length ? "· " + S.catalog.length + " tools" : "";
|
|
1354
|
+
if (!S.catalog.length) {
|
|
1355
|
+
setKids(el, q ? emptyState("search", "No tools match “" + q + "”", "Search runs BM25 over tool names and descriptions, the same as mycel_search.")
|
|
1356
|
+
: emptyState("search", "Catalog is empty", "Tools from connected servers appear here with their inferred contracts."));
|
|
1357
|
+
return;
|
|
1358
|
+
}
|
|
1359
|
+
const rows = S.catalog.map((t) => {
|
|
1360
|
+
const c = t.contract || {};
|
|
1361
|
+
return h("tr", null,
|
|
1362
|
+
h("td", null, h("div", { class: "mono", text: t.id }), h("div", { class: "faint ell", style: "font-size:12px;max-width:460px", title: t.description || "", text: t.description || "—" })),
|
|
1363
|
+
h("td", null, h("div", { class: "kv-chips" }, effectChip(c.effect),
|
|
1364
|
+
c.async ? h("span", { class: "chip blue", text: "async" }) : null,
|
|
1365
|
+
c.idempotent ? h("span", { class: "chip ghost", text: "idempotent" }) : null,
|
|
1366
|
+
t.trust === "untrusted" ? h("span", { class: "chip amber", text: "untrusted" }) : null)),
|
|
1367
|
+
h("td", { class: "num", text: c.costUsd ? usd(c.costUsd) : "—" }),
|
|
1368
|
+
h("td", { class: "num", text: c.latencyMs ? ms(c.latencyMs) : "—" }),
|
|
1369
|
+
h("td", { class: "muted", style: "font-size:12px", text: str(c.source) || "—" }));
|
|
1370
|
+
});
|
|
1371
|
+
setKids(el, h("table", { class: "tbl" },
|
|
1372
|
+
h("thead", null, h("tr", null, h("th", { scope: "col", text: "Tool" }), h("th", { scope: "col", text: "Contract" }), h("th", { scope: "col", class: "num", text: "Cost" }), h("th", { scope: "col", class: "num", text: "Latency" }), h("th", { scope: "col", text: "Source" }))),
|
|
1373
|
+
h("tbody", null, rows)));
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// ------------------------------------------------------------------ refs
|
|
1377
|
+
async function loadRefs() {
|
|
1378
|
+
try {
|
|
1379
|
+
const next = (await api("/api/refs")) || [];
|
|
1380
|
+
if (JSON.stringify(next) === JSON.stringify(S.refs) && $("refs-body").firstChild) return;
|
|
1381
|
+
S.refs = next; renderRefs();
|
|
1382
|
+
} catch { /* keep */ }
|
|
1383
|
+
}
|
|
1384
|
+
const loadRefsSoon = debounce(loadRefs, 2500);
|
|
1385
|
+
function refThumb(r) {
|
|
1386
|
+
const url = refUrl(r.id);
|
|
1387
|
+
if (url && str(r.mime).startsWith("image/")) return h("img", { class: "thumb", src: url, alt: "", loading: "lazy" });
|
|
1388
|
+
const kf = r.digest && r.digest.kind === "video" && Array.isArray(r.digest.keyframes) ? refUrl(r.digest.keyframes[0]) : null;
|
|
1389
|
+
if (kf) return h("img", { class: "thumb", src: kf, alt: "", loading: "lazy" });
|
|
1390
|
+
return h("span", { class: "thumb ph", "aria-hidden": "true" }, icon(str(r.mime).startsWith("video/") ? "image" : "file"));
|
|
1391
|
+
}
|
|
1392
|
+
function renderRefs() {
|
|
1393
|
+
const el = $("refs-body");
|
|
1394
|
+
const list = [...S.refs].sort((a, b) => str(b.createdAt).localeCompare(str(a.createdAt)));
|
|
1395
|
+
$("refs-count").textContent = list.length ? num(list.length) + " · " + bytes(list.reduce((a, r) => a + (r.size || 0), 0)) : "";
|
|
1396
|
+
if (!list.length) {
|
|
1397
|
+
setKids(el, emptyState("ref", "No refs stored", "Large or binary tool results are stored here content-addressed and replaced with a compact digest for the model."));
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
const rows = list.map((r) => {
|
|
1401
|
+
const open = h("button", { type: "button", class: "linkbtn mono", text: r.name || shortId(str(r.id).replace("ref://", ""), 12), title: "Preview " + r.id, "data-fkey": "r:" + r.id });
|
|
1402
|
+
const tr = h("tr", { class: "click" },
|
|
1403
|
+
h("td", { style: "width:44px" }, refThumb(r)),
|
|
1404
|
+
h("td", { class: "ell" }, open, h("div", { class: "faint mono", style: "font-size:11px", text: r.id })),
|
|
1405
|
+
h("td", { class: "mono muted", style: "font-size:12px", text: str(r.mime) }),
|
|
1406
|
+
h("td", { class: "num", text: bytes(r.size) }),
|
|
1407
|
+
h("td", null, r.taint === "untrusted" ? h("span", { class: "chip amber", text: "untrusted" }) : h("span", { class: "chip ghost", text: "trusted" })),
|
|
1408
|
+
h("td", { class: "muted mono", style: "font-size:12px", text: r.source ? [r.source.server, r.source.tool].filter(Boolean).join(".") || str(r.source.agent) : "—" }),
|
|
1409
|
+
h("td", { class: "muted", title: fullTime(r.createdAt), "data-ago": r.createdAt, text: ago(r.createdAt) }));
|
|
1410
|
+
const go = () => openRef(r, open);
|
|
1411
|
+
open.addEventListener("click", (ev) => { ev.stopPropagation(); go(); });
|
|
1412
|
+
tr.addEventListener("click", go);
|
|
1413
|
+
return tr;
|
|
1414
|
+
});
|
|
1415
|
+
keepFocus(el, () => setKids(el, h("table", { class: "tbl" },
|
|
1416
|
+
h("thead", null, h("tr", null, h("th", { scope: "col" }, h("span", { class: "sr-only", text: "Preview" })), h("th", { scope: "col", text: "Ref" }), h("th", { scope: "col", text: "Type" }), h("th", { scope: "col", class: "num", text: "Size" }), h("th", { scope: "col", text: "Taint" }), h("th", { scope: "col", text: "Source" }), h("th", { scope: "col", text: "Created" }))),
|
|
1417
|
+
h("tbody", null, rows))));
|
|
1418
|
+
}
|
|
1419
|
+
function openRef(r, opener) {
|
|
1420
|
+
S.lastFocus = opener || document.activeElement;
|
|
1421
|
+
const url = refUrl(r.id);
|
|
1422
|
+
const mime = str(r.mime);
|
|
1423
|
+
const dg = r.digest || {};
|
|
1424
|
+
const parts = [];
|
|
1425
|
+
parts.push(h("div", { class: "kvs", style: "margin-bottom:14px" },
|
|
1426
|
+
...[["Type", mime], ["Size", bytes(r.size)], ["Taint", r.taint], ["Created", fullTime(r.createdAt)], ["Source", r.source ? [r.source.server, r.source.tool, r.source.agent].filter(Boolean).join(" · ") : "—"], ["Digest", dg.kind], ["SHA-256", r.hash]]
|
|
1427
|
+
.filter(([, v]) => v).map(([k, v]) => h("div", null, h("div", { class: "k", text: k }), h("div", { class: "v", text: String(v) })))));
|
|
1428
|
+
if (r.taint === "untrusted") parts.push(h("div", { class: "warnbox", style: "margin-bottom:12px", text: "Untrusted content. Text is rendered inert; media is served with a sandbox CSP." }));
|
|
1429
|
+
if (url && mime.startsWith("image/")) {
|
|
1430
|
+
const img = h("img", { class: "preview-media", src: url, alt: "Preview of " + (r.name || r.id) });
|
|
1431
|
+
img.addEventListener("load", () => { if (img.naturalWidth < 96) { img.style.width = "160px"; img.style.imageRendering = "pixelated"; } });
|
|
1432
|
+
parts.push(img);
|
|
1433
|
+
}
|
|
1434
|
+
else if (url && mime.startsWith("video/")) parts.push(h("video", { class: "preview-media", src: url, controls: true, preload: "metadata" }));
|
|
1435
|
+
else if (url && mime.startsWith("audio/")) parts.push(h("audio", { src: url, controls: true, style: "width:100%" }));
|
|
1436
|
+
if (dg.kind === "video" && Array.isArray(dg.keyframes) && dg.keyframes.length) {
|
|
1437
|
+
parts.push(h("div", { class: "subhead", text: "Keyframes" }), h("div", { class: "keyframes" }, dg.keyframes.map((k) => refUrl(k)).filter(Boolean).map((u, i) => h("img", { src: u, alt: "Keyframe " + (i + 1), loading: "lazy" }))));
|
|
1438
|
+
}
|
|
1439
|
+
parts.push(h("div", { class: "subhead", text: "Digest (what the model sees)" }));
|
|
1440
|
+
if (dg.kind === "table" && Array.isArray(dg.columns)) {
|
|
1441
|
+
parts.push(h("div", { class: "faint", style: "font-size:12px;margin-bottom:6px", text: num(dg.rows) + " rows · " + dg.columns.length + " columns" }));
|
|
1442
|
+
parts.push(h("div", { class: "tbl-wrap panel", style: "box-shadow:none" }, h("table", { class: "tbl" },
|
|
1443
|
+
h("thead", null, h("tr", null, dg.columns.map((c) => h("th", { scope: "col", text: str(c) })))),
|
|
1444
|
+
h("tbody", null, (dg.sample || []).map((row) => h("tr", null, (row || []).map((c) => h("td", { class: "mono", style: "font-size:12px", text: str(c) }))))))));
|
|
1445
|
+
} else if (dg.kind === "text") {
|
|
1446
|
+
parts.push(h("div", { class: "faint", style: "font-size:12px;margin-bottom:6px", text: num(dg.chars) + " chars · " + num(dg.lines) + " lines" }));
|
|
1447
|
+
if (dg.outline && dg.outline.length) parts.push(valueBlock("Outline", dg.outline));
|
|
1448
|
+
parts.push(h("div", { class: "block-title", style: "margin-top:8px", text: "Head" }), h("pre", { class: "code", text: str(dg.head) }));
|
|
1449
|
+
if (dg.tail) parts.push(h("div", { class: "block-title", style: "margin-top:8px", text: "Tail" }), h("pre", { class: "code", text: str(dg.tail) }));
|
|
1450
|
+
} else {
|
|
1451
|
+
parts.push(jsonView(dg, { openDepth: 2 }));
|
|
1452
|
+
}
|
|
1453
|
+
if (url) parts.push(h("div", { style: "margin-top:16px" }, h("a", { class: "btn sm", href: url, target: "_blank", rel: "noopener noreferrer", text: "Open raw bytes" })));
|
|
1454
|
+
openDrawer(r.name || r.id, r.id, parts, { type: "ref", id: r.id });
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
// ------------------------------------------------------------------ drawer
|
|
1458
|
+
function openDrawer(title, sub, content, state) {
|
|
1459
|
+
if (!S.drawer) S.lastFocus = S.lastFocus || document.activeElement;
|
|
1460
|
+
S.drawer = state;
|
|
1461
|
+
$("drawer-title").textContent = title;
|
|
1462
|
+
$("drawer-sub").textContent = sub || "";
|
|
1463
|
+
setKids($("drawer-body"), content);
|
|
1464
|
+
$("drawer-body").scrollTop = 0;
|
|
1465
|
+
$("drawer").classList.add("open");
|
|
1466
|
+
$("drawer").setAttribute("aria-hidden", "false");
|
|
1467
|
+
$("backdrop").classList.add("open");
|
|
1468
|
+
document.body.style.overflow = "hidden";
|
|
1469
|
+
setTimeout(() => $("drawer-close").focus(), 30);
|
|
1470
|
+
}
|
|
1471
|
+
function closeDrawer() {
|
|
1472
|
+
if (!S.drawer) return;
|
|
1473
|
+
S.drawer = null;
|
|
1474
|
+
$("drawer").classList.remove("open");
|
|
1475
|
+
$("drawer").setAttribute("aria-hidden", "true");
|
|
1476
|
+
$("backdrop").classList.remove("open");
|
|
1477
|
+
document.body.style.overflow = "";
|
|
1478
|
+
const f = S.lastFocus; S.lastFocus = null;
|
|
1479
|
+
if (f && document.contains(f) && f.focus) f.focus();
|
|
1480
|
+
}
|
|
1481
|
+
$("drawer-close").addEventListener("click", closeDrawer);
|
|
1482
|
+
$("backdrop").addEventListener("click", closeDrawer);
|
|
1483
|
+
document.addEventListener("keydown", (ev) => {
|
|
1484
|
+
if (!S.drawer) return;
|
|
1485
|
+
if (ev.key === "Escape") { ev.preventDefault(); closeDrawer(); return; }
|
|
1486
|
+
if (ev.key === "Tab") {
|
|
1487
|
+
const f = [...$("drawer").querySelectorAll('button, [href], input, select, textarea, summary, video, audio, [tabindex]:not([tabindex="-1"])')].filter((x) => !x.disabled && x.offsetParent !== null);
|
|
1488
|
+
if (!f.length) return;
|
|
1489
|
+
const first = f[0], last = f[f.length - 1];
|
|
1490
|
+
if (ev.shiftKey && document.activeElement === first) { ev.preventDefault(); last.focus(); }
|
|
1491
|
+
else if (!ev.shiftKey && document.activeElement === last) { ev.preventDefault(); first.focus(); }
|
|
1492
|
+
else if (!$("drawer").contains(document.activeElement)) { ev.preventDefault(); first.focus(); }
|
|
1493
|
+
}
|
|
1494
|
+
});
|
|
1495
|
+
|
|
1496
|
+
// ------------------------------------------------------------------ live stream
|
|
1497
|
+
let sseOpen = false;
|
|
1498
|
+
let currentES = null;
|
|
1499
|
+
function setConn(state, label) {
|
|
1500
|
+
$("conn-dot").className = "dot " + state;
|
|
1501
|
+
$("conn-label").textContent = label;
|
|
1502
|
+
}
|
|
1503
|
+
let connectedOnce = false;
|
|
1504
|
+
function connect() {
|
|
1505
|
+
let es;
|
|
1506
|
+
try { es = new EventSource("/api/events?token=" + encodeURIComponent(TOKEN)); }
|
|
1507
|
+
catch { setConn("err", "Live stream unavailable"); return; }
|
|
1508
|
+
currentES = es;
|
|
1509
|
+
es.onopen = () => {
|
|
1510
|
+
sseOpen = true; setConn("live", "Live");
|
|
1511
|
+
// Catch up on anything missed while disconnected.
|
|
1512
|
+
if (connectedOnce) { loadOverview(); loadJobs(); loadApprovals(); loadTraces(); }
|
|
1513
|
+
connectedOnce = true;
|
|
1514
|
+
};
|
|
1515
|
+
es.onerror = () => {
|
|
1516
|
+
sseOpen = false;
|
|
1517
|
+
if (authBroken) { es.close(); return; }
|
|
1518
|
+
setConn("warn", "Reconnecting…");
|
|
1519
|
+
if (es.readyState === EventSource.CLOSED) setTimeout(() => { if (!authBroken) api("/api/overview").then(connect, () => { if (!authBroken) setTimeout(connect, 3000); }); }, 2000);
|
|
1520
|
+
};
|
|
1521
|
+
es.addEventListener("trace", (m) => {
|
|
1522
|
+
let e; try { e = JSON.parse(m.data); } catch { return; }
|
|
1523
|
+
if (!e || typeof e !== "object") return;
|
|
1524
|
+
pushEvent(e, true);
|
|
1525
|
+
if (S.drawer && S.drawer.type === "trace" && S.drawer.id === e.traceId) {
|
|
1526
|
+
if (!S.drawer.events.some((x) => evKey(x) === evKey(e))) { S.drawer.events.push(e); renderTraceDrawer(); }
|
|
1527
|
+
}
|
|
1528
|
+
loadTracesSoon();
|
|
1529
|
+
if (e.kind === "approval") loadApprovals();
|
|
1530
|
+
if (e.kind === "drift" || e.kind === "session") loadOverview();
|
|
1531
|
+
if (e.bytesOffloaded || e.kind === "call" || e.kind === "run") loadRefsSoon();
|
|
1532
|
+
liveBump(e);
|
|
1533
|
+
});
|
|
1534
|
+
es.addEventListener("job", (m) => {
|
|
1535
|
+
let v; try { v = JSON.parse(m.data); } catch { return; }
|
|
1536
|
+
if (v && v.id) onJobEvent(v);
|
|
1537
|
+
});
|
|
1538
|
+
}
|
|
1539
|
+
/** Keep the "live session" numbers moving between overview polls. */
|
|
1540
|
+
function liveBump(e) {
|
|
1541
|
+
const o = S.overview; if (!o || !o.live || !o.history) return;
|
|
1542
|
+
for (const s of [o.live, o.history]) {
|
|
1543
|
+
s.tokensSaved = (s.tokensSaved || 0) + (e.tokensSaved || 0);
|
|
1544
|
+
s.bytesOffloaded = (s.bytesOffloaded || 0) + (e.bytesOffloaded || 0);
|
|
1545
|
+
if (e.kind === "call") s.calls = (s.calls || 0) + 1;
|
|
1546
|
+
if (e.kind === "run") s.runs = (s.runs || 0) + 1;
|
|
1547
|
+
if (!e.ok && e.kind !== "policy") s.errors = (s.errors || 0) + 1;
|
|
1548
|
+
}
|
|
1549
|
+
if (e.costUsd && o.budget && o.budget.spent) o.budget.spent.day = (o.budget.spent.day || 0) + e.costUsd;
|
|
1550
|
+
renderOverview();
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
// ------------------------------------------------------------------ wiring
|
|
1554
|
+
$("feed-filter").addEventListener("click", (ev) => {
|
|
1555
|
+
const b = ev.target.closest("button[data-f]"); if (!b) return;
|
|
1556
|
+
S.feedFilter = b.dataset.f;
|
|
1557
|
+
for (const x of $("feed-filter").querySelectorAll("button")) x.setAttribute("aria-pressed", x === b ? "true" : "false");
|
|
1558
|
+
renderFeed();
|
|
1559
|
+
});
|
|
1560
|
+
$("feed-pause").addEventListener("click", () => {
|
|
1561
|
+
S.paused = !S.paused;
|
|
1562
|
+
if (!S.paused) { S.pausedBuffer = []; renderFeed(); }
|
|
1563
|
+
updatePauseLabel();
|
|
1564
|
+
});
|
|
1565
|
+
$("k-apv-btn").addEventListener("click", () => {
|
|
1566
|
+
$("approvals").scrollIntoView({ block: "start" });
|
|
1567
|
+
const first = $("apv-list").querySelector("button");
|
|
1568
|
+
(first || $("approvals")).focus({ preventScroll: true });
|
|
1569
|
+
});
|
|
1570
|
+
$("apv-refresh").addEventListener("click", loadApprovals);
|
|
1571
|
+
$("jobs-refresh").addEventListener("click", loadJobs);
|
|
1572
|
+
$("traces-refresh").addEventListener("click", loadTraces);
|
|
1573
|
+
$("refs-refresh").addEventListener("click", loadRefs);
|
|
1574
|
+
const searchSoon = debounce(loadCatalog, 200);
|
|
1575
|
+
$("catalog-q").addEventListener("input", (ev) => { S.catalogQ = ev.target.value; searchSoon(); });
|
|
1576
|
+
$("catalog-q").addEventListener("keydown", (ev) => { if (ev.key === "Escape" && ev.target.value) { ev.target.value = ""; S.catalogQ = ""; loadCatalog(); } });
|
|
1577
|
+
|
|
1578
|
+
// relative times drift; refresh lightly
|
|
1579
|
+
setInterval(() => {
|
|
1580
|
+
for (const n of document.querySelectorAll("[data-ago]")) n.textContent = ago(n.getAttribute("data-ago"));
|
|
1581
|
+
for (const [id, rec] of jobEls) { const j = S.jobs.get(id); if (j && ACTIVE(j.status)) rec.el._patch(j); }
|
|
1582
|
+
}, 10000);
|
|
1583
|
+
|
|
1584
|
+
async function init() {
|
|
1585
|
+
renderFeed(); renderApprovals(); renderJobs(); renderTraces(); renderRefs(); renderCatalog();
|
|
1586
|
+
connect();
|
|
1587
|
+
await Promise.all([loadOverview(), loadTraces(), loadJobs(), loadApprovals(), loadCatalog(), loadRefs()]);
|
|
1588
|
+
await seedFeed();
|
|
1589
|
+
setInterval(loadOverview, 5000);
|
|
1590
|
+
}
|
|
1591
|
+
init();
|
|
1592
|
+
})();
|
|
1593
|
+
</script>
|
|
1594
|
+
</body>
|
|
1595
|
+
</html>
|