4runr-os 2.10.39 → 2.10.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/gateway/dist/apps/gateway/src/index.js +14 -4
- package/apps/gateway/dist/apps/gateway/src/index.js.map +1 -1
- package/apps/gateway/dist/apps/gateway/src/metrics/monitoring-detail.d.ts +18 -0
- package/apps/gateway/dist/apps/gateway/src/metrics/monitoring-detail.d.ts.map +1 -0
- package/apps/gateway/dist/apps/gateway/src/metrics/monitoring-detail.js +117 -0
- package/apps/gateway/dist/apps/gateway/src/metrics/monitoring-detail.js.map +1 -0
- package/apps/gateway/dist/apps/gateway/src/middleware/log-capture.d.ts +2 -0
- package/apps/gateway/dist/apps/gateway/src/middleware/log-capture.d.ts.map +1 -0
- package/apps/gateway/dist/apps/gateway/src/middleware/log-capture.js +54 -0
- package/apps/gateway/dist/apps/gateway/src/middleware/log-capture.js.map +1 -0
- package/apps/gateway/dist/apps/gateway/src/routes/monitoring.d.ts +15 -0
- package/apps/gateway/dist/apps/gateway/src/routes/monitoring.d.ts.map +1 -0
- package/apps/gateway/dist/apps/gateway/src/routes/monitoring.js +164 -0
- package/apps/gateway/dist/apps/gateway/src/routes/monitoring.js.map +1 -0
- package/apps/gateway/package-lock.json +204 -353
- package/apps/gateway/src/index.ts +27 -8
- package/apps/gateway/src/metrics/monitoring-detail.ts +162 -0
- package/apps/gateway/src/middleware/log-capture.ts +70 -0
- package/apps/gateway/src/routes/monitoring.ts +298 -0
- package/dist/gateway-client.d.ts +2 -0
- package/dist/gateway-client.d.ts.map +1 -1
- package/dist/gateway-client.js +22 -0
- package/dist/gateway-client.js.map +1 -1
- package/dist/tui-handlers.js +498 -0
- package/dist/tui-handlers.js.map +1 -1
- package/mk3-tui/src/app/render_scheduler.rs +111 -112
- package/mk3-tui/src/app.rs +1078 -295
- package/mk3-tui/src/debug_log.rs +131 -124
- package/mk3-tui/src/io/mod.rs +63 -66
- package/mk3-tui/src/io/protocol.rs +14 -15
- package/mk3-tui/src/io/stdio.rs +31 -32
- package/mk3-tui/src/io/ws.rs +25 -32
- package/mk3-tui/src/main.rs +774 -212
- package/mk3-tui/src/monitoring/mod.rs +428 -0
- package/mk3-tui/src/screens/mod.rs +53 -39
- package/mk3-tui/src/storage/cache.rs +221 -224
- package/mk3-tui/src/storage/mod.rs +5 -6
- package/mk3-tui/src/ui/agent_builder.rs +1148 -922
- package/mk3-tui/src/ui/agent_list.rs +344 -295
- package/mk3-tui/src/ui/boot.rs +145 -148
- package/mk3-tui/src/ui/connection_portal.rs +121 -98
- package/mk3-tui/src/ui/help.rs +340 -284
- package/mk3-tui/src/ui/layout.rs +966 -803
- package/mk3-tui/src/ui/mod.rs +1 -1
- package/mk3-tui/src/ui/portal_monitoring.rs +1027 -147
- package/mk3-tui/src/ui/run_manager.rs +784 -764
- package/mk3-tui/src/ui/safe_viewport.rs +236 -235
- package/mk3-tui/src/ui/settings.rs +414 -362
- package/mk3-tui/src/ui/setup_portal.rs +158 -101
- package/mk3-tui/src/websocket.rs +315 -308
- package/package.json +2 -2
|
@@ -1,922 +1,1148 @@
|
|
|
1
|
-
|
|
2
|
-
///
|
|
3
|
-
|
|
4
|
-
use ratatui::prelude::*;
|
|
5
|
-
use ratatui::widgets::{Block, Borders, Paragraph, Wrap};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
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
|
-
pub
|
|
162
|
-
pub
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
//
|
|
171
|
-
pub
|
|
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
|
-
1
|
|
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
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
let
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
Line::from(
|
|
444
|
-
|
|
445
|
-
Span::styled(
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
Line::from(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
Line::from(
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
.
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
let
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
let
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
Span::styled("
|
|
546
|
-
Span::styled(
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
Line::from(vec![
|
|
552
|
-
Span::styled("
|
|
553
|
-
Span::styled(
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
Span::styled("
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
Line::from(
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
Line::from("
|
|
647
|
-
Line::from(vec![
|
|
648
|
-
Span::styled(
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
Span::styled(
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
]),
|
|
659
|
-
Line::from(
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
Span::styled(
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
"
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
let
|
|
685
|
-
|
|
686
|
-
Line::from("
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
Line::from("
|
|
725
|
-
Line::from(""),
|
|
726
|
-
Line::from(
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
Span::
|
|
738
|
-
Span::styled(
|
|
739
|
-
Span::
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
Span::
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
Span::raw("
|
|
750
|
-
Span::styled(
|
|
751
|
-
Span::
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
Style::default().fg(
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
text
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
let
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
Line::from(""),
|
|
841
|
-
Line::from("
|
|
842
|
-
|
|
843
|
-
Line::from("
|
|
844
|
-
Line::from("")
|
|
845
|
-
|
|
846
|
-
Line::from(""),
|
|
847
|
-
Line::from("
|
|
848
|
-
Line::from(
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
Line::from(
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
Line::from(
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
Span::
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
Span::styled(
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
1
|
+
use crate::app::AppState;
|
|
2
|
+
/// Agent Builder Screen
|
|
3
|
+
/// Multi-step wizard for creating and editing agents
|
|
4
|
+
use ratatui::prelude::*;
|
|
5
|
+
use ratatui::widgets::{Block, Borders, Paragraph, Wrap};
|
|
6
|
+
|
|
7
|
+
// === 4RUNR BRAND COLORS (matching layout.rs) ===
|
|
8
|
+
const BRAND_PURPLE: Color = Color::Rgb(138, 43, 226);
|
|
9
|
+
#[allow(dead_code)]
|
|
10
|
+
const BRAND_VIOLET: Color = Color::Rgb(148, 103, 189);
|
|
11
|
+
const CYBER_CYAN: Color = Color::Rgb(0, 255, 255);
|
|
12
|
+
const NEON_GREEN: Color = Color::Rgb(57, 255, 20);
|
|
13
|
+
const AMBER_WARN: Color = Color::Rgb(255, 191, 0);
|
|
14
|
+
const TEXT_PRIMARY: Color = Color::Rgb(230, 230, 240);
|
|
15
|
+
const TEXT_DIM: Color = Color::Rgb(100, 100, 120);
|
|
16
|
+
const TEXT_MUTED: Color = Color::Rgb(60, 60, 80);
|
|
17
|
+
const BG_PANEL: Color = Color::Rgb(18, 18, 25);
|
|
18
|
+
|
|
19
|
+
// === MODEL INFORMATION ===
|
|
20
|
+
struct ModelInfo {
|
|
21
|
+
context_window: u32,
|
|
22
|
+
max_output: u32,
|
|
23
|
+
training_cutoff: &'static str,
|
|
24
|
+
capabilities: Vec<&'static str>,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fn get_model_info(provider: &str, model: &str) -> ModelInfo {
|
|
28
|
+
match (provider, model) {
|
|
29
|
+
// OpenAI
|
|
30
|
+
("openai", "gpt-4") => ModelInfo {
|
|
31
|
+
context_window: 8192,
|
|
32
|
+
max_output: 4096,
|
|
33
|
+
training_cutoff: "Sep 2021",
|
|
34
|
+
capabilities: vec!["Text", "Code", "Analysis"],
|
|
35
|
+
},
|
|
36
|
+
("openai", "gpt-4-turbo") => ModelInfo {
|
|
37
|
+
context_window: 128000,
|
|
38
|
+
max_output: 4096,
|
|
39
|
+
training_cutoff: "Apr 2023",
|
|
40
|
+
capabilities: vec!["Text", "Code", "Vision", "JSON"],
|
|
41
|
+
},
|
|
42
|
+
("openai", "gpt-3.5-turbo") => ModelInfo {
|
|
43
|
+
context_window: 16385,
|
|
44
|
+
max_output: 4096,
|
|
45
|
+
training_cutoff: "Sep 2021",
|
|
46
|
+
capabilities: vec!["Text", "Code"],
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
// Anthropic
|
|
50
|
+
("anthropic", "claude-3-opus") => ModelInfo {
|
|
51
|
+
context_window: 200000,
|
|
52
|
+
max_output: 4096,
|
|
53
|
+
training_cutoff: "Aug 2023",
|
|
54
|
+
capabilities: vec!["Text", "Code", "Vision", "Analysis", "Long Context"],
|
|
55
|
+
},
|
|
56
|
+
("anthropic", "claude-3-sonnet") => ModelInfo {
|
|
57
|
+
context_window: 200000,
|
|
58
|
+
max_output: 4096,
|
|
59
|
+
training_cutoff: "Aug 2023",
|
|
60
|
+
capabilities: vec!["Text", "Code", "Vision", "Balanced"],
|
|
61
|
+
},
|
|
62
|
+
("anthropic", "claude-3-haiku") => ModelInfo {
|
|
63
|
+
context_window: 200000,
|
|
64
|
+
max_output: 4096,
|
|
65
|
+
training_cutoff: "Aug 2023",
|
|
66
|
+
capabilities: vec!["Text", "Code", "Fast", "Efficient"],
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// Local models
|
|
70
|
+
_ => ModelInfo {
|
|
71
|
+
context_window: 4096,
|
|
72
|
+
max_output: 2048,
|
|
73
|
+
training_cutoff: "Varies",
|
|
74
|
+
capabilities: vec!["Text", "Local", "Private"],
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// === COST CALCULATOR ===
|
|
80
|
+
/// Pricing data for different AI providers (per 1M tokens)
|
|
81
|
+
struct ModelPricing {
|
|
82
|
+
input_cost: f64, // USD per 1M input tokens
|
|
83
|
+
output_cost: f64, // USD per 1M output tokens
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
fn get_model_pricing(provider: &str, model: &str) -> ModelPricing {
|
|
87
|
+
match (provider, model) {
|
|
88
|
+
// OpenAI
|
|
89
|
+
("openai", "gpt-4") => ModelPricing {
|
|
90
|
+
input_cost: 30.0,
|
|
91
|
+
output_cost: 60.0,
|
|
92
|
+
},
|
|
93
|
+
("openai", "gpt-4-turbo") => ModelPricing {
|
|
94
|
+
input_cost: 10.0,
|
|
95
|
+
output_cost: 30.0,
|
|
96
|
+
},
|
|
97
|
+
("openai", "gpt-3.5-turbo") => ModelPricing {
|
|
98
|
+
input_cost: 0.5,
|
|
99
|
+
output_cost: 1.5,
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
// Anthropic
|
|
103
|
+
("anthropic", "claude-3-opus") => ModelPricing {
|
|
104
|
+
input_cost: 15.0,
|
|
105
|
+
output_cost: 75.0,
|
|
106
|
+
},
|
|
107
|
+
("anthropic", "claude-3-sonnet") => ModelPricing {
|
|
108
|
+
input_cost: 3.0,
|
|
109
|
+
output_cost: 15.0,
|
|
110
|
+
},
|
|
111
|
+
("anthropic", "claude-3-haiku") => ModelPricing {
|
|
112
|
+
input_cost: 0.25,
|
|
113
|
+
output_cost: 1.25,
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
// Local models (free)
|
|
117
|
+
_ => ModelPricing {
|
|
118
|
+
input_cost: 0.0,
|
|
119
|
+
output_cost: 0.0,
|
|
120
|
+
},
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
struct CostEstimate {
|
|
125
|
+
cost_1k: f64,
|
|
126
|
+
cost_10k: f64,
|
|
127
|
+
cost_100k: f64,
|
|
128
|
+
cost_1m: f64,
|
|
129
|
+
is_free: bool,
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
fn calculate_cost(provider: &str, model: &str, _max_tokens: u32) -> CostEstimate {
|
|
133
|
+
let pricing = get_model_pricing(provider, model);
|
|
134
|
+
let is_free = pricing.input_cost == 0.0 && pricing.output_cost == 0.0;
|
|
135
|
+
|
|
136
|
+
if is_free {
|
|
137
|
+
return CostEstimate {
|
|
138
|
+
cost_1k: 0.0,
|
|
139
|
+
cost_10k: 0.0,
|
|
140
|
+
cost_100k: 0.0,
|
|
141
|
+
cost_1m: 0.0,
|
|
142
|
+
is_free: true,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Assume 50/50 split between input and output tokens for estimation
|
|
147
|
+
let avg_cost_per_1m = (pricing.input_cost + pricing.output_cost) / 2.0;
|
|
148
|
+
|
|
149
|
+
CostEstimate {
|
|
150
|
+
cost_1k: avg_cost_per_1m / 1000.0,
|
|
151
|
+
cost_10k: avg_cost_per_1m / 100.0,
|
|
152
|
+
cost_100k: avg_cost_per_1m / 10.0,
|
|
153
|
+
cost_1m: avg_cost_per_1m,
|
|
154
|
+
is_free: false,
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/// Agent Builder wizard state
|
|
159
|
+
#[derive(Debug, Clone)]
|
|
160
|
+
pub struct AgentBuilderState {
|
|
161
|
+
pub current_step: usize, // 1-6
|
|
162
|
+
pub focused_field: usize,
|
|
163
|
+
|
|
164
|
+
// Step 1: Basic Info
|
|
165
|
+
pub name: String,
|
|
166
|
+
pub description: String,
|
|
167
|
+
|
|
168
|
+
// Step 2: Model Selection
|
|
169
|
+
pub use_local_model: bool,
|
|
170
|
+
pub provider: String, // "openai", "anthropic", "ollama", etc.
|
|
171
|
+
pub model: String, // "gpt-4", "claude-3", "llama2", etc.
|
|
172
|
+
pub local_provider: String, // "ollama", "lm-studio", "custom"
|
|
173
|
+
pub local_model: String,
|
|
174
|
+
pub local_url: String,
|
|
175
|
+
|
|
176
|
+
// Step 3: System Prompt
|
|
177
|
+
pub system_prompt: String,
|
|
178
|
+
|
|
179
|
+
// Step 4: Parameters
|
|
180
|
+
pub temperature: f32,
|
|
181
|
+
pub max_tokens: u32,
|
|
182
|
+
pub top_p: f32,
|
|
183
|
+
pub frequency_penalty: f32,
|
|
184
|
+
pub presence_penalty: f32,
|
|
185
|
+
|
|
186
|
+
// Step 5: Tools
|
|
187
|
+
pub selected_tools: Vec<String>,
|
|
188
|
+
pub available_tools: Vec<String>,
|
|
189
|
+
|
|
190
|
+
// Validation
|
|
191
|
+
pub validation_errors: Vec<String>,
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
impl Default for AgentBuilderState {
|
|
195
|
+
fn default() -> Self {
|
|
196
|
+
Self {
|
|
197
|
+
current_step: 1,
|
|
198
|
+
focused_field: 0,
|
|
199
|
+
name: String::new(),
|
|
200
|
+
description: String::new(),
|
|
201
|
+
use_local_model: false,
|
|
202
|
+
provider: "openai".to_string(),
|
|
203
|
+
model: "gpt-4".to_string(),
|
|
204
|
+
local_provider: "ollama".to_string(),
|
|
205
|
+
local_model: "llama2".to_string(),
|
|
206
|
+
local_url: "http://localhost:11434".to_string(),
|
|
207
|
+
system_prompt: String::new(),
|
|
208
|
+
temperature: 0.7,
|
|
209
|
+
max_tokens: 2000,
|
|
210
|
+
top_p: 1.0,
|
|
211
|
+
frequency_penalty: 0.0,
|
|
212
|
+
presence_penalty: 0.0,
|
|
213
|
+
selected_tools: Vec::new(),
|
|
214
|
+
available_tools: vec![
|
|
215
|
+
"calculator".to_string(),
|
|
216
|
+
"time".to_string(),
|
|
217
|
+
"weather".to_string(),
|
|
218
|
+
],
|
|
219
|
+
validation_errors: Vec::new(),
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
impl AgentBuilderState {
|
|
225
|
+
/// Validate current step
|
|
226
|
+
pub fn validate_step(&mut self) -> bool {
|
|
227
|
+
self.validation_errors.clear();
|
|
228
|
+
|
|
229
|
+
match self.current_step {
|
|
230
|
+
1 => {
|
|
231
|
+
if self.name.trim().is_empty() {
|
|
232
|
+
self.validation_errors.push("Name is required".to_string());
|
|
233
|
+
}
|
|
234
|
+
if self.name.len() > 50 {
|
|
235
|
+
self.validation_errors
|
|
236
|
+
.push("Name must be 50 characters or less".to_string());
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
2 => {
|
|
240
|
+
if !self.use_local_model && self.model.is_empty() {
|
|
241
|
+
self.validation_errors.push("Model is required".to_string());
|
|
242
|
+
}
|
|
243
|
+
if self.use_local_model && self.local_model.is_empty() {
|
|
244
|
+
self.validation_errors
|
|
245
|
+
.push("Local model is required".to_string());
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
3 => {
|
|
249
|
+
// System prompt is optional
|
|
250
|
+
}
|
|
251
|
+
4 => {
|
|
252
|
+
if !(0.0..=2.0).contains(&self.temperature) {
|
|
253
|
+
self.validation_errors
|
|
254
|
+
.push("Temperature must be between 0.0 and 2.0".to_string());
|
|
255
|
+
}
|
|
256
|
+
if self.max_tokens < 1 || self.max_tokens > 100000 {
|
|
257
|
+
self.validation_errors
|
|
258
|
+
.push("Max tokens must be between 1 and 100000".to_string());
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
5 => {
|
|
262
|
+
// Tools are optional
|
|
263
|
+
}
|
|
264
|
+
6 => {
|
|
265
|
+
// Review step - validate all
|
|
266
|
+
if self.name.trim().is_empty() {
|
|
267
|
+
self.validation_errors.push("Name is required".to_string());
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
_ => {}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
self.validation_errors.is_empty()
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/// Move to next step
|
|
277
|
+
pub fn next_step(&mut self) -> bool {
|
|
278
|
+
if self.validate_step() && self.current_step < 6 {
|
|
279
|
+
self.current_step += 1;
|
|
280
|
+
self.focused_field = 0;
|
|
281
|
+
true
|
|
282
|
+
} else {
|
|
283
|
+
false
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/// Move to previous step
|
|
288
|
+
pub fn prev_step(&mut self) {
|
|
289
|
+
if self.current_step > 1 {
|
|
290
|
+
self.current_step -= 1;
|
|
291
|
+
self.focused_field = 0;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/// Move to next field within current step
|
|
296
|
+
pub fn next_field(&mut self) {
|
|
297
|
+
let max_field = self.get_max_field_for_step();
|
|
298
|
+
if self.focused_field < max_field {
|
|
299
|
+
self.focused_field += 1;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/// Move to previous field within current step
|
|
304
|
+
pub fn prev_field(&mut self) {
|
|
305
|
+
if self.focused_field > 0 {
|
|
306
|
+
self.focused_field -= 1;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/// Get the maximum field index for the current step
|
|
311
|
+
fn get_max_field_for_step(&self) -> usize {
|
|
312
|
+
match self.current_step {
|
|
313
|
+
1 => 1, // Name, Description
|
|
314
|
+
2 => 4, // Provider, Model, Local Provider, Local Model, Local URL
|
|
315
|
+
3 => 0, // System Prompt (single field)
|
|
316
|
+
4 => 4, // Temperature, Max Tokens, Top P, Frequency Penalty, Presence Penalty
|
|
317
|
+
5 => self.available_tools.len().saturating_sub(1), // Tools list
|
|
318
|
+
6 => 0, // Review (no editable fields)
|
|
319
|
+
_ => 0,
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/// Render the Agent Builder screen
|
|
325
|
+
pub fn render(f: &mut Frame, state: &AppState) {
|
|
326
|
+
let area = f.size();
|
|
327
|
+
|
|
328
|
+
// Get wizard state from AppState
|
|
329
|
+
let wizard_state = &state.agent_builder;
|
|
330
|
+
|
|
331
|
+
render_wizard(f, area, wizard_state);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
fn render_wizard(f: &mut Frame, area: Rect, wizard: &AgentBuilderState) {
|
|
335
|
+
use ratatui::layout::{Constraint, Direction, Layout};
|
|
336
|
+
|
|
337
|
+
// Split area into content and footer
|
|
338
|
+
let v_chunks = Layout::default()
|
|
339
|
+
.direction(Direction::Vertical)
|
|
340
|
+
.constraints([
|
|
341
|
+
Constraint::Min(10), // Content
|
|
342
|
+
Constraint::Length(3), // Navigation footer
|
|
343
|
+
])
|
|
344
|
+
.split(area);
|
|
345
|
+
|
|
346
|
+
// Split content into main wizard and cost calculator (if on step 2 or 4)
|
|
347
|
+
let show_cost_calc = wizard.current_step == 2 || wizard.current_step == 4;
|
|
348
|
+
let h_chunks = Layout::default()
|
|
349
|
+
.direction(Direction::Horizontal)
|
|
350
|
+
.constraints(if show_cost_calc {
|
|
351
|
+
[
|
|
352
|
+
Constraint::Percentage(65), // Wizard content
|
|
353
|
+
Constraint::Percentage(35), // Cost calculator
|
|
354
|
+
]
|
|
355
|
+
.as_ref()
|
|
356
|
+
} else {
|
|
357
|
+
[
|
|
358
|
+
Constraint::Percentage(100), // Full width
|
|
359
|
+
Constraint::Length(0), // No cost calc
|
|
360
|
+
]
|
|
361
|
+
.as_ref()
|
|
362
|
+
})
|
|
363
|
+
.split(v_chunks[0]);
|
|
364
|
+
|
|
365
|
+
// Progress bar for title
|
|
366
|
+
let progress = wizard.current_step as f32 / 6.0;
|
|
367
|
+
let filled = (progress * 20.0) as usize;
|
|
368
|
+
let empty = 20 - filled;
|
|
369
|
+
let progress_bar = format!("[{}{}]", "█".repeat(filled), "░".repeat(empty));
|
|
370
|
+
|
|
371
|
+
// Main container with brand styling
|
|
372
|
+
let block = Block::default()
|
|
373
|
+
.title(format!(
|
|
374
|
+
" 🤖 Agent Builder - Step {}/6 {} ",
|
|
375
|
+
wizard.current_step, progress_bar
|
|
376
|
+
))
|
|
377
|
+
.title_style(Style::default().fg(CYBER_CYAN).add_modifier(Modifier::BOLD))
|
|
378
|
+
.borders(Borders::ALL)
|
|
379
|
+
.border_style(Style::default().fg(BRAND_PURPLE))
|
|
380
|
+
.style(Style::default().bg(BG_PANEL));
|
|
381
|
+
|
|
382
|
+
let inner = block.inner(h_chunks[0]);
|
|
383
|
+
f.render_widget(block, h_chunks[0]);
|
|
384
|
+
|
|
385
|
+
// Render current step
|
|
386
|
+
match wizard.current_step {
|
|
387
|
+
1 => render_step_1_basic_info(f, inner, wizard),
|
|
388
|
+
2 => render_step_2_model_selection(f, inner, wizard),
|
|
389
|
+
3 => render_step_3_system_prompt(f, inner, wizard),
|
|
390
|
+
4 => render_step_4_parameters(f, inner, wizard),
|
|
391
|
+
5 => render_step_5_tools(f, inner, wizard),
|
|
392
|
+
6 => render_step_6_review(f, inner, wizard),
|
|
393
|
+
_ => {}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Render cost calculator if visible
|
|
397
|
+
if show_cost_calc {
|
|
398
|
+
render_cost_calculator(f, h_chunks[1], wizard);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Render navigation footer
|
|
402
|
+
render_navigation_footer(f, v_chunks[1], wizard);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
fn render_cost_calculator(f: &mut Frame, area: Rect, wizard: &AgentBuilderState) {
|
|
406
|
+
use ratatui::layout::{Constraint, Direction, Layout};
|
|
407
|
+
|
|
408
|
+
// Split into cost and model info sections
|
|
409
|
+
let chunks = Layout::default()
|
|
410
|
+
.direction(Direction::Vertical)
|
|
411
|
+
.constraints([
|
|
412
|
+
Constraint::Percentage(60), // Cost info
|
|
413
|
+
Constraint::Percentage(40), // Model info
|
|
414
|
+
])
|
|
415
|
+
.split(area);
|
|
416
|
+
|
|
417
|
+
let provider = if wizard.use_local_model {
|
|
418
|
+
"local"
|
|
419
|
+
} else {
|
|
420
|
+
&wizard.provider
|
|
421
|
+
};
|
|
422
|
+
let model = if wizard.use_local_model {
|
|
423
|
+
&wizard.local_model
|
|
424
|
+
} else {
|
|
425
|
+
&wizard.model
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
let cost = calculate_cost(provider, model, wizard.max_tokens);
|
|
429
|
+
let model_info = get_model_info(provider, model);
|
|
430
|
+
|
|
431
|
+
// === COST SECTION ===
|
|
432
|
+
let cost_block = Block::default()
|
|
433
|
+
.title(" 💰 Cost Estimator ")
|
|
434
|
+
.borders(Borders::ALL)
|
|
435
|
+
.border_style(Style::default().fg(AMBER_WARN))
|
|
436
|
+
.style(Style::default().bg(BG_PANEL));
|
|
437
|
+
|
|
438
|
+
let cost_inner = cost_block.inner(chunks[0]);
|
|
439
|
+
f.render_widget(cost_block, chunks[0]);
|
|
440
|
+
|
|
441
|
+
let text = if cost.is_free {
|
|
442
|
+
vec![
|
|
443
|
+
Line::from(""),
|
|
444
|
+
Line::from(vec![
|
|
445
|
+
Span::styled("✓ ", Style::default().fg(NEON_GREEN)),
|
|
446
|
+
Span::styled("Local Model", Style::default().fg(NEON_GREEN).bold()),
|
|
447
|
+
]),
|
|
448
|
+
Line::from(""),
|
|
449
|
+
Line::from(vec![Span::styled(
|
|
450
|
+
"FREE",
|
|
451
|
+
Style::default()
|
|
452
|
+
.fg(NEON_GREEN)
|
|
453
|
+
.bold()
|
|
454
|
+
.add_modifier(Modifier::UNDERLINED),
|
|
455
|
+
)]),
|
|
456
|
+
Line::from(""),
|
|
457
|
+
Line::from("No API costs!").style(Style::default().fg(TEXT_DIM)),
|
|
458
|
+
Line::from("Self-hosted model").style(Style::default().fg(TEXT_DIM)),
|
|
459
|
+
Line::from(""),
|
|
460
|
+
Line::from("Benefits:").style(Style::default().fg(TEXT_PRIMARY).bold()),
|
|
461
|
+
Line::from(" • No usage limits").style(Style::default().fg(TEXT_DIM)),
|
|
462
|
+
Line::from(" • Full privacy").style(Style::default().fg(TEXT_DIM)),
|
|
463
|
+
Line::from(" • No API keys").style(Style::default().fg(TEXT_DIM)),
|
|
464
|
+
]
|
|
465
|
+
} else {
|
|
466
|
+
let cost_color = if cost.cost_1k < 0.01 {
|
|
467
|
+
NEON_GREEN
|
|
468
|
+
} else if cost.cost_1k < 0.05 {
|
|
469
|
+
AMBER_WARN
|
|
470
|
+
} else {
|
|
471
|
+
Color::Rgb(255, 69, 69)
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
vec![
|
|
475
|
+
Line::from(""),
|
|
476
|
+
Line::from(vec![
|
|
477
|
+
Span::styled("Provider: ", Style::default().fg(TEXT_DIM)),
|
|
478
|
+
Span::styled(provider, Style::default().fg(TEXT_PRIMARY).bold()),
|
|
479
|
+
]),
|
|
480
|
+
Line::from(vec![
|
|
481
|
+
Span::styled("Model: ", Style::default().fg(TEXT_DIM)),
|
|
482
|
+
Span::styled(model, Style::default().fg(TEXT_PRIMARY)),
|
|
483
|
+
]),
|
|
484
|
+
Line::from(""),
|
|
485
|
+
Line::from("Estimated Cost:").style(Style::default().fg(TEXT_PRIMARY).bold()),
|
|
486
|
+
Line::from(""),
|
|
487
|
+
Line::from(vec![
|
|
488
|
+
Span::styled(" 1K tokens: ", Style::default().fg(TEXT_DIM)),
|
|
489
|
+
Span::styled(
|
|
490
|
+
format!("${:.4}", cost.cost_1k),
|
|
491
|
+
Style::default().fg(cost_color),
|
|
492
|
+
),
|
|
493
|
+
]),
|
|
494
|
+
Line::from(vec![
|
|
495
|
+
Span::styled(" 10K tokens: ", Style::default().fg(TEXT_DIM)),
|
|
496
|
+
Span::styled(
|
|
497
|
+
format!("${:.3}", cost.cost_10k),
|
|
498
|
+
Style::default().fg(cost_color),
|
|
499
|
+
),
|
|
500
|
+
]),
|
|
501
|
+
Line::from(vec![
|
|
502
|
+
Span::styled(" 100K tokens: ", Style::default().fg(TEXT_DIM)),
|
|
503
|
+
Span::styled(
|
|
504
|
+
format!("${:.2}", cost.cost_100k),
|
|
505
|
+
Style::default().fg(cost_color),
|
|
506
|
+
),
|
|
507
|
+
]),
|
|
508
|
+
Line::from(vec![
|
|
509
|
+
Span::styled(" 1M tokens: ", Style::default().fg(TEXT_DIM)),
|
|
510
|
+
Span::styled(
|
|
511
|
+
format!("${:.2}", cost.cost_1m),
|
|
512
|
+
Style::default().fg(cost_color),
|
|
513
|
+
),
|
|
514
|
+
]),
|
|
515
|
+
Line::from(""),
|
|
516
|
+
Line::from(vec![
|
|
517
|
+
Span::styled("Max tokens: ", Style::default().fg(TEXT_DIM)),
|
|
518
|
+
Span::styled(
|
|
519
|
+
format!("{}", wizard.max_tokens),
|
|
520
|
+
Style::default().fg(CYBER_CYAN),
|
|
521
|
+
),
|
|
522
|
+
]),
|
|
523
|
+
]
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
let cost_paragraph = Paragraph::new(text)
|
|
527
|
+
.wrap(Wrap { trim: false })
|
|
528
|
+
.alignment(Alignment::Left);
|
|
529
|
+
|
|
530
|
+
f.render_widget(cost_paragraph, cost_inner);
|
|
531
|
+
|
|
532
|
+
// === MODEL INFO SECTION ===
|
|
533
|
+
let info_block = Block::default()
|
|
534
|
+
.title(" 📊 Model Info ")
|
|
535
|
+
.borders(Borders::ALL)
|
|
536
|
+
.border_style(Style::default().fg(CYBER_CYAN))
|
|
537
|
+
.style(Style::default().bg(BG_PANEL));
|
|
538
|
+
|
|
539
|
+
let info_inner = info_block.inner(chunks[1]);
|
|
540
|
+
f.render_widget(info_block, chunks[1]);
|
|
541
|
+
|
|
542
|
+
let info_text = vec![
|
|
543
|
+
Line::from(""),
|
|
544
|
+
Line::from(vec![
|
|
545
|
+
Span::styled("Context: ", Style::default().fg(TEXT_DIM)),
|
|
546
|
+
Span::styled(
|
|
547
|
+
format!("{} tokens", model_info.context_window),
|
|
548
|
+
Style::default().fg(NEON_GREEN),
|
|
549
|
+
),
|
|
550
|
+
]),
|
|
551
|
+
Line::from(vec![
|
|
552
|
+
Span::styled("Max Output: ", Style::default().fg(TEXT_DIM)),
|
|
553
|
+
Span::styled(
|
|
554
|
+
format!("{} tokens", model_info.max_output),
|
|
555
|
+
Style::default().fg(TEXT_PRIMARY),
|
|
556
|
+
),
|
|
557
|
+
]),
|
|
558
|
+
Line::from(vec![
|
|
559
|
+
Span::styled("Training: ", Style::default().fg(TEXT_DIM)),
|
|
560
|
+
Span::styled(model_info.training_cutoff, Style::default().fg(TEXT_MUTED)),
|
|
561
|
+
]),
|
|
562
|
+
Line::from(""),
|
|
563
|
+
Line::from("Capabilities:").style(Style::default().fg(TEXT_PRIMARY).bold()),
|
|
564
|
+
Line::from(
|
|
565
|
+
model_info
|
|
566
|
+
.capabilities
|
|
567
|
+
.iter()
|
|
568
|
+
.map(|cap| format!(" • {}", cap))
|
|
569
|
+
.collect::<Vec<_>>()
|
|
570
|
+
.join("\n"),
|
|
571
|
+
)
|
|
572
|
+
.style(Style::default().fg(TEXT_DIM)),
|
|
573
|
+
];
|
|
574
|
+
|
|
575
|
+
let info_paragraph = Paragraph::new(info_text)
|
|
576
|
+
.wrap(Wrap { trim: false })
|
|
577
|
+
.alignment(Alignment::Left);
|
|
578
|
+
|
|
579
|
+
f.render_widget(info_paragraph, info_inner);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
fn render_navigation_footer(f: &mut Frame, area: Rect, wizard: &AgentBuilderState) {
|
|
583
|
+
let block = Block::default()
|
|
584
|
+
.title(" ⌨️ Navigation ")
|
|
585
|
+
.borders(Borders::ALL)
|
|
586
|
+
.border_style(Style::default().fg(TEXT_DIM))
|
|
587
|
+
.style(Style::default().bg(BG_PANEL));
|
|
588
|
+
|
|
589
|
+
let inner = block.inner(area);
|
|
590
|
+
f.render_widget(block, area);
|
|
591
|
+
|
|
592
|
+
let can_go_back = wizard.current_step > 1;
|
|
593
|
+
let is_final_step = wizard.current_step == 6;
|
|
594
|
+
|
|
595
|
+
let nav_text = if is_final_step {
|
|
596
|
+
Line::from(vec![
|
|
597
|
+
Span::styled(
|
|
598
|
+
"←",
|
|
599
|
+
Style::default()
|
|
600
|
+
.fg(if can_go_back { CYBER_CYAN } else { TEXT_MUTED })
|
|
601
|
+
.bold(),
|
|
602
|
+
),
|
|
603
|
+
Span::styled(" Back │ ", Style::default().fg(TEXT_DIM)),
|
|
604
|
+
Span::styled("Tab/↑↓", Style::default().fg(CYBER_CYAN).bold()),
|
|
605
|
+
Span::styled(" Navigate │ ", Style::default().fg(TEXT_DIM)),
|
|
606
|
+
Span::styled("Enter", Style::default().fg(NEON_GREEN).bold()),
|
|
607
|
+
Span::styled(" Create Agent │ ", Style::default().fg(TEXT_DIM)),
|
|
608
|
+
Span::styled("ESC", Style::default().fg(Color::Rgb(255, 69, 69)).bold()),
|
|
609
|
+
Span::styled(" Cancel", Style::default().fg(TEXT_DIM)),
|
|
610
|
+
])
|
|
611
|
+
} else {
|
|
612
|
+
Line::from(vec![
|
|
613
|
+
Span::styled(
|
|
614
|
+
"←",
|
|
615
|
+
Style::default()
|
|
616
|
+
.fg(if can_go_back { CYBER_CYAN } else { TEXT_MUTED })
|
|
617
|
+
.bold(),
|
|
618
|
+
),
|
|
619
|
+
Span::styled(" Back │ ", Style::default().fg(TEXT_DIM)),
|
|
620
|
+
Span::styled("Tab/↑↓", Style::default().fg(CYBER_CYAN).bold()),
|
|
621
|
+
Span::styled(" Navigate │ ", Style::default().fg(TEXT_DIM)),
|
|
622
|
+
Span::styled("→/Enter", Style::default().fg(NEON_GREEN).bold()),
|
|
623
|
+
Span::styled(" Next │ ", Style::default().fg(TEXT_DIM)),
|
|
624
|
+
Span::styled("ESC", Style::default().fg(Color::Rgb(255, 69, 69)).bold()),
|
|
625
|
+
Span::styled(" Cancel", Style::default().fg(TEXT_DIM)),
|
|
626
|
+
])
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
let paragraph = Paragraph::new(nav_text)
|
|
630
|
+
.style(Style::default().fg(TEXT_PRIMARY))
|
|
631
|
+
.alignment(Alignment::Center);
|
|
632
|
+
|
|
633
|
+
f.render_widget(paragraph, inner);
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
fn render_step_1_basic_info(f: &mut Frame, area: Rect, wizard: &AgentBuilderState) {
|
|
637
|
+
let focused = wizard.focused_field;
|
|
638
|
+
|
|
639
|
+
let text = vec![
|
|
640
|
+
Line::from(""),
|
|
641
|
+
Line::from("Step 1: Basic Information").style(
|
|
642
|
+
Style::default()
|
|
643
|
+
.fg(BRAND_PURPLE)
|
|
644
|
+
.add_modifier(Modifier::BOLD),
|
|
645
|
+
),
|
|
646
|
+
Line::from(""),
|
|
647
|
+
Line::from(vec![
|
|
648
|
+
Span::styled(
|
|
649
|
+
if focused == 0 { "▶ " } else { " " },
|
|
650
|
+
Style::default().fg(CYBER_CYAN),
|
|
651
|
+
),
|
|
652
|
+
Span::raw("Name: "),
|
|
653
|
+
Span::styled(&wizard.name, Style::default().fg(NEON_GREEN)),
|
|
654
|
+
Span::styled(
|
|
655
|
+
if focused == 0 { "_" } else { "" },
|
|
656
|
+
Style::default().fg(CYBER_CYAN),
|
|
657
|
+
),
|
|
658
|
+
]),
|
|
659
|
+
Line::from(" (Required, max 50 characters)").style(Style::default().fg(TEXT_DIM)),
|
|
660
|
+
Line::from(""),
|
|
661
|
+
Line::from(vec![
|
|
662
|
+
Span::styled(
|
|
663
|
+
if focused == 1 { "▶ " } else { " " },
|
|
664
|
+
Style::default().fg(CYBER_CYAN),
|
|
665
|
+
),
|
|
666
|
+
Span::raw("Description: "),
|
|
667
|
+
Span::styled(&wizard.description, Style::default().fg(NEON_GREEN)),
|
|
668
|
+
Span::styled(
|
|
669
|
+
if focused == 1 { "_" } else { "" },
|
|
670
|
+
Style::default().fg(CYBER_CYAN),
|
|
671
|
+
),
|
|
672
|
+
]),
|
|
673
|
+
Line::from(" (Optional, brief description of agent purpose)")
|
|
674
|
+
.style(Style::default().fg(TEXT_DIM)),
|
|
675
|
+
Line::from(""),
|
|
676
|
+
Line::from(""),
|
|
677
|
+
Line::from("Navigation:").style(Style::default().fg(TEXT_MUTED)),
|
|
678
|
+
Line::from(" Tab/Shift+Tab/↑↓ - Move between fields").style(Style::default().fg(TEXT_DIM)),
|
|
679
|
+
Line::from(" Enter - Next step").style(Style::default().fg(TEXT_DIM)),
|
|
680
|
+
Line::from(" ESC - Cancel and return to Main").style(Style::default().fg(TEXT_DIM)),
|
|
681
|
+
];
|
|
682
|
+
|
|
683
|
+
// Show validation errors if any
|
|
684
|
+
let mut all_lines = text;
|
|
685
|
+
if !wizard.validation_errors.is_empty() {
|
|
686
|
+
all_lines.push(Line::from(""));
|
|
687
|
+
all_lines.push(
|
|
688
|
+
Line::from("Validation Errors:")
|
|
689
|
+
.style(Style::default().fg(Color::Red).add_modifier(Modifier::BOLD)),
|
|
690
|
+
);
|
|
691
|
+
for error in &wizard.validation_errors {
|
|
692
|
+
all_lines
|
|
693
|
+
.push(Line::from(format!(" • {}", error)).style(Style::default().fg(Color::Red)));
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
let paragraph = Paragraph::new(all_lines)
|
|
698
|
+
.wrap(Wrap { trim: false })
|
|
699
|
+
.alignment(Alignment::Left);
|
|
700
|
+
|
|
701
|
+
f.render_widget(paragraph, area);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
fn render_step_2_model_selection(f: &mut Frame, area: Rect, wizard: &AgentBuilderState) {
|
|
705
|
+
let focused = wizard.focused_field;
|
|
706
|
+
let model_type = if wizard.use_local_model {
|
|
707
|
+
"Local"
|
|
708
|
+
} else {
|
|
709
|
+
"Remote"
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
let text = vec![
|
|
713
|
+
Line::from(""),
|
|
714
|
+
Line::from("Step 2: Model Selection").style(
|
|
715
|
+
Style::default()
|
|
716
|
+
.fg(BRAND_PURPLE)
|
|
717
|
+
.add_modifier(Modifier::BOLD),
|
|
718
|
+
),
|
|
719
|
+
Line::from(""),
|
|
720
|
+
Line::from(vec![
|
|
721
|
+
Span::raw("Model Type: "),
|
|
722
|
+
Span::styled(model_type, Style::default().fg(CYBER_CYAN)),
|
|
723
|
+
]),
|
|
724
|
+
Line::from(" [ ] Remote (OpenAI, Anthropic, etc.)").style(Style::default().fg(TEXT_DIM)),
|
|
725
|
+
Line::from(" [ ] Local (Ollama, LM Studio, etc.)").style(Style::default().fg(TEXT_DIM)),
|
|
726
|
+
Line::from(""),
|
|
727
|
+
Line::from("Remote Model:").style(
|
|
728
|
+
Style::default()
|
|
729
|
+
.fg(TEXT_PRIMARY)
|
|
730
|
+
.add_modifier(Modifier::BOLD),
|
|
731
|
+
),
|
|
732
|
+
Line::from(vec![
|
|
733
|
+
Span::styled(
|
|
734
|
+
if focused == 0 { " ▶ " } else { " " },
|
|
735
|
+
Style::default().fg(CYBER_CYAN),
|
|
736
|
+
),
|
|
737
|
+
Span::raw("Provider: "),
|
|
738
|
+
Span::styled(&wizard.provider, Style::default().fg(NEON_GREEN)),
|
|
739
|
+
Span::styled(
|
|
740
|
+
if focused == 0 { "_" } else { "" },
|
|
741
|
+
Style::default().fg(CYBER_CYAN),
|
|
742
|
+
),
|
|
743
|
+
]),
|
|
744
|
+
Line::from(vec![
|
|
745
|
+
Span::styled(
|
|
746
|
+
if focused == 1 { " ▶ " } else { " " },
|
|
747
|
+
Style::default().fg(CYBER_CYAN),
|
|
748
|
+
),
|
|
749
|
+
Span::raw("Model: "),
|
|
750
|
+
Span::styled(&wizard.model, Style::default().fg(NEON_GREEN)),
|
|
751
|
+
Span::styled(
|
|
752
|
+
if focused == 1 { "_" } else { "" },
|
|
753
|
+
Style::default().fg(CYBER_CYAN),
|
|
754
|
+
),
|
|
755
|
+
]),
|
|
756
|
+
Line::from(""),
|
|
757
|
+
Line::from("Local Model:").style(
|
|
758
|
+
Style::default()
|
|
759
|
+
.fg(TEXT_PRIMARY)
|
|
760
|
+
.add_modifier(Modifier::BOLD),
|
|
761
|
+
),
|
|
762
|
+
Line::from(vec![
|
|
763
|
+
Span::styled(
|
|
764
|
+
if focused == 2 { " ▶ " } else { " " },
|
|
765
|
+
Style::default().fg(CYBER_CYAN),
|
|
766
|
+
),
|
|
767
|
+
Span::raw("Provider: "),
|
|
768
|
+
Span::styled(&wizard.local_provider, Style::default().fg(NEON_GREEN)),
|
|
769
|
+
Span::styled(
|
|
770
|
+
if focused == 2 { "_" } else { "" },
|
|
771
|
+
Style::default().fg(CYBER_CYAN),
|
|
772
|
+
),
|
|
773
|
+
]),
|
|
774
|
+
Line::from(vec![
|
|
775
|
+
Span::styled(
|
|
776
|
+
if focused == 3 { " ▶ " } else { " " },
|
|
777
|
+
Style::default().fg(CYBER_CYAN),
|
|
778
|
+
),
|
|
779
|
+
Span::raw("Model: "),
|
|
780
|
+
Span::styled(&wizard.local_model, Style::default().fg(NEON_GREEN)),
|
|
781
|
+
Span::styled(
|
|
782
|
+
if focused == 3 { "_" } else { "" },
|
|
783
|
+
Style::default().fg(CYBER_CYAN),
|
|
784
|
+
),
|
|
785
|
+
]),
|
|
786
|
+
Line::from(vec![
|
|
787
|
+
Span::styled(
|
|
788
|
+
if focused == 4 { " ▶ " } else { " " },
|
|
789
|
+
Style::default().fg(CYBER_CYAN),
|
|
790
|
+
),
|
|
791
|
+
Span::raw("URL: "),
|
|
792
|
+
Span::styled(&wizard.local_url, Style::default().fg(NEON_GREEN)),
|
|
793
|
+
Span::styled(
|
|
794
|
+
if focused == 4 { "_" } else { "" },
|
|
795
|
+
Style::default().fg(CYBER_CYAN),
|
|
796
|
+
),
|
|
797
|
+
]),
|
|
798
|
+
Line::from(""),
|
|
799
|
+
Line::from("Navigation:").style(Style::default().fg(TEXT_MUTED)),
|
|
800
|
+
Line::from(" Enter - Next step | ESC - Cancel").style(Style::default().fg(TEXT_DIM)),
|
|
801
|
+
];
|
|
802
|
+
|
|
803
|
+
let paragraph = Paragraph::new(text)
|
|
804
|
+
.wrap(Wrap { trim: false })
|
|
805
|
+
.alignment(Alignment::Left);
|
|
806
|
+
|
|
807
|
+
f.render_widget(paragraph, area);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
fn render_step_3_system_prompt(f: &mut Frame, area: Rect, wizard: &AgentBuilderState) {
|
|
811
|
+
let prompt_preview = if wizard.system_prompt.is_empty() {
|
|
812
|
+
"(type to add prompt)".to_string()
|
|
813
|
+
} else {
|
|
814
|
+
wizard.system_prompt.chars().take(200).collect::<String>()
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
let text = vec![
|
|
818
|
+
Line::from(""),
|
|
819
|
+
Line::from("Step 3: System Prompt").style(
|
|
820
|
+
Style::default()
|
|
821
|
+
.fg(BRAND_PURPLE)
|
|
822
|
+
.add_modifier(Modifier::BOLD),
|
|
823
|
+
),
|
|
824
|
+
Line::from(""),
|
|
825
|
+
Line::from("Define the agent's behavior and personality.")
|
|
826
|
+
.style(Style::default().fg(TEXT_PRIMARY)),
|
|
827
|
+
Line::from(""),
|
|
828
|
+
Line::from(vec![
|
|
829
|
+
Span::styled("▶ ", Style::default().fg(CYBER_CYAN)),
|
|
830
|
+
Span::raw("Current Prompt: "),
|
|
831
|
+
Span::styled("_", Style::default().fg(CYBER_CYAN)),
|
|
832
|
+
])
|
|
833
|
+
.style(
|
|
834
|
+
Style::default()
|
|
835
|
+
.fg(TEXT_PRIMARY)
|
|
836
|
+
.add_modifier(Modifier::BOLD),
|
|
837
|
+
),
|
|
838
|
+
Line::from("┌────────────────────────────────────────────────┐")
|
|
839
|
+
.style(Style::default().fg(TEXT_MUTED)),
|
|
840
|
+
Line::from(format!("│ {}│", prompt_preview)).style(Style::default().fg(NEON_GREEN)),
|
|
841
|
+
Line::from("└────────────────────────────────────────────────┘")
|
|
842
|
+
.style(Style::default().fg(TEXT_MUTED)),
|
|
843
|
+
Line::from(""),
|
|
844
|
+
Line::from(format!("Characters: {}", wizard.system_prompt.len()))
|
|
845
|
+
.style(Style::default().fg(TEXT_DIM)),
|
|
846
|
+
Line::from(""),
|
|
847
|
+
Line::from("Examples:").style(Style::default().fg(TEXT_MUTED)),
|
|
848
|
+
Line::from(" • You are a helpful coding assistant").style(Style::default().fg(TEXT_DIM)),
|
|
849
|
+
Line::from(" • You are an expert data analyst").style(Style::default().fg(TEXT_DIM)),
|
|
850
|
+
Line::from(" • You are a creative writing partner").style(Style::default().fg(TEXT_DIM)),
|
|
851
|
+
Line::from(""),
|
|
852
|
+
Line::from("Navigation:").style(Style::default().fg(TEXT_MUTED)),
|
|
853
|
+
Line::from(" Enter - Next step | ESC - Cancel").style(Style::default().fg(TEXT_DIM)),
|
|
854
|
+
];
|
|
855
|
+
|
|
856
|
+
let paragraph = Paragraph::new(text)
|
|
857
|
+
.wrap(Wrap { trim: false })
|
|
858
|
+
.alignment(Alignment::Left);
|
|
859
|
+
|
|
860
|
+
f.render_widget(paragraph, area);
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
fn render_step_4_parameters(f: &mut Frame, area: Rect, wizard: &AgentBuilderState) {
|
|
864
|
+
let focused = wizard.focused_field;
|
|
865
|
+
|
|
866
|
+
let text = vec![
|
|
867
|
+
Line::from(""),
|
|
868
|
+
Line::from("Step 4: Parameters").style(
|
|
869
|
+
Style::default()
|
|
870
|
+
.fg(BRAND_PURPLE)
|
|
871
|
+
.add_modifier(Modifier::BOLD),
|
|
872
|
+
),
|
|
873
|
+
Line::from(""),
|
|
874
|
+
Line::from("Fine-tune the model's behavior.").style(Style::default().fg(TEXT_PRIMARY)),
|
|
875
|
+
Line::from(""),
|
|
876
|
+
Line::from(vec![
|
|
877
|
+
Span::styled(
|
|
878
|
+
if focused == 0 { "▶ " } else { " " },
|
|
879
|
+
Style::default().fg(CYBER_CYAN),
|
|
880
|
+
),
|
|
881
|
+
Span::raw("Temperature: "),
|
|
882
|
+
Span::styled(
|
|
883
|
+
format!("{:.2}", wizard.temperature),
|
|
884
|
+
Style::default().fg(NEON_GREEN),
|
|
885
|
+
),
|
|
886
|
+
Span::styled(
|
|
887
|
+
if focused == 0 { "_" } else { "" },
|
|
888
|
+
Style::default().fg(CYBER_CYAN),
|
|
889
|
+
),
|
|
890
|
+
Span::raw(" (0.0 = focused, 2.0 = creative)"),
|
|
891
|
+
])
|
|
892
|
+
.style(Style::default().fg(TEXT_PRIMARY)),
|
|
893
|
+
Line::from(""),
|
|
894
|
+
Line::from(vec![
|
|
895
|
+
Span::styled(
|
|
896
|
+
if focused == 1 { "▶ " } else { " " },
|
|
897
|
+
Style::default().fg(CYBER_CYAN),
|
|
898
|
+
),
|
|
899
|
+
Span::raw("Max Tokens: "),
|
|
900
|
+
Span::styled(
|
|
901
|
+
format!("{}", wizard.max_tokens),
|
|
902
|
+
Style::default().fg(NEON_GREEN),
|
|
903
|
+
),
|
|
904
|
+
Span::styled(
|
|
905
|
+
if focused == 1 { "_" } else { "" },
|
|
906
|
+
Style::default().fg(CYBER_CYAN),
|
|
907
|
+
),
|
|
908
|
+
Span::raw(" (1-100000)"),
|
|
909
|
+
])
|
|
910
|
+
.style(Style::default().fg(TEXT_PRIMARY)),
|
|
911
|
+
Line::from(""),
|
|
912
|
+
Line::from(vec![
|
|
913
|
+
Span::raw("Top P: "),
|
|
914
|
+
Span::styled(
|
|
915
|
+
format!("{:.2}", wizard.top_p),
|
|
916
|
+
Style::default().fg(TEXT_DIM),
|
|
917
|
+
),
|
|
918
|
+
Span::raw(" (0.0-1.0, nucleus sampling)"),
|
|
919
|
+
])
|
|
920
|
+
.style(Style::default().fg(TEXT_DIM)),
|
|
921
|
+
Line::from(""),
|
|
922
|
+
Line::from(vec![
|
|
923
|
+
Span::raw("Frequency Penalty: "),
|
|
924
|
+
Span::styled(
|
|
925
|
+
format!("{:.2}", wizard.frequency_penalty),
|
|
926
|
+
Style::default().fg(TEXT_DIM),
|
|
927
|
+
),
|
|
928
|
+
Span::raw(" (-2.0 to 2.0)"),
|
|
929
|
+
])
|
|
930
|
+
.style(Style::default().fg(TEXT_DIM)),
|
|
931
|
+
Line::from(""),
|
|
932
|
+
Line::from(vec![
|
|
933
|
+
Span::raw("Presence Penalty: "),
|
|
934
|
+
Span::styled(
|
|
935
|
+
format!("{:.2}", wizard.presence_penalty),
|
|
936
|
+
Style::default().fg(TEXT_DIM),
|
|
937
|
+
),
|
|
938
|
+
Span::raw(" (-2.0 to 2.0)"),
|
|
939
|
+
])
|
|
940
|
+
.style(Style::default().fg(TEXT_DIM)),
|
|
941
|
+
Line::from(""),
|
|
942
|
+
Line::from("Navigation:").style(Style::default().fg(TEXT_MUTED)),
|
|
943
|
+
Line::from(" Enter - Next step | ESC - Cancel").style(Style::default().fg(TEXT_DIM)),
|
|
944
|
+
];
|
|
945
|
+
|
|
946
|
+
let paragraph = Paragraph::new(text)
|
|
947
|
+
.wrap(Wrap { trim: false })
|
|
948
|
+
.alignment(Alignment::Left);
|
|
949
|
+
|
|
950
|
+
f.render_widget(paragraph, area);
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
fn render_step_5_tools(f: &mut Frame, area: Rect, wizard: &AgentBuilderState) {
|
|
954
|
+
let selected_count = wizard.selected_tools.len();
|
|
955
|
+
let available_count = wizard.available_tools.len();
|
|
956
|
+
let focused = wizard.focused_field;
|
|
957
|
+
|
|
958
|
+
let mut text = vec![
|
|
959
|
+
Line::from(""),
|
|
960
|
+
Line::from("Step 5: Tools Selection").style(
|
|
961
|
+
Style::default()
|
|
962
|
+
.fg(BRAND_PURPLE)
|
|
963
|
+
.add_modifier(Modifier::BOLD),
|
|
964
|
+
),
|
|
965
|
+
Line::from(""),
|
|
966
|
+
Line::from(format!(
|
|
967
|
+
"Selected: {} / {} tools",
|
|
968
|
+
selected_count, available_count
|
|
969
|
+
))
|
|
970
|
+
.style(Style::default().fg(CYBER_CYAN)),
|
|
971
|
+
Line::from(""),
|
|
972
|
+
Line::from("Available Tools:").style(
|
|
973
|
+
Style::default()
|
|
974
|
+
.fg(TEXT_PRIMARY)
|
|
975
|
+
.add_modifier(Modifier::BOLD),
|
|
976
|
+
),
|
|
977
|
+
];
|
|
978
|
+
|
|
979
|
+
for (i, tool) in wizard.available_tools.iter().enumerate() {
|
|
980
|
+
let is_selected = wizard.selected_tools.contains(tool);
|
|
981
|
+
let checkbox = if is_selected { "[✓]" } else { "[ ]" };
|
|
982
|
+
let is_focused = i == focused;
|
|
983
|
+
let style = if is_selected {
|
|
984
|
+
Style::default().fg(NEON_GREEN)
|
|
985
|
+
} else if is_focused {
|
|
986
|
+
Style::default().fg(CYBER_CYAN)
|
|
987
|
+
} else {
|
|
988
|
+
Style::default().fg(TEXT_PRIMARY)
|
|
989
|
+
};
|
|
990
|
+
text.push(Line::from(vec![
|
|
991
|
+
Span::styled(
|
|
992
|
+
if is_focused { "▶ " } else { " " },
|
|
993
|
+
Style::default().fg(CYBER_CYAN),
|
|
994
|
+
),
|
|
995
|
+
Span::styled(format!("{} ", checkbox), style),
|
|
996
|
+
Span::styled(tool.clone(), style),
|
|
997
|
+
]));
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
text.extend(vec![
|
|
1001
|
+
Line::from(""),
|
|
1002
|
+
Line::from("Note: Use Space to toggle, ↑↓ to navigate")
|
|
1003
|
+
.style(Style::default().fg(TEXT_DIM)),
|
|
1004
|
+
Line::from(""),
|
|
1005
|
+
Line::from("Navigation:").style(Style::default().fg(TEXT_MUTED)),
|
|
1006
|
+
Line::from(" Enter - Next step | ESC - Cancel").style(Style::default().fg(TEXT_DIM)),
|
|
1007
|
+
]);
|
|
1008
|
+
|
|
1009
|
+
let paragraph = Paragraph::new(text)
|
|
1010
|
+
.wrap(Wrap { trim: false })
|
|
1011
|
+
.alignment(Alignment::Left);
|
|
1012
|
+
|
|
1013
|
+
f.render_widget(paragraph, area);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
fn render_step_6_review(f: &mut Frame, area: Rect, wizard: &AgentBuilderState) {
|
|
1017
|
+
let provider = if wizard.use_local_model {
|
|
1018
|
+
"local"
|
|
1019
|
+
} else {
|
|
1020
|
+
&wizard.provider
|
|
1021
|
+
};
|
|
1022
|
+
let model = if wizard.use_local_model {
|
|
1023
|
+
&wizard.local_model
|
|
1024
|
+
} else {
|
|
1025
|
+
&wizard.model
|
|
1026
|
+
};
|
|
1027
|
+
|
|
1028
|
+
let model_info_str = if wizard.use_local_model {
|
|
1029
|
+
format!("{} ({})", wizard.local_model, wizard.local_provider)
|
|
1030
|
+
} else {
|
|
1031
|
+
format!("{} ({})", wizard.model, wizard.provider)
|
|
1032
|
+
};
|
|
1033
|
+
|
|
1034
|
+
let cost = calculate_cost(provider, model, wizard.max_tokens);
|
|
1035
|
+
let model_info = get_model_info(provider, model);
|
|
1036
|
+
|
|
1037
|
+
let mut text = vec![
|
|
1038
|
+
Line::from(""),
|
|
1039
|
+
Line::from("Step 6: Review & Confirm").style(
|
|
1040
|
+
Style::default()
|
|
1041
|
+
.fg(BRAND_PURPLE)
|
|
1042
|
+
.add_modifier(Modifier::BOLD),
|
|
1043
|
+
),
|
|
1044
|
+
Line::from(""),
|
|
1045
|
+
Line::from("✓ Configuration Complete - Ready to Create")
|
|
1046
|
+
.style(Style::default().fg(NEON_GREEN).bold()),
|
|
1047
|
+
Line::from(""),
|
|
1048
|
+
Line::from("═══════════════════════════════════════════════════")
|
|
1049
|
+
.style(Style::default().fg(TEXT_MUTED)),
|
|
1050
|
+
Line::from(""),
|
|
1051
|
+
Line::from("Basic Info:").style(Style::default().fg(CYBER_CYAN).bold()),
|
|
1052
|
+
Line::from(vec![
|
|
1053
|
+
Span::styled(" Name: ", Style::default().fg(TEXT_DIM)),
|
|
1054
|
+
Span::styled(
|
|
1055
|
+
&wizard.name,
|
|
1056
|
+
Style::default().fg(NEON_GREEN).add_modifier(Modifier::BOLD),
|
|
1057
|
+
),
|
|
1058
|
+
]),
|
|
1059
|
+
Line::from(vec![
|
|
1060
|
+
Span::styled(" Description: ", Style::default().fg(TEXT_DIM)),
|
|
1061
|
+
Span::styled(
|
|
1062
|
+
if wizard.description.is_empty() {
|
|
1063
|
+
"(none)"
|
|
1064
|
+
} else {
|
|
1065
|
+
wizard.description.as_str()
|
|
1066
|
+
},
|
|
1067
|
+
Style::default().fg(TEXT_PRIMARY),
|
|
1068
|
+
),
|
|
1069
|
+
]),
|
|
1070
|
+
Line::from(""),
|
|
1071
|
+
Line::from("Model Configuration:").style(Style::default().fg(CYBER_CYAN).bold()),
|
|
1072
|
+
Line::from(vec![
|
|
1073
|
+
Span::styled(" Model: ", Style::default().fg(TEXT_DIM)),
|
|
1074
|
+
Span::styled(&model_info_str, Style::default().fg(TEXT_PRIMARY).bold()),
|
|
1075
|
+
]),
|
|
1076
|
+
Line::from(vec![
|
|
1077
|
+
Span::styled(" Context Window: ", Style::default().fg(TEXT_DIM)),
|
|
1078
|
+
Span::styled(
|
|
1079
|
+
format!("{} tokens", model_info.context_window),
|
|
1080
|
+
Style::default().fg(TEXT_PRIMARY),
|
|
1081
|
+
),
|
|
1082
|
+
]),
|
|
1083
|
+
Line::from(vec![
|
|
1084
|
+
Span::styled(" Temperature: ", Style::default().fg(TEXT_DIM)),
|
|
1085
|
+
Span::styled(
|
|
1086
|
+
format!("{:.2}", wizard.temperature),
|
|
1087
|
+
Style::default().fg(TEXT_PRIMARY),
|
|
1088
|
+
),
|
|
1089
|
+
]),
|
|
1090
|
+
Line::from(vec![
|
|
1091
|
+
Span::styled(" Max Tokens: ", Style::default().fg(TEXT_DIM)),
|
|
1092
|
+
Span::styled(
|
|
1093
|
+
format!("{}", wizard.max_tokens),
|
|
1094
|
+
Style::default().fg(TEXT_PRIMARY),
|
|
1095
|
+
),
|
|
1096
|
+
]),
|
|
1097
|
+
Line::from(""),
|
|
1098
|
+
Line::from("Tools:").style(Style::default().fg(CYBER_CYAN).bold()),
|
|
1099
|
+
Line::from(vec![
|
|
1100
|
+
Span::styled(" ", Style::default()),
|
|
1101
|
+
Span::styled(
|
|
1102
|
+
if wizard.selected_tools.is_empty() {
|
|
1103
|
+
"None selected".to_string()
|
|
1104
|
+
} else {
|
|
1105
|
+
wizard.selected_tools.join(", ")
|
|
1106
|
+
},
|
|
1107
|
+
Style::default().fg(TEXT_PRIMARY),
|
|
1108
|
+
),
|
|
1109
|
+
]),
|
|
1110
|
+
];
|
|
1111
|
+
|
|
1112
|
+
// Add cost estimate
|
|
1113
|
+
if !cost.is_free {
|
|
1114
|
+
text.push(Line::from(""));
|
|
1115
|
+
text.push(Line::from("Estimated Cost:").style(Style::default().fg(AMBER_WARN).bold()));
|
|
1116
|
+
text.push(Line::from(vec![
|
|
1117
|
+
Span::styled(" Per 1K tokens: ", Style::default().fg(TEXT_DIM)),
|
|
1118
|
+
Span::styled(
|
|
1119
|
+
format!("${:.4}", cost.cost_1k),
|
|
1120
|
+
Style::default().fg(TEXT_PRIMARY),
|
|
1121
|
+
),
|
|
1122
|
+
]));
|
|
1123
|
+
} else {
|
|
1124
|
+
text.push(Line::from(""));
|
|
1125
|
+
text.push(Line::from(vec![
|
|
1126
|
+
Span::styled(" ✓ ", Style::default().fg(NEON_GREEN)),
|
|
1127
|
+
Span::styled("FREE (Local Model)", Style::default().fg(NEON_GREEN).bold()),
|
|
1128
|
+
]));
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
text.push(Line::from(""));
|
|
1132
|
+
text.push(
|
|
1133
|
+
Line::from("═══════════════════════════════════════════════════")
|
|
1134
|
+
.style(Style::default().fg(TEXT_MUTED)),
|
|
1135
|
+
);
|
|
1136
|
+
text.push(Line::from(""));
|
|
1137
|
+
text.push(Line::from(vec![
|
|
1138
|
+
Span::styled("Press ", Style::default().fg(TEXT_DIM)),
|
|
1139
|
+
Span::styled("Enter", Style::default().fg(NEON_GREEN).bold()),
|
|
1140
|
+
Span::styled(" to create this agent", Style::default().fg(TEXT_DIM)),
|
|
1141
|
+
]));
|
|
1142
|
+
|
|
1143
|
+
let paragraph = Paragraph::new(text)
|
|
1144
|
+
.wrap(Wrap { trim: false })
|
|
1145
|
+
.alignment(Alignment::Left);
|
|
1146
|
+
|
|
1147
|
+
f.render_widget(paragraph, area);
|
|
1148
|
+
}
|