UNPKG

sei-agent-kit

Version:

A package for building AI agents on the SEI blockchain

27 lines 1.34 kB
import { StructuredTool } from "langchain/tools"; import { z } from "zod"; // Define a schema for a single order cancellation const OrderCancelSchema = z.object({ orderId: z.string().startsWith("0x").describe("The unique order ID of the order to be cancelled"), productId: z.number().int().positive().describe("The product ID of the order to be cancelled"), }); const CitrexCancelOrdersInputSchema = z.object({ orders: z.array(OrderCancelSchema).min(1).describe("Array of orders to cancel, each with orderId and productId"), }); export class SeiCitrexCancelOrdersTool extends StructuredTool { seiKit; name = "citrex_cancel_orders"; description = "Cancels multiple orders on the Citrex Protocol in a single operation. This is more efficient than cancelling orders one by one. Returns an array of success flags indicating whether each cancellation was successful."; schema = CitrexCancelOrdersInputSchema; constructor(seiKit) { super(); this.seiKit = seiKit; } async _call(input) { const { orders } = input; // Convert to the format expected by the SDK const formattedOrdersArgs = orders.map(({ orderId, productId }) => [orderId, productId]); return this.seiKit.citrexCancelOrders(formattedOrdersArgs); } } //# sourceMappingURL=cancelOrders.js.map