github-copilot-sdk 1.0.0-beta.7

Rust SDK for programmatic control of the GitHub Copilot CLI via JSON-RPC. Technical preview, pre-1.0.
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
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
//! 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, Default, 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.schedule_created")]
    SessionScheduleCreated,
    #[serde(rename = "session.schedule_cancelled")]
    SessionScheduleCancelled,
    #[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 = "session.custom_notification")]
    SessionCustomNotification,
    #[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,
    #[serde(rename = "session.canvas.opened")]
    SessionCanvasOpened,
    #[serde(rename = "session.canvas.registry_changed")]
    SessionCanvasRegistryChanged,
    #[serde(rename = "mcp_app.tool_call_complete")]
    McpAppToolCallComplete,
    /// Unknown event type for forward compatibility.
    #[default]
    #[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.schedule_created")]
    SessionScheduleCreated(SessionScheduleCreatedData),
    #[serde(rename = "session.schedule_cancelled")]
    SessionScheduleCancelled(SessionScheduleCancelledData),
    #[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 = "session.custom_notification")]
    SessionCustomNotification(SessionCustomNotificationData),
    #[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),
    #[serde(rename = "session.canvas.opened")]
    SessionCanvasOpened(SessionCanvasOpenedData),
    #[serde(rename = "session.canvas.registry_changed")]
    SessionCanvasRegistryChanged(SessionCanvasRegistryChangedData),
    #[serde(rename = "mcp_app.tool_call_complete")]
    McpAppToolCallComplete(McpAppToolCallCompleteData),
}

/// 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, Default, 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 event "session.start". Session initialization metadata including context and configuration
#[derive(Debug, Clone, Default, 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,
    /// When set, identifies a parent session whose context this session continues — e.g., a detached headless rem-agent run launched on the parent's interactive shutdown. Telemetry from this session is reported under the parent's session_id.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub detached_from_spawning_parent_session_id: Option<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. "none", "low", "medium", "high", "xhigh", "max")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_effort: Option<String>,
    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_summary: Option<ReasoningSummary>,
    /// Whether this session supports remote steering via GitHub
    #[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: i64,
}

/// Session event "session.resume". Session resume metadata including current context and event count
#[derive(Debug, Clone, Default, 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: i64,
    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_effort: Option<String>,
    /// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_summary: Option<ReasoningSummary>,
    /// Whether this session supports remote steering via GitHub
    #[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>,
}

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

/// Session event "session.error". Error details for timeline display including message and optional diagnostic information
#[derive(Debug, Clone, Default, 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"`). For `errorType: "quota"`, this is the CAPI quota error code (e.g., `"quota_exceeded"`, `"session_quota_exceeded"`, `"billing_not_configured"`).
    #[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>,
    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub service_request_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<i32>,
    /// 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>,
}

/// Session event "session.idle". Payload indicating the session is idle with no background agents in flight
#[derive(Debug, Clone, Default, 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 event "session.title_changed". Session title change payload containing the new display title
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTitleChangedData {
    /// The new display title for the session
    pub title: String,
}

/// Session event "session.schedule_created". Scheduled prompt registered via /every or /after
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionScheduleCreatedData {
    /// Optional user-facing label shown in the timeline instead of the actual prompt (e.g. `/skill-name args` when the prompt is a skill invocation expansion)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub display_prompt: Option<String>,
    /// Sequential id assigned to the scheduled prompt within the session
    pub id: i64,
    /// Interval between ticks in milliseconds
    pub interval_ms: i64,
    /// Prompt text that gets enqueued on every tick
    pub prompt: String,
    /// Whether the schedule re-arms after each tick (`/every`) or fires once (`/after`)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub recurring: Option<bool>,
}

/// Session event "session.schedule_cancelled". Scheduled prompt cancelled from the schedule manager dialog
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionScheduleCancelledData {
    /// Id of the scheduled prompt that was cancelled
    pub id: i64,
}

/// Session event "session.info". Informational message for timeline display with categorization
#[derive(Debug, Clone, Default, 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>,
}

/// Session event "session.warning". Warning message for timeline display with categorization
#[derive(Debug, Clone, Default, 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,
}

/// Session event "session.model_change". Model change details including previous and new model identifiers
#[derive(Debug, Clone, Default, 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>,
    /// Context tier after the model change; null explicitly clears a previously selected tier
    #[serde(skip_serializing_if = "Option::is_none")]
    pub context_tier: Option<SessionModelChangeDataContextTier>,
    /// 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 summary mode before the model change, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previous_reasoning_summary: Option<ReasoningSummary>,
    /// Reasoning effort level after the model change, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_effort: Option<String>,
    /// Reasoning summary mode after the model change, if applicable
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reasoning_summary: Option<ReasoningSummary>,
}

/// Session event "session.mode_changed". Agent mode change details including previous and new modes
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionModeChangedData {
    /// The session mode the agent is operating in
    pub new_mode: SessionMode,
    /// The session mode the agent is operating in
    pub previous_mode: SessionMode,
}

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

/// Session event "session.workspace_file_changed". Workspace file change details including path and operation type
#[derive(Debug, Clone, Default, 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, Default, 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 event "session.handoff". Session handoff metadata including source, context, and repository information
#[derive(Debug, Clone, Default, 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>,
}

/// Session event "session.truncation". Conversation truncation statistics including token counts and removed content metrics
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionTruncationData {
    /// Number of messages removed by truncation
    pub messages_removed_during_truncation: i64,
    /// 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: i64,
    /// Total tokens in conversation messages after truncation
    pub post_truncation_tokens_in_messages: i64,
    /// Number of conversation messages before truncation
    pub pre_truncation_messages_length: i64,
    /// Total tokens in conversation messages before truncation
    pub pre_truncation_tokens_in_messages: i64,
    /// Maximum token count for the model's context window
    pub token_limit: i64,
    /// Number of tokens removed by truncation
    pub tokens_removed_during_truncation: i64,
}

/// Session event "session.snapshot_rewind". Session rewind details including target event and count of removed events
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionSnapshotRewindData {
    /// Number of events that were removed by the rewind
    pub events_removed: i64,
    /// 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, Default, 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: i64,
    /// Total number of lines removed during the session
    pub lines_removed: i64,
}

/// Request count and cost metrics
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ShutdownModelMetricRequests {
    /// Cumulative cost multiplier for requests to this model
    ///
    /// <div class="warning">
    ///
    /// **Experimental.** This type is part of an experimental wire-protocol surface
    /// and may change or be removed in future SDK or CLI releases.
    ///
    /// </div>
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cost: Option<f64>,
    /// Total number of API requests made to this model
    ///
    /// <div class="warning">
    ///
    /// **Experimental.** This type is part of an experimental wire-protocol surface
    /// and may change or be removed in future SDK or CLI releases.
    ///
    /// </div>
    #[serde(skip_serializing_if = "Option::is_none")]
    pub count: Option<i64>,
}

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

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

/// Schema for the `ShutdownModelMetric` type.
#[derive(Debug, Clone, Default, 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
    ///
    /// <div class="warning">
    ///
    /// **Experimental.** This type is part of an experimental wire-protocol surface
    /// and may change or be removed in future SDK or CLI releases.
    ///
    /// </div>
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_nano_aiu: Option<f64>,
    /// Token usage breakdown
    pub usage: ShutdownModelMetricUsage,
}

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

/// Session event "session.shutdown". Session termination metrics including usage statistics, code changes, and shutdown reason
#[derive(Debug, Clone, Default, 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<i64>,
    /// 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<i64>,
    /// 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: i64,
    /// 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<i64>,
    /// 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<i64>,
    /// Cumulative time spent in API calls during the session, in milliseconds
    pub total_api_duration_ms: i64,
    /// Session-wide accumulated nano-AI units cost
    ///
    /// <div class="warning">
    ///
    /// **Experimental.** This type is part of an experimental wire-protocol surface
    /// and may change or be removed in future SDK or CLI releases.
    ///
    /// </div>
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_nano_aiu: Option<f64>,
    /// Total number of premium API requests used during the session
    #[doc(hidden)]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub(crate) total_premium_requests: Option<f64>,
}

/// Session event "session.context_changed". Updated working directory and git context after the change
#[derive(Debug, Clone, Default, 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>,
}

/// Session event "session.usage_info". Current context window usage statistics including token and message counts
#[derive(Debug, Clone, Default, 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<i64>,
    /// Current number of tokens in the context window
    pub current_tokens: i64,
    /// 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: i64,
    /// Token count from system message(s)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub system_tokens: Option<i64>,
    /// Maximum token count for the model's context window
    pub token_limit: i64,
    /// Token count from tool definitions
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_definitions_tokens: Option<i64>,
}

/// Session event "session.compaction_start". Context window breakdown at the start of LLM-powered conversation compaction
#[derive(Debug, Clone, Default, 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<i64>,
    /// Token count from system message(s) at compaction start
    #[serde(skip_serializing_if = "Option::is_none")]
    pub system_tokens: Option<i64>,
    /// Token count from tool definitions at compaction start
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_definitions_tokens: Option<i64>,
}

/// Token usage detail for a single billing category
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CompactionCompleteCompactionTokensUsedCopilotUsageTokenDetail {
    /// Number of tokens in this billing batch
    pub batch_size: i64,
    /// Cost per batch of tokens
    pub cost_per_batch: i64,
    /// Total token count for this entry
    pub token_count: i64,
    /// 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, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) 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, Default, 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<i64>,
    /// Tokens written to prompt cache in the compaction LLM call
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cache_write_tokens: Option<i64>,
    /// Per-request cost and usage data from the CAPI copilot_usage response field
    #[doc(hidden)]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub(crate) copilot_usage: Option<CompactionCompleteCompactionTokensUsedCopilotUsage>,
    /// Duration of the compaction LLM call in milliseconds
    #[serde(skip_serializing_if = "Option::is_none")]
    pub duration: Option<i64>,
    /// Input tokens consumed by the compaction LLM call
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input_tokens: Option<i64>,
    /// 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<i64>,
}

/// Session event "session.compaction_complete". Conversation compaction results including success status, metrics, and optional error details
#[derive(Debug, Clone, Default, 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<i64>,
    /// 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<i64>,
    /// User-supplied focus instructions provided to a manual `/compact` invocation. Omitted for automatic compaction and for manual compaction with no focus text.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub custom_instructions: Option<String>,
    /// 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<i64>,
    /// Total tokens in conversation after compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub post_compaction_tokens: Option<i64>,
    /// Number of messages before compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pre_compaction_messages_length: Option<i64>,
    /// Total tokens in conversation before compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pre_compaction_tokens: Option<i64>,
    /// 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>,
    /// Copilot service request ID (x-copilot-service-request-id header) for the compaction LLM call
    #[serde(skip_serializing_if = "Option::is_none")]
    pub service_request_id: Option<String>,
    /// 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<i64>,
    /// Number of tokens removed during compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tokens_removed: Option<i64>,
    /// Token count from tool definitions after compaction
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_definitions_tokens: Option<i64>,
}

/// Session event "session.task_complete". Task completion notification with summary from the agent
#[derive(Debug, Clone, Default, 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>,
}

/// Session event "user.message".
#[derive(Debug, Clone, Default, 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>,
    /// True when this user message was auto-injected by autopilot's continuation loop rather than typed by the user; used to distinguish autopilot-driven turns in telemetry.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_autopilot_continuation: Option<bool>,
    /// Path-backed native document attachments that stayed on the tagged_files path flow because native upload could not read them or 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>,
}

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

/// Session event "assistant.turn_start". Turn initialization metadata including identifier and interaction tracking
#[derive(Debug, Clone, Default, 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,
}

/// Session event "assistant.intent". Agent intent description for current activity or plan
#[derive(Debug, Clone, Default, 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,
}

/// Session event "assistant.reasoning". Assistant reasoning content for timeline display with complete thinking text
#[derive(Debug, Clone, Default, 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,
}

/// Session event "assistant.reasoning_delta". Streaming reasoning delta for incremental extended thinking updates
#[derive(Debug, Clone, Default, 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,
}

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

/// A tool invocation request from the assistant
#[derive(Debug, Clone, Default, 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>,
    /// 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>,
    /// 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>,
}

/// Session event "assistant.message". Assistant response containing text content, optional tool requests, and interaction metadata
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantMessageData {
    /// Raw Anthropic content array with advisor blocks (server_tool_use, advisor_tool_result) for verbatim round-tripping
    ///
    /// <div class="warning">
    ///
    /// **Experimental.** This type is part of an experimental wire-protocol surface
    /// and may change or be removed in future SDK or CLI releases.
    ///
    /// </div>
    #[serde(default)]
    pub anthropic_advisor_blocks: Vec<serde_json::Value>,
    /// Anthropic advisor model ID used for this response, for timeline display on replay
    ///
    /// <div class="warning">
    ///
    /// **Experimental.** This type is part of an experimental wire-protocol surface
    /// and may change or be removed in future SDK or CLI releases.
    ///
    /// </div>
    #[serde(skip_serializing_if = "Option::is_none")]
    pub anthropic_advisor_model: Option<String>,
    /// 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,
    /// Model that produced this assistant message, if known
    #[serde(skip_serializing_if = "Option::is_none")]
    pub model: Option<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<i64>,
    /// Tool call ID of the parent tool invocation when this event originates from a sub-agent
    #[doc(hidden)]
    #[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>,
    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub service_request_id: Option<String>,
    /// 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>,
}

/// Session event "assistant.message_start". Streaming assistant message start metadata
#[derive(Debug, Clone, Default, 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>,
}

/// Session event "assistant.message_delta". Streaming assistant message delta for incremental response updates
#[derive(Debug, Clone, Default, 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
    #[doc(hidden)]
    #[deprecated]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_tool_call_id: Option<String>,
}

/// Session event "assistant.turn_end". Turn completion metadata including the turn identifier
#[derive(Debug, Clone, Default, 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, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssistantUsageCopilotUsageTokenDetail {
    /// Number of tokens in this billing batch
    pub batch_size: i64,
    /// Cost per batch of tokens
    pub cost_per_batch: i64,
    /// Total token count for this entry
    pub token_count: i64,
    /// 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, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) 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,
}

/// Schema for the `AssistantUsageQuotaSnapshot` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct AssistantUsageQuotaSnapshot {
    /// Total requests allowed by the entitlement
    #[doc(hidden)]
    pub(crate) entitlement_requests: i64,
    /// Whether the user has an unlimited usage entitlement
    #[doc(hidden)]
    pub(crate) is_unlimited_entitlement: bool,
    /// Number of additional usage requests made this period
    #[doc(hidden)]
    pub(crate) overage: f64,
    /// Whether additional usage is allowed when quota is exhausted
    #[doc(hidden)]
    pub(crate) overage_allowed_with_exhausted_quota: bool,
    /// Percentage of quota remaining (0 to 100)
    #[doc(hidden)]
    pub(crate) remaining_percentage: f64,
    /// Date when the quota resets
    #[doc(hidden)]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub(crate) reset_date: Option<String>,
    /// Whether usage is still permitted after quota exhaustion
    #[doc(hidden)]
    pub(crate) usage_allowed_with_exhausted_quota: bool,
    /// Number of requests already consumed
    #[doc(hidden)]
    pub(crate) used_requests: i64,
}

/// Session event "assistant.usage". LLM API call usage metrics including tokens, costs, quotas, and billing information
#[derive(Debug, Clone, Default, 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>,
    /// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
    #[serde(skip_serializing_if = "Option::is_none")]
    pub api_endpoint: Option<AssistantUsageApiEndpoint>,
    /// Number of tokens read from prompt cache
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cache_read_tokens: Option<i64>,
    /// Number of tokens written to prompt cache
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cache_write_tokens: Option<i64>,
    /// Per-request cost and usage data from the CAPI copilot_usage response field
    #[doc(hidden)]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub(crate) copilot_usage: Option<AssistantUsageCopilotUsage>,
    /// Model multiplier cost for billing purposes
    ///
    /// <div class="warning">
    ///
    /// **Experimental.** This type is part of an experimental wire-protocol surface
    /// and may change or be removed in future SDK or CLI releases.
    ///
    /// </div>
    #[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<i64>,
    /// 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<i64>,
    /// 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<i64>,
    /// Parent tool call ID when this usage originates from a sub-agent
    #[doc(hidden)]
    #[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
    #[doc(hidden)]
    #[serde(default)]
    pub(crate) quota_snapshots: HashMap<String, AssistantUsageQuotaSnapshot>,
    /// Reasoning effort level used for model calls, if applicable (e.g. "none", "low", "medium", "high", "xhigh", "max")
    #[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<i64>,
    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub service_request_id: Option<String>,
    /// Time to first token in milliseconds. Only available for streaming requests
    #[serde(skip_serializing_if = "Option::is_none")]
    pub time_to_first_token_ms: Option<i64>,
}

/// Session event "model.call_failure". Failed LLM API call metadata for telemetry
#[derive(Debug, Clone, Default, 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<i64>,
    /// 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>,
    /// Copilot service request ID (x-copilot-service-request-id header) for CAPI log correlation
    #[serde(skip_serializing_if = "Option::is_none")]
    pub service_request_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<i32>,
}

/// Session event "abort". Turn abort information including the reason for termination
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AbortData {
    /// Finite reason code describing why the current turn was aborted
    pub reason: AbortReason,
}

/// Session event "tool.user_requested". User-initiated tool invocation request with tool name and arguments
#[derive(Debug, Clone, Default, 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,
}

/// Session event "tool.execution_start". Tool execution startup details including MCP server information when applicable
#[derive(Debug, Clone, Default, 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
    #[doc(hidden)]
    #[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>,
}

/// Session event "tool.execution_partial_result". Streaming tool execution output for incremental result display
#[derive(Debug, Clone, Default, 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,
}

/// Session event "tool.execution_progress". Tool execution progress notification with status message
#[derive(Debug, Clone, Default, 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, Default, 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,
}

/// Plain text content block
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentText {
    /// The text content
    pub text: String,
    /// Content block type discriminator
    pub r#type: ToolExecutionCompleteContentTextType,
}

/// Terminal/shell output content block with optional exit code and working directory
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentTerminal {
    /// Working directory where the command was executed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cwd: Option<String>,
    /// Process exit code, if the command has completed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub exit_code: Option<i64>,
    /// Terminal/shell output text
    pub text: String,
    /// Content block type discriminator
    pub r#type: ToolExecutionCompleteContentTerminalType,
}

/// Image content block with base64-encoded data
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentImage {
    /// Base64-encoded image data
    pub data: String,
    /// MIME type of the image (e.g., image/png, image/jpeg)
    pub mime_type: String,
    /// Content block type discriminator
    pub r#type: ToolExecutionCompleteContentImageType,
}

/// Audio content block with base64-encoded data
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentAudio {
    /// Base64-encoded audio data
    pub data: String,
    /// MIME type of the audio (e.g., audio/wav, audio/mpeg)
    pub mime_type: String,
    /// Content block type discriminator
    pub r#type: ToolExecutionCompleteContentAudioType,
}

/// Icon image for a resource
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentResourceLinkIcon {
    /// MIME type of the icon image
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    /// Available icon sizes (e.g., ['16x16', '32x32'])
    #[serde(default)]
    pub sizes: Vec<String>,
    /// URL or path to the icon image
    pub src: String,
    /// Theme variant this icon is intended for
    #[serde(skip_serializing_if = "Option::is_none")]
    pub theme: Option<ToolExecutionCompleteContentResourceLinkIconTheme>,
}

/// Resource link content block referencing an external resource
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentResourceLink {
    /// Human-readable description of the resource
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// Icons associated with this resource
    #[serde(default)]
    pub icons: Vec<ToolExecutionCompleteContentResourceLinkIcon>,
    /// MIME type of the resource content
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    /// Resource name identifier
    pub name: String,
    /// Size of the resource in bytes
    #[serde(skip_serializing_if = "Option::is_none")]
    pub size: Option<i64>,
    /// Human-readable display title for the resource
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,
    /// Content block type discriminator
    pub r#type: ToolExecutionCompleteContentResourceLinkType,
    /// URI identifying the resource
    pub uri: String,
}

/// Schema for the `EmbeddedTextResourceContents` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EmbeddedTextResourceContents {
    /// MIME type of the text content
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    /// Text content of the resource
    pub text: String,
    /// URI identifying the resource
    pub uri: String,
}

/// Schema for the `EmbeddedBlobResourceContents` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EmbeddedBlobResourceContents {
    /// Base64-encoded binary content of the resource
    pub blob: String,
    /// MIME type of the blob content
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mime_type: Option<String>,
    /// URI identifying the resource
    pub uri: String,
}

/// Embedded resource content block with inline text or binary data
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteContentResource {
    /// The embedded resource contents, either text or base64-encoded binary
    pub resource: ToolExecutionCompleteContentResourceDetails,
    /// Content block type discriminator
    pub r#type: ToolExecutionCompleteContentResourceType,
}

/// Schema for the `ToolExecutionCompleteUIResourceMetaUICsp` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUICsp {
    #[serde(default)]
    pub base_uri_domains: Vec<String>,
    #[serde(default)]
    pub connect_domains: Vec<String>,
    #[serde(default)]
    pub frame_domains: Vec<String>,
    #[serde(default)]
    pub resource_domains: Vec<String>,
}

/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsCamera` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsCamera {}

/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite {}

/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation {}

/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone {}

/// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissions` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUIPermissions {
    /// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsCamera` type.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub camera: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsCamera>,
    /// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite` type.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub clipboard_write: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsClipboardWrite>,
    /// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation` type.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub geolocation: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsGeolocation>,
    /// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone` type.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub microphone: Option<ToolExecutionCompleteUIResourceMetaUIPermissionsMicrophone>,
}

/// Schema for the `ToolExecutionCompleteUIResourceMetaUI` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMetaUI {
    /// Schema for the `ToolExecutionCompleteUIResourceMetaUICsp` type.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub csp: Option<ToolExecutionCompleteUIResourceMetaUICsp>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub domain: Option<String>,
    /// Schema for the `ToolExecutionCompleteUIResourceMetaUIPermissions` type.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub permissions: Option<ToolExecutionCompleteUIResourceMetaUIPermissions>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub prefers_border: Option<bool>,
}

/// Resource-level UI metadata (CSP, permissions, visual preferences)
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResourceMeta {
    /// Schema for the `ToolExecutionCompleteUIResourceMetaUI` type.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ui: Option<ToolExecutionCompleteUIResourceMetaUI>,
}

/// MCP Apps UI resource content for rendering in a sandboxed iframe
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteUIResource {
    /// Resource-level UI metadata (CSP, permissions, visual preferences)
    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
    pub meta: Option<ToolExecutionCompleteUIResourceMeta>,
    /// Base64-encoded HTML content
    #[serde(skip_serializing_if = "Option::is_none")]
    pub blob: Option<String>,
    /// MIME type of the content
    pub mime_type: String,
    /// HTML content as a string
    #[serde(skip_serializing_if = "Option::is_none")]
    pub text: Option<String>,
    /// The ui:// URI of the resource
    pub uri: String,
}

/// Tool execution result on success
#[derive(Debug, Clone, Default, 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<ToolExecutionCompleteContent>,
    /// 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>,
    /// MCP Apps UI resource content for rendering in a sandboxed iframe
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ui_resource: Option<ToolExecutionCompleteUIResource>,
}

/// Schema for the `ToolExecutionCompleteToolDescriptionMetaUI` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteToolDescriptionMetaUI {
    /// URI of the UI resource
    #[serde(skip_serializing_if = "Option::is_none")]
    pub resource_uri: Option<String>,
    /// Who can access this tool
    #[serde(default)]
    pub visibility: Vec<ToolExecutionCompleteToolDescriptionMetaUIVisibility>,
}

/// MCP Apps metadata for UI resource association
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteToolDescriptionMeta {
    /// Schema for the `ToolExecutionCompleteToolDescriptionMetaUI` type.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ui: Option<ToolExecutionCompleteToolDescriptionMetaUI>,
}

/// Tool definition metadata, present for MCP tools with MCP Apps support
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ToolExecutionCompleteToolDescription {
    /// MCP Apps metadata for UI resource association
    #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
    pub meta: Option<ToolExecutionCompleteToolDescriptionMeta>,
    /// Tool description
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// Tool name
    pub name: String,
}

/// Session event "tool.execution_complete". Tool execution completion results including success status, detailed output, and error information
#[derive(Debug, Clone, Default, 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
    #[doc(hidden)]
    #[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 this tool execution ran inside a sandbox container
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sandboxed: Option<bool>,
    /// Whether the tool execution completed successfully
    pub success: bool,
    /// Unique identifier for the completed tool call
    pub tool_call_id: String,
    /// Tool definition metadata, present for MCP tools with MCP Apps support
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_description: Option<ToolExecutionCompleteToolDescription>,
    /// 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>,
}

/// Session event "skill.invoked". Skill invocation details including content, allowed tools, and plugin metadata
#[derive(Debug, Clone, Default, 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>,
    /// Source identifier for where the skill was discovered. Known values include: project (workspace skill), inherited (parent-directory skill), personal-copilot (~/.copilot/skills), personal-agents (~/.agents/skills), personal-claude (~/.claude/skills), custom (configured directory), plugin (installed plugin), builtin (bundled runtime skill), and remote (org/enterprise skill)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source: Option<String>,
    /// What triggered the skill invocation: `user-invoked` (explicit user action, such as via a slash command or UI affordance), `agent-invoked` (agent requested the skill), or `context-load` (loaded as part of another context, such as preloading skills configured on a custom agent or subagent)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub trigger: Option<SkillInvokedTrigger>,
}

/// Session event "subagent.started". Sub-agent startup details including parent tool call and agent information
#[derive(Debug, Clone, Default, 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,
    /// Model the sub-agent will run with, when known at start. Surfaced in the timeline for auto-selected sub-agents (e.g. rubber-duck).
    #[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,
}

/// Session event "subagent.completed". Sub-agent completion details for successful execution
#[derive(Debug, Clone, Default, 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<i64>,
    /// 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<i64>,
    /// Total number of tool calls made by the sub-agent
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_tool_calls: Option<i64>,
}

/// Session event "subagent.failed". Sub-agent failure details including error message and agent information
#[derive(Debug, Clone, Default, 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<i64>,
    /// 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<i64>,
    /// Total number of tool calls made before the sub-agent failed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub total_tool_calls: Option<i64>,
}

/// Session event "subagent.selected". Custom agent selection details including name and available tools
#[derive(Debug, Clone, Default, 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>,
}

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

/// Session event "hook.start". Hook invocation start details including type and input data
#[derive(Debug, Clone, Default, 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, Default, 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>,
}

/// Session event "hook.end". Hook invocation completion details including output, success status, and error information
#[derive(Debug, Clone, Default, 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, Default, 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>,
}

/// Session event "system.message". System/developer instruction content with role and optional template metadata
#[derive(Debug, Clone, Default, 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,
}

/// Session event "system.notification". System-generated notification for runtime events like background task completion
#[derive(Debug, Clone, Default, 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,
}

/// Schema for the `PermissionRequestShellCommand` type.
#[derive(Debug, Clone, Default, 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,
}

/// Schema for the `PermissionRequestShellPossibleUrl` type.
#[derive(Debug, Clone, Default, 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, Default, 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, Default, 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, Default, 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, Default, 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, Default, 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, Default, 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, Default, 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, Default, 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,
}

/// Extension management permission request
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestExtensionManagement {
    /// Name of the extension being managed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub extension_name: Option<String>,
    /// Permission kind discriminator
    pub kind: PermissionRequestExtensionManagementKind,
    /// The extension management operation (scaffold, reload)
    pub operation: String,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// Extension permission access request
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRequestExtensionPermissionAccess {
    /// Capabilities the extension is requesting
    pub capabilities: Vec<String>,
    /// Name of the extension requesting permission access
    pub extension_name: String,
    /// Permission kind discriminator
    pub kind: PermissionRequestExtensionPermissionAccessKind,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// Shell command permission prompt
#[derive(Debug, Clone, Default, 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, Default, 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, Default, 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, Default, 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, Default, 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, Default, 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<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,
    /// 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, Default, 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, Default, 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, Default, 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,
}

/// Extension management permission prompt
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionPromptRequestExtensionManagement {
    /// Name of the extension being managed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub extension_name: Option<String>,
    /// Prompt kind discriminator
    pub kind: PermissionPromptRequestExtensionManagementKind,
    /// The extension management operation (scaffold, reload)
    pub operation: String,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// Extension permission access prompt
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionPromptRequestExtensionPermissionAccess {
    /// Capabilities the extension is requesting
    pub capabilities: Vec<String>,
    /// Name of the extension requesting permission access
    pub extension_name: String,
    /// Prompt kind discriminator
    pub kind: PermissionPromptRequestExtensionPermissionAccessKind,
    /// Tool call ID that triggered this permission request
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_call_id: Option<String>,
}

/// Session event "permission.requested". 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>,
}

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

/// Schema for the `UserToolSessionApprovalCommands` type.
#[derive(Debug, Clone, Default, 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,
}

/// Schema for the `UserToolSessionApprovalRead` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserToolSessionApprovalRead {
    /// Read approval kind
    pub kind: UserToolSessionApprovalReadKind,
}

/// Schema for the `UserToolSessionApprovalWrite` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserToolSessionApprovalWrite {
    /// Write approval kind
    pub kind: UserToolSessionApprovalWriteKind,
}

/// Schema for the `UserToolSessionApprovalMcp` type.
#[derive(Debug, Clone, Default, 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>,
}

/// Schema for the `UserToolSessionApprovalMemory` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserToolSessionApprovalMemory {
    /// Memory approval kind
    pub kind: UserToolSessionApprovalMemoryKind,
}

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

/// Schema for the `UserToolSessionApprovalExtensionManagement` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserToolSessionApprovalExtensionManagement {
    /// Extension management approval kind
    pub kind: UserToolSessionApprovalExtensionManagementKind,
    /// Optional operation identifier
    #[serde(skip_serializing_if = "Option::is_none")]
    pub operation: Option<String>,
}

/// Schema for the `UserToolSessionApprovalExtensionPermissionAccess` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserToolSessionApprovalExtensionPermissionAccess {
    /// Extension name
    pub extension_name: String,
    /// Extension permission access approval kind
    pub kind: UserToolSessionApprovalExtensionPermissionAccessKind,
}

/// Schema for the `PermissionApprovedForSession` type.
#[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,
}

/// Schema for the `PermissionApprovedForLocation` type.
#[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,
}

/// Schema for the `PermissionCancelled` type.
#[derive(Debug, Clone, Default, 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>,
}

/// Schema for the `PermissionRule` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PermissionRule {
    /// Argument value matched against the request, or null when the rule kind has no argument (e.g. 'read', 'write', 'memory').
    pub argument: Option<String>,
    /// The rule kind, such as Shell or GitHubMCP
    pub kind: String,
}

/// Schema for the `PermissionDeniedByRules` type.
#[derive(Debug, Clone, Default, 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>,
}

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

/// Schema for the `PermissionDeniedInteractivelyByUser` type.
#[derive(Debug, Clone, Default, 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,
}

/// Schema for the `PermissionDeniedByContentExclusionPolicy` type.
#[derive(Debug, Clone, Default, 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,
}

/// Schema for the `PermissionDeniedByPermissionRequestHook` type.
#[derive(Debug, Clone, Default, 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>,
}

/// Session event "permission.completed". 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>,
}

/// Session event "user_input.requested". User input request notification with question and optional predefined choices
#[derive(Debug, Clone, Default, 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>,
}

/// Session event "user_input.completed". User input request completion with the user's response
#[derive(Debug, Clone, Default, 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, Default, 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,
}

/// Session event "elicitation.requested". Elicitation request; may be form-based (structured input) or URL-based (browser redirect)
#[derive(Debug, Clone, Default, 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>,
}

/// Session event "elicitation.completed". Elicitation request completion with the user's response
#[derive(Debug, Clone, Default, 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,
}

/// Session event "sampling.requested". Sampling request from an MCP server; contains the server name and a requestId for correlation
#[derive(Debug, Clone, Default, 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,
}

/// Session event "sampling.completed". Sampling request completion notification signaling UI dismissal
#[derive(Debug, Clone, Default, 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, Default, 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>,
}

/// Session event "mcp.oauth_required". OAuth authentication request for an MCP server
#[derive(Debug, Clone, Default, 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>,
}

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

/// Session event "session.custom_notification". Opaque custom notification data. Consumers may branch on source and name, but payload semantics are source-defined.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionCustomNotificationData {
    /// Source-defined custom notification name
    pub name: String,
    /// Source-defined JSON payload for the custom notification
    pub payload: serde_json::Value,
    /// Namespace for the custom notification producer
    pub source: String,
    /// Optional source-defined string identifiers describing the payload subject
    #[serde(default)]
    pub subject: HashMap<String, String>,
    /// Optional source-defined payload schema version
    #[serde(skip_serializing_if = "Option::is_none")]
    pub version: Option<i64>,
}

/// Session event "external_tool.requested". External tool invocation request for client-side tool execution
#[derive(Debug, Clone, Default, 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>,
}

/// Session event "external_tool.completed". External tool completion notification signaling UI dismissal
#[derive(Debug, Clone, Default, 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,
}

/// Session event "command.queued". Queued slash command dispatch request for client execution
#[derive(Debug, Clone, Default, 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,
}

/// Session event "command.execute". Registered command dispatch request routed to the owning client
#[derive(Debug, Clone, Default, 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,
}

/// Session event "command.completed". Queued command completion notification signaling UI dismissal
#[derive(Debug, Clone, Default, 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,
}

/// Session event "auto_mode_switch.requested". Auto mode switch request notification requiring user approval
#[derive(Debug, Clone, Default, 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<i64>,
}

/// Session event "auto_mode_switch.completed". Auto mode switch completion notification
#[derive(Debug, Clone, Default, 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 auto-mode-switch choice
    pub response: AutoModeSwitchResponse,
}

/// Schema for the `CommandsChangedCommand` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CommandsChangedCommand {
    /// Optional human-readable command description.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// Slash command name without the leading slash.
    pub name: String,
}

/// Session event "commands.changed". SDK command registration change notification
#[derive(Debug, Clone, Default, 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, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CapabilitiesChangedUI {
    /// Whether canvas rendering is now supported
    #[serde(skip_serializing_if = "Option::is_none")]
    pub canvases: Option<bool>,
    /// Whether elicitation is now supported
    #[serde(skip_serializing_if = "Option::is_none")]
    pub elicitation: Option<bool>,
    /// Whether MCP Apps (SEP-1865) UI passthrough is now supported
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mcp_apps: Option<bool>,
}

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

/// Session event "exit_plan_mode.requested". Plan approval request with plan content and available user actions
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ExitPlanModeRequestedData {
    /// Available actions the user can take
    pub actions: Vec<ExitPlanModeAction>,
    /// Full content of the plan file
    pub plan_content: String,
    /// Recommended action to preselect for the user
    pub recommended_action: ExitPlanModeAction,
    /// 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,
}

/// Session event "exit_plan_mode.completed". Plan mode exit completion with the user's approval decision and optional feedback
#[derive(Debug, Clone, Default, 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,
    /// Action selected by the user
    #[serde(skip_serializing_if = "Option::is_none")]
    pub selected_action: Option<ExitPlanModeAction>,
}

/// Session event "session.tools_updated".
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionToolsUpdatedData {
    /// Identifier of the model the resolved tools apply to.
    pub model: String,
}

/// Session event "session.background_tasks_changed".
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionBackgroundTasksChangedData {}

/// Schema for the `SkillsLoadedSkill` type.
#[derive(Debug, Clone, Default, 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 (e.g., project, personal-copilot, plugin, builtin)
    pub source: SkillSource,
    /// Whether the skill can be invoked by the user as a slash command
    pub user_invocable: bool,
}

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

/// Schema for the `CustomAgentsUpdatedAgent` type.
#[derive(Debug, Clone, Default, 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,
}

/// Session event "session.custom_agents_updated".
#[derive(Debug, Clone, Default, 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>,
}

/// Schema for the `McpServersLoadedServer` type.
#[derive(Debug, Clone, Default, 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,
    /// Name of the plugin that supplied the effective MCP server config, only when source is plugin
    #[serde(skip_serializing_if = "Option::is_none")]
    pub plugin_name: Option<String>,
    /// Version of the plugin that supplied the effective MCP server config, only when source is plugin
    #[serde(skip_serializing_if = "Option::is_none")]
    pub plugin_version: Option<String>,
    /// Configuration source: user, workspace, plugin, or builtin
    #[serde(skip_serializing_if = "Option::is_none")]
    pub source: Option<McpServerSource>,
    /// Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
    pub status: McpServerStatus,
    /// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transport: Option<McpServerTransport>,
}

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

/// Session event "session.mcp_server_status_changed".
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionMcpServerStatusChangedData {
    /// Error message if the server entered a failed state
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<String>,
    /// Name of the MCP server whose status changed
    pub server_name: String,
    /// Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
    pub status: McpServerStatus,
}

/// Schema for the `ExtensionsLoadedExtension` type.
#[derive(Debug, Clone, Default, 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,
}

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

/// Session event "session.canvas.opened".
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionCanvasOpenedData {
    /// Runtime-controlled routing state for the instance. "ready" when the provider connection is live; "stale" when the provider has gone away and the instance is awaiting rebinding.
    pub availability: CanvasOpenedAvailability,
    /// Provider-local canvas identifier
    pub canvas_id: String,
    /// Owning provider identifier
    pub extension_id: String,
    /// Owning extension display name, when available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub extension_name: Option<String>,
    /// Input supplied when the instance was opened
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input: Option<serde_json::Value>,
    /// Stable caller-supplied canvas instance identifier
    pub instance_id: String,
    /// Whether this notification represents an idempotent reopen
    pub reopen: bool,
    /// Provider-supplied status text
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,
    /// Rendered title
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<String>,
    /// URL for web-rendered canvases
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<String>,
}

/// Schema for the `CanvasRegistryChangedCanvasAction` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CanvasRegistryChangedCanvasAction {
    /// Action description
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
    /// JSON Schema for action input
    #[serde(default)]
    pub input_schema: HashMap<String, serde_json::Value>,
    /// Action name
    pub name: String,
}

/// Schema for the `CanvasRegistryChangedCanvas` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CanvasRegistryChangedCanvas {
    /// Actions the agent or host may invoke
    #[serde(default)]
    pub actions: Vec<CanvasRegistryChangedCanvasAction>,
    /// Provider-local canvas identifier
    pub canvas_id: String,
    /// Short, single-sentence description shown to the agent in canvas catalogs.
    pub description: String,
    /// Human-readable canvas name
    pub display_name: String,
    /// Owning provider identifier
    pub extension_id: String,
    /// Owning extension display name, when available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub extension_name: Option<String>,
    /// JSON Schema for canvas open input
    #[serde(default)]
    pub input_schema: HashMap<String, serde_json::Value>,
}

/// Session event "session.canvas.registry_changed".
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionCanvasRegistryChangedData {
    /// Canvas declarations currently available
    pub canvases: Vec<CanvasRegistryChangedCanvas>,
}

/// Set when the underlying tools/call threw an error before returning a CallToolResult
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct McpAppToolCallCompleteError {
    /// Human-readable error message
    pub message: String,
}

/// Schema for the `McpAppToolCallCompleteToolMetaUI` type.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct McpAppToolCallCompleteToolMetaUI {
    /// `ui://` URI declared by the tool's `_meta.ui.resourceUri`
    #[serde(skip_serializing_if = "Option::is_none")]
    pub resource_uri: Option<String>,
    /// Tool visibility per SEP-1865 (typically a subset of `["model","app"]`)
    #[serde(default)]
    pub visibility: Vec<String>,
}

/// The tool's `_meta.ui` block at the time of the call, so consumers can decide whether to forward the result to the model without re-listing tools.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct McpAppToolCallCompleteToolMeta {
    /// Schema for the `McpAppToolCallCompleteToolMetaUI` type.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ui: Option<McpAppToolCallCompleteToolMetaUI>,
}

/// Session event "mcp_app.tool_call_complete". MCP App view called a tool on a connected MCP server (SEP-1865)
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct McpAppToolCallCompleteData {
    /// Arguments passed to the tool by the app view, if any
    #[serde(default)]
    pub arguments: HashMap<String, serde_json::Value>,
    /// Wall-clock duration of the underlying tools/call in milliseconds
    pub duration_ms: f64,
    /// Set when the underlying tools/call threw an error before returning a CallToolResult
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<McpAppToolCallCompleteError>,
    /// Standard MCP CallToolResult returned by the server. Present whether or not the call set isError.
    #[serde(default)]
    pub result: HashMap<String, serde_json::Value>,
    /// Name of the MCP server hosting the tool
    pub server_name: String,
    /// True when the call completed without throwing AND the MCP CallToolResult did not set isError
    pub success: bool,
    /// The tool's `_meta.ui` block at the time of the call, so consumers can decide whether to forward the result to the model without re-listing tools.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tool_meta: Option<McpAppToolCallCompleteToolMeta>,
    /// MCP tool name that was invoked
    pub tool_name: String,
}

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

/// Reasoning summary mode used for model calls, if applicable (e.g. "none", "concise", "detailed")
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ReasoningSummary {
    /// Do not request reasoning summaries from the model.
    #[serde(rename = "none")]
    None,
    /// Request a concise summary of the model's reasoning.
    #[serde(rename = "concise")]
    Concise,
    /// Request a detailed summary of the model's reasoning.
    #[serde(rename = "detailed")]
    Detailed,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum SessionModelChangeDataContextTier {
    /// Default context tier with standard context window size.
    #[serde(rename = "default")]
    Default,
    /// Extended context tier with a larger context window.
    #[serde(rename = "long_context")]
    LongContext,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// The session mode the agent is operating in
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum SessionMode {
    /// The agent is responding interactively to the user.
    #[serde(rename = "interactive")]
    Interactive,
    /// The agent is preparing a plan before making changes.
    #[serde(rename = "plan")]
    Plan,
    /// The agent is working autonomously toward task completion.
    #[serde(rename = "autopilot")]
    Autopilot,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

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

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

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

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

/// The agent mode that was active when this message was sent
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserMessageAgentMode {
    /// The agent is responding interactively to the user.
    #[serde(rename = "interactive")]
    Interactive,
    /// The agent is preparing a plan before making changes.
    #[serde(rename = "plan")]
    Plan,
    /// The agent is working autonomously toward task completion.
    #[serde(rename = "autopilot")]
    Autopilot,
    /// The agent is in shell-focused UI mode.
    #[serde(rename = "shell")]
    Shell,
    /// Unknown variant for forward compatibility.
    #[default]
    #[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, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum AssistantMessageToolRequestType {
    /// Standard function-style tool call.
    #[serde(rename = "function")]
    Function,
    /// Custom grammar-based tool call.
    #[serde(rename = "custom")]
    Custom,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// API endpoint used for this model call, matching CAPI supported_endpoints vocabulary
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum AssistantUsageApiEndpoint {
    /// Chat Completions API endpoint.
    #[serde(rename = "/chat/completions")]
    ChatCompletions,
    /// Anthropic Messages API endpoint.
    #[serde(rename = "/v1/messages")]
    V1Messages,
    /// Responses API endpoint.
    #[serde(rename = "/responses")]
    Responses,
    /// WebSocket Responses API endpoint.
    #[serde(rename = "ws:/responses")]
    WsResponses,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Where the failed model call originated
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ModelCallFailureSource {
    /// Model call from the top-level agent.
    #[serde(rename = "top_level")]
    TopLevel,
    /// Model call from a sub-agent.
    #[serde(rename = "subagent")]
    Subagent,
    /// Model call from MCP sampling.
    #[serde(rename = "mcp_sampling")]
    McpSampling,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Finite reason code describing why the current turn was aborted
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum AbortReason {
    /// The local user requested the abort, for example by pressing Ctrl+C in the CLI.
    #[serde(rename = "user_initiated")]
    UserInitiated,
    /// A remote command requested the abort.
    #[serde(rename = "remote_command")]
    RemoteCommand,
    /// An MCP server delivered a user.abort notification.
    #[serde(rename = "user_abort")]
    UserAbort,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Content block type discriminator
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ToolExecutionCompleteContentTextType {
    #[serde(rename = "text")]
    #[default]
    Text,
}

/// Content block type discriminator
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ToolExecutionCompleteContentTerminalType {
    #[serde(rename = "terminal")]
    #[default]
    Terminal,
}

/// Content block type discriminator
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ToolExecutionCompleteContentImageType {
    #[serde(rename = "image")]
    #[default]
    Image,
}

/// Content block type discriminator
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ToolExecutionCompleteContentAudioType {
    #[serde(rename = "audio")]
    #[default]
    Audio,
}

/// Theme variant this icon is intended for
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ToolExecutionCompleteContentResourceLinkIconTheme {
    /// Icon intended for light themes.
    #[serde(rename = "light")]
    Light,
    /// Icon intended for dark themes.
    #[serde(rename = "dark")]
    Dark,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Content block type discriminator
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ToolExecutionCompleteContentResourceLinkType {
    #[serde(rename = "resource_link")]
    #[default]
    ResourceLink,
}

/// The embedded resource contents, either text or base64-encoded binary
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ToolExecutionCompleteContentResourceDetails {
    EmbeddedTextResourceContents(EmbeddedTextResourceContents),
    EmbeddedBlobResourceContents(EmbeddedBlobResourceContents),
}

/// Content block type discriminator
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ToolExecutionCompleteContentResourceType {
    #[serde(rename = "resource")]
    #[default]
    Resource,
}

/// A content block within a tool result, which may be text, terminal output, image, audio, or a resource
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ToolExecutionCompleteContent {
    Text(ToolExecutionCompleteContentText),
    Terminal(ToolExecutionCompleteContentTerminal),
    Image(ToolExecutionCompleteContentImage),
    Audio(ToolExecutionCompleteContentAudio),
    ResourceLink(ToolExecutionCompleteContentResourceLink),
    Resource(ToolExecutionCompleteContentResource),
}

/// Allowed values for the `ToolExecutionCompleteToolDescriptionMetaUIVisibility` enumeration.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ToolExecutionCompleteToolDescriptionMetaUIVisibility {
    /// Tool is callable by the model (LLM tool surface)
    #[serde(rename = "model")]
    Model,
    /// Tool is callable by the MCP App view (iframe) via session.mcp.apps.callTool
    #[serde(rename = "app")]
    App,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// What triggered the skill invocation: `user-invoked` (explicit user action, such as via a slash command or UI affordance), `agent-invoked` (agent requested the skill), or `context-load` (loaded as part of another context, such as preloading skills configured on a custom agent or subagent)
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum SkillInvokedTrigger {
    /// Skill invocation requested explicitly by the user, such as via a slash command or UI affordance.
    #[serde(rename = "user-invoked")]
    UserInvoked,
    /// Skill invocation requested by the agent.
    #[serde(rename = "agent-invoked")]
    AgentInvoked,
    /// Skill content loaded as part of another context, such as a configured custom agent or subagent.
    #[serde(rename = "context-load")]
    ContextLoad,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

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

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

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

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

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

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

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

/// Vote direction (vote only)
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestMemoryDirection {
    /// Vote that the memory is useful or accurate.
    #[serde(rename = "upvote")]
    Upvote,
    /// Vote that the memory is incorrect or outdated.
    #[serde(rename = "downvote")]
    Downvote,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

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

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

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

/// Permission kind discriminator
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestExtensionManagementKind {
    #[serde(rename = "extension-management")]
    #[default]
    ExtensionManagement,
}

/// Permission kind discriminator
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionRequestExtensionPermissionAccessKind {
    #[serde(rename = "extension-permission-access")]
    #[default]
    ExtensionPermissionAccess,
}

/// 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),
    ExtensionManagement(PermissionRequestExtensionManagement),
    ExtensionPermissionAccess(PermissionRequestExtensionPermissionAccess),
}

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

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

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

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

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

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

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

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

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

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

/// Prompt kind discriminator
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestExtensionManagementKind {
    #[serde(rename = "extension-management")]
    #[default]
    ExtensionManagement,
}

/// Prompt kind discriminator
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionPromptRequestExtensionPermissionAccessKind {
    #[serde(rename = "extension-permission-access")]
    #[default]
    ExtensionPermissionAccess,
}

/// 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),
    ExtensionManagement(PermissionPromptRequestExtensionManagement),
    ExtensionPermissionAccess(PermissionPromptRequestExtensionPermissionAccess),
}

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

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

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

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

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

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

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

/// Extension management approval kind
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserToolSessionApprovalExtensionManagementKind {
    #[serde(rename = "extension-management")]
    #[default]
    ExtensionManagement,
}

/// Extension permission access approval kind
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserToolSessionApprovalExtensionPermissionAccessKind {
    #[serde(rename = "extension-permission-access")]
    #[default]
    ExtensionPermissionAccess,
}

/// 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),
    ExtensionManagement(UserToolSessionApprovalExtensionManagement),
    ExtensionPermissionAccess(UserToolSessionApprovalExtensionPermissionAccess),
}

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

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

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

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

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

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

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

/// Denied by a permission request hook registered by an extension or plugin
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionDeniedByPermissionRequestHookKind {
    #[serde(rename = "denied-by-permission-request-hook")]
    #[default]
    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, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ElicitationRequestedMode {
    /// Structured form-based elicitation.
    #[serde(rename = "form")]
    Form,
    /// Browser URL-based elicitation.
    #[serde(rename = "url")]
    Url,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

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

/// The user action: "accept" (submitted form), "decline" (explicitly refused), or "cancel" (dismissed)
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ElicitationCompletedAction {
    /// The user submitted the requested form.
    #[serde(rename = "accept")]
    Accept,
    /// The user explicitly declined the request.
    #[serde(rename = "decline")]
    Decline,
    /// The user dismissed the request.
    #[serde(rename = "cancel")]
    Cancel,
    /// Unknown variant for forward compatibility.
    #[default]
    #[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, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum McpOauthRequiredStaticClientConfigGrantType {
    #[serde(rename = "client_credentials")]
    #[default]
    ClientCredentials,
}

/// The user's auto-mode-switch choice
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum AutoModeSwitchResponse {
    /// Switch models for this request.
    #[serde(rename = "yes")]
    Yes,
    /// Switch models now and keep using the replacement automatically.
    #[serde(rename = "yes_always")]
    YesAlways,
    /// Do not switch models.
    #[serde(rename = "no")]
    No,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Exit plan mode action
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ExitPlanModeAction {
    /// Exit plan mode without starting implementation.
    #[serde(rename = "exit_only")]
    ExitOnly,
    /// Exit plan mode and continue in interactive mode.
    #[serde(rename = "interactive")]
    Interactive,
    /// Exit plan mode and continue autonomously.
    #[serde(rename = "autopilot")]
    Autopilot,
    /// Exit plan mode and continue with parallel autonomous workers.
    #[serde(rename = "autopilot_fleet")]
    AutopilotFleet,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Source location type (e.g., project, personal-copilot, plugin, builtin)
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum SkillSource {
    /// Skill defined in the current project's skill directories.
    #[serde(rename = "project")]
    Project,
    /// Skill discovered from a parent directory in the current workspace tree.
    #[serde(rename = "inherited")]
    Inherited,
    /// Skill defined in the user's Copilot skill directory.
    #[serde(rename = "personal-copilot")]
    PersonalCopilot,
    /// Skill defined in the user's personal agents skill directory.
    #[serde(rename = "personal-agents")]
    PersonalAgents,
    /// Skill provided by an installed plugin.
    #[serde(rename = "plugin")]
    Plugin,
    /// Skill loaded from a configured custom skill directory.
    #[serde(rename = "custom")]
    Custom,
    /// Skill bundled with the runtime.
    #[serde(rename = "builtin")]
    Builtin,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Configuration source: user, workspace, plugin, or builtin
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum McpServerSource {
    /// Server configured in the user's global MCP configuration.
    #[serde(rename = "user")]
    User,
    /// Server configured by the current workspace.
    #[serde(rename = "workspace")]
    Workspace,
    /// Server contributed by an installed plugin.
    #[serde(rename = "plugin")]
    Plugin,
    /// Server bundled with the runtime.
    #[serde(rename = "builtin")]
    Builtin,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Connection status: connected, failed, needs-auth, pending, disabled, or not_configured
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum McpServerStatus {
    /// The server is connected and available.
    #[serde(rename = "connected")]
    Connected,
    /// The server failed to connect or initialize.
    #[serde(rename = "failed")]
    Failed,
    /// The server requires authentication before it can connect.
    #[serde(rename = "needs-auth")]
    NeedsAuth,
    /// The server connection is still being established.
    #[serde(rename = "pending")]
    Pending,
    /// The server is configured but disabled.
    #[serde(rename = "disabled")]
    Disabled,
    /// The server is not configured for this session.
    #[serde(rename = "not_configured")]
    NotConfigured,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Transport mechanism: stdio, http, sse (deprecated), or memory (in-process MCP server)
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum McpServerTransport {
    /// Server communicates over stdio with a local child process.
    #[serde(rename = "stdio")]
    Stdio,
    /// Server communicates over streamable HTTP.
    #[serde(rename = "http")]
    Http,
    /// Server communicates over Server-Sent Events (deprecated).
    #[serde(rename = "sse")]
    Sse,
    /// Server is backed by an in-memory runtime implementation.
    #[serde(rename = "memory")]
    Memory,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Discovery source
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ExtensionsLoadedExtensionSource {
    /// Extension discovered from the current project.
    #[serde(rename = "project")]
    Project,
    /// Extension discovered from the user's extension directory.
    #[serde(rename = "user")]
    User,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Current status: running, disabled, failed, or starting
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ExtensionsLoadedExtensionStatus {
    /// The extension process is running.
    #[serde(rename = "running")]
    Running,
    /// The extension is installed but disabled.
    #[serde(rename = "disabled")]
    Disabled,
    /// The extension failed to start or crashed.
    #[serde(rename = "failed")]
    Failed,
    /// The extension process is starting.
    #[serde(rename = "starting")]
    Starting,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}

/// Runtime-controlled routing state for the instance. "ready" when the provider connection is live; "stale" when the provider has gone away and the instance is awaiting rebinding.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum CanvasOpenedAvailability {
    /// Provider connection is live; actions can be invoked.
    #[serde(rename = "ready")]
    Ready,
    /// Provider has gone away; the instance is awaiting rebinding.
    #[serde(rename = "stale")]
    Stale,
    /// Unknown variant for forward compatibility.
    #[default]
    #[serde(other)]
    Unknown,
}