tapes-client 0.2.0

One client for the whole tapes read surface: the sealed contract and a deployment's discovered cassettes, driven through a single pluggable transport.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
components:
  schemas:
    Discovery:
      description: |-
        Discovery is the document served at GET /v1/cassettes.

        It publishes what each cassette *is* — never what it is configured to. Core
        holds no configuration values—the deployment supplies them directly to the
        cassette—so there is nothing here to leak.
      properties:
        cassettes:
          items:
            $ref: '#/components/schemas/DiscoveryEntry'
          type: array
        contract_version:
          type: string
        problems:
          items:
            $ref: '#/components/schemas/Rejection'
          type: array
      type: object
    DiscoveryDepends:
      description: DiscoveryDepends is a cassette's declared dependency on core.
      properties:
        core:
          type: string
        views:
          items:
            type: string
          type: array
      type: object
    DiscoveryEntry:
      description: |-
        DiscoveryEntry describes one served cassette.

        The OpenAPI document is referenced, not inlined. A single spec runs to tens
        of kilobytes and clients poll discovery; inlining five of them turns every
        client boot into a megabyte of mostly-unchanged bytes. The digest is enough
        to know whether the fetch is worth making.
      properties:
        config:
          items:
            $ref: '#/components/schemas/DiscoverySetting'
          type: array
        depends:
          $ref: '#/components/schemas/DiscoveryDepends'
        description:
          type: string
        display_name:
          type: string
        manifest_digest:
          type: string
        name:
          type: string
        openapi_path:
          type: string
        openapi_status:
          type: string
        route_prefix:
          type: string
        tables:
          items:
            type: string
          type: array
        version:
          type: string
      type: object
    DiscoverySetting:
      description: DiscoverySetting is one configuration key as a schema, never as
        a value.
      properties:
        default: {}
        description:
          type: string
        key:
          type: string
        required:
          type: boolean
        secret:
          type: boolean
        type:
          type: string
      type: object
    ErrorResponse:
      description: ErrorResponse represents an error from the LLM API.
      properties:
        error:
          type: string
      type: object
    MCPError:
      description: MCPError is a JSON-RPC 2.0 error object.
      properties:
        code:
          description: Code is the JSON-RPC error code.
          example: -32600
          format: int32
          type: integer
        message:
          description: Message is a short description of the failure.
          example: invalid request
          type: string
      type: object
    MCPRequest:
      description: MCPRequest is a JSON-RPC 2.0 request to the streamable MCP endpoint.
      properties:
        id:
          description: ID correlates a response with this request. Absent on notifications.
          example: "1"
          type: string
        jsonrpc:
          description: JSONRPC is the protocol version, always "2.0".
          example: "2.0"
          type: string
        method:
          description: Method is the MCP method being invoked, such as tools/call.
          example: tools/call
          type: string
        params:
          additionalProperties: {}
          description: Params are the method's arguments.
          type: object
      type: object
    MCPResponse:
      description: |-
        MCPResponse is a JSON-RPC 2.0 response from the streamable MCP endpoint.

        Exactly one of Result and Error is set, which is the JSON-RPC contract rather
        than anything this server adds.
      properties:
        error:
          $ref: '#/components/schemas/MCPError'
        id:
          description: ID is the id of the request this answers.
          example: "1"
          type: string
        jsonrpc:
          description: JSONRPC is the protocol version, always "2.0".
          example: "2.0"
          type: string
        result:
          additionalProperties: {}
          description: Result is the method's return value on success.
          type: object
      type: object
    MainUsage:
      description: |-
        MainUsage is the task token slice of a trace: the main agent and its
        subagents (call_kind=main across every thread), no cache split or cost
        (those live on the total Usage). Deliberately not spine-only — a
        subagent doing the user's work is task spend, not shadow.
      properties:
        input_tokens:
          format: int64
          type: integer
        output_tokens:
          format: int64
          type: integer
      type: object
    ModelUsage:
      description: |-
        ModelUsage is one model's contribution to a session in the API: how
        many llm calls ran on it and what they spent. Cost-weighted (priced
        at derive time) so a per-model share reflects spend, not call count.
      properties:
        calls:
          format: int64
          type: integer
        cost_usd:
          format: double
          type: number
        input_tokens:
          format: int64
          type: integer
        model:
          type: string
        output_tokens:
          format: int64
          type: integer
      type: object
    RawTurnAttribution:
      description: |-
        RawTurnAttribution is the effective, repairable attribution projected over
        an immutable raw turn. Raw payload and envelope bytes remain untouched.
      properties:
        harness_id:
          type: string
        harness_session_id:
          type: string
        parent_harness_session_id:
          type: string
        raw_turn_id:
          format: int64
          type: integer
        thread_id:
          type: string
      type: object
    RawTurnAttributionRepairRequest:
      description: |-
        RawTurnAttributionRepairRequest selects exactly one raw row and supplies a
        complete replacement attribution. OrgID is supplied by the trusted caller
        context, never by an HTTP request body.
      properties:
        harness_id:
          type: string
        harness_session_id:
          type: string
        paper_proxy_request_id:
          type: string
        parent_harness_session_id:
          type: string
        raw_turn_id:
          format: int64
          type: integer
        reason:
          type: string
        thread_id:
          type: string
      type: object
    RawTurnAttributionRepairResult:
      properties:
        effective:
          $ref: '#/components/schemas/RawTurnAttribution'
        previous:
          $ref: '#/components/schemas/RawTurnAttribution'
        projections_pending:
          description: |-
            ProjectionsPending lists the sessions whose synchronous rebuild failed
            after the correction committed. Empty on full success. When set, the
            correction is effective at read time and the listed projections
            converge via the derive queue (marked dirty in the correction
            transaction); the call returns ErrRepairProjectionsPending alongside
            this result.
          items:
            $ref: '#/components/schemas/RepairPendingSession'
          type: array
        recorded:
          type: boolean
        source_cleanup_pending:
          description: |-
            SourceCleanupPending reports that the best-effort removal of the
            emptied previous-session row failed after the correction and both
            projection rebuilds applied. The leftover row is cosmetic — it anchors
            no effective turns — and nothing retries the deletion automatically:
            the flag makes the response honest about the leftover, it is not a
            promise of later cleanup. On its own it never accompanies an error;
            when ProjectionsPending is empty too, the repair succeeded.
          type: boolean
      type: object
    RawTurnHeaderItem:
      description: |-
        RawTurnHeaderItem is one wire-log row: what crossed the wire (or
        arrived as a transcript push), without the payload blobs. The
        `source` field is the wire-vs-transcript distinction.
      properties:
        agent_name:
          type: string
        id:
          format: int64
          type: integer
        meta:
          type: object
        provider:
          type: string
        received_at:
          format: date-time
          type: string
        request_bytes:
          format: int64
          type: integer
        request_id:
          type: string
        response_bytes:
          format: int64
          type: integer
        source:
          type: string
      type: object
    RawTurnListResponse:
      description: RawTurnListResponse is a session's wire log.
      properties:
        items:
          items:
            $ref: '#/components/schemas/RawTurnHeaderItem'
          type: array
      type: object
    ReconcileStats:
      description: ReconcileStats reports the transcript↔wire fusion for one org.
      properties:
        codex_interacted_rows:
          description: |-
            CodexInteractedRows counts anchor rows carrying a non-started
            kind (interacted re-entries banked by paperd for future
            rendering). They are deliberately INERT: excluded from every
            join, they perturb nothing but this counter — the visible proof
            the rows arrived and were ignored by design (PCC-1021 C).
          format: int32
          type: integer
        codex_threads_anchored:
          description: |-
            Codex thread-spawn anchoring (see codex.go). Unanchored threads
            degrade to trace-root placement — a non-zero count is the visible
            signal that spawn-anchor rows are missing or ambiguous.
          format: int32
          type: integer
        codex_threads_unanchored:
          format: int32
          type: integer
        conversation_joined:
          description: |-
            ConversationJoined / ConversationTotal measure how many
            conversation-spine nodes' content appears in a transcript — the
            Go-native version of the prototype's join-rate oracle.
          format: int32
          type: integer
        conversation_total:
          format: int32
          type: integer
        forked_chains:
          format: int32
          type: integer
        main_chains_joined:
          format: int32
          type: integer
        subagent_forks:
          format: int32
          type: integer
        transcript_files:
          format: int32
          type: integer
      type: object
    RederiveReport:
      description: RederiveReport summarizes one derive pass.
      properties:
        attached_verdicts:
          format: int32
          type: integer
        call_kinds:
          additionalProperties:
            format: int32
            type: integer
          type: object
        judged_actions:
          description: |-
            Verdict attach: judged actions grouped across stages, and how
            many attached one-to-one to a captured tool_use.
          format: int32
          type: integer
        node_kinds:
          additionalProperties:
            format: int32
            type: integer
          type: object
        nodes:
          format: int32
          type: integer
        parse_failures:
          items:
            type: string
          type: array
        parsed_turns:
          format: int32
          type: integer
        plans_attached:
          description: |-
            PlansAttached counts plan-name-gen calls linked to the
            ExitPlanMode tool_use that accepted the plan.
          format: int32
          type: integer
        raw_only_turns:
          format: int32
          type: integer
        raw_turns:
          format: int32
          type: integer
        reconcile:
          $ref: '#/components/schemas/ReconcileStats'
        unattached_actions:
          description: |-
            UnattachedActions samples judged actions that found no matching
            tool_use (capped) — expected for non-tool events like subagent
            handbacks; anything else is matcher signal worth reading.
          items:
            type: string
          type: array
        web_summary_attached:
          description: |-
            WebSummaryAttached counts web-summary calls linked back to their
            WebFetch/WebSearch tool_use.
          format: int32
          type: integer
      type: object
    Rejection:
      description: |-
        Rejection is a cassette core refused to serve, and why.

        Rejections are first-class rather than log lines because they are the answer
        to the question an operator actually asks — "why is my cassette not there?" —
        and that question is asked over HTTP, from a machine that cannot read the
        server's stderr.
      properties:
        reason:
          description: Reason is the human-facing explanation. It is never parsed.
          type: string
        subject:
          description: |-
            Subject names what was rejected: the configured OpenAPI URL, with any
            credential redacted.
          type: string
      type: object
    RepairPendingSession:
      description: |-
        RepairPendingSession names one harness session whose projection rebuild
        did not complete synchronously during a repair. The session is already
        queued for the derive worker, which converges it.
      properties:
        harness_id:
          type: string
        harness_session_id:
          type: string
      type: object
    SeedResult:
      description: Result summarizes one seeding run.
      properties:
        raw_turns:
          description: RawTurns is the total number of corpus rows replayed.
          format: int32
          type: integer
        raw_turns_deduped:
          format: int64
          type: integer
        raw_turns_inserted:
          description: |-
            RawTurnsInserted counts rows that landed as new raw turns;
            RawTurnsDeduped counts replays the raw layer's dedup absorbed
            (a re-seed reports everything deduped).
          format: int64
          type: integer
        sessions:
          description: Sessions is the number of demo sessions the corpora replay
            into.
          format: int32
          type: integer
      type: object
    SessionDetailResponse:
      description: |-
        SessionDetailResponse is the response for GET /v1/sessions/:id: the
        session record alone. The conversation content lives on the span model
        (GET /v1/sessions/:id/traces).
      properties:
        session:
          $ref: '#/components/schemas/SessionItem'
      type: object
    SessionItem:
      description: |-
        SessionItem is the per-session shape: capture identity at the top
        level, the deriver-owned projection nested under `rollup`. The split
        mirrors the storage rows — identity is ingest-written, rollup is
        deriver-written — so the wire can't blur which layer owns a field.
      properties:
        auth_subject:
          description: |-
            AuthSubject is the gateway-stamped JWT subject (WorkOS user id)
            captured at ingest; empty for rows captured before the edge began
            stamping it.
          type: string
        cwd:
          type: string
        display_name:
          description: |-
            DisplayName is the user's Console rename (sessions.display_name),
            empty unless a user set one. Written only by PATCH /v1/sessions/:id,
            never by ingest, so it survives a live session. It is the top of the
            DisplayTitle resolution; exposed raw so the edit affordance can seed
            its input from the user's own title (not the resolved fallback).
          type: string
        display_title:
          description: |-
            DisplayTitle is the server-resolved label clients should render:
            DisplayName -> rollup.title (generated) -> preview -> Name -> id
            slice. Resolving once on the server keeps every client (Console,
            paper CLI) from re-deriving — and diverging on — the precedence
            (PCC-970). Never empty: it falls back to a short harness id slice, then
            the session id (the primary key, always set for a stored row).
          type: string
        ended_at:
          format: date-time
          type: string
        harness_id:
          type: string
        harness_metadata:
          additionalProperties: {}
          type: object
        harness_session_id:
          type: string
        harness_version:
          type: string
        id:
          description: Identity — capture-side facts, ingest-written.
          type: string
        last_seen_at:
          format: date-time
          type: string
        live:
          description: |-
            Live is a runtime presence signal, not a projection fact: true when
            the session has no recorded end and was seen within the liveness
            window. Keyed on ended_at + last_seen_at recency (both ingest-fresh),
            never on the derived status: an interactive session folds to a
            terminal status (an end_turn assistant reply reads as "completed")
            after every turn while still open, so status cannot gate liveness.
            Computed at response time so the console renders it directly instead
            of inferring "running" itself.
          type: boolean
        name:
          description: |-
            Name is the harness identity-row label — the harness-supplied session
            name (a plan slug), or the folded title (rollup.title) as a fallback
            when no name was captured. This is capture/deriver provenance, NOT a
            user title: ingest re-sends it every turn. Clients should render
            DisplayTitle, not Name (PCC-970).
          type: string
        parent_session_id:
          type: string
        rollup:
          $ref: '#/components/schemas/SessionRollup'
        started_at:
          format: date-time
          type: string
      type: object
    SessionListResponse:
      description: SessionListResponse is the response envelope for GET /v1/sessions.
      properties:
        items:
          items:
            $ref: '#/components/schemas/SessionItem'
          type: array
        next_cursor:
          type: string
      type: object
    SessionRollup:
      description: |-
        SessionRollup is the deriver-owned session projection — status, title,
        counts, and spend, all folded from the span layer at derive time.
        Every field is 'unknown'/zero/empty until the session first derives.
      properties:
        kind_counts:
          additionalProperties:
            format: int32
            type: integer
          description: |-
            KindCounts (spans per call_kind) and Tasks (TaskCreate/TaskUpdate
            folds) are pinned so the rollup shape is uniform across sessions.
          type: object
        model:
          description: |-
            Model is the dominant conversation-spine model; ModelUsage is the
            per-model spend breakdown across every thread (subagent models
            included), cost-ordered so the UI can show "dominant model + share"
            without a cheap-subagent fan-out skewing it.
          type: string
        model_usage:
          items:
            $ref: '#/components/schemas/ModelUsage'
          type: array
        preview:
          type: string
        status:
          type: string
        tasks:
          items:
            $ref: '#/components/schemas/TreeTask'
          type: array
        title:
          description: |-
            Title is the deriver's folded session title (derived_title),
            generated from the conversation. Empty until title generation
            produces one. It never falls back to the identity-row name, so it is
            the stable descriptive title clients prefer for display; the
            identity-row label (harness name or rename) is SessionItem.Name.
          type: string
        turn_count:
          format: int32
          type: integer
        usage:
          $ref: '#/components/schemas/SessionUsage'
      type: object
    SessionTracesResponse:
      description: |-
        SessionTracesResponse is the composite session view on the span
        model. `schema` stamps the projection generation the rows were derived
        against, so the presentational shape can version independently.
      properties:
        links:
          items:
            $ref: '#/components/schemas/SpanLinkItem'
          type: array
        schema:
          type: string
        session:
          $ref: '#/components/schemas/SessionItem'
        traces:
          items:
            $ref: '#/components/schemas/TraceDetail'
          type: array
      type: object
    SessionUsage:
      description: |-
        SessionUsage is the session's total token/cost spend, folded from the
        span layer. Pinned (no omitempty) for a uniform object shape.
      properties:
        cost_usd:
          format: double
          type: number
        input_tokens:
          format: int64
          type: integer
        output_tokens:
          format: int64
          type: integer
      type: object
    SpanItem:
      description: |-
        SpanItem is one observed unit of work. Every field is a deriver
        output, formatting-only: the harness-taxonomy fields (call_kind, model,
        stop_reason, thread_id, verdict) are typed rather than bagged in a
        metadata map, and input/output are uniform content-block arrays for
        ALL kinds — the console owns per-kind rendering.
      properties:
        call_kind:
          description: Deriver-written taxonomy, promoted from the old metadata grab-bag.
          type: string
        duration_ns:
          format: int64
          type: integer
        input:
          description: |-
            Input/Output are content-block arrays (llm.ContentBlock), uniform for
            every kind (tool spans included — no unwrapping). Pinned to [] when
            empty.
          items:
            type: object
          type: array
        kind:
          type: string
        model:
          type: string
        name:
          type: string
        output:
          items:
            type: object
          type: array
        parent_span_id:
          type: string
        payload:
          description: |-
            Payload marks a preview-truncated span so the console drills in for
            the full payload; absent in full mode.
          type: string
        raw_turn_id:
          format: int64
          type: integer
        seq:
          description: |-
            Seq is the span's presentation ordinal within its trace; spans
            arrive sorted by it (started_at ties inside one llm call — parallel
            tool batches share an instant).
          format: int64
          type: integer
        span_id:
          type: string
        started_at:
          format: date-time
          type: string
        status:
          type: string
        stop_reason:
          type: string
        thread_id:
          type: string
        trace_id:
          type: string
        usage:
          description: |-
            Usage (was `metrics`) is an llm.Usage object on the wire — {}-pinned
            for usage-less spans.
          type: object
        verdict:
          description: |-
            Verdict is the typed security-monitor disposition (null off
            permission-check spans), deriver-written. It is a Verdict object or
            null on the wire; the oas tag states that, because a json.RawMessage
            carries no shape a reflector could recover.
          nullable: true
          type: object
      type: object
    SpanLinkItem:
      description: |-
        SpanLinkItem is a dataflow edge. kind is a typed top-level field
        (rejoin / verdict / compaction-seam / emits / feeds); from/to trace ids
        differ on cross-trace causality.
      properties:
        from_io:
          type: string
        from_span_id:
          type: string
        from_trace_id:
          type: string
        kind:
          type: string
        to_io:
          type: string
        to_span_id:
          type: string
        to_trace_id:
          type: string
      type: object
    SpanSearchOutput:
      description: SpanSearchOutput is the span search response.
      properties:
        count:
          format: int32
          type: integer
        query:
          type: string
        results:
          items:
            $ref: '#/components/schemas/SpanSearchResult'
          type: array
      type: object
    SpanSearchResult:
      description: SpanSearchResult is one span hit with its trace/turn context.
      properties:
        model:
          type: string
        score:
          format: float
          type: number
        session_id:
          type: string
        snippet:
          description: Snippet previews the matched span's delta-only text.
          type: string
        span_id:
          type: string
        started_at:
          format: date-time
          type: string
        trace_id:
          type: string
        user_prompt:
          description: |-
            UserPrompt is the prompt of the turn (trace) the span belongs to.
            Served explicitly (not omitempty) so a synthetic turn's empty prompt
            reaches consumers as "" rather than a dropped key — see TraceItem.
          type: string
      type: object
    StatsResponse:
      description: |-
        StatsResponse is the response for GET /v1/stats.

        The numbers come from the span-projection trace-grain rollups, so they
        agree with the session detail and trace views:

          - InputTokens / OutputTokens / TotalCost are SUMs of span_turns
            rollups — delta-only per-call usage, never the re-sent history
            (each main call re-bills the whole conversation on the wire).
          - TotalDurationMs is the SUM of trace durations — agent time. Idle
            time between turns does not count. Served in milliseconds, not the
            nanoseconds we store: the summed ns over a wide window overflows a
            JSON consumer's 2^53 safe-integer range (~104 cumulative days), and
            sub-ms precision is meaningless for an aggregate agent-time figure.
          - TurnCount counts traces (user-visible turns).
          - ToolCalls is the SUM of the turn rollups' tool span counts,
            windowed on the turn's started_at like every other figure here
            rather than on each tool span's own timestamp (PCC-936).
          - CompletedCount counts distinct sessions whose denormalized
            derived_status is 'completed' (chain-aware, PCC-515).
      properties:
        completed_count:
          format: int32
          type: integer
        input_tokens:
          format: int64
          type: integer
        output_tokens:
          format: int64
          type: integer
        session_count:
          format: int32
          type: integer
        tool_calls:
          format: int32
          type: integer
        total_cost:
          format: double
          type: number
        total_duration_ms:
          format: int64
          type: integer
        turn_count:
          format: int32
          type: integer
      type: object
    TraceDetail:
      description: |-
        TraceDetail is one trace with its spans. In the composite session
        response links are session-scoped (top level); the single-trace
        endpoint sets Links to the edges touching that trace. `schema` stamps
        the projection generation on the STANDALONE /v1/traces/{id} response
        (omitempty — the composite embeds TraceDetail and already carries one
        stamp at the top level, so the embedded copies stay unstamped).
      properties:
        links:
          items:
            $ref: '#/components/schemas/SpanLinkItem'
          type: array
        schema:
          type: string
        spans:
          items:
            $ref: '#/components/schemas/SpanItem'
          type: array
        trace:
          $ref: '#/components/schemas/TraceItem'
      type: object
    TraceItem:
      description: |-
        TraceItem is one user-visible turn's header. session_id / harness ids
        are not duplicated here — they belong to the session. A trace's
        post-compaction status is the typed Synthetic field below (promoted out
        of the old metadata grab-bag); the same seam is also recoverable from
        the session's compaction-seam links.
      properties:
        duration_ns:
          format: int64
          type: integer
        ended_at:
          format: date-time
          type: string
        main_usage:
          $ref: '#/components/schemas/MainUsage'
        response_preview:
          description: |-
            ResponsePreview is the derive-time fold of the closing
            conversation-spine llm call's text output — the answer line for
            collapsed turn cards, so summary consumers never need spans.
          type: string
        source:
          description: |-
            Source is the capture origin of the turn's rows ("wire" |
            "transcript"), promoted from raw_turns.source. Per-trace, so a
            session can mix live wire capture and transcript backfill. Today
            every trace is "wire": transcripts only reconcile fork/parent edges
            during derivation, they never form a trace on their own. "transcript"
            becomes real when a session is reconstructed purely from a transcript
            file with no proxy capture (an OSS backfill path).
          type: string
        span_count:
          format: int32
          type: integer
        started_at:
          format: date-time
          type: string
        status:
          type: string
        synthetic:
          description: |-
            Synthetic is a typed deriver signal ("post-compaction" for a
            compaction continuation, "shadow-opener" for a shadow-only opener),
            promoted out of the old metadata grab-bag. Absent for genuine
            prompt-opened turns.
          type: string
        trace_id:
          type: string
        usage:
          $ref: '#/components/schemas/TraceUsage'
        user_prompt:
          description: |-
            UserPrompt is served explicitly (not omitempty): a synthetic opener
            has an empty prompt, and dropping the key turns the empty string
            into `undefined` on the wire, which breaks consumers that expect a
            string (e.g. the console's stripHarnessTags). Empty means synthetic.
          type: string
      type: object
    TraceListResponse:
      description: |-
        TraceListResponse is the summaries list for one session. `schema`
        stamps the projection generation the rows were derived against — the
        same stamp the composite carries — so every trace-grain response is
        self-describing, not just the composite.
      properties:
        items:
          items:
            $ref: '#/components/schemas/TraceItem'
          type: array
        schema:
          type: string
      type: object
    TraceUsage:
      description: |-
        TraceUsage is a trace's total token/cost rollup. Fields are pinned
        (no omitempty) so the object shape is uniform across traces.
      properties:
        cache_creation_tokens:
          format: int64
          type: integer
        cache_read_tokens:
          format: int64
          type: integer
        cost_usd:
          format: double
          type: number
        input_tokens:
          format: int64
          type: integer
        output_tokens:
          format: int64
          type: integer
      type: object
    TreeTask:
      description: |-
        TreeTask is one task folded from the session's TaskCreate/TaskUpdate
        calls.
      properties:
        description:
          type: string
        id:
          type: string
        status:
          type: string
        subject:
          type: string
        updates:
          format: int32
          type: integer
      type: object
    createSkillRequest:
      description: |-
        createSkillRequest is the POST /v1/skills body for an authored-from-scratch
        skill — only a name is required; the rest default to an empty private draft.
      properties:
        content:
          type: string
        description:
          type: string
        name:
          type: string
        tags:
          items:
            type: string
          type: array
        type:
          type: string
      type: object
    deriveRunResponse:
      description: |-
        deriveRunResponse is the derive-run result, keyed by org.

        Declared as a type rather than assembled inline so the published schema is
        generated from the shape the handler actually returns; a fiber.Map would
        leave swag with nothing to describe and the endpoint documented as an opaque
        object.
      properties:
        orgs:
          additionalProperties:
            $ref: '#/components/schemas/RederiveReport'
          type: object
      type: object
    generateSkillRequest:
      description: |-
        generateSkillRequest is the POST /v1/skills/generate body. It mirrors the
        console's GenerateSkillInput: the client nominates source sessions plus
        optional hints, and the server is authoritative on the skill body. Wire
        shape is camelCase to match the console's skills schemas (which predate and
        diverge from the snake_case convention the rest of tapes uses).
      properties:
        hint:
          properties:
            description:
              type: string
            name:
              type: string
            tags:
              items:
                type: string
              type: array
            type:
              type: string
          type: object
        sessionIds:
          items:
            type: string
          type: array
      type: object
    publishSkillRequest:
      description: publishSkillRequest is the POST /v1/skills/:slug/versions body.
      properties:
        changelog:
          type: string
        content:
          type: string
      type: object
    seedDemoRequest:
      properties:
        overwrite:
          type: boolean
      type: object
    sessionSkillsResponse:
      description: |-
        sessionSkillsResponse is the envelope for the skills attributed to one
        session. Unpaginated: a session's skill count is bounded by what was
        generated from it.
      properties:
        items:
          items:
            $ref: '#/components/schemas/skillResponse'
          type: array
      type: object
    sessionUpdateRequest:
      description: |-
        sessionUpdateRequest is the PATCH /v1/sessions/:id body. DisplayName is a
        pointer so an absent field (nil) is distinguishable from an explicit null
        or an empty string, both of which mean "clear back to the auto-derived
        title" (CC-3); an absent field is a 400 (nothing to update). The field is
        display_name (not name) so the request matches the display_name it sets on
        the response — and never the harness identity `name` (PCC-970).
      properties:
        display_name:
          type: string
      type: object
    skillCountsResp:
      description: |-
        skillCountsResp are the tab counts for the current search: all matching,
        authored by the caller (mine), and everyone else's (team = all - mine).
      properties:
        all:
          format: int64
          type: integer
        mine:
          format: int64
          type: integer
        team:
          format: int64
          type: integer
      type: object
    skillResponse:
      description: |-
        skillResponse is the unified Skill shape the console expects (camelCase). id
        is the opaque identity / route key; slug is a cosmetic display label. content
        always lives on the skill row (versions are history only); parentId is null
        unless the skill is a duplicate/fork.
      properties:
        authorId:
          type: string
        content:
          type: string
        createdAt:
          type: string
        description:
          type: string
        downloadCount:
          format: int64
          type: integer
        id:
          type: string
        isAiGenerated:
          type: boolean
        name:
          type: string
        originatingSessionIds:
          items:
            type: string
          type: array
        parentId:
          type: string
        slug:
          type: string
        tags:
          items:
            type: string
          type: array
        type:
          type: string
        updatedAt:
          type: string
        version:
          type: string
        visibility:
          type: string
      type: object
    skillVersionResponse:
      description: skillVersionResponse is one immutable published snapshot.
      properties:
        authorId:
          type: string
        changelog:
          type: string
        content:
          type: string
        id:
          type: string
        publishedAt:
          type: string
        semver:
          type: string
        skillId:
          type: string
        versionNumber:
          format: int32
          type: integer
      type: object
    skillVersionsResponse:
      description: |-
        skillVersionsResponse is the full version history for one skill, newest
        first. TotalCount is the length of Versions — the history is returned whole
        rather than paged, so the two never disagree.
      properties:
        totalCount:
          format: int32
          type: integer
        versions:
          items:
            $ref: '#/components/schemas/skillVersionResponse'
          type: array
      type: object
    skillsListResponse:
      description: |-
        skillsListResponse is the paginated list envelope: one keyset page plus the
        opaque next_cursor (mirroring /v1/sessions) and the per-tab counts for the
        active search.
      properties:
        counts:
          $ref: '#/components/schemas/skillCountsResp'
        items:
          items:
            $ref: '#/components/schemas/skillResponse'
          type: array
        next_cursor:
          type: string
      type: object
    updateSkillRequest:
      description: |-
        updateSkillRequest is the PUT /v1/skills/:slug body — all fields optional;
        only present fields are applied onto the existing record.
      properties:
        content:
          type: string
        description:
          type: string
        name:
          type: string
        tags:
          items:
            type: string
          type: array
        type:
          type: string
        visibility:
          type: string
      type: object
info:
  description: |-
    HTTP API for inspecting, querying, and searching stored Tapes sessions.

    The REST surface exposes health checks, session listing and retrieval, derived session summaries, aggregate stats, semantic search, skill authoring and publishing, operator maintenance endpoints, and a streamable MCP endpoint.

    Not covered here: the ingest write surface, which is a separate server that publishes its own contract at its own /openapi.
  title: Tapes API
  version: "1.0"
openapi: 3.0.3
paths:
  /ping:
    get:
      description: Returns a simple JSON string confirming that the API server is
        reachable.
      operationId: ping
      responses:
        "200":
          content:
            application/json:
              schema:
                type: string
          description: pong
      summary: Health check
      tags:
      - health
  /v1/admin/derive/run:
    post:
      description: |-
        Rebuilds traces, spans, links, and session rollups for every org from the immutable raw-turn store. Idempotent: re-running reproduces the same projection and prunes rows the current derive no longer emits.

        This is how a projection or classifier change reaches already-captured data — it re-derives rather than re-captures. Cost scales with the raw layer, so it is an operator lever, not a request-path call.
      operationId: runDerive
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/deriveRunResponse'
          description: Per-org derive reports
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Derive failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Driver does not host the raw-turn layer
      summary: Re-derive the span projection (operator)
      tags:
      - admin
  /v1/admin/raw-turns/attribution-repair:
    post:
      description: Records an audited, append-only attribution correction without
        modifying raw_turns, then synchronously re-derives the previous and effective
        sessions. Select exactly one row by raw_turn_id or paper_proxy_request_id.
      operationId: repairRawTurnAttribution
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RawTurnAttributionRepairRequest'
        description: Attribution repair
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RawTurnAttributionRepairResult'
          description: Repair applied; source_cleanup_pending discloses a cosmetic
            leftover source session row that nothing retries automatically
        "202":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RawTurnAttributionRepairResult'
          description: Correction recorded; projections_pending lists sessions the
            derive worker will converge
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid payload or replacement attribution
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Raw turn not found
        "409":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Correlation selector is ambiguous
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Repair failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Driver does not support attribution repair
      summary: Repair raw-turn attribution (operator)
      tags:
      - admin
  /v1/admin/seed/demo:
    post:
      description: 'Replays the bundled demo capture corpora through the ingest write
        path into the caller''s org, then derives the seeded sessions. Idempotent:
        raw-turn dedup makes repeat seeds no-ops.'
      operationId: seedDemo
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/seedDemoRequest'
        description: Seed options (overwrite is no longer supported)
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeedResult'
          description: What was seeded
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid payload or unsupported option
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Seeding failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Driver does not host the raw-turn layer
      summary: Seed demo sessions (operator)
      tags:
      - admin
  /v1/cassettes:
    get:
      description: Lists the cassettes served by this API, their public route and
        OpenAPI paths, and any configured cassette sources that could not be loaded.
      operationId: listCassettes
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Discovery'
          description: What is installed here, and what failed
      summary: Discover installed cassettes
      tags:
      - cassettes
  /v1/mcp:
    delete:
      description: Requests termination of a streamable MCP session when a client
        is using session-oriented transport semantics.
      operationId: closeMcpSession
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MCPResponse'
          description: Session closed
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MCPResponse'
          description: Invalid request
      summary: Close an MCP session
      tags:
      - mcp
    get:
      description: Opens the streamable MCP endpoint for server-sent events. Stateless
        clients can use this to receive streamed MCP messages.
      operationId: openMcpStream
      responses:
        "200":
          content:
            text/event-stream:
              schema:
                type: string
          description: Server-sent event stream
      summary: Open an MCP event stream
      tags:
      - mcp
    post:
      description: |-
        Sends a JSON-RPC 2.0 request to the stateless Model Context Protocol endpoint mounted at /v1/mcp.

        Typical calls include initialize, tools/list, and tools/call. The server exposes tools advertised by installed cassettes, plus the legacy core search tool while search is configured in core.
      operationId: invokeMcp
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MCPRequest'
        description: JSON-RPC 2.0 request
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MCPResponse'
          description: JSON-RPC 2.0 response
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MCPResponse'
          description: Invalid JSON-RPC request
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MCPResponse'
          description: Server-side MCP error
      summary: Invoke the streamable MCP endpoint
      tags:
      - mcp
  /v1/search/spans:
    get:
      description: Embeds the query text and runs vector similarity over the embedded
        span projection (main llm spans, delta-only content). Each hit carries span,
        trace, and turn context.
      operationId: searchSpans
      parameters:
      - description: Search query
        in: query
        name: query
        required: true
        schema:
          type: string
      - description: Maximum number of results to return
        in: query
        name: top_k
        schema:
          default: 5
          minimum: 1
          type: integer
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpanSearchOutput'
          description: Search hits
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or invalid query parameters
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Search execution failed
        "503":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Span search is not configured or not yet initialized
      summary: Semantic search over span embeddings
      tags:
      - search
  /v1/sessions:
    get:
      description: Returns one row per harness session from the sessions table, cursor-paginated.
        Default order is last_active (last_seen_at) desc; override with the sort and
        direction query params.
      operationId: listSessions
      parameters:
      - description: Maximum number of sessions to return (default 50, max 200)
        in: query
        name: limit
        schema:
          minimum: 1
          type: integer
      - description: Opaque pagination cursor returned by a previous response
        in: query
        name: cursor
        schema:
          type: string
      - description: 'Sort column: last_active|started_at|turn_count|total_cost_usd|total_tokens|duration_ns|derived_status|auth_subject
          (default last_active)'
        in: query
        name: sort
        schema:
          type: string
      - description: 'Sort direction: asc|desc (default desc)'
        in: query
        name: direction
        schema:
          enum:
          - asc
          - desc
          type: string
      - description: Only include sessions with a turn started at or after this RFC3339
          timestamp (activity window, matches /v1/stats)
        in: query
        name: since
        schema:
          format: date-time
          type: string
      - description: Only include sessions with a turn started before this RFC3339
          timestamp (activity window, matches /v1/stats)
        in: query
        name: until
        schema:
          format: date-time
          type: string
      - description: 'Combined with harness_session_id, narrows the filter to the
          single session with this harness id (exact match). Rejected alone (400):
          a harness id names a harness, not a session. Incompatible with cursor, sort,
          direction, since, and until (400); limit is ignored when the filter is active'
        in: query
        name: harness_id
        schema:
          type: string
      - description: Filter to sessions with this harness session id (exact match).
          Alone it matches across all harnesses — the id is unique per harness, so
          at most one row per harness returns, in practice zero or one; with harness_id
          it is a single-harness point lookup. Incompatible with cursor, sort, direction,
          since, and until (400); limit is ignored when the filter is active
        in: query
        name: harness_session_id
        schema:
          type: string
      - description: Filter the paged list to sessions captured for this gateway-stamped
          JWT subject (exact match; ignored on the harness filter path)
        in: query
        name: auth_subject
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionListResponse'
          description: One page of sessions
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid query parameters, a lone harness_id, or cursor, sort,
            direction, since, or until combined with the harness filter
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to list sessions
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Sessions not supported by this backend
      summary: List sessions
      tags:
      - sessions
  /v1/sessions/{id}:
    delete:
      description: 'Permanently deletes a session and its subtree: subagent child
        sessions and their derived traces/spans cascade with it. The immutable raw_turns
        capture log is left intact.'
      operationId: deleteSession
      parameters:
      - description: Session id (UUID)
        in: path
        name: id
        required: true
        schema:
          type: string
      responses:
        "204":
          description: Session deleted
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or malformed id
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Session not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to delete session
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Sessions not supported by this backend
      summary: Delete a session
      tags:
      - sessions
    get:
      description: 'Returns a single session record. The conversation content lives
        on the span model: GET /v1/sessions/{id}/traces.'
      operationId: getSession
      parameters:
      - description: Session id (UUID)
        in: path
        name: id
        required: true
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionDetailResponse'
          description: The session
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or malformed id
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Session not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to load session
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Sessions not supported by this backend
      summary: Get a session
      tags:
      - sessions
    patch:
      description: Updates the user-editable display_name. An absent field is a 400;
        null or empty (after trim) clears back to the auto-derived title. Length is
        bounded to 200 characters.
      operationId: updateSession
      parameters:
      - description: Session id (UUID)
        in: path
        name: id
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/sessionUpdateRequest'
        description: Update request
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionDetailResponse'
          description: The updated session
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing/malformed id, missing display_name field, or display_name
            exceeds 200 characters
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Session not found or not in caller's org
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to update session
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Sessions not supported by this backend
      summary: Update a session's title
      tags:
      - sessions
  /v1/sessions/{id}/export:
    get:
      description: 'Returns the session as a single JSON line (downloadable attachment):
        the session object with its traces, each trace carrying its full spans — the
        same shape as GET /v1/sessions/{id}/traces with payload=full. detail=traces
        exports turn headers only (no spans or links).'
      operationId: exportSession
      parameters:
      - description: Session id (UUID)
        in: path
        name: id
        required: true
        schema:
          type: string
      - description: 'Export granularity: spans (default, traces with full spans)
          or traces (turn headers only)'
        in: query
        name: detail
        schema:
          enum:
          - spans
          - traces
          type: string
      responses:
        "200":
          content:
            application/x-ndjson:
              schema:
                type: string
          description: JSONL body, one session object with nested traces (and spans
            at detail=spans)
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or malformed id, or unrecognized detail
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Session not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to load or render the session
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Sessions not supported by this backend
      summary: Export a session as JSONL
      tags:
      - sessions
  /v1/sessions/{id}/raw_turns:
    get:
      description: 'The raw layer''s wire log: one row per captured call or transcript
        push, identity and sizes only. `source` distinguishes what crossed the wire
        from what the harness pushed as its own account.'
      operationId: listRawTurns
      parameters:
      - description: Session id (UUID)
        in: path
        name: id
        required: true
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RawTurnListResponse'
          description: The session's raw turn headers
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or malformed id
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Session not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to list raw turns
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Raw turns not supported by this backend
      summary: List a session's raw capture log (operator)
      tags:
      - sessions
  /v1/sessions/{id}/skills:
    get:
      description: Every skill generated from the given session. Unpaginated — the
        count is bounded by what was generated from that one session.
      operationId: listSessionSkills
      parameters:
      - description: Session id
        in: path
        name: id
        required: true
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/sessionSkillsResponse'
          description: The session's skills
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Listing failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Backend does not support skills
      summary: List a session's skills
      tags:
      - skills
  /v1/sessions/{id}/traces:
    get:
      description: Returns the session's user-visible turns as traces with nested
        spans (llm calls, tools, subagents, shadow calls, injected context) and dataflow
        links. Cross-trace links (compaction seams) are at the response top level.
      operationId: getSessionTraces
      parameters:
      - description: Session id (UUID)
        in: path
        name: id
        required: true
        schema:
          type: string
      - description: 'Span payload mode: full (default) or preview (strings truncated;
          fetch the span endpoint for full payloads)'
        in: query
        name: payload
        schema:
          enum:
          - full
          - preview
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionTracesResponse'
          description: The session's traces and spans
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or malformed id
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Session not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to load session
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Span traces not supported by this backend
      summary: Get a session's trace/span projection
      tags:
      - sessions
  /v1/sessions/export:
    get:
      description: Streams one JSON line per session in the given window, newest-first,
        as a downloadable attachment. Each line is the session object with its traces,
        each trace carrying its full spans — the same shape as GET /v1/sessions/{id}/traces
        with payload=full. detail=traces exports turn headers only (no spans or links).
        Defaults to the trailing 30 days. Not bounded by the /v1/sessions list cap
        — pages internally.
      operationId: exportSessions
      parameters:
      - description: 'Only include sessions with a turn started at or after this RFC3339
          timestamp (activity window; default: now - 30 days)'
        in: query
        name: since
        schema:
          format: date-time
          type: string
      - description: Only include sessions with a turn started before this RFC3339
          timestamp (activity window)
        in: query
        name: until
        schema:
          format: date-time
          type: string
      - description: 'Export granularity: spans (default, traces with full spans)
          or traces (turn headers only)'
        in: query
        name: detail
        schema:
          enum:
          - spans
          - traces
          type: string
      responses:
        "200":
          content:
            application/x-ndjson:
              schema:
                type: string
          description: JSONL body, one JSON object per session with nested traces
            (and spans at detail=spans)
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Malformed since/until, or unrecognized detail
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to list or render sessions
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Sessions not supported by this backend
      summary: Export sessions in a time window as JSONL
      tags:
      - sessions
  /v1/skills:
    get:
      description: |-
        One keyset page of the org's skills, newest-edited first, plus per-tab counts for the active search. Pagination mirrors /v1/sessions: pass the returned next_cursor to continue; its absence means the last page.

        The counts are computed over the whole matching set rather than the loaded page, so a filtered tab shows a true total.
      operationId: listSkills
      parameters:
      - description: Page size (default 24, max 100)
        in: query
        name: limit
        schema:
          minimum: 1
          type: integer
      - description: Opaque keyset cursor from a previous next_cursor. Reset it when
          changing sort.
        in: query
        name: cursor
        schema:
          type: string
      - description: Search over name, description, and tags
        in: query
        name: q
        schema:
          type: string
      - description: Which slice to return
        in: query
        name: scope
        schema:
          enum:
          - all
          - mine
          - team
          type: string
      - description: Ordering; defaults to most recently updated
        in: query
        name: sort
        schema:
          enum:
          - downloads
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/skillsListResponse'
          description: One page of skills
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Malformed cursor
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Listing failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Backend does not support skills
      summary: List skills
      tags:
      - skills
    post:
      description: Creates a skill authored by hand, as opposed to the generator.
        The caller supplies the content; nothing is inferred.
      operationId: createSkill
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/createSkillRequest'
        description: Skill to create
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/skillResponse'
          description: The created skill
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid body or unknown type
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Create failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Backend does not support skills
      summary: Create a skill
      tags:
      - skills
  /v1/skills/{id}:
    delete:
      description: Deletes the skill and its version history. Only the creator may
        delete; another member of the same org gets 403 rather than 404, so the skill's
        existence is not hidden from someone who can already list it.
      operationId: deleteSkill
      parameters:
      - description: Skill id
        in: path
        name: id
        required: true
        schema:
          type: string
      responses:
        "204":
          description: Deleted
        "403":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Only the creator can delete this skill
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Skill not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Delete failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Backend does not support skills
      summary: Delete a skill
      tags:
      - skills
    get:
      description: Returns one skill by its opaque id. The id is the route key; slug
        is a cosmetic display label and is not addressable.
      operationId: getSkill
      parameters:
      - description: Skill id
        in: path
        name: id
        required: true
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/skillResponse'
          description: The skill
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Skill not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Lookup failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Backend does not support skills
      summary: Get a skill
      tags:
      - skills
    put:
      description: Partial update of the skill head. Every field is optional; omitted
        fields are left as they are. Editing the head does not publish — use the versions
        endpoint to snapshot.
      operationId: updateSkill
      parameters:
      - description: Skill id
        in: path
        name: id
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updateSkillRequest'
        description: Fields to change
        required: true
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/skillResponse'
          description: The updated skill
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid body or unknown type
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Skill not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Save failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Backend does not support skills
      summary: Update a skill
      tags:
      - skills
  /v1/skills/{id}/duplicate:
    post:
      description: Forks a skill into a new one owned by the caller, with parentId
        set to the source. The copy starts its own version history; the source is
        untouched.
      operationId: duplicateSkill
      parameters:
      - description: Skill id to duplicate
        in: path
        name: id
        required: true
        schema:
          type: string
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/skillResponse'
          description: The duplicated skill
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Skill not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Duplicate failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Backend does not support skills
      summary: Duplicate a skill
      tags:
      - skills
  /v1/skills/{id}/skill.md:
    get:
      description: |-
        Renders the skill as an on-disk SKILL.md, served as an attachment. The frontmatter name is the kebab slug, which is what a harness matches to the skill's directory — not the human display name.

        Serving this counts a download, best-effort: a failed counter write never fails the download.
      operationId: getSkillMarkdown
      parameters:
      - description: Skill id
        in: path
        name: id
        required: true
        schema:
          type: string
      responses:
        "200":
          content:
            text/markdown:
              schema:
                type: string
          description: SKILL.md document
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Skill not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Lookup failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Backend does not support skills
      summary: Download a skill as SKILL.md
      tags:
      - skills
  /v1/skills/{id}/versions:
    get:
      description: Full published history for one skill, newest first. Returned whole
        rather than paged, so totalCount is always the length of versions.
      operationId: listSkillVersions
      parameters:
      - description: Skill id
        in: path
        name: id
        required: true
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/skillVersionsResponse'
          description: The skill's versions
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Listing failed
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Backend does not support skills
      summary: List a skill's versions
      tags:
      - skills
    post:
      description: 'Snapshots the skill''s current content as an immutable version
        and advances the skill''s semver. Versions are history: the head content stays
        on the skill row, so reading a skill never needs its versions.'
      operationId: publishSkill
      parameters:
      - description: Skill id
        in: path
        name: id
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/publishSkillRequest'
        description: Version metadata
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/skillVersionResponse'
          description: The published version
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Skill not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Publish failed, or the version landed but the head could not
            be advanced
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Backend does not support skills
      summary: Publish a skill version
      tags:
      - skills
  /v1/skills/generate:
    post:
      description: |-
        Runs the LLM skill generator over the nominated sessions and persists the result. The client nominates sources and optional hints; the server is authoritative on the skill body.

        Source sessions are read through an org-scoped in-process querier, so generation only ever sees sessions in the caller's tenant.
      operationId: generateSkill
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/generateSkillRequest'
        description: Source sessions and optional hints
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/skillResponse'
          description: The generated skill
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid body, or sessionIds missing/empty
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: One or more source sessions were not found
        "422":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Sources carried nothing the generator could use
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Generation or persistence failed, or no LLM provider is configured
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Backend does not support skills
      summary: Generate a skill from sessions
      tags:
      - skills
  /v1/stats:
    get:
      description: Returns counts plus cost / token / duration / tool-call / completed-count
        totals for the window. The numbers are span-grain trace rollup sums (delta-only
        usage, agent time = sum of trace durations) so they agree with the session
        and trace views; turn_count counts traces. Filter the window with since/until,
        and narrow every total to one user with auth_subject — the same subject the
        /v1/sessions filter takes, so a personal surface can show totals that match
        the rows beside them.
      operationId: getStats
      parameters:
      - description: Only include records at or after this RFC3339 timestamp
        in: query
        name: since
        schema:
          format: date-time
          type: string
      - description: Only include records before or at this RFC3339 timestamp
        in: query
        name: until
        schema:
          format: date-time
          type: string
      - description: Narrow every total to sessions captured for this gateway-stamped
          JWT subject (exact match). Omitted, the totals are org-wide. A subject with
          no sessions in the window aggregates to zeros, not an error
        in: query
        name: auth_subject
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StatsResponse'
          description: Aggregate stats for the window
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Invalid query parameters
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to compute stats
      summary: Get aggregate session stats
      tags:
      - sessions
  /v1/traces:
    get:
      description: Returns turn headers for a session — no span payloads. Fetch GET
        /v1/traces/{trace_id} per turn for spans and links.
      operationId: listTraces
      parameters:
      - description: Session id (UUID)
        in: query
        name: session_id
        required: true
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraceListResponse'
          description: The session's trace summaries
        "400":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or malformed session_id
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to list traces
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Traces not supported by this backend
      summary: List a session's traces (summaries)
      tags:
      - traces
  /v1/traces/{trace_id}:
    get:
      description: 'Returns one user-visible turn: its spans nested by parent_span_id
        and its dataflow links (links touching other traces included).'
      operationId: getTrace
      parameters:
      - description: Trace id
        in: path
        name: trace_id
        required: true
        schema:
          type: string
      - description: 'Span payload mode: full (default) or preview (strings truncated;
          fetch the span endpoint for full payloads)'
        in: query
        name: payload
        schema:
          enum:
          - full
          - preview
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraceDetail'
          description: The trace
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Trace not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to load trace
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Traces not supported by this backend
      summary: Get one trace with spans and links
      tags:
      - traces
  /v1/traces/{trace_id}/spans/{span_id}:
    get:
      description: 'The payload drill-in: one span''s complete input/output content.'
      operationId: getSpan
      parameters:
      - description: Trace id
        in: path
        name: trace_id
        required: true
        schema:
          type: string
      - description: Span id
        in: path
        name: span_id
        required: true
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpanItem'
          description: The span
        "404":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Span not found
        "500":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Failed to load span
        "501":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Spans not supported by this backend
      summary: Get one span with full payloads
      tags:
      - traces