import { z } from "zod";
import { fetchEvents } from "../services/gamma.js";
const schema = z.object({
event_slug: z.string().optional().describe("Event slug (e.g., 'presidential-election-2024')"),
event_id: z.string().optional().describe("Event ID (alternative to slug)"),
});
export const getEventMarketsTool = {
name: "get_event_markets",
description:
"Get markets for a specific event. Provide event_id or event_slug from list_events/search_markets. Example: event_id=80505.",
parameters: schema,
execute: async (args: z.infer<typeof schema>) => {
try {
if (!args.event_slug && !args.event_id) {
return JSON.stringify({ error: "Either event_slug or event_id is required" });
}
const params: { slug?: string; id?: string } = {};
if (args.event_slug) params.slug = args.event_slug;
if (args.event_id) params.id = args.event_id;
const data = await fetchEvents(params);
return JSON.stringify(data, null, 2);
} catch (error) {
return JSON.stringify({ error: error instanceof Error ? error.message : String(error) });
}
},
};