@semiont/make-meaning 0.2.30-build.61 → 0.2.30-build.63

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,9 +1,285 @@
1
- import { components, AnnotationUri } from '@semiont/api-client';
2
- import { ResourceId, EnvironmentConfig, ResourceAnnotations, AnnotationId, AnnotationCategory, GraphPath, GraphConnection } from '@semiont/core';
3
- import { CommentMatch, HighlightMatch, AssessmentMatch, TagMatch } from '@semiont/inference';
4
- export { AssessmentMatch, CommentMatch, HighlightMatch, TagMatch } from '@semiont/inference';
5
- import { JobWorker, JobQueue, Job } from '@semiont/jobs';
1
+ import { JobWorker, JobQueue, AnyJob } from '@semiont/jobs';
6
2
  import { EventStore } from '@semiont/event-sourcing';
3
+ import { RepresentationStore } from '@semiont/content';
4
+ import { EnvironmentConfig, ResourceId, StoredEvent, ResourceAnnotations, AnnotationId, AnnotationCategory, GraphPath, GraphConnection } from '@semiont/core';
5
+ import { InferenceClient } from '@semiont/inference';
6
+ import { GraphDatabase } from '@semiont/graph';
7
+ import { components, AnnotationUri, GenerationContext } from '@semiont/api-client';
8
+
9
+ /**
10
+ * Reference Detection Worker
11
+ *
12
+ * Processes detection jobs: runs AI inference to find entities in resources
13
+ * and emits reference.created events for each detected entity.
14
+ *
15
+ * This worker is INDEPENDENT of HTTP clients - it just processes jobs and emits events.
16
+ */
17
+
18
+ type ResourceDescriptor$2 = components['schemas']['ResourceDescriptor'];
19
+ interface DetectedAnnotation {
20
+ annotation: {
21
+ selector: {
22
+ start: number;
23
+ end: number;
24
+ exact: string;
25
+ prefix?: string;
26
+ suffix?: string;
27
+ };
28
+ entityTypes: string[];
29
+ };
30
+ }
31
+ declare class ReferenceDetectionWorker extends JobWorker {
32
+ private config;
33
+ private eventStore;
34
+ private inferenceClient;
35
+ constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
36
+ protected getWorkerName(): string;
37
+ protected canProcessJob(job: AnyJob): boolean;
38
+ protected executeJob(job: AnyJob): Promise<void>;
39
+ /**
40
+ * Detect entity references in resource using AI
41
+ * Self-contained implementation for reference detection
42
+ *
43
+ * Public for testing charset handling - see entity-detection-charset.test.ts
44
+ */
45
+ detectReferences(resource: ResourceDescriptor$2, entityTypes: string[], includeDescriptiveReferences?: boolean): Promise<DetectedAnnotation[]>;
46
+ private processDetectionJob;
47
+ protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
48
+ /**
49
+ * Update job progress and emit events to Event Store
50
+ * Overrides base class to also emit job progress events
51
+ */
52
+ protected updateJobProgress(job: AnyJob): Promise<void>;
53
+ }
54
+
55
+ /**
56
+ * Generation Worker
57
+ *
58
+ * Processes generation jobs: runs AI inference to generate new resources
59
+ * and emits resource.created and annotation.body.updated events.
60
+ *
61
+ * This worker is INDEPENDENT of HTTP clients - it just processes jobs and emits events.
62
+ */
63
+
64
+ declare class GenerationWorker extends JobWorker {
65
+ private config;
66
+ private eventStore;
67
+ private inferenceClient;
68
+ constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
69
+ protected getWorkerName(): string;
70
+ protected canProcessJob(job: AnyJob): boolean;
71
+ protected executeJob(job: AnyJob): Promise<void>;
72
+ private processGenerationJob;
73
+ /**
74
+ * Update job progress and emit events to Event Store
75
+ * Overrides base class to also emit job progress events
76
+ */
77
+ protected updateJobProgress(job: AnyJob): Promise<void>;
78
+ }
79
+
80
+ /**
81
+ * Highlight Detection Worker
82
+ *
83
+ * Processes highlight-detection jobs: runs AI inference to find passages
84
+ * that should be highlighted and creates highlight annotations.
85
+ */
86
+
87
+ declare class HighlightDetectionWorker extends JobWorker {
88
+ private config;
89
+ private eventStore;
90
+ private inferenceClient;
91
+ private isFirstProgress;
92
+ constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
93
+ protected getWorkerName(): string;
94
+ protected canProcessJob(job: AnyJob): boolean;
95
+ protected executeJob(job: AnyJob): Promise<void>;
96
+ /**
97
+ * Override updateJobProgress to emit events to Event Store
98
+ */
99
+ protected updateJobProgress(job: AnyJob): Promise<void>;
100
+ protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
101
+ private processHighlightDetectionJob;
102
+ private createHighlightAnnotation;
103
+ }
104
+
105
+ /**
106
+ * Assessment Detection Worker
107
+ *
108
+ * Processes assessment-detection jobs: runs AI inference to assess/evaluate
109
+ * passages in the text and creates assessment annotations.
110
+ */
111
+
112
+ declare class AssessmentDetectionWorker extends JobWorker {
113
+ private config;
114
+ private eventStore;
115
+ private inferenceClient;
116
+ private isFirstProgress;
117
+ constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
118
+ protected getWorkerName(): string;
119
+ protected canProcessJob(job: AnyJob): boolean;
120
+ protected executeJob(job: AnyJob): Promise<void>;
121
+ /**
122
+ * Override updateJobProgress to emit events to Event Store
123
+ */
124
+ protected updateJobProgress(job: AnyJob): Promise<void>;
125
+ protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
126
+ private processAssessmentDetectionJob;
127
+ private createAssessmentAnnotation;
128
+ }
129
+
130
+ /**
131
+ * Comment Detection Worker
132
+ *
133
+ * Processes comment-detection jobs: runs AI inference to identify passages
134
+ * that would benefit from explanatory comments and creates comment annotations.
135
+ */
136
+
137
+ declare class CommentDetectionWorker extends JobWorker {
138
+ private config;
139
+ private eventStore;
140
+ private inferenceClient;
141
+ private isFirstProgress;
142
+ constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
143
+ protected getWorkerName(): string;
144
+ protected canProcessJob(job: AnyJob): boolean;
145
+ protected executeJob(job: AnyJob): Promise<void>;
146
+ /**
147
+ * Override updateJobProgress to emit events to Event Store
148
+ */
149
+ protected updateJobProgress(job: AnyJob): Promise<void>;
150
+ protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
151
+ private processCommentDetectionJob;
152
+ private createCommentAnnotation;
153
+ }
154
+
155
+ /**
156
+ * Tag Detection Worker
157
+ *
158
+ * Processes tag-detection jobs: runs AI inference to identify passages
159
+ * serving specific structural roles (IRAC, IMRAD, Toulmin, etc.) and
160
+ * creates tag annotations with dual-body structure.
161
+ */
162
+
163
+ declare class TagDetectionWorker extends JobWorker {
164
+ private config;
165
+ private eventStore;
166
+ private inferenceClient;
167
+ private isFirstProgress;
168
+ constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient);
169
+ protected getWorkerName(): string;
170
+ protected canProcessJob(job: AnyJob): boolean;
171
+ protected executeJob(job: AnyJob): Promise<void>;
172
+ /**
173
+ * Override updateJobProgress to emit events to Event Store
174
+ */
175
+ protected updateJobProgress(job: AnyJob): Promise<void>;
176
+ protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
177
+ private processTagDetectionJob;
178
+ private createTagAnnotation;
179
+ }
180
+
181
+ /**
182
+ * GraphDB Consumer
183
+ * Subscribes to resource events and updates GraphDB accordingly
184
+ *
185
+ * Makes GraphDB a projection of Event Store events (single source of truth)
186
+ */
187
+
188
+ declare class GraphDBConsumer {
189
+ private config;
190
+ private eventStore;
191
+ private graphDb;
192
+ private subscriptions;
193
+ private _globalSubscription;
194
+ private processing;
195
+ private lastProcessed;
196
+ constructor(config: EnvironmentConfig, eventStore: EventStore, graphDb: GraphDatabase);
197
+ initialize(): Promise<void>;
198
+ /**
199
+ * Subscribe to global system-level events (no resourceId)
200
+ * This allows the consumer to react to events like entitytype.added
201
+ */
202
+ private subscribeToGlobalEvents;
203
+ private ensureInitialized;
204
+ /**
205
+ * Subscribe to events for a resource
206
+ * Apply each event to GraphDB
207
+ */
208
+ subscribeToResource(resourceId: ResourceId): Promise<void>;
209
+ /**
210
+ * Stop the consumer and unsubscribe from all events
211
+ */
212
+ stop(): Promise<void>;
213
+ /**
214
+ * Process event with ordering guarantee (sequential per resource)
215
+ */
216
+ protected processEvent(storedEvent: StoredEvent): Promise<void>;
217
+ /**
218
+ * Apply event to GraphDB
219
+ */
220
+ protected applyEventToGraph(storedEvent: StoredEvent): Promise<void>;
221
+ /**
222
+ * Rebuild entire resource from events
223
+ * Useful for recovery or initial sync
224
+ */
225
+ rebuildResource(resourceId: ResourceId): Promise<void>;
226
+ /**
227
+ * Rebuild entire GraphDB from all events
228
+ * Uses two-pass approach to ensure all resources exist before creating REFERENCES edges
229
+ */
230
+ rebuildAll(): Promise<void>;
231
+ /**
232
+ * Get consumer health metrics
233
+ */
234
+ getHealthMetrics(): {
235
+ subscriptions: number;
236
+ lastProcessed: Record<string, number>;
237
+ processing: string[];
238
+ };
239
+ /**
240
+ * Unsubscribe from resource
241
+ */
242
+ unsubscribeFromResource(resourceId: ResourceId): Promise<void>;
243
+ /**
244
+ * Unsubscribe from all resources
245
+ */
246
+ unsubscribeAll(): Promise<void>;
247
+ /**
248
+ * Shutdown consumer
249
+ */
250
+ shutdown(): Promise<void>;
251
+ }
252
+
253
+ /**
254
+ * Make-Meaning Service
255
+ *
256
+ * Consolidates all meaning-making infrastructure:
257
+ * - Job queue initialization
258
+ * - Worker instantiation and startup
259
+ * - Graph consumer (event-to-graph synchronization)
260
+ *
261
+ * Provides a clean interface similar to createEventStore():
262
+ * const makeMeaning = await startMakeMeaning(config);
263
+ */
264
+
265
+ interface MakeMeaningService {
266
+ jobQueue: JobQueue;
267
+ eventStore: EventStore;
268
+ repStore: RepresentationStore;
269
+ inferenceClient: InferenceClient;
270
+ graphDb: GraphDatabase;
271
+ workers: {
272
+ detection: ReferenceDetectionWorker;
273
+ generation: GenerationWorker;
274
+ highlight: HighlightDetectionWorker;
275
+ assessment: AssessmentDetectionWorker;
276
+ comment: CommentDetectionWorker;
277
+ tag: TagDetectionWorker;
278
+ };
279
+ graphConsumer: GraphDBConsumer;
280
+ stop: () => Promise<void>;
281
+ }
282
+ declare function startMakeMeaning(config: EnvironmentConfig): Promise<MakeMeaningService>;
7
283
 
8
284
  /**
9
285
  * Resource Context
@@ -12,7 +288,7 @@ import { EventStore } from '@semiont/event-sourcing';
12
288
  * Does NOT touch the graph - graph queries go through GraphContext
13
289
  */
14
290
 
15
- type ResourceDescriptor$2 = components['schemas']['ResourceDescriptor'];
291
+ type ResourceDescriptor$1 = components['schemas']['ResourceDescriptor'];
16
292
  interface ListResourcesFilters {
17
293
  search?: string;
18
294
  archived?: boolean;
@@ -21,16 +297,16 @@ declare class ResourceContext {
21
297
  /**
22
298
  * Get resource metadata from view storage
23
299
  */
24
- static getResourceMetadata(resourceId: ResourceId, config: EnvironmentConfig): Promise<ResourceDescriptor$2 | null>;
300
+ static getResourceMetadata(resourceId: ResourceId, config: EnvironmentConfig): Promise<ResourceDescriptor$1 | null>;
25
301
  /**
26
302
  * List all resources by scanning view storage
27
303
  */
28
- static listResources(filters: ListResourcesFilters | undefined, config: EnvironmentConfig): Promise<ResourceDescriptor$2[]>;
304
+ static listResources(filters: ListResourcesFilters | undefined, config: EnvironmentConfig): Promise<ResourceDescriptor$1[]>;
29
305
  /**
30
306
  * Add content previews to resources (for search results)
31
307
  * Retrieves and decodes the first 200 characters of each resource's primary representation
32
308
  */
33
- static addContentPreviews(resources: ResourceDescriptor$2[], config: EnvironmentConfig): Promise<Array<ResourceDescriptor$2 & {
309
+ static addContentPreviews(resources: ResourceDescriptor$1[], config: EnvironmentConfig): Promise<Array<ResourceDescriptor$1 & {
34
310
  content: string;
35
311
  }>>;
36
312
  }
@@ -128,6 +404,7 @@ declare class AnnotationContext {
128
404
  private static extractAnnotationContext;
129
405
  /**
130
406
  * Generate LLM summary of annotation in context
407
+ * Creates inference client per-request (HTTP handler context)
131
408
  */
132
409
  private static generateSummary;
133
410
  }
@@ -140,7 +417,7 @@ declare class AnnotationContext {
140
417
  */
141
418
 
142
419
  type Annotation = components['schemas']['Annotation'];
143
- type ResourceDescriptor$1 = components['schemas']['ResourceDescriptor'];
420
+ type ResourceDescriptor = components['schemas']['ResourceDescriptor'];
144
421
  declare class GraphContext {
145
422
  /**
146
423
  * Get all resources referencing this resource (backlinks)
@@ -161,7 +438,102 @@ declare class GraphContext {
161
438
  * Search resources by name (cross-resource query)
162
439
  * Requires full-text search - must use graph database
163
440
  */
164
- static searchResources(query: string, config: EnvironmentConfig, limit?: number): Promise<ResourceDescriptor$1[]>;
441
+ static searchResources(query: string, config: EnvironmentConfig, limit?: number): Promise<ResourceDescriptor[]>;
442
+ }
443
+
444
+ /**
445
+ * Response parsers for annotation detection motivations
446
+ *
447
+ * Provides static methods to parse and validate AI responses for each motivation type.
448
+ * Includes offset validation and correction logic.
449
+ * Extracted from worker implementations to centralize parsing logic.
450
+ */
451
+ /**
452
+ * Represents a detected comment with validated position
453
+ */
454
+ interface CommentMatch {
455
+ exact: string;
456
+ start: number;
457
+ end: number;
458
+ prefix?: string;
459
+ suffix?: string;
460
+ comment: string;
461
+ }
462
+ /**
463
+ * Represents a detected highlight with validated position
464
+ */
465
+ interface HighlightMatch {
466
+ exact: string;
467
+ start: number;
468
+ end: number;
469
+ prefix?: string;
470
+ suffix?: string;
471
+ }
472
+ /**
473
+ * Represents a detected assessment with validated position
474
+ */
475
+ interface AssessmentMatch {
476
+ exact: string;
477
+ start: number;
478
+ end: number;
479
+ prefix?: string;
480
+ suffix?: string;
481
+ assessment: string;
482
+ }
483
+ /**
484
+ * Represents a detected tag with validated position
485
+ */
486
+ interface TagMatch {
487
+ exact: string;
488
+ start: number;
489
+ end: number;
490
+ prefix?: string;
491
+ suffix?: string;
492
+ category: string;
493
+ }
494
+ declare class MotivationParsers {
495
+ /**
496
+ * Parse and validate AI response for comment detection
497
+ *
498
+ * @param response - Raw AI response string (may include markdown code fences)
499
+ * @param content - Original content to validate offsets against
500
+ * @returns Array of validated comment matches
501
+ */
502
+ static parseComments(response: string, content: string): CommentMatch[];
503
+ /**
504
+ * Parse and validate AI response for highlight detection
505
+ *
506
+ * @param response - Raw AI response string (may include markdown code fences)
507
+ * @param content - Original content to validate offsets against
508
+ * @returns Array of validated highlight matches
509
+ */
510
+ static parseHighlights(response: string, content: string): HighlightMatch[];
511
+ /**
512
+ * Parse and validate AI response for assessment detection
513
+ *
514
+ * @param response - Raw AI response string (may include markdown code fences)
515
+ * @param content - Original content to validate offsets against
516
+ * @returns Array of validated assessment matches
517
+ */
518
+ static parseAssessments(response: string, content: string): AssessmentMatch[];
519
+ /**
520
+ * Parse and validate AI response for tag detection
521
+ * Note: Does NOT validate offsets - caller must do that with content
522
+ *
523
+ * @param response - Raw AI response string (may include markdown code fences)
524
+ * @returns Array of tag matches (offsets not yet validated)
525
+ */
526
+ static parseTags(response: string): Omit<TagMatch, 'category'>[];
527
+ /**
528
+ * Validate tag offsets against content and add category
529
+ * Helper for tag detection after initial parsing
530
+ *
531
+ * @param tags - Parsed tags without validated offsets
532
+ * @param content - Original content to validate against
533
+ * @param category - Category to assign to validated tags
534
+ * @returns Array of validated tag matches
535
+ */
536
+ static validateTagOffsets(tags: Omit<TagMatch, 'category'>[], content: string, category: string): TagMatch[];
165
537
  }
166
538
 
167
539
  /**
@@ -184,43 +556,47 @@ declare class AnnotationDetection {
184
556
  *
185
557
  * @param resourceId - The resource to analyze
186
558
  * @param config - Environment configuration
559
+ * @param client - Inference client for AI operations
187
560
  * @param instructions - Optional user instructions for comment generation
188
561
  * @param tone - Optional tone guidance (e.g., "academic", "conversational")
189
562
  * @param density - Optional target number of comments per 2000 words
190
563
  * @returns Array of validated comment matches
191
564
  */
192
- static detectComments(resourceId: ResourceId, config: EnvironmentConfig, instructions?: string, tone?: string, density?: number): Promise<CommentMatch[]>;
565
+ static detectComments(resourceId: ResourceId, config: EnvironmentConfig, client: InferenceClient, instructions?: string, tone?: string, density?: number): Promise<CommentMatch[]>;
193
566
  /**
194
567
  * Detect highlights in a resource
195
568
  *
196
569
  * @param resourceId - The resource to analyze
197
570
  * @param config - Environment configuration
571
+ * @param client - Inference client for AI operations
198
572
  * @param instructions - Optional user instructions for highlight selection
199
573
  * @param density - Optional target number of highlights per 2000 words
200
574
  * @returns Array of validated highlight matches
201
575
  */
202
- static detectHighlights(resourceId: ResourceId, config: EnvironmentConfig, instructions?: string, density?: number): Promise<HighlightMatch[]>;
576
+ static detectHighlights(resourceId: ResourceId, config: EnvironmentConfig, client: InferenceClient, instructions?: string, density?: number): Promise<HighlightMatch[]>;
203
577
  /**
204
578
  * Detect assessments in a resource
205
579
  *
206
580
  * @param resourceId - The resource to analyze
207
581
  * @param config - Environment configuration
582
+ * @param client - Inference client for AI operations
208
583
  * @param instructions - Optional user instructions for assessment generation
209
584
  * @param tone - Optional tone guidance (e.g., "critical", "supportive")
210
585
  * @param density - Optional target number of assessments per 2000 words
211
586
  * @returns Array of validated assessment matches
212
587
  */
213
- static detectAssessments(resourceId: ResourceId, config: EnvironmentConfig, instructions?: string, tone?: string, density?: number): Promise<AssessmentMatch[]>;
588
+ static detectAssessments(resourceId: ResourceId, config: EnvironmentConfig, client: InferenceClient, instructions?: string, tone?: string, density?: number): Promise<AssessmentMatch[]>;
214
589
  /**
215
590
  * Detect tags in a resource for a specific category
216
591
  *
217
592
  * @param resourceId - The resource to analyze
218
593
  * @param config - Environment configuration
594
+ * @param client - Inference client for AI operations
219
595
  * @param schemaId - The tag schema identifier (e.g., "irac", "imrad")
220
596
  * @param category - The specific category to detect
221
597
  * @returns Array of validated tag matches
222
598
  */
223
- static detectTags(resourceId: ResourceId, config: EnvironmentConfig, schemaId: string, category: string): Promise<TagMatch[]>;
599
+ static detectTags(resourceId: ResourceId, config: EnvironmentConfig, client: InferenceClient, schemaId: string, category: string): Promise<TagMatch[]>;
224
600
  /**
225
601
  * Load resource content from representation store
226
602
  * Helper method used by all detection methods
@@ -233,172 +609,108 @@ declare class AnnotationDetection {
233
609
  }
234
610
 
235
611
  /**
236
- * Comment Detection Worker
612
+ * Prompt builders for annotation detection motivations
237
613
  *
238
- * Processes comment-detection jobs: runs AI inference to identify passages
239
- * that would benefit from explanatory comments and creates comment annotations.
614
+ * Provides static methods to build AI prompts for each Web Annotation motivation type.
615
+ * Extracted from worker implementations to centralize prompt logic.
240
616
  */
241
-
242
- declare class CommentDetectionWorker extends JobWorker {
243
- private config;
244
- private eventStore;
245
- private isFirstProgress;
246
- constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore);
247
- protected getWorkerName(): string;
248
- protected canProcessJob(job: Job): boolean;
249
- protected executeJob(job: Job): Promise<void>;
617
+ declare class MotivationPrompts {
250
618
  /**
251
- * Override updateJobProgress to emit events to Event Store
619
+ * Build a prompt for detecting comment-worthy passages
620
+ *
621
+ * @param content - The text content to analyze (will be truncated to 8000 chars)
622
+ * @param instructions - Optional user-provided instructions
623
+ * @param tone - Optional tone guidance (e.g., "academic", "conversational")
624
+ * @param density - Optional target number of comments per 2000 words
625
+ * @returns Formatted prompt string
252
626
  */
253
- protected updateJobProgress(job: Job): Promise<void>;
254
- protected handleJobFailure(job: Job, error: any): Promise<void>;
255
- private processCommentDetectionJob;
256
- private createCommentAnnotation;
257
- }
258
-
259
- /**
260
- * Highlight Detection Worker
261
- *
262
- * Processes highlight-detection jobs: runs AI inference to find passages
263
- * that should be highlighted and creates highlight annotations.
264
- */
265
-
266
- declare class HighlightDetectionWorker extends JobWorker {
267
- private config;
268
- private eventStore;
269
- private isFirstProgress;
270
- constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore);
271
- protected getWorkerName(): string;
272
- protected canProcessJob(job: Job): boolean;
273
- protected executeJob(job: Job): Promise<void>;
627
+ static buildCommentPrompt(content: string, instructions?: string, tone?: string, density?: number): string;
274
628
  /**
275
- * Override updateJobProgress to emit events to Event Store
629
+ * Build a prompt for detecting highlight-worthy passages
630
+ *
631
+ * @param content - The text content to analyze (will be truncated to 8000 chars)
632
+ * @param instructions - Optional user-provided instructions
633
+ * @param density - Optional target number of highlights per 2000 words
634
+ * @returns Formatted prompt string
276
635
  */
277
- protected updateJobProgress(job: Job): Promise<void>;
278
- protected handleJobFailure(job: Job, error: any): Promise<void>;
279
- private processHighlightDetectionJob;
280
- private createHighlightAnnotation;
281
- }
282
-
283
- /**
284
- * Assessment Detection Worker
285
- *
286
- * Processes assessment-detection jobs: runs AI inference to assess/evaluate
287
- * passages in the text and creates assessment annotations.
288
- */
289
-
290
- declare class AssessmentDetectionWorker extends JobWorker {
291
- private config;
292
- private eventStore;
293
- private isFirstProgress;
294
- constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore);
295
- protected getWorkerName(): string;
296
- protected canProcessJob(job: Job): boolean;
297
- protected executeJob(job: Job): Promise<void>;
636
+ static buildHighlightPrompt(content: string, instructions?: string, density?: number): string;
298
637
  /**
299
- * Override updateJobProgress to emit events to Event Store
638
+ * Build a prompt for detecting assessment-worthy passages
639
+ *
640
+ * @param content - The text content to analyze (will be truncated to 8000 chars)
641
+ * @param instructions - Optional user-provided instructions
642
+ * @param tone - Optional tone guidance (e.g., "critical", "supportive")
643
+ * @param density - Optional target number of assessments per 2000 words
644
+ * @returns Formatted prompt string
300
645
  */
301
- protected updateJobProgress(job: Job): Promise<void>;
302
- protected handleJobFailure(job: Job, error: any): Promise<void>;
303
- private processAssessmentDetectionJob;
304
- private createAssessmentAnnotation;
646
+ static buildAssessmentPrompt(content: string, instructions?: string, tone?: string, density?: number): string;
647
+ /**
648
+ * Build a prompt for detecting structural tags
649
+ *
650
+ * @param content - The full text content to analyze (NOT truncated for structural analysis)
651
+ * @param category - The specific category to detect
652
+ * @param schemaName - Human-readable schema name
653
+ * @param schemaDescription - Schema description
654
+ * @param schemaDomain - Schema domain
655
+ * @param categoryDescription - Category description
656
+ * @param categoryExamples - Example questions/guidance for this category
657
+ * @returns Formatted prompt string
658
+ */
659
+ static buildTagPrompt(content: string, category: string, schemaName: string, schemaDescription: string, schemaDomain: string, categoryDescription: string, categoryExamples: string[]): string;
305
660
  }
306
661
 
307
662
  /**
308
- * Tag Detection Worker
309
- *
310
- * Processes tag-detection jobs: runs AI inference to identify passages
311
- * serving specific structural roles (IRAC, IMRAD, Toulmin, etc.) and
312
- * creates tag annotations with dual-body structure.
663
+ * Entity reference extracted from text
313
664
  */
314
-
315
- declare class TagDetectionWorker extends JobWorker {
316
- private config;
317
- private eventStore;
318
- private isFirstProgress;
319
- constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore);
320
- protected getWorkerName(): string;
321
- protected canProcessJob(job: Job): boolean;
322
- protected executeJob(job: Job): Promise<void>;
323
- /**
324
- * Override updateJobProgress to emit events to Event Store
325
- */
326
- protected updateJobProgress(job: Job): Promise<void>;
327
- protected handleJobFailure(job: Job, error: any): Promise<void>;
328
- private processTagDetectionJob;
329
- private createTagAnnotation;
665
+ interface ExtractedEntity {
666
+ exact: string;
667
+ entityType: string;
668
+ startOffset: number;
669
+ endOffset: number;
670
+ prefix?: string;
671
+ suffix?: string;
330
672
  }
331
-
332
673
  /**
333
- * Reference Detection Worker
674
+ * Extract entity references from text using AI
334
675
  *
335
- * Processes detection jobs: runs AI inference to find entities in resources
336
- * and emits reference.created events for each detected entity.
337
- *
338
- * This worker is INDEPENDENT of HTTP clients - it just processes jobs and emits events.
676
+ * @param text - The text to analyze
677
+ * @param entityTypes - Array of entity types to detect (optionally with examples)
678
+ * @param client - Inference client for AI operations
679
+ * @param includeDescriptiveReferences - Include anaphoric/cataphoric references (default: false)
680
+ * @returns Array of extracted entities with their character offsets
339
681
  */
340
-
341
- type ResourceDescriptor = components['schemas']['ResourceDescriptor'];
342
- interface DetectedAnnotation {
343
- annotation: {
344
- selector: {
345
- start: number;
346
- end: number;
347
- exact: string;
348
- prefix?: string;
349
- suffix?: string;
350
- };
351
- entityTypes: string[];
352
- };
353
- }
354
- declare class ReferenceDetectionWorker extends JobWorker {
355
- private config;
356
- private eventStore;
357
- constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore);
358
- protected getWorkerName(): string;
359
- protected canProcessJob(job: Job): boolean;
360
- protected executeJob(job: Job): Promise<void>;
361
- /**
362
- * Detect entity references in resource using AI
363
- * Self-contained implementation for reference detection
364
- *
365
- * Public for testing charset handling - see entity-detection-charset.test.ts
366
- */
367
- detectReferences(resource: ResourceDescriptor, entityTypes: string[], includeDescriptiveReferences?: boolean): Promise<DetectedAnnotation[]>;
368
- private processDetectionJob;
369
- protected handleJobFailure(job: Job, error: any): Promise<void>;
370
- /**
371
- * Update job progress and emit events to Event Store
372
- * Overrides base class to also emit job progress events
373
- */
374
- protected updateJobProgress(job: Job): Promise<void>;
375
- }
682
+ declare function extractEntities(exact: string, entityTypes: string[] | {
683
+ type: string;
684
+ examples?: string[];
685
+ }[], client: InferenceClient, includeDescriptiveReferences?: boolean): Promise<ExtractedEntity[]>;
376
686
 
377
687
  /**
378
- * Generation Worker
379
- *
380
- * Processes generation jobs: runs AI inference to generate new resources
381
- * and emits resource.created and annotation.body.updated events.
688
+ * Resource Generation Functions
382
689
  *
383
- * This worker is INDEPENDENT of HTTP clients - it just processes jobs and emits events.
690
+ * Application-specific resource generation logic including:
691
+ * - Markdown resource generation from topics
692
+ * - Resource summary generation
693
+ * - Reference suggestion generation
694
+ * - Language handling and template processing
384
695
  */
385
696
 
386
- declare class GenerationWorker extends JobWorker {
387
- private config;
388
- private eventStore;
389
- constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore);
390
- protected getWorkerName(): string;
391
- protected canProcessJob(job: Job): boolean;
392
- protected executeJob(job: Job): Promise<void>;
393
- private processGenerationJob;
394
- /**
395
- * Update job progress and emit events to Event Store
396
- * Overrides base class to also emit job progress events
397
- */
398
- protected updateJobProgress(job: Job): Promise<void>;
399
- }
697
+ /**
698
+ * Generate resource content using inference
699
+ */
700
+ declare function generateResourceFromTopic(topic: string, entityTypes: string[], client: InferenceClient, userPrompt?: string, locale?: string, context?: GenerationContext, temperature?: number, maxTokens?: number): Promise<{
701
+ title: string;
702
+ content: string;
703
+ }>;
704
+ /**
705
+ * Generate an intelligent summary for a resource
706
+ */
707
+ declare function generateResourceSummary(resourceName: string, content: string, entityTypes: string[], client: InferenceClient): Promise<string>;
708
+ /**
709
+ * Generate smart suggestions for a reference
710
+ */
711
+ declare function generateReferenceSuggestions(referenceTitle: string, client: InferenceClient, entityType?: string, currentContent?: string): Promise<string[] | null>;
400
712
 
401
713
  declare const PACKAGE_NAME = "@semiont/make-meaning";
402
714
  declare const VERSION = "0.1.0";
403
715
 
404
- export { AnnotationContext, AnnotationDetection, AssessmentDetectionWorker, type BuildContextOptions, CommentDetectionWorker, GenerationWorker, GraphContext, HighlightDetectionWorker, type ListResourcesFilters, PACKAGE_NAME, ReferenceDetectionWorker, ResourceContext, TagDetectionWorker, VERSION };
716
+ export { AnnotationContext, AnnotationDetection, AssessmentDetectionWorker, type AssessmentMatch, type BuildContextOptions, CommentDetectionWorker, type CommentMatch, type ExtractedEntity, GenerationWorker, GraphContext, GraphDBConsumer, HighlightDetectionWorker, type HighlightMatch, type ListResourcesFilters, type MakeMeaningService, MotivationParsers, MotivationPrompts, PACKAGE_NAME, ReferenceDetectionWorker, ResourceContext, TagDetectionWorker, type TagMatch, VERSION, extractEntities, generateReferenceSuggestions, generateResourceFromTopic, generateResourceSummary, startMakeMeaning };