@semiont/make-meaning 0.3.4 → 0.3.6
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 +108 -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,45 @@ 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/agent-utils.ts
|
|
9969
|
+
function inferenceConfigToGenerator(workerType, config) {
|
|
9970
|
+
const providerLabel = config.type === "ollama" ? `Ollama ${config.model}` : config.type === "anthropic" ? `Anthropic ${config.model}` : config.type != null ? `${config.type} ${config.model}` : void 0;
|
|
9971
|
+
return {
|
|
9972
|
+
"@type": "SoftwareAgent",
|
|
9973
|
+
name: providerLabel ? `${workerType} / ${providerLabel}` : workerType,
|
|
9974
|
+
worker: workerType,
|
|
9975
|
+
inferenceProvider: config.type,
|
|
9976
|
+
model: config.model
|
|
9977
|
+
};
|
|
9978
|
+
}
|
|
9979
|
+
|
|
9980
|
+
// src/service.ts
|
|
9981
|
+
var import_rxjs8 = __toESM(require_cjs(), 1);
|
|
9982
|
+
var import_operators8 = __toESM(require_operators(), 1);
|
|
9952
9983
|
import { Readable } from "stream";
|
|
9953
|
-
import {
|
|
9984
|
+
import { createInferenceClient } from "@semiont/inference";
|
|
9954
9985
|
import { getGraphDatabase } from "@semiont/graph";
|
|
9955
9986
|
import {
|
|
9956
9987
|
ReferenceAnnotationWorker,
|
|
@@ -10378,26 +10409,13 @@ import * as path from "path";
|
|
|
10378
10409
|
import { DEFAULT_ENTITY_TYPES } from "@semiont/ontology";
|
|
10379
10410
|
import { userId } from "@semiont/core";
|
|
10380
10411
|
var bootstrapCompleted = false;
|
|
10381
|
-
async function bootstrapEntityTypes(eventBus,
|
|
10412
|
+
async function bootstrapEntityTypes(eventBus, project, logger) {
|
|
10382
10413
|
if (bootstrapCompleted) {
|
|
10383
10414
|
logger?.debug("Entity types bootstrap already completed, skipping");
|
|
10384
10415
|
return;
|
|
10385
10416
|
}
|
|
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
10417
|
const projectionPath = path.join(
|
|
10400
|
-
|
|
10418
|
+
project.stateDir,
|
|
10401
10419
|
"projections",
|
|
10402
10420
|
"__system__",
|
|
10403
10421
|
"entitytypes.json"
|
|
@@ -10437,11 +10455,10 @@ function resetBootstrap() {
|
|
|
10437
10455
|
// src/knowledge-base.ts
|
|
10438
10456
|
import { FilesystemViewStorage } from "@semiont/event-sourcing";
|
|
10439
10457
|
import { FilesystemRepresentationStore } from "@semiont/content";
|
|
10440
|
-
function createKnowledgeBase(eventStore,
|
|
10441
|
-
const views = new FilesystemViewStorage(
|
|
10458
|
+
function createKnowledgeBase(eventStore, project, graphDb, logger) {
|
|
10459
|
+
const views = new FilesystemViewStorage(project);
|
|
10442
10460
|
const content = new FilesystemRepresentationStore(
|
|
10443
|
-
|
|
10444
|
-
projectRoot,
|
|
10461
|
+
project,
|
|
10445
10462
|
logger.child({ component: "representation-store" })
|
|
10446
10463
|
);
|
|
10447
10464
|
return { eventStore, views, content, graph: graphDb };
|
|
@@ -11148,22 +11165,9 @@ var LLMContext = class {
|
|
|
11148
11165
|
// src/views/entity-types-reader.ts
|
|
11149
11166
|
import { promises as fs2 } from "fs";
|
|
11150
11167
|
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
|
-
}
|
|
11168
|
+
async function readEntityTypesProjection(project) {
|
|
11165
11169
|
const entityTypesPath = path2.join(
|
|
11166
|
-
|
|
11170
|
+
project.stateDir,
|
|
11167
11171
|
"projections",
|
|
11168
11172
|
"__system__",
|
|
11169
11173
|
"entitytypes.json"
|
|
@@ -11182,11 +11186,11 @@ async function readEntityTypesProjection(config) {
|
|
|
11182
11186
|
|
|
11183
11187
|
// src/gatherer.ts
|
|
11184
11188
|
var Gatherer = class {
|
|
11185
|
-
constructor(kb, eventBus, inferenceClient, logger,
|
|
11189
|
+
constructor(kb, eventBus, inferenceClient, logger, project) {
|
|
11186
11190
|
this.kb = kb;
|
|
11187
11191
|
this.eventBus = eventBus;
|
|
11188
11192
|
this.inferenceClient = inferenceClient;
|
|
11189
|
-
this.
|
|
11193
|
+
this.project = project;
|
|
11190
11194
|
this.logger = logger;
|
|
11191
11195
|
}
|
|
11192
11196
|
subscriptions = [];
|
|
@@ -11518,10 +11522,10 @@ var Gatherer = class {
|
|
|
11518
11522
|
// ========================================================================
|
|
11519
11523
|
async handleEntityTypes(event) {
|
|
11520
11524
|
try {
|
|
11521
|
-
if (!this.
|
|
11522
|
-
throw new Error("
|
|
11525
|
+
if (!this.project) {
|
|
11526
|
+
throw new Error("SemiontProject required for entity type reads");
|
|
11523
11527
|
}
|
|
11524
|
-
const entityTypes = await readEntityTypesProjection(this.
|
|
11528
|
+
const entityTypes = await readEntityTypesProjection(this.project);
|
|
11525
11529
|
this.eventBus.get("mark:entity-types-result").next({
|
|
11526
11530
|
correlationId: event.correlationId,
|
|
11527
11531
|
response: { entityTypes }
|
|
@@ -12395,27 +12399,13 @@ var CloneTokenManager = class {
|
|
|
12395
12399
|
};
|
|
12396
12400
|
|
|
12397
12401
|
// 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
|
-
}
|
|
12402
|
+
async function startMakeMeaning(project, config, eventBus, logger) {
|
|
12403
12403
|
const graphConfig = config.services?.graph;
|
|
12404
12404
|
if (!graphConfig) {
|
|
12405
12405
|
throw new Error("services.graph is required for make-meaning service");
|
|
12406
12406
|
}
|
|
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
12407
|
const jobQueueLogger = logger.child({ component: "job-queue" });
|
|
12418
|
-
const jobQueue = new JobQueue(
|
|
12408
|
+
const jobQueue = new JobQueue(project, jobQueueLogger, eventBus);
|
|
12419
12409
|
await jobQueue.initialize();
|
|
12420
12410
|
const jobStatusSubscription = eventBus.get("job:status-requested").pipe(
|
|
12421
12411
|
(0, import_operators8.mergeMap)((event) => (0, import_rxjs8.from)((async () => {
|
|
@@ -12454,15 +12444,36 @@ async function startMakeMeaning(config, eventBus, logger) {
|
|
|
12454
12444
|
error: (err) => jobQueueLogger.error("Job status pipeline error", { error: err })
|
|
12455
12445
|
});
|
|
12456
12446
|
const eventStoreLogger = logger.child({ component: "event-store" });
|
|
12457
|
-
const eventStore = createEventStoreCore(
|
|
12458
|
-
const
|
|
12459
|
-
|
|
12460
|
-
|
|
12461
|
-
|
|
12462
|
-
|
|
12463
|
-
|
|
12447
|
+
const eventStore = createEventStoreCore(project, void 0, eventBus, eventStoreLogger);
|
|
12448
|
+
const gathererInferenceClient = createInferenceClient(
|
|
12449
|
+
resolveActorInference(config, "gatherer"),
|
|
12450
|
+
logger.child({ component: "inference-client-gatherer" })
|
|
12451
|
+
);
|
|
12452
|
+
const matcherInferenceClient = createInferenceClient(
|
|
12453
|
+
resolveActorInference(config, "matcher"),
|
|
12454
|
+
logger.child({ component: "inference-client-matcher" })
|
|
12455
|
+
);
|
|
12456
|
+
const detectionInferenceCfg = resolveWorkerInference(config, "reference-annotation");
|
|
12457
|
+
const detectionInferenceClient = createInferenceClient(detectionInferenceCfg, logger.child({ component: "inference-client-reference-annotation" }));
|
|
12458
|
+
const detectionGenerator = inferenceConfigToGenerator("Reference Worker", detectionInferenceCfg);
|
|
12459
|
+
const generationInferenceClient = createInferenceClient(
|
|
12460
|
+
resolveWorkerInference(config, "generation"),
|
|
12461
|
+
logger.child({ component: "inference-client-generation" })
|
|
12462
|
+
);
|
|
12463
|
+
const highlightInferenceCfg = resolveWorkerInference(config, "highlight-annotation");
|
|
12464
|
+
const highlightInferenceClient = createInferenceClient(highlightInferenceCfg, logger.child({ component: "inference-client-highlight-annotation" }));
|
|
12465
|
+
const highlightGenerator = inferenceConfigToGenerator("Highlight Worker", highlightInferenceCfg);
|
|
12466
|
+
const assessmentInferenceCfg = resolveWorkerInference(config, "assessment-annotation");
|
|
12467
|
+
const assessmentInferenceClient = createInferenceClient(assessmentInferenceCfg, logger.child({ component: "inference-client-assessment-annotation" }));
|
|
12468
|
+
const assessmentGenerator = inferenceConfigToGenerator("Assessment Worker", assessmentInferenceCfg);
|
|
12469
|
+
const commentInferenceCfg = resolveWorkerInference(config, "comment-annotation");
|
|
12470
|
+
const commentInferenceClient = createInferenceClient(commentInferenceCfg, logger.child({ component: "inference-client-comment-annotation" }));
|
|
12471
|
+
const commentGenerator = inferenceConfigToGenerator("Comment Worker", commentInferenceCfg);
|
|
12472
|
+
const tagInferenceCfg = resolveWorkerInference(config, "tag-annotation");
|
|
12473
|
+
const tagInferenceClient = createInferenceClient(tagInferenceCfg, logger.child({ component: "inference-client-tag-annotation" }));
|
|
12474
|
+
const tagGenerator = inferenceConfigToGenerator("Tag Worker", tagInferenceCfg);
|
|
12464
12475
|
const graphDb = await getGraphDatabase(graphConfig);
|
|
12465
|
-
const kb = createKnowledgeBase(eventStore,
|
|
12476
|
+
const kb = createKnowledgeBase(eventStore, project, graphDb, logger);
|
|
12466
12477
|
const graphConsumerLogger = logger.child({ component: "graph-consumer" });
|
|
12467
12478
|
const graphConsumer = new GraphDBConsumer(eventStore, graphDb, graphConsumerLogger);
|
|
12468
12479
|
await graphConsumer.initialize();
|
|
@@ -12470,12 +12481,12 @@ async function startMakeMeaning(config, eventBus, logger) {
|
|
|
12470
12481
|
const stower = new Stower(kb, eventBus, stowerLogger);
|
|
12471
12482
|
await stower.initialize();
|
|
12472
12483
|
const bootstrapLogger = logger.child({ component: "entity-types-bootstrap" });
|
|
12473
|
-
await bootstrapEntityTypes(eventBus,
|
|
12484
|
+
await bootstrapEntityTypes(eventBus, project, bootstrapLogger);
|
|
12474
12485
|
const gathererLogger = logger.child({ component: "gatherer" });
|
|
12475
|
-
const gatherer = new Gatherer(kb, eventBus,
|
|
12486
|
+
const gatherer = new Gatherer(kb, eventBus, gathererInferenceClient, gathererLogger, project);
|
|
12476
12487
|
await gatherer.initialize();
|
|
12477
12488
|
const matcherLogger = logger.child({ component: "matcher" });
|
|
12478
|
-
const matcher = new Matcher(kb, eventBus, matcherLogger,
|
|
12489
|
+
const matcher = new Matcher(kb, eventBus, matcherLogger, matcherInferenceClient);
|
|
12479
12490
|
await matcher.initialize();
|
|
12480
12491
|
const cloneTokenLogger = logger.child({ component: "clone-token-manager" });
|
|
12481
12492
|
const cloneTokenManager = new CloneTokenManager(kb, eventBus, cloneTokenLogger);
|
|
@@ -12496,12 +12507,12 @@ async function startMakeMeaning(config, eventBus, logger) {
|
|
|
12496
12507
|
const commentLogger = logger.child({ component: "comment-detection-worker" });
|
|
12497
12508
|
const tagLogger = logger.child({ component: "tag-detection-worker" });
|
|
12498
12509
|
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,
|
|
12510
|
+
detection: new ReferenceAnnotationWorker(jobQueue, detectionInferenceClient, detectionGenerator, eventBus, contentFetcher, detectionLogger),
|
|
12511
|
+
generation: new GenerationWorker(jobQueue, generationInferenceClient, eventBus, generationLogger),
|
|
12512
|
+
highlight: new HighlightAnnotationWorker(jobQueue, highlightInferenceClient, highlightGenerator, eventBus, contentFetcher, highlightLogger),
|
|
12513
|
+
assessment: new AssessmentAnnotationWorker(jobQueue, assessmentInferenceClient, assessmentGenerator, eventBus, contentFetcher, assessmentLogger),
|
|
12514
|
+
comment: new CommentAnnotationWorker(jobQueue, commentInferenceClient, commentGenerator, eventBus, contentFetcher, commentLogger),
|
|
12515
|
+
tag: new TagAnnotationWorker(jobQueue, tagInferenceClient, tagGenerator, eventBus, contentFetcher, tagLogger)
|
|
12505
12516
|
};
|
|
12506
12517
|
workers.detection.start().catch((error) => {
|
|
12507
12518
|
detectionLogger.error("Worker stopped unexpectedly", { error });
|
|
@@ -12525,8 +12536,8 @@ async function startMakeMeaning(config, eventBus, logger) {
|
|
|
12525
12536
|
kb,
|
|
12526
12537
|
jobQueue,
|
|
12527
12538
|
eventStore,
|
|
12528
|
-
inferenceClient,
|
|
12529
12539
|
graphDb,
|
|
12540
|
+
gathererInferenceClient,
|
|
12530
12541
|
workers,
|
|
12531
12542
|
graphConsumer,
|
|
12532
12543
|
stower,
|
|
@@ -12609,9 +12620,9 @@ async function writeTarGz(entries, output) {
|
|
|
12609
12620
|
async function decompressStream(input) {
|
|
12610
12621
|
const gunzip = createGunzip();
|
|
12611
12622
|
const chunks = [];
|
|
12612
|
-
return new Promise((
|
|
12623
|
+
return new Promise((resolve, reject) => {
|
|
12613
12624
|
gunzip.on("data", (chunk) => chunks.push(chunk));
|
|
12614
|
-
gunzip.on("end", () =>
|
|
12625
|
+
gunzip.on("end", () => resolve(Buffer.concat(chunks)));
|
|
12615
12626
|
gunzip.on("error", reject);
|
|
12616
12627
|
input.on("error", reject);
|
|
12617
12628
|
input.pipe(gunzip);
|