UNPKG

pharos-agent-kit

Version:
185 lines (181 loc) 6.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ElfaAccountSmartStatsTool = exports.ElfaTrendingTokensTool = exports.ElfaSearchMentionsTool = exports.ElfaGetTopMentionsTool = exports.ElfaGetMentionsTool = exports.ElfaApiKeyStatusTool = exports.ElfaPingTool = void 0; const tools_1 = require("langchain/tools"); class ElfaPingTool extends tools_1.Tool { constructor(agent) { super(); this.agent = agent; this.name = "elfa_ping"; this.description = "Checks the health of the Elfa AI API by pinging it."; } async _call() { try { const data = await this.agent.pingElfaAiApi(); return JSON.stringify({ status: "success", data }); } catch (error) { return JSON.stringify({ status: "error", message: error.message, }); } } } exports.ElfaPingTool = ElfaPingTool; class ElfaApiKeyStatusTool extends tools_1.Tool { constructor(agent) { super(); this.agent = agent; this.name = "elfa_api_key_status"; this.description = "Retrieves the status and usage details of the Elfa AI API key."; } async _call() { try { const data = await this.agent.getElfaAiApiKeyStatus(); return JSON.stringify({ status: "success", data }); } catch (error) { return JSON.stringify({ status: "error", message: error.message, }); } } } exports.ElfaApiKeyStatusTool = ElfaApiKeyStatusTool; class ElfaGetMentionsTool extends tools_1.Tool { constructor(agent) { super(); this.agent = agent; this.name = "elfa_get_smart_mentions"; this.description = `Retrieves tweets by smart accounts with smart engagement from the Elfa AI API. Inputs (JSON string): - limit: number, eg 100 (optional) - offset: number, eg 0 (optional)`; } async _call(input) { try { const parsedInput = JSON.parse(input); const { limit = 100, offset = 0 } = parsedInput; const data = await this.agent.getSmartMentions(limit, offset); return JSON.stringify({ status: "success", data }); } catch (error) { return JSON.stringify({ status: "error", message: error.message, }); } } } exports.ElfaGetMentionsTool = ElfaGetMentionsTool; class ElfaGetTopMentionsTool extends tools_1.Tool { constructor(agent) { super(); this.agent = agent; this.name = "elfa_get_top_mentions"; this.description = `Retrieves top tweets for a given ticker symbol from the Elfa AI API. Inputs (JSON string): - ticker: string, eg "ETH" (required) - timeWindow: string, eg "3h" (optional) - page: number, eg 1 (optional) - pageSize: number, eg 10 (optional) - includeAccountDetails: boolean, eg false (optional)`; } async _call(input) { try { const parsedInput = JSON.parse(input); const { ticker, timeWindow = "3h", page = 1, pageSize = 10, includeAccountDetails = false, } = parsedInput; if (!ticker) { throw new Error("Ticker is required."); } const data = await this.agent.getTopMentionsByTicker(ticker, timeWindow, page, pageSize, includeAccountDetails); return JSON.stringify({ status: "success", data }); } catch (error) { return JSON.stringify({ status: "error", message: error.message, }); } } } exports.ElfaGetTopMentionsTool = ElfaGetTopMentionsTool; class ElfaSearchMentionsTool extends tools_1.Tool { constructor(agent) { super(); this.agent = agent; this.name = "elfa_search_mentions_by_keywords"; this.description = `Searches for tweets by keywords within a specified date range using the Elfa AI API. Inputs (JSON string): - keywords : string, eg "ai, agents" (required) - from: number, eg 9542671763 (required) - to: number, eg 9542671873 (required) - limit: number, eg 20 (optional)`; } async _call(input) { try { const parsedInput = JSON.parse(input); const { keywords, from, to, limit = 20 } = parsedInput; if (!keywords || !from || !to) { throw new Error("Keywords, from, and to fields are required."); } const data = await this.agent.searchMentionsByKeywords(keywords, from, to, limit); return JSON.stringify({ status: "success", data }); } catch (error) { return JSON.stringify({ status: "error", message: error.message, }); } } } exports.ElfaSearchMentionsTool = ElfaSearchMentionsTool; class ElfaTrendingTokensTool extends tools_1.Tool { constructor(agent) { super(); this.agent = agent; this.name = "elfa_trending_tokens"; this.description = `Retrieves trending tokens based on mentions from the Elfa AI API.`; } async _call(_input) { try { const data = await this.agent.getTrendingTokens(); return JSON.stringify({ status: "success", data }); } catch (error) { return JSON.stringify({ status: "error", message: error.message, }); } } } exports.ElfaTrendingTokensTool = ElfaTrendingTokensTool; class ElfaAccountSmartStatsTool extends tools_1.Tool { constructor(agent) { super(); this.agent = agent; this.name = "elfa_account_smart_stats"; this.description = `Retrieves smart stats and social metrics for a specified twitter account from the Elfa AI API. Inputs: username: string, eg "pharos_network" (required)`; } async _call(input) { try { const username = input.trim(); const data = await this.agent.getSmartTwitterAccountStats(username); return JSON.stringify({ status: "success", data }); } catch (error) { return JSON.stringify({ status: "error", message: error.message, }); } } } exports.ElfaAccountSmartStatsTool = ElfaAccountSmartStatsTool; //# sourceMappingURL=elfa_ai_api.js.map