"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEnvironmentsOutputSchema = void 0;
const zod_1 = require("zod");
const mcpMablTool_1 = require("./mcpMablTool");
const common_1 = require("../utils/common");
exports.getEnvironmentsOutputSchema = zod_1.z.object({
    environments: zod_1.z.array(zod_1.z.object({
        id: zod_1.z.string().optional(),
        name: zod_1.z.string().optional(),
    })),
});
const getEnvironments = (0, mcpMablTool_1.defineTool)({
    schema: {
        name: 'get_environments',
        title: 'Get all mabl environments',
        description: 'Get all mabl environments. Example: Get my mabl environments',
        inputSchema: zod_1.z.object({}),
        outputSchema: exports.getEnvironmentsOutputSchema,
        type: 'readOnly',
    },
    handle: async (_, context) => {
        const { mablApiClient, workspaceId } = context.getCurrentContext();
        const limit = 500;
        const environments = await mablApiClient.getEnvironments(workspaceId, limit);
        const environmentsResponse = environments.map((env) => ({
            id: env.id,
            name: env.name,
        }));
        return {
            content: [
                {
                    type: 'text',
                    text: (0, common_1.jsonPrettyPrint)({ environments: environmentsResponse }),
                },
            ],
            structuredContent: { environments: environmentsResponse },
        };
    },
});
exports.default = [getEnvironments];
