chore: recovery checkpoint - v3.0 API successfully recovered
CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB Recovery Status: - Successfully recovered brainy.ts from compiled JavaScript - All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.) - Neural subsystem intact (562KB embedded patterns, NLP working) - Augmentation pipeline operational (20+ augmentations) - HNSW clustering system complete - Triple Intelligence compiled (needs constructor fix) - Test suite validates functionality Changes preserved: - 898 files with changes from last 3 days - 144,475 insertions - All augmentation improvements - All test coverage enhancements - Complete v3.0 feature set This is a LOCAL checkpoint only - contains recovered work after corruption incident. Created backup in .backups/brainy-full-20250910-151314.tar.gz Branch: recovery-checkpoint-20250910-151433 Date: Wed Sep 10 03:18:04 PM PDT 2025
This commit is contained in:
parent
f65455fb22
commit
8ff382ca3b
895 changed files with 143654 additions and 28268 deletions
130
.recovery-workspace/dist-backup-20250910-141917/augmentations/display/cache.d.ts
vendored
Normal file
130
.recovery-workspace/dist-backup-20250910-141917/augmentations/display/cache.d.ts
vendored
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
* Universal Display Augmentation - Intelligent Caching System
|
||||
*
|
||||
* High-performance LRU cache with smart eviction and batch optimization
|
||||
* Designed for minimal memory footprint and maximum hit ratio
|
||||
*/
|
||||
import type { ComputedDisplayFields, DisplayAugmentationStats } from './types.js';
|
||||
/**
|
||||
* LRU (Least Recently Used) Cache for computed display fields
|
||||
* Optimized for the display augmentation use case
|
||||
*/
|
||||
export declare class DisplayCache {
|
||||
private cache;
|
||||
private readonly maxSize;
|
||||
private stats;
|
||||
constructor(maxSize?: number);
|
||||
/**
|
||||
* Get cached display fields with LRU update
|
||||
* @param key Cache key
|
||||
* @returns Cached fields or null if not found
|
||||
*/
|
||||
get(key: string): ComputedDisplayFields | null;
|
||||
/**
|
||||
* Store computed display fields in cache
|
||||
* @param key Cache key
|
||||
* @param fields Computed display fields
|
||||
* @param computationTime Time taken to compute (for stats)
|
||||
*/
|
||||
set(key: string, fields: ComputedDisplayFields, computationTime?: number): void;
|
||||
/**
|
||||
* Check if a key exists in cache without affecting LRU order
|
||||
* @param key Cache key
|
||||
* @returns True if key exists
|
||||
*/
|
||||
has(key: string): boolean;
|
||||
/**
|
||||
* Generate cache key from data
|
||||
* @param id Entity ID (preferred)
|
||||
* @param data Fallback data for key generation
|
||||
* @param entityType Type of entity (noun/verb)
|
||||
* @returns Cache key string
|
||||
*/
|
||||
generateKey(id?: string, data?: any, entityType?: 'noun' | 'verb'): string;
|
||||
/**
|
||||
* Clear all cached entries
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Get cache statistics
|
||||
* @returns Cache performance statistics
|
||||
*/
|
||||
getStats(): DisplayAugmentationStats;
|
||||
/**
|
||||
* Get current cache size
|
||||
* @returns Number of cached entries
|
||||
*/
|
||||
size(): number;
|
||||
/**
|
||||
* Get cache capacity
|
||||
* @returns Maximum cache size
|
||||
*/
|
||||
capacity(): number;
|
||||
/**
|
||||
* Evict least recently used entry
|
||||
*/
|
||||
private evictOldest;
|
||||
/**
|
||||
* Simple hash function for cache keys
|
||||
* @param str String to hash
|
||||
* @returns Simple hash number
|
||||
*/
|
||||
private simpleHash;
|
||||
/**
|
||||
* Optimize cache by removing stale entries
|
||||
* Called periodically to maintain cache health
|
||||
*/
|
||||
optimizeCache(): void;
|
||||
/**
|
||||
* Precompute display fields for a batch of entities
|
||||
* @param entities Array of entities with their compute functions
|
||||
* @returns Promise resolving when batch is complete
|
||||
*/
|
||||
batchPrecompute<T>(entities: Array<{
|
||||
key: string;
|
||||
computeFn: () => Promise<ComputedDisplayFields>;
|
||||
}>): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Request deduplicator for batch processing
|
||||
* Prevents duplicate computations for the same data
|
||||
*/
|
||||
export declare class RequestDeduplicator {
|
||||
private pendingRequests;
|
||||
private readonly batchSize;
|
||||
constructor(batchSize?: number);
|
||||
/**
|
||||
* Deduplicate computation request
|
||||
* @param key Unique key for the computation
|
||||
* @param computeFn Function to compute the result
|
||||
* @returns Promise that resolves to the computed fields
|
||||
*/
|
||||
deduplicate(key: string, computeFn: () => Promise<ComputedDisplayFields>): Promise<ComputedDisplayFields>;
|
||||
/**
|
||||
* Get number of pending requests
|
||||
* @returns Number of pending computations
|
||||
*/
|
||||
getPendingCount(): number;
|
||||
/**
|
||||
* Clear all pending requests
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Shutdown the deduplicator
|
||||
*/
|
||||
shutdown(): void;
|
||||
}
|
||||
/**
|
||||
* Get global display cache instance
|
||||
* @param maxSize Optional cache size (only used on first call)
|
||||
* @returns Shared display cache instance
|
||||
*/
|
||||
export declare function getGlobalDisplayCache(maxSize?: number): DisplayCache;
|
||||
/**
|
||||
* Clear global cache (for testing or memory management)
|
||||
*/
|
||||
export declare function clearGlobalDisplayCache(): void;
|
||||
/**
|
||||
* Shutdown global cache and cleanup
|
||||
*/
|
||||
export declare function shutdownGlobalDisplayCache(): void;
|
||||
|
|
@ -0,0 +1,319 @@
|
|||
/**
|
||||
* Universal Display Augmentation - Intelligent Caching System
|
||||
*
|
||||
* High-performance LRU cache with smart eviction and batch optimization
|
||||
* Designed for minimal memory footprint and maximum hit ratio
|
||||
*/
|
||||
/**
|
||||
* LRU (Least Recently Used) Cache for computed display fields
|
||||
* Optimized for the display augmentation use case
|
||||
*/
|
||||
export class DisplayCache {
|
||||
constructor(maxSize = 1000) {
|
||||
this.cache = new Map();
|
||||
this.stats = {
|
||||
hits: 0,
|
||||
misses: 0,
|
||||
evictions: 0,
|
||||
totalComputations: 0,
|
||||
totalComputationTime: 0
|
||||
};
|
||||
this.maxSize = maxSize;
|
||||
}
|
||||
/**
|
||||
* Get cached display fields with LRU update
|
||||
* @param key Cache key
|
||||
* @returns Cached fields or null if not found
|
||||
*/
|
||||
get(key) {
|
||||
const entry = this.cache.get(key);
|
||||
if (!entry) {
|
||||
this.stats.misses++;
|
||||
return null;
|
||||
}
|
||||
// Update LRU - move to end
|
||||
this.cache.delete(key);
|
||||
entry.lastAccessed = Date.now();
|
||||
entry.accessCount++;
|
||||
this.cache.set(key, entry);
|
||||
this.stats.hits++;
|
||||
return entry.fields;
|
||||
}
|
||||
/**
|
||||
* Store computed display fields in cache
|
||||
* @param key Cache key
|
||||
* @param fields Computed display fields
|
||||
* @param computationTime Time taken to compute (for stats)
|
||||
*/
|
||||
set(key, fields, computationTime) {
|
||||
// Remove if already exists (for LRU update)
|
||||
if (this.cache.has(key)) {
|
||||
this.cache.delete(key);
|
||||
}
|
||||
// Create cache entry
|
||||
const entry = {
|
||||
fields,
|
||||
lastAccessed: Date.now(),
|
||||
accessCount: 1
|
||||
};
|
||||
// Add to end (most recently used)
|
||||
this.cache.set(key, entry);
|
||||
// Update stats
|
||||
this.stats.totalComputations++;
|
||||
if (computationTime) {
|
||||
this.stats.totalComputationTime += computationTime;
|
||||
}
|
||||
// Evict oldest if over capacity
|
||||
if (this.cache.size > this.maxSize) {
|
||||
this.evictOldest();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check if a key exists in cache without affecting LRU order
|
||||
* @param key Cache key
|
||||
* @returns True if key exists
|
||||
*/
|
||||
has(key) {
|
||||
return this.cache.has(key);
|
||||
}
|
||||
/**
|
||||
* Generate cache key from data
|
||||
* @param id Entity ID (preferred)
|
||||
* @param data Fallback data for key generation
|
||||
* @param entityType Type of entity (noun/verb)
|
||||
* @returns Cache key string
|
||||
*/
|
||||
generateKey(id, data, entityType = 'noun') {
|
||||
// Use ID if available (most reliable)
|
||||
if (id) {
|
||||
return `${entityType}:${id}`;
|
||||
}
|
||||
// Generate hash from data
|
||||
if (data) {
|
||||
const dataString = JSON.stringify(data, Object.keys(data).sort());
|
||||
const hash = this.simpleHash(dataString);
|
||||
return `${entityType}:hash:${hash}`;
|
||||
}
|
||||
// Fallback to timestamp (not ideal but prevents crashes)
|
||||
return `${entityType}:temp:${Date.now()}:${Math.random()}`;
|
||||
}
|
||||
/**
|
||||
* Clear all cached entries
|
||||
*/
|
||||
clear() {
|
||||
this.cache.clear();
|
||||
this.stats = {
|
||||
hits: 0,
|
||||
misses: 0,
|
||||
evictions: 0,
|
||||
totalComputations: 0,
|
||||
totalComputationTime: 0
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Get cache statistics
|
||||
* @returns Cache performance statistics
|
||||
*/
|
||||
getStats() {
|
||||
const hitRatio = this.stats.hits + this.stats.misses > 0
|
||||
? this.stats.hits / (this.stats.hits + this.stats.misses)
|
||||
: 0;
|
||||
const avgComputationTime = this.stats.totalComputations > 0
|
||||
? this.stats.totalComputationTime / this.stats.totalComputations
|
||||
: 0;
|
||||
// Analyze cached types for common types statistics
|
||||
const typeCount = new Map();
|
||||
let fastestComputation = Infinity;
|
||||
let slowestComputation = 0;
|
||||
for (const entry of this.cache.values()) {
|
||||
const type = entry.fields.type;
|
||||
typeCount.set(type, (typeCount.get(type) || 0) + 1);
|
||||
}
|
||||
const commonTypes = Array.from(typeCount.entries())
|
||||
.sort(([, a], [, b]) => b - a)
|
||||
.slice(0, 10)
|
||||
.map(([type, count]) => ({
|
||||
type,
|
||||
count,
|
||||
percentage: Math.round((count / this.cache.size) * 100)
|
||||
}));
|
||||
return {
|
||||
totalComputations: this.stats.totalComputations,
|
||||
cacheHitRatio: Math.round(hitRatio * 100) / 100,
|
||||
averageComputationTime: Math.round(avgComputationTime * 100) / 100,
|
||||
commonTypes,
|
||||
performance: {
|
||||
fastestComputation,
|
||||
slowestComputation,
|
||||
totalComputationTime: this.stats.totalComputationTime
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Get current cache size
|
||||
* @returns Number of cached entries
|
||||
*/
|
||||
size() {
|
||||
return this.cache.size;
|
||||
}
|
||||
/**
|
||||
* Get cache capacity
|
||||
* @returns Maximum cache size
|
||||
*/
|
||||
capacity() {
|
||||
return this.maxSize;
|
||||
}
|
||||
/**
|
||||
* Evict least recently used entry
|
||||
*/
|
||||
evictOldest() {
|
||||
// First entry is oldest (LRU)
|
||||
const firstKey = this.cache.keys().next().value;
|
||||
if (firstKey) {
|
||||
this.cache.delete(firstKey);
|
||||
this.stats.evictions++;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Simple hash function for cache keys
|
||||
* @param str String to hash
|
||||
* @returns Simple hash number
|
||||
*/
|
||||
simpleHash(str) {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
const char = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + char;
|
||||
hash = hash & hash; // Convert to 32-bit integer
|
||||
}
|
||||
return Math.abs(hash);
|
||||
}
|
||||
/**
|
||||
* Optimize cache by removing stale entries
|
||||
* Called periodically to maintain cache health
|
||||
*/
|
||||
optimizeCache() {
|
||||
const now = Date.now();
|
||||
const maxAge = 24 * 60 * 60 * 1000; // 24 hours
|
||||
const minAccessCount = 2; // Minimum access count to keep
|
||||
const toDelete = [];
|
||||
for (const [key, entry] of this.cache.entries()) {
|
||||
// Remove very old entries with low access count
|
||||
if (now - entry.lastAccessed > maxAge && entry.accessCount < minAccessCount) {
|
||||
toDelete.push(key);
|
||||
}
|
||||
}
|
||||
// Remove stale entries
|
||||
for (const key of toDelete) {
|
||||
this.cache.delete(key);
|
||||
this.stats.evictions++;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Precompute display fields for a batch of entities
|
||||
* @param entities Array of entities with their compute functions
|
||||
* @returns Promise resolving when batch is complete
|
||||
*/
|
||||
async batchPrecompute(entities) {
|
||||
const promises = entities.map(async ({ key, computeFn }) => {
|
||||
if (!this.has(key)) {
|
||||
const startTime = Date.now();
|
||||
try {
|
||||
const fields = await computeFn();
|
||||
const computationTime = Date.now() - startTime;
|
||||
this.set(key, fields, computationTime);
|
||||
}
|
||||
catch (error) {
|
||||
console.warn(`Batch precompute failed for key ${key}:`, error);
|
||||
}
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Request deduplicator for batch processing
|
||||
* Prevents duplicate computations for the same data
|
||||
*/
|
||||
export class RequestDeduplicator {
|
||||
constructor(batchSize = 50) {
|
||||
this.pendingRequests = new Map();
|
||||
this.batchSize = batchSize;
|
||||
}
|
||||
/**
|
||||
* Deduplicate computation request
|
||||
* @param key Unique key for the computation
|
||||
* @param computeFn Function to compute the result
|
||||
* @returns Promise that resolves to the computed fields
|
||||
*/
|
||||
async deduplicate(key, computeFn) {
|
||||
// Return existing promise if already pending
|
||||
if (this.pendingRequests.has(key)) {
|
||||
return this.pendingRequests.get(key);
|
||||
}
|
||||
// Create new computation promise
|
||||
const promise = computeFn().finally(() => {
|
||||
// Remove from pending when complete
|
||||
this.pendingRequests.delete(key);
|
||||
});
|
||||
this.pendingRequests.set(key, promise);
|
||||
return promise;
|
||||
}
|
||||
/**
|
||||
* Get number of pending requests
|
||||
* @returns Number of pending computations
|
||||
*/
|
||||
getPendingCount() {
|
||||
return this.pendingRequests.size;
|
||||
}
|
||||
/**
|
||||
* Clear all pending requests
|
||||
*/
|
||||
clear() {
|
||||
this.pendingRequests.clear();
|
||||
}
|
||||
/**
|
||||
* Shutdown the deduplicator
|
||||
*/
|
||||
shutdown() {
|
||||
this.clear();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Global cache instance management
|
||||
* Provides singleton access to display cache
|
||||
*/
|
||||
let globalDisplayCache = null;
|
||||
/**
|
||||
* Get global display cache instance
|
||||
* @param maxSize Optional cache size (only used on first call)
|
||||
* @returns Shared display cache instance
|
||||
*/
|
||||
export function getGlobalDisplayCache(maxSize) {
|
||||
if (!globalDisplayCache) {
|
||||
globalDisplayCache = new DisplayCache(maxSize);
|
||||
// Set up periodic optimization
|
||||
setInterval(() => {
|
||||
globalDisplayCache?.optimizeCache();
|
||||
}, 60 * 60 * 1000); // Every hour
|
||||
}
|
||||
return globalDisplayCache;
|
||||
}
|
||||
/**
|
||||
* Clear global cache (for testing or memory management)
|
||||
*/
|
||||
export function clearGlobalDisplayCache() {
|
||||
if (globalDisplayCache) {
|
||||
globalDisplayCache.clear();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Shutdown global cache and cleanup
|
||||
*/
|
||||
export function shutdownGlobalDisplayCache() {
|
||||
if (globalDisplayCache) {
|
||||
globalDisplayCache.clear();
|
||||
globalDisplayCache = null;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=cache.js.map
|
||||
File diff suppressed because one or more lines are too long
52
.recovery-workspace/dist-backup-20250910-141917/augmentations/display/fieldPatterns.d.ts
vendored
Normal file
52
.recovery-workspace/dist-backup-20250910-141917/augmentations/display/fieldPatterns.d.ts
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
* Universal Display Augmentation - Smart Field Patterns
|
||||
*
|
||||
* Intelligent field detection patterns for mapping user data to display fields
|
||||
* Uses semantic understanding and common naming conventions
|
||||
*/
|
||||
import type { FieldPattern, FieldComputationContext } from './types.js';
|
||||
/**
|
||||
* Universal field patterns that work across all data types
|
||||
* Ordered by confidence level (highest first)
|
||||
*/
|
||||
export declare const UNIVERSAL_FIELD_PATTERNS: FieldPattern[];
|
||||
/**
|
||||
* Type-specific field patterns for enhanced detection
|
||||
* Used when we know the specific type of the entity
|
||||
*/
|
||||
export declare const TYPE_SPECIFIC_PATTERNS: Record<string, FieldPattern[]>;
|
||||
/**
|
||||
* Get field patterns for a specific entity type
|
||||
* @param entityType The type of entity (noun or verb)
|
||||
* @param specificType Optional specific noun/verb type
|
||||
* @returns Array of applicable field patterns
|
||||
*/
|
||||
export declare function getFieldPatterns(entityType: 'noun' | 'verb', specificType?: string): FieldPattern[];
|
||||
/**
|
||||
* Priority fields for different entity types (for AI analysis)
|
||||
* Used by the BrainyTypes and neural processing
|
||||
*/
|
||||
export declare const TYPE_PRIORITY_FIELDS: Record<string, string[]>;
|
||||
/**
|
||||
* Get priority fields for intelligent analysis
|
||||
* @param entityType The type of entity
|
||||
* @param specificType Optional specific type
|
||||
* @returns Array of priority field names
|
||||
*/
|
||||
export declare function getPriorityFields(entityType: 'noun' | 'verb', specificType?: string): string[];
|
||||
/**
|
||||
* Smart field value extraction with type-aware processing
|
||||
* @param data The data object to extract from
|
||||
* @param pattern The field pattern to apply
|
||||
* @param context The computation context
|
||||
* @returns The extracted and processed field value
|
||||
*/
|
||||
export declare function extractFieldValue(data: any, pattern: FieldPattern, context: FieldComputationContext): any;
|
||||
/**
|
||||
* Calculate confidence score for field detection
|
||||
* @param pattern The field pattern
|
||||
* @param context The computation context
|
||||
* @param value The extracted value
|
||||
* @returns Confidence score (0-1)
|
||||
*/
|
||||
export declare function calculateFieldConfidence(pattern: FieldPattern, context: FieldComputationContext, value: any): number;
|
||||
|
|
@ -0,0 +1,393 @@
|
|||
/**
|
||||
* Universal Display Augmentation - Smart Field Patterns
|
||||
*
|
||||
* Intelligent field detection patterns for mapping user data to display fields
|
||||
* Uses semantic understanding and common naming conventions
|
||||
*/
|
||||
import { NounType } from '../../types/graphTypes.js';
|
||||
/**
|
||||
* Universal field patterns that work across all data types
|
||||
* Ordered by confidence level (highest first)
|
||||
*/
|
||||
export const UNIVERSAL_FIELD_PATTERNS = [
|
||||
// Title/Name Patterns (Highest Priority)
|
||||
{
|
||||
fields: ['name', 'title', 'displayName', 'label', 'heading'],
|
||||
displayField: 'title',
|
||||
confidence: 0.95
|
||||
},
|
||||
{
|
||||
fields: ['firstName', 'lastName', 'fullName', 'realName'],
|
||||
displayField: 'title',
|
||||
confidence: 0.9,
|
||||
applicableTypes: [NounType.Person, NounType.User],
|
||||
transform: (value, context) => {
|
||||
const { metadata } = context;
|
||||
if (metadata.firstName && metadata.lastName) {
|
||||
return `${metadata.firstName} ${metadata.lastName}`.trim();
|
||||
}
|
||||
return String(value || '');
|
||||
}
|
||||
},
|
||||
{
|
||||
fields: ['companyName', 'organizationName', 'orgName', 'businessName'],
|
||||
displayField: 'title',
|
||||
confidence: 0.9,
|
||||
applicableTypes: [NounType.Organization]
|
||||
},
|
||||
{
|
||||
fields: ['filename', 'fileName', 'documentTitle', 'docName'],
|
||||
displayField: 'title',
|
||||
confidence: 0.85,
|
||||
applicableTypes: [NounType.Document, NounType.File, NounType.Media]
|
||||
},
|
||||
{
|
||||
fields: ['projectName', 'projectTitle', 'initiative'],
|
||||
displayField: 'title',
|
||||
confidence: 0.9,
|
||||
applicableTypes: [NounType.Project]
|
||||
},
|
||||
{
|
||||
fields: ['taskName', 'taskTitle', 'action', 'todo'],
|
||||
displayField: 'title',
|
||||
confidence: 0.85,
|
||||
applicableTypes: [NounType.Task]
|
||||
},
|
||||
{
|
||||
fields: ['subject', 'topic', 'headline', 'caption'],
|
||||
displayField: 'title',
|
||||
confidence: 0.8
|
||||
},
|
||||
// Description Patterns (High Priority)
|
||||
{
|
||||
fields: ['description', 'summary', 'overview', 'details'],
|
||||
displayField: 'description',
|
||||
confidence: 0.9
|
||||
},
|
||||
{
|
||||
fields: ['bio', 'biography', 'profile', 'about'],
|
||||
displayField: 'description',
|
||||
confidence: 0.85,
|
||||
applicableTypes: [NounType.Person, NounType.User]
|
||||
},
|
||||
{
|
||||
fields: ['content', 'text', 'body', 'message'],
|
||||
displayField: 'description',
|
||||
confidence: 0.8
|
||||
},
|
||||
{
|
||||
fields: ['abstract', 'excerpt', 'snippet', 'preview'],
|
||||
displayField: 'description',
|
||||
confidence: 0.75
|
||||
},
|
||||
{
|
||||
fields: ['notes', 'comments', 'remarks', 'observations'],
|
||||
displayField: 'description',
|
||||
confidence: 0.7
|
||||
},
|
||||
// Type Patterns (Medium Priority)
|
||||
{
|
||||
fields: ['type', 'category', 'classification', 'kind'],
|
||||
displayField: 'type',
|
||||
confidence: 0.9
|
||||
},
|
||||
{
|
||||
fields: ['nounType', 'entityType', 'objectType'],
|
||||
displayField: 'type',
|
||||
confidence: 0.95
|
||||
},
|
||||
{
|
||||
fields: ['role', 'position', 'jobTitle', 'occupation'],
|
||||
displayField: 'type',
|
||||
confidence: 0.8,
|
||||
applicableTypes: [NounType.Person, NounType.User],
|
||||
transform: (value) => String(value || 'Person')
|
||||
},
|
||||
{
|
||||
fields: ['industry', 'sector', 'domain', 'field'],
|
||||
displayField: 'type',
|
||||
confidence: 0.7,
|
||||
applicableTypes: [NounType.Organization]
|
||||
},
|
||||
// Tag Patterns (Medium Priority)
|
||||
{
|
||||
fields: ['tags', 'keywords', 'labels', 'categories'],
|
||||
displayField: 'tags',
|
||||
confidence: 0.85
|
||||
},
|
||||
{
|
||||
fields: ['topics', 'subjects', 'themes'],
|
||||
displayField: 'tags',
|
||||
confidence: 0.8
|
||||
}
|
||||
];
|
||||
/**
|
||||
* Type-specific field patterns for enhanced detection
|
||||
* Used when we know the specific type of the entity
|
||||
*/
|
||||
export const TYPE_SPECIFIC_PATTERNS = {
|
||||
[NounType.Person]: [
|
||||
{
|
||||
fields: ['email', 'emailAddress', 'contactEmail'],
|
||||
displayField: 'description',
|
||||
confidence: 0.7,
|
||||
transform: (value, context) => {
|
||||
const { metadata } = context;
|
||||
const role = metadata.role || metadata.jobTitle || metadata.position;
|
||||
const company = metadata.company || metadata.organization || metadata.employer;
|
||||
const parts = [];
|
||||
if (role)
|
||||
parts.push(role);
|
||||
if (company)
|
||||
parts.push(`at ${company}`);
|
||||
if (parts.length === 0 && value)
|
||||
parts.push(`Contact: ${value}`);
|
||||
return parts.join(' ') || 'Person';
|
||||
}
|
||||
},
|
||||
{
|
||||
fields: ['phone', 'phoneNumber', 'mobile', 'cell'],
|
||||
displayField: 'tags',
|
||||
confidence: 0.6
|
||||
}
|
||||
],
|
||||
[NounType.Organization]: [
|
||||
{
|
||||
fields: ['website', 'url', 'homepage', 'domain'],
|
||||
displayField: 'description',
|
||||
confidence: 0.7,
|
||||
transform: (value, context) => {
|
||||
const { metadata } = context;
|
||||
const industry = metadata.industry || metadata.sector;
|
||||
const location = metadata.location || metadata.city || metadata.country;
|
||||
const parts = [];
|
||||
if (industry)
|
||||
parts.push(industry);
|
||||
parts.push('organization');
|
||||
if (location)
|
||||
parts.push(`in ${location}`);
|
||||
return parts.join(' ');
|
||||
}
|
||||
},
|
||||
{
|
||||
fields: ['employees', 'size', 'headcount'],
|
||||
displayField: 'tags',
|
||||
confidence: 0.6
|
||||
}
|
||||
],
|
||||
[NounType.Project]: [
|
||||
{
|
||||
fields: ['status', 'phase', 'stage', 'state'],
|
||||
displayField: 'description',
|
||||
confidence: 0.8,
|
||||
transform: (value, context) => {
|
||||
const { metadata } = context;
|
||||
const status = String(value || 'active').toLowerCase();
|
||||
const budget = metadata.budget || metadata.cost;
|
||||
const lead = metadata.lead || metadata.manager || metadata.owner;
|
||||
const parts = [];
|
||||
parts.push(status.charAt(0).toUpperCase() + status.slice(1));
|
||||
if (metadata.description)
|
||||
parts.push('project');
|
||||
if (lead)
|
||||
parts.push(`led by ${lead}`);
|
||||
if (budget)
|
||||
parts.push(`($${parseInt(String(budget)).toLocaleString()} budget)`);
|
||||
return parts.join(' ');
|
||||
}
|
||||
}
|
||||
],
|
||||
[NounType.Document]: [
|
||||
{
|
||||
fields: ['author', 'creator', 'writer'],
|
||||
displayField: 'description',
|
||||
confidence: 0.7,
|
||||
transform: (value, context) => {
|
||||
const { metadata } = context;
|
||||
const docType = metadata.type || metadata.category || 'document';
|
||||
const date = metadata.date || metadata.created || metadata.published;
|
||||
const parts = [];
|
||||
if (docType)
|
||||
parts.push(docType);
|
||||
if (value)
|
||||
parts.push(`by ${value}`);
|
||||
if (date) {
|
||||
const dateStr = new Date(date).toLocaleDateString();
|
||||
parts.push(`(${dateStr})`);
|
||||
}
|
||||
return parts.join(' ');
|
||||
}
|
||||
}
|
||||
],
|
||||
[NounType.Task]: [
|
||||
{
|
||||
fields: ['priority', 'urgency', 'importance'],
|
||||
displayField: 'tags',
|
||||
confidence: 0.7
|
||||
}
|
||||
]
|
||||
};
|
||||
/**
|
||||
* Get field patterns for a specific entity type
|
||||
* @param entityType The type of entity (noun or verb)
|
||||
* @param specificType Optional specific noun/verb type
|
||||
* @returns Array of applicable field patterns
|
||||
*/
|
||||
export function getFieldPatterns(entityType, specificType) {
|
||||
const patterns = [...UNIVERSAL_FIELD_PATTERNS];
|
||||
if (entityType === 'noun' && specificType && TYPE_SPECIFIC_PATTERNS[specificType]) {
|
||||
patterns.unshift(...TYPE_SPECIFIC_PATTERNS[specificType]);
|
||||
}
|
||||
return patterns.sort((a, b) => b.confidence - a.confidence);
|
||||
}
|
||||
/**
|
||||
* Priority fields for different entity types (for AI analysis)
|
||||
* Used by the BrainyTypes and neural processing
|
||||
*/
|
||||
export const TYPE_PRIORITY_FIELDS = {
|
||||
[NounType.Person]: [
|
||||
'name', 'firstName', 'lastName', 'fullName', 'displayName',
|
||||
'email', 'role', 'jobTitle', 'position', 'title',
|
||||
'bio', 'description', 'about', 'profile',
|
||||
'company', 'organization', 'employer'
|
||||
],
|
||||
[NounType.Organization]: [
|
||||
'name', 'companyName', 'organizationName', 'title',
|
||||
'industry', 'sector', 'domain', 'type',
|
||||
'description', 'about', 'summary',
|
||||
'location', 'city', 'country', 'headquarters',
|
||||
'website', 'url'
|
||||
],
|
||||
[NounType.Project]: [
|
||||
'name', 'projectName', 'title', 'projectTitle',
|
||||
'description', 'summary', 'overview', 'goal',
|
||||
'status', 'phase', 'stage', 'state',
|
||||
'lead', 'manager', 'owner', 'team',
|
||||
'budget', 'timeline', 'deadline'
|
||||
],
|
||||
[NounType.Document]: [
|
||||
'title', 'filename', 'name', 'subject',
|
||||
'content', 'text', 'body', 'summary',
|
||||
'author', 'creator', 'writer',
|
||||
'type', 'category', 'format',
|
||||
'date', 'created', 'published'
|
||||
],
|
||||
[NounType.Task]: [
|
||||
'title', 'name', 'taskName', 'action',
|
||||
'description', 'details', 'notes',
|
||||
'status', 'state', 'priority',
|
||||
'assignee', 'owner', 'responsible',
|
||||
'due', 'deadline', 'dueDate'
|
||||
],
|
||||
[NounType.Event]: [
|
||||
'name', 'title', 'eventName',
|
||||
'description', 'details', 'summary',
|
||||
'startDate', 'endDate', 'date', 'time',
|
||||
'location', 'venue', 'address',
|
||||
'organizer', 'host', 'creator'
|
||||
],
|
||||
[NounType.Product]: [
|
||||
'name', 'productName', 'title',
|
||||
'description', 'summary', 'features',
|
||||
'price', 'cost', 'value',
|
||||
'category', 'type', 'brand',
|
||||
'manufacturer', 'vendor'
|
||||
]
|
||||
};
|
||||
/**
|
||||
* Get priority fields for intelligent analysis
|
||||
* @param entityType The type of entity
|
||||
* @param specificType Optional specific type
|
||||
* @returns Array of priority field names
|
||||
*/
|
||||
export function getPriorityFields(entityType, specificType) {
|
||||
if (entityType === 'noun' && specificType && TYPE_PRIORITY_FIELDS[specificType]) {
|
||||
return TYPE_PRIORITY_FIELDS[specificType];
|
||||
}
|
||||
// Default priority fields for any entity
|
||||
return [
|
||||
'name', 'title', 'label', 'displayName',
|
||||
'description', 'summary', 'about', 'details',
|
||||
'type', 'category', 'kind', 'classification',
|
||||
'tags', 'keywords', 'labels'
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Smart field value extraction with type-aware processing
|
||||
* @param data The data object to extract from
|
||||
* @param pattern The field pattern to apply
|
||||
* @param context The computation context
|
||||
* @returns The extracted and processed field value
|
||||
*/
|
||||
export function extractFieldValue(data, pattern, context) {
|
||||
// Find the first matching field
|
||||
let value = null;
|
||||
let matchedField = null;
|
||||
for (const field of pattern.fields) {
|
||||
if (data[field] !== undefined && data[field] !== null && data[field] !== '') {
|
||||
value = data[field];
|
||||
matchedField = field;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (value === null)
|
||||
return null;
|
||||
// Apply transformation if provided
|
||||
if (pattern.transform) {
|
||||
try {
|
||||
return pattern.transform(value, context);
|
||||
}
|
||||
catch (error) {
|
||||
console.warn(`Field transformation error for ${matchedField}:`, error);
|
||||
return String(value);
|
||||
}
|
||||
}
|
||||
// Default processing based on display field type
|
||||
switch (pattern.displayField) {
|
||||
case 'title':
|
||||
case 'description':
|
||||
case 'type':
|
||||
return String(value);
|
||||
case 'tags':
|
||||
if (Array.isArray(value))
|
||||
return value;
|
||||
if (typeof value === 'string') {
|
||||
return value.split(/[,;]\s*|\s+/).filter(Boolean);
|
||||
}
|
||||
return [String(value)];
|
||||
default:
|
||||
return value;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Calculate confidence score for field detection
|
||||
* @param pattern The field pattern
|
||||
* @param context The computation context
|
||||
* @param value The extracted value
|
||||
* @returns Confidence score (0-1)
|
||||
*/
|
||||
export function calculateFieldConfidence(pattern, context, value) {
|
||||
let confidence = pattern.confidence;
|
||||
// Boost confidence if type matches
|
||||
if (pattern.applicableTypes && context.typeResult) {
|
||||
if (pattern.applicableTypes.includes(context.typeResult.type)) {
|
||||
confidence = Math.min(1.0, confidence + 0.1);
|
||||
}
|
||||
}
|
||||
// Reduce confidence for empty or very short values
|
||||
if (typeof value === 'string') {
|
||||
if (value.length < 2) {
|
||||
confidence *= 0.5;
|
||||
}
|
||||
else if (value.length < 5) {
|
||||
confidence *= 0.8;
|
||||
}
|
||||
}
|
||||
// Reduce confidence for generic values
|
||||
const genericValues = ['unknown', 'n/a', 'null', 'undefined', 'default'];
|
||||
if (typeof value === 'string' && genericValues.includes(value.toLowerCase())) {
|
||||
confidence *= 0.3;
|
||||
}
|
||||
return Math.max(0, Math.min(1, confidence));
|
||||
}
|
||||
//# sourceMappingURL=fieldPatterns.js.map
|
||||
File diff suppressed because one or more lines are too long
57
.recovery-workspace/dist-backup-20250910-141917/augmentations/display/iconMappings.d.ts
vendored
Normal file
57
.recovery-workspace/dist-backup-20250910-141917/augmentations/display/iconMappings.d.ts
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* Universal Display Augmentation - Clean Display
|
||||
*
|
||||
* Simple, clean display without icons - focusing on AI-powered
|
||||
* titles, descriptions, and smart formatting that matches
|
||||
* Soulcraft's minimal aesthetic
|
||||
*/
|
||||
/**
|
||||
* No icon mappings - clean, minimal approach
|
||||
* The real value is in AI-generated titles and enhanced descriptions,
|
||||
* not visual clutter that doesn't align with professional aesthetics
|
||||
*/
|
||||
export declare const NOUN_TYPE_ICONS: Record<string, string>;
|
||||
/**
|
||||
* No icon mappings for verbs either - focus on clear relationship descriptions
|
||||
* Human-readable relationship text is more valuable than symbolic representations
|
||||
*/
|
||||
export declare const VERB_TYPE_ICONS: Record<string, string>;
|
||||
/**
|
||||
* Get icon for a noun type (returns empty string for clean display)
|
||||
* @param type The noun type
|
||||
* @returns Empty string (no icons)
|
||||
*/
|
||||
export declare function getNounIcon(type: string): string;
|
||||
/**
|
||||
* Get icon for a verb type (returns empty string for clean display)
|
||||
* @param type The verb type
|
||||
* @returns Empty string (no icons)
|
||||
*/
|
||||
export declare function getVerbIcon(type: string): string;
|
||||
/**
|
||||
* Get coverage statistics (for backwards compatibility)
|
||||
* @returns Coverage info showing clean approach
|
||||
*/
|
||||
export declare function getIconCoverage(): {
|
||||
nounTypes: {
|
||||
total: string;
|
||||
covered: string;
|
||||
};
|
||||
verbTypes: {
|
||||
total: string;
|
||||
covered: string;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Check if an icon exists for a type (always false for clean display)
|
||||
* @param type The type to check
|
||||
* @param entityType Whether it's a noun or verb
|
||||
* @returns Always false (no icons)
|
||||
*/
|
||||
export declare function hasIcon(type: string, entityType?: 'noun' | 'verb'): boolean;
|
||||
/**
|
||||
* Get fallback icon (returns empty string for clean display)
|
||||
* @param entityType The entity type
|
||||
* @returns Empty string (no fallback icons)
|
||||
*/
|
||||
export declare function getFallbackIcon(entityType?: 'noun' | 'verb'): string;
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
* Universal Display Augmentation - Clean Display
|
||||
*
|
||||
* Simple, clean display without icons - focusing on AI-powered
|
||||
* titles, descriptions, and smart formatting that matches
|
||||
* Soulcraft's minimal aesthetic
|
||||
*/
|
||||
/**
|
||||
* No icon mappings - clean, minimal approach
|
||||
* The real value is in AI-generated titles and enhanced descriptions,
|
||||
* not visual clutter that doesn't align with professional aesthetics
|
||||
*/
|
||||
export const NOUN_TYPE_ICONS = {};
|
||||
/**
|
||||
* No icon mappings for verbs either - focus on clear relationship descriptions
|
||||
* Human-readable relationship text is more valuable than symbolic representations
|
||||
*/
|
||||
export const VERB_TYPE_ICONS = {};
|
||||
/**
|
||||
* Get icon for a noun type (returns empty string for clean display)
|
||||
* @param type The noun type
|
||||
* @returns Empty string (no icons)
|
||||
*/
|
||||
export function getNounIcon(type) {
|
||||
return ''; // Clean, no icons
|
||||
}
|
||||
/**
|
||||
* Get icon for a verb type (returns empty string for clean display)
|
||||
* @param type The verb type
|
||||
* @returns Empty string (no icons)
|
||||
*/
|
||||
export function getVerbIcon(type) {
|
||||
return ''; // Clean, no icons
|
||||
}
|
||||
/**
|
||||
* Get coverage statistics (for backwards compatibility)
|
||||
* @returns Coverage info showing clean approach
|
||||
*/
|
||||
export function getIconCoverage() {
|
||||
return {
|
||||
nounTypes: {
|
||||
total: 'Clean display - no icons needed',
|
||||
covered: 'Focus on AI-powered content'
|
||||
},
|
||||
verbTypes: {
|
||||
total: 'Clean display - no icons needed',
|
||||
covered: 'Focus on relationship descriptions'
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Check if an icon exists for a type (always false for clean display)
|
||||
* @param type The type to check
|
||||
* @param entityType Whether it's a noun or verb
|
||||
* @returns Always false (no icons)
|
||||
*/
|
||||
export function hasIcon(type, entityType = 'noun') {
|
||||
return false; // Clean approach - no icons
|
||||
}
|
||||
/**
|
||||
* Get fallback icon (returns empty string for clean display)
|
||||
* @param entityType The entity type
|
||||
* @returns Empty string (no fallback icons)
|
||||
*/
|
||||
export function getFallbackIcon(entityType = 'noun') {
|
||||
return ''; // Clean, minimal display
|
||||
}
|
||||
//# sourceMappingURL=iconMappings.js.map
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"iconMappings.js","sourceRoot":"","sources":["../../../src/augmentations/display/iconMappings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAA2B,EAAE,CAAA;AAEzD;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAA2B,EAAE,CAAA;AAEzD;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,EAAE,CAAA,CAAC,kBAAkB;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,EAAE,CAAA,CAAC,kBAAkB;AAC9B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO;QACL,SAAS,EAAE;YACT,KAAK,EAAE,iCAAiC;YACxC,OAAO,EAAE,6BAA6B;SACvC;QACD,SAAS,EAAE;YACT,KAAK,EAAE,iCAAiC;YACxC,OAAO,EAAE,oCAAoC;SAC9C;KACF,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,aAA8B,MAAM;IACxE,OAAO,KAAK,CAAA,CAAC,4BAA4B;AAC3C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,aAA8B,MAAM;IAClE,OAAO,EAAE,CAAA,CAAC,yBAAyB;AACrC,CAAC"}
|
||||
109
.recovery-workspace/dist-backup-20250910-141917/augmentations/display/intelligentComputation.d.ts
vendored
Normal file
109
.recovery-workspace/dist-backup-20250910-141917/augmentations/display/intelligentComputation.d.ts
vendored
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/**
|
||||
* Universal Display Augmentation - Intelligent Computation Engine
|
||||
*
|
||||
* Leverages existing Brainy AI infrastructure for intelligent field computation:
|
||||
* - BrainyTypes for semantic type detection
|
||||
* - Neural Import patterns for field analysis
|
||||
* - JSON processing utilities for field extraction
|
||||
* - Existing NounType/VerbType taxonomy (31+40 types)
|
||||
*/
|
||||
import type { ComputedDisplayFields, DisplayConfig } from './types.js';
|
||||
import type { GraphVerb } from '../../coreTypes.js';
|
||||
/**
|
||||
* Intelligent field computation engine
|
||||
* Coordinates AI-powered analysis with fallback heuristics
|
||||
*/
|
||||
export declare class IntelligentComputationEngine {
|
||||
private typeMatcher;
|
||||
protected config: DisplayConfig;
|
||||
private initialized;
|
||||
constructor(config: DisplayConfig);
|
||||
/**
|
||||
* Initialize the computation engine with AI components
|
||||
*/
|
||||
initialize(): Promise<void>;
|
||||
/**
|
||||
* Compute display fields for a noun using AI-first approach
|
||||
* @param data The noun data/metadata
|
||||
* @param id Optional noun ID
|
||||
* @returns Computed display fields
|
||||
*/
|
||||
computeNounDisplay(data: any, id?: string): Promise<ComputedDisplayFields>;
|
||||
/**
|
||||
* Compute display fields for a verb using AI-first approach
|
||||
* @param verb The verb/relationship data
|
||||
* @returns Computed display fields
|
||||
*/
|
||||
computeVerbDisplay(verb: GraphVerb): Promise<ComputedDisplayFields>;
|
||||
/**
|
||||
* AI-powered computation using your existing BrainyTypes
|
||||
* @param data Entity data/metadata
|
||||
* @param entityType Type of entity (noun/verb)
|
||||
* @param options Additional options
|
||||
* @returns AI-computed display fields
|
||||
*/
|
||||
private computeWithAI;
|
||||
/**
|
||||
* AI-powered verb computation using relationship analysis
|
||||
* @param verb The verb/relationship
|
||||
* @returns AI-computed display fields
|
||||
*/
|
||||
private computeVerbWithAI;
|
||||
/**
|
||||
* Heuristic computation when AI is unavailable
|
||||
* @param data Entity data
|
||||
* @param entityType Type of entity
|
||||
* @param options Additional options
|
||||
* @returns Heuristically computed display fields
|
||||
*/
|
||||
private computeWithHeuristics;
|
||||
/**
|
||||
* Compute intelligent title using AI insights and your field extraction
|
||||
* @param context Computation context with AI results
|
||||
* @returns Computed title
|
||||
*/
|
||||
private computeIntelligentTitle;
|
||||
/**
|
||||
* Compute intelligent description using AI insights and context
|
||||
* @param context Computation context
|
||||
* @returns Enhanced description
|
||||
*/
|
||||
private computeIntelligentDescription;
|
||||
/**
|
||||
* Compute intelligent tags using type analysis
|
||||
* @param context Computation context
|
||||
* @returns Generated tags array
|
||||
*/
|
||||
private computeIntelligentTags;
|
||||
/**
|
||||
* Compute verb title (relationship summary)
|
||||
* @param context Verb computation context
|
||||
* @returns Verb title
|
||||
*/
|
||||
private computeVerbTitle;
|
||||
/**
|
||||
* Create minimal display for error cases
|
||||
* @param data Entity data
|
||||
* @param entityType Entity type
|
||||
* @returns Minimal display fields
|
||||
*/
|
||||
private createMinimalDisplay;
|
||||
private computePersonTitle;
|
||||
private computeOrganizationTitle;
|
||||
private computeProjectTitle;
|
||||
private computeDocumentTitle;
|
||||
private extractBestTitle;
|
||||
private createContextAwareDescription;
|
||||
private extractExplicitTags;
|
||||
private generateSemanticTags;
|
||||
private getReadableVerbPhrase;
|
||||
private computeVerbDescription;
|
||||
private computeVerbTags;
|
||||
private computeHumanReadableRelationship;
|
||||
private detectTypeHeuristically;
|
||||
private extractFieldWithPatterns;
|
||||
/**
|
||||
* Shutdown the computation engine
|
||||
*/
|
||||
shutdown(): Promise<void>;
|
||||
}
|
||||
|
|
@ -0,0 +1,462 @@
|
|||
/**
|
||||
* Universal Display Augmentation - Intelligent Computation Engine
|
||||
*
|
||||
* Leverages existing Brainy AI infrastructure for intelligent field computation:
|
||||
* - BrainyTypes for semantic type detection
|
||||
* - Neural Import patterns for field analysis
|
||||
* - JSON processing utilities for field extraction
|
||||
* - Existing NounType/VerbType taxonomy (31+40 types)
|
||||
*/
|
||||
import { getBrainyTypes } from '../typeMatching/brainyTypes.js';
|
||||
import { getFieldPatterns, getPriorityFields } from './fieldPatterns.js';
|
||||
import { prepareJsonForVectorization } from '../../utils/jsonProcessing.js';
|
||||
import { NounType, VerbType } from '../../types/graphTypes.js';
|
||||
/**
|
||||
* Intelligent field computation engine
|
||||
* Coordinates AI-powered analysis with fallback heuristics
|
||||
*/
|
||||
export class IntelligentComputationEngine {
|
||||
constructor(config) {
|
||||
this.typeMatcher = null;
|
||||
this.initialized = false;
|
||||
this.config = config;
|
||||
}
|
||||
/**
|
||||
* Initialize the computation engine with AI components
|
||||
*/
|
||||
async initialize() {
|
||||
if (this.initialized)
|
||||
return;
|
||||
try {
|
||||
// 🧠 LEVERAGE YOUR EXISTING AI INFRASTRUCTURE
|
||||
this.typeMatcher = await getBrainyTypes();
|
||||
if (this.typeMatcher) {
|
||||
console.log('🎨 Display computation engine initialized with AI intelligence');
|
||||
}
|
||||
else {
|
||||
console.warn('🎨 Display computation engine running in basic mode (AI unavailable)');
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.warn('🎨 AI initialization failed, using heuristic fallback:', error);
|
||||
}
|
||||
this.initialized = true;
|
||||
}
|
||||
/**
|
||||
* Compute display fields for a noun using AI-first approach
|
||||
* @param data The noun data/metadata
|
||||
* @param id Optional noun ID
|
||||
* @returns Computed display fields
|
||||
*/
|
||||
async computeNounDisplay(data, id) {
|
||||
const startTime = Date.now();
|
||||
try {
|
||||
// 🟢 PRIMARY PATH: Use your existing AI intelligence
|
||||
if (this.typeMatcher) {
|
||||
return await this.computeWithAI(data, 'noun', { id });
|
||||
}
|
||||
// 🟡 FALLBACK PATH: Use heuristic patterns
|
||||
return await this.computeWithHeuristics(data, 'noun', { id });
|
||||
}
|
||||
catch (error) {
|
||||
console.warn('Display computation failed, using minimal fallback:', error);
|
||||
return this.createMinimalDisplay(data, 'noun');
|
||||
}
|
||||
finally {
|
||||
const computationTime = Date.now() - startTime;
|
||||
if (this.config.debugMode) {
|
||||
console.log(`Display computation took ${computationTime}ms`);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Compute display fields for a verb using AI-first approach
|
||||
* @param verb The verb/relationship data
|
||||
* @returns Computed display fields
|
||||
*/
|
||||
async computeVerbDisplay(verb) {
|
||||
const startTime = Date.now();
|
||||
try {
|
||||
// 🟢 PRIMARY PATH: Use your existing AI for verb analysis
|
||||
if (this.typeMatcher) {
|
||||
return await this.computeVerbWithAI(verb);
|
||||
}
|
||||
// 🟡 FALLBACK PATH: Use heuristic patterns for verbs
|
||||
return await this.computeWithHeuristics(verb, 'verb');
|
||||
}
|
||||
catch (error) {
|
||||
console.warn('Verb display computation failed, using minimal fallback:', error);
|
||||
return this.createMinimalDisplay(verb, 'verb');
|
||||
}
|
||||
finally {
|
||||
const computationTime = Date.now() - startTime;
|
||||
if (this.config.debugMode) {
|
||||
console.log(`Verb display computation took ${computationTime}ms`);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* AI-powered computation using your existing BrainyTypes
|
||||
* @param data Entity data/metadata
|
||||
* @param entityType Type of entity (noun/verb)
|
||||
* @param options Additional options
|
||||
* @returns AI-computed display fields
|
||||
*/
|
||||
async computeWithAI(data, entityType, options = {}) {
|
||||
// 🧠 USE YOUR EXISTING TYPE DETECTION AI
|
||||
const typeResult = await this.typeMatcher.matchNounType(data);
|
||||
// Create computation context
|
||||
const context = {
|
||||
data,
|
||||
metadata: data,
|
||||
typeResult,
|
||||
config: this.config,
|
||||
entityType
|
||||
};
|
||||
// 🟢 INTELLIGENT FIELD EXTRACTION using your patterns + AI insights
|
||||
const displayFields = {
|
||||
title: await this.computeIntelligentTitle(context),
|
||||
description: await this.computeIntelligentDescription(context),
|
||||
type: typeResult.type,
|
||||
tags: await this.computeIntelligentTags(context),
|
||||
confidence: typeResult.confidence,
|
||||
reasoning: this.config.debugMode ? typeResult.reasoning : undefined,
|
||||
alternatives: this.config.debugMode ? typeResult.alternatives : undefined,
|
||||
computedAt: Date.now(),
|
||||
version: '1.0.0'
|
||||
};
|
||||
return displayFields;
|
||||
}
|
||||
/**
|
||||
* AI-powered verb computation using relationship analysis
|
||||
* @param verb The verb/relationship
|
||||
* @returns AI-computed display fields
|
||||
*/
|
||||
async computeVerbWithAI(verb) {
|
||||
// 🧠 USE YOUR EXISTING VERB TYPE DETECTION
|
||||
const typeResult = await this.typeMatcher.matchVerbType(verb, 0.7);
|
||||
// Create verb computation context
|
||||
const context = {
|
||||
data: verb,
|
||||
metadata: verb.metadata || {},
|
||||
typeResult,
|
||||
config: this.config,
|
||||
entityType: 'verb',
|
||||
verbContext: {
|
||||
sourceId: verb.sourceId,
|
||||
targetId: verb.targetId,
|
||||
verbType: verb.type
|
||||
}
|
||||
};
|
||||
// 🟢 INTELLIGENT VERB DISPLAY COMPUTATION
|
||||
const displayFields = {
|
||||
title: await this.computeVerbTitle(context),
|
||||
description: await this.computeVerbDescription(context),
|
||||
type: typeResult.type,
|
||||
tags: await this.computeVerbTags(context),
|
||||
relationship: await this.computeHumanReadableRelationship(context),
|
||||
confidence: typeResult.confidence,
|
||||
reasoning: this.config.debugMode ? typeResult.reasoning : undefined,
|
||||
alternatives: this.config.debugMode ? typeResult.alternatives : undefined,
|
||||
computedAt: Date.now(),
|
||||
version: '1.0.0'
|
||||
};
|
||||
return displayFields;
|
||||
}
|
||||
/**
|
||||
* Heuristic computation when AI is unavailable
|
||||
* @param data Entity data
|
||||
* @param entityType Type of entity
|
||||
* @param options Additional options
|
||||
* @returns Heuristically computed display fields
|
||||
*/
|
||||
async computeWithHeuristics(data, entityType, options = {}) {
|
||||
// Use basic type detection
|
||||
const detectedType = this.detectTypeHeuristically(data, entityType);
|
||||
const typeResult = {
|
||||
type: detectedType,
|
||||
confidence: 0.6, // Lower confidence for heuristics
|
||||
reasoning: 'Heuristic detection (AI unavailable)',
|
||||
alternatives: []
|
||||
};
|
||||
const context = {
|
||||
data,
|
||||
metadata: data,
|
||||
typeResult: typeResult,
|
||||
config: this.config,
|
||||
entityType
|
||||
};
|
||||
// Use pattern-based field extraction
|
||||
const patterns = getFieldPatterns(entityType, detectedType);
|
||||
return {
|
||||
title: this.extractFieldWithPatterns(data, patterns, 'title') || 'Untitled',
|
||||
description: this.extractFieldWithPatterns(data, patterns, 'description') || 'No description',
|
||||
type: detectedType,
|
||||
tags: this.extractFieldWithPatterns(data, patterns, 'tags') || [],
|
||||
confidence: typeResult.confidence,
|
||||
reasoning: this.config.debugMode ? typeResult.reasoning : undefined,
|
||||
computedAt: Date.now(),
|
||||
version: '1.0.0'
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Compute intelligent title using AI insights and your field extraction
|
||||
* @param context Computation context with AI results
|
||||
* @returns Computed title
|
||||
*/
|
||||
async computeIntelligentTitle(context) {
|
||||
const { data, typeResult } = context;
|
||||
// 🟢 USE TYPE-SPECIFIC LOGIC based on your NounType taxonomy
|
||||
switch (typeResult?.type) {
|
||||
case NounType.Person:
|
||||
return this.computePersonTitle(data);
|
||||
case NounType.Organization:
|
||||
return this.computeOrganizationTitle(data);
|
||||
case NounType.Project:
|
||||
return this.computeProjectTitle(data);
|
||||
case NounType.Document:
|
||||
return this.computeDocumentTitle(data);
|
||||
default:
|
||||
// 🟢 LEVERAGE YOUR JSON PROCESSING for unknown types
|
||||
return this.extractBestTitle(data, typeResult?.type);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Compute intelligent description using AI insights and context
|
||||
* @param context Computation context
|
||||
* @returns Enhanced description
|
||||
*/
|
||||
async computeIntelligentDescription(context) {
|
||||
const { data, typeResult } = context;
|
||||
// 🟢 USE YOUR EXISTING JSON PROCESSING for vectorization-quality text
|
||||
const priorityFields = getPriorityFields('noun', typeResult?.type);
|
||||
const enhancedText = prepareJsonForVectorization(data, {
|
||||
priorityFields,
|
||||
includeFieldNames: false,
|
||||
maxDepth: 2
|
||||
});
|
||||
// Create context-aware description based on type
|
||||
return this.createContextAwareDescription(data, typeResult, enhancedText);
|
||||
}
|
||||
/**
|
||||
* Compute intelligent tags using type analysis
|
||||
* @param context Computation context
|
||||
* @returns Generated tags array
|
||||
*/
|
||||
async computeIntelligentTags(context) {
|
||||
const { data, typeResult } = context;
|
||||
const tags = [];
|
||||
// Add type-based tag
|
||||
if (typeResult?.type) {
|
||||
tags.push(typeResult.type.toLowerCase());
|
||||
}
|
||||
// Extract explicit tags from data
|
||||
const explicitTags = this.extractExplicitTags(data);
|
||||
tags.push(...explicitTags);
|
||||
// Add semantic tags based on AI analysis
|
||||
if (typeResult && this.typeMatcher) {
|
||||
const semanticTags = this.generateSemanticTags(data, typeResult);
|
||||
tags.push(...semanticTags);
|
||||
}
|
||||
// Remove duplicates and return
|
||||
return [...new Set(tags.filter(Boolean))];
|
||||
}
|
||||
/**
|
||||
* Compute verb title (relationship summary)
|
||||
* @param context Verb computation context
|
||||
* @returns Verb title
|
||||
*/
|
||||
async computeVerbTitle(context) {
|
||||
const { verbContext, typeResult } = context;
|
||||
if (!verbContext)
|
||||
return 'Relationship';
|
||||
const { sourceId, targetId } = verbContext;
|
||||
const relationshipType = typeResult?.type || 'RelatedTo';
|
||||
// Try to get readable names for source and target
|
||||
// This could be enhanced to actually resolve the entities
|
||||
return `${sourceId} ${this.getReadableVerbPhrase(relationshipType)} ${targetId}`;
|
||||
}
|
||||
/**
|
||||
* Create minimal display for error cases
|
||||
* @param data Entity data
|
||||
* @param entityType Entity type
|
||||
* @returns Minimal display fields
|
||||
*/
|
||||
createMinimalDisplay(data, entityType) {
|
||||
return {
|
||||
title: data.name || data.title || data.id || 'Untitled',
|
||||
description: data.description || data.summary || 'No description available',
|
||||
type: entityType === 'noun' ? 'Item' : 'RelatedTo',
|
||||
tags: [],
|
||||
confidence: 0.1, // Very low confidence for fallback
|
||||
computedAt: Date.now(),
|
||||
version: '1.0.0'
|
||||
};
|
||||
}
|
||||
// Helper methods for specific noun types
|
||||
computePersonTitle(data) {
|
||||
if (data.firstName && data.lastName) {
|
||||
return `${data.firstName} ${data.lastName}`.trim();
|
||||
}
|
||||
return data.name || data.fullName || data.displayName || data.firstName || data.lastName || 'Person';
|
||||
}
|
||||
computeOrganizationTitle(data) {
|
||||
return data.name || data.companyName || data.organizationName || data.title || 'Organization';
|
||||
}
|
||||
computeProjectTitle(data) {
|
||||
return data.name || data.projectName || data.title || data.projectTitle || 'Project';
|
||||
}
|
||||
computeDocumentTitle(data) {
|
||||
return data.title || data.filename || data.name || data.subject || 'Document';
|
||||
}
|
||||
extractBestTitle(data, type) {
|
||||
const titleFields = ['name', 'title', 'displayName', 'label', 'subject', 'heading'];
|
||||
for (const field of titleFields) {
|
||||
if (data[field])
|
||||
return String(data[field]);
|
||||
}
|
||||
return data.id || Object.keys(data)[0] || 'Untitled';
|
||||
}
|
||||
createContextAwareDescription(data, typeResult, enhancedText) {
|
||||
// Start with basic description fields
|
||||
const basicDesc = data.description || data.summary || data.about || data.details;
|
||||
if (basicDesc)
|
||||
return String(basicDesc);
|
||||
// Use enhanced text from JSON processing
|
||||
if (enhancedText && enhancedText.length > 10) {
|
||||
return enhancedText.substring(0, 200) + (enhancedText.length > 200 ? '...' : '');
|
||||
}
|
||||
// Generate from available fields
|
||||
const parts = [];
|
||||
if (data.role)
|
||||
parts.push(data.role);
|
||||
if (data.company)
|
||||
parts.push(`at ${data.company}`);
|
||||
if (data.location)
|
||||
parts.push(`in ${data.location}`);
|
||||
return parts.length > 0 ? parts.join(' ') : 'No description available';
|
||||
}
|
||||
extractExplicitTags(data) {
|
||||
const tagFields = ['tags', 'keywords', 'labels', 'categories', 'topics'];
|
||||
for (const field of tagFields) {
|
||||
if (data[field]) {
|
||||
if (Array.isArray(data[field])) {
|
||||
return data[field].map(String).filter(Boolean);
|
||||
}
|
||||
if (typeof data[field] === 'string') {
|
||||
return data[field].split(/[,;]\s*|\s+/).filter(Boolean);
|
||||
}
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
generateSemanticTags(data, typeResult) {
|
||||
const tags = [];
|
||||
// Add confidence-based tags
|
||||
if (typeResult.confidence > 0.9)
|
||||
tags.push('verified');
|
||||
else if (typeResult.confidence < 0.7)
|
||||
tags.push('uncertain');
|
||||
// Add type-specific semantic tags
|
||||
if (data.status)
|
||||
tags.push(String(data.status).toLowerCase());
|
||||
if (data.priority)
|
||||
tags.push(String(data.priority).toLowerCase());
|
||||
if (data.category)
|
||||
tags.push(String(data.category).toLowerCase());
|
||||
return tags;
|
||||
}
|
||||
getReadableVerbPhrase(verbType) {
|
||||
const verbPhrases = {
|
||||
[VerbType.WorksWith]: 'works with',
|
||||
[VerbType.MemberOf]: 'is member of',
|
||||
[VerbType.ReportsTo]: 'reports to',
|
||||
[VerbType.CreatedBy]: 'created by',
|
||||
[VerbType.Owns]: 'owns',
|
||||
[VerbType.LocatedAt]: 'located at',
|
||||
[VerbType.Likes]: 'likes',
|
||||
[VerbType.Follows]: 'follows',
|
||||
[VerbType.Supervises]: 'supervises'
|
||||
};
|
||||
return verbPhrases[verbType] || 'related to';
|
||||
}
|
||||
async computeVerbDescription(context) {
|
||||
const { data, verbContext, typeResult } = context;
|
||||
if (data.description)
|
||||
return String(data.description);
|
||||
// Generate contextual description for relationship
|
||||
if (verbContext && typeResult) {
|
||||
const parts = [];
|
||||
const relationshipPhrase = this.getReadableVerbPhrase(typeResult.type);
|
||||
if (data.role)
|
||||
parts.push(`Role: ${data.role}`);
|
||||
if (data.startDate)
|
||||
parts.push(`Since: ${new Date(data.startDate).toLocaleDateString()}`);
|
||||
if (data.department)
|
||||
parts.push(`Department: ${data.department}`);
|
||||
return parts.length > 0
|
||||
? `${relationshipPhrase} - ${parts.join(', ')}`
|
||||
: `${relationshipPhrase} relationship`;
|
||||
}
|
||||
return 'Relationship';
|
||||
}
|
||||
async computeVerbTags(context) {
|
||||
const { data, typeResult } = context;
|
||||
const tags = ['relationship'];
|
||||
if (typeResult?.type) {
|
||||
tags.push(typeResult.type.toLowerCase());
|
||||
}
|
||||
// Add relationship-specific tags
|
||||
if (data.status)
|
||||
tags.push(String(data.status).toLowerCase());
|
||||
if (data.type)
|
||||
tags.push(String(data.type).toLowerCase());
|
||||
return [...new Set(tags)];
|
||||
}
|
||||
async computeHumanReadableRelationship(context) {
|
||||
const { verbContext, typeResult } = context;
|
||||
if (!verbContext || !typeResult)
|
||||
return 'Related';
|
||||
const { sourceId, targetId } = verbContext;
|
||||
const phrase = this.getReadableVerbPhrase(typeResult.type);
|
||||
return `${sourceId} ${phrase} ${targetId}`;
|
||||
}
|
||||
detectTypeHeuristically(data, entityType) {
|
||||
if (entityType === 'verb')
|
||||
return VerbType.RelatedTo;
|
||||
// Basic heuristics for noun types
|
||||
if (data.firstName || data.lastName || data.email)
|
||||
return NounType.Person;
|
||||
if (data.companyName || data.organization)
|
||||
return NounType.Organization;
|
||||
if (data.filename || data.fileType)
|
||||
return NounType.Document;
|
||||
if (data.projectName || data.initiative)
|
||||
return NounType.Project;
|
||||
if (data.taskName || data.todo)
|
||||
return NounType.Task;
|
||||
if (data.startDate || data.endDate)
|
||||
return NounType.Event;
|
||||
return 'Item'; // Generic fallback
|
||||
}
|
||||
extractFieldWithPatterns(data, patterns, fieldType) {
|
||||
const relevantPatterns = patterns.filter(p => p.displayField === fieldType);
|
||||
for (const pattern of relevantPatterns) {
|
||||
for (const field of pattern.fields) {
|
||||
if (data[field]) {
|
||||
return pattern.transform ? pattern.transform(data[field], { data, config: this.config }) : data[field];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Shutdown the computation engine
|
||||
*/
|
||||
async shutdown() {
|
||||
// Cleanup if needed
|
||||
this.typeMatcher = null;
|
||||
this.initialized = false;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=intelligentComputation.js.map
|
||||
File diff suppressed because one or more lines are too long
203
.recovery-workspace/dist-backup-20250910-141917/augmentations/display/types.d.ts
vendored
Normal file
203
.recovery-workspace/dist-backup-20250910-141917/augmentations/display/types.d.ts
vendored
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
/**
|
||||
* Universal Display Augmentation - Type Definitions
|
||||
*
|
||||
* Clean TypeScript interfaces for the display augmentation system
|
||||
*/
|
||||
import type { VectorDocument, GraphVerb } from '../../coreTypes.js';
|
||||
/**
|
||||
* Configuration interface for the Universal Display Augmentation
|
||||
*/
|
||||
export interface DisplayConfig {
|
||||
/** Enable/disable the augmentation */
|
||||
enabled: boolean;
|
||||
/** LRU cache size for computed display fields */
|
||||
cacheSize: number;
|
||||
/** Use lazy computation (recommended for performance) */
|
||||
lazyComputation: boolean;
|
||||
/** Batch processing size for multiple requests */
|
||||
batchSize: number;
|
||||
/** Minimum confidence threshold for AI type detection */
|
||||
confidenceThreshold: number;
|
||||
/** Custom field mappings (userField -> displayField) */
|
||||
customFieldMappings: Record<string, string>;
|
||||
/** Type-specific priority fields for intelligent detection */
|
||||
priorityFields: Record<string, string[]>;
|
||||
/** Enable debug mode with reasoning output */
|
||||
debugMode: boolean;
|
||||
}
|
||||
/**
|
||||
* Computed display fields for any noun or verb
|
||||
*/
|
||||
export interface ComputedDisplayFields {
|
||||
/** Primary display name (AI-detected best field combination) */
|
||||
title: string;
|
||||
/** Enhanced description with context awareness */
|
||||
description: string;
|
||||
/** Human-readable type name */
|
||||
type: string;
|
||||
/** Generated display tags for categorization */
|
||||
tags: string[];
|
||||
/** For verbs: human-readable relationship description */
|
||||
relationship?: string;
|
||||
/** AI confidence score (0-1) */
|
||||
confidence: number;
|
||||
/** Explanation of type detection reasoning (debug mode) */
|
||||
reasoning?: string;
|
||||
/** Alternative type suggestions with confidence scores */
|
||||
alternatives?: Array<{
|
||||
type: string;
|
||||
confidence: number;
|
||||
}>;
|
||||
/** Timestamp when fields were computed */
|
||||
computedAt: number;
|
||||
/** Version of augmentation that computed these fields */
|
||||
version: string;
|
||||
}
|
||||
/**
|
||||
* Cache entry for computed display fields
|
||||
*/
|
||||
export interface DisplayCacheEntry {
|
||||
fields: ComputedDisplayFields;
|
||||
lastAccessed: number;
|
||||
accessCount: number;
|
||||
}
|
||||
/**
|
||||
* Field computation context passed to computation functions
|
||||
*/
|
||||
export interface FieldComputationContext {
|
||||
/** The original data object */
|
||||
data: any;
|
||||
/** Metadata associated with the object */
|
||||
metadata: any;
|
||||
/** Type detection result from AI */
|
||||
typeResult?: TypeMatchResult;
|
||||
/** Display configuration */
|
||||
config: DisplayConfig;
|
||||
/** Whether this is a noun or verb */
|
||||
entityType: 'noun' | 'verb';
|
||||
/** For verbs: source and target information */
|
||||
verbContext?: {
|
||||
sourceId: string;
|
||||
targetId: string;
|
||||
verbType?: string;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Type matching result from BrainyTypes
|
||||
*/
|
||||
export interface TypeMatchResult {
|
||||
type: string;
|
||||
confidence: number;
|
||||
reasoning: string;
|
||||
alternatives: Array<{
|
||||
type: string;
|
||||
confidence: number;
|
||||
}>;
|
||||
}
|
||||
/**
|
||||
* Enhanced VectorDocument with display capabilities
|
||||
*/
|
||||
export interface EnhancedVectorDocument<T = any> extends VectorDocument<T> {
|
||||
/**
|
||||
* Get computed display field(s)
|
||||
* @param field Optional specific field name
|
||||
* @returns Single field value or all display fields
|
||||
*/
|
||||
getDisplay(): Promise<ComputedDisplayFields>;
|
||||
getDisplay(field: keyof ComputedDisplayFields): Promise<any>;
|
||||
/**
|
||||
* Get available fields for a specific augmentation namespace
|
||||
* @param namespace The augmentation namespace (e.g., 'display')
|
||||
* @returns Array of available field names
|
||||
*/
|
||||
getAvailableFields(namespace: string): string[];
|
||||
/**
|
||||
* Get available augmentation namespaces
|
||||
* @returns Array of available augmentation names
|
||||
*/
|
||||
getAvailableAugmentations(): string[];
|
||||
/**
|
||||
* Debug exploration of all computed fields
|
||||
*/
|
||||
explore(): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Enhanced GraphVerb with display capabilities
|
||||
*/
|
||||
export interface EnhancedGraphVerb extends GraphVerb {
|
||||
/**
|
||||
* Get computed display field(s) for relationships
|
||||
* @param field Optional specific field name
|
||||
* @returns Single field value or all display fields
|
||||
*/
|
||||
getDisplay(): Promise<ComputedDisplayFields>;
|
||||
getDisplay(field: keyof ComputedDisplayFields): Promise<any>;
|
||||
/**
|
||||
* Get available fields for a specific augmentation namespace
|
||||
* @param namespace The augmentation namespace (e.g., 'display')
|
||||
* @returns Array of available field names
|
||||
*/
|
||||
getAvailableFields(namespace: string): string[];
|
||||
}
|
||||
/**
|
||||
* Batch computation request for performance optimization
|
||||
*/
|
||||
export interface BatchComputationRequest {
|
||||
id: string;
|
||||
data: any;
|
||||
metadata: any;
|
||||
entityType: 'noun' | 'verb';
|
||||
verbContext?: {
|
||||
sourceId: string;
|
||||
targetId: string;
|
||||
verbType?: string;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Batch computation result
|
||||
*/
|
||||
export interface BatchComputationResult {
|
||||
id: string;
|
||||
fields: ComputedDisplayFields;
|
||||
error?: string;
|
||||
}
|
||||
/**
|
||||
* Field pattern for intelligent field detection
|
||||
*/
|
||||
export interface FieldPattern {
|
||||
/** Field names that match this pattern */
|
||||
fields: string[];
|
||||
/** Target display field name */
|
||||
displayField: keyof ComputedDisplayFields;
|
||||
/** Confidence score for this pattern match */
|
||||
confidence: number;
|
||||
/** Optional: specific noun/verb types this applies to */
|
||||
applicableTypes?: string[];
|
||||
/** Optional: transformation function for the field value */
|
||||
transform?: (value: any, context: FieldComputationContext) => string;
|
||||
}
|
||||
/**
|
||||
* Statistics for the display augmentation
|
||||
*/
|
||||
export interface DisplayAugmentationStats {
|
||||
/** Total number of computations performed */
|
||||
totalComputations: number;
|
||||
/** Cache hit ratio */
|
||||
cacheHitRatio: number;
|
||||
/** Average computation time in milliseconds */
|
||||
averageComputationTime: number;
|
||||
/** Type detection accuracy (when ground truth available) */
|
||||
typeDetectionAccuracy?: number;
|
||||
/** Most commonly detected types */
|
||||
commonTypes: Array<{
|
||||
type: string;
|
||||
count: number;
|
||||
percentage: number;
|
||||
}>;
|
||||
/** Performance metrics */
|
||||
performance: {
|
||||
fastestComputation: number;
|
||||
slowestComputation: number;
|
||||
totalComputationTime: number;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
/**
|
||||
* Universal Display Augmentation - Type Definitions
|
||||
*
|
||||
* Clean TypeScript interfaces for the display augmentation system
|
||||
*/
|
||||
export {};
|
||||
//# sourceMappingURL=types.js.map
|
||||
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/augmentations/display/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
||||
Loading…
Add table
Add a link
Reference in a new issue