@semiont/make-meaning 0.2.43 → 0.2.46
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/README.md +141 -262
- package/dist/index.d.ts +248 -542
- package/dist/index.js +11500 -4705
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,218 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EventStore } from '@semiont/event-sourcing';
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { JobQueue, ReferenceAnnotationWorker, GenerationWorker, HighlightAnnotationWorker, AssessmentAnnotationWorker, CommentAnnotationWorker, TagAnnotationWorker } from '@semiont/jobs';
|
|
2
|
+
import { EventStore, ViewStorage } from '@semiont/event-sourcing';
|
|
3
|
+
import { EnvironmentConfig, Logger, StoredEvent, ResourceId, EventBus, components, CreationMethod, UserId, AnnotationUri, ResourceAnnotations, AnnotationId, AnnotationCategory, GraphPath, GraphConnection } from '@semiont/core';
|
|
4
|
+
export { AssembledAnnotation, applyBodyOperations, assembleAnnotation } from '@semiont/core';
|
|
5
5
|
import { InferenceClient } from '@semiont/inference';
|
|
6
6
|
import { GraphDatabase } from '@semiont/graph';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Reference Detection Worker
|
|
10
|
-
*
|
|
11
|
-
* Processes detection jobs: runs AI inference to find entities in resources
|
|
12
|
-
* and emits reference.created events for each detected entity.
|
|
13
|
-
*
|
|
14
|
-
* This worker is INDEPENDENT of HTTP clients - it just processes jobs and emits events.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
type ResourceDescriptor$2 = components['schemas']['ResourceDescriptor'];
|
|
18
|
-
interface DetectedAnnotation {
|
|
19
|
-
annotation: {
|
|
20
|
-
selector: {
|
|
21
|
-
start: number;
|
|
22
|
-
end: number;
|
|
23
|
-
exact: string;
|
|
24
|
-
prefix?: string;
|
|
25
|
-
suffix?: string;
|
|
26
|
-
};
|
|
27
|
-
entityTypes: string[];
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
declare class ReferenceAnnotationWorker extends JobWorker {
|
|
31
|
-
private config;
|
|
32
|
-
private eventStore;
|
|
33
|
-
private inferenceClient;
|
|
34
|
-
private eventBus;
|
|
35
|
-
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient, eventBus: EventBus, logger: Logger);
|
|
36
|
-
protected getWorkerName(): string;
|
|
37
|
-
protected canProcessJob(job: AnyJob): boolean;
|
|
38
|
-
protected executeJob(job: AnyJob): Promise<DetectionResult>;
|
|
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
|
-
/**
|
|
48
|
-
* Emit completion event with result data
|
|
49
|
-
* Override base class to emit job.completed event (domain + progress)
|
|
50
|
-
*/
|
|
51
|
-
protected emitCompletionEvent(job: RunningJob<DetectionParams, DetectionProgress>, result: DetectionResult): Promise<void>;
|
|
52
|
-
protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Update job progress and emit events to Event Store and EventBus
|
|
55
|
-
* Overrides base class to emit both domain events and progress events
|
|
56
|
-
*/
|
|
57
|
-
protected updateJobProgress(job: AnyJob): Promise<void>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Generation Worker
|
|
62
|
-
*
|
|
63
|
-
* Processes generation jobs: runs AI inference to generate new resources
|
|
64
|
-
* and emits resource.created and annotation.body.updated events.
|
|
65
|
-
*
|
|
66
|
-
* This worker is INDEPENDENT of HTTP clients - it just processes jobs and emits events.
|
|
67
|
-
*/
|
|
68
|
-
|
|
69
|
-
declare class GenerationWorker extends JobWorker {
|
|
70
|
-
private config;
|
|
71
|
-
private eventStore;
|
|
72
|
-
private inferenceClient;
|
|
73
|
-
private eventBus;
|
|
74
|
-
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient, eventBus: EventBus, logger: Logger);
|
|
75
|
-
protected getWorkerName(): string;
|
|
76
|
-
protected canProcessJob(job: AnyJob): boolean;
|
|
77
|
-
protected executeJob(job: AnyJob): Promise<GenerationResult>;
|
|
78
|
-
private processGenerationJob;
|
|
79
|
-
/**
|
|
80
|
-
* Emit completion event with result data
|
|
81
|
-
* Override base class to emit job.completed event with resultResourceId
|
|
82
|
-
*/
|
|
83
|
-
protected emitCompletionEvent(job: RunningJob<GenerationParams, YieldProgress>, result: GenerationResult): Promise<void>;
|
|
84
|
-
protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* Update job progress and emit events to Event Store
|
|
87
|
-
* Overrides base class to also emit job progress events
|
|
88
|
-
*/
|
|
89
|
-
protected updateJobProgress(job: AnyJob): Promise<void>;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Highlight Detection Worker
|
|
94
|
-
*
|
|
95
|
-
* Processes highlight-detection jobs: runs AI inference to find passages
|
|
96
|
-
* that should be highlighted and creates highlight annotations.
|
|
97
|
-
*/
|
|
98
|
-
|
|
99
|
-
declare class HighlightAnnotationWorker extends JobWorker {
|
|
100
|
-
private config;
|
|
101
|
-
private eventStore;
|
|
102
|
-
private inferenceClient;
|
|
103
|
-
private eventBus;
|
|
104
|
-
private isFirstProgress;
|
|
105
|
-
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient, eventBus: EventBus, logger: Logger);
|
|
106
|
-
protected getWorkerName(): string;
|
|
107
|
-
protected canProcessJob(job: AnyJob): boolean;
|
|
108
|
-
protected executeJob(job: AnyJob): Promise<HighlightDetectionResult>;
|
|
109
|
-
/**
|
|
110
|
-
* Emit completion event with result data
|
|
111
|
-
* Override base class to emit job.completed event
|
|
112
|
-
*/
|
|
113
|
-
protected emitCompletionEvent(job: RunningJob<HighlightDetectionParams, HighlightDetectionProgress>, result: HighlightDetectionResult): Promise<void>;
|
|
114
|
-
/**
|
|
115
|
-
* Override updateJobProgress to emit events to Event Store
|
|
116
|
-
*/
|
|
117
|
-
protected updateJobProgress(job: AnyJob): Promise<void>;
|
|
118
|
-
protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
|
|
119
|
-
private processHighlightDetectionJob;
|
|
120
|
-
private createHighlightAnnotation;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Assessment Detection Worker
|
|
125
|
-
*
|
|
126
|
-
* Processes assessment-detection jobs: runs AI inference to assess/evaluate
|
|
127
|
-
* passages in the text and creates assessment annotations.
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
declare class AssessmentAnnotationWorker extends JobWorker {
|
|
131
|
-
private config;
|
|
132
|
-
private eventStore;
|
|
133
|
-
private inferenceClient;
|
|
134
|
-
private eventBus;
|
|
135
|
-
private isFirstProgress;
|
|
136
|
-
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient, eventBus: EventBus, logger: Logger);
|
|
137
|
-
protected getWorkerName(): string;
|
|
138
|
-
protected canProcessJob(job: AnyJob): boolean;
|
|
139
|
-
protected executeJob(job: AnyJob): Promise<AssessmentDetectionResult>;
|
|
140
|
-
/**
|
|
141
|
-
* Emit completion event with result data
|
|
142
|
-
* Override base class to emit job.completed event
|
|
143
|
-
*/
|
|
144
|
-
protected emitCompletionEvent(job: RunningJob<AssessmentDetectionParams, AssessmentDetectionProgress>, result: AssessmentDetectionResult): Promise<void>;
|
|
145
|
-
/**
|
|
146
|
-
* Override updateJobProgress to emit events to Event Store
|
|
147
|
-
*/
|
|
148
|
-
protected updateJobProgress(job: AnyJob): Promise<void>;
|
|
149
|
-
protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
|
|
150
|
-
private processAssessmentDetectionJob;
|
|
151
|
-
private createAssessmentAnnotation;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Comment Detection Worker
|
|
156
|
-
*
|
|
157
|
-
* Processes comment-detection jobs: runs AI inference to identify passages
|
|
158
|
-
* that would benefit from explanatory comments and creates comment annotations.
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
declare class CommentAnnotationWorker extends JobWorker {
|
|
162
|
-
private config;
|
|
163
|
-
private eventStore;
|
|
164
|
-
private inferenceClient;
|
|
165
|
-
private eventBus;
|
|
166
|
-
private isFirstProgress;
|
|
167
|
-
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient, eventBus: EventBus, logger: Logger);
|
|
168
|
-
protected getWorkerName(): string;
|
|
169
|
-
protected canProcessJob(job: AnyJob): boolean;
|
|
170
|
-
protected executeJob(job: AnyJob): Promise<CommentDetectionResult>;
|
|
171
|
-
/**
|
|
172
|
-
* Emit completion event with result data
|
|
173
|
-
* Override base class to emit job.completed event
|
|
174
|
-
*/
|
|
175
|
-
protected emitCompletionEvent(job: RunningJob<CommentDetectionParams, CommentDetectionProgress>, result: CommentDetectionResult): Promise<void>;
|
|
176
|
-
/**
|
|
177
|
-
* Override updateJobProgress to emit events to Event Store
|
|
178
|
-
*/
|
|
179
|
-
protected updateJobProgress(job: AnyJob): Promise<void>;
|
|
180
|
-
protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
|
|
181
|
-
private processCommentDetectionJob;
|
|
182
|
-
private createCommentAnnotation;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Tag Detection Worker
|
|
187
|
-
*
|
|
188
|
-
* Processes tag-detection jobs: runs AI inference to identify passages
|
|
189
|
-
* serving specific structural roles (IRAC, IMRAD, Toulmin, etc.) and
|
|
190
|
-
* creates tag annotations with dual-body structure.
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
|
-
declare class TagAnnotationWorker extends JobWorker {
|
|
194
|
-
private config;
|
|
195
|
-
private eventStore;
|
|
196
|
-
private inferenceClient;
|
|
197
|
-
private eventBus;
|
|
198
|
-
private isFirstProgress;
|
|
199
|
-
constructor(jobQueue: JobQueue, config: EnvironmentConfig, eventStore: EventStore, inferenceClient: InferenceClient, eventBus: EventBus, logger: Logger);
|
|
200
|
-
protected getWorkerName(): string;
|
|
201
|
-
protected canProcessJob(job: AnyJob): boolean;
|
|
202
|
-
protected executeJob(job: AnyJob): Promise<TagDetectionResult>;
|
|
203
|
-
/**
|
|
204
|
-
* Emit completion event with result data
|
|
205
|
-
* Override base class to emit job.completed event
|
|
206
|
-
*/
|
|
207
|
-
protected emitCompletionEvent(job: RunningJob<TagDetectionParams, TagDetectionProgress>, result: TagDetectionResult): Promise<void>;
|
|
208
|
-
/**
|
|
209
|
-
* Override updateJobProgress to emit events to Event Store
|
|
210
|
-
*/
|
|
211
|
-
protected updateJobProgress(job: AnyJob): Promise<void>;
|
|
212
|
-
protected handleJobFailure(job: AnyJob, error: any): Promise<void>;
|
|
213
|
-
private processTagDetectionJob;
|
|
214
|
-
private createTagAnnotation;
|
|
215
|
-
}
|
|
7
|
+
import { RepresentationStore } from '@semiont/content';
|
|
216
8
|
|
|
217
9
|
/**
|
|
218
10
|
* GraphDB Consumer
|
|
@@ -307,6 +99,198 @@ declare class GraphDBConsumer {
|
|
|
307
99
|
shutdown(): Promise<void>;
|
|
308
100
|
}
|
|
309
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Knowledge Base
|
|
104
|
+
*
|
|
105
|
+
* The inert store that records what intelligent actors decide.
|
|
106
|
+
* Groups the four KB subsystems from ARCHITECTURE.md:
|
|
107
|
+
*
|
|
108
|
+
* - Event Log (immutable append-only) — via EventStore
|
|
109
|
+
* - Materialized Views (fast single-doc queries) — via ViewStorage
|
|
110
|
+
* - Content Store (SHA-256 addressed, deduplicated) — via RepresentationStore
|
|
111
|
+
* - Graph (eventually consistent relationship projection) — via GraphDatabase
|
|
112
|
+
*
|
|
113
|
+
* The Gatherer and Binder are the only actors that read from these stores directly.
|
|
114
|
+
*/
|
|
115
|
+
|
|
116
|
+
interface KnowledgeBase {
|
|
117
|
+
eventStore: EventStore;
|
|
118
|
+
views: ViewStorage;
|
|
119
|
+
content: RepresentationStore;
|
|
120
|
+
graph: GraphDatabase;
|
|
121
|
+
}
|
|
122
|
+
declare function createKnowledgeBase(eventStore: EventStore, basePath: string, projectRoot: string | undefined, graphDb: GraphDatabase, logger: Logger): KnowledgeBase;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Gatherer Actor
|
|
126
|
+
*
|
|
127
|
+
* The read actor for the knowledge base. Subscribes to gather and browse events,
|
|
128
|
+
* queries KB stores via context modules, and emits results back to the bus.
|
|
129
|
+
*
|
|
130
|
+
* From ARCHITECTURE.md:
|
|
131
|
+
* "When a Generator Agent or Linker Agent emits a gather event, the Gatherer
|
|
132
|
+
* receives it from the bus, queries the relevant KB stores, and assembles
|
|
133
|
+
* the context needed for downstream work."
|
|
134
|
+
*
|
|
135
|
+
* Handles:
|
|
136
|
+
* - gather:requested / gather:resource-requested — LLM context assembly
|
|
137
|
+
* - browse:resource-requested — single resource metadata (materialized from events)
|
|
138
|
+
* - browse:resources-requested — list resources
|
|
139
|
+
* - browse:annotations-requested — all annotations for a resource
|
|
140
|
+
* - browse:annotation-requested — single annotation with resolved resource
|
|
141
|
+
* - browse:events-requested — resource event history
|
|
142
|
+
* - browse:annotation-history-requested — annotation event history
|
|
143
|
+
* - mark:entity-types-requested — list entity types
|
|
144
|
+
*
|
|
145
|
+
* RxJS pipeline follows the GraphDBConsumer pattern:
|
|
146
|
+
* - groupBy(resourceUri) for per-resource isolation (gather events)
|
|
147
|
+
* - mergeMap for independent request-response (browse events)
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
declare class Gatherer {
|
|
151
|
+
private publicURL;
|
|
152
|
+
private kb;
|
|
153
|
+
private eventBus;
|
|
154
|
+
private inferenceClient;
|
|
155
|
+
private config?;
|
|
156
|
+
private subscriptions;
|
|
157
|
+
private readonly logger;
|
|
158
|
+
constructor(publicURL: string, kb: KnowledgeBase, eventBus: EventBus, inferenceClient: InferenceClient, logger: Logger, config?: EnvironmentConfig | undefined);
|
|
159
|
+
initialize(): Promise<void>;
|
|
160
|
+
private handleAnnotationGather;
|
|
161
|
+
private handleResourceGather;
|
|
162
|
+
private handleBrowseResource;
|
|
163
|
+
private handleBrowseResources;
|
|
164
|
+
private handleBrowseAnnotations;
|
|
165
|
+
private handleBrowseAnnotation;
|
|
166
|
+
private handleBrowseEvents;
|
|
167
|
+
private handleBrowseAnnotationHistory;
|
|
168
|
+
private handleEntityTypes;
|
|
169
|
+
stop(): Promise<void>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Binder Actor
|
|
174
|
+
*
|
|
175
|
+
* Bridge between the event bus and the knowledge base for entity resolution.
|
|
176
|
+
* Subscribes to bind search events and referenced-by queries, queries KB stores
|
|
177
|
+
* (graph, views), and emits results back to the bus.
|
|
178
|
+
*
|
|
179
|
+
* From ARCHITECTURE.md:
|
|
180
|
+
* "When an Analyst or Linker Agent emits a bind event, the Binder receives it
|
|
181
|
+
* from the bus, searches the KB stores for matching resources, and resolves
|
|
182
|
+
* references — linking a mention to its referent."
|
|
183
|
+
*
|
|
184
|
+
* Handles:
|
|
185
|
+
* - bind:search-requested — search for binding candidates
|
|
186
|
+
* - bind:referenced-by-requested — find annotations that reference a resource
|
|
187
|
+
*
|
|
188
|
+
* The Binder handles only the read side (searching for candidates).
|
|
189
|
+
* The write side (annotation.body.updated) stays in the route where
|
|
190
|
+
* userId is available from auth context. That domain event still flows
|
|
191
|
+
* through the bus via EventStore auto-publish.
|
|
192
|
+
*/
|
|
193
|
+
|
|
194
|
+
declare class Binder {
|
|
195
|
+
private kb;
|
|
196
|
+
private eventBus;
|
|
197
|
+
private publicURL?;
|
|
198
|
+
private subscriptions;
|
|
199
|
+
private readonly logger;
|
|
200
|
+
constructor(kb: KnowledgeBase, eventBus: EventBus, logger: Logger, publicURL?: string | undefined);
|
|
201
|
+
initialize(): Promise<void>;
|
|
202
|
+
private handleSearch;
|
|
203
|
+
private handleReferencedBy;
|
|
204
|
+
stop(): Promise<void>;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Stower Actor
|
|
209
|
+
*
|
|
210
|
+
* The single write gateway to the Knowledge Base. Subscribes to command
|
|
211
|
+
* events on the EventBus and translates them into domain events on the
|
|
212
|
+
* EventStore + content writes to the RepresentationStore.
|
|
213
|
+
*
|
|
214
|
+
* From ARCHITECTURE.md:
|
|
215
|
+
* The Knowledge Base has exactly three actor interfaces:
|
|
216
|
+
* - Stower (write) — this actor
|
|
217
|
+
* - Gatherer (read context)
|
|
218
|
+
* - Binder (read search)
|
|
219
|
+
*
|
|
220
|
+
* No other code should call eventStore.appendEvent() or repStore.store().
|
|
221
|
+
*
|
|
222
|
+
* Subscriptions:
|
|
223
|
+
* - yield:create → resource.created (+ content store) → yield:created / yield:create-failed
|
|
224
|
+
* - mark:create → annotation.added → mark:created / mark:create-failed
|
|
225
|
+
* - mark:delete → annotation.removed → mark:deleted / mark:delete-failed
|
|
226
|
+
* - mark:update-body → annotation.body.updated → (no result event yet)
|
|
227
|
+
* - mark:archive → resource.archived (resource-scoped, no result event)
|
|
228
|
+
* - mark:unarchive → resource.unarchived (resource-scoped, no result event)
|
|
229
|
+
* - mark:add-entity-type → entitytype.added → mark:entity-type-added / mark:entity-type-add-failed
|
|
230
|
+
* - mark:update-entity-types → entitytag.added / entitytag.removed
|
|
231
|
+
* - job:start → job.started
|
|
232
|
+
* - job:report-progress → job.progress
|
|
233
|
+
* - job:complete → job.completed
|
|
234
|
+
* - job:fail → job.failed
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
type ResourceDescriptor$2 = components['schemas']['ResourceDescriptor'];
|
|
238
|
+
interface CreateResourceResult {
|
|
239
|
+
resourceId: ResourceId;
|
|
240
|
+
resource: ResourceDescriptor$2;
|
|
241
|
+
}
|
|
242
|
+
declare class Stower {
|
|
243
|
+
private kb;
|
|
244
|
+
private publicURL;
|
|
245
|
+
private eventBus;
|
|
246
|
+
private subscription;
|
|
247
|
+
private readonly logger;
|
|
248
|
+
constructor(kb: KnowledgeBase, publicURL: string, eventBus: EventBus, logger: Logger);
|
|
249
|
+
initialize(): Promise<void>;
|
|
250
|
+
private handleYieldCreate;
|
|
251
|
+
private handleMarkCreate;
|
|
252
|
+
private handleMarkDelete;
|
|
253
|
+
private handleMarkUpdateBody;
|
|
254
|
+
private handleMarkArchive;
|
|
255
|
+
private handleMarkUnarchive;
|
|
256
|
+
private handleAddEntityType;
|
|
257
|
+
private handleUpdateEntityTypes;
|
|
258
|
+
private handleJobStart;
|
|
259
|
+
private handleJobReportProgress;
|
|
260
|
+
private handleJobComplete;
|
|
261
|
+
private handleJobFail;
|
|
262
|
+
stop(): Promise<void>;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Clone Token Manager
|
|
267
|
+
*
|
|
268
|
+
* Reactive actor that handles clone token operations via the EventBus.
|
|
269
|
+
* Manages an in-memory token store for resource cloning workflows.
|
|
270
|
+
*
|
|
271
|
+
* Handles:
|
|
272
|
+
* - yield:clone-token-requested — generate a clone token for a resource
|
|
273
|
+
* - yield:clone-resource-requested — look up a resource by clone token
|
|
274
|
+
* - yield:clone-create — create a new resource from a clone token
|
|
275
|
+
*
|
|
276
|
+
* From COMPLETE-EVENT-PROTOCOL.md:
|
|
277
|
+
* "Clone tokens produce new resources — that's yield."
|
|
278
|
+
*/
|
|
279
|
+
|
|
280
|
+
declare class CloneTokenManager {
|
|
281
|
+
private kb;
|
|
282
|
+
private eventBus;
|
|
283
|
+
private subscriptions;
|
|
284
|
+
private readonly logger;
|
|
285
|
+
private readonly tokens;
|
|
286
|
+
constructor(kb: KnowledgeBase, eventBus: EventBus, logger: Logger);
|
|
287
|
+
initialize(): Promise<void>;
|
|
288
|
+
private handleGenerateToken;
|
|
289
|
+
private handleGetResource;
|
|
290
|
+
private handleCreateResource;
|
|
291
|
+
stop(): Promise<void>;
|
|
292
|
+
}
|
|
293
|
+
|
|
310
294
|
/**
|
|
311
295
|
* Make-Meaning Service
|
|
312
296
|
*
|
|
@@ -320,10 +304,9 @@ declare class GraphDBConsumer {
|
|
|
320
304
|
*/
|
|
321
305
|
|
|
322
306
|
interface MakeMeaningService {
|
|
307
|
+
kb: KnowledgeBase;
|
|
323
308
|
jobQueue: JobQueue;
|
|
324
309
|
eventStore: EventStore;
|
|
325
|
-
eventBus: EventBus;
|
|
326
|
-
repStore: RepresentationStore;
|
|
327
310
|
inferenceClient: InferenceClient;
|
|
328
311
|
graphDb: GraphDatabase;
|
|
329
312
|
workers: {
|
|
@@ -335,6 +318,10 @@ interface MakeMeaningService {
|
|
|
335
318
|
tag: TagAnnotationWorker;
|
|
336
319
|
};
|
|
337
320
|
graphConsumer: GraphDBConsumer;
|
|
321
|
+
stower: Stower;
|
|
322
|
+
gatherer: Gatherer;
|
|
323
|
+
binder: Binder;
|
|
324
|
+
cloneTokenManager: CloneTokenManager;
|
|
338
325
|
stop: () => Promise<void>;
|
|
339
326
|
}
|
|
340
327
|
declare function startMakeMeaning(config: EnvironmentConfig, eventBus: EventBus, logger: Logger): Promise<MakeMeaningService>;
|
|
@@ -343,7 +330,7 @@ declare function startMakeMeaning(config: EnvironmentConfig, eventBus: EventBus,
|
|
|
343
330
|
* Entity Types Bootstrap Service
|
|
344
331
|
*
|
|
345
332
|
* On startup, checks if the entity types projection exists.
|
|
346
|
-
* If not, emits
|
|
333
|
+
* If not, emits mark:add-entity-type for each DEFAULT_ENTITY_TYPES entry.
|
|
347
334
|
* This ensures the system has entity types available immediately after first deployment.
|
|
348
335
|
*/
|
|
349
336
|
|
|
@@ -351,7 +338,7 @@ declare function startMakeMeaning(config: EnvironmentConfig, eventBus: EventBus,
|
|
|
351
338
|
* Bootstrap entity types projection if it doesn't exist.
|
|
352
339
|
* Uses a system user ID (00000000-0000-0000-0000-000000000000) for bootstrap events.
|
|
353
340
|
*/
|
|
354
|
-
declare function bootstrapEntityTypes(
|
|
341
|
+
declare function bootstrapEntityTypes(eventBus: EventBus, config: EnvironmentConfig, logger?: Logger): Promise<void>;
|
|
355
342
|
/**
|
|
356
343
|
* Reset the bootstrap flag (used for testing)
|
|
357
344
|
*/
|
|
@@ -372,14 +359,14 @@ declare function readEntityTypesProjection(config: EnvironmentConfig): Promise<s
|
|
|
372
359
|
/**
|
|
373
360
|
* Resource Operations
|
|
374
361
|
*
|
|
375
|
-
* Business logic for resource operations
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
362
|
+
* Business logic for resource operations. All writes go through the EventBus
|
|
363
|
+
* — the Stower actor subscribes and handles persistence.
|
|
364
|
+
*
|
|
365
|
+
* For create: emits yield:create, awaits yield:created / yield:create-failed.
|
|
366
|
+
* For archive/unarchive: emits mark:archive / mark:unarchive on scoped bus.
|
|
367
|
+
* For entity type updates: emits mark:update-entity-types.
|
|
380
368
|
*/
|
|
381
369
|
|
|
382
|
-
type CreateResourceResponse = components['schemas']['CreateResourceResponse'];
|
|
383
370
|
type ContentFormat = components['schemas']['ContentFormat'];
|
|
384
371
|
interface UpdateResourceInput {
|
|
385
372
|
resourceId: ResourceId;
|
|
@@ -399,40 +386,27 @@ interface CreateResourceInput {
|
|
|
399
386
|
}
|
|
400
387
|
declare class ResourceOperations {
|
|
401
388
|
/**
|
|
402
|
-
* Create a new resource
|
|
403
|
-
* Orchestrates: content storage → event emission → response building
|
|
404
|
-
*/
|
|
405
|
-
static createResource(input: CreateResourceInput, userId: UserId, eventStore: EventStore, repStore: RepresentationStore, config: EnvironmentConfig): Promise<CreateResourceResponse>;
|
|
406
|
-
/**
|
|
407
|
-
* Update resource metadata by computing diffs and emitting events
|
|
408
|
-
* Handles: archived status changes, entity type additions/removals
|
|
409
|
-
*/
|
|
410
|
-
static updateResource(input: UpdateResourceInput, eventStore: EventStore): Promise<void>;
|
|
411
|
-
/**
|
|
412
|
-
* Update archived status by emitting resource.archived or resource.unarchived event
|
|
413
|
-
*/
|
|
414
|
-
private static updateArchivedStatus;
|
|
415
|
-
/**
|
|
416
|
-
* Update entity types by computing diff and emitting events for added/removed types
|
|
389
|
+
* Create a new resource via EventBus → Stower
|
|
417
390
|
*/
|
|
418
|
-
|
|
391
|
+
static createResource(input: CreateResourceInput, userId: UserId, eventBus: EventBus): Promise<ResourceId>;
|
|
419
392
|
/**
|
|
420
|
-
*
|
|
421
|
-
* Returns arrays of added and removed entity types
|
|
393
|
+
* Update resource metadata via EventBus → Stower
|
|
422
394
|
*/
|
|
423
|
-
|
|
395
|
+
static updateResource(input: UpdateResourceInput, eventBus: EventBus): Promise<void>;
|
|
424
396
|
}
|
|
425
397
|
|
|
426
398
|
/**
|
|
427
399
|
* Annotation Operations
|
|
428
400
|
*
|
|
429
|
-
* Business logic for annotation CRUD operations
|
|
430
|
-
*
|
|
431
|
-
* - Update annotation body (operations: add/remove/replace)
|
|
432
|
-
* - Delete annotations (validation, event emission)
|
|
401
|
+
* Business logic for annotation CRUD operations. All writes go through the
|
|
402
|
+
* EventBus — the Stower actor subscribes and handles persistence.
|
|
433
403
|
*
|
|
404
|
+
* - Create: emits mark:create with full annotation + userId + resourceId
|
|
405
|
+
* - Update body: emits mark:update-body
|
|
406
|
+
* - Delete: emits mark:delete with annotationId + userId + resourceId
|
|
434
407
|
*/
|
|
435
408
|
|
|
409
|
+
type Agent = components['schemas']['Agent'];
|
|
436
410
|
type Annotation$2 = components['schemas']['Annotation'];
|
|
437
411
|
type CreateAnnotationRequest = components['schemas']['CreateAnnotationRequest'];
|
|
438
412
|
type UpdateAnnotationBodyRequest = components['schemas']['UpdateAnnotationBodyRequest'];
|
|
@@ -444,21 +418,17 @@ interface UpdateAnnotationBodyResult {
|
|
|
444
418
|
}
|
|
445
419
|
declare class AnnotationOperations {
|
|
446
420
|
/**
|
|
447
|
-
* Create a new annotation
|
|
448
|
-
*/
|
|
449
|
-
static createAnnotation(request: CreateAnnotationRequest, userId: UserId, eventStore: EventStore, config: EnvironmentConfig): Promise<CreateAnnotationResult>;
|
|
450
|
-
/**
|
|
451
|
-
* Update annotation body with operations (add/remove/replace)
|
|
421
|
+
* Create a new annotation via EventBus → Stower
|
|
452
422
|
*/
|
|
453
|
-
static
|
|
423
|
+
static createAnnotation(request: CreateAnnotationRequest, userId: UserId, creator: Agent, eventBus: EventBus, publicURL: string): Promise<CreateAnnotationResult>;
|
|
454
424
|
/**
|
|
455
|
-
*
|
|
425
|
+
* Update annotation body via EventBus → Stower
|
|
456
426
|
*/
|
|
457
|
-
static
|
|
427
|
+
static updateAnnotationBody(id: string, request: UpdateAnnotationBodyRequest, userId: UserId, eventBus: EventBus, kb: KnowledgeBase): Promise<UpdateAnnotationBodyResult>;
|
|
458
428
|
/**
|
|
459
|
-
*
|
|
429
|
+
* Delete an annotation via EventBus → Stower
|
|
460
430
|
*/
|
|
461
|
-
|
|
431
|
+
static deleteAnnotation(id: string, resourceIdUri: string, userId: UserId, eventBus: EventBus, kb: KnowledgeBase, logger?: Logger): Promise<void>;
|
|
462
432
|
}
|
|
463
433
|
|
|
464
434
|
/**
|
|
@@ -477,23 +447,23 @@ declare class ResourceContext {
|
|
|
477
447
|
/**
|
|
478
448
|
* Get resource metadata from view storage
|
|
479
449
|
*/
|
|
480
|
-
static getResourceMetadata(resourceId: ResourceId,
|
|
450
|
+
static getResourceMetadata(resourceId: ResourceId, kb: KnowledgeBase): Promise<ResourceDescriptor$1 | null>;
|
|
481
451
|
/**
|
|
482
452
|
* List all resources by scanning view storage
|
|
483
453
|
*/
|
|
484
|
-
static listResources(filters: ListResourcesFilters | undefined,
|
|
454
|
+
static listResources(filters: ListResourcesFilters | undefined, kb: KnowledgeBase): Promise<ResourceDescriptor$1[]>;
|
|
485
455
|
/**
|
|
486
456
|
* Add content previews to resources (for search results)
|
|
487
457
|
* Retrieves and decodes the first 200 characters of each resource's primary representation
|
|
488
458
|
*/
|
|
489
|
-
static addContentPreviews(resources: ResourceDescriptor$1[],
|
|
459
|
+
static addContentPreviews(resources: ResourceDescriptor$1[], kb: KnowledgeBase): Promise<Array<ResourceDescriptor$1 & {
|
|
490
460
|
content: string;
|
|
491
461
|
}>>;
|
|
492
462
|
/**
|
|
493
463
|
* Get full content for a resource
|
|
494
464
|
* Retrieves and decodes the primary representation
|
|
495
465
|
*/
|
|
496
|
-
static getResourceContent(resource: ResourceDescriptor$1,
|
|
466
|
+
static getResourceContent(resource: ResourceDescriptor$1, kb: KnowledgeBase): Promise<string | undefined>;
|
|
497
467
|
}
|
|
498
468
|
|
|
499
469
|
/**
|
|
@@ -505,9 +475,6 @@ declare class ResourceContext {
|
|
|
505
475
|
* - Building LLM context for annotations
|
|
506
476
|
* - Extracting annotation text context
|
|
507
477
|
* - Generating AI summaries
|
|
508
|
-
*
|
|
509
|
-
* NOTE: This class contains static utility methods without logger access.
|
|
510
|
-
* Console statements kept for debugging - consider adding logger parameter in future.
|
|
511
478
|
*/
|
|
512
479
|
|
|
513
480
|
type AnnotationLLMContextResponse = components['schemas']['AnnotationLLMContextResponse'];
|
|
@@ -525,22 +492,23 @@ declare class AnnotationContext {
|
|
|
525
492
|
*
|
|
526
493
|
* @param annotationUri - Full annotation URI (e.g., http://localhost:4000/annotations/abc123)
|
|
527
494
|
* @param resourceId - Source resource ID
|
|
528
|
-
* @param
|
|
495
|
+
* @param kb - Knowledge base stores
|
|
529
496
|
* @param options - Context building options
|
|
497
|
+
* @param inferenceClient - Optional inference client for target context summary
|
|
530
498
|
* @returns Rich context for LLM processing
|
|
531
499
|
* @throws Error if annotation or resource not found
|
|
532
500
|
*/
|
|
533
|
-
static buildLLMContext(annotationUri: AnnotationUri, resourceId: ResourceId,
|
|
501
|
+
static buildLLMContext(annotationUri: AnnotationUri, resourceId: ResourceId, kb: KnowledgeBase, options?: BuildContextOptions, inferenceClient?: InferenceClient, logger?: Logger): Promise<AnnotationLLMContextResponse>;
|
|
534
502
|
/**
|
|
535
503
|
* Get resource annotations from view storage (fast path)
|
|
536
504
|
* Throws if view missing
|
|
537
505
|
*/
|
|
538
|
-
static getResourceAnnotations(resourceId: ResourceId,
|
|
506
|
+
static getResourceAnnotations(resourceId: ResourceId, kb: KnowledgeBase): Promise<ResourceAnnotations>;
|
|
539
507
|
/**
|
|
540
508
|
* Get all annotations
|
|
541
509
|
* @returns Array of all annotation objects
|
|
542
510
|
*/
|
|
543
|
-
static getAllAnnotations(resourceId: ResourceId,
|
|
511
|
+
static getAllAnnotations(resourceId: ResourceId, kb: KnowledgeBase): Promise<Annotation$1[]>;
|
|
544
512
|
/**
|
|
545
513
|
* Enrich reference annotations with resolved document names
|
|
546
514
|
* Adds _resolvedDocumentName property to annotations that link to documents
|
|
@@ -551,7 +519,7 @@ declare class AnnotationContext {
|
|
|
551
519
|
* Get resource stats (version info)
|
|
552
520
|
* @returns Version and timestamp info for the annotations
|
|
553
521
|
*/
|
|
554
|
-
static getResourceStats(resourceId: ResourceId,
|
|
522
|
+
static getResourceStats(resourceId: ResourceId, kb: KnowledgeBase): Promise<{
|
|
555
523
|
resourceId: ResourceId;
|
|
556
524
|
version: number;
|
|
557
525
|
updatedAt: string;
|
|
@@ -559,12 +527,12 @@ declare class AnnotationContext {
|
|
|
559
527
|
/**
|
|
560
528
|
* Check if resource exists in view storage
|
|
561
529
|
*/
|
|
562
|
-
static resourceExists(resourceId: ResourceId,
|
|
530
|
+
static resourceExists(resourceId: ResourceId, kb: KnowledgeBase): Promise<boolean>;
|
|
563
531
|
/**
|
|
564
532
|
* Get a single annotation by ID
|
|
565
533
|
* O(1) lookup using resource ID to access view storage
|
|
566
534
|
*/
|
|
567
|
-
static getAnnotation(annotationId: AnnotationId, resourceId: ResourceId,
|
|
535
|
+
static getAnnotation(annotationId: AnnotationId, resourceId: ResourceId, kb: KnowledgeBase): Promise<Annotation$1 | null>;
|
|
568
536
|
/**
|
|
569
537
|
* List annotations with optional filtering
|
|
570
538
|
* @param filters - Optional filters like resourceId and type
|
|
@@ -573,15 +541,15 @@ declare class AnnotationContext {
|
|
|
573
541
|
static listAnnotations(filters: {
|
|
574
542
|
resourceId?: ResourceId;
|
|
575
543
|
type?: AnnotationCategory;
|
|
576
|
-
} | undefined,
|
|
544
|
+
} | undefined, kb: KnowledgeBase): Promise<Annotation$1[]>;
|
|
577
545
|
/**
|
|
578
546
|
* Get annotation context (selected text with surrounding context)
|
|
579
547
|
*/
|
|
580
|
-
static getAnnotationContext(annotationId: AnnotationId, resourceId: ResourceId, contextBefore: number, contextAfter: number,
|
|
548
|
+
static getAnnotationContext(annotationId: AnnotationId, resourceId: ResourceId, contextBefore: number, contextAfter: number, kb: KnowledgeBase): Promise<AnnotationContextResponse>;
|
|
581
549
|
/**
|
|
582
550
|
* Generate AI summary of annotation in context
|
|
583
551
|
*/
|
|
584
|
-
static generateAnnotationSummary(annotationId: AnnotationId, resourceId: ResourceId,
|
|
552
|
+
static generateAnnotationSummary(annotationId: AnnotationId, resourceId: ResourceId, kb: KnowledgeBase, inferenceClient: InferenceClient): Promise<ContextualSummaryResponse>;
|
|
585
553
|
/**
|
|
586
554
|
* Get resource content as string
|
|
587
555
|
*/
|
|
@@ -629,27 +597,27 @@ declare class GraphContext {
|
|
|
629
597
|
* Get all resources referencing this resource (backlinks)
|
|
630
598
|
* Requires graph traversal - must use graph database
|
|
631
599
|
*/
|
|
632
|
-
static getBacklinks(resourceId: ResourceId,
|
|
600
|
+
static getBacklinks(resourceId: ResourceId, kb: KnowledgeBase, publicURL: string): Promise<Annotation[]>;
|
|
633
601
|
/**
|
|
634
602
|
* Find shortest path between two resources
|
|
635
603
|
* Requires graph traversal - must use graph database
|
|
636
604
|
*/
|
|
637
|
-
static findPath(fromResourceId: ResourceId, toResourceId: ResourceId,
|
|
605
|
+
static findPath(fromResourceId: ResourceId, toResourceId: ResourceId, kb: KnowledgeBase, maxDepth?: number): Promise<GraphPath[]>;
|
|
638
606
|
/**
|
|
639
607
|
* Get resource connections (graph edges)
|
|
640
608
|
* Requires graph traversal - must use graph database
|
|
641
609
|
*/
|
|
642
|
-
static getResourceConnections(resourceId: ResourceId,
|
|
610
|
+
static getResourceConnections(resourceId: ResourceId, kb: KnowledgeBase): Promise<GraphConnection[]>;
|
|
643
611
|
/**
|
|
644
612
|
* Search resources by name (cross-resource query)
|
|
645
613
|
* Requires full-text search - must use graph database
|
|
646
614
|
*/
|
|
647
|
-
static searchResources(query: string,
|
|
615
|
+
static searchResources(query: string, kb: KnowledgeBase, limit?: number): Promise<ResourceDescriptor[]>;
|
|
648
616
|
/**
|
|
649
617
|
* Build graph representation with nodes and edges for a resource and its connections
|
|
650
618
|
* Retrieves connections from graph and builds visualization-ready structure
|
|
651
619
|
*/
|
|
652
|
-
static buildGraphRepresentation(resourceId: ResourceId, maxRelated: number,
|
|
620
|
+
static buildGraphRepresentation(resourceId: ResourceId, maxRelated: number, kb: KnowledgeBase, publicURL: string): Promise<GraphRepresentation>;
|
|
653
621
|
}
|
|
654
622
|
|
|
655
623
|
/**
|
|
@@ -671,256 +639,9 @@ declare class LLMContext {
|
|
|
671
639
|
* Get comprehensive LLM context for a resource
|
|
672
640
|
* Includes: main resource, related resources, annotations, graph, content, summary, references
|
|
673
641
|
*/
|
|
674
|
-
static getResourceContext(resourceId: ResourceId, options: LLMContextOptions,
|
|
642
|
+
static getResourceContext(resourceId: ResourceId, options: LLMContextOptions, kb: KnowledgeBase, publicURL: string, inferenceClient: InferenceClient): Promise<ResourceLLMContextResponse>;
|
|
675
643
|
}
|
|
676
644
|
|
|
677
|
-
/**
|
|
678
|
-
* Response parsers for annotation detection motivations
|
|
679
|
-
*
|
|
680
|
-
* Provides static methods to parse and validate AI responses for each motivation type.
|
|
681
|
-
* Includes offset validation and correction logic.
|
|
682
|
-
* Extracted from worker implementations to centralize parsing logic.
|
|
683
|
-
*
|
|
684
|
-
* NOTE: These are static utility methods without logger access.
|
|
685
|
-
* Console statements kept for debugging - consider adding logger parameter in future.
|
|
686
|
-
*/
|
|
687
|
-
/**
|
|
688
|
-
* Represents a detected comment with validated position
|
|
689
|
-
*/
|
|
690
|
-
interface CommentMatch {
|
|
691
|
-
exact: string;
|
|
692
|
-
start: number;
|
|
693
|
-
end: number;
|
|
694
|
-
prefix?: string;
|
|
695
|
-
suffix?: string;
|
|
696
|
-
comment: string;
|
|
697
|
-
}
|
|
698
|
-
/**
|
|
699
|
-
* Represents a detected highlight with validated position
|
|
700
|
-
*/
|
|
701
|
-
interface HighlightMatch {
|
|
702
|
-
exact: string;
|
|
703
|
-
start: number;
|
|
704
|
-
end: number;
|
|
705
|
-
prefix?: string;
|
|
706
|
-
suffix?: string;
|
|
707
|
-
}
|
|
708
|
-
/**
|
|
709
|
-
* Represents a detected assessment with validated position
|
|
710
|
-
*/
|
|
711
|
-
interface AssessmentMatch {
|
|
712
|
-
exact: string;
|
|
713
|
-
start: number;
|
|
714
|
-
end: number;
|
|
715
|
-
prefix?: string;
|
|
716
|
-
suffix?: string;
|
|
717
|
-
assessment: string;
|
|
718
|
-
}
|
|
719
|
-
/**
|
|
720
|
-
* Represents a detected tag with validated position
|
|
721
|
-
*/
|
|
722
|
-
interface TagMatch {
|
|
723
|
-
exact: string;
|
|
724
|
-
start: number;
|
|
725
|
-
end: number;
|
|
726
|
-
prefix?: string;
|
|
727
|
-
suffix?: string;
|
|
728
|
-
category: string;
|
|
729
|
-
}
|
|
730
|
-
declare class MotivationParsers {
|
|
731
|
-
/**
|
|
732
|
-
* Parse and validate AI response for comment detection
|
|
733
|
-
*
|
|
734
|
-
* @param response - Raw AI response string (may include markdown code fences)
|
|
735
|
-
* @param content - Original content to validate offsets against
|
|
736
|
-
* @returns Array of validated comment matches
|
|
737
|
-
*/
|
|
738
|
-
static parseComments(response: string, content: string): CommentMatch[];
|
|
739
|
-
/**
|
|
740
|
-
* Parse and validate AI response for highlight detection
|
|
741
|
-
*
|
|
742
|
-
* @param response - Raw AI response string (may include markdown code fences)
|
|
743
|
-
* @param content - Original content to validate offsets against
|
|
744
|
-
* @returns Array of validated highlight matches
|
|
745
|
-
*/
|
|
746
|
-
static parseHighlights(response: string, content: string): HighlightMatch[];
|
|
747
|
-
/**
|
|
748
|
-
* Parse and validate AI response for assessment detection
|
|
749
|
-
*
|
|
750
|
-
* @param response - Raw AI response string (may include markdown code fences)
|
|
751
|
-
* @param content - Original content to validate offsets against
|
|
752
|
-
* @returns Array of validated assessment matches
|
|
753
|
-
*/
|
|
754
|
-
static parseAssessments(response: string, content: string): AssessmentMatch[];
|
|
755
|
-
/**
|
|
756
|
-
* Parse and validate AI response for tag detection
|
|
757
|
-
* Note: Does NOT validate offsets - caller must do that with content
|
|
758
|
-
*
|
|
759
|
-
* @param response - Raw AI response string (may include markdown code fences)
|
|
760
|
-
* @returns Array of tag matches (offsets not yet validated)
|
|
761
|
-
*/
|
|
762
|
-
static parseTags(response: string): Omit<TagMatch, 'category'>[];
|
|
763
|
-
/**
|
|
764
|
-
* Validate tag offsets against content and add category
|
|
765
|
-
* Helper for tag detection after initial parsing
|
|
766
|
-
*
|
|
767
|
-
* @param tags - Parsed tags without validated offsets
|
|
768
|
-
* @param content - Original content to validate against
|
|
769
|
-
* @param category - Category to assign to validated tags
|
|
770
|
-
* @returns Array of validated tag matches
|
|
771
|
-
*/
|
|
772
|
-
static validateTagOffsets(tags: Omit<TagMatch, 'category'>[], content: string, category: string): TagMatch[];
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
/**
|
|
776
|
-
* Annotation Detection
|
|
777
|
-
*
|
|
778
|
-
* Orchestrates the full annotation detection pipeline:
|
|
779
|
-
* 1. Fetch resource metadata and content
|
|
780
|
-
* 2. Build AI prompts using MotivationPrompts
|
|
781
|
-
* 3. Call AI inference
|
|
782
|
-
* 4. Parse and validate results using MotivationParsers
|
|
783
|
-
*
|
|
784
|
-
* This is the high-level API for AI-powered annotation detection.
|
|
785
|
-
* Workers and other consumers should use these methods instead of
|
|
786
|
-
* implementing detection logic directly.
|
|
787
|
-
*/
|
|
788
|
-
|
|
789
|
-
declare class AnnotationDetection {
|
|
790
|
-
/**
|
|
791
|
-
* Detect comments in a resource
|
|
792
|
-
*
|
|
793
|
-
* @param resourceId - The resource to analyze
|
|
794
|
-
* @param config - Environment configuration
|
|
795
|
-
* @param client - Inference client for AI operations
|
|
796
|
-
* @param instructions - Optional user instructions for comment generation
|
|
797
|
-
* @param tone - Optional tone guidance (e.g., "academic", "conversational")
|
|
798
|
-
* @param density - Optional target number of comments per 2000 words
|
|
799
|
-
* @returns Array of validated comment matches
|
|
800
|
-
*/
|
|
801
|
-
static detectComments(resourceId: ResourceId, config: EnvironmentConfig, client: InferenceClient, instructions?: string, tone?: string, density?: number): Promise<CommentMatch[]>;
|
|
802
|
-
/**
|
|
803
|
-
* Detect highlights in a resource
|
|
804
|
-
*
|
|
805
|
-
* @param resourceId - The resource to analyze
|
|
806
|
-
* @param config - Environment configuration
|
|
807
|
-
* @param client - Inference client for AI operations
|
|
808
|
-
* @param instructions - Optional user instructions for highlight selection
|
|
809
|
-
* @param density - Optional target number of highlights per 2000 words
|
|
810
|
-
* @returns Array of validated highlight matches
|
|
811
|
-
*/
|
|
812
|
-
static detectHighlights(resourceId: ResourceId, config: EnvironmentConfig, client: InferenceClient, instructions?: string, density?: number): Promise<HighlightMatch[]>;
|
|
813
|
-
/**
|
|
814
|
-
* Detect assessments in a resource
|
|
815
|
-
*
|
|
816
|
-
* @param resourceId - The resource to analyze
|
|
817
|
-
* @param config - Environment configuration
|
|
818
|
-
* @param client - Inference client for AI operations
|
|
819
|
-
* @param instructions - Optional user instructions for assessment generation
|
|
820
|
-
* @param tone - Optional tone guidance (e.g., "critical", "supportive")
|
|
821
|
-
* @param density - Optional target number of assessments per 2000 words
|
|
822
|
-
* @returns Array of validated assessment matches
|
|
823
|
-
*/
|
|
824
|
-
static detectAssessments(resourceId: ResourceId, config: EnvironmentConfig, client: InferenceClient, instructions?: string, tone?: string, density?: number): Promise<AssessmentMatch[]>;
|
|
825
|
-
/**
|
|
826
|
-
* Detect tags in a resource for a specific category
|
|
827
|
-
*
|
|
828
|
-
* @param resourceId - The resource to analyze
|
|
829
|
-
* @param config - Environment configuration
|
|
830
|
-
* @param client - Inference client for AI operations
|
|
831
|
-
* @param schemaId - The tag schema identifier (e.g., "irac", "imrad")
|
|
832
|
-
* @param category - The specific category to detect
|
|
833
|
-
* @returns Array of validated tag matches
|
|
834
|
-
*/
|
|
835
|
-
static detectTags(resourceId: ResourceId, config: EnvironmentConfig, client: InferenceClient, schemaId: string, category: string): Promise<TagMatch[]>;
|
|
836
|
-
/**
|
|
837
|
-
* Load resource content from representation store
|
|
838
|
-
* Helper method used by all detection methods
|
|
839
|
-
*
|
|
840
|
-
* @param resourceId - The resource ID to load
|
|
841
|
-
* @param config - Environment configuration
|
|
842
|
-
* @returns Resource content as string, or null if not available
|
|
843
|
-
*/
|
|
844
|
-
private static loadResourceContent;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
/**
|
|
848
|
-
* Prompt builders for annotation detection motivations
|
|
849
|
-
*
|
|
850
|
-
* Provides static methods to build AI prompts for each Web Annotation motivation type.
|
|
851
|
-
* Extracted from worker implementations to centralize prompt logic.
|
|
852
|
-
*/
|
|
853
|
-
declare class MotivationPrompts {
|
|
854
|
-
/**
|
|
855
|
-
* Build a prompt for detecting comment-worthy passages
|
|
856
|
-
*
|
|
857
|
-
* @param content - The text content to analyze (will be truncated to 8000 chars)
|
|
858
|
-
* @param instructions - Optional user-provided instructions
|
|
859
|
-
* @param tone - Optional tone guidance (e.g., "academic", "conversational")
|
|
860
|
-
* @param density - Optional target number of comments per 2000 words
|
|
861
|
-
* @returns Formatted prompt string
|
|
862
|
-
*/
|
|
863
|
-
static buildCommentPrompt(content: string, instructions?: string, tone?: string, density?: number): string;
|
|
864
|
-
/**
|
|
865
|
-
* Build a prompt for detecting highlight-worthy passages
|
|
866
|
-
*
|
|
867
|
-
* @param content - The text content to analyze (will be truncated to 8000 chars)
|
|
868
|
-
* @param instructions - Optional user-provided instructions
|
|
869
|
-
* @param density - Optional target number of highlights per 2000 words
|
|
870
|
-
* @returns Formatted prompt string
|
|
871
|
-
*/
|
|
872
|
-
static buildHighlightPrompt(content: string, instructions?: string, density?: number): string;
|
|
873
|
-
/**
|
|
874
|
-
* Build a prompt for detecting assessment-worthy passages
|
|
875
|
-
*
|
|
876
|
-
* @param content - The text content to analyze (will be truncated to 8000 chars)
|
|
877
|
-
* @param instructions - Optional user-provided instructions
|
|
878
|
-
* @param tone - Optional tone guidance (e.g., "critical", "supportive")
|
|
879
|
-
* @param density - Optional target number of assessments per 2000 words
|
|
880
|
-
* @returns Formatted prompt string
|
|
881
|
-
*/
|
|
882
|
-
static buildAssessmentPrompt(content: string, instructions?: string, tone?: string, density?: number): string;
|
|
883
|
-
/**
|
|
884
|
-
* Build a prompt for detecting structural tags
|
|
885
|
-
*
|
|
886
|
-
* @param content - The full text content to analyze (NOT truncated for structural analysis)
|
|
887
|
-
* @param category - The specific category to detect
|
|
888
|
-
* @param schemaName - Human-readable schema name
|
|
889
|
-
* @param schemaDescription - Schema description
|
|
890
|
-
* @param schemaDomain - Schema domain
|
|
891
|
-
* @param categoryDescription - Category description
|
|
892
|
-
* @param categoryExamples - Example questions/guidance for this category
|
|
893
|
-
* @returns Formatted prompt string
|
|
894
|
-
*/
|
|
895
|
-
static buildTagPrompt(content: string, category: string, schemaName: string, schemaDescription: string, schemaDomain: string, categoryDescription: string, categoryExamples: string[]): string;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
/**
|
|
899
|
-
* Entity reference extracted from text
|
|
900
|
-
*/
|
|
901
|
-
interface ExtractedEntity {
|
|
902
|
-
exact: string;
|
|
903
|
-
entityType: string;
|
|
904
|
-
startOffset: number;
|
|
905
|
-
endOffset: number;
|
|
906
|
-
prefix?: string;
|
|
907
|
-
suffix?: string;
|
|
908
|
-
}
|
|
909
|
-
/**
|
|
910
|
-
* Extract entity references from text using AI
|
|
911
|
-
*
|
|
912
|
-
* @param text - The text to analyze
|
|
913
|
-
* @param entityTypes - Array of entity types to detect (optionally with examples)
|
|
914
|
-
* @param client - Inference client for AI operations
|
|
915
|
-
* @param includeDescriptiveReferences - Include anaphoric/cataphoric references (default: false)
|
|
916
|
-
* @param logger - Optional logger for debugging entity extraction
|
|
917
|
-
* @returns Array of extracted entities with their character offsets
|
|
918
|
-
*/
|
|
919
|
-
declare function extractEntities(exact: string, entityTypes: string[] | {
|
|
920
|
-
type: string;
|
|
921
|
-
examples?: string[];
|
|
922
|
-
}[], client: InferenceClient, includeDescriptiveReferences?: boolean, logger?: Logger): Promise<ExtractedEntity[]>;
|
|
923
|
-
|
|
924
645
|
/**
|
|
925
646
|
* Resource Generation Functions
|
|
926
647
|
*
|
|
@@ -932,13 +653,6 @@ declare function extractEntities(exact: string, entityTypes: string[] | {
|
|
|
932
653
|
*
|
|
933
654
|
*/
|
|
934
655
|
|
|
935
|
-
/**
|
|
936
|
-
* Generate resource content using inference
|
|
937
|
-
*/
|
|
938
|
-
declare function generateResourceFromTopic(topic: string, entityTypes: string[], client: InferenceClient, userPrompt?: string, locale?: string, context?: YieldContext, temperature?: number, maxTokens?: number, logger?: Logger): Promise<{
|
|
939
|
-
title: string;
|
|
940
|
-
content: string;
|
|
941
|
-
}>;
|
|
942
656
|
/**
|
|
943
657
|
* Generate an intelligent summary for a resource
|
|
944
658
|
*/
|
|
@@ -948,15 +662,7 @@ declare function generateResourceSummary(resourceName: string, content: string,
|
|
|
948
662
|
*/
|
|
949
663
|
declare function generateReferenceSuggestions(referenceTitle: string, client: InferenceClient, entityType?: string, currentContent?: string): Promise<string[] | null>;
|
|
950
664
|
|
|
951
|
-
/**
|
|
952
|
-
* ID generation utilities
|
|
953
|
-
*/
|
|
954
|
-
/**
|
|
955
|
-
* Generate a UUID v4-like ID (without dashes)
|
|
956
|
-
*/
|
|
957
|
-
declare function generateUuid(): string;
|
|
958
|
-
|
|
959
665
|
declare const PACKAGE_NAME = "@semiont/make-meaning";
|
|
960
666
|
declare const VERSION = "0.1.0";
|
|
961
667
|
|
|
962
|
-
export { AnnotationContext,
|
|
668
|
+
export { AnnotationContext, AnnotationOperations, Binder, type BuildContextOptions, CloneTokenManager, type CreateAnnotationResult, type CreateResourceInput, type CreateResourceResult, Gatherer, GraphContext, GraphDBConsumer, type GraphEdge, type GraphNode, type GraphRepresentation, type KnowledgeBase, LLMContext, type LLMContextOptions, type ListResourcesFilters, type MakeMeaningService, PACKAGE_NAME, ResourceContext, ResourceOperations, Stower, type UpdateAnnotationBodyResult, type UpdateResourceInput, VERSION, bootstrapEntityTypes, createKnowledgeBase, generateReferenceSuggestions, generateResourceSummary, readEntityTypesProjection, resetBootstrap, startMakeMeaning };
|