@semiont/make-meaning 0.4.20 → 0.4.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +25 -176
- package/dist/index.js +329 -1020
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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,
|
|
11
|
-
if (
|
|
12
|
-
for (let key of __getOwnPropNames(
|
|
10
|
+
var __copyProps = (to, from8, except, desc) => {
|
|
11
|
+
if (from8 && typeof from8 === "object" || typeof from8 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from8))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () =>
|
|
14
|
+
__defProp(to, key, { get: () => from8[key], enumerable: !(desc = __getOwnPropDesc(from8, 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,
|
|
129
|
-
for (var i = 0, il =
|
|
130
|
-
to[j] =
|
|
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];
|
|
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
|
|
139
|
-
function
|
|
138
|
+
var Subscription7 = (function() {
|
|
139
|
+
function Subscription8(initialTeardown) {
|
|
140
140
|
this.initialTeardown = initialTeardown;
|
|
141
141
|
this.closed = false;
|
|
142
142
|
this._parentage = null;
|
|
143
143
|
this._finalizers = null;
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
Subscription8.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
|
-
|
|
212
|
+
Subscription8.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
|
|
218
|
+
if (teardown instanceof Subscription8) {
|
|
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
|
-
|
|
228
|
+
Subscription8.prototype._hasParent = function(parent) {
|
|
229
229
|
var _parentage = this._parentage;
|
|
230
230
|
return _parentage === parent || Array.isArray(_parentage) && _parentage.includes(parent);
|
|
231
231
|
};
|
|
232
|
-
|
|
232
|
+
Subscription8.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
|
-
|
|
236
|
+
Subscription8.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
|
-
|
|
244
|
+
Subscription8.prototype.remove = function(teardown) {
|
|
245
245
|
var _finalizers = this._finalizers;
|
|
246
246
|
_finalizers && arrRemove_1.arrRemove(_finalizers, teardown);
|
|
247
|
-
if (teardown instanceof
|
|
247
|
+
if (teardown instanceof Subscription8) {
|
|
248
248
|
teardown._removeParent(this);
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
|
-
|
|
252
|
-
var empty = new
|
|
251
|
+
Subscription8.EMPTY = (function() {
|
|
252
|
+
var empty = new Subscription8();
|
|
253
253
|
empty.closed = true;
|
|
254
254
|
return empty;
|
|
255
255
|
})();
|
|
256
|
-
return
|
|
256
|
+
return Subscription8;
|
|
257
257
|
})();
|
|
258
|
-
exports.Subscription =
|
|
259
|
-
exports.EMPTY_SUBSCRIPTION =
|
|
258
|
+
exports.Subscription = Subscription7;
|
|
259
|
+
exports.EMPTY_SUBSCRIPTION = Subscription7.EMPTY;
|
|
260
260
|
function isSubscription(value) {
|
|
261
|
-
return value instanceof
|
|
261
|
+
return value instanceof Subscription7 || 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,
|
|
312
|
-
for (var i = 0, il =
|
|
313
|
-
to[j] =
|
|
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];
|
|
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,
|
|
1072
|
-
for (var i = 0, il =
|
|
1073
|
-
to[j] =
|
|
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];
|
|
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
|
|
1219
|
-
__extends(
|
|
1220
|
-
function
|
|
1218
|
+
var Subject2 = (function(_super) {
|
|
1219
|
+
__extends(Subject3, _super);
|
|
1220
|
+
function Subject3() {
|
|
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
|
-
|
|
1230
|
+
Subject3.prototype.lift = function(operator) {
|
|
1231
1231
|
var subject = new AnonymousSubject(this, this);
|
|
1232
1232
|
subject.operator = operator;
|
|
1233
1233
|
return subject;
|
|
1234
1234
|
};
|
|
1235
|
-
|
|
1235
|
+
Subject3.prototype._throwIfClosed = function() {
|
|
1236
1236
|
if (this.closed) {
|
|
1237
1237
|
throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
|
|
1238
1238
|
}
|
|
1239
1239
|
};
|
|
1240
|
-
|
|
1240
|
+
Subject3.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
|
-
|
|
1266
|
+
Subject3.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
|
-
|
|
1280
|
+
Subject3.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
|
-
|
|
1293
|
+
Subject3.prototype.unsubscribe = function() {
|
|
1294
1294
|
this.isStopped = this.closed = true;
|
|
1295
1295
|
this.observers = this.currentObservers = null;
|
|
1296
1296
|
};
|
|
1297
|
-
Object.defineProperty(
|
|
1297
|
+
Object.defineProperty(Subject3.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
|
-
|
|
1305
|
+
Subject3.prototype._trySubscribe = function(subscriber) {
|
|
1306
1306
|
this._throwIfClosed();
|
|
1307
1307
|
return _super.prototype._trySubscribe.call(this, subscriber);
|
|
1308
1308
|
};
|
|
1309
|
-
|
|
1309
|
+
Subject3.prototype._subscribe = function(subscriber) {
|
|
1310
1310
|
this._throwIfClosed();
|
|
1311
1311
|
this._checkFinalizedStatuses(subscriber);
|
|
1312
1312
|
return this._innerSubscribe(subscriber);
|
|
1313
1313
|
};
|
|
1314
|
-
|
|
1314
|
+
Subject3.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
|
-
|
|
1327
|
+
Subject3.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
|
-
|
|
1335
|
+
Subject3.prototype.asObservable = function() {
|
|
1336
1336
|
var observable = new Observable_1.Observable();
|
|
1337
1337
|
observable.source = this;
|
|
1338
1338
|
return observable;
|
|
1339
1339
|
};
|
|
1340
|
-
|
|
1340
|
+
Subject3.create = function(destination, source) {
|
|
1341
1341
|
return new AnonymousSubject(destination, source);
|
|
1342
1342
|
};
|
|
1343
|
-
return
|
|
1343
|
+
return Subject3;
|
|
1344
1344
|
})(Observable_1.Observable);
|
|
1345
|
-
exports.Subject =
|
|
1345
|
+
exports.Subject = Subject2;
|
|
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
|
-
})(
|
|
1371
|
+
})(Subject2);
|
|
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,
|
|
1672
|
-
for (var i = 0, il =
|
|
1673
|
-
to[j] =
|
|
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];
|
|
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,
|
|
1881
|
-
for (var i = 0, il =
|
|
1882
|
-
to[j] =
|
|
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];
|
|
1883
1883
|
return to;
|
|
1884
1884
|
};
|
|
1885
1885
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -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
|
|
3444
|
+
function from8(input, scheduler) {
|
|
3445
3445
|
return scheduler ? scheduled_1.scheduled(input, scheduler) : innerFrom_1.innerFrom(input);
|
|
3446
3446
|
}
|
|
3447
|
-
exports.from =
|
|
3447
|
+
exports.from = from8;
|
|
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,
|
|
3836
|
-
for (var i = 0, il =
|
|
3837
|
-
to[j] =
|
|
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];
|
|
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,
|
|
3878
|
-
for (var i = 0, il =
|
|
3879
|
-
to[j] =
|
|
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];
|
|
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
|
|
4199
|
+
function mergeMap6(project, resultSelector, concurrent) {
|
|
4200
4200
|
if (concurrent === void 0) {
|
|
4201
4201
|
concurrent = Infinity;
|
|
4202
4202
|
}
|
|
4203
4203
|
if (isFunction_1.isFunction(resultSelector)) {
|
|
4204
|
-
return
|
|
4204
|
+
return mergeMap6(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 =
|
|
4216
|
+
exports.mergeMap = mergeMap6;
|
|
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,
|
|
5012
|
-
for (var i = 0, il =
|
|
5013
|
-
to[j] =
|
|
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];
|
|
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,
|
|
5642
|
-
for (var i = 0, il =
|
|
5643
|
-
to[j] =
|
|
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];
|
|
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,
|
|
5690
|
-
for (var i = 0, il =
|
|
5691
|
-
to[j] =
|
|
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];
|
|
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
|
|
5716
|
+
function concatMap5(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 =
|
|
5719
|
+
exports.concatMap = concatMap5;
|
|
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,
|
|
5764
|
-
for (var i = 0, il =
|
|
5765
|
-
to[j] =
|
|
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];
|
|
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,
|
|
5810
|
-
for (var i = 0, il =
|
|
5811
|
-
to[j] =
|
|
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];
|
|
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,
|
|
6303
|
-
for (var i = 0, il =
|
|
6304
|
-
to[j] =
|
|
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];
|
|
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
|
|
6543
|
+
function groupBy3(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 =
|
|
6610
|
+
exports.groupBy = groupBy3;
|
|
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,
|
|
6850
|
-
for (var i = 0, il =
|
|
6851
|
-
to[j] =
|
|
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];
|
|
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,
|
|
6897
|
-
for (var i = 0, il =
|
|
6898
|
-
to[j] =
|
|
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];
|
|
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,
|
|
6982
|
-
for (var i = 0, il =
|
|
6983
|
-
to[j] =
|
|
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];
|
|
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,
|
|
7166
|
-
for (var i = 0, il =
|
|
7167
|
-
to[j] =
|
|
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];
|
|
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,
|
|
7564
|
-
for (var i = 0, il =
|
|
7565
|
-
to[j] =
|
|
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];
|
|
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,
|
|
8566
|
-
for (var i = 0, il =
|
|
8567
|
-
to[j] =
|
|
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];
|
|
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,
|
|
8652
|
-
for (var i = 0, il =
|
|
8653
|
-
to[j] =
|
|
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];
|
|
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,
|
|
8695
|
-
for (var i = 0, il =
|
|
8696
|
-
to[j] =
|
|
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];
|
|
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,
|
|
9463
|
-
for (var i = 0, il =
|
|
9464
|
-
to[j] =
|
|
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];
|
|
9465
9465
|
return to;
|
|
9466
9466
|
};
|
|
9467
9467
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -9943,7 +9943,7 @@ var require_operators = __commonJS({
|
|
|
9943
9943
|
});
|
|
9944
9944
|
|
|
9945
9945
|
// src/service.ts
|
|
9946
|
-
import {
|
|
9946
|
+
import { FsJobQueue } from "@semiont/jobs";
|
|
9947
9947
|
import { createEventStore as createEventStoreCore } from "@semiont/event-sourcing";
|
|
9948
9948
|
import { jobId } from "@semiont/core";
|
|
9949
9949
|
|
|
@@ -9955,42 +9955,12 @@ function resolveActorInference(config, actor) {
|
|
|
9955
9955
|
`No inference config found for actor '${actor}'. Set actors.${actor}.inference in your config.`
|
|
9956
9956
|
);
|
|
9957
9957
|
}
|
|
9958
|
-
function resolveWorkerInference(config, workerType) {
|
|
9959
|
-
const specific = config.workers?.[workerType];
|
|
9960
|
-
if (specific) return specific;
|
|
9961
|
-
const defaultWorker = config.workers?.default;
|
|
9962
|
-
if (defaultWorker) return defaultWorker;
|
|
9963
|
-
throw new Error(
|
|
9964
|
-
`No inference config found for worker '${workerType}'. Set workers.${workerType}.inference or workers.default.inference in your config.`
|
|
9965
|
-
);
|
|
9966
|
-
}
|
|
9967
|
-
|
|
9968
|
-
// src/agent-utils.ts
|
|
9969
|
-
function inferenceConfigToGenerator(workerType, config) {
|
|
9970
|
-
const providerLabel = config.type === "ollama" ? `Ollama ${config.model}` : config.type === "anthropic" ? `Anthropic ${config.model}` : config.type != null ? `${config.type} ${config.model}` : void 0;
|
|
9971
|
-
return {
|
|
9972
|
-
"@type": "SoftwareAgent",
|
|
9973
|
-
name: providerLabel ? `${workerType} / ${providerLabel}` : workerType,
|
|
9974
|
-
worker: workerType,
|
|
9975
|
-
inferenceProvider: config.type,
|
|
9976
|
-
model: config.model
|
|
9977
|
-
};
|
|
9978
|
-
}
|
|
9979
9958
|
|
|
9980
9959
|
// src/service.ts
|
|
9981
|
-
var
|
|
9982
|
-
var
|
|
9983
|
-
import { Readable } from "stream";
|
|
9960
|
+
var import_rxjs9 = __toESM(require_cjs(), 1);
|
|
9961
|
+
var import_operators9 = __toESM(require_operators(), 1);
|
|
9984
9962
|
import { createInferenceClient } from "@semiont/inference";
|
|
9985
9963
|
import { getGraphDatabase } from "@semiont/graph";
|
|
9986
|
-
import {
|
|
9987
|
-
ReferenceAnnotationWorker,
|
|
9988
|
-
GenerationWorker,
|
|
9989
|
-
HighlightAnnotationWorker,
|
|
9990
|
-
AssessmentAnnotationWorker,
|
|
9991
|
-
CommentAnnotationWorker,
|
|
9992
|
-
TagAnnotationWorker
|
|
9993
|
-
} from "@semiont/jobs";
|
|
9994
9964
|
|
|
9995
9965
|
// src/knowledge-base.ts
|
|
9996
9966
|
import { FilesystemViewStorage } from "@semiont/event-sourcing";
|
|
@@ -10355,7 +10325,7 @@ var GraphDBConsumer = class _GraphDBConsumer {
|
|
|
10355
10325
|
const query = new EventQuery(this.eventStore.log.storage);
|
|
10356
10326
|
const events = await query.getResourceEvents(resourceId7);
|
|
10357
10327
|
for (const storedEvent of events) {
|
|
10358
|
-
await this.
|
|
10328
|
+
await this.safeApplyEvent(storedEvent);
|
|
10359
10329
|
}
|
|
10360
10330
|
this.logger.info("Resource rebuild complete", { resourceId: resourceId7, eventCount: events.length });
|
|
10361
10331
|
}
|
|
@@ -10379,7 +10349,7 @@ var GraphDBConsumer = class _GraphDBConsumer {
|
|
|
10379
10349
|
if (storedEvent.type === "mark:body-updated") {
|
|
10380
10350
|
continue;
|
|
10381
10351
|
}
|
|
10382
|
-
await this.
|
|
10352
|
+
await this.safeApplyEvent(storedEvent);
|
|
10383
10353
|
}
|
|
10384
10354
|
}
|
|
10385
10355
|
this.logger.info("Pass 1 complete - all nodes created");
|
|
@@ -10388,7 +10358,7 @@ var GraphDBConsumer = class _GraphDBConsumer {
|
|
|
10388
10358
|
const events = await query.getResourceEvents(makeResourceId(resourceId7));
|
|
10389
10359
|
for (const storedEvent of events) {
|
|
10390
10360
|
if (storedEvent.type === "mark:body-updated") {
|
|
10391
|
-
await this.
|
|
10361
|
+
await this.safeApplyEvent(storedEvent);
|
|
10392
10362
|
}
|
|
10393
10363
|
}
|
|
10394
10364
|
}
|
|
@@ -10414,635 +10384,9 @@ var GraphDBConsumer = class _GraphDBConsumer {
|
|
|
10414
10384
|
}
|
|
10415
10385
|
};
|
|
10416
10386
|
|
|
10417
|
-
// src/smelter.ts
|
|
10418
|
-
var import_rxjs2 = __toESM(require_cjs(), 1);
|
|
10419
|
-
var import_operators2 = __toESM(require_operators(), 1);
|
|
10420
|
-
import { burstBuffer as burstBuffer2, errField as errField2 } from "@semiont/core";
|
|
10421
|
-
import { resourceId as makeResourceId2, annotationId as makeAnnotationId2 } from "@semiont/core";
|
|
10422
|
-
import { chunkText, DEFAULT_CHUNKING_CONFIG } from "@semiont/vectors";
|
|
10423
|
-
import { getExactText, getTargetSelector } from "@semiont/api-client";
|
|
10424
|
-
var Smelter = class _Smelter {
|
|
10425
|
-
constructor(_eventStore, eventBus, vectorStore, embeddingProvider, contentStore, embeddingStore, viewStorage, logger, chunkingConfig) {
|
|
10426
|
-
this.eventBus = eventBus;
|
|
10427
|
-
this.vectorStore = vectorStore;
|
|
10428
|
-
this.embeddingProvider = embeddingProvider;
|
|
10429
|
-
this.contentStore = contentStore;
|
|
10430
|
-
this.embeddingStore = embeddingStore;
|
|
10431
|
-
this.viewStorage = viewStorage;
|
|
10432
|
-
this.logger = logger;
|
|
10433
|
-
this.chunkingConfig = chunkingConfig ?? DEFAULT_CHUNKING_CONFIG;
|
|
10434
|
-
}
|
|
10435
|
-
static SMELTER_RELEVANT_EVENTS = /* @__PURE__ */ new Set([
|
|
10436
|
-
"yield:created",
|
|
10437
|
-
"yield:updated",
|
|
10438
|
-
"yield:representation-added",
|
|
10439
|
-
"mark:archived",
|
|
10440
|
-
"mark:added",
|
|
10441
|
-
"mark:removed"
|
|
10442
|
-
]);
|
|
10443
|
-
static BURST_WINDOW_MS = 50;
|
|
10444
|
-
static MAX_BATCH_SIZE = 100;
|
|
10445
|
-
static IDLE_TIMEOUT_MS = 200;
|
|
10446
|
-
_globalSubscriptions = [];
|
|
10447
|
-
eventSubject = new import_rxjs2.Subject();
|
|
10448
|
-
pipelineSubscription = null;
|
|
10449
|
-
logger;
|
|
10450
|
-
chunkingConfig;
|
|
10451
|
-
async initialize() {
|
|
10452
|
-
this.logger.info("Smelter actor initializing");
|
|
10453
|
-
for (const eventType of _Smelter.SMELTER_RELEVANT_EVENTS) {
|
|
10454
|
-
this._globalSubscriptions.push(
|
|
10455
|
-
this.eventBus.getDomainEvent(eventType).subscribe(
|
|
10456
|
-
(storedEvent) => this.eventSubject.next(storedEvent)
|
|
10457
|
-
)
|
|
10458
|
-
);
|
|
10459
|
-
}
|
|
10460
|
-
this.pipelineSubscription = this.eventSubject.pipe(
|
|
10461
|
-
(0, import_operators2.groupBy)((se) => se.resourceId ?? "__unknown__"),
|
|
10462
|
-
(0, import_operators2.mergeMap)(
|
|
10463
|
-
(group) => group.pipe(
|
|
10464
|
-
burstBuffer2({
|
|
10465
|
-
burstWindowMs: _Smelter.BURST_WINDOW_MS,
|
|
10466
|
-
maxBatchSize: _Smelter.MAX_BATCH_SIZE,
|
|
10467
|
-
idleTimeoutMs: _Smelter.IDLE_TIMEOUT_MS
|
|
10468
|
-
}),
|
|
10469
|
-
(0, import_operators2.concatMap)((eventOrBatch) => {
|
|
10470
|
-
if (Array.isArray(eventOrBatch)) {
|
|
10471
|
-
return (0, import_rxjs2.from)(this.processBatch(eventOrBatch));
|
|
10472
|
-
}
|
|
10473
|
-
return (0, import_rxjs2.from)(this.safeProcessEvent(eventOrBatch));
|
|
10474
|
-
})
|
|
10475
|
-
)
|
|
10476
|
-
)
|
|
10477
|
-
).subscribe({
|
|
10478
|
-
error: (err) => this.logger.error("Smelter pipeline error", { error: err })
|
|
10479
|
-
});
|
|
10480
|
-
this.logger.info("Smelter actor initialized");
|
|
10481
|
-
}
|
|
10482
|
-
async stop() {
|
|
10483
|
-
for (const sub of this._globalSubscriptions) sub.unsubscribe();
|
|
10484
|
-
this._globalSubscriptions = [];
|
|
10485
|
-
this.pipelineSubscription?.unsubscribe();
|
|
10486
|
-
this.eventSubject.complete();
|
|
10487
|
-
this.logger.info("Smelter actor stopped");
|
|
10488
|
-
}
|
|
10489
|
-
/**
|
|
10490
|
-
* Rebuild the vector store from the EmbeddingStore (.semiont/embeddings/).
|
|
10491
|
-
*
|
|
10492
|
-
* For each stored file, checks whether the model matches the configured
|
|
10493
|
-
* provider. On mismatch, re-embeds from the stored text and overwrites the
|
|
10494
|
-
* file before upserting into Qdrant. On match, loads the stored vectors
|
|
10495
|
-
* directly — no embedding provider calls needed.
|
|
10496
|
-
*/
|
|
10497
|
-
async rebuildAll() {
|
|
10498
|
-
this.logger.info("Rebuilding vector store from EmbeddingStore");
|
|
10499
|
-
await this.vectorStore.clearAll();
|
|
10500
|
-
const currentModel = this.embeddingProvider.model();
|
|
10501
|
-
const currentDimensions = this.embeddingProvider.dimensions();
|
|
10502
|
-
const resourceIds = await this.embeddingStore.getAllResourceIds();
|
|
10503
|
-
this.logger.info("Found resource embedding files", { count: resourceIds.length });
|
|
10504
|
-
let resourcesIndexed = 0;
|
|
10505
|
-
for (const rid of resourceIds) {
|
|
10506
|
-
const resourceId7 = makeResourceId2(rid);
|
|
10507
|
-
const stored = await this.embeddingStore.readResourceEmbeddings(resourceId7);
|
|
10508
|
-
if (!stored || stored.chunks.length === 0) continue;
|
|
10509
|
-
let chunks;
|
|
10510
|
-
if (stored.model !== currentModel) {
|
|
10511
|
-
this.logger.info("Re-embedding resource (model mismatch)", {
|
|
10512
|
-
resourceId: rid,
|
|
10513
|
-
storedModel: stored.model,
|
|
10514
|
-
currentModel
|
|
10515
|
-
});
|
|
10516
|
-
const texts = stored.chunks.map((c) => c.text);
|
|
10517
|
-
const embeddings = await this.embeddingProvider.embedBatch(texts);
|
|
10518
|
-
chunks = stored.chunks.map((c, i) => ({
|
|
10519
|
-
chunkIndex: c.chunkIndex,
|
|
10520
|
-
text: c.text,
|
|
10521
|
-
embedding: embeddings[i]
|
|
10522
|
-
}));
|
|
10523
|
-
await this.embeddingStore.writeResourceChunks(resourceId7, currentModel, currentDimensions, chunks);
|
|
10524
|
-
} else {
|
|
10525
|
-
chunks = stored.chunks;
|
|
10526
|
-
}
|
|
10527
|
-
await this.vectorStore.upsertResourceVectors(resourceId7, chunks);
|
|
10528
|
-
resourcesIndexed++;
|
|
10529
|
-
}
|
|
10530
|
-
const annotationIds = await this.embeddingStore.getAllAnnotationIds();
|
|
10531
|
-
this.logger.info("Found annotation embedding files", { count: annotationIds.length });
|
|
10532
|
-
let annotationsIndexed = 0;
|
|
10533
|
-
for (const aid of annotationIds) {
|
|
10534
|
-
const annotationId3 = makeAnnotationId2(aid);
|
|
10535
|
-
const stored = await this.embeddingStore.readAnnotationEmbedding(annotationId3);
|
|
10536
|
-
if (!stored) continue;
|
|
10537
|
-
let embedding;
|
|
10538
|
-
if (stored.model !== currentModel) {
|
|
10539
|
-
this.logger.info("Re-embedding annotation (model mismatch)", {
|
|
10540
|
-
annotationId: aid,
|
|
10541
|
-
storedModel: stored.model,
|
|
10542
|
-
currentModel
|
|
10543
|
-
});
|
|
10544
|
-
embedding = await this.embeddingProvider.embed(stored.text);
|
|
10545
|
-
await this.embeddingStore.writeAnnotationEmbedding(
|
|
10546
|
-
annotationId3,
|
|
10547
|
-
makeResourceId2(stored.resourceId),
|
|
10548
|
-
currentModel,
|
|
10549
|
-
currentDimensions,
|
|
10550
|
-
stored.text,
|
|
10551
|
-
embedding,
|
|
10552
|
-
stored.motivation,
|
|
10553
|
-
stored.entityTypes
|
|
10554
|
-
);
|
|
10555
|
-
} else {
|
|
10556
|
-
embedding = stored.embedding;
|
|
10557
|
-
}
|
|
10558
|
-
const payload = {
|
|
10559
|
-
annotationId: annotationId3,
|
|
10560
|
-
resourceId: makeResourceId2(stored.resourceId),
|
|
10561
|
-
motivation: stored.motivation,
|
|
10562
|
-
entityTypes: stored.entityTypes,
|
|
10563
|
-
exactText: stored.text
|
|
10564
|
-
};
|
|
10565
|
-
await this.vectorStore.upsertAnnotationVector(annotationId3, embedding, payload);
|
|
10566
|
-
annotationsIndexed++;
|
|
10567
|
-
}
|
|
10568
|
-
const storedResourceIdSet = new Set(resourceIds);
|
|
10569
|
-
const allViews = await this.viewStorage.getAll();
|
|
10570
|
-
let backfilled = 0;
|
|
10571
|
-
for (const view of allViews) {
|
|
10572
|
-
const ridStr = view.resource["@id"];
|
|
10573
|
-
if (storedResourceIdSet.has(ridStr)) continue;
|
|
10574
|
-
if (view.resource.archived) continue;
|
|
10575
|
-
if (!view.resource.storageUri) continue;
|
|
10576
|
-
let content;
|
|
10577
|
-
try {
|
|
10578
|
-
content = await this.contentStore.retrieve(view.resource.storageUri);
|
|
10579
|
-
} catch (err) {
|
|
10580
|
-
this.logger.warn("Smelter back-fill skipped \u2014 content missing", {
|
|
10581
|
-
resourceId: ridStr,
|
|
10582
|
-
storageUri: view.resource.storageUri,
|
|
10583
|
-
error: err instanceof Error ? err.message : String(err)
|
|
10584
|
-
});
|
|
10585
|
-
continue;
|
|
10586
|
-
}
|
|
10587
|
-
const text = new TextDecoder().decode(content);
|
|
10588
|
-
if (!text.trim()) continue;
|
|
10589
|
-
const chunks = chunkText(text, this.chunkingConfig);
|
|
10590
|
-
if (chunks.length === 0) continue;
|
|
10591
|
-
const rid = makeResourceId2(ridStr);
|
|
10592
|
-
const embeddings = await this.embeddingProvider.embedBatch(chunks);
|
|
10593
|
-
const embeddingChunks = chunks.map((chunkText2, i) => ({
|
|
10594
|
-
chunkIndex: i,
|
|
10595
|
-
text: chunkText2,
|
|
10596
|
-
embedding: embeddings[i]
|
|
10597
|
-
}));
|
|
10598
|
-
await this.embeddingStore.writeResourceChunks(rid, currentModel, currentDimensions, embeddingChunks);
|
|
10599
|
-
await this.vectorStore.upsertResourceVectors(rid, embeddingChunks);
|
|
10600
|
-
backfilled++;
|
|
10601
|
-
resourcesIndexed++;
|
|
10602
|
-
this.logger.info("Smelter back-filled missing resource embedding", { resourceId: ridStr });
|
|
10603
|
-
}
|
|
10604
|
-
this.logger.info("Vector store rebuild complete", { resourcesIndexed, annotationsIndexed, backfilled });
|
|
10605
|
-
}
|
|
10606
|
-
async processBatch(events) {
|
|
10607
|
-
const runs = partitionByType(events);
|
|
10608
|
-
for (const run of runs) {
|
|
10609
|
-
try {
|
|
10610
|
-
if (run.length === 1) {
|
|
10611
|
-
await this.safeProcessEvent(run[0]);
|
|
10612
|
-
} else {
|
|
10613
|
-
await this.applyBatchByType(run);
|
|
10614
|
-
}
|
|
10615
|
-
} catch (error) {
|
|
10616
|
-
this.logger.error("Smelter failed to process batch run", {
|
|
10617
|
-
eventType: run[0].type,
|
|
10618
|
-
runSize: run.length,
|
|
10619
|
-
error: errField2(error)
|
|
10620
|
-
});
|
|
10621
|
-
}
|
|
10622
|
-
}
|
|
10623
|
-
}
|
|
10624
|
-
/**
|
|
10625
|
-
* Batch-optimized processing for consecutive events of the same type.
|
|
10626
|
-
*/
|
|
10627
|
-
async applyBatchByType(events) {
|
|
10628
|
-
const type = events[0].type;
|
|
10629
|
-
switch (type) {
|
|
10630
|
-
case "yield:created":
|
|
10631
|
-
await this.batchResourceCreated(events);
|
|
10632
|
-
break;
|
|
10633
|
-
case "mark:added":
|
|
10634
|
-
await this.batchAnnotationAdded(events);
|
|
10635
|
-
break;
|
|
10636
|
-
default:
|
|
10637
|
-
for (const event of events) {
|
|
10638
|
-
await this.safeProcessEvent(event);
|
|
10639
|
-
}
|
|
10640
|
-
}
|
|
10641
|
-
}
|
|
10642
|
-
/**
|
|
10643
|
-
* Batch-embed chunks from multiple yield:created events in a single
|
|
10644
|
-
* embedBatch() call, then write to EmbeddingStore and index per resource.
|
|
10645
|
-
*/
|
|
10646
|
-
async batchResourceCreated(events) {
|
|
10647
|
-
const resourceData = [];
|
|
10648
|
-
const allChunks = [];
|
|
10649
|
-
for (const storedEvent of events) {
|
|
10650
|
-
const event = storedEvent;
|
|
10651
|
-
const rid = makeResourceId2(event.resourceId);
|
|
10652
|
-
const storageUri = event.payload.storageUri;
|
|
10653
|
-
if (!storageUri) continue;
|
|
10654
|
-
const content = await this.contentStore.retrieve(storageUri);
|
|
10655
|
-
if (!content) continue;
|
|
10656
|
-
const text = new TextDecoder().decode(content);
|
|
10657
|
-
if (!text.trim()) continue;
|
|
10658
|
-
const chunks = chunkText(text, this.chunkingConfig);
|
|
10659
|
-
if (chunks.length === 0) continue;
|
|
10660
|
-
resourceData.push({ rid, chunks });
|
|
10661
|
-
allChunks.push(...chunks);
|
|
10662
|
-
}
|
|
10663
|
-
if (allChunks.length === 0) return;
|
|
10664
|
-
const allEmbeddings = await this.embeddingProvider.embedBatch(allChunks);
|
|
10665
|
-
const model = this.embeddingProvider.model();
|
|
10666
|
-
const dimensions = this.embeddingProvider.dimensions();
|
|
10667
|
-
let offset = 0;
|
|
10668
|
-
for (const { rid, chunks } of resourceData) {
|
|
10669
|
-
const embeddingChunks = chunks.map((text, i) => ({
|
|
10670
|
-
chunkIndex: i,
|
|
10671
|
-
text,
|
|
10672
|
-
embedding: allEmbeddings[offset + i]
|
|
10673
|
-
}));
|
|
10674
|
-
await this.embeddingStore.writeResourceChunks(rid, model, dimensions, embeddingChunks);
|
|
10675
|
-
await this.vectorStore.upsertResourceVectors(rid, embeddingChunks);
|
|
10676
|
-
this.logger.debug("Smelter batch-indexed resource", {
|
|
10677
|
-
resourceId: String(rid),
|
|
10678
|
-
chunks: embeddingChunks.length
|
|
10679
|
-
});
|
|
10680
|
-
offset += chunks.length;
|
|
10681
|
-
}
|
|
10682
|
-
}
|
|
10683
|
-
/**
|
|
10684
|
-
* Batch-embed exact texts from multiple mark:added events in a single
|
|
10685
|
-
* embedBatch() call, then write to EmbeddingStore and index per annotation.
|
|
10686
|
-
*/
|
|
10687
|
-
async batchAnnotationAdded(events) {
|
|
10688
|
-
const annotationData = [];
|
|
10689
|
-
for (const storedEvent of events) {
|
|
10690
|
-
const event = storedEvent;
|
|
10691
|
-
const annotation = event.payload.annotation;
|
|
10692
|
-
if (!annotation?.id) continue;
|
|
10693
|
-
const selector = getTargetSelector(annotation.target);
|
|
10694
|
-
const exactText = getExactText(selector);
|
|
10695
|
-
if (!exactText?.trim()) continue;
|
|
10696
|
-
annotationData.push({
|
|
10697
|
-
rid: makeResourceId2(event.resourceId),
|
|
10698
|
-
aid: makeAnnotationId2(annotation.id),
|
|
10699
|
-
exactText,
|
|
10700
|
-
motivation: annotation.motivation ?? "",
|
|
10701
|
-
entityTypes: annotation.entityTypes ?? []
|
|
10702
|
-
});
|
|
10703
|
-
}
|
|
10704
|
-
if (annotationData.length === 0) return;
|
|
10705
|
-
const allEmbeddings = await this.embeddingProvider.embedBatch(
|
|
10706
|
-
annotationData.map((a) => a.exactText)
|
|
10707
|
-
);
|
|
10708
|
-
const model = this.embeddingProvider.model();
|
|
10709
|
-
const dimensions = this.embeddingProvider.dimensions();
|
|
10710
|
-
for (let i = 0; i < annotationData.length; i++) {
|
|
10711
|
-
const { rid, aid, exactText, motivation, entityTypes } = annotationData[i];
|
|
10712
|
-
const embedding = allEmbeddings[i];
|
|
10713
|
-
await this.embeddingStore.writeAnnotationEmbedding(
|
|
10714
|
-
aid,
|
|
10715
|
-
rid,
|
|
10716
|
-
model,
|
|
10717
|
-
dimensions,
|
|
10718
|
-
exactText,
|
|
10719
|
-
embedding,
|
|
10720
|
-
motivation,
|
|
10721
|
-
entityTypes
|
|
10722
|
-
);
|
|
10723
|
-
const payload = {
|
|
10724
|
-
annotationId: aid,
|
|
10725
|
-
resourceId: rid,
|
|
10726
|
-
motivation,
|
|
10727
|
-
entityTypes,
|
|
10728
|
-
exactText
|
|
10729
|
-
};
|
|
10730
|
-
await this.vectorStore.upsertAnnotationVector(aid, embedding, payload);
|
|
10731
|
-
this.logger.debug("Smelter batch-indexed annotation", {
|
|
10732
|
-
annotationId: String(aid),
|
|
10733
|
-
resourceId: String(rid)
|
|
10734
|
-
});
|
|
10735
|
-
}
|
|
10736
|
-
}
|
|
10737
|
-
async safeProcessEvent(storedEvent) {
|
|
10738
|
-
try {
|
|
10739
|
-
await this.processEvent(storedEvent);
|
|
10740
|
-
} catch (err) {
|
|
10741
|
-
this.logger.error("Smelter failed to process event", {
|
|
10742
|
-
type: storedEvent.type,
|
|
10743
|
-
resourceId: storedEvent.resourceId,
|
|
10744
|
-
error: err instanceof Error ? err.message : String(err),
|
|
10745
|
-
stack: err instanceof Error ? err.stack : void 0
|
|
10746
|
-
});
|
|
10747
|
-
}
|
|
10748
|
-
}
|
|
10749
|
-
async processEvent(storedEvent) {
|
|
10750
|
-
switch (storedEvent.type) {
|
|
10751
|
-
case "yield:created":
|
|
10752
|
-
await this.handleResourceCreated(storedEvent);
|
|
10753
|
-
break;
|
|
10754
|
-
case "yield:updated":
|
|
10755
|
-
await this.handleResourceUpdated(storedEvent);
|
|
10756
|
-
break;
|
|
10757
|
-
case "yield:representation-added":
|
|
10758
|
-
await this.handleRepresentationAdded(storedEvent);
|
|
10759
|
-
break;
|
|
10760
|
-
case "mark:archived":
|
|
10761
|
-
await this.handleResourceArchived(storedEvent);
|
|
10762
|
-
break;
|
|
10763
|
-
case "mark:added":
|
|
10764
|
-
await this.handleAnnotationAdded(storedEvent);
|
|
10765
|
-
break;
|
|
10766
|
-
case "mark:removed":
|
|
10767
|
-
await this.handleAnnotationRemoved(storedEvent);
|
|
10768
|
-
break;
|
|
10769
|
-
}
|
|
10770
|
-
}
|
|
10771
|
-
async handleResourceCreated(event) {
|
|
10772
|
-
await new Promise((resolve2) => setTimeout(resolve2, 0));
|
|
10773
|
-
const rid = makeResourceId2(event.resourceId);
|
|
10774
|
-
const storageUri = event.payload.storageUri;
|
|
10775
|
-
if (!storageUri) return;
|
|
10776
|
-
this.logger.info("Smelter handleResourceCreated start", {
|
|
10777
|
-
resourceId: String(rid),
|
|
10778
|
-
storageUri,
|
|
10779
|
-
heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
|
|
10780
|
-
});
|
|
10781
|
-
const content = await this.contentStore.retrieve(storageUri);
|
|
10782
|
-
if (!content) return;
|
|
10783
|
-
const text = new TextDecoder().decode(content);
|
|
10784
|
-
if (!text.trim()) return;
|
|
10785
|
-
const chunks = chunkText(text, this.chunkingConfig);
|
|
10786
|
-
if (chunks.length === 0) return;
|
|
10787
|
-
this.logger.info("Smelter chunked resource", {
|
|
10788
|
-
resourceId: String(rid),
|
|
10789
|
-
textBytes: text.length,
|
|
10790
|
-
chunkCount: chunks.length,
|
|
10791
|
-
heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
|
|
10792
|
-
});
|
|
10793
|
-
const embeddings = await this.embeddingProvider.embedBatch(chunks);
|
|
10794
|
-
const model = this.embeddingProvider.model();
|
|
10795
|
-
const dimensions = this.embeddingProvider.dimensions();
|
|
10796
|
-
this.logger.info("Smelter embedded resource", {
|
|
10797
|
-
resourceId: String(rid),
|
|
10798
|
-
chunkCount: chunks.length,
|
|
10799
|
-
dimensions,
|
|
10800
|
-
heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
|
|
10801
|
-
});
|
|
10802
|
-
const embeddingChunks = chunks.map((text2, i) => ({
|
|
10803
|
-
chunkIndex: i,
|
|
10804
|
-
text: text2,
|
|
10805
|
-
embedding: embeddings[i]
|
|
10806
|
-
}));
|
|
10807
|
-
await this.embeddingStore.writeResourceChunks(rid, model, dimensions, embeddingChunks);
|
|
10808
|
-
this.logger.info("Smelter wrote resource embeddings to store", {
|
|
10809
|
-
resourceId: String(rid),
|
|
10810
|
-
chunkCount: embeddingChunks.length,
|
|
10811
|
-
heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
|
|
10812
|
-
});
|
|
10813
|
-
await this.vectorStore.upsertResourceVectors(rid, embeddingChunks);
|
|
10814
|
-
this.logger.info("Smelter indexed resource", {
|
|
10815
|
-
resourceId: String(rid),
|
|
10816
|
-
chunks: embeddingChunks.length,
|
|
10817
|
-
heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
|
|
10818
|
-
});
|
|
10819
|
-
}
|
|
10820
|
-
/**
|
|
10821
|
-
* Re-embed a resource whose content has changed in-place.
|
|
10822
|
-
*
|
|
10823
|
-
* Used by yield:updated and yield:representation-added handlers. Reads the
|
|
10824
|
-
* current storageUri from the materialized view (which is updated before the
|
|
10825
|
-
* EventBus fires), deletes stale Qdrant vectors, and overwrites the
|
|
10826
|
-
* EmbeddingStore file with fresh chunks.
|
|
10827
|
-
*/
|
|
10828
|
-
async reembedResource(rid) {
|
|
10829
|
-
const view = await this.viewStorage.get(rid);
|
|
10830
|
-
const storageUri = view?.resource.storageUri;
|
|
10831
|
-
if (!storageUri) return;
|
|
10832
|
-
const content = await this.contentStore.retrieve(storageUri);
|
|
10833
|
-
if (!content) return;
|
|
10834
|
-
const text = new TextDecoder().decode(content);
|
|
10835
|
-
if (!text.trim()) return;
|
|
10836
|
-
const chunks = chunkText(text, this.chunkingConfig);
|
|
10837
|
-
if (chunks.length === 0) return;
|
|
10838
|
-
const embeddings = await this.embeddingProvider.embedBatch(chunks);
|
|
10839
|
-
const model = this.embeddingProvider.model();
|
|
10840
|
-
const dimensions = this.embeddingProvider.dimensions();
|
|
10841
|
-
const embeddingChunks = chunks.map((chunkText2, i) => ({
|
|
10842
|
-
chunkIndex: i,
|
|
10843
|
-
text: chunkText2,
|
|
10844
|
-
embedding: embeddings[i]
|
|
10845
|
-
}));
|
|
10846
|
-
await this.embeddingStore.writeResourceChunks(rid, model, dimensions, embeddingChunks);
|
|
10847
|
-
await this.vectorStore.deleteResourceVectors(rid);
|
|
10848
|
-
await this.vectorStore.upsertResourceVectors(rid, embeddingChunks);
|
|
10849
|
-
this.logger.debug("Smelter re-embedded resource", {
|
|
10850
|
-
resourceId: String(rid),
|
|
10851
|
-
chunks: embeddingChunks.length
|
|
10852
|
-
});
|
|
10853
|
-
}
|
|
10854
|
-
async handleResourceUpdated(event) {
|
|
10855
|
-
await this.reembedResource(makeResourceId2(event.resourceId));
|
|
10856
|
-
}
|
|
10857
|
-
async handleRepresentationAdded(event) {
|
|
10858
|
-
await this.reembedResource(makeResourceId2(event.resourceId));
|
|
10859
|
-
}
|
|
10860
|
-
async handleResourceArchived(event) {
|
|
10861
|
-
const rid = makeResourceId2(event.resourceId);
|
|
10862
|
-
await this.vectorStore.deleteResourceVectors(rid);
|
|
10863
|
-
await this.embeddingStore.deleteResourceEmbeddings(rid);
|
|
10864
|
-
this.logger.debug("Smelter deleted resource vectors", { resourceId: String(rid) });
|
|
10865
|
-
}
|
|
10866
|
-
async handleAnnotationAdded(event) {
|
|
10867
|
-
await new Promise((resolve2) => setTimeout(resolve2, 0));
|
|
10868
|
-
const annotation = event.payload.annotation;
|
|
10869
|
-
if (!annotation || !annotation.id) return;
|
|
10870
|
-
const rid = makeResourceId2(event.resourceId);
|
|
10871
|
-
const aid = makeAnnotationId2(annotation.id);
|
|
10872
|
-
const selector = getTargetSelector(annotation.target);
|
|
10873
|
-
const exactText = getExactText(selector);
|
|
10874
|
-
if (!exactText || !exactText.trim()) return;
|
|
10875
|
-
this.logger.info("Smelter handleAnnotationAdded start", {
|
|
10876
|
-
annotationId: String(aid),
|
|
10877
|
-
resourceId: String(rid),
|
|
10878
|
-
textLength: exactText.length,
|
|
10879
|
-
heapMB: Math.round(process.memoryUsage().heapUsed / 1024 / 1024)
|
|
10880
|
-
});
|
|
10881
|
-
const embedding = await this.embeddingProvider.embed(exactText);
|
|
10882
|
-
const model = this.embeddingProvider.model();
|
|
10883
|
-
const dimensions = this.embeddingProvider.dimensions();
|
|
10884
|
-
const motivation = annotation.motivation ?? "";
|
|
10885
|
-
const entityTypes = annotation.entityTypes ?? [];
|
|
10886
|
-
await this.embeddingStore.writeAnnotationEmbedding(
|
|
10887
|
-
aid,
|
|
10888
|
-
rid,
|
|
10889
|
-
model,
|
|
10890
|
-
dimensions,
|
|
10891
|
-
exactText,
|
|
10892
|
-
embedding,
|
|
10893
|
-
motivation,
|
|
10894
|
-
entityTypes
|
|
10895
|
-
);
|
|
10896
|
-
const payload = {
|
|
10897
|
-
annotationId: aid,
|
|
10898
|
-
resourceId: rid,
|
|
10899
|
-
motivation,
|
|
10900
|
-
entityTypes,
|
|
10901
|
-
exactText
|
|
10902
|
-
};
|
|
10903
|
-
await this.vectorStore.upsertAnnotationVector(aid, embedding, payload);
|
|
10904
|
-
this.logger.info("Smelter indexed annotation", {
|
|
10905
|
-
annotationId: String(aid),
|
|
10906
|
-
resourceId: String(rid)
|
|
10907
|
-
});
|
|
10908
|
-
}
|
|
10909
|
-
async handleAnnotationRemoved(event) {
|
|
10910
|
-
const annotationId3 = String(event.payload.annotationId);
|
|
10911
|
-
if (!annotationId3) return;
|
|
10912
|
-
const aid = makeAnnotationId2(annotationId3);
|
|
10913
|
-
await this.vectorStore.deleteAnnotationVector(aid);
|
|
10914
|
-
await this.embeddingStore.deleteAnnotationEmbedding(aid);
|
|
10915
|
-
this.logger.debug("Smelter deleted annotation vector", { annotationId: String(aid) });
|
|
10916
|
-
}
|
|
10917
|
-
};
|
|
10918
|
-
|
|
10919
|
-
// src/embedding-store.ts
|
|
10920
|
-
import { promises as fs } from "fs";
|
|
10921
|
-
import * as path from "path";
|
|
10922
|
-
import { getShardPath } from "@semiont/event-sourcing";
|
|
10923
|
-
var EmbeddingStore = class {
|
|
10924
|
-
constructor(project) {
|
|
10925
|
-
this.project = project;
|
|
10926
|
-
}
|
|
10927
|
-
// ── Path helpers ────────────────────────────────────────────────────────────
|
|
10928
|
-
resourceFilePath(resourceId7) {
|
|
10929
|
-
const [ab, cd] = getShardPath(String(resourceId7));
|
|
10930
|
-
return path.join(this.project.embeddingsDir, ab, cd, `${String(resourceId7)}.jsonl`);
|
|
10931
|
-
}
|
|
10932
|
-
annotationFilePath(annotationId3) {
|
|
10933
|
-
const [ab, cd] = getShardPath(String(annotationId3));
|
|
10934
|
-
return path.join(this.project.embeddingsDir, ab, cd, `${String(annotationId3)}.json`);
|
|
10935
|
-
}
|
|
10936
|
-
// ── Resource embeddings ─────────────────────────────────────────────────────
|
|
10937
|
-
async writeResourceChunks(resourceId7, model, dimensions, chunks) {
|
|
10938
|
-
const filePath = this.resourceFilePath(resourceId7);
|
|
10939
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
10940
|
-
const header = JSON.stringify({ model, dimensions });
|
|
10941
|
-
const lines = chunks.map(
|
|
10942
|
-
(c) => JSON.stringify({ chunkIndex: c.chunkIndex, text: c.text, embedding: c.embedding })
|
|
10943
|
-
);
|
|
10944
|
-
await fs.writeFile(filePath, [header, ...lines].join("\n") + "\n", "utf-8");
|
|
10945
|
-
}
|
|
10946
|
-
async readResourceEmbeddings(resourceId7) {
|
|
10947
|
-
const filePath = this.resourceFilePath(resourceId7);
|
|
10948
|
-
try {
|
|
10949
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
10950
|
-
const lines = content.trim().split("\n").filter((l) => l.trim());
|
|
10951
|
-
if (lines.length === 0) return null;
|
|
10952
|
-
const header = JSON.parse(lines[0]);
|
|
10953
|
-
const chunks = lines.slice(1).map((l) => JSON.parse(l));
|
|
10954
|
-
return { model: header.model, dimensions: header.dimensions, chunks };
|
|
10955
|
-
} catch (err) {
|
|
10956
|
-
if (err.code === "ENOENT") return null;
|
|
10957
|
-
throw err;
|
|
10958
|
-
}
|
|
10959
|
-
}
|
|
10960
|
-
async deleteResourceEmbeddings(resourceId7) {
|
|
10961
|
-
const filePath = this.resourceFilePath(resourceId7);
|
|
10962
|
-
try {
|
|
10963
|
-
await fs.unlink(filePath);
|
|
10964
|
-
} catch (err) {
|
|
10965
|
-
if (err.code !== "ENOENT") throw err;
|
|
10966
|
-
}
|
|
10967
|
-
}
|
|
10968
|
-
// ── Annotation embeddings ───────────────────────────────────────────────────
|
|
10969
|
-
async writeAnnotationEmbedding(annotationId3, resourceId7, model, dimensions, text, embedding, motivation, entityTypes) {
|
|
10970
|
-
const filePath = this.annotationFilePath(annotationId3);
|
|
10971
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
10972
|
-
const data = {
|
|
10973
|
-
model,
|
|
10974
|
-
dimensions,
|
|
10975
|
-
resourceId: String(resourceId7),
|
|
10976
|
-
text,
|
|
10977
|
-
embedding,
|
|
10978
|
-
motivation,
|
|
10979
|
-
entityTypes
|
|
10980
|
-
};
|
|
10981
|
-
await fs.writeFile(filePath, JSON.stringify(data), "utf-8");
|
|
10982
|
-
}
|
|
10983
|
-
async readAnnotationEmbedding(annotationId3) {
|
|
10984
|
-
const filePath = this.annotationFilePath(annotationId3);
|
|
10985
|
-
try {
|
|
10986
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
10987
|
-
return JSON.parse(content);
|
|
10988
|
-
} catch (err) {
|
|
10989
|
-
if (err.code === "ENOENT") return null;
|
|
10990
|
-
throw err;
|
|
10991
|
-
}
|
|
10992
|
-
}
|
|
10993
|
-
async deleteAnnotationEmbedding(annotationId3) {
|
|
10994
|
-
const filePath = this.annotationFilePath(annotationId3);
|
|
10995
|
-
try {
|
|
10996
|
-
await fs.unlink(filePath);
|
|
10997
|
-
} catch (err) {
|
|
10998
|
-
if (err.code !== "ENOENT") throw err;
|
|
10999
|
-
}
|
|
11000
|
-
}
|
|
11001
|
-
// ── Scan ────────────────────────────────────────────────────────────────────
|
|
11002
|
-
/**
|
|
11003
|
-
* Scan embeddings directory and return all resource IDs (from *.jsonl files).
|
|
11004
|
-
*/
|
|
11005
|
-
async getAllResourceIds() {
|
|
11006
|
-
return this.scanIds((name) => name.endsWith(".jsonl"), ".jsonl");
|
|
11007
|
-
}
|
|
11008
|
-
/**
|
|
11009
|
-
* Scan embeddings directory and return all annotation IDs (from *.json files).
|
|
11010
|
-
*/
|
|
11011
|
-
async getAllAnnotationIds() {
|
|
11012
|
-
return this.scanIds((name) => name.endsWith(".json"), ".json");
|
|
11013
|
-
}
|
|
11014
|
-
async scanIds(filter, ext) {
|
|
11015
|
-
const base = this.project.embeddingsDir;
|
|
11016
|
-
try {
|
|
11017
|
-
await fs.access(base);
|
|
11018
|
-
} catch {
|
|
11019
|
-
return [];
|
|
11020
|
-
}
|
|
11021
|
-
const results = [];
|
|
11022
|
-
const scan = async (dir) => {
|
|
11023
|
-
let entries;
|
|
11024
|
-
try {
|
|
11025
|
-
entries = await fs.readdir(dir, { withFileTypes: true });
|
|
11026
|
-
} catch {
|
|
11027
|
-
return;
|
|
11028
|
-
}
|
|
11029
|
-
for (const entry of entries) {
|
|
11030
|
-
const full = path.join(dir, entry.name);
|
|
11031
|
-
if (entry.isDirectory()) {
|
|
11032
|
-
await scan(full);
|
|
11033
|
-
} else if (filter(entry.name)) {
|
|
11034
|
-
results.push(entry.name.slice(0, -ext.length));
|
|
11035
|
-
}
|
|
11036
|
-
}
|
|
11037
|
-
};
|
|
11038
|
-
await scan(base);
|
|
11039
|
-
return results;
|
|
11040
|
-
}
|
|
11041
|
-
};
|
|
11042
|
-
|
|
11043
10387
|
// src/knowledge-base.ts
|
|
11044
10388
|
async function createKnowledgeBase(eventStore, project, graphDb, eventBus, logger, options) {
|
|
11045
|
-
const views = new FilesystemViewStorage(project);
|
|
10389
|
+
const views = new FilesystemViewStorage(project, logger.child({ component: "view-storage" }));
|
|
11046
10390
|
const content = new WorkingTreeStore(
|
|
11047
10391
|
project,
|
|
11048
10392
|
logger.child({ component: "working-tree-store" })
|
|
@@ -11066,32 +10410,16 @@ async function createKnowledgeBase(eventStore, project, graphDb, eventBus, logge
|
|
|
11066
10410
|
graphConsumer,
|
|
11067
10411
|
projectionsDir: project.projectionsDir
|
|
11068
10412
|
};
|
|
11069
|
-
if (options?.vectorStore
|
|
10413
|
+
if (options?.vectorStore) {
|
|
11070
10414
|
kb.vectors = options.vectorStore;
|
|
11071
|
-
const embeddingStore = new EmbeddingStore(project);
|
|
11072
|
-
kb.smelter = new Smelter(
|
|
11073
|
-
eventStore,
|
|
11074
|
-
eventBus,
|
|
11075
|
-
options.vectorStore,
|
|
11076
|
-
options.embeddingProvider,
|
|
11077
|
-
content,
|
|
11078
|
-
embeddingStore,
|
|
11079
|
-
views,
|
|
11080
|
-
logger.child({ component: "smelter" }),
|
|
11081
|
-
options.chunkingConfig
|
|
11082
|
-
);
|
|
11083
|
-
await kb.smelter.initialize();
|
|
11084
|
-
if (!options.skipRebuild) {
|
|
11085
|
-
await kb.smelter.rebuildAll();
|
|
11086
|
-
}
|
|
11087
10415
|
}
|
|
11088
10416
|
return kb;
|
|
11089
10417
|
}
|
|
11090
10418
|
|
|
11091
10419
|
// src/gatherer.ts
|
|
11092
|
-
var
|
|
11093
|
-
var
|
|
11094
|
-
import { annotationId as
|
|
10420
|
+
var import_rxjs2 = __toESM(require_cjs(), 1);
|
|
10421
|
+
var import_operators2 = __toESM(require_operators(), 1);
|
|
10422
|
+
import { annotationId as makeAnnotationId2, resourceId, errField as errField2 } from "@semiont/core";
|
|
11095
10423
|
|
|
11096
10424
|
// src/generation/resource-generation.ts
|
|
11097
10425
|
async function generateResourceSummary(resourceName, content, entityTypes, client) {
|
|
@@ -11121,7 +10449,7 @@ import {
|
|
|
11121
10449
|
getBodySource,
|
|
11122
10450
|
getResourceId,
|
|
11123
10451
|
getTargetSource,
|
|
11124
|
-
getTargetSelector
|
|
10452
|
+
getTargetSelector,
|
|
11125
10453
|
getResourceEntityTypes,
|
|
11126
10454
|
getTextPositionSelector,
|
|
11127
10455
|
getPrimaryRepresentation as getPrimaryRepresentation2,
|
|
@@ -11279,7 +10607,7 @@ var AnnotationContext = class {
|
|
|
11279
10607
|
const primaryRep = getPrimaryRepresentation2(sourceDoc);
|
|
11280
10608
|
const sourceContent = await kb.content.retrieve(sourceDoc.storageUri);
|
|
11281
10609
|
const contentStr = decodeRepresentation2(sourceContent, primaryRep?.mediaType ?? "text/plain");
|
|
11282
|
-
const targetSelectorRaw =
|
|
10610
|
+
const targetSelectorRaw = getTargetSelector(annotation.target);
|
|
11283
10611
|
const targetSelector = Array.isArray(targetSelectorRaw) ? targetSelectorRaw[0] : targetSelectorRaw;
|
|
11284
10612
|
logger?.debug("Target selector", { type: targetSelector?.type });
|
|
11285
10613
|
if (!targetSelector) {
|
|
@@ -11656,7 +10984,7 @@ Summary:`;
|
|
|
11656
10984
|
* Extract annotation context from resource content
|
|
11657
10985
|
*/
|
|
11658
10986
|
static extractAnnotationContext(annotation, contentStr, contextBefore, contextAfter) {
|
|
11659
|
-
const targetSelector =
|
|
10987
|
+
const targetSelector = getTargetSelector(annotation.target);
|
|
11660
10988
|
const posSelector = targetSelector ? getTextPositionSelector(targetSelector) : null;
|
|
11661
10989
|
if (!posSelector) {
|
|
11662
10990
|
throw new Error("TextPositionSelector required for context");
|
|
@@ -11756,7 +11084,7 @@ var GraphContext = class {
|
|
|
11756
11084
|
|
|
11757
11085
|
// src/llm-context.ts
|
|
11758
11086
|
import { getResourceEntityTypes as getResourceEntityTypes3, getResourceId as getResourceId3 } from "@semiont/api-client";
|
|
11759
|
-
import { resourceId as
|
|
11087
|
+
import { resourceId as makeResourceId2 } from "@semiont/core";
|
|
11760
11088
|
var LLMContext = class {
|
|
11761
11089
|
/**
|
|
11762
11090
|
* Get comprehensive LLM context for a resource
|
|
@@ -11777,7 +11105,7 @@ var LLMContext = class {
|
|
|
11777
11105
|
const resourceIdStr = resourceId7.toString();
|
|
11778
11106
|
for (const node of graph.nodes) {
|
|
11779
11107
|
if (node.id !== resourceIdStr) {
|
|
11780
|
-
const relatedDoc = await ResourceContext.getResourceMetadata(
|
|
11108
|
+
const relatedDoc = await ResourceContext.getResourceMetadata(makeResourceId2(node.id), kb);
|
|
11781
11109
|
if (relatedDoc) {
|
|
11782
11110
|
relatedDocs.push(relatedDoc);
|
|
11783
11111
|
}
|
|
@@ -11832,18 +11160,18 @@ var Gatherer = class {
|
|
|
11832
11160
|
this.logger.info("Gatherer actor initialized");
|
|
11833
11161
|
const errorHandler = (err) => this.logger.error("Gatherer pipeline error", { error: err });
|
|
11834
11162
|
const annotationGather$ = this.eventBus.get("gather:requested").pipe(
|
|
11835
|
-
(0,
|
|
11836
|
-
(0,
|
|
11163
|
+
(0, import_operators2.groupBy)((event) => event.resourceId),
|
|
11164
|
+
(0, import_operators2.mergeMap)(
|
|
11837
11165
|
(group$) => group$.pipe(
|
|
11838
|
-
(0,
|
|
11166
|
+
(0, import_operators2.concatMap)((event) => (0, import_rxjs2.from)(this.handleAnnotationGather(event)))
|
|
11839
11167
|
)
|
|
11840
11168
|
)
|
|
11841
11169
|
);
|
|
11842
11170
|
const resourceGather$ = this.eventBus.get("gather:resource-requested").pipe(
|
|
11843
|
-
(0,
|
|
11844
|
-
(0,
|
|
11171
|
+
(0, import_operators2.groupBy)((event) => event.resourceId),
|
|
11172
|
+
(0, import_operators2.mergeMap)(
|
|
11845
11173
|
(group$) => group$.pipe(
|
|
11846
|
-
(0,
|
|
11174
|
+
(0, import_operators2.concatMap)((event) => (0, import_rxjs2.from)(this.handleResourceGather(event)))
|
|
11847
11175
|
)
|
|
11848
11176
|
)
|
|
11849
11177
|
);
|
|
@@ -11856,14 +11184,13 @@ var Gatherer = class {
|
|
|
11856
11184
|
// Gather handlers (existing)
|
|
11857
11185
|
// ========================================================================
|
|
11858
11186
|
async handleAnnotationGather(event) {
|
|
11859
|
-
const resultBus = this.eventBus.scope(event.resourceId);
|
|
11860
11187
|
try {
|
|
11861
11188
|
this.logger.debug("Gathering annotation context", {
|
|
11862
11189
|
annotationId: event.annotationId,
|
|
11863
11190
|
resourceId: event.resourceId
|
|
11864
11191
|
});
|
|
11865
11192
|
const response = await AnnotationContext.buildLLMContext(
|
|
11866
|
-
|
|
11193
|
+
makeAnnotationId2(event.annotationId),
|
|
11867
11194
|
resourceId(event.resourceId),
|
|
11868
11195
|
this.kb,
|
|
11869
11196
|
event.options ?? {},
|
|
@@ -11871,7 +11198,7 @@ var Gatherer = class {
|
|
|
11871
11198
|
this.logger,
|
|
11872
11199
|
this.embeddingProvider
|
|
11873
11200
|
);
|
|
11874
|
-
|
|
11201
|
+
this.eventBus.get("gather:complete").next({
|
|
11875
11202
|
correlationId: event.correlationId,
|
|
11876
11203
|
annotationId: event.annotationId,
|
|
11877
11204
|
response
|
|
@@ -11879,9 +11206,9 @@ var Gatherer = class {
|
|
|
11879
11206
|
} catch (error) {
|
|
11880
11207
|
this.logger.error("Gather annotation context failed", {
|
|
11881
11208
|
annotationId: event.annotationId,
|
|
11882
|
-
error:
|
|
11209
|
+
error: errField2(error)
|
|
11883
11210
|
});
|
|
11884
|
-
|
|
11211
|
+
this.eventBus.get("gather:failed").next({
|
|
11885
11212
|
correlationId: event.correlationId,
|
|
11886
11213
|
annotationId: event.annotationId,
|
|
11887
11214
|
message: error instanceof Error ? error.message : String(error)
|
|
@@ -11889,7 +11216,6 @@ var Gatherer = class {
|
|
|
11889
11216
|
}
|
|
11890
11217
|
}
|
|
11891
11218
|
async handleResourceGather(event) {
|
|
11892
|
-
const resultBus = this.eventBus.scope(event.resourceId);
|
|
11893
11219
|
try {
|
|
11894
11220
|
this.logger.debug("Gathering resource context", {
|
|
11895
11221
|
resourceId: event.resourceId
|
|
@@ -11900,7 +11226,7 @@ var Gatherer = class {
|
|
|
11900
11226
|
this.kb,
|
|
11901
11227
|
this.inferenceClient
|
|
11902
11228
|
);
|
|
11903
|
-
|
|
11229
|
+
this.eventBus.get("gather:resource-complete").next({
|
|
11904
11230
|
correlationId: event.correlationId,
|
|
11905
11231
|
resourceId: event.resourceId,
|
|
11906
11232
|
response: result
|
|
@@ -11908,9 +11234,9 @@ var Gatherer = class {
|
|
|
11908
11234
|
} catch (error) {
|
|
11909
11235
|
this.logger.error("Gather resource context failed", {
|
|
11910
11236
|
resourceId: event.resourceId,
|
|
11911
|
-
error:
|
|
11237
|
+
error: errField2(error)
|
|
11912
11238
|
});
|
|
11913
|
-
|
|
11239
|
+
this.eventBus.get("gather:resource-failed").next({
|
|
11914
11240
|
correlationId: event.correlationId,
|
|
11915
11241
|
resourceId: event.resourceId,
|
|
11916
11242
|
message: error instanceof Error ? error.message : String(error)
|
|
@@ -11935,9 +11261,9 @@ var Gatherer = class {
|
|
|
11935
11261
|
};
|
|
11936
11262
|
|
|
11937
11263
|
// src/matcher.ts
|
|
11938
|
-
var
|
|
11939
|
-
var
|
|
11940
|
-
import { resourceId as resourceId2, errField as
|
|
11264
|
+
var import_rxjs3 = __toESM(require_cjs(), 1);
|
|
11265
|
+
var import_operators3 = __toESM(require_operators(), 1);
|
|
11266
|
+
import { resourceId as resourceId2, errField as errField3 } from "@semiont/core";
|
|
11941
11267
|
import { getResourceId as getResourceId4, getResourceEntityTypes as getResourceEntityTypes4 } from "@semiont/api-client";
|
|
11942
11268
|
var Matcher = class {
|
|
11943
11269
|
constructor(kb, eventBus, logger, inferenceClient, embeddingProvider) {
|
|
@@ -11953,7 +11279,7 @@ var Matcher = class {
|
|
|
11953
11279
|
this.logger.info("Matcher actor initialized");
|
|
11954
11280
|
const errorHandler = (err) => this.logger.error("Matcher pipeline error", { error: err });
|
|
11955
11281
|
const search$ = this.eventBus.get("match:search-requested").pipe(
|
|
11956
|
-
(0,
|
|
11282
|
+
(0, import_operators3.concatMap)((event) => (0, import_rxjs3.from)(this.handleSearch(event)))
|
|
11957
11283
|
);
|
|
11958
11284
|
this.subscriptions.push(
|
|
11959
11285
|
search$.subscribe({ error: errorHandler })
|
|
@@ -11961,7 +11287,6 @@ var Matcher = class {
|
|
|
11961
11287
|
}
|
|
11962
11288
|
async handleSearch(event) {
|
|
11963
11289
|
try {
|
|
11964
|
-
const resultBus = this.eventBus.scope(event.resourceId);
|
|
11965
11290
|
const context = event.context;
|
|
11966
11291
|
const selectedText = context.sourceContext?.selected ?? "";
|
|
11967
11292
|
const userHint = context.userHint ?? "";
|
|
@@ -11978,7 +11303,7 @@ var Matcher = class {
|
|
|
11978
11303
|
event.useSemanticScoring
|
|
11979
11304
|
);
|
|
11980
11305
|
const limited = event.limit ? scored.slice(0, event.limit) : scored;
|
|
11981
|
-
|
|
11306
|
+
this.eventBus.get("match:search-results").next({
|
|
11982
11307
|
correlationId: event.correlationId,
|
|
11983
11308
|
referenceId: event.referenceId,
|
|
11984
11309
|
response: limited
|
|
@@ -11986,9 +11311,9 @@ var Matcher = class {
|
|
|
11986
11311
|
} catch (error) {
|
|
11987
11312
|
this.logger.error("Bind search failed", {
|
|
11988
11313
|
referenceId: event.referenceId,
|
|
11989
|
-
error:
|
|
11314
|
+
error: errField3(error)
|
|
11990
11315
|
});
|
|
11991
|
-
this.eventBus.
|
|
11316
|
+
this.eventBus.get("match:search-failed").next({
|
|
11992
11317
|
correlationId: event.correlationId,
|
|
11993
11318
|
referenceId: event.referenceId,
|
|
11994
11319
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -12254,10 +11579,10 @@ For each candidate, output a line with the number and score, like:
|
|
|
12254
11579
|
};
|
|
12255
11580
|
|
|
12256
11581
|
// src/stower.ts
|
|
12257
|
-
var
|
|
12258
|
-
var
|
|
12259
|
-
import { promises as
|
|
12260
|
-
import {
|
|
11582
|
+
var import_rxjs4 = __toESM(require_cjs(), 1);
|
|
11583
|
+
var import_operators4 = __toESM(require_operators(), 1);
|
|
11584
|
+
import { promises as fs } from "fs";
|
|
11585
|
+
import { errField as errField4, resourceId as resourceId3, userId as makeUserId, CREATION_METHODS, generateUuid } from "@semiont/core";
|
|
12261
11586
|
import { resolveStorageUri } from "@semiont/event-sourcing";
|
|
12262
11587
|
var Stower = class {
|
|
12263
11588
|
constructor(kb, eventBus, logger) {
|
|
@@ -12269,8 +11594,8 @@ var Stower = class {
|
|
|
12269
11594
|
logger;
|
|
12270
11595
|
async initialize() {
|
|
12271
11596
|
this.logger.info("Stower actor initialized");
|
|
12272
|
-
const pipe = (event, handler) => this.eventBus.get(event).pipe((0,
|
|
12273
|
-
this.subscription = (0,
|
|
11597
|
+
const pipe = (event, handler) => this.eventBus.get(event).pipe((0, import_operators4.concatMap)((e) => (0, import_rxjs4.from)(handler(e))));
|
|
11598
|
+
this.subscription = (0, import_rxjs4.merge)(
|
|
12274
11599
|
pipe("yield:create", (e) => this.handleYieldCreate(e)),
|
|
12275
11600
|
pipe("yield:update", (e) => this.handleYieldUpdate(e)),
|
|
12276
11601
|
pipe("yield:mv", (e) => this.handleYieldMv(e)),
|
|
@@ -12282,7 +11607,6 @@ var Stower = class {
|
|
|
12282
11607
|
pipe("mark:unarchive", (e) => this.handleMarkUnarchive(e)),
|
|
12283
11608
|
pipe("mark:update-entity-types", (e) => this.handleUpdateEntityTypes(e)),
|
|
12284
11609
|
pipe("job:start", (e) => this.handleJobStart(e)),
|
|
12285
|
-
pipe("job:report-progress", (e) => this.handleJobReportProgress(e)),
|
|
12286
11610
|
pipe("job:complete", (e) => this.handleJobComplete(e)),
|
|
12287
11611
|
pipe("job:fail", (e) => this.handleJobFail(e))
|
|
12288
11612
|
).subscribe({
|
|
@@ -12342,8 +11666,30 @@ var Stower = class {
|
|
|
12342
11666
|
]
|
|
12343
11667
|
};
|
|
12344
11668
|
this.eventBus.get("yield:create-ok").next({ resourceId: rId, resource });
|
|
11669
|
+
if (generatedFrom) {
|
|
11670
|
+
this.eventBus.get("mark:update-body").next({
|
|
11671
|
+
annotationId: generatedFrom.annotationId,
|
|
11672
|
+
userId: event.userId,
|
|
11673
|
+
resourceId: generatedFrom.resourceId,
|
|
11674
|
+
operations: [
|
|
11675
|
+
{
|
|
11676
|
+
op: "add",
|
|
11677
|
+
item: {
|
|
11678
|
+
type: "SpecificResource",
|
|
11679
|
+
source: rId,
|
|
11680
|
+
purpose: "linking"
|
|
11681
|
+
}
|
|
11682
|
+
}
|
|
11683
|
+
]
|
|
11684
|
+
});
|
|
11685
|
+
this.logger.info("Auto-bound generated resource to source reference", {
|
|
11686
|
+
resourceId: rId,
|
|
11687
|
+
sourceAnnotationId: generatedFrom.annotationId,
|
|
11688
|
+
sourceResourceId: generatedFrom.resourceId
|
|
11689
|
+
});
|
|
11690
|
+
}
|
|
12345
11691
|
} catch (error) {
|
|
12346
|
-
this.logger.error("Failed to create resource", { error });
|
|
11692
|
+
this.logger.error("Failed to create resource", { error: errField4(error) });
|
|
12347
11693
|
this.eventBus.get("yield:create-failed").next({
|
|
12348
11694
|
message: error instanceof Error ? error.message : String(error)
|
|
12349
11695
|
});
|
|
@@ -12364,7 +11710,7 @@ var Stower = class {
|
|
|
12364
11710
|
});
|
|
12365
11711
|
this.eventBus.get("yield:update-ok").next({ resourceId: event.resourceId });
|
|
12366
11712
|
} catch (error) {
|
|
12367
|
-
this.logger.error("Failed to update resource", { error });
|
|
11713
|
+
this.logger.error("Failed to update resource", { error: errField4(error) });
|
|
12368
11714
|
this.eventBus.get("yield:update-failed").next({
|
|
12369
11715
|
resourceId: event.resourceId,
|
|
12370
11716
|
message: error instanceof Error ? error.message : String(error)
|
|
@@ -12398,7 +11744,7 @@ var Stower = class {
|
|
|
12398
11744
|
});
|
|
12399
11745
|
this.eventBus.get("yield:move-ok").next({ resourceId: rId });
|
|
12400
11746
|
} catch (error) {
|
|
12401
|
-
this.logger.error("Failed to move resource", { error });
|
|
11747
|
+
this.logger.error("Failed to move resource", { error: errField4(error) });
|
|
12402
11748
|
this.eventBus.get("yield:move-failed").next({
|
|
12403
11749
|
fromUri: event.fromUri,
|
|
12404
11750
|
message: error instanceof Error ? error.message : String(error)
|
|
@@ -12408,17 +11754,20 @@ var Stower = class {
|
|
|
12408
11754
|
async handleMarkCreate(event) {
|
|
12409
11755
|
try {
|
|
12410
11756
|
this.logger.debug("Stowing annotation", { annotationId: event.annotation.id });
|
|
12411
|
-
await this.kb.eventStore.appendEvent(
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12415
|
-
|
|
12416
|
-
|
|
12417
|
-
|
|
12418
|
-
|
|
11757
|
+
await this.kb.eventStore.appendEvent(
|
|
11758
|
+
{
|
|
11759
|
+
type: "mark:added",
|
|
11760
|
+
resourceId: resourceId3(event.resourceId),
|
|
11761
|
+
userId: makeUserId(event.userId),
|
|
11762
|
+
version: 1,
|
|
11763
|
+
payload: { annotation: event.annotation }
|
|
11764
|
+
},
|
|
11765
|
+
event.correlationId ? { correlationId: event.correlationId } : void 0
|
|
11766
|
+
);
|
|
12419
11767
|
} catch (error) {
|
|
12420
|
-
this.logger.error("Failed to create annotation", { error });
|
|
11768
|
+
this.logger.error("Failed to create annotation", { error: errField4(error) });
|
|
12421
11769
|
this.eventBus.get("mark:create-failed").next({
|
|
11770
|
+
correlationId: event.correlationId,
|
|
12422
11771
|
message: error instanceof Error ? error.message : String(error)
|
|
12423
11772
|
});
|
|
12424
11773
|
}
|
|
@@ -12437,7 +11786,7 @@ var Stower = class {
|
|
|
12437
11786
|
});
|
|
12438
11787
|
this.eventBus.get("mark:delete-ok").next({ annotationId: event.annotationId });
|
|
12439
11788
|
} catch (error) {
|
|
12440
|
-
this.logger.error("Failed to delete annotation", { error });
|
|
11789
|
+
this.logger.error("Failed to delete annotation", { error: errField4(error) });
|
|
12441
11790
|
this.eventBus.get("mark:delete-failed").next({
|
|
12442
11791
|
message: error instanceof Error ? error.message : String(error)
|
|
12443
11792
|
});
|
|
@@ -12458,8 +11807,9 @@ var Stower = class {
|
|
|
12458
11807
|
event.correlationId ? { correlationId: event.correlationId } : void 0
|
|
12459
11808
|
);
|
|
12460
11809
|
} catch (error) {
|
|
12461
|
-
this.logger.error("Failed to update annotation body", { error });
|
|
11810
|
+
this.logger.error("Failed to update annotation body", { error: errField4(error) });
|
|
12462
11811
|
this.eventBus.get("mark:body-update-failed").next({
|
|
11812
|
+
correlationId: event.correlationId,
|
|
12463
11813
|
message: error instanceof Error ? error.message : String(error)
|
|
12464
11814
|
});
|
|
12465
11815
|
}
|
|
@@ -12488,7 +11838,7 @@ var Stower = class {
|
|
|
12488
11838
|
if (event.storageUri) {
|
|
12489
11839
|
const absPath = this.kb.content.resolveUri(event.storageUri);
|
|
12490
11840
|
try {
|
|
12491
|
-
await
|
|
11841
|
+
await fs.access(absPath);
|
|
12492
11842
|
} catch {
|
|
12493
11843
|
this.logger.warn("Unarchive failed: file not found at storageUri", { storageUri: event.storageUri });
|
|
12494
11844
|
return;
|
|
@@ -12511,7 +11861,7 @@ var Stower = class {
|
|
|
12511
11861
|
payload: { entityType: event.tag }
|
|
12512
11862
|
});
|
|
12513
11863
|
} catch (error) {
|
|
12514
|
-
this.logger.error("Failed to add entity type", { error });
|
|
11864
|
+
this.logger.error("Failed to add entity type", { error: errField4(error) });
|
|
12515
11865
|
this.eventBus.get("mark:entity-type-add-failed").next({
|
|
12516
11866
|
message: error instanceof Error ? error.message : String(error)
|
|
12517
11867
|
});
|
|
@@ -12545,20 +11895,10 @@ var Stower = class {
|
|
|
12545
11895
|
resourceId: resourceId3(event.resourceId),
|
|
12546
11896
|
userId: makeUserId(event.userId),
|
|
12547
11897
|
version: 1,
|
|
12548
|
-
payload: { jobId: event.jobId, jobType: event.jobType }
|
|
12549
|
-
});
|
|
12550
|
-
}
|
|
12551
|
-
async handleJobReportProgress(event) {
|
|
12552
|
-
await this.kb.eventStore.appendEvent({
|
|
12553
|
-
type: "job:progress",
|
|
12554
|
-
resourceId: resourceId3(event.resourceId),
|
|
12555
|
-
userId: makeUserId(event.userId),
|
|
12556
|
-
version: 1,
|
|
12557
11898
|
payload: {
|
|
12558
11899
|
jobId: event.jobId,
|
|
12559
11900
|
jobType: event.jobType,
|
|
12560
|
-
|
|
12561
|
-
progress: event.progress
|
|
11901
|
+
...event.annotationId ? { annotationId: event.annotationId } : {}
|
|
12562
11902
|
}
|
|
12563
11903
|
});
|
|
12564
11904
|
}
|
|
@@ -12571,6 +11911,7 @@ var Stower = class {
|
|
|
12571
11911
|
payload: {
|
|
12572
11912
|
jobId: event.jobId,
|
|
12573
11913
|
jobType: event.jobType,
|
|
11914
|
+
...event.annotationId ? { annotationId: event.annotationId } : {},
|
|
12574
11915
|
result: event.result
|
|
12575
11916
|
}
|
|
12576
11917
|
});
|
|
@@ -12584,6 +11925,7 @@ var Stower = class {
|
|
|
12584
11925
|
payload: {
|
|
12585
11926
|
jobId: event.jobId,
|
|
12586
11927
|
jobType: event.jobType,
|
|
11928
|
+
...event.annotationId ? { annotationId: event.annotationId } : {},
|
|
12587
11929
|
error: event.error
|
|
12588
11930
|
}
|
|
12589
11931
|
});
|
|
@@ -12596,27 +11938,27 @@ var Stower = class {
|
|
|
12596
11938
|
};
|
|
12597
11939
|
|
|
12598
11940
|
// src/browser.ts
|
|
12599
|
-
var
|
|
12600
|
-
var
|
|
12601
|
-
import { promises as
|
|
12602
|
-
import * as
|
|
11941
|
+
var import_rxjs5 = __toESM(require_cjs(), 1);
|
|
11942
|
+
var import_operators5 = __toESM(require_operators(), 1);
|
|
11943
|
+
import { promises as fs3 } from "fs";
|
|
11944
|
+
import * as path2 from "path";
|
|
12603
11945
|
import { resourceId as resourceId4, annotationId, errField as errField5 } from "@semiont/core";
|
|
12604
|
-
import { getExactText
|
|
11946
|
+
import { getExactText, getTargetSource as getTargetSource2, getTargetSelector as getTargetSelector2, getResourceEntityTypes as getResourceEntityTypes5, getBodySource as getBodySource2 } from "@semiont/api-client";
|
|
12605
11947
|
import { EventQuery as EventQuery2 } from "@semiont/event-sourcing";
|
|
12606
11948
|
import { getEntityTypes as getEntityTypes2 } from "@semiont/ontology";
|
|
12607
11949
|
|
|
12608
11950
|
// src/views/entity-types-reader.ts
|
|
12609
|
-
import { promises as
|
|
12610
|
-
import * as
|
|
11951
|
+
import { promises as fs2 } from "fs";
|
|
11952
|
+
import * as path from "path";
|
|
12611
11953
|
async function readEntityTypesProjection(project) {
|
|
12612
|
-
const entityTypesPath =
|
|
11954
|
+
const entityTypesPath = path.join(
|
|
12613
11955
|
project.stateDir,
|
|
12614
11956
|
"projections",
|
|
12615
11957
|
"__system__",
|
|
12616
11958
|
"entitytypes.json"
|
|
12617
11959
|
);
|
|
12618
11960
|
try {
|
|
12619
|
-
const content = await
|
|
11961
|
+
const content = await fs2.readFile(entityTypesPath, "utf-8");
|
|
12620
11962
|
const projection = JSON.parse(content);
|
|
12621
11963
|
return projection.entityTypes || [];
|
|
12622
11964
|
} catch (error) {
|
|
@@ -12641,7 +11983,7 @@ var Browser = class {
|
|
|
12641
11983
|
async initialize() {
|
|
12642
11984
|
this.logger.info("Browser actor initialized");
|
|
12643
11985
|
const errorHandler = (err) => this.logger.error("Browser pipeline error", { error: err });
|
|
12644
|
-
const pipe = (name, handler) => this.eventBus.get(name).pipe((0,
|
|
11986
|
+
const pipe = (name, handler) => this.eventBus.get(name).pipe((0, import_operators5.mergeMap)((event) => (0, import_rxjs5.from)(handler(event))));
|
|
12645
11987
|
this.subscriptions.push(
|
|
12646
11988
|
pipe("browse:resource-requested", (e) => this.handleBrowseResource(e)).subscribe({ error: errorHandler }),
|
|
12647
11989
|
pipe("browse:resources-requested", (e) => this.handleBrowseResources(e)).subscribe({ error: errorHandler }),
|
|
@@ -12855,7 +12197,7 @@ var Browser = class {
|
|
|
12855
12197
|
const docMap = new Map(resources.filter((doc) => doc !== null).map((doc) => [doc["@id"], doc]));
|
|
12856
12198
|
const referencedBy = references.map((ref) => {
|
|
12857
12199
|
const targetSource = getTargetSource2(ref.target);
|
|
12858
|
-
const targetSelector =
|
|
12200
|
+
const targetSelector = getTargetSelector2(ref.target);
|
|
12859
12201
|
const doc = docMap.get(targetSource);
|
|
12860
12202
|
return {
|
|
12861
12203
|
id: ref.id,
|
|
@@ -12863,7 +12205,7 @@ var Browser = class {
|
|
|
12863
12205
|
target: {
|
|
12864
12206
|
source: targetSource,
|
|
12865
12207
|
selector: {
|
|
12866
|
-
exact: targetSelector ?
|
|
12208
|
+
exact: targetSelector ? getExactText(targetSelector) : ""
|
|
12867
12209
|
}
|
|
12868
12210
|
}
|
|
12869
12211
|
};
|
|
@@ -12901,8 +12243,8 @@ var Browser = class {
|
|
|
12901
12243
|
async handleBrowseDirectory(event) {
|
|
12902
12244
|
const { correlationId, path: reqPath, sort = "name" } = event;
|
|
12903
12245
|
const projectRoot = this.project.root;
|
|
12904
|
-
const resolved =
|
|
12905
|
-
if (!resolved.startsWith(projectRoot +
|
|
12246
|
+
const resolved = path2.resolve(projectRoot, reqPath);
|
|
12247
|
+
if (!resolved.startsWith(projectRoot + path2.sep) && resolved !== projectRoot) {
|
|
12906
12248
|
this.eventBus.get("browse:directory-failed").next({
|
|
12907
12249
|
correlationId,
|
|
12908
12250
|
path: reqPath,
|
|
@@ -12912,7 +12254,7 @@ var Browser = class {
|
|
|
12912
12254
|
}
|
|
12913
12255
|
let dirents;
|
|
12914
12256
|
try {
|
|
12915
|
-
dirents = await
|
|
12257
|
+
dirents = await fs3.readdir(resolved, { withFileTypes: true, encoding: "utf8" });
|
|
12916
12258
|
} catch (err) {
|
|
12917
12259
|
const msg = err.code === "ENOENT" ? "path not found" : String(err);
|
|
12918
12260
|
this.eventBus.get("browse:directory-failed").next({
|
|
@@ -12926,16 +12268,16 @@ var Browser = class {
|
|
|
12926
12268
|
const allViews = await this.views.getAll();
|
|
12927
12269
|
const prefix = `file://${resolved}`;
|
|
12928
12270
|
const viewsByUri = new Map(
|
|
12929
|
-
allViews.filter((v) => v.resource.storageUri?.startsWith(prefix + "/") || v.resource.storageUri?.startsWith(prefix +
|
|
12271
|
+
allViews.filter((v) => v.resource.storageUri?.startsWith(prefix + "/") || v.resource.storageUri?.startsWith(prefix + path2.sep)).map((v) => [v.resource.storageUri, v])
|
|
12930
12272
|
);
|
|
12931
12273
|
const entries = [];
|
|
12932
12274
|
for (const dirent of visible) {
|
|
12933
|
-
const entryPath =
|
|
12934
|
-
const relPath =
|
|
12275
|
+
const entryPath = path2.join(resolved, dirent.name);
|
|
12276
|
+
const relPath = path2.relative(projectRoot, entryPath);
|
|
12935
12277
|
if (dirent.isDirectory()) {
|
|
12936
12278
|
let mtime = (/* @__PURE__ */ new Date(0)).toISOString();
|
|
12937
12279
|
try {
|
|
12938
|
-
const stat = await
|
|
12280
|
+
const stat = await fs3.stat(entryPath);
|
|
12939
12281
|
mtime = stat.mtime.toISOString();
|
|
12940
12282
|
} catch {
|
|
12941
12283
|
}
|
|
@@ -12945,7 +12287,7 @@ var Browser = class {
|
|
|
12945
12287
|
let size = 0;
|
|
12946
12288
|
let mtime = (/* @__PURE__ */ new Date(0)).toISOString();
|
|
12947
12289
|
try {
|
|
12948
|
-
const stat = await
|
|
12290
|
+
const stat = await fs3.stat(entryPath);
|
|
12949
12291
|
size = stat.size;
|
|
12950
12292
|
mtime = stat.mtime.toISOString();
|
|
12951
12293
|
} catch {
|
|
@@ -13000,33 +12342,51 @@ var Browser = class {
|
|
|
13000
12342
|
}
|
|
13001
12343
|
};
|
|
13002
12344
|
|
|
12345
|
+
// src/event-enrichment.ts
|
|
12346
|
+
function eventAnnotationId(event) {
|
|
12347
|
+
switch (event.type) {
|
|
12348
|
+
case "mark:added":
|
|
12349
|
+
return event.payload.annotation.id;
|
|
12350
|
+
case "mark:body-updated":
|
|
12351
|
+
return event.payload.annotationId;
|
|
12352
|
+
case "mark:removed":
|
|
12353
|
+
return event.payload.annotationId;
|
|
12354
|
+
default:
|
|
12355
|
+
return null;
|
|
12356
|
+
}
|
|
12357
|
+
}
|
|
12358
|
+
async function readAnnotationFromView(kb, resourceId7, annotationId3) {
|
|
12359
|
+
const allAnnotations = await AnnotationContext.getAllAnnotations(resourceId7, kb);
|
|
12360
|
+
return allAnnotations.find((a) => a.id === annotationId3) ?? null;
|
|
12361
|
+
}
|
|
12362
|
+
|
|
13003
12363
|
// src/clone-token-manager.ts
|
|
13004
|
-
var
|
|
13005
|
-
var
|
|
12364
|
+
var import_rxjs7 = __toESM(require_cjs(), 1);
|
|
12365
|
+
var import_operators7 = __toESM(require_operators(), 1);
|
|
13006
12366
|
import { CREATION_METHODS as CREATION_METHODS2, cloneToken as makeCloneToken, resourceId as resourceId5, userId as makeUserId2 } from "@semiont/core";
|
|
13007
12367
|
import { getPrimaryRepresentation as getPrimaryRepresentation3, getResourceEntityTypes as getResourceEntityTypes6 } from "@semiont/api-client";
|
|
13008
12368
|
import { deriveStorageUri } from "@semiont/content";
|
|
13009
12369
|
|
|
13010
12370
|
// src/resource-operations.ts
|
|
13011
|
-
var
|
|
13012
|
-
var
|
|
13013
|
-
import { resourceId as
|
|
12371
|
+
var import_rxjs6 = __toESM(require_cjs(), 1);
|
|
12372
|
+
var import_operators6 = __toESM(require_operators(), 1);
|
|
12373
|
+
import { resourceId as makeResourceId3 } from "@semiont/core";
|
|
13014
12374
|
var ResourceOperations = class {
|
|
13015
12375
|
/**
|
|
13016
12376
|
* Create a new resource via EventBus → Stower
|
|
13017
12377
|
*/
|
|
13018
12378
|
static async createResource(input, userId2, eventBus) {
|
|
13019
|
-
const result$ = (0,
|
|
12379
|
+
const result$ = (0, import_rxjs6.race)(
|
|
13020
12380
|
eventBus.get("yield:create-ok").pipe(
|
|
13021
|
-
(0,
|
|
13022
|
-
(0,
|
|
12381
|
+
(0, import_operators6.take)(1),
|
|
12382
|
+
(0, import_operators6.map)((result) => ({ ok: true, result }))
|
|
13023
12383
|
),
|
|
13024
12384
|
eventBus.get("yield:create-failed").pipe(
|
|
13025
|
-
(0,
|
|
13026
|
-
(0,
|
|
12385
|
+
(0, import_operators6.take)(1),
|
|
12386
|
+
(0, import_operators6.map)((failure) => ({ ok: false, error: new Error(failure.message) }))
|
|
13027
12387
|
),
|
|
13028
|
-
(0,
|
|
13029
|
-
(0,
|
|
12388
|
+
(0, import_rxjs6.timer)(3e4).pipe(
|
|
12389
|
+
(0, import_operators6.map)(() => ({ ok: false, error: new Error("Resource creation timed out") }))
|
|
13030
12390
|
)
|
|
13031
12391
|
);
|
|
13032
12392
|
eventBus.get("yield:create").next({
|
|
@@ -13038,13 +12398,17 @@ var ResourceOperations = class {
|
|
|
13038
12398
|
userId: userId2,
|
|
13039
12399
|
language: input.language,
|
|
13040
12400
|
entityTypes: input.entityTypes,
|
|
13041
|
-
creationMethod: input.creationMethod
|
|
12401
|
+
creationMethod: input.creationMethod,
|
|
12402
|
+
generatedFrom: input.generatedFrom,
|
|
12403
|
+
generationPrompt: input.generationPrompt,
|
|
12404
|
+
generator: input.generator,
|
|
12405
|
+
isDraft: input.isDraft
|
|
13042
12406
|
});
|
|
13043
|
-
const outcome = await (0,
|
|
12407
|
+
const outcome = await (0, import_rxjs6.firstValueFrom)(result$);
|
|
13044
12408
|
if (!outcome.ok) {
|
|
13045
12409
|
throw outcome.error;
|
|
13046
12410
|
}
|
|
13047
|
-
return
|
|
12411
|
+
return makeResourceId3(outcome.result.resourceId);
|
|
13048
12412
|
}
|
|
13049
12413
|
/**
|
|
13050
12414
|
* Update resource metadata via EventBus → Stower
|
|
@@ -13082,13 +12446,13 @@ var CloneTokenManager = class {
|
|
|
13082
12446
|
this.logger.info("CloneTokenManager actor initialized");
|
|
13083
12447
|
const errorHandler = (err) => this.logger.error("CloneTokenManager pipeline error", { error: err });
|
|
13084
12448
|
const generateToken$ = this.eventBus.get("yield:clone-token-requested").pipe(
|
|
13085
|
-
(0,
|
|
12449
|
+
(0, import_operators7.mergeMap)((event) => (0, import_rxjs7.from)(this.handleGenerateToken(event)))
|
|
13086
12450
|
);
|
|
13087
12451
|
const getResource$ = this.eventBus.get("yield:clone-resource-requested").pipe(
|
|
13088
|
-
(0,
|
|
12452
|
+
(0, import_operators7.mergeMap)((event) => (0, import_rxjs7.from)(this.handleGetResource(event)))
|
|
13089
12453
|
);
|
|
13090
12454
|
const createResource$ = this.eventBus.get("yield:clone-create").pipe(
|
|
13091
|
-
(0,
|
|
12455
|
+
(0, import_operators7.mergeMap)((event) => (0, import_rxjs7.from)(this.handleCreateResource(event)))
|
|
13092
12456
|
);
|
|
13093
12457
|
this.subscriptions.push(
|
|
13094
12458
|
generateToken$.subscribe({ error: errorHandler }),
|
|
@@ -13265,8 +12629,8 @@ var CloneTokenManager = class {
|
|
|
13265
12629
|
};
|
|
13266
12630
|
|
|
13267
12631
|
// src/bootstrap/entity-types.ts
|
|
13268
|
-
var
|
|
13269
|
-
var
|
|
12632
|
+
var import_rxjs8 = __toESM(require_cjs(), 1);
|
|
12633
|
+
var import_operators8 = __toESM(require_operators(), 1);
|
|
13270
12634
|
import { DEFAULT_ENTITY_TYPES } from "@semiont/ontology";
|
|
13271
12635
|
import { userId, resourceId as resourceId6 } from "@semiont/core";
|
|
13272
12636
|
async function bootstrapEntityTypes(eventBus, eventStore, logger) {
|
|
@@ -13283,13 +12647,13 @@ async function bootstrapEntityTypes(eventBus, eventStore, logger) {
|
|
|
13283
12647
|
const SYSTEM_USER_ID = userId("00000000-0000-0000-0000-000000000000");
|
|
13284
12648
|
for (const entityType of missing) {
|
|
13285
12649
|
logger?.debug("Adding entity type via EventBus", { entityType });
|
|
13286
|
-
const result$ = (0,
|
|
13287
|
-
eventBus.get("mark:entity-type-added").pipe((0,
|
|
13288
|
-
eventBus.get("mark:entity-type-add-failed").pipe((0,
|
|
13289
|
-
(0,
|
|
12650
|
+
const result$ = (0, import_rxjs8.race)(
|
|
12651
|
+
eventBus.get("mark:entity-type-added").pipe((0, import_operators8.take)(1), (0, import_operators8.map)(() => ({ ok: true }))),
|
|
12652
|
+
eventBus.get("mark:entity-type-add-failed").pipe((0, import_operators8.take)(1), (0, import_operators8.map)((f) => ({ ok: false, error: new Error(f.message) }))),
|
|
12653
|
+
(0, import_rxjs8.timer)(1e4).pipe((0, import_operators8.map)(() => ({ ok: false, error: new Error(`Timeout adding entity type: ${entityType}`) })))
|
|
13290
12654
|
);
|
|
13291
12655
|
eventBus.get("mark:add-entity-type").next({ tag: entityType, userId: SYSTEM_USER_ID });
|
|
13292
|
-
const outcome = await (0,
|
|
12656
|
+
const outcome = await (0, import_rxjs8.firstValueFrom)(result$);
|
|
13293
12657
|
if (!outcome.ok) {
|
|
13294
12658
|
throw outcome.error;
|
|
13295
12659
|
}
|
|
@@ -13311,10 +12675,10 @@ async function stopKnowledgeSystem(ks) {
|
|
|
13311
12675
|
// src/service.ts
|
|
13312
12676
|
async function createJobQueue(project, eventBus, logger) {
|
|
13313
12677
|
const jobQueueLogger = logger.child({ component: "job-queue" });
|
|
13314
|
-
const jobQueue = new
|
|
12678
|
+
const jobQueue = new FsJobQueue(project, jobQueueLogger, eventBus);
|
|
13315
12679
|
await jobQueue.initialize();
|
|
13316
12680
|
const jobStatusSubscription = eventBus.get("job:status-requested").pipe(
|
|
13317
|
-
(0,
|
|
12681
|
+
(0, import_operators9.mergeMap)((event) => (0, import_rxjs9.from)((async () => {
|
|
13318
12682
|
try {
|
|
13319
12683
|
const job = await jobQueue.getJob(jobId(event.jobId));
|
|
13320
12684
|
if (!job) {
|
|
@@ -13373,13 +12737,15 @@ async function createKnowledgeSystemFromConfig(project, config, eventBus, logger
|
|
|
13373
12737
|
}
|
|
13374
12738
|
const kb = await createKnowledgeBase(eventStore, project, graphDb, eventBus, logger, {
|
|
13375
12739
|
vectorStore,
|
|
13376
|
-
embeddingProvider,
|
|
13377
|
-
chunkingConfig: embeddingConfig?.chunking ? {
|
|
13378
|
-
chunkSize: embeddingConfig.chunking.chunkSize ?? 512,
|
|
13379
|
-
overlap: embeddingConfig.chunking.overlap ?? 64
|
|
13380
|
-
} : void 0,
|
|
13381
12740
|
skipRebuild
|
|
13382
12741
|
});
|
|
12742
|
+
eventStore.setEnrichEvent(async (event, resourceId7) => {
|
|
12743
|
+
const annId = eventAnnotationId(event);
|
|
12744
|
+
if (annId === null) return event;
|
|
12745
|
+
const annotation = await readAnnotationFromView(kb, resourceId7, annId);
|
|
12746
|
+
if (annotation === null) return event;
|
|
12747
|
+
return { ...event, annotation };
|
|
12748
|
+
});
|
|
13383
12749
|
const stower = new Stower(kb, eventBus, logger.child({ component: "stower" }));
|
|
13384
12750
|
await stower.initialize();
|
|
13385
12751
|
await bootstrapEntityTypes(eventBus, eventStore, logger.child({ component: "entity-types-bootstrap" }));
|
|
@@ -13406,57 +12772,6 @@ async function createKnowledgeSystemFromConfig(project, config, eventBus, logger
|
|
|
13406
12772
|
const ks = { kb, stower, gatherer, matcher, browser, cloneTokenManager, stop: () => stopKnowledgeSystem(ks) };
|
|
13407
12773
|
return ks;
|
|
13408
12774
|
}
|
|
13409
|
-
function createContentFetcher(ks) {
|
|
13410
|
-
return async (resourceId7) => {
|
|
13411
|
-
const view = await ks.kb.views.get(resourceId7);
|
|
13412
|
-
if (!view?.resource.storageUri) return null;
|
|
13413
|
-
const buffer = await ks.kb.content.retrieve(view.resource.storageUri);
|
|
13414
|
-
if (!buffer) return null;
|
|
13415
|
-
return Readable.from([buffer]);
|
|
13416
|
-
};
|
|
13417
|
-
}
|
|
13418
|
-
function createWorkers(jobQueue, contentFetcher, contentStore, eventBus, config, logger) {
|
|
13419
|
-
const detection = (() => {
|
|
13420
|
-
const cfg = resolveWorkerInference(config, "reference-annotation");
|
|
13421
|
-
return new ReferenceAnnotationWorker(jobQueue, createInferenceClient(cfg, logger.child({ component: "inference-client-reference-annotation" })), inferenceConfigToGenerator("Reference Worker", cfg), eventBus, contentFetcher, logger.child({ component: "reference-detection-worker" }));
|
|
13422
|
-
})();
|
|
13423
|
-
const generation = (() => {
|
|
13424
|
-
const cfg = resolveWorkerInference(config, "generation");
|
|
13425
|
-
return new GenerationWorker(jobQueue, createInferenceClient(cfg, logger.child({ component: "inference-client-generation" })), inferenceConfigToGenerator("Generation Worker", cfg), eventBus, contentStore, logger.child({ component: "generation-worker" }));
|
|
13426
|
-
})();
|
|
13427
|
-
const highlight = (() => {
|
|
13428
|
-
const cfg = resolveWorkerInference(config, "highlight-annotation");
|
|
13429
|
-
return new HighlightAnnotationWorker(jobQueue, createInferenceClient(cfg, logger.child({ component: "inference-client-highlight-annotation" })), inferenceConfigToGenerator("Highlight Worker", cfg), eventBus, contentFetcher, logger.child({ component: "highlight-detection-worker" }));
|
|
13430
|
-
})();
|
|
13431
|
-
const assessment = (() => {
|
|
13432
|
-
const cfg = resolveWorkerInference(config, "assessment-annotation");
|
|
13433
|
-
return new AssessmentAnnotationWorker(jobQueue, createInferenceClient(cfg, logger.child({ component: "inference-client-assessment-annotation" })), inferenceConfigToGenerator("Assessment Worker", cfg), eventBus, contentFetcher, logger.child({ component: "assessment-detection-worker" }));
|
|
13434
|
-
})();
|
|
13435
|
-
const comment = (() => {
|
|
13436
|
-
const cfg = resolveWorkerInference(config, "comment-annotation");
|
|
13437
|
-
return new CommentAnnotationWorker(jobQueue, createInferenceClient(cfg, logger.child({ component: "inference-client-comment-annotation" })), inferenceConfigToGenerator("Comment Worker", cfg), eventBus, contentFetcher, logger.child({ component: "comment-detection-worker" }));
|
|
13438
|
-
})();
|
|
13439
|
-
const tag = (() => {
|
|
13440
|
-
const cfg = resolveWorkerInference(config, "tag-annotation");
|
|
13441
|
-
return new TagAnnotationWorker(jobQueue, createInferenceClient(cfg, logger.child({ component: "inference-client-tag-annotation" })), inferenceConfigToGenerator("Tag Worker", cfg), eventBus, contentFetcher, logger.child({ component: "tag-detection-worker" }));
|
|
13442
|
-
})();
|
|
13443
|
-
return { detection, generation, highlight, assessment, comment, tag };
|
|
13444
|
-
}
|
|
13445
|
-
function startWorkers(workers, logger) {
|
|
13446
|
-
const entries = [
|
|
13447
|
-
["detection", "reference-detection-worker"],
|
|
13448
|
-
["generation", "generation-worker"],
|
|
13449
|
-
["highlight", "highlight-detection-worker"],
|
|
13450
|
-
["assessment", "assessment-detection-worker"],
|
|
13451
|
-
["comment", "comment-detection-worker"],
|
|
13452
|
-
["tag", "tag-detection-worker"]
|
|
13453
|
-
];
|
|
13454
|
-
for (const [key, component] of entries) {
|
|
13455
|
-
workers[key].start().catch((error) => {
|
|
13456
|
-
logger.child({ component }).error("Worker stopped unexpectedly", { error });
|
|
13457
|
-
});
|
|
13458
|
-
}
|
|
13459
|
-
}
|
|
13460
12775
|
async function startMakeMeaning(project, config, eventBus, logger, options) {
|
|
13461
12776
|
if (!config.services?.graph) {
|
|
13462
12777
|
throw new Error("services.graph is required for make-meaning service");
|
|
@@ -13464,16 +12779,11 @@ async function startMakeMeaning(project, config, eventBus, logger, options) {
|
|
|
13464
12779
|
const skipRebuild = options?.skipRebuild ?? process.env.SEMIONT_SKIP_REBUILD === "true";
|
|
13465
12780
|
const { jobQueue, jobStatusSubscription } = await createJobQueue(project, eventBus, logger);
|
|
13466
12781
|
const knowledgeSystem = await createKnowledgeSystemFromConfig(project, config, eventBus, logger, skipRebuild);
|
|
13467
|
-
const contentFetcher = createContentFetcher(knowledgeSystem);
|
|
13468
|
-
const workers = createWorkers(jobQueue, contentFetcher, knowledgeSystem.kb.content, eventBus, config, logger);
|
|
13469
|
-
startWorkers(workers, logger);
|
|
13470
12782
|
return {
|
|
13471
12783
|
knowledgeSystem,
|
|
13472
12784
|
jobQueue,
|
|
13473
|
-
workers,
|
|
13474
12785
|
stop: async () => {
|
|
13475
12786
|
logger.info("Stopping Make-Meaning service");
|
|
13476
|
-
await Promise.all(Object.values(workers).map((w) => w.stop()));
|
|
13477
12787
|
jobStatusSubscription.unsubscribe();
|
|
13478
12788
|
await knowledgeSystem.stop();
|
|
13479
12789
|
logger.info("Make-Meaning service stopped");
|
|
@@ -13486,7 +12796,7 @@ import { getExtensionForMimeType } from "@semiont/content";
|
|
|
13486
12796
|
|
|
13487
12797
|
// src/exchange/tar.ts
|
|
13488
12798
|
import { createGzip, createGunzip } from "zlib";
|
|
13489
|
-
import { Readable
|
|
12799
|
+
import { Readable, pipeline } from "stream";
|
|
13490
12800
|
import { promisify } from "util";
|
|
13491
12801
|
var pipelineAsync = promisify(pipeline);
|
|
13492
12802
|
var BLOCK_SIZE = 512;
|
|
@@ -13516,7 +12826,7 @@ function paddingBytes(size) {
|
|
|
13516
12826
|
}
|
|
13517
12827
|
async function writeTarGz(entries, output) {
|
|
13518
12828
|
const gzip = createGzip();
|
|
13519
|
-
const tarStream = new
|
|
12829
|
+
const tarStream = new Readable({ read() {
|
|
13520
12830
|
} });
|
|
13521
12831
|
const pipePromise = pipelineAsync(tarStream, gzip, output);
|
|
13522
12832
|
for await (const entry of entries) {
|
|
@@ -13672,8 +12982,8 @@ function collectContentRefs(streamData) {
|
|
|
13672
12982
|
}
|
|
13673
12983
|
|
|
13674
12984
|
// src/exchange/replay.ts
|
|
13675
|
-
var
|
|
13676
|
-
var
|
|
12985
|
+
var import_rxjs10 = __toESM(require_cjs(), 1);
|
|
12986
|
+
var import_operators10 = __toESM(require_operators(), 1);
|
|
13677
12987
|
import { deriveStorageUri as deriveStorageUri2 } from "@semiont/content";
|
|
13678
12988
|
var REPLAY_TIMEOUT_MS = 3e4;
|
|
13679
12989
|
async function replayEventStream(jsonl, eventBus, resolveBlob, contentStore, logger) {
|
|
@@ -13738,12 +13048,12 @@ async function replayEvent(event, eventBus, resolveBlob, contentStore, stats, lo
|
|
|
13738
13048
|
}
|
|
13739
13049
|
}
|
|
13740
13050
|
async function replayEntityTypeAdded(event, eventBus, logger) {
|
|
13741
|
-
const result$ = (0,
|
|
13742
|
-
eventBus.get("mark:entity-type-added").pipe((0,
|
|
13743
|
-
eventBus.get("mark:entity-type-add-failed").pipe((0,
|
|
13051
|
+
const result$ = (0, import_rxjs10.race)(
|
|
13052
|
+
eventBus.get("mark:entity-type-added").pipe((0, import_operators10.map)(() => "ok")),
|
|
13053
|
+
eventBus.get("mark:entity-type-add-failed").pipe((0, import_operators10.map)((e) => {
|
|
13744
13054
|
throw new Error(e.message);
|
|
13745
13055
|
})),
|
|
13746
|
-
(0,
|
|
13056
|
+
(0, import_rxjs10.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators10.map)(() => {
|
|
13747
13057
|
throw new Error("Timeout waiting for mark:entity-type-added");
|
|
13748
13058
|
}))
|
|
13749
13059
|
);
|
|
@@ -13751,7 +13061,7 @@ async function replayEntityTypeAdded(event, eventBus, logger) {
|
|
|
13751
13061
|
tag: event.payload.entityType,
|
|
13752
13062
|
userId: event.userId
|
|
13753
13063
|
});
|
|
13754
|
-
await (0,
|
|
13064
|
+
await (0, import_rxjs10.firstValueFrom)(result$);
|
|
13755
13065
|
logger?.debug("Replayed entitytype.added", { entityType: event.payload.entityType });
|
|
13756
13066
|
}
|
|
13757
13067
|
async function replayResourceCreated(event, eventBus, resolveBlob, contentStore, logger) {
|
|
@@ -13762,12 +13072,12 @@ async function replayResourceCreated(event, eventBus, resolveBlob, contentStore,
|
|
|
13762
13072
|
}
|
|
13763
13073
|
const resolvedUri = payload.storageUri || deriveStorageUri2(payload.name, payload.format);
|
|
13764
13074
|
const stored = await contentStore.store(blob, resolvedUri);
|
|
13765
|
-
const result$ = (0,
|
|
13766
|
-
eventBus.get("yield:create-ok").pipe((0,
|
|
13767
|
-
eventBus.get("yield:create-failed").pipe((0,
|
|
13075
|
+
const result$ = (0, import_rxjs10.race)(
|
|
13076
|
+
eventBus.get("yield:create-ok").pipe((0, import_operators10.map)((r) => r)),
|
|
13077
|
+
eventBus.get("yield:create-failed").pipe((0, import_operators10.map)((e) => {
|
|
13768
13078
|
throw new Error(e.message);
|
|
13769
13079
|
})),
|
|
13770
|
-
(0,
|
|
13080
|
+
(0, import_rxjs10.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators10.map)(() => {
|
|
13771
13081
|
throw new Error("Timeout waiting for yield:create-ok");
|
|
13772
13082
|
}))
|
|
13773
13083
|
);
|
|
@@ -13785,16 +13095,16 @@ async function replayResourceCreated(event, eventBus, resolveBlob, contentStore,
|
|
|
13785
13095
|
generatedFrom: payload.generatedFrom,
|
|
13786
13096
|
generationPrompt: payload.generationPrompt
|
|
13787
13097
|
});
|
|
13788
|
-
await (0,
|
|
13098
|
+
await (0, import_rxjs10.firstValueFrom)(result$);
|
|
13789
13099
|
logger?.debug("Replayed resource.created", { name: payload.name });
|
|
13790
13100
|
}
|
|
13791
13101
|
async function replayAnnotationAdded(event, eventBus, logger) {
|
|
13792
|
-
const result$ = (0,
|
|
13793
|
-
eventBus.get("mark:create-ok").pipe((0,
|
|
13794
|
-
eventBus.get("mark:create-failed").pipe((0,
|
|
13102
|
+
const result$ = (0, import_rxjs10.race)(
|
|
13103
|
+
eventBus.get("mark:create-ok").pipe((0, import_operators10.map)(() => "ok")),
|
|
13104
|
+
eventBus.get("mark:create-failed").pipe((0, import_operators10.map)((e) => {
|
|
13795
13105
|
throw new Error(e.message);
|
|
13796
13106
|
})),
|
|
13797
|
-
(0,
|
|
13107
|
+
(0, import_rxjs10.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators10.map)(() => {
|
|
13798
13108
|
throw new Error("Timeout waiting for mark:create-ok");
|
|
13799
13109
|
}))
|
|
13800
13110
|
);
|
|
@@ -13803,16 +13113,16 @@ async function replayAnnotationAdded(event, eventBus, logger) {
|
|
|
13803
13113
|
userId: event.userId,
|
|
13804
13114
|
resourceId: event.resourceId
|
|
13805
13115
|
});
|
|
13806
|
-
await (0,
|
|
13116
|
+
await (0, import_rxjs10.firstValueFrom)(result$);
|
|
13807
13117
|
logger?.debug("Replayed annotation.added", { annotationId: event.payload.annotation.id });
|
|
13808
13118
|
}
|
|
13809
13119
|
async function replayAnnotationBodyUpdated(event, eventBus, logger) {
|
|
13810
|
-
const result$ = (0,
|
|
13811
|
-
eventBus.get("mark:body-updated").pipe((0,
|
|
13812
|
-
eventBus.get("mark:body-update-failed").pipe((0,
|
|
13120
|
+
const result$ = (0, import_rxjs10.race)(
|
|
13121
|
+
eventBus.get("mark:body-updated").pipe((0, import_operators10.map)(() => "ok")),
|
|
13122
|
+
eventBus.get("mark:body-update-failed").pipe((0, import_operators10.map)((e) => {
|
|
13813
13123
|
throw new Error(e.message);
|
|
13814
13124
|
})),
|
|
13815
|
-
(0,
|
|
13125
|
+
(0, import_rxjs10.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators10.map)(() => {
|
|
13816
13126
|
throw new Error("Timeout waiting for mark:body-updated");
|
|
13817
13127
|
}))
|
|
13818
13128
|
);
|
|
@@ -13822,16 +13132,16 @@ async function replayAnnotationBodyUpdated(event, eventBus, logger) {
|
|
|
13822
13132
|
resourceId: event.resourceId,
|
|
13823
13133
|
operations: event.payload.operations
|
|
13824
13134
|
});
|
|
13825
|
-
await (0,
|
|
13135
|
+
await (0, import_rxjs10.firstValueFrom)(result$);
|
|
13826
13136
|
logger?.debug("Replayed annotation.body.updated", { annotationId: event.payload.annotationId });
|
|
13827
13137
|
}
|
|
13828
13138
|
async function replayAnnotationRemoved(event, eventBus, logger) {
|
|
13829
|
-
const result$ = (0,
|
|
13830
|
-
eventBus.get("mark:delete-ok").pipe((0,
|
|
13831
|
-
eventBus.get("mark:delete-failed").pipe((0,
|
|
13139
|
+
const result$ = (0, import_rxjs10.race)(
|
|
13140
|
+
eventBus.get("mark:delete-ok").pipe((0, import_operators10.map)(() => "ok")),
|
|
13141
|
+
eventBus.get("mark:delete-failed").pipe((0, import_operators10.map)((e) => {
|
|
13832
13142
|
throw new Error(e.message);
|
|
13833
13143
|
})),
|
|
13834
|
-
(0,
|
|
13144
|
+
(0, import_rxjs10.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators10.map)(() => {
|
|
13835
13145
|
throw new Error("Timeout waiting for mark:delete-ok");
|
|
13836
13146
|
}))
|
|
13837
13147
|
);
|
|
@@ -13840,7 +13150,7 @@ async function replayAnnotationRemoved(event, eventBus, logger) {
|
|
|
13840
13150
|
userId: event.userId,
|
|
13841
13151
|
resourceId: event.resourceId
|
|
13842
13152
|
});
|
|
13843
|
-
await (0,
|
|
13153
|
+
await (0, import_rxjs10.firstValueFrom)(result$);
|
|
13844
13154
|
logger?.debug("Replayed annotation.removed", { annotationId: event.payload.annotationId });
|
|
13845
13155
|
}
|
|
13846
13156
|
async function replayResourceArchived(event, eventBus, logger) {
|
|
@@ -14130,9 +13440,9 @@ function collectContentRefsFromResource(resource, refs) {
|
|
|
14130
13440
|
}
|
|
14131
13441
|
|
|
14132
13442
|
// src/exchange/linked-data-importer.ts
|
|
14133
|
-
var
|
|
14134
|
-
var
|
|
14135
|
-
import { resourceId as
|
|
13443
|
+
var import_rxjs11 = __toESM(require_cjs(), 1);
|
|
13444
|
+
var import_operators11 = __toESM(require_operators(), 1);
|
|
13445
|
+
import { resourceId as makeResourceId4 } from "@semiont/core";
|
|
14136
13446
|
import { deriveStorageUri as deriveStorageUri3 } from "@semiont/content";
|
|
14137
13447
|
var IMPORT_TIMEOUT_MS = 3e4;
|
|
14138
13448
|
function stripUriToId(uri) {
|
|
@@ -14235,12 +13545,12 @@ async function importLinkedData(archive, options) {
|
|
|
14235
13545
|
};
|
|
14236
13546
|
}
|
|
14237
13547
|
async function addEntityType(entityType, userId2, eventBus, logger) {
|
|
14238
|
-
const result$ = (0,
|
|
14239
|
-
eventBus.get("mark:entity-type-added").pipe((0,
|
|
14240
|
-
eventBus.get("mark:entity-type-add-failed").pipe((0,
|
|
13548
|
+
const result$ = (0, import_rxjs11.race)(
|
|
13549
|
+
eventBus.get("mark:entity-type-added").pipe((0, import_operators11.map)(() => "ok")),
|
|
13550
|
+
eventBus.get("mark:entity-type-add-failed").pipe((0, import_operators11.map)((e) => {
|
|
14241
13551
|
throw new Error(e.message);
|
|
14242
13552
|
})),
|
|
14243
|
-
(0,
|
|
13553
|
+
(0, import_rxjs11.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators11.map)(() => {
|
|
14244
13554
|
throw new Error("Timeout waiting for mark:entity-type-added");
|
|
14245
13555
|
}))
|
|
14246
13556
|
);
|
|
@@ -14248,7 +13558,7 @@ async function addEntityType(entityType, userId2, eventBus, logger) {
|
|
|
14248
13558
|
tag: entityType,
|
|
14249
13559
|
userId: userId2
|
|
14250
13560
|
});
|
|
14251
|
-
await (0,
|
|
13561
|
+
await (0, import_rxjs11.firstValueFrom)(result$);
|
|
14252
13562
|
logger?.debug("Added entity type", { entityType });
|
|
14253
13563
|
}
|
|
14254
13564
|
async function importResource(doc, userId2, eventBus, contentStore, resolveBlob, logger) {
|
|
@@ -14275,12 +13585,12 @@ async function importResource(doc, userId2, eventBus, contentStore, resolveBlob,
|
|
|
14275
13585
|
}
|
|
14276
13586
|
const resolvedUri = deriveStorageUri3(name, format);
|
|
14277
13587
|
const stored = await contentStore.store(blob, resolvedUri);
|
|
14278
|
-
const createResult$ = (0,
|
|
14279
|
-
eventBus.get("yield:create-ok").pipe((0,
|
|
14280
|
-
eventBus.get("yield:create-failed").pipe((0,
|
|
13588
|
+
const createResult$ = (0, import_rxjs11.race)(
|
|
13589
|
+
eventBus.get("yield:create-ok").pipe((0, import_operators11.map)((r) => r)),
|
|
13590
|
+
eventBus.get("yield:create-failed").pipe((0, import_operators11.map)((e) => {
|
|
14281
13591
|
throw new Error(e.message);
|
|
14282
13592
|
})),
|
|
14283
|
-
(0,
|
|
13593
|
+
(0, import_rxjs11.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators11.map)(() => {
|
|
14284
13594
|
throw new Error("Timeout waiting for yield:create-ok");
|
|
14285
13595
|
}))
|
|
14286
13596
|
);
|
|
@@ -14295,8 +13605,8 @@ async function importResource(doc, userId2, eventBus, contentStore, resolveBlob,
|
|
|
14295
13605
|
entityTypes: entityTypes ?? [],
|
|
14296
13606
|
creationMethod
|
|
14297
13607
|
});
|
|
14298
|
-
const created = await (0,
|
|
14299
|
-
const resourceId7 =
|
|
13608
|
+
const created = await (0, import_rxjs11.firstValueFrom)(createResult$);
|
|
13609
|
+
const resourceId7 = makeResourceId4(created.resourceId);
|
|
14300
13610
|
logger?.debug("Created resource from JSON-LD", { name, resourceId: resourceId7 });
|
|
14301
13611
|
let annotationsCreated = 0;
|
|
14302
13612
|
if (annotations && annotations.length > 0) {
|
|
@@ -14308,12 +13618,12 @@ async function importResource(doc, userId2, eventBus, contentStore, resolveBlob,
|
|
|
14308
13618
|
return { annotationsCreated };
|
|
14309
13619
|
}
|
|
14310
13620
|
async function createAnnotation(annotation, resourceId7, userId2, eventBus, logger) {
|
|
14311
|
-
const result$ = (0,
|
|
14312
|
-
eventBus.get("mark:create-ok").pipe((0,
|
|
14313
|
-
eventBus.get("mark:create-failed").pipe((0,
|
|
13621
|
+
const result$ = (0, import_rxjs11.race)(
|
|
13622
|
+
eventBus.get("mark:create-ok").pipe((0, import_operators11.map)(() => "ok")),
|
|
13623
|
+
eventBus.get("mark:create-failed").pipe((0, import_operators11.map)((e) => {
|
|
14314
13624
|
throw new Error(e.message);
|
|
14315
13625
|
})),
|
|
14316
|
-
(0,
|
|
13626
|
+
(0, import_rxjs11.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators11.map)(() => {
|
|
14317
13627
|
throw new Error("Timeout waiting for mark:create-ok");
|
|
14318
13628
|
}))
|
|
14319
13629
|
);
|
|
@@ -14322,7 +13632,7 @@ async function createAnnotation(annotation, resourceId7, userId2, eventBus, logg
|
|
|
14322
13632
|
userId: userId2,
|
|
14323
13633
|
resourceId: resourceId7
|
|
14324
13634
|
});
|
|
14325
|
-
await (0,
|
|
13635
|
+
await (0, import_rxjs11.firstValueFrom)(result$);
|
|
14326
13636
|
logger?.debug("Created annotation", { annotationId: annotation.id });
|
|
14327
13637
|
}
|
|
14328
13638
|
|
|
@@ -14333,14 +13643,14 @@ import {
|
|
|
14333
13643
|
} from "@semiont/core";
|
|
14334
13644
|
|
|
14335
13645
|
// src/annotation-operations.ts
|
|
14336
|
-
import { annotationId as annotationId2, resourceId as
|
|
13646
|
+
import { annotationId as annotationId2, resourceId as makeResourceId5, assembleAnnotation as assembleAnnotation2, applyBodyOperations as applyBodyOperations2 } from "@semiont/core";
|
|
14337
13647
|
var AnnotationOperations = class {
|
|
14338
13648
|
/**
|
|
14339
13649
|
* Create a new annotation via EventBus → Stower
|
|
14340
13650
|
*/
|
|
14341
13651
|
static async createAnnotation(request, userId2, creator, eventBus) {
|
|
14342
13652
|
const { annotation } = assembleAnnotation2(request, creator);
|
|
14343
|
-
const resId =
|
|
13653
|
+
const resId = makeResourceId5(request.target.source);
|
|
14344
13654
|
eventBus.get("mark:create").next({
|
|
14345
13655
|
annotation,
|
|
14346
13656
|
userId: userId2,
|
|
@@ -14352,7 +13662,7 @@ var AnnotationOperations = class {
|
|
|
14352
13662
|
* Update annotation body via EventBus → Stower
|
|
14353
13663
|
*/
|
|
14354
13664
|
static async updateAnnotationBody(id, request, userId2, eventBus, kb) {
|
|
14355
|
-
const resId =
|
|
13665
|
+
const resId = makeResourceId5(request.resourceId);
|
|
14356
13666
|
const annotation = await AnnotationContext.getAnnotation(
|
|
14357
13667
|
annotationId2(id),
|
|
14358
13668
|
resId,
|
|
@@ -14379,7 +13689,7 @@ var AnnotationOperations = class {
|
|
|
14379
13689
|
* Delete an annotation via EventBus → Stower
|
|
14380
13690
|
*/
|
|
14381
13691
|
static async deleteAnnotation(id, resourceIdStr, userId2, eventBus, kb, logger) {
|
|
14382
|
-
const resId =
|
|
13692
|
+
const resId = makeResourceId5(resourceIdStr);
|
|
14383
13693
|
const projection = await AnnotationContext.getResourceAnnotations(resId, kb);
|
|
14384
13694
|
const annotation = projection.annotations.find((a) => a.id === id);
|
|
14385
13695
|
if (!annotation) {
|
|
@@ -14412,7 +13722,6 @@ export {
|
|
|
14412
13722
|
PACKAGE_NAME,
|
|
14413
13723
|
ResourceContext,
|
|
14414
13724
|
ResourceOperations,
|
|
14415
|
-
Smelter,
|
|
14416
13725
|
Stower,
|
|
14417
13726
|
VERSION,
|
|
14418
13727
|
applyBodyOperations,
|