@dxos/client-services 0.7.4 → 0.7.5-labs.5f04cf6

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.
Files changed (75) hide show
  1. package/dist/lib/browser/{chunk-423GRVVV.mjs → chunk-EVMMT65L.mjs} +147 -104
  2. package/dist/lib/browser/chunk-EVMMT65L.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +1 -1
  6. package/dist/lib/node/{chunk-ZS24HRVA.cjs → chunk-LXXOZWCX.cjs} +182 -139
  7. package/dist/lib/node/chunk-LXXOZWCX.cjs.map +7 -0
  8. package/dist/lib/node/index.cjs +47 -47
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/testing/index.cjs +8 -8
  11. package/dist/lib/node-esm/{chunk-OQOXRHWF.mjs → chunk-74ZMFWJS.mjs} +147 -104
  12. package/dist/lib/node-esm/chunk-74ZMFWJS.mjs.map +7 -0
  13. package/dist/lib/node-esm/index.mjs +1 -1
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/testing/index.mjs +1 -1
  16. package/dist/types/src/packlets/agents/edge-agent-service.d.ts +1 -1
  17. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  18. package/dist/types/src/packlets/devices/devices-service.d.ts +1 -1
  19. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
  20. package/dist/types/src/packlets/devtools/devtools.d.ts +1 -1
  21. package/dist/types/src/packlets/devtools/devtools.d.ts.map +1 -1
  22. package/dist/types/src/packlets/devtools/feeds.d.ts +1 -1
  23. package/dist/types/src/packlets/devtools/feeds.d.ts.map +1 -1
  24. package/dist/types/src/packlets/devtools/keys.d.ts +1 -1
  25. package/dist/types/src/packlets/devtools/keys.d.ts.map +1 -1
  26. package/dist/types/src/packlets/devtools/metadata.d.ts +1 -1
  27. package/dist/types/src/packlets/devtools/metadata.d.ts.map +1 -1
  28. package/dist/types/src/packlets/devtools/network.d.ts +1 -1
  29. package/dist/types/src/packlets/devtools/network.d.ts.map +1 -1
  30. package/dist/types/src/packlets/devtools/spaces.d.ts +1 -1
  31. package/dist/types/src/packlets/devtools/spaces.d.ts.map +1 -1
  32. package/dist/types/src/packlets/identity/contacts-service.d.ts +1 -1
  33. package/dist/types/src/packlets/identity/contacts-service.d.ts.map +1 -1
  34. package/dist/types/src/packlets/identity/identity-service.d.ts +1 -1
  35. package/dist/types/src/packlets/identity/identity-service.d.ts.map +1 -1
  36. package/dist/types/src/packlets/invitations/invitations-service.d.ts +1 -1
  37. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  38. package/dist/types/src/packlets/logging/logging-service.d.ts +1 -1
  39. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  40. package/dist/types/src/packlets/network/network-service.d.ts +9 -2
  41. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  42. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  43. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  44. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +3 -0
  45. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  46. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  47. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  48. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  49. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  50. package/dist/types/src/version.d.ts +1 -1
  51. package/dist/types/src/version.d.ts.map +1 -1
  52. package/dist/types/tsconfig.tsbuildinfo +1 -0
  53. package/package.json +38 -38
  54. package/src/packlets/agents/edge-agent-service.ts +1 -1
  55. package/src/packlets/devices/devices-service.ts +1 -1
  56. package/src/packlets/devtools/devtools.ts +1 -1
  57. package/src/packlets/devtools/feeds.ts +1 -1
  58. package/src/packlets/devtools/keys.ts +1 -1
  59. package/src/packlets/devtools/metadata.ts +1 -1
  60. package/src/packlets/devtools/network.ts +1 -1
  61. package/src/packlets/devtools/spaces.ts +1 -1
  62. package/src/packlets/identity/contacts-service.ts +1 -1
  63. package/src/packlets/identity/identity-service.ts +1 -1
  64. package/src/packlets/invitations/invitations-service.ts +1 -1
  65. package/src/packlets/logging/logging-service.ts +1 -1
  66. package/src/packlets/network/network-service.ts +39 -1
  67. package/src/packlets/services/service-context.ts +3 -1
  68. package/src/packlets/spaces/edge-feed-replicator.ts +11 -5
  69. package/src/packlets/spaces/notarization-plugin.ts +32 -17
  70. package/src/packlets/spaces/spaces-service.ts +1 -1
  71. package/src/packlets/system/system-service.ts +1 -1
  72. package/src/version.ts +1 -5
  73. package/dist/lib/browser/chunk-423GRVVV.mjs.map +0 -7
  74. package/dist/lib/node/chunk-ZS24HRVA.cjs.map +0 -7
  75. package/dist/lib/node-esm/chunk-OQOXRHWF.mjs.map +0 -7
@@ -2,7 +2,7 @@ import "@dxos/node-std/globals";
2
2
 
3
3
  // packages/sdk/client-services/src/packlets/devtools/feeds.ts
4
4
  import { EventSubscriptions } from "@dxos/async";
5
- import { Stream } from "@dxos/codec-protobuf";
5
+ import { Stream } from "@dxos/codec-protobuf/stream";
6
6
  import { FeedIterator } from "@dxos/feed-store";
7
7
  import { PublicKey } from "@dxos/keys";
8
8
  import { log } from "@dxos/log";
@@ -113,7 +113,7 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
113
113
  };
114
114
 
115
115
  // packages/sdk/client-services/src/packlets/devtools/network.ts
116
- import { Stream as Stream2 } from "@dxos/codec-protobuf";
116
+ import { Stream as Stream2 } from "@dxos/codec-protobuf/stream";
117
117
  import { Context } from "@dxos/context";
118
118
  import { PublicKey as PublicKey2 } from "@dxos/keys";
119
119
  var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devtools/network.ts";
@@ -210,7 +210,7 @@ var getNetworkPeers = ({ networkManager }, request) => {
210
210
  };
211
211
 
212
212
  // packages/sdk/client-services/src/packlets/devtools/spaces.ts
213
- import { Stream as Stream3 } from "@dxos/codec-protobuf";
213
+ import { Stream as Stream3 } from "@dxos/codec-protobuf/stream";
214
214
  var subscribeToSpaces = (context, { spaceKeys = [] }) => {
215
215
  return new Stream3(({ next }) => {
216
216
  let unsubscribe;
@@ -247,11 +247,11 @@ var subscribeToSpaces = (context, { spaceKeys = [] }) => {
247
247
 
248
248
  // packages/sdk/client-services/src/packlets/devtools/devtools.ts
249
249
  import { Event as AsyncEvent } from "@dxos/async";
250
- import { Stream as Stream6 } from "@dxos/codec-protobuf";
250
+ import { Stream as Stream6 } from "@dxos/codec-protobuf/stream";
251
251
 
252
252
  // packages/sdk/client-services/src/packlets/devtools/keys.ts
253
253
  import { scheduleTask } from "@dxos/async";
254
- import { Stream as Stream4 } from "@dxos/codec-protobuf";
254
+ import { Stream as Stream4 } from "@dxos/codec-protobuf/stream";
255
255
  var subscribeToKeyringKeys = ({ keyring }) => new Stream4(({ next, ctx }) => {
256
256
  const update = async () => {
257
257
  next({
@@ -263,7 +263,7 @@ var subscribeToKeyringKeys = ({ keyring }) => new Stream4(({ next, ctx }) => {
263
263
  });
264
264
 
265
265
  // packages/sdk/client-services/src/packlets/devtools/metadata.ts
266
- import { Stream as Stream5 } from "@dxos/codec-protobuf";
266
+ import { Stream as Stream5 } from "@dxos/codec-protobuf/stream";
267
267
  var subscribeToMetadata = ({ context }) => new Stream5(({ next, ctx }) => {
268
268
  context.metadataStore.update.on(ctx, (data) => next({
269
269
  metadata: data
@@ -397,7 +397,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
397
397
  import { TRACE_PROCESSOR } from "@dxos/tracing";
398
398
 
399
399
  // packages/sdk/client-services/src/version.ts
400
- var DXOS_VERSION = "0.7.4";
400
+ var DXOS_VERSION = "0.7.5-labs.5f04cf6";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -1036,21 +1036,20 @@ var EdgeFeedReplicator = class extends Resource {
1036
1036
  });
1037
1037
  return;
1038
1038
  }
1039
- const logPayload = message.type === "data" ? {
1040
- feedKey: message.feedKey,
1041
- blocks: message.blocks.map((b) => b.index)
1042
- } : {
1043
- message
1044
- };
1045
- log4.info("sending message", logPayload, {
1046
- F: __dxlog_file6,
1047
- L: 152,
1048
- S: this,
1049
- C: (f, a) => f(...a)
1050
- });
1039
+ if (message.type === "data") {
1040
+ log4.info("sending blocks", {
1041
+ feedKey: message.feedKey,
1042
+ blocks: message.blocks.map((b) => b.index)
1043
+ }, {
1044
+ F: __dxlog_file6,
1045
+ L: 151,
1046
+ S: this,
1047
+ C: (f, a) => f(...a)
1048
+ });
1049
+ }
1051
1050
  invariant2(message.feedKey, void 0, {
1052
1051
  F: __dxlog_file6,
1053
- L: 154,
1052
+ L: 157,
1054
1053
  S: this,
1055
1054
  A: [
1056
1055
  "message.feedKey",
@@ -1062,7 +1061,7 @@ var EdgeFeedReplicator = class extends Resource {
1062
1061
  type: message.type
1063
1062
  }, {
1064
1063
  F: __dxlog_file6,
1065
- L: 157,
1064
+ L: 160,
1066
1065
  S: this,
1067
1066
  C: (f, a) => f(...a)
1068
1067
  });
@@ -1081,7 +1080,7 @@ var EdgeFeedReplicator = class extends Resource {
1081
1080
  if (!this._connectionCtx) {
1082
1081
  log4.warn("received message after connection context was disposed", void 0, {
1083
1082
  F: __dxlog_file6,
1084
- L: 172,
1083
+ L: 175,
1085
1084
  S: this,
1086
1085
  C: (f, a) => f(...a)
1087
1086
  });
@@ -1092,14 +1091,6 @@ var EdgeFeedReplicator = class extends Resource {
1092
1091
  case "metadata": {
1093
1092
  try {
1094
1093
  var _usingCtx = _using_ctx();
1095
- log4.info("received metadata", {
1096
- message
1097
- }, {
1098
- F: __dxlog_file6,
1099
- L: 178,
1100
- S: this,
1101
- C: (f, a) => f(...a)
1102
- });
1103
1094
  const feedKey = PublicKey3.fromHex(message.feedKey);
1104
1095
  const feed = this._feeds.get(feedKey);
1105
1096
  if (!feed) {
@@ -1107,7 +1098,7 @@ var EdgeFeedReplicator = class extends Resource {
1107
1098
  feedKey
1108
1099
  }, {
1109
1100
  F: __dxlog_file6,
1110
- L: 183,
1101
+ L: 184,
1111
1102
  S: this,
1112
1103
  C: (f, a) => f(...a)
1113
1104
  });
@@ -1115,7 +1106,18 @@ var EdgeFeedReplicator = class extends Resource {
1115
1106
  }
1116
1107
  const _guard = _usingCtx.u(await this._getPushMutex(feed.key).acquire());
1117
1108
  this._remoteLength.set(feedKey, message.length);
1109
+ const logMeta = {
1110
+ localLength: feed.length,
1111
+ remoteLength: message.length,
1112
+ feedKey
1113
+ };
1118
1114
  if (message.length > feed.length) {
1115
+ log4.info("requesting missing blocks", logMeta, {
1116
+ F: __dxlog_file6,
1117
+ L: 194,
1118
+ S: this,
1119
+ C: (f, a) => f(...a)
1120
+ });
1119
1121
  await this._sendMessage({
1120
1122
  type: "request",
1121
1123
  feedKey: feedKey.toHex(),
@@ -1125,6 +1127,12 @@ var EdgeFeedReplicator = class extends Resource {
1125
1127
  }
1126
1128
  });
1127
1129
  } else if (message.length < feed.length) {
1130
+ log4.info("pushing blocks to remote", logMeta, {
1131
+ F: __dxlog_file6,
1132
+ L: 202,
1133
+ S: this,
1134
+ C: (f, a) => f(...a)
1135
+ });
1128
1136
  await this._pushBlocks(feed, message.length, feed.length);
1129
1137
  }
1130
1138
  break;
@@ -1140,7 +1148,7 @@ var EdgeFeedReplicator = class extends Resource {
1140
1148
  blocks: message.blocks.map((b) => b.index)
1141
1149
  }, {
1142
1150
  F: __dxlog_file6,
1143
- L: 205,
1151
+ L: 211,
1144
1152
  S: this,
1145
1153
  C: (f, a) => f(...a)
1146
1154
  });
@@ -1151,7 +1159,7 @@ var EdgeFeedReplicator = class extends Resource {
1151
1159
  feedKey
1152
1160
  }, {
1153
1161
  F: __dxlog_file6,
1154
- L: 210,
1162
+ L: 216,
1155
1163
  S: this,
1156
1164
  C: (f, a) => f(...a)
1157
1165
  });
@@ -1165,7 +1173,7 @@ var EdgeFeedReplicator = class extends Resource {
1165
1173
  ...message
1166
1174
  }, {
1167
1175
  F: __dxlog_file6,
1168
- L: 219,
1176
+ L: 225,
1169
1177
  S: this,
1170
1178
  C: (f, a) => f(...a)
1171
1179
  });
@@ -1180,7 +1188,7 @@ var EdgeFeedReplicator = class extends Resource {
1180
1188
  to
1181
1189
  }, {
1182
1190
  F: __dxlog_file6,
1183
- L: 226,
1191
+ L: 232,
1184
1192
  S: this,
1185
1193
  C: (f, a) => f(...a)
1186
1194
  });
@@ -1190,7 +1198,7 @@ var EdgeFeedReplicator = class extends Resource {
1190
1198
  });
1191
1199
  invariant2(data instanceof Uint8Array, void 0, {
1192
1200
  F: __dxlog_file6,
1193
- L: 231,
1201
+ L: 237,
1194
1202
  S: this,
1195
1203
  A: [
1196
1204
  "data instanceof Uint8Array",
@@ -1218,7 +1226,7 @@ var EdgeFeedReplicator = class extends Resource {
1218
1226
  blocks: blocks.length
1219
1227
  }, {
1220
1228
  F: __dxlog_file6,
1221
- L: 252,
1229
+ L: 258,
1222
1230
  S: this,
1223
1231
  C: (f, a) => f(...a)
1224
1232
  });
@@ -1240,7 +1248,7 @@ var EdgeFeedReplicator = class extends Resource {
1240
1248
  if (!this._remoteLength.has(feed.key)) {
1241
1249
  log4("blocks not pushed because remote length is unknown", void 0, {
1242
1250
  F: __dxlog_file6,
1243
- L: 273,
1251
+ L: 279,
1244
1252
  S: this,
1245
1253
  C: (f, a) => f(...a)
1246
1254
  });
@@ -1265,7 +1273,7 @@ var EdgeFeedReplicator = class extends Resource {
1265
1273
  if (err instanceof EdgeIdentityChangedError || err instanceof EdgeConnectionClosedError) {
1266
1274
  log4("resetting on reconnect", void 0, {
1267
1275
  F: __dxlog_file6,
1268
- L: 290,
1276
+ L: 296,
1269
1277
  S: this,
1270
1278
  C: (f, a) => f(...a)
1271
1279
  });
@@ -1276,7 +1284,7 @@ var EdgeFeedReplicator = class extends Resource {
1276
1284
  }
1277
1285
  }, {
1278
1286
  F: __dxlog_file6,
1279
- L: 284
1287
+ L: 290
1280
1288
  });
1281
1289
  return connectionCtx;
1282
1290
  }
@@ -1443,6 +1451,7 @@ var NotarizationPlugin = class extends Resource3 {
1443
1451
  this._processedCredentials = new ComplexSet(PublicKey4.hash);
1444
1452
  this._processCredentialsTriggers = new ComplexMap3(PublicKey4.hash);
1445
1453
  this._activeEdgePollingIntervalHandle = void 0;
1454
+ this._activeEdgePollingEnabled = false;
1446
1455
  this._spaceId = params.spaceId;
1447
1456
  this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
1448
1457
  if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
@@ -1450,15 +1459,6 @@ var NotarizationPlugin = class extends Resource3 {
1450
1459
  }
1451
1460
  }
1452
1461
  setActiveEdgePollingEnabled(enabled) {
1453
- invariant4(this.isOpen, void 0, {
1454
- F: __dxlog_file8,
1455
- L: 109,
1456
- S: this,
1457
- A: [
1458
- "this.isOpen",
1459
- ""
1460
- ]
1461
- });
1462
1462
  const client = this._edgeClient;
1463
1463
  invariant4(client, void 0, {
1464
1464
  F: __dxlog_file8,
@@ -1469,30 +1469,30 @@ var NotarizationPlugin = class extends Resource3 {
1469
1469
  ""
1470
1470
  ]
1471
1471
  });
1472
- if (enabled && !this._activeEdgePollingIntervalHandle) {
1473
- this._activeEdgePollingIntervalHandle = setInterval(() => {
1474
- if (this._writer) {
1475
- this._notarizePendingEdgeCredentials(client, this._writer);
1476
- }
1477
- }, this._activeEdgePollingInterval);
1478
- } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1479
- clearInterval(this._activeEdgePollingIntervalHandle);
1480
- this._activeEdgePollingIntervalHandle = void 0;
1472
+ this._activeEdgePollingEnabled = enabled;
1473
+ if (this.isOpen) {
1474
+ if (enabled && !this._activeEdgePollingIntervalHandle) {
1475
+ this._startPeriodicEdgePolling(client);
1476
+ } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1477
+ this._stopPeriodicEdgePolling();
1478
+ }
1481
1479
  }
1482
1480
  }
1483
1481
  get hasWriter() {
1484
1482
  return !!this._writer;
1485
1483
  }
1486
1484
  async _open() {
1487
- if (this._edgeClient && this._writer) {
1488
- this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1485
+ if (this._edgeClient) {
1486
+ if (this._activeEdgePollingEnabled) {
1487
+ this._startPeriodicEdgePolling(this._edgeClient);
1488
+ }
1489
+ if (this._writer) {
1490
+ this._notarizePendingEdgeCredentials(this._edgeClient, this._writer);
1491
+ }
1489
1492
  }
1490
1493
  }
1491
1494
  async _close() {
1492
- if (this._activeEdgePollingIntervalHandle) {
1493
- clearInterval(this._activeEdgePollingIntervalHandle);
1494
- this._activeEdgePollingIntervalHandle = void 0;
1495
- }
1495
+ this._stopPeriodicEdgePolling();
1496
1496
  await this._ctx.dispose();
1497
1497
  }
1498
1498
  /**
@@ -1670,10 +1670,23 @@ var NotarizationPlugin = class extends Resource3 {
1670
1670
  ]
1671
1671
  });
1672
1672
  this._writer = writer;
1673
- if (this._edgeClient) {
1673
+ if (this._edgeClient && this.isOpen) {
1674
1674
  this._notarizePendingEdgeCredentials(this._edgeClient, writer);
1675
1675
  }
1676
1676
  }
1677
+ _startPeriodicEdgePolling(client) {
1678
+ this._activeEdgePollingIntervalHandle = setInterval(() => {
1679
+ if (this._writer) {
1680
+ this._notarizePendingEdgeCredentials(client, this._writer);
1681
+ }
1682
+ }, this._activeEdgePollingInterval);
1683
+ }
1684
+ _stopPeriodicEdgePolling() {
1685
+ if (this._activeEdgePollingIntervalHandle) {
1686
+ clearInterval(this._activeEdgePollingIntervalHandle);
1687
+ this._activeEdgePollingIntervalHandle = void 0;
1688
+ }
1689
+ }
1677
1690
  /**
1678
1691
  * The method is used only for adding agent feeds to spaces.
1679
1692
  * When an agent is created we can admit them into all the existing spaces. In case the operation fails
@@ -1692,7 +1705,7 @@ var NotarizationPlugin = class extends Resource3 {
1692
1705
  if (!credentials.length) {
1693
1706
  log5("edge did not return credentials for notarization", void 0, {
1694
1707
  F: __dxlog_file8,
1695
- L: 296,
1708
+ L: 311,
1696
1709
  S: this,
1697
1710
  C: (f, a) => f(...a)
1698
1711
  });
@@ -1702,7 +1715,7 @@ var NotarizationPlugin = class extends Resource3 {
1702
1715
  count: credentials.length
1703
1716
  }, {
1704
1717
  F: __dxlog_file8,
1705
- L: 300,
1718
+ L: 315,
1706
1719
  S: this,
1707
1720
  C: (f, a) => f(...a)
1708
1721
  });
@@ -1715,7 +1728,7 @@ var NotarizationPlugin = class extends Resource3 {
1715
1728
  count: decodedCredentials.length
1716
1729
  }, {
1717
1730
  F: __dxlog_file8,
1718
- L: 309,
1731
+ L: 324,
1719
1732
  S: this,
1720
1733
  C: (f, a) => f(...a)
1721
1734
  });
@@ -1743,7 +1756,7 @@ var NotarizationPlugin = class extends Resource3 {
1743
1756
  for (const credential of credentials) {
1744
1757
  invariant4(credential.id, "Credential must have an id", {
1745
1758
  F: __dxlog_file8,
1746
- L: 335,
1759
+ L: 350,
1747
1760
  S: this,
1748
1761
  A: [
1749
1762
  "credential.id",
@@ -1767,7 +1780,7 @@ var NotarizationPlugin = class extends Resource3 {
1767
1780
  peer: extension.localPeerId
1768
1781
  }, {
1769
1782
  F: __dxlog_file8,
1770
- L: 350,
1783
+ L: 365,
1771
1784
  S: this,
1772
1785
  C: (f, a) => f(...a)
1773
1786
  });
@@ -1779,7 +1792,7 @@ var NotarizationPlugin = class extends Resource3 {
1779
1792
  peer: extension.localPeerId
1780
1793
  }, {
1781
1794
  F: __dxlog_file8,
1782
- L: 355,
1795
+ L: 370,
1783
1796
  S: this,
1784
1797
  C: (f, a) => f(...a)
1785
1798
  });
@@ -1796,7 +1809,7 @@ var NotarizationPlugin = class extends Resource3 {
1796
1809
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1797
1810
  }, {
1798
1811
  F: __dxlog_file8,
1799
- L: 367,
1812
+ L: 382,
1800
1813
  S: this,
1801
1814
  C: (f, a) => f(...a)
1802
1815
  });
@@ -1812,7 +1825,7 @@ var handleEdgeError = (error) => {
1812
1825
  if (!(error instanceof EdgeCallFailedError) || error.errorData) {
1813
1826
  log5.catch(error, void 0, {
1814
1827
  F: __dxlog_file8,
1815
- L: 381,
1828
+ L: 396,
1816
1829
  S: void 0,
1817
1830
  C: (f, a) => f(...a)
1818
1831
  });
@@ -1821,7 +1834,7 @@ var handleEdgeError = (error) => {
1821
1834
  reason: error.reason
1822
1835
  }, {
1823
1836
  F: __dxlog_file8,
1824
- L: 383,
1837
+ L: 398,
1825
1838
  S: void 0,
1826
1839
  C: (f, a) => f(...a)
1827
1840
  });
@@ -2662,7 +2675,7 @@ DataSpaceManager = _ts_decorate3([
2662
2675
 
2663
2676
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
2664
2677
  import { EventSubscriptions as EventSubscriptions2, UpdateScheduler, scheduleTask as scheduleTask3 } from "@dxos/async";
2665
- import { Stream as Stream7 } from "@dxos/codec-protobuf";
2678
+ import { Stream as Stream7 } from "@dxos/codec-protobuf/stream";
2666
2679
  import { createAdmissionCredentials as createAdmissionCredentials2, getCredentialAssertion as getCredentialAssertion3 } from "@dxos/credentials";
2667
2680
  import { raise } from "@dxos/debug";
2668
2681
  import { writeMessages as writeMessages2 } from "@dxos/feed-store";
@@ -3748,7 +3761,7 @@ IdentityManager = _ts_decorate5([
3748
3761
 
3749
3762
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
3750
3763
  import { Trigger as Trigger4, sleep as sleep2 } from "@dxos/async";
3751
- import { Stream as Stream8 } from "@dxos/codec-protobuf";
3764
+ import { Stream as Stream8 } from "@dxos/codec-protobuf/stream";
3752
3765
  import { Resource as Resource5 } from "@dxos/context";
3753
3766
  import { createCredential as createCredential2, signPresentation } from "@dxos/credentials";
3754
3767
  import { invariant as invariant9 } from "@dxos/invariant";
@@ -6132,7 +6145,7 @@ var createAdmissionKeypair = () => {
6132
6145
  };
6133
6146
 
6134
6147
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
6135
- import { Stream as Stream9 } from "@dxos/codec-protobuf";
6148
+ import { Stream as Stream9 } from "@dxos/codec-protobuf/stream";
6136
6149
  import { QueryInvitationsResponse } from "@dxos/protocols/proto/dxos/client/services";
6137
6150
  import { trace as trace8 } from "@dxos/tracing";
6138
6151
  var InvitationsServiceImpl = class {
@@ -7314,7 +7327,7 @@ _ts_decorate9([
7314
7327
  ], EdgeAgentManager.prototype, "createAgent", null);
7315
7328
 
7316
7329
  // packages/sdk/client-services/src/packlets/agents/edge-agent-service.ts
7317
- import { Stream as Stream11 } from "@dxos/codec-protobuf";
7330
+ import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7318
7331
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7319
7332
  import { QueryAgentStatusResponse, QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
7320
7333
  var EdgeAgentServiceImpl = class {
@@ -7622,7 +7635,8 @@ var ServiceContext = class extends Resource7 {
7622
7635
  this.recoveryManager = new EdgeIdentityRecoveryManager(this.keyring, this._edgeHttpClient, () => this.identityManager.identity, this._acceptIdentity.bind(this));
7623
7636
  this.echoHost = new EchoHost({
7624
7637
  kv: this.level,
7625
- peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex()
7638
+ peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
7639
+ getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key
7626
7640
  });
7627
7641
  this._meshReplicator = new MeshEchoReplicator();
7628
7642
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeParams?.invitationConnectionDefaultParams);
@@ -7641,7 +7655,7 @@ var ServiceContext = class extends Resource7 {
7641
7655
  await this._checkStorageVersion();
7642
7656
  log24("opening...", void 0, {
7643
7657
  F: __dxlog_file28,
7644
- L: 198,
7658
+ L: 199,
7645
7659
  S: this,
7646
7660
  C: (f, a) => f(...a)
7647
7661
  });
@@ -7649,7 +7663,7 @@ var ServiceContext = class extends Resource7 {
7649
7663
  id: this._instanceId
7650
7664
  }), {
7651
7665
  F: __dxlog_file28,
7652
- L: 199,
7666
+ L: 200,
7653
7667
  S: this,
7654
7668
  C: (f, a) => f(...a)
7655
7669
  });
@@ -7676,7 +7690,7 @@ var ServiceContext = class extends Resource7 {
7676
7690
  count: loadedInvitations.invitations?.length
7677
7691
  }, {
7678
7692
  F: __dxlog_file28,
7679
- L: 227,
7693
+ L: 228,
7680
7694
  S: this,
7681
7695
  C: (f, a) => f(...a)
7682
7696
  });
@@ -7684,13 +7698,13 @@ var ServiceContext = class extends Resource7 {
7684
7698
  id: this._instanceId
7685
7699
  }), {
7686
7700
  F: __dxlog_file28,
7687
- L: 229,
7701
+ L: 230,
7688
7702
  S: this,
7689
7703
  C: (f, a) => f(...a)
7690
7704
  });
7691
7705
  log24("opened", void 0, {
7692
7706
  F: __dxlog_file28,
7693
- L: 230,
7707
+ L: 231,
7694
7708
  S: this,
7695
7709
  C: (f, a) => f(...a)
7696
7710
  });
@@ -7698,7 +7712,7 @@ var ServiceContext = class extends Resource7 {
7698
7712
  async _close(ctx) {
7699
7713
  log24("closing...", void 0, {
7700
7714
  F: __dxlog_file28,
7701
- L: 234,
7715
+ L: 235,
7702
7716
  S: this,
7703
7717
  C: (f, a) => f(...a)
7704
7718
  });
@@ -7717,7 +7731,7 @@ var ServiceContext = class extends Resource7 {
7717
7731
  await this._edgeConnection?.close();
7718
7732
  log24("closed", void 0, {
7719
7733
  F: __dxlog_file28,
7720
- L: 250,
7734
+ L: 251,
7721
7735
  S: this,
7722
7736
  C: (f, a) => f(...a)
7723
7737
  });
@@ -7728,7 +7742,7 @@ var ServiceContext = class extends Resource7 {
7728
7742
  await identity.joinNetwork();
7729
7743
  await this._initialize(new Context9(void 0, {
7730
7744
  F: __dxlog_file28,
7731
- L: 257
7745
+ L: 258
7732
7746
  }));
7733
7747
  return identity;
7734
7748
  }
@@ -7739,7 +7753,7 @@ var ServiceContext = class extends Resource7 {
7739
7753
  const factory = this._handlerFactories.get(invitation.kind);
7740
7754
  invariant20(factory, `Unknown invitation kind: ${invitation.kind}`, {
7741
7755
  F: __dxlog_file28,
7742
- L: 266,
7756
+ L: 267,
7743
7757
  S: this,
7744
7758
  A: [
7745
7759
  "factory",
@@ -7765,7 +7779,7 @@ var ServiceContext = class extends Resource7 {
7765
7779
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
7766
7780
  await this._initialize(new Context9(void 0, {
7767
7781
  F: __dxlog_file28,
7768
- L: 285
7782
+ L: 286
7769
7783
  }));
7770
7784
  return identity;
7771
7785
  }
@@ -7779,7 +7793,7 @@ var ServiceContext = class extends Resource7 {
7779
7793
  async _initialize(ctx) {
7780
7794
  log24("initializing spaces...", void 0, {
7781
7795
  F: __dxlog_file28,
7782
- L: 300,
7796
+ L: 301,
7783
7797
  S: this,
7784
7798
  C: (f, a) => f(...a)
7785
7799
  });
@@ -7818,7 +7832,7 @@ var ServiceContext = class extends Resource7 {
7818
7832
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
7819
7833
  invariant20(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7820
7834
  F: __dxlog_file28,
7821
- L: 338,
7835
+ L: 339,
7822
7836
  S: this,
7823
7837
  A: [
7824
7838
  "this.dataSpaceManager",
@@ -7842,7 +7856,7 @@ var ServiceContext = class extends Resource7 {
7842
7856
  details: assertion
7843
7857
  }, {
7844
7858
  F: __dxlog_file28,
7845
- L: 354,
7859
+ L: 355,
7846
7860
  S: this,
7847
7861
  C: (f, a) => f(...a)
7848
7862
  });
@@ -7853,7 +7867,7 @@ var ServiceContext = class extends Resource7 {
7853
7867
  details: assertion
7854
7868
  }, {
7855
7869
  F: __dxlog_file28,
7856
- L: 358,
7870
+ L: 359,
7857
7871
  S: this,
7858
7872
  C: (f, a) => f(...a)
7859
7873
  });
@@ -7864,7 +7878,7 @@ var ServiceContext = class extends Resource7 {
7864
7878
  details: assertion
7865
7879
  }, {
7866
7880
  F: __dxlog_file28,
7867
- L: 363,
7881
+ L: 364,
7868
7882
  S: this,
7869
7883
  C: (f, a) => f(...a)
7870
7884
  });
@@ -7875,7 +7889,7 @@ var ServiceContext = class extends Resource7 {
7875
7889
  } catch (err) {
7876
7890
  log24.catch(err, void 0, {
7877
7891
  F: __dxlog_file28,
7878
- L: 369,
7892
+ L: 370,
7879
7893
  S: this,
7880
7894
  C: (f, a) => f(...a)
7881
7895
  });
@@ -7891,12 +7905,12 @@ var ServiceContext = class extends Resource7 {
7891
7905
  let edgeIdentity;
7892
7906
  const identity = this.identityManager.identity;
7893
7907
  if (identity) {
7894
- log24.info("Setting identity on edge connection", {
7908
+ log24("setting identity on edge connection", {
7895
7909
  identity: identity.identityKey.toHex(),
7896
7910
  swarms: this.networkManager.topics
7897
7911
  }, {
7898
7912
  F: __dxlog_file28,
7899
- L: 383,
7913
+ L: 384,
7900
7914
  S: this,
7901
7915
  C: (f, a) => f(...a)
7902
7916
  });
@@ -7910,7 +7924,7 @@ var ServiceContext = class extends Resource7 {
7910
7924
  });
7911
7925
  invariant20(identity.deviceCredentialChain, void 0, {
7912
7926
  F: __dxlog_file28,
7913
- L: 401,
7927
+ L: 403,
7914
7928
  S: this,
7915
7929
  A: [
7916
7930
  "identity.deviceCredentialChain",
@@ -8220,7 +8234,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
8220
8234
 
8221
8235
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
8222
8236
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
8223
- import { Stream as Stream12 } from "@dxos/codec-protobuf";
8237
+ import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8224
8238
  import { invariant as invariant22 } from "@dxos/invariant";
8225
8239
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
8226
8240
  var __dxlog_file30 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
@@ -8310,7 +8324,7 @@ var DevicesServiceImpl = class {
8310
8324
 
8311
8325
  // packages/sdk/client-services/src/packlets/identity/contacts-service.ts
8312
8326
  import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask9, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
8313
- import { Stream as Stream13 } from "@dxos/codec-protobuf";
8327
+ import { Stream as Stream13 } from "@dxos/codec-protobuf/stream";
8314
8328
  import { PublicKey as PublicKey17 } from "@dxos/keys";
8315
8329
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
8316
8330
  var ContactsServiceImpl = class {
@@ -8393,7 +8407,7 @@ var ContactsServiceImpl = class {
8393
8407
 
8394
8408
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
8395
8409
  import { Event as Event10 } from "@dxos/async";
8396
- import { Stream as Stream14 } from "@dxos/codec-protobuf";
8410
+ import { Stream as Stream14 } from "@dxos/codec-protobuf/stream";
8397
8411
  import { PublicKey as PublicKey18 } from "@dxos/keys";
8398
8412
  import { getContextFromEntry, log as log26 } from "@dxos/log";
8399
8413
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
@@ -8516,7 +8530,7 @@ var shouldLog = (entry2, request) => {
8516
8530
  var LOG_PROCESSING = 0;
8517
8531
 
8518
8532
  // packages/sdk/client-services/src/packlets/network/network-service.ts
8519
- import { Stream as Stream15 } from "@dxos/codec-protobuf";
8533
+ import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
8520
8534
  var NetworkServiceImpl = class {
8521
8535
  constructor(networkManager, signalManager) {
8522
8536
  this.networkManager = networkManager;
@@ -8546,10 +8560,39 @@ var NetworkServiceImpl = class {
8546
8560
  async updateConfig(request) {
8547
8561
  await this.networkManager.setConnectionState(request.swarm);
8548
8562
  }
8563
+ async joinSwarm(request) {
8564
+ return this.signalManager.join(request);
8565
+ }
8566
+ async leaveSwarm(request) {
8567
+ return this.signalManager.leave(request);
8568
+ }
8569
+ subscribeSwarmState(request) {
8570
+ return new Stream15(({ next }) => {
8571
+ const unsubscribe = this.signalManager.swarmState?.on((state) => {
8572
+ if (request.topic.equals(state.swarmKey)) {
8573
+ next(state);
8574
+ }
8575
+ });
8576
+ return unsubscribe;
8577
+ });
8578
+ }
8579
+ async sendMessage(message) {
8580
+ return this.signalManager.sendMessage(message);
8581
+ }
8582
+ subscribeMessages(peer) {
8583
+ return new Stream15(({ next }) => {
8584
+ const unsubscribe = this.signalManager.onMessage.on((message) => {
8585
+ if (message.recipient.peerKey === peer.peerKey) {
8586
+ next(message);
8587
+ }
8588
+ });
8589
+ return unsubscribe;
8590
+ });
8591
+ }
8549
8592
  };
8550
8593
 
8551
8594
  // packages/sdk/client-services/src/packlets/system/system-service.ts
8552
- import { Stream as Stream16 } from "@dxos/codec-protobuf";
8595
+ import { Stream as Stream16 } from "@dxos/codec-protobuf/stream";
8553
8596
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
8554
8597
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
8555
8598
  var SystemServiceImpl = class {
@@ -9053,4 +9096,4 @@ export {
9053
9096
  importProfileData,
9054
9097
  ClientServicesHost
9055
9098
  };
9056
- //# sourceMappingURL=chunk-423GRVVV.mjs.map
9099
+ //# sourceMappingURL=chunk-EVMMT65L.mjs.map