@semiont/jobs 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 +18 -12
- package/dist/index.js +27 -29
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Readable } from 'stream';
|
|
2
2
|
import { ResourceId, JobId, UserId, EntityType, AnnotationId, components, GatheredContext, Logger, EventBus } from '@semiont/core';
|
|
3
|
+
import { SemiontProject } from '@semiont/core/node';
|
|
3
4
|
import { InferenceClient } from '@semiont/inference';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -277,9 +278,6 @@ interface JobQueryFilters {
|
|
|
277
278
|
* Jobs are stored in directories by status for easy polling.
|
|
278
279
|
*/
|
|
279
280
|
|
|
280
|
-
interface JobQueueConfig {
|
|
281
|
-
dataDir: string;
|
|
282
|
-
}
|
|
283
281
|
declare class JobQueue {
|
|
284
282
|
private eventBus?;
|
|
285
283
|
private jobsDir;
|
|
@@ -287,7 +285,7 @@ declare class JobQueue {
|
|
|
287
285
|
private pendingQueue;
|
|
288
286
|
private watcher;
|
|
289
287
|
private loadDebounceTimer;
|
|
290
|
-
constructor(
|
|
288
|
+
constructor(project: SemiontProject, logger: Logger, eventBus?: EventBus | undefined);
|
|
291
289
|
/**
|
|
292
290
|
* Initialize job queue directories, load pending jobs, and start fs.watch
|
|
293
291
|
*/
|
|
@@ -348,8 +346,6 @@ declare class JobQueue {
|
|
|
348
346
|
cancelled: number;
|
|
349
347
|
}>;
|
|
350
348
|
}
|
|
351
|
-
declare function getJobQueue(): JobQueue;
|
|
352
|
-
declare function initializeJobQueue(config: JobQueueConfig, logger: Logger, eventBus?: EventBus): Promise<JobQueue>;
|
|
353
349
|
|
|
354
350
|
/**
|
|
355
351
|
* Job Worker Base Class
|
|
@@ -426,6 +422,7 @@ declare abstract class JobWorker {
|
|
|
426
422
|
* emits events on the EventBus for all writes.
|
|
427
423
|
*/
|
|
428
424
|
|
|
425
|
+
type Agent$4 = components['schemas']['Agent'];
|
|
429
426
|
interface DetectedAnnotation {
|
|
430
427
|
annotation: {
|
|
431
428
|
selector: {
|
|
@@ -440,9 +437,10 @@ interface DetectedAnnotation {
|
|
|
440
437
|
}
|
|
441
438
|
declare class ReferenceAnnotationWorker extends JobWorker {
|
|
442
439
|
private inferenceClient;
|
|
440
|
+
private generator;
|
|
443
441
|
private eventBus;
|
|
444
442
|
private contentFetcher;
|
|
445
|
-
constructor(jobQueue: JobQueue, inferenceClient: InferenceClient, eventBus: EventBus, contentFetcher: ContentFetcher, logger: Logger);
|
|
443
|
+
constructor(jobQueue: JobQueue, inferenceClient: InferenceClient, generator: Agent$4, eventBus: EventBus, contentFetcher: ContentFetcher, logger: Logger);
|
|
446
444
|
protected getWorkerName(): string;
|
|
447
445
|
protected canProcessJob(job: AnyJob): boolean;
|
|
448
446
|
protected executeJob(job: AnyJob): Promise<DetectionResult>;
|
|
@@ -504,12 +502,14 @@ declare class GenerationWorker extends JobWorker {
|
|
|
504
502
|
* that should be highlighted and creates highlight annotations.
|
|
505
503
|
*/
|
|
506
504
|
|
|
505
|
+
type Agent$3 = components['schemas']['Agent'];
|
|
507
506
|
declare class HighlightAnnotationWorker extends JobWorker {
|
|
508
507
|
private inferenceClient;
|
|
508
|
+
private generator;
|
|
509
509
|
private eventBus;
|
|
510
510
|
private contentFetcher;
|
|
511
511
|
private isFirstProgress;
|
|
512
|
-
constructor(jobQueue: JobQueue, inferenceClient: InferenceClient, eventBus: EventBus, contentFetcher: ContentFetcher, logger: Logger);
|
|
512
|
+
constructor(jobQueue: JobQueue, inferenceClient: InferenceClient, generator: Agent$3, eventBus: EventBus, contentFetcher: ContentFetcher, logger: Logger);
|
|
513
513
|
protected getWorkerName(): string;
|
|
514
514
|
protected canProcessJob(job: AnyJob): boolean;
|
|
515
515
|
protected executeJob(job: AnyJob): Promise<HighlightDetectionResult>;
|
|
@@ -534,12 +534,14 @@ declare class HighlightAnnotationWorker extends JobWorker {
|
|
|
534
534
|
* passages in the text and creates assessment annotations.
|
|
535
535
|
*/
|
|
536
536
|
|
|
537
|
+
type Agent$2 = components['schemas']['Agent'];
|
|
537
538
|
declare class AssessmentAnnotationWorker extends JobWorker {
|
|
538
539
|
private inferenceClient;
|
|
540
|
+
private generator;
|
|
539
541
|
private eventBus;
|
|
540
542
|
private contentFetcher;
|
|
541
543
|
private isFirstProgress;
|
|
542
|
-
constructor(jobQueue: JobQueue, inferenceClient: InferenceClient, eventBus: EventBus, contentFetcher: ContentFetcher, logger: Logger);
|
|
544
|
+
constructor(jobQueue: JobQueue, inferenceClient: InferenceClient, generator: Agent$2, eventBus: EventBus, contentFetcher: ContentFetcher, logger: Logger);
|
|
543
545
|
protected getWorkerName(): string;
|
|
544
546
|
protected canProcessJob(job: AnyJob): boolean;
|
|
545
547
|
protected executeJob(job: AnyJob): Promise<AssessmentDetectionResult>;
|
|
@@ -564,12 +566,14 @@ declare class AssessmentAnnotationWorker extends JobWorker {
|
|
|
564
566
|
* that would benefit from explanatory comments and creates comment annotations.
|
|
565
567
|
*/
|
|
566
568
|
|
|
569
|
+
type Agent$1 = components['schemas']['Agent'];
|
|
567
570
|
declare class CommentAnnotationWorker extends JobWorker {
|
|
568
571
|
private inferenceClient;
|
|
572
|
+
private generator;
|
|
569
573
|
private eventBus;
|
|
570
574
|
private contentFetcher;
|
|
571
575
|
private isFirstProgress;
|
|
572
|
-
constructor(jobQueue: JobQueue, inferenceClient: InferenceClient, eventBus: EventBus, contentFetcher: ContentFetcher, logger: Logger);
|
|
576
|
+
constructor(jobQueue: JobQueue, inferenceClient: InferenceClient, generator: Agent$1, eventBus: EventBus, contentFetcher: ContentFetcher, logger: Logger);
|
|
573
577
|
protected getWorkerName(): string;
|
|
574
578
|
protected canProcessJob(job: AnyJob): boolean;
|
|
575
579
|
protected executeJob(job: AnyJob): Promise<CommentDetectionResult>;
|
|
@@ -595,12 +599,14 @@ declare class CommentAnnotationWorker extends JobWorker {
|
|
|
595
599
|
* creates tag annotations with dual-body structure.
|
|
596
600
|
*/
|
|
597
601
|
|
|
602
|
+
type Agent = components['schemas']['Agent'];
|
|
598
603
|
declare class TagAnnotationWorker extends JobWorker {
|
|
599
604
|
private inferenceClient;
|
|
605
|
+
private generator;
|
|
600
606
|
private eventBus;
|
|
601
607
|
private contentFetcher;
|
|
602
608
|
private isFirstProgress;
|
|
603
|
-
constructor(jobQueue: JobQueue, inferenceClient: InferenceClient, eventBus: EventBus, contentFetcher: ContentFetcher, logger: Logger);
|
|
609
|
+
constructor(jobQueue: JobQueue, inferenceClient: InferenceClient, generator: Agent, eventBus: EventBus, contentFetcher: ContentFetcher, logger: Logger);
|
|
604
610
|
protected getWorkerName(): string;
|
|
605
611
|
protected canProcessJob(job: AnyJob): boolean;
|
|
606
612
|
protected executeJob(job: AnyJob): Promise<TagDetectionResult>;
|
|
@@ -722,4 +728,4 @@ declare function generateResourceFromTopic(topic: string, entityTypes: string[],
|
|
|
722
728
|
content: string;
|
|
723
729
|
}>;
|
|
724
730
|
|
|
725
|
-
export { AnnotationDetection, type AnyJob, AssessmentAnnotationWorker, type AssessmentDetectionJob, type AssessmentDetectionParams, type AssessmentDetectionProgress, type AssessmentDetectionResult, type CancelledJob, CommentAnnotationWorker, type CommentDetectionJob, type CommentDetectionParams, type CommentDetectionProgress, type CommentDetectionResult, type CompleteJob, type ContentFetcher, type DetectionJob, type DetectionParams, type DetectionProgress, type DetectionResult, type FailedJob, type GenerationJob, type GenerationParams, type GenerationResult, GenerationWorker, HighlightAnnotationWorker, type HighlightDetectionJob, type HighlightDetectionParams, type HighlightDetectionProgress, type HighlightDetectionResult, type JobMetadata, type JobQueryFilters, JobQueue, type
|
|
731
|
+
export { AnnotationDetection, type AnyJob, AssessmentAnnotationWorker, type AssessmentDetectionJob, type AssessmentDetectionParams, type AssessmentDetectionProgress, type AssessmentDetectionResult, type CancelledJob, CommentAnnotationWorker, type CommentDetectionJob, type CommentDetectionParams, type CommentDetectionProgress, type CommentDetectionResult, type CompleteJob, type ContentFetcher, type DetectionJob, type DetectionParams, type DetectionProgress, type DetectionResult, type FailedJob, type GenerationJob, type GenerationParams, type GenerationResult, GenerationWorker, HighlightAnnotationWorker, type HighlightDetectionJob, type HighlightDetectionParams, type HighlightDetectionProgress, type HighlightDetectionResult, type JobMetadata, type JobQueryFilters, JobQueue, type JobStatus, type JobType, JobWorker, type PendingJob, ReferenceAnnotationWorker, type RunningJob, TagAnnotationWorker, type TagDetectionJob, type TagDetectionParams, type TagDetectionProgress, type TagDetectionResult, type YieldProgress, generateResourceFromTopic, isCancelledJob, isCompleteJob, isFailedJob, isPendingJob, isRunningJob };
|
package/dist/index.js
CHANGED
|
@@ -9712,9 +9712,9 @@ var require_operators = __commonJS({
|
|
|
9712
9712
|
}
|
|
9713
9713
|
});
|
|
9714
9714
|
var JobQueue = class {
|
|
9715
|
-
constructor(
|
|
9715
|
+
constructor(project, logger, eventBus) {
|
|
9716
9716
|
this.eventBus = eventBus;
|
|
9717
|
-
this.jobsDir =
|
|
9717
|
+
this.jobsDir = project.jobsDir;
|
|
9718
9718
|
this.logger = logger;
|
|
9719
9719
|
}
|
|
9720
9720
|
jobsDir;
|
|
@@ -9975,18 +9975,6 @@ var JobQueue = class {
|
|
|
9975
9975
|
return stats;
|
|
9976
9976
|
}
|
|
9977
9977
|
};
|
|
9978
|
-
var jobQueue = null;
|
|
9979
|
-
function getJobQueue() {
|
|
9980
|
-
if (!jobQueue) {
|
|
9981
|
-
throw new Error("JobQueue not initialized. Call initializeJobQueue() first.");
|
|
9982
|
-
}
|
|
9983
|
-
return jobQueue;
|
|
9984
|
-
}
|
|
9985
|
-
async function initializeJobQueue(config, logger, eventBus) {
|
|
9986
|
-
jobQueue = new JobQueue(config, logger, eventBus);
|
|
9987
|
-
await jobQueue.initialize();
|
|
9988
|
-
return jobQueue;
|
|
9989
|
-
}
|
|
9990
9978
|
|
|
9991
9979
|
// src/job-worker.ts
|
|
9992
9980
|
var JobWorker = class {
|
|
@@ -9996,8 +9984,8 @@ var JobWorker = class {
|
|
|
9996
9984
|
errorBackoffMs;
|
|
9997
9985
|
jobQueue;
|
|
9998
9986
|
logger;
|
|
9999
|
-
constructor(
|
|
10000
|
-
this.jobQueue =
|
|
9987
|
+
constructor(jobQueue, pollIntervalMs = 1e3, errorBackoffMs = 5e3, logger) {
|
|
9988
|
+
this.jobQueue = jobQueue;
|
|
10001
9989
|
this.pollIntervalMs = pollIntervalMs;
|
|
10002
9990
|
this.errorBackoffMs = errorBackoffMs;
|
|
10003
9991
|
this.logger = logger;
|
|
@@ -11083,9 +11071,10 @@ Example output:
|
|
|
11083
11071
|
|
|
11084
11072
|
// src/workers/reference-annotation-worker.ts
|
|
11085
11073
|
var ReferenceAnnotationWorker = class extends JobWorker {
|
|
11086
|
-
constructor(
|
|
11087
|
-
super(
|
|
11074
|
+
constructor(jobQueue, inferenceClient, generator, eventBus, contentFetcher, logger) {
|
|
11075
|
+
super(jobQueue, void 0, void 0, logger);
|
|
11088
11076
|
this.inferenceClient = inferenceClient;
|
|
11077
|
+
this.generator = generator;
|
|
11089
11078
|
this.eventBus = eventBus;
|
|
11090
11079
|
this.contentFetcher = contentFetcher;
|
|
11091
11080
|
}
|
|
@@ -11201,6 +11190,7 @@ var ReferenceAnnotationWorker = class extends JobWorker {
|
|
|
11201
11190
|
id: referenceId,
|
|
11202
11191
|
motivation: "linking",
|
|
11203
11192
|
creator,
|
|
11193
|
+
generator: this.generator,
|
|
11204
11194
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11205
11195
|
target: {
|
|
11206
11196
|
source: job.params.resourceId,
|
|
@@ -11495,8 +11485,8 @@ Requirements:
|
|
|
11495
11485
|
var import_rxjs = __toESM(require_cjs());
|
|
11496
11486
|
var import_operators = __toESM(require_operators());
|
|
11497
11487
|
var GenerationWorker = class extends JobWorker {
|
|
11498
|
-
constructor(
|
|
11499
|
-
super(
|
|
11488
|
+
constructor(jobQueue, inferenceClient, eventBus, logger) {
|
|
11489
|
+
super(jobQueue, void 0, void 0, logger);
|
|
11500
11490
|
this.inferenceClient = inferenceClient;
|
|
11501
11491
|
this.eventBus = eventBus;
|
|
11502
11492
|
}
|
|
@@ -11721,9 +11711,10 @@ var GenerationWorker = class extends JobWorker {
|
|
|
11721
11711
|
}
|
|
11722
11712
|
};
|
|
11723
11713
|
var HighlightAnnotationWorker = class extends JobWorker {
|
|
11724
|
-
constructor(
|
|
11725
|
-
super(
|
|
11714
|
+
constructor(jobQueue, inferenceClient, generator, eventBus, contentFetcher, logger) {
|
|
11715
|
+
super(jobQueue, void 0, void 0, logger);
|
|
11726
11716
|
this.inferenceClient = inferenceClient;
|
|
11717
|
+
this.generator = generator;
|
|
11727
11718
|
this.eventBus = eventBus;
|
|
11728
11719
|
this.contentFetcher = contentFetcher;
|
|
11729
11720
|
}
|
|
@@ -11883,6 +11874,7 @@ var HighlightAnnotationWorker = class extends JobWorker {
|
|
|
11883
11874
|
"id": annotationIdVal,
|
|
11884
11875
|
"motivation": "highlighting",
|
|
11885
11876
|
creator,
|
|
11877
|
+
generator: this.generator,
|
|
11886
11878
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11887
11879
|
"target": {
|
|
11888
11880
|
type: "SpecificResource",
|
|
@@ -11912,9 +11904,10 @@ var HighlightAnnotationWorker = class extends JobWorker {
|
|
|
11912
11904
|
}
|
|
11913
11905
|
};
|
|
11914
11906
|
var AssessmentAnnotationWorker = class extends JobWorker {
|
|
11915
|
-
constructor(
|
|
11916
|
-
super(
|
|
11907
|
+
constructor(jobQueue, inferenceClient, generator, eventBus, contentFetcher, logger) {
|
|
11908
|
+
super(jobQueue, void 0, void 0, logger);
|
|
11917
11909
|
this.inferenceClient = inferenceClient;
|
|
11910
|
+
this.generator = generator;
|
|
11918
11911
|
this.eventBus = eventBus;
|
|
11919
11912
|
this.contentFetcher = contentFetcher;
|
|
11920
11913
|
}
|
|
@@ -12075,6 +12068,7 @@ var AssessmentAnnotationWorker = class extends JobWorker {
|
|
|
12075
12068
|
"id": annotationIdVal,
|
|
12076
12069
|
"motivation": "assessing",
|
|
12077
12070
|
creator,
|
|
12071
|
+
generator: this.generator,
|
|
12078
12072
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12079
12073
|
"target": {
|
|
12080
12074
|
type: "SpecificResource",
|
|
@@ -12107,9 +12101,10 @@ var AssessmentAnnotationWorker = class extends JobWorker {
|
|
|
12107
12101
|
}
|
|
12108
12102
|
};
|
|
12109
12103
|
var CommentAnnotationWorker = class extends JobWorker {
|
|
12110
|
-
constructor(
|
|
12111
|
-
super(
|
|
12104
|
+
constructor(jobQueue, inferenceClient, generator, eventBus, contentFetcher, logger) {
|
|
12105
|
+
super(jobQueue, void 0, void 0, logger);
|
|
12112
12106
|
this.inferenceClient = inferenceClient;
|
|
12107
|
+
this.generator = generator;
|
|
12113
12108
|
this.eventBus = eventBus;
|
|
12114
12109
|
this.contentFetcher = contentFetcher;
|
|
12115
12110
|
}
|
|
@@ -12270,6 +12265,7 @@ var CommentAnnotationWorker = class extends JobWorker {
|
|
|
12270
12265
|
id: annotationIdVal,
|
|
12271
12266
|
motivation: "commenting",
|
|
12272
12267
|
creator,
|
|
12268
|
+
generator: this.generator,
|
|
12273
12269
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12274
12270
|
target: {
|
|
12275
12271
|
type: "SpecificResource",
|
|
@@ -12310,9 +12306,10 @@ var CommentAnnotationWorker = class extends JobWorker {
|
|
|
12310
12306
|
}
|
|
12311
12307
|
};
|
|
12312
12308
|
var TagAnnotationWorker = class extends JobWorker {
|
|
12313
|
-
constructor(
|
|
12314
|
-
super(
|
|
12309
|
+
constructor(jobQueue, inferenceClient, generator, eventBus, contentFetcher, logger) {
|
|
12310
|
+
super(jobQueue, void 0, void 0, logger);
|
|
12315
12311
|
this.inferenceClient = inferenceClient;
|
|
12312
|
+
this.generator = generator;
|
|
12316
12313
|
this.eventBus = eventBus;
|
|
12317
12314
|
this.contentFetcher = contentFetcher;
|
|
12318
12315
|
}
|
|
@@ -12505,6 +12502,7 @@ var TagAnnotationWorker = class extends JobWorker {
|
|
|
12505
12502
|
id: annotationIdVal,
|
|
12506
12503
|
motivation: "tagging",
|
|
12507
12504
|
creator,
|
|
12505
|
+
generator: this.generator,
|
|
12508
12506
|
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
12509
12507
|
target: {
|
|
12510
12508
|
type: "SpecificResource",
|
|
@@ -12552,6 +12550,6 @@ var TagAnnotationWorker = class extends JobWorker {
|
|
|
12552
12550
|
}
|
|
12553
12551
|
};
|
|
12554
12552
|
|
|
12555
|
-
export { AnnotationDetection, AssessmentAnnotationWorker, CommentAnnotationWorker, GenerationWorker, HighlightAnnotationWorker, JobQueue, JobWorker, ReferenceAnnotationWorker, TagAnnotationWorker, generateResourceFromTopic,
|
|
12553
|
+
export { AnnotationDetection, AssessmentAnnotationWorker, CommentAnnotationWorker, GenerationWorker, HighlightAnnotationWorker, JobQueue, JobWorker, ReferenceAnnotationWorker, TagAnnotationWorker, generateResourceFromTopic, isCancelledJob, isCompleteJob, isFailedJob, isPendingJob, isRunningJob };
|
|
12556
12554
|
//# sourceMappingURL=index.js.map
|
|
12557
12555
|
//# sourceMappingURL=index.js.map
|