@dxos/client-services 0.1.52 → 0.1.53-main.01cbc6b

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