@semiont/jobs 0.5.2 → 0.5.4

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.
Files changed (35) hide show
  1. package/dist/fs-job-queue.d.ts +79 -0
  2. package/dist/fs-job-queue.d.ts.map +1 -0
  3. package/dist/index.d.ts +20 -623
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +74 -218
  6. package/dist/index.js.map +1 -1
  7. package/dist/job-claim-adapter.d.ts +76 -0
  8. package/dist/job-claim-adapter.d.ts.map +1 -0
  9. package/dist/job-queue-interface.d.ts +19 -0
  10. package/dist/job-queue-interface.d.ts.map +1 -0
  11. package/dist/job-queue-state-unit.d.ts +26 -0
  12. package/dist/job-queue-state-unit.d.ts.map +1 -0
  13. package/dist/job-worker.d.ts +67 -0
  14. package/dist/job-worker.d.ts.map +1 -0
  15. package/dist/processors.d.ts +41 -0
  16. package/dist/processors.d.ts.map +1 -0
  17. package/dist/types.d.ts +319 -0
  18. package/dist/types.d.ts.map +1 -0
  19. package/dist/worker-main.d.ts +22 -2
  20. package/dist/worker-main.d.ts.map +1 -0
  21. package/dist/worker-main.js +175 -276
  22. package/dist/worker-main.js.map +1 -1
  23. package/dist/worker-process.d.ts +47 -0
  24. package/dist/worker-process.d.ts.map +1 -0
  25. package/dist/workers/annotation-detection.d.ts +61 -0
  26. package/dist/workers/annotation-detection.d.ts.map +1 -0
  27. package/dist/workers/detection/entity-extractor.d.ts +42 -0
  28. package/dist/workers/detection/entity-extractor.d.ts.map +1 -0
  29. package/dist/workers/detection/motivation-parsers.d.ts +116 -0
  30. package/dist/workers/detection/motivation-parsers.d.ts.map +1 -0
  31. package/dist/workers/detection/motivation-prompts.d.ts +57 -0
  32. package/dist/workers/detection/motivation-prompts.d.ts.map +1 -0
  33. package/dist/workers/generation/resource-generation.d.ts +23 -0
  34. package/dist/workers/generation/resource-generation.d.ts.map +1 -0
  35. package/package.json +3 -3
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Job Claim Adapter — worker-side job lifecycle glue on top of a
3
+ * shared bus.
4
+ *
5
+ * Replaces the old `WorkerStateUnit`, which owned its own actor and
6
+ * duplicated the SSE connection that `SemiontClient` already held.
7
+ * Workers construct a `SemiontSession` normally (one actor, one
8
+ * SSE connection) and use this adapter to attach job-claim behaviour
9
+ * on top of the session's bus.
10
+ *
11
+ * The adapter is intentionally thin: it subscribes to `job:queued`,
12
+ * claims jobs via the existing request-response protocol
13
+ * (`job:claim` → `job:claimed` / `job:claim-failed`), and exposes
14
+ * observables for job orchestration. It does **not** own the bus,
15
+ * has no HTTP concerns, and has no modal state.
16
+ *
17
+ * The `bus` parameter is typed against the small `JobClaimBus`
18
+ * interface below so the adapter is transport-neutral. HTTP workers
19
+ * pass `(session.client.transport as HttpTransport).actor`; an
20
+ * in-process worker could pass a shim wrapping `client.bus`.
21
+ */
22
+ import { Observable } from 'rxjs';
23
+ import type { WorkerBus } from '@semiont/sdk';
24
+ export interface JobAssignment {
25
+ jobId: string;
26
+ type: string;
27
+ resourceId: string;
28
+ }
29
+ export interface ActiveJob {
30
+ jobId: string;
31
+ type: string;
32
+ resourceId: string;
33
+ userId: string;
34
+ params: Record<string, unknown>;
35
+ }
36
+ export interface JobClaimAdapterOptions {
37
+ /** Shared bus (typically the session's HTTP actor or an in-process bus shim). */
38
+ bus: WorkerBus;
39
+ /**
40
+ * Job types this worker can process. Jobs of other types that
41
+ * arrive on `job:queued` are ignored. Empty array = accept any.
42
+ */
43
+ jobTypes: string[];
44
+ }
45
+ export interface JobClaimAdapter {
46
+ /** Currently-claimed job, or null when idle. */
47
+ readonly activeJob$: Observable<ActiveJob | null>;
48
+ /** True while a claim is in flight or a job is being processed. */
49
+ readonly isProcessing$: Observable<boolean>;
50
+ /** Monotonically-incrementing count of successfully-completed jobs. */
51
+ readonly jobsCompleted$: Observable<number>;
52
+ /** Stream of job failures (including claim-failed and processing errors). */
53
+ readonly errors$: Observable<{
54
+ jobId: string;
55
+ error: string;
56
+ }>;
57
+ /**
58
+ * Subscribe to `job:queued` events (adding the channel to the actor
59
+ * if not already subscribed) and begin claiming matching jobs.
60
+ * Idempotent — calling `start()` twice is a no-op.
61
+ */
62
+ start(): void;
63
+ /** Stop claiming new jobs. Does not cancel an in-flight job. */
64
+ stop(): void;
65
+ /** Signal successful completion of `activeJob$`. */
66
+ completeJob(): void;
67
+ /** Signal failure of `activeJob$`. Emits on `errors$`. */
68
+ failJob(jobId: string, error: string): void;
69
+ /** Release observables. Does not dispose the shared bus. */
70
+ dispose(): void;
71
+ }
72
+ /**
73
+ * Attach job-claim behaviour to a shared bus.
74
+ */
75
+ export declare function createJobClaimAdapter(options: JobClaimAdapterOptions): JobClaimAdapter;
76
+ //# sourceMappingURL=job-claim-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-claim-adapter.d.ts","sourceRoot":"","sources":["../src/job-claim-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAmB,UAAU,EAAW,MAAM,MAAM,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,sBAAsB;IACrC,iFAAiF;IACjF,GAAG,EAAE,SAAS,CAAC;IACf;;;OAGG;IACH,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,gDAAgD;IAChD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAClD,mEAAmE;IACnE,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAC5C,uEAAuE;IACvE,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC5C,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAE/D;;;;OAIG;IACH,KAAK,IAAI,IAAI,CAAC;IAEd,gEAAgE;IAChE,IAAI,IAAI,IAAI,CAAC;IAEb,oDAAoD;IACpD,WAAW,IAAI,IAAI,CAAC;IAEpB,0DAA0D;IAC1D,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5C,4DAA4D;IAC5D,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,GAAG,eAAe,CA+GtF"}
@@ -0,0 +1,19 @@
1
+ import type { AnyJob, JobStatus } from './types';
2
+ import type { JobId } from '@semiont/core';
3
+ export interface JobQueue {
4
+ initialize(): Promise<void>;
5
+ destroy(): void;
6
+ createJob(job: AnyJob): Promise<void>;
7
+ getJob(jobId: JobId): Promise<AnyJob | null>;
8
+ updateJob(job: AnyJob, oldStatus?: JobStatus): Promise<void>;
9
+ pollNextPendingJob(predicate?: (job: AnyJob) => boolean): Promise<AnyJob | null>;
10
+ cancelJob(jobId: JobId): Promise<boolean>;
11
+ getStats(): Promise<{
12
+ pending: number;
13
+ running: number;
14
+ complete: number;
15
+ failed: number;
16
+ cancelled: number;
17
+ }>;
18
+ }
19
+ //# sourceMappingURL=job-queue-interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-queue-interface.d.ts","sourceRoot":"","sources":["../src/job-queue-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,WAAW,QAAQ;IACvB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,IAAI,IAAI,CAAC;IAChB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7C,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACjF,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,QAAQ,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChH"}
@@ -0,0 +1,26 @@
1
+ import { type Observable } from 'rxjs';
2
+ import type { SemiontClient, StateUnit } from '@semiont/sdk';
3
+ export interface Job {
4
+ jobId: string;
5
+ type: string;
6
+ status: string;
7
+ resourceId: string;
8
+ /** DID of the user who initiated the job (audit). */
9
+ userId: string;
10
+ created: string;
11
+ startedAt?: string;
12
+ completedAt?: string;
13
+ error?: string;
14
+ progress?: Record<string, unknown>;
15
+ result?: Record<string, unknown>;
16
+ }
17
+ export interface JobQueueStateUnit extends StateUnit {
18
+ jobs$: Observable<Job[]>;
19
+ pendingByType$: Observable<Map<string, number>>;
20
+ runningJobs$: Observable<Job[]>;
21
+ jobCreated$: Observable<Job>;
22
+ jobCompleted$: Observable<Job>;
23
+ jobFailed$: Observable<Job>;
24
+ }
25
+ export declare function createJobQueueStateUnit(client: SemiontClient): JobQueueStateUnit;
26
+ //# sourceMappingURL=job-queue-state-unit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-queue-state-unit.d.ts","sourceRoot":"","sources":["../src/job-queue-state-unit.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,UAAU,EAAO,MAAM,MAAM,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE7D,MAAM,WAAW,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,KAAK,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;IACzB,cAAc,EAAE,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,YAAY,EAAE,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;IAChC,WAAW,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAC7B,aAAa,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;CAC7B;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,aAAa,GAAG,iBAAiB,CAoGhF"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Job Worker Base Class
3
+ *
4
+ * Abstract worker that polls the job queue and processes jobs.
5
+ * Subclasses implement specific job processing logic.
6
+ */
7
+ import type { AnyJob, RunningJob } from './types';
8
+ import type { JobQueue } from './job-queue-interface';
9
+ import type { Logger } from '@semiont/core';
10
+ export declare abstract class JobWorker {
11
+ private running;
12
+ private currentJob;
13
+ private pollIntervalMs;
14
+ private errorBackoffMs;
15
+ protected jobQueue: JobQueue;
16
+ protected logger: Logger;
17
+ constructor(jobQueue: JobQueue, pollIntervalMs: number | undefined, errorBackoffMs: number | undefined, logger: Logger);
18
+ /**
19
+ * Start the worker (polls queue in loop)
20
+ */
21
+ start(): Promise<void>;
22
+ /**
23
+ * Stop the worker (graceful shutdown)
24
+ */
25
+ stop(): Promise<void>;
26
+ /**
27
+ * Poll for next job to process
28
+ */
29
+ private pollNextJob;
30
+ /**
31
+ * Process a job (handles state transitions and error handling)
32
+ */
33
+ private processJob;
34
+ /**
35
+ * Handle job failure (retry or move to failed)
36
+ */
37
+ protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
38
+ /**
39
+ * Update job progress (best-effort, doesn't throw)
40
+ */
41
+ protected updateJobProgress(job: AnyJob): Promise<void>;
42
+ /**
43
+ * Sleep utility
44
+ */
45
+ protected sleep(ms: number): Promise<void>;
46
+ /**
47
+ * Emit completion event (optional hook for subclasses)
48
+ * Override this to emit job-specific completion events (e.g., job.completed)
49
+ */
50
+ protected emitCompletionEvent(_job: RunningJob<any, any>, _result: any): Promise<void>;
51
+ /**
52
+ * Get worker name (for logging)
53
+ */
54
+ protected abstract getWorkerName(): string;
55
+ /**
56
+ * Check if this worker can process the given job
57
+ */
58
+ protected abstract canProcessJob(job: AnyJob): boolean;
59
+ /**
60
+ * Execute the job (job-specific logic)
61
+ * This is where the actual work happens
62
+ * Return the result object (or void for jobs without results)
63
+ * Throw an error to trigger retry logic
64
+ */
65
+ protected abstract executeJob(job: AnyJob): Promise<any>;
66
+ }
67
+ //# sourceMappingURL=job-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-worker.d.ts","sourceRoot":"","sources":["../src/job-worker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAsC,MAAM,SAAS,CAAC;AACtF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,8BAAsB,SAAS;IAC7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,cAAc,CAAS;IAC/B,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC7B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGvB,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,MAAM,YAAO,EAC7B,cAAc,EAAE,MAAM,YAAO,EAC7B,MAAM,EAAE,MAAM;IAQhB;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwB5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB3B;;OAEG;YACW,WAAW;IAIzB;;OAEG;YACW,UAAU;IAkDxB;;OAEG;cACa,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAqCxE;;OAEG;cACa,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7D;;OAEG;IACH,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C;;;OAGG;cACa,mBAAmB,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAO5F;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa,IAAI,MAAM;IAE1C;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAEtD;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CACzD"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Job Processors — extracted from JobWorker subclasses
3
+ *
4
+ * Pure functions that take content + inference client + params,
5
+ * report progress via callback, and return annotations + results.
6
+ *
7
+ * No EventBus, no JobQueue, no side effects except calling inference.
8
+ * Two callers:
9
+ * 1. In-process JobWorker subclasses (existing path)
10
+ * 2. Remote WorkerStateUnit via worker-process.ts (new path)
11
+ */
12
+ import { type Logger, type components } from '@semiont/core';
13
+ import type { InferenceClient } from '@semiont/inference';
14
+ import type { HighlightDetectionParams, CommentDetectionParams, AssessmentDetectionParams, DetectionParams, TagDetectionParams, GenerationParams, HighlightDetectionResult, CommentDetectionResult, AssessmentDetectionResult, DetectionResult, TagDetectionResult, GenerationResult } from './types';
15
+ type Agent = components['schemas']['Agent'];
16
+ /**
17
+ * Progress callback. The three positional args satisfy the minimum
18
+ * `JobProgress` required fields (`percentage`, `message`, `stage`).
19
+ * The fourth optional arg carries job-type-specific fields
20
+ * (`currentEntityType`, `completedEntityTypes`, `requestParams`, etc.)
21
+ * that the progress UI renders.
22
+ */
23
+ export type OnProgress = (percentage: number, message: string, stage: string, extra?: Partial<JobProgress>) => void;
24
+ type JobProgress = components['schemas']['JobProgress'];
25
+ export interface ProcessorResult<R> {
26
+ annotations: Record<string, unknown>[];
27
+ result: R;
28
+ }
29
+ export declare function processHighlightJob(content: string, inferenceClient: InferenceClient, params: HighlightDetectionParams, userId: string, generator: Agent, onProgress: OnProgress): Promise<ProcessorResult<HighlightDetectionResult>>;
30
+ export declare function processCommentJob(content: string, inferenceClient: InferenceClient, params: CommentDetectionParams, userId: string, generator: Agent, onProgress: OnProgress): Promise<ProcessorResult<CommentDetectionResult>>;
31
+ export declare function processAssessmentJob(content: string, inferenceClient: InferenceClient, params: AssessmentDetectionParams, userId: string, generator: Agent, onProgress: OnProgress): Promise<ProcessorResult<AssessmentDetectionResult>>;
32
+ export declare function processReferenceJob(content: string, inferenceClient: InferenceClient, params: DetectionParams, userId: string, generator: Agent, onProgress: OnProgress, logger: Logger): Promise<ProcessorResult<DetectionResult>>;
33
+ export declare function processTagJob(content: string, inferenceClient: InferenceClient, params: TagDetectionParams, userId: string, generator: Agent, onProgress: OnProgress): Promise<ProcessorResult<TagDetectionResult>>;
34
+ export declare function processGenerationJob(inferenceClient: InferenceClient, params: GenerationParams, onProgress: OnProgress, logger: Logger): Promise<{
35
+ content: string;
36
+ title: string;
37
+ format: string;
38
+ result: GenerationResult;
39
+ }>;
40
+ export {};
41
+ //# sourceMappingURL=processors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processors.d.ts","sourceRoot":"","sources":["../src/processors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,EAAc,KAAK,MAAM,EAAmB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAE1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EACV,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAE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e,EACvB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAgE3C;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,KAAK,EAChB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC,CAqC9C;AAED,wBAAsB,oBAAoB,CACxC,eAAe,EAAE,eAAe,EAChC,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC,CAgCvF"}
@@ -0,0 +1,319 @@
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
@@ -0,0 +1 @@
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,GAAG,sBAAsB,GAAG,YAAY,GAAG,sBAAsB,GAAG,uBAAuB,GAAG,oBAAoB,GAAG,gBAAgB,CAAC;AACzJ,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;AAMpF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,KAAK,CAAC;IACV,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EA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;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,2 +1,22 @@
1
-
2
- export { }
1
+ /**
2
+ * Worker Pool Main — standalone entry point
3
+ *
4
+ * One worker host runs N parallel worker processes, one per distinct
5
+ * `(inferenceProvider, model)` configured in `~/.semiontconfig`. Each
6
+ * authenticates with the KS via `/api/tokens/agent` for *its* agent
7
+ * identity, and that JWT is what the bus stamps onto every event the
8
+ * process emits — so `_userId` on the bus and the `generator` on every
9
+ * annotation refer to the same software peer.
10
+ *
11
+ * Multiple job types may share an inference engine; in that case they
12
+ * share a worker process (and an agent identity). Different engines
13
+ * mean different processes and different agents.
14
+ *
15
+ * Environment variables (only two):
16
+ * SEMIONT_WORKER_SECRET — shared secret for /api/tokens/agent auth
17
+ * ANTHROPIC_API_KEY — only when using Anthropic inference
18
+ *
19
+ * Everything else comes from ~/.semiontconfig.
20
+ */
21
+ export {};
22
+ //# sourceMappingURL=worker-main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-main.d.ts","sourceRoot":"","sources":["../src/worker-main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}