@semiont/core 0.4.14 → 0.4.15

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
@@ -1479,7 +1479,7 @@ interface paths {
1479
1479
  patch?: never;
1480
1480
  trace?: never;
1481
1481
  };
1482
- "/resources/{id}/annotate-references-stream": {
1482
+ "/resources/{id}/annotate-references": {
1483
1483
  parameters: {
1484
1484
  query?: never;
1485
1485
  header?: never;
@@ -1538,7 +1538,7 @@ interface paths {
1538
1538
  patch?: never;
1539
1539
  trace?: never;
1540
1540
  };
1541
- "/resources/{id}/annotate-highlights-stream": {
1541
+ "/resources/{id}/annotate-highlights": {
1542
1542
  parameters: {
1543
1543
  query?: never;
1544
1544
  header?: never;
@@ -1597,7 +1597,7 @@ interface paths {
1597
1597
  patch?: never;
1598
1598
  trace?: never;
1599
1599
  };
1600
- "/resources/{id}/annotate-assessments-stream": {
1600
+ "/resources/{id}/annotate-assessments": {
1601
1601
  parameters: {
1602
1602
  query?: never;
1603
1603
  header?: never;
@@ -1656,7 +1656,7 @@ interface paths {
1656
1656
  patch?: never;
1657
1657
  trace?: never;
1658
1658
  };
1659
- "/resources/{id}/annotate-comments-stream": {
1659
+ "/resources/{id}/annotate-comments": {
1660
1660
  parameters: {
1661
1661
  query?: never;
1662
1662
  header?: never;
@@ -1715,7 +1715,7 @@ interface paths {
1715
1715
  patch?: never;
1716
1716
  trace?: never;
1717
1717
  };
1718
- "/resources/{id}/annotate-tags-stream": {
1718
+ "/resources/{id}/annotate-tags": {
1719
1719
  parameters: {
1720
1720
  query?: never;
1721
1721
  header?: never;
@@ -1833,7 +1833,7 @@ interface paths {
1833
1833
  patch?: never;
1834
1834
  trace?: never;
1835
1835
  };
1836
- "/resources/{id}/match-search-stream": {
1836
+ "/resources/{id}/match-search": {
1837
1837
  parameters: {
1838
1838
  query?: never;
1839
1839
  header?: never;
@@ -1843,8 +1843,8 @@ interface paths {
1843
1843
  get?: never;
1844
1844
  put?: never;
1845
1845
  /**
1846
- * Match Search (SSE Stream)
1847
- * @description Search for binding candidates for a reference annotation via Server-Sent Events. Delegates to the Matcher actor on the backend EventBus.
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
1848
  */
1849
1849
  post: {
1850
1850
  parameters: {
@@ -1858,25 +1858,20 @@ interface paths {
1858
1858
  };
1859
1859
  requestBody: {
1860
1860
  content: {
1861
- "application/json": components["schemas"]["MatchSearchStreamRequest"];
1861
+ "application/json": components["schemas"]["MatchSearchRequest"];
1862
1862
  };
1863
1863
  };
1864
1864
  responses: {
1865
- /** @description SSE stream opened successfully */
1866
- 200: {
1865
+ /** @description Search command accepted. Results delivered via events-stream. */
1866
+ 202: {
1867
1867
  headers: {
1868
1868
  [name: string]: unknown;
1869
1869
  };
1870
1870
  content: {
1871
- "text/event-stream": components["schemas"]["EventStreamResponse"];
1872
- };
1873
- };
1874
- /** @description referenceId and context are required */
1875
- 400: {
1876
- headers: {
1877
- [name: string]: unknown;
1871
+ "application/json": {
1872
+ correlationId: string;
1873
+ };
1878
1874
  };
1879
- content?: never;
1880
1875
  };
1881
1876
  /** @description Authentication required */
1882
1877
  401: {
@@ -1900,7 +1895,7 @@ interface paths {
1900
1895
  patch?: never;
1901
1896
  trace?: never;
1902
1897
  };
1903
- "/resources/{resourceId}/annotations/{annotationId}/gather-annotation-stream": {
1898
+ "/resources/{resourceId}/annotations/{annotationId}/gather": {
1904
1899
  parameters: {
1905
1900
  query?: never;
1906
1901
  header?: never;
@@ -1910,8 +1905,8 @@ interface paths {
1910
1905
  get?: never;
1911
1906
  put?: never;
1912
1907
  /**
1913
- * Gather Annotation LLM Context (SSE Stream)
1914
- * @description Stream real-time annotation LLM context gathering progress via Server-Sent Events
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.
1915
1910
  */
1916
1911
  post: {
1917
1912
  parameters: {
@@ -1925,81 +1920,21 @@ interface paths {
1925
1920
  };
1926
1921
  cookie?: never;
1927
1922
  };
1928
- requestBody?: {
1923
+ requestBody: {
1929
1924
  content: {
1930
1925
  "application/json": components["schemas"]["GatherAnnotationStreamRequest"];
1931
1926
  };
1932
1927
  };
1933
1928
  responses: {
1934
- /** @description SSE stream opened successfully */
1935
- 200: {
1936
- headers: {
1937
- [name: string]: unknown;
1938
- };
1939
- content: {
1940
- "text/event-stream": components["schemas"]["EventStreamResponse"];
1941
- };
1942
- };
1943
- /** @description Authentication required */
1944
- 401: {
1945
- headers: {
1946
- [name: string]: unknown;
1947
- };
1948
- content?: never;
1949
- };
1950
- /** @description Annotation not found */
1951
- 404: {
1952
- headers: {
1953
- [name: string]: unknown;
1954
- };
1955
- content?: never;
1956
- };
1957
- };
1958
- };
1959
- delete?: never;
1960
- options?: never;
1961
- head?: never;
1962
- patch?: never;
1963
- trace?: never;
1964
- };
1965
- "/resources/{resourceId}/annotations/{annotationId}/bind-stream": {
1966
- parameters: {
1967
- query?: never;
1968
- header?: never;
1969
- path?: never;
1970
- cookie?: never;
1971
- };
1972
- get?: never;
1973
- put?: never;
1974
- /**
1975
- * Bind Annotation Body (SSE Stream)
1976
- * @description Apply annotation body operations and stream completion via Server-Sent Events
1977
- */
1978
- post: {
1979
- parameters: {
1980
- query?: never;
1981
- header?: never;
1982
- path: {
1983
- /** @description Resource ID */
1984
- resourceId: string;
1985
- /** @description Annotation ID */
1986
- annotationId: string;
1987
- };
1988
- cookie?: never;
1989
- };
1990
- requestBody?: {
1991
- content: {
1992
- "application/json": components["schemas"]["BindAnnotationStreamRequest"];
1993
- };
1994
- };
1995
- responses: {
1996
- /** @description SSE stream opened successfully */
1997
- 200: {
1929
+ /** @description Gather command accepted. Results delivered via events-stream. */
1930
+ 202: {
1998
1931
  headers: {
1999
1932
  [name: string]: unknown;
2000
1933
  };
2001
1934
  content: {
2002
- "text/event-stream": components["schemas"]["EventStreamResponse"];
1935
+ "application/json": {
1936
+ correlationId: string;
1937
+ };
2003
1938
  };
2004
1939
  };
2005
1940
  /** @description Authentication required */
@@ -2009,13 +1944,6 @@ interface paths {
2009
1944
  };
2010
1945
  content?: never;
2011
1946
  };
2012
- /** @description Annotation not found */
2013
- 404: {
2014
- headers: {
2015
- [name: string]: unknown;
2016
- };
2017
- content?: never;
2018
- };
2019
1947
  };
2020
1948
  };
2021
1949
  delete?: never;
@@ -2477,7 +2405,7 @@ interface paths {
2477
2405
  patch?: never;
2478
2406
  trace?: never;
2479
2407
  };
2480
- "/resources/{resourceId}/annotations/{annotationId}/yield-resource-stream": {
2408
+ "/resources/{resourceId}/annotations/{annotationId}/yield-resource": {
2481
2409
  parameters: {
2482
2410
  query?: never;
2483
2411
  header?: never;
@@ -2487,35 +2415,45 @@ interface paths {
2487
2415
  get?: never;
2488
2416
  put?: never;
2489
2417
  /**
2490
- * Generate Resource (SSE Stream)
2491
- * @description Stream real-time resource generation progress via Server-Sent Events
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.
2492
2420
  */
2493
2421
  post: {
2494
2422
  parameters: {
2495
2423
  query?: never;
2496
2424
  header?: never;
2497
2425
  path: {
2498
- /** @description Resource ID */
2426
+ /** @description Source resource ID */
2499
2427
  resourceId: string;
2500
- /** @description Annotation ID */
2428
+ /** @description Reference annotation ID */
2501
2429
  annotationId: string;
2502
2430
  };
2503
2431
  cookie?: never;
2504
2432
  };
2505
- requestBody?: {
2433
+ requestBody: {
2506
2434
  content: {
2507
2435
  "application/json": components["schemas"]["YieldResourceStreamRequest"];
2508
2436
  };
2509
2437
  };
2510
2438
  responses: {
2511
- /** @description SSE stream opened successfully */
2512
- 200: {
2439
+ /** @description Generation command accepted. Progress and results delivered via events-stream. */
2440
+ 202: {
2513
2441
  headers: {
2514
2442
  [name: string]: unknown;
2515
2443
  };
2516
2444
  content: {
2517
- "text/event-stream": components["schemas"]["EventStreamResponse"];
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;
2518
2455
  };
2456
+ content?: never;
2519
2457
  };
2520
2458
  /** @description Authentication required */
2521
2459
  401: {
@@ -3106,7 +3044,10 @@ interface components {
3106
3044
  domain: string;
3107
3045
  isAdmin: boolean;
3108
3046
  };
3047
+ /** @description Short-lived access token (1 hour). Use as Authorization: Bearer header on API calls. */
3109
3048
  token: string;
3049
+ /** @description Long-lived refresh token (30 days). Exchange via POST /api/tokens/refresh for a fresh access token. */
3050
+ refreshToken: string;
3110
3051
  isNewUser: boolean;
3111
3052
  };
3112
3053
  BrowseFilesResponse: {
@@ -3200,6 +3141,13 @@ interface components {
3200
3141
  expiresAt: string;
3201
3142
  resource: components["schemas"]["ResourceDescriptor"];
3202
3143
  };
3144
+ /** @description Error response for failed bus commands. Replaces native Error objects on the EventBus so payloads are serializable and OpenAPI-typed. */
3145
+ CommandError: {
3146
+ /** @description Human-readable error message */
3147
+ message: string;
3148
+ /** @description Optional additional context (stack trace, field name, etc.) */
3149
+ details?: string;
3150
+ };
3203
3151
  /**
3204
3152
  * @description Content format as MIME type, optionally with charset parameter. Values include: text/plain, text/plain; charset=utf-8, text/plain; charset=iso-8859-1, text/markdown, text/markdown; charset=windows-1252, image/png, image/jpeg, application/pdf
3205
3153
  * @example text/plain; charset=utf-8
@@ -3342,6 +3290,336 @@ interface components {
3342
3290
  /** @description Array of body modification operations to apply */
3343
3291
  operations: (components["schemas"]["BodyOperationAdd"] | components["schemas"]["BodyOperationRemove"] | components["schemas"]["BodyOperationReplace"])[];
3344
3292
  };
3293
+ /** @description Progress payload emitted on gather:annotation-progress and gather:progress SSE channels during LLM context gathering. */
3294
+ GatherProgress: {
3295
+ message?: string;
3296
+ percentage?: number;
3297
+ };
3298
+ /** @description Completion payload emitted on gather:annotation-finished SSE channel. */
3299
+ GatherAnnotationFinished: {
3300
+ correlationId: string;
3301
+ annotationId: string;
3302
+ response: components["schemas"]["AnnotationLLMContextResponse"];
3303
+ };
3304
+ /** @description Completion payload emitted on gather:finished SSE channel for resource-level context gathering. */
3305
+ GatherFinished: {
3306
+ correlationId: string;
3307
+ resourceId: string;
3308
+ response: components["schemas"]["ResourceLLMContextResponse"];
3309
+ };
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
+ /** @description Search results payload emitted on match:search-results SSE channel. */
3368
+ MatchSearchResult: {
3369
+ correlationId: string;
3370
+ referenceId: string;
3371
+ response: (components["schemas"]["ResourceDescriptor"] & {
3372
+ /** @description Relevance score */
3373
+ score?: number;
3374
+ /** @description Human-readable reason for the match */
3375
+ matchReason?: string;
3376
+ })[];
3377
+ };
3378
+ /** @description Error payload emitted on match:search-failed SSE channel. */
3379
+ MatchSearchFailed: {
3380
+ correlationId: string;
3381
+ referenceId: string;
3382
+ error: string;
3383
+ };
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
+ /** @description Metadata added at persistence time. Part of every StoredEvent. */
3415
+ EventMetadata: {
3416
+ /** @description Monotonic position in the event log (ordering authority) */
3417
+ sequenceNumber: number;
3418
+ /** @description Byte offset in the JSONL file */
3419
+ streamPosition: number;
3420
+ /** @description SHA-256 of the previous event (hash chain) */
3421
+ prevEventHash?: string;
3422
+ /** @description SHA-256 of this event (integrity verification) */
3423
+ checksum?: string;
3424
+ /** @description Optional correlation id propagated from a command. Lets clients match command-result events back to the POST that initiated them. Set by EventStore.appendEvent's options when a route handler passes one through. */
3425
+ correlationId?: string;
3426
+ };
3427
+ /** @description Selection data for user-initiated annotations. Captures the text range and optional selector information from a user's highlight in the UI. */
3428
+ SelectionData: {
3429
+ /** @description The exact selected text */
3430
+ exact: string;
3431
+ /** @description Start character offset */
3432
+ start: number;
3433
+ /** @description End character offset */
3434
+ end: number;
3435
+ /** @description SVG selector for non-text selections (e.g. PDF regions) */
3436
+ svgSelector?: string;
3437
+ /** @description Fragment selector (e.g. page=2) */
3438
+ fragmentSelector?: string;
3439
+ /** @description Specification the fragment selector conforms to */
3440
+ conformsTo?: string;
3441
+ /** @description Text before the selection (for disambiguation) */
3442
+ prefix?: string;
3443
+ /** @description Text after the selection (for disambiguation) */
3444
+ suffix?: string;
3445
+ };
3446
+ /** @description A persisted domain event with metadata. Flat shape — event fields and metadata are peers. */
3447
+ StoredEventResponse: {
3448
+ /** @description Unique event ID (UUID) */
3449
+ id: string;
3450
+ /** @description Event type (flow verb name, e.g. mark:added) */
3451
+ type: string;
3452
+ /**
3453
+ * Format: date-time
3454
+ * @description When the event occurred
3455
+ */
3456
+ timestamp: string;
3457
+ /** @description DID of the user who triggered the event */
3458
+ userId: string;
3459
+ /** @description Resource this event affects (absent for system events) */
3460
+ resourceId?: string;
3461
+ /** @description Event schema version */
3462
+ version: number;
3463
+ /** @description Event-type-specific payload */
3464
+ payload: {
3465
+ [key: string]: unknown;
3466
+ };
3467
+ metadata: components["schemas"]["EventMetadata"];
3468
+ };
3469
+ /** @description Wire format emitted by GET /resources/:id/events/stream. Extends StoredEventResponse with optional enrichment fields populated from the materialized view at SSE-write time. Subscribers can read the enrichment fields directly to update local caches without an additional fetch. */
3470
+ EnrichedResourceEvent: components["schemas"]["StoredEventResponse"] & {
3471
+ /** @description Populated for events that mutate an annotation (mark:added, mark:body-updated, mark:removed). Carries the post-materialization annotation as it exists in the view, so subscribers can update local caches in-place without refetching. Absent for events that don't touch annotations. */
3472
+ annotation?: components["schemas"]["Annotation"];
3473
+ };
3474
+ /** @description Payload for yield:created domain event */
3475
+ ResourceCreatedPayload: {
3476
+ name: string;
3477
+ format: components["schemas"]["ContentFormat"];
3478
+ /** @description SHA-256 of content */
3479
+ contentChecksum: string;
3480
+ contentByteSize?: number;
3481
+ /** @enum {string} */
3482
+ creationMethod: "api" | "upload" | "ui" | "reference" | "cli" | "clone" | "generated";
3483
+ entityTypes?: string[];
3484
+ /** @description Working-tree URI (e.g. file://docs/overview.md) */
3485
+ storageUri?: string;
3486
+ language?: string;
3487
+ isDraft?: boolean;
3488
+ generatedFrom?: {
3489
+ resourceId: string;
3490
+ annotationId: string;
3491
+ };
3492
+ generationPrompt?: string;
3493
+ generator?: components["schemas"]["Agent"] | components["schemas"]["Agent"][];
3494
+ };
3495
+ /** @description Payload for yield:cloned domain event */
3496
+ ResourceClonedPayload: {
3497
+ name: string;
3498
+ format: components["schemas"]["ContentFormat"];
3499
+ contentChecksum: string;
3500
+ contentByteSize?: number;
3501
+ parentResourceId: string;
3502
+ /** @enum {string} */
3503
+ creationMethod: "api" | "upload" | "ui" | "reference" | "cli" | "clone" | "generated";
3504
+ entityTypes?: string[];
3505
+ language?: string;
3506
+ };
3507
+ /** @description Payload for yield:updated domain event */
3508
+ ResourceUpdatedPayload: {
3509
+ /** @description SHA-256 of new content */
3510
+ contentChecksum: string;
3511
+ contentByteSize?: number;
3512
+ };
3513
+ /** @description Payload for yield:moved domain event */
3514
+ ResourceMovedPayload: {
3515
+ /** @description Previous file:// URI */
3516
+ fromUri: string;
3517
+ /** @description New file:// URI */
3518
+ toUri: string;
3519
+ };
3520
+ /** @description Payload for mark:archived domain event */
3521
+ ResourceArchivedPayload: {
3522
+ reason?: string;
3523
+ };
3524
+ /** @description Payload for mark:unarchived domain event (empty payload) */
3525
+ ResourceUnarchivedPayload: Record<string, never>;
3526
+ /** @description Payload for yield:representation-added domain event */
3527
+ RepresentationAddedPayload: {
3528
+ representation: components["schemas"]["Representation"];
3529
+ };
3530
+ /** @description Payload for yield:representation-removed domain event */
3531
+ RepresentationRemovedPayload: {
3532
+ /** @description Checksum of the representation to remove */
3533
+ checksum: string;
3534
+ };
3535
+ /** @description Payload for mark:added domain event */
3536
+ AnnotationAddedPayload: {
3537
+ annotation: components["schemas"]["Annotation"];
3538
+ /** @description SHA-256 of resource content at annotation time */
3539
+ contentChecksum?: string;
3540
+ };
3541
+ /** @description Payload for mark:removed domain event */
3542
+ AnnotationRemovedPayload: {
3543
+ annotationId: string;
3544
+ };
3545
+ /** @description Payload for mark:body-updated domain event */
3546
+ AnnotationBodyUpdatedPayload: {
3547
+ annotationId: string;
3548
+ operations: (components["schemas"]["BodyOperationAdd"] | components["schemas"]["BodyOperationRemove"] | components["schemas"]["BodyOperationReplace"])[];
3549
+ };
3550
+ /** @description Payload for mark:entity-type-added domain event */
3551
+ EntityTypeAddedPayload: {
3552
+ entityType: string;
3553
+ };
3554
+ /** @description Payload for mark:entity-tag-added and mark:entity-tag-removed domain events */
3555
+ EntityTagChangedPayload: {
3556
+ entityType: string;
3557
+ };
3558
+ /**
3559
+ * @description Type of background job
3560
+ * @enum {string}
3561
+ */
3562
+ JobType: "reference-annotation" | "generation" | "highlight-annotation" | "assessment-annotation" | "comment-annotation" | "tag-annotation";
3563
+ /** @description Payload for job:started domain event */
3564
+ JobStartedPayload: {
3565
+ jobId: string;
3566
+ jobType: components["schemas"]["JobType"];
3567
+ totalSteps?: number;
3568
+ };
3569
+ /** @description Payload for job:progress domain event */
3570
+ JobProgressPayload: {
3571
+ jobId: string;
3572
+ jobType: components["schemas"]["JobType"];
3573
+ percentage: number;
3574
+ /** @description Human-readable current step */
3575
+ currentStep?: string;
3576
+ processedSteps?: number;
3577
+ totalSteps?: number;
3578
+ /** @description For detection: entities found so far */
3579
+ foundCount?: number;
3580
+ message?: string;
3581
+ /** @description Full progress object for extensibility */
3582
+ progress?: {
3583
+ [key: string]: unknown;
3584
+ };
3585
+ };
3586
+ /** @description Payload for job:completed domain event */
3587
+ JobCompletedPayload: {
3588
+ jobId: string;
3589
+ jobType: components["schemas"]["JobType"];
3590
+ totalSteps?: number;
3591
+ /** @description For detection: total entities found */
3592
+ foundCount?: number;
3593
+ /** @description For generation: ID of generated resource */
3594
+ resultResourceId?: string;
3595
+ /** @description For generation: URI of annotation that triggered generation */
3596
+ annotationUri?: string;
3597
+ message?: string;
3598
+ /** @description Full result object for extensibility */
3599
+ result?: {
3600
+ [key: string]: unknown;
3601
+ };
3602
+ };
3603
+ /** @description Payload for job:failed domain event */
3604
+ JobFailedPayload: {
3605
+ jobId: string;
3606
+ jobType: components["schemas"]["JobType"];
3607
+ error: string;
3608
+ details?: string;
3609
+ };
3610
+ /** @description Payload for embedding:computed domain event */
3611
+ EmbeddingComputedPayload: {
3612
+ annotationId?: string;
3613
+ chunkIndex: number;
3614
+ chunkText: string;
3615
+ embedding: number[];
3616
+ model: string;
3617
+ dimensions: number;
3618
+ };
3619
+ /** @description Payload for embedding:deleted domain event */
3620
+ EmbeddingDeletedPayload: {
3621
+ annotationId?: string;
3622
+ };
3345
3623
  AnnotateHighlightsStreamRequest: {
3346
3624
  /** @description Optional instructions to guide AI highlight annotation */
3347
3625
  instructions?: string;
@@ -3432,57 +3710,7 @@ interface components {
3432
3710
  storageUri: string;
3433
3711
  };
3434
3712
  GetAnnotationHistoryResponse: {
3435
- events: {
3436
- id: string;
3437
- type: string;
3438
- timestamp: string;
3439
- userId: string;
3440
- resourceId: string;
3441
- payload: {
3442
- name: string;
3443
- format: components["schemas"]["ContentFormat"];
3444
- contentChecksum: string;
3445
- /** @enum {string} */
3446
- creationMethod: "api" | "upload" | "ui" | "reference" | "clone" | "generated";
3447
- entityTypes?: string[];
3448
- metadata?: {
3449
- [key: string]: unknown;
3450
- };
3451
- } | {
3452
- name: string;
3453
- format: components["schemas"]["ContentFormat"];
3454
- contentChecksum: string;
3455
- parentResourceId: string;
3456
- /** @enum {string} */
3457
- creationMethod: "api" | "upload" | "ui" | "reference" | "clone" | "generated";
3458
- entityTypes?: string[];
3459
- metadata?: {
3460
- [key: string]: unknown;
3461
- };
3462
- } | {
3463
- reason?: string;
3464
- } | Record<string, never> | {
3465
- /** @description W3C Annotation (creator/created fields are optional in events - they're derived from event userId/timestamp) */
3466
- annotation: components["schemas"]["Annotation"];
3467
- } | {
3468
- /** @description Unified annotation ID */
3469
- annotationId: string;
3470
- } | {
3471
- /** @description Unified annotation ID */
3472
- annotationId: string;
3473
- /** @description For linking motivation */
3474
- targetResourceId: string;
3475
- } | {
3476
- entityType: string;
3477
- } | {
3478
- entityType: string;
3479
- };
3480
- metadata: {
3481
- sequenceNumber: number;
3482
- prevEventHash?: string;
3483
- checksum?: string;
3484
- };
3485
- }[];
3713
+ events: components["schemas"]["StoredEventResponse"][];
3486
3714
  total: number;
3487
3715
  annotationId: string;
3488
3716
  resourceId: string;
@@ -3503,21 +3731,7 @@ interface components {
3503
3731
  entityTypes: string[];
3504
3732
  };
3505
3733
  GetEventsResponse: {
3506
- events: {
3507
- event: {
3508
- id: string;
3509
- type: string;
3510
- timestamp: string;
3511
- userId: string;
3512
- resourceId: string;
3513
- payload?: unknown;
3514
- };
3515
- metadata: {
3516
- sequenceNumber: number;
3517
- prevEventHash?: string;
3518
- checksum?: string;
3519
- };
3520
- }[];
3734
+ events: components["schemas"]["StoredEventResponse"][];
3521
3735
  total: number;
3522
3736
  resourceId: string;
3523
3737
  };
@@ -3721,7 +3935,7 @@ interface components {
3721
3935
  * @description Application-specific: How this resource was created
3722
3936
  * @enum {string}
3723
3937
  */
3724
- creationMethod?: "api" | "upload" | "ui" | "reference" | "clone" | "generated";
3938
+ creationMethod?: "api" | "upload" | "ui" | "reference" | "cli" | "clone" | "generated";
3725
3939
  /** @description Application-specific: ID of annotation that triggered generation */
3726
3940
  sourceAnnotationId?: string;
3727
3941
  /** @description Application-specific: ID of source resource for clones/derivatives */
@@ -3886,39 +4100,272 @@ interface components {
3886
4100
  /** @description The validated JWT token string for the current session */
3887
4101
  token: string;
3888
4102
  };
3889
- SvgSelector: {
3890
- /** @enum {string} */
3891
- type: "SvgSelector";
3892
- /** @description SVG markup defining the region (must include xmlns attribute) */
3893
- value: string;
4103
+ /** @description Emitted when an annotation receives focus for beckoning */
4104
+ BeckonFocusEvent: {
4105
+ annotationId?: string;
4106
+ resourceId?: string;
3894
4107
  };
3895
- /** @description W3C Web Annotation FragmentSelector for media fragment identifiers (RFC 3778 for PDFs) */
3896
- FragmentSelector: {
3897
- /** @enum {string} */
3898
- type: "FragmentSelector";
3899
- /**
3900
- * @description Media fragment identifier (e.g., 'page=1&viewrect=100,200,50,30' for PDF)
3901
- * @example page=1&viewrect=100,200,50,30
3902
- */
3903
- value: string;
3904
- /**
3905
- * @description URI identifying the fragment syntax specification
3906
- * @example http://tools.ietf.org/rfc/rfc3778
3907
- */
3908
- conformsTo?: string;
4108
+ /** @description Emitted when an annotation is hovered over for beckoning */
4109
+ BeckonHoverEvent: {
4110
+ annotationId: string | null;
3909
4111
  };
3910
- /**
3911
- * @description W3C Web Annotation body purpose vocabulary - https://www.w3.org/TR/annotation-vocab/#motivation
4112
+ /** @description Emitted when a sparkle effect is triggered on an annotation */
4113
+ BeckonSparkleEvent: {
4114
+ annotationId: string;
4115
+ };
4116
+ /** @description Event payload emitted on the bind:body-updated bus channel after annotation bodies are modified. */
4117
+ BindBodyUpdated: {
4118
+ /** @description Branded AnnotationId of the annotation whose body was updated */
4119
+ annotationId: string;
4120
+ };
4121
+ /** @description Command payload sent on the bind:initiate bus channel to start a bind flow. */
4122
+ BindInitiateCommand: {
4123
+ /** @description Branded AnnotationId of the annotation being bound */
4124
+ annotationId: string;
4125
+ /** @description Branded ResourceId of the resource being bound to */
4126
+ resourceId: string;
4127
+ /** @description Default title for the bound annotation */
4128
+ defaultTitle: string;
4129
+ /** @description Entity types to associate with the annotation */
4130
+ entityTypes: string[];
4131
+ };
4132
+ /** @description Command payload sent on the bind:update-body bus channel to modify annotation bodies. */
4133
+ BindUpdateBodyCommand: {
4134
+ /** @description Client-supplied id used to match this command to its result event(s) on the events-stream. Generated by the route handler if absent. */
4135
+ correlationId: string;
4136
+ /** @description Branded AnnotationId of the annotation whose body is being updated */
4137
+ annotationId: string;
4138
+ /** @description Branded ResourceId of the resource the annotation belongs to */
4139
+ resourceId: string;
4140
+ /** @description Branded UserId of the user performing the update */
4141
+ userId?: string;
4142
+ /** @description List of body mutation operations to apply */
4143
+ operations: {
4144
+ /**
4145
+ * @description The type of body operation
4146
+ * @enum {string}
4147
+ */
4148
+ op: "add" | "remove" | "replace";
4149
+ /** @description Body item for add operations */
4150
+ item?: components["schemas"]["AnnotationBody"];
4151
+ /** @description Previous body item for replace operations */
4152
+ oldItem?: components["schemas"]["AnnotationBody"];
4153
+ /** @description Replacement body item for replace operations */
4154
+ newItem?: components["schemas"]["AnnotationBody"];
4155
+ }[];
4156
+ };
4157
+ /**
4158
+ * @description W3C Web Annotation body purpose vocabulary - https://www.w3.org/TR/annotation-vocab/#motivation
3912
4159
  * @enum {string}
3913
4160
  */
3914
4161
  BodyPurpose: "assessing" | "bookmarking" | "classifying" | "commenting" | "describing" | "editing" | "highlighting" | "identifying" | "linking" | "moderating" | "questioning" | "replying" | "tagging";
3915
- MediaTokenRequest: {
3916
- /** @description The resource ID to generate a media token for */
4162
+ /** @description Request to browse the history of an annotation */
4163
+ BrowseAnnotationHistoryRequest: {
4164
+ correlationId: string;
3917
4165
  resourceId: string;
4166
+ annotationId: string;
3918
4167
  };
3919
- MediaTokenResponse: {
3920
- /** @description Short-lived media token for use as ?token= query parameter on resource URLs */
3921
- token: string;
4168
+ /** @description Result of browsing annotation history */
4169
+ BrowseAnnotationHistoryResult: {
4170
+ correlationId: string;
4171
+ response: components["schemas"]["GetAnnotationHistoryResponse"];
4172
+ };
4173
+ /** @description Request to browse a single annotation */
4174
+ BrowseAnnotationRequest: {
4175
+ correlationId: string;
4176
+ resourceId: string;
4177
+ annotationId: string;
4178
+ };
4179
+ /** @description Result of browsing a single annotation */
4180
+ BrowseAnnotationResult: {
4181
+ correlationId: string;
4182
+ response: components["schemas"]["GetAnnotationResponse"];
4183
+ };
4184
+ /** @description Request to browse annotations for a resource */
4185
+ BrowseAnnotationsRequest: {
4186
+ correlationId: string;
4187
+ resourceId: string;
4188
+ };
4189
+ /** @description Result of browsing annotations for a resource */
4190
+ BrowseAnnotationsResult: {
4191
+ correlationId: string;
4192
+ response: components["schemas"]["GetAnnotationsResponse"];
4193
+ };
4194
+ /** @description Emitted when an annotation is clicked in the browse panel */
4195
+ BrowseClickEvent: {
4196
+ annotationId: string;
4197
+ motivation: components["schemas"]["Motivation"];
4198
+ };
4199
+ /** @description Request to browse a directory listing */
4200
+ BrowseDirectoryRequest: {
4201
+ correlationId: string;
4202
+ path: string;
4203
+ /** @enum {string} */
4204
+ sort?: "name" | "mtime" | "annotationCount";
4205
+ };
4206
+ /** @description Result of browsing a directory listing */
4207
+ BrowseDirectoryResult: {
4208
+ correlationId: string;
4209
+ response: {
4210
+ path: string;
4211
+ entries: components["schemas"]["DirectoryEntry"][];
4212
+ };
4213
+ };
4214
+ /** @description Emitted when an entity type is clicked in the browse panel */
4215
+ BrowseEntityTypeClickedEvent: {
4216
+ entityType: string;
4217
+ };
4218
+ /** @description Request to browse available entity types */
4219
+ BrowseEntityTypesRequest: {
4220
+ correlationId: string;
4221
+ };
4222
+ /** @description Result of browsing entity types */
4223
+ BrowseEntityTypesResult: {
4224
+ correlationId: string;
4225
+ response: components["schemas"]["GetEntityTypesResponse"];
4226
+ };
4227
+ /** @description Request to browse events for a resource */
4228
+ BrowseEventsRequest: {
4229
+ correlationId: string;
4230
+ resourceId: string;
4231
+ type?: string;
4232
+ userId?: string;
4233
+ limit?: number;
4234
+ };
4235
+ /** @description Result of browsing events for a resource */
4236
+ BrowseEventsResult: {
4237
+ correlationId: string;
4238
+ response: components["schemas"]["GetEventsResponse"];
4239
+ };
4240
+ /** @description Emitted when navigation to an external URL is requested */
4241
+ BrowseExternalNavigateEvent: {
4242
+ url: string;
4243
+ resourceId?: string;
4244
+ };
4245
+ /** @description Emitted when a link is clicked in the browse panel */
4246
+ BrowseLinkClickedEvent: {
4247
+ href: string;
4248
+ label?: string;
4249
+ };
4250
+ /** @description Emitted when a browse panel is opened */
4251
+ BrowsePanelOpenEvent: {
4252
+ panel: string;
4253
+ scrollToAnnotationId?: string;
4254
+ motivation?: string;
4255
+ };
4256
+ /** @description Emitted when a browse panel is toggled */
4257
+ BrowsePanelToggleEvent: {
4258
+ panel: string;
4259
+ };
4260
+ /** @description Request to browse annotations that reference a resource */
4261
+ BrowseReferencedByRequest: {
4262
+ correlationId: string;
4263
+ resourceId: string;
4264
+ motivation?: string;
4265
+ };
4266
+ /** @description Result of browsing annotations that reference a resource */
4267
+ BrowseReferencedByResult: {
4268
+ correlationId: string;
4269
+ response: components["schemas"]["GetReferencedByResponse"];
4270
+ };
4271
+ /** @description Emitted when navigation to a reference resource is requested */
4272
+ BrowseReferenceNavigateEvent: {
4273
+ resourceId: string;
4274
+ };
4275
+ /** @description Emitted when a resource is closed in the browse panel */
4276
+ BrowseResourceCloseEvent: {
4277
+ resourceId: string;
4278
+ };
4279
+ /** @description Emitted when resources are reordered in the browse panel */
4280
+ BrowseResourceReorderEvent: {
4281
+ oldIndex: number;
4282
+ newIndex: number;
4283
+ };
4284
+ /** @description Request to browse a single resource */
4285
+ BrowseResourceRequest: {
4286
+ correlationId: string;
4287
+ resourceId: string;
4288
+ };
4289
+ /** @description Result of browsing a single resource */
4290
+ BrowseResourceResult: {
4291
+ correlationId: string;
4292
+ response: components["schemas"]["GetResourceResponse"];
4293
+ };
4294
+ /** @description Request to browse resources with optional filtering and pagination */
4295
+ BrowseResourcesRequest: {
4296
+ correlationId: string;
4297
+ search?: string;
4298
+ archived?: boolean;
4299
+ entityType?: string;
4300
+ offset?: number;
4301
+ limit?: number;
4302
+ };
4303
+ /** @description Result of browsing resources */
4304
+ BrowseResourcesResult: {
4305
+ correlationId: string;
4306
+ response: components["schemas"]["ListResourcesResponse"];
4307
+ };
4308
+ /** @description Emitted when the browse panel requests a router navigation */
4309
+ BrowseRouterPushEvent: {
4310
+ path: string;
4311
+ reason?: string;
4312
+ };
4313
+ /** @description Command to store a computed embedding for a resource chunk */
4314
+ EmbeddingComputeCommand: {
4315
+ resourceId: string;
4316
+ annotationId?: string;
4317
+ chunkIndex: number;
4318
+ chunkText: string;
4319
+ embedding: number[];
4320
+ model: string;
4321
+ dimensions: number;
4322
+ };
4323
+ /** @description Command to delete embeddings for a resource or annotation */
4324
+ EmbeddingDeleteCommand: {
4325
+ resourceId: string;
4326
+ annotationId?: string;
4327
+ };
4328
+ /** @description W3C Web Annotation FragmentSelector for media fragment identifiers (RFC 3778 for PDFs) */
4329
+ FragmentSelector: {
4330
+ /** @enum {string} */
4331
+ type: "FragmentSelector";
4332
+ /**
4333
+ * @description Media fragment identifier (e.g., 'page=1&viewrect=100,200,50,30' for PDF)
4334
+ * @example page=1&viewrect=100,200,50,30
4335
+ */
4336
+ value: string;
4337
+ /**
4338
+ * @description URI identifying the fragment syntax specification
4339
+ * @example http://tools.ietf.org/rfc/rfc3778
4340
+ */
4341
+ conformsTo?: string;
4342
+ };
4343
+ /** @description Completion payload emitted on the gather:annotation-complete bus channel when annotation context gathering finishes. */
4344
+ GatherAnnotationComplete: {
4345
+ /** @description Client-generated correlation ID to thread the response back to the originating request */
4346
+ correlationId: string;
4347
+ /** @description Branded AnnotationId of the annotation whose context was gathered */
4348
+ annotationId: string;
4349
+ /** @description The gathered annotation context */
4350
+ response: components["schemas"]["AnnotationLLMContextResponse"];
4351
+ };
4352
+ /** @description Request payload sent on the gather:annotation-request bus channel to gather context for an annotation. */
4353
+ GatherAnnotationRequest: {
4354
+ /** @description Client-generated correlation ID to thread the response back to the originating request */
4355
+ correlationId: string;
4356
+ /** @description Branded AnnotationId of the annotation to gather context for */
4357
+ annotationId: string;
4358
+ /** @description Branded ResourceId of the resource the annotation belongs to */
4359
+ resourceId: string;
4360
+ /** @description Optional gathering configuration */
4361
+ options?: {
4362
+ /** @description Whether to include source context in the gathered result */
4363
+ includeSourceContext?: boolean;
4364
+ /** @description Whether to include target context in the gathered result */
4365
+ includeTargetContext?: boolean;
4366
+ /** @description Characters of surrounding text context to include */
4367
+ contextWindow?: number;
4368
+ };
3922
4369
  };
3923
4370
  /** @description Context gathered for an annotation. Includes source document excerpts, metadata, and graph-derived context. Used by both Find (bind) and Generate (yield) flows. */
3924
4371
  GatheredContext: {
@@ -3981,18 +4428,383 @@ interface components {
3981
4428
  similar: components["schemas"]["SemanticMatch"][];
3982
4429
  };
3983
4430
  };
3984
- MatchSearchStreamRequest: {
4431
+ /** @description Completion payload emitted on the gather:resource-complete bus channel when resource context gathering finishes. */
4432
+ GatherResourceComplete: {
3985
4433
  /** @description Client-generated correlation ID to thread the response back to the originating request */
4434
+ correlationId: string;
4435
+ /** @description Branded ResourceId of the resource whose context was gathered */
4436
+ resourceId: string;
4437
+ /** @description The gathered resource context */
4438
+ response: components["schemas"]["ResourceLLMContextResponse"];
4439
+ };
4440
+ /** @description Request payload sent on the gather:resource-request bus channel to gather context for a resource. */
4441
+ GatherResourceRequest: {
4442
+ /** @description Client-generated correlation ID to thread the response back to the originating request */
4443
+ correlationId: string;
4444
+ /** @description Branded ResourceId of the resource to gather context for */
4445
+ resourceId: string;
4446
+ /** @description Gathering configuration */
4447
+ options: {
4448
+ /** @description Depth of resource graph traversal */
4449
+ depth: number;
4450
+ /** @description Maximum number of related resources to include */
4451
+ maxResources: number;
4452
+ /** @description Whether to include resource content in the gathered result */
4453
+ includeContent: boolean;
4454
+ /** @description Whether to include resource summaries in the gathered result */
4455
+ includeSummary: boolean;
4456
+ };
4457
+ };
4458
+ /** @description Result of a completed assessment-annotation job. */
4459
+ JobAssessmentAnnotationResult: {
4460
+ assessmentsFound: number;
4461
+ assessmentsCreated: number;
4462
+ };
4463
+ /** @description Request to cancel a job */
4464
+ JobCancelRequest: {
4465
+ /** @enum {string} */
4466
+ jobType: "annotation" | "generation";
4467
+ };
4468
+ /** @description Result of a completed comment-annotation job. */
4469
+ JobCommentAnnotationResult: {
4470
+ commentsFound: number;
4471
+ commentsCreated: number;
4472
+ };
4473
+ /** @description Command to mark a job as complete */
4474
+ JobCompleteCommand: {
4475
+ resourceId: string;
4476
+ userId: string;
4477
+ jobId: string;
4478
+ jobType: components["schemas"]["JobType"];
4479
+ result?: components["schemas"]["JobResult"];
4480
+ };
4481
+ /** @description Command to mark a job as failed */
4482
+ JobFailCommand: {
4483
+ resourceId: string;
4484
+ userId: string;
4485
+ jobId: string;
4486
+ jobType: components["schemas"]["JobType"];
4487
+ error: string;
4488
+ };
4489
+ /** @description Result of a completed generation job. */
4490
+ JobGenerationResult: {
4491
+ /** @description ID of the generated resource */
4492
+ resourceId: string;
4493
+ /** @description Name of the generated resource */
4494
+ resourceName: string;
4495
+ };
4496
+ /** @description Result of a completed highlight-annotation job. */
4497
+ JobHighlightAnnotationResult: {
4498
+ highlightsFound: number;
4499
+ highlightsCreated: number;
4500
+ };
4501
+ /** @description Progress report from a running job. Common fields are stage/percentage/message; job-type-specific fields may also be present. */
4502
+ JobProgress: {
4503
+ /** @description Current processing stage */
4504
+ stage: string;
4505
+ /** @description Completion percentage (0-100) */
4506
+ percentage: number;
4507
+ /** @description Human-readable progress message */
4508
+ message: string;
4509
+ /** @description Total entity types to process (reference-annotation) */
4510
+ totalEntityTypes?: number;
4511
+ /** @description Entity types processed so far (reference-annotation) */
4512
+ processedEntityTypes?: number;
4513
+ /** @description Entities found so far (reference-annotation) */
4514
+ entitiesFound?: number;
4515
+ /** @description Annotations emitted so far (reference-annotation) */
4516
+ entitiesEmitted?: number;
4517
+ /** @description Entity type currently being processed */
4518
+ currentEntityType?: string;
4519
+ /** @description Categories processed (tag-annotation) */
4520
+ processedCategories?: number;
4521
+ /** @description Total categories (tag-annotation) */
4522
+ totalCategories?: number;
4523
+ /** @description Category currently being processed (tag-annotation) */
4524
+ currentCategory?: string;
4525
+ };
4526
+ /** @description Event indicating a job has been queued */
4527
+ JobQueuedEvent: {
4528
+ jobId: string;
4529
+ jobType: string;
4530
+ resourceId: string;
4531
+ };
4532
+ /** @description Result of a completed reference-annotation job. */
4533
+ JobReferenceAnnotationResult: {
4534
+ /** @description Total entities found */
4535
+ totalFound: number;
4536
+ /** @description Total annotations emitted */
4537
+ totalEmitted: number;
4538
+ /** @description Number of errors encountered */
4539
+ errors: number;
4540
+ };
4541
+ /** @description Command to report progress on a job */
4542
+ JobReportProgressCommand: {
4543
+ resourceId: string;
4544
+ userId: string;
4545
+ jobId: string;
4546
+ jobType: components["schemas"]["JobType"];
4547
+ percentage: number;
4548
+ progress?: components["schemas"]["JobProgress"];
4549
+ };
4550
+ /** @description Discriminated union of all job result types. */
4551
+ JobResult: components["schemas"]["JobGenerationResult"] | components["schemas"]["JobReferenceAnnotationResult"] | components["schemas"]["JobHighlightAnnotationResult"] | components["schemas"]["JobAssessmentAnnotationResult"] | components["schemas"]["JobCommentAnnotationResult"] | components["schemas"]["JobTagAnnotationResult"];
4552
+ /** @description Command to start a job */
4553
+ JobStartCommand: {
4554
+ resourceId: string;
4555
+ userId: string;
4556
+ jobId: string;
4557
+ jobType: components["schemas"]["JobType"];
4558
+ };
4559
+ /** @description Request to check the status of a job */
4560
+ JobStatusRequest: {
4561
+ correlationId: string;
4562
+ jobId: string;
4563
+ };
4564
+ /** @description Result of a job status request */
4565
+ JobStatusResult: {
4566
+ correlationId: string;
4567
+ response: components["schemas"]["JobStatusResponse"];
4568
+ };
4569
+ /** @description Result of a completed tag-annotation job. */
4570
+ JobTagAnnotationResult: {
4571
+ tagsFound: number;
4572
+ tagsCreated: number;
4573
+ /** @description Count of tags created per category */
4574
+ byCategory: {
4575
+ [key: string]: number;
4576
+ };
4577
+ };
4578
+ /** @description Bus command to add a new entity type tag. */
4579
+ MarkAddEntityTypeCommand: {
4580
+ tag: string;
4581
+ userId: string;
4582
+ };
4583
+ /** @description Bus command to archive a resource and optionally remove its file. */
4584
+ MarkArchiveCommand: {
4585
+ userId?: string;
4586
+ resourceId: string;
4587
+ storageUri?: string;
4588
+ keepFile?: boolean;
4589
+ noGit?: boolean;
4590
+ };
4591
+ /** @description Emitted when the user requests AI assistance for a mark */
4592
+ MarkAssistRequestEvent: {
4593
+ /** @description Client-supplied id used to match this command to its result event(s) on the events-stream. Generated by the route handler if absent. */
4594
+ correlationId?: string;
4595
+ motivation: components["schemas"]["Motivation"];
4596
+ options: {
4597
+ instructions?: string;
4598
+ /** @enum {string} */
4599
+ tone?: "scholarly" | "explanatory" | "conversational" | "technical" | "analytical" | "critical" | "balanced" | "constructive";
4600
+ density?: number;
4601
+ language?: string;
4602
+ entityTypes?: string[];
4603
+ includeDescriptiveReferences?: boolean;
4604
+ schemaId?: string;
4605
+ categories?: string[];
4606
+ };
4607
+ };
4608
+ /** @description Emitted when the mark click action changes */
4609
+ MarkClickChangedEvent: {
4610
+ action: string;
4611
+ };
4612
+ /** @description Bus command to create an annotation on a resource. */
4613
+ MarkCreateCommand: {
4614
+ annotation: components["schemas"]["Annotation"];
4615
+ userId: string;
4616
+ resourceId: string;
4617
+ };
4618
+ /** @description Success response after creating an annotation. */
4619
+ MarkCreateOk: {
4620
+ annotationId: string;
4621
+ };
4622
+ /** @description Bus command to delete an annotation. */
4623
+ MarkDeleteCommand: {
4624
+ annotationId: string;
4625
+ userId?: string;
4626
+ resourceId?: string;
4627
+ };
4628
+ /** @description Success response after deleting an annotation. */
4629
+ MarkDeleteOk: {
4630
+ annotationId: string;
4631
+ };
4632
+ /** @description Emitted when the user requests a new mark (annotation) on a resource */
4633
+ MarkRequestedEvent: {
4634
+ /** @description One or more W3C selectors */
4635
+ 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"])[];
4636
+ motivation: components["schemas"]["Motivation"];
4637
+ };
4638
+ /** @description Emitted when the active mark selection changes */
4639
+ MarkSelectionChangedEvent: {
4640
+ motivation: string | null;
4641
+ };
4642
+ /** @description Emitted when the mark shape changes */
4643
+ MarkShapeChangedEvent: {
4644
+ shape: string;
4645
+ };
4646
+ /** @description Emitted when a mark is submitted with its annotation body */
4647
+ MarkSubmitEvent: {
4648
+ motivation: components["schemas"]["Motivation"];
4649
+ /** @description One or more W3C selectors */
4650
+ 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"])[];
4651
+ body: components["schemas"]["AnnotationBody"][];
4652
+ };
4653
+ /** @description Bus command to unarchive a previously archived resource. */
4654
+ MarkUnarchiveCommand: {
4655
+ userId?: string;
4656
+ resourceId: string;
4657
+ storageUri?: string;
4658
+ };
4659
+ /** @description Bus command to update an annotation's body with patch operations. */
4660
+ MarkUpdateBodyCommand: {
4661
+ /** @description Correlation id threaded from the originating route through to event metadata. Lets the events-stream deliver matched results to the client that initiated the bind. */
3986
4662
  correlationId?: string;
4663
+ annotationId: string;
4664
+ userId: string;
4665
+ resourceId: string;
4666
+ operations: (components["schemas"]["BodyOperationAdd"] | components["schemas"]["BodyOperationRemove"] | components["schemas"]["BodyOperationReplace"])[];
4667
+ };
4668
+ /** @description Bus command to replace the entity types on a resource. */
4669
+ MarkUpdateEntityTypesCommand: {
4670
+ resourceId: string;
4671
+ userId: string;
4672
+ currentEntityTypes: string[];
4673
+ updatedEntityTypes: string[];
4674
+ };
4675
+ /** @description Request payload sent on the match:search-request bus channel to find candidate matches. */
4676
+ MatchSearchRequest: {
4677
+ /** @description Client-generated correlation ID to thread the response back to the originating request */
4678
+ correlationId: string;
4679
+ /** @description Resource ID the reference annotation belongs to. Used to scope result events on the EventBus so the events-stream delivers them to participants viewing this resource. */
4680
+ resourceId: string;
3987
4681
  /** @description Annotation ID of the reference to search candidates for */
3988
4682
  referenceId: string;
3989
4683
  /** @description Gathered context for the reference annotation */
3990
4684
  context: components["schemas"]["GatheredContext"];
3991
- /** @description Maximum number of candidate results to return (default: 10) */
4685
+ /** @description Maximum number of candidate results to return */
3992
4686
  limit?: number;
3993
- /** @description Enable semantic similarity scoring in addition to keyword matching (default: true) */
4687
+ /** @description Enable semantic similarity scoring in addition to keyword matching */
3994
4688
  useSemanticScoring?: boolean;
3995
4689
  };
4690
+ MediaTokenRequest: {
4691
+ /** @description The resource ID to generate a media token for */
4692
+ resourceId: string;
4693
+ };
4694
+ MediaTokenResponse: {
4695
+ /** @description Short-lived media token for use as ?token= query parameter on resource URLs */
4696
+ token: string;
4697
+ };
4698
+ /** @description Emitted when the hover delay setting changes */
4699
+ SettingsHoverDelayChangedEvent: {
4700
+ hoverDelayMs: number;
4701
+ };
4702
+ /** @description Emitted when the UI locale setting changes */
4703
+ SettingsLocaleChangedEvent: {
4704
+ locale: string;
4705
+ };
4706
+ /** @description Emitted when the UI theme setting changes */
4707
+ SettingsThemeChangedEvent: {
4708
+ /** @enum {string} */
4709
+ theme: "light" | "dark" | "system";
4710
+ };
4711
+ SvgSelector: {
4712
+ /** @enum {string} */
4713
+ type: "SvgSelector";
4714
+ /** @description SVG markup defining the region (must include xmlns attribute) */
4715
+ value: string;
4716
+ };
4717
+ /** @description Bus command to create a cloned resource from a clone token. */
4718
+ YieldCloneCreateCommand: {
4719
+ correlationId: string;
4720
+ token: string;
4721
+ name: string;
4722
+ content: string;
4723
+ userId: string;
4724
+ archiveOriginal?: boolean;
4725
+ };
4726
+ /** @description Success response after creating a cloned resource. */
4727
+ YieldCloneCreated: {
4728
+ correlationId: string;
4729
+ response: {
4730
+ resourceId?: string;
4731
+ };
4732
+ };
4733
+ /** @description Bus command to request cloning a resource using a clone token. */
4734
+ YieldCloneResourceRequest: {
4735
+ correlationId: string;
4736
+ token: string;
4737
+ };
4738
+ /** @description Bus command to request a clone token for a resource. */
4739
+ YieldCloneTokenRequest: {
4740
+ correlationId: string;
4741
+ resourceId: string;
4742
+ };
4743
+ /** @description Bus command to create a yielded resource in the knowledge base. */
4744
+ YieldCreateCommand: {
4745
+ name: string;
4746
+ storageUri: string;
4747
+ contentChecksum: string;
4748
+ byteSize: number;
4749
+ format: components["schemas"]["ContentFormat"];
4750
+ userId: string;
4751
+ language?: string;
4752
+ entityTypes?: string[];
4753
+ creationMethod?: string;
4754
+ isDraft?: boolean;
4755
+ generatedFrom?: {
4756
+ resourceId?: string;
4757
+ annotationId?: string;
4758
+ };
4759
+ generationPrompt?: string;
4760
+ generator?: components["schemas"]["Agent"] | components["schemas"]["Agent"][];
4761
+ noGit?: boolean;
4762
+ };
4763
+ /** @description Success response after creating a yielded resource. */
4764
+ YieldCreateOk: {
4765
+ resourceId: string;
4766
+ resource: components["schemas"]["ResourceDescriptor"];
4767
+ };
4768
+ /** @description Success response after moving a yielded resource. */
4769
+ YieldMoveOk: {
4770
+ resourceId: string;
4771
+ };
4772
+ /** @description Bus command to move (rename) a yielded resource. */
4773
+ YieldMvCommand: {
4774
+ fromUri: string;
4775
+ toUri: string;
4776
+ userId: string;
4777
+ noGit?: boolean;
4778
+ };
4779
+ /** @description Bus command to request yield (generation) of a new resource from an annotation. */
4780
+ YieldRequestCommand: {
4781
+ /** @description Client-supplied id used to match this command to its result event(s) on the events-stream. Generated by the route handler if absent. */
4782
+ correlationId?: string;
4783
+ annotationId: string;
4784
+ resourceId: string;
4785
+ options: {
4786
+ title: string;
4787
+ prompt?: string;
4788
+ language?: string;
4789
+ temperature?: number;
4790
+ maxTokens?: number;
4791
+ context?: components["schemas"]["GatheredContext"];
4792
+ storageUri: string;
4793
+ };
4794
+ };
4795
+ /** @description Bus command to update a yielded resource's storage content. */
4796
+ YieldUpdateCommand: {
4797
+ resourceId: string;
4798
+ storageUri: string;
4799
+ contentChecksum: string;
4800
+ byteSize: number;
4801
+ userId: string;
4802
+ noGit?: boolean;
4803
+ };
4804
+ /** @description Success response after updating a yielded resource. */
4805
+ YieldUpdateOk: {
4806
+ resourceId: string;
4807
+ };
3996
4808
  };
3997
4809
  responses: never;
3998
4810
  parameters: never;
@@ -4009,8 +4821,8 @@ type operations = Record<string, never>;
4009
4821
  * different string types at compile time.
4010
4822
  */
4011
4823
 
4012
- type Motivation$2 = components['schemas']['Motivation'];
4013
- type ContentFormat$1 = components['schemas']['ContentFormat'];
4824
+ type Motivation = components['schemas']['Motivation'];
4825
+ type ContentFormat = components['schemas']['ContentFormat'];
4014
4826
  type Email = string & {
4015
4827
  readonly __brand: 'Email';
4016
4828
  };
@@ -4083,6 +4895,7 @@ declare const CREATION_METHODS: {
4083
4895
  readonly UPLOAD: "upload";
4084
4896
  readonly UI: "ui";
4085
4897
  readonly REFERENCE: "reference";
4898
+ readonly CLI: "cli";
4086
4899
  readonly CLONE: "clone";
4087
4900
  readonly GENERATED: "generated";
4088
4901
  };
@@ -4120,13 +4933,13 @@ declare function userId(id: string): UserId;
4120
4933
  */
4121
4934
 
4122
4935
  type ResourceDescriptor = components['schemas']['ResourceDescriptor'];
4123
- type Annotation$5 = components['schemas']['Annotation'];
4936
+ type Annotation$4 = components['schemas']['Annotation'];
4124
4937
  /**
4125
4938
  * Represents a connection between resources through annotations
4126
4939
  */
4127
4940
  interface GraphConnection {
4128
4941
  targetResource: ResourceDescriptor;
4129
- annotations: Annotation$5[];
4942
+ annotations: Annotation$4[];
4130
4943
  relationshipType?: string;
4131
4944
  bidirectional: boolean;
4132
4945
  }
@@ -4135,7 +4948,7 @@ interface GraphConnection {
4135
4948
  */
4136
4949
  interface GraphPath {
4137
4950
  resources: ResourceDescriptor[];
4138
- annotations: Annotation$5[];
4951
+ annotations: Annotation$4[];
4139
4952
  }
4140
4953
  /**
4141
4954
  * Statistics about entity types in the graph
@@ -4146,282 +4959,125 @@ interface EntityTypeStats {
4146
4959
  }
4147
4960
 
4148
4961
  /**
4149
- * Resource Event Types
4962
+ * Persisted Events
4963
+ *
4964
+ * The 20 event types that get appended to the JSONL event log.
4965
+ * Each maps a type string to its OpenAPI payload schema.
4966
+ * The PersistedEvent union derives from this catalog.
4967
+ */
4968
+
4969
+ /**
4970
+ * Maps each persisted event type string to its OpenAPI payload schema.
4971
+ * Single source of truth for "what events get written to the log."
4972
+ */
4973
+ type PersistedEventCatalog = {
4974
+ 'yield:created': components['schemas']['ResourceCreatedPayload'];
4975
+ 'yield:cloned': components['schemas']['ResourceClonedPayload'];
4976
+ 'yield:updated': components['schemas']['ResourceUpdatedPayload'];
4977
+ 'yield:moved': components['schemas']['ResourceMovedPayload'];
4978
+ 'yield:representation-added': components['schemas']['RepresentationAddedPayload'];
4979
+ 'yield:representation-removed': components['schemas']['RepresentationRemovedPayload'];
4980
+ 'mark:added': components['schemas']['AnnotationAddedPayload'];
4981
+ 'mark:removed': components['schemas']['AnnotationRemovedPayload'];
4982
+ 'mark:body-updated': components['schemas']['AnnotationBodyUpdatedPayload'];
4983
+ 'mark:archived': components['schemas']['ResourceArchivedPayload'];
4984
+ 'mark:unarchived': components['schemas']['ResourceUnarchivedPayload'];
4985
+ 'mark:entity-tag-added': components['schemas']['EntityTagChangedPayload'];
4986
+ 'mark:entity-tag-removed': components['schemas']['EntityTagChangedPayload'];
4987
+ 'mark:entity-type-added': components['schemas']['EntityTypeAddedPayload'];
4988
+ 'job:started': components['schemas']['JobStartedPayload'];
4989
+ 'job:progress': components['schemas']['JobProgressPayload'];
4990
+ 'job:completed': components['schemas']['JobCompletedPayload'];
4991
+ 'job:failed': components['schemas']['JobFailedPayload'];
4992
+ 'embedding:computed': components['schemas']['EmbeddingComputedPayload'];
4993
+ 'embedding:deleted': components['schemas']['EmbeddingDeletedPayload'];
4994
+ };
4995
+ /** System event types — persisted events that have no resourceId. */
4996
+ type SystemEventType = 'mark:entity-type-added';
4997
+ /** Extract the concrete persisted event type for a given type string. */
4998
+ type EventOfType<K extends keyof PersistedEventCatalog> = K extends SystemEventType ? EventBase & {
4999
+ type: K;
5000
+ payload: PersistedEventCatalog[K];
5001
+ } : EventBase & {
5002
+ type: K;
5003
+ resourceId: ResourceId;
5004
+ payload: PersistedEventCatalog[K];
5005
+ };
5006
+ /** The union of all 20 persisted event types. Discriminated on `type`. */
5007
+ type PersistedEvent = {
5008
+ [K in keyof PersistedEventCatalog]: EventOfType<K>;
5009
+ }[keyof PersistedEventCatalog];
5010
+ type PersistedEventType = PersistedEvent['type'];
5011
+ /**
5012
+ * Runtime list of every persisted event type.
5013
+ *
5014
+ * Single source of truth for code that needs to enumerate event types at
5015
+ * runtime — most importantly the per-resource `events-stream` SSE route,
5016
+ * which subscribes to all of them. The exhaustiveness check below makes
5017
+ * it impossible to add a new member to `PersistedEventCatalog` without
5018
+ * also adding it here: forgetting fails to typecheck rather than silently
5019
+ * dropping the event from the events-stream.
5020
+ */
5021
+ declare const PERSISTED_EVENT_TYPES: readonly ["yield:created", "yield:cloned", "yield:updated", "yield:moved", "yield:representation-added", "yield:representation-removed", "mark:added", "mark:removed", "mark:body-updated", "mark:archived", "mark:unarchived", "mark:entity-tag-added", "mark:entity-tag-removed", "mark:entity-type-added", "job:started", "job:progress", "job:completed", "job:failed", "embedding:computed", "embedding:deleted"];
5022
+ /** Input type for appendEvent — PersistedEvent without id/timestamp (assigned at persistence time). */
5023
+ type EventInput = Omit<PersistedEvent, 'id' | 'timestamp'>;
5024
+
5025
+ /**
5026
+ * Event Base Types
4150
5027
  *
4151
- * Event-sourced architecture for resource state management
4152
- * Events are stored in an append-only log (JSONL format)
5028
+ * Core shapes for the event-sourced persistence model.
5029
+ * EventBase is the common shape for all domain events.
5030
+ * StoredEvent wraps an event with persistence metadata.
4153
5031
  *
4154
- * Federation-ready design:
4155
- * - resourceId uses content hashes (doc-sha256:...)
4156
- * - userId uses DID format (did:web:org.com:users:alice)
4157
- * - prevEventHash creates tamper-evident chains
4158
- * - Optional signatures for cross-org verification
5032
+ * These types are referenced by event-catalog.ts (domain events)
5033
+ * and bus-protocol.ts (the full EventMap).
4159
5034
  */
4160
5035
 
4161
- type Annotation$4 = components['schemas']['Annotation'];
4162
- type ContentFormat = components['schemas']['ContentFormat'];
4163
- type Motivation$1 = components['schemas']['Motivation'];
4164
- interface BaseEvent {
5036
+ /**
5037
+ * Narrow an OpenAPI-generated type by overriding specific fields with branded types.
5038
+ *
5039
+ * OpenAPI schemas use plain `string` for identifiers. TypeScript branded types
5040
+ * (ResourceId, AnnotationId, UserId, JobId) add compile-time safety. Brand<T, B>
5041
+ * takes the OpenAPI type T and replaces the fields listed in B with their branded
5042
+ * counterparts, preserving all other fields from the schema.
5043
+ *
5044
+ * @example
5045
+ * type MyCommand = Brand<components['schemas']['YieldCreateCommand'], { userId: UserId }>;
5046
+ * // Result: YieldCreateCommand with userId narrowed from string to UserId
5047
+ */
5048
+ type Brand<T, Overrides> = Omit<T, keyof Overrides> & Overrides;
5049
+ /** Fields common to ALL domain events (system and resource-scoped). */
5050
+ interface EventBase {
4165
5051
  id: string;
4166
5052
  timestamp: string;
4167
5053
  resourceId?: ResourceId;
4168
5054
  userId: UserId;
4169
5055
  version: number;
4170
5056
  }
4171
- interface ResourceCreatedEvent extends BaseEvent {
4172
- type: 'resource.created';
4173
- payload: {
4174
- name: string;
4175
- format: ContentFormat;
4176
- contentChecksum: string;
4177
- contentByteSize?: number;
4178
- creationMethod: CreationMethod;
4179
- entityTypes?: string[];
4180
- storageUri?: string;
4181
- language?: string;
4182
- isDraft?: boolean;
4183
- generatedFrom?: {
4184
- resourceId: string;
4185
- annotationId: string;
4186
- };
4187
- generationPrompt?: string;
4188
- generator?: components['schemas']['Agent'] | components['schemas']['Agent'][];
4189
- };
4190
- }
4191
- interface ResourceClonedEvent extends BaseEvent {
4192
- type: 'resource.cloned';
4193
- payload: {
4194
- name: string;
4195
- format: ContentFormat;
4196
- contentChecksum: string;
4197
- contentByteSize?: number;
4198
- parentResourceId: string;
4199
- creationMethod: CreationMethod;
4200
- entityTypes?: string[];
4201
- language?: string;
4202
- };
4203
- }
4204
- interface ResourceArchivedEvent extends BaseEvent {
4205
- type: 'resource.archived';
4206
- payload: {
4207
- reason?: string;
4208
- };
4209
- }
4210
- interface ResourceUnarchivedEvent extends BaseEvent {
4211
- type: 'resource.unarchived';
4212
- payload: Record<string, never>;
4213
- }
4214
- interface ResourceUpdatedEvent extends BaseEvent {
4215
- type: 'resource.updated';
4216
- resourceId: ResourceId;
4217
- payload: {
4218
- contentChecksum: string;
4219
- contentByteSize?: number;
4220
- };
4221
- }
4222
- interface ResourceMovedEvent extends BaseEvent {
4223
- type: 'resource.moved';
4224
- resourceId: ResourceId;
4225
- payload: {
4226
- fromUri: string;
4227
- toUri: string;
4228
- };
4229
- }
4230
- interface RepresentationAddedEvent extends BaseEvent {
4231
- type: 'representation.added';
4232
- resourceId: ResourceId;
4233
- payload: {
4234
- representation: {
4235
- '@id': string;
4236
- mediaType: string;
4237
- byteSize: number;
4238
- checksum: string;
4239
- created: string;
4240
- rel?: 'original' | 'thumbnail' | 'preview' | 'optimized' | 'derived' | 'other';
4241
- storageUri?: string;
4242
- filename?: string;
4243
- language?: string;
4244
- width?: number;
4245
- height?: number;
4246
- duration?: number;
4247
- };
4248
- };
4249
- }
4250
- interface RepresentationRemovedEvent extends BaseEvent {
4251
- type: 'representation.removed';
4252
- resourceId: ResourceId;
4253
- payload: {
4254
- checksum: string;
4255
- };
4256
- }
4257
- interface AnnotationAddedEvent extends BaseEvent {
4258
- type: 'annotation.added';
4259
- payload: {
4260
- annotation: Annotation$4;
4261
- contentChecksum?: string;
4262
- };
4263
- }
4264
- interface AnnotationRemovedEvent extends BaseEvent {
4265
- type: 'annotation.removed';
4266
- payload: {
4267
- annotationId: AnnotationId;
4268
- };
4269
- }
4270
- type BodyItem = {
4271
- type: 'TextualBody';
4272
- value: string;
4273
- purpose?: Motivation$1;
4274
- format?: string;
4275
- language?: string;
4276
- } | {
4277
- type: 'SpecificResource';
4278
- source: string;
4279
- purpose?: Motivation$1;
4280
- };
4281
- type BodyOperation = {
4282
- op: 'add';
4283
- item: BodyItem;
4284
- } | {
4285
- op: 'remove';
4286
- item: BodyItem;
4287
- } | {
4288
- op: 'replace';
4289
- oldItem: BodyItem;
4290
- newItem: BodyItem;
4291
- };
4292
- interface AnnotationBodyUpdatedEvent extends BaseEvent {
4293
- type: 'annotation.body.updated';
4294
- payload: {
4295
- annotationId: AnnotationId;
4296
- operations: BodyOperation[];
4297
- };
4298
- }
4299
- interface JobStartedEvent extends BaseEvent {
4300
- type: 'job.started';
4301
- resourceId: ResourceId;
4302
- payload: {
4303
- jobId: JobId;
4304
- jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';
4305
- totalSteps?: number;
4306
- };
4307
- }
4308
- interface JobProgressEvent extends BaseEvent {
4309
- type: 'job.progress';
4310
- resourceId: ResourceId;
4311
- payload: {
4312
- jobId: JobId;
4313
- jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';
4314
- percentage: number;
4315
- currentStep?: string;
4316
- processedSteps?: number;
4317
- totalSteps?: number;
4318
- foundCount?: number;
4319
- message?: string;
4320
- progress?: any;
4321
- };
4322
- }
4323
- interface JobCompletedEvent extends BaseEvent {
4324
- type: 'job.completed';
4325
- resourceId: ResourceId;
4326
- payload: {
4327
- jobId: JobId;
4328
- jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';
4329
- totalSteps?: number;
4330
- foundCount?: number;
4331
- resultResourceId?: ResourceId;
4332
- annotationUri?: AnnotationUri;
4333
- message?: string;
4334
- result?: any;
4335
- };
4336
- }
4337
- interface JobFailedEvent extends BaseEvent {
4338
- type: 'job.failed';
4339
- resourceId: ResourceId;
4340
- payload: {
4341
- jobId: JobId;
4342
- jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';
4343
- error: string;
4344
- details?: string;
4345
- };
4346
- }
4347
- interface EntityTagAddedEvent extends BaseEvent {
4348
- type: 'entitytag.added';
4349
- resourceId: ResourceId;
4350
- payload: {
4351
- entityType: string;
4352
- };
4353
- }
4354
- interface EntityTagRemovedEvent extends BaseEvent {
4355
- type: 'entitytag.removed';
4356
- resourceId: ResourceId;
4357
- payload: {
4358
- entityType: string;
4359
- };
4360
- }
4361
- interface EmbeddingComputedEvent extends BaseEvent {
4362
- type: 'embedding.computed';
4363
- resourceId: ResourceId;
4364
- payload: {
4365
- annotationId?: AnnotationId;
4366
- chunkIndex: number;
4367
- chunkText: string;
4368
- embedding: number[];
4369
- model: string;
4370
- dimensions: number;
4371
- };
4372
- }
4373
- interface EmbeddingDeletedEvent extends BaseEvent {
4374
- type: 'embedding.deleted';
4375
- resourceId: ResourceId;
4376
- payload: {
4377
- annotationId?: AnnotationId;
4378
- };
4379
- }
4380
- interface EntityTypeAddedEvent extends BaseEvent {
4381
- type: 'entitytype.added';
4382
- resourceId?: undefined;
4383
- payload: {
4384
- entityType: string;
4385
- };
4386
- }
4387
- type ResourceEvent = ResourceCreatedEvent | ResourceClonedEvent | ResourceUpdatedEvent | ResourceMovedEvent | ResourceArchivedEvent | ResourceUnarchivedEvent | RepresentationAddedEvent | RepresentationRemovedEvent | AnnotationAddedEvent | AnnotationRemovedEvent | AnnotationBodyUpdatedEvent | JobStartedEvent | JobProgressEvent | JobCompletedEvent | JobFailedEvent | EntityTagAddedEvent | EntityTagRemovedEvent | EntityTypeAddedEvent | EmbeddingComputedEvent | EmbeddingDeletedEvent;
4388
- type ResourceEventType = ResourceEvent['type'];
4389
- type SystemEvent = EntityTypeAddedEvent;
4390
- type ResourceScopedEvent = Exclude<ResourceEvent, SystemEvent>;
4391
- declare function isResourceEvent$1(event: any): event is ResourceEvent;
4392
- /**
4393
- * Type guard: Check if event is system-level (no resourceId)
4394
- * System events affect global state, not individual resources
4395
- */
4396
- declare function isSystemEvent(event: ResourceEvent): event is SystemEvent;
4397
- /**
4398
- * Type guard: Check if event is resource-scoped (has resourceId)
4399
- * Resource events affect a specific resource's state
4400
- */
4401
- declare function isResourceScopedEvent(event: ResourceEvent): event is ResourceScopedEvent;
4402
- declare function getEventType<T extends ResourceEvent>(event: ResourceEvent): T['type'];
4403
- interface EventMetadata {
4404
- sequenceNumber: number;
4405
- streamPosition: number;
4406
- timestamp: string;
4407
- prevEventHash?: string;
4408
- checksum?: string;
4409
- }
5057
+ /** Persistence metadata attached to every stored event. */
5058
+ type EventMetadata = components['schemas']['EventMetadata'];
5059
+ /** Optional cryptographic signature on a stored event. */
4410
5060
  interface EventSignature {
4411
5061
  algorithm: 'ed25519';
4412
5062
  publicKey: string;
4413
5063
  signature: string;
4414
5064
  keyId?: string;
4415
5065
  }
4416
- interface StoredEvent<T extends ResourceEvent = ResourceEvent> {
4417
- event: T;
5066
+ /**
5067
+ * A domain event with persistence metadata.
5068
+ * Flat intersection — no nesting (event.type, not event.event.type).
5069
+ */
5070
+ type StoredEvent<T extends EventBase = PersistedEvent> = T & {
4418
5071
  metadata: EventMetadata;
4419
5072
  signature?: EventSignature;
4420
- }
5073
+ };
5074
+ type BodyItem = components['schemas']['TextualBody'] | components['schemas']['SpecificResource'];
5075
+ type BodyOperation = components['schemas']['BodyOperationAdd'] | components['schemas']['BodyOperationRemove'] | components['schemas']['BodyOperationReplace'];
5076
+ type Annotation$3 = components['schemas']['Annotation'];
4421
5077
  interface EventQuery {
4422
5078
  resourceId?: ResourceId;
4423
5079
  userId?: string;
4424
- eventTypes?: ResourceEvent['type'][];
5080
+ eventTypes?: string[];
4425
5081
  fromTimestamp?: string;
4426
5082
  toTimestamp?: string;
4427
5083
  fromSequence?: number;
@@ -4429,768 +5085,302 @@ interface EventQuery {
4429
5085
  }
4430
5086
  interface ResourceAnnotations {
4431
5087
  resourceId: ResourceId;
4432
- annotations: Annotation$4[];
5088
+ annotations: Annotation$3[];
4433
5089
  version: number;
4434
5090
  updatedAt: string;
4435
5091
  }
4436
5092
 
4437
5093
  /**
4438
- * Event Type Guards and Extraction Utilities
5094
+ * Bus Protocol
4439
5095
  *
4440
- * Domain logic for working with resource events.
4441
- * No React dependencies - safe to use in any JavaScript environment.
4442
- */
4443
-
4444
- /**
4445
- * Minimal event shape accepted by event utility functions.
4446
- * Compatible with both the internal `StoredEvent` type and the OpenAPI-derived
4447
- * schema type (`GetEventsResponse['events'][number]`), which lacks `version`
4448
- * on the inner event.
4449
- */
4450
- interface StoredEventLike {
4451
- event: {
4452
- id: string;
4453
- type: string;
4454
- timestamp: string;
4455
- userId: string;
4456
- resourceId?: string;
4457
- payload?: unknown;
4458
- };
4459
- metadata: {
4460
- sequenceNumber: number;
4461
- prevEventHash?: string;
4462
- checksum?: string;
4463
- };
4464
- }
4465
- /**
4466
- * Extract annotation ID from event payload
4467
- * Returns null if event is not annotation-related
5096
+ * The complete EventMap for the RxJS EventBus. Every channel name and
5097
+ * its payload type is defined here domain events, commands, reads,
5098
+ * results, SSE stream payloads, and frontend UI events.
4468
5099
  *
4469
- * For annotation.added: extracts full URI from payload.annotation.id
4470
- * For annotation.removed/body.updated: constructs full URI from payload.annotationId (UUID) + resourceId
4471
- */
4472
- declare function getAnnotationUriFromEvent(event: StoredEventLike): AnnotationUri | null;
4473
- /**
4474
- * Check if an event is related to a specific annotation
4475
- */
4476
- declare function isEventRelatedToAnnotation(event: StoredEventLike, annotationUri: AnnotationUri): boolean;
4477
- /**
4478
- * Type guard to check if event is a resource event
4479
- */
4480
- declare function isResourceEvent(event: any): event is StoredEvent;
4481
-
4482
- /**
4483
- * Event Protocol Types
5100
+ * Command and result payloads use OpenAPI-generated types (plain strings
5101
+ * for identifiers). Branded type safety (ResourceId, UserId, etc.) is
5102
+ * enforced at function boundaries, not on bus payloads — callers use
5103
+ * factory functions (resourceId(), userId()) at the consume boundary.
4484
5104
  *
4485
- * Type definitions for the application's event-driven architecture.
4486
- * Single source of truth for all EventBus event types.
5105
+ * Domain events (StoredEvent<Interface>) retain branded types as they
5106
+ * are the system of record, not wire-format payloads.
5107
+ *
5108
+ * Organized by flow (verb), then by category within each flow.
4487
5109
  */
4488
5110
 
4489
5111
  type Selector = components['schemas']['TextPositionSelector'] | components['schemas']['TextQuoteSelector'] | components['schemas']['SvgSelector'] | components['schemas']['FragmentSelector'];
4490
5112
  type GatheredContext = components['schemas']['GatheredContext'];
4491
- type Annotation$3 = components['schemas']['Annotation'];
4492
- type Motivation = components['schemas']['Motivation'];
4493
- /**
4494
- * Progress state for resource yield workflow
4495
- */
4496
- interface YieldProgress {
4497
- status: 'started' | 'fetching' | 'generating' | 'creating' | 'complete' | 'error';
4498
- referenceId: string;
4499
- resourceName?: string;
4500
- resourceId?: string;
4501
- sourceResourceId?: string;
4502
- percentage: number;
4503
- message?: string;
4504
- }
4505
- /**
4506
- * Selection data for user-initiated annotations
4507
- */
4508
- interface SelectionData {
4509
- exact: string;
4510
- start: number;
4511
- end: number;
4512
- svgSelector?: string;
4513
- fragmentSelector?: string;
4514
- conformsTo?: string;
4515
- prefix?: string;
4516
- suffix?: string;
4517
- }
4518
- /**
4519
- * Progress state for mark workflows (manual and assisted)
4520
- *
4521
- * Unified progress interface supporting different annotation strategies:
4522
- * - Reference annotation: entity-type steps
4523
- * - Other motivations: percentage-based progress
4524
- */
4525
- interface MarkProgress {
4526
- status: string;
4527
- message?: string;
4528
- /** Reference annotation: currently scanning entity type */
4529
- currentEntityType?: string;
4530
- /** Reference annotation: completed entity types with counts (frontend-only) */
4531
- completedEntityTypes?: Array<{
4532
- entityType: string;
4533
- foundCount: number;
4534
- }>;
4535
- /** Percentage-based motivations (highlight, assessment, comment, tag) */
4536
- percentage?: number;
4537
- /** Category-based motivations (tag) */
4538
- currentCategory?: string;
4539
- processedCategories?: number;
4540
- totalCategories?: number;
4541
- /** Request parameters for display in progress UI (frontend-only, added by annotation-registry) */
4542
- requestParams?: Array<{
4543
- label: string;
4544
- value: string;
4545
- }>;
4546
- }
5113
+ type YieldProgress = components['schemas']['YieldProgress'];
5114
+ type MarkProgress = components['schemas']['MarkProgress'];
5115
+ type SelectionData = components['schemas']['SelectionData'];
4547
5116
  /**
4548
- * Unified event map for all application events
4549
- *
4550
- * Organized by workflow ("flows") and actor sections:
4551
- * 1. Yield Flow - Resource generation from references
4552
- * 2. Mark Flow - Manual + AI-assisted annotation (all motivations)
4553
- * 3. Bind Flow - Reference linking/resolution (search modal)
4554
- * 4. Matcher Flow - Candidate search for bind/link operations
4555
- * 5. Gather Flow - LLM context fetching from annotations
4556
- * 6. Browse Flow - Panel, sidebar, and application routing
4557
- * 7. Beckon Flow - Annotation hover/focus/sparkle coordination
5117
+ * The unified EventMap every channel on the EventBus.
4558
5118
  *
4559
- * Plus infrastructure events (domain events, SSE, resource operations, settings)
5119
+ * Convention:
5120
+ * - Domain events (past tense): StoredEvent<Interface> — branded types
5121
+ * - Commands/reads/results/UI: OpenAPI schema refs — plain strings
5122
+ * - void: UI-only signals with no payload
4560
5123
  */
4561
5124
  type EventMap = {
4562
- 'make-meaning:event': ResourceEvent;
4563
- 'yield:request': {
4564
- annotationId: AnnotationId;
4565
- resourceId: ResourceId;
4566
- options: {
4567
- title: string;
4568
- prompt?: string;
4569
- language?: string;
4570
- temperature?: number;
4571
- maxTokens?: number;
4572
- context: GatheredContext;
4573
- storageUri: string;
4574
- };
4575
- };
4576
- 'yield:progress': YieldProgress;
4577
- 'yield:finished': YieldProgress;
4578
- 'yield:failed': {
4579
- error?: Error | string;
4580
- status?: string;
4581
- referenceId?: string;
4582
- percentage?: number;
4583
- message?: string;
4584
- };
4585
- 'yield:representation-added': Extract<ResourceEvent, {
4586
- type: 'representation.added';
4587
- }>;
4588
- 'yield:representation-removed': Extract<ResourceEvent, {
4589
- type: 'representation.removed';
4590
- }>;
4591
- 'yield:create': {
4592
- name: string;
4593
- content?: Buffer;
4594
- storageUri?: string;
4595
- contentChecksum?: string;
4596
- format: components['schemas']['ContentFormat'];
4597
- userId: UserId;
4598
- language?: string;
4599
- entityTypes?: string[];
4600
- creationMethod?: CreationMethod;
4601
- isDraft?: boolean;
4602
- generatedFrom?: {
4603
- resourceId: string;
4604
- annotationId: string;
4605
- };
4606
- generationPrompt?: string;
4607
- generator?: components['schemas']['Agent'] | components['schemas']['Agent'][];
4608
- noGit?: boolean;
4609
- };
4610
- 'yield:created': {
4611
- resourceId: ResourceId;
4612
- resource: components['schemas']['ResourceDescriptor'];
4613
- };
4614
- 'yield:create-failed': {
4615
- error: Error;
4616
- };
4617
- 'yield:update': {
4618
- resourceId: ResourceId;
4619
- storageUri: string;
4620
- content?: Buffer;
4621
- contentChecksum: string;
4622
- userId: UserId;
4623
- noGit?: boolean;
4624
- };
4625
- 'yield:updated': {
4626
- resourceId: ResourceId;
4627
- };
4628
- 'yield:update-failed': {
4629
- resourceId: ResourceId;
4630
- error: Error;
4631
- };
4632
- 'yield:mv': {
4633
- fromUri: string;
4634
- toUri: string;
4635
- userId: UserId;
4636
- noGit?: boolean;
4637
- };
4638
- 'yield:moved': {
4639
- resourceId: ResourceId;
4640
- };
5125
+ 'yield:created': StoredEvent<EventOfType<'yield:created'>>;
5126
+ 'yield:cloned': StoredEvent<EventOfType<'yield:cloned'>>;
5127
+ 'yield:updated': StoredEvent<EventOfType<'yield:updated'>>;
5128
+ 'yield:moved': StoredEvent<EventOfType<'yield:moved'>>;
5129
+ 'yield:representation-added': StoredEvent<EventOfType<'yield:representation-added'>>;
5130
+ 'yield:representation-removed': StoredEvent<EventOfType<'yield:representation-removed'>>;
5131
+ 'yield:progress': components['schemas']['YieldProgress'];
5132
+ 'yield:finished': components['schemas']['YieldProgress'];
5133
+ 'yield:failed': components['schemas']['YieldStreamError'];
5134
+ 'yield:request': components['schemas']['YieldRequestCommand'];
5135
+ 'yield:create': components['schemas']['YieldCreateCommand'];
5136
+ 'yield:update': components['schemas']['YieldUpdateCommand'];
5137
+ 'yield:mv': components['schemas']['YieldMvCommand'];
5138
+ 'yield:clone': void;
5139
+ 'yield:clone-token-requested': components['schemas']['YieldCloneTokenRequest'];
5140
+ 'yield:clone-resource-requested': components['schemas']['YieldCloneResourceRequest'];
5141
+ 'yield:clone-create': components['schemas']['YieldCloneCreateCommand'];
5142
+ 'yield:create-ok': components['schemas']['YieldCreateOk'];
5143
+ 'yield:create-failed': components['schemas']['CommandError'];
5144
+ 'yield:update-ok': components['schemas']['YieldUpdateOk'];
5145
+ 'yield:update-failed': components['schemas']['YieldUpdateOk'] & components['schemas']['CommandError'];
5146
+ 'yield:move-ok': components['schemas']['YieldMoveOk'];
4641
5147
  'yield:move-failed': {
4642
5148
  fromUri: string;
4643
- error: Error;
4644
- };
4645
- 'yield:clone': void;
4646
- 'yield:clone-token-requested': {
4647
- correlationId: string;
4648
- resourceId: ResourceId;
4649
- };
5149
+ } & components['schemas']['CommandError'];
4650
5150
  'yield:clone-token-generated': {
4651
5151
  correlationId: string;
4652
5152
  response: components['schemas']['CloneResourceWithTokenResponse'];
4653
5153
  };
4654
5154
  'yield:clone-token-failed': {
4655
5155
  correlationId: string;
4656
- error: Error;
4657
- };
4658
- 'yield:clone-resource-requested': {
4659
- correlationId: string;
4660
- token: string;
4661
- };
5156
+ } & components['schemas']['CommandError'];
4662
5157
  'yield:clone-resource-result': {
4663
5158
  correlationId: string;
4664
5159
  response: components['schemas']['GetResourceByTokenResponse'];
4665
5160
  };
4666
5161
  'yield:clone-resource-failed': {
4667
5162
  correlationId: string;
4668
- error: Error;
4669
- };
4670
- 'yield:clone-create': {
4671
- correlationId: string;
4672
- token: string;
4673
- name: string;
4674
- content: string;
4675
- userId: UserId;
4676
- archiveOriginal?: boolean;
4677
- };
4678
- 'yield:clone-created': {
4679
- correlationId: string;
4680
- response: {
4681
- resourceId: ResourceId;
4682
- };
4683
- };
5163
+ } & components['schemas']['CommandError'];
5164
+ 'yield:clone-created': components['schemas']['YieldCloneCreated'];
4684
5165
  'yield:clone-create-failed': {
4685
5166
  correlationId: string;
4686
- error: Error;
4687
- };
4688
- 'mark:select-comment': SelectionData;
4689
- 'mark:select-tag': SelectionData;
4690
- 'mark:select-assessment': SelectionData;
4691
- 'mark:select-reference': SelectionData;
4692
- 'mark:requested': {
4693
- selector: Selector | Selector[];
4694
- motivation: Motivation;
4695
- };
5167
+ } & components['schemas']['CommandError'];
5168
+ 'mark:added': StoredEvent<EventOfType<'mark:added'>>;
5169
+ 'mark:removed': StoredEvent<EventOfType<'mark:removed'>>;
5170
+ 'mark:body-updated': StoredEvent<EventOfType<'mark:body-updated'>>;
5171
+ 'mark:entity-tag-added': StoredEvent<EventOfType<'mark:entity-tag-added'>>;
5172
+ 'mark:entity-tag-removed': StoredEvent<EventOfType<'mark:entity-tag-removed'>>;
5173
+ 'mark:entity-type-added': StoredEvent<EventOfType<'mark:entity-type-added'>>;
5174
+ 'mark:archived': StoredEvent<EventOfType<'mark:archived'>>;
5175
+ 'mark:unarchived': StoredEvent<EventOfType<'mark:unarchived'>>;
5176
+ 'mark:progress': components['schemas']['MarkProgress'];
5177
+ 'mark:assist-finished': components['schemas']['MarkAssistFinished'];
5178
+ 'mark:assist-failed': components['schemas']['MarkAssistFailed'];
5179
+ 'mark:create': components['schemas']['MarkCreateCommand'];
5180
+ 'mark:delete': components['schemas']['MarkDeleteCommand'];
5181
+ 'mark:update-body': components['schemas']['MarkUpdateBodyCommand'];
5182
+ 'mark:archive': components['schemas']['MarkArchiveCommand'];
5183
+ 'mark:unarchive': components['schemas']['MarkUnarchiveCommand'];
5184
+ 'mark:update-entity-types': components['schemas']['MarkUpdateEntityTypesCommand'];
5185
+ 'mark:add-entity-type': components['schemas']['MarkAddEntityTypeCommand'];
5186
+ 'mark:create-ok': components['schemas']['MarkCreateOk'];
5187
+ 'mark:create-failed': components['schemas']['CommandError'];
5188
+ 'mark:delete-ok': components['schemas']['MarkDeleteOk'];
5189
+ 'mark:delete-failed': components['schemas']['CommandError'];
5190
+ 'mark:body-update-failed': components['schemas']['CommandError'];
5191
+ 'mark:entity-type-add-failed': components['schemas']['CommandError'];
5192
+ 'mark:select-comment': components['schemas']['SelectionData'];
5193
+ 'mark:select-tag': components['schemas']['SelectionData'];
5194
+ 'mark:select-assessment': components['schemas']['SelectionData'];
5195
+ 'mark:select-reference': components['schemas']['SelectionData'];
5196
+ 'mark:requested': components['schemas']['MarkRequestedEvent'];
4696
5197
  'mark:cancel-pending': void;
4697
- 'mark:submit': {
4698
- motivation: Motivation;
4699
- selector: Selector | Selector[];
4700
- body: components['schemas']['AnnotationBody'][];
4701
- };
4702
- 'mark:create': {
4703
- annotation: Annotation$3;
4704
- userId: UserId;
4705
- resourceId: ResourceId;
4706
- };
4707
- 'mark:created': {
4708
- annotationId: AnnotationId;
4709
- };
4710
- 'mark:create-failed': {
4711
- error: Error;
4712
- };
4713
- 'mark:delete': {
4714
- annotationId: AnnotationId;
4715
- userId?: UserId;
4716
- resourceId?: ResourceId;
4717
- };
4718
- 'mark:deleted': {
4719
- annotationId: AnnotationId;
4720
- };
4721
- 'mark:delete-failed': {
4722
- error: Error;
4723
- };
4724
- 'mark:update-body': {
4725
- annotationId: AnnotationId;
4726
- userId: UserId;
4727
- resourceId: ResourceId;
4728
- operations: BodyOperation[];
4729
- };
4730
- 'mark:body-update-failed': {
4731
- error: Error;
4732
- };
4733
- 'mark:assist-request': {
4734
- motivation: Motivation;
4735
- options: {
4736
- instructions?: string;
4737
- tone?: 'scholarly' | 'explanatory' | 'conversational' | 'technical' | 'analytical' | 'critical' | 'balanced' | 'constructive';
4738
- density?: number;
4739
- language?: string;
4740
- entityTypes?: string[];
4741
- includeDescriptiveReferences?: boolean;
4742
- schemaId?: string;
4743
- categories?: string[];
4744
- };
4745
- };
4746
- 'mark:progress': MarkProgress & {
4747
- resourceId?: ResourceId;
4748
- };
4749
- 'mark:assist-finished': {
4750
- motivation?: Motivation;
4751
- resourceId?: ResourceId;
4752
- status?: string;
4753
- percentage?: number;
4754
- foundCount?: number;
4755
- createdCount?: number;
4756
- byCategory?: Record<string, number>;
4757
- message?: string;
4758
- progress?: MarkProgress;
4759
- };
4760
- 'mark:assist-failed': {
4761
- resourceId?: ResourceId;
4762
- message?: string;
4763
- };
5198
+ 'mark:submit': components['schemas']['MarkSubmitEvent'];
5199
+ 'mark:assist-request': components['schemas']['MarkAssistRequestEvent'];
4764
5200
  'mark:assist-cancelled': void;
4765
5201
  'mark:progress-dismiss': void;
4766
5202
  'mark:mode-toggled': void;
4767
- 'mark:selection-changed': {
4768
- motivation: string | null;
4769
- };
4770
- 'mark:click-changed': {
4771
- action: string;
4772
- };
4773
- 'mark:shape-changed': {
4774
- shape: string;
4775
- };
4776
- 'mark:added': Extract<ResourceEvent, {
4777
- type: 'annotation.added';
4778
- }>;
4779
- 'mark:removed': Extract<ResourceEvent, {
4780
- type: 'annotation.removed';
4781
- }>;
4782
- 'mark:body-updated': Extract<ResourceEvent, {
4783
- type: 'annotation.body.updated';
4784
- }>;
4785
- 'mark:entity-tag-added': Extract<ResourceEvent, {
4786
- type: 'entitytag.added';
4787
- }>;
4788
- 'mark:entity-tag-removed': Extract<ResourceEvent, {
4789
- type: 'entitytag.removed';
4790
- }>;
4791
- 'mark:update-entity-types': {
4792
- resourceId: ResourceId;
4793
- userId: UserId;
4794
- currentEntityTypes: string[];
4795
- updatedEntityTypes: string[];
4796
- };
4797
- 'mark:add-entity-type': {
4798
- tag: string;
4799
- userId: UserId;
4800
- };
4801
- 'mark:entity-type-added': {
4802
- tag: string;
4803
- };
4804
- 'mark:entity-type-add-failed': {
4805
- error: Error;
4806
- };
4807
- 'mark:archive': void | {
4808
- userId: UserId;
4809
- resourceId?: ResourceId;
4810
- storageUri?: string;
4811
- keepFile?: boolean;
4812
- noGit?: boolean;
4813
- };
4814
- 'mark:archived': Extract<ResourceEvent, {
4815
- type: 'resource.archived';
4816
- }>;
4817
- 'mark:unarchive': void | {
4818
- userId: UserId;
4819
- resourceId?: ResourceId;
4820
- storageUri?: string;
4821
- };
4822
- 'mark:unarchived': Extract<ResourceEvent, {
4823
- type: 'resource.unarchived';
4824
- }>;
4825
- 'bind:initiate': {
4826
- annotationId: AnnotationId;
4827
- resourceId: ResourceId;
4828
- defaultTitle: string;
4829
- entityTypes: string[];
4830
- };
4831
- 'bind:update-body': {
4832
- annotationId: AnnotationId;
4833
- resourceId: ResourceId;
4834
- userId?: UserId;
4835
- operations: Array<{
4836
- op: 'add' | 'remove' | 'replace';
4837
- item?: components['schemas']['AnnotationBody'];
4838
- oldItem?: components['schemas']['AnnotationBody'];
4839
- newItem?: components['schemas']['AnnotationBody'];
4840
- }>;
4841
- };
4842
- 'bind:body-updated': {
4843
- annotationId: AnnotationId;
4844
- };
4845
- 'bind:body-update-failed': {
4846
- error: Error;
4847
- };
4848
- 'bind:finished': {
4849
- annotationId: AnnotationId;
4850
- };
4851
- 'bind:failed': {
4852
- error: Error;
4853
- };
4854
- 'match:search-requested': {
4855
- correlationId: string;
4856
- referenceId: string;
4857
- context: GatheredContext;
4858
- limit?: number;
4859
- useSemanticScoring?: boolean;
4860
- };
4861
- 'match:search-results': {
4862
- correlationId: string;
4863
- referenceId: string;
4864
- response: Array<components['schemas']['ResourceDescriptor'] & {
4865
- score?: number;
4866
- matchReason?: string;
4867
- }>;
4868
- };
4869
- 'match:search-failed': {
4870
- correlationId: string;
4871
- referenceId: string;
4872
- error: string;
4873
- };
4874
- 'gather:requested': {
4875
- correlationId: string;
4876
- annotationId: AnnotationId;
4877
- resourceId: ResourceId;
4878
- options?: {
4879
- includeSourceContext?: boolean;
4880
- includeTargetContext?: boolean;
4881
- contextWindow?: number;
4882
- };
4883
- };
4884
- 'gather:complete': {
4885
- correlationId: string;
4886
- annotationId: AnnotationId;
4887
- response: components['schemas']['AnnotationLLMContextResponse'];
4888
- };
5203
+ 'mark:selection-changed': components['schemas']['MarkSelectionChangedEvent'];
5204
+ 'mark:click-changed': components['schemas']['MarkClickChangedEvent'];
5205
+ 'mark:shape-changed': components['schemas']['MarkShapeChangedEvent'];
5206
+ 'bind:initiate': components['schemas']['BindInitiateCommand'];
5207
+ 'bind:update-body': components['schemas']['BindUpdateBodyCommand'];
5208
+ 'bind:body-updated': components['schemas']['BindBodyUpdated'];
5209
+ 'bind:body-update-failed': components['schemas']['CommandError'];
5210
+ 'match:search-requested': components['schemas']['MatchSearchRequest'];
5211
+ 'match:search-results': components['schemas']['MatchSearchResult'];
5212
+ 'match:search-failed': components['schemas']['MatchSearchFailed'];
5213
+ 'gather:requested': components['schemas']['GatherAnnotationRequest'];
5214
+ 'gather:complete': components['schemas']['GatherAnnotationComplete'];
4889
5215
  'gather:failed': {
4890
5216
  correlationId: string;
4891
- annotationId: AnnotationId;
4892
- error: Error;
4893
- };
4894
- 'gather:annotation-progress': {
4895
- message?: string;
4896
- percentage?: number;
4897
- };
4898
- 'gather:annotation-finished': {
4899
- correlationId: string;
4900
- annotationId: AnnotationId;
4901
- response: components['schemas']['AnnotationLLMContextResponse'];
4902
- };
4903
- 'gather:resource-requested': {
4904
- correlationId: string;
4905
- resourceId: ResourceId;
4906
- options: {
4907
- depth: number;
4908
- maxResources: number;
4909
- includeContent: boolean;
4910
- includeSummary: boolean;
4911
- };
4912
- };
4913
- 'gather:resource-complete': {
4914
- correlationId: string;
4915
- resourceId: ResourceId;
4916
- response: components['schemas']['ResourceLLMContextResponse'];
4917
- };
5217
+ annotationId: string;
5218
+ } & components['schemas']['CommandError'];
5219
+ 'gather:resource-requested': components['schemas']['GatherResourceRequest'];
5220
+ 'gather:resource-complete': components['schemas']['GatherResourceComplete'];
4918
5221
  'gather:resource-failed': {
4919
5222
  correlationId: string;
4920
- resourceId: ResourceId;
4921
- error: Error;
4922
- };
4923
- 'gather:progress': {
4924
- message?: string;
4925
- percentage?: number;
4926
- };
4927
- 'gather:finished': {
4928
- correlationId: string;
4929
- resourceId: ResourceId;
4930
- response: components['schemas']['ResourceLLMContextResponse'];
4931
- };
4932
- 'browse:click': {
4933
- annotationId: string;
4934
- motivation: Motivation;
4935
- };
4936
- 'browse:panel-toggle': {
4937
- panel: string;
4938
- };
4939
- 'browse:panel-open': {
4940
- panel: string;
4941
- scrollToAnnotationId?: string;
4942
- motivation?: string;
4943
- };
4944
- 'browse:panel-close': void;
4945
- 'browse:sidebar-toggle': void;
4946
- 'browse:resource-close': {
4947
- resourceId: string;
4948
- };
4949
- 'browse:resource-reorder': {
4950
- oldIndex: number;
4951
- newIndex: number;
4952
- };
4953
- 'browse:link-clicked': {
4954
- href: string;
4955
- label?: string;
4956
- };
4957
- 'browse:router-push': {
4958
- path: string;
4959
- reason?: string;
4960
- };
4961
- 'browse:external-navigate': {
4962
- url: string;
4963
- resourceId?: string;
4964
- cancelFallback: () => void;
4965
- };
4966
- 'browse:reference-navigate': {
4967
5223
  resourceId: string;
4968
- };
4969
- 'browse:entity-type-clicked': {
4970
- entityType: string;
4971
- };
4972
- 'browse:resource-requested': {
4973
- correlationId: string;
4974
- resourceId: ResourceId;
4975
- };
4976
- 'browse:resource-result': {
4977
- correlationId: string;
4978
- response: components['schemas']['GetResourceResponse'];
4979
- };
5224
+ } & components['schemas']['CommandError'];
5225
+ 'gather:annotation-progress': components['schemas']['GatherProgress'];
5226
+ 'gather:annotation-finished': components['schemas']['GatherAnnotationFinished'];
5227
+ 'gather:progress': components['schemas']['GatherProgress'];
5228
+ 'gather:finished': components['schemas']['GatherFinished'];
5229
+ 'browse:resource-requested': components['schemas']['BrowseResourceRequest'];
5230
+ 'browse:resource-result': components['schemas']['BrowseResourceResult'];
4980
5231
  'browse:resource-failed': {
4981
5232
  correlationId: string;
4982
- error: Error;
4983
- };
4984
- 'browse:resources-requested': {
4985
- correlationId: string;
4986
- search?: string;
4987
- archived?: boolean;
4988
- entityType?: string;
4989
- offset?: number;
4990
- limit?: number;
4991
- };
4992
- 'browse:resources-result': {
4993
- correlationId: string;
4994
- response: components['schemas']['ListResourcesResponse'];
4995
- };
5233
+ } & components['schemas']['CommandError'];
5234
+ 'browse:resources-requested': components['schemas']['BrowseResourcesRequest'];
5235
+ 'browse:resources-result': components['schemas']['BrowseResourcesResult'];
4996
5236
  'browse:resources-failed': {
4997
5237
  correlationId: string;
4998
- error: Error;
4999
- };
5000
- 'browse:annotations-requested': {
5001
- correlationId: string;
5002
- resourceId: ResourceId;
5003
- };
5004
- 'browse:annotations-result': {
5005
- correlationId: string;
5006
- response: components['schemas']['GetAnnotationsResponse'];
5007
- };
5238
+ } & components['schemas']['CommandError'];
5239
+ 'browse:annotations-requested': components['schemas']['BrowseAnnotationsRequest'];
5240
+ 'browse:annotations-result': components['schemas']['BrowseAnnotationsResult'];
5008
5241
  'browse:annotations-failed': {
5009
5242
  correlationId: string;
5010
- error: Error;
5011
- };
5012
- 'browse:annotation-requested': {
5013
- correlationId: string;
5014
- resourceId: ResourceId;
5015
- annotationId: AnnotationId;
5016
- };
5017
- 'browse:annotation-result': {
5018
- correlationId: string;
5019
- response: components['schemas']['GetAnnotationResponse'];
5020
- };
5243
+ } & components['schemas']['CommandError'];
5244
+ 'browse:annotation-requested': components['schemas']['BrowseAnnotationRequest'];
5245
+ 'browse:annotation-result': components['schemas']['BrowseAnnotationResult'];
5021
5246
  'browse:annotation-failed': {
5022
5247
  correlationId: string;
5023
- error: Error;
5024
- };
5025
- 'browse:events-requested': {
5026
- correlationId: string;
5027
- resourceId: ResourceId;
5028
- type?: string;
5029
- userId?: string;
5030
- limit?: number;
5031
- };
5032
- 'browse:events-result': {
5033
- correlationId: string;
5034
- response: components['schemas']['GetEventsResponse'];
5035
- };
5248
+ } & components['schemas']['CommandError'];
5249
+ 'browse:events-requested': components['schemas']['BrowseEventsRequest'];
5250
+ 'browse:events-result': components['schemas']['BrowseEventsResult'];
5036
5251
  'browse:events-failed': {
5037
5252
  correlationId: string;
5038
- error: Error;
5039
- };
5040
- 'browse:annotation-history-requested': {
5041
- correlationId: string;
5042
- resourceId: ResourceId;
5043
- annotationId: AnnotationId;
5044
- };
5045
- 'browse:annotation-history-result': {
5046
- correlationId: string;
5047
- response: components['schemas']['GetAnnotationHistoryResponse'];
5048
- };
5253
+ } & components['schemas']['CommandError'];
5254
+ 'browse:annotation-history-requested': components['schemas']['BrowseAnnotationHistoryRequest'];
5255
+ 'browse:annotation-history-result': components['schemas']['BrowseAnnotationHistoryResult'];
5049
5256
  'browse:annotation-history-failed': {
5050
5257
  correlationId: string;
5051
- error: Error;
5052
- };
5053
- 'browse:referenced-by-requested': {
5054
- correlationId: string;
5055
- resourceId: ResourceId;
5056
- motivation?: string;
5057
- };
5058
- 'browse:referenced-by-result': {
5059
- correlationId: string;
5060
- response: components['schemas']['GetReferencedByResponse'];
5061
- };
5258
+ } & components['schemas']['CommandError'];
5259
+ 'browse:referenced-by-requested': components['schemas']['BrowseReferencedByRequest'];
5260
+ 'browse:referenced-by-result': components['schemas']['BrowseReferencedByResult'];
5062
5261
  'browse:referenced-by-failed': {
5063
5262
  correlationId: string;
5064
- error: Error;
5065
- };
5066
- 'browse:entity-types-requested': {
5067
- correlationId: string;
5068
- };
5069
- 'browse:entity-types-result': {
5070
- correlationId: string;
5071
- response: components['schemas']['GetEntityTypesResponse'];
5072
- };
5263
+ } & components['schemas']['CommandError'];
5264
+ 'browse:entity-types-requested': components['schemas']['BrowseEntityTypesRequest'];
5265
+ 'browse:entity-types-result': components['schemas']['BrowseEntityTypesResult'];
5073
5266
  'browse:entity-types-failed': {
5074
5267
  correlationId: string;
5075
- error: Error;
5076
- };
5077
- 'browse:directory-requested': {
5078
- correlationId: string;
5079
- path: string;
5080
- sort?: 'name' | 'mtime' | 'annotationCount';
5081
- };
5082
- 'browse:directory-result': {
5083
- correlationId: string;
5084
- response: {
5085
- path: string;
5086
- entries: components['schemas']['DirectoryEntry'][];
5087
- };
5088
- };
5268
+ } & components['schemas']['CommandError'];
5269
+ 'browse:directory-requested': components['schemas']['BrowseDirectoryRequest'];
5270
+ 'browse:directory-result': components['schemas']['BrowseDirectoryResult'];
5089
5271
  'browse:directory-failed': {
5090
5272
  correlationId: string;
5091
5273
  path: string;
5092
- error: Error;
5093
- };
5094
- 'beckon:hover': {
5095
- annotationId: string | null;
5096
- };
5097
- 'beckon:focus': {
5098
- annotationId?: string;
5099
- resourceId?: string;
5100
- };
5101
- 'beckon:sparkle': {
5102
- annotationId: string;
5103
- };
5104
- 'job:start': {
5105
- resourceId: ResourceId;
5106
- userId: UserId;
5107
- jobId: JobId;
5108
- jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';
5109
- };
5110
- 'job:report-progress': {
5111
- resourceId: ResourceId;
5112
- userId: UserId;
5113
- jobId: JobId;
5114
- jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';
5115
- percentage: number;
5116
- progress?: any;
5117
- };
5118
- 'job:complete': {
5119
- resourceId: ResourceId;
5120
- userId: UserId;
5121
- jobId: JobId;
5122
- jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';
5123
- result?: any;
5124
- };
5125
- 'job:fail': {
5126
- resourceId: ResourceId;
5127
- userId: UserId;
5128
- jobId: JobId;
5129
- jobType: 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';
5130
- error: string;
5131
- };
5132
- 'job:started': Extract<ResourceEvent, {
5133
- type: 'job.started';
5134
- }>;
5135
- 'job:progress': Extract<ResourceEvent, {
5136
- type: 'job.progress';
5137
- }>;
5138
- 'job:completed': Extract<ResourceEvent, {
5139
- type: 'job.completed';
5140
- }>;
5141
- 'job:failed': Extract<ResourceEvent, {
5142
- type: 'job.failed';
5143
- }>;
5144
- 'job:queued': {
5145
- jobId: string;
5146
- jobType: string;
5147
- resourceId: string;
5148
- };
5149
- 'job:cancel-requested': {
5150
- jobType: 'annotation' | 'generation';
5151
- };
5152
- 'job:status-requested': {
5153
- correlationId: string;
5154
- jobId: JobId;
5155
- };
5156
- 'job:status-result': {
5157
- correlationId: string;
5158
- response: components['schemas']['JobStatusResponse'];
5274
+ } & components['schemas']['CommandError'];
5275
+ 'browse:click': components['schemas']['BrowseClickEvent'];
5276
+ 'browse:panel-toggle': components['schemas']['BrowsePanelToggleEvent'];
5277
+ 'browse:panel-open': components['schemas']['BrowsePanelOpenEvent'];
5278
+ 'browse:panel-close': void;
5279
+ 'browse:sidebar-toggle': void;
5280
+ 'browse:resource-close': components['schemas']['BrowseResourceCloseEvent'];
5281
+ 'browse:resource-reorder': components['schemas']['BrowseResourceReorderEvent'];
5282
+ 'browse:link-clicked': components['schemas']['BrowseLinkClickedEvent'];
5283
+ 'browse:router-push': components['schemas']['BrowseRouterPushEvent'];
5284
+ 'browse:external-navigate': components['schemas']['BrowseExternalNavigateEvent'] & {
5285
+ cancelFallback: () => void;
5159
5286
  };
5287
+ 'browse:reference-navigate': components['schemas']['BrowseReferenceNavigateEvent'];
5288
+ 'browse:entity-type-clicked': components['schemas']['BrowseEntityTypeClickedEvent'];
5289
+ 'beckon:hover': components['schemas']['BeckonHoverEvent'];
5290
+ 'beckon:focus': components['schemas']['BeckonFocusEvent'];
5291
+ 'beckon:sparkle': components['schemas']['BeckonSparkleEvent'];
5292
+ 'job:started': StoredEvent<EventOfType<'job:started'>>;
5293
+ 'job:progress': StoredEvent<EventOfType<'job:progress'>>;
5294
+ 'job:completed': StoredEvent<EventOfType<'job:completed'>>;
5295
+ 'job:failed': StoredEvent<EventOfType<'job:failed'>>;
5296
+ 'job:start': components['schemas']['JobStartCommand'];
5297
+ 'job:report-progress': components['schemas']['JobReportProgressCommand'];
5298
+ 'job:complete': components['schemas']['JobCompleteCommand'];
5299
+ 'job:fail': components['schemas']['JobFailCommand'];
5300
+ 'job:queued': components['schemas']['JobQueuedEvent'];
5301
+ 'job:cancel-requested': components['schemas']['JobCancelRequest'];
5302
+ 'job:status-requested': components['schemas']['JobStatusRequest'];
5303
+ 'job:status-result': components['schemas']['JobStatusResult'];
5160
5304
  'job:status-failed': {
5161
5305
  correlationId: string;
5162
- error: Error;
5163
- };
5164
- 'settings:theme-changed': {
5165
- theme: 'light' | 'dark' | 'system';
5166
- };
5306
+ } & components['schemas']['CommandError'];
5307
+ 'embedding:compute': components['schemas']['EmbeddingComputeCommand'];
5308
+ 'embedding:delete': components['schemas']['EmbeddingDeleteCommand'];
5309
+ 'settings:theme-changed': components['schemas']['SettingsThemeChangedEvent'];
5167
5310
  'settings:line-numbers-toggled': void;
5168
- 'settings:locale-changed': {
5169
- locale: string;
5170
- };
5171
- 'settings:hover-delay-changed': {
5172
- hoverDelayMs: number;
5173
- };
5174
- 'embedding:computed': {
5175
- resourceId: ResourceId;
5176
- annotationId?: AnnotationId;
5177
- chunkIndex: number;
5178
- chunkText: string;
5179
- embedding: number[];
5180
- model: string;
5181
- dimensions: number;
5182
- };
5183
- 'embedding:deleted': {
5184
- resourceId: ResourceId;
5185
- annotationId?: AnnotationId;
5186
- };
5311
+ 'settings:locale-changed': components['schemas']['SettingsLocaleChangedEvent'];
5312
+ 'settings:hover-delay-changed': components['schemas']['SettingsHoverDelayChangedEvent'];
5187
5313
  'stream-connected': Record<string, never>;
5314
+ 'replay-window-exceeded': {
5315
+ resourceId?: string;
5316
+ lastEventId: number;
5317
+ missedCount: number;
5318
+ cap: number;
5319
+ message: string;
5320
+ };
5188
5321
  };
5322
+ /** Any valid channel name on the EventBus. */
5323
+ type EventName = keyof EventMap;
5189
5324
  /**
5190
- * Union type of all valid event names
5191
- * Use this to enforce compile-time checking of event names
5325
+ * Non-persisted event types that the per-resource events-stream should deliver
5326
+ * to all connected clients. These are ephemeral command-result and progress
5327
+ * events that don't go through EventStore.appendEvent but still need to reach
5328
+ * every participant viewing the resource for real-time collaboration.
5329
+ *
5330
+ * Actors (Binder, Gatherer, workers) publish these on the scoped EventBus
5331
+ * (`eventBus.scope(resourceId)`). The events-stream route subscribes to them
5332
+ * alongside the persisted event types.
5333
+ *
5334
+ * Unlike PERSISTED_EVENT_TYPES, there's no compile-time exhaustiveness check
5335
+ * here because these event types are a curated subset of EventMap — not every
5336
+ * non-persisted event should flow to all participants. Adding a new one is a
5337
+ * deliberate choice, not an automatic cascade.
5192
5338
  */
5193
- type EventName = keyof EventMap;
5339
+ 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"];
5340
+
5341
+ /**
5342
+ * Event Type Guards and Extraction Utilities
5343
+ *
5344
+ * Domain logic for working with resource events.
5345
+ * No React dependencies - safe to use in any JavaScript environment.
5346
+ */
5347
+
5348
+ /**
5349
+ * Minimal event shape accepted by event utility functions.
5350
+ * Compatible with both the internal `StoredEvent` type and the OpenAPI-derived
5351
+ * schema type (`GetEventsResponse['events'][number]`), which lacks `version`.
5352
+ *
5353
+ * Flat shape — event fields and metadata are peers (no `event` wrapper).
5354
+ */
5355
+ interface StoredEventLike {
5356
+ id: string;
5357
+ type: string;
5358
+ timestamp: string;
5359
+ userId: string;
5360
+ resourceId?: string;
5361
+ payload?: unknown;
5362
+ metadata: {
5363
+ sequenceNumber: number;
5364
+ prevEventHash?: string;
5365
+ checksum?: string;
5366
+ };
5367
+ }
5368
+ /**
5369
+ * Extract annotation ID from event payload
5370
+ * Returns null if event is not annotation-related
5371
+ *
5372
+ * For mark:added: extracts full URI from payload.annotation.id
5373
+ * For mark:removed/mark:body-updated: constructs full URI from payload.annotationId (UUID) + resourceId
5374
+ */
5375
+ declare function getAnnotationUriFromEvent(event: StoredEventLike): AnnotationUri | null;
5376
+ /**
5377
+ * Check if an event is related to a specific annotation
5378
+ */
5379
+ declare function isEventRelatedToAnnotation(event: StoredEventLike, annotationUri: AnnotationUri): boolean;
5380
+ /**
5381
+ * Type guard to check if an object is a StoredEvent (flat shape)
5382
+ */
5383
+ declare function isStoredEvent(event: any): event is StoredEvent;
5194
5384
 
5195
5385
  /**
5196
5386
  * RxJS-based Event Bus
@@ -5257,6 +5447,14 @@ declare class EventBus {
5257
5447
  * ```
5258
5448
  */
5259
5449
  get<K extends keyof EventMap>(eventName: K): Subject<EventMap[K]>;
5450
+ /**
5451
+ * Get the RxJS Subject for a domain event type (PersistedEventType).
5452
+ *
5453
+ * Domain event channels carry `StoredEvent`. This method avoids the need
5454
+ * for `as keyof EventMap` casts when subscribing to domain event channels
5455
+ * using runtime `PersistedEventType` strings.
5456
+ */
5457
+ getDomainEvent(eventType: PersistedEventType): Subject<StoredEvent>;
5260
5458
  /**
5261
5459
  * Destroy the event bus and complete all subjects
5262
5460
  *
@@ -5309,6 +5507,8 @@ declare class ScopedEventBus {
5309
5507
  * @returns The RxJS Subject for this scoped event
5310
5508
  */
5311
5509
  get<E extends keyof EventMap>(event: E): Subject<EventMap[E]>;
5510
+ /** Get the RxJS Subject for a domain event type on this scoped bus. */
5511
+ getDomainEvent(eventType: PersistedEventType): Subject<StoredEvent>;
5312
5512
  /**
5313
5513
  * Create a nested scope
5314
5514
  *
@@ -5795,4 +5995,4 @@ declare function getAllPlatformTypes(): PlatformType[];
5795
5995
  declare const CORE_TYPES_VERSION = "0.1.0";
5796
5996
  declare const SDK_VERSION = "0.1.0";
5797
5997
 
5798
- export { APIError, type AccessToken, type AnnotationAddedEvent, type AnnotationBodyUpdatedEvent, type AnnotationCategory, type AnnotationId, type AnnotationRemovedEvent, type AnnotationUri, type AssembledAnnotation, type AuthCode, type BaseEvent, type BaseUrl, type BodyItem, type BodyOperation, type BurstBufferOptions, CORE_TYPES_VERSION, CREATION_METHODS, type CloneToken, ConfigurationError, ConflictError, type ContentFormat$1 as ContentFormat, type CreateAnnotationInternal, type CreationMethod, type Email, type EmbeddingComputedEvent, type EmbeddingDeletedEvent, type EntityTagAddedEvent, type EntityTagRemovedEvent, type EntityType, type EntityTypeStats, type Environment, EnvironmentConfig, EventBus, type EventMap, type EventMetadata, type EventName, type EventQuery, type EventSignature, type GatheredContext, type GoogleAuthRequest, type GoogleCredential, type GraphConnection, type GraphPath, type JobCompletedEvent, type JobFailedEvent, type JobId, type JobProgressEvent, type JobStartedEvent, type Logger, type MCPToken, type MarkProgress, type Motivation$2 as Motivation, NotFoundError, type PlatformType, type RefreshToken, type RepresentationAddedEvent, type RepresentationRemovedEvent, type ResourceAnnotationUri, type ResourceAnnotations, type ResourceArchivedEvent, type ResourceClonedEvent, type ResourceCreatedEvent, type ResourceEvent, type ResourceEventType, type ResourceFilter, type ResourceId, type ResourceScopedEvent, type ResourceUnarchivedEvent, type ResourceUri, SDK_VERSION, ScopedEventBus, ScriptError, type SearchQuery, type SelectionData, type Selector, SemiontError, type StoredEvent, type StoredEventLike, type SystemEvent, 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, getEventType, getFragmentSelector, getSvgSelector, getTextPositionSelector, googleCredential, isAnnotationId, isArray, isBoolean, isDefined, isEventRelatedToAnnotation, isFunction, isNull, isNullish, isNumber, isObject, isResourceEvent$1 as isResourceEvent, isResourceId, isResourceScopedEvent, isResourceEvent as isStoredEvent, isString, isSystemEvent, isUndefined, isValidPlatformType, jobId, loadTomlConfig, mcpToken, type operations, parseEnvironment, type paths, refreshToken, resourceAnnotationUri, resourceId, resourceUri, searchQuery, userDID, userId, userToAgent, userToDid, validateEnvironment, validateSvgMarkup };
5998
+ export { APIError, type AccessToken, type AnnotationCategory, type AnnotationId, type AnnotationUri, type AssembledAnnotation, type AuthCode, type BaseUrl, type BodyItem, 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 };