'use strict';

var chunkP2ZMGGHF_cjs = require('./chunk-P2ZMGGHF.cjs');
var chunkY2BKW5ND_cjs = require('./chunk-Y2BKW5ND.cjs');
var chunk6P7P7Y5U_cjs = require('./chunk-6P7P7Y5U.cjs');
var fs = require('fs');

var GET_SYSTEM_PACKAGES_ROUTE = chunk6P7P7Y5U_cjs.createRoute({
  method: "GET",
  path: "/system/packages",
  responseType: "json",
  responseSchema: chunkP2ZMGGHF_cjs.systemPackagesResponseSchema,
  summary: "Get installed Mastra packages",
  description: "Returns a list of all installed Mastra packages and their versions from the project",
  tags: ["System"],
  requiresAuth: true,
  handler: async ({ mastra }) => {
    try {
      const packagesFilePath = process.env.MASTRA_PACKAGES_FILE;
      let packages = [];
      if (packagesFilePath) {
        try {
          const fileContent = fs.readFileSync(packagesFilePath, "utf-8");
          packages = JSON.parse(fileContent);
        } catch {
          packages = [];
        }
      }
      return { packages, isDev: process.env.MASTRA_DEV === "true", cmsEnabled: !!mastra.getEditor() };
    } catch (error) {
      return chunkY2BKW5ND_cjs.handleError(error, "Error getting system packages");
    }
  }
});

exports.GET_SYSTEM_PACKAGES_ROUTE = GET_SYSTEM_PACKAGES_ROUTE;
//# sourceMappingURL=chunk-QQGEBRIG.cjs.map
//# sourceMappingURL=chunk-QQGEBRIG.cjs.map