@suiware/ai-tools
Version:
Pluggable tools for Vercel AI SDK which allow AI assistants to interact with Sui Network and perform various actions.
34 lines (32 loc) • 1.18 kB
JavaScript
import { NaviService } from './chunk-OZX7KUX2.mjs';
import { __async, disableConsoleLog, enableConsoleLog } from './chunk-HFORSGSH.mjs';
import { tool } from 'ai';
import z from 'zod';
var suiSwapTool = tool({
description: "Swap coins",
parameters: z.object({
amount: z.number().describe("The amount of source coin to swap"),
sourceCoin: z.string().refine((arg) => NaviService.isSupportedCoin(arg), {
message: "The source coin not supported"
}).describe("The source coin"),
targetCoin: z.string().refine((arg) => NaviService.isSupportedCoin(arg), {
message: "The target coin not supported"
}).describe("The target coin")
}),
execute: (_0) => __async(null, [_0], function* ({ amount, sourceCoin, targetCoin }) {
const originalConsoleLog = disableConsoleLog();
const naviService = new NaviService();
const transactionResult = yield naviService.swap(
sourceCoin,
targetCoin,
amount
);
enableConsoleLog(originalConsoleLog);
return {
digest: transactionResult.digest
};
})
});
export { suiSwapTool };
//# sourceMappingURL=chunk-75WAM73K.mjs.map
//# sourceMappingURL=chunk-75WAM73K.mjs.map