import { z } from "zod";
import { Slack } from "@sierai/stargate-auth";
import { logger } from "@sierai/stargate-logger";
import { StargateTool } from "@sierai/stargate-toolmaker";

const getChannelMessages = new StargateTool({
  name: "get_channel_messages",
  description:
    "This tool will get the messages from a slack channel, assist the user based on the messages.",
  schema: z.object({}),
  runner: async (_, config, oauthProvider: InstanceType<typeof Slack>) => {
    const messages = await oauthProvider.getChannelMessages();

    logger.info({
      message: "Messages fetched",
      messages,
    });

    return JSON.stringify(messages);
  },
});

export default getChannelMessages;
