@semiont/jobs 0.5.24 → 0.5.26

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { JobId, UserId, ResourceId, EntityType, AnnotationId, GatheredContext, SupportedMediaType, TagSchema, Logger, EventBus, components } from '@semiont/core';
1
+ import { JobId, UserId, ResourceId, EntityType, AnnotationId, GatheredContext, SupportedMediaType, TagSchema, Logger, EventBus, components, Annotation } from '@semiont/core';
2
2
  import { SemiontProject } from '@semiont/core/node';
3
3
  import { InferenceClient } from '@semiont/inference';
4
4
 
@@ -524,17 +524,6 @@ interface GenerationCitation {
524
524
  exact: string;
525
525
  }
526
526
 
527
- /**
528
- * Job Processors
529
- *
530
- * Pure functions that take content + inference client + params,
531
- * report progress via callback, and return annotations + results.
532
- *
533
- * No EventBus, no JobQueue, no side effects except calling inference.
534
- * Driven by the remote worker process (worker-process.ts), which claims
535
- * jobs over SSE and dispatches by jobType to these functions.
536
- */
537
-
538
527
  /** A detected span — offsets into the extracted `.text`, plus optional context. */
539
528
  type SpanMatch = {
540
529
  exact: string;
@@ -550,7 +539,7 @@ type SpanMatch = {
550
539
  * motivation-specific body. This is the single axis that varies by media type,
551
540
  * so the detection processors themselves stay media-agnostic.
552
541
  */
553
- type BuildAnnotation = (motivation: string, match: SpanMatch, body?: Record<string, unknown> | Record<string, unknown>[]) => Record<string, unknown>;
542
+ type BuildAnnotation = (motivation: Motivation, match: SpanMatch, body?: Annotation['body']) => Annotation;
554
543
  /**
555
544
  * Progress callback. The three positional args satisfy the minimum
556
545
  * `JobProgress` required fields (`percentage`, `message`, `stage`).
@@ -560,8 +549,11 @@ type BuildAnnotation = (motivation: string, match: SpanMatch, body?: Record<stri
560
549
  */
561
550
  type OnProgress = (percentage: number, message: string, stage: string, extra?: Partial<JobProgress>) => void;
562
551
  type JobProgress = components['schemas']['JobProgress'];
552
+ /** The five W3C motivations this system mints — a closed vocabulary, so it is
553
+ * typed as one rather than as `string`. */
554
+ type Motivation = Annotation['motivation'];
563
555
  interface ProcessorResult<R> {
564
- annotations: Record<string, unknown>[];
556
+ annotations: Annotation[];
565
557
  result: R;
566
558
  }
567
559
  declare function processHighlightJob(content: string, inferenceClient: InferenceClient, params: HighlightDetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress): Promise<ProcessorResult<HighlightDetectionResult>>;
@@ -570,7 +562,7 @@ declare function processAssessmentJob(content: string, inferenceClient: Inferenc
570
562
  declare function processReferenceJob(content: string, inferenceClient: InferenceClient, params: DetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress, logger: Logger): Promise<ProcessorResult<DetectionResult>>;
571
563
  declare function processTagJob(content: string, inferenceClient: InferenceClient, params: TagDetectionParams, buildAnnotation: BuildAnnotation, onProgress: OnProgress): Promise<ProcessorResult<TagDetectionResult>>;
572
564
  declare function processGenerationJob(inferenceClient: InferenceClient, params: GenerationParams, onProgress: OnProgress, logger: Logger): Promise<{
573
- content: string;
565
+ content: Uint8Array;
574
566
  title: string;
575
567
  format: SupportedMediaType;
576
568
  citations: GenerationCitation[];
@@ -587,6 +579,7 @@ declare function processGenerationJob(inferenceClient: InferenceClient, params:
587
579
  * NOTE: These are static utility methods without logger access.
588
580
  * Console statements kept for debugging - consider adding logger parameter in future.
589
581
  */
582
+
590
583
  /**
591
584
  * Represents a detected comment with validated position
592
585
  */
@@ -652,7 +645,7 @@ declare class AnnotationDetection {
652
645
  * (source-resource locale). See `types.ts` "Locale conventions" for the
653
646
  * full discussion.
654
647
  */
655
- static detectComments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string): Promise<CommentMatch[]>;
648
+ static detectComments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string, onChunk?: (completedChunks: number, totalChunks: number) => void): Promise<CommentMatch[]>;
656
649
  /**
657
650
  * Detect highlights in content.
658
651
  *
@@ -660,7 +653,7 @@ declare class AnnotationDetection {
660
653
  * applies, used in the prompt so the LLM analyzes non-English source
661
654
  * correctly.
662
655
  */
663
- static detectHighlights(content: string, client: InferenceClient, instructions?: string, density?: number, sourceLanguage?: string): Promise<HighlightMatch[]>;
656
+ static detectHighlights(content: string, client: InferenceClient, instructions?: string, density?: number, sourceLanguage?: string, onChunk?: (completedChunks: number, totalChunks: number) => void): Promise<HighlightMatch[]>;
664
657
  /**
665
658
  * Detect assessments in content.
666
659
  *
@@ -668,7 +661,7 @@ declare class AnnotationDetection {
668
661
  * (annotation body locale). `sourceLanguage` is the locale of the content
669
662
  * being analyzed (source-resource locale).
670
663
  */
671
- static detectAssessments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string): Promise<AssessmentMatch[]>;
664
+ static detectAssessments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string, onChunk?: (completedChunks: number, totalChunks: number) => void): Promise<AssessmentMatch[]>;
672
665
  /**
673
666
  * Detect tags in content for a specific category.
674
667
  *
@@ -681,7 +674,7 @@ declare class AnnotationDetection {
681
674
  * identifiers, not LLM-generated text — so it's consumed at the body-stamp
682
675
  * site, not here.
683
676
  */
684
- static detectTags(content: string, client: InferenceClient, schema: TagSchema, category: string, sourceLanguage?: string): Promise<TagMatch[]>;
677
+ static detectTags(content: string, client: InferenceClient, schema: TagSchema, category: string, sourceLanguage?: string, onChunk?: (completedChunks: number, totalChunks: number) => void): Promise<TagMatch[]>;
685
678
  }
686
679
 
687
680
  /**
@@ -701,7 +694,10 @@ declare class AnnotationDetection {
701
694
  * generate German content from an English source resource. See
702
695
  * `types.ts` "Locale conventions" for the full discussion.
703
696
  */
704
- declare function generateResourceFromTopic(topic: string, entityTypes: string[], client: InferenceClient, logger: Logger, userPrompt?: string, locale?: string, context?: GatheredContext, temperature?: number, maxTokens?: number, sourceLanguage?: string, outputMediaType?: SupportedMediaType, task?: string, structure?: string, cite?: boolean): Promise<{
697
+ declare function generateResourceFromTopic(topic: string, entityTypes: string[], client: InferenceClient, logger: Logger, userPrompt?: string, locale?: string, context?: GatheredContext, temperature?: number, maxTokens?: number, sourceLanguage?: string, outputMediaType?: SupportedMediaType, task?: string, structure?: string, cite?: boolean, repair?: {
698
+ source: string;
699
+ error: string;
700
+ }): Promise<{
705
701
  title: string;
706
702
  content: string;
707
703
  }>;