@hivetechs/hive-ai
Version:
Real-time streaming AI consensus platform with HTTP+SSE MCP integration for Claude Code, VS Code, Cursor, and Windsurf - powered by OpenRouter's unified API
62 lines âĸ 3.08 kB
JavaScript
/**
* Usage Display Tool
* Provides a quick, easy-to-read overview of current usage and subscription status
*/
import { z } from 'zod';
import { UsageTracker } from '../../core/usage-tracker.js';
export const usageDisplayToolName = 'usage_display';
export const usageDisplayToolDescription = 'Quick overview of your current usage and subscription status';
export const UsageDisplaySchema = z.object({
format: z.enum(['quick', 'detailed']).default('quick').describe('Display format - quick for overview, detailed for full stats')
});
export async function runUsageDisplayTool(args) {
try {
const usageTracker = UsageTracker.getInstance();
if (args.format === 'detailed') {
// Return detailed usage display with progress bars and full information
const detailedDisplay = await usageTracker.getUsageDisplay();
return {
usage_overview: detailedDisplay,
message: detailedDisplay
};
}
else {
// Return quick usage check with any notifications
const usageCheck = await usageTracker.checkUsageBeforeConversation();
let quickDisplay = '';
if (usageCheck.notification) {
const { type, title, message } = usageCheck.notification;
const icon = type === 'critical' ? 'đ¨' : type === 'warning' ? 'â ī¸' : type === 'info' ? 'âšī¸' : 'â
';
quickDisplay = `${icon} **${title}**\n\n${message}`;
if (usageCheck.notification.action) {
quickDisplay += `\n\n[${usageCheck.notification.action.label}](${usageCheck.notification.action.url})`;
}
}
else {
// No notifications - show simple status
const detailedDisplay = await usageTracker.getUsageDisplay();
// Extract just the key information for quick display
const lines = detailedDisplay.split('\n');
const todayLine = lines.find(line => line.includes('**Today**:')) || '';
const monthLine = lines.find(line => line.includes('**This Month**:')) || '';
const statusLine = lines.find(line => line.includes('**Status**:')) || '';
quickDisplay = `đ **Quick Usage Check**\n\n`;
quickDisplay += `${todayLine}\n`;
quickDisplay += `${monthLine}\n\n`;
quickDisplay += `${statusLine}\n\n`;
quickDisplay += `For detailed view: \`usage_display format:detailed\``;
}
return {
status: usageCheck.allowed ? 'ok' : 'blocked',
message: quickDisplay
};
}
}
catch (error) {
return {
error: `Failed to get usage information: ${error instanceof Error ? error.message : 'Unknown error'}`,
message: 'â **ERROR** - Unable to retrieve usage information. Please check your connection and try again.'
};
}
}
//# sourceMappingURL=usage-display.js.map