@elizaos/plugin-ferepro 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +228 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +301 -0
- package/dist/index.js.map +1 -0
- package/package.json +85 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Eliza
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
# @elizaos/plugin-ferepro
|
2
|
+
|
3
|
+
A plugin for enabling WebSocket communication with FerePro API to provide AI-driven market insights within the ElizaOS ecosystem.
|
4
|
+
|
5
|
+
## Description
|
6
|
+
|
7
|
+
The FerePro plugin enables real-time communication with the FerePro API through WebSocket connections, providing market analysis, cryptocurrency comparisons, and financial insights.
|
8
|
+
|
9
|
+
## Features
|
10
|
+
|
11
|
+
- Real-time WebSocket communication
|
12
|
+
- Streaming and non-streaming response support
|
13
|
+
- Market data analysis and comparisons
|
14
|
+
- Cryptocurrency insights
|
15
|
+
- Debug mode for detailed responses
|
16
|
+
- Automatic connection management
|
17
|
+
- Comprehensive error handling
|
18
|
+
- Credit tracking and management
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
```bash
|
23
|
+
bun install @elizaos/plugin-ferepro
|
24
|
+
```
|
25
|
+
|
26
|
+
## Configuration
|
27
|
+
|
28
|
+
### Required Environment Variables
|
29
|
+
|
30
|
+
```env
|
31
|
+
# Required
|
32
|
+
Ensure that FEREAI_USER_ID and FEREAI_API_KEY are correctly set in the character secrets
|
33
|
+
sections or as environment variables.
|
34
|
+
|
35
|
+
FEREAI_USER_ID: FereAI User ID
|
36
|
+
FEREAI_API_KEY: FereAI API key
|
37
|
+
|
38
|
+
# Optional
|
39
|
+
FereAI pro take some time to respond. Set REQUEST_TIMEOUT to avoid response timeouts
|
40
|
+
in the character settings section or as environment variable.
|
41
|
+
|
42
|
+
REQUEST_TIMEOUT: Number of milliseconds before a request times out
|
43
|
+
|
44
|
+
```
|
45
|
+
|
46
|
+
## Usage
|
47
|
+
|
48
|
+
### Example Queries
|
49
|
+
|
50
|
+
1. Basic Market Query:
|
51
|
+
|
52
|
+
```typescript
|
53
|
+
// Get top cryptocurrencies
|
54
|
+
"What are the top 5 cryptocurrencies?";
|
55
|
+
```
|
56
|
+
|
57
|
+
2. Comparison Analysis:
|
58
|
+
|
59
|
+
```typescript
|
60
|
+
// Compare specific cryptocurrencies
|
61
|
+
"Compare Ethereum and Bitcoin for the past 6 months";
|
62
|
+
```
|
63
|
+
|
64
|
+
3. Historical Data:
|
65
|
+
|
66
|
+
```typescript
|
67
|
+
// Get historical performance
|
68
|
+
"Compare top 3 coins against Bitcoin in the last 3 months";
|
69
|
+
```
|
70
|
+
|
71
|
+
## Development
|
72
|
+
|
73
|
+
1. Clone the repository
|
74
|
+
2. Install dependencies:
|
75
|
+
|
76
|
+
```bash
|
77
|
+
bun install
|
78
|
+
```
|
79
|
+
|
80
|
+
3. Build the plugin:
|
81
|
+
|
82
|
+
```bash
|
83
|
+
bun run build
|
84
|
+
```
|
85
|
+
|
86
|
+
4. Run in development mode:
|
87
|
+
|
88
|
+
```bash
|
89
|
+
bun run dev
|
90
|
+
```
|
91
|
+
|
92
|
+
## API Reference
|
93
|
+
|
94
|
+
### Core Components
|
95
|
+
|
96
|
+
1. **FereProService**
|
97
|
+
|
98
|
+
- Manages WebSocket connections
|
99
|
+
- Handles message sending/receiving
|
100
|
+
- Processes streaming responses
|
101
|
+
- Tracks credits and usage
|
102
|
+
|
103
|
+
2. **Actions**
|
104
|
+
- EXECUTE_FEREPRO: Primary action for API communication
|
105
|
+
- Supports market queries and analysis requests
|
106
|
+
- Handles both streaming and non-streaming responses
|
107
|
+
|
108
|
+
### Response Structure
|
109
|
+
|
110
|
+
```typescript
|
111
|
+
export interface FereAIChatResponse {
|
112
|
+
answer: string;
|
113
|
+
chat_id: string;
|
114
|
+
representation: any[];
|
115
|
+
agent_api_name: string;
|
116
|
+
query_summary: string;
|
117
|
+
agent_credits: number;
|
118
|
+
credits_available: number;
|
119
|
+
}
|
120
|
+
```
|
121
|
+
|
122
|
+
## Error Handling
|
123
|
+
|
124
|
+
The plugin includes comprehensive error handling for:
|
125
|
+
|
126
|
+
- WebSocket connection issues
|
127
|
+
- Invalid message formats
|
128
|
+
- API response errors
|
129
|
+
- Credit limitation issues
|
130
|
+
|
131
|
+
## Common Issues & Troubleshooting
|
132
|
+
|
133
|
+
### Connection Issues
|
134
|
+
|
135
|
+
1. **WebSocket Connection Failures**
|
136
|
+
|
137
|
+
- Verify your internet connection
|
138
|
+
- Check if the FerePro API service is available
|
139
|
+
- Ensure your FERE_USER_ID and FERE_API_KEY is valid and active
|
140
|
+
|
141
|
+
2. **Message Timeout**
|
142
|
+
|
143
|
+
- The connection might time out for long-running queries
|
144
|
+
- Consider setting REQUEST_TIMEOUT to avoid response timeouts in the character settings section or as environment variable.
|
145
|
+
|
146
|
+
3. **Credit Depletion**
|
147
|
+
- Monitor credits_available in responses
|
148
|
+
- Set up alerts for low credit situations
|
149
|
+
- Contact FerePro support for credit top-up
|
150
|
+
|
151
|
+
### Response Parsing
|
152
|
+
|
153
|
+
1. **Invalid Response Format**
|
154
|
+
|
155
|
+
- Check if the query is properly formatted
|
156
|
+
- Verify the message structure matches the API requirements
|
157
|
+
- Enable debug mode for detailed error information
|
158
|
+
|
159
|
+
2. **Missing Data**
|
160
|
+
- Ensure the requested timeframe is valid
|
161
|
+
- Verify the cryptocurrencies exist in the database
|
162
|
+
- Check if you have access to the requested data tier
|
163
|
+
|
164
|
+
## Safety & Best Practices
|
165
|
+
|
166
|
+
### Security
|
167
|
+
|
168
|
+
1. **API Credentials**
|
169
|
+
|
170
|
+
- Never expose your FEREAI_USER_ID and FEREAI_API_KEY in public repositories
|
171
|
+
- Use environment variables or secrets sections in the character settings section for sensitive data
|
172
|
+
- Rotate credentials periodically if possible
|
173
|
+
|
174
|
+
2. **Rate Limiting**
|
175
|
+
- Implement appropriate delays between requests
|
176
|
+
- Monitor credit usage to prevent unexpected depletion
|
177
|
+
- Cache responses when appropriate
|
178
|
+
|
179
|
+
### Data Handling
|
180
|
+
|
181
|
+
1. **Response Validation**
|
182
|
+
|
183
|
+
- Always validate response data before processing
|
184
|
+
- Implement proper error handling for malformed data
|
185
|
+
- Log unexpected response formats for debugging
|
186
|
+
|
187
|
+
2. **Stream Management**
|
188
|
+
- Close WebSocket connections properly after use
|
189
|
+
- Implement reconnection logic for dropped connections
|
190
|
+
- Handle partial responses in streaming mode
|
191
|
+
|
192
|
+
### Best Practices
|
193
|
+
|
194
|
+
1. **Query Optimization**
|
195
|
+
|
196
|
+
- Keep queries focused and specific
|
197
|
+
- Use streaming for large data requests
|
198
|
+
- Implement caching for frequently requested data
|
199
|
+
|
200
|
+
2. **Error Handling**
|
201
|
+
|
202
|
+
- Implement comprehensive error catching
|
203
|
+
- Log errors with appropriate context
|
204
|
+
- Provide meaningful error messages to users
|
205
|
+
|
206
|
+
3. **Resource Management**
|
207
|
+
- Monitor WebSocket connection status
|
208
|
+
- Implement connection pooling for high-volume usage
|
209
|
+
- Clean up resources properly on service shutdown
|
210
|
+
|
211
|
+
## Contributing
|
212
|
+
|
213
|
+
Contributions are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information.
|
214
|
+
|
215
|
+
## Credits
|
216
|
+
|
217
|
+
Special thanks to:
|
218
|
+
|
219
|
+
- The Eliza community for their contributions and feedback
|
220
|
+
|
221
|
+
For more information about FerePro capabilities:
|
222
|
+
|
223
|
+
- [FereAI Website](https://www.fereai.xyz/)
|
224
|
+
- [FereAI Agents Documentation](https://docs.fereai.xyz/docs/product/ai-versions)
|
225
|
+
|
226
|
+
## License
|
227
|
+
|
228
|
+
This plugin is part of the Eliza project. See the main project repository for license information.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
@@ -0,0 +1,301 @@
|
|
1
|
+
import { Service, ServiceType, logger } from '@elizaos/core';
|
2
|
+
import WebSocket from 'ws';
|
3
|
+
import dayjs from 'dayjs';
|
4
|
+
|
5
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
6
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
7
|
+
}) : x)(function(x) {
|
8
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
9
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
10
|
+
});
|
11
|
+
var FereProAgentService = class _FereProAgentService extends Service {
|
12
|
+
apiKey;
|
13
|
+
userId;
|
14
|
+
baseUrl;
|
15
|
+
agentId;
|
16
|
+
settings;
|
17
|
+
static serviceType = ServiceType.WEB_SEARCH;
|
18
|
+
get serviceType() {
|
19
|
+
return _FereProAgentService.serviceType;
|
20
|
+
}
|
21
|
+
// Override the instance property for singleton pattern
|
22
|
+
static instance;
|
23
|
+
// Implement required static method from Service class
|
24
|
+
static getInstance() {
|
25
|
+
if (!this.instance) {
|
26
|
+
this.instance = new this();
|
27
|
+
}
|
28
|
+
return this.instance;
|
29
|
+
}
|
30
|
+
constructor(runtime) {
|
31
|
+
super(runtime);
|
32
|
+
}
|
33
|
+
// Implement required abstract properties
|
34
|
+
capabilityDescription = "Provides blockchain and cryptocurrency insights using FereAI API";
|
35
|
+
// Implement required abstract methods
|
36
|
+
async stop() {
|
37
|
+
console.log("FereProAgentService stopped");
|
38
|
+
}
|
39
|
+
// Implement required static methods
|
40
|
+
static async start(runtime) {
|
41
|
+
const service = new _FereProAgentService(runtime);
|
42
|
+
await service.initialize(runtime);
|
43
|
+
return service;
|
44
|
+
}
|
45
|
+
static async stop(_runtime) {
|
46
|
+
return Promise.resolve(true);
|
47
|
+
}
|
48
|
+
async initialize(runtime) {
|
49
|
+
this.apiKey = runtime.getSetting("FEREAI_API_KEY");
|
50
|
+
this.userId = runtime.getSetting("FEREAI_USER_ID");
|
51
|
+
this.baseUrl = "api.fereai.xyz";
|
52
|
+
this.agentId = "ProAgent";
|
53
|
+
this.settings = {
|
54
|
+
stream: true,
|
55
|
+
contextDuration: 1,
|
56
|
+
parentId: "0",
|
57
|
+
debug: false
|
58
|
+
};
|
59
|
+
if (!this.apiKey || !this.userId) {
|
60
|
+
throw new Error("FEREAI_API_KEY or FEREAI_USER_ID is required");
|
61
|
+
}
|
62
|
+
}
|
63
|
+
getWebSocketUrl(userPrompt) {
|
64
|
+
const apiKey = this.apiKey;
|
65
|
+
const userId = this.userId;
|
66
|
+
const baseUrl = this.baseUrl;
|
67
|
+
if (!apiKey || !userId || !baseUrl) {
|
68
|
+
throw new Error("Missing required API configuration");
|
69
|
+
}
|
70
|
+
switch (this.agentId) {
|
71
|
+
case "ProAgent":
|
72
|
+
return `wss://${baseUrl}/chat/v2/ws/${userId}?X-FRIDAY-KEY=${apiKey}`;
|
73
|
+
case "MarketAnalyzerAgent":
|
74
|
+
return `wss://${baseUrl}/ws/generate_summary/${userId}?X-FRIDAY-KEY=${apiKey}`;
|
75
|
+
default:
|
76
|
+
throw new Error(`Unsupported agent: ${this.agentId}`);
|
77
|
+
}
|
78
|
+
}
|
79
|
+
createPayload(message) {
|
80
|
+
const userTime = this.getUserTime();
|
81
|
+
return {
|
82
|
+
agent: this.agentId,
|
83
|
+
stream: this.settings.stream ?? true,
|
84
|
+
user_time: userTime.format(),
|
85
|
+
x_hours: this.settings.contextDuration ?? 1,
|
86
|
+
parent: this.settings.parentId === "0" ? 0 : this.settings.parentId ?? 0,
|
87
|
+
message
|
88
|
+
};
|
89
|
+
}
|
90
|
+
getUserTime() {
|
91
|
+
const utc = __require("dayjs/plugin/utc");
|
92
|
+
const timezone = __require("dayjs/plugin/timezone");
|
93
|
+
dayjs.extend(utc);
|
94
|
+
dayjs.extend(timezone);
|
95
|
+
const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
96
|
+
const currentTimestamp = Date.now();
|
97
|
+
return dayjs(currentTimestamp).tz(userTimezone);
|
98
|
+
}
|
99
|
+
isValidResponse(value) {
|
100
|
+
return typeof value === "object" && value !== null && "answer" in value && typeof value.answer === "string";
|
101
|
+
}
|
102
|
+
async getFereproResponse(userPrompt) {
|
103
|
+
return new Promise((resolve, reject) => {
|
104
|
+
const wsUrl = this.getWebSocketUrl(userPrompt);
|
105
|
+
const websocket = new WebSocket(wsUrl);
|
106
|
+
let responseData;
|
107
|
+
websocket.on("open", () => {
|
108
|
+
logger.debug("WebSocket connection opened [Prompt]:", userPrompt);
|
109
|
+
const payload = this.createPayload(userPrompt);
|
110
|
+
logger.debug("Sending payload:", JSON.stringify(payload, null, 2));
|
111
|
+
websocket.send(JSON.stringify(payload));
|
112
|
+
});
|
113
|
+
websocket.on("message", (data) => {
|
114
|
+
try {
|
115
|
+
const message = data.toString();
|
116
|
+
if (message.trim().startsWith("{")) {
|
117
|
+
const response = JSON.parse(message);
|
118
|
+
if (this.isValidResponse(response)) {
|
119
|
+
responseData = response;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
logger.debug("Received message:", message, "\n");
|
123
|
+
} catch (error) {
|
124
|
+
reject(error);
|
125
|
+
websocket.close();
|
126
|
+
}
|
127
|
+
});
|
128
|
+
websocket.on("error", (error) => {
|
129
|
+
reject(error);
|
130
|
+
websocket.close();
|
131
|
+
});
|
132
|
+
websocket.on("close", () => {
|
133
|
+
if (responseData) {
|
134
|
+
logger.debug("Received response:", responseData, "\n");
|
135
|
+
let result = null;
|
136
|
+
const responseDataChat = responseData;
|
137
|
+
logger.debug("Received response chat:", responseDataChat, "\n");
|
138
|
+
result = responseDataChat;
|
139
|
+
logger.debug("Returning result:", result, "\n");
|
140
|
+
resolve(result);
|
141
|
+
} else {
|
142
|
+
reject(new Error("WebSocket closed without receiving valid response"));
|
143
|
+
}
|
144
|
+
});
|
145
|
+
});
|
146
|
+
}
|
147
|
+
};
|
148
|
+
var executeFerePro = {
|
149
|
+
name: "EXECUTE_FEREPRO",
|
150
|
+
similes: [
|
151
|
+
"BLOCKCHAIN_INFO",
|
152
|
+
"CRYPTO_INFO",
|
153
|
+
"DEFI_DETAILS",
|
154
|
+
"NFT_DETAILS",
|
155
|
+
"WEB3_INSIGHTS",
|
156
|
+
"BLOCKCHAIN_RESEARCH",
|
157
|
+
"CRYPTO_RESEARCH",
|
158
|
+
"FIND_BLOCKCHAIN_INFO",
|
159
|
+
"GET_CRYPTO_DATA"
|
160
|
+
],
|
161
|
+
description: "Answer questions related to blockchain technology, cryptocurrencies, DeFi, NFTs, and Web3.",
|
162
|
+
validate: async (runtime, _message) => {
|
163
|
+
const apiKey = runtime.getSetting("FEREAI_API_KEY");
|
164
|
+
const userId = runtime.getSetting("FEREAI_USER_ID");
|
165
|
+
if (!apiKey || !userId) {
|
166
|
+
logger.error("FEREAI_API_KEY or FEREAI_USER_ID is required");
|
167
|
+
return false;
|
168
|
+
}
|
169
|
+
return true;
|
170
|
+
},
|
171
|
+
handler: async (runtime, message, state, options, callback) => {
|
172
|
+
logger.log("Fere Pro prompt received:", message.content.text);
|
173
|
+
try {
|
174
|
+
const fereproService = new FereProAgentService();
|
175
|
+
await fereproService.initialize(runtime);
|
176
|
+
if (!state) {
|
177
|
+
state = await runtime.composeState(message);
|
178
|
+
} else {
|
179
|
+
state = await runtime.composeState(message);
|
180
|
+
}
|
181
|
+
const response = await fereproService.getFereproResponse(message.content.text || "");
|
182
|
+
if (response.answer && response.answer !== "") {
|
183
|
+
if (callback) {
|
184
|
+
callback({
|
185
|
+
text: response.answer,
|
186
|
+
content: { ...response }
|
187
|
+
});
|
188
|
+
}
|
189
|
+
return true;
|
190
|
+
} else {
|
191
|
+
logger.error("Invalid FerePro response:", response);
|
192
|
+
if (callback) {
|
193
|
+
callback({
|
194
|
+
text: "Unable to process ferePro request. Please try again later.",
|
195
|
+
content: { error: "Invalid FerePro response" }
|
196
|
+
});
|
197
|
+
}
|
198
|
+
return false;
|
199
|
+
}
|
200
|
+
} catch (error) {
|
201
|
+
console.error("Invalid FerePro response:", error);
|
202
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
203
|
+
if (callback) {
|
204
|
+
callback({
|
205
|
+
text: `Error processing message: ${errorMessage}`,
|
206
|
+
content: { error: errorMessage }
|
207
|
+
});
|
208
|
+
}
|
209
|
+
return false;
|
210
|
+
}
|
211
|
+
},
|
212
|
+
examples: [
|
213
|
+
[
|
214
|
+
{
|
215
|
+
name: "{{user1}}",
|
216
|
+
content: {
|
217
|
+
text: "Tell me Solana memecoins which are greater than $100 million marketcap"
|
218
|
+
}
|
219
|
+
}
|
220
|
+
],
|
221
|
+
[
|
222
|
+
{
|
223
|
+
name: "{{user1}}",
|
224
|
+
content: {
|
225
|
+
text: "Tell me Base memecoins which are greater than $100 million marketcap"
|
226
|
+
}
|
227
|
+
}
|
228
|
+
],
|
229
|
+
[
|
230
|
+
{
|
231
|
+
name: "{{user1}}",
|
232
|
+
content: {
|
233
|
+
text: "Please tell me which ones would be a good buy in the current environment"
|
234
|
+
}
|
235
|
+
}
|
236
|
+
],
|
237
|
+
[
|
238
|
+
{
|
239
|
+
name: "{{user1}}",
|
240
|
+
content: {
|
241
|
+
text: "Compare the performance and social sentiment of the top 5 memecoins on Solana vs. Base. Highlight any significant differences and potential reasons"
|
242
|
+
}
|
243
|
+
}
|
244
|
+
],
|
245
|
+
[
|
246
|
+
{
|
247
|
+
name: "{{user1}}",
|
248
|
+
content: {
|
249
|
+
text: "Analyze the risk-adjusted returns of the top 10 trending tokens. Provide insights on which tokens offer the best risk-to-reward ratio"
|
250
|
+
}
|
251
|
+
}
|
252
|
+
],
|
253
|
+
[
|
254
|
+
{
|
255
|
+
name: "{{user1}}",
|
256
|
+
content: {
|
257
|
+
text: "Using historical data and current trends, predict the potential performance of the top 5 AI tokens over the next week. Provide the rationale behind each prediction"
|
258
|
+
}
|
259
|
+
}
|
260
|
+
],
|
261
|
+
[
|
262
|
+
{
|
263
|
+
name: "{{user1}}",
|
264
|
+
content: {
|
265
|
+
text: "Top KOLs for DEGEN on Base"
|
266
|
+
}
|
267
|
+
}
|
268
|
+
],
|
269
|
+
[
|
270
|
+
{
|
271
|
+
name: "{{user1}}",
|
272
|
+
content: {
|
273
|
+
text: "Give me a detailed analysis of $degen token"
|
274
|
+
}
|
275
|
+
}
|
276
|
+
],
|
277
|
+
[
|
278
|
+
{
|
279
|
+
name: "{{user1}}",
|
280
|
+
content: {
|
281
|
+
text: "Give me a summary of the latest crypto news today"
|
282
|
+
}
|
283
|
+
}
|
284
|
+
]
|
285
|
+
]
|
286
|
+
};
|
287
|
+
|
288
|
+
// src/index.ts
|
289
|
+
var fereProPlugin = {
|
290
|
+
name: "Fere Pro",
|
291
|
+
description: "Answer questions about blockchain, cryptocurrencies, and related topics using a dedicated API.",
|
292
|
+
actions: [executeFerePro],
|
293
|
+
evaluators: [],
|
294
|
+
providers: [],
|
295
|
+
services: [FereProAgentService]
|
296
|
+
};
|
297
|
+
var index_default = fereProPlugin;
|
298
|
+
|
299
|
+
export { index_default as default, fereProPlugin };
|
300
|
+
//# sourceMappingURL=index.js.map
|
301
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/services/ferepro.service.ts","../src/actions/ferePro.ts","../src/index.ts"],"names":["logger"],"mappings":";;;;;;;;;;AAeO,IAAM,mBAAA,GAAN,MAAM,oBAAA,SAA4B,OAAA,CAAmC;AAAA,EACxE,MAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,OAAA;AAAA,EACA,QAAA;AAAA,EAOA,OAAO,cAA+B,WAAA,CAAY,UAAA;AAAA,EAElD,IAAI,WAAA,GAA+B;AAC/B,IAAA,OAAO,oBAAA,CAAoB,WAAA;AAAA;AAC/B;AAAA,EAGA,OAAe,QAAA;AAAA;AAAA,EAGf,OAAO,WAAA,GAAoC;AACvC,IAAA,IAAI,CAAC,KAAK,QAAA,EAAU;AAChB,MAAA,IAAA,CAAK,QAAA,GAAW,IAAI,IAAA,EAAK;AAAA;AAE7B,IAAA,OAAO,IAAA,CAAK,QAAA;AAAA;AAChB,EAEA,YAAY,OAAA,EAAyB;AACjC,IAAA,KAAA,CAAM,OAAO,CAAA;AAAA;AACjB;AAAA,EAGA,qBAAA,GAAwB,kEAAA;AAAA;AAAA,EAGxB,MAAM,IAAA,GAAsB;AAExB,IAAA,OAAA,CAAQ,IAAI,6BAA6B,CAAA;AAAA;AAC7C;AAAA,EAGA,aAAa,MAAM,OAAA,EAA0C;AACzD,IAAA,MAAM,OAAA,GAAU,IAAI,oBAAA,CAAoB,OAAO,CAAA;AAC/C,IAAA,MAAM,OAAA,CAAQ,WAAW,OAAO,CAAA;AAChC,IAAA,OAAO,OAAA;AAAA;AACX,EAEA,aAAa,KAAK,QA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ACJ;AAAA,IACA;AAAA,MACI;AAAA,QACI,IAAA,EAAM,WAAA;AAAA,QACN,OAAA,EAAS;AAAA,UACL,IAAA,EAAM;AAAA;AACV;AACJ;AACJ;AAER,CAAA;;;AC/JO,IAAM,aAAA,GAAwB;AAAA,EACjC,IAAA,EAAM,UAAA;AAAA,EACN,WAAA,EACI,gGAAA;AAAA,EACJ,OAAA,EAAS,CAAC,cAAc,CAAA;AAAA,EACxB,YAAY,EAAC;AAAA,EACb,WAAW,EAAC;AAAA,EACZ,QAAA,EAAU,CAAC,mBAAmB;AAClC;AAEA,IAAO,aAAA,GAAQ","file":"index.js","sourcesContent":["import {\n logger,\n Service,\n IAgentRuntime,\n ServiceType,\n ServiceTypeName,\n Memory,\n stringToUuid,\n} from '@elizaos/core';\n\nimport WebSocket from 'ws';\nimport dayjs from 'dayjs';\n\nimport { FereAIChatResponse, IFereProService, FereAIAgentId } from '../types/ferepro-types';\n\nexport class FereProAgentService extends Service implements IFereProService {\n apiKey!: string;\n userId!: string;\n baseUrl!: string;\n agentId!: FereAIAgentId;\n settings!: {\n stream: boolean;\n contextDuration: number;\n parentId: string;\n debug: boolean;\n };\n\n static serviceType: ServiceTypeName = ServiceType.WEB_SEARCH;\n\n get serviceType(): ServiceTypeName {\n return FereProAgentService.serviceType;\n }\n\n // Override the instance property for singleton pattern\n private static instance: FereProAgentService;\n\n // Implement required static method from Service class\n static getInstance<T extends Service>(): T {\n if (!this.instance) {\n this.instance = new this() as FereProAgentService;\n }\n return this.instance as unknown as T;\n }\n\n constructor(runtime?: IAgentRuntime) {\n super(runtime);\n }\n\n // Implement required abstract properties\n capabilityDescription = 'Provides blockchain and cryptocurrency insights using FereAI API';\n\n // Implement required abstract methods\n async stop(): Promise<void> {\n // Clean up any resources if needed\n console.log('FereProAgentService stopped');\n }\n\n // Implement required static methods\n static async start(runtime: IAgentRuntime): Promise<Service> {\n const service = new FereProAgentService(runtime);\n await service.initialize(runtime);\n return service;\n }\n\n static async stop(_runtime: IAgentRuntime): Promise<unknown> {\n // Clean up static resources if needed\n return Promise.resolve(true);\n }\n\n async initialize(runtime: IAgentRuntime): Promise<void> {\n this.apiKey = runtime.getSetting('FEREAI_API_KEY');\n this.userId = runtime.getSetting('FEREAI_USER_ID');\n this.baseUrl = 'api.fereai.xyz';\n this.agentId = 'ProAgent';\n this.settings = {\n stream: true,\n contextDuration: 1,\n parentId: '0',\n debug: false,\n };\n\n if (!this.apiKey || !this.userId) {\n throw new Error('FEREAI_API_KEY or FEREAI_USER_ID is required');\n }\n }\n\n private getWebSocketUrl(userPrompt: string): string {\n const apiKey = this.apiKey;\n const userId = this.userId;\n const baseUrl = this.baseUrl;\n\n if (!apiKey || !userId || !baseUrl) {\n throw new Error('Missing required API configuration');\n }\n\n switch (this.agentId) {\n case 'ProAgent':\n return `wss://${baseUrl}/chat/v2/ws/${userId}?X-FRIDAY-KEY=${apiKey}`;\n case 'MarketAnalyzerAgent':\n return `wss://${baseUrl}/ws/generate_summary/${userId}?X-FRIDAY-KEY=${apiKey}`;\n default:\n throw new Error(`Unsupported agent: ${this.agentId}`);\n }\n }\n\n private createPayload(message: string) {\n const userTime = this.getUserTime();\n\n return {\n agent: this.agentId,\n stream: this.settings.stream ?? true,\n user_time: userTime.format(),\n x_hours: this.settings.contextDuration ?? 1,\n parent: this.settings.parentId === '0' ? 0 : (this.settings.parentId ?? 0),\n message,\n };\n }\n\n private getUserTime() {\n // Load plugins dynamically to avoid import issues in tests\n const utc = require('dayjs/plugin/utc');\n const timezone = require('dayjs/plugin/timezone');\n dayjs.extend(utc);\n dayjs.extend(timezone);\n const userTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n const currentTimestamp = Date.now();\n return dayjs(currentTimestamp).tz(userTimezone);\n }\n\n private isValidResponse(value: unknown): value is FereAIChatResponse {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'answer' in value &&\n typeof (value as any).answer === 'string'\n );\n }\n\n async getFereproResponse(userPrompt: string): Promise<FereAIChatResponse> {\n return new Promise((resolve, reject) => {\n const wsUrl = this.getWebSocketUrl(userPrompt);\n const websocket = new WebSocket(wsUrl);\n let responseData: FereAIChatResponse | null;\n\n websocket.on('open', () => {\n logger.debug('WebSocket connection opened [Prompt]:', userPrompt);\n\n const payload = this.createPayload(userPrompt);\n logger.debug('Sending payload:', JSON.stringify(payload, null, 2));\n\n websocket.send(JSON.stringify(payload));\n });\n\n websocket.on('message', (data: WebSocket.Data) => {\n try {\n const message = data.toString();\n if (message.trim().startsWith('{')) {\n const response = JSON.parse(message);\n if (this.isValidResponse(response)) {\n responseData = response as FereAIChatResponse;\n }\n }\n\n logger.debug('Received message:', message, '\\n');\n } catch (error) {\n reject(error);\n websocket.close();\n }\n });\n\n websocket.on('error', (error: Error) => {\n reject(error);\n websocket.close();\n });\n\n websocket.on('close', () => {\n if (responseData) {\n logger.debug('Received response:', responseData, '\\n');\n let result: any = null;\n\n const responseDataChat = responseData as FereAIChatResponse;\n logger.debug('Received response chat:', responseDataChat, '\\n');\n\n result = responseDataChat;\n\n logger.debug('Returning result:', result, '\\n');\n\n // Return the response\n resolve(result);\n } else {\n reject(new Error('WebSocket closed without receiving valid response'));\n }\n });\n });\n }\n}\n","import {\n logger,\n ActionExample,\n Memory,\n IAgentRuntime,\n State,\n type Action,\n HandlerCallback,\n} from '@elizaos/core';\nimport { FereProAgentService } from '../services/ferepro.service';\n\nexport const executeFerePro: Action = {\n name: 'EXECUTE_FEREPRO',\n similes: [\n 'BLOCKCHAIN_INFO',\n 'CRYPTO_INFO',\n 'DEFI_DETAILS',\n 'NFT_DETAILS',\n 'WEB3_INSIGHTS',\n 'BLOCKCHAIN_RESEARCH',\n 'CRYPTO_RESEARCH',\n 'FIND_BLOCKCHAIN_INFO',\n 'GET_CRYPTO_DATA',\n ],\n description:\n 'Answer questions related to blockchain technology, cryptocurrencies, DeFi, NFTs, and Web3.',\n validate: async (runtime: IAgentRuntime, _message: Memory) => {\n const apiKey = runtime.getSetting('FEREAI_API_KEY');\n const userId = runtime.getSetting('FEREAI_USER_ID');\n if (!apiKey || !userId) {\n logger.error('FEREAI_API_KEY or FEREAI_USER_ID is required');\n return false;\n }\n return true;\n },\n handler: async (\n runtime: IAgentRuntime,\n message: Memory,\n state?: State,\n options?: { [key: string]: unknown },\n callback?: HandlerCallback\n ) => {\n logger.log('Fere Pro prompt received:', message.content.text);\n\n try {\n // Initialize the FerePro service\n const fereproService = new FereProAgentService();\n await fereproService.initialize(runtime);\n\n // Ensure state exists or generate a new one\n if (!state) {\n state = (await runtime.composeState(message)) as State;\n } else {\n // Update existing state with new message context\n state = await runtime.composeState(message);\n }\n\n const response = await fereproService.getFereproResponse(message.content.text || '');\n\n if (response.answer && response.answer !== '') {\n if (callback) {\n callback({\n text: response.answer,\n content: { ...response },\n });\n }\n return true;\n } else {\n logger.error('Invalid FerePro response:', response);\n if (callback) {\n callback({\n text: 'Unable to process ferePro request. Please try again later.',\n content: { error: 'Invalid FerePro response' },\n });\n }\n return false;\n }\n } catch (error) {\n console.error('Invalid FerePro response:', error);\n const errorMessage = error instanceof Error ? error.message : 'Unknown error';\n if (callback) {\n callback({\n text: `Error processing message: ${errorMessage}`,\n content: { error: errorMessage },\n });\n }\n return false;\n }\n },\n examples: [\n [\n {\n name: '{{user1}}',\n content: {\n text: 'Tell me Solana memecoins which are greater than $100 million marketcap',\n },\n },\n ],\n [\n {\n name: '{{user1}}',\n content: {\n text: 'Tell me Base memecoins which are greater than $100 million marketcap',\n },\n },\n ],\n [\n {\n name: '{{user1}}',\n content: {\n text: 'Please tell me which ones would be a good buy in the current environment',\n },\n },\n ],\n [\n {\n name: '{{user1}}',\n content: {\n text: 'Compare the performance and social sentiment of the top 5 memecoins on Solana vs. Base. Highlight any significant differences and potential reasons',\n },\n },\n ],\n [\n {\n name: '{{user1}}',\n content: {\n text: 'Analyze the risk-adjusted returns of the top 10 trending tokens. Provide insights on which tokens offer the best risk-to-reward ratio',\n },\n },\n ],\n [\n {\n name: '{{user1}}',\n content: {\n text: 'Using historical data and current trends, predict the potential performance of the top 5 AI tokens over the next week. Provide the rationale behind each prediction',\n },\n },\n ],\n [\n {\n name: '{{user1}}',\n content: {\n text: 'Top KOLs for DEGEN on Base',\n },\n },\n ],\n [\n {\n name: '{{user1}}',\n content: {\n text: 'Give me a detailed analysis of $degen token',\n },\n },\n ],\n [\n {\n name: '{{user1}}',\n content: {\n text: 'Give me a summary of the latest crypto news today',\n },\n },\n ],\n ],\n};\n","import { Plugin } from '@elizaos/core';\nimport { FereProAgentService } from './services/ferepro.service';\nimport { executeFerePro } from './actions/ferePro';\n\nexport const fereProPlugin: Plugin = {\n name: 'Fere Pro',\n description:\n 'Answer questions about blockchain, cryptocurrencies, and related topics using a dedicated API.',\n actions: [executeFerePro],\n evaluators: [],\n providers: [],\n services: [FereProAgentService],\n};\n\nexport default fereProPlugin;\n"]}
|
package/package.json
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
{
|
2
|
+
"name": "@elizaos/plugin-ferepro",
|
3
|
+
"version": "1.0.5",
|
4
|
+
"description": "FerePro plugin for ElizaOS - Enables FereAI API integration and interactions",
|
5
|
+
"type": "module",
|
6
|
+
"author": "elizaOS Contributors",
|
7
|
+
"license": "MIT",
|
8
|
+
"repository": {
|
9
|
+
"type": "git",
|
10
|
+
"url": "https://github.com/elizaos/elizaos-plugins"
|
11
|
+
},
|
12
|
+
"keywords": [
|
13
|
+
"elizaos",
|
14
|
+
"plugin",
|
15
|
+
"fereai",
|
16
|
+
"api"
|
17
|
+
],
|
18
|
+
"main": "dist/index.js",
|
19
|
+
"module": "dist/index.js",
|
20
|
+
"types": "dist/index.d.ts",
|
21
|
+
"exports": {
|
22
|
+
"./package.json": "./package.json",
|
23
|
+
".": {
|
24
|
+
"import": {
|
25
|
+
"@elizaos/source": "./src/index.ts",
|
26
|
+
"types": "./dist/index.d.ts",
|
27
|
+
"default": "./dist/index.js"
|
28
|
+
}
|
29
|
+
}
|
30
|
+
},
|
31
|
+
"files": [
|
32
|
+
"dist"
|
33
|
+
],
|
34
|
+
"dependencies": {
|
35
|
+
"@elizaos/core": "^1.0.0",
|
36
|
+
"dayjs": "^1.11.13",
|
37
|
+
"ws": "^8.14.2"
|
38
|
+
},
|
39
|
+
"devDependencies": {
|
40
|
+
"@biomejs/biome": "1.5.3",
|
41
|
+
"@types/bun": "^1.2.18",
|
42
|
+
"@types/ws": "^8.5.10",
|
43
|
+
"prettier": "^3.6.2",
|
44
|
+
"tsup": "^8.3.5",
|
45
|
+
"typescript": "^5.3.0"
|
46
|
+
},
|
47
|
+
"peerDependencies": {
|
48
|
+
"@elizaos/core": "^1.0.0",
|
49
|
+
"whatwg-url": "7.1.0"
|
50
|
+
},
|
51
|
+
"scripts": {
|
52
|
+
"build": "bun run clean && bun run build:esm",
|
53
|
+
"build:esm": "tsup --format esm --dts",
|
54
|
+
"clean": "rm -rf dist",
|
55
|
+
"dev": "bun run build:esm --watch",
|
56
|
+
"test": "bun test",
|
57
|
+
"test:coverage": "bun test --coverage",
|
58
|
+
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md}\"",
|
59
|
+
"format:check": "prettier --check \"src/**/*.{ts,tsx,js,jsx,json,md}\""
|
60
|
+
},
|
61
|
+
"publishConfig": {
|
62
|
+
"access": "public"
|
63
|
+
},
|
64
|
+
"agentConfig": {
|
65
|
+
"pluginType": "elizaos:plugin:1.0.0",
|
66
|
+
"pluginParameters": {
|
67
|
+
"REQUEST_TIMEOUT": {
|
68
|
+
"type": "number",
|
69
|
+
"minLength": 90000,
|
70
|
+
"description": "Request timeout is required",
|
71
|
+
"optional": true
|
72
|
+
},
|
73
|
+
"FEREAI_USER_ID": {
|
74
|
+
"type": "string",
|
75
|
+
"minLength": 1,
|
76
|
+
"description": "FereAI user id is required"
|
77
|
+
},
|
78
|
+
"FEREAI_API_KEY": {
|
79
|
+
"type": "string",
|
80
|
+
"minLength": 1,
|
81
|
+
"description": "FereAI API key is required"
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|