@dxos/client-services 0.3.9-main.ee9a520 → 0.3.9-main.ef334cd

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 (28) hide show
  1. package/dist/lib/browser/{chunk-QETXI73D.mjs → chunk-5AFGJQGV.mjs} +111 -61
  2. package/dist/lib/browser/{chunk-QETXI73D.mjs.map → chunk-5AFGJQGV.mjs.map} +4 -4
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/packlets/testing/index.mjs +1 -1
  6. package/dist/lib/node/{chunk-TVYC6AI7.cjs → chunk-RD2EVVPQ.cjs} +120 -73
  7. package/dist/lib/node/chunk-RD2EVVPQ.cjs.map +7 -0
  8. package/dist/lib/node/index.cjs +37 -37
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/packlets/testing/index.cjs +8 -8
  11. package/dist/types/src/packlets/services/service-context.d.ts +2 -1
  12. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  13. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  14. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +8 -0
  15. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -0
  16. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +3 -2
  17. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  18. package/dist/types/src/packlets/spaces/data-space.d.ts +7 -2
  19. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  20. package/dist/types/src/version.d.ts +1 -1
  21. package/package.json +35 -35
  22. package/src/packlets/services/service-context.ts +5 -0
  23. package/src/packlets/services/service-host.ts +4 -1
  24. package/src/packlets/spaces/automerge-space-state.ts +22 -0
  25. package/src/packlets/spaces/data-space-manager.ts +11 -1
  26. package/src/packlets/spaces/data-space.ts +53 -6
  27. package/src/version.ts +1 -1
  28. package/dist/lib/node/chunk-TVYC6AI7.cjs.map +0 -7
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_TVYC6AI7_exports = {};
30
- __export(chunk_TVYC6AI7_exports, {
29
+ var chunk_RD2EVVPQ_exports = {};
30
+ __export(chunk_RD2EVVPQ_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -60,7 +60,7 @@ __export(chunk_TVYC6AI7_exports, {
60
60
  subscribeToSpaces: () => subscribeToSpaces,
61
61
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
62
  });
63
- module.exports = __toCommonJS(chunk_TVYC6AI7_exports);
63
+ module.exports = __toCommonJS(chunk_RD2EVVPQ_exports);
64
64
  var import_async = require("@dxos/async");
65
65
  var import_codec_protobuf = require("@dxos/codec-protobuf");
66
66
  var import_feed_store = require("@dxos/feed-store");
@@ -164,6 +164,7 @@ var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials"
164
164
  var import_timeframe2 = require("@dxos/timeframe");
165
165
  var import_tracing4 = require("@dxos/tracing");
166
166
  var import_util4 = require("@dxos/util");
167
+ var import_credentials11 = require("@dxos/credentials");
167
168
  var import_async11 = require("@dxos/async");
168
169
  var import_context7 = require("@dxos/context");
169
170
  var import_invariant10 = require("@dxos/invariant");
@@ -174,7 +175,7 @@ var import_teleport2 = require("@dxos/teleport");
174
175
  var import_util5 = require("@dxos/util");
175
176
  var import_async12 = require("@dxos/async");
176
177
  var import_context8 = require("@dxos/context");
177
- var import_credentials11 = require("@dxos/credentials");
178
+ var import_credentials12 = require("@dxos/credentials");
178
179
  var import_invariant11 = require("@dxos/invariant");
179
180
  var import_keys9 = require("@dxos/keys");
180
181
  var import_log11 = require("@dxos/log");
@@ -182,9 +183,9 @@ var import_protocols8 = require("@dxos/protocols");
182
183
  var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
183
184
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
184
185
  var import_util6 = require("@dxos/util");
185
- var import_credentials12 = require("@dxos/credentials");
186
+ var import_credentials13 = require("@dxos/credentials");
186
187
  var import_debug5 = require("@dxos/debug");
187
- var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
188
+ var import_credentials14 = require("@dxos/protocols/proto/dxos/halo/credentials");
188
189
  var import_timeframe3 = require("@dxos/timeframe");
189
190
  var import_async13 = require("@dxos/async");
190
191
  var import_codec_protobuf11 = require("@dxos/codec-protobuf");
@@ -195,7 +196,7 @@ var import_protocols9 = require("@dxos/protocols");
195
196
  var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
196
197
  var import_async14 = require("@dxos/async");
197
198
  var import_context9 = require("@dxos/context");
198
- var import_credentials14 = require("@dxos/credentials");
199
+ var import_credentials15 = require("@dxos/credentials");
199
200
  var import_debug7 = require("@dxos/debug");
200
201
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
201
202
  var import_feed_store4 = require("@dxos/feed-store");
@@ -2648,7 +2649,7 @@ var getPlatform = () => {
2648
2649
  };
2649
2650
  }
2650
2651
  };
2651
- var DXOS_VERSION = "0.3.9-main.ee9a520";
2652
+ var DXOS_VERSION = "0.3.9-main.ef334cd";
2652
2653
  var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
2653
2654
  var DEFAULT_TIMEOUT = 1e3;
2654
2655
  var createDiagnostics = async (clientServices, serviceContext, config) => {
@@ -2770,6 +2771,21 @@ var getSpaceStats = async (space) => {
2770
2771
  }
2771
2772
  return stats;
2772
2773
  };
2774
+ var AutomergeSpaceState = class {
2775
+ constructor() {
2776
+ this.rootUrl = void 0;
2777
+ this.lastEpoch = void 0;
2778
+ }
2779
+ async processCredential(credential) {
2780
+ if (!(0, import_credentials11.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
2781
+ return;
2782
+ }
2783
+ this.lastEpoch = credential;
2784
+ if (credential.subject.assertion.automergeRoot) {
2785
+ this.rootUrl = credential.subject.assertion.automergeRoot;
2786
+ }
2787
+ }
2788
+ };
2773
2789
  var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2774
2790
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2775
2791
  var DEFAULT_SUCCESS_DELAY = 1e3;
@@ -3044,6 +3060,9 @@ var DataSpace = class DataSpace2 {
3044
3060
  constructor(params) {
3045
3061
  this._ctx = new import_context6.Context();
3046
3062
  this._notarizationPlugin = new NotarizationPlugin();
3063
+ this._cache = void 0;
3064
+ this._automergeHost = void 0;
3065
+ this._automergeSpaceState = new AutomergeSpaceState();
3047
3066
  this._state = import_services7.SpaceState.CLOSED;
3048
3067
  this.error = void 0;
3049
3068
  this.stateUpdate = new import_async10.Event();
@@ -3068,7 +3087,7 @@ var DataSpace = class DataSpace2 {
3068
3087
  state: import_services7.SpaceState[this._state]
3069
3088
  }, {
3070
3089
  F: __dxlog_file12,
3071
- L: 118,
3090
+ L: 138,
3072
3091
  S: this,
3073
3092
  C: (f, a) => f(...a)
3074
3093
  });
@@ -3098,6 +3117,9 @@ var DataSpace = class DataSpace2 {
3098
3117
  get cache() {
3099
3118
  return this._cache;
3100
3119
  }
3120
+ get automergeSpaceState() {
3121
+ return this._automergeSpaceState;
3122
+ }
3101
3123
  async open() {
3102
3124
  await this._open();
3103
3125
  }
@@ -3105,13 +3127,14 @@ var DataSpace = class DataSpace2 {
3105
3127
  await this._gossip.open();
3106
3128
  await this._notarizationPlugin.open();
3107
3129
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
3130
+ await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
3108
3131
  await this._inner.open(new import_context6.Context());
3109
3132
  this._state = import_services7.SpaceState.CONTROL_ONLY;
3110
3133
  (0, import_log9.log)("new state", {
3111
3134
  state: import_services7.SpaceState[this._state]
3112
3135
  }, {
3113
3136
  F: __dxlog_file12,
3114
- L: 165,
3137
+ L: 190,
3115
3138
  S: this,
3116
3139
  C: (f, a) => f(...a)
3117
3140
  });
@@ -3129,7 +3152,7 @@ var DataSpace = class DataSpace2 {
3129
3152
  state: import_services7.SpaceState[this._state]
3130
3153
  }, {
3131
3154
  F: __dxlog_file12,
3132
- L: 179,
3155
+ L: 204,
3133
3156
  S: this,
3134
3157
  C: (f, a) => f(...a)
3135
3158
  });
@@ -3137,6 +3160,7 @@ var DataSpace = class DataSpace2 {
3137
3160
  this._ctx = new import_context6.Context();
3138
3161
  await this.authVerifier.close();
3139
3162
  await this._inner.close();
3163
+ await this._inner.spaceState.removeCredentialProcessor(this._automergeSpaceState);
3140
3164
  await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
3141
3165
  await this._notarizationPlugin.close();
3142
3166
  await this._presence.destroy();
@@ -3160,7 +3184,7 @@ var DataSpace = class DataSpace2 {
3160
3184
  if (err instanceof import_protocols6.CancelledError) {
3161
3185
  (0, import_log9.log)("data pipeline initialization cancelled", err, {
3162
3186
  F: __dxlog_file12,
3163
- L: 211,
3187
+ L: 237,
3164
3188
  S: this,
3165
3189
  C: (f, a) => f(...a)
3166
3190
  });
@@ -3168,7 +3192,7 @@ var DataSpace = class DataSpace2 {
3168
3192
  }
3169
3193
  import_log9.log.error("Error initializing data pipeline", err, {
3170
3194
  F: __dxlog_file12,
3171
- L: 215,
3195
+ L: 241,
3172
3196
  S: this,
3173
3197
  C: (f, a) => f(...a)
3174
3198
  });
@@ -3177,7 +3201,7 @@ var DataSpace = class DataSpace2 {
3177
3201
  state: import_services7.SpaceState[this._state]
3178
3202
  }, {
3179
3203
  F: __dxlog_file12,
3180
- L: 217,
3204
+ L: 243,
3181
3205
  S: this,
3182
3206
  C: (f, a) => f(...a)
3183
3207
  });
@@ -3197,7 +3221,7 @@ var DataSpace = class DataSpace2 {
3197
3221
  state: import_services7.SpaceState[this._state]
3198
3222
  }, {
3199
3223
  F: __dxlog_file12,
3200
- L: 233,
3224
+ L: 259,
3201
3225
  S: this,
3202
3226
  C: (f, a) => f(...a)
3203
3227
  });
@@ -3208,7 +3232,7 @@ var DataSpace = class DataSpace2 {
3208
3232
  await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
3209
3233
  (0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
3210
3234
  F: __dxlog_file12,
3211
- L: 247,
3235
+ L: 273,
3212
3236
  S: this,
3213
3237
  C: (f, a) => f(...a)
3214
3238
  });
@@ -3219,7 +3243,7 @@ var DataSpace = class DataSpace2 {
3219
3243
  this.metrics.dataPipelineReady = /* @__PURE__ */ new Date();
3220
3244
  (0, import_log9.log)("data pipeline ready", void 0, {
3221
3245
  F: __dxlog_file12,
3222
- L: 256,
3246
+ L: 282,
3223
3247
  S: this,
3224
3248
  C: (f, a) => f(...a)
3225
3249
  });
@@ -3229,7 +3253,7 @@ var DataSpace = class DataSpace2 {
3229
3253
  state: import_services7.SpaceState[this._state]
3230
3254
  }, {
3231
3255
  F: __dxlog_file12,
3232
- L: 260,
3256
+ L: 286,
3233
3257
  S: this,
3234
3258
  C: (f, a) => f(...a)
3235
3259
  });
@@ -3245,7 +3269,7 @@ var DataSpace = class DataSpace2 {
3245
3269
  await this._createWritableFeeds();
3246
3270
  (0, import_log9.log)("writable feeds created", void 0, {
3247
3271
  F: __dxlog_file12,
3248
- L: 276,
3272
+ L: 302,
3249
3273
  S: this,
3250
3274
  C: (f, a) => f(...a)
3251
3275
  });
@@ -3317,8 +3341,28 @@ var DataSpace = class DataSpace2 {
3317
3341
  }
3318
3342
  });
3319
3343
  }
3320
- async createEpoch() {
3321
- const epoch = await this.dataPipeline.createEpoch();
3344
+ async createEpoch(options) {
3345
+ let epoch;
3346
+ switch (options?.migration) {
3347
+ case void 0:
3348
+ case import_services7.CreateEpochRequest.Migration.NONE:
3349
+ {
3350
+ epoch = await this.dataPipeline.createEpoch();
3351
+ }
3352
+ break;
3353
+ case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE: {
3354
+ const document = this._automergeHost?.repo.create();
3355
+ epoch = {
3356
+ previousId: this._automergeSpaceState.lastEpoch?.id,
3357
+ number: (this._automergeSpaceState.lastEpoch?.subject.assertion.number ?? -1) + 1,
3358
+ timeframe: this._automergeSpaceState.lastEpoch?.subject.assertion.timeframe ?? new import_timeframe2.Timeframe(),
3359
+ automergeRoot: document?.url
3360
+ };
3361
+ }
3362
+ }
3363
+ if (!epoch) {
3364
+ return;
3365
+ }
3322
3366
  const receipt = await this.inner.controlPipeline.writer.write({
3323
3367
  credential: {
3324
3368
  credential: await this._signingContext.credentialSigner.createCredential({
@@ -3365,7 +3409,7 @@ var DataSpace = class DataSpace2 {
3365
3409
  state: import_services7.SpaceState[this._state]
3366
3410
  }, {
3367
3411
  F: __dxlog_file12,
3368
- L: 404,
3412
+ L: 451,
3369
3413
  S: this,
3370
3414
  C: (f, a) => f(...a)
3371
3415
  });
@@ -3402,7 +3446,7 @@ DataSpace = _ts_decorate4([
3402
3446
  ], DataSpace);
3403
3447
  var spaceGenesis = async (keyring, signingContext, space) => {
3404
3448
  const credentials = [
3405
- await (0, import_credentials12.createCredential)({
3449
+ await (0, import_credentials13.createCredential)({
3406
3450
  signer: keyring,
3407
3451
  issuer: space.key,
3408
3452
  subject: space.key,
@@ -3411,14 +3455,14 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3411
3455
  spaceKey: space.key
3412
3456
  }
3413
3457
  }),
3414
- await (0, import_credentials12.createCredential)({
3458
+ await (0, import_credentials13.createCredential)({
3415
3459
  signer: keyring,
3416
3460
  issuer: space.key,
3417
3461
  subject: signingContext.identityKey,
3418
3462
  assertion: {
3419
3463
  "@type": "dxos.halo.credentials.SpaceMember",
3420
3464
  spaceKey: space.key,
3421
- role: import_credentials13.SpaceMember.Role.ADMIN,
3465
+ role: import_credentials14.SpaceMember.Role.ADMIN,
3422
3466
  profile: signingContext.getProfile(),
3423
3467
  genesisFeedKey: space.controlFeedKey ?? (0, import_debug5.failUndefined)()
3424
3468
  }
@@ -3430,7 +3474,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3430
3474
  spaceKey: space.key,
3431
3475
  identityKey: signingContext.identityKey,
3432
3476
  deviceKey: signingContext.deviceKey,
3433
- designation: import_credentials13.AdmittedFeed.Designation.CONTROL
3477
+ designation: import_credentials14.AdmittedFeed.Designation.CONTROL
3434
3478
  }
3435
3479
  }),
3436
3480
  await signingContext.credentialSigner.createCredential({
@@ -3440,7 +3484,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3440
3484
  spaceKey: space.key,
3441
3485
  identityKey: signingContext.identityKey,
3442
3486
  deviceKey: signingContext.deviceKey,
3443
- designation: import_credentials13.AdmittedFeed.Designation.DATA
3487
+ designation: import_credentials14.AdmittedFeed.Designation.DATA
3444
3488
  }
3445
3489
  }),
3446
3490
  await signingContext.credentialSigner.createCredential({
@@ -3477,13 +3521,14 @@ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
3477
3521
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3478
3522
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3479
3523
  var DataSpaceManager = class DataSpaceManager2 {
3480
- constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
3524
+ constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
3481
3525
  this._spaceManager = _spaceManager;
3482
3526
  this._metadataStore = _metadataStore;
3483
3527
  this._dataServiceSubscriptions = _dataServiceSubscriptions;
3484
3528
  this._keyring = _keyring;
3485
3529
  this._signingContext = _signingContext;
3486
3530
  this._feedStore = _feedStore;
3531
+ this._automergeHost = _automergeHost;
3487
3532
  this._ctx = new import_context8.Context();
3488
3533
  this.updated = new import_async12.Event();
3489
3534
  this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
@@ -3497,7 +3542,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3497
3542
  async open() {
3498
3543
  (0, import_log11.log)("open", void 0, {
3499
3544
  F: __dxlog_file13,
3500
- L: 83,
3545
+ L: 92,
3501
3546
  S: this,
3502
3547
  C: (f, a) => f(...a)
3503
3548
  });
@@ -3505,7 +3550,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3505
3550
  id: this._instanceId
3506
3551
  }), {
3507
3552
  F: __dxlog_file13,
3508
- L: 84,
3553
+ L: 93,
3509
3554
  S: this,
3510
3555
  C: (f, a) => f(...a)
3511
3556
  });
@@ -3513,7 +3558,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3513
3558
  spaces: this._metadataStore.spaces.length
3514
3559
  }, {
3515
3560
  F: __dxlog_file13,
3516
- L: 85,
3561
+ L: 94,
3517
3562
  S: this,
3518
3563
  C: (f, a) => f(...a)
3519
3564
  });
@@ -3523,7 +3568,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3523
3568
  spaceMetadata
3524
3569
  }, {
3525
3570
  F: __dxlog_file13,
3526
- L: 89,
3571
+ L: 98,
3527
3572
  S: this,
3528
3573
  C: (f, a) => f(...a)
3529
3574
  });
@@ -3534,7 +3579,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3534
3579
  err
3535
3580
  }, {
3536
3581
  F: __dxlog_file13,
3537
- L: 92,
3582
+ L: 101,
3538
3583
  S: this,
3539
3584
  C: (f, a) => f(...a)
3540
3585
  });
@@ -3551,7 +3596,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3551
3596
  id: this._instanceId
3552
3597
  }), {
3553
3598
  F: __dxlog_file13,
3554
- L: 105,
3599
+ L: 114,
3555
3600
  S: this,
3556
3601
  C: (f, a) => f(...a)
3557
3602
  });
@@ -3559,7 +3604,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3559
3604
  async close() {
3560
3605
  (0, import_log11.log)("close", void 0, {
3561
3606
  F: __dxlog_file13,
3562
- L: 110,
3607
+ L: 119,
3563
3608
  S: this,
3564
3609
  C: (f, a) => f(...a)
3565
3610
  });
@@ -3575,7 +3620,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3575
3620
  async createSpace() {
3576
3621
  (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3577
3622
  F: __dxlog_file13,
3578
- L: 123,
3623
+ L: 132,
3579
3624
  S: this,
3580
3625
  A: [
3581
3626
  "this._isOpen",
@@ -3596,7 +3641,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3596
3641
  spaceKey
3597
3642
  }, {
3598
3643
  F: __dxlog_file13,
3599
- L: 135,
3644
+ L: 144,
3600
3645
  S: this,
3601
3646
  C: (f, a) => f(...a)
3602
3647
  });
@@ -3604,9 +3649,9 @@ var DataSpaceManager = class DataSpaceManager2 {
3604
3649
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
3605
3650
  await this._metadataStore.addSpace(metadata);
3606
3651
  const memberCredential = credentials[1];
3607
- (0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3652
+ (0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3608
3653
  F: __dxlog_file13,
3609
- L: 142,
3654
+ L: 151,
3610
3655
  S: this,
3611
3656
  A: [
3612
3657
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3624,13 +3669,13 @@ var DataSpaceManager = class DataSpaceManager2 {
3624
3669
  opts
3625
3670
  }, {
3626
3671
  F: __dxlog_file13,
3627
- L: 154,
3672
+ L: 163,
3628
3673
  S: this,
3629
3674
  C: (f, a) => f(...a)
3630
3675
  });
3631
3676
  (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3632
3677
  F: __dxlog_file13,
3633
- L: 155,
3678
+ L: 164,
3634
3679
  S: this,
3635
3680
  A: [
3636
3681
  "this._isOpen",
@@ -3639,7 +3684,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3639
3684
  });
3640
3685
  (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3641
3686
  F: __dxlog_file13,
3642
- L: 156,
3687
+ L: 165,
3643
3688
  S: this,
3644
3689
  A: [
3645
3690
  "!this._spaces.has(opts.spaceKey)",
@@ -3674,7 +3719,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3674
3719
  metadata
3675
3720
  }, {
3676
3721
  F: __dxlog_file13,
3677
- L: 189,
3722
+ L: 198,
3678
3723
  S: this,
3679
3724
  C: (f, a) => f(...a)
3680
3725
  });
@@ -3710,7 +3755,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3710
3755
  onAuthFailure: () => {
3711
3756
  import_log11.log.warn("auth failure", void 0, {
3712
3757
  F: __dxlog_file13,
3713
- L: 224,
3758
+ L: 233,
3714
3759
  S: this,
3715
3760
  C: (f, a) => f(...a)
3716
3761
  });
@@ -3734,7 +3779,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3734
3779
  space: space.key
3735
3780
  }, {
3736
3781
  F: __dxlog_file13,
3737
- L: 242,
3782
+ L: 251,
3738
3783
  S: this,
3739
3784
  C: (f, a) => f(...a)
3740
3785
  });
@@ -3746,7 +3791,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3746
3791
  open: this._isOpen
3747
3792
  }, {
3748
3793
  F: __dxlog_file13,
3749
- L: 249,
3794
+ L: 258,
3750
3795
  S: this,
3751
3796
  C: (f, a) => f(...a)
3752
3797
  });
@@ -3759,14 +3804,15 @@ var DataSpaceManager = class DataSpaceManager2 {
3759
3804
  space: space.key
3760
3805
  }, {
3761
3806
  F: __dxlog_file13,
3762
- L: 255,
3807
+ L: 264,
3763
3808
  S: this,
3764
3809
  C: (f, a) => f(...a)
3765
3810
  });
3766
3811
  await this._dataServiceSubscriptions.unregisterSpace(space.key);
3767
3812
  }
3768
3813
  },
3769
- cache: metadata.cache
3814
+ cache: metadata.cache,
3815
+ automergeHost: this._automergeHost
3770
3816
  });
3771
3817
  if (metadata.state !== import_services8.SpaceState.INACTIVE) {
3772
3818
  await dataSpace.open();
@@ -4052,6 +4098,7 @@ var ServiceContext = class ServiceContext2 {
4052
4098
  snapshotStore: this.snapshotStore
4053
4099
  });
4054
4100
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
4101
+ this.automergeHost = new import_echo_pipeline2.AutomergeHost(storage.createDirectory("automerge"));
4055
4102
  this.invitations = new InvitationsHandler(this.networkManager);
4056
4103
  this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
4057
4104
  }
@@ -4059,7 +4106,7 @@ var ServiceContext = class ServiceContext2 {
4059
4106
  await this._checkStorageVersion();
4060
4107
  (0, import_log13.log)("opening...", void 0, {
4061
4108
  F: __dxlog_file15,
4062
- L: 129,
4109
+ L: 133,
4063
4110
  S: this,
4064
4111
  C: (f, a) => f(...a)
4065
4112
  });
@@ -4067,7 +4114,7 @@ var ServiceContext = class ServiceContext2 {
4067
4114
  id: this._instanceId
4068
4115
  }), {
4069
4116
  F: __dxlog_file15,
4070
- L: 130,
4117
+ L: 134,
4071
4118
  S: this,
4072
4119
  C: (f, a) => f(...a)
4073
4120
  });
@@ -4083,13 +4130,13 @@ var ServiceContext = class ServiceContext2 {
4083
4130
  id: this._instanceId
4084
4131
  }), {
4085
4132
  F: __dxlog_file15,
4086
- L: 140,
4133
+ L: 144,
4087
4134
  S: this,
4088
4135
  C: (f, a) => f(...a)
4089
4136
  });
4090
4137
  (0, import_log13.log)("opened", void 0, {
4091
4138
  F: __dxlog_file15,
4092
- L: 141,
4139
+ L: 145,
4093
4140
  S: this,
4094
4141
  C: (f, a) => f(...a)
4095
4142
  });
@@ -4097,7 +4144,7 @@ var ServiceContext = class ServiceContext2 {
4097
4144
  async close() {
4098
4145
  (0, import_log13.log)("closing...", void 0, {
4099
4146
  F: __dxlog_file15,
4100
- L: 145,
4147
+ L: 149,
4101
4148
  S: this,
4102
4149
  C: (f, a) => f(...a)
4103
4150
  });
@@ -4114,7 +4161,7 @@ var ServiceContext = class ServiceContext2 {
4114
4161
  await this.metadataStore.close();
4115
4162
  (0, import_log13.log)("closed", void 0, {
4116
4163
  F: __dxlog_file15,
4117
- L: 157,
4164
+ L: 161,
4118
4165
  S: this,
4119
4166
  C: (f, a) => f(...a)
4120
4167
  });
@@ -4128,7 +4175,7 @@ var ServiceContext = class ServiceContext2 {
4128
4175
  const factory = this._handlerFactories.get(invitation.kind);
4129
4176
  (0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4130
4177
  F: __dxlog_file15,
4131
- L: 168,
4178
+ L: 172,
4132
4179
  S: this,
4133
4180
  A: [
4134
4181
  "factory",
@@ -4160,7 +4207,7 @@ var ServiceContext = class ServiceContext2 {
4160
4207
  async _initialize(ctx) {
4161
4208
  (0, import_log13.log)("initializing spaces...", void 0, {
4162
4209
  F: __dxlog_file15,
4163
- L: 199,
4210
+ L: 203,
4164
4211
  S: this,
4165
4212
  C: (f, a) => f(...a)
4166
4213
  });
@@ -4178,12 +4225,12 @@ var ServiceContext = class ServiceContext2 {
4178
4225
  });
4179
4226
  }
4180
4227
  };
4181
- this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
4228
+ this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore, this.automergeHost);
4182
4229
  await this.dataSpaceManager.open();
4183
4230
  this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
4184
4231
  (0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4185
4232
  F: __dxlog_file15,
4186
- L: 222,
4233
+ L: 227,
4187
4234
  S: this,
4188
4235
  A: [
4189
4236
  "this.dataSpaceManager",
@@ -4195,7 +4242,7 @@ var ServiceContext = class ServiceContext2 {
4195
4242
  this.initialized.wake();
4196
4243
  this._deviceSpaceSync = {
4197
4244
  processCredential: async (credential) => {
4198
- const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
4245
+ const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
4199
4246
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
4200
4247
  return;
4201
4248
  }
@@ -4207,7 +4254,7 @@ var ServiceContext = class ServiceContext2 {
4207
4254
  details: assertion
4208
4255
  }, {
4209
4256
  F: __dxlog_file15,
4210
- L: 238,
4257
+ L: 243,
4211
4258
  S: this,
4212
4259
  C: (f, a) => f(...a)
4213
4260
  });
@@ -4218,7 +4265,7 @@ var ServiceContext = class ServiceContext2 {
4218
4265
  details: assertion
4219
4266
  }, {
4220
4267
  F: __dxlog_file15,
4221
- L: 242,
4268
+ L: 247,
4222
4269
  S: this,
4223
4270
  C: (f, a) => f(...a)
4224
4271
  });
@@ -4229,7 +4276,7 @@ var ServiceContext = class ServiceContext2 {
4229
4276
  details: assertion
4230
4277
  }, {
4231
4278
  F: __dxlog_file15,
4232
- L: 247,
4279
+ L: 252,
4233
4280
  S: this,
4234
4281
  C: (f, a) => f(...a)
4235
4282
  });
@@ -4240,7 +4287,7 @@ var ServiceContext = class ServiceContext2 {
4240
4287
  } catch (err) {
4241
4288
  import_log13.log.catch(err, void 0, {
4242
4289
  F: __dxlog_file15,
4243
- L: 253,
4290
+ L: 258,
4244
4291
  S: this,
4245
4292
  C: (f, a) => f(...a)
4246
4293
  });
@@ -4840,7 +4887,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4840
4887
  await this._serviceContext.initialized.wait();
4841
4888
  return this._serviceContext.dataSpaceManager;
4842
4889
  }),
4843
- DataService: new import_echo_pipeline3.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4890
+ DataService: new import_echo_pipeline3.DataServiceImpl(this._serviceContext.dataServiceSubscriptions, this._serviceContext.automergeHost),
4844
4891
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
4845
4892
  LoggingService: this._loggingService,
4846
4893
  TracingService: this._tracingService,
@@ -4870,7 +4917,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4870
4917
  deviceKey
4871
4918
  }, {
4872
4919
  F: __dxlog_file17,
4873
- L: 317,
4920
+ L: 320,
4874
4921
  S: this,
4875
4922
  C: (f, a) => f(...a)
4876
4923
  });
@@ -4878,7 +4925,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4878
4925
  id: traceId
4879
4926
  }), {
4880
4927
  F: __dxlog_file17,
4881
- L: 318,
4928
+ L: 321,
4882
4929
  S: this,
4883
4930
  C: (f, a) => f(...a)
4884
4931
  });
@@ -4892,7 +4939,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4892
4939
  deviceKey
4893
4940
  }, {
4894
4941
  F: __dxlog_file17,
4895
- L: 329,
4942
+ L: 332,
4896
4943
  S: this,
4897
4944
  C: (f, a) => f(...a)
4898
4945
  });
@@ -4908,7 +4955,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4908
4955
  deviceKey
4909
4956
  }, {
4910
4957
  F: __dxlog_file17,
4911
- L: 336,
4958
+ L: 339,
4912
4959
  S: this,
4913
4960
  C: (f, a) => f(...a)
4914
4961
  });
@@ -4919,13 +4966,13 @@ var ClientServicesHost = class ClientServicesHost2 {
4919
4966
  id: traceId
4920
4967
  }), {
4921
4968
  F: __dxlog_file17,
4922
- L: 341,
4969
+ L: 344,
4923
4970
  S: this,
4924
4971
  C: (f, a) => f(...a)
4925
4972
  });
4926
4973
  (0, import_log15.log)("resetting...", void 0, {
4927
4974
  F: __dxlog_file17,
4928
- L: 343,
4975
+ L: 346,
4929
4976
  S: this,
4930
4977
  C: (f, a) => f(...a)
4931
4978
  });
@@ -4933,7 +4980,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4933
4980
  await this._storage.reset();
4934
4981
  (0, import_log15.log)("reset", void 0, {
4935
4982
  F: __dxlog_file17,
4936
- L: 346,
4983
+ L: 349,
4937
4984
  S: this,
4938
4985
  C: (f, a) => f(...a)
4939
4986
  });
@@ -4941,7 +4988,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4941
4988
  id: traceId
4942
4989
  }), {
4943
4990
  F: __dxlog_file17,
4944
- L: 347,
4991
+ L: 350,
4945
4992
  S: this,
4946
4993
  C: (f, a) => f(...a)
4947
4994
  });
@@ -5018,4 +5065,4 @@ ClientServicesHost = _ts_decorate8([
5018
5065
  subscribeToSpaces,
5019
5066
  subscribeToSwarmInfo
5020
5067
  });
5021
- //# sourceMappingURL=chunk-TVYC6AI7.cjs.map
5068
+ //# sourceMappingURL=chunk-RD2EVVPQ.cjs.map