import { createSubcommand } from "../../types.js";
import { clearAuth, defaultProfileName } from "../../config.js";
import { clearCachedUserInfo } from "../../cache/index.js";
import * as tui from "../../tui.js";
import { getCommand } from "../../command-prefix.js";
export const logoutCommand = createSubcommand({
    name: 'logout',
    description: 'Logout of the Agentuity Cloud Platform',
    tags: ['mutating', 'deletes-resource', 'fast', 'requires-auth'],
    toplevel: true,
    idempotent: false,
    examples: [
        { command: getCommand('auth logout'), description: 'Logout from account' },
        { command: getCommand('logout'), description: 'Logout from account' },
    ],
    async handler(ctx) {
        const { options } = ctx;
        await clearAuth();
        await clearCachedUserInfo(ctx.config?.name ?? defaultProfileName);
        if (!options.json) {
            tui.success('You have been logged out');
        }
    },
});
//# sourceMappingURL=logout.js.map