@semiont/jobs 0.5.4 → 0.5.5
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 +644 -20
- package/dist/worker-main.d.ts +2 -22
- package/dist/worker-main.js +1197 -1197
- package/dist/worker-main.js.map +1 -1
- package/package.json +4 -2
- package/dist/fs-job-queue.d.ts +0 -79
- package/dist/fs-job-queue.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/job-claim-adapter.d.ts +0 -76
- package/dist/job-claim-adapter.d.ts.map +0 -1
- package/dist/job-queue-interface.d.ts +0 -19
- package/dist/job-queue-interface.d.ts.map +0 -1
- package/dist/job-queue-state-unit.d.ts +0 -26
- package/dist/job-queue-state-unit.d.ts.map +0 -1
- package/dist/job-worker.d.ts +0 -67
- package/dist/job-worker.d.ts.map +0 -1
- package/dist/processors.d.ts +0 -41
- package/dist/processors.d.ts.map +0 -1
- package/dist/types.d.ts +0 -319
- package/dist/types.d.ts.map +0 -1
- package/dist/worker-main.d.ts.map +0 -1
- package/dist/worker-process.d.ts +0 -47
- package/dist/worker-process.d.ts.map +0 -1
- package/dist/workers/annotation-detection.d.ts +0 -61
- package/dist/workers/annotation-detection.d.ts.map +0 -1
- package/dist/workers/detection/entity-extractor.d.ts +0 -42
- package/dist/workers/detection/entity-extractor.d.ts.map +0 -1
- package/dist/workers/detection/motivation-parsers.d.ts +0 -116
- package/dist/workers/detection/motivation-parsers.d.ts.map +0 -1
- package/dist/workers/detection/motivation-prompts.d.ts +0 -57
- package/dist/workers/detection/motivation-prompts.d.ts.map +0 -1
- package/dist/workers/generation/resource-generation.d.ts +0 -23
- package/dist/workers/generation/resource-generation.d.ts.map +0 -1
package/dist/types.d.ts
DELETED
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Job Queue Type Definitions - Discriminated Union Design
|
|
3
|
-
*
|
|
4
|
-
* Jobs represent async work that can be queued, processed, and monitored.
|
|
5
|
-
* Uses TypeScript discriminated unions to enforce valid state transitions.
|
|
6
|
-
*
|
|
7
|
-
* Design principles:
|
|
8
|
-
* - Each job status has specific valid fields
|
|
9
|
-
* - Type narrowing works automatically via status discriminant
|
|
10
|
-
* - No optional fields that may or may not exist
|
|
11
|
-
* - State machine is explicit and type-safe
|
|
12
|
-
*/
|
|
13
|
-
import type { Readable } from 'stream';
|
|
14
|
-
import type { Annotation, JobId, EntityType, ResourceId, UserId, AnnotationId, GatheredContext, TagSchema } from '@semiont/core';
|
|
15
|
-
/**
|
|
16
|
-
* Content fetcher - turns a ResourceId into a readable stream.
|
|
17
|
-
* Workers use this to access resource content on demand.
|
|
18
|
-
* The implementation is provided by the backend at startup.
|
|
19
|
-
*/
|
|
20
|
-
export type ContentFetcher = (resourceId: ResourceId) => Promise<Readable | null>;
|
|
21
|
-
export type JobType = 'reference-annotation' | 'generation' | 'highlight-annotation' | 'assessment-annotation' | 'comment-annotation' | 'tag-annotation';
|
|
22
|
-
export type JobStatus = 'pending' | 'running' | 'complete' | 'failed' | 'cancelled';
|
|
23
|
-
/**
|
|
24
|
-
* Job metadata - common to all states
|
|
25
|
-
*/
|
|
26
|
-
export interface JobMetadata {
|
|
27
|
-
id: JobId;
|
|
28
|
-
type: JobType;
|
|
29
|
-
userId: UserId;
|
|
30
|
-
userName: string;
|
|
31
|
-
userEmail: string;
|
|
32
|
-
userDomain: string;
|
|
33
|
-
created: string;
|
|
34
|
-
retryCount: number;
|
|
35
|
-
maxRetries: number;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Locale conventions for detection/generation params.
|
|
39
|
-
*
|
|
40
|
-
* Two independent locales flow through these jobs:
|
|
41
|
-
*
|
|
42
|
-
* - `language` — *annotation body* locale. The BCP-47 tag the LLM should
|
|
43
|
-
* write generated body text in (comment text, assessment text, generated
|
|
44
|
-
* resource content, tag category label). Sourced from the user's UI
|
|
45
|
-
* locale. Stamped onto the W3C `TextualBody.language` field.
|
|
46
|
-
*
|
|
47
|
-
* - `sourceLanguage` — *source resource* locale. The BCP-47 tag of the
|
|
48
|
-
* content being analyzed. Sourced from `ResourceDescriptor` (carried as
|
|
49
|
-
* `Representation.language` on the primary representation). Used in
|
|
50
|
-
* prompts so the LLM analyzes non-English source correctly even when
|
|
51
|
-
* the user's UI locale differs.
|
|
52
|
-
*
|
|
53
|
-
* Examples: a German user analyzing an English document → `language='de'`,
|
|
54
|
-
* `sourceLanguage='en'`. An English user detecting entities in a French
|
|
55
|
-
* document → `language='en'` (unused for entity references), `sourceLanguage='fr'`.
|
|
56
|
-
*/
|
|
57
|
-
/**
|
|
58
|
-
* Detection job parameters
|
|
59
|
-
*/
|
|
60
|
-
export interface DetectionParams {
|
|
61
|
-
resourceId: ResourceId;
|
|
62
|
-
entityTypes: EntityType[];
|
|
63
|
-
includeDescriptiveReferences?: boolean;
|
|
64
|
-
/** Annotation body locale — see locale conventions above. */
|
|
65
|
-
language?: string;
|
|
66
|
-
/** Source-resource locale — see locale conventions above. */
|
|
67
|
-
sourceLanguage?: string;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Generation job parameters
|
|
71
|
-
*/
|
|
72
|
-
export interface GenerationParams {
|
|
73
|
-
referenceId: AnnotationId;
|
|
74
|
-
sourceResourceId: ResourceId;
|
|
75
|
-
sourceResourceName: string;
|
|
76
|
-
annotation: Annotation;
|
|
77
|
-
prompt?: string;
|
|
78
|
-
title?: string;
|
|
79
|
-
entityTypes?: EntityType[];
|
|
80
|
-
/** Annotation body locale — language the *generated resource* is written in. */
|
|
81
|
-
language?: string;
|
|
82
|
-
/**
|
|
83
|
-
* Source-resource locale — language of the resource being referenced.
|
|
84
|
-
* Used in the prompt so the LLM understands the embedded source-context
|
|
85
|
-
* snippet correctly when source ≠ target language.
|
|
86
|
-
*/
|
|
87
|
-
sourceLanguage?: string;
|
|
88
|
-
context?: GatheredContext;
|
|
89
|
-
temperature?: number;
|
|
90
|
-
maxTokens?: number;
|
|
91
|
-
storageUri?: string;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Highlight detection job parameters
|
|
95
|
-
*/
|
|
96
|
-
export interface HighlightDetectionParams {
|
|
97
|
-
resourceId: ResourceId;
|
|
98
|
-
instructions?: string;
|
|
99
|
-
density?: number;
|
|
100
|
-
/** Source-resource locale — see locale conventions above. */
|
|
101
|
-
sourceLanguage?: string;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Assessment detection job parameters
|
|
105
|
-
*/
|
|
106
|
-
export interface AssessmentDetectionParams {
|
|
107
|
-
resourceId: ResourceId;
|
|
108
|
-
instructions?: string;
|
|
109
|
-
tone?: 'analytical' | 'critical' | 'balanced' | 'constructive';
|
|
110
|
-
density?: number;
|
|
111
|
-
/** Annotation body locale — see locale conventions above. */
|
|
112
|
-
language?: string;
|
|
113
|
-
/** Source-resource locale — see locale conventions above. */
|
|
114
|
-
sourceLanguage?: string;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Comment detection job parameters
|
|
118
|
-
*/
|
|
119
|
-
export interface CommentDetectionParams {
|
|
120
|
-
resourceId: ResourceId;
|
|
121
|
-
instructions?: string;
|
|
122
|
-
tone?: 'scholarly' | 'explanatory' | 'conversational' | 'technical';
|
|
123
|
-
density?: number;
|
|
124
|
-
/** Annotation body locale — see locale conventions above. */
|
|
125
|
-
language?: string;
|
|
126
|
-
/** Source-resource locale — see locale conventions above. */
|
|
127
|
-
sourceLanguage?: string;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Tag detection job parameters.
|
|
131
|
-
*
|
|
132
|
-
* Carries the *full* `TagSchema` (not just an id). The dispatcher resolves
|
|
133
|
-
* the caller-supplied `schemaId` against the per-KB tag-schema projection
|
|
134
|
-
* at job-creation time and embeds the resolved schema here, keeping the
|
|
135
|
-
* worker independent of the registry.
|
|
136
|
-
*/
|
|
137
|
-
export interface TagDetectionParams {
|
|
138
|
-
resourceId: ResourceId;
|
|
139
|
-
schema: TagSchema;
|
|
140
|
-
categories: string[];
|
|
141
|
-
/** Annotation body locale — see locale conventions above. */
|
|
142
|
-
language?: string;
|
|
143
|
-
/** Source-resource locale — see locale conventions above. */
|
|
144
|
-
sourceLanguage?: string;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Detection job progress
|
|
148
|
-
*/
|
|
149
|
-
export interface DetectionProgress {
|
|
150
|
-
totalEntityTypes: number;
|
|
151
|
-
processedEntityTypes: number;
|
|
152
|
-
currentEntityType?: string;
|
|
153
|
-
entitiesFound: number;
|
|
154
|
-
entitiesEmitted: number;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Detection job result
|
|
158
|
-
*/
|
|
159
|
-
export interface DetectionResult {
|
|
160
|
-
totalFound: number;
|
|
161
|
-
totalEmitted: number;
|
|
162
|
-
errors: number;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Generation job progress
|
|
166
|
-
*/
|
|
167
|
-
export interface YieldProgress {
|
|
168
|
-
stage: 'fetching' | 'generating' | 'creating' | 'linking';
|
|
169
|
-
percentage: number;
|
|
170
|
-
message?: string;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Generation job result
|
|
174
|
-
*/
|
|
175
|
-
export interface GenerationResult {
|
|
176
|
-
resourceId: ResourceId;
|
|
177
|
-
resourceName: string;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Highlight detection job progress
|
|
181
|
-
*/
|
|
182
|
-
export interface HighlightDetectionProgress {
|
|
183
|
-
stage: 'analyzing' | 'creating';
|
|
184
|
-
percentage: number;
|
|
185
|
-
message?: string;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Highlight detection job result
|
|
189
|
-
*/
|
|
190
|
-
export interface HighlightDetectionResult {
|
|
191
|
-
highlightsFound: number;
|
|
192
|
-
highlightsCreated: number;
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Assessment detection job progress
|
|
196
|
-
*/
|
|
197
|
-
export interface AssessmentDetectionProgress {
|
|
198
|
-
stage: 'analyzing' | 'creating';
|
|
199
|
-
percentage: number;
|
|
200
|
-
message?: string;
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Assessment detection job result
|
|
204
|
-
*/
|
|
205
|
-
export interface AssessmentDetectionResult {
|
|
206
|
-
assessmentsFound: number;
|
|
207
|
-
assessmentsCreated: number;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Comment detection job progress
|
|
211
|
-
*/
|
|
212
|
-
export interface CommentDetectionProgress {
|
|
213
|
-
stage: 'analyzing' | 'creating';
|
|
214
|
-
percentage: number;
|
|
215
|
-
message?: string;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Comment detection job result
|
|
219
|
-
*/
|
|
220
|
-
export interface CommentDetectionResult {
|
|
221
|
-
commentsFound: number;
|
|
222
|
-
commentsCreated: number;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Tag detection job progress
|
|
226
|
-
*/
|
|
227
|
-
export interface TagDetectionProgress {
|
|
228
|
-
stage: 'analyzing' | 'creating';
|
|
229
|
-
percentage: number;
|
|
230
|
-
currentCategory?: string;
|
|
231
|
-
processedCategories: number;
|
|
232
|
-
totalCategories: number;
|
|
233
|
-
message?: string;
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Tag detection job result
|
|
237
|
-
*/
|
|
238
|
-
export interface TagDetectionResult {
|
|
239
|
-
tagsFound: number;
|
|
240
|
-
tagsCreated: number;
|
|
241
|
-
byCategory: Record<string, number>;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Pending job - just created, waiting to be picked up
|
|
245
|
-
*/
|
|
246
|
-
export interface PendingJob<P> {
|
|
247
|
-
status: 'pending';
|
|
248
|
-
metadata: JobMetadata;
|
|
249
|
-
params: P;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Running job - actively being processed
|
|
253
|
-
*/
|
|
254
|
-
export interface RunningJob<P, PG> {
|
|
255
|
-
status: 'running';
|
|
256
|
-
metadata: JobMetadata;
|
|
257
|
-
params: P;
|
|
258
|
-
startedAt: string;
|
|
259
|
-
progress: PG;
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* Complete job - successfully finished
|
|
263
|
-
*/
|
|
264
|
-
export interface CompleteJob<P, R> {
|
|
265
|
-
status: 'complete';
|
|
266
|
-
metadata: JobMetadata;
|
|
267
|
-
params: P;
|
|
268
|
-
startedAt: string;
|
|
269
|
-
completedAt: string;
|
|
270
|
-
result: R;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Failed job - encountered an error
|
|
274
|
-
*/
|
|
275
|
-
export interface FailedJob<P> {
|
|
276
|
-
status: 'failed';
|
|
277
|
-
metadata: JobMetadata;
|
|
278
|
-
params: P;
|
|
279
|
-
startedAt?: string;
|
|
280
|
-
completedAt: string;
|
|
281
|
-
error: string;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Cancelled job - stopped by user
|
|
285
|
-
*/
|
|
286
|
-
export interface CancelledJob<P> {
|
|
287
|
-
status: 'cancelled';
|
|
288
|
-
metadata: JobMetadata;
|
|
289
|
-
params: P;
|
|
290
|
-
startedAt?: string;
|
|
291
|
-
completedAt: string;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Generic job - discriminated union of all states
|
|
295
|
-
*/
|
|
296
|
-
export type Job<P, PG, R> = PendingJob<P> | RunningJob<P, PG> | CompleteJob<P, R> | FailedJob<P> | CancelledJob<P>;
|
|
297
|
-
export type DetectionJob = Job<DetectionParams, DetectionProgress, DetectionResult>;
|
|
298
|
-
export type GenerationJob = Job<GenerationParams, YieldProgress, GenerationResult>;
|
|
299
|
-
export type HighlightDetectionJob = Job<HighlightDetectionParams, HighlightDetectionProgress, HighlightDetectionResult>;
|
|
300
|
-
export type AssessmentDetectionJob = Job<AssessmentDetectionParams, AssessmentDetectionProgress, AssessmentDetectionResult>;
|
|
301
|
-
export type CommentDetectionJob = Job<CommentDetectionParams, CommentDetectionProgress, CommentDetectionResult>;
|
|
302
|
-
export type TagDetectionJob = Job<TagDetectionParams, TagDetectionProgress, TagDetectionResult>;
|
|
303
|
-
/**
|
|
304
|
-
* Discriminated union of all job types
|
|
305
|
-
*/
|
|
306
|
-
export type AnyJob = DetectionJob | GenerationJob | HighlightDetectionJob | AssessmentDetectionJob | CommentDetectionJob | TagDetectionJob;
|
|
307
|
-
export declare function isPendingJob(job: AnyJob): job is PendingJob<any>;
|
|
308
|
-
export declare function isRunningJob(job: AnyJob): job is RunningJob<any, any>;
|
|
309
|
-
export declare function isCompleteJob(job: AnyJob): job is CompleteJob<any, any>;
|
|
310
|
-
export declare function isFailedJob(job: AnyJob): job is FailedJob<any>;
|
|
311
|
-
export declare function isCancelledJob(job: AnyJob): job is CancelledJob<any>;
|
|
312
|
-
export interface JobQueryFilters {
|
|
313
|
-
status?: JobStatus;
|
|
314
|
-
type?: JobType;
|
|
315
|
-
userId?: UserId;
|
|
316
|
-
limit?: number;
|
|
317
|
-
offset?: number;
|
|
318
|
-
}
|
|
319
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEjI;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,UAAU,KAAK,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;AAGlF,MAAM,MAAM,OAAO,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AqB,GAAG,sBAAsB,GAAG,mBAAmB,GAAG,eAAe,CAAC;AAM3I,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAEhE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAErE;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAEvE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAE9D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAEpE;AAMD,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker-main.d.ts","sourceRoot":"","sources":["../src/worker-main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}
|
package/dist/worker-process.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Worker Process Entry Point
|
|
3
|
-
*
|
|
4
|
-
* One worker process serves a single software-agent identity — one
|
|
5
|
-
* `(inferenceProvider, model)` pair. The session it owns is
|
|
6
|
-
* authenticated *as that agent* (`/api/tokens/agent`), so every event
|
|
7
|
-
* the worker emits attributes to the agent at the bus seat. Multiple
|
|
8
|
-
* agents on the same host run as multiple worker processes side by
|
|
9
|
-
* side; their job-claim subscriptions don't interfere because each
|
|
10
|
-
* agent only subscribes to the job types its inference engine is
|
|
11
|
-
* configured to serve.
|
|
12
|
-
*
|
|
13
|
-
* `createJobClaimAdapter` handles the reactive contract (SSE
|
|
14
|
-
* subscription, claim, completion tracking). This file wires the
|
|
15
|
-
* job processors to the adapter and drives lifecycle emissions.
|
|
16
|
-
*/
|
|
17
|
-
import { type JobClaimAdapter, type ActiveJob } from './job-claim-adapter';
|
|
18
|
-
import type { SemiontSession } from '@semiont/sdk';
|
|
19
|
-
import type { InferenceClient } from '@semiont/inference';
|
|
20
|
-
import type { Logger, components } from '@semiont/core';
|
|
21
|
-
type Agent = components['schemas']['Agent'];
|
|
22
|
-
export interface WorkerProcessConfig {
|
|
23
|
-
/**
|
|
24
|
-
* The session authenticated as this worker's software-agent identity.
|
|
25
|
-
* Bus emits through this session attribute to that agent.
|
|
26
|
-
*/
|
|
27
|
-
session: SemiontSession;
|
|
28
|
-
/**
|
|
29
|
-
* The job types this agent serves. Today every job type a worker
|
|
30
|
-
* subscribes to runs through the same inference engine — different
|
|
31
|
-
* inference engines mean different agents and therefore different
|
|
32
|
-
* worker processes.
|
|
33
|
-
*/
|
|
34
|
-
jobTypes: string[];
|
|
35
|
-
inferenceClient: InferenceClient;
|
|
36
|
-
/**
|
|
37
|
-
* The agent (Software) record stamped onto annotations as `generator`
|
|
38
|
-
* and onto resources as `wasAttributedTo`. Same identity that the
|
|
39
|
-
* session is authenticated as.
|
|
40
|
-
*/
|
|
41
|
-
generator: Agent;
|
|
42
|
-
logger: Logger;
|
|
43
|
-
}
|
|
44
|
-
export declare function startWorkerProcess(config: WorkerProcessConfig): JobClaimAdapter;
|
|
45
|
-
export declare function handleJob(adapter: JobClaimAdapter, config: WorkerProcessConfig, job: ActiveJob): Promise<void>;
|
|
46
|
-
export {};
|
|
47
|
-
//# sourceMappingURL=worker-process.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"worker-process.d.ts","sourceRoot":"","sources":["../src/worker-process.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAyB,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAClG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAaxD,KAAK,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC;AAE5C,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,EAAE,cAAc,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,EAAE,eAAe,CAAC;IACjC;;;;OAIG;IACH,SAAS,EAAE,KAAK,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAiBD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,mBAAmB,GAAG,eAAe,CAkC/E;AAKD,wBAAsB,SAAS,CAC7B,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,mBAAmB,EAC3B,GAAG,EAAE,SAAS,GACb,OAAO,CAAC,IAAI,CAAC,CAsBf"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Annotation Detection
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates the full annotation detection pipeline:
|
|
5
|
-
* 1. Build AI prompts using MotivationPrompts
|
|
6
|
-
* 2. Call AI inference
|
|
7
|
-
* 3. Parse and validate results using MotivationParsers
|
|
8
|
-
*
|
|
9
|
-
* All methods take content as a string parameter.
|
|
10
|
-
* Workers are responsible for fetching content via ContentFetcher.
|
|
11
|
-
*/
|
|
12
|
-
import type { InferenceClient } from '@semiont/inference';
|
|
13
|
-
import { type CommentMatch, type HighlightMatch, type AssessmentMatch, type TagMatch } from './detection/motivation-parsers';
|
|
14
|
-
import type { ResourceId, TagSchema } from '@semiont/core';
|
|
15
|
-
import type { ContentFetcher } from '../types';
|
|
16
|
-
export declare class AnnotationDetection {
|
|
17
|
-
/**
|
|
18
|
-
* Fetch content from a ContentFetcher and read the stream to a string.
|
|
19
|
-
* Shared helper for all workers.
|
|
20
|
-
*/
|
|
21
|
-
static fetchContent(contentFetcher: ContentFetcher, resourceId: ResourceId): Promise<string>;
|
|
22
|
-
/**
|
|
23
|
-
* Detect comments in content.
|
|
24
|
-
*
|
|
25
|
-
* `language` is the locale the LLM should write comment text in (annotation
|
|
26
|
-
* body locale). `sourceLanguage` is the locale of the content being analyzed
|
|
27
|
-
* (source-resource locale). See `types.ts` "Locale conventions" for the
|
|
28
|
-
* full discussion.
|
|
29
|
-
*/
|
|
30
|
-
static detectComments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string): Promise<CommentMatch[]>;
|
|
31
|
-
/**
|
|
32
|
-
* Detect highlights in content.
|
|
33
|
-
*
|
|
34
|
-
* Highlights have no body — only `sourceLanguage` (source-resource locale)
|
|
35
|
-
* applies, used in the prompt so the LLM analyzes non-English source
|
|
36
|
-
* correctly.
|
|
37
|
-
*/
|
|
38
|
-
static detectHighlights(content: string, client: InferenceClient, instructions?: string, density?: number, sourceLanguage?: string): Promise<HighlightMatch[]>;
|
|
39
|
-
/**
|
|
40
|
-
* Detect assessments in content.
|
|
41
|
-
*
|
|
42
|
-
* `language` is the locale the LLM should write assessment text in
|
|
43
|
-
* (annotation body locale). `sourceLanguage` is the locale of the content
|
|
44
|
-
* being analyzed (source-resource locale).
|
|
45
|
-
*/
|
|
46
|
-
static detectAssessments(content: string, client: InferenceClient, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string): Promise<AssessmentMatch[]>;
|
|
47
|
-
/**
|
|
48
|
-
* Detect tags in content for a specific category.
|
|
49
|
-
*
|
|
50
|
-
* The full `TagSchema` is supplied by the dispatcher (resolved against
|
|
51
|
-
* the per-KB tag-schema projection at job-creation time) so the worker
|
|
52
|
-
* is independent of the registry.
|
|
53
|
-
*
|
|
54
|
-
* `sourceLanguage` is the locale of the content being analyzed. Body-locale
|
|
55
|
-
* (`language`) doesn't influence the tag prompt — categories are schema
|
|
56
|
-
* identifiers, not LLM-generated text — so it's consumed at the body-stamp
|
|
57
|
-
* site, not here.
|
|
58
|
-
*/
|
|
59
|
-
static detectTags(content: string, client: InferenceClient, schema: TagSchema, category: string, sourceLanguage?: string): Promise<TagMatch[]>;
|
|
60
|
-
}
|
|
61
|
-
//# sourceMappingURL=annotation-detection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"annotation-detection.d.ts","sourceRoot":"","sources":["../../src/workers/annotation-detection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,qBAAa,mBAAmB;IAE9B;;;OAGG;WACU,YAAY,CAAC,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAYlG;;;;;;;OAOG;WACU,cAAc,CACzB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,eAAe,EACvB,YAAY,CAAC,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,YAAY,EAAE,CAAC;IAM1B;;;;;;OAMG;WACU,gBAAgB,CAC3B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,eAAe,EACvB,YAAY,CAAC,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,cAAc,EAAE,CAAC;IAM5B;;;;;;OAMG;WACU,iBAAiB,CAC5B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,eAAe,EACvB,YAAY,CAAC,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,EAAE,CAAC;IAM7B;;;;;;;;;;;OAWG;WACU,UAAU,CACrB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,QAAQ,EAAE,CAAC;CAqBvB"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { InferenceClient } from '@semiont/inference';
|
|
2
|
-
import { type Logger } from '@semiont/core';
|
|
3
|
-
/**
|
|
4
|
-
* Entity reference extracted from text.
|
|
5
|
-
*
|
|
6
|
-
* `start` / `end` follow the W3C Web Annotation Data Model
|
|
7
|
-
* `TextPositionSelector` shape. The LLM-prompt wire format separately
|
|
8
|
-
* uses `startOffset` / `endOffset` (more self-documenting in prose);
|
|
9
|
-
* the parse step in `extractEntities` translates between the two so
|
|
10
|
-
* the rest of the pipeline never touches the LLM-shaped names.
|
|
11
|
-
*/
|
|
12
|
-
export interface ExtractedEntity {
|
|
13
|
-
exact: string;
|
|
14
|
-
entityType: string;
|
|
15
|
-
start: number;
|
|
16
|
-
end: number;
|
|
17
|
-
prefix?: string;
|
|
18
|
-
suffix?: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Extract entity references from text using AI.
|
|
22
|
-
*
|
|
23
|
-
* Locale: entity references' bodies are entity-type identifiers (not
|
|
24
|
-
* LLM-generated natural-language text), so only `sourceLanguage` (source-
|
|
25
|
-
* resource locale) is meaningful here — it's used in the prompt so the LLM
|
|
26
|
-
* analyzes non-English source correctly. There's no body-locale parameter.
|
|
27
|
-
*
|
|
28
|
-
* @param text - The text to analyze
|
|
29
|
-
* @param entityTypes - Array of entity types to detect (optionally with examples)
|
|
30
|
-
* @param client - Inference client for AI operations
|
|
31
|
-
* @param includeDescriptiveReferences - Include anaphoric/cataphoric references (default: false)
|
|
32
|
-
* @param logger - Logger for entity-extraction diagnostics (parse failures,
|
|
33
|
-
* anchor decisions, drops). Required so dropped/filtered entities never
|
|
34
|
-
* disappear silently.
|
|
35
|
-
* @param sourceLanguage - BCP-47 tag for the source content's language
|
|
36
|
-
* @returns Array of extracted entities with their character offsets
|
|
37
|
-
*/
|
|
38
|
-
export declare function extractEntities(exact: string, entityTypes: string[] | {
|
|
39
|
-
type: string;
|
|
40
|
-
examples?: string[];
|
|
41
|
-
}[], client: InferenceClient, includeDescriptiveReferences: boolean, logger: Logger, sourceLanguage?: string): Promise<ExtractedEntity[]>;
|
|
42
|
-
//# sourceMappingURL=entity-extractor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entity-extractor.d.ts","sourceRoot":"","sources":["../../../src/workers/detection/entity-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAwB,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,EAC/D,MAAM,EAAE,eAAe,EACvB,4BAA4B,EAAE,OAAO,EACrC,MAAM,EAAE,MAAM,EACd,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,eAAe,EAAE,CAAC,CAmS5B"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Response parsers for annotation detection motivations
|
|
3
|
-
*
|
|
4
|
-
* Provides static methods to parse and validate AI responses for each motivation type.
|
|
5
|
-
* Includes offset validation and correction logic.
|
|
6
|
-
* Extracted from worker implementations to centralize parsing logic.
|
|
7
|
-
*
|
|
8
|
-
* NOTE: These are static utility methods without logger access.
|
|
9
|
-
* Console statements kept for debugging - consider adding logger parameter in future.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* Best-effort extractor that pulls a JSON array of objects out of a raw
|
|
13
|
-
* LLM response. Tolerates:
|
|
14
|
-
* - markdown code fences (``` / ```json)
|
|
15
|
-
* - prose before/after the array
|
|
16
|
-
* - stray non-JSON tokens between array elements (a common
|
|
17
|
-
* hallucination: e.g. a line like `wide: 0,` inserted between two
|
|
18
|
-
* well-formed objects).
|
|
19
|
-
*
|
|
20
|
-
* Strategy: try strict `JSON.parse` first (fast path); on failure, walk
|
|
21
|
-
* between the outermost `[` and `]` and parse each balanced `{ ... }`
|
|
22
|
-
* object independently, skipping any that don't parse. Returns the
|
|
23
|
-
* recovered objects — callers should still filter/validate fields.
|
|
24
|
-
*
|
|
25
|
-
* Exported for direct unit testing of the state machine edge cases
|
|
26
|
-
* (nested braces in strings, escape sequences, empty/garbage input).
|
|
27
|
-
*/
|
|
28
|
-
export declare function extractObjectsFromArray(response: string): unknown[];
|
|
29
|
-
/**
|
|
30
|
-
* Represents a detected comment with validated position
|
|
31
|
-
*/
|
|
32
|
-
export interface CommentMatch {
|
|
33
|
-
exact: string;
|
|
34
|
-
start: number;
|
|
35
|
-
end: number;
|
|
36
|
-
prefix?: string;
|
|
37
|
-
suffix?: string;
|
|
38
|
-
comment: string;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Represents a detected highlight with validated position
|
|
42
|
-
*/
|
|
43
|
-
export interface HighlightMatch {
|
|
44
|
-
exact: string;
|
|
45
|
-
start: number;
|
|
46
|
-
end: number;
|
|
47
|
-
prefix?: string;
|
|
48
|
-
suffix?: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Represents a detected assessment with validated position
|
|
52
|
-
*/
|
|
53
|
-
export interface AssessmentMatch {
|
|
54
|
-
exact: string;
|
|
55
|
-
start: number;
|
|
56
|
-
end: number;
|
|
57
|
-
prefix?: string;
|
|
58
|
-
suffix?: string;
|
|
59
|
-
assessment: string;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Represents a detected tag with validated position
|
|
63
|
-
*/
|
|
64
|
-
export interface TagMatch {
|
|
65
|
-
exact: string;
|
|
66
|
-
start: number;
|
|
67
|
-
end: number;
|
|
68
|
-
prefix?: string;
|
|
69
|
-
suffix?: string;
|
|
70
|
-
category: string;
|
|
71
|
-
}
|
|
72
|
-
export declare class MotivationParsers {
|
|
73
|
-
/**
|
|
74
|
-
* Parse and validate AI response for comment detection
|
|
75
|
-
*
|
|
76
|
-
* @param response - Raw AI response string (may include markdown code fences)
|
|
77
|
-
* @param content - Original content to validate offsets against
|
|
78
|
-
* @returns Array of validated comment matches
|
|
79
|
-
*/
|
|
80
|
-
static parseComments(response: string, content: string): CommentMatch[];
|
|
81
|
-
/**
|
|
82
|
-
* Parse and validate AI response for highlight detection
|
|
83
|
-
*
|
|
84
|
-
* @param response - Raw AI response string (may include markdown code fences)
|
|
85
|
-
* @param content - Original content to validate offsets against
|
|
86
|
-
* @returns Array of validated highlight matches
|
|
87
|
-
*/
|
|
88
|
-
static parseHighlights(response: string, content: string): HighlightMatch[];
|
|
89
|
-
/**
|
|
90
|
-
* Parse and validate AI response for assessment detection
|
|
91
|
-
*
|
|
92
|
-
* @param response - Raw AI response string (may include markdown code fences)
|
|
93
|
-
* @param content - Original content to validate offsets against
|
|
94
|
-
* @returns Array of validated assessment matches
|
|
95
|
-
*/
|
|
96
|
-
static parseAssessments(response: string, content: string): AssessmentMatch[];
|
|
97
|
-
/**
|
|
98
|
-
* Parse and validate AI response for tag detection
|
|
99
|
-
* Note: Does NOT validate offsets - caller must do that with content
|
|
100
|
-
*
|
|
101
|
-
* @param response - Raw AI response string (may include markdown code fences)
|
|
102
|
-
* @returns Array of tag matches (offsets not yet validated)
|
|
103
|
-
*/
|
|
104
|
-
static parseTags(response: string): Omit<TagMatch, 'category'>[];
|
|
105
|
-
/**
|
|
106
|
-
* Validate tag offsets against content and add category
|
|
107
|
-
* Helper for tag detection after initial parsing
|
|
108
|
-
*
|
|
109
|
-
* @param tags - Parsed tags without validated offsets
|
|
110
|
-
* @param content - Original content to validate against
|
|
111
|
-
* @param category - Category to assign to validated tags
|
|
112
|
-
* @returns Array of validated tag matches
|
|
113
|
-
*/
|
|
114
|
-
static validateTagOffsets(tags: Omit<TagMatch, 'category'>[], content: string, category: string): TagMatch[];
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=motivation-parsers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"motivation-parsers.d.ts","sourceRoot":"","sources":["../../../src/workers/detection/motivation-parsers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,EAAE,CAuDnE;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,KAAK,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