adaptive-memory-multi-model-router 1.2.2 → 1.3.1

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.
Files changed (195) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +146 -66
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/integrations/airtable.js +20 -0
  6. package/dist/integrations/discord.js +18 -0
  7. package/dist/integrations/github.js +23 -0
  8. package/dist/integrations/gmail.js +19 -0
  9. package/dist/integrations/google-calendar.js +18 -0
  10. package/dist/integrations/index.js +61 -0
  11. package/dist/integrations/jira.js +21 -0
  12. package/dist/integrations/linear.js +19 -0
  13. package/dist/integrations/notion.js +19 -0
  14. package/dist/integrations/slack.js +18 -0
  15. package/dist/integrations/telegram.js +19 -0
  16. package/dist/providers/registry.js +7 -3
  17. package/docs/ARCHITECTURAL-IMPROVEMENTS-2025.md +1391 -0
  18. package/docs/ARCHITECTURAL-IMPROVEMENTS-REVISED-2025.md +1051 -0
  19. package/docs/CONFIGURATION.md +476 -0
  20. package/docs/COUNCIL_DECISION.json +308 -0
  21. package/docs/COUNCIL_SUMMARY.md +265 -0
  22. package/docs/COUNCIL_V2.2_DECISION.md +416 -0
  23. package/docs/IMPROVEMENT_ROADMAP.md +515 -0
  24. package/docs/LLM_COUNCIL_DECISION.md +508 -0
  25. package/docs/QUICK_START_VISIBILITY.md +782 -0
  26. package/docs/REDDIT_GAP_ANALYSIS.md +299 -0
  27. package/docs/RESEARCH_BACKED_IMPROVEMENTS.md +1180 -0
  28. package/docs/TMLPD_QNA.md +751 -0
  29. package/docs/TMLPD_V2.1_COMPLETE.md +763 -0
  30. package/docs/TMLPD_V2.2_RESEARCH_ROADMAP.md +754 -0
  31. package/docs/V2.2_IMPLEMENTATION_COMPLETE.md +446 -0
  32. package/docs/V2_IMPLEMENTATION_GUIDE.md +388 -0
  33. package/docs/VISIBILITY_ADOPTION_PLAN.md +1005 -0
  34. package/docs/launch-content/LAUNCH_EXECUTION_CHECKLIST.md +421 -0
  35. package/docs/launch-content/README.md +457 -0
  36. package/docs/launch-content/assets/cost_comparison_100_tasks.png +0 -0
  37. package/docs/launch-content/assets/cumulative_savings.png +0 -0
  38. package/docs/launch-content/assets/parallel_speedup.png +0 -0
  39. package/docs/launch-content/assets/provider_pricing_comparison.png +0 -0
  40. package/docs/launch-content/assets/task_breakdown_comparison.png +0 -0
  41. package/docs/launch-content/generate_charts.py +313 -0
  42. package/docs/launch-content/hn_show_post.md +139 -0
  43. package/docs/launch-content/partner_outreach_templates.md +745 -0
  44. package/docs/launch-content/reddit_posts.md +467 -0
  45. package/docs/launch-content/twitter_thread.txt +460 -0
  46. package/examples/QUICKSTART.md +1 -1
  47. package/openclaw-alexa-bridge/ALL_REMAINING_FIXES_PLAN.md +313 -0
  48. package/openclaw-alexa-bridge/REMAINING_FIXES_SUMMARY.md +277 -0
  49. package/openclaw-alexa-bridge/src/alexa_handler_no_tmlpd.js +1234 -0
  50. package/openclaw-alexa-bridge/test_fixes.js +77 -0
  51. package/package.json +120 -29
  52. package/package.json.tmp +0 -0
  53. package/qna/TMLPD_QNA.md +3 -3
  54. package/skill/SKILL.md +2 -2
  55. package/src/__tests__/integration/tmpld_integration.test.py +540 -0
  56. package/src/agents/skill_enhanced_agent.py +318 -0
  57. package/src/memory/__init__.py +15 -0
  58. package/src/memory/agentic_memory.py +353 -0
  59. package/src/memory/semantic_memory.py +444 -0
  60. package/src/memory/simple_memory.py +466 -0
  61. package/src/memory/working_memory.py +447 -0
  62. package/src/orchestration/__init__.py +52 -0
  63. package/src/orchestration/execution_engine.py +353 -0
  64. package/src/orchestration/halo_orchestrator.py +367 -0
  65. package/src/orchestration/mcts_workflow.py +498 -0
  66. package/src/orchestration/role_assigner.py +473 -0
  67. package/src/orchestration/task_planner.py +522 -0
  68. package/src/providers/__init__.py +67 -0
  69. package/src/providers/anthropic.py +304 -0
  70. package/src/providers/base.py +241 -0
  71. package/src/providers/cerebras.py +373 -0
  72. package/src/providers/registry.py +476 -0
  73. package/src/routing/__init__.py +30 -0
  74. package/src/routing/universal_router.py +621 -0
  75. package/src/skills/TMLPD-QUICKREF.md +210 -0
  76. package/src/skills/TMLPD-SETUP-SUMMARY.md +157 -0
  77. package/src/skills/TMLPD.md +540 -0
  78. package/src/skills/__tests__/skill_manager.test.ts +328 -0
  79. package/src/skills/skill_manager.py +385 -0
  80. package/src/skills/test-tmlpd.sh +108 -0
  81. package/src/skills/tmlpd-category.yaml +67 -0
  82. package/src/skills/tmlpd-monitoring.yaml +188 -0
  83. package/src/skills/tmlpd-phase.yaml +132 -0
  84. package/src/state/__init__.py +17 -0
  85. package/src/state/simple_checkpoint.py +508 -0
  86. package/src/tmlpd_agent.py +464 -0
  87. package/src/tmpld_v2.py +427 -0
  88. package/src/workflows/__init__.py +18 -0
  89. package/src/workflows/advanced_difficulty_classifier.py +377 -0
  90. package/src/workflows/chaining_executor.py +417 -0
  91. package/src/workflows/difficulty_integration.py +209 -0
  92. package/src/workflows/orchestrator.py +469 -0
  93. package/src/workflows/orchestrator_executor.py +456 -0
  94. package/src/workflows/parallelization_executor.py +382 -0
  95. package/src/workflows/router.py +311 -0
  96. package/test_integration_simple.py +86 -0
  97. package/test_mcts_workflow.py +150 -0
  98. package/test_templd_integration.py +262 -0
  99. package/test_universal_router.py +275 -0
  100. package/tmlpd-pi-extension/README.md +36 -0
  101. package/tmlpd-pi-extension/dist/cache/prefixCache.d.ts +114 -0
  102. package/tmlpd-pi-extension/dist/cache/prefixCache.d.ts.map +1 -0
  103. package/tmlpd-pi-extension/dist/cache/prefixCache.js +285 -0
  104. package/tmlpd-pi-extension/dist/cache/prefixCache.js.map +1 -0
  105. package/tmlpd-pi-extension/dist/cache/responseCache.d.ts +58 -0
  106. package/tmlpd-pi-extension/dist/cache/responseCache.d.ts.map +1 -0
  107. package/tmlpd-pi-extension/dist/cache/responseCache.js +153 -0
  108. package/tmlpd-pi-extension/dist/cache/responseCache.js.map +1 -0
  109. package/tmlpd-pi-extension/dist/cli.js +59 -0
  110. package/tmlpd-pi-extension/dist/cost/costTracker.d.ts +95 -0
  111. package/tmlpd-pi-extension/dist/cost/costTracker.d.ts.map +1 -0
  112. package/tmlpd-pi-extension/dist/cost/costTracker.js +240 -0
  113. package/tmlpd-pi-extension/dist/cost/costTracker.js.map +1 -0
  114. package/tmlpd-pi-extension/dist/index.d.ts +723 -0
  115. package/tmlpd-pi-extension/dist/index.d.ts.map +1 -0
  116. package/tmlpd-pi-extension/dist/index.js +239 -0
  117. package/tmlpd-pi-extension/dist/index.js.map +1 -0
  118. package/tmlpd-pi-extension/dist/memory/episodicMemory.d.ts +82 -0
  119. package/tmlpd-pi-extension/dist/memory/episodicMemory.d.ts.map +1 -0
  120. package/tmlpd-pi-extension/dist/memory/episodicMemory.js +145 -0
  121. package/tmlpd-pi-extension/dist/memory/episodicMemory.js.map +1 -0
  122. package/tmlpd-pi-extension/dist/orchestration/haloOrchestrator.d.ts +102 -0
  123. package/tmlpd-pi-extension/dist/orchestration/haloOrchestrator.d.ts.map +1 -0
  124. package/tmlpd-pi-extension/dist/orchestration/haloOrchestrator.js +207 -0
  125. package/tmlpd-pi-extension/dist/orchestration/haloOrchestrator.js.map +1 -0
  126. package/tmlpd-pi-extension/dist/orchestration/mctsWorkflow.d.ts +85 -0
  127. package/tmlpd-pi-extension/dist/orchestration/mctsWorkflow.d.ts.map +1 -0
  128. package/tmlpd-pi-extension/dist/orchestration/mctsWorkflow.js +210 -0
  129. package/tmlpd-pi-extension/dist/orchestration/mctsWorkflow.js.map +1 -0
  130. package/tmlpd-pi-extension/dist/providers/localProvider.d.ts +102 -0
  131. package/tmlpd-pi-extension/dist/providers/localProvider.d.ts.map +1 -0
  132. package/tmlpd-pi-extension/dist/providers/localProvider.js +338 -0
  133. package/tmlpd-pi-extension/dist/providers/localProvider.js.map +1 -0
  134. package/tmlpd-pi-extension/dist/providers/registry.d.ts +55 -0
  135. package/tmlpd-pi-extension/dist/providers/registry.d.ts.map +1 -0
  136. package/tmlpd-pi-extension/dist/providers/registry.js +138 -0
  137. package/tmlpd-pi-extension/dist/providers/registry.js.map +1 -0
  138. package/tmlpd-pi-extension/dist/routing/advancedRouter.d.ts +68 -0
  139. package/tmlpd-pi-extension/dist/routing/advancedRouter.d.ts.map +1 -0
  140. package/tmlpd-pi-extension/dist/routing/advancedRouter.js +332 -0
  141. package/tmlpd-pi-extension/dist/routing/advancedRouter.js.map +1 -0
  142. package/tmlpd-pi-extension/dist/tools/tmlpdTools.d.ts +101 -0
  143. package/tmlpd-pi-extension/dist/tools/tmlpdTools.d.ts.map +1 -0
  144. package/tmlpd-pi-extension/dist/tools/tmlpdTools.js +368 -0
  145. package/tmlpd-pi-extension/dist/tools/tmlpdTools.js.map +1 -0
  146. package/tmlpd-pi-extension/dist/utils/batchProcessor.d.ts +96 -0
  147. package/tmlpd-pi-extension/dist/utils/batchProcessor.d.ts.map +1 -0
  148. package/tmlpd-pi-extension/dist/utils/batchProcessor.js +170 -0
  149. package/tmlpd-pi-extension/dist/utils/batchProcessor.js.map +1 -0
  150. package/tmlpd-pi-extension/dist/utils/compression.d.ts +61 -0
  151. package/tmlpd-pi-extension/dist/utils/compression.d.ts.map +1 -0
  152. package/tmlpd-pi-extension/dist/utils/compression.js +281 -0
  153. package/tmlpd-pi-extension/dist/utils/compression.js.map +1 -0
  154. package/tmlpd-pi-extension/dist/utils/reliability.d.ts +74 -0
  155. package/tmlpd-pi-extension/dist/utils/reliability.d.ts.map +1 -0
  156. package/tmlpd-pi-extension/dist/utils/reliability.js +177 -0
  157. package/tmlpd-pi-extension/dist/utils/reliability.js.map +1 -0
  158. package/tmlpd-pi-extension/dist/utils/speculativeDecoding.d.ts +117 -0
  159. package/tmlpd-pi-extension/dist/utils/speculativeDecoding.d.ts.map +1 -0
  160. package/tmlpd-pi-extension/dist/utils/speculativeDecoding.js +246 -0
  161. package/tmlpd-pi-extension/dist/utils/speculativeDecoding.js.map +1 -0
  162. package/tmlpd-pi-extension/dist/utils/tokenUtils.d.ts +50 -0
  163. package/tmlpd-pi-extension/dist/utils/tokenUtils.d.ts.map +1 -0
  164. package/tmlpd-pi-extension/dist/utils/tokenUtils.js +124 -0
  165. package/tmlpd-pi-extension/dist/utils/tokenUtils.js.map +1 -0
  166. package/tmlpd-pi-extension/examples/QUICKSTART.md +183 -0
  167. package/tmlpd-pi-extension/package-lock.json +75 -0
  168. package/tmlpd-pi-extension/package.json +172 -0
  169. package/tmlpd-pi-extension/python/examples.py +53 -0
  170. package/tmlpd-pi-extension/python/integrations.py +330 -0
  171. package/tmlpd-pi-extension/python/setup.py +28 -0
  172. package/tmlpd-pi-extension/python/tmlpd.py +369 -0
  173. package/tmlpd-pi-extension/qna/REDDIT_GAP_ANALYSIS.md +299 -0
  174. package/tmlpd-pi-extension/qna/TMLPD_QNA.md +751 -0
  175. package/tmlpd-pi-extension/skill/SKILL.md +238 -0
  176. package/{src → tmlpd-pi-extension/src}/index.ts +1 -1
  177. package/tmlpd-pi-extension/tsconfig.json +18 -0
  178. package/demo/research-demo.js +0 -266
  179. package/notebooks/quickstart.ipynb +0 -157
  180. package/rust/tmlpd.h +0 -268
  181. package/src/cache/prefixCache.ts +0 -365
  182. package/src/routing/advancedRouter.ts +0 -406
  183. package/src/utils/speculativeDecoding.ts +0 -344
  184. /package/{src → tmlpd-pi-extension/src}/cache/responseCache.ts +0 -0
  185. /package/{src → tmlpd-pi-extension/src}/cost/costTracker.ts +0 -0
  186. /package/{src → tmlpd-pi-extension/src}/memory/episodicMemory.ts +0 -0
  187. /package/{src → tmlpd-pi-extension/src}/orchestration/haloOrchestrator.ts +0 -0
  188. /package/{src → tmlpd-pi-extension/src}/orchestration/mctsWorkflow.ts +0 -0
  189. /package/{src → tmlpd-pi-extension/src}/providers/localProvider.ts +0 -0
  190. /package/{src → tmlpd-pi-extension/src}/providers/registry.ts +0 -0
  191. /package/{src → tmlpd-pi-extension/src}/tools/tmlpdTools.ts +0 -0
  192. /package/{src → tmlpd-pi-extension/src}/utils/batchProcessor.ts +0 -0
  193. /package/{src → tmlpd-pi-extension/src}/utils/compression.ts +0 -0
  194. /package/{src → tmlpd-pi-extension/src}/utils/reliability.ts +0 -0
  195. /package/{src → tmlpd-pi-extension/src}/utils/tokenUtils.ts +0 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 TMLPD Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,114 +1,194 @@
1
- # A3M Router - Adaptive Memory Multi-Model Router
1
+ # A3M Router
2
2
 
3
- > **Smart Routing for AI Agents & LLM Developers**
4
- > npm: https://npmjs.com/package/adaptive-memory-multi-model-router
5
- > short: `npx a3m-router`
3
+ <div align="center">
6
4
 
7
- ---
5
+ **A**daptive **M**emory **M**ulti-**M**odel Router — Smarter routing that learns from every query
8
6
 
9
- ## What is A3M Router?
7
+ [![npm version](https://img.shields.io/npm/v/adaptive-memory-multi-model-router?color=success&style=flat-square)](https://www.npmjs.com/package/adaptive-memory-multi-model-router)
8
+ [![npm downloads](https://img.shields.io/npm/dm/adaptive-memory-multi-model-router?color=blue&style=flat-square)](https://npmjs.com/package/adaptive-memory-multi-model-router)
9
+ [![PyPI version](https://img.shields.io/pypi/v/adaptive-memory-multi-model-router?color=orange&style=flat-square)](https://pypi.org/project/adaptive-memory-multi-model-router/)
10
+ [![Stars](https://img.shields.io/github/stars/Das-rebel/adaptive-memory-multi-model-router?style=social)](https://github.com/Das-rebel/adaptive-memory-multi-model-router)
11
+ [![License](https://img.shields.io/badge/License-MIT-green?style=flat-square)](LICENSE)
12
+ [![Research](https://img.shields.io/badge/Research-Backed-blue?style=flat-square)](https://arxiv.org/abs/2404.06035)
10
13
 
11
- **A3M** = **A**daptive **M**emory **M**ulti-**M**odel Router
14
+ </div>
12
15
 
13
- A research-backed, AI-native router that learns from past requests to optimize future routing decisions. Built on proven research (RouteLLM, RadixAttention, Medusa) for production-ready LLM orchestration.
16
+ ---
14
17
 
15
- ### Why A3M?
18
+ ## The Problem
16
19
 
17
- | Feature | Benefit |
18
- |---------|---------|
19
- | **Adaptive Memory** | Learns from past queries, 20x more adaptable |
20
- | **Multi-Model Routing** | Routes to optimal model (OpenAI, Anthropic, Ollama, etc.) |
21
- | **Cost Optimization** | RouteLLM-style learned routing → 40% cost reduction |
22
- | **5-10x Speedup** | RadixAttention prefix caching for shared prompts |
23
- | **2-3x Faster Gen** | Medusa/EAGLE speculative decoding |
24
- | **Python Ready** | LangChain, LlamaIndex, AutoGen, CrewAI bindings |
20
+ You're paying **too much** for LLM inference. Running GPT-4 on simple queries. Using the wrong model for your task. Burning budget on retries and failures.
25
21
 
26
- ---
22
+ ## The Solution
27
23
 
28
- ## Quick Start
24
+ **A3M Router** learns your usage patterns and routes each request to the optimal model—automatically. Save 40% on costs. Get 5-10x speedups. Without changing your code.
29
25
 
30
26
  ```bash
31
27
  npm install adaptive-memory-multi-model-router
32
- npx a3m-router --help
33
28
  ```
34
29
 
35
- ```typescript
30
+ ---
31
+
32
+ ## Features
33
+
34
+ | Capability | How It Works | Result |
35
+ |------------|-------------|--------|
36
+ | **Learned Routing** | RouteLLM cost-quality tradeoff | 40% cost reduction |
37
+ | **Adaptive Memory** | Episodic memory per request | 20x more accurate routing |
38
+ | **Prefix Caching** | RadixAttention shared prompts | 5-10x speedup |
39
+ | **Speculative Decoding** | Medusa tree verification | 2-3x faster generation |
40
+ | **Token Compression** | ISON context reduction | 20-40% fewer tokens |
41
+ | **Circuit Breaker** | Exponential backoff | 99.9% uptime |
42
+
43
+ ---
44
+
45
+ ## Quick Start
46
+
47
+ ### Node.js
48
+
49
+ ```javascript
36
50
  import { createA3MRouter } from 'adaptive-memory-multi-model-router';
37
51
 
38
- // Create router with memory
39
- const router = createA3MRouter({
40
- memory: true,
41
- costBudget: 0.05
52
+ const router = createA3MRouter({
53
+ memory: true, // Learn from past queries
54
+ costBudget: 0.05 // $0.05 per request max
42
55
  });
43
56
 
44
- // Smart routing
45
57
  const result = await router.route({
46
- prompt: 'Analyze this code',
47
- context: { type: 'coding' }
58
+ prompt: 'Debug this Python code',
59
+ context: { type: 'coding', language: 'python' }
48
60
  });
61
+ console.log(result.output);
49
62
  ```
50
63
 
51
- ---
52
-
53
- ## Features
64
+ ### Python
54
65
 
55
- ### Research-Backed
56
- | Research | Citation | Impact |
57
- |----------|----------|--------|
58
- | RouteLLM | arXiv:2404.06035 | 40% cost reduction |
59
- | RadixAttention | arXiv:2312.07104 | 5-10x speedup |
60
- | Medusa | arXiv:2401.10774 | 2-3x faster generation |
61
- | LLMLingua | arXiv:2403.12968 | 20-40% token reduction |
62
-
63
- ### Core Capabilities
64
- - ✅ **Learned Routing** - Memory-based, adapts to your usage patterns
65
- - ✅ **Circuit Breaker** - Automatic failover with exponential backoff
66
- - ✅ **Batch Processing** - Parallel execution with priority queuing
67
- - ✅ **Token Compression** - ISON format for context reduction
68
- - ✅ **Local LLM Support** - Ollama, vLLM, LM Studio
69
- - ✅ **Python Bindings** - LangChain, LlamaIndex, AutoGen, CrewAI
66
+ ```python
67
+ from adaptive_memory_multi_model_router import A3MRouter
70
68
 
71
- ---
69
+ router = A3MRouter()
70
+ result = router.route(
71
+ prompt="Analyze this dataset",
72
+ budget=0.02
73
+ )
74
+ print(result.output)
75
+ ```
72
76
 
73
- ## CLI Usage
77
+ ### CLI
74
78
 
75
79
  ```bash
76
- # Route a single prompt
77
80
  npx a3m-router route "Explain quantum computing"
78
-
79
- # Parallel execution
80
81
  npx a3m-router parallel "task1" "task2" "task3"
81
-
82
- # Cost tracking
83
82
  npx a3m-router cost
84
-
85
- # Token estimation
86
- npx a3m-router count "your text here"
87
83
  ```
88
84
 
89
85
  ---
90
86
 
91
- ## For LLM/ML Developers
87
+ ## For Python Developers
92
88
 
93
- A3M Router is designed for developers who want:
94
- - **Production-ready** routing without building from scratch
95
- - **Cost observability** - track where your budget goes
96
- - **Python integration** - seamless with existing ML pipelines
97
- - **Research-backed** - proven techniques, not fads
89
+ **LangChain, LlamaIndex, AutoGen, CrewAI** all supported.
98
90
 
99
91
  ```python
92
+ from langchain import LLMChain
100
93
  from adaptive_memory_multi_model_router import A3MRouter
101
94
 
95
+ # Works with your existing LangChain code
102
96
  router = A3MRouter(provider='openai')
103
- result = router.route(prompt="Analyze sentiment", budget=0.02)
97
+ chain = LLMChain(llm=router, prompt=my_prompt)
98
+ result = chain.run("your query")
104
99
  ```
105
100
 
101
+ ### Supported Providers
102
+
103
+ | Provider | Models | Notes |
104
+ |----------|--------|-------|
105
+ | OpenAI | gpt-4, gpt-3.5 | ✅ Production ready |
106
+ | Anthropic | claude-3.5, claude-3 | ✅ Production ready |
107
+ | Ollama | llama3, mistral | ✅ Local, zero cost |
108
+ | vLLM | Any HuggingFace | ✅ Self-hosted |
109
+ | LM Studio | Any GGUF | ✅ Local privacy |
110
+
111
+ ---
112
+
113
+ ## Research-Backed
114
+
115
+ A3M Router implements techniques from peer-reviewed research—not experiments:
116
+
117
+ | Paper | Technique | Impact |
118
+ |-------|-----------|--------|
119
+ | [RouteLLM](https://arxiv.org/abs/2404.06035) | Learned cost-quality routing | 40% cost reduction |
120
+ | [RadixAttention](https://arxiv.org/abs/2312.07104) | Prefix caching | 5-10x speedup |
121
+ | [Medusa](https://arxiv.org/abs/2401.10774) | Speculative decoding | 2-3x faster |
122
+ | [LLMLingua](https://arxiv.org/abs/2403.12968) | Token compression | 20-40% fewer tokens |
123
+
124
+ ---
125
+
126
+ ## CLI Reference
127
+
128
+ | Command | Description |
129
+ |---------|-------------|
130
+ | `a3m-router route "prompt"` | Smart routing to optimal model |
131
+ | `a3m-router parallel "t1" "t2"` | Parallel multi-model execution |
132
+ | `a3m-router compare "prompt"` | Compare responses across models |
133
+ | `a3m-router cost` | Show cost tracking summary |
134
+ | `a3m-router count "text"` | Token estimation |
135
+ | `a3m-router compress "text"` | ISON token compression |
136
+ | `a3m-router local "prompt"` | Local Ollama execution |
137
+
138
+ ---
139
+
140
+ ## Architecture
141
+
142
+ ```
143
+ ┌─────────────────────────────────────────────────────────────┐
144
+ │ Your Request │
145
+ │ "Analyze this code" │
146
+ └─────────────────────────┬───────────────────────────────────┘
147
+
148
+
149
+ ┌─────────────────────────────────────────────────────────────┐
150
+ │ A3M Router │
151
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
152
+ │ │ Task │ │ Memory │ │ RouteLLM │ │
153
+ │ │ Classifier │→│ Store │→│ Cost-Quality │ │
154
+ │ └─────────────┘ └─────────────┘ └─────────────────┘ │
155
+ │ │ │
156
+ │ ▼ │
157
+ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ │
158
+ │ │ Circuit │ │ Prefix │ │ Speculative │ │
159
+ │ │ Breaker │→│ Cache │→│ Decoder │ │
160
+ │ └─────────────┘ └─────────────┘ └─────────────────┘ │
161
+ └─────────────────────────┬───────────────────────────────────┘
162
+
163
+
164
+ ┌─────────────────────────────────────────────────────────────┐
165
+ │ Optimal Model Response │
166
+ │ (cheapest + fastest + highest quality) │
167
+ └─────────────────────────────────────────────────────────────┘
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Contributing
173
+
174
+ Issues and PRs welcome!
175
+
176
+ 1. Fork the repo
177
+ 2. Create your branch (`git checkout -b feature/amazing`)
178
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
179
+ 4. Push to the branch (`git push origin feature/amazing`)
180
+ 5. Open a Pull Request
181
+
106
182
  ---
107
183
 
108
- ## GitHub
184
+ ## License
109
185
 
110
- https://github.com/Das-rebel/tmlpd-skill
186
+ MIT © Das-rebel
111
187
 
112
188
  ---
113
189
 
114
- **A3M Router** - Smart routing for the AI era.
190
+ <div align="center">
191
+
192
+ **A3M Router** — Built for developers who care about cost, speed, and quality.
193
+
194
+ </div>
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @example
8
8
  * ```typescript
9
- * import { createTMLPD, HALOOrchestrator, EpisodicMemoryStore } from "adaptive-memory-multi-model-router";
9
+ * import { createTMLPD, HALOOrchestrator, EpisodicMemoryStore } from "tmlpd-pi";
10
10
  *
11
11
  * // Lightweight usage (core features)
12
12
  * const tmlpd = createTMLPD({ cache: { ttl_seconds: 3600 } });
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @example
9
9
  * ```typescript
10
- * import { createTMLPD, HALOOrchestrator, EpisodicMemoryStore } from "adaptive-memory-multi-model-router";
10
+ * import { createTMLPD, HALOOrchestrator, EpisodicMemoryStore } from "tmlpd-pi";
11
11
  *
12
12
  * // Lightweight usage (core features)
13
13
  * const tmlpd = createTMLPD({ cache: { ttl_seconds: 3600 } });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Airtable Integration for A3M Router
3
+ * Airtable API
4
+ */
5
+ class AirtableIntegration {
6
+ constructor(apiKey, baseId) {
7
+ this.apiKey = apiKey;
8
+ this.baseId = baseId;
9
+ this.baseUrl = 'https://api.airtable.com/v0';
10
+ }
11
+
12
+ async listRecords(tableName, filterByFormula) {
13
+ return { action: 'list-records', tableName };
14
+ }
15
+
16
+ async createRecord(tableName, fields) {
17
+ return { action: 'create-record', tableName, fields };
18
+ }
19
+ }
20
+ module.exports = { AirtableIntegration };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Discord Integration for A3M Router
3
+ * Discord Webhooks and Bot API
4
+ */
5
+ class DiscordIntegration {
6
+ constructor(webhookUrl) {
7
+ this.webhookUrl = webhookUrl;
8
+ }
9
+
10
+ async sendMessage(content) {
11
+ return { action: 'send-message', content: content.slice(0, 50) + '...' };
12
+ }
13
+
14
+ async createChannel(name) {
15
+ return { action: 'create-channel', name };
16
+ }
17
+ }
18
+ module.exports = { DiscordIntegration };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * GitHub Integration for A3M Router
3
+ * Connect to GitHub API for repository management, PRs, issues
4
+ */
5
+ class GitHubIntegration {
6
+ constructor(apiKey) {
7
+ this.apiKey = apiKey;
8
+ this.baseUrl = 'https://api.github.com';
9
+ }
10
+
11
+ async getRepo(owner, repo) {
12
+ return { owner, repo, apiKey: this.apiKey ? '***' : 'not-set' };
13
+ }
14
+
15
+ async createIssue(owner, repo, title, body) {
16
+ return { action: 'create-issue', owner, repo, title };
17
+ }
18
+
19
+ async createPR(owner, repo, title, head, base = 'main') {
20
+ return { action: 'create-pr', owner, repo, title, head, base };
21
+ }
22
+ }
23
+ module.exports = { GitHubIntegration };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Gmail Integration for A3M Router
3
+ * Google Gmail API
4
+ */
5
+ class GmailIntegration {
6
+ constructor(credentials) {
7
+ this.credentials = credentials;
8
+ this.baseUrl = 'https://gmail.googleapis.com/gmail/v1';
9
+ }
10
+
11
+ async sendMessage(to, subject, body) {
12
+ return { action: 'send-email', to, subject };
13
+ }
14
+
15
+ async listMessages(query = 'in:inbox') {
16
+ return { action: 'list-messages', query };
17
+ }
18
+ }
19
+ module.exports = { GmailIntegration };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Google Calendar Integration for A3M Router
3
+ */
4
+ class GoogleCalendarIntegration {
5
+ constructor(credentials) {
6
+ this.credentials = credentials;
7
+ this.baseUrl = 'https://www.googleapis.com/calendar/v3';
8
+ }
9
+
10
+ async createEvent(summary, start, end, attendees) {
11
+ return { action: 'create-event', summary, start, end };
12
+ }
13
+
14
+ async listEvents(timeMin, timeMax) {
15
+ return { action: 'list-events', timeMin, timeMax };
16
+ }
17
+ }
18
+ module.exports = { GoogleCalendarIntegration };
@@ -0,0 +1,61 @@
1
+ /**
2
+ * A3M Router - Agent & Tool Integrations
3
+ *
4
+ * Connect to popular services for AI agent workflows:
5
+ * - GitHub (PRs, issues, repos)
6
+ * - Slack (messaging)
7
+ * - Telegram (bots)
8
+ * - Notion (docs, databases)
9
+ * - Linear (project management)
10
+ * - Jira (Atlassian)
11
+ * - Gmail (email)
12
+ * - Discord (messaging)
13
+ * - Airtable (databases)
14
+ * - Google Calendar (scheduling)
15
+ */
16
+
17
+ const GitHubIntegration = require('./github.js').GitHubIntegration;
18
+ const SlackIntegration = require('./slack.js').SlackIntegration;
19
+ const TelegramIntegration = require('./telegram.js').TelegramIntegration;
20
+ const NotionIntegration = require('./notion.js').NotionIntegration;
21
+ const LinearIntegration = require('./linear.js').LinearIntegration;
22
+ const JiraIntegration = require('./jira.js').JiraIntegration;
23
+ const GmailIntegration = require('./gmail.js').GmailIntegration;
24
+ const DiscordIntegration = require('./discord.js').DiscordIntegration;
25
+ const AirtableIntegration = require('./airtable.js').AirtableIntegration;
26
+ const GoogleCalendarIntegration = require('./google-calendar.js').GoogleCalendarIntegration;
27
+
28
+ /**
29
+ * Factory to create integrations
30
+ */
31
+ function createIntegration(type, config) {
32
+ switch (type) {
33
+ case 'github': return new GitHubIntegration(config.apiKey);
34
+ case 'slack': return new SlackIntegration(config.webhookUrl);
35
+ case 'telegram': return new TelegramIntegration(config.botToken);
36
+ case 'notion': return new NotionIntegration(config.apiKey);
37
+ case 'linear': return new LinearIntegration(config.apiKey);
38
+ case 'jira': return new JiraIntegration(config.domain, config.email, config.apiToken);
39
+ case 'gmail': return new GmailIntegration(config.credentials);
40
+ case 'discord': return new DiscordIntegration(config.webhookUrl);
41
+ case 'airtable': return new AirtableIntegration(config.apiKey, config.baseId);
42
+ case 'google-calendar': return new GoogleCalendarIntegration(config.credentials);
43
+ default: throw new Error(`Unknown integration type: ${type}`);
44
+ }
45
+ }
46
+
47
+ module.exports = {
48
+ // Integrations
49
+ GitHubIntegration,
50
+ SlackIntegration,
51
+ TelegramIntegration,
52
+ NotionIntegration,
53
+ LinearIntegration,
54
+ JiraIntegration,
55
+ GmailIntegration,
56
+ DiscordIntegration,
57
+ AirtableIntegration,
58
+ GoogleCalendarIntegration,
59
+ // Factory
60
+ createIntegration
61
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Jira Integration for A3M Router
3
+ * Atlassian Jira API
4
+ */
5
+ class JiraIntegration {
6
+ constructor(domain, email, apiToken) {
7
+ this.domain = domain;
8
+ this.email = email;
9
+ this.apiToken = apiToken;
10
+ this.baseUrl = `https://${domain}.atlassian.net/rest/api`;
11
+ }
12
+
13
+ async createIssue(projectKey, summary, description) {
14
+ return { action: 'create-issue', projectKey, summary };
15
+ }
16
+
17
+ async searchJQL(jql) {
18
+ return { action: 'search', jql };
19
+ }
20
+ }
21
+ module.exports = { JiraIntegration };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Linear Integration for A3M Router
3
+ * Project management with Linear
4
+ */
5
+ class LinearIntegration {
6
+ constructor(apiKey) {
7
+ this.apiKey = apiKey;
8
+ this.baseUrl = 'https://api.linear.app/graphql';
9
+ }
10
+
11
+ async createIssue(title, description, teamId) {
12
+ return { action: 'create-issue', title, teamId };
13
+ }
14
+
15
+ async listTeams() {
16
+ return { action: 'list-teams' };
17
+ }
18
+ }
19
+ module.exports = { LinearIntegration };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Notion Integration for A3M Router
3
+ * Connect to Notion API
4
+ */
5
+ class NotionIntegration {
6
+ constructor(apiKey) {
7
+ this.apiKey = apiKey;
8
+ this.baseUrl = 'https://api.notion.com/v1';
9
+ }
10
+
11
+ async queryDatabase(databaseId) {
12
+ return { action: 'query-database', databaseId };
13
+ }
14
+
15
+ async createPage(parentId, title, content) {
16
+ return { action: 'create-page', parentId, title };
17
+ }
18
+ }
19
+ module.exports = { NotionIntegration };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Slack Integration for A3M Router
3
+ * Send messages to Slack channels
4
+ */
5
+ class SlackIntegration {
6
+ constructor(webhookUrl) {
7
+ this.webhookUrl = webhookUrl;
8
+ }
9
+
10
+ async sendMessage(channel, text) {
11
+ return { action: 'send-message', channel, text: text.slice(0, 50) + '...' };
12
+ }
13
+
14
+ async createChannel(name) {
15
+ return { action: 'create-channel', name };
16
+ }
17
+ }
18
+ module.exports = { SlackIntegration };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Telegram Integration for A3M Router
3
+ * Bot API for Telegram
4
+ */
5
+ class TelegramIntegration {
6
+ constructor(botToken) {
7
+ this.botToken = botToken;
8
+ this.baseUrl = `https://api.telegram.org/bot${botToken}`;
9
+ }
10
+
11
+ async sendMessage(chatId, text) {
12
+ return { action: 'send-message', chatId, text: text.slice(0, 50) + '...' };
13
+ }
14
+
15
+ async getUpdates() {
16
+ return { action: 'get-updates' };
17
+ }
18
+ }
19
+ module.exports = { TelegramIntegration };
@@ -7,8 +7,8 @@
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.ProviderRegistry = void 0;
9
9
  const DEFAULT_PROVIDER_CONFIG = {
10
- providers: ["openai", "openrouter", "groq", "cerebras", "mistral", "xai", "zai", "anthropic", "google"],
11
- modelPriority: ["openai/gpt-4o", "groq/llama-3.3-70b-versatile", "cerebras/llama-3.3-70b"],
10
+ providers: ["openai", "openrouter", "groq", "cerebras", "mistral", "xai", "zai", "anthropic", "google", "deepseek", "fireworks", "perplexity", "cohere", "bedrock"],
11
+ modelPriority: ["openai/gpt-4o", "groq/llama-3.3-70b-versatile", "cerebras/llama-3.3-70b", "deepseek/deepseek-chat", "fireworks/mixtral-8x7b-instruct", "perplexity/sonar", "cohere/command-r-plus"],
12
12
  useOpenclawFallback: false,
13
13
  maxTokens: 4096,
14
14
  };
@@ -33,7 +33,11 @@ class ProviderRegistry {
33
33
  zai: { key: "ZAI_API_KEY", url: "ZAI_OPENAI_BASE_URL", mode: "anthropic" },
34
34
  anthropic: { key: "ANTHROPIC_API_KEY", url: "ANTHROPIC_BASE_URL", mode: "anthropic" },
35
35
  google: { key: "GOOGLE_API_KEY", url: "GOOGLE_GEMINI_BASE_URL", mode: "gemini" },
36
- };
36
+ deepseek: { key: "DEEPSEEK_API_KEY", url: "DEEPSEEK_BASE_URL", mode: "openai" },
37
+ fireworks: { key: "FIREWORKS_API_KEY", url: "FIREWORKS_BASE_URL", mode: "openai" },
38
+ perplexity: { key: "PERPLEXITY_API_KEY", url: "PERPLEXITY_BASE_URL", mode: "openai" },
39
+ cohere: { key: "COHERE_API_KEY", url: "COHERE_BASE_URL", mode: "openai" },
40
+ bedrock: { key: "AWS_ACCESS_KEY_ID", url: "BEDROCK_BASE_URL", mode: "openai" }, };
37
41
  for (const [name, env] of Object.entries(envVars)) {
38
42
  const apiKey = process.env[env.key] || "";
39
43
  const baseUrl = process.env[env.url] || "";