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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

// --------------------------------------------------------------------------
// IMPORTANT: After adding or updating settings, run `npm run docs:settings`
// to regenerate the settings reference in `docs/get-started/configuration.md`.
// --------------------------------------------------------------------------

import {
  DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
  DEFAULT_MODEL_CONFIGS,
  EDITOR_OPTIONS,
  AuthProviderType,
  type MCPServerConfig,
  type RequiredMcpServerConfig,
  type BugCommandSettings,
  type TelemetrySettings,
  type AuthType,
  type AgentOverride,
  type CustomTheme,
  type SandboxConfig,
  type VertexAiRoutingConfig,
} from '@google/gemini-cli-core';
import type { SessionRetentionSettings } from './settings.js';
import { DEFAULT_MIN_RETENTION } from '../utils/sessionCleanup.js';

export type SettingsType =
  | 'boolean'
  | 'string'
  | 'number'
  | 'array'
  | 'object'
  | 'enum';

export type SettingsValue =
  | boolean
  | string
  | number
  | string[]
  | object
  | undefined;

/**
 * Setting datatypes that "toggle" through a fixed list of options
 * (e.g. an enum or true/false) rather than allowing for free form input
 * (like a number or string).
 */
export const TOGGLE_TYPES: ReadonlySet<SettingsType | undefined> = new Set([
  'boolean',
  'enum',
]);

export interface SettingEnumOption {
  value: string | number;
  label: string;
}

function oneLine(strings: TemplateStringsArray, ...values: unknown[]): string {
  let result = '';
  for (let i = 0; i < strings.length; i++) {
    result += strings[i];
    if (i < values.length) {
      result += String(values[i]);
    }
  }
  return result.replace(/\s+/g, ' ').trim();
}

export interface SettingCollectionDefinition {
  type: SettingsType;
  description?: string;
  properties?: SettingsSchema;
  /** Enum type options  */
  options?: readonly SettingEnumOption[];
  /**
   * Optional reference identifier for generators that emit a `$ref`.
   * For example, a JSON schema generator can use this to point to a shared definition.
   */
  ref?: string;
  /**
   * Optional merge strategy for dynamically added properties.
   * Used when this collection definition is referenced via additionalProperties.
   */
  mergeStrategy?: MergeStrategy;
}

export enum MergeStrategy {
  // Replace the old value with the new value. This is the default.
  REPLACE = 'replace',
  // Concatenate arrays.
  CONCAT = 'concat',
  // Merge arrays, ensuring unique values.
  UNION = 'union',
  // Shallow merge objects.
  SHALLOW_MERGE = 'shallow_merge',
}

export interface SettingDefinition {
  type: SettingsType;
  label: string;
  category: string;
  requiresRestart: boolean;
  default: SettingsValue;
  description?: string;
  parentKey?: string;
  childKey?: string;
  key?: string;
  properties?: SettingsSchema;
  showInDialog?: boolean;
  ignoreInDocs?: boolean;
  mergeStrategy?: MergeStrategy;
  /** Enum type options  */
  options?: readonly SettingEnumOption[];
  /**
   * For collection types (e.g. arrays), describes the shape of each item.
   */
  items?: SettingCollectionDefinition;
  /**
   * For map-like objects without explicit `properties`, describes the shape of the values.
   */
  additionalProperties?: SettingCollectionDefinition;
  /**
   * Optional unit to display after the value (e.g. '%').
   */
  unit?: string;
  /**
   * Optional reference identifier for generators that emit a `$ref`.
   */
  ref?: string;
}

export interface SettingsSchema {
  [key: string]: SettingDefinition;
}

export type MemoryImportFormat = 'tree' | 'flat';
export type DnsResolutionOrder = 'ipv4first' | 'verbatim';

const pathArraySetting = (label: string, description: string) => ({
  type: 'array' as const,
  label,
  category: 'Advanced' as const,
  requiresRestart: true as const,
  default: [] as string[],
  description,
  showInDialog: false as const,
  items: { type: 'string' as const },
  mergeStrategy: MergeStrategy.UNION,
});

/**
 * The canonical schema for all settings.
 * The structure of this object defines the structure of the `Settings` type.
 * `as const` is crucial for TypeScript to infer the most specific types possible.
 */
const SETTINGS_SCHEMA = {
  // Maintained for compatibility/criticality
  mcpServers: {
    type: 'object',
    label: 'MCP Servers',
    category: 'Advanced',
    requiresRestart: true,
    default: {} as Record<string, MCPServerConfig>,
    description: 'Configuration for MCP servers.',
    showInDialog: false,
    mergeStrategy: MergeStrategy.SHALLOW_MERGE,
    additionalProperties: {
      type: 'object',
      ref: 'MCPServerConfig',
    },
  },

  policyPaths: pathArraySetting(
    'Policy Paths',
    'Additional policy files or directories to load.',
  ),

  adminPolicyPaths: pathArraySetting(
    'Admin Policy Paths',
    'Additional admin policy files or directories to load.',
  ),

  general: {
    type: 'object',
    label: 'General',
    category: 'General',
    requiresRestart: false,
    default: {},
    description: 'General application settings.',
    showInDialog: false,
    properties: {
      preferredEditor: {
        type: 'enum',
        label: 'Preferred Editor',
        category: 'General',
        requiresRestart: false,
        default: undefined as string | undefined,
        description: oneLine`
          The preferred editor to open files in. Must be one of the built-in
          supported identifiers. Use /editor in the CLI to pick interactively,
          or leave unset to use $VISUAL/$EDITOR.
        `,
        showInDialog: false,
        options: EDITOR_OPTIONS,
      },
      openEditorInNewWindow: {
        type: 'boolean',
        label: 'Open Editor in New Window',
        category: 'General',
        requiresRestart: false,
        default: false,
        description:
          'Open VS Code-family editors in a new window when editing files.',
        showInDialog: false,
      },
      vimMode: {
        type: 'boolean',
        label: 'Vim Mode',
        category: 'General',
        requiresRestart: false,
        default: false,
        description: 'Enable Vim keybindings',
        showInDialog: true,
      },
      defaultApprovalMode: {
        type: 'enum',
        label: 'Default Approval Mode',
        category: 'General',
        requiresRestart: false,
        default: 'default',
        description: oneLine`
          The default approval mode for tool execution.
          'default' prompts for approval, 'auto_edit' auto-approves edit tools,
          and 'plan' is read-only mode. YOLO mode (auto-approve all actions) can
          only be enabled via command line (--yolo or --approval-mode=yolo).
        `,
        showInDialog: true,
        options: [
          { value: 'default', label: 'Default' },
          { value: 'auto_edit', label: 'Auto Edit' },
          { value: 'plan', label: 'Plan' },
        ],
      },
      devtools: {
        type: 'boolean',
        label: 'DevTools',
        category: 'General',
        requiresRestart: false,
        default: false,
        description: 'Enable DevTools inspector on launch.',
        showInDialog: false,
      },
      enableAutoUpdate: {
        type: 'boolean',
        label: 'Enable Auto Update',
        category: 'General',
        requiresRestart: false,
        default: true,
        description: 'Enable automatic updates.',
        showInDialog: true,
      },
      enableAutoUpdateNotification: {
        type: 'boolean',
        label: 'Enable Auto Update Notification',
        category: 'General',
        requiresRestart: false,
        default: true,
        description: 'Enable update notification prompts.',
        showInDialog: false,
      },
      enableNotifications: {
        type: 'boolean',
        label: 'Enable Terminal Notifications',
        category: 'General',
        requiresRestart: false,
        default: false,
        description:
          'Enable terminal run-event notifications for action-required prompts and session completion.',
        showInDialog: true,
      },
      notificationMethod: {
        type: 'enum',
        label: 'Terminal Notification Method',
        category: 'General',
        requiresRestart: false,
        default: 'auto',
        description: 'How to send terminal notifications.',
        showInDialog: true,
        options: [
          { value: 'auto', label: 'Auto' },
          { value: 'osc9', label: 'OSC 9' },
          { value: 'osc777', label: 'OSC 777' },
          { value: 'bell', label: 'Bell' },
        ],
      },
      checkpointing: {
        type: 'object',
        label: 'Checkpointing',
        category: 'General',
        requiresRestart: true,
        default: {},
        description: 'Session checkpointing settings.',
        showInDialog: false,
        properties: {
          enabled: {
            type: 'boolean',
            label: 'Enable Checkpointing',
            category: 'General',
            requiresRestart: true,
            default: false,
            description: 'Enable session checkpointing for recovery',
            showInDialog: false,
          },
        },
      },
      plan: {
        type: 'object',
        label: 'Plan',
        category: 'General',
        requiresRestart: true,
        default: {},
        description: 'Planning features configuration.',
        showInDialog: false,
        properties: {
          enabled: {
            type: 'boolean',
            label: 'Enable Plan Mode',
            category: 'General',
            requiresRestart: true,
            default: true,
            description:
              'Enable Plan Mode for read-only safety during planning.',
            showInDialog: true,
          },
          directory: {
            type: 'string',
            label: 'Plan Directory',
            category: 'General',
            requiresRestart: true,
            default: undefined as string | undefined,
            description:
              'The directory where planning artifacts are stored. If not specified, defaults to the system temporary directory. A custom directory requires a policy to allow write access in Plan Mode.',
            showInDialog: true,
          },
          modelRouting: {
            type: 'boolean',
            label: 'Plan Model Routing',
            category: 'General',
            requiresRestart: false,
            default: true,
            description:
              'Automatically switch between Pro and Flash models based on Plan Mode status. Uses Pro for the planning phase and Flash for the implementation phase.',
            showInDialog: true,
          },
        },
      },
      retryFetchErrors: {
        type: 'boolean',
        label: 'Retry Fetch Errors',
        category: 'General',
        requiresRestart: false,
        default: true,
        description:
          'Retry on "exception TypeError: fetch failed sending request" errors.',
        showInDialog: true,
      },
      maxAttempts: {
        type: 'number',
        label: 'Max Chat Model Attempts',
        category: 'General',
        requiresRestart: false,
        default: 10,
        description:
          'Maximum number of attempts for requests to the main chat model. Cannot exceed 10.',
        showInDialog: true,
      },
      debugKeystrokeLogging: {
        type: 'boolean',
        label: 'Debug Keystroke Logging',
        category: 'General',
        requiresRestart: false,
        default: false,
        description: 'Enable debug logging of keystrokes to the console.',
        showInDialog: true,
      },
      sessionRetention: {
        type: 'object',
        label: 'Session Retention',
        category: 'General',
        requiresRestart: false,
        default: undefined as SessionRetentionSettings | undefined,
        showInDialog: false,
        properties: {
          enabled: {
            type: 'boolean',
            label: 'Enable Session Cleanup',
            category: 'General',
            requiresRestart: false,
            default: true as boolean,
            description: 'Enable automatic session cleanup',
            showInDialog: true,
          },
          maxAge: {
            type: 'string',
            label: 'Keep chat history',
            category: 'General',
            requiresRestart: false,
            default: '30d' as string,
            description:
              'Automatically delete chats older than this time period (e.g., "30d", "7d", "24h", "1w")',
            showInDialog: true,
          },
          maxCount: {
            type: 'number',
            label: 'Max Session Count',
            category: 'General',
            requiresRestart: false,
            default: undefined as number | undefined,
            description:
              'Alternative: Maximum number of sessions to keep (most recent)',
            showInDialog: false,
          },
          minRetention: {
            type: 'string',
            label: 'Min Retention Period',
            category: 'General',
            requiresRestart: false,
            default: DEFAULT_MIN_RETENTION,
            description: `Minimum retention period (safety limit, defaults to "${DEFAULT_MIN_RETENTION}")`,
            showInDialog: false,
          },
        },
        description: 'Settings for automatic session cleanup.',
      },
      topicUpdateNarration: {
        type: 'boolean',
        label: 'Topic & Update Narration',
        category: 'General',
        requiresRestart: false,
        default: true,
        description:
          'Enable the Topic & Update communication model for reduced chattiness and structured progress reporting.',
        showInDialog: true,
      },
      logRagSnippets: {
        type: 'boolean',
        label: 'Log RAG Snippets',
        category: 'General',
        requiresRestart: false,
        default: false,
        description:
          'Log full Code Customization (RAG) retrieved snippets to a local file for debugging.',
        showInDialog: true,
      },
    },
  },
  output: {
    type: 'object',
    label: 'Output',
    category: 'General',
    requiresRestart: false,
    default: {},
    description: 'Settings for the CLI output.',
    showInDialog: false,
    properties: {
      format: {
        type: 'enum',
        label: 'Output Format',
        category: 'General',
        requiresRestart: false,
        default: 'text',
        description: 'The format of the CLI output. Can be `text` or `json`.',
        showInDialog: true,
        options: [
          { value: 'text', label: 'Text' },
          { value: 'json', label: 'JSON' },
        ],
      },
    },
  },

  ui: {
    type: 'object',
    label: 'UI',
    category: 'UI',
    requiresRestart: false,
    default: {},
    description: 'User interface settings.',
    showInDialog: false,
    properties: {
      debugRainbow: {
        type: 'boolean',
        label: 'Debug Rainbow',
        category: 'UI',
        requiresRestart: true,
        default: false,
        description:
          'Enable debug rainbow rendering. Only useful for debugging rendering bugs and performance issues.',
        showInDialog: false,
      },
      theme: {
        type: 'string',
        label: 'Theme',
        category: 'UI',
        requiresRestart: false,
        default: undefined as string | undefined,
        description:
          'The color theme for the UI. See the CLI themes guide for available options.',
        showInDialog: false,
      },
      autoThemeSwitching: {
        type: 'boolean',
        label: 'Auto Theme Switching',
        category: 'UI',
        requiresRestart: false,
        default: true,
        description:
          'Automatically switch between default light and dark themes based on terminal background color.',
        showInDialog: true,
      },
      terminalBackgroundPollingInterval: {
        type: 'number',
        label: 'Terminal Background Polling Interval',
        category: 'UI',
        requiresRestart: false,
        default: 60,
        description:
          'Interval in seconds to poll the terminal background color.',
        showInDialog: true,
      },
      customThemes: {
        type: 'object',
        label: 'Custom Themes',
        category: 'UI',
        requiresRestart: false,
        default: {} as Record<string, CustomTheme>,
        description: 'Custom theme definitions.',
        showInDialog: false,
        additionalProperties: {
          type: 'object',
          ref: 'CustomTheme',
        },
      },
      hideWindowTitle: {
        type: 'boolean',
        label: 'Hide Window Title',
        category: 'UI',
        requiresRestart: true,
        default: false,
        description: 'Hide the window title bar',
        showInDialog: true,
      },
      inlineThinkingMode: {
        type: 'enum',
        label: 'Inline Thinking',
        category: 'UI',
        requiresRestart: false,
        default: 'off',
        description: 'Display model thinking inline: off or full.',
        showInDialog: true,
        options: [
          { value: 'off', label: 'Off' },
          { value: 'full', label: 'Full' },
        ],
      },
      showStatusInTitle: {
        type: 'boolean',
        label: 'Show Thoughts in Title',
        category: 'UI',
        requiresRestart: false,
        default: false,
        description:
          'Show Gemini CLI model thoughts in the terminal window title during the working phase',
        showInDialog: true,
      },
      dynamicWindowTitle: {
        type: 'boolean',
        label: 'Dynamic Window Title',
        category: 'UI',
        requiresRestart: false,
        default: true,
        description:
          'Update the terminal window title with current status icons (Ready: ◇, Action Required: ✋, Working: ✦)',
        showInDialog: true,
      },
      showHomeDirectoryWarning: {
        type: 'boolean',
        label: 'Show Home Directory Warning',
        category: 'UI',
        requiresRestart: true,
        default: true,
        description:
          'Show a warning when running Gemini CLI in the home directory.',
        showInDialog: true,
      },
      showCompatibilityWarnings: {
        type: 'boolean',
        label: 'Show Compatibility Warnings',
        category: 'UI',
        requiresRestart: true,
        default: true,
        description: 'Show warnings about terminal or OS compatibility issues.',
        showInDialog: true,
      },
      hideTips: {
        type: 'boolean',
        label: 'Hide Tips',
        category: 'UI',
        requiresRestart: false,
        default: false,
        description: 'Hide helpful tips in the UI',
        showInDialog: true,
      },
      escapePastedAtSymbols: {
        type: 'boolean',
        label: 'Escape Pasted @ Symbols',
        category: 'UI',
        requiresRestart: false,
        default: false,
        description:
          'When enabled, @ symbols in pasted text are escaped to prevent unintended @path expansion.',
        showInDialog: true,
      },
      showShortcutsHint: {
        type: 'boolean',
        label: 'Show Shortcuts Hint',
        category: 'UI',
        requiresRestart: false,
        default: true,
        description: 'Show the "? for shortcuts" hint above the input.',
        showInDialog: true,
      },
      compactToolOutput: {
        type: 'boolean',
        label: 'Compact Tool Output',
        category: 'UI',
        requiresRestart: false,
        default: true,
        description:
          'Display tool outputs (like directory listings and file reads) in a compact, structured format.',
        showInDialog: true,
      },
      hideBanner: {
        type: 'boolean',
        label: 'Hide Banner',
        category: 'UI',
        requiresRestart: false,
        default: false,
        description: 'Hide the application banner',
        showInDialog: true,
      },
      hideContextSummary: {
        type: 'boolean',
        label: 'Hide Context Summary',
        category: 'UI',
        requiresRestart: false,
        default: false,
        description:
          'Hide the context summary (GEMINI.md, MCP servers) above the input.',
        showInDialog: true,
      },
      footer: {
        type: 'object',
        label: 'Footer',
        category: 'UI',
        requiresRestart: false,
        default: {},
        description: 'Settings for the footer.',
        showInDialog: false,
        properties: {
          items: {
            type: 'array',
            label: 'Footer Items',
            category: 'UI',
            requiresRestart: false,
            default: undefined as string[] | undefined,
            description:
              'List of item IDs to display in the footer. Rendered in order',
            showInDialog: false,
            items: { type: 'string' },
          },
          showLabels: {
            type: 'boolean',
            label: 'Show Footer Labels',
            category: 'UI',
            requiresRestart: false,
            default: true,
            description:
              'Display a second line above the footer items with descriptive headers (e.g., /model).',
            showInDialog: false,
          },
          hideCWD: {
            type: 'boolean',
            label: 'Hide CWD',
            category: 'UI',
            requiresRestart: false,
            default: false,
            description: 'Hide the current working directory in the footer.',
            showInDialog: true,
          },
          hideSandboxStatus: {
            type: 'boolean',
            label: 'Hide Sandbox Status',
            category: 'UI',
            requiresRestart: false,
            default: false,
            description: 'Hide the sandbox status indicator in the footer.',
            showInDialog: true,
          },
          hideModelInfo: {
            type: 'boolean',
            label: 'Hide Model Info',
            category: 'UI',
            requiresRestart: false,
            default: false,
            description: 'Hide the model name and context usage in the footer.',
            showInDialog: true,
          },
          hideContextPercentage: {
            type: 'boolean',
            label: 'Hide Context Window Percentage',
            category: 'UI',
            requiresRestart: false,
            default: true,
            description: 'Hides the context window usage percentage.',
            showInDialog: true,
          },
        },
      },
      hideFooter: {
        type: 'boolean',
        label: 'Hide Footer',
        category: 'UI',
        requiresRestart: false,
        default: false,
        description: 'Hide the footer from the UI',
        showInDialog: true,
      },
      collapseDrawerDuringApproval: {
        type: 'boolean',
        label: 'Collapse Drawer During Approval',
        category: 'UI',
        requiresRestart: false,
        default: true,
        description:
          'Whether to collapse the UI drawer when a tool is awaiting confirmation.',
        showInDialog: false,
      },
      showMemoryUsage: {
        type: 'boolean',
        label: 'Show Memory Usage',
        category: 'UI',
        requiresRestart: false,
        default: false,
        description: 'Display memory usage information in the UI',
        showInDialog: true,
      },
      showLineNumbers: {
        type: 'boolean',
        label: 'Show Line Numbers',
        category: 'UI',
        requiresRestart: false,
        default: true,
        description: 'Show line numbers in the chat.',
        showInDialog: true,
      },
      showCitations: {
        type: 'boolean',
        label: 'Show Citations',
        category: 'UI',
        requiresRestart: false,
        default: false,
        description: 'Show citations for generated text in the chat.',
        showInDialog: true,
      },
      showModelInfoInChat: {
        type: 'boolean',
        label: 'Show Model Info In Chat',
        category: 'UI',
        requiresRestart: false,
        default: false,
        description: 'Show the model name in the chat for each model turn.',
        showInDialog: true,
      },
      showUserIdentity: {
        type: 'boolean',
        label: 'Show User Identity',
        category: 'UI',
        requiresRestart: false,
        default: true,
        description:
          "Show the signed-in user's identity (e.g. email) in the UI.",
        showInDialog: true,
      },
      useAlternateBuffer: {
        type: 'boolean',
        label: 'Use Alternate Screen Buffer',
        category: 'UI',
        requiresRestart: true,
        default: false,
        description:
          'Use an alternate screen buffer for the UI, preserving shell history.',
        showInDialog: true,
      },
      renderProcess: {
        type: 'boolean',
        label: 'Render Process',
        category: 'UI',
        requiresRestart: true,
        default: true,
        description: 'Enable Ink render process for the UI.',
        showInDialog: true,
      },
      terminalBuffer: {
        type: 'boolean',
        label: 'Terminal Buffer',
        category: 'UI',
        requiresRestart: true,
        default: false,
        description: 'Use the new terminal buffer architecture for rendering.',
        showInDialog: true,
      },
      useBackgroundColor: {
        type: 'boolean',
        label: 'Use Background Color',
        category: 'UI',
        requiresRestart: false,
        default: true,
        description: 'Whether to use background colors in the UI.',
        showInDialog: true,
      },
      incrementalRendering: {
        type: 'boolean',
        label: 'Incremental Rendering',
        category: 'UI',
        requiresRestart: true,
        default: true,
        description:
          'Enable incremental rendering for the UI. This option will reduce flickering but may cause rendering artifacts. Only supported when useAlternateBuffer is enabled.',
        showInDialog: true,
      },
      showSpinner: {
        type: 'boolean',
        label: 'Show Spinner',
        category: 'UI',
        requiresRestart: false,
        default: true,
        description: 'Show the spinner during operations.',
        showInDialog: true,
      },
      loadingPhrases: {
        type: 'enum',
        label: 'Loading Phrases',
        category: 'UI',
        requiresRestart: false,
        default: 'off',
        description:
          'What to show while the model is working: tips, witty comments, all, or off.',
        showInDialog: true,
        options: [
          { value: 'tips', label: 'Tips' },
          { value: 'witty', label: 'Witty' },
          { value: 'all', label: 'All' },
          { value: 'off', label: 'Off' },
        ],
      },
      errorVerbosity: {
        type: 'enum',
        label: 'Error Verbosity',
        category: 'UI',
        requiresRestart: false,
        default: 'low',
        description:
          'Controls whether recoverable errors are hidden (low) or fully shown (full).',
        showInDialog: true,
        options: [
          { value: 'low', label: 'Low' },
          { value: 'full', label: 'Full' },
        ],
      },
      customWittyPhrases: {
        type: 'array',
        label: 'Custom Witty Phrases',
        category: 'UI',
        requiresRestart: false,
        default: [] as string[],
        description: oneLine`
          Custom witty phrases to display during loading.
          When provided, the CLI cycles through these instead of the defaults.
        `,
        showInDialog: false,
        items: { type: 'string' },
      },
      accessibility: {
        type: 'object',
        label: 'Accessibility',
        category: 'UI',
        requiresRestart: true,
        default: {},
        description: 'Accessibility settings.',
        showInDialog: false,
        properties: {
          enableLoadingPhrases: {
            type: 'boolean',
            label: 'Enable Loading Phrases',
            category: 'UI',
            requiresRestart: true,
            default: true,
            description:
              '@deprecated Use ui.loadingPhrases instead. Enable loading phrases during operations.',
            showInDialog: false,
          },
          screenReader: {
            type: 'boolean',
            label: 'Screen Reader Mode',
            category: 'UI',
            requiresRestart: true,
            default: false,
            description:
              'Render output in plain-text to be more screen reader accessible',
            showInDialog: true,
          },
        },
      },
    },
  },

  ide: {
    type: 'object',
    label: 'IDE',
    category: 'IDE',
    requiresRestart: true,
    default: {},
    description: 'IDE integration settings.',
    showInDialog: false,
    properties: {
      enabled: {
        type: 'boolean',
        label: 'IDE Mode',
        category: 'IDE',
        requiresRestart: true,
        default: false,
        description: 'Enable IDE integration mode.',
        showInDialog: true,
      },
      hasSeenNudge: {
        type: 'boolean',
        label: 'Has Seen IDE Integration Nudge',
        category: 'IDE',
        requiresRestart: false,
        default: false,
        description: 'Whether the user has seen the IDE integration nudge.',
        showInDialog: false,
      },
    },
  },

  privacy: {
    type: 'object',
    label: 'Privacy',
    category: 'Privacy',
    requiresRestart: true,
    default: {},
    description: 'Privacy-related settings.',
    showInDialog: false,
    properties: {
      usageStatisticsEnabled: {
        type: 'boolean',
        label: 'Enable Usage Statistics',
        category: 'Privacy',
        requiresRestart: true,
        default: true,
        description: 'Enable collection of usage statistics',
        showInDialog: false,
      },
    },
  },

  telemetry: {
    type: 'object',
    label: 'Telemetry',
    category: 'Advanced',
    requiresRestart: true,
    default: undefined as TelemetrySettings | undefined,
    description: 'Telemetry configuration.',
    showInDialog: false,
    ref: 'TelemetrySettings',
  },

  billing: {
    type: 'object',
    label: 'Billing',
    category: 'Advanced',
    requiresRestart: false,
    default: {},
    description: 'Billing and AI credits settings.',
    showInDialog: false,
    properties: {
      overageStrategy: {
        type: 'enum',
        label: 'Overage Strategy',
        category: 'Advanced',
        requiresRestart: false,
        default: 'ask',
        description: oneLine`
          How to handle quota exhaustion when AI credits are available.
          'ask' prompts each time, 'always' automatically uses credits,
          'never' disables credit usage.
        `,
        showInDialog: true,
        options: [
          { value: 'ask', label: 'Ask each time' },
          { value: 'always', label: 'Always use credits' },
          { value: 'never', label: 'Never use credits' },
        ],
      },
      vertexAi: {
        type: 'object',
        label: 'Vertex AI',
        category: 'Advanced',
        requiresRestart: true,
        default: undefined as VertexAiRoutingConfig | undefined,
        description: 'Vertex AI request routing settings.',
        showInDialog: false,
        properties: {
          requestType: {
            type: 'enum',
            label: 'Vertex AI Request Type',
            category: 'Advanced',
            requiresRestart: true,
            default: undefined as VertexAiRoutingConfig['requestType'],
            description:
              'Sets the X-Vertex-AI-LLM-Request-Type header for Vertex AI requests.',
            showInDialog: false,
            options: [
              { value: 'dedicated', label: 'Dedicated' },
              { value: 'shared', label: 'Shared' },
            ],
          },
          sharedRequestType: {
            type: 'enum',
            label: 'Vertex AI Shared Request Type',
            category: 'Advanced',
            requiresRestart: true,
            default: undefined as VertexAiRoutingConfig['sharedRequestType'],
            description:
              'Sets the X-Vertex-AI-LLM-Shared-Request-Type header for Vertex AI requests.',
            showInDialog: false,
            options: [
              { value: 'priority', label: 'Priority' },
              { value: 'flex', label: 'Flex' },
            ],
          },
        },
      },
    },
  },

  model: {
    type: 'object',
    label: 'Model',
    category: 'Model',
    requiresRestart: false,
    default: {},
    description: 'Settings related to the generative model.',
    showInDialog: false,
    properties: {
      name: {
        type: 'string',
        label: 'Model',
        category: 'Model',
        requiresRestart: false,
        default: undefined as string | undefined,
        description: 'The Gemini model to use for conversations.',
        showInDialog: true,
      },
      maxSessionTurns: {
        type: 'number',
        label: 'Max Session Turns',
        category: 'Model',
        requiresRestart: false,
        default: -1,
        description:
          'Maximum number of user/model/tool turns to keep in a session. -1 means unlimited.',
        showInDialog: true,
      },
      summarizeToolOutput: {
        type: 'object',
        label: 'Summarize Tool Output',
        category: 'Model',
        requiresRestart: false,
        default: undefined as
          | Record<string, { tokenBudget?: number }>
          | undefined,
        description: oneLine`
          Enables or disables summarization of tool output.
          Configure per-tool token budgets (for example {"run_shell_command": {"tokenBudget": 2000}}).
          Currently only the run_shell_command tool supports summarization.
        `,
        showInDialog: false,
        additionalProperties: {
          type: 'object',
          description:
            'Per-tool summarization settings with an optional tokenBudget.',
          ref: 'SummarizeToolOutputSettings',
        },
      },
      compressionThreshold: {
        type: 'number',
        label: 'Context Compression Threshold',
        category: 'Model',
        requiresRestart: true,
        default: 0.5 as number,
        description:
          'The fraction of context usage at which to trigger context compression (e.g. 0.2, 0.3).',
        showInDialog: true,
        unit: '%',
      },
      disableLoopDetection: {
        type: 'boolean',
        label: 'Disable Loop Detection',
        category: 'Model',
        requiresRestart: true,
        default: false,
        description:
          'Disable automatic detection and prevention of infinite loops.',
        showInDialog: true,
      },
      skipNextSpeakerCheck: {
        type: 'boolean',
        label: 'Skip Next Speaker Check',
        category: 'Model',
        requiresRestart: false,
        default: true,
        description: 'Skip the next speaker check.',
        showInDialog: true,
      },
    },
  },

  modelConfigs: {
    type: 'object',
    label: 'Model Configs',
    category: 'Model',
    requiresRestart: false,
    default: DEFAULT_MODEL_CONFIGS,
    description: 'Model configurations.',
    showInDialog: false,
    properties: {
      aliases: {
        type: 'object',
        label: 'Model Config Aliases',
        category: 'Model',
        requiresRestart: false,
        default: DEFAULT_MODEL_CONFIGS.aliases,
        description:
          'Named presets for model configs. Can be used in place of a model name and can inherit from other aliases using an `extends` property.',
        showInDialog: false,
      },
      customAliases: {
        type: 'object',
        label: 'Custom Model Config Aliases',
        category: 'Model',
        requiresRestart: false,
        default: {},
        description:
          'Custom named presets for model configs. These are merged with (and override) the built-in aliases.',
        showInDialog: false,
      },
      customOverrides: {
        type: 'array',
        label: 'Custom Model Config Overrides',
        category: 'Model',
        requiresRestart: false,
        default: [],
        description:
          'Custom model config overrides. These are merged with (and added to) the built-in overrides.',
        showInDialog: false,
      },
      overrides: {
        type: 'array',
        label: 'Model Config Overrides',
        category: 'Model',
        requiresRestart: false,
        default: [],
        description:
          'Apply specific configuration overrides based on matches, with a primary key of model (or alias). The most specific match will be used.',
        showInDialog: false,
      },
      modelDefinitions: {
        type: 'object',
        label: 'Model Definitions',
        category: 'Model',
        requiresRestart: true,
        default: DEFAULT_MODEL_CONFIGS.modelDefinitions,
        description:
          'Registry of model metadata, including tier, family, and features.',
        showInDialog: false,
        additionalProperties: {
          type: 'object',
          ref: 'ModelDefinition',
        },
      },
      modelIdResolutions: {
        type: 'object',
        label: 'Model ID Resolutions',
        category: 'Model',
        requiresRestart: true,
        default: DEFAULT_MODEL_CONFIGS.modelIdResolutions,
        description:
          'Rules for resolving requested model names to concrete model IDs based on context.',
        showInDialog: false,
        additionalProperties: {
          type: 'object',
          ref: 'ModelResolution',
        },
      },
      classifierIdResolutions: {
        type: 'object',
        label: 'Classifier ID Resolutions',
        category: 'Model',
        requiresRestart: true,
        default: DEFAULT_MODEL_CONFIGS.classifierIdResolutions,
        description:
          'Rules for resolving classifier tiers (flash, pro) to concrete model IDs.',
        showInDialog: false,
        additionalProperties: {
          type: 'object',
          ref: 'ModelResolution',
        },
      },
      modelChains: {
        type: 'object',
        label: 'Model Chains',
        category: 'Model',
        requiresRestart: true,
        default: DEFAULT_MODEL_CONFIGS.modelChains,
        description:
          'Availability policy chains defining fallback behavior for models.',
        showInDialog: false,
        additionalProperties: {
          type: 'array',
          ref: 'ModelPolicyChain',
        },
      },
    },
  },

  agents: {
    type: 'object',
    label: 'Agents',
    category: 'Advanced',
    requiresRestart: true,
    default: {},
    description: 'Settings for subagents.',
    showInDialog: false,
    properties: {
      overrides: {
        type: 'object',
        label: 'Agent Overrides',
        category: 'Advanced',
        requiresRestart: true,
        default: {} as Record<string, AgentOverride>,
        description:
          'Override settings for specific agents, e.g. to disable the agent, set a custom model config, or run config.',
        showInDialog: false,
        additionalProperties: {
          type: 'object',
          ref: 'AgentOverride',
        },
      },
      browser: {
        type: 'object',
        label: 'Browser Agent',
        category: 'Advanced',
        requiresRestart: true,
        default: {},
        description: 'Settings specific to the browser agent.',
        showInDialog: false,
        properties: {
          sessionMode: {
            type: 'enum',
            label: 'Browser Session Mode',
            category: 'Advanced',
            requiresRestart: true,
            default: 'persistent',
            description:
              "Session mode: 'persistent', 'isolated', or 'existing'.",
            showInDialog: false,
            options: [
              { value: 'persistent', label: 'Persistent' },
              { value: 'isolated', label: 'Isolated' },
              { value: 'existing', label: 'Existing' },
            ],
          },
          headless: {
            type: 'boolean',
            label: 'Browser Headless',
            category: 'Advanced',
            requiresRestart: true,
            default: false,
            description: 'Run browser in headless mode.',
            showInDialog: false,
          },
          profilePath: {
            type: 'string',
            label: 'Browser Profile Path',
            category: 'Advanced',
            requiresRestart: true,
            default: undefined as string | undefined,
            description:
              'Path to browser profile directory for session persistence.',
            showInDialog: false,
          },
          visualModel: {
            type: 'string',
            label: 'Browser Visual Model',
            category: 'Advanced',
            requiresRestart: true,
            default: undefined as string | undefined,
            description:
              "Model for the visual agent's analyze_screenshot tool. When set, enables the tool.",
            showInDialog: false,
          },
          allowedDomains: {
            type: 'array',
            label: 'Allowed Domains',
            category: 'Advanced',
            requiresRestart: true,
            default: ['github.com', '*.google.com', 'localhost'] as string[],
            description: oneLine`
              A list of allowed domains for the browser agent
              (e.g., ["github.com", "*.google.com"]).
            `,
            showInDialog: false,
            items: { type: 'string' },
          },
          disableUserInput: {
            type: 'boolean',
            label: 'Disable User Input',
            category: 'Advanced',
            requiresRestart: false,
            default: true,
            description:
              'Disable user input on browser window during automation.',
            showInDialog: false,
          },
          maxActionsPerTask: {
            type: 'number',
            label: 'Max Actions Per Task',
            category: 'Advanced',
            requiresRestart: false,
            default: 100,
            description:
              'The maximum number of tool calls allowed per browser task. Enforcement is hard: the agent will be terminated when the limit is reached.',
            showInDialog: false,
          },
          confirmSensitiveActions: {
            type: 'boolean',
            label: 'Confirm Sensitive Actions',
            category: 'Advanced',
            requiresRestart: true,
            default: false,
            description:
              'Require manual confirmation for sensitive browser actions (e.g., fill_form, evaluate_script).',
            showInDialog: true,
          },
          blockFileUploads: {
            type: 'boolean',
            label: 'Block File Uploads',
            category: 'Advanced',
            requiresRestart: true,
            default: false,
            description:
              'Hard-block file upload requests from the browser agent.',
            showInDialog: true,
          },
        },
      },
    },
  },

  context: {
    type: 'object',
    label: 'Context',
    category: 'Context',
    requiresRestart: false,
    default: {},
    description: 'Settings for managing context provided to the model.',
    showInDialog: false,
    properties: {
      fileName: {
        type: 'string',
        label: 'Context File Name',
        category: 'Context',
        requiresRestart: false,
        default: undefined as string | string[] | undefined,
        ref: 'StringOrStringArray',
        description:
          'The name of the context file or files to load into memory. Accepts either a single string or an array of strings.',
        showInDialog: false,
      },
      importFormat: {
        type: 'string',
        label: 'Memory Import Format',
        category: 'Context',
        requiresRestart: false,
        default: undefined as MemoryImportFormat | undefined,
        description: 'The format to use when importing memory.',
        showInDialog: false,
      },
      includeDirectoryTree: {
        type: 'boolean',
        label: 'Include Directory Tree',
        category: 'Context',
        requiresRestart: false,
        default: true,
        description:
          'Whether to include the directory tree of the current working directory in the initial request to the model.',
        showInDialog: false,
      },
      discoveryMaxDirs: {
        type: 'number',
        label: 'Memory Discovery Max Dirs',
        category: 'Context',
        requiresRestart: false,
        default: 200,
        description: 'Maximum number of directories to search for memory.',
        showInDialog: true,
      },
      memoryBoundaryMarkers: {
        type: 'array',
        label: 'Memory Boundary Markers',
        category: 'Context',
        requiresRestart: true,
        default: ['.git'] as string[],
        description:
          'File or directory names that mark the boundary for GEMINI.md discovery. ' +
          'The upward traversal stops at the first directory containing any of these markers. ' +
          'An empty array disables parent traversal.',
        showInDialog: false,
        items: { type: 'string' },
      },
      includeDirectories: {
        type: 'array',
        label: 'Include Directories',
        category: 'Context',
        requiresRestart: false,
        default: [] as string[],
        description: oneLine`
          Additional directories to include in the workspace context.
          Missing directories will be skipped with a warning.
        `,
        showInDialog: false,
        items: { type: 'string' },
        mergeStrategy: MergeStrategy.CONCAT,
      },
      loadMemoryFromIncludeDirectories: {
        type: 'boolean',
        label: 'Load Memory From Include Directories',
        category: 'Context',
        requiresRestart: false,
        default: false,
        description: oneLine`
          Controls how /memory reload loads GEMINI.md files.
          When true, include directories are scanned; when false, only the current directory is used.
        `,
        showInDialog: true,
      },
      fileFiltering: {
        type: 'object',
        label: 'File Filtering',
        category: 'Context',
        requiresRestart: true,
        default: {},
        description: 'Settings for git-aware file filtering.',
        showInDialog: false,
        properties: {
          respectGitIgnore: {
            type: 'boolean',
            label: 'Respect .gitignore',
            category: 'Context',
            requiresRestart: true,
            default: true,
            description: 'Respect .gitignore files when searching.',
            showInDialog: true,
          },
          respectGeminiIgnore: {
            type: 'boolean',
            label: 'Respect .geminiignore',
            category: 'Context',
            requiresRestart: true,
            default: true,
            description: 'Respect .geminiignore files when searching.',
            showInDialog: true,
          },
          enableFileWatcher: {
            type: 'boolean',
            label: 'Enable File Watcher',
            category: 'Context',
            requiresRestart: true,
            default: false,
            description: oneLine`
              Enable file watcher updates for @ file suggestions (experimental).
            `,
            showInDialog: false,
          },
          enableRecursiveFileSearch: {
            type: 'boolean',
            label: 'Enable Recursive File Search',
            category: 'Context',
            requiresRestart: true,
            default: true,
            description: oneLine`
              Enable recursive file search functionality when completing @ references in the prompt.
            `,
            showInDialog: true,
          },
          enableFuzzySearch: {
            type: 'boolean',
            label: 'Enable Fuzzy Search',
            category: 'Context',
            requiresRestart: true,
            default: true,
            description: 'Enable fuzzy search when searching for files.',
            showInDialog: true,
          },
          customIgnoreFilePaths: {
            type: 'array',
            label: 'Custom Ignore File Paths',
            category: 'Context',
            requiresRestart: true,
            default: [] as string[],
            description:
              'Additional ignore file paths to respect. These files take precedence over .geminiignore and .gitignore. Files earlier in the array take precedence over files later in the array, e.g. the first file takes precedence over the second one.',
            showInDialog: true,
            items: { type: 'string' },
            mergeStrategy: MergeStrategy.UNION,
          },
        },
      },
    },
  },

  tools: {
    type: 'object',
    label: 'Tools',
    category: 'Tools',
    requiresRestart: true,
    default: {},
    description: 'Settings for built-in and custom tools.',
    showInDialog: false,
    properties: {
      sandbox: {
        type: 'string',
        label: 'Sandbox',
        category: 'Tools',
        requiresRestart: true,
        default: undefined as boolean | string | SandboxConfig | undefined,
        ref: 'BooleanOrStringOrObject',
        description: oneLine`
          Legacy full-process sandbox execution environment.
          Set to a boolean to enable or disable the sandbox, provide a string path to a sandbox profile,
          or specify an explicit sandbox command (e.g., "docker", "podman", "lxc", "windows-native").
        `,
        showInDialog: false,
      },
      sandboxAllowedPaths: {
        type: 'array',
        label: 'Sandbox Allowed Paths',
        category: 'Tools',
        requiresRestart: true,
        default: [] as string[],
        description:
          'List of additional paths that the sandbox is allowed to access.',
        showInDialog: true,
        items: { type: 'string' },
      },
      sandboxNetworkAccess: {
        type: 'boolean',
        label: 'Sandbox Network Access',
        category: 'Tools',
        requiresRestart: true,
        default: false,
        description: 'Whether the sandbox is allowed to access the network.',
        showInDialog: true,
      },
      shell: {
        type: 'object',
        label: 'Shell',
        category: 'Tools',
        requiresRestart: false,
        default: {},
        description: 'Settings for shell execution.',
        showInDialog: false,
        properties: {
          enableInteractiveShell: {
            type: 'boolean',
            label: 'Enable Interactive Shell',
            category: 'Tools',
            requiresRestart: true,
            default: true,
            description: oneLine`
              Use node-pty for an interactive shell experience.
              Fallback to child_process still applies.
            `,
            showInDialog: true,
          },
          backgroundCompletionBehavior: {
            type: 'enum',
            label: 'Background Completion Behavior',
            category: 'Tools',
            requiresRestart: false,
            default: 'silent',
            description:
              "Controls what happens when a background shell command finishes. 'silent' (default): quietly exits in background. 'inject': automatically returns output to agent. 'notify': shows brief message in chat.",
            showInDialog: false,
            options: [
              { label: 'Silent', value: 'silent' },
              { label: 'Inject', value: 'inject' },
              { label: 'Notify', value: 'notify' },
            ],
          },
          pager: {
            type: 'string',
            label: 'Pager',
            category: 'Tools',
            requiresRestart: false,
            default: 'cat' as string | undefined,
            description:
              'The pager command to use for shell output. Defaults to `cat`.',
            showInDialog: false,
          },
          showColor: {
            type: 'boolean',
            label: 'Show Color',
            category: 'Tools',
            requiresRestart: false,
            default: true,
            description: 'Show color in shell output.',
            showInDialog: true,
          },
          inactivityTimeout: {
            type: 'number',
            label: 'Inactivity Timeout',
            category: 'Tools',
            requiresRestart: false,
            default: 300,
            description:
              'The maximum time in seconds allowed without output from the shell command. Defaults to 5 minutes.',
            showInDialog: false,
          },
          enableShellOutputEfficiency: {
            type: 'boolean',
            label: 'Enable Shell Output Efficiency',
            category: 'Tools',
            requiresRestart: false,
            default: true,
            description:
              'Enable shell output efficiency optimizations for better performance.',
            showInDialog: false,
          },
        },
      },

      core: {
        type: 'array',
        label: 'Core Tools',
        category: 'Tools',
        requiresRestart: true,
        default: undefined as string[] | undefined,
        description: oneLine`
          Restrict the set of built-in tools with an allowlist.
          Match semantics mirror tools.allowed; see the built-in tools documentation for available names.
        `,
        showInDialog: false,
        items: { type: 'string' },
      },
      allowed: {
        type: 'array',
        label: 'Allowed Tools',
        category: 'Advanced',
        requiresRestart: true,
        default: undefined as string[] | undefined,
        description: oneLine`
          Tool names that bypass the confirmation dialog.
          Useful for trusted commands (for example ["run_shell_command(git)", "run_shell_command(npm test)"]).
          See shell tool command restrictions for matching details.
        `,
        showInDialog: false,
        items: { type: 'string' },
      },
      confirmationRequired: {
        type: 'array',
        label: 'Confirmation Required',
        category: 'Advanced',
        requiresRestart: true,
        default: undefined as string[] | undefined,
        description: oneLine`
          Tool names that always require user confirmation.
          Takes precedence over allowed tools and core tool allowlists.
        `,
        showInDialog: false,
        items: { type: 'string' },
      },
      exclude: {
        type: 'array',
        label: 'Exclude Tools',
        category: 'Tools',
        requiresRestart: true,
        default: undefined as string[] | undefined,
        description: 'Tool names to exclude from discovery.',
        showInDialog: false,
        items: { type: 'string' },
        mergeStrategy: MergeStrategy.UNION,
      },
      discoveryCommand: {
        type: 'string',
        label: 'Tool Discovery Command',
        category: 'Tools',
        requiresRestart: true,
        default: undefined as string | undefined,
        description: 'Command to run for tool discovery.',
        showInDialog: false,
      },
      callCommand: {
        type: 'string',
        label: 'Tool Call Command',
        category: 'Tools',
        requiresRestart: true,
        default: undefined as string | undefined,
        description: oneLine`
          Defines a custom shell command for invoking discovered tools.
          The command must take the tool name as the first argument, read JSON arguments from stdin, and emit JSON results on stdout.
        `,
        showInDialog: false,
      },
      useRipgrep: {
        type: 'boolean',
        label: 'Use Ripgrep',
        category: 'Tools',
        requiresRestart: false,
        default: true,
        description:
          'Use ripgrep for file content search instead of the fallback implementation. Provides faster search performance.',
        showInDialog: true,
      },
      truncateToolOutputThreshold: {
        type: 'number',
        label: 'Tool Output Truncation Threshold',
        category: 'General',
        requiresRestart: true,
        default: DEFAULT_TRUNCATE_TOOL_OUTPUT_THRESHOLD,
        description:
          'Maximum characters to show when truncating large tool outputs. Set to 0 or negative to disable truncation.',
        showInDialog: true,
      },
      disableLLMCorrection: {
        type: 'boolean',
        label: 'Disable LLM Correction',
        category: 'Tools',
        requiresRestart: true,
        default: true,
        description: oneLine`
          Disable LLM-based error correction for edit tools.
          When enabled, tools will fail immediately if exact string matches are not found, instead of attempting to self-correct.
        `,
        showInDialog: true,
      },
    },
  },

  mcp: {
    type: 'object',
    label: 'MCP',
    category: 'MCP',
    requiresRestart: true,
    default: {},
    description: 'Settings for Model Context Protocol (MCP) servers.',
    showInDialog: false,
    properties: {
      serverCommand: {
        type: 'string',
        label: 'MCP Server Command',
        category: 'MCP',
        requiresRestart: true,
        default: undefined as string | undefined,
        description: 'Command to start an MCP server.',
        showInDialog: false,
      },
      allowed: {
        type: 'array',
        label: 'Allow MCP Servers',
        category: 'MCP',
        requiresRestart: true,
        default: undefined as string[] | undefined,
        description: 'A list of MCP servers to allow.',
        showInDialog: false,
        items: { type: 'string' },
      },
      excluded: {
        type: 'array',
        label: 'Exclude MCP Servers',
        category: 'MCP',
        requiresRestart: true,
        default: undefined as string[] | undefined,
        description: 'A list of MCP servers to exclude.',
        showInDialog: false,
        items: { type: 'string' },
      },
    },
  },

  useWriteTodos: {
    type: 'boolean',
    label: 'Use WriteTodos',
    category: 'Advanced',
    requiresRestart: false,
    default: true,
    description: 'Enable the write_todos tool.',
    showInDialog: false,
  },
  security: {
    type: 'object',
    label: 'Security',
    category: 'Security',
    requiresRestart: true,
    default: {},
    description: 'Security-related settings.',
    showInDialog: false,
    properties: {
      toolSandboxing: {
        type: 'boolean',
        label: 'Tool Sandboxing',
        category: 'Security',
        requiresRestart: true,
        default: false,
        description:
          'Tool-level sandboxing. Isolates individual tools instead of the entire CLI process.',
        showInDialog: true,
      },
      disableYoloMode: {
        type: 'boolean',
        label: 'Disable YOLO Mode',
        category: 'Security',
        requiresRestart: true,
        default: false,
        description: 'Disable YOLO mode, even if enabled by a flag.',
        showInDialog: true,
      },
      disableAlwaysAllow: {
        type: 'boolean',
        label: 'Disable Always Allow',
        category: 'Security',
        requiresRestart: true,
        default: false,
        description:
          'Disable "Always allow" options in tool confirmation dialogs.',
        showInDialog: true,
      },
      enablePermanentToolApproval: {
        type: 'boolean',
        label: 'Allow Permanent Tool Approval',
        category: 'Security',
        requiresRestart: false,
        default: false,
        description:
          'Enable the "Allow for all future sessions" option in tool confirmation dialogs.',
        showInDialog: true,
      },
      autoAddToPolicyByDefault: {
        type: 'boolean',
        label: 'Auto-add to Policy by Default',
        category: 'Security',
        requiresRestart: false,
        default: false,
        description: oneLine`
          When enabled, the "Allow for all future sessions" option becomes the
          default choice for low-risk tools in trusted workspaces.
        `,
        showInDialog: true,
      },
      blockGitExtensions: {
        type: 'boolean',
        label: 'Blocks extensions from Git',
        category: 'Security',
        requiresRestart: true,
        default: false,
        description: 'Blocks installing and loading extensions from Git.',
        showInDialog: true,
      },
      allowedExtensions: {
        type: 'array',
        label: 'Extension Source Regex Allowlist',
        category: 'Security',
        requiresRestart: true,
        default: [] as string[],
        description:
          'List of Regex patterns for allowed extensions. If nonempty, only extensions that match the patterns in this list are allowed. Overrides the blockGitExtensions setting.',
        showInDialog: true,
        items: { type: 'string' },
      },
      folderTrust: {
        type: 'object',
        label: 'Folder Trust',
        category: 'Security',
        requiresRestart: false,
        default: {},
        description: 'Settings for folder trust.',
        showInDialog: false,
        properties: {
          enabled: {
            type: 'boolean',
            label: 'Folder Trust',
            category: 'Security',
            requiresRestart: true,
            default: true,
            description: 'Setting to track whether Folder trust is enabled.',
            showInDialog: true,
          },
        },
      },
      environmentVariableRedaction: {
        type: 'object',
        label: 'Environment Variable Redaction',
        category: 'Security',
        requiresRestart: false,
        default: {},
        description: 'Settings for environment variable redaction.',
        showInDialog: false,
        properties: {
          allowed: {
            type: 'array',
            label: 'Allowed Environment Variables',
            category: 'Security',
            requiresRestart: true,
            default: [] as string[],
            description:
              'Environment variables to always allow (bypass redaction).',
            showInDialog: false,
            items: { type: 'string' },
          },
          blocked: {
            type: 'array',
            label: 'Blocked Environment Variables',
            category: 'Security',
            requiresRestart: true,
            default: [] as string[],
            description: 'Environment variables to always redact.',
            showInDialog: false,
            items: { type: 'string' },
          },
          enabled: {
            type: 'boolean',
            label: 'Enable Environment Variable Redaction',
            category: 'Security',
            requiresRestart: true,
            default: false,
            description:
              'Enable redaction of environment variables that may contain secrets.',
            showInDialog: true,
          },
        },
      },
      auth: {
        type: 'object',
        label: 'Authentication',
        category: 'Security',
        requiresRestart: true,
        default: {},
        description: 'Authentication settings.',
        showInDialog: false,
        properties: {
          selectedType: {
            type: 'string',
            label: 'Selected Auth Type',
            category: 'Security',
            requiresRestart: true,
            default: undefined as AuthType | undefined,
            description: 'The currently selected authentication type.',
            showInDialog: false,
          },
          enforcedType: {
            type: 'string',
            label: 'Enforced Auth Type',
            category: 'Advanced',
            requiresRestart: true,
            default: undefined as AuthType | undefined,
            description:
              'The required auth type. If this does not match the selected auth type, the user will be prompted to re-authenticate.',
            showInDialog: false,
          },
          useExternal: {
            type: 'boolean',
            label: 'Use External Auth',
            category: 'Security',
            requiresRestart: true,
            default: undefined as boolean | undefined,
            description: 'Whether to use an external authentication flow.',
            showInDialog: false,
          },
        },
      },
      enableConseca: {
        type: 'boolean',
        label: 'Enable Context-Aware Security',
        category: 'Security',
        requiresRestart: true,
        default: false,
        description:
          'Enable the context-aware security checker. This feature uses an LLM to dynamically generate and enforce security policies for tool use based on your prompt, providing an additional layer of protection against unintended actions.',
        showInDialog: true,
      },
    },
  },

  advanced: {
    type: 'object',
    label: 'Advanced',
    category: 'Advanced',
    requiresRestart: true,
    default: {},
    description: 'Advanced settings for power users.',
    showInDialog: false,
    properties: {
      autoConfigureMemory: {
        type: 'boolean',
        label: 'Auto Configure Max Old Space Size',
        category: 'Advanced',
        requiresRestart: true,
        default: true,
        description:
          'Automatically configure Node.js memory limits. Note: Because memory is allocated during the initial process boot, this setting is only read from the global user settings file and ignores workspace-level overrides.',
        showInDialog: true,
      },
      dnsResolutionOrder: {
        type: 'string',
        label: 'DNS Resolution Order',
        category: 'Advanced',
        requiresRestart: true,
        default: undefined as DnsResolutionOrder | undefined,
        description: 'The DNS resolution order.',
        showInDialog: false,
      },
      excludedEnvVars: {
        type: 'array',
        label: 'Excluded Project Environment Variables',
        category: 'Advanced',
        requiresRestart: false,
        default: ['DEBUG', 'DEBUG_MODE'] as string[],
        description: 'Environment variables to exclude from project context.',
        showInDialog: false,
        items: { type: 'string' },
        mergeStrategy: MergeStrategy.UNION,
      },
      ignoreLocalEnv: {
        type: 'boolean',
        label: 'Ignore Local .env',
        category: 'Advanced',
        requiresRestart: true,
        default: false,
        description:
          'Whether to ignore generic .env files in the project directory.',
        showInDialog: true,
      },
      bugCommand: {
        type: 'object',
        label: 'Bug Command',
        category: 'Advanced',
        requiresRestart: false,
        default: undefined as BugCommandSettings | undefined,
        description: 'Configuration for the bug report command.',
        showInDialog: false,
        ref: 'BugCommandSettings',
      },
    },
  },

  experimental: {
    type: 'object',
    label: 'Experimental',
    category: 'Experimental',
    requiresRestart: true,
    default: {},
    description: 'Setting to enable experimental features',
    showInDialog: false,
    properties: {
      gemma: {
        type: 'boolean',
        label: 'Gemma Models',
        category: 'Experimental',
        requiresRestart: true,
        default: true,
        description: 'Enable access to Gemma 4 models via Gemini API.',
        showInDialog: true,
      },
      voiceMode: {
        type: 'boolean',
        label: 'Voice Mode',
        category: 'Experimental',
        requiresRestart: false,
        default: false,
        description:
          'Enable experimental voice dictation and commands (/voice, /voice model).',
        showInDialog: true,
      },
      voice: {
        type: 'object',
        label: 'Voice',
        category: 'Experimental',
        requiresRestart: false,
        default: {},
        description: 'Settings for voice mode and transcription.',
        showInDialog: false,
        properties: {
          activationMode: {
            type: 'enum',
            label: 'Voice Activation Mode',
            category: 'Experimental',
            requiresRestart: false,
            default: 'push-to-talk',
            description: 'How to trigger voice recording with the Space key.',
            showInDialog: true,
            options: [
              { value: 'push-to-talk', label: 'Push-To-Talk (Hold Space)' },
              { value: 'toggle', label: 'Toggle (Press Space to start/stop)' },
            ],
          },
          backend: {
            type: 'enum',
            label: 'Voice Transcription Backend',
            category: 'Experimental',
            requiresRestart: false,
            default: 'gemini-live',
            description: oneLine`
              The backend to use for voice transcription. Note: When using the
              Gemini Live backend, voice recordings are sent to Google Cloud for
              transcription.
            `,
            showInDialog: true,
            options: [
              { value: 'gemini-live', label: 'Gemini Live API (Cloud)' },
              { value: 'whisper', label: 'Whisper (Local)' },
            ],
          },
          whisperModel: {
            type: 'enum',
            label: 'Whisper Model',
            category: 'Experimental',
            requiresRestart: false,
            default: 'ggml-base.en.bin',
            description: 'The Whisper model to use for local transcription.',
            showInDialog: true,
            options: [
              { value: 'ggml-tiny.en.bin', label: 'Tiny (EN) - Fast (~75MB)' },
              {
                value: 'ggml-base.en.bin',
                label: 'Base (EN) - Balanced (~142MB)',
              },
              {
                value: 'ggml-large-v3-turbo-q5_0.bin',
                label: 'Large v3 Turbo (Q5_0) - High Accuracy (~547MB)',
              },
              {
                value: 'ggml-large-v3-turbo-q8_0.bin',
                label: 'Large v3 Turbo (Q8_0) - Max Accuracy (~834MB)',
              },
            ],
          },
          stopGracePeriodMs: {
            type: 'number',
            label: 'Voice Stop Grace Period (ms)',
            category: 'Experimental',
            requiresRestart: false,
            default: 4000,
            description:
              'How long to wait for final transcription after stopping recording.',
            showInDialog: true,
          },
        },
      },
      adk: {
        type: 'object',
        label: 'ADK',
        category: 'Experimental',
        requiresRestart: true,
        default: {},
        description: 'Settings for the Agent Development Kit (ADK).',
        showInDialog: false,
        properties: {
          agentSessionNoninteractiveEnabled: {
            type: 'boolean',
            label: 'Agent Session Non-interactive Enabled',
            category: 'Experimental',
            requiresRestart: true,
            default: false,
            description: 'Enable non-interactive agent sessions.',
            showInDialog: false,
          },
          agentSessionInteractiveEnabled: {
            type: 'boolean',
            label: 'Interactive Agent Session Enabled',
            category: 'Experimental',
            requiresRestart: true,
            default: false,
            description:
              'Enable the agent session implementation for the interactive CLI.',
            showInDialog: false,
          },
          agentSessionSubagentEnabled: {
            type: 'boolean',
            label: 'Agent Session Subagent Enabled',
            category: 'Experimental',
            requiresRestart: true,
            default: false,
            description:
              'Route subagent invocations through the AgentSession protocol instead of legacy executors.',
            showInDialog: false,
          },
        },
      },
      enableAgents: {
        type: 'boolean',
        label: 'Enable Agents',
        category: 'Experimental',
        requiresRestart: true,
        default: true,
        description: 'Enable local and remote subagents.',
        showInDialog: false,
      },
      worktrees: {
        type: 'boolean',
        label: 'Enable Git Worktrees',
        category: 'Experimental',
        requiresRestart: true,
        default: false,
        description:
          'Enable automated Git worktree management for parallel work.',
        showInDialog: true,
      },
      extensionManagement: {
        type: 'boolean',
        label: 'Extension Management',
        category: 'Experimental',
        requiresRestart: true,
        default: true,
        description: 'Enable extension management features.',
        showInDialog: false,
      },
      extensionConfig: {
        type: 'boolean',
        label: 'Extension Configuration',
        category: 'Experimental',
        requiresRestart: true,
        default: true,
        description: 'Enable requesting and fetching of extension settings.',
        showInDialog: false,
      },
      extensionRegistry: {
        type: 'boolean',
        label: 'Extension Registry Explore UI',
        category: 'Experimental',
        requiresRestart: true,
        default: false,
        description: 'Enable extension registry explore UI.',
        showInDialog: false,
      },
      extensionRegistryURI: {
        type: 'string',
        label: 'Extension Registry URI',
        category: 'Experimental',
        requiresRestart: true,
        default: 'https://geminicli.com/extensions.json',
        description:
          'The URI (web URL or local file path) of the extension registry.',
        showInDialog: false,
      },
      extensionReloading: {
        type: 'boolean',
        label: 'Extension Reloading',
        category: 'Experimental',
        requiresRestart: true,
        default: false,
        description:
          'Enables extension loading/unloading within the CLI session.',
        showInDialog: false,
      },
      useOSC52Paste: {
        type: 'boolean',
        label: 'Use OSC 52 Paste',
        category: 'Experimental',
        requiresRestart: false,
        default: false,
        description:
          'Use OSC 52 for pasting. This may be more robust than the default system when using remote terminal sessions (if your terminal is configured to allow it).',
        showInDialog: true,
      },
      useOSC52Copy: {
        type: 'boolean',
        label: 'Use OSC 52 Copy',
        category: 'Experimental',
        requiresRestart: false,
        default: false,
        description:
          'Use OSC 52 for copying. This may be more robust than the default system when using remote terminal sessions (if your terminal is configured to allow it).',
        showInDialog: true,
      },
      taskTracker: {
        type: 'boolean',
        label: 'Task Tracker',
        category: 'Experimental',
        requiresRestart: true,
        default: false,
        description: 'Enable task tracker tools.',
        showInDialog: false,
      },
      modelSteering: {
        type: 'boolean',
        label: 'Model Steering',
        category: 'Experimental',
        requiresRestart: false,
        default: false,
        description:
          'Enable model steering (user hints) to guide the model during tool execution.',
        showInDialog: true,
      },
      directWebFetch: {
        type: 'boolean',
        label: 'Direct Web Fetch',
        category: 'Experimental',
        requiresRestart: true,
        default: false,
        description:
          'Enable web fetch behavior that bypasses LLM summarization.',
        showInDialog: true,
      },
      dynamicModelConfiguration: {
        type: 'boolean',
        label: 'Dynamic Model Configuration',
        category: 'Experimental',
        requiresRestart: true,
        default: false,
        description:
          'Enable dynamic model configuration (definitions, resolutions, and chains) via settings.',
        showInDialog: false,
      },
      gemmaModelRouter: {
        type: 'object',
        label: 'Gemma Model Router',
        category: 'Experimental',
        requiresRestart: true,
        default: {},
        description: 'Enable Gemma model router (experimental).',
        showInDialog: false,
        properties: {
          enabled: {
            type: 'boolean',
            label: 'Enable Gemma Model Router',
            category: 'Experimental',
            requiresRestart: true,
            default: false,
            description:
              'Enable the Gemma Model Router (experimental). Requires a local endpoint serving Gemma via the Gemini API using LiteRT-LM shim.',
            showInDialog: true,
          },
          autoStartServer: {
            type: 'boolean',
            label: 'Auto-start LiteRT Server',
            category: 'Experimental',
            requiresRestart: true,
            default: false,
            description:
              'Automatically start the LiteRT-LM server when Gemini CLI starts and the Gemma router is enabled.',
            showInDialog: true,
          },
          binaryPath: {
            type: 'string',
            label: 'LiteRT Binary Path',
            category: 'Experimental',
            requiresRestart: true,
            default: '',
            description:
              'Custom path to the LiteRT-LM binary. Leave empty to use the default location (~/.gemini/bin/litert/).',
            showInDialog: false,
          },
          classifier: {
            type: 'object',
            label: 'Classifier',
            category: 'Experimental',
            requiresRestart: true,
            default: {},
            description: 'Classifier configuration.',
            showInDialog: false,
            properties: {
              host: {
                type: 'string',
                label: 'Host',
                category: 'Experimental',
                requiresRestart: true,
                default: 'http://localhost:9379',
                description: 'The host of the classifier.',
                showInDialog: false,
              },
              model: {
                type: 'string',
                label: 'Model',
                category: 'Experimental',
                requiresRestart: true,
                default: 'gemma3-1b-gpu-custom',
                description:
                  'The model to use for the classifier. Only tested on `gemma3-1b-gpu-custom`.',
                showInDialog: false,
              },
            },
          },
        },
      },
      stressTestProfile: {
        type: 'boolean',
        label:
          'Use the stress test profile to aggressively trigger context management.',
        category: 'Experimental',
        requiresRestart: true,
        default: false,
        description:
          'Significantly lowers token limits to force early garbage collection and distillation for testing purposes.',
        showInDialog: false,
      },
      autoMemory: {
        type: 'boolean',
        label: 'Auto Memory',
        category: 'Experimental',
        requiresRestart: true,
        default: false,
        description:
          'Automatically extract memory patches and skills from past sessions in the background. Every change is written as a unified diff `.patch` file under `<projectMemoryDir>/.inbox/<kind>/` and held for review in /memory inbox; nothing is applied until you approve it.',
        showInDialog: true,
      },
      generalistProfile: {
        type: 'boolean',
        label: 'Use the generalist profile to manage agent contexts.',
        category: 'Experimental',
        requiresRestart: true,
        default: false,
        description:
          'Suitable for general coding and software development tasks.',
        showInDialog: true,
      },
      powerUserProfile: {
        type: 'boolean',
        label: 'Use the power user profile to manage agent contexts.',
        category: 'Experimental',
        requiresRestart: true,
        default: false,
        description: 'Less cache friendly version of the generalist profile.',
        showInDialog: false,
      },
      contextManagement: {
        type: 'boolean',
        label: 'Enable Context Management',
        category: 'Experimental',
        requiresRestart: true,
        default: false,
        description: 'Enable logic for context management.',
        showInDialog: true,
      },
      topicUpdateNarration: {
        type: 'boolean',
        label: 'Topic & Update Narration',
        category: 'Experimental',
        requiresRestart: false,
        default: false,
        description: 'Deprecated: Use general.topicUpdateNarration instead.',
        showInDialog: false,
      },
    },
  },
  extensions: {
    type: 'object',
    label: 'Extensions',
    category: 'Extensions',
    requiresRestart: true,
    default: {},
    description: 'Settings for extensions.',
    showInDialog: false,
    properties: {
      disabled: {
        type: 'array',
        label: 'Disabled Extensions',
        category: 'Extensions',
        requiresRestart: true,
        default: [] as string[],
        description: 'List of disabled extensions.',
        showInDialog: false,
        items: { type: 'string' },
        mergeStrategy: MergeStrategy.UNION,
      },
      workspacesWithMigrationNudge: {
        type: 'array',
        label: 'Workspaces with Migration Nudge',
        category: 'Extensions',
        requiresRestart: false,
        default: [] as string[],
        description:
          'List of workspaces for which the migration nudge has been shown.',
        showInDialog: false,
        items: { type: 'string' },
        mergeStrategy: MergeStrategy.UNION,
      },
    },
  },

  skills: {
    type: 'object',
    label: 'Skills',
    category: 'Advanced',
    requiresRestart: true,
    default: {},
    description: 'Settings for agent skills.',
    showInDialog: false,
    properties: {
      enabled: {
        type: 'boolean',
        label: 'Enable Agent Skills',
        category: 'Advanced',
        requiresRestart: true,
        default: true,
        description: 'Enable Agent Skills.',
        showInDialog: true,
      },
      disabled: {
        type: 'array',
        label: 'Disabled Skills',
        category: 'Advanced',
        requiresRestart: true,
        default: [] as string[],
        description: 'List of disabled skills.',
        showInDialog: false,
        items: { type: 'string' },
        mergeStrategy: MergeStrategy.UNION,
      },
    },
  },

  hooksConfig: {
    type: 'object',
    label: 'HooksConfig',
    category: 'Advanced',
    requiresRestart: false,
    default: {},
    description:
      'Hook configurations for intercepting and customizing agent behavior.',
    showInDialog: false,
    properties: {
      enabled: {
        type: 'boolean',
        label: 'Enable Hooks',
        category: 'Advanced',
        requiresRestart: true,
        default: true,
        description:
          'Canonical toggle for the hooks system. When disabled, no hooks will be executed.',
        showInDialog: true,
      },
      disabled: {
        type: 'array',
        label: 'Disabled Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [] as string[],
        description:
          'List of hook names (commands) that should be disabled. Hooks in this list will not execute even if configured.',
        showInDialog: false,
        items: {
          type: 'string',
          description: 'Hook command name',
        },
        mergeStrategy: MergeStrategy.UNION,
      },
      notifications: {
        type: 'boolean',
        label: 'Hook Notifications',
        category: 'Advanced',
        requiresRestart: false,
        default: true,
        description: 'Show visual indicators when hooks are executing.',
        showInDialog: true,
      },
    },
  },

  hooks: {
    type: 'object',
    label: 'Hook Events',
    category: 'Advanced',
    requiresRestart: false,
    default: {},
    description: 'Event-specific hook configurations.',
    showInDialog: false,
    properties: {
      BeforeTool: {
        type: 'array',
        label: 'Before Tool Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [],
        description:
          'Hooks that execute before tool execution. Can intercept, validate, or modify tool calls.',
        showInDialog: false,
        ref: 'HookDefinitionArray',
        mergeStrategy: MergeStrategy.CONCAT,
      },
      AfterTool: {
        type: 'array',
        label: 'After Tool Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [],
        description:
          'Hooks that execute after tool execution. Can process results, log outputs, or trigger follow-up actions.',
        showInDialog: false,
        ref: 'HookDefinitionArray',
        mergeStrategy: MergeStrategy.CONCAT,
      },
      BeforeAgent: {
        type: 'array',
        label: 'Before Agent Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [],
        description:
          'Hooks that execute before agent loop starts. Can set up context or initialize resources.',
        showInDialog: false,
        ref: 'HookDefinitionArray',
        mergeStrategy: MergeStrategy.CONCAT,
      },
      AfterAgent: {
        type: 'array',
        label: 'After Agent Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [],
        description:
          'Hooks that execute after agent loop completes. Can perform cleanup or summarize results.',
        showInDialog: false,
        ref: 'HookDefinitionArray',
        mergeStrategy: MergeStrategy.CONCAT,
      },
      Notification: {
        type: 'array',
        label: 'Notification Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [],
        description:
          'Hooks that execute on notification events (errors, warnings, info). Can log or alert on specific conditions.',
        showInDialog: false,
        ref: 'HookDefinitionArray',
        mergeStrategy: MergeStrategy.CONCAT,
      },
      SessionStart: {
        type: 'array',
        label: 'Session Start Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [],
        description:
          'Hooks that execute when a session starts. Can initialize session-specific resources or state.',
        showInDialog: false,
        ref: 'HookDefinitionArray',
        mergeStrategy: MergeStrategy.CONCAT,
      },
      SessionEnd: {
        type: 'array',
        label: 'Session End Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [],
        description:
          'Hooks that execute when a session ends. Can perform cleanup or persist session data.',
        showInDialog: false,
        ref: 'HookDefinitionArray',
        mergeStrategy: MergeStrategy.CONCAT,
      },
      PreCompress: {
        type: 'array',
        label: 'Pre-Compress Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [],
        description:
          'Hooks that execute before chat history compression. Can back up or analyze conversation before compression.',
        showInDialog: false,
        ref: 'HookDefinitionArray',
        mergeStrategy: MergeStrategy.CONCAT,
      },
      BeforeModel: {
        type: 'array',
        label: 'Before Model Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [],
        description:
          'Hooks that execute before LLM requests. Can modify prompts, inject context, or control model parameters.',
        showInDialog: false,
        ref: 'HookDefinitionArray',
        mergeStrategy: MergeStrategy.CONCAT,
      },
      AfterModel: {
        type: 'array',
        label: 'After Model Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [],
        description:
          'Hooks that execute after LLM responses. Can process outputs, extract information, or log interactions.',
        showInDialog: false,
        ref: 'HookDefinitionArray',
        mergeStrategy: MergeStrategy.CONCAT,
      },
      BeforeToolSelection: {
        type: 'array',
        label: 'Before Tool Selection Hooks',
        category: 'Advanced',
        requiresRestart: false,
        default: [],
        description:
          'Hooks that execute before tool selection. Can filter or prioritize available tools dynamically.',
        showInDialog: false,
        ref: 'HookDefinitionArray',
        mergeStrategy: MergeStrategy.CONCAT,
      },
    },
    additionalProperties: {
      type: 'array',
      description:
        'Custom hook event arrays that contain hook definitions for user-defined events',
      mergeStrategy: MergeStrategy.CONCAT,
    },
  },

  contextManagement: {
    type: 'object',
    label: 'Context Management',
    category: 'Experimental',
    requiresRestart: true,
    default: {},
    description:
      'Settings for agent history and tool distillation context management.',
    showInDialog: false,
    properties: {
      historyWindow: {
        type: 'object',
        label: 'History Window Settings',
        category: 'Context Management',
        requiresRestart: true,
        default: {},
        showInDialog: false,
        properties: {
          maxTokens: {
            type: 'number',
            label: 'Max Tokens',
            category: 'Context Management',
            requiresRestart: true,
            default: 150_000,
            description:
              'The number of tokens to allow before triggering compression.',
            showInDialog: false,
          },
          retainedTokens: {
            type: 'number',
            label: 'Retained Tokens',
            category: 'Context Management',
            requiresRestart: true,
            default: 40_000,
            description: 'The number of tokens to always retain.',
            showInDialog: false,
          },
        },
      },
      messageLimits: {
        type: 'object',
        label: 'Message Limits',
        category: 'Context Management',
        requiresRestart: true,
        default: {},
        showInDialog: false,
        properties: {
          normalMaxTokens: {
            type: 'number',
            label: 'Normal Maximum Tokens',
            category: 'Context Management',
            requiresRestart: true,
            default: 2500,
            description:
              'The target number of tokens to budget for a normal conversation turn.',
            showInDialog: false,
          },
          retainedMaxTokens: {
            type: 'number',
            label: 'Retained Maximum Tokens',
            category: 'Context Management',
            requiresRestart: true,
            default: 12000,
            description:
              'The maximum number of tokens a single conversation turn can consume before truncation.',
            showInDialog: false,
          },
          normalizationHeadRatio: {
            type: 'number',
            label: 'Normalization Head Ratio',
            category: 'Context Management',
            requiresRestart: true,
            default: 0.25,
            description:
              'The ratio of tokens to retain from the beginning of a truncated message (0.0 to 1.0).',
            showInDialog: false,
          },
        },
      },
      tools: {
        type: 'object',
        label: 'Context Management Tools',
        category: 'Context Management',
        requiresRestart: true,
        default: {},
        showInDialog: false,
        properties: {
          distillation: {
            type: 'object',
            label: 'Tool Distillation',
            category: 'Context Management',
            requiresRestart: true,
            default: {},
            showInDialog: false,
            properties: {
              maxOutputTokens: {
                type: 'number',
                label: 'Max Output Tokens',
                category: 'Context Management',
                requiresRestart: true,
                default: 10_000,
                description:
                  'Maximum tokens to show to the model when truncating large tool outputs.',
                showInDialog: false,
              },
              summarizationThresholdTokens: {
                type: 'number',
                label: 'Tool Summarization Threshold',
                category: 'Context Management',
                requiresRestart: true,
                default: 20_000,
                description:
                  'Threshold above which truncated tool outputs will be summarized by an LLM.',
                showInDialog: false,
              },
            },
          },
          outputMasking: {
            type: 'object',
            label: 'Tool Output Masking',
            category: 'Context Management',
            requiresRestart: true,
            ignoreInDocs: false,
            default: {},
            description:
              'Advanced settings for tool output masking to manage context window efficiency.',
            showInDialog: false,
            properties: {
              protectionThresholdTokens: {
                type: 'number',
                label: 'Tool Protection Threshold (Tokens)',
                category: 'Context Management',
                requiresRestart: true,
                default: 50_000,
                description:
                  'Minimum number of tokens to protect from masking (most recent tool outputs).',
                showInDialog: false,
              },
              minPrunableThresholdTokens: {
                type: 'number',
                label: 'Min Prunable Tokens Threshold',
                category: 'Context Management',
                requiresRestart: true,
                default: 30_000,
                description:
                  'Minimum prunable tokens required to trigger a masking pass.',
                showInDialog: false,
              },
              protectLatestTurn: {
                type: 'boolean',
                label: 'Protect Latest Turn',
                category: 'Context Management',
                requiresRestart: true,
                default: true,
                description:
                  'Ensures the absolute latest turn is never masked, regardless of token count.',
                showInDialog: false,
              },
            },
          },
        },
      },
    },
  },

  admin: {
    type: 'object',
    label: 'Admin',
    category: 'Admin',
    requiresRestart: false,
    default: {},
    description: 'Settings configured remotely by enterprise admins.',
    showInDialog: false,
    mergeStrategy: MergeStrategy.REPLACE,
    properties: {
      secureModeEnabled: {
        type: 'boolean',
        label: 'Secure Mode Enabled',
        category: 'Admin',
        requiresRestart: false,
        default: false,
        description:
          'If true, disallows YOLO mode and "Always allow" options from being used.',
        showInDialog: false,
        mergeStrategy: MergeStrategy.REPLACE,
      },
      extensions: {
        type: 'object',
        label: 'Extensions Settings',
        category: 'Admin',
        requiresRestart: false,
        default: {},
        description: 'Extensions-specific admin settings.',
        showInDialog: false,
        mergeStrategy: MergeStrategy.REPLACE,
        properties: {
          enabled: {
            type: 'boolean',
            label: 'Extensions Enabled',
            category: 'Admin',
            requiresRestart: false,
            default: true,
            description:
              'If false, disallows extensions from being installed or used.',
            showInDialog: false,
            mergeStrategy: MergeStrategy.REPLACE,
          },
        },
      },
      mcp: {
        type: 'object',
        label: 'MCP Settings',
        category: 'Admin',
        requiresRestart: false,
        default: {},
        description: 'MCP-specific admin settings.',
        showInDialog: false,
        mergeStrategy: MergeStrategy.REPLACE,
        properties: {
          enabled: {
            type: 'boolean',
            label: 'MCP Enabled',
            category: 'Admin',
            requiresRestart: false,
            default: true,
            description: 'If false, disallows MCP servers from being used.',
            showInDialog: false,
            mergeStrategy: MergeStrategy.REPLACE,
          },
          config: {
            type: 'object',
            label: 'MCP Config',
            category: 'Admin',
            requiresRestart: false,
            default: {} as Record<string, MCPServerConfig>,
            description: 'Admin-configured MCP servers (allowlist).',
            showInDialog: false,
            mergeStrategy: MergeStrategy.REPLACE,
            additionalProperties: {
              type: 'object',
              ref: 'MCPServerConfig',
            },
          },
          requiredConfig: {
            type: 'object',
            label: 'Required MCP Config',
            category: 'Admin',
            requiresRestart: false,
            default: {} as Record<string, RequiredMcpServerConfig>,
            description: 'Admin-required MCP servers that are always injected.',
            showInDialog: false,
            mergeStrategy: MergeStrategy.REPLACE,
            additionalProperties: {
              type: 'object',
              ref: 'RequiredMcpServerConfig',
            },
          },
        },
      },
      skills: {
        type: 'object',
        label: 'Skills Settings',
        category: 'Admin',
        requiresRestart: false,
        default: {},
        description: 'Agent Skills-specific admin settings.',
        showInDialog: false,
        mergeStrategy: MergeStrategy.REPLACE,
        properties: {
          enabled: {
            type: 'boolean',
            label: 'Skills Enabled',
            category: 'Admin',
            requiresRestart: false,
            default: true,
            description: 'If false, disallows agent skills from being used.',
            showInDialog: false,
            mergeStrategy: MergeStrategy.REPLACE,
          },
        },
      },
    },
  },
} as const satisfies SettingsSchema;

export type SettingsSchemaType = typeof SETTINGS_SCHEMA;

export type SettingsJsonSchemaDefinition = Record<string, unknown>;

export const SETTINGS_SCHEMA_DEFINITIONS: Record<
  string,
  SettingsJsonSchemaDefinition
> = {
  MCPServerConfig: {
    type: 'object',
    description:
      'Definition of a Model Context Protocol (MCP) server configuration.',
    additionalProperties: false,
    properties: {
      command: {
        type: 'string',
        description: 'Executable invoked for stdio transport.',
      },
      args: {
        type: 'array',
        description: 'Command-line arguments for the stdio transport command.',
        items: { type: 'string' },
      },
      env: {
        type: 'object',
        description: 'Environment variables to set for the server process.',
        additionalProperties: { type: 'string' },
      },
      cwd: {
        type: 'string',
        description: 'Working directory for the server process.',
      },
      url: {
        type: 'string',
        description:
          'URL for SSE or HTTP transport. Use with "type" field to specify transport type.',
      },
      httpUrl: {
        type: 'string',
        description: 'Streaming HTTP transport URL.',
      },
      headers: {
        type: 'object',
        description: 'Additional HTTP headers sent to the server.',
        additionalProperties: { type: 'string' },
      },
      tcp: {
        type: 'string',
        description: 'TCP address for websocket transport.',
      },
      type: {
        type: 'string',
        description:
          'Transport type. Use "stdio" for local command, "sse" for Server-Sent Events, or "http" for Streamable HTTP.',
        enum: ['stdio', 'sse', 'http'],
      },
      timeout: {
        type: 'number',
        description: 'Timeout in milliseconds for MCP requests.',
      },
      trust: {
        type: 'boolean',
        description:
          'Marks the server as trusted. Trusted servers may gain additional capabilities.',
      },
      description: {
        type: 'string',
        description: 'Human-readable description of the server.',
      },
      includeTools: {
        type: 'array',
        description:
          'Subset of tools that should be enabled for this server. When omitted all tools are enabled.',
        items: { type: 'string' },
      },
      excludeTools: {
        type: 'array',
        description:
          'Tools that should be disabled for this server even if exposed.',
        items: { type: 'string' },
      },
      extension: {
        type: 'object',
        description:
          'Metadata describing the Gemini CLI extension that owns this MCP server.',
        additionalProperties: { type: ['string', 'boolean', 'number'] },
      },
      oauth: {
        type: 'object',
        description: 'OAuth configuration for authenticating with the server.',
        additionalProperties: true,
      },
      authProviderType: {
        type: 'string',
        description:
          'Authentication provider used for acquiring credentials (for example `dynamic_discovery`).',
        enum: Object.values(AuthProviderType),
      },
      targetAudience: {
        type: 'string',
        description:
          'OAuth target audience (CLIENT_ID.apps.googleusercontent.com).',
      },
      targetServiceAccount: {
        type: 'string',
        description:
          'Service account email to impersonate (name@project.iam.gserviceaccount.com).',
      },
    },
  },
  RequiredMcpServerConfig: {
    type: 'object',
    description:
      'Admin-required MCP server configuration (remote transports only).',
    additionalProperties: false,
    properties: {
      url: {
        type: 'string',
        description: 'URL for the required MCP server.',
      },
      type: {
        type: 'string',
        description: 'Transport type for the required server.',
        enum: ['sse', 'http'],
      },
      headers: {
        type: 'object',
        description: 'Additional HTTP headers sent to the server.',
        additionalProperties: { type: 'string' },
      },
      timeout: {
        type: 'number',
        description: 'Timeout in milliseconds for MCP requests.',
      },
      trust: {
        type: 'boolean',
        description:
          'Marks the server as trusted. Defaults to true for admin-required servers.',
      },
      description: {
        type: 'string',
        description: 'Human-readable description of the server.',
      },
      includeTools: {
        type: 'array',
        description: 'Subset of tools enabled for this server.',
        items: { type: 'string' },
      },
      excludeTools: {
        type: 'array',
        description: 'Tools disabled for this server.',
        items: { type: 'string' },
      },
      oauth: {
        type: 'object',
        description: 'OAuth configuration for authenticating with the server.',
        additionalProperties: true,
      },
      authProviderType: {
        type: 'string',
        description: 'Authentication provider used for acquiring credentials.',
        enum: Object.values(AuthProviderType),
      },
      targetAudience: {
        type: 'string',
        description:
          'OAuth target audience (CLIENT_ID.apps.googleusercontent.com).',
      },
      targetServiceAccount: {
        type: 'string',
        description:
          'Service account email to impersonate (name@project.iam.gserviceaccount.com).',
      },
    },
  },
  TelemetrySettings: {
    type: 'object',
    description: 'Telemetry configuration for Gemini CLI.',
    additionalProperties: false,
    properties: {
      enabled: {
        type: 'boolean',
        description: 'Enables telemetry emission.',
      },
      target: {
        type: 'string',
        description:
          'Telemetry destination (for example `stderr`, `stdout`, or `otlp`).',
      },
      otlpEndpoint: {
        type: 'string',
        description: 'Endpoint for OTLP exporters.',
      },
      otlpProtocol: {
        type: 'string',
        description: 'Protocol for OTLP exporters.',
        enum: ['grpc', 'http'],
      },
      traces: {
        type: 'boolean',
        description:
          'Whether detailed traces with large attributes are captured.',
      },
      logPrompts: {
        type: 'boolean',
        description: 'Whether prompts are logged in telemetry payloads.',
      },
      outfile: {
        type: 'string',
        description: 'File path for writing telemetry output.',
      },
      useCollector: {
        type: 'boolean',
        description: 'Whether to forward telemetry to an OTLP collector.',
      },
      useCliAuth: {
        type: 'boolean',
        description:
          'Whether to use CLI authentication for telemetry (only for in-process exporters).',
      },
    },
  },
  BugCommandSettings: {
    type: 'object',
    description: 'Configuration for the bug report helper command.',
    additionalProperties: false,
    properties: {
      urlTemplate: {
        type: 'string',
        description:
          'Template used to open a bug report URL. Variables in the template are populated at runtime.',
      },
    },
    required: ['urlTemplate'],
  },
  SummarizeToolOutputSettings: {
    type: 'object',
    description:
      'Controls summarization behavior for individual tools. All properties are optional.',
    additionalProperties: false,
    properties: {
      tokenBudget: {
        type: 'number',
        description:
          'Maximum number of tokens used when summarizing tool output.',
      },
    },
  },
  AgentOverride: {
    type: 'object',
    description: 'Override settings for a specific agent.',
    additionalProperties: false,
    properties: {
      modelConfig: {
        type: 'object',
        additionalProperties: true,
      },
      runConfig: {
        type: 'object',
        description: 'Run configuration for an agent.',
        additionalProperties: false,
        properties: {
          maxTimeMinutes: {
            type: 'number',
            description: 'The maximum execution time for the agent in minutes.',
          },
          maxTurns: {
            type: 'number',
            description: 'The maximum number of conversational turns.',
          },
        },
      },
      enabled: {
        type: 'boolean',
        description: 'Whether to enable the agent.',
      },
    },
  },
  CustomTheme: {
    type: 'object',
    description:
      'Custom theme definition used for styling Gemini CLI output. Colors are provided as hex strings or named ANSI colors.',
    additionalProperties: false,
    properties: {
      type: {
        type: 'string',
        enum: ['custom'],
        default: 'custom',
      },
      name: {
        type: 'string',
        description: 'Theme display name.',
      },
      text: {
        type: 'object',
        additionalProperties: false,
        properties: {
          primary: { type: 'string' },
          secondary: { type: 'string' },
          link: { type: 'string' },
          accent: { type: 'string' },
          response: { type: 'string' },
        },
      },
      background: {
        type: 'object',
        additionalProperties: false,
        properties: {
          primary: { type: 'string' },
          diff: {
            type: 'object',
            additionalProperties: false,
            properties: {
              added: { type: 'string' },
              removed: { type: 'string' },
            },
          },
        },
      },
      border: {
        type: 'object',
        additionalProperties: false,
        properties: {
          default: { type: 'string' },
          focused: { type: 'string' },
        },
      },
      ui: {
        type: 'object',
        additionalProperties: false,
        properties: {
          comment: { type: 'string' },
          symbol: { type: 'string' },
          gradient: {
            type: 'array',
            items: { type: 'string' },
          },
        },
      },
      status: {
        type: 'object',
        additionalProperties: false,
        properties: {
          error: { type: 'string' },
          success: { type: 'string' },
          warning: { type: 'string' },
        },
      },
      Background: { type: 'string' },
      Foreground: { type: 'string' },
      LightBlue: { type: 'string' },
      AccentBlue: { type: 'string' },
      AccentPurple: { type: 'string' },
      AccentCyan: { type: 'string' },
      AccentGreen: { type: 'string' },
      AccentYellow: { type: 'string' },
      AccentRed: { type: 'string' },
      DiffAdded: { type: 'string' },
      DiffRemoved: { type: 'string' },
      Comment: { type: 'string' },
      Gray: { type: 'string' },
      DarkGray: { type: 'string' },
      GradientColors: {
        type: 'array',
        items: { type: 'string' },
      },
    },
    required: ['type', 'name'],
  },
  StringOrStringArray: {
    description: 'Accepts either a single string or an array of strings.',
    anyOf: [{ type: 'string' }, { type: 'array', items: { type: 'string' } }],
  },
  BooleanOrStringOrObject: {
    description:
      'Accepts either a boolean flag, a string command name, or a configuration object.',
    anyOf: [
      { type: 'boolean' },
      { type: 'string' },
      {
        type: 'object',
        description: 'Sandbox configuration object.',
        additionalProperties: false,
        properties: {
          enabled: {
            type: 'boolean',
            description: 'Enables or disables the sandbox.',
          },
          command: {
            type: 'string',
            description:
              'The sandbox command to use (docker, podman, sandbox-exec, runsc, lxc).',
            enum: ['docker', 'podman', 'sandbox-exec', 'runsc', 'lxc'],
          },
          image: {
            type: 'string',
            description: 'The sandbox image to use.',
          },
          allowedPaths: {
            type: 'array',
            description:
              'A list of absolute host paths that should be accessible within the sandbox.',
            items: { type: 'string' },
          },
          networkAccess: {
            type: 'boolean',
            description: 'Whether the sandbox should have internet access.',
          },
        },
      },
    ],
  },
  HookDefinitionArray: {
    type: 'array',
    description: 'Array of hook definition objects for a specific event.',
    items: {
      type: 'object',
      description:
        'Hook definition specifying matcher pattern and hook configurations.',
      properties: {
        matcher: {
          type: 'string',
          description:
            'Pattern to match against the event context (tool name, notification type, etc.). Supports exact match, regex (/pattern/), and wildcards (*).',
        },
        hooks: {
          type: 'array',
          description: 'Hooks to execute when the matcher matches.',
          items: {
            type: 'object',
            description: 'Individual hook configuration.',
            properties: {
              name: {
                type: 'string',
                description: 'Unique identifier for the hook.',
              },
              type: {
                type: 'string',
                description:
                  'Type of hook (currently only "command" supported).',
              },
              command: {
                type: 'string',
                description:
                  'Shell command to execute. Receives JSON input via stdin and returns JSON output via stdout.',
              },
              description: {
                type: 'string',
                description: 'A description of the hook.',
              },
              timeout: {
                type: 'number',
                description: 'Timeout in milliseconds for hook execution.',
              },
            },
          },
        },
      },
    },
  },
  ModelDefinition: {
    type: 'object',
    description: 'Model metadata registry entry.',
    properties: {
      displayName: { type: 'string' },
      tier: { enum: ['pro', 'flash', 'flash-lite', 'custom', 'auto'] },
      family: { type: 'string' },
      isPreview: { type: 'boolean' },
      isVisible: { type: 'boolean' },
      dialogDescription: {
        type: 'string',
        description:
          "A description of the model to display in the model selection dialog. For the 'auto' alias, this value is dynamically generated and any value provided here will be ignored.",
      },
      features: {
        type: 'object',
        properties: {
          thinking: { type: 'boolean' },
          multimodalToolUse: { type: 'boolean' },
        },
      },
    },
  },
  ModelResolution: {
    type: 'object',
    description: 'Model resolution rule.',
    properties: {
      default: { type: 'string' },
      contexts: {
        type: 'array',
        items: {
          type: 'object',
          properties: {
            condition: {
              type: 'object',
              properties: {
                useGemini3_1: { type: 'boolean' },
                useGemini3_1FlashLite: { type: 'boolean' },
                useCustomTools: { type: 'boolean' },
                hasAccessToPreview: { type: 'boolean' },
                requestedModels: {
                  type: 'array',
                  items: { type: 'string' },
                },
              },
            },
            target: { type: 'string' },
          },
        },
      },
    },
  },
  ModelPolicyChain: {
    type: 'array',
    description: 'A chain of model policies for fallback behavior.',
    items: {
      type: 'object',
      ref: 'ModelPolicy',
    },
  },
  ModelPolicy: {
    type: 'object',
    description:
      'Defines the policy for a single model in the availability chain.',
    properties: {
      model: { type: 'string' },
      isLastResort: { type: 'boolean' },
      actions: {
        type: 'object',
        properties: {
          terminal: { type: 'string', enum: ['silent', 'prompt'] },
          transient: { type: 'string', enum: ['silent', 'prompt'] },
          not_found: { type: 'string', enum: ['silent', 'prompt'] },
          unknown: { type: 'string', enum: ['silent', 'prompt'] },
        },
      },
      stateTransitions: {
        type: 'object',
        properties: {
          terminal: { type: 'string', enum: ['terminal', 'sticky_retry'] },
          transient: { type: 'string', enum: ['terminal', 'sticky_retry'] },
          not_found: { type: 'string', enum: ['terminal', 'sticky_retry'] },
          unknown: { type: 'string', enum: ['terminal', 'sticky_retry'] },
        },
      },
    },
    required: ['model'],
  },
};

export function getSettingsSchema(): SettingsSchemaType {
  return SETTINGS_SCHEMA;
}

type InferSettings<T extends SettingsSchema> = {
  -readonly [K in keyof T]?: T[K] extends { properties: SettingsSchema }
    ? InferSettings<T[K]['properties']>
    : T[K]['type'] extends 'enum'
      ? T[K]['options'] extends readonly SettingEnumOption[]
        ? T[K]['options'][number]['value']
        : T[K]['default']
      : T[K]['default'] extends boolean
        ? boolean
        : T[K]['default'] extends string
          ? string
          : T[K]['default'] extends ReadonlyArray<infer U>
            ? U[]
            : T[K]['default'];
};

type InferMergedSettings<T extends SettingsSchema> = {
  -readonly [K in keyof T]-?: T[K] extends { properties: SettingsSchema }
    ? InferMergedSettings<T[K]['properties']>
    : T[K]['type'] extends 'enum'
      ? T[K]['options'] extends readonly SettingEnumOption[]
        ? T[K]['options'][number]['value']
        : T[K]['default']
      : T[K]['default'] extends boolean
        ? boolean
        : T[K]['default'] extends string
          ? string
          : T[K]['default'] extends ReadonlyArray<infer U>
            ? U[]
            : T[K]['default'];
};

export type Settings = InferSettings<SettingsSchemaType>;
export type MergedSettings = InferMergedSettings<SettingsSchemaType>;