adaptive-memory-multi-model-router 2.15.2 → 2.15.3
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/AGENT_COUNCIL_FINDINGS.md +123 -98
- package/ARCHITECTURE.md +1 -1
- package/CAMPAIGN_SUMMARY.md +87 -0
- package/ENTERPRISE_INTEGRATIONS.md +94 -0
- package/INTEGRATION_PROGRESS.md +96 -0
- package/OPPORTUNITIES_100.md +277 -0
- package/POPULARITY_BOOSTERS.md +1 -1
- package/README.md +143 -173
- package/README_ja.md +16 -20
- package/README_zh.md +13 -17
- package/TODO_BROWSER_AUTOMATION.md +87 -0
- package/a3m-integrations-summary.md +73 -0
- package/articles/CHINESE_DIRECTORIES.md +2 -2
- package/articles/CHINESE_SUBMISSIONS_READY.md +5 -5
- package/articles/HN_POST_READY.md +16 -20
- package/articles/HN_SHOW_SEO.md +49 -0
- package/articles/INDIEHACKERS_READY.md +19 -34
- package/articles/PRODUCTHUNT_READY.md +47 -67
- package/articles/REDDIT_SEO_2026.md +50 -0
- package/demo/IMPROVED_PROMPTS.md +3 -3
- package/demo/VEO3_PROMPTS.md +2 -2
- package/demo/VIDEO_PRODUCTION_GUIDE.md +3 -3
- package/dist/analytics/costAnalytics.d.ts +0 -1
- package/dist/benchmark/reproducible.d.ts +0 -1
- package/dist/cache/semanticCache.d.ts +0 -1
- package/dist/cost/budgetEnforcer.d.ts +0 -1
- package/dist/cost/costTracker.d.ts +0 -1
- package/dist/ensemble/multiRoundDialog.d.ts +0 -1
- package/dist/ensemble/shapleyValue.d.ts +0 -1
- package/dist/ensemble.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/integrations/oauth.d.ts +0 -1
- package/dist/integrations/scienceAdapter.d.ts +0 -1
- package/dist/memory/autoFetch.d.ts +0 -1
- package/dist/memory/hybridMemory.d.ts +0 -1
- package/dist/memory/memoryTree.d.ts +0 -1
- package/dist/memory/obsidianVault.d.ts +0 -1
- package/dist/memory/reasoningBank.d.ts +0 -1
- package/dist/observability/changeWatch.d.ts +0 -1
- package/dist/observability/fatigueDetector.d.ts +0 -1
- package/dist/observability/index.d.ts +0 -1
- package/dist/observability/metrics.d.ts +0 -1
- package/dist/observability/middleware.d.ts +0 -1
- package/dist/observability/tracer.d.ts +0 -1
- package/dist/observability/types.d.ts +0 -1
- package/dist/providers/providerConfig.d.ts +0 -1
- package/dist/routing/advancedRouter.d.ts +1 -2
- package/dist/routing/advancedRouter.js +84 -0
- package/dist/routing/advancedRouter.js.map +1 -1
- package/dist/routing/crossModelValidation.d.ts +0 -1
- package/dist/routing/providerHealth.d.ts +77 -2
- package/dist/routing/providerHealth.js +190 -4
- package/dist/routing/providerHealth.js.map +1 -1
- package/dist/routing/providerRetry.d.ts +0 -1
- package/dist/routing/shadowSampler.d.ts +187 -0
- package/dist/routing/shadowSampler.js +306 -0
- package/dist/routing/shadowSampler.js.map +1 -0
- package/dist/sdk.d.ts +0 -1
- package/dist/security/guardrails.d.ts +0 -1
- package/dist/server/dashboard.d.ts +0 -1
- package/dist/server/handlers/chatHandler.d.ts +0 -1
- package/dist/server/handlers/completionsHandler.d.ts +0 -1
- package/dist/server/handlers/embeddingsHandler.d.ts +0 -1
- package/dist/server/handlers/healthHandler.d.ts +0 -1
- package/dist/server/handlers/metricsHandler.d.ts +0 -1
- package/dist/server/handlers/modelsHandler.d.ts +0 -1
- package/dist/server/metrics.d.ts +0 -1
- package/dist/server/modelMapper.d.ts +0 -1
- package/dist/server/proxyServer.d.ts +0 -1
- package/dist/server/router.d.ts +0 -1
- package/dist/server/state.d.ts +0 -1
- package/dist/tui/dashboard.d.ts +0 -1
- package/dist/utils/costUtils.d.ts +0 -1
- package/dist/utils/sorting.d.ts +0 -1
- package/dist/utils/tokenUtils.d.ts +0 -1
- package/docs/comparison-litellm.md +10 -18
- package/docs/index.html +29 -34
- package/docs/llms-full.txt +6 -6
- package/docs/llms.txt +21 -23
- package/docs-site/index.html +19 -19
- package/integrations/browser-use/README.md +155 -0
- package/integrations/browser-use/examples/form-filling.ts +179 -0
- package/integrations/browser-use/index.ts +145 -0
- package/integrations/browser-use/package.json +34 -0
- package/integrations/browser-use/tsconfig.json +17 -0
- package/integrations/mcp-browser/README.md +177 -0
- package/integrations/mcp-browser/package.json +38 -0
- package/integrations/mcp-browser/src/index.ts +297 -0
- package/integrations/sota-browser/README.md +191 -0
- package/integrations/sota-browser/package.json +34 -0
- package/llms-full.txt +6 -6
- package/llms.txt +22 -33
- package/mcp-server/package.json +0 -6
- package/mcp-server/tsconfig.json +2 -3
- package/package.json +3 -3
- package/sitemap.xml +15 -9
- package/src/routing/advancedRouter.ts +101 -0
- package/src/routing/providerHealth.ts +234 -4
- package/src/routing/shadowSampler.ts +427 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -94
- package/.github/ISSUE_TEMPLATE/checklist.md +0 -35
- package/.github/ISSUE_TEMPLATE/config.yml +0 -17
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -71
- package/.well-known/ai-plugin.json +0 -16
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ShadowSampler — Value-Proportional Shadow Verification
|
|
4
|
+
*
|
|
5
|
+
* Implements Optimal Defense Theory (Rhoades 1979; McKey 1974; Zangerl & Bazzaz 1992)
|
|
6
|
+
* from plant ecological economics:
|
|
7
|
+
*
|
|
8
|
+
* "A plant allocates defensive compounds (defense cost) in proportion to
|
|
9
|
+
* tissue value, attack probability, and the marginal cost of defense."
|
|
10
|
+
*
|
|
11
|
+
* Mapped to A3M routing:
|
|
12
|
+
* - Tissue value → query stakes / expected cost of wrong answer
|
|
13
|
+
* - Attack probability → probability that the primary provider fails/misbehaves
|
|
14
|
+
* - Defense cost → cost of the shadow verification call
|
|
15
|
+
* - Marginal return → expected reduction in error rate from verification
|
|
16
|
+
*
|
|
17
|
+
* Instead of binary always-on (wasteful) or always-off (risky), ODT says:
|
|
18
|
+
* Sample shadow verification PROPORTIONALLY to expected value of verification.
|
|
19
|
+
*
|
|
20
|
+
* The sampling probability is:
|
|
21
|
+
* P(shadow) = f(expected_error_cost_reduction, query_risk)
|
|
22
|
+
*
|
|
23
|
+
* This is NOT the Zahavi "shared expert" (which always runs on 100% of queries).
|
|
24
|
+
* ODT shadow runs probabilistically — only on queries where the expected
|
|
25
|
+
* verification benefit exceeds the verification cost.
|
|
26
|
+
*
|
|
27
|
+
* Usage:
|
|
28
|
+
* const sampler = new ShadowSampler();
|
|
29
|
+
* const decision = await sampler.routeWithShadow(query, { strategy: 'auto' });
|
|
30
|
+
* // decision.hasShadow === true iff we sampled a shadow provider
|
|
31
|
+
* // decision.primaryResult and decision.shadowResult are compared automatically
|
|
32
|
+
*/
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.ShadowSampler = void 0;
|
|
35
|
+
const advancedRouter_1 = require("./advancedRouter");
|
|
36
|
+
const providerConfig_1 = require("../providers/providerConfig");
|
|
37
|
+
/**
|
|
38
|
+
* Optimal Defense Theory Shadow Sampler
|
|
39
|
+
*
|
|
40
|
+
* Allocates shadow verification proportionally to query value and risk.
|
|
41
|
+
*
|
|
42
|
+
* The ODT sampling probability:
|
|
43
|
+
* P_shadow = min(maxP, baseP + risk_adj + cost_adj + complexity_adj)
|
|
44
|
+
*
|
|
45
|
+
* where:
|
|
46
|
+
* baseP = baseline verification rate (ODT " constitutive defense")
|
|
47
|
+
* risk_adj = risk_profile scaling (ODT "induced defense")
|
|
48
|
+
* cost_adj = output cost scaling (value of correct answer)
|
|
49
|
+
* complexity_adj = query complexity signal
|
|
50
|
+
*/
|
|
51
|
+
class ShadowSampler {
|
|
52
|
+
config;
|
|
53
|
+
// Cached shadow provider (auto-selected on first call)
|
|
54
|
+
_shadowProvider = null;
|
|
55
|
+
// Counters for sampling statistics
|
|
56
|
+
_shadowCount = 0;
|
|
57
|
+
_totalCount = 0;
|
|
58
|
+
constructor(config = {}) {
|
|
59
|
+
this.config = {
|
|
60
|
+
minQueryStake: config.minQueryStake ?? 0.01,
|
|
61
|
+
maxShadowProbability: config.maxShadowProbability ?? 0.15,
|
|
62
|
+
riskScalingFactor: config.riskScalingFactor ?? 0.5,
|
|
63
|
+
costScalingFactor: config.costScalingFactor ?? 0.3,
|
|
64
|
+
shadowProvider: config.shadowProvider ?? null,
|
|
65
|
+
forceShadowProvider: config.forceShadowProvider ?? false,
|
|
66
|
+
useComplexitySignal: config.useComplexitySignal ?? true,
|
|
67
|
+
forceShadow: config.forceShadow ?? false,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Auto-select the cheapest available provider as the shadow.
|
|
72
|
+
* Excludes the primary provider to ensure diversity.
|
|
73
|
+
*/
|
|
74
|
+
selectShadowProvider(primaryProvider) {
|
|
75
|
+
if (this.config.forceShadowProvider && this.config.shadowProvider) {
|
|
76
|
+
return this.config.shadowProvider;
|
|
77
|
+
}
|
|
78
|
+
if (this._shadowProvider)
|
|
79
|
+
return this._shadowProvider;
|
|
80
|
+
const profiles = (0, providerConfig_1.getAvailableProviders)();
|
|
81
|
+
const candidates = Object.entries(profiles)
|
|
82
|
+
.filter(([name, p]) => {
|
|
83
|
+
// Exclude primary
|
|
84
|
+
if (name === primaryProvider)
|
|
85
|
+
return false;
|
|
86
|
+
// Must be available (has API key) — cost must be finite
|
|
87
|
+
const cost = (p.costPerK.input + p.costPerK.output) / 2;
|
|
88
|
+
return cost < Infinity;
|
|
89
|
+
})
|
|
90
|
+
.sort((a, b) => {
|
|
91
|
+
const costA = (a[1].costPerK.input + a[1].costPerK.output) / 2;
|
|
92
|
+
const costB = (b[1].costPerK.input + b[1].costPerK.output) / 2;
|
|
93
|
+
return costA - costB;
|
|
94
|
+
});
|
|
95
|
+
if (candidates.length === 0) {
|
|
96
|
+
// Fallback: pick any non-primary
|
|
97
|
+
const fallback = Object.keys(profiles).find(n => n !== primaryProvider);
|
|
98
|
+
this._shadowProvider = fallback || primaryProvider;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this._shadowProvider = candidates[0][0];
|
|
102
|
+
}
|
|
103
|
+
return this._shadowProvider;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Estimate the query "stakes" — the expected cost of a wrong answer.
|
|
107
|
+
*
|
|
108
|
+
* ODT maps this to "tissue value": how much is this asset worth protecting?
|
|
109
|
+
* In routing terms: if this query fails, how much does it cost?
|
|
110
|
+
*
|
|
111
|
+
* We approximate this as:
|
|
112
|
+
* stake ≈ estimated_output_tokens × cost_per_token × criticality_multiplier
|
|
113
|
+
*
|
|
114
|
+
* where criticality is derived from query complexity and risk_profile.
|
|
115
|
+
*/
|
|
116
|
+
estimateQueryStake(features) {
|
|
117
|
+
const estimatedTokens = features.length * 1.5; // rough estimate
|
|
118
|
+
const avgCostPerToken = 0.0001; // roughly $0.10/1K tokens
|
|
119
|
+
const stake = estimatedTokens * avgCostPerToken;
|
|
120
|
+
// Criticality multiplier from risk profile
|
|
121
|
+
const riskMultiplier = {
|
|
122
|
+
high: 10.0, // Wrong answer could cause real harm — worth verifying
|
|
123
|
+
medium: 2.0, // Some cost to wrong answer
|
|
124
|
+
low: 0.5, // Low stakes — skip verification
|
|
125
|
+
};
|
|
126
|
+
const riskMult = riskMultiplier[features.risk_profile || 'medium'] ?? 1.0;
|
|
127
|
+
// Complexity multiplier — complex queries are harder to verify but more valuable
|
|
128
|
+
// We use complexity as a proxy for "correctness is harder to judge"
|
|
129
|
+
const complexityMultiplier = 1 + (features.complexity || 0) * 2;
|
|
130
|
+
return stake * riskMult * complexityMultiplier;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Compute the ODT sampling probability for this query.
|
|
134
|
+
*
|
|
135
|
+
* ODT principle: defense (shadow) allocation ∝ expected benefit of defense.
|
|
136
|
+
* Expected benefit = P(failure) × cost_of_failure
|
|
137
|
+
*
|
|
138
|
+
* So P(shadow) scales with:
|
|
139
|
+
* 1. Query stake (expected cost of wrong answer)
|
|
140
|
+
* 2. Risk profile (probability of primary failure)
|
|
141
|
+
* 3. Output cost (verification ROI — cheaper outputs need less verification)
|
|
142
|
+
* 4. Complexity (complex queries benefit more from verification)
|
|
143
|
+
*/
|
|
144
|
+
computeShadowProbability(features, stake) {
|
|
145
|
+
// Base probability (ODT "constitutive defense" — baseline verification rate)
|
|
146
|
+
let p = 0.02; // 2% baseline
|
|
147
|
+
// === STAKES ADJUSTMENT (ODT "tissue value") ===
|
|
148
|
+
// Higher stake → proportionally higher verification probability
|
|
149
|
+
// Scale from 2% to maxP as stake goes from minStake to $1.00
|
|
150
|
+
if (stake >= this.config.minQueryStake) {
|
|
151
|
+
const stakeAdj = Math.min((stake - this.config.minQueryStake) / (1.0 - this.config.minQueryStake), 1.0) * (this.config.maxShadowProbability - 0.02);
|
|
152
|
+
p += stakeAdj;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
// Below minimum stake — no verification regardless
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
158
|
+
// === RISK ADJUSTMENT (ODT "attack probability") ===
|
|
159
|
+
// High-risk queries are more likely to have primary failures
|
|
160
|
+
// Scale risk_adj by riskScalingFactor (0.5 = 50% boost for high-risk)
|
|
161
|
+
const riskAdj = {
|
|
162
|
+
high: 0.10 * this.config.riskScalingFactor,
|
|
163
|
+
medium: 0.03 * this.config.riskScalingFactor,
|
|
164
|
+
low: 0.0,
|
|
165
|
+
};
|
|
166
|
+
p += riskAdj[features.risk_profile || 'medium'] ?? 0;
|
|
167
|
+
// === COMPLEXITY ADJUSTMENT (ODT "defense efficacy") ===
|
|
168
|
+
// Complex queries benefit more from verification (more errors to catch)
|
|
169
|
+
// But also harder to verify (requires domain knowledge to judge)
|
|
170
|
+
if (this.config.useComplexitySignal) {
|
|
171
|
+
if (features.has_code) {
|
|
172
|
+
p += 0.05; // Code verification has high ROI (bugs are costly)
|
|
173
|
+
}
|
|
174
|
+
if (features.requires_reasoning) {
|
|
175
|
+
p += 0.03; // Reasoning errors are subtle but costly
|
|
176
|
+
}
|
|
177
|
+
if (features.has_math) {
|
|
178
|
+
p += 0.04; // Math has objective ground truth — easy to verify (note: field is has_math)
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// === COST SCALING (ODT "marginal defense cost") ===
|
|
182
|
+
// Expensive outputs are harder to produce — verify to avoid waste
|
|
183
|
+
if (this.config.costScalingFactor > 0 && features.length > 500) {
|
|
184
|
+
const costAdj = Math.min((features.length - 500) / 10000, // scale up for very long outputs
|
|
185
|
+
0.05) * this.config.costScalingFactor;
|
|
186
|
+
p += costAdj;
|
|
187
|
+
}
|
|
188
|
+
// Clamp to [0, maxShadowProbability]
|
|
189
|
+
return Math.min(Math.max(p, 0), this.config.maxShadowProbability);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Route a query, with optional ODT-proportional shadow verification.
|
|
193
|
+
*
|
|
194
|
+
* @param prompt - The user query
|
|
195
|
+
* @param options - Routing options (same as routeQuery)
|
|
196
|
+
* @returns ShadowDecision with shadow metadata
|
|
197
|
+
*/
|
|
198
|
+
routeWithShadow(prompt, options) {
|
|
199
|
+
const features = (0, advancedRouter_1.extractQueryFeatures)(prompt);
|
|
200
|
+
const primaryDecision = (0, advancedRouter_1.routeQuery)(prompt, options?.available_models, options?.budget_multiplier);
|
|
201
|
+
// Compute query stakes and shadow probability
|
|
202
|
+
const stake = this.estimateQueryStake(features);
|
|
203
|
+
const shadowProb = this.computeShadowProbability(features, stake);
|
|
204
|
+
// ODT sampling decision
|
|
205
|
+
const shouldShadow = this.config.forceShadow || Math.random() < shadowProb;
|
|
206
|
+
const shadowProvider = shouldShadow
|
|
207
|
+
? this.selectShadowProvider(primaryDecision.primary_model || '')
|
|
208
|
+
: null;
|
|
209
|
+
if (shouldShadow) {
|
|
210
|
+
this._shadowCount++;
|
|
211
|
+
}
|
|
212
|
+
this._totalCount++;
|
|
213
|
+
const reasoning = shouldShadow
|
|
214
|
+
? `ODT shadow: stake=${stake.toFixed(4)}, risk=${features.risk_profile}, P=${shadowProb.toFixed(3)}, complexity=${features.complexity.toFixed(2)}`
|
|
215
|
+
: `ODT no-shadow: stake=${stake.toFixed(4)} below threshold`;
|
|
216
|
+
return {
|
|
217
|
+
...primaryDecision,
|
|
218
|
+
hasShadow: shouldShadow,
|
|
219
|
+
shadowProvider,
|
|
220
|
+
shadowProbability: shadowProb,
|
|
221
|
+
features,
|
|
222
|
+
shadowReasoning: reasoning,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Compare primary and shadow outputs.
|
|
227
|
+
* Returns the "better" answer and confidence delta.
|
|
228
|
+
*
|
|
229
|
+
* For production use: this would call both providers in parallel
|
|
230
|
+
* and compare outputs. For now, returns a stub that signals
|
|
231
|
+
* the caller should handle comparison.
|
|
232
|
+
*/
|
|
233
|
+
async compareOutputs(primaryAnswer, shadowAnswer) {
|
|
234
|
+
if (!shadowAnswer) {
|
|
235
|
+
return {
|
|
236
|
+
primary: primaryAnswer,
|
|
237
|
+
shadow: null,
|
|
238
|
+
winner: 'no-shadow',
|
|
239
|
+
confidenceDelta: 0,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
// Simple comparison: length + character overlap as proxy for agreement
|
|
243
|
+
// In production, this would use a proper semantic similarity check
|
|
244
|
+
const primaryLen = primaryAnswer.length;
|
|
245
|
+
const shadowLen = shadowAnswer.length;
|
|
246
|
+
const lengthRatio = Math.min(primaryLen, shadowLen) / Math.max(primaryLen, shadowLen);
|
|
247
|
+
// Count common bigrams as a simple similarity proxy
|
|
248
|
+
const primaryBigrams = new Set();
|
|
249
|
+
const shadowBigrams = new Set();
|
|
250
|
+
for (let i = 0; i < primaryAnswer.length - 1; i++) {
|
|
251
|
+
primaryBigrams.add(primaryAnswer.slice(i, i + 2));
|
|
252
|
+
}
|
|
253
|
+
for (let i = 0; i < shadowAnswer.length - 1; i++) {
|
|
254
|
+
shadowBigrams.add(shadowAnswer.slice(i, i + 2));
|
|
255
|
+
}
|
|
256
|
+
let intersection = 0;
|
|
257
|
+
for (const bg of primaryBigrams) {
|
|
258
|
+
if (shadowBigrams.has(bg))
|
|
259
|
+
intersection++;
|
|
260
|
+
}
|
|
261
|
+
const union = primaryBigrams.size + shadowBigrams.size - intersection;
|
|
262
|
+
const jaccard = union > 0 ? intersection / union : 0;
|
|
263
|
+
// High agreement (jaccard > 0.8) → trust primary
|
|
264
|
+
// Low agreement → flag for review or prefer primary
|
|
265
|
+
const winner = jaccard > 0.8 ? 'primary'
|
|
266
|
+
: jaccard > 0.5 ? 'tie'
|
|
267
|
+
: 'shadow'; // Low agreement: shadow might have caught something
|
|
268
|
+
const confidenceDelta = jaccard > 0.8 ? 0 : -0.1; // Reduce confidence if they differ
|
|
269
|
+
return {
|
|
270
|
+
primary: primaryAnswer,
|
|
271
|
+
shadow: shadowAnswer,
|
|
272
|
+
winner,
|
|
273
|
+
confidenceDelta,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Get sampling statistics for monitoring.
|
|
278
|
+
*/
|
|
279
|
+
getStats() {
|
|
280
|
+
return {
|
|
281
|
+
shadowCount: this._shadowCount,
|
|
282
|
+
totalCount: this._totalCount,
|
|
283
|
+
shadowRate: this._totalCount > 0 ? this._shadowCount / this._totalCount : 0,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Reset statistics counters.
|
|
288
|
+
*/
|
|
289
|
+
resetStats() {
|
|
290
|
+
this._shadowCount = 0;
|
|
291
|
+
this._totalCount = 0;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Update configuration at runtime.
|
|
295
|
+
*/
|
|
296
|
+
configure(config) {
|
|
297
|
+
this.config = { ...this.config, ...config };
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
exports.ShadowSampler = ShadowSampler;
|
|
301
|
+
// ============================================================
|
|
302
|
+
// NOTE: Named exports are at declaration level above.
|
|
303
|
+
// ShadowSampler, ShadowSamplerConfig, ShadowDecision, ShadowedResponse
|
|
304
|
+
// are all exported via 'export interface' / 'export class'
|
|
305
|
+
// ============================================================
|
|
306
|
+
//# sourceMappingURL=shadowSampler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadowSampler.js","sourceRoot":"","sources":["../../src/routing/shadowSampler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;;AAEH,qDAAmF;AACnF,gEAAwF;AAiFxF;;;;;;;;;;;;;GAaG;AACH,MAAa,aAAa;IAChB,MAAM,CAAgG;IAE9G,uDAAuD;IAC/C,eAAe,GAAkB,IAAI,CAAC;IAE9C,mCAAmC;IAC3B,YAAY,GAAG,CAAC,CAAC;IACjB,WAAW,GAAG,CAAC,CAAC;IAExB,YAAY,SAA8B,EAAE;QAC1C,IAAI,CAAC,MAAM,GAAG;YACZ,aAAa,EAAE,MAAM,CAAC,aAAa,IAAI,IAAI;YAC3C,oBAAoB,EAAE,MAAM,CAAC,oBAAoB,IAAI,IAAI;YACzD,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,IAAI,GAAG;YAClD,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,IAAI,GAAG;YAClD,cAAc,EAAE,MAAM,CAAC,cAAc,IAAI,IAAI;YAC7C,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,IAAI,KAAK;YACxD,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,IAAI,IAAI;YACvD,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,KAAK;SACzC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACK,oBAAoB,CAAC,eAAuB;QAClD,IAAI,IAAI,CAAC,MAAM,CAAC,mBAAmB,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAClE,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC;QACpC,CAAC;QAED,IAAI,IAAI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AM,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC9C,CAAC;CACF;AApSD,sCAoSC;AAED,+DAA+D;AAC/D,sDAAsD;AACtD,uEAAuE;AACvE,2DAA2D;AAC3D,+DAA+D"}
|
package/dist/sdk.d.ts
CHANGED
|
@@ -56,4 +56,3 @@ export declare function registerProvider(id: string, name: string): void;
|
|
|
56
56
|
*/
|
|
57
57
|
export declare function handleDashboardRequest(req: http.IncomingMessage, res: http.ServerResponse): boolean;
|
|
58
58
|
export declare function getDashboardHTML(): string;
|
|
59
|
-
//# sourceMappingURL=dashboard.d.ts.map
|
|
@@ -8,4 +8,3 @@ import * as http from 'http';
|
|
|
8
8
|
import { RouteContext } from '../router';
|
|
9
9
|
export declare function handleChatCompletions(req: http.IncomingMessage, res: http.ServerResponse, ctx: RouteContext): Promise<void>;
|
|
10
10
|
export default handleChatCompletions;
|
|
11
|
-
//# sourceMappingURL=chatHandler.d.ts.map
|
|
@@ -7,4 +7,3 @@ import * as http from 'http';
|
|
|
7
7
|
import { RouteContext } from '../router';
|
|
8
8
|
export declare function handleCompletions(req: http.IncomingMessage, res: http.ServerResponse, ctx: RouteContext): Promise<void>;
|
|
9
9
|
export default handleCompletions;
|
|
10
|
-
//# sourceMappingURL=completionsHandler.d.ts.map
|
|
@@ -14,4 +14,3 @@ import * as http from 'http';
|
|
|
14
14
|
import { RouteContext } from '../router';
|
|
15
15
|
export declare function handleEmbeddings(req: http.IncomingMessage, res: http.ServerResponse, ctx: RouteContext): Promise<void>;
|
|
16
16
|
export default handleEmbeddings;
|
|
17
|
-
//# sourceMappingURL=embeddingsHandler.d.ts.map
|
|
@@ -7,4 +7,3 @@ import * as http from 'http';
|
|
|
7
7
|
import { RouteContext } from '../router';
|
|
8
8
|
export declare function handleHealth(_req: http.IncomingMessage, res: http.ServerResponse, _ctx: RouteContext): Promise<void>;
|
|
9
9
|
export default handleHealth;
|
|
10
|
-
//# sourceMappingURL=healthHandler.d.ts.map
|
|
@@ -8,4 +8,3 @@ import * as http from 'http';
|
|
|
8
8
|
import { RouteContext } from '../router';
|
|
9
9
|
export declare function handleMetrics(_req: http.IncomingMessage, res: http.ServerResponse, _ctx: RouteContext): void;
|
|
10
10
|
export default handleMetrics;
|
|
11
|
-
//# sourceMappingURL=metricsHandler.d.ts.map
|
package/dist/server/metrics.d.ts
CHANGED
package/dist/server/router.d.ts
CHANGED
package/dist/server/state.d.ts
CHANGED
package/dist/tui/dashboard.d.ts
CHANGED
|
@@ -55,4 +55,3 @@ export declare function qualityAdjustedCostScore(costScore: number, qualityScore
|
|
|
55
55
|
*/
|
|
56
56
|
export declare function budgetAwareCostScore(costPer1K: number, budgetMultiplier?: number): number;
|
|
57
57
|
export declare function runValidationTests(): void;
|
|
58
|
-
//# sourceMappingURL=costUtils.d.ts.map
|
package/dist/utils/sorting.d.ts
CHANGED
|
@@ -8,16 +8,15 @@ litellm (48K★) is the most popular LLM gateway. Here's why A3M exists alongsid
|
|
|
8
8
|
|---------|---------|------------|
|
|
9
9
|
| **Approach** | Sequential fallback | Parallel ensemble |
|
|
10
10
|
| **Model selection** | Try one, fail, try next | Run all, pick best by confidence |
|
|
11
|
-
| **
|
|
12
|
-
| **Cost** | Pay for every attempt | Pay for best response |
|
|
11
|
+
| **Cost model** | Pay for every attempt | Pay for best response only |
|
|
13
12
|
| **Latency** | N × round-trip (sequential) | 1 × round-trip (parallel) |
|
|
14
13
|
| **Memory** | None | Episodic memory across sessions |
|
|
15
14
|
| **Size** | ~1.5GB (PyTorch) | 19.5KB (zero ML) |
|
|
16
15
|
| **Startup** | ~3s | <100ms |
|
|
17
16
|
| **GPU required** | Yes (for some models) | No |
|
|
18
|
-
| **
|
|
19
|
-
| **
|
|
20
|
-
| **
|
|
17
|
+
| **Routing accuracy** | Claims "100%" (no data) | 67% exact tier match (MMR-Bench) |
|
|
18
|
+
| **Cost savings** | Not published | 63% vs all-premium (MMR-Bench) |
|
|
19
|
+
| **Cache** | None | Semantic (embedding-based) |
|
|
21
20
|
|
|
22
21
|
## The Core Difference
|
|
23
22
|
|
|
@@ -54,11 +53,12 @@ const result = await router.route("Explain quantum computing")
|
|
|
54
53
|
|
|
55
54
|
## When to Use A3M
|
|
56
55
|
|
|
57
|
-
- You want the **cheapest** routing (
|
|
58
|
-
- You want
|
|
59
|
-
- You want **memory** across sessions (only router
|
|
56
|
+
- You want the **cheapest** routing (parallel execution means you only pay for the best result)
|
|
57
|
+
- You want **highest accuracy** (confidence-weighted ensemble beats sequential fallback)
|
|
58
|
+
- You want **memory** across sessions (only router with episodic memory)
|
|
60
59
|
- You want **sub-100ms startup** (litellm takes ~3s)
|
|
61
|
-
- You want **zero ML dependencies** (no GPU, no PyTorch)
|
|
60
|
+
- You want **zero ML dependencies** (no GPU, no PyTorch, 19.5KB)
|
|
61
|
+
- You want **semantic caching** (avoid repeated API calls for similar queries)
|
|
62
62
|
- You're building in Node.js/TypeScript
|
|
63
63
|
|
|
64
64
|
## When to Use Both
|
|
@@ -75,14 +75,6 @@ const router = createRouter({
|
|
|
75
75
|
|
|
76
76
|
This gives you litellm's 100+ providers AND A3M's parallel scoring.
|
|
77
77
|
|
|
78
|
-
## The Benchmark Question
|
|
79
|
-
|
|
80
|
-
litellm claims "100% routing accuracy" but publishes **zero data** to back this up. RouterArena (arXiv:2510.00202) is the first standardized benchmark for LLM routers. A3M submitted, litellm didn't.
|
|
81
|
-
|
|
82
|
-
> "Benchmark or GTFO." — A principle we stand by.
|
|
83
|
-
|
|
84
|
-
If litellm submits to RouterArena and scores higher than 96.77%, we'll celebrate. Competition drives improvement.
|
|
85
|
-
|
|
86
78
|
---
|
|
87
79
|
|
|
88
|
-
[GitHub](https://github.com/Das-rebel/a3m-router) · [npm](https://www.npmjs.com/package/adaptive-memory-multi-model-router)
|
|
80
|
+
[GitHub](https://github.com/Das-rebel/a3m-router) · [npm](https://www.npmjs.com/package/adaptive-memory-multi-model-router)
|