'use strict';

var chunkC6CCPCEC_cjs = require('./chunk-C6CCPCEC.cjs');
var chunk42M6Y2OD_cjs = require('./chunk-42M6Y2OD.cjs');
var chunkDIG2K5CV_cjs = require('./chunk-DIG2K5CV.cjs');
var chunkZ7LCIYK7_cjs = require('./chunk-Z7LCIYK7.cjs');
var chunkN54Q3AQR_cjs = require('./chunk-N54Q3AQR.cjs');
var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');

// src/server/handlers/logs.ts
var logs_exports = {};
chunkO7I5CWRX_cjs.__export(logs_exports, {
  LIST_LOGS_BY_RUN_ID_ROUTE: () => LIST_LOGS_BY_RUN_ID_ROUTE,
  LIST_LOGS_ROUTE: () => LIST_LOGS_ROUTE,
  LIST_LOG_TRANSPORTS_ROUTE: () => LIST_LOG_TRANSPORTS_ROUTE
});
var LIST_LOG_TRANSPORTS_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "GET",
  path: "/logs/transports",
  responseType: "json",
  responseSchema: chunkC6CCPCEC_cjs.listLogTransportsResponseSchema,
  summary: "List log transports",
  description: "Returns a list of all available log transports",
  tags: ["Logs"],
  requiresAuth: true,
  handler: async ({ mastra }) => {
    try {
      const logger = mastra.getLogger();
      const transports = logger.getTransports();
      return {
        transports: transports ? [...transports.keys()] : []
      };
    } catch (error) {
      return chunkZ7LCIYK7_cjs.handleError(error, "Error getting log Transports");
    }
  }
});
var LIST_LOGS_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "GET",
  path: "/logs",
  responseType: "json",
  queryParamSchema: chunkC6CCPCEC_cjs.listLogsQuerySchema,
  responseSchema: chunkC6CCPCEC_cjs.listLogsResponseSchema,
  summary: "List logs",
  description: "Returns logs from a specific transport with optional filtering by date range, log level, and custom filters",
  tags: ["Logs"],
  requiresAuth: true,
  handler: async ({ mastra, ...params }) => {
    try {
      const { transportId, fromDate, toDate, logLevel, filters: _filters, page, perPage } = params;
      chunk42M6Y2OD_cjs.validateBody({ transportId });
      const filters = chunk42M6Y2OD_cjs.parseFilters(_filters);
      const logs = await mastra.listLogs(transportId, {
        fromDate,
        toDate,
        logLevel,
        filters,
        page: page ? Number(page) : void 0,
        perPage: perPage ? Number(perPage) : void 0
      });
      return logs;
    } catch (error) {
      return chunkZ7LCIYK7_cjs.handleError(error, "Error getting logs");
    }
  }
});
var LIST_LOGS_BY_RUN_ID_ROUTE = chunkN54Q3AQR_cjs.createRoute({
  method: "GET",
  path: "/logs/:runId",
  responseType: "json",
  pathParamSchema: chunkDIG2K5CV_cjs.runIdSchema,
  queryParamSchema: chunkC6CCPCEC_cjs.listLogsQuerySchema,
  responseSchema: chunkC6CCPCEC_cjs.listLogsResponseSchema,
  summary: "List logs by run ID",
  description: "Returns all logs for a specific execution run from a transport",
  tags: ["Logs"],
  requiresAuth: true,
  handler: async ({ mastra, runId, ...params }) => {
    try {
      const { transportId, fromDate, toDate, logLevel, filters: _filters, page, perPage } = params;
      chunk42M6Y2OD_cjs.validateBody({ runId, transportId });
      const filters = chunk42M6Y2OD_cjs.parseFilters(_filters);
      const logs = await mastra.listLogsByRunId({
        runId,
        transportId,
        fromDate,
        toDate,
        logLevel,
        filters,
        page: page ? Number(page) : void 0,
        perPage: perPage ? Number(perPage) : void 0
      });
      return logs;
    } catch (error) {
      return chunkZ7LCIYK7_cjs.handleError(error, "Error getting logs by run ID");
    }
  }
});

exports.LIST_LOGS_BY_RUN_ID_ROUTE = LIST_LOGS_BY_RUN_ID_ROUTE;
exports.LIST_LOGS_ROUTE = LIST_LOGS_ROUTE;
exports.LIST_LOG_TRANSPORTS_ROUTE = LIST_LOG_TRANSPORTS_ROUTE;
exports.logs_exports = logs_exports;
//# sourceMappingURL=chunk-JJOGTXKN.cjs.map
//# sourceMappingURL=chunk-JJOGTXKN.cjs.map