@semiont/make-meaning 0.5.6 → 0.5.7
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/README.md +51 -32
- package/dist/index.d.ts +198 -23
- package/dist/index.js +751 -223
- package/dist/index.js.map +1 -1
- package/dist/smelter-main.js +547 -243
- package/dist/smelter-main.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { FsJobQueue } from '@semiont/jobs';
|
|
2
2
|
import { FilesystemViewStorage, resolveStorageUri, EventQuery, createEventStore } from '@semiont/event-sourcing';
|
|
3
|
-
import { getPrimaryRepresentation, decodeRepresentation, getTargetSource, getBodySource, resourceId, getTargetSelector, getResourceEntityTypes, getResourceId, getTextPositionSelector, annotationId, errField, userId, generateUuid, getExactText, cloneToken, didToAgent, assembleAnnotation, jobId, entityType, baseUrl, busLog, BRIDGED_CHANNELS,
|
|
4
|
-
|
|
5
|
-
import { withActorSpan, recordBusEmit, withSpan, SpanKind, registerJobQueueProvider } from '@semiont/observability';
|
|
3
|
+
import { getPrimaryRepresentation, decodeRepresentation, getTargetSource, getBodySource, resourceId, getTargetSelector, getResourceEntityTypes, getResourceId, getTextPositionSelector, annotationId, errField, userId, generateUuid, getExactText, cloneToken, baseMediaType, isSupportedMediaType, capabilitiesOf, didToAgent, assembleAnnotation, jobId, entityType, baseUrl, busLog, BRIDGED_CHANNELS, burstBuffer, textExtractionOf, getPrimaryMediaType, extensionForMediaType, applyBodyOperations, findBodyItem } from '@semiont/core';
|
|
4
|
+
import { withActorSpan, recordBusEmit, withSpan, SpanKind, registerJobQueueProvider, registerVectorIndexSizeProvider } from '@semiont/observability';
|
|
6
5
|
import { createInferenceClient } from '@semiont/inference';
|
|
7
6
|
import { getGraphDatabase } from '@semiont/graph';
|
|
8
|
-
import { WorkingTreeStore, deriveStorageUri,
|
|
7
|
+
import { WorkingTreeStore, deriveStorageUri, calculateChecksum } from '@semiont/content';
|
|
9
8
|
import { getEntityTypes, DEFAULT_ENTITY_TYPES } from '@semiont/ontology';
|
|
10
9
|
import { promises } from 'fs';
|
|
11
10
|
import * as path3 from 'path';
|
|
11
|
+
import { chunkText } from '@semiont/vectors';
|
|
12
|
+
import { busRequest } from '@semiont/sdk';
|
|
12
13
|
import { createGzip, createGunzip } from 'zlib';
|
|
13
14
|
import { pipeline, Readable } from 'stream';
|
|
14
15
|
import { promisify } from 'util';
|
|
@@ -22,11 +23,11 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
22
23
|
var __commonJS = (cb, mod) => function __require() {
|
|
23
24
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
24
25
|
};
|
|
25
|
-
var __copyProps = (to,
|
|
26
|
-
if (
|
|
27
|
-
for (let key of __getOwnPropNames(
|
|
26
|
+
var __copyProps = (to, from9, except, desc) => {
|
|
27
|
+
if (from9 && typeof from9 === "object" || typeof from9 === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from9))
|
|
28
29
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
-
__defProp(to, key, { get: () =>
|
|
30
|
+
__defProp(to, key, { get: () => from9[key], enumerable: !(desc = __getOwnPropDesc(from9, key)) || desc.enumerable });
|
|
30
31
|
}
|
|
31
32
|
return to;
|
|
32
33
|
};
|
|
@@ -135,9 +136,9 @@ var require_Subscription = __commonJS({
|
|
|
135
136
|
}
|
|
136
137
|
return ar;
|
|
137
138
|
};
|
|
138
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
139
|
-
for (var i = 0, il =
|
|
140
|
-
to[j] =
|
|
139
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
140
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
141
|
+
to[j] = from9[i];
|
|
141
142
|
return to;
|
|
142
143
|
};
|
|
143
144
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -145,14 +146,14 @@ var require_Subscription = __commonJS({
|
|
|
145
146
|
var isFunction_1 = require_isFunction();
|
|
146
147
|
var UnsubscriptionError_1 = require_UnsubscriptionError();
|
|
147
148
|
var arrRemove_1 = require_arrRemove();
|
|
148
|
-
var
|
|
149
|
-
function
|
|
149
|
+
var Subscription8 = (function() {
|
|
150
|
+
function Subscription9(initialTeardown) {
|
|
150
151
|
this.initialTeardown = initialTeardown;
|
|
151
152
|
this.closed = false;
|
|
152
153
|
this._parentage = null;
|
|
153
154
|
this._finalizers = null;
|
|
154
155
|
}
|
|
155
|
-
|
|
156
|
+
Subscription9.prototype.unsubscribe = function() {
|
|
156
157
|
var e_1, _a, e_2, _b;
|
|
157
158
|
var errors;
|
|
158
159
|
if (!this.closed) {
|
|
@@ -219,13 +220,13 @@ var require_Subscription = __commonJS({
|
|
|
219
220
|
}
|
|
220
221
|
}
|
|
221
222
|
};
|
|
222
|
-
|
|
223
|
+
Subscription9.prototype.add = function(teardown) {
|
|
223
224
|
var _a;
|
|
224
225
|
if (teardown && teardown !== this) {
|
|
225
226
|
if (this.closed) {
|
|
226
227
|
execFinalizer(teardown);
|
|
227
228
|
} else {
|
|
228
|
-
if (teardown instanceof
|
|
229
|
+
if (teardown instanceof Subscription9) {
|
|
229
230
|
if (teardown.closed || teardown._hasParent(this)) {
|
|
230
231
|
return;
|
|
231
232
|
}
|
|
@@ -235,15 +236,15 @@ var require_Subscription = __commonJS({
|
|
|
235
236
|
}
|
|
236
237
|
}
|
|
237
238
|
};
|
|
238
|
-
|
|
239
|
+
Subscription9.prototype._hasParent = function(parent) {
|
|
239
240
|
var _parentage = this._parentage;
|
|
240
241
|
return _parentage === parent || Array.isArray(_parentage) && _parentage.includes(parent);
|
|
241
242
|
};
|
|
242
|
-
|
|
243
|
+
Subscription9.prototype._addParent = function(parent) {
|
|
243
244
|
var _parentage = this._parentage;
|
|
244
245
|
this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
|
|
245
246
|
};
|
|
246
|
-
|
|
247
|
+
Subscription9.prototype._removeParent = function(parent) {
|
|
247
248
|
var _parentage = this._parentage;
|
|
248
249
|
if (_parentage === parent) {
|
|
249
250
|
this._parentage = null;
|
|
@@ -251,24 +252,24 @@ var require_Subscription = __commonJS({
|
|
|
251
252
|
arrRemove_1.arrRemove(_parentage, parent);
|
|
252
253
|
}
|
|
253
254
|
};
|
|
254
|
-
|
|
255
|
+
Subscription9.prototype.remove = function(teardown) {
|
|
255
256
|
var _finalizers = this._finalizers;
|
|
256
257
|
_finalizers && arrRemove_1.arrRemove(_finalizers, teardown);
|
|
257
|
-
if (teardown instanceof
|
|
258
|
+
if (teardown instanceof Subscription9) {
|
|
258
259
|
teardown._removeParent(this);
|
|
259
260
|
}
|
|
260
261
|
};
|
|
261
|
-
|
|
262
|
-
var empty = new
|
|
262
|
+
Subscription9.EMPTY = (function() {
|
|
263
|
+
var empty = new Subscription9();
|
|
263
264
|
empty.closed = true;
|
|
264
265
|
return empty;
|
|
265
266
|
})();
|
|
266
|
-
return
|
|
267
|
+
return Subscription9;
|
|
267
268
|
})();
|
|
268
|
-
exports.Subscription =
|
|
269
|
-
exports.EMPTY_SUBSCRIPTION =
|
|
269
|
+
exports.Subscription = Subscription8;
|
|
270
|
+
exports.EMPTY_SUBSCRIPTION = Subscription8.EMPTY;
|
|
270
271
|
function isSubscription(value) {
|
|
271
|
-
return value instanceof
|
|
272
|
+
return value instanceof Subscription8 || value && "closed" in value && isFunction_1.isFunction(value.remove) && isFunction_1.isFunction(value.add) && isFunction_1.isFunction(value.unsubscribe);
|
|
272
273
|
}
|
|
273
274
|
exports.isSubscription = isSubscription;
|
|
274
275
|
function execFinalizer(finalizer) {
|
|
@@ -316,9 +317,9 @@ var require_timeoutProvider = __commonJS({
|
|
|
316
317
|
}
|
|
317
318
|
return ar;
|
|
318
319
|
};
|
|
319
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
320
|
-
for (var i = 0, il =
|
|
321
|
-
to[j] =
|
|
320
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
321
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
322
|
+
to[j] = from9[i];
|
|
322
323
|
return to;
|
|
323
324
|
};
|
|
324
325
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -705,19 +706,19 @@ var require_Observable = __commonJS({
|
|
|
705
706
|
var config_1 = require_config();
|
|
706
707
|
var isFunction_1 = require_isFunction();
|
|
707
708
|
var errorContext_1 = require_errorContext();
|
|
708
|
-
var
|
|
709
|
-
function
|
|
709
|
+
var Observable3 = (function() {
|
|
710
|
+
function Observable4(subscribe) {
|
|
710
711
|
if (subscribe) {
|
|
711
712
|
this._subscribe = subscribe;
|
|
712
713
|
}
|
|
713
714
|
}
|
|
714
|
-
|
|
715
|
-
var observable = new
|
|
715
|
+
Observable4.prototype.lift = function(operator) {
|
|
716
|
+
var observable = new Observable4();
|
|
716
717
|
observable.source = this;
|
|
717
718
|
observable.operator = operator;
|
|
718
719
|
return observable;
|
|
719
720
|
};
|
|
720
|
-
|
|
721
|
+
Observable4.prototype.subscribe = function(observerOrNext, error, complete) {
|
|
721
722
|
var _this = this;
|
|
722
723
|
var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new Subscriber_1.SafeSubscriber(observerOrNext, error, complete);
|
|
723
724
|
errorContext_1.errorContext(function() {
|
|
@@ -726,14 +727,14 @@ var require_Observable = __commonJS({
|
|
|
726
727
|
});
|
|
727
728
|
return subscriber;
|
|
728
729
|
};
|
|
729
|
-
|
|
730
|
+
Observable4.prototype._trySubscribe = function(sink) {
|
|
730
731
|
try {
|
|
731
732
|
return this._subscribe(sink);
|
|
732
733
|
} catch (err) {
|
|
733
734
|
sink.error(err);
|
|
734
735
|
}
|
|
735
736
|
};
|
|
736
|
-
|
|
737
|
+
Observable4.prototype.forEach = function(next, promiseCtor) {
|
|
737
738
|
var _this = this;
|
|
738
739
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
739
740
|
return new promiseCtor(function(resolve2, reject) {
|
|
@@ -752,21 +753,21 @@ var require_Observable = __commonJS({
|
|
|
752
753
|
_this.subscribe(subscriber);
|
|
753
754
|
});
|
|
754
755
|
};
|
|
755
|
-
|
|
756
|
+
Observable4.prototype._subscribe = function(subscriber) {
|
|
756
757
|
var _a;
|
|
757
758
|
return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
|
|
758
759
|
};
|
|
759
|
-
|
|
760
|
+
Observable4.prototype[observable_1.observable] = function() {
|
|
760
761
|
return this;
|
|
761
762
|
};
|
|
762
|
-
|
|
763
|
+
Observable4.prototype.pipe = function() {
|
|
763
764
|
var operations = [];
|
|
764
765
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
765
766
|
operations[_i] = arguments[_i];
|
|
766
767
|
}
|
|
767
768
|
return pipe_1.pipeFromArray(operations)(this);
|
|
768
769
|
};
|
|
769
|
-
|
|
770
|
+
Observable4.prototype.toPromise = function(promiseCtor) {
|
|
770
771
|
var _this = this;
|
|
771
772
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
772
773
|
return new promiseCtor(function(resolve2, reject) {
|
|
@@ -780,12 +781,12 @@ var require_Observable = __commonJS({
|
|
|
780
781
|
});
|
|
781
782
|
});
|
|
782
783
|
};
|
|
783
|
-
|
|
784
|
-
return new
|
|
784
|
+
Observable4.create = function(subscribe) {
|
|
785
|
+
return new Observable4(subscribe);
|
|
785
786
|
};
|
|
786
|
-
return
|
|
787
|
+
return Observable4;
|
|
787
788
|
})();
|
|
788
|
-
exports.Observable =
|
|
789
|
+
exports.Observable = Observable3;
|
|
789
790
|
function getPromiseCtor(promiseCtor) {
|
|
790
791
|
var _a;
|
|
791
792
|
return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config_1.config.Promise) !== null && _a !== void 0 ? _a : Promise;
|
|
@@ -1061,9 +1062,9 @@ var require_animationFrameProvider = __commonJS({
|
|
|
1061
1062
|
}
|
|
1062
1063
|
return ar;
|
|
1063
1064
|
};
|
|
1064
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
1065
|
-
for (var i = 0, il =
|
|
1066
|
-
to[j] =
|
|
1065
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
1066
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
1067
|
+
to[j] = from9[i];
|
|
1067
1068
|
return to;
|
|
1068
1069
|
};
|
|
1069
1070
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1205,9 +1206,9 @@ var require_Subject = __commonJS({
|
|
|
1205
1206
|
var ObjectUnsubscribedError_1 = require_ObjectUnsubscribedError();
|
|
1206
1207
|
var arrRemove_1 = require_arrRemove();
|
|
1207
1208
|
var errorContext_1 = require_errorContext();
|
|
1208
|
-
var
|
|
1209
|
-
__extends(
|
|
1210
|
-
function
|
|
1209
|
+
var Subject4 = (function(_super) {
|
|
1210
|
+
__extends(Subject5, _super);
|
|
1211
|
+
function Subject5() {
|
|
1211
1212
|
var _this = _super.call(this) || this;
|
|
1212
1213
|
_this.closed = false;
|
|
1213
1214
|
_this.currentObservers = null;
|
|
@@ -1217,17 +1218,17 @@ var require_Subject = __commonJS({
|
|
|
1217
1218
|
_this.thrownError = null;
|
|
1218
1219
|
return _this;
|
|
1219
1220
|
}
|
|
1220
|
-
|
|
1221
|
+
Subject5.prototype.lift = function(operator) {
|
|
1221
1222
|
var subject = new AnonymousSubject(this, this);
|
|
1222
1223
|
subject.operator = operator;
|
|
1223
1224
|
return subject;
|
|
1224
1225
|
};
|
|
1225
|
-
|
|
1226
|
+
Subject5.prototype._throwIfClosed = function() {
|
|
1226
1227
|
if (this.closed) {
|
|
1227
1228
|
throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
|
|
1228
1229
|
}
|
|
1229
1230
|
};
|
|
1230
|
-
|
|
1231
|
+
Subject5.prototype.next = function(value) {
|
|
1231
1232
|
var _this = this;
|
|
1232
1233
|
errorContext_1.errorContext(function() {
|
|
1233
1234
|
var e_1, _a;
|
|
@@ -1253,7 +1254,7 @@ var require_Subject = __commonJS({
|
|
|
1253
1254
|
}
|
|
1254
1255
|
});
|
|
1255
1256
|
};
|
|
1256
|
-
|
|
1257
|
+
Subject5.prototype.error = function(err) {
|
|
1257
1258
|
var _this = this;
|
|
1258
1259
|
errorContext_1.errorContext(function() {
|
|
1259
1260
|
_this._throwIfClosed();
|
|
@@ -1267,7 +1268,7 @@ var require_Subject = __commonJS({
|
|
|
1267
1268
|
}
|
|
1268
1269
|
});
|
|
1269
1270
|
};
|
|
1270
|
-
|
|
1271
|
+
Subject5.prototype.complete = function() {
|
|
1271
1272
|
var _this = this;
|
|
1272
1273
|
errorContext_1.errorContext(function() {
|
|
1273
1274
|
_this._throwIfClosed();
|
|
@@ -1280,11 +1281,11 @@ var require_Subject = __commonJS({
|
|
|
1280
1281
|
}
|
|
1281
1282
|
});
|
|
1282
1283
|
};
|
|
1283
|
-
|
|
1284
|
+
Subject5.prototype.unsubscribe = function() {
|
|
1284
1285
|
this.isStopped = this.closed = true;
|
|
1285
1286
|
this.observers = this.currentObservers = null;
|
|
1286
1287
|
};
|
|
1287
|
-
Object.defineProperty(
|
|
1288
|
+
Object.defineProperty(Subject5.prototype, "observed", {
|
|
1288
1289
|
get: function() {
|
|
1289
1290
|
var _a;
|
|
1290
1291
|
return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
@@ -1292,16 +1293,16 @@ var require_Subject = __commonJS({
|
|
|
1292
1293
|
enumerable: false,
|
|
1293
1294
|
configurable: true
|
|
1294
1295
|
});
|
|
1295
|
-
|
|
1296
|
+
Subject5.prototype._trySubscribe = function(subscriber) {
|
|
1296
1297
|
this._throwIfClosed();
|
|
1297
1298
|
return _super.prototype._trySubscribe.call(this, subscriber);
|
|
1298
1299
|
};
|
|
1299
|
-
|
|
1300
|
+
Subject5.prototype._subscribe = function(subscriber) {
|
|
1300
1301
|
this._throwIfClosed();
|
|
1301
1302
|
this._checkFinalizedStatuses(subscriber);
|
|
1302
1303
|
return this._innerSubscribe(subscriber);
|
|
1303
1304
|
};
|
|
1304
|
-
|
|
1305
|
+
Subject5.prototype._innerSubscribe = function(subscriber) {
|
|
1305
1306
|
var _this = this;
|
|
1306
1307
|
var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
|
|
1307
1308
|
if (hasError || isStopped) {
|
|
@@ -1314,7 +1315,7 @@ var require_Subject = __commonJS({
|
|
|
1314
1315
|
arrRemove_1.arrRemove(observers, subscriber);
|
|
1315
1316
|
});
|
|
1316
1317
|
};
|
|
1317
|
-
|
|
1318
|
+
Subject5.prototype._checkFinalizedStatuses = function(subscriber) {
|
|
1318
1319
|
var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
|
|
1319
1320
|
if (hasError) {
|
|
1320
1321
|
subscriber.error(thrownError);
|
|
@@ -1322,17 +1323,17 @@ var require_Subject = __commonJS({
|
|
|
1322
1323
|
subscriber.complete();
|
|
1323
1324
|
}
|
|
1324
1325
|
};
|
|
1325
|
-
|
|
1326
|
+
Subject5.prototype.asObservable = function() {
|
|
1326
1327
|
var observable = new Observable_1.Observable();
|
|
1327
1328
|
observable.source = this;
|
|
1328
1329
|
return observable;
|
|
1329
1330
|
};
|
|
1330
|
-
|
|
1331
|
+
Subject5.create = function(destination, source) {
|
|
1331
1332
|
return new AnonymousSubject(destination, source);
|
|
1332
1333
|
};
|
|
1333
|
-
return
|
|
1334
|
+
return Subject5;
|
|
1334
1335
|
})(Observable_1.Observable);
|
|
1335
|
-
exports.Subject =
|
|
1336
|
+
exports.Subject = Subject4;
|
|
1336
1337
|
var AnonymousSubject = (function(_super) {
|
|
1337
1338
|
__extends(AnonymousSubject2, _super);
|
|
1338
1339
|
function AnonymousSubject2(destination, source) {
|
|
@@ -1358,7 +1359,7 @@ var require_Subject = __commonJS({
|
|
|
1358
1359
|
return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : Subscription_1.EMPTY_SUBSCRIPTION;
|
|
1359
1360
|
};
|
|
1360
1361
|
return AnonymousSubject2;
|
|
1361
|
-
})(
|
|
1362
|
+
})(Subject4);
|
|
1362
1363
|
exports.AnonymousSubject = AnonymousSubject;
|
|
1363
1364
|
}
|
|
1364
1365
|
});
|
|
@@ -1649,9 +1650,9 @@ var require_intervalProvider = __commonJS({
|
|
|
1649
1650
|
}
|
|
1650
1651
|
return ar;
|
|
1651
1652
|
};
|
|
1652
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
1653
|
-
for (var i = 0, il =
|
|
1654
|
-
to[j] =
|
|
1653
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
1654
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
1655
|
+
to[j] = from9[i];
|
|
1655
1656
|
return to;
|
|
1656
1657
|
};
|
|
1657
1658
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1855,9 +1856,9 @@ var require_immediateProvider = __commonJS({
|
|
|
1855
1856
|
}
|
|
1856
1857
|
return ar;
|
|
1857
1858
|
};
|
|
1858
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
1859
|
-
for (var i = 0, il =
|
|
1860
|
-
to[j] =
|
|
1859
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
1860
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
1861
|
+
to[j] = from9[i];
|
|
1861
1862
|
return to;
|
|
1862
1863
|
};
|
|
1863
1864
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -3379,10 +3380,10 @@ var require_from = __commonJS({
|
|
|
3379
3380
|
exports.from = void 0;
|
|
3380
3381
|
var scheduled_1 = require_scheduled();
|
|
3381
3382
|
var innerFrom_1 = require_innerFrom();
|
|
3382
|
-
function
|
|
3383
|
+
function from9(input, scheduler) {
|
|
3383
3384
|
return scheduler ? scheduled_1.scheduled(input, scheduler) : innerFrom_1.innerFrom(input);
|
|
3384
3385
|
}
|
|
3385
|
-
exports.from =
|
|
3386
|
+
exports.from = from9;
|
|
3386
3387
|
}
|
|
3387
3388
|
});
|
|
3388
3389
|
|
|
@@ -3755,9 +3756,9 @@ var require_mapOneOrManyArgs = __commonJS({
|
|
|
3755
3756
|
}
|
|
3756
3757
|
return ar;
|
|
3757
3758
|
};
|
|
3758
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
3759
|
-
for (var i = 0, il =
|
|
3760
|
-
to[j] =
|
|
3759
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
3760
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
3761
|
+
to[j] = from9[i];
|
|
3761
3762
|
return to;
|
|
3762
3763
|
};
|
|
3763
3764
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -3796,9 +3797,9 @@ var require_bindCallbackInternals = __commonJS({
|
|
|
3796
3797
|
}
|
|
3797
3798
|
return ar;
|
|
3798
3799
|
};
|
|
3799
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
3800
|
-
for (var i = 0, il =
|
|
3801
|
-
to[j] =
|
|
3800
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
3801
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
3802
|
+
to[j] = from9[i];
|
|
3802
3803
|
return to;
|
|
3803
3804
|
};
|
|
3804
3805
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -4111,12 +4112,12 @@ var require_mergeMap = __commonJS({
|
|
|
4111
4112
|
var lift_1 = require_lift();
|
|
4112
4113
|
var mergeInternals_1 = require_mergeInternals();
|
|
4113
4114
|
var isFunction_1 = require_isFunction();
|
|
4114
|
-
function
|
|
4115
|
+
function mergeMap7(project, resultSelector, concurrent) {
|
|
4115
4116
|
if (concurrent === void 0) {
|
|
4116
4117
|
concurrent = Infinity;
|
|
4117
4118
|
}
|
|
4118
4119
|
if (isFunction_1.isFunction(resultSelector)) {
|
|
4119
|
-
return
|
|
4120
|
+
return mergeMap7(function(a, i) {
|
|
4120
4121
|
return map_1.map(function(b, ii) {
|
|
4121
4122
|
return resultSelector(a, b, i, ii);
|
|
4122
4123
|
})(innerFrom_1.innerFrom(project(a, i)));
|
|
@@ -4128,7 +4129,7 @@ var require_mergeMap = __commonJS({
|
|
|
4128
4129
|
return mergeInternals_1.mergeInternals(source, subscriber, project, concurrent);
|
|
4129
4130
|
});
|
|
4130
4131
|
}
|
|
4131
|
-
exports.mergeMap =
|
|
4132
|
+
exports.mergeMap = mergeMap7;
|
|
4132
4133
|
}
|
|
4133
4134
|
});
|
|
4134
4135
|
|
|
@@ -4899,9 +4900,9 @@ var require_zip = __commonJS({
|
|
|
4899
4900
|
}
|
|
4900
4901
|
return ar;
|
|
4901
4902
|
};
|
|
4902
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
4903
|
-
for (var i = 0, il =
|
|
4904
|
-
to[j] =
|
|
4903
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
4904
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
4905
|
+
to[j] = from9[i];
|
|
4905
4906
|
return to;
|
|
4906
4907
|
};
|
|
4907
4908
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -5513,9 +5514,9 @@ var require_combineLatest2 = __commonJS({
|
|
|
5513
5514
|
}
|
|
5514
5515
|
return ar;
|
|
5515
5516
|
};
|
|
5516
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
5517
|
-
for (var i = 0, il =
|
|
5518
|
-
to[j] =
|
|
5517
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
5518
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
5519
|
+
to[j] = from9[i];
|
|
5519
5520
|
return to;
|
|
5520
5521
|
};
|
|
5521
5522
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -5560,9 +5561,9 @@ var require_combineLatestWith = __commonJS({
|
|
|
5560
5561
|
}
|
|
5561
5562
|
return ar;
|
|
5562
5563
|
};
|
|
5563
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
5564
|
-
for (var i = 0, il =
|
|
5565
|
-
to[j] =
|
|
5564
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
5565
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
5566
|
+
to[j] = from9[i];
|
|
5566
5567
|
return to;
|
|
5567
5568
|
};
|
|
5568
5569
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -5586,10 +5587,10 @@ var require_concatMap = __commonJS({
|
|
|
5586
5587
|
exports.concatMap = void 0;
|
|
5587
5588
|
var mergeMap_1 = require_mergeMap();
|
|
5588
5589
|
var isFunction_1 = require_isFunction();
|
|
5589
|
-
function
|
|
5590
|
+
function concatMap6(project, resultSelector) {
|
|
5590
5591
|
return isFunction_1.isFunction(resultSelector) ? mergeMap_1.mergeMap(project, resultSelector, 1) : mergeMap_1.mergeMap(project, 1);
|
|
5591
5592
|
}
|
|
5592
|
-
exports.concatMap =
|
|
5593
|
+
exports.concatMap = concatMap6;
|
|
5593
5594
|
}
|
|
5594
5595
|
});
|
|
5595
5596
|
|
|
@@ -5631,9 +5632,9 @@ var require_concat2 = __commonJS({
|
|
|
5631
5632
|
}
|
|
5632
5633
|
return ar;
|
|
5633
5634
|
};
|
|
5634
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
5635
|
-
for (var i = 0, il =
|
|
5636
|
-
to[j] =
|
|
5635
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
5636
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
5637
|
+
to[j] = from9[i];
|
|
5637
5638
|
return to;
|
|
5638
5639
|
};
|
|
5639
5640
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -5676,9 +5677,9 @@ var require_concatWith = __commonJS({
|
|
|
5676
5677
|
}
|
|
5677
5678
|
return ar;
|
|
5678
5679
|
};
|
|
5679
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
5680
|
-
for (var i = 0, il =
|
|
5681
|
-
to[j] =
|
|
5680
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
5681
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
5682
|
+
to[j] = from9[i];
|
|
5682
5683
|
return to;
|
|
5683
5684
|
};
|
|
5684
5685
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -6151,9 +6152,9 @@ var require_endWith = __commonJS({
|
|
|
6151
6152
|
}
|
|
6152
6153
|
return ar;
|
|
6153
6154
|
};
|
|
6154
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
6155
|
-
for (var i = 0, il =
|
|
6156
|
-
to[j] =
|
|
6155
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
6156
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
6157
|
+
to[j] = from9[i];
|
|
6157
6158
|
return to;
|
|
6158
6159
|
};
|
|
6159
6160
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -6382,7 +6383,7 @@ var require_groupBy = __commonJS({
|
|
|
6382
6383
|
var Subject_1 = require_Subject();
|
|
6383
6384
|
var lift_1 = require_lift();
|
|
6384
6385
|
var OperatorSubscriber_1 = require_OperatorSubscriber();
|
|
6385
|
-
function
|
|
6386
|
+
function groupBy4(keySelector, elementOrOptions, duration, connector) {
|
|
6386
6387
|
return lift_1.operate(function(source, subscriber) {
|
|
6387
6388
|
var element;
|
|
6388
6389
|
if (!elementOrOptions || typeof elementOrOptions === "function") {
|
|
@@ -6449,7 +6450,7 @@ var require_groupBy = __commonJS({
|
|
|
6449
6450
|
}
|
|
6450
6451
|
});
|
|
6451
6452
|
}
|
|
6452
|
-
exports.groupBy =
|
|
6453
|
+
exports.groupBy = groupBy4;
|
|
6453
6454
|
}
|
|
6454
6455
|
});
|
|
6455
6456
|
|
|
@@ -6679,9 +6680,9 @@ var require_merge2 = __commonJS({
|
|
|
6679
6680
|
}
|
|
6680
6681
|
return ar;
|
|
6681
6682
|
};
|
|
6682
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
6683
|
-
for (var i = 0, il =
|
|
6684
|
-
to[j] =
|
|
6683
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
6684
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
6685
|
+
to[j] = from9[i];
|
|
6685
6686
|
return to;
|
|
6686
6687
|
};
|
|
6687
6688
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -6725,9 +6726,9 @@ var require_mergeWith = __commonJS({
|
|
|
6725
6726
|
}
|
|
6726
6727
|
return ar;
|
|
6727
6728
|
};
|
|
6728
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
6729
|
-
for (var i = 0, il =
|
|
6730
|
-
to[j] =
|
|
6729
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
6730
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
6731
|
+
to[j] = from9[i];
|
|
6731
6732
|
return to;
|
|
6732
6733
|
};
|
|
6733
6734
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -6807,9 +6808,9 @@ var require_onErrorResumeNextWith = __commonJS({
|
|
|
6807
6808
|
}
|
|
6808
6809
|
return ar;
|
|
6809
6810
|
};
|
|
6810
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
6811
|
-
for (var i = 0, il =
|
|
6812
|
-
to[j] =
|
|
6811
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
6812
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
6813
|
+
to[j] = from9[i];
|
|
6813
6814
|
return to;
|
|
6814
6815
|
};
|
|
6815
6816
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -6984,9 +6985,9 @@ var require_raceWith = __commonJS({
|
|
|
6984
6985
|
}
|
|
6985
6986
|
return ar;
|
|
6986
6987
|
};
|
|
6987
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
6988
|
-
for (var i = 0, il =
|
|
6989
|
-
to[j] =
|
|
6988
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
6989
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
6990
|
+
to[j] = from9[i];
|
|
6990
6991
|
return to;
|
|
6991
6992
|
};
|
|
6992
6993
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -7373,9 +7374,9 @@ var require_share = __commonJS({
|
|
|
7373
7374
|
}
|
|
7374
7375
|
return ar;
|
|
7375
7376
|
};
|
|
7376
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
7377
|
-
for (var i = 0, il =
|
|
7378
|
-
to[j] =
|
|
7377
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
7378
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
7379
|
+
to[j] = from9[i];
|
|
7379
7380
|
return to;
|
|
7380
7381
|
};
|
|
7381
7382
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -8348,9 +8349,9 @@ var require_withLatestFrom = __commonJS({
|
|
|
8348
8349
|
}
|
|
8349
8350
|
return ar;
|
|
8350
8351
|
};
|
|
8351
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
8352
|
-
for (var i = 0, il =
|
|
8353
|
-
to[j] =
|
|
8352
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
8353
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
8354
|
+
to[j] = from9[i];
|
|
8354
8355
|
return to;
|
|
8355
8356
|
};
|
|
8356
8357
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -8432,9 +8433,9 @@ var require_zip2 = __commonJS({
|
|
|
8432
8433
|
}
|
|
8433
8434
|
return ar;
|
|
8434
8435
|
};
|
|
8435
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
8436
|
-
for (var i = 0, il =
|
|
8437
|
-
to[j] =
|
|
8436
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
8437
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
8438
|
+
to[j] = from9[i];
|
|
8438
8439
|
return to;
|
|
8439
8440
|
};
|
|
8440
8441
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -8474,9 +8475,9 @@ var require_zipWith = __commonJS({
|
|
|
8474
8475
|
}
|
|
8475
8476
|
return ar;
|
|
8476
8477
|
};
|
|
8477
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
8478
|
-
for (var i = 0, il =
|
|
8479
|
-
to[j] =
|
|
8478
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
8479
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
8480
|
+
to[j] = from9[i];
|
|
8480
8481
|
return to;
|
|
8481
8482
|
};
|
|
8482
8483
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -9239,9 +9240,9 @@ var require_race2 = __commonJS({
|
|
|
9239
9240
|
}
|
|
9240
9241
|
return ar;
|
|
9241
9242
|
};
|
|
9242
|
-
var __spreadArray = exports && exports.__spreadArray || function(to,
|
|
9243
|
-
for (var i = 0, il =
|
|
9244
|
-
to[j] =
|
|
9243
|
+
var __spreadArray = exports && exports.__spreadArray || function(to, from9) {
|
|
9244
|
+
for (var i = 0, il = from9.length, j = to.length; i < il; i++, j++)
|
|
9245
|
+
to[j] = from9[i];
|
|
9245
9246
|
return to;
|
|
9246
9247
|
};
|
|
9247
9248
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -10522,11 +10523,8 @@ Summary:`;
|
|
|
10522
10523
|
annotation,
|
|
10523
10524
|
sourceResource: sourceDoc,
|
|
10524
10525
|
targetResource: targetDoc,
|
|
10525
|
-
|
|
10526
|
-
...
|
|
10527
|
-
// Keep for backward compatibility
|
|
10528
|
-
...targetContext ? { targetContext } : {},
|
|
10529
|
-
...{}
|
|
10526
|
+
context: generationContext,
|
|
10527
|
+
...targetContext ? { targetContext } : {}
|
|
10530
10528
|
};
|
|
10531
10529
|
return response;
|
|
10532
10530
|
}
|
|
@@ -11786,6 +11784,18 @@ async function readTagSchemasProjection(project) {
|
|
|
11786
11784
|
throw error;
|
|
11787
11785
|
}
|
|
11788
11786
|
}
|
|
11787
|
+
async function assembleResourceGraph(kb, resourceId10) {
|
|
11788
|
+
const eventQuery = new EventQuery(kb.eventStore.log.storage);
|
|
11789
|
+
const events = await eventQuery.getResourceEvents(resourceId10);
|
|
11790
|
+
const stored = await kb.eventStore.views.materializer.materialize(events, resourceId10);
|
|
11791
|
+
if (!stored) return null;
|
|
11792
|
+
const annotations = stored.annotations.annotations;
|
|
11793
|
+
const entityReferences = annotations.filter((a) => {
|
|
11794
|
+
if (a.motivation !== "linking") return false;
|
|
11795
|
+
return getEntityTypes({ body: a.body }).length > 0;
|
|
11796
|
+
});
|
|
11797
|
+
return { resource: stored.resource, annotations, entityReferences };
|
|
11798
|
+
}
|
|
11789
11799
|
|
|
11790
11800
|
// src/browser.ts
|
|
11791
11801
|
var Browser = class {
|
|
@@ -11828,28 +11838,17 @@ var Browser = class {
|
|
|
11828
11838
|
// ========================================================================
|
|
11829
11839
|
async handleBrowseResource(event) {
|
|
11830
11840
|
try {
|
|
11831
|
-
const
|
|
11832
|
-
|
|
11833
|
-
const stored = await this.kb.eventStore.views.materializer.materialize(events, resourceId(event.resourceId));
|
|
11834
|
-
if (!stored) {
|
|
11841
|
+
const response = await assembleResourceGraph(this.kb, resourceId(event.resourceId));
|
|
11842
|
+
if (!response) {
|
|
11835
11843
|
this.eventBus.get("browse:resource-failed").next({
|
|
11836
11844
|
correlationId: event.correlationId,
|
|
11837
11845
|
message: "Resource not found"
|
|
11838
11846
|
});
|
|
11839
11847
|
return;
|
|
11840
11848
|
}
|
|
11841
|
-
const annotations = stored.annotations.annotations;
|
|
11842
|
-
const entityReferences = annotations.filter((a) => {
|
|
11843
|
-
if (a.motivation !== "linking") return false;
|
|
11844
|
-
return getEntityTypes({ body: a.body }).length > 0;
|
|
11845
|
-
});
|
|
11846
11849
|
this.eventBus.get("browse:resource-result").next({
|
|
11847
11850
|
correlationId: event.correlationId,
|
|
11848
|
-
response
|
|
11849
|
-
resource: stored.resource,
|
|
11850
|
-
annotations,
|
|
11851
|
-
entityReferences
|
|
11852
|
-
}
|
|
11851
|
+
response
|
|
11853
11852
|
});
|
|
11854
11853
|
} catch (error) {
|
|
11855
11854
|
this.logger.error("Browse resource failed", { resourceId: event.resourceId, error: errField(error) });
|
|
@@ -12401,10 +12400,8 @@ var CloneTokenManager = class {
|
|
|
12401
12400
|
});
|
|
12402
12401
|
return;
|
|
12403
12402
|
}
|
|
12404
|
-
const
|
|
12405
|
-
const
|
|
12406
|
-
const validFormats = ["text/plain", "text/markdown"];
|
|
12407
|
-
const format = validFormats.includes(mediaType) ? mediaType : "text/plain";
|
|
12403
|
+
const base = baseMediaType(getPrimaryRepresentation(sourceDoc)?.mediaType ?? "text/plain");
|
|
12404
|
+
const format = isSupportedMediaType(base) && capabilitiesOf(base)?.authorable ? base : "text/plain";
|
|
12408
12405
|
const resolvedUri = deriveStorageUri(event.name, format);
|
|
12409
12406
|
const stored = await this.kb.content.store(Buffer.from(event.content), resolvedUri);
|
|
12410
12407
|
const newResourceId = await ResourceOperations.createResource(
|
|
@@ -12774,6 +12771,61 @@ function registerJobCommandHandlers(eventBus, jobQueue, project, parentLogger) {
|
|
|
12774
12771
|
});
|
|
12775
12772
|
}
|
|
12776
12773
|
});
|
|
12774
|
+
eventBus.get("job:complete").subscribe(async (event) => {
|
|
12775
|
+
try {
|
|
12776
|
+
const moved = await jobQueue.completeJob(
|
|
12777
|
+
jobId(event.jobId),
|
|
12778
|
+
event.result ?? {}
|
|
12779
|
+
);
|
|
12780
|
+
if (!moved) {
|
|
12781
|
+
logger.warn("job:complete for a job not in running", { jobId: event.jobId });
|
|
12782
|
+
}
|
|
12783
|
+
} catch (error) {
|
|
12784
|
+
logger.error("Failed to sync job completion to queue", {
|
|
12785
|
+
jobId: event.jobId,
|
|
12786
|
+
error: error.message
|
|
12787
|
+
});
|
|
12788
|
+
}
|
|
12789
|
+
});
|
|
12790
|
+
eventBus.get("job:fail").subscribe(async (event) => {
|
|
12791
|
+
try {
|
|
12792
|
+
const outcome = await jobQueue.failJob(jobId(event.jobId), event.error);
|
|
12793
|
+
if (outcome === "retried") {
|
|
12794
|
+
logger.info("Job re-queued for retry", { jobId: event.jobId });
|
|
12795
|
+
} else if (outcome === null) {
|
|
12796
|
+
logger.warn("job:fail for a job not in running", { jobId: event.jobId });
|
|
12797
|
+
}
|
|
12798
|
+
} catch (error) {
|
|
12799
|
+
logger.error("Failed to sync job failure to queue", {
|
|
12800
|
+
jobId: event.jobId,
|
|
12801
|
+
error: error.message
|
|
12802
|
+
});
|
|
12803
|
+
}
|
|
12804
|
+
});
|
|
12805
|
+
eventBus.get("job:report-progress").subscribe(async (event) => {
|
|
12806
|
+
try {
|
|
12807
|
+
await jobQueue.recordProgress(
|
|
12808
|
+
jobId(event.jobId),
|
|
12809
|
+
event.progress ?? { percentage: event.percentage }
|
|
12810
|
+
);
|
|
12811
|
+
} catch (error) {
|
|
12812
|
+
logger.error("Failed to record job progress", {
|
|
12813
|
+
jobId: event.jobId,
|
|
12814
|
+
error: error.message
|
|
12815
|
+
});
|
|
12816
|
+
}
|
|
12817
|
+
});
|
|
12818
|
+
eventBus.get("job:cancel-requested").subscribe(async (event) => {
|
|
12819
|
+
try {
|
|
12820
|
+
const cancelled = await jobQueue.cancelPendingJobs(event.jobType);
|
|
12821
|
+
logger.info("Cancel requested", { jobType: event.jobType, cancelled });
|
|
12822
|
+
} catch (error) {
|
|
12823
|
+
logger.error("Failed to cancel pending jobs", {
|
|
12824
|
+
jobType: event.jobType,
|
|
12825
|
+
error: error.message
|
|
12826
|
+
});
|
|
12827
|
+
}
|
|
12828
|
+
});
|
|
12777
12829
|
}
|
|
12778
12830
|
|
|
12779
12831
|
// src/handlers/index.ts
|
|
@@ -12847,6 +12899,8 @@ async function createKnowledgeSystemFromConfig(project, config, eventBus, logger
|
|
|
12847
12899
|
embedding: embeddingConfig.type,
|
|
12848
12900
|
model: embeddingConfig.model
|
|
12849
12901
|
});
|
|
12902
|
+
const store = vectorStore;
|
|
12903
|
+
registerVectorIndexSizeProvider(() => store.count());
|
|
12850
12904
|
}
|
|
12851
12905
|
const kb = await createKnowledgeBase(eventStore, project, graphDb, eventBus, logger, {
|
|
12852
12906
|
vectorStore,
|
|
@@ -12999,10 +13053,6 @@ var LocalTransport = class {
|
|
|
12999
13053
|
this.errorsSubject.complete();
|
|
13000
13054
|
}
|
|
13001
13055
|
};
|
|
13002
|
-
function primaryRepresentation(reps) {
|
|
13003
|
-
if (!reps) return void 0;
|
|
13004
|
-
return Array.isArray(reps) ? reps[0] : reps;
|
|
13005
|
-
}
|
|
13006
13056
|
var LocalContentTransport = class {
|
|
13007
13057
|
constructor(ks) {
|
|
13008
13058
|
this.ks = ks;
|
|
@@ -13013,16 +13063,16 @@ var LocalContentTransport = class {
|
|
|
13013
13063
|
"LocalContentTransport does not support putBinary() \u2014 create resources via bus emits (mark/yield namespaces) in local mode"
|
|
13014
13064
|
);
|
|
13015
13065
|
}
|
|
13016
|
-
async getBinary(resourceId10,
|
|
13017
|
-
busLog("GET", "content", { resourceId: resourceId10
|
|
13066
|
+
async getBinary(resourceId10, _options) {
|
|
13067
|
+
busLog("GET", "content", { resourceId: resourceId10 });
|
|
13018
13068
|
return withSpan(
|
|
13019
13069
|
"content.get",
|
|
13020
13070
|
() => this.loadBinary(resourceId10),
|
|
13021
13071
|
{ kind: SpanKind.INTERNAL, attrs: { "resource.id": resourceId10 } }
|
|
13022
13072
|
);
|
|
13023
13073
|
}
|
|
13024
|
-
async getBinaryStream(resourceId10,
|
|
13025
|
-
busLog("GET", "content", { resourceId: resourceId10,
|
|
13074
|
+
async getBinaryStream(resourceId10, _options) {
|
|
13075
|
+
busLog("GET", "content", { resourceId: resourceId10, stream: true });
|
|
13026
13076
|
return withSpan(
|
|
13027
13077
|
"content.get",
|
|
13028
13078
|
async () => {
|
|
@@ -13045,7 +13095,7 @@ var LocalContentTransport = class {
|
|
|
13045
13095
|
async loadBinary(resourceId10) {
|
|
13046
13096
|
const view = await this.ks.kb.views.get(resourceId10);
|
|
13047
13097
|
if (!view) throw new Error(`Resource not found: ${resourceId10}`);
|
|
13048
|
-
const rep =
|
|
13098
|
+
const rep = getPrimaryRepresentation(view.resource);
|
|
13049
13099
|
if (!rep?.storageUri) {
|
|
13050
13100
|
throw new Error(`Resource ${resourceId10} has no representation with a storageUri`);
|
|
13051
13101
|
}
|
|
@@ -13053,13 +13103,494 @@ var LocalContentTransport = class {
|
|
|
13053
13103
|
const data = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
13054
13104
|
return { data, contentType: rep.mediaType };
|
|
13055
13105
|
}
|
|
13106
|
+
/**
|
|
13107
|
+
* Assemble the resource's JSON-LD graph in-process from the KB — the local
|
|
13108
|
+
* realization of `IContentTransport.getResourceGraph` (symmetric with
|
|
13109
|
+
* getBinary; SIMPLER-JSON-LD.md decision 7). Local mode has no auth.
|
|
13110
|
+
*/
|
|
13111
|
+
async getResourceGraph(resourceId10, _options) {
|
|
13112
|
+
const graph = await assembleResourceGraph(this.ks.kb, resourceId10);
|
|
13113
|
+
if (!graph) throw new Error(`Resource not found: ${resourceId10}`);
|
|
13114
|
+
return graph;
|
|
13115
|
+
}
|
|
13056
13116
|
dispose() {
|
|
13057
13117
|
}
|
|
13058
13118
|
};
|
|
13059
13119
|
|
|
13060
|
-
// src/smelter
|
|
13120
|
+
// src/smelter.ts
|
|
13061
13121
|
var import_rxjs11 = __toESM(require_cjs());
|
|
13062
13122
|
var import_operators10 = __toESM(require_operators());
|
|
13123
|
+
function isWorkItem(input) {
|
|
13124
|
+
return input.type.startsWith("smelt:");
|
|
13125
|
+
}
|
|
13126
|
+
var Smelter = class _Smelter {
|
|
13127
|
+
constructor(events$, vectorStore, embeddingProvider, content, bus, chunkingConfig, timing, logger) {
|
|
13128
|
+
this.events$ = events$;
|
|
13129
|
+
this.vectorStore = vectorStore;
|
|
13130
|
+
this.embeddingProvider = embeddingProvider;
|
|
13131
|
+
this.content = content;
|
|
13132
|
+
this.bus = bus;
|
|
13133
|
+
this.chunkingConfig = chunkingConfig;
|
|
13134
|
+
this.timing = timing;
|
|
13135
|
+
this.logger = logger;
|
|
13136
|
+
}
|
|
13137
|
+
events$;
|
|
13138
|
+
vectorStore;
|
|
13139
|
+
embeddingProvider;
|
|
13140
|
+
content;
|
|
13141
|
+
bus;
|
|
13142
|
+
chunkingConfig;
|
|
13143
|
+
timing;
|
|
13144
|
+
logger;
|
|
13145
|
+
static RECONCILE_PAGE_SIZE = 200;
|
|
13146
|
+
/** Bound on concurrently in-flight reconcile work — a cold rebuild must not fan out unbounded embedding calls. */
|
|
13147
|
+
static RECONCILE_WAVE = 8;
|
|
13148
|
+
eventSubject = new import_rxjs11.Subject();
|
|
13149
|
+
sourceSubscription = null;
|
|
13150
|
+
pipelineSubscription = null;
|
|
13151
|
+
_eventsProcessed = 0;
|
|
13152
|
+
_reconcileState = { phase: "pending" };
|
|
13153
|
+
workDone = 0;
|
|
13154
|
+
workWaiter = null;
|
|
13155
|
+
get eventsProcessed() {
|
|
13156
|
+
return this._eventsProcessed;
|
|
13157
|
+
}
|
|
13158
|
+
get reconcileState() {
|
|
13159
|
+
return this._reconcileState;
|
|
13160
|
+
}
|
|
13161
|
+
initialize() {
|
|
13162
|
+
this.pipelineSubscription = this.eventSubject.pipe(
|
|
13163
|
+
(0, import_operators10.groupBy)((e) => e.resourceId ?? "__unknown__"),
|
|
13164
|
+
(0, import_operators10.mergeMap)(
|
|
13165
|
+
(group) => group.pipe(
|
|
13166
|
+
burstBuffer({
|
|
13167
|
+
burstWindowMs: this.timing.burstWindowMs,
|
|
13168
|
+
maxBatchSize: this.timing.maxBatchSize,
|
|
13169
|
+
idleTimeoutMs: this.timing.idleTimeoutMs
|
|
13170
|
+
}),
|
|
13171
|
+
(0, import_operators10.concatMap)((inputOrBatch) => {
|
|
13172
|
+
if (Array.isArray(inputOrBatch)) {
|
|
13173
|
+
return (0, import_rxjs11.from)(
|
|
13174
|
+
withActorSpan("smelter", "batch", async () => {
|
|
13175
|
+
this._eventsProcessed += await this.processBatch(inputOrBatch);
|
|
13176
|
+
}, { "batch.size": inputOrBatch.length })
|
|
13177
|
+
);
|
|
13178
|
+
}
|
|
13179
|
+
return (0, import_rxjs11.from)(
|
|
13180
|
+
withActorSpan("smelter", inputOrBatch.type, async () => {
|
|
13181
|
+
const ok = await this.safeProcessEvent(inputOrBatch);
|
|
13182
|
+
if (isWorkItem(inputOrBatch)) this.noteWorkDone(1);
|
|
13183
|
+
else if (ok) this._eventsProcessed++;
|
|
13184
|
+
})
|
|
13185
|
+
);
|
|
13186
|
+
})
|
|
13187
|
+
)
|
|
13188
|
+
)
|
|
13189
|
+
).subscribe({
|
|
13190
|
+
error: (err) => this.logger.error("Smelter pipeline error", { error: errField(err) })
|
|
13191
|
+
});
|
|
13192
|
+
this.sourceSubscription = this.events$.subscribe((event) => {
|
|
13193
|
+
this.logger.debug("Bus event received", { type: event.type, resourceId: event.resourceId });
|
|
13194
|
+
this.eventSubject.next(event);
|
|
13195
|
+
});
|
|
13196
|
+
this.logger.info("Smelter pipeline initialized");
|
|
13197
|
+
}
|
|
13198
|
+
stop() {
|
|
13199
|
+
this.sourceSubscription?.unsubscribe();
|
|
13200
|
+
this.sourceSubscription = null;
|
|
13201
|
+
this.pipelineSubscription?.unsubscribe();
|
|
13202
|
+
this.pipelineSubscription = null;
|
|
13203
|
+
this.eventSubject.complete();
|
|
13204
|
+
this.logger.info("Smelter stopped");
|
|
13205
|
+
}
|
|
13206
|
+
noteWorkDone(count) {
|
|
13207
|
+
this.workDone += count;
|
|
13208
|
+
if (this.workWaiter && this.workDone >= this.workWaiter.target) {
|
|
13209
|
+
this.workWaiter.resolve();
|
|
13210
|
+
this.workWaiter = null;
|
|
13211
|
+
}
|
|
13212
|
+
}
|
|
13213
|
+
/**
|
|
13214
|
+
* Returns the number of WIRE events processed without error (the S9b
|
|
13215
|
+
* oracle) — `smelt:*` work-item runs tick the drain counter instead.
|
|
13216
|
+
*/
|
|
13217
|
+
async processBatch(events) {
|
|
13218
|
+
let wireProcessed = 0;
|
|
13219
|
+
for (const run of partitionByType(events)) {
|
|
13220
|
+
const workRun = isWorkItem(run[0]);
|
|
13221
|
+
try {
|
|
13222
|
+
if (run.length === 1) {
|
|
13223
|
+
const ok = await this.safeProcessEvent(run[0]);
|
|
13224
|
+
if (ok && !workRun) wireProcessed++;
|
|
13225
|
+
} else {
|
|
13226
|
+
const processed = await this.applyBatchByType(run);
|
|
13227
|
+
if (!workRun) wireProcessed += processed;
|
|
13228
|
+
}
|
|
13229
|
+
} catch (error) {
|
|
13230
|
+
this.logger.error("Smelter failed to process batch run", {
|
|
13231
|
+
eventType: run[0].type,
|
|
13232
|
+
runSize: run.length,
|
|
13233
|
+
error: errField(error)
|
|
13234
|
+
});
|
|
13235
|
+
} finally {
|
|
13236
|
+
if (workRun) this.noteWorkDone(run.length);
|
|
13237
|
+
}
|
|
13238
|
+
}
|
|
13239
|
+
return wireProcessed;
|
|
13240
|
+
}
|
|
13241
|
+
/**
|
|
13242
|
+
* Batch-optimized processing for consecutive events of the same type.
|
|
13243
|
+
* Returns the number of events processed without error.
|
|
13244
|
+
*/
|
|
13245
|
+
async applyBatchByType(events) {
|
|
13246
|
+
switch (events[0].type) {
|
|
13247
|
+
case "yield:created":
|
|
13248
|
+
case "smelt:embed":
|
|
13249
|
+
return this.batchResourceCreated(events);
|
|
13250
|
+
case "mark:added":
|
|
13251
|
+
case "smelt:embed-annotation":
|
|
13252
|
+
return this.batchAnnotationAdded(events);
|
|
13253
|
+
default: {
|
|
13254
|
+
let processed = 0;
|
|
13255
|
+
for (const event of events) {
|
|
13256
|
+
if (await this.safeProcessEvent(event)) processed++;
|
|
13257
|
+
}
|
|
13258
|
+
return processed;
|
|
13259
|
+
}
|
|
13260
|
+
}
|
|
13261
|
+
}
|
|
13262
|
+
/** Returns true if the input was processed without error. */
|
|
13263
|
+
async safeProcessEvent(event) {
|
|
13264
|
+
try {
|
|
13265
|
+
await this.processEvent(event);
|
|
13266
|
+
return true;
|
|
13267
|
+
} catch (err) {
|
|
13268
|
+
this.logger.error("Smelter failed to process event", {
|
|
13269
|
+
type: event.type,
|
|
13270
|
+
resourceId: event.resourceId,
|
|
13271
|
+
error: errField(err)
|
|
13272
|
+
});
|
|
13273
|
+
return false;
|
|
13274
|
+
}
|
|
13275
|
+
}
|
|
13276
|
+
async processEvent(event) {
|
|
13277
|
+
switch (event.type) {
|
|
13278
|
+
case "yield:created":
|
|
13279
|
+
await this.embedResource(event, "Indexed resource");
|
|
13280
|
+
break;
|
|
13281
|
+
case "yield:updated":
|
|
13282
|
+
case "yield:representation-added":
|
|
13283
|
+
await this.embedResource(event, "Re-embedded resource");
|
|
13284
|
+
break;
|
|
13285
|
+
case "mark:archived":
|
|
13286
|
+
await this.handleResourceArchived(event);
|
|
13287
|
+
break;
|
|
13288
|
+
case "mark:added":
|
|
13289
|
+
await this.handleAnnotationAdded(event);
|
|
13290
|
+
break;
|
|
13291
|
+
case "mark:removed":
|
|
13292
|
+
await this.handleAnnotationRemoved(event);
|
|
13293
|
+
break;
|
|
13294
|
+
// Reconcile work items — same handlers, distinct provenance.
|
|
13295
|
+
case "smelt:embed":
|
|
13296
|
+
await this.embedResource(event, "Reconcile-indexed resource");
|
|
13297
|
+
break;
|
|
13298
|
+
case "smelt:purge":
|
|
13299
|
+
await this.handleResourcePurge(event);
|
|
13300
|
+
break;
|
|
13301
|
+
case "smelt:embed-annotation":
|
|
13302
|
+
await this.handleAnnotationAdded(event);
|
|
13303
|
+
break;
|
|
13304
|
+
case "smelt:purge-annotation":
|
|
13305
|
+
await this.handleAnnotationRemoved(event);
|
|
13306
|
+
break;
|
|
13307
|
+
}
|
|
13308
|
+
}
|
|
13309
|
+
async handleResourcePurge(event) {
|
|
13310
|
+
const rid = event.resourceId;
|
|
13311
|
+
if (!rid) return;
|
|
13312
|
+
await this.vectorStore.deleteResourceVectors(resourceId(rid));
|
|
13313
|
+
this.logger.info("Reconcile deleted orphan resource vectors", { resourceId: rid });
|
|
13314
|
+
}
|
|
13315
|
+
/**
|
|
13316
|
+
* Resolve a resource's embeddable text: bytes via the content transport,
|
|
13317
|
+
* gated to media types that decode as text, decoded charset-aware. The
|
|
13318
|
+
* checksum is over the raw bytes actually read — stamped onto the vectors
|
|
13319
|
+
* so reconciliation can compare against the catalog's claim (S12). Returns
|
|
13320
|
+
* null (logged) when the resource doesn't decode as text, is unavailable,
|
|
13321
|
+
* or is empty — callers skip it.
|
|
13322
|
+
*/
|
|
13323
|
+
async fetchEmbeddableText(resourceId10) {
|
|
13324
|
+
try {
|
|
13325
|
+
const { data, contentType } = await this.content.getBinary(resourceId(resourceId10));
|
|
13326
|
+
if (textExtractionOf(contentType) !== "decode") {
|
|
13327
|
+
this.logger.debug("Skipping resource that does not decode as text", { resourceId: resourceId10, contentType });
|
|
13328
|
+
return null;
|
|
13329
|
+
}
|
|
13330
|
+
const bytes = Buffer.from(data);
|
|
13331
|
+
const text = decodeRepresentation(bytes, contentType);
|
|
13332
|
+
return text.trim() ? { text, checksum: calculateChecksum(bytes) } : null;
|
|
13333
|
+
} catch (error) {
|
|
13334
|
+
this.logger.warn("Content unavailable for embedding", { resourceId: resourceId10, error: errField(error) });
|
|
13335
|
+
return null;
|
|
13336
|
+
}
|
|
13337
|
+
}
|
|
13338
|
+
async embedResource(event, logMessage) {
|
|
13339
|
+
const rid = event.resourceId;
|
|
13340
|
+
if (!rid) return;
|
|
13341
|
+
const fetched = await this.fetchEmbeddableText(rid);
|
|
13342
|
+
if (!fetched) return;
|
|
13343
|
+
const chunks = chunkText(fetched.text, this.chunkingConfig);
|
|
13344
|
+
if (chunks.length === 0) return;
|
|
13345
|
+
const embeddings = await this.embeddingProvider.embedBatch(chunks);
|
|
13346
|
+
const embeddingChunks = chunks.map((t, i) => ({
|
|
13347
|
+
chunkIndex: i,
|
|
13348
|
+
text: t,
|
|
13349
|
+
embedding: embeddings[i]
|
|
13350
|
+
}));
|
|
13351
|
+
await this.vectorStore.upsertResourceVectors(resourceId(rid), embeddingChunks, fetched.checksum);
|
|
13352
|
+
this.logger.info(logMessage, { resourceId: rid, chunks: chunks.length });
|
|
13353
|
+
}
|
|
13354
|
+
async handleResourceArchived(event) {
|
|
13355
|
+
const rid = event.resourceId;
|
|
13356
|
+
if (!rid) return;
|
|
13357
|
+
await this.vectorStore.deleteResourceVectors(resourceId(rid));
|
|
13358
|
+
await this.vectorStore.deleteAnnotationVectorsForResource(resourceId(rid));
|
|
13359
|
+
this.logger.info("Deleted vectors for archived resource", { resourceId: rid });
|
|
13360
|
+
}
|
|
13361
|
+
async handleAnnotationAdded(event) {
|
|
13362
|
+
const annotation = event.payload.annotation;
|
|
13363
|
+
if (!annotation?.id) return;
|
|
13364
|
+
const rid = event.resourceId;
|
|
13365
|
+
if (!rid) return;
|
|
13366
|
+
const selector = getTargetSelector(annotation.target);
|
|
13367
|
+
const exactText = getExactText(selector);
|
|
13368
|
+
if (!exactText?.trim()) return;
|
|
13369
|
+
const aid = annotationId(annotation.id);
|
|
13370
|
+
const embedding = await this.embeddingProvider.embed(exactText);
|
|
13371
|
+
const payload = {
|
|
13372
|
+
annotationId: aid,
|
|
13373
|
+
resourceId: resourceId(rid),
|
|
13374
|
+
motivation: annotation.motivation ?? "",
|
|
13375
|
+
entityTypes: annotation.entityTypes ?? [],
|
|
13376
|
+
exactText
|
|
13377
|
+
};
|
|
13378
|
+
await this.vectorStore.upsertAnnotationVector(aid, embedding, payload);
|
|
13379
|
+
this.logger.info("Indexed annotation", { annotationId: String(aid) });
|
|
13380
|
+
}
|
|
13381
|
+
async handleAnnotationRemoved(event) {
|
|
13382
|
+
const annotationId5 = event.payload.annotationId;
|
|
13383
|
+
if (!annotationId5) return;
|
|
13384
|
+
const aid = annotationId(annotationId5);
|
|
13385
|
+
await this.vectorStore.deleteAnnotationVector(aid);
|
|
13386
|
+
this.logger.info("Deleted annotation vector", { annotationId: annotationId5 });
|
|
13387
|
+
}
|
|
13388
|
+
/**
|
|
13389
|
+
* Batch-embed chunks from multiple yield:created events in a single
|
|
13390
|
+
* embedBatch() call, then index per resource.
|
|
13391
|
+
*/
|
|
13392
|
+
async batchResourceCreated(events) {
|
|
13393
|
+
const resourceData = [];
|
|
13394
|
+
const allChunks = [];
|
|
13395
|
+
for (const event of events) {
|
|
13396
|
+
const rid = event.resourceId;
|
|
13397
|
+
if (!rid) continue;
|
|
13398
|
+
const fetched = await this.fetchEmbeddableText(rid);
|
|
13399
|
+
if (!fetched) continue;
|
|
13400
|
+
const chunks = chunkText(fetched.text, this.chunkingConfig);
|
|
13401
|
+
if (chunks.length === 0) continue;
|
|
13402
|
+
resourceData.push({ rid: resourceId(rid), chunks, checksum: fetched.checksum });
|
|
13403
|
+
allChunks.push(...chunks);
|
|
13404
|
+
}
|
|
13405
|
+
if (allChunks.length === 0) return events.length;
|
|
13406
|
+
const allEmbeddings = await this.embeddingProvider.embedBatch(allChunks);
|
|
13407
|
+
let offset = 0;
|
|
13408
|
+
for (const { rid, chunks, checksum } of resourceData) {
|
|
13409
|
+
const embeddingChunks = chunks.map((t, i) => ({
|
|
13410
|
+
chunkIndex: i,
|
|
13411
|
+
text: t,
|
|
13412
|
+
embedding: allEmbeddings[offset + i]
|
|
13413
|
+
}));
|
|
13414
|
+
await this.vectorStore.upsertResourceVectors(rid, embeddingChunks, checksum);
|
|
13415
|
+
this.logger.info("Batch-indexed resource", { resourceId: String(rid), chunks: chunks.length });
|
|
13416
|
+
offset += chunks.length;
|
|
13417
|
+
}
|
|
13418
|
+
return events.length;
|
|
13419
|
+
}
|
|
13420
|
+
/**
|
|
13421
|
+
* Batch-embed exact texts from multiple mark:added events in a single
|
|
13422
|
+
* embedBatch() call, then index per annotation.
|
|
13423
|
+
*/
|
|
13424
|
+
async batchAnnotationAdded(events) {
|
|
13425
|
+
const annotationData = [];
|
|
13426
|
+
for (const event of events) {
|
|
13427
|
+
const annotation = event.payload.annotation;
|
|
13428
|
+
if (!annotation?.id) continue;
|
|
13429
|
+
const rid = event.resourceId;
|
|
13430
|
+
if (!rid) continue;
|
|
13431
|
+
const selector = getTargetSelector(annotation.target);
|
|
13432
|
+
const exactText = getExactText(selector);
|
|
13433
|
+
if (!exactText?.trim()) continue;
|
|
13434
|
+
annotationData.push({
|
|
13435
|
+
rid: resourceId(rid),
|
|
13436
|
+
aid: annotationId(annotation.id),
|
|
13437
|
+
exactText,
|
|
13438
|
+
motivation: annotation.motivation ?? "",
|
|
13439
|
+
entityTypes: annotation.entityTypes ?? []
|
|
13440
|
+
});
|
|
13441
|
+
}
|
|
13442
|
+
if (annotationData.length === 0) return events.length;
|
|
13443
|
+
const allEmbeddings = await this.embeddingProvider.embedBatch(
|
|
13444
|
+
annotationData.map((a) => a.exactText)
|
|
13445
|
+
);
|
|
13446
|
+
for (let i = 0; i < annotationData.length; i++) {
|
|
13447
|
+
const { rid, aid, exactText, motivation, entityTypes } = annotationData[i];
|
|
13448
|
+
const payload = {
|
|
13449
|
+
annotationId: aid,
|
|
13450
|
+
resourceId: rid,
|
|
13451
|
+
motivation,
|
|
13452
|
+
entityTypes,
|
|
13453
|
+
exactText
|
|
13454
|
+
};
|
|
13455
|
+
await this.vectorStore.upsertAnnotationVector(aid, allEmbeddings[i], payload);
|
|
13456
|
+
this.logger.info("Batch-indexed annotation", { annotationId: String(aid) });
|
|
13457
|
+
}
|
|
13458
|
+
return events.length;
|
|
13459
|
+
}
|
|
13460
|
+
// ── Reconciliation ───────────────────────────────────────────────────
|
|
13461
|
+
/**
|
|
13462
|
+
* Reconcile the vector store against the KS catalog.
|
|
13463
|
+
*
|
|
13464
|
+
* Lists what IS indexed (via the store's id enumeration) and what SHOULD
|
|
13465
|
+
* be (non-archived resources with embeddable media types, plus their
|
|
13466
|
+
* exact-text annotations, via the `browse:*` RPC channels), then plans the
|
|
13467
|
+
* diff as `smelt:*` work items — embeds for what's missing, purges for
|
|
13468
|
+
* what shouldn't be there — and drains them through the pipeline mailbox.
|
|
13469
|
+
* Work items share the per-resource lanes with live events, so a reconcile
|
|
13470
|
+
* re-embed can never interleave with (or stale-overwrite) live processing
|
|
13471
|
+
* of the same resource (axioms S1/S2). Waves of RECONCILE_WAVE bound how
|
|
13472
|
+
* many embedding calls a cold rebuild has in flight.
|
|
13473
|
+
*
|
|
13474
|
+
* Call after the live subscription is attached so nothing falls in the
|
|
13475
|
+
* gap. The index snapshot is taken BEFORE the catalog listing so a
|
|
13476
|
+
* resource indexed by a live event mid-reconcile is never mistaken for an
|
|
13477
|
+
* orphan; convergence holds because every upsert replaces a resource's
|
|
13478
|
+
* full vector set from current content.
|
|
13479
|
+
*/
|
|
13480
|
+
async reconcile() {
|
|
13481
|
+
if (!this.pipelineSubscription) {
|
|
13482
|
+
throw new Error("Smelter.reconcile() requires initialize() \u2014 work items drain through the pipeline");
|
|
13483
|
+
}
|
|
13484
|
+
this._reconcileState = { phase: "running" };
|
|
13485
|
+
try {
|
|
13486
|
+
const [indexedResources, indexedAnnotations] = await Promise.all([
|
|
13487
|
+
this.vectorStore.listResourceChecksums(),
|
|
13488
|
+
this.vectorStore.listAnnotationIds()
|
|
13489
|
+
]);
|
|
13490
|
+
const resources = await this.listAllResources();
|
|
13491
|
+
this.logger.info("Reconcile started", {
|
|
13492
|
+
indexedResources: indexedResources.size,
|
|
13493
|
+
indexedAnnotations: indexedAnnotations.size,
|
|
13494
|
+
liveResources: resources.length
|
|
13495
|
+
});
|
|
13496
|
+
const embeddable = /* @__PURE__ */ new Map();
|
|
13497
|
+
for (const resource of resources) {
|
|
13498
|
+
const mediaType = getPrimaryMediaType(resource);
|
|
13499
|
+
if (resource["@id"] && mediaType && textExtractionOf(mediaType) === "decode") {
|
|
13500
|
+
embeddable.set(resource["@id"], getPrimaryRepresentation(resource)?.checksum);
|
|
13501
|
+
}
|
|
13502
|
+
}
|
|
13503
|
+
const work = [];
|
|
13504
|
+
for (const rid of indexedResources.keys()) {
|
|
13505
|
+
if (!embeddable.has(rid)) work.push({ type: "smelt:purge", resourceId: rid, payload: {} });
|
|
13506
|
+
}
|
|
13507
|
+
for (const [rid, catalogChecksum] of embeddable) {
|
|
13508
|
+
if (!indexedResources.has(rid)) {
|
|
13509
|
+
work.push({ type: "smelt:embed", resourceId: rid, payload: {} });
|
|
13510
|
+
} else if (catalogChecksum !== void 0 && indexedResources.get(rid) !== catalogChecksum) {
|
|
13511
|
+
work.push({ type: "smelt:embed", resourceId: rid, payload: {} });
|
|
13512
|
+
}
|
|
13513
|
+
}
|
|
13514
|
+
const liveAnnotationIds = /* @__PURE__ */ new Set();
|
|
13515
|
+
for (const resource of resources) {
|
|
13516
|
+
const rid = resource["@id"];
|
|
13517
|
+
if (!rid) continue;
|
|
13518
|
+
const { annotations } = await busRequest(
|
|
13519
|
+
this.bus,
|
|
13520
|
+
"browse:annotations-requested",
|
|
13521
|
+
{ resourceId: rid },
|
|
13522
|
+
"browse:annotations-result",
|
|
13523
|
+
"browse:annotations-failed"
|
|
13524
|
+
);
|
|
13525
|
+
for (const annotation of annotations) {
|
|
13526
|
+
const exactText = getExactText(getTargetSelector(annotation.target));
|
|
13527
|
+
if (!annotation.id || !exactText?.trim()) continue;
|
|
13528
|
+
liveAnnotationIds.add(annotation.id);
|
|
13529
|
+
if (!indexedAnnotations.has(annotation.id)) {
|
|
13530
|
+
work.push({ type: "smelt:embed-annotation", resourceId: rid, payload: { annotation } });
|
|
13531
|
+
}
|
|
13532
|
+
}
|
|
13533
|
+
}
|
|
13534
|
+
for (const aid of indexedAnnotations) {
|
|
13535
|
+
if (!liveAnnotationIds.has(aid)) {
|
|
13536
|
+
work.push({ type: "smelt:purge-annotation", resourceId: aid, payload: { annotationId: aid } });
|
|
13537
|
+
}
|
|
13538
|
+
}
|
|
13539
|
+
await this.drain(work);
|
|
13540
|
+
const summary = {
|
|
13541
|
+
resourcesEmbedded: work.filter((w) => w.type === "smelt:embed").length,
|
|
13542
|
+
resourceVectorsDeleted: work.filter((w) => w.type === "smelt:purge").length,
|
|
13543
|
+
annotationsEmbedded: work.filter((w) => w.type === "smelt:embed-annotation").length,
|
|
13544
|
+
annotationVectorsDeleted: work.filter((w) => w.type === "smelt:purge-annotation").length
|
|
13545
|
+
};
|
|
13546
|
+
this._reconcileState = { phase: "done", summary };
|
|
13547
|
+
this.logger.info("Reconcile complete", { ...summary });
|
|
13548
|
+
return summary;
|
|
13549
|
+
} catch (error) {
|
|
13550
|
+
this._reconcileState = {
|
|
13551
|
+
phase: "failed",
|
|
13552
|
+
error: error instanceof Error ? error.message : String(error)
|
|
13553
|
+
};
|
|
13554
|
+
this.logger.error("Reconcile failed", { error: errField(error) });
|
|
13555
|
+
throw error;
|
|
13556
|
+
}
|
|
13557
|
+
}
|
|
13558
|
+
/**
|
|
13559
|
+
* Enqueue planner work through the mailbox in bounded waves and await
|
|
13560
|
+
* completion. The pipeline ticks `noteWorkDone` for every consumed work
|
|
13561
|
+
* item (success or failure — failures are logged like any live event), so
|
|
13562
|
+
* each wave's waiter resolves exactly when its items have been processed.
|
|
13563
|
+
*/
|
|
13564
|
+
async drain(work) {
|
|
13565
|
+
for (let i = 0; i < work.length; i += _Smelter.RECONCILE_WAVE) {
|
|
13566
|
+
const wave = work.slice(i, i + _Smelter.RECONCILE_WAVE);
|
|
13567
|
+
const done = new Promise((resolve2) => {
|
|
13568
|
+
this.workWaiter = { target: this.workDone + wave.length, resolve: resolve2 };
|
|
13569
|
+
});
|
|
13570
|
+
for (const item of wave) this.eventSubject.next(item);
|
|
13571
|
+
await done;
|
|
13572
|
+
}
|
|
13573
|
+
}
|
|
13574
|
+
/** Page through `browse:resources-requested` until the catalog is exhausted. */
|
|
13575
|
+
async listAllResources() {
|
|
13576
|
+
const all = [];
|
|
13577
|
+
for (; ; ) {
|
|
13578
|
+
const page = await busRequest(
|
|
13579
|
+
this.bus,
|
|
13580
|
+
"browse:resources-requested",
|
|
13581
|
+
{ archived: false, offset: all.length, limit: _Smelter.RECONCILE_PAGE_SIZE },
|
|
13582
|
+
"browse:resources-result",
|
|
13583
|
+
"browse:resources-failed"
|
|
13584
|
+
);
|
|
13585
|
+
all.push(...page.resources);
|
|
13586
|
+
if (page.resources.length === 0 || all.length >= page.total) return all;
|
|
13587
|
+
}
|
|
13588
|
+
}
|
|
13589
|
+
};
|
|
13590
|
+
|
|
13591
|
+
// src/smelter-actor-state-unit.ts
|
|
13592
|
+
var import_rxjs12 = __toESM(require_cjs());
|
|
13593
|
+
var import_operators11 = __toESM(require_operators());
|
|
13063
13594
|
var SMELTER_CHANNELS = [
|
|
13064
13595
|
"yield:created",
|
|
13065
13596
|
"yield:updated",
|
|
@@ -13071,10 +13602,10 @@ var SMELTER_CHANNELS = [
|
|
|
13071
13602
|
function createSmelterActorStateUnit(options) {
|
|
13072
13603
|
const { bus } = options;
|
|
13073
13604
|
let started = false;
|
|
13074
|
-
const events$ = (0,
|
|
13605
|
+
const events$ = (0, import_rxjs12.merge)(
|
|
13075
13606
|
...SMELTER_CHANNELS.map(
|
|
13076
13607
|
(channel) => bus.on$(channel).pipe(
|
|
13077
|
-
(0,
|
|
13608
|
+
(0, import_operators11.map)((payload) => ({
|
|
13078
13609
|
type: channel,
|
|
13079
13610
|
resourceId: payload.resourceId,
|
|
13080
13611
|
payload
|
|
@@ -13084,7 +13615,6 @@ function createSmelterActorStateUnit(options) {
|
|
|
13084
13615
|
);
|
|
13085
13616
|
return {
|
|
13086
13617
|
events$,
|
|
13087
|
-
emit: (channel, payload) => bus.emit(channel, payload),
|
|
13088
13618
|
start: () => {
|
|
13089
13619
|
if (started) return;
|
|
13090
13620
|
started = true;
|
|
@@ -13215,7 +13745,7 @@ async function exportBackup(options, output) {
|
|
|
13215
13745
|
let totalContentBytes = 0;
|
|
13216
13746
|
for (const [storageUri, mediaType] of contentRefs) {
|
|
13217
13747
|
const data = await content.retrieve(storageUri);
|
|
13218
|
-
const ext =
|
|
13748
|
+
const ext = extensionForMediaType(mediaType);
|
|
13219
13749
|
contentBlobs.set(storageUri, { data, ext });
|
|
13220
13750
|
totalContentBytes += data.length;
|
|
13221
13751
|
}
|
|
@@ -13279,8 +13809,8 @@ function collectContentRefs(streamData) {
|
|
|
13279
13809
|
}
|
|
13280
13810
|
|
|
13281
13811
|
// src/exchange/replay.ts
|
|
13282
|
-
var
|
|
13283
|
-
var
|
|
13812
|
+
var import_rxjs13 = __toESM(require_cjs());
|
|
13813
|
+
var import_operators12 = __toESM(require_operators());
|
|
13284
13814
|
var REPLAY_TIMEOUT_MS = 3e4;
|
|
13285
13815
|
async function replayEventStream(jsonl, eventBus, resolveBlob, contentStore, logger) {
|
|
13286
13816
|
const lines = jsonl.trim().split("\n").filter((l) => l.length > 0);
|
|
@@ -13344,12 +13874,12 @@ async function replayEvent(event, eventBus, resolveBlob, contentStore, stats, lo
|
|
|
13344
13874
|
}
|
|
13345
13875
|
}
|
|
13346
13876
|
async function replayEntityTypeAdded(event, eventBus, logger) {
|
|
13347
|
-
const result$ = (0,
|
|
13348
|
-
eventBus.get("frame:entity-type-added").pipe((0,
|
|
13349
|
-
eventBus.get("frame:entity-type-add-failed").pipe((0,
|
|
13877
|
+
const result$ = (0, import_rxjs13.race)(
|
|
13878
|
+
eventBus.get("frame:entity-type-added").pipe((0, import_operators12.map)(() => "ok")),
|
|
13879
|
+
eventBus.get("frame:entity-type-add-failed").pipe((0, import_operators12.map)((e) => {
|
|
13350
13880
|
throw new Error(e.message);
|
|
13351
13881
|
})),
|
|
13352
|
-
(0,
|
|
13882
|
+
(0, import_rxjs13.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators12.map)(() => {
|
|
13353
13883
|
throw new Error("Timeout waiting for frame:entity-type-added");
|
|
13354
13884
|
}))
|
|
13355
13885
|
);
|
|
@@ -13357,7 +13887,7 @@ async function replayEntityTypeAdded(event, eventBus, logger) {
|
|
|
13357
13887
|
tag: event.payload.entityType,
|
|
13358
13888
|
_userId: event.userId
|
|
13359
13889
|
});
|
|
13360
|
-
await (0,
|
|
13890
|
+
await (0, import_rxjs13.firstValueFrom)(result$);
|
|
13361
13891
|
logger?.debug("Replayed entitytype.added", { entityType: event.payload.entityType });
|
|
13362
13892
|
}
|
|
13363
13893
|
async function replayResourceCreated(event, eventBus, resolveBlob, contentStore, logger) {
|
|
@@ -13366,14 +13896,15 @@ async function replayResourceCreated(event, eventBus, resolveBlob, contentStore,
|
|
|
13366
13896
|
if (!blob) {
|
|
13367
13897
|
throw new Error(`Missing content blob for checksum ${payload.contentChecksum}`);
|
|
13368
13898
|
}
|
|
13369
|
-
const
|
|
13899
|
+
const base = baseMediaType(payload.format);
|
|
13900
|
+
const resolvedUri = payload.storageUri || deriveStorageUri(payload.name, isSupportedMediaType(base) ? base : "application/octet-stream");
|
|
13370
13901
|
const stored = await contentStore.store(blob, resolvedUri);
|
|
13371
|
-
const result$ = (0,
|
|
13372
|
-
eventBus.get("yield:create-ok").pipe((0,
|
|
13373
|
-
eventBus.get("yield:create-failed").pipe((0,
|
|
13902
|
+
const result$ = (0, import_rxjs13.race)(
|
|
13903
|
+
eventBus.get("yield:create-ok").pipe((0, import_operators12.map)((r) => r)),
|
|
13904
|
+
eventBus.get("yield:create-failed").pipe((0, import_operators12.map)((e) => {
|
|
13374
13905
|
throw new Error(e.message);
|
|
13375
13906
|
})),
|
|
13376
|
-
(0,
|
|
13907
|
+
(0, import_rxjs13.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators12.map)(() => {
|
|
13377
13908
|
throw new Error("Timeout waiting for yield:create-ok");
|
|
13378
13909
|
}))
|
|
13379
13910
|
);
|
|
@@ -13390,16 +13921,16 @@ async function replayResourceCreated(event, eventBus, resolveBlob, contentStore,
|
|
|
13390
13921
|
generatedFrom: payload.generatedFrom,
|
|
13391
13922
|
generationPrompt: payload.generationPrompt
|
|
13392
13923
|
});
|
|
13393
|
-
await (0,
|
|
13924
|
+
await (0, import_rxjs13.firstValueFrom)(result$);
|
|
13394
13925
|
logger?.debug("Replayed resource.created", { name: payload.name });
|
|
13395
13926
|
}
|
|
13396
13927
|
async function replayAnnotationAdded(event, eventBus, logger) {
|
|
13397
|
-
const result$ = (0,
|
|
13398
|
-
eventBus.get("mark:create-ok").pipe((0,
|
|
13399
|
-
eventBus.get("mark:create-failed").pipe((0,
|
|
13928
|
+
const result$ = (0, import_rxjs13.race)(
|
|
13929
|
+
eventBus.get("mark:create-ok").pipe((0, import_operators12.map)(() => "ok")),
|
|
13930
|
+
eventBus.get("mark:create-failed").pipe((0, import_operators12.map)((e) => {
|
|
13400
13931
|
throw new Error(e.message);
|
|
13401
13932
|
})),
|
|
13402
|
-
(0,
|
|
13933
|
+
(0, import_rxjs13.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators12.map)(() => {
|
|
13403
13934
|
throw new Error("Timeout waiting for mark:create-ok");
|
|
13404
13935
|
}))
|
|
13405
13936
|
);
|
|
@@ -13408,16 +13939,16 @@ async function replayAnnotationAdded(event, eventBus, logger) {
|
|
|
13408
13939
|
_userId: event.userId,
|
|
13409
13940
|
resourceId: event.resourceId
|
|
13410
13941
|
});
|
|
13411
|
-
await (0,
|
|
13942
|
+
await (0, import_rxjs13.firstValueFrom)(result$);
|
|
13412
13943
|
logger?.debug("Replayed annotation.added", { annotationId: event.payload.annotation.id });
|
|
13413
13944
|
}
|
|
13414
13945
|
async function replayAnnotationBodyUpdated(event, eventBus, logger) {
|
|
13415
|
-
const result$ = (0,
|
|
13416
|
-
eventBus.get("mark:body-updated").pipe((0,
|
|
13417
|
-
eventBus.get("mark:body-update-failed").pipe((0,
|
|
13946
|
+
const result$ = (0, import_rxjs13.race)(
|
|
13947
|
+
eventBus.get("mark:body-updated").pipe((0, import_operators12.map)(() => "ok")),
|
|
13948
|
+
eventBus.get("mark:body-update-failed").pipe((0, import_operators12.map)((e) => {
|
|
13418
13949
|
throw new Error(e.message);
|
|
13419
13950
|
})),
|
|
13420
|
-
(0,
|
|
13951
|
+
(0, import_rxjs13.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators12.map)(() => {
|
|
13421
13952
|
throw new Error("Timeout waiting for mark:body-updated");
|
|
13422
13953
|
}))
|
|
13423
13954
|
);
|
|
@@ -13427,16 +13958,16 @@ async function replayAnnotationBodyUpdated(event, eventBus, logger) {
|
|
|
13427
13958
|
resourceId: event.resourceId,
|
|
13428
13959
|
operations: event.payload.operations
|
|
13429
13960
|
});
|
|
13430
|
-
await (0,
|
|
13961
|
+
await (0, import_rxjs13.firstValueFrom)(result$);
|
|
13431
13962
|
logger?.debug("Replayed annotation.body.updated", { annotationId: event.payload.annotationId });
|
|
13432
13963
|
}
|
|
13433
13964
|
async function replayAnnotationRemoved(event, eventBus, logger) {
|
|
13434
|
-
const result$ = (0,
|
|
13435
|
-
eventBus.get("mark:delete-ok").pipe((0,
|
|
13436
|
-
eventBus.get("mark:delete-failed").pipe((0,
|
|
13965
|
+
const result$ = (0, import_rxjs13.race)(
|
|
13966
|
+
eventBus.get("mark:delete-ok").pipe((0, import_operators12.map)(() => "ok")),
|
|
13967
|
+
eventBus.get("mark:delete-failed").pipe((0, import_operators12.map)((e) => {
|
|
13437
13968
|
throw new Error(e.message);
|
|
13438
13969
|
})),
|
|
13439
|
-
(0,
|
|
13970
|
+
(0, import_rxjs13.timer)(REPLAY_TIMEOUT_MS).pipe((0, import_operators12.map)(() => {
|
|
13440
13971
|
throw new Error("Timeout waiting for mark:delete-ok");
|
|
13441
13972
|
}))
|
|
13442
13973
|
);
|
|
@@ -13445,7 +13976,7 @@ async function replayAnnotationRemoved(event, eventBus, logger) {
|
|
|
13445
13976
|
_userId: event.userId,
|
|
13446
13977
|
resourceId: event.resourceId
|
|
13447
13978
|
});
|
|
13448
|
-
await (0,
|
|
13979
|
+
await (0, import_rxjs13.firstValueFrom)(result$);
|
|
13449
13980
|
logger?.debug("Replayed annotation.removed", { annotationId: event.payload.annotationId });
|
|
13450
13981
|
}
|
|
13451
13982
|
async function replayResourceArchived(event, eventBus, logger) {
|
|
@@ -13625,7 +14156,7 @@ async function exportLinkedData(options, output) {
|
|
|
13625
14156
|
for (const [storageUri, mediaType] of contentRefs) {
|
|
13626
14157
|
try {
|
|
13627
14158
|
const data = await content.retrieve(storageUri);
|
|
13628
|
-
const ext =
|
|
14159
|
+
const ext = extensionForMediaType(mediaType);
|
|
13629
14160
|
contentBlobs.set(storageUri, { data, ext });
|
|
13630
14161
|
} catch (err) {
|
|
13631
14162
|
logger?.warn("Failed to retrieve content blob", { storageUri, error: String(err) });
|
|
@@ -13704,7 +14235,7 @@ function buildResourceJsonLd(resource, annotations, sourceUrl) {
|
|
|
13704
14235
|
if (rep.checksum) {
|
|
13705
14236
|
const rawChecksum = rep.checksum.startsWith("sha256:") ? rep.checksum.slice(7) : rep.checksum;
|
|
13706
14237
|
mediaObj["sha256"] = rawChecksum;
|
|
13707
|
-
const ext =
|
|
14238
|
+
const ext = extensionForMediaType(rep.mediaType);
|
|
13708
14239
|
mediaObj["name"] = `${rawChecksum}${ext}`;
|
|
13709
14240
|
}
|
|
13710
14241
|
if (rep.language) mediaObj["inLanguage"] = rep.language;
|
|
@@ -13730,8 +14261,8 @@ function collectContentRefsFromResource(resource, refs) {
|
|
|
13730
14261
|
}
|
|
13731
14262
|
|
|
13732
14263
|
// src/exchange/linked-data-importer.ts
|
|
13733
|
-
var
|
|
13734
|
-
var
|
|
14264
|
+
var import_rxjs14 = __toESM(require_cjs());
|
|
14265
|
+
var import_operators13 = __toESM(require_operators());
|
|
13735
14266
|
var IMPORT_TIMEOUT_MS = 3e4;
|
|
13736
14267
|
function stripUriToId(uri) {
|
|
13737
14268
|
if (!uri.includes("/")) return uri;
|
|
@@ -13833,12 +14364,12 @@ async function importLinkedData(archive, options) {
|
|
|
13833
14364
|
};
|
|
13834
14365
|
}
|
|
13835
14366
|
async function addEntityType(entityType2, userId3, eventBus, logger) {
|
|
13836
|
-
const result$ = (0,
|
|
13837
|
-
eventBus.get("frame:entity-type-added").pipe((0,
|
|
13838
|
-
eventBus.get("frame:entity-type-add-failed").pipe((0,
|
|
14367
|
+
const result$ = (0, import_rxjs14.race)(
|
|
14368
|
+
eventBus.get("frame:entity-type-added").pipe((0, import_operators13.map)(() => "ok")),
|
|
14369
|
+
eventBus.get("frame:entity-type-add-failed").pipe((0, import_operators13.map)((e) => {
|
|
13839
14370
|
throw new Error(e.message);
|
|
13840
14371
|
})),
|
|
13841
|
-
(0,
|
|
14372
|
+
(0, import_rxjs14.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators13.map)(() => {
|
|
13842
14373
|
throw new Error("Timeout waiting for frame:entity-type-added");
|
|
13843
14374
|
}))
|
|
13844
14375
|
);
|
|
@@ -13846,7 +14377,7 @@ async function addEntityType(entityType2, userId3, eventBus, logger) {
|
|
|
13846
14377
|
tag: entityType2,
|
|
13847
14378
|
_userId: userId3
|
|
13848
14379
|
});
|
|
13849
|
-
await (0,
|
|
14380
|
+
await (0, import_rxjs14.firstValueFrom)(result$);
|
|
13850
14381
|
logger?.debug("Added entity type", { entityType: entityType2 });
|
|
13851
14382
|
}
|
|
13852
14383
|
async function importResource(doc, userId3, eventBus, contentStore, resolveBlob, logger) {
|
|
@@ -13870,14 +14401,15 @@ async function importResource(doc, userId3, eventBus, contentStore, resolveBlob,
|
|
|
13870
14401
|
if (!blob) {
|
|
13871
14402
|
throw new Error(`Missing content blob for checksum ${contentChecksum} (resource "${name}")`);
|
|
13872
14403
|
}
|
|
13873
|
-
const
|
|
14404
|
+
const base = baseMediaType(format);
|
|
14405
|
+
const resolvedUri = deriveStorageUri(name, isSupportedMediaType(base) ? base : "application/octet-stream");
|
|
13874
14406
|
const stored = await contentStore.store(blob, resolvedUri);
|
|
13875
|
-
const createResult$ = (0,
|
|
13876
|
-
eventBus.get("yield:create-ok").pipe((0,
|
|
13877
|
-
eventBus.get("yield:create-failed").pipe((0,
|
|
14407
|
+
const createResult$ = (0, import_rxjs14.race)(
|
|
14408
|
+
eventBus.get("yield:create-ok").pipe((0, import_operators13.map)((r) => r)),
|
|
14409
|
+
eventBus.get("yield:create-failed").pipe((0, import_operators13.map)((e) => {
|
|
13878
14410
|
throw new Error(e.message);
|
|
13879
14411
|
})),
|
|
13880
|
-
(0,
|
|
14412
|
+
(0, import_rxjs14.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators13.map)(() => {
|
|
13881
14413
|
throw new Error("Timeout waiting for yield:create-ok");
|
|
13882
14414
|
}))
|
|
13883
14415
|
);
|
|
@@ -13891,7 +14423,7 @@ async function importResource(doc, userId3, eventBus, contentStore, resolveBlob,
|
|
|
13891
14423
|
language,
|
|
13892
14424
|
entityTypes: entityTypes ?? []
|
|
13893
14425
|
});
|
|
13894
|
-
const created = await (0,
|
|
14426
|
+
const created = await (0, import_rxjs14.firstValueFrom)(createResult$);
|
|
13895
14427
|
const resourceId10 = resourceId(created.resourceId);
|
|
13896
14428
|
logger?.debug("Created resource from JSON-LD", { name, resourceId: resourceId10 });
|
|
13897
14429
|
let annotationsCreated = 0;
|
|
@@ -13904,12 +14436,12 @@ async function importResource(doc, userId3, eventBus, contentStore, resolveBlob,
|
|
|
13904
14436
|
return { annotationsCreated };
|
|
13905
14437
|
}
|
|
13906
14438
|
async function createAnnotation(annotation, resourceId10, userId3, eventBus, logger) {
|
|
13907
|
-
const result$ = (0,
|
|
13908
|
-
eventBus.get("mark:create-ok").pipe((0,
|
|
13909
|
-
eventBus.get("mark:create-failed").pipe((0,
|
|
14439
|
+
const result$ = (0, import_rxjs14.race)(
|
|
14440
|
+
eventBus.get("mark:create-ok").pipe((0, import_operators13.map)(() => "ok")),
|
|
14441
|
+
eventBus.get("mark:create-failed").pipe((0, import_operators13.map)((e) => {
|
|
13910
14442
|
throw new Error(e.message);
|
|
13911
14443
|
})),
|
|
13912
|
-
(0,
|
|
14444
|
+
(0, import_rxjs14.timer)(IMPORT_TIMEOUT_MS).pipe((0, import_operators13.map)(() => {
|
|
13913
14445
|
throw new Error("Timeout waiting for mark:create-ok");
|
|
13914
14446
|
}))
|
|
13915
14447
|
);
|
|
@@ -13918,7 +14450,7 @@ async function createAnnotation(annotation, resourceId10, userId3, eventBus, log
|
|
|
13918
14450
|
_userId: userId3,
|
|
13919
14451
|
resourceId: resourceId10
|
|
13920
14452
|
});
|
|
13921
|
-
await (0,
|
|
14453
|
+
await (0, import_rxjs14.firstValueFrom)(result$);
|
|
13922
14454
|
logger?.debug("Created annotation", { annotationId: annotation.id });
|
|
13923
14455
|
}
|
|
13924
14456
|
var AnnotationOperations = class {
|
|
@@ -13982,10 +14514,6 @@ var AnnotationOperations = class {
|
|
|
13982
14514
|
}
|
|
13983
14515
|
};
|
|
13984
14516
|
|
|
13985
|
-
|
|
13986
|
-
var PACKAGE_NAME = "@semiont/make-meaning";
|
|
13987
|
-
var VERSION = "0.1.0";
|
|
13988
|
-
|
|
13989
|
-
export { AnnotationContext, AnnotationOperations, BACKUP_FORMAT, Browser, CloneTokenManager, FORMAT_VERSION, Gatherer, GraphContext, LLMContext, LocalContentTransport, LocalTransport, Matcher, PACKAGE_NAME, ResourceContext, ResourceOperations, Stower, VERSION, bootstrapEntityTypes, createKnowledgeBase, createSmelterActorStateUnit, exportBackup, exportLinkedData, generateReferenceSuggestions, generateResourceSummary, importBackup, importLinkedData, isBackupManifest, readEntityTypesProjection, registerAnnotationAssemblyHandler, registerAnnotationLookupHandlers, registerBindUpdateBodyHandler, registerBusHandlers, registerJobCommandHandlers, startMakeMeaning, stopKnowledgeSystem, validateManifestVersion };
|
|
14517
|
+
export { AnnotationContext, AnnotationOperations, BACKUP_FORMAT, Browser, CloneTokenManager, FORMAT_VERSION, Gatherer, GraphContext, LLMContext, LocalContentTransport, LocalTransport, Matcher, ResourceContext, ResourceOperations, Smelter, Stower, bootstrapEntityTypes, createKnowledgeBase, createSmelterActorStateUnit, exportBackup, exportLinkedData, generateReferenceSuggestions, generateResourceSummary, importBackup, importLinkedData, isBackupManifest, readEntityTypesProjection, registerAnnotationAssemblyHandler, registerAnnotationLookupHandlers, registerBindUpdateBodyHandler, registerBusHandlers, registerJobCommandHandlers, startMakeMeaning, stopKnowledgeSystem, validateManifestVersion };
|
|
13990
14518
|
//# sourceMappingURL=index.js.map
|
|
13991
14519
|
//# sourceMappingURL=index.js.map
|