@highway1/cli 0.1.47 → 0.1.48

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Clawiverse Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -116805,14 +116805,25 @@ function createMessageRouter(libp2p, verifyFn, dht, relayPeers) {
116805
116805
  });
116806
116806
  const s2 = await conn.newStream(PROTOCOL_PREFIX3, { runOnLimitedConnection: true });
116807
116807
  logger5.info("Direct dial succeeded", { addr });
116808
- return s2;
116808
+ return { conn, stream: s2 };
116809
116809
  } catch {
116810
116810
  return null;
116811
116811
  }
116812
116812
  });
116813
- stream = await Promise.race(
116814
- directDialPromises.map((p2) => p2.then((s2) => s2 || Promise.reject()))
116813
+ const winner = await Promise.race(
116814
+ directDialPromises.map((p2) => p2.then((r2) => r2 || Promise.reject()))
116815
116815
  ).catch(() => void 0);
116816
+ if (winner) {
116817
+ stream = winner.stream;
116818
+ Promise.allSettled(directDialPromises).then((results) => {
116819
+ for (const result of results) {
116820
+ if (result.status === "fulfilled" && result.value && result.value.stream !== stream) {
116821
+ result.value.conn.close().catch(() => {
116822
+ });
116823
+ }
116824
+ }
116825
+ });
116826
+ }
116816
116827
  }
116817
116828
  let lastError;
116818
116829
  if (!stream) {
@@ -116830,16 +116841,27 @@ function createMessageRouter(libp2p, verifyFn, dht, relayPeers) {
116830
116841
  logger5.info("Relay connection established", { addr });
116831
116842
  const s2 = await conn.newStream(PROTOCOL_PREFIX3, { runOnLimitedConnection: true });
116832
116843
  logger5.info("Relay stream opened", { addr });
116833
- return s2;
116844
+ return { conn, stream: s2 };
116834
116845
  } catch (relayErr) {
116835
116846
  logger5.warn("Relay dial failed", { addr, error: relayErr.message });
116836
116847
  lastError = relayErr;
116837
116848
  return null;
116838
116849
  }
116839
116850
  });
116840
- stream = await Promise.race(
116841
- relayDialPromises.map((p2) => p2.then((s2) => s2 || Promise.reject()))
116851
+ const winner = await Promise.race(
116852
+ relayDialPromises.map((p2) => p2.then((r2) => r2 || Promise.reject()))
116842
116853
  ).catch(() => void 0);
116854
+ if (winner) {
116855
+ stream = winner.stream;
116856
+ Promise.allSettled(relayDialPromises).then((results) => {
116857
+ for (const result of results) {
116858
+ if (result.status === "fulfilled" && result.value && result.value.stream !== stream) {
116859
+ result.value.conn.close().catch(() => {
116860
+ });
116861
+ }
116862
+ }
116863
+ });
116864
+ }
116843
116865
  }
116844
116866
  }
116845
116867
  if (!stream && dht && "queryRelayPeers" in dht) {
@@ -116941,6 +116963,10 @@ async function handleIncomingStream(stream, handlers, catchAllHandler, verifyFn)
116941
116963
  chunks.push(chunk.subarray());
116942
116964
  }
116943
116965
  const data = concatUint8Arrays(chunks);
116966
+ if (data.length === 0) {
116967
+ logger5.debug("Received empty stream, ignoring");
116968
+ return;
116969
+ }
116944
116970
  const envelope = decodeMessage2(data);
116945
116971
  if (!validateEnvelope(envelope)) {
116946
116972
  logger5.warn("Received invalid message envelope");
@@ -119367,7 +119393,8 @@ var ClawDaemon = class {
119367
119393
  this.node = await createNode({
119368
119394
  keyPair,
119369
119395
  bootstrapPeers: this.bootstrapPeers,
119370
- enableDHT: true
119396
+ enableDHT: true,
119397
+ reserveRelaySlot: this.bootstrapPeers.length > 0
119371
119398
  });
119372
119399
  await this.node.start();
119373
119400
  logger12.info("Node started", { peerId: this.node.getPeerId() });