tokenfirewall
tokenfirewall copied to clipboard
Scalable LLM cost enforcement middleware for Node.js with budget protection and multi-provider support
## 📌 Description Create TypeScript definitions and interfaces for the Smart Model Selection task classification system. ## 🚀 Tasks - [ ] Create src/router/taskTypes.ts - [ ] Define TaskType enum...
## 📌 Description Implement registry system for storing and managing task configurations. ## 🚀 Tasks - [ ] Create src/router/taskRegistry.ts - [ ] Implement TaskRegistry class - [ ] Add...
Comprehensive testing before release. ## Tasks - [ ] Run all unit tests - [ ] Run all integration tests - [ ] Manual testing with real APIs - [...
Implement keyword-based task detection engine. ## Tasks - [ ] Create keywordDetector.ts - [ ] Implement detectByKeywords() - [ ] Add confidence scoring - [ ] Add unit tests ##...
Create language detection for non-English prompts. ## Tasks - [ ] Create languageDetector.ts - [ ] Implement detectLanguage() - [ ] Detect Chinese characters - [ ] Add unit tests...
Implement validation for smart router configuration. ## Tasks - [ ] Create smartRouterValidator.ts - [ ] Implement validateSmartRouterOptions() - [ ] Validate confidence threshold - [ ] Add helpful error...
Create context-aware task detection using conversation history. ## Tasks - [ ] Create contextAnalyzer.ts - [ ] Implement analyzeContext() - [ ] Extract context from history - [ ] Add...
Create regex-based pattern detection system. ## Tasks - [ ] Create patternDetector.ts - [ ] Implement detectByPatterns() - [ ] Add timeout protection - [ ] Add unit tests ##...
Optimize smart routing performance. ## Tasks - [ ] Profile classification performance - [ ] Optimize regex patterns - [ ] Add caching for repeated prompts - [ ] Ensure...
[Security][Critical] Unknown model names tracked at zero cost, bypassing budget enforcement entirely
## Summary `src/core/costEngine.ts` catches errors from `getPricing()` and returns `{ totalCost: 0 }` for any unrecognized model. The budget manager receives zero cost and never increments `totalSpent`. ## Affected File...