@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resource-context.ts","../src/annotation-context.ts","../src/graph-context.ts","../src/annotation-detection.ts","../src/index.ts"],"sourcesContent":["/**\n * Resource Context\n *\n * Assembles resource context from view storage and content store\n * Does NOT touch the graph - graph queries go through GraphContext\n */\n\nimport { FilesystemViewStorage } from '@semiont/event-sourcing';\nimport { FilesystemRepresentationStore } from '@semiont/content';\nimport { getPrimaryRepresentation, decodeRepresentation } from '@semiont/api-client';\nimport type { components } from '@semiont/api-client';\nimport type { EnvironmentConfig, ResourceId } from '@semiont/core';\n\ntype ResourceDescriptor = components['schemas']['ResourceDescriptor'];\n\nexport interface ListResourcesFilters {\n search?: string;\n archived?: boolean;\n}\n\nexport class ResourceContext {\n /**\n * Get resource metadata from view storage\n */\n static async getResourceMetadata(resourceId: ResourceId, config: EnvironmentConfig): Promise<ResourceDescriptor | null> {\n const basePath = config.services.filesystem!.path;\n const projectRoot = config._metadata?.projectRoot;\n\n const viewStorage = new FilesystemViewStorage(basePath, projectRoot);\n\n const view = await viewStorage.get(resourceId);\n if (!view) {\n return null;\n }\n\n return view.resource;\n }\n\n /**\n * List all resources by scanning view storage\n */\n static async listResources(filters: ListResourcesFilters | undefined, config: EnvironmentConfig): Promise<ResourceDescriptor[]> {\n const basePath = config.services.filesystem!.path;\n const projectRoot = config._metadata?.projectRoot;\n\n const viewStorage = new FilesystemViewStorage(basePath, projectRoot);\n\n const allViews = await viewStorage.getAll();\n const resources: ResourceDescriptor[] = [];\n\n for (const view of allViews) {\n const doc = view.resource;\n\n // Apply filters\n if (filters?.archived !== undefined && doc.archived !== filters.archived) {\n continue;\n }\n\n if (filters?.search) {\n const searchLower = filters.search.toLowerCase();\n if (!doc.name.toLowerCase().includes(searchLower)) {\n continue;\n }\n }\n\n resources.push(doc);\n }\n\n // Sort by creation date (newest first)\n resources.sort((a, b) => {\n const aTime = a.dateCreated ? new Date(a.dateCreated).getTime() : 0;\n const bTime = b.dateCreated ? new Date(b.dateCreated).getTime() : 0;\n return bTime - aTime;\n });\n\n return resources;\n }\n\n /**\n * Add content previews to resources (for search results)\n * Retrieves and decodes the first 200 characters of each resource's primary representation\n */\n static async addContentPreviews(\n resources: ResourceDescriptor[],\n config: EnvironmentConfig\n ): Promise<Array<ResourceDescriptor & { content: string }>> {\n const basePath = config.services.filesystem!.path;\n const projectRoot = config._metadata?.projectRoot;\n const repStore = new FilesystemRepresentationStore({ basePath }, projectRoot);\n\n return await Promise.all(\n resources.map(async (doc) => {\n try {\n const primaryRep = getPrimaryRepresentation(doc);\n if (primaryRep?.checksum && primaryRep?.mediaType) {\n const contentBuffer = await repStore.retrieve(primaryRep.checksum, primaryRep.mediaType);\n const contentPreview = decodeRepresentation(contentBuffer, primaryRep.mediaType).slice(0, 200);\n return { ...doc, content: contentPreview };\n }\n return { ...doc, content: '' };\n } catch {\n return { ...doc, content: '' };\n }\n })\n );\n }\n}\n","/**\n * Annotation Context\n *\n * Assembles annotation context from view storage and content store.\n * Provides methods for:\n * - Getting resource annotations\n * - Building LLM context for annotations\n * - Extracting annotation text context\n * - Generating AI summaries\n */\n\nimport { generateResourceSummary, generateText } from '@semiont/inference';\nimport {\n getBodySource,\n getTargetSource,\n getTargetSelector,\n getResourceEntityTypes,\n getTextPositionSelector,\n getPrimaryRepresentation,\n decodeRepresentation,\n} from '@semiont/api-client';\nimport type { components, AnnotationUri, GenerationContext } from '@semiont/api-client';\nimport { FilesystemRepresentationStore } from '@semiont/content';\nimport { FilesystemViewStorage } from '@semiont/event-sourcing';\nimport type {\n EnvironmentConfig,\n ResourceId,\n ResourceAnnotations,\n AnnotationId,\n AnnotationCategory,\n} from '@semiont/core';\nimport { resourceId as createResourceId, uriToResourceId } from '@semiont/core';\nimport { getEntityTypes } from '@semiont/ontology';\nimport { ResourceContext } from './resource-context';\n\ntype AnnotationLLMContextResponse = components['schemas']['AnnotationLLMContextResponse'];\ntype TextPositionSelector = components['schemas']['TextPositionSelector'];\ntype TextQuoteSelector = components['schemas']['TextQuoteSelector'];\ntype Annotation = components['schemas']['Annotation'];\ntype ResourceDescriptor = components['schemas']['ResourceDescriptor'];\ntype AnnotationContextResponse = components['schemas']['AnnotationContextResponse'];\ntype ContextualSummaryResponse = components['schemas']['ContextualSummaryResponse'];\n\nexport interface BuildContextOptions {\n includeSourceContext?: boolean;\n includeTargetContext?: boolean;\n contextWindow?: number;\n}\n\ninterface AnnotationTextContext {\n before: string;\n selected: string;\n after: string;\n}\n\nexport class AnnotationContext {\n /**\n * Build LLM context for an annotation\n *\n * @param annotationUri - Full annotation URI (e.g., http://localhost:4000/annotations/abc123)\n * @param resourceId - Source resource ID\n * @param config - Application configuration\n * @param options - Context building options\n * @returns Rich context for LLM processing\n * @throws Error if annotation or resource not found\n */\n static async buildLLMContext(\n annotationUri: AnnotationUri,\n resourceId: ResourceId,\n config: EnvironmentConfig,\n options: BuildContextOptions = {}\n ): Promise<AnnotationLLMContextResponse> {\n const {\n includeSourceContext = true,\n includeTargetContext = true,\n contextWindow = 1000\n } = options;\n\n // Validate contextWindow range\n if (contextWindow < 100 || contextWindow > 5000) {\n throw new Error('contextWindow must be between 100 and 5000');\n }\n\n console.log(`[AnnotationContext] buildLLMContext called with annotationUri=${annotationUri}, resourceId=${resourceId}`);\n\n const basePath = config.services.filesystem!.path;\n console.log(`[AnnotationContext] basePath=${basePath}`);\n\n const projectRoot = config._metadata?.projectRoot;\n const viewStorage = new FilesystemViewStorage(basePath, projectRoot);\n const repStore = new FilesystemRepresentationStore({ basePath }, projectRoot);\n\n // Get source resource view\n console.log(`[AnnotationContext] Getting view for resourceId=${resourceId}`);\n let sourceView;\n try {\n sourceView = await viewStorage.get(resourceId);\n console.log(`[AnnotationContext] Got view:`, !!sourceView);\n\n if (!sourceView) {\n throw new Error('Source resource not found');\n }\n } catch (error) {\n console.error(`[AnnotationContext] Error getting view:`, error);\n throw error;\n }\n\n console.log(`[AnnotationContext] Looking for annotation ${annotationUri} in resource ${resourceId}`);\n console.log(`[AnnotationContext] View has ${sourceView.annotations.annotations.length} annotations`);\n console.log(`[AnnotationContext] First 5 annotation IDs:`, sourceView.annotations.annotations.slice(0, 5).map((a: Annotation) => a.id));\n\n // Find the annotation in the view (annotations have full URIs as their id)\n const annotation = sourceView.annotations.annotations.find((a: Annotation) => a.id === annotationUri);\n console.log(`[AnnotationContext] Found annotation:`, !!annotation);\n\n if (!annotation) {\n throw new Error('Annotation not found in view');\n }\n\n const targetSource = getTargetSource(annotation.target);\n // Extract resource ID from the target source URI (format: http://host/resources/{id})\n const targetResourceId = targetSource.split('/').pop();\n console.log(`[AnnotationContext] Target source: ${targetSource}, Expected resource ID: ${resourceId}, Extracted ID: ${targetResourceId}`);\n\n if (targetResourceId !== resourceId) {\n throw new Error(`Annotation target resource ID (${targetResourceId}) does not match expected resource ID (${resourceId})`);\n }\n\n const sourceDoc = sourceView.resource;\n\n // Get target resource if annotation is a reference (has resolved body source)\n const bodySource = getBodySource(annotation.body);\n\n // Extract target document from body source URI if present\n let targetDoc = null;\n if (bodySource) {\n // Inline extraction: \"http://localhost:4000/resources/abc123\" → \"abc123\"\n const parts = (bodySource as string).split('/');\n const lastPart = parts[parts.length - 1];\n if (!lastPart) {\n throw new Error(`Invalid body source URI: ${bodySource}`);\n }\n const targetResourceId = createResourceId(lastPart);\n const targetView = await viewStorage.get(targetResourceId);\n targetDoc = targetView?.resource || null;\n }\n\n // Build source context if requested\n let sourceContext;\n if (includeSourceContext) {\n const primaryRep = getPrimaryRepresentation(sourceDoc);\n if (!primaryRep?.checksum || !primaryRep?.mediaType) {\n throw new Error('Source content not found');\n }\n const sourceContent = await repStore.retrieve(primaryRep.checksum, primaryRep.mediaType);\n const contentStr = decodeRepresentation(sourceContent, primaryRep.mediaType);\n\n const targetSelectorRaw = getTargetSelector(annotation.target);\n\n // Handle array of selectors - take the first one\n const targetSelector = Array.isArray(targetSelectorRaw) ? targetSelectorRaw[0] : targetSelectorRaw;\n\n console.log(`[AnnotationContext] Target selector type:`, targetSelector?.type);\n\n if (!targetSelector) {\n console.warn(`[AnnotationContext] No target selector found`);\n } else if (targetSelector.type === 'TextPositionSelector') {\n // TypeScript now knows this is TextPositionSelector with required start/end\n const selector = targetSelector as TextPositionSelector;\n const start = selector.start;\n const end = selector.end;\n\n const before = contentStr.slice(Math.max(0, start - contextWindow), start);\n const selected = contentStr.slice(start, end);\n const after = contentStr.slice(end, Math.min(contentStr.length, end + contextWindow));\n\n sourceContext = { before, selected, after };\n console.log(`[AnnotationContext] Built source context using TextPositionSelector (${start}-${end})`);\n } else if (targetSelector.type === 'TextQuoteSelector') {\n // TypeScript now knows this is TextQuoteSelector with required exact\n const selector = targetSelector as TextQuoteSelector;\n const exact = selector.exact;\n const index = contentStr.indexOf(exact);\n\n if (index !== -1) {\n const start = index;\n const end = index + exact.length;\n\n const before = contentStr.slice(Math.max(0, start - contextWindow), start);\n const selected = exact;\n const after = contentStr.slice(end, Math.min(contentStr.length, end + contextWindow));\n\n sourceContext = { before, selected, after };\n console.log(`[AnnotationContext] Built source context using TextQuoteSelector (found at ${index})`);\n } else {\n console.warn(`[AnnotationContext] TextQuoteSelector exact text not found in content: \"${exact.substring(0, 50)}...\"`);\n }\n } else {\n console.warn(`[AnnotationContext] Unknown selector type: ${(targetSelector as any).type}`);\n }\n }\n\n // Build target context if requested and available\n let targetContext;\n if (includeTargetContext && targetDoc) {\n const targetRep = getPrimaryRepresentation(targetDoc);\n if (targetRep?.checksum && targetRep?.mediaType) {\n const targetContent = await repStore.retrieve(targetRep.checksum, targetRep.mediaType);\n const contentStr = decodeRepresentation(targetContent, targetRep.mediaType);\n\n targetContext = {\n content: contentStr.slice(0, contextWindow * 2),\n summary: await generateResourceSummary(targetDoc.name, contentStr, getResourceEntityTypes(targetDoc), config),\n };\n }\n }\n\n // TODO: Generate suggested resolution using AI\n const suggestedResolution = undefined;\n\n // Build GenerationContext structure\n const generationContext: GenerationContext | undefined = sourceContext ? {\n sourceContext: {\n before: sourceContext.before || '',\n selected: sourceContext.selected,\n after: sourceContext.after || '',\n },\n metadata: {\n resourceType: 'document',\n language: sourceDoc.language as string | undefined,\n entityTypes: getEntityTypes(annotation),\n },\n } : undefined;\n\n const response: AnnotationLLMContextResponse = {\n annotation,\n sourceResource: sourceDoc,\n targetResource: targetDoc,\n ...(generationContext ? { context: generationContext } : {}),\n ...(sourceContext ? { sourceContext } : {}), // Keep for backward compatibility\n ...(targetContext ? { targetContext } : {}),\n ...(suggestedResolution ? { suggestedResolution } : {}),\n };\n\n return response;\n }\n\n /**\n * Get resource annotations from view storage (fast path)\n * Throws if view missing\n */\n static async getResourceAnnotations(resourceId: ResourceId, config: EnvironmentConfig): Promise<ResourceAnnotations> {\n if (!config.services?.filesystem?.path) {\n throw new Error('Filesystem path not found in configuration');\n }\n const basePath = config.services.filesystem.path;\n const projectRoot = config._metadata?.projectRoot;\n const viewStorage = new FilesystemViewStorage(basePath, projectRoot);\n const view = await viewStorage.get(resourceId);\n\n if (!view) {\n throw new Error(`Resource ${resourceId} not found in view storage`);\n }\n\n return view.annotations;\n }\n\n /**\n * Get all annotations\n * @returns Array of all annotation objects\n */\n static async getAllAnnotations(resourceId: ResourceId, config: EnvironmentConfig): Promise<Annotation[]> {\n const annotations = await this.getResourceAnnotations(resourceId, config);\n\n // Enrich resolved references with document names\n // NOTE: Future optimization - make this optional via query param if performance becomes an issue\n return await this.enrichResolvedReferences(annotations.annotations, config);\n }\n\n /**\n * Enrich reference annotations with resolved document names\n * Adds _resolvedDocumentName property to annotations that link to documents\n * @private\n */\n private static async enrichResolvedReferences(annotations: Annotation[], config: EnvironmentConfig): Promise<Annotation[]> {\n if (!config.services?.filesystem?.path) {\n return annotations;\n }\n\n // Extract unique resolved document URIs from reference annotations\n const resolvedUris = new Set<string>();\n for (const ann of annotations) {\n if (ann.motivation === 'linking' && ann.body) {\n const body = Array.isArray(ann.body) ? ann.body : [ann.body];\n for (const item of body) {\n if (item.purpose === 'linking' && item.source) {\n resolvedUris.add(item.source);\n }\n }\n }\n }\n\n if (resolvedUris.size === 0) {\n return annotations;\n }\n\n // Batch fetch all resolved documents in parallel\n const basePath = config.services.filesystem.path;\n const projectRoot = config._metadata?.projectRoot;\n const viewStorage = new FilesystemViewStorage(basePath, projectRoot);\n\n const metadataPromises = Array.from(resolvedUris).map(async (uri) => {\n const docId = uri.split('/resources/')[1];\n if (!docId) return null;\n\n try {\n const view = await viewStorage.get(docId as ResourceId);\n if (view?.resource?.name) {\n return {\n uri,\n metadata: {\n name: view.resource.name,\n mediaType: view.resource.mediaType as string | undefined\n }\n };\n }\n } catch (e) {\n // Document might not exist, skip\n }\n return null;\n });\n\n const results = await Promise.all(metadataPromises);\n const uriToMetadata = new Map<string, { name: string; mediaType?: string }>();\n for (const result of results) {\n if (result) {\n uriToMetadata.set(result.uri, result.metadata);\n }\n }\n\n // Add _resolvedDocumentName and _resolvedDocumentMediaType to annotations\n return annotations.map(ann => {\n if (ann.motivation === 'linking' && ann.body) {\n const body = Array.isArray(ann.body) ? ann.body : [ann.body];\n for (const item of body) {\n if (item.purpose === 'linking' && item.source) {\n const metadata = uriToMetadata.get(item.source);\n if (metadata) {\n return {\n ...ann,\n _resolvedDocumentName: metadata.name,\n _resolvedDocumentMediaType: metadata.mediaType\n } as Annotation;\n }\n }\n }\n }\n return ann;\n });\n }\n\n /**\n * Get resource stats (version info)\n * @returns Version and timestamp info for the annotations\n */\n static async getResourceStats(resourceId: ResourceId, config: EnvironmentConfig): Promise<{\n resourceId: ResourceId;\n version: number;\n updatedAt: string;\n }> {\n const annotations = await this.getResourceAnnotations(resourceId, config);\n return {\n resourceId: annotations.resourceId,\n version: annotations.version,\n updatedAt: annotations.updatedAt,\n };\n }\n\n /**\n * Check if resource exists in view storage\n */\n static async resourceExists(resourceId: ResourceId, config: EnvironmentConfig): Promise<boolean> {\n if (!config.services?.filesystem?.path) {\n throw new Error('Filesystem path not found in configuration');\n }\n const basePath = config.services.filesystem.path;\n const projectRoot = config._metadata?.projectRoot;\n const viewStorage = new FilesystemViewStorage(basePath, projectRoot);\n return await viewStorage.exists(resourceId);\n }\n\n /**\n * Get a single annotation by ID\n * O(1) lookup using resource ID to access view storage\n */\n static async getAnnotation(annotationId: AnnotationId, resourceId: ResourceId, config: EnvironmentConfig): Promise<Annotation | null> {\n const annotations = await this.getResourceAnnotations(resourceId, config);\n // Extract short ID from annotation's full URI for comparison\n return annotations.annotations.find((a: Annotation) => {\n const shortId = a.id.split('/').pop();\n return shortId === annotationId;\n }) || null;\n }\n\n /**\n * List annotations with optional filtering\n * @param filters - Optional filters like resourceId and type\n * @throws Error if resourceId not provided (cross-resource queries not supported in view storage)\n */\n static async listAnnotations(filters: { resourceId?: ResourceId; type?: AnnotationCategory } | undefined, config: EnvironmentConfig): Promise<Annotation[]> {\n if (!filters?.resourceId) {\n throw new Error('resourceId is required for annotation listing - cross-resource queries not supported in view storage');\n }\n\n // Use view storage directly\n return await this.getAllAnnotations(filters.resourceId, config);\n }\n\n /**\n * Get annotation context (selected text with surrounding context)\n */\n static async getAnnotationContext(\n annotationId: AnnotationId,\n resourceId: ResourceId,\n contextBefore: number,\n contextAfter: number,\n config: EnvironmentConfig\n ): Promise<AnnotationContextResponse> {\n const basePath = config.services.filesystem!.path;\n const projectRoot = config._metadata?.projectRoot;\n const repStore = new FilesystemRepresentationStore({ basePath }, projectRoot);\n\n // Get annotation from view storage\n const annotation = await this.getAnnotation(annotationId, resourceId, config);\n if (!annotation) {\n throw new Error('Annotation not found');\n }\n\n // Get resource metadata from view storage\n const resource = await ResourceContext.getResourceMetadata(\n uriToResourceId(getTargetSource(annotation.target)),\n config\n );\n if (!resource) {\n throw new Error('Resource not found');\n }\n\n // Get content from representation store\n const contentStr = await this.getResourceContent(resource, repStore);\n\n // Extract context based on annotation position\n const context = this.extractAnnotationContext(annotation, contentStr, contextBefore, contextAfter);\n\n return {\n annotation: annotation,\n context,\n resource: {\n '@context': resource['@context'],\n '@id': resource['@id'],\n name: resource.name,\n entityTypes: resource.entityTypes,\n representations: resource.representations,\n archived: resource.archived,\n creationMethod: resource.creationMethod,\n wasAttributedTo: resource.wasAttributedTo,\n dateCreated: resource.dateCreated,\n },\n };\n }\n\n /**\n * Generate AI summary of annotation in context\n */\n static async generateAnnotationSummary(\n annotationId: AnnotationId,\n resourceId: ResourceId,\n config: EnvironmentConfig\n ): Promise<ContextualSummaryResponse> {\n const basePath = config.services.filesystem!.path;\n const projectRoot = config._metadata?.projectRoot;\n const repStore = new FilesystemRepresentationStore({ basePath }, projectRoot);\n\n // Get annotation from view storage\n const annotation = await this.getAnnotation(annotationId, resourceId, config);\n if (!annotation) {\n throw new Error('Annotation not found');\n }\n\n // Get resource from view storage\n const resource = await ResourceContext.getResourceMetadata(\n uriToResourceId(getTargetSource(annotation.target)),\n config\n );\n if (!resource) {\n throw new Error('Resource not found');\n }\n\n // Get content from representation store\n const contentStr = await this.getResourceContent(resource, repStore);\n\n // Extract annotation text with context (fixed 500 chars for summary)\n const contextSize = 500;\n const context = this.extractAnnotationContext(annotation, contentStr, contextSize, contextSize);\n\n // Extract entity types from annotation body\n const annotationEntityTypes = getEntityTypes(annotation);\n\n // Generate summary using LLM\n const summary = await this.generateSummary(resource, context, annotationEntityTypes, config);\n\n return {\n summary,\n relevantFields: {\n resourceId: resource.id,\n resourceName: resource.name,\n entityTypes: annotationEntityTypes,\n },\n context: {\n before: context.before.substring(Math.max(0, context.before.length - 200)), // Last 200 chars\n selected: context.selected,\n after: context.after.substring(0, 200), // First 200 chars\n },\n };\n }\n\n /**\n * Get resource content as string\n */\n private static async getResourceContent(\n resource: ResourceDescriptor,\n repStore: FilesystemRepresentationStore\n ): Promise<string> {\n const primaryRep = getPrimaryRepresentation(resource);\n if (!primaryRep?.checksum || !primaryRep?.mediaType) {\n throw new Error('Resource content not found');\n }\n const content = await repStore.retrieve(primaryRep.checksum, primaryRep.mediaType);\n return decodeRepresentation(content, primaryRep.mediaType);\n }\n\n /**\n * Extract annotation context from resource content\n */\n private static extractAnnotationContext(\n annotation: Annotation,\n contentStr: string,\n contextBefore: number,\n contextAfter: number\n ): AnnotationTextContext {\n const targetSelector = getTargetSelector(annotation.target);\n const posSelector = targetSelector ? getTextPositionSelector(targetSelector) : null;\n if (!posSelector) {\n throw new Error('TextPositionSelector required for context');\n }\n\n const selStart = posSelector.start;\n const selEnd = posSelector.end;\n const start = Math.max(0, selStart - contextBefore);\n const end = Math.min(contentStr.length, selEnd + contextAfter);\n\n return {\n before: contentStr.substring(start, selStart),\n selected: contentStr.substring(selStart, selEnd),\n after: contentStr.substring(selEnd, end),\n };\n }\n\n /**\n * Generate LLM summary of annotation in context\n */\n private static async generateSummary(\n resource: ResourceDescriptor,\n context: AnnotationTextContext,\n entityTypes: string[],\n config: EnvironmentConfig\n ): Promise<string> {\n const summaryPrompt = `Summarize this text in context:\n\nContext before: \"${context.before.substring(Math.max(0, context.before.length - 200))}\"\nSelected exact: \"${context.selected}\"\nContext after: \"${context.after.substring(0, 200)}\"\n\nResource: ${resource.name}\nEntity types: ${entityTypes.join(', ')}`;\n\n return await generateText(summaryPrompt, config, 500, 0.5);\n }\n}\n","/**\n * Graph Context\n *\n * Provides graph database operations for resources and annotations.\n * All methods require graph traversal - must use graph database.\n */\n\nimport { getGraphDatabase } from '@semiont/graph';\nimport { resourceIdToURI } from '@semiont/core';\nimport type {\n ResourceId,\n EnvironmentConfig,\n GraphConnection,\n GraphPath,\n} from '@semiont/core';\nimport type { components } from '@semiont/api-client';\n\ntype Annotation = components['schemas']['Annotation'];\ntype ResourceDescriptor = components['schemas']['ResourceDescriptor'];\n\nexport class GraphContext {\n /**\n * Get all resources referencing this resource (backlinks)\n * Requires graph traversal - must use graph database\n */\n static async getBacklinks(resourceId: ResourceId, config: EnvironmentConfig): Promise<Annotation[]> {\n const graphDb = await getGraphDatabase(config);\n const resourceUri = resourceIdToURI(resourceId, config.services.backend!.publicURL);\n return await graphDb.getResourceReferencedBy(resourceUri);\n }\n\n /**\n * Find shortest path between two resources\n * Requires graph traversal - must use graph database\n */\n static async findPath(\n fromResourceId: ResourceId,\n toResourceId: ResourceId,\n config: EnvironmentConfig,\n maxDepth?: number\n ): Promise<GraphPath[]> {\n const graphDb = await getGraphDatabase(config);\n return await graphDb.findPath(fromResourceId, toResourceId, maxDepth);\n }\n\n /**\n * Get resource connections (graph edges)\n * Requires graph traversal - must use graph database\n */\n static async getResourceConnections(resourceId: ResourceId, config: EnvironmentConfig): Promise<GraphConnection[]> {\n const graphDb = await getGraphDatabase(config);\n return await graphDb.getResourceConnections(resourceId);\n }\n\n /**\n * Search resources by name (cross-resource query)\n * Requires full-text search - must use graph database\n */\n static async searchResources(query: string, config: EnvironmentConfig, limit?: number): Promise<ResourceDescriptor[]> {\n const graphDb = await getGraphDatabase(config);\n return await graphDb.searchResources(query, limit);\n }\n}\n","/**\n * Annotation Detection\n *\n * Orchestrates the full annotation detection pipeline:\n * 1. Fetch resource metadata and content\n * 2. Build AI prompts using MotivationPrompts\n * 3. Call AI inference\n * 4. Parse and validate results using MotivationParsers\n *\n * This is the high-level API for AI-powered annotation detection.\n * Workers and other consumers should use these methods instead of\n * implementing detection logic directly.\n */\n\nimport { ResourceContext } from './resource-context';\nimport { FilesystemRepresentationStore } from '@semiont/content';\nimport { getPrimaryRepresentation, decodeRepresentation } from '@semiont/api-client';\nimport {\n MotivationPrompts,\n MotivationParsers,\n generateText,\n type CommentMatch,\n type HighlightMatch,\n type AssessmentMatch,\n type TagMatch,\n} from '@semiont/inference';\nimport { getTagSchema, getSchemaCategory } from '@semiont/ontology';\nimport type { EnvironmentConfig, ResourceId } from '@semiont/core';\n\nexport class AnnotationDetection {\n /**\n * Detect comments in a resource\n *\n * @param resourceId - The resource to analyze\n * @param config - Environment configuration\n * @param instructions - Optional user instructions for comment generation\n * @param tone - Optional tone guidance (e.g., \"academic\", \"conversational\")\n * @param density - Optional target number of comments per 2000 words\n * @returns Array of validated comment matches\n */\n static async detectComments(\n resourceId: ResourceId,\n config: EnvironmentConfig,\n instructions?: string,\n tone?: string,\n density?: number\n ): Promise<CommentMatch[]> {\n // 1. Fetch resource metadata\n const resource = await ResourceContext.getResourceMetadata(resourceId, config);\n if (!resource) {\n throw new Error(`Resource ${resourceId} not found`);\n }\n\n // 2. Load content from representation store\n const content = await this.loadResourceContent(resourceId, config);\n if (!content) {\n throw new Error(`Could not load content for resource ${resourceId}`);\n }\n\n // 3. Build prompt\n const prompt = MotivationPrompts.buildCommentPrompt(content, instructions, tone, density);\n\n // 4. Call AI inference\n const response = await generateText(\n prompt,\n config,\n 3000, // maxTokens: Higher than highlights/assessments due to comment text\n 0.4 // temperature: Slightly higher to allow creative context\n );\n\n // 5. Parse and validate response\n return MotivationParsers.parseComments(response, content);\n }\n\n /**\n * Detect highlights in a resource\n *\n * @param resourceId - The resource to analyze\n * @param config - Environment configuration\n * @param instructions - Optional user instructions for highlight selection\n * @param density - Optional target number of highlights per 2000 words\n * @returns Array of validated highlight matches\n */\n static async detectHighlights(\n resourceId: ResourceId,\n config: EnvironmentConfig,\n instructions?: string,\n density?: number\n ): Promise<HighlightMatch[]> {\n // 1. Fetch resource metadata\n const resource = await ResourceContext.getResourceMetadata(resourceId, config);\n if (!resource) {\n throw new Error(`Resource ${resourceId} not found`);\n }\n\n // 2. Load content from representation store\n const content = await this.loadResourceContent(resourceId, config);\n if (!content) {\n throw new Error(`Could not load content for resource ${resourceId}`);\n }\n\n // 3. Build prompt\n const prompt = MotivationPrompts.buildHighlightPrompt(content, instructions, density);\n\n // 4. Call AI inference\n const response = await generateText(\n prompt,\n config,\n 2000, // maxTokens: Lower than comments/assessments (no body text)\n 0.3 // temperature: Low for consistent importance judgments\n );\n\n // 5. Parse and validate response\n return MotivationParsers.parseHighlights(response, content);\n }\n\n /**\n * Detect assessments in a resource\n *\n * @param resourceId - The resource to analyze\n * @param config - Environment configuration\n * @param instructions - Optional user instructions for assessment generation\n * @param tone - Optional tone guidance (e.g., \"critical\", \"supportive\")\n * @param density - Optional target number of assessments per 2000 words\n * @returns Array of validated assessment matches\n */\n static async detectAssessments(\n resourceId: ResourceId,\n config: EnvironmentConfig,\n instructions?: string,\n tone?: string,\n density?: number\n ): Promise<AssessmentMatch[]> {\n // 1. Fetch resource metadata\n const resource = await ResourceContext.getResourceMetadata(resourceId, config);\n if (!resource) {\n throw new Error(`Resource ${resourceId} not found`);\n }\n\n // 2. Load content from representation store\n const content = await this.loadResourceContent(resourceId, config);\n if (!content) {\n throw new Error(`Could not load content for resource ${resourceId}`);\n }\n\n // 3. Build prompt\n const prompt = MotivationPrompts.buildAssessmentPrompt(content, instructions, tone, density);\n\n // 4. Call AI inference\n const response = await generateText(\n prompt,\n config,\n 3000, // maxTokens: Higher for assessment text\n 0.3 // temperature: Lower for analytical consistency\n );\n\n // 5. Parse and validate response\n return MotivationParsers.parseAssessments(response, content);\n }\n\n /**\n * Detect tags in a resource for a specific category\n *\n * @param resourceId - The resource to analyze\n * @param config - Environment configuration\n * @param schemaId - The tag schema identifier (e.g., \"irac\", \"imrad\")\n * @param category - The specific category to detect\n * @returns Array of validated tag matches\n */\n static async detectTags(\n resourceId: ResourceId,\n config: EnvironmentConfig,\n schemaId: string,\n category: string\n ): Promise<TagMatch[]> {\n // Validate schema and category\n const schema = getTagSchema(schemaId);\n if (!schema) {\n throw new Error(`Invalid tag schema: ${schemaId}`);\n }\n\n const categoryInfo = getSchemaCategory(schemaId, category);\n if (!categoryInfo) {\n throw new Error(`Invalid category \"${category}\" for schema ${schemaId}`);\n }\n\n // 1. Fetch resource metadata\n const resource = await ResourceContext.getResourceMetadata(resourceId, config);\n if (!resource) {\n throw new Error(`Resource ${resourceId} not found`);\n }\n\n // 2. Load content from representation store (FULL content for structural analysis)\n const content = await this.loadResourceContent(resourceId, config);\n if (!content) {\n throw new Error(`Could not load content for resource ${resourceId}`);\n }\n\n // 3. Build prompt with schema and category information\n const prompt = MotivationPrompts.buildTagPrompt(\n content,\n category,\n schema.name,\n schema.description,\n schema.domain,\n categoryInfo.description,\n categoryInfo.examples\n );\n\n // 4. Call AI inference\n const response = await generateText(\n prompt,\n config,\n 4000, // maxTokens: Higher for full document analysis\n 0.2 // temperature: Lower for structural consistency\n );\n\n // 5. Parse response (without validation)\n const parsedTags = MotivationParsers.parseTags(response);\n\n // 6. Validate offsets and add category\n return MotivationParsers.validateTagOffsets(parsedTags, content, category);\n }\n\n /**\n * Load resource content from representation store\n * Helper method used by all detection methods\n *\n * @param resourceId - The resource ID to load\n * @param config - Environment configuration\n * @returns Resource content as string, or null if not available\n */\n private static async loadResourceContent(\n resourceId: ResourceId,\n config: EnvironmentConfig\n ): Promise<string | null> {\n const resource = await ResourceContext.getResourceMetadata(resourceId, config);\n if (!resource) return null;\n\n const primaryRep = getPrimaryRepresentation(resource);\n if (!primaryRep) return null;\n\n // Only process text content\n const baseMediaType = primaryRep.mediaType?.split(';')[0]?.trim() || '';\n if (baseMediaType !== 'text/plain' && baseMediaType !== 'text/markdown') {\n return null;\n }\n\n if (!primaryRep.checksum || !primaryRep.mediaType) return null;\n\n const basePath = config.services.filesystem!.path;\n const projectRoot = config._metadata?.projectRoot;\n const repStore = new FilesystemRepresentationStore({ basePath }, projectRoot);\n const contentBuffer = await repStore.retrieve(primaryRep.checksum, primaryRep.mediaType);\n return decodeRepresentation(contentBuffer, primaryRep.mediaType);\n }\n}\n","// @semiont/make-meaning - Making meaning from resources\n// Transforms raw resources into meaningful, interconnected knowledge\n\n// Context assembly exports\nexport { ResourceContext } from './resource-context';\nexport type { ListResourcesFilters } from './resource-context';\nexport { AnnotationContext } from './annotation-context';\nexport type { BuildContextOptions } from './annotation-context';\nexport { GraphContext } from './graph-context';\n\n// Detection exports\nexport { AnnotationDetection } from './annotation-detection';\n\n// Re-export match types from @semiont/inference for convenience\nexport type {\n CommentMatch,\n HighlightMatch,\n AssessmentMatch,\n TagMatch,\n} from '@semiont/inference';\n\n// Reasoning exports (future)\n// export { ResourceReasoning } from './resource-reasoning';\n\n// Placeholder for initial build\nexport const PACKAGE_NAME = '@semiont/make-meaning';\nexport const VERSION = '0.1.0';\n"],"mappings":";AAOA,SAAS,6BAA6B;AACtC,SAAS,qCAAqC;AAC9C,SAAS,0BAA0B,4BAA4B;AAWxD,IAAM,kBAAN,MAAsB;AAAA;AAAA;AAAA;AAAA,EAI3B,aAAa,oBAAoB,YAAwB,QAA+D;AACtH,UAAM,WAAW,OAAO,SAAS,WAAY;AAC7C,UAAM,cAAc,OAAO,WAAW;AAEtC,UAAM,cAAc,IAAI,sBAAsB,UAAU,WAAW;AAEnE,UAAM,OAAO,MAAM,YAAY,IAAI,UAAU;AAC7C,QAAI,CAAC,MAAM;AACT,aAAO;AAAA,IACT;AAEA,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,aAAa,cAAc,SAA2C,QAA0D;AAC9H,UAAM,WAAW,OAAO,SAAS,WAAY;AAC7C,UAAM,cAAc,OAAO,WAAW;AAEtC,UAAM,cAAc,IAAI,sBAAsB,UAAU,WAAW;AAEnE,UAAM,WAAW,MAAM,YAAY,OAAO;AAC1C,UAAM,YAAkC,CAAC;AAEzC,eAAW,QAAQ,UAAU;AAC3B,YAAM,MAAM,KAAK;AAGjB,UAAI,SAAS,aAAa,UAAa,IAAI,aAAa,QAAQ,UAAU;AACxE;AAAA,MACF;AAEA,UAAI,SAAS,QAAQ;AACnB,cAAM,cAAc,QAAQ,OAAO,YAAY;AAC/C,YAAI,CAAC,IAAI,KAAK,YAAY,EAAE,SAAS,WAAW,GAAG;AACjD;AAAA,QACF;AAAA,MACF;AAEA,gBAAU,KAAK,GAAG;AAAA,IACpB;AAGA,cAAU,KAAK,CAAC,GAAG,MAAM;AACvB,YAAM,QAAQ,EAAE,cAAc,IAAI,KAAK,EAAE,WAAW,E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AAG,EAAE,CAAC,GAAG,KAAK,KAAK;AACrE,QAAI,kBAAkB,gBAAgB,kBAAkB,iBAAiB;AACvE,aAAO;AAAA,IACT;AAEA,QAAI,CAAC,WAAW,YAAY,CAAC,WAAW,UAAW,QAAO;AAE1D,UAAM,WAAW,OAAO,SAAS,WAAY;AAC7C,UAAM,cAAc,OAAO,WAAW;AACtC,UAAM,WAAW,IAAID,+BAA8B,EAAE,SAAS,GAAG,WAAW;AAC5E,UAAM,gBAAgB,MAAM,SAAS,SAAS,WAAW,UAAU,WAAW,SAAS;AACvF,WAAOE,sBAAqB,eAAe,WAAW,SAAS;AAAA,EACjE;AACF;;;ACvOO,IAAM,eAAe;AACrB,IAAM,UAAU;","names":["getPrimaryRepresentation","decodeRepresentation","FilesystemRepresentationStore","FilesystemViewStorage","FilesystemViewStorage","FilesystemRepresentationStore","targetResourceId","getPrimaryRepresentation","decodeRepresentation","FilesystemRepresentationStore","getPrimaryRepresentation","decodeRepresentation","generateText"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@semiont/make-meaning",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Making meaning from resources through context assembly, pattern detection, and relationship reasoning",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "npm run typecheck && tsup",
|
|
20
|
+
"typecheck": "tsc --noEmit",
|
|
21
|
+
"clean": "rm -rf dist",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@semiont/core": "*",
|
|
27
|
+
"@semiont/api-client": "*",
|
|
28
|
+
"@semiont/event-sourcing": "*",
|
|
29
|
+
"@semiont/content": "*",
|
|
30
|
+
"@semiont/graph": "*",
|
|
31
|
+
"@semiont/ontology": "*",
|
|
32
|
+
"@semiont/inference": "*"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"tsup": "^8.0.1",
|
|
36
|
+
"typescript": "^5.6.3",
|
|
37
|
+
"vitest": "^2.1.8"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"semantic-annotation",
|
|
41
|
+
"knowledge-graph",
|
|
42
|
+
"context-assembly",
|
|
43
|
+
"meaning-making",
|
|
44
|
+
"resource-analysis"
|
|
45
|
+
],
|
|
46
|
+
"author": "The AI Alliance",
|
|
47
|
+
"license": "Apache-2.0",
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "https://github.com/The-AI-Alliance/semiont.git",
|
|
51
|
+
"directory": "packages/make-meaning"
|
|
52
|
+
}
|
|
53
|
+
}
|