// tools/license-status.ts — Handler for license_status MCP tool.
// Shows current tier, limits, usage, and upgrade URL.
import { licenseStore } from '../storage/index.js';
import { resolveCurrentTier, getTierLimits, loadLicensePlans, } from '../engine/license-validator.js';
export async function handleLicenseStatus(_args) {
    const state = await licenseStore.getLicenseState();
    const tier = resolveCurrentTier(state);
    const limits = getTierLimits(tier);
    const config = loadLicensePlans();
    const projectCount = await licenseStore.countActiveProjects();
    const lines = [];
    lines.push(`## Planu License Status`);
    lines.push('');
    if (state) {
        lines.push(`**Plan:** ${tier.charAt(0).toUpperCase() + tier.slice(1)}`);
        lines.push(`**Customer:** ${state.customerName} (${state.customerEmail})`);
        lines.push(`**Variant:** ${state.variantName}`);
        lines.push(`**Activated:** ${state.activatedAt}`);
        lines.push(`**Last validated:** ${state.lastValidatedAt}`);
    }
    else {
        lines.push(`**Plan:** Free`);
        lines.push(`**Tools available:** ${String(config.freeTools.length)} of ${String(config.freeTools.length + config.proTools.length)}`);
    }
    lines.push('');
    lines.push('### Limits');
    lines.push(`- Projects: ${String(projectCount)} / ${limits.maxProjects >= 999999 ? '∞' : String(limits.maxProjects)}`);
    lines.push(`- Active specs: ${limits.maxActiveSpecs >= 999999 ? '∞' : String(limits.maxActiveSpecs)} per project`);
    if (tier === 'free') {
        lines.push('');
        lines.push('### Upgrade');
        lines.push(`Unlock all 60+ tools, 10 projects, and unlimited specs.`);
        lines.push(`→ ${config.upgradeUrl}`);
        lines.push('');
        lines.push('Already have a key? Use `activate_license` to activate it.');
    }
    return { content: [{ type: 'text', text: lines.join('\n') }] };
}
//# sourceMappingURL=license-status.js.map