adaptive-memory-multi-model-router 2.2.7 → 2.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -254,7 +254,7 @@ LiteLLM ████████████████ ~500ms
254
254
 
255
255
  See full benchmark methodology at [`scripts/routing-benchmark-v2.js`](scripts/routing-benchmark-v2.js) or run it with `node scripts/routing-benchmark-v2.js`.
256
256
 
257
- | Metric | A3M Router | LiteLLM |
257
+ | Metric | A3M Router | [LiteLLM](https://github.com/BerriAI/litellm) |
258
258
  |--------|:----------:|:---------------:|
259
259
  | **±1 tier accuracy** | **99.5%** | N/A (manual) |
260
260
  | Exact tier match | 64.5% | N/A |
@@ -310,7 +310,7 @@ We ran **MMLU-style questions** and **quality tests** against each provider via
310
310
 
311
311
  > **May 2026** — 15 MMLU questions + 8 quality questions per provider via real API. Run `node scripts/run-mmlu-benchmark.js` to replicate. Results in [`benchmark-results.json`](benchmark-results.json).
312
312
 
313
- | Metric | A3M Router | LiteLLM |
313
+ | Metric | A3M Router | [LiteLLM](https://github.com/BerriAI/litellm) |
314
314
  |--------|:----------:|:--------:|
315
315
  | ±1 tier accuracy | **99.5%** | N/A |
316
316
  | Package size | **19.5 KB** | ~50 MB |
@@ -784,20 +784,22 @@ const modelWithTools = model.bindTools([searchTool, calculatorTool]);
784
784
 
785
785
  ## Comparison
786
786
 
787
- | Feature | A3M Router | [LiteLLM](https://github.com/BerriAI/litellm) | [Portkey](https://github.com/Portkey-AI/gateway) | [OpenRouter](https://openrouter.ai) |
787
+ | Feature | A3M Router | [LiteLLM](https://github.com/BerriAI/litellm) | [Portkey](https://github.com/Portkey-AI/gateway) | [RouteLLM](https://github.com/Surfsol/RouteLLM) |
788
788
  |---------|:----------:|:-------:|:-------:|:-------:|
789
789
  | **Routing accuracy published** | **Yes** (99.5% ±1) | No (manual) | No | No |
790
790
  | **Intelligent routing** | Multi-signal per-query | Manual selection | Manual | Manual |
791
791
  | **Zero ML / Zero GPU** | **Yes** | Yes | Yes | Yes |
792
- | **Package size** | 19.5 KB | ~50 MB | ~30 MB | API-only |
793
- | **OpenAI-compatible proxy** | **Yes** | No | Yes | Yes | Yes |
794
- | **Adaptive memory** | **Yes** | No | No | No | No |
795
- | **Semantic cache** | **Yes** (trigram) | No | No | Yes | No |
796
- | **Prompt injection detection** | **Yes** (17 patterns) | No | No | Yes | No |
797
- | **PII redaction** | **Yes** | No | No | Yes | No |
798
- | **Hallucination checks** | **Yes** | No | No | No | No |
799
- | **Cost analytics** | **Yes** | No | Yes | Yes | Yes |
800
- | **Budget alerts** | **Yes** | No | No | Yes | No |
792
+ | **Package size** | 19.5 KB | ~50 MB | ~30 MB | ~15 MB |
793
+ | **OpenAI-compatible proxy** | **Yes** | No | Yes | Yes |
794
+ | **Adaptive memory** | **Yes** | No | No | No |
795
+ | **Semantic cache** | **Yes** (trigram) | No | No | No |
796
+ | **Prompt injection detection** | **Yes** (17 patterns) | No | No | No |
797
+ | **PII redaction** | **Yes** | No | No | No |
798
+ | **Hallucination checks** | **Yes** | No | No | No |
799
+ | **Cost analytics** | **Yes** | No | Yes | No |
800
+ | **Budget alerts** | **Yes** | No | No | No |
801
+ | **Circuit breaker** | **Yes** | No | No | No |
802
+ | **Multi-provider (36+)** | **Yes** | Yes | Yes | Yes |
801
803
  | **Circuit breaker** | **Yes** | No | No | Yes | No |
802
804
  | **LangChain adapter** | **Yes** | No | Yes | Yes | No |
803
805
  | **Python SDK** | **Yes** | Yes | Yes | Yes | Yes |
@@ -852,6 +854,7 @@ import { createProxyServer } from 'adaptive-memory-multi-model-router/server';
852
854
  - You only use one LLM provider
853
855
  - Your workload is >80% expert-level queries (just use GPT-4o directly)
854
856
  - You need 250+ provider integrations (use [Portkey](https://github.com/Portkey-AI/gateway))
857
+ - You need ML-based routing with BERT classifiers (use [RouteLLM](https://github.com/Surfsol/RouteLLM))
855
858
  - You need enterprise SLAs or managed hosting
856
859
 
857
860
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adaptive-memory-multi-model-router",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
4
4
  "shortName": "A3M Router",
5
5
  "displayName": "A3M Router - Adaptive Memory Multi-Model Router",
6
6
  "description": "LLM router & AI gateway with 99.5% routing accuracy — supports 47 providers including DeepSeek, Kimi (Moonshot), Qwen, Zhipu GLM, Yi, Baichuan, MiniMax, StepFun. Zero ML, 19.5KB. Multi-signal routing, semantic cache, guardrails, cost analytics. MIT. TypeScript SDK + Python SDK + OpenAI proxy.",
@@ -53,89 +53,118 @@
53
53
  }
54
54
  },
55
55
  "keywords": [
56
- "llm-proxy",
56
+ "ai-guardrails",
57
+ "moonshot",
58
+ "adaptive-routing",
59
+ "llm-manager",
57
60
  "claude",
58
- "ai",
59
- "openai-compatible",
60
- "no-gpu",
61
- "openai",
62
- "routing-accuracy",
63
- "minimax",
64
- "portkey-alternative",
65
- "中文llm",
66
- "provider-fallback",
67
- "nlp",
68
- "ollama",
69
- "cerebras",
70
- "openai-sdk",
61
+ "guardrails",
71
62
  "ai-sdk",
63
+ "qwen",
64
+ "groq",
65
+ "high-availability",
72
66
  "openai-proxy",
73
- "cerebras-proxy",
74
- "深度求索",
75
- "anthropic",
76
- "ai-cost-optimization",
67
+ "multi-provider",
77
68
  "model-router",
78
- "model-routing",
79
- "chinese-ai",
80
- "vercel-ai",
81
- "ai-load-balancer",
82
- "deepseek",
69
+ "rate-limiter",
83
70
  "llm-routing",
71
+ "semantic-routing",
72
+ "circuit-breaker",
73
+ "openrouter",
74
+ "litellm-alternative",
75
+ "zhipu",
76
+ "llm-management",
77
+ "ai-agent",
78
+ "vercel-ai",
79
+ "deepseek-proxy",
80
+ "groq-proxy",
84
81
  "mistral",
85
- "ollama-proxy",
86
- "moonshot",
87
- "stepfun",
82
+ "llm-gateway",
83
+ "cost-based-routing",
84
+ "ollama",
88
85
  "cost-optimization",
89
- "keyword-routing",
90
- "zhipu",
91
- "llm-manager",
92
- "ai-router",
93
- "multi-provider",
94
- "yi-llm",
95
- "chinese-llm",
96
- "glms",
97
- "llm",
86
+ "chatgpt",
87
+ "nlp",
88
+ "smart-llm-router",
89
+ "openai-sdk",
90
+ "distributed-llm",
91
+ "llm-proxy",
92
+ "chatbot",
93
+ "ai-cost-optimization",
94
+ "stepfun",
95
+ "reverse-proxy",
96
+ "llm-orchestration",
97
+ "llm-caching",
98
+ "intelligent-load-balancer",
98
99
  "llm-load-balancer",
99
- "language-model",
100
+ "ai-gateway",
101
+ "helicone",
102
+ "failover",
103
+ "ai",
104
+ "intent-routing",
105
+ "api-gateway",
106
+ "retry-proxy",
107
+ "glms",
100
108
  "claude-proxy",
109
+ "content-routing",
110
+ "chinese-llm",
101
111
  "lightweight",
102
- "chatgpt",
103
- "smart-routing",
104
- "阿里qwen",
112
+ "dynamic-routing",
113
+ "provider-selector",
114
+ "ai-orchestration",
115
+ "provider-fallback",
105
116
  "zh-llm",
117
+ "load-balancer",
118
+ "request-routing",
119
+ "model-routing",
120
+ "anthropic",
121
+ "阿里qwen",
122
+ "multi-llm",
123
+ "深度求索",
124
+ "intelligent-router",
125
+ "domain-routing",
106
126
  "中文ai",
127
+ "aleph-alpha",
128
+ "llm-router",
129
+ "minimax",
107
130
  "benchmark",
108
- "helicone",
109
- "mistral-proxy",
110
- "llm-orchestration",
111
- "openrouter",
112
- "kimi",
113
- "moonshot-kimi",
114
- "guardrails",
115
- "ai-agent",
131
+ "cerebras",
132
+ "keyword-routing",
133
+ "traffic-routing",
134
+ "中文llm",
135
+ "ai-proxy",
136
+ "llm-cluster",
116
137
  "baichuan",
117
- "routellm-alternative",
138
+ "portkey-alternative",
139
+ "openai",
140
+ "language-model",
141
+ "ai-router",
142
+ "yi-llm",
118
143
  "anthropic-proxy",
119
- "token-counter",
120
- "deepseek-proxy",
121
- "llm-gateway",
122
- "multi-llm",
123
- "ai-gateway",
124
- "groq",
125
- "litellm-alternative",
126
- "ai-proxy",
127
- "llm-router",
128
- "domain-routing",
129
- "groq-proxy",
130
- "qwen",
144
+ "query-routing",
131
145
  "gpt",
146
+ "chinese-ai",
147
+ "moonshot-kimi",
148
+ "routing-accuracy",
149
+ "cerebras-proxy",
132
150
  "openai-api",
133
- "query-routing",
134
- "aleph-alpha",
135
- "semantic-cache",
151
+ "kimi",
152
+ "model-selection",
153
+ "no-gpu",
154
+ "ai-load-balancer",
155
+ "routellm-alternative",
156
+ "token-counter",
157
+ "smart-routing",
158
+ "model-management",
159
+ "deepseek",
160
+ "task-routing",
161
+ "ollama-proxy",
136
162
  "langchain",
137
- "ai-guardrails",
138
- "chatbot"
163
+ "llm-failover",
164
+ "mistral-proxy",
165
+ "openai-compatible",
166
+ "semantic-cache",
167
+ "llm"
139
168
  ],
140
169
  "author": "Das-rebel <subho@example.com>",
141
170
  "license": "MIT",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1H,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACzJ,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,qBA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1B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK,CAAC,OAAe,IAAI;QAC7B,IAAA,+BAAiB,EAAC,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,oBAAoB,IAAI,KAAK,CAAC;QAC/C,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,IAAI,0BAA0B,CAAC;IACtD,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,KAAa;QACnB,OAAO,IAAA,qCAAoB,EAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACK,YAAY,CAClB,UAAkB;QAElB,IAAI,UAAU,GAAG,IAAI;YAAE,OAAO,MAAM,CAAC;QACrC,IAAI,UAAU,GAAG,IAAI;YAAE,OAAO,OAAO,CAAC;QACtC,IAAI,UAAU,GAAG,IAAI;YAAE,OAAO,KAAK,CAAC;QACpC,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA7FD,8BA6FC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,MAAwB;IAChD,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
package/test.js.bak DELETED
@@ -1,376 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * A3M Router Test Suite v1.9.0
4
- * Comprehensive tests for generic provider system
5
- */
6
-
7
- const assert = require('assert');
8
- const {
9
- createA3MRouter,
10
- getAvailableProviders,
11
- registerProvider,
12
- deregisterProvider,
13
- DEFAULT_PROVIDERS,
14
- providerConfig,
15
- routeQuery,
16
- routeBatch,
17
- recommendForTask,
18
- extractQueryFeatures,
19
- MODEL_PROFILES,
20
- countTokens,
21
- estimateCost,
22
- MemoryTree,
23
- CostTracker,
24
- ResponseCache,
25
- ProviderRegistry,
26
- } = require('./dist/index.js');
27
-
28
- let passed = 0;
29
- let failed = 0;
30
-
31
- function test(name, fn) {
32
- try {
33
- fn();
34
- console.log(' ✅ ' + name);
35
- passed++;
36
- } catch (e) {
37
- console.log(' ❌ ' + name + ': ' + e.message);
38
- failed++;
39
- }
40
- }
41
-
42
- function asyncTest(name, fn) {
43
- return fn()
44
- .then(() => {
45
- console.log(' ✅ ' + name);
46
- passed++;
47
- })
48
- .catch(e => {
49
- console.log(' ❌ ' + name + ': ' + e.message);
50
- failed++;
51
- });
52
- }
53
-
54
- console.log('\n═══════════════════════════════════════════════════════════════');
55
- console.log('🧪 A3M Router Test Suite v1.9.0');
56
- console.log('═══════════════════════════════════════════════════════════════\n');
57
-
58
- // ============================================================
59
- // TEST 1: Provider Configuration
60
- // ============================================================
61
- console.log('📦 Provider Configuration Tests');
62
- console.log('─────────────────────────────────────────────────────────────');
63
-
64
- test('providerConfig module loads', () => {
65
- assert(providerConfig, 'providerConfig should be defined');
66
- assert(typeof providerConfig.loadConfig === 'function', 'loadConfig should be a function');
67
- assert(typeof providerConfig.getAvailableProviders === 'function', 'getAvailableProviders should be a function');
68
- });
69
-
70
- test('DEFAULT_PROVIDERS has expected providers', () => {
71
- assert(DEFAULT_PROVIDERS, 'DEFAULT_PROVIDERS should be defined');
72
- assert(DEFAULT_PROVIDERS.groq, 'should have groq');
73
- assert(DEFAULT_PROVIDERS.mistral, 'should have mistral');
74
- assert(DEFAULT_PROVIDERS.cerebras, 'should have cerebras');
75
- assert(DEFAULT_PROVIDERS.commandcode, 'should have commandcode');
76
- assert(DEFAULT_PROVIDERS.opencode, 'should have opencode');
77
- });
78
-
79
- test('getAvailableProviders returns configured providers', () => {
80
- const available = getAvailableProviders();
81
- assert(available, 'should return available providers');
82
- assert(Object.keys(available).length > 0, 'should have at least one provider');
83
-
84
- // Check that available providers have required fields
85
- for (const [id, p] of Object.entries(available)) {
86
- assert(p.id, 'provider should have id');
87
- assert(p.name, 'provider should have name');
88
- assert(p.type, 'provider should have type');
89
- assert(p.models, 'provider should have models');
90
- assert(Array.isArray(p.models), 'models should be an array');
91
- }
92
- });
93
-
94
- test('Provider types are correct', () => {
95
- const available = getAvailableProviders();
96
-
97
- if (available.groq) {
98
- assert.strictEqual(available.groq.type, 'api', 'groq should be api type');
99
- }
100
- if (available.commandcode) {
101
- assert.strictEqual(available.commandcode.type, 'cli', 'commandcode should be cli type');
102
- }
103
- if (available.opencode) {
104
- assert.strictEqual(available.opencode.type, 'cli', 'opencode should be cli type');
105
- }
106
- });
107
-
108
- // ============================================================
109
- // TEST 2: Routing
110
- // ============================================================
111
- console.log('\n🔀 Routing Tests');
112
- console.log('─────────────────────────────────────────────────────────────');
113
-
114
- test('routeQuery returns valid result', () => {
115
- const result = routeQuery('What is 2+2?');
116
- assert(result, 'should return a result');
117
- assert(result.primary_model, 'should have primary_model');
118
- assert(Array.isArray(result.fallback_models), 'should have fallback_models array');
119
- assert(typeof result.estimated_cost === 'number', 'should have estimated_cost');
120
- assert(typeof result.confidence === 'number', 'should have confidence');
121
- });
122
-
123
- test('routeQuery selects free providers for simple queries', () => {
124
- const result = routeQuery('Hello');
125
- assert(result.primary_model, 'should have primary_model');
126
- // Should prefer free/cheap providers for simple queries
127
- assert(result.estimated_cost < 0.5, 'should have low cost for simple query');
128
- });
129
-
130
- test('routeQuery selects appropriate provider for code', () => {
131
- const result = routeQuery('Write a Python function to sort an array');
132
- assert(result.primary_model, 'should have primary_model');
133
- assert(result.reasoning, 'should have reasoning');
134
- // Should mention code in reasoning
135
- assert(result.reasoning.toLowerCase().includes('code') ||
136
- result.features.has_code, 'should detect code');
137
- });
138
-
139
- test('routeBatch returns array of results', () => {
140
- const queries = ['Hello', 'What is 2+2?', 'Write Python code'];
141
- const results = routeBatch(queries);
142
- assert(Array.isArray(results), 'should return array');
143
- assert.strictEqual(results.length, queries.length, 'should have same length as queries');
144
-
145
- results.forEach((r, i) => {
146
- assert(r.primary_model, 'result ' + i + ' should have primary_model');
147
- });
148
- });
149
-
150
- test('recommendForTask returns recommendation', () => {
151
- const rec = recommendForTask('coding');
152
- assert(rec, 'should return recommendation');
153
- assert(rec.primary, 'should have primary');
154
- assert(Array.isArray(rec.fallbacks), 'should have fallbacks array');
155
- assert(rec.reason, 'should have reason');
156
- });
157
-
158
- test('extractQueryFeatures detects code', () => {
159
- const features = extractQueryFeatures('function test() { return 1; }');
160
- assert(features.has_code, 'should detect code');
161
- assert(features.complexity > 0.3, 'should have elevated complexity');
162
- });
163
-
164
- test('extractQueryFeatures detects math', () => {
165
- const features = extractQueryFeatures('Calculate the integral of x^2');
166
- assert(features.has_math, 'should detect math');
167
- });
168
-
169
- test('extractQueryFeatures detects translation', () => {
170
- const features = extractQueryFeatures('Translate hello to French');
171
- assert(features.is_translation, 'should detect translation');
172
- });
173
-
174
- // ============================================================
175
- // TEST 3: Model Profiles
176
- // ============================================================
177
- console.log('\n📊 Model Profile Tests');
178
- console.log('─────────────────────────────────────────────────────────────');
179
-
180
- test('MODEL_PROFILES is populated', () => {
181
- assert(MODEL_PROFILES, 'MODEL_PROFILES should be defined');
182
- assert(Object.keys(MODEL_PROFILES).length > 0, 'should have model profiles');
183
- });
184
-
185
- test('Model profiles have required fields', () => {
186
- for (const [name, profile] of Object.entries(MODEL_PROFILES)) {
187
- assert(profile.name, name + ' should have name');
188
- assert(profile.provider, name + ' should have provider');
189
- assert(typeof profile.cost_per_1k_input === 'number', name + ' should have cost_per_1k_input');
190
- assert(typeof profile.cost_per_1k_output === 'number', name + ' should have cost_per_1k_output');
191
- assert(typeof profile.quality_score === 'number', name + ' should have quality_score');
192
- assert(Array.isArray(profile.strengths), name + ' should have strengths array');
193
- }
194
- });
195
-
196
- // ============================================================
197
- // TEST 4: Token Utilities
198
- // ============================================================
199
- console.log('\n🔢 Token Utility Tests');
200
- console.log('─────────────────────────────────────────────────────────────');
201
-
202
- test('countTokens returns number', () => {
203
- const tokens = countTokens('Hello world');
204
- assert(typeof tokens === 'number', 'should return number');
205
- assert(tokens > 0, 'should return positive number');
206
- });
207
-
208
- test('countTokens counts correctly', () => {
209
- const tokens = countTokens('Hello world');
210
- assert(tokens >= 2, 'should count at least 2 tokens for 2 words');
211
- });
212
-
213
- test('estimateCost returns number', () => {
214
- const cost = estimateCost(100, 50, 'gpt-4o');
215
- assert(typeof cost === 'number', 'should return number');
216
- assert(cost >= 0, 'should return non-negative');
217
- });
218
-
219
- // ============================================================
220
- // TEST 5: A3M Router Factory
221
- // ============================================================
222
- console.log('\n🏭 A3M Router Factory Tests');
223
- console.log('─────────────────────────────────────────────────────────────');
224
-
225
- test('createA3MRouter returns router object', () => {
226
- const router = createA3MRouter({});
227
- assert(router, 'should return router');
228
- assert(typeof router.route === 'function', 'should have route function');
229
- assert(typeof router.routeBatch === 'function', 'should have routeBatch function');
230
- assert(typeof router.recommend === 'function', 'should have recommend function');
231
- });
232
-
233
- test('createA3MRouter has memory', () => {
234
- const router = createA3MRouter({});
235
- assert(router.memory, 'should have memory');
236
- assert(typeof router.memory.add === 'function', 'memory should have add');
237
- assert(typeof router.memory.search === 'function', 'memory should have search');
238
- });
239
-
240
- test('createA3MRouter has cache', () => {
241
- const router = createA3MRouter({});
242
- assert(router.cache, 'should have cache');
243
- });
244
-
245
- test('createA3MRouter has costTracker', () => {
246
- const router = createA3MRouter({});
247
- assert(router.costTracker, 'should have costTracker');
248
- });
249
-
250
- test('createA3MRouter has providers registry', () => {
251
- const router = createA3MRouter({});
252
- assert(router.providers, 'should have providers');
253
- });
254
-
255
- test('createA3MRouter has compression', () => {
256
- const router = createA3MRouter({});
257
- assert(router.compression, 'should have compression');
258
- });
259
-
260
- test('createA3MRouter has vault', () => {
261
- const router = createA3MRouter({});
262
- assert(router.vault, 'should have vault');
263
- });
264
-
265
- test('createA3MRouter has autoFetch', () => {
266
- const router = createA3MRouter({});
267
- assert(router.autoFetch, 'should have autoFetch');
268
- });
269
-
270
- test('createA3MRouter has oauth', () => {
271
- const router = createA3MRouter({});
272
- assert(router.oauth, 'should have oauth');
273
- });
274
-
275
- // ============================================================
276
- // TEST 6: Memory Tree
277
- // ============================================================
278
- console.log('\n🧠 Memory Tree Tests');
279
- console.log('─────────────────────────────────────────────────────────────');
280
-
281
- test('MemoryTree can add and search', () => {
282
- const memory = new MemoryTree({ maxSize: 100 });
283
- memory.add('Python is great for data science', { tags: ['python', 'data'] });
284
- memory.add('JavaScript is great for web', { tags: ['js', 'web'] });
285
-
286
- const results = memory.search('python data');
287
- assert(Array.isArray(results), 'should return array');
288
- assert(results.length > 0, 'should find results');
289
- });
290
-
291
- test('MemoryTree getStats returns stats', () => {
292
- const memory = new MemoryTree({ maxSize: 100 });
293
- memory.add('Test entry', { tags: ['test'] });
294
-
295
- const stats = memory.getStats();
296
- assert(stats, 'should return stats');
297
- assert(typeof stats.totalChunks === 'number', 'should have totalChunks');
298
- assert(typeof stats.indexSize === 'number', 'should have indexSize');
299
- });
300
-
301
- // ============================================================
302
- // TEST 7: Provider Registry
303
- // ============================================================
304
- console.log('\n📋 Provider Registry Tests');
305
- console.log('─────────────────────────────────────────────────────────────');
306
-
307
- test('ProviderRegistry can be instantiated', () => {
308
- const registry = new ProviderRegistry();
309
- assert(registry, 'should create registry');
310
- assert(typeof registry.getReadyProviders === 'function', 'should have getReadyProviders');
311
- assert(typeof registry.selectModel === 'function', 'should have selectModel');
312
- });
313
-
314
- test('ProviderRegistry getStatus returns status', () => {
315
- const registry = new ProviderRegistry();
316
- const status = registry.getStatus();
317
- assert(status, 'should return status');
318
- assert(Array.isArray(status.providers), 'should have providers array');
319
- assert(Array.isArray(status.available), 'should have available array');
320
- });
321
-
322
- // ============================================================
323
- // TEST 8: Dynamic Provider Registration
324
- // ============================================================
325
- console.log('\n🔧 Dynamic Provider Registration Tests');
326
- console.log('─────────────────────────────────────────────────────────────');
327
-
328
- test('registerProvider adds new provider', () => {
329
- const testProvider = {
330
- name: 'TestProvider',
331
- type: 'api',
332
- baseUrl: 'https://test.example.com',
333
- models: ['test-model'],
334
- priority: 99,
335
- };
336
-
337
- registerProvider('test-provider', testProvider);
338
-
339
- // Check it was added to runtime providers
340
- const available = getAvailableProviders();
341
- // Note: won't show up without API key, but should be in _providers
342
- assert(providerConfig._providers['test-provider'], 'should be in _providers');
343
- assert.strictEqual(providerConfig._providers['test-provider'].name, 'TestProvider');
344
-
345
- // Clean up
346
- deregisterProvider('test-provider');
347
- });
348
-
349
- test('deregisterProvider removes provider', () => {
350
- // First add
351
- registerProvider('temp-provider', { name: 'Temp', type: 'api', models: [] });
352
- assert(providerConfig._providers['temp-provider'], 'should exist in _providers');
353
-
354
- // Then remove
355
- deregisterProvider('temp-provider');
356
- assert(!providerConfig._providers['temp-provider'], 'should be removed from _providers');
357
- });
358
-
359
- // ============================================================
360
- // SUMMARY
361
- // ============================================================
362
- console.log('\n═══════════════════════════════════════════════════════════════');
363
- console.log('📊 Test Summary');
364
- console.log('═══════════════════════════════════════════════════════════════');
365
- console.log(' Total: ' + (passed + failed));
366
- console.log(' Passed: ' + passed + ' ✅');
367
- console.log(' Failed: ' + failed + (failed > 0 ? ' ❌' : ''));
368
- console.log('');
369
-
370
- if (failed > 0) {
371
- console.log('❌ Some tests failed');
372
- process.exit(1);
373
- } else {
374
- console.log('✅ All tests passed!');
375
- process.exit(0);
376
- }