@highway1/cli 0.1.24 → 0.1.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highway1/cli",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "description": "CLI tool for Clawiverse network",
5
5
  "type": "module",
6
6
  "bin": {
@@ -113,6 +113,17 @@ export function registerJoinCommand(program: Command): void {
113
113
 
114
114
  cardSpin.succeed('Agent Card published!');
115
115
 
116
+ // Keep connection alive by pinging bootstrap peers periodically
117
+ const pingInterval = setInterval(async () => {
118
+ for (const peer of node.libp2p.getPeers()) {
119
+ try {
120
+ await node.libp2p.services.ping.ping(peer);
121
+ } catch {
122
+ // ignore ping failures
123
+ }
124
+ }
125
+ }, 30000); // ping every 30s
126
+
116
127
  // Register message handlers for incoming messages
117
128
  const router = createMessageRouter(
118
129
  node.libp2p,
@@ -183,6 +194,7 @@ export function registerJoinCommand(program: Command): void {
183
194
  process.on('SIGINT', async () => {
184
195
  console.log();
185
196
  const stopSpin = spinner('Stopping node...');
197
+ clearInterval(pingInterval);
186
198
  await router.stop();
187
199
  await node.stop();
188
200
  stopSpin.succeed('Node stopped');
@@ -55,10 +55,19 @@ export function registerSendCommand(program: Command): void {
55
55
  enableDHT: true,
56
56
  });
57
57
 
58
+ // Register peer:identify listener BEFORE start() so we don't miss the event
59
+ const identifyDone = new Promise<void>((resolve) => {
60
+ const timeout = setTimeout(resolve, 12000);
61
+ node.libp2p.addEventListener('peer:identify', () => {
62
+ clearTimeout(timeout);
63
+ setTimeout(resolve, 500);
64
+ }, { once: true });
65
+ });
66
+
58
67
  await node.start();
59
68
 
60
69
  spin.text = 'Connecting to network...';
61
- await new Promise((resolve) => setTimeout(resolve, 3000));
70
+ await identifyDone;
62
71
 
63
72
  const dht = createDHTOperations(node.libp2p);
64
73