decharge-scout 2.2.0 → 2.5.0
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/index.js +18 -5
- package/package.json +1 -1
- package/src/wallet-server.js +2 -1
package/index.js
CHANGED
|
@@ -175,15 +175,28 @@ async function main(options) {
|
|
|
175
175
|
console.log(chalk.gray('You have 30 seconds to respond...'));
|
|
176
176
|
|
|
177
177
|
try {
|
|
178
|
+
let timeoutId;
|
|
179
|
+
let hasResolved = false;
|
|
180
|
+
|
|
178
181
|
// Create a promise that auto-resolves after 30 seconds
|
|
179
182
|
const timeoutPromise = new Promise((resolve) => {
|
|
180
|
-
setTimeout(() => {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
+
timeoutId = setTimeout(() => {
|
|
184
|
+
if (!hasResolved) {
|
|
185
|
+
hasResolved = true;
|
|
186
|
+
console.log(chalk.yellow('\n⏱️ Timeout - using detected location...'));
|
|
187
|
+
resolve('__TIMEOUT__');
|
|
188
|
+
}
|
|
183
189
|
}, 30000);
|
|
184
190
|
});
|
|
185
191
|
|
|
186
|
-
const questionPromise = question('Enter custom location (or press Enter): ')
|
|
192
|
+
const questionPromise = question('Enter custom location (or press Enter): ').then(answer => {
|
|
193
|
+
if (!hasResolved) {
|
|
194
|
+
hasResolved = true;
|
|
195
|
+
clearTimeout(timeoutId);
|
|
196
|
+
return answer;
|
|
197
|
+
}
|
|
198
|
+
return '__TIMEOUT__'; // If timeout already occurred, ignore this answer
|
|
199
|
+
});
|
|
187
200
|
|
|
188
201
|
const customLocation = await Promise.race([questionPromise, timeoutPromise]);
|
|
189
202
|
|
|
@@ -246,7 +259,7 @@ async function main(options) {
|
|
|
246
259
|
});
|
|
247
260
|
|
|
248
261
|
// Main query cycle
|
|
249
|
-
await runQueryCycle(
|
|
262
|
+
await runQueryCycle(walletAddress, agentName, location, options);
|
|
250
263
|
|
|
251
264
|
} catch (error) {
|
|
252
265
|
console.error(chalk.red(`\n❌ Error: ${error.message}`));
|
package/package.json
CHANGED
package/src/wallet-server.js
CHANGED
|
@@ -13,7 +13,8 @@ import { dirname } from 'path';
|
|
|
13
13
|
import open from 'open';
|
|
14
14
|
import chalk from 'chalk';
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// WebSocket.Server is the correct export for ws package
|
|
17
|
+
const WebSocketServer = WebSocket.Server;
|
|
17
18
|
|
|
18
19
|
const __filename = fileURLToPath(import.meta.url);
|
|
19
20
|
const __dirname = dirname(__filename);
|