brainy/.recovery-workspace/dist-backup-20250910-141917/augmentations/neuralImport.d.ts
David Snelling 8ff382ca3b 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
2025-09-10 15:18:04 -07:00

145 lines
4.1 KiB
TypeScript

/**
* Neural Import Augmentation - AI-Powered Data Understanding
*
* 🧠 Built-in AI augmentation for intelligent data processing
* ⚛️ Always free, always included, always enabled
*
* Now using the unified BrainyAugmentation interface!
*/
import { BaseAugmentation } from './brainyAugmentation.js';
export interface NeuralAnalysisResult {
detectedEntities: DetectedEntity[];
detectedRelationships: DetectedRelationship[];
confidence: number;
insights: NeuralInsight[];
}
export interface DetectedEntity {
originalData: any;
nounType: string;
confidence: number;
suggestedId: string;
reasoning: string;
alternativeTypes: Array<{
type: string;
confidence: number;
}>;
}
export interface DetectedRelationship {
sourceId: string;
targetId: string;
verbType: string;
confidence: number;
weight: number;
reasoning: string;
context: string;
metadata?: Record<string, any>;
}
export interface NeuralInsight {
type: 'hierarchy' | 'cluster' | 'pattern' | 'anomaly' | 'opportunity';
description: string;
confidence: number;
affectedEntities: string[];
recommendation?: string;
}
export interface NeuralImportConfig {
confidenceThreshold: number;
enableWeights: boolean;
skipDuplicates: boolean;
categoryFilter?: string[];
dataType?: string;
}
/**
* Neural Import Augmentation - Unified Implementation
* Processes data with AI before storage operations
*/
export declare class NeuralImportAugmentation extends BaseAugmentation {
readonly name = "neural-import";
readonly timing: "before";
readonly metadata: {
reads: "*";
writes: string[];
};
operations: ("add" | "addNoun" | "addVerb" | "all")[];
readonly priority = 80;
protected config: NeuralImportConfig;
private analysisCache;
private typeMatcher;
constructor(config?: Partial<NeuralImportConfig>);
protected onInitialize(): Promise<void>;
protected onShutdown(): Promise<void>;
/**
* Execute augmentation - process data with AI before storage
*/
execute<T = any>(operation: string, params: any, next: () => Promise<T>): Promise<T>;
/**
* Extract raw data from operation params
*/
private extractRawData;
/**
* Get the full neural analysis result (for external use)
*/
getNeuralAnalysis(rawData: Buffer | string, dataType?: string): Promise<NeuralAnalysisResult>;
/**
* Parse raw data based on type
*/
private parseRawData;
/**
* Parse CSV data - handles quoted values, escaped quotes, and edge cases
*/
private parseCSV;
/**
* Parse YAML data
*/
private parseYAML;
/**
* Parse a YAML value (handle strings, numbers, booleans, null)
*/
private parseYAMLValue;
/**
* Perform neural analysis on parsed data
*/
private performNeuralAnalysis;
/**
* Infer noun type from object structure using intelligent type matching
*/
private inferNounType;
/**
* Detect relationships from object references
*/
private detectRelationships;
/**
* Infer verb type from field name using intelligent type matching
*/
private inferVerbType;
/**
* Group entities by type
*/
private groupByType;
/**
* Store neural analysis results
*/
private storeNeuralAnalysis;
/**
* Helper to get data type from file path
*/
private getDataTypeFromPath;
/**
* PUBLIC API: Process raw data (for external use, like Synapses)
* This maintains compatibility with code that wants to use Neural Import directly
*/
processRawData(rawData: Buffer | string, dataType: string, options?: Record<string, unknown>): Promise<{
success: boolean;
data: {
nouns: string[];
verbs: string[];
confidence?: number;
insights?: Array<{
type: string;
description: string;
confidence: number;
}>;
metadata?: Record<string, unknown>;
};
error?: string;
}>;
}