import { apiSchemaManifestResponseSchema, systemPackagesResponseSchema } from './chunk-4PB6LUYQ.js';
import { createRoute } from './chunk-E53AJNZB.js';
import { handleError } from './chunk-P23KBWKB.js';
import { readFileSync } from 'fs';

var GET_API_SCHEMA_ROUTE = createRoute({
  method: "GET",
  path: "/system/api-schema",
  responseType: "json",
  responseSchema: 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-HTSK7CWD.js');
    return buildApiSchemaManifest();
  }
});
var GET_SYSTEM_PACKAGES_ROUTE = 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 ({ mastra }) => {
    try {
      const packagesFilePath = process.env.MASTRA_PACKAGES_FILE;
      let packages = [];
      if (packagesFilePath) {
        try {
          const fileContent = 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 handleError(error, "Error getting system packages");
    }
  }
});

export { GET_API_SCHEMA_ROUTE, GET_SYSTEM_PACKAGES_ROUTE };
//# sourceMappingURL=chunk-N63KDS6D.js.map
//# sourceMappingURL=chunk-N63KDS6D.js.map