@semiont/core 0.5.8 → 0.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -218,54 +218,6 @@ interface paths {
218
218
  patch?: never;
219
219
  trace?: never;
220
220
  };
221
- "/api/tokens/mcp-generate": {
222
- parameters: {
223
- query?: never;
224
- header?: never;
225
- path?: never;
226
- cookie?: never;
227
- };
228
- get?: never;
229
- put?: never;
230
- /**
231
- * Generate MCP Token
232
- * @description Generate a short-lived token for MCP server
233
- */
234
- post: {
235
- parameters: {
236
- query?: never;
237
- header?: never;
238
- path?: never;
239
- cookie?: never;
240
- };
241
- requestBody?: never;
242
- responses: {
243
- /** @description MCP token generated */
244
- 200: {
245
- headers: {
246
- [name: string]: unknown;
247
- };
248
- content: {
249
- "application/json": components["schemas"]["MCPGenerateResponse"];
250
- };
251
- };
252
- /** @description Unauthorized */
253
- 401: {
254
- headers: {
255
- [name: string]: unknown;
256
- };
257
- content: {
258
- "application/json": components["schemas"]["ErrorResponse"];
259
- };
260
- };
261
- };
262
- };
263
- delete?: never;
264
- options?: never;
265
- head?: never;
266
- patch?: never;
267
- trace?: never;
268
- };
269
221
  "/api/tokens/media": {
270
222
  parameters: {
271
223
  query?: never;
@@ -509,7 +461,7 @@ interface paths {
509
461
  put?: never;
510
462
  /**
511
463
  * Logout
512
- * @description Logout the current user
464
+ * @description Log out the current user by revoking the per-user token epoch (SDK-AUTH-CORS Phase 2): the user's tokenVersion is incremented, so every outstanding access and refresh token for that user is rejected from here on. Returns 204 No Content — there is no session body to return.
513
465
  */
514
466
  post: {
515
467
  parameters: {
@@ -520,14 +472,12 @@ interface paths {
520
472
  };
521
473
  requestBody?: never;
522
474
  responses: {
523
- /** @description Logged out successfully */
524
- 200: {
475
+ /** @description Logged out the user's tokens are revoked. No content. */
476
+ 204: {
525
477
  headers: {
526
478
  [name: string]: unknown;
527
479
  };
528
- content: {
529
- "application/json": components["schemas"]["AcceptTermsResponse"];
530
- };
480
+ content?: never;
531
481
  };
532
482
  };
533
483
  };
@@ -1308,75 +1258,6 @@ interface paths {
1308
1258
  patch?: never;
1309
1259
  trace?: never;
1310
1260
  };
1311
- "/api/tokens/mcp-setup": {
1312
- parameters: {
1313
- query?: never;
1314
- header?: never;
1315
- path?: never;
1316
- cookie?: never;
1317
- };
1318
- /**
1319
- * MCP Setup (browser-driven CLI handoff)
1320
- * @description Browser flow that generates a long-lived (30 day) MCP refresh token for the authenticated user and redirects to a localhost callback URL with the token as a query parameter. Used by CLI tooling (similar to Google's OAuth CLI flow).
1321
- *
1322
- * The callback URL must match one of the localhost patterns (`http://localhost:<port>/...`, `http://127.0.0.1:<port>/...`, or `http://[::1]:<port>/...`).
1323
- */
1324
- get: {
1325
- parameters: {
1326
- query: {
1327
- /** @description Localhost URL to redirect to with `?token=<refresh-token>` on success. */
1328
- callback: string;
1329
- };
1330
- header?: never;
1331
- path?: never;
1332
- cookie?: never;
1333
- };
1334
- requestBody?: never;
1335
- responses: {
1336
- /** @description Redirect to the callback URL with the newly-issued refresh token appended as a `?token=` query parameter. */
1337
- 302: {
1338
- headers: {
1339
- [name: string]: unknown;
1340
- };
1341
- content?: never;
1342
- };
1343
- /** @description Missing or non-localhost callback URL */
1344
- 400: {
1345
- headers: {
1346
- [name: string]: unknown;
1347
- };
1348
- content: {
1349
- "application/json": components["schemas"]["ErrorResponse"];
1350
- };
1351
- };
1352
- /** @description Authentication required */
1353
- 401: {
1354
- headers: {
1355
- [name: string]: unknown;
1356
- };
1357
- content: {
1358
- "application/json": components["schemas"]["ErrorResponse"];
1359
- };
1360
- };
1361
- /** @description Failed to generate refresh token */
1362
- 500: {
1363
- headers: {
1364
- [name: string]: unknown;
1365
- };
1366
- content: {
1367
- "application/json": components["schemas"]["ErrorResponse"];
1368
- };
1369
- };
1370
- };
1371
- };
1372
- put?: never;
1373
- post?: never;
1374
- delete?: never;
1375
- options?: never;
1376
- head?: never;
1377
- patch?: never;
1378
- trace?: never;
1379
- };
1380
1261
  "/bus/subscribe": {
1381
1262
  parameters: {
1382
1263
  query?: never;
@@ -1735,7 +1616,7 @@ interface paths {
1735
1616
  };
1736
1617
  /**
1737
1618
  * Get a resource's stored representation (browser-friendly alias)
1738
- * @description Identical pipe to GET /resources/{id} — verbatim bytes, stored media type in Content-Type, Accept never read. Exists only as the auth affordance for `<img>` / PDF.js / download links, which cannot carry Authorization headers: the `?token=` media token or the httpOnly semiont-token cookie ride along automatically.
1619
+ * @description Identical pipe to GET /resources/{id} — verbatim bytes, stored media type in Content-Type, Accept never read. Exists only as the auth affordance for `<img>` / PDF.js / download links, which cannot carry Authorization headers: the `?token=` media token rides along automatically.
1739
1620
  *
1740
1621
  * Responses carry `Cache-Control: public, max-age=31536000, immutable` — `public` is safe here, unlike the bearer-authenticated main route, because the `?token=` is part of the cache key.
1741
1622
  */
@@ -1933,17 +1814,6 @@ interface components {
1933
1814
  };
1934
1815
  resource: components["schemas"]["ResourceDescriptor"];
1935
1816
  };
1936
- AnnotationLLMContextResponse: {
1937
- annotation: components["schemas"]["Annotation"];
1938
- sourceResource: components["schemas"]["ResourceDescriptor"];
1939
- targetResource?: components["schemas"]["ResourceDescriptor"] | null;
1940
- /** @description Gathered context for this annotation */
1941
- context?: components["schemas"]["GatheredContext"];
1942
- targetContext?: {
1943
- content: string;
1944
- summary?: string;
1945
- };
1946
- };
1947
1817
  /** @description W3C Web Annotation target object - source is required, selector is optional */
1948
1818
  AnnotationTarget: {
1949
1819
  /** @description IRI of the resource being annotated */
@@ -2113,22 +1983,7 @@ interface components {
2113
1983
  };
2114
1984
  CreateAnnotationRequest: {
2115
1985
  motivation: components["schemas"]["Motivation"];
2116
- target: {
2117
- source: string;
2118
- selector: components["schemas"]["TextPositionSelector"] | {
2119
- /** @enum {string} */
2120
- type: "TextQuoteSelector";
2121
- exact: string;
2122
- prefix?: string;
2123
- suffix?: string;
2124
- } | components["schemas"]["SvgSelector"] | components["schemas"]["FragmentSelector"] | (components["schemas"]["TextPositionSelector"] | {
2125
- /** @enum {string} */
2126
- type: "TextQuoteSelector";
2127
- exact: string;
2128
- prefix?: string;
2129
- suffix?: string;
2130
- } | components["schemas"]["SvgSelector"] | components["schemas"]["FragmentSelector"])[];
2131
- };
1986
+ target: components["schemas"]["AnnotationTarget"];
2132
1987
  /** @description Optional body. Omit for annotations whose motivation alone is meaningful (highlighting) or whose user-supplied content is empty. Shape matches Annotation.body. */
2133
1988
  body?: components["schemas"]["AnnotationBody"] | components["schemas"]["AnnotationBody"][];
2134
1989
  };
@@ -2141,23 +1996,11 @@ interface components {
2141
1996
  success: boolean;
2142
1997
  message: string;
2143
1998
  };
2144
- /** @description Progress payload emitted on gather:annotation-progress and gather:progress SSE channels during LLM context gathering. */
1999
+ /** @description Progress payload emitted on the gather:annotation-progress SSE channel during LLM context gathering. */
2145
2000
  GatherProgress: {
2146
2001
  message?: string;
2147
2002
  percentage?: number;
2148
2003
  };
2149
- /** @description Completion payload emitted on gather:annotation-finished SSE channel. */
2150
- GatherAnnotationFinished: {
2151
- correlationId: string;
2152
- annotationId: string;
2153
- response: components["schemas"]["AnnotationLLMContextResponse"];
2154
- };
2155
- /** @description Completion payload emitted on gather:finished SSE channel for resource-level context gathering. */
2156
- GatherFinished: {
2157
- correlationId: string;
2158
- resourceId: string;
2159
- response: components["schemas"]["ResourceLLMContextResponse"];
2160
- };
2161
2004
  /** @description Search results payload emitted on match:search-results SSE channel. */
2162
2005
  MatchSearchResult: {
2163
2006
  correlationId: string;
@@ -2464,6 +2307,35 @@ interface components {
2464
2307
  progress?: unknown;
2465
2308
  result?: unknown;
2466
2309
  };
2310
+ /** @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. */
2311
+ KnowledgeGraph: {
2312
+ nodes: {
2313
+ /** @description Node identifier — a ResourceId or AnnotationId */
2314
+ id: string;
2315
+ /**
2316
+ * @description Whether this node is a resource or an annotation
2317
+ * @enum {string}
2318
+ */
2319
+ type: "resource" | "annotation";
2320
+ label: string;
2321
+ /** @description Entity types on the node (resources) or carried by the annotation */
2322
+ entityTypes?: string[];
2323
+ metadata?: {
2324
+ [key: string]: unknown;
2325
+ };
2326
+ }[];
2327
+ edges: {
2328
+ source: string;
2329
+ target: string;
2330
+ /** @description Edge kind (e.g. citation, annotation-of, sibling) */
2331
+ type: string;
2332
+ /** @description Whether the connection goes both ways */
2333
+ bidirectional?: boolean;
2334
+ metadata?: {
2335
+ [key: string]: unknown;
2336
+ };
2337
+ }[];
2338
+ };
2467
2339
  ListResourcesResponse: {
2468
2340
  resources: components["schemas"]["ResourceDescriptor"][];
2469
2341
  total: number;
@@ -2479,9 +2351,6 @@ interface components {
2479
2351
  /** @description User password (minimum 8 characters) */
2480
2352
  password: string;
2481
2353
  };
2482
- MCPGenerateResponse: {
2483
- refresh_token: string;
2484
- };
2485
2354
  /**
2486
2355
  * @description Semiont-supported W3C Web Annotation motivations - https://www.w3.org/TR/annotation-vocab/#motivation
2487
2356
  * @enum {string}
@@ -2620,37 +2489,6 @@ interface components {
2620
2489
  /** @description Entity types on the matched passage */
2621
2490
  entityTypes?: string[];
2622
2491
  };
2623
- ResourceLLMContextResponse: {
2624
- mainResource: components["schemas"]["ResourceDescriptor"];
2625
- relatedResources: components["schemas"]["ResourceDescriptor"][];
2626
- annotations: components["schemas"]["Annotation"][];
2627
- graph: {
2628
- nodes: {
2629
- id: string;
2630
- type: string;
2631
- label: string;
2632
- metadata: {
2633
- [key: string]: unknown;
2634
- };
2635
- }[];
2636
- edges: {
2637
- source: string;
2638
- target: string;
2639
- type: string;
2640
- metadata: {
2641
- [key: string]: unknown;
2642
- };
2643
- }[];
2644
- };
2645
- summary?: string;
2646
- suggestedReferences?: string[];
2647
- /** @description The content of the main resource (included if includeContent=true) */
2648
- mainResourceContent?: string;
2649
- /** @description Map of resource IDs to their content (included if includeContent=true) */
2650
- relatedResourcesContent?: {
2651
- [key: string]: string;
2652
- };
2653
- };
2654
2492
  SpecificResource: {
2655
2493
  /** @enum {string} */
2656
2494
  type: "SpecificResource";
@@ -2767,12 +2605,10 @@ interface components {
2767
2605
  BeckonSparkleEvent: {
2768
2606
  annotationId: string;
2769
2607
  };
2770
- /** @description Success result emitted on the bind:body-updated bus channel after bind:update-body has been applied. */
2608
+ /** @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. */
2771
2609
  BindBodyUpdated: {
2772
- /** @description Correlation ID echoed from the originating bind:update-body command */
2610
+ /** @description Correlation id echoed from the originating bind:update-body command so busRequest can match the reply. */
2773
2611
  correlationId: string;
2774
- /** @description Branded AnnotationId of the annotation whose body was updated */
2775
- annotationId: string;
2776
2612
  };
2777
2613
  /** @description Command payload sent on the bind:initiate bus channel to start a bind flow. */
2778
2614
  BindInitiateCommand: {
@@ -3004,8 +2840,8 @@ interface components {
3004
2840
  correlationId: string;
3005
2841
  /** @description Branded AnnotationId of the annotation whose context was gathered */
3006
2842
  annotationId: string;
3007
- /** @description The gathered annotation context */
3008
- response: components["schemas"]["AnnotationLLMContextResponse"];
2843
+ /** @description The gathered annotation context (unified GatheredContext, focus.kind:'annotation') */
2844
+ response: components["schemas"]["GatheredContext"];
3009
2845
  };
3010
2846
  /** @description Request payload sent on the gather:requested bus channel to gather context for an annotation. */
3011
2847
  GatherAnnotationRequest: {
@@ -3025,66 +2861,75 @@ interface components {
3025
2861
  contextWindow?: number;
3026
2862
  };
3027
2863
  };
3028
- /** @description Context gathered for an annotation. Includes source document excerpts, metadata, and graph-derived context. Used by both Find (bind) and Generate (yield) flows. */
2864
+ /** @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. */
3029
2865
  GatheredContext: {
3030
- /** @description The annotation this context was gathered for */
3031
- annotation: components["schemas"]["Annotation"];
3032
- /** @description The resource containing the annotation */
3033
- sourceResource: components["schemas"]["ResourceDescriptor"];
3034
- /** @description Text context from the source document */
3035
- sourceContext?: {
3036
- /** @description Text appearing before the selected passage */
3037
- before?: string;
3038
- /** @description The selected text passage (the annotation target) */
3039
- selected: string;
3040
- /** @description Text appearing after the selected passage */
3041
- after?: string;
2866
+ /** @description The gather anchor. Discriminated on `kind`. */
2867
+ focus: {
2868
+ /** @enum {string} */
2869
+ kind: "annotation";
2870
+ /** @description The annotation this context was gathered for */
2871
+ annotation: components["schemas"]["Annotation"];
2872
+ /** @description The resource containing the annotation */
2873
+ sourceResource: components["schemas"]["ResourceDescriptor"];
2874
+ /** @description Text context around the annotation target */
2875
+ selected?: {
2876
+ /** @description Text appearing before the selected passage */
2877
+ before?: string;
2878
+ /** @description The selected text passage (the annotation target) */
2879
+ text: string;
2880
+ /** @description Text appearing after the selected passage */
2881
+ after?: string;
2882
+ };
2883
+ /** @description User-provided hint to supplement or replace the selected text for search and generation */
2884
+ userHint?: string;
2885
+ /** @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). */
2886
+ targetResource?: components["schemas"]["ResourceDescriptor"];
2887
+ /** @description Context about the annotation's link target. Dormant — see LINK-TARGET-CONTEXT.md. */
2888
+ targetContext?: {
2889
+ content: string;
2890
+ summary?: string;
2891
+ };
2892
+ } | {
2893
+ /** @enum {string} */
2894
+ kind: "resource";
2895
+ /** @description The resource this context was gathered for */
2896
+ resource: components["schemas"]["ResourceDescriptor"];
2897
+ summary?: string;
2898
+ suggestedReferences?: string[];
2899
+ /** @description Resource content (included when requested) */
2900
+ content?: {
2901
+ /** @description Content of the focal resource */
2902
+ main?: string;
2903
+ /** @description Map of related resource IDs to their content */
2904
+ related?: {
2905
+ [key: string]: string;
2906
+ };
2907
+ };
3042
2908
  };
3043
- /** @description Context metadata about the annotation and its source */
3044
- metadata?: {
2909
+ /** @description Knowledge graph backbone resources AND annotations as typed nodes. The flattened views (connections, citedBy, siblings) are derived from this. */
2910
+ graph: components["schemas"]["KnowledgeGraph"];
2911
+ /** @description Semantically similar passages from across the knowledge base, found via vector search */
2912
+ semanticContext?: {
2913
+ /** @description Passages ranked by cosine similarity to the focal text */
2914
+ similar: components["schemas"]["SemanticMatch"][];
2915
+ /** @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. */
2916
+ excludedEntityTypes?: string[];
2917
+ };
2918
+ /** @description Context metadata about the focal anchor and its source */
2919
+ metadata: {
3045
2920
  /** @description Type of source resource (e.g., 'document', 'image', 'video') */
3046
2921
  resourceType?: string;
3047
2922
  /** @description BCP 47 language tag of source content */
3048
2923
  language?: string;
3049
- /** @description Entity types associated with the annotation */
2924
+ /** @description Entity types associated with the focal anchor */
3050
2925
  entityTypes?: string[];
3051
- };
3052
- /** @description User-provided textual hint to supplement or replace the selected text for search and generation */
3053
- userHint?: string;
3054
- /** @description Graph-derived context from the knowledge base */
3055
- graphContext?: {
3056
- /** @description Resources connected to the source resource via annotations */
3057
- connections?: {
3058
- /** @description ID of the connected resource */
3059
- resourceId: string;
3060
- /** @description Name of the connected resource */
3061
- resourceName: string;
3062
- /** @description Entity types on the connected resource */
3063
- entityTypes?: string[];
3064
- /** @description Whether the connection goes both ways */
3065
- bidirectional: boolean;
3066
- }[];
3067
- /** @description Number of other resources that reference the source resource */
3068
- citedByCount?: number;
3069
- /** @description Resources that reference the source resource */
3070
- citedBy?: {
3071
- resourceId: string;
3072
- resourceName: string;
3073
- }[];
3074
- /** @description Entity types from other annotations on the same resource */
3075
- siblingEntityTypes?: string[];
3076
- /** @description Global frequency counts for entity types (for IDF-like weighting) */
2926
+ /** @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. */
3077
2927
  entityTypeFrequencies?: {
3078
2928
  [key: string]: number;
3079
2929
  };
3080
- /** @description LLM-generated summary of the annotation's relationships in the knowledge graph */
3081
- inferredRelationshipSummary?: string;
3082
- };
3083
- /** @description Semantically similar passages from across the knowledge base, found via vector search */
3084
- semanticContext?: {
3085
- /** @description Passages ranked by cosine similarity to the focal text */
3086
- similar: components["schemas"]["SemanticMatch"][];
3087
2930
  };
2931
+ /** @description LLM-generated summary of the focal anchor's relationships in the knowledge graph */
2932
+ inferredRelationshipSummary?: string;
3088
2933
  };
3089
2934
  /** @description Completion payload emitted on the gather:resource-complete bus channel when resource context gathering finishes. */
3090
2935
  GatherResourceComplete: {
@@ -3092,8 +2937,8 @@ interface components {
3092
2937
  correlationId: string;
3093
2938
  /** @description Branded ResourceId of the resource whose context was gathered */
3094
2939
  resourceId: string;
3095
- /** @description The gathered resource context */
3096
- response: components["schemas"]["ResourceLLMContextResponse"];
2940
+ /** @description The gathered resource context (unified GatheredContext, focus.kind:'resource') */
2941
+ response: components["schemas"]["GatheredContext"];
3097
2942
  };
3098
2943
  /** @description Request payload sent on the gather:resource-requested bus channel to gather context for a resource. */
3099
2944
  GatherResourceRequest: {
@@ -3111,6 +2956,8 @@ interface components {
3111
2956
  includeContent: boolean;
3112
2957
  /** @description Whether to include resource summaries in the gathered result */
3113
2958
  includeSummary: boolean;
2959
+ /** @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. */
2960
+ excludeEntityTypes?: string[];
3114
2961
  };
3115
2962
  };
3116
2963
  /** @description Request to generate an AI summary of an annotation */
@@ -3126,6 +2973,8 @@ interface components {
3126
2973
  };
3127
2974
  /** @description Request to cancel a job */
3128
2975
  JobCancelRequest: {
2976
+ /** @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. */
2977
+ correlationId?: string;
3129
2978
  /** @enum {string} */
3130
2979
  jobType: "annotation" | "generation";
3131
2980
  };
@@ -3137,6 +2986,8 @@ interface components {
3137
2986
  /** @description Command to create a new job via the event bus */
3138
2987
  JobCreateCommand: {
3139
2988
  correlationId: string;
2989
+ /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
2990
+ _userId?: string;
3140
2991
  /** @enum {string} */
3141
2992
  jobType: "reference-annotation" | "highlight-annotation" | "assessment-annotation" | "comment-annotation" | "tag-annotation" | "generation";
3142
2993
  resourceId: string;
@@ -3289,18 +3140,24 @@ interface components {
3289
3140
  };
3290
3141
  /** @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. */
3291
3142
  FrameAddEntityTypeCommand: {
3143
+ /** @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. */
3144
+ correlationId?: string;
3292
3145
  tag: string;
3293
3146
  /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
3294
3147
  _userId?: string;
3295
3148
  };
3296
3149
  /** @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. */
3297
3150
  FrameAddTagSchemaCommand: {
3151
+ /** @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. */
3152
+ correlationId?: string;
3298
3153
  schema: components["schemas"]["TagSchema"];
3299
3154
  /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
3300
3155
  _userId?: string;
3301
3156
  };
3302
3157
  /** @description Bus command to archive a resource and optionally remove its file. */
3303
3158
  MarkArchiveCommand: {
3159
+ /** @description Correlation id for request/reply matching, set by the SDK's busRequest so the confirmed-write ack/failure routes back. */
3160
+ correlationId?: string;
3304
3161
  /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
3305
3162
  _userId?: string;
3306
3163
  resourceId: string;
@@ -3338,9 +3195,14 @@ interface components {
3338
3195
  annotation: components["schemas"]["Annotation"];
3339
3196
  resourceId: string;
3340
3197
  };
3341
- /** @description Success response after creating an annotation. */
3198
+ /** @description Success reply after creating an annotation, matched to the originating command by correlationId. */
3342
3199
  MarkCreateOk: {
3343
- annotationId: string;
3200
+ /** @description Correlation id echoed from the mark:create-request command so busRequest can match the reply. */
3201
+ correlationId?: string;
3202
+ /** @description The created annotation's identity. */
3203
+ response: {
3204
+ annotationId: string;
3205
+ };
3344
3206
  };
3345
3207
  /** @description Raw annotation creation intent — bus handler assembles the W3C annotation */
3346
3208
  MarkCreateRequest: {
@@ -3350,14 +3212,21 @@ interface components {
3350
3212
  };
3351
3213
  /** @description Bus command to delete an annotation. */
3352
3214
  MarkDeleteCommand: {
3215
+ /** @description Correlation id for request/reply matching, set by the SDK's busRequest so the confirmed-write ack/failure routes back. */
3216
+ correlationId?: string;
3353
3217
  /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
3354
3218
  _userId?: string;
3355
3219
  annotationId: string;
3356
3220
  resourceId?: string;
3357
3221
  };
3358
- /** @description Success response after deleting an annotation. */
3222
+ /** @description Success reply after deleting an annotation, matched to the originating command by correlationId. */
3359
3223
  MarkDeleteOk: {
3360
- annotationId: string;
3224
+ /** @description Correlation id echoed from the mark:delete command so busRequest can match the reply. */
3225
+ correlationId?: string;
3226
+ /** @description The deleted annotation's identity. */
3227
+ response: {
3228
+ annotationId: string;
3229
+ };
3361
3230
  };
3362
3231
  /** @description Emitted when the user requests a new mark (annotation) on a resource */
3363
3232
  MarkRequestedEvent: {
@@ -3383,6 +3252,8 @@ interface components {
3383
3252
  };
3384
3253
  /** @description Bus command to unarchive a previously archived resource. */
3385
3254
  MarkUnarchiveCommand: {
3255
+ /** @description Correlation id for request/reply matching, set by the SDK's busRequest so the confirmed-write ack/failure routes back. */
3256
+ correlationId?: string;
3386
3257
  /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
3387
3258
  _userId?: string;
3388
3259
  resourceId: string;
@@ -3477,7 +3348,7 @@ interface components {
3477
3348
  YieldCloneCreated: {
3478
3349
  correlationId: string;
3479
3350
  response: {
3480
- resourceId?: string;
3351
+ resourceId: string;
3481
3352
  };
3482
3353
  };
3483
3354
  /** @description Bus command to request cloning a resource using a clone token. */
@@ -3492,6 +3363,8 @@ interface components {
3492
3363
  };
3493
3364
  /** @description Bus command to create a yielded resource in the knowledge base. */
3494
3365
  YieldCreateCommand: {
3366
+ /** @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. */
3367
+ correlationId?: string;
3495
3368
  /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
3496
3369
  _userId?: string;
3497
3370
  name: string;
@@ -3510,14 +3383,14 @@ interface components {
3510
3383
  generator?: components["schemas"]["Agent"] | components["schemas"]["Agent"][];
3511
3384
  noGit?: boolean;
3512
3385
  };
3513
- /** @description Success response after creating a yielded resource. */
3386
+ /** @description Success reply after creating a yielded resource, matched to the originating command by correlationId. */
3514
3387
  YieldCreateOk: {
3515
- resourceId: string;
3516
- resource: components["schemas"]["ResourceDescriptor"];
3517
- };
3518
- /** @description Success response after moving a yielded resource. */
3519
- YieldMoveOk: {
3520
- resourceId: string;
3388
+ /** @description Correlation id echoed from the yield:create command so busRequest can match the reply. */
3389
+ correlationId?: string;
3390
+ /** @description The created resource's identity. */
3391
+ response: {
3392
+ resourceId: string;
3393
+ };
3521
3394
  };
3522
3395
  /** @description Bus command to move (rename) a yielded resource. */
3523
3396
  YieldMvCommand: {
@@ -3529,6 +3402,8 @@ interface components {
3529
3402
  };
3530
3403
  /** @description Bus command to update a yielded resource's storage content. */
3531
3404
  YieldUpdateCommand: {
3405
+ /** @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. */
3406
+ correlationId?: string;
3532
3407
  /** @description Authenticated user's DID, injected by the /bus/emit gateway. Clients do not set this. */
3533
3408
  _userId?: string;
3534
3409
  resourceId: string;
@@ -3537,9 +3412,14 @@ interface components {
3537
3412
  byteSize: number;
3538
3413
  noGit?: boolean;
3539
3414
  };
3540
- /** @description Success response after updating a yielded resource. */
3415
+ /** @description Success reply after updating a yielded resource, matched to the originating command by correlationId. */
3541
3416
  YieldUpdateOk: {
3542
- resourceId: string;
3417
+ /** @description Correlation id echoed from the yield:update command so busRequest can match the reply. */
3418
+ correlationId?: string;
3419
+ /** @description The updated resource's identity. */
3420
+ response: {
3421
+ resourceId: string;
3422
+ };
3543
3423
  };
3544
3424
  };
3545
3425
  responses: never;
@@ -3913,8 +3793,7 @@ type EventMap = {
3913
3793
  'yield:create-ok': components['schemas']['YieldCreateOk'];
3914
3794
  'yield:create-failed': components['schemas']['CommandError'];
3915
3795
  'yield:update-ok': components['schemas']['YieldUpdateOk'];
3916
- 'yield:update-failed': components['schemas']['YieldUpdateOk'] & components['schemas']['CommandError'];
3917
- 'yield:move-ok': components['schemas']['YieldMoveOk'];
3796
+ 'yield:update-failed': components['schemas']['CommandError'];
3918
3797
  'yield:move-failed': {
3919
3798
  fromUri: string;
3920
3799
  } & components['schemas']['CommandError'];
@@ -3954,6 +3833,14 @@ type EventMap = {
3954
3833
  'mark:create-failed': components['schemas']['CommandError'];
3955
3834
  'mark:delete-ok': components['schemas']['MarkDeleteOk'];
3956
3835
  'mark:delete-failed': components['schemas']['CommandError'];
3836
+ 'mark:archive-ok': {
3837
+ correlationId?: string;
3838
+ };
3839
+ 'mark:archive-failed': components['schemas']['CommandError'];
3840
+ 'mark:unarchive-ok': {
3841
+ correlationId?: string;
3842
+ };
3843
+ 'mark:unarchive-failed': components['schemas']['CommandError'];
3957
3844
  'mark:body-update-failed': components['schemas']['CommandError'];
3958
3845
  'mark:select-comment': components['schemas']['SelectionData'];
3959
3846
  'mark:select-tag': components['schemas']['SelectionData'];
@@ -3973,7 +3860,13 @@ type EventMap = {
3973
3860
  'frame:tag-schema-added': StoredEvent<EventOfType<'frame:tag-schema-added'>>;
3974
3861
  'frame:add-entity-type': components['schemas']['FrameAddEntityTypeCommand'];
3975
3862
  'frame:add-tag-schema': components['schemas']['FrameAddTagSchemaCommand'];
3863
+ 'frame:entity-type-add-ok': {
3864
+ correlationId?: string;
3865
+ };
3976
3866
  'frame:entity-type-add-failed': components['schemas']['CommandError'];
3867
+ 'frame:tag-schema-add-ok': {
3868
+ correlationId?: string;
3869
+ };
3977
3870
  'frame:tag-schema-add-failed': components['schemas']['CommandError'];
3978
3871
  'bind:initiate': BindInitiateCommand;
3979
3872
  'bind:update-body': BindUpdateBodyCommand;
@@ -4003,9 +3896,6 @@ type EventMap = {
4003
3896
  correlationId: string;
4004
3897
  } & components['schemas']['CommandError'];
4005
3898
  'gather:annotation-progress': components['schemas']['GatherProgress'];
4006
- 'gather:annotation-finished': components['schemas']['GatherAnnotationFinished'];
4007
- 'gather:progress': components['schemas']['GatherProgress'];
4008
- 'gather:finished': components['schemas']['GatherFinished'];
4009
3899
  'browse:resource-requested': components['schemas']['BrowseResourceRequest'];
4010
3900
  'browse:resource-result': components['schemas']['BrowseResourceResult'];
4011
3901
  'browse:resource-failed': {
@@ -4110,6 +4000,13 @@ type EventMap = {
4110
4000
  'job:claim-failed': {
4111
4001
  correlationId: string;
4112
4002
  } & components['schemas']['CommandError'];
4003
+ 'job:cancel-ok': {
4004
+ correlationId?: string;
4005
+ response: {
4006
+ cancelled: number;
4007
+ };
4008
+ };
4009
+ 'job:cancel-failed': components['schemas']['CommandError'];
4113
4010
  'settings:theme-changed': components['schemas']['SettingsThemeChangedEvent'];
4114
4011
  'settings:line-numbers-toggled': void;
4115
4012
  'settings:locale-changed': components['schemas']['SettingsLocaleChangedEvent'];
@@ -4143,7 +4040,22 @@ type EventMap = {
4143
4040
  reason: string;
4144
4041
  };
4145
4042
  };
4146
- /** Any valid channel name on the EventBus. */
4043
+ /**
4044
+ * Any valid channel name on the EventBus — `keyof EventMap`, the root channel
4045
+ * type. Two subsets matter, and confusing them is a silent-failure trap:
4046
+ *
4047
+ * - `EmittableChannel` (below) — channels with a non-null `CHANNEL_SCHEMAS`
4048
+ * entry; what you EMIT (the `/bus/emit` gateway validates the payload).
4049
+ * - `BridgedChannel` (`bridged-channels.ts`) — the transport fan-in set; the
4050
+ * only channels a client can SUBSCRIBE to over a concrete transport.
4051
+ *
4052
+ * Request/reply (`busRequest`) emits on an `EmittableChannel` and subscribes on
4053
+ * `BridgedChannel` replies. A reply channel that is a valid `EventName` but NOT
4054
+ * in `BRIDGED_CHANNELS` is never delivered → the request times out with no
4055
+ * compile or runtime error (see
4056
+ * `.plans/bugs/gather-resource-complete-not-bridged.md`). `busRequest` now types
4057
+ * its reply params `BridgedChannel` so that omission is a compile error.
4058
+ */
4147
4059
  type EventName = keyof EventMap;
4148
4060
  /**
4149
4061
  * Genuine resource-bound broadcast event types.
@@ -4202,7 +4114,6 @@ declare const CHANNEL_SCHEMAS: {
4202
4114
  readonly 'yield:create-failed': "CommandError";
4203
4115
  readonly 'yield:update-ok': "YieldUpdateOk";
4204
4116
  readonly 'yield:update-failed': null;
4205
- readonly 'yield:move-ok': "YieldMoveOk";
4206
4117
  readonly 'yield:move-failed': null;
4207
4118
  readonly 'yield:clone-token-generated': null;
4208
4119
  readonly 'yield:clone-token-failed': null;
@@ -4232,8 +4143,14 @@ declare const CHANNEL_SCHEMAS: {
4232
4143
  readonly 'mark:create-failed': "CommandError";
4233
4144
  readonly 'mark:delete-ok': "MarkDeleteOk";
4234
4145
  readonly 'mark:delete-failed': "CommandError";
4146
+ readonly 'mark:archive-ok': null;
4147
+ readonly 'mark:archive-failed': "CommandError";
4148
+ readonly 'mark:unarchive-ok': null;
4149
+ readonly 'mark:unarchive-failed': "CommandError";
4235
4150
  readonly 'mark:body-update-failed': "CommandError";
4151
+ readonly 'frame:entity-type-add-ok': null;
4236
4152
  readonly 'frame:entity-type-add-failed': "CommandError";
4153
+ readonly 'frame:tag-schema-add-ok': null;
4237
4154
  readonly 'frame:tag-schema-add-failed': "CommandError";
4238
4155
  readonly 'mark:select-comment': "SelectionData";
4239
4156
  readonly 'mark:select-tag': "SelectionData";
@@ -4266,9 +4183,6 @@ declare const CHANNEL_SCHEMAS: {
4266
4183
  readonly 'gather:summary-result': null;
4267
4184
  readonly 'gather:summary-failed': null;
4268
4185
  readonly 'gather:annotation-progress': "GatherProgress";
4269
- readonly 'gather:annotation-finished': "GatherAnnotationFinished";
4270
- readonly 'gather:progress': "GatherProgress";
4271
- readonly 'gather:finished': "GatherFinished";
4272
4186
  readonly 'browse:resource-requested': "BrowseResourceRequest";
4273
4187
  readonly 'browse:resource-result': "BrowseResourceResult";
4274
4188
  readonly 'browse:resource-failed': null;
@@ -4336,6 +4250,8 @@ declare const CHANNEL_SCHEMAS: {
4336
4250
  readonly 'job:create-failed': null;
4337
4251
  readonly 'job:claimed': null;
4338
4252
  readonly 'job:claim-failed': null;
4253
+ readonly 'job:cancel-ok': null;
4254
+ readonly 'job:cancel-failed': "CommandError";
4339
4255
  readonly 'settings:theme-changed': "SettingsThemeChangedEvent";
4340
4256
  readonly 'settings:line-numbers-toggled': null;
4341
4257
  readonly 'settings:locale-changed': "SettingsLocaleChangedEvent";
@@ -4821,7 +4737,9 @@ declare function validateSvgMarkup(svg: string): string | null;
4821
4737
  * Generates a bare annotation ID (no URL prefix). URIs are constructed
4822
4738
  * at the API boundary when returning responses to clients.
4823
4739
  *
4824
- * Throws on invalid input (missing selector, missing motivation, invalid SVG).
4740
+ * Throws on invalid input (missing motivation, invalid SVG markup). The target
4741
+ * selector is OPTIONAL — a source-only target annotates the whole resource (W3C;
4742
+ * e.g. resource-level edges), per RESOURCE-LEVEL-ANCHOR.
4825
4743
  */
4826
4744
  declare function assembleAnnotation(request: CreateAnnotationRequest, creator: Agent$2): AssembledAnnotation;
4827
4745
  /**
@@ -5346,9 +5264,6 @@ interface IBackendOperations {
5346
5264
  logout(): Promise<void>;
5347
5265
  acceptTerms(): Promise<void>;
5348
5266
  getCurrentUser(): Promise<UserResponse>;
5349
- generateMcpToken(): Promise<{
5350
- token: string;
5351
- }>;
5352
5267
  getMediaToken(resourceId: ResourceId): Promise<{
5353
5268
  token: string;
5354
5269
  }>;
@@ -5445,23 +5360,221 @@ interface IContentTransport {
5445
5360
  dispose(): void;
5446
5361
  }
5447
5362
 
5363
+ declare const BUS_OPERATIONS: {
5364
+ readonly 'bind:update-body': {
5365
+ readonly result: "bind:body-updated";
5366
+ readonly failure: "bind:body-update-failed";
5367
+ };
5368
+ readonly 'browse:resource-requested': {
5369
+ readonly result: "browse:resource-result";
5370
+ readonly failure: "browse:resource-failed";
5371
+ };
5372
+ readonly 'browse:resources-requested': {
5373
+ readonly result: "browse:resources-result";
5374
+ readonly failure: "browse:resources-failed";
5375
+ };
5376
+ readonly 'browse:annotation-requested': {
5377
+ readonly result: "browse:annotation-result";
5378
+ readonly failure: "browse:annotation-failed";
5379
+ };
5380
+ readonly 'browse:annotations-requested': {
5381
+ readonly result: "browse:annotations-result";
5382
+ readonly failure: "browse:annotations-failed";
5383
+ };
5384
+ readonly 'browse:annotation-history-requested': {
5385
+ readonly result: "browse:annotation-history-result";
5386
+ readonly failure: "browse:annotation-history-failed";
5387
+ };
5388
+ readonly 'browse:events-requested': {
5389
+ readonly result: "browse:events-result";
5390
+ readonly failure: "browse:events-failed";
5391
+ };
5392
+ readonly 'browse:referenced-by-requested': {
5393
+ readonly result: "browse:referenced-by-result";
5394
+ readonly failure: "browse:referenced-by-failed";
5395
+ };
5396
+ readonly 'browse:entity-types-requested': {
5397
+ readonly result: "browse:entity-types-result";
5398
+ readonly failure: "browse:entity-types-failed";
5399
+ };
5400
+ readonly 'browse:tag-schemas-requested': {
5401
+ readonly result: "browse:tag-schemas-result";
5402
+ readonly failure: "browse:tag-schemas-failed";
5403
+ };
5404
+ readonly 'browse:directory-requested': {
5405
+ readonly result: "browse:directory-result";
5406
+ readonly failure: "browse:directory-failed";
5407
+ };
5408
+ readonly 'browse:annotation-context-requested': {
5409
+ readonly result: "browse:annotation-context-result";
5410
+ readonly failure: "browse:annotation-context-failed";
5411
+ };
5412
+ readonly 'frame:add-entity-type': {
5413
+ readonly result: "frame:entity-type-add-ok";
5414
+ readonly failure: "frame:entity-type-add-failed";
5415
+ };
5416
+ readonly 'frame:add-tag-schema': {
5417
+ readonly result: "frame:tag-schema-add-ok";
5418
+ readonly failure: "frame:tag-schema-add-failed";
5419
+ };
5420
+ readonly 'gather:requested': {
5421
+ readonly result: "gather:complete";
5422
+ readonly failure: "gather:failed";
5423
+ readonly progress: "gather:annotation-progress";
5424
+ };
5425
+ readonly 'gather:resource-requested': {
5426
+ readonly result: "gather:resource-complete";
5427
+ readonly failure: "gather:resource-failed";
5428
+ };
5429
+ readonly 'gather:summary-requested': {
5430
+ readonly result: "gather:summary-result";
5431
+ readonly failure: "gather:summary-failed";
5432
+ };
5433
+ readonly 'job:create': {
5434
+ readonly result: "job:created";
5435
+ readonly failure: "job:create-failed";
5436
+ };
5437
+ readonly 'job:status-requested': {
5438
+ readonly result: "job:status-result";
5439
+ readonly failure: "job:status-failed";
5440
+ };
5441
+ readonly 'job:cancel-requested': {
5442
+ readonly result: "job:cancel-ok";
5443
+ readonly failure: "job:cancel-failed";
5444
+ };
5445
+ readonly 'job:claim': {
5446
+ readonly result: "job:claimed";
5447
+ readonly failure: "job:claim-failed";
5448
+ };
5449
+ readonly 'mark:create-request': {
5450
+ readonly result: "mark:create-ok";
5451
+ readonly failure: "mark:create-failed";
5452
+ };
5453
+ readonly 'mark:delete': {
5454
+ readonly result: "mark:delete-ok";
5455
+ readonly failure: "mark:delete-failed";
5456
+ };
5457
+ readonly 'mark:archive': {
5458
+ readonly result: "mark:archive-ok";
5459
+ readonly failure: "mark:archive-failed";
5460
+ };
5461
+ readonly 'mark:unarchive': {
5462
+ readonly result: "mark:unarchive-ok";
5463
+ readonly failure: "mark:unarchive-failed";
5464
+ };
5465
+ readonly 'match:search-requested': {
5466
+ readonly result: "match:search-results";
5467
+ readonly failure: "match:search-failed";
5468
+ };
5469
+ readonly 'yield:create': {
5470
+ readonly result: "yield:create-ok";
5471
+ readonly failure: "yield:create-failed";
5472
+ };
5473
+ readonly 'yield:update': {
5474
+ readonly result: "yield:update-ok";
5475
+ readonly failure: "yield:update-failed";
5476
+ };
5477
+ readonly 'yield:clone-create': {
5478
+ readonly result: "yield:clone-created";
5479
+ readonly failure: "yield:clone-create-failed";
5480
+ };
5481
+ readonly 'yield:clone-resource-requested': {
5482
+ readonly result: "yield:clone-resource-result";
5483
+ readonly failure: "yield:clone-resource-failed";
5484
+ };
5485
+ readonly 'yield:clone-token-requested': {
5486
+ readonly result: "yield:clone-token-generated";
5487
+ readonly failure: "yield:clone-token-failed";
5488
+ };
5489
+ };
5490
+ /** The request-channel key of a registered operation — what `busRequest` takes. */
5491
+ type BusOperationKey = keyof typeof BUS_OPERATIONS;
5492
+
5448
5493
  /**
5449
5494
  * BRIDGED_CHANNELS
5450
5495
  *
5451
5496
  * The set of bus channels that any concrete transport bridges into the
5452
5497
  * caller-supplied bus via `bridgeInto`. Transport-neutral: every concrete
5453
- * `ITransport` shares the same set; HTTP delivers them via SSE,
5454
- * in-process transports forward them directly from the local actor bus.
5498
+ * `ITransport` shares the same set; HTTP delivers them via SSE, in-process
5499
+ * transports forward them directly from the local actor bus.
5500
+ *
5501
+ * This is the *fan-in* set — channels for events the transport receives and
5502
+ * pushes onto the client's bus. It is not the same as the channels the client
5503
+ * emits (which is open-ended).
5504
+ *
5505
+ * It is DERIVED, not hand-listed: the request/reply replies come from
5506
+ * `BUS_OPERATIONS` (bus-operations.ts), so no operation's reply can be
5507
+ * forgotten here — that was the recurring unbridged-reply bug class. The only
5508
+ * hand-maintained part is `BRIDGED_BROADCASTS`: the genuine non-request/reply
5509
+ * minority (lifecycle events and UI/infra signals that no single requester
5510
+ * owns). See .plans/BUS-OPERATIONS-REGISTRY.md.
5511
+ *
5512
+ * Resource-scoped channels (joined/left via `subscribeToResource`) are tracked
5513
+ * separately by transports that care about scope (HTTP).
5514
+ */
5515
+ /**
5516
+ * Bridged channels with no owning operation: job-lifecycle events (multi-viewer,
5517
+ * no single requester owns the reply), KB-global frame domain events, UI signals,
5518
+ * and SSE infrastructure. A reply channel must NOT go here — declare its
5519
+ * operation in `BUS_OPERATIONS` instead.
5520
+ */
5521
+ declare const BRIDGED_BROADCASTS: readonly ["job:report-progress", "job:complete", "job:fail", "frame:entity-type-added", "frame:tag-schema-added", "beckon:focus", "beckon:sparkle", "bus:resume-gap"];
5522
+ type OpSpecs = (typeof BUS_OPERATIONS)[keyof typeof BUS_OPERATIONS];
5523
+ type ProgressChannel<O> = O extends {
5524
+ progress: infer P extends EventName;
5525
+ } ? P : never;
5526
+ /** The union of every reply channel declared in the registry. */
5527
+ type RegistryReply = OpSpecs['result'] | OpSpecs['failure'] | ProgressChannel<OpSpecs>;
5528
+ declare const BRIDGED_CHANNELS: readonly BridgedChannel[];
5529
+ /**
5530
+ * The SUBSCRIBE-side subset of `EventName` — the channels a client can receive
5531
+ * over a concrete transport. See the family note on `EventName` in
5532
+ * bus-protocol.ts (emit on an `EmittableChannel`, subscribe on a `BridgedChannel`).
5533
+ */
5534
+ type BridgedChannel = RegistryReply | (typeof BRIDGED_BROADCASTS)[number];
5535
+
5536
+ /**
5537
+ * The value a registered operation resolves to: the `response` field of its
5538
+ * result channel's payload, or `void` for a result channel that carries no
5539
+ * `response` (a confirmed-write ack with no data). Inferred from the registry,
5540
+ * so callers never annotate `busRequest`'s return type. Relies on the reply-shape
5541
+ * standard — see .plans/REPLY-SHAPE-STANDARD.md.
5542
+ */
5543
+ type BusReply<Op extends BusOperationKey> = EventMap[(typeof BUS_OPERATIONS)[Op]['result'] & EventName] extends {
5544
+ response: infer R;
5545
+ } ? R : void;
5546
+ type BusRequestErrorCode = 'bus.timeout' | 'bus.rejected' | 'bus.closed' | 'bus.bad-payload' | 'bus.unauthorized' | 'bus.forbidden' | 'bus.not-found';
5547
+ declare class BusRequestError extends SemiontError {
5548
+ code: BusRequestErrorCode;
5549
+ constructor(message: string, code: BusRequestErrorCode, details?: Record<string, unknown>);
5550
+ }
5551
+ /**
5552
+ * Subset of ITransport that `busRequest` needs: a way to send a command and
5553
+ * a way to observe channels. Generic enough that an in-process transport
5554
+ * can satisfy it without round-tripping through HTTP.
5555
+ */
5556
+ interface BusRequestPrimitive {
5557
+ emit<K extends keyof EventMap>(channel: K, payload: EventMap[K]): Promise<void>;
5558
+ stream<K extends keyof EventMap>(channel: K): Observable<EventMap[K]>;
5559
+ }
5560
+ /**
5561
+ * Request/reply over the bus, keyed by the operation's request channel.
5455
5562
  *
5456
- * Note: this is the *fan-in* set channels for events the transport
5457
- * receives and pushes onto the client's bus. It is not the same as the
5458
- * channels the client emits (which is open-ended).
5563
+ * The `operation` is a `BusOperationKey` (a request channel declared in
5564
+ * `BUS_OPERATIONS`); the matching `result`/`failure` reply channels are looked
5565
+ * up from the registry, so a caller cannot pass a mismatched or unbridged reply
5566
+ * pair — the recurring unbridged-reply bug class is unrepresentable. Every
5567
+ * registry reply derives into `BRIDGED_CHANNELS` (see bridged-channels.ts), so
5568
+ * the transport always subscribes to it (cf.
5569
+ * .plans/bugs/gather-resource-complete-not-bridged.md, where the `gather:resource-*`
5570
+ * pair shipped unbridged with no compile/runtime signal).
5459
5571
  *
5460
- * Resource-scoped channels (joined/left via `subscribeToResource`) are
5461
- * tracked separately by transports that care about scope (HTTP).
5572
+ * The return type is INFERRED from the registry (`BusReply<Op>` = the result
5573
+ * channel's `response` type, or `void`) callers never annotate it. Every reply
5574
+ * is `{ correlationId, response: T }` (data) or `{ correlationId }` (void); see
5575
+ * .plans/REPLY-SHAPE-STANDARD.md. `busRequest` reads `e.response`.
5462
5576
  */
5463
- declare const BRIDGED_CHANNELS: readonly ["browse:resources-result", "browse:resources-failed", "browse:resource-result", "browse:resource-failed", "browse:annotations-result", "browse:annotations-failed", "browse:annotation-result", "browse:annotation-failed", "browse:annotation-history-result", "browse:annotation-history-failed", "browse:events-result", "browse:events-failed", "browse:referenced-by-result", "browse:referenced-by-failed", "browse:entity-types-result", "browse:entity-types-failed", "browse:tag-schemas-result", "browse:tag-schemas-failed", "browse:directory-result", "browse:directory-failed", "browse:annotation-context-result", "browse:annotation-context-failed", "mark:delete-ok", "mark:delete-failed", "mark:create-ok", "mark:create-failed", "match:search-results", "match:search-failed", "gather:complete", "gather:failed", "gather:annotation-progress", "gather:annotation-finished", "gather:summary-result", "gather:summary-failed", "bind:body-updated", "bind:body-update-failed", "job:report-progress", "job:complete", "job:fail", "job:status-result", "job:status-failed", "job:created", "job:create-failed", "job:claimed", "job:claim-failed", "yield:create-ok", "yield:create-failed", "yield:update-ok", "yield:update-failed", "yield:clone-token-generated", "yield:clone-token-failed", "yield:clone-resource-result", "yield:clone-resource-failed", "yield:clone-created", "yield:clone-create-failed", "frame:entity-type-added", "frame:tag-schema-added", "beckon:focus", "beckon:sparkle", "bus:resume-gap"];
5464
- type BridgedChannel = typeof BRIDGED_CHANNELS[number];
5577
+ declare function busRequest<Op extends BusOperationKey>(bus: BusRequestPrimitive, operation: Op, payload: Record<string, unknown>, timeoutMs?: number): Promise<BusReply<Op>>;
5465
5578
 
5466
5579
  /**
5467
5580
  * Fuzzy Anchoring for W3C Web Annotation TextQuoteSelector
@@ -6128,6 +6241,33 @@ interface GoogleAuthRequest {
6128
6241
  */
6129
6242
  declare function generateUuid(): string;
6130
6243
 
6244
+ /**
6245
+ * Marker for the state-unit pattern: a stateful, lifecycled object with an
6246
+ * RxJS-shaped public surface, constructed by a factory function
6247
+ * (`createFooStateUnit`), with internal state held in a closure.
6248
+ *
6249
+ * The structural contract is `dispose()` — the rest of the pattern
6250
+ * (closure-based identity, Observable public surface, internal Subjects
6251
+ * exposed as `.asObservable()` views, no leaked subscriptions, composition
6252
+ * by parameter rather than ownership) is convention, made executable by the
6253
+ * axiom harness in `@semiont/core/testing` (`assertStateUnitAxioms`).
6254
+ *
6255
+ * Lives in `@semiont/core` (not sdk) so every layer can share one definition
6256
+ * without dependency cycles — `http-transport`'s `ActorStateUnit` sits below
6257
+ * sdk and would otherwise have to re-declare it. See
6258
+ * `packages/sdk/docs/STATE-UNITS.md` for the full pattern and rationale, and
6259
+ * `.plans/STATE-UNIT-AXIOMS.md` for the axiom ledger.
6260
+ */
6261
+ interface StateUnit {
6262
+ /**
6263
+ * Idempotent, total teardown. Completes every Subject the unit owns,
6264
+ * unsubscribes every internal subscription, releases timers / abort
6265
+ * controllers / network handles. Safe to call multiple times — the
6266
+ * second call is a no-op.
6267
+ */
6268
+ dispose(): void;
6269
+ }
6270
+
6131
6271
  /**
6132
6272
  * Common type guard utilities
6133
6273
  */
@@ -6385,7 +6525,6 @@ interface BackendServiceConfig {
6385
6525
  command?: string;
6386
6526
  port: number;
6387
6527
  publicURL: string;
6388
- corsOrigin: string;
6389
6528
  image?: string;
6390
6529
  cpu?: string;
6391
6530
  memory?: string;
@@ -6931,5 +7070,36 @@ declare function isValidPlatformType(value: string): value is PlatformType;
6931
7070
  */
6932
7071
  declare function getAllPlatformTypes(): PlatformType[];
6933
7072
 
6934
- export { AUTHORABLE_MEDIA_TYPES, BRIDGED_CHANNELS, CHANNEL_SCHEMAS, CONTEXT_FULL_WEIGHT, CONTEXT_PARTIAL_WEIGHT, ConfigurationError, ConflictError, EMBEDDABLE_MEDIA_TYPES, EventBus, JWTTokenSchema, LOCALES, MEDIA_TYPES, NotFoundError, PERSISTED_EVENT_TYPES, POSITION_WEIGHT_MAX, POSITION_WINDOW, RESOURCE_BROADCAST_TYPES, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, agentToDid, anchorAnnotation, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseMediaType, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, capabilitiesOf, cloneToken, createCircleSvg, createFragmentSelector, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, didToAgent, email, entityType, errField, extensionForMediaType, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getNodeEncoding, getPageFromFragment, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceEntityTypes, getResourceId, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, googleCredential, hasTargetSelector, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isHighlight, isNull, isNullish, isNumber, isObject, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isSupportedMediaType, isTag, isUndefined, isValidEmail, isValidPlatformType, jobId, loadTomlConfig, mcpToken, mediaTypeForExtension, normalizeCoordinates, normalizeText, parseEnvironment, parseFragmentSelector, parseSvgSelector, reconcileSelector, refreshToken, resourceAnnotationUri, resourceId, resourceUri, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, softwareToAgent, textExtractionOf, userDID, userId, userToAgent, userToDid, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
6935
- export type { AccessToken, AnchorConfidence, AnchorMethod, AnchorSelectors, AnchorStrategy, AnchoringModel, Annotation, AnnotationCategory, AnnotationId, AnnotationUri, AnthropicProviderConfig, AppConfig, AssembledAnnotation, AuthCode, BackendDownload, BackendServiceConfig, BaseUrl, BodyItem, BodyItemIdentity, BodyOperation, BoundingBox, Brand, BridgedChannel, BurstBufferOptions, BusOp, CloneToken, ConnectionState, ContentCache, ContentFormat, CreateAnnotationInternal, DatabaseServiceConfig, Email, EmbeddingServiceConfig, EmittableChannel, EntityType, EntityTypeStats, Environment, EnvironmentConfig, EventBase, EventInput, EventMap, EventMetadata, EventName, EventOfType, EventQuery, EventSignature, FragmentSelector, FrontendServiceConfig, GatheredContext, GoogleAuthRequest, GoogleCredential, GraphConnection, GraphDatabaseType, GraphPath, GraphServiceConfig, HealthCheckResponse, IBackendOperations, IContentTransport, ITransport, InferenceProvidersConfig, JobId, ListUsersResponse, LlmSelectorInput, LocaleInfo, Logger, MCPToken, MatchQuality, McpServiceConfig, MediaTypeCapabilities, Motivation, OllamaProviderConfig, PdfCoordinate, PersistedEvent, PersistedEventType, PlatformType, Point, ProgressCallback, ProgressEvent, PutBinaryOptions, PutBinaryProgress, PutBinaryRequest, ReconciledSelector, RefreshToken, RenderMode, RenderedAnchor, ResourceAnnotationUri, ResourceAnnotations, ResourceBroadcastType, ResourceDescriptor, ResourceFilter, ResourceId, ResourceUri, SearchQuery, SelectionData, Selector, SemiontConfig, ServicePlatformConfig, ServicesConfig, SiteConfig, StatusResponse, StoredEvent, StoredEventLike, SupportedMediaType, SvgSelector, TagCategory, TagSchema, TextExtraction, TextPosition, TextPositionSelector, TextQuoteSelector, ActorInferenceConfig as TomlActorInferenceConfig, TomlFileReader, InferenceConfig as TomlInferenceConfig, WorkerInferenceConfig as TomlWorkerInferenceConfig, TransportErrorCode, UpdateResourceInput, UpdateUserRequest, UpdateUserResponse, UserDID, UserId, UserResponse, ValidationFailure, ValidationResult, ValidationSuccess, VectorsServiceConfig, components, operations, paths };
7073
+ /**
7074
+ * Knowledge-graph view derivation (CONTEXT-UNIFICATION P3, Q1=A).
7075
+ *
7076
+ * A pure function over the core `KnowledgeGraph` type, so both `@semiont/make-meaning` (the matcher)
7077
+ * and `@semiont/jobs` (the generation prompt builder) can share one derivation. `buildKnowledgeGraph`
7078
+ * — which queries the graph DB — stays in make-meaning; this only transforms an already-built graph.
7079
+ *
7080
+ * Reports the graph as-is (Option A): missing-view citers are kept (the citation edge reflects a real
7081
+ * reference event); the only filter is excluding the focal annotation from siblings (an annotation
7082
+ * isn't its own sibling). Peer connections are edges out of `mainResourceId`; citations and
7083
+ * `annotation-of` edges point INTO it. The graph is a projection of the event log (the system of
7084
+ * record), read here because it is the queryable projection at gather time.
7085
+ */
7086
+
7087
+ type KnowledgeGraph = components['schemas']['KnowledgeGraph'];
7088
+ interface GraphViews {
7089
+ connections: {
7090
+ resourceId: string;
7091
+ resourceName: string;
7092
+ entityTypes: string[];
7093
+ bidirectional: boolean;
7094
+ }[];
7095
+ citedBy: {
7096
+ resourceId: string;
7097
+ resourceName: string;
7098
+ }[];
7099
+ citedByCount: number;
7100
+ siblingEntityTypes: string[];
7101
+ }
7102
+ declare function deriveViews(graph: KnowledgeGraph, mainResourceId: string, focalAnnotationId?: string): GraphViews;
7103
+
7104
+ export { AUTHORABLE_MEDIA_TYPES, BRIDGED_CHANNELS, BusRequestError, CHANNEL_SCHEMAS, CONTEXT_FULL_WEIGHT, CONTEXT_PARTIAL_WEIGHT, ConfigurationError, ConflictError, EMBEDDABLE_MEDIA_TYPES, EventBus, JWTTokenSchema, LOCALES, MEDIA_TYPES, NotFoundError, PERSISTED_EVENT_TYPES, POSITION_WEIGHT_MAX, POSITION_WINDOW, RESOURCE_BROADCAST_TYPES, ScopedEventBus, ScriptError, SemiontError, UnauthorizedError, ValidationError, accessToken, agentToDid, anchorAnnotation, annotationId, annotationUri, applyBodyOperations, assembleAnnotation, authCode, baseMediaType, baseUrl, buildContentCache, burstBuffer, busLog, busLogEnabled, busRequest, capabilitiesOf, cloneToken, createCircleSvg, createFragmentSelector, createPolygonSvg, createRectangleSvg, createTomlConfigLoader, decodeRepresentation, decodeWithCharset, deriveViews, didToAgent, email, entityType, errField, extensionForMediaType, extractBoundingBox, extractCharset, extractContext, findBestTextMatch, findBodyItem, formatLocaleDisplay, generateUuid, getAllLocaleCodes, getAllPlatformTypes, getAnnotationExactText, getAnnotationUriFromEvent, getBodySource, getBodyType, getChecksum, getCommentText, getCreator, getDerivedFrom, getExactText, getFragmentSelector, getLanguage, getLocaleEnglishName, getLocaleInfo, getLocaleNativeName, getNodeEncoding, getPageFromFragment, getPrimaryMediaType, getPrimaryRepresentation, getPrimarySelector, getResourceEntityTypes, getResourceId, getStorageUri, getSvgSelector, getTargetSelector, getTargetSource, getTextPositionSelector, getTextQuoteSelector, googleCredential, hasTargetSelector, isAnnotationId, isArchived, isArray, isAssessment, isBodyResolved, isBoolean, isComment, isDefined, isDraft, isEventRelatedToAnnotation, isFunction, isHighlight, isNull, isNullish, isNumber, isObject, isReference, isResolvedReference, isResourceId, isStoredEvent, isString, isStubReference, isSupportedMediaType, isTag, isUndefined, isValidEmail, isValidPlatformType, jobId, loadTomlConfig, mcpToken, mediaTypeForExtension, normalizeCoordinates, normalizeText, parseEnvironment, parseFragmentSelector, parseSvgSelector, reconcileSelector, refreshToken, resourceAnnotationUri, resourceId, resourceUri, scaleSvgToNative, searchQuery, serializePerKey, setBusLogTraceIdProvider, softwareToAgent, textExtractionOf, userDID, userId, userToAgent, userToDid, validateData, validateEnvironment, validateSvgMarkup, verifyPosition };
7105
+ export type { AccessToken, AnchorConfidence, AnchorMethod, AnchorSelectors, AnchorStrategy, AnchoringModel, Annotation, AnnotationCategory, AnnotationId, AnnotationUri, AnthropicProviderConfig, AppConfig, AssembledAnnotation, AuthCode, BackendDownload, BackendServiceConfig, BaseUrl, BodyItem, BodyItemIdentity, BodyOperation, BoundingBox, Brand, BridgedChannel, BurstBufferOptions, BusOp, BusRequestErrorCode, BusRequestPrimitive, CloneToken, ConnectionState, ContentCache, ContentFormat, CreateAnnotationInternal, DatabaseServiceConfig, Email, EmbeddingServiceConfig, EmittableChannel, EntityType, EntityTypeStats, Environment, EnvironmentConfig, EventBase, EventInput, EventMap, EventMetadata, EventName, EventOfType, EventQuery, EventSignature, FragmentSelector, FrontendServiceConfig, GatheredContext, GoogleAuthRequest, GoogleCredential, GraphConnection, GraphDatabaseType, GraphPath, GraphServiceConfig, GraphViews, HealthCheckResponse, IBackendOperations, IContentTransport, ITransport, InferenceProvidersConfig, JobId, ListUsersResponse, LlmSelectorInput, LocaleInfo, Logger, MCPToken, MatchQuality, McpServiceConfig, MediaTypeCapabilities, Motivation, OllamaProviderConfig, PdfCoordinate, PersistedEvent, PersistedEventType, PlatformType, Point, ProgressCallback, ProgressEvent, PutBinaryOptions, PutBinaryProgress, PutBinaryRequest, ReconciledSelector, RefreshToken, RenderMode, RenderedAnchor, ResourceAnnotationUri, ResourceAnnotations, ResourceBroadcastType, ResourceDescriptor, ResourceFilter, ResourceId, ResourceUri, SearchQuery, SelectionData, Selector, SemiontConfig, ServicePlatformConfig, ServicesConfig, SiteConfig, StateUnit, StatusResponse, StoredEvent, StoredEventLike, SupportedMediaType, SvgSelector, TagCategory, TagSchema, TextExtraction, TextPosition, TextPositionSelector, TextQuoteSelector, ActorInferenceConfig as TomlActorInferenceConfig, TomlFileReader, InferenceConfig as TomlInferenceConfig, WorkerInferenceConfig as TomlWorkerInferenceConfig, TransportErrorCode, UpdateResourceInput, UpdateUserRequest, UpdateUserResponse, UserDID, UserId, UserResponse, ValidationFailure, ValidationResult, ValidationSuccess, VectorsServiceConfig, components, operations, paths };