A powerful SDK for building AI agents with seamless voice-text context switching capabilities. Enable your agents to maintain conversation context when switching between voice and text modalities.
- π Seamless Voice-Text Context Switching - The main innovation
- π€ Multi-LLM Support - OpenAI, Anthropic, Ollama, Google, Azure, Custom APIs
- π§ Intelligent Context Management - Pluggable context providers with auto-discovery
- πΎ Persistent Session Management - Redis, MongoDB, or in-memory storage
- ποΈ Configurable Speech Integration - STT/TTS with multiple provider support
- π Auto-Documentation Discovery - README, docs, changelogs automatically indexed
- β‘ Event-Driven Architecture - Real-time monitoring and analytics
- π§ TypeScript First - Full type safety and IntelliSense support
- ποΈ Modular Architecture - Use only what you need
- π Secure by Default - Environment-based configuration
- π Performance Monitoring - Built-in metrics and analytics
- π‘οΈ Error Handling - Graceful fallbacks and retry mechanisms
- π§ͺ Comprehensive Testing - Unit and integration tests included
- π Rich Documentation - Examples, guides, and API reference
The Problem: Traditional AI agents lose context when switching between voice and text interactions.
Our Solution: Intelligent context bridging that preserves conversation state and adapts responses for different modalities.
// Start conversation via text
await agent.processMessage('I need help with order #12345', 'text', 'session-123');
// π THE MAGIC: Switch to voice mid-conversation
await agent.switchModality('voice', 'session-123');
// Agent responds: "I see you're asking about order 12345. Let me help you with that..."
// Continue seamlessly with voice
const audioFile = new File([audioBuffer], 'voice.wav');
await agent.processMessage(audioFile, 'voice', 'session-123');
npm install contextual-agent-sdk
import { ContextualAgent } from 'contextual-agent-sdk';
const agent = new ContextualAgent({
name: 'Support Agent',
systemPrompt: 'You are a helpful customer support agent.',
llm: {
providers: {
'openai': {
type: 'openai',
apiKey: process.env.OPENAI_API_KEY
}
},
defaultProvider: 'openai'
}
});
// Text interaction
const response = await agent.processMessage(
'Hello, I need help',
'text',
'session-123'
);
console.log(response.data.message.content);
import {
ContextualAgent,
KnowledgeBaseProvider,
DatabaseContextProvider
} from 'contextual-agent-sdk';
// 1. Setup context providers
const knowledgeBase = new KnowledgeBaseProvider({
id: 'docs',
name: 'Documentation',
priority: 90,
options: {
autoDiscoverDocs: {
enabled: true,
rootPath: process.cwd(),
patterns: ['README.md', 'docs/**/*.md']
}
}
});
const database = new DatabaseContextProvider({
id: 'user_data',
name: 'User Database',
priority: 80,
connection: {
type: 'custom',
customQuery: async (query) => {
// Your database logic
return { preferences: {}, history: [] };
}
}
});
// 2. Setup speech providers
const speechToText = {
async transcribe(audioInput, options) {
// OpenAI Whisper implementation
const formData = new FormData();
formData.append('file', audioInput);
formData.append('model', options?.model || 'whisper-1');
const response = await fetch('https://api.openai.com/v1/audio/transcriptions', {
method: 'POST',
headers: { 'Authorization': `Bearer ${process.env.OPENAI_API_KEY}` },
body: formData
});
return await response.json();
}
};
// 3. Create agent with full configuration
const agent = new ContextualAgent({
name: 'Advanced Support Agent',
systemPrompt: 'You are an intelligent support agent with access to documentation and user data.',
// Multi-LLM setup with fallback
llm: {
providers: {
'openai': { type: 'openai', apiKey: process.env.OPENAI_API_KEY },
'anthropic': { type: 'anthropic', apiKey: process.env.ANTHROPIC_API_KEY },
'ollama': { type: 'ollama', baseURL: 'http://localhost:11434' }
},
defaultProvider: 'openai',
fallbackProvider: 'ollama'
},
// Context management
contextManager: {
providers: [knowledgeBase, database]
},
// Speech capabilities
modalityRouter: {
speechToText,
defaultSTTOptions: {
language: 'en-US',
model: 'whisper-1'
}
},
// Persistent storage
storage: {
type: 'redis',
config: { url: process.env.REDIS_URL }
}
});
// 4. Use the agent
const textResponse = await agent.processMessage(
'What are the installation steps?',
'text',
'session-123'
);
// 5. Switch to voice seamlessly
const voiceResponse = await agent.switchModality('voice', 'session-123');
// 6. Process voice input
const audioFile = new File([audioBuffer], 'question.wav');
const voiceReply = await agent.processMessage(audioFile, 'voice', 'session-123');
const docsProvider = new KnowledgeBaseProvider({
id: 'project_docs',
options: {
autoDiscoverDocs: {
enabled: true,
patterns: [
'README.md', 'CHANGELOG.md', 'LICENSE',
'docs/**/*.md', 'api/**/*.json'
]
}
}
});
// Automatically indexes:
// β
README files
// β
Documentation folders
// β
API specifications
// β
Changelog and contributing guides
// β
License information
class CRMProvider implements ContextProvider {
async getContext(params) {
const customer = await crm.getCustomer(params.userId);
return {
content: {
tier: customer.tier,
tickets: customer.openTickets,
satisfaction: customer.satisfactionScore
},
metadata: {
source: 'crm',
timestamp: new Date()
}
};
}
}
// OpenAI Whisper + TTS
const openaiSpeech = {
speechToText: whisperProvider,
textToSpeech: openaiTTSProvider
};
// Google Cloud Speech
const googleSpeech = {
speechToText: googleSTTProvider,
textToSpeech: googleTTSProvider
};
// AWS Transcribe + Polly
const awsSpeech = {
speechToText: transcribeProvider,
textToSpeech: pollyProvider
};
// Mix and match
const agent = new ContextualAgent({
modalityRouter: {
speechToText: googleSTTProvider, // Google for STT
textToSpeech: openaiTTSProvider, // OpenAI for TTS
defaultSTTOptions: {
language: 'en-US',
model: 'latest_long'
}
}
});
const agent = new ContextualAgent({
llm: {
providers: {
'primary': { type: 'openai', apiKey: '...' },
'backup': { type: 'anthropic', apiKey: '...' },
'local': { type: 'ollama', baseURL: 'http://localhost:11434' },
'custom': { type: 'custom', baseURL: 'https://my-llm-api.com' }
},
defaultProvider: 'primary',
fallbackProvider: 'backup'
}
});
// Runtime provider management
agent.addLLMProvider('new-provider', { type: 'openai', apiKey: '...' });
agent.setDefaultLLMProvider('new-provider');
// Test providers
const status = await agent.testLLMProvider('primary');
console.log(status.success); // true/false
// Redis (Production)
const agent = new ContextualAgent({
storage: {
type: 'redis',
config: {
url: process.env.REDIS_URL,
ssl: true,
maxConnections: 10
}
}
});
// MongoDB (Document Storage)
const agent = new ContextualAgent({
storage: {
type: 'mongodb',
config: {
url: process.env.MONGODB_URL,
ssl: true
}
}
});
// Memory (Development)
const agent = new ContextualAgent({
storage: { type: 'memory' }
});
// Session events
agent.on('session_started', (event) => {
console.log(`New session: ${event.sessionId}`);
});
// Context switching events
agent.on('modality_switched', (event) => {
console.log(`Switched from ${event.data.from} to ${event.data.to}`);
});
// Context bridging events
agent.on('context_bridged', (event) => {
console.log(`Context bridged: ${event.data.bridgeType}`);
});
// Performance monitoring
agent.on('performance_metric', (event) => {
console.log(`Response time: ${event.data.responseTime}ms`);
});
// Error handling
agent.on('error_occurred', (event) => {
console.error(`Error in session ${event.sessionId}:`, event.data.error);
});
Create a .env
file:
# LLM Providers
OPENAI_API_KEY=sk-your-openai-key
ANTHROPIC_API_KEY=sk-ant-your-anthropic-key
GOOGLE_AI_API_KEY=your-google-key
OLLAMA_HOST=http://localhost:11434
# Speech Services
AZURE_SPEECH_KEY=your-azure-key
AZURE_SPEECH_REGION=your-region
GOOGLE_APPLICATION_CREDENTIALS=path/to/service-account.json
ASSEMBLYAI_API_KEY=your-assemblyai-key
DEEPGRAM_API_KEY=your-deepgram-key
# Storage
REDIS_URL=redis://localhost:6379
MONGODB_URL=mongodb://localhost:27017/agents
# Defaults
DEFAULT_LLM_PROVIDER=openai
DEFAULT_STT_LANGUAGE=en-US
DEFAULT_TTS_VOICE=alloy
interface AgentConfig {
name: string;
systemPrompt: string;
llm?: LLMConfig;
contextManager?: ContextManagerConfig;
modalityRouter?: ModalityRouterConfig;
storage?: StorageConfig;
}
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β ContextualAgent ββββββ SessionManager ββββββ StorageProviderβ
β β β β β (Redis/Mongo) β
β Main SDK Class β β Session & State β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β ModalityRouter β β ContextManager β β LLMManager β
β β β β β β
β Voice/Text β β Context Bridge β β Multi-Provider β
β Processing β β & Providers β β Management β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
# Run all tests
npm test
# Run specific test suites
npm run test:core
npm run test:integration
# Run with coverage
npm run test:coverage
# Validate setup
npm run validate-setup
# Basic multi-LLM demo
npm run demo:multi-llm
# Investor presentation demo
npm run demo:investor
# Interactive HTTP server
npm run demo
const supportAgent = new ContextualAgent({
systemPrompt: 'You are a customer support agent with access to user data and documentation.',
contextManager: {
providers: [
new DatabaseContextProvider({ /* CRM integration */ }),
new KnowledgeBaseProvider({ /* FAQ & docs */ })
]
}
});
// Handle support tickets across voice and text
const tutorAgent = new ContextualAgent({
systemPrompt: 'You are an educational assistant helping students learn.',
contextManager: {
providers: [
new KnowledgeBaseProvider({ /* Curriculum content */ }),
new DatabaseContextProvider({ /* Student progress */ })
]
}
});
// Seamless transition from reading materials to voice Q&A
const codeAgent = new ContextualAgent({
contextManager: {
providers: [
new KnowledgeBaseProvider({
options: {
autoDiscoverDocs: {
enabled: true,
patterns: ['**/*.md', 'src/**/*.ts', 'docs/**/*']
}
}
})
]
}
});
// Code review via text, explanations via voice
FROM node:18-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --production
COPY . .
RUN npm run build
EXPOSE 3000
CMD ["npm", "start"]
# docker-compose.yml
version: '3.8'
services:
agent:
build: .
environment:
- OPENAI_API_KEY=${OPENAI_API_KEY}
- REDIS_URL=redis://redis:6379
depends_on:
- redis
redis:
image: redis:7-alpine
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you use this SDK in your project, please provide attribution to simcoder technologies a subsidiary of SCS Group as the creator. You can do this in one of the following ways:
<!-- In your app footer or about section -->
Powered by <a href="https://github.com/simcoder/contextual-agent-sdk">Contextual Agent SDK</a> by simcoder technologies
## Credits
- Uses [Contextual Agent SDK](https://github.com/simcoder/contextual-agent-sdk) by simcoder technologies for seamless voice-text AI interactions
{
"credits": {
"contextual-agent-sdk": "simcoder technologies - https://github.com/simcoder/contextual-agent-sdk"
}
}
import { getAttribution, getHTMLAttribution, logAttribution } from 'contextual-agent-sdk';
// Get attribution info
const attribution = getAttribution();
console.log(attribution.author); // "simcoder technologies a subsidiary of SCS Group"
// Generate HTML for your app
const htmlCredit = getHTMLAttribution();
// Returns: "Powered by <a href="...">Contextual Agent SDK</a> by simcoder technologies"
// Log attribution during development
logAttribution(); // Shows attribution info in console
// For React/Vue components
function AboutPage() {
const attribution = getAttribution();
return (
<div>
<p>This app uses {attribution.library} by simcoder technologies</p>
<a href={attribution.url}>Learn more about the technology</a>
</div>
);
}
This SDK represents significant innovation in AI agent technology. Attribution helps:
- β Give credit where credit is due
- β Help others discover this technology
- β Support continued development and improvement
- β Build a community around the innovation
Thank you for using Contextual Agent SDK responsibly!
- β First SDK to solve seamless voice-text context switching
- β Production Ready with enterprise-grade features
- β Provider Agnostic - use any LLM or speech service
- β TypeScript First - full type safety and great DX
- β Modular Design - use only what you need
- β Comprehensive Documentation - examples and guides
- β Active Development - regular updates and improvements
Ready to build the future of conversational AI? Get started with Contextual Agent SDK today!
Track the usage and adoption of your SDK with these tools:
-
NPM Download Counts API:
# Get daily downloads curl https://api.npmjs.org/downloads/point/last-day/contextual-agent-sdk # Get weekly downloads curl https://api.npmjs.org/downloads/point/last-week/contextual-agent-sdk # Get monthly downloads curl https://api.npmjs.org/downloads/point/last-month/contextual-agent-sdk # Get historical data curl https://api.npmjs.org/downloads/range/2024-01-01:2024-12-31/contextual-agent-sdk
-
Third-Party Analytics Tools:
- npm-stat.com - Historical download statistics
- npmtrends.com - Compare download trends
- pkgstats.com - Package discovery and stats
- npm-pack-count - Automated download tracking
-
Built-in GitHub Insights:
- Repository > Insights > Traffic (14-day data retention)
- Stars history and Fork tracking
- Clone statistics and Visitor analytics
-
Extended Analytics Tools:
- YHYPE - Extended GitHub analytics (>14 days)
- OSS Insight - Deep repository insights
- GitHub Traffic Dashboard - Custom traffic analytics
- u8views.com - Profile view tracking
-
Profile View Tracking:
<!-- Add to your GitHub profile README --> 
-
Automated License Scanning:
-
Code Attribution Detection:
- Vendetect - Detect copied/vendored code
- Custom GitHub search for attribution mentions
- Google search alerts for your SDK name
The SDK includes optional, privacy-first telemetry:
import { reportUsage } from 'contextual-agent-sdk/utils/attribution';
// Optional usage reporting (production only, user-consented)
await reportUsage({
projectName: 'my-chatbot',
environment: 'production',
features: ['voice-switching', 'context-management'],
disableTelemetry: false // Set to true to disable
});
Privacy Features:
- β Opt-in only - Disabled by default
- β Production only - Never runs in development
- β Anonymous - No personal data collected
- β Non-blocking - Silently fails without affecting app
- β Transparent - Full source code available
Use built-in utilities to ensure proper attribution:
import {
getAttribution,
getHTMLAttribution,
getMarkdownAttribution,
getAttributionBadge,
validateAttribution
} from 'contextual-agent-sdk/utils/attribution';
// Get attribution info
const attribution = getAttribution();
console.log(attribution.author); // "simcoder technologies a subsidiary of SCS Group"
// Generate HTML for your app
const htmlCredit = getHTMLAttribution();
// Returns: "Powered by <a href="...">Contextual Agent SDK</a> by simcoder technologies"
// Add badge to README
const badge = getAttributionBadge('markdown');
// Returns: [](https://github.com/simcoder/contextual-agent-sdk)
// Validate your package.json includes proper attribution
const validation = validateAttribution(require('./package.json'));
if (!validation.isValid) {
console.log('Attribution suggestions:', validation.suggestions);
}
// Log attribution during development
logAttribution();
React Component:
function AboutPage() {
const attribution = getAttribution();
return (
<div>
<p>This app uses {attribution.library} by simcoder technologies</p>
<a href={attribution.url}>Learn more about the technology</a>
</div>
);
}
Package.json Credits:
{
"credits": {
"contextual-agent-sdk": "simcoder technologies - https://github.com/simcoder/contextual-agent-sdk"
}
}
- β MIT License with Attribution Clause - Legally enforceable
- β Clear attribution requirements in LICENSE file
- β Multiple attribution options (flexible compliance)
- β Automated scanning with tools like SCANOSS and ScanCode
- β GitHub search alerts for usage without attribution
- β Download analytics to track adoption
- β Code fingerprinting to detect unauthorized copies
- β Clear documentation makes compliance easy
- β Helpful tools reduce friction for proper attribution
- β Community reporting via GitHub issues
- β Professional follow-up for violations
-
Set up NPM download monitoring:
npm install -g npm-download-stats npm-download-stats contextual-agent-sdk
-
Enable GitHub repository insights:
- Go to Settings > Features > Insights
- Enable Traffic and Community analytics
-
Use YHYPE for extended analytics:
- Sign up at yhype.me
- Connect your GitHub account
- Track repository metrics beyond 14 days
-
Set up Google Alerts:
"contextual-agent-sdk" -site:github.com -site:npmjs.com "simcoder technologies" "AI agent"
-
Deploy license scanning:
# Install SCANOSS pip install scanoss # Scan for your code usage scanoss scan /path/to/suspect/repository
If you use this SDK in your project, please provide attribution to simcoder technologies a subsidiary of SCS Group as the creator. You can do this in one of the following ways:
<!-- In your app footer or about section -->
Powered by <a href="https://github.com/simcoder/contextual-agent-sdk">Contextual Agent SDK</a> by simcoder technologies
## Credits
- Uses [Contextual Agent SDK](https://github.com/simcoder/contextual-agent-sdk) by simcoder technologies for seamless voice-text AI interactions
{
"credits": {
"contextual-agent-sdk": "simcoder technologies - https://github.com/simcoder/contextual-agent-sdk"
}
}
import { getAttribution, getHTMLAttribution, logAttribution } from 'contextual-agent-sdk';
// Get attribution info
const attribution = getAttribution();
console.log(attribution.author); // "simcoder technologies a subsidiary of SCS Group"
// Generate HTML for your app
const htmlCredit = getHTMLAttribution();
// Returns: "Powered by <a href="...">Contextual Agent SDK</a> by simcoder technologies"
// Log attribution during development
logAttribution(); // Shows attribution info in console
// For React/Vue components
function AboutPage() {
const attribution = getAttribution();
return (
<div>
<p>This app uses {attribution.library} by simcoder technologies</p>
<a href={attribution.url}>Learn more about the technology</a>
</div>
);
}
This SDK represents significant innovation in AI agent technology. Attribution helps:
- β Give credit where credit is due
- β Help others discover this technology
- β Support continued development and improvement
- β Build a community around the innovation
Thank you for using Contextual Agent SDK responsibly!
- β First SDK to solve seamless voice-text context switching
- β Production Ready with enterprise-grade features
- β Provider Agnostic - use any LLM or speech service
- β TypeScript First - full type safety and great DX
- β Modular Design - use only what you need
- β Comprehensive Documentation - examples and guides
- β Active Development - regular updates and improvements
Ready to build the future of conversational AI? Get started with Contextual Agent SDK today!
This comprehensive monitoring approach ensures you can track usage, enforce attribution, and protect your intellectual property while maintaining the open-source nature of your SDK! π