@semiont/jobs 0.5.32 → 0.5.34
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 +51 -60
- package/dist/index.js +227 -143
- package/dist/index.js.map +1 -1
- package/dist/worker-main.js +326 -179
- package/dist/worker-main.js.map +1 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JobId, UserId, ResourceId, EntityType, GenerationJobParams, TagSchema, Logger, EventBus, components, Annotation, SupportedMediaType, GatheredContext } from '@semiont/core';
|
|
1
|
+
import { JobId, UserId, ResourceId, EntityType, JobReferenceAnnotationResult, GenerationJobParams, JobHighlightAnnotationResult, JobAssessmentAnnotationResult, JobCommentAnnotationResult, TagSchema, JobTagAnnotationResult, Logger, EventBus, components, Annotation, SupportedMediaType, GatheredContext } from '@semiont/core';
|
|
2
2
|
import { SemiontState } from '@semiont/core/node';
|
|
3
3
|
import { InferenceClient } from '@semiont/inference';
|
|
4
4
|
|
|
@@ -142,15 +142,6 @@ interface DetectionProgress {
|
|
|
142
142
|
entitiesFound: number;
|
|
143
143
|
entitiesEmitted: number;
|
|
144
144
|
}
|
|
145
|
-
/**
|
|
146
|
-
* Detection job result
|
|
147
|
-
*/
|
|
148
|
-
interface DetectionResult {
|
|
149
|
-
kind: 'reference-annotation';
|
|
150
|
-
totalFound: number;
|
|
151
|
-
totalEmitted: number;
|
|
152
|
-
errors: number;
|
|
153
|
-
}
|
|
154
145
|
/**
|
|
155
146
|
* Generation job progress
|
|
156
147
|
*/
|
|
@@ -178,14 +169,6 @@ interface HighlightDetectionProgress {
|
|
|
178
169
|
percentage: number;
|
|
179
170
|
message?: string;
|
|
180
171
|
}
|
|
181
|
-
/**
|
|
182
|
-
* Highlight detection job result
|
|
183
|
-
*/
|
|
184
|
-
interface HighlightDetectionResult {
|
|
185
|
-
kind: 'highlight-annotation';
|
|
186
|
-
highlightsFound: number;
|
|
187
|
-
highlightsCreated: number;
|
|
188
|
-
}
|
|
189
172
|
/**
|
|
190
173
|
* Assessment detection job progress
|
|
191
174
|
*/
|
|
@@ -194,14 +177,6 @@ interface AssessmentDetectionProgress {
|
|
|
194
177
|
percentage: number;
|
|
195
178
|
message?: string;
|
|
196
179
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Assessment detection job result
|
|
199
|
-
*/
|
|
200
|
-
interface AssessmentDetectionResult {
|
|
201
|
-
kind: 'assessment-annotation';
|
|
202
|
-
assessmentsFound: number;
|
|
203
|
-
assessmentsCreated: number;
|
|
204
|
-
}
|
|
205
180
|
/**
|
|
206
181
|
* Comment detection job progress
|
|
207
182
|
*/
|
|
@@ -210,14 +185,6 @@ interface CommentDetectionProgress {
|
|
|
210
185
|
percentage: number;
|
|
211
186
|
message?: string;
|
|
212
187
|
}
|
|
213
|
-
/**
|
|
214
|
-
* Comment detection job result
|
|
215
|
-
*/
|
|
216
|
-
interface CommentDetectionResult {
|
|
217
|
-
kind: 'comment-annotation';
|
|
218
|
-
commentsFound: number;
|
|
219
|
-
commentsCreated: number;
|
|
220
|
-
}
|
|
221
188
|
/**
|
|
222
189
|
* Tag detection job progress
|
|
223
190
|
*/
|
|
@@ -229,15 +196,6 @@ interface TagDetectionProgress {
|
|
|
229
196
|
totalCategories: number;
|
|
230
197
|
message?: string;
|
|
231
198
|
}
|
|
232
|
-
/**
|
|
233
|
-
* Tag detection job result
|
|
234
|
-
*/
|
|
235
|
-
interface TagDetectionResult {
|
|
236
|
-
kind: 'tag-annotation';
|
|
237
|
-
tagsFound: number;
|
|
238
|
-
tagsCreated: number;
|
|
239
|
-
byCategory: Record<string, number>;
|
|
240
|
-
}
|
|
241
199
|
/**
|
|
242
200
|
* Pending job - just created, waiting to be picked up
|
|
243
201
|
*/
|
|
@@ -292,12 +250,12 @@ interface CancelledJob<P> {
|
|
|
292
250
|
* Generic job - discriminated union of all states
|
|
293
251
|
*/
|
|
294
252
|
type Job<P, PG, R> = PendingJob<P> | RunningJob<P, PG> | CompleteJob<P, R> | FailedJob<P> | CancelledJob<P>;
|
|
295
|
-
type DetectionJob = Job<DetectionParams, DetectionProgress,
|
|
253
|
+
type DetectionJob = Job<DetectionParams, DetectionProgress, JobReferenceAnnotationResult>;
|
|
296
254
|
type GenerationJob = Job<GenerationJobParams, YieldProgress, GenerationResult>;
|
|
297
|
-
type HighlightDetectionJob = Job<HighlightDetectionParams, HighlightDetectionProgress,
|
|
298
|
-
type AssessmentDetectionJob = Job<AssessmentDetectionParams, AssessmentDetectionProgress,
|
|
299
|
-
type CommentDetectionJob = Job<CommentDetectionParams, CommentDetectionProgress,
|
|
300
|
-
type TagDetectionJob = Job<TagDetectionParams, TagDetectionProgress,
|
|
255
|
+
type HighlightDetectionJob = Job<HighlightDetectionParams, HighlightDetectionProgress, JobHighlightAnnotationResult>;
|
|
256
|
+
type AssessmentDetectionJob = Job<AssessmentDetectionParams, AssessmentDetectionProgress, JobAssessmentAnnotationResult>;
|
|
257
|
+
type CommentDetectionJob = Job<CommentDetectionParams, CommentDetectionProgress, JobCommentAnnotationResult>;
|
|
258
|
+
type TagDetectionJob = Job<TagDetectionParams, TagDetectionProgress, JobTagAnnotationResult>;
|
|
301
259
|
/**
|
|
302
260
|
* Discriminated union of all job types
|
|
303
261
|
*/
|
|
@@ -555,13 +513,23 @@ type JobProgressMessage = components['schemas']['JobProgressMessage'];
|
|
|
555
513
|
/** The five W3C motivations this system mints — a closed vocabulary, so it is
|
|
556
514
|
* typed as one rather than as `string`. */
|
|
557
515
|
type Motivation = Annotation['motivation'];
|
|
516
|
+
/**
|
|
517
|
+
* A detection processor returns only its result. Annotations leave through
|
|
518
|
+
* `onChunkComplete`, per chunk — a return that also carried them would be a
|
|
519
|
+
* second path to the same write.
|
|
520
|
+
*/
|
|
558
521
|
interface ProcessorResult<R> {
|
|
559
|
-
annotations: Annotation[];
|
|
560
522
|
result: R;
|
|
561
523
|
}
|
|
562
|
-
declare function processHighlightJob(content: string, inferenceClient: InferenceClient, params: HighlightDetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress
|
|
563
|
-
|
|
564
|
-
|
|
524
|
+
declare function processHighlightJob(content: string, inferenceClient: InferenceClient, params: HighlightDetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress,
|
|
525
|
+
/** This chunk's novel annotations, awaited: the durability write. */
|
|
526
|
+
onChunkComplete: (annotations: Annotation[]) => Promise<void>): Promise<ProcessorResult<JobHighlightAnnotationResult>>;
|
|
527
|
+
declare function processCommentJob(content: string, inferenceClient: InferenceClient, params: CommentDetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress,
|
|
528
|
+
/** This chunk's novel annotations, awaited: the durability write. */
|
|
529
|
+
onChunkComplete: (annotations: Annotation[]) => Promise<void>): Promise<ProcessorResult<JobCommentAnnotationResult>>;
|
|
530
|
+
declare function processAssessmentJob(content: string, inferenceClient: InferenceClient, params: AssessmentDetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress,
|
|
531
|
+
/** This chunk's novel annotations, awaited: the durability write. */
|
|
532
|
+
onChunkComplete: (annotations: Annotation[]) => Promise<void>): Promise<ProcessorResult<JobAssessmentAnnotationResult>>;
|
|
565
533
|
/**
|
|
566
534
|
* Reference detection commits per UNIT — one entity type — through
|
|
567
535
|
* `onUnitComplete` (ABANDONED-INFERENCE P2, checkpointed resume): the
|
|
@@ -571,10 +539,21 @@ declare function processAssessmentJob(content: string, inferenceClient: Inferenc
|
|
|
571
539
|
* annotations as well would recreate the post-run batch that N2 showed
|
|
572
540
|
* discards completed work wholesale.
|
|
573
541
|
*/
|
|
574
|
-
declare function processReferenceJob(content: string, inferenceClient: InferenceClient, params: DetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress, logger: Logger,
|
|
575
|
-
|
|
542
|
+
declare function processReferenceJob(content: string, inferenceClient: InferenceClient, params: DetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress, logger: Logger,
|
|
543
|
+
/**
|
|
544
|
+
* The CHECKPOINT, fired once per unit after every one of its chunks has
|
|
545
|
+
* committed. It carries no annotations — the effect already happened per
|
|
546
|
+
* chunk through `onChunkComplete`, and a unit callback that also carried
|
|
547
|
+
* them would be a second commit path.
|
|
548
|
+
*/
|
|
549
|
+
onUnitComplete: (entityType: string) => Promise<void>, signal?: AbortSignal,
|
|
550
|
+
/** This chunk's novel annotations, awaited: the durability write. */
|
|
551
|
+
onChunkComplete?: (annotations: Annotation[]) => Promise<void>): Promise<{
|
|
552
|
+
result: JobReferenceAnnotationResult;
|
|
576
553
|
}>;
|
|
577
|
-
declare function processTagJob(content: string, inferenceClient: InferenceClient, params: TagDetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress
|
|
554
|
+
declare function processTagJob(content: string, inferenceClient: InferenceClient, params: TagDetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress,
|
|
555
|
+
/** This chunk's novel annotations, awaited: the durability write. */
|
|
556
|
+
onChunkComplete: (annotations: Annotation[]) => Promise<void>): Promise<ProcessorResult<JobTagAnnotationResult>>;
|
|
578
557
|
declare function processGenerationJob(inferenceClient: InferenceClient, params: GenerationJobParams, onProgress: OnProgress, logger: Logger): Promise<{
|
|
579
558
|
content: Uint8Array;
|
|
580
559
|
title: string;
|
|
@@ -659,7 +638,9 @@ declare class AnnotationDetection {
|
|
|
659
638
|
* (source-resource locale). See `types.ts` "Locale conventions" for the
|
|
660
639
|
* full discussion.
|
|
661
640
|
*/
|
|
662
|
-
static detectComments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string, onActivity?: (completedChunks: number, totalChunks: number) => void
|
|
641
|
+
static detectComments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string, onActivity?: (completedChunks: number, totalChunks: number) => void,
|
|
642
|
+
/** This chunk's matches, as the chunk completes. */
|
|
643
|
+
onChunkResults?: (matches: CommentMatch[]) => Promise<void>): Promise<CommentMatch[]>;
|
|
663
644
|
/**
|
|
664
645
|
* Detect highlights in content.
|
|
665
646
|
*
|
|
@@ -667,7 +648,9 @@ declare class AnnotationDetection {
|
|
|
667
648
|
* applies, used in the prompt so the LLM analyzes non-English source
|
|
668
649
|
* correctly.
|
|
669
650
|
*/
|
|
670
|
-
static detectHighlights(content: string, client: InferenceClient, instructions?: string, density?: number, sourceLanguage?: string, onActivity?: (completedChunks: number, totalChunks: number) => void
|
|
651
|
+
static detectHighlights(content: string, client: InferenceClient, instructions?: string, density?: number, sourceLanguage?: string, onActivity?: (completedChunks: number, totalChunks: number) => void,
|
|
652
|
+
/** This chunk's matches, as the chunk completes. */
|
|
653
|
+
onChunkResults?: (matches: HighlightMatch[]) => Promise<void>): Promise<HighlightMatch[]>;
|
|
671
654
|
/**
|
|
672
655
|
* Detect assessments in content.
|
|
673
656
|
*
|
|
@@ -675,7 +658,9 @@ declare class AnnotationDetection {
|
|
|
675
658
|
* (annotation body locale). `sourceLanguage` is the locale of the content
|
|
676
659
|
* being analyzed (source-resource locale).
|
|
677
660
|
*/
|
|
678
|
-
static detectAssessments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string, onActivity?: (completedChunks: number, totalChunks: number) => void
|
|
661
|
+
static detectAssessments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string, onActivity?: (completedChunks: number, totalChunks: number) => void,
|
|
662
|
+
/** This chunk's matches, as the chunk completes. */
|
|
663
|
+
onChunkResults?: (matches: AssessmentMatch[]) => Promise<void>): Promise<AssessmentMatch[]>;
|
|
679
664
|
/**
|
|
680
665
|
* Detect tags in content for a specific category.
|
|
681
666
|
*
|
|
@@ -688,7 +673,13 @@ declare class AnnotationDetection {
|
|
|
688
673
|
* identifiers, not LLM-generated text — so it's consumed at the body-stamp
|
|
689
674
|
* site, not here.
|
|
690
675
|
*/
|
|
691
|
-
static detectTags(content: string, client: InferenceClient, schema: TagSchema, category: string, sourceLanguage?: string, onActivity?: (completedChunks: number, totalChunks: number) => void
|
|
676
|
+
static detectTags(content: string, client: InferenceClient, schema: TagSchema, category: string, sourceLanguage?: string, onActivity?: (completedChunks: number, totalChunks: number) => void,
|
|
677
|
+
/**
|
|
678
|
+
* This chunk's matches, ANCHORED before they leave: `parse` here yields
|
|
679
|
+
* raw tags, so this path runs `validateTagOffsets` per chunk — a per-item
|
|
680
|
+
* anchor against the full document, so partitioning changes nothing.
|
|
681
|
+
*/
|
|
682
|
+
onChunkResults?: (matches: TagMatch[]) => Promise<void>): Promise<TagMatch[]>;
|
|
692
683
|
}
|
|
693
684
|
|
|
694
685
|
/**
|
|
@@ -763,4 +754,4 @@ declare function generateResourceFromTopic(topic: string, entityTypes: string[],
|
|
|
763
754
|
declare const STALL_THRESHOLD_MS: number;
|
|
764
755
|
|
|
765
756
|
export { AnnotationDetection, FsJobQueue, STALL_THRESHOLD_MS, generateResourceFromTopic, isCancelledJob, isCompleteJob, isFailedJob, isPendingJob, isRunningJob, processAssessmentJob, processCommentJob, processGenerationJob, processHighlightJob, processReferenceJob, processTagJob };
|
|
766
|
-
export type { AnyJob, AssessmentDetectionJob, AssessmentDetectionParams, AssessmentDetectionProgress,
|
|
757
|
+
export type { AnyJob, AssessmentDetectionJob, AssessmentDetectionParams, AssessmentDetectionProgress, CancelledJob, CommentDetectionJob, CommentDetectionParams, CommentDetectionProgress, CompleteJob, DetectionJob, DetectionParams, DetectionProgress, FailedJob, GenerationJob, GenerationResult, HighlightDetectionJob, HighlightDetectionParams, HighlightDetectionProgress, JobMetadata, JobQueryFilters, JobQueue, JobStatus, JobType, OnProgress, PendingJob, ProcessorResult, RunningJob, TagDetectionJob, TagDetectionParams, TagDetectionProgress, YieldProgress };
|