@dxos/client-services 0.4.10-main.7ce71da → 0.4.10-main.8583d5a

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 (82) hide show
  1. package/dist/lib/browser/{chunk-RI5YQYKS.mjs → chunk-ZBQ4LQQX.mjs} +746 -561
  2. package/dist/lib/browser/chunk-ZBQ4LQQX.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +11 -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 +11 -5
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-GW6EAU3Y.cjs → chunk-HMAV5VTX.cjs} +690 -593
  9. package/dist/lib/node/chunk-HMAV5VTX.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +46 -38
  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 +15 -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 +7 -5
  33. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  34. package/dist/types/src/packlets/services/service-host.d.ts +5 -1
  35. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  36. package/dist/types/src/packlets/services/util.d.ts +1 -0
  37. package/dist/types/src/packlets/services/util.d.ts.map +1 -1
  38. package/dist/types/src/packlets/storage/index.d.ts +1 -0
  39. package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
  40. package/dist/types/src/packlets/storage/level.d.ts +4 -0
  41. package/dist/types/src/packlets/storage/level.d.ts.map +1 -0
  42. package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
  43. package/dist/types/src/packlets/storage/util.d.ts +4 -0
  44. package/dist/types/src/packlets/storage/util.d.ts.map +1 -0
  45. package/dist/types/src/packlets/system/system-service.d.ts +1 -1
  46. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  47. package/dist/types/src/packlets/testing/test-builder.d.ts +5 -2
  48. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  49. package/dist/types/src/version.d.ts +1 -1
  50. package/package.json +36 -34
  51. package/src/index.ts +1 -0
  52. package/src/packlets/devices/devices-service.test.ts +1 -1
  53. package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
  54. package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
  55. package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
  56. package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
  57. package/src/packlets/diagnostics/index.ts +7 -0
  58. package/src/packlets/identity/identity-service.test.ts +1 -1
  59. package/src/packlets/indexing/util.ts +1 -1
  60. package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
  61. package/src/packlets/invitations/invitations-handler.ts +5 -12
  62. package/src/packlets/invitations/invitations-service.ts +5 -5
  63. package/src/packlets/network/network-service.test.ts +1 -1
  64. package/src/packlets/services/automerge-host.test.ts +9 -3
  65. package/src/packlets/services/index.ts +1 -1
  66. package/src/packlets/services/service-context.test.ts +9 -6
  67. package/src/packlets/services/service-context.ts +12 -5
  68. package/src/packlets/services/service-host.ts +49 -13
  69. package/src/packlets/services/service-registry.test.ts +1 -1
  70. package/src/packlets/services/util.ts +2 -0
  71. package/src/packlets/spaces/data-space-manager.test.ts +4 -4
  72. package/src/packlets/spaces/spaces-service.test.ts +1 -1
  73. package/src/packlets/storage/index.ts +1 -0
  74. package/src/packlets/storage/level.ts +19 -0
  75. package/src/packlets/storage/storage.ts +3 -9
  76. package/src/packlets/storage/util.ts +19 -0
  77. package/src/packlets/system/system-service.ts +1 -1
  78. package/src/packlets/testing/test-builder.ts +23 -5
  79. package/src/version.ts +1 -1
  80. package/dist/lib/browser/chunk-RI5YQYKS.mjs.map +0 -7
  81. package/dist/lib/node/chunk-GW6EAU3Y.cjs.map +0 -7
  82. 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_GW6EAU3Y_exports = {};
30
- __export(chunk_GW6EAU3Y_exports, {
29
+ var chunk_HMAV5VTX_exports = {};
30
+ __export(chunk_HMAV5VTX_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,10 +49,12 @@ __export(chunk_GW6EAU3Y_exports, {
47
49
  SpacesServiceImpl: () => SpacesServiceImpl,
48
50
  TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
49
51
  createAuthProvider: () => createAuthProvider,
52
+ createCollectDiagnosticsBroadcastHandler: () => createCollectDiagnosticsBroadcastHandler,
53
+ createCollectDiagnosticsBroadcastSender: () => createCollectDiagnosticsBroadcastSender,
50
54
  createDiagnostics: () => createDiagnostics,
55
+ createLevel: () => createLevel,
51
56
  createStorageObjects: () => createStorageObjects,
52
57
  getNetworkPeers: () => getNetworkPeers,
53
- invitationExpired: () => invitationExpired,
54
58
  isLocked: () => isLocked,
55
59
  subscribeToFeedBlocks: () => subscribeToFeedBlocks,
56
60
  subscribeToFeeds: () => subscribeToFeeds,
@@ -60,7 +64,7 @@ __export(chunk_GW6EAU3Y_exports, {
60
64
  subscribeToSpaces: () => subscribeToSpaces,
61
65
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
66
  });
63
- module.exports = __toCommonJS(chunk_GW6EAU3Y_exports);
67
+ module.exports = __toCommonJS(chunk_HMAV5VTX_exports);
64
68
  var import_async = require("@dxos/async");
65
69
  var import_codec_protobuf = require("@dxos/codec-protobuf");
66
70
  var import_feed_store = require("@dxos/feed-store");
@@ -134,6 +138,7 @@ var import_teleport = require("@dxos/teleport");
134
138
  var import_async9 = require("@dxos/async");
135
139
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
136
140
  var import_context6 = require("@dxos/context");
141
+ var import_echo_pipeline = require("@dxos/echo-pipeline");
137
142
  var import_invariant7 = require("@dxos/invariant");
138
143
  var import_log6 = require("@dxos/log");
139
144
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
@@ -147,118 +152,127 @@ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
147
152
  var import_debug2 = require("@dxos/debug");
148
153
  var import_rpc = require("@dxos/rpc");
149
154
  var import_tracing3 = require("@dxos/tracing");
150
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
151
- var import_credentials9 = require("@dxos/credentials");
152
- var import_invariant9 = require("@dxos/invariant");
153
- var import_protocols7 = require("@dxos/protocols");
154
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
155
- var import_tracing4 = require("@dxos/tracing");
156
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
157
155
  var import_async10 = require("@dxos/async");
158
156
  var import_client_protocol3 = require("@dxos/client-protocol");
159
157
  var import_context7 = require("@dxos/context");
160
158
  var import_debug3 = require("@dxos/debug");
161
159
  var import_echo_db = require("@dxos/echo-db");
162
- var import_echo_pipeline = require("@dxos/echo-pipeline");
163
160
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
164
- var import_invariant10 = require("@dxos/invariant");
161
+ var import_echo_pipeline3 = require("@dxos/echo-pipeline");
162
+ var import_invariant9 = require("@dxos/invariant");
165
163
  var import_keys7 = require("@dxos/keys");
166
164
  var import_log8 = require("@dxos/log");
167
- var import_protocols8 = require("@dxos/protocols");
168
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
169
- 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");
170
168
  var import_timeframe2 = require("@dxos/timeframe");
171
- var import_tracing5 = require("@dxos/tracing");
169
+ var import_tracing4 = require("@dxos/tracing");
172
170
  var import_util4 = require("@dxos/util");
173
171
  var import_async11 = require("@dxos/async");
174
- var import_credentials11 = require("@dxos/credentials");
172
+ var import_credentials10 = require("@dxos/credentials");
175
173
  var import_async12 = require("@dxos/async");
176
174
  var import_context8 = require("@dxos/context");
177
- var import_invariant11 = require("@dxos/invariant");
175
+ var import_invariant10 = require("@dxos/invariant");
178
176
  var import_keys8 = require("@dxos/keys");
179
177
  var import_log9 = require("@dxos/log");
180
- var import_protocols9 = require("@dxos/protocols");
178
+ var import_protocols8 = require("@dxos/protocols");
181
179
  var import_teleport2 = require("@dxos/teleport");
182
180
  var import_util5 = require("@dxos/util");
183
181
  var import_async13 = require("@dxos/async");
184
182
  var import_context9 = require("@dxos/context");
185
- var import_credentials12 = require("@dxos/credentials");
186
- var import_invariant12 = require("@dxos/invariant");
183
+ var import_credentials11 = require("@dxos/credentials");
184
+ var import_invariant11 = require("@dxos/invariant");
187
185
  var import_keys9 = require("@dxos/keys");
188
186
  var import_log10 = require("@dxos/log");
189
- var import_protocols10 = require("@dxos/protocols");
190
- 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");
191
189
  var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
192
190
  var import_util6 = require("@dxos/util");
193
- var import_credentials13 = require("@dxos/credentials");
191
+ var import_credentials12 = require("@dxos/credentials");
194
192
  var import_debug4 = require("@dxos/debug");
195
- var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
193
+ var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
196
194
  var import_timeframe3 = require("@dxos/timeframe");
197
195
  var import_async14 = require("@dxos/async");
198
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
196
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
199
197
  var import_debug5 = require("@dxos/debug");
200
- var import_invariant13 = require("@dxos/invariant");
198
+ var import_invariant12 = require("@dxos/invariant");
201
199
  var import_log11 = require("@dxos/log");
202
- var import_protocols11 = require("@dxos/protocols");
203
- 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");
204
202
  var import_async15 = require("@dxos/async");
205
203
  var import_context10 = require("@dxos/context");
206
- var import_credentials15 = require("@dxos/credentials");
204
+ var import_credentials14 = require("@dxos/credentials");
207
205
  var import_debug6 = require("@dxos/debug");
208
- var import_echo_pipeline3 = require("@dxos/echo-pipeline");
206
+ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
209
207
  var import_feed_store4 = require("@dxos/feed-store");
210
208
  var import_indexing = require("@dxos/indexing");
211
- var import_invariant14 = require("@dxos/invariant");
209
+ var import_invariant13 = require("@dxos/invariant");
212
210
  var import_keyring = require("@dxos/keyring");
213
211
  var import_keys10 = require("@dxos/keys");
214
212
  var import_log12 = require("@dxos/log");
215
- var import_protocols12 = require("@dxos/protocols");
216
- 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");
217
215
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
218
- var import_tracing6 = require("@dxos/tracing");
216
+ var import_tracing5 = require("@dxos/tracing");
219
217
  var import_util7 = require("@dxos/util");
220
218
  var import_automerge = require("@dxos/automerge/automerge");
221
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");
222
224
  var import_protocols13 = require("@dxos/protocols");
223
- var import_invariant15 = require("@dxos/invariant");
224
- var import_lock_file = require("@dxos/lock-file");
225
- var import_log13 = require("@dxos/log");
226
- var import_client_protocol4 = require("@dxos/client-protocol");
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");
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");
230
231
  var import_util8 = require("@dxos/util");
231
232
  var import_async16 = require("@dxos/async");
232
- var import_client_protocol5 = require("@dxos/client-protocol");
233
+ var import_client_protocol4 = require("@dxos/client-protocol");
233
234
  var import_context11 = require("@dxos/context");
234
- var import_echo_pipeline4 = require("@dxos/echo-pipeline");
235
+ var import_echo_pipeline5 = require("@dxos/echo-pipeline");
235
236
  var E = __toESM(require("@dxos/echo-schema"));
236
- var import_echo_schema = require("@dxos/echo-schema");
237
237
  var import_indexing2 = require("@dxos/indexing");
238
- var import_invariant16 = require("@dxos/invariant");
238
+ var import_invariant15 = require("@dxos/invariant");
239
239
  var import_keys11 = require("@dxos/keys");
240
- var import_log14 = require("@dxos/log");
240
+ var import_log13 = require("@dxos/log");
241
241
  var import_messaging = require("@dxos/messaging");
242
242
  var import_network_manager2 = require("@dxos/network-manager");
243
- var import_protocols15 = require("@dxos/protocols");
244
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
245
- 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");
246
246
  var import_util9 = require("@dxos/util");
247
247
  var import_websocket_rpc = require("@dxos/websocket-rpc");
248
248
  var import_async17 = require("@dxos/async");
249
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");
250
252
  var import_invariant17 = require("@dxos/invariant");
251
- 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");
252
255
  var import_async18 = require("@dxos/async");
253
256
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
254
257
  var import_keys12 = require("@dxos/keys");
255
258
  var import_log15 = require("@dxos/log");
256
- var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
259
+ var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
257
260
  var import_util10 = require("@dxos/util");
258
261
  var import_codec_protobuf14 = require("@dxos/codec-protobuf");
259
- var import_codec_protobuf15 = require("@dxos/codec-protobuf");
260
- 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");
261
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");
262
276
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
263
277
  return new import_codec_protobuf.Stream(({ next }) => {
264
278
  const subscriptions = new import_async.EventSubscriptions();
@@ -1792,11 +1806,11 @@ var InvitationsHandler = class {
1792
1806
  this._networkManager = _networkManager;
1793
1807
  }
1794
1808
  createInvitation(protocol, options) {
1795
- 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 ?? {};
1796
1810
  const authCode = options?.authCode ?? (authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0);
1797
1811
  (0, import_invariant5.invariant)(protocol, void 0, {
1798
1812
  F: __dxlog_file7,
1799
- L: 84,
1813
+ L: 85,
1800
1814
  S: this,
1801
1815
  A: [
1802
1816
  "protocol",
@@ -1811,9 +1825,10 @@ var InvitationsHandler = class {
1811
1825
  swarmKey,
1812
1826
  authCode,
1813
1827
  timeout,
1814
- persistent,
1828
+ persistent: persistent && type !== import_services3.Invitation.Type.OFFLINE,
1815
1829
  created,
1816
1830
  lifetime,
1831
+ multiUse,
1817
1832
  ...protocol.getInvitationContext()
1818
1833
  };
1819
1834
  const stream = new import_async7.PushStream();
@@ -1828,7 +1843,7 @@ var InvitationsHandler = class {
1828
1843
  ...protocol.toJSON()
1829
1844
  }, {
1830
1845
  F: __dxlog_file7,
1831
- L: 109,
1846
+ L: 111,
1832
1847
  S: this,
1833
1848
  C: (f, a) => f(...a)
1834
1849
  });
@@ -1853,7 +1868,7 @@ var InvitationsHandler = class {
1853
1868
  const deviceKey = admissionRequest.device?.deviceKey ?? admissionRequest.space?.deviceKey;
1854
1869
  (0, import_invariant5.invariant)(deviceKey, void 0, {
1855
1870
  F: __dxlog_file7,
1856
- L: 130,
1871
+ L: 132,
1857
1872
  S: this,
1858
1873
  A: [
1859
1874
  "deviceKey",
@@ -1876,7 +1891,7 @@ var InvitationsHandler = class {
1876
1891
  id: traceId
1877
1892
  }), {
1878
1893
  F: __dxlog_file7,
1879
- L: 148,
1894
+ L: 150,
1880
1895
  S: this,
1881
1896
  C: (f, a) => f(...a)
1882
1897
  });
@@ -1884,7 +1899,7 @@ var InvitationsHandler = class {
1884
1899
  ...protocol.toJSON()
1885
1900
  }, {
1886
1901
  F: __dxlog_file7,
1887
- L: 149,
1902
+ L: 151,
1888
1903
  S: this,
1889
1904
  C: (f, a) => f(...a)
1890
1905
  });
@@ -1900,7 +1915,7 @@ var InvitationsHandler = class {
1900
1915
  ...protocol.toJSON()
1901
1916
  }, {
1902
1917
  F: __dxlog_file7,
1903
- L: 152,
1918
+ L: 154,
1904
1919
  S: this,
1905
1920
  C: (f, a) => f(...a)
1906
1921
  });
@@ -1912,7 +1927,7 @@ var InvitationsHandler = class {
1912
1927
  id: traceId
1913
1928
  }), {
1914
1929
  F: __dxlog_file7,
1915
- L: 154,
1930
+ L: 156,
1916
1931
  S: this,
1917
1932
  C: (f, a) => f(...a)
1918
1933
  });
@@ -1922,7 +1937,7 @@ var InvitationsHandler = class {
1922
1937
  ...protocol.toJSON()
1923
1938
  }, {
1924
1939
  F: __dxlog_file7,
1925
- L: 157,
1940
+ L: 159,
1926
1941
  S: this,
1927
1942
  C: (f, a) => f(...a)
1928
1943
  });
@@ -1933,7 +1948,7 @@ var InvitationsHandler = class {
1933
1948
  } else {
1934
1949
  import_log4.log.error("failed", err, {
1935
1950
  F: __dxlog_file7,
1936
- L: 160,
1951
+ L: 162,
1937
1952
  S: this,
1938
1953
  C: (f, a) => f(...a)
1939
1954
  });
@@ -1944,12 +1959,12 @@ var InvitationsHandler = class {
1944
1959
  error: err
1945
1960
  }), {
1946
1961
  F: __dxlog_file7,
1947
- L: 163,
1962
+ L: 165,
1948
1963
  S: this,
1949
1964
  C: (f, a) => f(...a)
1950
1965
  });
1951
1966
  } finally {
1952
- if (type !== import_services3.Invitation.Type.MULTIUSE) {
1967
+ if (!multiUse) {
1953
1968
  await swarmConnection.close();
1954
1969
  await ctx.dispose();
1955
1970
  }
@@ -1965,7 +1980,7 @@ var InvitationsHandler = class {
1965
1980
  ...protocol.toJSON()
1966
1981
  }, {
1967
1982
  F: __dxlog_file7,
1968
- L: 178,
1983
+ L: 180,
1969
1984
  S: this,
1970
1985
  C: (f, a) => f(...a)
1971
1986
  });
@@ -1976,7 +1991,7 @@ var InvitationsHandler = class {
1976
1991
  } else {
1977
1992
  import_log4.log.error("failed", err, {
1978
1993
  F: __dxlog_file7,
1979
- L: 181,
1994
+ L: 183,
1980
1995
  S: this,
1981
1996
  C: (f, a) => f(...a)
1982
1997
  });
@@ -1990,7 +2005,7 @@ var InvitationsHandler = class {
1990
2005
  if (invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now()) {
1991
2006
  import_log4.log.warn("invitation has already expired", void 0, {
1992
2007
  F: __dxlog_file7,
1993
- L: 192,
2008
+ L: 194,
1994
2009
  S: this,
1995
2010
  C: (f, a) => f(...a)
1996
2011
  });
@@ -2041,7 +2056,7 @@ var InvitationsHandler = class {
2041
2056
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
2042
2057
  (0, import_invariant5.invariant)(protocol, void 0, {
2043
2058
  F: __dxlog_file7,
2044
- L: 246,
2059
+ L: 248,
2045
2060
  S: this,
2046
2061
  A: [
2047
2062
  "protocol",
@@ -2051,7 +2066,7 @@ var InvitationsHandler = class {
2051
2066
  if (deviceProfile) {
2052
2067
  (0, import_invariant5.invariant)(invitation.kind === import_services3.Invitation.Kind.DEVICE, "deviceProfile provided for non-device invitation", {
2053
2068
  F: __dxlog_file7,
2054
- L: 250,
2069
+ L: 252,
2055
2070
  S: this,
2056
2071
  A: [
2057
2072
  "invitation.kind === Invitation.Kind.DEVICE",
@@ -2066,7 +2081,7 @@ var InvitationsHandler = class {
2066
2081
  const setState = (newData) => {
2067
2082
  (0, import_invariant5.invariant)(newData.state !== void 0, void 0, {
2068
2083
  F: __dxlog_file7,
2069
- L: 261,
2084
+ L: 263,
2070
2085
  S: this,
2071
2086
  A: [
2072
2087
  "newData.state !== undefined",
@@ -2086,7 +2101,7 @@ var InvitationsHandler = class {
2086
2101
  ...protocol.toJSON()
2087
2102
  }, {
2088
2103
  F: __dxlog_file7,
2089
- L: 269,
2104
+ L: 271,
2090
2105
  S: this,
2091
2106
  C: (f, a) => f(...a)
2092
2107
  });
@@ -2096,7 +2111,7 @@ var InvitationsHandler = class {
2096
2111
  } else {
2097
2112
  import_log4.log.warn("auth failed", err, {
2098
2113
  F: __dxlog_file7,
2099
- L: 272,
2114
+ L: 274,
2100
2115
  S: this,
2101
2116
  C: (f, a) => f(...a)
2102
2117
  });
@@ -2110,7 +2125,7 @@ var InvitationsHandler = class {
2110
2125
  ...protocol.toJSON()
2111
2126
  }, {
2112
2127
  F: __dxlog_file7,
2113
- L: 280,
2128
+ L: 282,
2114
2129
  S: this,
2115
2130
  C: (f, a) => f(...a)
2116
2131
  });
@@ -2125,7 +2140,7 @@ var InvitationsHandler = class {
2125
2140
  currentState
2126
2141
  }, {
2127
2142
  F: __dxlog_file7,
2128
- L: 290,
2143
+ L: 292,
2129
2144
  S: this,
2130
2145
  C: (f, a) => f(...a)
2131
2146
  });
@@ -2140,7 +2155,7 @@ var InvitationsHandler = class {
2140
2155
  id: traceId
2141
2156
  }), {
2142
2157
  F: __dxlog_file7,
2143
- L: 299,
2158
+ L: 301,
2144
2159
  S: this,
2145
2160
  C: (f, a) => f(...a)
2146
2161
  });
@@ -2152,7 +2167,7 @@ var InvitationsHandler = class {
2152
2167
  ...protocol.toJSON()
2153
2168
  }, {
2154
2169
  F: __dxlog_file7,
2155
- L: 307,
2170
+ L: 309,
2156
2171
  S: this,
2157
2172
  C: (f, a) => f(...a)
2158
2173
  });
@@ -2163,7 +2178,7 @@ var InvitationsHandler = class {
2163
2178
  ...protocol.toJSON()
2164
2179
  }, {
2165
2180
  F: __dxlog_file7,
2166
- L: 311,
2181
+ L: 313,
2167
2182
  S: this,
2168
2183
  C: (f, a) => f(...a)
2169
2184
  });
@@ -2173,7 +2188,7 @@ var InvitationsHandler = class {
2173
2188
  response: introductionResponse
2174
2189
  }, {
2175
2190
  F: __dxlog_file7,
2176
- L: 315,
2191
+ L: 317,
2177
2192
  S: this,
2178
2193
  C: (f, a) => f(...a)
2179
2194
  });
@@ -2182,7 +2197,7 @@ var InvitationsHandler = class {
2182
2197
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
2183
2198
  (0, import_log4.log)("guest waiting for authentication code...", void 0, {
2184
2199
  F: __dxlog_file7,
2185
- L: 321,
2200
+ L: 323,
2186
2201
  S: this,
2187
2202
  C: (f, a) => f(...a)
2188
2203
  });
@@ -2194,7 +2209,7 @@ var InvitationsHandler = class {
2194
2209
  });
2195
2210
  (0, import_log4.log)("sending authentication request", void 0, {
2196
2211
  F: __dxlog_file7,
2197
- L: 325,
2212
+ L: 327,
2198
2213
  S: this,
2199
2214
  C: (f, a) => f(...a)
2200
2215
  });
@@ -2215,7 +2230,7 @@ var InvitationsHandler = class {
2215
2230
  attempt
2216
2231
  }, {
2217
2232
  F: __dxlog_file7,
2218
- L: 336,
2233
+ L: 338,
2219
2234
  S: this,
2220
2235
  C: (f, a) => f(...a)
2221
2236
  });
@@ -2228,7 +2243,7 @@ var InvitationsHandler = class {
2228
2243
  ...protocol.toJSON()
2229
2244
  }, {
2230
2245
  F: __dxlog_file7,
2231
- L: 344,
2246
+ L: 346,
2232
2247
  S: this,
2233
2248
  C: (f, a) => f(...a)
2234
2249
  });
@@ -2240,7 +2255,7 @@ var InvitationsHandler = class {
2240
2255
  ...protocol.toJSON()
2241
2256
  }, {
2242
2257
  F: __dxlog_file7,
2243
- L: 355,
2258
+ L: 357,
2244
2259
  S: this,
2245
2260
  C: (f, a) => f(...a)
2246
2261
  });
@@ -2253,7 +2268,7 @@ var InvitationsHandler = class {
2253
2268
  id: traceId
2254
2269
  }), {
2255
2270
  F: __dxlog_file7,
2256
- L: 357,
2271
+ L: 359,
2257
2272
  S: this,
2258
2273
  C: (f, a) => f(...a)
2259
2274
  });
@@ -2263,7 +2278,7 @@ var InvitationsHandler = class {
2263
2278
  ...protocol.toJSON()
2264
2279
  }, {
2265
2280
  F: __dxlog_file7,
2266
- L: 360,
2281
+ L: 362,
2267
2282
  S: this,
2268
2283
  C: (f, a) => f(...a)
2269
2284
  });
@@ -2273,7 +2288,7 @@ var InvitationsHandler = class {
2273
2288
  } else {
2274
2289
  (0, import_log4.log)("auth failed", err, {
2275
2290
  F: __dxlog_file7,
2276
- L: 363,
2291
+ L: 365,
2277
2292
  S: this,
2278
2293
  C: (f, a) => f(...a)
2279
2294
  });
@@ -2284,7 +2299,7 @@ var InvitationsHandler = class {
2284
2299
  error: err
2285
2300
  }), {
2286
2301
  F: __dxlog_file7,
2287
- L: 366,
2302
+ L: 368,
2288
2303
  S: this,
2289
2304
  C: (f, a) => f(...a)
2290
2305
  });
@@ -2302,7 +2317,7 @@ var InvitationsHandler = class {
2302
2317
  ...protocol.toJSON()
2303
2318
  }, {
2304
2319
  F: __dxlog_file7,
2305
- L: 377,
2320
+ L: 379,
2306
2321
  S: this,
2307
2322
  C: (f, a) => f(...a)
2308
2323
  });
@@ -2312,7 +2327,7 @@ var InvitationsHandler = class {
2312
2327
  } else {
2313
2328
  (0, import_log4.log)("auth failed", err, {
2314
2329
  F: __dxlog_file7,
2315
- L: 380,
2330
+ L: 382,
2316
2331
  S: this,
2317
2332
  C: (f, a) => f(...a)
2318
2333
  });
@@ -2329,7 +2344,7 @@ var InvitationsHandler = class {
2329
2344
  } else {
2330
2345
  (0, import_invariant5.invariant)(invitation.swarmKey, void 0, {
2331
2346
  F: __dxlog_file7,
2332
- L: 394,
2347
+ L: 396,
2333
2348
  S: this,
2334
2349
  A: [
2335
2350
  "invitation.swarmKey",
@@ -2368,9 +2383,6 @@ var InvitationsHandler = class {
2368
2383
  return observable;
2369
2384
  }
2370
2385
  };
2371
- var invitationExpired = (invitation) => {
2372
- return invitation.created && invitation.lifetime && invitation.lifetime !== 0 && invitation.created.getTime() + invitation.lifetime * 1e3 < Date.now();
2373
- };
2374
2386
  var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
2375
2387
  var InvitationsServiceImpl = class {
2376
2388
  constructor(_invitationsHandler, _getHandler, _metadataStore) {
@@ -2426,7 +2438,7 @@ var InvitationsServiceImpl = class {
2426
2438
  await this._metadataStore.removeInvitation(invitation.get().invitationId);
2427
2439
  }
2428
2440
  this._createInvitations.delete(invitation.get().invitationId);
2429
- if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
2441
+ if (!invitation.get().multiUse) {
2430
2442
  this._removedCreated.emit(invitation.get());
2431
2443
  }
2432
2444
  });
@@ -2434,7 +2446,7 @@ var InvitationsServiceImpl = class {
2434
2446
  }
2435
2447
  async loadPersistentInvitations() {
2436
2448
  const persistentInvitations = this._metadataStore.getInvitations();
2437
- const freshInvitations = persistentInvitations.filter(async (invitation) => !invitationExpired(invitation));
2449
+ const freshInvitations = persistentInvitations.filter(async (invitation) => !(0, import_echo_pipeline.hasInvitationExpired)(invitation));
2438
2450
  const cInvitations = freshInvitations.map((persistentInvitation) => {
2439
2451
  (0, import_invariant7.invariant)(!this._createInvitations.get(persistentInvitation.invitationId), "invitation already exists", {
2440
2452
  F: __dxlog_file8,
@@ -2487,7 +2499,7 @@ var InvitationsServiceImpl = class {
2487
2499
  }, () => {
2488
2500
  close();
2489
2501
  this._acceptInvitations.delete(invitation.get().invitationId);
2490
- if (invitation.get().type !== import_services5.Invitation.Type.MULTIUSE) {
2502
+ if (!invitation.get().multiUse) {
2491
2503
  this._removedAccepted.emit(invitation.get());
2492
2504
  }
2493
2505
  });
@@ -2860,141 +2872,6 @@ _ts_decorate3([
2860
2872
  ClientRpcServer = _ts_decorate3([
2861
2873
  import_tracing3.trace.resource()
2862
2874
  ], ClientRpcServer);
2863
- var getPlatform = () => {
2864
- if (process.browser) {
2865
- if (typeof window !== "undefined") {
2866
- const { userAgent } = window.navigator;
2867
- return {
2868
- type: import_services8.Platform.PLATFORM_TYPE.BROWSER,
2869
- userAgent,
2870
- uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
2871
- };
2872
- } else {
2873
- return {
2874
- type: import_services8.Platform.PLATFORM_TYPE.SHARED_WORKER,
2875
- uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
2876
- };
2877
- }
2878
- } else {
2879
- const { platform: platform2, version, arch } = process;
2880
- return {
2881
- type: import_services8.Platform.PLATFORM_TYPE.NODE,
2882
- platform: platform2,
2883
- arch,
2884
- runtime: version,
2885
- uptime: Math.floor(process.uptime()),
2886
- memory: process.memoryUsage()
2887
- };
2888
- }
2889
- };
2890
- var DXOS_VERSION = "0.4.10-main.7ce71da";
2891
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2892
- var DEFAULT_TIMEOUT = 1e3;
2893
- var createDiagnostics = async (clientServices, serviceContext, config) => {
2894
- const diagnostics = {
2895
- created: (/* @__PURE__ */ new Date()).toISOString(),
2896
- platform: getPlatform(),
2897
- client: {
2898
- version: DXOS_VERSION,
2899
- storage: {
2900
- version: import_protocols7.STORAGE_VERSION
2901
- }
2902
- },
2903
- trace: import_tracing4.TRACE_PROCESSOR.getDiagnostics()
2904
- };
2905
- {
2906
- (0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
2907
- F: __dxlog_file10,
2908
- L: 108,
2909
- S: void 0,
2910
- A: [
2911
- "clientServices.LoggingService",
2912
- "'SystemService is not available.'"
2913
- ]
2914
- });
2915
- diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
2916
- timeout: DEFAULT_TIMEOUT
2917
- }).catch(() => void 0);
2918
- }
2919
- if (typeof navigator !== "undefined" && navigator.storage) {
2920
- const map = /* @__PURE__ */ new Map();
2921
- const dir = await navigator.storage.getDirectory();
2922
- for await (const filename of dir?.keys()) {
2923
- const idx = filename.indexOf("-", filename.indexOf("-") + 1);
2924
- if (idx === -1) {
2925
- continue;
2926
- }
2927
- map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
2928
- }
2929
- diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
2930
- file,
2931
- count
2932
- }));
2933
- }
2934
- const identity = serviceContext.identityManager.identity;
2935
- if (identity) {
2936
- diagnostics.identity = {
2937
- identityKey: identity.identityKey,
2938
- spaceKey: identity.space.key,
2939
- profile: identity.profileDocument
2940
- };
2941
- const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
2942
- timeout: DEFAULT_TIMEOUT
2943
- }).catch(() => void 0) ?? {};
2944
- diagnostics.devices = devices;
2945
- if (serviceContext.dataSpaceManager) {
2946
- diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
2947
- }
2948
- const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
2949
- timeout: DEFAULT_TIMEOUT
2950
- }).catch(() => void 0) ?? {};
2951
- diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
2952
- feedKey,
2953
- bytes,
2954
- length
2955
- }));
2956
- const status = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
2957
- timeout: DEFAULT_TIMEOUT
2958
- }).catch(() => void 0);
2959
- diagnostics.networkStatus = status;
2960
- diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
2961
- }
2962
- diagnostics.config = config.values;
2963
- return diagnostics;
2964
- };
2965
- var getSpaceStats = async (space) => {
2966
- const stats = {
2967
- key: space.key,
2968
- metrics: space.metrics,
2969
- epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
2970
- ...credential.subject.assertion,
2971
- id: credential.id
2972
- })),
2973
- members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
2974
- identity: {
2975
- identityKey: member.key,
2976
- profile: {
2977
- displayName: member.assertion.profile?.displayName
2978
- }
2979
- },
2980
- presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE
2981
- })),
2982
- pipeline: {
2983
- // TODO(burdon): Pick properties from credentials if needed.
2984
- currentEpoch: space.automergeSpaceState.lastEpoch,
2985
- appliedEpoch: space.automergeSpaceState.lastEpoch,
2986
- controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
2987
- currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
2988
- targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
2989
- totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
2990
- }
2991
- };
2992
- if (stats.metrics) {
2993
- const { open, ready } = stats.metrics;
2994
- stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
2995
- }
2996
- return stats;
2997
- };
2998
2875
  var AutomergeSpaceState = class {
2999
2876
  constructor(_onNewRoot) {
3000
2877
  this._onNewRoot = _onNewRoot;
@@ -3004,7 +2881,7 @@ var AutomergeSpaceState = class {
3004
2881
  this._isProcessingRootDocs = false;
3005
2882
  }
3006
2883
  async processCredential(credential) {
3007
- if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
2884
+ if (!(0, import_credentials10.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
3008
2885
  return;
3009
2886
  }
3010
2887
  this.lastEpoch = credential;
@@ -3029,7 +2906,7 @@ var AutomergeSpaceState = class {
3029
2906
  await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
3030
2907
  }
3031
2908
  };
3032
- 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";
3033
2910
  var DEFAULT_RETRY_TIMEOUT = 1e3;
3034
2911
  var DEFAULT_SUCCESS_DELAY = 1e3;
3035
2912
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -3057,13 +2934,13 @@ var NotarizationPlugin = class {
3057
2934
  (0, import_log9.log)("notarize", {
3058
2935
  credentials
3059
2936
  }, {
3060
- F: __dxlog_file11,
2937
+ F: __dxlog_file10,
3061
2938
  L: 90,
3062
2939
  S: this,
3063
2940
  C: (f, a) => f(...a)
3064
2941
  });
3065
- (0, import_invariant11.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
3066
- F: __dxlog_file11,
2942
+ (0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
2943
+ F: __dxlog_file10,
3067
2944
  L: 91,
3068
2945
  S: this,
3069
2946
  A: [
@@ -3077,7 +2954,7 @@ var NotarizationPlugin = class {
3077
2954
  import_log9.log.warn("Notarization error", {
3078
2955
  err
3079
2956
  }, {
3080
- F: __dxlog_file11,
2957
+ F: __dxlog_file10,
3081
2958
  L: 99,
3082
2959
  S: this,
3083
2960
  C: (f, a) => f(...a)
@@ -3093,7 +2970,7 @@ var NotarizationPlugin = class {
3093
2970
  timeout,
3094
2971
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
3095
2972
  }, {
3096
- F: __dxlog_file11,
2973
+ F: __dxlog_file10,
3097
2974
  L: 111,
3098
2975
  S: this,
3099
2976
  C: (f, a) => f(...a)
@@ -3116,7 +2993,7 @@ var NotarizationPlugin = class {
3116
2993
  import_log9.log.info("Exhausted all peers to notarize with", {
3117
2994
  retryIn: retryTimeout
3118
2995
  }, {
3119
- F: __dxlog_file11,
2996
+ F: __dxlog_file10,
3120
2997
  L: 136,
3121
2998
  S: this,
3122
2999
  C: (f, a) => f(...a)
@@ -3130,7 +3007,7 @@ var NotarizationPlugin = class {
3130
3007
  peer: peer.localPeerId,
3131
3008
  credentialId: credentials.map((credential) => credential.id)
3132
3009
  }, {
3133
- F: __dxlog_file11,
3010
+ F: __dxlog_file10,
3134
3011
  L: 143,
3135
3012
  S: this,
3136
3013
  C: (f, a) => f(...a)
@@ -3139,7 +3016,7 @@ var NotarizationPlugin = class {
3139
3016
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
3140
3017
  });
3141
3018
  (0, import_log9.log)("success", void 0, {
3142
- F: __dxlog_file11,
3019
+ F: __dxlog_file10,
3143
3020
  L: 147,
3144
3021
  S: this,
3145
3022
  C: (f, a) => f(...a)
@@ -3148,7 +3025,7 @@ var NotarizationPlugin = class {
3148
3025
  } catch (err) {
3149
3026
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
3150
3027
  import_log9.log.info("error notarizing (recoverable)", err, {
3151
- F: __dxlog_file11,
3028
+ F: __dxlog_file10,
3152
3029
  L: 151,
3153
3030
  S: this,
3154
3031
  C: (f, a) => f(...a)
@@ -3166,7 +3043,7 @@ var NotarizationPlugin = class {
3166
3043
  errors.wait()
3167
3044
  ]);
3168
3045
  (0, import_log9.log)("done", void 0, {
3169
- F: __dxlog_file11,
3046
+ F: __dxlog_file10,
3170
3047
  L: 162,
3171
3048
  S: this,
3172
3049
  C: (f, a) => f(...a)
@@ -3187,8 +3064,8 @@ var NotarizationPlugin = class {
3187
3064
  this._processCredentialsTriggers.delete(credential.id);
3188
3065
  }
3189
3066
  setWriter(writer) {
3190
- (0, import_invariant11.invariant)(!this._writer, "Writer already set.", {
3191
- F: __dxlog_file11,
3067
+ (0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
3068
+ F: __dxlog_file10,
3192
3069
  L: 181,
3193
3070
  S: this,
3194
3071
  A: [
@@ -3212,8 +3089,8 @@ var NotarizationPlugin = class {
3212
3089
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
3213
3090
  }
3214
3091
  for (const credential of request.credentials ?? []) {
3215
- (0, import_invariant11.invariant)(credential.id, "Credential must have an id", {
3216
- F: __dxlog_file11,
3092
+ (0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
3093
+ F: __dxlog_file10,
3217
3094
  L: 200,
3218
3095
  S: this,
3219
3096
  A: [
@@ -3233,7 +3110,7 @@ var NotarizationPlugin = class {
3233
3110
  (0, import_log9.log)("extension opened", {
3234
3111
  peer: extension.localPeerId
3235
3112
  }, {
3236
- F: __dxlog_file11,
3113
+ F: __dxlog_file10,
3237
3114
  L: 211,
3238
3115
  S: this,
3239
3116
  C: (f, a) => f(...a)
@@ -3245,7 +3122,7 @@ var NotarizationPlugin = class {
3245
3122
  (0, import_log9.log)("extension closed", {
3246
3123
  peer: extension.localPeerId
3247
3124
  }, {
3248
- F: __dxlog_file11,
3125
+ F: __dxlog_file10,
3249
3126
  L: 216,
3250
3127
  S: this,
3251
3128
  C: (f, a) => f(...a)
@@ -3261,10 +3138,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
3261
3138
  constructor(_params) {
3262
3139
  super({
3263
3140
  requested: {
3264
- NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3141
+ NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3265
3142
  },
3266
3143
  exposed: {
3267
- NotarizationService: import_protocols9.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3144
+ NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
3268
3145
  }
3269
3146
  });
3270
3147
  this._params = _params;
@@ -3297,14 +3174,14 @@ function _ts_decorate4(decorators, target, key, desc) {
3297
3174
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3298
3175
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3299
3176
  }
3300
- 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";
3301
3178
  var DataSpace = class {
3302
3179
  constructor(params) {
3303
3180
  this._ctx = new import_context7.Context();
3304
3181
  this._notarizationPlugin = new NotarizationPlugin();
3305
3182
  this._cache = void 0;
3306
3183
  this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
3307
- this._state = import_services9.SpaceState.CLOSED;
3184
+ this._state = import_services7.SpaceState.CLOSED;
3308
3185
  this.error = void 0;
3309
3186
  this.stateUpdate = new import_async10.Event();
3310
3187
  this.metrics = {};
@@ -3326,9 +3203,9 @@ var DataSpace = class {
3326
3203
  this._cache = params.cache;
3327
3204
  this._state = params.initialState;
3328
3205
  (0, import_log8.log)("new state", {
3329
- state: import_services9.SpaceState[this._state]
3206
+ state: import_services7.SpaceState[this._state]
3330
3207
  }, {
3331
- F: __dxlog_file12,
3208
+ F: __dxlog_file11,
3332
3209
  L: 140,
3333
3210
  S: this,
3334
3211
  C: (f, a) => f(...a)
@@ -3374,11 +3251,11 @@ var DataSpace = class {
3374
3251
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
3375
3252
  await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
3376
3253
  await this._inner.open(new import_context7.Context());
3377
- this._state = import_services9.SpaceState.CONTROL_ONLY;
3254
+ this._state = import_services7.SpaceState.CONTROL_ONLY;
3378
3255
  (0, import_log8.log)("new state", {
3379
- state: import_services9.SpaceState[this._state]
3256
+ state: import_services7.SpaceState[this._state]
3380
3257
  }, {
3381
- F: __dxlog_file12,
3258
+ F: __dxlog_file11,
3382
3259
  L: 198,
3383
3260
  S: this,
3384
3261
  C: (f, a) => f(...a)
@@ -3392,11 +3269,11 @@ var DataSpace = class {
3392
3269
  }
3393
3270
  async _close() {
3394
3271
  await this._callbacks.beforeClose?.();
3395
- this._state = import_services9.SpaceState.CLOSED;
3272
+ this._state = import_services7.SpaceState.CLOSED;
3396
3273
  (0, import_log8.log)("new state", {
3397
- state: import_services9.SpaceState[this._state]
3274
+ state: import_services7.SpaceState[this._state]
3398
3275
  }, {
3399
- F: __dxlog_file12,
3276
+ F: __dxlog_file11,
3400
3277
  L: 212,
3401
3278
  S: this,
3402
3279
  C: (f, a) => f(...a)
@@ -3426,9 +3303,9 @@ var DataSpace = class {
3426
3303
  this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
3427
3304
  await this.initializeDataPipeline();
3428
3305
  } catch (err) {
3429
- if (err instanceof import_protocols8.CancelledError || err instanceof import_context7.ContextDisposedError) {
3306
+ if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
3430
3307
  (0, import_log8.log)("data pipeline initialization cancelled", err, {
3431
- F: __dxlog_file12,
3308
+ F: __dxlog_file11,
3432
3309
  L: 245,
3433
3310
  S: this,
3434
3311
  C: (f, a) => f(...a)
@@ -3436,16 +3313,16 @@ var DataSpace = class {
3436
3313
  return;
3437
3314
  }
3438
3315
  import_log8.log.error("Error initializing data pipeline", err, {
3439
- F: __dxlog_file12,
3316
+ F: __dxlog_file11,
3440
3317
  L: 249,
3441
3318
  S: this,
3442
3319
  C: (f, a) => f(...a)
3443
3320
  });
3444
- this._state = import_services9.SpaceState.ERROR;
3321
+ this._state = import_services7.SpaceState.ERROR;
3445
3322
  (0, import_log8.log)("new state", {
3446
- state: import_services9.SpaceState[this._state]
3323
+ state: import_services7.SpaceState[this._state]
3447
3324
  }, {
3448
- F: __dxlog_file12,
3325
+ F: __dxlog_file11,
3449
3326
  L: 251,
3450
3327
  S: this,
3451
3328
  C: (f, a) => f(...a)
@@ -3458,14 +3335,14 @@ var DataSpace = class {
3458
3335
  });
3459
3336
  }
3460
3337
  async initializeDataPipeline() {
3461
- if (this._state !== import_services9.SpaceState.CONTROL_ONLY) {
3462
- throw new import_protocols8.SystemError("Invalid operation");
3338
+ if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
3339
+ throw new import_protocols7.SystemError("Invalid operation");
3463
3340
  }
3464
- this._state = import_services9.SpaceState.INITIALIZING;
3341
+ this._state = import_services7.SpaceState.INITIALIZING;
3465
3342
  (0, import_log8.log)("new state", {
3466
- state: import_services9.SpaceState[this._state]
3343
+ state: import_services7.SpaceState[this._state]
3467
3344
  }, {
3468
- F: __dxlog_file12,
3345
+ F: __dxlog_file11,
3469
3346
  L: 267,
3470
3347
  S: this,
3471
3348
  C: (f, a) => f(...a)
@@ -3475,17 +3352,17 @@ var DataSpace = class {
3475
3352
  this._automergeSpaceState.startProcessingRootDocs();
3476
3353
  await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
3477
3354
  (0, import_log8.log)("data pipeline ready", void 0, {
3478
- F: __dxlog_file12,
3355
+ F: __dxlog_file11,
3479
3356
  L: 279,
3480
3357
  S: this,
3481
3358
  C: (f, a) => f(...a)
3482
3359
  });
3483
3360
  await this._callbacks.beforeReady?.();
3484
- this._state = import_services9.SpaceState.READY;
3361
+ this._state = import_services7.SpaceState.READY;
3485
3362
  (0, import_log8.log)("new state", {
3486
- state: import_services9.SpaceState[this._state]
3363
+ state: import_services7.SpaceState[this._state]
3487
3364
  }, {
3488
- F: __dxlog_file12,
3365
+ F: __dxlog_file11,
3489
3366
  L: 283,
3490
3367
  S: this,
3491
3368
  C: (f, a) => f(...a)
@@ -3501,14 +3378,14 @@ var DataSpace = class {
3501
3378
  this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
3502
3379
  await this._createWritableFeeds();
3503
3380
  (0, import_log8.log)("writable feeds created", void 0, {
3504
- F: __dxlog_file12,
3381
+ F: __dxlog_file11,
3505
3382
  L: 299,
3506
3383
  S: this,
3507
3384
  C: (f, a) => f(...a)
3508
3385
  });
3509
3386
  this.stateUpdate.emit();
3510
3387
  if (!this.notarizationPlugin.hasWriter) {
3511
- this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
3388
+ this.notarizationPlugin.setWriter((0, import_echo_pipeline2.createMappedFeedWriter)((credential) => ({
3512
3389
  credential: {
3513
3390
  credential
3514
3391
  }
@@ -3529,7 +3406,7 @@ var DataSpace = class {
3529
3406
  spaceKey: this.key,
3530
3407
  deviceKey: this._signingContext.deviceKey,
3531
3408
  identityKey: this._signingContext.identityKey,
3532
- designation: import_credentials10.AdmittedFeed.Designation.CONTROL
3409
+ designation: import_credentials9.AdmittedFeed.Designation.CONTROL
3533
3410
  }
3534
3411
  }));
3535
3412
  }
@@ -3546,7 +3423,7 @@ var DataSpace = class {
3546
3423
  spaceKey: this.key,
3547
3424
  deviceKey: this._signingContext.deviceKey,
3548
3425
  identityKey: this._signingContext.identityKey,
3549
- designation: import_credentials10.AdmittedFeed.Designation.DATA
3426
+ designation: import_credentials9.AdmittedFeed.Designation.DATA
3550
3427
  }
3551
3428
  }));
3552
3429
  }
@@ -3564,7 +3441,7 @@ var DataSpace = class {
3564
3441
  space: this.key,
3565
3442
  rootUrl
3566
3443
  }, {
3567
- F: __dxlog_file12,
3444
+ F: __dxlog_file11,
3568
3445
  L: 365,
3569
3446
  S: this,
3570
3447
  C: (f, a) => f(...a)
@@ -3579,7 +3456,7 @@ var DataSpace = class {
3579
3456
  if (this._ctx.disposed) {
3580
3457
  return;
3581
3458
  }
3582
- const doc = handle.docSync() ?? (0, import_invariant10.failedInvariant)();
3459
+ const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
3583
3460
  if (!doc.access?.spaceKey) {
3584
3461
  handle.change((doc2) => {
3585
3462
  doc2.access = {
@@ -3596,7 +3473,7 @@ var DataSpace = class {
3596
3473
  rootUrl,
3597
3474
  err
3598
3475
  }, {
3599
- F: __dxlog_file12,
3476
+ F: __dxlog_file11,
3600
3477
  L: 388,
3601
3478
  S: this,
3602
3479
  C: (f, a) => f(...a)
@@ -3623,7 +3500,7 @@ var DataSpace = class {
3623
3500
  let epoch;
3624
3501
  switch (options?.migration) {
3625
3502
  case void 0:
3626
- case import_services9.CreateEpochRequest.Migration.NONE:
3503
+ case import_services7.CreateEpochRequest.Migration.NONE:
3627
3504
  {
3628
3505
  epoch = {
3629
3506
  previousId: this._automergeSpaceState.lastEpoch?.id,
@@ -3633,7 +3510,7 @@ var DataSpace = class {
3633
3510
  };
3634
3511
  }
3635
3512
  break;
3636
- case import_services9.CreateEpochRequest.Migration.INIT_AUTOMERGE:
3513
+ case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE:
3637
3514
  {
3638
3515
  const document = this._automergeHost.repo.create();
3639
3516
  epoch = {
@@ -3644,14 +3521,14 @@ var DataSpace = class {
3644
3521
  };
3645
3522
  }
3646
3523
  break;
3647
- case import_services9.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3524
+ case import_services7.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
3648
3525
  {
3649
3526
  const currentRootUrl = this._automergeSpaceState.rootUrl;
3650
3527
  const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3651
3528
  await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
3652
3529
  const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
3653
- (0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3654
- F: __dxlog_file12,
3530
+ (0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3531
+ F: __dxlog_file11,
3655
3532
  L: 438,
3656
3533
  S: this,
3657
3534
  A: [
@@ -3667,10 +3544,10 @@ var DataSpace = class {
3667
3544
  };
3668
3545
  }
3669
3546
  break;
3670
- case import_services9.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3547
+ case import_services7.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3671
3548
  {
3672
3549
  import_log8.log.info("Fragmenting", void 0, {
3673
- F: __dxlog_file12,
3550
+ F: __dxlog_file11,
3674
3551
  L: 450,
3675
3552
  S: this,
3676
3553
  C: (f, a) => f(...a)
@@ -3681,8 +3558,8 @@ var DataSpace = class {
3681
3558
  const objects = Object.entries(rootHandle.docSync().objects);
3682
3559
  const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_db.TYPE_PROPERTIES);
3683
3560
  const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3684
- (0, import_invariant10.invariant)(properties, "Properties not found", {
3685
- F: __dxlog_file12,
3561
+ (0, import_invariant9.invariant)(properties, "Properties not found", {
3562
+ F: __dxlog_file11,
3686
3563
  L: 460,
3687
3564
  S: this,
3688
3565
  A: [
@@ -3697,8 +3574,8 @@ var DataSpace = class {
3697
3574
  ])
3698
3575
  };
3699
3576
  const newRoot = this._automergeHost.repo.create(newSpaceDoc);
3700
- (0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3701
- F: __dxlog_file12,
3577
+ (0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3578
+ F: __dxlog_file11,
3702
3579
  L: 465,
3703
3580
  S: this,
3704
3581
  A: [
@@ -3706,7 +3583,7 @@ var DataSpace = class {
3706
3583
  ""
3707
3584
  ]
3708
3585
  });
3709
- 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);
3710
3587
  await docLoader.loadSpaceRootDocHandle(this._ctx, {
3711
3588
  rootUrl: newRoot.url
3712
3589
  });
@@ -3750,24 +3627,24 @@ var DataSpace = class {
3750
3627
  ]));
3751
3628
  }
3752
3629
  async activate() {
3753
- if (this._state !== import_services9.SpaceState.INACTIVE) {
3630
+ if (this._state !== import_services7.SpaceState.INACTIVE) {
3754
3631
  return;
3755
3632
  }
3756
- await this._metadataStore.setSpaceState(this.key, import_services9.SpaceState.ACTIVE);
3633
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
3757
3634
  await this._open();
3758
3635
  this.initializeDataPipelineAsync();
3759
3636
  }
3760
3637
  async deactivate() {
3761
- if (this._state === import_services9.SpaceState.INACTIVE) {
3638
+ if (this._state === import_services7.SpaceState.INACTIVE) {
3762
3639
  return;
3763
3640
  }
3764
- await this._metadataStore.setSpaceState(this.key, import_services9.SpaceState.INACTIVE);
3641
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
3765
3642
  await this._close();
3766
- this._state = import_services9.SpaceState.INACTIVE;
3643
+ this._state = import_services7.SpaceState.INACTIVE;
3767
3644
  (0, import_log8.log)("new state", {
3768
- state: import_services9.SpaceState[this._state]
3645
+ state: import_services7.SpaceState[this._state]
3769
3646
  }, {
3770
- F: __dxlog_file12,
3647
+ F: __dxlog_file11,
3771
3648
  L: 531,
3772
3649
  S: this,
3773
3650
  C: (f, a) => f(...a)
@@ -3776,18 +3653,18 @@ var DataSpace = class {
3776
3653
  }
3777
3654
  };
3778
3655
  _ts_decorate4([
3779
- import_tracing5.trace.info()
3656
+ import_tracing4.trace.info()
3780
3657
  ], DataSpace.prototype, "_inner", void 0);
3781
3658
  _ts_decorate4([
3782
- import_tracing5.trace.info()
3659
+ import_tracing4.trace.info()
3783
3660
  ], DataSpace.prototype, "key", null);
3784
3661
  _ts_decorate4([
3785
- import_tracing5.trace.info({
3786
- enum: import_services9.SpaceState
3662
+ import_tracing4.trace.info({
3663
+ enum: import_services7.SpaceState
3787
3664
  })
3788
3665
  ], DataSpace.prototype, "state", null);
3789
3666
  _ts_decorate4([
3790
- import_tracing5.trace.info({
3667
+ import_tracing4.trace.info({
3791
3668
  depth: null
3792
3669
  })
3793
3670
  ], DataSpace.prototype, "_automergeInfo", null);
@@ -3798,12 +3675,12 @@ _ts_decorate4([
3798
3675
  import_async10.synchronized
3799
3676
  ], DataSpace.prototype, "close", null);
3800
3677
  _ts_decorate4([
3801
- import_tracing5.trace.span({
3678
+ import_tracing4.trace.span({
3802
3679
  showInBrowserTimeline: true
3803
3680
  })
3804
3681
  ], DataSpace.prototype, "initializeDataPipeline", null);
3805
3682
  _ts_decorate4([
3806
- import_tracing5.trace.span({
3683
+ import_tracing4.trace.span({
3807
3684
  showInBrowserTimeline: true
3808
3685
  })
3809
3686
  ], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
@@ -3818,11 +3695,11 @@ _ts_decorate4([
3818
3695
  ], DataSpace.prototype, "deactivate", null);
3819
3696
  DataSpace = _ts_decorate4([
3820
3697
  (0, import_async10.trackLeaks)("open", "close"),
3821
- import_tracing5.trace.resource()
3698
+ import_tracing4.trace.resource()
3822
3699
  ], DataSpace);
3823
3700
  var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3824
3701
  const credentials = [
3825
- await (0, import_credentials13.createCredential)({
3702
+ await (0, import_credentials12.createCredential)({
3826
3703
  signer: keyring,
3827
3704
  issuer: space.key,
3828
3705
  subject: space.key,
@@ -3831,14 +3708,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3831
3708
  spaceKey: space.key
3832
3709
  }
3833
3710
  }),
3834
- await (0, import_credentials13.createCredential)({
3711
+ await (0, import_credentials12.createCredential)({
3835
3712
  signer: keyring,
3836
3713
  issuer: space.key,
3837
3714
  subject: signingContext.identityKey,
3838
3715
  assertion: {
3839
3716
  "@type": "dxos.halo.credentials.SpaceMember",
3840
3717
  spaceKey: space.key,
3841
- role: import_credentials14.SpaceMember.Role.ADMIN,
3718
+ role: import_credentials13.SpaceMember.Role.ADMIN,
3842
3719
  profile: signingContext.getProfile(),
3843
3720
  genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
3844
3721
  }
@@ -3850,7 +3727,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3850
3727
  spaceKey: space.key,
3851
3728
  identityKey: signingContext.identityKey,
3852
3729
  deviceKey: signingContext.deviceKey,
3853
- designation: import_credentials14.AdmittedFeed.Designation.CONTROL
3730
+ designation: import_credentials13.AdmittedFeed.Designation.CONTROL
3854
3731
  }
3855
3732
  }),
3856
3733
  await signingContext.credentialSigner.createCredential({
@@ -3860,7 +3737,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
3860
3737
  spaceKey: space.key,
3861
3738
  identityKey: signingContext.identityKey,
3862
3739
  deviceKey: signingContext.deviceKey,
3863
- designation: import_credentials14.AdmittedFeed.Designation.DATA
3740
+ designation: import_credentials13.AdmittedFeed.Designation.DATA
3864
3741
  }
3865
3742
  }),
3866
3743
  await signingContext.credentialSigner.createCredential({
@@ -3894,7 +3771,7 @@ function _ts_decorate5(decorators, target, key, desc) {
3894
3771
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3895
3772
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3896
3773
  }
3897
- 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";
3898
3775
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3899
3776
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3900
3777
  var DataSpaceManager = class {
@@ -3920,15 +3797,15 @@ var DataSpaceManager = class {
3920
3797
  }
3921
3798
  async open() {
3922
3799
  (0, import_log10.log)("open", void 0, {
3923
- F: __dxlog_file13,
3800
+ F: __dxlog_file12,
3924
3801
  L: 98,
3925
3802
  S: this,
3926
3803
  C: (f, a) => f(...a)
3927
3804
  });
3928
- 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({
3929
3806
  id: this._instanceId
3930
3807
  }), {
3931
- F: __dxlog_file13,
3808
+ F: __dxlog_file12,
3932
3809
  L: 99,
3933
3810
  S: this,
3934
3811
  C: (f, a) => f(...a)
@@ -3936,7 +3813,7 @@ var DataSpaceManager = class {
3936
3813
  (0, import_log10.log)("metadata loaded", {
3937
3814
  spaces: this._metadataStore.spaces.length
3938
3815
  }, {
3939
- F: __dxlog_file13,
3816
+ F: __dxlog_file12,
3940
3817
  L: 100,
3941
3818
  S: this,
3942
3819
  C: (f, a) => f(...a)
@@ -3946,7 +3823,7 @@ var DataSpaceManager = class {
3946
3823
  (0, import_log10.log)("load space", {
3947
3824
  spaceMetadata
3948
3825
  }, {
3949
- F: __dxlog_file13,
3826
+ F: __dxlog_file12,
3950
3827
  L: 104,
3951
3828
  S: this,
3952
3829
  C: (f, a) => f(...a)
@@ -3957,7 +3834,7 @@ var DataSpaceManager = class {
3957
3834
  spaceMetadata,
3958
3835
  err
3959
3836
  }, {
3960
- F: __dxlog_file13,
3837
+ F: __dxlog_file12,
3961
3838
  L: 107,
3962
3839
  S: this,
3963
3840
  C: (f, a) => f(...a)
@@ -3967,14 +3844,14 @@ var DataSpaceManager = class {
3967
3844
  this._isOpen = true;
3968
3845
  this.updated.emit();
3969
3846
  for (const space of this._spaces.values()) {
3970
- if (space.state !== import_services10.SpaceState.INACTIVE) {
3847
+ if (space.state !== import_services8.SpaceState.INACTIVE) {
3971
3848
  space.initializeDataPipelineAsync();
3972
3849
  }
3973
3850
  }
3974
- 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({
3975
3852
  id: this._instanceId
3976
3853
  }), {
3977
- F: __dxlog_file13,
3854
+ F: __dxlog_file12,
3978
3855
  L: 120,
3979
3856
  S: this,
3980
3857
  C: (f, a) => f(...a)
@@ -3982,7 +3859,7 @@ var DataSpaceManager = class {
3982
3859
  }
3983
3860
  async close() {
3984
3861
  (0, import_log10.log)("close", void 0, {
3985
- F: __dxlog_file13,
3862
+ F: __dxlog_file12,
3986
3863
  L: 125,
3987
3864
  S: this,
3988
3865
  C: (f, a) => f(...a)
@@ -3997,8 +3874,8 @@ var DataSpaceManager = class {
3997
3874
  * Creates a new space writing the genesis credentials to the control feed.
3998
3875
  */
3999
3876
  async createSpace() {
4000
- (0, import_invariant12.invariant)(this._isOpen, "Not open.", {
4001
- F: __dxlog_file13,
3877
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3878
+ F: __dxlog_file12,
4002
3879
  L: 138,
4003
3880
  S: this,
4004
3881
  A: [
@@ -4014,12 +3891,12 @@ var DataSpaceManager = class {
4014
3891
  genesisFeedKey: controlFeedKey,
4015
3892
  controlFeedKey,
4016
3893
  dataFeedKey,
4017
- state: import_services10.SpaceState.ACTIVE
3894
+ state: import_services8.SpaceState.ACTIVE
4018
3895
  };
4019
3896
  (0, import_log10.log)("creating space...", {
4020
3897
  spaceKey
4021
3898
  }, {
4022
- F: __dxlog_file13,
3899
+ F: __dxlog_file12,
4023
3900
  L: 150,
4024
3901
  S: this,
4025
3902
  C: (f, a) => f(...a)
@@ -4034,8 +3911,8 @@ var DataSpaceManager = class {
4034
3911
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
4035
3912
  await this._metadataStore.addSpace(metadata);
4036
3913
  const memberCredential = credentials[1];
4037
- (0, import_invariant12.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
4038
- F: __dxlog_file13,
3914
+ (0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3915
+ F: __dxlog_file12,
4039
3916
  L: 163,
4040
3917
  S: this,
4041
3918
  A: [
@@ -4053,13 +3930,13 @@ var DataSpaceManager = class {
4053
3930
  (0, import_log10.log)("accept space", {
4054
3931
  opts
4055
3932
  }, {
4056
- F: __dxlog_file13,
3933
+ F: __dxlog_file12,
4057
3934
  L: 175,
4058
3935
  S: this,
4059
3936
  C: (f, a) => f(...a)
4060
3937
  });
4061
- (0, import_invariant12.invariant)(this._isOpen, "Not open.", {
4062
- F: __dxlog_file13,
3938
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3939
+ F: __dxlog_file12,
4063
3940
  L: 176,
4064
3941
  S: this,
4065
3942
  A: [
@@ -4067,8 +3944,8 @@ var DataSpaceManager = class {
4067
3944
  "'Not open.'"
4068
3945
  ]
4069
3946
  });
4070
- (0, import_invariant12.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
4071
- F: __dxlog_file13,
3947
+ (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3948
+ F: __dxlog_file12,
4072
3949
  L: 177,
4073
3950
  S: this,
4074
3951
  A: [
@@ -4096,14 +3973,14 @@ var DataSpaceManager = class {
4096
3973
  async waitUntilSpaceReady(spaceKey) {
4097
3974
  await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
4098
3975
  const space = this._spaces.get(spaceKey);
4099
- return !!space && space.state === import_services10.SpaceState.READY;
3976
+ return !!space && space.state === import_services8.SpaceState.READY;
4100
3977
  }));
4101
3978
  }
4102
3979
  async _constructSpace(metadata) {
4103
3980
  (0, import_log10.log)("construct space", {
4104
3981
  metadata
4105
3982
  }, {
4106
- F: __dxlog_file13,
3983
+ F: __dxlog_file12,
4107
3984
  L: 210,
4108
3985
  S: this,
4109
3986
  C: (f, a) => f(...a)
@@ -4141,7 +4018,7 @@ var DataSpaceManager = class {
4141
4018
  },
4142
4019
  onAuthFailure: () => {
4143
4020
  import_log10.log.warn("auth failure", void 0, {
4144
- F: __dxlog_file13,
4021
+ F: __dxlog_file12,
4145
4022
  L: 247,
4146
4023
  S: this,
4147
4024
  C: (f, a) => f(...a)
@@ -4153,7 +4030,7 @@ var DataSpaceManager = class {
4153
4030
  dataFeed && await space.setDataFeed(dataFeed);
4154
4031
  const dataSpace = new DataSpace({
4155
4032
  inner: space,
4156
- 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,
4157
4034
  metadataStore: this._metadataStore,
4158
4035
  gossip,
4159
4036
  presence,
@@ -4165,7 +4042,7 @@ var DataSpaceManager = class {
4165
4042
  (0, import_log10.log)("before space ready", {
4166
4043
  space: space.key
4167
4044
  }, {
4168
- F: __dxlog_file13,
4045
+ F: __dxlog_file12,
4169
4046
  L: 265,
4170
4047
  S: this,
4171
4048
  C: (f, a) => f(...a)
@@ -4176,7 +4053,7 @@ var DataSpaceManager = class {
4176
4053
  space: space.key,
4177
4054
  open: this._isOpen
4178
4055
  }, {
4179
- F: __dxlog_file13,
4056
+ F: __dxlog_file12,
4180
4057
  L: 268,
4181
4058
  S: this,
4182
4059
  C: (f, a) => f(...a)
@@ -4189,7 +4066,7 @@ var DataSpaceManager = class {
4189
4066
  (0, import_log10.log)("before space close", {
4190
4067
  space: space.key
4191
4068
  }, {
4192
- F: __dxlog_file13,
4069
+ F: __dxlog_file12,
4193
4070
  L: 274,
4194
4071
  S: this,
4195
4072
  C: (f, a) => f(...a)
@@ -4199,7 +4076,7 @@ var DataSpaceManager = class {
4199
4076
  cache: metadata.cache,
4200
4077
  automergeHost: this._automergeHost
4201
4078
  });
4202
- if (metadata.state !== import_services10.SpaceState.INACTIVE) {
4079
+ if (metadata.state !== import_services8.SpaceState.INACTIVE) {
4203
4080
  await dataSpace.open();
4204
4081
  }
4205
4082
  if (metadata.controlTimeframe) {
@@ -4224,7 +4101,7 @@ _ts_decorate5([
4224
4101
  DataSpaceManager = _ts_decorate5([
4225
4102
  (0, import_async13.trackLeaks)("open", "close")
4226
4103
  ], DataSpaceManager);
4227
- 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";
4228
4105
  var SpacesServiceImpl = class {
4229
4106
  constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
4230
4107
  this._identityManager = _identityManager;
@@ -4241,29 +4118,29 @@ var SpacesServiceImpl = class {
4241
4118
  }
4242
4119
  async updateSpace({ spaceKey, state }) {
4243
4120
  const dataSpaceManager = await this._getDataSpaceManager();
4244
- 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));
4245
4122
  if (state) {
4246
4123
  switch (state) {
4247
- case import_services11.SpaceState.ACTIVE:
4124
+ case import_services9.SpaceState.ACTIVE:
4248
4125
  await space.activate();
4249
4126
  break;
4250
- case import_services11.SpaceState.INACTIVE:
4127
+ case import_services9.SpaceState.INACTIVE:
4251
4128
  await space.deactivate();
4252
4129
  break;
4253
4130
  default:
4254
- throw new import_protocols11.ApiError("Invalid space state");
4131
+ throw new import_protocols10.ApiError("Invalid space state");
4255
4132
  }
4256
4133
  }
4257
4134
  }
4258
4135
  querySpaces() {
4259
- return new import_codec_protobuf11.Stream(({ next, ctx }) => {
4136
+ return new import_codec_protobuf10.Stream(({ next, ctx }) => {
4260
4137
  const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
4261
4138
  const dataSpaceManager = await this._getDataSpaceManager();
4262
4139
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
4263
4140
  (0, import_log11.log)("update", {
4264
4141
  spaces
4265
4142
  }, {
4266
- F: __dxlog_file14,
4143
+ F: __dxlog_file13,
4267
4144
  L: 77,
4268
4145
  S: this,
4269
4146
  C: (f, a) => f(...a)
@@ -4303,14 +4180,14 @@ var SpacesServiceImpl = class {
4303
4180
  }
4304
4181
  async postMessage({ spaceKey, channel, message }) {
4305
4182
  const dataSpaceManager = await this._getDataSpaceManager();
4306
- 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));
4307
4184
  await space.postMessage(getChannelId(channel), message);
4308
4185
  }
4309
4186
  subscribeMessages({ spaceKey, channel }) {
4310
- return new import_codec_protobuf11.Stream(({ ctx, next }) => {
4187
+ return new import_codec_protobuf10.Stream(({ ctx, next }) => {
4311
4188
  (0, import_async14.scheduleTask)(ctx, async () => {
4312
4189
  const dataSpaceManager = await this._getDataSpaceManager();
4313
- 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));
4314
4191
  const handle = space.listen(getChannelId(channel), (message) => {
4315
4192
  next(message);
4316
4193
  });
@@ -4319,8 +4196,8 @@ var SpacesServiceImpl = class {
4319
4196
  });
4320
4197
  }
4321
4198
  queryCredentials({ spaceKey, noTail }) {
4322
- return new import_codec_protobuf11.Stream(({ ctx, next, close }) => {
4323
- 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));
4324
4201
  const processor = {
4325
4202
  processCredential: async (credential) => {
4326
4203
  next(credential);
@@ -4336,7 +4213,7 @@ var SpacesServiceImpl = class {
4336
4213
  });
4337
4214
  }
4338
4215
  async writeCredentials({ spaceKey, credentials }) {
4339
- 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));
4340
4217
  for (const credential of credentials ?? []) {
4341
4218
  if (credential.proof) {
4342
4219
  await space.controlPipeline.writer.write({
@@ -4345,8 +4222,8 @@ var SpacesServiceImpl = class {
4345
4222
  }
4346
4223
  });
4347
4224
  } else {
4348
- (0, import_invariant13.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
4349
- F: __dxlog_file14,
4225
+ (0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
4226
+ F: __dxlog_file13,
4350
4227
  L: 164,
4351
4228
  S: this,
4352
4229
  A: [
@@ -4354,8 +4231,8 @@ var SpacesServiceImpl = class {
4354
4231
  "'Id on unsigned credentials is not allowed'"
4355
4232
  ]
4356
4233
  });
4357
- (0, import_invariant13.invariant)(this._identityManager.identity, "Identity is not available", {
4358
- F: __dxlog_file14,
4234
+ (0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
4235
+ F: __dxlog_file13,
4359
4236
  L: 165,
4360
4237
  S: this,
4361
4238
  A: [
@@ -4364,8 +4241,8 @@ var SpacesServiceImpl = class {
4364
4241
  ]
4365
4242
  });
4366
4243
  const signer = this._identityManager.identity.getIdentityCredentialSigner();
4367
- (0, import_invariant13.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
4368
- F: __dxlog_file14,
4244
+ (0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
4245
+ F: __dxlog_file13,
4369
4246
  L: 167,
4370
4247
  S: this,
4371
4248
  A: [
@@ -4387,7 +4264,7 @@ var SpacesServiceImpl = class {
4387
4264
  }
4388
4265
  async createEpoch({ spaceKey, migration }) {
4389
4266
  const dataSpaceManager = await this._getDataSpaceManager();
4390
- 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));
4391
4268
  await space.createEpoch({
4392
4269
  migration
4393
4270
  });
@@ -4396,7 +4273,7 @@ var SpacesServiceImpl = class {
4396
4273
  return {
4397
4274
  spaceKey: space.key,
4398
4275
  state: space.state,
4399
- error: space.error ? (0, import_protocols11.encodeError)(space.error) : void 0,
4276
+ error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
4400
4277
  pipeline: {
4401
4278
  currentEpoch: space.automergeSpaceState.lastEpoch,
4402
4279
  appliedEpoch: space.automergeSpaceState.lastEpoch,
@@ -4421,7 +4298,7 @@ var SpacesServiceImpl = class {
4421
4298
  identityKey: member.key,
4422
4299
  profile: member.profile ?? {}
4423
4300
  },
4424
- 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,
4425
4302
  peerStates: peers
4426
4303
  };
4427
4304
  }),
@@ -4440,18 +4317,18 @@ var createSelectedDocumentsIterator = (automergeHost) => (
4440
4317
  // TODO(mykola): Unload automerge handles after usage.
4441
4318
  async function* loadDocuments(ids) {
4442
4319
  for (const id of ids) {
4443
- const { documentId, objectId } = import_protocols13.idCodec.decode(id);
4320
+ const { documentId, objectId } = import_protocols12.idCodec.decode(id);
4444
4321
  const handle = automergeHost.repo.find(documentId);
4445
4322
  await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
4446
4323
  const doc = handle.docSync();
4447
4324
  const hash = (0, import_automerge.getHeads)(doc).join("");
4448
- yield [
4325
+ yield doc.objects?.[objectId] ? [
4449
4326
  {
4450
4327
  id,
4451
4328
  object: doc.objects[objectId],
4452
4329
  currentHash: hash
4453
4330
  }
4454
- ];
4331
+ ] : [];
4455
4332
  }
4456
4333
  }
4457
4334
  );
@@ -4473,7 +4350,7 @@ var createDocumentsIterator = (automergeHost) => (
4473
4350
  if (doc.objects) {
4474
4351
  yield Object.entries(doc.objects).map(([objectId, object]) => {
4475
4352
  return {
4476
- id: import_protocols13.idCodec.encode({
4353
+ id: import_protocols12.idCodec.encode({
4477
4354
  documentId: handle.documentId,
4478
4355
  objectId
4479
4356
  }),
@@ -4516,18 +4393,20 @@ function _ts_decorate6(decorators, target, key, desc) {
4516
4393
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4517
4394
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4518
4395
  }
4519
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4520
- var ServiceContext = class {
4521
- constructor(storage, networkManager, signalManager, _runtimeParams) {
4396
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4397
+ var ServiceContext = class extends import_context10.Resource {
4398
+ constructor(storage, level, networkManager, signalManager, _runtimeParams) {
4399
+ super();
4522
4400
  this.storage = storage;
4401
+ this.level = level;
4523
4402
  this.networkManager = networkManager;
4524
4403
  this.signalManager = signalManager;
4525
4404
  this._runtimeParams = _runtimeParams;
4526
4405
  this.initialized = new import_async15.Trigger();
4527
4406
  this._handlerFactories = /* @__PURE__ */ new Map();
4528
4407
  this._instanceId = import_keys10.PublicKey.random().toHex();
4529
- this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
4530
- 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"));
4531
4410
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
4532
4411
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
4533
4412
  this.feedStore = new import_feed_store4.FeedStore({
@@ -4535,12 +4414,12 @@ var ServiceContext = class {
4535
4414
  root: storage.createDirectory("feeds"),
4536
4415
  signer: this.keyring,
4537
4416
  hypercore: {
4538
- valueEncoding: import_echo_pipeline3.valueEncoding,
4417
+ valueEncoding: import_echo_pipeline4.valueEncoding,
4539
4418
  stats: true
4540
4419
  }
4541
4420
  })
4542
4421
  });
4543
- this.spaceManager = new import_echo_pipeline3.SpaceManager({
4422
+ this.spaceManager = new import_echo_pipeline4.SpaceManager({
4544
4423
  feedStore: this.feedStore,
4545
4424
  networkManager: this.networkManager,
4546
4425
  blobStore: this.blobStore,
@@ -4549,10 +4428,11 @@ var ServiceContext = class {
4549
4428
  });
4550
4429
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
4551
4430
  this.indexMetadata = new import_indexing.IndexMetadataStore({
4552
- directory: storage.createDirectory("index-metadata")
4431
+ db: level.sublevel("index-metadata")
4553
4432
  });
4554
- this.automergeHost = new import_echo_pipeline3.AutomergeHost({
4433
+ this.automergeHost = new import_echo_pipeline4.AutomergeHost({
4555
4434
  directory: storage.createDirectory("automerge"),
4435
+ db: level.sublevel("automerge"),
4556
4436
  metadata: this.indexMetadata
4557
4437
  });
4558
4438
  this.indexer = new import_indexing.Indexer({
@@ -4564,51 +4444,52 @@ var ServiceContext = class {
4564
4444
  getAllDocuments: createDocumentsIterator(this.automergeHost)
4565
4445
  });
4566
4446
  this.invitations = new InvitationsHandler(this.networkManager);
4567
- 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)));
4568
4448
  }
4569
- async open(ctx) {
4449
+ async _open(ctx) {
4570
4450
  await this._checkStorageVersion();
4571
4451
  (0, import_log12.log)("opening...", void 0, {
4572
- F: __dxlog_file15,
4573
- L: 151,
4452
+ F: __dxlog_file14,
4453
+ L: 157,
4574
4454
  S: this,
4575
4455
  C: (f, a) => f(...a)
4576
4456
  });
4577
- 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({
4578
4458
  id: this._instanceId
4579
4459
  }), {
4580
- F: __dxlog_file15,
4581
- L: 152,
4460
+ F: __dxlog_file14,
4461
+ L: 158,
4582
4462
  S: this,
4583
4463
  C: (f, a) => f(...a)
4584
4464
  });
4585
4465
  await this.signalManager.open();
4586
4466
  await this.networkManager.open();
4467
+ await this.automergeHost.open();
4587
4468
  await this.metadataStore.load();
4588
4469
  await this.spaceManager.open();
4589
4470
  await this.identityManager.open(ctx);
4590
4471
  if (this.identityManager.identity) {
4591
4472
  await this._initialize(ctx);
4592
4473
  }
4593
- 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({
4594
4475
  id: this._instanceId
4595
4476
  }), {
4596
- F: __dxlog_file15,
4597
- L: 162,
4477
+ F: __dxlog_file14,
4478
+ L: 169,
4598
4479
  S: this,
4599
4480
  C: (f, a) => f(...a)
4600
4481
  });
4601
4482
  (0, import_log12.log)("opened", void 0, {
4602
- F: __dxlog_file15,
4603
- L: 163,
4483
+ F: __dxlog_file14,
4484
+ L: 170,
4604
4485
  S: this,
4605
4486
  C: (f, a) => f(...a)
4606
4487
  });
4607
4488
  }
4608
- async close() {
4489
+ async _close() {
4609
4490
  (0, import_log12.log)("closing...", void 0, {
4610
- F: __dxlog_file15,
4611
- L: 167,
4491
+ F: __dxlog_file14,
4492
+ L: 174,
4612
4493
  S: this,
4613
4494
  C: (f, a) => f(...a)
4614
4495
  });
@@ -4625,8 +4506,8 @@ var ServiceContext = class {
4625
4506
  await this.metadataStore.close();
4626
4507
  await this.indexer.destroy();
4627
4508
  (0, import_log12.log)("closed", void 0, {
4628
- F: __dxlog_file15,
4629
- L: 180,
4509
+ F: __dxlog_file14,
4510
+ L: 187,
4630
4511
  S: this,
4631
4512
  C: (f, a) => f(...a)
4632
4513
  });
@@ -4638,9 +4519,9 @@ var ServiceContext = class {
4638
4519
  }
4639
4520
  getInvitationHandler(invitation) {
4640
4521
  const factory = this._handlerFactories.get(invitation.kind);
4641
- (0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4642
- F: __dxlog_file15,
4643
- L: 191,
4522
+ (0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4523
+ F: __dxlog_file14,
4524
+ L: 198,
4644
4525
  S: this,
4645
4526
  A: [
4646
4527
  "factory",
@@ -4664,15 +4545,15 @@ var ServiceContext = class {
4664
4545
  }
4665
4546
  async _checkStorageVersion() {
4666
4547
  await this.metadataStore.load();
4667
- if (this.metadataStore.version !== import_protocols12.STORAGE_VERSION) {
4668
- 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);
4669
4550
  }
4670
4551
  }
4671
4552
  // Called when identity is created.
4672
4553
  async _initialize(ctx) {
4673
4554
  (0, import_log12.log)("initializing spaces...", void 0, {
4674
- F: __dxlog_file15,
4675
- L: 222,
4555
+ F: __dxlog_file14,
4556
+ L: 229,
4676
4557
  S: this,
4677
4558
  C: (f, a) => f(...a)
4678
4559
  });
@@ -4692,10 +4573,10 @@ var ServiceContext = class {
4692
4573
  };
4693
4574
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
4694
4575
  await this.dataSpaceManager.open();
4695
- this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
4696
- (0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4697
- F: __dxlog_file15,
4698
- L: 246,
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,
4699
4580
  S: this,
4700
4581
  A: [
4701
4582
  "this.dataSpaceManager",
@@ -4707,7 +4588,7 @@ var ServiceContext = class {
4707
4588
  this.initialized.wake();
4708
4589
  this._deviceSpaceSync = {
4709
4590
  processCredential: async (credential) => {
4710
- const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
4591
+ const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
4711
4592
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
4712
4593
  return;
4713
4594
  }
@@ -4718,8 +4599,8 @@ var ServiceContext = class {
4718
4599
  (0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
4719
4600
  details: assertion
4720
4601
  }, {
4721
- F: __dxlog_file15,
4722
- L: 262,
4602
+ F: __dxlog_file14,
4603
+ L: 269,
4723
4604
  S: this,
4724
4605
  C: (f, a) => f(...a)
4725
4606
  });
@@ -4729,8 +4610,8 @@ var ServiceContext = class {
4729
4610
  (0, import_log12.log)("space already exists, ignoring space admission", {
4730
4611
  details: assertion
4731
4612
  }, {
4732
- F: __dxlog_file15,
4733
- L: 266,
4613
+ F: __dxlog_file14,
4614
+ L: 273,
4734
4615
  S: this,
4735
4616
  C: (f, a) => f(...a)
4736
4617
  });
@@ -4740,8 +4621,8 @@ var ServiceContext = class {
4740
4621
  (0, import_log12.log)("accepting space recorded in halo", {
4741
4622
  details: assertion
4742
4623
  }, {
4743
- F: __dxlog_file15,
4744
- L: 271,
4624
+ F: __dxlog_file14,
4625
+ L: 278,
4745
4626
  S: this,
4746
4627
  C: (f, a) => f(...a)
4747
4628
  });
@@ -4751,8 +4632,8 @@ var ServiceContext = class {
4751
4632
  });
4752
4633
  } catch (err) {
4753
4634
  import_log12.log.catch(err, void 0, {
4754
- F: __dxlog_file15,
4755
- L: 277,
4635
+ F: __dxlog_file14,
4636
+ L: 284,
4756
4637
  S: this,
4757
4638
  C: (f, a) => f(...a)
4758
4639
  });
@@ -4763,14 +4644,14 @@ var ServiceContext = class {
4763
4644
  }
4764
4645
  };
4765
4646
  _ts_decorate6([
4766
- import_tracing6.trace.span()
4767
- ], ServiceContext.prototype, "open", null);
4647
+ import_tracing5.trace.span()
4648
+ ], ServiceContext.prototype, "_open", null);
4768
4649
  _ts_decorate6([
4769
- import_tracing6.trace.span()
4650
+ import_tracing5.trace.span()
4770
4651
  ], ServiceContext.prototype, "_initialize", null);
4771
4652
  ServiceContext = _ts_decorate6([
4772
4653
  (0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
4773
- import_tracing6.trace.resource()
4654
+ import_tracing5.trace.resource()
4774
4655
  ], ServiceContext);
4775
4656
  var ServiceRegistry = class {
4776
4657
  // prettier-ignore
@@ -4794,103 +4675,155 @@ var ServiceRegistry = class {
4794
4675
  delete this._handlers[name];
4795
4676
  }
4796
4677
  };
4797
- function _ts_decorate7(decorators, target, key, desc) {
4798
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4799
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4800
- r = Reflect.decorate(decorators, target, key, desc);
4801
- else
4802
- for (var i = decorators.length - 1; i >= 0; i--)
4803
- if (d = decorators[i])
4804
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4805
- return c > 3 && r && Object.defineProperty(target, key, r), r;
4806
- }
4807
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
4808
- var Lock = class {
4809
- constructor({ lockKey: lockPath, onAcquire, onRelease }) {
4810
- this._lockPath = lockPath;
4811
- this._onAcquire = onAcquire;
4812
- this._onRelease = onRelease;
4813
- }
4814
- get lockKey() {
4815
- return this._lockPath;
4816
- }
4817
- async acquire() {
4818
- (0, import_log13.log)("acquiring lock...", void 0, {
4819
- F: __dxlog_file16,
4820
- L: 32,
4821
- S: this,
4822
- C: (f, a) => f(...a)
4823
- });
4824
- this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
4825
- await this._onAcquire?.();
4826
- (0, import_log13.log)("acquired lock", void 0, {
4827
- F: __dxlog_file16,
4828
- L: 37,
4829
- S: this,
4830
- C: (f, a) => f(...a)
4831
- });
4678
+ var DXOS_VERSION = "0.4.10-main.8583d5a";
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
+ };
4832
4704
  }
4833
- async release() {
4834
- await this._onRelease?.();
4835
- (0, import_invariant15.invariant)(this._fileHandle, "Lock is not acquired", {
4836
- F: __dxlog_file16,
4837
- L: 42,
4838
- 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,
4839
4725
  A: [
4840
- "this._fileHandle",
4841
- "'Lock is not acquired'"
4726
+ "clientServices.LoggingService",
4727
+ "'SystemService is not available.'"
4842
4728
  ]
4843
4729
  });
4844
- await import_lock_file.LockFile.release(this._fileHandle);
4845
- }
4846
- };
4847
- _ts_decorate7([
4848
- import_log13.logInfo
4849
- ], Lock.prototype, "lockKey", null);
4850
- var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
4851
- var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
4852
- var createStorageObjects = (config) => {
4853
- const { persistent = false, keyStore, dataStore, dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
4854
- if (persistent && dataStore === StorageDriver.RAM) {
4855
- 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);
4856
4733
  }
4857
- if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
4858
- 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
+ }));
4859
4748
  }
4860
- if (persistent && keyStore === StorageDriver.RAM) {
4861
- 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;
4862
4776
  }
4863
- if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
4864
- 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();
4865
4810
  }
4811
+ return stats;
4812
+ };
4813
+ var createCollectDiagnosticsBroadcastSender = () => {
4866
4814
  return {
4867
- storage: (0, import_random_access_storage.createStorage)({
4868
- type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
4869
- root: `${dataRoot}/`
4870
- })
4815
+ broadcastDiagnosticsRequest: async () => void 0
4871
4816
  };
4872
4817
  };
4873
- var toStorageType = (type) => {
4874
- switch (type) {
4875
- case void 0:
4876
- return void 0;
4877
- case StorageDriver.RAM:
4878
- return import_random_access_storage.StorageType.RAM;
4879
- case StorageDriver.CHROME:
4880
- return import_random_access_storage.StorageType.CHROME;
4881
- case StorageDriver.FIREFOX:
4882
- return import_random_access_storage.StorageType.FIREFOX;
4883
- case StorageDriver.IDB:
4884
- return import_random_access_storage.StorageType.IDB;
4885
- case StorageDriver.NODE:
4886
- return import_random_access_storage.StorageType.NODE;
4887
- case StorageDriver.WEBFS:
4888
- return import_random_access_storage.StorageType.WEBFS;
4889
- default:
4890
- throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
4891
- }
4818
+ var createCollectDiagnosticsBroadcastHandler = (_) => {
4819
+ return {
4820
+ start: () => {
4821
+ },
4822
+ stop: () => {
4823
+ }
4824
+ };
4892
4825
  };
4893
- 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";
4894
4827
  var DevicesServiceImpl = class {
4895
4828
  constructor(_identityManager) {
4896
4829
  this._identityManager = _identityManager;
@@ -4907,8 +4840,8 @@ var DevicesServiceImpl = class {
4907
4840
  devices: []
4908
4841
  });
4909
4842
  } else {
4910
- (0, import_invariant17.invariant)(this._identityManager.identity?.presence, "presence not present", {
4911
- F: __dxlog_file17,
4843
+ (0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
4844
+ F: __dxlog_file16,
4912
4845
  L: 32,
4913
4846
  S: this,
4914
4847
  A: [
@@ -4923,9 +4856,9 @@ var DevicesServiceImpl = class {
4923
4856
  const peerState = peers.find((peer) => peer.identityKey.equals(key));
4924
4857
  return {
4925
4858
  deviceKey: key,
4926
- 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,
4927
4860
  profile,
4928
- 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
4929
4862
  };
4930
4863
  })
4931
4864
  });
@@ -4966,6 +4899,60 @@ var DevicesServiceImpl = class {
4966
4899
  });
4967
4900
  }
4968
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);
4969
4956
  var LoggingServiceImpl = class {
4970
4957
  constructor() {
4971
4958
  this._logs = new import_async18.Event();
@@ -5065,18 +5052,18 @@ var LoggingServiceImpl = class {
5065
5052
  });
5066
5053
  }
5067
5054
  };
5068
- var matchFilter = (filter, level, path, options) => {
5055
+ var matchFilter = (filter, level, path2, options) => {
5069
5056
  switch (options) {
5070
- case import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5071
- return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
5072
- case import_services15.QueryLogsRequest.MatchingOptions.EXPLICIT:
5073
- return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
5057
+ case import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5058
+ return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
5059
+ case import_services16.QueryLogsRequest.MatchingOptions.EXPLICIT:
5060
+ return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
5074
5061
  }
5075
5062
  };
5076
5063
  var shouldLog = (entry2, request) => {
5077
- const options = request.options ?? import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5064
+ const options = request.options ?? import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5078
5065
  if (request.filters === void 0) {
5079
- return options === import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5066
+ return options === import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
5080
5067
  } else {
5081
5068
  return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
5082
5069
  }
@@ -5112,6 +5099,63 @@ var NetworkServiceImpl = class {
5112
5099
  await this.networkManager.setConnectionState(request.swarm);
5113
5100
  }
5114
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
+ };
5115
5159
  var SystemServiceImpl = class {
5116
5160
  constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
5117
5161
  this._config = config;
@@ -5131,9 +5175,9 @@ var SystemServiceImpl = class {
5131
5175
  const diagnostics = await this._getDiagnostics();
5132
5176
  return {
5133
5177
  timestamp: /* @__PURE__ */ new Date(),
5134
- diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util11.jsonKeyReplacer)({
5135
- truncate: keys === import_services16.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
5136
- 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
5137
5181
  })))
5138
5182
  };
5139
5183
  }
@@ -5181,16 +5225,18 @@ var ClientServicesHost = class {
5181
5225
  transportFactory,
5182
5226
  signalManager,
5183
5227
  storage,
5228
+ level,
5184
5229
  // TODO(wittjosiah): Turn this on by default.
5185
5230
  lockKey,
5186
5231
  callbacks,
5187
5232
  runtimeParams
5188
5233
  } = {}) {
5189
- this._tracingService = import_tracing7.TRACE_PROCESSOR.createTraceSender();
5234
+ this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
5190
5235
  this._statusUpdate = new import_async16.Event();
5191
5236
  this._opening = false;
5192
5237
  this._open = false;
5193
5238
  this._storage = storage;
5239
+ this._level = level;
5194
5240
  this._callbacks = callbacks;
5195
5241
  this._runtimeParams = runtimeParams;
5196
5242
  if (config) {
@@ -5214,14 +5260,14 @@ var ClientServicesHost = class {
5214
5260
  this._systemService = new SystemServiceImpl({
5215
5261
  config: () => this._config,
5216
5262
  statusUpdate: this._statusUpdate,
5217
- getCurrentStatus: () => this.isOpen ? import_services13.SystemStatus.ACTIVE : import_services13.SystemStatus.INACTIVE,
5263
+ getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
5218
5264
  getDiagnostics: () => {
5219
5265
  return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
5220
5266
  },
5221
5267
  onUpdateStatus: async (status) => {
5222
- if (!this.isOpen && status === import_services13.SystemStatus.ACTIVE) {
5268
+ if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
5223
5269
  await this._resourceLock?.acquire();
5224
- } else if (this.isOpen && status === import_services13.SystemStatus.INACTIVE) {
5270
+ } else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
5225
5271
  await this._resourceLock?.release();
5226
5272
  }
5227
5273
  },
@@ -5229,8 +5275,9 @@ var ClientServicesHost = class {
5229
5275
  await this.reset();
5230
5276
  }
5231
5277
  });
5278
+ this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
5232
5279
  this._loggingService = new LoggingServiceImpl();
5233
- this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
5280
+ this._serviceRegistry = new ServiceRegistry(import_client_protocol4.clientServiceBundle, {
5234
5281
  SystemService: this._systemService,
5235
5282
  TracingService: this._tracingService
5236
5283
  });
@@ -5259,25 +5306,25 @@ var ClientServicesHost = class {
5259
5306
  * Can only be called once.
5260
5307
  */
5261
5308
  initialize({ config, ...options }) {
5262
- (0, import_invariant16.invariant)(!this._open, "service host is open", {
5309
+ (0, import_invariant15.invariant)(!this._open, "service host is open", {
5263
5310
  F: __dxlog_file18,
5264
- L: 180,
5311
+ L: 197,
5265
5312
  S: this,
5266
5313
  A: [
5267
5314
  "!this._open",
5268
5315
  "'service host is open'"
5269
5316
  ]
5270
5317
  });
5271
- (0, import_log14.log)("initializing...", void 0, {
5318
+ (0, import_log13.log)("initializing...", void 0, {
5272
5319
  F: __dxlog_file18,
5273
- L: 181,
5320
+ L: 198,
5274
5321
  S: this,
5275
5322
  C: (f, a) => f(...a)
5276
5323
  });
5277
5324
  if (config) {
5278
- (0, import_invariant16.invariant)(!this._config, "config already set", {
5325
+ (0, import_invariant15.invariant)(!this._config, "config already set", {
5279
5326
  F: __dxlog_file18,
5280
- L: 184,
5327
+ L: 201,
5281
5328
  S: this,
5282
5329
  A: [
5283
5330
  "!this._config",
@@ -5290,9 +5337,9 @@ var ClientServicesHost = class {
5290
5337
  }
5291
5338
  }
5292
5339
  if (!options.signalManager) {
5293
- import_log14.log.warn("running signaling without telemetry metadata.", void 0, {
5340
+ import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
5294
5341
  F: __dxlog_file18,
5295
- L: 192,
5342
+ L: 209,
5296
5343
  S: this,
5297
5344
  C: (f, a) => f(...a)
5298
5345
  });
@@ -5301,9 +5348,9 @@ var ClientServicesHost = class {
5301
5348
  iceServers: this._config?.get("runtime.services.ice")
5302
5349
  }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
5303
5350
  this._signalManager = signalManager;
5304
- (0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
5351
+ (0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
5305
5352
  F: __dxlog_file18,
5306
- L: 203,
5353
+ L: 220,
5307
5354
  S: this,
5308
5355
  A: [
5309
5356
  "!this._networkManager",
@@ -5315,9 +5362,9 @@ var ClientServicesHost = class {
5315
5362
  transportFactory,
5316
5363
  signalManager
5317
5364
  });
5318
- (0, import_log14.log)("initialized", void 0, {
5365
+ (0, import_log13.log)("initialized", void 0, {
5319
5366
  F: __dxlog_file18,
5320
- L: 210,
5367
+ L: 227,
5321
5368
  S: this,
5322
5369
  C: (f, a) => f(...a)
5323
5370
  });
@@ -5327,44 +5374,44 @@ var ClientServicesHost = class {
5327
5374
  return;
5328
5375
  }
5329
5376
  const traceId = import_keys11.PublicKey.random().toHex();
5330
- import_log14.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
5377
+ import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
5331
5378
  id: traceId
5332
5379
  }), {
5333
5380
  F: __dxlog_file18,
5334
- L: 221,
5381
+ L: 238,
5335
5382
  S: this,
5336
5383
  C: (f, a) => f(...a)
5337
5384
  });
5338
- (0, import_invariant16.invariant)(this._config, "config not set", {
5385
+ (0, import_invariant15.invariant)(this._config, "config not set", {
5339
5386
  F: __dxlog_file18,
5340
- L: 223,
5387
+ L: 240,
5341
5388
  S: this,
5342
5389
  A: [
5343
5390
  "this._config",
5344
5391
  "'config not set'"
5345
5392
  ]
5346
5393
  });
5347
- (0, import_invariant16.invariant)(this._storage, "storage not set", {
5394
+ (0, import_invariant15.invariant)(this._storage, "storage not set", {
5348
5395
  F: __dxlog_file18,
5349
- L: 224,
5396
+ L: 241,
5350
5397
  S: this,
5351
5398
  A: [
5352
5399
  "this._storage",
5353
5400
  "'storage not set'"
5354
5401
  ]
5355
5402
  });
5356
- (0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
5403
+ (0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
5357
5404
  F: __dxlog_file18,
5358
- L: 225,
5405
+ L: 242,
5359
5406
  S: this,
5360
5407
  A: [
5361
5408
  "this._signalManager",
5362
5409
  "'signal manager not set'"
5363
5410
  ]
5364
5411
  });
5365
- (0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
5412
+ (0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
5366
5413
  F: __dxlog_file18,
5367
- L: 226,
5414
+ L: 243,
5368
5415
  S: this,
5369
5416
  A: [
5370
5417
  "this._networkManager",
@@ -5372,17 +5419,21 @@ var ClientServicesHost = class {
5372
5419
  ]
5373
5420
  });
5374
5421
  this._opening = true;
5375
- (0, import_log14.log)("opening...", {
5422
+ (0, import_log13.log)("opening...", {
5376
5423
  lockKey: this._resourceLock?.lockKey
5377
5424
  }, {
5378
5425
  F: __dxlog_file18,
5379
- L: 229,
5426
+ L: 246,
5380
5427
  S: this,
5381
5428
  C: (f, a) => f(...a)
5382
5429
  });
5430
+ if (!this._level) {
5431
+ this._level = await createLevel(this._config.get("runtime.client.storage", {}));
5432
+ }
5433
+ await this._level.open();
5383
5434
  await this._resourceLock?.acquire();
5384
5435
  await this._loggingService.open();
5385
- this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
5436
+ this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
5386
5437
  this._serviceRegistry.setServices({
5387
5438
  SystemService: this._systemService,
5388
5439
  IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
@@ -5392,7 +5443,7 @@ var ClientServicesHost = class {
5392
5443
  await this._serviceContext.initialized.wait();
5393
5444
  return this._serviceContext.dataSpaceManager;
5394
5445
  }),
5395
- DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.automergeHost),
5446
+ DataService: new import_echo_pipeline5.DataServiceImpl(this._serviceContext.automergeHost),
5396
5447
  IndexService: new import_indexing2.IndexServiceImpl({
5397
5448
  indexer: this._serviceContext.indexer,
5398
5449
  automergeHost: this._serviceContext.automergeHost
@@ -5408,9 +5459,9 @@ var ClientServicesHost = class {
5408
5459
  })
5409
5460
  });
5410
5461
  await this._serviceContext.open(ctx);
5411
- (0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5462
+ (0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5412
5463
  F: __dxlog_file18,
5413
- L: 290,
5464
+ L: 314,
5414
5465
  S: this,
5415
5466
  A: [
5416
5467
  "this.serviceRegistry.services.InvitationsService",
@@ -5418,11 +5469,11 @@ var ClientServicesHost = class {
5418
5469
  ]
5419
5470
  });
5420
5471
  const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
5421
- (0, import_log14.log)("loaded persistent invitations", {
5472
+ (0, import_log13.log)("loaded persistent invitations", {
5422
5473
  count: loadedInvitations.invitations?.length
5423
5474
  }, {
5424
5475
  F: __dxlog_file18,
5425
- L: 293,
5476
+ L: 317,
5426
5477
  S: this,
5427
5478
  C: (f, a) => f(...a)
5428
5479
  });
@@ -5431,28 +5482,29 @@ var ClientServicesHost = class {
5431
5482
  this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
5432
5483
  url: devtoolsProxy,
5433
5484
  requested: {},
5434
- exposed: import_client_protocol5.clientServiceBundle,
5485
+ exposed: import_client_protocol4.clientServiceBundle,
5435
5486
  handlers: this.services
5436
5487
  });
5437
5488
  void this._devtoolsProxy.open();
5438
5489
  }
5490
+ this.diagnosticsBroadcastHandler.start();
5439
5491
  this._opening = false;
5440
5492
  this._open = true;
5441
5493
  this._statusUpdate.emit();
5442
5494
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
5443
- (0, import_log14.log)("opened", {
5495
+ (0, import_log13.log)("opened", {
5444
5496
  deviceKey
5445
5497
  }, {
5446
5498
  F: __dxlog_file18,
5447
- L: 310,
5499
+ L: 335,
5448
5500
  S: this,
5449
5501
  C: (f, a) => f(...a)
5450
5502
  });
5451
- 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({
5452
5504
  id: traceId
5453
5505
  }), {
5454
5506
  F: __dxlog_file18,
5455
- L: 311,
5507
+ L: 336,
5456
5508
  S: this,
5457
5509
  C: (f, a) => f(...a)
5458
5510
  });
@@ -5462,60 +5514,62 @@ var ClientServicesHost = class {
5462
5514
  return;
5463
5515
  }
5464
5516
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
5465
- (0, import_log14.log)("closing...", {
5517
+ (0, import_log13.log)("closing...", {
5466
5518
  deviceKey
5467
5519
  }, {
5468
5520
  F: __dxlog_file18,
5469
- L: 322,
5521
+ L: 347,
5470
5522
  S: this,
5471
5523
  C: (f, a) => f(...a)
5472
5524
  });
5525
+ this.diagnosticsBroadcastHandler.stop();
5473
5526
  await this._devtoolsProxy?.close();
5474
5527
  this._serviceRegistry.setServices({
5475
5528
  SystemService: this._systemService
5476
5529
  });
5477
5530
  await this._loggingService.close();
5478
5531
  await this._serviceContext.close();
5532
+ await this._level?.close();
5479
5533
  this._open = false;
5480
5534
  this._statusUpdate.emit();
5481
- (0, import_log14.log)("closed", {
5535
+ (0, import_log13.log)("closed", {
5482
5536
  deviceKey
5483
5537
  }, {
5484
5538
  F: __dxlog_file18,
5485
- L: 329,
5539
+ L: 356,
5486
5540
  S: this,
5487
5541
  C: (f, a) => f(...a)
5488
5542
  });
5489
5543
  }
5490
5544
  async reset() {
5491
5545
  const traceId = import_keys11.PublicKey.random().toHex();
5492
- import_log14.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
5546
+ import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
5493
5547
  id: traceId
5494
5548
  }), {
5495
5549
  F: __dxlog_file18,
5496
- L: 334,
5550
+ L: 361,
5497
5551
  S: this,
5498
5552
  C: (f, a) => f(...a)
5499
5553
  });
5500
- (0, import_log14.log)("resetting...", void 0, {
5554
+ (0, import_log13.log)("resetting...", void 0, {
5501
5555
  F: __dxlog_file18,
5502
- L: 336,
5556
+ L: 363,
5503
5557
  S: this,
5504
5558
  C: (f, a) => f(...a)
5505
5559
  });
5506
5560
  await this._serviceContext?.close();
5507
5561
  await this._storage.reset();
5508
- (0, import_log14.log)("reset", void 0, {
5562
+ (0, import_log13.log)("reset", void 0, {
5509
5563
  F: __dxlog_file18,
5510
- L: 339,
5564
+ L: 366,
5511
5565
  S: this,
5512
5566
  C: (f, a) => f(...a)
5513
5567
  });
5514
- 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({
5515
5569
  id: traceId
5516
5570
  }), {
5517
5571
  F: __dxlog_file18,
5518
- L: 340,
5572
+ L: 367,
5519
5573
  S: this,
5520
5574
  C: (f, a) => f(...a)
5521
5575
  });
@@ -5526,9 +5580,9 @@ var ClientServicesHost = class {
5526
5580
  await this._serviceContext.initialized.wait();
5527
5581
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5528
5582
  const automergeIndex = space.automergeSpaceState.rootUrl;
5529
- (0, import_invariant16.invariant)(automergeIndex, void 0, {
5583
+ (0, import_invariant15.invariant)(automergeIndex, void 0, {
5530
5584
  F: __dxlog_file18,
5531
- L: 352,
5585
+ L: 379,
5532
5586
  S: this,
5533
5587
  A: [
5534
5588
  "automergeIndex",
@@ -5537,47 +5591,88 @@ var ClientServicesHost = class {
5537
5591
  });
5538
5592
  const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5539
5593
  await document.whenReady();
5540
- const objectDocument = (0, import_echo_schema.createRawObjectDoc)({
5541
- [import_client_protocol5.defaultKey]: identity.identityKey.toHex()
5542
- }, {
5543
- type: E.getTypeReference(import_client_protocol5.PropertiesSchema)
5544
- });
5594
+ const properties = {
5595
+ system: {
5596
+ type: (0, import_echo_pipeline5.encodeReference)(E.getTypeReference(import_client_protocol4.Properties))
5597
+ },
5598
+ data: {
5599
+ [import_client_protocol4.defaultKey]: identity.identityKey.toHex()
5600
+ },
5601
+ meta: {
5602
+ keys: []
5603
+ }
5604
+ };
5605
+ const propertiesId = import_keys11.PublicKey.random().toHex();
5545
5606
  document.change((doc) => {
5546
5607
  (0, import_util9.assignDeep)(doc, [
5547
5608
  "objects",
5548
- objectDocument.id
5549
- ], objectDocument.handle.docSync());
5609
+ propertiesId
5610
+ ], properties);
5550
5611
  });
5551
- await (0, import_async16.sleep)(200);
5612
+ await this._serviceContext.automergeHost.repo.flush();
5552
5613
  return identity;
5553
5614
  }
5554
5615
  };
5555
5616
  _ts_decorate8([
5556
- import_tracing7.trace.info()
5617
+ import_tracing8.trace.info()
5557
5618
  ], ClientServicesHost.prototype, "_opening", void 0);
5558
5619
  _ts_decorate8([
5559
- import_tracing7.trace.info()
5620
+ import_tracing8.trace.info()
5560
5621
  ], ClientServicesHost.prototype, "_open", void 0);
5561
5622
  _ts_decorate8([
5562
5623
  import_async16.synchronized,
5563
- import_tracing7.trace.span()
5624
+ import_tracing8.trace.span()
5564
5625
  ], ClientServicesHost.prototype, "open", null);
5565
5626
  _ts_decorate8([
5566
5627
  import_async16.synchronized,
5567
- import_tracing7.trace.span()
5628
+ import_tracing8.trace.span()
5568
5629
  ], ClientServicesHost.prototype, "close", null);
5569
5630
  ClientServicesHost = _ts_decorate8([
5570
- import_tracing7.trace.resource()
5631
+ import_tracing8.trace.resource()
5571
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
+ };
5572
5665
  // Annotate the CommonJS export names for ESM import in node:
5573
5666
  0 && (module.exports = {
5574
5667
  ClientRpcServer,
5575
5668
  ClientServicesHost,
5669
+ ClientServicesProviderResource,
5576
5670
  DataSpace,
5577
5671
  DataSpaceManager,
5578
5672
  DeviceInvitationProtocol,
5579
5673
  DevtoolsHostEvents,
5580
5674
  DevtoolsServiceImpl,
5675
+ DiagnosticsCollector,
5581
5676
  Identity,
5582
5677
  IdentityManager,
5583
5678
  IdentityServiceImpl,
@@ -5590,10 +5685,12 @@ ClientServicesHost = _ts_decorate8([
5590
5685
  SpacesServiceImpl,
5591
5686
  TrustedKeySetAuthVerifier,
5592
5687
  createAuthProvider,
5688
+ createCollectDiagnosticsBroadcastHandler,
5689
+ createCollectDiagnosticsBroadcastSender,
5593
5690
  createDiagnostics,
5691
+ createLevel,
5594
5692
  createStorageObjects,
5595
5693
  getNetworkPeers,
5596
- invitationExpired,
5597
5694
  isLocked,
5598
5695
  subscribeToFeedBlocks,
5599
5696
  subscribeToFeeds,
@@ -5603,4 +5700,4 @@ ClientServicesHost = _ts_decorate8([
5603
5700
  subscribeToSpaces,
5604
5701
  subscribeToSwarmInfo
5605
5702
  });
5606
- //# sourceMappingURL=chunk-GW6EAU3Y.cjs.map
5703
+ //# sourceMappingURL=chunk-HMAV5VTX.cjs.map