Introduced `pluginLoader.ts` to enable loading and configuring augmentation plugins from external packages. Added `examples/externalPlugins.js` to demonstrate usage. Enhanced storage status reporting in `opfsStorage` and `BrainyData` with detailed storage capacity and usage methods. Updated README with an external plugin usage guide.
185 lines
3.6 KiB
TypeScript
185 lines
3.6 KiB
TypeScript
/**
|
|
* OPFS BrainyData
|
|
* A vector database using HNSW indexing with Origin Private File System storage
|
|
*/
|
|
|
|
// Export main BrainyData class and related types
|
|
import { BrainyData, BrainyDataConfig } from './brainyData.js'
|
|
export { BrainyData }
|
|
export type { BrainyDataConfig }
|
|
|
|
// Export distance functions for convenience
|
|
import {
|
|
euclideanDistance,
|
|
cosineDistance,
|
|
manhattanDistance,
|
|
dotProductDistance
|
|
} from './utils/index.js'
|
|
export {
|
|
euclideanDistance,
|
|
cosineDistance,
|
|
manhattanDistance,
|
|
dotProductDistance
|
|
}
|
|
|
|
// Export embedding functionality
|
|
import {
|
|
SimpleEmbedding,
|
|
UniversalSentenceEncoder,
|
|
createEmbeddingFunction,
|
|
createTensorFlowEmbeddingFunction,
|
|
createSimpleEmbeddingFunction,
|
|
defaultEmbeddingFunction
|
|
} from './utils/embedding.js'
|
|
export {
|
|
SimpleEmbedding,
|
|
UniversalSentenceEncoder,
|
|
createEmbeddingFunction,
|
|
createTensorFlowEmbeddingFunction,
|
|
createSimpleEmbeddingFunction,
|
|
defaultEmbeddingFunction
|
|
}
|
|
|
|
// Export storage adapters
|
|
import {
|
|
OPFSStorage,
|
|
MemoryStorage,
|
|
createStorage
|
|
} from './storage/opfsStorage.js'
|
|
export {
|
|
OPFSStorage,
|
|
MemoryStorage,
|
|
createStorage
|
|
}
|
|
|
|
// Export augmentation pipeline
|
|
import {
|
|
AugmentationPipeline,
|
|
augmentationPipeline,
|
|
ExecutionMode,
|
|
PipelineOptions
|
|
} from './augmentationPipeline.js'
|
|
export {
|
|
AugmentationPipeline,
|
|
augmentationPipeline,
|
|
ExecutionMode
|
|
}
|
|
export type { PipelineOptions }
|
|
|
|
// Export plugin loader
|
|
import {
|
|
loadPlugins,
|
|
configureAndStartPipeline,
|
|
createSensePluginConfig,
|
|
createConduitPluginConfig
|
|
} from './pluginLoader.js'
|
|
import type {
|
|
PluginLoaderOptions,
|
|
PluginConfig,
|
|
PluginLoadResult
|
|
} from './pluginLoader.js'
|
|
export {
|
|
loadPlugins,
|
|
configureAndStartPipeline,
|
|
createSensePluginConfig,
|
|
createConduitPluginConfig
|
|
}
|
|
export type {
|
|
PluginLoaderOptions,
|
|
PluginConfig,
|
|
PluginLoadResult
|
|
}
|
|
|
|
// Export types
|
|
import type {
|
|
Vector,
|
|
VectorDocument,
|
|
SearchResult,
|
|
DistanceFunction,
|
|
EmbeddingFunction,
|
|
EmbeddingModel,
|
|
HNSWNode,
|
|
Edge,
|
|
HNSWConfig,
|
|
StorageAdapter
|
|
} from './coreTypes.js'
|
|
export type {
|
|
Vector,
|
|
VectorDocument,
|
|
SearchResult,
|
|
DistanceFunction,
|
|
EmbeddingFunction,
|
|
EmbeddingModel,
|
|
HNSWNode,
|
|
Edge,
|
|
HNSWConfig,
|
|
StorageAdapter
|
|
}
|
|
|
|
// Export augmentation types
|
|
import type {
|
|
IAugmentation,
|
|
AugmentationResponse,
|
|
IWebSocketSupport,
|
|
ISenseAugmentation,
|
|
IConduitAugmentation,
|
|
ICognitionAugmentation,
|
|
IMemoryAugmentation,
|
|
IPerceptionAugmentation,
|
|
IDialogAugmentation,
|
|
IActivationAugmentation
|
|
} from './types/augmentations.js'
|
|
import { AugmentationType, BrainyAugmentations } from './types/augmentations.js'
|
|
export type {
|
|
IAugmentation,
|
|
AugmentationResponse,
|
|
IWebSocketSupport
|
|
}
|
|
export {
|
|
AugmentationType,
|
|
BrainyAugmentations,
|
|
ISenseAugmentation,
|
|
IConduitAugmentation,
|
|
ICognitionAugmentation,
|
|
IMemoryAugmentation,
|
|
IPerceptionAugmentation,
|
|
IDialogAugmentation,
|
|
IActivationAugmentation
|
|
}
|
|
|
|
// Export combined WebSocket augmentation interfaces
|
|
export type {
|
|
IWebSocketCognitionAugmentation,
|
|
IWebSocketSenseAugmentation,
|
|
IWebSocketPerceptionAugmentation,
|
|
IWebSocketActivationAugmentation,
|
|
IWebSocketDialogAugmentation,
|
|
IWebSocketConduitAugmentation,
|
|
IWebSocketMemoryAugmentation
|
|
} from './types/augmentations.js'
|
|
|
|
// Export graph types
|
|
import type {
|
|
GraphNoun,
|
|
GraphVerb,
|
|
EmbeddedGraphVerb,
|
|
Person,
|
|
Place,
|
|
Thing,
|
|
Event,
|
|
Concept,
|
|
Content
|
|
} from './types/graphTypes.js'
|
|
import { NounType, VerbType } from './types/graphTypes.js'
|
|
export type {
|
|
GraphNoun,
|
|
GraphVerb,
|
|
EmbeddedGraphVerb,
|
|
Person,
|
|
Place,
|
|
Thing,
|
|
Event,
|
|
Concept,
|
|
Content
|
|
}
|
|
export { NounType, VerbType }
|