@dxos/client-services 0.3.11-main.5e1976a → 0.3.11-main.604a65a

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 (36) hide show
  1. package/dist/lib/browser/{chunk-QIHAW5TM.mjs → chunk-MOW7FRV3.mjs} +127 -40
  2. package/dist/lib/browser/chunk-MOW7FRV3.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/packlets/testing/index.mjs +1 -1
  6. package/dist/lib/node/{chunk-4R65PB4H.cjs → chunk-E5I5NVZ4.cjs} +217 -130
  7. package/dist/lib/node/chunk-E5I5NVZ4.cjs.map +7 -0
  8. package/dist/lib/node/index.cjs +37 -37
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +8 -8
  11. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  12. package/dist/types/src/packlets/services/diagnostics.d.ts +32 -16
  13. package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -1
  14. package/dist/types/src/packlets/services/platform.d.ts +1 -14
  15. package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
  16. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +2 -0
  17. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -1
  18. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  19. package/dist/types/src/packlets/spaces/data-space.d.ts +2 -0
  20. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  21. package/dist/types/src/packlets/system/system-service.d.ts +3 -2
  22. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  23. package/dist/types/src/version.d.ts +1 -1
  24. package/package.json +35 -35
  25. package/src/packlets/identity/identity-manager.ts +1 -1
  26. package/src/packlets/network/network-service.ts +5 -1
  27. package/src/packlets/services/diagnostics.ts +52 -16
  28. package/src/packlets/services/platform.ts +7 -19
  29. package/src/packlets/spaces/automerge-space-state.ts +4 -0
  30. package/src/packlets/spaces/data-space-manager.ts +5 -1
  31. package/src/packlets/spaces/data-space.ts +36 -3
  32. package/src/packlets/spaces/spaces-service.ts +2 -2
  33. package/src/packlets/system/system-service.ts +7 -1
  34. package/src/version.ts +1 -1
  35. package/dist/lib/browser/chunk-QIHAW5TM.mjs.map +0 -7
  36. package/dist/lib/node/chunk-4R65PB4H.cjs.map +0 -7
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_4R65PB4H_exports = {};
30
- __export(chunk_4R65PB4H_exports, {
29
+ var chunk_E5I5NVZ4_exports = {};
30
+ __export(chunk_E5I5NVZ4_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -60,7 +60,7 @@ __export(chunk_4R65PB4H_exports, {
60
60
  subscribeToSpaces: () => subscribeToSpaces,
61
61
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
62
  });
63
- module.exports = __toCommonJS(chunk_4R65PB4H_exports);
63
+ module.exports = __toCommonJS(chunk_E5I5NVZ4_exports);
64
64
  var import_async = require("@dxos/async");
65
65
  var import_codec_protobuf = require("@dxos/codec-protobuf");
66
66
  var import_feed_store = require("@dxos/feed-store");
@@ -153,23 +153,26 @@ var import_invariant9 = require("@dxos/invariant");
153
153
  var import_log8 = require("@dxos/log");
154
154
  var import_protocols7 = require("@dxos/protocols");
155
155
  var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
156
+ var import_tracing4 = require("@dxos/tracing");
157
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
156
158
  var import_async10 = require("@dxos/async");
157
159
  var import_client_protocol3 = require("@dxos/client-protocol");
158
160
  var import_context6 = require("@dxos/context");
159
161
  var import_debug4 = require("@dxos/debug");
160
162
  var import_echo_pipeline = require("@dxos/echo-pipeline");
163
+ var import_invariant10 = require("@dxos/invariant");
161
164
  var import_keys7 = require("@dxos/keys");
162
165
  var import_log9 = require("@dxos/log");
163
166
  var import_protocols8 = require("@dxos/protocols");
164
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
167
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
165
168
  var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
166
169
  var import_timeframe2 = require("@dxos/timeframe");
167
- var import_tracing4 = require("@dxos/tracing");
170
+ var import_tracing5 = require("@dxos/tracing");
168
171
  var import_util4 = require("@dxos/util");
169
172
  var import_credentials11 = require("@dxos/credentials");
170
173
  var import_async11 = require("@dxos/async");
171
174
  var import_context7 = require("@dxos/context");
172
- var import_invariant10 = require("@dxos/invariant");
175
+ var import_invariant11 = require("@dxos/invariant");
173
176
  var import_keys8 = require("@dxos/keys");
174
177
  var import_log10 = require("@dxos/log");
175
178
  var import_protocols9 = require("@dxos/protocols");
@@ -178,11 +181,11 @@ var import_util5 = require("@dxos/util");
178
181
  var import_async12 = require("@dxos/async");
179
182
  var import_context8 = require("@dxos/context");
180
183
  var import_credentials12 = require("@dxos/credentials");
181
- var import_invariant11 = require("@dxos/invariant");
184
+ var import_invariant12 = require("@dxos/invariant");
182
185
  var import_keys9 = require("@dxos/keys");
183
186
  var import_log11 = require("@dxos/log");
184
187
  var import_protocols10 = require("@dxos/protocols");
185
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
188
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
186
189
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
187
190
  var import_util6 = require("@dxos/util");
188
191
  var import_credentials13 = require("@dxos/credentials");
@@ -192,26 +195,26 @@ var import_timeframe3 = require("@dxos/timeframe");
192
195
  var import_async13 = require("@dxos/async");
193
196
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
194
197
  var import_debug6 = require("@dxos/debug");
195
- var import_invariant12 = require("@dxos/invariant");
198
+ var import_invariant13 = require("@dxos/invariant");
196
199
  var import_log12 = require("@dxos/log");
197
200
  var import_protocols11 = require("@dxos/protocols");
198
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
201
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
199
202
  var import_async14 = require("@dxos/async");
200
203
  var import_context9 = require("@dxos/context");
201
204
  var import_credentials15 = require("@dxos/credentials");
202
205
  var import_debug7 = require("@dxos/debug");
203
206
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
204
207
  var import_feed_store4 = require("@dxos/feed-store");
205
- var import_invariant13 = require("@dxos/invariant");
208
+ var import_invariant14 = require("@dxos/invariant");
206
209
  var import_keyring = require("@dxos/keyring");
207
210
  var import_keys10 = require("@dxos/keys");
208
211
  var import_log13 = require("@dxos/log");
209
212
  var import_protocols12 = require("@dxos/protocols");
210
- var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
213
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
211
214
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
212
- var import_tracing5 = require("@dxos/tracing");
215
+ var import_tracing6 = require("@dxos/tracing");
213
216
  var import_util7 = require("@dxos/util");
214
- var import_invariant14 = require("@dxos/invariant");
217
+ var import_invariant15 = require("@dxos/invariant");
215
218
  var import_lock_file = require("@dxos/lock-file");
216
219
  var import_log14 = require("@dxos/log");
217
220
  var import_client_protocol4 = require("@dxos/client-protocol");
@@ -225,28 +228,28 @@ var import_context10 = require("@dxos/context");
225
228
  var import_document_model2 = require("@dxos/document-model");
226
229
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
227
230
  var import_echo_schema = require("@dxos/echo-schema");
228
- var import_invariant15 = require("@dxos/invariant");
231
+ var import_invariant16 = require("@dxos/invariant");
229
232
  var import_keys11 = require("@dxos/keys");
230
233
  var import_log15 = require("@dxos/log");
231
234
  var import_messaging = require("@dxos/messaging");
232
235
  var import_model_factory = require("@dxos/model-factory");
233
236
  var import_network_manager2 = require("@dxos/network-manager");
234
237
  var import_protocols14 = require("@dxos/protocols");
235
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
238
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
236
239
  var import_text_model = require("@dxos/text-model");
237
- var import_tracing6 = require("@dxos/tracing");
240
+ var import_tracing7 = require("@dxos/tracing");
238
241
  var import_websocket_rpc = require("@dxos/websocket-rpc");
239
242
  var import_async16 = require("@dxos/async");
240
243
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
241
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
244
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
242
245
  var import_async17 = require("@dxos/async");
243
246
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
244
247
  var import_log16 = require("@dxos/log");
245
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
248
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
246
249
  var import_util9 = require("@dxos/util");
247
250
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
248
251
  var import_codec_protobuf15 = require("@dxos/codec-protobuf");
249
- var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
252
+ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
250
253
  var import_util10 = require("@dxos/util");
251
254
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
252
255
  return new import_codec_protobuf.Stream(({ next }) => {
@@ -1176,7 +1179,7 @@ var IdentityManager = class {
1176
1179
  genesisFeedKey: spaceRecord.genesisFeedKey
1177
1180
  },
1178
1181
  swarmIdentity,
1179
- onNetworkConnection: () => {
1182
+ onAuthorizedConnection: () => {
1180
1183
  },
1181
1184
  onAuthFailure: () => {
1182
1185
  import_log3.log.warn("auth failure", void 0, {
@@ -2650,28 +2653,29 @@ var getPlatform = () => {
2650
2653
  if (typeof window !== "undefined") {
2651
2654
  const { userAgent } = window.navigator;
2652
2655
  return {
2653
- type: "browser",
2656
+ type: import_services7.Platform.PLATFORM_TYPE.BROWSER,
2654
2657
  userAgent,
2655
2658
  uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2656
2659
  };
2657
2660
  } else {
2658
2661
  return {
2659
- type: "shared-worker",
2662
+ type: import_services7.Platform.PLATFORM_TYPE.SHARED_WORKER,
2660
2663
  uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2661
2664
  };
2662
2665
  }
2663
2666
  } else {
2664
2667
  const { platform: platform2, version, arch } = process;
2665
2668
  return {
2666
- type: "node",
2667
- platform: `${platform2} ${version} ${arch}`,
2668
- runtime: process.version,
2669
+ type: import_services7.Platform.PLATFORM_TYPE.NODE,
2670
+ platform: platform2,
2671
+ arch,
2672
+ runtime: version,
2669
2673
  uptime: Math.floor(process.uptime()),
2670
2674
  memory: process.memoryUsage()
2671
2675
  };
2672
2676
  }
2673
2677
  };
2674
- var DXOS_VERSION = "0.3.11-main.5e1976a";
2678
+ var DXOS_VERSION = "0.3.11-main.604a65a";
2675
2679
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2676
2680
  var DEFAULT_TIMEOUT = 1e3;
2677
2681
  var createDiagnostics = async (clientServices, serviceContext, config) => {
@@ -2683,12 +2687,13 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
2683
2687
  storage: {
2684
2688
  version: import_protocols7.STORAGE_VERSION
2685
2689
  }
2686
- }
2690
+ },
2691
+ trace: import_tracing4.TRACE_PROCESSOR.getDiagnostics()
2687
2692
  };
2688
2693
  {
2689
2694
  (0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
2690
2695
  F: __dxlog_file10,
2691
- L: 92,
2696
+ L: 111,
2692
2697
  S: void 0,
2693
2698
  A: [
2694
2699
  "clientServices.LoggingService",
@@ -2699,6 +2704,21 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
2699
2704
  timeout: DEFAULT_TIMEOUT
2700
2705
  }).catch(() => void 0);
2701
2706
  }
2707
+ if (typeof navigator !== "undefined" && navigator.storage) {
2708
+ const map = /* @__PURE__ */ new Map();
2709
+ const dir = await navigator.storage.getDirectory();
2710
+ for await (const filename of dir?.keys()) {
2711
+ const idx = filename.indexOf("-", filename.indexOf("-") + 1);
2712
+ if (idx === -1) {
2713
+ continue;
2714
+ }
2715
+ map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
2716
+ }
2717
+ diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
2718
+ file,
2719
+ count
2720
+ }));
2721
+ }
2702
2722
  const identity = serviceContext.identityManager.identity;
2703
2723
  if (identity) {
2704
2724
  diagnostics.identity = {
@@ -2739,7 +2759,7 @@ var getProperties = (space) => {
2739
2759
  } catch (err) {
2740
2760
  import_log8.log.warn(err.message, void 0, {
2741
2761
  F: __dxlog_file10,
2742
- L: 160,
2762
+ L: 196,
2743
2763
  S: void 0,
2744
2764
  C: (f, a) => f(...a)
2745
2765
  });
@@ -2794,7 +2814,8 @@ var getSpaceStats = async (space) => {
2794
2814
  return stats;
2795
2815
  };
2796
2816
  var AutomergeSpaceState = class {
2797
- constructor() {
2817
+ constructor(_onNewRoot) {
2818
+ this._onNewRoot = _onNewRoot;
2798
2819
  this.rootUrl = void 0;
2799
2820
  this.lastEpoch = void 0;
2800
2821
  }
@@ -2805,6 +2826,7 @@ var AutomergeSpaceState = class {
2805
2826
  this.lastEpoch = credential;
2806
2827
  if (credential.subject.assertion.automergeRoot) {
2807
2828
  this.rootUrl = credential.subject.assertion.automergeRoot;
2829
+ this._onNewRoot(this.rootUrl);
2808
2830
  }
2809
2831
  }
2810
2832
  };
@@ -2841,7 +2863,7 @@ var NotarizationPlugin = class {
2841
2863
  S: this,
2842
2864
  C: (f, a) => f(...a)
2843
2865
  });
2844
- (0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
2866
+ (0, import_invariant11.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
2845
2867
  F: __dxlog_file11,
2846
2868
  L: 91,
2847
2869
  S: this,
@@ -2966,7 +2988,7 @@ var NotarizationPlugin = class {
2966
2988
  this._processCredentialsTriggers.delete(credential.id);
2967
2989
  }
2968
2990
  setWriter(writer) {
2969
- (0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
2991
+ (0, import_invariant11.invariant)(!this._writer, "Writer already set.", {
2970
2992
  F: __dxlog_file11,
2971
2993
  L: 181,
2972
2994
  S: this,
@@ -2991,7 +3013,7 @@ var NotarizationPlugin = class {
2991
3013
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2992
3014
  }
2993
3015
  for (const credential of request.credentials ?? []) {
2994
- (0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
3016
+ (0, import_invariant11.invariant)(credential.id, "Credential must have an id", {
2995
3017
  F: __dxlog_file11,
2996
3018
  L: 200,
2997
3019
  S: this,
@@ -3083,8 +3105,8 @@ var DataSpace = class {
3083
3105
  this._ctx = new import_context6.Context();
3084
3106
  this._notarizationPlugin = new NotarizationPlugin();
3085
3107
  this._cache = void 0;
3086
- this._automergeSpaceState = new AutomergeSpaceState();
3087
- this._state = import_services7.SpaceState.CLOSED;
3108
+ this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
3109
+ this._state = import_services8.SpaceState.CLOSED;
3088
3110
  this.error = void 0;
3089
3111
  this.stateUpdate = new import_async10.Event();
3090
3112
  this.metrics = {};
@@ -3106,10 +3128,10 @@ var DataSpace = class {
3106
3128
  this._cache = params.cache;
3107
3129
  this._state = params.initialState;
3108
3130
  (0, import_log9.log)("new state", {
3109
- state: import_services7.SpaceState[this._state]
3131
+ state: import_services8.SpaceState[this._state]
3110
3132
  }, {
3111
3133
  F: __dxlog_file12,
3112
- L: 137,
3134
+ L: 141,
3113
3135
  S: this,
3114
3136
  C: (f, a) => f(...a)
3115
3137
  });
@@ -3142,6 +3164,12 @@ var DataSpace = class {
3142
3164
  get automergeSpaceState() {
3143
3165
  return this._automergeSpaceState;
3144
3166
  }
3167
+ get _automergeInfo() {
3168
+ return {
3169
+ rootUrl: this._automergeSpaceState.rootUrl,
3170
+ lastEpoch: this._automergeSpaceState.lastEpoch
3171
+ };
3172
+ }
3145
3173
  async open() {
3146
3174
  await this._open();
3147
3175
  }
@@ -3151,12 +3179,12 @@ var DataSpace = class {
3151
3179
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
3152
3180
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
3153
3181
  await this._inner.open(new import_context6.Context());
3154
- this._state = import_services7.SpaceState.CONTROL_ONLY;
3182
+ this._state = import_services8.SpaceState.CONTROL_ONLY;
3155
3183
  (0, import_log9.log)("new state", {
3156
- state: import_services7.SpaceState[this._state]
3184
+ state: import_services8.SpaceState[this._state]
3157
3185
  }, {
3158
3186
  F: __dxlog_file12,
3159
- L: 189,
3187
+ L: 203,
3160
3188
  S: this,
3161
3189
  C: (f, a) => f(...a)
3162
3190
  });
@@ -3169,12 +3197,12 @@ var DataSpace = class {
3169
3197
  }
3170
3198
  async _close() {
3171
3199
  await this._callbacks.beforeClose?.();
3172
- this._state = import_services7.SpaceState.CLOSED;
3200
+ this._state = import_services8.SpaceState.CLOSED;
3173
3201
  (0, import_log9.log)("new state", {
3174
- state: import_services7.SpaceState[this._state]
3202
+ state: import_services8.SpaceState[this._state]
3175
3203
  }, {
3176
3204
  F: __dxlog_file12,
3177
- L: 203,
3205
+ L: 217,
3178
3206
  S: this,
3179
3207
  C: (f, a) => f(...a)
3180
3208
  });
@@ -3203,10 +3231,10 @@ var DataSpace = class {
3203
3231
  this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
3204
3232
  await this.initializeDataPipeline();
3205
3233
  } catch (err) {
3206
- if (err instanceof import_protocols8.CancelledError) {
3234
+ if (err instanceof import_protocols8.CancelledError || err instanceof import_context6.ContextDisposedError) {
3207
3235
  (0, import_log9.log)("data pipeline initialization cancelled", err, {
3208
3236
  F: __dxlog_file12,
3209
- L: 236,
3237
+ L: 250,
3210
3238
  S: this,
3211
3239
  C: (f, a) => f(...a)
3212
3240
  });
@@ -3214,16 +3242,16 @@ var DataSpace = class {
3214
3242
  }
3215
3243
  import_log9.log.error("Error initializing data pipeline", err, {
3216
3244
  F: __dxlog_file12,
3217
- L: 240,
3245
+ L: 254,
3218
3246
  S: this,
3219
3247
  C: (f, a) => f(...a)
3220
3248
  });
3221
- this._state = import_services7.SpaceState.ERROR;
3249
+ this._state = import_services8.SpaceState.ERROR;
3222
3250
  (0, import_log9.log)("new state", {
3223
- state: import_services7.SpaceState[this._state]
3251
+ state: import_services8.SpaceState[this._state]
3224
3252
  }, {
3225
3253
  F: __dxlog_file12,
3226
- L: 242,
3254
+ L: 256,
3227
3255
  S: this,
3228
3256
  C: (f, a) => f(...a)
3229
3257
  });
@@ -3235,15 +3263,15 @@ var DataSpace = class {
3235
3263
  });
3236
3264
  }
3237
3265
  async initializeDataPipeline() {
3238
- if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
3266
+ if (this._state !== import_services8.SpaceState.CONTROL_ONLY) {
3239
3267
  throw new import_protocols8.SystemError("Invalid operation");
3240
3268
  }
3241
- this._state = import_services7.SpaceState.INITIALIZING;
3269
+ this._state = import_services8.SpaceState.INITIALIZING;
3242
3270
  (0, import_log9.log)("new state", {
3243
- state: import_services7.SpaceState[this._state]
3271
+ state: import_services8.SpaceState[this._state]
3244
3272
  }, {
3245
3273
  F: __dxlog_file12,
3246
- L: 258,
3274
+ L: 272,
3247
3275
  S: this,
3248
3276
  C: (f, a) => f(...a)
3249
3277
  });
@@ -3254,7 +3282,7 @@ var DataSpace = class {
3254
3282
  await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
3255
3283
  (0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
3256
3284
  F: __dxlog_file12,
3257
- L: 272,
3285
+ L: 286,
3258
3286
  S: this,
3259
3287
  C: (f, a) => f(...a)
3260
3288
  });
@@ -3265,17 +3293,17 @@ var DataSpace = class {
3265
3293
  this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
3266
3294
  (0, import_log9.log)("data pipeline ready", void 0, {
3267
3295
  F: __dxlog_file12,
3268
- L: 281,
3296
+ L: 295,
3269
3297
  S: this,
3270
3298
  C: (f, a) => f(...a)
3271
3299
  });
3272
3300
  await this._callbacks.beforeReady?.();
3273
- this._state = import_services7.SpaceState.READY;
3301
+ this._state = import_services8.SpaceState.READY;
3274
3302
  (0, import_log9.log)("new state", {
3275
- state: import_services7.SpaceState[this._state]
3303
+ state: import_services8.SpaceState[this._state]
3276
3304
  }, {
3277
3305
  F: __dxlog_file12,
3278
- L: 285,
3306
+ L: 299,
3279
3307
  S: this,
3280
3308
  C: (f, a) => f(...a)
3281
3309
  });
@@ -3291,7 +3319,7 @@ var DataSpace = class {
3291
3319
  await this._createWritableFeeds();
3292
3320
  (0, import_log9.log)("writable feeds created", void 0, {
3293
3321
  F: __dxlog_file12,
3294
- L: 301,
3322
+ L: 315,
3295
3323
  S: this,
3296
3324
  C: (f, a) => f(...a)
3297
3325
  });
@@ -3348,6 +3376,40 @@ var DataSpace = class {
3348
3376
  await this._metadataStore.setWritableFeedKeys(this.key, this.inner.controlFeedKey, this.inner.dataFeedKey);
3349
3377
  }
3350
3378
  }
3379
+ _onNewAutomergeRoot(rootUrl) {
3380
+ (0, import_log9.log)("loading automerge root doc for space", {
3381
+ space: this.key,
3382
+ rootUrl
3383
+ }, {
3384
+ F: __dxlog_file12,
3385
+ L: 381,
3386
+ S: this,
3387
+ C: (f, a) => f(...a)
3388
+ });
3389
+ const handle = this._automergeHost.repo.find(rootUrl);
3390
+ queueMicrotask(async () => {
3391
+ try {
3392
+ await handle.whenReady();
3393
+ const doc = handle.docSync() ?? (0, import_invariant10.failedInvariant)();
3394
+ if (!doc.experimental_spaceKey) {
3395
+ handle.change((doc2) => {
3396
+ doc2.experimental_spaceKey = this.key.toHex();
3397
+ });
3398
+ }
3399
+ } catch (err) {
3400
+ import_log9.log.warn("error loading automerge root doc", {
3401
+ space: this.key,
3402
+ rootUrl,
3403
+ err
3404
+ }, {
3405
+ F: __dxlog_file12,
3406
+ L: 394,
3407
+ S: this,
3408
+ C: (f, a) => f(...a)
3409
+ });
3410
+ }
3411
+ });
3412
+ }
3351
3413
  // TODO(dmaretskyi): Use profile from signing context.
3352
3414
  async updateOwnProfile(profile) {
3353
3415
  const credential = await this._signingContext.credentialSigner.createCredential({
@@ -3367,12 +3429,12 @@ var DataSpace = class {
3367
3429
  let epoch;
3368
3430
  switch (options?.migration) {
3369
3431
  case void 0:
3370
- case import_services7.CreateEpochRequest.Migration.NONE:
3432
+ case import_services8.CreateEpochRequest.Migration.NONE:
3371
3433
  {
3372
3434
  epoch = await this.dataPipeline.createEpoch();
3373
3435
  }
3374
3436
  break;
3375
- case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
3437
+ case import_services8.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
3376
3438
  const document = this._automergeHost.repo.create();
3377
3439
  epoch = {
3378
3440
  previousId: this._automergeSpaceState.lastEpoch?.id,
@@ -3413,31 +3475,47 @@ var DataSpace = class {
3413
3475
  }
3414
3476
  }
3415
3477
  async activate() {
3416
- if (this._state !== import_services7.SpaceState.INACTIVE) {
3478
+ if (this._state !== import_services8.SpaceState.INACTIVE) {
3417
3479
  return;
3418
3480
  }
3419
- await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
3481
+ await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.ACTIVE);
3420
3482
  await this._open();
3421
3483
  this.initializeDataPipelineAsync();
3422
3484
  }
3423
3485
  async deactivate() {
3424
- if (this._state === import_services7.SpaceState.INACTIVE) {
3486
+ if (this._state === import_services8.SpaceState.INACTIVE) {
3425
3487
  return;
3426
3488
  }
3427
- await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
3489
+ await this._metadataStore.setSpaceState(this.key, import_services8.SpaceState.INACTIVE);
3428
3490
  await this._close();
3429
- this._state = import_services7.SpaceState.INACTIVE;
3491
+ this._state = import_services8.SpaceState.INACTIVE;
3430
3492
  (0, import_log9.log)("new state", {
3431
- state: import_services7.SpaceState[this._state]
3493
+ state: import_services8.SpaceState[this._state]
3432
3494
  }, {
3433
3495
  F: __dxlog_file12,
3434
- L: 450,
3496
+ L: 483,
3435
3497
  S: this,
3436
3498
  C: (f, a) => f(...a)
3437
3499
  });
3438
3500
  this.stateUpdate.emit();
3439
3501
  }
3440
3502
  };
3503
+ _ts_decorate4([
3504
+ import_tracing5.trace.info()
3505
+ ], DataSpace.prototype, "_inner", void 0);
3506
+ _ts_decorate4([
3507
+ import_tracing5.trace.info()
3508
+ ], DataSpace.prototype, "key", null);
3509
+ _ts_decorate4([
3510
+ import_tracing5.trace.info({
3511
+ enum: import_services8.SpaceState
3512
+ })
3513
+ ], DataSpace.prototype, "state", null);
3514
+ _ts_decorate4([
3515
+ import_tracing5.trace.info({
3516
+ depth: null
3517
+ })
3518
+ ], DataSpace.prototype, "_automergeInfo", null);
3441
3519
  _ts_decorate4([
3442
3520
  import_async10.synchronized
3443
3521
  ], DataSpace.prototype, "open", null);
@@ -3445,12 +3523,12 @@ _ts_decorate4([
3445
3523
  import_async10.synchronized
3446
3524
  ], DataSpace.prototype, "close", null);
3447
3525
  _ts_decorate4([
3448
- import_tracing4.trace.span({
3526
+ import_tracing5.trace.span({
3449
3527
  showInBrowserTimeline: true
3450
3528
  })
3451
3529
  ], DataSpace.prototype, "initializeDataPipeline", null);
3452
3530
  _ts_decorate4([
3453
- import_tracing4.trace.span({
3531
+ import_tracing5.trace.span({
3454
3532
  showInBrowserTimeline: true
3455
3533
  })
3456
3534
  ], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
@@ -3464,7 +3542,8 @@ _ts_decorate4([
3464
3542
  import_async10.synchronized
3465
3543
  ], DataSpace.prototype, "deactivate", null);
3466
3544
  DataSpace = _ts_decorate4([
3467
- (0, import_async10.trackLeaks)("open", "close")
3545
+ (0, import_async10.trackLeaks)("open", "close"),
3546
+ import_tracing5.trace.resource()
3468
3547
  ], DataSpace);
3469
3548
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3470
3549
  const credentials = [
@@ -3611,7 +3690,7 @@ var DataSpaceManager = class {
3611
3690
  this._isOpen = true;
3612
3691
  this.updated.emit();
3613
3692
  for (const space of this._spaces.values()) {
3614
- if (space.state !== import_services8.SpaceState.INACTIVE) {
3693
+ if (space.state !== import_services9.SpaceState.INACTIVE) {
3615
3694
  space.initializeDataPipelineAsync();
3616
3695
  }
3617
3696
  }
@@ -3641,7 +3720,7 @@ var DataSpaceManager = class {
3641
3720
  * Creates a new space writing the genesis credentials to the control feed.
3642
3721
  */
3643
3722
  async createSpace() {
3644
- (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3723
+ (0, import_invariant12.invariant)(this._isOpen, "Not open.", {
3645
3724
  F: __dxlog_file13,
3646
3725
  L: 130,
3647
3726
  S: this,
@@ -3658,7 +3737,7 @@ var DataSpaceManager = class {
3658
3737
  genesisFeedKey: controlFeedKey,
3659
3738
  controlFeedKey,
3660
3739
  dataFeedKey,
3661
- state: import_services8.SpaceState.ACTIVE
3740
+ state: import_services9.SpaceState.ACTIVE
3662
3741
  };
3663
3742
  (0, import_log11.log)("creating space...", {
3664
3743
  spaceKey
@@ -3670,12 +3749,15 @@ var DataSpaceManager = class {
3670
3749
  });
3671
3750
  const space = await this._constructSpace(metadata);
3672
3751
  const automergeRoot = this._automergeHost.repo.create();
3752
+ automergeRoot.change((doc) => {
3753
+ doc.experimental_spaceKey = spaceKey.toHex();
3754
+ });
3673
3755
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
3674
3756
  await this._metadataStore.addSpace(metadata);
3675
3757
  const memberCredential = credentials[1];
3676
- (0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3758
+ (0, import_invariant12.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3677
3759
  F: __dxlog_file13,
3678
- L: 151,
3760
+ L: 154,
3679
3761
  S: this,
3680
3762
  A: [
3681
3763
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3693,22 +3775,22 @@ var DataSpaceManager = class {
3693
3775
  opts
3694
3776
  }, {
3695
3777
  F: __dxlog_file13,
3696
- L: 163,
3778
+ L: 166,
3697
3779
  S: this,
3698
3780
  C: (f, a) => f(...a)
3699
3781
  });
3700
- (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3782
+ (0, import_invariant12.invariant)(this._isOpen, "Not open.", {
3701
3783
  F: __dxlog_file13,
3702
- L: 164,
3784
+ L: 167,
3703
3785
  S: this,
3704
3786
  A: [
3705
3787
  "this._isOpen",
3706
3788
  "'Not open.'"
3707
3789
  ]
3708
3790
  });
3709
- (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3791
+ (0, import_invariant12.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3710
3792
  F: __dxlog_file13,
3711
- L: 165,
3793
+ L: 168,
3712
3794
  S: this,
3713
3795
  A: [
3714
3796
  "!this._spaces.has(opts.spaceKey)",
@@ -3735,7 +3817,7 @@ var DataSpaceManager = class {
3735
3817
  async waitUntilSpaceReady(spaceKey) {
3736
3818
  await (0, import_context8.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
3737
3819
  const space = this._spaces.get(spaceKey);
3738
- return !!space && space.state === import_services8.SpaceState.READY;
3820
+ return !!space && space.state === import_services9.SpaceState.READY;
3739
3821
  }));
3740
3822
  }
3741
3823
  async _constructSpace(metadata) {
@@ -3743,7 +3825,7 @@ var DataSpaceManager = class {
3743
3825
  metadata
3744
3826
  }, {
3745
3827
  F: __dxlog_file13,
3746
- L: 198,
3828
+ L: 201,
3747
3829
  S: this,
3748
3830
  C: (f, a) => f(...a)
3749
3831
  });
@@ -3770,17 +3852,18 @@ var DataSpaceManager = class {
3770
3852
  credentialProvider: createAuthProvider(this._signingContext.credentialSigner),
3771
3853
  credentialAuthenticator: (0, import_util6.deferFunction)(() => dataSpace.authVerifier.verifier)
3772
3854
  },
3773
- onNetworkConnection: (session) => {
3855
+ onAuthorizedConnection: (session) => {
3774
3856
  session.addExtension("dxos.mesh.teleport.gossip", gossip.createExtension({
3775
3857
  remotePeerId: session.remotePeerId
3776
3858
  }));
3777
3859
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
3860
+ this._automergeHost.authorizeDevice(space.key, session.remotePeerId);
3778
3861
  session.addExtension("dxos.mesh.teleport.automerge", this._automergeHost.createExtension());
3779
3862
  },
3780
3863
  onAuthFailure: () => {
3781
3864
  import_log11.log.warn("auth failure", void 0, {
3782
3865
  F: __dxlog_file13,
3783
- L: 234,
3866
+ L: 238,
3784
3867
  S: this,
3785
3868
  C: (f, a) => f(...a)
3786
3869
  });
@@ -3791,7 +3874,7 @@ var DataSpaceManager = class {
3791
3874
  dataFeed && space.setDataFeed(dataFeed);
3792
3875
  const dataSpace = new DataSpace({
3793
3876
  inner: space,
3794
- initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
3877
+ initialState: metadata.state === import_services9.SpaceState.INACTIVE ? import_services9.SpaceState.INACTIVE : import_services9.SpaceState.CLOSED,
3795
3878
  metadataStore: this._metadataStore,
3796
3879
  gossip,
3797
3880
  presence,
@@ -3804,7 +3887,7 @@ var DataSpaceManager = class {
3804
3887
  space: space.key
3805
3888
  }, {
3806
3889
  F: __dxlog_file13,
3807
- L: 252,
3890
+ L: 256,
3808
3891
  S: this,
3809
3892
  C: (f, a) => f(...a)
3810
3893
  });
@@ -3816,7 +3899,7 @@ var DataSpaceManager = class {
3816
3899
  open: this._isOpen
3817
3900
  }, {
3818
3901
  F: __dxlog_file13,
3819
- L: 259,
3902
+ L: 263,
3820
3903
  S: this,
3821
3904
  C: (f, a) => f(...a)
3822
3905
  });
@@ -3829,7 +3912,7 @@ var DataSpaceManager = class {
3829
3912
  space: space.key
3830
3913
  }, {
3831
3914
  F: __dxlog_file13,
3832
- L: 265,
3915
+ L: 269,
3833
3916
  S: this,
3834
3917
  C: (f, a) => f(...a)
3835
3918
  });
@@ -3839,7 +3922,7 @@ var DataSpaceManager = class {
3839
3922
  cache: metadata.cache,
3840
3923
  automergeHost: this._automergeHost
3841
3924
  });
3842
- if (metadata.state !== import_services8.SpaceState.INACTIVE) {
3925
+ if (metadata.state !== import_services9.SpaceState.INACTIVE) {
3843
3926
  await dataSpace.open();
3844
3927
  }
3845
3928
  if (metadata.controlTimeframe) {
@@ -3888,10 +3971,10 @@ var SpacesServiceImpl = class {
3888
3971
  const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug6.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
3889
3972
  if (state) {
3890
3973
  switch (state) {
3891
- case import_services9.SpaceState.ACTIVE:
3974
+ case import_services10.SpaceState.ACTIVE:
3892
3975
  await space.activate();
3893
3976
  break;
3894
- case import_services9.SpaceState.INACTIVE:
3977
+ case import_services10.SpaceState.INACTIVE:
3895
3978
  await space.deactivate();
3896
3979
  break;
3897
3980
  default:
@@ -3992,7 +4075,7 @@ var SpacesServiceImpl = class {
3992
4075
  }
3993
4076
  });
3994
4077
  } else {
3995
- (0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
4078
+ (0, import_invariant13.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
3996
4079
  F: __dxlog_file14,
3997
4080
  L: 168,
3998
4081
  S: this,
@@ -4001,7 +4084,7 @@ var SpacesServiceImpl = class {
4001
4084
  "'Id on unsigned credentials is not allowed'"
4002
4085
  ]
4003
4086
  });
4004
- (0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
4087
+ (0, import_invariant13.invariant)(this._identityManager.identity, "Identity is not available", {
4005
4088
  F: __dxlog_file14,
4006
4089
  L: 169,
4007
4090
  S: this,
@@ -4011,7 +4094,7 @@ var SpacesServiceImpl = class {
4011
4094
  ]
4012
4095
  });
4013
4096
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
4014
- (0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
4097
+ (0, import_invariant13.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
4015
4098
  F: __dxlog_file14,
4016
4099
  L: 171,
4017
4100
  S: this,
@@ -4068,7 +4151,7 @@ var SpacesServiceImpl = class {
4068
4151
  displayName: member.profile?.displayName
4069
4152
  }
4070
4153
  },
4071
- presence: member.removed ? import_services9.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
4154
+ presence: member.removed ? import_services10.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services10.SpaceMember.PresenceState.ONLINE : import_services10.SpaceMember.PresenceState.OFFLINE,
4072
4155
  peerStates: peers
4073
4156
  };
4074
4157
  }),
@@ -4125,7 +4208,7 @@ var ServiceContext = class {
4125
4208
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
4126
4209
  this.automergeHost = new import_echo_pipeline2.AutomergeHost(storage.createDirectory("automerge"));
4127
4210
  this.invitations = new InvitationsHandler(this.networkManager);
4128
- this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
4211
+ this._handlerFactories.set(import_services11.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
4129
4212
  }
4130
4213
  async open(ctx) {
4131
4214
  await this._checkStorageVersion();
@@ -4199,7 +4282,7 @@ var ServiceContext = class {
4199
4282
  }
4200
4283
  getInvitationHandler(invitation) {
4201
4284
  const factory = this._handlerFactories.get(invitation.kind);
4202
- (0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4285
+ (0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4203
4286
  F: __dxlog_file15,
4204
4287
  L: 173,
4205
4288
  S: this,
@@ -4253,8 +4336,8 @@ var ServiceContext = class {
4253
4336
  };
4254
4337
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore, this.automergeHost);
4255
4338
  await this.dataSpaceManager.open();
4256
- this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
4257
- (0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4339
+ this._handlerFactories.set(import_services11.Invitation.Kind.SPACE, (invitation) => {
4340
+ (0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4258
4341
  F: __dxlog_file15,
4259
4342
  L: 228,
4260
4343
  S: this,
@@ -4324,14 +4407,14 @@ var ServiceContext = class {
4324
4407
  }
4325
4408
  };
4326
4409
  _ts_decorate6([
4327
- import_tracing5.trace.span()
4410
+ import_tracing6.trace.span()
4328
4411
  ], ServiceContext.prototype, "open", null);
4329
4412
  _ts_decorate6([
4330
- import_tracing5.trace.span()
4413
+ import_tracing6.trace.span()
4331
4414
  ], ServiceContext.prototype, "_initialize", null);
4332
4415
  ServiceContext = _ts_decorate6([
4333
4416
  (0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
4334
- import_tracing5.trace.resource()
4417
+ import_tracing6.trace.resource()
4335
4418
  ], ServiceContext);
4336
4419
  var ServiceRegistry = class {
4337
4420
  // prettier-ignore
@@ -4393,7 +4476,7 @@ var Lock = class {
4393
4476
  }
4394
4477
  async release() {
4395
4478
  await this._onRelease?.();
4396
- (0, import_invariant14.invariant)(this._fileHandle, "Lock is not acquired", {
4479
+ (0, import_invariant15.invariant)(this._fileHandle, "Lock is not acquired", {
4397
4480
  F: __dxlog_file16,
4398
4481
  L: 42,
4399
4482
  S: this,
@@ -4470,7 +4553,7 @@ var DevicesServiceImpl = class {
4470
4553
  next({
4471
4554
  devices: Array.from(deviceKeys.entries()).map(([key, profile]) => ({
4472
4555
  deviceKey: key,
4473
- kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services12.DeviceKind.CURRENT : import_services12.DeviceKind.TRUSTED,
4556
+ kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services13.DeviceKind.CURRENT : import_services13.DeviceKind.TRUSTED,
4474
4557
  profile
4475
4558
  }))
4476
4559
  });
@@ -4585,16 +4668,16 @@ var LoggingServiceImpl = class {
4585
4668
  };
4586
4669
  var matchFilter = (filter, level, path, options) => {
4587
4670
  switch (options) {
4588
- case import_services13.QueryLogsRequest.MatchingOptions.INCLUSIVE:
4671
+ case import_services14.QueryLogsRequest.MatchingOptions.INCLUSIVE:
4589
4672
  return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
4590
- case import_services13.QueryLogsRequest.MatchingOptions.EXPLICIT:
4673
+ case import_services14.QueryLogsRequest.MatchingOptions.EXPLICIT:
4591
4674
  return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
4592
4675
  }
4593
4676
  };
4594
4677
  var shouldLog = (entry2, request) => {
4595
- const options = request.options ?? import_services13.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4678
+ const options = request.options ?? import_services14.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4596
4679
  if (request.filters === void 0) {
4597
- return options === import_services13.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4680
+ return options === import_services14.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4598
4681
  } else {
4599
4682
  return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
4600
4683
  }
@@ -4610,6 +4693,7 @@ var NetworkServiceImpl = class {
4610
4693
  const update = () => {
4611
4694
  next({
4612
4695
  swarm: this.networkManager.connectionState,
4696
+ connectionInfo: this.networkManager.connectionLog?.swarms,
4613
4697
  signaling: this.signalManager.getStatus().map(({ host, state }) => ({
4614
4698
  server: host,
4615
4699
  state
@@ -4649,11 +4733,14 @@ var SystemServiceImpl = class {
4649
4733
  return {
4650
4734
  timestamp: /* @__PURE__ */ new Date(),
4651
4735
  diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util10.jsonKeyReplacer)({
4652
- truncate: keys === import_services14.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4653
- humanize: keys === import_services14.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
4736
+ truncate: keys === import_services15.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4737
+ humanize: keys === import_services15.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
4654
4738
  })))
4655
4739
  };
4656
4740
  }
4741
+ async getPlatform() {
4742
+ return getPlatform();
4743
+ }
4657
4744
  async updateStatus({ status }) {
4658
4745
  await this._onUpdateStatus(status);
4659
4746
  }
@@ -4715,7 +4802,7 @@ var ClientServicesHost = class {
4715
4802
  lockKey,
4716
4803
  callbacks
4717
4804
  } = {}) {
4718
- this._tracingService = import_tracing6.TRACE_PROCESSOR.createTraceSender();
4805
+ this._tracingService = import_tracing7.TRACE_PROCESSOR.createTraceSender();
4719
4806
  this._statusUpdate = new import_async15.Event();
4720
4807
  this._opening = false;
4721
4808
  this._open = false;
@@ -4743,14 +4830,14 @@ var ClientServicesHost = class {
4743
4830
  this._systemService = new SystemServiceImpl({
4744
4831
  config: this._config,
4745
4832
  statusUpdate: this._statusUpdate,
4746
- getCurrentStatus: () => this.isOpen ? import_services11.SystemStatus.ACTIVE : import_services11.SystemStatus.INACTIVE,
4833
+ getCurrentStatus: () => this.isOpen ? import_services12.SystemStatus.ACTIVE : import_services12.SystemStatus.INACTIVE,
4747
4834
  getDiagnostics: () => {
4748
4835
  return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
4749
4836
  },
4750
4837
  onUpdateStatus: async (status) => {
4751
- if (!this.isOpen && status === import_services11.SystemStatus.ACTIVE) {
4838
+ if (!this.isOpen && status === import_services12.SystemStatus.ACTIVE) {
4752
4839
  await this._resourceLock?.acquire();
4753
- } else if (this.isOpen && status === import_services11.SystemStatus.INACTIVE) {
4840
+ } else if (this.isOpen && status === import_services12.SystemStatus.INACTIVE) {
4754
4841
  await this._resourceLock?.release();
4755
4842
  }
4756
4843
  },
@@ -4788,7 +4875,7 @@ var ClientServicesHost = class {
4788
4875
  * Can only be called once.
4789
4876
  */
4790
4877
  initialize({ config, ...options }) {
4791
- (0, import_invariant15.invariant)(!this._open, "service host is open", {
4878
+ (0, import_invariant16.invariant)(!this._open, "service host is open", {
4792
4879
  F: __dxlog_file17,
4793
4880
  L: 201,
4794
4881
  S: this,
@@ -4804,7 +4891,7 @@ var ClientServicesHost = class {
4804
4891
  C: (f, a) => f(...a)
4805
4892
  });
4806
4893
  if (config) {
4807
- (0, import_invariant15.invariant)(!this._config, "config already set", {
4894
+ (0, import_invariant16.invariant)(!this._config, "config already set", {
4808
4895
  F: __dxlog_file17,
4809
4896
  L: 205,
4810
4897
  S: this,
@@ -4822,7 +4909,7 @@ var ClientServicesHost = class {
4822
4909
  iceServers: this._config?.get("runtime.services.ice")
4823
4910
  }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
4824
4911
  this._signalManager = signalManager;
4825
- (0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
4912
+ (0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
4826
4913
  F: __dxlog_file17,
4827
4914
  L: 221,
4828
4915
  S: this,
@@ -4856,7 +4943,7 @@ var ClientServicesHost = class {
4856
4943
  S: this,
4857
4944
  C: (f, a) => f(...a)
4858
4945
  });
4859
- (0, import_invariant15.invariant)(this._config, "config not set", {
4946
+ (0, import_invariant16.invariant)(this._config, "config not set", {
4860
4947
  F: __dxlog_file17,
4861
4948
  L: 241,
4862
4949
  S: this,
@@ -4865,7 +4952,7 @@ var ClientServicesHost = class {
4865
4952
  "'config not set'"
4866
4953
  ]
4867
4954
  });
4868
- (0, import_invariant15.invariant)(this._storage, "storage not set", {
4955
+ (0, import_invariant16.invariant)(this._storage, "storage not set", {
4869
4956
  F: __dxlog_file17,
4870
4957
  L: 242,
4871
4958
  S: this,
@@ -4874,7 +4961,7 @@ var ClientServicesHost = class {
4874
4961
  "'storage not set'"
4875
4962
  ]
4876
4963
  });
4877
- (0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
4964
+ (0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
4878
4965
  F: __dxlog_file17,
4879
4966
  L: 243,
4880
4967
  S: this,
@@ -4883,7 +4970,7 @@ var ClientServicesHost = class {
4883
4970
  "'signal manager not set'"
4884
4971
  ]
4885
4972
  });
4886
- (0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
4973
+ (0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
4887
4974
  F: __dxlog_file17,
4888
4975
  L: 244,
4889
4976
  S: this,
@@ -5042,7 +5129,7 @@ var ClientServicesHost = class {
5042
5129
  });
5043
5130
  } else {
5044
5131
  const automergeIndex = space.automergeSpaceState.rootUrl;
5045
- (0, import_invariant15.invariant)(automergeIndex, void 0, {
5132
+ (0, import_invariant16.invariant)(automergeIndex, void 0, {
5046
5133
  F: __dxlog_file17,
5047
5134
  L: 375,
5048
5135
  S: this,
@@ -5062,21 +5149,21 @@ var ClientServicesHost = class {
5062
5149
  }
5063
5150
  };
5064
5151
  _ts_decorate8([
5065
- import_tracing6.trace.info()
5152
+ import_tracing7.trace.info()
5066
5153
  ], ClientServicesHost.prototype, "_opening", void 0);
5067
5154
  _ts_decorate8([
5068
- import_tracing6.trace.info()
5155
+ import_tracing7.trace.info()
5069
5156
  ], ClientServicesHost.prototype, "_open", void 0);
5070
5157
  _ts_decorate8([
5071
5158
  import_async15.synchronized,
5072
- import_tracing6.trace.span()
5159
+ import_tracing7.trace.span()
5073
5160
  ], ClientServicesHost.prototype, "open", null);
5074
5161
  _ts_decorate8([
5075
5162
  import_async15.synchronized,
5076
- import_tracing6.trace.span()
5163
+ import_tracing7.trace.span()
5077
5164
  ], ClientServicesHost.prototype, "close", null);
5078
5165
  ClientServicesHost = _ts_decorate8([
5079
- import_tracing6.trace.resource()
5166
+ import_tracing7.trace.resource()
5080
5167
  ], ClientServicesHost);
5081
5168
  // Annotate the CommonJS export names for ESM import in node:
5082
5169
  0 && (module.exports = {
@@ -5112,4 +5199,4 @@ ClientServicesHost = _ts_decorate8([
5112
5199
  subscribeToSpaces,
5113
5200
  subscribeToSwarmInfo
5114
5201
  });
5115
- //# sourceMappingURL=chunk-4R65PB4H.cjs.map
5202
+ //# sourceMappingURL=chunk-E5I5NVZ4.cjs.map