@highway1/cli 0.1.34 → 0.1.36
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 +34 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -116212,7 +116212,14 @@ async function createNode(config2) {
|
|
|
116212
116212
|
},
|
|
116213
116213
|
selectors: {
|
|
116214
116214
|
clawiverse: () => 0
|
|
116215
|
-
}
|
|
116215
|
+
},
|
|
116216
|
+
// Optimize for small networks: reduce replication factor and query timeout
|
|
116217
|
+
kBucketSize: 20,
|
|
116218
|
+
// Default K=20, keep for compatibility
|
|
116219
|
+
querySelfInterval: 3e5,
|
|
116220
|
+
// Self-query every 5 min (default 30s)
|
|
116221
|
+
// Allow queries to complete faster in small networks
|
|
116222
|
+
allowQueryWithZeroPeers: true
|
|
116216
116223
|
});
|
|
116217
116224
|
}
|
|
116218
116225
|
const peerDiscovery = [];
|
|
@@ -116433,7 +116440,7 @@ function capKey(cap) {
|
|
|
116433
116440
|
}
|
|
116434
116441
|
async function readDIDList(dht, key) {
|
|
116435
116442
|
try {
|
|
116436
|
-
for await (const event of dht.get(key, { signal: AbortSignal.timeout(
|
|
116443
|
+
for await (const event of dht.get(key, { signal: AbortSignal.timeout(3e4) })) {
|
|
116437
116444
|
const raw = extractValue(event);
|
|
116438
116445
|
if (raw) {
|
|
116439
116446
|
const text = toString2(raw);
|
|
@@ -116446,11 +116453,18 @@ async function readDIDList(dht, key) {
|
|
|
116446
116453
|
}
|
|
116447
116454
|
async function writeDIDList(dht, key, dids) {
|
|
116448
116455
|
const value2 = fromString2([...new Set(dids)].join("\n"));
|
|
116449
|
-
|
|
116450
|
-
|
|
116456
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
116457
|
+
try {
|
|
116458
|
+
for await (const _ of dht.put(key, value2, { signal: AbortSignal.timeout(3e4) })) {
|
|
116459
|
+
}
|
|
116460
|
+
return;
|
|
116461
|
+
} catch (e2) {
|
|
116462
|
+
if (e2?.name === "AbortError" && attempt < 3) {
|
|
116463
|
+
logger4.debug(`DHT put timeout, retrying (${attempt}/3)...`);
|
|
116464
|
+
continue;
|
|
116465
|
+
}
|
|
116466
|
+
if (e2?.name !== "AbortError") throw e2;
|
|
116451
116467
|
}
|
|
116452
|
-
} catch (e2) {
|
|
116453
|
-
if (e2?.name !== "AbortError") throw e2;
|
|
116454
116468
|
}
|
|
116455
116469
|
}
|
|
116456
116470
|
function createDHTOperations(libp2p) {
|
|
@@ -116462,17 +116476,26 @@ function createDHTOperations(libp2p) {
|
|
|
116462
116476
|
const dht = libp2p.services?.dht;
|
|
116463
116477
|
if (!dht) throw new DiscoveryError("DHT service not available");
|
|
116464
116478
|
const agentKey = fromString2(`/clawiverse/agent/${card.did}`);
|
|
116465
|
-
|
|
116466
|
-
|
|
116479
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
116480
|
+
try {
|
|
116481
|
+
for await (const _ of dht.put(agentKey, encodeForDHT(card), { signal: AbortSignal.timeout(3e4) })) {
|
|
116482
|
+
}
|
|
116483
|
+
break;
|
|
116484
|
+
} catch (e2) {
|
|
116485
|
+
if (e2?.name === "AbortError" && attempt < 3) {
|
|
116486
|
+
logger4.debug(`DHT put agent card timeout, retrying (${attempt}/3)...`);
|
|
116487
|
+
continue;
|
|
116488
|
+
}
|
|
116489
|
+
logger4.warn("DHT put agent card failed (non-fatal)", { error: e2.message });
|
|
116490
|
+
break;
|
|
116467
116491
|
}
|
|
116468
|
-
} catch (e2) {
|
|
116469
|
-
logger4.warn("DHT put agent card failed (non-fatal)", { error: e2.message });
|
|
116470
116492
|
}
|
|
116471
116493
|
const caps = (card.capabilities ?? []).map(
|
|
116472
116494
|
(c2) => typeof c2 === "string" ? c2 : c2.name
|
|
116473
116495
|
).filter(Boolean);
|
|
116474
116496
|
caps.push("__all__");
|
|
116475
|
-
|
|
116497
|
+
const importantCaps = ["__all__"];
|
|
116498
|
+
await Promise.all(importantCaps.map(async (cap) => {
|
|
116476
116499
|
const capKeyStr = `/clawiverse/cap/${capKey(cap)}`;
|
|
116477
116500
|
const capDHTKey = fromString2(capKeyStr);
|
|
116478
116501
|
try {
|