fraudTech commited on
Commit
481feb4
·
0 Parent(s):

Deploy frontend to Hugging Face Spaces

Browse files
.gitignore ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ node_modules
2
+ dist
3
+ *.log
4
+ .env
5
+ .env.local
6
+ .env.development.local
7
+ .env.test.local
8
+ .env.production.local
9
+ .DS_Store
10
+ *.swp
11
+ *.swo
12
+ *~
13
+ .vscode
14
+ .idea
Dockerfile ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Frontend Dockerfile
2
+ FROM node:20-alpine AS builder
3
+
4
+ WORKDIR /app
5
+
6
+ # Copy package files
7
+ COPY web/package*.json ./
8
+ RUN npm ci
9
+
10
+ # Copy source code
11
+ COPY web/ ./
12
+
13
+ # Build the app
14
+ RUN npm run build
15
+
16
+ # Production stage - serve with nginx
17
+ FROM nginx:alpine
18
+
19
+ # Copy built files
20
+ COPY --from=builder /app/dist /usr/share/nginx/html
21
+
22
+ # Copy nginx configuration
23
+ COPY web/nginx.conf /etc/nginx/conf.d/default.conf
24
+
25
+ EXPOSE 7860
26
+
27
+ CMD ["nginx", "-g", "daemon off;"]
28
+
29
+ # In Dockerfile, before npm run build, add:
30
+ ARG GATEWAY_URL=https://YOUR_USERNAME-evo-gateway.hf.space/api
31
+ ENV VITE_GATEWAY_URL=$GATEWAY_URL
package-lock.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "name": "evo-frontend-deploy",
3
+ "lockfileVersion": 3,
4
+ "requires": true,
5
+ "packages": {}
6
+ }
web/.env.development ADDED
@@ -0,0 +1 @@
 
 
1
+ VITE_GATEWAY_URL=http://localhost:3001/api
web/.env.production ADDED
@@ -0,0 +1 @@
 
 
1
+ VITE_GATEWAY_URL=/api
web/.gitignore ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ node_modules
2
+ dist
3
+ *.log
4
+ .env.local
5
+ .env.development.local
6
+ .env.test.local
7
+ .env.production.local
8
+ .DS_Store
web/index.html ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>EVO - Web Interface</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
web/nginx.conf ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ server {
2
+ listen 7860;
3
+ server_name _;
4
+ root /usr/share/nginx/html;
5
+ index index.html;
6
+
7
+ # Gzip compression
8
+ gzip on;
9
+ gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
10
+
11
+ # Security headers
12
+ add_header X-Frame-Options "SAMEORIGIN" always;
13
+ add_header X-Content-Type-Options "nosniff" always;
14
+ add_header X-XSS-Protection "1; mode=block" always;
15
+
16
+ # SPA routing - serve index.html for all routes
17
+ location / {
18
+ try_files $uri $uri/ /index.html;
19
+ }
20
+
21
+ # Cache static assets
22
+ location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
23
+ expires 1y;
24
+ add_header Cache-Control "public, immutable";
25
+ }
26
+
27
+ # Don't cache index.html
28
+ location = /index.html {
29
+ add_header Cache-Control "no-cache, no-store, must-revalidate";
30
+ }
31
+ }
web/package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
web/package.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ai-agent-web",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc && vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "react": "^18.2.0",
13
+ "react-dom": "^18.2.0",
14
+ "react-markdown": "^9.0.1",
15
+ "react-syntax-highlighter": "^15.5.0",
16
+ "axios": "^1.6.2"
17
+ },
18
+ "devDependencies": {
19
+ "@types/react": "^18.2.43",
20
+ "@types/react-dom": "^18.2.17",
21
+ "@types/react-syntax-highlighter": "^15.5.11",
22
+ "@vitejs/plugin-react": "^4.2.1",
23
+ "typescript": "^5.3.3",
24
+ "vite": "^5.0.8"
25
+ }
26
+ }
web/src/App.css ADDED
@@ -0,0 +1,829 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ * {
2
+ margin: 0;
3
+ padding: 0;
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ strong, b, [style*="font-weight: 700"], [style*="font-weight: bold"] {
8
+ color: #e8d4c0 !important;
9
+ font-weight: 600;
10
+ }
11
+
12
+ body {
13
+ font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
14
+ -webkit-font-smoothing: auto;
15
+ -moz-osx-font-smoothing: auto;
16
+ background: #1a1614;
17
+ color: #d4c5b9;
18
+ overflow: hidden;
19
+ height: 100vh;
20
+ }
21
+
22
+ @keyframes flicker {
23
+ 0% { opacity: 0.98; }
24
+ 50% { opacity: 1; }
25
+ 100% { opacity: 0.98; }
26
+ }
27
+
28
+ #root {
29
+ height: 100vh;
30
+ overflow: hidden;
31
+ }
32
+
33
+ .app {
34
+ display: flex;
35
+ flex-direction: column;
36
+ height: 100vh;
37
+ background: #1a1614;
38
+ position: relative;
39
+ overflow: hidden;
40
+ }
41
+
42
+ /* Remove CRT effects */
43
+ .app::before,
44
+ .app::after {
45
+ display: none;
46
+ }
47
+
48
+ @keyframes scanline {
49
+ 0% {
50
+ transform: translateY(0);
51
+ }
52
+ 100% {
53
+ transform: translateY(10px);
54
+ }
55
+ }
56
+
57
+ @keyframes flicker {
58
+ 0%, 100% {
59
+ opacity: 0.8;
60
+ }
61
+ 50% {
62
+ opacity: 1;
63
+ }
64
+ }
65
+
66
+ .header {
67
+ background: #211d1a;
68
+ padding: 1rem 1.5rem;
69
+ border-bottom: 1px solid #3a342e;
70
+ display: flex;
71
+ justify-content: space-between;
72
+ align-items: center;
73
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
74
+ }
75
+
76
+ .header-left {
77
+ display: flex;
78
+ align-items: center;
79
+ gap: 1rem;
80
+ }
81
+
82
+ .header h1 {
83
+ font-size: 1.5rem;
84
+ font-weight: 600;
85
+ color: #e8d4c0;
86
+ letter-spacing: 2px;
87
+ text-shadow: 0 0 5px rgba(232, 212, 192, 0.5);
88
+ }
89
+
90
+ @keyframes textGlow {
91
+ from {
92
+ text-shadow: 0 0 5px rgba(232, 212, 192, 0.5), 0 0 10px rgba(232, 212, 192, 0.3);
93
+ }
94
+ to {
95
+ text-shadow: 0 0 10px rgba(232, 212, 192, 0.8), 0 0 20px rgba(232, 212, 192, 0.4);
96
+ }
97
+ }
98
+
99
+ .header h1::before {
100
+ content: '> ';
101
+ color: #e8d4c0;
102
+ animation: textGlow 2s ease-in-out infinite alternate;
103
+ }
104
+
105
+ .version {
106
+ background: #2a2520;
107
+ color: #a89784;
108
+ padding: 0.25rem 0.75rem;
109
+ font-size: 0.75rem;
110
+ font-weight: 500;
111
+ border-radius: 4px;
112
+ border: 1px solid #3a342e;
113
+ }
114
+
115
+ .header-actions {
116
+ display: flex;
117
+ gap: 1rem;
118
+ align-items: center;
119
+ }
120
+
121
+ .tools-badge {
122
+ background: #2a2520;
123
+ color: #c9b8a3;
124
+ padding: 0.5rem 1rem;
125
+ font-size: 0.875rem;
126
+ font-weight: 500;
127
+ border-radius: 6px;
128
+ border: 1px solid #3a342e;
129
+ }
130
+
131
+ .settings-btn {
132
+ background: #2a2520;
133
+ border: 1px solid #3a342e;
134
+ color: #c9b8a3;
135
+ padding: 0.5rem 1rem;
136
+ cursor: pointer;
137
+ font-size: 0.9rem;
138
+ font-weight: 500;
139
+ transition: all 0.2s ease;
140
+ display: flex;
141
+ align-items: center;
142
+ gap: 0.5rem;
143
+ border-radius: 6px;
144
+ }
145
+
146
+ .settings-btn:hover {
147
+ background: #3a342e;
148
+ color: #e8d4c0;
149
+ border-color: #4a433c;
150
+ }
151
+
152
+ .settings-btn:active {
153
+ transform: scale(0.98);
154
+ }
155
+
156
+ .icon-settings {
157
+ font-size: 1rem;
158
+ }
159
+
160
+ .settings-panel {
161
+ background: #211d1a;
162
+ padding: 1.5rem;
163
+ border-bottom: 1px solid #3a342e;
164
+ }
165
+
166
+ .settings-panel h3 {
167
+ color: #e8d4c0;
168
+ margin-bottom: 1rem;
169
+ font-weight: 600;
170
+ font-size: 1rem;
171
+ }
172
+
173
+ .settings-panel h3::before {
174
+ content: '';
175
+ margin-right: 0;
176
+ }
177
+
178
+ .settings-panel h3::after {
179
+ content: '';
180
+ margin-left: 0;
181
+ }
182
+
183
+ .setting-group {
184
+ display: flex;
185
+ gap: 1rem;
186
+ align-items: center;
187
+ margin-bottom: 1rem;
188
+ }
189
+
190
+ .setting-group label {
191
+ min-width: 150px;
192
+ font-weight: 500;
193
+ color: #c9b8a3;
194
+ }
195
+
196
+ .setting-group input {
197
+ flex: 1;
198
+ padding: 0.625rem;
199
+ background: #2a2520;
200
+ border: 1px solid #3a342e;
201
+ color: #d4c5b9;
202
+ font-size: 0.9rem;
203
+ border-radius: 6px;
204
+ transition: all 0.2s ease;
205
+ }
206
+
207
+ .setting-group input:focus {
208
+ outline: none;
209
+ border-color: #8b7355;
210
+ background: #312c27;
211
+ }
212
+
213
+ .save-btn {
214
+ background: #8b7355;
215
+ color: #1a1614;
216
+ border: none;
217
+ padding: 0.625rem 1.5rem;
218
+ cursor: pointer;
219
+ font-weight: 500;
220
+ font-size: 0.9rem;
221
+ transition: all 0.2s ease;
222
+ border-radius: 6px;
223
+ }
224
+
225
+ .save-btn:hover {
226
+ background: #9d8264;
227
+ }
228
+
229
+ .save-btn:active {
230
+ transform: scale(0.98);
231
+ }
232
+
233
+ .available-tools {
234
+ background: #211d1a;
235
+ padding: 1.5rem;
236
+ border-bottom: 1px solid #3a342e;
237
+ }
238
+
239
+ .available-tools h4 {
240
+ color: #e8d4c0;
241
+ margin-bottom: 1rem;
242
+ font-weight: 600;
243
+ font-size: 1rem;
244
+ }
245
+
246
+ .available-tools h4::before {
247
+ content: '';
248
+ margin-right: 0;
249
+ }
250
+
251
+ .available-tools h4::after {
252
+ content: '';
253
+ margin-left: 0;
254
+ }
255
+
256
+ .tools-grid {
257
+ display: flex;
258
+ flex-wrap: wrap;
259
+ gap: 0.5rem;
260
+ }
261
+
262
+ .tool-chip {
263
+ background: #2a2520;
264
+ padding: 0.375rem 0.875rem;
265
+ font-size: 0.8rem;
266
+ color: #c9b8a3;
267
+ font-weight: 500;
268
+ border: 1px solid #3a342e;
269
+ border-radius: 4px;
270
+ }
271
+
272
+ .chat-container {
273
+ flex: 1;
274
+ display: flex;
275
+ flex-direction: column;
276
+ overflow: hidden;
277
+ background: #1a1614;
278
+ }
279
+
280
+ .messages {
281
+ flex: 1;
282
+ overflow-y: auto;
283
+ padding: 1.5rem;
284
+ display: flex;
285
+ flex-direction: column;
286
+ gap: 1rem;
287
+ scrollbar-width: thin;
288
+ scrollbar-color: #3a342e #211d1a;
289
+ }
290
+
291
+ .messages::-webkit-scrollbar {
292
+ width: 10px;
293
+ }
294
+
295
+ .messages::-webkit-scrollbar-track {
296
+ background: #211d1a;
297
+ }
298
+
299
+ .messages::-webkit-scrollbar-thumb {
300
+ background: #3a342e;
301
+ border-radius: 5px;
302
+ }
303
+
304
+ .messages::-webkit-scrollbar-thumb:hover {
305
+ background: #4a433c;
306
+ }
307
+
308
+ .welcome {
309
+ text-align: center;
310
+ padding: 4rem 2rem;
311
+ }
312
+
313
+ .welcome h2 {
314
+ color: #e8d4c0;
315
+ margin-bottom: 1rem;
316
+ font-size: 2rem;
317
+ font-weight: 600;
318
+ }
319
+
320
+ .welcome h2::before {
321
+ content: '';
322
+ }
323
+
324
+ .welcome h2::after {
325
+ content: '';
326
+ }
327
+
328
+ .welcome p {
329
+ color: #a89784;
330
+ font-size: 1rem;
331
+ }
332
+
333
+ .examples {
334
+ margin-top: 2rem;
335
+ }
336
+
337
+ .examples h3 {
338
+ margin-bottom: 1.5rem;
339
+ color: #c9b8a3;
340
+ font-weight: 600;
341
+ font-size: 1rem;
342
+ }
343
+
344
+ .example-btn {
345
+ background: #2a2520;
346
+ border: 1px solid #3a342e;
347
+ color: #c9b8a3;
348
+ padding: 0.75rem 1.5rem;
349
+ margin: 0.5rem;
350
+ cursor: pointer;
351
+ transition: all 0.2s ease;
352
+ font-weight: 500;
353
+ font-size: 0.9rem;
354
+ border-radius: 6px;
355
+ }
356
+
357
+ .example-btn:hover {
358
+ background: #3a342e;
359
+ color: #e8d4c0;
360
+ border-color: #4a433c;
361
+ }
362
+
363
+ .example-btn:active {
364
+ transform: scale(0.98);
365
+ }
366
+
367
+ .message {
368
+ max-width: 800px;
369
+ padding: 1.25rem 1.5rem;
370
+ border: 1px solid #3a342e;
371
+ background: #211d1a;
372
+ border-radius: 2px;
373
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
374
+ }
375
+
376
+ .message-user {
377
+ align-self: flex-end;
378
+ margin-left: auto;
379
+ background: #2a2520;
380
+ }
381
+
382
+ .message-user::before {
383
+ content: '';
384
+ margin-right: 0;
385
+ }
386
+
387
+ .message-assistant {
388
+ align-self: flex-start;
389
+ }
390
+
391
+ .message-assistant::before {
392
+ content: '';
393
+ margin-right: 0;
394
+ }
395
+
396
+ .message-header {
397
+ display: flex;
398
+ justify-content: space-between;
399
+ margin-bottom: 0.75rem;
400
+ font-size: 0.8rem;
401
+ padding-bottom: 0.5rem;
402
+ border-bottom: 1px solid #3a342e;
403
+ gap: 2rem;
404
+ }
405
+
406
+ .message-role {
407
+ font-weight: 600;
408
+ color: #8b7355;
409
+ text-transform: uppercase;
410
+ font-size: 0.75rem;
411
+ letter-spacing: 0.5px;
412
+ }
413
+
414
+ .message-time {
415
+ color: #6e5d4d;
416
+ opacity: 0.8;
417
+ }
418
+
419
+ .message-content {
420
+ line-height: 1.7;
421
+ color: #d4c5b9;
422
+ }
423
+
424
+ .message-content h1,
425
+ .message-content h2,
426
+ .message-content h3,
427
+ .message-content h4,
428
+ .message-content h5,
429
+ .message-content h6,
430
+ .message-content strong,
431
+ .message-content b {
432
+ color: #f4e6d0;
433
+ font-weight: 600;
434
+ }
435
+
436
+ .message-content pre {
437
+ background: #1a1614;
438
+ padding: 1rem;
439
+ overflow-x: auto;
440
+ margin: 0.75rem 0;
441
+ border: 1px solid #3a342e;
442
+ border-radius: 6px;
443
+ }
444
+
445
+ .message-content code {
446
+ background: #2a2520;
447
+ padding: 0.2rem 0.5rem;
448
+ font-size: 0.9em;
449
+ border-radius: 3px;
450
+ color: #c9b8a3;
451
+ font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
452
+ }
453
+
454
+ .tool-calls {
455
+ margin-top: 1rem;
456
+ padding-top: 1rem;
457
+ border-top: 1px solid #3a342e;
458
+ }
459
+
460
+ .tool-calls h4 {
461
+ margin-bottom: 0.75rem;
462
+ color: #8b7355;
463
+ font-size: 0.85rem;
464
+ font-weight: 600;
465
+ text-transform: uppercase;
466
+ letter-spacing: 0.5px;
467
+ }
468
+
469
+ .tool-call {
470
+ background: #1a1614;
471
+ padding: 1rem;
472
+ margin-top: 0.5rem;
473
+ border: 1px solid #3a342e;
474
+ border-radius: 6px;
475
+ }
476
+
477
+ .tool-name {
478
+ color: #8b7355;
479
+ font-weight: 600;
480
+ margin-bottom: 0.5rem;
481
+ font-size: 0.9rem;
482
+ }
483
+
484
+ .tool-name::before {
485
+ content: '';
486
+ }
487
+
488
+ .tool-details {
489
+ font-size: 0.85rem;
490
+ }
491
+
492
+ .tool-details summary {
493
+ cursor: pointer;
494
+ color: #a89784;
495
+ padding: 0.5rem 0;
496
+ font-weight: 500;
497
+ }
498
+
499
+ .tool-input, .tool-output {
500
+ margin-top: 0.5rem;
501
+ }
502
+
503
+ .tool-input pre, .tool-output pre {
504
+ background: #211d1a;
505
+ padding: 0.75rem;
506
+ overflow-x: auto;
507
+ font-size: 0.85rem;
508
+ border: 1px solid #3a342e;
509
+ color: #c9b8a3;
510
+ border-radius: 4px;
511
+ font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Consolas', monospace;
512
+ }
513
+
514
+ .typing-indicator {
515
+ display: flex;
516
+ align-items: center;
517
+ gap: 0.5rem;
518
+ padding: 1rem 0;
519
+ }
520
+
521
+ .typing-indicator span {
522
+ width: 8px;
523
+ height: 8px;
524
+ background: #8b7355;
525
+ border-radius: 50%;
526
+ animation: typing 1.4s infinite;
527
+ }
528
+
529
+ .typing-indicator span:nth-child(2) {
530
+ animation-delay: 0.2s;
531
+ }
532
+
533
+ .typing-indicator span:nth-child(3) {
534
+ animation-delay: 0.4s;
535
+ }
536
+
537
+ .status-message {
538
+ margin-left: 0.5rem;
539
+ color: #9d8264;
540
+ font-size: 0.9rem;
541
+ font-style: italic;
542
+ opacity: 0.9;
543
+ }
544
+
545
+ @keyframes typing {
546
+ 0%, 60%, 100% {
547
+ transform: translateY(0);
548
+ opacity: 0.5;
549
+ }
550
+ 30% {
551
+ transform: translateY(-10px);
552
+ opacity: 1;
553
+ }
554
+ }
555
+
556
+ .input-container {
557
+ background: #211d1a;
558
+ padding: 1.25rem 1.5rem;
559
+ border-top: 1px solid #3a342e;
560
+ display: flex;
561
+ gap: 1rem;
562
+ box-shadow: 0 -1px 3px rgba(0, 0, 0, 0.2);
563
+ }
564
+
565
+ .input-container textarea {
566
+ flex: 1;
567
+ padding: 0.875rem;
568
+ background: #2a2520;
569
+ border: 1px solid #3a342e;
570
+ color: #d4c5b9;
571
+ resize: none;
572
+ font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
573
+ font-size: 0.95rem;
574
+ line-height: 1.5;
575
+ border-radius: 2px;
576
+ transition: all 0.2s ease;
577
+ letter-spacing: 0.5px;
578
+ }
579
+
580
+ .input-container textarea:focus {
581
+ outline: none;
582
+ border-color: #8b7355;
583
+ background: #312c27;
584
+ box-shadow: 0 0 8px rgba(139, 115, 85, 0.4);
585
+ }
586
+
587
+ .input-container textarea::placeholder {
588
+ color: #6e5d4d;
589
+ }
590
+
591
+ .send-btn {
592
+ background: #8b7355;
593
+ color: #1a1614;
594
+ border: none;
595
+ padding: 0.875rem 2rem;
596
+ cursor: pointer;
597
+ font-size: 0.95rem;
598
+ font-weight: 600;
599
+ transition: all 0.2s ease;
600
+ border-radius: 8px;
601
+ }
602
+
603
+ .send-btn:hover:not(:disabled) {
604
+ background: #9d8264;
605
+ }
606
+
607
+ .send-btn:active:not(:disabled) {
608
+ transform: scale(0.98);
609
+ }
610
+
611
+ .send-btn:disabled {
612
+ opacity: 0.5;
613
+ cursor: not-allowed;
614
+ background: #4a433c;
615
+ }
616
+
617
+ /* Login Page Styles */
618
+ .login-container {
619
+ display: flex;
620
+ justify-content: center;
621
+ align-items: center;
622
+ height: 100vh;
623
+ background: #1a1614;
624
+ padding: 2rem;
625
+ }
626
+
627
+ .login-container::before {
628
+ display: none;
629
+ }
630
+
631
+ .login-box {
632
+ background: #211d1a;
633
+ border: 1px solid #3a342e;
634
+ padding: 2.5rem;
635
+ max-width: 420px;
636
+ width: 100%;
637
+ border-radius: 12px;
638
+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
639
+ }
640
+
641
+ .login-header {
642
+ text-align: center;
643
+ margin-bottom: 2rem;
644
+ border-bottom: 1px solid #3a342e;
645
+ padding-bottom: 1.5rem;
646
+ }
647
+
648
+ .login-header h1 {
649
+ font-size: 2rem;
650
+ color: #e8d4c0;
651
+ margin-bottom: 0.5rem;
652
+ font-weight: 600;
653
+ }
654
+
655
+ .login-subtitle {
656
+ color: #a89784;
657
+ font-size: 0.9rem;
658
+ }
659
+
660
+ .login-form {
661
+ display: flex;
662
+ flex-direction: column;
663
+ gap: 1.5rem;
664
+ }
665
+
666
+ .form-group {
667
+ display: flex;
668
+ flex-direction: column;
669
+ gap: 0.5rem;
670
+ }
671
+
672
+ .form-group label {
673
+ color: #c9b8a3;
674
+ font-size: 0.9rem;
675
+ font-weight: 500;
676
+ }
677
+
678
+ .form-group input {
679
+ padding: 0.875rem;
680
+ background: #2a2520;
681
+ border: 1px solid #3a342e;
682
+ color: #d4c5b9;
683
+ font-size: 1rem;
684
+ transition: all 0.2s ease;
685
+ border-radius: 2px;
686
+ font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
687
+ letter-spacing: 0.5px;
688
+ }
689
+
690
+ .form-group input:focus {
691
+ outline: none;
692
+ border-color: #8b7355;
693
+ background: #312c27;
694
+ box-shadow: 0 0 8px rgba(139, 115, 85, 0.4);
695
+ }
696
+
697
+ .form-group input::placeholder {
698
+ color: #6e5d4d;
699
+ }
700
+
701
+ .error-message {
702
+ background: #2d1a1a;
703
+ border: 1px solid #8b4545;
704
+ color: #d4a3a3;
705
+ padding: 0.875rem;
706
+ font-size: 0.9rem;
707
+ text-align: center;
708
+ border-radius: 6px;
709
+ }
710
+
711
+ @keyframes errorPulse {
712
+ from {
713
+ box-shadow: 0 0 3px rgba(139, 69, 69, 0.3);
714
+ }
715
+ to {
716
+ box-shadow: 0 0 8px rgba(139, 69, 69, 0.5);
717
+ }
718
+ }
719
+
720
+ .login-btn {
721
+ background: #8b7355;
722
+ color: #1a1614;
723
+ border: 1px solid #a89784;
724
+ padding: 0.875rem;
725
+ font-size: 1rem;
726
+ font-weight: 600;
727
+ cursor: pointer;
728
+ transition: all 0.2s ease;
729
+ margin-top: 0.5rem;
730
+ border-radius: 2px;
731
+ font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
732
+ text-transform: uppercase;
733
+ letter-spacing: 1px;
734
+ }
735
+
736
+ .login-btn:hover:not(:disabled) {
737
+ background: #9d8264;
738
+ box-shadow: 0 0 10px rgba(157, 130, 100, 0.6);
739
+ text-shadow: 0 0 5px rgba(26, 22, 20, 0.8);
740
+ }
741
+
742
+ .login-btn:active:not(:disabled) {
743
+ transform: scale(0.98);
744
+ }
745
+
746
+ .login-btn:disabled {
747
+ opacity: 0.5;
748
+ cursor: not-allowed;
749
+ background: #4a433c;
750
+ }
751
+
752
+ .login-footer {
753
+ margin-top: 1.5rem;
754
+ text-align: center;
755
+ padding-top: 1rem;
756
+ border-top: 1px solid #3a342e;
757
+ }
758
+
759
+ .toggle-mode {
760
+ background: transparent;
761
+ border: none;
762
+ color: #8b7355;
763
+ font-size: 0.9rem;
764
+ cursor: pointer;
765
+ text-decoration: underline;
766
+ transition: all 0.2s ease;
767
+ }
768
+
769
+ .toggle-mode:hover {
770
+ color: #9d8264;
771
+ }
772
+
773
+ .demo-info {
774
+ margin-top: 1.5rem;
775
+ padding: 1rem;
776
+ background: #2a2520;
777
+ border: 1px solid #3a342e;
778
+ font-size: 0.85rem;
779
+ color: #a89784;
780
+ text-align: center;
781
+ border-radius: 6px;
782
+ }
783
+
784
+ .demo-info p {
785
+ margin: 0.25rem 0;
786
+ }
787
+
788
+ .demo-info strong {
789
+ color: #c9b8a3 !important;
790
+ font-weight: 600;
791
+ }
792
+
793
+ /* Header User Info */
794
+ .header-right {
795
+ display: flex;
796
+ align-items: center;
797
+ gap: 1rem;
798
+ }
799
+
800
+ .user-info {
801
+ color: #c9b8a3;
802
+ font-size: 0.9rem;
803
+ padding: 0.5rem 1rem;
804
+ background: #2a2520;
805
+ border: 1px solid #3a342e;
806
+ border-radius: 6px;
807
+ }
808
+
809
+ .logout-btn {
810
+ background: #2a2520;
811
+ border: 1px solid #3a342e;
812
+ color: #c9b8a3;
813
+ padding: 0.5rem 1rem;
814
+ cursor: pointer;
815
+ font-size: 0.9rem;
816
+ font-weight: 500;
817
+ transition: all 0.2s ease;
818
+ border-radius: 6px;
819
+ }
820
+
821
+ .logout-btn:hover {
822
+ background: #3a342e;
823
+ color: #e8d4c0;
824
+ border-color: #4a433c;
825
+ }
826
+
827
+ .logout-btn:active {
828
+ transform: scale(0.98);
829
+ }
web/src/App.tsx ADDED
@@ -0,0 +1,553 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useRef, useEffect } from 'react';
2
+ import ReactMarkdown from 'react-markdown';
3
+ import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
4
+ import Login from './Login';
5
+ import './App.css';
6
+
7
+ // Eye-health optimized warm syntax highlighting theme
8
+ const terminalTheme = {
9
+ 'code[class*="language-"]': {
10
+ color: '#c9b8a3',
11
+ fontFamily: '"SF Mono", "Monaco", "Cascadia Code", "Consolas", monospace',
12
+ fontSize: '0.9em',
13
+ background: '#1a1614',
14
+ },
15
+ 'pre[class*="language-"]': {
16
+ color: '#c9b8a3',
17
+ fontFamily: '"SF Mono", "Monaco", "Cascadia Code", "Consolas", monospace',
18
+ fontSize: '0.9em',
19
+ background: '#1a1614',
20
+ padding: '1rem',
21
+ margin: '0.75rem 0',
22
+ overflow: 'auto',
23
+ border: '1px solid #3a342e',
24
+ borderRadius: '6px',
25
+ },
26
+ comment: {
27
+ color: '#6e5d4d',
28
+ fontStyle: 'italic',
29
+ },
30
+ prolog: { color: '#6e5d4d' },
31
+ doctype: { color: '#6e5d4d' },
32
+ cdata: { color: '#6e5d4d' },
33
+ punctuation: { color: '#a89784' },
34
+ property: { color: '#c9b8a3' },
35
+ tag: { color: '#d4a574' },
36
+ boolean: { color: '#b89968' },
37
+ number: { color: '#b89968' },
38
+ constant: { color: '#c9b8a3' },
39
+ symbol: { color: '#c9b8a3' },
40
+ deleted: { color: '#d49999' },
41
+ selector: { color: '#d4a574' },
42
+ 'attr-name': { color: '#d4a574' },
43
+ string: { color: '#9d8264' },
44
+ char: { color: '#9d8264' },
45
+ builtin: { color: '#c9b8a3' },
46
+ inserted: { color: '#9d8264' },
47
+ operator: { color: '#a89784' },
48
+ entity: { color: '#d4a574' },
49
+ url: { color: '#8b7355' },
50
+ '.language-css .token.string': { color: '#9d8264' },
51
+ '.style .token.string': { color: '#9d8264' },
52
+ variable: { color: '#c9b8a3' },
53
+ atrule: { color: '#d4a574' },
54
+ 'attr-value': { color: '#9d8264' },
55
+ function: { color: '#d4a574' },
56
+ 'class-name': { color: '#d4a574' },
57
+ keyword: { color: '#b89968', fontWeight: 'bold' },
58
+ regex: { color: '#9d8264' },
59
+ important: { color: '#d4a574', fontWeight: 'bold' },
60
+ };
61
+
62
+ interface Message {
63
+ id: string;
64
+ role: 'user' | 'assistant' | 'system';
65
+ content: string;
66
+ timestamp: Date;
67
+ toolCalls?: ToolCall[];
68
+ }
69
+
70
+ interface ToolCall {
71
+ name: string;
72
+ input: string;
73
+ output: string;
74
+ }
75
+
76
+ interface User {
77
+ username: string;
78
+ name: string;
79
+ }
80
+
81
+ const AVAILABLE_TOOLS = [
82
+ 'prolog_exec',
83
+ ];
84
+
85
+ const GATEWAY_URL = import.meta.env.VITE_GATEWAY_URL || '/api';
86
+
87
+ function App() {
88
+ const [isAuthenticated, setIsAuthenticated] = useState(false);
89
+ const [token, setToken] = useState<string | null>(localStorage.getItem('auth_token'));
90
+ const [user, setUser] = useState<User | null>(null);
91
+ const [messages, setMessages] = useState<Message[]>([]);
92
+ const [input, setInput] = useState('');
93
+ const [isLoading, setIsLoading] = useState(false);
94
+ const [statusMessage, setStatusMessage] = useState('');
95
+ const [apiKey, setApiKey] = useState(localStorage.getItem('deepseek_api_key') || '');
96
+ const [showSettings, setShowSettings] = useState(false);
97
+ const [showTools, setShowTools] = useState(false);
98
+ const messagesEndRef = useRef<HTMLDivElement>(null);
99
+ const messagesContainerRef = useRef<HTMLDivElement>(null);
100
+
101
+ // Verify token on mount
102
+ useEffect(() => {
103
+ const verifyToken = async () => {
104
+ if (token) {
105
+ try {
106
+ const response = await fetch(`${GATEWAY_URL}/auth/verify`, {
107
+ headers: {
108
+ 'Authorization': `Bearer ${token}`
109
+ }
110
+ });
111
+ if (response.ok) {
112
+ const data = await response.json();
113
+ setUser(data.user);
114
+ setIsAuthenticated(true);
115
+ } else {
116
+ // Token invalid, clear it
117
+ localStorage.removeItem('auth_token');
118
+ setToken(null);
119
+ }
120
+ } catch (error) {
121
+ console.error('Token verification failed:', error);
122
+ localStorage.removeItem('auth_token');
123
+ setToken(null);
124
+ }
125
+ }
126
+ };
127
+ verifyToken();
128
+ }, [token]);
129
+
130
+ useEffect(() => {
131
+ // Only auto-scroll if user is near the bottom (within 150px)
132
+ const container = messagesContainerRef.current;
133
+ if (container) {
134
+ const isNearBottom = container.scrollHeight - container.scrollTop - container.clientHeight < 150;
135
+ if (isNearBottom) {
136
+ messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
137
+ }
138
+ }
139
+ }, [messages]);
140
+
141
+ const handleSendMessage = async () => {
142
+ if (!input.trim() || isLoading) return;
143
+
144
+ const userMessage: Message = {
145
+ id: Date.now().toString(),
146
+ role: 'user',
147
+ content: input,
148
+ timestamp: new Date(),
149
+ };
150
+
151
+ setMessages((prev) => [...prev, userMessage]);
152
+ const currentInput = input;
153
+ setInput('');
154
+ setIsLoading(true);
155
+ setStatusMessage('Connecting to AI model...');
156
+
157
+ // Create a temporary assistant message that will be updated
158
+ const assistantId = (Date.now() + 1).toString();
159
+ const assistantMessage: Message = {
160
+ id: assistantId,
161
+ role: 'assistant',
162
+ content: '',
163
+ timestamp: new Date(),
164
+ toolCalls: [],
165
+ };
166
+
167
+ setMessages((prev) => [...prev, assistantMessage]);
168
+
169
+ try {
170
+ const response = await fetch(`${GATEWAY_URL}/chat`, {
171
+ method: 'POST',
172
+ headers: {
173
+ 'Content-Type': 'application/json',
174
+ 'Authorization': `Bearer ${token}`
175
+ },
176
+ body: JSON.stringify({
177
+ message: currentInput,
178
+ apiKey: apiKey,
179
+ }),
180
+ });
181
+
182
+ if (!response.ok) {
183
+ throw new Error('Network response was not ok');
184
+ }
185
+
186
+ const reader = response.body?.getReader();
187
+ const decoder = new TextDecoder();
188
+
189
+ if (!reader) {
190
+ throw new Error('No response body');
191
+ }
192
+
193
+ let buffer = '';
194
+
195
+ while (true) {
196
+ const { done, value } = await reader.read();
197
+
198
+ if (done) break;
199
+
200
+ buffer += decoder.decode(value, { stream: true });
201
+ const lines = buffer.split('\n\n');
202
+ buffer = lines.pop() || '';
203
+
204
+ for (const line of lines) {
205
+ if (!line.trim()) continue;
206
+
207
+ const eventMatch = line.match(/^event: (.+)$/m);
208
+ const dataMatch = line.match(/^data: (.+)$/m);
209
+
210
+ if (!eventMatch || !dataMatch) continue;
211
+
212
+ const event = eventMatch[1];
213
+ const data = JSON.parse(dataMatch[1]);
214
+
215
+ if (event === 'status') {
216
+ // Update status message to show with loading indicator
217
+ setStatusMessage(data.message || 'Processing...');
218
+ } else if (event === 'content_chunk') {
219
+ // Stream content chunks as they arrive
220
+ setIsLoading(false); // Hide loading indicator when content starts streaming
221
+ setStatusMessage(''); // Clear status message
222
+ setMessages((prev) =>
223
+ prev.map((msg) =>
224
+ msg.id === assistantId
225
+ ? {
226
+ ...msg,
227
+ content: (msg.content || '') + data.chunk,
228
+ }
229
+ : msg
230
+ )
231
+ );
232
+ } else if (event === 'tool_start') {
233
+ // Display the tool's description if available
234
+ if (data.description) {
235
+ // Extract first line of description (before first newline)
236
+ const firstLine = data.description.split('\n')[0].trim();
237
+ setStatusMessage(firstLine);
238
+ } else {
239
+ // Fallback to tool name map
240
+ const toolNameMap: Record<string, string> = {
241
+ 'prolog_exec': 'executing Prolog code',
242
+ 'python_exec': 'running Python code',
243
+ 'lean4_exec': 'executing Lean 4 code',
244
+ 'mathlib_check': 'checking Mathlib',
245
+ 'mathlib_search': 'searching Mathlib',
246
+ 'prolog_to_lean': 'running Prolog→Lean pipeline',
247
+ 'prolog_to_python': 'running Prolog→Python pipeline',
248
+ 'prolog_swe': 'running Prolog→SWE pipeline',
249
+ 'read_file': 'reading file',
250
+ 'write_file': 'writing file',
251
+ 'list_files': 'listing files',
252
+ 'search_files': 'searching files',
253
+ 'run_command': 'running command',
254
+ 'replace_in_file': 'modifying file',
255
+ };
256
+ const friendlyName = toolNameMap[data.name] || `running ${data.name}`;
257
+ setStatusMessage(`Running tool: ${friendlyName}...`);
258
+ }
259
+
260
+ // Add tool call placeholder
261
+ setMessages((prev) =>
262
+ prev.map((msg) =>
263
+ msg.id === assistantId
264
+ ? {
265
+ ...msg,
266
+ toolCalls: [
267
+ ...(msg.toolCalls || []),
268
+ {
269
+ name: data.name,
270
+ input: data.input,
271
+ output: '⏳ Running...',
272
+ },
273
+ ],
274
+ }
275
+ : msg
276
+ )
277
+ );
278
+ } else if (event === 'tool_complete') {
279
+ // Update status after tool completes
280
+ setStatusMessage('Analyzing results...');
281
+ // Update tool call with result
282
+ setMessages((prev) =>
283
+ prev.map((msg) =>
284
+ msg.id === assistantId
285
+ ? {
286
+ ...msg,
287
+ toolCalls: (msg.toolCalls || []).map((tc) =>
288
+ tc.name === data.name && tc.output === '⏳ Running...'
289
+ ? { ...tc, output: data.output }
290
+ : tc
291
+ ),
292
+ }
293
+ : msg
294
+ )
295
+ );
296
+ } else if (event === 'response') {
297
+ // Final response
298
+ setMessages((prev) =>
299
+ prev.map((msg) =>
300
+ msg.id === assistantId
301
+ ? {
302
+ ...msg,
303
+ content: data.content,
304
+ toolCalls: data.toolCalls || msg.toolCalls,
305
+ }
306
+ : msg
307
+ )
308
+ );
309
+ } else if (event === 'error') {
310
+ // Error occurred
311
+ setIsLoading(false);
312
+ setStatusMessage('');
313
+ setMessages((prev) =>
314
+ prev.map((msg) =>
315
+ msg.id === assistantId
316
+ ? {
317
+ ...msg,
318
+ content: `Error: ${data.error}\n${data.details || ''}`,
319
+ }
320
+ : msg
321
+ )
322
+ );
323
+ }
324
+ }
325
+ }
326
+ } catch (error) {
327
+ console.error('Error sending message:', error);
328
+ setIsLoading(false);
329
+ setStatusMessage('');
330
+ setMessages((prev) =>
331
+ prev.map((msg) =>
332
+ msg.id === assistantId
333
+ ? {
334
+ ...msg,
335
+ content: 'Sorry, there was an error processing your request. Please check your API key and try again.',
336
+ }
337
+ : msg
338
+ )
339
+ );
340
+ } finally {
341
+ setIsLoading(false);
342
+ setStatusMessage('');
343
+ }
344
+ };
345
+
346
+ const handleKeyPress = (e: React.KeyboardEvent) => {
347
+ if (e.key === 'Enter' && !e.shiftKey) {
348
+ e.preventDefault();
349
+ handleSendMessage();
350
+ }
351
+ };
352
+
353
+ const saveApiKey = () => {
354
+ localStorage.setItem('deepseek_api_key', apiKey);
355
+ setShowSettings(false);
356
+ };
357
+
358
+ const handleLogin = (authToken: string, userData: User) => {
359
+ setToken(authToken);
360
+ setUser(userData);
361
+ setIsAuthenticated(true);
362
+ localStorage.setItem('auth_token', authToken);
363
+ };
364
+
365
+ const handleLogout = () => {
366
+ setToken(null);
367
+ setUser(null);
368
+ setIsAuthenticated(false);
369
+ setMessages([]);
370
+ localStorage.removeItem('auth_token');
371
+ };
372
+
373
+ if (!isAuthenticated) {
374
+ return <Login onLogin={handleLogin} />;
375
+ }
376
+
377
+ return (
378
+ <div className="app">
379
+ <header className="header">
380
+ <div className="header-left">
381
+ <h1>EVO</h1>
382
+ <span className="version">v1.0</span>
383
+ </div>
384
+ <div className="header-right">
385
+ <span className="user-info">👤 {user?.name}</span>
386
+ <button className="logout-btn" onClick={handleLogout}>
387
+ Logout
388
+ </button>
389
+ </div>
390
+ <div className="header-actions">
391
+ <span className="tools-badge">{AVAILABLE_TOOLS.length} Tools</span>
392
+ <button onClick={() => setShowTools(!showTools)} className="settings-btn">
393
+ <span className="icon-settings">🔧</span>
394
+ <span>Tools</span>
395
+ </button>
396
+ <button onClick={() => setShowSettings(!showSettings)} className="settings-btn">
397
+ <span className="icon-settings">⚙</span>
398
+ <span>Settings</span>
399
+ </button>
400
+ </div>
401
+ </header>
402
+
403
+ {showTools && (
404
+ <div className="available-tools">
405
+ <h4>Available Tools</h4>
406
+ <div className="tools-grid">
407
+ {AVAILABLE_TOOLS.map((tool) => (
408
+ <span key={tool} className="tool-chip">
409
+ {tool}
410
+ </span>
411
+ ))}
412
+ </div>
413
+ </div>
414
+ )}
415
+
416
+ {showSettings && (
417
+ <div className="settings-panel">
418
+ <h3>Settings</h3>
419
+ <div className="setting-group">
420
+ <label>DeepSeek API Key:</label>
421
+ <input
422
+ type="password"
423
+ value={apiKey}
424
+ onChange={(e) => setApiKey(e.target.value)}
425
+ placeholder="Enter your API key"
426
+ />
427
+ <button onClick={saveApiKey} className="save-btn">
428
+ Save
429
+ </button>
430
+ </div>
431
+ </div>
432
+ )}
433
+
434
+ <div className="chat-container">
435
+ <div className="messages" ref={messagesContainerRef}>
436
+ {messages.length === 0 && (
437
+ <div className="welcome">
438
+ <h2>Welcome</h2>
439
+ <p>Ask me anything about coding, math, or use any of the available tools!</p>
440
+ <div className="examples">
441
+ <h3>Try these examples:</h3>
442
+ <button onClick={() => setInput("What is the derivative of x^2 + 1?")} className="example-btn">
443
+ Calculate derivative
444
+ </button>
445
+ <button onClick={() => setInput("Count the letter 'r' in 'strawberry'")} className="example-btn">
446
+ Count characters
447
+ </button>
448
+ <button onClick={() => setInput("Use Lean 4 to verify 2 + 2 = 4")} className="example-btn">
449
+ Verify with Lean 4
450
+ </button>
451
+ </div>
452
+ </div>
453
+ )}
454
+
455
+ {messages.map((message) => {
456
+ // Don't render empty assistant messages while loading
457
+ if (message.role === 'assistant' && !message.content && (!message.toolCalls || message.toolCalls.length === 0)) {
458
+ return null;
459
+ }
460
+
461
+ return (
462
+ <div key={message.id} className={`message message-${message.role}`}>
463
+ <div className="message-header">
464
+ <span className="message-role">
465
+ {message.role === 'user' ? 'You' : 'Assistant'}
466
+ </span>
467
+ <span className="message-time">
468
+ {message.timestamp.toLocaleTimeString()}
469
+ </span>
470
+ </div>
471
+ <div className="message-content">
472
+ <ReactMarkdown
473
+ components={{
474
+ code({ className, children, ...props }: any) {
475
+ const match = /language-(\w+)/.exec(className || '');
476
+ return match ? (
477
+ <SyntaxHighlighter
478
+ style={terminalTheme as any}
479
+ language={match[1]}
480
+ PreTag="div"
481
+ {...props}
482
+ >
483
+ {String(children).replace(/\n$/, '')}
484
+ </SyntaxHighlighter>
485
+ ) : (
486
+ <code className={className} {...props}>
487
+ {children}
488
+ </code>
489
+ );
490
+ },
491
+ }}
492
+ >
493
+ {message.content}
494
+ </ReactMarkdown>
495
+ </div>
496
+ {message.toolCalls && message.toolCalls.length > 0 && (
497
+ <div className="tool-calls">
498
+ <h4>Tool Calls</h4>
499
+ {message.toolCalls.map((tool, idx) => (
500
+ <div key={idx} className="tool-call">
501
+ <div className="tool-name">→ {tool.name}</div>
502
+ <details>
503
+ <summary>View details</summary>
504
+ <div className="tool-details">
505
+ <div className="tool-input">
506
+ <strong>Input:</strong>
507
+ <pre>{tool.input}</pre>
508
+ </div>
509
+ <div className="tool-output">
510
+ <strong>Output:</strong>
511
+ <pre>{tool.output}</pre>
512
+ </div>
513
+ </div>
514
+ </details>
515
+ </div>
516
+ ))}
517
+ </div>
518
+ )}
519
+ </div>
520
+ );
521
+ })}
522
+
523
+ {isLoading && (
524
+ <div className="typing-indicator">
525
+ <span></span>
526
+ <span></span>
527
+ <span></span>
528
+ <em className="status-message">{statusMessage || 'Thinking...'}</em>
529
+ </div>
530
+ )}
531
+
532
+ <div ref={messagesEndRef} />
533
+ </div>
534
+
535
+ <div className="input-container">
536
+ <textarea
537
+ value={input}
538
+ onChange={(e) => setInput(e.target.value)}
539
+ onKeyPress={handleKeyPress}
540
+ placeholder="Ask me anything... (Shift+Enter for new line)"
541
+ disabled={isLoading}
542
+ rows={3}
543
+ />
544
+ <button onClick={handleSendMessage} disabled={isLoading || !input.trim()} className="send-btn">
545
+ {isLoading ? 'Sending...' : 'Send'}
546
+ </button>
547
+ </div>
548
+ </div>
549
+ </div>
550
+ );
551
+ }
552
+
553
+ export default App;
web/src/Login.tsx ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+
3
+ interface LoginProps {
4
+ onLogin: (token: string, user: { username: string; name: string }) => void;
5
+ }
6
+
7
+ const Login: React.FC<LoginProps> = ({ onLogin }) => {
8
+ const [username, setUsername] = useState('');
9
+ const [password, setPassword] = useState('');
10
+ const [isRegistering, setIsRegistering] = useState(false);
11
+ const [name, setName] = useState('');
12
+ const [error, setError] = useState('');
13
+ const [loading, setLoading] = useState(false);
14
+
15
+ const GATEWAY_URL = import.meta.env.VITE_GATEWAY_URL || '/api';
16
+
17
+ const handleSubmit = async (e: React.FormEvent) => {
18
+ e.preventDefault();
19
+ setError('');
20
+ setLoading(true);
21
+
22
+ try {
23
+ const endpoint = isRegistering ? '/auth/register' : '/auth/login';
24
+ const body = isRegistering
25
+ ? { username, password, name }
26
+ : { username, password };
27
+
28
+ const response = await fetch(`${GATEWAY_URL}${endpoint}`, {
29
+ method: 'POST',
30
+ headers: { 'Content-Type': 'application/json' },
31
+ body: JSON.stringify(body)
32
+ });
33
+
34
+ const data = await response.json();
35
+
36
+ if (!response.ok) {
37
+ throw new Error(data.error || 'Authentication failed');
38
+ }
39
+
40
+ onLogin(data.token, data.user);
41
+ } catch (err: any) {
42
+ setError(err.message || 'An error occurred');
43
+ } finally {
44
+ setLoading(false);
45
+ }
46
+ };
47
+
48
+ return (
49
+ <div className="login-container">
50
+ <div className="login-box">
51
+ <div className="login-header">
52
+ <h1>EVO</h1>
53
+ <p className="login-subtitle">AI Coding Assistant</p>
54
+ </div>
55
+
56
+ <form onSubmit={handleSubmit} className="login-form">
57
+ <div className="form-group">
58
+ <label>Username</label>
59
+ <input
60
+ type="text"
61
+ value={username}
62
+ onChange={(e) => setUsername(e.target.value)}
63
+ placeholder="Enter username"
64
+ required
65
+ autoComplete="username"
66
+ />
67
+ </div>
68
+
69
+ {isRegistering && (
70
+ <div className="form-group">
71
+ <label>Full Name</label>
72
+ <input
73
+ type="text"
74
+ value={name}
75
+ onChange={(e) => setName(e.target.value)}
76
+ placeholder="Enter your name"
77
+ required
78
+ />
79
+ </div>
80
+ )}
81
+
82
+ <div className="form-group">
83
+ <label>Password</label>
84
+ <input
85
+ type="password"
86
+ value={password}
87
+ onChange={(e) => setPassword(e.target.value)}
88
+ placeholder="Enter password"
89
+ required
90
+ autoComplete={isRegistering ? 'new-password' : 'current-password'}
91
+ />
92
+ </div>
93
+
94
+ {error && <div className="error-message">{error}</div>}
95
+
96
+ <button type="submit" className="login-btn" disabled={loading}>
97
+ {loading ? 'Please wait...' : isRegistering ? 'Register' : 'Login'}
98
+ </button>
99
+ </form>
100
+
101
+ <div className="login-footer">
102
+ <button
103
+ type="button"
104
+ className="toggle-mode"
105
+ onClick={() => {
106
+ setIsRegistering(!isRegistering);
107
+ setError('');
108
+ }}
109
+ >
110
+ {isRegistering
111
+ ? 'Already have an account? Login'
112
+ : 'Need an account? Register'}
113
+ </button>
114
+ </div>
115
+
116
+ <div className="demo-info">
117
+ <p>Demo credentials:</p>
118
+ <p>Username: <strong>demo</strong></p>
119
+ <p>Password: <strong>demo123</strong></p>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ );
124
+ };
125
+
126
+ export default Login;
web/src/index.css ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
3
+ line-height: 1.6;
4
+ font-weight: 400;
5
+
6
+ color-scheme: dark;
7
+ color: #d4c5b9;
8
+ background-color: #1a1614;
9
+
10
+ font-synthesis: none;
11
+ text-rendering: geometricPrecision;
12
+ -webkit-font-smoothing: auto;
13
+ -moz-osx-font-smoothing: auto;
14
+ }
15
+
16
+ * {
17
+ margin: 0;
18
+ padding: 0;
19
+ box-sizing: border-box;
20
+ }
21
+
22
+ body {
23
+ margin: 0;
24
+ display: flex;
25
+ place-items: center;
26
+ min-width: 320px;
27
+ min-height: 100vh;
28
+ background: #1a1614;
29
+ }
30
+
31
+ #root {
32
+ width: 100%;
33
+ height: 100vh;
34
+ background: #1a1614;
35
+ }
web/src/main.tsx ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import App from './App';
4
+ import './index.css';
5
+
6
+ ReactDOM.createRoot(document.getElementById('root')!).render(
7
+ <React.StrictMode>
8
+ <App />
9
+ </React.StrictMode>
10
+ );
web/src/vite-env.d.ts ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_GATEWAY_URL: string
5
+ }
6
+
7
+ interface ImportMeta {
8
+ readonly env: ImportMetaEnv
9
+ }
web/tsconfig.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+ "moduleResolution": "bundler",
9
+ "allowImportingTsExtensions": true,
10
+ "resolveJsonModule": true,
11
+ "isolatedModules": true,
12
+ "noEmit": true,
13
+ "jsx": "react-jsx",
14
+ "strict": true,
15
+ "noUnusedLocals": true,
16
+ "noUnusedParameters": true,
17
+ "noFallthroughCasesInSwitch": true
18
+ },
19
+ "include": ["src"],
20
+ "references": [{ "path": "./tsconfig.node.json" }]
21
+ }
web/tsconfig.node.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "skipLibCheck": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowSyntheticDefaultImports": true
8
+ },
9
+ "include": ["vite.config.ts"]
10
+ }
web/vite.config.ts ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ server: {
7
+ port: 3000,
8
+ proxy: {
9
+ '/api': {
10
+ target: 'http://localhost:3001',
11
+ changeOrigin: true,
12
+ },
13
+ },
14
+ },
15
+ });