tesseract-agent 0.4.5 → 0.4.6
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-bundle/cli.js +28 -17
- package/package.json +1 -1
package/dist-bundle/cli.js
CHANGED
|
@@ -45578,6 +45578,11 @@ var PeerLinkManager = class {
|
|
|
45578
45578
|
quicSrflx = null;
|
|
45579
45579
|
quicInitP = null;
|
|
45580
45580
|
quicKeepalive = null;
|
|
45581
|
+
/** Set once if the QUIC native dep (@matrixai/quic) can't be loaded on this host —
|
|
45582
|
+
* e.g. the desktop app doesn't ship it, or an arch with no prebuilt binding. The
|
|
45583
|
+
* QUIC tier then no-ops permanently and the TCP tiers carry every link (fail-closed,
|
|
45584
|
+
* exactly what the lazy-load design in quic-transport.ts promises). */
|
|
45585
|
+
quicUnavailable = false;
|
|
45581
45586
|
constructor(certPath, keyPath) {
|
|
45582
45587
|
this.certPath = certPath;
|
|
45583
45588
|
this.keyPath = keyPath;
|
|
@@ -45624,22 +45629,28 @@ var PeerLinkManager = class {
|
|
|
45624
45629
|
return;
|
|
45625
45630
|
const stunPort = Number(process.env.CCB_STUN_PORT ?? 3478);
|
|
45626
45631
|
const identity = await this.identity();
|
|
45627
|
-
|
|
45628
|
-
|
|
45629
|
-
|
|
45630
|
-
|
|
45631
|
-
|
|
45632
|
-
|
|
45633
|
-
|
|
45634
|
-
|
|
45635
|
-
|
|
45636
|
-
|
|
45637
|
-
|
|
45638
|
-
|
|
45639
|
-
|
|
45640
|
-
|
|
45641
|
-
|
|
45642
|
-
|
|
45632
|
+
try {
|
|
45633
|
+
const q = await Promise.resolve().then(() => (init_quic_transport(), quic_transport_exports));
|
|
45634
|
+
const socket2 = await q.makeQuicSocket(this.udpPort);
|
|
45635
|
+
this.quicSocket = socket2;
|
|
45636
|
+
await q.startQuicServerOnSocket({ socket: socket2, identity, onStream: (bs) => this.acceptInbound(bs, "punch") });
|
|
45637
|
+
const refresh = async () => {
|
|
45638
|
+
try {
|
|
45639
|
+
const s = await q.discoverSrflx(socket2, stunHost, stunPort);
|
|
45640
|
+
const i = s.lastIndexOf(":");
|
|
45641
|
+
this.quicSrflx = { type: "srflx", ip: s.slice(0, i), port: Number(s.slice(i + 1)), proto: "udp", priority: 40 };
|
|
45642
|
+
} catch {
|
|
45643
|
+
}
|
|
45644
|
+
};
|
|
45645
|
+
await refresh();
|
|
45646
|
+
this.quicKeepalive = setInterval(() => {
|
|
45647
|
+
void refresh();
|
|
45648
|
+
}, 2e4);
|
|
45649
|
+
} catch (e) {
|
|
45650
|
+
this.quicUnavailable = true;
|
|
45651
|
+
this.quicSocket = null;
|
|
45652
|
+
console.warn(`[peer-link] QUIC tier unavailable \u2014 using TCP tiers only: ${e?.message ?? e}`);
|
|
45653
|
+
}
|
|
45643
45654
|
}
|
|
45644
45655
|
async nudgeQuic(peer) {
|
|
45645
45656
|
if (!this.quicSocket)
|
|
@@ -45755,7 +45766,7 @@ var PeerLinkManager = class {
|
|
|
45755
45766
|
async handleGo(msg) {
|
|
45756
45767
|
const token = Buffer.from(msg.token, "hex");
|
|
45757
45768
|
const udp = msg.peerCandidates.filter((c) => c.proto === "udp");
|
|
45758
|
-
const quicOn = this.quicEnabled() && udp.length > 0;
|
|
45769
|
+
const quicOn = this.quicEnabled() && udp.length > 0 && !this.quicUnavailable;
|
|
45759
45770
|
if (msg.role === "listen") {
|
|
45760
45771
|
if (quicOn) {
|
|
45761
45772
|
await this.initQuic();
|