feat: add meta-tools for intelligent tool discovery and orchestration
Summary
This PR replaces the fuzzy search implementation in meta-tools with Orama, a powerful semantic search engine that uses BM25 scoring for better relevance ranking.
Key Improvements:
- Semantic Search: Orama provides true semantic search capabilities with BM25 algorithm
- Better Relevance: Field boosting (name: 2x, tags: 1.5x, description: 1x) ensures the most relevant tools surface first
- Stemming Support: Built-in stemming tokenizer improves search quality across word variations
- New API Method: Added `metaSearchTools()` to StackOneToolSet for direct semantic search
Changes
Dependencies
- ➕ Added `@orama/orama` (3.1.11) - Modern semantic search engine
- ➖ Removed `@nozbe/microfuzz` - Replaced with more powerful Orama
Implementation Details
1. Enhanced GetRelevantTools
- Migrated from fuzzy matching to semantic search using Orama
- Implemented BM25 scoring with configurable parameters
- Added tool categorization and tagging for better search accuracy
- Maintained backward compatibility with existing score normalization (0-1 range)
2. New metaSearchTools Method
```typescript
// Search for tools using natural language
const tools = await toolset.metaSearchTools("manage employee time off", {
limit: 10,
minScore: 0.3,
accountId: "optional-account-id"
});
```
3. Improved Indexing
Tools are now indexed with:
- name: The tool identifier
- description: Full description for context
- category: Extracted from tool name (e.g., 'hris' from 'hris_create_employee')
- tags: Action types and name parts for granular matching
Technical Notes
- Score Normalization: While Orama returns 0-1 scores, we maintain our normalization layer for consistency and human-readable match reasons
- Type Safety: Used `unknown` type with proper assertions to satisfy strict linting rules
- Performance: Orama builds an in-memory index on first use, subsequent searches are very fast
Testing
All existing tests pass, including:
- ✅ Meta-tools tests (30/30 passing)
- ✅ StackOne toolset tests (18/18 passing)
- ✅ Linting and type checking
Migration Guide
No breaking changes! The existing API remains unchanged. To use the new semantic search:
```typescript
// Option 1: Use GetRelevantTools (automatically uses Orama now)
const relevantTools = tools.getTool('get_relevant_tools');
const results = await relevantTools.execute({ query: "employee management" });
// Option 2: Use the new metaSearchTools method
const tools = await toolset.metaSearchTools("employee management");
```
Future Improvements
- Add relevance parameter configuration for BM25 tuning
- Consider adding vector search capabilities (Orama supports hybrid search)
- Implement search result highlighting