import { z } from "zod";
import { api } from "../services/api.js";
const getOrderBookSchema = z.object({
token_id: z.string().describe("The token ID for the market outcome"),
});
export const getOrderBookTool = {
name: "get_order_book",
description:
"Get order book via CLOB /book for token_id. Source: clobTokenIds from list_active_markets or get_market_details. If token has no active order book, returns 404. Example: token_id=clobTokenIds[0].",
parameters: getOrderBookSchema,
execute: async (args: z.infer<typeof getOrderBookSchema>) => {
try {
const data = await api.getOrderBook(args.token_id);
return JSON.stringify(data, null, 2);
} catch (error) {
return JSON.stringify({
error: error instanceof Error ? error.message : String(error),
});
}
},
};