@semiont/api-client 0.4.2 → 0.4.4

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.js CHANGED
@@ -179,7 +179,7 @@ var SSEClient = class {
179
179
  *
180
180
  * @example
181
181
  * ```typescript
182
- * const stream = sseClient.annotateReferences(
182
+ * const stream = sseClient.markReferences(
183
183
  * 'http://localhost:4000/resources/doc-123',
184
184
  * { entityTypes: ['Person', 'Organization'] },
185
185
  * { auth: 'your-token' }
@@ -202,7 +202,7 @@ var SSEClient = class {
202
202
  * stream.close();
203
203
  * ```
204
204
  */
205
- annotateReferences(resourceId, request, options) {
205
+ markReferences(resourceId, request, options) {
206
206
  const url = `${this.baseUrl}/resources/${resourceId}/annotate-references-stream`;
207
207
  return createSSEStream(
208
208
  url,
@@ -234,7 +234,7 @@ var SSEClient = class {
234
234
  *
235
235
  * @example
236
236
  * ```typescript
237
- * const stream = sseClient.yieldResourceFromAnnotation(
237
+ * const stream = sseClient.yieldResource(
238
238
  * 'http://localhost:4000/resources/doc-123',
239
239
  * 'http://localhost:4000/annotations/ann-456',
240
240
  * { language: 'es', title: 'Spanish Summary' },
@@ -258,7 +258,7 @@ var SSEClient = class {
258
258
  * stream.close();
259
259
  * ```
260
260
  */
261
- yieldResourceFromAnnotation(resourceId, annotationId, request, options) {
261
+ yieldResource(resourceId, annotationId, request, options) {
262
262
  const url = `${this.baseUrl}/resources/${resourceId}/annotations/${annotationId}/yield-resource-stream`;
263
263
  return createSSEStream(
264
264
  url,
@@ -289,7 +289,7 @@ var SSEClient = class {
289
289
  *
290
290
  * @example
291
291
  * ```typescript
292
- * const stream = sseClient.annotateHighlights(
292
+ * const stream = sseClient.markHighlights(
293
293
  * 'http://localhost:4000/resources/doc-123',
294
294
  * { instructions: 'Focus on key technical points' },
295
295
  * { auth: 'your-token' }
@@ -312,7 +312,7 @@ var SSEClient = class {
312
312
  * stream.close();
313
313
  * ```
314
314
  */
315
- annotateHighlights(resourceId, request = {}, options) {
315
+ markHighlights(resourceId, request = {}, options) {
316
316
  const url = `${this.baseUrl}/resources/${resourceId}/annotate-highlights-stream`;
317
317
  return createSSEStream(
318
318
  url,
@@ -343,7 +343,7 @@ var SSEClient = class {
343
343
  *
344
344
  * @example
345
345
  * ```typescript
346
- * const stream = sseClient.annotateAssessments(
346
+ * const stream = sseClient.markAssessments(
347
347
  * 'http://localhost:4000/resources/doc-123',
348
348
  * { instructions: 'Evaluate claims for accuracy' },
349
349
  * { auth: 'your-token' }
@@ -366,7 +366,7 @@ var SSEClient = class {
366
366
  * stream.close();
367
367
  * ```
368
368
  */
369
- annotateAssessments(resourceId, request = {}, options) {
369
+ markAssessments(resourceId, request = {}, options) {
370
370
  const url = `${this.baseUrl}/resources/${resourceId}/annotate-assessments-stream`;
371
371
  return createSSEStream(
372
372
  url,
@@ -399,7 +399,7 @@ var SSEClient = class {
399
399
  *
400
400
  * @example
401
401
  * ```typescript
402
- * const stream = sseClient.annotateComments(
402
+ * const stream = sseClient.markComments(
403
403
  * 'http://localhost:4000/resources/doc-123',
404
404
  * {
405
405
  * instructions: 'Focus on technical terminology',
@@ -424,7 +424,7 @@ var SSEClient = class {
424
424
  * stream.close();
425
425
  * ```
426
426
  */
427
- annotateComments(resourceId, request = {}, options) {
427
+ markComments(resourceId, request = {}, options) {
428
428
  const url = `${this.baseUrl}/resources/${resourceId}/annotate-comments-stream`;
429
429
  return createSSEStream(
430
430
  url,
@@ -457,7 +457,7 @@ var SSEClient = class {
457
457
  *
458
458
  * @example
459
459
  * ```typescript
460
- * const stream = sseClient.annotateTags(
460
+ * const stream = sseClient.markTags(
461
461
  * 'http://localhost:4000/resources/doc-123',
462
462
  * {
463
463
  * schemaId: 'legal-irac',
@@ -483,7 +483,7 @@ var SSEClient = class {
483
483
  * stream.close();
484
484
  * ```
485
485
  */
486
- annotateTags(resourceId, request, options) {
486
+ markTags(resourceId, request, options) {
487
487
  const url = `${this.baseUrl}/resources/${resourceId}/annotate-tags-stream`;
488
488
  return createSSEStream(
489
489
  url,
@@ -502,11 +502,100 @@ var SSEClient = class {
502
502
  this.logger
503
503
  );
504
504
  }
505
+ /**
506
+ * Gather LLM context for a resource (streaming)
507
+ *
508
+ * Streams resource LLM context gathering progress via Server-Sent Events.
509
+ *
510
+ * @param resourceId - Resource URI or ID
511
+ * @param request - Gather configuration (depth, maxResources, includeContent, includeSummary)
512
+ * @param options - Request options (auth token, eventBus)
513
+ * @returns SSE stream controller with progress/complete/error callbacks
514
+ */
515
+ gatherResource(resourceId, request, options) {
516
+ const url = `${this.baseUrl}/resources/${resourceId}/gather-resource-stream`;
517
+ return createSSEStream(
518
+ url,
519
+ {
520
+ method: "POST",
521
+ headers: this.getHeaders(options.auth),
522
+ body: JSON.stringify(request)
523
+ },
524
+ {
525
+ progressEvents: ["gather:progress"],
526
+ completeEvent: "gather:finished",
527
+ errorEvent: "gather:failed",
528
+ eventBus: options.eventBus,
529
+ eventPrefix: void 0
530
+ },
531
+ this.logger
532
+ );
533
+ }
534
+ /**
535
+ * Gather LLM context for an annotation (streaming)
536
+ *
537
+ * Streams annotation LLM context gathering progress via Server-Sent Events.
538
+ *
539
+ * @param resourceId - Resource URI or ID
540
+ * @param annotationId - Annotation URI or ID
541
+ * @param request - Gather configuration (contextWindow)
542
+ * @param options - Request options (auth token, eventBus)
543
+ * @returns SSE stream controller with progress/complete/error callbacks
544
+ */
545
+ gatherAnnotation(resourceId, annotationId, request, options) {
546
+ const url = `${this.baseUrl}/resources/${resourceId}/annotations/${annotationId}/gather-annotation-stream`;
547
+ return createSSEStream(
548
+ url,
549
+ {
550
+ method: "POST",
551
+ headers: this.getHeaders(options.auth),
552
+ body: JSON.stringify(request)
553
+ },
554
+ {
555
+ progressEvents: ["gather:annotation-progress"],
556
+ completeEvent: "gather:annotation-finished",
557
+ errorEvent: "gather:failed",
558
+ eventBus: options.eventBus,
559
+ eventPrefix: void 0
560
+ },
561
+ this.logger
562
+ );
563
+ }
564
+ /**
565
+ * Bind annotation body (streaming)
566
+ *
567
+ * Applies annotation body operations and streams completion via Server-Sent Events.
568
+ *
569
+ * @param resourceId - Resource URI or ID
570
+ * @param annotationId - Annotation URI or ID
571
+ * @param request - Bind operations (resourceId + operations array)
572
+ * @param options - Request options (auth token, eventBus)
573
+ * @returns SSE stream controller with complete/error callbacks
574
+ */
575
+ bindAnnotation(resourceId, annotationId, request, options) {
576
+ const url = `${this.baseUrl}/resources/${resourceId}/annotations/${annotationId}/bind-stream`;
577
+ return createSSEStream(
578
+ url,
579
+ {
580
+ method: "POST",
581
+ headers: this.getHeaders(options.auth),
582
+ body: JSON.stringify(request)
583
+ },
584
+ {
585
+ progressEvents: [],
586
+ completeEvent: "bind:finished",
587
+ errorEvent: "bind:failed",
588
+ eventBus: options.eventBus,
589
+ eventPrefix: void 0
590
+ },
591
+ this.logger
592
+ );
593
+ }
505
594
  /**
506
595
  * Search for binding candidates (streaming)
507
596
  *
508
- * Bridges bind:search-requested to the backend Matcher actor via SSE.
509
- * Results emit as bind:search-results on the browser EventBus.
597
+ * Bridges match:search-requested to the backend Matcher actor via SSE.
598
+ * Results emit as match:search-results on the browser EventBus.
510
599
  *
511
600
  * @param resourceId - Resource the annotation belongs to
512
601
  * @param request - Search configuration (referenceId, context, limit)
@@ -524,8 +613,8 @@ var SSEClient = class {
524
613
  },
525
614
  {
526
615
  progressEvents: [],
527
- completeEvent: "bind:search-results",
528
- errorEvent: "bind:search-failed",
616
+ completeEvent: "match:search-results",
617
+ errorEvent: "match:search-failed",
529
618
  eventBus: options.eventBus
530
619
  },
531
620
  this.logger
@@ -640,6 +729,42 @@ var SSEClient = class {
640
729
  }
641
730
  return stream;
642
731
  }
732
+ /**
733
+ * Subscribe to participant attention stream (long-lived stream)
734
+ *
735
+ * Opens a participant-scoped SSE connection to receive cross-participant
736
+ * beckon signals. Signals are delivered as 'beckon:focus' events routed
737
+ * to the EventBus — the existing scroll/highlight machinery handles them.
738
+ *
739
+ * Signals are ephemeral — delivered if connected, dropped if not.
740
+ *
741
+ * @param options - Request options (auth token, eventBus)
742
+ * @returns SSE stream controller
743
+ */
744
+ attentionStream(options) {
745
+ const url = `${this.baseUrl}/api/participants/me/attention-stream`;
746
+ const stream = createSSEStream(
747
+ url,
748
+ {
749
+ method: "GET",
750
+ headers: this.getHeaders(options.auth)
751
+ },
752
+ {
753
+ progressEvents: ["*"],
754
+ completeEvent: null,
755
+ errorEvent: null,
756
+ eventBus: options.eventBus
757
+ },
758
+ this.logger
759
+ );
760
+ if (options.onConnected) {
761
+ const sub = options.eventBus.get(SSE_STREAM_CONNECTED).subscribe(() => {
762
+ options.onConnected();
763
+ sub.unsubscribe();
764
+ });
765
+ }
766
+ return stream;
767
+ }
643
768
  };
644
769
 
645
770
  // src/client.ts
@@ -815,7 +940,7 @@ var SemiontApiClient = class {
815
940
  * @param data.sourceResourceId - Optional source resource ID
816
941
  * @param options - Request options including auth
817
942
  */
818
- async createResource(data, options) {
943
+ async yieldResource(data, options) {
819
944
  const formData = new FormData();
820
945
  formData.append("name", data.name);
821
946
  formData.append("format", data.format);
@@ -849,7 +974,7 @@ var SemiontApiClient = class {
849
974
  auth: options?.auth
850
975
  }).json();
851
976
  }
852
- async getResource(id, options) {
977
+ async browseResource(id, options) {
853
978
  return this.http.get(`${this.baseUrl}/resources/${id}`, {
854
979
  ...options,
855
980
  auth: options?.auth
@@ -937,7 +1062,7 @@ var SemiontApiClient = class {
937
1062
  }
938
1063
  return { stream: response.body, contentType };
939
1064
  }
940
- async listResources(limit, archived, query, options) {
1065
+ async browseResources(limit, archived, query, options) {
941
1066
  const searchParams = new URLSearchParams();
942
1067
  if (limit) searchParams.append("limit", limit.toString());
943
1068
  if (archived !== void 0) searchParams.append("archived", archived.toString());
@@ -961,26 +1086,7 @@ var SemiontApiClient = class {
961
1086
  auth: options?.auth
962
1087
  }).json();
963
1088
  }
964
- async getResourceAnnotations(id, options) {
965
- return this.http.get(`${this.baseUrl}/resources/${id}/annotations`, {
966
- ...options,
967
- auth: options?.auth
968
- }).json();
969
- }
970
- async getAnnotationLLMContext(resourceId, annotationId, options) {
971
- const searchParams = new URLSearchParams();
972
- if (options?.contextWindow) {
973
- searchParams.append("contextWindow", options.contextWindow.toString());
974
- }
975
- return this.http.get(
976
- `${this.baseUrl}/resources/${resourceId}/annotations/${annotationId}/llm-context`,
977
- {
978
- searchParams,
979
- auth: options?.auth
980
- }
981
- ).json();
982
- }
983
- async getResourceReferencedBy(id, options) {
1089
+ async browseReferences(id, options) {
984
1090
  return this.http.get(`${this.baseUrl}/resources/${id}/referenced-by`, {
985
1091
  ...options,
986
1092
  auth: options?.auth
@@ -1008,7 +1114,7 @@ var SemiontApiClient = class {
1008
1114
  // ============================================================================
1009
1115
  // ANNOTATIONS
1010
1116
  // ============================================================================
1011
- async createAnnotation(id, data, options) {
1117
+ async markAnnotation(id, data, options) {
1012
1118
  return this.http.post(`${this.baseUrl}/resources/${id}/annotations`, {
1013
1119
  json: data,
1014
1120
  ...options,
@@ -1021,13 +1127,13 @@ var SemiontApiClient = class {
1021
1127
  auth: options?.auth
1022
1128
  }).json();
1023
1129
  }
1024
- async getResourceAnnotation(resourceId, annotationId, options) {
1130
+ async browseAnnotation(resourceId, annotationId, options) {
1025
1131
  return this.http.get(`${this.baseUrl}/resources/${resourceId}/annotations/${annotationId}`, {
1026
1132
  ...options,
1027
1133
  auth: options?.auth
1028
1134
  }).json();
1029
1135
  }
1030
- async listAnnotations(id, motivation, options) {
1136
+ async browseAnnotations(id, motivation, options) {
1031
1137
  const searchParams = new URLSearchParams();
1032
1138
  if (motivation) searchParams.append("motivation", motivation);
1033
1139
  return this.http.get(`${this.baseUrl}/resources/${id}/annotations`, {
@@ -1042,7 +1148,7 @@ var SemiontApiClient = class {
1042
1148
  auth: options?.auth
1043
1149
  });
1044
1150
  }
1045
- async updateAnnotationBody(resourceId, annotationId, data, options) {
1151
+ async bindAnnotation(resourceId, annotationId, data, options) {
1046
1152
  await this.http.put(`${this.baseUrl}/resources/${resourceId}/annotations/${annotationId}/body`, {
1047
1153
  json: data,
1048
1154
  ...options,
@@ -1080,6 +1186,16 @@ var SemiontApiClient = class {
1080
1186
  }).json();
1081
1187
  }
1082
1188
  // ============================================================================
1189
+ // PARTICIPANTS
1190
+ // ============================================================================
1191
+ async beckonAttention(participantId, data, options) {
1192
+ return this.http.post(`${this.baseUrl}/api/participants/${participantId}/attention`, {
1193
+ json: data,
1194
+ ...options,
1195
+ auth: options?.auth
1196
+ }).json();
1197
+ }
1198
+ // ============================================================================
1083
1199
  // ADMIN
1084
1200
  // ============================================================================
1085
1201
  async listUsers(options) {
@@ -1252,20 +1368,6 @@ var SemiontApiClient = class {
1252
1368
  }
1253
1369
  }
1254
1370
  // ============================================================================
1255
- // LLM CONTEXT
1256
- // ============================================================================
1257
- async getResourceLLMContext(id, options) {
1258
- const searchParams = new URLSearchParams();
1259
- if (options?.depth !== void 0) searchParams.append("depth", options.depth.toString());
1260
- if (options?.maxResources !== void 0) searchParams.append("maxResources", options.maxResources.toString());
1261
- if (options?.includeContent !== void 0) searchParams.append("includeContent", options.includeContent.toString());
1262
- if (options?.includeSummary !== void 0) searchParams.append("includeSummary", options.includeSummary.toString());
1263
- return this.http.get(`${this.baseUrl}/resources/${id}/llm-context`, {
1264
- searchParams,
1265
- auth: options?.auth
1266
- }).json();
1267
- }
1268
- // ============================================================================
1269
1371
  // SYSTEM STATUS
1270
1372
  // ============================================================================
1271
1373
  async healthCheck(options) {
@@ -1280,6 +1382,16 @@ var SemiontApiClient = class {
1280
1382
  }
1281
1383
  return this.http.get(`${this.baseUrl}/api/status`).json();
1282
1384
  }
1385
+ async browseFiles(dirPath, sort, options) {
1386
+ const searchParams = new URLSearchParams();
1387
+ if (dirPath) searchParams.append("path", dirPath);
1388
+ if (sort) searchParams.append("sort", sort);
1389
+ return this.http.get(`${this.baseUrl}/api/browse/files`, {
1390
+ searchParams,
1391
+ ...options,
1392
+ auth: options?.auth
1393
+ }).json();
1394
+ }
1283
1395
  };
1284
1396
  async function eventBusRequest(eventBus, requestEvent, payload, successEvent, failureEvent, timeoutMs = 3e4) {
1285
1397
  const correlationId = payload.correlationId;
@@ -1309,7 +1421,7 @@ var EventBusClient = class {
1309
1421
  // ========================================================================
1310
1422
  // Browse Flow — Resource reads
1311
1423
  // ========================================================================
1312
- async getResource(resourceId) {
1424
+ async browseResource(resourceId) {
1313
1425
  return eventBusRequest(
1314
1426
  this.eventBus,
1315
1427
  "browse:resource-requested",
@@ -1319,7 +1431,7 @@ var EventBusClient = class {
1319
1431
  this.timeoutMs
1320
1432
  );
1321
1433
  }
1322
- async listResources(options) {
1434
+ async browseResources(options) {
1323
1435
  return eventBusRequest(
1324
1436
  this.eventBus,
1325
1437
  "browse:resources-requested",
@@ -1381,10 +1493,10 @@ var EventBusClient = class {
1381
1493
  async getReferencedBy(resourceId, motivation) {
1382
1494
  return eventBusRequest(
1383
1495
  this.eventBus,
1384
- "bind:referenced-by-requested",
1496
+ "browse:referenced-by-requested",
1385
1497
  { correlationId: crypto.randomUUID(), resourceId, motivation },
1386
- "bind:referenced-by-result",
1387
- "bind:referenced-by-failed",
1498
+ "browse:referenced-by-result",
1499
+ "browse:referenced-by-failed",
1388
1500
  this.timeoutMs
1389
1501
  );
1390
1502
  }
@@ -1394,10 +1506,10 @@ var EventBusClient = class {
1394
1506
  async listEntityTypes() {
1395
1507
  return eventBusRequest(
1396
1508
  this.eventBus,
1397
- "mark:entity-types-requested",
1509
+ "browse:entity-types-requested",
1398
1510
  { correlationId: crypto.randomUUID() },
1399
- "mark:entity-types-result",
1400
- "mark:entity-types-failed",
1511
+ "browse:entity-types-result",
1512
+ "browse:entity-types-failed",
1401
1513
  this.timeoutMs
1402
1514
  );
1403
1515
  }
@@ -1453,7 +1565,7 @@ var EventBusClient = class {
1453
1565
  // ========================================================================
1454
1566
  // Gather Flow — LLM context
1455
1567
  // ========================================================================
1456
- async getAnnotationLLMContext(annotationId, resourceId, options) {
1568
+ async gatherAnnotation(annotationId, resourceId, options) {
1457
1569
  const correlationId = crypto.randomUUID();
1458
1570
  const result$ = merge(
1459
1571
  this.eventBus.get("gather:complete").pipe(
@@ -1478,7 +1590,7 @@ var EventBusClient = class {
1478
1590
  }
1479
1591
  return result.response;
1480
1592
  }
1481
- async getResourceLLMContext(resourceId, options) {
1593
+ async gatherResource(resourceId, options) {
1482
1594
  const correlationId = crypto.randomUUID();
1483
1595
  const result$ = merge(
1484
1596
  this.eventBus.get("gather:resource-complete").pipe(
@@ -1509,17 +1621,17 @@ var EventBusClient = class {
1509
1621
  const correlationId = crypto.randomUUID();
1510
1622
  const referenceId = correlationId;
1511
1623
  const result$ = merge(
1512
- this.eventBus.get("bind:search-results").pipe(
1624
+ this.eventBus.get("match:search-results").pipe(
1513
1625
  filter((e) => e.correlationId === correlationId),
1514
1626
  map((e) => ({ ok: true, results: e.results }))
1515
1627
  ),
1516
- this.eventBus.get("bind:search-failed").pipe(
1628
+ this.eventBus.get("match:search-failed").pipe(
1517
1629
  filter((e) => e.correlationId === correlationId),
1518
1630
  map((e) => ({ ok: false, error: e.error }))
1519
1631
  )
1520
1632
  ).pipe(take(1), timeout(this.timeoutMs));
1521
1633
  const resultPromise = firstValueFrom(result$);
1522
- this.eventBus.get("bind:search-requested").next({
1634
+ this.eventBus.get("match:search-requested").next({
1523
1635
  correlationId,
1524
1636
  referenceId,
1525
1637
  context: {