@dxos/client-services 0.4.10-main.d9dc7ae → 0.4.10-main.e9f9c10

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 (64) hide show
  1. package/dist/lib/browser/{chunk-WYFJLESV.mjs → chunk-4GN43XQ4.mjs} +708 -561
  2. package/dist/lib/browser/chunk-4GN43XQ4.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +9 -3
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +8 -4
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-SF4YXR7W.cjs → chunk-V7W7YK6W.cjs} +663 -599
  9. package/dist/lib/node/chunk-V7W7YK6W.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +45 -39
  11. package/dist/lib/node/index.cjs.map +1 -1
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/packlets/testing/index.cjs +13 -9
  14. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  15. package/dist/types/src/index.d.ts +1 -0
  16. package/dist/types/src/index.d.ts.map +1 -1
  17. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +5 -0
  18. package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -0
  19. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +5 -0
  20. package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -0
  21. package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts +15 -0
  22. package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -0
  23. package/dist/types/src/packlets/{services → diagnostics}/diagnostics.d.ts +1 -1
  24. package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -0
  25. package/dist/types/src/packlets/diagnostics/index.d.ts +4 -0
  26. package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -0
  27. package/dist/types/src/packlets/invitations/invitations-handler.d.ts +0 -1
  28. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  29. package/dist/types/src/packlets/invitations/invitations-service.d.ts.map +1 -1
  30. package/dist/types/src/packlets/services/index.d.ts +1 -1
  31. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  32. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  33. package/dist/types/src/packlets/services/service-host.d.ts +4 -1
  34. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  35. package/dist/types/src/packlets/services/util.d.ts +1 -0
  36. package/dist/types/src/packlets/services/util.d.ts.map +1 -1
  37. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  38. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  39. package/dist/types/src/packlets/testing/test-builder.d.ts +4 -1
  40. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  41. package/dist/types/src/version.d.ts +1 -1
  42. package/package.json +35 -34
  43. package/src/index.ts +1 -0
  44. package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
  45. package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
  46. package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
  47. package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
  48. package/src/packlets/diagnostics/index.ts +7 -0
  49. package/src/packlets/invitations/invitations-handler.ts +5 -12
  50. package/src/packlets/invitations/invitations-service.ts +5 -5
  51. package/src/packlets/services/automerge-host.test.ts +9 -3
  52. package/src/packlets/services/index.ts +1 -1
  53. package/src/packlets/services/service-context.test.ts +4 -1
  54. package/src/packlets/services/service-context.ts +2 -0
  55. package/src/packlets/services/service-host.ts +21 -2
  56. package/src/packlets/services/util.ts +2 -0
  57. package/src/packlets/spaces/data-space-manager.test.ts +4 -4
  58. package/src/packlets/storage/level.ts +1 -1
  59. package/src/packlets/system/system-service.ts +1 -1
  60. package/src/packlets/testing/test-builder.ts +20 -4
  61. package/src/version.ts +1 -1
  62. package/dist/lib/browser/chunk-WYFJLESV.mjs.map +0 -7
  63. package/dist/lib/node/chunk-SF4YXR7W.cjs.map +0 -7
  64. package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
@@ -26,15 +26,17 @@ 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_SF4YXR7W_exports = {};
30
- __export(chunk_SF4YXR7W_exports, {
29
+ var chunk_V7W7YK6W_exports = {};
30
+ __export(chunk_V7W7YK6W_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
+ ClientServicesProviderResource: () => ClientServicesProviderResource,
33
34
  DataSpace: () => DataSpace,
34
35
  DataSpaceManager: () => DataSpaceManager,
35
36
  DeviceInvitationProtocol: () => DeviceInvitationProtocol,
36
37
  DevtoolsHostEvents: () => DevtoolsHostEvents,
37
38
  DevtoolsServiceImpl: () => DevtoolsServiceImpl,
39
+ DiagnosticsCollector: () => DiagnosticsCollector,
38
40
  Identity: () => Identity,
39
41
  IdentityManager: () => IdentityManager,
40
42
  IdentityServiceImpl: () => IdentityServiceImpl,
@@ -47,11 +49,12 @@ __export(chunk_SF4YXR7W_exports, {
47
49
  SpacesServiceImpl: () => SpacesServiceImpl,
48
50
  TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
49
51
  createAuthProvider: () => createAuthProvider,
52
+ createCollectDiagnosticsBroadcastHandler: () => createCollectDiagnosticsBroadcastHandler,
53
+ createCollectDiagnosticsBroadcastSender: () => createCollectDiagnosticsBroadcastSender,
50
54
  createDiagnostics: () => createDiagnostics,
51
55
  createLevel: () => createLevel,
52
56
  createStorageObjects: () => createStorageObjects,
53
57
  getNetworkPeers: () => getNetworkPeers,
54
- invitationExpired: () => invitationExpired,
55
58
  isLocked: () => isLocked,
56
59
  subscribeToFeedBlocks: () => subscribeToFeedBlocks,
57
60
  subscribeToFeeds: () => subscribeToFeeds,
@@ -61,7 +64,7 @@ __export(chunk_SF4YXR7W_exports, {
61
64
  subscribeToSpaces: () => subscribeToSpaces,
62
65
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
63
66
  });
64
- module.exports = __toCommonJS(chunk_SF4YXR7W_exports);
67
+ module.exports = __toCommonJS(chunk_V7W7YK6W_exports);
65
68
  var import_async = require("@dxos/async");
66
69
  var import_codec_protobuf = require("@dxos/codec-protobuf");
67
70
  var import_feed_store = require("@dxos/feed-store");
@@ -135,6 +138,7 @@ var import_teleport = require("@dxos/teleport");
135
138
  var import_async9 = require("@dxos/async");
136
139
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
137
140
  var import_context6 = require("@dxos/context");
141
+ var import_echo_pipeline = require("@dxos/echo-pipeline");
138
142
  var import_invariant7 = require("@dxos/invariant");
139
143
  var import_log6 = require("@dxos/log");
140
144
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
@@ -148,121 +152,127 @@ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
148
152
  var import_debug2 = require("@dxos/debug");
149
153
  var import_rpc = require("@dxos/rpc");
150
154
  var import_tracing3 = require("@dxos/tracing");
151
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
152
- var import_credentials9 = require("@dxos/credentials");
153
- var import_invariant9 = require("@dxos/invariant");
154
- var import_protocols7 = require("@dxos/protocols");
155
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
156
- var import_tracing4 = require("@dxos/tracing");
157
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
158
155
  var import_async10 = require("@dxos/async");
159
156
  var import_client_protocol3 = require("@dxos/client-protocol");
160
157
  var import_context7 = require("@dxos/context");
161
158
  var import_debug3 = require("@dxos/debug");
162
159
  var import_echo_db = require("@dxos/echo-db");
163
- var import_echo_pipeline = require("@dxos/echo-pipeline");
164
160
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
165
- var import_invariant10 = require("@dxos/invariant");
161
+ var import_echo_pipeline3 = require("@dxos/echo-pipeline");
162
+ var import_invariant9 = require("@dxos/invariant");
166
163
  var import_keys7 = require("@dxos/keys");
167
164
  var import_log8 = require("@dxos/log");
168
- var import_protocols8 = require("@dxos/protocols");
169
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
170
- var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
165
+ var import_protocols7 = require("@dxos/protocols");
166
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
167
+ var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
171
168
  var import_timeframe2 = require("@dxos/timeframe");
172
- var import_tracing5 = require("@dxos/tracing");
169
+ var import_tracing4 = require("@dxos/tracing");
173
170
  var import_util4 = require("@dxos/util");
174
171
  var import_async11 = require("@dxos/async");
175
- var import_credentials11 = require("@dxos/credentials");
172
+ var import_credentials10 = require("@dxos/credentials");
176
173
  var import_async12 = require("@dxos/async");
177
174
  var import_context8 = require("@dxos/context");
178
- var import_invariant11 = require("@dxos/invariant");
175
+ var import_invariant10 = require("@dxos/invariant");
179
176
  var import_keys8 = require("@dxos/keys");
180
177
  var import_log9 = require("@dxos/log");
181
- var import_protocols9 = require("@dxos/protocols");
178
+ var import_protocols8 = require("@dxos/protocols");
182
179
  var import_teleport2 = require("@dxos/teleport");
183
180
  var import_util5 = require("@dxos/util");
184
181
  var import_async13 = require("@dxos/async");
185
182
  var import_context9 = require("@dxos/context");
186
- var import_credentials12 = require("@dxos/credentials");
187
- var import_invariant12 = require("@dxos/invariant");
183
+ var import_credentials11 = require("@dxos/credentials");
184
+ var import_invariant11 = require("@dxos/invariant");
188
185
  var import_keys9 = require("@dxos/keys");
189
186
  var import_log10 = require("@dxos/log");
190
- var import_protocols10 = require("@dxos/protocols");
191
- var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
187
+ var import_protocols9 = require("@dxos/protocols");
188
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
192
189
  var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
193
190
  var import_util6 = require("@dxos/util");
194
- var import_credentials13 = require("@dxos/credentials");
191
+ var import_credentials12 = require("@dxos/credentials");
195
192
  var import_debug4 = require("@dxos/debug");
196
- var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
193
+ var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
197
194
  var import_timeframe3 = require("@dxos/timeframe");
198
195
  var import_async14 = require("@dxos/async");
199
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
196
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
200
197
  var import_debug5 = require("@dxos/debug");
201
- var import_invariant13 = require("@dxos/invariant");
198
+ var import_invariant12 = require("@dxos/invariant");
202
199
  var import_log11 = require("@dxos/log");
203
- var import_protocols11 = require("@dxos/protocols");
204
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
200
+ var import_protocols10 = require("@dxos/protocols");
201
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
205
202
  var import_async15 = require("@dxos/async");
206
203
  var import_context10 = require("@dxos/context");
207
- var import_credentials15 = require("@dxos/credentials");
204
+ var import_credentials14 = require("@dxos/credentials");
208
205
  var import_debug6 = require("@dxos/debug");
209
- var import_echo_pipeline3 = require("@dxos/echo-pipeline");
206
+ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
210
207
  var import_feed_store4 = require("@dxos/feed-store");
211
208
  var import_indexing = require("@dxos/indexing");
212
- var import_invariant14 = require("@dxos/invariant");
209
+ var import_invariant13 = require("@dxos/invariant");
213
210
  var import_keyring = require("@dxos/keyring");
214
211
  var import_keys10 = require("@dxos/keys");
215
212
  var import_log12 = require("@dxos/log");
216
- var import_protocols12 = require("@dxos/protocols");
217
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
213
+ var import_protocols11 = require("@dxos/protocols");
214
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
218
215
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
219
- var import_tracing6 = require("@dxos/tracing");
216
+ var import_tracing5 = require("@dxos/tracing");
220
217
  var import_util7 = require("@dxos/util");
221
218
  var import_automerge = require("@dxos/automerge/automerge");
222
219
  var import_debug7 = require("@dxos/debug");
220
+ var import_protocols12 = require("@dxos/protocols");
221
+ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
222
+ var import_credentials15 = require("@dxos/credentials");
223
+ var import_invariant14 = require("@dxos/invariant");
223
224
  var import_protocols13 = require("@dxos/protocols");
224
- var import_invariant15 = require("@dxos/invariant");
225
- var import_lock_file = require("@dxos/lock-file");
226
- var import_log13 = require("@dxos/log");
227
- var import_protocols14 = require("@dxos/protocols");
228
- var import_config = require("@dxos/protocols/proto/dxos/config");
229
- var import_random_access_storage = require("@dxos/random-access-storage");
230
- var import_client_protocol4 = require("@dxos/client-protocol");
231
- var import_config2 = require("@dxos/protocols/proto/dxos/config");
225
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
226
+ var import_tracing6 = require("@dxos/tracing");
227
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
228
+ var import_config = require("@dxos/config");
229
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
230
+ var import_tracing7 = require("@dxos/tracing");
232
231
  var import_util8 = require("@dxos/util");
233
- var import_level = require("level");
234
- var import_node_path = __toESM(require("node:path"));
235
- var import_keys11 = require("@dxos/keys");
236
232
  var import_async16 = require("@dxos/async");
237
- var import_client_protocol5 = require("@dxos/client-protocol");
233
+ var import_client_protocol4 = require("@dxos/client-protocol");
238
234
  var import_context11 = require("@dxos/context");
239
- var import_echo_pipeline4 = require("@dxos/echo-pipeline");
235
+ var import_echo_pipeline5 = require("@dxos/echo-pipeline");
240
236
  var E = __toESM(require("@dxos/echo-schema"));
241
237
  var import_indexing2 = require("@dxos/indexing");
242
- var import_invariant16 = require("@dxos/invariant");
243
- var import_keys12 = require("@dxos/keys");
244
- var import_log14 = require("@dxos/log");
238
+ var import_invariant15 = require("@dxos/invariant");
239
+ var import_keys11 = require("@dxos/keys");
240
+ var import_log13 = require("@dxos/log");
245
241
  var import_messaging = require("@dxos/messaging");
246
242
  var import_network_manager2 = require("@dxos/network-manager");
247
- var import_protocols15 = require("@dxos/protocols");
248
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
249
- var import_tracing7 = require("@dxos/tracing");
243
+ var import_protocols14 = require("@dxos/protocols");
244
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
245
+ var import_tracing8 = require("@dxos/tracing");
250
246
  var import_util9 = require("@dxos/util");
251
247
  var import_websocket_rpc = require("@dxos/websocket-rpc");
252
248
  var import_async17 = require("@dxos/async");
253
249
  var import_codec_protobuf12 = require("@dxos/codec-protobuf");
250
+ var import_invariant16 = require("@dxos/invariant");
251
+ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
254
252
  var import_invariant17 = require("@dxos/invariant");
255
- var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
253
+ var import_lock_file = require("@dxos/lock-file");
254
+ var import_log14 = require("@dxos/log");
256
255
  var import_async18 = require("@dxos/async");
257
256
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
258
- var import_keys13 = require("@dxos/keys");
257
+ var import_keys12 = require("@dxos/keys");
259
258
  var import_log15 = require("@dxos/log");
260
- var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
259
+ var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
261
260
  var import_util10 = require("@dxos/util");
262
261
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
263
- var import_codec_protobuf15 = require("@dxos/codec-protobuf");
264
- var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
262
+ var import_protocols15 = require("@dxos/protocols");
263
+ var import_config2 = require("@dxos/protocols/proto/dxos/config");
264
+ var import_random_access_storage = require("@dxos/random-access-storage");
265
+ var import_client_protocol5 = require("@dxos/client-protocol");
266
+ var import_config3 = require("@dxos/protocols/proto/dxos/config");
265
267
  var import_util11 = require("@dxos/util");
268
+ var import_level = require("level");
269
+ var import_node_path = __toESM(require("node:path"));
270
+ var import_keys13 = require("@dxos/keys");
271
+ var import_codec_protobuf15 = require("@dxos/codec-protobuf");
272
+ var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
273
+ var import_util12 = require("@dxos/util");
274
+ var import_keys14 = require("@dxos/keys");
275
+ var import_util13 = require("@dxos/util");
266
276
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
267
277
  return new import_codec_protobuf.Stream(({ next }) => {
268
278
  const subscriptions = new import_async.EventSubscriptions();
@@ -1796,11 +1806,11 @@ var InvitationsHandler = class {
1796
1806
  this._networkManager = _networkManager;
1797
1807
  }
1798
1808
  createInvitation(protocol, options) {
1799
- const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random(), persistent = true, created = /* @__PURE__ */ new Date(), lifetime = 86400 } = options ?? {};
1809
+ const { invitationId = import_keys5.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys5.PublicKey.random(), persistent = true, created = /* @__PURE__ */ new Date(), lifetime = 86400, multiUse = false } = options ?? {};
1800
1810
  const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
1801
1811
  (0, import_invariant5.invariant)(protocol, void 0, {
1802
1812
  F: __dxlog_file7,
1803
- L: 84,
1813
+ L: 85,
1804
1814
  S: this,
1805
1815
  A: [
1806
1816
  "protocol",
@@ -1815,9 +1825,10 @@ var InvitationsHandler = class {
1815
1825
  swarmKey,
1816
1826
  authCode,
1817
1827
  timeout,
1818
- persistent,
1828
+ persistent: persistent && type !== import_services3.Invitation.Type.OFFLINE,
1819
1829
  created,
1820
1830
  lifetime,
1831
+ multiUse,
1821
1832
  ...protocol.getInvitationContext()
1822
1833
  };
1823
1834
  const stream = new import_async7.PushStream();
@@ -1832,7 +1843,7 @@ var InvitationsHandler = class {
1832
1843
  ...protocol.toJSON()
1833
1844
  }, {
1834
1845
  F: __dxlog_file7,
1835
- L: 109,
1846
+ L: 111,
1836
1847
  S: this,
1837
1848
  C: (f, a) => f(...a)
1838
1849
  });
@@ -1857,7 +1868,7 @@ var InvitationsHandler = class {
1857
1868
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
1858
1869
  (0, import_invariant5.invariant)(deviceKey, void 0, {
1859
1870
  F: __dxlog_file7,
1860
- L: 130,
1871
+ L: 132,
1861
1872
  S: this,
1862
1873
  A: [
1863
1874
  "deviceKey",
@@ -1880,7 +1891,7 @@ var InvitationsHandler = class {
1880
1891
  id: traceId
1881
1892
  }), {
1882
1893
  F: __dxlog_file7,
1883
- L: 148,
1894
+ L: 150,
1884
1895
  S: this,
1885
1896
  C: (f, a) => f(...a)
1886
1897
  });
@@ -1888,7 +1899,7 @@ var InvitationsHandler = class {
1888
1899
  ...protocol.toJSON()
1889
1900
  }, {
1890
1901
  F: __dxlog_file7,
1891
- L: 149,
1902
+ L: 151,
1892
1903
  S: this,
1893
1904
  C: (f, a) => f(...a)
1894
1905
  });
@@ -1904,7 +1915,7 @@ var InvitationsHandler = class {
1904
1915
  ...protocol.toJSON()
1905
1916
  }, {
1906
1917
  F: __dxlog_file7,
1907
- L: 152,
1918
+ L: 154,
1908
1919
  S: this,
1909
1920
  C: (f, a) => f(...a)
1910
1921
  });
@@ -1916,7 +1927,7 @@ var InvitationsHandler = class {
1916
1927
  id: traceId
1917
1928
  }), {
1918
1929
  F: __dxlog_file7,
1919
- L: 154,
1930
+ L: 156,
1920
1931
  S: this,
1921
1932
  C: (f, a) => f(...a)
1922
1933
  });
@@ -1926,7 +1937,7 @@ var InvitationsHandler = class {
1926
1937
  ...protocol.toJSON()
1927
1938
  }, {
1928
1939
  F: __dxlog_file7,
1929
- L: 157,
1940
+ L: 159,
1930
1941
  S: this,
1931
1942
  C: (f, a) => f(...a)
1932
1943
  });
@@ -1937,7 +1948,7 @@ var InvitationsHandler = class {
1937
1948
  } else {
1938
1949
  import_log4.log.error("failed", err, {
1939
1950
  F: __dxlog_file7,
1940
- L: 160,
1951
+ L: 162,
1941
1952
  S: this,
1942
1953
  C: (f, a) => f(...a)
1943
1954
  });
@@ -1948,12 +1959,12 @@ var InvitationsHandler = class {
1948
1959
  error: err
1949
1960
  }), {
1950
1961
  F: __dxlog_file7,
1951
- L: 163,
1962
+ L: 165,
1952
1963
  S: this,
1953
1964
  C: (f, a) => f(...a)
1954
1965
  });
1955
1966
  } finally {
1956
- if (type !== import_services3.Invitation.Type.MULTIUSE) {
1967
+ if (!multiUse) {
1957
1968
  await swarmConnection.close();
1958
1969
  await ctx.dispose();
1959
1970
  }
@@ -1969,7 +1980,7 @@ var InvitationsHandler = class {
1969
1980
  ...protocol.toJSON()
1970
1981
  }, {
1971
1982
  F: __dxlog_file7,
1972
- L: 178,
1983
+ L: 180,
1973
1984
  S: this,
1974
1985
  C: (f, a) => f(...a)
1975
1986
  });
@@ -1980,7 +1991,7 @@ var InvitationsHandler = class {
1980
1991
  } else {
1981
1992
  import_log4.log.error("failed", err, {
1982
1993
  F: __dxlog_file7,
1983
- L: 181,
1994
+ L: 183,
1984
1995
  S: this,
1985
1996
  C: (f, a) => f(...a)
1986
1997
  });
@@ -1994,7 +2005,7 @@ var InvitationsHandler = class {
1994
2005
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
1995
2006
  import_log4.log.warn("invitation has already expired", void 0, {
1996
2007
  F: __dxlog_file7,
1997
- L: 192,
2008
+ L: 194,
1998
2009
  S: this,
1999
2010
  C: (f, a) => f(...a)
2000
2011
  });
@@ -2045,7 +2056,7 @@ var InvitationsHandler = class {
2045
2056
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
2046
2057
  (0, import_invariant5.invariant)(protocol, void 0, {
2047
2058
  F: __dxlog_file7,
2048
- L: 246,
2059
+ L: 248,
2049
2060
  S: this,
2050
2061
  A: [
2051
2062
  "protocol",
@@ -2055,7 +2066,7 @@ var InvitationsHandler = class {
2055
2066
  if (deviceProfile) {
2056
2067
  (0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2057
2068
  F: __dxlog_file7,
2058
- L: 250,
2069
+ L: 252,
2059
2070
  S: this,
2060
2071
  A: [
2061
2072
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -2070,7 +2081,7 @@ var InvitationsHandler = class {
2070
2081
  const setState = (newData) => {
2071
2082
  (0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
2072
2083
  F: __dxlog_file7,
2073
- L: 261,
2084
+ L: 263,
2074
2085
  S: this,
2075
2086
  A: [
2076
2087
  "newData.state !== undefined",
@@ -2090,7 +2101,7 @@ var InvitationsHandler = class {
2090
2101
  ...protocol.toJSON()
2091
2102
  }, {
2092
2103
  F: __dxlog_file7,
2093
- L: 269,
2104
+ L: 271,
2094
2105
  S: this,
2095
2106
  C: (f, a) => f(...a)
2096
2107
  });
@@ -2100,7 +2111,7 @@ var InvitationsHandler = class {
2100
2111
  } else {
2101
2112
  import_log4.log.warn("auth failed", err, {
2102
2113
  F: __dxlog_file7,
2103
- L: 272,
2114
+ L: 274,
2104
2115
  S: this,
2105
2116
  C: (f, a) => f(...a)
2106
2117
  });
@@ -2114,7 +2125,7 @@ var InvitationsHandler = class {
2114
2125
  ...protocol.toJSON()
2115
2126
  }, {
2116
2127
  F: __dxlog_file7,
2117
- L: 280,
2128
+ L: 282,
2118
2129
  S: this,
2119
2130
  C: (f, a) => f(...a)
2120
2131
  });
@@ -2129,7 +2140,7 @@ var InvitationsHandler = class {
2129
2140
  currentState
2130
2141
  }, {
2131
2142
  F: __dxlog_file7,
2132
- L: 290,
2143
+ L: 292,
2133
2144
  S: this,
2134
2145
  C: (f, a) => f(...a)
2135
2146
  });
@@ -2144,7 +2155,7 @@ var InvitationsHandler = class {
2144
2155
  id: traceId
2145
2156
  }), {
2146
2157
  F: __dxlog_file7,
2147
- L: 299,
2158
+ L: 301,
2148
2159
  S: this,
2149
2160
  C: (f, a) => f(...a)
2150
2161
  });
@@ -2156,7 +2167,7 @@ var InvitationsHandler = class {
2156
2167
  ...protocol.toJSON()
2157
2168
  }, {
2158
2169
  F: __dxlog_file7,
2159
- L: 307,
2170
+ L: 309,
2160
2171
  S: this,
2161
2172
  C: (f, a) => f(...a)
2162
2173
  });
@@ -2167,7 +2178,7 @@ var InvitationsHandler = class {
2167
2178
  ...protocol.toJSON()
2168
2179
  }, {
2169
2180
  F: __dxlog_file7,
2170
- L: 311,
2181
+ L: 313,
2171
2182
  S: this,
2172
2183
  C: (f, a) => f(...a)
2173
2184
  });
@@ -2177,7 +2188,7 @@ var InvitationsHandler = class {
2177
2188
  response: introductionResponse
2178
2189
  }, {
2179
2190
  F: __dxlog_file7,
2180
- L: 315,
2191
+ L: 317,
2181
2192
  S: this,
2182
2193
  C: (f, a) => f(...a)
2183
2194
  });
@@ -2186,7 +2197,7 @@ var InvitationsHandler = class {
2186
2197
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2187
2198
  (0, import_log4.log)("guest waiting for authentication code...", void 0, {
2188
2199
  F: __dxlog_file7,
2189
- L: 321,
2200
+ L: 323,
2190
2201
  S: this,
2191
2202
  C: (f, a) => f(...a)
2192
2203
  });
@@ -2198,7 +2209,7 @@ var InvitationsHandler = class {
2198
2209
  });
2199
2210
  (0, import_log4.log)("sending authentication request", void 0, {
2200
2211
  F: __dxlog_file7,
2201
- L: 325,
2212
+ L: 327,
2202
2213
  S: this,
2203
2214
  C: (f, a) => f(...a)
2204
2215
  });
@@ -2219,7 +2230,7 @@ var InvitationsHandler = class {
2219
2230
  attempt
2220
2231
  }, {
2221
2232
  F: __dxlog_file7,
2222
- L: 336,
2233
+ L: 338,
2223
2234
  S: this,
2224
2235
  C: (f, a) => f(...a)
2225
2236
  });
@@ -2232,7 +2243,7 @@ var InvitationsHandler = class {
2232
2243
  ...protocol.toJSON()
2233
2244
  }, {
2234
2245
  F: __dxlog_file7,
2235
- L: 344,
2246
+ L: 346,
2236
2247
  S: this,
2237
2248
  C: (f, a) => f(...a)
2238
2249
  });
@@ -2244,7 +2255,7 @@ var InvitationsHandler = class {
2244
2255
  ...protocol.toJSON()
2245
2256
  }, {
2246
2257
  F: __dxlog_file7,
2247
- L: 355,
2258
+ L: 357,
2248
2259
  S: this,
2249
2260
  C: (f, a) => f(...a)
2250
2261
  });
@@ -2257,7 +2268,7 @@ var InvitationsHandler = class {
2257
2268
  id: traceId
2258
2269
  }), {
2259
2270
  F: __dxlog_file7,
2260
- L: 357,
2271
+ L: 359,
2261
2272
  S: this,
2262
2273
  C: (f, a) => f(...a)
2263
2274
  });
@@ -2267,7 +2278,7 @@ var InvitationsHandler = class {
2267
2278
  ...protocol.toJSON()
2268
2279
  }, {
2269
2280
  F: __dxlog_file7,
2270
- L: 360,
2281
+ L: 362,
2271
2282
  S: this,
2272
2283
  C: (f, a) => f(...a)
2273
2284
  });
@@ -2277,7 +2288,7 @@ var InvitationsHandler = class {
2277
2288
  } else {
2278
2289
  (0, import_log4.log)("auth failed", err, {
2279
2290
  F: __dxlog_file7,
2280
- L: 363,
2291
+ L: 365,
2281
2292
  S: this,
2282
2293
  C: (f, a) => f(...a)
2283
2294
  });
@@ -2288,7 +2299,7 @@ var InvitationsHandler = class {
2288
2299
  error: err
2289
2300
  }), {
2290
2301
  F: __dxlog_file7,
2291
- L: 366,
2302
+ L: 368,
2292
2303
  S: this,
2293
2304
  C: (f, a) => f(...a)
2294
2305
  });
@@ -2306,7 +2317,7 @@ var InvitationsHandler = class {
2306
2317
  ...protocol.toJSON()
2307
2318
  }, {
2308
2319
  F: __dxlog_file7,
2309
- L: 377,
2320
+ L: 379,
2310
2321
  S: this,
2311
2322
  C: (f, a) => f(...a)
2312
2323
  });
@@ -2316,7 +2327,7 @@ var InvitationsHandler = class {
2316
2327
  } else {
2317
2328
  (0, import_log4.log)("auth failed", err, {
2318
2329
  F: __dxlog_file7,
2319
- L: 380,
2330
+ L: 382,
2320
2331
  S: this,
2321
2332
  C: (f, a) => f(...a)
2322
2333
  });
@@ -2333,7 +2344,7 @@ var InvitationsHandler = class {
2333
2344
  } else {
2334
2345
  (0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
2335
2346
  F: __dxlog_file7,
2336
- L: 394,
2347
+ L: 396,
2337
2348
  S: this,
2338
2349
  A: [
2339
2350
  "invitation.swarmKey",
@@ -2372,9 +2383,6 @@ var InvitationsHandler = class {
2372
2383
  return observable;
2373
2384
  }
2374
2385
  };
2375
- var invitationExpired = (invitation) => {
2376
- return invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now();
2377
- };
2378
2386
  var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
2379
2387
  var InvitationsServiceImpl = class {
2380
2388
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
@@ -2430,7 +2438,7 @@ var InvitationsServiceImpl = class {
2430
2438
  await this._metadataStore.removeInvitation(invitation.get().invitationId);
2431
2439
  }
2432
2440
  this._createInvitations.delete(invitation.get().invitationId);
2433
- if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
2441
+ if (!invitation.get().multiUse) {
2434
2442
  this._removedCreated.emit(invitation.get());
2435
2443
  }
2436
2444
  });
@@ -2438,7 +2446,7 @@ var InvitationsServiceImpl = class {
2438
2446
  }
2439
2447
  async loadPersistentInvitations() {
2440
2448
  const persistentInvitations = this._metadataStore.getInvitations();
2441
- const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
2449
+ const freshInvitations = persistentInvitations.filter(async (invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
2442
2450
  const cInvitations = freshInvitations.map((persistentInvitation) => {
2443
2451
  (0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
2444
2452
  F: __dxlog_file8,
@@ -2491,7 +2499,7 @@ var InvitationsServiceImpl = class {
2491
2499
  }, () => {
2492
2500
  close();
2493
2501
  this._acceptInvitations.delete(invitation.get().invitationId);
2494
- if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
2502
+ if (!invitation.get().multiUse) {
2495
2503
  this._removedAccepted.emit(invitation.get());
2496
2504
  }
2497
2505
  });
@@ -2864,141 +2872,6 @@ _ts_decorate3([
2864
2872
  ClientRpcServer = _ts_decorate3([
2865
2873
  import_tracing3.trace.resource()
2866
2874
  ], ClientRpcServer);
2867
- var getPlatform = () => {
2868
- if (process.browser) {
2869
- if (typeof window !== "undefined") {
2870
- const { userAgent } = window.navigator;
2871
- return {
2872
- type: import_services8.Platform.PLATFORM_TYPE.BROWSER,
2873
- userAgent,
2874
- uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2875
- };
2876
- } else {
2877
- return {
2878
- type: import_services8.Platform.PLATFORM_TYPE.SHARED_WORKER,
2879
- uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2880
- };
2881
- }
2882
- } else {
2883
- const { platform: platform2, version, arch } = process;
2884
- return {
2885
- type: import_services8.Platform.PLATFORM_TYPE.NODE,
2886
- platform: platform2,
2887
- arch,
2888
- runtime: version,
2889
- uptime: Math.floor(process.uptime()),
2890
- memory: process.memoryUsage()
2891
- };
2892
- }
2893
- };
2894
- var DXOS_VERSION = "0.4.10-main.d9dc7ae";
2895
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2896
- var DEFAULT_TIMEOUT = 1e3;
2897
- var createDiagnostics = async (clientServices, serviceContext, config) => {
2898
- const diagnostics = {
2899
- created: (/* @__PURE__ */ new Date()).toISOString(),
2900
- platform: getPlatform(),
2901
- client: {
2902
- version: DXOS_VERSION,
2903
- storage: {
2904
- version: import_protocols7.STORAGE_VERSION
2905
- }
2906
- },
2907
- trace: import_tracing4.TRACE_PROCESSOR.getDiagnostics()
2908
- };
2909
- {
2910
- (0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
2911
- F: __dxlog_file10,
2912
- L: 108,
2913
- S: void 0,
2914
- A: [
2915
- "clientServices.LoggingService",
2916
- "'SystemService is not available.'"
2917
- ]
2918
- });
2919
- diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
2920
- timeout: DEFAULT_TIMEOUT
2921
- }).catch(() => void 0);
2922
- }
2923
- if (typeof navigator !== "undefined" && navigator.storage) {
2924
- const map = /* @__PURE__ */ new Map();
2925
- const dir = await navigator.storage.getDirectory();
2926
- for await (const filename of dir?.keys()) {
2927
- const idx = filename.indexOf("-", filename.indexOf("-") + 1);
2928
- if (idx === -1) {
2929
- continue;
2930
- }
2931
- map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
2932
- }
2933
- diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
2934
- file,
2935
- count
2936
- }));
2937
- }
2938
- const identity = serviceContext.identityManager.identity;
2939
- if (identity) {
2940
- diagnostics.identity = {
2941
- identityKey: identity.identityKey,
2942
- spaceKey: identity.space.key,
2943
- profile: identity.profileDocument
2944
- };
2945
- const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
2946
- timeout: DEFAULT_TIMEOUT
2947
- }).catch(() => void 0) ?? {};
2948
- diagnostics.devices = devices;
2949
- if (serviceContext.dataSpaceManager) {
2950
- diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
2951
- }
2952
- const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2953
- timeout: DEFAULT_TIMEOUT
2954
- }).catch(() => void 0) ?? {};
2955
- diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
2956
- feedKey,
2957
- bytes,
2958
- length
2959
- }));
2960
- const status = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
2961
- timeout: DEFAULT_TIMEOUT
2962
- }).catch(() => void 0);
2963
- diagnostics.networkStatus = status;
2964
- diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
2965
- }
2966
- diagnostics.config = config.values;
2967
- return diagnostics;
2968
- };
2969
- var getSpaceStats = async (space) => {
2970
- const stats = {
2971
- key: space.key,
2972
- metrics: space.metrics,
2973
- epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
2974
- ...credential.subject.assertion,
2975
- id: credential.id
2976
- })),
2977
- members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
2978
- identity: {
2979
- identityKey: member.key,
2980
- profile: {
2981
- displayName: member.assertion.profile?.displayName
2982
- }
2983
- },
2984
- presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE
2985
- })),
2986
- pipeline: {
2987
- // TODO(burdon): Pick properties from credentials if needed.
2988
- currentEpoch: space.automergeSpaceState.lastEpoch,
2989
- appliedEpoch: space.automergeSpaceState.lastEpoch,
2990
- controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
2991
- currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
2992
- targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
2993
- totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
2994
- }
2995
- };
2996
- if (stats.metrics) {
2997
- const { open, ready } = stats.metrics;
2998
- stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
2999
- }
3000
- return stats;
3001
- };
3002
2875
  var AutomergeSpaceState = class {
3003
2876
  constructor(_onNewRoot) {
3004
2877
  this._onNewRoot = _onNewRoot;
@@ -3008,7 +2881,7 @@ var AutomergeSpaceState = class {
3008
2881
  this._isProcessingRootDocs = false;
3009
2882
  }
3010
2883
  async processCredential(credential) {
3011
- if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
2884
+ if (!(0, import_credentials10.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
3012
2885
  return;
3013
2886
  }
3014
2887
  this.lastEpoch = credential;
@@ -3033,7 +2906,7 @@ var AutomergeSpaceState = class {
3033
2906
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3034
2907
  }
3035
2908
  };
3036
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2909
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
3037
2910
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3038
2911
  var DEFAULT_SUCCESS_DELAY = 1e3;
3039
2912
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -3061,13 +2934,13 @@ var NotarizationPlugin = class {
3061
2934
  (0, import_log9.log)("notarize", {
3062
2935
  credentials
3063
2936
  }, {
3064
- F: __dxlog_file11,
2937
+ F: __dxlog_file10,
3065
2938
  L: 90,
3066
2939
  S: this,
3067
2940
  C: (f, a) => f(...a)
3068
2941
  });
3069
- (0, import_invariant11.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
3070
- F: __dxlog_file11,
2942
+ (0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
2943
+ F: __dxlog_file10,
3071
2944
  L: 91,
3072
2945
  S: this,
3073
2946
  A: [
@@ -3081,7 +2954,7 @@ var NotarizationPlugin = class {
3081
2954
  import_log9.log.warn("Notarization error", {
3082
2955
  err
3083
2956
  }, {
3084
- F: __dxlog_file11,
2957
+ F: __dxlog_file10,
3085
2958
  L: 99,
3086
2959
  S: this,
3087
2960
  C: (f, a) => f(...a)
@@ -3097,7 +2970,7 @@ var NotarizationPlugin = class {
3097
2970
  timeout,
3098
2971
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
3099
2972
  }, {
3100
- F: __dxlog_file11,
2973
+ F: __dxlog_file10,
3101
2974
  L: 111,
3102
2975
  S: this,
3103
2976
  C: (f, a) => f(...a)
@@ -3120,7 +2993,7 @@ var NotarizationPlugin = class {
3120
2993
  import_log9.log.info("Exhausted all peers to notarize with", {
3121
2994
  retryIn: retryTimeout
3122
2995
  }, {
3123
- F: __dxlog_file11,
2996
+ F: __dxlog_file10,
3124
2997
  L: 136,
3125
2998
  S: this,
3126
2999
  C: (f, a) => f(...a)
@@ -3134,7 +3007,7 @@ var NotarizationPlugin = class {
3134
3007
  peer: peer.localPeerId,
3135
3008
  credentialId: credentials.map((credential) => credential.id)
3136
3009
  }, {
3137
- F: __dxlog_file11,
3010
+ F: __dxlog_file10,
3138
3011
  L: 143,
3139
3012
  S: this,
3140
3013
  C: (f, a) => f(...a)
@@ -3143,7 +3016,7 @@ var NotarizationPlugin = class {
3143
3016
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
3144
3017
  });
3145
3018
  (0, import_log9.log)("success", void 0, {
3146
- F: __dxlog_file11,
3019
+ F: __dxlog_file10,
3147
3020
  L: 147,
3148
3021
  S: this,
3149
3022
  C: (f, a) => f(...a)
@@ -3152,7 +3025,7 @@ var NotarizationPlugin = class {
3152
3025
  } catch (err) {
3153
3026
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
3154
3027
  import_log9.log.info("error notarizing (recoverable)", err, {
3155
- F: __dxlog_file11,
3028
+ F: __dxlog_file10,
3156
3029
  L: 151,
3157
3030
  S: this,
3158
3031
  C: (f, a) => f(...a)
@@ -3170,7 +3043,7 @@ var NotarizationPlugin = class {
3170
3043
  errors.wait()
3171
3044
  ]);
3172
3045
  (0, import_log9.log)("done", void 0, {
3173
- F: __dxlog_file11,
3046
+ F: __dxlog_file10,
3174
3047
  L: 162,
3175
3048
  S: this,
3176
3049
  C: (f, a) => f(...a)
@@ -3191,8 +3064,8 @@ var NotarizationPlugin = class {
3191
3064
  this._processCredentialsTriggers.delete(credential.id);
3192
3065
  }
3193
3066
  setWriter(writer) {
3194
- (0, import_invariant11.invariant)(!this._writer, "Writer already set.", {
3195
- F: __dxlog_file11,
3067
+ (0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
3068
+ F: __dxlog_file10,
3196
3069
  L: 181,
3197
3070
  S: this,
3198
3071
  A: [
@@ -3216,8 +3089,8 @@ var NotarizationPlugin = class {
3216
3089
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
3217
3090
  }
3218
3091
  for (const credential of request.credentials ?? []) {
3219
- (0, import_invariant11.invariant)(credential.id, "Credential must have an id", {
3220
- F: __dxlog_file11,
3092
+ (0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
3093
+ F: __dxlog_file10,
3221
3094
  L: 200,
3222
3095
  S: this,
3223
3096
  A: [
@@ -3237,7 +3110,7 @@ var NotarizationPlugin = class {
3237
3110
  (0, import_log9.log)("extension opened", {
3238
3111
  peer: extension.localPeerId
3239
3112
  }, {
3240
- F: __dxlog_file11,
3113
+ F: __dxlog_file10,
3241
3114
  L: 211,
3242
3115
  S: this,
3243
3116
  C: (f, a) => f(...a)
@@ -3249,7 +3122,7 @@ var NotarizationPlugin = class {
3249
3122
  (0, import_log9.log)("extension closed", {
3250
3123
  peer: extension.localPeerId
3251
3124
  }, {
3252
- F: __dxlog_file11,
3125
+ F: __dxlog_file10,
3253
3126
  L: 216,
3254
3127
  S: this,
3255
3128
  C: (f, a) => f(...a)
@@ -3265,10 +3138,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
3265
3138
  constructor(_params) {
3266
3139
  super({
3267
3140
  requested: {
3268
- NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3141
+ NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3269
3142
  },
3270
3143
  exposed: {
3271
- NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3144
+ NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3272
3145
  }
3273
3146
  });
3274
3147
  this._params = _params;
@@ -3301,14 +3174,14 @@ function _ts_decorate4(decorators, target, key, desc) {
3301
3174
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3302
3175
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3303
3176
  }
3304
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3177
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
3305
3178
  var DataSpace = class {
3306
3179
  constructor(params) {
3307
3180
  this._ctx = new import_context7.Context();
3308
3181
  this._notarizationPlugin = new NotarizationPlugin();
3309
3182
  this._cache = void 0;
3310
3183
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
3311
- this._state = import_services9.SpaceState.CLOSED;
3184
+ this._state = import_services7.SpaceState.CLOSED;
3312
3185
  this.error = void 0;
3313
3186
  this.stateUpdate = new import_async10.Event();
3314
3187
  this.metrics = {};
@@ -3330,9 +3203,9 @@ var DataSpace = class {
3330
3203
  this._cache = params.cache;
3331
3204
  this._state = params.initialState;
3332
3205
  (0, import_log8.log)("new state", {
3333
- state: import_services9.SpaceState[this._state]
3206
+ state: import_services7.SpaceState[this._state]
3334
3207
  }, {
3335
- F: __dxlog_file12,
3208
+ F: __dxlog_file11,
3336
3209
  L: 140,
3337
3210
  S: this,
3338
3211
  C: (f, a) => f(...a)
@@ -3378,11 +3251,11 @@ var DataSpace = class {
3378
3251
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
3379
3252
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
3380
3253
  await this._inner.open(new import_context7.Context());
3381
- this._state = import_services9.SpaceState.CONTROL_ONLY;
3254
+ this._state = import_services7.SpaceState.CONTROL_ONLY;
3382
3255
  (0, import_log8.log)("new state", {
3383
- state: import_services9.SpaceState[this._state]
3256
+ state: import_services7.SpaceState[this._state]
3384
3257
  }, {
3385
- F: __dxlog_file12,
3258
+ F: __dxlog_file11,
3386
3259
  L: 198,
3387
3260
  S: this,
3388
3261
  C: (f, a) => f(...a)
@@ -3396,11 +3269,11 @@ var DataSpace = class {
3396
3269
  }
3397
3270
  async _close() {
3398
3271
  await this._callbacks.beforeClose?.();
3399
- this._state = import_services9.SpaceState.CLOSED;
3272
+ this._state = import_services7.SpaceState.CLOSED;
3400
3273
  (0, import_log8.log)("new state", {
3401
- state: import_services9.SpaceState[this._state]
3274
+ state: import_services7.SpaceState[this._state]
3402
3275
  }, {
3403
- F: __dxlog_file12,
3276
+ F: __dxlog_file11,
3404
3277
  L: 212,
3405
3278
  S: this,
3406
3279
  C: (f, a) => f(...a)
@@ -3430,9 +3303,9 @@ var DataSpace = class {
3430
3303
  this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
3431
3304
  await this.initializeDataPipeline();
3432
3305
  } catch (err) {
3433
- if (err instanceof import_protocols8.CancelledError || err instanceof import_context7.ContextDisposedError) {
3306
+ if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
3434
3307
  (0, import_log8.log)("data pipeline initialization cancelled", err, {
3435
- F: __dxlog_file12,
3308
+ F: __dxlog_file11,
3436
3309
  L: 245,
3437
3310
  S: this,
3438
3311
  C: (f, a) => f(...a)
@@ -3440,16 +3313,16 @@ var DataSpace = class {
3440
3313
  return;
3441
3314
  }
3442
3315
  import_log8.log.error("Error initializing data pipeline", err, {
3443
- F: __dxlog_file12,
3316
+ F: __dxlog_file11,
3444
3317
  L: 249,
3445
3318
  S: this,
3446
3319
  C: (f, a) => f(...a)
3447
3320
  });
3448
- this._state = import_services9.SpaceState.ERROR;
3321
+ this._state = import_services7.SpaceState.ERROR;
3449
3322
  (0, import_log8.log)("new state", {
3450
- state: import_services9.SpaceState[this._state]
3323
+ state: import_services7.SpaceState[this._state]
3451
3324
  }, {
3452
- F: __dxlog_file12,
3325
+ F: __dxlog_file11,
3453
3326
  L: 251,
3454
3327
  S: this,
3455
3328
  C: (f, a) => f(...a)
@@ -3462,14 +3335,14 @@ var DataSpace = class {
3462
3335
  });
3463
3336
  }
3464
3337
  async initializeDataPipeline() {
3465
- if (this._state !== import_services9.SpaceState.CONTROL_ONLY) {
3466
- throw new import_protocols8.SystemError("Invalid operation");
3338
+ if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
3339
+ throw new import_protocols7.SystemError("Invalid operation");
3467
3340
  }
3468
- this._state = import_services9.SpaceState.INITIALIZING;
3341
+ this._state = import_services7.SpaceState.INITIALIZING;
3469
3342
  (0, import_log8.log)("new state", {
3470
- state: import_services9.SpaceState[this._state]
3343
+ state: import_services7.SpaceState[this._state]
3471
3344
  }, {
3472
- F: __dxlog_file12,
3345
+ F: __dxlog_file11,
3473
3346
  L: 267,
3474
3347
  S: this,
3475
3348
  C: (f, a) => f(...a)
@@ -3479,17 +3352,17 @@ var DataSpace = class {
3479
3352
  this._automergeSpaceState.startProcessingRootDocs();
3480
3353
  await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
3481
3354
  (0, import_log8.log)("data pipeline ready", void 0, {
3482
- F: __dxlog_file12,
3355
+ F: __dxlog_file11,
3483
3356
  L: 279,
3484
3357
  S: this,
3485
3358
  C: (f, a) => f(...a)
3486
3359
  });
3487
3360
  await this._callbacks.beforeReady?.();
3488
- this._state = import_services9.SpaceState.READY;
3361
+ this._state = import_services7.SpaceState.READY;
3489
3362
  (0, import_log8.log)("new state", {
3490
- state: import_services9.SpaceState[this._state]
3363
+ state: import_services7.SpaceState[this._state]
3491
3364
  }, {
3492
- F: __dxlog_file12,
3365
+ F: __dxlog_file11,
3493
3366
  L: 283,
3494
3367
  S: this,
3495
3368
  C: (f, a) => f(...a)
@@ -3505,14 +3378,14 @@ var DataSpace = class {
3505
3378
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
3506
3379
  await this._createWritableFeeds();
3507
3380
  (0, import_log8.log)("writable feeds created", void 0, {
3508
- F: __dxlog_file12,
3381
+ F: __dxlog_file11,
3509
3382
  L: 299,
3510
3383
  S: this,
3511
3384
  C: (f, a) => f(...a)
3512
3385
  });
3513
3386
  this.stateUpdate.emit();
3514
3387
  if (!this.notarizationPlugin.hasWriter) {
3515
- this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
3388
+ this.notarizationPlugin.setWriter((0, import_echo_pipeline2.createMappedFeedWriter)((credential) => ({
3516
3389
  credential: {
3517
3390
  credential
3518
3391
  }
@@ -3533,7 +3406,7 @@ var DataSpace = class {
3533
3406
  spaceKey: this.key,
3534
3407
  deviceKey: this._signingContext.deviceKey,
3535
3408
  identityKey: this._signingContext.identityKey,
3536
- designation: import_credentials10.AdmittedFeed.Designation.CONTROL
3409
+ designation: import_credentials9.AdmittedFeed.Designation.CONTROL
3537
3410
  }
3538
3411
  }));
3539
3412
  }
@@ -3550,7 +3423,7 @@ var DataSpace = class {
3550
3423
  spaceKey: this.key,
3551
3424
  deviceKey: this._signingContext.deviceKey,
3552
3425
  identityKey: this._signingContext.identityKey,
3553
- designation: import_credentials10.AdmittedFeed.Designation.DATA
3426
+ designation: import_credentials9.AdmittedFeed.Designation.DATA
3554
3427
  }
3555
3428
  }));
3556
3429
  }
@@ -3568,7 +3441,7 @@ var DataSpace = class {
3568
3441
  space: this.key,
3569
3442
  rootUrl
3570
3443
  }, {
3571
- F: __dxlog_file12,
3444
+ F: __dxlog_file11,
3572
3445
  L: 365,
3573
3446
  S: this,
3574
3447
  C: (f, a) => f(...a)
@@ -3583,7 +3456,7 @@ var DataSpace = class {
3583
3456
  if (this._ctx.disposed) {
3584
3457
  return;
3585
3458
  }
3586
- const doc = handle.docSync() ?? (0, import_invariant10.failedInvariant)();
3459
+ const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
3587
3460
  if (!doc.access?.spaceKey) {
3588
3461
  handle.change((doc2) => {
3589
3462
  doc2.access = {
@@ -3600,7 +3473,7 @@ var DataSpace = class {
3600
3473
  rootUrl,
3601
3474
  err
3602
3475
  }, {
3603
- F: __dxlog_file12,
3476
+ F: __dxlog_file11,
3604
3477
  L: 388,
3605
3478
  S: this,
3606
3479
  C: (f, a) => f(...a)
@@ -3627,7 +3500,7 @@ var DataSpace = class {
3627
3500
  let epoch;
3628
3501
  switch (options?.migration) {
3629
3502
  case void 0:
3630
- case import_services9.CreateEpochRequest.Migration.NONE:
3503
+ case import_services7.CreateEpochRequest.Migration.NONE:
3631
3504
  {
3632
3505
  epoch = {
3633
3506
  previousId: this._automergeSpaceState.lastEpoch?.id,
@@ -3637,7 +3510,7 @@ var DataSpace = class {
3637
3510
  };
3638
3511
  }
3639
3512
  break;
3640
- case import_services9.CreateEpochRequest.Migration.INIT_AUTOMERGE:
3513
+ case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE:
3641
3514
  {
3642
3515
  const document = this._automergeHost.repo.create();
3643
3516
  epoch = {
@@ -3648,14 +3521,14 @@ var DataSpace = class {
3648
3521
  };
3649
3522
  }
3650
3523
  break;
3651
- case import_services9.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3524
+ case import_services7.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3652
3525
  {
3653
3526
  const currentRootUrl = this._automergeSpaceState.rootUrl;
3654
3527
  const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3655
3528
  await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
3656
3529
  const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
3657
- (0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3658
- F: __dxlog_file12,
3530
+ (0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3531
+ F: __dxlog_file11,
3659
3532
  L: 438,
3660
3533
  S: this,
3661
3534
  A: [
@@ -3671,10 +3544,10 @@ var DataSpace = class {
3671
3544
  };
3672
3545
  }
3673
3546
  break;
3674
- case import_services9.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3547
+ case import_services7.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3675
3548
  {
3676
3549
  import_log8.log.info("Fragmenting", void 0, {
3677
- F: __dxlog_file12,
3550
+ F: __dxlog_file11,
3678
3551
  L: 450,
3679
3552
  S: this,
3680
3553
  C: (f, a) => f(...a)
@@ -3685,8 +3558,8 @@ var DataSpace = class {
3685
3558
  const objects = Object.entries(rootHandle.docSync().objects);
3686
3559
  const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_db.TYPE_PROPERTIES);
3687
3560
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3688
- (0, import_invariant10.invariant)(properties, "Properties not found", {
3689
- F: __dxlog_file12,
3561
+ (0, import_invariant9.invariant)(properties, "Properties not found", {
3562
+ F: __dxlog_file11,
3690
3563
  L: 460,
3691
3564
  S: this,
3692
3565
  A: [
@@ -3701,8 +3574,8 @@ var DataSpace = class {
3701
3574
  ])
3702
3575
  };
3703
3576
  const newRoot = this._automergeHost.repo.create(newSpaceDoc);
3704
- (0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3705
- F: __dxlog_file12,
3577
+ (0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3578
+ F: __dxlog_file11,
3706
3579
  L: 465,
3707
3580
  S: this,
3708
3581
  A: [
@@ -3710,7 +3583,7 @@ var DataSpace = class {
3710
3583
  ""
3711
3584
  ]
3712
3585
  });
3713
- const docLoader = new import_echo_pipeline2.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
3586
+ const docLoader = new import_echo_pipeline3.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
3714
3587
  await docLoader.loadSpaceRootDocHandle(this._ctx, {
3715
3588
  rootUrl: newRoot.url
3716
3589
  });
@@ -3754,24 +3627,24 @@ var DataSpace = class {
3754
3627
  ]));
3755
3628
  }
3756
3629
  async activate() {
3757
- if (this._state !== import_services9.SpaceState.INACTIVE) {
3630
+ if (this._state !== import_services7.SpaceState.INACTIVE) {
3758
3631
  return;
3759
3632
  }
3760
- await this._metadataStore.setSpaceState(this.key, import_services9.SpaceState.ACTIVE);
3633
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
3761
3634
  await this._open();
3762
3635
  this.initializeDataPipelineAsync();
3763
3636
  }
3764
3637
  async deactivate() {
3765
- if (this._state === import_services9.SpaceState.INACTIVE) {
3638
+ if (this._state === import_services7.SpaceState.INACTIVE) {
3766
3639
  return;
3767
3640
  }
3768
- await this._metadataStore.setSpaceState(this.key, import_services9.SpaceState.INACTIVE);
3641
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
3769
3642
  await this._close();
3770
- this._state = import_services9.SpaceState.INACTIVE;
3643
+ this._state = import_services7.SpaceState.INACTIVE;
3771
3644
  (0, import_log8.log)("new state", {
3772
- state: import_services9.SpaceState[this._state]
3645
+ state: import_services7.SpaceState[this._state]
3773
3646
  }, {
3774
- F: __dxlog_file12,
3647
+ F: __dxlog_file11,
3775
3648
  L: 531,
3776
3649
  S: this,
3777
3650
  C: (f, a) => f(...a)
@@ -3780,18 +3653,18 @@ var DataSpace = class {
3780
3653
  }
3781
3654
  };
3782
3655
  _ts_decorate4([
3783
- import_tracing5.trace.info()
3656
+ import_tracing4.trace.info()
3784
3657
  ], DataSpace.prototype, "_inner", void 0);
3785
3658
  _ts_decorate4([
3786
- import_tracing5.trace.info()
3659
+ import_tracing4.trace.info()
3787
3660
  ], DataSpace.prototype, "key", null);
3788
3661
  _ts_decorate4([
3789
- import_tracing5.trace.info({
3790
- enum: import_services9.SpaceState
3662
+ import_tracing4.trace.info({
3663
+ enum: import_services7.SpaceState
3791
3664
  })
3792
3665
  ], DataSpace.prototype, "state", null);
3793
3666
  _ts_decorate4([
3794
- import_tracing5.trace.info({
3667
+ import_tracing4.trace.info({
3795
3668
  depth: null
3796
3669
  })
3797
3670
  ], DataSpace.prototype, "_automergeInfo", null);
@@ -3802,12 +3675,12 @@ _ts_decorate4([
3802
3675
  import_async10.synchronized
3803
3676
  ], DataSpace.prototype, "close", null);
3804
3677
  _ts_decorate4([
3805
- import_tracing5.trace.span({
3678
+ import_tracing4.trace.span({
3806
3679
  showInBrowserTimeline: true
3807
3680
  })
3808
3681
  ], DataSpace.prototype, "initializeDataPipeline", null);
3809
3682
  _ts_decorate4([
3810
- import_tracing5.trace.span({
3683
+ import_tracing4.trace.span({
3811
3684
  showInBrowserTimeline: true
3812
3685
  })
3813
3686
  ], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
@@ -3822,11 +3695,11 @@ _ts_decorate4([
3822
3695
  ], DataSpace.prototype, "deactivate", null);
3823
3696
  DataSpace = _ts_decorate4([
3824
3697
  (0, import_async10.trackLeaks)("open", "close"),
3825
- import_tracing5.trace.resource()
3698
+ import_tracing4.trace.resource()
3826
3699
  ], DataSpace);
3827
3700
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3828
3701
  const credentials = [
3829
- await (0, import_credentials13.createCredential)({
3702
+ await (0, import_credentials12.createCredential)({
3830
3703
  signer: keyring,
3831
3704
  issuer: space.key,
3832
3705
  subject: space.key,
@@ -3835,14 +3708,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3835
3708
  spaceKey: space.key
3836
3709
  }
3837
3710
  }),
3838
- await (0, import_credentials13.createCredential)({
3711
+ await (0, import_credentials12.createCredential)({
3839
3712
  signer: keyring,
3840
3713
  issuer: space.key,
3841
3714
  subject: signingContext.identityKey,
3842
3715
  assertion: {
3843
3716
  "@type": "dxos.halo.credentials.SpaceMember",
3844
3717
  spaceKey: space.key,
3845
- role: import_credentials14.SpaceMember.Role.ADMIN,
3718
+ role: import_credentials13.SpaceMember.Role.ADMIN,
3846
3719
  profile: signingContext.getProfile(),
3847
3720
  genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
3848
3721
  }
@@ -3854,7 +3727,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3854
3727
  spaceKey: space.key,
3855
3728
  identityKey: signingContext.identityKey,
3856
3729
  deviceKey: signingContext.deviceKey,
3857
- designation: import_credentials14.AdmittedFeed.Designation.CONTROL
3730
+ designation: import_credentials13.AdmittedFeed.Designation.CONTROL
3858
3731
  }
3859
3732
  }),
3860
3733
  await signingContext.credentialSigner.createCredential({
@@ -3864,7 +3737,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3864
3737
  spaceKey: space.key,
3865
3738
  identityKey: signingContext.identityKey,
3866
3739
  deviceKey: signingContext.deviceKey,
3867
- designation: import_credentials14.AdmittedFeed.Designation.DATA
3740
+ designation: import_credentials13.AdmittedFeed.Designation.DATA
3868
3741
  }
3869
3742
  }),
3870
3743
  await signingContext.credentialSigner.createCredential({
@@ -3898,7 +3771,7 @@ function _ts_decorate5(decorators, target, key, desc) {
3898
3771
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3899
3772
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3900
3773
  }
3901
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3774
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
3902
3775
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3903
3776
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3904
3777
  var DataSpaceManager = class {
@@ -3924,15 +3797,15 @@ var DataSpaceManager = class {
3924
3797
  }
3925
3798
  async open() {
3926
3799
  (0, import_log10.log)("open", void 0, {
3927
- F: __dxlog_file13,
3800
+ F: __dxlog_file12,
3928
3801
  L: 98,
3929
3802
  S: this,
3930
3803
  C: (f, a) => f(...a)
3931
3804
  });
3932
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols10.trace.begin({
3805
+ import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.begin({
3933
3806
  id: this._instanceId
3934
3807
  }), {
3935
- F: __dxlog_file13,
3808
+ F: __dxlog_file12,
3936
3809
  L: 99,
3937
3810
  S: this,
3938
3811
  C: (f, a) => f(...a)
@@ -3940,7 +3813,7 @@ var DataSpaceManager = class {
3940
3813
  (0, import_log10.log)("metadata loaded", {
3941
3814
  spaces: this._metadataStore.spaces.length
3942
3815
  }, {
3943
- F: __dxlog_file13,
3816
+ F: __dxlog_file12,
3944
3817
  L: 100,
3945
3818
  S: this,
3946
3819
  C: (f, a) => f(...a)
@@ -3950,7 +3823,7 @@ var DataSpaceManager = class {
3950
3823
  (0, import_log10.log)("load space", {
3951
3824
  spaceMetadata
3952
3825
  }, {
3953
- F: __dxlog_file13,
3826
+ F: __dxlog_file12,
3954
3827
  L: 104,
3955
3828
  S: this,
3956
3829
  C: (f, a) => f(...a)
@@ -3961,7 +3834,7 @@ var DataSpaceManager = class {
3961
3834
  spaceMetadata,
3962
3835
  err
3963
3836
  }, {
3964
- F: __dxlog_file13,
3837
+ F: __dxlog_file12,
3965
3838
  L: 107,
3966
3839
  S: this,
3967
3840
  C: (f, a) => f(...a)
@@ -3971,14 +3844,14 @@ var DataSpaceManager = class {
3971
3844
  this._isOpen = true;
3972
3845
  this.updated.emit();
3973
3846
  for (const space of this._spaces.values()) {
3974
- if (space.state !== import_services10.SpaceState.INACTIVE) {
3847
+ if (space.state !== import_services8.SpaceState.INACTIVE) {
3975
3848
  space.initializeDataPipelineAsync();
3976
3849
  }
3977
3850
  }
3978
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols10.trace.end({
3851
+ import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.end({
3979
3852
  id: this._instanceId
3980
3853
  }), {
3981
- F: __dxlog_file13,
3854
+ F: __dxlog_file12,
3982
3855
  L: 120,
3983
3856
  S: this,
3984
3857
  C: (f, a) => f(...a)
@@ -3986,7 +3859,7 @@ var DataSpaceManager = class {
3986
3859
  }
3987
3860
  async close() {
3988
3861
  (0, import_log10.log)("close", void 0, {
3989
- F: __dxlog_file13,
3862
+ F: __dxlog_file12,
3990
3863
  L: 125,
3991
3864
  S: this,
3992
3865
  C: (f, a) => f(...a)
@@ -4001,8 +3874,8 @@ var DataSpaceManager = class {
4001
3874
  * Creates a new space writing the genesis credentials to the control feed.
4002
3875
  */
4003
3876
  async createSpace() {
4004
- (0, import_invariant12.invariant)(this._isOpen, "Not open.", {
4005
- F: __dxlog_file13,
3877
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3878
+ F: __dxlog_file12,
4006
3879
  L: 138,
4007
3880
  S: this,
4008
3881
  A: [
@@ -4018,12 +3891,12 @@ var DataSpaceManager = class {
4018
3891
  genesisFeedKey: controlFeedKey,
4019
3892
  controlFeedKey,
4020
3893
  dataFeedKey,
4021
- state: import_services10.SpaceState.ACTIVE
3894
+ state: import_services8.SpaceState.ACTIVE
4022
3895
  };
4023
3896
  (0, import_log10.log)("creating space...", {
4024
3897
  spaceKey
4025
3898
  }, {
4026
- F: __dxlog_file13,
3899
+ F: __dxlog_file12,
4027
3900
  L: 150,
4028
3901
  S: this,
4029
3902
  C: (f, a) => f(...a)
@@ -4038,8 +3911,8 @@ var DataSpaceManager = class {
4038
3911
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
4039
3912
  await this._metadataStore.addSpace(metadata);
4040
3913
  const memberCredential = credentials[1];
4041
- (0, import_invariant12.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4042
- F: __dxlog_file13,
3914
+ (0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3915
+ F: __dxlog_file12,
4043
3916
  L: 163,
4044
3917
  S: this,
4045
3918
  A: [
@@ -4057,13 +3930,13 @@ var DataSpaceManager = class {
4057
3930
  (0, import_log10.log)("accept space", {
4058
3931
  opts
4059
3932
  }, {
4060
- F: __dxlog_file13,
3933
+ F: __dxlog_file12,
4061
3934
  L: 175,
4062
3935
  S: this,
4063
3936
  C: (f, a) => f(...a)
4064
3937
  });
4065
- (0, import_invariant12.invariant)(this._isOpen, "Not open.", {
4066
- F: __dxlog_file13,
3938
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3939
+ F: __dxlog_file12,
4067
3940
  L: 176,
4068
3941
  S: this,
4069
3942
  A: [
@@ -4071,8 +3944,8 @@ var DataSpaceManager = class {
4071
3944
  "'Not open.'"
4072
3945
  ]
4073
3946
  });
4074
- (0, import_invariant12.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4075
- F: __dxlog_file13,
3947
+ (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3948
+ F: __dxlog_file12,
4076
3949
  L: 177,
4077
3950
  S: this,
4078
3951
  A: [
@@ -4100,14 +3973,14 @@ var DataSpaceManager = class {
4100
3973
  async waitUntilSpaceReady(spaceKey) {
4101
3974
  await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
4102
3975
  const space = this._spaces.get(spaceKey);
4103
- return !!space && space.state === import_services10.SpaceState.READY;
3976
+ return !!space && space.state === import_services8.SpaceState.READY;
4104
3977
  }));
4105
3978
  }
4106
3979
  async _constructSpace(metadata) {
4107
3980
  (0, import_log10.log)("construct space", {
4108
3981
  metadata
4109
3982
  }, {
4110
- F: __dxlog_file13,
3983
+ F: __dxlog_file12,
4111
3984
  L: 210,
4112
3985
  S: this,
4113
3986
  C: (f, a) => f(...a)
@@ -4145,7 +4018,7 @@ var DataSpaceManager = class {
4145
4018
  },
4146
4019
  onAuthFailure: () => {
4147
4020
  import_log10.log.warn("auth failure", void 0, {
4148
- F: __dxlog_file13,
4021
+ F: __dxlog_file12,
4149
4022
  L: 247,
4150
4023
  S: this,
4151
4024
  C: (f, a) => f(...a)
@@ -4157,7 +4030,7 @@ var DataSpaceManager = class {
4157
4030
  dataFeed && await space.setDataFeed(dataFeed);
4158
4031
  const dataSpace = new DataSpace({
4159
4032
  inner: space,
4160
- initialState: metadata.state === import_services10.SpaceState.INACTIVE ? import_services10.SpaceState.INACTIVE : import_services10.SpaceState.CLOSED,
4033
+ initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
4161
4034
  metadataStore: this._metadataStore,
4162
4035
  gossip,
4163
4036
  presence,
@@ -4169,7 +4042,7 @@ var DataSpaceManager = class {
4169
4042
  (0, import_log10.log)("before space ready", {
4170
4043
  space: space.key
4171
4044
  }, {
4172
- F: __dxlog_file13,
4045
+ F: __dxlog_file12,
4173
4046
  L: 265,
4174
4047
  S: this,
4175
4048
  C: (f, a) => f(...a)
@@ -4180,7 +4053,7 @@ var DataSpaceManager = class {
4180
4053
  space: space.key,
4181
4054
  open: this._isOpen
4182
4055
  }, {
4183
- F: __dxlog_file13,
4056
+ F: __dxlog_file12,
4184
4057
  L: 268,
4185
4058
  S: this,
4186
4059
  C: (f, a) => f(...a)
@@ -4193,7 +4066,7 @@ var DataSpaceManager = class {
4193
4066
  (0, import_log10.log)("before space close", {
4194
4067
  space: space.key
4195
4068
  }, {
4196
- F: __dxlog_file13,
4069
+ F: __dxlog_file12,
4197
4070
  L: 274,
4198
4071
  S: this,
4199
4072
  C: (f, a) => f(...a)
@@ -4203,7 +4076,7 @@ var DataSpaceManager = class {
4203
4076
  cache: metadata.cache,
4204
4077
  automergeHost: this._automergeHost
4205
4078
  });
4206
- if (metadata.state !== import_services10.SpaceState.INACTIVE) {
4079
+ if (metadata.state !== import_services8.SpaceState.INACTIVE) {
4207
4080
  await dataSpace.open();
4208
4081
  }
4209
4082
  if (metadata.controlTimeframe) {
@@ -4228,7 +4101,7 @@ _ts_decorate5([
4228
4101
  DataSpaceManager = _ts_decorate5([
4229
4102
  (0, import_async13.trackLeaks)("open", "close")
4230
4103
  ], DataSpaceManager);
4231
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
4104
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
4232
4105
  var SpacesServiceImpl = class {
4233
4106
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
4234
4107
  this._identityManager = _identityManager;
@@ -4245,29 +4118,29 @@ var SpacesServiceImpl = class {
4245
4118
  }
4246
4119
  async updateSpace({ spaceKey, state }) {
4247
4120
  const dataSpaceManager = await this._getDataSpaceManager();
4248
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4121
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4249
4122
  if (state) {
4250
4123
  switch (state) {
4251
- case import_services11.SpaceState.ACTIVE:
4124
+ case import_services9.SpaceState.ACTIVE:
4252
4125
  await space.activate();
4253
4126
  break;
4254
- case import_services11.SpaceState.INACTIVE:
4127
+ case import_services9.SpaceState.INACTIVE:
4255
4128
  await space.deactivate();
4256
4129
  break;
4257
4130
  default:
4258
- throw new import_protocols11.ApiError("Invalid space state");
4131
+ throw new import_protocols10.ApiError("Invalid space state");
4259
4132
  }
4260
4133
  }
4261
4134
  }
4262
4135
  querySpaces() {
4263
- return new import_codec_protobuf11.Stream(({ next, ctx }) => {
4136
+ return new import_codec_protobuf10.Stream(({ next, ctx }) => {
4264
4137
  const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
4265
4138
  const dataSpaceManager = await this._getDataSpaceManager();
4266
4139
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
4267
4140
  (0, import_log11.log)("update", {
4268
4141
  spaces
4269
4142
  }, {
4270
- F: __dxlog_file14,
4143
+ F: __dxlog_file13,
4271
4144
  L: 77,
4272
4145
  S: this,
4273
4146
  C: (f, a) => f(...a)
@@ -4307,14 +4180,14 @@ var SpacesServiceImpl = class {
4307
4180
  }
4308
4181
  async postMessage({ spaceKey, channel, message }) {
4309
4182
  const dataSpaceManager = await this._getDataSpaceManager();
4310
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4183
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4311
4184
  await space.postMessage(getChannelId(channel), message);
4312
4185
  }
4313
4186
  subscribeMessages({ spaceKey, channel }) {
4314
- return new import_codec_protobuf11.Stream(({ ctx, next }) => {
4187
+ return new import_codec_protobuf10.Stream(({ ctx, next }) => {
4315
4188
  (0, import_async14.scheduleTask)(ctx, async () => {
4316
4189
  const dataSpaceManager = await this._getDataSpaceManager();
4317
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4190
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4318
4191
  const handle = space.listen(getChannelId(channel), (message) => {
4319
4192
  next(message);
4320
4193
  });
@@ -4323,8 +4196,8 @@ var SpacesServiceImpl = class {
4323
4196
  });
4324
4197
  }
4325
4198
  queryCredentials({ spaceKey, noTail }) {
4326
- return new import_codec_protobuf11.Stream(({ ctx, next, close }) => {
4327
- const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4199
+ return new import_codec_protobuf10.Stream(({ ctx, next, close }) => {
4200
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4328
4201
  const processor = {
4329
4202
  processCredential: async (credential) => {
4330
4203
  next(credential);
@@ -4340,7 +4213,7 @@ var SpacesServiceImpl = class {
4340
4213
  });
4341
4214
  }
4342
4215
  async writeCredentials({ spaceKey, credentials }) {
4343
- const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4216
+ const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4344
4217
  for (const credential of credentials ?? []) {
4345
4218
  if (credential.proof) {
4346
4219
  await space.controlPipeline.writer.write({
@@ -4349,8 +4222,8 @@ var SpacesServiceImpl = class {
4349
4222
  }
4350
4223
  });
4351
4224
  } else {
4352
- (0, import_invariant13.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
4353
- F: __dxlog_file14,
4225
+ (0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
4226
+ F: __dxlog_file13,
4354
4227
  L: 164,
4355
4228
  S: this,
4356
4229
  A: [
@@ -4358,8 +4231,8 @@ var SpacesServiceImpl = class {
4358
4231
  "'Id on unsigned credentials is not allowed'"
4359
4232
  ]
4360
4233
  });
4361
- (0, import_invariant13.invariant)(this._identityManager.identity, "Identity is not available", {
4362
- F: __dxlog_file14,
4234
+ (0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
4235
+ F: __dxlog_file13,
4363
4236
  L: 165,
4364
4237
  S: this,
4365
4238
  A: [
@@ -4368,8 +4241,8 @@ var SpacesServiceImpl = class {
4368
4241
  ]
4369
4242
  });
4370
4243
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
4371
- (0, import_invariant13.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
4372
- F: __dxlog_file14,
4244
+ (0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
4245
+ F: __dxlog_file13,
4373
4246
  L: 167,
4374
4247
  S: this,
4375
4248
  A: [
@@ -4391,7 +4264,7 @@ var SpacesServiceImpl = class {
4391
4264
  }
4392
4265
  async createEpoch({ spaceKey, migration }) {
4393
4266
  const dataSpaceManager = await this._getDataSpaceManager();
4394
- const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols11.SpaceNotFoundError(spaceKey));
4267
+ const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
4395
4268
  await space.createEpoch({
4396
4269
  migration
4397
4270
  });
@@ -4400,7 +4273,7 @@ var SpacesServiceImpl = class {
4400
4273
  return {
4401
4274
  spaceKey: space.key,
4402
4275
  state: space.state,
4403
- error: space.error ? (0, import_protocols11.encodeError)(space.error) : void 0,
4276
+ error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
4404
4277
  pipeline: {
4405
4278
  currentEpoch: space.automergeSpaceState.lastEpoch,
4406
4279
  appliedEpoch: space.automergeSpaceState.lastEpoch,
@@ -4425,7 +4298,7 @@ var SpacesServiceImpl = class {
4425
4298
  identityKey: member.key,
4426
4299
  profile: member.profile ?? {}
4427
4300
  },
4428
- presence: member.removed ? import_services11.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services11.SpaceMember.PresenceState.ONLINE : import_services11.SpaceMember.PresenceState.OFFLINE,
4301
+ presence: member.removed ? import_services9.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
4429
4302
  peerStates: peers
4430
4303
  };
4431
4304
  }),
@@ -4444,7 +4317,7 @@ var createSelectedDocumentsIterator = (automergeHost) => (
4444
4317
  // TODO(mykola): Unload automerge handles after usage.
4445
4318
  async function* loadDocuments(ids) {
4446
4319
  for (const id of ids) {
4447
- const { documentId, objectId } = import_protocols13.idCodec.decode(id);
4320
+ const { documentId, objectId } = import_protocols12.idCodec.decode(id);
4448
4321
  const handle = automergeHost.repo.find(documentId);
4449
4322
  await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
4450
4323
  const doc = handle.docSync();
@@ -4477,7 +4350,7 @@ var createDocumentsIterator = (automergeHost) => (
4477
4350
  if (doc.objects) {
4478
4351
  yield Object.entries(doc.objects).map(([objectId, object]) => {
4479
4352
  return {
4480
- id: import_protocols13.idCodec.encode({
4353
+ id: import_protocols12.idCodec.encode({
4481
4354
  documentId: handle.documentId,
4482
4355
  objectId
4483
4356
  }),
@@ -4520,7 +4393,7 @@ function _ts_decorate6(decorators, target, key, desc) {
4520
4393
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4521
4394
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4522
4395
  }
4523
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4396
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4524
4397
  var ServiceContext = class extends import_context10.Resource {
4525
4398
  constructor(storage, level, networkManager, signalManager, _runtimeParams) {
4526
4399
  super();
@@ -4532,8 +4405,8 @@ var ServiceContext = class extends import_context10.Resource {
4532
4405
  this.initialized = new import_async15.Trigger();
4533
4406
  this._handlerFactories = /* @__PURE__ */ new Map();
4534
4407
  this._instanceId = import_keys10.PublicKey.random().toHex();
4535
- this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
4536
- this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
4408
+ this.metadataStore = new import_echo_pipeline4.MetadataStore(storage.createDirectory("metadata"));
4409
+ this.snapshotStore = new import_echo_pipeline4.SnapshotStore(storage.createDirectory("snapshots"));
4537
4410
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
4538
4411
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
4539
4412
  this.feedStore = new import_feed_store4.FeedStore({
@@ -4541,12 +4414,12 @@ var ServiceContext = class extends import_context10.Resource {
4541
4414
  root: storage.createDirectory("feeds"),
4542
4415
  signer: this.keyring,
4543
4416
  hypercore: {
4544
- valueEncoding: import_echo_pipeline3.valueEncoding,
4417
+ valueEncoding: import_echo_pipeline4.valueEncoding,
4545
4418
  stats: true
4546
4419
  }
4547
4420
  })
4548
4421
  });
4549
- this.spaceManager = new import_echo_pipeline3.SpaceManager({
4422
+ this.spaceManager = new import_echo_pipeline4.SpaceManager({
4550
4423
  feedStore: this.feedStore,
4551
4424
  networkManager: this.networkManager,
4552
4425
  blobStore: this.blobStore,
@@ -4557,8 +4430,9 @@ var ServiceContext = class extends import_context10.Resource {
4557
4430
  this.indexMetadata = new import_indexing.IndexMetadataStore({
4558
4431
  db: level.sublevel("index-metadata")
4559
4432
  });
4560
- this.automergeHost = new import_echo_pipeline3.AutomergeHost({
4433
+ this.automergeHost = new import_echo_pipeline4.AutomergeHost({
4561
4434
  directory: storage.createDirectory("automerge"),
4435
+ db: level.sublevel("automerge"),
4562
4436
  metadata: this.indexMetadata
4563
4437
  });
4564
4438
  this.indexer = new import_indexing.Indexer({
@@ -4570,51 +4444,52 @@ var ServiceContext = class extends import_context10.Resource {
4570
4444
  getAllDocuments: createDocumentsIterator(this.automergeHost)
4571
4445
  });
4572
4446
  this.invitations = new InvitationsHandler(this.networkManager);
4573
- this._handlerFactories.set(import_services12.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
4447
+ this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
4574
4448
  }
4575
4449
  async _open(ctx) {
4576
4450
  await this._checkStorageVersion();
4577
4451
  (0, import_log12.log)("opening...", void 0, {
4578
- F: __dxlog_file15,
4579
- L: 156,
4452
+ F: __dxlog_file14,
4453
+ L: 157,
4580
4454
  S: this,
4581
4455
  C: (f, a) => f(...a)
4582
4456
  });
4583
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.begin({
4457
+ import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.begin({
4584
4458
  id: this._instanceId
4585
4459
  }), {
4586
- F: __dxlog_file15,
4587
- L: 157,
4460
+ F: __dxlog_file14,
4461
+ L: 158,
4588
4462
  S: this,
4589
4463
  C: (f, a) => f(...a)
4590
4464
  });
4591
4465
  await this.signalManager.open();
4592
4466
  await this.networkManager.open();
4467
+ await this.automergeHost.open();
4593
4468
  await this.metadataStore.load();
4594
4469
  await this.spaceManager.open();
4595
4470
  await this.identityManager.open(ctx);
4596
4471
  if (this.identityManager.identity) {
4597
4472
  await this._initialize(ctx);
4598
4473
  }
4599
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols12.trace.end({
4474
+ import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
4600
4475
  id: this._instanceId
4601
4476
  }), {
4602
- F: __dxlog_file15,
4603
- L: 167,
4477
+ F: __dxlog_file14,
4478
+ L: 169,
4604
4479
  S: this,
4605
4480
  C: (f, a) => f(...a)
4606
4481
  });
4607
4482
  (0, import_log12.log)("opened", void 0, {
4608
- F: __dxlog_file15,
4609
- L: 168,
4483
+ F: __dxlog_file14,
4484
+ L: 170,
4610
4485
  S: this,
4611
4486
  C: (f, a) => f(...a)
4612
4487
  });
4613
4488
  }
4614
4489
  async _close() {
4615
4490
  (0, import_log12.log)("closing...", void 0, {
4616
- F: __dxlog_file15,
4617
- L: 172,
4491
+ F: __dxlog_file14,
4492
+ L: 174,
4618
4493
  S: this,
4619
4494
  C: (f, a) => f(...a)
4620
4495
  });
@@ -4631,8 +4506,8 @@ var ServiceContext = class extends import_context10.Resource {
4631
4506
  await this.metadataStore.close();
4632
4507
  await this.indexer.destroy();
4633
4508
  (0, import_log12.log)("closed", void 0, {
4634
- F: __dxlog_file15,
4635
- L: 185,
4509
+ F: __dxlog_file14,
4510
+ L: 187,
4636
4511
  S: this,
4637
4512
  C: (f, a) => f(...a)
4638
4513
  });
@@ -4644,9 +4519,9 @@ var ServiceContext = class extends import_context10.Resource {
4644
4519
  }
4645
4520
  getInvitationHandler(invitation) {
4646
4521
  const factory = this._handlerFactories.get(invitation.kind);
4647
- (0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4648
- F: __dxlog_file15,
4649
- L: 196,
4522
+ (0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4523
+ F: __dxlog_file14,
4524
+ L: 198,
4650
4525
  S: this,
4651
4526
  A: [
4652
4527
  "factory",
@@ -4670,15 +4545,15 @@ var ServiceContext = class extends import_context10.Resource {
4670
4545
  }
4671
4546
  async _checkStorageVersion() {
4672
4547
  await this.metadataStore.load();
4673
- if (this.metadataStore.version !== import_protocols12.STORAGE_VERSION) {
4674
- throw new import_protocols12.InvalidStorageVersionError(import_protocols12.STORAGE_VERSION, this.metadataStore.version);
4548
+ if (this.metadataStore.version !== import_protocols11.STORAGE_VERSION) {
4549
+ throw new import_protocols11.InvalidStorageVersionError(import_protocols11.STORAGE_VERSION, this.metadataStore.version);
4675
4550
  }
4676
4551
  }
4677
4552
  // Called when identity is created.
4678
4553
  async _initialize(ctx) {
4679
4554
  (0, import_log12.log)("initializing spaces...", void 0, {
4680
- F: __dxlog_file15,
4681
- L: 227,
4555
+ F: __dxlog_file14,
4556
+ L: 229,
4682
4557
  S: this,
4683
4558
  C: (f, a) => f(...a)
4684
4559
  });
@@ -4698,10 +4573,10 @@ var ServiceContext = class extends import_context10.Resource {
4698
4573
  };
4699
4574
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
4700
4575
  await this.dataSpaceManager.open();
4701
- this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
4702
- (0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4703
- F: __dxlog_file15,
4704
- L: 251,
4576
+ this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
4577
+ (0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4578
+ F: __dxlog_file14,
4579
+ L: 253,
4705
4580
  S: this,
4706
4581
  A: [
4707
4582
  "this.dataSpaceManager",
@@ -4713,7 +4588,7 @@ var ServiceContext = class extends import_context10.Resource {
4713
4588
  this.initialized.wake();
4714
4589
  this._deviceSpaceSync = {
4715
4590
  processCredential: async (credential) => {
4716
- const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
4591
+ const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
4717
4592
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
4718
4593
  return;
4719
4594
  }
@@ -4724,8 +4599,8 @@ var ServiceContext = class extends import_context10.Resource {
4724
4599
  (0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
4725
4600
  details: assertion
4726
4601
  }, {
4727
- F: __dxlog_file15,
4728
- L: 267,
4602
+ F: __dxlog_file14,
4603
+ L: 269,
4729
4604
  S: this,
4730
4605
  C: (f, a) => f(...a)
4731
4606
  });
@@ -4735,8 +4610,8 @@ var ServiceContext = class extends import_context10.Resource {
4735
4610
  (0, import_log12.log)("space already exists, ignoring space admission", {
4736
4611
  details: assertion
4737
4612
  }, {
4738
- F: __dxlog_file15,
4739
- L: 271,
4613
+ F: __dxlog_file14,
4614
+ L: 273,
4740
4615
  S: this,
4741
4616
  C: (f, a) => f(...a)
4742
4617
  });
@@ -4746,8 +4621,8 @@ var ServiceContext = class extends import_context10.Resource {
4746
4621
  (0, import_log12.log)("accepting space recorded in halo", {
4747
4622
  details: assertion
4748
4623
  }, {
4749
- F: __dxlog_file15,
4750
- L: 276,
4624
+ F: __dxlog_file14,
4625
+ L: 278,
4751
4626
  S: this,
4752
4627
  C: (f, a) => f(...a)
4753
4628
  });
@@ -4757,8 +4632,8 @@ var ServiceContext = class extends import_context10.Resource {
4757
4632
  });
4758
4633
  } catch (err) {
4759
4634
  import_log12.log.catch(err, void 0, {
4760
- F: __dxlog_file15,
4761
- L: 282,
4635
+ F: __dxlog_file14,
4636
+ L: 284,
4762
4637
  S: this,
4763
4638
  C: (f, a) => f(...a)
4764
4639
  });
@@ -4769,14 +4644,14 @@ var ServiceContext = class extends import_context10.Resource {
4769
4644
  }
4770
4645
  };
4771
4646
  _ts_decorate6([
4772
- import_tracing6.trace.span()
4647
+ import_tracing5.trace.span()
4773
4648
  ], ServiceContext.prototype, "_open", null);
4774
4649
  _ts_decorate6([
4775
- import_tracing6.trace.span()
4650
+ import_tracing5.trace.span()
4776
4651
  ], ServiceContext.prototype, "_initialize", null);
4777
4652
  ServiceContext = _ts_decorate6([
4778
4653
  (0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
4779
- import_tracing6.trace.resource()
4654
+ import_tracing5.trace.resource()
4780
4655
  ], ServiceContext);
4781
4656
  var ServiceRegistry = class {
4782
4657
  // prettier-ignore
@@ -4800,118 +4675,155 @@ var ServiceRegistry = class {
4800
4675
  delete this._handlers[name];
4801
4676
  }
4802
4677
  };
4803
- function _ts_decorate7(decorators, target, key, desc) {
4804
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4805
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4806
- r = Reflect.decorate(decorators, target, key, desc);
4807
- else
4808
- for (var i = decorators.length - 1; i >= 0; i--)
4809
- if (d = decorators[i])
4810
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4811
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4812
- }
4813
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
4814
- var Lock = class {
4815
- constructor({ lockKey: lockPath, onAcquire, onRelease }) {
4816
- this._lockPath = lockPath;
4817
- this._onAcquire = onAcquire;
4818
- this._onRelease = onRelease;
4819
- }
4820
- get lockKey() {
4821
- return this._lockPath;
4822
- }
4823
- async acquire() {
4824
- (0, import_log13.log)("acquiring lock...", void 0, {
4825
- F: __dxlog_file16,
4826
- L: 32,
4827
- S: this,
4828
- C: (f, a) => f(...a)
4829
- });
4830
- this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
4831
- await this._onAcquire?.();
4832
- (0, import_log13.log)("acquired lock", void 0, {
4833
- F: __dxlog_file16,
4834
- L: 37,
4835
- S: this,
4836
- C: (f, a) => f(...a)
4837
- });
4678
+ var DXOS_VERSION = "0.4.10-main.e9f9c10";
4679
+ var getPlatform = () => {
4680
+ if (process.browser) {
4681
+ if (typeof window !== "undefined") {
4682
+ const { userAgent } = window.navigator;
4683
+ return {
4684
+ type: import_services12.Platform.PLATFORM_TYPE.BROWSER,
4685
+ userAgent,
4686
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
4687
+ };
4688
+ } else {
4689
+ return {
4690
+ type: import_services12.Platform.PLATFORM_TYPE.SHARED_WORKER,
4691
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
4692
+ };
4693
+ }
4694
+ } else {
4695
+ const { platform: platform2, version, arch } = process;
4696
+ return {
4697
+ type: import_services12.Platform.PLATFORM_TYPE.NODE,
4698
+ platform: platform2,
4699
+ arch,
4700
+ runtime: version,
4701
+ uptime: Math.floor(process.uptime()),
4702
+ memory: process.memoryUsage()
4703
+ };
4838
4704
  }
4839
- async release() {
4840
- await this._onRelease?.();
4841
- (0, import_invariant15.invariant)(this._fileHandle, "Lock is not acquired", {
4842
- F: __dxlog_file16,
4843
- L: 42,
4844
- S: this,
4705
+ };
4706
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
4707
+ var DEFAULT_TIMEOUT = 1e3;
4708
+ var createDiagnostics = async (clientServices, serviceContext, config) => {
4709
+ const diagnostics = {
4710
+ created: (/* @__PURE__ */ new Date()).toISOString(),
4711
+ platform: getPlatform(),
4712
+ client: {
4713
+ version: DXOS_VERSION,
4714
+ storage: {
4715
+ version: import_protocols13.STORAGE_VERSION
4716
+ }
4717
+ },
4718
+ trace: import_tracing6.TRACE_PROCESSOR.getDiagnostics()
4719
+ };
4720
+ {
4721
+ (0, import_invariant14.invariant)(clientServices.LoggingService, "SystemService is not available.", {
4722
+ F: __dxlog_file15,
4723
+ L: 108,
4724
+ S: void 0,
4845
4725
  A: [
4846
- "this._fileHandle",
4847
- "'Lock is not acquired'"
4726
+ "clientServices.LoggingService",
4727
+ "'SystemService is not available.'"
4848
4728
  ]
4849
4729
  });
4850
- await import_lock_file.LockFile.release(this._fileHandle);
4851
- }
4852
- };
4853
- _ts_decorate7([
4854
- import_log13.logInfo
4855
- ], Lock.prototype, "lockKey", null);
4856
- var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
4857
- var getRootPath = (config) => {
4858
- const { dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
4859
- return `${dataRoot}/`;
4860
- };
4861
- var isPersistent = (config) => {
4862
- const { persistent = false } = config ?? {};
4863
- return config.dataStore !== void 0 && config.dataStore !== import_config2.Runtime.Client.Storage.StorageDriver.RAM || persistent;
4864
- };
4865
- var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
4866
- var createStorageObjects = (config) => {
4867
- const { persistent = false, keyStore, dataStore } = config ?? {};
4868
- if (persistent && dataStore === StorageDriver.RAM) {
4869
- throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
4730
+ diagnostics.metrics = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
4731
+ timeout: DEFAULT_TIMEOUT
4732
+ }).catch(() => void 0);
4870
4733
  }
4871
- if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
4872
- throw new import_protocols14.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
4734
+ if (typeof navigator !== "undefined" && navigator.storage) {
4735
+ const map = /* @__PURE__ */ new Map();
4736
+ const dir = await navigator.storage.getDirectory();
4737
+ for await (const filename of dir?.keys()) {
4738
+ const idx = filename.indexOf("-", filename.indexOf("-") + 1);
4739
+ if (idx === -1) {
4740
+ continue;
4741
+ }
4742
+ map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
4743
+ }
4744
+ diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
4745
+ file,
4746
+ count
4747
+ }));
4873
4748
  }
4874
- if (persistent && keyStore === StorageDriver.RAM) {
4875
- throw new import_protocols14.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
4749
+ const identity = serviceContext.identityManager.identity;
4750
+ if (identity) {
4751
+ diagnostics.identity = {
4752
+ identityKey: identity.identityKey,
4753
+ spaceKey: identity.space.key,
4754
+ profile: identity.profileDocument
4755
+ };
4756
+ const { devices } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
4757
+ timeout: DEFAULT_TIMEOUT
4758
+ }).catch(() => void 0) ?? {};
4759
+ diagnostics.devices = devices;
4760
+ if (serviceContext.dataSpaceManager) {
4761
+ diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
4762
+ }
4763
+ const { feeds = [] } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
4764
+ timeout: DEFAULT_TIMEOUT
4765
+ }).catch(() => void 0) ?? {};
4766
+ diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
4767
+ feedKey,
4768
+ bytes,
4769
+ length
4770
+ }));
4771
+ const status = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
4772
+ timeout: DEFAULT_TIMEOUT
4773
+ }).catch(() => void 0);
4774
+ diagnostics.networkStatus = status;
4775
+ diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
4876
4776
  }
4877
- if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
4878
- throw new import_protocols14.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
4777
+ diagnostics.config = config.values;
4778
+ return diagnostics;
4779
+ };
4780
+ var getSpaceStats = async (space) => {
4781
+ const stats = {
4782
+ key: space.key,
4783
+ metrics: space.metrics,
4784
+ epochs: space.inner.spaceState.credentials.filter((0, import_credentials15.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
4785
+ ...credential.subject.assertion,
4786
+ id: credential.id
4787
+ })),
4788
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
4789
+ identity: {
4790
+ identityKey: member.key,
4791
+ profile: {
4792
+ displayName: member.assertion.profile?.displayName
4793
+ }
4794
+ },
4795
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services11.SpaceMember.PresenceState.ONLINE : import_services11.SpaceMember.PresenceState.OFFLINE
4796
+ })),
4797
+ pipeline: {
4798
+ // TODO(burdon): Pick properties from credentials if needed.
4799
+ currentEpoch: space.automergeSpaceState.lastEpoch,
4800
+ appliedEpoch: space.automergeSpaceState.lastEpoch,
4801
+ controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
4802
+ currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
4803
+ targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
4804
+ totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
4805
+ }
4806
+ };
4807
+ if (stats.metrics) {
4808
+ const { open, ready } = stats.metrics;
4809
+ stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
4879
4810
  }
4811
+ return stats;
4812
+ };
4813
+ var createCollectDiagnosticsBroadcastSender = () => {
4880
4814
  return {
4881
- storage: (0, import_random_access_storage.createStorage)({
4882
- type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
4883
- root: getRootPath(config)
4884
- })
4815
+ broadcastDiagnosticsRequest: async () => void 0
4885
4816
  };
4886
4817
  };
4887
- var toStorageType = (type) => {
4888
- switch (type) {
4889
- case void 0:
4890
- return void 0;
4891
- case StorageDriver.RAM:
4892
- return import_random_access_storage.StorageType.RAM;
4893
- case StorageDriver.CHROME:
4894
- return import_random_access_storage.StorageType.CHROME;
4895
- case StorageDriver.FIREFOX:
4896
- return import_random_access_storage.StorageType.FIREFOX;
4897
- case StorageDriver.IDB:
4898
- return import_random_access_storage.StorageType.IDB;
4899
- case StorageDriver.NODE:
4900
- return import_random_access_storage.StorageType.NODE;
4901
- case StorageDriver.WEBFS:
4902
- return import_random_access_storage.StorageType.WEBFS;
4903
- default:
4904
- throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
4905
- }
4906
- };
4907
- var createLevel = async (config) => {
4908
- const persistent = isPersistent(config);
4909
- const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys11.PublicKey.random().toHex());
4910
- const level = new import_level.Level(storagePath);
4911
- await level.open();
4912
- return level;
4818
+ var createCollectDiagnosticsBroadcastHandler = (_) => {
4819
+ return {
4820
+ start: () => {
4821
+ },
4822
+ stop: () => {
4823
+ }
4824
+ };
4913
4825
  };
4914
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
4826
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
4915
4827
  var DevicesServiceImpl = class {
4916
4828
  constructor(_identityManager) {
4917
4829
  this._identityManager = _identityManager;
@@ -4928,8 +4840,8 @@ var DevicesServiceImpl = class {
4928
4840
  devices: []
4929
4841
  });
4930
4842
  } else {
4931
- (0, import_invariant17.invariant)(this._identityManager.identity?.presence, "presence not present", {
4932
- F: __dxlog_file17,
4843
+ (0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
4844
+ F: __dxlog_file16,
4933
4845
  L: 32,
4934
4846
  S: this,
4935
4847
  A: [
@@ -4944,9 +4856,9 @@ var DevicesServiceImpl = class {
4944
4856
  const peerState = peers.find((peer) => peer.identityKey.equals(key));
4945
4857
  return {
4946
4858
  deviceKey: key,
4947
- kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services14.DeviceKind.CURRENT : import_services14.DeviceKind.TRUSTED,
4859
+ kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services15.DeviceKind.CURRENT : import_services15.DeviceKind.TRUSTED,
4948
4860
  profile,
4949
- presence: isMe ? import_services14.Device.PresenceState.ONLINE : peerState ? import_services14.Device.PresenceState.ONLINE : import_services14.Device.PresenceState.OFFLINE
4861
+ presence: isMe ? import_services15.Device.PresenceState.ONLINE : peerState ? import_services15.Device.PresenceState.ONLINE : import_services15.Device.PresenceState.OFFLINE
4950
4862
  };
4951
4863
  })
4952
4864
  });
@@ -4987,11 +4899,65 @@ var DevicesServiceImpl = class {
4987
4899
  });
4988
4900
  }
4989
4901
  };
4902
+ function _ts_decorate7(decorators, target, key, desc) {
4903
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4904
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4905
+ r = Reflect.decorate(decorators, target, key, desc);
4906
+ else
4907
+ for (var i = decorators.length - 1; i >= 0; i--)
4908
+ if (d = decorators[i])
4909
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4910
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
4911
+ }
4912
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
4913
+ var Lock = class {
4914
+ constructor({ lockKey: lockPath, onAcquire, onRelease }) {
4915
+ this._lockPath = lockPath;
4916
+ this._onAcquire = onAcquire;
4917
+ this._onRelease = onRelease;
4918
+ }
4919
+ get lockKey() {
4920
+ return this._lockPath;
4921
+ }
4922
+ async acquire() {
4923
+ (0, import_log14.log)("acquiring lock...", void 0, {
4924
+ F: __dxlog_file17,
4925
+ L: 32,
4926
+ S: this,
4927
+ C: (f, a) => f(...a)
4928
+ });
4929
+ this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
4930
+ await this._onAcquire?.();
4931
+ (0, import_log14.log)("acquired lock", void 0, {
4932
+ F: __dxlog_file17,
4933
+ L: 37,
4934
+ S: this,
4935
+ C: (f, a) => f(...a)
4936
+ });
4937
+ }
4938
+ async release() {
4939
+ await this._onRelease?.();
4940
+ (0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
4941
+ F: __dxlog_file17,
4942
+ L: 42,
4943
+ S: this,
4944
+ A: [
4945
+ "this._fileHandle",
4946
+ "'Lock is not acquired'"
4947
+ ]
4948
+ });
4949
+ await import_lock_file.LockFile.release(this._fileHandle);
4950
+ }
4951
+ };
4952
+ _ts_decorate7([
4953
+ import_log14.logInfo
4954
+ ], Lock.prototype, "lockKey", null);
4955
+ var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
4990
4956
  var LoggingServiceImpl = class {
4991
4957
  constructor() {
4992
4958
  this._logs = new import_async18.Event();
4993
4959
  this._started = Date.now();
4994
- this._sessionId = import_keys13.PublicKey.random().toHex();
4960
+ this._sessionId = import_keys12.PublicKey.random().toHex();
4995
4961
  this._logProcessor = (_config, entry2) => {
4996
4962
  this._logs.emit(entry2);
4997
4963
  };
@@ -5088,16 +5054,16 @@ var LoggingServiceImpl = class {
5088
5054
  };
5089
5055
  var matchFilter = (filter, level, path2, options) => {
5090
5056
  switch (options) {
5091
- case import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5057
+ case import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5092
5058
  return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
5093
- case import_services15.QueryLogsRequest.MatchingOptions.EXPLICIT:
5059
+ case import_services16.QueryLogsRequest.MatchingOptions.EXPLICIT:
5094
5060
  return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
5095
5061
  }
5096
5062
  };
5097
5063
  var shouldLog = (entry2, request) => {
5098
- const options = request.options ?? import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5064
+ const options = request.options ?? import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5099
5065
  if (request.filters === void 0) {
5100
- return options === import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5066
+ return options === import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5101
5067
  } else {
5102
5068
  return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
5103
5069
  }
@@ -5133,6 +5099,63 @@ var NetworkServiceImpl = class {
5133
5099
  await this.networkManager.setConnectionState(request.swarm);
5134
5100
  }
5135
5101
  };
5102
+ var getRootPath = (config) => {
5103
+ const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol5.DX_DATA : "dxos/storage" } = config ?? {};
5104
+ return `${dataRoot}/`;
5105
+ };
5106
+ var isPersistent = (config) => {
5107
+ const { persistent = false } = config ?? {};
5108
+ return config.dataStore !== void 0 && config.dataStore !== import_config3.Runtime.Client.Storage.StorageDriver.RAM || persistent;
5109
+ };
5110
+ var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
5111
+ var createStorageObjects = (config) => {
5112
+ const { persistent = false, keyStore, dataStore } = config ?? {};
5113
+ if (persistent && dataStore === StorageDriver.RAM) {
5114
+ throw new import_protocols15.InvalidConfigError("RAM storage cannot be used in persistent mode.");
5115
+ }
5116
+ if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
5117
+ throw new import_protocols15.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
5118
+ }
5119
+ if (persistent && keyStore === StorageDriver.RAM) {
5120
+ throw new import_protocols15.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
5121
+ }
5122
+ if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
5123
+ throw new import_protocols15.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
5124
+ }
5125
+ return {
5126
+ storage: (0, import_random_access_storage.createStorage)({
5127
+ type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
5128
+ root: getRootPath(config)
5129
+ })
5130
+ };
5131
+ };
5132
+ var toStorageType = (type) => {
5133
+ switch (type) {
5134
+ case void 0:
5135
+ return void 0;
5136
+ case StorageDriver.RAM:
5137
+ return import_random_access_storage.StorageType.RAM;
5138
+ case StorageDriver.CHROME:
5139
+ return import_random_access_storage.StorageType.CHROME;
5140
+ case StorageDriver.FIREFOX:
5141
+ return import_random_access_storage.StorageType.FIREFOX;
5142
+ case StorageDriver.IDB:
5143
+ return import_random_access_storage.StorageType.IDB;
5144
+ case StorageDriver.NODE:
5145
+ return import_random_access_storage.StorageType.NODE;
5146
+ case StorageDriver.WEBFS:
5147
+ return import_random_access_storage.StorageType.WEBFS;
5148
+ default:
5149
+ throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
5150
+ }
5151
+ };
5152
+ var createLevel = async (config) => {
5153
+ const persistent = isPersistent(config);
5154
+ const storagePath = persistent ? import_node_path.default.join(getRootPath(config), "level") : `/tmp/dxos-${import_keys13.PublicKey.random().toHex()}`;
5155
+ const level = new import_level.Level(storagePath);
5156
+ await level.open();
5157
+ return level;
5158
+ };
5136
5159
  var SystemServiceImpl = class {
5137
5160
  constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
5138
5161
  this._config = config;
@@ -5152,9 +5175,9 @@ var SystemServiceImpl = class {
5152
5175
  const diagnostics = await this._getDiagnostics();
5153
5176
  return {
5154
5177
  timestamp: /* @__PURE__ */ new Date(),
5155
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util11.jsonKeyReplacer)({
5156
- truncate: keys === import_services16.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
5157
- humanize: keys === import_services16.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
5178
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
5179
+ truncate: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
5180
+ humanize: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
5158
5181
  })))
5159
5182
  };
5160
5183
  }
@@ -5202,16 +5225,18 @@ var ClientServicesHost = class {
5202
5225
  transportFactory,
5203
5226
  signalManager,
5204
5227
  storage,
5228
+ level,
5205
5229
  // TODO(wittjosiah): Turn this on by default.
5206
5230
  lockKey,
5207
5231
  callbacks,
5208
5232
  runtimeParams
5209
5233
  } = {}) {
5210
- this._tracingService = import_tracing7.TRACE_PROCESSOR.createTraceSender();
5234
+ this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
5211
5235
  this._statusUpdate = new import_async16.Event();
5212
5236
  this._opening = false;
5213
5237
  this._open = false;
5214
5238
  this._storage = storage;
5239
+ this._level = level;
5215
5240
  this._callbacks = callbacks;
5216
5241
  this._runtimeParams = runtimeParams;
5217
5242
  if (config) {
@@ -5235,14 +5260,14 @@ var ClientServicesHost = class {
5235
5260
  this._systemService = new SystemServiceImpl({
5236
5261
  config: () => this._config,
5237
5262
  statusUpdate: this._statusUpdate,
5238
- getCurrentStatus: () => this.isOpen ? import_services13.SystemStatus.ACTIVE : import_services13.SystemStatus.INACTIVE,
5263
+ getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
5239
5264
  getDiagnostics: () => {
5240
5265
  return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
5241
5266
  },
5242
5267
  onUpdateStatus: async (status) => {
5243
- if (!this.isOpen && status === import_services13.SystemStatus.ACTIVE) {
5268
+ if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
5244
5269
  await this._resourceLock?.acquire();
5245
- } else if (this.isOpen && status === import_services13.SystemStatus.INACTIVE) {
5270
+ } else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
5246
5271
  await this._resourceLock?.release();
5247
5272
  }
5248
5273
  },
@@ -5250,8 +5275,9 @@ var ClientServicesHost = class {
5250
5275
  await this.reset();
5251
5276
  }
5252
5277
  });
5278
+ this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
5253
5279
  this._loggingService = new LoggingServiceImpl();
5254
- this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
5280
+ this._serviceRegistry = new ServiceRegistry(import_client_protocol4.clientServiceBundle, {
5255
5281
  SystemService: this._systemService,
5256
5282
  TracingService: this._tracingService
5257
5283
  });
@@ -5280,25 +5306,25 @@ var ClientServicesHost = class {
5280
5306
  * Can only be called once.
5281
5307
  */
5282
5308
  initialize({ config, ...options }) {
5283
- (0, import_invariant16.invariant)(!this._open, "service host is open", {
5309
+ (0, import_invariant15.invariant)(!this._open, "service host is open", {
5284
5310
  F: __dxlog_file18,
5285
- L: 182,
5311
+ L: 197,
5286
5312
  S: this,
5287
5313
  A: [
5288
5314
  "!this._open",
5289
5315
  "'service host is open'"
5290
5316
  ]
5291
5317
  });
5292
- (0, import_log14.log)("initializing...", void 0, {
5318
+ (0, import_log13.log)("initializing...", void 0, {
5293
5319
  F: __dxlog_file18,
5294
- L: 183,
5320
+ L: 198,
5295
5321
  S: this,
5296
5322
  C: (f, a) => f(...a)
5297
5323
  });
5298
5324
  if (config) {
5299
- (0, import_invariant16.invariant)(!this._config, "config already set", {
5325
+ (0, import_invariant15.invariant)(!this._config, "config already set", {
5300
5326
  F: __dxlog_file18,
5301
- L: 186,
5327
+ L: 201,
5302
5328
  S: this,
5303
5329
  A: [
5304
5330
  "!this._config",
@@ -5311,9 +5337,9 @@ var ClientServicesHost = class {
5311
5337
  }
5312
5338
  }
5313
5339
  if (!options.signalManager) {
5314
- import_log14.log.warn("running signaling without telemetry metadata.", void 0, {
5340
+ import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
5315
5341
  F: __dxlog_file18,
5316
- L: 194,
5342
+ L: 209,
5317
5343
  S: this,
5318
5344
  C: (f, a) => f(...a)
5319
5345
  });
@@ -5322,9 +5348,9 @@ var ClientServicesHost = class {
5322
5348
  iceServers: this._config?.get("runtime.services.ice")
5323
5349
  }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
5324
5350
  this._signalManager = signalManager;
5325
- (0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
5351
+ (0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
5326
5352
  F: __dxlog_file18,
5327
- L: 205,
5353
+ L: 220,
5328
5354
  S: this,
5329
5355
  A: [
5330
5356
  "!this._networkManager",
@@ -5336,9 +5362,9 @@ var ClientServicesHost = class {
5336
5362
  transportFactory,
5337
5363
  signalManager
5338
5364
  });
5339
- (0, import_log14.log)("initialized", void 0, {
5365
+ (0, import_log13.log)("initialized", void 0, {
5340
5366
  F: __dxlog_file18,
5341
- L: 212,
5367
+ L: 227,
5342
5368
  S: this,
5343
5369
  C: (f, a) => f(...a)
5344
5370
  });
@@ -5347,45 +5373,45 @@ var ClientServicesHost = class {
5347
5373
  if (this._open) {
5348
5374
  return;
5349
5375
  }
5350
- const traceId = import_keys12.PublicKey.random().toHex();
5351
- import_log14.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
5376
+ const traceId = import_keys11.PublicKey.random().toHex();
5377
+ import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
5352
5378
  id: traceId
5353
5379
  }), {
5354
5380
  F: __dxlog_file18,
5355
- L: 223,
5381
+ L: 238,
5356
5382
  S: this,
5357
5383
  C: (f, a) => f(...a)
5358
5384
  });
5359
- (0, import_invariant16.invariant)(this._config, "config not set", {
5385
+ (0, import_invariant15.invariant)(this._config, "config not set", {
5360
5386
  F: __dxlog_file18,
5361
- L: 225,
5387
+ L: 240,
5362
5388
  S: this,
5363
5389
  A: [
5364
5390
  "this._config",
5365
5391
  "'config not set'"
5366
5392
  ]
5367
5393
  });
5368
- (0, import_invariant16.invariant)(this._storage, "storage not set", {
5394
+ (0, import_invariant15.invariant)(this._storage, "storage not set", {
5369
5395
  F: __dxlog_file18,
5370
- L: 226,
5396
+ L: 241,
5371
5397
  S: this,
5372
5398
  A: [
5373
5399
  "this._storage",
5374
5400
  "'storage not set'"
5375
5401
  ]
5376
5402
  });
5377
- (0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
5403
+ (0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
5378
5404
  F: __dxlog_file18,
5379
- L: 227,
5405
+ L: 242,
5380
5406
  S: this,
5381
5407
  A: [
5382
5408
  "this._signalManager",
5383
5409
  "'signal manager not set'"
5384
5410
  ]
5385
5411
  });
5386
- (0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
5412
+ (0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
5387
5413
  F: __dxlog_file18,
5388
- L: 228,
5414
+ L: 243,
5389
5415
  S: this,
5390
5416
  A: [
5391
5417
  "this._networkManager",
@@ -5393,17 +5419,18 @@ var ClientServicesHost = class {
5393
5419
  ]
5394
5420
  });
5395
5421
  this._opening = true;
5396
- (0, import_log14.log)("opening...", {
5422
+ (0, import_log13.log)("opening...", {
5397
5423
  lockKey: this._resourceLock?.lockKey
5398
5424
  }, {
5399
5425
  F: __dxlog_file18,
5400
- L: 231,
5426
+ L: 246,
5401
5427
  S: this,
5402
5428
  C: (f, a) => f(...a)
5403
5429
  });
5404
5430
  if (!this._level) {
5405
5431
  this._level = await createLevel(this._config.get("runtime.client.storage", {}));
5406
5432
  }
5433
+ await this._level.open();
5407
5434
  await this._resourceLock?.acquire();
5408
5435
  await this._loggingService.open();
5409
5436
  this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
@@ -5416,7 +5443,7 @@ var ClientServicesHost = class {
5416
5443
  await this._serviceContext.initialized.wait();
5417
5444
  return this._serviceContext.dataSpaceManager;
5418
5445
  }),
5419
- DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.automergeHost),
5446
+ DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
5420
5447
  IndexService: new import_indexing2.IndexServiceImpl({
5421
5448
  indexer: this._serviceContext.indexer,
5422
5449
  automergeHost: this._serviceContext.automergeHost
@@ -5432,9 +5459,9 @@ var ClientServicesHost = class {
5432
5459
  })
5433
5460
  });
5434
5461
  await this._serviceContext.open(ctx);
5435
- (0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5462
+ (0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5436
5463
  F: __dxlog_file18,
5437
- L: 297,
5464
+ L: 314,
5438
5465
  S: this,
5439
5466
  A: [
5440
5467
  "this.serviceRegistry.services.InvitationsService",
@@ -5442,11 +5469,11 @@ var ClientServicesHost = class {
5442
5469
  ]
5443
5470
  });
5444
5471
  const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
5445
- (0, import_log14.log)("loaded persistent invitations", {
5472
+ (0, import_log13.log)("loaded persistent invitations", {
5446
5473
  count: loadedInvitations.invitations?.length
5447
5474
  }, {
5448
5475
  F: __dxlog_file18,
5449
- L: 300,
5476
+ L: 317,
5450
5477
  S: this,
5451
5478
  C: (f, a) => f(...a)
5452
5479
  });
@@ -5455,28 +5482,29 @@ var ClientServicesHost = class {
5455
5482
  this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
5456
5483
  url: devtoolsProxy,
5457
5484
  requested: {},
5458
- exposed: import_client_protocol5.clientServiceBundle,
5485
+ exposed: import_client_protocol4.clientServiceBundle,
5459
5486
  handlers: this.services
5460
5487
  });
5461
5488
  void this._devtoolsProxy.open();
5462
5489
  }
5490
+ this.diagnosticsBroadcastHandler.start();
5463
5491
  this._opening = false;
5464
5492
  this._open = true;
5465
5493
  this._statusUpdate.emit();
5466
5494
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
5467
- (0, import_log14.log)("opened", {
5495
+ (0, import_log13.log)("opened", {
5468
5496
  deviceKey
5469
5497
  }, {
5470
5498
  F: __dxlog_file18,
5471
- L: 317,
5499
+ L: 335,
5472
5500
  S: this,
5473
5501
  C: (f, a) => f(...a)
5474
5502
  });
5475
- import_log14.log.trace("dxos.client-services.host.open", import_protocols15.trace.end({
5503
+ import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
5476
5504
  id: traceId
5477
5505
  }), {
5478
5506
  F: __dxlog_file18,
5479
- L: 318,
5507
+ L: 336,
5480
5508
  S: this,
5481
5509
  C: (f, a) => f(...a)
5482
5510
  });
@@ -5486,14 +5514,15 @@ var ClientServicesHost = class {
5486
5514
  return;
5487
5515
  }
5488
5516
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
5489
- (0, import_log14.log)("closing...", {
5517
+ (0, import_log13.log)("closing...", {
5490
5518
  deviceKey
5491
5519
  }, {
5492
5520
  F: __dxlog_file18,
5493
- L: 329,
5521
+ L: 347,
5494
5522
  S: this,
5495
5523
  C: (f, a) => f(...a)
5496
5524
  });
5525
+ this.diagnosticsBroadcastHandler.stop();
5497
5526
  await this._devtoolsProxy?.close();
5498
5527
  this._serviceRegistry.setServices({
5499
5528
  SystemService: this._systemService
@@ -5503,44 +5532,44 @@ var ClientServicesHost = class {
5503
5532
  await this._level?.close();
5504
5533
  this._open = false;
5505
5534
  this._statusUpdate.emit();
5506
- (0, import_log14.log)("closed", {
5535
+ (0, import_log13.log)("closed", {
5507
5536
  deviceKey
5508
5537
  }, {
5509
5538
  F: __dxlog_file18,
5510
- L: 337,
5539
+ L: 356,
5511
5540
  S: this,
5512
5541
  C: (f, a) => f(...a)
5513
5542
  });
5514
5543
  }
5515
5544
  async reset() {
5516
- const traceId = import_keys12.PublicKey.random().toHex();
5517
- import_log14.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
5545
+ const traceId = import_keys11.PublicKey.random().toHex();
5546
+ import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
5518
5547
  id: traceId
5519
5548
  }), {
5520
5549
  F: __dxlog_file18,
5521
- L: 342,
5550
+ L: 361,
5522
5551
  S: this,
5523
5552
  C: (f, a) => f(...a)
5524
5553
  });
5525
- (0, import_log14.log)("resetting...", void 0, {
5554
+ (0, import_log13.log)("resetting...", void 0, {
5526
5555
  F: __dxlog_file18,
5527
- L: 344,
5556
+ L: 363,
5528
5557
  S: this,
5529
5558
  C: (f, a) => f(...a)
5530
5559
  });
5531
5560
  await this._serviceContext?.close();
5532
5561
  await this._storage.reset();
5533
- (0, import_log14.log)("reset", void 0, {
5562
+ (0, import_log13.log)("reset", void 0, {
5534
5563
  F: __dxlog_file18,
5535
- L: 347,
5564
+ L: 366,
5536
5565
  S: this,
5537
5566
  C: (f, a) => f(...a)
5538
5567
  });
5539
- import_log14.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.end({
5568
+ import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.end({
5540
5569
  id: traceId
5541
5570
  }), {
5542
5571
  F: __dxlog_file18,
5543
- L: 348,
5572
+ L: 367,
5544
5573
  S: this,
5545
5574
  C: (f, a) => f(...a)
5546
5575
  });
@@ -5551,9 +5580,9 @@ var ClientServicesHost = class {
5551
5580
  await this._serviceContext.initialized.wait();
5552
5581
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5553
5582
  const automergeIndex = space.automergeSpaceState.rootUrl;
5554
- (0, import_invariant16.invariant)(automergeIndex, void 0, {
5583
+ (0, import_invariant15.invariant)(automergeIndex, void 0, {
5555
5584
  F: __dxlog_file18,
5556
- L: 360,
5585
+ L: 379,
5557
5586
  S: this,
5558
5587
  A: [
5559
5588
  "automergeIndex",
@@ -5564,16 +5593,16 @@ var ClientServicesHost = class {
5564
5593
  await document.whenReady();
5565
5594
  const properties = {
5566
5595
  system: {
5567
- type: (0, import_echo_pipeline4.encodeReference)(E.getTypeReference(import_client_protocol5.Properties))
5596
+ type: (0, import_echo_pipeline5.encodeReference)(E.getTypeReference(import_client_protocol4.Properties))
5568
5597
  },
5569
5598
  data: {
5570
- [import_client_protocol5.defaultKey]: identity.identityKey.toHex()
5599
+ [import_client_protocol4.defaultKey]: identity.identityKey.toHex()
5571
5600
  },
5572
5601
  meta: {
5573
5602
  keys: []
5574
5603
  }
5575
5604
  };
5576
- const propertiesId = import_keys12.PublicKey.random().toHex();
5605
+ const propertiesId = import_keys11.PublicKey.random().toHex();
5577
5606
  document.change((doc) => {
5578
5607
  (0, import_util9.assignDeep)(doc, [
5579
5608
  "objects",
@@ -5585,31 +5614,65 @@ var ClientServicesHost = class {
5585
5614
  }
5586
5615
  };
5587
5616
  _ts_decorate8([
5588
- import_tracing7.trace.info()
5617
+ import_tracing8.trace.info()
5589
5618
  ], ClientServicesHost.prototype, "_opening", void 0);
5590
5619
  _ts_decorate8([
5591
- import_tracing7.trace.info()
5620
+ import_tracing8.trace.info()
5592
5621
  ], ClientServicesHost.prototype, "_open", void 0);
5593
5622
  _ts_decorate8([
5594
5623
  import_async16.synchronized,
5595
- import_tracing7.trace.span()
5624
+ import_tracing8.trace.span()
5596
5625
  ], ClientServicesHost.prototype, "open", null);
5597
5626
  _ts_decorate8([
5598
5627
  import_async16.synchronized,
5599
- import_tracing7.trace.span()
5628
+ import_tracing8.trace.span()
5600
5629
  ], ClientServicesHost.prototype, "close", null);
5601
5630
  ClientServicesHost = _ts_decorate8([
5602
- import_tracing7.trace.resource()
5631
+ import_tracing8.trace.resource()
5603
5632
  ], ClientServicesHost);
5633
+ var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
5634
+ var DiagnosticsCollector = class {
5635
+ static {
5636
+ this.broadcastSender = createCollectDiagnosticsBroadcastSender();
5637
+ }
5638
+ static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
5639
+ const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
5640
+ keys: options.humanize ? import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
5641
+ });
5642
+ const clientDiagnostics = {
5643
+ config,
5644
+ trace: import_tracing7.TRACE_PROCESSOR.getDiagnostics()
5645
+ };
5646
+ const diagnostics = serviceDiagnostics != null ? {
5647
+ client: clientDiagnostics,
5648
+ services: serviceDiagnostics
5649
+ } : {
5650
+ client: clientDiagnostics,
5651
+ broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
5652
+ };
5653
+ return JSON.parse(JSON.stringify(diagnostics, (0, import_util8.jsonKeyReplacer)(options)));
5654
+ }
5655
+ };
5656
+ var findSystemServiceProvider = () => {
5657
+ const serviceProviders = import_tracing7.TRACE_PROCESSOR.findByAnnotation(ClientServicesProviderResource);
5658
+ const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
5659
+ return providerResource?.instance?.deref() ?? null;
5660
+ };
5661
+ var findConfigs = () => {
5662
+ const configs = import_tracing7.TRACE_PROCESSOR.findByAnnotation(import_config.ConfigResource);
5663
+ return configs.map((r) => r.instance.deref()).filter(import_util8.nonNullable);
5664
+ };
5604
5665
  // Annotate the CommonJS export names for ESM import in node:
5605
5666
  0 && (module.exports = {
5606
5667
  ClientRpcServer,
5607
5668
  ClientServicesHost,
5669
+ ClientServicesProviderResource,
5608
5670
  DataSpace,
5609
5671
  DataSpaceManager,
5610
5672
  DeviceInvitationProtocol,
5611
5673
  DevtoolsHostEvents,
5612
5674
  DevtoolsServiceImpl,
5675
+ DiagnosticsCollector,
5613
5676
  Identity,
5614
5677
  IdentityManager,
5615
5678
  IdentityServiceImpl,
@@ -5622,11 +5685,12 @@ ClientServicesHost = _ts_decorate8([
5622
5685
  SpacesServiceImpl,
5623
5686
  TrustedKeySetAuthVerifier,
5624
5687
  createAuthProvider,
5688
+ createCollectDiagnosticsBroadcastHandler,
5689
+ createCollectDiagnosticsBroadcastSender,
5625
5690
  createDiagnostics,
5626
5691
  createLevel,
5627
5692
  createStorageObjects,
5628
5693
  getNetworkPeers,
5629
- invitationExpired,
5630
5694
  isLocked,
5631
5695
  subscribeToFeedBlocks,
5632
5696
  subscribeToFeeds,
@@ -5636,4 +5700,4 @@ ClientServicesHost = _ts_decorate8([
5636
5700
  subscribeToSpaces,
5637
5701
  subscribeToSwarmInfo
5638
5702
  });
5639
- //# sourceMappingURL=chunk-SF4YXR7W.cjs.map
5703
+ //# sourceMappingURL=chunk-V7W7YK6W.cjs.map