@semiont/core 0.4.19 → 0.4.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -7,304 +7,6 @@ export { A as AnthropicProviderConfig, a as AppConfig, B as BackendServiceConfig
7
7
  * Do not make direct changes to the file.
8
8
  */
9
9
  interface paths {
10
- "/resources/{id}": {
11
- parameters: {
12
- query?: never;
13
- header?: never;
14
- path?: never;
15
- cookie?: never;
16
- };
17
- /**
18
- * Get Resource by URI (W3C Content Negotiation)
19
- * @description W3C-compliant globally resolvable resource URI with content negotiation. Returns JSON-LD metadata (Accept: application/ld+json), raw representation (Accept: text/plain, text/markdown, etc.), or redirects to frontend (?view=semiont). Requires authentication.
20
- */
21
- get: {
22
- parameters: {
23
- query?: {
24
- /** @description Optional view parameter. If set to 'semiont', redirects to frontend viewer. */
25
- view?: "semiont";
26
- };
27
- header?: never;
28
- path: {
29
- /** @description Resource ID */
30
- id: string;
31
- };
32
- cookie?: never;
33
- };
34
- requestBody?: never;
35
- responses: {
36
- /** @description Resource metadata (JSON-LD) or raw representation */
37
- 200: {
38
- headers: {
39
- [name: string]: unknown;
40
- };
41
- content: {
42
- "application/ld+json": components["schemas"]["GetResourceResponse"];
43
- "text/plain": string;
44
- "text/markdown": string;
45
- };
46
- };
47
- /** @description Redirect to frontend viewer (when ?view=semiont) */
48
- 302: {
49
- headers: {
50
- [name: string]: unknown;
51
- };
52
- content?: never;
53
- };
54
- /** @description Resource not found */
55
- 404: {
56
- headers: {
57
- [name: string]: unknown;
58
- };
59
- content?: never;
60
- };
61
- };
62
- };
63
- put?: never;
64
- post?: never;
65
- delete?: never;
66
- options?: never;
67
- head?: never;
68
- /**
69
- * Update Resource
70
- * @description Update resource metadata (append-only operations - name and content are immutable)
71
- */
72
- patch: {
73
- parameters: {
74
- query?: never;
75
- header?: never;
76
- path: {
77
- /** @description Resource ID */
78
- id: string;
79
- };
80
- cookie?: never;
81
- };
82
- requestBody?: {
83
- content: {
84
- "application/json": components["schemas"]["UpdateResourceRequest"];
85
- };
86
- };
87
- responses: {
88
- /** @description Update accepted */
89
- 202: {
90
- headers: {
91
- [name: string]: unknown;
92
- };
93
- content?: never;
94
- };
95
- /** @description Resource not found */
96
- 404: {
97
- headers: {
98
- [name: string]: unknown;
99
- };
100
- content?: never;
101
- };
102
- };
103
- };
104
- trace?: never;
105
- };
106
- "/annotations/{id}": {
107
- parameters: {
108
- query?: never;
109
- header?: never;
110
- path?: never;
111
- cookie?: never;
112
- };
113
- /**
114
- * Get Annotation by URI (W3C Content Negotiation)
115
- * @description W3C-compliant globally resolvable annotation URI with content negotiation. Returns JSON-LD for API clients (Accept: application/ld+json or application/json). Redirects to frontend for browsers (Accept: text/html or browser User-Agent). Requires authentication and resourceId query parameter.
116
- */
117
- get: {
118
- parameters: {
119
- query: {
120
- /** @description Resource ID or URI containing the annotation */
121
- resourceId: string;
122
- };
123
- header?: never;
124
- path: {
125
- /** @description Annotation ID */
126
- id: string;
127
- };
128
- cookie?: never;
129
- };
130
- requestBody?: never;
131
- responses: {
132
- /** @description Annotation representation (JSON-LD) */
133
- 200: {
134
- headers: {
135
- [name: string]: unknown;
136
- };
137
- content: {
138
- "application/ld+json": components["schemas"]["GetAnnotationResponse"];
139
- };
140
- };
141
- /** @description Redirect to frontend (for browsers) */
142
- 302: {
143
- headers: {
144
- [name: string]: unknown;
145
- };
146
- content?: never;
147
- };
148
- /** @description Missing resourceId parameter */
149
- 400: {
150
- headers: {
151
- [name: string]: unknown;
152
- };
153
- content?: never;
154
- };
155
- /** @description Annotation not found */
156
- 404: {
157
- headers: {
158
- [name: string]: unknown;
159
- };
160
- content?: never;
161
- };
162
- };
163
- };
164
- put?: never;
165
- post?: never;
166
- delete?: never;
167
- options?: never;
168
- head?: never;
169
- patch?: never;
170
- trace?: never;
171
- };
172
- "/api/annotations/{id}/context": {
173
- parameters: {
174
- query?: never;
175
- header?: never;
176
- path?: never;
177
- cookie?: never;
178
- };
179
- /**
180
- * Get Annotation Context
181
- * @description Get the text context around an annotation with configurable before/after window
182
- */
183
- get: {
184
- parameters: {
185
- query: {
186
- /** @description Resource ID containing the annotation */
187
- resourceId: string;
188
- /** @description Number of characters before the selection */
189
- contextBefore?: number;
190
- /** @description Number of characters after the selection */
191
- contextAfter?: number;
192
- };
193
- header?: never;
194
- path: {
195
- /** @description Annotation ID */
196
- id: string;
197
- };
198
- cookie?: never;
199
- };
200
- requestBody?: never;
201
- responses: {
202
- /** @description Annotation context */
203
- 200: {
204
- headers: {
205
- [name: string]: unknown;
206
- };
207
- content: {
208
- "application/json": components["schemas"]["AnnotationContextResponse"];
209
- };
210
- };
211
- /** @description Invalid query parameters */
212
- 400: {
213
- headers: {
214
- [name: string]: unknown;
215
- };
216
- content?: never;
217
- };
218
- /** @description Authentication required */
219
- 401: {
220
- headers: {
221
- [name: string]: unknown;
222
- };
223
- content?: never;
224
- };
225
- /** @description Annotation not found */
226
- 404: {
227
- headers: {
228
- [name: string]: unknown;
229
- };
230
- content?: never;
231
- };
232
- };
233
- };
234
- put?: never;
235
- post?: never;
236
- delete?: never;
237
- options?: never;
238
- head?: never;
239
- patch?: never;
240
- trace?: never;
241
- };
242
- "/api/annotations/{id}/summary": {
243
- parameters: {
244
- query?: never;
245
- header?: never;
246
- path?: never;
247
- cookie?: never;
248
- };
249
- /**
250
- * Get Annotation Summary
251
- * @description Get an AI-generated summary of the annotation in context
252
- */
253
- get: {
254
- parameters: {
255
- query: {
256
- /** @description Resource ID containing the annotation */
257
- resourceId: string;
258
- };
259
- header?: never;
260
- path: {
261
- /** @description Annotation ID */
262
- id: string;
263
- };
264
- cookie?: never;
265
- };
266
- requestBody?: never;
267
- responses: {
268
- /** @description AI-generated annotation summary */
269
- 200: {
270
- headers: {
271
- [name: string]: unknown;
272
- };
273
- content: {
274
- "application/json": components["schemas"]["ContextualSummaryResponse"];
275
- };
276
- };
277
- /** @description Missing resourceId parameter */
278
- 400: {
279
- headers: {
280
- [name: string]: unknown;
281
- };
282
- content?: never;
283
- };
284
- /** @description Authentication required */
285
- 401: {
286
- headers: {
287
- [name: string]: unknown;
288
- };
289
- content?: never;
290
- };
291
- /** @description Annotation not found */
292
- 404: {
293
- headers: {
294
- [name: string]: unknown;
295
- };
296
- content?: never;
297
- };
298
- };
299
- };
300
- put?: never;
301
- post?: never;
302
- delete?: never;
303
- options?: never;
304
- head?: never;
305
- patch?: never;
306
- trace?: never;
307
- };
308
10
  "/api/health": {
309
11
  parameters: {
310
12
  query?: never;
@@ -618,6 +320,73 @@ interface paths {
618
320
  patch?: never;
619
321
  trace?: never;
620
322
  };
323
+ "/api/tokens/worker": {
324
+ parameters: {
325
+ query?: never;
326
+ header?: never;
327
+ path?: never;
328
+ cookie?: never;
329
+ };
330
+ get?: never;
331
+ put?: never;
332
+ /**
333
+ * Worker Token Exchange
334
+ * @description Exchange a shared secret for a bearer JWT. Used by workers and actors connecting to the EventBus.
335
+ */
336
+ post: {
337
+ parameters: {
338
+ query?: never;
339
+ header?: never;
340
+ path?: never;
341
+ cookie?: never;
342
+ };
343
+ requestBody: {
344
+ content: {
345
+ "application/json": {
346
+ /** @description The shared worker secret (SEMIONT_WORKER_SECRET) */
347
+ secret: string;
348
+ };
349
+ };
350
+ };
351
+ responses: {
352
+ /** @description Token issued */
353
+ 200: {
354
+ headers: {
355
+ [name: string]: unknown;
356
+ };
357
+ content: {
358
+ "application/json": {
359
+ /** @description Bearer JWT for subsequent authenticated requests */
360
+ token: string;
361
+ };
362
+ };
363
+ };
364
+ /** @description Invalid worker secret */
365
+ 401: {
366
+ headers: {
367
+ [name: string]: unknown;
368
+ };
369
+ content: {
370
+ "application/json": components["schemas"]["ErrorResponse"];
371
+ };
372
+ };
373
+ /** @description Worker authentication not configured */
374
+ 503: {
375
+ headers: {
376
+ [name: string]: unknown;
377
+ };
378
+ content: {
379
+ "application/json": components["schemas"]["ErrorResponse"];
380
+ };
381
+ };
382
+ };
383
+ };
384
+ delete?: never;
385
+ options?: never;
386
+ head?: never;
387
+ patch?: never;
388
+ trace?: never;
389
+ };
621
390
  "/api/users/me": {
622
391
  parameters: {
623
392
  query?: never;
@@ -1247,7 +1016,7 @@ interface paths {
1247
1016
  patch?: never;
1248
1017
  trace?: never;
1249
1018
  };
1250
- "/api/admin/exchange/export": {
1019
+ "/api/moderate/exchange/export": {
1251
1020
  parameters: {
1252
1021
  query?: never;
1253
1022
  header?: never;
@@ -1290,7 +1059,7 @@ interface paths {
1290
1059
  "application/json": components["schemas"]["ErrorResponse"];
1291
1060
  };
1292
1061
  };
1293
- /** @description Forbidden - Admin access required */
1062
+ /** @description Forbidden - moderator or admin role required */
1294
1063
  403: {
1295
1064
  headers: {
1296
1065
  [name: string]: unknown;
@@ -1307,7 +1076,7 @@ interface paths {
1307
1076
  patch?: never;
1308
1077
  trace?: never;
1309
1078
  };
1310
- "/api/admin/exchange/import": {
1079
+ "/api/moderate/exchange/import": {
1311
1080
  parameters: {
1312
1081
  query?: never;
1313
1082
  header?: never;
@@ -1366,7 +1135,7 @@ interface paths {
1366
1135
  "application/json": components["schemas"]["ErrorResponse"];
1367
1136
  };
1368
1137
  };
1369
- /** @description Forbidden - Admin access required */
1138
+ /** @description Forbidden - moderator or admin role required */
1370
1139
  403: {
1371
1140
  headers: {
1372
1141
  [name: string]: unknown;
@@ -1383,7 +1152,7 @@ interface paths {
1383
1152
  patch?: never;
1384
1153
  trace?: never;
1385
1154
  };
1386
- "/resources": {
1155
+ "/api/cookies/consent": {
1387
1156
  parameters: {
1388
1157
  query?: never;
1389
1158
  header?: never;
@@ -1391,129 +1160,25 @@ interface paths {
1391
1160
  cookie?: never;
1392
1161
  };
1393
1162
  /**
1394
- * List Resources
1395
- * @description List all resources with optional filters
1163
+ * Get cookie consent preferences
1164
+ * @description Returns the current user's cookie consent preferences.
1396
1165
  */
1397
1166
  get: {
1398
- parameters: {
1399
- query?: {
1400
- offset?: number | null;
1401
- limit?: number | null;
1402
- entityType?: string;
1403
- archived?: "true" | "false" | boolean;
1404
- search?: string;
1405
- /** @description Search query */
1406
- q?: string;
1407
- };
1408
- header?: never;
1409
- path?: never;
1410
- cookie?: never;
1411
- };
1412
- requestBody?: never;
1413
- responses: {
1414
- /** @description Resources listed successfully */
1415
- 200: {
1416
- headers: {
1417
- [name: string]: unknown;
1418
- };
1419
- content: {
1420
- "application/json": components["schemas"]["ListResourcesResponse"];
1421
- };
1422
- };
1423
- };
1424
- };
1425
- put?: never;
1426
- /**
1427
- * Create Resource
1428
- * @description Create a new resource
1429
- */
1430
- post: {
1431
1167
  parameters: {
1432
1168
  query?: never;
1433
1169
  header?: never;
1434
1170
  path?: never;
1435
1171
  cookie?: never;
1436
1172
  };
1437
- requestBody: {
1438
- content: {
1439
- "multipart/form-data": {
1440
- /** @description Resource name */
1441
- name: string;
1442
- /**
1443
- * Format: binary
1444
- * @description Binary content of the resource
1445
- */
1446
- file: string;
1447
- /** @description MIME type (e.g., text/markdown, image/png) */
1448
- format: string;
1449
- /** @description JSON-encoded array of entity types */
1450
- entityTypes?: string;
1451
- /** @description ISO 639-1 language code */
1452
- language?: string;
1453
- /** @description How the resource was created */
1454
- creationMethod?: string;
1455
- /** @description Source annotation ID (for generated resources) */
1456
- sourceAnnotationId?: string;
1457
- /** @description Source resource ID (for cloned resources) */
1458
- sourceResourceId?: string;
1459
- };
1460
- };
1461
- };
1462
- responses: {
1463
- /** @description Resource creation accepted */
1464
- 202: {
1465
- headers: {
1466
- [name: string]: unknown;
1467
- };
1468
- content: {
1469
- "application/json": {
1470
- resourceId: string;
1471
- };
1472
- };
1473
- };
1474
- };
1475
- };
1476
- delete?: never;
1477
- options?: never;
1478
- head?: never;
1479
- patch?: never;
1480
- trace?: never;
1481
- };
1482
- "/resources/{id}/annotate-references": {
1483
- parameters: {
1484
- query?: never;
1485
- header?: never;
1486
- path?: never;
1487
- cookie?: never;
1488
- };
1489
- get?: never;
1490
- put?: never;
1491
- /**
1492
- * Annotate References with Progress (SSE)
1493
- * @description Stream real-time reference annotation progress via Server-Sent Events
1494
- */
1495
- post: {
1496
- parameters: {
1497
- query?: never;
1498
- header?: never;
1499
- path: {
1500
- id: string;
1501
- };
1502
- cookie?: never;
1503
- };
1504
- requestBody?: {
1505
- content: {
1506
- "application/json": components["schemas"]["AnnotateReferencesStreamRequest"];
1507
- };
1508
- };
1173
+ requestBody?: never;
1509
1174
  responses: {
1510
- /** @description SSE stream opened successfully */
1175
+ /** @description Current consent preferences */
1511
1176
  200: {
1512
1177
  headers: {
1513
1178
  [name: string]: unknown;
1514
1179
  };
1515
1180
  content: {
1516
- "text/event-stream": components["schemas"]["EventStreamResponse"];
1181
+ "application/json": components["schemas"]["CookieConsentResponse"];
1517
1182
  };
1518
1183
  };
1519
1184
  /** @description Authentication required */
@@ -1521,117 +1186,46 @@ interface paths {
1521
1186
  headers: {
1522
1187
  [name: string]: unknown;
1523
1188
  };
1524
- content?: never;
1525
- };
1526
- /** @description Resource not found */
1527
- 404: {
1528
- headers: {
1529
- [name: string]: unknown;
1189
+ content: {
1190
+ "application/json": components["schemas"]["ErrorResponse"];
1530
1191
  };
1531
- content?: never;
1532
1192
  };
1533
1193
  };
1534
1194
  };
1535
- delete?: never;
1536
- options?: never;
1537
- head?: never;
1538
- patch?: never;
1539
- trace?: never;
1540
- };
1541
- "/resources/{id}/annotate-highlights": {
1542
- parameters: {
1543
- query?: never;
1544
- header?: never;
1545
- path?: never;
1546
- cookie?: never;
1547
- };
1548
- get?: never;
1549
1195
  put?: never;
1550
1196
  /**
1551
- * Annotate Highlights with Progress (SSE)
1552
- * @description Stream real-time highlight annotation progress via Server-Sent Events
1197
+ * Update cookie consent preferences
1198
+ * @description Update the current user's cookie consent preferences. The `necessary` flag must be true — necessary cookies cannot be disabled.
1553
1199
  */
1554
1200
  post: {
1555
1201
  parameters: {
1556
1202
  query?: never;
1557
1203
  header?: never;
1558
- path: {
1559
- id: string;
1560
- };
1204
+ path?: never;
1561
1205
  cookie?: never;
1562
1206
  };
1563
- requestBody?: {
1207
+ requestBody: {
1564
1208
  content: {
1565
- "application/json": components["schemas"]["AnnotateHighlightsStreamRequest"];
1209
+ "application/json": components["schemas"]["CookieConsentRequest"];
1566
1210
  };
1567
1211
  };
1568
1212
  responses: {
1569
- /** @description SSE stream opened successfully */
1213
+ /** @description Consent updated */
1570
1214
  200: {
1571
1215
  headers: {
1572
1216
  [name: string]: unknown;
1573
1217
  };
1574
1218
  content: {
1575
- "text/event-stream": components["schemas"]["EventStreamResponse"];
1576
- };
1577
- };
1578
- /** @description Authentication required */
1579
- 401: {
1580
- headers: {
1581
- [name: string]: unknown;
1219
+ "application/json": components["schemas"]["CookieConsentResponse"];
1582
1220
  };
1583
- content?: never;
1584
- };
1585
- /** @description Resource not found */
1586
- 404: {
1587
- headers: {
1588
- [name: string]: unknown;
1589
- };
1590
- content?: never;
1591
- };
1592
- };
1593
- };
1594
- delete?: never;
1595
- options?: never;
1596
- head?: never;
1597
- patch?: never;
1598
- trace?: never;
1599
- };
1600
- "/resources/{id}/annotate-assessments": {
1601
- parameters: {
1602
- query?: never;
1603
- header?: never;
1604
- path?: never;
1605
- cookie?: never;
1606
- };
1607
- get?: never;
1608
- put?: never;
1609
- /**
1610
- * Annotate Assessments with Progress (SSE)
1611
- * @description Stream real-time assessment annotation progress via Server-Sent Events
1612
- */
1613
- post: {
1614
- parameters: {
1615
- query?: never;
1616
- header?: never;
1617
- path: {
1618
- id: string;
1619
- };
1620
- cookie?: never;
1621
- };
1622
- requestBody?: {
1623
- content: {
1624
- "application/json": components["schemas"]["AnnotateAssessmentsStreamRequest"];
1625
1221
  };
1626
- };
1627
- responses: {
1628
- /** @description SSE stream opened successfully */
1629
- 200: {
1222
+ /** @description Invalid consent data (non-boolean fields, missing fields, or necessary=false) */
1223
+ 400: {
1630
1224
  headers: {
1631
1225
  [name: string]: unknown;
1632
1226
  };
1633
1227
  content: {
1634
- "text/event-stream": components["schemas"]["EventStreamResponse"];
1228
+ "application/json": components["schemas"]["CookieConsentResponse"];
1635
1229
  };
1636
1230
  };
1637
1231
  /** @description Authentication required */
@@ -1639,14 +1233,9 @@ interface paths {
1639
1233
  headers: {
1640
1234
  [name: string]: unknown;
1641
1235
  };
1642
- content?: never;
1643
- };
1644
- /** @description Resource not found */
1645
- 404: {
1646
- headers: {
1647
- [name: string]: unknown;
1236
+ content: {
1237
+ "application/json": components["schemas"]["ErrorResponse"];
1648
1238
  };
1649
- content?: never;
1650
1239
  };
1651
1240
  };
1652
1241
  };
@@ -1656,41 +1245,33 @@ interface paths {
1656
1245
  patch?: never;
1657
1246
  trace?: never;
1658
1247
  };
1659
- "/resources/{id}/annotate-comments": {
1248
+ "/api/cookies/export": {
1660
1249
  parameters: {
1661
1250
  query?: never;
1662
1251
  header?: never;
1663
1252
  path?: never;
1664
1253
  cookie?: never;
1665
1254
  };
1666
- get?: never;
1667
- put?: never;
1668
1255
  /**
1669
- * Annotate Comments with Progress (SSE)
1670
- * @description Stream real-time comment annotation progress via Server-Sent Events
1256
+ * Export cookie data (GDPR)
1257
+ * @description Export the current user's cookie-related data as a downloadable JSON file. Response sets `Content-Disposition: attachment; filename="cookie-data-export-<timestamp>.json"`.
1671
1258
  */
1672
- post: {
1259
+ get: {
1673
1260
  parameters: {
1674
1261
  query?: never;
1675
1262
  header?: never;
1676
- path: {
1677
- id: string;
1678
- };
1263
+ path?: never;
1679
1264
  cookie?: never;
1680
1265
  };
1681
- requestBody?: {
1682
- content: {
1683
- "application/json": components["schemas"]["AnnotateCommentsStreamRequest"];
1684
- };
1685
- };
1266
+ requestBody?: never;
1686
1267
  responses: {
1687
- /** @description SSE stream opened successfully */
1268
+ /** @description User cookie data as attachment */
1688
1269
  200: {
1689
1270
  headers: {
1690
1271
  [name: string]: unknown;
1691
1272
  };
1692
1273
  content: {
1693
- "text/event-stream": components["schemas"]["EventStreamResponse"];
1274
+ "application/json": components["schemas"]["CookieExportResponse"];
1694
1275
  };
1695
1276
  };
1696
1277
  /** @description Authentication required */
@@ -1698,786 +1279,21 @@ interface paths {
1698
1279
  headers: {
1699
1280
  [name: string]: unknown;
1700
1281
  };
1701
- content?: never;
1702
- };
1703
- /** @description Resource not found */
1704
- 404: {
1705
- headers: {
1706
- [name: string]: unknown;
1282
+ content: {
1283
+ "application/json": components["schemas"]["ErrorResponse"];
1707
1284
  };
1708
- content?: never;
1709
- };
1710
- };
1711
- };
1712
- delete?: never;
1713
- options?: never;
1714
- head?: never;
1715
- patch?: never;
1716
- trace?: never;
1717
- };
1718
- "/resources/{id}/annotate-tags": {
1719
- parameters: {
1720
- query?: never;
1721
- header?: never;
1722
- path?: never;
1723
- cookie?: never;
1724
- };
1725
- get?: never;
1726
- put?: never;
1727
- /**
1728
- * Annotate Tags with Progress (SSE)
1729
- * @description Stream real-time tag annotation progress via Server-Sent Events. Identifies passages serving specific structural roles (IRAC, IMRAD, Toulmin frameworks).
1730
- */
1731
- post: {
1732
- parameters: {
1733
- query?: never;
1734
- header?: never;
1735
- path: {
1736
- id: string;
1737
- };
1738
- cookie?: never;
1739
- };
1740
- requestBody?: {
1741
- content: {
1742
- "application/json": components["schemas"]["AnnotateTagsStreamRequest"];
1743
- };
1744
- };
1745
- responses: {
1746
- /** @description SSE stream opened successfully */
1747
- 200: {
1748
- headers: {
1749
- [name: string]: unknown;
1750
- };
1751
- content: {
1752
- "text/event-stream": components["schemas"]["EventStreamResponse"];
1753
- };
1754
- };
1755
- /** @description Authentication required */
1756
- 401: {
1757
- headers: {
1758
- [name: string]: unknown;
1759
- };
1760
- content?: never;
1761
- };
1762
- /** @description Resource not found */
1763
- 404: {
1764
- headers: {
1765
- [name: string]: unknown;
1766
- };
1767
- content?: never;
1768
- };
1769
- };
1770
- };
1771
- delete?: never;
1772
- options?: never;
1773
- head?: never;
1774
- patch?: never;
1775
- trace?: never;
1776
- };
1777
- "/resources/{id}/gather-resource-stream": {
1778
- parameters: {
1779
- query?: never;
1780
- header?: never;
1781
- path?: never;
1782
- cookie?: never;
1783
- };
1784
- get?: never;
1785
- put?: never;
1786
- /**
1787
- * Gather Resource LLM Context (SSE Stream)
1788
- * @description Stream real-time resource LLM context gathering progress via Server-Sent Events
1789
- */
1790
- post: {
1791
- parameters: {
1792
- query?: never;
1793
- header?: never;
1794
- path: {
1795
- id: string;
1796
- };
1797
- cookie?: never;
1798
- };
1799
- requestBody?: {
1800
- content: {
1801
- "application/json": components["schemas"]["GatherResourceStreamRequest"];
1802
- };
1803
- };
1804
- responses: {
1805
- /** @description SSE stream opened successfully */
1806
- 200: {
1807
- headers: {
1808
- [name: string]: unknown;
1809
- };
1810
- content: {
1811
- "text/event-stream": components["schemas"]["EventStreamResponse"];
1812
- };
1813
- };
1814
- /** @description Authentication required */
1815
- 401: {
1816
- headers: {
1817
- [name: string]: unknown;
1818
- };
1819
- content?: never;
1820
- };
1821
- /** @description Resource not found */
1822
- 404: {
1823
- headers: {
1824
- [name: string]: unknown;
1825
- };
1826
- content?: never;
1827
- };
1828
- };
1829
- };
1830
- delete?: never;
1831
- options?: never;
1832
- head?: never;
1833
- patch?: never;
1834
- trace?: never;
1835
- };
1836
- "/resources/{id}/match-search": {
1837
- parameters: {
1838
- query?: never;
1839
- header?: never;
1840
- path?: never;
1841
- cookie?: never;
1842
- };
1843
- get?: never;
1844
- put?: never;
1845
- /**
1846
- * Match Search
1847
- * @description Submit a match-search command for binding candidates. Returns {correlationId} immediately. Results are delivered asynchronously via the long-lived events-stream as match:search-results or match:search-failed events.
1848
- */
1849
- post: {
1850
- parameters: {
1851
- query?: never;
1852
- header?: never;
1853
- path: {
1854
- /** @description Resource ID */
1855
- id: string;
1856
- };
1857
- cookie?: never;
1858
- };
1859
- requestBody: {
1860
- content: {
1861
- "application/json": components["schemas"]["MatchSearchRequest"];
1862
- };
1863
- };
1864
- responses: {
1865
- /** @description Search command accepted. Results delivered via events-stream. */
1866
- 202: {
1867
- headers: {
1868
- [name: string]: unknown;
1869
- };
1870
- content: {
1871
- "application/json": {
1872
- correlationId: string;
1873
- };
1874
- };
1875
- };
1876
- /** @description Authentication required */
1877
- 401: {
1878
- headers: {
1879
- [name: string]: unknown;
1880
- };
1881
- content?: never;
1882
- };
1883
- /** @description Resource not found */
1884
- 404: {
1885
- headers: {
1886
- [name: string]: unknown;
1887
- };
1888
- content?: never;
1889
- };
1890
- };
1891
- };
1892
- delete?: never;
1893
- options?: never;
1894
- head?: never;
1895
- patch?: never;
1896
- trace?: never;
1897
- };
1898
- "/resources/{resourceId}/annotations/{annotationId}/gather": {
1899
- parameters: {
1900
- query?: never;
1901
- header?: never;
1902
- path?: never;
1903
- cookie?: never;
1904
- };
1905
- get?: never;
1906
- put?: never;
1907
- /**
1908
- * Gather Annotation Context
1909
- * @description Submit a gather-context command for an annotation. Returns {correlationId} immediately. The Gatherer assembles passage + graph context (long-running, involves LLM calls) and delivers results via the events-stream as gather:complete, gather:failed, or gather:annotation-progress events.
1910
- */
1911
- post: {
1912
- parameters: {
1913
- query?: never;
1914
- header?: never;
1915
- path: {
1916
- /** @description Resource ID */
1917
- resourceId: string;
1918
- /** @description Annotation ID */
1919
- annotationId: string;
1920
- };
1921
- cookie?: never;
1922
- };
1923
- requestBody: {
1924
- content: {
1925
- "application/json": components["schemas"]["GatherAnnotationStreamRequest"];
1926
- };
1927
- };
1928
- responses: {
1929
- /** @description Gather command accepted. Results delivered via events-stream. */
1930
- 202: {
1931
- headers: {
1932
- [name: string]: unknown;
1933
- };
1934
- content: {
1935
- "application/json": {
1936
- correlationId: string;
1937
- };
1938
- };
1939
- };
1940
- /** @description Authentication required */
1941
- 401: {
1942
- headers: {
1943
- [name: string]: unknown;
1944
- };
1945
- content?: never;
1946
- };
1947
- };
1948
- };
1949
- delete?: never;
1950
- options?: never;
1951
- head?: never;
1952
- patch?: never;
1953
- trace?: never;
1954
- };
1955
- "/resources/{id}/referenced-by": {
1956
- parameters: {
1957
- query?: never;
1958
- header?: never;
1959
- path?: never;
1960
- cookie?: never;
1961
- };
1962
- /**
1963
- * Get Referenced By
1964
- * @description Get resources that reference this resource
1965
- */
1966
- get: {
1967
- parameters: {
1968
- query?: {
1969
- /** @description Filter incoming references by W3C motivation type (e.g., 'linking', 'commenting', 'highlighting') */
1970
- motivation?: components["schemas"]["Motivation"];
1971
- };
1972
- header?: never;
1973
- path: {
1974
- id: string;
1975
- };
1976
- cookie?: never;
1977
- };
1978
- requestBody?: never;
1979
- responses: {
1980
- /** @description Resources that reference this resource */
1981
- 200: {
1982
- headers: {
1983
- [name: string]: unknown;
1984
- };
1985
- content: {
1986
- "application/json": components["schemas"]["GetReferencedByResponse"];
1987
- };
1988
- };
1989
- };
1990
- };
1991
- put?: never;
1992
- post?: never;
1993
- delete?: never;
1994
- options?: never;
1995
- head?: never;
1996
- patch?: never;
1997
- trace?: never;
1998
- };
1999
- "/api/clone-tokens/{token}": {
2000
- parameters: {
2001
- query?: never;
2002
- header?: never;
2003
- path?: never;
2004
- cookie?: never;
2005
- };
2006
- /**
2007
- * Get Resource by Clone Token
2008
- * @description Retrieve a resource using a clone token
2009
- */
2010
- get: {
2011
- parameters: {
2012
- query?: never;
2013
- header?: never;
2014
- path: {
2015
- token: string;
2016
- };
2017
- cookie?: never;
2018
- };
2019
- requestBody?: never;
2020
- responses: {
2021
- /** @description Resource retrieved successfully */
2022
- 200: {
2023
- headers: {
2024
- [name: string]: unknown;
2025
- };
2026
- content: {
2027
- "application/json": components["schemas"]["GetResourceByTokenResponse"];
2028
- };
2029
- };
2030
- };
2031
- };
2032
- put?: never;
2033
- post?: never;
2034
- delete?: never;
2035
- options?: never;
2036
- head?: never;
2037
- patch?: never;
2038
- trace?: never;
2039
- };
2040
- "/api/clone-tokens/create-resource": {
2041
- parameters: {
2042
- query?: never;
2043
- header?: never;
2044
- path?: never;
2045
- cookie?: never;
2046
- };
2047
- get?: never;
2048
- put?: never;
2049
- /**
2050
- * Create Resource from Clone Token
2051
- * @description Create a new resource using a clone token
2052
- */
2053
- post: {
2054
- parameters: {
2055
- query?: never;
2056
- header?: never;
2057
- path?: never;
2058
- cookie?: never;
2059
- };
2060
- requestBody?: {
2061
- content: {
2062
- "application/json": components["schemas"]["CreateResourceFromTokenRequest"];
2063
- };
2064
- };
2065
- responses: {
2066
- /** @description Resource creation accepted */
2067
- 202: {
2068
- headers: {
2069
- [name: string]: unknown;
2070
- };
2071
- content: {
2072
- "application/json": {
2073
- resourceId: string;
2074
- };
2075
- };
2076
- };
2077
- };
2078
- };
2079
- delete?: never;
2080
- options?: never;
2081
- head?: never;
2082
- patch?: never;
2083
- trace?: never;
2084
- };
2085
- "/resources/{id}/clone-with-token": {
2086
- parameters: {
2087
- query?: never;
2088
- header?: never;
2089
- path?: never;
2090
- cookie?: never;
2091
- };
2092
- get?: never;
2093
- put?: never;
2094
- /**
2095
- * Clone Resource with Token
2096
- * @description Generate a temporary token for cloning a resource
2097
- */
2098
- post: {
2099
- parameters: {
2100
- query?: never;
2101
- header?: never;
2102
- path: {
2103
- id: string;
2104
- };
2105
- cookie?: never;
2106
- };
2107
- requestBody?: never;
2108
- responses: {
2109
- /** @description Clone token generated successfully */
2110
- 200: {
2111
- headers: {
2112
- [name: string]: unknown;
2113
- };
2114
- content: {
2115
- "application/json": components["schemas"]["CloneResourceWithTokenResponse"];
2116
- };
2117
- };
2118
- };
2119
- };
2120
- delete?: never;
2121
- options?: never;
2122
- head?: never;
2123
- patch?: never;
2124
- trace?: never;
2125
- };
2126
- "/resources/{id}/annotations": {
2127
- parameters: {
2128
- query?: never;
2129
- header?: never;
2130
- path?: never;
2131
- cookie?: never;
2132
- };
2133
- /**
2134
- * Get Resource Annotations
2135
- * @description Get all annotations (both highlights and references) in a resource
2136
- */
2137
- get: {
2138
- parameters: {
2139
- query?: never;
2140
- header?: never;
2141
- path: {
2142
- id: string;
2143
- };
2144
- cookie?: never;
2145
- };
2146
- requestBody?: never;
2147
- responses: {
2148
- /** @description Resource annotations */
2149
- 200: {
2150
- headers: {
2151
- [name: string]: unknown;
2152
- };
2153
- content: {
2154
- "application/json": components["schemas"]["CreateResourceResponse"];
2155
- };
2156
- };
2157
- };
2158
- };
2159
- put?: never;
2160
- /**
2161
- * Create Annotation
2162
- * @description Create a new annotation/reference in a resource
2163
- */
2164
- post: {
2165
- parameters: {
2166
- query?: never;
2167
- header?: never;
2168
- path: {
2169
- /** @description Resource ID */
2170
- id: string;
2171
- };
2172
- cookie?: never;
2173
- };
2174
- requestBody?: {
2175
- content: {
2176
- "application/json": components["schemas"]["CreateAnnotationRequest"];
2177
- };
2178
- };
2179
- responses: {
2180
- /** @description Annotation creation accepted */
2181
- 202: {
2182
- headers: {
2183
- [name: string]: unknown;
2184
- };
2185
- content: {
2186
- "application/json": {
2187
- annotationId: string;
2188
- };
2189
- };
2190
- };
2191
- };
2192
- };
2193
- delete?: never;
2194
- options?: never;
2195
- head?: never;
2196
- patch?: never;
2197
- trace?: never;
2198
- };
2199
- "/resources/{id}/events": {
2200
- parameters: {
2201
- query?: never;
2202
- header?: never;
2203
- path?: never;
2204
- cookie?: never;
2205
- };
2206
- /**
2207
- * Get Resource Event History
2208
- * @description Get full event history for a resource with optional filtering
2209
- */
2210
- get: {
2211
- parameters: {
2212
- query?: {
2213
- type?: "resource.created" | "resource.cloned" | "resource.updated" | "resource.moved" | "resource.archived" | "resource.unarchived" | "annotation.added" | "annotation.removed" | "annotation.body.updated" | "entitytag.added" | "entitytag.removed" | "entitytype.added";
2214
- userId?: string;
2215
- limit?: number;
2216
- };
2217
- header?: never;
2218
- path: {
2219
- id: string;
2220
- };
2221
- cookie?: never;
2222
- };
2223
- requestBody?: never;
2224
- responses: {
2225
- /** @description Events retrieved successfully */
2226
- 200: {
2227
- headers: {
2228
- [name: string]: unknown;
2229
- };
2230
- content: {
2231
- "application/json": components["schemas"]["GetEventsResponse"];
2232
- };
2233
- };
2234
- };
2235
- };
2236
- put?: never;
2237
- post?: never;
2238
- delete?: never;
2239
- options?: never;
2240
- head?: never;
2241
- patch?: never;
2242
- trace?: never;
2243
- };
2244
- "/resources/{id}/events/stream": {
2245
- parameters: {
2246
- query?: never;
2247
- header?: never;
2248
- path?: never;
2249
- cookie?: never;
2250
- };
2251
- /**
2252
- * Subscribe to Resource Events (SSE)
2253
- * @description Open a Server-Sent Events stream to receive real-time resource events
2254
- */
2255
- get: {
2256
- parameters: {
2257
- query?: never;
2258
- header?: never;
2259
- path: {
2260
- id: string;
2261
- };
2262
- cookie?: never;
2263
- };
2264
- requestBody?: never;
2265
- responses: {
2266
- /** @description SSE stream opened successfully */
2267
- 200: {
2268
- headers: {
2269
- [name: string]: unknown;
2270
- };
2271
- content: {
2272
- "text/event-stream": components["schemas"]["EventStreamResponse"];
2273
- };
2274
- };
2275
- };
2276
- };
2277
- put?: never;
2278
- post?: never;
2279
- delete?: never;
2280
- options?: never;
2281
- head?: never;
2282
- patch?: never;
2283
- trace?: never;
2284
- };
2285
- "/resources/{resourceId}/annotations/{annotationId}": {
2286
- parameters: {
2287
- query?: never;
2288
- header?: never;
2289
- path?: never;
2290
- cookie?: never;
2291
- };
2292
- /**
2293
- * Get Annotation
2294
- * @description Get a specific annotation from a resource using nested path
2295
- */
2296
- get: {
2297
- parameters: {
2298
- query?: never;
2299
- header?: never;
2300
- path: {
2301
- /** @description Resource ID */
2302
- resourceId: string;
2303
- /** @description Annotation ID */
2304
- annotationId: string;
2305
- };
2306
- cookie?: never;
2307
- };
2308
- requestBody?: never;
2309
- responses: {
2310
- /** @description Annotation retrieved successfully */
2311
- 200: {
2312
- headers: {
2313
- [name: string]: unknown;
2314
- };
2315
- content: {
2316
- "application/json": components["schemas"]["GetAnnotationResponse"];
2317
- };
2318
- };
2319
- /** @description Annotation not found */
2320
- 404: {
2321
- headers: {
2322
- [name: string]: unknown;
2323
- };
2324
- content?: never;
2325
1285
  };
2326
1286
  };
2327
1287
  };
2328
1288
  put?: never;
2329
1289
  post?: never;
2330
- /**
2331
- * Delete Annotation
2332
- * @description Delete an annotation from a resource
2333
- */
2334
- delete: {
2335
- parameters: {
2336
- query?: never;
2337
- header?: never;
2338
- path: {
2339
- /** @description Resource ID */
2340
- resourceId: string;
2341
- /** @description Annotation ID */
2342
- annotationId: string;
2343
- };
2344
- cookie?: never;
2345
- };
2346
- requestBody?: never;
2347
- responses: {
2348
- /** @description Annotation deletion accepted */
2349
- 202: {
2350
- headers: {
2351
- [name: string]: unknown;
2352
- };
2353
- content?: never;
2354
- };
2355
- };
2356
- };
2357
- options?: never;
2358
- head?: never;
2359
- patch?: never;
2360
- trace?: never;
2361
- };
2362
- "/resources/{resourceId}/annotations/{annotationId}/body": {
2363
- parameters: {
2364
- query?: never;
2365
- header?: never;
2366
- path?: never;
2367
- cookie?: never;
2368
- };
2369
- get?: never;
2370
- /**
2371
- * Update Annotation Body
2372
- * @description Apply fine-grained operations to modify annotation body items (add, remove, or replace TextualBody and SpecificResource items)
2373
- */
2374
- put: {
2375
- parameters: {
2376
- query?: never;
2377
- header?: never;
2378
- path: {
2379
- /** @description Resource ID */
2380
- resourceId: string;
2381
- /** @description Annotation ID */
2382
- annotationId: string;
2383
- };
2384
- cookie?: never;
2385
- };
2386
- requestBody?: {
2387
- content: {
2388
- "application/json": components["schemas"]["UpdateAnnotationBodyRequest"];
2389
- };
2390
- };
2391
- responses: {
2392
- /** @description Annotation body update accepted */
2393
- 202: {
2394
- headers: {
2395
- [name: string]: unknown;
2396
- };
2397
- content?: never;
2398
- };
2399
- };
2400
- };
2401
- post?: never;
2402
- delete?: never;
2403
- options?: never;
2404
- head?: never;
2405
- patch?: never;
2406
- trace?: never;
2407
- };
2408
- "/resources/{resourceId}/annotations/{annotationId}/yield-resource": {
2409
- parameters: {
2410
- query?: never;
2411
- header?: never;
2412
- path?: never;
2413
- cookie?: never;
2414
- };
2415
- get?: never;
2416
- put?: never;
2417
- /**
2418
- * Generate Resource from Annotation
2419
- * @description Submit a resource generation command. Returns {correlationId, jobId} immediately. The generation worker processes the job asynchronously and delivers progress (yield:progress) and completion (yield:finished) or failure (yield:failed) via the events-stream to all connected clients.
2420
- */
2421
- post: {
2422
- parameters: {
2423
- query?: never;
2424
- header?: never;
2425
- path: {
2426
- /** @description Source resource ID */
2427
- resourceId: string;
2428
- /** @description Reference annotation ID */
2429
- annotationId: string;
2430
- };
2431
- cookie?: never;
2432
- };
2433
- requestBody: {
2434
- content: {
2435
- "application/json": components["schemas"]["YieldResourceStreamRequest"];
2436
- };
2437
- };
2438
- responses: {
2439
- /** @description Generation command accepted. Progress and results delivered via events-stream. */
2440
- 202: {
2441
- headers: {
2442
- [name: string]: unknown;
2443
- };
2444
- content: {
2445
- "application/json": {
2446
- correlationId: string;
2447
- jobId: string;
2448
- };
2449
- };
2450
- };
2451
- /** @description Context is required for generation */
2452
- 400: {
2453
- headers: {
2454
- [name: string]: unknown;
2455
- };
2456
- content?: never;
2457
- };
2458
- /** @description Authentication required */
2459
- 401: {
2460
- headers: {
2461
- [name: string]: unknown;
2462
- };
2463
- content?: never;
2464
- };
2465
- /** @description Annotation not found */
2466
- 404: {
2467
- headers: {
2468
- [name: string]: unknown;
2469
- };
2470
- content?: never;
2471
- };
2472
- };
2473
- };
2474
1290
  delete?: never;
2475
1291
  options?: never;
2476
1292
  head?: never;
2477
1293
  patch?: never;
2478
1294
  trace?: never;
2479
1295
  };
2480
- "/resources/{resourceId}/annotations/{annotationId}/history": {
1296
+ "/api/tokens/mcp-setup": {
2481
1297
  parameters: {
2482
1298
  query?: never;
2483
1299
  header?: never;
@@ -2485,36 +1301,56 @@ interface paths {
2485
1301
  cookie?: never;
2486
1302
  };
2487
1303
  /**
2488
- * Get Annotation History
2489
- * @description Get full event history for a specific annotation (highlight or reference)
1304
+ * MCP Setup (browser-driven CLI handoff)
1305
+ * @description Browser flow that generates a long-lived (30 day) MCP refresh token for the authenticated user and redirects to a localhost callback URL with the token as a query parameter. Used by CLI tooling (similar to Google's OAuth CLI flow).
1306
+ *
1307
+ * The callback URL must match one of the localhost patterns (`http://localhost:<port>/...`, `http://127.0.0.1:<port>/...`, or `http://[::1]:<port>/...`).
2490
1308
  */
2491
1309
  get: {
2492
1310
  parameters: {
2493
- query?: never;
2494
- header?: never;
2495
- path: {
2496
- resourceId: string;
2497
- annotationId: string;
1311
+ query: {
1312
+ /** @description Localhost URL to redirect to with `?token=<refresh-token>` on success. */
1313
+ callback: string;
2498
1314
  };
1315
+ header?: never;
1316
+ path?: never;
2499
1317
  cookie?: never;
2500
1318
  };
2501
1319
  requestBody?: never;
2502
1320
  responses: {
2503
- /** @description Annotation history retrieved successfully */
2504
- 200: {
1321
+ /** @description Redirect to the callback URL with the newly-issued refresh token appended as a `?token=` query parameter. */
1322
+ 302: {
1323
+ headers: {
1324
+ [name: string]: unknown;
1325
+ };
1326
+ content?: never;
1327
+ };
1328
+ /** @description Missing or non-localhost callback URL */
1329
+ 400: {
1330
+ headers: {
1331
+ [name: string]: unknown;
1332
+ };
1333
+ content: {
1334
+ "application/json": components["schemas"]["ErrorResponse"];
1335
+ };
1336
+ };
1337
+ /** @description Authentication required */
1338
+ 401: {
2505
1339
  headers: {
2506
1340
  [name: string]: unknown;
2507
1341
  };
2508
1342
  content: {
2509
- "application/json": components["schemas"]["GetAnnotationHistoryResponse"];
1343
+ "application/json": components["schemas"]["ErrorResponse"];
2510
1344
  };
2511
1345
  };
2512
- /** @description Annotation not found */
2513
- 404: {
1346
+ /** @description Failed to generate refresh token */
1347
+ 500: {
2514
1348
  headers: {
2515
1349
  [name: string]: unknown;
2516
1350
  };
2517
- content?: never;
1351
+ content: {
1352
+ "application/json": components["schemas"]["ErrorResponse"];
1353
+ };
2518
1354
  };
2519
1355
  };
2520
1356
  };
@@ -2526,7 +1362,7 @@ interface paths {
2526
1362
  patch?: never;
2527
1363
  trace?: never;
2528
1364
  };
2529
- "/api/entity-types": {
1365
+ "/bus/subscribe": {
2530
1366
  parameters: {
2531
1367
  query?: never;
2532
1368
  header?: never;
@@ -2534,56 +1370,52 @@ interface paths {
2534
1370
  cookie?: never;
2535
1371
  };
2536
1372
  /**
2537
- * Get Entity Types
2538
- * @description Get list of available entity types for references
1373
+ * Subscribe to the Semiont event bus (SSE)
1374
+ * @description Opens a long-lived Server-Sent Events stream over which the bus delivers events matching the requested channels and scopes.
1375
+ *
1376
+ * Each SSE frame has `event: bus-event`, a JSON-encoded `data` of the form `{ channel, payload, scope? }`, and an `id` (either a persisted event id, `scope:seq`, for domain events; or an ephemeral id for job-lifecycle / result channels).
1377
+ *
1378
+ * Pass the last-received id as `Last-Event-ID` to resume — the server replays missed persisted events and emits a `bus:resume-gap` synthetic event when the gap exceeds the replay window.
2539
1379
  */
2540
1380
  get: {
2541
1381
  parameters: {
2542
- query?: never;
2543
- header?: never;
1382
+ query?: {
1383
+ /** @description Unscoped channels to subscribe to. Repeat the parameter for multiple channels. At least one of `channel` or `scoped` is required. */
1384
+ channel?: string[];
1385
+ /** @description Resource-scoped channels to subscribe to (requires `scope`). Repeat for multiple. */
1386
+ scoped?: string[];
1387
+ /** @description Resource scope for scoped channels (typically a resourceId). */
1388
+ scope?: string;
1389
+ };
1390
+ header?: {
1391
+ /** @description Id of the last event the client received. On reconnect, the server replays persisted events after this id and emits `bus:resume-gap` if the gap exceeds the replay cap. */
1392
+ "Last-Event-ID"?: string;
1393
+ };
2544
1394
  path?: never;
2545
1395
  cookie?: never;
2546
1396
  };
2547
1397
  requestBody?: never;
2548
1398
  responses: {
2549
- /** @description Entity types retrieved successfully */
1399
+ /** @description SSE stream opened */
2550
1400
  200: {
2551
1401
  headers: {
2552
1402
  [name: string]: unknown;
2553
1403
  };
2554
1404
  content: {
2555
- "application/json": components["schemas"]["GetEntityTypesResponse"];
1405
+ "text/event-stream": components["schemas"]["EventStreamResponse"];
2556
1406
  };
2557
1407
  };
2558
- };
2559
- };
2560
- put?: never;
2561
- /**
2562
- * Add Entity Type
2563
- * @description Add a new entity type to the collection (append-only, requires moderator/admin)
2564
- */
2565
- post: {
2566
- parameters: {
2567
- query?: never;
2568
- header?: never;
2569
- path?: never;
2570
- cookie?: never;
2571
- };
2572
- requestBody?: {
2573
- content: {
2574
- "application/json": components["schemas"]["AddEntityTypeRequest"];
2575
- };
2576
- };
2577
- responses: {
2578
- /** @description Entity type addition accepted */
2579
- 202: {
1408
+ /** @description No channels requested (at least one `channel` or `scoped` parameter required) */
1409
+ 400: {
2580
1410
  headers: {
2581
1411
  [name: string]: unknown;
2582
1412
  };
2583
- content?: never;
1413
+ content: {
1414
+ "application/json": components["schemas"]["ErrorResponse"];
1415
+ };
2584
1416
  };
2585
- /** @description Forbidden - Moderator or Admin access required */
2586
- 403: {
1417
+ /** @description Authentication required */
1418
+ 401: {
2587
1419
  headers: {
2588
1420
  [name: string]: unknown;
2589
1421
  };
@@ -2593,13 +1425,15 @@ interface paths {
2593
1425
  };
2594
1426
  };
2595
1427
  };
1428
+ put?: never;
1429
+ post?: never;
2596
1430
  delete?: never;
2597
1431
  options?: never;
2598
1432
  head?: never;
2599
1433
  patch?: never;
2600
1434
  trace?: never;
2601
1435
  };
2602
- "/api/entity-types/bulk": {
1436
+ "/bus/emit": {
2603
1437
  parameters: {
2604
1438
  query?: never;
2605
1439
  header?: never;
@@ -2609,8 +1443,12 @@ interface paths {
2609
1443
  get?: never;
2610
1444
  put?: never;
2611
1445
  /**
2612
- * Bulk Add Entity Types
2613
- * @description Add multiple entity types to the collection (append-only, requires moderator/admin)
1446
+ * Emit an event on the Semiont bus
1447
+ * @description Publishes an event to the bus. The channel name must be registered in `bus-protocol.ts` (`EventMap`); the payload is validated against the channel's schema in `CHANNEL_SCHEMAS` when one is registered.
1448
+ *
1449
+ * When `scope` is set, the event publishes on `eventBus.scope(scope)` rather than the global bus, routing it to per-resource SSE subscribers only. The authenticated user's DID is attached to the payload as `_userId` automatically.
1450
+ *
1451
+ * Returns 202 Accepted — the event is delivered to in-memory subscribers synchronously, but downstream persistence (Stower) and materialization happen asynchronously.
2614
1452
  */
2615
1453
  post: {
2616
1454
  parameters: {
@@ -2619,21 +1457,30 @@ interface paths {
2619
1457
  path?: never;
2620
1458
  cookie?: never;
2621
1459
  };
2622
- requestBody?: {
1460
+ requestBody: {
2623
1461
  content: {
2624
- "application/json": components["schemas"]["BulkAddEntityTypesRequest"];
1462
+ "application/json": components["schemas"]["BusEmitRequest"];
2625
1463
  };
2626
1464
  };
2627
1465
  responses: {
2628
- /** @description Entity types addition accepted */
1466
+ /** @description Event accepted and published to subscribers */
2629
1467
  202: {
2630
1468
  headers: {
2631
1469
  [name: string]: unknown;
2632
1470
  };
2633
1471
  content?: never;
2634
1472
  };
2635
- /** @description Forbidden - Moderator or Admin access required */
2636
- 403: {
1473
+ /** @description Missing/invalid channel, payload, or scope; or payload failed schema validation for the channel */
1474
+ 400: {
1475
+ headers: {
1476
+ [name: string]: unknown;
1477
+ };
1478
+ content: {
1479
+ "application/json": components["schemas"]["ErrorResponse"];
1480
+ };
1481
+ };
1482
+ /** @description Authentication required */
1483
+ 401: {
2637
1484
  headers: {
2638
1485
  [name: string]: unknown;
2639
1486
  };
@@ -2649,46 +1496,98 @@ interface paths {
2649
1496
  patch?: never;
2650
1497
  trace?: never;
2651
1498
  };
2652
- "/api/events/stream": {
1499
+ "/resources": {
2653
1500
  parameters: {
2654
1501
  query?: never;
2655
1502
  header?: never;
2656
1503
  path?: never;
2657
1504
  cookie?: never;
2658
1505
  };
1506
+ get?: never;
1507
+ put?: never;
2659
1508
  /**
2660
- * Subscribe to Global Events (SSE)
2661
- * @description Open a Server-Sent Events stream to receive real-time system-level events (e.g., entity type changes). Events not scoped to a specific resource are delivered on this channel.
1509
+ * Create a resource
1510
+ * @description Upload binary content + metadata as multipart/form-data. The backend writes content to disk, then emits yield:create on the bus; Stower persists it and returns a 202 with the new resourceId. Full reconciliation happens via SSE domain events (yield:created).
1511
+ *
1512
+ * Generation workers and the /know/compose page both hit this route — bytes always travel on the HTTP wire, never on the bus.
2662
1513
  */
2663
- get: {
1514
+ post: {
2664
1515
  parameters: {
2665
1516
  query?: never;
2666
1517
  header?: never;
2667
1518
  path?: never;
2668
1519
  cookie?: never;
2669
1520
  };
2670
- requestBody?: never;
1521
+ requestBody: {
1522
+ content: {
1523
+ "multipart/form-data": {
1524
+ /** @description Human-readable resource name */
1525
+ name: string;
1526
+ /**
1527
+ * Format: binary
1528
+ * @description Binary content
1529
+ */
1530
+ file: string;
1531
+ /** @description Media type of the content (e.g. text/plain, text/markdown, image/png) */
1532
+ format: string;
1533
+ /** @description Where the content has been / should be placed (file://... for local). If omitted, derived from name + format. */
1534
+ storageUri?: string;
1535
+ /** @description ISO 639-1 language code */
1536
+ language?: string;
1537
+ /** @description JSON-stringified array of entity type names */
1538
+ entityTypes?: string;
1539
+ /** @description How this resource was created (api, ui, upload, reference, cli, clone, generated) */
1540
+ creationMethod?: string;
1541
+ /** @description For AI-generated resources: the annotation that triggered generation. Nested into generatedFrom.annotationId on the persisted event. */
1542
+ sourceAnnotationId?: string;
1543
+ /** @description For AI-generated resources: the source resource the generating annotation lives on. Nested into generatedFrom.resourceId on the persisted event. */
1544
+ sourceResourceId?: string;
1545
+ /** @description For AI-generated resources: the prompt that drove generation */
1546
+ generationPrompt?: string;
1547
+ /** @description For AI-generated resources: JSON-stringified Agent (single object or array), capturing which model/worker produced the content */
1548
+ generator?: string;
1549
+ /** @description 'true' or 'false' — whether the resource is a draft */
1550
+ isDraft?: string;
1551
+ };
1552
+ };
1553
+ };
2671
1554
  responses: {
2672
- /** @description SSE stream opened successfully */
2673
- 200: {
1555
+ /** @description Resource accepted for creation */
1556
+ 202: {
2674
1557
  headers: {
2675
1558
  [name: string]: unknown;
2676
1559
  };
2677
1560
  content: {
2678
- "text/event-stream": components["schemas"]["EventStreamResponse"];
1561
+ "application/json": components["schemas"]["CreateResourceResponse"];
1562
+ };
1563
+ };
1564
+ /** @description Missing required fields (name, file, or format) */
1565
+ 400: {
1566
+ headers: {
1567
+ [name: string]: unknown;
1568
+ };
1569
+ content: {
1570
+ "application/json": components["schemas"]["ErrorResponse"];
1571
+ };
1572
+ };
1573
+ /** @description Authentication required */
1574
+ 401: {
1575
+ headers: {
1576
+ [name: string]: unknown;
1577
+ };
1578
+ content: {
1579
+ "application/json": components["schemas"]["ErrorResponse"];
2679
1580
  };
2680
1581
  };
2681
1582
  };
2682
1583
  };
2683
- put?: never;
2684
- post?: never;
2685
1584
  delete?: never;
2686
1585
  options?: never;
2687
1586
  head?: never;
2688
1587
  patch?: never;
2689
1588
  trace?: never;
2690
1589
  };
2691
- "/api/jobs/{id}": {
1590
+ "/resources/{id}": {
2692
1591
  parameters: {
2693
1592
  query?: never;
2694
1593
  header?: never;
@@ -2696,13 +1595,20 @@ interface paths {
2696
1595
  cookie?: never;
2697
1596
  };
2698
1597
  /**
2699
- * Get Job Status
2700
- * @description Get the current status and progress of an async job
1598
+ * Get a resource (content-negotiated)
1599
+ * @description Content negotiation via the Accept header:
1600
+ * - application/ld+json (default) — returns JSON-LD metadata including all annotations + inbound entity references
1601
+ * - text/* or image/* or application/pdf — returns the raw representation bytes
1602
+ *
1603
+ * Binary payloads flow directly from the content store; metadata payloads go through the bus gateway.
2701
1604
  */
2702
1605
  get: {
2703
1606
  parameters: {
2704
1607
  query?: never;
2705
- header?: never;
1608
+ header?: {
1609
+ /** @description application/ld+json for metadata, or a text/image/pdf media type for raw content */
1610
+ Accept?: string;
1611
+ };
2706
1612
  path: {
2707
1613
  id: string;
2708
1614
  };
@@ -2710,21 +1616,46 @@ interface paths {
2710
1616
  };
2711
1617
  requestBody?: never;
2712
1618
  responses: {
2713
- /** @description Job status retrieved successfully */
1619
+ /** @description Resource content or metadata, depending on Accept */
2714
1620
  200: {
2715
1621
  headers: {
2716
1622
  [name: string]: unknown;
2717
1623
  };
2718
1624
  content: {
2719
- "application/json": components["schemas"]["JobStatusResponse"];
1625
+ "application/ld+json": components["schemas"]["GetResourceResponse"];
1626
+ "text/plain": string;
1627
+ "text/markdown": string;
1628
+ "text/html": string;
1629
+ "image/*": string;
1630
+ "application/pdf": string;
2720
1631
  };
2721
1632
  };
2722
- /** @description Job not found */
1633
+ /** @description Resource not found */
2723
1634
  404: {
2724
1635
  headers: {
2725
1636
  [name: string]: unknown;
2726
1637
  };
2727
- content?: never;
1638
+ content: {
1639
+ "application/json": components["schemas"]["ErrorResponse"];
1640
+ };
1641
+ };
1642
+ /** @description Failed to retrieve resource */
1643
+ 500: {
1644
+ headers: {
1645
+ [name: string]: unknown;
1646
+ };
1647
+ content: {
1648
+ "application/json": components["schemas"]["ErrorResponse"];
1649
+ };
1650
+ };
1651
+ /** @description Request timed out (bus gateway) */
1652
+ 504: {
1653
+ headers: {
1654
+ [name: string]: unknown;
1655
+ };
1656
+ content: {
1657
+ "application/json": components["schemas"]["ErrorResponse"];
1658
+ };
2728
1659
  };
2729
1660
  };
2730
1661
  };
@@ -2733,95 +1664,55 @@ interface paths {
2733
1664
  delete?: never;
2734
1665
  options?: never;
2735
1666
  head?: never;
2736
- patch?: never;
2737
- trace?: never;
2738
- };
2739
- "/api/participants/{id}/attention": {
2740
- parameters: {
2741
- query?: never;
2742
- header?: never;
2743
- path?: never;
2744
- cookie?: never;
2745
- };
2746
- get?: never;
2747
- put?: never;
2748
1667
  /**
2749
- * Beckon Participant
2750
- * @description Direct a participant's attention to a resource or annotation. Produces no persistent annotations attention signal only. The participant may be a human username or an agent identifier.
1668
+ * Update resource metadata
1669
+ * @description Archive/unarchive or update entity types. Emits mark:archive / mark:unarchive / mark:update-entity-types on the bus; returns 202 immediately. Frontend reconciles state via SSE domain events.
2751
1670
  */
2752
- post: {
1671
+ patch: {
2753
1672
  parameters: {
2754
1673
  query?: never;
2755
1674
  header?: never;
2756
1675
  path: {
2757
- /** @description Participant username or agent identifier */
2758
1676
  id: string;
2759
1677
  };
2760
1678
  cookie?: never;
2761
1679
  };
2762
1680
  requestBody: {
2763
1681
  content: {
2764
- "application/json": components["schemas"]["BeckonRequest"];
1682
+ "application/json": components["schemas"]["UpdateResourceRequest"];
2765
1683
  };
2766
1684
  };
2767
1685
  responses: {
2768
- /** @description Attention signal accepted */
1686
+ /** @description Update accepted */
2769
1687
  202: {
1688
+ headers: {
1689
+ [name: string]: unknown;
1690
+ };
1691
+ content?: never;
1692
+ };
1693
+ /** @description Authentication required */
1694
+ 401: {
2770
1695
  headers: {
2771
1696
  [name: string]: unknown;
2772
1697
  };
2773
1698
  content: {
2774
- "application/json": components["schemas"]["BeckonResponse"];
1699
+ "application/json": components["schemas"]["ErrorResponse"];
2775
1700
  };
2776
1701
  };
2777
- };
2778
- };
2779
- delete?: never;
2780
- options?: never;
2781
- head?: never;
2782
- patch?: never;
2783
- trace?: never;
2784
- };
2785
- "/api/participants/me/attention-stream": {
2786
- parameters: {
2787
- query?: never;
2788
- header?: never;
2789
- path?: never;
2790
- cookie?: never;
2791
- };
2792
- /**
2793
- * Participant Attention Stream
2794
- * @description Open a persistent SSE connection to receive beckon signals directed at the authenticated participant. Signals are ephemeral — delivered if connected, dropped if not. No queue, no replay.
2795
- */
2796
- get: {
2797
- parameters: {
2798
- query?: never;
2799
- header?: never;
2800
- path?: never;
2801
- cookie?: never;
2802
- };
2803
- requestBody?: never;
2804
- responses: {
2805
- /** @description SSE stream of beckon:focus events */
2806
- 200: {
1702
+ /** @description Resource not found */
1703
+ 404: {
2807
1704
  headers: {
2808
1705
  [name: string]: unknown;
2809
1706
  };
2810
1707
  content: {
2811
- "text/event-stream": string;
1708
+ "application/json": components["schemas"]["ErrorResponse"];
2812
1709
  };
2813
1710
  };
2814
1711
  };
2815
1712
  };
2816
- put?: never;
2817
- post?: never;
2818
- delete?: never;
2819
- options?: never;
2820
- head?: never;
2821
- patch?: never;
2822
1713
  trace?: never;
2823
1714
  };
2824
- "/api/browse/files": {
1715
+ "/api/resources/{id}": {
2825
1716
  parameters: {
2826
1717
  query?: never;
2827
1718
  header?: never;
@@ -2829,34 +1720,37 @@ interface paths {
2829
1720
  cookie?: never;
2830
1721
  };
2831
1722
  /**
2832
- * Browse project directory
2833
- * @description List files and directories in a project directory, merged with Knowledge Base metadata for tracked resources.
1723
+ * Get raw resource content (browser-friendly alias)
1724
+ * @description Browser-friendly alternative to GET /resources/{id} that always returns the raw representation, never JSON-LD. Used by `<img>` / PDF.js / `<video>` tags and anywhere an httpOnly cookie is the only feasible auth vector. Behaves like GET /resources/{id} with JSON-LD stripped from the Accept header before content negotiation.
1725
+ *
1726
+ * Sets long-lived immutable Cache-Control (content is addressed by checksum upstream, so bytes never change for a given resource id).
2834
1727
  */
2835
1728
  get: {
2836
1729
  parameters: {
2837
- query?: {
2838
- /** @description Directory path relative to project root. Empty string or omit for project root. */
2839
- path?: string;
2840
- /** @description Sort order for directory entries. */
2841
- sort?: "name" | "mtime" | "annotationCount";
2842
- };
1730
+ query?: never;
2843
1731
  header?: never;
2844
- path?: never;
1732
+ path: {
1733
+ id: string;
1734
+ };
2845
1735
  cookie?: never;
2846
1736
  };
2847
1737
  requestBody?: never;
2848
1738
  responses: {
2849
- /** @description Directory listing with KB metadata merged */
1739
+ /** @description Raw representation bytes with appropriate Content-Type */
2850
1740
  200: {
2851
1741
  headers: {
2852
1742
  [name: string]: unknown;
2853
1743
  };
2854
1744
  content: {
2855
- "application/json": components["schemas"]["BrowseFilesResponse"];
1745
+ "text/plain": string;
1746
+ "text/markdown": string;
1747
+ "text/html": string;
1748
+ "image/*": string;
1749
+ "application/pdf": string;
2856
1750
  };
2857
1751
  };
2858
- /** @description Invalid path (e.g. path escapes project root) */
2859
- 400: {
1752
+ /** @description Resource or representation not found */
1753
+ 404: {
2860
1754
  headers: {
2861
1755
  [name: string]: unknown;
2862
1756
  };
@@ -2864,8 +1758,8 @@ interface paths {
2864
1758
  "application/json": components["schemas"]["ErrorResponse"];
2865
1759
  };
2866
1760
  };
2867
- /** @description Directory not found */
2868
- 404: {
1761
+ /** @description Failed to retrieve resource */
1762
+ 500: {
2869
1763
  headers: {
2870
1764
  [name: string]: unknown;
2871
1765
  };
@@ -2890,9 +1784,6 @@ interface components {
2890
1784
  success: boolean;
2891
1785
  message: string;
2892
1786
  };
2893
- AddEntityTypeRequest: {
2894
- tag: string;
2895
- };
2896
1787
  AdminUpdateUserResponse: {
2897
1788
  success: boolean;
2898
1789
  user: {
@@ -2978,8 +1869,8 @@ interface components {
2978
1869
  motivation: components["schemas"]["Motivation"];
2979
1870
  /** @description W3C Web Annotation target - can be a simple IRI string (entire resource) or an object with source and optional selector (fragment) */
2980
1871
  target: string | components["schemas"]["AnnotationTarget"];
2981
- /** @description W3C Web Annotation body - can be empty array, single body, or array of bodies */
2982
- body: components["schemas"]["AnnotationBody"][] | components["schemas"]["AnnotationBody"] | components["schemas"]["AnnotationBody"][];
1872
+ /** @description W3C Web Annotation body. Optional per the W3C spec — annotations whose motivation alone is meaningful (highlighting) legitimately omit it. Present values are either a single body or a non-empty array of bodies; the prior empty-array 'stub' branch has been removed (it was a naming lie shared between highlights and never-actually-emitted stub references, and the source of the #651 reference-annotation validator bug). */
1873
+ body?: components["schemas"]["AnnotationBody"] | components["schemas"]["AnnotationBody"][];
2983
1874
  creator?: components["schemas"]["Agent"];
2984
1875
  created?: string;
2985
1876
  modified?: string;
@@ -3026,14 +1917,6 @@ interface components {
3026
1917
  /** @description Optional selector to identify a specific segment of the source resource */
3027
1918
  selector?: components["schemas"]["TextPositionSelector"] | components["schemas"]["TextQuoteSelector"] | components["schemas"]["SvgSelector"] | components["schemas"]["FragmentSelector"] | (components["schemas"]["TextPositionSelector"] | components["schemas"]["TextQuoteSelector"] | components["schemas"]["SvgSelector"] | components["schemas"]["FragmentSelector"])[];
3028
1919
  };
3029
- AsyncJobResponse: {
3030
- jobId: string;
3031
- /** @enum {string} */
3032
- status: "pending" | "running" | "complete" | "failed" | "cancelled";
3033
- /** @enum {string} */
3034
- type: "reference-annotation" | "generation";
3035
- created: string;
3036
- };
3037
1920
  AuthResponse: {
3038
1921
  success: boolean;
3039
1922
  user: {
@@ -3055,6 +1938,53 @@ interface components {
3055
1938
  path: string;
3056
1939
  entries: components["schemas"]["DirectoryEntry"][];
3057
1940
  };
1941
+ /** @description Emit an event on the Semiont bus. Channel names come from bus-protocol.ts; payload shape is validated against the channel's registered schema (CHANNEL_SCHEMAS). An optional scope routes resource-scoped broadcasts (e.g. mark:added, job:complete) to per-resource subscribers via eventBus.scope(scope); leave it unset for unscoped/global events. */
1942
+ BusEmitRequest: {
1943
+ /** @description Channel name from bus-protocol.ts EventMap */
1944
+ channel: string;
1945
+ /** @description Channel-specific payload, validated against CHANNEL_SCHEMAS */
1946
+ payload: {
1947
+ [key: string]: unknown;
1948
+ };
1949
+ /** @description Optional resource scope for broadcast channels (e.g. resourceId). Publishers only — frontends must never set this. */
1950
+ scope?: string;
1951
+ };
1952
+ /** @description User's cookie consent preferences. `necessary` is always true — necessary cookies cannot be disabled. Timestamps and version are stamped server-side. */
1953
+ CookieConsent: {
1954
+ /** @enum {boolean} */
1955
+ necessary: true;
1956
+ analytics: boolean;
1957
+ marketing: boolean;
1958
+ preferences: boolean;
1959
+ /** Format: date-time */
1960
+ timestamp: string;
1961
+ version: string;
1962
+ };
1963
+ /** @description Request body for POST /api/cookies/consent. All four preference fields must be booleans; `necessary` must be true. */
1964
+ CookieConsentRequest: {
1965
+ /** @enum {boolean} */
1966
+ necessary: true;
1967
+ analytics: boolean;
1968
+ marketing: boolean;
1969
+ preferences: boolean;
1970
+ };
1971
+ /** @description Standard envelope for cookie consent endpoints. On success `success: true` and `consent` carries the current preferences; on error `success: false` and `error` carries a human-readable message. */
1972
+ CookieConsentResponse: {
1973
+ success: boolean;
1974
+ consent?: components["schemas"]["CookieConsent"];
1975
+ error?: string;
1976
+ };
1977
+ /** @description GDPR data export of a user's cookie-related data. The response is returned as a file download (Content-Disposition: attachment). */
1978
+ CookieExportResponse: {
1979
+ user: {
1980
+ id: string;
1981
+ email: string;
1982
+ };
1983
+ consent: components["schemas"]["CookieConsent"];
1984
+ /** Format: date-time */
1985
+ exportDate: string;
1986
+ dataRetentionPolicy: string;
1987
+ };
3058
1988
  DirectoryEntry: components["schemas"]["FileEntry"] | components["schemas"]["DirEntry"];
3059
1989
  FileEntry: {
3060
1990
  /** @enum {string} */
@@ -3106,22 +2036,9 @@ interface components {
3106
2036
  };
3107
2037
  BodyOperationReplace: {
3108
2038
  /** @enum {string} */
3109
- op: "replace";
3110
- oldItem: components["schemas"]["TextualBody"] | components["schemas"]["SpecificResource"];
3111
- newItem: components["schemas"]["TextualBody"] | components["schemas"]["SpecificResource"];
3112
- };
3113
- /**
3114
- * @description Annotation body type - TextualBody for textual content, SpecificResource for resource links
3115
- * @enum {string}
3116
- */
3117
- BodyType: "TextualBody" | "SpecificResource";
3118
- BeckonRequest: {
3119
- /** @description Resource to direct attention at */
3120
- resourceId: string;
3121
- /** @description Specific annotation within the resource (optional) */
3122
- annotationId?: string;
3123
- /** @description Human-readable context for the participant (max 500 chars) */
3124
- message?: string;
2039
+ op: "replace";
2040
+ oldItem: components["schemas"]["TextualBody"] | components["schemas"]["SpecificResource"];
2041
+ newItem: components["schemas"]["TextualBody"] | components["schemas"]["SpecificResource"];
3125
2042
  };
3126
2043
  BeckonResponse: {
3127
2044
  /** @description Username or agent identifier that was beckoned */
@@ -3131,9 +2048,6 @@ interface components {
3131
2048
  /** @description Annotation the attention was directed at (if provided) */
3132
2049
  annotationId?: string;
3133
2050
  };
3134
- BulkAddEntityTypesRequest: {
3135
- tags: string[];
3136
- };
3137
2051
  CloneResourceWithTokenResponse: {
3138
2052
  /** @description Generated clone token */
3139
2053
  token: string;
@@ -3143,6 +2057,8 @@ interface components {
3143
2057
  };
3144
2058
  /** @description Error response for failed bus commands. Replaces native Error objects on the EventBus so payloads are serializable and OpenAPI-typed. */
3145
2059
  CommandError: {
2060
+ /** @description Optional correlation id echoed from the originating command. When present, the failure event can be matched back to the specific command that failed. */
2061
+ correlationId?: string;
3146
2062
  /** @description Human-readable error message */
3147
2063
  message: string;
3148
2064
  /** @description Optional additional context (stack trace, field name, etc.) */
@@ -3182,114 +2098,18 @@ interface components {
3182
2098
  suffix?: string;
3183
2099
  } | components["schemas"]["SvgSelector"] | components["schemas"]["FragmentSelector"])[];
3184
2100
  };
3185
- body: unknown[] | components["schemas"]["AnnotationBody"] | components["schemas"]["AnnotationBody"][];
3186
- };
3187
- CreateFromAnnotationRequest: {
3188
- /** @description ID of the resource containing the annotation */
3189
- resourceId: string;
3190
- name: string;
3191
- content: string;
3192
- format: components["schemas"]["ContentFormat"];
3193
- };
3194
- CreateFromAnnotationResponse: {
3195
- resource: components["schemas"]["ResourceDescriptor"];
3196
- annotations: components["schemas"]["Annotation"][];
3197
- };
3198
- CreateJobResponse: {
3199
- jobId: string;
3200
- /** @enum {string} */
3201
- type: "reference-annotation" | "generation";
3202
- /** @enum {string} */
3203
- status: "pending" | "running" | "complete" | "failed" | "cancelled";
3204
- created: string;
3205
- resourceId?: string;
3206
- };
3207
- CreateResourceFromAnnotationResponse: {
3208
- resource: components["schemas"]["ResourceDescriptor"];
3209
- annotation: components["schemas"]["Annotation"];
3210
- };
3211
- CreateResourceFromSelectionRequest: {
3212
- /** @description ID of the resource containing the annotation */
3213
- resourceId: string;
3214
- content: string;
3215
- name: string;
3216
- format: components["schemas"]["ContentFormat"];
3217
- entityTypes?: string[];
3218
- metadata?: {
3219
- [key: string]: unknown;
3220
- };
3221
- prompt?: string;
3222
- language?: string;
3223
- };
3224
- CreateResourceFromSelectionResponse: {
3225
- resource: components["schemas"]["ResourceDescriptor"];
3226
- annotation: components["schemas"]["Annotation"];
3227
- };
3228
- CreateResourceFromTokenRequest: {
3229
- /** @description Clone token */
3230
- token: string;
3231
- /** @description Name for the new resource */
3232
- name: string;
3233
- /** @description Content for the new resource */
3234
- content: string;
3235
- /** @description Whether to archive the original resource */
3236
- archiveOriginal?: boolean;
3237
- };
3238
- CreateResourceRequest: {
3239
- name: string;
3240
- content: string;
3241
- format: components["schemas"]["ContentFormat"];
3242
- entityTypes: string[];
3243
- language?: string;
3244
- creationMethod?: string;
3245
- sourceAnnotationId?: string;
3246
- sourceResourceId?: string;
2101
+ /** @description Optional body. Omit for annotations whose motivation alone is meaningful (highlighting) or whose user-supplied content is empty. Shape matches Annotation.body. */
2102
+ body?: components["schemas"]["AnnotationBody"] | components["schemas"]["AnnotationBody"][];
3247
2103
  };
2104
+ /** @description Response body for POST /resources (202 Accepted). Resource creation is asynchronous — the backend writes content to disk, emits yield:create on the bus, and returns the newly-minted resourceId immediately. Consumers watch SSE domain events (yield:created) to observe the fully-persisted state. */
3248
2105
  CreateResourceResponse: {
3249
- resource: components["schemas"]["ResourceDescriptor"];
3250
- annotations: components["schemas"]["Annotation"][];
3251
- };
3252
- DeleteAnnotationRequest: {
3253
- /**
3254
- * Format: uri
3255
- * @description Resource URI containing the annotation (required for O(1) Layer 3 lookup)
3256
- */
2106
+ /** @description The id of the newly-created resource. Assigned by Stower when it persists yield:create. */
3257
2107
  resourceId: string;
3258
2108
  };
3259
2109
  DeleteUserResponse: {
3260
2110
  success: boolean;
3261
2111
  message: string;
3262
2112
  };
3263
- AnnotateReferencesStreamRequest: {
3264
- /** @description Entity types to annotate (e.g., 'Person', 'Organization', 'Location') */
3265
- entityTypes: string[];
3266
- /** @description Include anaphoric/cataphoric references (e.g., 'the CEO', 'the tech giant') in addition to direct mentions */
3267
- includeDescriptiveReferences?: boolean;
3268
- };
3269
- GatherResourceStreamRequest: {
3270
- /** @description Client-generated correlation ID to thread the response back to the originating request */
3271
- correlationId?: string;
3272
- /** @description Graph traversal depth (default: 2) */
3273
- depth?: number;
3274
- /** @description Maximum related resources to include (default: 10) */
3275
- maxResources?: number;
3276
- /** @description Include full resource content (default: true) */
3277
- includeContent?: boolean;
3278
- /** @description Include AI-generated summary (default: false) */
3279
- includeSummary?: boolean;
3280
- };
3281
- GatherAnnotationStreamRequest: {
3282
- /** @description Client-generated correlation ID to thread the response back to the originating request */
3283
- correlationId?: string;
3284
- /** @description Characters of surrounding text context (default: 1000) */
3285
- contextWindow?: number;
3286
- };
3287
- BindAnnotationStreamRequest: {
3288
- /** @description Resource ID containing the annotation (required for O(1) Layer 3 lookup) */
3289
- resourceId: string;
3290
- /** @description Array of body modification operations to apply */
3291
- operations: (components["schemas"]["BodyOperationAdd"] | components["schemas"]["BodyOperationRemove"] | components["schemas"]["BodyOperationReplace"])[];
3292
- };
3293
2113
  /** @description Progress payload emitted on gather:annotation-progress and gather:progress SSE channels during LLM context gathering. */
3294
2114
  GatherProgress: {
3295
2115
  message?: string;
@@ -3307,63 +2127,6 @@ interface components {
3307
2127
  resourceId: string;
3308
2128
  response: components["schemas"]["ResourceLLMContextResponse"];
3309
2129
  };
3310
- /** @description Progress state for mark (annotation) workflows. Supports both entity-type-step and percentage-based progress strategies. Emitted on mark:progress SSE channel. */
3311
- MarkProgress: {
3312
- /** @description Echoes the correlationId from the originating mark:assist-request command, if any. Lets clients match progress events back to the operation that initiated them. */
3313
- correlationId?: string;
3314
- /** @description Current status of the annotation workflow */
3315
- status: string;
3316
- /** @description Human-readable status message */
3317
- message?: string;
3318
- /** @description Resource being annotated */
3319
- resourceId?: string;
3320
- /** @description Reference annotation: currently scanning entity type */
3321
- currentEntityType?: string;
3322
- /** @description Reference annotation: completed entity types with counts */
3323
- completedEntityTypes?: {
3324
- entityType: string;
3325
- foundCount: number;
3326
- }[];
3327
- /** @description Percentage-based motivations (highlight, assessment, comment, tag) */
3328
- percentage?: number;
3329
- /** @description Category-based motivations (tag): current category */
3330
- currentCategory?: string;
3331
- /** @description Category-based motivations (tag): number processed */
3332
- processedCategories?: number;
3333
- /** @description Category-based motivations (tag): total categories */
3334
- totalCategories?: number;
3335
- /** @description Request parameters for display in progress UI */
3336
- requestParams?: {
3337
- label: string;
3338
- value: string;
3339
- }[];
3340
- };
3341
- /** @description Completion payload emitted on mark:assist-finished SSE channel when AI-assisted annotation completes. */
3342
- MarkAssistFinished: {
3343
- /** @description Echoes the correlationId from the originating mark:assist-request command, if any. */
3344
- correlationId?: string;
3345
- motivation?: components["schemas"]["Motivation"];
3346
- resourceId?: string;
3347
- status?: string;
3348
- percentage?: number;
3349
- /** @description Number of annotations found/created */
3350
- foundCount?: number;
3351
- /** @description Number of annotations actually created */
3352
- createdCount?: number;
3353
- /** @description Counts by category (for tag annotations) */
3354
- byCategory?: {
3355
- [key: string]: number;
3356
- };
3357
- message?: string;
3358
- progress?: components["schemas"]["MarkProgress"];
3359
- };
3360
- /** @description Error payload emitted on mark:assist-failed SSE channel when AI-assisted annotation fails. */
3361
- MarkAssistFailed: {
3362
- /** @description Echoes the correlationId from the originating mark:assist-request command, if any. */
3363
- correlationId?: string;
3364
- resourceId?: string;
3365
- message?: string;
3366
- };
3367
2130
  /** @description Search results payload emitted on match:search-results SSE channel. */
3368
2131
  MatchSearchResult: {
3369
2132
  correlationId: string;
@@ -3381,36 +2144,6 @@ interface components {
3381
2144
  referenceId: string;
3382
2145
  error: string;
3383
2146
  };
3384
- /** @description Progress state for resource yield (generation) workflow. Emitted as SSE events on yield:progress and yield:finished channels. */
3385
- YieldProgress: {
3386
- /** @description Echoes the correlationId from the originating yield:request command, if any. Lets clients match progress events back to the operation that initiated them. */
3387
- correlationId?: string;
3388
- /** @enum {string} */
3389
- status: "started" | "fetching" | "generating" | "creating" | "complete" | "error";
3390
- /** @description ID of the reference annotation that triggered generation */
3391
- referenceId: string;
3392
- /** @description Name of the resource being generated */
3393
- resourceName?: string;
3394
- /** @description ID of the generated resource (available after creation) */
3395
- resourceId?: string;
3396
- /** @description ID of the source resource containing the reference */
3397
- sourceResourceId?: string;
3398
- /** @description Progress percentage (0-100) */
3399
- percentage: number;
3400
- /** @description Human-readable status message */
3401
- message?: string;
3402
- };
3403
- /** @description Error payload emitted on yield:failed SSE channel when resource generation fails. */
3404
- YieldStreamError: {
3405
- /** @description Echoes the correlationId from the originating yield:request command, if any. */
3406
- correlationId?: string;
3407
- /** @description Error message */
3408
- error?: string;
3409
- status?: string;
3410
- referenceId?: string;
3411
- percentage?: number;
3412
- message?: string;
3413
- };
3414
2147
  /** @description Metadata added at persistence time. Part of every StoredEvent. Integrity is provided by git at the commit level (when gitSync is enabled), not by in-event metadata fields. */
3415
2148
  EventMetadata: {
3416
2149
  /** @description Monotonic position in the event log (ordering authority) */
@@ -3560,6 +2293,8 @@ interface components {
3560
2293
  JobStartedPayload: {
3561
2294
  jobId: string;
3562
2295
  jobType: components["schemas"]["JobType"];
2296
+ /** @description Annotation this job is attached to, when applicable */
2297
+ annotationId?: string;
3563
2298
  totalSteps?: number;
3564
2299
  };
3565
2300
  /** @description Payload for job:progress domain event */
@@ -3583,6 +2318,8 @@ interface components {
3583
2318
  JobCompletedPayload: {
3584
2319
  jobId: string;
3585
2320
  jobType: components["schemas"]["JobType"];
2321
+ /** @description Annotation this job was attached to, when applicable */
2322
+ annotationId?: string;
3586
2323
  totalSteps?: number;
3587
2324
  /** @description For detection: total entities found */
3588
2325
  foundCount?: number;
@@ -3600,47 +2337,11 @@ interface components {
3600
2337
  JobFailedPayload: {
3601
2338
  jobId: string;
3602
2339
  jobType: components["schemas"]["JobType"];
2340
+ /** @description Annotation this job was attached to, when applicable */
2341
+ annotationId?: string;
3603
2342
  error: string;
3604
2343
  details?: string;
3605
2344
  };
3606
- AnnotateHighlightsStreamRequest: {
3607
- /** @description Optional instructions to guide AI highlight annotation */
3608
- instructions?: string;
3609
- /** @description Optional density: desired number of highlights per 2000 words of text (1-15) */
3610
- density?: number;
3611
- };
3612
- AnnotateAssessmentsStreamRequest: {
3613
- /** @description Optional instructions to guide AI assessment annotation */
3614
- instructions?: string;
3615
- /**
3616
- * @description Optional tone/style for generated assessments
3617
- * @enum {string}
3618
- */
3619
- tone?: "analytical" | "critical" | "balanced" | "constructive";
3620
- /** @description Optional density: desired number of assessments per 2000 words of text (1-10) */
3621
- density?: number;
3622
- /** @description BCP 47 language tag for the generated assessment text (e.g. "en", "fr", "de") */
3623
- language?: string;
3624
- };
3625
- AnnotateCommentsStreamRequest: {
3626
- /** @description Optional instructions to guide AI comment annotation */
3627
- instructions?: string;
3628
- /**
3629
- * @description Optional tone/style for generated comments
3630
- * @enum {string}
3631
- */
3632
- tone?: "scholarly" | "explanatory" | "conversational" | "technical";
3633
- /** @description Optional density: desired number of comments per 2000 words of text (2-12) */
3634
- density?: number;
3635
- /** @description BCP 47 language tag for the generated comment text (e.g. 'en', 'fr', 'de') */
3636
- language?: string;
3637
- };
3638
- AnnotateTagsStreamRequest: {
3639
- /** @description Tag schema ID (e.g., 'legal-irac', 'scientific-imrad', 'argument-toulmin') */
3640
- schemaId: string;
3641
- /** @description Categories to annotate from the selected schema (e.g., ['Issue', 'Rule', 'Application', 'Conclusion']) */
3642
- categories: string[];
3643
- };
3644
2345
  ErrorResponse: {
3645
2346
  error: string;
3646
2347
  code?: string;
@@ -3651,47 +2352,6 @@ interface components {
3651
2352
  data: string;
3652
2353
  id?: string;
3653
2354
  };
3654
- YieldResourceFromAnnotationRequest: {
3655
- /** @description Optional name for the generated resource */
3656
- name?: string;
3657
- /** @description Entity types for the generated resource */
3658
- entityTypes?: string[];
3659
- /** @description Optional AI prompt for generation */
3660
- prompt?: string;
3661
- /** @description Language code (e.g., 'en', 'es') */
3662
- language?: string;
3663
- };
3664
- YieldResourceFromAnnotationResponse: {
3665
- resource: components["schemas"]["ResourceDescriptor"];
3666
- annotation: components["schemas"]["Annotation"];
3667
- generated: boolean;
3668
- };
3669
- YieldResourceRequest: {
3670
- /** @description Resource ID containing the annotation */
3671
- resourceId: string;
3672
- /** @description Custom title for generated resource */
3673
- title?: string;
3674
- /** @description Custom prompt for content generation */
3675
- prompt?: string;
3676
- /** @description Language locale (e.g., "es", "fr", "ja") */
3677
- language?: string;
3678
- };
3679
- YieldResourceStreamRequest: {
3680
- /** @description Custom title for generated resource */
3681
- title?: string;
3682
- /** @description Custom prompt for content generation */
3683
- prompt?: string;
3684
- /** @description Language locale for generated content (e.g., "es", "fr", "ja") */
3685
- language?: string;
3686
- /** @description Gathered context including source document excerpts, metadata, and graph context */
3687
- context: components["schemas"]["GatheredContext"];
3688
- /** @description Inference temperature (0.0 = focused, 1.0 = creative) */
3689
- temperature?: number;
3690
- /** @description Maximum tokens to generate */
3691
- maxTokens?: number;
3692
- /** @description file://-relative URI where the generated resource will be saved (e.g. file://generated/overview.md) */
3693
- storageUri: string;
3694
- };
3695
2355
  GetAnnotationHistoryResponse: {
3696
2356
  events: components["schemas"]["StoredEventResponse"][];
3697
2357
  total: number;
@@ -3772,12 +2432,6 @@ interface components {
3772
2432
  progress?: unknown;
3773
2433
  result?: unknown;
3774
2434
  };
3775
- ListAnnotationsResponse: {
3776
- annotations: components["schemas"]["Annotation"][];
3777
- total: number;
3778
- offset: number;
3779
- limit: number;
3780
- };
3781
2435
  ListResourcesResponse: {
3782
2436
  resources: components["schemas"]["ResourceDescriptor"][];
3783
2437
  total: number;
@@ -3852,14 +2506,6 @@ interface components {
3852
2506
  } & {
3853
2507
  [key: string]: unknown;
3854
2508
  };
3855
- BindAnnotationRequest: {
3856
- /** @description Target resource ID to resolve reference to */
3857
- resourceId: string;
3858
- };
3859
- BindAnnotationResponse: {
3860
- annotation: components["schemas"]["Annotation"];
3861
- targetResource?: components["schemas"]["ResourceDescriptor"] | null;
3862
- };
3863
2509
  /** @description Metadata about a resource (1:1 with its URI). JSON-LD subject is @id. Link to concrete bytes via representations. */
3864
2510
  ResourceDescriptor: {
3865
2511
  /** @description JSON-LD context; URI, object, or array of these. */
@@ -4098,8 +2744,10 @@ interface components {
4098
2744
  BeckonSparkleEvent: {
4099
2745
  annotationId: string;
4100
2746
  };
4101
- /** @description Event payload emitted on the bind:body-updated bus channel after annotation bodies are modified. */
2747
+ /** @description Success result emitted on the bind:body-updated bus channel after bind:update-body has been applied. */
4102
2748
  BindBodyUpdated: {
2749
+ /** @description Correlation ID echoed from the originating bind:update-body command */
2750
+ correlationId: string;
4103
2751
  /** @description Branded AnnotationId of the annotation whose body was updated */
4104
2752
  annotationId: string;
4105
2753
  };
@@ -4166,6 +2814,14 @@ interface components {
4166
2814
  correlationId: string;
4167
2815
  response: components["schemas"]["GetAnnotationResponse"];
4168
2816
  };
2817
+ /** @description Request to get contextual text around an annotation */
2818
+ BrowseAnnotationContextRequest: {
2819
+ correlationId: string;
2820
+ annotationId: string;
2821
+ resourceId: string;
2822
+ contextBefore?: number;
2823
+ contextAfter?: number;
2824
+ };
4169
2825
  /** @description Request to browse annotations for a resource */
4170
2826
  BrowseAnnotationsRequest: {
4171
2827
  correlationId: string;
@@ -4319,7 +2975,7 @@ interface components {
4319
2975
  /** @description The gathered annotation context */
4320
2976
  response: components["schemas"]["AnnotationLLMContextResponse"];
4321
2977
  };
4322
- /** @description Request payload sent on the gather:annotation-request bus channel to gather context for an annotation. */
2978
+ /** @description Request payload sent on the gather:requested bus channel to gather context for an annotation. */
4323
2979
  GatherAnnotationRequest: {
4324
2980
  /** @description Client-generated correlation ID to thread the response back to the originating request */
4325
2981
  correlationId: string;
@@ -4407,7 +3063,7 @@ interface components {
4407
3063
  /** @description The gathered resource context */
4408
3064
  response: components["schemas"]["ResourceLLMContextResponse"];
4409
3065
  };
4410
- /** @description Request payload sent on the gather:resource-request bus channel to gather context for a resource. */
3066
+ /** @description Request payload sent on the gather:resource-requested bus channel to gather context for a resource. */
4411
3067
  GatherResourceRequest: {
4412
3068
  /** @description Client-generated correlation ID to thread the response back to the originating request */
4413
3069
  correlationId: string;
@@ -4425,6 +3081,12 @@ interface components {
4425
3081
  includeSummary: boolean;
4426
3082
  };
4427
3083
  };
3084
+ /** @description Request to generate an AI summary of an annotation */
3085
+ GatherSummaryRequest: {
3086
+ correlationId: string;
3087
+ annotationId: string;
3088
+ resourceId: string;
3089
+ };
4428
3090
  /** @description Result of a completed assessment-annotation job. */
4429
3091
  JobAssessmentAnnotationResult: {
4430
3092
  assessmentsFound: number;
@@ -4435,6 +3097,28 @@ interface components {
4435
3097
  /** @enum {string} */
4436
3098
  jobType: "annotation" | "generation";
4437
3099
  };
3100
+ /** @description Command to claim a pending job (atomic CAS: pending → running) */
3101
+ JobClaimCommand: {
3102
+ correlationId: string;
3103
+ jobId: string;
3104
+ };
3105
+ /** @description Command to create a new job via the event bus */
3106
+ JobCreateCommand: {
3107
+ correlationId: string;
3108
+ /** @enum {string} */
3109
+ jobType: "reference-annotation" | "highlight-annotation" | "assessment-annotation" | "comment-annotation" | "tag-annotation" | "generation";
3110
+ resourceId: string;
3111
+ params: {
3112
+ [key: string]: unknown;
3113
+ };
3114
+ };
3115
+ /** @description Result of a job:create command */
3116
+ JobCreatedResult: {
3117
+ correlationId: string;
3118
+ response: {
3119
+ jobId: string;
3120
+ };
3121
+ };
4438
3122
  /** @description Result of a completed comment-annotation job. */
4439
3123
  JobCommentAnnotationResult: {
4440
3124
  commentsFound: number;
@@ -4446,6 +3130,8 @@ interface components {
4446
3130
  userId: string;
4447
3131
  jobId: string;
4448
3132
  jobType: components["schemas"]["JobType"];
3133
+ /** @description Annotation this job is attached to, when applicable. Lets the UI route completion feedback (toast, resolve state) to a specific annotation. */
3134
+ annotationId?: string;
4449
3135
  result?: components["schemas"]["JobResult"];
4450
3136
  };
4451
3137
  /** @description Command to mark a job as failed */
@@ -4454,12 +3140,14 @@ interface components {
4454
3140
  userId: string;
4455
3141
  jobId: string;
4456
3142
  jobType: components["schemas"]["JobType"];
3143
+ /** @description Annotation this job is attached to, when applicable. Lets the UI route failure feedback (error toast, revert state) to a specific annotation. */
3144
+ annotationId?: string;
4457
3145
  error: string;
4458
3146
  };
4459
- /** @description Result of a completed generation job. */
3147
+ /** @description Result of a completed generation job. resourceId is assigned by Stower when yield:create is processed; the worker emits job:complete with only resourceName, and Stower populates resourceId on the persisted payload. */
4460
3148
  JobGenerationResult: {
4461
- /** @description ID of the generated resource */
4462
- resourceId: string;
3149
+ /** @description ID of the generated resource (populated by Stower, not by the worker) */
3150
+ resourceId?: string;
4463
3151
  /** @description Name of the generated resource */
4464
3152
  resourceName: string;
4465
3153
  };
@@ -4468,14 +3156,16 @@ interface components {
4468
3156
  highlightsFound: number;
4469
3157
  highlightsCreated: number;
4470
3158
  };
4471
- /** @description Progress report from a running job. Common fields are stage/percentage/message; job-type-specific fields may also be present. */
3159
+ /** @description Progress report from a running job. Common fields are stage/percentage/message; job-type-specific fields may also be present. This is the single progress shape for every job type — annotation workers and generation alike. */
4472
3160
  JobProgress: {
4473
- /** @description Current processing stage */
3161
+ /** @description Current processing stage (e.g. 'analyzing', 'creating', 'complete', 'error') */
4474
3162
  stage: string;
4475
3163
  /** @description Completion percentage (0-100) */
4476
3164
  percentage: number;
4477
3165
  /** @description Human-readable progress message */
4478
3166
  message: string;
3167
+ /** @description Annotation this job is attached to, when applicable. Echoed inside JobProgress (in addition to the outer command envelope) so consumers that only see the inner progress object (e.g. client.yield.fromAnnotation's Observable) can still route visual feedback to a specific annotation. */
3168
+ annotationId?: string;
4479
3169
  /** @description Total entity types to process (reference-annotation) */
4480
3170
  totalEntityTypes?: number;
4481
3171
  /** @description Entity types processed so far (reference-annotation) */
@@ -4486,12 +3176,22 @@ interface components {
4486
3176
  entitiesEmitted?: number;
4487
3177
  /** @description Entity type currently being processed */
4488
3178
  currentEntityType?: string;
3179
+ /** @description Reference annotation: completed entity types with per-type counts, for UI progress display */
3180
+ completedEntityTypes?: {
3181
+ entityType: string;
3182
+ foundCount: number;
3183
+ }[];
4489
3184
  /** @description Categories processed (tag-annotation) */
4490
3185
  processedCategories?: number;
4491
3186
  /** @description Total categories (tag-annotation) */
4492
3187
  totalCategories?: number;
4493
3188
  /** @description Category currently being processed (tag-annotation) */
4494
3189
  currentCategory?: string;
3190
+ /** @description Echoed job parameters for display in the progress UI (e.g. entity types or categories the user asked to detect) */
3191
+ requestParams?: {
3192
+ label: string;
3193
+ value: string;
3194
+ }[];
4495
3195
  };
4496
3196
  /** @description Event indicating a job has been queued */
4497
3197
  JobQueuedEvent: {
@@ -4514,6 +3214,8 @@ interface components {
4514
3214
  userId: string;
4515
3215
  jobId: string;
4516
3216
  jobType: components["schemas"]["JobType"];
3217
+ /** @description Annotation this job is attached to, when applicable. Lets the UI attach progress visuals to a specific annotation (e.g. a reference whose generation is running). */
3218
+ annotationId?: string;
4517
3219
  percentage: number;
4518
3220
  progress?: components["schemas"]["JobProgress"];
4519
3221
  };
@@ -4525,6 +3227,8 @@ interface components {
4525
3227
  userId: string;
4526
3228
  jobId: string;
4527
3229
  jobType: components["schemas"]["JobType"];
3230
+ /** @description Annotation this job is attached to, when applicable. Set for annotation-scoped jobs like generation (from a specific reference). Unset for resource-scoped jobs like bulk reference/tag/highlight detection. */
3231
+ annotationId?: string;
4528
3232
  };
4529
3233
  /** @description Request to check the status of a job */
4530
3234
  JobStatusRequest: {
@@ -4581,6 +3285,8 @@ interface components {
4581
3285
  };
4582
3286
  /** @description Bus command to create an annotation on a resource. */
4583
3287
  MarkCreateCommand: {
3288
+ /** @description Optional correlation id threaded from the originating mark:create-request. Propagated into event metadata by Stower so annotation-assembly can emit mark:create-ok after persistence completes. */
3289
+ correlationId?: string;
4584
3290
  annotation: components["schemas"]["Annotation"];
4585
3291
  userId: string;
4586
3292
  resourceId: string;
@@ -4589,6 +3295,12 @@ interface components {
4589
3295
  MarkCreateOk: {
4590
3296
  annotationId: string;
4591
3297
  };
3298
+ /** @description Raw annotation creation intent — bus handler assembles the W3C annotation */
3299
+ MarkCreateRequest: {
3300
+ correlationId: string;
3301
+ resourceId: string;
3302
+ request: components["schemas"]["CreateAnnotationRequest"];
3303
+ };
4592
3304
  /** @description Bus command to delete an annotation. */
4593
3305
  MarkDeleteCommand: {
4594
3306
  annotationId: string;
@@ -4618,7 +3330,8 @@ interface components {
4618
3330
  motivation: components["schemas"]["Motivation"];
4619
3331
  /** @description One or more W3C selectors */
4620
3332
  selector: components["schemas"]["TextPositionSelector"] | components["schemas"]["TextQuoteSelector"] | components["schemas"]["SvgSelector"] | components["schemas"]["FragmentSelector"] | (components["schemas"]["TextPositionSelector"] | components["schemas"]["TextQuoteSelector"] | components["schemas"]["SvgSelector"] | components["schemas"]["FragmentSelector"])[];
4621
- body: components["schemas"]["AnnotationBody"][];
3333
+ /** @description Optional body. Omit for annotations whose motivation alone is meaningful (e.g. highlighting) or whose user-supplied content is empty (e.g. an assessing annotation saved without comment text). Shape matches Annotation.body. */
3334
+ body?: components["schemas"]["AnnotationBody"] | components["schemas"]["AnnotationBody"][];
4622
3335
  };
4623
3336
  /** @description Bus command to unarchive a previously archived resource. */
4624
3337
  MarkUnarchiveCommand: {
@@ -5076,11 +3789,6 @@ interface ResourceAnnotations {
5076
3789
  * Organized by flow (verb), then by category within each flow.
5077
3790
  */
5078
3791
 
5079
- type Selector = components['schemas']['TextPositionSelector'] | components['schemas']['TextQuoteSelector'] | components['schemas']['SvgSelector'] | components['schemas']['FragmentSelector'];
5080
- type GatheredContext = components['schemas']['GatheredContext'];
5081
- type YieldProgress = components['schemas']['YieldProgress'];
5082
- type MarkProgress = components['schemas']['MarkProgress'];
5083
- type SelectionData = components['schemas']['SelectionData'];
5084
3792
  /**
5085
3793
  * The unified EventMap — every channel on the EventBus.
5086
3794
  *
@@ -5096,9 +3804,6 @@ type EventMap = {
5096
3804
  'yield:moved': StoredEvent<EventOfType<'yield:moved'>>;
5097
3805
  'yield:representation-added': StoredEvent<EventOfType<'yield:representation-added'>>;
5098
3806
  'yield:representation-removed': StoredEvent<EventOfType<'yield:representation-removed'>>;
5099
- 'yield:progress': components['schemas']['YieldProgress'];
5100
- 'yield:finished': components['schemas']['YieldProgress'];
5101
- 'yield:failed': components['schemas']['YieldStreamError'];
5102
3807
  'yield:request': components['schemas']['YieldRequestCommand'];
5103
3808
  'yield:create': components['schemas']['YieldCreateCommand'];
5104
3809
  'yield:update': components['schemas']['YieldUpdateCommand'];
@@ -5141,9 +3846,7 @@ type EventMap = {
5141
3846
  'mark:entity-type-added': StoredEvent<EventOfType<'mark:entity-type-added'>>;
5142
3847
  'mark:archived': StoredEvent<EventOfType<'mark:archived'>>;
5143
3848
  'mark:unarchived': StoredEvent<EventOfType<'mark:unarchived'>>;
5144
- 'mark:progress': components['schemas']['MarkProgress'];
5145
- 'mark:assist-finished': components['schemas']['MarkAssistFinished'];
5146
- 'mark:assist-failed': components['schemas']['MarkAssistFailed'];
3849
+ 'mark:create-request': components['schemas']['MarkCreateRequest'];
5147
3850
  'mark:create': components['schemas']['MarkCreateCommand'];
5148
3851
  'mark:delete': components['schemas']['MarkDeleteCommand'];
5149
3852
  'mark:update-body': components['schemas']['MarkUpdateBodyCommand'];
@@ -5190,6 +3893,14 @@ type EventMap = {
5190
3893
  correlationId: string;
5191
3894
  resourceId: string;
5192
3895
  } & components['schemas']['CommandError'];
3896
+ 'gather:summary-requested': components['schemas']['GatherSummaryRequest'];
3897
+ 'gather:summary-result': {
3898
+ correlationId: string;
3899
+ response: Record<string, unknown>;
3900
+ };
3901
+ 'gather:summary-failed': {
3902
+ correlationId: string;
3903
+ } & components['schemas']['CommandError'];
5193
3904
  'gather:annotation-progress': components['schemas']['GatherProgress'];
5194
3905
  'gather:annotation-finished': components['schemas']['GatherAnnotationFinished'];
5195
3906
  'gather:progress': components['schemas']['GatherProgress'];
@@ -5224,6 +3935,14 @@ type EventMap = {
5224
3935
  'browse:annotation-history-failed': {
5225
3936
  correlationId: string;
5226
3937
  } & components['schemas']['CommandError'];
3938
+ 'browse:annotation-context-requested': components['schemas']['BrowseAnnotationContextRequest'];
3939
+ 'browse:annotation-context-result': {
3940
+ correlationId: string;
3941
+ response: Record<string, unknown>;
3942
+ };
3943
+ 'browse:annotation-context-failed': {
3944
+ correlationId: string;
3945
+ } & components['schemas']['CommandError'];
5227
3946
  'browse:referenced-by-requested': components['schemas']['BrowseReferencedByRequest'];
5228
3947
  'browse:referenced-by-result': components['schemas']['BrowseReferencedByResult'];
5229
3948
  'browse:referenced-by-failed': {
@@ -5241,19 +3960,19 @@ type EventMap = {
5241
3960
  path: string;
5242
3961
  } & components['schemas']['CommandError'];
5243
3962
  'browse:click': components['schemas']['BrowseClickEvent'];
5244
- 'browse:panel-toggle': components['schemas']['BrowsePanelToggleEvent'];
5245
- 'browse:panel-open': components['schemas']['BrowsePanelOpenEvent'];
5246
- 'browse:panel-close': void;
5247
- 'browse:sidebar-toggle': void;
5248
- 'browse:resource-close': components['schemas']['BrowseResourceCloseEvent'];
5249
- 'browse:resource-reorder': components['schemas']['BrowseResourceReorderEvent'];
5250
- 'browse:link-clicked': components['schemas']['BrowseLinkClickedEvent'];
5251
- 'browse:router-push': components['schemas']['BrowseRouterPushEvent'];
5252
- 'browse:external-navigate': components['schemas']['BrowseExternalNavigateEvent'] & {
5253
- cancelFallback: () => void;
5254
- };
5255
3963
  'browse:reference-navigate': components['schemas']['BrowseReferenceNavigateEvent'];
5256
3964
  'browse:entity-type-clicked': components['schemas']['BrowseEntityTypeClickedEvent'];
3965
+ 'panel:toggle': components['schemas']['BrowsePanelToggleEvent'];
3966
+ 'panel:open': components['schemas']['BrowsePanelOpenEvent'];
3967
+ 'panel:close': void;
3968
+ 'shell:sidebar-toggle': void;
3969
+ 'tabs:close': components['schemas']['BrowseResourceCloseEvent'];
3970
+ 'tabs:reorder': components['schemas']['BrowseResourceReorderEvent'];
3971
+ 'nav:link-clicked': components['schemas']['BrowseLinkClickedEvent'];
3972
+ 'nav:push': components['schemas']['BrowseRouterPushEvent'];
3973
+ 'nav:external': components['schemas']['BrowseExternalNavigateEvent'] & {
3974
+ cancelFallback: () => void;
3975
+ };
5257
3976
  'beckon:hover': components['schemas']['BeckonHoverEvent'];
5258
3977
  'beckon:focus': components['schemas']['BeckonFocusEvent'];
5259
3978
  'beckon:sparkle': components['schemas']['BeckonSparkleEvent'];
@@ -5268,10 +3987,23 @@ type EventMap = {
5268
3987
  'job:queued': components['schemas']['JobQueuedEvent'];
5269
3988
  'job:cancel-requested': components['schemas']['JobCancelRequest'];
5270
3989
  'job:status-requested': components['schemas']['JobStatusRequest'];
3990
+ 'job:create': components['schemas']['JobCreateCommand'];
3991
+ 'job:claim': components['schemas']['JobClaimCommand'];
5271
3992
  'job:status-result': components['schemas']['JobStatusResult'];
5272
3993
  'job:status-failed': {
5273
3994
  correlationId: string;
5274
3995
  } & components['schemas']['CommandError'];
3996
+ 'job:created': components['schemas']['JobCreatedResult'];
3997
+ 'job:create-failed': {
3998
+ correlationId: string;
3999
+ } & components['schemas']['CommandError'];
4000
+ 'job:claimed': {
4001
+ correlationId: string;
4002
+ response: Record<string, unknown>;
4003
+ };
4004
+ 'job:claim-failed': {
4005
+ correlationId: string;
4006
+ } & components['schemas']['CommandError'];
5275
4007
  'settings:theme-changed': components['schemas']['SettingsThemeChangedEvent'];
5276
4008
  'settings:line-numbers-toggled': void;
5277
4009
  'settings:locale-changed': components['schemas']['SettingsLocaleChangedEvent'];
@@ -5284,25 +4016,253 @@ type EventMap = {
5284
4016
  cap: number;
5285
4017
  message: string;
5286
4018
  };
4019
+ /**
4020
+ * Emitted by the `/bus/subscribe` handler when a client reconnected
4021
+ * with `Last-Event-ID: p-<scope>-<seq>` but the server could not
4022
+ * replay all missed persisted events for that scope (retention
4023
+ * window exceeded, scope unknown, or request unparseable). The
4024
+ * client should treat this as a signal to fall back to the pre-
4025
+ * resumption contract: invalidate caches for the affected scope
4026
+ * and re-read from scratch. Analogous to `replay-window-exceeded`
4027
+ * but scoped to the bus gateway rather than the per-resource
4028
+ * events stream.
4029
+ *
4030
+ * `scope` is the scope string the client asked about (omitted for
4031
+ * global-persisted resumption gaps, if that path ever exists).
4032
+ * `reason` is human-readable, for logging.
4033
+ */
4034
+ 'bus:resume-gap': {
4035
+ scope?: string;
4036
+ lastSeenId?: string;
4037
+ reason: string;
4038
+ };
5287
4039
  };
5288
4040
  /** Any valid channel name on the EventBus. */
5289
4041
  type EventName = keyof EventMap;
5290
4042
  /**
5291
- * Non-persisted event types that the per-resource events-stream should deliver
5292
- * to all connected clients. These are ephemeral command-result and progress
5293
- * events that don't go through EventStore.appendEvent but still need to reach
5294
- * every participant viewing the resource for real-time collaboration.
4043
+ * Genuine resource-bound broadcast event types.
4044
+ *
4045
+ * Publishers emit these on the scoped EventBus (`eventBus.scope(resourceId)`)
4046
+ * because every participant viewing the resource should receive them — not
4047
+ * just the caller who triggered the originating action. Examples: resource
4048
+ * generation progress, which multiple viewers of a generating resource all
4049
+ * want to see.
4050
+ *
4051
+ * Non-broadcast progress (AI-assist progress for one user, search results
4052
+ * for one caller) does NOT belong here. Those are per-caller correlation-ID
4053
+ * responses and publish globally — the caller filters by `correlationId`.
4054
+ *
4055
+ * The frontend's `subscribeToResource(id)` wires these channels via
4056
+ * `scope=id&scoped=<channel>` so the SSE route delivers them to that
4057
+ * participant. WorkerVM uses this list to decide which emitted events to
4058
+ * scope to their resource.
4059
+ */
4060
+ /**
4061
+ * Audit note (SIMPLE-BUS Phase 3 close): `yield:progress` was
4062
+ * considered for inclusion but has only one consumer — the
4063
+ * yield-initiator's Observable in `packages/api-client/src/namespaces/yield.ts`.
4064
+ * No viewer of the resource other than the initiator subscribes to
4065
+ * progress. Scoping therefore serves no fan-out-narrowing purpose for
4066
+ * that channel, so it stays global (as a correlation-ID-shaped
4067
+ * response, filtered by `referenceId`). Only `yield:finished` and
4068
+ * `yield:failed` have a genuine multi-participant consumer (the
4069
+ * ResourceViewerPage toast on the source resource).
4070
+ */
4071
+ declare const RESOURCE_BROADCAST_TYPES: readonly ["job:complete", "job:fail"];
4072
+ type ResourceBroadcastType = typeof RESOURCE_BROADCAST_TYPES[number];
4073
+ /**
4074
+ * Authoritative map from bus channel to OpenAPI schema name.
4075
+ *
4076
+ * Every {@link EventName} must appear. The `satisfies` clause below
4077
+ * enforces completeness at compile time — adding a channel to
4078
+ * {@link EventMap} without adding an entry here is a build error.
4079
+ *
4080
+ * Values:
4081
+ * - `<SchemaName>`: payload validates against `components['schemas'][SchemaName]`.
4082
+ * - `null`: no single-schema validation. Used for branded
4083
+ * `StoredEvent` wrappers, `void` UI signals, and compound inline
4084
+ * types (e.g. `{ correlationId } & CommandError`). These are not
4085
+ * validated by `/bus/emit`.
4086
+ *
4087
+ * The `/bus/emit` route reads this map to validate incoming payloads.
4088
+ * Consumers can also use it to do client-side pre-flight validation
4089
+ * before emitting.
4090
+ */
4091
+ declare const CHANNEL_SCHEMAS: {
4092
+ readonly 'yield:created': null;
4093
+ readonly 'yield:cloned': null;
4094
+ readonly 'yield:updated': null;
4095
+ readonly 'yield:moved': null;
4096
+ readonly 'yield:representation-added': null;
4097
+ readonly 'yield:representation-removed': null;
4098
+ readonly 'yield:request': "YieldRequestCommand";
4099
+ readonly 'yield:create': "YieldCreateCommand";
4100
+ readonly 'yield:update': "YieldUpdateCommand";
4101
+ readonly 'yield:mv': "YieldMvCommand";
4102
+ readonly 'yield:clone': null;
4103
+ readonly 'yield:clone-token-requested': "YieldCloneTokenRequest";
4104
+ readonly 'yield:clone-resource-requested': "YieldCloneResourceRequest";
4105
+ readonly 'yield:clone-create': "YieldCloneCreateCommand";
4106
+ readonly 'yield:create-ok': "YieldCreateOk";
4107
+ readonly 'yield:create-failed': "CommandError";
4108
+ readonly 'yield:update-ok': "YieldUpdateOk";
4109
+ readonly 'yield:update-failed': null;
4110
+ readonly 'yield:move-ok': "YieldMoveOk";
4111
+ readonly 'yield:move-failed': null;
4112
+ readonly 'yield:clone-token-generated': null;
4113
+ readonly 'yield:clone-token-failed': null;
4114
+ readonly 'yield:clone-resource-result': null;
4115
+ readonly 'yield:clone-resource-failed': null;
4116
+ readonly 'yield:clone-created': "YieldCloneCreated";
4117
+ readonly 'yield:clone-create-failed': null;
4118
+ readonly 'mark:added': null;
4119
+ readonly 'mark:removed': null;
4120
+ readonly 'mark:body-updated': null;
4121
+ readonly 'mark:entity-tag-added': null;
4122
+ readonly 'mark:entity-tag-removed': null;
4123
+ readonly 'mark:entity-type-added': null;
4124
+ readonly 'mark:archived': null;
4125
+ readonly 'mark:unarchived': null;
4126
+ readonly 'mark:create-request': "MarkCreateRequest";
4127
+ readonly 'mark:create': "MarkCreateCommand";
4128
+ readonly 'mark:delete': "MarkDeleteCommand";
4129
+ readonly 'mark:update-body': "MarkUpdateBodyCommand";
4130
+ readonly 'mark:archive': "MarkArchiveCommand";
4131
+ readonly 'mark:unarchive': "MarkUnarchiveCommand";
4132
+ readonly 'mark:update-entity-types': "MarkUpdateEntityTypesCommand";
4133
+ readonly 'mark:add-entity-type': "MarkAddEntityTypeCommand";
4134
+ readonly 'mark:create-ok': "MarkCreateOk";
4135
+ readonly 'mark:create-failed': "CommandError";
4136
+ readonly 'mark:delete-ok': "MarkDeleteOk";
4137
+ readonly 'mark:delete-failed': "CommandError";
4138
+ readonly 'mark:body-update-failed': "CommandError";
4139
+ readonly 'mark:entity-type-add-failed': "CommandError";
4140
+ readonly 'mark:select-comment': "SelectionData";
4141
+ readonly 'mark:select-tag': "SelectionData";
4142
+ readonly 'mark:select-assessment': "SelectionData";
4143
+ readonly 'mark:select-reference': "SelectionData";
4144
+ readonly 'mark:requested': "MarkRequestedEvent";
4145
+ readonly 'mark:cancel-pending': null;
4146
+ readonly 'mark:submit': "MarkSubmitEvent";
4147
+ readonly 'mark:assist-request': "MarkAssistRequestEvent";
4148
+ readonly 'mark:assist-cancelled': null;
4149
+ readonly 'mark:progress-dismiss': null;
4150
+ readonly 'mark:mode-toggled': null;
4151
+ readonly 'mark:selection-changed': "MarkSelectionChangedEvent";
4152
+ readonly 'mark:click-changed': "MarkClickChangedEvent";
4153
+ readonly 'mark:shape-changed': "MarkShapeChangedEvent";
4154
+ readonly 'bind:initiate': "BindInitiateCommand";
4155
+ readonly 'bind:update-body': "BindUpdateBodyCommand";
4156
+ readonly 'bind:body-updated': "BindBodyUpdated";
4157
+ readonly 'bind:body-update-failed': "CommandError";
4158
+ readonly 'match:search-requested': "MatchSearchRequest";
4159
+ readonly 'match:search-results': "MatchSearchResult";
4160
+ readonly 'match:search-failed': "MatchSearchFailed";
4161
+ readonly 'gather:requested': "GatherAnnotationRequest";
4162
+ readonly 'gather:complete': "GatherAnnotationComplete";
4163
+ readonly 'gather:failed': null;
4164
+ readonly 'gather:resource-requested': "GatherResourceRequest";
4165
+ readonly 'gather:resource-complete': "GatherResourceComplete";
4166
+ readonly 'gather:resource-failed': null;
4167
+ readonly 'gather:summary-requested': "GatherSummaryRequest";
4168
+ readonly 'gather:summary-result': null;
4169
+ readonly 'gather:summary-failed': null;
4170
+ readonly 'gather:annotation-progress': "GatherProgress";
4171
+ readonly 'gather:annotation-finished': "GatherAnnotationFinished";
4172
+ readonly 'gather:progress': "GatherProgress";
4173
+ readonly 'gather:finished': "GatherFinished";
4174
+ readonly 'browse:resource-requested': "BrowseResourceRequest";
4175
+ readonly 'browse:resource-result': "BrowseResourceResult";
4176
+ readonly 'browse:resource-failed': null;
4177
+ readonly 'browse:resources-requested': "BrowseResourcesRequest";
4178
+ readonly 'browse:resources-result': "BrowseResourcesResult";
4179
+ readonly 'browse:resources-failed': null;
4180
+ readonly 'browse:annotations-requested': "BrowseAnnotationsRequest";
4181
+ readonly 'browse:annotations-result': "BrowseAnnotationsResult";
4182
+ readonly 'browse:annotations-failed': null;
4183
+ readonly 'browse:annotation-requested': "BrowseAnnotationRequest";
4184
+ readonly 'browse:annotation-result': "BrowseAnnotationResult";
4185
+ readonly 'browse:annotation-failed': null;
4186
+ readonly 'browse:events-requested': "BrowseEventsRequest";
4187
+ readonly 'browse:events-result': "BrowseEventsResult";
4188
+ readonly 'browse:events-failed': null;
4189
+ readonly 'browse:annotation-history-requested': "BrowseAnnotationHistoryRequest";
4190
+ readonly 'browse:annotation-history-result': "BrowseAnnotationHistoryResult";
4191
+ readonly 'browse:annotation-history-failed': null;
4192
+ readonly 'browse:annotation-context-requested': "BrowseAnnotationContextRequest";
4193
+ readonly 'browse:annotation-context-result': null;
4194
+ readonly 'browse:annotation-context-failed': null;
4195
+ readonly 'browse:referenced-by-requested': "BrowseReferencedByRequest";
4196
+ readonly 'browse:referenced-by-result': "BrowseReferencedByResult";
4197
+ readonly 'browse:referenced-by-failed': null;
4198
+ readonly 'browse:entity-types-requested': "BrowseEntityTypesRequest";
4199
+ readonly 'browse:entity-types-result': "BrowseEntityTypesResult";
4200
+ readonly 'browse:entity-types-failed': null;
4201
+ readonly 'browse:directory-requested': "BrowseDirectoryRequest";
4202
+ readonly 'browse:directory-result': "BrowseDirectoryResult";
4203
+ readonly 'browse:directory-failed': null;
4204
+ readonly 'browse:click': "BrowseClickEvent";
4205
+ readonly 'browse:reference-navigate': "BrowseReferenceNavigateEvent";
4206
+ readonly 'browse:entity-type-clicked': "BrowseEntityTypeClickedEvent";
4207
+ readonly 'panel:toggle': "BrowsePanelToggleEvent";
4208
+ readonly 'panel:open': "BrowsePanelOpenEvent";
4209
+ readonly 'panel:close': null;
4210
+ readonly 'shell:sidebar-toggle': null;
4211
+ readonly 'tabs:close': "BrowseResourceCloseEvent";
4212
+ readonly 'tabs:reorder': "BrowseResourceReorderEvent";
4213
+ readonly 'nav:link-clicked': "BrowseLinkClickedEvent";
4214
+ readonly 'nav:push': "BrowseRouterPushEvent";
4215
+ readonly 'nav:external': null;
4216
+ readonly 'beckon:hover': "BeckonHoverEvent";
4217
+ readonly 'beckon:focus': "BeckonFocusEvent";
4218
+ readonly 'beckon:sparkle': "BeckonSparkleEvent";
4219
+ readonly 'job:started': null;
4220
+ readonly 'job:progress': null;
4221
+ readonly 'job:completed': null;
4222
+ readonly 'job:failed': null;
4223
+ readonly 'job:start': "JobStartCommand";
4224
+ readonly 'job:report-progress': "JobReportProgressCommand";
4225
+ readonly 'job:complete': "JobCompleteCommand";
4226
+ readonly 'job:fail': "JobFailCommand";
4227
+ readonly 'job:queued': "JobQueuedEvent";
4228
+ readonly 'job:cancel-requested': "JobCancelRequest";
4229
+ readonly 'job:status-requested': "JobStatusRequest";
4230
+ readonly 'job:create': "JobCreateCommand";
4231
+ readonly 'job:claim': "JobClaimCommand";
4232
+ readonly 'job:status-result': "JobStatusResult";
4233
+ readonly 'job:status-failed': null;
4234
+ readonly 'job:created': "JobCreatedResult";
4235
+ readonly 'job:create-failed': null;
4236
+ readonly 'job:claimed': null;
4237
+ readonly 'job:claim-failed': null;
4238
+ readonly 'settings:theme-changed': "SettingsThemeChangedEvent";
4239
+ readonly 'settings:line-numbers-toggled': null;
4240
+ readonly 'settings:locale-changed': "SettingsLocaleChangedEvent";
4241
+ readonly 'settings:hover-delay-changed': "SettingsHoverDelayChangedEvent";
4242
+ readonly 'stream-connected': null;
4243
+ readonly 'replay-window-exceeded': null;
4244
+ readonly 'bus:resume-gap': null;
4245
+ };
4246
+ /** Channels where `/bus/emit` validates the payload (non-null schema). */
4247
+ type EmittableChannel = {
4248
+ [K in EventName]: typeof CHANNEL_SCHEMAS[K] extends null ? never : K;
4249
+ }[EventName];
4250
+
4251
+ /**
4252
+ * Payload Type Aliases
5295
4253
  *
5296
- * Actors (Binder, Gatherer, workers) publish these on the scoped EventBus
5297
- * (`eventBus.scope(resourceId)`). The events-stream route subscribes to them
5298
- * alongside the persisted event types.
4254
+ * Convenience aliases for OpenAPI-generated schema types that are
4255
+ * referenced across the codebase. Shorter than
4256
+ * `components['schemas']['<Name>']` and carry intent.
5299
4257
  *
5300
- * Unlike PERSISTED_EVENT_TYPES, there's no compile-time exhaustiveness check
5301
- * here because these event types are a curated subset of EventMap — not every
5302
- * non-persisted event should flow to all participants. Adding a new one is a
5303
- * deliberate choice, not an automatic cascade.
4258
+ * These aliases are not about the bus. They live here so that
4259
+ * bus-protocol.ts can focus on channel-protocol concerns (EventMap,
4260
+ * CHANNEL_SCHEMAS, scope classification).
5304
4261
  */
5305
- declare const STREAM_COMMAND_RESULT_TYPES: readonly ["match:search-results", "match:search-failed", "gather:complete", "gather:failed", "gather:annotation-progress", "mark:progress", "mark:assist-finished", "mark:assist-failed", "yield:progress", "yield:finished", "yield:failed"];
4262
+
4263
+ type Selector = components['schemas']['TextPositionSelector'] | components['schemas']['TextQuoteSelector'] | components['schemas']['SvgSelector'] | components['schemas']['FragmentSelector'];
4264
+ type GatheredContext = components['schemas']['GatheredContext'];
4265
+ type SelectionData = components['schemas']['SelectionData'];
5306
4266
 
5307
4267
  /**
5308
4268
  * Event Type Guards and Extraction Utilities
@@ -5545,6 +4505,57 @@ interface BurstBufferOptions {
5545
4505
  */
5546
4506
  declare function burstBuffer<T>(options: BurstBufferOptions): OperatorFunction<T, T | T[]>;
5547
4507
 
4508
+ /**
4509
+ * serializePerKey — run async work serialized per key, parallel across keys.
4510
+ *
4511
+ * Invariant: two calls with the same `key` run strictly in sequence (the
4512
+ * second `work` does not start until the first has settled). Calls with
4513
+ * different keys overlap freely.
4514
+ *
4515
+ * Error isolation: a rejected work function does not poison subsequent
4516
+ * tasks for the same key. The next task starts fresh from whatever state
4517
+ * the failed task left behind. The rejection still propagates to *this*
4518
+ * caller.
4519
+ *
4520
+ * Registry cleanup: the entry for a key is removed as soon as its chain
4521
+ * empties, so the Map stays bounded by the number of keys with work
4522
+ * currently in flight, not by the total number of keys ever seen.
4523
+ *
4524
+ * ## Usage
4525
+ *
4526
+ * ```ts
4527
+ * const chains = new Map<string, Promise<void>>();
4528
+ *
4529
+ * async function write(resourceId: string, event: Event) {
4530
+ * return serializePerKey(resourceId, chains, async () => {
4531
+ * // Read-modify-write on a view file. Any two concurrent calls with
4532
+ * // the same resourceId will be serialized; different resourceIds
4533
+ * // will proceed in parallel.
4534
+ * const view = await viewStorage.get(resourceId);
4535
+ * applyEvent(view, event);
4536
+ * await viewStorage.save(resourceId, view);
4537
+ * });
4538
+ * }
4539
+ * ```
4540
+ *
4541
+ * ## When to use this vs RxJS `groupBy + concatMap`
4542
+ *
4543
+ * Use `serializePerKey` when the work arrives as **direct method calls**
4544
+ * that need to block the caller until completion. This is the RPC shape
4545
+ * — think `EventStore.appendEvent` calling `await views.materializeResource(...)`
4546
+ * and needing the view written before any subscriber sees the published
4547
+ * event.
4548
+ *
4549
+ * Use RxJS `groupBy(keyFn) + concatMap(...)` when the work arrives as an
4550
+ * **event stream** that a component subscribes to once at startup. This
4551
+ * is how `Smelter`, `GraphDBConsumer`, and `Gatherer` serialize their own
4552
+ * per-resource work — see their implementations in `packages/make-meaning`.
4553
+ *
4554
+ * Both patterns solve the same logical problem ("serialize work per key").
4555
+ * The choice is dictated by whether the caller is awaiting the result.
4556
+ */
4557
+ declare function serializePerKey<K, T>(key: K, chains: Map<K, Promise<void>>, work: () => Promise<T>): Promise<T>;
4558
+
5548
4559
  /**
5549
4560
  * Logger interface for observability
5550
4561
  *
@@ -5570,6 +4581,36 @@ interface Logger {
5570
4581
  error(message: string, meta?: any): void;
5571
4582
  child(meta: Record<string, any>): Logger;
5572
4583
  }
4584
+ /**
4585
+ * Serialize an error value into a form that JSON.stringify can handle
4586
+ * meaningfully.
4587
+ *
4588
+ * Winston's default JSON formatter serializes `Error` instances as `{}`
4589
+ * because `message`, `stack`, and `name` are non-enumerable properties on
4590
+ * the Error prototype. That means `logger.error('x', { error })` with a
4591
+ * raw Error argument produces useless log lines like
4592
+ * `{"error":{},"message":"x",...}`, throwing away the information you
4593
+ * actually need to diagnose the failure.
4594
+ *
4595
+ * This helper extracts the parts you want to see in a log — name,
4596
+ * message, stack, and cause — and leaves non-Error values alone (so
4597
+ * strings, numbers, and plain objects pass through unchanged).
4598
+ *
4599
+ * ## Usage
4600
+ *
4601
+ * ```ts
4602
+ * try {
4603
+ * await doSomething();
4604
+ * } catch (error) {
4605
+ * logger.error('Something failed', { error: errField(error) });
4606
+ * }
4607
+ * ```
4608
+ *
4609
+ * Use this at every `logger.error` call site that includes an `error`
4610
+ * field derived from a catch block. Raw `{ error }` without this helper
4611
+ * is almost always a bug.
4612
+ */
4613
+ declare function errField(error: unknown): unknown;
5573
4614
 
5574
4615
  /**
5575
4616
  * Annotation body utilities
@@ -5690,7 +4731,7 @@ interface CreateAnnotationInternal {
5690
4731
  id: string;
5691
4732
  motivation: Annotation['motivation'];
5692
4733
  target: Annotation['target'];
5693
- body: Annotation['body'];
4734
+ body?: Annotation['body'];
5694
4735
  creator: components['schemas']['Agent'];
5695
4736
  }
5696
4737
 
@@ -5854,7 +4895,7 @@ declare function userToAgent(user: {
5854
4895
  * @param did - DID:WEB identifier string
5855
4896
  * @returns Minimal W3C Agent object
5856
4897
  */
5857
- declare function didToAgent(did: string): Agent;
4898
+ declare function didToAgent(did: string | undefined | null): Agent;
5858
4899
 
5859
4900
  /**
5860
4901
  * TOML Config Loader
@@ -5990,4 +5031,4 @@ declare function getAllPlatformTypes(): PlatformType[];
5990
5031
  declare const CORE_TYPES_VERSION = "0.1.0";
5991
5032
  declare const SDK_VERSION = "0.1.0";
5992
5033
 
5993
- export { APIError, type AccessToken, type AnnotationCategory, type AnnotationId, type AnnotationUri, type AssembledAnnotation, type AuthCode, type BaseUrl, type BodyItem, type BodyItemIdentity, type BodyOperation, type Brand, type BurstBufferOptions, CORE_TYPES_VERSION, CREATION_METHODS, type CloneToken, ConfigurationError, ConflictError, type ContentFormat, type CreateAnnotationInternal, type CreationMethod, type Email, type EntityType, type EntityTypeStats, type Environment, EnvironmentConfig, type EventBase, EventBus, type EventInput, type EventMap, type EventMetadata, type EventName, type EventOfType, type EventQuery, type EventSignature, type GatheredContext, type GoogleAuthRequest, type GoogleCredential, type GraphConnection, type GraphPath, type JobId, type Logger, type MCPToken, type MarkProgress, type Motivation, NotFoundError, PERSISTED_EVENT_TYPES, type PersistedEvent, type PersistedEventType, type PlatformType, type RefreshToken, type ResourceAnnotationUri, type ResourceAnnotations, type ResourceFilter, type ResourceId, type ResourceUri, SDK_VERSION, STREAM_COMMAND_RESULT_TYPES, ScopedEventBus, ScriptError, type SearchQuery, type SelectionData, type Selector, SemiontError, type StoredEvent, type StoredEventLike, type ActorInferenceConfig as TomlActorInferenceConfig, type TomlFileReader, type InferenceConfig as TomlInferenceConfig, type WorkerInferenceConfig as TomlWorkerInferenceConfig, UnauthorizedError, type UpdateResourceInput, type UserDID, type UserId, ValidationError, type YieldProgress, accessToken, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, burstBuffer, cloneToken, type components, createTomlConfigLoader, didToAgent, email, entityType, findBodyItem, generateUuid, getAllPlatformTypes, getAnnotationUriFromEvent, getFragmentSelector, getSvgSelector, getTextPositionSelector, googleCredential, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceId, isStoredEvent, isString, isUndefined, isValidPlatformType, jobId, loadTomlConfig, mcpToken, type operations, parseEnvironment, type paths, refreshToken, resourceAnnotationUri, resourceId, resourceUri, searchQuery, userDID, userId, userToAgent, userToDid, validateEnvironment, validateSvgMarkup };
5034
+ export { APIError, type AccessToken, type AnnotationCategory, type AnnotationId, type AnnotationUri, type AssembledAnnotation, type AuthCode, type BaseUrl, type BodyItem, type BodyItemIdentity, type BodyOperation, type Brand, type BurstBufferOptions, CHANNEL_SCHEMAS, CORE_TYPES_VERSION, CREATION_METHODS, type CloneToken, ConfigurationError, ConflictError, type ContentFormat, type CreateAnnotationInternal, type CreationMethod, type Email, type EmittableChannel, type EntityType, type EntityTypeStats, type Environment, EnvironmentConfig, type EventBase, EventBus, type EventInput, type EventMap, type EventMetadata, type EventName, type EventOfType, type EventQuery, type EventSignature, type GatheredContext, type GoogleAuthRequest, type GoogleCredential, type GraphConnection, type GraphPath, type JobId, type Logger, type MCPToken, type Motivation, NotFoundError, PERSISTED_EVENT_TYPES, type PersistedEvent, type PersistedEventType, type PlatformType, RESOURCE_BROADCAST_TYPES, type RefreshToken, type ResourceAnnotationUri, type ResourceAnnotations, type ResourceBroadcastType, type ResourceFilter, type ResourceId, type ResourceUri, SDK_VERSION, ScopedEventBus, ScriptError, type SearchQuery, type SelectionData, type Selector, SemiontError, type StoredEvent, type StoredEventLike, type ActorInferenceConfig as TomlActorInferenceConfig, type TomlFileReader, type InferenceConfig as TomlInferenceConfig, type WorkerInferenceConfig as TomlWorkerInferenceConfig, UnauthorizedError, type UpdateResourceInput, type UserDID, type UserId, ValidationError, accessToken, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseUrl, burstBuffer, cloneToken, type components, createTomlConfigLoader, didToAgent, email, entityType, errField, findBodyItem, generateUuid, getAllPlatformTypes, getAnnotationUriFromEvent, getFragmentSelector, getSvgSelector, getTextPositionSelector, googleCredential, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceId, isStoredEvent, isString, isUndefined, isValidPlatformType, jobId, loadTomlConfig, mcpToken, type operations, parseEnvironment, type paths, refreshToken, resourceAnnotationUri, resourceId, resourceUri, searchQuery, serializePerKey, userDID, userId, userToAgent, userToDid, validateEnvironment, validateSvgMarkup };