@almadar/std 3.12.2 → 3.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/behaviors/exports/atoms/std-agent-activity-log.orb +559 -0
  2. package/behaviors/exports/atoms/std-agent-chat-thread.orb +774 -0
  3. package/behaviors/exports/atoms/std-agent-classifier.orb +871 -0
  4. package/behaviors/exports/atoms/std-agent-completion.orb +933 -0
  5. package/behaviors/exports/atoms/std-agent-context-window.orb +2294 -0
  6. package/behaviors/exports/atoms/std-agent-conversation.orb +1020 -0
  7. package/behaviors/exports/atoms/std-agent-memory.orb +879 -0
  8. package/behaviors/exports/atoms/std-agent-provider.orb +898 -0
  9. package/behaviors/exports/atoms/std-agent-search.orb +448 -0
  10. package/behaviors/exports/atoms/std-agent-session.orb +835 -0
  11. package/behaviors/exports/atoms/std-agent-step-progress.orb +850 -0
  12. package/behaviors/exports/atoms/std-agent-token-gauge.orb +1616 -0
  13. package/behaviors/exports/atoms/std-agent-tool-call.orb +1237 -0
  14. package/behaviors/exports/molecules/std-agent-fix-loop.orb +3177 -0
  15. package/behaviors/exports/molecules/std-agent-learner.orb +2950 -0
  16. package/behaviors/exports/molecules/std-agent-planner.orb +2655 -0
  17. package/behaviors/exports/molecules/std-agent-rag.orb +1871 -0
  18. package/behaviors/exports/molecules/std-agent-tool-loop.orb +4857 -0
  19. package/behaviors/exports/organisms/std-agent-assistant.orb +6440 -0
  20. package/behaviors/exports/organisms/std-agent-builder.orb +14863 -0
  21. package/behaviors/exports/organisms/std-agent-pipeline.orb +11950 -0
  22. package/behaviors/exports/organisms/std-agent-reviewer.orb +5405 -0
  23. package/behaviors/exports/organisms/std-agent-tutor.orb +5107 -0
  24. package/behaviors/exports/validation-report.json +2 -1099
  25. package/dist/behaviors/exports/atoms/std-agent-activity-log.orb +559 -0
  26. package/dist/behaviors/exports/atoms/std-agent-chat-thread.orb +774 -0
  27. package/dist/behaviors/exports/atoms/std-agent-classifier.orb +871 -0
  28. package/dist/behaviors/exports/atoms/std-agent-completion.orb +933 -0
  29. package/dist/behaviors/exports/atoms/std-agent-context-window.orb +2294 -0
  30. package/dist/behaviors/exports/atoms/std-agent-conversation.orb +1020 -0
  31. package/dist/behaviors/exports/atoms/std-agent-memory.orb +879 -0
  32. package/dist/behaviors/exports/atoms/std-agent-provider.orb +898 -0
  33. package/dist/behaviors/exports/atoms/std-agent-search.orb +448 -0
  34. package/dist/behaviors/exports/atoms/std-agent-session.orb +835 -0
  35. package/dist/behaviors/exports/atoms/std-agent-step-progress.orb +850 -0
  36. package/dist/behaviors/exports/atoms/std-agent-token-gauge.orb +1616 -0
  37. package/dist/behaviors/exports/atoms/std-agent-tool-call.orb +1237 -0
  38. package/dist/behaviors/exports/molecules/std-agent-fix-loop.orb +3177 -0
  39. package/dist/behaviors/exports/molecules/std-agent-learner.orb +2950 -0
  40. package/dist/behaviors/exports/molecules/std-agent-planner.orb +2655 -0
  41. package/dist/behaviors/exports/molecules/std-agent-rag.orb +1871 -0
  42. package/dist/behaviors/exports/molecules/std-agent-tool-loop.orb +4857 -0
  43. package/dist/behaviors/exports/organisms/std-agent-assistant.orb +6440 -0
  44. package/dist/behaviors/exports/organisms/std-agent-builder.orb +14863 -0
  45. package/dist/behaviors/exports/organisms/std-agent-pipeline.orb +11950 -0
  46. package/dist/behaviors/exports/organisms/std-agent-reviewer.orb +5405 -0
  47. package/dist/behaviors/exports/organisms/std-agent-tutor.orb +5107 -0
  48. package/dist/behaviors/exports/validation-report.json +2 -1099
  49. package/dist/behaviors/exports-reader.js +7156 -302
  50. package/dist/behaviors/exports-reader.js.map +1 -1
  51. package/dist/behaviors/functions/index.d.ts +781 -1
  52. package/dist/behaviors/functions/index.js +7080 -303
  53. package/dist/behaviors/functions/index.js.map +1 -1
  54. package/dist/behaviors/index.d.ts +1 -1
  55. package/dist/behaviors/index.js +7159 -305
  56. package/dist/behaviors/index.js.map +1 -1
  57. package/dist/behaviors/query.js +7158 -304
  58. package/dist/behaviors/query.js.map +1 -1
  59. package/dist/exports/atoms/std-agent-activity-log.orb +559 -0
  60. package/dist/exports/atoms/std-agent-chat-thread.orb +774 -0
  61. package/dist/exports/atoms/std-agent-classifier.orb +871 -0
  62. package/dist/exports/atoms/std-agent-completion.orb +933 -0
  63. package/dist/exports/atoms/std-agent-context-window.orb +2294 -0
  64. package/dist/exports/atoms/std-agent-conversation.orb +1020 -0
  65. package/dist/exports/atoms/std-agent-memory.orb +879 -0
  66. package/dist/exports/atoms/std-agent-provider.orb +898 -0
  67. package/dist/exports/atoms/std-agent-search.orb +448 -0
  68. package/dist/exports/atoms/std-agent-session.orb +835 -0
  69. package/dist/exports/atoms/std-agent-step-progress.orb +850 -0
  70. package/dist/exports/atoms/std-agent-token-gauge.orb +1616 -0
  71. package/dist/exports/atoms/std-agent-tool-call.orb +1237 -0
  72. package/dist/exports/molecules/std-agent-fix-loop.orb +3177 -0
  73. package/dist/exports/molecules/std-agent-learner.orb +2950 -0
  74. package/dist/exports/molecules/std-agent-planner.orb +2655 -0
  75. package/dist/exports/molecules/std-agent-rag.orb +1871 -0
  76. package/dist/exports/molecules/std-agent-tool-loop.orb +4857 -0
  77. package/dist/exports/organisms/std-agent-assistant.orb +6440 -0
  78. package/dist/exports/organisms/std-agent-builder.orb +14863 -0
  79. package/dist/exports/organisms/std-agent-pipeline.orb +11950 -0
  80. package/dist/exports/organisms/std-agent-reviewer.orb +5405 -0
  81. package/dist/exports/organisms/std-agent-tutor.orb +5107 -0
  82. package/dist/exports/validation-report.json +2 -1099
  83. package/dist/index.d.ts +1 -1
  84. package/dist/index.js +7159 -305
  85. package/dist/index.js.map +1 -1
  86. package/package.json +1 -1
@@ -0,0 +1,2294 @@
1
+ {
2
+ "name": "AgentContextWindowOrbital",
3
+ "orbitals": [
4
+ {
5
+ "name": "AgentContextWindowOrbital",
6
+ "entity": {
7
+ "name": "AgentContextWindow",
8
+ "persistence": "persistent",
9
+ "collection": "agentcontextwindows",
10
+ "fields": [
11
+ {
12
+ "name": "id",
13
+ "type": "string"
14
+ },
15
+ {
16
+ "name": "name",
17
+ "type": "string"
18
+ },
19
+ {
20
+ "name": "description",
21
+ "type": "string"
22
+ },
23
+ {
24
+ "name": "status",
25
+ "type": "string",
26
+ "default": "active",
27
+ "values": [
28
+ "active",
29
+ "inactive",
30
+ "pending"
31
+ ]
32
+ },
33
+ {
34
+ "name": "createdAt",
35
+ "type": "string"
36
+ },
37
+ {
38
+ "name": "tokenCount",
39
+ "type": "number",
40
+ "default": 0
41
+ },
42
+ {
43
+ "name": "maxTokens",
44
+ "type": "number",
45
+ "default": 200000
46
+ },
47
+ {
48
+ "name": "usage",
49
+ "type": "number",
50
+ "default": 0
51
+ },
52
+ {
53
+ "name": "lastCompactedAt",
54
+ "type": "string",
55
+ "default": ""
56
+ },
57
+ {
58
+ "name": "current",
59
+ "type": "number",
60
+ "default": 0
61
+ },
62
+ {
63
+ "name": "max",
64
+ "type": "number",
65
+ "default": 200000
66
+ },
67
+ {
68
+ "name": "threshold",
69
+ "type": "number",
70
+ "default": 0.85
71
+ },
72
+ {
73
+ "name": "message",
74
+ "type": "string",
75
+ "default": ""
76
+ },
77
+ {
78
+ "name": "notificationType",
79
+ "type": "string",
80
+ "default": "info"
81
+ }
82
+ ]
83
+ },
84
+ "traits": [
85
+ {
86
+ "name": "AgentContextWindowGauge",
87
+ "linkedEntity": "AgentContextWindow",
88
+ "category": "interaction",
89
+ "stateMachine": {
90
+ "states": [
91
+ {
92
+ "name": "normal",
93
+ "isInitial": true
94
+ },
95
+ {
96
+ "name": "warning"
97
+ },
98
+ {
99
+ "name": "critical"
100
+ }
101
+ ],
102
+ "events": [
103
+ {
104
+ "key": "INIT",
105
+ "name": "Initialize"
106
+ },
107
+ {
108
+ "key": "UPDATE",
109
+ "name": "Update Token Count",
110
+ "payload": [
111
+ {
112
+ "name": "current",
113
+ "type": "number",
114
+ "required": true
115
+ }
116
+ ]
117
+ },
118
+ {
119
+ "key": "COMPACT",
120
+ "name": "Compact Context"
121
+ },
122
+ {
123
+ "key": "RESET",
124
+ "name": "Reset Gauge"
125
+ }
126
+ ],
127
+ "transitions": [
128
+ {
129
+ "from": "normal",
130
+ "to": "normal",
131
+ "event": "INIT",
132
+ "effects": [
133
+ [
134
+ "fetch",
135
+ "AgentContextWindow"
136
+ ],
137
+ [
138
+ "render-ui",
139
+ "main",
140
+ {
141
+ "type": "stack",
142
+ "direction": "vertical",
143
+ "gap": "lg",
144
+ "children": [
145
+ {
146
+ "type": "stack",
147
+ "direction": "horizontal",
148
+ "gap": "sm",
149
+ "align": "center",
150
+ "children": [
151
+ {
152
+ "type": "icon",
153
+ "name": "gauge",
154
+ "size": "lg"
155
+ },
156
+ {
157
+ "type": "typography",
158
+ "content": "Token Usage",
159
+ "variant": "h2"
160
+ },
161
+ {
162
+ "type": "badge",
163
+ "label": "Normal",
164
+ "variant": "default"
165
+ }
166
+ ]
167
+ },
168
+ {
169
+ "type": "divider"
170
+ },
171
+ {
172
+ "type": "progress-bar",
173
+ "value": "@entity.current",
174
+ "max": "@entity.max"
175
+ },
176
+ {
177
+ "type": "stack",
178
+ "direction": "horizontal",
179
+ "gap": "md",
180
+ "children": [
181
+ {
182
+ "type": "stat-display",
183
+ "label": "Tokens Used",
184
+ "value": "@entity.current"
185
+ },
186
+ {
187
+ "type": "stat-display",
188
+ "label": "Max Tokens",
189
+ "value": "@entity.max"
190
+ }
191
+ ]
192
+ },
193
+ {
194
+ "type": "button",
195
+ "label": "Reset",
196
+ "event": "RESET",
197
+ "variant": "ghost",
198
+ "icon": "rotate-ccw"
199
+ }
200
+ ]
201
+ }
202
+ ]
203
+ ]
204
+ },
205
+ {
206
+ "from": "normal",
207
+ "to": "normal",
208
+ "event": "UPDATE",
209
+ "guard": [
210
+ "<",
211
+ [
212
+ "/",
213
+ "@payload.current",
214
+ "@entity.max"
215
+ ],
216
+ 0.85
217
+ ],
218
+ "effects": [
219
+ [
220
+ "set",
221
+ "@entity.current",
222
+ "@payload.current"
223
+ ],
224
+ [
225
+ "render-ui",
226
+ "main",
227
+ {
228
+ "type": "stack",
229
+ "direction": "vertical",
230
+ "gap": "lg",
231
+ "children": [
232
+ {
233
+ "type": "stack",
234
+ "direction": "horizontal",
235
+ "gap": "sm",
236
+ "align": "center",
237
+ "children": [
238
+ {
239
+ "type": "icon",
240
+ "name": "gauge",
241
+ "size": "lg"
242
+ },
243
+ {
244
+ "type": "typography",
245
+ "content": "Token Usage",
246
+ "variant": "h2"
247
+ },
248
+ {
249
+ "type": "badge",
250
+ "label": "Normal",
251
+ "variant": "default"
252
+ }
253
+ ]
254
+ },
255
+ {
256
+ "type": "divider"
257
+ },
258
+ {
259
+ "type": "progress-bar",
260
+ "value": "@entity.current",
261
+ "max": "@entity.max"
262
+ },
263
+ {
264
+ "type": "stack",
265
+ "direction": "horizontal",
266
+ "gap": "md",
267
+ "children": [
268
+ {
269
+ "type": "stat-display",
270
+ "label": "Tokens Used",
271
+ "value": "@entity.current"
272
+ },
273
+ {
274
+ "type": "stat-display",
275
+ "label": "Max Tokens",
276
+ "value": "@entity.max"
277
+ }
278
+ ]
279
+ },
280
+ {
281
+ "type": "button",
282
+ "label": "Reset",
283
+ "event": "RESET",
284
+ "variant": "ghost",
285
+ "icon": "rotate-ccw"
286
+ }
287
+ ]
288
+ }
289
+ ]
290
+ ]
291
+ },
292
+ {
293
+ "from": "normal",
294
+ "to": "warning",
295
+ "event": "UPDATE",
296
+ "guard": [
297
+ "and",
298
+ [
299
+ ">=",
300
+ [
301
+ "/",
302
+ "@payload.current",
303
+ "@entity.max"
304
+ ],
305
+ 0.85
306
+ ],
307
+ [
308
+ "<",
309
+ [
310
+ "/",
311
+ "@payload.current",
312
+ "@entity.max"
313
+ ],
314
+ 0.95
315
+ ]
316
+ ],
317
+ "effects": [
318
+ [
319
+ "set",
320
+ "@entity.current",
321
+ "@payload.current"
322
+ ],
323
+ [
324
+ "render-ui",
325
+ "main",
326
+ {
327
+ "type": "stack",
328
+ "direction": "vertical",
329
+ "gap": "lg",
330
+ "children": [
331
+ {
332
+ "type": "stack",
333
+ "direction": "horizontal",
334
+ "gap": "sm",
335
+ "align": "center",
336
+ "children": [
337
+ {
338
+ "type": "icon",
339
+ "name": "alert-triangle",
340
+ "size": "lg"
341
+ },
342
+ {
343
+ "type": "typography",
344
+ "content": "Token Usage",
345
+ "variant": "h2"
346
+ },
347
+ {
348
+ "type": "badge",
349
+ "label": "Warning",
350
+ "variant": "warning"
351
+ }
352
+ ]
353
+ },
354
+ {
355
+ "type": "divider"
356
+ },
357
+ {
358
+ "type": "alert",
359
+ "variant": "warning",
360
+ "message": "Token usage approaching limit. Consider compacting."
361
+ },
362
+ {
363
+ "type": "progress-bar",
364
+ "value": "@entity.current",
365
+ "max": "@entity.max"
366
+ },
367
+ {
368
+ "type": "stack",
369
+ "direction": "horizontal",
370
+ "gap": "md",
371
+ "children": [
372
+ {
373
+ "type": "stat-display",
374
+ "label": "Tokens Used",
375
+ "value": "@entity.current"
376
+ },
377
+ {
378
+ "type": "stat-display",
379
+ "label": "Max Tokens",
380
+ "value": "@entity.max"
381
+ }
382
+ ]
383
+ },
384
+ {
385
+ "type": "stack",
386
+ "direction": "horizontal",
387
+ "gap": "sm",
388
+ "children": [
389
+ {
390
+ "type": "button",
391
+ "label": "Compact",
392
+ "event": "COMPACT",
393
+ "variant": "primary",
394
+ "icon": "minimize-2"
395
+ },
396
+ {
397
+ "type": "button",
398
+ "label": "Reset",
399
+ "event": "RESET",
400
+ "variant": "ghost",
401
+ "icon": "rotate-ccw"
402
+ }
403
+ ]
404
+ }
405
+ ]
406
+ }
407
+ ]
408
+ ]
409
+ },
410
+ {
411
+ "from": "normal",
412
+ "to": "critical",
413
+ "event": "UPDATE",
414
+ "guard": [
415
+ ">=",
416
+ [
417
+ "/",
418
+ "@payload.current",
419
+ "@entity.max"
420
+ ],
421
+ 0.95
422
+ ],
423
+ "effects": [
424
+ [
425
+ "set",
426
+ "@entity.current",
427
+ "@payload.current"
428
+ ],
429
+ [
430
+ "render-ui",
431
+ "main",
432
+ {
433
+ "type": "stack",
434
+ "direction": "vertical",
435
+ "gap": "lg",
436
+ "children": [
437
+ {
438
+ "type": "stack",
439
+ "direction": "horizontal",
440
+ "gap": "sm",
441
+ "align": "center",
442
+ "children": [
443
+ {
444
+ "type": "icon",
445
+ "name": "alert-octagon",
446
+ "size": "lg"
447
+ },
448
+ {
449
+ "type": "typography",
450
+ "content": "Token Usage",
451
+ "variant": "h2"
452
+ },
453
+ {
454
+ "type": "badge",
455
+ "label": "Critical",
456
+ "variant": "destructive"
457
+ }
458
+ ]
459
+ },
460
+ {
461
+ "type": "divider"
462
+ },
463
+ {
464
+ "type": "alert",
465
+ "variant": "error",
466
+ "message": "Token usage critical. Compact immediately to avoid truncation."
467
+ },
468
+ {
469
+ "type": "progress-bar",
470
+ "value": "@entity.current",
471
+ "max": "@entity.max"
472
+ },
473
+ {
474
+ "type": "stack",
475
+ "direction": "horizontal",
476
+ "gap": "md",
477
+ "children": [
478
+ {
479
+ "type": "stat-display",
480
+ "label": "Tokens Used",
481
+ "value": "@entity.current"
482
+ },
483
+ {
484
+ "type": "stat-display",
485
+ "label": "Max Tokens",
486
+ "value": "@entity.max"
487
+ }
488
+ ]
489
+ },
490
+ {
491
+ "type": "stack",
492
+ "direction": "horizontal",
493
+ "gap": "sm",
494
+ "children": [
495
+ {
496
+ "type": "button",
497
+ "label": "Compact Now",
498
+ "event": "COMPACT",
499
+ "variant": "primary",
500
+ "icon": "minimize-2"
501
+ },
502
+ {
503
+ "type": "button",
504
+ "label": "Reset",
505
+ "event": "RESET",
506
+ "variant": "ghost",
507
+ "icon": "rotate-ccw"
508
+ }
509
+ ]
510
+ }
511
+ ]
512
+ }
513
+ ]
514
+ ]
515
+ },
516
+ {
517
+ "from": "warning",
518
+ "to": "warning",
519
+ "event": "UPDATE",
520
+ "guard": [
521
+ "and",
522
+ [
523
+ ">=",
524
+ [
525
+ "/",
526
+ "@payload.current",
527
+ "@entity.max"
528
+ ],
529
+ 0.85
530
+ ],
531
+ [
532
+ "<",
533
+ [
534
+ "/",
535
+ "@payload.current",
536
+ "@entity.max"
537
+ ],
538
+ 0.95
539
+ ]
540
+ ],
541
+ "effects": [
542
+ [
543
+ "set",
544
+ "@entity.current",
545
+ "@payload.current"
546
+ ],
547
+ [
548
+ "render-ui",
549
+ "main",
550
+ {
551
+ "type": "stack",
552
+ "direction": "vertical",
553
+ "gap": "lg",
554
+ "children": [
555
+ {
556
+ "type": "stack",
557
+ "direction": "horizontal",
558
+ "gap": "sm",
559
+ "align": "center",
560
+ "children": [
561
+ {
562
+ "type": "icon",
563
+ "name": "alert-triangle",
564
+ "size": "lg"
565
+ },
566
+ {
567
+ "type": "typography",
568
+ "content": "Token Usage",
569
+ "variant": "h2"
570
+ },
571
+ {
572
+ "type": "badge",
573
+ "label": "Warning",
574
+ "variant": "warning"
575
+ }
576
+ ]
577
+ },
578
+ {
579
+ "type": "divider"
580
+ },
581
+ {
582
+ "type": "alert",
583
+ "variant": "warning",
584
+ "message": "Token usage approaching limit. Consider compacting."
585
+ },
586
+ {
587
+ "type": "progress-bar",
588
+ "value": "@entity.current",
589
+ "max": "@entity.max"
590
+ },
591
+ {
592
+ "type": "stack",
593
+ "direction": "horizontal",
594
+ "gap": "md",
595
+ "children": [
596
+ {
597
+ "type": "stat-display",
598
+ "label": "Tokens Used",
599
+ "value": "@entity.current"
600
+ },
601
+ {
602
+ "type": "stat-display",
603
+ "label": "Max Tokens",
604
+ "value": "@entity.max"
605
+ }
606
+ ]
607
+ },
608
+ {
609
+ "type": "stack",
610
+ "direction": "horizontal",
611
+ "gap": "sm",
612
+ "children": [
613
+ {
614
+ "type": "button",
615
+ "label": "Compact",
616
+ "event": "COMPACT",
617
+ "variant": "primary",
618
+ "icon": "minimize-2"
619
+ },
620
+ {
621
+ "type": "button",
622
+ "label": "Reset",
623
+ "event": "RESET",
624
+ "variant": "ghost",
625
+ "icon": "rotate-ccw"
626
+ }
627
+ ]
628
+ }
629
+ ]
630
+ }
631
+ ]
632
+ ]
633
+ },
634
+ {
635
+ "from": "warning",
636
+ "to": "critical",
637
+ "event": "UPDATE",
638
+ "guard": [
639
+ ">=",
640
+ [
641
+ "/",
642
+ "@payload.current",
643
+ "@entity.max"
644
+ ],
645
+ 0.95
646
+ ],
647
+ "effects": [
648
+ [
649
+ "set",
650
+ "@entity.current",
651
+ "@payload.current"
652
+ ],
653
+ [
654
+ "render-ui",
655
+ "main",
656
+ {
657
+ "type": "stack",
658
+ "direction": "vertical",
659
+ "gap": "lg",
660
+ "children": [
661
+ {
662
+ "type": "stack",
663
+ "direction": "horizontal",
664
+ "gap": "sm",
665
+ "align": "center",
666
+ "children": [
667
+ {
668
+ "type": "icon",
669
+ "name": "alert-octagon",
670
+ "size": "lg"
671
+ },
672
+ {
673
+ "type": "typography",
674
+ "content": "Token Usage",
675
+ "variant": "h2"
676
+ },
677
+ {
678
+ "type": "badge",
679
+ "label": "Critical",
680
+ "variant": "destructive"
681
+ }
682
+ ]
683
+ },
684
+ {
685
+ "type": "divider"
686
+ },
687
+ {
688
+ "type": "alert",
689
+ "variant": "error",
690
+ "message": "Token usage critical. Compact immediately to avoid truncation."
691
+ },
692
+ {
693
+ "type": "progress-bar",
694
+ "value": "@entity.current",
695
+ "max": "@entity.max"
696
+ },
697
+ {
698
+ "type": "stack",
699
+ "direction": "horizontal",
700
+ "gap": "md",
701
+ "children": [
702
+ {
703
+ "type": "stat-display",
704
+ "label": "Tokens Used",
705
+ "value": "@entity.current"
706
+ },
707
+ {
708
+ "type": "stat-display",
709
+ "label": "Max Tokens",
710
+ "value": "@entity.max"
711
+ }
712
+ ]
713
+ },
714
+ {
715
+ "type": "stack",
716
+ "direction": "horizontal",
717
+ "gap": "sm",
718
+ "children": [
719
+ {
720
+ "type": "button",
721
+ "label": "Compact Now",
722
+ "event": "COMPACT",
723
+ "variant": "primary",
724
+ "icon": "minimize-2"
725
+ },
726
+ {
727
+ "type": "button",
728
+ "label": "Reset",
729
+ "event": "RESET",
730
+ "variant": "ghost",
731
+ "icon": "rotate-ccw"
732
+ }
733
+ ]
734
+ }
735
+ ]
736
+ }
737
+ ]
738
+ ]
739
+ },
740
+ {
741
+ "from": "warning",
742
+ "to": "normal",
743
+ "event": "UPDATE",
744
+ "guard": [
745
+ "<",
746
+ [
747
+ "/",
748
+ "@payload.current",
749
+ "@entity.max"
750
+ ],
751
+ 0.85
752
+ ],
753
+ "effects": [
754
+ [
755
+ "set",
756
+ "@entity.current",
757
+ "@payload.current"
758
+ ],
759
+ [
760
+ "render-ui",
761
+ "main",
762
+ {
763
+ "type": "stack",
764
+ "direction": "vertical",
765
+ "gap": "lg",
766
+ "children": [
767
+ {
768
+ "type": "stack",
769
+ "direction": "horizontal",
770
+ "gap": "sm",
771
+ "align": "center",
772
+ "children": [
773
+ {
774
+ "type": "icon",
775
+ "name": "gauge",
776
+ "size": "lg"
777
+ },
778
+ {
779
+ "type": "typography",
780
+ "content": "Token Usage",
781
+ "variant": "h2"
782
+ },
783
+ {
784
+ "type": "badge",
785
+ "label": "Normal",
786
+ "variant": "default"
787
+ }
788
+ ]
789
+ },
790
+ {
791
+ "type": "divider"
792
+ },
793
+ {
794
+ "type": "progress-bar",
795
+ "value": "@entity.current",
796
+ "max": "@entity.max"
797
+ },
798
+ {
799
+ "type": "stack",
800
+ "direction": "horizontal",
801
+ "gap": "md",
802
+ "children": [
803
+ {
804
+ "type": "stat-display",
805
+ "label": "Tokens Used",
806
+ "value": "@entity.current"
807
+ },
808
+ {
809
+ "type": "stat-display",
810
+ "label": "Max Tokens",
811
+ "value": "@entity.max"
812
+ }
813
+ ]
814
+ },
815
+ {
816
+ "type": "button",
817
+ "label": "Reset",
818
+ "event": "RESET",
819
+ "variant": "ghost",
820
+ "icon": "rotate-ccw"
821
+ }
822
+ ]
823
+ }
824
+ ]
825
+ ]
826
+ },
827
+ {
828
+ "from": "critical",
829
+ "to": "critical",
830
+ "event": "UPDATE",
831
+ "guard": [
832
+ ">=",
833
+ [
834
+ "/",
835
+ "@payload.current",
836
+ "@entity.max"
837
+ ],
838
+ 0.95
839
+ ],
840
+ "effects": [
841
+ [
842
+ "set",
843
+ "@entity.current",
844
+ "@payload.current"
845
+ ],
846
+ [
847
+ "render-ui",
848
+ "main",
849
+ {
850
+ "type": "stack",
851
+ "direction": "vertical",
852
+ "gap": "lg",
853
+ "children": [
854
+ {
855
+ "type": "stack",
856
+ "direction": "horizontal",
857
+ "gap": "sm",
858
+ "align": "center",
859
+ "children": [
860
+ {
861
+ "type": "icon",
862
+ "name": "alert-octagon",
863
+ "size": "lg"
864
+ },
865
+ {
866
+ "type": "typography",
867
+ "content": "Token Usage",
868
+ "variant": "h2"
869
+ },
870
+ {
871
+ "type": "badge",
872
+ "label": "Critical",
873
+ "variant": "destructive"
874
+ }
875
+ ]
876
+ },
877
+ {
878
+ "type": "divider"
879
+ },
880
+ {
881
+ "type": "alert",
882
+ "variant": "error",
883
+ "message": "Token usage critical. Compact immediately to avoid truncation."
884
+ },
885
+ {
886
+ "type": "progress-bar",
887
+ "value": "@entity.current",
888
+ "max": "@entity.max"
889
+ },
890
+ {
891
+ "type": "stack",
892
+ "direction": "horizontal",
893
+ "gap": "md",
894
+ "children": [
895
+ {
896
+ "type": "stat-display",
897
+ "label": "Tokens Used",
898
+ "value": "@entity.current"
899
+ },
900
+ {
901
+ "type": "stat-display",
902
+ "label": "Max Tokens",
903
+ "value": "@entity.max"
904
+ }
905
+ ]
906
+ },
907
+ {
908
+ "type": "stack",
909
+ "direction": "horizontal",
910
+ "gap": "sm",
911
+ "children": [
912
+ {
913
+ "type": "button",
914
+ "label": "Compact Now",
915
+ "event": "COMPACT",
916
+ "variant": "primary",
917
+ "icon": "minimize-2"
918
+ },
919
+ {
920
+ "type": "button",
921
+ "label": "Reset",
922
+ "event": "RESET",
923
+ "variant": "ghost",
924
+ "icon": "rotate-ccw"
925
+ }
926
+ ]
927
+ }
928
+ ]
929
+ }
930
+ ]
931
+ ]
932
+ },
933
+ {
934
+ "from": "critical",
935
+ "to": "warning",
936
+ "event": "UPDATE",
937
+ "guard": [
938
+ "and",
939
+ [
940
+ ">=",
941
+ [
942
+ "/",
943
+ "@payload.current",
944
+ "@entity.max"
945
+ ],
946
+ 0.85
947
+ ],
948
+ [
949
+ "<",
950
+ [
951
+ "/",
952
+ "@payload.current",
953
+ "@entity.max"
954
+ ],
955
+ 0.95
956
+ ]
957
+ ],
958
+ "effects": [
959
+ [
960
+ "set",
961
+ "@entity.current",
962
+ "@payload.current"
963
+ ],
964
+ [
965
+ "render-ui",
966
+ "main",
967
+ {
968
+ "type": "stack",
969
+ "direction": "vertical",
970
+ "gap": "lg",
971
+ "children": [
972
+ {
973
+ "type": "stack",
974
+ "direction": "horizontal",
975
+ "gap": "sm",
976
+ "align": "center",
977
+ "children": [
978
+ {
979
+ "type": "icon",
980
+ "name": "alert-triangle",
981
+ "size": "lg"
982
+ },
983
+ {
984
+ "type": "typography",
985
+ "content": "Token Usage",
986
+ "variant": "h2"
987
+ },
988
+ {
989
+ "type": "badge",
990
+ "label": "Warning",
991
+ "variant": "warning"
992
+ }
993
+ ]
994
+ },
995
+ {
996
+ "type": "divider"
997
+ },
998
+ {
999
+ "type": "alert",
1000
+ "variant": "warning",
1001
+ "message": "Token usage approaching limit. Consider compacting."
1002
+ },
1003
+ {
1004
+ "type": "progress-bar",
1005
+ "value": "@entity.current",
1006
+ "max": "@entity.max"
1007
+ },
1008
+ {
1009
+ "type": "stack",
1010
+ "direction": "horizontal",
1011
+ "gap": "md",
1012
+ "children": [
1013
+ {
1014
+ "type": "stat-display",
1015
+ "label": "Tokens Used",
1016
+ "value": "@entity.current"
1017
+ },
1018
+ {
1019
+ "type": "stat-display",
1020
+ "label": "Max Tokens",
1021
+ "value": "@entity.max"
1022
+ }
1023
+ ]
1024
+ },
1025
+ {
1026
+ "type": "stack",
1027
+ "direction": "horizontal",
1028
+ "gap": "sm",
1029
+ "children": [
1030
+ {
1031
+ "type": "button",
1032
+ "label": "Compact",
1033
+ "event": "COMPACT",
1034
+ "variant": "primary",
1035
+ "icon": "minimize-2"
1036
+ },
1037
+ {
1038
+ "type": "button",
1039
+ "label": "Reset",
1040
+ "event": "RESET",
1041
+ "variant": "ghost",
1042
+ "icon": "rotate-ccw"
1043
+ }
1044
+ ]
1045
+ }
1046
+ ]
1047
+ }
1048
+ ]
1049
+ ]
1050
+ },
1051
+ {
1052
+ "from": "critical",
1053
+ "to": "normal",
1054
+ "event": "UPDATE",
1055
+ "guard": [
1056
+ "<",
1057
+ [
1058
+ "/",
1059
+ "@payload.current",
1060
+ "@entity.max"
1061
+ ],
1062
+ 0.85
1063
+ ],
1064
+ "effects": [
1065
+ [
1066
+ "set",
1067
+ "@entity.current",
1068
+ "@payload.current"
1069
+ ],
1070
+ [
1071
+ "render-ui",
1072
+ "main",
1073
+ {
1074
+ "type": "stack",
1075
+ "direction": "vertical",
1076
+ "gap": "lg",
1077
+ "children": [
1078
+ {
1079
+ "type": "stack",
1080
+ "direction": "horizontal",
1081
+ "gap": "sm",
1082
+ "align": "center",
1083
+ "children": [
1084
+ {
1085
+ "type": "icon",
1086
+ "name": "gauge",
1087
+ "size": "lg"
1088
+ },
1089
+ {
1090
+ "type": "typography",
1091
+ "content": "Token Usage",
1092
+ "variant": "h2"
1093
+ },
1094
+ {
1095
+ "type": "badge",
1096
+ "label": "Normal",
1097
+ "variant": "default"
1098
+ }
1099
+ ]
1100
+ },
1101
+ {
1102
+ "type": "divider"
1103
+ },
1104
+ {
1105
+ "type": "progress-bar",
1106
+ "value": "@entity.current",
1107
+ "max": "@entity.max"
1108
+ },
1109
+ {
1110
+ "type": "stack",
1111
+ "direction": "horizontal",
1112
+ "gap": "md",
1113
+ "children": [
1114
+ {
1115
+ "type": "stat-display",
1116
+ "label": "Tokens Used",
1117
+ "value": "@entity.current"
1118
+ },
1119
+ {
1120
+ "type": "stat-display",
1121
+ "label": "Max Tokens",
1122
+ "value": "@entity.max"
1123
+ }
1124
+ ]
1125
+ },
1126
+ {
1127
+ "type": "button",
1128
+ "label": "Reset",
1129
+ "event": "RESET",
1130
+ "variant": "ghost",
1131
+ "icon": "rotate-ccw"
1132
+ }
1133
+ ]
1134
+ }
1135
+ ]
1136
+ ]
1137
+ },
1138
+ {
1139
+ "from": "normal",
1140
+ "to": "normal",
1141
+ "event": "COMPACT",
1142
+ "effects": [
1143
+ [
1144
+ "agent/compact"
1145
+ ],
1146
+ [
1147
+ "set",
1148
+ "@entity.lastCompactedAt",
1149
+ "@now"
1150
+ ],
1151
+ [
1152
+ "agent/token-count"
1153
+ ],
1154
+ [
1155
+ "render-ui",
1156
+ "main",
1157
+ {
1158
+ "type": "stack",
1159
+ "direction": "vertical",
1160
+ "gap": "lg",
1161
+ "children": [
1162
+ {
1163
+ "type": "stack",
1164
+ "direction": "horizontal",
1165
+ "gap": "sm",
1166
+ "align": "center",
1167
+ "children": [
1168
+ {
1169
+ "type": "icon",
1170
+ "name": "gauge",
1171
+ "size": "lg"
1172
+ },
1173
+ {
1174
+ "type": "typography",
1175
+ "content": "Token Usage",
1176
+ "variant": "h2"
1177
+ },
1178
+ {
1179
+ "type": "badge",
1180
+ "label": "Normal",
1181
+ "variant": "default"
1182
+ }
1183
+ ]
1184
+ },
1185
+ {
1186
+ "type": "divider"
1187
+ },
1188
+ {
1189
+ "type": "progress-bar",
1190
+ "value": "@entity.current",
1191
+ "max": "@entity.max"
1192
+ },
1193
+ {
1194
+ "type": "stack",
1195
+ "direction": "horizontal",
1196
+ "gap": "md",
1197
+ "children": [
1198
+ {
1199
+ "type": "stat-display",
1200
+ "label": "Tokens Used",
1201
+ "value": "@entity.current"
1202
+ },
1203
+ {
1204
+ "type": "stat-display",
1205
+ "label": "Max Tokens",
1206
+ "value": "@entity.max"
1207
+ }
1208
+ ]
1209
+ },
1210
+ {
1211
+ "type": "button",
1212
+ "label": "Reset",
1213
+ "event": "RESET",
1214
+ "variant": "ghost",
1215
+ "icon": "rotate-ccw"
1216
+ }
1217
+ ]
1218
+ }
1219
+ ]
1220
+ ]
1221
+ },
1222
+ {
1223
+ "from": "warning",
1224
+ "to": "normal",
1225
+ "event": "COMPACT",
1226
+ "effects": [
1227
+ [
1228
+ "agent/compact"
1229
+ ],
1230
+ [
1231
+ "set",
1232
+ "@entity.lastCompactedAt",
1233
+ "@now"
1234
+ ],
1235
+ [
1236
+ "agent/token-count"
1237
+ ],
1238
+ [
1239
+ "render-ui",
1240
+ "main",
1241
+ {
1242
+ "type": "stack",
1243
+ "direction": "vertical",
1244
+ "gap": "lg",
1245
+ "children": [
1246
+ {
1247
+ "type": "stack",
1248
+ "direction": "horizontal",
1249
+ "gap": "sm",
1250
+ "align": "center",
1251
+ "children": [
1252
+ {
1253
+ "type": "icon",
1254
+ "name": "gauge",
1255
+ "size": "lg"
1256
+ },
1257
+ {
1258
+ "type": "typography",
1259
+ "content": "Token Usage",
1260
+ "variant": "h2"
1261
+ },
1262
+ {
1263
+ "type": "badge",
1264
+ "label": "Normal",
1265
+ "variant": "default"
1266
+ }
1267
+ ]
1268
+ },
1269
+ {
1270
+ "type": "divider"
1271
+ },
1272
+ {
1273
+ "type": "progress-bar",
1274
+ "value": "@entity.current",
1275
+ "max": "@entity.max"
1276
+ },
1277
+ {
1278
+ "type": "stack",
1279
+ "direction": "horizontal",
1280
+ "gap": "md",
1281
+ "children": [
1282
+ {
1283
+ "type": "stat-display",
1284
+ "label": "Tokens Used",
1285
+ "value": "@entity.current"
1286
+ },
1287
+ {
1288
+ "type": "stat-display",
1289
+ "label": "Max Tokens",
1290
+ "value": "@entity.max"
1291
+ }
1292
+ ]
1293
+ },
1294
+ {
1295
+ "type": "button",
1296
+ "label": "Reset",
1297
+ "event": "RESET",
1298
+ "variant": "ghost",
1299
+ "icon": "rotate-ccw"
1300
+ }
1301
+ ]
1302
+ }
1303
+ ]
1304
+ ]
1305
+ },
1306
+ {
1307
+ "from": "critical",
1308
+ "to": "normal",
1309
+ "event": "COMPACT",
1310
+ "effects": [
1311
+ [
1312
+ "agent/compact"
1313
+ ],
1314
+ [
1315
+ "set",
1316
+ "@entity.lastCompactedAt",
1317
+ "@now"
1318
+ ],
1319
+ [
1320
+ "agent/token-count"
1321
+ ],
1322
+ [
1323
+ "render-ui",
1324
+ "main",
1325
+ {
1326
+ "type": "stack",
1327
+ "direction": "vertical",
1328
+ "gap": "lg",
1329
+ "children": [
1330
+ {
1331
+ "type": "stack",
1332
+ "direction": "horizontal",
1333
+ "gap": "sm",
1334
+ "align": "center",
1335
+ "children": [
1336
+ {
1337
+ "type": "icon",
1338
+ "name": "gauge",
1339
+ "size": "lg"
1340
+ },
1341
+ {
1342
+ "type": "typography",
1343
+ "content": "Token Usage",
1344
+ "variant": "h2"
1345
+ },
1346
+ {
1347
+ "type": "badge",
1348
+ "label": "Normal",
1349
+ "variant": "default"
1350
+ }
1351
+ ]
1352
+ },
1353
+ {
1354
+ "type": "divider"
1355
+ },
1356
+ {
1357
+ "type": "progress-bar",
1358
+ "value": "@entity.current",
1359
+ "max": "@entity.max"
1360
+ },
1361
+ {
1362
+ "type": "stack",
1363
+ "direction": "horizontal",
1364
+ "gap": "md",
1365
+ "children": [
1366
+ {
1367
+ "type": "stat-display",
1368
+ "label": "Tokens Used",
1369
+ "value": "@entity.current"
1370
+ },
1371
+ {
1372
+ "type": "stat-display",
1373
+ "label": "Max Tokens",
1374
+ "value": "@entity.max"
1375
+ }
1376
+ ]
1377
+ },
1378
+ {
1379
+ "type": "button",
1380
+ "label": "Reset",
1381
+ "event": "RESET",
1382
+ "variant": "ghost",
1383
+ "icon": "rotate-ccw"
1384
+ }
1385
+ ]
1386
+ }
1387
+ ]
1388
+ ]
1389
+ },
1390
+ {
1391
+ "from": "normal",
1392
+ "to": "normal",
1393
+ "event": "RESET",
1394
+ "effects": [
1395
+ [
1396
+ "set",
1397
+ "@entity.current",
1398
+ 0
1399
+ ],
1400
+ [
1401
+ "render-ui",
1402
+ "main",
1403
+ {
1404
+ "type": "stack",
1405
+ "direction": "vertical",
1406
+ "gap": "lg",
1407
+ "children": [
1408
+ {
1409
+ "type": "stack",
1410
+ "direction": "horizontal",
1411
+ "gap": "sm",
1412
+ "align": "center",
1413
+ "children": [
1414
+ {
1415
+ "type": "icon",
1416
+ "name": "gauge",
1417
+ "size": "lg"
1418
+ },
1419
+ {
1420
+ "type": "typography",
1421
+ "content": "Token Usage",
1422
+ "variant": "h2"
1423
+ },
1424
+ {
1425
+ "type": "badge",
1426
+ "label": "Normal",
1427
+ "variant": "default"
1428
+ }
1429
+ ]
1430
+ },
1431
+ {
1432
+ "type": "divider"
1433
+ },
1434
+ {
1435
+ "type": "progress-bar",
1436
+ "value": "@entity.current",
1437
+ "max": "@entity.max"
1438
+ },
1439
+ {
1440
+ "type": "stack",
1441
+ "direction": "horizontal",
1442
+ "gap": "md",
1443
+ "children": [
1444
+ {
1445
+ "type": "stat-display",
1446
+ "label": "Tokens Used",
1447
+ "value": "@entity.current"
1448
+ },
1449
+ {
1450
+ "type": "stat-display",
1451
+ "label": "Max Tokens",
1452
+ "value": "@entity.max"
1453
+ }
1454
+ ]
1455
+ },
1456
+ {
1457
+ "type": "button",
1458
+ "label": "Reset",
1459
+ "event": "RESET",
1460
+ "variant": "ghost",
1461
+ "icon": "rotate-ccw"
1462
+ }
1463
+ ]
1464
+ }
1465
+ ]
1466
+ ]
1467
+ },
1468
+ {
1469
+ "from": "warning",
1470
+ "to": "normal",
1471
+ "event": "RESET",
1472
+ "effects": [
1473
+ [
1474
+ "set",
1475
+ "@entity.current",
1476
+ 0
1477
+ ],
1478
+ [
1479
+ "render-ui",
1480
+ "main",
1481
+ {
1482
+ "type": "stack",
1483
+ "direction": "vertical",
1484
+ "gap": "lg",
1485
+ "children": [
1486
+ {
1487
+ "type": "stack",
1488
+ "direction": "horizontal",
1489
+ "gap": "sm",
1490
+ "align": "center",
1491
+ "children": [
1492
+ {
1493
+ "type": "icon",
1494
+ "name": "gauge",
1495
+ "size": "lg"
1496
+ },
1497
+ {
1498
+ "type": "typography",
1499
+ "content": "Token Usage",
1500
+ "variant": "h2"
1501
+ },
1502
+ {
1503
+ "type": "badge",
1504
+ "label": "Normal",
1505
+ "variant": "default"
1506
+ }
1507
+ ]
1508
+ },
1509
+ {
1510
+ "type": "divider"
1511
+ },
1512
+ {
1513
+ "type": "progress-bar",
1514
+ "value": "@entity.current",
1515
+ "max": "@entity.max"
1516
+ },
1517
+ {
1518
+ "type": "stack",
1519
+ "direction": "horizontal",
1520
+ "gap": "md",
1521
+ "children": [
1522
+ {
1523
+ "type": "stat-display",
1524
+ "label": "Tokens Used",
1525
+ "value": "@entity.current"
1526
+ },
1527
+ {
1528
+ "type": "stat-display",
1529
+ "label": "Max Tokens",
1530
+ "value": "@entity.max"
1531
+ }
1532
+ ]
1533
+ },
1534
+ {
1535
+ "type": "button",
1536
+ "label": "Reset",
1537
+ "event": "RESET",
1538
+ "variant": "ghost",
1539
+ "icon": "rotate-ccw"
1540
+ }
1541
+ ]
1542
+ }
1543
+ ]
1544
+ ]
1545
+ },
1546
+ {
1547
+ "from": "critical",
1548
+ "to": "normal",
1549
+ "event": "RESET",
1550
+ "effects": [
1551
+ [
1552
+ "set",
1553
+ "@entity.current",
1554
+ 0
1555
+ ],
1556
+ [
1557
+ "render-ui",
1558
+ "main",
1559
+ {
1560
+ "type": "stack",
1561
+ "direction": "vertical",
1562
+ "gap": "lg",
1563
+ "children": [
1564
+ {
1565
+ "type": "stack",
1566
+ "direction": "horizontal",
1567
+ "gap": "sm",
1568
+ "align": "center",
1569
+ "children": [
1570
+ {
1571
+ "type": "icon",
1572
+ "name": "gauge",
1573
+ "size": "lg"
1574
+ },
1575
+ {
1576
+ "type": "typography",
1577
+ "content": "Token Usage",
1578
+ "variant": "h2"
1579
+ },
1580
+ {
1581
+ "type": "badge",
1582
+ "label": "Normal",
1583
+ "variant": "default"
1584
+ }
1585
+ ]
1586
+ },
1587
+ {
1588
+ "type": "divider"
1589
+ },
1590
+ {
1591
+ "type": "progress-bar",
1592
+ "value": "@entity.current",
1593
+ "max": "@entity.max"
1594
+ },
1595
+ {
1596
+ "type": "stack",
1597
+ "direction": "horizontal",
1598
+ "gap": "md",
1599
+ "children": [
1600
+ {
1601
+ "type": "stat-display",
1602
+ "label": "Tokens Used",
1603
+ "value": "@entity.current"
1604
+ },
1605
+ {
1606
+ "type": "stat-display",
1607
+ "label": "Max Tokens",
1608
+ "value": "@entity.max"
1609
+ }
1610
+ ]
1611
+ },
1612
+ {
1613
+ "type": "button",
1614
+ "label": "Reset",
1615
+ "event": "RESET",
1616
+ "variant": "ghost",
1617
+ "icon": "rotate-ccw"
1618
+ }
1619
+ ]
1620
+ }
1621
+ ]
1622
+ ]
1623
+ }
1624
+ ]
1625
+ }
1626
+ },
1627
+ {
1628
+ "name": "AgentContextWindowNotification",
1629
+ "linkedEntity": "AgentContextWindow",
1630
+ "category": "interaction",
1631
+ "stateMachine": {
1632
+ "states": [
1633
+ {
1634
+ "name": "hidden",
1635
+ "isInitial": true
1636
+ },
1637
+ {
1638
+ "name": "visible"
1639
+ }
1640
+ ],
1641
+ "events": [
1642
+ {
1643
+ "key": "INIT",
1644
+ "name": "Initialize"
1645
+ },
1646
+ {
1647
+ "key": "SHOW",
1648
+ "name": "Show Notification",
1649
+ "payload": [
1650
+ {
1651
+ "name": "message",
1652
+ "type": "string",
1653
+ "required": true
1654
+ },
1655
+ {
1656
+ "name": "notificationType",
1657
+ "type": "string"
1658
+ }
1659
+ ]
1660
+ },
1661
+ {
1662
+ "key": "HIDE",
1663
+ "name": "Hide Notification"
1664
+ }
1665
+ ],
1666
+ "transitions": [
1667
+ {
1668
+ "from": "hidden",
1669
+ "to": "hidden",
1670
+ "event": "INIT",
1671
+ "effects": [
1672
+ [
1673
+ "fetch",
1674
+ "AgentContextWindow"
1675
+ ]
1676
+ ]
1677
+ },
1678
+ {
1679
+ "from": "hidden",
1680
+ "to": "visible",
1681
+ "event": "SHOW",
1682
+ "effects": [
1683
+ [
1684
+ "set",
1685
+ "@entity.message",
1686
+ "@payload.message"
1687
+ ],
1688
+ [
1689
+ "set",
1690
+ "@entity.notificationType",
1691
+ "@payload.notificationType"
1692
+ ],
1693
+ [
1694
+ "render-ui",
1695
+ "main",
1696
+ {
1697
+ "type": "stack",
1698
+ "direction": "vertical",
1699
+ "gap": "lg",
1700
+ "children": [
1701
+ {
1702
+ "type": "stack",
1703
+ "direction": "horizontal",
1704
+ "gap": "md",
1705
+ "justify": "space-between",
1706
+ "align": "center",
1707
+ "children": [
1708
+ {
1709
+ "type": "stack",
1710
+ "direction": "horizontal",
1711
+ "gap": "md",
1712
+ "align": "center",
1713
+ "children": [
1714
+ {
1715
+ "type": "icon",
1716
+ "name": "layers",
1717
+ "size": "lg"
1718
+ },
1719
+ {
1720
+ "type": "typography",
1721
+ "content": "Context Window Alert",
1722
+ "variant": "h2"
1723
+ }
1724
+ ]
1725
+ },
1726
+ {
1727
+ "type": "button",
1728
+ "label": "Dismiss",
1729
+ "event": "HIDE",
1730
+ "variant": "ghost",
1731
+ "icon": "x"
1732
+ }
1733
+ ]
1734
+ },
1735
+ {
1736
+ "type": "divider"
1737
+ },
1738
+ {
1739
+ "type": "alert",
1740
+ "variant": [
1741
+ "object/get",
1742
+ [
1743
+ "array/first",
1744
+ "@entity"
1745
+ ],
1746
+ "notificationType"
1747
+ ],
1748
+ "message": [
1749
+ "object/get",
1750
+ [
1751
+ "array/first",
1752
+ "@entity"
1753
+ ],
1754
+ "message"
1755
+ ]
1756
+ },
1757
+ {
1758
+ "type": "toast-slot",
1759
+ "position": "top-right"
1760
+ },
1761
+ {
1762
+ "type": "violation-alert",
1763
+ "severity": "warning",
1764
+ "message": [
1765
+ "object/get",
1766
+ [
1767
+ "array/first",
1768
+ "@entity"
1769
+ ],
1770
+ "message"
1771
+ ],
1772
+ "category": "compliance"
1773
+ }
1774
+ ]
1775
+ }
1776
+ ]
1777
+ ]
1778
+ },
1779
+ {
1780
+ "from": "visible",
1781
+ "to": "visible",
1782
+ "event": "SHOW",
1783
+ "effects": [
1784
+ [
1785
+ "set",
1786
+ "@entity.message",
1787
+ "@payload.message"
1788
+ ],
1789
+ [
1790
+ "set",
1791
+ "@entity.notificationType",
1792
+ "@payload.notificationType"
1793
+ ],
1794
+ [
1795
+ "render-ui",
1796
+ "main",
1797
+ {
1798
+ "type": "stack",
1799
+ "direction": "vertical",
1800
+ "gap": "lg",
1801
+ "children": [
1802
+ {
1803
+ "type": "stack",
1804
+ "direction": "horizontal",
1805
+ "gap": "md",
1806
+ "justify": "space-between",
1807
+ "align": "center",
1808
+ "children": [
1809
+ {
1810
+ "type": "stack",
1811
+ "direction": "horizontal",
1812
+ "gap": "md",
1813
+ "align": "center",
1814
+ "children": [
1815
+ {
1816
+ "type": "icon",
1817
+ "name": "layers",
1818
+ "size": "lg"
1819
+ },
1820
+ {
1821
+ "type": "typography",
1822
+ "content": "Context Window Alert",
1823
+ "variant": "h2"
1824
+ }
1825
+ ]
1826
+ },
1827
+ {
1828
+ "type": "button",
1829
+ "label": "Dismiss",
1830
+ "event": "HIDE",
1831
+ "variant": "ghost",
1832
+ "icon": "x"
1833
+ }
1834
+ ]
1835
+ },
1836
+ {
1837
+ "type": "divider"
1838
+ },
1839
+ {
1840
+ "type": "alert",
1841
+ "variant": [
1842
+ "object/get",
1843
+ [
1844
+ "array/first",
1845
+ "@entity"
1846
+ ],
1847
+ "notificationType"
1848
+ ],
1849
+ "message": [
1850
+ "object/get",
1851
+ [
1852
+ "array/first",
1853
+ "@entity"
1854
+ ],
1855
+ "message"
1856
+ ]
1857
+ },
1858
+ {
1859
+ "type": "toast-slot",
1860
+ "position": "top-right"
1861
+ },
1862
+ {
1863
+ "type": "violation-alert",
1864
+ "severity": "warning",
1865
+ "message": [
1866
+ "object/get",
1867
+ [
1868
+ "array/first",
1869
+ "@entity"
1870
+ ],
1871
+ "message"
1872
+ ],
1873
+ "category": "compliance"
1874
+ }
1875
+ ]
1876
+ }
1877
+ ]
1878
+ ]
1879
+ },
1880
+ {
1881
+ "from": "visible",
1882
+ "to": "hidden",
1883
+ "event": "HIDE",
1884
+ "effects": [
1885
+ [
1886
+ "set",
1887
+ "@entity.message",
1888
+ ""
1889
+ ]
1890
+ ]
1891
+ }
1892
+ ]
1893
+ }
1894
+ },
1895
+ {
1896
+ "name": "AgentContextWindowAgent",
1897
+ "linkedEntity": "AgentContextWindow",
1898
+ "category": "interaction",
1899
+ "emits": [
1900
+ {
1901
+ "event": "SHOW",
1902
+ "scope": "internal",
1903
+ "payload": [
1904
+ {
1905
+ "name": "tokenCount",
1906
+ "type": "number"
1907
+ },
1908
+ {
1909
+ "name": "usage",
1910
+ "type": "number"
1911
+ }
1912
+ ]
1913
+ },
1914
+ {
1915
+ "event": "UPDATE",
1916
+ "scope": "internal",
1917
+ "payload": [
1918
+ {
1919
+ "name": "current",
1920
+ "type": "number"
1921
+ },
1922
+ {
1923
+ "name": "max",
1924
+ "type": "number"
1925
+ }
1926
+ ]
1927
+ }
1928
+ ],
1929
+ "stateMachine": {
1930
+ "states": [
1931
+ {
1932
+ "name": "normal",
1933
+ "isInitial": true
1934
+ },
1935
+ {
1936
+ "name": "approaching_limit"
1937
+ },
1938
+ {
1939
+ "name": "at_limit"
1940
+ }
1941
+ ],
1942
+ "events": [
1943
+ {
1944
+ "key": "INIT",
1945
+ "name": "Initialize"
1946
+ },
1947
+ {
1948
+ "key": "UPDATE_TOKENS",
1949
+ "name": "Update Token Count"
1950
+ },
1951
+ {
1952
+ "key": "COMPACT",
1953
+ "name": "Compact Context"
1954
+ }
1955
+ ],
1956
+ "transitions": [
1957
+ {
1958
+ "from": "normal",
1959
+ "to": "normal",
1960
+ "event": "INIT",
1961
+ "effects": [
1962
+ [
1963
+ "fetch",
1964
+ "AgentContextWindow"
1965
+ ],
1966
+ [
1967
+ "agent/token-count"
1968
+ ],
1969
+ [
1970
+ "agent/context-usage"
1971
+ ],
1972
+ [
1973
+ "render-ui",
1974
+ "main",
1975
+ {
1976
+ "type": "empty-state",
1977
+ "icon": "layers",
1978
+ "title": "Context Window",
1979
+ "description": "Context Window is ready"
1980
+ }
1981
+ ]
1982
+ ]
1983
+ },
1984
+ {
1985
+ "from": "normal",
1986
+ "to": "normal",
1987
+ "event": "UPDATE_TOKENS",
1988
+ "guard": [
1989
+ "<",
1990
+ [
1991
+ "/",
1992
+ "@entity.tokenCount",
1993
+ "@entity.maxTokens"
1994
+ ],
1995
+ 0.85
1996
+ ],
1997
+ "effects": [
1998
+ [
1999
+ "agent/token-count"
2000
+ ],
2001
+ [
2002
+ "agent/context-usage"
2003
+ ],
2004
+ [
2005
+ "set",
2006
+ "@entity.usage",
2007
+ [
2008
+ "*",
2009
+ [
2010
+ "/",
2011
+ "@entity.tokenCount",
2012
+ "@entity.maxTokens"
2013
+ ],
2014
+ 100
2015
+ ]
2016
+ ],
2017
+ [
2018
+ "set",
2019
+ "@entity.current",
2020
+ "@entity.tokenCount"
2021
+ ],
2022
+ [
2023
+ "emit",
2024
+ "UPDATE"
2025
+ ]
2026
+ ]
2027
+ },
2028
+ {
2029
+ "from": "normal",
2030
+ "to": "approaching_limit",
2031
+ "event": "UPDATE_TOKENS",
2032
+ "guard": [
2033
+ "and",
2034
+ [
2035
+ ">=",
2036
+ [
2037
+ "/",
2038
+ "@entity.tokenCount",
2039
+ "@entity.maxTokens"
2040
+ ],
2041
+ 0.85
2042
+ ],
2043
+ [
2044
+ "<",
2045
+ [
2046
+ "/",
2047
+ "@entity.tokenCount",
2048
+ "@entity.maxTokens"
2049
+ ],
2050
+ 1
2051
+ ]
2052
+ ],
2053
+ "effects": [
2054
+ [
2055
+ "agent/token-count"
2056
+ ],
2057
+ [
2058
+ "agent/context-usage"
2059
+ ],
2060
+ [
2061
+ "set",
2062
+ "@entity.usage",
2063
+ [
2064
+ "*",
2065
+ [
2066
+ "/",
2067
+ "@entity.tokenCount",
2068
+ "@entity.maxTokens"
2069
+ ],
2070
+ 100
2071
+ ]
2072
+ ],
2073
+ [
2074
+ "set",
2075
+ "@entity.current",
2076
+ "@entity.tokenCount"
2077
+ ],
2078
+ [
2079
+ "emit",
2080
+ "UPDATE"
2081
+ ],
2082
+ [
2083
+ "emit",
2084
+ "SHOW"
2085
+ ]
2086
+ ]
2087
+ },
2088
+ {
2089
+ "from": "approaching_limit",
2090
+ "to": "at_limit",
2091
+ "event": "UPDATE_TOKENS",
2092
+ "guard": [
2093
+ ">=",
2094
+ [
2095
+ "/",
2096
+ "@entity.tokenCount",
2097
+ "@entity.maxTokens"
2098
+ ],
2099
+ 1
2100
+ ],
2101
+ "effects": [
2102
+ [
2103
+ "agent/token-count"
2104
+ ],
2105
+ [
2106
+ "agent/context-usage"
2107
+ ],
2108
+ [
2109
+ "set",
2110
+ "@entity.usage",
2111
+ 100
2112
+ ],
2113
+ [
2114
+ "set",
2115
+ "@entity.current",
2116
+ "@entity.tokenCount"
2117
+ ],
2118
+ [
2119
+ "emit",
2120
+ "UPDATE"
2121
+ ],
2122
+ [
2123
+ "emit",
2124
+ "SHOW"
2125
+ ]
2126
+ ]
2127
+ },
2128
+ {
2129
+ "from": "approaching_limit",
2130
+ "to": "normal",
2131
+ "event": "COMPACT",
2132
+ "effects": [
2133
+ [
2134
+ "agent/compact"
2135
+ ],
2136
+ [
2137
+ "agent/token-count"
2138
+ ],
2139
+ [
2140
+ "agent/context-usage"
2141
+ ],
2142
+ [
2143
+ "set",
2144
+ "@entity.lastCompactedAt",
2145
+ "@now"
2146
+ ],
2147
+ [
2148
+ "set",
2149
+ "@entity.usage",
2150
+ [
2151
+ "*",
2152
+ [
2153
+ "/",
2154
+ "@entity.tokenCount",
2155
+ "@entity.maxTokens"
2156
+ ],
2157
+ 100
2158
+ ]
2159
+ ],
2160
+ [
2161
+ "set",
2162
+ "@entity.current",
2163
+ "@entity.tokenCount"
2164
+ ],
2165
+ [
2166
+ "emit",
2167
+ "UPDATE"
2168
+ ]
2169
+ ]
2170
+ },
2171
+ {
2172
+ "from": "at_limit",
2173
+ "to": "normal",
2174
+ "event": "COMPACT",
2175
+ "effects": [
2176
+ [
2177
+ "agent/compact"
2178
+ ],
2179
+ [
2180
+ "agent/token-count"
2181
+ ],
2182
+ [
2183
+ "agent/context-usage"
2184
+ ],
2185
+ [
2186
+ "set",
2187
+ "@entity.lastCompactedAt",
2188
+ "@now"
2189
+ ],
2190
+ [
2191
+ "set",
2192
+ "@entity.usage",
2193
+ [
2194
+ "*",
2195
+ [
2196
+ "/",
2197
+ "@entity.tokenCount",
2198
+ "@entity.maxTokens"
2199
+ ],
2200
+ 100
2201
+ ]
2202
+ ],
2203
+ [
2204
+ "set",
2205
+ "@entity.current",
2206
+ "@entity.tokenCount"
2207
+ ],
2208
+ [
2209
+ "emit",
2210
+ "UPDATE"
2211
+ ]
2212
+ ]
2213
+ },
2214
+ {
2215
+ "from": "approaching_limit",
2216
+ "to": "approaching_limit",
2217
+ "event": "UPDATE_TOKENS",
2218
+ "guard": [
2219
+ "and",
2220
+ [
2221
+ ">=",
2222
+ [
2223
+ "/",
2224
+ "@entity.tokenCount",
2225
+ "@entity.maxTokens"
2226
+ ],
2227
+ 0.85
2228
+ ],
2229
+ [
2230
+ "<",
2231
+ [
2232
+ "/",
2233
+ "@entity.tokenCount",
2234
+ "@entity.maxTokens"
2235
+ ],
2236
+ 1
2237
+ ]
2238
+ ],
2239
+ "effects": [
2240
+ [
2241
+ "agent/token-count"
2242
+ ],
2243
+ [
2244
+ "agent/context-usage"
2245
+ ],
2246
+ [
2247
+ "set",
2248
+ "@entity.usage",
2249
+ [
2250
+ "*",
2251
+ [
2252
+ "/",
2253
+ "@entity.tokenCount",
2254
+ "@entity.maxTokens"
2255
+ ],
2256
+ 100
2257
+ ]
2258
+ ],
2259
+ [
2260
+ "set",
2261
+ "@entity.current",
2262
+ "@entity.tokenCount"
2263
+ ],
2264
+ [
2265
+ "emit",
2266
+ "UPDATE"
2267
+ ]
2268
+ ]
2269
+ }
2270
+ ]
2271
+ }
2272
+ }
2273
+ ],
2274
+ "pages": [
2275
+ {
2276
+ "name": "AgentContextWindowPage",
2277
+ "path": "/agentcontextwindows",
2278
+ "traits": [
2279
+ {
2280
+ "ref": "AgentContextWindowGauge"
2281
+ },
2282
+ {
2283
+ "ref": "AgentContextWindowNotification"
2284
+ },
2285
+ {
2286
+ "ref": "AgentContextWindowAgent"
2287
+ }
2288
+ ]
2289
+ }
2290
+ ]
2291
+ }
2292
+ ],
2293
+ "description": "Context window management atom for agent token tracking. Composes UI atoms (stdAgentTokenGauge for visual display, stdNotification for threshold alerts) with an agent trait that handles agent/compact, agent/token-count, and agent/context-usage."
2294
+ }