mcponce 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,675 +2,586 @@ import { resolveCompletion } from '../utils/completion.js';
2
2
  import { normalizeResourceResult } from '../utils/media.js';
3
3
  export function createInspectorHtml(serverName, version) {
4
4
  return `<!DOCTYPE html>
5
- <html lang="en">
5
+ <html lang="en" class="h-full bg-slate-950">
6
6
  <head>
7
7
  <meta charset="UTF-8">
8
8
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
9
9
  <title>${serverName} — mcponce Inspector</title>
10
+ <!-- Tailwind CSS via CDN -->
11
+ <script src="https://cdn.tailwindcss.com"></script>
12
+ <!-- EUIX Engine UMD via CDN -->
13
+ <script src="https://unpkg.com/euixjs/dist/EUIXEngine.umd.js"></script>
10
14
  <style>
11
- :root {
12
- --bg: #0b0f19;
13
- --surface: #111827;
14
- --surface-hover: #1f2937;
15
- --surface-active: #283548;
16
- --border: #1f293d;
17
- --border-focus: #4f46e5;
18
- --text: #f9fafb;
19
- --text-muted: #9ca3af;
20
- --text-dim: #6b7280;
21
- --primary: #6366f1;
22
- --primary-hover: #4f46e5;
23
- --primary-glow: rgba(99, 102, 241, 0.25);
24
- --success: #10b981;
25
- --success-bg: rgba(16, 185, 129, 0.12);
26
- --warning: #f59e0b;
27
- --warning-bg: rgba(245, 158, 11, 0.12);
28
- --error: #ef4444;
29
- --error-bg: rgba(239, 68, 68, 0.12);
30
- --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
31
- --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
32
- }
33
- * { box-sizing: border-box; margin: 0; padding: 0; }
34
- body {
35
- font-family: var(--font-sans);
36
- background: var(--bg);
37
- color: var(--text);
38
- line-height: 1.5;
39
- height: 100vh;
40
- overflow: hidden;
41
- display: flex;
42
- flex-direction: column;
43
- }
44
- header {
45
- background: var(--surface);
46
- border-bottom: 1px solid var(--border);
47
- padding: 0.75rem 1.25rem;
48
- display: flex;
49
- align-items: center;
50
- justify-content: space-between;
51
- flex-shrink: 0;
52
- }
53
- .brand {
54
- display: flex;
55
- align-items: center;
56
- gap: 0.75rem;
57
- }
58
- .logo {
59
- background: linear-gradient(135deg, #6366f1, #a855f7);
60
- color: white;
61
- font-weight: 800;
62
- font-size: 0.85rem;
63
- padding: 0.25rem 0.6rem;
64
- border-radius: 6px;
65
- letter-spacing: -0.02em;
66
- }
67
- .server-name {
68
- font-weight: 700;
69
- font-size: 1.05rem;
70
- letter-spacing: -0.01em;
71
- }
72
- .badge {
73
- font-size: 0.72rem;
74
- padding: 0.15rem 0.5rem;
75
- border-radius: 9999px;
76
- font-weight: 600;
77
- text-transform: uppercase;
78
- letter-spacing: 0.04em;
79
- }
80
- .badge-status {
81
- background: var(--success-bg);
82
- color: var(--success);
83
- display: inline-flex;
84
- align-items: center;
85
- gap: 0.35rem;
86
- }
87
- .badge-status::before {
88
- content: '';
89
- width: 6px;
90
- height: 6px;
91
- border-radius: 50%;
92
- background: var(--success);
93
- box-shadow: 0 0 6px var(--success);
94
- }
95
- .badge-version {
96
- background: var(--surface-hover);
97
- color: var(--text-muted);
98
- }
99
- .nav-links {
100
- display: flex;
101
- align-items: center;
102
- gap: 0.75rem;
103
- }
104
- .nav-link {
105
- color: var(--text-muted);
106
- text-decoration: none;
107
- font-size: 0.82rem;
108
- font-weight: 500;
109
- padding: 0.35rem 0.65rem;
110
- border-radius: 6px;
111
- border: 1px solid var(--border);
112
- transition: all 0.15s;
113
- }
114
- .nav-link:hover {
115
- background: var(--surface-hover);
116
- color: var(--text);
117
- border-color: var(--text-dim);
118
- }
119
- .container {
120
- display: flex;
121
- flex: 1;
122
- overflow: hidden;
123
- }
124
- .sidebar {
125
- width: 320px;
126
- background: var(--surface);
127
- border-right: 1px solid var(--border);
128
- display: flex;
129
- flex-direction: column;
130
- flex-shrink: 0;
131
- }
132
- .search-box {
133
- padding: 0.85rem;
134
- border-bottom: 1px solid var(--border);
135
- }
136
- .search-input {
137
- width: 100%;
138
- background: var(--bg);
139
- border: 1px solid var(--border);
140
- border-radius: 6px;
141
- padding: 0.5rem 0.75rem;
142
- color: var(--text);
143
- font-size: 0.85rem;
144
- outline: none;
145
- transition: border-color 0.15s;
146
- }
147
- .search-input:focus {
148
- border-color: var(--border-focus);
149
- }
150
- .section-tabs {
151
- display: flex;
152
- border-bottom: 1px solid var(--border);
153
- background: rgba(0, 0, 0, 0.15);
154
- }
155
- .tab-btn {
156
- flex: 1;
157
- padding: 0.65rem 0.25rem;
158
- background: none;
159
- border: none;
160
- color: var(--text-muted);
161
- font-size: 0.78rem;
162
- font-weight: 600;
163
- cursor: pointer;
164
- border-bottom: 2px solid transparent;
165
- transition: all 0.15s;
166
- }
167
- .tab-btn:hover {
168
- color: var(--text);
169
- }
170
- .tab-btn.active {
171
- color: var(--primary);
172
- border-bottom-color: var(--primary);
173
- background: var(--surface);
174
- }
175
- .item-list {
176
- flex: 1;
177
- overflow-y: auto;
178
- padding: 0.5rem;
179
- }
180
- .list-item {
181
- padding: 0.65rem 0.75rem;
182
- border-radius: 6px;
183
- cursor: pointer;
184
- margin-bottom: 0.25rem;
185
- border: 1px solid transparent;
186
- transition: all 0.15s;
187
- }
188
- .list-item:hover {
189
- background: var(--surface-hover);
190
- }
191
- .list-item.active {
192
- background: var(--surface-active);
193
- border-color: var(--primary);
194
- }
195
- .item-name {
196
- font-weight: 600;
197
- font-size: 0.85rem;
198
- font-family: var(--font-mono);
199
- display: flex;
200
- align-items: center;
201
- justify-content: space-between;
202
- }
203
- .item-desc {
204
- font-size: 0.75rem;
205
- color: var(--text-muted);
206
- margin-top: 0.2rem;
207
- white-space: nowrap;
208
- overflow: hidden;
209
- text-overflow: ellipsis;
210
- }
211
- .main {
212
- flex: 1;
213
- overflow-y: auto;
214
- padding: 1.5rem;
215
- display: flex;
216
- flex-direction: column;
217
- gap: 1.25rem;
218
- }
219
- .card {
220
- background: var(--surface);
221
- border: 1px solid var(--border);
222
- border-radius: 8px;
223
- padding: 1.25rem;
224
- }
225
- .card-header {
226
- display: flex;
227
- align-items: center;
228
- justify-content: space-between;
229
- margin-bottom: 0.85rem;
230
- padding-bottom: 0.75rem;
231
- border-bottom: 1px solid var(--border);
232
- }
233
- .card-title {
234
- font-size: 1.15rem;
235
- font-weight: 700;
236
- font-family: var(--font-mono);
237
- }
238
- .form-group {
239
- margin-bottom: 1rem;
240
- }
241
- .form-label {
242
- display: flex;
243
- align-items: center;
244
- justify-content: space-between;
245
- font-size: 0.8rem;
246
- font-weight: 600;
247
- color: var(--text);
248
- margin-bottom: 0.35rem;
249
- font-family: var(--font-mono);
250
- }
251
- .form-type {
252
- font-size: 0.72rem;
253
- color: var(--text-muted);
254
- font-weight: normal;
255
- }
256
- .form-input, .form-textarea {
257
- width: 100%;
258
- background: var(--bg);
259
- border: 1px solid var(--border);
260
- border-radius: 6px;
261
- padding: 0.55rem 0.75rem;
262
- color: var(--text);
263
- font-size: 0.85rem;
264
- font-family: var(--font-mono);
265
- outline: none;
266
- transition: border-color 0.15s;
267
- }
268
- .form-input:focus, .form-textarea:focus {
269
- border-color: var(--border-focus);
270
- }
271
- .form-textarea {
272
- min-height: 80px;
273
- resize: vertical;
274
- }
275
- .form-checkbox {
276
- margin-right: 0.5rem;
277
- accent-color: var(--primary);
278
- }
279
- .actions {
280
- display: flex;
281
- gap: 0.75rem;
282
- margin-top: 1rem;
283
- }
284
- .btn {
285
- padding: 0.55rem 1.1rem;
286
- border-radius: 6px;
287
- font-weight: 600;
288
- font-size: 0.85rem;
289
- cursor: pointer;
290
- border: none;
291
- transition: all 0.15s;
292
- display: inline-flex;
293
- align-items: center;
294
- gap: 0.4rem;
295
- }
296
- .btn-primary {
297
- background: var(--primary);
298
- color: white;
299
- box-shadow: 0 2px 8px var(--primary-glow);
300
- }
301
- .btn-primary:hover {
302
- background: var(--primary-hover);
303
- }
304
- .btn-secondary {
305
- background: var(--surface-hover);
306
- color: var(--text);
307
- border: 1px solid var(--border);
308
- }
309
- .btn-secondary:hover {
310
- background: var(--surface-active);
311
- }
312
- .output-section {
313
- background: var(--bg);
314
- border: 1px solid var(--border);
315
- border-radius: 6px;
316
- padding: 1rem;
317
- margin-top: 1rem;
318
- }
319
- .output-header {
320
- display: flex;
321
- align-items: center;
322
- justify-content: space-between;
323
- margin-bottom: 0.75rem;
324
- font-size: 0.78rem;
325
- color: var(--text-muted);
326
- }
327
- .output-pre {
328
- font-family: var(--font-mono);
329
- font-size: 0.82rem;
330
- white-space: pre-wrap;
331
- word-break: break-word;
332
- color: #e2e8f0;
333
- max-height: 400px;
334
- overflow-y: auto;
335
- }
336
- .grid-stats {
337
- display: grid;
338
- grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
339
- gap: 1rem;
340
- }
341
- .stat-card {
342
- background: var(--bg);
343
- border: 1px solid var(--border);
344
- border-radius: 6px;
345
- padding: 1rem;
346
- }
347
- .stat-value {
348
- font-size: 1.5rem;
349
- font-weight: 700;
350
- font-family: var(--font-mono);
351
- color: var(--primary);
352
- margin-top: 0.25rem;
353
- }
354
- .stat-label {
355
- font-size: 0.75rem;
356
- color: var(--text-muted);
357
- text-transform: uppercase;
358
- letter-spacing: 0.05em;
359
- }
360
- .toast {
361
- position: fixed;
362
- bottom: 1.5rem;
363
- right: 1.5rem;
364
- background: var(--surface);
365
- border: 1px solid var(--border);
366
- padding: 0.65rem 1.25rem;
367
- border-radius: 6px;
368
- box-shadow: 0 4px 12px rgba(0,0,0,0.5);
369
- font-size: 0.85rem;
370
- color: var(--text);
371
- opacity: 0;
372
- transform: translateY(10px);
373
- transition: all 0.2s;
374
- pointer-events: none;
375
- }
376
- .toast.show {
377
- opacity: 1;
378
- transform: translateY(0);
379
- }
15
+ /* Sleek dark scrollbar */
16
+ ::-webkit-scrollbar { width: 6px; height: 6px; }
17
+ ::-webkit-scrollbar-track { background: #020617; }
18
+ ::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 3px; }
19
+ ::-webkit-scrollbar-thumb:hover { background: #334155; }
380
20
  </style>
381
21
  </head>
382
- <body>
383
- <header>
384
- <div class="brand">
385
- <span class="logo">mcponce</span>
386
- <span class="server-name">${serverName}</span>
387
- <span class="badge badge-version">v${version}</span>
388
- <span class="badge badge-status">Active</span>
22
+ <body class="h-full bg-slate-950 text-slate-100 antialiased overflow-hidden select-none">
23
+ <div id="app" class="h-full w-full flex flex-col">
24
+ <div id="fallback-loading" class="flex-1 flex flex-col items-center justify-center gap-3 text-slate-400">
25
+ <div class="w-8 h-8 border-2 border-indigo-500 border-t-transparent rounded-full animate-spin"></div>
26
+ <div class="text-sm font-medium">Initializing mcponce Inspector (EUIX Engine)...</div>
389
27
  </div>
390
- <div class="nav-links">
391
- <a href="/metrics" target="_blank" class="nav-link">Prometheus (/metrics)</a>
392
- <a href="/analytics" target="_blank" class="nav-link">Telemetry (/analytics)</a>
393
- <a href="/health" target="_blank" class="nav-link">Health (/health)</a>
394
- </div>
395
- </header>
396
-
397
- <div class="container">
398
- <aside class="sidebar">
399
- <div class="search-box">
400
- <input type="text" id="search" class="search-input" placeholder="Search tools, resources, prompts...">
401
- </div>
402
- <div class="section-tabs">
403
- <button class="tab-btn active" onclick="switchSection('tools')">Tools (<span id="count-tools">0</span>)</button>
404
- <button class="tab-btn" onclick="switchSection('resources')">Resources (<span id="count-resources">0</span>)</button>
405
- <button class="tab-btn" onclick="switchSection('prompts')">Prompts (<span id="count-prompts">0</span>)</button>
406
- <button class="tab-btn" onclick="switchSection('metrics')">Metrics</button>
407
- </div>
408
- <div id="items-list" class="item-list"></div>
409
- </aside>
410
-
411
- <main class="main" id="workspace">
412
- <div class="card">
413
- <div class="card-title">Select an item from the sidebar to inspect and run</div>
414
- </div>
415
- </main>
416
28
  </div>
417
29
 
418
- <div id="toast" class="toast">Copied to clipboard!</div>
30
+ <script id="euix-spec" type="text/xml">
31
+ <uid_spec>
32
+ <data_model>
33
+ <state id="serverName" type="string">${serverName}</state>
34
+ <state id="serverVersion" type="string">${version}</state>
35
+ <state id="serverPid" type="number">0</state>
36
+ <state id="serverUptime" type="number">0</state>
37
+ <state id="activeTab" type="string">tools</state>
38
+ <state id="searchQuery" type="string"></state>
39
+ <state id="selectedToolName" type="string"></state>
40
+ <state id="selectedResourceUri" type="string"></state>
41
+ <state id="selectedPromptName" type="string"></state>
42
+ <state id="toolArgsJson" type="string">{}</state>
43
+ <state id="promptArgsJson" type="string">{}</state>
44
+ <state id="resourceUriInput" type="string"></state>
45
+ <state id="executionResult" type="string"></state>
46
+ <state id="executionStatus" type="string"></state>
47
+ <state id="executionDuration" type="string"></state>
48
+ <state id="isLoading" type="boolean">false</state>
49
+ <state id="tools" type="array">[]</state>
50
+ <state id="resources" type="array">[]</state>
51
+ <state id="resourceTemplates" type="array">[]</state>
52
+ <state id="prompts" type="array">[]</state>
53
+ <state id="totalCalls" type="number">0</state>
54
+ <state id="totalErrors" type="number">0</state>
55
+ <state id="activeSessions" type="number">0</state>
56
+ <state id="avgDurationMs" type="number">0</state>
57
+ </data_model>
419
58
 
420
- <script>
421
- let state = { tools: [], resources: [], resourceTemplates: [], prompts: [], analytics: {}, server: {} };
422
- let activeSection = 'tools';
423
- let activeItem = null;
424
-
425
- async function loadState() {
426
- try {
427
- const res = await fetch('/inspect/api/state');
428
- state = await res.json();
429
- document.getElementById('count-tools').textContent = state.tools.length;
430
- document.getElementById('count-resources').textContent = state.resources.length + (state.resourceTemplates || []).length;
431
- document.getElementById('count-prompts').textContent = state.prompts.length;
432
- renderSidebar();
433
- if (state.tools.length > 0 && !activeItem) {
434
- selectItem('tools', state.tools[0].name);
435
- }
436
- } catch (err) {
437
- console.error('Failed to load inspector state:', err);
438
- }
439
- }
59
+ <on_mount action="RUN_SCRIPT">
60
+ <![CDATA[
61
+ function loadInspectorState() {
62
+ fetch('/inspect/api/state')
63
+ .then(function(res) { return res.json(); })
64
+ .then(function(state) {
65
+ if (state.server) {
66
+ $data.serverName = state.server.name || $data.serverName;
67
+ $data.serverVersion = state.server.version || $data.serverVersion;
68
+ $data.serverPid = state.server.pid || 0;
69
+ $data.serverUptime = state.server.uptime || 0;
70
+ }
71
+ $data.tools = state.tools || [];
72
+ $data.resources = state.resources || [];
73
+ $data.resourceTemplates = state.resourceTemplates || [];
74
+ $data.prompts = state.prompts || [];
440
75
 
441
- function switchSection(section) {
442
- activeSection = section;
443
- document.querySelectorAll('.tab-btn').forEach((btn, idx) => {
444
- btn.classList.toggle('active', ['tools', 'resources', 'prompts', 'metrics'][idx] === section);
445
- });
446
- renderSidebar();
447
- if (section === 'metrics') {
448
- renderMetricsWorkspace();
449
- }
450
- }
76
+ var a = state.analytics || {};
77
+ var m = state.metrics || {};
78
+ $data.totalCalls = a.totalInvocations || 0;
79
+ $data.totalErrors = a.totalErrors || 0;
80
+ $data.activeSessions = m.activeSessions || 0;
81
+ $data.avgDurationMs = a.avgDurationMs ? Math.round(a.avgDurationMs) : 0;
451
82
 
452
- function renderSidebar() {
453
- const list = document.getElementById('items-list');
454
- list.innerHTML = '';
455
- const query = document.getElementById('search').value.toLowerCase();
456
-
457
- if (activeSection === 'tools') {
458
- state.tools.filter(t => t.name.toLowerCase().includes(query) || (t.description || '').toLowerCase().includes(query)).forEach(t => {
459
- const item = document.createElement('div');
460
- item.className = 'list-item' + (activeItem === t.name ? ' active' : '');
461
- item.onclick = () => selectItem('tools', t.name);
462
- item.innerHTML = '<div class="item-name">' + t.name + '</div><div class="item-desc">' + (t.description || 'No description') + '</div>';
463
- list.appendChild(item);
464
- });
465
- } else if (activeSection === 'resources') {
466
- const allRes = [...(state.resources || []), ...(state.resourceTemplates || [])];
467
- allRes.filter(r => (r.uri || r.uriTemplate || '').toLowerCase().includes(query)).forEach(r => {
468
- const name = r.uri || r.uriTemplate;
469
- const item = document.createElement('div');
470
- item.className = 'list-item' + (activeItem === name ? ' active' : '');
471
- item.onclick = () => selectItem('resources', name);
472
- item.innerHTML = '<div class="item-name">' + name + '</div><div class="item-desc">' + (r.description || 'Resource') + '</div>';
473
- list.appendChild(item);
474
- });
475
- } else if (activeSection === 'prompts') {
476
- state.prompts.filter(p => p.name.toLowerCase().includes(query)).forEach(p => {
477
- const item = document.createElement('div');
478
- item.className = 'list-item' + (activeItem === p.name ? ' active' : '');
479
- item.onclick = () => selectItem('prompts', p.name);
480
- item.innerHTML = '<div class="item-name">' + p.name + '</div><div class="item-desc">' + (p.description || 'Prompt') + '</div>';
481
- list.appendChild(item);
83
+ if ($data.tools.length > 0 && !$data.selectedToolName) {
84
+ $data.selectedToolName = $data.tools[0].name;
85
+ var sample = {};
86
+ if ($data.tools[0].inputSchema && $data.tools[0].inputSchema.properties) {
87
+ for (var k in $data.tools[0].inputSchema.properties) {
88
+ var p = $data.tools[0].inputSchema.properties[k];
89
+ sample[k] = p.default !== undefined ? p.default : (p.type === 'number' ? 0 : (p.type === 'boolean' ? false : ''));
90
+ }
91
+ }
92
+ $data.toolArgsJson = JSON.stringify(sample, null, 2);
93
+ }
94
+ if ($data.resources.length > 0 && !$data.selectedResourceUri) {
95
+ $data.selectedResourceUri = $data.resources[0].uri;
96
+ $data.resourceUriInput = $data.resources[0].uri;
97
+ } else if ($data.resourceTemplates.length > 0 && !$data.selectedResourceUri) {
98
+ $data.selectedResourceUri = $data.resourceTemplates[0].uriTemplate;
99
+ $data.resourceUriInput = $data.resourceTemplates[0].uriTemplate;
100
+ }
101
+ if ($data.prompts.length > 0 && !$data.selectedPromptName) {
102
+ $data.selectedPromptName = $data.prompts[0].name;
103
+ $data.promptArgsJson = '{}';
104
+ }
105
+ })
106
+ .catch(function(err) {
107
+ console.error('Failed to load inspector state:', err);
482
108
  });
483
- }
484
109
  }
110
+ window.__refreshInspectorState = loadInspectorState;
111
+ loadInspectorState();
112
+ ]]>
113
+ </on_mount>
485
114
 
486
- document.getElementById('search').addEventListener('input', renderSidebar);
487
-
488
- function selectItem(section, name) {
489
- activeItem = name;
490
- renderSidebar();
491
- if (section === 'tools') {
492
- renderToolWorkspace(name);
493
- } else if (section === 'resources') {
494
- renderResourceWorkspace(name);
495
- } else if (section === 'prompts') {
496
- renderPromptWorkspace(name);
497
- }
498
- }
115
+ <div class="flex flex-col h-full w-full bg-slate-950 text-slate-100 overflow-hidden font-sans">
116
+ <!-- Top Header -->
117
+ <header class="flex items-center justify-between px-5 py-3 bg-slate-900 border-b border-slate-800 flex-shrink-0">
118
+ <div class="flex items-center gap-3">
119
+ <div class="bg-gradient-to-r from-indigo-500 to-violet-600 text-white font-black text-xs px-2.5 py-1 rounded shadow-md tracking-wider">
120
+ MCPONCE
121
+ </div>
122
+ <div class="flex items-center gap-2">
123
+ <span class="font-bold text-sm tracking-tight text-white">{data.serverName}</span>
124
+ <span class="text-xs px-2 py-0.5 rounded-full bg-slate-800 text-slate-400 border border-slate-700 font-mono">
125
+ v{data.serverVersion}
126
+ </span>
127
+ <div class="flex items-center gap-1.5 px-2.5 py-0.5 rounded-full bg-emerald-950/60 border border-emerald-800/60 text-emerald-400 text-xs font-semibold">
128
+ <span class="w-2 h-2 rounded-full bg-emerald-400 animate-pulse"></span>
129
+ ONLINE
130
+ </div>
131
+ </div>
132
+ </div>
499
133
 
500
- function renderToolWorkspace(name) {
501
- const tool = state.tools.find(t => t.name === name);
502
- if (!tool) return;
503
-
504
- const ws = document.getElementById('workspace');
505
- let propertiesHtml = '';
506
- const schema = tool.inputSchema || {};
507
- const props = schema.properties || {};
508
-
509
- Object.entries(props).forEach(([propName, propDef]) => {
510
- const type = propDef.type || 'string';
511
- const isRequired = Array.isArray(schema.required) && schema.required.includes(propName);
512
- propertiesHtml += '<div class="form-group"><label class="form-label"><span>' + propName + (isRequired ? ' *' : '') + '</span><span class="form-type">' + type + (propDef.description ? ' — ' + propDef.description : '') + '</span></label>';
513
- if (type === 'boolean') {
514
- propertiesHtml += '<input type="checkbox" id="field-' + propName + '" class="form-checkbox" ' + (propDef.default ? 'checked' : '') + '>';
515
- } else if (type === 'number' || type === 'integer') {
516
- propertiesHtml += '<input type="number" id="field-' + propName + '" class="form-input" value="' + (propDef.default !== undefined ? propDef.default : '') + '">';
517
- } else if (type === 'object' || type === 'array') {
518
- propertiesHtml += '<textarea id="field-' + propName + '" class="form-textarea">' + (propDef.default ? JSON.stringify(propDef.default, null, 2) : '') + '</textarea>';
519
- } else {
520
- propertiesHtml += '<input type="text" id="field-' + propName + '" class="form-input" value="' + (propDef.default !== undefined ? propDef.default : '') + '">';
521
- }
522
- propertiesHtml += '</div>';
523
- });
134
+ <!-- Navigation Tabs -->
135
+ <nav class="flex items-center gap-1.5">
136
+ <button on_click:set="activeTab='tools'" class="px-3 py-1.5 rounded-lg text-xs font-medium transition-all {data.activeTab == 'tools' ? 'bg-indigo-600 text-white shadow-sm' : 'text-slate-400 hover:text-slate-200 hover:bg-slate-800'}">
137
+ Tools <span class="ml-1 px-1.5 py-0.2 rounded bg-slate-950/60 text-[10px] font-mono">{data.tools.length}</span>
138
+ </button>
139
+ <button on_click:set="activeTab='resources'" class="px-3 py-1.5 rounded-lg text-xs font-medium transition-all {data.activeTab == 'resources' ? 'bg-indigo-600 text-white shadow-sm' : 'text-slate-400 hover:text-slate-200 hover:bg-slate-800'}">
140
+ Resources <span class="ml-1 px-1.5 py-0.2 rounded bg-slate-950/60 text-[10px] font-mono">{data.resources.length}</span>
141
+ </button>
142
+ <button on_click:set="activeTab='prompts'" class="px-3 py-1.5 rounded-lg text-xs font-medium transition-all {data.activeTab == 'prompts' ? 'bg-indigo-600 text-white shadow-sm' : 'text-slate-400 hover:text-slate-200 hover:bg-slate-800'}">
143
+ Prompts <span class="ml-1 px-1.5 py-0.2 rounded bg-slate-950/60 text-[10px] font-mono">{data.prompts.length}</span>
144
+ </button>
145
+ <button on_click:set="activeTab='metrics'" class="px-3 py-1.5 rounded-lg text-xs font-medium transition-all {data.activeTab == 'metrics' ? 'bg-indigo-600 text-white shadow-sm' : 'text-slate-400 hover:text-slate-200 hover:bg-slate-800'}">
146
+ Metrics
147
+ </button>
148
+ <div class="h-4 w-px bg-slate-800 mx-1"></div>
149
+ <button class="px-2.5 py-1.5 rounded-lg text-xs font-medium text-slate-400 hover:text-slate-200 hover:bg-slate-800 transition-colors flex items-center gap-1">
150
+ <on_click action="RUN_SCRIPT">
151
+ <![CDATA[
152
+ if (window.__refreshInspectorState) {
153
+ window.__refreshInspectorState();
154
+ }
155
+ ]]>
156
+ </on_click>
157
+ Refresh
158
+ </button>
159
+ </nav>
160
+ </header>
524
161
 
525
- if (!propertiesHtml) {
526
- propertiesHtml = '<div style="color: var(--text-muted); font-size: 0.85rem;">This tool takes no arguments.</div>';
527
- }
162
+ <!-- Main Workspace -->
163
+ <div class="flex flex-1 overflow-hidden">
164
+ <!-- Sidebar -->
165
+ <aside class="w-80 border-r border-slate-800 bg-slate-900/40 flex flex-col flex-shrink-0">
166
+ <div class="p-3 border-b border-slate-800/80">
167
+ <input bind="searchQuery" placeholder="Filter items..." class="w-full px-3 py-1.5 text-xs bg-slate-950 border border-slate-800 rounded-lg text-slate-200 placeholder-slate-500 focus:outline-none focus:border-indigo-500 transition-colors" />
168
+ </div>
528
169
 
529
- ws.innerHTML = '<div class="card"><div class="card-header"><div class="card-title">' + tool.name + '</div><div>' +
530
- (tool.cache ? '<span class="badge" style="background: rgba(99,102,241,0.15); color: #818cf8;">LRU Cached</span> ' : '') +
531
- (tool.sequential ? '<span class="badge" style="background: rgba(245,158,11,0.15); color: #f59e0b;">Sequential</span>' : '') +
532
- '</div></div><p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem;">' + (tool.description || 'No description provided.') + '</p>' +
533
- '<form id="tool-form" onsubmit="executeTool(event, \'' + tool.name + '\')">' + propertiesHtml +
534
- '<div class="actions"><button type="submit" class="btn btn-primary">▶ Run Tool</button><button type="button" class="btn btn-secondary" onclick="renderToolWorkspace(\'' + tool.name + '\')">Reset</button></div></form>' +
535
- '<div id="output-box" style="display: none;" class="output-section"><div class="output-header"><span id="output-status"></span><span id="output-meta"></span></div><pre id="output-text" class="output-pre"></pre></div></div>';
536
- }
170
+ <div class="flex-1 overflow-y-auto p-2 space-y-1">
171
+ <!-- Tools List -->
172
+ <div class="{data.activeTab == 'tools' ? 'block' : 'hidden'}">
173
+ <for_each items="{data.tools}" var="tool" key="name">
174
+ <div class="p-2.5 rounded-lg cursor-pointer transition-all border {data.selectedToolName == tool.name ? 'bg-indigo-950/60 border-indigo-500/70 text-white shadow-sm' : 'border-transparent text-slate-400 hover:bg-slate-800/60 hover:text-slate-200'}">
175
+ <on_click action="RUN_SCRIPT">
176
+ <![CDATA[
177
+ $data.selectedToolName = tool.name;
178
+ $data.executionResult = '';
179
+ $data.executionStatus = '';
180
+ $data.executionDuration = '';
181
+ var sample = {};
182
+ if (tool.inputSchema && tool.inputSchema.properties) {
183
+ for (var k in tool.inputSchema.properties) {
184
+ var p = tool.inputSchema.properties[k];
185
+ sample[k] = p.default !== undefined ? p.default : (p.type === 'number' ? 0 : (p.type === 'boolean' ? false : ''));
186
+ }
187
+ }
188
+ $data.toolArgsJson = JSON.stringify(sample, null, 2);
189
+ ]]>
190
+ </on_click>
191
+ <div class="flex items-center justify-between">
192
+ <span class="font-mono text-xs font-semibold text-indigo-300">{tool.name}</span>
193
+ </div>
194
+ <p class="text-[11px] text-slate-400 mt-1 line-clamp-2">{tool.description}</p>
195
+ </div>
196
+ </for_each>
197
+ </div>
537
198
 
538
- async function executeTool(e, name) {
539
- e.preventDefault();
540
- const tool = state.tools.find(t => t.name === name);
541
- const props = (tool.inputSchema || {}).properties || {};
542
- const args = {};
543
-
544
- Object.entries(props).forEach(([propName, propDef]) => {
545
- const el = document.getElementById('field-' + propName);
546
- if (!el) return;
547
- if (propDef.type === 'boolean') {
548
- args[propName] = el.checked;
549
- } else if (propDef.type === 'number' || propDef.type === 'integer') {
550
- if (el.value !== '') args[propName] = Number(el.value);
551
- } else if (propDef.type === 'object' || propDef.type === 'array') {
552
- if (el.value.trim() !== '') {
553
- try { args[propName] = JSON.parse(el.value); } catch { args[propName] = el.value; }
554
- }
555
- } else {
556
- if (el.value !== '') args[propName] = el.value;
557
- }
558
- });
559
-
560
- const outBox = document.getElementById('output-box');
561
- const outStatus = document.getElementById('output-status');
562
- const outMeta = document.getElementById('output-meta');
563
- const outText = document.getElementById('output-text');
564
-
565
- outBox.style.display = 'block';
566
- outStatus.innerHTML = '<span style="color: var(--warning);">Running...</span>';
567
- outText.textContent = 'Executing tool...';
568
-
569
- const start = performance.now();
570
- try {
571
- const res = await fetch('/inspect/api/tools/' + encodeURIComponent(name), {
572
- method: 'POST',
573
- headers: { 'Content-Type': 'application/json' },
574
- body: JSON.stringify({ args })
575
- });
576
- const duration = Math.round(performance.now() - start);
577
- const data = await res.json();
199
+ <!-- Resources List -->
200
+ <div class="{data.activeTab == 'resources' ? 'block' : 'hidden'}">
201
+ <for_each items="{data.resources}" var="res" key="uri">
202
+ <div class="p-2.5 rounded-lg cursor-pointer transition-all border {data.selectedResourceUri == res.uri ? 'bg-indigo-950/60 border-indigo-500/70 text-white shadow-sm' : 'border-transparent text-slate-400 hover:bg-slate-800/60 hover:text-slate-200'}">
203
+ <on_click action="RUN_SCRIPT">
204
+ <![CDATA[
205
+ $data.selectedResourceUri = res.uri;
206
+ $data.resourceUriInput = res.uri;
207
+ $data.executionResult = '';
208
+ $data.executionStatus = '';
209
+ $data.executionDuration = '';
210
+ ]]>
211
+ </on_click>
212
+ <div class="font-mono text-xs font-semibold text-emerald-300 truncate">{res.uri}</div>
213
+ <p class="text-[11px] text-slate-400 mt-0.5 line-clamp-1">{res.name}</p>
214
+ </div>
215
+ </for_each>
216
+ <for_each items="{data.resourceTemplates}" var="tpl" key="uriTemplate">
217
+ <div class="p-2.5 rounded-lg cursor-pointer transition-all border {data.selectedResourceUri == tpl.uriTemplate ? 'bg-indigo-950/60 border-indigo-500/70 text-white shadow-sm' : 'border-transparent text-slate-400 hover:bg-slate-800/60 hover:text-slate-200'}">
218
+ <on_click action="RUN_SCRIPT">
219
+ <![CDATA[
220
+ $data.selectedResourceUri = tpl.uriTemplate;
221
+ $data.resourceUriInput = tpl.uriTemplate;
222
+ $data.executionResult = '';
223
+ $data.executionStatus = '';
224
+ $data.executionDuration = '';
225
+ ]]>
226
+ </on_click>
227
+ <div class="font-mono text-xs font-semibold text-cyan-300 truncate">{tpl.uriTemplate}</div>
228
+ <p class="text-[11px] text-slate-400 mt-0.5 line-clamp-1">Template</p>
229
+ </div>
230
+ </for_each>
231
+ </div>
578
232
 
579
- if (data.success) {
580
- outStatus.innerHTML = '<span style="color: var(--success); font-weight: bold;">✔ OK (200)</span>';
581
- outMeta.textContent = duration + ' ms' + (data.cached ? ' • Cache HIT' : ' • Cache MISS');
582
- outText.textContent = JSON.stringify(data.result, null, 2);
583
- } else {
584
- outStatus.innerHTML = '<span style="color: var(--error); font-weight: bold;">✖ Error</span>';
585
- outMeta.textContent = duration + ' ms';
586
- outText.textContent = data.error || 'Unknown error occurred';
587
- }
588
- } catch (err) {
589
- outStatus.innerHTML = '<span style="color: var(--error); font-weight: bold;">✖ Network Error</span>';
590
- outText.textContent = String(err);
591
- }
592
- }
233
+ <!-- Prompts List -->
234
+ <div class="{data.activeTab == 'prompts' ? 'block' : 'hidden'}">
235
+ <for_each items="{data.prompts}" var="prompt" key="name">
236
+ <div class="p-2.5 rounded-lg cursor-pointer transition-all border {data.selectedPromptName == prompt.name ? 'bg-indigo-950/60 border-indigo-500/70 text-white shadow-sm' : 'border-transparent text-slate-400 hover:bg-slate-800/60 hover:text-slate-200'}">
237
+ <on_click action="RUN_SCRIPT">
238
+ <![CDATA[
239
+ $data.selectedPromptName = prompt.name;
240
+ $data.executionResult = '';
241
+ $data.executionStatus = '';
242
+ $data.executionDuration = '';
243
+ var sample = {};
244
+ if (prompt.argsSchema && typeof prompt.argsSchema === 'object') {
245
+ for (var k in prompt.argsSchema) {
246
+ sample[k] = '';
247
+ }
248
+ }
249
+ $data.promptArgsJson = JSON.stringify(sample, null, 2);
250
+ ]]>
251
+ </on_click>
252
+ <div class="font-mono text-xs font-semibold text-purple-300">{prompt.name}</div>
253
+ <p class="text-[11px] text-slate-400 mt-0.5 line-clamp-2">{prompt.description}</p>
254
+ </div>
255
+ </for_each>
256
+ </div>
593
257
 
594
- function renderResourceWorkspace(name) {
595
- const allRes = [...(state.resources || []), ...(state.resourceTemplates || [])];
596
- const res = allRes.find(r => (r.uri || r.uriTemplate) === name);
597
- if (!res) return;
258
+ <!-- Metrics Sidebar info -->
259
+ <div class="{data.activeTab == 'metrics' ? 'block p-3 space-y-2' : 'hidden'}">
260
+ <div class="text-xs font-semibold text-slate-300 uppercase tracking-wider">Telemetry Overview</div>
261
+ <div class="text-xs text-slate-400">Live operational server metrics and runtime statistics.</div>
262
+ </div>
263
+ </div>
264
+ </aside>
598
265
 
599
- const ws = document.getElementById('workspace');
600
- const isTemplate = !!res.uriTemplate;
601
- const uriStr = res.uri || res.uriTemplate;
266
+ <!-- Main Detail / Workspace Panel -->
267
+ <main class="flex-1 flex flex-col overflow-y-auto bg-slate-950 p-6">
268
+ <!-- Tools Detail Panel -->
269
+ <div class="{data.activeTab == 'tools' ? 'flex flex-col gap-5' : 'hidden'}">
270
+ <div class="flex items-center justify-between pb-4 border-b border-slate-800">
271
+ <div>
272
+ <div class="text-xs text-slate-400 font-mono">Tool Inspection</div>
273
+ <h2 class="text-xl font-bold text-white font-mono mt-0.5">{data.selectedToolName}</h2>
274
+ </div>
275
+ <button class="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-semibold rounded-lg shadow-sm transition-colors flex items-center gap-1.5">
276
+ <on_click action="RUN_SCRIPT">
277
+ <![CDATA[
278
+ $data.isLoading = true;
279
+ $data.executionStatus = 'loading';
280
+ $data.executionResult = 'Executing ' + $data.selectedToolName + '...';
281
+ $data.executionDuration = '';
602
282
 
603
- ws.innerHTML = '<div class="card"><div class="card-header"><div class="card-title">' + uriStr + '</div>' +
604
- '<span class="badge" style="background: rgba(16,185,129,0.15); color: #10b981;">' + (isTemplate ? 'Template (RFC 6570)' : 'Static Resource') + '</span></div>' +
605
- '<p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem;">' + (res.description || 'No description.') + '</p>' +
606
- '<div class="actions"><button class="btn btn-primary" onclick="readResource(\'' + encodeURIComponent(uriStr) + '\')">Read Resource</button></div>' +
607
- '<div id="res-output" style="display: none;" class="output-section"><pre id="res-text" class="output-pre"></pre></div></div>';
608
- }
283
+ var args = {};
284
+ try {
285
+ if ($data.toolArgsJson && $data.toolArgsJson.trim()) {
286
+ args = JSON.parse($data.toolArgsJson);
287
+ }
288
+ } catch (e) {
289
+ $data.isLoading = false;
290
+ $data.executionStatus = 'error';
291
+ $data.executionResult = 'Invalid JSON arguments: ' + e.message;
292
+ return;
293
+ }
609
294
 
610
- async function readResource(encodedUri) {
611
- const uri = decodeURIComponent(encodedUri);
612
- const outBox = document.getElementById('res-output');
613
- const outText = document.getElementById('res-text');
614
- outBox.style.display = 'block';
615
- outText.textContent = 'Reading resource...';
616
-
617
- try {
618
- const res = await fetch('/inspect/api/resources/read', {
619
- method: 'POST',
620
- headers: { 'Content-Type': 'application/json' },
621
- body: JSON.stringify({ uri })
622
- });
623
- const data = await res.json();
624
- outText.textContent = JSON.stringify(data, null, 2);
625
- } catch (err) {
626
- outText.textContent = String(err);
627
- }
628
- }
295
+ var startTime = Date.now();
296
+ fetch('/inspect/api/tools/' + encodeURIComponent($data.selectedToolName), {
297
+ method: 'POST',
298
+ headers: { 'Content-Type': 'application/json' },
299
+ body: JSON.stringify({ args: args })
300
+ })
301
+ .then(function(res) {
302
+ return res.json().then(function(json) {
303
+ return { ok: res.ok, status: res.status, data: json };
304
+ });
305
+ })
306
+ .then(function(res) {
307
+ $data.isLoading = false;
308
+ var duration = Date.now() - startTime;
309
+ $data.executionDuration = (res.data.durationMs != null ? res.data.durationMs : duration) + ' ms';
310
+ if (res.ok && res.data.success !== false) {
311
+ $data.executionStatus = 'success';
312
+ $data.executionResult = JSON.stringify(res.data.result || res.data, null, 2);
313
+ } else {
314
+ $data.executionStatus = 'error';
315
+ $data.executionResult = res.data.error || JSON.stringify(res.data, null, 2);
316
+ }
317
+ })
318
+ .catch(function(err) {
319
+ $data.isLoading = false;
320
+ $data.executionStatus = 'error';
321
+ $data.executionResult = 'Execution error: ' + err.message;
322
+ });
323
+ ]]>
324
+ </on_click>
325
+ Run Tool (POST)
326
+ </button>
327
+ </div>
629
328
 
630
- function renderPromptWorkspace(name) {
631
- const prompt = state.prompts.find(p => p.name === name);
632
- if (!prompt) return;
633
- const ws = document.getElementById('workspace');
634
- ws.innerHTML = '<div class="card"><div class="card-header"><div class="card-title">' + prompt.name + '</div><span class="badge badge-version">Prompt</span></div>' +
635
- '<p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem;">' + (prompt.description || 'No description.') + '</p>' +
636
- '<div class="actions"><button class="btn btn-primary" onclick="getPrompt(\'' + prompt.name + '\')">Render Prompt</button></div>' +
637
- '<div id="prompt-output" style="display: none;" class="output-section"><pre id="prompt-text" class="output-pre"></pre></div></div>';
638
- }
329
+ <!-- Parameters Editor -->
330
+ <div class="flex flex-col gap-2">
331
+ <label class="text-xs font-semibold text-slate-300 flex items-center justify-between">
332
+ <span>Arguments (JSON)</span>
333
+ <span class="text-[11px] text-slate-500 font-normal">Edit parameters before running</span>
334
+ </label>
335
+ <textarea bind="toolArgsJson" rows="6" class="w-full p-3 font-mono text-xs bg-slate-900 border border-slate-800 rounded-lg text-slate-200 focus:outline-none focus:border-indigo-500 transition-colors" placeholder="{}"></textarea>
336
+ </div>
639
337
 
640
- async function getPrompt(name) {
641
- const outBox = document.getElementById('prompt-output');
642
- const outText = document.getElementById('prompt-text');
643
- outBox.style.display = 'block';
644
- outText.textContent = 'Fetching prompt...';
645
- try {
646
- const res = await fetch('/inspect/api/prompts/get', {
647
- method: 'POST',
648
- headers: { 'Content-Type': 'application/json' },
649
- body: JSON.stringify({ name })
650
- });
651
- const data = await res.json();
652
- outText.textContent = JSON.stringify(data, null, 2);
653
- } catch (err) {
654
- outText.textContent = String(err);
655
- }
656
- }
338
+ <!-- Output Viewer -->
339
+ <div class="flex flex-col gap-2">
340
+ <div class="flex items-center justify-between">
341
+ <span class="text-xs font-semibold text-slate-300">Execution Output</span>
342
+ <div class="flex items-center gap-2">
343
+ <span class="text-xs text-slate-400 font-mono">{data.executionDuration}</span>
344
+ <span class="text-[11px] font-mono px-2 py-0.5 rounded font-semibold {data.executionStatus == 'success' ? 'bg-emerald-950 text-emerald-400 border border-emerald-800' : (data.executionStatus == 'error' ? 'bg-rose-950 text-rose-400 border border-rose-800' : 'hidden')}">
345
+ {data.executionStatus == 'success' ? '200 OK' : 'ERROR'}
346
+ </span>
347
+ </div>
348
+ </div>
349
+ <pre class="p-4 rounded-lg font-mono text-xs bg-slate-900 border border-slate-800 text-slate-200 overflow-x-auto min-h-[140px] max-h-96">{data.executionResult || '// Output will appear here after execution'}</pre>
350
+ </div>
351
+ </div>
657
352
 
658
- function renderMetricsWorkspace() {
659
- const ws = document.getElementById('workspace');
660
- const a = state.analytics || {};
661
- const m = state.metrics || {};
662
-
663
- ws.innerHTML = '<div class="card"><div class="card-header"><div class="card-title">Live Server Telemetry & Metrics</div></div>' +
664
- '<div class="grid-stats">' +
665
- '<div class="stat-card"><div class="stat-label">Total Calls</div><div class="stat-value">' + (a.totalInvocations || 0) + '</div></div>' +
666
- '<div class="stat-card"><div class="stat-label">Total Errors</div><div class="stat-value" style="color: var(--error);">' + (a.totalErrors || 0) + '</div></div>' +
667
- '<div class="stat-card"><div class="stat-label">Active Sessions</div><div class="stat-value" style="color: var(--success);">' + (m.activeSessions || 0) + '</div></div>' +
668
- '<div class="stat-card"><div class="stat-label">Avg Duration</div><div class="stat-value">' + (a.avgDurationMs ? Math.round(a.avgDurationMs) + 'ms' : '0ms') + '</div></div>' +
669
- '</div>' +
670
- '<div style="margin-top: 1.5rem;"><a href="/metrics" target="_blank" class="btn btn-secondary">Open Raw Prometheus (/metrics)</a> <a href="/analytics" target="_blank" class="btn btn-secondary">Open JSON Analytics (/analytics)</a></div></div>';
671
- }
353
+ <!-- Resources Detail Panel -->
354
+ <div class="{data.activeTab == 'resources' ? 'flex flex-col gap-5' : 'hidden'}">
355
+ <div class="flex items-center justify-between pb-4 border-b border-slate-800">
356
+ <div>
357
+ <div class="text-xs text-slate-400 font-mono">Resource Inspection</div>
358
+ <h2 class="text-xl font-bold text-white font-mono mt-0.5">Read Resource</h2>
359
+ </div>
360
+ <button class="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-semibold rounded-lg shadow-sm transition-colors">
361
+ <on_click action="RUN_SCRIPT">
362
+ <![CDATA[
363
+ $data.isLoading = true;
364
+ $data.executionStatus = 'loading';
365
+ $data.executionResult = 'Reading resource ' + $data.resourceUriInput + '...';
366
+ $data.executionDuration = '';
367
+
368
+ var startTime = Date.now();
369
+ fetch('/inspect/api/resources/read', {
370
+ method: 'POST',
371
+ headers: { 'Content-Type': 'application/json' },
372
+ body: JSON.stringify({ uri: $data.resourceUriInput })
373
+ })
374
+ .then(function(res) {
375
+ return res.json().then(function(json) {
376
+ return { ok: res.ok, status: res.status, data: json };
377
+ });
378
+ })
379
+ .then(function(res) {
380
+ $data.isLoading = false;
381
+ var duration = Date.now() - startTime;
382
+ $data.executionDuration = duration + ' ms';
383
+ if (res.ok && res.data.success !== false) {
384
+ $data.executionStatus = 'success';
385
+ $data.executionResult = JSON.stringify(res.data.result || res.data, null, 2);
386
+ } else {
387
+ $data.executionStatus = 'error';
388
+ $data.executionResult = res.data.error || JSON.stringify(res.data, null, 2);
389
+ }
390
+ })
391
+ .catch(function(err) {
392
+ $data.isLoading = false;
393
+ $data.executionStatus = 'error';
394
+ $data.executionResult = 'Error: ' + err.message;
395
+ });
396
+ ]]>
397
+ </on_click>
398
+ Read Resource (POST)
399
+ </button>
400
+ </div>
401
+
402
+ <div class="flex flex-col gap-2">
403
+ <label class="text-xs font-semibold text-slate-300">Resource URI</label>
404
+ <input bind="resourceUriInput" placeholder="custom://resource/path" class="w-full px-3 py-2 font-mono text-xs bg-slate-900 border border-slate-800 rounded-lg text-slate-200 focus:outline-none focus:border-indigo-500" />
405
+ </div>
406
+
407
+ <div class="flex flex-col gap-2">
408
+ <div class="flex items-center justify-between">
409
+ <span class="text-xs font-semibold text-slate-300">Resource Payload</span>
410
+ <span class="text-xs text-slate-400 font-mono">{data.executionDuration}</span>
411
+ </div>
412
+ <pre class="p-4 rounded-lg font-mono text-xs bg-slate-900 border border-slate-800 text-slate-200 overflow-x-auto min-h-[140px] max-h-96">{data.executionResult || '// Resource contents will appear here'}</pre>
413
+ </div>
414
+ </div>
415
+
416
+ <!-- Prompts Detail Panel -->
417
+ <div class="{data.activeTab == 'prompts' ? 'flex flex-col gap-5' : 'hidden'}">
418
+ <div class="flex items-center justify-between pb-4 border-b border-slate-800">
419
+ <div>
420
+ <div class="text-xs text-slate-400 font-mono">Prompt Inspection</div>
421
+ <h2 class="text-xl font-bold text-white font-mono mt-0.5">{data.selectedPromptName}</h2>
422
+ </div>
423
+ <button class="px-4 py-2 bg-indigo-600 hover:bg-indigo-500 text-white text-xs font-semibold rounded-lg shadow-sm transition-colors">
424
+ <on_click action="RUN_SCRIPT">
425
+ <![CDATA[
426
+ $data.isLoading = true;
427
+ $data.executionStatus = 'loading';
428
+ $data.executionResult = 'Getting prompt ' + $data.selectedPromptName + '...';
429
+ $data.executionDuration = '';
430
+
431
+ var args = {};
432
+ try {
433
+ if ($data.promptArgsJson && $data.promptArgsJson.trim()) {
434
+ args = JSON.parse($data.promptArgsJson);
435
+ }
436
+ } catch (e) {
437
+ $data.isLoading = false;
438
+ $data.executionStatus = 'error';
439
+ $data.executionResult = 'Invalid JSON: ' + e.message;
440
+ return;
441
+ }
442
+
443
+ var startTime = Date.now();
444
+ fetch('/inspect/api/prompts/get', {
445
+ method: 'POST',
446
+ headers: { 'Content-Type': 'application/json' },
447
+ body: JSON.stringify({ name: $data.selectedPromptName, args: args })
448
+ })
449
+ .then(function(res) {
450
+ return res.json().then(function(json) {
451
+ return { ok: res.ok, status: res.status, data: json };
452
+ });
453
+ })
454
+ .then(function(res) {
455
+ $data.isLoading = false;
456
+ var duration = Date.now() - startTime;
457
+ $data.executionDuration = duration + ' ms';
458
+ if (res.ok && res.data.success !== false) {
459
+ $data.executionStatus = 'success';
460
+ $data.executionResult = JSON.stringify(res.data.result || res.data, null, 2);
461
+ } else {
462
+ $data.executionStatus = 'error';
463
+ $data.executionResult = res.data.error || JSON.stringify(res.data, null, 2);
464
+ }
465
+ })
466
+ .catch(function(err) {
467
+ $data.isLoading = false;
468
+ $data.executionStatus = 'error';
469
+ $data.executionResult = 'Error: ' + err.message;
470
+ });
471
+ ]]>
472
+ </on_click>
473
+ Get Prompt (POST)
474
+ </button>
475
+ </div>
476
+
477
+ <div class="flex flex-col gap-2">
478
+ <label class="text-xs font-semibold text-slate-300">Prompt Arguments (JSON)</label>
479
+ <textarea bind="promptArgsJson" rows="4" class="w-full p-3 font-mono text-xs bg-slate-900 border border-slate-800 rounded-lg text-slate-200 focus:outline-none focus:border-indigo-500" placeholder="{}"></textarea>
480
+ </div>
481
+
482
+ <div class="flex flex-col gap-2">
483
+ <div class="flex items-center justify-between">
484
+ <span class="text-xs font-semibold text-slate-300">Prompt Messages</span>
485
+ <span class="text-xs text-slate-400 font-mono">{data.executionDuration}</span>
486
+ </div>
487
+ <pre class="p-4 rounded-lg font-mono text-xs bg-slate-900 border border-slate-800 text-slate-200 overflow-x-auto min-h-[140px] max-h-96">{data.executionResult || '// Prompt messages will appear here'}</pre>
488
+ </div>
489
+ </div>
490
+
491
+ <!-- Metrics Detail Panel -->
492
+ <div class="{data.activeTab == 'metrics' ? 'flex flex-col gap-6' : 'hidden'}">
493
+ <div class="pb-4 border-b border-slate-800">
494
+ <div class="text-xs text-slate-400 font-mono">Telemetry & Health</div>
495
+ <h2 class="text-xl font-bold text-white mt-0.5">Live Server Metrics</h2>
496
+ </div>
672
497
 
673
- loadState();
498
+ <div class="grid grid-cols-2 lg:grid-cols-4 gap-4">
499
+ <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 flex flex-col gap-1">
500
+ <span class="text-xs text-slate-400 font-medium">Total Invocations</span>
501
+ <span class="text-2xl font-bold text-white font-mono">{data.totalCalls}</span>
502
+ </div>
503
+ <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 flex flex-col gap-1">
504
+ <span class="text-xs text-slate-400 font-medium">Total Errors</span>
505
+ <span class="text-2xl font-bold text-rose-400 font-mono">{data.totalErrors}</span>
506
+ </div>
507
+ <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 flex flex-col gap-1">
508
+ <span class="text-xs text-slate-400 font-medium">Active Sessions</span>
509
+ <span class="text-2xl font-bold text-emerald-400 font-mono">{data.activeSessions}</span>
510
+ </div>
511
+ <div class="p-4 rounded-xl bg-slate-900 border border-slate-800 flex flex-col gap-1">
512
+ <span class="text-xs text-slate-400 font-medium">Avg Duration</span>
513
+ <span class="text-2xl font-bold text-indigo-300 font-mono">{data.avgDurationMs} ms</span>
514
+ </div>
515
+ </div>
516
+
517
+ <div class="p-4 rounded-xl bg-slate-900/60 border border-slate-800 flex flex-col gap-3">
518
+ <span class="text-xs font-semibold text-slate-300 uppercase tracking-wider">Process Info</span>
519
+ <div class="grid grid-cols-2 gap-4 text-xs font-mono">
520
+ <div class="flex items-center justify-between p-2 rounded bg-slate-950 border border-slate-850">
521
+ <span class="text-slate-400">PID:</span>
522
+ <span class="text-slate-200">{data.serverPid}</span>
523
+ </div>
524
+ <div class="flex items-center justify-between p-2 rounded bg-slate-950 border border-slate-850">
525
+ <span class="text-slate-400">Uptime:</span>
526
+ <span class="text-slate-200">{data.serverUptime}s</span>
527
+ </div>
528
+ </div>
529
+ </div>
530
+
531
+ <div class="flex items-center gap-3 pt-2">
532
+ <a href="/metrics" target="_blank" class="px-3.5 py-2 bg-slate-900 hover:bg-slate-800 text-slate-200 text-xs font-medium rounded-lg border border-slate-800 transition-colors">
533
+ Open Raw Prometheus (/metrics)
534
+ </a>
535
+ <a href="/analytics" target="_blank" class="px-3.5 py-2 bg-slate-900 hover:bg-slate-800 text-slate-200 text-xs font-medium rounded-lg border border-slate-800 transition-colors">
536
+ Open JSON Analytics (/analytics)
537
+ </a>
538
+ <a href="/inspect/api/state" target="_blank" class="px-3.5 py-2 bg-slate-900 hover:bg-slate-800 text-slate-200 text-xs font-medium rounded-lg border border-slate-800 transition-colors">
539
+ Open State JSON (/inspect/api/state)
540
+ </a>
541
+ </div>
542
+ </div>
543
+ </main>
544
+ </div>
545
+ </div>
546
+ </uid_spec>
547
+ </script>
548
+
549
+ <script>
550
+ (function() {
551
+ function bootstrap() {
552
+ var specEl = document.getElementById('euix-spec');
553
+ if (!specEl) return;
554
+ var xml = specEl.textContent || specEl.innerText;
555
+ var container = document.getElementById('app');
556
+
557
+ var engine = window.EUIXEngine && (window.EUIXEngine.EUIXEngine || window.EUIXEngine.default || window.EUIXEngine);
558
+ if (engine && typeof engine.mount === 'function') {
559
+ container.innerHTML = '';
560
+ try {
561
+ engine.mount(xml, container);
562
+ } catch (err) {
563
+ console.error('EUIX mount error:', err);
564
+ container.innerHTML = '<div class="p-8 text-rose-400 font-mono text-sm">Failed to mount EUIX Engine: ' + err.message + '</div>';
565
+ }
566
+ } else {
567
+ console.warn('EUIXEngine not found on window');
568
+ var loadingEl = document.getElementById('fallback-loading');
569
+ if (loadingEl) {
570
+ loadingEl.innerHTML = '<div class="p-6 text-center text-slate-300 font-sans">' +
571
+ '<div class="text-base font-semibold text-amber-400 mb-2">EUIX Engine CDN Offline or Blocked</div>' +
572
+ '<p class="text-xs text-slate-400 max-w-md mx-auto">Inspector UI requires unpkg CDN to load EUIXEngine.umd.js. Check network connection or proxy settings.</p>' +
573
+ '<div class="mt-4"><a href="/inspect/api/state" class="px-3 py-1.5 bg-slate-800 hover:bg-slate-700 text-slate-200 rounded text-xs">View Raw JSON State (/inspect/api/state)</a></div>' +
574
+ '</div>';
575
+ }
576
+ }
577
+ }
578
+
579
+ if (document.readyState === 'loading') {
580
+ document.addEventListener('DOMContentLoaded', bootstrap);
581
+ } else {
582
+ bootstrap();
583
+ }
584
+ })();
674
585
  </script>
675
586
  </body>
676
587
  </html>`;