@semiont/core 0.5.10 → 0.5.12

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/testing.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { Observable } from 'rxjs';
1
+ import { Observable, Subject, BehaviorSubject } from 'rxjs';
2
+ import * as fc from 'fast-check';
2
3
 
3
4
  /**
4
5
  * Marker for the state-unit pattern: a stateful, lifecycled object with an
@@ -92,5 +93,2917 @@ interface StateUnitAxiomSpec<T extends StateUnit> {
92
93
  */
93
94
  declare function assertStateUnitAxioms<T extends StateUnit>(spec: StateUnitAxiomSpec<T>): void;
94
95
 
95
- export { assertStateUnitAxioms, disposeProbe };
96
- export type { DisposeProbe, StateUnitAxiomSpec };
96
+ declare class SemiontError extends Error {
97
+ code: string;
98
+ details?: Record<string, unknown> | undefined;
99
+ constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
100
+ }
101
+
102
+ interface components {
103
+ schemas: {
104
+ AcceptTermsResponse: {
105
+ success: boolean;
106
+ message: string;
107
+ };
108
+ AdminUpdateUserResponse: {
109
+ success: boolean;
110
+ user: {
111
+ id: string;
112
+ email: string;
113
+ name: string | null;
114
+ image: string | null;
115
+ domain: string;
116
+ provider: string;
117
+ isAdmin: boolean;
118
+ isActive: boolean;
119
+ lastLogin: string | null;
120
+ created: string;
121
+ updatedAt: string;
122
+ };
123
+ };
124
+ AdminUsersListResponse: {
125
+ success: boolean;
126
+ users: {
127
+ id: string;
128
+ email: string;
129
+ name: string | null;
130
+ image: string | null;
131
+ domain: string;
132
+ provider: string;
133
+ isAdmin: boolean;
134
+ isActive: boolean;
135
+ lastLogin: string | null;
136
+ created: string;
137
+ updatedAt: string;
138
+ }[];
139
+ };
140
+ AdminUserStatsResponse: {
141
+ success: boolean;
142
+ stats: {
143
+ totalUsers: number;
144
+ activeUsers: number;
145
+ adminUsers: number;
146
+ regularUsers: number;
147
+ domainBreakdown: {
148
+ domain: string;
149
+ count: number;
150
+ }[];
151
+ recentSignups: {
152
+ id: string;
153
+ email: string;
154
+ name: string | null;
155
+ created: string;
156
+ }[];
157
+ };
158
+ };
159
+ /** @description Web Annotation / W3C PROV Agent. Discriminated by @type — Person, Organization, or Software. Each branch carries fields appropriate to its kind. Software peers are first-class participants, not a sub-class of Person. */
160
+ Agent: ({
161
+ /** @constant */
162
+ "@type": "Person";
163
+ /**
164
+ * Format: uri
165
+ * @description DID-shaped identifier (e.g. did:web:host:users:email%40host)
166
+ */
167
+ "@id"?: string;
168
+ /** @description Display name */
169
+ name: string;
170
+ nickname?: string;
171
+ email?: string;
172
+ email_sha1?: string;
173
+ homepage?: string;
174
+ } & {
175
+ [key: string]: unknown;
176
+ }) | ({
177
+ /** @constant */
178
+ "@type": "Organization";
179
+ /** Format: uri */
180
+ "@id"?: string;
181
+ name: string;
182
+ homepage?: string;
183
+ } & {
184
+ [key: string]: unknown;
185
+ }) | ({
186
+ /** @constant */
187
+ "@type": "Software";
188
+ /**
189
+ * Format: uri
190
+ * @description DID-shaped identifier (e.g. did:web:host:agents:provider:model)
191
+ */
192
+ "@id"?: string;
193
+ /** @description Stable human-friendly label. Not parsed; UI composes display from structured fields. */
194
+ name: string;
195
+ /** @description Inference provider (e.g. ollama, anthropic) */
196
+ provider?: string;
197
+ /** @description Model identifier (e.g. gemma2:27b, claude-3-5-sonnet) */
198
+ model?: string;
199
+ /** @description Inference parameters (temperature, maxTokens, systemPrompt, etc.). Runtime metadata, not part of identity. */
200
+ parameters?: {
201
+ [key: string]: unknown;
202
+ };
203
+ } & {
204
+ [key: string]: unknown;
205
+ });
206
+ Annotation: {
207
+ /**
208
+ * @description W3C Web Annotation JSON-LD context
209
+ * @default http://www.w3.org/ns/anno.jsonld
210
+ * @enum {string}
211
+ */
212
+ "@context": "http://www.w3.org/ns/anno.jsonld";
213
+ /**
214
+ * @description W3C Annotation type
215
+ * @default Annotation
216
+ * @enum {string}
217
+ */
218
+ type: "Annotation";
219
+ id: string;
220
+ motivation: components["schemas"]["Motivation"];
221
+ /** @description W3C Web Annotation target - can be a simple IRI string (entire resource) or an object with source and optional selector (fragment) */
222
+ target: string | components["schemas"]["AnnotationTarget"];
223
+ /** @description W3C Web Annotation body. Optional per the W3C spec — annotations whose motivation alone is meaningful (highlighting) legitimately omit it. Present values are either a single body or a non-empty array of bodies; the prior empty-array 'stub' branch has been removed (it was a naming lie shared between highlights and never-actually-emitted stub references, and the source of the #651 reference-annotation validator bug). */
224
+ body?: components["schemas"]["AnnotationBody"] | components["schemas"]["AnnotationBody"][];
225
+ /** @description Web Annotation creator — the entity that initiated the annotation. For human-driven work this is a Person; for autonomous-agent work this is a Software peer. */
226
+ creator?: components["schemas"]["Agent"];
227
+ created?: string;
228
+ modified?: string;
229
+ /** @description Web Annotation generator — the SoftwareAgent that produced the annotation, when software was involved. Absent for purely manual annotations. Single object is the common case; array supports pipelines that combine multiple software peers. */
230
+ generator?: components["schemas"]["Agent"] | components["schemas"]["Agent"][];
231
+ /** @description PROV-O wasAttributedTo — all parties responsible for this annotation. For human-prompted AI work this combines `creator` (the Person) and `generator` (the Software). For purely manual annotations it equals `[creator]`; for autonomous-agent work it equals `[generator]` (and `creator` may be the same Software). */
232
+ wasAttributedTo?: components["schemas"]["Agent"] | components["schemas"]["Agent"][];
233
+ };
234
+ /** @description Phase 2: Body can be TextualBody (for entity tags, descriptions) or SpecificResource (for links) */
235
+ AnnotationBody: components["schemas"]["TextualBody"] | components["schemas"]["SpecificResource"];
236
+ AnnotationContextResponse: {
237
+ annotation: components["schemas"]["Annotation"];
238
+ context: {
239
+ before?: string;
240
+ selected: string;
241
+ after?: string;
242
+ };
243
+ resource: components["schemas"]["ResourceDescriptor"];
244
+ };
245
+ /** @description W3C Web Annotation target object - source is required, selector is optional */
246
+ AnnotationTarget: {
247
+ /** @description IRI of the resource being annotated */
248
+ source: string;
249
+ /** @description Optional selector to identify a specific segment of the source resource */
250
+ 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"])[];
251
+ };
252
+ AuthResponse: {
253
+ success: boolean;
254
+ user: {
255
+ id: string;
256
+ email: string;
257
+ name: string | null;
258
+ image: string | null;
259
+ domain: string;
260
+ isAdmin: boolean;
261
+ };
262
+ /** @description Short-lived access token (1 hour). Use as Authorization: Bearer header on API calls. */
263
+ token: string;
264
+ /** @description Long-lived refresh token (30 days). Exchange via POST /api/tokens/refresh for a fresh access token. */
265
+ refreshToken: string;
266
+ isNewUser: boolean;
267
+ };
268
+ BrowseFilesResponse: {
269
+ /** @description The directory path that was listed, relative to project root */
270
+ path: string;
271
+ entries: components["schemas"]["DirectoryEntry"][];
272
+ };
273
+ /** @description Emit an event on the Semiont bus. Channel names come from bus-protocol.ts; payload shape is validated against the channel's registered schema (CHANNEL_SCHEMAS). An optional scope routes resource-scoped broadcasts (e.g. mark:added, job:complete) to per-resource subscribers via eventBus.scope(scope); leave it unset for unscoped/global events. */
274
+ BusEmitRequest: {
275
+ /** @description Channel name from bus-protocol.ts EventMap */
276
+ channel: string;
277
+ /** @description Channel-specific payload, validated against CHANNEL_SCHEMAS */
278
+ payload: {
279
+ [key: string]: unknown;
280
+ };
281
+ /** @description Optional resource scope for broadcast channels (e.g. resourceId). Publishers only — frontends must never set this. */
282
+ scope?: string;
283
+ };
284
+ /** @description User's cookie consent preferences. `necessary` is always true — necessary cookies cannot be disabled. Timestamps and version are stamped server-side. */
285
+ CookieConsent: {
286
+ /** @enum {boolean} */
287
+ necessary: true;
288
+ analytics: boolean;
289
+ marketing: boolean;
290
+ preferences: boolean;
291
+ /** Format: date-time */
292
+ timestamp: string;
293
+ version: string;
294
+ };
295
+ /** @description Request body for POST /api/cookies/consent. All four preference fields must be booleans; `necessary` must be true. */
296
+ CookieConsentRequest: {
297
+ /** @enum {boolean} */
298
+ necessary: true;
299
+ analytics: boolean;
300
+ marketing: boolean;
301
+ preferences: boolean;
302
+ };
303
+ /** @description Standard envelope for cookie consent endpoints. On success `success: true` and `consent` carries the current preferences; on error `success: false` and `error` carries a human-readable message. */
304
+ CookieConsentResponse: {
305
+ success: boolean;
306
+ consent?: components["schemas"]["CookieConsent"];
307
+ error?: string;
308
+ };
309
+ /** @description GDPR data export of a user's cookie-related data. The response is returned as a file download (Content-Disposition: attachment). */
310
+ CookieExportResponse: {
311
+ user: {
312
+ id: string;
313
+ email: string;
314
+ };
315
+ consent: components["schemas"]["CookieConsent"];
316
+ /** Format: date-time */
317
+ exportDate: string;
318
+ dataRetentionPolicy: string;
319
+ };
320
+ DirectoryEntry: components["schemas"]["FileEntry"] | components["schemas"]["DirEntry"];
321
+ FileEntry: {
322
+ /** @enum {string} */
323
+ type: "file";
324
+ /** @description Entry name (basename) */
325
+ name: string;
326
+ /** @description Path relative to project root */
327
+ path: string;
328
+ /** @description File size in bytes */
329
+ size: number;
330
+ /**
331
+ * Format: date-time
332
+ * @description Last modified time (ISO 8601)
333
+ */
334
+ mtime: string;
335
+ /** @description True if this file is a tracked resource in the Knowledge Base */
336
+ tracked: boolean;
337
+ /** @description Resource ID (only when tracked is true) */
338
+ resourceId?: string;
339
+ /** @description Entity types assigned to this resource (only when tracked is true) */
340
+ entityTypes?: string[];
341
+ /** @description Number of annotations on this resource (only when tracked is true) */
342
+ annotationCount?: number;
343
+ /** @description DID of the user who created the resource (only when tracked is true) */
344
+ creator?: string;
345
+ };
346
+ DirEntry: {
347
+ /** @enum {string} */
348
+ type: "dir";
349
+ /** @description Entry name (basename) */
350
+ name: string;
351
+ /** @description Path relative to project root */
352
+ path: string;
353
+ /**
354
+ * Format: date-time
355
+ * @description Last modified time (ISO 8601)
356
+ */
357
+ mtime: string;
358
+ };
359
+ BodyOperationAdd: {
360
+ /** @enum {string} */
361
+ op: "add";
362
+ item: components["schemas"]["TextualBody"] | components["schemas"]["SpecificResource"];
363
+ };
364
+ BodyOperationRemove: {
365
+ /** @enum {string} */
366
+ op: "remove";
367
+ item: components["schemas"]["TextualBody"] | components["schemas"]["SpecificResource"];
368
+ };
369
+ BodyOperationReplace: {
370
+ /** @enum {string} */
371
+ op: "replace";
372
+ oldItem: components["schemas"]["TextualBody"] | components["schemas"]["SpecificResource"];
373
+ newItem: components["schemas"]["TextualBody"] | components["schemas"]["SpecificResource"];
374
+ };
375
+ CloneResourceWithTokenResponse: {
376
+ /** @description Generated clone token */
377
+ token: string;
378
+ /** @description ISO 8601 timestamp when token expires */
379
+ expiresAt: string;
380
+ resource: components["schemas"]["ResourceDescriptor"];
381
+ };
382
+ /** @description Error response for failed bus commands. Replaces native Error objects on the EventBus so payloads are serializable and OpenAPI-typed. */
383
+ CommandError: {
384
+ /** @description Optional correlation id echoed from the originating command. When present, the failure event can be matched back to the specific command that failed. */
385
+ correlationId?: string;
386
+ /** @description Human-readable error message */
387
+ message: string;
388
+ /** @description Optional additional context (stack trace, field name, etc.) */
389
+ details?: string;
390
+ };
391
+ /**
392
+ * @description Content format as a MIME type, optionally with parameters. The base type (everything before the first ';') MUST be a SupportedMediaType; parameters such as charset are preserved as metadata. Semantic validation happens in code at the create/yield boundary — there is deliberately no pattern here, the vocabulary lives in SupportedMediaType. Examples: text/plain, text/plain; charset=iso-8859-1, text/markdown; charset=windows-1252, image/png, application/pdf
393
+ * @example text/plain; charset=utf-8
394
+ */
395
+ ContentFormat: string;
396
+ /**
397
+ * @description Base MIME types (no parameters) admitted by Semiont. Membership is the create/yield gate — every member is storable, nameable, and uploadable. What more the system can do with a type (render, annotate, extract text, author) is curated per type in @semiont/core's media-type registry, which is keyed by this enum.
398
+ * @enum {string}
399
+ */
400
+ SupportedMediaType: "text/plain" | "text/markdown" | "text/html" | "text/css" | "text/csv" | "text/xml" | "application/json" | "application/xml" | "application/yaml" | "application/x-yaml" | "application/pdf" | "application/msword" | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" | "application/vnd.ms-excel" | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | "application/vnd.ms-powerpoint" | "application/vnd.openxmlformats-officedocument.presentationml.presentation" | "application/zip" | "application/gzip" | "application/x-tar" | "application/x-7z-compressed" | "application/octet-stream" | "application/wasm" | "image/png" | "image/jpeg" | "image/gif" | "image/webp" | "image/svg+xml" | "image/bmp" | "image/tiff" | "image/x-icon" | "video/mp4" | "video/mpeg" | "video/webm" | "video/ogg" | "video/quicktime" | "video/x-msvideo" | "audio/mpeg" | "audio/wav" | "audio/ogg" | "audio/webm" | "audio/aac" | "audio/flac" | "text/javascript" | "application/javascript" | "text/x-typescript" | "application/typescript" | "text/x-python" | "text/x-java" | "text/x-c" | "text/x-c++" | "text/x-csharp" | "text/x-go" | "text/x-rust" | "text/x-ruby" | "text/x-php" | "text/x-swift" | "text/x-kotlin" | "text/x-shell" | "font/woff" | "font/woff2" | "font/ttf" | "font/otf";
401
+ ContextualSummaryResponse: {
402
+ summary: string;
403
+ relevantFields: {
404
+ [key: string]: unknown;
405
+ };
406
+ context: {
407
+ before?: string;
408
+ selected: string;
409
+ after?: string;
410
+ };
411
+ };
412
+ CreateAnnotationRequest: {
413
+ motivation: components["schemas"]["Motivation"];
414
+ target: components["schemas"]["AnnotationTarget"];
415
+ /** @description Optional body. Omit for annotations whose motivation alone is meaningful (highlighting) or whose user-supplied content is empty. Shape matches Annotation.body. */
416
+ body?: components["schemas"]["AnnotationBody"] | components["schemas"]["AnnotationBody"][];
417
+ };
418
+ /** @description Response body for POST /resources (202 Accepted). Resource creation is asynchronous — the backend writes content to disk, emits yield:create on the bus, and returns the newly-minted resourceId immediately. Consumers watch SSE domain events (yield:created) to observe the fully-persisted state. */
419
+ CreateResourceResponse: {
420
+ /** @description The id of the newly-created resource. Assigned by Stower when it persists yield:create. */
421
+ resourceId: string;
422
+ };
423
+ DeleteUserResponse: {
424
+ success: boolean;
425
+ message: string;
426
+ };
427
+ /** @description Progress payload emitted on the gather:annotation-progress SSE channel during LLM context gathering. */
428
+ GatherProgress: {
429
+ message?: string;
430
+ percentage?: number;
431
+ };
432
+ /** @description Search results payload emitted on match:search-results SSE channel. */
433
+ MatchSearchResult: {
434
+ correlationId: string;
435
+ referenceId: string;
436
+ response: (components["schemas"]["ResourceDescriptor"] & {
437
+ /** @description Relevance score */
438
+ score?: number;
439
+ /** @description Human-readable reason for the match */
440
+ matchReason?: string;
441
+ })[];
442
+ };
443
+ /** @description Error payload emitted on match:search-failed SSE channel. */
444
+ MatchSearchFailed: {
445
+ correlationId: string;
446
+ referenceId: string;
447
+ error: string;
448
+ };
449
+ /** @description Metadata added at persistence time. Part of every StoredEvent. Integrity is provided by git at the commit level (when gitSync is enabled), not by in-event metadata fields. */
450
+ EventMetadata: {
451
+ /** @description Monotonic position in the event log (ordering authority) */
452
+ sequenceNumber: number;
453
+ /** @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. */
454
+ correlationId?: string;
455
+ };
456
+ /** @description Selection data for user-initiated annotations. Captures the text range and optional selector information from a user's highlight in the UI. */
457
+ SelectionData: {
458
+ /** @description The exact selected text */
459
+ exact: string;
460
+ /** @description Start character offset */
461
+ start: number;
462
+ /** @description End character offset */
463
+ end: number;
464
+ /** @description SVG selector for non-text selections (e.g. PDF regions) */
465
+ svgSelector?: string;
466
+ /** @description Fragment selector (e.g. page=2) */
467
+ fragmentSelector?: string;
468
+ /** @description Specification the fragment selector conforms to */
469
+ conformsTo?: string;
470
+ /** @description Text before the selection (for disambiguation) */
471
+ prefix?: string;
472
+ /** @description Text after the selection (for disambiguation) */
473
+ suffix?: string;
474
+ };
475
+ /** @description A persisted domain event with metadata. Flat shape — event fields and metadata are peers. */
476
+ StoredEventResponse: {
477
+ /** @description Unique event ID (UUID) */
478
+ id: string;
479
+ /** @description Event type (flow verb name, e.g. mark:added) */
480
+ type: string;
481
+ /**
482
+ * Format: date-time
483
+ * @description When the event occurred
484
+ */
485
+ timestamp: string;
486
+ /** @description DID of the user who triggered the event */
487
+ userId: string;
488
+ /** @description Resource this event affects (absent for system events) */
489
+ resourceId?: string;
490
+ /** @description Event schema version */
491
+ version: number;
492
+ /** @description Event-type-specific payload */
493
+ payload: {
494
+ [key: string]: unknown;
495
+ };
496
+ metadata: components["schemas"]["EventMetadata"];
497
+ };
498
+ /** @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. */
499
+ EnrichedResourceEvent: components["schemas"]["StoredEventResponse"] & {
500
+ /** @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. */
501
+ annotation?: components["schemas"]["Annotation"];
502
+ };
503
+ /** @description Payload for yield:created domain event */
504
+ ResourceCreatedPayload: {
505
+ name: string;
506
+ format: components["schemas"]["ContentFormat"];
507
+ /** @description SHA-256 of content */
508
+ contentChecksum: string;
509
+ contentByteSize?: number;
510
+ entityTypes?: string[];
511
+ /** @description Working-tree URI (e.g. file://docs/overview.md) */
512
+ storageUri?: string;
513
+ language?: string;
514
+ isDraft?: boolean;
515
+ generatedFrom?: {
516
+ resourceId: string;
517
+ annotationId: string;
518
+ };
519
+ generationPrompt?: string;
520
+ generator?: components["schemas"]["Agent"] | components["schemas"]["Agent"][];
521
+ };
522
+ /** @description Payload for yield:cloned domain event */
523
+ ResourceClonedPayload: {
524
+ name: string;
525
+ format: components["schemas"]["ContentFormat"];
526
+ contentChecksum: string;
527
+ contentByteSize?: number;
528
+ parentResourceId: string;
529
+ entityTypes?: string[];
530
+ language?: string;
531
+ };
532
+ /** @description Payload for yield:updated domain event */
533
+ ResourceUpdatedPayload: {
534
+ /** @description SHA-256 of new content */
535
+ contentChecksum: string;
536
+ contentByteSize?: number;
537
+ };
538
+ /** @description Payload for yield:moved domain event */
539
+ ResourceMovedPayload: {
540
+ /** @description Previous file:// URI */
541
+ fromUri: string;
542
+ /** @description New file:// URI */
543
+ toUri: string;
544
+ };
545
+ /** @description Payload for mark:archived domain event */
546
+ ResourceArchivedPayload: {
547
+ reason?: string;
548
+ };
549
+ /** @description Payload for mark:unarchived domain event (empty payload) */
550
+ ResourceUnarchivedPayload: Record<string, never>;
551
+ /** @description Payload for yield:representation-added domain event */
552
+ RepresentationAddedPayload: {
553
+ representation: components["schemas"]["Representation"];
554
+ };
555
+ /** @description Payload for yield:representation-removed domain event */
556
+ RepresentationRemovedPayload: {
557
+ /** @description Checksum of the representation to remove */
558
+ checksum: string;
559
+ };
560
+ /** @description Payload for mark:added domain event */
561
+ AnnotationAddedPayload: {
562
+ annotation: components["schemas"]["Annotation"];
563
+ /** @description SHA-256 of resource content at annotation time */
564
+ contentChecksum?: string;
565
+ };
566
+ /** @description Payload for mark:removed domain event */
567
+ AnnotationRemovedPayload: {
568
+ annotationId: string;
569
+ };
570
+ /** @description Payload for mark:body-updated domain event */
571
+ AnnotationBodyUpdatedPayload: {
572
+ annotationId: string;
573
+ operations: (components["schemas"]["BodyOperationAdd"] | components["schemas"]["BodyOperationRemove"] | components["schemas"]["BodyOperationReplace"])[];
574
+ };
575
+ /** @description Payload for frame:entity-type-added domain event (system-level, no resourceId — fan-out is global) */
576
+ EntityTypeAddedPayload: {
577
+ entityType: string;
578
+ };
579
+ /** @description Payload for frame:tag-schema-added domain event (system-level, no resourceId — fan-out is global to the KB). */
580
+ TagSchemaAddedPayload: {
581
+ schema: components["schemas"]["TagSchema"];
582
+ };
583
+ /** @description Payload for mark:entity-tag-added and mark:entity-tag-removed domain events */
584
+ EntityTagChangedPayload: {
585
+ entityType: string;
586
+ };
587
+ /**
588
+ * @description Type of background job
589
+ * @enum {string}
590
+ */
591
+ JobType: "reference-annotation" | "generation" | "highlight-annotation" | "assessment-annotation" | "comment-annotation" | "tag-annotation";
592
+ /** @description Payload for job:started domain event */
593
+ JobStartedPayload: {
594
+ jobId: string;
595
+ jobType: components["schemas"]["JobType"];
596
+ /** @description Annotation this job is attached to, when applicable */
597
+ annotationId?: string;
598
+ totalSteps?: number;
599
+ };
600
+ /** @description Payload for job:progress domain event */
601
+ JobProgressPayload: {
602
+ jobId: string;
603
+ jobType: components["schemas"]["JobType"];
604
+ percentage: number;
605
+ /** @description Human-readable current step */
606
+ currentStep?: string;
607
+ processedSteps?: number;
608
+ totalSteps?: number;
609
+ /** @description For detection: entities found so far */
610
+ foundCount?: number;
611
+ message?: string;
612
+ /** @description Full progress object for extensibility */
613
+ progress?: {
614
+ [key: string]: unknown;
615
+ };
616
+ };
617
+ /** @description Payload for job:completed domain event */
618
+ JobCompletedPayload: {
619
+ jobId: string;
620
+ jobType: components["schemas"]["JobType"];
621
+ /** @description Annotation this job was attached to, when applicable */
622
+ annotationId?: string;
623
+ totalSteps?: number;
624
+ /** @description For detection: total entities found */
625
+ foundCount?: number;
626
+ /** @description For generation: ID of generated resource */
627
+ resultResourceId?: string;
628
+ /** @description For generation: URI of annotation that triggered generation */
629
+ annotationUri?: string;
630
+ message?: string;
631
+ /** @description Full result object for extensibility */
632
+ result?: {
633
+ [key: string]: unknown;
634
+ };
635
+ };
636
+ /** @description Payload for job:failed domain event */
637
+ JobFailedPayload: {
638
+ jobId: string;
639
+ jobType: components["schemas"]["JobType"];
640
+ /** @description Annotation this job was attached to, when applicable */
641
+ annotationId?: string;
642
+ error: string;
643
+ details?: string;
644
+ };
645
+ ErrorResponse: {
646
+ error: string;
647
+ code?: string;
648
+ details?: unknown;
649
+ };
650
+ EventStreamResponse: {
651
+ event: string;
652
+ data: string;
653
+ id?: string;
654
+ };
655
+ GetAnnotationHistoryResponse: {
656
+ events: components["schemas"]["StoredEventResponse"][];
657
+ total: number;
658
+ annotationId: string;
659
+ resourceId: string;
660
+ };
661
+ GetAnnotationResponse: {
662
+ annotation: components["schemas"]["Annotation"];
663
+ resource: components["schemas"]["ResourceDescriptor"] | null;
664
+ resolvedResource: components["schemas"]["ResourceDescriptor"] | null;
665
+ };
666
+ GetAnnotationsResponse: {
667
+ annotations: components["schemas"]["Annotation"][];
668
+ /** @description Total number of annotations */
669
+ total: number;
670
+ /** @description Motivation filter applied (if any) */
671
+ motivation?: components["schemas"]["Motivation"] | null;
672
+ };
673
+ GetEntityTypesResponse: {
674
+ entityTypes: string[];
675
+ };
676
+ GetEventsResponse: {
677
+ events: components["schemas"]["StoredEventResponse"][];
678
+ total: number;
679
+ resourceId: string;
680
+ };
681
+ GetReferencedByResponse: {
682
+ referencedBy: {
683
+ /** @description Reference annotation ID */
684
+ id: string;
685
+ /** @description Name of resource containing the reference */
686
+ resourceName: string;
687
+ target: {
688
+ /** @description ID of resource containing the reference */
689
+ source: string;
690
+ selector: {
691
+ /** @description The selected text that references this resource */
692
+ exact: string;
693
+ };
694
+ };
695
+ }[];
696
+ };
697
+ GetResourceByTokenResponse: {
698
+ sourceResource: components["schemas"]["ResourceDescriptor"];
699
+ /** @description ISO 8601 timestamp when token expires */
700
+ expiresAt: string;
701
+ };
702
+ GetResourceResponse: {
703
+ resource: components["schemas"]["ResourceDescriptor"];
704
+ /** @description All annotations for the resource (highlights, references, assessments, etc.) */
705
+ annotations: components["schemas"]["Annotation"][];
706
+ /** @description Annotations that reference this resource from other resources */
707
+ entityReferences: components["schemas"]["Annotation"][];
708
+ };
709
+ GetTagSchemasResponse: {
710
+ tagSchemas: components["schemas"]["TagSchema"][];
711
+ };
712
+ GoogleAuthRequest: {
713
+ access_token: string;
714
+ };
715
+ HealthResponse: {
716
+ status: string;
717
+ message: string;
718
+ version: string;
719
+ timestamp: string;
720
+ /** @enum {string} */
721
+ database: "connected" | "disconnected" | "unknown";
722
+ environment: string;
723
+ };
724
+ JobStatusResponse: {
725
+ jobId: string;
726
+ type: components["schemas"]["JobType"];
727
+ /** @enum {string} */
728
+ status: "pending" | "running" | "complete" | "failed" | "cancelled";
729
+ userId: string;
730
+ created: string;
731
+ startedAt?: string;
732
+ completedAt?: string;
733
+ error?: string;
734
+ progress?: unknown;
735
+ result?: unknown;
736
+ };
737
+ /** @description Knowledge graph gathered for an LLM context — a shared backbone in which resources AND annotations are typed nodes, connected by typed (optionally bidirectional) edges. Flattened views the matcher/generation read (connections, citedBy, siblings) are derived from these nodes/edges. */
738
+ KnowledgeGraph: {
739
+ nodes: {
740
+ /** @description Node identifier — a ResourceId or AnnotationId */
741
+ id: string;
742
+ /**
743
+ * @description Whether this node is a resource or an annotation
744
+ * @enum {string}
745
+ */
746
+ type: "resource" | "annotation";
747
+ label: string;
748
+ /** @description Entity types on the node (resources) or carried by the annotation */
749
+ entityTypes?: string[];
750
+ metadata?: {
751
+ [key: string]: unknown;
752
+ };
753
+ }[];
754
+ edges: {
755
+ source: string;
756
+ target: string;
757
+ /** @description Edge kind (e.g. citation, annotation-of, sibling) */
758
+ type: string;
759
+ /** @description Whether the connection goes both ways */
760
+ bidirectional?: boolean;
761
+ metadata?: {
762
+ [key: string]: unknown;
763
+ };
764
+ }[];
765
+ };
766
+ ListResourcesResponse: {
767
+ resources: components["schemas"]["ResourceDescriptor"][];
768
+ total: number;
769
+ offset: number;
770
+ limit: number;
771
+ };
772
+ PasswordAuthRequest: {
773
+ /**
774
+ * Format: email
775
+ * @description User email address
776
+ */
777
+ email: string;
778
+ /** @description User password (minimum 8 characters) */
779
+ password: string;
780
+ };
781
+ /**
782
+ * @description Semiont-supported W3C Web Annotation motivations - https://www.w3.org/TR/annotation-vocab/#motivation
783
+ * @enum {string}
784
+ */
785
+ Motivation: "assessing" | "commenting" | "highlighting" | "linking" | "tagging";
786
+ OAuthConfigResponse: {
787
+ providers: {
788
+ name: string;
789
+ isConfigured: boolean;
790
+ clientId: string;
791
+ }[];
792
+ allowedDomains: string[];
793
+ };
794
+ /** @description A specific, byte-addressable rendition of a resource (file/asset/variant). */
795
+ Representation: {
796
+ /**
797
+ * Format: uri
798
+ * @description Stable ID for this representation.
799
+ */
800
+ "@id"?: string;
801
+ /** @description Type(s), e.g., schema:MediaObject. */
802
+ "@type"?: string | string[];
803
+ /** @description MIME/media type (e.g., text/markdown, image/png). */
804
+ mediaType: string;
805
+ /** @description Working-tree URI identifying where the bytes live. Only file:// is supported (e.g. file://docs/overview.md). */
806
+ storageUri?: string;
807
+ filename?: string;
808
+ /** @description Size of the payload in bytes. */
809
+ byteSize?: number;
810
+ /** @description Integrity hash (e.g., sha256:abcd…). */
811
+ checksum?: string;
812
+ /** @description Compression/transfer encoding if applicable. */
813
+ encoding?: string;
814
+ /** @description IETF BCP 47 language tag (e.g., en, es-ES). */
815
+ language?: string;
816
+ /** @description Pixels (images/video). */
817
+ width?: number;
818
+ /** @description Pixels (images/video). */
819
+ height?: number;
820
+ /** @description Seconds (audio/video). */
821
+ duration?: number;
822
+ /** Format: date-time */
823
+ created?: string;
824
+ /** Format: date-time */
825
+ modified?: string;
826
+ /** @description Profile/shape the bytes conform to (e.g., a JSON profile or SVG profile). */
827
+ conformsTo?: string | string[];
828
+ tags?: string[];
829
+ /**
830
+ * @description Semantics of this rendition relative to the resource (e.g., original, thumbnail, preview, derived).
831
+ * @enum {string}
832
+ */
833
+ rel?: "original" | "thumbnail" | "preview" | "optimized" | "derived" | "other";
834
+ } & {
835
+ [key: string]: unknown;
836
+ };
837
+ /** @description Metadata about a resource (1:1 with its URI). JSON-LD subject is @id. Link to concrete bytes via representations. */
838
+ ResourceDescriptor: {
839
+ /** @description JSON-LD context; URI, object, or array of these. */
840
+ "@context": string | {
841
+ [key: string]: unknown;
842
+ } | (string | {
843
+ [key: string]: unknown;
844
+ })[];
845
+ /** @description Canonical URI/URN of the resource being described. */
846
+ "@id": string;
847
+ /** @description Type(s) of the resource (IRIs/CURIEs via @context). */
848
+ "@type"?: string | string[];
849
+ name: string;
850
+ description?: string;
851
+ /** @description Persistent identifiers (e.g., DOI, URN). */
852
+ identifier?: string | string[] | ({
853
+ /** Format: uri */
854
+ "@id"?: string;
855
+ value?: string;
856
+ scheme?: string;
857
+ } & {
858
+ [key: string]: unknown;
859
+ });
860
+ /** @description Topics (IRIs or strings). */
861
+ about?: string | string[];
862
+ /** @description Equivalent/authoritative references. */
863
+ sameAs?: string[];
864
+ isPartOf?: string[];
865
+ hasPart?: string[];
866
+ /** Format: uri */
867
+ license?: string;
868
+ version?: string;
869
+ /** Format: date-time */
870
+ dateCreated?: string;
871
+ /** Format: date-time */
872
+ dateModified?: string;
873
+ /** @description W3C PROV - source resources this was derived from */
874
+ wasDerivedFrom?: string | string[];
875
+ /** @description W3C PROV - agents responsible for this resource */
876
+ wasAttributedTo?: components["schemas"]["Agent"] | components["schemas"]["Agent"][];
877
+ /** @description Software agent that produced or processed this resource (W3C Web Annotation model) */
878
+ generator?: components["schemas"]["Agent"] | components["schemas"]["Agent"][];
879
+ /** @description Profile/shape URI this resource description conforms to. */
880
+ conformsTo?: string | string[];
881
+ /** @description Convenience set summarizing media types across representations. */
882
+ availableFormats?: string[];
883
+ /** @description Managed or referenced byte-level renditions of this resource. */
884
+ representations: components["schemas"]["Representation"] | components["schemas"]["Representation"][];
885
+ /** @description Application-specific: Whether this resource is archived */
886
+ archived?: boolean;
887
+ /** @description Application-specific: Entity types for this resource */
888
+ entityTypes?: string[];
889
+ /** @description Application-specific: Whether this resource is a draft */
890
+ isDraft?: boolean;
891
+ /** @description Application-specific: ID of annotation that triggered generation */
892
+ sourceAnnotationId?: string;
893
+ /** @description Application-specific: ID of source resource for clones/derivatives */
894
+ sourceResourceId?: string;
895
+ /**
896
+ * Format: uri
897
+ * @description Original URI from a source knowledge base when this resource was imported
898
+ */
899
+ originatedFrom?: string;
900
+ /** @description Working-tree URI for this resource (e.g. file://docs/overview.md). Stable across updates and moves. */
901
+ storageUri?: string;
902
+ /** @description SHA-256 hex hash of the current content. Updated on resource.created, resource.updated, resource.cloned events. */
903
+ currentChecksum?: string;
904
+ } & {
905
+ [key: string]: unknown;
906
+ };
907
+ SemanticMatch: {
908
+ /** @description The chunk text that matched */
909
+ text: string;
910
+ /** @description Source resource ID */
911
+ resourceId: string;
912
+ /** @description Source annotation ID, if the match is from an annotation */
913
+ annotationId?: string;
914
+ /** @description Cosine similarity score (0-1) */
915
+ score: number;
916
+ /** @description Entity types on the matched passage */
917
+ entityTypes?: string[];
918
+ };
919
+ SpecificResource: {
920
+ /** @enum {string} */
921
+ type: "SpecificResource";
922
+ /** @description IRI of the target resource */
923
+ source: string;
924
+ /** @description Why this body is included */
925
+ purpose?: components["schemas"]["BodyPurpose"];
926
+ };
927
+ StatusResponse: {
928
+ status: string;
929
+ version: string;
930
+ features: {
931
+ semanticContent: string;
932
+ collaboration: string;
933
+ rbac: string;
934
+ };
935
+ message: string;
936
+ authenticatedAs?: string;
937
+ /** @description Name of the knowledge base project */
938
+ projectName?: string;
939
+ /** @description Current git branch of the knowledge base repository */
940
+ gitBranch?: string;
941
+ };
942
+ TextPositionSelector: {
943
+ /** @enum {string} */
944
+ type: "TextPositionSelector";
945
+ /** @description Character offset from resource start */
946
+ start: number;
947
+ /** @description Character offset from resource start */
948
+ end: number;
949
+ };
950
+ TextQuoteSelector: {
951
+ /** @enum {string} */
952
+ type: "TextQuoteSelector";
953
+ exact: string;
954
+ prefix?: string;
955
+ suffix?: string;
956
+ };
957
+ TextualBody: {
958
+ /** @enum {string} */
959
+ type: "TextualBody";
960
+ /** @description The text content (e.g., entity type name) */
961
+ value: string;
962
+ /** @description Why this body is included */
963
+ purpose?: components["schemas"]["BodyPurpose"];
964
+ /** @description MIME type (defaults to text/plain) */
965
+ format?: string;
966
+ /** @description BCP 47 language tag */
967
+ language?: string;
968
+ };
969
+ TokenRefreshRequest: {
970
+ /**
971
+ * @description Refresh token obtained during login
972
+ * @example eyJhbGciOiJIUzI1NiIs...
973
+ */
974
+ refreshToken: string;
975
+ };
976
+ TokenRefreshResponse: {
977
+ access_token: string;
978
+ };
979
+ UpdateAnnotationBodyRequest: {
980
+ /** @description Resource ID containing the annotation (required for O(1) Layer 3 lookup) */
981
+ resourceId: string;
982
+ /** @description Array of body modification operations to apply */
983
+ operations: (components["schemas"]["BodyOperationAdd"] | components["schemas"]["BodyOperationRemove"] | components["schemas"]["BodyOperationReplace"])[];
984
+ };
985
+ UpdateUserRequest: {
986
+ isAdmin?: boolean;
987
+ isActive?: boolean;
988
+ name?: string;
989
+ };
990
+ UpdateUserResponse: {
991
+ success: boolean;
992
+ user: {
993
+ id: string;
994
+ email: string;
995
+ name?: string | null;
996
+ image?: string | null;
997
+ domain: string;
998
+ provider: string;
999
+ isAdmin: boolean;
1000
+ isActive: boolean;
1001
+ lastLogin?: string | null;
1002
+ created: string;
1003
+ updatedAt: string;
1004
+ };
1005
+ };
1006
+ UserResponse: {
1007
+ id: string;
1008
+ email: string;
1009
+ name: string | null;
1010
+ image: string | null;
1011
+ domain: string;
1012
+ provider: string;
1013
+ isAdmin: boolean;
1014
+ isModerator: boolean;
1015
+ isActive: boolean;
1016
+ termsAcceptedAt: string | null;
1017
+ lastLogin: string | null;
1018
+ created: string;
1019
+ /** @description The validated JWT token string for the current session */
1020
+ token: string;
1021
+ };
1022
+ /** @description Emitted when an annotation receives focus for beckoning */
1023
+ BeckonFocusEvent: {
1024
+ annotationId?: string;
1025
+ resourceId?: string;
1026
+ };
1027
+ /** @description Emitted when an annotation is hovered over for beckoning */
1028
+ BeckonHoverEvent: {
1029
+ annotationId: string | null;
1030
+ };
1031
+ /** @description Emitted when a sparkle effect is triggered on an annotation */
1032
+ BeckonSparkleEvent: {
1033
+ annotationId: string;
1034
+ };
1035
+ /** @description Void success reply emitted on the bind:body-updated channel after bind:update-body has been applied, matched to the originating command by correlationId. */
1036
+ BindBodyUpdated: {
1037
+ /** @description Correlation id echoed from the originating bind:update-body command so busRequest can match the reply. */
1038
+ correlationId: string;
1039
+ };
1040
+ /** @description Command payload sent on the bind:initiate bus channel to start a bind flow. */
1041
+ BindInitiateCommand: {
1042
+ /** @description Branded AnnotationId of the annotation being bound */
1043
+ annotationId: string;
1044
+ /** @description Branded ResourceId of the resource being bound to */
1045
+ resourceId: string;
1046
+ /** @description Default title for the bound annotation */
1047
+ defaultTitle: string;
1048
+ /** @description Entity types to associate with the annotation */
1049
+ entityTypes: string[];
1050
+ };
1051
+ /** @description Command payload sent on the bind:update-body bus channel to modify annotation bodies. */
1052
+ BindUpdateBodyCommand: {
1053
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1054
+ _userId?: string;
1055
+ /** @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. */
1056
+ correlationId: string;
1057
+ /** @description Branded AnnotationId of the annotation whose body is being updated */
1058
+ annotationId: string;
1059
+ /** @description Branded ResourceId of the resource the annotation belongs to */
1060
+ resourceId: string;
1061
+ /** @description List of body mutation operations to apply */
1062
+ operations: {
1063
+ /**
1064
+ * @description The type of body operation
1065
+ * @enum {string}
1066
+ */
1067
+ op: "add" | "remove" | "replace";
1068
+ /** @description Body item for add operations */
1069
+ item?: components["schemas"]["AnnotationBody"];
1070
+ /** @description Previous body item for replace operations */
1071
+ oldItem?: components["schemas"]["AnnotationBody"];
1072
+ /** @description Replacement body item for replace operations */
1073
+ newItem?: components["schemas"]["AnnotationBody"];
1074
+ }[];
1075
+ };
1076
+ /**
1077
+ * @description W3C Web Annotation body purpose vocabulary - https://www.w3.org/TR/annotation-vocab/#motivation
1078
+ * @enum {string}
1079
+ */
1080
+ BodyPurpose: "assessing" | "bookmarking" | "classifying" | "commenting" | "describing" | "editing" | "highlighting" | "identifying" | "linking" | "moderating" | "questioning" | "replying" | "tagging";
1081
+ /** @description Request to browse the KB's collaborator directory (its declared Agents) */
1082
+ BrowseAgentsRequest: {
1083
+ correlationId: string;
1084
+ };
1085
+ /** @description Result of browsing the collaborator directory */
1086
+ BrowseAgentsResult: {
1087
+ correlationId: string;
1088
+ response: {
1089
+ agents: components["schemas"]["CollaboratorEntry"][];
1090
+ };
1091
+ };
1092
+ /** @description Request to browse the history of an annotation */
1093
+ BrowseAnnotationHistoryRequest: {
1094
+ correlationId: string;
1095
+ resourceId: string;
1096
+ annotationId: string;
1097
+ };
1098
+ /** @description Result of browsing annotation history */
1099
+ BrowseAnnotationHistoryResult: {
1100
+ correlationId: string;
1101
+ response: components["schemas"]["GetAnnotationHistoryResponse"];
1102
+ };
1103
+ /** @description Request to browse a single annotation */
1104
+ BrowseAnnotationRequest: {
1105
+ correlationId: string;
1106
+ resourceId: string;
1107
+ annotationId: string;
1108
+ };
1109
+ /** @description Result of browsing a single annotation */
1110
+ BrowseAnnotationResult: {
1111
+ correlationId: string;
1112
+ response: components["schemas"]["GetAnnotationResponse"];
1113
+ };
1114
+ /** @description Request to get contextual text around an annotation */
1115
+ BrowseAnnotationContextRequest: {
1116
+ correlationId: string;
1117
+ annotationId: string;
1118
+ resourceId: string;
1119
+ contextBefore?: number;
1120
+ contextAfter?: number;
1121
+ };
1122
+ /** @description Request to browse annotations for a resource */
1123
+ BrowseAnnotationsRequest: {
1124
+ correlationId: string;
1125
+ resourceId: string;
1126
+ };
1127
+ /** @description Result of browsing annotations for a resource */
1128
+ BrowseAnnotationsResult: {
1129
+ correlationId: string;
1130
+ response: components["schemas"]["GetAnnotationsResponse"];
1131
+ };
1132
+ /** @description Emitted when an annotation is clicked in the browse panel */
1133
+ BrowseClickEvent: {
1134
+ annotationId: string;
1135
+ motivation: components["schemas"]["Motivation"];
1136
+ };
1137
+ /** @description Request to browse a directory listing */
1138
+ BrowseDirectoryRequest: {
1139
+ correlationId: string;
1140
+ path: string;
1141
+ /** @enum {string} */
1142
+ sort?: "name" | "mtime" | "annotationCount";
1143
+ };
1144
+ /** @description Result of browsing a directory listing */
1145
+ BrowseDirectoryResult: {
1146
+ correlationId: string;
1147
+ response: {
1148
+ path: string;
1149
+ entries: components["schemas"]["DirectoryEntry"][];
1150
+ };
1151
+ };
1152
+ /** @description Emitted when an entity type is clicked in the browse panel */
1153
+ BrowseEntityTypeClickedEvent: {
1154
+ entityType: string;
1155
+ };
1156
+ /** @description Request to browse available entity types */
1157
+ BrowseEntityTypesRequest: {
1158
+ correlationId: string;
1159
+ };
1160
+ /** @description Result of browsing entity types */
1161
+ BrowseEntityTypesResult: {
1162
+ correlationId: string;
1163
+ response: components["schemas"]["GetEntityTypesResponse"];
1164
+ };
1165
+ /** @description Request to browse events for a resource */
1166
+ BrowseEventsRequest: {
1167
+ correlationId: string;
1168
+ resourceId: string;
1169
+ type?: string;
1170
+ userId?: string;
1171
+ limit?: number;
1172
+ };
1173
+ /** @description Result of browsing events for a resource */
1174
+ BrowseEventsResult: {
1175
+ correlationId: string;
1176
+ response: components["schemas"]["GetEventsResponse"];
1177
+ };
1178
+ /** @description Emitted when navigation to an external URL is requested */
1179
+ BrowseExternalNavigateEvent: {
1180
+ url: string;
1181
+ resourceId?: string;
1182
+ };
1183
+ /** @description Emitted when a link is clicked in the browse panel */
1184
+ BrowseLinkClickedEvent: {
1185
+ href: string;
1186
+ label?: string;
1187
+ };
1188
+ /** @description Emitted when a browse panel is opened */
1189
+ BrowsePanelOpenEvent: {
1190
+ panel: string;
1191
+ scrollToAnnotationId?: string;
1192
+ motivation?: string;
1193
+ };
1194
+ /** @description Emitted when a browse panel is toggled */
1195
+ BrowsePanelToggleEvent: {
1196
+ panel: string;
1197
+ };
1198
+ /** @description Request to browse annotations that reference a resource */
1199
+ BrowseReferencedByRequest: {
1200
+ correlationId: string;
1201
+ resourceId: string;
1202
+ motivation?: string;
1203
+ };
1204
+ /** @description Result of browsing annotations that reference a resource */
1205
+ BrowseReferencedByResult: {
1206
+ correlationId: string;
1207
+ response: components["schemas"]["GetReferencedByResponse"];
1208
+ };
1209
+ /** @description Emitted when navigation to a reference resource is requested */
1210
+ BrowseReferenceNavigateEvent: {
1211
+ resourceId: string;
1212
+ };
1213
+ /** @description Emitted when a resource is closed in the browse panel */
1214
+ BrowseResourceCloseEvent: {
1215
+ resourceId: string;
1216
+ };
1217
+ /** @description Emitted when resources are reordered in the browse panel */
1218
+ BrowseResourceReorderEvent: {
1219
+ oldIndex: number;
1220
+ newIndex: number;
1221
+ };
1222
+ /** @description Request to browse a single resource */
1223
+ BrowseResourceRequest: {
1224
+ correlationId: string;
1225
+ resourceId: string;
1226
+ };
1227
+ /** @description Result of browsing a single resource */
1228
+ BrowseResourceResult: {
1229
+ correlationId: string;
1230
+ response: components["schemas"]["GetResourceResponse"];
1231
+ };
1232
+ /** @description Request to browse resources with optional filtering and pagination */
1233
+ BrowseResourcesRequest: {
1234
+ correlationId: string;
1235
+ search?: string;
1236
+ archived?: boolean;
1237
+ entityType?: string;
1238
+ offset?: number;
1239
+ limit?: number;
1240
+ };
1241
+ /** @description Result of browsing resources */
1242
+ BrowseResourcesResult: {
1243
+ correlationId: string;
1244
+ response: components["schemas"]["ListResourcesResponse"];
1245
+ };
1246
+ /** @description Emitted when the browse panel requests a router navigation */
1247
+ BrowseRouterPushEvent: {
1248
+ path: string;
1249
+ reason?: string;
1250
+ };
1251
+ /** @description Request to browse registered tag schemas */
1252
+ BrowseTagSchemasRequest: {
1253
+ correlationId: string;
1254
+ };
1255
+ /** @description Result of browsing tag schemas */
1256
+ BrowseTagSchemasResult: {
1257
+ correlationId: string;
1258
+ response: components["schemas"]["GetTagSchemasResponse"];
1259
+ };
1260
+ /** @description One collaborator in the KB's directory: a W3C Agent plus, for software agents declared in the KB's worker inference config, the job types it serves. Actor-role-only agents (gatherer/matcher) and Persons omit servesJobTypes. */
1261
+ CollaboratorEntry: {
1262
+ agent: components["schemas"]["Agent"];
1263
+ /** @description Job types this agent is declared to serve (from the KB's workers.* config sections). Absent for Persons and for agents declared only under actor roles. */
1264
+ servesJobTypes?: components["schemas"]["JobType"][];
1265
+ };
1266
+ /** @description W3C Web Annotation FragmentSelector for media fragment identifiers (RFC 3778 for PDFs) */
1267
+ FragmentSelector: {
1268
+ /** @enum {string} */
1269
+ type: "FragmentSelector";
1270
+ /**
1271
+ * @description Media fragment identifier (e.g., 'page=1&viewrect=100,200,50,30' for PDF)
1272
+ * @example page=1&viewrect=100,200,50,30
1273
+ */
1274
+ value: string;
1275
+ /**
1276
+ * @description URI identifying the fragment syntax specification
1277
+ * @example http://tools.ietf.org/rfc/rfc3778
1278
+ */
1279
+ conformsTo?: string;
1280
+ };
1281
+ /** @description Completion payload emitted on the gather:annotation-complete bus channel when annotation context gathering finishes. */
1282
+ GatherAnnotationComplete: {
1283
+ /** @description Client-generated correlation ID to thread the response back to the originating request */
1284
+ correlationId: string;
1285
+ /** @description Branded AnnotationId of the annotation whose context was gathered */
1286
+ annotationId: string;
1287
+ /** @description The gathered annotation context (unified GatheredContext, focus.kind:'annotation') */
1288
+ response: components["schemas"]["GatheredContext"];
1289
+ };
1290
+ /** @description Request payload sent on the gather:requested bus channel to gather context for an annotation. */
1291
+ GatherAnnotationRequest: {
1292
+ /** @description Client-generated correlation ID to thread the response back to the originating request */
1293
+ correlationId: string;
1294
+ /** @description Branded AnnotationId of the annotation to gather context for */
1295
+ annotationId: string;
1296
+ /** @description Branded ResourceId of the resource the annotation belongs to */
1297
+ resourceId: string;
1298
+ /** @description Optional gathering configuration */
1299
+ options?: {
1300
+ /** @description Whether to include source context in the gathered result */
1301
+ includeSourceContext?: boolean;
1302
+ /** @description Whether to include target context in the gathered result */
1303
+ includeTargetContext?: boolean;
1304
+ /** @description Characters of surrounding text context to include */
1305
+ contextWindow?: number;
1306
+ };
1307
+ };
1308
+ /** @description Context gathered for a gather.* call — consumed by yield.* (generation) and the matcher. A shared base (graph, semanticContext, metadata, inferredRelationshipSummary) plus a discriminated `focus` that names the anchor: an annotation or a whole resource. */
1309
+ GatheredContext: {
1310
+ /** @description The gather anchor. Discriminated on `kind`. */
1311
+ focus: {
1312
+ /** @enum {string} */
1313
+ kind: "annotation";
1314
+ /** @description The annotation this context was gathered for */
1315
+ annotation: components["schemas"]["Annotation"];
1316
+ /** @description The resource containing the annotation */
1317
+ sourceResource: components["schemas"]["ResourceDescriptor"];
1318
+ /** @description Text context around the annotation target */
1319
+ selected?: {
1320
+ /** @description Text appearing before the selected passage */
1321
+ before?: string;
1322
+ /** @description The selected text passage (the annotation target) */
1323
+ text: string;
1324
+ /** @description Text appearing after the selected passage */
1325
+ after?: string;
1326
+ };
1327
+ /** @description User-provided hint to supplement or replace the selected text for search and generation */
1328
+ userHint?: string;
1329
+ /** @description The resource the annotation links to, if it is a resolved reference. Dormant capability — produced/exposed but not yet consumed (see LINK-TARGET-CONTEXT.md). */
1330
+ targetResource?: components["schemas"]["ResourceDescriptor"];
1331
+ /** @description Context about the annotation's link target. Dormant — see LINK-TARGET-CONTEXT.md. */
1332
+ targetContext?: {
1333
+ content: string;
1334
+ summary?: string;
1335
+ };
1336
+ } | {
1337
+ /** @enum {string} */
1338
+ kind: "resource";
1339
+ /** @description The resource this context was gathered for */
1340
+ resource: components["schemas"]["ResourceDescriptor"];
1341
+ summary?: string;
1342
+ suggestedReferences?: string[];
1343
+ /** @description Resource content (included when requested) */
1344
+ content?: {
1345
+ /** @description Content of the focal resource */
1346
+ main?: string;
1347
+ /** @description Map of related resource IDs to their content */
1348
+ related?: {
1349
+ [key: string]: string;
1350
+ };
1351
+ };
1352
+ };
1353
+ /** @description Knowledge graph backbone — resources AND annotations as typed nodes. The flattened views (connections, citedBy, siblings) are derived from this. */
1354
+ graph: components["schemas"]["KnowledgeGraph"];
1355
+ /** @description Semantically similar passages from across the knowledge base, found via vector search */
1356
+ semanticContext?: {
1357
+ /** @description Passages ranked by cosine similarity to the focal text */
1358
+ similar: components["schemas"]["SemanticMatch"][];
1359
+ /** @description Entity types excluded from this recall — a record of how `similar` was filtered (e.g. ['Question'] so answer-generation never surfaces prior questions). Absent when no exclusion was applied. */
1360
+ excludedEntityTypes?: string[];
1361
+ };
1362
+ /** @description Context metadata about the focal anchor and its source */
1363
+ metadata: {
1364
+ /** @description Type of source resource (e.g., 'document', 'image', 'video') */
1365
+ resourceType?: string;
1366
+ /** @description BCP 47 language tag of source content */
1367
+ language?: string;
1368
+ /** @description Entity types associated with the focal anchor */
1369
+ entityTypes?: string[];
1370
+ /** @description Global frequency counts for entity types (for IDF-like weighting). A KB-wide statistic, not a neighborhood property — kept here rather than on the graph. */
1371
+ entityTypeFrequencies?: {
1372
+ [key: string]: number;
1373
+ };
1374
+ };
1375
+ /** @description LLM-generated summary of the focal anchor's relationships in the knowledge graph */
1376
+ inferredRelationshipSummary?: string;
1377
+ };
1378
+ /** @description Completion payload emitted on the gather:resource-complete bus channel when resource context gathering finishes. */
1379
+ GatherResourceComplete: {
1380
+ /** @description Client-generated correlation ID to thread the response back to the originating request */
1381
+ correlationId: string;
1382
+ /** @description Branded ResourceId of the resource whose context was gathered */
1383
+ resourceId: string;
1384
+ /** @description The gathered resource context (unified GatheredContext, focus.kind:'resource') */
1385
+ response: components["schemas"]["GatheredContext"];
1386
+ };
1387
+ /** @description Request payload sent on the gather:resource-requested bus channel to gather context for a resource. */
1388
+ GatherResourceRequest: {
1389
+ /** @description Client-generated correlation ID to thread the response back to the originating request */
1390
+ correlationId: string;
1391
+ /** @description Branded ResourceId of the resource to gather context for */
1392
+ resourceId: string;
1393
+ /** @description Gathering configuration */
1394
+ options: {
1395
+ /** @description Depth of resource graph traversal */
1396
+ depth: number;
1397
+ /** @description Maximum number of related resources to include */
1398
+ maxResources: number;
1399
+ /** @description Whether to include resource content in the gathered result */
1400
+ includeContent: boolean;
1401
+ /** @description Whether to include resource summaries in the gathered result */
1402
+ includeSummary: boolean;
1403
+ /** @description Entity types to exclude from the semantic recall built into this context (caller-supplied; e.g. a chat consumer passes ['Question'] so prior questions never ground answer generation). Optional; default none. */
1404
+ excludeEntityTypes?: string[];
1405
+ };
1406
+ };
1407
+ /** @description Request to generate an AI summary of an annotation */
1408
+ GatherSummaryRequest: {
1409
+ correlationId: string;
1410
+ annotationId: string;
1411
+ resourceId: string;
1412
+ };
1413
+ /** @description Result of a completed assessment-annotation job. */
1414
+ JobAssessmentAnnotationResult: {
1415
+ assessmentsFound: number;
1416
+ assessmentsCreated: number;
1417
+ };
1418
+ /** @description Request to cancel a job */
1419
+ JobCancelRequest: {
1420
+ /** @description Correlation id for request/reply matching, set by the SDK's busRequest so the confirmed-write ack/failure routes back. Absent for the local cancelRequest UI signal. */
1421
+ correlationId?: string;
1422
+ /** @enum {string} */
1423
+ jobType: "annotation" | "generation";
1424
+ };
1425
+ /** @description Command to claim a pending job (atomic CAS: pending → running) */
1426
+ JobClaimCommand: {
1427
+ correlationId: string;
1428
+ jobId: string;
1429
+ };
1430
+ /** @description Command to create a new job via the event bus */
1431
+ JobCreateCommand: {
1432
+ correlationId: string;
1433
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1434
+ _userId?: string;
1435
+ jobType: components["schemas"]["JobType"];
1436
+ resourceId: string;
1437
+ params: {
1438
+ [key: string]: unknown;
1439
+ };
1440
+ };
1441
+ /** @description Result of a job:create command */
1442
+ JobCreatedResult: {
1443
+ correlationId: string;
1444
+ response: {
1445
+ jobId: string;
1446
+ };
1447
+ };
1448
+ /** @description Result of a completed comment-annotation job. */
1449
+ JobCommentAnnotationResult: {
1450
+ commentsFound: number;
1451
+ commentsCreated: number;
1452
+ };
1453
+ /** @description Command to mark a job as complete */
1454
+ JobCompleteCommand: {
1455
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1456
+ _userId?: string;
1457
+ resourceId: string;
1458
+ jobId: string;
1459
+ jobType: components["schemas"]["JobType"];
1460
+ /** @description Annotation this job is attached to, when applicable. Lets the UI route completion feedback (toast, resolve state) to a specific annotation. */
1461
+ annotationId?: string;
1462
+ result?: components["schemas"]["JobResult"];
1463
+ };
1464
+ /** @description Command to mark a job as failed */
1465
+ JobFailCommand: {
1466
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1467
+ _userId?: string;
1468
+ resourceId: string;
1469
+ jobId: string;
1470
+ jobType: components["schemas"]["JobType"];
1471
+ /** @description Annotation this job is attached to, when applicable. Lets the UI route failure feedback (error toast, revert state) to a specific annotation. */
1472
+ annotationId?: string;
1473
+ error: string;
1474
+ };
1475
+ /** @description Result of a completed generation job. resourceId is assigned by Stower when yield:create is processed; the worker emits job:complete with only resourceName, and Stower populates resourceId on the persisted payload. */
1476
+ JobGenerationResult: {
1477
+ /** @description ID of the generated resource (populated by Stower, not by the worker) */
1478
+ resourceId?: string;
1479
+ /** @description Name of the generated resource */
1480
+ resourceName: string;
1481
+ };
1482
+ /** @description Result of a completed highlight-annotation job. */
1483
+ JobHighlightAnnotationResult: {
1484
+ highlightsFound: number;
1485
+ highlightsCreated: number;
1486
+ };
1487
+ /** @description Progress report from a running job. Common fields are stage/percentage/message; job-type-specific fields may also be present. This is the single progress shape for every job type — annotation workers and generation alike. */
1488
+ JobProgress: {
1489
+ /** @description Current processing stage (e.g. 'analyzing', 'creating', 'complete', 'error') */
1490
+ stage: string;
1491
+ /** @description Completion percentage (0-100) */
1492
+ percentage: number;
1493
+ /** @description Human-readable progress message */
1494
+ message: string;
1495
+ /** @description Annotation this job is attached to, when applicable. Echoed inside JobProgress (in addition to the outer command envelope) so consumers that only see the inner progress object (e.g. client.yield.fromAnnotation's Observable) can still route visual feedback to a specific annotation. */
1496
+ annotationId?: string;
1497
+ /** @description Total entity types to process (reference-annotation) */
1498
+ totalEntityTypes?: number;
1499
+ /** @description Entity types processed so far (reference-annotation) */
1500
+ processedEntityTypes?: number;
1501
+ /** @description Entities found so far (reference-annotation) */
1502
+ entitiesFound?: number;
1503
+ /** @description Annotations emitted so far (reference-annotation) */
1504
+ entitiesEmitted?: number;
1505
+ /** @description Entity type currently being processed */
1506
+ currentEntityType?: string;
1507
+ /** @description Reference annotation: completed entity types with per-type counts, for UI progress display */
1508
+ completedEntityTypes?: {
1509
+ entityType: string;
1510
+ foundCount: number;
1511
+ }[];
1512
+ /** @description Categories processed (tag-annotation) */
1513
+ processedCategories?: number;
1514
+ /** @description Total categories (tag-annotation) */
1515
+ totalCategories?: number;
1516
+ /** @description Category currently being processed (tag-annotation) */
1517
+ currentCategory?: string;
1518
+ /** @description Echoed job parameters for display in the progress UI (e.g. entity types or categories the user asked to detect) */
1519
+ requestParams?: {
1520
+ label: string;
1521
+ value: string;
1522
+ }[];
1523
+ };
1524
+ /** @description Event indicating a job has been queued */
1525
+ JobQueuedEvent: {
1526
+ jobId: string;
1527
+ jobType: string;
1528
+ resourceId: string;
1529
+ /** @description DID of the user who initiated the job (audit). */
1530
+ userId: string;
1531
+ };
1532
+ /** @description Result of a completed reference-annotation job. */
1533
+ JobReferenceAnnotationResult: {
1534
+ /** @description Total entities found */
1535
+ totalFound: number;
1536
+ /** @description Total annotations emitted */
1537
+ totalEmitted: number;
1538
+ /** @description Number of errors encountered */
1539
+ errors: number;
1540
+ };
1541
+ /** @description Command to report progress on a job */
1542
+ JobReportProgressCommand: {
1543
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1544
+ _userId?: string;
1545
+ resourceId: string;
1546
+ jobId: string;
1547
+ jobType: components["schemas"]["JobType"];
1548
+ /** @description Annotation this job is attached to, when applicable. Lets the UI attach progress visuals to a specific annotation (e.g. a reference whose generation is running). */
1549
+ annotationId?: string;
1550
+ percentage: number;
1551
+ progress?: components["schemas"]["JobProgress"];
1552
+ };
1553
+ /** @description Discriminated union of all job result types. */
1554
+ JobResult: components["schemas"]["JobGenerationResult"] | components["schemas"]["JobReferenceAnnotationResult"] | components["schemas"]["JobHighlightAnnotationResult"] | components["schemas"]["JobAssessmentAnnotationResult"] | components["schemas"]["JobCommentAnnotationResult"] | components["schemas"]["JobTagAnnotationResult"];
1555
+ /** @description Command to start a job */
1556
+ JobStartCommand: {
1557
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1558
+ _userId?: string;
1559
+ resourceId: string;
1560
+ jobId: string;
1561
+ jobType: components["schemas"]["JobType"];
1562
+ /** @description Annotation this job is attached to, when applicable. Set for annotation-scoped jobs like generation (from a specific reference). Unset for resource-scoped jobs like bulk reference/tag/highlight detection. */
1563
+ annotationId?: string;
1564
+ };
1565
+ /** @description Request to check the status of a job */
1566
+ JobStatusRequest: {
1567
+ correlationId: string;
1568
+ jobId: string;
1569
+ };
1570
+ /** @description Result of a job status request */
1571
+ JobStatusResult: {
1572
+ correlationId: string;
1573
+ response: components["schemas"]["JobStatusResponse"];
1574
+ };
1575
+ /** @description Result of a completed tag-annotation job. */
1576
+ JobTagAnnotationResult: {
1577
+ tagsFound: number;
1578
+ tagsCreated: number;
1579
+ /** @description Count of tags created per category */
1580
+ byCategory: {
1581
+ [key: string]: number;
1582
+ };
1583
+ };
1584
+ /** @description Bus command to add a new entity type to the KB's vocabulary. Carried on the `frame:add-entity-type` channel — Frame is the schema-layer flow that owns vocabulary writes. */
1585
+ FrameAddEntityTypeCommand: {
1586
+ /** @description Correlation id for request/reply matching, set by the SDK's busRequest so the confirmed-write ack/failure routes back. Absent for in-process (bootstrap/replay/import) emits, which race the frame:entity-type-added domain event instead. */
1587
+ correlationId?: string;
1588
+ tag: string;
1589
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1590
+ _userId?: string;
1591
+ };
1592
+ /** @description Bus command to register a tag schema with the KB's runtime registry. Carried on the `frame:add-tag-schema` channel — Frame is the schema-layer flow that owns vocabulary writes. Most-recent registration of a given `schema.id` wins; the projection reflects the latest content. Identical re-registrations are silent; differing content overwrites and logs a warning. */
1593
+ FrameAddTagSchemaCommand: {
1594
+ /** @description Correlation id for request/reply matching, set by the SDK's busRequest so the confirmed-write ack/failure routes back. Absent for in-process emits. */
1595
+ correlationId?: string;
1596
+ schema: components["schemas"]["TagSchema"];
1597
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1598
+ _userId?: string;
1599
+ };
1600
+ /** @description Bus command to archive a resource and optionally remove its file. */
1601
+ MarkArchiveCommand: {
1602
+ /** @description Correlation id for request/reply matching, set by the SDK's busRequest so the confirmed-write ack/failure routes back. */
1603
+ correlationId?: string;
1604
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1605
+ _userId?: string;
1606
+ resourceId: string;
1607
+ storageUri?: string;
1608
+ keepFile?: boolean;
1609
+ noGit?: boolean;
1610
+ };
1611
+ /** @description Emitted when the user requests AI assistance for a mark */
1612
+ MarkAssistRequestEvent: {
1613
+ /** @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. */
1614
+ correlationId?: string;
1615
+ motivation: components["schemas"]["Motivation"];
1616
+ options: {
1617
+ instructions?: string;
1618
+ /** @enum {string} */
1619
+ tone?: "scholarly" | "explanatory" | "conversational" | "technical" | "analytical" | "critical" | "balanced" | "constructive";
1620
+ density?: number;
1621
+ language?: string;
1622
+ entityTypes?: string[];
1623
+ includeDescriptiveReferences?: boolean;
1624
+ schemaId?: string;
1625
+ categories?: string[];
1626
+ };
1627
+ };
1628
+ /** @description Bus command to create an annotation on a resource. */
1629
+ MarkCreateCommand: {
1630
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1631
+ _userId?: string;
1632
+ /** @description Optional correlation id threaded from the originating mark:create-request. Propagated into event metadata by Stower so annotation-assembly can emit mark:create-ok after persistence completes. */
1633
+ correlationId?: string;
1634
+ annotation: components["schemas"]["Annotation"];
1635
+ resourceId: string;
1636
+ };
1637
+ /** @description Success reply after creating an annotation, matched to the originating command by correlationId. */
1638
+ MarkCreateOk: {
1639
+ /** @description Correlation id echoed from the mark:create-request command so busRequest can match the reply. */
1640
+ correlationId?: string;
1641
+ /** @description The created annotation's identity. */
1642
+ response: {
1643
+ annotationId: string;
1644
+ };
1645
+ };
1646
+ /** @description Raw annotation creation intent — bus handler assembles the W3C annotation */
1647
+ MarkCreateRequest: {
1648
+ correlationId: string;
1649
+ resourceId: string;
1650
+ request: components["schemas"]["CreateAnnotationRequest"];
1651
+ };
1652
+ /** @description Bus command to delete an annotation. */
1653
+ MarkDeleteCommand: {
1654
+ /** @description Correlation id for request/reply matching, set by the SDK's busRequest so the confirmed-write ack/failure routes back. */
1655
+ correlationId?: string;
1656
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1657
+ _userId?: string;
1658
+ annotationId: string;
1659
+ resourceId?: string;
1660
+ };
1661
+ /** @description Success reply after deleting an annotation, matched to the originating command by correlationId. */
1662
+ MarkDeleteOk: {
1663
+ /** @description Correlation id echoed from the mark:delete command so busRequest can match the reply. */
1664
+ correlationId?: string;
1665
+ /** @description The deleted annotation's identity. */
1666
+ response: {
1667
+ annotationId: string;
1668
+ };
1669
+ };
1670
+ /** @description Emitted when the user requests a new mark (annotation) on a resource */
1671
+ MarkRequestedEvent: {
1672
+ /** @description The '@id' of the resource the mark belongs to (W3C target.source). Routes the event to the right viewer/state unit when a host mounts many viewers on one session. */
1673
+ source: string;
1674
+ /** @description One or more W3C selectors */
1675
+ 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"])[];
1676
+ motivation: components["schemas"]["Motivation"];
1677
+ };
1678
+ /** @description Emitted when a mark is submitted with its annotation body */
1679
+ MarkSubmitEvent: {
1680
+ /** @description The '@id' of the resource the mark belongs to (W3C target.source). Routes the submit to the state unit bound to that resource — without it, N mounted units each create the annotation (N copies on N resources). */
1681
+ source: string;
1682
+ motivation: components["schemas"]["Motivation"];
1683
+ /** @description One or more W3C selectors */
1684
+ 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"])[];
1685
+ /** @description Optional body. Omit for annotations whose motivation alone is meaningful (e.g. highlighting) or whose user-supplied content is empty (e.g. an assessing annotation saved without comment text). Shape matches Annotation.body. */
1686
+ body?: components["schemas"]["AnnotationBody"] | components["schemas"]["AnnotationBody"][];
1687
+ };
1688
+ /** @description Bus command to unarchive a previously archived resource. */
1689
+ MarkUnarchiveCommand: {
1690
+ /** @description Correlation id for request/reply matching, set by the SDK's busRequest so the confirmed-write ack/failure routes back. */
1691
+ correlationId?: string;
1692
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1693
+ _userId?: string;
1694
+ resourceId: string;
1695
+ storageUri?: string;
1696
+ };
1697
+ /** @description Bus command to update an annotation's body with patch operations. */
1698
+ MarkUpdateBodyCommand: {
1699
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1700
+ _userId?: string;
1701
+ /** @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. */
1702
+ correlationId?: string;
1703
+ annotationId: string;
1704
+ resourceId: string;
1705
+ operations: (components["schemas"]["BodyOperationAdd"] | components["schemas"]["BodyOperationRemove"] | components["schemas"]["BodyOperationReplace"])[];
1706
+ };
1707
+ /** @description Bus command to replace the entity types on a resource. */
1708
+ MarkUpdateEntityTypesCommand: {
1709
+ /** @description Correlation id for request/reply matching, set by the SDK's busRequest so the confirmed-write ack/failure routes back. */
1710
+ correlationId?: string;
1711
+ resourceId: string;
1712
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1713
+ _userId?: string;
1714
+ currentEntityTypes: string[];
1715
+ updatedEntityTypes: string[];
1716
+ };
1717
+ /** @description Request payload sent on the match:search-request bus channel to find candidate matches. */
1718
+ MatchSearchRequest: {
1719
+ /** @description Client-generated correlation ID to thread the response back to the originating request */
1720
+ correlationId: string;
1721
+ /** @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. */
1722
+ resourceId: string;
1723
+ /** @description Annotation ID of the reference to search candidates for */
1724
+ referenceId: string;
1725
+ /** @description Gathered context for the reference annotation */
1726
+ context: components["schemas"]["GatheredContext"];
1727
+ /** @description Maximum number of candidate results to return */
1728
+ limit?: number;
1729
+ /** @description Enable semantic similarity scoring in addition to keyword matching */
1730
+ useSemanticScoring?: boolean;
1731
+ };
1732
+ MediaTokenRequest: {
1733
+ /** @description The resource ID to generate a media token for */
1734
+ resourceId: string;
1735
+ };
1736
+ MediaTokenResponse: {
1737
+ /** @description Short-lived media token for use as ?token= query parameter on resource URLs */
1738
+ token: string;
1739
+ };
1740
+ /** @description Emitted when the hover delay setting changes */
1741
+ SettingsHoverDelayChangedEvent: {
1742
+ hoverDelayMs: number;
1743
+ };
1744
+ /** @description Emitted when the UI locale setting changes */
1745
+ SettingsLocaleChangedEvent: {
1746
+ locale: string;
1747
+ };
1748
+ /** @description Emitted when the UI theme setting changes */
1749
+ SettingsThemeChangedEvent: {
1750
+ /** @enum {string} */
1751
+ theme: "light" | "dark" | "system";
1752
+ };
1753
+ SvgSelector: {
1754
+ /** @enum {string} */
1755
+ type: "SvgSelector";
1756
+ /** @description SVG markup defining the region (must include xmlns attribute) */
1757
+ value: string;
1758
+ };
1759
+ /** @description A single category within a tag schema (e.g. 'Issue' in IRAC, 'distinguished' in legal-citation-treatment). Each category carries methodology-bound semantics: a name, a description, and examples used in the LLM prompt. */
1760
+ TagCategory: {
1761
+ name: string;
1762
+ description: string;
1763
+ examples: string[];
1764
+ };
1765
+ /** @description A structural-analysis schema (e.g. legal-irac, scientific-imrad, argument-toulmin). Defines a methodology framework as an id, name, description, domain hint, and an ordered list of categories. KBs and their skills register schemas with the runtime registry via `frame.addTagSchema(...)` at session start. */
1766
+ TagSchema: {
1767
+ id: string;
1768
+ name: string;
1769
+ description: string;
1770
+ /** @description Free-form domain hint (e.g. 'legal', 'scientific', 'general'). Used in the LLM prompt to tune the model's analysis voice. KB authors choose. */
1771
+ domain: string;
1772
+ tags: components["schemas"]["TagCategory"][];
1773
+ };
1774
+ /** @description Bus command to rebuild the graph projection from the event log — the whole graph when resourceId is absent, one resource when present. Served by the Weaver; replaces direct rebuild access, which does not survive the Weaver's container split. */
1775
+ WeaveRebuildCommand: {
1776
+ /** @description Correlation id for request/reply matching, set by busRequest so the ok/failed reply routes back. */
1777
+ correlationId?: string;
1778
+ /** @description When present, rebuild only this resource; otherwise clear and rebuild the entire graph. */
1779
+ resourceId?: string;
1780
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1781
+ _userId?: string;
1782
+ };
1783
+ /** @description Bus command to create a cloned resource from a clone token. */
1784
+ YieldCloneCreateCommand: {
1785
+ correlationId: string;
1786
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1787
+ _userId?: string;
1788
+ token: string;
1789
+ name: string;
1790
+ content: string;
1791
+ archiveOriginal?: boolean;
1792
+ };
1793
+ /** @description Success response after creating a cloned resource. */
1794
+ YieldCloneCreated: {
1795
+ correlationId: string;
1796
+ response: {
1797
+ resourceId: string;
1798
+ };
1799
+ };
1800
+ /** @description Bus command to request cloning a resource using a clone token. */
1801
+ YieldCloneResourceRequest: {
1802
+ correlationId: string;
1803
+ token: string;
1804
+ };
1805
+ /** @description Bus command to request a clone token for a resource. */
1806
+ YieldCloneTokenRequest: {
1807
+ correlationId: string;
1808
+ resourceId: string;
1809
+ };
1810
+ /** @description Bus command to create a yielded resource in the knowledge base. */
1811
+ YieldCreateCommand: {
1812
+ /** @description Correlation id for request/reply matching, set by busRequest so the yield:create-ok / yield:create-failed reply routes back to the awaiting caller. */
1813
+ correlationId?: string;
1814
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1815
+ _userId?: string;
1816
+ name: string;
1817
+ storageUri: string;
1818
+ contentChecksum: string;
1819
+ byteSize: number;
1820
+ format: components["schemas"]["ContentFormat"];
1821
+ language?: string;
1822
+ entityTypes?: string[];
1823
+ isDraft?: boolean;
1824
+ generatedFrom?: {
1825
+ resourceId?: string;
1826
+ annotationId?: string;
1827
+ };
1828
+ generationPrompt?: string;
1829
+ generator?: components["schemas"]["Agent"] | components["schemas"]["Agent"][];
1830
+ noGit?: boolean;
1831
+ };
1832
+ /** @description Success reply after creating a yielded resource, matched to the originating command by correlationId. */
1833
+ YieldCreateOk: {
1834
+ /** @description Correlation id echoed from the yield:create command so busRequest can match the reply. */
1835
+ correlationId?: string;
1836
+ /** @description The created resource's identity. */
1837
+ response: {
1838
+ resourceId: string;
1839
+ };
1840
+ };
1841
+ /** @description Bus command to move (rename) a yielded resource. */
1842
+ YieldMvCommand: {
1843
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1844
+ _userId?: string;
1845
+ fromUri: string;
1846
+ toUri: string;
1847
+ noGit?: boolean;
1848
+ };
1849
+ /** @description Bus command to update a yielded resource's storage content. */
1850
+ YieldUpdateCommand: {
1851
+ /** @description Correlation id for request/reply matching, set by busRequest so the yield:update-ok / yield:update-failed reply routes back to the awaiting caller. */
1852
+ correlationId?: string;
1853
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
1854
+ _userId?: string;
1855
+ resourceId: string;
1856
+ storageUri: string;
1857
+ contentChecksum: string;
1858
+ byteSize: number;
1859
+ noGit?: boolean;
1860
+ };
1861
+ /** @description Success reply after updating a yielded resource, matched to the originating command by correlationId. */
1862
+ YieldUpdateOk: {
1863
+ /** @description Correlation id echoed from the yield:update command so busRequest can match the reply. */
1864
+ correlationId?: string;
1865
+ /** @description The updated resource's identity. */
1866
+ response: {
1867
+ resourceId: string;
1868
+ };
1869
+ };
1870
+ };
1871
+ responses: never;
1872
+ parameters: never;
1873
+ requestBodies: never;
1874
+ headers: never;
1875
+ pathItems: never;
1876
+ }
1877
+
1878
+ /**
1879
+ * Branded string types for compile-time type safety
1880
+ *
1881
+ * These types are zero-cost at runtime but prevent mixing
1882
+ * different string types at compile time.
1883
+ */
1884
+
1885
+ type BaseUrl = string & {
1886
+ readonly __brand: 'BaseUrl';
1887
+ };
1888
+
1889
+ /**
1890
+ * Branded identifier types for compile-time type safety.
1891
+ *
1892
+ * These types prevent mixing up resource IDs, annotation IDs, and user IDs
1893
+ * at compile time while having zero runtime overhead.
1894
+ *
1895
+ * URI types (ResourceUri, AnnotationUri) are in @semiont/http-transport
1896
+ * since they deal with HTTP URIs returned by the API.
1897
+ */
1898
+ type ResourceId = string & {
1899
+ readonly __brand: 'ResourceId';
1900
+ };
1901
+ type AnnotationId = string & {
1902
+ readonly __brand: 'AnnotationId';
1903
+ };
1904
+ type UserId = string & {
1905
+ readonly __brand: 'UserId';
1906
+ };
1907
+
1908
+ /**
1909
+ * Annotation types
1910
+ */
1911
+
1912
+ type RawAnnotation = components['schemas']['Annotation'];
1913
+ /**
1914
+ * Domain-level Annotation type. Same shape as the OpenAPI-generated
1915
+ * `components['schemas']['Annotation']`, but with a branded `AnnotationId`
1916
+ * for the `id` field. Use this import everywhere the codebase refers to
1917
+ * "an annotation"; the raw OpenAPI type is only used inside
1918
+ * `@semiont/http-transport` at the HTTP boundary.
1919
+ *
1920
+ * Implemented by intersection (not `Omit`) to be robust against generator
1921
+ * drift — if the OpenAPI schema gets `additionalProperties: true` added,
1922
+ * `Omit` on the resulting intersection type silently drops named fields.
1923
+ */
1924
+ type Annotation = RawAnnotation & {
1925
+ id: AnnotationId;
1926
+ };
1927
+
1928
+ /**
1929
+ * Graph types - Models for graph connections and relationships
1930
+ */
1931
+
1932
+ type RawResourceDescriptor = components['schemas']['ResourceDescriptor'];
1933
+ /**
1934
+ * Domain-level ResourceDescriptor type. Same shape as the OpenAPI-generated
1935
+ * `components['schemas']['ResourceDescriptor']`, but with a branded `ResourceId`
1936
+ * for the `@id` field.
1937
+ *
1938
+ * Implemented by intersection (not `Omit`) because the generated raw type
1939
+ * ends in `& { [key: string]: unknown }` — `Omit` on an intersection with
1940
+ * an index signature drops almost all named fields.
1941
+ */
1942
+ type ResourceDescriptor = RawResourceDescriptor & {
1943
+ '@id': ResourceId;
1944
+ };
1945
+
1946
+ /**
1947
+ * Persisted Events
1948
+ *
1949
+ * The event types that get appended to the JSONL event log.
1950
+ * Each maps a type string to its OpenAPI payload schema.
1951
+ * The PersistedEvent union derives from this catalog.
1952
+ */
1953
+
1954
+ type AnnotationAddedPayload = components['schemas']['AnnotationAddedPayload'] & {
1955
+ annotation: Annotation;
1956
+ };
1957
+ type AnnotationRemovedPayload = components['schemas']['AnnotationRemovedPayload'] & {
1958
+ annotationId: AnnotationId;
1959
+ };
1960
+ type AnnotationBodyUpdatedPayload = components['schemas']['AnnotationBodyUpdatedPayload'] & {
1961
+ annotationId: AnnotationId;
1962
+ };
1963
+ /**
1964
+ * Maps each persisted event type string to its OpenAPI payload schema.
1965
+ * Single source of truth for "what events get written to the log."
1966
+ */
1967
+ type PersistedEventCatalog = {
1968
+ 'yield:created': components['schemas']['ResourceCreatedPayload'];
1969
+ 'yield:cloned': components['schemas']['ResourceClonedPayload'];
1970
+ 'yield:updated': components['schemas']['ResourceUpdatedPayload'];
1971
+ 'yield:moved': components['schemas']['ResourceMovedPayload'];
1972
+ 'yield:representation-added': components['schemas']['RepresentationAddedPayload'];
1973
+ 'yield:representation-removed': components['schemas']['RepresentationRemovedPayload'];
1974
+ 'mark:added': AnnotationAddedPayload;
1975
+ 'mark:removed': AnnotationRemovedPayload;
1976
+ 'mark:body-updated': AnnotationBodyUpdatedPayload;
1977
+ 'mark:archived': components['schemas']['ResourceArchivedPayload'];
1978
+ 'mark:unarchived': components['schemas']['ResourceUnarchivedPayload'];
1979
+ 'mark:entity-tag-added': components['schemas']['EntityTagChangedPayload'];
1980
+ 'mark:entity-tag-removed': components['schemas']['EntityTagChangedPayload'];
1981
+ 'frame:entity-type-added': components['schemas']['EntityTypeAddedPayload'];
1982
+ 'frame:tag-schema-added': components['schemas']['TagSchemaAddedPayload'];
1983
+ 'job:started': components['schemas']['JobStartedPayload'];
1984
+ 'job:progress': components['schemas']['JobProgressPayload'];
1985
+ 'job:completed': components['schemas']['JobCompletedPayload'];
1986
+ 'job:failed': components['schemas']['JobFailedPayload'];
1987
+ };
1988
+ /** System event types — persisted events that have no resourceId. */
1989
+ type SystemEventType = 'frame:entity-type-added' | 'frame:tag-schema-added';
1990
+ /** Extract the concrete persisted event type for a given type string. */
1991
+ type EventOfType<K extends keyof PersistedEventCatalog> = K extends SystemEventType ? EventBase & {
1992
+ type: K;
1993
+ payload: PersistedEventCatalog[K];
1994
+ } : EventBase & {
1995
+ type: K;
1996
+ resourceId: ResourceId;
1997
+ payload: PersistedEventCatalog[K];
1998
+ };
1999
+ /** The union of all persisted event types. Discriminated on `type`. */
2000
+ type PersistedEvent = {
2001
+ [K in keyof PersistedEventCatalog]: EventOfType<K>;
2002
+ }[keyof PersistedEventCatalog];
2003
+ type PersistedEventType = PersistedEvent['type'];
2004
+
2005
+ /**
2006
+ * Event Base Types
2007
+ *
2008
+ * Core shapes for the event-sourced persistence model.
2009
+ * EventBase is the common shape for all domain events.
2010
+ * StoredEvent wraps an event with persistence metadata.
2011
+ *
2012
+ * These types are referenced by event-catalog.ts (domain events)
2013
+ * and bus-protocol.ts (the full EventMap).
2014
+ */
2015
+
2016
+ /** Fields common to ALL domain events (system and resource-scoped). */
2017
+ interface EventBase {
2018
+ id: string;
2019
+ timestamp: string;
2020
+ resourceId?: ResourceId;
2021
+ userId: UserId;
2022
+ version: number;
2023
+ }
2024
+ /** Persistence metadata attached to every stored event. */
2025
+ type EventMetadata = components['schemas']['EventMetadata'];
2026
+ /** Optional cryptographic signature on a stored event. */
2027
+ interface EventSignature {
2028
+ algorithm: 'ed25519';
2029
+ publicKey: string;
2030
+ signature: string;
2031
+ keyId?: string;
2032
+ }
2033
+ /**
2034
+ * A domain event with persistence metadata.
2035
+ * Flat intersection — no nesting (event.type, not event.event.type).
2036
+ */
2037
+ type StoredEvent<T extends EventBase = PersistedEvent> = T & {
2038
+ metadata: EventMetadata;
2039
+ signature?: EventSignature;
2040
+ };
2041
+
2042
+ /**
2043
+ * Bus Protocol
2044
+ *
2045
+ * The complete EventMap for the RxJS EventBus. Every channel name and
2046
+ * its payload type is defined here — domain events, commands, reads,
2047
+ * results, SSE stream payloads, and frontend UI events.
2048
+ *
2049
+ * Identifier discipline: where a payload carries an annotation or
2050
+ * resource id, the TypeScript layer narrows the OpenAPI `string` to the
2051
+ * branded type (`AnnotationId`, `ResourceId`, `UserId`). The runtime
2052
+ * wire shape is unchanged (brands have no runtime representation);
2053
+ * what this buys us is that command handlers don't have to re-brand
2054
+ * at every seam. Brand once at the entry boundary (HTTP route handler,
2055
+ * DOM attribute read, URL param parse), not at every bus hop in
2056
+ * between. See `.plans/BRAND-UPSTREAM.md` for the rationale.
2057
+ *
2058
+ * Organized by flow (verb), then by category within each flow.
2059
+ */
2060
+
2061
+ type MarkDeleteCommand = components['schemas']['MarkDeleteCommand'] & {
2062
+ annotationId: AnnotationId;
2063
+ resourceId?: ResourceId;
2064
+ };
2065
+ type MarkUpdateBodyCommand = components['schemas']['MarkUpdateBodyCommand'] & {
2066
+ annotationId: AnnotationId;
2067
+ resourceId: ResourceId;
2068
+ };
2069
+ type BindInitiateCommand = components['schemas']['BindInitiateCommand'] & {
2070
+ annotationId: AnnotationId;
2071
+ resourceId: ResourceId;
2072
+ };
2073
+ type BindUpdateBodyCommand = components['schemas']['BindUpdateBodyCommand'] & {
2074
+ annotationId: AnnotationId;
2075
+ resourceId: ResourceId;
2076
+ };
2077
+ /**
2078
+ * The unified EventMap — every channel on the EventBus.
2079
+ *
2080
+ * Convention:
2081
+ * - Domain events (past tense): StoredEvent<Interface> — branded types
2082
+ * - Commands/reads/results/UI: OpenAPI schema refs — plain strings
2083
+ * - void: UI-only signals with no payload
2084
+ */
2085
+ /**
2086
+ * Viewport-space rectangle of a clicked annotation element — runtime-only
2087
+ * view geometry riding UI events (never wire vocabulary; deliberately not in
2088
+ * the OpenAPI schemas). Structurally satisfied by a DOM `DOMRect`, spelled
2089
+ * out here because this package compiles without the DOM lib.
2090
+ */
2091
+ interface AnchorRect {
2092
+ x: number;
2093
+ y: number;
2094
+ width: number;
2095
+ height: number;
2096
+ top: number;
2097
+ right: number;
2098
+ bottom: number;
2099
+ left: number;
2100
+ }
2101
+ type EventMap = {
2102
+ 'yield:created': StoredEvent<EventOfType<'yield:created'>>;
2103
+ 'yield:cloned': StoredEvent<EventOfType<'yield:cloned'>>;
2104
+ 'yield:updated': StoredEvent<EventOfType<'yield:updated'>>;
2105
+ 'yield:moved': StoredEvent<EventOfType<'yield:moved'>>;
2106
+ 'yield:representation-added': StoredEvent<EventOfType<'yield:representation-added'>>;
2107
+ 'yield:representation-removed': StoredEvent<EventOfType<'yield:representation-removed'>>;
2108
+ 'yield:create': components['schemas']['YieldCreateCommand'];
2109
+ 'yield:update': components['schemas']['YieldUpdateCommand'];
2110
+ 'yield:mv': components['schemas']['YieldMvCommand'];
2111
+ 'yield:clone': void;
2112
+ 'yield:clone-token-requested': components['schemas']['YieldCloneTokenRequest'];
2113
+ 'yield:clone-resource-requested': components['schemas']['YieldCloneResourceRequest'];
2114
+ 'yield:clone-create': components['schemas']['YieldCloneCreateCommand'];
2115
+ 'yield:create-ok': components['schemas']['YieldCreateOk'];
2116
+ 'yield:create-failed': components['schemas']['CommandError'];
2117
+ 'yield:update-ok': components['schemas']['YieldUpdateOk'];
2118
+ 'yield:update-failed': components['schemas']['CommandError'];
2119
+ 'yield:move-failed': {
2120
+ fromUri: string;
2121
+ } & components['schemas']['CommandError'];
2122
+ 'yield:clone-token-generated': {
2123
+ correlationId: string;
2124
+ response: components['schemas']['CloneResourceWithTokenResponse'];
2125
+ };
2126
+ 'yield:clone-token-failed': {
2127
+ correlationId: string;
2128
+ } & components['schemas']['CommandError'];
2129
+ 'yield:clone-resource-result': {
2130
+ correlationId: string;
2131
+ response: components['schemas']['GetResourceByTokenResponse'];
2132
+ };
2133
+ 'yield:clone-resource-failed': {
2134
+ correlationId: string;
2135
+ } & components['schemas']['CommandError'];
2136
+ 'yield:clone-created': components['schemas']['YieldCloneCreated'];
2137
+ 'yield:clone-create-failed': {
2138
+ correlationId: string;
2139
+ } & components['schemas']['CommandError'];
2140
+ 'mark:added': StoredEvent<EventOfType<'mark:added'>>;
2141
+ 'mark:removed': StoredEvent<EventOfType<'mark:removed'>>;
2142
+ 'mark:body-updated': StoredEvent<EventOfType<'mark:body-updated'>>;
2143
+ 'mark:entity-tag-added': StoredEvent<EventOfType<'mark:entity-tag-added'>>;
2144
+ 'mark:entity-tag-removed': StoredEvent<EventOfType<'mark:entity-tag-removed'>>;
2145
+ 'mark:archived': StoredEvent<EventOfType<'mark:archived'>>;
2146
+ 'mark:unarchived': StoredEvent<EventOfType<'mark:unarchived'>>;
2147
+ 'mark:create-request': components['schemas']['MarkCreateRequest'];
2148
+ 'mark:create': components['schemas']['MarkCreateCommand'];
2149
+ 'mark:delete': MarkDeleteCommand;
2150
+ 'mark:update-body': MarkUpdateBodyCommand;
2151
+ 'mark:archive': components['schemas']['MarkArchiveCommand'];
2152
+ 'mark:unarchive': components['schemas']['MarkUnarchiveCommand'];
2153
+ 'mark:update-entity-types': components['schemas']['MarkUpdateEntityTypesCommand'];
2154
+ 'mark:create-ok': components['schemas']['MarkCreateOk'];
2155
+ 'mark:create-failed': components['schemas']['CommandError'];
2156
+ 'mark:delete-ok': components['schemas']['MarkDeleteOk'];
2157
+ 'mark:delete-failed': components['schemas']['CommandError'];
2158
+ 'mark:archive-ok': {
2159
+ correlationId?: string;
2160
+ };
2161
+ 'mark:archive-failed': components['schemas']['CommandError'];
2162
+ 'mark:unarchive-ok': {
2163
+ correlationId?: string;
2164
+ };
2165
+ 'mark:unarchive-failed': components['schemas']['CommandError'];
2166
+ 'mark:update-entity-types-ok': {
2167
+ correlationId?: string;
2168
+ };
2169
+ 'mark:update-entity-types-failed': components['schemas']['CommandError'];
2170
+ 'mark:body-update-failed': components['schemas']['CommandError'];
2171
+ 'mark:select-comment': components['schemas']['SelectionData'];
2172
+ 'mark:select-tag': components['schemas']['SelectionData'];
2173
+ 'mark:select-assessment': components['schemas']['SelectionData'];
2174
+ 'mark:select-reference': components['schemas']['SelectionData'];
2175
+ 'mark:requested': components['schemas']['MarkRequestedEvent'];
2176
+ 'mark:cancel-pending': void;
2177
+ 'mark:submit': components['schemas']['MarkSubmitEvent'];
2178
+ 'mark:assist-request': components['schemas']['MarkAssistRequestEvent'];
2179
+ 'mark:assist-cancelled': void;
2180
+ 'mark:progress-dismiss': void;
2181
+ 'frame:entity-type-added': StoredEvent<EventOfType<'frame:entity-type-added'>>;
2182
+ 'frame:tag-schema-added': StoredEvent<EventOfType<'frame:tag-schema-added'>>;
2183
+ 'frame:add-entity-type': components['schemas']['FrameAddEntityTypeCommand'];
2184
+ 'frame:add-tag-schema': components['schemas']['FrameAddTagSchemaCommand'];
2185
+ 'frame:entity-type-add-ok': {
2186
+ correlationId?: string;
2187
+ };
2188
+ 'frame:entity-type-add-failed': components['schemas']['CommandError'];
2189
+ 'frame:tag-schema-add-ok': {
2190
+ correlationId?: string;
2191
+ };
2192
+ 'frame:tag-schema-add-failed': components['schemas']['CommandError'];
2193
+ 'bind:initiate': BindInitiateCommand;
2194
+ 'bind:update-body': BindUpdateBodyCommand;
2195
+ 'bind:body-updated': components['schemas']['BindBodyUpdated'];
2196
+ 'bind:body-update-failed': components['schemas']['CommandError'];
2197
+ 'match:search-requested': components['schemas']['MatchSearchRequest'];
2198
+ 'match:search-results': components['schemas']['MatchSearchResult'];
2199
+ 'match:search-failed': components['schemas']['MatchSearchFailed'];
2200
+ 'gather:requested': components['schemas']['GatherAnnotationRequest'];
2201
+ 'gather:complete': components['schemas']['GatherAnnotationComplete'];
2202
+ 'gather:failed': {
2203
+ correlationId: string;
2204
+ annotationId: string;
2205
+ } & components['schemas']['CommandError'];
2206
+ 'gather:resource-requested': components['schemas']['GatherResourceRequest'];
2207
+ 'gather:resource-complete': components['schemas']['GatherResourceComplete'];
2208
+ 'gather:resource-failed': {
2209
+ correlationId: string;
2210
+ resourceId: string;
2211
+ } & components['schemas']['CommandError'];
2212
+ 'gather:summary-requested': components['schemas']['GatherSummaryRequest'];
2213
+ 'gather:summary-result': {
2214
+ correlationId: string;
2215
+ response: Record<string, unknown>;
2216
+ };
2217
+ 'gather:summary-failed': {
2218
+ correlationId: string;
2219
+ } & components['schemas']['CommandError'];
2220
+ 'gather:annotation-progress': components['schemas']['GatherProgress'];
2221
+ 'browse:resource-requested': components['schemas']['BrowseResourceRequest'];
2222
+ 'browse:resource-result': {
2223
+ correlationId: string;
2224
+ response: Omit<components['schemas']['GetResourceResponse'], 'resource' | 'annotations' | 'entityReferences'> & {
2225
+ resource: ResourceDescriptor;
2226
+ annotations: Annotation[];
2227
+ entityReferences: Annotation[];
2228
+ };
2229
+ };
2230
+ 'browse:resource-failed': {
2231
+ correlationId: string;
2232
+ } & components['schemas']['CommandError'];
2233
+ 'browse:resources-requested': components['schemas']['BrowseResourcesRequest'];
2234
+ 'browse:resources-result': {
2235
+ correlationId: string;
2236
+ response: Omit<components['schemas']['ListResourcesResponse'], 'resources'> & {
2237
+ resources: ResourceDescriptor[];
2238
+ };
2239
+ };
2240
+ 'browse:resources-failed': {
2241
+ correlationId: string;
2242
+ } & components['schemas']['CommandError'];
2243
+ 'browse:annotations-requested': components['schemas']['BrowseAnnotationsRequest'];
2244
+ 'browse:annotations-result': {
2245
+ correlationId: string;
2246
+ response: Omit<components['schemas']['GetAnnotationsResponse'], 'annotations'> & {
2247
+ annotations: Annotation[];
2248
+ };
2249
+ };
2250
+ 'browse:annotations-failed': {
2251
+ correlationId: string;
2252
+ } & components['schemas']['CommandError'];
2253
+ 'browse:annotation-requested': components['schemas']['BrowseAnnotationRequest'];
2254
+ 'browse:annotation-result': {
2255
+ correlationId: string;
2256
+ response: Omit<components['schemas']['GetAnnotationResponse'], 'annotation' | 'resource' | 'resolvedResource'> & {
2257
+ annotation: Annotation;
2258
+ resource: ResourceDescriptor | null;
2259
+ resolvedResource: ResourceDescriptor | null;
2260
+ };
2261
+ };
2262
+ 'browse:annotation-failed': {
2263
+ correlationId: string;
2264
+ } & components['schemas']['CommandError'];
2265
+ 'browse:events-requested': components['schemas']['BrowseEventsRequest'];
2266
+ 'browse:events-result': components['schemas']['BrowseEventsResult'];
2267
+ 'browse:events-failed': {
2268
+ correlationId: string;
2269
+ } & components['schemas']['CommandError'];
2270
+ 'browse:annotation-history-requested': components['schemas']['BrowseAnnotationHistoryRequest'];
2271
+ 'browse:annotation-history-result': components['schemas']['BrowseAnnotationHistoryResult'];
2272
+ 'browse:annotation-history-failed': {
2273
+ correlationId: string;
2274
+ } & components['schemas']['CommandError'];
2275
+ 'browse:annotation-context-requested': components['schemas']['BrowseAnnotationContextRequest'];
2276
+ 'browse:annotation-context-result': {
2277
+ correlationId: string;
2278
+ response: Record<string, unknown>;
2279
+ };
2280
+ 'browse:annotation-context-failed': {
2281
+ correlationId: string;
2282
+ } & components['schemas']['CommandError'];
2283
+ 'browse:referenced-by-requested': components['schemas']['BrowseReferencedByRequest'];
2284
+ 'browse:referenced-by-result': components['schemas']['BrowseReferencedByResult'];
2285
+ 'browse:referenced-by-failed': {
2286
+ correlationId: string;
2287
+ } & components['schemas']['CommandError'];
2288
+ 'browse:entity-types-requested': components['schemas']['BrowseEntityTypesRequest'];
2289
+ 'browse:entity-types-result': components['schemas']['BrowseEntityTypesResult'];
2290
+ 'browse:entity-types-failed': {
2291
+ correlationId: string;
2292
+ } & components['schemas']['CommandError'];
2293
+ 'browse:tag-schemas-requested': components['schemas']['BrowseTagSchemasRequest'];
2294
+ 'browse:tag-schemas-result': components['schemas']['BrowseTagSchemasResult'];
2295
+ 'browse:tag-schemas-failed': {
2296
+ correlationId: string;
2297
+ } & components['schemas']['CommandError'];
2298
+ 'browse:agents-requested': components['schemas']['BrowseAgentsRequest'];
2299
+ 'browse:agents-result': components['schemas']['BrowseAgentsResult'];
2300
+ 'browse:agents-failed': {
2301
+ correlationId: string;
2302
+ } & components['schemas']['CommandError'];
2303
+ 'browse:directory-requested': components['schemas']['BrowseDirectoryRequest'];
2304
+ 'browse:directory-result': components['schemas']['BrowseDirectoryResult'];
2305
+ 'browse:directory-failed': {
2306
+ correlationId: string;
2307
+ path: string;
2308
+ } & components['schemas']['CommandError'];
2309
+ 'browse:click': components['schemas']['BrowseClickEvent'] & {
2310
+ anchorRect?: AnchorRect;
2311
+ };
2312
+ 'browse:reference-navigate': components['schemas']['BrowseReferenceNavigateEvent'];
2313
+ 'browse:entity-type-clicked': components['schemas']['BrowseEntityTypeClickedEvent'];
2314
+ 'panel:toggle': components['schemas']['BrowsePanelToggleEvent'];
2315
+ 'panel:open': components['schemas']['BrowsePanelOpenEvent'] & {
2316
+ anchorRect?: AnchorRect;
2317
+ };
2318
+ 'panel:close': void;
2319
+ 'shell:sidebar-toggle': void;
2320
+ 'tabs:close': components['schemas']['BrowseResourceCloseEvent'];
2321
+ 'tabs:reorder': components['schemas']['BrowseResourceReorderEvent'];
2322
+ 'nav:link-clicked': components['schemas']['BrowseLinkClickedEvent'];
2323
+ 'nav:push': components['schemas']['BrowseRouterPushEvent'];
2324
+ 'nav:external': components['schemas']['BrowseExternalNavigateEvent'] & {
2325
+ cancelFallback: () => void;
2326
+ };
2327
+ 'beckon:hover': components['schemas']['BeckonHoverEvent'];
2328
+ 'beckon:focus': components['schemas']['BeckonFocusEvent'];
2329
+ 'beckon:sparkle': components['schemas']['BeckonSparkleEvent'];
2330
+ 'job:started': StoredEvent<EventOfType<'job:started'>>;
2331
+ 'job:progress': StoredEvent<EventOfType<'job:progress'>>;
2332
+ 'job:completed': StoredEvent<EventOfType<'job:completed'>>;
2333
+ 'job:failed': StoredEvent<EventOfType<'job:failed'>>;
2334
+ 'job:start': components['schemas']['JobStartCommand'];
2335
+ 'job:report-progress': components['schemas']['JobReportProgressCommand'];
2336
+ 'job:complete': components['schemas']['JobCompleteCommand'];
2337
+ 'job:fail': components['schemas']['JobFailCommand'];
2338
+ 'job:queued': components['schemas']['JobQueuedEvent'];
2339
+ 'job:cancel-requested': components['schemas']['JobCancelRequest'];
2340
+ 'job:status-requested': components['schemas']['JobStatusRequest'];
2341
+ 'job:create': components['schemas']['JobCreateCommand'];
2342
+ 'job:claim': components['schemas']['JobClaimCommand'];
2343
+ 'job:status-result': components['schemas']['JobStatusResult'];
2344
+ 'job:status-failed': {
2345
+ correlationId: string;
2346
+ } & components['schemas']['CommandError'];
2347
+ 'job:created': components['schemas']['JobCreatedResult'];
2348
+ 'job:create-failed': {
2349
+ correlationId: string;
2350
+ } & components['schemas']['CommandError'];
2351
+ 'job:claimed': {
2352
+ correlationId: string;
2353
+ response: Record<string, unknown>;
2354
+ };
2355
+ 'job:claim-failed': {
2356
+ correlationId: string;
2357
+ } & components['schemas']['CommandError'];
2358
+ 'job:cancel-ok': {
2359
+ correlationId?: string;
2360
+ response: {
2361
+ cancelled: number;
2362
+ };
2363
+ };
2364
+ 'job:cancel-failed': components['schemas']['CommandError'];
2365
+ /**
2366
+ * Emitted by the Weaver after applying an event (or a batch's last event)
2367
+ * for a resource to the graph. `sequenceNumber` is the resource-stream
2368
+ * sequence of the last applied event. Folded by `WeaveProgress`
2369
+ * (make-meaning) into the backend-local applied map that the
2370
+ * `whenApplied` barrier awaits. In-process signal today; crosses the
2371
+ * bus gateway after WEAVER-ISOLATION.
2372
+ */
2373
+ 'weave:applied': {
2374
+ resourceId: string;
2375
+ sequenceNumber: number;
2376
+ };
2377
+ 'smelt:settled': {
2378
+ resourceId: string;
2379
+ contentChecksum: string;
2380
+ outcome: 'indexed' | 'skipped';
2381
+ };
2382
+ 'weave:rebuild': components['schemas']['WeaveRebuildCommand'];
2383
+ 'weave:rebuild-ok': {
2384
+ correlationId?: string;
2385
+ };
2386
+ 'weave:rebuild-failed': {
2387
+ correlationId?: string;
2388
+ message: string;
2389
+ };
2390
+ 'settings:theme-changed': components['schemas']['SettingsThemeChangedEvent'];
2391
+ 'settings:line-numbers-toggled': void;
2392
+ 'settings:locale-changed': components['schemas']['SettingsLocaleChangedEvent'];
2393
+ 'settings:hover-delay-changed': components['schemas']['SettingsHoverDelayChangedEvent'];
2394
+ 'stream-connected': Record<string, never>;
2395
+ 'replay-window-exceeded': {
2396
+ resourceId?: string;
2397
+ lastEventId: number;
2398
+ missedCount: number;
2399
+ cap: number;
2400
+ message: string;
2401
+ };
2402
+ /**
2403
+ * Emitted by the `/bus/subscribe` handler when a client reconnected
2404
+ * with `Last-Event-ID: p-<scope>-<seq>` but the server could not
2405
+ * replay all missed persisted events for that scope (retention
2406
+ * window exceeded, scope unknown, or request unparseable). The
2407
+ * client should treat this as a signal to fall back to the pre-
2408
+ * resumption contract: invalidate caches for the affected scope
2409
+ * and re-read from scratch. Analogous to `replay-window-exceeded`
2410
+ * but scoped to the bus gateway rather than the per-resource
2411
+ * events stream.
2412
+ *
2413
+ * `scope` is the scope string the client asked about (omitted for
2414
+ * global-persisted resumption gaps, if that path ever exists).
2415
+ * `reason` is human-readable, for logging.
2416
+ */
2417
+ 'bus:resume-gap': {
2418
+ scope?: string;
2419
+ lastSeenId?: string;
2420
+ reason: string;
2421
+ };
2422
+ };
2423
+
2424
+ /**
2425
+ * RxJS-based Event Bus
2426
+ *
2427
+ * Framework-agnostic event bus providing direct access to typed RxJS Subjects.
2428
+ *
2429
+ * Can be used in Node.js, browser, workers, CLI - anywhere RxJS runs.
2430
+ */
2431
+
2432
+ /**
2433
+ * RxJS-based event bus
2434
+ *
2435
+ * Provides direct access to RxJS Subjects for each event type.
2436
+ * Use standard RxJS patterns for emitting and subscribing.
2437
+ *
2438
+ * @example
2439
+ * ```typescript
2440
+ * const eventBus = new EventBus();
2441
+ *
2442
+ * // Emit events
2443
+ * eventBus.get('beckon:hover').next({ annotationId: 'ann-1' });
2444
+ *
2445
+ * // Subscribe to events
2446
+ * const subscription = eventBus.get('beckon:hover').subscribe(({ annotationId }) => {
2447
+ * console.log('Hover:', annotationId);
2448
+ * });
2449
+ *
2450
+ * // Use RxJS operators
2451
+ * import { debounceTime } from 'rxjs/operators';
2452
+ * eventBus.get('beckon:hover')
2453
+ * .pipe(debounceTime(100))
2454
+ * .subscribe(handleHover);
2455
+ *
2456
+ * // Cleanup
2457
+ * subscription.unsubscribe();
2458
+ * eventBus.destroy();
2459
+ * ```
2460
+ */
2461
+ declare class EventBus {
2462
+ private subjects;
2463
+ private isDestroyed;
2464
+ constructor();
2465
+ /**
2466
+ * Get the RxJS Subject for an event
2467
+ *
2468
+ * Returns a typed Subject that can be used with all RxJS operators.
2469
+ * Subjects are created lazily on first access.
2470
+ *
2471
+ * @param eventName - The event name
2472
+ * @returns The RxJS Subject for this event
2473
+ *
2474
+ * @example
2475
+ * ```typescript
2476
+ * // Emit
2477
+ * eventBus.get('beckon:hover').next({ annotationId: 'ann-1' });
2478
+ *
2479
+ * // Subscribe
2480
+ * const sub = eventBus.get('beckon:hover').subscribe(handleHover);
2481
+ *
2482
+ * // With operators
2483
+ * eventBus.get('beckon:hover')
2484
+ * .pipe(debounceTime(100), distinctUntilChanged())
2485
+ * .subscribe(handleHover);
2486
+ * ```
2487
+ */
2488
+ get<K extends keyof EventMap>(eventName: K): Subject<EventMap[K]>;
2489
+ /**
2490
+ * Get the RxJS Subject for a domain event type (PersistedEventType).
2491
+ *
2492
+ * Domain event channels carry `StoredEvent`. This method avoids the need
2493
+ * for `as keyof EventMap` casts when subscribing to domain event channels
2494
+ * using runtime `PersistedEventType` strings.
2495
+ */
2496
+ getDomainEvent(eventType: PersistedEventType): Subject<StoredEvent>;
2497
+ /**
2498
+ * Destroy the event bus and complete all subjects
2499
+ *
2500
+ * After calling destroy(), no new events can be emitted or subscribed to.
2501
+ * All active subscriptions will be completed.
2502
+ */
2503
+ destroy(): void;
2504
+ /**
2505
+ * Check if the event bus has been destroyed
2506
+ */
2507
+ get destroyed(): boolean;
2508
+ /**
2509
+ * Create a resource-scoped event bus
2510
+ *
2511
+ * Events emitted or subscribed through the scoped bus are isolated to that resource.
2512
+ * Internally, events are namespaced but the API remains identical to the parent bus.
2513
+ *
2514
+ * @param resourceId - Resource identifier to scope events to
2515
+ * @returns A scoped event bus for this resource
2516
+ *
2517
+ * @example
2518
+ * ```typescript
2519
+ * const eventBus = new EventBus();
2520
+ * const resource1 = eventBus.scope('resource-1');
2521
+ * const resource2 = eventBus.scope('resource-2');
2522
+ *
2523
+ * // These are isolated - only resource1 subscribers will fire
2524
+ * resource1.get('detection:progress').next({ status: 'started' });
2525
+ * ```
2526
+ */
2527
+ scope(resourceId: string): ScopedEventBus;
2528
+ }
2529
+ /**
2530
+ * Resource-scoped event bus
2531
+ *
2532
+ * Provides isolated event streams per resource while maintaining the same API
2533
+ * as the parent EventBus. Events are internally namespaced by resourceId.
2534
+ */
2535
+ declare class ScopedEventBus {
2536
+ private parent;
2537
+ private scopePrefix;
2538
+ constructor(parent: EventBus, scopePrefix: string);
2539
+ /**
2540
+ * Get the RxJS Subject for a scoped event
2541
+ *
2542
+ * Returns the same type as the parent bus, but events are isolated to this scope.
2543
+ * Internally uses namespaced keys but preserves type safety.
2544
+ *
2545
+ * @param event - The event name
2546
+ * @returns The RxJS Subject for this scoped event
2547
+ */
2548
+ get<E extends keyof EventMap>(event: E): Subject<EventMap[E]>;
2549
+ /** Get the RxJS Subject for a domain event type on this scoped bus. */
2550
+ getDomainEvent(eventType: PersistedEventType): Subject<StoredEvent>;
2551
+ /**
2552
+ * Create a nested scope
2553
+ *
2554
+ * Allows hierarchical scoping like `resource-1:subsystem-a`
2555
+ *
2556
+ * @param subScope - Additional scope level
2557
+ * @returns A nested scoped event bus
2558
+ */
2559
+ scope(subScope: string): ScopedEventBus;
2560
+ }
2561
+
2562
+ /**
2563
+ * Transport interfaces — the shared contract for any wire-or-local
2564
+ * communication path consumed by `SemiontClient`. Concrete implementations
2565
+ * live alongside the runtime they wrap (`HttpTransport` in
2566
+ * `@semiont/http-transport`, in-process variants in `@semiont/make-meaning`,
2567
+ * etc.).
2568
+ *
2569
+ * Three interfaces:
2570
+ *
2571
+ * ITransport — bus primitives + lifecycle. Universal: every
2572
+ * concrete transport implements this.
2573
+ * IBackendOperations — auth, admin, exchange, system endpoints.
2574
+ * HTTP-shaped today; an in-process transport may
2575
+ * implement none, some, or a different set.
2576
+ * Optional on `SemiontClient` — passed only when
2577
+ * the host has a backend that supports them.
2578
+ * IContentTransport — binary I/O (putBinary / getBinary). Narrow by
2579
+ * design because binary has different backpressure
2580
+ * and streaming characteristics.
2581
+ *
2582
+ * The behavioral guarantees every implementation must honor are documented
2583
+ * in `docs/protocol/TRANSPORT-CONTRACT.md`.
2584
+ */
2585
+
2586
+ /**
2587
+ * Six-state lifecycle for a transport's connection. Drives UI affordances
2588
+ * (connecting spinners, reconnecting banners, etc.) and is observed via
2589
+ * `ITransport.state$`.
2590
+ *
2591
+ * initial ─ pre-`start()`; never enters subscribers' streams
2592
+ * except as the first replayed value
2593
+ * connecting ─ in-flight initial open
2594
+ * open ─ healthy, delivering events
2595
+ * reconnecting ─ open → dropped, retrying; may be transient
2596
+ * degraded ─ has been reconnecting for > DEGRADED_THRESHOLD_MS;
2597
+ * UI banner threshold; distinguishes brief mount-
2598
+ * churn cycles from sustained disconnection
2599
+ * closed ─ stop()/dispose() called; terminal
2600
+ */
2601
+ type ConnectionState = 'initial' | 'connecting' | 'open' | 'reconnecting' | 'degraded' | 'closed';
2602
+ interface ITransport {
2603
+ /**
2604
+ * Base URL the transport speaks to. For HTTP this is `https://host[:port]`;
2605
+ * for in-process transports, an opaque identifier (e.g. `local://kb-id`).
2606
+ */
2607
+ readonly baseUrl: BaseUrl;
2608
+ /**
2609
+ * Publish a payload on the named channel.
2610
+ *
2611
+ * `resourceScope`, when set, marks the emit as a resource-scoped
2612
+ * broadcast — only delivered to subscribers attached to that
2613
+ * resource's scope.
2614
+ */
2615
+ emit<K extends keyof EventMap>(channel: K, payload: EventMap[K], resourceScope?: ResourceId): Promise<void>;
2616
+ on<K extends keyof EventMap>(channel: K, handler: (payload: EventMap[K]) => void): () => void;
2617
+ stream<K extends keyof EventMap>(channel: K): Observable<EventMap[K]>;
2618
+ /**
2619
+ * Subscribe to a resource-scoped channel set. HTTP attaches a scope to
2620
+ * its SSE connection; in-process transports may be a no-op because
2621
+ * local events are delivered without scoping.
2622
+ *
2623
+ * Returns a disposer that detaches the scope when the last subscriber
2624
+ * unsubscribes (ref-counted).
2625
+ *
2626
+ * SDK-internal: this is the scope primitive the SDK's resource-scoped
2627
+ * `browse.*` live queries drive on subscribe/teardown (freshness follows
2628
+ * observation; #847) — it is not part of the application-facing surface.
2629
+ * Single-scope at a time; multi-scope is deferred
2630
+ * (`.plans/MULTI-RESOURCE-SCOPE.md`).
2631
+ */
2632
+ subscribeToResource(resourceId: ResourceId): () => void;
2633
+ /**
2634
+ * Hand the given bus to the transport so the transport can publish
2635
+ * the events it receives into it. The reference flows
2636
+ * client → transport (the client owns the bus); transports never
2637
+ * construct or replace it. Concrete transports decide what "receives"
2638
+ * means: HTTP bridges every channel it observes on its SSE wire;
2639
+ * an in-process transport bridges from the local actor bus.
2640
+ */
2641
+ bridgeInto(bus: EventBus): void;
2642
+ /**
2643
+ * Transport-level connection state. For HTTP, reflects the SSE
2644
+ * connection's health; for in-process transports, typically `'open'`
2645
+ * from construction onward (no connection to lose).
2646
+ */
2647
+ readonly state$: Observable<ConnectionState>;
2648
+ /**
2649
+ * Stream of transport-level errors surfaced from typed-wire methods or
2650
+ * other transport-mediated round-trips, just before they're thrown to
2651
+ * the caller. Each emission is a `SemiontError` (or subclass — HTTP
2652
+ * emits `APIError`, in-process transports emit whatever subclass is
2653
+ * appropriate). Consumers can subscribe for global error handling
2654
+ * (e.g. surfacing 401/403 as modals, logging) without wrapping every
2655
+ * call site in try/catch. Distinct from bus-level errors, which are
2656
+ * surfaced via the channel-correlation pattern in `busRequest`.
2657
+ */
2658
+ readonly errors$: Observable<SemiontError>;
2659
+ dispose(): void;
2660
+ }
2661
+
2662
+ declare const BUS_OPERATIONS: {
2663
+ readonly 'bind:update-body': {
2664
+ readonly result: "bind:body-updated";
2665
+ readonly failure: "bind:body-update-failed";
2666
+ };
2667
+ readonly 'browse:resource-requested': {
2668
+ readonly result: "browse:resource-result";
2669
+ readonly failure: "browse:resource-failed";
2670
+ };
2671
+ readonly 'browse:resources-requested': {
2672
+ readonly result: "browse:resources-result";
2673
+ readonly failure: "browse:resources-failed";
2674
+ };
2675
+ readonly 'browse:annotation-requested': {
2676
+ readonly result: "browse:annotation-result";
2677
+ readonly failure: "browse:annotation-failed";
2678
+ };
2679
+ readonly 'browse:annotations-requested': {
2680
+ readonly result: "browse:annotations-result";
2681
+ readonly failure: "browse:annotations-failed";
2682
+ };
2683
+ readonly 'browse:annotation-history-requested': {
2684
+ readonly result: "browse:annotation-history-result";
2685
+ readonly failure: "browse:annotation-history-failed";
2686
+ };
2687
+ readonly 'browse:events-requested': {
2688
+ readonly result: "browse:events-result";
2689
+ readonly failure: "browse:events-failed";
2690
+ };
2691
+ readonly 'browse:referenced-by-requested': {
2692
+ readonly result: "browse:referenced-by-result";
2693
+ readonly failure: "browse:referenced-by-failed";
2694
+ };
2695
+ readonly 'browse:entity-types-requested': {
2696
+ readonly result: "browse:entity-types-result";
2697
+ readonly failure: "browse:entity-types-failed";
2698
+ };
2699
+ readonly 'browse:tag-schemas-requested': {
2700
+ readonly result: "browse:tag-schemas-result";
2701
+ readonly failure: "browse:tag-schemas-failed";
2702
+ };
2703
+ readonly 'browse:agents-requested': {
2704
+ readonly result: "browse:agents-result";
2705
+ readonly failure: "browse:agents-failed";
2706
+ };
2707
+ readonly 'browse:directory-requested': {
2708
+ readonly result: "browse:directory-result";
2709
+ readonly failure: "browse:directory-failed";
2710
+ };
2711
+ readonly 'browse:annotation-context-requested': {
2712
+ readonly result: "browse:annotation-context-result";
2713
+ readonly failure: "browse:annotation-context-failed";
2714
+ };
2715
+ readonly 'frame:add-entity-type': {
2716
+ readonly result: "frame:entity-type-add-ok";
2717
+ readonly failure: "frame:entity-type-add-failed";
2718
+ };
2719
+ readonly 'frame:add-tag-schema': {
2720
+ readonly result: "frame:tag-schema-add-ok";
2721
+ readonly failure: "frame:tag-schema-add-failed";
2722
+ };
2723
+ readonly 'gather:requested': {
2724
+ readonly result: "gather:complete";
2725
+ readonly failure: "gather:failed";
2726
+ readonly progress: "gather:annotation-progress";
2727
+ };
2728
+ readonly 'gather:resource-requested': {
2729
+ readonly result: "gather:resource-complete";
2730
+ readonly failure: "gather:resource-failed";
2731
+ };
2732
+ readonly 'gather:summary-requested': {
2733
+ readonly result: "gather:summary-result";
2734
+ readonly failure: "gather:summary-failed";
2735
+ };
2736
+ readonly 'job:create': {
2737
+ readonly result: "job:created";
2738
+ readonly failure: "job:create-failed";
2739
+ };
2740
+ readonly 'job:status-requested': {
2741
+ readonly result: "job:status-result";
2742
+ readonly failure: "job:status-failed";
2743
+ };
2744
+ readonly 'job:cancel-requested': {
2745
+ readonly result: "job:cancel-ok";
2746
+ readonly failure: "job:cancel-failed";
2747
+ };
2748
+ readonly 'job:claim': {
2749
+ readonly result: "job:claimed";
2750
+ readonly failure: "job:claim-failed";
2751
+ };
2752
+ readonly 'mark:create-request': {
2753
+ readonly result: "mark:create-ok";
2754
+ readonly failure: "mark:create-failed";
2755
+ };
2756
+ readonly 'mark:delete': {
2757
+ readonly result: "mark:delete-ok";
2758
+ readonly failure: "mark:delete-failed";
2759
+ };
2760
+ readonly 'mark:archive': {
2761
+ readonly result: "mark:archive-ok";
2762
+ readonly failure: "mark:archive-failed";
2763
+ };
2764
+ readonly 'mark:unarchive': {
2765
+ readonly result: "mark:unarchive-ok";
2766
+ readonly failure: "mark:unarchive-failed";
2767
+ };
2768
+ readonly 'mark:update-entity-types': {
2769
+ readonly result: "mark:update-entity-types-ok";
2770
+ readonly failure: "mark:update-entity-types-failed";
2771
+ };
2772
+ readonly 'match:search-requested': {
2773
+ readonly result: "match:search-results";
2774
+ readonly failure: "match:search-failed";
2775
+ };
2776
+ readonly 'weave:rebuild': {
2777
+ readonly result: "weave:rebuild-ok";
2778
+ readonly failure: "weave:rebuild-failed";
2779
+ };
2780
+ readonly 'yield:create': {
2781
+ readonly result: "yield:create-ok";
2782
+ readonly failure: "yield:create-failed";
2783
+ };
2784
+ readonly 'yield:update': {
2785
+ readonly result: "yield:update-ok";
2786
+ readonly failure: "yield:update-failed";
2787
+ };
2788
+ readonly 'yield:clone-create': {
2789
+ readonly result: "yield:clone-created";
2790
+ readonly failure: "yield:clone-create-failed";
2791
+ };
2792
+ readonly 'yield:clone-resource-requested': {
2793
+ readonly result: "yield:clone-resource-result";
2794
+ readonly failure: "yield:clone-resource-failed";
2795
+ };
2796
+ readonly 'yield:clone-token-requested': {
2797
+ readonly result: "yield:clone-token-generated";
2798
+ readonly failure: "yield:clone-token-failed";
2799
+ };
2800
+ };
2801
+ /** The request-channel key of a registered operation — what `busRequest` takes. */
2802
+ type BusOperationKey = keyof typeof BUS_OPERATIONS;
2803
+
2804
+ /**
2805
+ * FaultyTransport — a seeded, scriptable `ITransport` simulator for the
2806
+ * liveness axioms (`.plans/LIVENESS-AXIOMS.md`). fast-check draws a fault
2807
+ * schedule; the transport applies one `FaultAction` per request-channel emit
2808
+ * and synthesizes replies from the `BUS_OPERATIONS` registry, so real
2809
+ * compositions (`busRequest`, SWR caches, live queries) run unmodified against
2810
+ * generated wire behavior no hand-written test names.
2811
+ *
2812
+ * Home is core (not sdk/test-utils) for the same reason as
2813
+ * `assertStateUnitAxioms`: it needs only core types, and every layer —
2814
+ * including `http-transport`, below sdk — can consume it via
2815
+ * `@semiont/core/testing` without a dependency cycle.
2816
+ *
2817
+ * Deterministic-by-construction: no `Date.now`, no randomness of its own —
2818
+ * all variation comes in through the schedule (fast-check owns the seed).
2819
+ * Time is real `setTimeout` at millisecond scale; properties pass a small
2820
+ * explicit `timeoutMs` to `busRequest`, so nothing waits 30 s.
2821
+ */
2822
+
2823
+ /** One wire behavior, applied to a single request-channel emit. */
2824
+ type FaultAction = {
2825
+ kind: 'deliver';
2826
+ } | {
2827
+ kind: 'drop-reply';
2828
+ } | {
2829
+ kind: 'delay';
2830
+ ms: number;
2831
+ } | {
2832
+ kind: 'duplicate-reply';
2833
+ } | {
2834
+ kind: 'reject-emit';
2835
+ };
2836
+ /**
2837
+ * Scope-contention behavior of `subscribeToResource`:
2838
+ * `single-slot-throw` mirrors today's HttpTransport (one distinct scope at a
2839
+ * time; a second distinct scope throws); `multi` mirrors the
2840
+ * post-MULTI-RESOURCE-SCOPE world. The same properties run under both so the
2841
+ * migration can't silently change liveness behavior.
2842
+ */
2843
+ type ScopeModel = 'single-slot-throw' | 'multi';
2844
+ /** requestLog entry — one per request-channel emit, in arrival order. */
2845
+ interface RequestLogEntry {
2846
+ channel: BusOperationKey;
2847
+ /** The action the schedule assigned to this emit. */
2848
+ action: FaultAction;
2849
+ correlationId: string | undefined;
2850
+ /**
2851
+ * Request identity for retry accounting: channel + payload minus the
2852
+ * per-issue fields (`correlationId`, `_trace`, `_userId`). Two emits with
2853
+ * the same key are the same logical request re-issued.
2854
+ */
2855
+ retryKey: string;
2856
+ }
2857
+ interface FaultyTransportConfig {
2858
+ /**
2859
+ * The i-th request-channel emit applies `schedule[i % schedule.length]`.
2860
+ * Empty/omitted → every request delivers.
2861
+ */
2862
+ schedule?: readonly FaultAction[];
2863
+ /** Default `'single-slot-throw'` (today's HttpTransport). */
2864
+ scopeModel?: ScopeModel;
2865
+ /**
2866
+ * Synthesize the `response` value for a delivered reply. Return `undefined`
2867
+ * for a void ack (`{ correlationId }` only). Default: `{}` for every op.
2868
+ */
2869
+ makeResponse?: (operation: BusOperationKey, payload: Record<string, unknown>) => unknown;
2870
+ }
2871
+ /** Stable request identity: channel + sorted payload minus per-issue fields. */
2872
+ declare function retryKeyOf(channel: string, payload: Record<string, unknown>): string;
2873
+ declare class FaultyTransport implements ITransport {
2874
+ readonly baseUrl: BaseUrl;
2875
+ readonly state$: BehaviorSubject<ConnectionState>;
2876
+ private readonly errorsSubject;
2877
+ readonly errors$: Observable<SemiontError>;
2878
+ /** Every request-channel emit, in order — the L2 accounting surface. */
2879
+ readonly requestLog: RequestLogEntry[];
2880
+ private readonly bus;
2881
+ private readonly schedule;
2882
+ private readonly scopeModel;
2883
+ private readonly makeResponse;
2884
+ private requestCount;
2885
+ private activeScope;
2886
+ private scopeRefs;
2887
+ private readonly timers;
2888
+ private disposed;
2889
+ constructor(cfg?: FaultyTransportConfig);
2890
+ emit<K extends keyof EventMap>(channel: K, payload: EventMap[K], resourceScope?: ResourceId): Promise<void>;
2891
+ on<K extends keyof EventMap>(channel: K, handler: (payload: EventMap[K]) => void): () => void;
2892
+ stream<K extends keyof EventMap>(channel: K): Observable<EventMap[K]>;
2893
+ subscribeToResource(rid: ResourceId): () => void;
2894
+ bridgeInto(bus: EventBus): void;
2895
+ dispose(): void;
2896
+ }
2897
+
2898
+ /**
2899
+ * Executable enforcement of the liveness axioms — the runtime twin of
2900
+ * `.plans/LIVENESS-AXIOMS.md`, and the composition-level sibling of
2901
+ * `assertStateUnitAxioms` (state-unit-axioms.ts). Where the StateUnit axioms
2902
+ * make *per-unit* wrongness mechanically detectable, these make *silence*
2903
+ * detectable: every existing enforcement tier is safety (nothing wrong is
2904
+ * delivered); these assert liveness (something is eventually delivered).
2905
+ *
2906
+ * Axioms (fault-schedule dimension; fast-check):
2907
+ * L1 Subscriber liveness — every output emits next|error within the bound,
2908
+ * under any fault schedule. Error is a permitted outcome; the forbidden
2909
+ * fourth state is pending-forever.
2910
+ * L2 Request settlement — every awaited path settles within the bound;
2911
+ * re-issues per logical request stay within the retry budget (B14: one);
2912
+ * a faulted request must be re-issued or surfaced, never swallowed.
2913
+ * L3 Delivery across lifecycle transitions — every event written to a live
2914
+ * connection reaches the output exactly once, wherever a client-initiated
2915
+ * transition (handover / reconnect / scope change) lands. Retirement is
2916
+ * by drain, never by abort (TRANSPORT-HTTP.md, Abort discipline).
2917
+ *
2918
+ * Framework-agnostic on purpose — only `rxjs` + `fast-check`, no `vitest` — so
2919
+ * it ships through `@semiont/core/testing` and any package's test runner can
2920
+ * invoke it. Deterministic virtual time: properties pass a small explicit
2921
+ * `timeoutMs` to `busRequest`; no `Date.now`, no 30 s real waits.
2922
+ */
2923
+
2924
+ /** What one fresh run of the composition exposes to the axioms. */
2925
+ interface LivenessScenario {
2926
+ /**
2927
+ * Live-query-shaped outputs. The harness subscribes each one; every
2928
+ * subscription must see `next` or `error` within the bound (L1).
2929
+ */
2930
+ outputs: readonly Observable<unknown>[];
2931
+ /**
2932
+ * Awaited paths. Each promise must settle — resolve or reject — within the
2933
+ * bound (L2). Rejections are fine; pending-forever is the violation.
2934
+ */
2935
+ settlements?: readonly Promise<unknown>[];
2936
+ teardown?: () => void;
2937
+ }
2938
+ interface LivenessAxiomSpec {
2939
+ /** Build a FRESH composition wired to the given transport. Called per run. */
2940
+ setup: (transport: FaultyTransport) => LivenessScenario | Promise<LivenessScenario>;
2941
+ /**
2942
+ * The timeoutMs the scenario passes to `busRequest` — the bound is derived
2943
+ * from it: (timeoutMs × (1 + retryBudget) + Σdelays) × slackFactor.
2944
+ */
2945
+ timeoutMs: number;
2946
+ /** Max sanctioned re-issues per logical request (B14 budget). Default 1. */
2947
+ retryBudget?: number;
2948
+ /** Override the generated fault schedules (teeth tests pin one). */
2949
+ scheduleArb?: fc.Arbitrary<readonly FaultAction[]>;
2950
+ /** Scope model(s) to run under. Default `'single-slot-throw'`. */
2951
+ scopeModel?: ScopeModel | 'both';
2952
+ /** Passed through to FaultyTransport (reply synthesis). */
2953
+ makeResponse?: (operation: string, payload: Record<string, unknown>) => unknown;
2954
+ /** fast-check run budget (default 25 — CI-fast; crank locally). */
2955
+ numRuns?: number;
2956
+ /** Real-scheduler jitter headroom on the bound (default 4×). */
2957
+ slackFactor?: number;
2958
+ }
2959
+ /** The five wire behaviors, uniformly weighted; delays stay small (≤5 ms). */
2960
+ declare function arbFaultAction(): fc.Arbitrary<FaultAction>;
2961
+ declare function arbFaultSchedule(maxLength?: number): fc.Arbitrary<readonly FaultAction[]>;
2962
+ /**
2963
+ * Run L1 + L2 against `spec` across generated fault schedules. Throws a
2964
+ * labeled Error (`L1: …` / `L2: …`) on the first violation.
2965
+ */
2966
+ declare function assertLivenessAxioms(spec: LivenessAxiomSpec): Promise<void>;
2967
+ /**
2968
+ * A connection-stream-shaped subject: something that accepts writes to the
2969
+ * live connection, can be told to transition (handover / reconnect / scope
2970
+ * change), and exposes the subscriber-facing output. P3 adapts the real
2971
+ * actor's mock-connection harness to this shape; the teeth tests drive
2972
+ * reconstructed pre-fix doubles.
2973
+ */
2974
+ interface DeliverySubject {
2975
+ /** Write the event with this id to the currently-live connection. */
2976
+ write: (eventId: string) => void;
2977
+ /** Client-initiated lifecycle transition. */
2978
+ transition: () => void | Promise<void>;
2979
+ /** Subscriber-facing output; each emission is a delivered event id. */
2980
+ output$: Observable<string>;
2981
+ /**
2982
+ * Drain pending asynchronous delivery at end of sequence (a live connection
2983
+ * eventually flushes). Default: one macrotask tick.
2984
+ */
2985
+ settle?: () => Promise<void>;
2986
+ teardown?: () => void;
2987
+ }
2988
+ type DeliveryOp = 'write' | 'transition';
2989
+ interface DeliveryAxiomSpec {
2990
+ /** Build a FRESH subject. Called per run. */
2991
+ setup: () => DeliverySubject;
2992
+ /** Override the generated op sequences (teeth tests pin one). */
2993
+ opsArb?: fc.Arbitrary<readonly DeliveryOp[]>;
2994
+ /** Max generated sequence length (default 12). */
2995
+ maxOps?: number;
2996
+ /** fast-check run budget (default 50 — these runs are cheap). */
2997
+ numRuns?: number;
2998
+ }
2999
+ declare function arbDeliveryOps(maxOps?: number): fc.Arbitrary<readonly DeliveryOp[]>;
3000
+ /**
3001
+ * Run L3 against `spec` across generated write/transition interleavings.
3002
+ * Throws a labeled Error (`L3: …`) on the first violation: an event written
3003
+ * to a live connection delivered zero times (lost — retired by abort instead
3004
+ * of drain) or more than once (duplicate).
3005
+ */
3006
+ declare function assertExactlyOnceDelivery(spec: DeliveryAxiomSpec): Promise<void>;
3007
+
3008
+ export { FaultyTransport, arbDeliveryOps, arbFaultAction, arbFaultSchedule, assertExactlyOnceDelivery, assertLivenessAxioms, assertStateUnitAxioms, disposeProbe, retryKeyOf };
3009
+ export type { DeliveryAxiomSpec, DeliveryOp, DeliverySubject, DisposeProbe, FaultAction, FaultyTransportConfig, LivenessAxiomSpec, LivenessScenario, RequestLogEntry, ScopeModel, StateUnitAxiomSpec };