@dxos/client-services 0.3.9-main.f27ec14 → 0.3.9-main.f8fc6b9

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 (37) hide show
  1. package/dist/lib/browser/{chunk-RXLILE6E.mjs → chunk-F2XXOT7U.mjs} +127 -65
  2. package/dist/lib/browser/chunk-F2XXOT7U.mjs.map +7 -0
  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 +7 -3
  6. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/{chunk-U3CT7ITF.cjs → chunk-ZZBDK4AA.cjs} +128 -77
  8. package/dist/lib/node/chunk-ZZBDK4AA.cjs.map +7 -0
  9. package/dist/lib/node/index.cjs +37 -37
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +11 -8
  12. package/dist/lib/node/packlets/testing/index.cjs.map +3 -3
  13. package/dist/types/src/packlets/services/service-context.d.ts +2 -1
  14. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  15. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  16. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts +8 -0
  17. package/dist/types/src/packlets/spaces/automerge-space-state.d.ts.map +1 -0
  18. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +3 -2
  19. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  20. package/dist/types/src/packlets/spaces/data-space.d.ts +7 -2
  21. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/genesis.d.ts +1 -1
  23. package/dist/types/src/packlets/spaces/genesis.d.ts.map +1 -1
  24. package/dist/types/src/packlets/testing/test-builder.d.ts +3 -1
  25. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  26. package/dist/types/src/version.d.ts +1 -1
  27. package/package.json +35 -35
  28. package/src/packlets/services/service-context.ts +5 -0
  29. package/src/packlets/services/service-host.ts +5 -2
  30. package/src/packlets/spaces/automerge-space-state.ts +22 -0
  31. package/src/packlets/spaces/data-space-manager.ts +12 -2
  32. package/src/packlets/spaces/data-space.ts +53 -6
  33. package/src/packlets/spaces/genesis.ts +7 -1
  34. package/src/packlets/testing/test-builder.ts +7 -0
  35. package/src/version.ts +1 -1
  36. package/dist/lib/browser/chunk-RXLILE6E.mjs.map +0 -7
  37. package/dist/lib/node/chunk-U3CT7ITF.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_U3CT7ITF_exports = {};
30
- __export(chunk_U3CT7ITF_exports, {
29
+ var chunk_ZZBDK4AA_exports = {};
30
+ __export(chunk_ZZBDK4AA_exports, {
31
31
  ClientRpcServer: () => ClientRpcServer,
32
32
  ClientServicesHost: () => ClientServicesHost,
33
33
  DataSpace: () => DataSpace,
@@ -60,7 +60,7 @@ __export(chunk_U3CT7ITF_exports, {
60
60
  subscribeToSpaces: () => subscribeToSpaces,
61
61
  subscribeToSwarmInfo: () => subscribeToSwarmInfo
62
62
  });
63
- module.exports = __toCommonJS(chunk_U3CT7ITF_exports);
63
+ module.exports = __toCommonJS(chunk_ZZBDK4AA_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.f27ec14";
2652
+ var DXOS_VERSION = "0.3.9-main.f8fc6b9";
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
  });
@@ -3400,9 +3444,9 @@ _ts_decorate4([
3400
3444
  DataSpace = _ts_decorate4([
3401
3445
  (0, import_async10.trackLeaks)("open", "close")
3402
3446
  ], DataSpace);
3403
- var spaceGenesis = async (keyring, signingContext, space) => {
3447
+ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
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({
@@ -3450,7 +3494,8 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3450
3494
  number: 0,
3451
3495
  previousId: void 0,
3452
3496
  timeframe: new import_timeframe3.Timeframe(),
3453
- snapshotCid: void 0
3497
+ snapshotCid: void 0,
3498
+ automergeRoot
3454
3499
  }
3455
3500
  })
3456
3501
  ];
@@ -3477,13 +3522,14 @@ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/s
3477
3522
  var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
3478
3523
  var PRESENCE_OFFLINE_TIMEOUT = 2e4;
3479
3524
  var DataSpaceManager = class DataSpaceManager2 {
3480
- constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
3525
+ constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore, _automergeHost) {
3481
3526
  this._spaceManager = _spaceManager;
3482
3527
  this._metadataStore = _metadataStore;
3483
3528
  this._dataServiceSubscriptions = _dataServiceSubscriptions;
3484
3529
  this._keyring = _keyring;
3485
3530
  this._signingContext = _signingContext;
3486
3531
  this._feedStore = _feedStore;
3532
+ this._automergeHost = _automergeHost;
3487
3533
  this._ctx = new import_context8.Context();
3488
3534
  this.updated = new import_async12.Event();
3489
3535
  this._spaces = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
@@ -3497,7 +3543,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3497
3543
  async open() {
3498
3544
  (0, import_log11.log)("open", void 0, {
3499
3545
  F: __dxlog_file13,
3500
- L: 83,
3546
+ L: 90,
3501
3547
  S: this,
3502
3548
  C: (f, a) => f(...a)
3503
3549
  });
@@ -3505,7 +3551,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3505
3551
  id: this._instanceId
3506
3552
  }), {
3507
3553
  F: __dxlog_file13,
3508
- L: 84,
3554
+ L: 91,
3509
3555
  S: this,
3510
3556
  C: (f, a) => f(...a)
3511
3557
  });
@@ -3513,7 +3559,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3513
3559
  spaces: this._metadataStore.spaces.length
3514
3560
  }, {
3515
3561
  F: __dxlog_file13,
3516
- L: 85,
3562
+ L: 92,
3517
3563
  S: this,
3518
3564
  C: (f, a) => f(...a)
3519
3565
  });
@@ -3523,7 +3569,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3523
3569
  spaceMetadata
3524
3570
  }, {
3525
3571
  F: __dxlog_file13,
3526
- L: 89,
3572
+ L: 96,
3527
3573
  S: this,
3528
3574
  C: (f, a) => f(...a)
3529
3575
  });
@@ -3534,7 +3580,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3534
3580
  err
3535
3581
  }, {
3536
3582
  F: __dxlog_file13,
3537
- L: 92,
3583
+ L: 99,
3538
3584
  S: this,
3539
3585
  C: (f, a) => f(...a)
3540
3586
  });
@@ -3551,7 +3597,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3551
3597
  id: this._instanceId
3552
3598
  }), {
3553
3599
  F: __dxlog_file13,
3554
- L: 105,
3600
+ L: 112,
3555
3601
  S: this,
3556
3602
  C: (f, a) => f(...a)
3557
3603
  });
@@ -3559,7 +3605,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3559
3605
  async close() {
3560
3606
  (0, import_log11.log)("close", void 0, {
3561
3607
  F: __dxlog_file13,
3562
- L: 110,
3608
+ L: 117,
3563
3609
  S: this,
3564
3610
  C: (f, a) => f(...a)
3565
3611
  });
@@ -3575,7 +3621,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3575
3621
  async createSpace() {
3576
3622
  (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3577
3623
  F: __dxlog_file13,
3578
- L: 123,
3624
+ L: 130,
3579
3625
  S: this,
3580
3626
  A: [
3581
3627
  "this._isOpen",
@@ -3596,17 +3642,18 @@ var DataSpaceManager = class DataSpaceManager2 {
3596
3642
  spaceKey
3597
3643
  }, {
3598
3644
  F: __dxlog_file13,
3599
- L: 135,
3645
+ L: 142,
3600
3646
  S: this,
3601
3647
  C: (f, a) => f(...a)
3602
3648
  });
3603
3649
  const space = await this._constructSpace(metadata);
3604
- const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
3650
+ const automergeRoot = this._automergeHost.repo.create();
3651
+ const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
3605
3652
  await this._metadataStore.addSpace(metadata);
3606
3653
  const memberCredential = credentials[1];
3607
- (0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3654
+ (0, import_invariant11.invariant)((0, import_credentials12.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3608
3655
  F: __dxlog_file13,
3609
- L: 142,
3656
+ L: 151,
3610
3657
  S: this,
3611
3658
  A: [
3612
3659
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -3624,13 +3671,13 @@ var DataSpaceManager = class DataSpaceManager2 {
3624
3671
  opts
3625
3672
  }, {
3626
3673
  F: __dxlog_file13,
3627
- L: 154,
3674
+ L: 163,
3628
3675
  S: this,
3629
3676
  C: (f, a) => f(...a)
3630
3677
  });
3631
3678
  (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3632
3679
  F: __dxlog_file13,
3633
- L: 155,
3680
+ L: 164,
3634
3681
  S: this,
3635
3682
  A: [
3636
3683
  "this._isOpen",
@@ -3639,7 +3686,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3639
3686
  });
3640
3687
  (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3641
3688
  F: __dxlog_file13,
3642
- L: 156,
3689
+ L: 165,
3643
3690
  S: this,
3644
3691
  A: [
3645
3692
  "!this._spaces.has(opts.spaceKey)",
@@ -3674,7 +3721,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3674
3721
  metadata
3675
3722
  }, {
3676
3723
  F: __dxlog_file13,
3677
- L: 189,
3724
+ L: 198,
3678
3725
  S: this,
3679
3726
  C: (f, a) => f(...a)
3680
3727
  });
@@ -3710,7 +3757,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3710
3757
  onAuthFailure: () => {
3711
3758
  import_log11.log.warn("auth failure", void 0, {
3712
3759
  F: __dxlog_file13,
3713
- L: 224,
3760
+ L: 233,
3714
3761
  S: this,
3715
3762
  C: (f, a) => f(...a)
3716
3763
  });
@@ -3734,7 +3781,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3734
3781
  space: space.key
3735
3782
  }, {
3736
3783
  F: __dxlog_file13,
3737
- L: 242,
3784
+ L: 251,
3738
3785
  S: this,
3739
3786
  C: (f, a) => f(...a)
3740
3787
  });
@@ -3746,7 +3793,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3746
3793
  open: this._isOpen
3747
3794
  }, {
3748
3795
  F: __dxlog_file13,
3749
- L: 249,
3796
+ L: 258,
3750
3797
  S: this,
3751
3798
  C: (f, a) => f(...a)
3752
3799
  });
@@ -3759,14 +3806,15 @@ var DataSpaceManager = class DataSpaceManager2 {
3759
3806
  space: space.key
3760
3807
  }, {
3761
3808
  F: __dxlog_file13,
3762
- L: 255,
3809
+ L: 264,
3763
3810
  S: this,
3764
3811
  C: (f, a) => f(...a)
3765
3812
  });
3766
3813
  await this._dataServiceSubscriptions.unregisterSpace(space.key);
3767
3814
  }
3768
3815
  },
3769
- cache: metadata.cache
3816
+ cache: metadata.cache,
3817
+ automergeHost: this._automergeHost
3770
3818
  });
3771
3819
  if (metadata.state !== import_services8.SpaceState.INACTIVE) {
3772
3820
  await dataSpace.open();
@@ -4052,6 +4100,7 @@ var ServiceContext = class ServiceContext2 {
4052
4100
  snapshotStore: this.snapshotStore
4053
4101
  });
4054
4102
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
4103
+ this.automergeHost = new import_echo_pipeline2.AutomergeHost(storage.createDirectory("automerge"));
4055
4104
  this.invitations = new InvitationsHandler(this.networkManager);
4056
4105
  this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug7.failUndefined)(), this._acceptIdentity.bind(this)));
4057
4106
  }
@@ -4059,7 +4108,7 @@ var ServiceContext = class ServiceContext2 {
4059
4108
  await this._checkStorageVersion();
4060
4109
  (0, import_log13.log)("opening...", void 0, {
4061
4110
  F: __dxlog_file15,
4062
- L: 129,
4111
+ L: 133,
4063
4112
  S: this,
4064
4113
  C: (f, a) => f(...a)
4065
4114
  });
@@ -4067,7 +4116,7 @@ var ServiceContext = class ServiceContext2 {
4067
4116
  id: this._instanceId
4068
4117
  }), {
4069
4118
  F: __dxlog_file15,
4070
- L: 130,
4119
+ L: 134,
4071
4120
  S: this,
4072
4121
  C: (f, a) => f(...a)
4073
4122
  });
@@ -4083,13 +4132,13 @@ var ServiceContext = class ServiceContext2 {
4083
4132
  id: this._instanceId
4084
4133
  }), {
4085
4134
  F: __dxlog_file15,
4086
- L: 140,
4135
+ L: 144,
4087
4136
  S: this,
4088
4137
  C: (f, a) => f(...a)
4089
4138
  });
4090
4139
  (0, import_log13.log)("opened", void 0, {
4091
4140
  F: __dxlog_file15,
4092
- L: 141,
4141
+ L: 145,
4093
4142
  S: this,
4094
4143
  C: (f, a) => f(...a)
4095
4144
  });
@@ -4097,7 +4146,7 @@ var ServiceContext = class ServiceContext2 {
4097
4146
  async close() {
4098
4147
  (0, import_log13.log)("closing...", void 0, {
4099
4148
  F: __dxlog_file15,
4100
- L: 145,
4149
+ L: 149,
4101
4150
  S: this,
4102
4151
  C: (f, a) => f(...a)
4103
4152
  });
@@ -4114,7 +4163,7 @@ var ServiceContext = class ServiceContext2 {
4114
4163
  await this.metadataStore.close();
4115
4164
  (0, import_log13.log)("closed", void 0, {
4116
4165
  F: __dxlog_file15,
4117
- L: 157,
4166
+ L: 161,
4118
4167
  S: this,
4119
4168
  C: (f, a) => f(...a)
4120
4169
  });
@@ -4128,7 +4177,7 @@ var ServiceContext = class ServiceContext2 {
4128
4177
  const factory = this._handlerFactories.get(invitation.kind);
4129
4178
  (0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
4130
4179
  F: __dxlog_file15,
4131
- L: 168,
4180
+ L: 172,
4132
4181
  S: this,
4133
4182
  A: [
4134
4183
  "factory",
@@ -4160,7 +4209,7 @@ var ServiceContext = class ServiceContext2 {
4160
4209
  async _initialize(ctx) {
4161
4210
  (0, import_log13.log)("initializing spaces...", void 0, {
4162
4211
  F: __dxlog_file15,
4163
- L: 199,
4212
+ L: 203,
4164
4213
  S: this,
4165
4214
  C: (f, a) => f(...a)
4166
4215
  });
@@ -4178,12 +4227,12 @@ var ServiceContext = class ServiceContext2 {
4178
4227
  });
4179
4228
  }
4180
4229
  };
4181
- this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
4230
+ this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore, this.automergeHost);
4182
4231
  await this.dataSpaceManager.open();
4183
4232
  this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
4184
4233
  (0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
4185
4234
  F: __dxlog_file15,
4186
- L: 222,
4235
+ L: 227,
4187
4236
  S: this,
4188
4237
  A: [
4189
4238
  "this.dataSpaceManager",
@@ -4195,7 +4244,7 @@ var ServiceContext = class ServiceContext2 {
4195
4244
  this.initialized.wake();
4196
4245
  this._deviceSpaceSync = {
4197
4246
  processCredential: async (credential) => {
4198
- const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
4247
+ const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
4199
4248
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
4200
4249
  return;
4201
4250
  }
@@ -4207,7 +4256,7 @@ var ServiceContext = class ServiceContext2 {
4207
4256
  details: assertion
4208
4257
  }, {
4209
4258
  F: __dxlog_file15,
4210
- L: 238,
4259
+ L: 243,
4211
4260
  S: this,
4212
4261
  C: (f, a) => f(...a)
4213
4262
  });
@@ -4218,7 +4267,7 @@ var ServiceContext = class ServiceContext2 {
4218
4267
  details: assertion
4219
4268
  }, {
4220
4269
  F: __dxlog_file15,
4221
- L: 242,
4270
+ L: 247,
4222
4271
  S: this,
4223
4272
  C: (f, a) => f(...a)
4224
4273
  });
@@ -4229,7 +4278,7 @@ var ServiceContext = class ServiceContext2 {
4229
4278
  details: assertion
4230
4279
  }, {
4231
4280
  F: __dxlog_file15,
4232
- L: 247,
4281
+ L: 252,
4233
4282
  S: this,
4234
4283
  C: (f, a) => f(...a)
4235
4284
  });
@@ -4240,7 +4289,7 @@ var ServiceContext = class ServiceContext2 {
4240
4289
  } catch (err) {
4241
4290
  import_log13.log.catch(err, void 0, {
4242
4291
  F: __dxlog_file15,
4243
- L: 253,
4292
+ L: 258,
4244
4293
  S: this,
4245
4294
  C: (f, a) => f(...a)
4246
4295
  });
@@ -4840,7 +4889,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4840
4889
  await this._serviceContext.initialized.wait();
4841
4890
  return this._serviceContext.dataSpaceManager;
4842
4891
  }),
4843
- DataService: new import_echo_pipeline3.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4892
+ DataService: new import_echo_pipeline3.DataServiceImpl(this._serviceContext.dataServiceSubscriptions, this._serviceContext.automergeHost),
4844
4893
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
4845
4894
  LoggingService: this._loggingService,
4846
4895
  TracingService: this._tracingService,
@@ -4870,7 +4919,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4870
4919
  deviceKey
4871
4920
  }, {
4872
4921
  F: __dxlog_file17,
4873
- L: 317,
4922
+ L: 320,
4874
4923
  S: this,
4875
4924
  C: (f, a) => f(...a)
4876
4925
  });
@@ -4878,7 +4927,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4878
4927
  id: traceId
4879
4928
  }), {
4880
4929
  F: __dxlog_file17,
4881
- L: 318,
4930
+ L: 321,
4882
4931
  S: this,
4883
4932
  C: (f, a) => f(...a)
4884
4933
  });
@@ -4892,7 +4941,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4892
4941
  deviceKey
4893
4942
  }, {
4894
4943
  F: __dxlog_file17,
4895
- L: 329,
4944
+ L: 332,
4896
4945
  S: this,
4897
4946
  C: (f, a) => f(...a)
4898
4947
  });
@@ -4908,7 +4957,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4908
4957
  deviceKey
4909
4958
  }, {
4910
4959
  F: __dxlog_file17,
4911
- L: 336,
4960
+ L: 339,
4912
4961
  S: this,
4913
4962
  C: (f, a) => f(...a)
4914
4963
  });
@@ -4919,13 +4968,13 @@ var ClientServicesHost = class ClientServicesHost2 {
4919
4968
  id: traceId
4920
4969
  }), {
4921
4970
  F: __dxlog_file17,
4922
- L: 341,
4971
+ L: 344,
4923
4972
  S: this,
4924
4973
  C: (f, a) => f(...a)
4925
4974
  });
4926
4975
  (0, import_log15.log)("resetting...", void 0, {
4927
4976
  F: __dxlog_file17,
4928
- L: 343,
4977
+ L: 346,
4929
4978
  S: this,
4930
4979
  C: (f, a) => f(...a)
4931
4980
  });
@@ -4933,7 +4982,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4933
4982
  await this._storage.reset();
4934
4983
  (0, import_log15.log)("reset", void 0, {
4935
4984
  F: __dxlog_file17,
4936
- L: 346,
4985
+ L: 349,
4937
4986
  S: this,
4938
4987
  C: (f, a) => f(...a)
4939
4988
  });
@@ -4941,7 +4990,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4941
4990
  id: traceId
4942
4991
  }), {
4943
4992
  F: __dxlog_file17,
4944
- L: 347,
4993
+ L: 350,
4945
4994
  S: this,
4946
4995
  C: (f, a) => f(...a)
4947
4996
  });
@@ -4951,7 +5000,9 @@ var ClientServicesHost = class ClientServicesHost2 {
4951
5000
  const identity = await this._serviceContext.createIdentity(params);
4952
5001
  await this._serviceContext.initialized.wait();
4953
5002
  const space = await this._serviceContext.dataSpaceManager.createSpace();
4954
- const obj = new import_client_protocol5.Properties();
5003
+ const obj = new import_client_protocol5.Properties(void 0, {
5004
+ useAutomergeBackend: false
5005
+ });
4955
5006
  obj[import_client_protocol5.defaultKey] = identity.identityKey.toHex();
4956
5007
  await this._serviceRegistry.services.DataService.write({
4957
5008
  spaceKey: space.key,
@@ -5018,4 +5069,4 @@ ClientServicesHost = _ts_decorate8([
5018
5069
  subscribeToSpaces,
5019
5070
  subscribeToSwarmInfo
5020
5071
  });
5021
- //# sourceMappingURL=chunk-U3CT7ITF.cjs.map
5072
+ //# sourceMappingURL=chunk-ZZBDK4AA.cjs.map