'use strict';

var chunkSUKFO7UM_cjs = require('./chunk-SUKFO7UM.cjs');
var chunkK52BGIHQ_cjs = require('./chunk-K52BGIHQ.cjs');
var fs = require('fs');
var zod = require('zod');

var mastraPackageSchema = zod.z.object({
  name: zod.z.string(),
  version: zod.z.string()
});
var systemPackagesResponseSchema = zod.z.object({
  packages: zod.z.array(mastraPackageSchema),
  isDev: zod.z.boolean()
});

// src/server/handlers/system.ts
var GET_SYSTEM_PACKAGES_ROUTE = chunkK52BGIHQ_cjs.createRoute({
  method: "GET",
  path: "/system/packages",
  responseType: "json",
  responseSchema: 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 () => {
    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" };
    } catch (error) {
      return chunkSUKFO7UM_cjs.handleError(error, "Error getting system packages");
    }
  }
});

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