@semiont/backend 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
@@ -2,7 +2,7 @@
2
2
  import winston from 'winston';
3
3
  import { z } from 'zod';
4
4
  import jwt from 'jsonwebtoken';
5
- import { email, userId, accessToken, googleCredential, annotationId, resourceId, EventBus, jobId, entityType, assembleAnnotation, userToAgent } from '@semiont/core';
5
+ import { email, userId, accessToken, googleCredential, annotationId, resourceId, userToDid, EventBus, jobId, entityType, assembleAnnotation, userToAgent } from '@semiont/core';
6
6
  import { cors } from 'hono/cors';
7
7
  import { serve } from '@hono/node-server';
8
8
  import { Hono } from 'hono';
@@ -613,7 +613,7 @@ var require_timeoutProvider = __commonJS({
613
613
  });
614
614
  exports$1.timeoutProvider = void 0;
615
615
  exports$1.timeoutProvider = {
616
- setTimeout: /* @__PURE__ */ __name(function(handler, timeout4) {
616
+ setTimeout: /* @__PURE__ */ __name(function(handler, timeout2) {
617
617
  var args = [];
618
618
  for (var _i = 2; _i < arguments.length; _i++) {
619
619
  args[_i - 2] = arguments[_i];
@@ -622,12 +622,12 @@ var require_timeoutProvider = __commonJS({
622
622
  if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
623
623
  return delegate.setTimeout.apply(delegate, __spreadArray([
624
624
  handler,
625
- timeout4
625
+ timeout2
626
626
  ], __read(args)));
627
627
  }
628
628
  return setTimeout.apply(void 0, __spreadArray([
629
629
  handler,
630
- timeout4
630
+ timeout2
631
631
  ], __read(args)));
632
632
  }, "setTimeout"),
633
633
  clearTimeout: /* @__PURE__ */ __name(function(handle) {
@@ -1580,9 +1580,9 @@ var require_Subject = __commonJS({
1580
1580
  var ObjectUnsubscribedError_1 = require_ObjectUnsubscribedError();
1581
1581
  var arrRemove_1 = require_arrRemove();
1582
1582
  var errorContext_1 = require_errorContext();
1583
- var Subject = (function(_super) {
1584
- __extends(Subject2, _super);
1585
- function Subject2() {
1583
+ var Subject2 = (function(_super) {
1584
+ __extends(Subject3, _super);
1585
+ function Subject3() {
1586
1586
  var _this = _super.call(this) || this;
1587
1587
  _this.closed = false;
1588
1588
  _this.currentObservers = null;
@@ -1592,18 +1592,18 @@ var require_Subject = __commonJS({
1592
1592
  _this.thrownError = null;
1593
1593
  return _this;
1594
1594
  }
1595
- __name(Subject2, "Subject");
1596
- Subject2.prototype.lift = function(operator) {
1595
+ __name(Subject3, "Subject");
1596
+ Subject3.prototype.lift = function(operator) {
1597
1597
  var subject = new AnonymousSubject(this, this);
1598
1598
  subject.operator = operator;
1599
1599
  return subject;
1600
1600
  };
1601
- Subject2.prototype._throwIfClosed = function() {
1601
+ Subject3.prototype._throwIfClosed = function() {
1602
1602
  if (this.closed) {
1603
1603
  throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
1604
1604
  }
1605
1605
  };
1606
- Subject2.prototype.next = function(value) {
1606
+ Subject3.prototype.next = function(value) {
1607
1607
  var _this = this;
1608
1608
  errorContext_1.errorContext(function() {
1609
1609
  var e_1, _a;
@@ -1631,7 +1631,7 @@ var require_Subject = __commonJS({
1631
1631
  }
1632
1632
  });
1633
1633
  };
1634
- Subject2.prototype.error = function(err) {
1634
+ Subject3.prototype.error = function(err) {
1635
1635
  var _this = this;
1636
1636
  errorContext_1.errorContext(function() {
1637
1637
  _this._throwIfClosed();
@@ -1645,7 +1645,7 @@ var require_Subject = __commonJS({
1645
1645
  }
1646
1646
  });
1647
1647
  };
1648
- Subject2.prototype.complete = function() {
1648
+ Subject3.prototype.complete = function() {
1649
1649
  var _this = this;
1650
1650
  errorContext_1.errorContext(function() {
1651
1651
  _this._throwIfClosed();
@@ -1658,11 +1658,11 @@ var require_Subject = __commonJS({
1658
1658
  }
1659
1659
  });
1660
1660
  };
1661
- Subject2.prototype.unsubscribe = function() {
1661
+ Subject3.prototype.unsubscribe = function() {
1662
1662
  this.isStopped = this.closed = true;
1663
1663
  this.observers = this.currentObservers = null;
1664
1664
  };
1665
- Object.defineProperty(Subject2.prototype, "observed", {
1665
+ Object.defineProperty(Subject3.prototype, "observed", {
1666
1666
  get: /* @__PURE__ */ __name(function() {
1667
1667
  var _a;
1668
1668
  return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
@@ -1670,16 +1670,16 @@ var require_Subject = __commonJS({
1670
1670
  enumerable: false,
1671
1671
  configurable: true
1672
1672
  });
1673
- Subject2.prototype._trySubscribe = function(subscriber) {
1673
+ Subject3.prototype._trySubscribe = function(subscriber) {
1674
1674
  this._throwIfClosed();
1675
1675
  return _super.prototype._trySubscribe.call(this, subscriber);
1676
1676
  };
1677
- Subject2.prototype._subscribe = function(subscriber) {
1677
+ Subject3.prototype._subscribe = function(subscriber) {
1678
1678
  this._throwIfClosed();
1679
1679
  this._checkFinalizedStatuses(subscriber);
1680
1680
  return this._innerSubscribe(subscriber);
1681
1681
  };
1682
- Subject2.prototype._innerSubscribe = function(subscriber) {
1682
+ Subject3.prototype._innerSubscribe = function(subscriber) {
1683
1683
  var _this = this;
1684
1684
  var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
1685
1685
  if (hasError || isStopped) {
@@ -1692,7 +1692,7 @@ var require_Subject = __commonJS({
1692
1692
  arrRemove_1.arrRemove(observers, subscriber);
1693
1693
  });
1694
1694
  };
1695
- Subject2.prototype._checkFinalizedStatuses = function(subscriber) {
1695
+ Subject3.prototype._checkFinalizedStatuses = function(subscriber) {
1696
1696
  var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
1697
1697
  if (hasError) {
1698
1698
  subscriber.error(thrownError);
@@ -1700,17 +1700,17 @@ var require_Subject = __commonJS({
1700
1700
  subscriber.complete();
1701
1701
  }
1702
1702
  };
1703
- Subject2.prototype.asObservable = function() {
1703
+ Subject3.prototype.asObservable = function() {
1704
1704
  var observable = new Observable_1.Observable();
1705
1705
  observable.source = this;
1706
1706
  return observable;
1707
1707
  };
1708
- Subject2.create = function(destination, source) {
1708
+ Subject3.create = function(destination, source) {
1709
1709
  return new AnonymousSubject(destination, source);
1710
1710
  };
1711
- return Subject2;
1711
+ return Subject3;
1712
1712
  })(Observable_1.Observable);
1713
- exports$1.Subject = Subject;
1713
+ exports$1.Subject = Subject2;
1714
1714
  var AnonymousSubject = (function(_super) {
1715
1715
  __extends(AnonymousSubject2, _super);
1716
1716
  function AnonymousSubject2(destination, source) {
@@ -1737,7 +1737,7 @@ var require_Subject = __commonJS({
1737
1737
  return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : Subscription_1.EMPTY_SUBSCRIPTION;
1738
1738
  };
1739
1739
  return AnonymousSubject2;
1740
- })(Subject);
1740
+ })(Subject2);
1741
1741
  exports$1.AnonymousSubject = AnonymousSubject;
1742
1742
  }
1743
1743
  });
@@ -2061,7 +2061,7 @@ var require_intervalProvider = __commonJS({
2061
2061
  });
2062
2062
  exports$1.intervalProvider = void 0;
2063
2063
  exports$1.intervalProvider = {
2064
- setInterval: /* @__PURE__ */ __name(function(handler, timeout4) {
2064
+ setInterval: /* @__PURE__ */ __name(function(handler, timeout2) {
2065
2065
  var args = [];
2066
2066
  for (var _i = 2; _i < arguments.length; _i++) {
2067
2067
  args[_i - 2] = arguments[_i];
@@ -2070,12 +2070,12 @@ var require_intervalProvider = __commonJS({
2070
2070
  if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
2071
2071
  return delegate.setInterval.apply(delegate, __spreadArray([
2072
2072
  handler,
2073
- timeout4
2073
+ timeout2
2074
2074
  ], __read(args)));
2075
2075
  }
2076
2076
  return setInterval.apply(void 0, __spreadArray([
2077
2077
  handler,
2078
- timeout4
2078
+ timeout2
2079
2079
  ], __read(args)));
2080
2080
  }, "setInterval"),
2081
2081
  clearInterval: /* @__PURE__ */ __name(function(handle) {
@@ -4283,7 +4283,7 @@ var require_firstValueFrom = __commonJS({
4283
4283
  exports$1.firstValueFrom = void 0;
4284
4284
  var EmptyError_1 = require_EmptyError();
4285
4285
  var Subscriber_1 = require_Subscriber();
4286
- function firstValueFrom4(source, config2) {
4286
+ function firstValueFrom2(source, config2) {
4287
4287
  var hasConfig = typeof config2 === "object";
4288
4288
  return new Promise(function(resolve, reject) {
4289
4289
  var subscriber = new Subscriber_1.SafeSubscriber({
@@ -4303,8 +4303,8 @@ var require_firstValueFrom = __commonJS({
4303
4303
  source.subscribe(subscriber);
4304
4304
  });
4305
4305
  }
4306
- __name(firstValueFrom4, "firstValueFrom");
4307
- exports$1.firstValueFrom = firstValueFrom4;
4306
+ __name(firstValueFrom2, "firstValueFrom");
4307
+ exports$1.firstValueFrom = firstValueFrom2;
4308
4308
  }
4309
4309
  });
4310
4310
 
@@ -4402,7 +4402,7 @@ var require_timeout = __commonJS({
4402
4402
  this.info = info;
4403
4403
  }, "TimeoutErrorImpl");
4404
4404
  });
4405
- function timeout4(config2, schedulerArg) {
4405
+ function timeout2(config2, schedulerArg) {
4406
4406
  var _a = isDate_1.isValidDate(config2) ? {
4407
4407
  first: config2
4408
4408
  } : typeof config2 === "number" ? {
@@ -4444,8 +4444,8 @@ var require_timeout = __commonJS({
4444
4444
  !seen && startTimer(first != null ? typeof first === "number" ? first : +first - scheduler.now() : each);
4445
4445
  });
4446
4446
  }
4447
- __name(timeout4, "timeout");
4448
- exports$1.timeout = timeout4;
4447
+ __name(timeout2, "timeout");
4448
+ exports$1.timeout = timeout2;
4449
4449
  function timeoutErrorFactory(info) {
4450
4450
  throw new exports$1.TimeoutError(info);
4451
4451
  }
@@ -4462,7 +4462,7 @@ var require_map = __commonJS({
4462
4462
  exports$1.map = void 0;
4463
4463
  var lift_1 = require_lift();
4464
4464
  var OperatorSubscriber_1 = require_OperatorSubscriber();
4465
- function map4(project, thisArg) {
4465
+ function map2(project, thisArg) {
4466
4466
  return lift_1.operate(function(source, subscriber) {
4467
4467
  var index = 0;
4468
4468
  source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function(value) {
@@ -4470,8 +4470,8 @@ var require_map = __commonJS({
4470
4470
  }));
4471
4471
  });
4472
4472
  }
4473
- __name(map4, "map");
4474
- exports$1.map = map4;
4473
+ __name(map2, "map");
4474
+ exports$1.map = map2;
4475
4475
  }
4476
4476
  });
4477
4477
 
@@ -5501,7 +5501,7 @@ var require_merge = __commonJS({
5501
5501
  var empty_1 = require_empty();
5502
5502
  var args_1 = require_args();
5503
5503
  var from_1 = require_from();
5504
- function merge4() {
5504
+ function merge2() {
5505
5505
  var args = [];
5506
5506
  for (var _i = 0; _i < arguments.length; _i++) {
5507
5507
  args[_i] = arguments[_i];
@@ -5511,8 +5511,8 @@ var require_merge = __commonJS({
5511
5511
  var sources = args;
5512
5512
  return !sources.length ? empty_1.EMPTY : sources.length === 1 ? innerFrom_1.innerFrom(sources[0]) : mergeAll_1.mergeAll(concurrent)(from_1.from(sources, scheduler));
5513
5513
  }
5514
- __name(merge4, "merge");
5515
- exports$1.merge = merge4;
5514
+ __name(merge2, "merge");
5515
+ exports$1.merge = merge2;
5516
5516
  }
5517
5517
  });
5518
5518
 
@@ -5636,7 +5636,7 @@ var require_filter = __commonJS({
5636
5636
  exports$1.filter = void 0;
5637
5637
  var lift_1 = require_lift();
5638
5638
  var OperatorSubscriber_1 = require_OperatorSubscriber();
5639
- function filter4(predicate, thisArg) {
5639
+ function filter2(predicate, thisArg) {
5640
5640
  return lift_1.operate(function(source, subscriber) {
5641
5641
  var index = 0;
5642
5642
  source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function(value) {
@@ -5644,8 +5644,8 @@ var require_filter = __commonJS({
5644
5644
  }));
5645
5645
  });
5646
5646
  }
5647
- __name(filter4, "filter");
5648
- exports$1.filter = filter4;
5647
+ __name(filter2, "filter");
5648
+ exports$1.filter = filter2;
5649
5649
  }
5650
5650
  });
5651
5651
 
@@ -6901,7 +6901,7 @@ var require_take = __commonJS({
6901
6901
  var empty_1 = require_empty();
6902
6902
  var lift_1 = require_lift();
6903
6903
  var OperatorSubscriber_1 = require_OperatorSubscriber();
6904
- function take4(count) {
6904
+ function take2(count) {
6905
6905
  return count <= 0 ? function() {
6906
6906
  return empty_1.EMPTY;
6907
6907
  } : lift_1.operate(function(source, subscriber) {
@@ -6916,8 +6916,8 @@ var require_take = __commonJS({
6916
6916
  }));
6917
6917
  });
6918
6918
  }
6919
- __name(take4, "take");
6920
- exports$1.take = take4;
6919
+ __name(take2, "take");
6920
+ exports$1.take = take2;
6921
6921
  }
6922
6922
  });
6923
6923
 
@@ -7807,7 +7807,7 @@ var require_merge2 = __commonJS({
7807
7807
  var mergeAll_1 = require_mergeAll();
7808
7808
  var args_1 = require_args();
7809
7809
  var from_1 = require_from();
7810
- function merge4() {
7810
+ function merge2() {
7811
7811
  var args = [];
7812
7812
  for (var _i = 0; _i < arguments.length; _i++) {
7813
7813
  args[_i] = arguments[_i];
@@ -7820,8 +7820,8 @@ var require_merge2 = __commonJS({
7820
7820
  ], __read(args)), scheduler)).subscribe(subscriber);
7821
7821
  });
7822
7822
  }
7823
- __name(merge4, "merge");
7824
- exports$1.merge = merge4;
7823
+ __name(merge2, "merge");
7824
+ exports$1.merge = merge2;
7825
7825
  }
7826
7826
  });
7827
7827
 
@@ -12760,6 +12760,127 @@ var openapi_default = {
12760
12760
  "isNewUser"
12761
12761
  ]
12762
12762
  },
12763
+ BrowseFilesResponse: {
12764
+ type: "object",
12765
+ required: [
12766
+ "path",
12767
+ "entries"
12768
+ ],
12769
+ properties: {
12770
+ path: {
12771
+ type: "string",
12772
+ description: "The directory path that was listed, relative to project root"
12773
+ },
12774
+ entries: {
12775
+ type: "array",
12776
+ items: {
12777
+ $ref: "#/components/schemas/DirectoryEntry"
12778
+ }
12779
+ }
12780
+ },
12781
+ additionalProperties: false
12782
+ },
12783
+ DirectoryEntry: {
12784
+ oneOf: [
12785
+ {
12786
+ $ref: "#/components/schemas/FileEntry"
12787
+ },
12788
+ {
12789
+ $ref: "#/components/schemas/DirEntry"
12790
+ }
12791
+ ]
12792
+ },
12793
+ FileEntry: {
12794
+ type: "object",
12795
+ required: [
12796
+ "type",
12797
+ "name",
12798
+ "path",
12799
+ "size",
12800
+ "mtime",
12801
+ "tracked"
12802
+ ],
12803
+ properties: {
12804
+ type: {
12805
+ type: "string",
12806
+ enum: [
12807
+ "file"
12808
+ ]
12809
+ },
12810
+ name: {
12811
+ type: "string",
12812
+ description: "Entry name (basename)"
12813
+ },
12814
+ path: {
12815
+ type: "string",
12816
+ description: "Path relative to project root"
12817
+ },
12818
+ size: {
12819
+ type: "integer",
12820
+ description: "File size in bytes"
12821
+ },
12822
+ mtime: {
12823
+ type: "string",
12824
+ format: "date-time",
12825
+ description: "Last modified time (ISO 8601)"
12826
+ },
12827
+ tracked: {
12828
+ type: "boolean",
12829
+ description: "True if this file is a tracked resource in the Knowledge Base"
12830
+ },
12831
+ resourceId: {
12832
+ type: "string",
12833
+ description: "Resource ID (only when tracked is true)"
12834
+ },
12835
+ entityTypes: {
12836
+ type: "array",
12837
+ items: {
12838
+ type: "string"
12839
+ },
12840
+ description: "Entity types assigned to this resource (only when tracked is true)"
12841
+ },
12842
+ annotationCount: {
12843
+ type: "integer",
12844
+ description: "Number of annotations on this resource (only when tracked is true)"
12845
+ },
12846
+ creator: {
12847
+ type: "string",
12848
+ description: "DID of the user who created the resource (only when tracked is true)"
12849
+ }
12850
+ },
12851
+ additionalProperties: false
12852
+ },
12853
+ DirEntry: {
12854
+ type: "object",
12855
+ required: [
12856
+ "type",
12857
+ "name",
12858
+ "path",
12859
+ "mtime"
12860
+ ],
12861
+ properties: {
12862
+ type: {
12863
+ type: "string",
12864
+ enum: [
12865
+ "dir"
12866
+ ]
12867
+ },
12868
+ name: {
12869
+ type: "string",
12870
+ description: "Entry name (basename)"
12871
+ },
12872
+ path: {
12873
+ type: "string",
12874
+ description: "Path relative to project root"
12875
+ },
12876
+ mtime: {
12877
+ type: "string",
12878
+ format: "date-time",
12879
+ description: "Last modified time (ISO 8601)"
12880
+ }
12881
+ },
12882
+ additionalProperties: false
12883
+ },
12763
12884
  BodyOperationAdd: {
12764
12885
  type: "object",
12765
12886
  properties: {
@@ -12854,6 +12975,48 @@ var openapi_default = {
12854
12975
  ],
12855
12976
  description: "Annotation body type - TextualBody for textual content, SpecificResource for resource links"
12856
12977
  },
12978
+ BeckonRequest: {
12979
+ type: "object",
12980
+ properties: {
12981
+ resourceId: {
12982
+ type: "string",
12983
+ description: "Resource to direct attention at"
12984
+ },
12985
+ annotationId: {
12986
+ type: "string",
12987
+ description: "Specific annotation within the resource (optional)"
12988
+ },
12989
+ message: {
12990
+ type: "string",
12991
+ description: "Human-readable context for the participant (max 500 chars)",
12992
+ maxLength: 500
12993
+ }
12994
+ },
12995
+ required: [
12996
+ "resourceId"
12997
+ ]
12998
+ },
12999
+ BeckonResponse: {
13000
+ type: "object",
13001
+ properties: {
13002
+ participant: {
13003
+ type: "string",
13004
+ description: "Username or agent identifier that was beckoned"
13005
+ },
13006
+ resourceId: {
13007
+ type: "string",
13008
+ description: "Resource the attention was directed at"
13009
+ },
13010
+ annotationId: {
13011
+ type: "string",
13012
+ description: "Annotation the attention was directed at (if provided)"
13013
+ }
13014
+ },
13015
+ required: [
13016
+ "participant",
13017
+ "resourceId"
13018
+ ]
13019
+ },
12857
13020
  BulkAddEntityTypesRequest: {
12858
13021
  type: "object",
12859
13022
  properties: {
@@ -13333,6 +13496,73 @@ var openapi_default = {
13333
13496
  "entityTypes"
13334
13497
  ]
13335
13498
  },
13499
+ GatherResourceStreamRequest: {
13500
+ type: "object",
13501
+ properties: {
13502
+ depth: {
13503
+ type: "integer",
13504
+ minimum: 1,
13505
+ maximum: 3,
13506
+ description: "Graph traversal depth (default: 2)"
13507
+ },
13508
+ maxResources: {
13509
+ type: "integer",
13510
+ minimum: 1,
13511
+ maximum: 20,
13512
+ description: "Maximum related resources to include (default: 10)"
13513
+ },
13514
+ includeContent: {
13515
+ type: "boolean",
13516
+ description: "Include full resource content (default: true)"
13517
+ },
13518
+ includeSummary: {
13519
+ type: "boolean",
13520
+ description: "Include AI-generated summary (default: false)"
13521
+ }
13522
+ }
13523
+ },
13524
+ GatherAnnotationStreamRequest: {
13525
+ type: "object",
13526
+ properties: {
13527
+ contextWindow: {
13528
+ type: "integer",
13529
+ minimum: 100,
13530
+ maximum: 5e3,
13531
+ description: "Characters of surrounding text context (default: 1000)"
13532
+ }
13533
+ }
13534
+ },
13535
+ BindAnnotationStreamRequest: {
13536
+ type: "object",
13537
+ properties: {
13538
+ resourceId: {
13539
+ type: "string",
13540
+ description: "Resource ID containing the annotation (required for O(1) Layer 3 lookup)"
13541
+ },
13542
+ operations: {
13543
+ type: "array",
13544
+ items: {
13545
+ oneOf: [
13546
+ {
13547
+ $ref: "#/components/schemas/BodyOperationAdd"
13548
+ },
13549
+ {
13550
+ $ref: "#/components/schemas/BodyOperationRemove"
13551
+ },
13552
+ {
13553
+ $ref: "#/components/schemas/BodyOperationReplace"
13554
+ }
13555
+ ]
13556
+ },
13557
+ minItems: 1,
13558
+ description: "Array of body modification operations to apply"
13559
+ }
13560
+ },
13561
+ required: [
13562
+ "resourceId",
13563
+ "operations"
13564
+ ]
13565
+ },
13336
13566
  AnnotateHighlightsStreamRequest: {
13337
13567
  type: "object",
13338
13568
  properties: {
@@ -13370,6 +13600,10 @@ var openapi_default = {
13370
13600
  minimum: 1,
13371
13601
  maximum: 10,
13372
13602
  description: "Optional density: desired number of assessments per 2000 words of text (1-10)"
13603
+ },
13604
+ language: {
13605
+ type: "string",
13606
+ description: 'BCP 47 language tag for the generated assessment text (e.g. "en", "fr", "de")'
13373
13607
  }
13374
13608
  }
13375
13609
  },
@@ -13395,6 +13629,10 @@ var openapi_default = {
13395
13629
  minimum: 2,
13396
13630
  maximum: 12,
13397
13631
  description: "Optional density: desired number of comments per 2000 words of text (2-12)"
13632
+ },
13633
+ language: {
13634
+ type: "string",
13635
+ description: "BCP 47 language tag for the generated comment text (e.g. 'en', 'fr', 'de')"
13398
13636
  }
13399
13637
  }
13400
13638
  },
@@ -14220,20 +14458,12 @@ var openapi_default = {
14220
14458
  type: "string",
14221
14459
  enum: [
14222
14460
  "assessing",
14223
- "bookmarking",
14224
- "classifying",
14225
14461
  "commenting",
14226
- "describing",
14227
- "editing",
14228
14462
  "highlighting",
14229
- "identifying",
14230
14463
  "linking",
14231
- "moderating",
14232
- "questioning",
14233
- "replying",
14234
14464
  "tagging"
14235
14465
  ],
14236
- description: "W3C Web Annotation motivation vocabulary - https://www.w3.org/TR/annotation-vocab/#motivation"
14466
+ description: "Semiont-supported W3C Web Annotation motivations - https://www.w3.org/TR/annotation-vocab/#motivation"
14237
14467
  },
14238
14468
  OAuthConfigResponse: {
14239
14469
  type: "object",
@@ -14593,6 +14823,20 @@ var openapi_default = {
14593
14823
  }
14594
14824
  ]
14595
14825
  },
14826
+ generator: {
14827
+ description: "Software agent that produced or processed this resource (W3C Web Annotation model)",
14828
+ oneOf: [
14829
+ {
14830
+ $ref: "#/components/schemas/Agent"
14831
+ },
14832
+ {
14833
+ type: "array",
14834
+ items: {
14835
+ $ref: "#/components/schemas/Agent"
14836
+ }
14837
+ }
14838
+ ]
14839
+ },
14596
14840
  conformsTo: {
14597
14841
  description: "Profile/shape URI this resource description conforms to.",
14598
14842
  oneOf: [
@@ -14803,7 +15047,7 @@ var openapi_default = {
14803
15047
  description: "IRI of the target resource"
14804
15048
  },
14805
15049
  purpose: {
14806
- $ref: "#/components/schemas/Motivation",
15050
+ $ref: "#/components/schemas/BodyPurpose",
14807
15051
  description: "Why this body is included"
14808
15052
  }
14809
15053
  },
@@ -14916,7 +15160,7 @@ var openapi_default = {
14916
15160
  description: "The text content (e.g., entity type name)"
14917
15161
  },
14918
15162
  purpose: {
14919
- $ref: "#/components/schemas/Motivation",
15163
+ $ref: "#/components/schemas/BodyPurpose",
14920
15164
  description: "Why this body is included"
14921
15165
  },
14922
15166
  format: {
@@ -15179,6 +15423,25 @@ var openapi_default = {
15179
15423
  "value"
15180
15424
  ]
15181
15425
  },
15426
+ BodyPurpose: {
15427
+ type: "string",
15428
+ enum: [
15429
+ "assessing",
15430
+ "bookmarking",
15431
+ "classifying",
15432
+ "commenting",
15433
+ "describing",
15434
+ "editing",
15435
+ "highlighting",
15436
+ "identifying",
15437
+ "linking",
15438
+ "moderating",
15439
+ "questioning",
15440
+ "replying",
15441
+ "tagging"
15442
+ ],
15443
+ description: "W3C Web Annotation body purpose vocabulary - https://www.w3.org/TR/annotation-vocab/#motivation"
15444
+ },
15182
15445
  GatheredContext: {
15183
15446
  type: "object",
15184
15447
  description: "Context gathered for an annotation. Includes source document excerpts, metadata, and graph-derived context. Used by both Find (bind) and Generate (yield) flows.",
@@ -16255,8 +16518,8 @@ exchangeRouter.post("/api/admin/exchange/backup", async (c) => {
16255
16518
  (async () => {
16256
16519
  try {
16257
16520
  await exportBackup({
16258
- eventStore: mm.kb.eventStore,
16259
- content: mm.kb.content,
16521
+ eventStore: mm.knowledgeSystem.kb.eventStore,
16522
+ content: mm.knowledgeSystem.kb.content,
16260
16523
  sourceUrl
16261
16524
  }, nodeWritable);
16262
16525
  } catch (err) {
@@ -16355,8 +16618,8 @@ exchangeRouter.post("/api/moderate/exchange/export", async (c) => {
16355
16618
  (async () => {
16356
16619
  try {
16357
16620
  await exportLinkedData({
16358
- views: mm.kb.views,
16359
- content: mm.kb.content,
16621
+ views: mm.knowledgeSystem.kb.views,
16622
+ content: mm.knowledgeSystem.kb.content,
16360
16623
  sourceUrl,
16361
16624
  entityTypes,
16362
16625
  includeArchived
@@ -16475,7 +16738,7 @@ function registerCreateResource(router) {
16475
16738
  entityTypes,
16476
16739
  creationMethod: creationMethod || void 0,
16477
16740
  storageUri: storageUri || void 0
16478
- }, userId(user.id), eventBus2);
16741
+ }, userId(userToDid(user)), eventBus2);
16479
16742
  return c.json({
16480
16743
  resourceId: resourceId20
16481
16744
  }, 202);
@@ -16792,7 +17055,7 @@ function registerGetResourceUri(router) {
16792
17055
  }
16793
17056
  const acceptHeader = c.req.header("Accept") || "application/ld+json";
16794
17057
  if (acceptHeader.includes("text/") || acceptHeader.includes("image/") || acceptHeader.includes("application/pdf")) {
16795
- const { kb } = c.get("makeMeaning");
17058
+ const { knowledgeSystem: { kb } } = c.get("makeMeaning");
16796
17059
  let resource;
16797
17060
  try {
16798
17061
  resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
@@ -16906,7 +17169,7 @@ function registerUpdateResource(router) {
16906
17169
  const body = c.get("validatedBody");
16907
17170
  const user = c.get("user");
16908
17171
  const eventBus2 = c.get("eventBus");
16909
- const { kb } = c.get("makeMeaning");
17172
+ const { knowledgeSystem: { kb } } = c.get("makeMeaning");
16910
17173
  const doc = await ResourceContext.getResourceMetadata(resourceId(id), kb);
16911
17174
  if (!doc) {
16912
17175
  throw new HTTPException(404, {
@@ -16915,7 +17178,7 @@ function registerUpdateResource(router) {
16915
17178
  }
16916
17179
  await ResourceOperations.updateResource({
16917
17180
  resourceId: resourceId(id),
16918
- userId: userId(user.id),
17181
+ userId: userId(userToDid(user)),
16919
17182
  currentArchived: doc.archived,
16920
17183
  updatedArchived: body.archived,
16921
17184
  currentEntityTypes: doc.entityTypes,
@@ -16985,7 +17248,7 @@ function registerAnnotateReferencesStream(router, jobQueue) {
16985
17248
  });
16986
17249
  }
16987
17250
  const eventBus2 = c.get("eventBus");
16988
- const { kb } = c.get("makeMeaning");
17251
+ const { knowledgeSystem: { kb } } = c.get("makeMeaning");
16989
17252
  const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
16990
17253
  if (!resource) {
16991
17254
  throw new HTTPException(404, {
@@ -16997,7 +17260,7 @@ function registerAnnotateReferencesStream(router, jobQueue) {
16997
17260
  metadata: {
16998
17261
  id: jobId(`job-${nanoid()}`),
16999
17262
  type: "reference-annotation",
17000
- userId: userId(user.id),
17263
+ userId: userId(userToDid(user)),
17001
17264
  userName: user.name || user.email,
17002
17265
  userEmail: user.email,
17003
17266
  userDomain: user.domain,
@@ -17187,7 +17450,7 @@ function registerAnnotateHighlightsStream(router, jobQueue) {
17187
17450
  });
17188
17451
  }
17189
17452
  const eventBus2 = c.get("eventBus");
17190
- const { kb } = c.get("makeMeaning");
17453
+ const { knowledgeSystem: { kb } } = c.get("makeMeaning");
17191
17454
  const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
17192
17455
  if (!resource) {
17193
17456
  throw new HTTPException(404, {
@@ -17199,7 +17462,7 @@ function registerAnnotateHighlightsStream(router, jobQueue) {
17199
17462
  metadata: {
17200
17463
  id: jobId(`job-${nanoid()}`),
17201
17464
  type: "highlight-annotation",
17202
- userId: userId(user.id),
17465
+ userId: userId(userToDid(user)),
17203
17466
  userName: user.name || user.email,
17204
17467
  userEmail: user.email,
17205
17468
  userDomain: user.domain,
@@ -17375,7 +17638,7 @@ function registerAnnotateAssessmentsStream(router, jobQueue) {
17375
17638
  router.post("/resources/:id/annotate-assessments-stream", validateRequestBody("AnnotateAssessmentsStreamRequest"), async (c) => {
17376
17639
  const { id } = c.req.param();
17377
17640
  const body = c.get("validatedBody");
17378
- const { instructions, tone, density } = body;
17641
+ const { instructions, tone, density, language } = body;
17379
17642
  if (density !== void 0 && (typeof density !== "number" || density < 1 || density > 10)) {
17380
17643
  throw new HTTPException(400, {
17381
17644
  message: "Invalid density. Must be a number between 1 and 10."
@@ -17397,7 +17660,7 @@ function registerAnnotateAssessmentsStream(router, jobQueue) {
17397
17660
  });
17398
17661
  }
17399
17662
  const eventBus2 = c.get("eventBus");
17400
- const { kb } = c.get("makeMeaning");
17663
+ const { knowledgeSystem: { kb } } = c.get("makeMeaning");
17401
17664
  const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
17402
17665
  if (!resource) {
17403
17666
  throw new HTTPException(404, {
@@ -17409,7 +17672,7 @@ function registerAnnotateAssessmentsStream(router, jobQueue) {
17409
17672
  metadata: {
17410
17673
  id: jobId(`job-${nanoid()}`),
17411
17674
  type: "assessment-annotation",
17412
- userId: userId(user.id),
17675
+ userId: userId(userToDid(user)),
17413
17676
  userName: user.name || user.email,
17414
17677
  userEmail: user.email,
17415
17678
  userDomain: user.domain,
@@ -17421,7 +17684,8 @@ function registerAnnotateAssessmentsStream(router, jobQueue) {
17421
17684
  resourceId: resourceId(id),
17422
17685
  instructions,
17423
17686
  tone,
17424
- density
17687
+ density,
17688
+ language
17425
17689
  }
17426
17690
  };
17427
17691
  await jobQueue.createJob(job);
@@ -17596,7 +17860,7 @@ function registerAnnotateCommentsStream(router, jobQueue) {
17596
17860
  router.post("/resources/:id/annotate-comments-stream", validateRequestBody("AnnotateCommentsStreamRequest"), async (c) => {
17597
17861
  const { id } = c.req.param();
17598
17862
  const body = c.get("validatedBody");
17599
- const { instructions, tone, density } = body;
17863
+ const { instructions, tone, density, language } = body;
17600
17864
  if (density !== void 0 && (typeof density !== "number" || density < 2 || density > 12)) {
17601
17865
  throw new HTTPException(400, {
17602
17866
  message: "Invalid density. Must be a number between 2 and 12."
@@ -17618,7 +17882,7 @@ function registerAnnotateCommentsStream(router, jobQueue) {
17618
17882
  });
17619
17883
  }
17620
17884
  const eventBus2 = c.get("eventBus");
17621
- const { kb } = c.get("makeMeaning");
17885
+ const { knowledgeSystem: { kb } } = c.get("makeMeaning");
17622
17886
  const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
17623
17887
  if (!resource) {
17624
17888
  throw new HTTPException(404, {
@@ -17630,7 +17894,7 @@ function registerAnnotateCommentsStream(router, jobQueue) {
17630
17894
  metadata: {
17631
17895
  id: jobId(`job-${nanoid()}`),
17632
17896
  type: "comment-annotation",
17633
- userId: userId(user.id),
17897
+ userId: userId(userToDid(user)),
17634
17898
  userName: user.name || user.email,
17635
17899
  userEmail: user.email,
17636
17900
  userDomain: user.domain,
@@ -17642,7 +17906,8 @@ function registerAnnotateCommentsStream(router, jobQueue) {
17642
17906
  resourceId: resourceId(id),
17643
17907
  instructions,
17644
17908
  tone,
17645
- density
17909
+ density,
17910
+ language
17646
17911
  }
17647
17912
  };
17648
17913
  await jobQueue.createJob(job);
@@ -18010,7 +18275,7 @@ function registerAnnotateTagsStream(router, jobQueue) {
18010
18275
  });
18011
18276
  }
18012
18277
  const eventBus2 = c.get("eventBus");
18013
- const { kb } = c.get("makeMeaning");
18278
+ const { knowledgeSystem: { kb } } = c.get("makeMeaning");
18014
18279
  const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
18015
18280
  if (!resource) {
18016
18281
  throw new HTTPException(404, {
@@ -18022,7 +18287,7 @@ function registerAnnotateTagsStream(router, jobQueue) {
18022
18287
  metadata: {
18023
18288
  id: jobId(`job-${nanoid()}`),
18024
18289
  type: "tag-annotation",
18025
- userId: userId(user.id),
18290
+ userId: userId(userToDid(user)),
18026
18291
  userName: user.name || user.email,
18027
18292
  userEmail: user.email,
18028
18293
  userDomain: user.domain,
@@ -18198,134 +18463,6 @@ function registerAnnotateTagsStream(router, jobQueue) {
18198
18463
  });
18199
18464
  }
18200
18465
  __name(registerAnnotateTagsStream, "registerAnnotateTagsStream");
18201
-
18202
- // src/routes/resources/routes/llm-context.ts
18203
- var import_rxjs2 = __toESM(require_cjs());
18204
- var import_operators2 = __toESM(require_operators());
18205
- function registerGetResourceLLMContext(router) {
18206
- router.get("/resources/:id/llm-context", async (c) => {
18207
- const { id } = c.req.param();
18208
- const query = c.req.query();
18209
- const eventBus2 = c.get("eventBus");
18210
- const depth = query.depth ? Number(query.depth) : 2;
18211
- const maxResources = query.maxResources ? Number(query.maxResources) : 10;
18212
- const includeContent = query.includeContent === "false" ? false : true;
18213
- const includeSummary = query.includeSummary === "true" ? true : false;
18214
- if (depth < 1 || depth > 3) {
18215
- throw new HTTPException(400, {
18216
- message: 'Query parameter "depth" must be between 1 and 3'
18217
- });
18218
- }
18219
- if (maxResources < 1 || maxResources > 20) {
18220
- throw new HTTPException(400, {
18221
- message: 'Query parameter "maxResources" must be between 1 and 20'
18222
- });
18223
- }
18224
- eventBus2.get("gather:resource-requested").next({
18225
- resourceId: resourceId(id),
18226
- options: {
18227
- depth,
18228
- maxResources,
18229
- includeContent,
18230
- includeSummary
18231
- }
18232
- });
18233
- try {
18234
- const result = await (0, import_rxjs2.firstValueFrom)((0, import_rxjs2.merge)(eventBus2.get("gather:resource-complete").pipe((0, import_operators2.filter)((e) => e.resourceId === id), (0, import_operators2.map)((e) => ({
18235
- ok: true,
18236
- context: e.context
18237
- }))), eventBus2.get("gather:resource-failed").pipe((0, import_operators2.filter)((e) => e.resourceId === id), (0, import_operators2.map)((e) => ({
18238
- ok: false,
18239
- error: e.error
18240
- })))).pipe((0, import_operators2.take)(1), (0, import_operators2.timeout)(3e4)));
18241
- if (!result.ok) {
18242
- throw result.error;
18243
- }
18244
- return c.json(result.context);
18245
- } catch (error) {
18246
- if (error instanceof Error) {
18247
- if (error.message === "Resource not found") {
18248
- throw new HTTPException(404, {
18249
- message: "Resource not found"
18250
- });
18251
- }
18252
- if (error.name === "TimeoutError") {
18253
- throw new HTTPException(504, {
18254
- message: "Context gathering timed out"
18255
- });
18256
- }
18257
- }
18258
- throw error;
18259
- }
18260
- });
18261
- }
18262
- __name(registerGetResourceLLMContext, "registerGetResourceLLMContext");
18263
-
18264
- // src/routes/resources/routes/annotation-llm-context.ts
18265
- var import_rxjs3 = __toESM(require_cjs());
18266
- var import_operators3 = __toESM(require_operators());
18267
- function registerGetAnnotationLLMContext(router) {
18268
- router.get("/resources/:resourceId/annotations/:annotationId/llm-context", async (c) => {
18269
- const { resourceId: resourceIdParam, annotationId: annotationIdParam } = c.req.param();
18270
- const query = c.req.query();
18271
- const eventBus2 = c.get("eventBus");
18272
- const includeSourceContext = query.includeSourceContext === "false" ? false : true;
18273
- const includeTargetContext = query.includeTargetContext === "false" ? false : true;
18274
- const contextWindow = query.contextWindow ? Number(query.contextWindow) : 1e3;
18275
- if (contextWindow < 100 || contextWindow > 5e3) {
18276
- throw new HTTPException(400, {
18277
- message: 'Query parameter "contextWindow" must be between 100 and 5000'
18278
- });
18279
- }
18280
- eventBus2.get("gather:requested").next({
18281
- annotationId: annotationId(annotationIdParam),
18282
- resourceId: resourceId(resourceIdParam),
18283
- options: {
18284
- includeSourceContext,
18285
- includeTargetContext,
18286
- contextWindow
18287
- }
18288
- });
18289
- try {
18290
- const result = await (0, import_rxjs3.firstValueFrom)((0, import_rxjs3.merge)(eventBus2.get("gather:complete").pipe((0, import_operators3.filter)((e) => e.annotationId === annotationIdParam), (0, import_operators3.map)((e) => ({
18291
- ok: true,
18292
- response: e.response
18293
- }))), eventBus2.get("gather:failed").pipe((0, import_operators3.filter)((e) => e.annotationId === annotationIdParam), (0, import_operators3.map)((e) => ({
18294
- ok: false,
18295
- error: e.error
18296
- })))).pipe((0, import_operators3.take)(1), (0, import_operators3.timeout)(3e4)));
18297
- if (!result.ok) {
18298
- throw result.error;
18299
- }
18300
- return c.json(result.response);
18301
- } catch (error) {
18302
- if (error instanceof Error) {
18303
- if (error.message === "Annotation not found") {
18304
- throw new HTTPException(404, {
18305
- message: "Annotation not found"
18306
- });
18307
- }
18308
- if (error.message === "Source resource not found") {
18309
- throw new HTTPException(404, {
18310
- message: "Source resource not found"
18311
- });
18312
- }
18313
- if (error.message === "Source content not found") {
18314
- throw new HTTPException(404, {
18315
- message: "Source content not found"
18316
- });
18317
- }
18318
- if (error.name === "TimeoutError") {
18319
- throw new HTTPException(504, {
18320
- message: "Context gathering timed out"
18321
- });
18322
- }
18323
- }
18324
- throw error;
18325
- }
18326
- });
18327
- }
18328
- __name(registerGetAnnotationLLMContext, "registerGetAnnotationLLMContext");
18329
18466
  function registerGetReferencedBy(router) {
18330
18467
  router.get("/resources/:id/referenced-by", async (c) => {
18331
18468
  const { id } = c.req.param();
@@ -18333,11 +18470,11 @@ function registerGetReferencedBy(router) {
18333
18470
  const eventBus2 = c.get("eventBus");
18334
18471
  const correlationId = crypto.randomUUID();
18335
18472
  try {
18336
- const response = await eventBusRequest(eventBus2, "bind:referenced-by-requested", {
18473
+ const response = await eventBusRequest(eventBus2, "browse:referenced-by-requested", {
18337
18474
  correlationId,
18338
18475
  resourceId: resourceId(id),
18339
18476
  motivation
18340
- }, "bind:referenced-by-result", "bind:referenced-by-failed");
18477
+ }, "browse:referenced-by-result", "browse:referenced-by-failed");
18341
18478
  return c.json(response);
18342
18479
  } catch (error) {
18343
18480
  if (error instanceof Error && error.name === "TimeoutError") {
@@ -18372,7 +18509,7 @@ function registerBindSearchStream(router) {
18372
18509
  });
18373
18510
  }
18374
18511
  const eventBus2 = c.get("eventBus");
18375
- const { kb } = c.get("makeMeaning");
18512
+ const { knowledgeSystem: { kb } } = c.get("makeMeaning");
18376
18513
  const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
18377
18514
  if (!resource) {
18378
18515
  throw new HTTPException(404, {
@@ -18400,7 +18537,7 @@ function registerBindSearchStream(router) {
18400
18537
  if (closeStreamCallback) closeStreamCallback();
18401
18538
  }, "cleanup");
18402
18539
  try {
18403
- subscriptions.push(eventBus2.get("bind:search-results").subscribe(async (event) => {
18540
+ subscriptions.push(eventBus2.get("match:search-results").subscribe(async (event) => {
18404
18541
  if (event.correlationId !== correlationId) return;
18405
18542
  if (isStreamClosed) return;
18406
18543
  logger2.info("Bind search completed", {
@@ -18413,7 +18550,7 @@ function registerBindSearchStream(router) {
18413
18550
  referenceId: event.referenceId,
18414
18551
  results: event.results
18415
18552
  }),
18416
- event: "bind:search-results",
18553
+ event: "match:search-results",
18417
18554
  id: String(Date.now())
18418
18555
  });
18419
18556
  } catch (error) {
@@ -18421,7 +18558,7 @@ function registerBindSearchStream(router) {
18421
18558
  }
18422
18559
  cleanup();
18423
18560
  }));
18424
- subscriptions.push(eventBus2.get("bind:search-failed").subscribe(async (event) => {
18561
+ subscriptions.push(eventBus2.get("match:search-failed").subscribe(async (event) => {
18425
18562
  if (event.correlationId !== correlationId) return;
18426
18563
  if (isStreamClosed) return;
18427
18564
  logger2.error("Bind search failed", {
@@ -18434,7 +18571,7 @@ function registerBindSearchStream(router) {
18434
18571
  referenceId: event.referenceId,
18435
18572
  error: event.error.message
18436
18573
  }),
18437
- event: "bind:search-failed",
18574
+ event: "match:search-failed",
18438
18575
  id: String(Date.now())
18439
18576
  });
18440
18577
  } catch (error) {
@@ -18442,7 +18579,7 @@ function registerBindSearchStream(router) {
18442
18579
  }
18443
18580
  cleanup();
18444
18581
  }));
18445
- eventBus2.get("bind:search-requested").next({
18582
+ eventBus2.get("match:search-requested").next({
18446
18583
  correlationId,
18447
18584
  referenceId,
18448
18585
  context,
@@ -18460,7 +18597,7 @@ function registerBindSearchStream(router) {
18460
18597
  referenceId,
18461
18598
  error: error instanceof Error ? error.message : "Search failed"
18462
18599
  }),
18463
- event: "bind:search-failed",
18600
+ event: "match:search-failed",
18464
18601
  id: String(Date.now())
18465
18602
  });
18466
18603
  } catch (sseError) {
@@ -18516,7 +18653,7 @@ function registerTokenRoutes(router) {
18516
18653
  token: body.token,
18517
18654
  name: body.name,
18518
18655
  content: body.content,
18519
- userId: userId(user.id),
18656
+ userId: userId(userToDid(user)),
18520
18657
  archiveOriginal: body.archiveOriginal
18521
18658
  }, "yield:clone-created", "yield:clone-create-failed");
18522
18659
  return c.json({
@@ -18659,7 +18796,7 @@ function registerGetEventStream(router) {
18659
18796
  logger2.info("Client connecting to resource events stream", {
18660
18797
  resourceId: rId
18661
18798
  });
18662
- const { eventStore } = c.get("makeMeaning");
18799
+ const { knowledgeSystem: { kb: { eventStore } } } = c.get("makeMeaning");
18663
18800
  const query = new EventQuery(eventStore.log.storage);
18664
18801
  const events = await query.getResourceEvents(rId);
18665
18802
  if (events.length === 0) {
@@ -18808,7 +18945,7 @@ function registerCreateAnnotation(router) {
18808
18945
  const eventBus2 = c.get("eventBus");
18809
18946
  eventBus2.get("mark:create").next({
18810
18947
  annotation,
18811
- userId: userId(user.id),
18948
+ userId: userId(userToDid(user)),
18812
18949
  resourceId: resourceId(id)
18813
18950
  });
18814
18951
  return c.json({
@@ -18854,7 +18991,7 @@ function registerDeleteAnnotation(router) {
18854
18991
  const eventBus2 = c.get("eventBus");
18855
18992
  eventBus2.get("mark:delete").next({
18856
18993
  annotationId: annotationId(annotationIdParam),
18857
- userId: userId(user.id),
18994
+ userId: userId(userToDid(user)),
18858
18995
  resourceId: resourceId(resourceIdParam)
18859
18996
  });
18860
18997
  return c.body(null, 202);
@@ -18870,7 +19007,7 @@ function registerUpdateAnnotationBody(router) {
18870
19007
  eventBus2.get("mark:update-body").next({
18871
19008
  annotationId: annotationId(annotationIdParam),
18872
19009
  resourceId: resourceId(resourceIdParam),
18873
- userId: userId(user.id),
19010
+ userId: userId(userToDid(user)),
18874
19011
  operations: request.operations
18875
19012
  });
18876
19013
  return c.body(null, 202);
@@ -18897,7 +19034,7 @@ function registerYieldResourceStream(router, jobQueue) {
18897
19034
  });
18898
19035
  }
18899
19036
  const eventBus2 = c.get("eventBus");
18900
- const { kb } = c.get("makeMeaning");
19037
+ const { knowledgeSystem: { kb } } = c.get("makeMeaning");
18901
19038
  logger2.info("Starting resource generation", {
18902
19039
  language: body.language
18903
19040
  });
@@ -18933,7 +19070,7 @@ function registerYieldResourceStream(router, jobQueue) {
18933
19070
  metadata: {
18934
19071
  id: jobId(`job-${nanoid()}`),
18935
19072
  type: "generation",
18936
- userId: userId(user.id),
19073
+ userId: userId(userToDid(user)),
18937
19074
  userName: user.name || user.email,
18938
19075
  userEmail: user.email,
18939
19076
  userDomain: user.domain,
@@ -19094,6 +19231,121 @@ function registerYieldResourceStream(router, jobQueue) {
19094
19231
  });
19095
19232
  }
19096
19233
  __name(registerYieldResourceStream, "registerYieldResourceStream");
19234
+ init_logger();
19235
+ function registerGatherAnnotationStream(router) {
19236
+ router.post("/resources/:resourceId/annotations/:annotationId/gather-annotation-stream", validateRequestBody("GatherAnnotationStreamRequest"), async (c) => {
19237
+ const { resourceId: resourceIdParam, annotationId: annotationIdParam } = c.req.param();
19238
+ const body = c.get("validatedBody");
19239
+ const contextWindow = body.contextWindow ?? 1e3;
19240
+ const eventBus2 = c.get("eventBus");
19241
+ const logger2 = getLogger().child({
19242
+ component: "gather-annotation-stream",
19243
+ resourceId: resourceIdParam,
19244
+ annotationId: annotationIdParam
19245
+ });
19246
+ const user = c.get("user");
19247
+ if (!user) {
19248
+ throw new HTTPException(401, {
19249
+ message: "Authentication required"
19250
+ });
19251
+ }
19252
+ eventBus2.get("gather:requested").next({
19253
+ annotationId: annotationId(annotationIdParam),
19254
+ resourceId: resourceId(resourceIdParam),
19255
+ options: {
19256
+ includeSourceContext: true,
19257
+ includeTargetContext: true,
19258
+ contextWindow
19259
+ }
19260
+ });
19261
+ logger2.info("Emitted gather:requested", {
19262
+ annotationId: annotationIdParam,
19263
+ contextWindow
19264
+ });
19265
+ c.header("X-Accel-Buffering", "no");
19266
+ c.header("Cache-Control", "no-cache, no-transform");
19267
+ return streamSSE(c, async (stream) => {
19268
+ let isStreamClosed = false;
19269
+ const subscriptions = [];
19270
+ let keepAliveInterval = null;
19271
+ const streamPromise = new Promise((resolve) => {
19272
+ const cleanup = /* @__PURE__ */ __name(() => {
19273
+ if (isStreamClosed) return;
19274
+ isStreamClosed = true;
19275
+ if (keepAliveInterval) clearInterval(keepAliveInterval);
19276
+ subscriptions.forEach((sub) => sub.unsubscribe());
19277
+ resolve();
19278
+ }, "cleanup");
19279
+ subscriptions.push(eventBus2.get("gather:annotation-progress").subscribe(async (event) => {
19280
+ if (isStreamClosed) return;
19281
+ try {
19282
+ await writeTypedSSE(stream, {
19283
+ data: JSON.stringify({
19284
+ message: event.message,
19285
+ percentage: event.percentage
19286
+ }),
19287
+ event: "gather:annotation-progress",
19288
+ id: String(Date.now())
19289
+ });
19290
+ } catch {
19291
+ cleanup();
19292
+ }
19293
+ }));
19294
+ subscriptions.push(eventBus2.get("gather:complete").subscribe(async (event) => {
19295
+ if (event.annotationId !== annotationIdParam) return;
19296
+ if (isStreamClosed) return;
19297
+ try {
19298
+ await writeTypedSSE(stream, {
19299
+ data: JSON.stringify({
19300
+ annotationId: event.annotationId,
19301
+ response: event.response
19302
+ }),
19303
+ event: "gather:annotation-finished",
19304
+ id: String(Date.now())
19305
+ });
19306
+ } catch {
19307
+ }
19308
+ cleanup();
19309
+ }));
19310
+ subscriptions.push(eventBus2.get("gather:failed").subscribe(async (event) => {
19311
+ if (event.annotationId !== annotationIdParam) return;
19312
+ if (isStreamClosed) return;
19313
+ try {
19314
+ await writeTypedSSE(stream, {
19315
+ data: JSON.stringify({
19316
+ annotationId: event.annotationId,
19317
+ error: event.error
19318
+ }),
19319
+ event: "gather:failed",
19320
+ id: String(Date.now())
19321
+ });
19322
+ } catch {
19323
+ }
19324
+ cleanup();
19325
+ }));
19326
+ keepAliveInterval = setInterval(async () => {
19327
+ if (isStreamClosed) {
19328
+ clearInterval(keepAliveInterval);
19329
+ return;
19330
+ }
19331
+ try {
19332
+ await stream.writeSSE({
19333
+ data: ":keep-alive"
19334
+ });
19335
+ } catch {
19336
+ cleanup();
19337
+ }
19338
+ }, 3e4);
19339
+ c.req.raw.signal.addEventListener("abort", () => {
19340
+ logger2.info("Client disconnected from gather stream");
19341
+ cleanup();
19342
+ });
19343
+ });
19344
+ return streamPromise;
19345
+ });
19346
+ });
19347
+ }
19348
+ __name(registerGatherAnnotationStream, "registerGatherAnnotationStream");
19097
19349
  function registerGetAnnotationHistory(router) {
19098
19350
  router.get("/resources/:resourceId/annotations/:annotationId/history", async (c) => {
19099
19351
  const { resourceId: resourceId20, annotationId: annotationId6 } = c.req.param();
@@ -19141,8 +19393,6 @@ function createResourcesRouter(jobQueue) {
19141
19393
  registerAnnotateAssessmentsStream(resourcesRouter2, jobQueue);
19142
19394
  registerAnnotateCommentsStream(resourcesRouter2, jobQueue);
19143
19395
  registerAnnotateTagsStream(resourcesRouter2, jobQueue);
19144
- registerGetResourceLLMContext(resourcesRouter2);
19145
- registerGetAnnotationLLMContext(resourcesRouter2);
19146
19396
  registerGetReferencedBy(resourcesRouter2);
19147
19397
  registerBindSearchStream(resourcesRouter2);
19148
19398
  registerGetResourceAnnotations(resourcesRouter2);
@@ -19150,6 +19400,7 @@ function createResourcesRouter(jobQueue) {
19150
19400
  registerGetAnnotation(resourcesRouter2);
19151
19401
  registerUpdateAnnotationBody(resourcesRouter2);
19152
19402
  registerYieldResourceStream(resourcesRouter2, jobQueue);
19403
+ registerGatherAnnotationStream(resourcesRouter2);
19153
19404
  registerGetAnnotationHistory(resourcesRouter2);
19154
19405
  registerDeleteAnnotation(resourcesRouter2);
19155
19406
  registerGetEvents(resourcesRouter2);
@@ -19170,7 +19421,7 @@ function registerGetAnnotationUri(router) {
19170
19421
  router.get("/annotations/:id", async (c) => {
19171
19422
  const { id } = c.req.param();
19172
19423
  const query = c.req.query();
19173
- const { kb } = c.get("makeMeaning");
19424
+ const { knowledgeSystem: { kb } } = c.get("makeMeaning");
19174
19425
  const resourceIdParam = query.resourceId;
19175
19426
  if (!resourceIdParam) {
19176
19427
  throw new HTTPException(400, {
@@ -19210,7 +19461,7 @@ var operationsRouter = createAnnotationRouter();
19210
19461
  operationsRouter.get("/api/annotations/:id/context", async (c) => {
19211
19462
  const { id } = c.req.param();
19212
19463
  const query = c.req.query();
19213
- const { kb } = c.get("makeMeaning");
19464
+ const { knowledgeSystem: { kb } } = c.get("makeMeaning");
19214
19465
  const resourceId20 = query.resourceId;
19215
19466
  if (!resourceId20) {
19216
19467
  throw new HTTPException(400, {
@@ -19259,7 +19510,7 @@ operationsRouter.get("/api/annotations/:id/context", async (c) => {
19259
19510
  operationsRouter.get("/api/annotations/:id/summary", async (c) => {
19260
19511
  const { id } = c.req.param();
19261
19512
  const query = c.req.query();
19262
- const { kb, gathererInferenceClient: inferenceClient } = c.get("makeMeaning");
19513
+ const { knowledgeSystem: { gatherer } } = c.get("makeMeaning");
19263
19514
  const resourceId20 = query.resourceId;
19264
19515
  if (!resourceId20) {
19265
19516
  throw new HTTPException(400, {
@@ -19267,7 +19518,7 @@ operationsRouter.get("/api/annotations/:id/summary", async (c) => {
19267
19518
  });
19268
19519
  }
19269
19520
  try {
19270
- const response = await AnnotationContext.generateAnnotationSummary(annotationId(id), resourceId(resourceId20), kb, inferenceClient);
19521
+ const response = await gatherer.generateAnnotationSummary(annotationId(id), resourceId(resourceId20));
19271
19522
  return c.json(response);
19272
19523
  } catch (error) {
19273
19524
  if (error instanceof Error && error.message === "Annotation not found") {
@@ -19300,9 +19551,9 @@ entityTypesRouter.use("/api/entity-types/*", authMiddleware);
19300
19551
  entityTypesRouter.get("/api/entity-types", async (c) => {
19301
19552
  const eventBus2 = c.get("eventBus");
19302
19553
  const correlationId = crypto.randomUUID();
19303
- const response = await eventBusRequest(eventBus2, "mark:entity-types-requested", {
19554
+ const response = await eventBusRequest(eventBus2, "browse:entity-types-requested", {
19304
19555
  correlationId
19305
- }, "mark:entity-types-result", "mark:entity-types-failed");
19556
+ }, "browse:entity-types-result", "browse:entity-types-failed");
19306
19557
  return c.json(response, 200);
19307
19558
  });
19308
19559
  entityTypesRouter.post("/api/entity-types", validateRequestBody("AddEntityTypeRequest"), async (c) => {
@@ -19316,7 +19567,7 @@ entityTypesRouter.post("/api/entity-types", validateRequestBody("AddEntityTypeRe
19316
19567
  const eventBus2 = c.get("eventBus");
19317
19568
  eventBus2.get("mark:add-entity-type").next({
19318
19569
  tag: body.tag,
19319
- userId: userId(user.id)
19570
+ userId: userId(userToDid(user))
19320
19571
  });
19321
19572
  return c.body(null, 202);
19322
19573
  });
@@ -19332,7 +19583,7 @@ entityTypesRouter.post("/api/entity-types/bulk", validateRequestBody("BulkAddEnt
19332
19583
  for (const tag of body.tags) {
19333
19584
  eventBus2.get("mark:add-entity-type").next({
19334
19585
  tag,
19335
- userId: userId(user.id)
19586
+ userId: userId(userToDid(user))
19336
19587
  });
19337
19588
  }
19338
19589
  return c.body(null, 202);
@@ -19346,7 +19597,7 @@ globalEventsRouter.use("/api/events/stream", authMiddleware);
19346
19597
  globalEventsRouter.get("/api/events/stream", async (c) => {
19347
19598
  const logger2 = getRouteLogger4();
19348
19599
  logger2.info("Client connecting to global events stream");
19349
- const { eventStore } = c.get("makeMeaning");
19600
+ const { knowledgeSystem: { kb: { eventStore } } } = c.get("makeMeaning");
19350
19601
  return streamSSE(c, async (stream) => {
19351
19602
  await stream.writeSSE({
19352
19603
  data: JSON.stringify({
@@ -19472,6 +19723,162 @@ function createJobsRouter(_jobQueue, authMiddleware2) {
19472
19723
  }
19473
19724
  __name(createJobsRouter, "createJobsRouter");
19474
19725
 
19726
+ // src/routes/participants/attention-channels.ts
19727
+ var import_rxjs2 = __toESM(require_cjs());
19728
+ var channels = /* @__PURE__ */ new Map();
19729
+ function getOrCreateChannel(participantId) {
19730
+ if (!channels.has(participantId)) {
19731
+ channels.set(participantId, new import_rxjs2.Subject());
19732
+ }
19733
+ return channels.get(participantId);
19734
+ }
19735
+ __name(getOrCreateChannel, "getOrCreateChannel");
19736
+ function removeChannel(participantId) {
19737
+ channels.get(participantId)?.complete();
19738
+ channels.delete(participantId);
19739
+ }
19740
+ __name(removeChannel, "removeChannel");
19741
+
19742
+ // src/routes/participants/routes/beckon.ts
19743
+ function registerBeckon(router) {
19744
+ router.post("/api/participants/:id/attention", validateRequestBody("BeckonRequest"), async (c) => {
19745
+ const { id: participantId } = c.req.param();
19746
+ const request = c.get("validatedBody");
19747
+ getOrCreateChannel(participantId).next({
19748
+ resourceId: request.resourceId,
19749
+ ...request.annotationId ? {
19750
+ annotationId: request.annotationId
19751
+ } : {}
19752
+ });
19753
+ return c.json({
19754
+ participant: participantId,
19755
+ resourceId: resourceId(request.resourceId),
19756
+ ...request.annotationId ? {
19757
+ annotationId: request.annotationId
19758
+ } : {}
19759
+ }, 202);
19760
+ });
19761
+ }
19762
+ __name(registerBeckon, "registerBeckon");
19763
+ init_logger();
19764
+ function registerAttentionStream(router) {
19765
+ router.get("/api/participants/me/attention-stream", async (c) => {
19766
+ const user = c.get("user");
19767
+ const participantId = user.id;
19768
+ const logger2 = getLogger().child({
19769
+ component: "attention-stream",
19770
+ participantId
19771
+ });
19772
+ logger2.info("Client connecting to attention stream");
19773
+ return streamSSE(c, async (stream) => {
19774
+ await stream.writeSSE({
19775
+ data: JSON.stringify({
19776
+ type: "connected",
19777
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
19778
+ message: "Attention stream connected"
19779
+ }),
19780
+ event: SSE_STREAM_CONNECTED,
19781
+ id: String(Date.now())
19782
+ });
19783
+ let isStreamClosed = false;
19784
+ let keepAliveInterval = null;
19785
+ let closeStreamCallback = null;
19786
+ const streamPromise = new Promise((resolve) => {
19787
+ closeStreamCallback = resolve;
19788
+ });
19789
+ const cleanup = /* @__PURE__ */ __name(() => {
19790
+ if (isStreamClosed) return;
19791
+ isStreamClosed = true;
19792
+ if (keepAliveInterval) clearInterval(keepAliveInterval);
19793
+ subscription.unsubscribe();
19794
+ removeChannel(participantId);
19795
+ closeStreamCallback?.();
19796
+ }, "cleanup");
19797
+ const subject = getOrCreateChannel(participantId);
19798
+ const subscription = subject.subscribe(async (signal) => {
19799
+ if (isStreamClosed) return;
19800
+ try {
19801
+ await stream.writeSSE({
19802
+ data: JSON.stringify(signal),
19803
+ event: "beckon:focus",
19804
+ id: String(Date.now())
19805
+ });
19806
+ } catch (error) {
19807
+ logger2.error("Error writing beckon signal to attention stream", {
19808
+ error
19809
+ });
19810
+ cleanup();
19811
+ }
19812
+ });
19813
+ keepAliveInterval = setInterval(async () => {
19814
+ if (isStreamClosed) {
19815
+ if (keepAliveInterval) clearInterval(keepAliveInterval);
19816
+ return;
19817
+ }
19818
+ try {
19819
+ await stream.writeSSE({
19820
+ data: ":keep-alive"
19821
+ });
19822
+ } catch {
19823
+ cleanup();
19824
+ }
19825
+ }, 3e4);
19826
+ c.req.raw.signal.addEventListener("abort", () => {
19827
+ logger2.info("Client disconnected from attention stream");
19828
+ cleanup();
19829
+ });
19830
+ return streamPromise;
19831
+ });
19832
+ });
19833
+ }
19834
+ __name(registerAttentionStream, "registerAttentionStream");
19835
+
19836
+ // src/routes/participants/index.ts
19837
+ var participantsRouter = new Hono();
19838
+ participantsRouter.use("/api/participants/*", authMiddleware);
19839
+ registerBeckon(participantsRouter);
19840
+ registerAttentionStream(participantsRouter);
19841
+ var browseRouter = new Hono();
19842
+ browseRouter.use("/api/browse/*", authMiddleware);
19843
+ browseRouter.get("/api/browse/files", async (c) => {
19844
+ const reqPath = c.req.query("path") ?? "";
19845
+ const sort = c.req.query("sort");
19846
+ if (sort !== void 0 && sort !== "name" && sort !== "mtime" && sort !== "annotationCount") {
19847
+ throw new HTTPException(400, {
19848
+ message: 'Invalid sort value. Must be "name", "mtime", or "annotationCount".'
19849
+ });
19850
+ }
19851
+ const eventBus2 = c.get("eventBus");
19852
+ const correlationId = crypto.randomUUID();
19853
+ try {
19854
+ const response = await eventBusRequest(eventBus2, "browse:directory-requested", {
19855
+ correlationId,
19856
+ path: reqPath,
19857
+ sort
19858
+ }, "browse:directory-result", "browse:directory-failed");
19859
+ return c.json(response);
19860
+ } catch (error) {
19861
+ if (error instanceof Error) {
19862
+ if (error.name === "TimeoutError") {
19863
+ throw new HTTPException(504, {
19864
+ message: "Request timed out"
19865
+ });
19866
+ }
19867
+ if (error.message === "path not found") {
19868
+ throw new HTTPException(404, {
19869
+ message: error.message
19870
+ });
19871
+ }
19872
+ if (error.message === "path escapes project root") {
19873
+ throw new HTTPException(400, {
19874
+ message: error.message
19875
+ });
19876
+ }
19877
+ }
19878
+ throw error;
19879
+ }
19880
+ });
19881
+
19475
19882
  // src/middleware/security-headers.ts
19476
19883
  var securityHeaders = /* @__PURE__ */ __name(() => {
19477
19884
  return async (c, next) => {
@@ -19636,6 +20043,8 @@ app.route("/", entityTypesRouter);
19636
20043
  app.route("/", globalEventsRouter);
19637
20044
  var jobsRouter = createJobsRouter(makeMeaning.jobQueue, authMiddleware);
19638
20045
  app.route("/", jobsRouter);
20046
+ app.route("/", participantsRouter);
20047
+ app.route("/", browseRouter);
19639
20048
  app.get("/api", (c) => {
19640
20049
  const acceptHeader = c.req.header("Accept") || "";
19641
20050
  const userAgent = c.req.header("User-Agent") || "";
@@ -19648,7 +20057,8 @@ app.get("/api", (c) => {
19648
20057
  return c.redirect(redirectUrl);
19649
20058
  });
19650
20059
  app.get("/api/openapi.json", (c) => {
19651
- const openApiPath = path.join(__dirname$1, "../../../specs/openapi.json");
20060
+ const distPath = path.join(__dirname$1, "openapi.json");
20061
+ const openApiPath = fs.existsSync(distPath) ? distPath : path.join(__dirname$1, "../../../specs/openapi.json");
19652
20062
  const openApiContent = fs.readFileSync(openApiPath, "utf-8");
19653
20063
  const openApiSpec = JSON.parse(openApiContent);
19654
20064
  const port2 = backendService.port || 4e3;
@@ -19715,7 +20125,7 @@ if (config.env?.NODE_ENV !== "test") {
19715
20125
  });
19716
20126
  }
19717
20127
  try {
19718
- const entityTypes = await makeMeaning.graphDb.getEntityTypes();
20128
+ const entityTypes = await makeMeaning.knowledgeSystem.kb.graph.getEntityTypes();
19719
20129
  logger.info("Loaded entity types from graph database", {
19720
20130
  count: entityTypes.length
19721
20131
  });