@dxos/client-services 0.4.10-main.ec8b427 → 0.4.10-main.eedd150

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 (59) hide show
  1. package/dist/lib/browser/{chunk-4NKBBUMB.mjs → chunk-I6GQX7F3.mjs} +196 -84
  2. package/dist/lib/browser/{chunk-4NKBBUMB.mjs.map → chunk-I6GQX7F3.mjs.map} +4 -4
  3. package/dist/lib/browser/index.mjs +50 -20
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +6 -4
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-5YRLBMIC.cjs → chunk-42TXJ32V.cjs} +195 -88
  9. package/dist/lib/node/chunk-42TXJ32V.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +87 -57
  11. package/dist/lib/node/index.cjs.map +3 -3
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/packlets/testing/index.cjs +10 -8
  14. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  15. package/dist/types/src/packlets/indexing/util.d.ts +2 -2
  16. package/dist/types/src/packlets/indexing/util.d.ts.map +1 -1
  17. package/dist/types/src/packlets/services/service-context.d.ts +3 -1
  18. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/service-host.d.ts +1 -0
  20. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  21. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  22. package/dist/types/src/packlets/storage/index.d.ts +1 -0
  23. package/dist/types/src/packlets/storage/index.d.ts.map +1 -1
  24. package/dist/types/src/packlets/storage/level.d.ts +4 -0
  25. package/dist/types/src/packlets/storage/level.d.ts.map +1 -0
  26. package/dist/types/src/packlets/storage/storage.d.ts.map +1 -1
  27. package/dist/types/src/packlets/storage/util.d.ts +4 -0
  28. package/dist/types/src/packlets/storage/util.d.ts.map +1 -0
  29. package/dist/types/src/packlets/testing/test-builder.d.ts +1 -1
  30. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  31. package/dist/types/src/packlets/vault/shared-worker-connection.d.ts +5 -5
  32. package/dist/types/src/packlets/vault/shared-worker-connection.d.ts.map +1 -1
  33. package/dist/types/src/packlets/vault/worker-runtime.d.ts +2 -0
  34. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  35. package/dist/types/src/packlets/vault/worker-session.d.ts +2 -0
  36. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  37. package/dist/types/src/version.d.ts +1 -1
  38. package/package.json +35 -34
  39. package/src/packlets/devices/devices-service.test.ts +1 -1
  40. package/src/packlets/identity/identity-service.test.ts +1 -1
  41. package/src/packlets/indexing/util.ts +4 -4
  42. package/src/packlets/invitations/device-invitation-protocol.test.ts +1 -1
  43. package/src/packlets/network/network-service.test.ts +1 -1
  44. package/src/packlets/services/service-context.test.ts +5 -5
  45. package/src/packlets/services/service-context.ts +7 -4
  46. package/src/packlets/services/service-host.ts +32 -8
  47. package/src/packlets/services/service-registry.test.ts +1 -1
  48. package/src/packlets/spaces/data-space.ts +51 -2
  49. package/src/packlets/spaces/spaces-service.test.ts +1 -1
  50. package/src/packlets/storage/index.ts +1 -0
  51. package/src/packlets/storage/level.ts +19 -0
  52. package/src/packlets/storage/storage.ts +3 -9
  53. package/src/packlets/storage/util.ts +19 -0
  54. package/src/packlets/testing/test-builder.ts +5 -3
  55. package/src/packlets/vault/shared-worker-connection.ts +3 -8
  56. package/src/packlets/vault/worker-runtime.ts +27 -2
  57. package/src/packlets/vault/worker-session.ts +6 -0
  58. package/src/version.ts +1 -1
  59. package/dist/lib/node/chunk-5YRLBMIC.cjs.map +0 -7
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_5YRLBMIC_exports = {};
30
- __export(chunk_5YRLBMIC_exports, {
29
+ var chunk_42TXJ32V_exports = {};
30
+ __export(chunk_42TXJ32V_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -48,6 +48,7 @@ __export(chunk_5YRLBMIC_exports, {
48
48
  TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
49
49
  createAuthProvider: () => createAuthProvider,
50
50
  createDiagnostics: () => createDiagnostics,
51
+ createLevel: () => createLevel,
51
52
  createStorageObjects: () => createStorageObjects,
52
53
  getNetworkPeers: () => getNetworkPeers,
53
54
  invitationExpired: () => invitationExpired,
@@ -60,7 +61,7 @@ __export(chunk_5YRLBMIC_exports, {
60
61
  subscribeToSpaces: () => subscribeToSpaces,
61
62
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
63
  });
63
- module.exports = __toCommonJS(chunk_5YRLBMIC_exports);
64
+ module.exports = __toCommonJS(chunk_42TXJ32V_exports);
64
65
  var import_async = require("@dxos/async");
65
66
  var import_codec_protobuf = require("@dxos/codec-protobuf");
66
67
  var import_feed_store = require("@dxos/feed-store");
@@ -158,7 +159,9 @@ var import_async10 = require("@dxos/async");
158
159
  var import_client_protocol3 = require("@dxos/client-protocol");
159
160
  var import_context7 = require("@dxos/context");
160
161
  var import_debug3 = require("@dxos/debug");
162
+ var import_echo_db = require("@dxos/echo-db");
161
163
  var import_echo_pipeline = require("@dxos/echo-pipeline");
164
+ var import_echo_pipeline2 = require("@dxos/echo-pipeline");
162
165
  var import_invariant10 = require("@dxos/invariant");
163
166
  var import_keys7 = require("@dxos/keys");
164
167
  var import_log8 = require("@dxos/log");
@@ -203,7 +206,7 @@ var import_async15 = require("@dxos/async");
203
206
  var import_context10 = require("@dxos/context");
204
207
  var import_credentials15 = require("@dxos/credentials");
205
208
  var import_debug6 = require("@dxos/debug");
206
- var import_echo_pipeline2 = require("@dxos/echo-pipeline");
209
+ var import_echo_pipeline3 = require("@dxos/echo-pipeline");
207
210
  var import_feed_store4 = require("@dxos/feed-store");
208
211
  var import_indexing = require("@dxos/indexing");
209
212
  var import_invariant14 = require("@dxos/invariant");
@@ -221,19 +224,23 @@ var import_protocols13 = require("@dxos/protocols");
221
224
  var import_invariant15 = require("@dxos/invariant");
222
225
  var import_lock_file = require("@dxos/lock-file");
223
226
  var import_log13 = require("@dxos/log");
224
- var import_client_protocol4 = require("@dxos/client-protocol");
225
227
  var import_protocols14 = require("@dxos/protocols");
226
228
  var import_config = require("@dxos/protocols/proto/dxos/config");
227
229
  var import_random_access_storage = require("@dxos/random-access-storage");
230
+ var import_client_protocol4 = require("@dxos/client-protocol");
231
+ var import_config2 = require("@dxos/protocols/proto/dxos/config");
228
232
  var import_util8 = require("@dxos/util");
233
+ var import_level = require("level");
234
+ var import_node_path = __toESM(require("node:path"));
235
+ var import_keys11 = require("@dxos/keys");
229
236
  var import_async16 = require("@dxos/async");
230
237
  var import_client_protocol5 = require("@dxos/client-protocol");
231
238
  var import_context11 = require("@dxos/context");
232
- var import_echo_pipeline3 = require("@dxos/echo-pipeline");
233
- var import_echo_schema = require("@dxos/echo-schema");
239
+ var import_echo_pipeline4 = require("@dxos/echo-pipeline");
240
+ var E = __toESM(require("@dxos/echo-schema"));
234
241
  var import_indexing2 = require("@dxos/indexing");
235
242
  var import_invariant16 = require("@dxos/invariant");
236
- var import_keys11 = require("@dxos/keys");
243
+ var import_keys12 = require("@dxos/keys");
237
244
  var import_log14 = require("@dxos/log");
238
245
  var import_messaging = require("@dxos/messaging");
239
246
  var import_network_manager2 = require("@dxos/network-manager");
@@ -248,7 +255,7 @@ var import_invariant17 = require("@dxos/invariant");
248
255
  var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
249
256
  var import_async18 = require("@dxos/async");
250
257
  var import_codec_protobuf13 = require("@dxos/codec-protobuf");
251
- var import_keys12 = require("@dxos/keys");
258
+ var import_keys13 = require("@dxos/keys");
252
259
  var import_log15 = require("@dxos/log");
253
260
  var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
254
261
  var import_util10 = require("@dxos/util");
@@ -2884,7 +2891,7 @@ var getPlatform = () => {
2884
2891
  };
2885
2892
  }
2886
2893
  };
2887
- var DXOS_VERSION = "0.4.10-main.ec8b427";
2894
+ var DXOS_VERSION = "0.4.10-main.eedd150";
2888
2895
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2889
2896
  var DEFAULT_TIMEOUT = 1e3;
2890
2897
  var createDiagnostics = async (clientServices, serviceContext, config) => {
@@ -3326,7 +3333,7 @@ var DataSpace = class {
3326
3333
  state: import_services9.SpaceState[this._state]
3327
3334
  }, {
3328
3335
  F: __dxlog_file12,
3329
- L: 132,
3336
+ L: 140,
3330
3337
  S: this,
3331
3338
  C: (f, a) => f(...a)
3332
3339
  });
@@ -3376,7 +3383,7 @@ var DataSpace = class {
3376
3383
  state: import_services9.SpaceState[this._state]
3377
3384
  }, {
3378
3385
  F: __dxlog_file12,
3379
- L: 190,
3386
+ L: 198,
3380
3387
  S: this,
3381
3388
  C: (f, a) => f(...a)
3382
3389
  });
@@ -3394,7 +3401,7 @@ var DataSpace = class {
3394
3401
  state: import_services9.SpaceState[this._state]
3395
3402
  }, {
3396
3403
  F: __dxlog_file12,
3397
- L: 204,
3404
+ L: 212,
3398
3405
  S: this,
3399
3406
  C: (f, a) => f(...a)
3400
3407
  });
@@ -3426,7 +3433,7 @@ var DataSpace = class {
3426
3433
  if (err instanceof import_protocols8.CancelledError || err instanceof import_context7.ContextDisposedError) {
3427
3434
  (0, import_log8.log)("data pipeline initialization cancelled", err, {
3428
3435
  F: __dxlog_file12,
3429
- L: 237,
3436
+ L: 245,
3430
3437
  S: this,
3431
3438
  C: (f, a) => f(...a)
3432
3439
  });
@@ -3434,7 +3441,7 @@ var DataSpace = class {
3434
3441
  }
3435
3442
  import_log8.log.error("Error initializing data pipeline", err, {
3436
3443
  F: __dxlog_file12,
3437
- L: 241,
3444
+ L: 249,
3438
3445
  S: this,
3439
3446
  C: (f, a) => f(...a)
3440
3447
  });
@@ -3443,7 +3450,7 @@ var DataSpace = class {
3443
3450
  state: import_services9.SpaceState[this._state]
3444
3451
  }, {
3445
3452
  F: __dxlog_file12,
3446
- L: 243,
3453
+ L: 251,
3447
3454
  S: this,
3448
3455
  C: (f, a) => f(...a)
3449
3456
  });
@@ -3463,7 +3470,7 @@ var DataSpace = class {
3463
3470
  state: import_services9.SpaceState[this._state]
3464
3471
  }, {
3465
3472
  F: __dxlog_file12,
3466
- L: 259,
3473
+ L: 267,
3467
3474
  S: this,
3468
3475
  C: (f, a) => f(...a)
3469
3476
  });
@@ -3473,7 +3480,7 @@ var DataSpace = class {
3473
3480
  await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
3474
3481
  (0, import_log8.log)("data pipeline ready", void 0, {
3475
3482
  F: __dxlog_file12,
3476
- L: 271,
3483
+ L: 279,
3477
3484
  S: this,
3478
3485
  C: (f, a) => f(...a)
3479
3486
  });
@@ -3483,7 +3490,7 @@ var DataSpace = class {
3483
3490
  state: import_services9.SpaceState[this._state]
3484
3491
  }, {
3485
3492
  F: __dxlog_file12,
3486
- L: 275,
3493
+ L: 283,
3487
3494
  S: this,
3488
3495
  C: (f, a) => f(...a)
3489
3496
  });
@@ -3499,7 +3506,7 @@ var DataSpace = class {
3499
3506
  await this._createWritableFeeds();
3500
3507
  (0, import_log8.log)("writable feeds created", void 0, {
3501
3508
  F: __dxlog_file12,
3502
- L: 291,
3509
+ L: 299,
3503
3510
  S: this,
3504
3511
  C: (f, a) => f(...a)
3505
3512
  });
@@ -3562,7 +3569,7 @@ var DataSpace = class {
3562
3569
  rootUrl
3563
3570
  }, {
3564
3571
  F: __dxlog_file12,
3565
- L: 357,
3572
+ L: 365,
3566
3573
  S: this,
3567
3574
  C: (f, a) => f(...a)
3568
3575
  });
@@ -3594,7 +3601,7 @@ var DataSpace = class {
3594
3601
  err
3595
3602
  }, {
3596
3603
  F: __dxlog_file12,
3597
- L: 380,
3604
+ L: 388,
3598
3605
  S: this,
3599
3606
  C: (f, a) => f(...a)
3600
3607
  });
@@ -3649,7 +3656,7 @@ var DataSpace = class {
3649
3656
  const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
3650
3657
  (0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3651
3658
  F: __dxlog_file12,
3652
- L: 430,
3659
+ L: 438,
3653
3660
  S: this,
3654
3661
  A: [
3655
3662
  "typeof newRoot.url === 'string' && newRoot.url.length > 0",
@@ -3664,6 +3671,66 @@ var DataSpace = class {
3664
3671
  };
3665
3672
  }
3666
3673
  break;
3674
+ case import_services9.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
3675
+ {
3676
+ import_log8.log.info("Fragmenting", void 0, {
3677
+ F: __dxlog_file12,
3678
+ L: 450,
3679
+ S: this,
3680
+ C: (f, a) => f(...a)
3681
+ });
3682
+ const currentRootUrl = this._automergeSpaceState.rootUrl;
3683
+ const rootHandle = this._automergeHost.repo.find(currentRootUrl);
3684
+ await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
3685
+ const objects = Object.entries(rootHandle.docSync().objects);
3686
+ const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_db.TYPE_PROPERTIES);
3687
+ const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
3688
+ (0, import_invariant10.invariant)(properties, "Properties not found", {
3689
+ F: __dxlog_file12,
3690
+ L: 460,
3691
+ S: this,
3692
+ A: [
3693
+ "properties",
3694
+ "'Properties not found'"
3695
+ ]
3696
+ });
3697
+ const newSpaceDoc = {
3698
+ ...rootHandle.docSync(),
3699
+ objects: Object.fromEntries([
3700
+ properties
3701
+ ])
3702
+ };
3703
+ const newRoot = this._automergeHost.repo.create(newSpaceDoc);
3704
+ (0, import_invariant10.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
3705
+ F: __dxlog_file12,
3706
+ L: 465,
3707
+ S: this,
3708
+ A: [
3709
+ "typeof newRoot.url === 'string' && newRoot.url.length > 0",
3710
+ ""
3711
+ ]
3712
+ });
3713
+ const docLoader = new import_echo_pipeline2.AutomergeDocumentLoaderImpl(this.key, this._automergeHost.repo);
3714
+ await docLoader.loadSpaceRootDocHandle(this._ctx, {
3715
+ rootUrl: newRoot.url
3716
+ });
3717
+ otherObjects.forEach(([key, value]) => {
3718
+ const handle = docLoader.createDocumentForObject(key);
3719
+ handle.change((doc) => {
3720
+ (0, import_util4.assignDeep)(doc, [
3721
+ "objects",
3722
+ key
3723
+ ], value);
3724
+ });
3725
+ });
3726
+ epoch = {
3727
+ previousId: this._automergeSpaceState.lastEpoch?.id,
3728
+ number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
3729
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
3730
+ automergeRoot: newRoot.url
3731
+ };
3732
+ }
3733
+ break;
3667
3734
  }
3668
3735
  if (!epoch) {
3669
3736
  return;
@@ -3705,7 +3772,7 @@ var DataSpace = class {
3705
3772
  state: import_services9.SpaceState[this._state]
3706
3773
  }, {
3707
3774
  F: __dxlog_file12,
3708
- L: 482,
3775
+ L: 531,
3709
3776
  S: this,
3710
3777
  C: (f, a) => f(...a)
3711
3778
  });
@@ -4369,7 +4436,7 @@ var SpacesServiceImpl = class {
4369
4436
  }
4370
4437
  };
4371
4438
  var getChannelId = (channel) => `user-channel/${channel}`;
4372
- var createLoadDocuments = (automergeHost) => (
4439
+ var createSelectedDocumentsIterator = (automergeHost) => (
4373
4440
  /**
4374
4441
  * Get object data blobs from Automerge Repo by ids.
4375
4442
  * @param ids
@@ -4382,17 +4449,17 @@ var createLoadDocuments = (automergeHost) => (
4382
4449
  await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
4383
4450
  const doc = handle.docSync();
4384
4451
  const hash = (0, import_automerge.getHeads)(doc).join("");
4385
- yield [
4452
+ yield doc.objects?.[objectId] ? [
4386
4453
  {
4387
4454
  id,
4388
4455
  object: doc.objects[objectId],
4389
4456
  currentHash: hash
4390
4457
  }
4391
- ];
4458
+ ] : [];
4392
4459
  }
4393
4460
  }
4394
4461
  );
4395
- var createGetAllDocuments = (automergeHost) => (
4462
+ var createDocumentsIterator = (automergeHost) => (
4396
4463
  /**
4397
4464
  * Recursively get all object data blobs from Automerge Repo.
4398
4465
  * @param ids
@@ -4415,7 +4482,7 @@ var createGetAllDocuments = (automergeHost) => (
4415
4482
  objectId
4416
4483
  }),
4417
4484
  object,
4418
- currentHash: heads.at(-1)
4485
+ currentHash: heads.join("")
4419
4486
  };
4420
4487
  });
4421
4488
  }
@@ -4455,16 +4522,17 @@ function _ts_decorate6(decorators, target, key, desc) {
4455
4522
  }
4456
4523
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
4457
4524
  var ServiceContext = class {
4458
- constructor(storage, networkManager, signalManager, _runtimeParams) {
4525
+ constructor(storage, level, networkManager, signalManager, _runtimeParams) {
4459
4526
  this.storage = storage;
4527
+ this.level = level;
4460
4528
  this.networkManager = networkManager;
4461
4529
  this.signalManager = signalManager;
4462
4530
  this._runtimeParams = _runtimeParams;
4463
4531
  this.initialized = new import_async15.Trigger();
4464
4532
  this._handlerFactories = /* @__PURE__ */ new Map();
4465
4533
  this._instanceId = import_keys10.PublicKey.random().toHex();
4466
- this.metadataStore = new import_echo_pipeline2.MetadataStore(storage.createDirectory("metadata"));
4467
- this.snapshotStore = new import_echo_pipeline2.SnapshotStore(storage.createDirectory("snapshots"));
4534
+ this.metadataStore = new import_echo_pipeline3.MetadataStore(storage.createDirectory("metadata"));
4535
+ this.snapshotStore = new import_echo_pipeline3.SnapshotStore(storage.createDirectory("snapshots"));
4468
4536
  this.blobStore = new import_teleport_extension_object_sync.BlobStore(storage.createDirectory("blobs"));
4469
4537
  this.keyring = new import_keyring.Keyring(storage.createDirectory("keyring"));
4470
4538
  this.feedStore = new import_feed_store4.FeedStore({
@@ -4472,12 +4540,12 @@ var ServiceContext = class {
4472
4540
  root: storage.createDirectory("feeds"),
4473
4541
  signer: this.keyring,
4474
4542
  hypercore: {
4475
- valueEncoding: import_echo_pipeline2.valueEncoding,
4543
+ valueEncoding: import_echo_pipeline3.valueEncoding,
4476
4544
  stats: true
4477
4545
  }
4478
4546
  })
4479
4547
  });
4480
- this.spaceManager = new import_echo_pipeline2.SpaceManager({
4548
+ this.spaceManager = new import_echo_pipeline3.SpaceManager({
4481
4549
  feedStore: this.feedStore,
4482
4550
  networkManager: this.networkManager,
4483
4551
  blobStore: this.blobStore,
@@ -4486,9 +4554,9 @@ var ServiceContext = class {
4486
4554
  });
4487
4555
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager, this._runtimeParams);
4488
4556
  this.indexMetadata = new import_indexing.IndexMetadataStore({
4489
- directory: storage.createDirectory("index-metadata")
4557
+ db: level.sublevel("index-metadata")
4490
4558
  });
4491
- this.automergeHost = new import_echo_pipeline2.AutomergeHost({
4559
+ this.automergeHost = new import_echo_pipeline3.AutomergeHost({
4492
4560
  directory: storage.createDirectory("automerge"),
4493
4561
  metadata: this.indexMetadata
4494
4562
  });
@@ -4497,8 +4565,8 @@ var ServiceContext = class {
4497
4565
  directory: storage.createDirectory("index-store")
4498
4566
  }),
4499
4567
  metadataStore: this.indexMetadata,
4500
- loadDocuments: createLoadDocuments(this.automergeHost),
4501
- getAllDocuments: createGetAllDocuments(this.automergeHost)
4568
+ loadDocuments: createSelectedDocumentsIterator(this.automergeHost),
4569
+ getAllDocuments: createDocumentsIterator(this.automergeHost)
4502
4570
  });
4503
4571
  this.invitations = new InvitationsHandler(this.networkManager);
4504
4572
  this._handlerFactories.set(import_services12.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
@@ -4507,7 +4575,7 @@ var ServiceContext = class {
4507
4575
  await this._checkStorageVersion();
4508
4576
  (0, import_log12.log)("opening...", void 0, {
4509
4577
  F: __dxlog_file15,
4510
- L: 151,
4578
+ L: 154,
4511
4579
  S: this,
4512
4580
  C: (f, a) => f(...a)
4513
4581
  });
@@ -4515,7 +4583,7 @@ var ServiceContext = class {
4515
4583
  id: this._instanceId
4516
4584
  }), {
4517
4585
  F: __dxlog_file15,
4518
- L: 152,
4586
+ L: 155,
4519
4587
  S: this,
4520
4588
  C: (f, a) => f(...a)
4521
4589
  });
@@ -4531,13 +4599,13 @@ var ServiceContext = class {
4531
4599
  id: this._instanceId
4532
4600
  }), {
4533
4601
  F: __dxlog_file15,
4534
- L: 162,
4602
+ L: 165,
4535
4603
  S: this,
4536
4604
  C: (f, a) => f(...a)
4537
4605
  });
4538
4606
  (0, import_log12.log)("opened", void 0, {
4539
4607
  F: __dxlog_file15,
4540
- L: 163,
4608
+ L: 166,
4541
4609
  S: this,
4542
4610
  C: (f, a) => f(...a)
4543
4611
  });
@@ -4545,7 +4613,7 @@ var ServiceContext = class {
4545
4613
  async close() {
4546
4614
  (0, import_log12.log)("closing...", void 0, {
4547
4615
  F: __dxlog_file15,
4548
- L: 167,
4616
+ L: 170,
4549
4617
  S: this,
4550
4618
  C: (f, a) => f(...a)
4551
4619
  });
@@ -4563,7 +4631,7 @@ var ServiceContext = class {
4563
4631
  await this.indexer.destroy();
4564
4632
  (0, import_log12.log)("closed", void 0, {
4565
4633
  F: __dxlog_file15,
4566
- L: 180,
4634
+ L: 183,
4567
4635
  S: this,
4568
4636
  C: (f, a) => f(...a)
4569
4637
  });
@@ -4577,7 +4645,7 @@ var ServiceContext = class {
4577
4645
  const factory = this._handlerFactories.get(invitation.kind);
4578
4646
  (0, import_invariant14.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4579
4647
  F: __dxlog_file15,
4580
- L: 191,
4648
+ L: 194,
4581
4649
  S: this,
4582
4650
  A: [
4583
4651
  "factory",
@@ -4609,7 +4677,7 @@ var ServiceContext = class {
4609
4677
  async _initialize(ctx) {
4610
4678
  (0, import_log12.log)("initializing spaces...", void 0, {
4611
4679
  F: __dxlog_file15,
4612
- L: 222,
4680
+ L: 225,
4613
4681
  S: this,
4614
4682
  C: (f, a) => f(...a)
4615
4683
  });
@@ -4632,7 +4700,7 @@ var ServiceContext = class {
4632
4700
  this._handlerFactories.set(import_services12.Invitation.Kind.SPACE, (invitation) => {
4633
4701
  (0, import_invariant14.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4634
4702
  F: __dxlog_file15,
4635
- L: 246,
4703
+ L: 249,
4636
4704
  S: this,
4637
4705
  A: [
4638
4706
  "this.dataSpaceManager",
@@ -4656,7 +4724,7 @@ var ServiceContext = class {
4656
4724
  details: assertion
4657
4725
  }, {
4658
4726
  F: __dxlog_file15,
4659
- L: 262,
4727
+ L: 265,
4660
4728
  S: this,
4661
4729
  C: (f, a) => f(...a)
4662
4730
  });
@@ -4667,7 +4735,7 @@ var ServiceContext = class {
4667
4735
  details: assertion
4668
4736
  }, {
4669
4737
  F: __dxlog_file15,
4670
- L: 266,
4738
+ L: 269,
4671
4739
  S: this,
4672
4740
  C: (f, a) => f(...a)
4673
4741
  });
@@ -4678,7 +4746,7 @@ var ServiceContext = class {
4678
4746
  details: assertion
4679
4747
  }, {
4680
4748
  F: __dxlog_file15,
4681
- L: 271,
4749
+ L: 274,
4682
4750
  S: this,
4683
4751
  C: (f, a) => f(...a)
4684
4752
  });
@@ -4689,7 +4757,7 @@ var ServiceContext = class {
4689
4757
  } catch (err) {
4690
4758
  import_log12.log.catch(err, void 0, {
4691
4759
  F: __dxlog_file15,
4692
- L: 277,
4760
+ L: 280,
4693
4761
  S: this,
4694
4762
  C: (f, a) => f(...a)
4695
4763
  });
@@ -4785,9 +4853,17 @@ _ts_decorate7([
4785
4853
  import_log13.logInfo
4786
4854
  ], Lock.prototype, "lockKey", null);
4787
4855
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
4856
+ var getRootPath = (config) => {
4857
+ const { dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
4858
+ return `${dataRoot}/`;
4859
+ };
4860
+ var isPersistent = (config) => {
4861
+ const { persistent = false } = config ?? {};
4862
+ return config.dataStore !== void 0 && config.dataStore !== import_config2.Runtime.Client.Storage.StorageDriver.RAM || persistent;
4863
+ };
4788
4864
  var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
4789
4865
  var createStorageObjects = (config) => {
4790
- const { persistent = false, keyStore, dataStore, dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
4866
+ const { persistent = false, keyStore, dataStore } = config ?? {};
4791
4867
  if (persistent && dataStore === StorageDriver.RAM) {
4792
4868
  throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
4793
4869
  }
@@ -4803,7 +4879,7 @@ var createStorageObjects = (config) => {
4803
4879
  return {
4804
4880
  storage: (0, import_random_access_storage.createStorage)({
4805
4881
  type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
4806
- root: `${dataRoot}/`
4882
+ root: getRootPath(config)
4807
4883
  })
4808
4884
  };
4809
4885
  };
@@ -4827,6 +4903,13 @@ var toStorageType = (type) => {
4827
4903
  throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
4828
4904
  }
4829
4905
  };
4906
+ var createLevel = async (config) => {
4907
+ const persistent = isPersistent(config);
4908
+ const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys11.PublicKey.random().toHex());
4909
+ const level = new import_level.Level(storagePath);
4910
+ await level.open();
4911
+ return level;
4912
+ };
4830
4913
  var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
4831
4914
  var DevicesServiceImpl = class {
4832
4915
  constructor(_identityManager) {
@@ -4907,7 +4990,7 @@ var LoggingServiceImpl = class {
4907
4990
  constructor() {
4908
4991
  this._logs = new import_async18.Event();
4909
4992
  this._started = Date.now();
4910
- this._sessionId = import_keys12.PublicKey.random().toHex();
4993
+ this._sessionId = import_keys13.PublicKey.random().toHex();
4911
4994
  this._logProcessor = (_config, entry2) => {
4912
4995
  this._logs.emit(entry2);
4913
4996
  };
@@ -5002,12 +5085,12 @@ var LoggingServiceImpl = class {
5002
5085
  });
5003
5086
  }
5004
5087
  };
5005
- var matchFilter = (filter, level, path, options) => {
5088
+ var matchFilter = (filter, level, path2, options) => {
5006
5089
  switch (options) {
5007
5090
  case import_services15.QueryLogsRequest.MatchingOptions.INCLUSIVE:
5008
- return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
5091
+ return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
5009
5092
  case import_services15.QueryLogsRequest.MatchingOptions.EXPLICIT:
5010
- return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
5093
+ return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
5011
5094
  }
5012
5095
  };
5013
5096
  var shouldLog = (entry2, request) => {
@@ -5198,7 +5281,7 @@ var ClientServicesHost = class {
5198
5281
  initialize({ config, ...options }) {
5199
5282
  (0, import_invariant16.invariant)(!this._open, "service host is open", {
5200
5283
  F: __dxlog_file18,
5201
- L: 179,
5284
+ L: 182,
5202
5285
  S: this,
5203
5286
  A: [
5204
5287
  "!this._open",
@@ -5207,14 +5290,14 @@ var ClientServicesHost = class {
5207
5290
  });
5208
5291
  (0, import_log14.log)("initializing...", void 0, {
5209
5292
  F: __dxlog_file18,
5210
- L: 180,
5293
+ L: 183,
5211
5294
  S: this,
5212
5295
  C: (f, a) => f(...a)
5213
5296
  });
5214
5297
  if (config) {
5215
5298
  (0, import_invariant16.invariant)(!this._config, "config already set", {
5216
5299
  F: __dxlog_file18,
5217
- L: 183,
5300
+ L: 186,
5218
5301
  S: this,
5219
5302
  A: [
5220
5303
  "!this._config",
@@ -5226,13 +5309,21 @@ var ClientServicesHost = class {
5226
5309
  this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
5227
5310
  }
5228
5311
  }
5312
+ if (!options.signalManager) {
5313
+ import_log14.log.warn("running signaling without telemetry metadata.", void 0, {
5314
+ F: __dxlog_file18,
5315
+ L: 194,
5316
+ S: this,
5317
+ C: (f, a) => f(...a)
5318
+ });
5319
+ }
5229
5320
  const { connectionLog = true, transportFactory = (0, import_network_manager2.createSimplePeerTransportFactory)({
5230
5321
  iceServers: this._config?.get("runtime.services.ice")
5231
5322
  }), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
5232
5323
  this._signalManager = signalManager;
5233
5324
  (0, import_invariant16.invariant)(!this._networkManager, "network manager already set", {
5234
5325
  F: __dxlog_file18,
5235
- L: 199,
5326
+ L: 205,
5236
5327
  S: this,
5237
5328
  A: [
5238
5329
  "!this._networkManager",
@@ -5246,7 +5337,7 @@ var ClientServicesHost = class {
5246
5337
  });
5247
5338
  (0, import_log14.log)("initialized", void 0, {
5248
5339
  F: __dxlog_file18,
5249
- L: 206,
5340
+ L: 212,
5250
5341
  S: this,
5251
5342
  C: (f, a) => f(...a)
5252
5343
  });
@@ -5255,18 +5346,18 @@ var ClientServicesHost = class {
5255
5346
  if (this._open) {
5256
5347
  return;
5257
5348
  }
5258
- const traceId = import_keys11.PublicKey.random().toHex();
5349
+ const traceId = import_keys12.PublicKey.random().toHex();
5259
5350
  import_log14.log.trace("dxos.client-services.host.open", import_protocols15.trace.begin({
5260
5351
  id: traceId
5261
5352
  }), {
5262
5353
  F: __dxlog_file18,
5263
- L: 217,
5354
+ L: 223,
5264
5355
  S: this,
5265
5356
  C: (f, a) => f(...a)
5266
5357
  });
5267
5358
  (0, import_invariant16.invariant)(this._config, "config not set", {
5268
5359
  F: __dxlog_file18,
5269
- L: 219,
5360
+ L: 225,
5270
5361
  S: this,
5271
5362
  A: [
5272
5363
  "this._config",
@@ -5275,7 +5366,7 @@ var ClientServicesHost = class {
5275
5366
  });
5276
5367
  (0, import_invariant16.invariant)(this._storage, "storage not set", {
5277
5368
  F: __dxlog_file18,
5278
- L: 220,
5369
+ L: 226,
5279
5370
  S: this,
5280
5371
  A: [
5281
5372
  "this._storage",
@@ -5284,7 +5375,7 @@ var ClientServicesHost = class {
5284
5375
  });
5285
5376
  (0, import_invariant16.invariant)(this._signalManager, "signal manager not set", {
5286
5377
  F: __dxlog_file18,
5287
- L: 221,
5378
+ L: 227,
5288
5379
  S: this,
5289
5380
  A: [
5290
5381
  "this._signalManager",
@@ -5293,7 +5384,7 @@ var ClientServicesHost = class {
5293
5384
  });
5294
5385
  (0, import_invariant16.invariant)(this._networkManager, "network manager not set", {
5295
5386
  F: __dxlog_file18,
5296
- L: 222,
5387
+ L: 228,
5297
5388
  S: this,
5298
5389
  A: [
5299
5390
  "this._networkManager",
@@ -5305,13 +5396,16 @@ var ClientServicesHost = class {
5305
5396
  lockKey: this._resourceLock?.lockKey
5306
5397
  }, {
5307
5398
  F: __dxlog_file18,
5308
- L: 225,
5399
+ L: 231,
5309
5400
  S: this,
5310
5401
  C: (f, a) => f(...a)
5311
5402
  });
5403
+ if (!this._level) {
5404
+ this._level = await createLevel(this._config.get("runtime.client.storage", {}));
5405
+ }
5312
5406
  await this._resourceLock?.acquire();
5313
5407
  await this._loggingService.open();
5314
- this._serviceContext = new ServiceContext(this._storage, this._networkManager, this._signalManager, this._runtimeParams);
5408
+ this._serviceContext = new ServiceContext(this._storage, this._level, this._networkManager, this._signalManager, this._runtimeParams);
5315
5409
  this._serviceRegistry.setServices({
5316
5410
  SystemService: this._systemService,
5317
5411
  IdentityService: new IdentityServiceImpl((params) => this._createIdentity(params), this._serviceContext.identityManager, this._serviceContext.keyring, (profile) => this._serviceContext.broadcastProfileUpdate(profile)),
@@ -5321,7 +5415,7 @@ var ClientServicesHost = class {
5321
5415
  await this._serviceContext.initialized.wait();
5322
5416
  return this._serviceContext.dataSpaceManager;
5323
5417
  }),
5324
- DataService: new import_echo_pipeline3.DataServiceImpl(this._serviceContext.automergeHost),
5418
+ DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.automergeHost),
5325
5419
  IndexService: new import_indexing2.IndexServiceImpl({
5326
5420
  indexer: this._serviceContext.indexer,
5327
5421
  automergeHost: this._serviceContext.automergeHost
@@ -5339,7 +5433,7 @@ var ClientServicesHost = class {
5339
5433
  await this._serviceContext.open(ctx);
5340
5434
  (0, import_invariant16.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
5341
5435
  F: __dxlog_file18,
5342
- L: 286,
5436
+ L: 297,
5343
5437
  S: this,
5344
5438
  A: [
5345
5439
  "this.serviceRegistry.services.InvitationsService",
@@ -5351,7 +5445,7 @@ var ClientServicesHost = class {
5351
5445
  count: loadedInvitations.invitations?.length
5352
5446
  }, {
5353
5447
  F: __dxlog_file18,
5354
- L: 289,
5448
+ L: 300,
5355
5449
  S: this,
5356
5450
  C: (f, a) => f(...a)
5357
5451
  });
@@ -5373,7 +5467,7 @@ var ClientServicesHost = class {
5373
5467
  deviceKey
5374
5468
  }, {
5375
5469
  F: __dxlog_file18,
5376
- L: 306,
5470
+ L: 317,
5377
5471
  S: this,
5378
5472
  C: (f, a) => f(...a)
5379
5473
  });
@@ -5381,7 +5475,7 @@ var ClientServicesHost = class {
5381
5475
  id: traceId
5382
5476
  }), {
5383
5477
  F: __dxlog_file18,
5384
- L: 307,
5478
+ L: 318,
5385
5479
  S: this,
5386
5480
  C: (f, a) => f(...a)
5387
5481
  });
@@ -5395,7 +5489,7 @@ var ClientServicesHost = class {
5395
5489
  deviceKey
5396
5490
  }, {
5397
5491
  F: __dxlog_file18,
5398
- L: 318,
5492
+ L: 329,
5399
5493
  S: this,
5400
5494
  C: (f, a) => f(...a)
5401
5495
  });
@@ -5405,30 +5499,31 @@ var ClientServicesHost = class {
5405
5499
  });
5406
5500
  await this._loggingService.close();
5407
5501
  await this._serviceContext.close();
5502
+ await this._level?.close();
5408
5503
  this._open = false;
5409
5504
  this._statusUpdate.emit();
5410
5505
  (0, import_log14.log)("closed", {
5411
5506
  deviceKey
5412
5507
  }, {
5413
5508
  F: __dxlog_file18,
5414
- L: 325,
5509
+ L: 337,
5415
5510
  S: this,
5416
5511
  C: (f, a) => f(...a)
5417
5512
  });
5418
5513
  }
5419
5514
  async reset() {
5420
- const traceId = import_keys11.PublicKey.random().toHex();
5515
+ const traceId = import_keys12.PublicKey.random().toHex();
5421
5516
  import_log14.log.trace("dxos.sdk.client-services-host.reset", import_protocols15.trace.begin({
5422
5517
  id: traceId
5423
5518
  }), {
5424
5519
  F: __dxlog_file18,
5425
- L: 330,
5520
+ L: 342,
5426
5521
  S: this,
5427
5522
  C: (f, a) => f(...a)
5428
5523
  });
5429
5524
  (0, import_log14.log)("resetting...", void 0, {
5430
5525
  F: __dxlog_file18,
5431
- L: 332,
5526
+ L: 344,
5432
5527
  S: this,
5433
5528
  C: (f, a) => f(...a)
5434
5529
  });
@@ -5436,7 +5531,7 @@ var ClientServicesHost = class {
5436
5531
  await this._storage.reset();
5437
5532
  (0, import_log14.log)("reset", void 0, {
5438
5533
  F: __dxlog_file18,
5439
- L: 335,
5534
+ L: 347,
5440
5535
  S: this,
5441
5536
  C: (f, a) => f(...a)
5442
5537
  });
@@ -5444,7 +5539,7 @@ var ClientServicesHost = class {
5444
5539
  id: traceId
5445
5540
  }), {
5446
5541
  F: __dxlog_file18,
5447
- L: 336,
5542
+ L: 348,
5448
5543
  S: this,
5449
5544
  C: (f, a) => f(...a)
5450
5545
  });
@@ -5454,12 +5549,10 @@ var ClientServicesHost = class {
5454
5549
  const identity = await this._serviceContext.createIdentity(params);
5455
5550
  await this._serviceContext.initialized.wait();
5456
5551
  const space = await this._serviceContext.dataSpaceManager.createSpace();
5457
- const obj = new import_client_protocol5.Properties(void 0);
5458
- obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
5459
5552
  const automergeIndex = space.automergeSpaceState.rootUrl;
5460
5553
  (0, import_invariant16.invariant)(automergeIndex, void 0, {
5461
5554
  F: __dxlog_file18,
5462
- L: 351,
5555
+ L: 360,
5463
5556
  S: this,
5464
5557
  A: [
5465
5558
  "automergeIndex",
@@ -5468,12 +5561,25 @@ var ClientServicesHost = class {
5468
5561
  });
5469
5562
  const document = await this._serviceContext.automergeHost.repo.find(automergeIndex);
5470
5563
  await document.whenReady();
5564
+ const properties = {
5565
+ system: {
5566
+ type: (0, import_echo_pipeline4.encodeReference)(E.getTypeReference(import_client_protocol5.Properties))
5567
+ },
5568
+ data: {
5569
+ [import_client_protocol5.defaultKey]: identity.identityKey.toHex()
5570
+ },
5571
+ meta: {
5572
+ keys: []
5573
+ }
5574
+ };
5575
+ const propertiesId = import_keys12.PublicKey.random().toHex();
5471
5576
  document.change((doc) => {
5472
5577
  (0, import_util9.assignDeep)(doc, [
5473
5578
  "objects",
5474
- (0, import_echo_schema.getAutomergeObjectCore)(obj).id
5475
- ], (0, import_echo_schema.getRawDoc)(obj).handle.docSync());
5579
+ propertiesId
5580
+ ], properties);
5476
5581
  });
5582
+ await this._serviceContext.automergeHost.repo.flush();
5477
5583
  return identity;
5478
5584
  }
5479
5585
  };
@@ -5516,6 +5622,7 @@ ClientServicesHost = _ts_decorate8([
5516
5622
  TrustedKeySetAuthVerifier,
5517
5623
  createAuthProvider,
5518
5624
  createDiagnostics,
5625
+ createLevel,
5519
5626
  createStorageObjects,
5520
5627
  getNetworkPeers,
5521
5628
  invitationExpired,
@@ -5528,4 +5635,4 @@ ClientServicesHost = _ts_decorate8([
5528
5635
  subscribeToSpaces,
5529
5636
  subscribeToSwarmInfo
5530
5637
  });
5531
- //# sourceMappingURL=chunk-5YRLBMIC.cjs.map
5638
+ //# sourceMappingURL=chunk-42TXJ32V.cjs.map