diff --git a/src/brainyData.ts b/src/brainyData.ts index 110fa3ea..38e4b193 100644 --- a/src/brainyData.ts +++ b/src/brainyData.ts @@ -4,19 +4,19 @@ */ import { v4 as uuidv4 } from 'uuid' -import { HNSWIndex } from './hnsw/hnswIndex.js' -import { createStorage } from './storage/opfsStorage.js' +import { HNSWIndex } from './hnsw/hnswIndex.ts' +import { createStorage } from './storage/opfsStorage.ts' import { DistanceFunction, Edge, EmbeddingFunction, - HNSWConfig, + HNSWConfig, HNSWNode, SearchResult, StorageAdapter, Vector, VectorDocument -} from './coreTypes.js' -import { cosineDistance, defaultEmbeddingFunction, euclideanDistance } from './utils/index.js' +} from './coreTypes.ts' +import { cosineDistance, defaultEmbeddingFunction, euclideanDistance } from './utils/index.ts' export interface BrainyDataConfig { /** @@ -94,7 +94,7 @@ export class BrainyData { await this.storage!.init() // Load all nodes from storage - const nodes = await this.storage!.getAllNodes() + const nodes: HNSWNode[] = await this.storage!.getAllNodes() // Clear the index and add all nodes this.index.clear() @@ -631,12 +631,12 @@ export class BrainyData { // Check if the storage adapter has a getStorageStatus method if (typeof this.storage.getStorageStatus !== 'function') { // If not, determine the storage type based on the constructor name - const storageType = this.storage.constructor.name.toLowerCase().replace('storage', ''); + const storageType = this.storage.constructor.name.toLowerCase().replace('storage', '') return { type: storageType || 'unknown', used: 0, quota: null, - details: { + details: { error: 'Storage adapter does not implement getStorageStatus method', storageAdapter: this.storage.constructor.name, indexSize: this.size() @@ -666,13 +666,13 @@ export class BrainyData { console.error('Failed to get storage status:', error) // Determine the storage type based on the constructor name - const storageType = this.storage.constructor.name.toLowerCase().replace('storage', ''); + const storageType = this.storage.constructor.name.toLowerCase().replace('storage', '') return { type: storageType || 'unknown', used: 0, quota: null, - details: { + details: { error: String(error), storageAdapter: this.storage.constructor.name, indexSize: this.size() diff --git a/src/examples/basicUsage.ts b/src/examples/basicUsage.ts index 83f881c4..9971defe 100644 --- a/src/examples/basicUsage.ts +++ b/src/examples/basicUsage.ts @@ -2,7 +2,7 @@ * Basic usage example for the Soulcraft Brainy database */ -import { BrainyData } from '../brainyData.js' +import { BrainyData } from '../brainyData.ts' // Example data - word embeddings const wordEmbeddings = { diff --git a/src/hnsw/hnswIndex.ts b/src/hnsw/hnswIndex.ts index efaf3daa..9ac89499 100644 --- a/src/hnsw/hnswIndex.ts +++ b/src/hnsw/hnswIndex.ts @@ -3,8 +3,8 @@ * Based on the paper: "Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs" */ -import { DistanceFunction, HNSWConfig, HNSWNode, Vector, VectorDocument } from '../coreTypes.js' -import { euclideanDistance } from '../utils/index.js' +import { DistanceFunction, HNSWConfig, HNSWNode, Vector, VectorDocument } from '../coreTypes.ts' +import { euclideanDistance } from '../utils/index.ts' // Default HNSW parameters const DEFAULT_CONFIG: HNSWConfig = { diff --git a/src/index.ts b/src/index.ts index 6d959ba9..ba0a6ef9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ */ // Export main BrainyData class and related types -import { BrainyData, BrainyDataConfig } from './brainyData.js' +import { BrainyData, BrainyDataConfig } from './brainyData.ts' export { BrainyData } export type { BrainyDataConfig } @@ -14,7 +14,7 @@ import { cosineDistance, manhattanDistance, dotProductDistance -} from './utils/index.js' +} from './utils/index.ts' export { euclideanDistance, cosineDistance, @@ -30,7 +30,7 @@ import { createTensorFlowEmbeddingFunction, createSimpleEmbeddingFunction, defaultEmbeddingFunction -} from './utils/embedding.js' +} from './utils/embedding.ts' export { SimpleEmbedding, UniversalSentenceEncoder, @@ -45,7 +45,7 @@ import { OPFSStorage, MemoryStorage, createStorage -} from './storage/opfsStorage.js' +} from './storage/opfsStorage.ts' export { OPFSStorage, MemoryStorage, @@ -58,7 +58,7 @@ import { augmentationPipeline, ExecutionMode, PipelineOptions -} from './augmentationPipeline.js' +} from './augmentationPipeline.ts' export { AugmentationPipeline, augmentationPipeline, @@ -72,12 +72,12 @@ import { configureAndStartPipeline, createSensePluginConfig, createConduitPluginConfig -} from './pluginLoader.js' +} from './pluginLoader.ts' import type { PluginLoaderOptions, PluginConfig, PluginLoadResult -} from './pluginLoader.js' +} from './pluginLoader.ts' export { loadPlugins, configureAndStartPipeline, @@ -102,7 +102,7 @@ import type { Edge, HNSWConfig, StorageAdapter -} from './coreTypes.js' +} from './coreTypes.ts' export type { Vector, VectorDocument, @@ -128,8 +128,8 @@ import type { IPerceptionAugmentation, IDialogAugmentation, IActivationAugmentation -} from './types/augmentations.js' -import { AugmentationType, BrainyAugmentations } from './types/augmentations.js' +} from './types/augmentations.ts' +import { AugmentationType, BrainyAugmentations } from './types/augmentations.ts' export type { IAugmentation, AugmentationResponse, @@ -156,7 +156,7 @@ export type { IWebSocketDialogAugmentation, IWebSocketConduitAugmentation, IWebSocketMemoryAugmentation -} from './types/augmentations.js' +} from './types/augmentations.ts' // Export graph types import type { @@ -169,8 +169,8 @@ import type { Event, Concept, Content -} from './types/graphTypes.js' -import { NounType, VerbType } from './types/graphTypes.js' +} from './types/graphTypes.ts' +import { NounType, VerbType } from './types/graphTypes.ts' export type { GraphNoun, GraphVerb, diff --git a/src/storage/fileSystemStorage.ts b/src/storage/fileSystemStorage.ts index 26399f66..c79ece06 100644 --- a/src/storage/fileSystemStorage.ts +++ b/src/storage/fileSystemStorage.ts @@ -1,4 +1,4 @@ -import { Edge, HNSWNode, StorageAdapter } from '../coreTypes.js' +import { Edge, HNSWNode, StorageAdapter } from '../coreTypes.ts' // We'll dynamically import Node.js built-in modules let fs: any diff --git a/src/storage/opfsStorage.ts b/src/storage/opfsStorage.ts index 6b2f71b8..2826e846 100644 --- a/src/storage/opfsStorage.ts +++ b/src/storage/opfsStorage.ts @@ -3,7 +3,7 @@ * Provides persistent storage for the vector database using the Origin Private File System API */ -import { Edge, HNSWNode, StorageAdapter } from '../coreTypes.js' +import { Edge, HNSWNode, StorageAdapter } from '../coreTypes.ts' // Directory and file names const ROOT_DIR = 'opfs-vector-db' @@ -902,7 +902,7 @@ export async function createStorage(options: { if (isNode) { // In Node.js, use FileSystemStorage first, then fall back to memory try { - const fileSystemModule = await import('./fileSystemStorage.js') + const fileSystemModule = await import('./fileSystemStorage.ts') return new fileSystemModule.FileSystemStorage() } catch (error) { console.warn('Failed to load FileSystemStorage, falling back to in-memory storage:', error) @@ -928,7 +928,7 @@ export async function createStorage(options: { try { // Try to load FileSystemStorage for browser environments // Note: This will likely fail as FileSystemStorage is designed for Node.js - const fileSystemModule = await import('./fileSystemStorage.js') + const fileSystemModule = await import('./fileSystemStorage.ts') return new fileSystemModule.FileSystemStorage() } catch (error) { console.warn('FileSystem storage is not available, falling back to in-memory storage') diff --git a/src/utils/distance.ts b/src/utils/distance.ts index 6cd71c81..8bb29858 100644 --- a/src/utils/distance.ts +++ b/src/utils/distance.ts @@ -2,7 +2,7 @@ * Distance functions for vector similarity calculations */ -import { DistanceFunction, Vector } from '../coreTypes.js' +import { DistanceFunction, Vector } from '../coreTypes.ts' /** * Calculates the Euclidean distance between two vectors diff --git a/src/utils/embedding.ts b/src/utils/embedding.ts index 7445b121..5a2df8d7 100644 --- a/src/utils/embedding.ts +++ b/src/utils/embedding.ts @@ -2,7 +2,7 @@ * Embedding functions for converting data to vectors */ -import { EmbeddingFunction, EmbeddingModel, Vector } from '../coreTypes.js' +import { EmbeddingFunction, EmbeddingModel, Vector } from '../coreTypes.ts' /** * Simple character-based embedding function diff --git a/src/utils/index.ts b/src/utils/index.ts index 11db368e..97935fc8 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,2 +1,2 @@ -export * from './distance.js' -export * from './embedding.js' +export * from './distance.ts' +export * from './embedding.ts' diff --git a/tsconfig.json b/tsconfig.json index 9949368e..64b185c0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,7 @@ ], "skipLibCheck": true, "forceConsistentCasingInFileNames": true, - "allowImportingTsExtensions": false, + "allowImportingTsExtensions": true, "noEmit": false, "preserveConstEnums": true, "sourceMap": true