@semiont/make-meaning 0.3.3 → 0.3.5
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 +46 -13
- package/dist/index.js +101 -97
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,22 +1,54 @@
|
|
|
1
1
|
import { JobQueue, ReferenceAnnotationWorker, GenerationWorker, HighlightAnnotationWorker, AssessmentAnnotationWorker, CommentAnnotationWorker, TagAnnotationWorker } from '@semiont/jobs';
|
|
2
2
|
import { EventStore, ViewStorage } from '@semiont/event-sourcing';
|
|
3
|
-
import {
|
|
3
|
+
import { SemiontProject } from '@semiont/core/node';
|
|
4
|
+
import { GraphServiceConfig, Logger, StoredEvent, ResourceId, EventBus, components, UserId, CreationMethod, AnnotationId, ResourceAnnotations, AnnotationCategory, GraphPath, GraphConnection } from '@semiont/core';
|
|
4
5
|
export { AssembledAnnotation, applyBodyOperations, assembleAnnotation } from '@semiont/core';
|
|
5
6
|
import { InferenceClient } from '@semiont/inference';
|
|
6
7
|
import { GraphDatabase } from '@semiont/graph';
|
|
7
8
|
import { RepresentationStore } from '@semiont/content';
|
|
8
9
|
import { Writable, Readable } from 'node:stream';
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Inference configuration for a single actor or worker.
|
|
13
|
+
*/
|
|
14
|
+
interface InferenceConfig {
|
|
15
|
+
type: 'anthropic' | 'ollama';
|
|
16
|
+
model: string;
|
|
17
|
+
maxTokens?: number;
|
|
18
|
+
apiKey?: string;
|
|
19
|
+
endpoint?: string;
|
|
20
|
+
baseURL?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Per-actor inference overrides.
|
|
24
|
+
* Stower never calls an LLM, so it has no entry here.
|
|
25
|
+
*/
|
|
26
|
+
interface ActorInferenceConfig {
|
|
27
|
+
gatherer?: InferenceConfig;
|
|
28
|
+
matcher?: InferenceConfig;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Per-worker-type inference overrides.
|
|
32
|
+
* Falls back to `workers.default` if a specific worker is not listed.
|
|
33
|
+
*/
|
|
34
|
+
interface WorkerInferenceConfig {
|
|
35
|
+
default?: InferenceConfig;
|
|
36
|
+
'reference-annotation'?: InferenceConfig;
|
|
37
|
+
'highlight-annotation'?: InferenceConfig;
|
|
38
|
+
'assessment-annotation'?: InferenceConfig;
|
|
39
|
+
'comment-annotation'?: InferenceConfig;
|
|
40
|
+
'tag-annotation'?: InferenceConfig;
|
|
41
|
+
'generation'?: InferenceConfig;
|
|
42
|
+
}
|
|
10
43
|
/** Narrow config type — only the fields make-meaning actually reads */
|
|
11
44
|
interface MakeMeaningConfig {
|
|
12
45
|
services: {
|
|
13
|
-
filesystem?: FilesystemServiceConfig;
|
|
14
46
|
graph?: GraphServiceConfig;
|
|
15
|
-
inference?: InferenceServiceConfig;
|
|
16
|
-
};
|
|
17
|
-
_metadata?: {
|
|
18
|
-
projectRoot: string;
|
|
19
47
|
};
|
|
48
|
+
/** Per-actor inference config */
|
|
49
|
+
actors?: ActorInferenceConfig;
|
|
50
|
+
/** Per-worker-type inference config */
|
|
51
|
+
workers?: WorkerInferenceConfig;
|
|
20
52
|
}
|
|
21
53
|
|
|
22
54
|
/**
|
|
@@ -131,7 +163,7 @@ interface KnowledgeBase {
|
|
|
131
163
|
content: RepresentationStore;
|
|
132
164
|
graph: GraphDatabase;
|
|
133
165
|
}
|
|
134
|
-
declare function createKnowledgeBase(eventStore: EventStore,
|
|
166
|
+
declare function createKnowledgeBase(eventStore: EventStore, project: SemiontProject, graphDb: GraphDatabase, logger: Logger): KnowledgeBase;
|
|
135
167
|
|
|
136
168
|
/**
|
|
137
169
|
* Gatherer Actor
|
|
@@ -163,10 +195,10 @@ declare class Gatherer {
|
|
|
163
195
|
private kb;
|
|
164
196
|
private eventBus;
|
|
165
197
|
private inferenceClient;
|
|
166
|
-
private
|
|
198
|
+
private project?;
|
|
167
199
|
private subscriptions;
|
|
168
200
|
private readonly logger;
|
|
169
|
-
constructor(kb: KnowledgeBase, eventBus: EventBus, inferenceClient: InferenceClient, logger: Logger,
|
|
201
|
+
constructor(kb: KnowledgeBase, eventBus: EventBus, inferenceClient: InferenceClient, logger: Logger, project?: SemiontProject | undefined);
|
|
170
202
|
initialize(): Promise<void>;
|
|
171
203
|
private handleAnnotationGather;
|
|
172
204
|
private handleResourceGather;
|
|
@@ -342,8 +374,9 @@ interface MakeMeaningService {
|
|
|
342
374
|
kb: KnowledgeBase;
|
|
343
375
|
jobQueue: JobQueue;
|
|
344
376
|
eventStore: EventStore;
|
|
345
|
-
inferenceClient: InferenceClient;
|
|
346
377
|
graphDb: GraphDatabase;
|
|
378
|
+
/** Inference client for the Gatherer actor — use for context-assembly operations */
|
|
379
|
+
gathererInferenceClient: InferenceClient;
|
|
347
380
|
workers: {
|
|
348
381
|
detection: ReferenceAnnotationWorker;
|
|
349
382
|
generation: GenerationWorker;
|
|
@@ -359,7 +392,7 @@ interface MakeMeaningService {
|
|
|
359
392
|
cloneTokenManager: CloneTokenManager;
|
|
360
393
|
stop: () => Promise<void>;
|
|
361
394
|
}
|
|
362
|
-
declare function startMakeMeaning(config: MakeMeaningConfig, eventBus: EventBus, logger: Logger): Promise<MakeMeaningService>;
|
|
395
|
+
declare function startMakeMeaning(project: SemiontProject, config: MakeMeaningConfig, eventBus: EventBus, logger: Logger): Promise<MakeMeaningService>;
|
|
363
396
|
|
|
364
397
|
/**
|
|
365
398
|
* Entity Types Bootstrap Service
|
|
@@ -373,7 +406,7 @@ declare function startMakeMeaning(config: MakeMeaningConfig, eventBus: EventBus,
|
|
|
373
406
|
* Bootstrap entity types projection if it doesn't exist.
|
|
374
407
|
* Uses a system user ID (00000000-0000-0000-0000-000000000000) for bootstrap events.
|
|
375
408
|
*/
|
|
376
|
-
declare function bootstrapEntityTypes(eventBus: EventBus,
|
|
409
|
+
declare function bootstrapEntityTypes(eventBus: EventBus, project: SemiontProject, logger?: Logger): Promise<void>;
|
|
377
410
|
/**
|
|
378
411
|
* Reset the bootstrap flag (used for testing)
|
|
379
412
|
*/
|
|
@@ -389,7 +422,7 @@ declare function resetBootstrap(): void;
|
|
|
389
422
|
/**
|
|
390
423
|
* Read entity types from view storage projection
|
|
391
424
|
*/
|
|
392
|
-
declare function readEntityTypesProjection(
|
|
425
|
+
declare function readEntityTypesProjection(project: SemiontProject): Promise<string[]>;
|
|
393
426
|
|
|
394
427
|
/**
|
|
395
428
|
* Exchange Format Manifest Types
|
package/dist/index.js
CHANGED
|
@@ -737,7 +737,7 @@ var require_Observable = __commonJS({
|
|
|
737
737
|
Observable2.prototype.forEach = function(next, promiseCtor) {
|
|
738
738
|
var _this = this;
|
|
739
739
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
740
|
-
return new promiseCtor(function(
|
|
740
|
+
return new promiseCtor(function(resolve, reject) {
|
|
741
741
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
742
742
|
next: function(value) {
|
|
743
743
|
try {
|
|
@@ -748,7 +748,7 @@ var require_Observable = __commonJS({
|
|
|
748
748
|
}
|
|
749
749
|
},
|
|
750
750
|
error: reject,
|
|
751
|
-
complete:
|
|
751
|
+
complete: resolve
|
|
752
752
|
});
|
|
753
753
|
_this.subscribe(subscriber);
|
|
754
754
|
});
|
|
@@ -770,14 +770,14 @@ var require_Observable = __commonJS({
|
|
|
770
770
|
Observable2.prototype.toPromise = function(promiseCtor) {
|
|
771
771
|
var _this = this;
|
|
772
772
|
promiseCtor = getPromiseCtor(promiseCtor);
|
|
773
|
-
return new promiseCtor(function(
|
|
773
|
+
return new promiseCtor(function(resolve, reject) {
|
|
774
774
|
var value;
|
|
775
775
|
_this.subscribe(function(x) {
|
|
776
776
|
return value = x;
|
|
777
777
|
}, function(err) {
|
|
778
778
|
return reject(err);
|
|
779
779
|
}, function() {
|
|
780
|
-
return
|
|
780
|
+
return resolve(value);
|
|
781
781
|
});
|
|
782
782
|
});
|
|
783
783
|
};
|
|
@@ -2873,11 +2873,11 @@ var require_innerFrom = __commonJS({
|
|
|
2873
2873
|
"use strict";
|
|
2874
2874
|
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
2875
2875
|
function adopt(value) {
|
|
2876
|
-
return value instanceof P ? value : new P(function(
|
|
2877
|
-
|
|
2876
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
2877
|
+
resolve(value);
|
|
2878
2878
|
});
|
|
2879
2879
|
}
|
|
2880
|
-
return new (P || (P = Promise))(function(
|
|
2880
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
2881
2881
|
function fulfilled(value) {
|
|
2882
2882
|
try {
|
|
2883
2883
|
step(generator.next(value));
|
|
@@ -2893,7 +2893,7 @@ var require_innerFrom = __commonJS({
|
|
|
2893
2893
|
}
|
|
2894
2894
|
}
|
|
2895
2895
|
function step(result) {
|
|
2896
|
-
result.done ?
|
|
2896
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2897
2897
|
}
|
|
2898
2898
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2899
2899
|
});
|
|
@@ -2975,14 +2975,14 @@ var require_innerFrom = __commonJS({
|
|
|
2975
2975
|
}, i);
|
|
2976
2976
|
function verb(n) {
|
|
2977
2977
|
i[n] = o[n] && function(v) {
|
|
2978
|
-
return new Promise(function(
|
|
2979
|
-
v = o[n](v), settle(
|
|
2978
|
+
return new Promise(function(resolve, reject) {
|
|
2979
|
+
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
|
2980
2980
|
});
|
|
2981
2981
|
};
|
|
2982
2982
|
}
|
|
2983
|
-
function settle(
|
|
2983
|
+
function settle(resolve, reject, d, v) {
|
|
2984
2984
|
Promise.resolve(v).then(function(v2) {
|
|
2985
|
-
|
|
2985
|
+
resolve({ value: v2, done: d });
|
|
2986
2986
|
}, reject);
|
|
2987
2987
|
}
|
|
2988
2988
|
};
|
|
@@ -3601,7 +3601,7 @@ var require_lastValueFrom = __commonJS({
|
|
|
3601
3601
|
var EmptyError_1 = require_EmptyError();
|
|
3602
3602
|
function lastValueFrom(source, config) {
|
|
3603
3603
|
var hasConfig = typeof config === "object";
|
|
3604
|
-
return new Promise(function(
|
|
3604
|
+
return new Promise(function(resolve, reject) {
|
|
3605
3605
|
var _hasValue = false;
|
|
3606
3606
|
var _value;
|
|
3607
3607
|
source.subscribe({
|
|
@@ -3612,9 +3612,9 @@ var require_lastValueFrom = __commonJS({
|
|
|
3612
3612
|
error: reject,
|
|
3613
3613
|
complete: function() {
|
|
3614
3614
|
if (_hasValue) {
|
|
3615
|
-
|
|
3615
|
+
resolve(_value);
|
|
3616
3616
|
} else if (hasConfig) {
|
|
3617
|
-
|
|
3617
|
+
resolve(config.defaultValue);
|
|
3618
3618
|
} else {
|
|
3619
3619
|
reject(new EmptyError_1.EmptyError());
|
|
3620
3620
|
}
|
|
@@ -3636,16 +3636,16 @@ var require_firstValueFrom = __commonJS({
|
|
|
3636
3636
|
var Subscriber_1 = require_Subscriber();
|
|
3637
3637
|
function firstValueFrom5(source, config) {
|
|
3638
3638
|
var hasConfig = typeof config === "object";
|
|
3639
|
-
return new Promise(function(
|
|
3639
|
+
return new Promise(function(resolve, reject) {
|
|
3640
3640
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
3641
3641
|
next: function(value) {
|
|
3642
|
-
|
|
3642
|
+
resolve(value);
|
|
3643
3643
|
subscriber.unsubscribe();
|
|
3644
3644
|
},
|
|
3645
3645
|
error: reject,
|
|
3646
3646
|
complete: function() {
|
|
3647
3647
|
if (hasConfig) {
|
|
3648
|
-
|
|
3648
|
+
resolve(config.defaultValue);
|
|
3649
3649
|
} else {
|
|
3650
3650
|
reject(new EmptyError_1.EmptyError());
|
|
3651
3651
|
}
|
|
@@ -9943,14 +9943,33 @@ var require_operators = __commonJS({
|
|
|
9943
9943
|
});
|
|
9944
9944
|
|
|
9945
9945
|
// src/service.ts
|
|
9946
|
-
var import_rxjs8 = __toESM(require_cjs(), 1);
|
|
9947
|
-
var import_operators8 = __toESM(require_operators(), 1);
|
|
9948
|
-
import * as path3 from "path";
|
|
9949
9946
|
import { JobQueue } from "@semiont/jobs";
|
|
9950
9947
|
import { createEventStore as createEventStoreCore } from "@semiont/event-sourcing";
|
|
9951
9948
|
import { getPrimaryRepresentation as getPrimaryRepresentation4 } from "@semiont/api-client";
|
|
9949
|
+
|
|
9950
|
+
// src/config.ts
|
|
9951
|
+
function resolveActorInference(config, actor) {
|
|
9952
|
+
const specific = config.actors?.[actor];
|
|
9953
|
+
if (specific) return specific;
|
|
9954
|
+
throw new Error(
|
|
9955
|
+
`No inference config found for actor '${actor}'. Set actors.${actor}.inference in your config.`
|
|
9956
|
+
);
|
|
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/service.ts
|
|
9969
|
+
var import_rxjs8 = __toESM(require_cjs(), 1);
|
|
9970
|
+
var import_operators8 = __toESM(require_operators(), 1);
|
|
9952
9971
|
import { Readable } from "stream";
|
|
9953
|
-
import {
|
|
9972
|
+
import { createInferenceClient } from "@semiont/inference";
|
|
9954
9973
|
import { getGraphDatabase } from "@semiont/graph";
|
|
9955
9974
|
import {
|
|
9956
9975
|
ReferenceAnnotationWorker,
|
|
@@ -10378,26 +10397,13 @@ import * as path from "path";
|
|
|
10378
10397
|
import { DEFAULT_ENTITY_TYPES } from "@semiont/ontology";
|
|
10379
10398
|
import { userId } from "@semiont/core";
|
|
10380
10399
|
var bootstrapCompleted = false;
|
|
10381
|
-
async function bootstrapEntityTypes(eventBus,
|
|
10400
|
+
async function bootstrapEntityTypes(eventBus, project, logger) {
|
|
10382
10401
|
if (bootstrapCompleted) {
|
|
10383
10402
|
logger?.debug("Entity types bootstrap already completed, skipping");
|
|
10384
10403
|
return;
|
|
10385
10404
|
}
|
|
10386
|
-
const configuredPath = config.services.filesystem?.path;
|
|
10387
|
-
if (!configuredPath) {
|
|
10388
|
-
throw new Error("services.filesystem.path is required for entity types bootstrap");
|
|
10389
|
-
}
|
|
10390
|
-
const projectRoot = config._metadata?.projectRoot;
|
|
10391
|
-
let basePath;
|
|
10392
|
-
if (path.isAbsolute(configuredPath)) {
|
|
10393
|
-
basePath = configuredPath;
|
|
10394
|
-
} else if (projectRoot) {
|
|
10395
|
-
basePath = path.resolve(projectRoot, configuredPath);
|
|
10396
|
-
} else {
|
|
10397
|
-
basePath = path.resolve(configuredPath);
|
|
10398
|
-
}
|
|
10399
10405
|
const projectionPath = path.join(
|
|
10400
|
-
|
|
10406
|
+
project.stateDir,
|
|
10401
10407
|
"projections",
|
|
10402
10408
|
"__system__",
|
|
10403
10409
|
"entitytypes.json"
|
|
@@ -10437,11 +10443,10 @@ function resetBootstrap() {
|
|
|
10437
10443
|
// src/knowledge-base.ts
|
|
10438
10444
|
import { FilesystemViewStorage } from "@semiont/event-sourcing";
|
|
10439
10445
|
import { FilesystemRepresentationStore } from "@semiont/content";
|
|
10440
|
-
function createKnowledgeBase(eventStore,
|
|
10441
|
-
const views = new FilesystemViewStorage(
|
|
10446
|
+
function createKnowledgeBase(eventStore, project, graphDb, logger) {
|
|
10447
|
+
const views = new FilesystemViewStorage(project);
|
|
10442
10448
|
const content = new FilesystemRepresentationStore(
|
|
10443
|
-
|
|
10444
|
-
projectRoot,
|
|
10449
|
+
project,
|
|
10445
10450
|
logger.child({ component: "representation-store" })
|
|
10446
10451
|
);
|
|
10447
10452
|
return { eventStore, views, content, graph: graphDb };
|
|
@@ -11148,22 +11153,9 @@ var LLMContext = class {
|
|
|
11148
11153
|
// src/views/entity-types-reader.ts
|
|
11149
11154
|
import { promises as fs2 } from "fs";
|
|
11150
11155
|
import * as path2 from "path";
|
|
11151
|
-
async function readEntityTypesProjection(
|
|
11152
|
-
const configuredPath = config.services.filesystem?.path;
|
|
11153
|
-
if (!configuredPath) {
|
|
11154
|
-
throw new Error("services.filesystem.path is required for entity types reader");
|
|
11155
|
-
}
|
|
11156
|
-
const projectRoot = config._metadata?.projectRoot;
|
|
11157
|
-
let basePath;
|
|
11158
|
-
if (path2.isAbsolute(configuredPath)) {
|
|
11159
|
-
basePath = configuredPath;
|
|
11160
|
-
} else if (projectRoot) {
|
|
11161
|
-
basePath = path2.resolve(projectRoot, configuredPath);
|
|
11162
|
-
} else {
|
|
11163
|
-
basePath = path2.resolve(configuredPath);
|
|
11164
|
-
}
|
|
11156
|
+
async function readEntityTypesProjection(project) {
|
|
11165
11157
|
const entityTypesPath = path2.join(
|
|
11166
|
-
|
|
11158
|
+
project.stateDir,
|
|
11167
11159
|
"projections",
|
|
11168
11160
|
"__system__",
|
|
11169
11161
|
"entitytypes.json"
|
|
@@ -11182,11 +11174,11 @@ async function readEntityTypesProjection(config) {
|
|
|
11182
11174
|
|
|
11183
11175
|
// src/gatherer.ts
|
|
11184
11176
|
var Gatherer = class {
|
|
11185
|
-
constructor(kb, eventBus, inferenceClient, logger,
|
|
11177
|
+
constructor(kb, eventBus, inferenceClient, logger, project) {
|
|
11186
11178
|
this.kb = kb;
|
|
11187
11179
|
this.eventBus = eventBus;
|
|
11188
11180
|
this.inferenceClient = inferenceClient;
|
|
11189
|
-
this.
|
|
11181
|
+
this.project = project;
|
|
11190
11182
|
this.logger = logger;
|
|
11191
11183
|
}
|
|
11192
11184
|
subscriptions = [];
|
|
@@ -11518,10 +11510,10 @@ var Gatherer = class {
|
|
|
11518
11510
|
// ========================================================================
|
|
11519
11511
|
async handleEntityTypes(event) {
|
|
11520
11512
|
try {
|
|
11521
|
-
if (!this.
|
|
11522
|
-
throw new Error("
|
|
11513
|
+
if (!this.project) {
|
|
11514
|
+
throw new Error("SemiontProject required for entity type reads");
|
|
11523
11515
|
}
|
|
11524
|
-
const entityTypes = await readEntityTypesProjection(this.
|
|
11516
|
+
const entityTypes = await readEntityTypesProjection(this.project);
|
|
11525
11517
|
this.eventBus.get("mark:entity-types-result").next({
|
|
11526
11518
|
correlationId: event.correlationId,
|
|
11527
11519
|
response: { entityTypes }
|
|
@@ -12395,27 +12387,13 @@ var CloneTokenManager = class {
|
|
|
12395
12387
|
};
|
|
12396
12388
|
|
|
12397
12389
|
// src/service.ts
|
|
12398
|
-
async function startMakeMeaning(config, eventBus, logger) {
|
|
12399
|
-
const filesystemConfig = config.services?.filesystem;
|
|
12400
|
-
if (!filesystemConfig?.path) {
|
|
12401
|
-
throw new Error("services.filesystem.path is required for make-meaning service");
|
|
12402
|
-
}
|
|
12390
|
+
async function startMakeMeaning(project, config, eventBus, logger) {
|
|
12403
12391
|
const graphConfig = config.services?.graph;
|
|
12404
12392
|
if (!graphConfig) {
|
|
12405
12393
|
throw new Error("services.graph is required for make-meaning service");
|
|
12406
12394
|
}
|
|
12407
|
-
const configuredPath = filesystemConfig.path;
|
|
12408
|
-
const projectRoot = config._metadata?.projectRoot;
|
|
12409
|
-
let basePath;
|
|
12410
|
-
if (path3.isAbsolute(configuredPath)) {
|
|
12411
|
-
basePath = configuredPath;
|
|
12412
|
-
} else if (projectRoot) {
|
|
12413
|
-
basePath = path3.resolve(projectRoot, configuredPath);
|
|
12414
|
-
} else {
|
|
12415
|
-
basePath = path3.resolve(configuredPath);
|
|
12416
|
-
}
|
|
12417
12395
|
const jobQueueLogger = logger.child({ component: "job-queue" });
|
|
12418
|
-
const jobQueue = new JobQueue(
|
|
12396
|
+
const jobQueue = new JobQueue(project, jobQueueLogger, eventBus);
|
|
12419
12397
|
await jobQueue.initialize();
|
|
12420
12398
|
const jobStatusSubscription = eventBus.get("job:status-requested").pipe(
|
|
12421
12399
|
(0, import_operators8.mergeMap)((event) => (0, import_rxjs8.from)((async () => {
|
|
@@ -12454,15 +12432,41 @@ async function startMakeMeaning(config, eventBus, logger) {
|
|
|
12454
12432
|
error: (err) => jobQueueLogger.error("Job status pipeline error", { error: err })
|
|
12455
12433
|
});
|
|
12456
12434
|
const eventStoreLogger = logger.child({ component: "event-store" });
|
|
12457
|
-
const eventStore = createEventStoreCore(
|
|
12458
|
-
const
|
|
12459
|
-
|
|
12460
|
-
|
|
12461
|
-
|
|
12462
|
-
|
|
12463
|
-
|
|
12435
|
+
const eventStore = createEventStoreCore(project, void 0, eventBus, eventStoreLogger);
|
|
12436
|
+
const gathererInferenceClient = createInferenceClient(
|
|
12437
|
+
resolveActorInference(config, "gatherer"),
|
|
12438
|
+
logger.child({ component: "inference-client-gatherer" })
|
|
12439
|
+
);
|
|
12440
|
+
const matcherInferenceClient = createInferenceClient(
|
|
12441
|
+
resolveActorInference(config, "matcher"),
|
|
12442
|
+
logger.child({ component: "inference-client-matcher" })
|
|
12443
|
+
);
|
|
12444
|
+
const detectionInferenceClient = createInferenceClient(
|
|
12445
|
+
resolveWorkerInference(config, "reference-annotation"),
|
|
12446
|
+
logger.child({ component: "inference-client-reference-annotation" })
|
|
12447
|
+
);
|
|
12448
|
+
const generationInferenceClient = createInferenceClient(
|
|
12449
|
+
resolveWorkerInference(config, "generation"),
|
|
12450
|
+
logger.child({ component: "inference-client-generation" })
|
|
12451
|
+
);
|
|
12452
|
+
const highlightInferenceClient = createInferenceClient(
|
|
12453
|
+
resolveWorkerInference(config, "highlight-annotation"),
|
|
12454
|
+
logger.child({ component: "inference-client-highlight-annotation" })
|
|
12455
|
+
);
|
|
12456
|
+
const assessmentInferenceClient = createInferenceClient(
|
|
12457
|
+
resolveWorkerInference(config, "assessment-annotation"),
|
|
12458
|
+
logger.child({ component: "inference-client-assessment-annotation" })
|
|
12459
|
+
);
|
|
12460
|
+
const commentInferenceClient = createInferenceClient(
|
|
12461
|
+
resolveWorkerInference(config, "comment-annotation"),
|
|
12462
|
+
logger.child({ component: "inference-client-comment-annotation" })
|
|
12463
|
+
);
|
|
12464
|
+
const tagInferenceClient = createInferenceClient(
|
|
12465
|
+
resolveWorkerInference(config, "tag-annotation"),
|
|
12466
|
+
logger.child({ component: "inference-client-tag-annotation" })
|
|
12467
|
+
);
|
|
12464
12468
|
const graphDb = await getGraphDatabase(graphConfig);
|
|
12465
|
-
const kb = createKnowledgeBase(eventStore,
|
|
12469
|
+
const kb = createKnowledgeBase(eventStore, project, graphDb, logger);
|
|
12466
12470
|
const graphConsumerLogger = logger.child({ component: "graph-consumer" });
|
|
12467
12471
|
const graphConsumer = new GraphDBConsumer(eventStore, graphDb, graphConsumerLogger);
|
|
12468
12472
|
await graphConsumer.initialize();
|
|
@@ -12470,12 +12474,12 @@ async function startMakeMeaning(config, eventBus, logger) {
|
|
|
12470
12474
|
const stower = new Stower(kb, eventBus, stowerLogger);
|
|
12471
12475
|
await stower.initialize();
|
|
12472
12476
|
const bootstrapLogger = logger.child({ component: "entity-types-bootstrap" });
|
|
12473
|
-
await bootstrapEntityTypes(eventBus,
|
|
12477
|
+
await bootstrapEntityTypes(eventBus, project, bootstrapLogger);
|
|
12474
12478
|
const gathererLogger = logger.child({ component: "gatherer" });
|
|
12475
|
-
const gatherer = new Gatherer(kb, eventBus,
|
|
12479
|
+
const gatherer = new Gatherer(kb, eventBus, gathererInferenceClient, gathererLogger, project);
|
|
12476
12480
|
await gatherer.initialize();
|
|
12477
12481
|
const matcherLogger = logger.child({ component: "matcher" });
|
|
12478
|
-
const matcher = new Matcher(kb, eventBus, matcherLogger,
|
|
12482
|
+
const matcher = new Matcher(kb, eventBus, matcherLogger, matcherInferenceClient);
|
|
12479
12483
|
await matcher.initialize();
|
|
12480
12484
|
const cloneTokenLogger = logger.child({ component: "clone-token-manager" });
|
|
12481
12485
|
const cloneTokenManager = new CloneTokenManager(kb, eventBus, cloneTokenLogger);
|
|
@@ -12496,12 +12500,12 @@ async function startMakeMeaning(config, eventBus, logger) {
|
|
|
12496
12500
|
const commentLogger = logger.child({ component: "comment-detection-worker" });
|
|
12497
12501
|
const tagLogger = logger.child({ component: "tag-detection-worker" });
|
|
12498
12502
|
const workers = {
|
|
12499
|
-
detection: new ReferenceAnnotationWorker(jobQueue,
|
|
12500
|
-
generation: new GenerationWorker(jobQueue,
|
|
12501
|
-
highlight: new HighlightAnnotationWorker(jobQueue,
|
|
12502
|
-
assessment: new AssessmentAnnotationWorker(jobQueue,
|
|
12503
|
-
comment: new CommentAnnotationWorker(jobQueue,
|
|
12504
|
-
tag: new TagAnnotationWorker(jobQueue,
|
|
12503
|
+
detection: new ReferenceAnnotationWorker(jobQueue, detectionInferenceClient, eventBus, contentFetcher, detectionLogger),
|
|
12504
|
+
generation: new GenerationWorker(jobQueue, generationInferenceClient, eventBus, generationLogger),
|
|
12505
|
+
highlight: new HighlightAnnotationWorker(jobQueue, highlightInferenceClient, eventBus, contentFetcher, highlightLogger),
|
|
12506
|
+
assessment: new AssessmentAnnotationWorker(jobQueue, assessmentInferenceClient, eventBus, contentFetcher, assessmentLogger),
|
|
12507
|
+
comment: new CommentAnnotationWorker(jobQueue, commentInferenceClient, eventBus, contentFetcher, commentLogger),
|
|
12508
|
+
tag: new TagAnnotationWorker(jobQueue, tagInferenceClient, eventBus, contentFetcher, tagLogger)
|
|
12505
12509
|
};
|
|
12506
12510
|
workers.detection.start().catch((error) => {
|
|
12507
12511
|
detectionLogger.error("Worker stopped unexpectedly", { error });
|
|
@@ -12525,8 +12529,8 @@ async function startMakeMeaning(config, eventBus, logger) {
|
|
|
12525
12529
|
kb,
|
|
12526
12530
|
jobQueue,
|
|
12527
12531
|
eventStore,
|
|
12528
|
-
inferenceClient,
|
|
12529
12532
|
graphDb,
|
|
12533
|
+
gathererInferenceClient,
|
|
12530
12534
|
workers,
|
|
12531
12535
|
graphConsumer,
|
|
12532
12536
|
stower,
|
|
@@ -12609,9 +12613,9 @@ async function writeTarGz(entries, output) {
|
|
|
12609
12613
|
async function decompressStream(input) {
|
|
12610
12614
|
const gunzip = createGunzip();
|
|
12611
12615
|
const chunks = [];
|
|
12612
|
-
return new Promise((
|
|
12616
|
+
return new Promise((resolve, reject) => {
|
|
12613
12617
|
gunzip.on("data", (chunk) => chunks.push(chunk));
|
|
12614
|
-
gunzip.on("end", () =>
|
|
12618
|
+
gunzip.on("end", () => resolve(Buffer.concat(chunks)));
|
|
12615
12619
|
gunzip.on("error", reject);
|
|
12616
12620
|
input.on("error", reject);
|
|
12617
12621
|
input.pipe(gunzip);
|