feat: wire plugin system with provider resolution, storage factories, and browser deprecation

- Wire PluginRegistry into Brainy init() with provider resolution for distance,
  metadataIndex, graphIndex, embeddings, roaring, msgpack, and storage adapters
- Add setupStorage() factory that resolves storage:* providers from plugins before
  falling back to built-in createStorage()
- Export internals API (setGlobalCache, UnifiedCache, EntityIdMapper, etc.) for
  cortex plugin consumption
- Add plugin.test.ts verifying registration, activation, and provider resolution
- Deprecate browser support (OPFS, Web Workers, WASM embeddings) with warnings
  in preparation for v8.0 server-only release
- FileSystemStorage: fix setupStorage resolution for mmap-filesystem provider
This commit is contained in:
David Snelling 2026-01-31 12:02:13 -08:00
parent 25912b5728
commit 1513e297ef
11 changed files with 456 additions and 33 deletions

View file

@ -78,7 +78,7 @@ export class FileSystemStorage extends BaseStorage {
private readonly SHARDING_DEPTH = 1 as const
private readonly MAX_SHARDS = 256 // Hex range: 00-ff
private cachedShardingDepth: number = this.SHARDING_DEPTH // Always use fixed depth
private rootDir: string
protected rootDir: string
private nounsDir!: string
private verbsDir!: string
private metadataDir!: string

View file

@ -80,6 +80,7 @@ export class OPFSStorage extends BaseStorage {
constructor() {
super()
console.warn('[brainy] OPFS storage is deprecated and will be removed in v8.0. Use Node.js/Bun with filesystem or mmap-filesystem storage instead.')
// Check if OPFS is available
this.isAvailable =
typeof navigator !== 'undefined' &&

View file

@ -480,6 +480,7 @@ export async function createStorage(
return memStorage
case 'opfs': {
console.warn('[brainy] OPFS storage is deprecated and will be removed in v8.0. Migrate to Node.js/Bun with filesystem or mmap-filesystem storage.')
// Check if OPFS is available
const opfsStorage = new OPFSStorage()
if (opfsStorage.isOPFSAvailable()) {
@ -839,6 +840,7 @@ export async function createStorage(
// Next, try OPFS (browser only)
if (isBrowser()) {
console.warn('[brainy] Browser environment detected. Browser support is deprecated and will be removed in v8.0. Migrate to Node.js/Bun.')
const opfsStorage = new OPFSStorage()
if (opfsStorage.isOPFSAvailable()) {
console.log('Using OPFS storage (auto-detected) + TypeAware wrapper')