@dxos/teleport 0.3.7 → 0.3.8-main.598e316

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.
@@ -49,7 +49,7 @@ var import_node_stream = require("node:stream");
49
49
  var import_async = require("@dxos/async");
50
50
  var import_invariant = require("@dxos/invariant");
51
51
  var import_log = require("@dxos/log");
52
- var __dxlog_file = "/mnt/ramdisk/work/packages/core/mesh/teleport/src/muxing/framer.ts";
52
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/muxing/framer.ts";
53
53
  var FRAME_LENGTH_SIZE = 2;
54
54
  var Framer = class {
55
55
  constructor() {
@@ -170,7 +170,7 @@ var Framer = class {
170
170
  }
171
171
  destroy() {
172
172
  if (this._stream.readableLength > 0) {
173
- import_log.log.warn("framer destroyed while there are still read bytes in the buffer.", void 0, {
173
+ import_log.log.info("framer destroyed while there are still read bytes in the buffer.", void 0, {
174
174
  F: __dxlog_file,
175
175
  L: 140,
176
176
  S: this,
@@ -224,7 +224,7 @@ var varint = __toESM(require("varint"));
224
224
  var import_async2 = require("@dxos/async");
225
225
  var import_invariant2 = require("@dxos/invariant");
226
226
  var import_log2 = require("@dxos/log");
227
- var __dxlog_file2 = "/mnt/ramdisk/work/packages/core/mesh/teleport/src/muxing/balancer.ts";
227
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/muxing/balancer.ts";
228
228
  var MAX_CHUNK_SIZE = 8192;
229
229
  var Balancer = class {
230
230
  constructor(_sysChannelId) {
@@ -263,7 +263,7 @@ var Balancer = class {
263
263
  }
264
264
  destroy() {
265
265
  if (this._sendBuffers.size !== 0) {
266
- import_log2.log.warn("destroying balancer with pending calls", void 0, {
266
+ import_log2.log.info("destroying balancer with pending calls", void 0, {
267
267
  F: __dxlog_file2,
268
268
  L: 80,
269
269
  S: this,
@@ -429,7 +429,7 @@ var decodeChunk = (data, withLength) => {
429
429
  };
430
430
 
431
431
  // packages/core/mesh/teleport/src/muxing/muxer.ts
432
- var __dxlog_file3 = "/mnt/ramdisk/work/packages/core/mesh/teleport/src/muxing/muxer.ts";
432
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/muxing/muxer.ts";
433
433
  var Command = import_protocols.schema.getCodecForType("dxos.mesh.muxer.Command");
434
434
  var DEFAULT_SEND_COMMAND_TIMEOUT = 6e4;
435
435
  var DESTROY_COMMAND_SEND_TIMEOUT = 5e3;
@@ -687,7 +687,7 @@ var Muxer = class {
687
687
  }
688
688
  async _handleCommand(cmd) {
689
689
  if (this._disposed) {
690
- import_log3.log.warn("Received command after destroy", {
690
+ import_log3.log.warn("Received command after disposed", {
691
691
  cmd
692
692
  }, {
693
693
  F: __dxlog_file3,
@@ -748,6 +748,17 @@ var Muxer = class {
748
748
  }
749
749
  }
750
750
  async _sendCommand(cmd, channelId = -1, timeout = DEFAULT_SEND_COMMAND_TIMEOUT) {
751
+ if (this._disposed) {
752
+ import_log3.log.info("ignoring sendCommand after disposed", {
753
+ cmd
754
+ }, {
755
+ F: __dxlog_file3,
756
+ L: 388,
757
+ S: this,
758
+ C: (f, a) => f(...a)
759
+ });
760
+ return;
761
+ }
751
762
  try {
752
763
  const trigger = new import_async3.Trigger();
753
764
  this._balancer.pushData(Command.encode(cmd), trigger, channelId);
@@ -790,7 +801,7 @@ var Muxer = class {
790
801
  threshold: MAX_SAFE_FRAME_SIZE
791
802
  }, {
792
803
  F: __dxlog_file3,
793
- L: 425,
804
+ L: 429,
794
805
  S: this,
795
806
  C: (f, a) => f(...a)
796
807
  });
@@ -857,15 +868,157 @@ var Muxer = class {
857
868
  };
858
869
 
859
870
  // packages/core/mesh/teleport/src/teleport.ts
860
- var import_async4 = require("@dxos/async");
861
- var import_context2 = require("@dxos/context");
871
+ var import_async5 = require("@dxos/async");
872
+ var import_context3 = require("@dxos/context");
862
873
  var import_debug2 = require("@dxos/debug");
863
874
  var import_invariant4 = require("@dxos/invariant");
864
875
  var import_keys = require("@dxos/keys");
876
+ var import_log5 = require("@dxos/log");
877
+ var import_protocols3 = require("@dxos/protocols");
878
+
879
+ // packages/core/mesh/teleport/src/control-extension.ts
880
+ var import_async4 = require("@dxos/async");
881
+ var import_context2 = require("@dxos/context");
865
882
  var import_log4 = require("@dxos/log");
866
883
  var import_protocols2 = require("@dxos/protocols");
867
884
  var import_rpc = require("@dxos/rpc");
868
885
  var import_util = require("@dxos/util");
886
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/control-extension.ts";
887
+ var HEARTBEAT_RTT_WARN_THRESH = 1e4;
888
+ var ControlExtension = class {
889
+ constructor(opts, localPeerId, remotePeerId) {
890
+ this.opts = opts;
891
+ this.localPeerId = localPeerId;
892
+ this.remotePeerId = remotePeerId;
893
+ this._ctx = new import_context2.Context({
894
+ onError: (err) => {
895
+ this._extensionContext.close(err);
896
+ }
897
+ });
898
+ this.onExtensionRegistered = new import_util.Callback();
899
+ }
900
+ async registerExtension(name) {
901
+ await this._rpc.rpc.Control.registerExtension({
902
+ name
903
+ });
904
+ }
905
+ async onOpen(extensionContext) {
906
+ this._extensionContext = extensionContext;
907
+ this._rpc = (0, import_rpc.createProtoRpcPeer)({
908
+ requested: {
909
+ Control: import_protocols2.schema.getService("dxos.mesh.teleport.control.ControlService")
910
+ },
911
+ exposed: {
912
+ Control: import_protocols2.schema.getService("dxos.mesh.teleport.control.ControlService")
913
+ },
914
+ handlers: {
915
+ Control: {
916
+ registerExtension: async (request) => {
917
+ this.onExtensionRegistered.call(request.name);
918
+ },
919
+ heartbeat: async (request) => {
920
+ (0, import_log4.log)("received heartbeat request", {
921
+ ts: request.requestTimestamp,
922
+ localPeerId: this.localPeerId.truncate(),
923
+ remotePeerId: this.remotePeerId.truncate()
924
+ }, {
925
+ F: __dxlog_file4,
926
+ L: 66,
927
+ S: this,
928
+ C: (f, a) => f(...a)
929
+ });
930
+ return {
931
+ requestTimestamp: request.requestTimestamp
932
+ };
933
+ }
934
+ }
935
+ },
936
+ port: await extensionContext.createPort("rpc", {
937
+ contentType: 'application/x-protobuf; messageType="dxos.rpc.Message"'
938
+ }),
939
+ timeout: this.opts.heartbeatTimeout
940
+ });
941
+ await this._rpc.open();
942
+ (0, import_async4.scheduleTaskInterval)(this._ctx, async () => {
943
+ const reqTS = /* @__PURE__ */ new Date();
944
+ try {
945
+ const resp = await (0, import_async4.asyncTimeout)(this._rpc.rpc.Control.heartbeat({
946
+ requestTimestamp: reqTS
947
+ }), this.opts.heartbeatTimeout);
948
+ const now = Date.now();
949
+ if (resp.requestTimestamp instanceof Date) {
950
+ if (now - resp.requestTimestamp.getTime() > (HEARTBEAT_RTT_WARN_THRESH < this.opts.heartbeatTimeout ? HEARTBEAT_RTT_WARN_THRESH : this.opts.heartbeatTimeout / 2)) {
951
+ import_log4.log.warn(`heartbeat RTT for Teleport > ${HEARTBEAT_RTT_WARN_THRESH / 1e3}s`, {
952
+ rtt: now - resp.requestTimestamp.getTime(),
953
+ localPeerId: this.localPeerId.truncate(),
954
+ remotePeerId: this.remotePeerId.truncate()
955
+ }, {
956
+ F: __dxlog_file4,
957
+ L: 103,
958
+ S: this,
959
+ C: (f, a) => f(...a)
960
+ });
961
+ } else {
962
+ (0, import_log4.log)("heartbeat RTT", {
963
+ rtt: now - resp.requestTimestamp.getTime(),
964
+ localPeerId: this.localPeerId.truncate(),
965
+ remotePeerId: this.remotePeerId.truncate()
966
+ }, {
967
+ F: __dxlog_file4,
968
+ L: 109,
969
+ S: this,
970
+ C: (f, a) => f(...a)
971
+ });
972
+ }
973
+ }
974
+ } catch (err) {
975
+ const now = Date.now();
976
+ if (err instanceof import_protocols2.RpcClosedError) {
977
+ (0, import_log4.log)("ignoring RpcClosedError in heartbeat", void 0, {
978
+ F: __dxlog_file4,
979
+ L: 119,
980
+ S: this,
981
+ C: (f, a) => f(...a)
982
+ });
983
+ return;
984
+ }
985
+ if (err instanceof import_async4.TimeoutError) {
986
+ (0, import_log4.log)("timeout waiting for heartbeat response", {
987
+ err,
988
+ delay: now - reqTS.getTime()
989
+ }, {
990
+ F: __dxlog_file4,
991
+ L: 123,
992
+ S: this,
993
+ C: (f, a) => f(...a)
994
+ });
995
+ this.opts.onTimeout(err);
996
+ } else {
997
+ import_log4.log.info("other error waiting for heartbeat response", {
998
+ err,
999
+ delay: now - reqTS.getTime()
1000
+ }, {
1001
+ F: __dxlog_file4,
1002
+ L: 126,
1003
+ S: this,
1004
+ C: (f, a) => f(...a)
1005
+ });
1006
+ this.opts.onTimeout(err);
1007
+ }
1008
+ }
1009
+ }, this.opts.heartbeatInterval);
1010
+ }
1011
+ async onClose(err) {
1012
+ await this._ctx.dispose();
1013
+ await this._rpc.close();
1014
+ }
1015
+ async onAbort(err) {
1016
+ await this._ctx.dispose();
1017
+ await this._rpc.abort();
1018
+ }
1019
+ };
1020
+
1021
+ // packages/core/mesh/teleport/src/teleport.ts
869
1022
  function _ts_decorate(decorators, target, key, desc) {
870
1023
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
871
1024
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -876,17 +1029,17 @@ function _ts_decorate(decorators, target, key, desc) {
876
1029
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
877
1030
  return c > 3 && r && Object.defineProperty(target, key, r), r;
878
1031
  }
879
- var __dxlog_file4 = "/mnt/ramdisk/work/packages/core/mesh/teleport/src/teleport.ts";
1032
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/teleport.ts";
880
1033
  var CONTROL_HEARTBEAT_INTERVAL = 1e4;
881
1034
  var CONTROL_HEARTBEAT_TIMEOUT = 6e4;
882
1035
  var Teleport = class {
883
1036
  constructor({ initiator, localPeerId, remotePeerId }) {
884
- this._ctx = new import_context2.Context({
1037
+ this._ctx = new import_context3.Context({
885
1038
  onError: (err) => {
886
1039
  void this.destroy(err).catch(() => {
887
- import_log4.log.error("Error during destroy", err, {
888
- F: __dxlog_file4,
889
- L: 47,
1040
+ import_log5.log.error("Error during destroy", err, {
1041
+ F: __dxlog_file5,
1042
+ L: 38,
890
1043
  S: this,
891
1044
  C: (f, a) => f(...a)
892
1045
  });
@@ -894,35 +1047,14 @@ var Teleport = class {
894
1047
  }
895
1048
  });
896
1049
  this._muxer = new Muxer();
897
- this._control = new ControlExtension({
898
- heartbeatInterval: CONTROL_HEARTBEAT_INTERVAL,
899
- heartbeatTimeout: CONTROL_HEARTBEAT_TIMEOUT,
900
- onTimeout: () => {
901
- if (this._destroying || this._aborting) {
902
- return;
903
- }
904
- (0, import_log4.log)("abort teleport due to onTimeout in ControlExtension", void 0, {
905
- F: __dxlog_file4,
906
- L: 62,
907
- S: this,
908
- C: (f, a) => f(...a)
909
- });
910
- this.abort(new import_protocols2.TimeoutError("control extension")).catch((err) => import_log4.log.catch(err, void 0, {
911
- F: __dxlog_file4,
912
- L: 63,
913
- S: this,
914
- C: (f, a) => f(...a)
915
- }));
916
- }
917
- });
918
1050
  this._extensions = /* @__PURE__ */ new Map();
919
1051
  this._remoteExtensions = /* @__PURE__ */ new Set();
920
1052
  this._open = false;
921
1053
  this._destroying = false;
922
1054
  this._aborting = false;
923
1055
  (0, import_invariant4.invariant)(typeof initiator === "boolean", void 0, {
924
- F: __dxlog_file4,
925
- L: 75,
1056
+ F: __dxlog_file5,
1057
+ L: 55,
926
1058
  S: this,
927
1059
  A: [
928
1060
  "typeof initiator === 'boolean'",
@@ -930,8 +1062,8 @@ var Teleport = class {
930
1062
  ]
931
1063
  });
932
1064
  (0, import_invariant4.invariant)(import_keys.PublicKey.isPublicKey(localPeerId), void 0, {
933
- F: __dxlog_file4,
934
- L: 76,
1065
+ F: __dxlog_file5,
1066
+ L: 56,
935
1067
  S: this,
936
1068
  A: [
937
1069
  "PublicKey.isPublicKey(localPeerId)",
@@ -939,8 +1071,8 @@ var Teleport = class {
939
1071
  ]
940
1072
  });
941
1073
  (0, import_invariant4.invariant)(import_keys.PublicKey.isPublicKey(remotePeerId), void 0, {
942
- F: __dxlog_file4,
943
- L: 77,
1074
+ F: __dxlog_file5,
1075
+ L: 57,
944
1076
  S: this,
945
1077
  A: [
946
1078
  "PublicKey.isPublicKey(remotePeerId)",
@@ -950,18 +1082,39 @@ var Teleport = class {
950
1082
  this.initiator = initiator;
951
1083
  this.localPeerId = localPeerId;
952
1084
  this.remotePeerId = remotePeerId;
1085
+ this._control = new ControlExtension({
1086
+ heartbeatInterval: CONTROL_HEARTBEAT_INTERVAL,
1087
+ heartbeatTimeout: CONTROL_HEARTBEAT_TIMEOUT,
1088
+ onTimeout: () => {
1089
+ if (this._destroying || this._aborting) {
1090
+ return;
1091
+ }
1092
+ import_log5.log.info("abort teleport due to onTimeout in ControlExtension", void 0, {
1093
+ F: __dxlog_file5,
1094
+ L: 70,
1095
+ S: this,
1096
+ C: (f, a) => f(...a)
1097
+ });
1098
+ this.abort(new import_protocols3.TimeoutError("control extension")).catch((err) => import_log5.log.catch(err, void 0, {
1099
+ F: __dxlog_file5,
1100
+ L: 71,
1101
+ S: this,
1102
+ C: (f, a) => f(...a)
1103
+ }));
1104
+ }
1105
+ }, this.localPeerId, this.remotePeerId);
953
1106
  this._control.onExtensionRegistered.set(async (name) => {
954
- (0, import_log4.log)("remote extension", {
1107
+ (0, import_log5.log)("remote extension", {
955
1108
  name
956
1109
  }, {
957
- F: __dxlog_file4,
958
- L: 83,
1110
+ F: __dxlog_file5,
1111
+ L: 79,
959
1112
  S: this,
960
1113
  C: (f, a) => f(...a)
961
1114
  });
962
1115
  (0, import_invariant4.invariant)(!this._remoteExtensions.has(name), "Remote extension already exists", {
963
- F: __dxlog_file4,
964
- L: 84,
1116
+ F: __dxlog_file5,
1117
+ L: 80,
965
1118
  S: this,
966
1119
  A: [
967
1120
  "!this._remoteExtensions.has(name)",
@@ -980,9 +1133,9 @@ var Teleport = class {
980
1133
  {
981
1134
  this._muxer.stream.on("close", async () => {
982
1135
  if (this._destroying || this._aborting) {
983
- (0, import_log4.log)("destroy teleport due to muxer stream close, skipping due to already destroying/aborting", void 0, {
984
- F: __dxlog_file4,
985
- L: 100,
1136
+ (0, import_log5.log)("destroy teleport due to muxer stream close, skipping due to already destroying/aborting", void 0, {
1137
+ F: __dxlog_file5,
1138
+ L: 96,
986
1139
  S: this,
987
1140
  C: (f, a) => f(...a)
988
1141
  });
@@ -995,7 +1148,7 @@ var Teleport = class {
995
1148
  });
996
1149
  }
997
1150
  this._muxer.statsUpdated.on((stats) => {
998
- import_log4.log.trace("dxos.mesh.teleport.stats", {
1151
+ import_log5.log.trace("dxos.mesh.teleport.stats", {
999
1152
  localPeerId,
1000
1153
  remotePeerId,
1001
1154
  bytesSent: stats.bytesSent,
@@ -1004,8 +1157,8 @@ var Teleport = class {
1004
1157
  bytesReceivedRate: stats.bytesReceivedRate,
1005
1158
  channels: stats.channels
1006
1159
  }, {
1007
- F: __dxlog_file4,
1008
- L: 113,
1160
+ F: __dxlog_file5,
1161
+ L: 109,
1009
1162
  S: this,
1010
1163
  C: (f, a) => f(...a)
1011
1164
  });
@@ -1041,9 +1194,9 @@ var Teleport = class {
1041
1194
  try {
1042
1195
  await extension.onAbort(err);
1043
1196
  } catch (err2) {
1044
- import_log4.log.catch(err2, void 0, {
1045
- F: __dxlog_file4,
1046
- L: 166,
1197
+ import_log5.log.catch(err2, void 0, {
1198
+ F: __dxlog_file5,
1199
+ L: 162,
1047
1200
  S: this,
1048
1201
  C: (f, a) => f(...a)
1049
1202
  });
@@ -1064,9 +1217,9 @@ var Teleport = class {
1064
1217
  try {
1065
1218
  await extension.onClose(err);
1066
1219
  } catch (err2) {
1067
- import_log4.log.catch(err2, void 0, {
1068
- F: __dxlog_file4,
1069
- L: 190,
1220
+ import_log5.log.catch(err2, void 0, {
1221
+ F: __dxlog_file5,
1222
+ L: 186,
1070
1223
  S: this,
1071
1224
  C: (f, a) => f(...a)
1072
1225
  });
@@ -1078,35 +1231,35 @@ var Teleport = class {
1078
1231
  if (!this._open) {
1079
1232
  throw new Error("Not open");
1080
1233
  }
1081
- (0, import_log4.log)("addExtension", {
1234
+ (0, import_log5.log)("addExtension", {
1082
1235
  name
1083
1236
  }, {
1084
- F: __dxlog_file4,
1085
- L: 202,
1237
+ F: __dxlog_file5,
1238
+ L: 198,
1086
1239
  S: this,
1087
1240
  C: (f, a) => f(...a)
1088
1241
  });
1089
1242
  this._setExtension(name, extension);
1090
- (0, import_async4.scheduleTask)(this._ctx, async () => {
1243
+ (0, import_async5.scheduleTask)(this._ctx, async () => {
1091
1244
  try {
1092
1245
  await this._control.registerExtension(name);
1093
1246
  } catch (err) {
1094
- if (err instanceof import_protocols2.RpcClosedError) {
1247
+ if (err instanceof import_protocols3.RpcClosedError) {
1095
1248
  return;
1096
1249
  }
1097
1250
  throw err;
1098
1251
  }
1099
1252
  });
1100
1253
  if (this._remoteExtensions.has(name)) {
1101
- (0, import_async4.scheduleTask)(this._ctx, async () => {
1254
+ (0, import_async5.scheduleTask)(this._ctx, async () => {
1102
1255
  await this._openExtension(name);
1103
1256
  });
1104
1257
  }
1105
1258
  }
1106
1259
  _setExtension(extensionName, extension) {
1107
1260
  (0, import_invariant4.invariant)(!extensionName.includes("/"), "Invalid extension name", {
1108
- F: __dxlog_file4,
1109
- L: 226,
1261
+ F: __dxlog_file5,
1262
+ L: 222,
1110
1263
  S: this,
1111
1264
  A: [
1112
1265
  "!extensionName.includes('/')",
@@ -1114,8 +1267,8 @@ var Teleport = class {
1114
1267
  ]
1115
1268
  });
1116
1269
  (0, import_invariant4.invariant)(!this._extensions.has(extensionName), "Extension already exists", {
1117
- F: __dxlog_file4,
1118
- L: 227,
1270
+ F: __dxlog_file5,
1271
+ L: 223,
1119
1272
  S: this,
1120
1273
  A: [
1121
1274
  "!this._extensions.has(extensionName)",
@@ -1125,11 +1278,11 @@ var Teleport = class {
1125
1278
  this._extensions.set(extensionName, extension);
1126
1279
  }
1127
1280
  async _openExtension(extensionName) {
1128
- (0, import_log4.log)("open extension", {
1281
+ (0, import_log5.log)("open extension", {
1129
1282
  extensionName
1130
1283
  }, {
1131
- F: __dxlog_file4,
1132
- L: 232,
1284
+ F: __dxlog_file5,
1285
+ L: 228,
1133
1286
  S: this,
1134
1287
  C: (f, a) => f(...a)
1135
1288
  });
@@ -1140,8 +1293,8 @@ var Teleport = class {
1140
1293
  remotePeerId: this.remotePeerId,
1141
1294
  createPort: async (channelName, opts) => {
1142
1295
  (0, import_invariant4.invariant)(!channelName.includes("/"), "Invalid channel name", {
1143
- F: __dxlog_file4,
1144
- L: 240,
1296
+ F: __dxlog_file5,
1297
+ L: 236,
1145
1298
  S: this,
1146
1299
  A: [
1147
1300
  "!channelName.includes('/')",
@@ -1152,8 +1305,8 @@ var Teleport = class {
1152
1305
  },
1153
1306
  createStream: async (channelName, opts) => {
1154
1307
  (0, import_invariant4.invariant)(!channelName.includes("/"), "Invalid channel name", {
1155
- F: __dxlog_file4,
1156
- L: 244,
1308
+ F: __dxlog_file5,
1309
+ L: 240,
1157
1310
  S: this,
1158
1311
  A: [
1159
1312
  "!channelName.includes('/')",
@@ -1163,90 +1316,35 @@ var Teleport = class {
1163
1316
  return this._muxer.createStream(`${extensionName}/${channelName}`, opts);
1164
1317
  },
1165
1318
  close: (err) => {
1166
- void (0, import_async4.runInContextAsync)(this._ctx, async () => {
1319
+ void (0, import_async5.runInContextAsync)(this._ctx, async () => {
1167
1320
  await this.close(err);
1168
1321
  });
1169
1322
  }
1170
1323
  };
1171
1324
  await extension.onOpen(context);
1172
- (0, import_log4.log)("extension opened", {
1325
+ (0, import_log5.log)("extension opened", {
1173
1326
  extensionName
1174
1327
  }, {
1175
- F: __dxlog_file4,
1176
- L: 255,
1328
+ F: __dxlog_file5,
1329
+ L: 251,
1177
1330
  S: this,
1178
1331
  C: (f, a) => f(...a)
1179
1332
  });
1180
1333
  }
1181
1334
  };
1182
1335
  _ts_decorate([
1183
- import_async4.synchronized
1336
+ import_async5.synchronized
1184
1337
  ], Teleport.prototype, "abort", null);
1185
1338
  _ts_decorate([
1186
- import_async4.synchronized
1339
+ import_async5.synchronized
1187
1340
  ], Teleport.prototype, "destroy", null);
1188
- var ControlExtension = class {
1189
- constructor(opts) {
1190
- this.opts = opts;
1191
- this._ctx = new import_context2.Context({
1192
- onError: (err) => {
1193
- this._extensionContext.close(err);
1194
- }
1195
- });
1196
- this.onExtensionRegistered = new import_util.Callback();
1197
- }
1198
- async registerExtension(name) {
1199
- await this._rpc.rpc.Control.registerExtension({
1200
- name
1201
- });
1202
- }
1203
- async onOpen(extensionContext) {
1204
- this._extensionContext = extensionContext;
1205
- this._rpc = (0, import_rpc.createProtoRpcPeer)({
1206
- requested: {
1207
- Control: import_protocols2.schema.getService("dxos.mesh.teleport.control.ControlService")
1208
- },
1209
- exposed: {
1210
- Control: import_protocols2.schema.getService("dxos.mesh.teleport.control.ControlService")
1211
- },
1212
- handlers: {
1213
- Control: {
1214
- registerExtension: async (request) => {
1215
- this.onExtensionRegistered.call(request.name);
1216
- },
1217
- heartbeat: async (request) => {
1218
- }
1219
- }
1220
- },
1221
- port: await extensionContext.createPort("rpc", {
1222
- contentType: 'application/x-protobuf; messagType="dxos.rpc.Message"'
1223
- })
1224
- });
1225
- await this._rpc.open();
1226
- (0, import_async4.scheduleTaskInterval)(this._ctx, async () => {
1227
- try {
1228
- await (0, import_async4.asyncTimeout)(this._rpc.rpc.Control.heartbeat(), this.opts.heartbeatTimeout);
1229
- } catch (err) {
1230
- this.opts.onTimeout();
1231
- }
1232
- }, this.opts.heartbeatInterval);
1233
- }
1234
- async onClose(err) {
1235
- await this._ctx.dispose();
1236
- await this._rpc.close();
1237
- }
1238
- async onAbort(err) {
1239
- await this._ctx.dispose();
1240
- await this._rpc.abort();
1241
- }
1242
- };
1243
1341
 
1244
1342
  // packages/core/mesh/teleport/src/testing/test-builder.ts
1245
1343
  var import_node_stream3 = require("node:stream");
1246
1344
  var import_invariant5 = require("@dxos/invariant");
1247
1345
  var import_keys2 = require("@dxos/keys");
1248
- var import_log5 = require("@dxos/log");
1249
- var __dxlog_file5 = "/mnt/ramdisk/work/packages/core/mesh/teleport/src/testing/test-builder.ts";
1346
+ var import_log6 = require("@dxos/log");
1347
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/testing/test-builder.ts";
1250
1348
  var TestBuilder = class {
1251
1349
  constructor() {
1252
1350
  this._peers = /* @__PURE__ */ new Set();
@@ -1266,7 +1364,7 @@ var TestBuilder = class {
1266
1364
  }
1267
1365
  async connect(peer1, peer2) {
1268
1366
  (0, import_invariant5.invariant)(peer1 !== peer2, void 0, {
1269
- F: __dxlog_file5,
1367
+ F: __dxlog_file6,
1270
1368
  L: 37,
1271
1369
  S: this,
1272
1370
  A: [
@@ -1275,7 +1373,7 @@ var TestBuilder = class {
1275
1373
  ]
1276
1374
  });
1277
1375
  (0, import_invariant5.invariant)(this._peers.has(peer1), void 0, {
1278
- F: __dxlog_file5,
1376
+ F: __dxlog_file6,
1279
1377
  L: 38,
1280
1378
  S: this,
1281
1379
  A: [
@@ -1284,7 +1382,7 @@ var TestBuilder = class {
1284
1382
  ]
1285
1383
  });
1286
1384
  (0, import_invariant5.invariant)(this._peers.has(peer1), void 0, {
1287
- F: __dxlog_file5,
1385
+ F: __dxlog_file6,
1288
1386
  L: 39,
1289
1387
  S: this,
1290
1388
  A: [
@@ -1312,7 +1410,7 @@ var TestBuilder = class {
1312
1410
  }
1313
1411
  async disconnect(peer1, peer2) {
1314
1412
  (0, import_invariant5.invariant)(peer1 !== peer2, void 0, {
1315
- F: __dxlog_file5,
1413
+ F: __dxlog_file6,
1316
1414
  L: 51,
1317
1415
  S: this,
1318
1416
  A: [
@@ -1321,7 +1419,7 @@ var TestBuilder = class {
1321
1419
  ]
1322
1420
  });
1323
1421
  (0, import_invariant5.invariant)(this._peers.has(peer1), void 0, {
1324
- F: __dxlog_file5,
1422
+ F: __dxlog_file6,
1325
1423
  L: 52,
1326
1424
  S: this,
1327
1425
  A: [
@@ -1330,7 +1428,7 @@ var TestBuilder = class {
1330
1428
  ]
1331
1429
  });
1332
1430
  (0, import_invariant5.invariant)(this._peers.has(peer1), void 0, {
1333
- F: __dxlog_file5,
1431
+ F: __dxlog_file6,
1334
1432
  L: 53,
1335
1433
  S: this,
1336
1434
  A: [
@@ -1341,7 +1439,7 @@ var TestBuilder = class {
1341
1439
  const connection1 = Array.from(peer1.connections).find((connection) => connection.remotePeerId.equals(peer2.peerId));
1342
1440
  const connection2 = Array.from(peer2.connections).find((connection) => connection.remotePeerId.equals(peer1.peerId));
1343
1441
  (0, import_invariant5.invariant)(connection1, void 0, {
1344
- F: __dxlog_file5,
1442
+ F: __dxlog_file6,
1345
1443
  L: 62,
1346
1444
  S: this,
1347
1445
  A: [
@@ -1350,7 +1448,7 @@ var TestBuilder = class {
1350
1448
  ]
1351
1449
  });
1352
1450
  (0, import_invariant5.invariant)(connection2, void 0, {
1353
- F: __dxlog_file5,
1451
+ F: __dxlog_file6,
1354
1452
  L: 63,
1355
1453
  S: this,
1356
1454
  A: [
@@ -1380,7 +1478,7 @@ var TestPeer = class {
1380
1478
  }
1381
1479
  async openConnection(connection) {
1382
1480
  (0, import_invariant5.invariant)(this.connections.has(connection), void 0, {
1383
- F: __dxlog_file5,
1481
+ F: __dxlog_file6,
1384
1482
  L: 84,
1385
1483
  S: this,
1386
1484
  A: [
@@ -1393,7 +1491,7 @@ var TestPeer = class {
1393
1491
  }
1394
1492
  async closeConnection(connection) {
1395
1493
  (0, import_invariant5.invariant)(this.connections.has(connection), void 0, {
1396
- F: __dxlog_file5,
1494
+ F: __dxlog_file6,
1397
1495
  L: 90,
1398
1496
  S: this,
1399
1497
  A: [
@@ -1414,8 +1512,8 @@ var TestPeer = class {
1414
1512
  var pipeStreams = (stream1, stream2) => {
1415
1513
  (0, import_node_stream3.pipeline)(stream1, stream2, (err) => {
1416
1514
  if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") {
1417
- import_log5.log.catch(err, void 0, {
1418
- F: __dxlog_file5,
1515
+ import_log6.log.catch(err, void 0, {
1516
+ F: __dxlog_file6,
1419
1517
  L: 106,
1420
1518
  S: void 0,
1421
1519
  C: (f, a) => f(...a)
@@ -1424,8 +1522,8 @@ var pipeStreams = (stream1, stream2) => {
1424
1522
  });
1425
1523
  (0, import_node_stream3.pipeline)(stream2, stream1, (err) => {
1426
1524
  if (err && err.code !== "ERR_STREAM_PREMATURE_CLOSE") {
1427
- import_log5.log.catch(err, void 0, {
1428
- F: __dxlog_file5,
1525
+ import_log6.log.catch(err, void 0, {
1526
+ F: __dxlog_file6,
1429
1527
  L: 111,
1430
1528
  S: void 0,
1431
1529
  C: (f, a) => f(...a)
@@ -1447,28 +1545,28 @@ var TestConnection = class {
1447
1545
  };
1448
1546
 
1449
1547
  // packages/core/mesh/teleport/src/testing/test-extension.ts
1450
- var import_async5 = require("@dxos/async");
1548
+ var import_async6 = require("@dxos/async");
1451
1549
  var import_invariant6 = require("@dxos/invariant");
1452
- var import_log6 = require("@dxos/log");
1453
- var import_protocols3 = require("@dxos/protocols");
1550
+ var import_log7 = require("@dxos/log");
1551
+ var import_protocols4 = require("@dxos/protocols");
1454
1552
  var import_rpc2 = require("@dxos/rpc");
1455
- var __dxlog_file6 = "/mnt/ramdisk/work/packages/core/mesh/teleport/src/testing/test-extension.ts";
1553
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/testing/test-extension.ts";
1456
1554
  var TestExtension = class {
1457
1555
  constructor(callbacks = {}) {
1458
1556
  this.callbacks = callbacks;
1459
- this.open = new import_async5.Trigger();
1460
- this.closed = new import_async5.Trigger();
1461
- this.aborted = new import_async5.Trigger();
1557
+ this.open = new import_async6.Trigger();
1558
+ this.closed = new import_async6.Trigger();
1559
+ this.aborted = new import_async6.Trigger();
1462
1560
  }
1463
1561
  get remotePeerId() {
1464
1562
  return this.extensionContext?.remotePeerId;
1465
1563
  }
1466
1564
  async onOpen(context) {
1467
- (0, import_log6.log)("onOpen", {
1565
+ (0, import_log7.log)("onOpen", {
1468
1566
  localPeerId: context.localPeerId,
1469
1567
  remotePeerId: context.remotePeerId
1470
1568
  }, {
1471
- F: __dxlog_file6,
1569
+ F: __dxlog_file7,
1472
1570
  L: 34,
1473
1571
  S: this,
1474
1572
  C: (f, a) => f(...a)
@@ -1479,10 +1577,10 @@ var TestExtension = class {
1479
1577
  contentType: 'application/x-protobuf; messageType="dxos.rpc.Message"'
1480
1578
  }),
1481
1579
  requested: {
1482
- TestService: import_protocols3.schema.getService("example.testing.rpc.TestService")
1580
+ TestService: import_protocols4.schema.getService("example.testing.rpc.TestService")
1483
1581
  },
1484
1582
  exposed: {
1485
- TestService: import_protocols3.schema.getService("example.testing.rpc.TestService")
1583
+ TestService: import_protocols4.schema.getService("example.testing.rpc.TestService")
1486
1584
  },
1487
1585
  handlers: {
1488
1586
  TestService: {
@@ -1502,10 +1600,10 @@ var TestExtension = class {
1502
1600
  this.open.wake();
1503
1601
  }
1504
1602
  async onClose(err) {
1505
- (0, import_log6.log)("onClose", {
1603
+ (0, import_log7.log)("onClose", {
1506
1604
  err
1507
1605
  }, {
1508
- F: __dxlog_file6,
1606
+ F: __dxlog_file7,
1509
1607
  L: 68,
1510
1608
  S: this,
1511
1609
  C: (f, a) => f(...a)
@@ -1515,10 +1613,10 @@ var TestExtension = class {
1515
1613
  await this._rpc?.close();
1516
1614
  }
1517
1615
  async onAbort(err) {
1518
- (0, import_log6.log)("onAbort", {
1616
+ (0, import_log7.log)("onAbort", {
1519
1617
  err
1520
1618
  }, {
1521
- F: __dxlog_file6,
1619
+ F: __dxlog_file7,
1522
1620
  L: 75,
1523
1621
  S: this,
1524
1622
  C: (f, a) => f(...a)
@@ -1531,11 +1629,11 @@ var TestExtension = class {
1531
1629
  await this.open.wait({
1532
1630
  timeout: 1500
1533
1631
  });
1534
- const res = await (0, import_async5.asyncTimeout)(this._rpc.rpc.TestService.testCall({
1632
+ const res = await (0, import_async6.asyncTimeout)(this._rpc.rpc.TestService.testCall({
1535
1633
  data: message
1536
1634
  }), 1500);
1537
1635
  (0, import_invariant6.invariant)(res.data === message, void 0, {
1538
- F: __dxlog_file6,
1636
+ F: __dxlog_file7,
1539
1637
  L: 84,
1540
1638
  S: this,
1541
1639
  A: [
@@ -1554,18 +1652,18 @@ var TestExtension = class {
1554
1652
 
1555
1653
  // packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts
1556
1654
  var import_node_crypto = require("node:crypto");
1557
- var import_async6 = require("@dxos/async");
1655
+ var import_async7 = require("@dxos/async");
1558
1656
  var import_invariant7 = require("@dxos/invariant");
1559
- var import_log7 = require("@dxos/log");
1560
- var import_protocols4 = require("@dxos/protocols");
1657
+ var import_log8 = require("@dxos/log");
1658
+ var import_protocols5 = require("@dxos/protocols");
1561
1659
  var import_rpc3 = require("@dxos/rpc");
1562
- var __dxlog_file7 = "/mnt/ramdisk/work/packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts";
1660
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/testing/test-extension-with-streams.ts";
1563
1661
  var TestExtensionWithStreams = class {
1564
1662
  constructor(callbacks = {}) {
1565
1663
  this.callbacks = callbacks;
1566
- this.open = new import_async6.Trigger();
1567
- this.closed = new import_async6.Trigger();
1568
- this.aborted = new import_async6.Trigger();
1664
+ this.open = new import_async7.Trigger();
1665
+ this.closed = new import_async7.Trigger();
1666
+ this.aborted = new import_async7.Trigger();
1569
1667
  this._streams = /* @__PURE__ */ new Map();
1570
1668
  }
1571
1669
  get remotePeerId() {
@@ -1573,7 +1671,7 @@ var TestExtensionWithStreams = class {
1573
1671
  }
1574
1672
  async _openStream(streamTag, interval = 5, chunkSize = 2048) {
1575
1673
  (0, import_invariant7.invariant)(!this._streams.has(streamTag), `Stream already exists: ${streamTag}`, {
1576
- F: __dxlog_file7,
1674
+ F: __dxlog_file8,
1577
1675
  L: 39,
1578
1676
  S: this,
1579
1677
  A: [
@@ -1621,7 +1719,7 @@ var TestExtensionWithStreams = class {
1621
1719
  });
1622
1720
  streamEntry.reportingTimer = setInterval(() => {
1623
1721
  const { bytesSent, bytesReceived, sendErrors, receiveErrors } = streamEntry;
1624
- import_log7.log.trace("dxos.test.stream-stats", {
1722
+ import_log8.log.trace("dxos.test.stream-stats", {
1625
1723
  streamTag,
1626
1724
  bytesSent,
1627
1725
  bytesReceived,
@@ -1630,7 +1728,7 @@ var TestExtensionWithStreams = class {
1630
1728
  from: this.extensionContext?.localPeerId,
1631
1729
  to: this.extensionContext?.remotePeerId
1632
1730
  }, {
1633
- F: __dxlog_file7,
1731
+ F: __dxlog_file8,
1634
1732
  L: 93,
1635
1733
  S: this,
1636
1734
  C: (f, a) => f(...a)
@@ -1639,7 +1737,7 @@ var TestExtensionWithStreams = class {
1639
1737
  }
1640
1738
  _closeStream(streamTag) {
1641
1739
  (0, import_invariant7.invariant)(this._streams.has(streamTag), `Stream does not exist: ${streamTag}`, {
1642
- F: __dxlog_file7,
1740
+ F: __dxlog_file8,
1643
1741
  L: 106,
1644
1742
  S: this,
1645
1743
  A: [
@@ -1662,11 +1760,11 @@ var TestExtensionWithStreams = class {
1662
1760
  };
1663
1761
  }
1664
1762
  async onOpen(context) {
1665
- (0, import_log7.log)("onOpen", {
1763
+ (0, import_log8.log)("onOpen", {
1666
1764
  localPeerId: context.localPeerId,
1667
1765
  remotePeerId: context.remotePeerId
1668
1766
  }, {
1669
- F: __dxlog_file7,
1767
+ F: __dxlog_file8,
1670
1768
  L: 128,
1671
1769
  S: this,
1672
1770
  C: (f, a) => f(...a)
@@ -1677,10 +1775,10 @@ var TestExtensionWithStreams = class {
1677
1775
  contentType: 'application/x-protobuf; messageType="dxos.rpc.Message"'
1678
1776
  }),
1679
1777
  requested: {
1680
- TestServiceWithStreams: import_protocols4.schema.getService("example.testing.rpc.TestServiceWithStreams")
1778
+ TestServiceWithStreams: import_protocols5.schema.getService("example.testing.rpc.TestServiceWithStreams")
1681
1779
  },
1682
1780
  exposed: {
1683
- TestServiceWithStreams: import_protocols4.schema.getService("example.testing.rpc.TestServiceWithStreams")
1781
+ TestServiceWithStreams: import_protocols5.schema.getService("example.testing.rpc.TestServiceWithStreams")
1684
1782
  },
1685
1783
  handlers: {
1686
1784
  TestServiceWithStreams: {
@@ -1712,10 +1810,10 @@ var TestExtensionWithStreams = class {
1712
1810
  this.open.wake();
1713
1811
  }
1714
1812
  async onClose(err) {
1715
- (0, import_log7.log)("onClose", {
1813
+ (0, import_log8.log)("onClose", {
1716
1814
  err
1717
1815
  }, {
1718
- F: __dxlog_file7,
1816
+ F: __dxlog_file8,
1719
1817
  L: 179,
1720
1818
  S: this,
1721
1819
  C: (f, a) => f(...a)
@@ -1723,10 +1821,10 @@ var TestExtensionWithStreams = class {
1723
1821
  await this.callbacks.onClose?.();
1724
1822
  this.closed.wake();
1725
1823
  for (const [streamTag, stream] of Object.entries(this._streams)) {
1726
- (0, import_log7.log)("closing stream", {
1824
+ (0, import_log8.log)("closing stream", {
1727
1825
  streamTag
1728
1826
  }, {
1729
- F: __dxlog_file7,
1827
+ F: __dxlog_file8,
1730
1828
  L: 183,
1731
1829
  S: this,
1732
1830
  C: (f, a) => f(...a)
@@ -1737,10 +1835,10 @@ var TestExtensionWithStreams = class {
1737
1835
  await this._rpc?.close();
1738
1836
  }
1739
1837
  async onAbort(err) {
1740
- (0, import_log7.log)("onAbort", {
1838
+ (0, import_log8.log)("onAbort", {
1741
1839
  err
1742
1840
  }, {
1743
- F: __dxlog_file7,
1841
+ F: __dxlog_file8,
1744
1842
  L: 191,
1745
1843
  S: this,
1746
1844
  C: (f, a) => f(...a)
@@ -1762,7 +1860,7 @@ var TestExtensionWithStreams = class {
1762
1860
  streamLoadChunkSize
1763
1861
  });
1764
1862
  (0, import_invariant7.invariant)(data === streamTag, void 0, {
1765
- F: __dxlog_file7,
1863
+ F: __dxlog_file8,
1766
1864
  L: 207,
1767
1865
  S: this,
1768
1866
  A: [
@@ -1781,7 +1879,7 @@ var TestExtensionWithStreams = class {
1781
1879
  data: streamTag
1782
1880
  });
1783
1881
  (0, import_invariant7.invariant)(data === streamTag, void 0, {
1784
- F: __dxlog_file7,
1882
+ F: __dxlog_file8,
1785
1883
  L: 220,
1786
1884
  S: this,
1787
1885
  A: [
@@ -1815,7 +1913,7 @@ var TestExtensionWithStreams = class {
1815
1913
  // packages/core/mesh/teleport/src/rpc-extension.ts
1816
1914
  var import_invariant8 = require("@dxos/invariant");
1817
1915
  var import_rpc4 = require("@dxos/rpc");
1818
- var __dxlog_file8 = "/mnt/ramdisk/work/packages/core/mesh/teleport/src/rpc-extension.ts";
1916
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/mesh/teleport/src/rpc-extension.ts";
1819
1917
  var RpcExtension = class {
1820
1918
  constructor(_rpcParams) {
1821
1919
  this._rpcParams = _rpcParams;
@@ -1832,7 +1930,7 @@ var RpcExtension = class {
1832
1930
  }
1833
1931
  get rpc() {
1834
1932
  (0, import_invariant8.invariant)(this._rpc, void 0, {
1835
- F: __dxlog_file8,
1933
+ F: __dxlog_file9,
1836
1934
  L: 32,
1837
1935
  S: this,
1838
1936
  A: [