UNPKG

@agentek/tools

Version:

Blockchain tools for AI agents

30 lines 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fearGreedIndexTool = void 0; const zod_1 = require("zod"); const client_js_1 = require("../client.js"); const utils_js_1 = require("../utils.js"); const getFearAndGreedIndexToolParams = zod_1.z.object({}); exports.fearGreedIndexTool = (0, client_js_1.createTool)({ name: "getFearAndGreedIndex", description: "Retrieves the current Fear and Greed Index value from Alternative.me API.", parameters: getFearAndGreedIndexToolParams, execute: async (_client, _args) => { try { const response = await fetch("https://api.alternative.me/fng/"); const data = await response.json(); if (!data || !data.data || !Array.isArray(data.data) || !data.data[0] || !data.data[0].value) { throw new Error("Invalid response format from Fear and Greed API."); } return (0, utils_js_1.clean)(data.data[0]); } catch (error) { throw new Error(`Failed to fetch Fear and Greed Index: ${error.message}`); } }, }); //# sourceMappingURL=tools.js.map