@dxos/client-services 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8

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 (41) hide show
  1. package/dist/lib/browser/{chunk-J33W6T4Q.mjs → chunk-SVH323CC.mjs} +688 -124
  2. package/dist/lib/browser/chunk-SVH323CC.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +23 -15
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +1 -1
  7. package/dist/lib/node-esm/{chunk-34HKLADW.mjs → chunk-XCY7TTXS.mjs} +688 -124
  8. package/dist/lib/node-esm/chunk-XCY7TTXS.mjs.map +7 -0
  9. package/dist/lib/node-esm/index.mjs +23 -15
  10. package/dist/lib/node-esm/index.mjs.map +3 -3
  11. package/dist/lib/node-esm/meta.json +1 -1
  12. package/dist/lib/node-esm/testing/index.mjs +1 -1
  13. package/dist/types/src/packlets/logging/logging-service.d.ts +4 -0
  14. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  15. package/dist/types/src/packlets/services/feed-syncer.d.ts +59 -0
  16. package/dist/types/src/packlets/services/feed-syncer.d.ts.map +1 -0
  17. package/dist/types/src/packlets/services/feed-syncer.test.d.ts +2 -0
  18. package/dist/types/src/packlets/services/feed-syncer.test.d.ts.map +1 -0
  19. package/dist/types/src/packlets/services/platform.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/service-context.d.ts +1 -2
  21. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  22. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  23. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  24. package/dist/types/src/packlets/worker/worker-runtime.d.ts +11 -3
  25. package/dist/types/src/packlets/worker/worker-runtime.d.ts.map +1 -1
  26. package/dist/types/src/version.d.ts +1 -1
  27. package/dist/types/src/version.d.ts.map +1 -1
  28. package/dist/types/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +43 -43
  30. package/src/packlets/logging/logging-service.ts +4 -0
  31. package/src/packlets/services/feed-syncer.test.ts +340 -0
  32. package/src/packlets/services/feed-syncer.ts +330 -0
  33. package/src/packlets/services/platform.ts +7 -1
  34. package/src/packlets/services/service-context.ts +84 -11
  35. package/src/packlets/services/service-host.ts +5 -3
  36. package/src/packlets/spaces/data-space.ts +3 -0
  37. package/src/packlets/worker/worker-runtime.ts +13 -5
  38. package/src/packlets/worker/worker-session.ts +4 -4
  39. package/src/version.ts +1 -1
  40. package/dist/lib/browser/chunk-J33W6T4Q.mjs.map +0 -7
  41. package/dist/lib/node-esm/chunk-34HKLADW.mjs.map +0 -7
@@ -403,7 +403,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
403
403
  import { TRACE_PROCESSOR } from "@dxos/tracing";
404
404
 
405
405
  // src/version.ts
406
- var DXOS_VERSION = "0.8.4-main.bc674ce";
406
+ var DXOS_VERSION = "0.8.4-main.c351d160a8";
407
407
 
408
408
  // src/packlets/services/platform.ts
409
409
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -416,11 +416,16 @@ var getPlatform = () => {
416
416
  userAgent,
417
417
  uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
418
418
  };
419
- } else {
419
+ } else if (typeof SharedWorkerGlobalScope !== "undefined") {
420
420
  return {
421
421
  type: Platform.PLATFORM_TYPE.SHARED_WORKER,
422
422
  uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
423
423
  };
424
+ } else {
425
+ return {
426
+ type: Platform.PLATFORM_TYPE.DEDICATED_WORKER,
427
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
428
+ };
424
429
  }
425
430
  } else {
426
431
  const { platform: platform2, version, arch } = process;
@@ -4708,9 +4713,12 @@ var DataSpace = class {
4708
4713
  C: (f, a) => f(...a)
4709
4714
  });
4710
4715
  } catch (err) {
4716
+ if (err instanceof ContextDisposedError) {
4717
+ return;
4718
+ }
4711
4719
  log12.error("error notarizing credentials for feed admission", err, {
4712
4720
  F: __dxlog_file15,
4713
- L: 453,
4721
+ L: 456,
4714
4722
  S: this,
4715
4723
  C: (f, a) => f(...a)
4716
4724
  });
@@ -4725,7 +4733,7 @@ var DataSpace = class {
4725
4733
  rootUrl
4726
4734
  }, {
4727
4735
  F: __dxlog_file15,
4728
- L: 463,
4736
+ L: 466,
4729
4737
  S: this,
4730
4738
  C: (f, a) => f(...a)
4731
4739
  });
@@ -4741,7 +4749,7 @@ var DataSpace = class {
4741
4749
  await warnAfterTimeout(5e3, "Automerge root doc load timeout (DataSpace)", async () => {
4742
4750
  handle = await cancelWithContext2(this._ctx, this._echoHost.loadDoc(Context6.default(void 0, {
4743
4751
  F: __dxlog_file15,
4744
- L: 473
4752
+ L: 476
4745
4753
  }), rootUrl, {
4746
4754
  fetchFromNetwork: true
4747
4755
  }));
@@ -4785,7 +4793,7 @@ var DataSpace = class {
4785
4793
  err
4786
4794
  }, {
4787
4795
  F: __dxlog_file15,
4788
- L: 512,
4796
+ L: 515,
4789
4797
  S: this,
4790
4798
  C: (f, a) => f(...a)
4791
4799
  });
@@ -4875,7 +4883,7 @@ var DataSpace = class {
4875
4883
  state: SpaceState4[this._state]
4876
4884
  }, {
4877
4885
  F: __dxlog_file15,
4878
- L: 594,
4886
+ L: 597,
4879
4887
  S: this,
4880
4888
  C: (f, a) => f(...a)
4881
4889
  });
@@ -7653,17 +7661,18 @@ var mapStatus = (agentStatus) => {
7653
7661
 
7654
7662
  // src/packlets/services/service-context.ts
7655
7663
  import { Mutex as Mutex4, Trigger as Trigger7 } from "@dxos/async";
7656
- import { Context as Context10, Resource as Resource8 } from "@dxos/context";
7664
+ import { Context as Context10, Resource as Resource9 } from "@dxos/context";
7657
7665
  import { getCredentialAssertion as getCredentialAssertion6 } from "@dxos/credentials";
7658
7666
  import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
7659
7667
  import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
7660
7668
  import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
7661
7669
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
7662
- import { invariant as invariant22 } from "@dxos/invariant";
7670
+ import { invariant as invariant23 } from "@dxos/invariant";
7663
7671
  import { Keyring } from "@dxos/keyring";
7664
7672
  import { PublicKey as PublicKey15 } from "@dxos/keys";
7665
7673
  import { log as log23 } from "@dxos/log";
7666
7674
  import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
7675
+ import { FeedProtocol as FeedProtocol2 } from "@dxos/protocols";
7667
7676
  import { Invitation as Invitation10 } from "@dxos/protocols/proto/dxos/client/services";
7668
7677
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
7669
7678
  import { trace as Trace3 } from "@dxos/tracing";
@@ -7889,6 +7898,246 @@ var decodeCredential = (credentialBase64) => {
7889
7898
  return codec.decode(credentialBytes);
7890
7899
  };
7891
7900
 
7901
+ // src/packlets/services/feed-syncer.ts
7902
+ import { Encoder, decode as cborXdecode } from "cbor-x";
7903
+ import * as Effect from "effect/Effect";
7904
+ import * as Schema from "effect/Schema";
7905
+ import { AsyncTask, scheduleTask as scheduleTask9 } from "@dxos/async";
7906
+ import { Resource as Resource8 } from "@dxos/context";
7907
+ import { MessageSchema } from "@dxos/edge-client";
7908
+ import { RuntimeProvider } from "@dxos/effect";
7909
+ import { SyncClient } from "@dxos/feed";
7910
+ import { invariant as invariant22 } from "@dxos/invariant";
7911
+ import { SpaceId as SpaceId4 } from "@dxos/keys";
7912
+ import { FeedProtocol } from "@dxos/protocols";
7913
+ import { EdgeService as EdgeService2 } from "@dxos/protocols";
7914
+ import { createBuf } from "@dxos/protocols/buf";
7915
+ import { bufferToArray as bufferToArray2 } from "@dxos/util";
7916
+ var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/feed-syncer.ts";
7917
+ var encoder = new Encoder({
7918
+ tagUint8Array: false,
7919
+ useRecords: false
7920
+ });
7921
+ var DEFAULT_MESSAGE_BLOCKS_LIMIT = 50;
7922
+ var DEFAULT_SYNC_CONCURRENCY = 5;
7923
+ var DEFAULT_POLLING_INTERVAL = 5e3;
7924
+ var DEFAULT_POLL_REQUEST_THROTTLE_MS = 250;
7925
+ var MAX_BLOCKING_SYNC_ITERATIONS = 100;
7926
+ var FeedSyncer = class extends Resource8 {
7927
+ #syncNamespaces;
7928
+ #messageBlocksLimit;
7929
+ #syncConcurrency;
7930
+ #pollingInterval;
7931
+ #pollRequestThrottleMs;
7932
+ #runtime;
7933
+ #feedStore;
7934
+ #edgeClient;
7935
+ #syncClient;
7936
+ #getSpaceIds;
7937
+ #spacesToPoll = /* @__PURE__ */ new Set();
7938
+ /** Last time full poll was completed. */
7939
+ #lastFullPoll = null;
7940
+ #throttledPollScheduled = false;
7941
+ #lastRequestedPollAt = null;
7942
+ constructor(options) {
7943
+ super();
7944
+ this.#runtime = options.runtime;
7945
+ this.#feedStore = options.feedStore;
7946
+ this.#edgeClient = options.edgeClient;
7947
+ this.#syncClient = new SyncClient({
7948
+ peerId: options.peerId,
7949
+ feedStore: options.feedStore,
7950
+ sendMessage: this.#sendMessage.bind(this)
7951
+ });
7952
+ this.#getSpaceIds = options.getSpaceIds;
7953
+ this.#syncNamespaces = options.syncNamespaces;
7954
+ this.#messageBlocksLimit = options.messageBlocksLimit ?? DEFAULT_MESSAGE_BLOCKS_LIMIT;
7955
+ this.#syncConcurrency = options.syncConcurrency ?? DEFAULT_SYNC_CONCURRENCY;
7956
+ this.#pollingInterval = options.pollingInterval ?? DEFAULT_POLLING_INTERVAL;
7957
+ this.#pollRequestThrottleMs = options.pollRequestThrottleMs ?? DEFAULT_POLL_REQUEST_THROTTLE_MS;
7958
+ }
7959
+ async _open() {
7960
+ this._ctx.onDispose(this.#edgeClient.onMessage((msg) => {
7961
+ if (!msg.serviceId) {
7962
+ return;
7963
+ }
7964
+ const service = msg.serviceId.split(":")[0];
7965
+ if (service !== EdgeService2.QUEUE_REPLICATOR) {
7966
+ return;
7967
+ }
7968
+ const handleMessageEffect = Effect.gen(this, function* () {
7969
+ const decoded = yield* Effect.try({
7970
+ try: () => cborXdecode(msg.payload.value),
7971
+ catch: (error) => new Error(`Failed to decode feed sync message: ${error}`)
7972
+ });
7973
+ const payload = yield* Schema.validate(FeedProtocol.ProtocolMessage)(decoded);
7974
+ yield* this.#syncClient.handleMessage(payload);
7975
+ });
7976
+ void RuntimeProvider.runPromise(this.#runtime)(handleMessageEffect);
7977
+ }));
7978
+ this._ctx.onDispose(
7979
+ // NOTE: This will fire immediately if the connection is already open.
7980
+ this.#edgeClient.onReconnected(async () => {
7981
+ })
7982
+ );
7983
+ this.#feedStore.onNewBlocks.on(this._ctx, () => {
7984
+ this.#pushTask.schedule();
7985
+ });
7986
+ await this.#pollTask.open();
7987
+ await this.#pushTask.open();
7988
+ this.#resetSpacesToPoll();
7989
+ this.#pollTask.schedule();
7990
+ }
7991
+ async _close() {
7992
+ await this.#pollTask.close();
7993
+ await this.#pushTask.close();
7994
+ }
7995
+ /**
7996
+ * Schedules a best-effort pull without blocking the caller.
7997
+ */
7998
+ schedulePoll() {
7999
+ this.#resetSpacesToPoll();
8000
+ if (this.#throttledPollScheduled) {
8001
+ return;
8002
+ }
8003
+ const now = Date.now();
8004
+ const delay = this.#lastRequestedPollAt == null ? 0 : Math.max(this.#pollRequestThrottleMs - (now - this.#lastRequestedPollAt), 0);
8005
+ this.#throttledPollScheduled = true;
8006
+ scheduleTask9(this._ctx, () => {
8007
+ this.#throttledPollScheduled = false;
8008
+ this.#lastRequestedPollAt = Date.now();
8009
+ this.#pollTask.schedule();
8010
+ }, delay);
8011
+ }
8012
+ /**
8013
+ * Performs queue sync and blocks until there are no pending sync batches.
8014
+ */
8015
+ async syncBlocking({ spaceId, subspaceTag, shouldPush = true, shouldPull = true }) {
8016
+ invariant22(SpaceId4.isValid(spaceId), void 0, {
8017
+ F: __dxlog_file27,
8018
+ L: 190,
8019
+ S: this,
8020
+ A: [
8021
+ "SpaceId.isValid(spaceId)",
8022
+ ""
8023
+ ]
8024
+ });
8025
+ invariant22(FeedProtocol.isWellKnownNamespace(subspaceTag), void 0, {
8026
+ F: __dxlog_file27,
8027
+ L: 191,
8028
+ S: this,
8029
+ A: [
8030
+ "FeedProtocol.isWellKnownNamespace(subspaceTag)",
8031
+ ""
8032
+ ]
8033
+ });
8034
+ if (!shouldPush && !shouldPull) {
8035
+ return;
8036
+ }
8037
+ await RuntimeProvider.runPromise(this.#runtime)(Effect.gen(this, function* () {
8038
+ let done = false;
8039
+ let iterations = 0;
8040
+ while (!done) {
8041
+ done = true;
8042
+ if (shouldPull) {
8043
+ const pullResult = yield* this.#syncClient.pull({
8044
+ spaceId,
8045
+ feedNamespace: subspaceTag,
8046
+ limit: this.#messageBlocksLimit
8047
+ });
8048
+ done &&= pullResult.done;
8049
+ }
8050
+ if (shouldPush) {
8051
+ const pushResult = yield* this.#syncClient.push({
8052
+ spaceId,
8053
+ feedNamespace: subspaceTag,
8054
+ limit: this.#messageBlocksLimit
8055
+ });
8056
+ done &&= pushResult.done;
8057
+ }
8058
+ iterations++;
8059
+ if (iterations > MAX_BLOCKING_SYNC_ITERATIONS) {
8060
+ throw new Error("Blocking sync exceeded max iterations.");
8061
+ }
8062
+ }
8063
+ }));
8064
+ }
8065
+ #resetSpacesToPoll() {
8066
+ this.#spacesToPoll.clear();
8067
+ this.#getSpaceIds().forEach((spaceId) => {
8068
+ this.#spacesToPoll.add(spaceId);
8069
+ });
8070
+ this.#lastFullPoll = Date.now();
8071
+ }
8072
+ #sendMessage(message) {
8073
+ return Effect.gen(this, function* () {
8074
+ const encoded = encoder.encode(message);
8075
+ yield* Effect.tryPromise(async () => this.#edgeClient.send(createBuf(MessageSchema, {
8076
+ source: {
8077
+ identityKey: this.#edgeClient.identityKey,
8078
+ peerKey: this.#edgeClient.peerKey
8079
+ },
8080
+ serviceId: this.#getTargetServiceId(message),
8081
+ payload: {
8082
+ value: bufferToArray2(encoded)
8083
+ }
8084
+ })));
8085
+ });
8086
+ }
8087
+ #getTargetServiceId(message) {
8088
+ return FeedProtocol.encodeServiceId(message.feedNamespace, message.spaceId);
8089
+ }
8090
+ #pollTask = new AsyncTask(async () => Effect.gen(this, function* () {
8091
+ yield* Effect.forEach(this.#spacesToPoll, (spaceId) => Effect.gen(this, function* () {
8092
+ let doneForAllNamespaces = true;
8093
+ for (const feedNamespace of this.#syncNamespaces) {
8094
+ const { done } = yield* this.#syncClient.pull({
8095
+ spaceId,
8096
+ feedNamespace,
8097
+ limit: this.#messageBlocksLimit
8098
+ });
8099
+ if (!done) {
8100
+ doneForAllNamespaces = false;
8101
+ }
8102
+ }
8103
+ if (doneForAllNamespaces) {
8104
+ this.#spacesToPoll.delete(spaceId);
8105
+ }
8106
+ }), {
8107
+ concurrency: this.#syncConcurrency
8108
+ });
8109
+ if (this.#lastFullPoll == null || Date.now() - this.#lastFullPoll > this.#pollingInterval) {
8110
+ this.#resetSpacesToPoll();
8111
+ this.#pollTask.schedule();
8112
+ } else if (this.#spacesToPoll.size > 0) {
8113
+ this.#pollTask.schedule();
8114
+ } else {
8115
+ this.#resetSpacesToPoll();
8116
+ scheduleTask9(this._ctx, () => this.#pollTask.schedule(), Math.max(this.#pollingInterval - (Date.now() - (this.#lastFullPoll ?? 0)), 0));
8117
+ }
8118
+ }).pipe(RuntimeProvider.runPromise(this.#runtime)));
8119
+ #pushTask = new AsyncTask(async () => Effect.gen(this, function* () {
8120
+ yield* Effect.forEach(this.#getSpaceIds(), (spaceId) => Effect.gen(this, function* () {
8121
+ let doneForAllNamespaces = true;
8122
+ for (const feedNamespace of this.#syncNamespaces) {
8123
+ const { done } = yield* this.#syncClient.push({
8124
+ spaceId,
8125
+ feedNamespace,
8126
+ limit: this.#messageBlocksLimit
8127
+ });
8128
+ if (!done) {
8129
+ doneForAllNamespaces = false;
8130
+ }
8131
+ }
8132
+ if (!doneForAllNamespaces) {
8133
+ this.#pushTask.schedule();
8134
+ }
8135
+ }), {
8136
+ concurrency: this.#syncConcurrency
8137
+ });
8138
+ }).pipe(RuntimeProvider.runPromise(this.#runtime)));
8139
+ };
8140
+
7892
8141
  // src/packlets/services/service-context.ts
7893
8142
  function _ts_decorate8(decorators, target, key, desc) {
7894
8143
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -7961,8 +8210,8 @@ function _ts_dispose_resources4(env) {
7961
8210
  return next();
7962
8211
  })(env);
7963
8212
  }
7964
- var __dxlog_file27 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
7965
- var ServiceContext = class extends Resource8 {
8213
+ var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
8214
+ var ServiceContext = class extends Resource9 {
7966
8215
  storage;
7967
8216
  level;
7968
8217
  networkManager;
@@ -7986,6 +8235,7 @@ var ServiceContext = class extends Resource8 {
7986
8235
  echoHost;
7987
8236
  _meshReplicator = void 0;
7988
8237
  _echoEdgeReplicator = void 0;
8238
+ _feedSyncer = void 0;
7989
8239
  // Initialized after identity is initialized.
7990
8240
  dataSpaceManager;
7991
8241
  edgeAgentManager;
@@ -7995,14 +8245,14 @@ var ServiceContext = class extends Resource8 {
7995
8245
  constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtime, _runtimeProps, _edgeFeatures) {
7996
8246
  super(), this.storage = storage, this.level = level, this.networkManager = networkManager, this.signalManager = signalManager, this._edgeConnection = _edgeConnection, this._edgeHttpClient = _edgeHttpClient, this._runtime = _runtime, this._runtimeProps = _runtimeProps, this._edgeFeatures = _edgeFeatures;
7997
8247
  log23("runtimeProps", this._runtimeProps, {
7998
- F: __dxlog_file27,
7999
- L: 120,
8248
+ F: __dxlog_file28,
8249
+ L: 122,
8000
8250
  S: this,
8001
8251
  C: (f, a) => f(...a)
8002
8252
  });
8003
8253
  log23("edgeFeatures", this._edgeFeatures, {
8004
- F: __dxlog_file27,
8005
- L: 121,
8254
+ F: __dxlog_file28,
8255
+ L: 123,
8006
8256
  S: this,
8007
8257
  C: (f, a) => f(...a)
8008
8258
  });
@@ -8041,12 +8291,15 @@ var ServiceContext = class extends Resource8 {
8041
8291
  kv: this.level,
8042
8292
  peerIdProvider: () => this.identityManager.identity?.deviceKey?.toHex(),
8043
8293
  getSpaceKeyByRootDocumentId: (documentId) => this.spaceManager.findSpaceByRootDocumentId(documentId)?.key,
8044
- indexing: {
8045
- vector: this._runtimeProps?.enableVectorIndexing,
8046
- sqlIndex: this._runtimeProps?.enableSqlite
8047
- },
8048
8294
  runtime: this._runtime,
8049
- localQueues: this._runtimeProps?.enableLocalQueues
8295
+ syncQueue: async (request) => {
8296
+ return this._feedSyncer?.syncBlocking({
8297
+ spaceId: request.spaceId,
8298
+ subspaceTag: request.subspaceTag,
8299
+ shouldPush: request.shouldPush,
8300
+ shouldPull: request.shouldPull
8301
+ });
8302
+ }
8050
8303
  });
8051
8304
  this.invitations = new InvitationsHandler(this.networkManager, this._edgeHttpClient, _runtimeProps?.invitationConnectionDefaultProps);
8052
8305
  this.invitationsManager = new InvitationsManager(this.invitations, (invitation) => this.getInvitationHandler(invitation), this.metadataStore);
@@ -8060,72 +8313,258 @@ var ServiceContext = class extends Resource8 {
8060
8313
  edgeHttpClient: this._edgeHttpClient
8061
8314
  });
8062
8315
  }
8316
+ if (this.echoHost.feedStore && this._edgeConnection) {
8317
+ this._feedSyncer = new FeedSyncer({
8318
+ runtime: this._runtime,
8319
+ feedStore: this.echoHost.feedStore,
8320
+ edgeClient: this._edgeConnection,
8321
+ peerId: this.identityManager.identity?.deviceKey?.toHex() ?? "",
8322
+ getSpaceIds: () => this.echoHost.spaceIds,
8323
+ syncNamespaces: [
8324
+ FeedProtocol2.WellKnownNamespaces.data,
8325
+ FeedProtocol2.WellKnownNamespaces.trace
8326
+ ]
8327
+ });
8328
+ }
8063
8329
  }
8064
8330
  async _open(ctx) {
8065
8331
  await this._checkStorageVersion();
8066
8332
  log23("opening...", void 0, {
8067
- F: __dxlog_file27,
8068
- L: 215,
8333
+ F: __dxlog_file28,
8334
+ L: 231,
8069
8335
  S: this,
8070
8336
  C: (f, a) => f(...a)
8071
8337
  });
8072
8338
  log23.trace("dxos.sdk.service-context.open", trace9.begin({
8073
8339
  id: this._instanceId
8074
8340
  }), {
8075
- F: __dxlog_file27,
8076
- L: 216,
8341
+ F: __dxlog_file28,
8342
+ L: 232,
8343
+ S: this,
8344
+ C: (f, a) => f(...a)
8345
+ });
8346
+ log23("opening identityManager...", void 0, {
8347
+ F: __dxlog_file28,
8348
+ L: 234,
8077
8349
  S: this,
8078
8350
  C: (f, a) => f(...a)
8079
8351
  });
8080
8352
  await this.identityManager.open(ctx);
8353
+ log23("identityManager opened", {
8354
+ hasIdentity: !!this.identityManager.identity
8355
+ }, {
8356
+ F: __dxlog_file28,
8357
+ L: 236,
8358
+ S: this,
8359
+ C: (f, a) => f(...a)
8360
+ });
8361
+ log23("setting network identity...", void 0, {
8362
+ F: __dxlog_file28,
8363
+ L: 238,
8364
+ S: this,
8365
+ C: (f, a) => f(...a)
8366
+ });
8081
8367
  await this._setNetworkIdentity();
8368
+ log23("network identity set", void 0, {
8369
+ F: __dxlog_file28,
8370
+ L: 240,
8371
+ S: this,
8372
+ C: (f, a) => f(...a)
8373
+ });
8374
+ log23("opening edge connection...", void 0, {
8375
+ F: __dxlog_file28,
8376
+ L: 242,
8377
+ S: this,
8378
+ C: (f, a) => f(...a)
8379
+ });
8082
8380
  await this._edgeConnection?.open();
8381
+ log23("edge connection opened", void 0, {
8382
+ F: __dxlog_file28,
8383
+ L: 244,
8384
+ S: this,
8385
+ C: (f, a) => f(...a)
8386
+ });
8387
+ log23("opening signal manager...", void 0, {
8388
+ F: __dxlog_file28,
8389
+ L: 246,
8390
+ S: this,
8391
+ C: (f, a) => f(...a)
8392
+ });
8083
8393
  await this.signalManager.open();
8394
+ log23("signal manager opened", void 0, {
8395
+ F: __dxlog_file28,
8396
+ L: 248,
8397
+ S: this,
8398
+ C: (f, a) => f(...a)
8399
+ });
8400
+ log23("opening network manager...", void 0, {
8401
+ F: __dxlog_file28,
8402
+ L: 250,
8403
+ S: this,
8404
+ C: (f, a) => f(...a)
8405
+ });
8084
8406
  await this.networkManager.open();
8407
+ log23("network manager opened", void 0, {
8408
+ F: __dxlog_file28,
8409
+ L: 252,
8410
+ S: this,
8411
+ C: (f, a) => f(...a)
8412
+ });
8413
+ log23("opening echo host...", void 0, {
8414
+ F: __dxlog_file28,
8415
+ L: 254,
8416
+ S: this,
8417
+ C: (f, a) => f(...a)
8418
+ });
8085
8419
  await this.echoHost.open(ctx);
8420
+ log23("echo host opened", void 0, {
8421
+ F: __dxlog_file28,
8422
+ L: 256,
8423
+ S: this,
8424
+ C: (f, a) => f(...a)
8425
+ });
8086
8426
  if (this._meshReplicator) {
8427
+ log23("adding mesh replicator...", void 0, {
8428
+ F: __dxlog_file28,
8429
+ L: 259,
8430
+ S: this,
8431
+ C: (f, a) => f(...a)
8432
+ });
8087
8433
  await this.echoHost.addReplicator(this._meshReplicator);
8434
+ log23("mesh replicator added", void 0, {
8435
+ F: __dxlog_file28,
8436
+ L: 261,
8437
+ S: this,
8438
+ C: (f, a) => f(...a)
8439
+ });
8088
8440
  }
8089
8441
  if (this._echoEdgeReplicator) {
8442
+ log23("adding edge replicator...", void 0, {
8443
+ F: __dxlog_file28,
8444
+ L: 264,
8445
+ S: this,
8446
+ C: (f, a) => f(...a)
8447
+ });
8090
8448
  await this.echoHost.addReplicator(this._echoEdgeReplicator);
8449
+ log23("edge replicator added", void 0, {
8450
+ F: __dxlog_file28,
8451
+ L: 266,
8452
+ S: this,
8453
+ C: (f, a) => f(...a)
8454
+ });
8091
8455
  }
8456
+ log23("loading metadata store...", void 0, {
8457
+ F: __dxlog_file28,
8458
+ L: 269,
8459
+ S: this,
8460
+ C: (f, a) => f(...a)
8461
+ });
8092
8462
  await this.metadataStore.load();
8463
+ log23("metadata store loaded", void 0, {
8464
+ F: __dxlog_file28,
8465
+ L: 271,
8466
+ S: this,
8467
+ C: (f, a) => f(...a)
8468
+ });
8469
+ log23("opening space manager...", void 0, {
8470
+ F: __dxlog_file28,
8471
+ L: 273,
8472
+ S: this,
8473
+ C: (f, a) => f(...a)
8474
+ });
8093
8475
  await this.spaceManager.open();
8476
+ log23("space manager opened", void 0, {
8477
+ F: __dxlog_file28,
8478
+ L: 275,
8479
+ S: this,
8480
+ C: (f, a) => f(...a)
8481
+ });
8094
8482
  if (this.identityManager.identity) {
8483
+ log23("joining network...", void 0, {
8484
+ F: __dxlog_file28,
8485
+ L: 278,
8486
+ S: this,
8487
+ C: (f, a) => f(...a)
8488
+ });
8095
8489
  await this.identityManager.identity.joinNetwork();
8490
+ log23("network joined", void 0, {
8491
+ F: __dxlog_file28,
8492
+ L: 280,
8493
+ S: this,
8494
+ C: (f, a) => f(...a)
8495
+ });
8496
+ log23("initializing spaces...(calling _initialize)", void 0, {
8497
+ F: __dxlog_file28,
8498
+ L: 282,
8499
+ S: this,
8500
+ C: (f, a) => f(...a)
8501
+ });
8096
8502
  await this._initialize(ctx);
8503
+ log23("spaces initialized", void 0, {
8504
+ F: __dxlog_file28,
8505
+ L: 284,
8506
+ S: this,
8507
+ C: (f, a) => f(...a)
8508
+ });
8509
+ } else {
8510
+ log23("no identity, skipping network join and space initialization", void 0, {
8511
+ F: __dxlog_file28,
8512
+ L: 286,
8513
+ S: this,
8514
+ C: (f, a) => f(...a)
8515
+ });
8097
8516
  }
8517
+ log23("opening feed syncer...", void 0, {
8518
+ F: __dxlog_file28,
8519
+ L: 289,
8520
+ S: this,
8521
+ C: (f, a) => f(...a)
8522
+ });
8523
+ await this._feedSyncer?.open();
8524
+ log23("feed syncer opened", void 0, {
8525
+ F: __dxlog_file28,
8526
+ L: 291,
8527
+ S: this,
8528
+ C: (f, a) => f(...a)
8529
+ });
8530
+ log23("loading persistent invitations...", void 0, {
8531
+ F: __dxlog_file28,
8532
+ L: 293,
8533
+ S: this,
8534
+ C: (f, a) => f(...a)
8535
+ });
8098
8536
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
8099
8537
  log23("loaded persistent invitations", {
8100
8538
  count: loadedInvitations.invitations?.length
8101
8539
  }, {
8102
- F: __dxlog_file27,
8103
- L: 244,
8540
+ F: __dxlog_file28,
8541
+ L: 295,
8104
8542
  S: this,
8105
8543
  C: (f, a) => f(...a)
8106
8544
  });
8107
8545
  log23.trace("dxos.sdk.service-context.open", trace9.end({
8108
8546
  id: this._instanceId
8109
8547
  }), {
8110
- F: __dxlog_file27,
8111
- L: 246,
8548
+ F: __dxlog_file28,
8549
+ L: 297,
8112
8550
  S: this,
8113
8551
  C: (f, a) => f(...a)
8114
8552
  });
8115
8553
  log23("opened", void 0, {
8116
- F: __dxlog_file27,
8117
- L: 247,
8554
+ F: __dxlog_file28,
8555
+ L: 298,
8118
8556
  S: this,
8119
8557
  C: (f, a) => f(...a)
8120
8558
  });
8121
8559
  }
8122
8560
  async _close(ctx) {
8123
8561
  log23("closing...", void 0, {
8124
- F: __dxlog_file27,
8125
- L: 251,
8562
+ F: __dxlog_file28,
8563
+ L: 302,
8126
8564
  S: this,
8127
8565
  C: (f, a) => f(...a)
8128
8566
  });
8567
+ await this._feedSyncer?.close();
8129
8568
  if (this._deviceSpaceSync && this.identityManager.identity) {
8130
8569
  await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
8131
8570
  }
@@ -8140,8 +8579,8 @@ var ServiceContext = class extends Resource8 {
8140
8579
  await this.feedStore.close();
8141
8580
  await this.metadataStore.close();
8142
8581
  log23("closed", void 0, {
8143
- F: __dxlog_file27,
8144
- L: 267,
8582
+ F: __dxlog_file28,
8583
+ L: 321,
8145
8584
  S: this,
8146
8585
  C: (f, a) => f(...a)
8147
8586
  });
@@ -8151,8 +8590,8 @@ var ServiceContext = class extends Resource8 {
8151
8590
  await this._setNetworkIdentity();
8152
8591
  await identity.joinNetwork();
8153
8592
  await this._initialize(new Context10(void 0, {
8154
- F: __dxlog_file27,
8155
- L: 274
8593
+ F: __dxlog_file28,
8594
+ L: 328
8156
8595
  }));
8157
8596
  return identity;
8158
8597
  }
@@ -8161,9 +8600,9 @@ var ServiceContext = class extends Resource8 {
8161
8600
  throw new Error("Identity must be created before joining a space.");
8162
8601
  }
8163
8602
  const factory = this._handlerFactories.get(invitation.kind);
8164
- invariant22(factory, `Unknown invitation kind: ${invitation.kind}`, {
8165
- F: __dxlog_file27,
8166
- L: 283,
8603
+ invariant23(factory, `Unknown invitation kind: ${invitation.kind}`, {
8604
+ F: __dxlog_file28,
8605
+ L: 337,
8167
8606
  S: this,
8168
8607
  A: [
8169
8608
  "factory",
@@ -8188,8 +8627,8 @@ var ServiceContext = class extends Resource8 {
8188
8627
  await identity.joinNetwork();
8189
8628
  await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
8190
8629
  await this._initialize(new Context10(void 0, {
8191
- F: __dxlog_file27,
8192
- L: 302
8630
+ F: __dxlog_file28,
8631
+ L: 356
8193
8632
  }));
8194
8633
  return identity;
8195
8634
  }
@@ -8201,9 +8640,9 @@ var ServiceContext = class extends Resource8 {
8201
8640
  }
8202
8641
  // Called when identity is created.
8203
8642
  async _initialize(ctx) {
8204
- log23("initializing spaces...", void 0, {
8205
- F: __dxlog_file27,
8206
- L: 317,
8643
+ log23("_initialize: start", void 0, {
8644
+ F: __dxlog_file28,
8645
+ L: 371,
8207
8646
  S: this,
8208
8647
  C: (f, a) => f(...a)
8209
8648
  });
@@ -8221,6 +8660,12 @@ var ServiceContext = class extends Resource8 {
8221
8660
  });
8222
8661
  }
8223
8662
  };
8663
+ log23("_initialize: creating DataSpaceManager", void 0, {
8664
+ F: __dxlog_file28,
8665
+ L: 383,
8666
+ S: this,
8667
+ C: (f, a) => f(...a)
8668
+ });
8224
8669
  this.dataSpaceManager = new DataSpaceManager({
8225
8670
  spaceManager: this.spaceManager,
8226
8671
  metadataStore: this.metadataStore,
@@ -8236,13 +8681,37 @@ var ServiceContext = class extends Resource8 {
8236
8681
  runtimeProps: this._runtimeProps,
8237
8682
  edgeFeatures: this._edgeFeatures
8238
8683
  });
8684
+ log23("_initialize: opening DataSpaceManager...", void 0, {
8685
+ F: __dxlog_file28,
8686
+ L: 399,
8687
+ S: this,
8688
+ C: (f, a) => f(...a)
8689
+ });
8239
8690
  await this.dataSpaceManager.open();
8691
+ log23("_initialize: DataSpaceManager opened", void 0, {
8692
+ F: __dxlog_file28,
8693
+ L: 401,
8694
+ S: this,
8695
+ C: (f, a) => f(...a)
8696
+ });
8240
8697
  this.edgeAgentManager = new EdgeAgentManager(this._edgeFeatures, this._edgeHttpClient, this.dataSpaceManager, identity);
8698
+ log23("_initialize: opening EdgeAgentManager...", void 0, {
8699
+ F: __dxlog_file28,
8700
+ L: 409,
8701
+ S: this,
8702
+ C: (f, a) => f(...a)
8703
+ });
8241
8704
  await this.edgeAgentManager.open();
8705
+ log23("_initialize: EdgeAgentManager opened", void 0, {
8706
+ F: __dxlog_file28,
8707
+ L: 411,
8708
+ S: this,
8709
+ C: (f, a) => f(...a)
8710
+ });
8242
8711
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
8243
- invariant22(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8244
- F: __dxlog_file27,
8245
- L: 355,
8712
+ invariant23(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
8713
+ F: __dxlog_file28,
8714
+ L: 414,
8246
8715
  S: this,
8247
8716
  A: [
8248
8717
  "this.dataSpaceManager",
@@ -8252,6 +8721,12 @@ var ServiceContext = class extends Resource8 {
8252
8721
  return new SpaceInvitationProtocol(this.dataSpaceManager, signingContext, this.keyring, invitation.spaceKey);
8253
8722
  });
8254
8723
  this.initialized.wake();
8724
+ log23("_initialize: initialized.wake() called", void 0, {
8725
+ F: __dxlog_file28,
8726
+ L: 418,
8727
+ S: this,
8728
+ C: (f, a) => f(...a)
8729
+ });
8255
8730
  this._deviceSpaceSync = {
8256
8731
  processCredential: async (credential) => {
8257
8732
  const assertion = getCredentialAssertion6(credential);
@@ -8265,8 +8740,8 @@ var ServiceContext = class extends Resource8 {
8265
8740
  log23("dataSpaceManager not initialized yet, ignoring space admission", {
8266
8741
  details: assertion
8267
8742
  }, {
8268
- F: __dxlog_file27,
8269
- L: 371,
8743
+ F: __dxlog_file28,
8744
+ L: 431,
8270
8745
  S: this,
8271
8746
  C: (f, a) => f(...a)
8272
8747
  });
@@ -8276,8 +8751,8 @@ var ServiceContext = class extends Resource8 {
8276
8751
  log23("space already exists, ignoring space admission", {
8277
8752
  details: assertion
8278
8753
  }, {
8279
- F: __dxlog_file27,
8280
- L: 375,
8754
+ F: __dxlog_file28,
8755
+ L: 435,
8281
8756
  S: this,
8282
8757
  C: (f, a) => f(...a)
8283
8758
  });
@@ -8287,8 +8762,8 @@ var ServiceContext = class extends Resource8 {
8287
8762
  log23("accepting space recorded in halo", {
8288
8763
  details: assertion
8289
8764
  }, {
8290
- F: __dxlog_file27,
8291
- L: 380,
8765
+ F: __dxlog_file28,
8766
+ L: 440,
8292
8767
  S: this,
8293
8768
  C: (f, a) => f(...a)
8294
8769
  });
@@ -8298,8 +8773,8 @@ var ServiceContext = class extends Resource8 {
8298
8773
  });
8299
8774
  } catch (err) {
8300
8775
  log23.catch(err, void 0, {
8301
- F: __dxlog_file27,
8302
- L: 386,
8776
+ F: __dxlog_file28,
8777
+ L: 446,
8303
8778
  S: this,
8304
8779
  C: (f, a) => f(...a)
8305
8780
  });
@@ -8315,40 +8790,102 @@ var ServiceContext = class extends Resource8 {
8315
8790
  hasError: false
8316
8791
  };
8317
8792
  try {
8793
+ log23("_setNetworkIdentity: acquiring mutex...", void 0, {
8794
+ F: __dxlog_file28,
8795
+ L: 455,
8796
+ S: this,
8797
+ C: (f, a) => f(...a)
8798
+ });
8318
8799
  const _ = _ts_add_disposable_resource4(env, await this._edgeIdentityUpdateMutex.acquire(), false);
8800
+ log23("_setNetworkIdentity: mutex acquired", void 0, {
8801
+ F: __dxlog_file28,
8802
+ L: 457,
8803
+ S: this,
8804
+ C: (f, a) => f(...a)
8805
+ });
8319
8806
  let edgeIdentity;
8320
8807
  const identity = this.identityManager.identity;
8321
8808
  if (identity) {
8322
- log23("setting identity on edge connection", {
8809
+ log23("_setNetworkIdentity: has identity", {
8323
8810
  identity: identity.identityKey.toHex(),
8324
- swarms: this.networkManager.topics
8811
+ hasDeviceCredential: !!params?.deviceCredential
8325
8812
  }, {
8326
- F: __dxlog_file27,
8327
- L: 400,
8813
+ F: __dxlog_file28,
8814
+ L: 462,
8328
8815
  S: this,
8329
8816
  C: (f, a) => f(...a)
8330
8817
  });
8331
8818
  if (params?.deviceCredential) {
8819
+ log23("_setNetworkIdentity: creating chain edge identity with device credential...", void 0, {
8820
+ F: __dxlog_file28,
8821
+ L: 468,
8822
+ S: this,
8823
+ C: (f, a) => f(...a)
8824
+ });
8332
8825
  edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, params?.deviceCredential && {
8333
8826
  credential: params.deviceCredential
8334
8827
  }, []);
8828
+ log23("_setNetworkIdentity: chain edge identity created", void 0, {
8829
+ F: __dxlog_file28,
8830
+ L: 476,
8831
+ S: this,
8832
+ C: (f, a) => f(...a)
8833
+ });
8335
8834
  } else {
8835
+ log23("_setNetworkIdentity: waiting for identity.ready()...", void 0, {
8836
+ F: __dxlog_file28,
8837
+ L: 478,
8838
+ S: this,
8839
+ C: (f, a) => f(...a)
8840
+ });
8336
8841
  await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
8337
8842
  await identity.ready();
8338
8843
  });
8339
- invariant22(identity.deviceCredentialChain, void 0, {
8340
- F: __dxlog_file27,
8341
- L: 419,
8844
+ log23("_setNetworkIdentity: identity.ready() resolved", {
8845
+ hasDeviceCredentialChain: !!identity.deviceCredentialChain
8846
+ }, {
8847
+ F: __dxlog_file28,
8848
+ L: 483,
8849
+ S: this,
8850
+ C: (f, a) => f(...a)
8851
+ });
8852
+ invariant23(identity.deviceCredentialChain, void 0, {
8853
+ F: __dxlog_file28,
8854
+ L: 487,
8342
8855
  S: this,
8343
8856
  A: [
8344
8857
  "identity.deviceCredentialChain",
8345
8858
  ""
8346
8859
  ]
8347
8860
  });
8861
+ log23("_setNetworkIdentity: creating chain edge identity...", void 0, {
8862
+ F: __dxlog_file28,
8863
+ L: 489,
8864
+ S: this,
8865
+ C: (f, a) => f(...a)
8866
+ });
8348
8867
  edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []);
8868
+ log23("_setNetworkIdentity: chain edge identity created", void 0, {
8869
+ F: __dxlog_file28,
8870
+ L: 497,
8871
+ S: this,
8872
+ C: (f, a) => f(...a)
8873
+ });
8349
8874
  }
8350
8875
  } else {
8876
+ log23("_setNetworkIdentity: no identity, creating ephemeral edge identity...", void 0, {
8877
+ F: __dxlog_file28,
8878
+ L: 500,
8879
+ S: this,
8880
+ C: (f, a) => f(...a)
8881
+ });
8351
8882
  edgeIdentity = await createEphemeralEdgeIdentity();
8883
+ log23("_setNetworkIdentity: ephemeral edge identity created", void 0, {
8884
+ F: __dxlog_file28,
8885
+ L: 502,
8886
+ S: this,
8887
+ C: (f, a) => f(...a)
8888
+ });
8352
8889
  }
8353
8890
  this._edgeConnection?.setIdentity(edgeIdentity);
8354
8891
  this._edgeHttpClient?.setIdentity(edgeIdentity);
@@ -8356,6 +8893,12 @@ var ServiceContext = class extends Resource8 {
8356
8893
  identityKey: edgeIdentity.identityKey,
8357
8894
  peerKey: edgeIdentity.peerKey
8358
8895
  });
8896
+ log23("_setNetworkIdentity: done", void 0, {
8897
+ F: __dxlog_file28,
8898
+ L: 511,
8899
+ S: this,
8900
+ C: (f, a) => f(...a)
8901
+ });
8359
8902
  } catch (e) {
8360
8903
  env.error = e;
8361
8904
  env.hasError = true;
@@ -8485,13 +9028,13 @@ var ServiceRegistry = class {
8485
9028
 
8486
9029
  // src/packlets/services/service-host.ts
8487
9030
  import * as SqlClient from "@effect/sql/SqlClient";
8488
- import * as Effect from "effect/Effect";
9031
+ import * as Effect2 from "effect/Effect";
8489
9032
  import { Event as Event11, synchronized as synchronized4 } from "@dxos/async";
8490
9033
  import { clientServiceBundle } from "@dxos/client-protocol";
8491
9034
  import { Context as Context11 } from "@dxos/context";
8492
9035
  import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
8493
- import { RuntimeProvider } from "@dxos/effect";
8494
- import { invariant as invariant24 } from "@dxos/invariant";
9036
+ import { RuntimeProvider as RuntimeProvider2 } from "@dxos/effect";
9037
+ import { invariant as invariant25 } from "@dxos/invariant";
8495
9038
  import { PublicKey as PublicKey19 } from "@dxos/keys";
8496
9039
  import { log as log25 } from "@dxos/log";
8497
9040
  import { EdgeSignalManager, WebsocketSignalManager } from "@dxos/messaging";
@@ -8505,9 +9048,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
8505
9048
  // src/packlets/devices/devices-service.ts
8506
9049
  import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
8507
9050
  import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
8508
- import { invariant as invariant23 } from "@dxos/invariant";
9051
+ import { invariant as invariant24 } from "@dxos/invariant";
8509
9052
  import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
8510
- var __dxlog_file28 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
9053
+ var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8511
9054
  var DevicesServiceImpl = class {
8512
9055
  _identityManager;
8513
9056
  _edgeConnection;
@@ -8527,8 +9070,8 @@ var DevicesServiceImpl = class {
8527
9070
  devices: []
8528
9071
  });
8529
9072
  } else {
8530
- invariant23(this._identityManager.identity?.presence, "presence not present", {
8531
- F: __dxlog_file28,
9073
+ invariant24(this._identityManager.identity?.presence, "presence not present", {
9074
+ F: __dxlog_file29,
8532
9075
  L: 37,
8533
9076
  S: this,
8534
9077
  A: [
@@ -8595,7 +9138,7 @@ var DevicesServiceImpl = class {
8595
9138
  };
8596
9139
 
8597
9140
  // src/packlets/identity/contacts-service.ts
8598
- import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateScheduler2, scheduleTask as scheduleTask9 } from "@dxos/async";
9141
+ import { SubscriptionList as SubscriptionList4, UpdateScheduler as UpdateScheduler2, scheduleTask as scheduleTask10 } from "@dxos/async";
8599
9142
  import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8600
9143
  import { PublicKey as PublicKey17 } from "@dxos/keys";
8601
9144
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
@@ -8657,7 +9200,7 @@ var ContactsServiceImpl = class {
8657
9200
  }, {
8658
9201
  maxFrequency: 2
8659
9202
  });
8660
- scheduleTask9(ctx, async () => {
9203
+ scheduleTask10(ctx, async () => {
8661
9204
  const subscriptions = new SubscriptionList4();
8662
9205
  ctx.onDispose(() => subscriptions.clear());
8663
9206
  const subscribeToSpaceAndUpdate = () => {
@@ -8936,7 +9479,7 @@ function _ts_decorate9(decorators, target, key, desc) {
8936
9479
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8937
9480
  return c > 3 && r && Object.defineProperty(target, key, r), r;
8938
9481
  }
8939
- var __dxlog_file29 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
9482
+ var __dxlog_file30 = "/__w/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
8940
9483
  var ClientServicesHost = class {
8941
9484
  _resourceLock;
8942
9485
  _serviceRegistry;
@@ -8990,7 +9533,7 @@ var ClientServicesHost = class {
8990
9533
  onAcquire: () => {
8991
9534
  if (!this._opening) {
8992
9535
  void this.open(new Context11(void 0, {
8993
- F: __dxlog_file29,
9536
+ F: __dxlog_file30,
8994
9537
  L: 147
8995
9538
  }));
8996
9539
  }
@@ -9045,7 +9588,7 @@ var ClientServicesHost = class {
9045
9588
  * Debugging util.
9046
9589
  */
9047
9590
  async exportSqliteDatabase() {
9048
- return await RuntimeProvider.runPromise(this._runtime)(Effect.gen(function* () {
9591
+ return await RuntimeProvider2.runPromise(this._runtime)(Effect2.gen(function* () {
9049
9592
  const sql = yield* SqlExport.SqlExport;
9050
9593
  return yield* sql.export;
9051
9594
  }));
@@ -9054,7 +9597,7 @@ var ClientServicesHost = class {
9054
9597
  * Debugging util.
9055
9598
  */
9056
9599
  async runSqliteQuery(query, params) {
9057
- return await RuntimeProvider.runPromise(this._runtime)(Effect.gen(function* () {
9600
+ return await RuntimeProvider2.runPromise(this._runtime)(Effect2.gen(function* () {
9058
9601
  const sql = yield* SqlClient.SqlClient;
9059
9602
  return yield* sql`${sql.unsafe(query, params)}`;
9060
9603
  }));
@@ -9065,8 +9608,8 @@ var ClientServicesHost = class {
9065
9608
  * Can only be called once.
9066
9609
  */
9067
9610
  initialize({ config, ...options }) {
9068
- invariant24(!this._open, "service host is open", {
9069
- F: __dxlog_file29,
9611
+ invariant25(!this._open, "service host is open", {
9612
+ F: __dxlog_file30,
9070
9613
  L: 237,
9071
9614
  S: this,
9072
9615
  A: [
@@ -9075,7 +9618,7 @@ var ClientServicesHost = class {
9075
9618
  ]
9076
9619
  });
9077
9620
  log25("initializing...", void 0, {
9078
- F: __dxlog_file29,
9621
+ F: __dxlog_file30,
9079
9622
  L: 238,
9080
9623
  S: this,
9081
9624
  C: (f, a) => f(...a)
@@ -9087,12 +9630,9 @@ var ClientServicesHost = class {
9087
9630
  if (this._runtimeProps.enableVectorIndexing === void 0) {
9088
9631
  this._runtimeProps.enableVectorIndexing = config?.get("runtime.client.enableVectorIndexing", false);
9089
9632
  }
9090
- if (this._runtimeProps.enableLocalQueues === void 0) {
9091
- this._runtimeProps.enableLocalQueues = config?.get("runtime.client.enableLocalQueues", false);
9092
- }
9093
- invariant24(!this._config, "config already set", {
9094
- F: __dxlog_file29,
9095
- L: 251,
9633
+ invariant25(!this._config, "config already set", {
9634
+ F: __dxlog_file30,
9635
+ L: 248,
9096
9636
  S: this,
9097
9637
  A: [
9098
9638
  "!this._config",
@@ -9119,9 +9659,9 @@ var ClientServicesHost = class {
9119
9659
  edgeConnection: this._edgeConnection
9120
9660
  }) : new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
9121
9661
  this._signalManager = signalManager;
9122
- invariant24(!this._networkManager, "network manager already set", {
9123
- F: __dxlog_file29,
9124
- L: 282,
9662
+ invariant25(!this._networkManager, "network manager already set", {
9663
+ F: __dxlog_file30,
9664
+ L: 279,
9125
9665
  S: this,
9126
9666
  A: [
9127
9667
  "!this._networkManager",
@@ -9138,8 +9678,8 @@ var ClientServicesHost = class {
9138
9678
  } : void 0
9139
9679
  });
9140
9680
  log25("initialized", void 0, {
9141
- F: __dxlog_file29,
9142
- L: 295,
9681
+ F: __dxlog_file30,
9682
+ L: 292,
9143
9683
  S: this,
9144
9684
  C: (f, a) => f(...a)
9145
9685
  });
@@ -9152,41 +9692,41 @@ var ClientServicesHost = class {
9152
9692
  log25.trace("dxos.client-services.host.open", trace10.begin({
9153
9693
  id: traceId
9154
9694
  }), {
9155
- F: __dxlog_file29,
9156
- L: 306,
9695
+ F: __dxlog_file30,
9696
+ L: 303,
9157
9697
  S: this,
9158
9698
  C: (f, a) => f(...a)
9159
9699
  });
9160
- invariant24(this._config, "config not set", {
9161
- F: __dxlog_file29,
9162
- L: 308,
9700
+ invariant25(this._config, "config not set", {
9701
+ F: __dxlog_file30,
9702
+ L: 305,
9163
9703
  S: this,
9164
9704
  A: [
9165
9705
  "this._config",
9166
9706
  "'config not set'"
9167
9707
  ]
9168
9708
  });
9169
- invariant24(this._storage, "storage not set", {
9170
- F: __dxlog_file29,
9171
- L: 309,
9709
+ invariant25(this._storage, "storage not set", {
9710
+ F: __dxlog_file30,
9711
+ L: 306,
9172
9712
  S: this,
9173
9713
  A: [
9174
9714
  "this._storage",
9175
9715
  "'storage not set'"
9176
9716
  ]
9177
9717
  });
9178
- invariant24(this._signalManager, "signal manager not set", {
9179
- F: __dxlog_file29,
9180
- L: 310,
9718
+ invariant25(this._signalManager, "signal manager not set", {
9719
+ F: __dxlog_file30,
9720
+ L: 307,
9181
9721
  S: this,
9182
9722
  A: [
9183
9723
  "this._signalManager",
9184
9724
  "'signal manager not set'"
9185
9725
  ]
9186
9726
  });
9187
- invariant24(this._networkManager, "network manager not set", {
9188
- F: __dxlog_file29,
9189
- L: 311,
9727
+ invariant25(this._networkManager, "network manager not set", {
9728
+ F: __dxlog_file30,
9729
+ L: 308,
9190
9730
  S: this,
9191
9731
  A: [
9192
9732
  "this._networkManager",
@@ -9197,8 +9737,8 @@ var ClientServicesHost = class {
9197
9737
  log25("opening...", {
9198
9738
  lockKey: this._resourceLock?.lockKey
9199
9739
  }, {
9200
- F: __dxlog_file29,
9201
- L: 314,
9740
+ F: __dxlog_file30,
9741
+ L: 311,
9202
9742
  S: this,
9203
9743
  C: (f, a) => f(...a)
9204
9744
  });
@@ -9239,8 +9779,32 @@ var ClientServicesHost = class {
9239
9779
  }),
9240
9780
  EdgeAgentService: new EdgeAgentServiceImpl(agentManagerProvider, this._edgeConnection)
9241
9781
  });
9782
+ log25("service-host: opening service context...", void 0, {
9783
+ F: __dxlog_file30,
9784
+ L: 395,
9785
+ S: this,
9786
+ C: (f, a) => f(...a)
9787
+ });
9242
9788
  await this._serviceContext.open(ctx);
9789
+ log25("service-host: service context opened", void 0, {
9790
+ F: __dxlog_file30,
9791
+ L: 397,
9792
+ S: this,
9793
+ C: (f, a) => f(...a)
9794
+ });
9795
+ log25("service-host: opening identity service...", void 0, {
9796
+ F: __dxlog_file30,
9797
+ L: 399,
9798
+ S: this,
9799
+ C: (f, a) => f(...a)
9800
+ });
9243
9801
  await identityService.open();
9802
+ log25("service-host: identity service opened", void 0, {
9803
+ F: __dxlog_file30,
9804
+ L: 401,
9805
+ S: this,
9806
+ C: (f, a) => f(...a)
9807
+ });
9244
9808
  const devtoolsProxy = this._config?.get("runtime.client.devtoolsProxy");
9245
9809
  if (devtoolsProxy) {
9246
9810
  this._devtoolsProxy = new WebsocketRpcClient({
@@ -9259,16 +9823,16 @@ var ClientServicesHost = class {
9259
9823
  log25("opened", {
9260
9824
  deviceKey
9261
9825
  }, {
9262
- F: __dxlog_file29,
9263
- L: 417,
9826
+ F: __dxlog_file30,
9827
+ L: 419,
9264
9828
  S: this,
9265
9829
  C: (f, a) => f(...a)
9266
9830
  });
9267
9831
  log25.trace("dxos.client-services.host.open", trace10.end({
9268
9832
  id: traceId
9269
9833
  }), {
9270
- F: __dxlog_file29,
9271
- L: 418,
9834
+ F: __dxlog_file30,
9835
+ L: 420,
9272
9836
  S: this,
9273
9837
  C: (f, a) => f(...a)
9274
9838
  });
@@ -9281,8 +9845,8 @@ var ClientServicesHost = class {
9281
9845
  log25("closing...", {
9282
9846
  deviceKey
9283
9847
  }, {
9284
- F: __dxlog_file29,
9285
- L: 429,
9848
+ F: __dxlog_file30,
9849
+ L: 431,
9286
9850
  S: this,
9287
9851
  C: (f, a) => f(...a)
9288
9852
  });
@@ -9299,8 +9863,8 @@ var ClientServicesHost = class {
9299
9863
  log25("closed", {
9300
9864
  deviceKey
9301
9865
  }, {
9302
- F: __dxlog_file29,
9303
- L: 438,
9866
+ F: __dxlog_file30,
9867
+ L: 440,
9304
9868
  S: this,
9305
9869
  C: (f, a) => f(...a)
9306
9870
  });
@@ -9310,14 +9874,14 @@ var ClientServicesHost = class {
9310
9874
  log25.trace("dxos.sdk.client-services-host.reset", trace10.begin({
9311
9875
  id: traceId
9312
9876
  }), {
9313
- F: __dxlog_file29,
9314
- L: 443,
9877
+ F: __dxlog_file30,
9878
+ L: 445,
9315
9879
  S: this,
9316
9880
  C: (f, a) => f(...a)
9317
9881
  });
9318
9882
  log25.info("resetting...", void 0, {
9319
- F: __dxlog_file29,
9320
- L: 445,
9883
+ F: __dxlog_file30,
9884
+ L: 447,
9321
9885
  S: this,
9322
9886
  C: (f, a) => f(...a)
9323
9887
  });
@@ -9330,24 +9894,24 @@ var ClientServicesHost = class {
9330
9894
  log25.warn("failed to clear leveldb during reset", {
9331
9895
  err
9332
9896
  }, {
9333
- F: __dxlog_file29,
9334
- L: 455,
9897
+ F: __dxlog_file30,
9898
+ L: 457,
9335
9899
  S: this,
9336
9900
  C: (f, a) => f(...a)
9337
9901
  });
9338
9902
  }
9339
9903
  await this._storage.reset();
9340
9904
  log25.info("reset", void 0, {
9341
- F: __dxlog_file29,
9342
- L: 458,
9905
+ F: __dxlog_file30,
9906
+ L: 460,
9343
9907
  S: this,
9344
9908
  C: (f, a) => f(...a)
9345
9909
  });
9346
9910
  log25.trace("dxos.sdk.client-services-host.reset", trace10.end({
9347
9911
  id: traceId
9348
9912
  }), {
9349
- F: __dxlog_file29,
9350
- L: 459,
9913
+ F: __dxlog_file30,
9914
+ L: 461,
9351
9915
  S: this,
9352
9916
  C: (f, a) => f(...a)
9353
9917
  });
@@ -9418,4 +9982,4 @@ export {
9418
9982
  ServiceRegistry,
9419
9983
  ClientServicesHost
9420
9984
  };
9421
- //# sourceMappingURL=chunk-J33W6T4Q.mjs.map
9985
+ //# sourceMappingURL=chunk-SVH323CC.mjs.map