'use strict';

var chunkE7UDPLDF_cjs = require('./chunk-E7UDPLDF.cjs');
var chunkAZORAK4H_cjs = require('./chunk-AZORAK4H.cjs');
var chunkB34S64RC_cjs = require('./chunk-B34S64RC.cjs');
var fs = require('fs');

var GET_API_SCHEMA_ROUTE = chunkAZORAK4H_cjs.createRoute({
  method: "GET",
  path: "/system/api-schema",
  responseType: "json",
  responseSchema: chunkE7UDPLDF_cjs.apiSchemaManifestResponseSchema,
  summary: "Get API schema manifest",
  description: "Returns the route-contract-derived API schema manifest for the machine-readable CLI",
  tags: ["System"],
  requiresAuth: true,
  handler: async () => {
    const { buildApiSchemaManifest } = await import('./api-schema-manifest-WVM7QABS.cjs');
    return buildApiSchemaManifest();
  }
});
var GET_SYSTEM_PACKAGES_ROUTE = chunkAZORAK4H_cjs.createRoute({
  method: "GET",
  path: "/system/packages",
  responseType: "json",
  responseSchema: chunkE7UDPLDF_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_API_SCHEMA_ROUTE = GET_API_SCHEMA_ROUTE;
exports.GET_SYSTEM_PACKAGES_ROUTE = GET_SYSTEM_PACKAGES_ROUTE;
//# sourceMappingURL=chunk-2GEO7VUJ.cjs.map
//# sourceMappingURL=chunk-2GEO7VUJ.cjs.map