"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cliConfigProvider_1 = require("@mablhq-internal/runtime/providers/cliConfigProvider");
const mcpMablTool_1 = require("./mcpMablTool");
const zod_1 = require("zod");
const switchWorkspace = (0, mcpMablTool_1.defineTool)({
    schema: {
        name: 'switch_workspace',
        title: 'Switch the current workspace',
        description: 'Switch to a different workspace by providing a workspace ID. Example: Switch to workspace "Personal"',
        inputSchema: zod_1.z.object({
            workspaceId: zod_1.z.string().describe('The ID of the workspace to switch to'),
        }),
        type: 'destructive',
    },
    handle: async (args, context) => {
        const { mablApiClient } = context.getCurrentContext();
        const { workspaceId: newWorkspaceId } = args;
        const workspace = await mablApiClient.getWorkspace(newWorkspaceId);
        await cliConfigProvider_1.CliConfigProvider.setWorkspace(workspace);
        await context.setWorkspaceId(newWorkspaceId);
        return {
            content: [
                {
                    type: 'text',
                    text: `Successfully switched workspace to "${workspace.name}" (${newWorkspaceId})`,
                },
            ],
        };
    },
});
exports.default = [switchWorkspace];
