@dxos/client-services 0.1.53-main.d095ee3 → 0.1.53-main.d1a4933

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 (62) hide show
  1. package/dist/lib/browser/{chunk-BSRQYPXL.mjs → chunk-EYXOVYW5.mjs} +787 -683
  2. package/dist/lib/browser/chunk-EYXOVYW5.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +101 -120
  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 +24 -7
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +853 -770
  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 +770 -652
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  14. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  15. package/dist/types/src/packlets/services/service-host.d.ts +7 -1
  16. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  17. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  18. package/dist/types/src/packlets/spaces/data-space.d.ts +11 -2
  19. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  20. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +2 -1
  21. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/spaces-service.d.ts +1 -1
  23. package/dist/types/src/packlets/spaces/spaces-service.d.ts.map +1 -1
  24. package/dist/types/src/packlets/testing/test-builder.d.ts +7 -1
  25. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  26. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts +1 -1
  27. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  28. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts +1 -1
  29. package/dist/types/src/packlets/vault/iframe-proxy-runtime.d.ts.map +1 -1
  30. package/dist/types/src/packlets/vault/shell-runtime.d.ts +1 -21
  31. package/dist/types/src/packlets/vault/shell-runtime.d.ts.map +1 -1
  32. package/package.json +33 -32
  33. package/src/packlets/identity/identity-manager.test.ts +1 -1
  34. package/src/packlets/identity/identity-manager.ts +8 -8
  35. package/src/packlets/identity/identity-service.ts +2 -2
  36. package/src/packlets/identity/identity.test.ts +1 -1
  37. package/src/packlets/identity/identity.ts +22 -27
  38. package/src/packlets/invitations/device-invitation-protocol.ts +4 -4
  39. package/src/packlets/invitations/invitation-extension.ts +5 -5
  40. package/src/packlets/invitations/invitations-handler.ts +6 -6
  41. package/src/packlets/invitations/invitations-service.ts +3 -3
  42. package/src/packlets/invitations/space-invitation-protocol.ts +9 -9
  43. package/src/packlets/locks/node.ts +2 -2
  44. package/src/packlets/logging/logging-service.ts +4 -4
  45. package/src/packlets/services/service-context.test.ts +1 -1
  46. package/src/packlets/services/service-context.ts +12 -10
  47. package/src/packlets/services/service-host.test.ts +50 -2
  48. package/src/packlets/services/service-host.ts +25 -9
  49. package/src/packlets/spaces/data-space-manager.test.ts +72 -118
  50. package/src/packlets/spaces/data-space-manager.ts +18 -8
  51. package/src/packlets/spaces/data-space.ts +66 -20
  52. package/src/packlets/spaces/notarization-plugin.test.ts +1 -1
  53. package/src/packlets/spaces/notarization-plugin.ts +9 -5
  54. package/src/packlets/spaces/spaces-service.ts +26 -8
  55. package/src/packlets/testing/invitation-utils.ts +2 -2
  56. package/src/packlets/testing/test-builder.ts +36 -4
  57. package/src/packlets/vault/iframe-host-runtime.ts +2 -2
  58. package/src/packlets/vault/iframe-proxy-runtime.ts +2 -2
  59. package/src/packlets/vault/shell-runtime.ts +3 -49
  60. package/src/packlets/vault/worker-runtime.ts +1 -1
  61. package/src/packlets/vault/worker-session.ts +2 -2
  62. package/dist/lib/browser/chunk-BSRQYPXL.mjs.map +0 -7
@@ -44,7 +44,6 @@ __export(src_exports, {
44
44
  InvitationsHandler: () => InvitationsHandler,
45
45
  InvitationsServiceImpl: () => InvitationsServiceImpl,
46
46
  Lock: () => Lock,
47
- MemoryShellRuntime: () => MemoryShellRuntime,
48
47
  ServiceContext: () => ServiceContext,
49
48
  ServiceRegistry: () => ServiceRegistry,
50
49
  ShellRuntimeImpl: () => ShellRuntimeImpl,
@@ -54,6 +53,7 @@ __export(src_exports, {
54
53
  WorkerRuntime: () => WorkerRuntime,
55
54
  WorkerSession: () => WorkerSession,
56
55
  createAuthProvider: () => createAuthProvider,
56
+ createDefaultModelFactory: () => createDefaultModelFactory,
57
57
  createStorageObjects: () => createStorageObjects,
58
58
  getNetworkPeers: () => getNetworkPeers,
59
59
  isLocked: () => isLocked,
@@ -419,6 +419,7 @@ var import_context2 = require("@dxos/context");
419
419
  var import_credentials = require("@dxos/credentials");
420
420
  var import_log = require("@dxos/log");
421
421
  var import_protocols = require("@dxos/protocols");
422
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
422
423
  var createAuthProvider = (signer) => async (nonce) => {
423
424
  const credential = await signer.createCredential({
424
425
  assertion: {
@@ -444,20 +445,20 @@ var TrustedKeySetAuthVerifier = class {
444
445
  (0, import_log.log)("authenticating...", {
445
446
  credential
446
447
  }, {
447
- file: "authenticator.ts",
448
- line: 57,
449
- scope: this,
450
- callSite: (f, a) => f(...a)
448
+ F: __dxlog_file,
449
+ L: 57,
450
+ S: this,
451
+ C: (f, a) => f(...a)
451
452
  });
452
453
  const result = await (0, import_credentials.verifyCredential)(credential);
453
454
  if (result.kind === "fail") {
454
455
  (0, import_log.log)("Invalid credential", {
455
456
  result
456
457
  }, {
457
- file: "authenticator.ts",
458
- line: 61,
459
- scope: this,
460
- callSite: (f, a) => f(...a)
458
+ F: __dxlog_file,
459
+ L: 61,
460
+ S: this,
461
+ C: (f, a) => f(...a)
461
462
  });
462
463
  return false;
463
464
  }
@@ -466,10 +467,10 @@ var TrustedKeySetAuthVerifier = class {
466
467
  nonce,
467
468
  credential
468
469
  }, {
469
- file: "authenticator.ts",
470
- line: 66,
471
- scope: this,
472
- callSite: (f, a) => f(...a)
470
+ F: __dxlog_file,
471
+ L: 66,
472
+ S: this,
473
+ C: (f, a) => f(...a)
473
474
  });
474
475
  return false;
475
476
  }
@@ -477,10 +478,10 @@ var TrustedKeySetAuthVerifier = class {
477
478
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
478
479
  key: credential.issuer
479
480
  }, {
480
- file: "authenticator.ts",
481
- line: 71,
482
- scope: this,
483
- callSite: (f, a) => f(...a)
481
+ F: __dxlog_file,
482
+ L: 71,
483
+ S: this,
484
+ C: (f, a) => f(...a)
484
485
  });
485
486
  return true;
486
487
  }
@@ -493,20 +494,20 @@ var TrustedKeySetAuthVerifier = class {
493
494
  (0, import_log.log)("auth success", {
494
495
  key: credential.issuer
495
496
  }, {
496
- file: "authenticator.ts",
497
- line: 82,
498
- scope: this,
499
- callSite: (f, a) => f(...a)
497
+ F: __dxlog_file,
498
+ L: 82,
499
+ S: this,
500
+ C: (f, a) => f(...a)
500
501
  });
501
502
  trigger.wake(true);
502
503
  } else {
503
504
  (0, import_log.log)("key is not currently in trusted set, waiting...", {
504
505
  key: credential.issuer
505
506
  }, {
506
- file: "authenticator.ts",
507
- line: 85,
508
- scope: this,
509
- callSite: (f, a) => f(...a)
507
+ F: __dxlog_file,
508
+ L: 85,
509
+ S: this,
510
+ C: (f, a) => f(...a)
510
511
  });
511
512
  }
512
513
  });
@@ -528,7 +529,7 @@ var TrustedKeySetAuthVerifier = class {
528
529
  };
529
530
 
530
531
  // packages/sdk/client-services/src/packlets/identity/identity.ts
531
- var import_node_assert = __toESM(require("node:assert"));
532
+ var import_tiny_invariant = __toESM(require("tiny-invariant"));
532
533
  var import_async5 = require("@dxos/async");
533
534
  var import_client_protocol = require("@dxos/client-protocol");
534
535
  var import_credentials2 = require("@dxos/credentials");
@@ -536,6 +537,7 @@ var import_debug = require("@dxos/debug");
536
537
  var import_feed_store2 = require("@dxos/feed-store");
537
538
  var import_log2 = require("@dxos/log");
538
539
  var import_credentials3 = require("@dxos/protocols/proto/dxos/halo/credentials");
540
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
539
541
  var Identity = class {
540
542
  constructor({ space, signer, identityKey, deviceKey }) {
541
543
  this.stateUpdate = new import_async5.Event();
@@ -543,15 +545,15 @@ var Identity = class {
543
545
  this._signer = signer;
544
546
  this.identityKey = identityKey;
545
547
  this.deviceKey = deviceKey;
546
- this._deviceStateMachine = this.space.spaceState.registerProcessor(new import_credentials2.DeviceStateMachine({
548
+ this._deviceStateMachine = new import_credentials2.DeviceStateMachine({
547
549
  identityKey: this.identityKey,
548
550
  deviceKey: this.deviceKey,
549
551
  onUpdate: () => this.stateUpdate.emit()
550
- }));
551
- this._profileStateMachine = this.space.spaceState.registerProcessor(new import_credentials2.ProfileStateMachine({
552
+ });
553
+ this._profileStateMachine = new import_credentials2.ProfileStateMachine({
552
554
  identityKey: this.identityKey,
553
555
  onUpdate: () => this.stateUpdate.emit()
554
- }));
556
+ });
555
557
  this.authVerifier = new TrustedKeySetAuthVerifier({
556
558
  trustedKeysProvider: () => this.authorizedDeviceKeys,
557
559
  update: this.stateUpdate,
@@ -560,27 +562,27 @@ var Identity = class {
560
562
  }
561
563
  // TODO(burdon): Expose state object?
562
564
  get authorizedDeviceKeys() {
563
- return this._deviceStateMachine.processor.authorizedDeviceKeys;
565
+ return this._deviceStateMachine.authorizedDeviceKeys;
564
566
  }
565
567
  async open() {
566
- await this._deviceStateMachine.open();
567
- await this._profileStateMachine.open();
568
+ await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
569
+ await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
568
570
  await this.space.open();
569
571
  }
570
572
  async close() {
571
573
  await this.authVerifier.close();
572
- await this._deviceStateMachine.close();
573
- await this._profileStateMachine.close();
574
+ await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
575
+ await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
574
576
  await this.space.close();
575
577
  }
576
578
  async ready() {
577
- await this._deviceStateMachine.processor.deviceChainReady.wait();
579
+ await this._deviceStateMachine.deviceChainReady.wait();
578
580
  await this.controlPipeline.state.waitUntilReachedTargetTimeframe({
579
581
  timeout: import_client_protocol.LOAD_CONTROL_FEEDS_TIMEOUT
580
582
  });
581
583
  }
582
584
  get profileDocument() {
583
- return this._profileStateMachine.processor.profile;
585
+ return this._profileStateMachine.profile;
584
586
  }
585
587
  /**
586
588
  * @test-only
@@ -595,7 +597,7 @@ var Identity = class {
595
597
  return this.space.genesisFeedKey;
596
598
  }
597
599
  get deviceCredentialChain() {
598
- return this._deviceStateMachine.processor.deviceCredentialChain;
600
+ return this._deviceStateMachine.deviceCredentialChain;
599
601
  }
600
602
  getAdmissionCredentials() {
601
603
  var _a, _b;
@@ -610,8 +612,8 @@ var Identity = class {
610
612
  * Requires identity to be ready.
611
613
  */
612
614
  getIdentityCredentialSigner() {
613
- (0, import_node_assert.default)(this._deviceStateMachine.processor.deviceCredentialChain, "Device credential chain is not ready.");
614
- return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.processor.deviceCredentialChain, this.deviceKey);
615
+ (0, import_tiny_invariant.default)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.");
616
+ return (0, import_credentials2.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
615
617
  }
616
618
  /**
617
619
  * Issues credentials as device.
@@ -627,10 +629,10 @@ var Identity = class {
627
629
  controlFeedKey,
628
630
  dataFeedKey
629
631
  }, {
630
- file: "identity.ts",
631
- line: 156,
632
- scope: this,
633
- callSite: (f, a) => f(...a)
632
+ F: __dxlog_file2,
633
+ L: 151,
634
+ S: this,
635
+ C: (f, a) => f(...a)
634
636
  });
635
637
  const signer = this.getIdentityCredentialSigner();
636
638
  await (0, import_feed_store2.writeMessages)(this.controlPipeline.writer, [
@@ -671,7 +673,7 @@ var Identity = class {
671
673
  };
672
674
 
673
675
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
674
- var import_node_assert2 = __toESM(require("node:assert"));
676
+ var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
675
677
  var import_async6 = require("@dxos/async");
676
678
  var import_credentials4 = require("@dxos/credentials");
677
679
  var import_keys4 = require("@dxos/keys");
@@ -679,6 +681,7 @@ var import_log3 = require("@dxos/log");
679
681
  var import_protocols2 = require("@dxos/protocols");
680
682
  var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
681
683
  var import_util2 = require("@dxos/util");
684
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
682
685
  var IdentityManager = class {
683
686
  // TODO(burdon): IdentityManagerParams.
684
687
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
@@ -698,20 +701,20 @@ var IdentityManager = class {
698
701
  import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
699
702
  id: traceId
700
703
  }), {
701
- file: "identity-manager.ts",
702
- line: 70,
703
- scope: this,
704
- callSite: (f, a) => f(...a)
704
+ F: __dxlog_file3,
705
+ L: 70,
706
+ S: this,
707
+ C: (f, a) => f(...a)
705
708
  });
706
709
  await this._metadataStore.load();
707
710
  const identityRecord = this._metadataStore.getIdentityRecord();
708
711
  (0, import_log3.log)("identity record", {
709
712
  identityRecord
710
713
  }, {
711
- file: "identity-manager.ts",
712
- line: 74,
713
- scope: this,
714
- callSite: (f, a) => f(...a)
714
+ F: __dxlog_file3,
715
+ L: 74,
716
+ S: this,
717
+ C: (f, a) => f(...a)
715
718
  });
716
719
  if (identityRecord) {
717
720
  this._identity = await this._constructIdentity(identityRecord);
@@ -721,20 +724,20 @@ var IdentityManager = class {
721
724
  identityKey: identityRecord.identityKey,
722
725
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
723
726
  }, {
724
- file: "identity-manager.ts",
725
- line: 79,
726
- scope: this,
727
- callSite: (f, a) => f(...a)
727
+ F: __dxlog_file3,
728
+ L: 79,
729
+ S: this,
730
+ C: (f, a) => f(...a)
728
731
  });
729
732
  this.stateUpdate.emit();
730
733
  }
731
734
  import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.end({
732
735
  id: traceId
733
736
  }), {
734
- file: "identity-manager.ts",
735
- line: 85,
736
- scope: this,
737
- callSite: (f, a) => f(...a)
737
+ F: __dxlog_file3,
738
+ L: 85,
739
+ S: this,
740
+ C: (f, a) => f(...a)
738
741
  });
739
742
  }
740
743
  async close() {
@@ -743,12 +746,12 @@ var IdentityManager = class {
743
746
  }
744
747
  async createIdentity({ displayName } = {}) {
745
748
  var _a;
746
- (0, import_node_assert2.default)(!this._identity, "Identity already exists.");
747
- (0, import_log3.log)("creating identity...", {}, {
748
- file: "identity-manager.ts",
749
- line: 94,
750
- scope: this,
751
- callSite: (f, a) => f(...a)
749
+ (0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
750
+ (0, import_log3.log)("creating identity...", void 0, {
751
+ F: __dxlog_file3,
752
+ L: 94,
753
+ S: this,
754
+ C: (f, a) => f(...a)
752
755
  });
753
756
  const controlFeedKey = await this._keyring.createKey();
754
757
  const identityRecord = {
@@ -765,8 +768,8 @@ var IdentityManager = class {
765
768
  await identity.open();
766
769
  {
767
770
  const generator = new import_credentials4.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
768
- (0, import_node_assert2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
769
- (0, import_node_assert2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
771
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.");
772
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.");
770
773
  const credentials = [
771
774
  // Space genesis.
772
775
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
@@ -794,20 +797,20 @@ var IdentityManager = class {
794
797
  identityKey: identityRecord.identityKey,
795
798
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
796
799
  }, {
797
- file: "identity-manager.ts",
798
- line: 149,
799
- scope: this,
800
- callSite: (f, a) => f(...a)
800
+ F: __dxlog_file3,
801
+ L: 149,
802
+ S: this,
803
+ C: (f, a) => f(...a)
801
804
  });
802
805
  this.stateUpdate.emit();
803
806
  (0, import_log3.log)("created identity", {
804
807
  identityKey: identity.identityKey,
805
808
  deviceKey: identity.deviceKey
806
809
  }, {
807
- file: "identity-manager.ts",
808
- line: 155,
809
- scope: this,
810
- callSite: (f, a) => f(...a)
810
+ F: __dxlog_file3,
811
+ L: 155,
812
+ S: this,
813
+ C: (f, a) => f(...a)
811
814
  });
812
815
  return identity;
813
816
  }
@@ -819,12 +822,12 @@ var IdentityManager = class {
819
822
  (0, import_log3.log)("accepting identity", {
820
823
  params
821
824
  }, {
822
- file: "identity-manager.ts",
823
- line: 163,
824
- scope: this,
825
- callSite: (f, a) => f(...a)
825
+ F: __dxlog_file3,
826
+ L: 163,
827
+ S: this,
828
+ C: (f, a) => f(...a)
826
829
  });
827
- (0, import_node_assert2.default)(!this._identity, "Identity already exists.");
830
+ (0, import_tiny_invariant2.default)(!this._identity, "Identity already exists.");
828
831
  const identityRecord = {
829
832
  identityKey: params.identityKey,
830
833
  deviceKey: params.deviceKey,
@@ -845,38 +848,38 @@ var IdentityManager = class {
845
848
  identityKey: identityRecord.identityKey,
846
849
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
847
850
  }, {
848
- file: "identity-manager.ts",
849
- line: 183,
850
- scope: this,
851
- callSite: (f, a) => f(...a)
851
+ F: __dxlog_file3,
852
+ L: 183,
853
+ S: this,
854
+ C: (f, a) => f(...a)
852
855
  });
853
856
  this.stateUpdate.emit();
854
857
  (0, import_log3.log)("accepted identity", {
855
858
  identityKey: identity.identityKey,
856
859
  deviceKey: identity.deviceKey
857
860
  }, {
858
- file: "identity-manager.ts",
859
- line: 189,
860
- scope: this,
861
- callSite: (f, a) => f(...a)
861
+ F: __dxlog_file3,
862
+ L: 189,
863
+ S: this,
864
+ C: (f, a) => f(...a)
862
865
  });
863
866
  return identity;
864
867
  }
865
868
  async _constructIdentity(identityRecord) {
866
- (0, import_node_assert2.default)(!this._identity);
869
+ (0, import_tiny_invariant2.default)(!this._identity);
867
870
  (0, import_log3.log)("constructing identity", {
868
871
  identityRecord
869
872
  }, {
870
- file: "identity-manager.ts",
871
- line: 195,
872
- scope: this,
873
- callSite: (f, a) => f(...a)
873
+ F: __dxlog_file3,
874
+ L: 195,
875
+ S: this,
876
+ C: (f, a) => f(...a)
874
877
  });
875
- (0, import_node_assert2.default)(identityRecord.haloSpace.controlFeedKey);
878
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.controlFeedKey);
876
879
  const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
877
880
  writable: true
878
881
  });
879
- (0, import_node_assert2.default)(identityRecord.haloSpace.dataFeedKey);
882
+ (0, import_tiny_invariant2.default)(identityRecord.haloSpace.dataFeedKey);
880
883
  const dataFeed = await this._feedStore.openFeed(identityRecord.haloSpace.dataFeedKey, {
881
884
  writable: true,
882
885
  sparse: true
@@ -901,10 +904,10 @@ var IdentityManager = class {
901
904
  (0, import_log3.log)("done", {
902
905
  identityKey: identityRecord.identityKey
903
906
  }, {
904
- file: "identity-manager.ts",
905
- line: 226,
906
- scope: this,
907
- callSite: (f, a) => f(...a)
907
+ F: __dxlog_file3,
908
+ L: 226,
909
+ S: this,
910
+ C: (f, a) => f(...a)
908
911
  });
909
912
  if (identityRecord.haloSpace.controlTimeframe) {
910
913
  identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
@@ -921,11 +924,11 @@ var IdentityManager = class {
921
924
  onNetworkConnection: () => {
922
925
  },
923
926
  onAuthFailure: () => {
924
- import_log3.log.warn("auth failure", {}, {
925
- file: "identity-manager.ts",
926
- line: 245,
927
- scope: this,
928
- callSite: (f, a) => f(...a)
927
+ import_log3.log.warn("auth failure", void 0, {
928
+ F: __dxlog_file3,
929
+ L: 245,
930
+ S: this,
931
+ C: (f, a) => f(...a)
929
932
  });
930
933
  },
931
934
  memberKey: identityKey
@@ -934,7 +937,7 @@ var IdentityManager = class {
934
937
  };
935
938
 
936
939
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
937
- var import_node_assert3 = __toESM(require("node:assert"));
940
+ var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
938
941
  var import_codec_protobuf7 = require("@dxos/codec-protobuf");
939
942
  var import_credentials6 = require("@dxos/credentials");
940
943
  var import_debug2 = require("@dxos/debug");
@@ -970,7 +973,7 @@ var IdentityServiceImpl = class {
970
973
  };
971
974
  }
972
975
  async signPresentation({ presentation, nonce }) {
973
- (0, import_node_assert3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
976
+ (0, import_tiny_invariant3.default)(this._serviceContext.identityManager.identity, "Identity not initialized.");
974
977
  return await (0, import_credentials6.signPresentation)({
975
978
  presentation,
976
979
  signer: this._serviceContext.keyring,
@@ -982,7 +985,7 @@ var IdentityServiceImpl = class {
982
985
  };
983
986
 
984
987
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
985
- var import_node_assert4 = __toESM(require("node:assert"));
988
+ var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
986
989
  var import_services = require("@dxos/protocols/proto/dxos/client/services");
987
990
  var DeviceInvitationProtocol = class {
988
991
  constructor(_keyring, _getIdentity, _acceptIdentity) {
@@ -999,7 +1002,7 @@ var DeviceInvitationProtocol = class {
999
1002
  };
1000
1003
  }
1001
1004
  async admit(request) {
1002
- (0, import_node_assert4.default)(request.device);
1005
+ (0, import_tiny_invariant4.default)(request.device);
1003
1006
  const identity = this._getIdentity();
1004
1007
  await identity.admitDevice(request.device);
1005
1008
  return {
@@ -1027,9 +1030,9 @@ var DeviceInvitationProtocol = class {
1027
1030
  };
1028
1031
  }
1029
1032
  async accept(response, request) {
1030
- (0, import_node_assert4.default)(response.device);
1033
+ (0, import_tiny_invariant4.default)(response.device);
1031
1034
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
1032
- (0, import_node_assert4.default)(request.device);
1035
+ (0, import_tiny_invariant4.default)(request.device);
1033
1036
  const { deviceKey, controlFeedKey, dataFeedKey } = request.device;
1034
1037
  await this._acceptIdentity({
1035
1038
  identityKey,
@@ -1047,7 +1050,7 @@ var DeviceInvitationProtocol = class {
1047
1050
  };
1048
1051
 
1049
1052
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1050
- var import_node_assert6 = __toESM(require("node:assert"));
1053
+ var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
1051
1054
  var import_async8 = require("@dxos/async");
1052
1055
  var import_client_protocol2 = require("@dxos/client-protocol");
1053
1056
  var import_context4 = require("@dxos/context");
@@ -1061,7 +1064,7 @@ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
1061
1064
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
1062
1065
 
1063
1066
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
1064
- var import_node_assert5 = __toESM(require("node:assert"));
1067
+ var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
1065
1068
  var import_async7 = require("@dxos/async");
1066
1069
  var import_context3 = require("@dxos/context");
1067
1070
  var import_errors = require("@dxos/errors");
@@ -1071,6 +1074,7 @@ var import_protocols3 = require("@dxos/protocols");
1071
1074
  var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
1072
1075
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
1073
1076
  var import_teleport = require("@dxos/teleport");
1077
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
1074
1078
  var OPTIONS_TIMEOUT = 1e4;
1075
1079
  var MAX_OTP_ATTEMPTS = 3;
1076
1080
  var InvitationHostExtension = class extends import_teleport.RpcExtension {
@@ -1098,7 +1102,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1098
1102
  // Perhaps in the future we will have more complex logic here.
1099
1103
  InvitationHostService: {
1100
1104
  options: async (options) => {
1101
- (0, import_node_assert5.default)(!this._remoteOptions, "Remote options already set.");
1105
+ (0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
1102
1106
  this._remoteOptions = options;
1103
1107
  this._remoteOptionsTrigger.wake();
1104
1108
  },
@@ -1108,20 +1112,20 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1108
1112
  import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
1109
1113
  id: traceId
1110
1114
  }), {
1111
- file: "invitation-extension.ts",
1112
- line: 98,
1113
- scope: this,
1114
- callSite: (f, a) => f(...a)
1115
+ F: __dxlog_file4,
1116
+ L: 98,
1117
+ S: this,
1118
+ C: (f, a) => f(...a)
1115
1119
  });
1116
1120
  const invitation = await this._callbacks.resolveInvitation(request);
1117
1121
  if (!invitation) {
1118
1122
  import_log4.log.warn("invitation not found", {
1119
1123
  invitationId
1120
1124
  }, {
1121
- file: "invitation-extension.ts",
1122
- line: 102,
1123
- scope: this,
1124
- callSite: (f, a) => f(...a)
1125
+ F: __dxlog_file4,
1126
+ L: 102,
1127
+ S: this,
1128
+ C: (f, a) => f(...a)
1125
1129
  });
1126
1130
  this._callbacks.onError(new Error("Invitation not found."));
1127
1131
  return {
@@ -1132,10 +1136,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1132
1136
  (0, import_log4.log)("guest introduced itself", {
1133
1137
  guestProfile: profile
1134
1138
  }, {
1135
- file: "invitation-extension.ts",
1136
- line: 111,
1137
- scope: this,
1138
- callSite: (f, a) => f(...a)
1139
+ F: __dxlog_file4,
1140
+ L: 111,
1141
+ S: this,
1142
+ C: (f, a) => f(...a)
1139
1143
  });
1140
1144
  this.guestProfile = profile;
1141
1145
  this._callbacks.onStateUpdate({
@@ -1145,10 +1149,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1145
1149
  import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
1146
1150
  id: traceId
1147
1151
  }), {
1148
- file: "invitation-extension.ts",
1149
- line: 118,
1150
- scope: this,
1151
- callSite: (f, a) => f(...a)
1152
+ F: __dxlog_file4,
1153
+ L: 118,
1154
+ S: this,
1155
+ C: (f, a) => f(...a)
1152
1156
  });
1153
1157
  return {
1154
1158
  spaceKey: this.invitation.authMethod === import_services2.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
@@ -1160,28 +1164,28 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1160
1164
  import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
1161
1165
  id: traceId
1162
1166
  }), {
1163
- file: "invitation-extension.ts",
1164
- line: 127,
1165
- scope: this,
1166
- callSite: (f, a) => f(...a)
1167
+ F: __dxlog_file4,
1168
+ L: 127,
1169
+ S: this,
1170
+ C: (f, a) => f(...a)
1167
1171
  });
1168
1172
  (0, import_log4.log)("received authentication request", {
1169
1173
  authCode: code
1170
1174
  }, {
1171
- file: "invitation-extension.ts",
1172
- line: 128,
1173
- scope: this,
1174
- callSite: (f, a) => f(...a)
1175
+ F: __dxlog_file4,
1176
+ L: 128,
1177
+ S: this,
1178
+ C: (f, a) => f(...a)
1175
1179
  });
1176
1180
  let status = import_invitations.AuthenticationResponse.Status.OK;
1177
- (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
1181
+ (0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
1178
1182
  switch (this.invitation.authMethod) {
1179
1183
  case import_services2.Invitation.AuthMethod.NONE: {
1180
- (0, import_log4.log)("authentication not required", {}, {
1181
- file: "invitation-extension.ts",
1182
- line: 134,
1183
- scope: this,
1184
- callSite: (f, a) => f(...a)
1184
+ (0, import_log4.log)("authentication not required", void 0, {
1185
+ F: __dxlog_file4,
1186
+ L: 134,
1187
+ S: this,
1188
+ C: (f, a) => f(...a)
1185
1189
  });
1186
1190
  return {
1187
1191
  status: import_invitations.AuthenticationResponse.Status.OK
@@ -1203,10 +1207,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1203
1207
  import_log4.log.error("invalid authentication method", {
1204
1208
  authMethod: this.invitation.authMethod
1205
1209
  }, {
1206
- file: "invitation-extension.ts",
1207
- line: 152,
1208
- scope: this,
1209
- callSite: (f, a) => f(...a)
1210
+ F: __dxlog_file4,
1211
+ L: 152,
1212
+ S: this,
1213
+ C: (f, a) => f(...a)
1210
1214
  });
1211
1215
  status = import_invitations.AuthenticationResponse.Status.INTERNAL_ERROR;
1212
1216
  break;
@@ -1218,10 +1222,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1218
1222
  status
1219
1223
  }
1220
1224
  }), {
1221
- file: "invitation-extension.ts",
1222
- line: 158,
1223
- scope: this,
1224
- callSite: (f, a) => f(...a)
1225
+ F: __dxlog_file4,
1226
+ L: 158,
1227
+ S: this,
1228
+ C: (f, a) => f(...a)
1225
1229
  });
1226
1230
  return {
1227
1231
  status
@@ -1232,13 +1236,13 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1232
1236
  import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
1233
1237
  id: traceId
1234
1238
  }), {
1235
- file: "invitation-extension.ts",
1236
- line: 164,
1237
- scope: this,
1238
- callSite: (f, a) => f(...a)
1239
+ F: __dxlog_file4,
1240
+ L: 164,
1241
+ S: this,
1242
+ C: (f, a) => f(...a)
1239
1243
  });
1240
1244
  try {
1241
- (0, import_node_assert5.default)(this.invitation, "Invitation is not set.");
1245
+ (0, import_tiny_invariant5.default)(this.invitation, "Invitation is not set.");
1242
1246
  if (isAuthenticationRequired(this.invitation) && !this.authenticationPassed) {
1243
1247
  throw new Error("Not authenticated");
1244
1248
  }
@@ -1246,10 +1250,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1246
1250
  import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
1247
1251
  id: traceId
1248
1252
  }), {
1249
- file: "invitation-extension.ts",
1250
- line: 175,
1251
- scope: this,
1252
- callSite: (f, a) => f(...a)
1253
+ F: __dxlog_file4,
1254
+ L: 175,
1255
+ S: this,
1256
+ C: (f, a) => f(...a)
1253
1257
  });
1254
1258
  return response;
1255
1259
  } catch (err) {
@@ -1303,7 +1307,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1303
1307
  return {
1304
1308
  InvitationHostService: {
1305
1309
  options: async (options) => {
1306
- (0, import_node_assert5.default)(!this._remoteOptions, "Remote options already set.");
1310
+ (0, import_tiny_invariant5.default)(!this._remoteOptions, "Remote options already set.");
1307
1311
  this._remoteOptions = options;
1308
1312
  this._remoteOptionsTrigger.wake();
1309
1313
  },
@@ -1323,11 +1327,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1323
1327
  var _a;
1324
1328
  await super.onOpen(context);
1325
1329
  try {
1326
- (0, import_log4.log)("begin options", {}, {
1327
- file: "invitation-extension.ts",
1328
- line: 263,
1329
- scope: this,
1330
- callSite: (f, a) => f(...a)
1330
+ (0, import_log4.log)("begin options", void 0, {
1331
+ F: __dxlog_file4,
1332
+ L: 263,
1333
+ S: this,
1334
+ C: (f, a) => f(...a)
1331
1335
  });
1332
1336
  await (0, import_context3.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
1333
1337
  role: import_invitations.Options.Role.GUEST
@@ -1335,11 +1339,11 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1335
1339
  await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1336
1340
  timeout: OPTIONS_TIMEOUT
1337
1341
  }));
1338
- (0, import_log4.log)("end options", {}, {
1339
- file: "invitation-extension.ts",
1340
- line: 266,
1341
- scope: this,
1342
- callSite: (f, a) => f(...a)
1342
+ (0, import_log4.log)("end options", void 0, {
1343
+ F: __dxlog_file4,
1344
+ L: 266,
1345
+ S: this,
1346
+ C: (f, a) => f(...a)
1343
1347
  });
1344
1348
  if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.HOST) {
1345
1349
  throw new import_errors.InvalidInvitationExtensionRoleError(void 0, {
@@ -1350,20 +1354,20 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1350
1354
  this._callbacks.onOpen(this._ctx);
1351
1355
  } catch (err) {
1352
1356
  (0, import_log4.log)("openError", err, {
1353
- file: "invitation-extension.ts",
1354
- line: 276,
1355
- scope: this,
1356
- callSite: (f, a) => f(...a)
1357
+ F: __dxlog_file4,
1358
+ L: 276,
1359
+ S: this,
1360
+ C: (f, a) => f(...a)
1357
1361
  });
1358
1362
  this._callbacks.onError(err);
1359
1363
  }
1360
1364
  }
1361
1365
  async onClose() {
1362
- (0, import_log4.log)("onClose", {}, {
1363
- file: "invitation-extension.ts",
1364
- line: 282,
1365
- scope: this,
1366
- callSite: (f, a) => f(...a)
1366
+ (0, import_log4.log)("onClose", void 0, {
1367
+ F: __dxlog_file4,
1368
+ L: 282,
1369
+ S: this,
1370
+ C: (f, a) => f(...a)
1367
1371
  });
1368
1372
  await this._ctx.dispose();
1369
1373
  }
@@ -1371,6 +1375,7 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1371
1375
  var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
1372
1376
 
1373
1377
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1378
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1374
1379
  var InvitationsHandler = class {
1375
1380
  /**
1376
1381
  * @internal
@@ -1382,7 +1387,7 @@ var InvitationsHandler = class {
1382
1387
  var _a;
1383
1388
  const { invitationId = import_keys6.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_keys6.PublicKey.random() } = options != null ? options : {};
1384
1389
  const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials7.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1385
- (0, import_node_assert6.default)(protocol);
1390
+ (0, import_tiny_invariant6.default)(protocol);
1386
1391
  const invitation = {
1387
1392
  invitationId,
1388
1393
  type,
@@ -1404,10 +1409,10 @@ var InvitationsHandler = class {
1404
1409
  (0, import_log5.log)("complete", {
1405
1410
  ...protocol.toJSON()
1406
1411
  }, {
1407
- file: "invitations-handler.ts",
1408
- line: 99,
1409
- scope: this,
1410
- callSite: (f, a) => f(...a)
1412
+ F: __dxlog_file5,
1413
+ L: 99,
1414
+ S: this,
1415
+ C: (f, a) => f(...a)
1411
1416
  });
1412
1417
  stream.complete();
1413
1418
  });
@@ -1429,7 +1434,7 @@ var InvitationsHandler = class {
1429
1434
  var _a2, _b, _c;
1430
1435
  try {
1431
1436
  const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1432
- (0, import_node_assert6.default)(deviceKey);
1437
+ (0, import_tiny_invariant6.default)(deviceKey);
1433
1438
  const admissionResponse = await protocol.admit(admissionRequest, extension.guestProfile);
1434
1439
  extension.completedTrigger.wake(deviceKey);
1435
1440
  return admissionResponse;
@@ -1445,18 +1450,18 @@ var InvitationsHandler = class {
1445
1450
  import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
1446
1451
  id: traceId
1447
1452
  }), {
1448
- file: "invitations-handler.ts",
1449
- line: 138,
1450
- scope: this,
1451
- callSite: (f, a) => f(...a)
1453
+ F: __dxlog_file5,
1454
+ L: 138,
1455
+ S: this,
1456
+ C: (f, a) => f(...a)
1452
1457
  });
1453
1458
  (0, import_log5.log)("connected", {
1454
1459
  ...protocol.toJSON()
1455
1460
  }, {
1456
- file: "invitations-handler.ts",
1457
- line: 139,
1458
- scope: this,
1459
- callSite: (f, a) => f(...a)
1461
+ F: __dxlog_file5,
1462
+ L: 139,
1463
+ S: this,
1464
+ C: (f, a) => f(...a)
1460
1465
  });
1461
1466
  stream.next({
1462
1467
  ...invitation,
@@ -1469,10 +1474,10 @@ var InvitationsHandler = class {
1469
1474
  guest: deviceKey,
1470
1475
  ...protocol.toJSON()
1471
1476
  }, {
1472
- file: "invitations-handler.ts",
1473
- line: 142,
1474
- scope: this,
1475
- callSite: (f, a) => f(...a)
1477
+ F: __dxlog_file5,
1478
+ L: 142,
1479
+ S: this,
1480
+ C: (f, a) => f(...a)
1476
1481
  });
1477
1482
  stream.next({
1478
1483
  ...invitation,
@@ -1481,20 +1486,20 @@ var InvitationsHandler = class {
1481
1486
  import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
1482
1487
  id: traceId
1483
1488
  }), {
1484
- file: "invitations-handler.ts",
1485
- line: 144,
1486
- scope: this,
1487
- callSite: (f, a) => f(...a)
1489
+ F: __dxlog_file5,
1490
+ L: 144,
1491
+ S: this,
1492
+ C: (f, a) => f(...a)
1488
1493
  });
1489
1494
  } catch (err) {
1490
1495
  if (err instanceof import_async8.TimeoutError) {
1491
1496
  (0, import_log5.log)("timeout", {
1492
1497
  ...protocol.toJSON()
1493
1498
  }, {
1494
- file: "invitations-handler.ts",
1495
- line: 147,
1496
- scope: this,
1497
- callSite: (f, a) => f(...a)
1499
+ F: __dxlog_file5,
1500
+ L: 147,
1501
+ S: this,
1502
+ C: (f, a) => f(...a)
1498
1503
  });
1499
1504
  stream.next({
1500
1505
  ...invitation,
@@ -1502,10 +1507,10 @@ var InvitationsHandler = class {
1502
1507
  });
1503
1508
  } else {
1504
1509
  import_log5.log.error("failed", err, {
1505
- file: "invitations-handler.ts",
1506
- line: 150,
1507
- scope: this,
1508
- callSite: (f, a) => f(...a)
1510
+ F: __dxlog_file5,
1511
+ L: 150,
1512
+ S: this,
1513
+ C: (f, a) => f(...a)
1509
1514
  });
1510
1515
  stream.error(err);
1511
1516
  }
@@ -1513,10 +1518,10 @@ var InvitationsHandler = class {
1513
1518
  id: traceId,
1514
1519
  error: err
1515
1520
  }), {
1516
- file: "invitations-handler.ts",
1517
- line: 153,
1518
- scope: this,
1519
- callSite: (f, a) => f(...a)
1521
+ F: __dxlog_file5,
1522
+ L: 153,
1523
+ S: this,
1524
+ C: (f, a) => f(...a)
1520
1525
  });
1521
1526
  } finally {
1522
1527
  if (type !== import_services3.Invitation.Type.MULTIUSE) {
@@ -1534,10 +1539,10 @@ var InvitationsHandler = class {
1534
1539
  (0, import_log5.log)("timeout", {
1535
1540
  ...protocol.toJSON()
1536
1541
  }, {
1537
- file: "invitations-handler.ts",
1538
- line: 168,
1539
- scope: this,
1540
- callSite: (f, a) => f(...a)
1542
+ F: __dxlog_file5,
1543
+ L: 168,
1544
+ S: this,
1545
+ C: (f, a) => f(...a)
1541
1546
  });
1542
1547
  stream.next({
1543
1548
  ...invitation,
@@ -1545,10 +1550,10 @@ var InvitationsHandler = class {
1545
1550
  });
1546
1551
  } else {
1547
1552
  import_log5.log.error("failed", err, {
1548
- file: "invitations-handler.ts",
1549
- line: 171,
1550
- scope: this,
1551
- callSite: (f, a) => f(...a)
1553
+ F: __dxlog_file5,
1554
+ L: 171,
1555
+ S: this,
1556
+ C: (f, a) => f(...a)
1552
1557
  });
1553
1558
  stream.error(err);
1554
1559
  }
@@ -1588,13 +1593,13 @@ var InvitationsHandler = class {
1588
1593
  }
1589
1594
  acceptInvitation(protocol, invitation) {
1590
1595
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
1591
- (0, import_node_assert6.default)(protocol);
1596
+ (0, import_tiny_invariant6.default)(protocol);
1592
1597
  const authenticated = new import_async8.Trigger();
1593
1598
  let admitted = false;
1594
1599
  let currentState;
1595
1600
  const stream = new import_async8.PushStream();
1596
1601
  const setState = (newData) => {
1597
- (0, import_node_assert6.default)(newData.state !== void 0);
1602
+ (0, import_tiny_invariant6.default)(newData.state !== void 0);
1598
1603
  currentState = newData.state;
1599
1604
  stream.next({
1600
1605
  ...invitation,
@@ -1607,20 +1612,20 @@ var InvitationsHandler = class {
1607
1612
  (0, import_log5.log)("timeout", {
1608
1613
  ...protocol.toJSON()
1609
1614
  }, {
1610
- file: "invitations-handler.ts",
1611
- line: 230,
1612
- scope: this,
1613
- callSite: (f, a) => f(...a)
1615
+ F: __dxlog_file5,
1616
+ L: 230,
1617
+ S: this,
1618
+ C: (f, a) => f(...a)
1614
1619
  });
1615
1620
  setState({
1616
1621
  state: import_services3.Invitation.State.TIMEOUT
1617
1622
  });
1618
1623
  } else {
1619
1624
  import_log5.log.warn("auth failed", err, {
1620
- file: "invitations-handler.ts",
1621
- line: 233,
1622
- scope: this,
1623
- callSite: (f, a) => f(...a)
1625
+ F: __dxlog_file5,
1626
+ L: 233,
1627
+ S: this,
1628
+ C: (f, a) => f(...a)
1624
1629
  });
1625
1630
  stream.error(err);
1626
1631
  }
@@ -1631,10 +1636,10 @@ var InvitationsHandler = class {
1631
1636
  (0, import_log5.log)("complete", {
1632
1637
  ...protocol.toJSON()
1633
1638
  }, {
1634
- file: "invitations-handler.ts",
1635
- line: 241,
1636
- scope: this,
1637
- callSite: (f, a) => f(...a)
1639
+ F: __dxlog_file5,
1640
+ L: 241,
1641
+ S: this,
1642
+ C: (f, a) => f(...a)
1638
1643
  });
1639
1644
  stream.complete();
1640
1645
  });
@@ -1646,10 +1651,10 @@ var InvitationsHandler = class {
1646
1651
  (0, import_log5.log)("extension disposed", {
1647
1652
  currentState
1648
1653
  }, {
1649
- file: "invitations-handler.ts",
1650
- line: 251,
1651
- scope: this,
1652
- callSite: (f, a) => f(...a)
1654
+ F: __dxlog_file5,
1655
+ L: 251,
1656
+ S: this,
1657
+ C: (f, a) => f(...a)
1653
1658
  });
1654
1659
  if (!admitted) {
1655
1660
  stream.error(new Error("Remote peer disconnected."));
@@ -1661,10 +1666,10 @@ var InvitationsHandler = class {
1661
1666
  import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
1662
1667
  id: traceId
1663
1668
  }), {
1664
- file: "invitations-handler.ts",
1665
- line: 260,
1666
- scope: this,
1667
- callSite: (f, a) => f(...a)
1669
+ F: __dxlog_file5,
1670
+ L: 260,
1671
+ S: this,
1672
+ C: (f, a) => f(...a)
1668
1673
  });
1669
1674
  if (++connectionCount > 1) {
1670
1675
  throw new Error(`multiple connections detected: ${connectionCount}`);
@@ -1673,10 +1678,10 @@ var InvitationsHandler = class {
1673
1678
  (0, import_log5.log)("connected", {
1674
1679
  ...protocol.toJSON()
1675
1680
  }, {
1676
- file: "invitations-handler.ts",
1677
- line: 268,
1678
- scope: this,
1679
- callSite: (f, a) => f(...a)
1681
+ F: __dxlog_file5,
1682
+ L: 268,
1683
+ S: this,
1684
+ C: (f, a) => f(...a)
1680
1685
  });
1681
1686
  setState({
1682
1687
  state: import_services3.Invitation.State.CONNECTED
@@ -1684,20 +1689,20 @@ var InvitationsHandler = class {
1684
1689
  (0, import_log5.log)("introduce", {
1685
1690
  ...protocol.toJSON()
1686
1691
  }, {
1687
- file: "invitations-handler.ts",
1688
- line: 272,
1689
- scope: this,
1690
- callSite: (f, a) => f(...a)
1692
+ F: __dxlog_file5,
1693
+ L: 272,
1694
+ S: this,
1695
+ C: (f, a) => f(...a)
1691
1696
  });
1692
1697
  const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
1693
1698
  (0, import_log5.log)("introduce response", {
1694
1699
  ...protocol.toJSON(),
1695
1700
  response: introductionResponse
1696
1701
  }, {
1697
- file: "invitations-handler.ts",
1698
- line: 276,
1699
- scope: this,
1700
- callSite: (f, a) => f(...a)
1702
+ F: __dxlog_file5,
1703
+ L: 276,
1704
+ S: this,
1705
+ C: (f, a) => f(...a)
1701
1706
  });
1702
1707
  invitation.authMethod = introductionResponse.authMethod;
1703
1708
  if (introductionResponse.spaceKey) {
@@ -1705,11 +1710,11 @@ var InvitationsHandler = class {
1705
1710
  }
1706
1711
  if (isAuthenticationRequired(invitation)) {
1707
1712
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1708
- (0, import_log5.log)("guest waiting for authentication code...", {}, {
1709
- file: "invitations-handler.ts",
1710
- line: 285,
1711
- scope: this,
1712
- callSite: (f, a) => f(...a)
1713
+ (0, import_log5.log)("guest waiting for authentication code...", void 0, {
1714
+ F: __dxlog_file5,
1715
+ L: 285,
1716
+ S: this,
1717
+ C: (f, a) => f(...a)
1713
1718
  });
1714
1719
  setState({
1715
1720
  state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
@@ -1717,11 +1722,11 @@ var InvitationsHandler = class {
1717
1722
  const authCode = await authenticated.wait({
1718
1723
  timeout
1719
1724
  });
1720
- (0, import_log5.log)("sending authentication request", {}, {
1721
- file: "invitations-handler.ts",
1722
- line: 289,
1723
- scope: this,
1724
- callSite: (f, a) => f(...a)
1725
+ (0, import_log5.log)("sending authentication request", void 0, {
1726
+ F: __dxlog_file5,
1727
+ L: 289,
1728
+ S: this,
1729
+ C: (f, a) => f(...a)
1725
1730
  });
1726
1731
  setState({
1727
1732
  state: import_services3.Invitation.State.AUTHENTICATING
@@ -1739,10 +1744,10 @@ var InvitationsHandler = class {
1739
1744
  (0, import_log5.log)("retrying invalid code", {
1740
1745
  attempt
1741
1746
  }, {
1742
- file: "invitations-handler.ts",
1743
- line: 300,
1744
- scope: this,
1745
- callSite: (f, a) => f(...a)
1747
+ F: __dxlog_file5,
1748
+ L: 300,
1749
+ S: this,
1750
+ C: (f, a) => f(...a)
1746
1751
  });
1747
1752
  authenticated.reset();
1748
1753
  }
@@ -1756,10 +1761,10 @@ var InvitationsHandler = class {
1756
1761
  (0, import_log5.log)("request admission", {
1757
1762
  ...protocol.toJSON()
1758
1763
  }, {
1759
- file: "invitations-handler.ts",
1760
- line: 311,
1761
- scope: this,
1762
- callSite: (f, a) => f(...a)
1764
+ F: __dxlog_file5,
1765
+ L: 311,
1766
+ S: this,
1767
+ C: (f, a) => f(...a)
1763
1768
  });
1764
1769
  const admissionRequest = await protocol.createAdmissionRequest();
1765
1770
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
@@ -1768,10 +1773,10 @@ var InvitationsHandler = class {
1768
1773
  (0, import_log5.log)("admitted by host", {
1769
1774
  ...protocol.toJSON()
1770
1775
  }, {
1771
- file: "invitations-handler.ts",
1772
- line: 322,
1773
- scope: this,
1774
- callSite: (f, a) => f(...a)
1776
+ F: __dxlog_file5,
1777
+ L: 322,
1778
+ S: this,
1779
+ C: (f, a) => f(...a)
1775
1780
  });
1776
1781
  setState({
1777
1782
  ...result,
@@ -1780,30 +1785,30 @@ var InvitationsHandler = class {
1780
1785
  import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
1781
1786
  id: traceId
1782
1787
  }), {
1783
- file: "invitations-handler.ts",
1784
- line: 324,
1785
- scope: this,
1786
- callSite: (f, a) => f(...a)
1788
+ F: __dxlog_file5,
1789
+ L: 324,
1790
+ S: this,
1791
+ C: (f, a) => f(...a)
1787
1792
  });
1788
1793
  } catch (err) {
1789
1794
  if (err instanceof import_async8.TimeoutError) {
1790
1795
  (0, import_log5.log)("timeout", {
1791
1796
  ...protocol.toJSON()
1792
1797
  }, {
1793
- file: "invitations-handler.ts",
1794
- line: 327,
1795
- scope: this,
1796
- callSite: (f, a) => f(...a)
1798
+ F: __dxlog_file5,
1799
+ L: 327,
1800
+ S: this,
1801
+ C: (f, a) => f(...a)
1797
1802
  });
1798
1803
  setState({
1799
1804
  state: import_services3.Invitation.State.TIMEOUT
1800
1805
  });
1801
1806
  } else {
1802
1807
  (0, import_log5.log)("auth failed", err, {
1803
- file: "invitations-handler.ts",
1804
- line: 330,
1805
- scope: this,
1806
- callSite: (f, a) => f(...a)
1808
+ F: __dxlog_file5,
1809
+ L: 330,
1810
+ S: this,
1811
+ C: (f, a) => f(...a)
1807
1812
  });
1808
1813
  stream.error(err);
1809
1814
  }
@@ -1811,10 +1816,10 @@ var InvitationsHandler = class {
1811
1816
  id: traceId,
1812
1817
  error: err
1813
1818
  }), {
1814
- file: "invitations-handler.ts",
1815
- line: 333,
1816
- scope: this,
1817
- callSite: (f, a) => f(...a)
1819
+ F: __dxlog_file5,
1820
+ L: 333,
1821
+ S: this,
1822
+ C: (f, a) => f(...a)
1818
1823
  });
1819
1824
  } finally {
1820
1825
  await ctx.dispose();
@@ -1829,20 +1834,20 @@ var InvitationsHandler = class {
1829
1834
  (0, import_log5.log)("timeout", {
1830
1835
  ...protocol.toJSON()
1831
1836
  }, {
1832
- file: "invitations-handler.ts",
1833
- line: 344,
1834
- scope: this,
1835
- callSite: (f, a) => f(...a)
1837
+ F: __dxlog_file5,
1838
+ L: 344,
1839
+ S: this,
1840
+ C: (f, a) => f(...a)
1836
1841
  });
1837
1842
  setState({
1838
1843
  state: import_services3.Invitation.State.TIMEOUT
1839
1844
  });
1840
1845
  } else {
1841
1846
  (0, import_log5.log)("auth failed", err, {
1842
- file: "invitations-handler.ts",
1843
- line: 347,
1844
- scope: this,
1845
- callSite: (f, a) => f(...a)
1847
+ F: __dxlog_file5,
1848
+ L: 347,
1849
+ S: this,
1850
+ C: (f, a) => f(...a)
1846
1851
  });
1847
1852
  stream.error(err);
1848
1853
  }
@@ -1851,7 +1856,7 @@ var InvitationsHandler = class {
1851
1856
  return extension;
1852
1857
  };
1853
1858
  (0, import_async8.scheduleTask)(ctx, async () => {
1854
- (0, import_node_assert6.default)(invitation.swarmKey);
1859
+ (0, import_tiny_invariant6.default)(invitation.swarmKey);
1855
1860
  const topic = invitation.swarmKey;
1856
1861
  const swarmConnection = await this._networkManager.joinSwarm({
1857
1862
  topic,
@@ -1884,11 +1889,12 @@ var InvitationsHandler = class {
1884
1889
  };
1885
1890
 
1886
1891
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1887
- var import_node_assert7 = __toESM(require("node:assert"));
1892
+ var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
1888
1893
  var import_async9 = require("@dxos/async");
1889
1894
  var import_codec_protobuf8 = require("@dxos/codec-protobuf");
1890
1895
  var import_log6 = require("@dxos/log");
1891
1896
  var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
1897
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
1892
1898
  var InvitationsServiceImpl = class {
1893
1899
  constructor(_invitationsHandler, _getHandler) {
1894
1900
  this._invitationsHandler = _invitationsHandler;
@@ -1949,35 +1955,35 @@ var InvitationsServiceImpl = class {
1949
1955
  });
1950
1956
  }
1951
1957
  async authenticate({ invitationId, authCode }) {
1952
- (0, import_log6.log)("authenticating...", {}, {
1953
- file: "invitations-service.ts",
1954
- line: 103,
1955
- scope: this,
1956
- callSite: (f, a) => f(...a)
1958
+ (0, import_log6.log)("authenticating...", void 0, {
1959
+ F: __dxlog_file6,
1960
+ L: 103,
1961
+ S: this,
1962
+ C: (f, a) => f(...a)
1957
1963
  });
1958
- (0, import_node_assert7.default)(invitationId);
1964
+ (0, import_tiny_invariant7.default)(invitationId);
1959
1965
  const observable = this._acceptInvitations.get(invitationId);
1960
1966
  if (!observable) {
1961
1967
  import_log6.log.warn("invalid invitation", {
1962
1968
  invitationId
1963
1969
  }, {
1964
- file: "invitations-service.ts",
1965
- line: 107,
1966
- scope: this,
1967
- callSite: (f, a) => f(...a)
1970
+ F: __dxlog_file6,
1971
+ L: 107,
1972
+ S: this,
1973
+ C: (f, a) => f(...a)
1968
1974
  });
1969
1975
  } else {
1970
1976
  await observable.authenticate(authCode);
1971
1977
  }
1972
1978
  }
1973
1979
  async cancelInvitation({ invitationId }) {
1974
- (0, import_log6.log)("deleting...", {}, {
1975
- file: "invitations-service.ts",
1976
- line: 114,
1977
- scope: this,
1978
- callSite: (f, a) => f(...a)
1980
+ (0, import_log6.log)("deleting...", void 0, {
1981
+ F: __dxlog_file6,
1982
+ L: 114,
1983
+ S: this,
1984
+ C: (f, a) => f(...a)
1979
1985
  });
1980
- (0, import_node_assert7.default)(invitationId);
1986
+ (0, import_tiny_invariant7.default)(invitationId);
1981
1987
  const created = this._createInvitations.get(invitationId);
1982
1988
  const accepted = this._acceptInvitations.get(invitationId);
1983
1989
  if (created) {
@@ -1992,10 +1998,10 @@ var InvitationsServiceImpl = class {
1992
1998
  import_log6.log.warn("invalid invitation", {
1993
1999
  invitationId
1994
2000
  }, {
1995
- file: "invitations-service.ts",
1996
- line: 127,
1997
- scope: this,
1998
- callSite: (f, a) => f(...a)
2001
+ F: __dxlog_file6,
2002
+ L: 127,
2003
+ S: this,
2004
+ C: (f, a) => f(...a)
1999
2005
  });
2000
2006
  }
2001
2007
  }
@@ -2052,11 +2058,12 @@ var InvitationsServiceImpl = class {
2052
2058
  };
2053
2059
 
2054
2060
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
2055
- var import_node_assert8 = __toESM(require("node:assert"));
2061
+ var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
2056
2062
  var import_credentials8 = require("@dxos/credentials");
2057
2063
  var import_feed_store3 = require("@dxos/feed-store");
2058
2064
  var import_log7 = require("@dxos/log");
2059
2065
  var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
2066
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2060
2067
  var SpaceInvitationProtocol = class {
2061
2068
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
2062
2069
  this._spaceManager = _spaceManager;
@@ -2078,24 +2085,24 @@ var SpaceInvitationProtocol = class {
2078
2085
  }
2079
2086
  async admit(request, guestProfile) {
2080
2087
  var _a;
2081
- (0, import_node_assert8.default)(this._spaceKey);
2088
+ (0, import_tiny_invariant8.default)(this._spaceKey);
2082
2089
  const space = await this._spaceManager.spaces.get(this._spaceKey);
2083
- (0, import_node_assert8.default)(space);
2084
- (0, import_node_assert8.default)(request.space);
2090
+ (0, import_tiny_invariant8.default)(space);
2091
+ (0, import_tiny_invariant8.default)(request.space);
2085
2092
  const { identityKey, deviceKey } = request.space;
2086
2093
  (0, import_log7.log)("writing guest credentials", {
2087
2094
  host: this._signingContext.deviceKey,
2088
2095
  guest: deviceKey
2089
2096
  }, {
2090
- file: "space-invitation-protocol.ts",
2091
- line: 50,
2092
- scope: this,
2093
- callSite: (f, a) => f(...a)
2097
+ F: __dxlog_file7,
2098
+ L: 50,
2099
+ S: this,
2100
+ C: (f, a) => f(...a)
2094
2101
  });
2095
2102
  const credentials = await (0, import_credentials8.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
2096
- (0, import_node_assert8.default)(credentials[0].credential);
2103
+ (0, import_tiny_invariant8.default)(credentials[0].credential);
2097
2104
  const spaceMemberCredential = credentials[0].credential.credential;
2098
- (0, import_node_assert8.default)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2105
+ (0, import_tiny_invariant8.default)((0, import_credentials8.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2099
2106
  await (0, import_feed_store3.writeMessages)(space.inner.controlPipeline.writer, credentials);
2100
2107
  return {
2101
2108
  space: {
@@ -2123,11 +2130,11 @@ var SpaceInvitationProtocol = class {
2123
2130
  };
2124
2131
  }
2125
2132
  async accept(response) {
2126
- (0, import_node_assert8.default)(response.space);
2133
+ (0, import_tiny_invariant8.default)(response.space);
2127
2134
  const { credential, controlTimeframe, dataTimeframe } = response.space;
2128
2135
  const assertion = (0, import_credentials8.getCredentialAssertion)(credential);
2129
- (0, import_node_assert8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
2130
- (0, import_node_assert8.default)(credential.subject.id.equals(this._signingContext.identityKey));
2136
+ (0, import_tiny_invariant8.default)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential");
2137
+ (0, import_tiny_invariant8.default)(credential.subject.id.equals(this._signingContext.identityKey));
2131
2138
  await this._spaceManager.acceptSpace({
2132
2139
  spaceKey: assertion.spaceKey,
2133
2140
  genesisFeedKey: assertion.genesisFeedKey,
@@ -2142,7 +2149,7 @@ var SpaceInvitationProtocol = class {
2142
2149
  };
2143
2150
 
2144
2151
  // packages/sdk/client-services/src/packlets/services/service-context.ts
2145
- var import_node_assert11 = __toESM(require("node:assert"));
2152
+ var import_tiny_invariant11 = __toESM(require("tiny-invariant"));
2146
2153
  var import_async14 = require("@dxos/async");
2147
2154
  var import_credentials13 = require("@dxos/credentials");
2148
2155
  var import_debug6 = require("@dxos/debug");
@@ -2156,7 +2163,7 @@ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
2156
2163
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
2157
2164
 
2158
2165
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2159
- var import_node_assert10 = __toESM(require("node:assert"));
2166
+ var import_tiny_invariant10 = __toESM(require("tiny-invariant"));
2160
2167
  var import_async12 = require("@dxos/async");
2161
2168
  var import_context7 = require("@dxos/context");
2162
2169
  var import_credentials12 = require("@dxos/credentials");
@@ -2182,7 +2189,7 @@ var import_timeframe = require("@dxos/timeframe");
2182
2189
  var import_util4 = require("@dxos/util");
2183
2190
 
2184
2191
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2185
- var import_node_assert9 = __toESM(require("node:assert"));
2192
+ var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
2186
2193
  var import_async10 = require("@dxos/async");
2187
2194
  var import_context5 = require("@dxos/context");
2188
2195
  var import_keys7 = require("@dxos/keys");
@@ -2190,6 +2197,7 @@ var import_log8 = require("@dxos/log");
2190
2197
  var import_protocols5 = require("@dxos/protocols");
2191
2198
  var import_teleport2 = require("@dxos/teleport");
2192
2199
  var import_util3 = require("@dxos/util");
2200
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2193
2201
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2194
2202
  var DEFAULT_SUCCESS_DELAY = 1e3;
2195
2203
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
@@ -2202,6 +2210,9 @@ var NotarizationPlugin = class {
2202
2210
  this._processedCredentials = new import_util3.ComplexSet(import_keys7.PublicKey.hash);
2203
2211
  this._processCredentialsTriggers = new import_util3.ComplexMap(import_keys7.PublicKey.hash);
2204
2212
  }
2213
+ get hasWriter() {
2214
+ return !!this._writer;
2215
+ }
2205
2216
  async open() {
2206
2217
  }
2207
2218
  async close() {
@@ -2214,22 +2225,22 @@ var NotarizationPlugin = class {
2214
2225
  (0, import_log8.log)("notarize", {
2215
2226
  credentials
2216
2227
  }, {
2217
- file: "notarization-plugin.ts",
2218
- line: 87,
2219
- scope: this,
2220
- callSite: (f, a) => f(...a)
2228
+ F: __dxlog_file8,
2229
+ L: 91,
2230
+ S: this,
2231
+ C: (f, a) => f(...a)
2221
2232
  });
2222
- (0, import_node_assert9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2233
+ (0, import_tiny_invariant9.default)(credentials.every((credential) => credential.id), "Credentials must have an id");
2223
2234
  const errors = new import_async10.Trigger();
2224
2235
  const ctx = this._ctx.derive({
2225
2236
  onError: (err) => {
2226
2237
  import_log8.log.warn("Notarization error", {
2227
2238
  err
2228
2239
  }, {
2229
- file: "notarization-plugin.ts",
2230
- line: 96,
2231
- scope: this,
2232
- callSite: (f, a) => f(...a)
2240
+ F: __dxlog_file8,
2241
+ L: 100,
2242
+ S: this,
2243
+ C: (f, a) => f(...a)
2233
2244
  });
2234
2245
  void ctx.dispose();
2235
2246
  errors.throw(err);
@@ -2242,10 +2253,10 @@ var NotarizationPlugin = class {
2242
2253
  timeout,
2243
2254
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2244
2255
  }, {
2245
- file: "notarization-plugin.ts",
2246
- line: 108,
2247
- scope: this,
2248
- callSite: (f, a) => f(...a)
2256
+ F: __dxlog_file8,
2257
+ L: 112,
2258
+ S: this,
2259
+ C: (f, a) => f(...a)
2249
2260
  });
2250
2261
  void ctx.dispose();
2251
2262
  errors.throw(new import_async10.TimeoutError(timeout, "Notarization timed out"));
@@ -2265,10 +2276,10 @@ var NotarizationPlugin = class {
2265
2276
  import_log8.log.warn("Exhausted all peers to notarize with", {
2266
2277
  retryIn: retryTimeout
2267
2278
  }, {
2268
- file: "notarization-plugin.ts",
2269
- line: 133,
2270
- scope: this,
2271
- callSite: (f, a) => f(...a)
2279
+ F: __dxlog_file8,
2280
+ L: 137,
2281
+ S: this,
2282
+ C: (f, a) => f(...a)
2272
2283
  });
2273
2284
  peersTried.clear();
2274
2285
  (0, import_async10.scheduleTask)(ctx, () => notarizeTask.schedule(), retryTimeout);
@@ -2279,28 +2290,28 @@ var NotarizationPlugin = class {
2279
2290
  peer: peer.localPeerId,
2280
2291
  credentialId: credentials.map((credential) => credential.id)
2281
2292
  }, {
2282
- file: "notarization-plugin.ts",
2283
- line: 140,
2284
- scope: this,
2285
- callSite: (f, a) => f(...a)
2293
+ F: __dxlog_file8,
2294
+ L: 144,
2295
+ S: this,
2296
+ C: (f, a) => f(...a)
2286
2297
  });
2287
2298
  await peer.rpc.NotarizationService.notarize({
2288
2299
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2289
2300
  });
2290
- (0, import_log8.log)("success", {}, {
2291
- file: "notarization-plugin.ts",
2292
- line: 144,
2293
- scope: this,
2294
- callSite: (f, a) => f(...a)
2301
+ (0, import_log8.log)("success", void 0, {
2302
+ F: __dxlog_file8,
2303
+ L: 148,
2304
+ S: this,
2305
+ C: (f, a) => f(...a)
2295
2306
  });
2296
2307
  await (0, import_async10.sleep)(successDelay);
2297
2308
  } catch (err) {
2298
2309
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
2299
2310
  import_log8.log.warn("error notarizing (recoverable)", err, {
2300
- file: "notarization-plugin.ts",
2301
- line: 148,
2302
- scope: this,
2303
- callSite: (f, a) => f(...a)
2311
+ F: __dxlog_file8,
2312
+ L: 152,
2313
+ S: this,
2314
+ C: (f, a) => f(...a)
2304
2315
  });
2305
2316
  }
2306
2317
  notarizeTask.schedule();
@@ -2314,11 +2325,11 @@ var NotarizationPlugin = class {
2314
2325
  allNotarized,
2315
2326
  errors.wait()
2316
2327
  ]);
2317
- (0, import_log8.log)("done", {}, {
2318
- file: "notarization-plugin.ts",
2319
- line: 159,
2320
- scope: this,
2321
- callSite: (f, a) => f(...a)
2328
+ (0, import_log8.log)("done", void 0, {
2329
+ F: __dxlog_file8,
2330
+ L: 163,
2331
+ S: this,
2332
+ C: (f, a) => f(...a)
2322
2333
  });
2323
2334
  } finally {
2324
2335
  await ctx.dispose();
@@ -2327,7 +2338,7 @@ var NotarizationPlugin = class {
2327
2338
  /**
2328
2339
  * Called with credentials arriving from the control pipeline.
2329
2340
  */
2330
- async process(credential) {
2341
+ async processCredential(credential) {
2331
2342
  var _a;
2332
2343
  if (!credential.id) {
2333
2344
  return;
@@ -2337,7 +2348,7 @@ var NotarizationPlugin = class {
2337
2348
  this._processCredentialsTriggers.delete(credential.id);
2338
2349
  }
2339
2350
  setWriter(writer) {
2340
- (0, import_node_assert9.default)(!this._writer, "Writer already set.");
2351
+ (0, import_tiny_invariant9.default)(!this._writer, "Writer already set.");
2341
2352
  this._writer = writer;
2342
2353
  }
2343
2354
  async _waitUntilProcessed(id) {
@@ -2355,7 +2366,7 @@ var NotarizationPlugin = class {
2355
2366
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2356
2367
  }
2357
2368
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2358
- (0, import_node_assert9.default)(credential.id, "Credential must have an id");
2369
+ (0, import_tiny_invariant9.default)(credential.id, "Credential must have an id");
2359
2370
  if (this._processedCredentials.has(credential.id)) {
2360
2371
  continue;
2361
2372
  }
@@ -2368,10 +2379,10 @@ var NotarizationPlugin = class {
2368
2379
  (0, import_log8.log)("extension opened", {
2369
2380
  peer: extension.localPeerId
2370
2381
  }, {
2371
- file: "notarization-plugin.ts",
2372
- line: 208,
2373
- scope: this,
2374
- callSite: (f, a) => f(...a)
2382
+ F: __dxlog_file8,
2383
+ L: 212,
2384
+ S: this,
2385
+ C: (f, a) => f(...a)
2375
2386
  });
2376
2387
  this._extensions.add(extension);
2377
2388
  this._extensionOpened.emit();
@@ -2380,10 +2391,10 @@ var NotarizationPlugin = class {
2380
2391
  (0, import_log8.log)("extension closed", {
2381
2392
  peer: extension.localPeerId
2382
2393
  }, {
2383
- file: "notarization-plugin.ts",
2384
- line: 213,
2385
- scope: this,
2386
- callSite: (f, a) => f(...a)
2394
+ F: __dxlog_file8,
2395
+ L: 217,
2396
+ S: this,
2397
+ C: (f, a) => f(...a)
2387
2398
  });
2388
2399
  this._extensions.delete(extension);
2389
2400
  },
@@ -2424,7 +2435,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2424
2435
  };
2425
2436
 
2426
2437
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2427
- var __decorate = function(decorators, target, key, desc) {
2438
+ function _ts_decorate(decorators, target, key, desc) {
2428
2439
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2429
2440
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2430
2441
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2433,10 +2444,12 @@ var __decorate = function(decorators, target, key, desc) {
2433
2444
  if (d = decorators[i])
2434
2445
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2435
2446
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2436
- };
2447
+ }
2448
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2437
2449
  var DataSpace = class DataSpace2 {
2438
2450
  constructor(params) {
2439
2451
  this._ctx = new import_context6.Context();
2452
+ this._notarizationPlugin = new NotarizationPlugin();
2440
2453
  this._state = import_services6.SpaceState.CLOSED;
2441
2454
  /**
2442
2455
  * Error for _state === SpaceState.ERROR.
@@ -2459,8 +2472,8 @@ var DataSpace = class DataSpace2 {
2459
2472
  update: this._inner.stateUpdate,
2460
2473
  authTimeout: import_client_protocol3.AUTH_TIMEOUT
2461
2474
  });
2462
- this._notarizationPluginConsumer = this._inner.spaceState.registerProcessor(new NotarizationPlugin());
2463
2475
  this._cache = params.cache;
2476
+ this._state = params.initialState;
2464
2477
  }
2465
2478
  get key() {
2466
2479
  return this._inner.key;
@@ -2482,25 +2495,36 @@ var DataSpace = class DataSpace2 {
2482
2495
  return this._presence;
2483
2496
  }
2484
2497
  get notarizationPlugin() {
2485
- return this._notarizationPluginConsumer.processor;
2498
+ return this._notarizationPlugin;
2486
2499
  }
2487
2500
  get cache() {
2488
2501
  return this._cache;
2489
2502
  }
2490
2503
  async open() {
2491
- await this.notarizationPlugin.open();
2492
- await this._notarizationPluginConsumer.open();
2504
+ await this._open();
2505
+ }
2506
+ async _open() {
2507
+ await this._notarizationPlugin.open();
2508
+ await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
2493
2509
  await this._inner.open();
2494
- this._state = import_services6.SpaceState.INACTIVE;
2510
+ this._state = import_services6.SpaceState.CONTROL_ONLY;
2511
+ this.stateUpdate.emit();
2512
+ this.metrics = {};
2495
2513
  this.metrics.open = new Date();
2496
2514
  }
2497
2515
  async close() {
2516
+ await this._close();
2517
+ }
2518
+ async _close() {
2519
+ var _a, _b;
2520
+ await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
2498
2521
  this._state = import_services6.SpaceState.CLOSED;
2499
2522
  await this._ctx.dispose();
2523
+ this._ctx = new import_context6.Context();
2500
2524
  await this.authVerifier.close();
2501
2525
  await this._inner.close();
2502
- await this._notarizationPluginConsumer.close();
2503
- await this.notarizationPlugin.close();
2526
+ await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
2527
+ await this._notarizationPlugin.close();
2504
2528
  await this._presence.destroy();
2505
2529
  }
2506
2530
  async postMessage(channel, message) {
@@ -2520,18 +2544,18 @@ var DataSpace = class DataSpace2 {
2520
2544
  } catch (err) {
2521
2545
  if (err instanceof import_errors3.CancelledError) {
2522
2546
  (0, import_log9.log)("Data pipeline initialization cancelled", err, {
2523
- file: "data-space.ts",
2524
- line: 173,
2525
- scope: this,
2526
- callSite: (f, a) => f(...a)
2547
+ F: __dxlog_file9,
2548
+ L: 193,
2549
+ S: this,
2550
+ C: (f, a) => f(...a)
2527
2551
  });
2528
2552
  return;
2529
2553
  }
2530
2554
  import_log9.log.error("Error initializing data pipeline", err, {
2531
- file: "data-space.ts",
2532
- line: 177,
2533
- scope: this,
2534
- callSite: (f, a) => f(...a)
2555
+ F: __dxlog_file9,
2556
+ L: 197,
2557
+ S: this,
2558
+ C: (f, a) => f(...a)
2535
2559
  });
2536
2560
  this._state = import_services6.SpaceState.ERROR;
2537
2561
  this.error = err;
@@ -2543,7 +2567,7 @@ var DataSpace = class DataSpace2 {
2543
2567
  }
2544
2568
  async initializeDataPipeline() {
2545
2569
  var _a, _b, _c, _d;
2546
- if (this._state !== import_services6.SpaceState.INACTIVE) {
2570
+ if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
2547
2571
  throw new import_errors3.SystemError("Invalid operation");
2548
2572
  }
2549
2573
  this._state = import_services6.SpaceState.INITIALIZING;
@@ -2553,37 +2577,39 @@ var DataSpace = class DataSpace2 {
2553
2577
  });
2554
2578
  this.metrics.controlPipelineReady = new Date();
2555
2579
  await this._createWritableFeeds();
2556
- (0, import_log9.log)("Writable feeds created", {}, {
2557
- file: "data-space.ts",
2558
- line: 201,
2559
- scope: this,
2560
- callSite: (f, a) => f(...a)
2580
+ (0, import_log9.log)("Writable feeds created", void 0, {
2581
+ F: __dxlog_file9,
2582
+ L: 221,
2583
+ S: this,
2584
+ C: (f, a) => f(...a)
2561
2585
  });
2562
2586
  this.stateUpdate.emit();
2563
- this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
2564
- credential: {
2565
- credential
2566
- }
2567
- }), this._inner.controlPipeline.writer));
2587
+ if (!this.notarizationPlugin.hasWriter) {
2588
+ this.notarizationPlugin.setWriter((0, import_echo_pipeline.createMappedFeedWriter)((credential) => ({
2589
+ credential: {
2590
+ credential
2591
+ }
2592
+ }), this._inner.controlPipeline.writer));
2593
+ }
2568
2594
  await this._inner.initializeDataPipeline();
2569
2595
  this.metrics.dataPipelineOpen = new Date();
2570
2596
  await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2571
- (0, import_log9.log)("waiting for data pipeline to reach target timeframe", {}, {
2572
- file: "data-space.ts",
2573
- line: 220,
2574
- scope: this,
2575
- callSite: (f, a) => f(...a)
2597
+ (0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
2598
+ F: __dxlog_file9,
2599
+ L: 242,
2600
+ S: this,
2601
+ C: (f, a) => f(...a)
2576
2602
  });
2577
2603
  await this._inner.dataPipeline.pipelineState.waitUntilReachedTargetTimeframe({
2578
2604
  ctx: this._ctx,
2579
2605
  breakOnStall: false
2580
2606
  });
2581
2607
  this.metrics.dataPipelineReady = new Date();
2582
- (0, import_log9.log)("data pipeline ready", {}, {
2583
- file: "data-space.ts",
2584
- line: 229,
2585
- scope: this,
2586
- callSite: (f, a) => f(...a)
2608
+ (0, import_log9.log)("data pipeline ready", void 0, {
2609
+ F: __dxlog_file9,
2610
+ L: 251,
2611
+ S: this,
2612
+ C: (f, a) => f(...a)
2587
2613
  });
2588
2614
  await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
2589
2615
  this._state = import_services6.SpaceState.READY;
@@ -2661,11 +2687,40 @@ var DataSpace = class DataSpace2 {
2661
2687
  }
2662
2688
  }
2663
2689
  }
2690
+ async activate() {
2691
+ if (this._state !== import_services6.SpaceState.INACTIVE) {
2692
+ throw new import_errors3.SystemError("Invalid operation");
2693
+ }
2694
+ await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.ACTIVE);
2695
+ await this._open();
2696
+ this.initializeDataPipelineAsync();
2697
+ }
2698
+ async deactivate() {
2699
+ if (this._state === import_services6.SpaceState.INACTIVE) {
2700
+ throw new import_errors3.SystemError("Invalid operation");
2701
+ }
2702
+ await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.INACTIVE);
2703
+ await this._close();
2704
+ this._state = import_services6.SpaceState.INACTIVE;
2705
+ this.stateUpdate.emit();
2706
+ }
2664
2707
  };
2665
- __decorate([
2708
+ _ts_decorate([
2709
+ import_async11.synchronized
2710
+ ], DataSpace.prototype, "open", null);
2711
+ _ts_decorate([
2712
+ import_async11.synchronized
2713
+ ], DataSpace.prototype, "close", null);
2714
+ _ts_decorate([
2666
2715
  (0, import_debug3.timed)(1e4)
2667
2716
  ], DataSpace.prototype, "_createWritableFeeds", null);
2668
- DataSpace = __decorate([
2717
+ _ts_decorate([
2718
+ import_async11.synchronized
2719
+ ], DataSpace.prototype, "activate", null);
2720
+ _ts_decorate([
2721
+ import_async11.synchronized
2722
+ ], DataSpace.prototype, "deactivate", null);
2723
+ DataSpace = _ts_decorate([
2669
2724
  (0, import_async11.trackLeaks)("open", "close")
2670
2725
  ], DataSpace);
2671
2726
 
@@ -2740,7 +2795,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2740
2795
  };
2741
2796
 
2742
2797
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2743
- var __decorate2 = function(decorators, target, key, desc) {
2798
+ function _ts_decorate2(decorators, target, key, desc) {
2744
2799
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2745
2800
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2746
2801
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2749,7 +2804,8 @@ var __decorate2 = function(decorators, target, key, desc) {
2749
2804
  if (d = decorators[i])
2750
2805
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2751
2806
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2752
- };
2807
+ }
2808
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
2753
2809
  var DataSpaceManager = class DataSpaceManager2 {
2754
2810
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
2755
2811
  this._spaceManager = _spaceManager;
@@ -2769,50 +2825,52 @@ var DataSpaceManager = class DataSpaceManager2 {
2769
2825
  return this._spaces;
2770
2826
  }
2771
2827
  async open() {
2772
- (0, import_log10.log)("open", {}, {
2773
- file: "data-space-manager.ts",
2774
- line: 80,
2775
- scope: this,
2776
- callSite: (f, a) => f(...a)
2828
+ (0, import_log10.log)("open", void 0, {
2829
+ F: __dxlog_file10,
2830
+ L: 80,
2831
+ S: this,
2832
+ C: (f, a) => f(...a)
2777
2833
  });
2778
2834
  import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
2779
2835
  id: this._instanceId
2780
2836
  }), {
2781
- file: "data-space-manager.ts",
2782
- line: 81,
2783
- scope: this,
2784
- callSite: (f, a) => f(...a)
2837
+ F: __dxlog_file10,
2838
+ L: 81,
2839
+ S: this,
2840
+ C: (f, a) => f(...a)
2785
2841
  });
2786
2842
  await this._metadataStore.load();
2787
2843
  (0, import_log10.log)("metadata loaded", {
2788
2844
  spaces: this._metadataStore.spaces.length
2789
2845
  }, {
2790
- file: "data-space-manager.ts",
2791
- line: 83,
2792
- scope: this,
2793
- callSite: (f, a) => f(...a)
2846
+ F: __dxlog_file10,
2847
+ L: 83,
2848
+ S: this,
2849
+ C: (f, a) => f(...a)
2794
2850
  });
2795
2851
  for (const spaceMetadata of this._metadataStore.spaces) {
2796
2852
  try {
2797
2853
  (0, import_log10.log)("load space", {
2798
2854
  spaceMetadata
2799
2855
  }, {
2800
- file: "data-space-manager.ts",
2801
- line: 87,
2802
- scope: this,
2803
- callSite: (f, a) => f(...a)
2856
+ F: __dxlog_file10,
2857
+ L: 87,
2858
+ S: this,
2859
+ C: (f, a) => f(...a)
2804
2860
  });
2805
2861
  const space = await this._constructSpace(spaceMetadata);
2806
- space.initializeDataPipelineAsync();
2862
+ if (spaceMetadata.state !== import_services7.SpaceState.INACTIVE) {
2863
+ space.initializeDataPipelineAsync();
2864
+ }
2807
2865
  } catch (err) {
2808
2866
  import_log10.log.error("Error loading space", {
2809
2867
  spaceMetadata,
2810
2868
  err
2811
2869
  }, {
2812
- file: "data-space-manager.ts",
2813
- line: 91,
2814
- scope: this,
2815
- callSite: (f, a) => f(...a)
2870
+ F: __dxlog_file10,
2871
+ L: 93,
2872
+ S: this,
2873
+ C: (f, a) => f(...a)
2816
2874
  });
2817
2875
  }
2818
2876
  }
@@ -2821,18 +2879,18 @@ var DataSpaceManager = class DataSpaceManager2 {
2821
2879
  import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
2822
2880
  id: this._instanceId
2823
2881
  }), {
2824
- file: "data-space-manager.ts",
2825
- line: 97,
2826
- scope: this,
2827
- callSite: (f, a) => f(...a)
2882
+ F: __dxlog_file10,
2883
+ L: 99,
2884
+ S: this,
2885
+ C: (f, a) => f(...a)
2828
2886
  });
2829
2887
  }
2830
2888
  async close() {
2831
- (0, import_log10.log)("close", {}, {
2832
- file: "data-space-manager.ts",
2833
- line: 102,
2834
- scope: this,
2835
- callSite: (f, a) => f(...a)
2889
+ (0, import_log10.log)("close", void 0, {
2890
+ F: __dxlog_file10,
2891
+ L: 104,
2892
+ S: this,
2893
+ C: (f, a) => f(...a)
2836
2894
  });
2837
2895
  this._isOpen = false;
2838
2896
  await this._ctx.dispose();
@@ -2844,7 +2902,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2844
2902
  * Creates a new space writing the genesis credentials to the control feed.
2845
2903
  */
2846
2904
  async createSpace() {
2847
- (0, import_node_assert10.default)(this._isOpen, "Not open.");
2905
+ (0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
2848
2906
  const spaceKey = await this._keyring.createKey();
2849
2907
  const controlFeedKey = await this._keyring.createKey();
2850
2908
  const dataFeedKey = await this._keyring.createKey();
@@ -2852,21 +2910,22 @@ var DataSpaceManager = class DataSpaceManager2 {
2852
2910
  key: spaceKey,
2853
2911
  genesisFeedKey: controlFeedKey,
2854
2912
  controlFeedKey,
2855
- dataFeedKey
2913
+ dataFeedKey,
2914
+ state: import_services7.SpaceState.ACTIVE
2856
2915
  };
2857
2916
  (0, import_log10.log)("creating space...", {
2858
2917
  spaceKey
2859
2918
  }, {
2860
- file: "data-space-manager.ts",
2861
- line: 126,
2862
- scope: this,
2863
- callSite: (f, a) => f(...a)
2919
+ F: __dxlog_file10,
2920
+ L: 129,
2921
+ S: this,
2922
+ C: (f, a) => f(...a)
2864
2923
  });
2865
2924
  const space = await this._constructSpace(metadata);
2866
2925
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
2867
2926
  await this._metadataStore.addSpace(metadata);
2868
2927
  const memberCredential = credentials[1];
2869
- (0, import_node_assert10.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2928
+ (0, import_tiny_invariant10.default)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember");
2870
2929
  await this._signingContext.recordCredential(memberCredential);
2871
2930
  await space.initializeDataPipeline();
2872
2931
  this.updated.emit();
@@ -2877,13 +2936,13 @@ var DataSpaceManager = class DataSpaceManager2 {
2877
2936
  (0, import_log10.log)("accept space", {
2878
2937
  opts
2879
2938
  }, {
2880
- file: "data-space-manager.ts",
2881
- line: 145,
2882
- scope: this,
2883
- callSite: (f, a) => f(...a)
2939
+ F: __dxlog_file10,
2940
+ L: 148,
2941
+ S: this,
2942
+ C: (f, a) => f(...a)
2884
2943
  });
2885
- (0, import_node_assert10.default)(this._isOpen, "Not open.");
2886
- (0, import_node_assert10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
2944
+ (0, import_tiny_invariant10.default)(this._isOpen, "Not open.");
2945
+ (0, import_tiny_invariant10.default)(!this._spaces.has(opts.spaceKey), "Space already exists.");
2887
2946
  const metadata = {
2888
2947
  key: opts.spaceKey,
2889
2948
  genesisFeedKey: opts.genesisFeedKey,
@@ -2911,10 +2970,10 @@ var DataSpaceManager = class DataSpaceManager2 {
2911
2970
  (0, import_log10.log)("construct space", {
2912
2971
  metadata
2913
2972
  }, {
2914
- file: "data-space-manager.ts",
2915
- line: 180,
2916
- scope: this,
2917
- callSite: (f, a) => f(...a)
2973
+ F: __dxlog_file10,
2974
+ L: 183,
2975
+ S: this,
2976
+ C: (f, a) => f(...a)
2918
2977
  });
2919
2978
  const gossip = new import_teleport_extension_gossip.Gossip({
2920
2979
  localPeerId: this._signingContext.deviceKey
@@ -2946,11 +3005,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2946
3005
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
2947
3006
  },
2948
3007
  onAuthFailure: () => {
2949
- import_log10.log.warn("auth failure", {}, {
2950
- file: "data-space-manager.ts",
2951
- line: 211,
2952
- scope: this,
2953
- callSite: (f, a) => f(...a)
3008
+ import_log10.log.warn("auth failure", void 0, {
3009
+ F: __dxlog_file10,
3010
+ L: 214,
3011
+ S: this,
3012
+ C: (f, a) => f(...a)
2954
3013
  });
2955
3014
  },
2956
3015
  memberKey: this._signingContext.identityKey
@@ -2959,6 +3018,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2959
3018
  dataFeed && space.setDataFeed(dataFeed);
2960
3019
  const dataSpace = new DataSpace({
2961
3020
  inner: space,
3021
+ initialState: metadata.state === import_services7.SpaceState.INACTIVE ? import_services7.SpaceState.INACTIVE : import_services7.SpaceState.CLOSED,
2962
3022
  metadataStore: this._metadataStore,
2963
3023
  gossip,
2964
3024
  presence,
@@ -2970,31 +3030,44 @@ var DataSpaceManager = class DataSpaceManager2 {
2970
3030
  (0, import_log10.log)("before space ready", {
2971
3031
  space: space.key
2972
3032
  }, {
2973
- file: "data-space-manager.ts",
2974
- line: 228,
2975
- scope: this,
2976
- callSite: (f, a) => f(...a)
3033
+ F: __dxlog_file10,
3034
+ L: 232,
3035
+ S: this,
3036
+ C: (f, a) => f(...a)
2977
3037
  });
2978
- this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
3038
+ await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
2979
3039
  },
2980
3040
  afterReady: async () => {
2981
3041
  (0, import_log10.log)("after space ready", {
2982
3042
  space: space.key,
2983
3043
  open: this._isOpen
2984
3044
  }, {
2985
- file: "data-space-manager.ts",
2986
- line: 235,
2987
- scope: this,
2988
- callSite: (f, a) => f(...a)
3045
+ F: __dxlog_file10,
3046
+ L: 239,
3047
+ S: this,
3048
+ C: (f, a) => f(...a)
2989
3049
  });
2990
3050
  if (this._isOpen) {
2991
3051
  this.updated.emit();
2992
3052
  }
3053
+ },
3054
+ beforeClose: async () => {
3055
+ (0, import_log10.log)("before space close", {
3056
+ space: space.key
3057
+ }, {
3058
+ F: __dxlog_file10,
3059
+ L: 245,
3060
+ S: this,
3061
+ C: (f, a) => f(...a)
3062
+ });
3063
+ await this._dataServiceSubscriptions.unregisterSpace(space.key);
2993
3064
  }
2994
3065
  },
2995
3066
  cache: metadata.cache
2996
3067
  });
2997
- await dataSpace.open();
3068
+ if (metadata.state !== import_services7.SpaceState.INACTIVE) {
3069
+ await dataSpace.open();
3070
+ }
2998
3071
  if (metadata.controlTimeframe) {
2999
3072
  dataSpace.inner.controlPipeline.state.setTargetTimeframe(metadata.controlTimeframe);
3000
3073
  }
@@ -3005,19 +3078,19 @@ var DataSpaceManager = class DataSpaceManager2 {
3005
3078
  return dataSpace;
3006
3079
  }
3007
3080
  };
3008
- __decorate2([
3081
+ _ts_decorate2([
3009
3082
  import_async12.synchronized
3010
3083
  ], DataSpaceManager.prototype, "open", null);
3011
- __decorate2([
3084
+ _ts_decorate2([
3012
3085
  import_async12.synchronized
3013
3086
  ], DataSpaceManager.prototype, "close", null);
3014
- __decorate2([
3087
+ _ts_decorate2([
3015
3088
  import_async12.synchronized
3016
3089
  ], DataSpaceManager.prototype, "createSpace", null);
3017
- __decorate2([
3090
+ _ts_decorate2([
3018
3091
  import_async12.synchronized
3019
3092
  ], DataSpaceManager.prototype, "acceptSpace", null);
3020
- DataSpaceManager = __decorate2([
3093
+ DataSpaceManager = _ts_decorate2([
3021
3094
  (0, import_async12.trackLeaks)("open", "close")
3022
3095
  ], DataSpaceManager);
3023
3096
 
@@ -3026,10 +3099,12 @@ var import_async13 = require("@dxos/async");
3026
3099
  var import_codec_protobuf9 = require("@dxos/codec-protobuf");
3027
3100
  var import_debug5 = require("@dxos/debug");
3028
3101
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
3102
+ var import_errors4 = require("@dxos/errors");
3029
3103
  var import_log11 = require("@dxos/log");
3030
3104
  var import_protocols7 = require("@dxos/protocols");
3031
3105
  var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
3032
3106
  var import_util6 = require("@dxos/util");
3107
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3033
3108
  var SpacesServiceImpl = class {
3034
3109
  constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
3035
3110
  this._identityManager = _identityManager;
@@ -3045,8 +3120,22 @@ var SpacesServiceImpl = class {
3045
3120
  const space = await dataSpaceManager.createSpace();
3046
3121
  return this._serializeSpace(space);
3047
3122
  }
3048
- async updateSpace(request) {
3049
- (0, import_debug5.todo)();
3123
+ async updateSpace({ spaceKey, state }) {
3124
+ var _a;
3125
+ const dataSpaceManager = await this._getDataSpaceManager();
3126
+ const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3127
+ if (state) {
3128
+ switch (state) {
3129
+ case import_services8.SpaceState.ACTIVE:
3130
+ await space.activate();
3131
+ break;
3132
+ case import_services8.SpaceState.INACTIVE:
3133
+ await space.deactivate();
3134
+ break;
3135
+ default:
3136
+ throw new import_errors4.ApiError("Invalid space state");
3137
+ }
3138
+ }
3050
3139
  }
3051
3140
  querySpaces() {
3052
3141
  return new import_codec_protobuf9.Stream(({ next, ctx }) => {
@@ -3056,10 +3145,10 @@ var SpacesServiceImpl = class {
3056
3145
  (0, import_log11.log)("update", {
3057
3146
  spaces
3058
3147
  }, {
3059
- file: "spaces-service.ts",
3060
- line: 60,
3061
- scope: this,
3062
- callSite: (f, a) => f(...a)
3148
+ F: __dxlog_file11,
3149
+ L: 78,
3150
+ S: this,
3151
+ C: (f, a) => f(...a)
3063
3152
  });
3064
3153
  next({
3065
3154
  spaces
@@ -3120,13 +3209,13 @@ var SpacesServiceImpl = class {
3120
3209
  return new import_codec_protobuf9.Stream(({ ctx, next }) => {
3121
3210
  var _a;
3122
3211
  const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug5.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3123
- const processor = space.spaceState.registerProcessor({
3124
- process: async (credential) => {
3212
+ const processor = {
3213
+ processCredential: async (credential) => {
3125
3214
  next(credential);
3126
3215
  }
3127
- });
3128
- ctx.onDispose(() => processor.close());
3129
- (0, import_async13.scheduleTask)(ctx, () => processor.open());
3216
+ };
3217
+ ctx.onDispose(() => space.spaceState.removeCredentialProcessor(processor));
3218
+ (0, import_async13.scheduleTask)(ctx, () => space.spaceState.addCredentialProcessor(processor));
3130
3219
  });
3131
3220
  }
3132
3221
  async writeCredentials({ spaceKey, credentials }) {
@@ -3186,6 +3275,7 @@ var SpacesServiceImpl = class {
3186
3275
  var getChannelId = (channel) => `user-channel/${channel}`;
3187
3276
 
3188
3277
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3278
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3189
3279
  var ServiceContext = class {
3190
3280
  // prettier-ignore
3191
3281
  constructor(storage, networkManager, signalManager, modelFactory) {
@@ -3229,17 +3319,17 @@ var ServiceContext = class {
3229
3319
  import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
3230
3320
  id: this._instanceId
3231
3321
  }), {
3232
- file: "service-context.ts",
3233
- line: 126,
3234
- scope: this,
3235
- callSite: (f, a) => f(...a)
3322
+ F: __dxlog_file12,
3323
+ L: 126,
3324
+ S: this,
3325
+ C: (f, a) => f(...a)
3236
3326
  });
3237
3327
  await this._checkStorageVersion();
3238
- (0, import_log12.log)("opening...", {}, {
3239
- file: "service-context.ts",
3240
- line: 130,
3241
- scope: this,
3242
- callSite: (f, a) => f(...a)
3328
+ (0, import_log12.log)("opening...", void 0, {
3329
+ F: __dxlog_file12,
3330
+ L: 130,
3331
+ S: this,
3332
+ C: (f, a) => f(...a)
3243
3333
  });
3244
3334
  await this.signalManager.open();
3245
3335
  await this.networkManager.open();
@@ -3248,42 +3338,44 @@ var ServiceContext = class {
3248
3338
  if (this.identityManager.identity) {
3249
3339
  await this._initialize();
3250
3340
  }
3251
- (0, import_log12.log)("opened", {}, {
3252
- file: "service-context.ts",
3253
- line: 138,
3254
- scope: this,
3255
- callSite: (f, a) => f(...a)
3341
+ (0, import_log12.log)("opened", void 0, {
3342
+ F: __dxlog_file12,
3343
+ L: 138,
3344
+ S: this,
3345
+ C: (f, a) => f(...a)
3256
3346
  });
3257
3347
  import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
3258
3348
  id: this._instanceId
3259
3349
  }), {
3260
- file: "service-context.ts",
3261
- line: 139,
3262
- scope: this,
3263
- callSite: (f, a) => f(...a)
3350
+ F: __dxlog_file12,
3351
+ L: 139,
3352
+ S: this,
3353
+ C: (f, a) => f(...a)
3264
3354
  });
3265
3355
  }
3266
3356
  async close() {
3267
- var _a, _b;
3268
- (0, import_log12.log)("closing...", {}, {
3269
- file: "service-context.ts",
3270
- line: 143,
3271
- scope: this,
3272
- callSite: (f, a) => f(...a)
3273
- });
3274
- await ((_a = this._deviceSpaceSync) == null ? void 0 : _a.close());
3275
- await ((_b = this.dataSpaceManager) == null ? void 0 : _b.close());
3357
+ var _a;
3358
+ (0, import_log12.log)("closing...", void 0, {
3359
+ F: __dxlog_file12,
3360
+ L: 143,
3361
+ S: this,
3362
+ C: (f, a) => f(...a)
3363
+ });
3364
+ if (this._deviceSpaceSync && this.identityManager.identity) {
3365
+ await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
3366
+ }
3367
+ await ((_a = this.dataSpaceManager) == null ? void 0 : _a.close());
3276
3368
  await this.identityManager.close();
3277
3369
  await this.spaceManager.close();
3278
3370
  await this.feedStore.close();
3279
3371
  await this.networkManager.close();
3280
3372
  await this.signalManager.close();
3281
3373
  this.dataServiceSubscriptions.clear();
3282
- (0, import_log12.log)("closed", {}, {
3283
- file: "service-context.ts",
3284
- line: 152,
3285
- scope: this,
3286
- callSite: (f, a) => f(...a)
3374
+ (0, import_log12.log)("closed", void 0, {
3375
+ F: __dxlog_file12,
3376
+ L: 154,
3377
+ S: this,
3378
+ C: (f, a) => f(...a)
3287
3379
  });
3288
3380
  }
3289
3381
  async createIdentity(params = {}) {
@@ -3293,7 +3385,7 @@ var ServiceContext = class {
3293
3385
  }
3294
3386
  getInvitationHandler(invitation) {
3295
3387
  const factory = this._handlerFactories.get(invitation.kind);
3296
- (0, import_node_assert11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3388
+ (0, import_tiny_invariant11.default)(factory, `Unknown invitation kind: ${invitation.kind}`);
3297
3389
  return factory(invitation);
3298
3390
  }
3299
3391
  async _acceptIdentity(params) {
@@ -3310,11 +3402,11 @@ var ServiceContext = class {
3310
3402
  // Called when identity is created.
3311
3403
  async _initialize() {
3312
3404
  var _a;
3313
- (0, import_log12.log)("initializing spaces...", {}, {
3314
- file: "service-context.ts",
3315
- line: 185,
3316
- scope: this,
3317
- callSite: (f, a) => f(...a)
3405
+ (0, import_log12.log)("initializing spaces...", void 0, {
3406
+ F: __dxlog_file12,
3407
+ L: 187,
3408
+ S: this,
3409
+ C: (f, a) => f(...a)
3318
3410
  });
3319
3411
  const identity = (_a = this.identityManager.identity) != null ? _a : (0, import_debug6.failUndefined)();
3320
3412
  const signingContext = {
@@ -3333,12 +3425,12 @@ var ServiceContext = class {
3333
3425
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3334
3426
  await this.dataSpaceManager.open();
3335
3427
  this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
3336
- (0, import_node_assert11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3428
+ (0, import_tiny_invariant11.default)(this.dataSpaceManager, "dataSpaceManager not initialized yet");
3337
3429
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
3338
3430
  });
3339
3431
  this.initialized.wake();
3340
- this._deviceSpaceSync = identity.space.spaceState.registerProcessor({
3341
- process: async (credential) => {
3432
+ this._deviceSpaceSync = {
3433
+ processCredential: async (credential) => {
3342
3434
  const assertion = (0, import_credentials13.getCredentialAssertion)(credential);
3343
3435
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
3344
3436
  return;
@@ -3350,10 +3442,10 @@ var ServiceContext = class {
3350
3442
  (0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
3351
3443
  details: assertion
3352
3444
  }, {
3353
- file: "service-context.ts",
3354
- line: 224,
3355
- scope: this,
3356
- callSite: (f, a) => f(...a)
3445
+ F: __dxlog_file12,
3446
+ L: 226,
3447
+ S: this,
3448
+ C: (f, a) => f(...a)
3357
3449
  });
3358
3450
  return;
3359
3451
  }
@@ -3361,10 +3453,10 @@ var ServiceContext = class {
3361
3453
  (0, import_log12.log)("space already exists, ignoring space admission", {
3362
3454
  details: assertion
3363
3455
  }, {
3364
- file: "service-context.ts",
3365
- line: 228,
3366
- scope: this,
3367
- callSite: (f, a) => f(...a)
3456
+ F: __dxlog_file12,
3457
+ L: 230,
3458
+ S: this,
3459
+ C: (f, a) => f(...a)
3368
3460
  });
3369
3461
  return;
3370
3462
  }
@@ -3372,40 +3464,43 @@ var ServiceContext = class {
3372
3464
  (0, import_log12.log)("accepting space recorded in halo", {
3373
3465
  details: assertion
3374
3466
  }, {
3375
- file: "service-context.ts",
3376
- line: 233,
3377
- scope: this,
3378
- callSite: (f, a) => f(...a)
3467
+ F: __dxlog_file12,
3468
+ L: 235,
3469
+ S: this,
3470
+ C: (f, a) => f(...a)
3379
3471
  });
3380
3472
  await this.dataSpaceManager.acceptSpace({
3381
3473
  spaceKey: assertion.spaceKey,
3382
3474
  genesisFeedKey: assertion.genesisFeedKey
3383
3475
  });
3384
3476
  } catch (err) {
3385
- import_log12.log.catch(err, {}, {
3386
- file: "service-context.ts",
3387
- line: 239,
3388
- scope: this,
3389
- callSite: (f, a) => f(...a)
3477
+ import_log12.log.catch(err, void 0, {
3478
+ F: __dxlog_file12,
3479
+ L: 241,
3480
+ S: this,
3481
+ C: (f, a) => f(...a)
3390
3482
  });
3391
3483
  }
3392
3484
  }
3393
- });
3394
- await this._deviceSpaceSync.open();
3485
+ };
3486
+ await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
3395
3487
  }
3396
3488
  };
3397
3489
 
3398
3490
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3399
- var import_node_assert13 = __toESM(require("node:assert"));
3491
+ var import_tiny_invariant13 = __toESM(require("tiny-invariant"));
3400
3492
  var import_async17 = require("@dxos/async");
3401
3493
  var import_client_protocol5 = require("@dxos/client-protocol");
3494
+ var import_document_model = require("@dxos/document-model");
3402
3495
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3403
3496
  var import_keys11 = require("@dxos/keys");
3404
3497
  var import_log15 = require("@dxos/log");
3405
3498
  var import_messaging = require("@dxos/messaging");
3499
+ var import_model_factory = require("@dxos/model-factory");
3406
3500
  var import_network_manager2 = require("@dxos/network-manager");
3407
3501
  var import_protocols9 = require("@dxos/protocols");
3408
3502
  var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3503
+ var import_text_model = require("@dxos/text-model");
3409
3504
 
3410
3505
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3411
3506
  var import_async15 = require("@dxos/async");
@@ -3455,10 +3550,10 @@ var DevicesServiceImpl = class {
3455
3550
  };
3456
3551
 
3457
3552
  // packages/sdk/client-services/src/packlets/locks/node.ts
3458
- var import_node_assert12 = __toESM(require("node:assert"));
3553
+ var import_tiny_invariant12 = __toESM(require("tiny-invariant"));
3459
3554
  var import_lock_file = require("@dxos/lock-file");
3460
3555
  var import_log13 = require("@dxos/log");
3461
- var __decorate3 = function(decorators, target, key, desc) {
3556
+ function _ts_decorate3(decorators, target, key, desc) {
3462
3557
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3463
3558
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3464
3559
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3467,7 +3562,8 @@ var __decorate3 = function(decorators, target, key, desc) {
3467
3562
  if (d = decorators[i])
3468
3563
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3469
3564
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3470
- };
3565
+ }
3566
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
3471
3567
  var Lock = class {
3472
3568
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
3473
3569
  this._lockPath = lockPath;
@@ -3479,29 +3575,29 @@ var Lock = class {
3479
3575
  }
3480
3576
  async acquire() {
3481
3577
  var _a;
3482
- (0, import_log13.log)("acquiring lock...", {}, {
3483
- file: "node.ts",
3484
- line: 32,
3485
- scope: this,
3486
- callSite: (f, a) => f(...a)
3578
+ (0, import_log13.log)("acquiring lock...", void 0, {
3579
+ F: __dxlog_file13,
3580
+ L: 32,
3581
+ S: this,
3582
+ C: (f, a) => f(...a)
3487
3583
  });
3488
3584
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
3489
3585
  await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3490
- (0, import_log13.log)("acquired lock", {}, {
3491
- file: "node.ts",
3492
- line: 37,
3493
- scope: this,
3494
- callSite: (f, a) => f(...a)
3586
+ (0, import_log13.log)("acquired lock", void 0, {
3587
+ F: __dxlog_file13,
3588
+ L: 37,
3589
+ S: this,
3590
+ C: (f, a) => f(...a)
3495
3591
  });
3496
3592
  }
3497
3593
  async release() {
3498
3594
  var _a;
3499
3595
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3500
- (0, import_node_assert12.default)(this._fileHandle, "Lock is not acquired");
3596
+ (0, import_tiny_invariant12.default)(this._fileHandle, "Lock is not acquired");
3501
3597
  await import_lock_file.LockFile.release(this._fileHandle);
3502
3598
  }
3503
3599
  };
3504
- __decorate3([
3600
+ _ts_decorate3([
3505
3601
  import_log13.logInfo
3506
3602
  ], Lock.prototype, "lockKey", null);
3507
3603
  var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
@@ -3533,7 +3629,7 @@ var LoggingServiceImpl = class {
3533
3629
  if (LOG_PROCESSING > 0) {
3534
3630
  return;
3535
3631
  }
3536
- if (((_a = entry2.meta) == null ? void 0 : _a.file.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
3632
+ if (((_a = entry2.meta) == null ? void 0 : _a.F.includes("logging-service")) || entry2.context && Object.values(entry2.context).some((value) => typeof value === "string" && value.includes("LoggingService"))) {
3537
3633
  return;
3538
3634
  }
3539
3635
  if (!shouldLog(entry2, request)) {
@@ -3545,8 +3641,8 @@ var LoggingServiceImpl = class {
3545
3641
  timestamp: new Date(),
3546
3642
  meta: {
3547
3643
  // TODO(dmaretskyi): Fix proto.
3548
- file: (_c = (_b = entry2.meta) == null ? void 0 : _b.file) != null ? _c : "",
3549
- line: (_e = (_d = entry2.meta) == null ? void 0 : _d.line) != null ? _e : 0
3644
+ file: (_c = (_b = entry2.meta) == null ? void 0 : _b.F) != null ? _c : "",
3645
+ line: (_e = (_d = entry2.meta) == null ? void 0 : _d.L) != null ? _e : 0
3550
3646
  }
3551
3647
  };
3552
3648
  try {
@@ -3576,7 +3672,7 @@ var shouldLog = (entry2, request) => {
3576
3672
  } else {
3577
3673
  return request.filters.some((filter) => {
3578
3674
  var _a2, _b;
3579
- return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.file) != null ? _b : "", options);
3675
+ return matchFilter(filter, entry2.level, (_b = (_a2 = entry2.meta) == null ? void 0 : _a2.F) != null ? _b : "", options);
3580
3676
  });
3581
3677
  }
3582
3678
  };
@@ -3616,7 +3712,7 @@ var NetworkServiceImpl = class {
3616
3712
 
3617
3713
  // packages/sdk/client-services/src/packlets/storage/storage.ts
3618
3714
  var import_client_protocol4 = require("@dxos/client-protocol");
3619
- var import_errors4 = require("@dxos/errors");
3715
+ var import_errors5 = require("@dxos/errors");
3620
3716
  var import_config = require("@dxos/protocols/proto/dxos/config");
3621
3717
  var import_random_access_storage = require("@dxos/random-access-storage");
3622
3718
  var import_util8 = require("@dxos/util");
@@ -3624,16 +3720,16 @@ var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
3624
3720
  var createStorageObjects = (config) => {
3625
3721
  const { path = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage", storageType, keyStorage, persistent = false } = config != null ? config : {};
3626
3722
  if (persistent && storageType === StorageDriver.RAM) {
3627
- throw new import_errors4.InvalidConfigError("RAM storage cannot be used in persistent mode.");
3723
+ throw new import_errors5.InvalidConfigError("RAM storage cannot be used in persistent mode.");
3628
3724
  }
3629
3725
  if (!persistent && storageType !== void 0 && storageType !== StorageDriver.RAM) {
3630
- throw new import_errors4.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
3726
+ throw new import_errors5.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
3631
3727
  }
3632
3728
  if (persistent && keyStorage === StorageDriver.RAM) {
3633
- throw new import_errors4.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
3729
+ throw new import_errors5.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
3634
3730
  }
3635
3731
  if (!persistent && keyStorage !== StorageDriver.RAM && keyStorage !== void 0) {
3636
- throw new import_errors4.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
3732
+ throw new import_errors5.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
3637
3733
  }
3638
3734
  return {
3639
3735
  storage: (0, import_random_access_storage.createStorage)({
@@ -3726,7 +3822,7 @@ var ServiceRegistry = class {
3726
3822
  };
3727
3823
 
3728
3824
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3729
- var __decorate4 = function(decorators, target, key, desc) {
3825
+ function _ts_decorate4(decorators, target, key, desc) {
3730
3826
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3731
3827
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3732
3828
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3735,24 +3831,30 @@ var __decorate4 = function(decorators, target, key, desc) {
3735
3831
  if (d = decorators[i])
3736
3832
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3737
3833
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3834
+ }
3835
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
3836
+ var createDefaultModelFactory = () => {
3837
+ return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
3738
3838
  };
3739
3839
  var ClientServicesHost = class {
3740
3840
  constructor({
3741
3841
  config,
3742
- modelFactory = (0, import_client_protocol5.createDefaultModelFactory)(),
3842
+ modelFactory = createDefaultModelFactory(),
3743
3843
  // TODO(burdon): Create ApolloLink abstraction (see Client).
3744
3844
  transportFactory,
3745
3845
  signalManager,
3746
3846
  connectionLog,
3747
3847
  storage,
3748
3848
  // TODO(wittjosiah): Turn this on by default.
3749
- lockKey
3849
+ lockKey,
3850
+ callbacks
3750
3851
  } = {}) {
3751
3852
  this._statusUpdate = new import_async17.Event();
3752
3853
  this._opening = false;
3753
3854
  this._open = false;
3754
3855
  this._storage = storage;
3755
3856
  this._modelFactory = modelFactory;
3857
+ this._callbacks = callbacks;
3756
3858
  if (config) {
3757
3859
  this.initialize({
3758
3860
  config,
@@ -3811,9 +3913,9 @@ var ClientServicesHost = class {
3811
3913
  */
3812
3914
  initialize({ config, ...options }) {
3813
3915
  var _a, _b, _c;
3814
- (0, import_node_assert13.default)(!this._open, "service host is open");
3916
+ (0, import_tiny_invariant13.default)(!this._open, "service host is open");
3815
3917
  if (config) {
3816
- (0, import_node_assert13.default)(!this._config, "config already set");
3918
+ (0, import_tiny_invariant13.default)(!this._config, "config already set");
3817
3919
  this._config = config;
3818
3920
  if (!this._storage) {
3819
3921
  this._storage = createStorageObjects(config.get("runtime.client.storage", {})).storage;
@@ -3823,7 +3925,7 @@ var ClientServicesHost = class {
3823
3925
  iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
3824
3926
  }), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
3825
3927
  this._signalManager = signalManager;
3826
- (0, import_node_assert13.default)(!this._networkManager, "network manager already set");
3928
+ (0, import_tiny_invariant13.default)(!this._networkManager, "network manager already set");
3827
3929
  this._networkManager = new import_network_manager2.NetworkManager({
3828
3930
  log: connectionLog,
3829
3931
  transportFactory,
@@ -3839,23 +3941,23 @@ var ClientServicesHost = class {
3839
3941
  import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
3840
3942
  id: traceId
3841
3943
  }), {
3842
- file: "service-host.ts",
3843
- line: 188,
3844
- scope: this,
3845
- callSite: (f, a) => f(...a)
3846
- });
3847
- (0, import_node_assert13.default)(this._config, "config not set");
3848
- (0, import_node_assert13.default)(this._storage, "storage not set");
3849
- (0, import_node_assert13.default)(this._signalManager, "signal manager not set");
3850
- (0, import_node_assert13.default)(this._networkManager, "network manager not set");
3944
+ F: __dxlog_file14,
3945
+ L: 203,
3946
+ S: this,
3947
+ C: (f, a) => f(...a)
3948
+ });
3949
+ (0, import_tiny_invariant13.default)(this._config, "config not set");
3950
+ (0, import_tiny_invariant13.default)(this._storage, "storage not set");
3951
+ (0, import_tiny_invariant13.default)(this._signalManager, "signal manager not set");
3952
+ (0, import_tiny_invariant13.default)(this._networkManager, "network manager not set");
3851
3953
  this._opening = true;
3852
3954
  (0, import_log15.log)("opening...", {
3853
3955
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
3854
3956
  }, {
3855
- file: "service-host.ts",
3856
- line: 196,
3857
- scope: this,
3858
- callSite: (f, a) => f(...a)
3957
+ F: __dxlog_file14,
3958
+ L: 211,
3959
+ S: this,
3960
+ C: (f, a) => f(...a)
3859
3961
  });
3860
3962
  await ((_b = this._resourceLock) == null ? void 0 : _b.acquire());
3861
3963
  await this._loggingService.open();
@@ -3887,18 +3989,18 @@ var ClientServicesHost = class {
3887
3989
  (0, import_log15.log)("opened", {
3888
3990
  deviceKey
3889
3991
  }, {
3890
- file: "service-host.ts",
3891
- line: 251,
3892
- scope: this,
3893
- callSite: (f, a) => f(...a)
3992
+ F: __dxlog_file14,
3993
+ L: 266,
3994
+ S: this,
3995
+ C: (f, a) => f(...a)
3894
3996
  });
3895
3997
  import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
3896
3998
  id: traceId
3897
3999
  }), {
3898
- file: "service-host.ts",
3899
- line: 252,
3900
- scope: this,
3901
- callSite: (f, a) => f(...a)
4000
+ F: __dxlog_file14,
4001
+ L: 267,
4002
+ S: this,
4003
+ C: (f, a) => f(...a)
3902
4004
  });
3903
4005
  }
3904
4006
  async close() {
@@ -3910,10 +4012,10 @@ var ClientServicesHost = class {
3910
4012
  (0, import_log15.log)("closing...", {
3911
4013
  deviceKey
3912
4014
  }, {
3913
- file: "service-host.ts",
3914
- line: 262,
3915
- scope: this,
3916
- callSite: (f, a) => f(...a)
4015
+ F: __dxlog_file14,
4016
+ L: 277,
4017
+ S: this,
4018
+ C: (f, a) => f(...a)
3917
4019
  });
3918
4020
  this._serviceRegistry.setServices({
3919
4021
  SystemService: this._systemService
@@ -3925,51 +4027,52 @@ var ClientServicesHost = class {
3925
4027
  (0, import_log15.log)("closed", {
3926
4028
  deviceKey
3927
4029
  }, {
3928
- file: "service-host.ts",
3929
- line: 268,
3930
- scope: this,
3931
- callSite: (f, a) => f(...a)
4030
+ F: __dxlog_file14,
4031
+ L: 283,
4032
+ S: this,
4033
+ C: (f, a) => f(...a)
3932
4034
  });
3933
4035
  }
3934
4036
  async reset() {
3935
- var _a;
4037
+ var _a, _b, _c;
3936
4038
  const traceId = import_keys11.PublicKey.random().toHex();
3937
4039
  import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
3938
4040
  id: traceId
3939
4041
  }), {
3940
- file: "service-host.ts",
3941
- line: 273,
3942
- scope: this,
3943
- callSite: (f, a) => f(...a)
4042
+ F: __dxlog_file14,
4043
+ L: 288,
4044
+ S: this,
4045
+ C: (f, a) => f(...a)
3944
4046
  });
3945
- (0, import_log15.log)("resetting...", {}, {
3946
- file: "service-host.ts",
3947
- line: 275,
3948
- scope: this,
3949
- callSite: (f, a) => f(...a)
4047
+ (0, import_log15.log)("resetting...", void 0, {
4048
+ F: __dxlog_file14,
4049
+ L: 290,
4050
+ S: this,
4051
+ C: (f, a) => f(...a)
3950
4052
  });
3951
4053
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
3952
4054
  await this._storage.reset();
3953
- (0, import_log15.log)("reset", {}, {
3954
- file: "service-host.ts",
3955
- line: 278,
3956
- scope: this,
3957
- callSite: (f, a) => f(...a)
4055
+ (0, import_log15.log)("reset", void 0, {
4056
+ F: __dxlog_file14,
4057
+ L: 293,
4058
+ S: this,
4059
+ C: (f, a) => f(...a)
3958
4060
  });
3959
4061
  import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
3960
4062
  id: traceId
3961
4063
  }), {
3962
- file: "service-host.ts",
3963
- line: 279,
3964
- scope: this,
3965
- callSite: (f, a) => f(...a)
4064
+ F: __dxlog_file14,
4065
+ L: 294,
4066
+ S: this,
4067
+ C: (f, a) => f(...a)
3966
4068
  });
4069
+ await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
3967
4070
  }
3968
4071
  };
3969
- __decorate4([
4072
+ _ts_decorate4([
3970
4073
  import_async17.synchronized
3971
4074
  ], ClientServicesHost.prototype, "open", null);
3972
- __decorate4([
4075
+ _ts_decorate4([
3973
4076
  import_async17.synchronized
3974
4077
  ], ClientServicesHost.prototype, "close", null);
3975
4078
 
@@ -4035,7 +4138,7 @@ var ClientRpcServer = class {
4035
4138
  };
4036
4139
 
4037
4140
  // packages/sdk/client-services/src/packlets/vault/shell-runtime.ts
4038
- var import_node_assert14 = __toESM(require("node:assert"));
4141
+ var import_tiny_invariant14 = __toESM(require("tiny-invariant"));
4039
4142
  var import_async18 = require("@dxos/async");
4040
4143
  var import_client_protocol6 = require("@dxos/client-protocol");
4041
4144
  var import_iframe = require("@dxos/protocols/proto/dxos/iframe");
@@ -4065,7 +4168,7 @@ var ShellRuntimeImpl = class {
4065
4168
  });
4066
4169
  }
4067
4170
  async setAppContext(context) {
4068
- (0, import_node_assert14.default)(this._appRpc, "runtime not open");
4171
+ (0, import_tiny_invariant14.default)(this._appRpc, "runtime not open");
4069
4172
  await this._appRpc.rpc.AppService.setContext(context);
4070
4173
  }
4071
4174
  async open() {
@@ -4092,39 +4195,9 @@ var ShellRuntimeImpl = class {
4092
4195
  this._appRpc = void 0;
4093
4196
  }
4094
4197
  };
4095
- var MemoryShellRuntime = class {
4096
- constructor({ layout, invitationCode, spaceKey } = {}) {
4097
- this.layoutUpdate = new import_async18.Event();
4098
- this.contextUpdate = new import_async18.Event();
4099
- this._layout = layout != null ? layout : import_iframe.ShellLayout.DEFAULT;
4100
- this._invitationCode = invitationCode;
4101
- this._spaceKey = spaceKey;
4102
- }
4103
- get layout() {
4104
- return this._layout;
4105
- }
4106
- get invitationCode() {
4107
- return this._invitationCode;
4108
- }
4109
- get spaceKey() {
4110
- return this._spaceKey;
4111
- }
4112
- setLayout(layout, options = {}) {
4113
- this._layout = layout;
4114
- this._invitationCode = options.invitationCode;
4115
- this._spaceKey = options.spaceKey;
4116
- this.layoutUpdate.emit({
4117
- layout,
4118
- ...options
4119
- });
4120
- }
4121
- async setAppContext(context) {
4122
- this.contextUpdate.emit(context);
4123
- }
4124
- };
4125
4198
 
4126
4199
  // packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts
4127
- var __decorate5 = function(decorators, target, key, desc) {
4200
+ function _ts_decorate5(decorators, target, key, desc) {
4128
4201
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4129
4202
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4130
4203
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4133,7 +4206,8 @@ var __decorate5 = function(decorators, target, key, desc) {
4133
4206
  if (d = decorators[i])
4134
4207
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4135
4208
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4136
- };
4209
+ }
4210
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-host-runtime.ts";
4137
4211
  var LOCK_KEY = "DXOS_RESOURCE_LOCK";
4138
4212
  var IFrameHostRuntime = class {
4139
4213
  constructor({ config, origin, appPort, shellPort }) {
@@ -4154,11 +4228,11 @@ var IFrameHostRuntime = class {
4154
4228
  }
4155
4229
  async start() {
4156
4230
  var _a;
4157
- (0, import_log16.log)("starting...", {}, {
4158
- file: "iframe-host-runtime.ts",
4159
- line: 70,
4160
- scope: this,
4161
- callSite: (f, a) => f(...a)
4231
+ (0, import_log16.log)("starting...", void 0, {
4232
+ F: __dxlog_file15,
4233
+ L: 70,
4234
+ S: this,
4235
+ C: (f, a) => f(...a)
4162
4236
  });
4163
4237
  try {
4164
4238
  this._config = await (0, import_util9.getAsyncValue)(this._configProvider);
@@ -4203,53 +4277,54 @@ var IFrameHostRuntime = class {
4203
4277
  (_a = this._shellRuntime) == null ? void 0 : _a.open()
4204
4278
  ]);
4205
4279
  this._ready.wake(void 0);
4206
- (0, import_log16.log)("started", {}, {
4207
- file: "iframe-host-runtime.ts",
4208
- line: 113,
4209
- scope: this,
4210
- callSite: (f, a) => f(...a)
4280
+ (0, import_log16.log)("started", void 0, {
4281
+ F: __dxlog_file15,
4282
+ L: 113,
4283
+ S: this,
4284
+ C: (f, a) => f(...a)
4211
4285
  });
4212
4286
  } catch (err) {
4213
4287
  this._ready.wake(err);
4214
- import_log16.log.catch(err, {}, {
4215
- file: "iframe-host-runtime.ts",
4216
- line: 116,
4217
- scope: this,
4218
- callSite: (f, a) => f(...a)
4288
+ import_log16.log.catch(err, void 0, {
4289
+ F: __dxlog_file15,
4290
+ L: 116,
4291
+ S: this,
4292
+ C: (f, a) => f(...a)
4219
4293
  });
4220
4294
  }
4221
4295
  }
4222
4296
  async stop() {
4223
4297
  var _a;
4224
- (0, import_log16.log)("stopping...", {}, {
4225
- file: "iframe-host-runtime.ts",
4226
- line: 121,
4227
- scope: this,
4228
- callSite: (f, a) => f(...a)
4298
+ (0, import_log16.log)("stopping...", void 0, {
4299
+ F: __dxlog_file15,
4300
+ L: 121,
4301
+ S: this,
4302
+ C: (f, a) => f(...a)
4229
4303
  });
4230
4304
  await this._clientRpc.close();
4231
4305
  await this._clientServices.close();
4232
4306
  await ((_a = this._shellRuntime) == null ? void 0 : _a.close());
4233
- (0, import_log16.log)("stopped", {}, {
4234
- file: "iframe-host-runtime.ts",
4235
- line: 125,
4236
- scope: this,
4237
- callSite: (f, a) => f(...a)
4307
+ (0, import_log16.log)("stopped", void 0, {
4308
+ F: __dxlog_file15,
4309
+ L: 125,
4310
+ S: this,
4311
+ C: (f, a) => f(...a)
4238
4312
  });
4239
4313
  }
4240
4314
  };
4241
- __decorate5([
4315
+ _ts_decorate5([
4242
4316
  import_log16.logInfo
4243
4317
  ], IFrameHostRuntime.prototype, "origin", void 0);
4244
4318
 
4245
4319
  // packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts
4246
4320
  var import_async20 = require("@dxos/async");
4247
4321
  var import_client_protocol8 = require("@dxos/client-protocol");
4248
- var import_errors5 = require("@dxos/errors");
4322
+ var import_errors6 = require("@dxos/errors");
4249
4323
  var import_log17 = require("@dxos/log");
4250
4324
  var import_network_manager4 = require("@dxos/network-manager");
4251
4325
  var import_rpc3 = require("@dxos/rpc");
4252
4326
  var import_util10 = require("@dxos/util");
4327
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/iframe-proxy-runtime.ts";
4253
4328
  var IFrameProxyRuntime = class {
4254
4329
  constructor({ config, systemPort, shellPort }) {
4255
4330
  this._id = String(Math.floor(Math.random() * 1e6));
@@ -4297,13 +4372,13 @@ var IFrameProxyRuntime = class {
4297
4372
  lockKey
4298
4373
  });
4299
4374
  } catch (err) {
4300
- import_log17.log.catch(err, {}, {
4301
- file: "iframe-proxy-runtime.ts",
4302
- line: 85,
4303
- scope: this,
4304
- callSite: (f, a) => f(...a)
4375
+ import_log17.log.catch(err, void 0, {
4376
+ F: __dxlog_file16,
4377
+ L: 85,
4378
+ S: this,
4379
+ C: (f, a) => f(...a)
4305
4380
  });
4306
- throw new import_errors5.RemoteServiceConnectionError("Failed to connect to worker");
4381
+ throw new import_errors6.RemoteServiceConnectionError("Failed to connect to worker");
4307
4382
  }
4308
4383
  await ((_a = this._shellRuntime) == null ? void 0 : _a.open());
4309
4384
  }
@@ -4326,13 +4401,13 @@ var import_messaging3 = require("@dxos/messaging");
4326
4401
  var import_network_manager5 = require("@dxos/network-manager");
4327
4402
 
4328
4403
  // packages/sdk/client-services/src/packlets/vault/worker-session.ts
4329
- var import_node_assert15 = __toESM(require("node:assert"));
4404
+ var import_tiny_invariant15 = __toESM(require("tiny-invariant"));
4330
4405
  var import_async21 = require("@dxos/async");
4331
4406
  var import_client_protocol9 = require("@dxos/client-protocol");
4332
4407
  var import_log18 = require("@dxos/log");
4333
4408
  var import_rpc4 = require("@dxos/rpc");
4334
4409
  var import_util11 = require("@dxos/util");
4335
- var __decorate6 = function(decorators, target, key, desc) {
4410
+ function _ts_decorate6(decorators, target, key, desc) {
4336
4411
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4337
4412
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4338
4413
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4341,12 +4416,13 @@ var __decorate6 = function(decorators, target, key, desc) {
4341
4416
  if (d = decorators[i])
4342
4417
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4343
4418
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4344
- };
4419
+ }
4420
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-session.ts";
4345
4421
  var WorkerSession = class {
4346
4422
  constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
4347
4423
  this._startTrigger = new import_async21.Trigger();
4348
4424
  this.onClose = new import_util11.Callback();
4349
- (0, import_node_assert15.default)(serviceHost);
4425
+ (0, import_tiny_invariant15.default)(serviceHost);
4350
4426
  this._serviceHost = serviceHost;
4351
4427
  const middleware = {
4352
4428
  handleCall: async (method, params, handler) => {
@@ -4393,11 +4469,11 @@ var WorkerSession = class {
4393
4469
  try {
4394
4470
  await this.close();
4395
4471
  } catch (err) {
4396
- import_log18.log.catch(err, {}, {
4397
- file: "worker-session.ts",
4398
- line: 100,
4399
- scope: this,
4400
- callSite: (f, a) => f(...a)
4472
+ import_log18.log.catch(err, void 0, {
4473
+ F: __dxlog_file17,
4474
+ L: 100,
4475
+ S: this,
4476
+ C: (f, a) => f(...a)
4401
4477
  });
4402
4478
  }
4403
4479
  });
@@ -4410,11 +4486,11 @@ var WorkerSession = class {
4410
4486
  this.bridgeService = this._iframeRpc.rpc.BridgeService;
4411
4487
  }
4412
4488
  async open() {
4413
- import_log18.log.info("opening..", {}, {
4414
- file: "worker-session.ts",
4415
- line: 114,
4416
- scope: this,
4417
- callSite: (f, a) => f(...a)
4489
+ import_log18.log.info("opening..", void 0, {
4490
+ F: __dxlog_file17,
4491
+ L: 114,
4492
+ S: this,
4493
+ C: (f, a) => f(...a)
4418
4494
  });
4419
4495
  await Promise.all([
4420
4496
  this._clientRpc.open(),
@@ -4429,20 +4505,20 @@ var WorkerSession = class {
4429
4505
  }
4430
4506
  }
4431
4507
  async close() {
4432
- import_log18.log.info("closing..", {}, {
4433
- file: "worker-session.ts",
4434
- line: 124,
4435
- scope: this,
4436
- callSite: (f, a) => f(...a)
4508
+ import_log18.log.info("closing..", void 0, {
4509
+ F: __dxlog_file17,
4510
+ L: 124,
4511
+ S: this,
4512
+ C: (f, a) => f(...a)
4437
4513
  });
4438
4514
  try {
4439
4515
  await this.onClose.callIfSet();
4440
4516
  } catch (err) {
4441
- import_log18.log.catch(err, {}, {
4442
- file: "worker-session.ts",
4443
- line: 128,
4444
- scope: this,
4445
- callSite: (f, a) => f(...a)
4517
+ import_log18.log.catch(err, void 0, {
4518
+ F: __dxlog_file17,
4519
+ L: 128,
4520
+ S: this,
4521
+ C: (f, a) => f(...a)
4446
4522
  });
4447
4523
  }
4448
4524
  await Promise.all([
@@ -4454,11 +4530,11 @@ var WorkerSession = class {
4454
4530
  try {
4455
4531
  await (0, import_async21.asyncTimeout)(this._shellClientRpc.open(), 1e3);
4456
4532
  } catch (e) {
4457
- import_log18.log.info("No shell connected.", {}, {
4458
- file: "worker-session.ts",
4459
- line: 138,
4460
- scope: this,
4461
- callSite: (f, a) => f(...a)
4533
+ import_log18.log.info("No shell connected.", void 0, {
4534
+ F: __dxlog_file17,
4535
+ L: 138,
4536
+ S: this,
4537
+ C: (f, a) => f(...a)
4462
4538
  });
4463
4539
  }
4464
4540
  }
@@ -4467,14 +4543,15 @@ var WorkerSession = class {
4467
4543
  }).then(callback);
4468
4544
  }
4469
4545
  };
4470
- __decorate6([
4546
+ _ts_decorate6([
4471
4547
  import_log18.logInfo
4472
4548
  ], WorkerSession.prototype, "origin", void 0);
4473
- __decorate6([
4549
+ _ts_decorate6([
4474
4550
  import_log18.logInfo
4475
4551
  ], WorkerSession.prototype, "lockKey", void 0);
4476
4552
 
4477
4553
  // packages/sdk/client-services/src/packlets/vault/worker-runtime.ts
4554
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/vault/worker-runtime.ts";
4478
4555
  var WorkerRuntime = class {
4479
4556
  // prettier-ignore
4480
4557
  constructor(_configProvider) {
@@ -4482,17 +4559,23 @@ var WorkerRuntime = class {
4482
4559
  this._transportFactory = new import_network_manager5.WebRTCTransportProxyFactory();
4483
4560
  this._ready = new import_async22.Trigger();
4484
4561
  this.sessions = /* @__PURE__ */ new Set();
4485
- this._clientServices = new ClientServicesHost();
4562
+ this._clientServices = new ClientServicesHost({
4563
+ callbacks: {
4564
+ onReset: async () => {
4565
+ self.close();
4566
+ }
4567
+ }
4568
+ });
4486
4569
  }
4487
4570
  get host() {
4488
4571
  return this._clientServices;
4489
4572
  }
4490
4573
  async start() {
4491
- (0, import_log19.log)("starting...", {}, {
4492
- file: "worker-runtime.ts",
4493
- line: 48,
4494
- scope: this,
4495
- callSite: (f, a) => f(...a)
4574
+ (0, import_log19.log)("starting...", void 0, {
4575
+ F: __dxlog_file18,
4576
+ L: 48,
4577
+ S: this,
4578
+ C: (f, a) => f(...a)
4496
4579
  });
4497
4580
  try {
4498
4581
  this._config = await this._configProvider();
@@ -4504,19 +4587,19 @@ var WorkerRuntime = class {
4504
4587
  });
4505
4588
  await this._clientServices.open();
4506
4589
  this._ready.wake(void 0);
4507
- (0, import_log19.log)("started", {}, {
4508
- file: "worker-runtime.ts",
4509
- line: 62,
4510
- scope: this,
4511
- callSite: (f, a) => f(...a)
4590
+ (0, import_log19.log)("started", void 0, {
4591
+ F: __dxlog_file18,
4592
+ L: 62,
4593
+ S: this,
4594
+ C: (f, a) => f(...a)
4512
4595
  });
4513
4596
  } catch (err) {
4514
4597
  this._ready.wake(err);
4515
- import_log19.log.catch(err, {}, {
4516
- file: "worker-runtime.ts",
4517
- line: 65,
4518
- scope: this,
4519
- callSite: (f, a) => f(...a)
4598
+ import_log19.log.catch(err, void 0, {
4599
+ F: __dxlog_file18,
4600
+ L: 65,
4601
+ S: this,
4602
+ C: (f, a) => f(...a)
4520
4603
  });
4521
4604
  }
4522
4605
  }
@@ -4546,11 +4629,11 @@ var WorkerRuntime = class {
4546
4629
  * Selects one of the existing session fro WebRTC networking.
4547
4630
  */
4548
4631
  _reconnectWebrtc() {
4549
- (0, import_log19.log)("reconnecting webrtc...", {}, {
4550
- file: "worker-runtime.ts",
4551
- line: 102,
4552
- scope: this,
4553
- callSite: (f, a) => f(...a)
4632
+ (0, import_log19.log)("reconnecting webrtc...", void 0, {
4633
+ F: __dxlog_file18,
4634
+ L: 102,
4635
+ S: this,
4636
+ C: (f, a) => f(...a)
4554
4637
  });
4555
4638
  if (this._sessionForNetworking) {
4556
4639
  if (!this.sessions.has(this._sessionForNetworking)) {
@@ -4584,7 +4667,6 @@ var WorkerRuntime = class {
4584
4667
  InvitationsHandler,
4585
4668
  InvitationsServiceImpl,
4586
4669
  Lock,
4587
- MemoryShellRuntime,
4588
4670
  ServiceContext,
4589
4671
  ServiceRegistry,
4590
4672
  ShellRuntimeImpl,
@@ -4594,6 +4676,7 @@ var WorkerRuntime = class {
4594
4676
  WorkerRuntime,
4595
4677
  WorkerSession,
4596
4678
  createAuthProvider,
4679
+ createDefaultModelFactory,
4597
4680
  createStorageObjects,
4598
4681
  getNetworkPeers,
4599
4682
  isLocked,