oxios 1.8.0

Oxios Agent OS — Agent Operating System powered by oxi-sdk
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
# Oxios Agent OS — REST API Reference

> **Base URL:** `http://127.0.0.1:4200`
> **API Version:** 0.1.2
> **Body Size Limit:** 10 MB per request
> **Date:** 2026-05-17

---

## Table of Contents

1. [Authentication]#1-authentication
2. [Chat]#2-chat
3. [System]#3-system
4. [Agents]#4-agents
5. [Workspace]#5-workspace
6. [Seeds]#6-seeds
7. [Skills]#7-skills
8. [Memory]#8-memory
9. [Programs]#9-programs
10. [Scheduler]#10-scheduler
11. [Audit]#11-audit
12. [Permissions]#12-permissions
13. [Cron Jobs]#13-cron-jobs
14. [Sessions]#14-sessions
15. [Personas]#15-personas
16. [Git]#16-git
17. [Budget]#17-budget
18. [Resources]#18-resources
19. [Agent Groups]#19-agent-groups
20. [Approvals (HitL)]#20-approvals-hitl
21. [SSE Events]#21-sse-events
22. [Host Tools]#22-host-tools
23. [Metrics]#23-metrics
24. [Error Responses]#24-error-responses
25. [Rate Limiting]#25-rate-limiting
26. [Pagination]#26-pagination

---

## Overview

Oxios exposes a REST API built on Axum. All `/api/*` endpoints require Bearer token authentication (when auth is enabled). The `/health` endpoint and static assets are always public.

**Common Headers:**

| Header | Required | Description |
|---|---|---|
| `Authorization` | Yes (when auth enabled) | `Bearer <token>` |
| `Content-Type` | Yes (for POST/PUT) | `application/json` |

---

## 1. Authentication

Authentication uses Bearer tokens. When `auth_enabled` is `true` in the config, all `/api/*` endpoints require a valid token.

Tokens are validated against (in order):
1. The kernel's auth manager (registered tokens)
2. The `OXIOS_API_KEY` environment variable
3. The static API key from the config file

```sh
# Authenticate via Authorization header
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/status
```

**Unauthenticated Response:**

```json
HTTP 401 Unauthorized
```

---

## 2. Chat

### POST /api/chat

Send a message to the Oxios gateway for processing and receive a synchronous response.

**Authentication:** Required

**Request Body:**

```json
{
  "content": "Build a TODO app with React and SQLite",
  "user_id": "default",
  "session_id": ""
}
```

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `content` | `string` | Yes || The user's message. Max 64 KB. |
| `user_id` | `string` | No | `"default"` | User identifier for multi-tenant use. |
| `session_id` | `string` | No | `""` | Session ID for multi-turn conversations. |

**Response:** `200 OK`

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "echo": "Build a TODO app with React and SQLite",
  "reply": "I will help you build a TODO app...",
  "session_id": "abc-123-def",
  "phase": "code"
}
```

| Field | Type | Description |
|---|---|---|
| `id` | `string` | Message ID (UUID). |
| `echo` | `string` | Echo of the user's original message. |
| `reply` | `string` | The orchestrator's response. |
| `session_id` | `string?` | Session ID for multi-turn conversations. |
| `phase` | `string?` | Phase reached during orchestration. |

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/chat \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Build a TODO app with React and SQLite",
    "user_id": "alice",
    "session_id": "session-42"
  }'
```

### GET /api/chat/stream

WebSocket endpoint for real-time bidirectional chat streaming.

**Authentication:** Required (via `token` query parameter)

**Query Parameters:**

| Parameter | Type | Required | Description |
|---|---|---|---|
| `token` | `string` | Yes (when auth enabled) | Bearer token for authentication. |

**Protocol:**

- Client sends text messages (plain text content).
- Server broadcasts JSON-encoded kernel events.
- Connection is bidirectional: client sends, server streams events back.

**Example:**

```sh
# Connect via wscat
wscat -c "ws://127.0.0.1:4200/api/chat/stream?token=YOUR_TOKEN"
```

**JavaScript Example:**

```javascript
const ws = new WebSocket('ws://127.0.0.1:4200/api/chat/stream?token=YOUR_TOKEN');

ws.onopen = () => {
  ws.send('Build a REST API with Rust');
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('Event:', data);
};
```

---

## 3. System

### GET /health

Health check endpoint. **No authentication required.**

**Response:** `200 OK`

```json
{
  "status": "ok",
  "version": "0.2.0-alpha"
}
```

**Example:**

```sh
curl http://127.0.0.1:4200/health
```

### GET /api/status

System status with component-level health details.

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "service": "oxios",
  "status": "running",
  "version": "0.2.0-alpha",
  "channels": ["web"],
  "uptime": "2h 15m 30s",
  "components": {
    "state_store": {
      "healthy": true,
      "detail": null
    },
    "event_bus": {
      "healthy": true,
      "detail": null
    },
    "memory": {
      "enabled": true,
      "index_size": 128,
      "total_entries": 512
    },
    "agents": {
      "active_count": 3,
      "total_forked": 42,
      "total_completed": 38,
      "total_failed": 1
    }
  }
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/status
```

### GET /api/config

Get the current Oxios configuration.

**Authentication:** Required

**Response:** `200 OK`

Returns the full `OxiosConfig` object serialized as JSON. Shape depends on config schema.

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/config
```

### PUT /api/config

Update the configuration. Validates the incoming JSON, persists to disk, and hot-reloads in memory.

**Authentication:** Required

**Request Body:** A valid `OxiosConfig` JSON object.

**Response:** `200 OK` — Returns the submitted config JSON.

```json
{
  "server": { "host": "127.0.0.1", "port": 4200 },
  "security": { "auth_enabled": true }
}
```

**Error Response:** `400 Bad Request` if the config shape is invalid.

**Example:**

```sh
curl -X PUT http://127.0.0.1:4200/api/config \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "server": { "host": "0.0.0.0", "port": 4200 },
    "security": { "auth_enabled": false }
  }'
```

---

## 4. Agents

### GET /api/agents

List all agent instances (paginated).

**Authentication:** Required

**Query Parameters:**

| Parameter | Type | Default | Description |
|---|---|---|---|
| `page` | `integer` | `1` | Page number (1-indexed). |
| `limit` | `integer` | `50` | Items per page (max 500). |

**Response:** `200 OK`

```json
{
  "items": [
    {
      "id": "agent-550e8400",
      "name": "build-todo-app",
      "status": "Running",
      "created_at": "2026-05-17T10:30:00+00:00",
      "seed_id": "seed-abc-123"
    }
  ],
  "total": 42,
  "page": 1,
  "limit": 50
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  "http://127.0.0.1:4200/api/agents?page=1&limit=10"
```

### POST /api/agents/{id}/kill

Kill a running agent.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string` | Agent ID to kill. |

**Response:** `200 OK` (empty body on success)

**Error Response:** `404 Not Found` if agent doesn't exist.

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/agents/agent-550e8400/kill \
  -H "Authorization: Bearer YOUR_TOKEN"
```

---

## 5. Workspace

### GET /api/workspace/tree

List the file tree of the workspace directory.

**Authentication:** Required

**Query Parameters:**

| Parameter | Type | Required | Description |
|---|---|---|---|
| `dir` | `string` | No | Subdirectory to list (relative to workspace root). |

**Response:** `200 OK`

```json
[
  {
    "name": "src",
    "is_dir": true,
    "size": 0
  },
  {
    "name": "Cargo.toml",
    "is_dir": false,
    "size": 512
  },
  {
    "name": "README.md",
    "is_dir": false,
    "size": 2048
  }
]
```

Directories are sorted before files; entries are sorted alphabetically within each group.

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  "http://127.0.0.1:4200/api/workspace/tree?dir=src"
```

### GET /api/workspace/file/{*path}

Read a file from the workspace.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `*path` | `string` | Relative file path within the workspace. |

**Response:** `200 OK` — File content with appropriate `Content-Type` header.

Supported MIME types: `.md` → `text/markdown`, `.json` → `application/json`, `.toml` → `application/toml`, `.yaml`/`.yml` → `application/yaml`, `.txt` → `text/plain`, `.html` → `text/html`, `.css` → `text/css`, `.js` → `application/javascript`. All others default to `text/plain`.

**Error Response:** `404 Not Found` or `403 Forbidden` (path traversal denied).

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/workspace/file/src/main.rs
```

### PUT /api/workspace/file/{*path}

Write or update a file in the workspace. Max body size: 1 MB.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `*path` | `string` | Relative file path within the workspace. |

**Request Body:** Plain text content (body is the file content).

**Response:** `200 OK` (empty body on success)

**Error Response:** `403 Forbidden` (path traversal), `413 Payload Too Large` (> 1 MB).

**Example:**

```sh
curl -X PUT http://127.0.0.1:4200/api/workspace/file/src/main.rs \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: text/plain" \
  -d 'fn main() { println!("Hello, Oxios!"); }'
```

---

## 6. Seeds

### GET /api/seeds

List Ouroboros seeds (paginated).

**Authentication:** Required

**Query Parameters:**

| Parameter | Type | Default | Description |
|---|---|---|---|
| `page` | `integer` | `1` | Page number (1-indexed). |
| `limit` | `integer` | `50` | Items per page (max 500). |

**Response:** `200 OK`

```json
{
  "items": [
    {
      "id": "seed-550e8400",
      "goal": "Build a REST API",
      "constraints_count": 3,
      "created_at": "2026-05-17T10:30:00+00:00"
    }
  ],
  "total": 15,
  "page": 1,
  "limit": 50
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  "http://127.0.0.1:4200/api/seeds?page=1&limit=20"
```

### GET /api/seeds/{id}

Get a specific seed by ID.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string` | Seed ID. |

**Response:** `200 OK`

For JSON-format seeds:

```json
{
  "id": "seed-550e8400",
  "goal": "Build a REST API",
  "constraints": ["Use Rust", "Include tests"],
  "created_at": "2026-05-17T10:30:00+00:00",
  "generation": 2,
  "parent_seed_id": "seed-parent-001"
}
```

For markdown-format seeds:

```json
{
  "id": "my-seed",
  "content": "# My Seed\nBuild something great..."
}
```

**Error Response:** `404 Not Found`

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/seeds/seed-550e8400
```

### GET /api/seeds/{id}/evolution

Get the evolution lineage for a seed (parent chain traced back to root).

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string` | Seed ID. |

**Response:** `200 OK`

```json
[
  {
    "id": "seed-root",
    "generation": 0,
    "goal": "Build a REST API",
    "parent_id": null,
    "score": 0.72,
    "passed": false
  },
  {
    "id": "seed-gen1",
    "generation": 1,
    "goal": "Build a REST API with proper error handling",
    "parent_id": "seed-root",
    "score": 0.89,
    "passed": true
  },
  {
    "id": "seed-550e8400",
    "generation": 2,
    "goal": "Build a production-ready REST API with tests",
    "parent_id": "seed-gen1",
    "score": 0.95,
    "passed": true
  }
]
```

Entries are ordered from root (oldest) to child (newest).

**Error Response:** `404 Not Found`

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/seeds/seed-550e8400/evolution
```

---

## 7. Skills

### GET /api/skills

List all registered skills (paginated).

**Authentication:** Required

**Query Parameters:**

| Parameter | Type | Default | Description |
|---|---|---|---|
| `page` | `integer` | `1` | Page number. |
| `limit` | `integer` | `50` | Items per page (max 500). |

**Response:** `200 OK`

```json
{
  "items": [
    {
      "name": "code-review",
      "description": "Review code changes and provide feedback"
    },
    {
      "name": "deploy",
      "description": "Deploy the application to production"
    }
  ],
  "total": 2,
  "page": 1,
  "limit": 50
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/skills
```

### GET /api/skills/{name}

Get a specific skill's full content.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `name` | `string` | Skill name. |

**Response:** `200 OK`

```json
{
  "name": "code-review",
  "description": "Review code changes and provide feedback",
  "content": "# Code Review Skill\n\n## Steps\n1. Read diff...",
  "path": "/workspace/.oxios/skills/code-review.md"
}
```

**Error Response:** `404 Not Found`

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/skills/code-review
```

### POST /api/skills

Create a new skill. Max content size: 64 KB.

**Authentication:** Required

**Request Body:**

```json
{
  "name": "deploy",
  "description": "Deploy the application to production",
  "content": "# Deploy Skill\n\n## Steps\n1. Run tests\n2. Build\n3. Deploy"
}
```

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `name` | `string` | Yes || Skill name (unique identifier). |
| `description` | `string` | Yes || Human-readable description. |
| `content` | `string` | No | `""` | Markdown content. Max 64 KB. |

**Response:** `200 OK`

```json
{
  "status": "created",
  "name": "deploy"
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/skills \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "deploy",
    "description": "Deploy the application to production",
    "content": "# Deploy Skill\n\n1. Run tests\n2. Build\n3. Deploy"
  }'
```

### DELETE /api/skills/{name}

Delete a skill.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `name` | `string` | Skill name. |

**Response:** `200 OK`

```json
{
  "status": "deleted",
  "name": "deploy"
}
```

**Example:**

```sh
curl -X DELETE http://127.0.0.1:4200/api/skills/deploy \
  -H "Authorization: Bearer YOUR_TOKEN"
```

---

## 8. Memory

### GET /api/memory

List all memory entries (paginated). Includes both daily memory and knowledge base entries.

**Authentication:** Required

**Query Parameters:**

| Parameter | Type | Default | Description |
|---|---|---|---|
| `page` | `integer` | `1` | Page number. |
| `limit` | `integer` | `50` | Items per page (max 500). |

**Response:** `200 OK`

```json
{
  "items": [
    {
      "name": "2026-05-17",
      "category": "daily"
    },
    {
      "name": "rust-patterns",
      "category": "knowledge"
    }
  ],
  "total": 25,
  "page": 1,
  "limit": 50
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  "http://127.0.0.1:4200/api/memory?page=1&limit=20"
```

### GET /api/memory/{name}

Get a specific memory entry by name.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `name` | `string` | Memory entry name. Searches `memory/` then `memory/knowledge/`. |

**Response:** `200 OK`

```json
{
  "name": "rust-patterns",
  "category": "knowledge",
  "content": "# Rust Patterns\n\n## Builder Pattern\n..."
}
```

**Error Response:** `404 Not Found`

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/memory/rust-patterns
```

### POST /api/memory

Create a new memory entry. Max content size: 32 KB.

**Authentication:** Required

**Request Body:**

```json
{
  "content": "Oxios uses an event-driven architecture with a broadcast bus.",
  "memory_type": "fact",
  "tags": ["architecture", "events"],
  "importance": 0.8
}
```

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `content` | `string` | Yes || Memory content. Max 32 KB. |
| `memory_type` | `string` | No | `"fact"` | One of: `fact`, `episode`, `knowledge`. |
| `tags` | `string[]` | No | `[]` | Tags for categorization. |
| `importance` | `float` | No | `0.5` | Importance score (0.0–1.0). |

**Response:** `200 OK`

```json
{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "status": "created"
}
```

**Error Response:** `400 Bad Request` if `memory_type` is invalid.

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/memory \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Oxios uses an event-driven architecture",
    "memory_type": "fact",
    "tags": ["architecture"],
    "importance": 0.8
  }'
```

### POST /api/memory/search

Search memory entries by keyword.

**Authentication:** Required

**Request Body:**

```json
{
  "query": "architecture",
  "memory_type": "fact",
  "limit": 10
}
```

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `query` | `string` | Yes || Search query string. |
| `memory_type` | `string` | No | `null` | Filter by type: `conversation`, `session`, `fact`, `episode`, `knowledge`. |
| `limit` | `integer` | No | `10` | Maximum results. |

**Response:** `200 OK`

```json
{
  "count": 2,
  "entries": [
    {
      "id": "a1b2c3d4",
      "type": "fact",
      "content": "Oxios uses an event-driven architecture",
      "tags": ["architecture"],
      "importance": 0.8,
      "created_at": "2026-05-17T10:30:00+00:00"
    }
  ]
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/memory/search \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "architecture", "limit": 5}'
```

### POST /api/memory/semantic

Semantic search using HNSW approximate nearest neighbor index.

**Authentication:** Required

**Request Body:**

```json
{
  "query": "How does the event system work?",
  "memory_type": null,
  "limit": 10
}
```

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `query` | `string` | Yes || Natural language query. |
| `memory_type` | `string` | No | `null` | Filter by type. |
| `limit` | `integer` | No | `10` | Maximum results. |

**Response:** `200 OK`

```json
{
  "count": 3,
  "entries": [
    {
      "id": "a1b2c3d4",
      "type": "fact",
      "content": "Oxios uses an event-driven architecture with a broadcast bus.",
      "tags": ["architecture", "events"],
      "importance": 0.8,
      "similarity": 0.94,
      "distance": 0.06,
      "created_at": "2026-05-17T10:30:00+00:00"
    }
  ],
  "engine": "hnsw"
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/memory/semantic \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"query": "How does the event system work?", "limit": 5}'
```

---

## 9. Programs

### GET /api/programs

List all installed programs (paginated).

**Authentication:** Required

**Query Parameters:**

| Parameter | Type | Default | Description |
|---|---|---|---|
| `page` | `integer` | `1` | Page number. |
| `limit` | `integer` | `50` | Items per page (max 500). |

**Response:** `200 OK`

```json
{
  "items": [
    {
      "name": "my-program",
      "version": "1.0.0",
      "description": "A custom Oxios program",
      "author": "oxios",
      "enabled": true,
      "tools_count": 3,
      "has_skill_content": true
    }
  ],
  "total": 5,
  "page": 1,
  "limit": 50
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/programs
```

### POST /api/programs

Install a program from a remote source (Git URL or tarball URL). Local path installation is not allowed via API.

**Authentication:** Required

**Request Body:**

```json
{
  "path": "https://example.com/my-program.tar.gz"
}
```

| Field | Type | Required | Description |
|---|---|---|---|
| `path` | `string` | Yes | Git URL (`.git` suffix or `git@` prefix) or HTTP(S) tarball URL. Max 8192 chars. |

**Response:** `200 OK`

```json
{
  "status": "installed",
  "name": "my-program",
  "version": "1.0.0"
}
```

**Error Response:** `400 Bad Request` for invalid source or installation failure.

**Example:**

```sh
# Install from tarball
curl -X POST http://127.0.0.1:4200/api/programs \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"path": "https://example.com/my-program.tar.gz"}'

# Install from Git
curl -X POST http://127.0.0.1:4200/api/programs \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"path": "https://github.com/example/oxios-program.git"}'
```

### GET /api/programs/{name}

Get detailed information about a specific program.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `name` | `string` | Program name. |

**Response:** `200 OK`

```json
{
  "name": "my-program",
  "version": "1.0.0",
  "description": "A custom Oxios program",
  "author": "oxios",
  "enabled": true,
  "tools": [
    {
      "name": "analyze",
      "description": "Analyze code quality"
    }
  ],
  "skill_content": "# My Program Skill\n...",
  "path": "/workspace/.oxios/programs/my-program"
}
```

**Error Response:** `404 Not Found`

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/programs/my-program
```

### DELETE /api/programs/{name}

Uninstall a program.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `name` | `string` | Program name. |

**Response:** `200 OK`

```json
{
  "status": "uninstalled",
  "name": "my-program"
}
```

**Example:**

```sh
curl -X DELETE http://127.0.0.1:4200/api/programs/my-program \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### POST /api/programs/{name}/enable

Enable a disabled program.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `name` | `string` | Program name. |

**Response:** `200 OK`

```json
{
  "status": "enabled",
  "name": "my-program"
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/programs/my-program/enable \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### POST /api/programs/{name}/disable

Disable a program (without uninstalling).

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `name` | `string` | Program name. |

**Response:** `200 OK`

```json
{
  "status": "disabled",
  "name": "my-program"
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/programs/my-program/disable \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### GET /api/programs/{name}/host-requirements

Check host requirements for a program.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `name` | `string` | Program name. |

**Response:** `200 OK` — Returns the host requirements check result (shape depends on program manifest).

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/programs/my-program/host-requirements
```

---

## 10. Scheduler

### GET /api/scheduler/stats

Get scheduler statistics.

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "queued": 5,
  "running": 2,
  "max_concurrent": 10,
  "rate_limit_per_minute": 60,
  "rate_remaining": 45
}
```

| Field | Type | Description |
|---|---|---|
| `queued` | `integer` | Number of tasks waiting in the queue. |
| `running` | `integer` | Number of currently executing tasks. |
| `max_concurrent` | `integer` | Maximum concurrent tasks allowed. |
| `rate_limit_per_minute` | `integer` | Rate limit (requests per minute). |
| `rate_remaining` | `integer` | Remaining requests in current window. |

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/scheduler/stats
```

### GET /api/scheduler/tasks

List queued and running tasks.

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "queued": [
    {
      "id": "task-001",
      "description": "Build TODO app",
      "priority": "High",
      "status": "Queued",
      "created_at": "2026-05-17T10:30:00+00:00",
      "error": null
    }
  ],
  "running": [
    {
      "id": "task-002",
      "description": "Refactor auth module",
      "priority": "Normal",
      "status": "Running",
      "created_at": "2026-05-17T10:25:00+00:00",
      "error": null
    }
  ]
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/scheduler/tasks
```

---

## 11. Audit

### GET /api/audit/entries

Query audit trail entries within a sequence range.

**Authentication:** Required

**Query Parameters:**

| Parameter | Type | Default | Description |
|---|---|---|---|
| `from_seq` | `integer` | `0` | Starting sequence number (inclusive). |
| `to_seq` | `integer` | `100` | Ending sequence number (inclusive). |

**Response:** `200 OK`

```json
{
  "entries": [
    {
      "seq": 1,
      "timestamp": "2026-05-17T10:30:00+00:00",
      "agent_name": "builder-agent",
      "action": "file_write",
      "resource": "/workspace/src/main.rs",
      "allowed": true,
      "hash": "sha256:abc123...",
      "prev_hash": "sha256:def456..."
    }
  ],
  "count": 1
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  "http://127.0.0.1:4200/api/audit/entries?from_seq=0&to_seq=50"
```

### GET /api/audit/verify

Verify the cryptographic hash chain integrity of the entire audit trail.

**Authentication:** Required

**Response (valid chain):** `200 OK`

```json
{
  "valid": true,
  "entry_count": 150
}
```

**Response (broken chain):** `200 OK`

```json
{
  "valid": false,
  "entry_count": 150,
  "broken_at_seq": 42,
  "expected": "sha256:abc123...",
  "found": "sha256:def456..."
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/audit/verify
```

### GET /api/audit/agent/{agent_id}

Query all audit entries for a specific agent.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `agent_id` | `string` | Agent identifier. |

**Response:** `200 OK`

```json
{
  "entries": [
    {
      "seq": 5,
      "agent_name": "builder-agent",
      "action": "file_write",
      "resource": "/workspace/src/main.rs",
      "allowed": true
    }
  ],
  "count": 1
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/audit/agent/builder-agent
```

### POST /api/audit/export

Export audit entries as JSON starting from a sequence number.

**Authentication:** Required

**Request Body:**

```json
{
  "from_seq": 0
}
```

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `from_seq` | `integer` | No | `0` | Starting sequence number. |

**Response:** `200 OK`

```json
{
  "json": "[{\"seq\":0,...},{\"seq\":1,...}]",
  "entry_count": 150
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/audit/export \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"from_seq": 100}'
```

### POST /api/audit/flush

Flush in-memory audit entries to the StateStore for persistence.

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "flushed": 150
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/audit/flush \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### GET /api/audit

Legacy audit log endpoint (paginated). Returns security audit entries in reverse chronological order.

**Authentication:** Required

**Query Parameters:**

| Parameter | Type | Default | Description |
|---|---|---|---|
| `page` | `integer` | `1` | Page number. |
| `limit` | `integer` | `50` | Items per page (max 500). |

**Response:** `200 OK`

```json
{
  "items": [
    {
      "timestamp": "2026-05-17T10:30:00+00:00",
      "agent_name": "builder-agent",
      "action": "file_write",
      "resource": "/workspace/src/main.rs",
      "allowed": true,
      "reason": null
    }
  ],
  "total": 150,
  "page": 1,
  "limit": 50
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  "http://127.0.0.1:4200/api/audit?page=1&limit=20"
```

---

## 12. Permissions

### GET /api/permissions/{agent}

Get permissions for a specific agent.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `agent` | `string` | Agent name. |

**Response:** `200 OK`

```json
{
  "agent_name": "builder-agent",
  "allowed_tools": ["file_read", "file_write", "shell_exec"],
  "allowed_paths": ["/workspace/src"],
  "denied_paths": ["/etc", "/root"],
  "network_access": true,
  "max_execution_time_secs": 300,
  "max_memory_mb": 512,
  "can_fork": false
}
```

**Error Response:** `404 Not Found`

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/permissions/builder-agent
```

### PUT /api/permissions/{agent}

Update permissions for a specific agent.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `agent` | `string` | Agent name. |

**Request Body:**

```json
{
  "allowed_tools": ["file_read", "file_write"],
  "allowed_paths": ["/workspace/src"],
  "denied_paths": ["/etc"],
  "network_access": false,
  "max_execution_time_secs": 120,
  "max_memory_mb": 256,
  "can_fork": false
}
```

All fields are optional — only provided fields will be updated.

**Response:** `200 OK`

```json
{
  "status": "updated",
  "agent": "builder-agent"
}
```

**Example:**

```sh
curl -X PUT http://127.0.0.1:4200/api/permissions/builder-agent \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "network_access": false,
    "max_execution_time_secs": 120
  }'
```

---

## 13. Cron Jobs

### GET /api/cron-jobs

List all cron jobs.

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "jobs": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "daily-backup",
      "schedule": "0 0 * * * *",
      "goal": "Create a backup of the workspace",
      "constraints": ["Include all source files"],
      "toolchain": "default",
      "priority": "Normal",
      "last_run": "2026-05-17T00:00:00+00:00",
      "last_success": true
    }
  ]
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/cron-jobs
```

### POST /api/cron-jobs

Create a new cron job.

**Authentication:** Required

**Request Body:**

```json
{
  "name": "daily-backup",
  "schedule": "0 0 * * * *",
  "goal": "Create a backup of the workspace",
  "constraints": ["Include all source files"],
  "acceptance_criteria": ["Backup file exists"],
  "toolchain": "default",
  "priority": "Normal"
}
```

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `name` | `string` | Yes || Human-readable job name. |
| `schedule` | `string` | Yes || Cron expression (6-field: sec min hour day month weekday). |
| `goal` | `string` | Yes || The goal/prompt to execute. |
| `constraints` | `string[]` | No | `[]` | Optional constraints. |
| `acceptance_criteria` | `string[]` | No | `[]` | Optional acceptance criteria. |
| `toolchain` | `string` | No | `"default"` | Toolchain to use. |
| `priority` | `string` | No | `"Normal"` | Priority: `Low`, `Normal`, `High`, `Critical`. |

**Response:** `200 OK`

```json
{
  "id": "550e8400-e29b-41d4-a716-446655440000"
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/cron-jobs \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "daily-backup",
    "schedule": "0 0 * * * *",
    "goal": "Create a backup of the workspace",
    "constraints": ["Include all source files"]
  }'
```

### GET /api/cron-jobs/{id}

Get a specific cron job.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string (UUID)` | Cron job ID. |

**Response:** `200 OK` — Returns the full `CronJob` object.

**Error Response:** `404 Not Found`

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/cron-jobs/550e8400-e29b-41d4-a716-446655440000
```

### DELETE /api/cron-jobs/{id}

Delete a cron job.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string (UUID)` | Cron job ID. |

**Response:** `200 OK`

```json
{
  "deleted": "550e8400-e29b-41d4-a716-446655440000"
}
```

**Example:**

```sh
curl -X DELETE http://127.0.0.1:4200/api/cron-jobs/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### POST /api/cron-jobs/{id}/edit

Update a cron job's configuration.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string (UUID)` | Cron job ID. |

**Request Body:** A `CronJobUpdate` object with optional fields to update.

**Response:** `200 OK`

```json
{
  "updated": "550e8400-e29b-41d4-a716-446655440000"
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/cron-jobs/550e8400-e29b-41d4-a716-446655440000/edit \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"schedule": "0 */6 * * * *"}'
```

### POST /api/cron-jobs/{id}/trigger

Manually trigger a cron job execution.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string (UUID)` | Cron job ID. |

**Response:** `200 OK`

```json
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "success": true,
  "summary": "Backup completed successfully. 42 files backed up."
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/cron-jobs/550e8400-e29b-41d4-a716-446655440000/trigger \
  -H "Authorization: Bearer YOUR_TOKEN"
```

---

## 14. Sessions

### GET /api/sessions

List recent sessions (paginated).

**Authentication:** Required

**Query Parameters:**

| Parameter | Type | Default | Description |
|---|---|---|---|
| `page` | `integer` | `1` | Page number. |
| `limit` | `integer` | `50` | Items per page (max 500). |

**Response:** `200 OK`

```json
{
  "items": [
    {
      "id": "session-abc-123",
      "user_id": "alice",
      "message_count": 5,
      "active_seed_id": "seed-550e8400",
      "created_at": "2026-05-17T10:00:00+00:00",
      "updated_at": "2026-05-17T10:30:00+00:00"
    }
  ],
  "total": 20,
  "page": 1,
  "limit": 50
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  "http://127.0.0.1:4200/api/sessions?page=1&limit=10"
```

### GET /api/sessions/{id}

Get a session with full message history.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string` | Session ID. |

**Response:** `200 OK`

```json
{
  "id": "session-abc-123",
  "user_id": "alice",
  "user_messages": ["Build a TODO app", "Add tests"],
  "agent_responses": [
    {
      "content": "I will help you build a TODO app...",
      "session_id": "session-abc-123",
      "seed_id": "seed-550e8400",
      "phase_reached": "code",
      "evaluation_passed": true,
      "timestamp": "2026-05-17T10:15:00+00:00"
    }
  ],
  "active_seed_id": "seed-550e8400",
  "active_persona_id": "persona-dev",
  "created_at": "2026-05-17T10:00:00+00:00",
  "updated_at": "2026-05-17T10:30:00+00:00",
  "metadata": {}
}
```

**Error Response:** `404 Not Found`

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/sessions/session-abc-123
```

### DELETE /api/sessions/{id}

Delete a session.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string` | Session ID. |

**Response:** `200 OK`

```json
{
  "status": "deleted",
  "id": "session-abc-123"
}
```

**Error Response:** `404 Not Found`

**Example:**

```sh
curl -X DELETE http://127.0.0.1:4200/api/sessions/session-abc-123 \
  -H "Authorization: Bearer YOUR_TOKEN"
```

---

## 15. Personas

### GET /api/personas

List all personas.

**Authentication:** Required

**Response:** `200 OK`

```json
[
  {
    "id": "persona-dev",
    "name": "Developer",
    "role": "Software Engineer",
    "description": "A skilled software developer persona",
    "enabled": true,
    "personality_traits": ["analytical", "thorough", "pragmatic"]
  },
  {
    "id": "persona-creative",
    "name": "Creative",
    "role": "Designer",
    "description": "A creative design-focused persona",
    "enabled": true,
    "personality_traits": ["creative", "visual", "empathetic"]
  }
]
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/personas
```

### POST /api/personas

Create a new persona.

**Authentication:** Required

**Request Body:**

```json
{
  "name": "Reviewer",
  "role": "Code Reviewer",
  "description": "A thorough code review specialist",
  "system_prompt": "You are an expert code reviewer...",
  "enabled": true,
  "model": "gpt-4",
  "personality_traits": ["detail-oriented", "constructive"]
}
```

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `name` | `string` | Yes || Persona display name. |
| `role` | `string` | Yes || Persona role. |
| `description` | `string` | Yes || Description. |
| `system_prompt` | `string` | No | `""` | System prompt for LLM. |
| `enabled` | `boolean` | No | `true` | Whether the persona is enabled. |
| `model` | `string` | No | `null` | Preferred LLM model. |
| `personality_traits` | `string[]` | No | `[]` | Personality descriptors. |

**Response:** `200 OK`

```json
{
  "status": "created",
  "id": "a1b2c3d4-e5f6-7890",
  "name": "Reviewer"
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/personas \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Reviewer",
    "role": "Code Reviewer",
    "description": "A thorough code review specialist",
    "system_prompt": "You are an expert code reviewer."
  }'
```

### GET /api/personas/{id}

Get a specific persona with full details.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string` | Persona ID. |

**Response:** `200 OK`

```json
{
  "id": "persona-dev",
  "name": "Developer",
  "role": "Software Engineer",
  "description": "A skilled software developer persona",
  "system_prompt": "You are an expert software developer...",
  "enabled": true,
  "model": "gpt-4",
  "personality_traits": ["analytical", "thorough"]
}
```

**Error Response:** `404 Not Found`

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/personas/persona-dev
```

### PUT /api/personas/{id}

Update a persona. Only provided fields are updated.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string` | Persona ID. |

**Request Body:**

```json
{
  "name": "Senior Developer",
  "system_prompt": "You are a senior software engineer...",
  "enabled": true
}
```

All fields are optional (partial update).

**Response:** `200 OK`

```json
{
  "status": "updated",
  "id": "persona-dev"
}
```

**Example:**

```sh
curl -X PUT http://127.0.0.1:4200/api/personas/persona-dev \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Senior Developer", "enabled": true}'
```

### DELETE /api/personas/{id}

Delete a persona. Cannot delete the last remaining persona.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string` | Persona ID. |

**Response:** `200 OK`

```json
{
  "status": "deleted",
  "id": "persona-creative"
}
```

**Error Response:** `400 Bad Request` if deleting the last persona. `404 Not Found` if persona doesn't exist.

**Example:**

```sh
curl -X DELETE http://127.0.0.1:4200/api/personas/persona-creative \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### GET /api/personas/active

Get the currently active persona.

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "id": "persona-dev",
  "name": "Developer",
  "role": "Software Engineer",
  "description": "A skilled software developer persona",
  "system_prompt": "You are an expert software developer...",
  "enabled": true
}
```

**Response (no active persona):**

```json
{
  "active": false,
  "message": "No active persona set"
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/personas/active
```

### PUT /api/personas/active

Set the active persona.

**Authentication:** Required

**Request Body:**

```json
{
  "id": "persona-dev"
}
```

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | `string` | Yes | Persona ID to activate. |

**Response:** `200 OK`

```json
{
  "status": "active",
  "id": "persona-dev",
  "name": "Developer"
}
```

**Example:**

```sh
curl -X PUT http://127.0.0.1:4200/api/personas/active \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"id": "persona-dev"}'
```

---

## 16. Git

### GET /api/git/log

Get the commit log (up to 100 entries).

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "entries": [
    {
      "hash": "abc123def456",
      "author": "oxios-agent",
      "message": "feat: add TODO app components",
      "timestamp": "2026-05-17T10:30:00+00:00"
    }
  ]
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/git/log
```

### GET /api/git/tags

List all Git tags.

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "tags": ["v0.1.0", "0.1.2", "seed-evolution-3"]
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/git/tags
```

### POST /api/git/verify

Verify repository integrity.

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "valid": true
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/git/verify \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### POST /api/git/restore

Restore a file to its state at a specific commit.

**Authentication:** Required

**Request Body:**

```json
{
  "hash": "abc123def456",
  "path": "src/main.rs"
}
```

| Field | Type | Required | Description |
|---|---|---|---|
| `hash` | `string` | Yes | Commit hash to restore from. |
| `path` | `string` | Yes | Relative file path to restore. |

**Response:** `200 OK`

```json
{
  "restored": "src/main.rs",
  "from": "abc123def456"
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/git/restore \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"hash": "abc123def456", "path": "src/main.rs"}'
```

---

## 17. Budget

### GET /api/budget/{agent_id}

Get budget status for an agent.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `agent_id` | `string` | Agent identifier. |

**Response:** `200 OK`

```json
{
  "agent_id": "builder-agent",
  "tokens_remaining": 45000,
  "calls_remaining": 95,
  "window_remaining_secs": 3420,
  "is_exhausted": false
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/budget/builder-agent
```

### POST /api/budget/{agent_id}

Set budget limits for an agent.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `agent_id` | `string` | Agent identifier. |

**Request Body:**

```json
{
  "token_budget": 50000,
  "calls_budget": 100,
  "window_secs": 3600
}
```

| Field | Type | Required | Description |
|---|---|---|---|
| `token_budget` | `integer` | Yes | Maximum tokens allowed in window. |
| `calls_budget` | `integer` | Yes | Maximum API calls in window. |
| `window_secs` | `integer` | Yes | Budget window duration in seconds. |

**Response:** `200 OK`

```json
{
  "set": true,
  "agent_id": "builder-agent"
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/budget/builder-agent \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"token_budget": 50000, "calls_budget": 100, "window_secs": 3600}'
```

### DELETE /api/budget/{agent_id}

Remove budget limits for an agent.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `agent_id` | `string` | Agent identifier. |

**Response:** `200 OK`

```json
{
  "removed": true,
  "agent_id": "builder-agent"
}
```

**Example:**

```sh
curl -X DELETE http://127.0.0.1:4200/api/budget/builder-agent \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### POST /api/budget/{agent_id}/reserve

Reserve tokens from an agent's budget.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `agent_id` | `string` | Agent identifier. |

**Request Body:**

```json
{
  "tokens": 5000
}
```

| Field | Type | Required | Description |
|---|---|---|---|
| `tokens` | `integer` | Yes | Number of tokens to reserve. |

**Response:** `200 OK`

```json
{
  "reserved": true
}
```

**Error Response:** `500 Internal Server Error` if budget is exceeded.

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/budget/builder-agent/reserve \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"tokens": 5000}'
```

### POST /api/budget/{agent_id}/reset

Reset an agent's budget window (restore full allocation).

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `agent_id` | `string` | Agent identifier. |

**Response:** `200 OK`

```json
{
  "reset": true,
  "agent_id": "builder-agent"
}
```

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/budget/builder-agent/reset \
  -H "Authorization: Bearer YOUR_TOKEN"
```

---

## 18. Resources

### GET /api/resources

Get the current system resource snapshot.

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "cpu_percent": 45.2,
  "memory_percent": 62.8,
  "memory_used_mb": 6420,
  "memory_total_mb": 10240,
  "load_avg_1m": 2.1,
  "load_avg_5m": 1.8,
  "load_avg_15m": 1.5,
  "timestamp": "2026-05-17T10:30:00+00:00"
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/resources
```

### GET /api/resources/history

Get historical resource snapshots.

**Authentication:** Required

**Query Parameters:**

| Parameter | Type | Default | Description |
|---|---|---|---|
| `last_n` | `integer` | `30` | Number of most recent snapshots. |

**Response:** `200 OK`

```json
{
  "snapshots": [
    {
      "cpu_percent": 45.2,
      "memory_percent": 62.8,
      "timestamp": "2026-05-17T10:30:00+00:00"
    },
    {
      "cpu_percent": 38.1,
      "memory_percent": 60.5,
      "timestamp": "2026-05-17T10:25:00+00:00"
    }
  ],
  "count": 2
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  "http://127.0.0.1:4200/api/resources/history?last_n=10"
```

### GET /api/resources/overload

Check if the system is currently overloaded.

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "overloaded": false,
  "threshold": {
    "cpu_percent": 90.0,
    "memory_percent": 90.0,
    "load_avg": 10.0
  }
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/resources/overload
```

---

## 19. Agent Groups

### GET /api/agent-groups

List all agent groups from the state store.

**Authentication:** Required

**Response:** `200 OK`

```json
[
  {
    "id": "group-550e8400",
    "name": "parallel-build",
    "agent_count": 3,
    "status": "running",
    "created_at": "2026-05-17T10:30:00+00:00"
  }
]
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/agent-groups
```

### GET /api/agent-groups/{id}

Get a specific agent group by ID.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string` | Agent group ID. |

**Response:** `200 OK` — Returns the full agent group object.

**Error Response:** `404 Not Found`

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/agent-groups/group-550e8400
```

---

## 20. Approvals (HitL)

Human-in-the-Loop (HitL) approval workflow for agent actions.

### GET /api/approvals

List all approval requests (pending and history).

**Authentication:** Required

**Response:** `200 OK`

```json
[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "subject": "agent:builder-agent",
    "action": "use_tool:shell_exec",
    "resource": "/workspace/scripts/deploy.sh",
    "reason": "Agent requests shell execution for deployment",
    "created_at": "2026-05-17T10:30:00+00:00",
    "status": "pending"
  }
]
```

Possible `action` values: `use_tool:{tool}`, `access_path:{path}`, `manage_agents`, `manage_programs`, `manage_workspaces`, `manage_rbac`, `view_audit_log`, `system_config`.

Possible `status` values: `pending`, `approved`, `rejected`, `expired`.

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/approvals
```

### POST /api/approvals/{id}/approve

Approve a pending approval request.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string (UUID)` | Approval request ID. |

**Response:** `200 OK`

```json
{
  "status": "approved",
  "id": "550e8400-e29b-41d4-a716-446655440000"
}
```

**Error Response:** `400 Bad Request` (invalid UUID) or `404 Not Found`.

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/approvals/550e8400-e29b-41d4-a716-446655440000/approve \
  -H "Authorization: Bearer YOUR_TOKEN"
```

### POST /api/approvals/{id}/reject

Reject a pending approval request.

**Authentication:** Required

**Path Parameters:**

| Parameter | Type | Description |
|---|---|---|
| `id` | `string (UUID)` | Approval request ID. |

**Response:** `200 OK`

```json
{
  "status": "rejected",
  "id": "550e8400-e29b-41d4-a716-446655440000"
}
```

**Error Response:** `400 Bad Request` (invalid UUID) or `404 Not Found`.

**Example:**

```sh
curl -X POST http://127.0.0.1:4200/api/approvals/550e8400-e29b-41d4-a716-446655440000/reject \
  -H "Authorization: Bearer YOUR_TOKEN"
```

---

## 21. SSE Events

### GET /api/events

Subscribe to a Server-Sent Events (SSE) stream of kernel events.

**Authentication:** Required

**Keep-Alive:** Ping every 30 seconds.

**Event Types:**

| Event Type | Description |
|---|---|
| `agent_created` | New agent spawned |
| `agent_started` | Agent begins execution |
| `agent_stopped` | Agent finished execution |
| `agent_failed` | Agent encountered an error |
| `message_received` | Message received on channel (content excluded) |
| `seed_created` | New Ouroboros seed created |
| `evaluation_complete` | Seed evaluation finished |
| `phase_started` | Orchestration phase started |
| `phase_completed` | Orchestration phase completed |
| `agent_output` | Agent produced output (content excluded) |
| `approval_requested` | HitL approval requested |
| `approval_resolved` | HitL approval approved/rejected |
| `memory_stored` | Memory entry stored |
| `memory_recalled` | Memory entries recalled |
| `agent_group_created` | Agent group created |
| `agent_group_member_completed` | Agent group member finished |
| `space_created` | Knowledge space created |
| `space_activated` | Knowledge space activated |
| `space_archived` | Knowledge space archived |
| `spaces_merged` | Knowledge spaces merged |
| `knowledge_cross_referenced` | Knowledge cross-referenced between spaces |

**Event Format (SSE):**

```
data: {"type":"agent_started","agent_id":"abc-123"}
```

**Example (curl):**

```sh
curl -N -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/events
```

**Example (JavaScript):**

```javascript
const eventSource = new EventSource('http://127.0.0.1:4200/api/events');

// Note: For auth, you may need to proxy or use a custom fetch-based SSE client
// since EventSource doesn't support custom headers.

eventSource.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log(`[${data.type}]`, data);
};
```

**Example (Python):**

```python
import sseclient
import requests
import json

response = requests.get(
    'http://127.0.0.1:4200/api/events',
    stream=True,
    headers={
        'Accept': 'text/event-stream',
        'Authorization': 'Bearer YOUR_TOKEN'
    }
)

client = sseclient.SSEClient(response)

for event in client.events():
    data = json.loads(event.data)
    print(f"[{data.get('type', 'unknown')}] {data}")
```

> **Note:** Sensitive data (message content, full seed content, LLM responses) is excluded from SSE events for security.

---

## 22. Host Tools

### GET /api/host-tools

Check availability of required and optional host tools.

**Authentication:** Required

**Response:** `200 OK`

```json
{
  "all_required_present": true,
  "missing_required": [],
  "optional_available": {
    "git": true,
    "docker": false,
    "node": true,
    "cargo": true
  }
}
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/host-tools
```

---

## 23. Metrics

### GET /api/metrics

Prometheus-compatible metrics endpoint.

**Authentication:** Required

**Response:** `200 OK` — Plain text in Prometheus exposition format.

```
# HELP oxios_agents_forked_total Total agents forked
# TYPE oxios_agents_forked_total counter
oxios_agents_forked_total 42

# HELP oxios_agents_completed_total Total agents completed
# TYPE oxios_agents_completed_total counter
oxios_agents_completed_total 38

# HELP oxios_agents_failed_total Total agents failed
# TYPE oxios_agents_failed_total counter
oxios_agents_failed_total 1
```

**Example:**

```sh
curl -H "Authorization: Bearer YOUR_TOKEN" \
  http://127.0.0.1:4200/api/metrics
```

**Prometheus Scrape Config:**

```yaml
scrape_configs:
  - job_name: 'oxios'
    static_configs:
      - targets: ['127.0.0.1:4200']
    metrics_path: '/api/metrics'
    bearer_token: 'YOUR_TOKEN'
```

---

## 24. Error Responses

All errors follow a consistent JSON format:

```json
{
  "error": "Description of the error"
}
```

**HTTP Status Codes:**

| Status | Code | Description |
|---|---|---|
| `400 Bad Request` | 400 | Invalid request body or parameters |
| `401 Unauthorized` | 401 | Missing or invalid authentication token |
| `403 Forbidden` | 403 | Path traversal or permission denied |
| `404 Not Found` | 404 | Resource not found |
| `413 Payload Too Large` | 413 | Request body exceeds size limit |
| `429 Too Many Requests` | 429 | Rate limit exceeded |
| `500 Internal Server Error` | 500 | Server-side error |

---

## 25. Rate Limiting

All `/api/*` endpoints are protected by a token-bucket rate limiter. The limiter is configured at server startup with a maximum requests-per-minute setting.

- **Refill rate:** `max_requests_per_minute / 60` tokens per second
- **Burst capacity:** `max_requests_per_minute`
- **Response when limited:** `HTTP 429 Too Many Requests`

---

## 26. Pagination

Many list endpoints support pagination with these query parameters:

| Parameter | Type | Default | Max | Description |
|---|---|---|---|---|
| `page` | `integer` | `1` || Page number (1-indexed). |
| `limit` | `integer` | `50` | `500` | Items per page. |

**Paginated Response Format:**

```json
{
  "items": [...],
  "total": 150,
  "page": 1,
  "limit": 50
}
```

- `items` contains the current page's items.
- `total` is the total number of items across all pages.
- Page 0 is treated as page 1 (underflow protection via `saturating_sub`).

---

## Endpoint Summary

| # | Method | Path | Auth | Description |
|---|---|---|---|---|
| 1 | `GET` | `/health` | No | Health check |
| 2 | `POST` | `/api/chat` | Yes | Send chat message |
| 3 | `GET` | `/api/chat/stream` | Yes* | WebSocket chat stream |
| 4 | `GET` | `/api/status` | Yes | System status with component health |
| 5 | `GET` | `/api/agents` | Yes | List agents (paginated) |
| 6 | `POST` | `/api/agents/{id}/kill` | Yes | Kill an agent |
| 7 | `GET` | `/api/config` | Yes | Get configuration |
| 8 | `PUT` | `/api/config` | Yes | Update configuration |
| 9 | `GET` | `/api/workspace/tree` | Yes | List workspace file tree |
| 10 | `GET` | `/api/workspace/file/{*path}` | Yes | Read workspace file |
| 11 | `PUT` | `/api/workspace/file/{*path}` | Yes | Write workspace file |
| 12 | `GET` | `/api/seeds` | Yes | List seeds (paginated) |
| 13 | `GET` | `/api/seeds/{id}` | Yes | Get a seed |
| 14 | `GET` | `/api/seeds/{id}/evolution` | Yes | Get seed evolution lineage |
| 15 | `GET` | `/api/skills` | Yes | List skills (paginated) |
| 16 | `GET` | `/api/skills/{name}` | Yes | Get a skill |
| 17 | `POST` | `/api/skills` | Yes | Create a skill |
| 18 | `DELETE` | `/api/skills/{name}` | Yes | Delete a skill |
| 19 | `GET` | `/api/memory` | Yes | List memory entries (paginated) |
| 20 | `POST` | `/api/memory` | Yes | Create a memory entry |
| 21 | `GET` | `/api/memory/{name}` | Yes | Get a memory entry |
| 22 | `POST` | `/api/memory/search` | Yes | Search memory |
| 23 | `POST` | `/api/memory/semantic` | Yes | Semantic search (HNSW) |
| 24 | `GET` | `/api/programs` | Yes | List programs (paginated) |
| 25 | `POST` | `/api/programs` | Yes | Install a program |
| 26 | `GET` | `/api/programs/{name}` | Yes | Get a program |
| 27 | `DELETE` | `/api/programs/{name}` | Yes | Uninstall a program |
| 28 | `POST` | `/api/programs/{name}/enable` | Yes | Enable a program |
| 29 | `POST` | `/api/programs/{name}/disable` | Yes | Disable a program |
| 30 | `GET` | `/api/programs/{name}/host-requirements` | Yes | Check host requirements |
| 31 | `GET` | `/api/scheduler/stats` | Yes | Scheduler statistics |
| 32 | `GET` | `/api/scheduler/tasks` | Yes | List scheduler tasks |
| 33 | `GET` | `/api/audit/entries` | Yes | Query audit entries by range |
| 34 | `GET` | `/api/audit/verify` | Yes | Verify audit chain integrity |
| 35 | `GET` | `/api/audit/agent/{agent_id}` | Yes | Query audit by agent |
| 36 | `POST` | `/api/audit/export` | Yes | Export audit entries |
| 37 | `POST` | `/api/audit/flush` | Yes | Flush audit to disk |
| 38 | `GET` | `/api/audit` | Yes | Legacy audit log (paginated) |
| 39 | `GET` | `/api/permissions/{agent}` | Yes | Get agent permissions |
| 40 | `PUT` | `/api/permissions/{agent}` | Yes | Update agent permissions |
| 41 | `GET` | `/api/cron-jobs` | Yes | List cron jobs |
| 42 | `POST` | `/api/cron-jobs` | Yes | Create a cron job |
| 43 | `GET` | `/api/cron-jobs/{id}` | Yes | Get a cron job |
| 44 | `DELETE` | `/api/cron-jobs/{id}` | Yes | Delete a cron job |
| 45 | `POST` | `/api/cron-jobs/{id}/edit` | Yes | Update a cron job |
| 46 | `POST` | `/api/cron-jobs/{id}/trigger` | Yes | Manually trigger a cron job |
| 47 | `GET` | `/api/sessions` | Yes | List sessions (paginated) |
| 48 | `GET` | `/api/sessions/{id}` | Yes | Get session with history |
| 49 | `DELETE` | `/api/sessions/{id}` | Yes | Delete a session |
| 50 | `GET` | `/api/personas` | Yes | List personas |
| 51 | `POST` | `/api/personas` | Yes | Create a persona |
| 52 | `GET` | `/api/personas/{id}` | Yes | Get a persona |
| 53 | `PUT` | `/api/personas/{id}` | Yes | Update a persona |
| 54 | `DELETE` | `/api/personas/{id}` | Yes | Delete a persona |
| 55 | `GET` | `/api/personas/active` | Yes | Get active persona |
| 56 | `PUT` | `/api/personas/active` | Yes | Set active persona |
| 57 | `GET` | `/api/git/log` | Yes | Git commit log |
| 58 | `GET` | `/api/git/tags` | Yes | List Git tags |
| 59 | `POST` | `/api/git/verify` | Yes | Verify repo integrity |
| 60 | `POST` | `/api/git/restore` | Yes | Restore file from commit |
| 61 | `GET` | `/api/budget/{agent_id}` | Yes | Get agent budget |
| 62 | `POST` | `/api/budget/{agent_id}` | Yes | Set agent budget |
| 63 | `DELETE` | `/api/budget/{agent_id}` | Yes | Remove agent budget |
| 64 | `POST` | `/api/budget/{agent_id}/reserve` | Yes | Reserve budget tokens |
| 65 | `POST` | `/api/budget/{agent_id}/reset` | Yes | Reset agent budget |
| 66 | `GET` | `/api/resources` | Yes | Resource snapshot |
| 67 | `GET` | `/api/resources/history` | Yes | Resource history |
| 68 | `GET` | `/api/resources/overload` | Yes | Overload check |
| 69 | `GET` | `/api/agent-groups` | Yes | List agent groups |
| 70 | `GET` | `/api/agent-groups/{id}` | Yes | Get agent group |
| 71 | `GET` | `/api/approvals` | Yes | List approval requests |
| 72 | `POST` | `/api/approvals/{id}/approve` | Yes | Approve a request |
| 73 | `POST` | `/api/approvals/{id}/reject` | Yes | Reject a request |
| 74 | `GET` | `/api/events` | Yes | SSE event stream |
| 75 | `GET` | `/api/host-tools` | Yes | Check host tools |
| 76 | `GET` | `/api/metrics` | Yes | Prometheus metrics |

*\* WebSocket auth uses `?token=` query parameter instead of `Authorization` header.*