'use strict';

var chunkZFCNTRZ2_cjs = require('./chunk-ZFCNTRZ2.cjs');
var chunkYDO5OPEU_cjs = require('./chunk-YDO5OPEU.cjs');
var chunkB34S64RC_cjs = require('./chunk-B34S64RC.cjs');
var fs = require('fs');

var GET_SYSTEM_PACKAGES_ROUTE = chunkYDO5OPEU_cjs.createRoute({
  method: "GET",
  path: "/system/packages",
  responseType: "json",
  responseSchema: chunkZFCNTRZ2_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 = [];
        }
      }
      const storage = mastra.getStorage();
      const storageType = storage?.name;
      const observabilityStorageType = storage?.stores?.observability?.constructor.name;
      return {
        packages,
        isDev: process.env.MASTRA_DEV === "true",
        cmsEnabled: !!mastra.getEditor(),
        storageType,
        observabilityStorageType
      };
    } catch (error) {
      return chunkB34S64RC_cjs.handleError(error, "Error getting system packages");
    }
  }
});

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