import { logger } from "../../logger.js";
/**
 * Creates a CommandHandler for the "usage" remote command.
 * Delegates to buildToolUsageReport() — the same logic used by the /usage Telegram command.
 */
export function createUsageHandler() {
    return async (_commandId, _payload) => {
        try {
            logger.system("[usage-handler] Received remote usage command");
            const { buildToolUsageReport } = await import("../tool-usage.js");
            const report = await buildToolUsageReport();
            logger.system("[usage-handler] Usage report generated successfully");
            return {
                status: "completed",
                result: JSON.stringify({ message: report }),
            };
        }
        catch (err) {
            const errMsg = err instanceof Error ? err.message : String(err);
            logger.err(`[usage-handler] Failed to generate usage report: ${errMsg}`);
            return {
                status: "failed",
                result: JSON.stringify({ error: errMsg }),
            };
        }
    };
}
//# sourceMappingURL=usage-handler.js.map