|
| 1 | +/** |
| 2 | + * Controller Prerequisites — local shim for `agentic-flow/agentdb`. |
| 3 | + * |
| 4 | + * Mirrors the registry that lives in the upstream `agentdb` package |
| 5 | + * (`agentdb/dist/controllers/prerequisites.js`). Exposing it through the |
| 6 | + * `agentic-flow/agentdb` re-export means consumers (e.g. ruflo) can rely on |
| 7 | + * a single import surface regardless of which agentdb version is installed. |
| 8 | + * |
| 9 | + * Issue #146 Gap 2. |
| 10 | + */ |
| 11 | + |
| 12 | +export type ControllerRequirement = |
| 13 | + | 'database' |
| 14 | + | 'embedder' |
| 15 | + | 'vectorBackend' |
| 16 | + | 'graphBackend' |
| 17 | + | 'learningBackend' |
| 18 | + | 'config' |
| 19 | + | 'wasm' |
| 20 | + | 'networkEndpoint'; |
| 21 | + |
| 22 | +export type ControllerSafety = 'pure' | 'opens-resource' | 'opens-network'; |
| 23 | + |
| 24 | +export interface ControllerPrerequisite { |
| 25 | + name: string; |
| 26 | + requirements: ControllerRequirement[]; |
| 27 | + optional: ControllerRequirement[]; |
| 28 | + arity: number; |
| 29 | + safety: ControllerSafety; |
| 30 | + description: string; |
| 31 | +} |
| 32 | + |
| 33 | +export const controllerPrerequisites: readonly ControllerPrerequisite[] = Object.freeze([ |
| 34 | + { |
| 35 | + name: 'AttentionService', |
| 36 | + requirements: ['config'], |
| 37 | + optional: ['wasm'], |
| 38 | + arity: 1, |
| 39 | + safety: 'opens-resource', |
| 40 | + description: 'Self / cross / multi-head attention over embeddings.' |
| 41 | + }, |
| 42 | + { |
| 43 | + name: 'CausalMemoryGraph', |
| 44 | + requirements: ['database'], |
| 45 | + optional: ['embedder', 'graphBackend', 'vectorBackend', 'config'], |
| 46 | + arity: 5, |
| 47 | + safety: 'opens-resource', |
| 48 | + description: 'Causal edge graph over memories.' |
| 49 | + }, |
| 50 | + { |
| 51 | + name: 'CausalRecall', |
| 52 | + requirements: ['database', 'embedder'], |
| 53 | + optional: ['vectorBackend', 'config'], |
| 54 | + arity: 4, |
| 55 | + safety: 'pure', |
| 56 | + description: 'Causal-uplift reranker.' |
| 57 | + }, |
| 58 | + { |
| 59 | + name: 'ContextSynthesizer', |
| 60 | + requirements: ['database'], |
| 61 | + optional: ['embedder', 'config'], |
| 62 | + arity: 3, |
| 63 | + safety: 'pure', |
| 64 | + description: 'Synthesises retrieved memories into context.' |
| 65 | + }, |
| 66 | + { |
| 67 | + name: 'EmbeddingService', |
| 68 | + requirements: ['config'], |
| 69 | + optional: [], |
| 70 | + arity: 1, |
| 71 | + safety: 'pure', |
| 72 | + description: 'Text → vector embedder.' |
| 73 | + }, |
| 74 | + { |
| 75 | + name: 'EnhancedEmbeddingService', |
| 76 | + requirements: ['config'], |
| 77 | + optional: [], |
| 78 | + arity: 1, |
| 79 | + safety: 'pure', |
| 80 | + description: 'EmbeddingService with caching and provider fallback.' |
| 81 | + }, |
| 82 | + { |
| 83 | + name: 'ExplainableRecall', |
| 84 | + requirements: ['database', 'embedder'], |
| 85 | + optional: ['vectorBackend'], |
| 86 | + arity: 3, |
| 87 | + safety: 'pure', |
| 88 | + description: 'Recall with feature attributions.' |
| 89 | + }, |
| 90 | + { |
| 91 | + name: 'HNSWIndex', |
| 92 | + requirements: ['database'], |
| 93 | + optional: ['config'], |
| 94 | + arity: 2, |
| 95 | + safety: 'opens-resource', |
| 96 | + description: 'On-disk HNSW vector index.' |
| 97 | + }, |
| 98 | + { |
| 99 | + name: 'LearningSystem', |
| 100 | + requirements: ['database', 'embedder'], |
| 101 | + optional: ['vectorBackend', 'config'], |
| 102 | + arity: 4, |
| 103 | + safety: 'pure', |
| 104 | + description: 'Online learning consolidator.' |
| 105 | + }, |
| 106 | + { |
| 107 | + name: 'MMRDiversityRanker', |
| 108 | + requirements: [], |
| 109 | + optional: ['config'], |
| 110 | + arity: 1, |
| 111 | + safety: 'pure', |
| 112 | + description: 'MMR diversity reranker.' |
| 113 | + }, |
| 114 | + { |
| 115 | + name: 'MemoryController', |
| 116 | + requirements: [], |
| 117 | + optional: ['vectorBackend', 'config'], |
| 118 | + arity: 2, |
| 119 | + safety: 'pure', |
| 120 | + description: 'High-level memory orchestration.' |
| 121 | + }, |
| 122 | + { |
| 123 | + name: 'MetadataFilter', |
| 124 | + requirements: [], |
| 125 | + optional: [], |
| 126 | + arity: 0, |
| 127 | + safety: 'pure', |
| 128 | + description: 'Pure utility for metadata predicates.' |
| 129 | + }, |
| 130 | + { |
| 131 | + name: 'NightlyLearner', |
| 132 | + requirements: ['database', 'embedder'], |
| 133 | + optional: ['config'], |
| 134 | + arity: 3, |
| 135 | + safety: 'pure', |
| 136 | + description: 'Background consolidation pipeline.' |
| 137 | + }, |
| 138 | + { |
| 139 | + name: 'QUICClient', |
| 140 | + requirements: ['config', 'networkEndpoint'], |
| 141 | + optional: [], |
| 142 | + arity: 1, |
| 143 | + safety: 'opens-network', |
| 144 | + description: 'QUIC sync client.' |
| 145 | + }, |
| 146 | + { |
| 147 | + name: 'QUICServer', |
| 148 | + requirements: ['config'], |
| 149 | + optional: [], |
| 150 | + arity: 1, |
| 151 | + safety: 'opens-network', |
| 152 | + description: 'QUIC sync server.' |
| 153 | + }, |
| 154 | + { |
| 155 | + name: 'ReasoningBank', |
| 156 | + requirements: ['database', 'embedder'], |
| 157 | + optional: ['vectorBackend', 'graphBackend', 'config'], |
| 158 | + arity: 5, |
| 159 | + safety: 'pure', |
| 160 | + description: 'Reasoning memory facade.' |
| 161 | + }, |
| 162 | + { |
| 163 | + name: 'ReflexionMemory', |
| 164 | + requirements: ['database', 'embedder'], |
| 165 | + optional: ['vectorBackend', 'learningBackend', 'graphBackend'], |
| 166 | + arity: 5, |
| 167 | + safety: 'pure', |
| 168 | + description: 'Episodic replay memory.' |
| 169 | + }, |
| 170 | + { |
| 171 | + name: 'SkillLibrary', |
| 172 | + requirements: ['database', 'embedder'], |
| 173 | + optional: ['vectorBackend', 'graphBackend', 'config'], |
| 174 | + arity: 5, |
| 175 | + safety: 'pure', |
| 176 | + description: 'Reusable skill registry.' |
| 177 | + }, |
| 178 | + { |
| 179 | + name: 'SyncCoordinator', |
| 180 | + requirements: ['config'], |
| 181 | + optional: ['networkEndpoint'], |
| 182 | + arity: 1, |
| 183 | + safety: 'opens-network', |
| 184 | + description: 'Multi-peer QUIC sync coordinator.' |
| 185 | + }, |
| 186 | + { |
| 187 | + name: 'WASMVectorSearch', |
| 188 | + requirements: ['wasm'], |
| 189 | + optional: ['config'], |
| 190 | + arity: 1, |
| 191 | + safety: 'opens-resource', |
| 192 | + description: 'Pure-WASM vector search index.' |
| 193 | + } |
| 194 | +]); |
| 195 | + |
| 196 | +export const noArgControllers: readonly ControllerPrerequisite[] = Object.freeze( |
| 197 | + controllerPrerequisites.filter(c => c.requirements.length === 0) |
| 198 | +); |
| 199 | + |
| 200 | +export function getControllerPrerequisite(name: string): ControllerPrerequisite | null { |
| 201 | + return controllerPrerequisites.find(c => c.name === name) ?? null; |
| 202 | +} |
| 203 | + |
| 204 | +export function filterBySafety( |
| 205 | + safety: readonly ControllerSafety[] |
| 206 | +): readonly ControllerPrerequisite[] { |
| 207 | + return controllerPrerequisites.filter(c => safety.includes(c.safety)); |
| 208 | +} |
0 commit comments