@highway1/cli 0.1.24 → 0.1.26
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/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/join.ts +12 -0
- package/src/commands/send.ts +10 -1
package/dist/index.js
CHANGED
|
@@ -118282,6 +118282,14 @@ function registerJoinCommand(program2) {
|
|
|
118282
118282
|
const dht = createDHTOperations(node.libp2p);
|
|
118283
118283
|
await dht.publishAgentCard(signedCard);
|
|
118284
118284
|
cardSpin.succeed("Agent Card published!");
|
|
118285
|
+
const pingInterval = setInterval(async () => {
|
|
118286
|
+
for (const peer of node.libp2p.getPeers()) {
|
|
118287
|
+
try {
|
|
118288
|
+
await node.libp2p.services.ping.ping(peer);
|
|
118289
|
+
} catch {
|
|
118290
|
+
}
|
|
118291
|
+
}
|
|
118292
|
+
}, 3e4);
|
|
118285
118293
|
const router = createMessageRouter(
|
|
118286
118294
|
node.libp2p,
|
|
118287
118295
|
async () => true,
|
|
@@ -118339,6 +118347,7 @@ function registerJoinCommand(program2) {
|
|
|
118339
118347
|
process.on("SIGINT", async () => {
|
|
118340
118348
|
console.log();
|
|
118341
118349
|
const stopSpin = spinner("Stopping node...");
|
|
118350
|
+
clearInterval(pingInterval);
|
|
118342
118351
|
await router.stop();
|
|
118343
118352
|
await node.stop();
|
|
118344
118353
|
stopSpin.succeed("Node stopped");
|
|
@@ -118503,9 +118512,16 @@ function registerSendCommand(program2) {
|
|
|
118503
118512
|
bootstrapPeers,
|
|
118504
118513
|
enableDHT: true
|
|
118505
118514
|
});
|
|
118515
|
+
const identifyDone = new Promise((resolve) => {
|
|
118516
|
+
const timeout = setTimeout(resolve, 12e3);
|
|
118517
|
+
node.libp2p.addEventListener("peer:identify", () => {
|
|
118518
|
+
clearTimeout(timeout);
|
|
118519
|
+
setTimeout(resolve, 500);
|
|
118520
|
+
}, { once: true });
|
|
118521
|
+
});
|
|
118506
118522
|
await node.start();
|
|
118507
118523
|
spin.text = "Connecting to network...";
|
|
118508
|
-
await
|
|
118524
|
+
await identifyDone;
|
|
118509
118525
|
const dht = createDHTOperations(node.libp2p);
|
|
118510
118526
|
const router = createMessageRouter(
|
|
118511
118527
|
node.libp2p,
|