@semiont/core 0.5.9 → 0.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +515 -188
- package/dist/index.js +279 -141
- package/dist/index.js.map +1 -1
- package/dist/testing.d.ts +2909 -0
- package/dist/testing.js +745 -0
- package/dist/testing.js.map +1 -0
- package/package.json +16 -3
|
@@ -0,0 +1,2909 @@
|
|
|
1
|
+
import { Observable, Subject, BehaviorSubject } from 'rxjs';
|
|
2
|
+
import * as fc from 'fast-check';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Marker for the state-unit pattern: a stateful, lifecycled object with an
|
|
6
|
+
* RxJS-shaped public surface, constructed by a factory function
|
|
7
|
+
* (`createFooStateUnit`), with internal state held in a closure.
|
|
8
|
+
*
|
|
9
|
+
* The structural contract is `dispose()` — the rest of the pattern
|
|
10
|
+
* (closure-based identity, Observable public surface, internal Subjects
|
|
11
|
+
* exposed as `.asObservable()` views, no leaked subscriptions, composition
|
|
12
|
+
* by parameter rather than ownership) is convention, made executable by the
|
|
13
|
+
* axiom harness in `@semiont/core/testing` (`assertStateUnitAxioms`).
|
|
14
|
+
*
|
|
15
|
+
* Lives in `@semiont/core` (not sdk) so every layer can share one definition
|
|
16
|
+
* without dependency cycles — `http-transport`'s `ActorStateUnit` sits below
|
|
17
|
+
* sdk and would otherwise have to re-declare it. See
|
|
18
|
+
* `packages/sdk/docs/STATE-UNITS.md` for the full pattern and rationale, and
|
|
19
|
+
* `.plans/STATE-UNIT-AXIOMS.md` for the axiom ledger.
|
|
20
|
+
*/
|
|
21
|
+
interface StateUnit {
|
|
22
|
+
/**
|
|
23
|
+
* Idempotent, total teardown. Completes every Subject the unit owns,
|
|
24
|
+
* unsubscribes every internal subscription, releases timers / abort
|
|
25
|
+
* controllers / network handles. Safe to call multiple times — the
|
|
26
|
+
* second call is a no-op.
|
|
27
|
+
*/
|
|
28
|
+
dispose(): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Executable enforcement of the StateUnit pattern — the runtime twin of
|
|
33
|
+
* `packages/sdk/docs/STATE-UNITS.md` and the ledger in
|
|
34
|
+
* `.plans/STATE-UNIT-AXIOMS.md`. The `StateUnit` interface's own comment notes
|
|
35
|
+
* the pattern is convention; this file makes it executable.
|
|
36
|
+
*
|
|
37
|
+
* `assertStateUnitAxioms(spec)` runs every applicable axiom against a factory in
|
|
38
|
+
* one shot, throwing a labeled Error on the first violation (the axiom id is in
|
|
39
|
+
* the message). It is framework-agnostic on purpose — only `rxjs` + `fast-check`,
|
|
40
|
+
* no `vitest` — so it ships through `@semiont/core/testing` and any package's test
|
|
41
|
+
* runner can invoke it from a single `it(...)` per state unit. It lives in core
|
|
42
|
+
* (not sdk) so even packages below sdk (e.g. `http-transport`) can use it without
|
|
43
|
+
* a dependency cycle.
|
|
44
|
+
*
|
|
45
|
+
* Axioms (random-input dimension; fast-check):
|
|
46
|
+
* A5 dispose() is idempotent and total (n ∈ [1,20] calls never throw)
|
|
47
|
+
* A5b post-dispose inertness — every public method is a no-op after dispose
|
|
48
|
+
* A6 every pre-dispose subscriber (k ∈ [1,10]) sees `complete` on dispose
|
|
49
|
+
* X3-runtime instance isolation — driving one instance never moves another's surfaces
|
|
50
|
+
* Structural assertions (single-shot):
|
|
51
|
+
* A1 plain-object identity (no class instance)
|
|
52
|
+
* X1 no raw Subject on the public surface
|
|
53
|
+
* A7-passed disposing the unit must NOT dispose an injected dependency
|
|
54
|
+
* A7-owned disposing the unit MUST dispose its internally-constructed children
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* A disposable stand-in for an injected dependency. Pass one as a unit's
|
|
59
|
+
* constructor arg, then list it in `setup().passedIn` so A7-passed can assert
|
|
60
|
+
* the unit never disposed it. Counts calls so A7-passed also holds under the
|
|
61
|
+
* repeated-dispose stress of A5.
|
|
62
|
+
*/
|
|
63
|
+
interface DisposeProbe extends StateUnit {
|
|
64
|
+
readonly disposeCount: number;
|
|
65
|
+
}
|
|
66
|
+
declare function disposeProbe(): DisposeProbe;
|
|
67
|
+
type SetupResult<T extends StateUnit> = T | {
|
|
68
|
+
unit: T;
|
|
69
|
+
passedIn?: readonly DisposeProbe[];
|
|
70
|
+
teardown?: () => void;
|
|
71
|
+
};
|
|
72
|
+
interface StateUnitAxiomSpec<T extends StateUnit> {
|
|
73
|
+
/**
|
|
74
|
+
* Build a FRESH unit. Called many times (fast-check re-runs), so it must
|
|
75
|
+
* return an independent instance each call. Return the bare unit, or an object
|
|
76
|
+
* carrying the injected `passedIn` probes (A7-passed) and a `teardown` to
|
|
77
|
+
* release per-instance resources (e.g. a mock bus).
|
|
78
|
+
*/
|
|
79
|
+
setup: () => SetupResult<T>;
|
|
80
|
+
/** Owned public Observables — Subjects the unit completes on dispose (A6, X3, post-dispose inertness). */
|
|
81
|
+
surfaces?: (unit: T) => readonly Observable<unknown>[];
|
|
82
|
+
/** Public input methods as zero-arg callers (A5b post-dispose, X3 drive). */
|
|
83
|
+
invocations?: (unit: T) => readonly (() => unknown)[];
|
|
84
|
+
/** Surfaces of internally-constructed children — must complete when the outer disposes (A7-owned). */
|
|
85
|
+
ownedChildSurfaces?: (unit: T) => readonly Observable<unknown>[];
|
|
86
|
+
/** fast-check run budget per property (default 30). */
|
|
87
|
+
numRuns?: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Run every applicable axiom against `spec`. Throws a labeled Error on the first
|
|
91
|
+
* violation. Axioms whose accessors are omitted are skipped (e.g. A7-passed
|
|
92
|
+
* runs only when `setup` returns `passedIn`; A6 only when `surfaces` is given).
|
|
93
|
+
*/
|
|
94
|
+
declare function assertStateUnitAxioms<T extends StateUnit>(spec: StateUnitAxiomSpec<T>): void;
|
|
95
|
+
|
|
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 create a cloned resource from a clone token. */
|
|
1775
|
+
YieldCloneCreateCommand: {
|
|
1776
|
+
correlationId: string;
|
|
1777
|
+
/** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
|
|
1778
|
+
_userId?: string;
|
|
1779
|
+
token: string;
|
|
1780
|
+
name: string;
|
|
1781
|
+
content: string;
|
|
1782
|
+
archiveOriginal?: boolean;
|
|
1783
|
+
};
|
|
1784
|
+
/** @description Success response after creating a cloned resource. */
|
|
1785
|
+
YieldCloneCreated: {
|
|
1786
|
+
correlationId: string;
|
|
1787
|
+
response: {
|
|
1788
|
+
resourceId: string;
|
|
1789
|
+
};
|
|
1790
|
+
};
|
|
1791
|
+
/** @description Bus command to request cloning a resource using a clone token. */
|
|
1792
|
+
YieldCloneResourceRequest: {
|
|
1793
|
+
correlationId: string;
|
|
1794
|
+
token: string;
|
|
1795
|
+
};
|
|
1796
|
+
/** @description Bus command to request a clone token for a resource. */
|
|
1797
|
+
YieldCloneTokenRequest: {
|
|
1798
|
+
correlationId: string;
|
|
1799
|
+
resourceId: string;
|
|
1800
|
+
};
|
|
1801
|
+
/** @description Bus command to create a yielded resource in the knowledge base. */
|
|
1802
|
+
YieldCreateCommand: {
|
|
1803
|
+
/** @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. */
|
|
1804
|
+
correlationId?: string;
|
|
1805
|
+
/** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
|
|
1806
|
+
_userId?: string;
|
|
1807
|
+
name: string;
|
|
1808
|
+
storageUri: string;
|
|
1809
|
+
contentChecksum: string;
|
|
1810
|
+
byteSize: number;
|
|
1811
|
+
format: components["schemas"]["ContentFormat"];
|
|
1812
|
+
language?: string;
|
|
1813
|
+
entityTypes?: string[];
|
|
1814
|
+
isDraft?: boolean;
|
|
1815
|
+
generatedFrom?: {
|
|
1816
|
+
resourceId?: string;
|
|
1817
|
+
annotationId?: string;
|
|
1818
|
+
};
|
|
1819
|
+
generationPrompt?: string;
|
|
1820
|
+
generator?: components["schemas"]["Agent"] | components["schemas"]["Agent"][];
|
|
1821
|
+
noGit?: boolean;
|
|
1822
|
+
};
|
|
1823
|
+
/** @description Success reply after creating a yielded resource, matched to the originating command by correlationId. */
|
|
1824
|
+
YieldCreateOk: {
|
|
1825
|
+
/** @description Correlation id echoed from the yield:create command so busRequest can match the reply. */
|
|
1826
|
+
correlationId?: string;
|
|
1827
|
+
/** @description The created resource's identity. */
|
|
1828
|
+
response: {
|
|
1829
|
+
resourceId: string;
|
|
1830
|
+
};
|
|
1831
|
+
};
|
|
1832
|
+
/** @description Bus command to move (rename) a yielded resource. */
|
|
1833
|
+
YieldMvCommand: {
|
|
1834
|
+
/** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
|
|
1835
|
+
_userId?: string;
|
|
1836
|
+
fromUri: string;
|
|
1837
|
+
toUri: string;
|
|
1838
|
+
noGit?: boolean;
|
|
1839
|
+
};
|
|
1840
|
+
/** @description Bus command to update a yielded resource's storage content. */
|
|
1841
|
+
YieldUpdateCommand: {
|
|
1842
|
+
/** @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. */
|
|
1843
|
+
correlationId?: string;
|
|
1844
|
+
/** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
|
|
1845
|
+
_userId?: string;
|
|
1846
|
+
resourceId: string;
|
|
1847
|
+
storageUri: string;
|
|
1848
|
+
contentChecksum: string;
|
|
1849
|
+
byteSize: number;
|
|
1850
|
+
noGit?: boolean;
|
|
1851
|
+
};
|
|
1852
|
+
/** @description Success reply after updating a yielded resource, matched to the originating command by correlationId. */
|
|
1853
|
+
YieldUpdateOk: {
|
|
1854
|
+
/** @description Correlation id echoed from the yield:update command so busRequest can match the reply. */
|
|
1855
|
+
correlationId?: string;
|
|
1856
|
+
/** @description The updated resource's identity. */
|
|
1857
|
+
response: {
|
|
1858
|
+
resourceId: string;
|
|
1859
|
+
};
|
|
1860
|
+
};
|
|
1861
|
+
};
|
|
1862
|
+
responses: never;
|
|
1863
|
+
parameters: never;
|
|
1864
|
+
requestBodies: never;
|
|
1865
|
+
headers: never;
|
|
1866
|
+
pathItems: never;
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
/**
|
|
1870
|
+
* Branded string types for compile-time type safety
|
|
1871
|
+
*
|
|
1872
|
+
* These types are zero-cost at runtime but prevent mixing
|
|
1873
|
+
* different string types at compile time.
|
|
1874
|
+
*/
|
|
1875
|
+
|
|
1876
|
+
type BaseUrl = string & {
|
|
1877
|
+
readonly __brand: 'BaseUrl';
|
|
1878
|
+
};
|
|
1879
|
+
|
|
1880
|
+
/**
|
|
1881
|
+
* Branded identifier types for compile-time type safety.
|
|
1882
|
+
*
|
|
1883
|
+
* These types prevent mixing up resource IDs, annotation IDs, and user IDs
|
|
1884
|
+
* at compile time while having zero runtime overhead.
|
|
1885
|
+
*
|
|
1886
|
+
* URI types (ResourceUri, AnnotationUri) are in @semiont/http-transport
|
|
1887
|
+
* since they deal with HTTP URIs returned by the API.
|
|
1888
|
+
*/
|
|
1889
|
+
type ResourceId = string & {
|
|
1890
|
+
readonly __brand: 'ResourceId';
|
|
1891
|
+
};
|
|
1892
|
+
type AnnotationId = string & {
|
|
1893
|
+
readonly __brand: 'AnnotationId';
|
|
1894
|
+
};
|
|
1895
|
+
type UserId = string & {
|
|
1896
|
+
readonly __brand: 'UserId';
|
|
1897
|
+
};
|
|
1898
|
+
|
|
1899
|
+
/**
|
|
1900
|
+
* Annotation types
|
|
1901
|
+
*/
|
|
1902
|
+
|
|
1903
|
+
type RawAnnotation = components['schemas']['Annotation'];
|
|
1904
|
+
/**
|
|
1905
|
+
* Domain-level Annotation type. Same shape as the OpenAPI-generated
|
|
1906
|
+
* `components['schemas']['Annotation']`, but with a branded `AnnotationId`
|
|
1907
|
+
* for the `id` field. Use this import everywhere the codebase refers to
|
|
1908
|
+
* "an annotation"; the raw OpenAPI type is only used inside
|
|
1909
|
+
* `@semiont/http-transport` at the HTTP boundary.
|
|
1910
|
+
*
|
|
1911
|
+
* Implemented by intersection (not `Omit`) to be robust against generator
|
|
1912
|
+
* drift — if the OpenAPI schema gets `additionalProperties: true` added,
|
|
1913
|
+
* `Omit` on the resulting intersection type silently drops named fields.
|
|
1914
|
+
*/
|
|
1915
|
+
type Annotation = RawAnnotation & {
|
|
1916
|
+
id: AnnotationId;
|
|
1917
|
+
};
|
|
1918
|
+
|
|
1919
|
+
/**
|
|
1920
|
+
* Persisted Events
|
|
1921
|
+
*
|
|
1922
|
+
* The event types that get appended to the JSONL event log.
|
|
1923
|
+
* Each maps a type string to its OpenAPI payload schema.
|
|
1924
|
+
* The PersistedEvent union derives from this catalog.
|
|
1925
|
+
*/
|
|
1926
|
+
|
|
1927
|
+
type AnnotationAddedPayload = components['schemas']['AnnotationAddedPayload'] & {
|
|
1928
|
+
annotation: Annotation;
|
|
1929
|
+
};
|
|
1930
|
+
type AnnotationRemovedPayload = components['schemas']['AnnotationRemovedPayload'] & {
|
|
1931
|
+
annotationId: AnnotationId;
|
|
1932
|
+
};
|
|
1933
|
+
type AnnotationBodyUpdatedPayload = components['schemas']['AnnotationBodyUpdatedPayload'] & {
|
|
1934
|
+
annotationId: AnnotationId;
|
|
1935
|
+
};
|
|
1936
|
+
/**
|
|
1937
|
+
* Maps each persisted event type string to its OpenAPI payload schema.
|
|
1938
|
+
* Single source of truth for "what events get written to the log."
|
|
1939
|
+
*/
|
|
1940
|
+
type PersistedEventCatalog = {
|
|
1941
|
+
'yield:created': components['schemas']['ResourceCreatedPayload'];
|
|
1942
|
+
'yield:cloned': components['schemas']['ResourceClonedPayload'];
|
|
1943
|
+
'yield:updated': components['schemas']['ResourceUpdatedPayload'];
|
|
1944
|
+
'yield:moved': components['schemas']['ResourceMovedPayload'];
|
|
1945
|
+
'yield:representation-added': components['schemas']['RepresentationAddedPayload'];
|
|
1946
|
+
'yield:representation-removed': components['schemas']['RepresentationRemovedPayload'];
|
|
1947
|
+
'mark:added': AnnotationAddedPayload;
|
|
1948
|
+
'mark:removed': AnnotationRemovedPayload;
|
|
1949
|
+
'mark:body-updated': AnnotationBodyUpdatedPayload;
|
|
1950
|
+
'mark:archived': components['schemas']['ResourceArchivedPayload'];
|
|
1951
|
+
'mark:unarchived': components['schemas']['ResourceUnarchivedPayload'];
|
|
1952
|
+
'mark:entity-tag-added': components['schemas']['EntityTagChangedPayload'];
|
|
1953
|
+
'mark:entity-tag-removed': components['schemas']['EntityTagChangedPayload'];
|
|
1954
|
+
'frame:entity-type-added': components['schemas']['EntityTypeAddedPayload'];
|
|
1955
|
+
'frame:tag-schema-added': components['schemas']['TagSchemaAddedPayload'];
|
|
1956
|
+
'job:started': components['schemas']['JobStartedPayload'];
|
|
1957
|
+
'job:progress': components['schemas']['JobProgressPayload'];
|
|
1958
|
+
'job:completed': components['schemas']['JobCompletedPayload'];
|
|
1959
|
+
'job:failed': components['schemas']['JobFailedPayload'];
|
|
1960
|
+
};
|
|
1961
|
+
/** System event types — persisted events that have no resourceId. */
|
|
1962
|
+
type SystemEventType = 'frame:entity-type-added' | 'frame:tag-schema-added';
|
|
1963
|
+
/** Extract the concrete persisted event type for a given type string. */
|
|
1964
|
+
type EventOfType<K extends keyof PersistedEventCatalog> = K extends SystemEventType ? EventBase & {
|
|
1965
|
+
type: K;
|
|
1966
|
+
payload: PersistedEventCatalog[K];
|
|
1967
|
+
} : EventBase & {
|
|
1968
|
+
type: K;
|
|
1969
|
+
resourceId: ResourceId;
|
|
1970
|
+
payload: PersistedEventCatalog[K];
|
|
1971
|
+
};
|
|
1972
|
+
/** The union of all persisted event types. Discriminated on `type`. */
|
|
1973
|
+
type PersistedEvent = {
|
|
1974
|
+
[K in keyof PersistedEventCatalog]: EventOfType<K>;
|
|
1975
|
+
}[keyof PersistedEventCatalog];
|
|
1976
|
+
type PersistedEventType = PersistedEvent['type'];
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* Event Base Types
|
|
1980
|
+
*
|
|
1981
|
+
* Core shapes for the event-sourced persistence model.
|
|
1982
|
+
* EventBase is the common shape for all domain events.
|
|
1983
|
+
* StoredEvent wraps an event with persistence metadata.
|
|
1984
|
+
*
|
|
1985
|
+
* These types are referenced by event-catalog.ts (domain events)
|
|
1986
|
+
* and bus-protocol.ts (the full EventMap).
|
|
1987
|
+
*/
|
|
1988
|
+
|
|
1989
|
+
/** Fields common to ALL domain events (system and resource-scoped). */
|
|
1990
|
+
interface EventBase {
|
|
1991
|
+
id: string;
|
|
1992
|
+
timestamp: string;
|
|
1993
|
+
resourceId?: ResourceId;
|
|
1994
|
+
userId: UserId;
|
|
1995
|
+
version: number;
|
|
1996
|
+
}
|
|
1997
|
+
/** Persistence metadata attached to every stored event. */
|
|
1998
|
+
type EventMetadata = components['schemas']['EventMetadata'];
|
|
1999
|
+
/** Optional cryptographic signature on a stored event. */
|
|
2000
|
+
interface EventSignature {
|
|
2001
|
+
algorithm: 'ed25519';
|
|
2002
|
+
publicKey: string;
|
|
2003
|
+
signature: string;
|
|
2004
|
+
keyId?: string;
|
|
2005
|
+
}
|
|
2006
|
+
/**
|
|
2007
|
+
* A domain event with persistence metadata.
|
|
2008
|
+
* Flat intersection — no nesting (event.type, not event.event.type).
|
|
2009
|
+
*/
|
|
2010
|
+
type StoredEvent<T extends EventBase = PersistedEvent> = T & {
|
|
2011
|
+
metadata: EventMetadata;
|
|
2012
|
+
signature?: EventSignature;
|
|
2013
|
+
};
|
|
2014
|
+
|
|
2015
|
+
/**
|
|
2016
|
+
* Bus Protocol
|
|
2017
|
+
*
|
|
2018
|
+
* The complete EventMap for the RxJS EventBus. Every channel name and
|
|
2019
|
+
* its payload type is defined here — domain events, commands, reads,
|
|
2020
|
+
* results, SSE stream payloads, and frontend UI events.
|
|
2021
|
+
*
|
|
2022
|
+
* Identifier discipline: where a payload carries an annotation or
|
|
2023
|
+
* resource id, the TypeScript layer narrows the OpenAPI `string` to the
|
|
2024
|
+
* branded type (`AnnotationId`, `ResourceId`, `UserId`). The runtime
|
|
2025
|
+
* wire shape is unchanged (brands have no runtime representation);
|
|
2026
|
+
* what this buys us is that command handlers don't have to re-brand
|
|
2027
|
+
* at every seam. Brand once at the entry boundary (HTTP route handler,
|
|
2028
|
+
* DOM attribute read, URL param parse), not at every bus hop in
|
|
2029
|
+
* between. See `.plans/BRAND-UPSTREAM.md` for the rationale.
|
|
2030
|
+
*
|
|
2031
|
+
* Organized by flow (verb), then by category within each flow.
|
|
2032
|
+
*/
|
|
2033
|
+
|
|
2034
|
+
type MarkDeleteCommand = components['schemas']['MarkDeleteCommand'] & {
|
|
2035
|
+
annotationId: AnnotationId;
|
|
2036
|
+
resourceId?: ResourceId;
|
|
2037
|
+
};
|
|
2038
|
+
type MarkUpdateBodyCommand = components['schemas']['MarkUpdateBodyCommand'] & {
|
|
2039
|
+
annotationId: AnnotationId;
|
|
2040
|
+
resourceId: ResourceId;
|
|
2041
|
+
};
|
|
2042
|
+
type BindInitiateCommand = components['schemas']['BindInitiateCommand'] & {
|
|
2043
|
+
annotationId: AnnotationId;
|
|
2044
|
+
resourceId: ResourceId;
|
|
2045
|
+
};
|
|
2046
|
+
type BindUpdateBodyCommand = components['schemas']['BindUpdateBodyCommand'] & {
|
|
2047
|
+
annotationId: AnnotationId;
|
|
2048
|
+
resourceId: ResourceId;
|
|
2049
|
+
};
|
|
2050
|
+
/**
|
|
2051
|
+
* The unified EventMap — every channel on the EventBus.
|
|
2052
|
+
*
|
|
2053
|
+
* Convention:
|
|
2054
|
+
* - Domain events (past tense): StoredEvent<Interface> — branded types
|
|
2055
|
+
* - Commands/reads/results/UI: OpenAPI schema refs — plain strings
|
|
2056
|
+
* - void: UI-only signals with no payload
|
|
2057
|
+
*/
|
|
2058
|
+
type EventMap = {
|
|
2059
|
+
'yield:created': StoredEvent<EventOfType<'yield:created'>>;
|
|
2060
|
+
'yield:cloned': StoredEvent<EventOfType<'yield:cloned'>>;
|
|
2061
|
+
'yield:updated': StoredEvent<EventOfType<'yield:updated'>>;
|
|
2062
|
+
'yield:moved': StoredEvent<EventOfType<'yield:moved'>>;
|
|
2063
|
+
'yield:representation-added': StoredEvent<EventOfType<'yield:representation-added'>>;
|
|
2064
|
+
'yield:representation-removed': StoredEvent<EventOfType<'yield:representation-removed'>>;
|
|
2065
|
+
'yield:create': components['schemas']['YieldCreateCommand'];
|
|
2066
|
+
'yield:update': components['schemas']['YieldUpdateCommand'];
|
|
2067
|
+
'yield:mv': components['schemas']['YieldMvCommand'];
|
|
2068
|
+
'yield:clone': void;
|
|
2069
|
+
'yield:clone-token-requested': components['schemas']['YieldCloneTokenRequest'];
|
|
2070
|
+
'yield:clone-resource-requested': components['schemas']['YieldCloneResourceRequest'];
|
|
2071
|
+
'yield:clone-create': components['schemas']['YieldCloneCreateCommand'];
|
|
2072
|
+
'yield:create-ok': components['schemas']['YieldCreateOk'];
|
|
2073
|
+
'yield:create-failed': components['schemas']['CommandError'];
|
|
2074
|
+
'yield:update-ok': components['schemas']['YieldUpdateOk'];
|
|
2075
|
+
'yield:update-failed': components['schemas']['CommandError'];
|
|
2076
|
+
'yield:move-failed': {
|
|
2077
|
+
fromUri: string;
|
|
2078
|
+
} & components['schemas']['CommandError'];
|
|
2079
|
+
'yield:clone-token-generated': {
|
|
2080
|
+
correlationId: string;
|
|
2081
|
+
response: components['schemas']['CloneResourceWithTokenResponse'];
|
|
2082
|
+
};
|
|
2083
|
+
'yield:clone-token-failed': {
|
|
2084
|
+
correlationId: string;
|
|
2085
|
+
} & components['schemas']['CommandError'];
|
|
2086
|
+
'yield:clone-resource-result': {
|
|
2087
|
+
correlationId: string;
|
|
2088
|
+
response: components['schemas']['GetResourceByTokenResponse'];
|
|
2089
|
+
};
|
|
2090
|
+
'yield:clone-resource-failed': {
|
|
2091
|
+
correlationId: string;
|
|
2092
|
+
} & components['schemas']['CommandError'];
|
|
2093
|
+
'yield:clone-created': components['schemas']['YieldCloneCreated'];
|
|
2094
|
+
'yield:clone-create-failed': {
|
|
2095
|
+
correlationId: string;
|
|
2096
|
+
} & components['schemas']['CommandError'];
|
|
2097
|
+
'mark:added': StoredEvent<EventOfType<'mark:added'>>;
|
|
2098
|
+
'mark:removed': StoredEvent<EventOfType<'mark:removed'>>;
|
|
2099
|
+
'mark:body-updated': StoredEvent<EventOfType<'mark:body-updated'>>;
|
|
2100
|
+
'mark:entity-tag-added': StoredEvent<EventOfType<'mark:entity-tag-added'>>;
|
|
2101
|
+
'mark:entity-tag-removed': StoredEvent<EventOfType<'mark:entity-tag-removed'>>;
|
|
2102
|
+
'mark:archived': StoredEvent<EventOfType<'mark:archived'>>;
|
|
2103
|
+
'mark:unarchived': StoredEvent<EventOfType<'mark:unarchived'>>;
|
|
2104
|
+
'mark:create-request': components['schemas']['MarkCreateRequest'];
|
|
2105
|
+
'mark:create': components['schemas']['MarkCreateCommand'];
|
|
2106
|
+
'mark:delete': MarkDeleteCommand;
|
|
2107
|
+
'mark:update-body': MarkUpdateBodyCommand;
|
|
2108
|
+
'mark:archive': components['schemas']['MarkArchiveCommand'];
|
|
2109
|
+
'mark:unarchive': components['schemas']['MarkUnarchiveCommand'];
|
|
2110
|
+
'mark:update-entity-types': components['schemas']['MarkUpdateEntityTypesCommand'];
|
|
2111
|
+
'mark:create-ok': components['schemas']['MarkCreateOk'];
|
|
2112
|
+
'mark:create-failed': components['schemas']['CommandError'];
|
|
2113
|
+
'mark:delete-ok': components['schemas']['MarkDeleteOk'];
|
|
2114
|
+
'mark:delete-failed': components['schemas']['CommandError'];
|
|
2115
|
+
'mark:archive-ok': {
|
|
2116
|
+
correlationId?: string;
|
|
2117
|
+
};
|
|
2118
|
+
'mark:archive-failed': components['schemas']['CommandError'];
|
|
2119
|
+
'mark:unarchive-ok': {
|
|
2120
|
+
correlationId?: string;
|
|
2121
|
+
};
|
|
2122
|
+
'mark:unarchive-failed': components['schemas']['CommandError'];
|
|
2123
|
+
'mark:update-entity-types-ok': {
|
|
2124
|
+
correlationId?: string;
|
|
2125
|
+
};
|
|
2126
|
+
'mark:update-entity-types-failed': components['schemas']['CommandError'];
|
|
2127
|
+
'mark:body-update-failed': components['schemas']['CommandError'];
|
|
2128
|
+
'mark:select-comment': components['schemas']['SelectionData'];
|
|
2129
|
+
'mark:select-tag': components['schemas']['SelectionData'];
|
|
2130
|
+
'mark:select-assessment': components['schemas']['SelectionData'];
|
|
2131
|
+
'mark:select-reference': components['schemas']['SelectionData'];
|
|
2132
|
+
'mark:requested': components['schemas']['MarkRequestedEvent'];
|
|
2133
|
+
'mark:cancel-pending': void;
|
|
2134
|
+
'mark:submit': components['schemas']['MarkSubmitEvent'];
|
|
2135
|
+
'mark:assist-request': components['schemas']['MarkAssistRequestEvent'];
|
|
2136
|
+
'mark:assist-cancelled': void;
|
|
2137
|
+
'mark:progress-dismiss': void;
|
|
2138
|
+
'frame:entity-type-added': StoredEvent<EventOfType<'frame:entity-type-added'>>;
|
|
2139
|
+
'frame:tag-schema-added': StoredEvent<EventOfType<'frame:tag-schema-added'>>;
|
|
2140
|
+
'frame:add-entity-type': components['schemas']['FrameAddEntityTypeCommand'];
|
|
2141
|
+
'frame:add-tag-schema': components['schemas']['FrameAddTagSchemaCommand'];
|
|
2142
|
+
'frame:entity-type-add-ok': {
|
|
2143
|
+
correlationId?: string;
|
|
2144
|
+
};
|
|
2145
|
+
'frame:entity-type-add-failed': components['schemas']['CommandError'];
|
|
2146
|
+
'frame:tag-schema-add-ok': {
|
|
2147
|
+
correlationId?: string;
|
|
2148
|
+
};
|
|
2149
|
+
'frame:tag-schema-add-failed': components['schemas']['CommandError'];
|
|
2150
|
+
'bind:initiate': BindInitiateCommand;
|
|
2151
|
+
'bind:update-body': BindUpdateBodyCommand;
|
|
2152
|
+
'bind:body-updated': components['schemas']['BindBodyUpdated'];
|
|
2153
|
+
'bind:body-update-failed': components['schemas']['CommandError'];
|
|
2154
|
+
'match:search-requested': components['schemas']['MatchSearchRequest'];
|
|
2155
|
+
'match:search-results': components['schemas']['MatchSearchResult'];
|
|
2156
|
+
'match:search-failed': components['schemas']['MatchSearchFailed'];
|
|
2157
|
+
'gather:requested': components['schemas']['GatherAnnotationRequest'];
|
|
2158
|
+
'gather:complete': components['schemas']['GatherAnnotationComplete'];
|
|
2159
|
+
'gather:failed': {
|
|
2160
|
+
correlationId: string;
|
|
2161
|
+
annotationId: string;
|
|
2162
|
+
} & components['schemas']['CommandError'];
|
|
2163
|
+
'gather:resource-requested': components['schemas']['GatherResourceRequest'];
|
|
2164
|
+
'gather:resource-complete': components['schemas']['GatherResourceComplete'];
|
|
2165
|
+
'gather:resource-failed': {
|
|
2166
|
+
correlationId: string;
|
|
2167
|
+
resourceId: string;
|
|
2168
|
+
} & components['schemas']['CommandError'];
|
|
2169
|
+
'gather:summary-requested': components['schemas']['GatherSummaryRequest'];
|
|
2170
|
+
'gather:summary-result': {
|
|
2171
|
+
correlationId: string;
|
|
2172
|
+
response: Record<string, unknown>;
|
|
2173
|
+
};
|
|
2174
|
+
'gather:summary-failed': {
|
|
2175
|
+
correlationId: string;
|
|
2176
|
+
} & components['schemas']['CommandError'];
|
|
2177
|
+
'gather:annotation-progress': components['schemas']['GatherProgress'];
|
|
2178
|
+
'browse:resource-requested': components['schemas']['BrowseResourceRequest'];
|
|
2179
|
+
'browse:resource-result': components['schemas']['BrowseResourceResult'];
|
|
2180
|
+
'browse:resource-failed': {
|
|
2181
|
+
correlationId: string;
|
|
2182
|
+
} & components['schemas']['CommandError'];
|
|
2183
|
+
'browse:resources-requested': components['schemas']['BrowseResourcesRequest'];
|
|
2184
|
+
'browse:resources-result': components['schemas']['BrowseResourcesResult'];
|
|
2185
|
+
'browse:resources-failed': {
|
|
2186
|
+
correlationId: string;
|
|
2187
|
+
} & components['schemas']['CommandError'];
|
|
2188
|
+
'browse:annotations-requested': components['schemas']['BrowseAnnotationsRequest'];
|
|
2189
|
+
'browse:annotations-result': components['schemas']['BrowseAnnotationsResult'];
|
|
2190
|
+
'browse:annotations-failed': {
|
|
2191
|
+
correlationId: string;
|
|
2192
|
+
} & components['schemas']['CommandError'];
|
|
2193
|
+
'browse:annotation-requested': components['schemas']['BrowseAnnotationRequest'];
|
|
2194
|
+
'browse:annotation-result': components['schemas']['BrowseAnnotationResult'];
|
|
2195
|
+
'browse:annotation-failed': {
|
|
2196
|
+
correlationId: string;
|
|
2197
|
+
} & components['schemas']['CommandError'];
|
|
2198
|
+
'browse:events-requested': components['schemas']['BrowseEventsRequest'];
|
|
2199
|
+
'browse:events-result': components['schemas']['BrowseEventsResult'];
|
|
2200
|
+
'browse:events-failed': {
|
|
2201
|
+
correlationId: string;
|
|
2202
|
+
} & components['schemas']['CommandError'];
|
|
2203
|
+
'browse:annotation-history-requested': components['schemas']['BrowseAnnotationHistoryRequest'];
|
|
2204
|
+
'browse:annotation-history-result': components['schemas']['BrowseAnnotationHistoryResult'];
|
|
2205
|
+
'browse:annotation-history-failed': {
|
|
2206
|
+
correlationId: string;
|
|
2207
|
+
} & components['schemas']['CommandError'];
|
|
2208
|
+
'browse:annotation-context-requested': components['schemas']['BrowseAnnotationContextRequest'];
|
|
2209
|
+
'browse:annotation-context-result': {
|
|
2210
|
+
correlationId: string;
|
|
2211
|
+
response: Record<string, unknown>;
|
|
2212
|
+
};
|
|
2213
|
+
'browse:annotation-context-failed': {
|
|
2214
|
+
correlationId: string;
|
|
2215
|
+
} & components['schemas']['CommandError'];
|
|
2216
|
+
'browse:referenced-by-requested': components['schemas']['BrowseReferencedByRequest'];
|
|
2217
|
+
'browse:referenced-by-result': components['schemas']['BrowseReferencedByResult'];
|
|
2218
|
+
'browse:referenced-by-failed': {
|
|
2219
|
+
correlationId: string;
|
|
2220
|
+
} & components['schemas']['CommandError'];
|
|
2221
|
+
'browse:entity-types-requested': components['schemas']['BrowseEntityTypesRequest'];
|
|
2222
|
+
'browse:entity-types-result': components['schemas']['BrowseEntityTypesResult'];
|
|
2223
|
+
'browse:entity-types-failed': {
|
|
2224
|
+
correlationId: string;
|
|
2225
|
+
} & components['schemas']['CommandError'];
|
|
2226
|
+
'browse:tag-schemas-requested': components['schemas']['BrowseTagSchemasRequest'];
|
|
2227
|
+
'browse:tag-schemas-result': components['schemas']['BrowseTagSchemasResult'];
|
|
2228
|
+
'browse:tag-schemas-failed': {
|
|
2229
|
+
correlationId: string;
|
|
2230
|
+
} & components['schemas']['CommandError'];
|
|
2231
|
+
'browse:agents-requested': components['schemas']['BrowseAgentsRequest'];
|
|
2232
|
+
'browse:agents-result': components['schemas']['BrowseAgentsResult'];
|
|
2233
|
+
'browse:agents-failed': {
|
|
2234
|
+
correlationId: string;
|
|
2235
|
+
} & components['schemas']['CommandError'];
|
|
2236
|
+
'browse:directory-requested': components['schemas']['BrowseDirectoryRequest'];
|
|
2237
|
+
'browse:directory-result': components['schemas']['BrowseDirectoryResult'];
|
|
2238
|
+
'browse:directory-failed': {
|
|
2239
|
+
correlationId: string;
|
|
2240
|
+
path: string;
|
|
2241
|
+
} & components['schemas']['CommandError'];
|
|
2242
|
+
'browse:click': components['schemas']['BrowseClickEvent'];
|
|
2243
|
+
'browse:reference-navigate': components['schemas']['BrowseReferenceNavigateEvent'];
|
|
2244
|
+
'browse:entity-type-clicked': components['schemas']['BrowseEntityTypeClickedEvent'];
|
|
2245
|
+
'panel:toggle': components['schemas']['BrowsePanelToggleEvent'];
|
|
2246
|
+
'panel:open': components['schemas']['BrowsePanelOpenEvent'];
|
|
2247
|
+
'panel:close': void;
|
|
2248
|
+
'shell:sidebar-toggle': void;
|
|
2249
|
+
'tabs:close': components['schemas']['BrowseResourceCloseEvent'];
|
|
2250
|
+
'tabs:reorder': components['schemas']['BrowseResourceReorderEvent'];
|
|
2251
|
+
'nav:link-clicked': components['schemas']['BrowseLinkClickedEvent'];
|
|
2252
|
+
'nav:push': components['schemas']['BrowseRouterPushEvent'];
|
|
2253
|
+
'nav:external': components['schemas']['BrowseExternalNavigateEvent'] & {
|
|
2254
|
+
cancelFallback: () => void;
|
|
2255
|
+
};
|
|
2256
|
+
'beckon:hover': components['schemas']['BeckonHoverEvent'];
|
|
2257
|
+
'beckon:focus': components['schemas']['BeckonFocusEvent'];
|
|
2258
|
+
'beckon:sparkle': components['schemas']['BeckonSparkleEvent'];
|
|
2259
|
+
'job:started': StoredEvent<EventOfType<'job:started'>>;
|
|
2260
|
+
'job:progress': StoredEvent<EventOfType<'job:progress'>>;
|
|
2261
|
+
'job:completed': StoredEvent<EventOfType<'job:completed'>>;
|
|
2262
|
+
'job:failed': StoredEvent<EventOfType<'job:failed'>>;
|
|
2263
|
+
'job:start': components['schemas']['JobStartCommand'];
|
|
2264
|
+
'job:report-progress': components['schemas']['JobReportProgressCommand'];
|
|
2265
|
+
'job:complete': components['schemas']['JobCompleteCommand'];
|
|
2266
|
+
'job:fail': components['schemas']['JobFailCommand'];
|
|
2267
|
+
'job:queued': components['schemas']['JobQueuedEvent'];
|
|
2268
|
+
'job:cancel-requested': components['schemas']['JobCancelRequest'];
|
|
2269
|
+
'job:status-requested': components['schemas']['JobStatusRequest'];
|
|
2270
|
+
'job:create': components['schemas']['JobCreateCommand'];
|
|
2271
|
+
'job:claim': components['schemas']['JobClaimCommand'];
|
|
2272
|
+
'job:status-result': components['schemas']['JobStatusResult'];
|
|
2273
|
+
'job:status-failed': {
|
|
2274
|
+
correlationId: string;
|
|
2275
|
+
} & components['schemas']['CommandError'];
|
|
2276
|
+
'job:created': components['schemas']['JobCreatedResult'];
|
|
2277
|
+
'job:create-failed': {
|
|
2278
|
+
correlationId: string;
|
|
2279
|
+
} & components['schemas']['CommandError'];
|
|
2280
|
+
'job:claimed': {
|
|
2281
|
+
correlationId: string;
|
|
2282
|
+
response: Record<string, unknown>;
|
|
2283
|
+
};
|
|
2284
|
+
'job:claim-failed': {
|
|
2285
|
+
correlationId: string;
|
|
2286
|
+
} & components['schemas']['CommandError'];
|
|
2287
|
+
'job:cancel-ok': {
|
|
2288
|
+
correlationId?: string;
|
|
2289
|
+
response: {
|
|
2290
|
+
cancelled: number;
|
|
2291
|
+
};
|
|
2292
|
+
};
|
|
2293
|
+
'job:cancel-failed': components['schemas']['CommandError'];
|
|
2294
|
+
'settings:theme-changed': components['schemas']['SettingsThemeChangedEvent'];
|
|
2295
|
+
'settings:line-numbers-toggled': void;
|
|
2296
|
+
'settings:locale-changed': components['schemas']['SettingsLocaleChangedEvent'];
|
|
2297
|
+
'settings:hover-delay-changed': components['schemas']['SettingsHoverDelayChangedEvent'];
|
|
2298
|
+
'stream-connected': Record<string, never>;
|
|
2299
|
+
'replay-window-exceeded': {
|
|
2300
|
+
resourceId?: string;
|
|
2301
|
+
lastEventId: number;
|
|
2302
|
+
missedCount: number;
|
|
2303
|
+
cap: number;
|
|
2304
|
+
message: string;
|
|
2305
|
+
};
|
|
2306
|
+
/**
|
|
2307
|
+
* Emitted by the `/bus/subscribe` handler when a client reconnected
|
|
2308
|
+
* with `Last-Event-ID: p-<scope>-<seq>` but the server could not
|
|
2309
|
+
* replay all missed persisted events for that scope (retention
|
|
2310
|
+
* window exceeded, scope unknown, or request unparseable). The
|
|
2311
|
+
* client should treat this as a signal to fall back to the pre-
|
|
2312
|
+
* resumption contract: invalidate caches for the affected scope
|
|
2313
|
+
* and re-read from scratch. Analogous to `replay-window-exceeded`
|
|
2314
|
+
* but scoped to the bus gateway rather than the per-resource
|
|
2315
|
+
* events stream.
|
|
2316
|
+
*
|
|
2317
|
+
* `scope` is the scope string the client asked about (omitted for
|
|
2318
|
+
* global-persisted resumption gaps, if that path ever exists).
|
|
2319
|
+
* `reason` is human-readable, for logging.
|
|
2320
|
+
*/
|
|
2321
|
+
'bus:resume-gap': {
|
|
2322
|
+
scope?: string;
|
|
2323
|
+
lastSeenId?: string;
|
|
2324
|
+
reason: string;
|
|
2325
|
+
};
|
|
2326
|
+
};
|
|
2327
|
+
|
|
2328
|
+
/**
|
|
2329
|
+
* RxJS-based Event Bus
|
|
2330
|
+
*
|
|
2331
|
+
* Framework-agnostic event bus providing direct access to typed RxJS Subjects.
|
|
2332
|
+
*
|
|
2333
|
+
* Can be used in Node.js, browser, workers, CLI - anywhere RxJS runs.
|
|
2334
|
+
*/
|
|
2335
|
+
|
|
2336
|
+
/**
|
|
2337
|
+
* RxJS-based event bus
|
|
2338
|
+
*
|
|
2339
|
+
* Provides direct access to RxJS Subjects for each event type.
|
|
2340
|
+
* Use standard RxJS patterns for emitting and subscribing.
|
|
2341
|
+
*
|
|
2342
|
+
* @example
|
|
2343
|
+
* ```typescript
|
|
2344
|
+
* const eventBus = new EventBus();
|
|
2345
|
+
*
|
|
2346
|
+
* // Emit events
|
|
2347
|
+
* eventBus.get('beckon:hover').next({ annotationId: 'ann-1' });
|
|
2348
|
+
*
|
|
2349
|
+
* // Subscribe to events
|
|
2350
|
+
* const subscription = eventBus.get('beckon:hover').subscribe(({ annotationId }) => {
|
|
2351
|
+
* console.log('Hover:', annotationId);
|
|
2352
|
+
* });
|
|
2353
|
+
*
|
|
2354
|
+
* // Use RxJS operators
|
|
2355
|
+
* import { debounceTime } from 'rxjs/operators';
|
|
2356
|
+
* eventBus.get('beckon:hover')
|
|
2357
|
+
* .pipe(debounceTime(100))
|
|
2358
|
+
* .subscribe(handleHover);
|
|
2359
|
+
*
|
|
2360
|
+
* // Cleanup
|
|
2361
|
+
* subscription.unsubscribe();
|
|
2362
|
+
* eventBus.destroy();
|
|
2363
|
+
* ```
|
|
2364
|
+
*/
|
|
2365
|
+
declare class EventBus {
|
|
2366
|
+
private subjects;
|
|
2367
|
+
private isDestroyed;
|
|
2368
|
+
constructor();
|
|
2369
|
+
/**
|
|
2370
|
+
* Get the RxJS Subject for an event
|
|
2371
|
+
*
|
|
2372
|
+
* Returns a typed Subject that can be used with all RxJS operators.
|
|
2373
|
+
* Subjects are created lazily on first access.
|
|
2374
|
+
*
|
|
2375
|
+
* @param eventName - The event name
|
|
2376
|
+
* @returns The RxJS Subject for this event
|
|
2377
|
+
*
|
|
2378
|
+
* @example
|
|
2379
|
+
* ```typescript
|
|
2380
|
+
* // Emit
|
|
2381
|
+
* eventBus.get('beckon:hover').next({ annotationId: 'ann-1' });
|
|
2382
|
+
*
|
|
2383
|
+
* // Subscribe
|
|
2384
|
+
* const sub = eventBus.get('beckon:hover').subscribe(handleHover);
|
|
2385
|
+
*
|
|
2386
|
+
* // With operators
|
|
2387
|
+
* eventBus.get('beckon:hover')
|
|
2388
|
+
* .pipe(debounceTime(100), distinctUntilChanged())
|
|
2389
|
+
* .subscribe(handleHover);
|
|
2390
|
+
* ```
|
|
2391
|
+
*/
|
|
2392
|
+
get<K extends keyof EventMap>(eventName: K): Subject<EventMap[K]>;
|
|
2393
|
+
/**
|
|
2394
|
+
* Get the RxJS Subject for a domain event type (PersistedEventType).
|
|
2395
|
+
*
|
|
2396
|
+
* Domain event channels carry `StoredEvent`. This method avoids the need
|
|
2397
|
+
* for `as keyof EventMap` casts when subscribing to domain event channels
|
|
2398
|
+
* using runtime `PersistedEventType` strings.
|
|
2399
|
+
*/
|
|
2400
|
+
getDomainEvent(eventType: PersistedEventType): Subject<StoredEvent>;
|
|
2401
|
+
/**
|
|
2402
|
+
* Destroy the event bus and complete all subjects
|
|
2403
|
+
*
|
|
2404
|
+
* After calling destroy(), no new events can be emitted or subscribed to.
|
|
2405
|
+
* All active subscriptions will be completed.
|
|
2406
|
+
*/
|
|
2407
|
+
destroy(): void;
|
|
2408
|
+
/**
|
|
2409
|
+
* Check if the event bus has been destroyed
|
|
2410
|
+
*/
|
|
2411
|
+
get destroyed(): boolean;
|
|
2412
|
+
/**
|
|
2413
|
+
* Create a resource-scoped event bus
|
|
2414
|
+
*
|
|
2415
|
+
* Events emitted or subscribed through the scoped bus are isolated to that resource.
|
|
2416
|
+
* Internally, events are namespaced but the API remains identical to the parent bus.
|
|
2417
|
+
*
|
|
2418
|
+
* @param resourceId - Resource identifier to scope events to
|
|
2419
|
+
* @returns A scoped event bus for this resource
|
|
2420
|
+
*
|
|
2421
|
+
* @example
|
|
2422
|
+
* ```typescript
|
|
2423
|
+
* const eventBus = new EventBus();
|
|
2424
|
+
* const resource1 = eventBus.scope('resource-1');
|
|
2425
|
+
* const resource2 = eventBus.scope('resource-2');
|
|
2426
|
+
*
|
|
2427
|
+
* // These are isolated - only resource1 subscribers will fire
|
|
2428
|
+
* resource1.get('detection:progress').next({ status: 'started' });
|
|
2429
|
+
* ```
|
|
2430
|
+
*/
|
|
2431
|
+
scope(resourceId: string): ScopedEventBus;
|
|
2432
|
+
}
|
|
2433
|
+
/**
|
|
2434
|
+
* Resource-scoped event bus
|
|
2435
|
+
*
|
|
2436
|
+
* Provides isolated event streams per resource while maintaining the same API
|
|
2437
|
+
* as the parent EventBus. Events are internally namespaced by resourceId.
|
|
2438
|
+
*/
|
|
2439
|
+
declare class ScopedEventBus {
|
|
2440
|
+
private parent;
|
|
2441
|
+
private scopePrefix;
|
|
2442
|
+
constructor(parent: EventBus, scopePrefix: string);
|
|
2443
|
+
/**
|
|
2444
|
+
* Get the RxJS Subject for a scoped event
|
|
2445
|
+
*
|
|
2446
|
+
* Returns the same type as the parent bus, but events are isolated to this scope.
|
|
2447
|
+
* Internally uses namespaced keys but preserves type safety.
|
|
2448
|
+
*
|
|
2449
|
+
* @param event - The event name
|
|
2450
|
+
* @returns The RxJS Subject for this scoped event
|
|
2451
|
+
*/
|
|
2452
|
+
get<E extends keyof EventMap>(event: E): Subject<EventMap[E]>;
|
|
2453
|
+
/** Get the RxJS Subject for a domain event type on this scoped bus. */
|
|
2454
|
+
getDomainEvent(eventType: PersistedEventType): Subject<StoredEvent>;
|
|
2455
|
+
/**
|
|
2456
|
+
* Create a nested scope
|
|
2457
|
+
*
|
|
2458
|
+
* Allows hierarchical scoping like `resource-1:subsystem-a`
|
|
2459
|
+
*
|
|
2460
|
+
* @param subScope - Additional scope level
|
|
2461
|
+
* @returns A nested scoped event bus
|
|
2462
|
+
*/
|
|
2463
|
+
scope(subScope: string): ScopedEventBus;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2466
|
+
/**
|
|
2467
|
+
* Transport interfaces — the shared contract for any wire-or-local
|
|
2468
|
+
* communication path consumed by `SemiontClient`. Concrete implementations
|
|
2469
|
+
* live alongside the runtime they wrap (`HttpTransport` in
|
|
2470
|
+
* `@semiont/http-transport`, in-process variants in `@semiont/make-meaning`,
|
|
2471
|
+
* etc.).
|
|
2472
|
+
*
|
|
2473
|
+
* Three interfaces:
|
|
2474
|
+
*
|
|
2475
|
+
* ITransport — bus primitives + lifecycle. Universal: every
|
|
2476
|
+
* concrete transport implements this.
|
|
2477
|
+
* IBackendOperations — auth, admin, exchange, system endpoints.
|
|
2478
|
+
* HTTP-shaped today; an in-process transport may
|
|
2479
|
+
* implement none, some, or a different set.
|
|
2480
|
+
* Optional on `SemiontClient` — passed only when
|
|
2481
|
+
* the host has a backend that supports them.
|
|
2482
|
+
* IContentTransport — binary I/O (putBinary / getBinary). Narrow by
|
|
2483
|
+
* design because binary has different backpressure
|
|
2484
|
+
* and streaming characteristics.
|
|
2485
|
+
*
|
|
2486
|
+
* The behavioral guarantees every implementation must honor are documented
|
|
2487
|
+
* in `docs/protocol/TRANSPORT-CONTRACT.md`.
|
|
2488
|
+
*/
|
|
2489
|
+
|
|
2490
|
+
/**
|
|
2491
|
+
* Six-state lifecycle for a transport's connection. Drives UI affordances
|
|
2492
|
+
* (connecting spinners, reconnecting banners, etc.) and is observed via
|
|
2493
|
+
* `ITransport.state$`.
|
|
2494
|
+
*
|
|
2495
|
+
* initial ─ pre-`start()`; never enters subscribers' streams
|
|
2496
|
+
* except as the first replayed value
|
|
2497
|
+
* connecting ─ in-flight initial open
|
|
2498
|
+
* open ─ healthy, delivering events
|
|
2499
|
+
* reconnecting ─ open → dropped, retrying; may be transient
|
|
2500
|
+
* degraded ─ has been reconnecting for > DEGRADED_THRESHOLD_MS;
|
|
2501
|
+
* UI banner threshold; distinguishes brief mount-
|
|
2502
|
+
* churn cycles from sustained disconnection
|
|
2503
|
+
* closed ─ stop()/dispose() called; terminal
|
|
2504
|
+
*/
|
|
2505
|
+
type ConnectionState = 'initial' | 'connecting' | 'open' | 'reconnecting' | 'degraded' | 'closed';
|
|
2506
|
+
interface ITransport {
|
|
2507
|
+
/**
|
|
2508
|
+
* Base URL the transport speaks to. For HTTP this is `https://host[:port]`;
|
|
2509
|
+
* for in-process transports, an opaque identifier (e.g. `local://kb-id`).
|
|
2510
|
+
*/
|
|
2511
|
+
readonly baseUrl: BaseUrl;
|
|
2512
|
+
/**
|
|
2513
|
+
* Publish a payload on the named channel.
|
|
2514
|
+
*
|
|
2515
|
+
* `resourceScope`, when set, marks the emit as a resource-scoped
|
|
2516
|
+
* broadcast — only delivered to subscribers attached to that
|
|
2517
|
+
* resource's scope.
|
|
2518
|
+
*/
|
|
2519
|
+
emit<K extends keyof EventMap>(channel: K, payload: EventMap[K], resourceScope?: ResourceId): Promise<void>;
|
|
2520
|
+
on<K extends keyof EventMap>(channel: K, handler: (payload: EventMap[K]) => void): () => void;
|
|
2521
|
+
stream<K extends keyof EventMap>(channel: K): Observable<EventMap[K]>;
|
|
2522
|
+
/**
|
|
2523
|
+
* Subscribe to a resource-scoped channel set. HTTP attaches a scope to
|
|
2524
|
+
* its SSE connection; in-process transports may be a no-op because
|
|
2525
|
+
* local events are delivered without scoping.
|
|
2526
|
+
*
|
|
2527
|
+
* Returns a disposer that detaches the scope when the last subscriber
|
|
2528
|
+
* unsubscribes (ref-counted).
|
|
2529
|
+
*
|
|
2530
|
+
* SDK-internal: this is the scope primitive the SDK's resource-scoped
|
|
2531
|
+
* `browse.*` live queries drive on subscribe/teardown (freshness follows
|
|
2532
|
+
* observation; #847) — it is not part of the application-facing surface.
|
|
2533
|
+
* Single-scope at a time; multi-scope is deferred
|
|
2534
|
+
* (`.plans/MULTI-RESOURCE-SCOPE.md`).
|
|
2535
|
+
*/
|
|
2536
|
+
subscribeToResource(resourceId: ResourceId): () => void;
|
|
2537
|
+
/**
|
|
2538
|
+
* Hand the given bus to the transport so the transport can publish
|
|
2539
|
+
* the events it receives into it. The reference flows
|
|
2540
|
+
* client → transport (the client owns the bus); transports never
|
|
2541
|
+
* construct or replace it. Concrete transports decide what "receives"
|
|
2542
|
+
* means: HTTP bridges every channel it observes on its SSE wire;
|
|
2543
|
+
* an in-process transport bridges from the local actor bus.
|
|
2544
|
+
*/
|
|
2545
|
+
bridgeInto(bus: EventBus): void;
|
|
2546
|
+
/**
|
|
2547
|
+
* Transport-level connection state. For HTTP, reflects the SSE
|
|
2548
|
+
* connection's health; for in-process transports, typically `'open'`
|
|
2549
|
+
* from construction onward (no connection to lose).
|
|
2550
|
+
*/
|
|
2551
|
+
readonly state$: Observable<ConnectionState>;
|
|
2552
|
+
/**
|
|
2553
|
+
* Stream of transport-level errors surfaced from typed-wire methods or
|
|
2554
|
+
* other transport-mediated round-trips, just before they're thrown to
|
|
2555
|
+
* the caller. Each emission is a `SemiontError` (or subclass — HTTP
|
|
2556
|
+
* emits `APIError`, in-process transports emit whatever subclass is
|
|
2557
|
+
* appropriate). Consumers can subscribe for global error handling
|
|
2558
|
+
* (e.g. surfacing 401/403 as modals, logging) without wrapping every
|
|
2559
|
+
* call site in try/catch. Distinct from bus-level errors, which are
|
|
2560
|
+
* surfaced via the channel-correlation pattern in `busRequest`.
|
|
2561
|
+
*/
|
|
2562
|
+
readonly errors$: Observable<SemiontError>;
|
|
2563
|
+
dispose(): void;
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
declare const BUS_OPERATIONS: {
|
|
2567
|
+
readonly 'bind:update-body': {
|
|
2568
|
+
readonly result: "bind:body-updated";
|
|
2569
|
+
readonly failure: "bind:body-update-failed";
|
|
2570
|
+
};
|
|
2571
|
+
readonly 'browse:resource-requested': {
|
|
2572
|
+
readonly result: "browse:resource-result";
|
|
2573
|
+
readonly failure: "browse:resource-failed";
|
|
2574
|
+
};
|
|
2575
|
+
readonly 'browse:resources-requested': {
|
|
2576
|
+
readonly result: "browse:resources-result";
|
|
2577
|
+
readonly failure: "browse:resources-failed";
|
|
2578
|
+
};
|
|
2579
|
+
readonly 'browse:annotation-requested': {
|
|
2580
|
+
readonly result: "browse:annotation-result";
|
|
2581
|
+
readonly failure: "browse:annotation-failed";
|
|
2582
|
+
};
|
|
2583
|
+
readonly 'browse:annotations-requested': {
|
|
2584
|
+
readonly result: "browse:annotations-result";
|
|
2585
|
+
readonly failure: "browse:annotations-failed";
|
|
2586
|
+
};
|
|
2587
|
+
readonly 'browse:annotation-history-requested': {
|
|
2588
|
+
readonly result: "browse:annotation-history-result";
|
|
2589
|
+
readonly failure: "browse:annotation-history-failed";
|
|
2590
|
+
};
|
|
2591
|
+
readonly 'browse:events-requested': {
|
|
2592
|
+
readonly result: "browse:events-result";
|
|
2593
|
+
readonly failure: "browse:events-failed";
|
|
2594
|
+
};
|
|
2595
|
+
readonly 'browse:referenced-by-requested': {
|
|
2596
|
+
readonly result: "browse:referenced-by-result";
|
|
2597
|
+
readonly failure: "browse:referenced-by-failed";
|
|
2598
|
+
};
|
|
2599
|
+
readonly 'browse:entity-types-requested': {
|
|
2600
|
+
readonly result: "browse:entity-types-result";
|
|
2601
|
+
readonly failure: "browse:entity-types-failed";
|
|
2602
|
+
};
|
|
2603
|
+
readonly 'browse:tag-schemas-requested': {
|
|
2604
|
+
readonly result: "browse:tag-schemas-result";
|
|
2605
|
+
readonly failure: "browse:tag-schemas-failed";
|
|
2606
|
+
};
|
|
2607
|
+
readonly 'browse:agents-requested': {
|
|
2608
|
+
readonly result: "browse:agents-result";
|
|
2609
|
+
readonly failure: "browse:agents-failed";
|
|
2610
|
+
};
|
|
2611
|
+
readonly 'browse:directory-requested': {
|
|
2612
|
+
readonly result: "browse:directory-result";
|
|
2613
|
+
readonly failure: "browse:directory-failed";
|
|
2614
|
+
};
|
|
2615
|
+
readonly 'browse:annotation-context-requested': {
|
|
2616
|
+
readonly result: "browse:annotation-context-result";
|
|
2617
|
+
readonly failure: "browse:annotation-context-failed";
|
|
2618
|
+
};
|
|
2619
|
+
readonly 'frame:add-entity-type': {
|
|
2620
|
+
readonly result: "frame:entity-type-add-ok";
|
|
2621
|
+
readonly failure: "frame:entity-type-add-failed";
|
|
2622
|
+
};
|
|
2623
|
+
readonly 'frame:add-tag-schema': {
|
|
2624
|
+
readonly result: "frame:tag-schema-add-ok";
|
|
2625
|
+
readonly failure: "frame:tag-schema-add-failed";
|
|
2626
|
+
};
|
|
2627
|
+
readonly 'gather:requested': {
|
|
2628
|
+
readonly result: "gather:complete";
|
|
2629
|
+
readonly failure: "gather:failed";
|
|
2630
|
+
readonly progress: "gather:annotation-progress";
|
|
2631
|
+
};
|
|
2632
|
+
readonly 'gather:resource-requested': {
|
|
2633
|
+
readonly result: "gather:resource-complete";
|
|
2634
|
+
readonly failure: "gather:resource-failed";
|
|
2635
|
+
};
|
|
2636
|
+
readonly 'gather:summary-requested': {
|
|
2637
|
+
readonly result: "gather:summary-result";
|
|
2638
|
+
readonly failure: "gather:summary-failed";
|
|
2639
|
+
};
|
|
2640
|
+
readonly 'job:create': {
|
|
2641
|
+
readonly result: "job:created";
|
|
2642
|
+
readonly failure: "job:create-failed";
|
|
2643
|
+
};
|
|
2644
|
+
readonly 'job:status-requested': {
|
|
2645
|
+
readonly result: "job:status-result";
|
|
2646
|
+
readonly failure: "job:status-failed";
|
|
2647
|
+
};
|
|
2648
|
+
readonly 'job:cancel-requested': {
|
|
2649
|
+
readonly result: "job:cancel-ok";
|
|
2650
|
+
readonly failure: "job:cancel-failed";
|
|
2651
|
+
};
|
|
2652
|
+
readonly 'job:claim': {
|
|
2653
|
+
readonly result: "job:claimed";
|
|
2654
|
+
readonly failure: "job:claim-failed";
|
|
2655
|
+
};
|
|
2656
|
+
readonly 'mark:create-request': {
|
|
2657
|
+
readonly result: "mark:create-ok";
|
|
2658
|
+
readonly failure: "mark:create-failed";
|
|
2659
|
+
};
|
|
2660
|
+
readonly 'mark:delete': {
|
|
2661
|
+
readonly result: "mark:delete-ok";
|
|
2662
|
+
readonly failure: "mark:delete-failed";
|
|
2663
|
+
};
|
|
2664
|
+
readonly 'mark:archive': {
|
|
2665
|
+
readonly result: "mark:archive-ok";
|
|
2666
|
+
readonly failure: "mark:archive-failed";
|
|
2667
|
+
};
|
|
2668
|
+
readonly 'mark:unarchive': {
|
|
2669
|
+
readonly result: "mark:unarchive-ok";
|
|
2670
|
+
readonly failure: "mark:unarchive-failed";
|
|
2671
|
+
};
|
|
2672
|
+
readonly 'mark:update-entity-types': {
|
|
2673
|
+
readonly result: "mark:update-entity-types-ok";
|
|
2674
|
+
readonly failure: "mark:update-entity-types-failed";
|
|
2675
|
+
};
|
|
2676
|
+
readonly 'match:search-requested': {
|
|
2677
|
+
readonly result: "match:search-results";
|
|
2678
|
+
readonly failure: "match:search-failed";
|
|
2679
|
+
};
|
|
2680
|
+
readonly 'yield:create': {
|
|
2681
|
+
readonly result: "yield:create-ok";
|
|
2682
|
+
readonly failure: "yield:create-failed";
|
|
2683
|
+
};
|
|
2684
|
+
readonly 'yield:update': {
|
|
2685
|
+
readonly result: "yield:update-ok";
|
|
2686
|
+
readonly failure: "yield:update-failed";
|
|
2687
|
+
};
|
|
2688
|
+
readonly 'yield:clone-create': {
|
|
2689
|
+
readonly result: "yield:clone-created";
|
|
2690
|
+
readonly failure: "yield:clone-create-failed";
|
|
2691
|
+
};
|
|
2692
|
+
readonly 'yield:clone-resource-requested': {
|
|
2693
|
+
readonly result: "yield:clone-resource-result";
|
|
2694
|
+
readonly failure: "yield:clone-resource-failed";
|
|
2695
|
+
};
|
|
2696
|
+
readonly 'yield:clone-token-requested': {
|
|
2697
|
+
readonly result: "yield:clone-token-generated";
|
|
2698
|
+
readonly failure: "yield:clone-token-failed";
|
|
2699
|
+
};
|
|
2700
|
+
};
|
|
2701
|
+
/** The request-channel key of a registered operation — what `busRequest` takes. */
|
|
2702
|
+
type BusOperationKey = keyof typeof BUS_OPERATIONS;
|
|
2703
|
+
|
|
2704
|
+
/**
|
|
2705
|
+
* FaultyTransport — a seeded, scriptable `ITransport` simulator for the
|
|
2706
|
+
* liveness axioms (`.plans/LIVENESS-AXIOMS.md`). fast-check draws a fault
|
|
2707
|
+
* schedule; the transport applies one `FaultAction` per request-channel emit
|
|
2708
|
+
* and synthesizes replies from the `BUS_OPERATIONS` registry, so real
|
|
2709
|
+
* compositions (`busRequest`, SWR caches, live queries) run unmodified against
|
|
2710
|
+
* generated wire behavior no hand-written test names.
|
|
2711
|
+
*
|
|
2712
|
+
* Home is core (not sdk/test-utils) for the same reason as
|
|
2713
|
+
* `assertStateUnitAxioms`: it needs only core types, and every layer —
|
|
2714
|
+
* including `http-transport`, below sdk — can consume it via
|
|
2715
|
+
* `@semiont/core/testing` without a dependency cycle.
|
|
2716
|
+
*
|
|
2717
|
+
* Deterministic-by-construction: no `Date.now`, no randomness of its own —
|
|
2718
|
+
* all variation comes in through the schedule (fast-check owns the seed).
|
|
2719
|
+
* Time is real `setTimeout` at millisecond scale; properties pass a small
|
|
2720
|
+
* explicit `timeoutMs` to `busRequest`, so nothing waits 30 s.
|
|
2721
|
+
*/
|
|
2722
|
+
|
|
2723
|
+
/** One wire behavior, applied to a single request-channel emit. */
|
|
2724
|
+
type FaultAction = {
|
|
2725
|
+
kind: 'deliver';
|
|
2726
|
+
} | {
|
|
2727
|
+
kind: 'drop-reply';
|
|
2728
|
+
} | {
|
|
2729
|
+
kind: 'delay';
|
|
2730
|
+
ms: number;
|
|
2731
|
+
} | {
|
|
2732
|
+
kind: 'duplicate-reply';
|
|
2733
|
+
} | {
|
|
2734
|
+
kind: 'reject-emit';
|
|
2735
|
+
};
|
|
2736
|
+
/**
|
|
2737
|
+
* Scope-contention behavior of `subscribeToResource`:
|
|
2738
|
+
* `single-slot-throw` mirrors today's HttpTransport (one distinct scope at a
|
|
2739
|
+
* time; a second distinct scope throws); `multi` mirrors the
|
|
2740
|
+
* post-MULTI-RESOURCE-SCOPE world. The same properties run under both so the
|
|
2741
|
+
* migration can't silently change liveness behavior.
|
|
2742
|
+
*/
|
|
2743
|
+
type ScopeModel = 'single-slot-throw' | 'multi';
|
|
2744
|
+
/** requestLog entry — one per request-channel emit, in arrival order. */
|
|
2745
|
+
interface RequestLogEntry {
|
|
2746
|
+
channel: BusOperationKey;
|
|
2747
|
+
/** The action the schedule assigned to this emit. */
|
|
2748
|
+
action: FaultAction;
|
|
2749
|
+
correlationId: string | undefined;
|
|
2750
|
+
/**
|
|
2751
|
+
* Request identity for retry accounting: channel + payload minus the
|
|
2752
|
+
* per-issue fields (`correlationId`, `_trace`, `_userId`). Two emits with
|
|
2753
|
+
* the same key are the same logical request re-issued.
|
|
2754
|
+
*/
|
|
2755
|
+
retryKey: string;
|
|
2756
|
+
}
|
|
2757
|
+
interface FaultyTransportConfig {
|
|
2758
|
+
/**
|
|
2759
|
+
* The i-th request-channel emit applies `schedule[i % schedule.length]`.
|
|
2760
|
+
* Empty/omitted → every request delivers.
|
|
2761
|
+
*/
|
|
2762
|
+
schedule?: readonly FaultAction[];
|
|
2763
|
+
/** Default `'single-slot-throw'` (today's HttpTransport). */
|
|
2764
|
+
scopeModel?: ScopeModel;
|
|
2765
|
+
/**
|
|
2766
|
+
* Synthesize the `response` value for a delivered reply. Return `undefined`
|
|
2767
|
+
* for a void ack (`{ correlationId }` only). Default: `{}` for every op.
|
|
2768
|
+
*/
|
|
2769
|
+
makeResponse?: (operation: BusOperationKey, payload: Record<string, unknown>) => unknown;
|
|
2770
|
+
}
|
|
2771
|
+
/** Stable request identity: channel + sorted payload minus per-issue fields. */
|
|
2772
|
+
declare function retryKeyOf(channel: string, payload: Record<string, unknown>): string;
|
|
2773
|
+
declare class FaultyTransport implements ITransport {
|
|
2774
|
+
readonly baseUrl: BaseUrl;
|
|
2775
|
+
readonly state$: BehaviorSubject<ConnectionState>;
|
|
2776
|
+
private readonly errorsSubject;
|
|
2777
|
+
readonly errors$: Observable<SemiontError>;
|
|
2778
|
+
/** Every request-channel emit, in order — the L2 accounting surface. */
|
|
2779
|
+
readonly requestLog: RequestLogEntry[];
|
|
2780
|
+
private readonly bus;
|
|
2781
|
+
private readonly schedule;
|
|
2782
|
+
private readonly scopeModel;
|
|
2783
|
+
private readonly makeResponse;
|
|
2784
|
+
private requestCount;
|
|
2785
|
+
private activeScope;
|
|
2786
|
+
private scopeRefs;
|
|
2787
|
+
private readonly timers;
|
|
2788
|
+
private disposed;
|
|
2789
|
+
constructor(cfg?: FaultyTransportConfig);
|
|
2790
|
+
emit<K extends keyof EventMap>(channel: K, payload: EventMap[K], resourceScope?: ResourceId): Promise<void>;
|
|
2791
|
+
on<K extends keyof EventMap>(channel: K, handler: (payload: EventMap[K]) => void): () => void;
|
|
2792
|
+
stream<K extends keyof EventMap>(channel: K): Observable<EventMap[K]>;
|
|
2793
|
+
subscribeToResource(rid: ResourceId): () => void;
|
|
2794
|
+
bridgeInto(bus: EventBus): void;
|
|
2795
|
+
dispose(): void;
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
/**
|
|
2799
|
+
* Executable enforcement of the liveness axioms — the runtime twin of
|
|
2800
|
+
* `.plans/LIVENESS-AXIOMS.md`, and the composition-level sibling of
|
|
2801
|
+
* `assertStateUnitAxioms` (state-unit-axioms.ts). Where the StateUnit axioms
|
|
2802
|
+
* make *per-unit* wrongness mechanically detectable, these make *silence*
|
|
2803
|
+
* detectable: every existing enforcement tier is safety (nothing wrong is
|
|
2804
|
+
* delivered); these assert liveness (something is eventually delivered).
|
|
2805
|
+
*
|
|
2806
|
+
* Axioms (fault-schedule dimension; fast-check):
|
|
2807
|
+
* L1 Subscriber liveness — every output emits next|error within the bound,
|
|
2808
|
+
* under any fault schedule. Error is a permitted outcome; the forbidden
|
|
2809
|
+
* fourth state is pending-forever.
|
|
2810
|
+
* L2 Request settlement — every awaited path settles within the bound;
|
|
2811
|
+
* re-issues per logical request stay within the retry budget (B14: one);
|
|
2812
|
+
* a faulted request must be re-issued or surfaced, never swallowed.
|
|
2813
|
+
* L3 Delivery across lifecycle transitions — every event written to a live
|
|
2814
|
+
* connection reaches the output exactly once, wherever a client-initiated
|
|
2815
|
+
* transition (handover / reconnect / scope change) lands. Retirement is
|
|
2816
|
+
* by drain, never by abort (TRANSPORT-HTTP.md, Abort discipline).
|
|
2817
|
+
*
|
|
2818
|
+
* Framework-agnostic on purpose — only `rxjs` + `fast-check`, no `vitest` — so
|
|
2819
|
+
* it ships through `@semiont/core/testing` and any package's test runner can
|
|
2820
|
+
* invoke it. Deterministic virtual time: properties pass a small explicit
|
|
2821
|
+
* `timeoutMs` to `busRequest`; no `Date.now`, no 30 s real waits.
|
|
2822
|
+
*/
|
|
2823
|
+
|
|
2824
|
+
/** What one fresh run of the composition exposes to the axioms. */
|
|
2825
|
+
interface LivenessScenario {
|
|
2826
|
+
/**
|
|
2827
|
+
* Live-query-shaped outputs. The harness subscribes each one; every
|
|
2828
|
+
* subscription must see `next` or `error` within the bound (L1).
|
|
2829
|
+
*/
|
|
2830
|
+
outputs: readonly Observable<unknown>[];
|
|
2831
|
+
/**
|
|
2832
|
+
* Awaited paths. Each promise must settle — resolve or reject — within the
|
|
2833
|
+
* bound (L2). Rejections are fine; pending-forever is the violation.
|
|
2834
|
+
*/
|
|
2835
|
+
settlements?: readonly Promise<unknown>[];
|
|
2836
|
+
teardown?: () => void;
|
|
2837
|
+
}
|
|
2838
|
+
interface LivenessAxiomSpec {
|
|
2839
|
+
/** Build a FRESH composition wired to the given transport. Called per run. */
|
|
2840
|
+
setup: (transport: FaultyTransport) => LivenessScenario | Promise<LivenessScenario>;
|
|
2841
|
+
/**
|
|
2842
|
+
* The timeoutMs the scenario passes to `busRequest` — the bound is derived
|
|
2843
|
+
* from it: (timeoutMs × (1 + retryBudget) + Σdelays) × slackFactor.
|
|
2844
|
+
*/
|
|
2845
|
+
timeoutMs: number;
|
|
2846
|
+
/** Max sanctioned re-issues per logical request (B14 budget). Default 1. */
|
|
2847
|
+
retryBudget?: number;
|
|
2848
|
+
/** Override the generated fault schedules (teeth tests pin one). */
|
|
2849
|
+
scheduleArb?: fc.Arbitrary<readonly FaultAction[]>;
|
|
2850
|
+
/** Scope model(s) to run under. Default `'single-slot-throw'`. */
|
|
2851
|
+
scopeModel?: ScopeModel | 'both';
|
|
2852
|
+
/** Passed through to FaultyTransport (reply synthesis). */
|
|
2853
|
+
makeResponse?: (operation: string, payload: Record<string, unknown>) => unknown;
|
|
2854
|
+
/** fast-check run budget (default 25 — CI-fast; crank locally). */
|
|
2855
|
+
numRuns?: number;
|
|
2856
|
+
/** Real-scheduler jitter headroom on the bound (default 4×). */
|
|
2857
|
+
slackFactor?: number;
|
|
2858
|
+
}
|
|
2859
|
+
/** The five wire behaviors, uniformly weighted; delays stay small (≤5 ms). */
|
|
2860
|
+
declare function arbFaultAction(): fc.Arbitrary<FaultAction>;
|
|
2861
|
+
declare function arbFaultSchedule(maxLength?: number): fc.Arbitrary<readonly FaultAction[]>;
|
|
2862
|
+
/**
|
|
2863
|
+
* Run L1 + L2 against `spec` across generated fault schedules. Throws a
|
|
2864
|
+
* labeled Error (`L1: …` / `L2: …`) on the first violation.
|
|
2865
|
+
*/
|
|
2866
|
+
declare function assertLivenessAxioms(spec: LivenessAxiomSpec): Promise<void>;
|
|
2867
|
+
/**
|
|
2868
|
+
* A connection-stream-shaped subject: something that accepts writes to the
|
|
2869
|
+
* live connection, can be told to transition (handover / reconnect / scope
|
|
2870
|
+
* change), and exposes the subscriber-facing output. P3 adapts the real
|
|
2871
|
+
* actor's mock-connection harness to this shape; the teeth tests drive
|
|
2872
|
+
* reconstructed pre-fix doubles.
|
|
2873
|
+
*/
|
|
2874
|
+
interface DeliverySubject {
|
|
2875
|
+
/** Write the event with this id to the currently-live connection. */
|
|
2876
|
+
write: (eventId: string) => void;
|
|
2877
|
+
/** Client-initiated lifecycle transition. */
|
|
2878
|
+
transition: () => void | Promise<void>;
|
|
2879
|
+
/** Subscriber-facing output; each emission is a delivered event id. */
|
|
2880
|
+
output$: Observable<string>;
|
|
2881
|
+
/**
|
|
2882
|
+
* Drain pending asynchronous delivery at end of sequence (a live connection
|
|
2883
|
+
* eventually flushes). Default: one macrotask tick.
|
|
2884
|
+
*/
|
|
2885
|
+
settle?: () => Promise<void>;
|
|
2886
|
+
teardown?: () => void;
|
|
2887
|
+
}
|
|
2888
|
+
type DeliveryOp = 'write' | 'transition';
|
|
2889
|
+
interface DeliveryAxiomSpec {
|
|
2890
|
+
/** Build a FRESH subject. Called per run. */
|
|
2891
|
+
setup: () => DeliverySubject;
|
|
2892
|
+
/** Override the generated op sequences (teeth tests pin one). */
|
|
2893
|
+
opsArb?: fc.Arbitrary<readonly DeliveryOp[]>;
|
|
2894
|
+
/** Max generated sequence length (default 12). */
|
|
2895
|
+
maxOps?: number;
|
|
2896
|
+
/** fast-check run budget (default 50 — these runs are cheap). */
|
|
2897
|
+
numRuns?: number;
|
|
2898
|
+
}
|
|
2899
|
+
declare function arbDeliveryOps(maxOps?: number): fc.Arbitrary<readonly DeliveryOp[]>;
|
|
2900
|
+
/**
|
|
2901
|
+
* Run L3 against `spec` across generated write/transition interleavings.
|
|
2902
|
+
* Throws a labeled Error (`L3: …`) on the first violation: an event written
|
|
2903
|
+
* to a live connection delivered zero times (lost — retired by abort instead
|
|
2904
|
+
* of drain) or more than once (duplicate).
|
|
2905
|
+
*/
|
|
2906
|
+
declare function assertExactlyOnceDelivery(spec: DeliveryAxiomSpec): Promise<void>;
|
|
2907
|
+
|
|
2908
|
+
export { FaultyTransport, arbDeliveryOps, arbFaultAction, arbFaultSchedule, assertExactlyOnceDelivery, assertLivenessAxioms, assertStateUnitAxioms, disposeProbe, retryKeyOf };
|
|
2909
|
+
export type { DeliveryAxiomSpec, DeliveryOp, DeliverySubject, DisposeProbe, FaultAction, FaultyTransportConfig, LivenessAxiomSpec, LivenessScenario, RequestLogEntry, ScopeModel, StateUnitAxiomSpec };
|