@semiont/jobs 0.5.3 → 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 -632
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +65 -56
  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 +165 -114
  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,47 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,61 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,42 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,116 @@
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
@@ -0,0 +1 @@
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,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,iBAAiB;IAC5B;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE;IA2CvE;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE;IAwC3E;;;;;;OAMG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,EAAE;IAyC7E;;;;;;OAMG;IACH,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE;IAsBhE;;;;;;;;OAQG;IACH,MAAM,CAAC,kBAAkB,CACvB,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,EAClC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,QAAQ,EAAE;CAsBd"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Prompt builders for annotation detection motivations
3
+ *
4
+ * Provides static methods to build AI prompts for each Web Annotation motivation type.
5
+ * Extracted from worker implementations to centralize prompt logic.
6
+ *
7
+ * Locale handling: builders take two optional BCP-47 tags. `language` is the
8
+ * locale the *generated body text* should be written in (sourced from the user's
9
+ * UI locale); `sourceLanguage` is the locale of the *text being analyzed*
10
+ * (sourced from `ResourceDescriptor` / its primary representation). They are
11
+ * independent — see `types.ts` "Locale conventions" for the full discussion.
12
+ */
13
+ export declare class MotivationPrompts {
14
+ /**
15
+ * Build a prompt for detecting comment-worthy passages
16
+ *
17
+ * @param content - The text content to analyze (will be truncated to 8000 chars)
18
+ * @param instructions - Optional user-provided instructions
19
+ * @param tone - Optional tone guidance (e.g., "academic", "conversational")
20
+ * @param density - Optional target number of comments per 2000 words
21
+ * @returns Formatted prompt string
22
+ */
23
+ static buildCommentPrompt(content: string, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string): string;
24
+ /**
25
+ * Build a prompt for detecting highlight-worthy passages
26
+ *
27
+ * @param content - The text content to analyze (will be truncated to 8000 chars)
28
+ * @param instructions - Optional user-provided instructions
29
+ * @param density - Optional target number of highlights per 2000 words
30
+ * @returns Formatted prompt string
31
+ */
32
+ static buildHighlightPrompt(content: string, instructions?: string, density?: number, sourceLanguage?: string): string;
33
+ /**
34
+ * Build a prompt for detecting assessment-worthy passages
35
+ *
36
+ * @param content - The text content to analyze (will be truncated to 8000 chars)
37
+ * @param instructions - Optional user-provided instructions
38
+ * @param tone - Optional tone guidance (e.g., "critical", "supportive")
39
+ * @param density - Optional target number of assessments per 2000 words
40
+ * @returns Formatted prompt string
41
+ */
42
+ static buildAssessmentPrompt(content: string, instructions?: string, tone?: string, density?: number, language?: string, sourceLanguage?: string): string;
43
+ /**
44
+ * Build a prompt for detecting structural tags
45
+ *
46
+ * @param content - The full text content to analyze (NOT truncated for structural analysis)
47
+ * @param category - The specific category to detect
48
+ * @param schemaName - Human-readable schema name
49
+ * @param schemaDescription - Schema description
50
+ * @param schemaDomain - Schema domain
51
+ * @param categoryDescription - Category description
52
+ * @param categoryExamples - Example questions/guidance for this category
53
+ * @returns Formatted prompt string
54
+ */
55
+ static buildTagPrompt(content: string, category: string, schemaName: string, schemaDescription: string, schemaDomain: string, categoryDescription: string, categoryExamples: string[], sourceLanguage?: string): string;
56
+ }
57
+ //# sourceMappingURL=motivation-prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motivation-prompts.d.ts","sourceRoot":"","sources":["../../../src/workers/detection/motivation-prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAoBH,qBAAa,iBAAiB;IAC5B;;;;;;;;OAQG;IACH,MAAM,CAAC,kBAAkB,CACvB,OAAO,EAAE,MAAM,EACf,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,MAAM;IA8ET;;;;;;;OAOG;IACH,MAAM,CAAC,oBAAoB,CACzB,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM;IAwET;;;;;;;;OAQG;IACH,MAAM,CAAC,qBAAqB,CAC1B,OAAO,EAAE,MAAM,EACf,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,MAAM;IA8ET;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,cAAc,CACnB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,EACzB,YAAY,EAAE,MAAM,EACpB,mBAAmB,EAAE,MAAM,EAC3B,gBAAgB,EAAE,MAAM,EAAE,EAC1B,cAAc,CAAC,EAAE,MAAM,GACtB,MAAM;CAiDV"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Resource Generation
3
+ *
4
+ * Generates markdown resources from topics using AI inference.
5
+ */
6
+ import type { GatheredContext, Logger } from '@semiont/core';
7
+ import type { InferenceClient } from '@semiont/inference';
8
+ /**
9
+ * Generate resource content using inference.
10
+ *
11
+ * Locale parameters: `locale` is the *body* locale — the language the
12
+ * generated resource should be written in (sourced from the user's UI
13
+ * locale). `sourceLanguage` is the *source* locale — the language of the
14
+ * referenced resource whose context (selected passage, surrounding text)
15
+ * is embedded into the prompt. They're independent: a German user can
16
+ * generate German content from an English source resource. See
17
+ * `types.ts` "Locale conventions" for the full discussion.
18
+ */
19
+ export declare function generateResourceFromTopic(topic: string, entityTypes: string[], client: InferenceClient, logger: Logger, userPrompt?: string, locale?: string, context?: GatheredContext, temperature?: number, maxTokens?: number, sourceLanguage?: string): Promise<{
20
+ title: string;
21
+ content: string;
22
+ }>;
23
+ //# sourceMappingURL=resource-generation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-generation.d.ts","sourceRoot":"","sources":["../../../src/workers/generation/resource-generation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAO1D;;;;;;;;;;GAUG;AACH,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EAAE,EACrB,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,EACzB,WAAW,CAAC,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAyJ7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semiont/jobs",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "type": "module",
5
5
  "description": "Filesystem-based job queue and worker infrastructure",
6
6
  "main": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "README.md"
21
21
  ],
22
22
  "scripts": {
23
- "build": "npm run typecheck && tsup",
23
+ "build": "npm run typecheck && tsup && tsc -p tsconfig.build.json",
24
24
  "typecheck": "tsc --noEmit",
25
25
  "test": "vitest",
26
26
  "test:coverage": "vitest run --coverage"
@@ -37,7 +37,7 @@
37
37
  "devDependencies": {
38
38
  "@vitest/coverage-v8": "^4.1.0",
39
39
  "tsup": "^8.0.1",
40
- "typescript": "^5.6.3"
40
+ "typescript": "^6.0.2"
41
41
  },
42
42
  "publishConfig": {
43
43
  "access": "public"