@tangle-network/sandbox 0.64.15 → 0.64.17
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.
|
@@ -431,7 +431,7 @@ interface SessionGatewayStats {
|
|
|
431
431
|
*/
|
|
432
432
|
declare function calculateConnectionQuality(metrics: ConnectionMetrics, isConnected: boolean): ConnectionQuality;
|
|
433
433
|
//#endregion
|
|
434
|
-
//#region ../../../packages/sdk/dist/client-
|
|
434
|
+
//#region ../../../packages/sdk/dist/client-DlMgBOqN.d.ts
|
|
435
435
|
//#region src/session-gateway/core-types.d.ts
|
|
436
436
|
interface SubscriptionDenial {
|
|
437
437
|
channel: string;
|
|
@@ -505,8 +505,6 @@ declare class SessionGatewayClientCore {
|
|
|
505
505
|
private state;
|
|
506
506
|
private readonly counters;
|
|
507
507
|
private readonly connectionWaiters;
|
|
508
|
-
private readonly reconnects;
|
|
509
|
-
private readonly heartbeat;
|
|
510
508
|
private readonly metrics;
|
|
511
509
|
private readonly replayCursor;
|
|
512
510
|
private readonly inbound;
|
|
@@ -33,7 +33,7 @@ function calculateConnectionQuality(metrics, isConnected) {
|
|
|
33
33
|
return "good";
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
36
|
-
//#region ../../../packages/sdk/dist/types-
|
|
36
|
+
//#region ../../../packages/sdk/dist/types-B1NMYFuB.js
|
|
37
37
|
function invokeClientCallback(name, callback, onError) {
|
|
38
38
|
try {
|
|
39
39
|
callback();
|
|
@@ -713,8 +713,8 @@ var SessionGatewayClientCore = class {
|
|
|
713
713
|
eventsReceived: 0
|
|
714
714
|
};
|
|
715
715
|
connectionWaiters;
|
|
716
|
-
reconnects;
|
|
717
|
-
heartbeat;
|
|
716
|
+
#reconnects;
|
|
717
|
+
#heartbeat;
|
|
718
718
|
metrics;
|
|
719
719
|
replayCursor;
|
|
720
720
|
inbound;
|
|
@@ -724,9 +724,9 @@ var SessionGatewayClientCore = class {
|
|
|
724
724
|
this.#config = resolveClientConfig(config);
|
|
725
725
|
this.handlers = config.handlers ?? {};
|
|
726
726
|
this.connectionWaiters = new ConnectionWaiters(this.#config.connectionEstablishmentTimeoutMs);
|
|
727
|
-
this
|
|
727
|
+
this.#reconnects = new ReconnectScheduler(this.#config);
|
|
728
728
|
this.metrics = new ConnectionMetricsTracker(initialMetrics, this.#config.latencyHistorySize, () => this.state === "connected", (metrics) => invokeClientCallback("onMetricsChange", () => this.handlers.onMetricsChange?.(metrics), this.handlers.onError));
|
|
729
|
-
this
|
|
729
|
+
this.#heartbeat = new Heartbeat(this.#config, this.metrics, () => this.ws, (message) => this.send(message));
|
|
730
730
|
this.replayCursor = new ReplayCursor(new ReplayStateStore(this.#config.enableReplayPersistence, replayStorage, this.#config.replayStorageKeyPrefix, this.#config.url, this.#config.sessionId), {
|
|
731
731
|
enabled: this.#config.enableDeduplication,
|
|
732
732
|
maxSize: this.#config.maxDeduplicationSize
|
|
@@ -749,7 +749,7 @@ var SessionGatewayClientCore = class {
|
|
|
749
749
|
*/
|
|
750
750
|
connect() {
|
|
751
751
|
if (this.state === "connected" || this.state === "connecting" || this.state === "reconnecting") return;
|
|
752
|
-
const nextState = this
|
|
752
|
+
const nextState = this.#reconnects.hasConnectedBefore ? "reconnecting" : "connecting";
|
|
753
753
|
this.setState(nextState);
|
|
754
754
|
if (this.getState() !== nextState) return;
|
|
755
755
|
this.connectWebSocket();
|
|
@@ -769,7 +769,7 @@ var SessionGatewayClientCore = class {
|
|
|
769
769
|
}
|
|
770
770
|
};
|
|
771
771
|
socket.onopen = () => {
|
|
772
|
-
if (this.ws === socket) this
|
|
772
|
+
if (this.ws === socket) this.#heartbeat.resetMissedPongs();
|
|
773
773
|
};
|
|
774
774
|
socket.onclose = (event) => this.handleClose(socket, event.code, event.reason);
|
|
775
775
|
socket.onerror = () => {
|
|
@@ -789,8 +789,8 @@ var SessionGatewayClientCore = class {
|
|
|
789
789
|
*/
|
|
790
790
|
disconnect() {
|
|
791
791
|
this.connectionWaiters.rejectAll(/* @__PURE__ */ new Error("Client disconnected"));
|
|
792
|
-
this
|
|
793
|
-
this
|
|
792
|
+
this.#heartbeat.stop();
|
|
793
|
+
this.#reconnects.cancel();
|
|
794
794
|
this.inbound.requests.rejectAll("Connection closed");
|
|
795
795
|
this.connectionWaiters.established = false;
|
|
796
796
|
const socket = this.ws;
|
|
@@ -870,9 +870,9 @@ var SessionGatewayClientCore = class {
|
|
|
870
870
|
return {
|
|
871
871
|
state: this.state,
|
|
872
872
|
connectedAt: this.counters.connectedAt,
|
|
873
|
-
lastPingAt: this
|
|
874
|
-
lastPongAt: this
|
|
875
|
-
reconnectAttempts: this
|
|
873
|
+
lastPingAt: this.#heartbeat.lastPingAt,
|
|
874
|
+
lastPongAt: this.#heartbeat.lastPongAt,
|
|
875
|
+
reconnectAttempts: this.#reconnects.attempts,
|
|
876
876
|
messagesReceived: this.counters.messagesReceived,
|
|
877
877
|
messagesSent: this.counters.messagesSent,
|
|
878
878
|
eventsReceived: this.counters.eventsReceived,
|
|
@@ -920,12 +920,12 @@ var SessionGatewayClientCore = class {
|
|
|
920
920
|
handleConnectionEstablished(sessionId) {
|
|
921
921
|
if (this.connectionWaiters.established) return;
|
|
922
922
|
this.connectionWaiters.clear();
|
|
923
|
-
const isReconnect = this
|
|
923
|
+
const isReconnect = this.#reconnects.hasConnectedBefore;
|
|
924
924
|
this.connectionWaiters.established = true;
|
|
925
|
-
this
|
|
925
|
+
this.#reconnects.hasConnectedBefore = true;
|
|
926
926
|
this.counters.connectedAt = Date.now();
|
|
927
|
-
this
|
|
928
|
-
this
|
|
927
|
+
this.#reconnects.attempts = 0;
|
|
928
|
+
this.#heartbeat.start();
|
|
929
929
|
const subscribe = this.replayCursor.subscribeMessage(this.#config.channels);
|
|
930
930
|
if (subscribe) this.send(subscribe);
|
|
931
931
|
this.setState("connected");
|
|
@@ -942,12 +942,12 @@ var SessionGatewayClientCore = class {
|
|
|
942
942
|
this.connectionWaiters.clear();
|
|
943
943
|
this.ws = null;
|
|
944
944
|
this.connectionWaiters.established = false;
|
|
945
|
-
this
|
|
946
|
-
this
|
|
945
|
+
this.#heartbeat.stop();
|
|
946
|
+
this.#reconnects.cancel();
|
|
947
947
|
this.inbound.requests.rejectAll("Connection closed");
|
|
948
|
-
if (this
|
|
948
|
+
if (this.#reconnects.canRetry()) {
|
|
949
949
|
this.setState("reconnecting");
|
|
950
|
-
if (this.state === "reconnecting") this
|
|
950
|
+
if (this.state === "reconnecting") this.#reconnects.schedule(() => {
|
|
951
951
|
if (this.state === "reconnecting" && this.ws === null) this.connectWebSocket();
|
|
952
952
|
});
|
|
953
953
|
} else {
|
|
@@ -962,7 +962,7 @@ var SessionGatewayClientCore = class {
|
|
|
962
962
|
const message = parseServerFrame(data, this.handlers);
|
|
963
963
|
if (!message) return;
|
|
964
964
|
if (CONTROL_MESSAGE_TYPES.has(message.type)) {
|
|
965
|
-
if (message.type === "pong") this
|
|
965
|
+
if (message.type === "pong") this.#heartbeat.handlePong(message.timestamp);
|
|
966
966
|
deliverServerMessage(message, this.inbound);
|
|
967
967
|
return;
|
|
968
968
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/sandbox",
|
|
3
|
-
"version": "0.64.
|
|
3
|
+
"version": "0.64.17",
|
|
4
4
|
"description": "Client SDK for the Tangle Sandbox platform - build AI agent applications with dev containers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -163,13 +163,13 @@
|
|
|
163
163
|
"@repo/shared": "0.0.0",
|
|
164
164
|
"@tangle-network/agent-profile-materialize": "0.26.0",
|
|
165
165
|
"@tangle-network/cli-agent-registry": "0.10.2",
|
|
166
|
-
"@tangle-network/runtime-contracts": "0.19.0",
|
|
167
166
|
"@tangle-network/sdk": "4.0.16",
|
|
167
|
+
"@tangle-network/runtime-contracts": "0.19.0",
|
|
168
168
|
"@tangle-network/sse-core": "0.0.0"
|
|
169
169
|
},
|
|
170
170
|
"tangleRelease": {
|
|
171
|
-
"sourceSha": "
|
|
172
|
-
"mergedAt": "2026-10-
|
|
171
|
+
"sourceSha": "08bb687ce982f53edfe2bd5a65d41c74291b6724",
|
|
172
|
+
"mergedAt": "2026-10-22T15:17:12-06:00"
|
|
173
173
|
},
|
|
174
174
|
"scripts": {
|
|
175
175
|
"build": "node scripts/build-dist.mjs",
|