@semiont/make-meaning 0.1.0
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 +742 -0
- package/dist/index.d.ts +236 -0
- package/dist/index.js +715 -0
- package/dist/index.js.map +1 -0
- package/package.json +53 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { components, AnnotationUri } from '@semiont/api-client';
|
|
2
|
+
import { ResourceId, EnvironmentConfig, ResourceAnnotations, AnnotationId, AnnotationCategory, GraphPath, GraphConnection } from '@semiont/core';
|
|
3
|
+
import { CommentMatch, HighlightMatch, AssessmentMatch, TagMatch } from '@semiont/inference';
|
|
4
|
+
export { AssessmentMatch, CommentMatch, HighlightMatch, TagMatch } from '@semiont/inference';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Resource Context
|
|
8
|
+
*
|
|
9
|
+
* Assembles resource context from view storage and content store
|
|
10
|
+
* Does NOT touch the graph - graph queries go through GraphContext
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
type ResourceDescriptor$1 = components['schemas']['ResourceDescriptor'];
|
|
14
|
+
interface ListResourcesFilters {
|
|
15
|
+
search?: string;
|
|
16
|
+
archived?: boolean;
|
|
17
|
+
}
|
|
18
|
+
declare class ResourceContext {
|
|
19
|
+
/**
|
|
20
|
+
* Get resource metadata from view storage
|
|
21
|
+
*/
|
|
22
|
+
static getResourceMetadata(resourceId: ResourceId, config: EnvironmentConfig): Promise<ResourceDescriptor$1 | null>;
|
|
23
|
+
/**
|
|
24
|
+
* List all resources by scanning view storage
|
|
25
|
+
*/
|
|
26
|
+
static listResources(filters: ListResourcesFilters | undefined, config: EnvironmentConfig): Promise<ResourceDescriptor$1[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Add content previews to resources (for search results)
|
|
29
|
+
* Retrieves and decodes the first 200 characters of each resource's primary representation
|
|
30
|
+
*/
|
|
31
|
+
static addContentPreviews(resources: ResourceDescriptor$1[], config: EnvironmentConfig): Promise<Array<ResourceDescriptor$1 & {
|
|
32
|
+
content: string;
|
|
33
|
+
}>>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Annotation Context
|
|
38
|
+
*
|
|
39
|
+
* Assembles annotation context from view storage and content store.
|
|
40
|
+
* Provides methods for:
|
|
41
|
+
* - Getting resource annotations
|
|
42
|
+
* - Building LLM context for annotations
|
|
43
|
+
* - Extracting annotation text context
|
|
44
|
+
* - Generating AI summaries
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
type AnnotationLLMContextResponse = components['schemas']['AnnotationLLMContextResponse'];
|
|
48
|
+
type Annotation$1 = components['schemas']['Annotation'];
|
|
49
|
+
type AnnotationContextResponse = components['schemas']['AnnotationContextResponse'];
|
|
50
|
+
type ContextualSummaryResponse = components['schemas']['ContextualSummaryResponse'];
|
|
51
|
+
interface BuildContextOptions {
|
|
52
|
+
includeSourceContext?: boolean;
|
|
53
|
+
includeTargetContext?: boolean;
|
|
54
|
+
contextWindow?: number;
|
|
55
|
+
}
|
|
56
|
+
declare class AnnotationContext {
|
|
57
|
+
/**
|
|
58
|
+
* Build LLM context for an annotation
|
|
59
|
+
*
|
|
60
|
+
* @param annotationUri - Full annotation URI (e.g., http://localhost:4000/annotations/abc123)
|
|
61
|
+
* @param resourceId - Source resource ID
|
|
62
|
+
* @param config - Application configuration
|
|
63
|
+
* @param options - Context building options
|
|
64
|
+
* @returns Rich context for LLM processing
|
|
65
|
+
* @throws Error if annotation or resource not found
|
|
66
|
+
*/
|
|
67
|
+
static buildLLMContext(annotationUri: AnnotationUri, resourceId: ResourceId, config: EnvironmentConfig, options?: BuildContextOptions): Promise<AnnotationLLMContextResponse>;
|
|
68
|
+
/**
|
|
69
|
+
* Get resource annotations from view storage (fast path)
|
|
70
|
+
* Throws if view missing
|
|
71
|
+
*/
|
|
72
|
+
static getResourceAnnotations(resourceId: ResourceId, config: EnvironmentConfig): Promise<ResourceAnnotations>;
|
|
73
|
+
/**
|
|
74
|
+
* Get all annotations
|
|
75
|
+
* @returns Array of all annotation objects
|
|
76
|
+
*/
|
|
77
|
+
static getAllAnnotations(resourceId: ResourceId, config: EnvironmentConfig): Promise<Annotation$1[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Enrich reference annotations with resolved document names
|
|
80
|
+
* Adds _resolvedDocumentName property to annotations that link to documents
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
private static enrichResolvedReferences;
|
|
84
|
+
/**
|
|
85
|
+
* Get resource stats (version info)
|
|
86
|
+
* @returns Version and timestamp info for the annotations
|
|
87
|
+
*/
|
|
88
|
+
static getResourceStats(resourceId: ResourceId, config: EnvironmentConfig): Promise<{
|
|
89
|
+
resourceId: ResourceId;
|
|
90
|
+
version: number;
|
|
91
|
+
updatedAt: string;
|
|
92
|
+
}>;
|
|
93
|
+
/**
|
|
94
|
+
* Check if resource exists in view storage
|
|
95
|
+
*/
|
|
96
|
+
static resourceExists(resourceId: ResourceId, config: EnvironmentConfig): Promise<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* Get a single annotation by ID
|
|
99
|
+
* O(1) lookup using resource ID to access view storage
|
|
100
|
+
*/
|
|
101
|
+
static getAnnotation(annotationId: AnnotationId, resourceId: ResourceId, config: EnvironmentConfig): Promise<Annotation$1 | null>;
|
|
102
|
+
/**
|
|
103
|
+
* List annotations with optional filtering
|
|
104
|
+
* @param filters - Optional filters like resourceId and type
|
|
105
|
+
* @throws Error if resourceId not provided (cross-resource queries not supported in view storage)
|
|
106
|
+
*/
|
|
107
|
+
static listAnnotations(filters: {
|
|
108
|
+
resourceId?: ResourceId;
|
|
109
|
+
type?: AnnotationCategory;
|
|
110
|
+
} | undefined, config: EnvironmentConfig): Promise<Annotation$1[]>;
|
|
111
|
+
/**
|
|
112
|
+
* Get annotation context (selected text with surrounding context)
|
|
113
|
+
*/
|
|
114
|
+
static getAnnotationContext(annotationId: AnnotationId, resourceId: ResourceId, contextBefore: number, contextAfter: number, config: EnvironmentConfig): Promise<AnnotationContextResponse>;
|
|
115
|
+
/**
|
|
116
|
+
* Generate AI summary of annotation in context
|
|
117
|
+
*/
|
|
118
|
+
static generateAnnotationSummary(annotationId: AnnotationId, resourceId: ResourceId, config: EnvironmentConfig): Promise<ContextualSummaryResponse>;
|
|
119
|
+
/**
|
|
120
|
+
* Get resource content as string
|
|
121
|
+
*/
|
|
122
|
+
private static getResourceContent;
|
|
123
|
+
/**
|
|
124
|
+
* Extract annotation context from resource content
|
|
125
|
+
*/
|
|
126
|
+
private static extractAnnotationContext;
|
|
127
|
+
/**
|
|
128
|
+
* Generate LLM summary of annotation in context
|
|
129
|
+
*/
|
|
130
|
+
private static generateSummary;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Graph Context
|
|
135
|
+
*
|
|
136
|
+
* Provides graph database operations for resources and annotations.
|
|
137
|
+
* All methods require graph traversal - must use graph database.
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
type Annotation = components['schemas']['Annotation'];
|
|
141
|
+
type ResourceDescriptor = components['schemas']['ResourceDescriptor'];
|
|
142
|
+
declare class GraphContext {
|
|
143
|
+
/**
|
|
144
|
+
* Get all resources referencing this resource (backlinks)
|
|
145
|
+
* Requires graph traversal - must use graph database
|
|
146
|
+
*/
|
|
147
|
+
static getBacklinks(resourceId: ResourceId, config: EnvironmentConfig): Promise<Annotation[]>;
|
|
148
|
+
/**
|
|
149
|
+
* Find shortest path between two resources
|
|
150
|
+
* Requires graph traversal - must use graph database
|
|
151
|
+
*/
|
|
152
|
+
static findPath(fromResourceId: ResourceId, toResourceId: ResourceId, config: EnvironmentConfig, maxDepth?: number): Promise<GraphPath[]>;
|
|
153
|
+
/**
|
|
154
|
+
* Get resource connections (graph edges)
|
|
155
|
+
* Requires graph traversal - must use graph database
|
|
156
|
+
*/
|
|
157
|
+
static getResourceConnections(resourceId: ResourceId, config: EnvironmentConfig): Promise<GraphConnection[]>;
|
|
158
|
+
/**
|
|
159
|
+
* Search resources by name (cross-resource query)
|
|
160
|
+
* Requires full-text search - must use graph database
|
|
161
|
+
*/
|
|
162
|
+
static searchResources(query: string, config: EnvironmentConfig, limit?: number): Promise<ResourceDescriptor[]>;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Annotation Detection
|
|
167
|
+
*
|
|
168
|
+
* Orchestrates the full annotation detection pipeline:
|
|
169
|
+
* 1. Fetch resource metadata and content
|
|
170
|
+
* 2. Build AI prompts using MotivationPrompts
|
|
171
|
+
* 3. Call AI inference
|
|
172
|
+
* 4. Parse and validate results using MotivationParsers
|
|
173
|
+
*
|
|
174
|
+
* This is the high-level API for AI-powered annotation detection.
|
|
175
|
+
* Workers and other consumers should use these methods instead of
|
|
176
|
+
* implementing detection logic directly.
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
declare class AnnotationDetection {
|
|
180
|
+
/**
|
|
181
|
+
* Detect comments in a resource
|
|
182
|
+
*
|
|
183
|
+
* @param resourceId - The resource to analyze
|
|
184
|
+
* @param config - Environment configuration
|
|
185
|
+
* @param instructions - Optional user instructions for comment generation
|
|
186
|
+
* @param tone - Optional tone guidance (e.g., "academic", "conversational")
|
|
187
|
+
* @param density - Optional target number of comments per 2000 words
|
|
188
|
+
* @returns Array of validated comment matches
|
|
189
|
+
*/
|
|
190
|
+
static detectComments(resourceId: ResourceId, config: EnvironmentConfig, instructions?: string, tone?: string, density?: number): Promise<CommentMatch[]>;
|
|
191
|
+
/**
|
|
192
|
+
* Detect highlights in a resource
|
|
193
|
+
*
|
|
194
|
+
* @param resourceId - The resource to analyze
|
|
195
|
+
* @param config - Environment configuration
|
|
196
|
+
* @param instructions - Optional user instructions for highlight selection
|
|
197
|
+
* @param density - Optional target number of highlights per 2000 words
|
|
198
|
+
* @returns Array of validated highlight matches
|
|
199
|
+
*/
|
|
200
|
+
static detectHighlights(resourceId: ResourceId, config: EnvironmentConfig, instructions?: string, density?: number): Promise<HighlightMatch[]>;
|
|
201
|
+
/**
|
|
202
|
+
* Detect assessments in a resource
|
|
203
|
+
*
|
|
204
|
+
* @param resourceId - The resource to analyze
|
|
205
|
+
* @param config - Environment configuration
|
|
206
|
+
* @param instructions - Optional user instructions for assessment generation
|
|
207
|
+
* @param tone - Optional tone guidance (e.g., "critical", "supportive")
|
|
208
|
+
* @param density - Optional target number of assessments per 2000 words
|
|
209
|
+
* @returns Array of validated assessment matches
|
|
210
|
+
*/
|
|
211
|
+
static detectAssessments(resourceId: ResourceId, config: EnvironmentConfig, instructions?: string, tone?: string, density?: number): Promise<AssessmentMatch[]>;
|
|
212
|
+
/**
|
|
213
|
+
* Detect tags in a resource for a specific category
|
|
214
|
+
*
|
|
215
|
+
* @param resourceId - The resource to analyze
|
|
216
|
+
* @param config - Environment configuration
|
|
217
|
+
* @param schemaId - The tag schema identifier (e.g., "irac", "imrad")
|
|
218
|
+
* @param category - The specific category to detect
|
|
219
|
+
* @returns Array of validated tag matches
|
|
220
|
+
*/
|
|
221
|
+
static detectTags(resourceId: ResourceId, config: EnvironmentConfig, schemaId: string, category: string): Promise<TagMatch[]>;
|
|
222
|
+
/**
|
|
223
|
+
* Load resource content from representation store
|
|
224
|
+
* Helper method used by all detection methods
|
|
225
|
+
*
|
|
226
|
+
* @param resourceId - The resource ID to load
|
|
227
|
+
* @param config - Environment configuration
|
|
228
|
+
* @returns Resource content as string, or null if not available
|
|
229
|
+
*/
|
|
230
|
+
private static loadResourceContent;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
declare const PACKAGE_NAME = "@semiont/make-meaning";
|
|
234
|
+
declare const VERSION = "0.1.0";
|
|
235
|
+
|
|
236
|
+
export { AnnotationContext, AnnotationDetection, type BuildContextOptions, GraphContext, type ListResourcesFilters, PACKAGE_NAME, ResourceContext, VERSION };
|