github-copilot-sdk 0.1.0

Rust SDK for programmatic control of the GitHub Copilot CLI via JSON-RPC. Technical preview, pre-1.0.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
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
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
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
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
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
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
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
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
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
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
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
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
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
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
//! Auto-generated from session-events.schema.json — do not edit manually.

use std::collections::HashMap;

use serde::{Deserialize, Serialize};

use crate::types::{RequestId, SessionId};

/// Identifies the kind of session event.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SessionEventType {
    #[serde(rename = "session.start")]
    SessionStart,
    #[serde(rename = "session.resume")]
    SessionResume,
    #[serde(rename = "session.remote_steerable_changed")]
    SessionRemoteSteerableChanged,
    #[serde(rename = "session.error")]
    SessionError,
    #[serde(rename = "session.idle")]
    SessionIdle,
    #[serde(rename = "session.title_changed")]
    SessionTitleChanged,
    #[serde(rename = "session.info")]
    SessionInfo,
    #[serde(rename = "session.warning")]
    SessionWarning,
    #[serde(rename = "session.model_change")]
    SessionModelChange,
    #[serde(rename = "session.mode_changed")]
    SessionModeChanged,
    #[serde(rename = "session.plan_changed")]
    SessionPlanChanged,
    #[serde(rename = "session.workspace_file_changed")]
    SessionWorkspaceFileChanged,
    #[serde(rename = "session.handoff")]
    SessionHandoff,
    #[serde(rename = "session.truncation")]
    SessionTruncation,
    #[serde(rename = "session.snapshot_rewind")]
    SessionSnapshotRewind,
    #[serde(rename = "session.shutdown")]
    SessionShutdown,
    #[serde(rename = "session.context_changed")]
    SessionContextChanged,
    #[serde(rename = "session.usage_info")]
    SessionUsageInfo,
    #[serde(rename = "session.compaction_start")]
    SessionCompactionStart,
    #[serde(rename = "session.compaction_complete")]
    SessionCompactionComplete,
    #[serde(rename = "session.task_complete")]
    SessionTaskComplete,
    #[serde(rename = "user.message")]
    UserMessage,
    #[serde(rename = "pending_messages.modified")]
    PendingMessagesModified,
    #[serde(rename = "assistant.turn_start")]
    AssistantTurnStart,
    #[serde(rename = "assistant.intent")]
    AssistantIntent,
    #[serde(rename = "assistant.reasoning")]
    AssistantReasoning,
    #[serde(rename = "assistant.reasoning_delta")]
    AssistantReasoningDelta,
    #[serde(rename = "assistant.streaming_delta")]
    AssistantStreamingDelta,
    #[serde(rename = "assistant.message")]
    AssistantMessage,
    #[serde(rename = "assistant.message_start")]
    AssistantMessageStart,
    #[serde(rename = "assistant.message_delta")]
    AssistantMessageDelta,
    #[serde(rename = "assistant.turn_end")]
    AssistantTurnEnd,
    #[serde(rename = "assistant.usage")]
    AssistantUsage,
    #[serde(rename = "model.call_failure")]
    ModelCallFailure,
    #[serde(rename = "abort")]
    Abort,
    #[serde(rename = "tool.user_requested")]
    ToolUserRequested,
    #[serde(rename = "tool.execution_start")]
    ToolExecutionStart,
    #[serde(rename = "tool.execution_partial_result")]
    ToolExecutionPartialResult,
    #[serde(rename = "tool.execution_progress")]
    ToolExecutionProgress,
    #[serde(rename = "tool.execution_complete")]
    ToolExecutionComplete,
    #[serde(rename = "skill.invoked")]
    SkillInvoked,
    #[serde(rename = "subagent.started")]
    SubagentStarted,
    #[serde(rename = "subagent.completed")]
    SubagentCompleted,
    #[serde(rename = "subagent.failed")]
    SubagentFailed,
    #[serde(rename = "subagent.selected")]
    SubagentSelected,
    #[serde(rename = "subagent.deselected")]
    SubagentDeselected,
    #[serde(rename = "hook.start")]
    HookStart,
    #[serde(rename = "hook.end")]
    HookEnd,
    #[serde(rename = "system.message")]
    SystemMessage,
    #[serde(rename = "system.notification")]
    SystemNotification,
    #[serde(rename = "permission.requested")]
    PermissionRequested,
    #[serde(rename = "permission.completed")]
    PermissionCompleted,
    #[serde(rename = "user_input.requested")]
    UserInputRequested,
    #[serde(rename = "user_input.completed")]
    UserInputCompleted,
    #[serde(rename = "elicitation.requested")]
    ElicitationRequested,
    #[serde(rename = "elicitation.completed")]
    ElicitationCompleted,
    #[serde(rename = "sampling.requested")]
    SamplingRequested,
    #[serde(rename = "sampling.completed")]
    SamplingCompleted,
    #[serde(rename = "mcp.oauth_required")]
    McpOauthRequired,
    #[serde(rename = "mcp.oauth_completed")]
    McpOauthCompleted,
    #[serde(rename = "external_tool.requested")]
    ExternalToolRequested,
    #[serde(rename = "external_tool.completed")]
    ExternalToolCompleted,
    #[serde(rename = "command.queued")]
    CommandQueued,
    #[serde(rename = "command.execute")]
    CommandExecute,
    #[serde(rename = "command.completed")]
    CommandCompleted,
    #[serde(rename = "auto_mode_switch.requested")]
    AutoModeSwitchRequested,
    #[serde(rename = "auto_mode_switch.completed")]
    AutoModeSwitchCompleted,
    #[serde(rename = "commands.changed")]
    CommandsChanged,
    #[serde(rename = "capabilities.changed")]
    CapabilitiesChanged,
    #[serde(rename = "exit_plan_mode.requested")]
    ExitPlanModeRequested,
    #[serde(rename = "exit_plan_mode.completed")]
    ExitPlanModeCompleted,
    #[serde(rename = "session.tools_updated")]
    SessionToolsUpdated,
    #[serde(rename = "session.background_tasks_changed")]
    SessionBackgroundTasksChanged,
    #[serde(rename = "session.skills_loaded")]
    SessionSkillsLoaded,
    #[serde(rename = "session.custom_agents_updated")]
    SessionCustomAgentsUpdated,
    #[serde(rename = "session.mcp_servers_loaded")]
    SessionMcpServersLoaded,
    #[serde(rename = "session.mcp_server_status_changed")]
    SessionMcpServerStatusChanged,
    #[serde(rename = "session.extensions_loaded")]
    SessionExtensionsLoaded,
    /// Unknown event type for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Typed session event data, discriminated by the event `type` field.
///
/// Use with [`TypedSessionEvent`] for fully typed event handling.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", content = "data")]
pub enum SessionEventData {
    #[serde(rename = "session.start")]
    SessionStart(SessionStartData),
    #[serde(rename = "session.resume")]
    SessionResume(SessionResumeData),
    #[serde(rename = "session.remote_steerable_changed")]
    SessionRemoteSteerableChanged(SessionRemoteSteerableChangedData),
    #[serde(rename = "session.error")]
    SessionError(SessionErrorData),
    #[serde(rename = "session.idle")]
    SessionIdle(SessionIdleData),
    #[serde(rename = "session.title_changed")]
    SessionTitleChanged(SessionTitleChangedData),
    #[serde(rename = "session.info")]
    SessionInfo(SessionInfoData),
    #[serde(rename = "session.warning")]
    SessionWarning(SessionWarningData),
    #[serde(rename = "session.model_change")]
    SessionModelChange(SessionModelChangeData),
    #[serde(rename = "session.mode_changed")]
    SessionModeChanged(SessionModeChangedData),
    #[serde(rename = "session.plan_changed")]
    SessionPlanChanged(SessionPlanChangedData),
    #[serde(rename = "session.workspace_file_changed")]
    SessionWorkspaceFileChanged(SessionWorkspaceFileChangedData),
    #[serde(rename = "session.handoff")]
    SessionHandoff(SessionHandoffData),
    #[serde(rename = "session.truncation")]
    SessionTruncation(SessionTruncationData),
    #[serde(rename = "session.snapshot_rewind")]
    SessionSnapshotRewind(SessionSnapshotRewindData),
    #[serde(rename = "session.shutdown")]
    SessionShutdown(SessionShutdownData),
    #[serde(rename = "session.context_changed")]
    SessionContextChanged(SessionContextChangedData),
    #[serde(rename = "session.usage_info")]
    SessionUsageInfo(SessionUsageInfoData),
    #[serde(rename = "session.compaction_start")]
    SessionCompactionStart(SessionCompactionStartData),
    #[serde(rename = "session.compaction_complete")]
    SessionCompactionComplete(SessionCompactionCompleteData),
    #[serde(rename = "session.task_complete")]
    SessionTaskComplete(SessionTaskCompleteData),
    #[serde(rename = "user.message")]
    UserMessage(UserMessageData),
    #[serde(rename = "pending_messages.modified")]
    PendingMessagesModified(PendingMessagesModifiedData),
    #[serde(rename = "assistant.turn_start")]
    AssistantTurnStart(AssistantTurnStartData),
    #[serde(rename = "assistant.intent")]
    AssistantIntent(AssistantIntentData),
    #[serde(rename = "assistant.reasoning")]
    AssistantReasoning(AssistantReasoningData),
    #[serde(rename = "assistant.reasoning_delta")]
    AssistantReasoningDelta(AssistantReasoningDeltaData),
    #[serde(rename = "assistant.streaming_delta")]
    AssistantStreamingDelta(AssistantStreamingDeltaData),
    #[serde(rename = "assistant.message")]
    AssistantMessage(AssistantMessageData),
    #[serde(rename = "assistant.message_start")]
    AssistantMessageStart(AssistantMessageStartData),
    #[serde(rename = "assistant.message_delta")]
    AssistantMessageDelta(AssistantMessageDeltaData),
    #[serde(rename = "assistant.turn_end")]
    AssistantTurnEnd(AssistantTurnEndData),
    #[serde(rename = "assistant.usage")]
    AssistantUsage(AssistantUsageData),
    #[serde(rename = "model.call_failure")]
    ModelCallFailure(ModelCallFailureData),
    #[serde(rename = "abort")]
    Abort(AbortData),
    #[serde(rename = "tool.user_requested")]
    ToolUserRequested(ToolUserRequestedData),
    #[serde(rename = "tool.execution_start")]
    ToolExecutionStart(ToolExecutionStartData),
    #[serde(rename = "tool.execution_partial_result")]
    ToolExecutionPartialResult(ToolExecutionPartialResultData),
    #[serde(rename = "tool.execution_progress")]
    ToolExecutionProgress(ToolExecutionProgressData),
    #[serde(rename = "tool.execution_complete")]
    ToolExecutionComplete(ToolExecutionCompleteData),
    #[serde(rename = "skill.invoked")]
    SkillInvoked(SkillInvokedData),
    #[serde(rename = "subagent.started")]
    SubagentStarted(SubagentStartedData),
    #[serde(rename = "subagent.completed")]
    SubagentCompleted(SubagentCompletedData),
    #[serde(rename = "subagent.failed")]
    SubagentFailed(SubagentFailedData),
    #[serde(rename = "subagent.selected")]
    SubagentSelected(SubagentSelectedData),
    #[serde(rename = "subagent.deselected")]
    SubagentDeselected(SubagentDeselectedData),
    #[serde(rename = "hook.start")]
    HookStart(HookStartData),
    #[serde(rename = "hook.end")]
    HookEnd(HookEndData),
    #[serde(rename = "system.message")]
    SystemMessage(SystemMessageData),
    #[serde(rename = "system.notification")]
    SystemNotification(SystemNotificationData),
    #[serde(rename = "permission.requested")]
    PermissionRequested(PermissionRequestedData),
    #[serde(rename = "permission.completed")]
    PermissionCompleted(PermissionCompletedData),
    #[serde(rename = "user_input.requested")]
    UserInputRequested(UserInputRequestedData),
    #[serde(rename = "user_input.completed")]
    UserInputCompleted(UserInputCompletedData),
    #[serde(rename = "elicitation.requested")]
    ElicitationRequested(ElicitationRequestedData),
    #[serde(rename = "elicitation.completed")]
    ElicitationCompleted(ElicitationCompletedData),
    #[serde(rename = "sampling.requested")]
    SamplingRequested(SamplingRequestedData),
    #[serde(rename = "sampling.completed")]
    SamplingCompleted(SamplingCompletedData),
    #[serde(rename = "mcp.oauth_required")]
    McpOauthRequired(McpOauthRequiredData),
    #[serde(rename = "mcp.oauth_completed")]
    McpOauthCompleted(McpOauthCompletedData),
    #[serde(rename = "external_tool.requested")]
    ExternalToolRequested(ExternalToolRequestedData),
    #[serde(rename = "external_tool.completed")]
    ExternalToolCompleted(ExternalToolCompletedData),
    #[serde(rename = "command.queued")]
    CommandQueued(CommandQueuedData),
    #[serde(rename = "command.execute")]
    CommandExecute(CommandExecuteData),
    #[serde(rename = "command.completed")]
    CommandCompleted(CommandCompletedData),
    #[serde(rename = "auto_mode_switch.requested")]
    AutoModeSwitchRequested(AutoModeSwitchRequestedData),
    #[serde(rename = "auto_mode_switch.completed")]
    AutoModeSwitchCompleted(AutoModeSwitchCompletedData),
    #[serde(rename = "commands.changed")]
    CommandsChanged(CommandsChangedData),
    #[serde(rename = "capabilities.changed")]
    CapabilitiesChanged(CapabilitiesChangedData),
    #[serde(rename = "exit_plan_mode.requested")]
    ExitPlanModeRequested(ExitPlanModeRequestedData),
    #[serde(rename = "exit_plan_mode.completed")]
    ExitPlanModeCompleted(ExitPlanModeCompletedData),
    #[serde(rename = "session.tools_updated")]
    SessionToolsUpdated(SessionToolsUpdatedData),
    #[serde(rename = "session.background_tasks_changed")]
    SessionBackgroundTasksChanged(SessionBackgroundTasksChangedData),
    #[serde(rename = "session.skills_loaded")]
    SessionSkillsLoaded(SessionSkillsLoadedData),
    #[serde(rename = "session.custom_agents_updated")]
    SessionCustomAgentsUpdated(SessionCustomAgentsUpdatedData),
    #[serde(rename = "session.mcp_servers_loaded")]
    SessionMcpServersLoaded(SessionMcpServersLoadedData),
    #[serde(rename = "session.mcp_server_status_changed")]
    SessionMcpServerStatusChanged(SessionMcpServerStatusChangedData),
    #[serde(rename = "session.extensions_loaded")]
    SessionExtensionsLoaded(SessionExtensionsLoadedData),
}

/// A session event with typed data payload.
///
/// The common event fields (id, timestamp, parentId, ephemeral, agentId)
/// are available directly. The event-specific data is in the `payload`
/// field as a [`SessionEventData`] enum.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TypedSessionEvent {
    /// Unique event identifier (UUID v4).
    pub id: String,
    /// ISO 8601 timestamp when the event was created.
    pub timestamp: String,
    /// ID of the preceding event in the chain.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_id: Option<String>,
    /// When true, the event is transient and not persisted.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ephemeral: Option<bool>,
    /// Sub-agent instance identifier. Absent for events from the root /
    /// main agent and session-level events.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub agent_id: Option<String>,
    /// The typed event payload (discriminated by event type).
    #[serde(flatten)]
    pub payload: SessionEventData,
}

/// Working directory and git context at session start
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WorkingDirectoryContext {
    /// Base commit of current git branch at session start time
    #[serde(skip_serializing_if = "Option::is_none")]
    pub base_commit: Option<String>,
    /// Current git branch name
    #[serde(skip_serializing_if = "Option::is_none")]
    pub branch: Option<String>,
    /// Current working directory path
    pub cwd: String,
    /// Root directory of the git repository, resolved via git rev-parse
    #[serde(skip_serializing_if = "Option::is_none")]
    pub git_root: Option<String>,
    /// Head commit of current git branch at session start time
    #[serde(skip_serializing_if = "Option::is_none")]
    pub head_commit: Option<String>,
    /// Hosting platform type of the repository (github or ado)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub host_type: Option<WorkingDirectoryContextHostType>,
    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub repository: Option<String>,
    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub repository_host: Option<String>,
}

/// Session initialization metadata including context and configuration
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionStartData {
    /// Whether the session was already in use by another client at start time
    #[serde(skip_serializing_if = "Option::is_none")]
    pub already_in_use: Option<bool>,
    /// Working directory and git context at session start
    #[serde(skip_serializing_if = "Option::is_none")]
    pub context: Option<WorkingDirectoryContext>,
    /// Version string of the Copilot application
    pub copilot_version: String,
    /// Identifier of the software producing the events (e.g., "copilot-agent")
    pub producer: String,
    /// Reasoning effort level used for model calls, if applicable (e.g. "low", "medium", "high", "xhigh")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_effort: Option<String>,
    /// Whether this session supports remote steering via Mission Control
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remote_steerable: Option<bool>,
    /// Model selected at session creation time, if any
    #[serde(skip_serializing_if = "Option::is_none")]
    pub selected_model: Option<String>,
    /// Unique identifier for the session
    pub session_id: SessionId,
    /// ISO 8601 timestamp when the session was created
    pub start_time: String,
    /// Schema version number for the session event format
    pub version: f64,
}

/// Session resume metadata including current context and event count
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionResumeData {
    /// Whether the session was already in use by another client at resume time
    #[serde(skip_serializing_if = "Option::is_none")]
    pub already_in_use: Option<bool>,
    /// Updated working directory and git context at resume time
    #[serde(skip_serializing_if = "Option::is_none")]
    pub context: Option<WorkingDirectoryContext>,
    /// When true, tool calls and permission requests left in flight by the previous session lifetime remain pending after resume and the agentic loop awaits their results. User sends are queued behind the pending work until all such requests reach a terminal state. When false (the default), any such tool calls and permission requests are immediately marked as interrupted on resume.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub continue_pending_work: Option<bool>,
    /// Total number of persisted events in the session at the time of resume
    pub event_count: f64,
    /// Reasoning effort level used for model calls, if applicable (e.g. "low", "medium", "high", "xhigh")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_effort: Option<String>,
    /// Whether this session supports remote steering via Mission Control
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remote_steerable: Option<bool>,
    /// ISO 8601 timestamp when the session was resumed
    pub resume_time: String,
    /// Model currently selected at resume time
    #[serde(skip_serializing_if = "Option::is_none")]
    pub selected_model: Option<String>,
    /// True when this resume attached to a session that the runtime already had running in-memory (for example, an extension joining a session another client was actively driving). False (or omitted) for cold resumes — the runtime had to reconstitute the session from its persisted event log.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub session_was_active: Option<bool>,
}

/// Notifies Mission Control that the session's remote steering capability has changed
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionRemoteSteerableChangedData {
    /// Whether this session now supports remote steering via Mission Control
    pub remote_steerable: bool,
}

/// Error details for timeline display including message and optional diagnostic information
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionErrorData {
    /// Only set on `errorType: "rate_limit"`. When `true`, the runtime will follow this error with an `auto_mode_switch.requested` event (or silently switch if `continueOnAutoMode` is enabled). UI clients can use this flag to suppress duplicate rendering of the rate-limit error when they show their own auto-mode-switch prompt.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub eligible_for_auto_switch: Option<bool>,
    /// Fine-grained error code from the upstream provider, when available. For `errorType: "rate_limit"`, this is one of the `RateLimitErrorCode` values (e.g., `"user_weekly_rate_limited"`, `"user_global_rate_limited"`, `"rate_limited"`, `"user_model_rate_limited"`, `"integration_rate_limited"`).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error_code: Option<String>,
    /// Category of error (e.g., "authentication", "authorization", "quota", "rate_limit", "context_limit", "query")
    pub error_type: String,
    /// Human-readable error message
    pub message: String,
    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
    #[serde(skip_serializing_if = "Option::is_none")]
    pub provider_call_id: Option<String>,
    /// Error stack trace, when available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stack: Option<String>,
    /// HTTP status code from the upstream request, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status_code: Option<i64>,
    /// Optional URL associated with this error that the user can open in a browser
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
}

/// Payload indicating the session is idle with no background agents in flight
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionIdleData {
    /// True when the preceding agentic loop was cancelled via abort signal
    #[serde(skip_serializing_if = "Option::is_none")]
    pub aborted: Option<bool>,
}

/// Session title change payload containing the new display title
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTitleChangedData {
    /// The new display title for the session
    pub title: String,
}

/// Informational message for timeline display with categorization
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionInfoData {
    /// Category of informational message (e.g., "notification", "timing", "context_window", "mcp", "snapshot", "configuration", "authentication", "model")
    pub info_type: String,
    /// Human-readable informational message for display in the timeline
    pub message: String,
    /// Optional actionable tip displayed with this message
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tip: Option<String>,
    /// Optional URL associated with this message that the user can open in a browser
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
}

/// Warning message for timeline display with categorization
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionWarningData {
    /// Human-readable warning message for display in the timeline
    pub message: String,
    /// Optional URL associated with this warning that the user can open in a browser
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
    /// Category of warning (e.g., "subscription", "policy", "mcp")
    pub warning_type: String,
}

/// Model change details including previous and new model identifiers
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionModelChangeData {
    /// Reason the change happened, when not user-initiated. Currently `"rate_limit_auto_switch"` for changes triggered by the auto-mode-switch rate-limit recovery path. UI clients can use this to render contextual copy.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cause: Option<String>,
    /// Newly selected model identifier
    pub new_model: String,
    /// Model that was previously selected, if any
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previous_model: Option<String>,
    /// Reasoning effort level before the model change, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previous_reasoning_effort: Option<String>,
    /// Reasoning effort level after the model change, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_effort: Option<String>,
}

/// Agent mode change details including previous and new modes
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionModeChangedData {
    /// Agent mode after the change (e.g., "interactive", "plan", "autopilot")
    pub new_mode: String,
    /// Agent mode before the change (e.g., "interactive", "plan", "autopilot")
    pub previous_mode: String,
}

/// Plan file operation details indicating what changed
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionPlanChangedData {
    /// The type of operation performed on the plan file
    pub operation: PlanChangedOperation,
}

/// Workspace file change details including path and operation type
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionWorkspaceFileChangedData {
    /// Whether the file was newly created or updated
    pub operation: WorkspaceFileChangedOperation,
    /// Relative path within the session workspace files directory
    pub path: String,
}

/// Repository context for the handed-off session
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HandoffRepository {
    /// Git branch name, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub branch: Option<String>,
    /// Repository name
    pub name: String,
    /// Repository owner (user or organization)
    pub owner: String,
}

/// Session handoff metadata including source, context, and repository information
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionHandoffData {
    /// Additional context information for the handoff
    #[serde(skip_serializing_if = "Option::is_none")]
    pub context: Option<String>,
    /// ISO 8601 timestamp when the handoff occurred
    pub handoff_time: String,
    /// GitHub host URL for the source session (e.g., https://github.com or https://tenant.ghe.com)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub host: Option<String>,
    /// Session ID of the remote session being handed off
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remote_session_id: Option<SessionId>,
    /// Repository context for the handed-off session
    #[serde(skip_serializing_if = "Option::is_none")]
    pub repository: Option<HandoffRepository>,
    /// Origin type of the session being handed off
    pub source_type: HandoffSourceType,
    /// Summary of the work done in the source session
    #[serde(skip_serializing_if = "Option::is_none")]
    pub summary: Option<String>,
}

/// Conversation truncation statistics including token counts and removed content metrics
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTruncationData {
    /// Number of messages removed by truncation
    pub messages_removed_during_truncation: f64,
    /// Identifier of the component that performed truncation (e.g., "BasicTruncator")
    pub performed_by: String,
    /// Number of conversation messages after truncation
    pub post_truncation_messages_length: f64,
    /// Total tokens in conversation messages after truncation
    pub post_truncation_tokens_in_messages: f64,
    /// Number of conversation messages before truncation
    pub pre_truncation_messages_length: f64,
    /// Total tokens in conversation messages before truncation
    pub pre_truncation_tokens_in_messages: f64,
    /// Maximum token count for the model's context window
    pub token_limit: f64,
    /// Number of tokens removed by truncation
    pub tokens_removed_during_truncation: f64,
}

/// Session rewind details including target event and count of removed events
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionSnapshotRewindData {
    /// Number of events that were removed by the rewind
    pub events_removed: f64,
    /// Event ID that was rewound to; this event and all after it were removed
    pub up_to_event_id: String,
}

/// Aggregate code change metrics for the session
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownCodeChanges {
    /// List of file paths that were modified during the session
    pub files_modified: Vec<String>,
    /// Total number of lines added during the session
    pub lines_added: f64,
    /// Total number of lines removed during the session
    pub lines_removed: f64,
}

/// Request count and cost metrics
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownModelMetricRequests {
    /// Cumulative cost multiplier for requests to this model
    pub cost: f64,
    /// Total number of API requests made to this model
    pub count: f64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownModelMetricTokenDetail {
    /// Accumulated token count for this token type
    pub token_count: f64,
}

/// Token usage breakdown
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownModelMetricUsage {
    /// Total tokens read from prompt cache across all requests
    pub cache_read_tokens: f64,
    /// Total tokens written to prompt cache across all requests
    pub cache_write_tokens: f64,
    /// Total input tokens consumed across all requests to this model
    pub input_tokens: f64,
    /// Total output tokens produced across all requests to this model
    pub output_tokens: f64,
    /// Total reasoning tokens produced across all requests to this model
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_tokens: Option<f64>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownModelMetric {
    /// Request count and cost metrics
    pub requests: ShutdownModelMetricRequests,
    /// Token count details per type
    #[serde(default)]
    pub token_details: HashMap<String, ShutdownModelMetricTokenDetail>,
    /// Accumulated nano-AI units cost for this model
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_nano_aiu: Option<f64>,
    /// Token usage breakdown
    pub usage: ShutdownModelMetricUsage,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownTokenDetail {
    /// Accumulated token count for this token type
    pub token_count: f64,
}

/// Session termination metrics including usage statistics, code changes, and shutdown reason
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionShutdownData {
    /// Aggregate code change metrics for the session
    pub code_changes: ShutdownCodeChanges,
    /// Non-system message token count at shutdown
    #[serde(skip_serializing_if = "Option::is_none")]
    pub conversation_tokens: Option<f64>,
    /// Model that was selected at the time of shutdown
    #[serde(skip_serializing_if = "Option::is_none")]
    pub current_model: Option<String>,
    /// Total tokens in context window at shutdown
    #[serde(skip_serializing_if = "Option::is_none")]
    pub current_tokens: Option<f64>,
    /// Error description when shutdownType is "error"
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error_reason: Option<String>,
    /// Per-model usage breakdown, keyed by model identifier
    pub model_metrics: HashMap<String, ShutdownModelMetric>,
    /// Unix timestamp (milliseconds) when the session started
    pub session_start_time: f64,
    /// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
    pub shutdown_type: ShutdownType,
    /// System message token count at shutdown
    #[serde(skip_serializing_if = "Option::is_none")]
    pub system_tokens: Option<f64>,
    /// Session-wide per-token-type accumulated token counts
    #[serde(default)]
    pub token_details: HashMap<String, ShutdownTokenDetail>,
    /// Tool definitions token count at shutdown
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_definitions_tokens: Option<f64>,
    /// Cumulative time spent in API calls during the session, in milliseconds
    pub total_api_duration_ms: f64,
    /// Session-wide accumulated nano-AI units cost
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_nano_aiu: Option<f64>,
    /// Total number of premium API requests used during the session
    pub total_premium_requests: f64,
}

/// Working directory and git context at session start
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionContextChangedData {
    /// Base commit of current git branch at session start time
    #[serde(skip_serializing_if = "Option::is_none")]
    pub base_commit: Option<String>,
    /// Current git branch name
    #[serde(skip_serializing_if = "Option::is_none")]
    pub branch: Option<String>,
    /// Current working directory path
    pub cwd: String,
    /// Root directory of the git repository, resolved via git rev-parse
    #[serde(skip_serializing_if = "Option::is_none")]
    pub git_root: Option<String>,
    /// Head commit of current git branch at session start time
    #[serde(skip_serializing_if = "Option::is_none")]
    pub head_commit: Option<String>,
    /// Hosting platform type of the repository (github or ado)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub host_type: Option<WorkingDirectoryContextHostType>,
    /// Repository identifier derived from the git remote URL ("owner/name" for GitHub, "org/project/repo" for Azure DevOps)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub repository: Option<String>,
    /// Raw host string from the git remote URL (e.g. "github.com", "mycompany.ghe.com", "dev.azure.com")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub repository_host: Option<String>,
}

/// Current context window usage statistics including token and message counts
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionUsageInfoData {
    /// Token count from non-system messages (user, assistant, tool)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub conversation_tokens: Option<f64>,
    /// Current number of tokens in the context window
    pub current_tokens: f64,
    /// Whether this is the first usage_info event emitted in this session
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_initial: Option<bool>,
    /// Current number of messages in the conversation
    pub messages_length: f64,
    /// Token count from system message(s)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub system_tokens: Option<f64>,
    /// Maximum token count for the model's context window
    pub token_limit: f64,
    /// Token count from tool definitions
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_definitions_tokens: Option<f64>,
}

/// Context window breakdown at the start of LLM-powered conversation compaction
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionCompactionStartData {
    /// Token count from non-system messages (user, assistant, tool) at compaction start
    #[serde(skip_serializing_if = "Option::is_none")]
    pub conversation_tokens: Option<f64>,
    /// Token count from system message(s) at compaction start
    #[serde(skip_serializing_if = "Option::is_none")]
    pub system_tokens: Option<f64>,
    /// Token count from tool definitions at compaction start
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_definitions_tokens: Option<f64>,
}

/// Token usage detail for a single billing category
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail {
    /// Number of tokens in this billing batch
    pub batch_size: f64,
    /// Cost per batch of tokens
    pub cost_per_batch: f64,
    /// Total token count for this entry
    pub token_count: f64,
    /// Token category (e.g., "input", "output")
    pub token_type: String,
}

/// Per-request cost and usage data from the CAPI copilot_usage response field
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CompactionCompleteCompactionTokensUsedCopilotUsage {
    /// Itemized token usage breakdown
    pub token_details: Vec<CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail>,
    /// Total cost in nano-AI units for this request
    pub total_nano_aiu: f64,
}

/// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CompactionCompleteCompactionTokensUsed {
    /// Cached input tokens reused in the compaction LLM call
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cache_read_tokens: Option<f64>,
    /// Tokens written to prompt cache in the compaction LLM call
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cache_write_tokens: Option<f64>,
    /// Per-request cost and usage data from the CAPI copilot_usage response field
    #[serde(skip_serializing_if = "Option::is_none")]
    pub copilot_usage: Option<CompactionCompleteCompactionTokensUsedCopilotUsage>,
    /// Duration of the compaction LLM call in milliseconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<f64>,
    /// Input tokens consumed by the compaction LLM call
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input_tokens: Option<f64>,
    /// Model identifier used for the compaction LLM call
    #[serde(skip_serializing_if = "Option::is_none")]
    pub model: Option<String>,
    /// Output tokens produced by the compaction LLM call
    #[serde(skip_serializing_if = "Option::is_none")]
    pub output_tokens: Option<f64>,
}

/// Conversation compaction results including success status, metrics, and optional error details
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionCompactionCompleteData {
    /// Checkpoint snapshot number created for recovery
    #[serde(skip_serializing_if = "Option::is_none")]
    pub checkpoint_number: Option<f64>,
    /// File path where the checkpoint was stored
    #[serde(skip_serializing_if = "Option::is_none")]
    pub checkpoint_path: Option<String>,
    /// Token usage breakdown for the compaction LLM call (aligned with assistant.usage format)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub compaction_tokens_used: Option<CompactionCompleteCompactionTokensUsed>,
    /// Token count from non-system messages (user, assistant, tool) after compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub conversation_tokens: Option<f64>,
    /// Error message if compaction failed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<String>,
    /// Number of messages removed during compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub messages_removed: Option<f64>,
    /// Total tokens in conversation after compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub post_compaction_tokens: Option<f64>,
    /// Number of messages before compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pre_compaction_messages_length: Option<f64>,
    /// Total tokens in conversation before compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pre_compaction_tokens: Option<f64>,
    /// GitHub request tracing ID (x-github-request-id header) for the compaction LLM call
    #[serde(skip_serializing_if = "Option::is_none")]
    pub request_id: Option<RequestId>,
    /// Whether compaction completed successfully
    pub success: bool,
    /// LLM-generated summary of the compacted conversation history
    #[serde(skip_serializing_if = "Option::is_none")]
    pub summary_content: Option<String>,
    /// Token count from system message(s) after compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub system_tokens: Option<f64>,
    /// Number of tokens removed during compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tokens_removed: Option<f64>,
    /// Token count from tool definitions after compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_definitions_tokens: Option<f64>,
}

/// Task completion notification with summary from the agent
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTaskCompleteData {
    /// Whether the tool call succeeded. False when validation failed (e.g., invalid arguments)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub success: Option<bool>,
    /// Summary of the completed task, provided by the agent
    #[serde(skip_serializing_if = "Option::is_none")]
    pub summary: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserMessageData {
    /// The agent mode that was active when this message was sent
    #[serde(skip_serializing_if = "Option::is_none")]
    pub agent_mode: Option<UserMessageAgentMode>,
    /// Files, selections, or GitHub references attached to the message
    #[serde(default)]
    pub attachments: Vec<serde_json::Value>,
    /// The user's message text as displayed in the timeline
    pub content: String,
    /// CAPI interaction ID for correlating this user message with its turn
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interaction_id: Option<String>,
    /// Path-backed native document attachments that stayed on the tagged_files path flow because native upload would exceed the request size limit
    #[serde(default)]
    pub native_document_path_fallback_paths: Vec<String>,
    /// Parent agent task ID for background telemetry correlated to this user turn
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_agent_task_id: Option<String>,
    /// Origin of this message, used for timeline filtering (e.g., "skill-pdf" for skill-injected messages that should be hidden from the user)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source: Option<String>,
    /// Normalized document MIME types that were sent natively instead of through tagged_files XML
    #[serde(default)]
    pub supported_native_document_mime_types: Vec<String>,
    /// Transformed version of the message sent to the model, with XML wrapping, timestamps, and other augmentations for prompt caching
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transformed_content: Option<String>,
}

/// Empty payload; the event signals that the pending message queue has changed
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PendingMessagesModifiedData {}

/// Turn initialization metadata including identifier and interaction tracking
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantTurnStartData {
    /// CAPI interaction ID for correlating this turn with upstream telemetry
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interaction_id: Option<String>,
    /// Identifier for this turn within the agentic loop, typically a stringified turn number
    pub turn_id: String,
}

/// Agent intent description for current activity or plan
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantIntentData {
    /// Short description of what the agent is currently doing or planning to do
    pub intent: String,
}

/// Assistant reasoning content for timeline display with complete thinking text
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantReasoningData {
    /// The complete extended thinking text from the model
    pub content: String,
    /// Unique identifier for this reasoning block
    pub reasoning_id: String,
}

/// Streaming reasoning delta for incremental extended thinking updates
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantReasoningDeltaData {
    /// Incremental text chunk to append to the reasoning content
    pub delta_content: String,
    /// Reasoning block ID this delta belongs to, matching the corresponding assistant.reasoning event
    pub reasoning_id: String,
}

/// Streaming response progress with cumulative byte count
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantStreamingDeltaData {
    /// Cumulative total bytes received from the streaming response so far
    pub total_response_size_bytes: f64,
}

/// A tool invocation request from the assistant
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantMessageToolRequest {
    /// Arguments to pass to the tool, format depends on the tool
    #[serde(skip_serializing_if = "Option::is_none")]
    pub arguments: Option<serde_json::Value>,
    /// Resolved intention summary describing what this specific call does
    #[serde(skip_serializing_if = "Option::is_none")]
    pub intention_summary: Option<String>,
    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mcp_server_name: Option<String>,
    /// Name of the tool being invoked
    pub name: String,
    /// Unique identifier for this tool call
    pub tool_call_id: String,
    /// Human-readable display title for the tool
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_title: Option<String>,
    /// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub r#type: Option<AssistantMessageToolRequestType>,
}

/// Assistant response containing text content, optional tool requests, and interaction metadata
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantMessageData {
    /// The assistant's text response content
    pub content: String,
    /// Encrypted reasoning content from OpenAI models. Session-bound and stripped on resume.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub encrypted_content: Option<String>,
    /// CAPI interaction ID for correlating this message with upstream telemetry
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interaction_id: Option<String>,
    /// Unique identifier for this assistant message
    pub message_id: String,
    /// Actual output token count from the API response (completion_tokens), used for accurate token accounting
    #[serde(skip_serializing_if = "Option::is_none")]
    pub output_tokens: Option<f64>,
    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
    #[deprecated]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_tool_call_id: Option<String>,
    /// Generation phase for phased-output models (e.g., thinking vs. response phases)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub phase: Option<String>,
    /// Opaque/encrypted extended thinking data from Anthropic models. Session-bound and stripped on resume.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_opaque: Option<String>,
    /// Readable reasoning text from the model's extended thinking
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_text: Option<String>,
    /// GitHub request tracing ID (x-github-request-id header) for correlating with server-side logs
    #[serde(skip_serializing_if = "Option::is_none")]
    pub request_id: Option<RequestId>,
    /// Tool invocations requested by the assistant in this message
    #[serde(default)]
    pub tool_requests: Vec<AssistantMessageToolRequest>,
    /// Identifier for the agent loop turn that produced this message, matching the corresponding assistant.turn_start event
    #[serde(skip_serializing_if = "Option::is_none")]
    pub turn_id: Option<String>,
}

/// Streaming assistant message start metadata
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantMessageStartData {
    /// Message ID this start event belongs to, matching subsequent deltas and assistant.message
    pub message_id: String,
    /// Generation phase this message belongs to for phased-output models
    #[serde(skip_serializing_if = "Option::is_none")]
    pub phase: Option<String>,
}

/// Streaming assistant message delta for incremental response updates
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantMessageDeltaData {
    /// Incremental text chunk to append to the message content
    pub delta_content: String,
    /// Message ID this delta belongs to, matching the corresponding assistant.message event
    pub message_id: String,
    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
    #[deprecated]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_tool_call_id: Option<String>,
}

/// Turn completion metadata including the turn identifier
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantTurnEndData {
    /// Identifier of the turn that has ended, matching the corresponding assistant.turn_start event
    pub turn_id: String,
}

/// Token usage detail for a single billing category
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantUsageCopilotUsageTokenDetail {
    /// Number of tokens in this billing batch
    pub batch_size: f64,
    /// Cost per batch of tokens
    pub cost_per_batch: f64,
    /// Total token count for this entry
    pub token_count: f64,
    /// Token category (e.g., "input", "output")
    pub token_type: String,
}

/// Per-request cost and usage data from the CAPI copilot_usage response field
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantUsageCopilotUsage {
    /// Itemized token usage breakdown
    pub token_details: Vec<AssistantUsageCopilotUsageTokenDetail>,
    /// Total cost in nano-AI units for this request
    pub total_nano_aiu: f64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantUsageQuotaSnapshot {
    /// Total requests allowed by the entitlement
    pub entitlement_requests: f64,
    /// Whether the user has an unlimited usage entitlement
    pub is_unlimited_entitlement: bool,
    /// Number of requests over the entitlement limit
    pub overage: f64,
    /// Whether overage is allowed when quota is exhausted
    pub overage_allowed_with_exhausted_quota: bool,
    /// Percentage of quota remaining (0.0 to 1.0)
    pub remaining_percentage: f64,
    /// Date when the quota resets
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reset_date: Option<String>,
    /// Whether usage is still permitted after quota exhaustion
    pub usage_allowed_with_exhausted_quota: bool,
    /// Number of requests already consumed
    pub used_requests: f64,
}

/// LLM API call usage metrics including tokens, costs, quotas, and billing information
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantUsageData {
    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub api_call_id: Option<String>,
    /// Number of tokens read from prompt cache
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cache_read_tokens: Option<f64>,
    /// Number of tokens written to prompt cache
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cache_write_tokens: Option<f64>,
    /// Per-request cost and usage data from the CAPI copilot_usage response field
    #[serde(skip_serializing_if = "Option::is_none")]
    pub copilot_usage: Option<AssistantUsageCopilotUsage>,
    /// Model multiplier cost for billing purposes
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cost: Option<f64>,
    /// Duration of the API call in milliseconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<f64>,
    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
    #[serde(skip_serializing_if = "Option::is_none")]
    pub initiator: Option<String>,
    /// Number of input tokens consumed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input_tokens: Option<f64>,
    /// Average inter-token latency in milliseconds. Only available for streaming requests
    #[serde(skip_serializing_if = "Option::is_none")]
    pub inter_token_latency_ms: Option<f64>,
    /// Model identifier used for this API call
    pub model: String,
    /// Number of output tokens produced
    #[serde(skip_serializing_if = "Option::is_none")]
    pub output_tokens: Option<f64>,
    /// Parent tool call ID when this usage originates from a sub-agent
    #[deprecated]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_tool_call_id: Option<String>,
    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub provider_call_id: Option<String>,
    /// Per-quota resource usage snapshots, keyed by quota identifier
    #[serde(default)]
    pub quota_snapshots: HashMap<String, AssistantUsageQuotaSnapshot>,
    /// Reasoning effort level used for model calls, if applicable (e.g. "low", "medium", "high", "xhigh")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_effort: Option<String>,
    /// Number of output tokens used for reasoning (e.g., chain-of-thought)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_tokens: Option<f64>,
    /// Time to first token in milliseconds. Only available for streaming requests
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ttft_ms: Option<f64>,
}

/// Failed LLM API call metadata for telemetry
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ModelCallFailureData {
    /// Completion ID from the model provider (e.g., chatcmpl-abc123)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub api_call_id: Option<String>,
    /// Duration of the failed API call in milliseconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration_ms: Option<f64>,
    /// Raw provider/runtime error message for restricted telemetry
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error_message: Option<String>,
    /// What initiated this API call (e.g., "sub-agent", "mcp-sampling"); absent for user-initiated calls
    #[serde(skip_serializing_if = "Option::is_none")]
    pub initiator: Option<String>,
    /// Model identifier used for the failed API call
    #[serde(skip_serializing_if = "Option::is_none")]
    pub model: Option<String>,
    /// GitHub request tracing ID (x-github-request-id header) for server-side log correlation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub provider_call_id: Option<String>,
    /// Where the failed model call originated
    pub source: ModelCallFailureSource,
    /// HTTP status code from the failed request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status_code: Option<i64>,
}

/// Turn abort information including the reason for termination
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AbortData {
    /// Reason the current turn was aborted (e.g., "user initiated")
    pub reason: String,
}

/// User-initiated tool invocation request with tool name and arguments
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolUserRequestedData {
    /// Arguments for the tool invocation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub arguments: Option<serde_json::Value>,
    /// Unique identifier for this tool call
    pub tool_call_id: String,
    /// Name of the tool the user wants to invoke
    pub tool_name: String,
}

/// Tool execution startup details including MCP server information when applicable
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionStartData {
    /// Arguments passed to the tool
    #[serde(skip_serializing_if = "Option::is_none")]
    pub arguments: Option<serde_json::Value>,
    /// Name of the MCP server hosting this tool, when the tool is an MCP tool
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mcp_server_name: Option<String>,
    /// Original tool name on the MCP server, when the tool is an MCP tool
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mcp_tool_name: Option<String>,
    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
    #[deprecated]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_tool_call_id: Option<String>,
    /// Unique identifier for this tool call
    pub tool_call_id: String,
    /// Name of the tool being executed
    pub tool_name: String,
    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
    #[serde(skip_serializing_if = "Option::is_none")]
    pub turn_id: Option<String>,
}

/// Streaming tool execution output for incremental result display
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionPartialResultData {
    /// Incremental output chunk from the running tool
    pub partial_output: String,
    /// Tool call ID this partial result belongs to
    pub tool_call_id: String,
}

/// Tool execution progress notification with status message
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionProgressData {
    /// Human-readable progress status message (e.g., from an MCP server)
    pub progress_message: String,
    /// Tool call ID this progress notification belongs to
    pub tool_call_id: String,
}

/// Error details when the tool execution failed
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteError {
    /// Machine-readable error code
    #[serde(skip_serializing_if = "Option::is_none")]
    pub code: Option<String>,
    /// Human-readable error message
    pub message: String,
}

/// Tool execution result on success
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteResult {
    /// Concise tool result text sent to the LLM for chat completion, potentially truncated for token efficiency
    pub content: String,
    /// Structured content blocks (text, images, audio, resources) returned by the tool in their native format
    #[serde(default)]
    pub contents: Vec<serde_json::Value>,
    /// Full detailed tool result for UI/timeline display, preserving complete content such as diffs. Falls back to content when absent.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub detailed_content: Option<String>,
}

/// Tool execution completion results including success status, detailed output, and error information
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteData {
    /// Error details when the tool execution failed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<ToolExecutionCompleteError>,
    /// CAPI interaction ID for correlating this tool execution with upstream telemetry
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interaction_id: Option<String>,
    /// Whether this tool call was explicitly requested by the user rather than the assistant
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_user_requested: Option<bool>,
    /// Model identifier that generated this tool call
    #[serde(skip_serializing_if = "Option::is_none")]
    pub model: Option<String>,
    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
    #[deprecated]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_tool_call_id: Option<String>,
    /// Tool execution result on success
    #[serde(skip_serializing_if = "Option::is_none")]
    pub result: Option<ToolExecutionCompleteResult>,
    /// Whether the tool execution completed successfully
    pub success: bool,
    /// Unique identifier for the completed tool call
    pub tool_call_id: String,
    /// Tool-specific telemetry data (e.g., CodeQL check counts, grep match counts)
    #[serde(default)]
    pub tool_telemetry: HashMap<String, serde_json::Value>,
    /// Identifier for the agent loop turn this tool was invoked in, matching the corresponding assistant.turn_start event
    #[serde(skip_serializing_if = "Option::is_none")]
    pub turn_id: Option<String>,
}

/// Skill invocation details including content, allowed tools, and plugin metadata
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SkillInvokedData {
    /// Tool names that should be auto-approved when this skill is active
    #[serde(default)]
    pub allowed_tools: Vec<String>,
    /// Full content of the skill file, injected into the conversation for the model
    pub content: String,
    /// Description of the skill from its SKILL.md frontmatter
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// Name of the invoked skill
    pub name: String,
    /// File path to the SKILL.md definition
    pub path: String,
    /// Name of the plugin this skill originated from, when applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub plugin_name: Option<String>,
    /// Version of the plugin this skill originated from, when applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub plugin_version: Option<String>,
}

/// Sub-agent startup details including parent tool call and agent information
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SubagentStartedData {
    /// Description of what the sub-agent does
    pub agent_description: String,
    /// Human-readable display name of the sub-agent
    pub agent_display_name: String,
    /// Internal name of the sub-agent
    pub agent_name: String,
    /// Tool call ID of the parent tool invocation that spawned this sub-agent
    pub tool_call_id: String,
}

/// Sub-agent completion details for successful execution
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SubagentCompletedData {
    /// Human-readable display name of the sub-agent
    pub agent_display_name: String,
    /// Internal name of the sub-agent
    pub agent_name: String,
    /// Wall-clock duration of the sub-agent execution in milliseconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration_ms: Option<f64>,
    /// Model used by the sub-agent
    #[serde(skip_serializing_if = "Option::is_none")]
    pub model: Option<String>,
    /// Tool call ID of the parent tool invocation that spawned this sub-agent
    pub tool_call_id: String,
    /// Total tokens (input + output) consumed by the sub-agent
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_tokens: Option<f64>,
    /// Total number of tool calls made by the sub-agent
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_tool_calls: Option<f64>,
}

/// Sub-agent failure details including error message and agent information
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SubagentFailedData {
    /// Human-readable display name of the sub-agent
    pub agent_display_name: String,
    /// Internal name of the sub-agent
    pub agent_name: String,
    /// Wall-clock duration of the sub-agent execution in milliseconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration_ms: Option<f64>,
    /// Error message describing why the sub-agent failed
    pub error: String,
    /// Model used by the sub-agent (if any model calls succeeded before failure)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub model: Option<String>,
    /// Tool call ID of the parent tool invocation that spawned this sub-agent
    pub tool_call_id: String,
    /// Total tokens (input + output) consumed before the sub-agent failed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_tokens: Option<f64>,
    /// Total number of tool calls made before the sub-agent failed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_tool_calls: Option<f64>,
}

/// Custom agent selection details including name and available tools
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SubagentSelectedData {
    /// Human-readable display name of the selected custom agent
    pub agent_display_name: String,
    /// Internal name of the selected custom agent
    pub agent_name: String,
    /// List of tool names available to this agent, or null for all tools
    pub tools: Vec<String>,
}

/// Empty payload; the event signals that the custom agent was deselected, returning to the default agent
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SubagentDeselectedData {}

/// Hook invocation start details including type and input data
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HookStartData {
    /// Unique identifier for this hook invocation
    pub hook_invocation_id: String,
    /// Type of hook being invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
    pub hook_type: String,
    /// Input data passed to the hook
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input: Option<serde_json::Value>,
}

/// Error details when the hook failed
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HookEndError {
    /// Human-readable error message
    pub message: String,
    /// Error stack trace, when available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stack: Option<String>,
}

/// Hook invocation completion details including output, success status, and error information
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct HookEndData {
    /// Error details when the hook failed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<HookEndError>,
    /// Identifier matching the corresponding hook.start event
    pub hook_invocation_id: String,
    /// Type of hook that was invoked (e.g., "preToolUse", "postToolUse", "sessionStart")
    pub hook_type: String,
    /// Output data produced by the hook
    #[serde(skip_serializing_if = "Option::is_none")]
    pub output: Option<serde_json::Value>,
    /// Whether the hook completed successfully
    pub success: bool,
}

/// Metadata about the prompt template and its construction
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SystemMessageMetadata {
    /// Version identifier of the prompt template used
    #[serde(skip_serializing_if = "Option::is_none")]
    pub prompt_version: Option<String>,
    /// Template variables used when constructing the prompt
    #[serde(default)]
    pub variables: HashMap<String, serde_json::Value>,
}

/// System/developer instruction content with role and optional template metadata
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SystemMessageData {
    /// The system or developer prompt text sent as model input
    pub content: String,
    /// Metadata about the prompt template and its construction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub metadata: Option<SystemMessageMetadata>,
    /// Optional name identifier for the message source
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    /// Message role: "system" for system prompts, "developer" for developer-injected instructions
    pub role: SystemMessageRole,
}

/// System-generated notification for runtime events like background task completion
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SystemNotificationData {
    /// The notification text, typically wrapped in <system_notification> XML tags
    pub content: String,
    /// Structured metadata identifying what triggered this notification
    pub kind: serde_json::Value,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestShellCommand {
    /// Command identifier (e.g., executable name)
    pub identifier: String,
    /// Whether this command is read-only (no side effects)
    pub read_only: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestShellPossibleUrl {
    /// URL that may be accessed by the command
    pub url: String,
}

/// Shell command permission request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestShell {
    /// Whether the UI can offer session-wide approval for this command pattern
    pub can_offer_session_approval: bool,
    /// Parsed command identifiers found in the command text
    pub commands: Vec<PermissionRequestShellCommand>,
    /// The complete shell command text to be executed
    pub full_command_text: String,
    /// Whether the command includes a file write redirection (e.g., > or >>)
    pub has_write_file_redirection: bool,
    /// Human-readable description of what the command intends to do
    pub intention: String,
    /// Permission kind discriminator
    pub kind: PermissionRequestShellKind,
    /// File paths that may be read or written by the command
    pub possible_paths: Vec<String>,
    /// URLs that may be accessed by the command
    pub possible_urls: Vec<PermissionRequestShellPossibleUrl>,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// Optional warning message about risks of running this command
    #[serde(skip_serializing_if = "Option::is_none")]
    pub warning: Option<String>,
}

/// File write permission request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestWrite {
    /// Whether the UI can offer session-wide approval for file write operations
    pub can_offer_session_approval: bool,
    /// Unified diff showing the proposed changes
    pub diff: String,
    /// Path of the file being written to
    pub file_name: String,
    /// Human-readable description of the intended file change
    pub intention: String,
    /// Permission kind discriminator
    pub kind: PermissionRequestWriteKind,
    /// Complete new file contents for newly created files
    #[serde(skip_serializing_if = "Option::is_none")]
    pub new_file_contents: Option<String>,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// File or directory read permission request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestRead {
    /// Human-readable description of why the file is being read
    pub intention: String,
    /// Permission kind discriminator
    pub kind: PermissionRequestReadKind,
    /// Path of the file or directory being read
    pub path: String,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// MCP tool invocation permission request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestMcp {
    /// Arguments to pass to the MCP tool
    #[serde(skip_serializing_if = "Option::is_none")]
    pub args: Option<serde_json::Value>,
    /// Permission kind discriminator
    pub kind: PermissionRequestMcpKind,
    /// Whether this MCP tool is read-only (no side effects)
    pub read_only: bool,
    /// Name of the MCP server providing the tool
    pub server_name: String,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// Internal name of the MCP tool
    pub tool_name: String,
    /// Human-readable title of the MCP tool
    pub tool_title: String,
}

/// URL access permission request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestUrl {
    /// Human-readable description of why the URL is being accessed
    pub intention: String,
    /// Permission kind discriminator
    pub kind: PermissionRequestUrlKind,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// URL to be fetched
    pub url: String,
}

/// Memory operation permission request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestMemory {
    /// Whether this is a store or vote memory operation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub action: Option<PermissionRequestMemoryAction>,
    /// Source references for the stored fact (store only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub citations: Option<String>,
    /// Vote direction (vote only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub direction: Option<PermissionRequestMemoryDirection>,
    /// The fact being stored or voted on
    pub fact: String,
    /// Permission kind discriminator
    pub kind: PermissionRequestMemoryKind,
    /// Reason for the vote (vote only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reason: Option<String>,
    /// Topic or subject of the memory (store only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub subject: Option<String>,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// Custom tool invocation permission request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestCustomTool {
    /// Arguments to pass to the custom tool
    #[serde(skip_serializing_if = "Option::is_none")]
    pub args: Option<serde_json::Value>,
    /// Permission kind discriminator
    pub kind: PermissionRequestCustomToolKind,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// Description of what the custom tool does
    pub tool_description: String,
    /// Name of the custom tool
    pub tool_name: String,
}

/// Hook confirmation permission request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestHook {
    /// Optional message from the hook explaining why confirmation is needed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub hook_message: Option<String>,
    /// Permission kind discriminator
    pub kind: PermissionRequestHookKind,
    /// Arguments of the tool call being gated
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_args: Option<serde_json::Value>,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// Name of the tool the hook is gating
    pub tool_name: String,
}

/// Shell command permission prompt
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionPromptRequestCommands {
    /// Whether the UI can offer session-wide approval for this command pattern
    pub can_offer_session_approval: bool,
    /// Command identifiers covered by this approval prompt
    pub command_identifiers: Vec<String>,
    /// The complete shell command text to be executed
    pub full_command_text: String,
    /// Human-readable description of what the command intends to do
    pub intention: String,
    /// Prompt kind discriminator
    pub kind: PermissionPromptRequestCommandsKind,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// Optional warning message about risks of running this command
    #[serde(skip_serializing_if = "Option::is_none")]
    pub warning: Option<String>,
}

/// File write permission prompt
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionPromptRequestWrite {
    /// Whether the UI can offer session-wide approval for file write operations
    pub can_offer_session_approval: bool,
    /// Unified diff showing the proposed changes
    pub diff: String,
    /// Path of the file being written to
    pub file_name: String,
    /// Human-readable description of the intended file change
    pub intention: String,
    /// Prompt kind discriminator
    pub kind: PermissionPromptRequestWriteKind,
    /// Complete new file contents for newly created files
    #[serde(skip_serializing_if = "Option::is_none")]
    pub new_file_contents: Option<String>,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// File read permission prompt
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionPromptRequestRead {
    /// Human-readable description of why the file is being read
    pub intention: String,
    /// Prompt kind discriminator
    pub kind: PermissionPromptRequestReadKind,
    /// Path of the file or directory being read
    pub path: String,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// MCP tool invocation permission prompt
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionPromptRequestMcp {
    /// Arguments to pass to the MCP tool
    #[serde(skip_serializing_if = "Option::is_none")]
    pub args: Option<serde_json::Value>,
    /// Prompt kind discriminator
    pub kind: PermissionPromptRequestMcpKind,
    /// Name of the MCP server providing the tool
    pub server_name: String,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// Internal name of the MCP tool
    pub tool_name: String,
    /// Human-readable title of the MCP tool
    pub tool_title: String,
}

/// URL access permission prompt
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionPromptRequestUrl {
    /// Human-readable description of why the URL is being accessed
    pub intention: String,
    /// Prompt kind discriminator
    pub kind: PermissionPromptRequestUrlKind,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// URL to be fetched
    pub url: String,
}

/// Memory operation permission prompt
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionPromptRequestMemory {
    /// Whether this is a store or vote memory operation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub action: Option<PermissionPromptRequestMemoryAction>,
    /// Source references for the stored fact (store only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub citations: Option<String>,
    /// Vote direction (vote only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub direction: Option<PermissionPromptRequestMemoryDirection>,
    /// The fact being stored or voted on
    pub fact: String,
    /// Prompt kind discriminator
    pub kind: PermissionPromptRequestMemoryKind,
    /// Reason for the vote (vote only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reason: Option<String>,
    /// Topic or subject of the memory (store only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub subject: Option<String>,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// Custom tool invocation permission prompt
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionPromptRequestCustomTool {
    /// Arguments to pass to the custom tool
    #[serde(skip_serializing_if = "Option::is_none")]
    pub args: Option<serde_json::Value>,
    /// Prompt kind discriminator
    pub kind: PermissionPromptRequestCustomToolKind,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// Description of what the custom tool does
    pub tool_description: String,
    /// Name of the custom tool
    pub tool_name: String,
}

/// Path access permission prompt
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionPromptRequestPath {
    /// Underlying permission kind that needs path approval
    pub access_kind: PermissionPromptRequestPathAccessKind,
    /// Prompt kind discriminator
    pub kind: PermissionPromptRequestPathKind,
    /// File paths that require explicit approval
    pub paths: Vec<String>,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// Hook confirmation permission prompt
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionPromptRequestHook {
    /// Optional message from the hook explaining why confirmation is needed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub hook_message: Option<String>,
    /// Prompt kind discriminator
    pub kind: PermissionPromptRequestHookKind,
    /// Arguments of the tool call being gated
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_args: Option<serde_json::Value>,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// Name of the tool the hook is gating
    pub tool_name: String,
}

/// Permission request notification requiring client approval with request details
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestedData {
    /// Details of the permission being requested
    pub permission_request: PermissionRequest,
    /// Derived user-facing permission prompt details for UI consumers
    #[serde(skip_serializing_if = "Option::is_none")]
    pub prompt_request: Option<PermissionPromptRequest>,
    /// Unique identifier for this permission request; used to respond via session.respondToPermission()
    pub request_id: RequestId,
    /// When true, this permission was already resolved by a permissionRequest hook and requires no client action
    #[serde(skip_serializing_if = "Option::is_none")]
    pub resolved_by_hook: Option<bool>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionApproved {
    /// The permission request was approved
    pub kind: PermissionApprovedKind,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserToolSessionApprovalCommands {
    /// Command identifiers approved by the user
    pub command_identifiers: Vec<String>,
    /// Command approval kind
    pub kind: UserToolSessionApprovalCommandsKind,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserToolSessionApprovalRead {
    /// Read approval kind
    pub kind: UserToolSessionApprovalReadKind,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserToolSessionApprovalWrite {
    /// Write approval kind
    pub kind: UserToolSessionApprovalWriteKind,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserToolSessionApprovalMcp {
    /// MCP tool approval kind
    pub kind: UserToolSessionApprovalMcpKind,
    /// MCP server name
    pub server_name: String,
    /// Optional MCP tool name, or null for all tools on the server
    pub tool_name: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserToolSessionApprovalMemory {
    /// Memory approval kind
    pub kind: UserToolSessionApprovalMemoryKind,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserToolSessionApprovalCustomTool {
    /// Custom tool approval kind
    pub kind: UserToolSessionApprovalCustomToolKind,
    /// Custom tool name
    pub tool_name: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionApprovedForSession {
    /// The approval to add as a session-scoped rule
    pub approval: UserToolSessionApproval,
    /// Approved and remembered for the rest of the session
    pub kind: PermissionApprovedForSessionKind,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionApprovedForLocation {
    /// The approval to persist for this location
    pub approval: UserToolSessionApproval,
    /// Approved and persisted for this project location
    pub kind: PermissionApprovedForLocationKind,
    /// The location key (git root or cwd) to persist the approval to
    pub location_key: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionCancelled {
    /// The permission request was cancelled before a response was used
    pub kind: PermissionCancelledKind,
    /// Optional explanation of why the request was cancelled
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reason: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRule {
    /// Optional rule argument matched against the request
    pub argument: Option<String>,
    /// The rule kind, such as Shell or GitHubMCP
    pub kind: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionDeniedByRules {
    /// Denied because approval rules explicitly blocked it
    pub kind: PermissionDeniedByRulesKind,
    /// Rules that denied the request
    pub rules: Vec<PermissionRule>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser {
    /// Denied because no approval rule matched and user confirmation was unavailable
    pub kind: PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionDeniedInteractivelyByUser {
    /// Optional feedback from the user explaining the denial
    #[serde(skip_serializing_if = "Option::is_none")]
    pub feedback: Option<String>,
    /// Whether to force-reject the current agent turn
    #[serde(skip_serializing_if = "Option::is_none")]
    pub force_reject: Option<bool>,
    /// Denied by the user during an interactive prompt
    pub kind: PermissionDeniedInteractivelyByUserKind,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionDeniedByContentExclusionPolicy {
    /// Denied by the organization's content exclusion policy
    pub kind: PermissionDeniedByContentExclusionPolicyKind,
    /// Human-readable explanation of why the path was excluded
    pub message: String,
    /// File path that triggered the exclusion
    pub path: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionDeniedByPermissionRequestHook {
    /// Whether to interrupt the current agent turn
    #[serde(skip_serializing_if = "Option::is_none")]
    pub interrupt: Option<bool>,
    /// Denied by a permission request hook registered by an extension or plugin
    pub kind: PermissionDeniedByPermissionRequestHookKind,
    /// Optional message from the hook explaining the denial
    #[serde(skip_serializing_if = "Option::is_none")]
    pub message: Option<String>,
}

/// Permission request completion notification signaling UI dismissal
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionCompletedData {
    /// Request ID of the resolved permission request; clients should dismiss any UI for this request
    pub request_id: RequestId,
    /// The result of the permission request
    pub result: PermissionResult,
    /// Optional tool call ID associated with this permission prompt; clients may use it to correlate UI created from tool-scoped prompts
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// User input request notification with question and optional predefined choices
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserInputRequestedData {
    /// Whether the user can provide a free-form text response in addition to predefined choices
    #[serde(skip_serializing_if = "Option::is_none")]
    pub allow_freeform: Option<bool>,
    /// Predefined choices for the user to select from, if applicable
    #[serde(default)]
    pub choices: Vec<String>,
    /// The question or prompt to present to the user
    pub question: String,
    /// Unique identifier for this input request; used to respond via session.respondToUserInput()
    pub request_id: RequestId,
    /// The LLM-assigned tool call ID that triggered this request; used by remote UIs to correlate responses
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// User input request completion with the user's response
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserInputCompletedData {
    /// The user's answer to the input request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub answer: Option<String>,
    /// Request ID of the resolved user input request; clients should dismiss any UI for this request
    pub request_id: RequestId,
    /// Whether the answer was typed as free-form text rather than selected from choices
    #[serde(skip_serializing_if = "Option::is_none")]
    pub was_freeform: Option<bool>,
}

/// JSON Schema describing the form fields to present to the user (form mode only)
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ElicitationRequestedSchema {
    /// Form field definitions, keyed by field name
    pub properties: HashMap<String, serde_json::Value>,
    /// List of required field names
    #[serde(default)]
    pub required: Vec<String>,
    /// Schema type indicator (always 'object')
    pub r#type: ElicitationRequestedSchemaType,
}

/// Elicitation request; may be form-based (structured input) or URL-based (browser redirect)
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ElicitationRequestedData {
    /// The source that initiated the request (MCP server name, or absent for agent-initiated)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub elicitation_source: Option<String>,
    /// Message describing what information is needed from the user
    pub message: String,
    /// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mode: Option<ElicitationRequestedMode>,
    /// JSON Schema describing the form fields to present to the user (form mode only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub requested_schema: Option<ElicitationRequestedSchema>,
    /// Unique identifier for this elicitation request; used to respond via session.respondToElicitation()
    pub request_id: RequestId,
    /// Tool call ID from the LLM completion; used to correlate with CompletionChunk.toolCall.id for remote UIs
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
    /// URL to open in the user's browser (url mode only)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
}

/// Elicitation request completion with the user's response
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ElicitationCompletedData {
    /// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub action: Option<ElicitationCompletedAction>,
    /// The submitted form data when action is 'accept'; keys match the requested schema fields
    #[serde(default)]
    pub content: HashMap<String, serde_json::Value>,
    /// Request ID of the resolved elicitation request; clients should dismiss any UI for this request
    pub request_id: RequestId,
}

/// Sampling request from an MCP server; contains the server name and a requestId for correlation
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SamplingRequestedData {
    /// The JSON-RPC request ID from the MCP protocol
    pub mcp_request_id: serde_json::Value,
    /// Unique identifier for this sampling request; used to respond via session.respondToSampling()
    pub request_id: RequestId,
    /// Name of the MCP server that initiated the sampling request
    pub server_name: String,
}

/// Sampling request completion notification signaling UI dismissal
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SamplingCompletedData {
    /// Request ID of the resolved sampling request; clients should dismiss any UI for this request
    pub request_id: RequestId,
}

/// Static OAuth client configuration, if the server specifies one
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct McpOauthRequiredStaticClientConfig {
    /// OAuth client ID for the server
    pub client_id: String,
    /// Optional non-default OAuth grant type. When set to 'client_credentials', the OAuth flow runs headlessly using the client_id + keychain-stored secret (no browser, no callback server).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub grant_type: Option<McpOauthRequiredStaticClientConfigGrantType>,
    /// Whether this is a public OAuth client
    #[serde(skip_serializing_if = "Option::is_none")]
    pub public_client: Option<bool>,
}

/// OAuth authentication request for an MCP server
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct McpOauthRequiredData {
    /// Unique identifier for this OAuth request; used to respond via session.respondToMcpOAuth()
    pub request_id: RequestId,
    /// Display name of the MCP server that requires OAuth
    pub server_name: String,
    /// URL of the MCP server that requires OAuth
    pub server_url: String,
    /// Static OAuth client configuration, if the server specifies one
    #[serde(skip_serializing_if = "Option::is_none")]
    pub static_client_config: Option<McpOauthRequiredStaticClientConfig>,
}

/// MCP OAuth request completion notification
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct McpOauthCompletedData {
    /// Request ID of the resolved OAuth request
    pub request_id: RequestId,
}

/// External tool invocation request for client-side tool execution
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExternalToolRequestedData {
    /// Arguments to pass to the external tool
    #[serde(skip_serializing_if = "Option::is_none")]
    pub arguments: Option<serde_json::Value>,
    /// Unique identifier for this request; used to respond via session.respondToExternalTool()
    pub request_id: RequestId,
    /// Session ID that this external tool request belongs to
    pub session_id: SessionId,
    /// Tool call ID assigned to this external tool invocation
    pub tool_call_id: String,
    /// Name of the external tool to invoke
    pub tool_name: String,
    /// W3C Trace Context traceparent header for the execute_tool span
    #[serde(skip_serializing_if = "Option::is_none")]
    pub traceparent: Option<String>,
    /// W3C Trace Context tracestate header for the execute_tool span
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tracestate: Option<String>,
}

/// External tool completion notification signaling UI dismissal
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExternalToolCompletedData {
    /// Request ID of the resolved external tool request; clients should dismiss any UI for this request
    pub request_id: RequestId,
}

/// Queued slash command dispatch request for client execution
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CommandQueuedData {
    /// The slash command text to be executed (e.g., /help, /clear)
    pub command: String,
    /// Unique identifier for this request; used to respond via session.respondToQueuedCommand()
    pub request_id: RequestId,
}

/// Registered command dispatch request routed to the owning client
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CommandExecuteData {
    /// Raw argument string after the command name
    pub args: String,
    /// The full command text (e.g., /deploy production)
    pub command: String,
    /// Command name without leading /
    pub command_name: String,
    /// Unique identifier; used to respond via session.commands.handlePendingCommand()
    pub request_id: RequestId,
}

/// Queued command completion notification signaling UI dismissal
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CommandCompletedData {
    /// Request ID of the resolved command request; clients should dismiss any UI for this request
    pub request_id: RequestId,
}

/// Auto mode switch request notification requiring user approval
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AutoModeSwitchRequestedData {
    /// The rate limit error code that triggered this request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error_code: Option<String>,
    /// Unique identifier for this request; used to respond via session.respondToAutoModeSwitch()
    pub request_id: RequestId,
    /// Seconds until the rate limit resets, when known. Lets clients render a humanized reset time alongside the prompt.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub retry_after_seconds: Option<f64>,
}

/// Auto mode switch completion notification
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AutoModeSwitchCompletedData {
    /// Request ID of the resolved request; clients should dismiss any UI for this request
    pub request_id: RequestId,
    /// The user's choice: 'yes', 'yes_always', or 'no'
    pub response: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CommandsChangedCommand {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    pub name: String,
}

/// SDK command registration change notification
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CommandsChangedData {
    /// Current list of registered SDK commands
    pub commands: Vec<CommandsChangedCommand>,
}

/// UI capability changes
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CapabilitiesChangedUI {
    /// Whether elicitation is now supported
    #[serde(skip_serializing_if = "Option::is_none")]
    pub elicitation: Option<bool>,
}

/// Session capability change notification
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CapabilitiesChangedData {
    /// UI capability changes
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ui: Option<CapabilitiesChangedUI>,
}

/// Plan approval request with plan content and available user actions
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExitPlanModeRequestedData {
    /// Available actions the user can take (e.g., approve, edit, reject)
    pub actions: Vec<String>,
    /// Full content of the plan file
    pub plan_content: String,
    /// The recommended action for the user to take
    pub recommended_action: String,
    /// Unique identifier for this request; used to respond via session.respondToExitPlanMode()
    pub request_id: RequestId,
    /// Summary of the plan that was created
    pub summary: String,
}

/// Plan mode exit completion with the user's approval decision and optional feedback
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExitPlanModeCompletedData {
    /// Whether the plan was approved by the user
    #[serde(skip_serializing_if = "Option::is_none")]
    pub approved: Option<bool>,
    /// Whether edits should be auto-approved without confirmation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub auto_approve_edits: Option<bool>,
    /// Free-form feedback from the user if they requested changes to the plan
    #[serde(skip_serializing_if = "Option::is_none")]
    pub feedback: Option<String>,
    /// Request ID of the resolved exit plan mode request; clients should dismiss any UI for this request
    pub request_id: RequestId,
    /// Which action the user selected (e.g. 'autopilot', 'interactive', 'exit_only')
    #[serde(skip_serializing_if = "Option::is_none")]
    pub selected_action: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionToolsUpdatedData {
    pub model: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionBackgroundTasksChangedData {}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SkillsLoadedSkill {
    /// Description of what the skill does
    pub description: String,
    /// Whether the skill is currently enabled
    pub enabled: bool,
    /// Unique identifier for the skill
    pub name: String,
    /// Absolute path to the skill file, if available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub path: Option<String>,
    /// Source location type of the skill (e.g., project, personal, plugin)
    pub source: String,
    /// Whether the skill can be invoked by the user as a slash command
    pub user_invocable: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionSkillsLoadedData {
    /// Array of resolved skill metadata
    pub skills: Vec<SkillsLoadedSkill>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CustomAgentsUpdatedAgent {
    /// Description of what the agent does
    pub description: String,
    /// Human-readable display name
    pub display_name: String,
    /// Unique identifier for the agent
    pub id: String,
    /// Model override for this agent, if set
    #[serde(skip_serializing_if = "Option::is_none")]
    pub model: Option<String>,
    /// Internal name of the agent
    pub name: String,
    /// Source location: user, project, inherited, remote, or plugin
    pub source: String,
    /// List of tool names available to this agent, or null when all tools are available
    pub tools: Vec<String>,
    /// Whether the agent can be selected by the user
    pub user_invocable: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionCustomAgentsUpdatedData {
    /// Array of loaded custom agent metadata
    pub agents: Vec<CustomAgentsUpdatedAgent>,
    /// Fatal errors from agent loading
    pub errors: Vec<String>,
    /// Non-fatal warnings from agent loading
    pub warnings: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct McpServersLoadedServer {
    /// Error message if the server failed to connect
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<String>,
    /// Server name (config key)
    pub name: String,
    /// Configuration source: user, workspace, plugin, or builtin
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source: Option<String>,
    /// Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
    pub status: McpServersLoadedServerStatus,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionMcpServersLoadedData {
    /// Array of MCP server status summaries
    pub servers: Vec<McpServersLoadedServer>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionMcpServerStatusChangedData {
    /// Name of the MCP server whose status changed
    pub server_name: String,
    /// New connection status: connected, failed, needs-auth, pending, disabled, or not_configured
    pub status: McpServerStatusChangedStatus,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExtensionsLoadedExtension {
    /// Source-qualified extension ID (e.g., 'project:my-ext', 'user:auth-helper')
    pub id: String,
    /// Extension name (directory name)
    pub name: String,
    /// Discovery source
    pub source: ExtensionsLoadedExtensionSource,
    /// Current status: running, disabled, failed, or starting
    pub status: ExtensionsLoadedExtensionStatus,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionExtensionsLoadedData {
    /// Array of discovered extensions and their status
    pub extensions: Vec<ExtensionsLoadedExtension>,
}

/// Hosting platform type of the repository (github or ado)
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum WorkingDirectoryContextHostType {
    #[serde(rename = "github")]
    Github,
    #[serde(rename = "ado")]
    Ado,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// The type of operation performed on the plan file
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PlanChangedOperation {
    #[serde(rename = "create")]
    Create,
    #[serde(rename = "update")]
    Update,
    #[serde(rename = "delete")]
    Delete,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Whether the file was newly created or updated
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum WorkspaceFileChangedOperation {
    #[serde(rename = "create")]
    Create,
    #[serde(rename = "update")]
    Update,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Origin type of the session being handed off
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum HandoffSourceType {
    #[serde(rename = "remote")]
    Remote,
    #[serde(rename = "local")]
    Local,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Whether the session ended normally ("routine") or due to a crash/fatal error ("error")
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ShutdownType {
    #[serde(rename = "routine")]
    Routine,
    #[serde(rename = "error")]
    Error,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// The agent mode that was active when this message was sent
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserMessageAgentMode {
    #[serde(rename = "interactive")]
    Interactive,
    #[serde(rename = "plan")]
    Plan,
    #[serde(rename = "autopilot")]
    Autopilot,
    #[serde(rename = "shell")]
    Shell,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Tool call type: "function" for standard tool calls, "custom" for grammar-based tool calls. Defaults to "function" when absent.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum AssistantMessageToolRequestType {
    #[serde(rename = "function")]
    Function,
    #[serde(rename = "custom")]
    Custom,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Where the failed model call originated
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ModelCallFailureSource {
    #[serde(rename = "top_level")]
    TopLevel,
    #[serde(rename = "subagent")]
    Subagent,
    #[serde(rename = "mcp_sampling")]
    McpSampling,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Message role: "system" for system prompts, "developer" for developer-injected instructions
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum SystemMessageRole {
    #[serde(rename = "system")]
    System,
    #[serde(rename = "developer")]
    Developer,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Permission kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestShellKind {
    #[serde(rename = "shell")]
    Shell,
}

/// Permission kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestWriteKind {
    #[serde(rename = "write")]
    Write,
}

/// Permission kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestReadKind {
    #[serde(rename = "read")]
    Read,
}

/// Permission kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestMcpKind {
    #[serde(rename = "mcp")]
    Mcp,
}

/// Permission kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestUrlKind {
    #[serde(rename = "url")]
    Url,
}

/// Whether this is a store or vote memory operation
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestMemoryAction {
    #[serde(rename = "store")]
    Store,
    #[serde(rename = "vote")]
    Vote,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Vote direction (vote only)
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestMemoryDirection {
    #[serde(rename = "upvote")]
    Upvote,
    #[serde(rename = "downvote")]
    Downvote,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Permission kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestMemoryKind {
    #[serde(rename = "memory")]
    Memory,
}

/// Permission kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestCustomToolKind {
    #[serde(rename = "custom-tool")]
    CustomTool,
}

/// Permission kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestHookKind {
    #[serde(rename = "hook")]
    Hook,
}

/// Details of the permission being requested
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PermissionRequest {
    Shell(PermissionRequestShell),
    Write(PermissionRequestWrite),
    Read(PermissionRequestRead),
    Mcp(PermissionRequestMcp),
    Url(PermissionRequestUrl),
    Memory(PermissionRequestMemory),
    CustomTool(PermissionRequestCustomTool),
    Hook(PermissionRequestHook),
}

/// Prompt kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestCommandsKind {
    #[serde(rename = "commands")]
    Commands,
}

/// Prompt kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestWriteKind {
    #[serde(rename = "write")]
    Write,
}

/// Prompt kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestReadKind {
    #[serde(rename = "read")]
    Read,
}

/// Prompt kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestMcpKind {
    #[serde(rename = "mcp")]
    Mcp,
}

/// Prompt kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestUrlKind {
    #[serde(rename = "url")]
    Url,
}

/// Whether this is a store or vote memory operation
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestMemoryAction {
    #[serde(rename = "store")]
    Store,
    #[serde(rename = "vote")]
    Vote,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Vote direction (vote only)
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestMemoryDirection {
    #[serde(rename = "upvote")]
    Upvote,
    #[serde(rename = "downvote")]
    Downvote,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Prompt kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestMemoryKind {
    #[serde(rename = "memory")]
    Memory,
}

/// Prompt kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestCustomToolKind {
    #[serde(rename = "custom-tool")]
    CustomTool,
}

/// Underlying permission kind that needs path approval
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestPathAccessKind {
    #[serde(rename = "read")]
    Read,
    #[serde(rename = "shell")]
    Shell,
    #[serde(rename = "write")]
    Write,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Prompt kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestPathKind {
    #[serde(rename = "path")]
    Path,
}

/// Prompt kind discriminator
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestHookKind {
    #[serde(rename = "hook")]
    Hook,
}

/// Derived user-facing permission prompt details for UI consumers
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PermissionPromptRequest {
    Commands(PermissionPromptRequestCommands),
    Write(PermissionPromptRequestWrite),
    Read(PermissionPromptRequestRead),
    Mcp(PermissionPromptRequestMcp),
    Url(PermissionPromptRequestUrl),
    Memory(PermissionPromptRequestMemory),
    CustomTool(PermissionPromptRequestCustomTool),
    Path(PermissionPromptRequestPath),
    Hook(PermissionPromptRequestHook),
}

/// The permission request was approved
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionApprovedKind {
    #[serde(rename = "approved")]
    Approved,
}

/// Command approval kind
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserToolSessionApprovalCommandsKind {
    #[serde(rename = "commands")]
    Commands,
}

/// Read approval kind
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserToolSessionApprovalReadKind {
    #[serde(rename = "read")]
    Read,
}

/// Write approval kind
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserToolSessionApprovalWriteKind {
    #[serde(rename = "write")]
    Write,
}

/// MCP tool approval kind
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserToolSessionApprovalMcpKind {
    #[serde(rename = "mcp")]
    Mcp,
}

/// Memory approval kind
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserToolSessionApprovalMemoryKind {
    #[serde(rename = "memory")]
    Memory,
}

/// Custom tool approval kind
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserToolSessionApprovalCustomToolKind {
    #[serde(rename = "custom-tool")]
    CustomTool,
}

/// The approval to add as a session-scoped rule
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UserToolSessionApproval {
    Commands(UserToolSessionApprovalCommands),
    Read(UserToolSessionApprovalRead),
    Write(UserToolSessionApprovalWrite),
    Mcp(UserToolSessionApprovalMcp),
    Memory(UserToolSessionApprovalMemory),
    CustomTool(UserToolSessionApprovalCustomTool),
}

/// Approved and remembered for the rest of the session
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionApprovedForSessionKind {
    #[serde(rename = "approved-for-session")]
    ApprovedForSession,
}

/// Approved and persisted for this project location
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionApprovedForLocationKind {
    #[serde(rename = "approved-for-location")]
    ApprovedForLocation,
}

/// The permission request was cancelled before a response was used
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionCancelledKind {
    #[serde(rename = "cancelled")]
    Cancelled,
}

/// Denied because approval rules explicitly blocked it
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionDeniedByRulesKind {
    #[serde(rename = "denied-by-rules")]
    DeniedByRules,
}

/// Denied because no approval rule matched and user confirmation was unavailable
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUserKind {
    #[serde(rename = "denied-no-approval-rule-and-could-not-request-from-user")]
    DeniedNoApprovalRuleAndCouldNotRequestFromUser,
}

/// Denied by the user during an interactive prompt
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionDeniedInteractivelyByUserKind {
    #[serde(rename = "denied-interactively-by-user")]
    DeniedInteractivelyByUser,
}

/// Denied by the organization's content exclusion policy
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionDeniedByContentExclusionPolicyKind {
    #[serde(rename = "denied-by-content-exclusion-policy")]
    DeniedByContentExclusionPolicy,
}

/// Denied by a permission request hook registered by an extension or plugin
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionDeniedByPermissionRequestHookKind {
    #[serde(rename = "denied-by-permission-request-hook")]
    DeniedByPermissionRequestHook,
}

/// The result of the permission request
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum PermissionResult {
    Approved(PermissionApproved),
    ApprovedForSession(PermissionApprovedForSession),
    ApprovedForLocation(PermissionApprovedForLocation),
    Cancelled(PermissionCancelled),
    DeniedByRules(PermissionDeniedByRules),
    DeniedNoApprovalRuleAndCouldNotRequestFromUser(
        PermissionDeniedNoApprovalRuleAndCouldNotRequestFromUser,
    ),
    DeniedInteractivelyByUser(PermissionDeniedInteractivelyByUser),
    DeniedByContentExclusionPolicy(PermissionDeniedByContentExclusionPolicy),
    DeniedByPermissionRequestHook(PermissionDeniedByPermissionRequestHook),
}

/// Elicitation mode; "form" for structured input, "url" for browser-based. Defaults to "form" when absent.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ElicitationRequestedMode {
    #[serde(rename = "form")]
    Form,
    #[serde(rename = "url")]
    Url,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Schema type indicator (always 'object')
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ElicitationRequestedSchemaType {
    #[serde(rename = "object")]
    Object,
}

/// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ElicitationCompletedAction {
    #[serde(rename = "accept")]
    Accept,
    #[serde(rename = "decline")]
    Decline,
    #[serde(rename = "cancel")]
    Cancel,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Optional non-default OAuth grant type. When set to 'client_credentials', the OAuth flow runs headlessly using the client_id + keychain-stored secret (no browser, no callback server).
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum McpOauthRequiredStaticClientConfigGrantType {
    #[serde(rename = "client_credentials")]
    ClientCredentials,
}

/// Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum McpServersLoadedServerStatus {
    #[serde(rename = "connected")]
    Connected,
    #[serde(rename = "failed")]
    Failed,
    #[serde(rename = "needs-auth")]
    NeedsAuth,
    #[serde(rename = "pending")]
    Pending,
    #[serde(rename = "disabled")]
    Disabled,
    #[serde(rename = "not_configured")]
    NotConfigured,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// New connection status: connected, failed, needs-auth, pending, disabled, or not_configured
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum McpServerStatusChangedStatus {
    #[serde(rename = "connected")]
    Connected,
    #[serde(rename = "failed")]
    Failed,
    #[serde(rename = "needs-auth")]
    NeedsAuth,
    #[serde(rename = "pending")]
    Pending,
    #[serde(rename = "disabled")]
    Disabled,
    #[serde(rename = "not_configured")]
    NotConfigured,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Discovery source
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ExtensionsLoadedExtensionSource {
    #[serde(rename = "project")]
    Project,
    #[serde(rename = "user")]
    User,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}

/// Current status: running, disabled, failed, or starting
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum ExtensionsLoadedExtensionStatus {
    #[serde(rename = "running")]
    Running,
    #[serde(rename = "disabled")]
    Disabled,
    #[serde(rename = "failed")]
    Failed,
    #[serde(rename = "starting")]
    Starting,
    /// Unknown variant for forward compatibility.
    #[serde(other)]
    Unknown,
}