@semiont/make-meaning 0.4.12 → 0.4.13

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
@@ -7,11 +7,11 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __commonJS = (cb, mod) => function __require() {
8
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
9
  };
10
- var __copyProps = (to, from8, except, desc) => {
11
- if (from8 && typeof from8 === "object" || typeof from8 === "function") {
12
- for (let key of __getOwnPropNames(from8))
10
+ var __copyProps = (to, from9, except, desc) => {
11
+ if (from9 && typeof from9 === "object" || typeof from9 === "function") {
12
+ for (let key of __getOwnPropNames(from9))
13
13
  if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from8[key], enumerable: !(desc = __getOwnPropDesc(from8, key)) || desc.enumerable });
14
+ __defProp(to, key, { get: () => from9[key], enumerable: !(desc = __getOwnPropDesc(from9, key)) || desc.enumerable });
15
15
  }
16
16
  return to;
17
17
  };
@@ -125,9 +125,9 @@ var require_Subscription = __commonJS({
125
125
  }
126
126
  return ar;
127
127
  };
128
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
129
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
130
- to[j] = from8[i];
128
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
129
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
130
+ to[j] = from9[i];
131
131
  return to;
132
132
  };
133
133
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -135,14 +135,14 @@ var require_Subscription = __commonJS({
135
135
  var isFunction_1 = require_isFunction();
136
136
  var UnsubscriptionError_1 = require_UnsubscriptionError();
137
137
  var arrRemove_1 = require_arrRemove();
138
- var Subscription7 = (function() {
139
- function Subscription8(initialTeardown) {
138
+ var Subscription8 = (function() {
139
+ function Subscription9(initialTeardown) {
140
140
  this.initialTeardown = initialTeardown;
141
141
  this.closed = false;
142
142
  this._parentage = null;
143
143
  this._finalizers = null;
144
144
  }
145
- Subscription8.prototype.unsubscribe = function() {
145
+ Subscription9.prototype.unsubscribe = function() {
146
146
  var e_1, _a, e_2, _b;
147
147
  var errors;
148
148
  if (!this.closed) {
@@ -209,13 +209,13 @@ var require_Subscription = __commonJS({
209
209
  }
210
210
  }
211
211
  };
212
- Subscription8.prototype.add = function(teardown) {
212
+ Subscription9.prototype.add = function(teardown) {
213
213
  var _a;
214
214
  if (teardown && teardown !== this) {
215
215
  if (this.closed) {
216
216
  execFinalizer(teardown);
217
217
  } else {
218
- if (teardown instanceof Subscription8) {
218
+ if (teardown instanceof Subscription9) {
219
219
  if (teardown.closed || teardown._hasParent(this)) {
220
220
  return;
221
221
  }
@@ -225,15 +225,15 @@ var require_Subscription = __commonJS({
225
225
  }
226
226
  }
227
227
  };
228
- Subscription8.prototype._hasParent = function(parent) {
228
+ Subscription9.prototype._hasParent = function(parent) {
229
229
  var _parentage = this._parentage;
230
230
  return _parentage === parent || Array.isArray(_parentage) && _parentage.includes(parent);
231
231
  };
232
- Subscription8.prototype._addParent = function(parent) {
232
+ Subscription9.prototype._addParent = function(parent) {
233
233
  var _parentage = this._parentage;
234
234
  this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
235
235
  };
236
- Subscription8.prototype._removeParent = function(parent) {
236
+ Subscription9.prototype._removeParent = function(parent) {
237
237
  var _parentage = this._parentage;
238
238
  if (_parentage === parent) {
239
239
  this._parentage = null;
@@ -241,24 +241,24 @@ var require_Subscription = __commonJS({
241
241
  arrRemove_1.arrRemove(_parentage, parent);
242
242
  }
243
243
  };
244
- Subscription8.prototype.remove = function(teardown) {
244
+ Subscription9.prototype.remove = function(teardown) {
245
245
  var _finalizers = this._finalizers;
246
246
  _finalizers && arrRemove_1.arrRemove(_finalizers, teardown);
247
- if (teardown instanceof Subscription8) {
247
+ if (teardown instanceof Subscription9) {
248
248
  teardown._removeParent(this);
249
249
  }
250
250
  };
251
- Subscription8.EMPTY = (function() {
252
- var empty = new Subscription8();
251
+ Subscription9.EMPTY = (function() {
252
+ var empty = new Subscription9();
253
253
  empty.closed = true;
254
254
  return empty;
255
255
  })();
256
- return Subscription8;
256
+ return Subscription9;
257
257
  })();
258
- exports.Subscription = Subscription7;
259
- exports.EMPTY_SUBSCRIPTION = Subscription7.EMPTY;
258
+ exports.Subscription = Subscription8;
259
+ exports.EMPTY_SUBSCRIPTION = Subscription8.EMPTY;
260
260
  function isSubscription(value) {
261
- return value instanceof Subscription7 || value && "closed" in value && isFunction_1.isFunction(value.remove) && isFunction_1.isFunction(value.add) && isFunction_1.isFunction(value.unsubscribe);
261
+ return value instanceof Subscription8 || value && "closed" in value && isFunction_1.isFunction(value.remove) && isFunction_1.isFunction(value.add) && isFunction_1.isFunction(value.unsubscribe);
262
262
  }
263
263
  exports.isSubscription = isSubscription;
264
264
  function execFinalizer(finalizer) {
@@ -308,9 +308,9 @@ var require_timeoutProvider = __commonJS({
308
308
  }
309
309
  return ar;
310
310
  };
311
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
312
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
313
- to[j] = from8[i];
311
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
312
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
313
+ to[j] = from9[i];
314
314
  return to;
315
315
  };
316
316
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1068,9 +1068,9 @@ var require_animationFrameProvider = __commonJS({
1068
1068
  }
1069
1069
  return ar;
1070
1070
  };
1071
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
1072
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
1073
- to[j] = from8[i];
1071
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
1072
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
1073
+ to[j] = from9[i];
1074
1074
  return to;
1075
1075
  };
1076
1076
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1215,9 +1215,9 @@ var require_Subject = __commonJS({
1215
1215
  var ObjectUnsubscribedError_1 = require_ObjectUnsubscribedError();
1216
1216
  var arrRemove_1 = require_arrRemove();
1217
1217
  var errorContext_1 = require_errorContext();
1218
- var Subject2 = (function(_super) {
1219
- __extends(Subject3, _super);
1220
- function Subject3() {
1218
+ var Subject3 = (function(_super) {
1219
+ __extends(Subject4, _super);
1220
+ function Subject4() {
1221
1221
  var _this = _super.call(this) || this;
1222
1222
  _this.closed = false;
1223
1223
  _this.currentObservers = null;
@@ -1227,17 +1227,17 @@ var require_Subject = __commonJS({
1227
1227
  _this.thrownError = null;
1228
1228
  return _this;
1229
1229
  }
1230
- Subject3.prototype.lift = function(operator) {
1230
+ Subject4.prototype.lift = function(operator) {
1231
1231
  var subject = new AnonymousSubject(this, this);
1232
1232
  subject.operator = operator;
1233
1233
  return subject;
1234
1234
  };
1235
- Subject3.prototype._throwIfClosed = function() {
1235
+ Subject4.prototype._throwIfClosed = function() {
1236
1236
  if (this.closed) {
1237
1237
  throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
1238
1238
  }
1239
1239
  };
1240
- Subject3.prototype.next = function(value) {
1240
+ Subject4.prototype.next = function(value) {
1241
1241
  var _this = this;
1242
1242
  errorContext_1.errorContext(function() {
1243
1243
  var e_1, _a;
@@ -1263,7 +1263,7 @@ var require_Subject = __commonJS({
1263
1263
  }
1264
1264
  });
1265
1265
  };
1266
- Subject3.prototype.error = function(err) {
1266
+ Subject4.prototype.error = function(err) {
1267
1267
  var _this = this;
1268
1268
  errorContext_1.errorContext(function() {
1269
1269
  _this._throwIfClosed();
@@ -1277,7 +1277,7 @@ var require_Subject = __commonJS({
1277
1277
  }
1278
1278
  });
1279
1279
  };
1280
- Subject3.prototype.complete = function() {
1280
+ Subject4.prototype.complete = function() {
1281
1281
  var _this = this;
1282
1282
  errorContext_1.errorContext(function() {
1283
1283
  _this._throwIfClosed();
@@ -1290,11 +1290,11 @@ var require_Subject = __commonJS({
1290
1290
  }
1291
1291
  });
1292
1292
  };
1293
- Subject3.prototype.unsubscribe = function() {
1293
+ Subject4.prototype.unsubscribe = function() {
1294
1294
  this.isStopped = this.closed = true;
1295
1295
  this.observers = this.currentObservers = null;
1296
1296
  };
1297
- Object.defineProperty(Subject3.prototype, "observed", {
1297
+ Object.defineProperty(Subject4.prototype, "observed", {
1298
1298
  get: function() {
1299
1299
  var _a;
1300
1300
  return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
@@ -1302,16 +1302,16 @@ var require_Subject = __commonJS({
1302
1302
  enumerable: false,
1303
1303
  configurable: true
1304
1304
  });
1305
- Subject3.prototype._trySubscribe = function(subscriber) {
1305
+ Subject4.prototype._trySubscribe = function(subscriber) {
1306
1306
  this._throwIfClosed();
1307
1307
  return _super.prototype._trySubscribe.call(this, subscriber);
1308
1308
  };
1309
- Subject3.prototype._subscribe = function(subscriber) {
1309
+ Subject4.prototype._subscribe = function(subscriber) {
1310
1310
  this._throwIfClosed();
1311
1311
  this._checkFinalizedStatuses(subscriber);
1312
1312
  return this._innerSubscribe(subscriber);
1313
1313
  };
1314
- Subject3.prototype._innerSubscribe = function(subscriber) {
1314
+ Subject4.prototype._innerSubscribe = function(subscriber) {
1315
1315
  var _this = this;
1316
1316
  var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
1317
1317
  if (hasError || isStopped) {
@@ -1324,7 +1324,7 @@ var require_Subject = __commonJS({
1324
1324
  arrRemove_1.arrRemove(observers, subscriber);
1325
1325
  });
1326
1326
  };
1327
- Subject3.prototype._checkFinalizedStatuses = function(subscriber) {
1327
+ Subject4.prototype._checkFinalizedStatuses = function(subscriber) {
1328
1328
  var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
1329
1329
  if (hasError) {
1330
1330
  subscriber.error(thrownError);
@@ -1332,17 +1332,17 @@ var require_Subject = __commonJS({
1332
1332
  subscriber.complete();
1333
1333
  }
1334
1334
  };
1335
- Subject3.prototype.asObservable = function() {
1335
+ Subject4.prototype.asObservable = function() {
1336
1336
  var observable = new Observable_1.Observable();
1337
1337
  observable.source = this;
1338
1338
  return observable;
1339
1339
  };
1340
- Subject3.create = function(destination, source) {
1340
+ Subject4.create = function(destination, source) {
1341
1341
  return new AnonymousSubject(destination, source);
1342
1342
  };
1343
- return Subject3;
1343
+ return Subject4;
1344
1344
  })(Observable_1.Observable);
1345
- exports.Subject = Subject2;
1345
+ exports.Subject = Subject3;
1346
1346
  var AnonymousSubject = (function(_super) {
1347
1347
  __extends(AnonymousSubject2, _super);
1348
1348
  function AnonymousSubject2(destination, source) {
@@ -1368,7 +1368,7 @@ var require_Subject = __commonJS({
1368
1368
  return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : Subscription_1.EMPTY_SUBSCRIPTION;
1369
1369
  };
1370
1370
  return AnonymousSubject2;
1371
- })(Subject2);
1371
+ })(Subject3);
1372
1372
  exports.AnonymousSubject = AnonymousSubject;
1373
1373
  }
1374
1374
  });
@@ -1668,9 +1668,9 @@ var require_intervalProvider = __commonJS({
1668
1668
  }
1669
1669
  return ar;
1670
1670
  };
1671
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
1672
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
1673
- to[j] = from8[i];
1671
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
1672
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
1673
+ to[j] = from9[i];
1674
1674
  return to;
1675
1675
  };
1676
1676
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1877,9 +1877,9 @@ var require_immediateProvider = __commonJS({
1877
1877
  }
1878
1878
  return ar;
1879
1879
  };
1880
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
1881
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
1882
- to[j] = from8[i];
1880
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
1881
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
1882
+ to[j] = from9[i];
1883
1883
  return to;
1884
1884
  };
1885
1885
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -3095,7 +3095,7 @@ var require_innerFrom = __commonJS({
3095
3095
  exports.fromIterable = fromIterable;
3096
3096
  function fromAsyncIterable(asyncIterable) {
3097
3097
  return new Observable_1.Observable(function(subscriber) {
3098
- process(asyncIterable, subscriber).catch(function(err) {
3098
+ process2(asyncIterable, subscriber).catch(function(err) {
3099
3099
  return subscriber.error(err);
3100
3100
  });
3101
3101
  });
@@ -3105,7 +3105,7 @@ var require_innerFrom = __commonJS({
3105
3105
  return fromAsyncIterable(isReadableStreamLike_1.readableStreamLikeToAsyncGenerator(readableStream));
3106
3106
  }
3107
3107
  exports.fromReadableStreamLike = fromReadableStreamLike;
3108
- function process(asyncIterable, subscriber) {
3108
+ function process2(asyncIterable, subscriber) {
3109
3109
  var asyncIterable_1, asyncIterable_1_1;
3110
3110
  var e_2, _a;
3111
3111
  return __awaiter(this, void 0, void 0, function() {
@@ -3441,10 +3441,10 @@ var require_from = __commonJS({
3441
3441
  exports.from = void 0;
3442
3442
  var scheduled_1 = require_scheduled();
3443
3443
  var innerFrom_1 = require_innerFrom();
3444
- function from8(input, scheduler) {
3444
+ function from9(input, scheduler) {
3445
3445
  return scheduler ? scheduled_1.scheduled(input, scheduler) : innerFrom_1.innerFrom(input);
3446
3446
  }
3447
- exports.from = from8;
3447
+ exports.from = from9;
3448
3448
  }
3449
3449
  });
3450
3450
 
@@ -3832,9 +3832,9 @@ var require_mapOneOrManyArgs = __commonJS({
3832
3832
  }
3833
3833
  return ar;
3834
3834
  };
3835
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
3836
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
3837
- to[j] = from8[i];
3835
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
3836
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
3837
+ to[j] = from9[i];
3838
3838
  return to;
3839
3839
  };
3840
3840
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -3874,9 +3874,9 @@ var require_bindCallbackInternals = __commonJS({
3874
3874
  }
3875
3875
  return ar;
3876
3876
  };
3877
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
3878
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
3879
- to[j] = from8[i];
3877
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
3878
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
3879
+ to[j] = from9[i];
3880
3880
  return to;
3881
3881
  };
3882
3882
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -4196,12 +4196,12 @@ var require_mergeMap = __commonJS({
4196
4196
  var lift_1 = require_lift();
4197
4197
  var mergeInternals_1 = require_mergeInternals();
4198
4198
  var isFunction_1 = require_isFunction();
4199
- function mergeMap6(project, resultSelector, concurrent) {
4199
+ function mergeMap7(project, resultSelector, concurrent) {
4200
4200
  if (concurrent === void 0) {
4201
4201
  concurrent = Infinity;
4202
4202
  }
4203
4203
  if (isFunction_1.isFunction(resultSelector)) {
4204
- return mergeMap6(function(a, i) {
4204
+ return mergeMap7(function(a, i) {
4205
4205
  return map_1.map(function(b, ii) {
4206
4206
  return resultSelector(a, b, i, ii);
4207
4207
  })(innerFrom_1.innerFrom(project(a, i)));
@@ -4213,7 +4213,7 @@ var require_mergeMap = __commonJS({
4213
4213
  return mergeInternals_1.mergeInternals(source, subscriber, project, concurrent);
4214
4214
  });
4215
4215
  }
4216
- exports.mergeMap = mergeMap6;
4216
+ exports.mergeMap = mergeMap7;
4217
4217
  }
4218
4218
  });
4219
4219
 
@@ -5008,9 +5008,9 @@ var require_zip = __commonJS({
5008
5008
  }
5009
5009
  return ar;
5010
5010
  };
5011
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
5012
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
5013
- to[j] = from8[i];
5011
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
5012
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
5013
+ to[j] = from9[i];
5014
5014
  return to;
5015
5015
  };
5016
5016
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -5638,9 +5638,9 @@ var require_combineLatest2 = __commonJS({
5638
5638
  }
5639
5639
  return ar;
5640
5640
  };
5641
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
5642
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
5643
- to[j] = from8[i];
5641
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
5642
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
5643
+ to[j] = from9[i];
5644
5644
  return to;
5645
5645
  };
5646
5646
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -5686,9 +5686,9 @@ var require_combineLatestWith = __commonJS({
5686
5686
  }
5687
5687
  return ar;
5688
5688
  };
5689
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
5690
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
5691
- to[j] = from8[i];
5689
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
5690
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
5691
+ to[j] = from9[i];
5692
5692
  return to;
5693
5693
  };
5694
5694
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -5713,10 +5713,10 @@ var require_concatMap = __commonJS({
5713
5713
  exports.concatMap = void 0;
5714
5714
  var mergeMap_1 = require_mergeMap();
5715
5715
  var isFunction_1 = require_isFunction();
5716
- function concatMap5(project, resultSelector) {
5716
+ function concatMap6(project, resultSelector) {
5717
5717
  return isFunction_1.isFunction(resultSelector) ? mergeMap_1.mergeMap(project, resultSelector, 1) : mergeMap_1.mergeMap(project, 1);
5718
5718
  }
5719
- exports.concatMap = concatMap5;
5719
+ exports.concatMap = concatMap6;
5720
5720
  }
5721
5721
  });
5722
5722
 
@@ -5760,9 +5760,9 @@ var require_concat2 = __commonJS({
5760
5760
  }
5761
5761
  return ar;
5762
5762
  };
5763
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
5764
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
5765
- to[j] = from8[i];
5763
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
5764
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
5765
+ to[j] = from9[i];
5766
5766
  return to;
5767
5767
  };
5768
5768
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -5806,9 +5806,9 @@ var require_concatWith = __commonJS({
5806
5806
  }
5807
5807
  return ar;
5808
5808
  };
5809
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
5810
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
5811
- to[j] = from8[i];
5809
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
5810
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
5811
+ to[j] = from9[i];
5812
5812
  return to;
5813
5813
  };
5814
5814
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -6299,9 +6299,9 @@ var require_endWith = __commonJS({
6299
6299
  }
6300
6300
  return ar;
6301
6301
  };
6302
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
6303
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
6304
- to[j] = from8[i];
6302
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
6303
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
6304
+ to[j] = from9[i];
6305
6305
  return to;
6306
6306
  };
6307
6307
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -6540,7 +6540,7 @@ var require_groupBy = __commonJS({
6540
6540
  var Subject_1 = require_Subject();
6541
6541
  var lift_1 = require_lift();
6542
6542
  var OperatorSubscriber_1 = require_OperatorSubscriber();
6543
- function groupBy3(keySelector, elementOrOptions, duration, connector) {
6543
+ function groupBy4(keySelector, elementOrOptions, duration, connector) {
6544
6544
  return lift_1.operate(function(source, subscriber) {
6545
6545
  var element;
6546
6546
  if (!elementOrOptions || typeof elementOrOptions === "function") {
@@ -6607,7 +6607,7 @@ var require_groupBy = __commonJS({
6607
6607
  }
6608
6608
  });
6609
6609
  }
6610
- exports.groupBy = groupBy3;
6610
+ exports.groupBy = groupBy4;
6611
6611
  }
6612
6612
  });
6613
6613
 
@@ -6846,9 +6846,9 @@ var require_merge2 = __commonJS({
6846
6846
  }
6847
6847
  return ar;
6848
6848
  };
6849
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
6850
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
6851
- to[j] = from8[i];
6849
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
6850
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
6851
+ to[j] = from9[i];
6852
6852
  return to;
6853
6853
  };
6854
6854
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -6893,9 +6893,9 @@ var require_mergeWith = __commonJS({
6893
6893
  }
6894
6894
  return ar;
6895
6895
  };
6896
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
6897
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
6898
- to[j] = from8[i];
6896
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
6897
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
6898
+ to[j] = from9[i];
6899
6899
  return to;
6900
6900
  };
6901
6901
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -6978,9 +6978,9 @@ var require_onErrorResumeNextWith = __commonJS({
6978
6978
  }
6979
6979
  return ar;
6980
6980
  };
6981
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
6982
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
6983
- to[j] = from8[i];
6981
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
6982
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
6983
+ to[j] = from9[i];
6984
6984
  return to;
6985
6985
  };
6986
6986
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -7162,9 +7162,9 @@ var require_raceWith = __commonJS({
7162
7162
  }
7163
7163
  return ar;
7164
7164
  };
7165
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
7166
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
7167
- to[j] = from8[i];
7165
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
7166
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
7167
+ to[j] = from9[i];
7168
7168
  return to;
7169
7169
  };
7170
7170
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -7560,9 +7560,9 @@ var require_share = __commonJS({
7560
7560
  }
7561
7561
  return ar;
7562
7562
  };
7563
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
7564
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
7565
- to[j] = from8[i];
7563
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
7564
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
7565
+ to[j] = from9[i];
7566
7566
  return to;
7567
7567
  };
7568
7568
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -8562,9 +8562,9 @@ var require_withLatestFrom = __commonJS({
8562
8562
  }
8563
8563
  return ar;
8564
8564
  };
8565
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
8566
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
8567
- to[j] = from8[i];
8565
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
8566
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
8567
+ to[j] = from9[i];
8568
8568
  return to;
8569
8569
  };
8570
8570
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -8648,9 +8648,9 @@ var require_zip2 = __commonJS({
8648
8648
  }
8649
8649
  return ar;
8650
8650
  };
8651
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
8652
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
8653
- to[j] = from8[i];
8651
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
8652
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
8653
+ to[j] = from9[i];
8654
8654
  return to;
8655
8655
  };
8656
8656
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -8691,9 +8691,9 @@ var require_zipWith = __commonJS({
8691
8691
  }
8692
8692
  return ar;
8693
8693
  };
8694
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
8695
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
8696
- to[j] = from8[i];
8694
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
8695
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
8696
+ to[j] = from9[i];
8697
8697
  return to;
8698
8698
  };
8699
8699
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -9459,9 +9459,9 @@ var require_race2 = __commonJS({
9459
9459
  }
9460
9460
  return ar;
9461
9461
  };
9462
- var __spreadArray = exports && exports.__spreadArray || function(to, from8) {
9463
- for (var i = 0, il = from8.length, j = to.length; i < il; i++, j++)
9464
- to[j] = from8[i];
9462
+ var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
9463
+ for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
9464
+ to[j] = from9[i];
9465
9465
  return to;
9466
9466
  };
9467
9467
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -9977,8 +9977,8 @@ function inferenceConfigToGenerator(workerType, config) {
9977
9977
  }
9978
9978
 
9979
9979
  // src/service.ts
9980
- var import_rxjs9 = __toESM(require_cjs(), 1);
9981
- var import_operators9 = __toESM(require_operators(), 1);
9980
+ var import_rxjs10 = __toESM(require_cjs(), 1);
9981
+ var import_operators10 = __toESM(require_operators(), 1);
9982
9982
  import { Readable } from "stream";
9983
9983
  import { createInferenceClient } from "@semiont/inference";
9984
9984
  import { getGraphDatabase } from "@semiont/graph";
@@ -10001,6 +10001,23 @@ var import_operators = __toESM(require_operators(), 1);
10001
10001
  import { EventQuery } from "@semiont/event-sourcing";
10002
10002
  import { didToAgent, burstBuffer } from "@semiont/core";
10003
10003
  import { resourceId as makeResourceId, annotationId as makeAnnotationId, findBodyItem } from "@semiont/core";
10004
+
10005
+ // src/batch-utils.ts
10006
+ function partitionByType(events) {
10007
+ const runs = [];
10008
+ let currentRun = [];
10009
+ for (const event of events) {
10010
+ if (currentRun.length > 0 && currentRun[0].event.type !== event.event.type) {
10011
+ runs.push(currentRun);
10012
+ currentRun = [];
10013
+ }
10014
+ currentRun.push(event);
10015
+ }
10016
+ if (currentRun.length > 0) runs.push(currentRun);
10017
+ return runs;
10018
+ }
10019
+
10020
+ // src/graph/consumer.ts
10004
10021
  var GraphDBConsumer = class _GraphDBConsumer {
10005
10022
  constructor(eventStore, graphDb, logger) {
10006
10023
  this.eventStore = eventStore;
@@ -10117,16 +10134,7 @@ var GraphDBConsumer = class _GraphDBConsumer {
10117
10134
  * Partitions into consecutive same-type runs for batch optimization.
10118
10135
  */
10119
10136
  async processBatch(events) {
10120
- const runs = [];
10121
- let currentRun = [];
10122
- for (const event of events) {
10123
- if (currentRun.length > 0 && currentRun[0].event.type !== event.event.type) {
10124
- runs.push(currentRun);
10125
- currentRun = [];
10126
- }
10127
- currentRun.push(event);
10128
- }
10129
- if (currentRun.length > 0) runs.push(currentRun);
10137
+ const runs = partitionByType(events);
10130
10138
  for (const run of runs) {
10131
10139
  try {
10132
10140
  if (run.length === 1) {
@@ -10404,8 +10412,423 @@ var GraphDBConsumer = class _GraphDBConsumer {
10404
10412
  }
10405
10413
  };
10406
10414
 
10415
+ // src/smelter.ts
10416
+ var import_rxjs2 = __toESM(require_cjs(), 1);
10417
+ var import_operators2 = __toESM(require_operators(), 1);
10418
+ import { EventQuery as EventQuery2 } from "@semiont/event-sourcing";
10419
+ import { burstBuffer as burstBuffer2 } from "@semiont/core";
10420
+ import { resourceId as makeResourceId2, annotationId as makeAnnotationId2 } from "@semiont/core";
10421
+ import { chunkText, DEFAULT_CHUNKING_CONFIG } from "@semiont/vectors";
10422
+ import { getExactText, getTargetSelector } from "@semiont/api-client";
10423
+ var Smelter = class _Smelter {
10424
+ constructor(eventStore, eventBus, vectorStore, embeddingProvider, contentStore, logger, chunkingConfig) {
10425
+ this.eventStore = eventStore;
10426
+ this.eventBus = eventBus;
10427
+ this.vectorStore = vectorStore;
10428
+ this.embeddingProvider = embeddingProvider;
10429
+ this.contentStore = contentStore;
10430
+ this.logger = logger;
10431
+ this.chunkingConfig = chunkingConfig ?? DEFAULT_CHUNKING_CONFIG;
10432
+ }
10433
+ static SMELTER_RELEVANT_EVENTS = /* @__PURE__ */ new Set([
10434
+ "resource.created",
10435
+ "resource.archived",
10436
+ "annotation.added",
10437
+ "annotation.removed"
10438
+ ]);
10439
+ static BURST_WINDOW_MS = 50;
10440
+ static MAX_BATCH_SIZE = 100;
10441
+ static IDLE_TIMEOUT_MS = 200;
10442
+ _globalSubscription = null;
10443
+ eventSubject = new import_rxjs2.Subject();
10444
+ pipelineSubscription = null;
10445
+ logger;
10446
+ chunkingConfig;
10447
+ async initialize() {
10448
+ this.logger.info("Smelter actor initializing");
10449
+ this._globalSubscription = this.eventStore.bus.subscriptions.subscribeGlobal(
10450
+ (storedEvent) => {
10451
+ if (!_Smelter.SMELTER_RELEVANT_EVENTS.has(storedEvent.event.type)) return;
10452
+ this.eventSubject.next(storedEvent);
10453
+ }
10454
+ );
10455
+ this.pipelineSubscription = this.eventSubject.pipe(
10456
+ (0, import_operators2.groupBy)((se) => se.event.resourceId ?? "__unknown__"),
10457
+ (0, import_operators2.mergeMap)(
10458
+ (group) => group.pipe(
10459
+ burstBuffer2({
10460
+ burstWindowMs: _Smelter.BURST_WINDOW_MS,
10461
+ maxBatchSize: _Smelter.MAX_BATCH_SIZE,
10462
+ idleTimeoutMs: _Smelter.IDLE_TIMEOUT_MS
10463
+ }),
10464
+ (0, import_operators2.concatMap)((eventOrBatch) => {
10465
+ if (Array.isArray(eventOrBatch)) {
10466
+ return (0, import_rxjs2.from)(this.processBatch(eventOrBatch));
10467
+ }
10468
+ return (0, import_rxjs2.from)(this.safeProcessEvent(eventOrBatch));
10469
+ })
10470
+ )
10471
+ )
10472
+ ).subscribe({
10473
+ error: (err) => this.logger.error("Smelter pipeline error", { error: err })
10474
+ });
10475
+ this.logger.info("Smelter actor initialized");
10476
+ }
10477
+ async stop() {
10478
+ if (this._globalSubscription && typeof this._globalSubscription.unsubscribe === "function") {
10479
+ this._globalSubscription.unsubscribe();
10480
+ }
10481
+ this._globalSubscription = null;
10482
+ this.pipelineSubscription?.unsubscribe();
10483
+ this.eventSubject.complete();
10484
+ this.logger.info("Smelter actor stopped");
10485
+ }
10486
+ /**
10487
+ * Rebuild the vector store from persisted embedding events in the event log.
10488
+ * Reads all embedding.computed / embedding.deleted events and replays them.
10489
+ * Bypasses the live pipeline — reads directly from the event store.
10490
+ */
10491
+ async rebuildAll() {
10492
+ this.logger.info("Rebuilding vector store from events");
10493
+ await this.vectorStore.clearAll();
10494
+ const allResourceIds = await this.eventStore.log.getAllResourceIds();
10495
+ this.logger.info("Found resources to scan", { count: allResourceIds.length });
10496
+ const query = new EventQuery2(this.eventStore.log.storage);
10497
+ let indexed = 0;
10498
+ for (const rid of allResourceIds) {
10499
+ const events = await query.getResourceEvents(makeResourceId2(rid));
10500
+ const embeddingEvents = events.filter(
10501
+ (e) => e.event.type === "embedding.computed" || e.event.type === "embedding.deleted"
10502
+ );
10503
+ if (embeddingEvents.length === 0) continue;
10504
+ const lastEvent = embeddingEvents[embeddingEvents.length - 1];
10505
+ if (lastEvent.event.type === "embedding.deleted" && !lastEvent.event.payload.annotationId) {
10506
+ continue;
10507
+ }
10508
+ const deletedAnnotations = /* @__PURE__ */ new Set();
10509
+ for (const e of embeddingEvents) {
10510
+ if (e.event.type === "embedding.deleted") {
10511
+ const payload = e.event.payload;
10512
+ if (payload.annotationId) deletedAnnotations.add(String(payload.annotationId));
10513
+ }
10514
+ }
10515
+ const resourceChunks = [];
10516
+ for (const e of embeddingEvents) {
10517
+ if (e.event.type !== "embedding.computed") continue;
10518
+ const payload = e.event.payload;
10519
+ if (payload.annotationId) {
10520
+ if (deletedAnnotations.has(String(payload.annotationId))) continue;
10521
+ await this.vectorStore.upsertAnnotationVector(
10522
+ makeAnnotationId2(String(payload.annotationId)),
10523
+ payload.embedding,
10524
+ {
10525
+ annotationId: makeAnnotationId2(String(payload.annotationId)),
10526
+ resourceId: makeResourceId2(e.event.resourceId),
10527
+ motivation: "",
10528
+ entityTypes: [],
10529
+ exactText: payload.chunkText
10530
+ }
10531
+ );
10532
+ } else {
10533
+ resourceChunks.push({
10534
+ chunkIndex: payload.chunkIndex,
10535
+ text: payload.chunkText,
10536
+ embedding: payload.embedding
10537
+ });
10538
+ }
10539
+ }
10540
+ if (resourceChunks.length > 0) {
10541
+ await this.vectorStore.upsertResourceVectors(
10542
+ makeResourceId2(rid),
10543
+ resourceChunks
10544
+ );
10545
+ }
10546
+ indexed++;
10547
+ }
10548
+ this.logger.info("Vector store rebuild complete", { resourcesIndexed: indexed });
10549
+ }
10550
+ async processBatch(events) {
10551
+ const runs = partitionByType(events);
10552
+ for (const run of runs) {
10553
+ try {
10554
+ if (run.length === 1) {
10555
+ await this.safeProcessEvent(run[0]);
10556
+ } else {
10557
+ await this.applyBatchByType(run);
10558
+ }
10559
+ } catch (error) {
10560
+ this.logger.error("Smelter failed to process batch run", {
10561
+ eventType: run[0].event.type,
10562
+ runSize: run.length,
10563
+ error
10564
+ });
10565
+ }
10566
+ }
10567
+ }
10568
+ /**
10569
+ * Batch-optimized processing for consecutive events of the same type.
10570
+ * Collects all texts across events, embeds in a single embedBatch() call,
10571
+ * then distributes results back to their respective resources/annotations.
10572
+ */
10573
+ async applyBatchByType(events) {
10574
+ const type = events[0].event.type;
10575
+ switch (type) {
10576
+ case "resource.created":
10577
+ await this.batchResourceCreated(events);
10578
+ break;
10579
+ case "annotation.added":
10580
+ await this.batchAnnotationAdded(events);
10581
+ break;
10582
+ default:
10583
+ for (const event of events) {
10584
+ await this.safeProcessEvent(event);
10585
+ }
10586
+ }
10587
+ }
10588
+ /**
10589
+ * Batch-embed chunks from multiple resource.created events in a single
10590
+ * embedBatch() call, then emit events and index per resource.
10591
+ */
10592
+ async batchResourceCreated(events) {
10593
+ const resourceData = [];
10594
+ const allChunks = [];
10595
+ for (const storedEvent of events) {
10596
+ const event = storedEvent.event;
10597
+ const rid = makeResourceId2(event.resourceId);
10598
+ const storageUri = event.payload.storageUri;
10599
+ if (!storageUri) continue;
10600
+ const content = await this.contentStore.retrieve(storageUri);
10601
+ if (!content) continue;
10602
+ const text = new TextDecoder().decode(content);
10603
+ if (!text.trim()) continue;
10604
+ const chunks = chunkText(text, this.chunkingConfig);
10605
+ if (chunks.length === 0) continue;
10606
+ resourceData.push({ rid, chunks });
10607
+ allChunks.push(...chunks);
10608
+ }
10609
+ if (allChunks.length === 0) return;
10610
+ const allEmbeddings = await this.embeddingProvider.embedBatch(allChunks);
10611
+ const model = this.embeddingProvider.model();
10612
+ const dimensions = this.embeddingProvider.dimensions();
10613
+ let offset = 0;
10614
+ for (const { rid, chunks } of resourceData) {
10615
+ const embeddingChunks = chunks.map((text, i) => {
10616
+ const embedding = allEmbeddings[offset + i];
10617
+ this.eventBus.get("embedding:computed").next({
10618
+ resourceId: rid,
10619
+ chunkIndex: i,
10620
+ chunkText: text,
10621
+ embedding,
10622
+ model,
10623
+ dimensions
10624
+ });
10625
+ return { chunkIndex: i, text, embedding };
10626
+ });
10627
+ await this.vectorStore.upsertResourceVectors(rid, embeddingChunks);
10628
+ this.logger.debug("Smelter batch-indexed resource", {
10629
+ resourceId: String(rid),
10630
+ chunks: embeddingChunks.length
10631
+ });
10632
+ offset += chunks.length;
10633
+ }
10634
+ }
10635
+ /**
10636
+ * Batch-embed exact texts from multiple annotation.added events in a
10637
+ * single embedBatch() call, then emit events and index per annotation.
10638
+ */
10639
+ async batchAnnotationAdded(events) {
10640
+ const annotationData = [];
10641
+ for (const storedEvent of events) {
10642
+ const event = storedEvent.event;
10643
+ const annotation = event.payload.annotation;
10644
+ if (!annotation?.id) continue;
10645
+ const selector = getTargetSelector(annotation.target);
10646
+ const exactText = getExactText(selector);
10647
+ if (!exactText?.trim()) continue;
10648
+ annotationData.push({
10649
+ rid: makeResourceId2(event.resourceId),
10650
+ aid: makeAnnotationId2(annotation.id),
10651
+ exactText,
10652
+ annotation
10653
+ });
10654
+ }
10655
+ if (annotationData.length === 0) return;
10656
+ const allEmbeddings = await this.embeddingProvider.embedBatch(
10657
+ annotationData.map((a) => a.exactText)
10658
+ );
10659
+ for (let i = 0; i < annotationData.length; i++) {
10660
+ const { rid, aid, exactText, annotation } = annotationData[i];
10661
+ const embedding = allEmbeddings[i];
10662
+ this.eventBus.get("embedding:computed").next({
10663
+ resourceId: rid,
10664
+ annotationId: aid,
10665
+ chunkIndex: 0,
10666
+ chunkText: exactText,
10667
+ embedding,
10668
+ model: this.embeddingProvider.model(),
10669
+ dimensions: this.embeddingProvider.dimensions()
10670
+ });
10671
+ const payload = {
10672
+ annotationId: aid,
10673
+ resourceId: rid,
10674
+ motivation: annotation.motivation ?? "",
10675
+ entityTypes: annotation.entityTypes ?? [],
10676
+ exactText
10677
+ };
10678
+ await this.vectorStore.upsertAnnotationVector(aid, embedding, payload);
10679
+ this.logger.debug("Smelter batch-indexed annotation", {
10680
+ annotationId: String(aid),
10681
+ resourceId: String(rid)
10682
+ });
10683
+ }
10684
+ }
10685
+ async safeProcessEvent(storedEvent) {
10686
+ try {
10687
+ await this.processEvent(storedEvent);
10688
+ } catch (err) {
10689
+ this.logger.error("Smelter failed to process event", {
10690
+ type: storedEvent.event.type,
10691
+ resourceId: storedEvent.event.resourceId,
10692
+ error: err instanceof Error ? err.message : String(err),
10693
+ stack: err instanceof Error ? err.stack : void 0
10694
+ });
10695
+ }
10696
+ }
10697
+ async processEvent(storedEvent) {
10698
+ const event = storedEvent.event;
10699
+ switch (event.type) {
10700
+ case "resource.created":
10701
+ await this.handleResourceCreated(event);
10702
+ break;
10703
+ case "resource.archived":
10704
+ await this.handleResourceArchived(event);
10705
+ break;
10706
+ case "annotation.added":
10707
+ await this.handleAnnotationAdded(event);
10708
+ break;
10709
+ case "annotation.removed":
10710
+ await this.handleAnnotationRemoved(event);
10711
+ break;
10712
+ }
10713
+ }
10714
+ async handleResourceCreated(event) {
10715
+ await new Promise((resolve2) => setTimeout(resolve2, 0));
10716
+ const rid = makeResourceId2(event.resourceId);
10717
+ const storageUri = event.payload.storageUri;
10718
+ if (!storageUri) return;
10719
+ this.logger.info("Smelter handleResourceCreated start", {
10720
+ resourceId: String(rid),
10721
+ storageUri,
10722
+ heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
10723
+ });
10724
+ const content = await this.contentStore.retrieve(storageUri);
10725
+ if (!content) return;
10726
+ const text = new TextDecoder().decode(content);
10727
+ if (!text.trim()) return;
10728
+ const chunks = chunkText(text, this.chunkingConfig);
10729
+ if (chunks.length === 0) return;
10730
+ this.logger.info("Smelter chunked resource", {
10731
+ resourceId: String(rid),
10732
+ textBytes: text.length,
10733
+ chunkCount: chunks.length,
10734
+ heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
10735
+ });
10736
+ const embeddings = await this.embeddingProvider.embedBatch(chunks);
10737
+ const model = this.embeddingProvider.model();
10738
+ const dimensions = this.embeddingProvider.dimensions();
10739
+ this.logger.info("Smelter embedded resource", {
10740
+ resourceId: String(rid),
10741
+ chunkCount: chunks.length,
10742
+ dimensions,
10743
+ heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
10744
+ });
10745
+ const embeddingChunks = chunks.map((text2, i) => {
10746
+ this.eventBus.get("embedding:computed").next({
10747
+ resourceId: rid,
10748
+ chunkIndex: i,
10749
+ chunkText: text2,
10750
+ embedding: embeddings[i],
10751
+ model,
10752
+ dimensions
10753
+ });
10754
+ return { chunkIndex: i, text: text2, embedding: embeddings[i] };
10755
+ });
10756
+ this.logger.info("Smelter emitted events", {
10757
+ resourceId: String(rid),
10758
+ chunkCount: embeddingChunks.length,
10759
+ heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
10760
+ });
10761
+ await this.vectorStore.upsertResourceVectors(rid, embeddingChunks);
10762
+ this.logger.info("Smelter indexed resource", {
10763
+ resourceId: String(rid),
10764
+ chunks: embeddingChunks.length,
10765
+ heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
10766
+ });
10767
+ }
10768
+ async handleResourceArchived(event) {
10769
+ const rid = makeResourceId2(event.resourceId);
10770
+ await this.vectorStore.deleteResourceVectors(rid);
10771
+ this.eventBus.get("embedding:deleted").next({ resourceId: rid });
10772
+ this.logger.debug("Smelter deleted resource vectors", {
10773
+ resourceId: String(rid)
10774
+ });
10775
+ }
10776
+ async handleAnnotationAdded(event) {
10777
+ await new Promise((resolve2) => setTimeout(resolve2, 0));
10778
+ const annotation = event.payload.annotation;
10779
+ if (!annotation || !annotation.id) return;
10780
+ const rid = makeResourceId2(event.resourceId);
10781
+ const aid = makeAnnotationId2(annotation.id);
10782
+ const selector = getTargetSelector(annotation.target);
10783
+ const exactText = getExactText(selector);
10784
+ if (!exactText || !exactText.trim()) return;
10785
+ this.logger.info("Smelter handleAnnotationAdded start", {
10786
+ annotationId: String(aid),
10787
+ resourceId: String(rid),
10788
+ textLength: exactText.length,
10789
+ heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
10790
+ });
10791
+ const embedding = await this.embeddingProvider.embed(exactText);
10792
+ this.eventBus.get("embedding:computed").next({
10793
+ resourceId: rid,
10794
+ annotationId: aid,
10795
+ chunkIndex: 0,
10796
+ chunkText: exactText,
10797
+ embedding,
10798
+ model: this.embeddingProvider.model(),
10799
+ dimensions: this.embeddingProvider.dimensions()
10800
+ });
10801
+ const payload = {
10802
+ annotationId: aid,
10803
+ resourceId: rid,
10804
+ motivation: annotation.motivation ?? "",
10805
+ entityTypes: annotation.entityTypes ?? [],
10806
+ exactText
10807
+ };
10808
+ await this.vectorStore.upsertAnnotationVector(aid, embedding, payload);
10809
+ this.logger.info("Smelter indexed annotation", {
10810
+ annotationId: String(aid),
10811
+ resourceId: String(rid)
10812
+ });
10813
+ }
10814
+ async handleAnnotationRemoved(event) {
10815
+ const annotationId2 = String(event.payload.annotationId);
10816
+ if (!annotationId2) return;
10817
+ const rid = makeResourceId2(event.resourceId);
10818
+ const aid = makeAnnotationId2(annotationId2);
10819
+ await this.vectorStore.deleteAnnotationVector(aid);
10820
+ this.eventBus.get("embedding:deleted").next({
10821
+ resourceId: rid,
10822
+ annotationId: aid
10823
+ });
10824
+ this.logger.debug("Smelter deleted annotation vector", {
10825
+ annotationId: String(aid)
10826
+ });
10827
+ }
10828
+ };
10829
+
10407
10830
  // src/knowledge-base.ts
10408
- async function createKnowledgeBase(eventStore, project, graphDb, logger) {
10831
+ async function createKnowledgeBase(eventStore, project, graphDb, logger, options) {
10409
10832
  const views = new FilesystemViewStorage(project);
10410
10833
  const content = new WorkingTreeStore(
10411
10834
  project,
@@ -10417,13 +10840,40 @@ async function createKnowledgeBase(eventStore, project, graphDb, logger) {
10417
10840
  logger.child({ component: "graph-consumer" })
10418
10841
  );
10419
10842
  await graphConsumer.initialize();
10420
- return { eventStore, views, content, graph: graphDb, graphConsumer, projectionsDir: project.projectionsDir };
10843
+ if (!options?.skipRebuild) {
10844
+ await graphConsumer.rebuildAll();
10845
+ }
10846
+ const kb = {
10847
+ eventStore,
10848
+ views,
10849
+ content,
10850
+ graph: graphDb,
10851
+ graphConsumer,
10852
+ projectionsDir: project.projectionsDir
10853
+ };
10854
+ if (options?.vectorStore && options?.embeddingProvider && options?.eventBus) {
10855
+ kb.vectors = options.vectorStore;
10856
+ kb.smelter = new Smelter(
10857
+ eventStore,
10858
+ options.eventBus,
10859
+ options.vectorStore,
10860
+ options.embeddingProvider,
10861
+ content,
10862
+ logger.child({ component: "smelter" }),
10863
+ options.chunkingConfig
10864
+ );
10865
+ await kb.smelter.initialize();
10866
+ if (!options.skipRebuild) {
10867
+ await kb.smelter.rebuildAll();
10868
+ }
10869
+ }
10870
+ return kb;
10421
10871
  }
10422
10872
 
10423
10873
  // src/gatherer.ts
10424
- var import_rxjs2 = __toESM(require_cjs(), 1);
10425
- var import_operators2 = __toESM(require_operators(), 1);
10426
- import { annotationId as makeAnnotationId2 } from "@semiont/core";
10874
+ var import_rxjs3 = __toESM(require_cjs(), 1);
10875
+ var import_operators3 = __toESM(require_operators(), 1);
10876
+ import { annotationId as makeAnnotationId3 } from "@semiont/core";
10427
10877
 
10428
10878
  // src/generation/resource-generation.ts
10429
10879
  async function generateResourceSummary(resourceName, content, entityTypes, client) {
@@ -10453,7 +10903,7 @@ import {
10453
10903
  getBodySource,
10454
10904
  getResourceId,
10455
10905
  getTargetSource,
10456
- getTargetSelector,
10906
+ getTargetSelector as getTargetSelector2,
10457
10907
  getResourceEntityTypes,
10458
10908
  getTextPositionSelector,
10459
10909
  getPrimaryRepresentation as getPrimaryRepresentation2,
@@ -10549,7 +10999,7 @@ var AnnotationContext = class {
10549
10999
  * @returns Rich context for LLM processing
10550
11000
  * @throws Error if annotation or resource not found
10551
11001
  */
10552
- static async buildLLMContext(annotationId2, resourceId4, kb, options = {}, inferenceClient, logger) {
11002
+ static async buildLLMContext(annotationId2, resourceId4, kb, options = {}, inferenceClient, logger, embeddingProvider) {
10553
11003
  const {
10554
11004
  includeSourceContext = true,
10555
11005
  includeTargetContext = true,
@@ -10603,7 +11053,7 @@ var AnnotationContext = class {
10603
11053
  const primaryRep = getPrimaryRepresentation2(sourceDoc);
10604
11054
  const sourceContent = await kb.content.retrieve(sourceDoc.storageUri);
10605
11055
  const contentStr = decodeRepresentation2(sourceContent, primaryRep?.mediaType ?? "text/plain");
10606
- const targetSelectorRaw = getTargetSelector(annotation.target);
11056
+ const targetSelectorRaw = getTargetSelector2(annotation.target);
10607
11057
  const targetSelector = Array.isArray(targetSelectorRaw) ? targetSelectorRaw[0] : targetSelectorRaw;
10608
11058
  logger?.debug("Target selector", { type: targetSelector?.type });
10609
11059
  if (!targetSelector) {
@@ -10723,6 +11173,31 @@ Summary:`;
10723
11173
  citedByCount: citedByMap.size,
10724
11174
  siblingEntityTypes: siblingEntityTypes.size
10725
11175
  });
11176
+ let semanticContext;
11177
+ if (kb.vectors && embeddingProvider && sourceContext?.selected) {
11178
+ try {
11179
+ const focalEmbedding = await embeddingProvider.embed(sourceContext.selected);
11180
+ const results = await kb.vectors.searchAnnotations(focalEmbedding, {
11181
+ limit: 10,
11182
+ scoreThreshold: 0.5,
11183
+ filter: { excludeResourceId: resourceId4 }
11184
+ });
11185
+ if (results.length > 0) {
11186
+ semanticContext = {
11187
+ similar: results.map((r) => ({
11188
+ text: r.text,
11189
+ resourceId: r.resourceId,
11190
+ annotationId: r.annotationId,
11191
+ score: r.score,
11192
+ entityTypes: r.entityTypes
11193
+ }))
11194
+ };
11195
+ logger?.debug("Semantic context found", { matches: results.length });
11196
+ }
11197
+ } catch (error) {
11198
+ logger?.warn("Semantic context search failed", { error });
11199
+ }
11200
+ }
10726
11201
  const generationContext = {
10727
11202
  annotation,
10728
11203
  sourceResource: sourceDoc,
@@ -10731,7 +11206,8 @@ Summary:`;
10731
11206
  language: sourceDoc.language,
10732
11207
  entityTypes: annotationEntityTypes
10733
11208
  },
10734
- graphContext
11209
+ graphContext,
11210
+ ...semanticContext ? { semanticContext } : {}
10735
11211
  };
10736
11212
  if (sourceContext) {
10737
11213
  generationContext.sourceContext = {
@@ -10954,7 +11430,7 @@ Summary:`;
10954
11430
  * Extract annotation context from resource content
10955
11431
  */
10956
11432
  static extractAnnotationContext(annotation, contentStr, contextBefore, contextAfter) {
10957
- const targetSelector = getTargetSelector(annotation.target);
11433
+ const targetSelector = getTargetSelector2(annotation.target);
10958
11434
  const posSelector = targetSelector ? getTextPositionSelector(targetSelector) : null;
10959
11435
  if (!posSelector) {
10960
11436
  throw new Error("TextPositionSelector required for context");
@@ -11054,7 +11530,7 @@ var GraphContext = class {
11054
11530
 
11055
11531
  // src/llm-context.ts
11056
11532
  import { getResourceEntityTypes as getResourceEntityTypes3, getResourceId as getResourceId3 } from "@semiont/api-client";
11057
- import { resourceId as makeResourceId2 } from "@semiont/core";
11533
+ import { resourceId as makeResourceId3 } from "@semiont/core";
11058
11534
  var LLMContext = class {
11059
11535
  /**
11060
11536
  * Get comprehensive LLM context for a resource
@@ -11075,7 +11551,7 @@ var LLMContext = class {
11075
11551
  const resourceIdStr = resourceId4.toString();
11076
11552
  for (const node of graph.nodes) {
11077
11553
  if (node.id !== resourceIdStr) {
11078
- const relatedDoc = await ResourceContext.getResourceMetadata(makeResourceId2(node.id), kb);
11554
+ const relatedDoc = await ResourceContext.getResourceMetadata(makeResourceId3(node.id), kb);
11079
11555
  if (relatedDoc) {
11080
11556
  relatedDocs.push(relatedDoc);
11081
11557
  }
@@ -11117,10 +11593,11 @@ var LLMContext = class {
11117
11593
 
11118
11594
  // src/gatherer.ts
11119
11595
  var Gatherer = class {
11120
- constructor(kb, eventBus, inferenceClient, logger) {
11596
+ constructor(kb, eventBus, inferenceClient, logger, embeddingProvider) {
11121
11597
  this.kb = kb;
11122
11598
  this.eventBus = eventBus;
11123
11599
  this.inferenceClient = inferenceClient;
11600
+ this.embeddingProvider = embeddingProvider;
11124
11601
  this.logger = logger;
11125
11602
  }
11126
11603
  subscriptions = [];
@@ -11129,18 +11606,18 @@ var Gatherer = class {
11129
11606
  this.logger.info("Gatherer actor initialized");
11130
11607
  const errorHandler = (err) => this.logger.error("Gatherer pipeline error", { error: err });
11131
11608
  const annotationGather$ = this.eventBus.get("gather:requested").pipe(
11132
- (0, import_operators2.groupBy)((event) => event.resourceId),
11133
- (0, import_operators2.mergeMap)(
11609
+ (0, import_operators3.groupBy)((event) => event.resourceId),
11610
+ (0, import_operators3.mergeMap)(
11134
11611
  (group$) => group$.pipe(
11135
- (0, import_operators2.concatMap)((event) => (0, import_rxjs2.from)(this.handleAnnotationGather(event)))
11612
+ (0, import_operators3.concatMap)((event) => (0, import_rxjs3.from)(this.handleAnnotationGather(event)))
11136
11613
  )
11137
11614
  )
11138
11615
  );
11139
11616
  const resourceGather$ = this.eventBus.get("gather:resource-requested").pipe(
11140
- (0, import_operators2.groupBy)((event) => event.resourceId),
11141
- (0, import_operators2.mergeMap)(
11617
+ (0, import_operators3.groupBy)((event) => event.resourceId),
11618
+ (0, import_operators3.mergeMap)(
11142
11619
  (group$) => group$.pipe(
11143
- (0, import_operators2.concatMap)((event) => (0, import_rxjs2.from)(this.handleResourceGather(event)))
11620
+ (0, import_operators3.concatMap)((event) => (0, import_rxjs3.from)(this.handleResourceGather(event)))
11144
11621
  )
11145
11622
  )
11146
11623
  );
@@ -11159,12 +11636,13 @@ var Gatherer = class {
11159
11636
  resourceId: event.resourceId
11160
11637
  });
11161
11638
  const response = await AnnotationContext.buildLLMContext(
11162
- makeAnnotationId2(event.annotationId),
11639
+ makeAnnotationId3(event.annotationId),
11163
11640
  event.resourceId,
11164
11641
  this.kb,
11165
11642
  event.options ?? {},
11166
11643
  this.inferenceClient,
11167
- this.logger
11644
+ this.logger,
11645
+ this.embeddingProvider
11168
11646
  );
11169
11647
  this.eventBus.get("gather:complete").next({
11170
11648
  correlationId: event.correlationId,
@@ -11229,15 +11707,16 @@ var Gatherer = class {
11229
11707
  };
11230
11708
 
11231
11709
  // src/matcher.ts
11232
- var import_rxjs3 = __toESM(require_cjs(), 1);
11233
- var import_operators3 = __toESM(require_operators(), 1);
11710
+ var import_rxjs4 = __toESM(require_cjs(), 1);
11711
+ var import_operators4 = __toESM(require_operators(), 1);
11234
11712
  import { resourceId } from "@semiont/core";
11235
11713
  import { getResourceId as getResourceId4, getResourceEntityTypes as getResourceEntityTypes4 } from "@semiont/api-client";
11236
11714
  var Matcher = class {
11237
- constructor(kb, eventBus, logger, inferenceClient) {
11715
+ constructor(kb, eventBus, logger, inferenceClient, embeddingProvider) {
11238
11716
  this.kb = kb;
11239
11717
  this.eventBus = eventBus;
11240
11718
  this.inferenceClient = inferenceClient;
11719
+ this.embeddingProvider = embeddingProvider;
11241
11720
  this.logger = logger;
11242
11721
  }
11243
11722
  subscriptions = [];
@@ -11246,7 +11725,7 @@ var Matcher = class {
11246
11725
  this.logger.info("Matcher actor initialized");
11247
11726
  const errorHandler = (err) => this.logger.error("Matcher pipeline error", { error: err });
11248
11727
  const search$ = this.eventBus.get("match:search-requested").pipe(
11249
- (0, import_operators3.concatMap)((event) => (0, import_rxjs3.from)(this.handleSearch(event)))
11728
+ (0, import_operators4.concatMap)((event) => (0, import_rxjs4.from)(this.handleSearch(event)))
11250
11729
  );
11251
11730
  this.subscriptions.push(
11252
11731
  search$.subscribe({ error: errorHandler })
@@ -11305,9 +11784,11 @@ var Matcher = class {
11305
11784
  async contextDrivenSearch(searchTerm, context, useSemanticScoring) {
11306
11785
  const annotationEntityTypes = context.metadata?.entityTypes ?? [];
11307
11786
  const connections = context.graphContext?.connections ?? [];
11308
- const [nameMatches, entityTypeMatches] = await Promise.all([
11787
+ const [nameMatches, entityTypeMatches, semanticMatches] = await Promise.all([
11309
11788
  this.kb.graph.searchResources(searchTerm),
11310
- annotationEntityTypes.length > 0 ? this.kb.graph.listResources({ entityTypes: annotationEntityTypes, limit: 50 }).then((r) => r.resources) : Promise.resolve([])
11789
+ annotationEntityTypes.length > 0 ? this.kb.graph.listResources({ entityTypes: annotationEntityTypes, limit: 50 }).then((r) => r.resources) : Promise.resolve([]),
11790
+ // 4. Semantic match — vector similarity search (if vectors configured)
11791
+ this.searchVectors(searchTerm, annotationEntityTypes)
11311
11792
  ]);
11312
11793
  const neighborResources = await Promise.all(
11313
11794
  connections.map(
@@ -11330,10 +11811,17 @@ var Matcher = class {
11330
11811
  for (const r of neighborResources) {
11331
11812
  if (r) addCandidate(r, "neighborhood");
11332
11813
  }
11814
+ const semanticScores = /* @__PURE__ */ new Map();
11815
+ for (const sm of semanticMatches) {
11816
+ semanticScores.set(sm.resourceId, sm.score);
11817
+ const resource = await this.kb.graph.getResource(resourceId(sm.resourceId)).catch(() => null);
11818
+ if (resource) addCandidate(resource, "semantic");
11819
+ }
11333
11820
  this.logger.debug("Candidate retrieval", {
11334
11821
  nameMatches: nameMatches.length,
11335
11822
  entityTypeMatches: entityTypeMatches.length,
11336
11823
  neighborResources: neighborResources.filter(Boolean).length,
11824
+ semanticMatches: semanticMatches.length,
11337
11825
  totalCandidates: candidateMap.size
11338
11826
  });
11339
11827
  const connectionIds = new Set(connections.map((c) => c.resourceId));
@@ -11390,6 +11878,11 @@ var Matcher = class {
11390
11878
  const ageDays = ageMs / (1e3 * 60 * 60 * 24);
11391
11879
  score += Math.max(0, 5 * (1 - ageDays / 30));
11392
11880
  }
11881
+ const semanticScore = semanticScores.get(id);
11882
+ if (semanticScore !== void 0) {
11883
+ score += semanticScore * 25;
11884
+ reasons.push("semantic similarity");
11885
+ }
11393
11886
  if (sources.size > 1) {
11394
11887
  score += sources.size * 3;
11395
11888
  reasons.push(`${sources.size} retrieval sources`);
@@ -11501,6 +11994,28 @@ No explanations.`;
11501
11994
  });
11502
11995
  return scores;
11503
11996
  }
11997
+ /**
11998
+ * Search vectors for semantically similar resources.
11999
+ * Returns empty array if vectors or embedding provider are not configured.
12000
+ */
12001
+ async searchVectors(searchTerm, entityTypes) {
12002
+ if (!this.kb.vectors || !this.embeddingProvider || !searchTerm.trim()) return [];
12003
+ try {
12004
+ const embedding = await this.embeddingProvider.embed(searchTerm);
12005
+ const results = await this.kb.vectors.searchResources(embedding, {
12006
+ limit: 20,
12007
+ scoreThreshold: 0.4,
12008
+ filter: entityTypes.length > 0 ? { entityTypes } : void 0
12009
+ });
12010
+ return results.map((r) => ({
12011
+ resourceId: String(r.resourceId),
12012
+ score: r.score
12013
+ }));
12014
+ } catch (error) {
12015
+ this.logger.warn("Vector search failed, falling back to structural search", { error });
12016
+ return [];
12017
+ }
12018
+ }
11504
12019
  async stop() {
11505
12020
  for (const sub of this.subscriptions) {
11506
12021
  sub.unsubscribe();
@@ -11511,10 +12026,10 @@ No explanations.`;
11511
12026
  };
11512
12027
 
11513
12028
  // src/stower.ts
11514
- var import_rxjs4 = __toESM(require_cjs(), 1);
11515
- var import_operators4 = __toESM(require_operators(), 1);
12029
+ var import_rxjs5 = __toESM(require_cjs(), 1);
12030
+ var import_operators5 = __toESM(require_operators(), 1);
11516
12031
  import { promises as fs } from "fs";
11517
- import { resourceId as resourceId2, annotationId as makeAnnotationId3, CREATION_METHODS, generateUuid } from "@semiont/core";
12032
+ import { resourceId as resourceId2, userId as makeUserId, annotationId as makeAnnotationId4, CREATION_METHODS, generateUuid } from "@semiont/core";
11518
12033
  import { resolveStorageUri } from "@semiont/event-sourcing";
11519
12034
  import { getExtensionForMimeType } from "@semiont/content";
11520
12035
  var Stower = class {
@@ -11527,8 +12042,8 @@ var Stower = class {
11527
12042
  logger;
11528
12043
  async initialize() {
11529
12044
  this.logger.info("Stower actor initialized");
11530
- const pipe = (event, handler) => this.eventBus.get(event).pipe((0, import_operators4.concatMap)((e) => (0, import_rxjs4.from)(handler(e))));
11531
- this.subscription = (0, import_rxjs4.merge)(
12045
+ const pipe = (event, handler) => this.eventBus.get(event).pipe((0, import_operators5.concatMap)((e) => (0, import_rxjs5.from)(handler(e))));
12046
+ this.subscription = (0, import_rxjs5.merge)(
11532
12047
  pipe("yield:create", (e) => this.handleYieldCreate(e)),
11533
12048
  pipe("yield:update", (e) => this.handleYieldUpdate(e)),
11534
12049
  pipe("yield:mv", (e) => this.handleYieldMv(e)),
@@ -11542,7 +12057,9 @@ var Stower = class {
11542
12057
  pipe("job:start", (e) => this.handleJobStart(e)),
11543
12058
  pipe("job:report-progress", (e) => this.handleJobReportProgress(e)),
11544
12059
  pipe("job:complete", (e) => this.handleJobComplete(e)),
11545
- pipe("job:fail", (e) => this.handleJobFail(e))
12060
+ pipe("job:fail", (e) => this.handleJobFail(e)),
12061
+ pipe("embedding:computed", (e) => this.handleEmbeddingComputed(e)),
12062
+ pipe("embedding:deleted", (e) => this.handleEmbeddingDeleted(e))
11546
12063
  ).subscribe({
11547
12064
  error: (err) => this.logger.error("Stower pipeline error", { error: err })
11548
12065
  });
@@ -11691,7 +12208,7 @@ var Stower = class {
11691
12208
  version: 1,
11692
12209
  payload: { annotation: event.annotation }
11693
12210
  });
11694
- this.eventBus.get("mark:created").next({ annotationId: makeAnnotationId3(event.annotation.id) });
12211
+ this.eventBus.get("mark:created").next({ annotationId: makeAnnotationId4(event.annotation.id) });
11695
12212
  } catch (error) {
11696
12213
  this.logger.error("Failed to create annotation", { error });
11697
12214
  this.eventBus.get("mark:create-failed").next({
@@ -11859,6 +12376,33 @@ var Stower = class {
11859
12376
  }
11860
12377
  });
11861
12378
  }
12379
+ async handleEmbeddingComputed(event) {
12380
+ await this.kb.eventStore.appendEvent({
12381
+ type: "embedding.computed",
12382
+ resourceId: event.resourceId,
12383
+ userId: makeUserId("did:web:system:smelter"),
12384
+ version: 1,
12385
+ payload: {
12386
+ annotationId: event.annotationId,
12387
+ chunkIndex: event.chunkIndex,
12388
+ chunkText: event.chunkText,
12389
+ embedding: event.embedding,
12390
+ model: event.model,
12391
+ dimensions: event.dimensions
12392
+ }
12393
+ });
12394
+ }
12395
+ async handleEmbeddingDeleted(event) {
12396
+ await this.kb.eventStore.appendEvent({
12397
+ type: "embedding.deleted",
12398
+ resourceId: event.resourceId,
12399
+ userId: makeUserId("did:web:system:smelter"),
12400
+ version: 1,
12401
+ payload: {
12402
+ annotationId: event.annotationId
12403
+ }
12404
+ });
12405
+ }
11862
12406
  async stop() {
11863
12407
  this.subscription?.unsubscribe();
11864
12408
  this.subscription = null;
@@ -11872,13 +12416,13 @@ function deriveStorageUri(name, format) {
11872
12416
  }
11873
12417
 
11874
12418
  // src/browser.ts
11875
- var import_rxjs5 = __toESM(require_cjs(), 1);
11876
- var import_operators5 = __toESM(require_operators(), 1);
12419
+ var import_rxjs6 = __toESM(require_cjs(), 1);
12420
+ var import_operators6 = __toESM(require_operators(), 1);
11877
12421
  import { promises as fs3 } from "fs";
11878
12422
  import * as path2 from "path";
11879
12423
  import { resourceId as resourceId3 } from "@semiont/core";
11880
- import { getExactText, getTargetSource as getTargetSource2, getTargetSelector as getTargetSelector2, getResourceEntityTypes as getResourceEntityTypes5, getBodySource as getBodySource2 } from "@semiont/api-client";
11881
- import { EventQuery as EventQuery2 } from "@semiont/event-sourcing";
12424
+ import { getExactText as getExactText2, getTargetSource as getTargetSource2, getTargetSelector as getTargetSelector3, getResourceEntityTypes as getResourceEntityTypes5, getBodySource as getBodySource2 } from "@semiont/api-client";
12425
+ import { EventQuery as EventQuery3 } from "@semiont/event-sourcing";
11882
12426
  import { getEntityTypes as getEntityTypes2 } from "@semiont/ontology";
11883
12427
 
11884
12428
  // src/views/entity-types-reader.ts
@@ -11917,7 +12461,7 @@ var Browser = class {
11917
12461
  async initialize() {
11918
12462
  this.logger.info("Browser actor initialized");
11919
12463
  const errorHandler = (err) => this.logger.error("Browser pipeline error", { error: err });
11920
- const pipe = (name, handler) => this.eventBus.get(name).pipe((0, import_operators5.mergeMap)((event) => (0, import_rxjs5.from)(handler(event))));
12464
+ const pipe = (name, handler) => this.eventBus.get(name).pipe((0, import_operators6.mergeMap)((event) => (0, import_rxjs6.from)(handler(event))));
11921
12465
  this.subscriptions.push(
11922
12466
  pipe("browse:resource-requested", (e) => this.handleBrowseResource(e)).subscribe({ error: errorHandler }),
11923
12467
  pipe("browse:resources-requested", (e) => this.handleBrowseResources(e)).subscribe({ error: errorHandler }),
@@ -11935,7 +12479,7 @@ var Browser = class {
11935
12479
  // ========================================================================
11936
12480
  async handleBrowseResource(event) {
11937
12481
  try {
11938
- const eventQuery = new EventQuery2(this.kb.eventStore.log.storage);
12482
+ const eventQuery = new EventQuery3(this.kb.eventStore.log.storage);
11939
12483
  const events = await eventQuery.getResourceEvents(event.resourceId);
11940
12484
  const stored = await this.kb.eventStore.views.materializer.materialize(events, event.resourceId);
11941
12485
  if (!stored) {
@@ -12048,7 +12592,7 @@ var Browser = class {
12048
12592
  }
12049
12593
  async handleBrowseEvents(event) {
12050
12594
  try {
12051
- const eventQuery = new EventQuery2(this.kb.eventStore.log.storage);
12595
+ const eventQuery = new EventQuery3(this.kb.eventStore.log.storage);
12052
12596
  const filters = {
12053
12597
  resourceId: event.resourceId
12054
12598
  };
@@ -12103,7 +12647,7 @@ var Browser = class {
12103
12647
  });
12104
12648
  return;
12105
12649
  }
12106
- const eventQuery = new EventQuery2(this.kb.eventStore.log.storage);
12650
+ const eventQuery = new EventQuery3(this.kb.eventStore.log.storage);
12107
12651
  const allEvents = await eventQuery.queryEvents({ resourceId: event.resourceId });
12108
12652
  const annotationEvents = allEvents.filter((stored) => {
12109
12653
  const ev = stored.event;
@@ -12159,7 +12703,7 @@ var Browser = class {
12159
12703
  const docMap = new Map(resources.filter((doc) => doc !== null).map((doc) => [doc["@id"], doc]));
12160
12704
  const referencedBy = references.map((ref) => {
12161
12705
  const targetSource = getTargetSource2(ref.target);
12162
- const targetSelector = getTargetSelector2(ref.target);
12706
+ const targetSelector = getTargetSelector3(ref.target);
12163
12707
  const doc = docMap.get(targetSource);
12164
12708
  return {
12165
12709
  id: ref.id,
@@ -12167,7 +12711,7 @@ var Browser = class {
12167
12711
  target: {
12168
12712
  source: targetSource,
12169
12713
  selector: {
12170
- exact: targetSelector ? getExactText(targetSelector) : ""
12714
+ exact: targetSelector ? getExactText2(targetSelector) : ""
12171
12715
  }
12172
12716
  }
12173
12717
  };
@@ -12305,30 +12849,30 @@ var Browser = class {
12305
12849
  };
12306
12850
 
12307
12851
  // src/clone-token-manager.ts
12308
- var import_rxjs7 = __toESM(require_cjs(), 1);
12309
- var import_operators7 = __toESM(require_operators(), 1);
12852
+ var import_rxjs8 = __toESM(require_cjs(), 1);
12853
+ var import_operators8 = __toESM(require_operators(), 1);
12310
12854
  import { CREATION_METHODS as CREATION_METHODS2, cloneToken as makeCloneToken } from "@semiont/core";
12311
12855
  import { getPrimaryRepresentation as getPrimaryRepresentation3, getResourceEntityTypes as getResourceEntityTypes6 } from "@semiont/api-client";
12312
12856
 
12313
12857
  // src/resource-operations.ts
12314
- var import_rxjs6 = __toESM(require_cjs(), 1);
12315
- var import_operators6 = __toESM(require_operators(), 1);
12858
+ var import_rxjs7 = __toESM(require_cjs(), 1);
12859
+ var import_operators7 = __toESM(require_operators(), 1);
12316
12860
  var ResourceOperations = class {
12317
12861
  /**
12318
12862
  * Create a new resource via EventBus → Stower
12319
12863
  */
12320
12864
  static async createResource(input, userId2, eventBus) {
12321
- const result$ = (0, import_rxjs6.race)(
12865
+ const result$ = (0, import_rxjs7.race)(
12322
12866
  eventBus.get("yield:created").pipe(
12323
- (0, import_operators6.take)(1),
12324
- (0, import_operators6.map)((result) => ({ ok: true, result }))
12867
+ (0, import_operators7.take)(1),
12868
+ (0, import_operators7.map)((result) => ({ ok: true, result }))
12325
12869
  ),
12326
12870
  eventBus.get("yield:create-failed").pipe(
12327
- (0, import_operators6.take)(1),
12328
- (0, import_operators6.map)((failure) => ({ ok: false, error: failure.error }))
12871
+ (0, import_operators7.take)(1),
12872
+ (0, import_operators7.map)((failure) => ({ ok: false, error: failure.error }))
12329
12873
  ),
12330
- (0, import_rxjs6.timer)(3e4).pipe(
12331
- (0, import_operators6.map)(() => ({ ok: false, error: new Error("Resource creation timed out") }))
12874
+ (0, import_rxjs7.timer)(3e4).pipe(
12875
+ (0, import_operators7.map)(() => ({ ok: false, error: new Error("Resource creation timed out") }))
12332
12876
  )
12333
12877
  );
12334
12878
  eventBus.get("yield:create").next({
@@ -12341,7 +12885,7 @@ var ResourceOperations = class {
12341
12885
  creationMethod: input.creationMethod,
12342
12886
  storageUri: input.storageUri
12343
12887
  });
12344
- const outcome = await (0, import_rxjs6.firstValueFrom)(result$);
12888
+ const outcome = await (0, import_rxjs7.firstValueFrom)(result$);
12345
12889
  if (!outcome.ok) {
12346
12890
  throw outcome.error;
12347
12891
  }
@@ -12383,13 +12927,13 @@ var CloneTokenManager = class {
12383
12927
  this.logger.info("CloneTokenManager actor initialized");
12384
12928
  const errorHandler = (err) => this.logger.error("CloneTokenManager pipeline error", { error: err });
12385
12929
  const generateToken$ = this.eventBus.get("yield:clone-token-requested").pipe(
12386
- (0, import_operators7.mergeMap)((event) => (0, import_rxjs7.from)(this.handleGenerateToken(event)))
12930
+ (0, import_operators8.mergeMap)((event) => (0, import_rxjs8.from)(this.handleGenerateToken(event)))
12387
12931
  );
12388
12932
  const getResource$ = this.eventBus.get("yield:clone-resource-requested").pipe(
12389
- (0, import_operators7.mergeMap)((event) => (0, import_rxjs7.from)(this.handleGetResource(event)))
12933
+ (0, import_operators8.mergeMap)((event) => (0, import_rxjs8.from)(this.handleGetResource(event)))
12390
12934
  );
12391
12935
  const createResource$ = this.eventBus.get("yield:clone-create").pipe(
12392
- (0, import_operators7.mergeMap)((event) => (0, import_rxjs7.from)(this.handleCreateResource(event)))
12936
+ (0, import_operators8.mergeMap)((event) => (0, import_rxjs8.from)(this.handleCreateResource(event)))
12393
12937
  );
12394
12938
  this.subscriptions.push(
12395
12939
  generateToken$.subscribe({ error: errorHandler }),
@@ -12562,8 +13106,8 @@ var CloneTokenManager = class {
12562
13106
  };
12563
13107
 
12564
13108
  // src/bootstrap/entity-types.ts
12565
- var import_rxjs8 = __toESM(require_cjs(), 1);
12566
- var import_operators8 = __toESM(require_operators(), 1);
13109
+ var import_rxjs9 = __toESM(require_cjs(), 1);
13110
+ var import_operators9 = __toESM(require_operators(), 1);
12567
13111
  import { promises as fs4 } from "fs";
12568
13112
  import * as path3 from "path";
12569
13113
  import { DEFAULT_ENTITY_TYPES } from "@semiont/ontology";
@@ -12594,13 +13138,13 @@ async function bootstrapEntityTypes(eventBus, project, logger) {
12594
13138
  const SYSTEM_USER_ID = userId("00000000-0000-0000-0000-000000000000");
12595
13139
  for (const entityType of DEFAULT_ENTITY_TYPES) {
12596
13140
  logger?.debug("Adding entity type via EventBus", { entityType });
12597
- const result$ = (0, import_rxjs8.race)(
12598
- eventBus.get("mark:entity-type-added").pipe((0, import_operators8.take)(1), (0, import_operators8.map)(() => ({ ok: true }))),
12599
- eventBus.get("mark:entity-type-add-failed").pipe((0, import_operators8.take)(1), (0, import_operators8.map)((f) => ({ ok: false, error: f.error }))),
12600
- (0, import_rxjs8.timer)(1e4).pipe((0, import_operators8.map)(() => ({ ok: false, error: new Error(`Timeout adding entity type: ${entityType}`) })))
13141
+ const result$ = (0, import_rxjs9.race)(
13142
+ eventBus.get("mark:entity-type-added").pipe((0, import_operators9.take)(1), (0, import_operators9.map)(() => ({ ok: true }))),
13143
+ eventBus.get("mark:entity-type-add-failed").pipe((0, import_operators9.take)(1), (0, import_operators9.map)((f) => ({ ok: false, error: f.error }))),
13144
+ (0, import_rxjs9.timer)(1e4).pipe((0, import_operators9.map)(() => ({ ok: false, error: new Error(`Timeout adding entity type: ${entityType}`) })))
12601
13145
  );
12602
13146
  eventBus.get("mark:add-entity-type").next({ tag: entityType, userId: SYSTEM_USER_ID });
12603
- const outcome = await (0, import_rxjs8.firstValueFrom)(result$);
13147
+ const outcome = await (0, import_rxjs9.firstValueFrom)(result$);
12604
13148
  if (!outcome.ok) {
12605
13149
  throw outcome.error;
12606
13150
  }
@@ -12629,7 +13173,7 @@ async function createJobQueue(project, eventBus, logger) {
12629
13173
  const jobQueue = new JobQueue(project, jobQueueLogger, eventBus);
12630
13174
  await jobQueue.initialize();
12631
13175
  const jobStatusSubscription = eventBus.get("job:status-requested").pipe(
12632
- (0, import_operators9.mergeMap)((event) => (0, import_rxjs9.from)((async () => {
13176
+ (0, import_operators10.mergeMap)((event) => (0, import_rxjs10.from)((async () => {
12633
13177
  try {
12634
13178
  const job = await jobQueue.getJob(event.jobId);
12635
13179
  if (!job) {
@@ -12663,11 +13207,39 @@ async function createJobQueue(project, eventBus, logger) {
12663
13207
  });
12664
13208
  return { jobQueue, jobStatusSubscription };
12665
13209
  }
12666
- async function createKnowledgeSystemFromConfig(project, config, eventBus, logger) {
13210
+ async function createKnowledgeSystemFromConfig(project, config, eventBus, logger, skipRebuild) {
12667
13211
  const graphConfig = config.services.graph;
12668
13212
  const graphDb = await getGraphDatabase(graphConfig);
12669
13213
  const eventStore = createEventStoreCore(project, eventBus, logger.child({ component: "event-store" }));
12670
- const kb = await createKnowledgeBase(eventStore, project, graphDb, logger);
13214
+ let vectorStore;
13215
+ let embeddingProvider;
13216
+ const vectorsConfig = config.services.vectors;
13217
+ const embeddingConfig = config.services.embedding;
13218
+ if (vectorsConfig && embeddingConfig) {
13219
+ const { createVectorStore, createEmbeddingProvider } = await import("@semiont/vectors");
13220
+ embeddingProvider = await createEmbeddingProvider(embeddingConfig);
13221
+ vectorStore = await createVectorStore({
13222
+ type: vectorsConfig.type ?? "qdrant",
13223
+ host: vectorsConfig.host,
13224
+ port: vectorsConfig.port,
13225
+ dimensions: embeddingProvider.dimensions()
13226
+ });
13227
+ logger.info("Vector search initialized", {
13228
+ store: vectorsConfig.type,
13229
+ embedding: embeddingConfig.type,
13230
+ model: embeddingConfig.model
13231
+ });
13232
+ }
13233
+ const kb = await createKnowledgeBase(eventStore, project, graphDb, logger, {
13234
+ vectorStore,
13235
+ embeddingProvider,
13236
+ eventBus,
13237
+ chunkingConfig: embeddingConfig?.chunking ? {
13238
+ chunkSize: embeddingConfig.chunking.chunkSize ?? 512,
13239
+ overlap: embeddingConfig.chunking.overlap ?? 64
13240
+ } : void 0,
13241
+ skipRebuild
13242
+ });
12671
13243
  const stower = new Stower(kb, eventBus, logger.child({ component: "stower" }));
12672
13244
  await stower.initialize();
12673
13245
  await bootstrapEntityTypes(eventBus, project, logger.child({ component: "entity-types-bootstrap" }));
@@ -12675,14 +13247,16 @@ async function createKnowledgeSystemFromConfig(project, config, eventBus, logger
12675
13247
  kb,
12676
13248
  eventBus,
12677
13249
  createInferenceClient(resolveActorInference(config, "gatherer"), logger.child({ component: "inference-client-gatherer" })),
12678
- logger.child({ component: "gatherer" })
13250
+ logger.child({ component: "gatherer" }),
13251
+ embeddingProvider
12679
13252
  );
12680
13253
  await gatherer.initialize();
12681
13254
  const matcher = new Matcher(
12682
13255
  kb,
12683
13256
  eventBus,
12684
13257
  logger.child({ component: "matcher" }),
12685
- createInferenceClient(resolveActorInference(config, "matcher"), logger.child({ component: "inference-client-matcher" }))
13258
+ createInferenceClient(resolveActorInference(config, "matcher"), logger.child({ component: "inference-client-matcher" })),
13259
+ embeddingProvider
12686
13260
  );
12687
13261
  await matcher.initialize();
12688
13262
  const browser = new Browser(kb.views, kb, eventBus, project, logger.child({ component: "browser" }));
@@ -12743,12 +13317,13 @@ function startWorkers(workers, logger) {
12743
13317
  });
12744
13318
  }
12745
13319
  }
12746
- async function startMakeMeaning(project, config, eventBus, logger) {
13320
+ async function startMakeMeaning(project, config, eventBus, logger, options) {
12747
13321
  if (!config.services?.graph) {
12748
13322
  throw new Error("services.graph is required for make-meaning service");
12749
13323
  }
13324
+ const skipRebuild = options?.skipRebuild ?? process.env.SEMIONT_SKIP_REBUILD === "true";
12750
13325
  const { jobQueue, jobStatusSubscription } = await createJobQueue(project, eventBus, logger);
12751
- const knowledgeSystem = await createKnowledgeSystemFromConfig(project, config, eventBus, logger);
13326
+ const knowledgeSystem = await createKnowledgeSystemFromConfig(project, config, eventBus, logger, skipRebuild);
12752
13327
  const contentFetcher = createContentFetcher(knowledgeSystem);
12753
13328
  const workers = createWorkers(jobQueue, contentFetcher, eventBus, config, logger);
12754
13329
  startWorkers(workers, logger);
@@ -12959,8 +13534,8 @@ function collectContentRefs(streamData) {
12959
13534
  }
12960
13535
 
12961
13536
  // src/exchange/replay.ts
12962
- var import_rxjs10 = __toESM(require_cjs(), 1);
12963
- var import_operators10 = __toESM(require_operators(), 1);
13537
+ var import_rxjs11 = __toESM(require_cjs(), 1);
13538
+ var import_operators11 = __toESM(require_operators(), 1);
12964
13539
  var REPLAY_TIMEOUT_MS = 3e4;
12965
13540
  async function replayEventStream(jsonl, eventBus, resolveBlob, logger) {
12966
13541
  const lines = jsonl.trim().split("\n").filter((l) => l.length > 0);
@@ -13039,12 +13614,12 @@ async function replayEvent(event, eventBus, resolveBlob, stats, logger) {
13039
13614
  }
13040
13615
  }
13041
13616
  async function replayEntityTypeAdded(event, eventBus, logger) {
13042
- const result$ = (0, import_rxjs10.race)(
13043
- eventBus.get("mark:entity-type-added").pipe((0, import_operators10.map)(() => "ok")),
13044
- eventBus.get("mark:entity-type-add-failed").pipe((0, import_operators10.map)((e) => {
13617
+ const result$ = (0, import_rxjs11.race)(
13618
+ eventBus.get("mark:entity-type-added").pipe((0, import_operators11.map)(() => "ok")),
13619
+ eventBus.get("mark:entity-type-add-failed").pipe((0, import_operators11.map)((e) => {
13045
13620
  throw e.error;
13046
13621
  })),
13047
- (0, import_rxjs10.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators10.map)(() => {
13622
+ (0, import_rxjs11.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators11.map)(() => {
13048
13623
  throw new Error("Timeout waiting for mark:entity-type-added");
13049
13624
  }))
13050
13625
  );
@@ -13052,7 +13627,7 @@ async function replayEntityTypeAdded(event, eventBus, logger) {
13052
13627
  tag: event.payload.entityType,
13053
13628
  userId: event.userId
13054
13629
  });
13055
- await (0, import_rxjs10.firstValueFrom)(result$);
13630
+ await (0, import_rxjs11.firstValueFrom)(result$);
13056
13631
  logger?.debug("Replayed entitytype.added", { entityType: event.payload.entityType });
13057
13632
  }
13058
13633
  async function replayResourceCreated(event, eventBus, resolveBlob, logger) {
@@ -13061,12 +13636,12 @@ async function replayResourceCreated(event, eventBus, resolveBlob, logger) {
13061
13636
  if (!blob) {
13062
13637
  throw new Error(`Missing content blob for checksum ${payload.contentChecksum}`);
13063
13638
  }
13064
- const result$ = (0, import_rxjs10.race)(
13065
- eventBus.get("yield:created").pipe((0, import_operators10.map)((r) => r)),
13066
- eventBus.get("yield:create-failed").pipe((0, import_operators10.map)((e) => {
13639
+ const result$ = (0, import_rxjs11.race)(
13640
+ eventBus.get("yield:created").pipe((0, import_operators11.map)((r) => r)),
13641
+ eventBus.get("yield:create-failed").pipe((0, import_operators11.map)((e) => {
13067
13642
  throw e.error;
13068
13643
  })),
13069
- (0, import_rxjs10.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators10.map)(() => {
13644
+ (0, import_rxjs11.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators11.map)(() => {
13070
13645
  throw new Error("Timeout waiting for yield:created");
13071
13646
  }))
13072
13647
  );
@@ -13082,16 +13657,16 @@ async function replayResourceCreated(event, eventBus, resolveBlob, logger) {
13082
13657
  generatedFrom: payload.generatedFrom,
13083
13658
  generationPrompt: payload.generationPrompt
13084
13659
  });
13085
- await (0, import_rxjs10.firstValueFrom)(result$);
13660
+ await (0, import_rxjs11.firstValueFrom)(result$);
13086
13661
  logger?.debug("Replayed resource.created", { name: payload.name });
13087
13662
  }
13088
13663
  async function replayAnnotationAdded(event, eventBus, logger) {
13089
- const result$ = (0, import_rxjs10.race)(
13090
- eventBus.get("mark:created").pipe((0, import_operators10.map)(() => "ok")),
13091
- eventBus.get("mark:create-failed").pipe((0, import_operators10.map)((e) => {
13664
+ const result$ = (0, import_rxjs11.race)(
13665
+ eventBus.get("mark:created").pipe((0, import_operators11.map)(() => "ok")),
13666
+ eventBus.get("mark:create-failed").pipe((0, import_operators11.map)((e) => {
13092
13667
  throw e.error;
13093
13668
  })),
13094
- (0, import_rxjs10.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators10.map)(() => {
13669
+ (0, import_rxjs11.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators11.map)(() => {
13095
13670
  throw new Error("Timeout waiting for mark:created");
13096
13671
  }))
13097
13672
  );
@@ -13100,16 +13675,16 @@ async function replayAnnotationAdded(event, eventBus, logger) {
13100
13675
  userId: event.userId,
13101
13676
  resourceId: event.resourceId
13102
13677
  });
13103
- await (0, import_rxjs10.firstValueFrom)(result$);
13678
+ await (0, import_rxjs11.firstValueFrom)(result$);
13104
13679
  logger?.debug("Replayed annotation.added", { annotationId: event.payload.annotation.id });
13105
13680
  }
13106
13681
  async function replayAnnotationBodyUpdated(event, eventBus, logger) {
13107
- const result$ = (0, import_rxjs10.race)(
13108
- eventBus.get("mark:body-updated").pipe((0, import_operators10.map)(() => "ok")),
13109
- eventBus.get("mark:body-update-failed").pipe((0, import_operators10.map)((e) => {
13682
+ const result$ = (0, import_rxjs11.race)(
13683
+ eventBus.get("mark:body-updated").pipe((0, import_operators11.map)(() => "ok")),
13684
+ eventBus.get("mark:body-update-failed").pipe((0, import_operators11.map)((e) => {
13110
13685
  throw e.error;
13111
13686
  })),
13112
- (0, import_rxjs10.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators10.map)(() => {
13687
+ (0, import_rxjs11.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators11.map)(() => {
13113
13688
  throw new Error("Timeout waiting for mark:body-updated");
13114
13689
  }))
13115
13690
  );
@@ -13119,16 +13694,16 @@ async function replayAnnotationBodyUpdated(event, eventBus, logger) {
13119
13694
  resourceId: event.resourceId,
13120
13695
  operations: event.payload.operations
13121
13696
  });
13122
- await (0, import_rxjs10.firstValueFrom)(result$);
13697
+ await (0, import_rxjs11.firstValueFrom)(result$);
13123
13698
  logger?.debug("Replayed annotation.body.updated", { annotationId: event.payload.annotationId });
13124
13699
  }
13125
13700
  async function replayAnnotationRemoved(event, eventBus, logger) {
13126
- const result$ = (0, import_rxjs10.race)(
13127
- eventBus.get("mark:deleted").pipe((0, import_operators10.map)(() => "ok")),
13128
- eventBus.get("mark:delete-failed").pipe((0, import_operators10.map)((e) => {
13701
+ const result$ = (0, import_rxjs11.race)(
13702
+ eventBus.get("mark:deleted").pipe((0, import_operators11.map)(() => "ok")),
13703
+ eventBus.get("mark:delete-failed").pipe((0, import_operators11.map)((e) => {
13129
13704
  throw e.error;
13130
13705
  })),
13131
- (0, import_rxjs10.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators10.map)(() => {
13706
+ (0, import_rxjs11.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators11.map)(() => {
13132
13707
  throw new Error("Timeout waiting for mark:deleted");
13133
13708
  }))
13134
13709
  );
@@ -13137,7 +13712,7 @@ async function replayAnnotationRemoved(event, eventBus, logger) {
13137
13712
  userId: event.userId,
13138
13713
  resourceId: event.resourceId
13139
13714
  });
13140
- await (0, import_rxjs10.firstValueFrom)(result$);
13715
+ await (0, import_rxjs11.firstValueFrom)(result$);
13141
13716
  logger?.debug("Replayed annotation.removed", { annotationId: event.payload.annotationId });
13142
13717
  }
13143
13718
  async function replayResourceArchived(event, eventBus, logger) {
@@ -13428,8 +14003,8 @@ function collectContentRefsFromResource(resource, refs) {
13428
14003
  }
13429
14004
 
13430
14005
  // src/exchange/linked-data-importer.ts
13431
- var import_rxjs11 = __toESM(require_cjs(), 1);
13432
- var import_operators11 = __toESM(require_operators(), 1);
14006
+ var import_rxjs12 = __toESM(require_cjs(), 1);
14007
+ var import_operators12 = __toESM(require_operators(), 1);
13433
14008
  var IMPORT_TIMEOUT_MS = 3e4;
13434
14009
  function stripUriToId(uri) {
13435
14010
  if (!uri.includes("/")) return uri;
@@ -13531,12 +14106,12 @@ async function importLinkedData(archive, options) {
13531
14106
  };
13532
14107
  }
13533
14108
  async function addEntityType(entityType, userId2, eventBus, logger) {
13534
- const result$ = (0, import_rxjs11.race)(
13535
- eventBus.get("mark:entity-type-added").pipe((0, import_operators11.map)(() => "ok")),
13536
- eventBus.get("mark:entity-type-add-failed").pipe((0, import_operators11.map)((e) => {
14109
+ const result$ = (0, import_rxjs12.race)(
14110
+ eventBus.get("mark:entity-type-added").pipe((0, import_operators12.map)(() => "ok")),
14111
+ eventBus.get("mark:entity-type-add-failed").pipe((0, import_operators12.map)((e) => {
13537
14112
  throw e.error;
13538
14113
  })),
13539
- (0, import_rxjs11.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators11.map)(() => {
14114
+ (0, import_rxjs12.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators12.map)(() => {
13540
14115
  throw new Error("Timeout waiting for mark:entity-type-added");
13541
14116
  }))
13542
14117
  );
@@ -13544,7 +14119,7 @@ async function addEntityType(entityType, userId2, eventBus, logger) {
13544
14119
  tag: entityType,
13545
14120
  userId: userId2
13546
14121
  });
13547
- await (0, import_rxjs11.firstValueFrom)(result$);
14122
+ await (0, import_rxjs12.firstValueFrom)(result$);
13548
14123
  logger?.debug("Added entity type", { entityType });
13549
14124
  }
13550
14125
  async function importResource(doc, userId2, eventBus, resolveBlob, logger) {
@@ -13569,12 +14144,12 @@ async function importResource(doc, userId2, eventBus, resolveBlob, logger) {
13569
14144
  if (!blob) {
13570
14145
  throw new Error(`Missing content blob for checksum ${contentChecksum} (resource "${name}")`);
13571
14146
  }
13572
- const createResult$ = (0, import_rxjs11.race)(
13573
- eventBus.get("yield:created").pipe((0, import_operators11.map)((r) => r)),
13574
- eventBus.get("yield:create-failed").pipe((0, import_operators11.map)((e) => {
14147
+ const createResult$ = (0, import_rxjs12.race)(
14148
+ eventBus.get("yield:created").pipe((0, import_operators12.map)((r) => r)),
14149
+ eventBus.get("yield:create-failed").pipe((0, import_operators12.map)((e) => {
13575
14150
  throw e.error;
13576
14151
  })),
13577
- (0, import_rxjs11.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators11.map)(() => {
14152
+ (0, import_rxjs12.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators12.map)(() => {
13578
14153
  throw new Error("Timeout waiting for yield:created");
13579
14154
  }))
13580
14155
  );
@@ -13587,7 +14162,7 @@ async function importResource(doc, userId2, eventBus, resolveBlob, logger) {
13587
14162
  entityTypes: entityTypes ?? [],
13588
14163
  creationMethod
13589
14164
  });
13590
- const created = await (0, import_rxjs11.firstValueFrom)(createResult$);
14165
+ const created = await (0, import_rxjs12.firstValueFrom)(createResult$);
13591
14166
  const resourceId4 = created.resourceId;
13592
14167
  logger?.debug("Created resource from JSON-LD", { name, resourceId: resourceId4 });
13593
14168
  let annotationsCreated = 0;
@@ -13600,12 +14175,12 @@ async function importResource(doc, userId2, eventBus, resolveBlob, logger) {
13600
14175
  return { annotationsCreated };
13601
14176
  }
13602
14177
  async function createAnnotation(annotation, resourceId4, userId2, eventBus, logger) {
13603
- const result$ = (0, import_rxjs11.race)(
13604
- eventBus.get("mark:created").pipe((0, import_operators11.map)(() => "ok")),
13605
- eventBus.get("mark:create-failed").pipe((0, import_operators11.map)((e) => {
14178
+ const result$ = (0, import_rxjs12.race)(
14179
+ eventBus.get("mark:created").pipe((0, import_operators12.map)(() => "ok")),
14180
+ eventBus.get("mark:create-failed").pipe((0, import_operators12.map)((e) => {
13606
14181
  throw e.error;
13607
14182
  })),
13608
- (0, import_rxjs11.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators11.map)(() => {
14183
+ (0, import_rxjs12.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators12.map)(() => {
13609
14184
  throw new Error("Timeout waiting for mark:created");
13610
14185
  }))
13611
14186
  );
@@ -13614,7 +14189,7 @@ async function createAnnotation(annotation, resourceId4, userId2, eventBus, logg
13614
14189
  userId: userId2,
13615
14190
  resourceId: resourceId4
13616
14191
  });
13617
- await (0, import_rxjs11.firstValueFrom)(result$);
14192
+ await (0, import_rxjs12.firstValueFrom)(result$);
13618
14193
  logger?.debug("Created annotation", { annotationId: annotation.id });
13619
14194
  }
13620
14195
 
@@ -13625,14 +14200,14 @@ import {
13625
14200
  } from "@semiont/core";
13626
14201
 
13627
14202
  // src/annotation-operations.ts
13628
- import { annotationId, resourceId as makeResourceId3, assembleAnnotation as assembleAnnotation2, applyBodyOperations as applyBodyOperations2 } from "@semiont/core";
14203
+ import { annotationId, resourceId as makeResourceId4, assembleAnnotation as assembleAnnotation2, applyBodyOperations as applyBodyOperations2 } from "@semiont/core";
13629
14204
  var AnnotationOperations = class {
13630
14205
  /**
13631
14206
  * Create a new annotation via EventBus → Stower
13632
14207
  */
13633
14208
  static async createAnnotation(request, userId2, creator, eventBus) {
13634
14209
  const { annotation } = assembleAnnotation2(request, creator);
13635
- const resId = makeResourceId3(request.target.source);
14210
+ const resId = makeResourceId4(request.target.source);
13636
14211
  eventBus.get("mark:create").next({
13637
14212
  annotation,
13638
14213
  userId: userId2,
@@ -13644,7 +14219,7 @@ var AnnotationOperations = class {
13644
14219
  * Update annotation body via EventBus → Stower
13645
14220
  */
13646
14221
  static async updateAnnotationBody(id, request, userId2, eventBus, kb) {
13647
- const resId = makeResourceId3(request.resourceId);
14222
+ const resId = makeResourceId4(request.resourceId);
13648
14223
  const annotation = await AnnotationContext.getAnnotation(
13649
14224
  annotationId(id),
13650
14225
  resId,
@@ -13671,7 +14246,7 @@ var AnnotationOperations = class {
13671
14246
  * Delete an annotation via EventBus → Stower
13672
14247
  */
13673
14248
  static async deleteAnnotation(id, resourceIdStr, userId2, eventBus, kb, logger) {
13674
- const resId = makeResourceId3(resourceIdStr);
14249
+ const resId = makeResourceId4(resourceIdStr);
13675
14250
  const projection = await AnnotationContext.getResourceAnnotations(resId, kb);
13676
14251
  const annotation = projection.annotations.find((a) => a.id === id);
13677
14252
  if (!annotation) {
@@ -13704,6 +14279,7 @@ export {
13704
14279
  PACKAGE_NAME,
13705
14280
  ResourceContext,
13706
14281
  ResourceOperations,
14282
+ Smelter,
13707
14283
  Stower,
13708
14284
  VERSION,
13709
14285
  applyBodyOperations,