@dxos/client-services 0.1.56-main.be59a09 → 0.1.56-main.c19b7cd

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 (47) hide show
  1. package/dist/lib/browser/{chunk-K67JOICT.mjs → chunk-ZOTHWLK5.mjs} +228 -149
  2. package/dist/lib/browser/chunk-ZOTHWLK5.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +14 -12
  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 +2 -2
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +223 -142
  9. package/dist/lib/node/index.cjs.map +3 -3
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +210 -131
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -1
  14. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity.d.ts +3 -2
  16. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  17. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  18. package/dist/types/src/packlets/services/service-context.d.ts +2 -1
  19. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/service-host.d.ts +3 -1
  21. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  23. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  24. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  25. package/dist/types/src/version.d.ts +1 -1
  26. package/package.json +34 -33
  27. package/src/packlets/devices/devices-service.test.ts +2 -1
  28. package/src/packlets/identity/identity-manager.test.ts +4 -3
  29. package/src/packlets/identity/identity-manager.ts +9 -5
  30. package/src/packlets/identity/identity-service.test.ts +2 -1
  31. package/src/packlets/identity/identity.test.ts +7 -6
  32. package/src/packlets/identity/identity.ts +8 -3
  33. package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
  34. package/src/packlets/network/network-service.test.ts +2 -1
  35. package/src/packlets/services/client-rpc-server.ts +4 -4
  36. package/src/packlets/services/service-context.test.ts +59 -0
  37. package/src/packlets/services/service-context.ts +11 -6
  38. package/src/packlets/services/service-host.test.ts +6 -5
  39. package/src/packlets/services/service-host.ts +15 -3
  40. package/src/packlets/services/service-registry.test.ts +2 -1
  41. package/src/packlets/spaces/data-space.ts +17 -5
  42. package/src/packlets/spaces/spaces-service.test.ts +2 -1
  43. package/src/packlets/testing/test-builder.ts +1 -1
  44. package/src/packlets/vault/iframe-host-runtime.ts +2 -1
  45. package/src/packlets/vault/worker-runtime.ts +2 -1
  46. package/src/version.ts +1 -1
  47. package/dist/lib/browser/chunk-K67JOICT.mjs.map +0 -7
@@ -70,7 +70,7 @@ var import_protocols = require("@dxos/protocols");
70
70
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
71
71
 
72
72
  // packages/sdk/client-services/src/version.ts
73
- var DXOS_VERSION = "0.1.56-main.be59a09";
73
+ var DXOS_VERSION = "0.1.56-main.c19b7cd";
74
74
 
75
75
  // packages/sdk/client-services/src/packlets/services/platform.ts
76
76
  var getPlatform = () => {
@@ -228,6 +228,7 @@ var getSpaceStats = async (space) => {
228
228
 
229
229
  // packages/sdk/client-services/src/packlets/services/service-context.ts
230
230
  var import_async11 = require("@dxos/async");
231
+ var import_context8 = require("@dxos/context");
231
232
  var import_credentials15 = require("@dxos/credentials");
232
233
  var import_debug7 = require("@dxos/debug");
233
234
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
@@ -239,6 +240,7 @@ var import_log13 = require("@dxos/log");
239
240
  var import_protocols9 = require("@dxos/protocols");
240
241
  var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
241
242
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
243
+ var import_tracing3 = require("@dxos/tracing");
242
244
 
243
245
  // packages/sdk/client-services/src/packlets/identity/authenticator.ts
244
246
  var import_async = require("@dxos/async");
@@ -365,8 +367,19 @@ var import_feed_store = require("@dxos/feed-store");
365
367
  var import_invariant2 = require("@dxos/invariant");
366
368
  var import_log3 = require("@dxos/log");
367
369
  var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
370
+ var import_tracing = require("@dxos/tracing");
371
+ function _ts_decorate(decorators, target, key, desc) {
372
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
373
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
374
+ r = Reflect.decorate(decorators, target, key, desc);
375
+ else
376
+ for (var i = decorators.length - 1; i >= 0; i--)
377
+ if (d = decorators[i])
378
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
379
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
380
+ }
368
381
  var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
369
- var Identity = class {
382
+ var Identity = class Identity2 {
370
383
  constructor({ space, signer, identityKey, deviceKey }) {
371
384
  this.stateUpdate = new import_async2.Event();
372
385
  this.space = space;
@@ -392,12 +405,12 @@ var Identity = class {
392
405
  get authorizedDeviceKeys() {
393
406
  return this._deviceStateMachine.authorizedDeviceKeys;
394
407
  }
395
- async open() {
408
+ async open(ctx) {
396
409
  await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
397
410
  await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
398
- await this.space.open();
411
+ await this.space.open(ctx);
399
412
  }
400
- async close() {
413
+ async close(ctx) {
401
414
  await this.authVerifier.close();
402
415
  await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
403
416
  await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
@@ -442,7 +455,7 @@ var Identity = class {
442
455
  getIdentityCredentialSigner() {
443
456
  (0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
444
457
  F: __dxlog_file3,
445
- L: 134,
458
+ L: 139,
446
459
  S: this,
447
460
  A: [
448
461
  "this._deviceStateMachine.deviceCredentialChain",
@@ -466,7 +479,7 @@ var Identity = class {
466
479
  dataFeedKey
467
480
  }, {
468
481
  F: __dxlog_file3,
469
- L: 150,
482
+ L: 155,
470
483
  S: this,
471
484
  C: (f, a) => f(...a)
472
485
  });
@@ -507,18 +520,39 @@ var Identity = class {
507
520
  })));
508
521
  }
509
522
  };
523
+ _ts_decorate([
524
+ import_tracing.trace.span()
525
+ ], Identity.prototype, "open", null);
526
+ _ts_decorate([
527
+ import_tracing.trace.span()
528
+ ], Identity.prototype, "close", null);
529
+ Identity = _ts_decorate([
530
+ import_tracing.trace.resource()
531
+ ], Identity);
510
532
 
511
533
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
512
534
  var import_async3 = require("@dxos/async");
535
+ var import_context2 = require("@dxos/context");
513
536
  var import_credentials6 = require("@dxos/credentials");
514
537
  var import_invariant3 = require("@dxos/invariant");
515
538
  var import_keys2 = require("@dxos/keys");
516
539
  var import_log4 = require("@dxos/log");
517
540
  var import_protocols3 = require("@dxos/protocols");
518
541
  var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
542
+ var import_tracing2 = require("@dxos/tracing");
519
543
  var import_util = require("@dxos/util");
544
+ function _ts_decorate2(decorators, target, key, desc) {
545
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
546
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
547
+ r = Reflect.decorate(decorators, target, key, desc);
548
+ else
549
+ for (var i = decorators.length - 1; i >= 0; i--)
550
+ if (d = decorators[i])
551
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
552
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
553
+ }
520
554
  var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
521
- var IdentityManager = class {
555
+ var IdentityManager = class IdentityManager2 {
522
556
  // TODO(burdon): IdentityManagerParams.
523
557
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
524
558
  constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
@@ -531,14 +565,14 @@ var IdentityManager = class {
531
565
  get identity() {
532
566
  return this._identity;
533
567
  }
534
- async open() {
568
+ async open(ctx) {
535
569
  var _a;
536
570
  const traceId = import_keys2.PublicKey.random().toHex();
537
571
  import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
538
572
  id: traceId
539
573
  }), {
540
574
  F: __dxlog_file4,
541
- L: 69,
575
+ L: 73,
542
576
  S: this,
543
577
  C: (f, a) => f(...a)
544
578
  });
@@ -548,20 +582,20 @@ var IdentityManager = class {
548
582
  identityRecord
549
583
  }, {
550
584
  F: __dxlog_file4,
551
- L: 73,
585
+ L: 77,
552
586
  S: this,
553
587
  C: (f, a) => f(...a)
554
588
  });
555
589
  if (identityRecord) {
556
590
  this._identity = await this._constructIdentity(identityRecord);
557
- await this._identity.open();
591
+ await this._identity.open(ctx);
558
592
  await this._identity.ready();
559
593
  import_log4.log.trace("dxos.halo.identity", {
560
594
  identityKey: identityRecord.identityKey,
561
595
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
562
596
  }, {
563
597
  F: __dxlog_file4,
564
- L: 78,
598
+ L: 82,
565
599
  S: this,
566
600
  C: (f, a) => f(...a)
567
601
  });
@@ -571,20 +605,20 @@ var IdentityManager = class {
571
605
  id: traceId
572
606
  }), {
573
607
  F: __dxlog_file4,
574
- L: 84,
608
+ L: 88,
575
609
  S: this,
576
610
  C: (f, a) => f(...a)
577
611
  });
578
612
  }
579
613
  async close() {
580
614
  var _a;
581
- await ((_a = this._identity) == null ? void 0 : _a.close());
615
+ await ((_a = this._identity) == null ? void 0 : _a.close(new import_context2.Context()));
582
616
  }
583
617
  async createIdentity({ displayName } = {}) {
584
618
  var _a;
585
619
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
586
620
  F: __dxlog_file4,
587
- L: 92,
621
+ L: 96,
588
622
  S: this,
589
623
  A: [
590
624
  "!this._identity",
@@ -593,7 +627,7 @@ var IdentityManager = class {
593
627
  });
594
628
  (0, import_log4.log)("creating identity...", void 0, {
595
629
  F: __dxlog_file4,
596
- L: 93,
630
+ L: 97,
597
631
  S: this,
598
632
  C: (f, a) => f(...a)
599
633
  });
@@ -609,12 +643,12 @@ var IdentityManager = class {
609
643
  }
610
644
  };
611
645
  const identity = await this._constructIdentity(identityRecord);
612
- await identity.open();
646
+ await identity.open(new import_context2.Context());
613
647
  {
614
648
  const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
615
649
  (0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
616
650
  F: __dxlog_file4,
617
- L: 112,
651
+ L: 116,
618
652
  S: this,
619
653
  A: [
620
654
  "identityRecord.haloSpace.genesisFeedKey",
@@ -623,7 +657,7 @@ var IdentityManager = class {
623
657
  });
624
658
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
625
659
  F: __dxlog_file4,
626
- L: 113,
660
+ L: 117,
627
661
  S: this,
628
662
  A: [
629
663
  "identityRecord.haloSpace.dataFeedKey",
@@ -658,7 +692,7 @@ var IdentityManager = class {
658
692
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
659
693
  }, {
660
694
  F: __dxlog_file4,
661
- L: 148,
695
+ L: 152,
662
696
  S: this,
663
697
  C: (f, a) => f(...a)
664
698
  });
@@ -668,7 +702,7 @@ var IdentityManager = class {
668
702
  deviceKey: identity.deviceKey
669
703
  }, {
670
704
  F: __dxlog_file4,
671
- L: 154,
705
+ L: 158,
672
706
  S: this,
673
707
  C: (f, a) => f(...a)
674
708
  });
@@ -683,13 +717,13 @@ var IdentityManager = class {
683
717
  params
684
718
  }, {
685
719
  F: __dxlog_file4,
686
- L: 162,
720
+ L: 166,
687
721
  S: this,
688
722
  C: (f, a) => f(...a)
689
723
  });
690
724
  (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
691
725
  F: __dxlog_file4,
692
- L: 163,
726
+ L: 167,
693
727
  S: this,
694
728
  A: [
695
729
  "!this._identity",
@@ -708,7 +742,7 @@ var IdentityManager = class {
708
742
  }
709
743
  };
710
744
  const identity = await this._constructIdentity(identityRecord);
711
- await identity.open();
745
+ await identity.open(new import_context2.Context());
712
746
  this._identity = identity;
713
747
  await this._metadataStore.setIdentityRecord(identityRecord);
714
748
  await this._identity.ready();
@@ -717,7 +751,7 @@ var IdentityManager = class {
717
751
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
718
752
  }, {
719
753
  F: __dxlog_file4,
720
- L: 182,
754
+ L: 186,
721
755
  S: this,
722
756
  C: (f, a) => f(...a)
723
757
  });
@@ -727,7 +761,7 @@ var IdentityManager = class {
727
761
  deviceKey: identity.deviceKey
728
762
  }, {
729
763
  F: __dxlog_file4,
730
- L: 188,
764
+ L: 192,
731
765
  S: this,
732
766
  C: (f, a) => f(...a)
733
767
  });
@@ -736,7 +770,7 @@ var IdentityManager = class {
736
770
  async _constructIdentity(identityRecord) {
737
771
  (0, import_invariant3.invariant)(!this._identity, void 0, {
738
772
  F: __dxlog_file4,
739
- L: 193,
773
+ L: 197,
740
774
  S: this,
741
775
  A: [
742
776
  "!this._identity",
@@ -747,13 +781,13 @@ var IdentityManager = class {
747
781
  identityRecord
748
782
  }, {
749
783
  F: __dxlog_file4,
750
- L: 194,
784
+ L: 198,
751
785
  S: this,
752
786
  C: (f, a) => f(...a)
753
787
  });
754
788
  (0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
755
789
  F: __dxlog_file4,
756
- L: 197,
790
+ L: 201,
757
791
  S: this,
758
792
  A: [
759
793
  "identityRecord.haloSpace.controlFeedKey",
@@ -765,7 +799,7 @@ var IdentityManager = class {
765
799
  });
766
800
  (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
767
801
  F: __dxlog_file4,
768
- L: 201,
802
+ L: 205,
769
803
  S: this,
770
804
  A: [
771
805
  "identityRecord.haloSpace.dataFeedKey",
@@ -797,7 +831,7 @@ var IdentityManager = class {
797
831
  identityKey: identityRecord.identityKey
798
832
  }, {
799
833
  F: __dxlog_file4,
800
- L: 225,
834
+ L: 229,
801
835
  S: this,
802
836
  C: (f, a) => f(...a)
803
837
  });
@@ -818,7 +852,7 @@ var IdentityManager = class {
818
852
  onAuthFailure: () => {
819
853
  import_log4.log.warn("auth failure", void 0, {
820
854
  F: __dxlog_file4,
821
- L: 244,
855
+ L: 248,
822
856
  S: this,
823
857
  C: (f, a) => f(...a)
824
858
  });
@@ -827,6 +861,12 @@ var IdentityManager = class {
827
861
  });
828
862
  }
829
863
  };
864
+ _ts_decorate2([
865
+ import_tracing2.trace.span()
866
+ ], IdentityManager.prototype, "open", null);
867
+ IdentityManager = _ts_decorate2([
868
+ import_tracing2.trace.resource()
869
+ ], IdentityManager);
830
870
 
831
871
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
832
872
  var import_codec_protobuf3 = require("@dxos/codec-protobuf");
@@ -978,7 +1018,7 @@ var DeviceInvitationProtocol = class {
978
1018
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
979
1019
  var import_async5 = require("@dxos/async");
980
1020
  var import_client_protocol2 = require("@dxos/client-protocol");
981
- var import_context3 = require("@dxos/context");
1021
+ var import_context4 = require("@dxos/context");
982
1022
  var import_credentials9 = require("@dxos/credentials");
983
1023
  var import_errors2 = require("@dxos/errors");
984
1024
  var import_invariant7 = require("@dxos/invariant");
@@ -991,7 +1031,7 @@ var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations")
991
1031
 
992
1032
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
993
1033
  var import_async4 = require("@dxos/async");
994
- var import_context2 = require("@dxos/context");
1034
+ var import_context3 = require("@dxos/context");
995
1035
  var import_errors = require("@dxos/errors");
996
1036
  var import_invariant6 = require("@dxos/invariant");
997
1037
  var import_keys3 = require("@dxos/keys");
@@ -1014,7 +1054,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1014
1054
  }
1015
1055
  });
1016
1056
  this._callbacks = _callbacks;
1017
- this._ctx = new import_context2.Context();
1057
+ this._ctx = new import_context3.Context();
1018
1058
  this._remoteOptionsTrigger = new import_async4.Trigger();
1019
1059
  this.invitation = void 0;
1020
1060
  this.guestProfile = void 0;
@@ -1221,7 +1261,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1221
1261
  await this.rpc.InvitationHostService.options({
1222
1262
  role: import_invitations.Options.Role.HOST
1223
1263
  });
1224
- await (0, import_context2.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1264
+ await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1225
1265
  timeout: OPTIONS_TIMEOUT
1226
1266
  }));
1227
1267
  if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.GUEST) {
@@ -1250,7 +1290,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1250
1290
  }
1251
1291
  });
1252
1292
  this._callbacks = _callbacks;
1253
- this._ctx = new import_context2.Context();
1293
+ this._ctx = new import_context3.Context();
1254
1294
  this._remoteOptionsTrigger = new import_async4.Trigger();
1255
1295
  }
1256
1296
  async getHandlers() {
@@ -1291,10 +1331,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1291
1331
  S: this,
1292
1332
  C: (f, a) => f(...a)
1293
1333
  });
1294
- await (0, import_context2.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
1334
+ await (0, import_context3.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
1295
1335
  role: import_invitations.Options.Role.GUEST
1296
1336
  }));
1297
- await (0, import_context2.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1337
+ await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1298
1338
  timeout: OPTIONS_TIMEOUT
1299
1339
  }));
1300
1340
  (0, import_log5.log)("end options", void 0, {
@@ -1365,7 +1405,7 @@ var InvitationsHandler = class {
1365
1405
  ...protocol.getInvitationContext()
1366
1406
  };
1367
1407
  const stream = new import_async5.PushStream();
1368
- const ctx = new import_context3.Context({
1408
+ const ctx = new import_context4.Context({
1369
1409
  onError: (err) => {
1370
1410
  void ctx.dispose();
1371
1411
  stream.error(err);
@@ -1596,7 +1636,7 @@ var InvitationsHandler = class {
1596
1636
  ...newData
1597
1637
  });
1598
1638
  };
1599
- const ctx = new import_context3.Context({
1639
+ const ctx = new import_context4.Context({
1600
1640
  onError: (err) => {
1601
1641
  if (err instanceof import_async5.TimeoutError) {
1602
1642
  (0, import_log6.log)("timeout", {
@@ -2228,7 +2268,7 @@ var SpaceInvitationProtocol = class {
2228
2268
 
2229
2269
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2230
2270
  var import_async9 = require("@dxos/async");
2231
- var import_context6 = require("@dxos/context");
2271
+ var import_context7 = require("@dxos/context");
2232
2272
  var import_credentials14 = require("@dxos/credentials");
2233
2273
  var import_invariant11 = require("@dxos/invariant");
2234
2274
  var import_keys7 = require("@dxos/keys");
@@ -2241,7 +2281,7 @@ var import_util4 = require("@dxos/util");
2241
2281
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2242
2282
  var import_async8 = require("@dxos/async");
2243
2283
  var import_client_protocol3 = require("@dxos/client-protocol");
2244
- var import_context5 = require("@dxos/context");
2284
+ var import_context6 = require("@dxos/context");
2245
2285
  var import_debug4 = require("@dxos/debug");
2246
2286
  var import_echo_pipeline = require("@dxos/echo-pipeline");
2247
2287
  var import_errors3 = require("@dxos/errors");
@@ -2254,7 +2294,7 @@ var import_util3 = require("@dxos/util");
2254
2294
 
2255
2295
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2256
2296
  var import_async7 = require("@dxos/async");
2257
- var import_context4 = require("@dxos/context");
2297
+ var import_context5 = require("@dxos/context");
2258
2298
  var import_invariant10 = require("@dxos/invariant");
2259
2299
  var import_keys5 = require("@dxos/keys");
2260
2300
  var import_log9 = require("@dxos/log");
@@ -2268,7 +2308,7 @@ var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
2268
2308
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
2269
2309
  var NotarizationPlugin = class {
2270
2310
  constructor() {
2271
- this._ctx = new import_context4.Context();
2311
+ this._ctx = new import_context5.Context();
2272
2312
  this._extensionOpened = new import_async7.Event();
2273
2313
  this._extensions = /* @__PURE__ */ new Set();
2274
2314
  this._processedCredentials = new import_util2.ComplexSet(import_keys5.PublicKey.hash);
@@ -2393,7 +2433,7 @@ var NotarizationPlugin = class {
2393
2433
  this._extensionOpened.on(ctx, () => notarizeTask.schedule());
2394
2434
  try {
2395
2435
  await Promise.race([
2396
- (0, import_context4.rejectOnDispose)(ctx),
2436
+ (0, import_context5.rejectOnDispose)(ctx),
2397
2437
  allNotarized,
2398
2438
  errors.wait()
2399
2439
  ]);
@@ -2523,7 +2563,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2523
2563
  };
2524
2564
 
2525
2565
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2526
- function _ts_decorate(decorators, target, key, desc) {
2566
+ function _ts_decorate3(decorators, target, key, desc) {
2527
2567
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2528
2568
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2529
2569
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2534,9 +2574,10 @@ function _ts_decorate(decorators, target, key, desc) {
2534
2574
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2535
2575
  }
2536
2576
  var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2577
+ var ENABLE_FEED_PURGE = false;
2537
2578
  var DataSpace = class DataSpace2 {
2538
2579
  constructor(params) {
2539
- this._ctx = new import_context5.Context();
2580
+ this._ctx = new import_context6.Context();
2540
2581
  this._notarizationPlugin = new NotarizationPlugin();
2541
2582
  this._state = import_services7.SpaceState.CLOSED;
2542
2583
  /**
@@ -2594,7 +2635,7 @@ var DataSpace = class DataSpace2 {
2594
2635
  async _open() {
2595
2636
  await this._notarizationPlugin.open();
2596
2637
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
2597
- await this._inner.open();
2638
+ await this._inner.open(new import_context6.Context());
2598
2639
  this._state = import_services7.SpaceState.CONTROL_ONLY;
2599
2640
  this.stateUpdate.emit();
2600
2641
  this.metrics = {};
@@ -2608,7 +2649,7 @@ var DataSpace = class DataSpace2 {
2608
2649
  await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
2609
2650
  this._state = import_services7.SpaceState.CLOSED;
2610
2651
  await this._ctx.dispose();
2611
- this._ctx = new import_context5.Context();
2652
+ this._ctx = new import_context6.Context();
2612
2653
  await this.authVerifier.close();
2613
2654
  await this._inner.close();
2614
2655
  await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
@@ -2633,7 +2674,7 @@ var DataSpace = class DataSpace2 {
2633
2674
  if (err instanceof import_errors3.CancelledError) {
2634
2675
  (0, import_log10.log)("data pipeline initialization cancelled", err, {
2635
2676
  F: __dxlog_file12,
2636
- L: 193,
2677
+ L: 199,
2637
2678
  S: this,
2638
2679
  C: (f, a) => f(...a)
2639
2680
  });
@@ -2641,7 +2682,7 @@ var DataSpace = class DataSpace2 {
2641
2682
  }
2642
2683
  import_log10.log.error("Error initializing data pipeline", err, {
2643
2684
  F: __dxlog_file12,
2644
- L: 197,
2685
+ L: 203,
2645
2686
  S: this,
2646
2687
  C: (f, a) => f(...a)
2647
2688
  });
@@ -2667,7 +2708,7 @@ var DataSpace = class DataSpace2 {
2667
2708
  await this._createWritableFeeds();
2668
2709
  (0, import_log10.log)("writable feeds created", void 0, {
2669
2710
  F: __dxlog_file12,
2670
- L: 221,
2711
+ L: 227,
2671
2712
  S: this,
2672
2713
  C: (f, a) => f(...a)
2673
2714
  });
@@ -2681,10 +2722,10 @@ var DataSpace = class DataSpace2 {
2681
2722
  }
2682
2723
  await this._inner.initializeDataPipeline();
2683
2724
  this.metrics.dataPipelineOpen = new Date();
2684
- await (0, import_context5.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2725
+ await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2685
2726
  (0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
2686
2727
  F: __dxlog_file12,
2687
- L: 242,
2728
+ L: 248,
2688
2729
  S: this,
2689
2730
  C: (f, a) => f(...a)
2690
2731
  });
@@ -2695,7 +2736,7 @@ var DataSpace = class DataSpace2 {
2695
2736
  this.metrics.dataPipelineReady = new Date();
2696
2737
  (0, import_log10.log)("data pipeline ready", void 0, {
2697
2738
  F: __dxlog_file12,
2698
- L: 251,
2739
+ L: 257,
2699
2740
  S: this,
2700
2741
  C: (f, a) => f(...a)
2701
2742
  });
@@ -2768,10 +2809,13 @@ var DataSpace = class DataSpace2 {
2768
2809
  receipt.seq
2769
2810
  ]
2770
2811
  ]));
2771
- for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
2772
- const indexBeforeEpoch = epoch.timeframe.get(feed.key);
2773
- if (indexBeforeEpoch) {
2774
- await feed.clear(0, indexBeforeEpoch + 1);
2812
+ if (ENABLE_FEED_PURGE) {
2813
+ for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
2814
+ const indexBeforeEpoch = epoch.timeframe.get(feed.key);
2815
+ if (indexBeforeEpoch === void 0) {
2816
+ continue;
2817
+ }
2818
+ await feed.safeClear(0, indexBeforeEpoch + 1);
2775
2819
  }
2776
2820
  }
2777
2821
  }
@@ -2793,22 +2837,22 @@ var DataSpace = class DataSpace2 {
2793
2837
  this.stateUpdate.emit();
2794
2838
  }
2795
2839
  };
2796
- _ts_decorate([
2840
+ _ts_decorate3([
2797
2841
  import_async8.synchronized
2798
2842
  ], DataSpace.prototype, "open", null);
2799
- _ts_decorate([
2843
+ _ts_decorate3([
2800
2844
  import_async8.synchronized
2801
2845
  ], DataSpace.prototype, "close", null);
2802
- _ts_decorate([
2846
+ _ts_decorate3([
2803
2847
  (0, import_debug4.timed)(1e4)
2804
2848
  ], DataSpace.prototype, "_createWritableFeeds", null);
2805
- _ts_decorate([
2849
+ _ts_decorate3([
2806
2850
  import_async8.synchronized
2807
2851
  ], DataSpace.prototype, "activate", null);
2808
- _ts_decorate([
2852
+ _ts_decorate3([
2809
2853
  import_async8.synchronized
2810
2854
  ], DataSpace.prototype, "deactivate", null);
2811
- DataSpace = _ts_decorate([
2855
+ DataSpace = _ts_decorate3([
2812
2856
  (0, import_async8.trackLeaks)("open", "close")
2813
2857
  ], DataSpace);
2814
2858
 
@@ -2883,7 +2927,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2883
2927
  };
2884
2928
 
2885
2929
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2886
- function _ts_decorate2(decorators, target, key, desc) {
2930
+ function _ts_decorate4(decorators, target, key, desc) {
2887
2931
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2888
2932
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2889
2933
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2902,7 +2946,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2902
2946
  this._keyring = _keyring;
2903
2947
  this._signingContext = _signingContext;
2904
2948
  this._feedStore = _feedStore;
2905
- this._ctx = new import_context6.Context();
2949
+ this._ctx = new import_context7.Context();
2906
2950
  this.updated = new import_async9.Event();
2907
2951
  this._spaces = new import_util4.ComplexMap(import_keys7.PublicKey.hash);
2908
2952
  this._isOpen = false;
@@ -3081,7 +3125,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3081
3125
  * TODO(dmaretskyi): Consider removing.
3082
3126
  */
3083
3127
  async waitUntilSpaceReady(spaceKey) {
3084
- await (0, import_context6.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
3128
+ await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
3085
3129
  const space = this._spaces.get(spaceKey);
3086
3130
  return !!space && space.state === import_services8.SpaceState.READY;
3087
3131
  }));
@@ -3198,19 +3242,19 @@ var DataSpaceManager = class DataSpaceManager2 {
3198
3242
  return dataSpace;
3199
3243
  }
3200
3244
  };
3201
- _ts_decorate2([
3245
+ _ts_decorate4([
3202
3246
  import_async9.synchronized
3203
3247
  ], DataSpaceManager.prototype, "open", null);
3204
- _ts_decorate2([
3248
+ _ts_decorate4([
3205
3249
  import_async9.synchronized
3206
3250
  ], DataSpaceManager.prototype, "close", null);
3207
- _ts_decorate2([
3251
+ _ts_decorate4([
3208
3252
  import_async9.synchronized
3209
3253
  ], DataSpaceManager.prototype, "createSpace", null);
3210
- _ts_decorate2([
3254
+ _ts_decorate4([
3211
3255
  import_async9.synchronized
3212
3256
  ], DataSpaceManager.prototype, "acceptSpace", null);
3213
- DataSpaceManager = _ts_decorate2([
3257
+ DataSpaceManager = _ts_decorate4([
3214
3258
  (0, import_async9.trackLeaks)("open", "close")
3215
3259
  ], DataSpaceManager);
3216
3260
 
@@ -3401,8 +3445,18 @@ var SpacesServiceImpl = class {
3401
3445
  var getChannelId = (channel) => `user-channel/${channel}`;
3402
3446
 
3403
3447
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3448
+ function _ts_decorate5(decorators, target, key, desc) {
3449
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3450
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3451
+ r = Reflect.decorate(decorators, target, key, desc);
3452
+ else
3453
+ for (var i = decorators.length - 1; i >= 0; i--)
3454
+ if (d = decorators[i])
3455
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3456
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3457
+ }
3404
3458
  var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3405
- var ServiceContext = class {
3459
+ var ServiceContext = class ServiceContext2 {
3406
3460
  // prettier-ignore
3407
3461
  constructor(storage, networkManager, signalManager, modelFactory) {
3408
3462
  this.storage = storage;
@@ -3441,11 +3495,11 @@ var ServiceContext = class {
3441
3495
  return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
3442
3496
  }, this._acceptIdentity.bind(this)));
3443
3497
  }
3444
- async open() {
3498
+ async open(ctx) {
3445
3499
  await this._checkStorageVersion();
3446
3500
  (0, import_log13.log)("opening...", void 0, {
3447
3501
  F: __dxlog_file15,
3448
- L: 127,
3502
+ L: 131,
3449
3503
  S: this,
3450
3504
  C: (f, a) => f(...a)
3451
3505
  });
@@ -3453,28 +3507,28 @@ var ServiceContext = class {
3453
3507
  id: this._instanceId
3454
3508
  }), {
3455
3509
  F: __dxlog_file15,
3456
- L: 128,
3510
+ L: 132,
3457
3511
  S: this,
3458
3512
  C: (f, a) => f(...a)
3459
3513
  });
3460
3514
  await this.signalManager.open();
3461
3515
  await this.networkManager.open();
3462
3516
  await this.spaceManager.open();
3463
- await this.identityManager.open();
3517
+ await this.identityManager.open(ctx);
3464
3518
  if (this.identityManager.identity) {
3465
- await this._initialize();
3519
+ await this._initialize(ctx);
3466
3520
  }
3467
3521
  import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
3468
3522
  id: this._instanceId
3469
3523
  }), {
3470
3524
  F: __dxlog_file15,
3471
- L: 136,
3525
+ L: 140,
3472
3526
  S: this,
3473
3527
  C: (f, a) => f(...a)
3474
3528
  });
3475
3529
  (0, import_log13.log)("opened", void 0, {
3476
3530
  F: __dxlog_file15,
3477
- L: 137,
3531
+ L: 141,
3478
3532
  S: this,
3479
3533
  C: (f, a) => f(...a)
3480
3534
  });
@@ -3483,7 +3537,7 @@ var ServiceContext = class {
3483
3537
  var _a;
3484
3538
  (0, import_log13.log)("closing...", void 0, {
3485
3539
  F: __dxlog_file15,
3486
- L: 141,
3540
+ L: 145,
3487
3541
  S: this,
3488
3542
  C: (f, a) => f(...a)
3489
3543
  });
@@ -3499,21 +3553,21 @@ var ServiceContext = class {
3499
3553
  this.dataServiceSubscriptions.clear();
3500
3554
  (0, import_log13.log)("closed", void 0, {
3501
3555
  F: __dxlog_file15,
3502
- L: 152,
3556
+ L: 156,
3503
3557
  S: this,
3504
3558
  C: (f, a) => f(...a)
3505
3559
  });
3506
3560
  }
3507
3561
  async createIdentity(params = {}) {
3508
3562
  const identity = await this.identityManager.createIdentity(params);
3509
- await this._initialize();
3563
+ await this._initialize(new import_context8.Context());
3510
3564
  return identity;
3511
3565
  }
3512
3566
  getInvitationHandler(invitation) {
3513
3567
  const factory = this._handlerFactories.get(invitation.kind);
3514
3568
  (0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
3515
3569
  F: __dxlog_file15,
3516
- L: 164,
3570
+ L: 168,
3517
3571
  S: this,
3518
3572
  A: [
3519
3573
  "factory",
@@ -3524,7 +3578,7 @@ var ServiceContext = class {
3524
3578
  }
3525
3579
  async _acceptIdentity(params) {
3526
3580
  const identity = await this.identityManager.acceptIdentity(params);
3527
- await this._initialize();
3581
+ await this._initialize(new import_context8.Context());
3528
3582
  return identity;
3529
3583
  }
3530
3584
  async _checkStorageVersion() {
@@ -3534,11 +3588,11 @@ var ServiceContext = class {
3534
3588
  }
3535
3589
  }
3536
3590
  // Called when identity is created.
3537
- async _initialize() {
3591
+ async _initialize(ctx) {
3538
3592
  var _a;
3539
3593
  (0, import_log13.log)("initializing spaces...", void 0, {
3540
3594
  F: __dxlog_file15,
3541
- L: 185,
3595
+ L: 190,
3542
3596
  S: this,
3543
3597
  C: (f, a) => f(...a)
3544
3598
  });
@@ -3561,7 +3615,7 @@ var ServiceContext = class {
3561
3615
  this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
3562
3616
  (0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3563
3617
  F: __dxlog_file15,
3564
- L: 208,
3618
+ L: 213,
3565
3619
  S: this,
3566
3620
  A: [
3567
3621
  "this.dataSpaceManager",
@@ -3585,7 +3639,7 @@ var ServiceContext = class {
3585
3639
  details: assertion
3586
3640
  }, {
3587
3641
  F: __dxlog_file15,
3588
- L: 224,
3642
+ L: 229,
3589
3643
  S: this,
3590
3644
  C: (f, a) => f(...a)
3591
3645
  });
@@ -3596,7 +3650,7 @@ var ServiceContext = class {
3596
3650
  details: assertion
3597
3651
  }, {
3598
3652
  F: __dxlog_file15,
3599
- L: 228,
3653
+ L: 233,
3600
3654
  S: this,
3601
3655
  C: (f, a) => f(...a)
3602
3656
  });
@@ -3607,7 +3661,7 @@ var ServiceContext = class {
3607
3661
  details: assertion
3608
3662
  }, {
3609
3663
  F: __dxlog_file15,
3610
- L: 233,
3664
+ L: 238,
3611
3665
  S: this,
3612
3666
  C: (f, a) => f(...a)
3613
3667
  });
@@ -3618,7 +3672,7 @@ var ServiceContext = class {
3618
3672
  } catch (err) {
3619
3673
  import_log13.log.catch(err, void 0, {
3620
3674
  F: __dxlog_file15,
3621
- L: 239,
3675
+ L: 244,
3622
3676
  S: this,
3623
3677
  C: (f, a) => f(...a)
3624
3678
  });
@@ -3628,10 +3682,20 @@ var ServiceContext = class {
3628
3682
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
3629
3683
  }
3630
3684
  };
3685
+ _ts_decorate5([
3686
+ import_tracing3.trace.span()
3687
+ ], ServiceContext.prototype, "open", null);
3688
+ _ts_decorate5([
3689
+ import_tracing3.trace.span()
3690
+ ], ServiceContext.prototype, "_initialize", null);
3691
+ ServiceContext = _ts_decorate5([
3692
+ import_tracing3.trace.resource()
3693
+ ], ServiceContext);
3631
3694
 
3632
3695
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3633
3696
  var import_async17 = require("@dxos/async");
3634
3697
  var import_client_protocol5 = require("@dxos/client-protocol");
3698
+ var import_context10 = require("@dxos/context");
3635
3699
  var import_document_model2 = require("@dxos/document-model");
3636
3700
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3637
3701
  var import_invariant14 = require("@dxos/invariant");
@@ -3643,6 +3707,7 @@ var import_network_manager2 = require("@dxos/network-manager");
3643
3707
  var import_protocols10 = require("@dxos/protocols");
3644
3708
  var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
3645
3709
  var import_text_model = require("@dxos/text-model");
3710
+ var import_tracing4 = require("@dxos/tracing");
3646
3711
 
3647
3712
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3648
3713
  var import_async12 = require("@dxos/async");
@@ -3798,7 +3863,7 @@ var subscribeToMetadata = ({ context }) => new import_codec_protobuf9.Stream(({
3798
3863
 
3799
3864
  // packages/sdk/client-services/src/packlets/devtools/network.ts
3800
3865
  var import_codec_protobuf10 = require("@dxos/codec-protobuf");
3801
- var import_context7 = require("@dxos/context");
3866
+ var import_context9 = require("@dxos/context");
3802
3867
  var import_keys10 = require("@dxos/keys");
3803
3868
  var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next, close }) => {
3804
3869
  const update = () => {
@@ -3815,7 +3880,7 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf1
3815
3880
  update();
3816
3881
  });
3817
3882
  var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next }) => {
3818
- const ctx = new import_context7.Context();
3883
+ const ctx = new import_context9.Context();
3819
3884
  signalManager.onMessage.on(ctx, (message) => {
3820
3885
  next({
3821
3886
  message: {
@@ -4008,7 +4073,7 @@ var DevtoolsServiceImpl = class {
4008
4073
  var import_invariant13 = require("@dxos/invariant");
4009
4074
  var import_lock_file = require("@dxos/lock-file");
4010
4075
  var import_log14 = require("@dxos/log");
4011
- function _ts_decorate3(decorators, target, key, desc) {
4076
+ function _ts_decorate6(decorators, target, key, desc) {
4012
4077
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4013
4078
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4014
4079
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4060,7 +4125,7 @@ var Lock = class {
4060
4125
  await import_lock_file.LockFile.release(this._fileHandle);
4061
4126
  }
4062
4127
  };
4063
- _ts_decorate3([
4128
+ _ts_decorate6([
4064
4129
  import_log14.logInfo
4065
4130
  ], Lock.prototype, "lockKey", null);
4066
4131
 
@@ -4348,7 +4413,7 @@ var ServiceRegistry = class {
4348
4413
  };
4349
4414
 
4350
4415
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4351
- function _ts_decorate4(decorators, target, key, desc) {
4416
+ function _ts_decorate7(decorators, target, key, desc) {
4352
4417
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4353
4418
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4354
4419
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4362,7 +4427,7 @@ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
4362
4427
  var createDefaultModelFactory = () => {
4363
4428
  return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
4364
4429
  };
4365
- var ClientServicesHost = class {
4430
+ var ClientServicesHost = class ClientServicesHost2 {
4366
4431
  constructor({
4367
4432
  config,
4368
4433
  modelFactory = createDefaultModelFactory(),
@@ -4373,6 +4438,7 @@ var ClientServicesHost = class {
4373
4438
  lockKey,
4374
4439
  callbacks
4375
4440
  } = {}) {
4441
+ this._tracingService = import_tracing4.TRACE_PROCESSOR.createTraceSender();
4376
4442
  this._statusUpdate = new import_async17.Event();
4377
4443
  this._opening = false;
4378
4444
  this._open = false;
@@ -4391,7 +4457,7 @@ var ClientServicesHost = class {
4391
4457
  lockKey,
4392
4458
  onAcquire: () => {
4393
4459
  if (!this._opening) {
4394
- void this.open();
4460
+ void this.open(new import_context10.Context());
4395
4461
  }
4396
4462
  },
4397
4463
  onRelease: () => this.close()
@@ -4418,7 +4484,8 @@ var ClientServicesHost = class {
4418
4484
  });
4419
4485
  this._loggingService = new LoggingServiceImpl();
4420
4486
  this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
4421
- SystemService: this._systemService
4487
+ SystemService: this._systemService,
4488
+ TracingService: this._tracingService
4422
4489
  });
4423
4490
  }
4424
4491
  get isOpen() {
@@ -4448,7 +4515,7 @@ var ClientServicesHost = class {
4448
4515
  var _a, _b, _c;
4449
4516
  (0, import_invariant14.invariant)(!this._open, "service host is open", {
4450
4517
  F: __dxlog_file17,
4451
- L: 172,
4518
+ L: 181,
4452
4519
  S: this,
4453
4520
  A: [
4454
4521
  "!this._open",
@@ -4457,14 +4524,14 @@ var ClientServicesHost = class {
4457
4524
  });
4458
4525
  import_log16.log.info("initializing...", void 0, {
4459
4526
  F: __dxlog_file17,
4460
- L: 173,
4527
+ L: 182,
4461
4528
  S: this,
4462
4529
  C: (f, a) => f(...a)
4463
4530
  });
4464
4531
  if (config) {
4465
4532
  (0, import_invariant14.invariant)(!this._config, "config already set", {
4466
4533
  F: __dxlog_file17,
4467
- L: 176,
4534
+ L: 185,
4468
4535
  S: this,
4469
4536
  A: [
4470
4537
  "!this._config",
@@ -4482,7 +4549,7 @@ var ClientServicesHost = class {
4482
4549
  this._signalManager = signalManager;
4483
4550
  (0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
4484
4551
  F: __dxlog_file17,
4485
- L: 192,
4552
+ L: 201,
4486
4553
  S: this,
4487
4554
  A: [
4488
4555
  "!this._networkManager",
@@ -4496,12 +4563,12 @@ var ClientServicesHost = class {
4496
4563
  });
4497
4564
  import_log16.log.info("initialized", void 0, {
4498
4565
  F: __dxlog_file17,
4499
- L: 199,
4566
+ L: 208,
4500
4567
  S: this,
4501
4568
  C: (f, a) => f(...a)
4502
4569
  });
4503
4570
  }
4504
- async open() {
4571
+ async open(ctx) {
4505
4572
  var _a, _b, _c;
4506
4573
  if (this._open) {
4507
4574
  return;
@@ -4511,13 +4578,13 @@ var ClientServicesHost = class {
4511
4578
  id: traceId
4512
4579
  }), {
4513
4580
  F: __dxlog_file17,
4514
- L: 209,
4581
+ L: 219,
4515
4582
  S: this,
4516
4583
  C: (f, a) => f(...a)
4517
4584
  });
4518
4585
  (0, import_invariant14.invariant)(this._config, "config not set", {
4519
4586
  F: __dxlog_file17,
4520
- L: 211,
4587
+ L: 221,
4521
4588
  S: this,
4522
4589
  A: [
4523
4590
  "this._config",
@@ -4526,7 +4593,7 @@ var ClientServicesHost = class {
4526
4593
  });
4527
4594
  (0, import_invariant14.invariant)(this._storage, "storage not set", {
4528
4595
  F: __dxlog_file17,
4529
- L: 212,
4596
+ L: 222,
4530
4597
  S: this,
4531
4598
  A: [
4532
4599
  "this._storage",
@@ -4535,7 +4602,7 @@ var ClientServicesHost = class {
4535
4602
  });
4536
4603
  (0, import_invariant14.invariant)(this._signalManager, "signal manager not set", {
4537
4604
  F: __dxlog_file17,
4538
- L: 213,
4605
+ L: 223,
4539
4606
  S: this,
4540
4607
  A: [
4541
4608
  "this._signalManager",
@@ -4544,7 +4611,7 @@ var ClientServicesHost = class {
4544
4611
  });
4545
4612
  (0, import_invariant14.invariant)(this._networkManager, "network manager not set", {
4546
4613
  F: __dxlog_file17,
4547
- L: 214,
4614
+ L: 224,
4548
4615
  S: this,
4549
4616
  A: [
4550
4617
  "this._networkManager",
@@ -4556,7 +4623,7 @@ var ClientServicesHost = class {
4556
4623
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4557
4624
  }, {
4558
4625
  F: __dxlog_file17,
4559
- L: 217,
4626
+ L: 227,
4560
4627
  S: this,
4561
4628
  C: (f, a) => f(...a)
4562
4629
  });
@@ -4575,6 +4642,7 @@ var ClientServicesHost = class {
4575
4642
  DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4576
4643
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
4577
4644
  LoggingService: this._loggingService,
4645
+ TracingService: this._tracingService,
4578
4646
  // TODO(burdon): Move to new protobuf definitions.
4579
4647
  DevtoolsHost: new DevtoolsServiceImpl({
4580
4648
  events: new DevtoolsHostEvents(),
@@ -4582,7 +4650,7 @@ var ClientServicesHost = class {
4582
4650
  context: this._serviceContext
4583
4651
  })
4584
4652
  });
4585
- await this._serviceContext.open();
4653
+ await this._serviceContext.open(ctx);
4586
4654
  this._opening = false;
4587
4655
  this._open = true;
4588
4656
  this._statusUpdate.emit();
@@ -4591,7 +4659,7 @@ var ClientServicesHost = class {
4591
4659
  deviceKey
4592
4660
  }, {
4593
4661
  F: __dxlog_file17,
4594
- L: 269,
4662
+ L: 280,
4595
4663
  S: this,
4596
4664
  C: (f, a) => f(...a)
4597
4665
  });
@@ -4599,7 +4667,7 @@ var ClientServicesHost = class {
4599
4667
  id: traceId
4600
4668
  }), {
4601
4669
  F: __dxlog_file17,
4602
- L: 270,
4670
+ L: 281,
4603
4671
  S: this,
4604
4672
  C: (f, a) => f(...a)
4605
4673
  });
@@ -4614,7 +4682,7 @@ var ClientServicesHost = class {
4614
4682
  deviceKey
4615
4683
  }, {
4616
4684
  F: __dxlog_file17,
4617
- L: 280,
4685
+ L: 292,
4618
4686
  S: this,
4619
4687
  C: (f, a) => f(...a)
4620
4688
  });
@@ -4629,7 +4697,7 @@ var ClientServicesHost = class {
4629
4697
  deviceKey
4630
4698
  }, {
4631
4699
  F: __dxlog_file17,
4632
- L: 286,
4700
+ L: 298,
4633
4701
  S: this,
4634
4702
  C: (f, a) => f(...a)
4635
4703
  });
@@ -4641,13 +4709,13 @@ var ClientServicesHost = class {
4641
4709
  id: traceId
4642
4710
  }), {
4643
4711
  F: __dxlog_file17,
4644
- L: 291,
4712
+ L: 303,
4645
4713
  S: this,
4646
4714
  C: (f, a) => f(...a)
4647
4715
  });
4648
4716
  (0, import_log16.log)("resetting...", void 0, {
4649
4717
  F: __dxlog_file17,
4650
- L: 293,
4718
+ L: 305,
4651
4719
  S: this,
4652
4720
  C: (f, a) => f(...a)
4653
4721
  });
@@ -4655,7 +4723,7 @@ var ClientServicesHost = class {
4655
4723
  await this._storage.reset();
4656
4724
  (0, import_log16.log)("reset", void 0, {
4657
4725
  F: __dxlog_file17,
4658
- L: 296,
4726
+ L: 308,
4659
4727
  S: this,
4660
4728
  C: (f, a) => f(...a)
4661
4729
  });
@@ -4663,19 +4731,30 @@ var ClientServicesHost = class {
4663
4731
  id: traceId
4664
4732
  }), {
4665
4733
  F: __dxlog_file17,
4666
- L: 297,
4734
+ L: 309,
4667
4735
  S: this,
4668
4736
  C: (f, a) => f(...a)
4669
4737
  });
4670
4738
  await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
4671
4739
  }
4672
4740
  };
4673
- _ts_decorate4([
4674
- import_async17.synchronized
4741
+ _ts_decorate7([
4742
+ import_tracing4.trace.info()
4743
+ ], ClientServicesHost.prototype, "_opening", void 0);
4744
+ _ts_decorate7([
4745
+ import_tracing4.trace.info()
4746
+ ], ClientServicesHost.prototype, "_open", void 0);
4747
+ _ts_decorate7([
4748
+ import_async17.synchronized,
4749
+ import_tracing4.trace.span()
4675
4750
  ], ClientServicesHost.prototype, "open", null);
4676
- _ts_decorate4([
4677
- import_async17.synchronized
4751
+ _ts_decorate7([
4752
+ import_async17.synchronized,
4753
+ import_tracing4.trace.span()
4678
4754
  ], ClientServicesHost.prototype, "close", null);
4755
+ ClientServicesHost = _ts_decorate7([
4756
+ import_tracing4.trace.resource()
4757
+ ], ClientServicesHost);
4679
4758
 
4680
4759
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
4681
4760
  var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/invitation-utils.ts";
@@ -4859,7 +4938,7 @@ var acceptInvitation = (guest, invitation) => {
4859
4938
  };
4860
4939
 
4861
4940
  // packages/sdk/client-services/src/packlets/testing/test-builder.ts
4862
- var import_context8 = require("@dxos/context");
4941
+ var import_context11 = require("@dxos/context");
4863
4942
  var import_credentials16 = require("@dxos/credentials");
4864
4943
  var import_debug8 = require("@dxos/debug");
4865
4944
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
@@ -4894,7 +4973,7 @@ var createPeers = async (numPeers) => {
4894
4973
  const peer = createServiceContext({
4895
4974
  signalContext
4896
4975
  });
4897
- await peer.open();
4976
+ await peer.open(new import_context11.Context());
4898
4977
  return peer;
4899
4978
  }));
4900
4979
  };
@@ -4909,7 +4988,7 @@ var syncItemsLocal = async (db1, db2) => {
4909
4988
  var TestBuilder = class {
4910
4989
  constructor() {
4911
4990
  this.signalContext = new import_messaging2.MemorySignalManagerContext();
4912
- this._ctx = new import_context8.Context();
4991
+ this._ctx = new import_context11.Context();
4913
4992
  }
4914
4993
  createPeer(peerOptions) {
4915
4994
  const peer = new TestPeer(this.signalContext, peerOptions);