kmail-cmail
v1.0.10
Published
An intelligent AI agent that performs various automated tasks
Downloads
1,145
Maintainers
Readme
Cmail
An intelligent AI agent that performs various automated tasks including file operations, data processing, text analysis, web scraping, and automation.
Installation
npm install kmail-cmailUsage
const Cmail = require('cmail');
// Initialize the AI agent
const agent = new Cmail({
name: 'My Assistant',
debug: true
});
// Execute various tasks
async function runTasks() {
try {
// File operations
const writeResult = await agent.executeTask('file_write', {
filePath: './output.txt',
content: 'Hello from Cmail AI Agent!'
});
const readResult = await agent.executeTask('file_read', {
filePath: './output.txt'
});
// Data processing
const dataResult = await agent.executeTask('data_process', {
data: [1, 2, 3, 4, 5],
operation: 'sum'
});
// Text analysis
const textResult = await agent.executeTask('text_analyze', {
text: 'Contact us at [email protected] or visit https://example.com',
analysis: 'extract_emails'
});
// List files in directory
const listResult = await agent.executeTask('file_list', {
directory: './'
});
console.log('Task results:', { writeResult, readResult, dataResult, textResult, listResult });
// View task history
console.log('Task History:', agent.getTaskHistory());
// View agent capabilities
console.log('Capabilities:', agent.getCapabilities());
} catch (error) {
console.error('Error executing tasks:', error.message);
}
}
runTasks();Web UI
Cmail includes a modern, responsive web interface with enhanced UX:
Features
- Modern Dark Theme: Beautiful gradient backgrounds with animated effects
- Tabbed Interface: Organized workspace with Chat, Files, Tools, and Models sections
- Keyboard Shortcuts: Ctrl+1/2/3/4 to quickly switch between tabs
- Real-time Status: Live Ollama connection status indicator
- Enhanced Chat: Typing indicators, message history, and markdown support
- File Operations: Read, write, and list files with visual feedback
- Data Analysis Tools: Text analysis and data processing utilities
- Model Management: Visual model selection with status indicators
- Copy to Clipboard: One-click copy for all outputs
- Responsive Design: Works seamlessly on desktop and mobile devices
- Loading States: Beautiful animated loading indicators
- Error Handling: Clear error messages with visual feedback
Starting the Web UI
# Start the web server
cmail web
# Or specify custom port and host
cmail web --port 8080 --host 127.0.0.1The web interface will be available at http://localhost:6000 by default.
Web UI Sections
Chat Tab
- Select AI models from dropdown
- Real-time conversation with typing indicators
- Message history persistence
- Clear chat functionality
- Keyboard shortcuts (Enter to send, Shift+Enter for new line)
Files Tab
- List directory contents
- Read file contents
- Write/create files
- Visual file type indicators
Tools Tab
- Text analysis (word count, character count, email/URL extraction)
- Data processing (count, sum, average, filter, sort)
- JSON validation for data operations
- Copy results to clipboard
Models Tab
- View installed Ollama models
- Visual model selection
- Refresh model list
- Popular model badges
- Real-time status indicators
CLI Commands
Constructor Options
name(string): Agent name (default: 'Cmail Agent')version(string): Agent version (default: '1.0.0')debug(boolean): Enable debug logging (default: false)
Methods
executeTask(taskType, params)
Executes a specific task with given parameters.
Parameters:
taskType(string): Type of task to executeparams(object): Task-specific parameters
Returns: Promise that resolves to an object with success, taskId, and result or error properties.
getTaskHistory()
Returns the history of all executed tasks.
getCapabilities()
Returns the list of available agent capabilities.
Task Types
File Operations
file_read
filePath(string): Path to the file to read
file_write
filePath(string): Path where to write the filecontent(string): Content to write to the file
file_list
directory(string): Directory path to list files from
Data Processing
data_process
data(array/object): Data to processoperation(string): Operation type - 'count', 'sum', 'average', 'filter', 'sort'
Text Analysis
text_analyze
text(string): Text to analyzeanalysis(string): Analysis type - 'word_count', 'character_count', 'line_count', 'extract_emails', 'extract_urls'
Web Scraping
web_scrape
url(string): URL to scrapeselector(string): CSS selector for content extraction
Automation
automation
script(string): Automation script to execute
Examples
Data Processing Example
const numbers = [10, 20, 30, 40, 50];
const result = await agent.executeTask('data_process', {
data: numbers,
operation: 'average'
});
console.log('Average:', result.result); // 30Text Analysis Example
const text = 'Contact: [email protected], [email protected], [email protected]';
const emails = await agent.executeTask('text_analyze', {
text: text,
analysis: 'extract_emails'
});
console.log('Emails found:', emails.result);
// ['[email protected]', '[email protected]', '[email protected]']File Management Example
// Create a directory and files
await agent.executeTask('file_write', {
filePath: './data/report.txt',
content: 'Quarterly Report Data'
});
// List files
const files = await agent.executeTask('file_list', {
directory: './data'
});
console.log('Files:', files.result);License
ISC
