feat: add adapter factory + registry pattern for queue, storage, memory

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jarvis
2026-04-02 20:25:42 -05:00
parent 41961a6980
commit 9d22ef4cc9
6 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
import type { MemoryAdapter, MemoryConfig } from './types.js';
type MemoryType = MemoryConfig['type'];
const registry = new Map<MemoryType, (config: MemoryConfig) => MemoryAdapter>();
export function registerMemoryAdapter(
type: MemoryType,
factory: (config: MemoryConfig) => MemoryAdapter,
): void {
registry.set(type, factory);
}
export function createMemoryAdapter(config: MemoryConfig): MemoryAdapter {
const factory = registry.get(config.type);
if (!factory) throw new Error(`No adapter registered for type: ${config.type}`);
return factory(config);
}