'use strict';

var chunk4P7D66VB_cjs = require('./chunk-4P7D66VB.cjs');
var chunk5UKYK7YK_cjs = require('./chunk-5UKYK7YK.cjs');
var chunkB34S64RC_cjs = require('./chunk-B34S64RC.cjs');
var fs = require('fs');

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

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