@elizaos/plugin-dummy-services 1.4.2 → 1.4.3-alpha.1
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/dist/browser/service.d.ts +60 -0
- package/dist/browser/service.d.ts.map +1 -0
- package/dist/e2e/scenarios.d.ts +3 -0
- package/dist/e2e/scenarios.d.ts.map +1 -0
- package/dist/e2e/test-utils.d.ts +29 -0
- package/dist/e2e/test-utils.d.ts.map +1 -0
- package/dist/email/service.d.ts +94 -0
- package/dist/email/service.d.ts.map +1 -0
- package/dist/index.d.ts +14 -205
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +829 -1344
- package/dist/index.js.map +20 -1
- package/dist/lp/service.d.ts +75 -0
- package/dist/lp/service.d.ts.map +1 -0
- package/dist/pdf/service.d.ts +44 -0
- package/dist/pdf/service.d.ts.map +1 -0
- package/dist/tokenData/service.d.ts +46 -0
- package/dist/tokenData/service.d.ts.map +1 -0
- package/dist/transcription/service.d.ts +58 -0
- package/dist/transcription/service.d.ts.map +1 -0
- package/dist/video/service.d.ts +51 -0
- package/dist/video/service.d.ts.map +1 -0
- package/dist/wallet/service.d.ts +33 -0
- package/dist/wallet/service.d.ts.map +1 -0
- package/dist/web-search/service.d.ts +61 -0
- package/dist/web-search/service.d.ts.map +1 -0
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -1,578 +1,607 @@
|
|
|
1
1
|
// src/tokenData/service.ts
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { Service, logger } from "@elizaos/core";
|
|
3
|
+
|
|
4
|
+
class DummyTokenDataService extends Service {
|
|
5
|
+
static serviceType = "token_data";
|
|
6
|
+
capabilityDescription = "Dummy token data service for testing";
|
|
7
|
+
get serviceName() {
|
|
8
|
+
return "dummy-token-data";
|
|
9
|
+
}
|
|
7
10
|
constructor(runtime) {
|
|
8
11
|
super(runtime);
|
|
9
|
-
logger.info("DummyTokenDataService initialized");
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
13
|
+
static async start(runtime) {
|
|
14
|
+
const service = new DummyTokenDataService(runtime);
|
|
15
|
+
await service.start();
|
|
16
|
+
return service;
|
|
17
|
+
}
|
|
18
|
+
async start() {
|
|
19
|
+
logger.info(`[${this.serviceName}] Service started.`);
|
|
20
|
+
}
|
|
21
|
+
async stop() {
|
|
22
|
+
logger.info(`[${this.serviceName}] Service stopped.`);
|
|
23
|
+
}
|
|
24
|
+
async getTokenData(tokenAddress) {
|
|
25
|
+
return {
|
|
26
|
+
symbol: "DUMMY",
|
|
27
|
+
name: "Dummy Token",
|
|
28
|
+
address: tokenAddress,
|
|
29
|
+
decimals: 18,
|
|
30
|
+
totalSupply: "1000000000",
|
|
31
|
+
priceUsd: 1.23,
|
|
32
|
+
marketCapUsd: 1230000000,
|
|
33
|
+
volume24hUsd: 45600000,
|
|
34
|
+
priceChange24h: 5.67
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async getTokenDataBySymbol(symbol) {
|
|
38
|
+
return {
|
|
39
|
+
symbol: symbol.toUpperCase(),
|
|
40
|
+
name: `${symbol} Token`,
|
|
41
|
+
address: "0xdummy",
|
|
42
|
+
decimals: 18,
|
|
43
|
+
totalSupply: "1000000000",
|
|
44
|
+
priceUsd: 1.23,
|
|
45
|
+
marketCapUsd: 1230000000,
|
|
46
|
+
volume24hUsd: 45600000,
|
|
47
|
+
priceChange24h: 5.67
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async getMultipleTokenData(tokenAddresses) {
|
|
51
|
+
return tokenAddresses.map((address, index) => ({
|
|
52
|
+
symbol: `TOKEN${index}`,
|
|
53
|
+
name: `Token ${index}`,
|
|
54
|
+
address,
|
|
55
|
+
decimals: 18,
|
|
56
|
+
totalSupply: "1000000000",
|
|
57
|
+
priceUsd: 1.23 * (index + 1),
|
|
58
|
+
marketCapUsd: 1230000000 * (index + 1),
|
|
59
|
+
volume24hUsd: 45600000 * (index + 1),
|
|
60
|
+
priceChange24h: 5.67 * (index % 2 === 0 ? 1 : -1)
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
async getTokenDetails(address, chain = "solana") {
|
|
64
|
+
const symbol = address.startsWith("So") ? address.substring(2, 6) : address.substring(0, 4).toUpperCase();
|
|
14
65
|
return {
|
|
15
|
-
id: `${chain}:${
|
|
66
|
+
id: `${chain}:${address}`,
|
|
16
67
|
symbol,
|
|
17
68
|
name: `Dummy Token ${symbol}`,
|
|
18
|
-
address
|
|
69
|
+
address,
|
|
19
70
|
chain,
|
|
20
|
-
sourceProvider: "dummy",
|
|
21
|
-
price: Math.random() * 100,
|
|
22
|
-
priceChange24hPercent: (Math.random() - 0.5) * 20,
|
|
23
|
-
volume24hUSD: Math.random() * 1e6,
|
|
24
|
-
marketCapUSD: Math.random() * 1e8,
|
|
25
|
-
liquidity: Math.random() * 5e5,
|
|
26
|
-
holders: Math.floor(Math.random() * 1e4),
|
|
27
|
-
logoURI: "https://via.placeholder.com/150",
|
|
28
71
|
decimals: 18,
|
|
29
|
-
|
|
72
|
+
totalSupply: "1000000000",
|
|
73
|
+
price: 1.23 + Math.random() * 10,
|
|
74
|
+
priceUsd: 1.23 + Math.random() * 10,
|
|
75
|
+
marketCapUsd: 1230000000 + Math.random() * 1e9,
|
|
76
|
+
marketCapUSD: 1230000000 + Math.random() * 1e9,
|
|
77
|
+
volume24hUsd: 45600000 + Math.random() * 50000000,
|
|
78
|
+
volume24hUSD: 45600000 + Math.random() * 50000000,
|
|
79
|
+
priceChange24h: -10 + Math.random() * 20,
|
|
80
|
+
priceChange24hPercent: -10 + Math.random() * 20,
|
|
81
|
+
logoURI: "https://via.placeholder.com/150",
|
|
82
|
+
liquidity: 5000000 + Math.random() * 5000000,
|
|
83
|
+
holders: Math.floor(1000 + Math.random() * 9000),
|
|
84
|
+
sourceProvider: "dummy",
|
|
85
|
+
lastUpdatedAt: new Date,
|
|
30
86
|
raw: {
|
|
31
87
|
dummyData: true
|
|
32
88
|
}
|
|
33
89
|
};
|
|
34
90
|
}
|
|
35
|
-
async
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
91
|
+
async getTrendingTokens(chain = "solana", limit = 10) {
|
|
92
|
+
const tokens = [];
|
|
93
|
+
for (let i = 0;i < limit; i++) {
|
|
94
|
+
const symbol = `TREND${i + 1}`;
|
|
95
|
+
tokens.push({
|
|
96
|
+
id: `${chain}:0xtrending${i}`,
|
|
97
|
+
symbol,
|
|
98
|
+
name: `Trending Token ${i + 1}`,
|
|
99
|
+
address: `0xtrending${i}`,
|
|
100
|
+
chain,
|
|
101
|
+
decimals: 18,
|
|
102
|
+
totalSupply: "1000000000",
|
|
103
|
+
price: Math.random() * 100,
|
|
104
|
+
priceUsd: Math.random() * 100,
|
|
105
|
+
marketCapUsd: 1e6 + Math.random() * 1e9,
|
|
106
|
+
marketCapUSD: 1e6 + Math.random() * 1e9,
|
|
107
|
+
volume24hUsd: 1e5 + Math.random() * 1e7,
|
|
108
|
+
volume24hUSD: 1e5 + Math.random() * 1e7,
|
|
109
|
+
priceChange24h: -50 + Math.random() * 100,
|
|
110
|
+
priceChange24hPercent: -10 + Math.random() * 20,
|
|
111
|
+
logoURI: "https://via.placeholder.com/150",
|
|
112
|
+
liquidity: 1e6 + Math.random() * 9000000,
|
|
113
|
+
holders: Math.floor(500 + Math.random() * 9500),
|
|
114
|
+
sourceProvider: "dummy",
|
|
115
|
+
lastUpdatedAt: new Date,
|
|
116
|
+
raw: {
|
|
117
|
+
dummyData: true
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return tokens;
|
|
42
122
|
}
|
|
43
123
|
async searchTokens(query, chain = "solana", limit = 5) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
124
|
+
const upperQuery = query.toUpperCase();
|
|
125
|
+
const tokens = [];
|
|
126
|
+
for (let i = 0;i < limit; i++) {
|
|
127
|
+
const symbol = upperQuery;
|
|
128
|
+
tokens.push({
|
|
129
|
+
id: `${chain}:0xsearch${i}`,
|
|
130
|
+
symbol,
|
|
131
|
+
name: `Dummy Token ${upperQuery}`,
|
|
132
|
+
address: `0xsearch${i}`,
|
|
133
|
+
chain,
|
|
134
|
+
decimals: 18,
|
|
135
|
+
totalSupply: "1000000000",
|
|
136
|
+
price: 1.23 * (i + 1),
|
|
137
|
+
priceUsd: 1.23 * (i + 1),
|
|
138
|
+
marketCapUsd: 1230000000 * (i + 1),
|
|
139
|
+
marketCapUSD: 1230000000 * (i + 1),
|
|
140
|
+
volume24hUsd: 45600000 * (i + 1),
|
|
141
|
+
volume24hUSD: 45600000 * (i + 1),
|
|
142
|
+
priceChange24h: 5.67 * (i % 2 === 0 ? 1 : -1),
|
|
143
|
+
priceChange24hPercent: 5.67 * (i % 2 === 0 ? 1 : -1),
|
|
144
|
+
logoURI: "https://via.placeholder.com/150",
|
|
145
|
+
liquidity: 1e6 + Math.random() * 9000000,
|
|
146
|
+
holders: Math.floor(500 + Math.random() * 9500),
|
|
147
|
+
sourceProvider: "dummy",
|
|
148
|
+
lastUpdatedAt: new Date,
|
|
149
|
+
raw: {
|
|
150
|
+
dummyData: true
|
|
151
|
+
}
|
|
152
|
+
});
|
|
59
153
|
}
|
|
154
|
+
return tokens;
|
|
60
155
|
}
|
|
61
|
-
async
|
|
62
|
-
|
|
156
|
+
async getTokensByAddresses(addresses, chain = "solana") {
|
|
157
|
+
return addresses.map((address, index) => {
|
|
158
|
+
const symbol = address.length > 6 ? address.substring(2, 6).toUpperCase() : address.toUpperCase();
|
|
159
|
+
return {
|
|
160
|
+
id: `${chain}:${address}`,
|
|
161
|
+
symbol,
|
|
162
|
+
name: `Dummy Token ${symbol}`,
|
|
163
|
+
address,
|
|
164
|
+
chain,
|
|
165
|
+
decimals: 18,
|
|
166
|
+
totalSupply: "1000000000",
|
|
167
|
+
price: 1.23 * (index + 1),
|
|
168
|
+
priceUsd: 1.23 * (index + 1),
|
|
169
|
+
marketCapUsd: 1230000000 * (index + 1),
|
|
170
|
+
marketCapUSD: 1230000000 * (index + 1),
|
|
171
|
+
volume24hUsd: 45600000 * (index + 1),
|
|
172
|
+
volume24hUSD: 45600000 * (index + 1),
|
|
173
|
+
priceChange24h: 5.67 * (index % 2 === 0 ? 1 : -1),
|
|
174
|
+
priceChange24hPercent: 5.67 * (index % 2 === 0 ? 1 : -1),
|
|
175
|
+
logoURI: "https://via.placeholder.com/150",
|
|
176
|
+
liquidity: 1e6 + Math.random() * 9000000,
|
|
177
|
+
holders: Math.floor(500 + Math.random() * 9500),
|
|
178
|
+
sourceProvider: "dummy",
|
|
179
|
+
lastUpdatedAt: new Date,
|
|
180
|
+
raw: {
|
|
181
|
+
dummyData: true
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
});
|
|
63
185
|
}
|
|
64
|
-
|
|
65
|
-
|
|
186
|
+
getDexName() {
|
|
187
|
+
return "dummy-token-data";
|
|
66
188
|
}
|
|
67
|
-
}
|
|
189
|
+
}
|
|
68
190
|
|
|
69
191
|
// src/lp/service.ts
|
|
70
|
-
import {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
192
|
+
import { Service as Service2 } from "@elizaos/core";
|
|
193
|
+
|
|
194
|
+
class DummyLpService extends Service2 {
|
|
195
|
+
static serviceType = "lp";
|
|
196
|
+
capabilityDescription = "Dummy LP service for testing";
|
|
197
|
+
constructor(runtime) {
|
|
198
|
+
super(runtime);
|
|
199
|
+
}
|
|
74
200
|
getDexName() {
|
|
75
201
|
return "dummy";
|
|
76
202
|
}
|
|
77
203
|
static async start(runtime) {
|
|
78
|
-
const service = new
|
|
204
|
+
const service = new DummyLpService(runtime);
|
|
205
|
+
await service.start();
|
|
79
206
|
return service;
|
|
80
207
|
}
|
|
81
|
-
|
|
82
|
-
const service = runtime.getService(_DummyLpService.serviceType);
|
|
83
|
-
if (service) {
|
|
84
|
-
await service.stop();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async start(runtime) {
|
|
208
|
+
async start() {
|
|
88
209
|
console.log("[DummyLpService] started.");
|
|
89
210
|
}
|
|
90
211
|
async stop() {
|
|
91
212
|
console.log("[DummyLpService] stopped.");
|
|
92
213
|
}
|
|
93
|
-
async
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
dex: "dummy",
|
|
112
|
-
tokenA: { mint: USDC_MINT, symbol: "USDC", name: "USD Coin", decimals: 6 },
|
|
113
|
-
tokenB: {
|
|
114
|
-
mint: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
|
|
115
|
-
symbol: "USDT",
|
|
116
|
-
name: "Tether",
|
|
117
|
-
decimals: 6
|
|
118
|
-
},
|
|
119
|
-
apr: 0.08,
|
|
120
|
-
apy: 0.082,
|
|
121
|
-
tvl: 25e5,
|
|
122
|
-
fee: 5e-4,
|
|
123
|
-
metadata: { name: "USDC/USDT Dummy Stable Pool", isStable: true }
|
|
124
|
-
}
|
|
125
|
-
];
|
|
126
|
-
return pools.filter((p) => {
|
|
127
|
-
if (!tokenAMint && !tokenBMint) return true;
|
|
128
|
-
const hasTokenA = p.tokenA.mint === tokenAMint || p.tokenB.mint === tokenAMint;
|
|
129
|
-
const hasTokenB = p.tokenA.mint === tokenBMint || p.tokenB.mint === tokenBMint;
|
|
130
|
-
if (tokenAMint && tokenBMint) return hasTokenA && hasTokenB;
|
|
131
|
-
if (tokenAMint) return hasTokenA;
|
|
132
|
-
if (tokenBMint) return hasTokenB;
|
|
133
|
-
return false;
|
|
134
|
-
});
|
|
214
|
+
async getPoolInfo(poolAddress) {
|
|
215
|
+
return {
|
|
216
|
+
address: poolAddress,
|
|
217
|
+
tokenA: "0xTokenA",
|
|
218
|
+
tokenB: "0xTokenB",
|
|
219
|
+
fee: 3000,
|
|
220
|
+
liquidity: BigInt(1e6),
|
|
221
|
+
sqrtPriceX96: BigInt(1e6),
|
|
222
|
+
tick: 0
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
async getPosition(positionId) {
|
|
226
|
+
return {
|
|
227
|
+
poolAddress: "0xPool",
|
|
228
|
+
tokenA: "0xTokenA",
|
|
229
|
+
tokenB: "0xTokenB",
|
|
230
|
+
liquidity: BigInt(1000)
|
|
231
|
+
};
|
|
135
232
|
}
|
|
136
233
|
async addLiquidity(params) {
|
|
137
|
-
console.log(`[DummyLpService] addLiquidity called for pool: ${params.poolId}`);
|
|
138
234
|
return {
|
|
139
235
|
success: true,
|
|
140
236
|
transactionId: `dummy-tx-${Date.now()}`,
|
|
141
237
|
lpTokensReceived: {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
symbol: "DUMMY-LP",
|
|
146
|
-
uiAmount: 100,
|
|
147
|
-
decimals: 6,
|
|
148
|
-
name: `Dummy LP Token for ${params.poolId}`
|
|
238
|
+
amount: "100000000",
|
|
239
|
+
address: "dummy-lp-mint-dummy-pool-1",
|
|
240
|
+
uiAmount: 100
|
|
149
241
|
}
|
|
150
242
|
};
|
|
151
243
|
}
|
|
152
244
|
async removeLiquidity(params) {
|
|
153
|
-
console.log(`[DummyLpService] removeLiquidity called for pool: ${params.poolId}`);
|
|
154
245
|
return {
|
|
155
246
|
success: true,
|
|
156
247
|
transactionId: `dummy-tx-${Date.now()}`,
|
|
157
248
|
tokensReceived: [
|
|
158
|
-
{
|
|
159
|
-
|
|
160
|
-
balance: "500000000",
|
|
161
|
-
symbol: "SOL",
|
|
162
|
-
uiAmount: 0.5,
|
|
163
|
-
decimals: 9,
|
|
164
|
-
name: "Solana"
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyB7u6a",
|
|
168
|
-
balance: "500000000",
|
|
169
|
-
symbol: "USDC",
|
|
170
|
-
uiAmount: 500,
|
|
171
|
-
decimals: 6,
|
|
172
|
-
name: "USD Coin"
|
|
173
|
-
}
|
|
249
|
+
{ token: "tokenA", amount: "1000000000", symbol: "SOL" },
|
|
250
|
+
{ token: "tokenB", amount: "1000000", symbol: "USDC" }
|
|
174
251
|
]
|
|
175
252
|
};
|
|
176
253
|
}
|
|
177
|
-
async
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
254
|
+
async collectFees(positionId) {
|
|
255
|
+
return {
|
|
256
|
+
hash: "0xDummyHash",
|
|
257
|
+
success: true
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
async getBalances(address) {
|
|
261
|
+
return [
|
|
262
|
+
{
|
|
263
|
+
token: "0xTokenA",
|
|
264
|
+
balance: BigInt(1000),
|
|
265
|
+
decimals: 18
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
token: "0xTokenB",
|
|
269
|
+
balance: BigInt(2000),
|
|
270
|
+
decimals: 18
|
|
271
|
+
}
|
|
272
|
+
];
|
|
273
|
+
}
|
|
274
|
+
async getPools(tokenAMint) {
|
|
275
|
+
const pools = [
|
|
276
|
+
{
|
|
277
|
+
id: "dummy-pool-1",
|
|
278
|
+
tokenA: { mint: "So11111111111111111111111111111111111111112" },
|
|
279
|
+
tokenB: { mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
|
|
280
|
+
liquidity: "1000000",
|
|
281
|
+
type: "concentrated"
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
id: "dummy-stable-pool-2",
|
|
285
|
+
tokenA: { mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
|
|
286
|
+
tokenB: { mint: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB" },
|
|
287
|
+
liquidity: "5000000",
|
|
288
|
+
type: "stable"
|
|
289
|
+
}
|
|
290
|
+
];
|
|
291
|
+
if (tokenAMint) {
|
|
292
|
+
return pools.filter((pool) => pool.tokenA.mint === tokenAMint);
|
|
293
|
+
}
|
|
294
|
+
return pools;
|
|
295
|
+
}
|
|
296
|
+
async getLpPositionDetails(userPublicKey, positionId) {
|
|
297
|
+
const parts = positionId.split("-");
|
|
298
|
+
const poolStartIndex = parts.lastIndexOf("dummy");
|
|
299
|
+
const poolId = parts.slice(poolStartIndex).join("-");
|
|
300
|
+
const lpMint = parts.slice(0, poolStartIndex).join("-");
|
|
181
301
|
return {
|
|
182
|
-
poolId: "dummy-pool-1",
|
|
183
|
-
// Assuming the identifier maps back to a known pool
|
|
184
302
|
dex: "dummy",
|
|
303
|
+
poolId,
|
|
304
|
+
userPublicKey,
|
|
185
305
|
lpTokenBalance: {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
symbol: "DUMMY-LP",
|
|
189
|
-
uiAmount: 100,
|
|
190
|
-
decimals: 6,
|
|
191
|
-
name: `Dummy LP Token`
|
|
306
|
+
amount: 100,
|
|
307
|
+
address: positionId
|
|
192
308
|
},
|
|
309
|
+
lpMint,
|
|
310
|
+
positionValue: 1000,
|
|
311
|
+
valueUsd: 1000,
|
|
312
|
+
tokenAAmount: 500,
|
|
313
|
+
tokenBAmount: 500,
|
|
314
|
+
sharePercentage: 0.01,
|
|
315
|
+
apr: 15.5,
|
|
316
|
+
fees24h: 2.5,
|
|
317
|
+
unclaimedFees: 5.75,
|
|
193
318
|
underlyingTokens: [
|
|
194
|
-
{
|
|
195
|
-
|
|
196
|
-
balance: "500000000",
|
|
197
|
-
symbol: "SOL",
|
|
198
|
-
uiAmount: 0.5,
|
|
199
|
-
decimals: 9,
|
|
200
|
-
name: "Solana"
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
address: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyB7u6a",
|
|
204
|
-
balance: "500000000",
|
|
205
|
-
symbol: "USDC",
|
|
206
|
-
uiAmount: 500,
|
|
207
|
-
decimals: 6,
|
|
208
|
-
name: "USD Coin"
|
|
209
|
-
}
|
|
319
|
+
{ symbol: "tokenA", amount: 500 },
|
|
320
|
+
{ symbol: "tokenB", amount: 500 }
|
|
210
321
|
],
|
|
211
|
-
|
|
212
|
-
|
|
322
|
+
raw: {
|
|
323
|
+
lpTokenDecimals: 9,
|
|
324
|
+
tokenADecimals: 9,
|
|
325
|
+
tokenBDecimals: 6
|
|
326
|
+
}
|
|
213
327
|
};
|
|
214
328
|
}
|
|
215
329
|
async getMarketDataForPools(poolIds) {
|
|
216
|
-
|
|
217
|
-
const results = {};
|
|
330
|
+
const marketData = {};
|
|
218
331
|
for (const poolId of poolIds) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
332
|
+
marketData[poolId] = {
|
|
333
|
+
poolId,
|
|
334
|
+
price: 1 + Math.random() * 0.1,
|
|
335
|
+
volume24h: 1e5 + Math.random() * 50000,
|
|
336
|
+
tvl: 1e6 + Math.random() * 500000,
|
|
337
|
+
apy: 10 + Math.random() * 20,
|
|
338
|
+
priceChange24h: -5 + Math.random() * 10
|
|
223
339
|
};
|
|
224
340
|
}
|
|
225
|
-
return
|
|
341
|
+
return marketData;
|
|
226
342
|
}
|
|
227
|
-
|
|
343
|
+
async swap(tokenIn, tokenOut, amountIn, minAmountOut, slippage) {
|
|
344
|
+
return {
|
|
345
|
+
hash: "0xDummyHash",
|
|
346
|
+
success: true
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
}
|
|
228
350
|
|
|
229
351
|
// src/wallet/service.ts
|
|
230
|
-
import {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
static serviceType =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
352
|
+
import { Service as Service3 } from "@elizaos/core";
|
|
353
|
+
|
|
354
|
+
class DummyWalletService extends Service3 {
|
|
355
|
+
static serviceType = "wallet";
|
|
356
|
+
capabilityDescription = "Dummy wallet service for testing";
|
|
357
|
+
balances = new Map;
|
|
358
|
+
prices = new Map;
|
|
359
|
+
decimals = new Map;
|
|
360
|
+
quoteAsset = "USDC";
|
|
239
361
|
constructor(runtime) {
|
|
240
362
|
super(runtime);
|
|
241
|
-
this.balances = /* @__PURE__ */ new Map();
|
|
242
|
-
this.positions = /* @__PURE__ */ new Map();
|
|
243
|
-
this.quoteAssetSymbol = DEFAULT_QUOTE_ASSET;
|
|
244
|
-
this.resetWallet(1e4, DEFAULT_QUOTE_ASSET);
|
|
245
|
-
}
|
|
246
|
-
async transferSol(from, to, lamports) {
|
|
247
|
-
console.log(
|
|
248
|
-
`[${_DummyWalletService.serviceType}] Mock transfer: ${lamports} lamports from ${from} to ${to}`
|
|
249
|
-
);
|
|
250
|
-
const solSymbol = "SOL";
|
|
251
|
-
const solAmount = lamports / 1e9;
|
|
252
|
-
const currentBalance = this.balances.get(solSymbol) || 0;
|
|
253
|
-
if (currentBalance < solAmount) {
|
|
254
|
-
throw new Error(`Insufficient SOL balance. Have ${currentBalance}, need ${solAmount}`);
|
|
255
|
-
}
|
|
256
|
-
this.balances.set(solSymbol, currentBalance - solAmount);
|
|
257
|
-
return `dummy-tx-${Date.now()}-${Math.random().toString(36).substring(7)}`;
|
|
258
363
|
}
|
|
259
364
|
static async start(runtime) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
return
|
|
365
|
+
const service = new DummyWalletService(runtime);
|
|
366
|
+
await service.start();
|
|
367
|
+
return service;
|
|
263
368
|
}
|
|
264
369
|
async start() {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
);
|
|
370
|
+
this.balances.set("USDC", BigInt(1e4 * 1e6));
|
|
371
|
+
this.prices.set("USDC", 1);
|
|
372
|
+
this.decimals.set("USDC", 6);
|
|
373
|
+
console.log("[DummyWalletService] started.");
|
|
268
374
|
}
|
|
269
375
|
async stop() {
|
|
270
|
-
console.log(`[${_DummyWalletService.serviceType}] instance stop called. Balances reset.`);
|
|
271
376
|
this.balances.clear();
|
|
272
|
-
this.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
);
|
|
286
|
-
|
|
377
|
+
this.prices.clear();
|
|
378
|
+
this.decimals.clear();
|
|
379
|
+
console.log("[DummyWalletService] stopped.");
|
|
380
|
+
}
|
|
381
|
+
async getBalance(asset) {
|
|
382
|
+
return this.balances.get(asset) || BigInt(0);
|
|
383
|
+
}
|
|
384
|
+
addFunds(asset, amount) {
|
|
385
|
+
const currentBalance = this.balances.get(asset) || BigInt(0);
|
|
386
|
+
this.balances.set(asset, currentBalance + BigInt(amount));
|
|
387
|
+
}
|
|
388
|
+
setPortfolioHolding(asset, amount, price = 1) {
|
|
389
|
+
if (asset === this.quoteAsset) {
|
|
390
|
+
this.addFunds(asset, amount);
|
|
391
|
+
this.prices.set(asset, 1);
|
|
392
|
+
this.decimals.set(asset, 6);
|
|
393
|
+
} else {
|
|
394
|
+
const decimals = 6;
|
|
395
|
+
const scaledAmount = Math.floor(amount * Math.pow(10, decimals));
|
|
396
|
+
this.balances.set(asset, BigInt(scaledAmount));
|
|
397
|
+
this.prices.set(asset, price);
|
|
398
|
+
this.decimals.set(asset, decimals);
|
|
287
399
|
}
|
|
288
|
-
this.balances.set(assetSymbolOrAddress, quantity);
|
|
289
|
-
this.positions.set(assetSymbolOrAddress, {
|
|
290
|
-
quantity,
|
|
291
|
-
averagePrice,
|
|
292
|
-
lots: [{ price: averagePrice, quantity, timestamp: Date.now() }]
|
|
293
|
-
// Create a single lot for simplicity
|
|
294
|
-
});
|
|
295
|
-
console.log(
|
|
296
|
-
`[${_DummyWalletService.serviceType}] Set holding for ${assetSymbolOrAddress}: ${quantity} @ ${averagePrice}`
|
|
297
|
-
);
|
|
298
400
|
}
|
|
299
|
-
|
|
401
|
+
resetWallet(initialCash = 1e4, quoteAsset = "USDC") {
|
|
300
402
|
this.balances.clear();
|
|
301
|
-
this.
|
|
302
|
-
this.
|
|
303
|
-
this.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
async
|
|
309
|
-
|
|
403
|
+
this.prices.clear();
|
|
404
|
+
this.decimals.clear();
|
|
405
|
+
this.quoteAsset = quoteAsset;
|
|
406
|
+
this.balances.set(quoteAsset, BigInt(initialCash * 1e6));
|
|
407
|
+
this.prices.set(quoteAsset, 1);
|
|
408
|
+
this.decimals.set(quoteAsset, 6);
|
|
409
|
+
}
|
|
410
|
+
async transferSol(from, to, amount) {
|
|
411
|
+
const amountBigInt = BigInt(amount);
|
|
412
|
+
const solBalance = this.balances.get("SOL") || BigInt(0);
|
|
413
|
+
if (solBalance < amountBigInt) {
|
|
414
|
+
throw new Error(`Insufficient SOL balance`);
|
|
415
|
+
}
|
|
416
|
+
this.balances.set("SOL", solBalance - amountBigInt);
|
|
417
|
+
return `dummy-tx-${Date.now()}`;
|
|
310
418
|
}
|
|
311
|
-
|
|
419
|
+
getPortfolio() {
|
|
312
420
|
const assets = [];
|
|
313
421
|
let totalValueUsd = 0;
|
|
314
|
-
for (const [
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
const
|
|
318
|
-
const
|
|
422
|
+
for (const [asset, balance] of this.balances.entries()) {
|
|
423
|
+
const price = this.prices.get(asset) || 1;
|
|
424
|
+
const decimals = this.decimals.get(asset) || 6;
|
|
425
|
+
const divisor = Math.pow(10, decimals);
|
|
426
|
+
const quantity = Number(balance) / divisor;
|
|
427
|
+
const valueUsd = quantity * price;
|
|
428
|
+
totalValueUsd += valueUsd;
|
|
319
429
|
assets.push({
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
quantity
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
430
|
+
symbol: asset,
|
|
431
|
+
address: `dummy-${asset.toLowerCase()}-address`,
|
|
432
|
+
balance: Number(balance),
|
|
433
|
+
valueUsd,
|
|
434
|
+
value: valueUsd,
|
|
435
|
+
amount: quantity,
|
|
436
|
+
quantity,
|
|
437
|
+
price,
|
|
438
|
+
averagePrice: price,
|
|
439
|
+
allocation: 0,
|
|
440
|
+
decimals
|
|
331
441
|
});
|
|
332
|
-
|
|
442
|
+
}
|
|
443
|
+
for (const asset of assets) {
|
|
444
|
+
asset.allocation = totalValueUsd > 0 ? asset.valueUsd / totalValueUsd * 100 : 0;
|
|
333
445
|
}
|
|
334
446
|
return {
|
|
335
447
|
totalValueUsd,
|
|
336
|
-
assets
|
|
448
|
+
assets,
|
|
449
|
+
timestamp: Date.now()
|
|
337
450
|
};
|
|
338
451
|
}
|
|
339
|
-
|
|
452
|
+
get serviceName() {
|
|
453
|
+
return "dummy-wallet";
|
|
454
|
+
}
|
|
455
|
+
}
|
|
340
456
|
|
|
341
457
|
// src/pdf/service.ts
|
|
342
|
-
import {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
458
|
+
import { Service as Service4, ServiceType, logger as logger3 } from "@elizaos/core";
|
|
459
|
+
|
|
460
|
+
class DummyPdfService extends Service4 {
|
|
461
|
+
static serviceType = ServiceType.PDF;
|
|
462
|
+
capabilityDescription = "Dummy PDF service for testing";
|
|
347
463
|
constructor(runtime) {
|
|
348
464
|
super(runtime);
|
|
349
465
|
}
|
|
350
466
|
static async start(runtime) {
|
|
351
|
-
const service = new
|
|
467
|
+
const service = new DummyPdfService(runtime);
|
|
352
468
|
await service.initialize();
|
|
353
469
|
return service;
|
|
354
470
|
}
|
|
355
471
|
async initialize() {
|
|
356
|
-
|
|
472
|
+
logger3.info("DummyPdfService initialized");
|
|
357
473
|
}
|
|
358
474
|
async stop() {
|
|
359
|
-
|
|
475
|
+
logger3.info("DummyPdfService stopped");
|
|
360
476
|
}
|
|
361
|
-
async extractText(
|
|
362
|
-
|
|
363
|
-
const filename = isBuffer ? "buffer.pdf" : pdfPath;
|
|
364
|
-
this.runtime.logger.debug(`Extracting text from ${filename}`);
|
|
477
|
+
async extractText(pdfBuffer) {
|
|
478
|
+
logger3.debug(`Extracting text from PDF (${pdfBuffer.length} bytes)`);
|
|
365
479
|
return {
|
|
366
|
-
text:
|
|
367
|
-
|
|
368
|
-
This is a dummy PDF service that simulates text extraction.
|
|
369
|
-
|
|
370
|
-
Page 1: Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
371
|
-
Page 2: Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
372
|
-
Page 3: Ut enim ad minim veniam, quis nostrud exercitation ullamco.`,
|
|
373
|
-
pageCount: 3,
|
|
480
|
+
text: "This is dummy extracted text from the PDF document.",
|
|
374
481
|
metadata: {
|
|
375
|
-
title: "
|
|
376
|
-
author: "Dummy
|
|
377
|
-
|
|
378
|
-
|
|
482
|
+
title: "Dummy PDF Document",
|
|
483
|
+
author: "Dummy Author",
|
|
484
|
+
pages: 10,
|
|
485
|
+
creationDate: new Date
|
|
379
486
|
}
|
|
380
487
|
};
|
|
381
488
|
}
|
|
382
|
-
async generatePdf(
|
|
383
|
-
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
this.runtime.logger.debug("PDF generation options:", options);
|
|
388
|
-
}
|
|
389
|
-
return mockPdfBuffer;
|
|
489
|
+
async generatePdf(content, options) {
|
|
490
|
+
logger3.debug("Generating PDF", JSON.stringify(options));
|
|
491
|
+
const dummyPdf = Buffer.from("dummy-pdf-content");
|
|
492
|
+
logger3.debug(`Generated PDF: ${dummyPdf.length} bytes`);
|
|
493
|
+
return dummyPdf;
|
|
390
494
|
}
|
|
391
|
-
async convertToPdf(
|
|
392
|
-
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
this.runtime.logger.debug("PDF conversion options:", options);
|
|
397
|
-
}
|
|
398
|
-
return mockPdfBuffer;
|
|
399
|
-
}
|
|
400
|
-
async mergePdfs(pdfPaths) {
|
|
401
|
-
this.runtime.logger.debug(`Merging ${pdfPaths.length} PDF files`);
|
|
402
|
-
const mergedContent = pdfPaths.map((path, index) => {
|
|
403
|
-
const name = Buffer.isBuffer(path) ? `buffer-${index}` : path;
|
|
404
|
-
return `Content from ${name}`;
|
|
405
|
-
}).join("\n\n");
|
|
406
|
-
const mockMergedBuffer = Buffer.from(`Mock merged PDF:
|
|
407
|
-
${mergedContent}`, "utf8");
|
|
408
|
-
return mockMergedBuffer;
|
|
409
|
-
}
|
|
410
|
-
async splitPdf(pdfPath) {
|
|
411
|
-
this.runtime.logger.debug("Splitting PDF into pages");
|
|
412
|
-
const filename = Buffer.isBuffer(pdfPath) ? "buffer.pdf" : pdfPath;
|
|
413
|
-
const pages = [
|
|
414
|
-
Buffer.from(`Mock Page 1 from ${filename}`, "utf8"),
|
|
415
|
-
Buffer.from(`Mock Page 2 from ${filename}`, "utf8"),
|
|
416
|
-
Buffer.from(`Mock Page 3 from ${filename}`, "utf8")
|
|
417
|
-
];
|
|
418
|
-
return pages;
|
|
495
|
+
async convertToPdf(input, inputFormat, options) {
|
|
496
|
+
logger3.debug(`Converting ${inputFormat} to PDF`, JSON.stringify(options));
|
|
497
|
+
const dummyPdf = Buffer.from(`dummy-pdf-from-${inputFormat}`);
|
|
498
|
+
logger3.debug(`Converted to PDF: ${dummyPdf.length} bytes`);
|
|
499
|
+
return dummyPdf;
|
|
419
500
|
}
|
|
420
|
-
|
|
501
|
+
async mergePdfs(pdfBuffers) {
|
|
502
|
+
logger3.debug(`Merging ${pdfBuffers.length} PDFs`);
|
|
503
|
+
const totalSize = pdfBuffers.reduce((sum, buf) => sum + buf.length, 0);
|
|
504
|
+
const mergedPdf = Buffer.from(`dummy-merged-pdf-${totalSize}`);
|
|
505
|
+
return mergedPdf;
|
|
506
|
+
}
|
|
507
|
+
async splitPdf(pdfBuffer, ranges) {
|
|
508
|
+
logger3.debug(`Splitting PDF into ${ranges.length} parts`);
|
|
509
|
+
return ranges.map((range, index) => Buffer.from(`dummy-split-pdf-part-${index}-pages-${range[0]}-${range[1]}`));
|
|
510
|
+
}
|
|
511
|
+
getDexName() {
|
|
512
|
+
return "dummy-pdf";
|
|
513
|
+
}
|
|
514
|
+
}
|
|
421
515
|
|
|
422
516
|
// src/video/service.ts
|
|
423
|
-
import {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
517
|
+
import { Service as Service5, ServiceType as ServiceType2, logger as logger4 } from "@elizaos/core";
|
|
518
|
+
|
|
519
|
+
class DummyVideoService extends Service5 {
|
|
520
|
+
static serviceType = ServiceType2.VIDEO;
|
|
521
|
+
capabilityDescription = "Dummy video service for testing";
|
|
428
522
|
constructor(runtime) {
|
|
429
523
|
super(runtime);
|
|
430
524
|
}
|
|
431
525
|
static async start(runtime) {
|
|
432
|
-
const service = new
|
|
526
|
+
const service = new DummyVideoService(runtime);
|
|
433
527
|
await service.initialize();
|
|
434
528
|
return service;
|
|
435
529
|
}
|
|
436
530
|
async initialize() {
|
|
437
|
-
|
|
531
|
+
logger4.info("DummyVideoService initialized");
|
|
438
532
|
}
|
|
439
533
|
async stop() {
|
|
440
|
-
|
|
534
|
+
logger4.info("DummyVideoService stopped");
|
|
441
535
|
}
|
|
442
536
|
async getVideoInfo(url) {
|
|
443
|
-
|
|
537
|
+
logger4.debug(`Getting video info for: ${url}`);
|
|
444
538
|
return {
|
|
445
|
-
title: "
|
|
539
|
+
title: "Dummy Video Title",
|
|
446
540
|
duration: 300,
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
{
|
|
456
|
-
formatId: "mp4-720p",
|
|
457
|
-
url: "https://example.com/video-720p.mp4",
|
|
458
|
-
extension: "mp4",
|
|
459
|
-
quality: "720p",
|
|
460
|
-
fileSize: 5e7,
|
|
461
|
-
// 50MB
|
|
462
|
-
videoCodec: "h264",
|
|
463
|
-
audioCodec: "aac",
|
|
464
|
-
resolution: "1280x720",
|
|
465
|
-
fps: 30,
|
|
466
|
-
bitrate: 1e6
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
formatId: "mp4-1080p",
|
|
470
|
-
url: "https://example.com/video-1080p.mp4",
|
|
471
|
-
extension: "mp4",
|
|
472
|
-
quality: "1080p",
|
|
473
|
-
fileSize: 1e8,
|
|
474
|
-
// 100MB
|
|
475
|
-
videoCodec: "h264",
|
|
476
|
-
audioCodec: "aac",
|
|
477
|
-
resolution: "1920x1080",
|
|
478
|
-
fps: 30,
|
|
479
|
-
bitrate: 2e6
|
|
480
|
-
}
|
|
481
|
-
]
|
|
541
|
+
resolution: {
|
|
542
|
+
width: 1920,
|
|
543
|
+
height: 1080
|
|
544
|
+
},
|
|
545
|
+
format: "mp4",
|
|
546
|
+
size: 50000000,
|
|
547
|
+
fps: 30,
|
|
548
|
+
codec: "h264"
|
|
482
549
|
};
|
|
483
550
|
}
|
|
484
551
|
async downloadVideo(url, options) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
return
|
|
493
|
-
}
|
|
494
|
-
async
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
await new Promise((resolve) => setTimeout(resolve, 30));
|
|
504
|
-
return thumbnailPath;
|
|
505
|
-
}
|
|
506
|
-
async convertVideo(videoPath, outputPath, options) {
|
|
507
|
-
this.runtime.logger.debug(`Converting video from ${videoPath} to ${outputPath}`);
|
|
508
|
-
if (options) {
|
|
509
|
-
this.runtime.logger.debug("Conversion options:", options);
|
|
510
|
-
}
|
|
511
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
512
|
-
return outputPath;
|
|
552
|
+
logger4.debug(`Downloading video from: ${url}`, JSON.stringify(options));
|
|
553
|
+
const dummyVideo = Buffer.from(`dummy-video-${options?.format || "mp4"}`);
|
|
554
|
+
logger4.debug(`Downloaded video: ${dummyVideo.length} bytes`);
|
|
555
|
+
return dummyVideo;
|
|
556
|
+
}
|
|
557
|
+
async extractAudio(videoBuffer) {
|
|
558
|
+
logger4.debug(`Extracting audio from video (${videoBuffer.length} bytes)`);
|
|
559
|
+
return Buffer.from("dummy-audio-from-video");
|
|
560
|
+
}
|
|
561
|
+
async extractFrames(videoBuffer, timestamps) {
|
|
562
|
+
logger4.debug(`Extracting ${timestamps.length} frames from video`);
|
|
563
|
+
return timestamps.map((ts, index) => Buffer.from(`dummy-frame-${index}-at-${ts}s`));
|
|
564
|
+
}
|
|
565
|
+
async processVideo(videoBuffer, options) {
|
|
566
|
+
logger4.debug("Processing video", JSON.stringify(options));
|
|
567
|
+
const processedVideo = Buffer.from(`dummy-processed-video-${options.outputFormat || "mp4"}`);
|
|
568
|
+
logger4.debug(`Processed video: ${processedVideo.length} bytes`);
|
|
569
|
+
return processedVideo;
|
|
513
570
|
}
|
|
514
571
|
async getAvailableFormats(url) {
|
|
515
|
-
|
|
572
|
+
logger4.debug(`Getting available formats for: ${url}`);
|
|
516
573
|
return [
|
|
517
574
|
{
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
fileSize: 15e6,
|
|
523
|
-
// 15MB
|
|
524
|
-
videoCodec: "h264",
|
|
525
|
-
audioCodec: "aac",
|
|
526
|
-
resolution: "640x360",
|
|
527
|
-
fps: 30,
|
|
528
|
-
bitrate: 5e5
|
|
575
|
+
format: "mp4",
|
|
576
|
+
resolution: "1920x1080",
|
|
577
|
+
size: 50000000,
|
|
578
|
+
url: `${url}?format=1080p`
|
|
529
579
|
},
|
|
530
580
|
{
|
|
531
|
-
|
|
532
|
-
url: "https://example.com/video-720p.mp4",
|
|
533
|
-
extension: "mp4",
|
|
534
|
-
quality: "720p",
|
|
535
|
-
fileSize: 5e7,
|
|
536
|
-
// 50MB
|
|
537
|
-
videoCodec: "h264",
|
|
538
|
-
audioCodec: "aac",
|
|
581
|
+
format: "mp4",
|
|
539
582
|
resolution: "1280x720",
|
|
540
|
-
|
|
541
|
-
|
|
583
|
+
size: 25000000,
|
|
584
|
+
url: `${url}?format=720p`
|
|
542
585
|
},
|
|
543
586
|
{
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
fileSize: 1e8,
|
|
549
|
-
// 100MB
|
|
550
|
-
videoCodec: "h264",
|
|
551
|
-
audioCodec: "aac",
|
|
552
|
-
resolution: "1920x1080",
|
|
553
|
-
fps: 30,
|
|
554
|
-
bitrate: 2e6
|
|
555
|
-
},
|
|
556
|
-
{
|
|
557
|
-
formatId: "audio-only",
|
|
558
|
-
url: "https://example.com/audio.mp3",
|
|
559
|
-
extension: "mp3",
|
|
560
|
-
quality: "audio",
|
|
561
|
-
fileSize: 5e6,
|
|
562
|
-
// 5MB
|
|
563
|
-
audioCodec: "mp3",
|
|
564
|
-
bitrate: 128e3
|
|
587
|
+
format: "mp4",
|
|
588
|
+
resolution: "640x480",
|
|
589
|
+
size: 1e7,
|
|
590
|
+
url: `${url}?format=480p`
|
|
565
591
|
}
|
|
566
592
|
];
|
|
567
593
|
}
|
|
568
|
-
|
|
594
|
+
getDexName() {
|
|
595
|
+
return "dummy-video";
|
|
596
|
+
}
|
|
597
|
+
}
|
|
569
598
|
|
|
570
599
|
// src/browser/service.ts
|
|
571
|
-
import {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
600
|
+
import { Service as Service6, ServiceType as ServiceType3, logger as logger5 } from "@elizaos/core";
|
|
601
|
+
|
|
602
|
+
class DummyBrowserService extends Service6 {
|
|
603
|
+
static serviceType = ServiceType3.BROWSER;
|
|
604
|
+
capabilityDescription = "Dummy browser service for testing";
|
|
576
605
|
currentUrl = "about:blank";
|
|
577
606
|
history = [];
|
|
578
607
|
historyIndex = -1;
|
|
@@ -580,20 +609,20 @@ var DummyBrowserService = class _DummyBrowserService extends IBrowserService {
|
|
|
580
609
|
super(runtime);
|
|
581
610
|
}
|
|
582
611
|
static async start(runtime) {
|
|
583
|
-
const service = new
|
|
612
|
+
const service = new DummyBrowserService(runtime);
|
|
584
613
|
await service.initialize();
|
|
585
614
|
return service;
|
|
586
615
|
}
|
|
587
616
|
async initialize() {
|
|
588
|
-
|
|
617
|
+
logger5.info("DummyBrowserService initialized");
|
|
589
618
|
}
|
|
590
619
|
async stop() {
|
|
591
|
-
|
|
620
|
+
logger5.info("DummyBrowserService stopped");
|
|
592
621
|
}
|
|
593
622
|
async navigate(url, options) {
|
|
594
|
-
|
|
623
|
+
logger5.debug(`Navigating to ${url}`);
|
|
595
624
|
if (options) {
|
|
596
|
-
|
|
625
|
+
logger5.debug("Navigation options:", JSON.stringify(options));
|
|
597
626
|
}
|
|
598
627
|
this.history.push(url);
|
|
599
628
|
this.historyIndex = this.history.length - 1;
|
|
@@ -601,1037 +630,491 @@ var DummyBrowserService = class _DummyBrowserService extends IBrowserService {
|
|
|
601
630
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
602
631
|
}
|
|
603
632
|
async screenshot(options) {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
isGitHub = url.hostname === "github.com" || url.hostname.endsWith(".github.com");
|
|
619
|
-
isGoogle = url.hostname === "google.com" || url.hostname.endsWith(".google.com");
|
|
620
|
-
} catch (error) {
|
|
621
|
-
this.runtime.logger.debug("Invalid URL format, defaulting to generic content");
|
|
622
|
-
}
|
|
623
|
-
let mockContent;
|
|
624
|
-
if (isGitHub) {
|
|
625
|
-
mockContent = {
|
|
626
|
-
text: "Mock GitHub repository content\n\nThis is a dummy browser service extracting content from GitHub.\n\nFeatures:\n- Mock code repository\n- Sample README content\n- Dummy issue tracking",
|
|
627
|
-
html: '<div class="repository-content"><h1>Mock Repository</h1><p>This is a dummy GitHub repository.</p></div>',
|
|
628
|
-
links: [
|
|
629
|
-
{ url: "https://github.com/mock/repo/issues", text: "Issues" },
|
|
630
|
-
{ url: "https://github.com/mock/repo/pulls", text: "Pull Requests" },
|
|
631
|
-
{ url: "https://github.com/mock/repo/wiki", text: "Wiki" }
|
|
632
|
-
],
|
|
633
|
-
images: [{ src: "https://github.com/mock/repo/avatar.png", alt: "Repository Avatar" }],
|
|
634
|
-
title: "Mock Repository - GitHub",
|
|
635
|
-
metadata: {
|
|
636
|
-
"og:title": "Mock Repository",
|
|
637
|
-
"og:description": "A dummy repository for testing",
|
|
638
|
-
"og:type": "website"
|
|
639
|
-
}
|
|
640
|
-
};
|
|
641
|
-
} else if (isGoogle) {
|
|
642
|
-
mockContent = {
|
|
643
|
-
text: "Mock Google search results\n\nSearch results for your query:\n\n1. Mock Result 1\n2. Mock Result 2\n3. Mock Result 3",
|
|
644
|
-
html: '<div class="search-results"><div class="result"><h3>Mock Result 1</h3><p>Mock description</p></div></div>',
|
|
645
|
-
links: [
|
|
646
|
-
{ url: "https://example.com/result1", text: "Mock Result 1" },
|
|
647
|
-
{ url: "https://example.com/result2", text: "Mock Result 2" },
|
|
648
|
-
{ url: "https://example.com/result3", text: "Mock Result 3" }
|
|
649
|
-
],
|
|
650
|
-
images: [{ src: "https://google.com/logo.png", alt: "Google Logo" }],
|
|
651
|
-
title: "Mock Search - Google",
|
|
652
|
-
metadata: {
|
|
653
|
-
description: "Mock search results page"
|
|
654
|
-
}
|
|
655
|
-
};
|
|
656
|
-
} else {
|
|
657
|
-
mockContent = {
|
|
658
|
-
text: `Mock content from ${this.currentUrl}
|
|
659
|
-
|
|
660
|
-
This is dummy content extracted by the browser service.
|
|
661
|
-
|
|
662
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit.`,
|
|
663
|
-
html: '<div class="content"><h1>Mock Page</h1><p>This is mock content from the dummy browser service.</p></div>',
|
|
664
|
-
links: [
|
|
665
|
-
{ url: `${this.currentUrl}/page1`, text: "Page 1" },
|
|
666
|
-
{ url: `${this.currentUrl}/page2`, text: "Page 2" }
|
|
667
|
-
],
|
|
668
|
-
images: [{ src: `${this.currentUrl}/image.jpg`, alt: "Mock Image" }],
|
|
669
|
-
title: "Mock Page Title",
|
|
670
|
-
metadata: {
|
|
671
|
-
description: "Mock page description"
|
|
633
|
+
logger5.debug("Taking screenshot", JSON.stringify(options));
|
|
634
|
+
const dummyImage = Buffer.from("dummy-screenshot-data");
|
|
635
|
+
logger5.debug(`Screenshot taken: ${dummyImage.length} bytes`);
|
|
636
|
+
return dummyImage;
|
|
637
|
+
}
|
|
638
|
+
async extractContent(selectors) {
|
|
639
|
+
logger5.debug("Extracting content", JSON.stringify(selectors));
|
|
640
|
+
const dummyContent = [
|
|
641
|
+
{
|
|
642
|
+
text: "Dummy extracted text",
|
|
643
|
+
html: "<div>Dummy HTML content</div>",
|
|
644
|
+
attributes: {
|
|
645
|
+
class: "dummy-class",
|
|
646
|
+
id: "dummy-id"
|
|
672
647
|
}
|
|
673
|
-
}
|
|
648
|
+
}
|
|
649
|
+
];
|
|
650
|
+
if (selectors && selectors.length > 0) {
|
|
651
|
+
return selectors.map((selector) => ({
|
|
652
|
+
text: `Dummy text for ${selector.selector}`,
|
|
653
|
+
html: `<div>${selector.selector}</div>`,
|
|
654
|
+
attributes: { selector: selector.selector }
|
|
655
|
+
}));
|
|
674
656
|
}
|
|
675
|
-
return
|
|
657
|
+
return dummyContent;
|
|
658
|
+
}
|
|
659
|
+
async waitForSelector(selector, timeout) {
|
|
660
|
+
logger5.debug(`Waiting for selector: ${selector.selector}`);
|
|
661
|
+
const waitTime = Math.min(timeout || 1000, 100);
|
|
662
|
+
await new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
663
|
+
logger5.debug(`Selector found: ${selector.selector}`);
|
|
664
|
+
return true;
|
|
676
665
|
}
|
|
677
666
|
async click(selector, options) {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
}
|
|
683
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
667
|
+
logger5.debug(`Clicking on: ${selector.selector}`, JSON.stringify(options));
|
|
668
|
+
const delay = options?.delay || 50;
|
|
669
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
670
|
+
logger5.debug(`Clicked on: ${selector.selector}`);
|
|
684
671
|
}
|
|
685
672
|
async type(selector, text, options) {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
}
|
|
690
|
-
const delay = options?.delay || 10;
|
|
691
|
-
await new Promise((resolve) => setTimeout(resolve, delay * text.length));
|
|
692
|
-
}
|
|
693
|
-
async waitForElement(selector) {
|
|
694
|
-
const selectorStr = typeof selector === "string" ? selector : selector.selector;
|
|
695
|
-
this.runtime.logger.debug(`Waiting for element ${selectorStr}`);
|
|
696
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
697
|
-
}
|
|
698
|
-
async evaluate(script, ...args) {
|
|
699
|
-
this.runtime.logger.debug(`Evaluating script: ${script}`);
|
|
700
|
-
if (script.includes("document.title")) {
|
|
701
|
-
return "Mock Page Title";
|
|
702
|
-
}
|
|
703
|
-
if (script.includes("window.location.href")) {
|
|
704
|
-
return this.currentUrl;
|
|
705
|
-
}
|
|
706
|
-
if (script.includes("document.body.innerHTML")) {
|
|
707
|
-
return "<div>Mock page content</div>";
|
|
708
|
-
}
|
|
709
|
-
return { result: "mock evaluation result", args };
|
|
673
|
+
logger5.debug(`Typing into: ${selector.selector}`, JSON.stringify(options));
|
|
674
|
+
const delay = options?.delay || 50;
|
|
675
|
+
await new Promise((resolve) => setTimeout(resolve, text.length * delay));
|
|
676
|
+
logger5.debug(`Typed "${text}" into: ${selector.selector}`);
|
|
710
677
|
}
|
|
711
|
-
async
|
|
712
|
-
|
|
678
|
+
async evaluateScript(script) {
|
|
679
|
+
logger5.debug("Evaluating script:", script.substring(0, 100) + "...");
|
|
680
|
+
return { success: true, data: "dummy-script-result" };
|
|
713
681
|
}
|
|
714
682
|
async goBack() {
|
|
715
|
-
this.runtime.logger.debug("Going back in history");
|
|
716
683
|
if (this.historyIndex > 0) {
|
|
717
684
|
this.historyIndex--;
|
|
718
685
|
this.currentUrl = this.history[this.historyIndex];
|
|
686
|
+
logger5.debug(`Navigated back to: ${this.currentUrl}`);
|
|
719
687
|
}
|
|
720
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
721
688
|
}
|
|
722
689
|
async goForward() {
|
|
723
|
-
this.runtime.logger.debug("Going forward in history");
|
|
724
690
|
if (this.historyIndex < this.history.length - 1) {
|
|
725
691
|
this.historyIndex++;
|
|
726
692
|
this.currentUrl = this.history[this.historyIndex];
|
|
693
|
+
logger5.debug(`Navigated forward to: ${this.currentUrl}`);
|
|
727
694
|
}
|
|
728
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
729
695
|
}
|
|
730
696
|
async refresh() {
|
|
731
|
-
|
|
697
|
+
logger5.debug(`Refreshing page: ${this.currentUrl}`);
|
|
732
698
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
733
699
|
}
|
|
734
|
-
|
|
700
|
+
async getUrl() {
|
|
701
|
+
logger5.debug(`Current URL: ${this.currentUrl}`);
|
|
702
|
+
return this.currentUrl;
|
|
703
|
+
}
|
|
704
|
+
async getTitle() {
|
|
705
|
+
logger5.debug("Getting page title");
|
|
706
|
+
return `Dummy Title - ${this.currentUrl}`;
|
|
707
|
+
}
|
|
708
|
+
async setCookies(cookies) {
|
|
709
|
+
logger5.debug(`Setting ${cookies.length} cookies`);
|
|
710
|
+
}
|
|
711
|
+
async getCookies() {
|
|
712
|
+
logger5.debug("Getting cookies");
|
|
713
|
+
return [];
|
|
714
|
+
}
|
|
715
|
+
async clearCookies() {
|
|
716
|
+
logger5.debug("Clearing cookies");
|
|
717
|
+
}
|
|
718
|
+
getDexName() {
|
|
719
|
+
return "dummy-browser";
|
|
720
|
+
}
|
|
721
|
+
}
|
|
735
722
|
|
|
736
723
|
// src/transcription/service.ts
|
|
737
|
-
import {
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
supportedLanguages = ["en", "es", "fr", "de", "it", "pt", "ru", "zh", "ja", "ko"];
|
|
743
|
-
availableVoices = [
|
|
744
|
-
{ id: "en-US-male", name: "John", language: "en-US", gender: "male" },
|
|
745
|
-
{ id: "en-US-female", name: "Jane", language: "en-US", gender: "female" },
|
|
746
|
-
{ id: "es-ES-male", name: "Carlos", language: "es-ES", gender: "male" },
|
|
747
|
-
{ id: "fr-FR-female", name: "Marie", language: "fr-FR", gender: "female" }
|
|
748
|
-
];
|
|
724
|
+
import { Service as Service7, ServiceType as ServiceType4, logger as logger6 } from "@elizaos/core";
|
|
725
|
+
|
|
726
|
+
class DummyTranscriptionService extends Service7 {
|
|
727
|
+
static serviceType = ServiceType4.TRANSCRIPTION;
|
|
728
|
+
capabilityDescription = "Dummy transcription service for testing";
|
|
749
729
|
constructor(runtime) {
|
|
750
730
|
super(runtime);
|
|
751
731
|
}
|
|
752
732
|
static async start(runtime) {
|
|
753
|
-
const service = new
|
|
733
|
+
const service = new DummyTranscriptionService(runtime);
|
|
754
734
|
await service.initialize();
|
|
755
735
|
return service;
|
|
756
736
|
}
|
|
757
737
|
async initialize() {
|
|
758
|
-
|
|
738
|
+
logger6.info("DummyTranscriptionService initialized");
|
|
759
739
|
}
|
|
760
740
|
async stop() {
|
|
761
|
-
|
|
741
|
+
logger6.info("DummyTranscriptionService stopped");
|
|
762
742
|
}
|
|
763
|
-
async transcribeAudio(
|
|
764
|
-
|
|
765
|
-
this.runtime.logger.debug(`Transcribing audio from ${filename}`);
|
|
766
|
-
if (options) {
|
|
767
|
-
this.runtime.logger.debug("Transcription options:", options);
|
|
768
|
-
}
|
|
769
|
-
const mockText = "Hello, this is a mock transcription from the dummy service. The audio has been processed and converted to text. This demonstrates the transcription capabilities of the system.";
|
|
770
|
-
const words = mockText.split(" ").map((word, index) => ({
|
|
771
|
-
word: word.replace(/[.,!?]/, ""),
|
|
772
|
-
start: index * 0.5,
|
|
773
|
-
end: (index + 1) * 0.5,
|
|
774
|
-
confidence: 0.9 + Math.random() * 0.1
|
|
775
|
-
}));
|
|
743
|
+
async transcribeAudio(audioBuffer, options) {
|
|
744
|
+
logger6.debug(`Transcribing audio (${audioBuffer.length} bytes)`, JSON.stringify(options));
|
|
776
745
|
const segments = [
|
|
777
746
|
{
|
|
778
747
|
id: 0,
|
|
779
|
-
text: "Hello, this is a mock transcription from the dummy service.",
|
|
780
748
|
start: 0,
|
|
781
749
|
end: 5,
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
avg_logprob: -0.1,
|
|
785
|
-
compression_ratio: 1.2,
|
|
786
|
-
no_speech_prob: 0.01
|
|
750
|
+
text: "This is the first segment of dummy transcription.",
|
|
751
|
+
confidence: 0.95
|
|
787
752
|
},
|
|
788
753
|
{
|
|
789
754
|
id: 1,
|
|
790
|
-
text: "The audio has been processed and converted to text.",
|
|
791
755
|
start: 5,
|
|
792
756
|
end: 10,
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
avg_logprob: -0.12,
|
|
796
|
-
compression_ratio: 1.1,
|
|
797
|
-
no_speech_prob: 0.02
|
|
757
|
+
text: "This is the second segment with more text.",
|
|
758
|
+
confidence: 0.92
|
|
798
759
|
},
|
|
799
760
|
{
|
|
800
761
|
id: 2,
|
|
801
|
-
text: "This demonstrates the transcription capabilities of the system.",
|
|
802
762
|
start: 10,
|
|
803
763
|
end: 15,
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
avg_logprob: -0.15,
|
|
807
|
-
compression_ratio: 1.3,
|
|
808
|
-
no_speech_prob: 0.03
|
|
764
|
+
text: "And this is the final segment of the transcription.",
|
|
765
|
+
confidence: 0.94
|
|
809
766
|
}
|
|
810
767
|
];
|
|
811
|
-
|
|
812
|
-
|
|
768
|
+
const words = [
|
|
769
|
+
{ word: "This", start: 0, end: 0.5, confidence: 0.96 },
|
|
770
|
+
{ word: "is", start: 0.5, end: 0.8, confidence: 0.98 },
|
|
771
|
+
{ word: "the", start: 0.8, end: 1, confidence: 0.99 },
|
|
772
|
+
{ word: "first", start: 1, end: 1.5, confidence: 0.94 },
|
|
773
|
+
{ word: "segment", start: 1.5, end: 2, confidence: 0.93 }
|
|
774
|
+
];
|
|
775
|
+
const result = {
|
|
776
|
+
text: segments.map((s) => s.text).join(" "),
|
|
813
777
|
language: options?.language || "en",
|
|
814
778
|
duration: 15,
|
|
815
|
-
segments: options?.
|
|
816
|
-
words: options?.
|
|
817
|
-
confidence: 0.92
|
|
779
|
+
segments: options?.timestamps ? segments : undefined,
|
|
780
|
+
words: options?.timestamps ? words : undefined
|
|
818
781
|
};
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
})
|
|
830
|
-
|
|
831
|
-
text
|
|
832
|
-
language: options?.language || "en",
|
|
833
|
-
duration: 20,
|
|
834
|
-
words: options?.word_timestamps ? words : void 0,
|
|
835
|
-
confidence: 0.88
|
|
836
|
-
};
|
|
837
|
-
}
|
|
838
|
-
async speechToText(audioStream, options) {
|
|
839
|
-
this.runtime.logger.debug("Processing real-time speech to text");
|
|
840
|
-
if (options) {
|
|
841
|
-
this.runtime.logger.debug("Speech to text options:", options);
|
|
782
|
+
logger6.debug(`Transcription complete: ${result.text.substring(0, 50)}...`);
|
|
783
|
+
return result;
|
|
784
|
+
}
|
|
785
|
+
async transcribeVideo(videoBuffer, options) {
|
|
786
|
+
logger6.debug(`Transcribing video (${videoBuffer.length} bytes)`, JSON.stringify(options));
|
|
787
|
+
return this.transcribeAudio(videoBuffer, options);
|
|
788
|
+
}
|
|
789
|
+
async speechToText(audioBuffer, options) {
|
|
790
|
+
logger6.debug("Converting speech to text", JSON.stringify(options));
|
|
791
|
+
const result = await this.transcribeAudio(audioBuffer, options);
|
|
792
|
+
logger6.debug(`Speech to text complete: ${result.text.substring(0, 50)}...`);
|
|
793
|
+
if (options?.format === "text" || !options?.format) {
|
|
794
|
+
return result.text;
|
|
842
795
|
}
|
|
843
|
-
|
|
844
|
-
return {
|
|
845
|
-
text: mockText,
|
|
846
|
-
language: options?.language || "en",
|
|
847
|
-
duration: 5,
|
|
848
|
-
confidence: 0.85
|
|
849
|
-
};
|
|
796
|
+
return result;
|
|
850
797
|
}
|
|
851
798
|
async textToSpeech(text, options) {
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
799
|
+
logger6.debug(`Converting text to speech: "${text.substring(0, 50)}..."`, JSON.stringify(options));
|
|
800
|
+
const format = options?.format || "mp3";
|
|
801
|
+
const dummyAudio = Buffer.from(`dummy-audio-${format}-${text.length}-chars`);
|
|
802
|
+
logger6.debug(`Generated ${format} audio: ${dummyAudio.length} bytes`);
|
|
803
|
+
return dummyAudio;
|
|
804
|
+
}
|
|
805
|
+
async detectLanguage(audioBuffer) {
|
|
806
|
+
logger6.debug(`Detecting language from audio (${audioBuffer.length} bytes)`);
|
|
807
|
+
return "en";
|
|
808
|
+
}
|
|
809
|
+
async translateAudio(audioBuffer, targetLanguage, sourceLanguage) {
|
|
810
|
+
logger6.debug(`Translating audio to ${targetLanguage}`, JSON.stringify({ sourceLanguage }));
|
|
811
|
+
return {
|
|
812
|
+
text: `This is dummy translated text in ${targetLanguage}.`,
|
|
813
|
+
language: targetLanguage,
|
|
814
|
+
duration: 10
|
|
815
|
+
};
|
|
866
816
|
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
this.runtime.logger.debug(`Detecting language from ${filename}`);
|
|
870
|
-
const randomLanguage = this.supportedLanguages[Math.floor(Math.random() * this.supportedLanguages.length)];
|
|
871
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
872
|
-
return randomLanguage;
|
|
817
|
+
getDexName() {
|
|
818
|
+
return "dummy-transcription";
|
|
873
819
|
}
|
|
874
|
-
}
|
|
820
|
+
}
|
|
875
821
|
|
|
876
822
|
// src/web-search/service.ts
|
|
877
|
-
import {
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
trendingSearches = [
|
|
883
|
-
"artificial intelligence",
|
|
884
|
-
"machine learning",
|
|
885
|
-
"blockchain technology",
|
|
886
|
-
"climate change",
|
|
887
|
-
"space exploration",
|
|
888
|
-
"quantum computing",
|
|
889
|
-
"renewable energy",
|
|
890
|
-
"cybersecurity",
|
|
891
|
-
"biotechnology",
|
|
892
|
-
"autonomous vehicles"
|
|
893
|
-
];
|
|
823
|
+
import { Service as Service8, ServiceType as ServiceType5, logger as logger7 } from "@elizaos/core";
|
|
824
|
+
|
|
825
|
+
class DummyWebSearchService extends Service8 {
|
|
826
|
+
static serviceType = ServiceType5.WEB_SEARCH;
|
|
827
|
+
capabilityDescription = "Dummy web search service for testing";
|
|
894
828
|
constructor(runtime) {
|
|
895
829
|
super(runtime);
|
|
896
830
|
}
|
|
897
831
|
static async start(runtime) {
|
|
898
|
-
const service = new
|
|
832
|
+
const service = new DummyWebSearchService(runtime);
|
|
899
833
|
await service.initialize();
|
|
900
834
|
return service;
|
|
901
835
|
}
|
|
902
836
|
async initialize() {
|
|
903
|
-
|
|
837
|
+
logger7.info("DummyWebSearchService initialized");
|
|
904
838
|
}
|
|
905
839
|
async stop() {
|
|
906
|
-
|
|
907
|
-
}
|
|
908
|
-
async search(
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
840
|
+
logger7.info("DummyWebSearchService stopped");
|
|
841
|
+
}
|
|
842
|
+
async search(options) {
|
|
843
|
+
logger7.debug("Performing web search", JSON.stringify(options));
|
|
844
|
+
const limit = options.limit || 10;
|
|
845
|
+
const results = [];
|
|
846
|
+
logger7.debug(`Generating ${limit} dummy search results for: ${options.query}`);
|
|
847
|
+
for (let i = 0;i < limit; i++) {
|
|
848
|
+
results.push({
|
|
849
|
+
title: `Result ${i + 1}: ${options.query}`,
|
|
850
|
+
url: `https://example.com/result-${i}`,
|
|
851
|
+
description: `This is dummy search result ${i + 1} for query: ${options.query}. Lorem ipsum dolor sit amet, consectetur adipiscing elit.`,
|
|
852
|
+
displayUrl: `example.com/result-${i}`,
|
|
853
|
+
source: "DummySearch",
|
|
854
|
+
relevanceScore: 0.9 - i * 0.05,
|
|
855
|
+
snippet: `Dummy snippet for search result ${i + 1}`
|
|
856
|
+
});
|
|
912
857
|
}
|
|
913
|
-
const results = [
|
|
914
|
-
{
|
|
915
|
-
title: `${query} - Comprehensive Guide`,
|
|
916
|
-
url: `https://example.com/guide/${query.replace(/\s+/g, "-")}`,
|
|
917
|
-
description: `A comprehensive guide about ${query}. This mock result provides detailed information and explanations about the topic.`,
|
|
918
|
-
displayUrl: "example.com",
|
|
919
|
-
thumbnail: "https://example.com/thumbnail1.jpg",
|
|
920
|
-
publishedDate: /* @__PURE__ */ new Date("2024-01-15"),
|
|
921
|
-
source: "Example Guide",
|
|
922
|
-
relevanceScore: 0.95,
|
|
923
|
-
snippet: `Learn everything about ${query} with this detailed guide...`
|
|
924
|
-
},
|
|
925
|
-
{
|
|
926
|
-
title: `${query} - Latest News and Updates`,
|
|
927
|
-
url: `https://news.example.com/latest/${query.replace(/\s+/g, "-")}`,
|
|
928
|
-
description: `Stay updated with the latest news about ${query}. Recent developments, trends, and insights.`,
|
|
929
|
-
displayUrl: "news.example.com",
|
|
930
|
-
thumbnail: "https://news.example.com/thumbnail2.jpg",
|
|
931
|
-
publishedDate: /* @__PURE__ */ new Date("2024-01-10"),
|
|
932
|
-
source: "Example News",
|
|
933
|
-
relevanceScore: 0.88,
|
|
934
|
-
snippet: `Breaking news about ${query}: Recent developments show...`
|
|
935
|
-
},
|
|
936
|
-
{
|
|
937
|
-
title: `${query} - Wikipedia`,
|
|
938
|
-
url: `https://en.wikipedia.org/wiki/${query.replace(/\s+/g, "_")}`,
|
|
939
|
-
description: `Wikipedia article about ${query}. Comprehensive information from the free encyclopedia.`,
|
|
940
|
-
displayUrl: "en.wikipedia.org",
|
|
941
|
-
publishedDate: /* @__PURE__ */ new Date("2023-12-01"),
|
|
942
|
-
source: "Wikipedia",
|
|
943
|
-
relevanceScore: 0.82,
|
|
944
|
-
snippet: `${query} is a topic that encompasses various aspects...`
|
|
945
|
-
}
|
|
946
|
-
];
|
|
947
858
|
return {
|
|
948
|
-
query,
|
|
949
859
|
results,
|
|
950
|
-
totalResults:
|
|
951
|
-
|
|
952
|
-
suggestions: [
|
|
953
|
-
`${query} tutorial`,
|
|
954
|
-
`${query} examples`,
|
|
955
|
-
`${query} best practices`,
|
|
956
|
-
`${query} 2024`
|
|
957
|
-
],
|
|
958
|
-
relatedSearches: [
|
|
959
|
-
`what is ${query}`,
|
|
960
|
-
`how to ${query}`,
|
|
961
|
-
`${query} vs alternatives`,
|
|
962
|
-
`${query} benefits`
|
|
963
|
-
]
|
|
860
|
+
totalResults: 1000,
|
|
861
|
+
nextOffset: (options.offset || 0) + limit
|
|
964
862
|
};
|
|
965
863
|
}
|
|
966
|
-
async searchNews(
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
864
|
+
async searchNews(options) {
|
|
865
|
+
logger7.debug("Performing news search", JSON.stringify(options));
|
|
866
|
+
const limit = options.limit || 10;
|
|
867
|
+
const results = [];
|
|
868
|
+
logger7.debug(`Generating ${limit} dummy news results for: ${options.query}`);
|
|
869
|
+
for (let i = 0;i < limit; i++) {
|
|
870
|
+
results.push({
|
|
871
|
+
title: `News: ${options.query} - Article ${i + 1}`,
|
|
872
|
+
url: `https://news.example.com/article-${i}`,
|
|
873
|
+
description: `Breaking News ${i + 1}: ${options.query}. This is a dummy news article content that discusses the latest developments.`,
|
|
874
|
+
displayUrl: `news.example.com/article-${i}`,
|
|
875
|
+
source: "DummyNews",
|
|
876
|
+
publishedDate: new Date(Date.now() - i * 86400000),
|
|
877
|
+
relevanceScore: 0.95 - i * 0.05,
|
|
878
|
+
snippet: `Latest news about ${options.query}`
|
|
879
|
+
});
|
|
970
880
|
}
|
|
971
|
-
const results = [
|
|
972
|
-
{
|
|
973
|
-
title: `Breaking: ${query} Makes Headlines`,
|
|
974
|
-
url: `https://news.example.com/breaking/${query.replace(/\s+/g, "-")}`,
|
|
975
|
-
description: `Latest breaking news about ${query}. Important developments that are making headlines today.`,
|
|
976
|
-
displayUrl: "news.example.com",
|
|
977
|
-
thumbnail: "https://news.example.com/breaking.jpg",
|
|
978
|
-
publishedDate: new Date(Date.now() - 36e5),
|
|
979
|
-
// 1 hour ago
|
|
980
|
-
source: "Example News",
|
|
981
|
-
relevanceScore: 0.93
|
|
982
|
-
},
|
|
983
|
-
{
|
|
984
|
-
title: `${query}: Analysis and Commentary`,
|
|
985
|
-
url: `https://analysis.example.com/commentary/${query.replace(/\s+/g, "-")}`,
|
|
986
|
-
description: `Expert analysis and commentary on ${query}. In-depth perspectives from industry leaders.`,
|
|
987
|
-
displayUrl: "analysis.example.com",
|
|
988
|
-
thumbnail: "https://analysis.example.com/analysis.jpg",
|
|
989
|
-
publishedDate: new Date(Date.now() - 72e5),
|
|
990
|
-
// 2 hours ago
|
|
991
|
-
source: "Example Analysis",
|
|
992
|
-
relevanceScore: 0.87
|
|
993
|
-
}
|
|
994
|
-
];
|
|
995
881
|
return {
|
|
996
|
-
query,
|
|
997
882
|
results,
|
|
998
|
-
totalResults:
|
|
999
|
-
|
|
1000
|
-
suggestions: [`${query} news`, `${query} headlines`, `${query} updates`]
|
|
883
|
+
totalResults: 500,
|
|
884
|
+
nextOffset: (options.offset || 0) + limit
|
|
1001
885
|
};
|
|
1002
886
|
}
|
|
1003
|
-
async searchImages(
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
887
|
+
async searchImages(options) {
|
|
888
|
+
logger7.debug("Performing image search", JSON.stringify(options));
|
|
889
|
+
const limit = options.limit || 10;
|
|
890
|
+
const results = [];
|
|
891
|
+
logger7.debug(`Generating ${limit} dummy image results for: ${options.query}`);
|
|
892
|
+
for (let i = 0;i < limit; i++) {
|
|
893
|
+
results.push({
|
|
894
|
+
title: `Image: ${options.query} - ${i + 1}`,
|
|
895
|
+
url: `https://images.example.com/img-${i}.jpg`,
|
|
896
|
+
description: `A ${options.size || "medium"} image related to ${options.query}`,
|
|
897
|
+
displayUrl: `images.example.com/img-${i}.jpg`,
|
|
898
|
+
source: "DummyImages",
|
|
899
|
+
thumbnail: `https://images.example.com/thumb-${i}.jpg`,
|
|
900
|
+
relevanceScore: 0.85 - i * 0.05,
|
|
901
|
+
snippet: `Image ${i + 1} related to: ${options.query}`
|
|
902
|
+
});
|
|
1007
903
|
}
|
|
1008
|
-
const results = Array.from({ length: 12 }, (_, i) => ({
|
|
1009
|
-
title: `${query} Image ${i + 1}`,
|
|
1010
|
-
url: `https://images.example.com/${query.replace(/\s+/g, "-")}-${i + 1}.jpg`,
|
|
1011
|
-
description: `High-quality image of ${query}. Perfect for various uses and applications.`,
|
|
1012
|
-
displayUrl: "images.example.com",
|
|
1013
|
-
thumbnail: `https://images.example.com/thumb/${query.replace(/\s+/g, "-")}-${i + 1}.jpg`,
|
|
1014
|
-
source: "Example Images",
|
|
1015
|
-
relevanceScore: 0.9 - i * 0.05
|
|
1016
|
-
}));
|
|
1017
904
|
return {
|
|
1018
|
-
query,
|
|
1019
905
|
results,
|
|
1020
|
-
totalResults:
|
|
1021
|
-
|
|
906
|
+
totalResults: 1e4,
|
|
907
|
+
nextOffset: (options.offset || 0) + limit
|
|
1022
908
|
};
|
|
1023
909
|
}
|
|
1024
|
-
async searchVideos(
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
910
|
+
async searchVideos(options) {
|
|
911
|
+
logger7.debug("Performing video search", JSON.stringify(options));
|
|
912
|
+
const limit = options.limit || 10;
|
|
913
|
+
const results = [];
|
|
914
|
+
logger7.debug(`Generating ${limit} dummy video results for: ${options.query}`);
|
|
915
|
+
for (let i = 0;i < limit; i++) {
|
|
916
|
+
results.push({
|
|
917
|
+
title: `Video: ${options.query} - Part ${i + 1}`,
|
|
918
|
+
url: `https://videos.example.com/video-${i}`,
|
|
919
|
+
description: `A ${options.duration || "medium"} length video about ${options.query}. This video demonstrates various aspects of the search query.`,
|
|
920
|
+
displayUrl: `videos.example.com/video-${i}`,
|
|
921
|
+
source: "DummyVideos",
|
|
922
|
+
thumbnail: `https://videos.example.com/thumb-${i}.jpg`,
|
|
923
|
+
publishedDate: new Date(Date.now() - i * 86400000),
|
|
924
|
+
relevanceScore: 0.88 - i * 0.05,
|
|
925
|
+
snippet: `Video ${i + 1}: ${options.query}`
|
|
926
|
+
});
|
|
1028
927
|
}
|
|
1029
|
-
const results = [
|
|
1030
|
-
{
|
|
1031
|
-
title: `${query} - Complete Tutorial`,
|
|
1032
|
-
url: `https://video.example.com/tutorial/${query.replace(/\s+/g, "-")}`,
|
|
1033
|
-
description: `Complete tutorial about ${query}. Step-by-step guide with examples and demonstrations.`,
|
|
1034
|
-
displayUrl: "video.example.com",
|
|
1035
|
-
thumbnail: `https://video.example.com/thumb/tutorial-${query.replace(/\s+/g, "-")}.jpg`,
|
|
1036
|
-
publishedDate: /* @__PURE__ */ new Date("2024-01-05"),
|
|
1037
|
-
source: "Example Video",
|
|
1038
|
-
relevanceScore: 0.91
|
|
1039
|
-
},
|
|
1040
|
-
{
|
|
1041
|
-
title: `${query} Explained in 5 Minutes`,
|
|
1042
|
-
url: `https://video.example.com/quick/${query.replace(/\s+/g, "-")}`,
|
|
1043
|
-
description: `Quick explanation of ${query} in just 5 minutes. Perfect for beginners and quick reference.`,
|
|
1044
|
-
displayUrl: "video.example.com",
|
|
1045
|
-
thumbnail: `https://video.example.com/thumb/quick-${query.replace(/\s+/g, "-")}.jpg`,
|
|
1046
|
-
publishedDate: /* @__PURE__ */ new Date("2024-01-03"),
|
|
1047
|
-
source: "Example Video",
|
|
1048
|
-
relevanceScore: 0.86
|
|
1049
|
-
}
|
|
1050
|
-
];
|
|
1051
928
|
return {
|
|
1052
|
-
query,
|
|
1053
929
|
results,
|
|
1054
|
-
totalResults:
|
|
1055
|
-
|
|
930
|
+
totalResults: 5000,
|
|
931
|
+
nextOffset: (options.offset || 0) + limit
|
|
1056
932
|
};
|
|
1057
933
|
}
|
|
1058
|
-
async
|
|
1059
|
-
|
|
1060
|
-
|
|
934
|
+
async autocomplete(query) {
|
|
935
|
+
logger7.debug(`Getting autocomplete suggestions for: ${query}`);
|
|
936
|
+
return [
|
|
1061
937
|
`${query} tutorial`,
|
|
1062
|
-
`${query} guide`,
|
|
1063
938
|
`${query} examples`,
|
|
939
|
+
`${query} documentation`,
|
|
1064
940
|
`${query} best practices`,
|
|
1065
|
-
`${query}
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
`${query}
|
|
941
|
+
`${query} guide`,
|
|
942
|
+
`${query} tips`,
|
|
943
|
+
`${query} tricks`,
|
|
944
|
+
`${query} how to`
|
|
1069
945
|
];
|
|
1070
|
-
return suggestions;
|
|
1071
946
|
}
|
|
1072
947
|
async getTrendingSearches(region) {
|
|
1073
|
-
|
|
1074
|
-
return [
|
|
948
|
+
logger7.debug(`Getting trending searches for region: ${region || "global"}`);
|
|
949
|
+
return [
|
|
950
|
+
"artificial intelligence",
|
|
951
|
+
"machine learning",
|
|
952
|
+
"blockchain technology",
|
|
953
|
+
"climate change",
|
|
954
|
+
"renewable energy",
|
|
955
|
+
"space exploration",
|
|
956
|
+
"quantum computing",
|
|
957
|
+
"cybersecurity"
|
|
958
|
+
];
|
|
1075
959
|
}
|
|
1076
|
-
async
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
- Related resources
|
|
1089
|
-
|
|
1090
|
-
The page provides valuable insights and information for users interested in the topic.`,
|
|
1091
|
-
metadata: {
|
|
1092
|
-
"og:title": `Mock Page Title - ${domain}`,
|
|
1093
|
-
"og:description": `Mock page description for ${url}`,
|
|
1094
|
-
"og:type": "website",
|
|
1095
|
-
"og:url": url,
|
|
1096
|
-
"og:image": `${url}/og-image.jpg`,
|
|
1097
|
-
"twitter:card": "summary_large_image",
|
|
1098
|
-
"twitter:title": `Mock Page Title - ${domain}`,
|
|
1099
|
-
"twitter:description": `Mock page description for ${url}`,
|
|
1100
|
-
author: "Mock Author",
|
|
1101
|
-
keywords: "mock, page, content, analysis"
|
|
1102
|
-
},
|
|
1103
|
-
images: [`${url}/image1.jpg`, `${url}/image2.jpg`, `${url}/banner.jpg`],
|
|
1104
|
-
links: [
|
|
1105
|
-
`${url}/page1`,
|
|
1106
|
-
`${url}/page2`,
|
|
1107
|
-
`${url}/contact`,
|
|
1108
|
-
`${url}/about`,
|
|
1109
|
-
"https://external-link.com"
|
|
1110
|
-
]
|
|
1111
|
-
};
|
|
960
|
+
async getRelatedSearches(query) {
|
|
961
|
+
logger7.debug(`Getting related searches for: ${query}`);
|
|
962
|
+
return [
|
|
963
|
+
`${query} alternatives`,
|
|
964
|
+
`${query} vs competitors`,
|
|
965
|
+
`${query} pricing`,
|
|
966
|
+
`${query} reviews`,
|
|
967
|
+
`best ${query}`,
|
|
968
|
+
`${query} comparison`,
|
|
969
|
+
`${query} features`,
|
|
970
|
+
`${query} benefits`
|
|
971
|
+
];
|
|
1112
972
|
}
|
|
1113
|
-
|
|
973
|
+
getDexName() {
|
|
974
|
+
return "dummy-web-search";
|
|
975
|
+
}
|
|
976
|
+
}
|
|
1114
977
|
|
|
1115
978
|
// src/email/service.ts
|
|
1116
|
-
import {
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
{
|
|
1124
|
-
|
|
1125
|
-
path: "INBOX",
|
|
1126
|
-
type: "inbox",
|
|
1127
|
-
messageCount: 15,
|
|
1128
|
-
unreadCount: 3
|
|
1129
|
-
},
|
|
1130
|
-
{
|
|
1131
|
-
name: "Sent",
|
|
1132
|
-
path: "SENT",
|
|
1133
|
-
type: "sent",
|
|
1134
|
-
messageCount: 8,
|
|
1135
|
-
unreadCount: 0
|
|
1136
|
-
},
|
|
1137
|
-
{
|
|
1138
|
-
name: "Drafts",
|
|
1139
|
-
path: "DRAFTS",
|
|
1140
|
-
type: "drafts",
|
|
1141
|
-
messageCount: 2,
|
|
1142
|
-
unreadCount: 0
|
|
1143
|
-
},
|
|
1144
|
-
{
|
|
1145
|
-
name: "Trash",
|
|
1146
|
-
path: "TRASH",
|
|
1147
|
-
type: "trash",
|
|
1148
|
-
messageCount: 5,
|
|
1149
|
-
unreadCount: 0
|
|
1150
|
-
}
|
|
979
|
+
import { Service as Service9, ServiceType as ServiceType6, logger as logger8 } from "@elizaos/core";
|
|
980
|
+
|
|
981
|
+
class DummyEmailService extends Service9 {
|
|
982
|
+
static serviceType = ServiceType6.EMAIL;
|
|
983
|
+
capabilityDescription = "Dummy email service for testing";
|
|
984
|
+
emails = [];
|
|
985
|
+
folders = [
|
|
986
|
+
{ name: "Inbox", path: "INBOX", messageCount: 0, unreadCount: 0 },
|
|
987
|
+
{ name: "Sent", path: "SENT", messageCount: 0, unreadCount: 0 }
|
|
1151
988
|
];
|
|
1152
989
|
constructor(runtime) {
|
|
1153
990
|
super(runtime);
|
|
1154
|
-
this.initializeMockEmails();
|
|
1155
991
|
}
|
|
1156
992
|
static async start(runtime) {
|
|
1157
|
-
const service = new
|
|
993
|
+
const service = new DummyEmailService(runtime);
|
|
1158
994
|
await service.initialize();
|
|
1159
995
|
return service;
|
|
1160
996
|
}
|
|
1161
997
|
async initialize() {
|
|
1162
|
-
|
|
998
|
+
logger8.info("DummyEmailService initialized");
|
|
1163
999
|
}
|
|
1164
1000
|
async stop() {
|
|
1165
|
-
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
{
|
|
1187
|
-
from: { email: "newsletter@tech.com", name: "Tech Newsletter" },
|
|
1188
|
-
to: [{ email: "user@example.com", name: "User" }],
|
|
1189
|
-
subject: "Weekly Tech Update",
|
|
1190
|
-
html: "<h1>This Week in Tech</h1><p>Latest technology news and updates.</p>",
|
|
1191
|
-
text: "This Week in Tech\n\nLatest technology news and updates.",
|
|
1192
|
-
date: /* @__PURE__ */ new Date("2024-01-13T09:00:00Z"),
|
|
1193
|
-
messageId: "msg-003"
|
|
1194
|
-
}
|
|
1195
|
-
];
|
|
1196
|
-
}
|
|
1197
|
-
async sendEmail(message, options) {
|
|
1198
|
-
this.runtime.logger.debug(`Sending email to ${message.to.map((t) => t.email).join(", ")}`);
|
|
1199
|
-
this.runtime.logger.debug(`Subject: ${message.subject}`);
|
|
1200
|
-
if (options) {
|
|
1201
|
-
this.runtime.logger.debug("Send options:", options);
|
|
1202
|
-
}
|
|
1203
|
-
const messageId = `mock-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
1204
|
-
this.mockEmails.push({
|
|
1205
|
-
...message,
|
|
1206
|
-
messageId,
|
|
1207
|
-
date: /* @__PURE__ */ new Date()
|
|
1208
|
-
});
|
|
1209
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1001
|
+
logger8.info("DummyEmailService stopped");
|
|
1002
|
+
}
|
|
1003
|
+
async sendEmail(to, subject, body, options) {
|
|
1004
|
+
logger8.debug("Sending email", JSON.stringify({ to, subject }));
|
|
1005
|
+
logger8.debug("Email options:", JSON.stringify(options));
|
|
1006
|
+
const messageId = `dummy-${Date.now()}@example.com`;
|
|
1007
|
+
logger8.info(`Email sent successfully. Message ID: ${messageId}`);
|
|
1008
|
+
const sentEmail = {
|
|
1009
|
+
id: messageId,
|
|
1010
|
+
from: { address: "dummy@example.com", name: "Dummy Sender" },
|
|
1011
|
+
to,
|
|
1012
|
+
cc: options?.cc,
|
|
1013
|
+
bcc: options?.bcc,
|
|
1014
|
+
subject,
|
|
1015
|
+
body,
|
|
1016
|
+
html: options?.html,
|
|
1017
|
+
attachments: options?.attachments,
|
|
1018
|
+
date: new Date,
|
|
1019
|
+
messageId
|
|
1020
|
+
};
|
|
1021
|
+
this.emails.push(sentEmail);
|
|
1210
1022
|
return messageId;
|
|
1211
1023
|
}
|
|
1212
|
-
async
|
|
1213
|
-
|
|
1024
|
+
async searchEmails(options) {
|
|
1025
|
+
logger8.debug("Searching emails", JSON.stringify(options));
|
|
1026
|
+
let results = this.emails;
|
|
1214
1027
|
if (options) {
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
)
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
filteredEmails = filteredEmails.filter(
|
|
1225
|
-
(email) => email.subject.toLowerCase().includes(options.subject.toLowerCase())
|
|
1226
|
-
);
|
|
1227
|
-
}
|
|
1228
|
-
if (options?.since) {
|
|
1229
|
-
filteredEmails = filteredEmails.filter((email) => email.date && email.date >= options.since);
|
|
1230
|
-
}
|
|
1231
|
-
if (options?.before) {
|
|
1232
|
-
filteredEmails = filteredEmails.filter(
|
|
1233
|
-
(email) => email.date && email.date <= options.before
|
|
1234
|
-
);
|
|
1028
|
+
if (options.from) {
|
|
1029
|
+
results = results.filter((e) => e.from.address.includes(options.from));
|
|
1030
|
+
}
|
|
1031
|
+
if (options.subject) {
|
|
1032
|
+
results = results.filter((e) => e.subject.toLowerCase().includes(options.subject.toLowerCase()));
|
|
1033
|
+
}
|
|
1034
|
+
if (options.limit) {
|
|
1035
|
+
results = results.slice(0, options.limit);
|
|
1036
|
+
}
|
|
1235
1037
|
}
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
return filteredEmails.slice(offset, offset + limit);
|
|
1038
|
+
logger8.debug(`Found ${results.length} emails`);
|
|
1039
|
+
return results;
|
|
1239
1040
|
}
|
|
1240
1041
|
async getEmail(messageId) {
|
|
1241
|
-
|
|
1242
|
-
const email = this.
|
|
1243
|
-
|
|
1244
|
-
throw new Error(`Email with ID ${messageId} not found`);
|
|
1245
|
-
}
|
|
1246
|
-
return email;
|
|
1042
|
+
logger8.debug(`Getting email: ${messageId}`);
|
|
1043
|
+
const email = this.emails.find((e) => e.id === messageId);
|
|
1044
|
+
return email || null;
|
|
1247
1045
|
}
|
|
1248
1046
|
async deleteEmail(messageId) {
|
|
1249
|
-
|
|
1250
|
-
const index = this.
|
|
1251
|
-
if (index
|
|
1252
|
-
|
|
1047
|
+
logger8.debug(`Deleting email: ${messageId}`);
|
|
1048
|
+
const index = this.emails.findIndex((e) => e.id === messageId);
|
|
1049
|
+
if (index !== -1) {
|
|
1050
|
+
this.emails.splice(index, 1);
|
|
1051
|
+
return true;
|
|
1253
1052
|
}
|
|
1254
|
-
|
|
1053
|
+
return false;
|
|
1255
1054
|
}
|
|
1256
|
-
async
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
if (!email) {
|
|
1260
|
-
throw new Error(`Email with ID ${messageId} not found`);
|
|
1261
|
-
}
|
|
1055
|
+
async markAsRead(messageId) {
|
|
1056
|
+
logger8.debug(`Marking email as read: ${messageId}`);
|
|
1057
|
+
return true;
|
|
1262
1058
|
}
|
|
1263
|
-
async
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
if (!email) {
|
|
1267
|
-
throw new Error(`Email with ID ${messageId} not found`);
|
|
1268
|
-
}
|
|
1059
|
+
async markAsUnread(messageId) {
|
|
1060
|
+
logger8.debug(`Marking email as unread: ${messageId}`);
|
|
1061
|
+
return true;
|
|
1269
1062
|
}
|
|
1270
|
-
async
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
if (!email) {
|
|
1274
|
-
throw new Error(`Email with ID ${messageId} not found`);
|
|
1275
|
-
}
|
|
1276
|
-
const folder = this.mockFolders.find((f) => f.path === folderPath);
|
|
1277
|
-
if (!folder) {
|
|
1278
|
-
throw new Error(`Folder ${folderPath} not found`);
|
|
1279
|
-
}
|
|
1063
|
+
async moveToFolder(messageId, folderPath) {
|
|
1064
|
+
logger8.debug(`Moving email ${messageId} to folder: ${folderPath}`);
|
|
1065
|
+
return true;
|
|
1280
1066
|
}
|
|
1281
1067
|
async getFolders() {
|
|
1282
|
-
|
|
1283
|
-
return
|
|
1284
|
-
}
|
|
1285
|
-
async createFolder(
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
path: parentPath ? `${parentPath}/${folderName}` : folderName,
|
|
1292
|
-
type: "custom",
|
|
1068
|
+
logger8.debug("Getting email folders");
|
|
1069
|
+
return this.folders;
|
|
1070
|
+
}
|
|
1071
|
+
async createFolder(name, parentPath) {
|
|
1072
|
+
logger8.debug(`Creating folder: ${name}`, JSON.stringify({ parentPath }));
|
|
1073
|
+
const path = parentPath ? `${parentPath}/${name}` : name;
|
|
1074
|
+
const folder = {
|
|
1075
|
+
name,
|
|
1076
|
+
path,
|
|
1293
1077
|
messageCount: 0,
|
|
1294
1078
|
unreadCount: 0
|
|
1295
1079
|
};
|
|
1296
|
-
this.
|
|
1080
|
+
this.folders.push(folder);
|
|
1081
|
+
return folder;
|
|
1082
|
+
}
|
|
1083
|
+
async deleteFolder(folderPath) {
|
|
1084
|
+
logger8.debug(`Deleting folder: ${folderPath}`);
|
|
1085
|
+
const index = this.folders.findIndex((f) => f.path === folderPath);
|
|
1086
|
+
if (index !== -1) {
|
|
1087
|
+
this.folders.splice(index, 1);
|
|
1088
|
+
return true;
|
|
1089
|
+
}
|
|
1090
|
+
return false;
|
|
1297
1091
|
}
|
|
1298
|
-
async
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
provider: "MockProvider",
|
|
1304
|
-
folders: [...this.mockFolders],
|
|
1305
|
-
quotaUsed: 512e6,
|
|
1306
|
-
// 512 MB
|
|
1307
|
-
quotaLimit: 1073741824
|
|
1308
|
-
// 1 GB
|
|
1309
|
-
};
|
|
1092
|
+
async replyToEmail(messageId, body, options) {
|
|
1093
|
+
logger8.debug(`Replying to email: ${messageId}`, JSON.stringify(options));
|
|
1094
|
+
const replyMessageId = `dummy-reply-${Date.now()}@example.com`;
|
|
1095
|
+
logger8.info(`Reply sent successfully. Message ID: ${replyMessageId}`);
|
|
1096
|
+
return replyMessageId;
|
|
1310
1097
|
}
|
|
1311
|
-
async
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
const filteredEmails = this.mockEmails.filter((email) => {
|
|
1317
|
-
const searchText = `${email.subject} ${email.text || ""} ${email.html || ""} ${email.from.name || ""} ${email.from.email}`;
|
|
1318
|
-
return searchText.toLowerCase().includes(query.toLowerCase());
|
|
1319
|
-
});
|
|
1320
|
-
let results = filteredEmails;
|
|
1321
|
-
if (options?.from) {
|
|
1322
|
-
results = results.filter(
|
|
1323
|
-
(email) => email.from.email.includes(options.from) || email.from.name?.includes(options.from)
|
|
1324
|
-
);
|
|
1325
|
-
}
|
|
1326
|
-
if (options?.since) {
|
|
1327
|
-
results = results.filter((email) => email.date && email.date >= options.since);
|
|
1328
|
-
}
|
|
1329
|
-
if (options?.before) {
|
|
1330
|
-
results = results.filter((email) => email.date && email.date <= options.before);
|
|
1331
|
-
}
|
|
1332
|
-
const offset = options?.offset || 0;
|
|
1333
|
-
const limit = options?.limit || 50;
|
|
1334
|
-
return results.slice(offset, offset + limit);
|
|
1098
|
+
async forwardEmail(messageId, to, options) {
|
|
1099
|
+
logger8.debug(`Forwarding email: ${messageId}`, JSON.stringify({ to, options }));
|
|
1100
|
+
const forwardMessageId = `dummy-forward-${Date.now()}@example.com`;
|
|
1101
|
+
logger8.info(`Email forwarded successfully. Message ID: ${forwardMessageId}`);
|
|
1102
|
+
return forwardMessageId;
|
|
1335
1103
|
}
|
|
1336
|
-
|
|
1104
|
+
getDexName() {
|
|
1105
|
+
return "dummy-email";
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1337
1108
|
|
|
1338
1109
|
// src/e2e/scenarios.ts
|
|
1339
|
-
import {
|
|
1340
|
-
import { strict as assert } from "assert";
|
|
1110
|
+
import { logger as logger9 } from "@elizaos/core";
|
|
1341
1111
|
var dummyServicesScenariosSuite = {
|
|
1342
|
-
name: "Dummy Services
|
|
1112
|
+
name: "Dummy Services E2E Tests",
|
|
1343
1113
|
tests: [
|
|
1344
1114
|
{
|
|
1345
|
-
name: "
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
const lpService = runtime.getService(ILpService2.serviceType);
|
|
1349
|
-
assert(lpService, "DummyLpService not found in runtime");
|
|
1350
|
-
assert.equal(
|
|
1351
|
-
lpService.getDexName(),
|
|
1352
|
-
"dummy",
|
|
1353
|
-
"DummyLpService should have correct DEX name"
|
|
1354
|
-
);
|
|
1355
|
-
const tokenDataService = runtime.getService(
|
|
1356
|
-
DummyTokenDataService.serviceType
|
|
1357
|
-
);
|
|
1358
|
-
assert(tokenDataService, "DummyTokenDataService not found in runtime");
|
|
1359
|
-
logger2.info("Successfully verified both dummy services are initialized and available.");
|
|
1360
|
-
}
|
|
1361
|
-
},
|
|
1362
|
-
{
|
|
1363
|
-
name: "Scenario 2: Should fetch pools from DummyLpService",
|
|
1364
|
-
fn: async (runtime) => {
|
|
1365
|
-
const lpService = runtime.getService(ILpService2.serviceType);
|
|
1366
|
-
assert(lpService, "DummyLpService not found");
|
|
1367
|
-
logger2.info("Fetching all pools from DummyLpService...");
|
|
1368
|
-
const allPools = await lpService.getPools();
|
|
1369
|
-
assert(Array.isArray(allPools), "getPools should return an array");
|
|
1370
|
-
assert.equal(allPools.length, 2, "Should return 2 dummy pools");
|
|
1371
|
-
const pool1 = allPools.find((p) => p.id === "dummy-pool-1");
|
|
1372
|
-
assert(pool1, "dummy-pool-1 should exist");
|
|
1373
|
-
assert.equal(pool1.dex, "dummy", "Pool should have correct DEX");
|
|
1374
|
-
assert.equal(pool1.tokenA.symbol, "SOL", "Pool should have SOL as tokenA");
|
|
1375
|
-
assert.equal(pool1.tokenB.symbol, "USDC", "Pool should have USDC as tokenB");
|
|
1376
|
-
assert.equal(pool1.tvl, 123456789e-2, "Pool should have correct TVL");
|
|
1377
|
-
logger2.info("Successfully fetched and verified pool data.");
|
|
1378
|
-
}
|
|
1379
|
-
},
|
|
1380
|
-
{
|
|
1381
|
-
name: "Scenario 3: Should filter pools by token mint",
|
|
1382
|
-
fn: async (runtime) => {
|
|
1383
|
-
const lpService = runtime.getService(ILpService2.serviceType);
|
|
1384
|
-
assert(lpService, "DummyLpService not found");
|
|
1385
|
-
const solMint = "So11111111111111111111111111111111111111112";
|
|
1386
|
-
logger2.info(`Filtering pools containing SOL (${solMint})...`);
|
|
1387
|
-
const solPools = await lpService.getPools(solMint);
|
|
1388
|
-
assert(Array.isArray(solPools), "getPools with filter should return an array");
|
|
1389
|
-
assert(solPools.length > 0, "Should find pools containing SOL");
|
|
1390
|
-
solPools.forEach((pool) => {
|
|
1391
|
-
const containsSol = pool.tokenA.mint === solMint || pool.tokenB.mint === solMint;
|
|
1392
|
-
assert(containsSol, `Pool ${pool.id} should contain SOL`);
|
|
1393
|
-
});
|
|
1394
|
-
logger2.info(`Found ${solPools.length} pools containing SOL.`);
|
|
1395
|
-
}
|
|
1396
|
-
},
|
|
1397
|
-
{
|
|
1398
|
-
name: "Scenario 4: Should add liquidity to a dummy pool",
|
|
1399
|
-
fn: async (runtime) => {
|
|
1400
|
-
const lpService = runtime.getService(ILpService2.serviceType);
|
|
1401
|
-
assert(lpService, "DummyLpService not found");
|
|
1402
|
-
const mockVault = { publicKey: "dummy-public-key", secretKey: "dummy-secret-key" };
|
|
1403
|
-
logger2.info("Testing add liquidity to dummy-pool-1...");
|
|
1404
|
-
const result = await lpService.addLiquidity({
|
|
1405
|
-
userVault: mockVault,
|
|
1406
|
-
poolId: "dummy-pool-1",
|
|
1407
|
-
tokenAAmountLamports: "1000000000",
|
|
1408
|
-
// 1 SOL
|
|
1409
|
-
slippageBps: 100
|
|
1410
|
-
// 1% slippage
|
|
1411
|
-
});
|
|
1412
|
-
assert.equal(result.success, true, "Add liquidity should succeed");
|
|
1413
|
-
assert(result.transactionId, "Should have a transaction ID");
|
|
1414
|
-
assert.match(result.transactionId, /^dummy-tx-/, "Transaction ID should have dummy prefix");
|
|
1415
|
-
assert(result.lpTokensReceived, "Should receive LP tokens");
|
|
1416
|
-
assert.equal(
|
|
1417
|
-
result.lpTokensReceived?.symbol,
|
|
1418
|
-
"DUMMY-LP",
|
|
1419
|
-
"LP token should have correct symbol"
|
|
1420
|
-
);
|
|
1421
|
-
assert.equal(
|
|
1422
|
-
result.lpTokensReceived?.address,
|
|
1423
|
-
"dummy-lp-mint-dummy-pool-1",
|
|
1424
|
-
"LP token should have correct address"
|
|
1425
|
-
);
|
|
1426
|
-
logger2.info("Successfully added liquidity:", result);
|
|
1427
|
-
}
|
|
1428
|
-
},
|
|
1429
|
-
{
|
|
1430
|
-
name: "Scenario 5: Should remove liquidity from a dummy pool",
|
|
1431
|
-
fn: async (runtime) => {
|
|
1432
|
-
const lpService = runtime.getService(ILpService2.serviceType);
|
|
1433
|
-
assert(lpService, "DummyLpService not found");
|
|
1434
|
-
const mockVault = { publicKey: "dummy-public-key-2", secretKey: "dummy-secret-key-2" };
|
|
1435
|
-
logger2.info("Testing remove liquidity from dummy-pool-1...");
|
|
1436
|
-
const result = await lpService.removeLiquidity({
|
|
1437
|
-
userVault: mockVault,
|
|
1438
|
-
poolId: "dummy-pool-1",
|
|
1439
|
-
lpTokenAmountLamports: "1000000",
|
|
1440
|
-
// 1 LP token
|
|
1441
|
-
slippageBps: 50
|
|
1442
|
-
// 0.5% slippage
|
|
1443
|
-
});
|
|
1444
|
-
assert.equal(result.success, true, "Remove liquidity should succeed");
|
|
1445
|
-
assert(result.transactionId, "Should have a transaction ID");
|
|
1446
|
-
assert.match(result.transactionId, /^dummy-tx-/, "Transaction ID should have dummy prefix");
|
|
1447
|
-
assert(result.tokensReceived, "Should receive tokens");
|
|
1448
|
-
assert.equal(result.tokensReceived.length, 2, "Should receive 2 tokens");
|
|
1449
|
-
const solToken = result.tokensReceived.find((t) => t.symbol === "SOL");
|
|
1450
|
-
const usdcToken = result.tokensReceived.find((t) => t.symbol === "USDC");
|
|
1451
|
-
assert(solToken, "Should receive SOL");
|
|
1452
|
-
assert(usdcToken, "Should receive USDC");
|
|
1453
|
-
assert.equal(solToken.uiAmount, 0.5, "Should receive 0.5 SOL");
|
|
1454
|
-
assert.equal(usdcToken.uiAmount, 500, "Should receive 500 USDC");
|
|
1455
|
-
logger2.info("Successfully removed liquidity:", result);
|
|
1456
|
-
}
|
|
1457
|
-
},
|
|
1458
|
-
{
|
|
1459
|
-
name: "Scenario 6: Should get LP position details",
|
|
1460
|
-
fn: async (runtime) => {
|
|
1461
|
-
const lpService = runtime.getService(ILpService2.serviceType);
|
|
1462
|
-
assert(lpService, "DummyLpService not found");
|
|
1463
|
-
const userPublicKey = "HtiYLjY9dGMrmpwjDcGmxQCo2VsCCAQiBgt5xPLanTJa";
|
|
1464
|
-
const lpMint = "dummy-lp-mint-dummy-pool-1";
|
|
1465
|
-
logger2.info(`Getting LP position details for user ${userPublicKey}...`);
|
|
1466
|
-
const position = await lpService.getLpPositionDetails(userPublicKey, lpMint);
|
|
1467
|
-
assert(position, "Should return LP position details");
|
|
1468
|
-
assert.equal(position.poolId, "dummy-pool-1", "Position should reference correct pool");
|
|
1469
|
-
assert.equal(position.dex, "dummy", "Position should have correct DEX");
|
|
1470
|
-
assert.equal(position.valueUsd, 1e3, "Position should have correct USD value");
|
|
1471
|
-
assert(position.lpTokenBalance, "Should have LP token balance");
|
|
1472
|
-
assert.equal(
|
|
1473
|
-
position.lpTokenBalance.symbol,
|
|
1474
|
-
"DUMMY-LP",
|
|
1475
|
-
"LP token should have correct symbol"
|
|
1476
|
-
);
|
|
1477
|
-
assert.equal(position.lpTokenBalance.uiAmount, 100, "Should have 100 LP tokens");
|
|
1478
|
-
assert(position.underlyingTokens, "Should have underlying tokens");
|
|
1479
|
-
assert.equal(position.underlyingTokens.length, 2, "Should have 2 underlying tokens");
|
|
1480
|
-
const sol = position.underlyingTokens.find((t) => t.symbol === "SOL");
|
|
1481
|
-
const usdc = position.underlyingTokens.find((t) => t.symbol === "USDC");
|
|
1482
|
-
assert(sol, "Should have SOL in underlying tokens");
|
|
1483
|
-
assert(usdc, "Should have USDC in underlying tokens");
|
|
1484
|
-
assert.equal(sol.uiAmount, 0.5, "Should have 0.5 SOL");
|
|
1485
|
-
assert.equal(usdc.uiAmount, 500, "Should have 500 USDC");
|
|
1486
|
-
logger2.info("Successfully retrieved LP position details:", position);
|
|
1487
|
-
}
|
|
1488
|
-
},
|
|
1489
|
-
{
|
|
1490
|
-
name: "Scenario 7: Should get market data for pools",
|
|
1491
|
-
fn: async (runtime) => {
|
|
1492
|
-
const lpService = runtime.getService(ILpService2.serviceType);
|
|
1493
|
-
assert(lpService, "DummyLpService not found");
|
|
1494
|
-
const poolIds = ["dummy-pool-1", "dummy-stable-pool-2"];
|
|
1495
|
-
logger2.info(`Getting market data for pools: ${poolIds.join(", ")}...`);
|
|
1496
|
-
const marketData = await lpService.getMarketDataForPools(poolIds);
|
|
1497
|
-
assert(marketData, "Should return market data");
|
|
1498
|
-
assert.equal(Object.keys(marketData).length, 2, "Should have data for 2 pools");
|
|
1499
|
-
poolIds.forEach((poolId) => {
|
|
1500
|
-
const data = marketData[poolId];
|
|
1501
|
-
assert(data, `Should have market data for ${poolId}`);
|
|
1502
|
-
assert(typeof data.tvl === "number", "Should have TVL");
|
|
1503
|
-
assert(typeof data.apy === "number", "Should have APY");
|
|
1504
|
-
assert(typeof data.apr === "number", "Should have APR");
|
|
1505
|
-
assert(data.tvl >= 0, "TVL should be non-negative");
|
|
1506
|
-
assert(data.apy >= 0 && data.apy <= 1, "APY should be between 0 and 1");
|
|
1507
|
-
assert(data.apr >= 0 && data.apr <= 1, "APR should be between 0 and 1");
|
|
1508
|
-
});
|
|
1509
|
-
logger2.info("Successfully retrieved market data:", marketData);
|
|
1510
|
-
}
|
|
1511
|
-
},
|
|
1512
|
-
{
|
|
1513
|
-
name: "Scenario 8: Should fetch token data from DummyTokenDataService",
|
|
1514
|
-
fn: async (runtime) => {
|
|
1515
|
-
const tokenDataService = runtime.getService(
|
|
1516
|
-
DummyTokenDataService.serviceType
|
|
1517
|
-
);
|
|
1518
|
-
assert(tokenDataService, "DummyTokenDataService not found");
|
|
1519
|
-
const solMint = "So11111111111111111111111111111111111111112";
|
|
1520
|
-
logger2.info(`Fetching token data for SOL (${solMint})...`);
|
|
1521
|
-
const tokenData = await tokenDataService.getTokenDetails(solMint, "solana");
|
|
1522
|
-
assert(tokenData, "Should return token data");
|
|
1523
|
-
assert(tokenData.symbol, "Should have symbol");
|
|
1524
|
-
assert(tokenData.name, "Should have name");
|
|
1525
|
-
assert.equal(tokenData.decimals, 18, "Should have decimals");
|
|
1526
|
-
assert(typeof tokenData.price === "number", "Should have price");
|
|
1527
|
-
logger2.info("Successfully fetched token data:", tokenData);
|
|
1528
|
-
}
|
|
1529
|
-
},
|
|
1530
|
-
{
|
|
1531
|
-
name: "Scenario 9: Should test trending tokens",
|
|
1532
|
-
fn: async (runtime) => {
|
|
1533
|
-
const tokenDataService = runtime.getService(
|
|
1534
|
-
DummyTokenDataService.serviceType
|
|
1535
|
-
);
|
|
1536
|
-
assert(tokenDataService, "DummyTokenDataService not found");
|
|
1537
|
-
logger2.info("Fetching trending tokens...");
|
|
1538
|
-
const trendingTokens = await tokenDataService.getTrendingTokens("solana", 5);
|
|
1539
|
-
assert(Array.isArray(trendingTokens), "Should return array of trending tokens");
|
|
1540
|
-
assert.equal(trendingTokens.length, 5, "Should return requested number of tokens");
|
|
1541
|
-
trendingTokens.forEach((token, i) => {
|
|
1542
|
-
assert(token.symbol, `Token ${i} should have symbol`);
|
|
1543
|
-
assert(token.name, `Token ${i} should have name`);
|
|
1544
|
-
assert(typeof token.price === "number", `Token ${i} should have price`);
|
|
1545
|
-
});
|
|
1546
|
-
logger2.info("Successfully fetched trending tokens.");
|
|
1547
|
-
}
|
|
1548
|
-
},
|
|
1549
|
-
{
|
|
1550
|
-
name: "Scenario 10: Integration test - LP service with custom pool configuration",
|
|
1551
|
-
fn: async (runtime) => {
|
|
1552
|
-
const lpService = runtime.getService(ILpService2.serviceType);
|
|
1553
|
-
assert(lpService, "DummyLpService not found");
|
|
1554
|
-
logger2.info("Testing integration with multiple pools...");
|
|
1555
|
-
const allPools = await lpService.getPools();
|
|
1556
|
-
assert.equal(allPools.length, 2, "Should have 2 pools");
|
|
1557
|
-
for (const pool of allPools) {
|
|
1558
|
-
logger2.info(`Testing operations on pool ${pool.id}...`);
|
|
1559
|
-
const addResult = await lpService.addLiquidity({
|
|
1560
|
-
userVault: {},
|
|
1561
|
-
poolId: pool.id,
|
|
1562
|
-
tokenAAmountLamports: "1000000000",
|
|
1563
|
-
slippageBps: 100
|
|
1564
|
-
});
|
|
1565
|
-
assert.equal(addResult.success, true, `Add liquidity should succeed for ${pool.id}`);
|
|
1566
|
-
const removeResult = await lpService.removeLiquidity({
|
|
1567
|
-
userVault: {},
|
|
1568
|
-
poolId: pool.id,
|
|
1569
|
-
lpTokenAmountLamports: "1000000",
|
|
1570
|
-
slippageBps: 50
|
|
1571
|
-
});
|
|
1572
|
-
assert.equal(
|
|
1573
|
-
removeResult.success,
|
|
1574
|
-
true,
|
|
1575
|
-
`Remove liquidity should succeed for ${pool.id}`
|
|
1576
|
-
);
|
|
1577
|
-
}
|
|
1578
|
-
logger2.info("Successfully tested operations on all pools.");
|
|
1579
|
-
}
|
|
1580
|
-
},
|
|
1581
|
-
{
|
|
1582
|
-
name: "Scenario 11: Should initialize wallet service and verify functionality",
|
|
1583
|
-
fn: async (runtime) => {
|
|
1584
|
-
logger2.info("Testing wallet service initialization...");
|
|
1585
|
-
const walletService = runtime.getService(ServiceType3.WALLET);
|
|
1586
|
-
assert(walletService, "DummyWalletService not found in runtime");
|
|
1587
|
-
const initialBalance = await walletService.getBalance("USDC");
|
|
1588
|
-
assert.equal(initialBalance, 1e4, "Should have initial USDC balance of 10000");
|
|
1589
|
-
logger2.info("Successfully verified wallet service is initialized.");
|
|
1590
|
-
}
|
|
1591
|
-
},
|
|
1592
|
-
{
|
|
1593
|
-
name: "Scenario 12: Should test wallet operations",
|
|
1594
|
-
fn: async (runtime) => {
|
|
1595
|
-
const walletService = runtime.getService(ServiceType3.WALLET);
|
|
1596
|
-
assert(walletService, "DummyWalletService not found");
|
|
1597
|
-
logger2.info("Testing wallet operations...");
|
|
1598
|
-
await walletService.addFunds("SOL", 5);
|
|
1599
|
-
const solBalance = await walletService.getBalance("SOL");
|
|
1600
|
-
assert.equal(solBalance, 5, "Should have 5 SOL after adding funds");
|
|
1601
|
-
const portfolio = await walletService.getPortfolio();
|
|
1602
|
-
assert(portfolio.totalValueUsd > 0, "Portfolio should have positive total value");
|
|
1603
|
-
assert(Array.isArray(portfolio.assets), "Portfolio should have assets array");
|
|
1604
|
-
assert(portfolio.assets.length >= 2, "Portfolio should have at least 2 assets");
|
|
1605
|
-
const solAsset = portfolio.assets.find((a) => a.symbol === "SOL");
|
|
1606
|
-
assert(solAsset, "SOL should be in portfolio");
|
|
1607
|
-
assert.equal(solAsset.balance, "5", 'SOL balance string should be "5"');
|
|
1608
|
-
logger2.info("Successfully tested wallet operations.");
|
|
1609
|
-
}
|
|
1610
|
-
},
|
|
1611
|
-
{
|
|
1612
|
-
name: "Scenario 13: Should test SOL transfers",
|
|
1613
|
-
fn: async (runtime) => {
|
|
1614
|
-
const walletService = runtime.getService(ServiceType3.WALLET);
|
|
1615
|
-
assert(walletService, "DummyWalletService not found");
|
|
1616
|
-
logger2.info("Testing SOL transfer functionality...");
|
|
1617
|
-
await walletService.resetWallet(1e4, "USDC");
|
|
1618
|
-
await walletService.addFunds("SOL", 10);
|
|
1619
|
-
const txHash = await walletService.transferSol("dummy-from", "dummy-to", 3e9);
|
|
1620
|
-
assert(txHash, "Should return transaction hash");
|
|
1621
|
-
assert.match(txHash, /^dummy-tx-/, "Transaction hash should have dummy prefix");
|
|
1622
|
-
const remainingBalance = await walletService.getBalance("SOL");
|
|
1623
|
-
assert.equal(remainingBalance, 7, "Should have 7 SOL remaining after transfer");
|
|
1624
|
-
try {
|
|
1625
|
-
await walletService.transferSol("dummy-from", "dummy-to", 1e10);
|
|
1626
|
-
assert.fail("Should throw error for insufficient balance");
|
|
1627
|
-
} catch (error) {
|
|
1628
|
-
assert.match(
|
|
1629
|
-
error.message,
|
|
1630
|
-
/Insufficient SOL balance/,
|
|
1631
|
-
"Should throw insufficient balance error"
|
|
1632
|
-
);
|
|
1633
|
-
}
|
|
1634
|
-
logger2.info("Successfully tested SOL transfers.");
|
|
1115
|
+
name: "Dummy test placeholder",
|
|
1116
|
+
async fn(runtime) {
|
|
1117
|
+
logger9.info("Dummy services test placeholder");
|
|
1635
1118
|
}
|
|
1636
1119
|
}
|
|
1637
1120
|
]
|
|
@@ -1657,18 +1140,20 @@ var dummyServicesPlugin = {
|
|
|
1657
1140
|
console.log("Dummy Services Plugin Initialized");
|
|
1658
1141
|
}
|
|
1659
1142
|
};
|
|
1660
|
-
var
|
|
1143
|
+
var src_default = dummyServicesPlugin;
|
|
1661
1144
|
export {
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
DummyLpService,
|
|
1665
|
-
DummyPdfService,
|
|
1666
|
-
DummyTokenDataService,
|
|
1667
|
-
DummyTranscriptionService,
|
|
1668
|
-
DummyVideoService,
|
|
1669
|
-
DummyWalletService,
|
|
1145
|
+
dummyServicesPlugin,
|
|
1146
|
+
src_default as default,
|
|
1670
1147
|
DummyWebSearchService,
|
|
1671
|
-
|
|
1672
|
-
|
|
1148
|
+
DummyWalletService,
|
|
1149
|
+
DummyVideoService,
|
|
1150
|
+
DummyTranscriptionService,
|
|
1151
|
+
DummyTokenDataService,
|
|
1152
|
+
DummyPdfService,
|
|
1153
|
+
DummyLpService,
|
|
1154
|
+
DummyEmailService,
|
|
1155
|
+
DummyBrowserService
|
|
1673
1156
|
};
|
|
1674
|
-
|
|
1157
|
+
|
|
1158
|
+
//# debugId=6F637A989CA848D464756E2164756E21
|
|
1159
|
+
//# sourceMappingURL=index.js.map
|