-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_dashboard.html
More file actions
380 lines (360 loc) · 13.8 KB
/
demo_dashboard.html
File metadata and controls
380 lines (360 loc) · 13.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lexecon Demo - Governance Proof Chain</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--bg: #0f172a;
--card: #1e293b;
--border: #334155;
--text: #f1f5f9;
--muted: #94a3b8;
--primary: #0891b2;
--success: #10b981;
--warning: #f59e0b;
--danger: #dc2626;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: var(--bg);
color: var(--text);
line-height: 1.6;
min-height: 100vh;
}
.container { max-width: 1200px; margin: 0 auto; padding: 40px 20px; }
header { text-align: center; margin-bottom: 40px; }
header h1 { font-size: 32px; font-weight: 600; margin-bottom: 8px; }
header p { color: var(--muted); font-size: 16px; }
.flow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 40px; }
@media (max-width: 900px) { .flow { grid-template-columns: 1fr; } }
.step {
background: var(--card);
border: 1px solid var(--border);
border-radius: 12px;
padding: 24px;
text-align: center;
position: relative;
}
.step::after {
content: "→";
position: absolute;
right: -16px;
top: 50%;
transform: translateY(-50%);
color: var(--primary);
font-size: 20px;
font-weight: bold;
}
.step:last-child::after { display: none; }
@media (max-width: 900px) {
.step::after { content: "↓"; right: 50%; top: 100%; transform: translateX(50%); }
}
.step-num {
width: 32px;
height: 32px;
background: var(--primary);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
font-size: 14px;
margin: 0 auto 12px;
}
.step h3 { font-size: 16px; margin-bottom: 4px; }
.step p { font-size: 13px; color: var(--muted); }
.demo-area {
background: var(--card);
border: 1px solid var(--border);
border-radius: 12px;
padding: 32px;
}
.section { margin-bottom: 32px; }
.section:last-child { margin-bottom: 0; }
.section h2 {
font-size: 18px;
font-weight: 600;
margin-bottom: 16px;
display: flex;
align-items: center;
gap: 8px;
}
.form-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
margin-bottom: 16px;
}
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
label {
display: block;
font-size: 13px;
font-weight: 500;
margin-bottom: 6px;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.5px;
}
input, select, textarea {
width: 100%;
padding: 10px 12px;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text);
font-size: 14px;
font-family: inherit;
}
input:focus, select:focus, textarea:focus {
outline: none;
border-color: var(--primary);
}
textarea { min-height: 80px; resize: vertical; }
button {
background: var(--primary);
color: white;
border: none;
padding: 12px 24px;
border-radius: 8px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: opacity 0.2s;
}
button:hover { opacity: 0.9; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.result {
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
padding: 16px;
margin-top: 16px;
font-family: 'SF Mono', Monaco, monospace;
font-size: 12px;
overflow-x: auto;
white-space: pre-wrap;
word-break: break-all;
}
.result:empty { display: none; }
.status-allow { color: var(--success); }
.status-deny { color: var(--danger); }
.status-escalate { color: var(--warning); }
.ledger-entry {
border-left: 3px solid var(--primary);
padding-left: 12px;
margin: 8px 0;
}
.hash {
font-family: 'SF Mono', Monaco, monospace;
font-size: 11px;
color: var(--muted);
word-break: break-all;
}
.badge {
display: inline-block;
padding: 2px 8px;
border-radius: 4px;
font-size: 11px;
font-weight: 600;
text-transform: uppercase;
}
.badge-success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge-danger { background: rgba(220, 38, 38, 0.2); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.empty-state {
text-align: center;
padding: 40px;
color: var(--muted);
}
.spinner {
display: inline-block;
width: 16px;
height: 16px;
border: 2px solid var(--border);
border-top-color: var(--primary);
border-radius: 50%;
animation: spin 1s linear infinite;
margin-right: 8px;
vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
</style>
</head>
<body>
<div class="container">
<header>
<h1>🔐 Lexecon Demo</h1>
<p>Cryptographic governance for AI tool execution</p>
</header>
<div class="flow">
<div class="step">
<div class="step-num">1</div>
<h3>Capability</h3>
<p>Issue cryptographic credential</p>
</div>
<div class="step">
<div class="step-num">2</div>
<h3>Policy</h3>
<p>Evaluate against governance rules</p>
</div>
<div class="step">
<div class="step-num">3</div>
<h3>Execution</h3>
<p>Invoke tool with constraints</p>
</div>
<div class="step">
<div class="step-num">4</div>
<h3>Proof</h3>
<p>Append-only ledger entry</p>
</div>
</div>
<div class="demo-area">
<div class="section">
<h2>🚀 Execute Request</h2>
<div class="form-row">
<div>
<label>Actor</label>
<input type="text" id="actor" value="user:alice@example.com" placeholder="user:alice@example.com">
</div>
<div>
<label>Tool</label>
<input type="text" id="tool" value="file:read" placeholder="file:read">
</div>
</div>
<div class="form-row">
<div>
<label>Action</label>
<input type="text" id="action" value="read_document" placeholder="read_document">
</div>
<div>
<label>Risk Level</label>
<select id="risk">
<option value="1">Low (1)</option>
<option value="2" selected>Medium (2)</option>
<option value="3">High (3)</option>
<option value="4">Critical (4)</option>
<option value="5">Severe (5)</option>
</select>
</div>
</div>
<div>
<label>User Intent</label>
<textarea id="intent" placeholder="Describe what the user is trying to accomplish...">Retrieve quarterly financial report for analysis</textarea>
</div>
<div style="margin-top: 16px;">
<button id="executeBtn" onclick="executeRequest()">
Execute Governance Flow
</button>
</div>
<div id="result" class="result"></div>
</div>
<div class="section">
<h2>📜 Ledger Entries</h2>
<div id="ledger">
<div class="empty-state">No entries yet. Execute a request to see the proof chain.</div>
</div>
<div style="margin-top: 16px;">
<button onclick="refreshLedger()">Refresh Ledger</button>
<button onclick="seedData()" style="margin-left: 8px; background: var(--border);">Seed Demo Data</button>
</div>
</div>
</div>
</div>
<script>
const API_BASE = window.location.origin;
async function executeRequest() {
const btn = document.getElementById('executeBtn');
const result = document.getElementById('result');
btn.disabled = true;
btn.innerHTML = '<span class="spinner"></span>Processing...';
result.textContent = '';
const request = {
actor: document.getElementById('actor').value,
proposed_action: document.getElementById('action').value,
tool: document.getElementById('tool').value,
user_intent: document.getElementById('intent').value,
risk_level: parseInt(document.getElementById('risk').value),
data_classes: [],
requested_output_type: 'tool_action',
policy_mode: 'strict',
context: { timestamp: new Date().toISOString() }
};
try {
const response = await fetch(`${API_BASE}/decide`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(request)
});
const data = await response.json();
let statusClass = 'status-escalate';
if (data.decision === 'allow') statusClass = 'status-allow';
if (data.decision === 'deny') statusClass = 'status-deny';
result.innerHTML = `
<strong>Decision:</strong> <span class="${statusClass}">${data.decision.toUpperCase()}</span>
<strong>Confidence:</strong> ${(data.confidence * 100).toFixed(1)}%
<strong>Ledger Hash:</strong> <span class="hash">${data.ledger_entry_hash || 'N/A'}</span>
<strong>Reasoning:</strong> ${data.reasoning || 'No reasoning provided'}
<strong>Full Response:</strong>
${JSON.stringify(data, null, 2)}
`.trim();
refreshLedger();
} catch (err) {
result.innerHTML = `<span class="status-deny">Error: ${err.message}</span>`;
} finally {
btn.disabled = false;
btn.textContent = 'Execute Governance Flow';
}
}
async function refreshLedger() {
const ledger = document.getElementById('ledger');
try {
const response = await fetch(`${API_BASE}/ledger/entries?limit=10`);
const data = await response.json();
if (!data.entries || data.entries.length === 0) {
ledger.innerHTML = '<div class="empty-state">No entries in ledger.</div>';
return;
}
ledger.innerHTML = data.entries.slice().reverse().map(entry => {
const time = new Date(entry.timestamp).toLocaleString();
let badge = '';
if (entry.event_type === 'decision') {
const decision = entry.data?.decision || 'unknown';
const badgeClass = decision === 'allow' ? 'badge-success' :
decision === 'deny' ? 'badge-danger' : 'badge-warning';
badge = `<span class="badge ${badgeClass}">${decision}</span>`;
}
return `
<div class="ledger-entry">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px;">
<strong>${entry.event_type}</strong>
${badge}
<span style="color: var(--muted); font-size: 12px;">${time}</span>
</div>
<div class="hash">${entry.entry_hash}</div>
</div>
`;
}).join('');
} catch (err) {
ledger.innerHTML = `<div class="empty-state">Error loading ledger: ${err.message}</div>`;
}
}
async function seedData() {
const btn = event.target;
btn.disabled = true;
try {
await fetch(`${API_BASE}/demo/seed`, { method: 'POST' });
refreshLedger();
} catch (err) {
console.error('Failed to seed:', err);
} finally {
btn.disabled = false;
}
}
// Load ledger on page load
refreshLedger();
</script>
</body>
</html>