@dxos/client-services 0.1.56-main.bf228a7 → 0.1.56-main.c19b7cd

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 (69) hide show
  1. package/dist/lib/browser/{chunk-FD4L7N4K.mjs → chunk-ZOTHWLK5.mjs} +623 -335
  2. package/dist/lib/browser/chunk-ZOTHWLK5.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +23 -19
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/packlets/testing/index.mjs +2 -2
  7. package/dist/lib/browser/packlets/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/index.cjs +752 -461
  9. package/dist/lib/node/index.cjs.map +4 -4
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/packlets/testing/index.cjs +1016 -729
  12. package/dist/lib/node/packlets/testing/index.cjs.map +4 -4
  13. package/dist/types/src/packlets/identity/identity-manager.d.ts +2 -1
  14. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  15. package/dist/types/src/packlets/identity/identity.d.ts +3 -2
  16. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  17. package/dist/types/src/packlets/logging/logging-service.d.ts +6 -2
  18. package/dist/types/src/packlets/logging/logging-service.d.ts.map +1 -1
  19. package/dist/types/src/packlets/services/client-rpc-server.d.ts.map +1 -1
  20. package/dist/types/src/packlets/services/diagnostics.d.ts +46 -0
  21. package/dist/types/src/packlets/services/diagnostics.d.ts.map +1 -0
  22. package/dist/types/src/packlets/services/index.d.ts +1 -0
  23. package/dist/types/src/packlets/services/index.d.ts.map +1 -1
  24. package/dist/types/src/packlets/services/platform.d.ts +16 -0
  25. package/dist/types/src/packlets/services/platform.d.ts.map +1 -0
  26. package/dist/types/src/packlets/services/service-context.d.ts +2 -1
  27. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  28. package/dist/types/src/packlets/services/service-host.d.ts +7 -3
  29. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  30. package/dist/types/src/packlets/services/util.d.ts +6 -0
  31. package/dist/types/src/packlets/services/util.d.ts.map +1 -0
  32. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  33. package/dist/types/src/packlets/system/system-service.d.ts +12 -2
  34. package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
  35. package/dist/types/src/packlets/vault/iframe-host-runtime.d.ts.map +1 -1
  36. package/dist/types/src/packlets/vault/worker-runtime.d.ts.map +1 -1
  37. package/dist/types/src/packlets/vault/worker-session.d.ts.map +1 -1
  38. package/dist/types/src/version.d.ts +2 -0
  39. package/dist/types/src/version.d.ts.map +1 -0
  40. package/package.json +34 -33
  41. package/src/packlets/devices/devices-service.test.ts +2 -1
  42. package/src/packlets/identity/identity-manager.test.ts +4 -3
  43. package/src/packlets/identity/identity-manager.ts +9 -5
  44. package/src/packlets/identity/identity-service.test.ts +2 -1
  45. package/src/packlets/identity/identity.test.ts +7 -6
  46. package/src/packlets/identity/identity.ts +8 -3
  47. package/src/packlets/invitations/device-invitation-protocol.test.ts +2 -1
  48. package/src/packlets/logging/logging-service.ts +17 -9
  49. package/src/packlets/network/network-service.test.ts +2 -1
  50. package/src/packlets/services/client-rpc-server.ts +4 -4
  51. package/src/packlets/services/diagnostics.ts +211 -0
  52. package/src/packlets/services/index.ts +1 -0
  53. package/src/packlets/services/platform.ts +48 -0
  54. package/src/packlets/services/service-context.test.ts +59 -0
  55. package/src/packlets/services/service-context.ts +13 -9
  56. package/src/packlets/services/service-host.test.ts +11 -10
  57. package/src/packlets/services/service-host.ts +37 -21
  58. package/src/packlets/services/service-registry.test.ts +3 -1
  59. package/src/packlets/services/util.ts +33 -0
  60. package/src/packlets/spaces/data-space.ts +17 -5
  61. package/src/packlets/spaces/spaces-service.test.ts +2 -1
  62. package/src/packlets/system/system-service.test.ts +1 -0
  63. package/src/packlets/system/system-service.ts +34 -2
  64. package/src/packlets/testing/test-builder.ts +1 -1
  65. package/src/packlets/vault/iframe-host-runtime.ts +2 -1
  66. package/src/packlets/vault/worker-runtime.ts +2 -1
  67. package/src/packlets/vault/worker-session.ts +6 -1
  68. package/src/version.ts +1 -0
  69. package/dist/lib/browser/chunk-FD4L7N4K.mjs.map +0 -7
@@ -52,36 +52,204 @@ var createMockCredential = async ({ signer, issuer }) => (0, import_credentials.
52
52
 
53
53
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
54
54
  var import_async18 = require("@dxos/async");
55
- var import_invariant14 = require("@dxos/invariant");
56
- var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
55
+ var import_invariant15 = require("@dxos/invariant");
56
+ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
57
57
 
58
58
  // packages/sdk/client-services/src/packlets/services/client-rpc-server.ts
59
59
  var import_codec_protobuf = require("@dxos/codec-protobuf");
60
60
  var import_debug = require("@dxos/debug");
61
61
  var import_rpc = require("@dxos/rpc");
62
62
 
63
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
64
+ var import_codec_protobuf2 = require("@dxos/codec-protobuf");
65
+ var import_credentials2 = require("@dxos/credentials");
66
+ var import_document_model = require("@dxos/document-model");
67
+ var import_invariant = require("@dxos/invariant");
68
+ var import_log = require("@dxos/log");
69
+ var import_protocols = require("@dxos/protocols");
70
+ var import_services = require("@dxos/protocols/proto/dxos/client/services");
71
+
72
+ // packages/sdk/client-services/src/version.ts
73
+ var DXOS_VERSION = "0.1.56-main.c19b7cd";
74
+
75
+ // packages/sdk/client-services/src/packlets/services/platform.ts
76
+ var getPlatform = () => {
77
+ if (process.browser) {
78
+ if (typeof window !== "undefined") {
79
+ const { userAgent } = window.navigator;
80
+ return {
81
+ type: "browser",
82
+ userAgent,
83
+ uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
84
+ };
85
+ } else {
86
+ return {
87
+ type: "shared-worker",
88
+ uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
89
+ };
90
+ }
91
+ } else {
92
+ const { platform, version, arch } = process;
93
+ return {
94
+ type: "node",
95
+ platform: `${platform} ${version} ${arch}`,
96
+ runtime: process.version,
97
+ uptime: Math.floor(process.uptime()),
98
+ memory: process.memoryUsage()
99
+ };
100
+ }
101
+ };
102
+
103
+ // packages/sdk/client-services/src/packlets/services/diagnostics.ts
104
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
105
+ var DEFAULT_TIMEOUT = 1e3;
106
+ var createDiagnostics = async (clientServices, serviceContext, config) => {
107
+ var _a, _b, _c;
108
+ const diagnostics = {
109
+ created: new Date().toISOString(),
110
+ platform: getPlatform(),
111
+ client: {
112
+ version: DXOS_VERSION,
113
+ storage: {
114
+ version: import_protocols.STORAGE_VERSION
115
+ }
116
+ }
117
+ };
118
+ {
119
+ (0, import_invariant.invariant)(clientServices.LoggingService, "SystemService is not available.", {
120
+ F: __dxlog_file,
121
+ L: 87,
122
+ S: void 0,
123
+ A: [
124
+ "clientServices.LoggingService",
125
+ "'SystemService is not available.'"
126
+ ]
127
+ });
128
+ diagnostics.metrics = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
129
+ timeout: DEFAULT_TIMEOUT
130
+ }).catch(() => void 0);
131
+ }
132
+ const identity = serviceContext.identityManager.identity;
133
+ if (identity) {
134
+ diagnostics.identity = {
135
+ identityKey: identity.identityKey,
136
+ spaceKey: identity.space.key,
137
+ profile: identity.profileDocument
138
+ };
139
+ const { devices } = (_a = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
140
+ timeout: DEFAULT_TIMEOUT
141
+ }).catch(() => void 0)) != null ? _a : {};
142
+ diagnostics.devices = devices;
143
+ if (serviceContext.dataSpaceManager) {
144
+ diagnostics.spaces = await Promise.all((_b = Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space))) != null ? _b : []);
145
+ }
146
+ const { feeds = [] } = (_c = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
147
+ timeout: DEFAULT_TIMEOUT
148
+ }).catch(() => void 0)) != null ? _c : {};
149
+ diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
150
+ feedKey,
151
+ bytes,
152
+ length
153
+ }));
154
+ }
155
+ diagnostics.config = config.values;
156
+ return diagnostics;
157
+ };
158
+ var getProperties = (space) => {
159
+ let properties = {};
160
+ try {
161
+ const propertiesItem = space.dataPipeline.itemManager.items.find((item) => {
162
+ var _a, _b;
163
+ return ((_a = item.modelMeta) == null ? void 0 : _a.type) === import_document_model.DocumentModel.meta.type && ((_b = item.state) == null ? void 0 : _b.type) === "dxos.sdk.client.Properties";
164
+ });
165
+ const state = propertiesItem == null ? void 0 : propertiesItem.state;
166
+ properties = state == null ? void 0 : state.data;
167
+ } catch (err) {
168
+ import_log.log.warn(err.message, void 0, {
169
+ F: __dxlog_file,
170
+ L: 144,
171
+ S: void 0,
172
+ C: (f, a) => f(...a)
173
+ });
174
+ }
175
+ return properties;
176
+ };
177
+ var getSpaceStats = async (space) => {
178
+ var _a, _b, _c, _d, _e, _f;
179
+ const stats = {
180
+ key: space.key,
181
+ metrics: space.metrics,
182
+ epochs: space.inner.spaceState.credentials.filter((0, import_credentials2.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
183
+ ...credential.subject.assertion,
184
+ id: credential.id
185
+ })),
186
+ members: Array.from(space.inner.spaceState.members.values()).map((member) => {
187
+ var _a2;
188
+ return {
189
+ identity: {
190
+ identityKey: member.key,
191
+ profile: {
192
+ displayName: (_a2 = member.assertion.profile) == null ? void 0 : _a2.displayName
193
+ }
194
+ },
195
+ presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services.SpaceMember.PresenceState.ONLINE : import_services.SpaceMember.PresenceState.OFFLINE
196
+ };
197
+ }),
198
+ pipeline: {
199
+ // TODO(burdon): Pick properties from credentials if needed.
200
+ // currentEpoch: space.dataPipeline.currentEpoch,
201
+ // appliedEpoch: space.dataPipeline.appliedEpoch,
202
+ controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
203
+ currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
204
+ targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
205
+ totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe,
206
+ // TODO(burdon): Empty?
207
+ dataFeeds: (_b = (_a = space.dataPipeline.pipelineState) == null ? void 0 : _a.feeds.map((feed) => feed.key)) != null ? _b : [],
208
+ startDataTimeframe: (_c = space.dataPipeline.pipelineState) == null ? void 0 : _c.startTimeframe,
209
+ currentDataTimeframe: (_d = space.dataPipeline.pipelineState) == null ? void 0 : _d.timeframe,
210
+ targetDataTimeframe: (_e = space.dataPipeline.pipelineState) == null ? void 0 : _e.targetTimeframe,
211
+ totalDataTimeframe: (_f = space.dataPipeline.pipelineState) == null ? void 0 : _f.endTimeframe
212
+ }
213
+ };
214
+ if (space.dataPipeline.itemManager) {
215
+ Object.assign(stats, {
216
+ properties: getProperties(space),
217
+ db: {
218
+ objects: space.dataPipeline.itemManager.entities.size
219
+ }
220
+ });
221
+ }
222
+ if (stats.metrics) {
223
+ const { open, ready } = stats.metrics;
224
+ stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
225
+ }
226
+ return stats;
227
+ };
228
+
63
229
  // packages/sdk/client-services/src/packlets/services/service-context.ts
64
230
  var import_async11 = require("@dxos/async");
65
- var import_credentials14 = require("@dxos/credentials");
231
+ var import_context8 = require("@dxos/context");
232
+ var import_credentials15 = require("@dxos/credentials");
66
233
  var import_debug7 = require("@dxos/debug");
67
234
  var import_echo_pipeline3 = require("@dxos/echo-pipeline");
68
235
  var import_feed_store3 = require("@dxos/feed-store");
69
- var import_invariant11 = require("@dxos/invariant");
236
+ var import_invariant12 = require("@dxos/invariant");
70
237
  var import_keyring = require("@dxos/keyring");
71
238
  var import_keys8 = require("@dxos/keys");
72
- var import_log12 = require("@dxos/log");
73
- var import_protocols8 = require("@dxos/protocols");
74
- var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
239
+ var import_log13 = require("@dxos/log");
240
+ var import_protocols9 = require("@dxos/protocols");
241
+ var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
75
242
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
243
+ var import_tracing3 = require("@dxos/tracing");
76
244
 
77
245
  // packages/sdk/client-services/src/packlets/identity/authenticator.ts
78
246
  var import_async = require("@dxos/async");
79
247
  var import_context = require("@dxos/context");
80
- var import_credentials2 = require("@dxos/credentials");
81
- var import_log = require("@dxos/log");
82
- var import_protocols = require("@dxos/protocols");
83
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
84
- var Credential = import_protocols.schema.getCodecForType("dxos.halo.credentials.Credential");
248
+ var import_credentials3 = require("@dxos/credentials");
249
+ var import_log2 = require("@dxos/log");
250
+ var import_protocols2 = require("@dxos/protocols");
251
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/authenticator.ts";
252
+ var Credential = import_protocols2.schema.getCodecForType("dxos.halo.credentials.Credential");
85
253
  var createAuthProvider = (signer) => async (nonce) => {
86
254
  const credential = await signer.createCredential({
87
255
  assertion: {
@@ -104,20 +272,20 @@ var TrustedKeySetAuthVerifier = class {
104
272
  get verifier() {
105
273
  return async (nonce, auth) => {
106
274
  const credential = Credential.decode(auth);
107
- (0, import_log.log)("authenticating...", {
275
+ (0, import_log2.log)("authenticating...", {
108
276
  credential
109
277
  }, {
110
- F: __dxlog_file,
278
+ F: __dxlog_file2,
111
279
  L: 59,
112
280
  S: this,
113
281
  C: (f, a) => f(...a)
114
282
  });
115
- const result = await (0, import_credentials2.verifyCredential)(credential);
283
+ const result = await (0, import_credentials3.verifyCredential)(credential);
116
284
  if (result.kind === "fail") {
117
- (0, import_log.log)("Invalid credential", {
285
+ (0, import_log2.log)("Invalid credential", {
118
286
  result
119
287
  }, {
120
- F: __dxlog_file,
288
+ F: __dxlog_file2,
121
289
  L: 63,
122
290
  S: this,
123
291
  C: (f, a) => f(...a)
@@ -125,11 +293,11 @@ var TrustedKeySetAuthVerifier = class {
125
293
  return false;
126
294
  }
127
295
  if (!credential.proof.nonce || !Buffer.from(nonce).equals(credential.proof.nonce)) {
128
- (0, import_log.log)("Invalid nonce", {
296
+ (0, import_log2.log)("Invalid nonce", {
129
297
  nonce,
130
298
  credential
131
299
  }, {
132
- F: __dxlog_file,
300
+ F: __dxlog_file2,
133
301
  L: 68,
134
302
  S: this,
135
303
  C: (f, a) => f(...a)
@@ -137,10 +305,10 @@ var TrustedKeySetAuthVerifier = class {
137
305
  return false;
138
306
  }
139
307
  if (this._isTrustedKey(credential.issuer)) {
140
- (0, import_log.log)("key is not currently in trusted set, waiting...", {
308
+ (0, import_log2.log)("key is not currently in trusted set, waiting...", {
141
309
  key: credential.issuer
142
310
  }, {
143
- F: __dxlog_file,
311
+ F: __dxlog_file2,
144
312
  L: 73,
145
313
  S: this,
146
314
  C: (f, a) => f(...a)
@@ -153,20 +321,20 @@ var TrustedKeySetAuthVerifier = class {
153
321
  });
154
322
  const clear = this._params.update.on(this._ctx, () => {
155
323
  if (this._isTrustedKey(credential.issuer)) {
156
- (0, import_log.log)("auth success", {
324
+ (0, import_log2.log)("auth success", {
157
325
  key: credential.issuer
158
326
  }, {
159
- F: __dxlog_file,
327
+ F: __dxlog_file2,
160
328
  L: 84,
161
329
  S: this,
162
330
  C: (f, a) => f(...a)
163
331
  });
164
332
  trigger.wake(true);
165
333
  } else {
166
- (0, import_log.log)("key is not currently in trusted set, waiting...", {
334
+ (0, import_log2.log)("key is not currently in trusted set, waiting...", {
167
335
  key: credential.issuer
168
336
  }, {
169
- F: __dxlog_file,
337
+ F: __dxlog_file2,
170
338
  L: 87,
171
339
  S: this,
172
340
  C: (f, a) => f(...a)
@@ -193,26 +361,37 @@ var TrustedKeySetAuthVerifier = class {
193
361
  // packages/sdk/client-services/src/packlets/identity/identity.ts
194
362
  var import_async2 = require("@dxos/async");
195
363
  var import_client_protocol = require("@dxos/client-protocol");
196
- var import_credentials3 = require("@dxos/credentials");
364
+ var import_credentials4 = require("@dxos/credentials");
197
365
  var import_debug2 = require("@dxos/debug");
198
366
  var import_feed_store = require("@dxos/feed-store");
199
- var import_invariant = require("@dxos/invariant");
200
- var import_log2 = require("@dxos/log");
201
- var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
202
- var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
203
- var Identity = class {
367
+ var import_invariant2 = require("@dxos/invariant");
368
+ var import_log3 = require("@dxos/log");
369
+ var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
370
+ var import_tracing = require("@dxos/tracing");
371
+ function _ts_decorate(decorators, target, key, desc) {
372
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
373
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
374
+ r = Reflect.decorate(decorators, target, key, desc);
375
+ else
376
+ for (var i = decorators.length - 1; i >= 0; i--)
377
+ if (d = decorators[i])
378
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
379
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
380
+ }
381
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity.ts";
382
+ var Identity = class Identity2 {
204
383
  constructor({ space, signer, identityKey, deviceKey }) {
205
384
  this.stateUpdate = new import_async2.Event();
206
385
  this.space = space;
207
386
  this._signer = signer;
208
387
  this.identityKey = identityKey;
209
388
  this.deviceKey = deviceKey;
210
- this._deviceStateMachine = new import_credentials3.DeviceStateMachine({
389
+ this._deviceStateMachine = new import_credentials4.DeviceStateMachine({
211
390
  identityKey: this.identityKey,
212
391
  deviceKey: this.deviceKey,
213
392
  onUpdate: () => this.stateUpdate.emit()
214
393
  });
215
- this._profileStateMachine = new import_credentials3.ProfileStateMachine({
394
+ this._profileStateMachine = new import_credentials4.ProfileStateMachine({
216
395
  identityKey: this.identityKey,
217
396
  onUpdate: () => this.stateUpdate.emit()
218
397
  });
@@ -226,12 +405,12 @@ var Identity = class {
226
405
  get authorizedDeviceKeys() {
227
406
  return this._deviceStateMachine.authorizedDeviceKeys;
228
407
  }
229
- async open() {
408
+ async open(ctx) {
230
409
  await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
231
410
  await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
232
- await this.space.open();
411
+ await this.space.open(ctx);
233
412
  }
234
- async close() {
413
+ async close(ctx) {
235
414
  await this.authVerifier.close();
236
415
  await this.space.spaceState.removeCredentialProcessor(this._profileStateMachine);
237
416
  await this.space.spaceState.removeCredentialProcessor(this._deviceStateMachine);
@@ -274,33 +453,33 @@ var Identity = class {
274
453
  * Requires identity to be ready.
275
454
  */
276
455
  getIdentityCredentialSigner() {
277
- (0, import_invariant.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
278
- F: __dxlog_file2,
279
- L: 134,
456
+ (0, import_invariant2.invariant)(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
457
+ F: __dxlog_file3,
458
+ L: 139,
280
459
  S: this,
281
460
  A: [
282
461
  "this._deviceStateMachine.deviceCredentialChain",
283
462
  "'Device credential chain is not ready.'"
284
463
  ]
285
464
  });
286
- return (0, import_credentials3.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
465
+ return (0, import_credentials4.createCredentialSignerWithChain)(this._signer, this._deviceStateMachine.deviceCredentialChain, this.deviceKey);
287
466
  }
288
467
  /**
289
468
  * Issues credentials as device.
290
469
  */
291
470
  getDeviceCredentialSigner() {
292
- return (0, import_credentials3.createCredentialSignerWithKey)(this._signer, this.deviceKey);
471
+ return (0, import_credentials4.createCredentialSignerWithKey)(this._signer, this.deviceKey);
293
472
  }
294
473
  async admitDevice({ deviceKey, controlFeedKey, dataFeedKey }) {
295
- (0, import_log2.log)("Admitting device:", {
474
+ (0, import_log3.log)("Admitting device:", {
296
475
  identityKey: this.identityKey,
297
476
  hostDevice: this.deviceKey,
298
477
  deviceKey,
299
478
  controlFeedKey,
300
479
  dataFeedKey
301
480
  }, {
302
- F: __dxlog_file2,
303
- L: 150,
481
+ F: __dxlog_file3,
482
+ L: 155,
304
483
  S: this,
305
484
  C: (f, a) => f(...a)
306
485
  });
@@ -321,7 +500,7 @@ var Identity = class {
321
500
  spaceKey: this.haloSpaceKey,
322
501
  deviceKey,
323
502
  identityKey: this.identityKey,
324
- designation: import_credentials4.AdmittedFeed.Designation.CONTROL
503
+ designation: import_credentials5.AdmittedFeed.Designation.CONTROL
325
504
  }
326
505
  }),
327
506
  await signer.createCredential({
@@ -331,7 +510,7 @@ var Identity = class {
331
510
  spaceKey: this.haloSpaceKey,
332
511
  deviceKey,
333
512
  identityKey: this.identityKey,
334
- designation: import_credentials4.AdmittedFeed.Designation.DATA
513
+ designation: import_credentials5.AdmittedFeed.Designation.DATA
335
514
  }
336
515
  })
337
516
  ].map((credential) => ({
@@ -341,18 +520,39 @@ var Identity = class {
341
520
  })));
342
521
  }
343
522
  };
523
+ _ts_decorate([
524
+ import_tracing.trace.span()
525
+ ], Identity.prototype, "open", null);
526
+ _ts_decorate([
527
+ import_tracing.trace.span()
528
+ ], Identity.prototype, "close", null);
529
+ Identity = _ts_decorate([
530
+ import_tracing.trace.resource()
531
+ ], Identity);
344
532
 
345
533
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
346
534
  var import_async3 = require("@dxos/async");
347
- var import_credentials5 = require("@dxos/credentials");
348
- var import_invariant2 = require("@dxos/invariant");
535
+ var import_context2 = require("@dxos/context");
536
+ var import_credentials6 = require("@dxos/credentials");
537
+ var import_invariant3 = require("@dxos/invariant");
349
538
  var import_keys2 = require("@dxos/keys");
350
- var import_log3 = require("@dxos/log");
351
- var import_protocols2 = require("@dxos/protocols");
352
- var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials");
539
+ var import_log4 = require("@dxos/log");
540
+ var import_protocols3 = require("@dxos/protocols");
541
+ var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
542
+ var import_tracing2 = require("@dxos/tracing");
353
543
  var import_util = require("@dxos/util");
354
- var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
355
- var IdentityManager = class {
544
+ function _ts_decorate2(decorators, target, key, desc) {
545
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
546
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
547
+ r = Reflect.decorate(decorators, target, key, desc);
548
+ else
549
+ for (var i = decorators.length - 1; i >= 0; i--)
550
+ if (d = decorators[i])
551
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
552
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
553
+ }
554
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-manager.ts";
555
+ var IdentityManager = class IdentityManager2 {
356
556
  // TODO(burdon): IdentityManagerParams.
357
557
  // TODO(dmaretskyi): Perhaps this should take/generate the peerKey outside of an initialized identity.
358
558
  constructor(_metadataStore, _keyring, _feedStore, _spaceManager) {
@@ -365,69 +565,69 @@ var IdentityManager = class {
365
565
  get identity() {
366
566
  return this._identity;
367
567
  }
368
- async open() {
568
+ async open(ctx) {
369
569
  var _a;
370
570
  const traceId = import_keys2.PublicKey.random().toHex();
371
- import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.begin({
571
+ import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.begin({
372
572
  id: traceId
373
573
  }), {
374
- F: __dxlog_file3,
375
- L: 69,
574
+ F: __dxlog_file4,
575
+ L: 73,
376
576
  S: this,
377
577
  C: (f, a) => f(...a)
378
578
  });
379
579
  await this._metadataStore.load();
380
580
  const identityRecord = this._metadataStore.getIdentityRecord();
381
- (0, import_log3.log)("identity record", {
581
+ (0, import_log4.log)("identity record", {
382
582
  identityRecord
383
583
  }, {
384
- F: __dxlog_file3,
385
- L: 73,
584
+ F: __dxlog_file4,
585
+ L: 77,
386
586
  S: this,
387
587
  C: (f, a) => f(...a)
388
588
  });
389
589
  if (identityRecord) {
390
590
  this._identity = await this._constructIdentity(identityRecord);
391
- await this._identity.open();
591
+ await this._identity.open(ctx);
392
592
  await this._identity.ready();
393
- import_log3.log.trace("dxos.halo.identity", {
593
+ import_log4.log.trace("dxos.halo.identity", {
394
594
  identityKey: identityRecord.identityKey,
395
595
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
396
596
  }, {
397
- F: __dxlog_file3,
398
- L: 78,
597
+ F: __dxlog_file4,
598
+ L: 82,
399
599
  S: this,
400
600
  C: (f, a) => f(...a)
401
601
  });
402
602
  this.stateUpdate.emit();
403
603
  }
404
- import_log3.log.trace("dxos.halo.identity-manager.open", import_protocols2.trace.end({
604
+ import_log4.log.trace("dxos.halo.identity-manager.open", import_protocols3.trace.end({
405
605
  id: traceId
406
606
  }), {
407
- F: __dxlog_file3,
408
- L: 84,
607
+ F: __dxlog_file4,
608
+ L: 88,
409
609
  S: this,
410
610
  C: (f, a) => f(...a)
411
611
  });
412
612
  }
413
613
  async close() {
414
614
  var _a;
415
- await ((_a = this._identity) == null ? void 0 : _a.close());
615
+ await ((_a = this._identity) == null ? void 0 : _a.close(new import_context2.Context()));
416
616
  }
417
617
  async createIdentity({ displayName } = {}) {
418
618
  var _a;
419
- (0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
420
- F: __dxlog_file3,
421
- L: 92,
619
+ (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
620
+ F: __dxlog_file4,
621
+ L: 96,
422
622
  S: this,
423
623
  A: [
424
624
  "!this._identity",
425
625
  "'Identity already exists.'"
426
626
  ]
427
627
  });
428
- (0, import_log3.log)("creating identity...", void 0, {
429
- F: __dxlog_file3,
430
- L: 93,
628
+ (0, import_log4.log)("creating identity...", void 0, {
629
+ F: __dxlog_file4,
630
+ L: 97,
431
631
  S: this,
432
632
  C: (f, a) => f(...a)
433
633
  });
@@ -443,21 +643,21 @@ var IdentityManager = class {
443
643
  }
444
644
  };
445
645
  const identity = await this._constructIdentity(identityRecord);
446
- await identity.open();
646
+ await identity.open(new import_context2.Context());
447
647
  {
448
- const generator = new import_credentials5.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
449
- (0, import_invariant2.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
450
- F: __dxlog_file3,
451
- L: 112,
648
+ const generator = new import_credentials6.CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
649
+ (0, import_invariant3.invariant)(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
650
+ F: __dxlog_file4,
651
+ L: 116,
452
652
  S: this,
453
653
  A: [
454
654
  "identityRecord.haloSpace.genesisFeedKey",
455
655
  "'Genesis feed key is required.'"
456
656
  ]
457
657
  });
458
- (0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
459
- F: __dxlog_file3,
460
- L: 113,
658
+ (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
659
+ F: __dxlog_file4,
660
+ L: 117,
461
661
  S: this,
462
662
  A: [
463
663
  "identityRecord.haloSpace.dataFeedKey",
@@ -468,7 +668,7 @@ var IdentityManager = class {
468
668
  // Space genesis.
469
669
  ...await generator.createSpaceGenesis(identityRecord.haloSpace.key, identityRecord.haloSpace.genesisFeedKey),
470
670
  // Feed admission.
471
- await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials6.AdmittedFeed.Designation.DATA)
671
+ await generator.createFeedAdmission(identityRecord.haloSpace.key, identityRecord.haloSpace.dataFeedKey, import_credentials7.AdmittedFeed.Designation.DATA)
472
672
  ];
473
673
  if (displayName) {
474
674
  credentials.push(await generator.createProfileCredential({
@@ -487,22 +687,22 @@ var IdentityManager = class {
487
687
  await this._metadataStore.setIdentityRecord(identityRecord);
488
688
  this._identity = identity;
489
689
  await this._identity.ready();
490
- import_log3.log.trace("dxos.halo.identity", {
690
+ import_log4.log.trace("dxos.halo.identity", {
491
691
  identityKey: identityRecord.identityKey,
492
692
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
493
693
  }, {
494
- F: __dxlog_file3,
495
- L: 148,
694
+ F: __dxlog_file4,
695
+ L: 152,
496
696
  S: this,
497
697
  C: (f, a) => f(...a)
498
698
  });
499
699
  this.stateUpdate.emit();
500
- (0, import_log3.log)("created identity", {
700
+ (0, import_log4.log)("created identity", {
501
701
  identityKey: identity.identityKey,
502
702
  deviceKey: identity.deviceKey
503
703
  }, {
504
- F: __dxlog_file3,
505
- L: 154,
704
+ F: __dxlog_file4,
705
+ L: 158,
506
706
  S: this,
507
707
  C: (f, a) => f(...a)
508
708
  });
@@ -513,17 +713,17 @@ var IdentityManager = class {
513
713
  */
514
714
  async acceptIdentity(params) {
515
715
  var _a;
516
- (0, import_log3.log)("accepting identity", {
716
+ (0, import_log4.log)("accepting identity", {
517
717
  params
518
718
  }, {
519
- F: __dxlog_file3,
520
- L: 162,
719
+ F: __dxlog_file4,
720
+ L: 166,
521
721
  S: this,
522
722
  C: (f, a) => f(...a)
523
723
  });
524
- (0, import_invariant2.invariant)(!this._identity, "Identity already exists.", {
525
- F: __dxlog_file3,
526
- L: 163,
724
+ (0, import_invariant3.invariant)(!this._identity, "Identity already exists.", {
725
+ F: __dxlog_file4,
726
+ L: 167,
527
727
  S: this,
528
728
  A: [
529
729
  "!this._identity",
@@ -542,52 +742,52 @@ var IdentityManager = class {
542
742
  }
543
743
  };
544
744
  const identity = await this._constructIdentity(identityRecord);
545
- await identity.open();
745
+ await identity.open(new import_context2.Context());
546
746
  this._identity = identity;
547
747
  await this._metadataStore.setIdentityRecord(identityRecord);
548
748
  await this._identity.ready();
549
- import_log3.log.trace("dxos.halo.identity", {
749
+ import_log4.log.trace("dxos.halo.identity", {
550
750
  identityKey: identityRecord.identityKey,
551
751
  displayName: (_a = this._identity.profileDocument) == null ? void 0 : _a.displayName
552
752
  }, {
553
- F: __dxlog_file3,
554
- L: 182,
753
+ F: __dxlog_file4,
754
+ L: 186,
555
755
  S: this,
556
756
  C: (f, a) => f(...a)
557
757
  });
558
758
  this.stateUpdate.emit();
559
- (0, import_log3.log)("accepted identity", {
759
+ (0, import_log4.log)("accepted identity", {
560
760
  identityKey: identity.identityKey,
561
761
  deviceKey: identity.deviceKey
562
762
  }, {
563
- F: __dxlog_file3,
564
- L: 188,
763
+ F: __dxlog_file4,
764
+ L: 192,
565
765
  S: this,
566
766
  C: (f, a) => f(...a)
567
767
  });
568
768
  return identity;
569
769
  }
570
770
  async _constructIdentity(identityRecord) {
571
- (0, import_invariant2.invariant)(!this._identity, void 0, {
572
- F: __dxlog_file3,
573
- L: 193,
771
+ (0, import_invariant3.invariant)(!this._identity, void 0, {
772
+ F: __dxlog_file4,
773
+ L: 197,
574
774
  S: this,
575
775
  A: [
576
776
  "!this._identity",
577
777
  ""
578
778
  ]
579
779
  });
580
- (0, import_log3.log)("constructing identity", {
780
+ (0, import_log4.log)("constructing identity", {
581
781
  identityRecord
582
782
  }, {
583
- F: __dxlog_file3,
584
- L: 194,
783
+ F: __dxlog_file4,
784
+ L: 198,
585
785
  S: this,
586
786
  C: (f, a) => f(...a)
587
787
  });
588
- (0, import_invariant2.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
589
- F: __dxlog_file3,
590
- L: 197,
788
+ (0, import_invariant3.invariant)(identityRecord.haloSpace.controlFeedKey, void 0, {
789
+ F: __dxlog_file4,
790
+ L: 201,
591
791
  S: this,
592
792
  A: [
593
793
  "identityRecord.haloSpace.controlFeedKey",
@@ -597,9 +797,9 @@ var IdentityManager = class {
597
797
  const controlFeed = await this._feedStore.openFeed(identityRecord.haloSpace.controlFeedKey, {
598
798
  writable: true
599
799
  });
600
- (0, import_invariant2.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
601
- F: __dxlog_file3,
602
- L: 201,
800
+ (0, import_invariant3.invariant)(identityRecord.haloSpace.dataFeedKey, void 0, {
801
+ F: __dxlog_file4,
802
+ L: 205,
603
803
  S: this,
604
804
  A: [
605
805
  "identityRecord.haloSpace.dataFeedKey",
@@ -614,7 +814,7 @@ var IdentityManager = class {
614
814
  spaceRecord: identityRecord.haloSpace,
615
815
  swarmIdentity: {
616
816
  peerKey: identityRecord.deviceKey,
617
- credentialProvider: createAuthProvider((0, import_credentials5.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
817
+ credentialProvider: createAuthProvider((0, import_credentials6.createCredentialSignerWithKey)(this._keyring, identityRecord.deviceKey)),
618
818
  credentialAuthenticator: (0, import_util.deferFunction)(() => identity.authVerifier.verifier)
619
819
  },
620
820
  identityKey: identityRecord.identityKey
@@ -627,11 +827,11 @@ var IdentityManager = class {
627
827
  identityKey: identityRecord.identityKey,
628
828
  deviceKey: identityRecord.deviceKey
629
829
  });
630
- (0, import_log3.log)("done", {
830
+ (0, import_log4.log)("done", {
631
831
  identityKey: identityRecord.identityKey
632
832
  }, {
633
- F: __dxlog_file3,
634
- L: 225,
833
+ F: __dxlog_file4,
834
+ L: 229,
635
835
  S: this,
636
836
  C: (f, a) => f(...a)
637
837
  });
@@ -650,9 +850,9 @@ var IdentityManager = class {
650
850
  onNetworkConnection: () => {
651
851
  },
652
852
  onAuthFailure: () => {
653
- import_log3.log.warn("auth failure", void 0, {
654
- F: __dxlog_file3,
655
- L: 244,
853
+ import_log4.log.warn("auth failure", void 0, {
854
+ F: __dxlog_file4,
855
+ L: 248,
656
856
  S: this,
657
857
  C: (f, a) => f(...a)
658
858
  });
@@ -661,13 +861,19 @@ var IdentityManager = class {
661
861
  });
662
862
  }
663
863
  };
864
+ _ts_decorate2([
865
+ import_tracing2.trace.span()
866
+ ], IdentityManager.prototype, "open", null);
867
+ IdentityManager = _ts_decorate2([
868
+ import_tracing2.trace.resource()
869
+ ], IdentityManager);
664
870
 
665
871
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
666
- var import_codec_protobuf2 = require("@dxos/codec-protobuf");
667
- var import_credentials7 = require("@dxos/credentials");
872
+ var import_codec_protobuf3 = require("@dxos/codec-protobuf");
873
+ var import_credentials8 = require("@dxos/credentials");
668
874
  var import_debug3 = require("@dxos/debug");
669
- var import_invariant3 = require("@dxos/invariant");
670
- var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
875
+ var import_invariant4 = require("@dxos/invariant");
876
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/identity/identity-service.ts";
671
877
  var IdentityServiceImpl = class {
672
878
  // TODO(wittjosiah): Remove dependency on service context.
673
879
  constructor(_serviceContext) {
@@ -681,7 +887,7 @@ var IdentityServiceImpl = class {
681
887
  return (0, import_debug3.todo)();
682
888
  }
683
889
  queryIdentity() {
684
- return new import_codec_protobuf2.Stream(({ next }) => {
890
+ return new import_codec_protobuf3.Stream(({ next }) => {
685
891
  const emitNext = () => next({
686
892
  identity: this._getIdentity()
687
893
  });
@@ -700,8 +906,8 @@ var IdentityServiceImpl = class {
700
906
  };
701
907
  }
702
908
  async signPresentation({ presentation, nonce }) {
703
- (0, import_invariant3.invariant)(this._serviceContext.identityManager.identity, "Identity not initialized.", {
704
- F: __dxlog_file4,
909
+ (0, import_invariant4.invariant)(this._serviceContext.identityManager.identity, "Identity not initialized.", {
910
+ F: __dxlog_file5,
705
911
  L: 56,
706
912
  S: this,
707
913
  A: [
@@ -709,7 +915,7 @@ var IdentityServiceImpl = class {
709
915
  "'Identity not initialized.'"
710
916
  ]
711
917
  });
712
- return await (0, import_credentials7.signPresentation)({
918
+ return await (0, import_credentials8.signPresentation)({
713
919
  presentation,
714
920
  signer: this._serviceContext.keyring,
715
921
  signerKey: this._serviceContext.identityManager.identity.deviceKey,
@@ -720,9 +926,9 @@ var IdentityServiceImpl = class {
720
926
  };
721
927
 
722
928
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
723
- var import_invariant4 = require("@dxos/invariant");
724
- var import_services = require("@dxos/protocols/proto/dxos/client/services");
725
- var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
929
+ var import_invariant5 = require("@dxos/invariant");
930
+ var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
931
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts";
726
932
  var DeviceInvitationProtocol = class {
727
933
  constructor(_keyring, _getIdentity, _acceptIdentity) {
728
934
  this._keyring = _keyring;
@@ -734,12 +940,12 @@ var DeviceInvitationProtocol = class {
734
940
  }
735
941
  getInvitationContext() {
736
942
  return {
737
- kind: import_services.Invitation.Kind.DEVICE
943
+ kind: import_services2.Invitation.Kind.DEVICE
738
944
  };
739
945
  }
740
946
  async admit(request) {
741
- (0, import_invariant4.invariant)(request.device, void 0, {
742
- F: __dxlog_file5,
947
+ (0, import_invariant5.invariant)(request.device, void 0, {
948
+ F: __dxlog_file6,
743
949
  L: 31,
744
950
  S: this,
745
951
  A: [
@@ -774,8 +980,8 @@ var DeviceInvitationProtocol = class {
774
980
  };
775
981
  }
776
982
  async accept(response, request) {
777
- (0, import_invariant4.invariant)(response.device, void 0, {
778
- F: __dxlog_file5,
983
+ (0, import_invariant5.invariant)(response.device, void 0, {
984
+ F: __dxlog_file6,
779
985
  L: 64,
780
986
  S: this,
781
987
  A: [
@@ -784,8 +990,8 @@ var DeviceInvitationProtocol = class {
784
990
  ]
785
991
  });
786
992
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
787
- (0, import_invariant4.invariant)(request.device, void 0, {
788
- F: __dxlog_file5,
993
+ (0, import_invariant5.invariant)(request.device, void 0, {
994
+ F: __dxlog_file6,
789
995
  L: 67,
790
996
  S: this,
791
997
  A: [
@@ -812,43 +1018,43 @@ var DeviceInvitationProtocol = class {
812
1018
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
813
1019
  var import_async5 = require("@dxos/async");
814
1020
  var import_client_protocol2 = require("@dxos/client-protocol");
815
- var import_context3 = require("@dxos/context");
816
- var import_credentials8 = require("@dxos/credentials");
1021
+ var import_context4 = require("@dxos/context");
1022
+ var import_credentials9 = require("@dxos/credentials");
817
1023
  var import_errors2 = require("@dxos/errors");
818
- var import_invariant6 = require("@dxos/invariant");
1024
+ var import_invariant7 = require("@dxos/invariant");
819
1025
  var import_keys4 = require("@dxos/keys");
820
- var import_log5 = require("@dxos/log");
1026
+ var import_log6 = require("@dxos/log");
821
1027
  var import_network_manager = require("@dxos/network-manager");
822
- var import_protocols4 = require("@dxos/protocols");
823
- var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
1028
+ var import_protocols5 = require("@dxos/protocols");
1029
+ var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
824
1030
  var import_invitations2 = require("@dxos/protocols/proto/dxos/halo/invitations");
825
1031
 
826
1032
  // packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts
827
1033
  var import_async4 = require("@dxos/async");
828
- var import_context2 = require("@dxos/context");
1034
+ var import_context3 = require("@dxos/context");
829
1035
  var import_errors = require("@dxos/errors");
830
- var import_invariant5 = require("@dxos/invariant");
1036
+ var import_invariant6 = require("@dxos/invariant");
831
1037
  var import_keys3 = require("@dxos/keys");
832
- var import_log4 = require("@dxos/log");
833
- var import_protocols3 = require("@dxos/protocols");
834
- var import_services2 = require("@dxos/protocols/proto/dxos/client/services");
1038
+ var import_log5 = require("@dxos/log");
1039
+ var import_protocols4 = require("@dxos/protocols");
1040
+ var import_services3 = require("@dxos/protocols/proto/dxos/client/services");
835
1041
  var import_invitations = require("@dxos/protocols/proto/dxos/halo/invitations");
836
1042
  var import_teleport = require("@dxos/teleport");
837
- var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
1043
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitation-extension.ts";
838
1044
  var OPTIONS_TIMEOUT = 1e4;
839
1045
  var MAX_OTP_ATTEMPTS = 3;
840
1046
  var InvitationHostExtension = class extends import_teleport.RpcExtension {
841
1047
  constructor(_callbacks) {
842
1048
  super({
843
1049
  requested: {
844
- InvitationHostService: import_protocols3.schema.getService("dxos.halo.invitations.InvitationHostService")
1050
+ InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
845
1051
  },
846
1052
  exposed: {
847
- InvitationHostService: import_protocols3.schema.getService("dxos.halo.invitations.InvitationHostService")
1053
+ InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
848
1054
  }
849
1055
  });
850
1056
  this._callbacks = _callbacks;
851
- this._ctx = new import_context2.Context();
1057
+ this._ctx = new import_context3.Context();
852
1058
  this._remoteOptionsTrigger = new import_async4.Trigger();
853
1059
  this.invitation = void 0;
854
1060
  this.guestProfile = void 0;
@@ -862,8 +1068,8 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
862
1068
  // Perhaps in the future we will have more complex logic here.
863
1069
  InvitationHostService: {
864
1070
  options: async (options) => {
865
- (0, import_invariant5.invariant)(!this._remoteOptions, "Remote options already set.", {
866
- F: __dxlog_file6,
1071
+ (0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
1072
+ F: __dxlog_file7,
867
1073
  L: 88,
868
1074
  S: this,
869
1075
  A: [
@@ -877,34 +1083,34 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
877
1083
  introduce: async (request) => {
878
1084
  const { profile, invitationId } = request;
879
1085
  const traceId = import_keys3.PublicKey.random().toHex();
880
- import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.begin({
1086
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols4.trace.begin({
881
1087
  id: traceId
882
1088
  }), {
883
- F: __dxlog_file6,
1089
+ F: __dxlog_file7,
884
1090
  L: 97,
885
1091
  S: this,
886
1092
  C: (f, a) => f(...a)
887
1093
  });
888
1094
  const invitation = await this._callbacks.resolveInvitation(request);
889
1095
  if (!invitation) {
890
- import_log4.log.warn("invitation not found", {
1096
+ import_log5.log.warn("invitation not found", {
891
1097
  invitationId
892
1098
  }, {
893
- F: __dxlog_file6,
1099
+ F: __dxlog_file7,
894
1100
  L: 101,
895
1101
  S: this,
896
1102
  C: (f, a) => f(...a)
897
1103
  });
898
1104
  this._callbacks.onError(new Error("Invitation not found."));
899
1105
  return {
900
- authMethod: import_services2.Invitation.AuthMethod.NONE
1106
+ authMethod: import_services3.Invitation.AuthMethod.NONE
901
1107
  };
902
1108
  }
903
1109
  this.invitation = invitation;
904
- (0, import_log4.log)("guest introduced itself", {
1110
+ (0, import_log5.log)("guest introduced itself", {
905
1111
  guestProfile: profile
906
1112
  }, {
907
- F: __dxlog_file6,
1113
+ F: __dxlog_file7,
908
1114
  L: 110,
909
1115
  S: this,
910
1116
  C: (f, a) => f(...a)
@@ -912,42 +1118,42 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
912
1118
  this.guestProfile = profile;
913
1119
  this._callbacks.onStateUpdate({
914
1120
  ...this.invitation,
915
- state: import_services2.Invitation.State.READY_FOR_AUTHENTICATION
1121
+ state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
916
1122
  });
917
- import_log4.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols3.trace.end({
1123
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.introduce", import_protocols4.trace.end({
918
1124
  id: traceId
919
1125
  }), {
920
- F: __dxlog_file6,
1126
+ F: __dxlog_file7,
921
1127
  L: 117,
922
1128
  S: this,
923
1129
  C: (f, a) => f(...a)
924
1130
  });
925
1131
  return {
926
- spaceKey: this.invitation.authMethod === import_services2.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
1132
+ spaceKey: this.invitation.authMethod === import_services3.Invitation.AuthMethod.NONE ? this.invitation.spaceKey : void 0,
927
1133
  authMethod: this.invitation.authMethod
928
1134
  };
929
1135
  },
930
1136
  authenticate: async ({ authCode: code }) => {
931
1137
  const traceId = import_keys3.PublicKey.random().toHex();
932
- import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.begin({
1138
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols4.trace.begin({
933
1139
  id: traceId
934
1140
  }), {
935
- F: __dxlog_file6,
1141
+ F: __dxlog_file7,
936
1142
  L: 126,
937
1143
  S: this,
938
1144
  C: (f, a) => f(...a)
939
1145
  });
940
- (0, import_log4.log)("received authentication request", {
1146
+ (0, import_log5.log)("received authentication request", {
941
1147
  authCode: code
942
1148
  }, {
943
- F: __dxlog_file6,
1149
+ F: __dxlog_file7,
944
1150
  L: 127,
945
1151
  S: this,
946
1152
  C: (f, a) => f(...a)
947
1153
  });
948
1154
  let status = import_invitations.AuthenticationResponse.Status.OK;
949
- (0, import_invariant5.invariant)(this.invitation, "Invitation is not set.", {
950
- F: __dxlog_file6,
1155
+ (0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
1156
+ F: __dxlog_file7,
951
1157
  L: 130,
952
1158
  S: this,
953
1159
  A: [
@@ -956,9 +1162,9 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
956
1162
  ]
957
1163
  });
958
1164
  switch (this.invitation.authMethod) {
959
- case import_services2.Invitation.AuthMethod.NONE: {
960
- (0, import_log4.log)("authentication not required", void 0, {
961
- F: __dxlog_file6,
1165
+ case import_services3.Invitation.AuthMethod.NONE: {
1166
+ (0, import_log5.log)("authentication not required", void 0, {
1167
+ F: __dxlog_file7,
962
1168
  L: 133,
963
1169
  S: this,
964
1170
  C: (f, a) => f(...a)
@@ -967,7 +1173,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
967
1173
  status: import_invitations.AuthenticationResponse.Status.OK
968
1174
  };
969
1175
  }
970
- case import_services2.Invitation.AuthMethod.SHARED_SECRET: {
1176
+ case import_services3.Invitation.AuthMethod.SHARED_SECRET: {
971
1177
  if (this.invitation.authCode) {
972
1178
  if (this.authenticationRetry++ > MAX_OTP_ATTEMPTS) {
973
1179
  status = import_invitations.AuthenticationResponse.Status.INVALID_OPT_ATTEMPTS;
@@ -980,10 +1186,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
980
1186
  break;
981
1187
  }
982
1188
  default: {
983
- import_log4.log.error("invalid authentication method", {
1189
+ import_log5.log.error("invalid authentication method", {
984
1190
  authMethod: this.invitation.authMethod
985
1191
  }, {
986
- F: __dxlog_file6,
1192
+ F: __dxlog_file7,
987
1193
  L: 151,
988
1194
  S: this,
989
1195
  C: (f, a) => f(...a)
@@ -992,13 +1198,13 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
992
1198
  break;
993
1199
  }
994
1200
  }
995
- import_log4.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols3.trace.end({
1201
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.authenticate", import_protocols4.trace.end({
996
1202
  id: traceId,
997
1203
  data: {
998
1204
  status
999
1205
  }
1000
1206
  }), {
1001
- F: __dxlog_file6,
1207
+ F: __dxlog_file7,
1002
1208
  L: 157,
1003
1209
  S: this,
1004
1210
  C: (f, a) => f(...a)
@@ -1009,17 +1215,17 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1009
1215
  },
1010
1216
  admit: async (request) => {
1011
1217
  const traceId = import_keys3.PublicKey.random().toHex();
1012
- import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.begin({
1218
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols4.trace.begin({
1013
1219
  id: traceId
1014
1220
  }), {
1015
- F: __dxlog_file6,
1221
+ F: __dxlog_file7,
1016
1222
  L: 163,
1017
1223
  S: this,
1018
1224
  C: (f, a) => f(...a)
1019
1225
  });
1020
1226
  try {
1021
- (0, import_invariant5.invariant)(this.invitation, "Invitation is not set.", {
1022
- F: __dxlog_file6,
1227
+ (0, import_invariant6.invariant)(this.invitation, "Invitation is not set.", {
1228
+ F: __dxlog_file7,
1023
1229
  L: 166,
1024
1230
  S: this,
1025
1231
  A: [
@@ -1031,10 +1237,10 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1031
1237
  throw new Error("Not authenticated");
1032
1238
  }
1033
1239
  const response = await this._callbacks.admit(request);
1034
- import_log4.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols3.trace.end({
1240
+ import_log5.log.trace("dxos.sdk.invitation-handler.host.admit", import_protocols4.trace.end({
1035
1241
  id: traceId
1036
1242
  }), {
1037
- F: __dxlog_file6,
1243
+ F: __dxlog_file7,
1038
1244
  L: 174,
1039
1245
  S: this,
1040
1246
  C: (f, a) => f(...a)
@@ -1055,7 +1261,7 @@ var InvitationHostExtension = class extends import_teleport.RpcExtension {
1055
1261
  await this.rpc.InvitationHostService.options({
1056
1262
  role: import_invitations.Options.Role.HOST
1057
1263
  });
1058
- await (0, import_context2.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1264
+ await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1059
1265
  timeout: OPTIONS_TIMEOUT
1060
1266
  }));
1061
1267
  if (((_a = this._remoteOptions) == null ? void 0 : _a.role) !== import_invitations.Options.Role.GUEST) {
@@ -1077,22 +1283,22 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1077
1283
  constructor(_callbacks) {
1078
1284
  super({
1079
1285
  requested: {
1080
- InvitationHostService: import_protocols3.schema.getService("dxos.halo.invitations.InvitationHostService")
1286
+ InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
1081
1287
  },
1082
1288
  exposed: {
1083
- InvitationHostService: import_protocols3.schema.getService("dxos.halo.invitations.InvitationHostService")
1289
+ InvitationHostService: import_protocols4.schema.getService("dxos.halo.invitations.InvitationHostService")
1084
1290
  }
1085
1291
  });
1086
1292
  this._callbacks = _callbacks;
1087
- this._ctx = new import_context2.Context();
1293
+ this._ctx = new import_context3.Context();
1088
1294
  this._remoteOptionsTrigger = new import_async4.Trigger();
1089
1295
  }
1090
1296
  async getHandlers() {
1091
1297
  return {
1092
1298
  InvitationHostService: {
1093
1299
  options: async (options) => {
1094
- (0, import_invariant5.invariant)(!this._remoteOptions, "Remote options already set.", {
1095
- F: __dxlog_file6,
1300
+ (0, import_invariant6.invariant)(!this._remoteOptions, "Remote options already set.", {
1301
+ F: __dxlog_file7,
1096
1302
  L: 241,
1097
1303
  S: this,
1098
1304
  A: [
@@ -1119,20 +1325,20 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1119
1325
  var _a;
1120
1326
  await super.onOpen(context);
1121
1327
  try {
1122
- (0, import_log4.log)("begin options", void 0, {
1123
- F: __dxlog_file6,
1328
+ (0, import_log5.log)("begin options", void 0, {
1329
+ F: __dxlog_file7,
1124
1330
  L: 262,
1125
1331
  S: this,
1126
1332
  C: (f, a) => f(...a)
1127
1333
  });
1128
- await (0, import_context2.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
1334
+ await (0, import_context3.cancelWithContext)(this._ctx, this.rpc.InvitationHostService.options({
1129
1335
  role: import_invitations.Options.Role.GUEST
1130
1336
  }));
1131
- await (0, import_context2.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1337
+ await (0, import_context3.cancelWithContext)(this._ctx, this._remoteOptionsTrigger.wait({
1132
1338
  timeout: OPTIONS_TIMEOUT
1133
1339
  }));
1134
- (0, import_log4.log)("end options", void 0, {
1135
- F: __dxlog_file6,
1340
+ (0, import_log5.log)("end options", void 0, {
1341
+ F: __dxlog_file7,
1136
1342
  L: 265,
1137
1343
  S: this,
1138
1344
  C: (f, a) => f(...a)
@@ -1145,8 +1351,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1145
1351
  }
1146
1352
  this._callbacks.onOpen(this._ctx);
1147
1353
  } catch (err) {
1148
- (0, import_log4.log)("openError", err, {
1149
- F: __dxlog_file6,
1354
+ (0, import_log5.log)("openError", err, {
1355
+ F: __dxlog_file7,
1150
1356
  L: 275,
1151
1357
  S: this,
1152
1358
  C: (f, a) => f(...a)
@@ -1155,8 +1361,8 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1155
1361
  }
1156
1362
  }
1157
1363
  async onClose() {
1158
- (0, import_log4.log)("onClose", void 0, {
1159
- F: __dxlog_file6,
1364
+ (0, import_log5.log)("onClose", void 0, {
1365
+ F: __dxlog_file7,
1160
1366
  L: 281,
1161
1367
  S: this,
1162
1368
  C: (f, a) => f(...a)
@@ -1164,10 +1370,10 @@ var InvitationGuestExtension = class extends import_teleport.RpcExtension {
1164
1370
  await this._ctx.dispose();
1165
1371
  }
1166
1372
  };
1167
- var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services2.Invitation.AuthMethod.NONE;
1373
+ var isAuthenticationRequired = (invitation) => invitation.authMethod !== import_services3.Invitation.AuthMethod.NONE;
1168
1374
 
1169
1375
  // packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts
1170
- var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1376
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-handler.ts";
1171
1377
  var InvitationsHandler = class {
1172
1378
  /**
1173
1379
  * @internal
@@ -1177,10 +1383,10 @@ var InvitationsHandler = class {
1177
1383
  }
1178
1384
  createInvitation(protocol, options) {
1179
1385
  var _a;
1180
- const { invitationId = import_keys4.PublicKey.random().toHex(), type = import_services3.Invitation.Type.INTERACTIVE, authMethod = import_services3.Invitation.AuthMethod.SHARED_SECRET, state = import_services3.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys4.PublicKey.random() } = options != null ? options : {};
1181
- const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services3.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials8.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1182
- (0, import_invariant6.invariant)(protocol, void 0, {
1183
- F: __dxlog_file7,
1386
+ const { invitationId = import_keys4.PublicKey.random().toHex(), type = import_services4.Invitation.Type.INTERACTIVE, authMethod = import_services4.Invitation.AuthMethod.SHARED_SECRET, state = import_services4.Invitation.State.INIT, timeout = import_client_protocol2.INVITATION_TIMEOUT, swarmKey = import_keys4.PublicKey.random() } = options != null ? options : {};
1387
+ const authCode = (_a = options == null ? void 0 : options.authCode) != null ? _a : authMethod === import_services4.Invitation.AuthMethod.SHARED_SECRET ? (0, import_credentials9.generatePasscode)(import_client_protocol2.AUTHENTICATION_CODE_LENGTH) : void 0;
1388
+ (0, import_invariant7.invariant)(protocol, void 0, {
1389
+ F: __dxlog_file8,
1184
1390
  L: 76,
1185
1391
  S: this,
1186
1392
  A: [
@@ -1199,17 +1405,17 @@ var InvitationsHandler = class {
1199
1405
  ...protocol.getInvitationContext()
1200
1406
  };
1201
1407
  const stream = new import_async5.PushStream();
1202
- const ctx = new import_context3.Context({
1408
+ const ctx = new import_context4.Context({
1203
1409
  onError: (err) => {
1204
1410
  void ctx.dispose();
1205
1411
  stream.error(err);
1206
1412
  }
1207
1413
  });
1208
1414
  ctx.onDispose(() => {
1209
- (0, import_log5.log)("complete", {
1415
+ (0, import_log6.log)("complete", {
1210
1416
  ...protocol.toJSON()
1211
1417
  }, {
1212
- F: __dxlog_file7,
1418
+ F: __dxlog_file8,
1213
1419
  L: 98,
1214
1420
  S: this,
1215
1421
  C: (f, a) => f(...a)
@@ -1221,7 +1427,7 @@ var InvitationsHandler = class {
1221
1427
  onStateUpdate: (invitation2) => {
1222
1428
  stream.next({
1223
1429
  ...invitation2,
1224
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1430
+ state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1225
1431
  });
1226
1432
  },
1227
1433
  resolveInvitation: async ({ invitationId: invitationId2 }) => {
@@ -1234,8 +1440,8 @@ var InvitationsHandler = class {
1234
1440
  var _a2, _b, _c;
1235
1441
  try {
1236
1442
  const deviceKey = (_c = (_a2 = admissionRequest.device) == null ? void 0 : _a2.deviceKey) != null ? _c : (_b = admissionRequest.space) == null ? void 0 : _b.deviceKey;
1237
- (0, import_invariant6.invariant)(deviceKey, void 0, {
1238
- F: __dxlog_file7,
1443
+ (0, import_invariant7.invariant)(deviceKey, void 0, {
1444
+ F: __dxlog_file8,
1239
1445
  L: 119,
1240
1446
  S: this,
1241
1447
  A: [
@@ -1255,84 +1461,84 @@ var InvitationsHandler = class {
1255
1461
  (0, import_async5.scheduleTask)(ctx, async () => {
1256
1462
  const traceId = import_keys4.PublicKey.random().toHex();
1257
1463
  try {
1258
- import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.begin({
1464
+ import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.begin({
1259
1465
  id: traceId
1260
1466
  }), {
1261
- F: __dxlog_file7,
1467
+ F: __dxlog_file8,
1262
1468
  L: 137,
1263
1469
  S: this,
1264
1470
  C: (f, a) => f(...a)
1265
1471
  });
1266
- (0, import_log5.log)("connected", {
1472
+ (0, import_log6.log)("connected", {
1267
1473
  ...protocol.toJSON()
1268
1474
  }, {
1269
- F: __dxlog_file7,
1475
+ F: __dxlog_file8,
1270
1476
  L: 138,
1271
1477
  S: this,
1272
1478
  C: (f, a) => f(...a)
1273
1479
  });
1274
1480
  stream.next({
1275
1481
  ...invitation,
1276
- state: import_services3.Invitation.State.CONNECTED
1482
+ state: import_services4.Invitation.State.CONNECTED
1277
1483
  });
1278
1484
  const deviceKey = await extension.completedTrigger.wait({
1279
1485
  timeout
1280
1486
  });
1281
- (0, import_log5.log)("admitted guest", {
1487
+ (0, import_log6.log)("admitted guest", {
1282
1488
  guest: deviceKey,
1283
1489
  ...protocol.toJSON()
1284
1490
  }, {
1285
- F: __dxlog_file7,
1491
+ F: __dxlog_file8,
1286
1492
  L: 141,
1287
1493
  S: this,
1288
1494
  C: (f, a) => f(...a)
1289
1495
  });
1290
1496
  stream.next({
1291
1497
  ...invitation,
1292
- state: import_services3.Invitation.State.SUCCESS
1498
+ state: import_services4.Invitation.State.SUCCESS
1293
1499
  });
1294
- import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.end({
1500
+ import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.end({
1295
1501
  id: traceId
1296
1502
  }), {
1297
- F: __dxlog_file7,
1503
+ F: __dxlog_file8,
1298
1504
  L: 143,
1299
1505
  S: this,
1300
1506
  C: (f, a) => f(...a)
1301
1507
  });
1302
1508
  } catch (err) {
1303
1509
  if (err instanceof import_async5.TimeoutError) {
1304
- (0, import_log5.log)("timeout", {
1510
+ (0, import_log6.log)("timeout", {
1305
1511
  ...protocol.toJSON()
1306
1512
  }, {
1307
- F: __dxlog_file7,
1513
+ F: __dxlog_file8,
1308
1514
  L: 146,
1309
1515
  S: this,
1310
1516
  C: (f, a) => f(...a)
1311
1517
  });
1312
1518
  stream.next({
1313
1519
  ...invitation,
1314
- state: import_services3.Invitation.State.TIMEOUT
1520
+ state: import_services4.Invitation.State.TIMEOUT
1315
1521
  });
1316
1522
  } else {
1317
- import_log5.log.error("failed", err, {
1318
- F: __dxlog_file7,
1523
+ import_log6.log.error("failed", err, {
1524
+ F: __dxlog_file8,
1319
1525
  L: 149,
1320
1526
  S: this,
1321
1527
  C: (f, a) => f(...a)
1322
1528
  });
1323
1529
  stream.error(err);
1324
1530
  }
1325
- import_log5.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols4.trace.error({
1531
+ import_log6.log.trace("dxos.sdk.invitations-handler.host.onOpen", import_protocols5.trace.error({
1326
1532
  id: traceId,
1327
1533
  error: err
1328
1534
  }), {
1329
- F: __dxlog_file7,
1535
+ F: __dxlog_file8,
1330
1536
  L: 152,
1331
1537
  S: this,
1332
1538
  C: (f, a) => f(...a)
1333
1539
  });
1334
1540
  } finally {
1335
- if (type !== import_services3.Invitation.Type.MULTIUSE) {
1541
+ if (type !== import_services4.Invitation.Type.MULTIUSE) {
1336
1542
  await swarmConnection.close();
1337
1543
  await ctx.dispose();
1338
1544
  }
@@ -1344,21 +1550,21 @@ var InvitationsHandler = class {
1344
1550
  return;
1345
1551
  }
1346
1552
  if (err instanceof import_async5.TimeoutError) {
1347
- (0, import_log5.log)("timeout", {
1553
+ (0, import_log6.log)("timeout", {
1348
1554
  ...protocol.toJSON()
1349
1555
  }, {
1350
- F: __dxlog_file7,
1556
+ F: __dxlog_file8,
1351
1557
  L: 167,
1352
1558
  S: this,
1353
1559
  C: (f, a) => f(...a)
1354
1560
  });
1355
1561
  stream.next({
1356
1562
  ...invitation,
1357
- state: import_services3.Invitation.State.TIMEOUT
1563
+ state: import_services4.Invitation.State.TIMEOUT
1358
1564
  });
1359
1565
  } else {
1360
- import_log5.log.error("failed", err, {
1361
- F: __dxlog_file7,
1566
+ import_log6.log.error("failed", err, {
1567
+ F: __dxlog_file8,
1362
1568
  L: 170,
1363
1569
  S: this,
1364
1570
  C: (f, a) => f(...a)
@@ -1383,7 +1589,7 @@ var InvitationsHandler = class {
1383
1589
  ctx.onDispose(() => swarmConnection.close());
1384
1590
  stream.next({
1385
1591
  ...invitation,
1386
- state: import_services3.Invitation.State.CONNECTING
1592
+ state: import_services4.Invitation.State.CONNECTING
1387
1593
  });
1388
1594
  });
1389
1595
  const observable = new import_client_protocol2.CancellableInvitationObservable({
@@ -1392,7 +1598,7 @@ var InvitationsHandler = class {
1392
1598
  onCancel: async () => {
1393
1599
  stream.next({
1394
1600
  ...invitation,
1395
- state: import_services3.Invitation.State.CANCELLED
1601
+ state: import_services4.Invitation.State.CANCELLED
1396
1602
  });
1397
1603
  await ctx.dispose();
1398
1604
  }
@@ -1401,8 +1607,8 @@ var InvitationsHandler = class {
1401
1607
  }
1402
1608
  acceptInvitation(protocol, invitation) {
1403
1609
  const { timeout = import_client_protocol2.INVITATION_TIMEOUT } = invitation;
1404
- (0, import_invariant6.invariant)(protocol, void 0, {
1405
- F: __dxlog_file7,
1610
+ (0, import_invariant7.invariant)(protocol, void 0, {
1611
+ F: __dxlog_file8,
1406
1612
  L: 210,
1407
1613
  S: this,
1408
1614
  A: [
@@ -1415,8 +1621,8 @@ var InvitationsHandler = class {
1415
1621
  let currentState;
1416
1622
  const stream = new import_async5.PushStream();
1417
1623
  const setState = (newData) => {
1418
- (0, import_invariant6.invariant)(newData.state !== void 0, void 0, {
1419
- F: __dxlog_file7,
1624
+ (0, import_invariant7.invariant)(newData.state !== void 0, void 0, {
1625
+ F: __dxlog_file8,
1420
1626
  L: 221,
1421
1627
  S: this,
1422
1628
  A: [
@@ -1430,23 +1636,23 @@ var InvitationsHandler = class {
1430
1636
  ...newData
1431
1637
  });
1432
1638
  };
1433
- const ctx = new import_context3.Context({
1639
+ const ctx = new import_context4.Context({
1434
1640
  onError: (err) => {
1435
1641
  if (err instanceof import_async5.TimeoutError) {
1436
- (0, import_log5.log)("timeout", {
1642
+ (0, import_log6.log)("timeout", {
1437
1643
  ...protocol.toJSON()
1438
1644
  }, {
1439
- F: __dxlog_file7,
1645
+ F: __dxlog_file8,
1440
1646
  L: 229,
1441
1647
  S: this,
1442
1648
  C: (f, a) => f(...a)
1443
1649
  });
1444
1650
  setState({
1445
- state: import_services3.Invitation.State.TIMEOUT
1651
+ state: import_services4.Invitation.State.TIMEOUT
1446
1652
  });
1447
1653
  } else {
1448
- import_log5.log.warn("auth failed", err, {
1449
- F: __dxlog_file7,
1654
+ import_log6.log.warn("auth failed", err, {
1655
+ F: __dxlog_file8,
1450
1656
  L: 232,
1451
1657
  S: this,
1452
1658
  C: (f, a) => f(...a)
@@ -1457,10 +1663,10 @@ var InvitationsHandler = class {
1457
1663
  }
1458
1664
  });
1459
1665
  ctx.onDispose(() => {
1460
- (0, import_log5.log)("complete", {
1666
+ (0, import_log6.log)("complete", {
1461
1667
  ...protocol.toJSON()
1462
1668
  }, {
1463
- F: __dxlog_file7,
1669
+ F: __dxlog_file8,
1464
1670
  L: 240,
1465
1671
  S: this,
1466
1672
  C: (f, a) => f(...a)
@@ -1472,10 +1678,10 @@ var InvitationsHandler = class {
1472
1678
  const extension = new InvitationGuestExtension({
1473
1679
  onOpen: (extensionCtx) => {
1474
1680
  extensionCtx.onDispose(async () => {
1475
- (0, import_log5.log)("extension disposed", {
1681
+ (0, import_log6.log)("extension disposed", {
1476
1682
  currentState
1477
1683
  }, {
1478
- F: __dxlog_file7,
1684
+ F: __dxlog_file8,
1479
1685
  L: 250,
1480
1686
  S: this,
1481
1687
  C: (f, a) => f(...a)
@@ -1487,10 +1693,10 @@ var InvitationsHandler = class {
1487
1693
  (0, import_async5.scheduleTask)(ctx, async () => {
1488
1694
  const traceId = import_keys4.PublicKey.random().toHex();
1489
1695
  try {
1490
- import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.begin({
1696
+ import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.begin({
1491
1697
  id: traceId
1492
1698
  }), {
1493
- F: __dxlog_file7,
1699
+ F: __dxlog_file8,
1494
1700
  L: 259,
1495
1701
  S: this,
1496
1702
  C: (f, a) => f(...a)
@@ -1499,31 +1705,31 @@ var InvitationsHandler = class {
1499
1705
  throw new Error(`multiple connections detected: ${connectionCount}`);
1500
1706
  }
1501
1707
  (0, import_async5.scheduleTask)(ctx, () => ctx.raise(new import_async5.TimeoutError(timeout)), timeout);
1502
- (0, import_log5.log)("connected", {
1708
+ (0, import_log6.log)("connected", {
1503
1709
  ...protocol.toJSON()
1504
1710
  }, {
1505
- F: __dxlog_file7,
1711
+ F: __dxlog_file8,
1506
1712
  L: 267,
1507
1713
  S: this,
1508
1714
  C: (f, a) => f(...a)
1509
1715
  });
1510
1716
  setState({
1511
- state: import_services3.Invitation.State.CONNECTED
1717
+ state: import_services4.Invitation.State.CONNECTED
1512
1718
  });
1513
- (0, import_log5.log)("introduce", {
1719
+ (0, import_log6.log)("introduce", {
1514
1720
  ...protocol.toJSON()
1515
1721
  }, {
1516
- F: __dxlog_file7,
1722
+ F: __dxlog_file8,
1517
1723
  L: 271,
1518
1724
  S: this,
1519
1725
  C: (f, a) => f(...a)
1520
1726
  });
1521
1727
  const introductionResponse = await extension.rpc.InvitationHostService.introduce(protocol.createIntroduction());
1522
- (0, import_log5.log)("introduce response", {
1728
+ (0, import_log6.log)("introduce response", {
1523
1729
  ...protocol.toJSON(),
1524
1730
  response: introductionResponse
1525
1731
  }, {
1526
- F: __dxlog_file7,
1732
+ F: __dxlog_file8,
1527
1733
  L: 275,
1528
1734
  S: this,
1529
1735
  C: (f, a) => f(...a)
@@ -1534,26 +1740,26 @@ var InvitationsHandler = class {
1534
1740
  }
1535
1741
  if (isAuthenticationRequired(invitation)) {
1536
1742
  for (let attempt = 1; attempt <= MAX_OTP_ATTEMPTS; attempt++) {
1537
- (0, import_log5.log)("guest waiting for authentication code...", void 0, {
1538
- F: __dxlog_file7,
1743
+ (0, import_log6.log)("guest waiting for authentication code...", void 0, {
1744
+ F: __dxlog_file8,
1539
1745
  L: 284,
1540
1746
  S: this,
1541
1747
  C: (f, a) => f(...a)
1542
1748
  });
1543
1749
  setState({
1544
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1750
+ state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1545
1751
  });
1546
1752
  const authCode = await authenticated.wait({
1547
1753
  timeout
1548
1754
  });
1549
- (0, import_log5.log)("sending authentication request", void 0, {
1550
- F: __dxlog_file7,
1755
+ (0, import_log6.log)("sending authentication request", void 0, {
1756
+ F: __dxlog_file8,
1551
1757
  L: 288,
1552
1758
  S: this,
1553
1759
  C: (f, a) => f(...a)
1554
1760
  });
1555
1761
  setState({
1556
- state: import_services3.Invitation.State.AUTHENTICATING
1762
+ state: import_services4.Invitation.State.AUTHENTICATING
1557
1763
  });
1558
1764
  const response = await extension.rpc.InvitationHostService.authenticate({
1559
1765
  authCode
@@ -1565,10 +1771,10 @@ var InvitationsHandler = class {
1565
1771
  if (attempt === MAX_OTP_ATTEMPTS) {
1566
1772
  throw new Error(`Maximum retry attempts: ${MAX_OTP_ATTEMPTS}`);
1567
1773
  } else {
1568
- (0, import_log5.log)("retrying invalid code", {
1774
+ (0, import_log6.log)("retrying invalid code", {
1569
1775
  attempt
1570
1776
  }, {
1571
- F: __dxlog_file7,
1777
+ F: __dxlog_file8,
1572
1778
  L: 299,
1573
1779
  S: this,
1574
1780
  C: (f, a) => f(...a)
@@ -1579,13 +1785,13 @@ var InvitationsHandler = class {
1579
1785
  }
1580
1786
  } else {
1581
1787
  setState({
1582
- state: import_services3.Invitation.State.READY_FOR_AUTHENTICATION
1788
+ state: import_services4.Invitation.State.READY_FOR_AUTHENTICATION
1583
1789
  });
1584
1790
  }
1585
- (0, import_log5.log)("request admission", {
1791
+ (0, import_log6.log)("request admission", {
1586
1792
  ...protocol.toJSON()
1587
1793
  }, {
1588
- F: __dxlog_file7,
1794
+ F: __dxlog_file8,
1589
1795
  L: 310,
1590
1796
  S: this,
1591
1797
  C: (f, a) => f(...a)
@@ -1594,53 +1800,53 @@ var InvitationsHandler = class {
1594
1800
  const admissionResponse = await extension.rpc.InvitationHostService.admit(admissionRequest);
1595
1801
  admitted = true;
1596
1802
  const result = await protocol.accept(admissionResponse, admissionRequest);
1597
- (0, import_log5.log)("admitted by host", {
1803
+ (0, import_log6.log)("admitted by host", {
1598
1804
  ...protocol.toJSON()
1599
1805
  }, {
1600
- F: __dxlog_file7,
1806
+ F: __dxlog_file8,
1601
1807
  L: 321,
1602
1808
  S: this,
1603
1809
  C: (f, a) => f(...a)
1604
1810
  });
1605
1811
  setState({
1606
1812
  ...result,
1607
- state: import_services3.Invitation.State.SUCCESS
1813
+ state: import_services4.Invitation.State.SUCCESS
1608
1814
  });
1609
- import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.end({
1815
+ import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.end({
1610
1816
  id: traceId
1611
1817
  }), {
1612
- F: __dxlog_file7,
1818
+ F: __dxlog_file8,
1613
1819
  L: 323,
1614
1820
  S: this,
1615
1821
  C: (f, a) => f(...a)
1616
1822
  });
1617
1823
  } catch (err) {
1618
1824
  if (err instanceof import_async5.TimeoutError) {
1619
- (0, import_log5.log)("timeout", {
1825
+ (0, import_log6.log)("timeout", {
1620
1826
  ...protocol.toJSON()
1621
1827
  }, {
1622
- F: __dxlog_file7,
1828
+ F: __dxlog_file8,
1623
1829
  L: 326,
1624
1830
  S: this,
1625
1831
  C: (f, a) => f(...a)
1626
1832
  });
1627
1833
  setState({
1628
- state: import_services3.Invitation.State.TIMEOUT
1834
+ state: import_services4.Invitation.State.TIMEOUT
1629
1835
  });
1630
1836
  } else {
1631
- (0, import_log5.log)("auth failed", err, {
1632
- F: __dxlog_file7,
1837
+ (0, import_log6.log)("auth failed", err, {
1838
+ F: __dxlog_file8,
1633
1839
  L: 329,
1634
1840
  S: this,
1635
1841
  C: (f, a) => f(...a)
1636
1842
  });
1637
1843
  stream.error(err);
1638
1844
  }
1639
- import_log5.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols4.trace.error({
1845
+ import_log6.log.trace("dxos.sdk.invitations-handler.guest.onOpen", import_protocols5.trace.error({
1640
1846
  id: traceId,
1641
1847
  error: err
1642
1848
  }), {
1643
- F: __dxlog_file7,
1849
+ F: __dxlog_file8,
1644
1850
  L: 332,
1645
1851
  S: this,
1646
1852
  C: (f, a) => f(...a)
@@ -1655,20 +1861,20 @@ var InvitationsHandler = class {
1655
1861
  return;
1656
1862
  }
1657
1863
  if (err instanceof import_async5.TimeoutError) {
1658
- (0, import_log5.log)("timeout", {
1864
+ (0, import_log6.log)("timeout", {
1659
1865
  ...protocol.toJSON()
1660
1866
  }, {
1661
- F: __dxlog_file7,
1867
+ F: __dxlog_file8,
1662
1868
  L: 343,
1663
1869
  S: this,
1664
1870
  C: (f, a) => f(...a)
1665
1871
  });
1666
1872
  setState({
1667
- state: import_services3.Invitation.State.TIMEOUT
1873
+ state: import_services4.Invitation.State.TIMEOUT
1668
1874
  });
1669
1875
  } else {
1670
- (0, import_log5.log)("auth failed", err, {
1671
- F: __dxlog_file7,
1876
+ (0, import_log6.log)("auth failed", err, {
1877
+ F: __dxlog_file8,
1672
1878
  L: 346,
1673
1879
  S: this,
1674
1880
  C: (f, a) => f(...a)
@@ -1680,8 +1886,8 @@ var InvitationsHandler = class {
1680
1886
  return extension;
1681
1887
  };
1682
1888
  (0, import_async5.scheduleTask)(ctx, async () => {
1683
- (0, import_invariant6.invariant)(invitation.swarmKey, void 0, {
1684
- F: __dxlog_file7,
1889
+ (0, import_invariant7.invariant)(invitation.swarmKey, void 0, {
1890
+ F: __dxlog_file8,
1685
1891
  L: 356,
1686
1892
  S: this,
1687
1893
  A: [
@@ -1700,7 +1906,7 @@ var InvitationsHandler = class {
1700
1906
  });
1701
1907
  ctx.onDispose(() => swarmConnection.close());
1702
1908
  setState({
1703
- state: import_services3.Invitation.State.CONNECTING
1909
+ state: import_services4.Invitation.State.CONNECTING
1704
1910
  });
1705
1911
  });
1706
1912
  const observable = new import_client_protocol2.AuthenticatingInvitationObservable({
@@ -1708,7 +1914,7 @@ var InvitationsHandler = class {
1708
1914
  subscriber: stream.observable,
1709
1915
  onCancel: async () => {
1710
1916
  setState({
1711
- state: import_services3.Invitation.State.CANCELLED
1917
+ state: import_services4.Invitation.State.CANCELLED
1712
1918
  });
1713
1919
  await ctx.dispose();
1714
1920
  },
@@ -1722,11 +1928,11 @@ var InvitationsHandler = class {
1722
1928
 
1723
1929
  // packages/sdk/client-services/src/packlets/invitations/invitations-service.ts
1724
1930
  var import_async6 = require("@dxos/async");
1725
- var import_codec_protobuf3 = require("@dxos/codec-protobuf");
1726
- var import_invariant7 = require("@dxos/invariant");
1727
- var import_log6 = require("@dxos/log");
1728
- var import_services4 = require("@dxos/protocols/proto/dxos/client/services");
1729
- var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
1931
+ var import_codec_protobuf4 = require("@dxos/codec-protobuf");
1932
+ var import_invariant8 = require("@dxos/invariant");
1933
+ var import_log7 = require("@dxos/log");
1934
+ var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
1935
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/invitations-service.ts";
1730
1936
  var InvitationsServiceImpl = class {
1731
1937
  constructor(_invitationsHandler, _getHandler) {
1732
1938
  this._invitationsHandler = _invitationsHandler;
@@ -1753,7 +1959,7 @@ var InvitationsServiceImpl = class {
1753
1959
  this._createInvitations.set(invitation.get().invitationId, invitation);
1754
1960
  this._invitationCreated.emit(invitation.get());
1755
1961
  }
1756
- return new import_codec_protobuf3.Stream(({ next, close }) => {
1962
+ return new import_codec_protobuf4.Stream(({ next, close }) => {
1757
1963
  invitation.subscribe((invitation2) => {
1758
1964
  next(invitation2);
1759
1965
  }, (err) => {
@@ -1775,7 +1981,7 @@ var InvitationsServiceImpl = class {
1775
1981
  this._acceptInvitations.set(invitation.get().invitationId, invitation);
1776
1982
  this._invitationAccepted.emit(invitation.get());
1777
1983
  }
1778
- return new import_codec_protobuf3.Stream(({ next, close }) => {
1984
+ return new import_codec_protobuf4.Stream(({ next, close }) => {
1779
1985
  invitation.subscribe((invitation2) => {
1780
1986
  next(invitation2);
1781
1987
  }, (err) => {
@@ -1787,14 +1993,14 @@ var InvitationsServiceImpl = class {
1787
1993
  });
1788
1994
  }
1789
1995
  async authenticate({ invitationId, authCode }) {
1790
- (0, import_log6.log)("authenticating...", void 0, {
1791
- F: __dxlog_file8,
1996
+ (0, import_log7.log)("authenticating...", void 0, {
1997
+ F: __dxlog_file9,
1792
1998
  L: 102,
1793
1999
  S: this,
1794
2000
  C: (f, a) => f(...a)
1795
2001
  });
1796
- (0, import_invariant7.invariant)(invitationId, void 0, {
1797
- F: __dxlog_file8,
2002
+ (0, import_invariant8.invariant)(invitationId, void 0, {
2003
+ F: __dxlog_file9,
1798
2004
  L: 103,
1799
2005
  S: this,
1800
2006
  A: [
@@ -1804,10 +2010,10 @@ var InvitationsServiceImpl = class {
1804
2010
  });
1805
2011
  const observable = this._acceptInvitations.get(invitationId);
1806
2012
  if (!observable) {
1807
- import_log6.log.warn("invalid invitation", {
2013
+ import_log7.log.warn("invalid invitation", {
1808
2014
  invitationId
1809
2015
  }, {
1810
- F: __dxlog_file8,
2016
+ F: __dxlog_file9,
1811
2017
  L: 106,
1812
2018
  S: this,
1813
2019
  C: (f, a) => f(...a)
@@ -1817,14 +2023,14 @@ var InvitationsServiceImpl = class {
1817
2023
  }
1818
2024
  }
1819
2025
  async cancelInvitation({ invitationId }) {
1820
- (0, import_log6.log)("deleting...", void 0, {
1821
- F: __dxlog_file8,
2026
+ (0, import_log7.log)("deleting...", void 0, {
2027
+ F: __dxlog_file9,
1822
2028
  L: 113,
1823
2029
  S: this,
1824
2030
  C: (f, a) => f(...a)
1825
2031
  });
1826
- (0, import_invariant7.invariant)(invitationId, void 0, {
1827
- F: __dxlog_file8,
2032
+ (0, import_invariant8.invariant)(invitationId, void 0, {
2033
+ F: __dxlog_file9,
1828
2034
  L: 114,
1829
2035
  S: this,
1830
2036
  A: [
@@ -1843,10 +2049,10 @@ var InvitationsServiceImpl = class {
1843
2049
  this._acceptInvitations.delete(invitationId);
1844
2050
  this._removedAccepted.emit(accepted.get());
1845
2051
  } else {
1846
- import_log6.log.warn("invalid invitation", {
2052
+ import_log7.log.warn("invalid invitation", {
1847
2053
  invitationId
1848
2054
  }, {
1849
- F: __dxlog_file8,
2055
+ F: __dxlog_file9,
1850
2056
  L: 126,
1851
2057
  S: this,
1852
2058
  C: (f, a) => f(...a)
@@ -1854,11 +2060,11 @@ var InvitationsServiceImpl = class {
1854
2060
  }
1855
2061
  }
1856
2062
  queryInvitations() {
1857
- return new import_codec_protobuf3.Stream(({ next, ctx }) => {
2063
+ return new import_codec_protobuf4.Stream(({ next, ctx }) => {
1858
2064
  this._invitationCreated.on(ctx, (invitation) => {
1859
2065
  next({
1860
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
1861
- type: import_services4.QueryInvitationsResponse.Type.CREATED,
2066
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2067
+ type: import_services5.QueryInvitationsResponse.Type.CREATED,
1862
2068
  invitations: [
1863
2069
  invitation
1864
2070
  ]
@@ -1866,8 +2072,8 @@ var InvitationsServiceImpl = class {
1866
2072
  });
1867
2073
  this._invitationAccepted.on(ctx, (invitation) => {
1868
2074
  next({
1869
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
1870
- type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
2075
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2076
+ type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
1871
2077
  invitations: [
1872
2078
  invitation
1873
2079
  ]
@@ -1875,8 +2081,8 @@ var InvitationsServiceImpl = class {
1875
2081
  });
1876
2082
  this._removedCreated.on(ctx, (invitation) => {
1877
2083
  next({
1878
- action: import_services4.QueryInvitationsResponse.Action.REMOVED,
1879
- type: import_services4.QueryInvitationsResponse.Type.CREATED,
2084
+ action: import_services5.QueryInvitationsResponse.Action.REMOVED,
2085
+ type: import_services5.QueryInvitationsResponse.Type.CREATED,
1880
2086
  invitations: [
1881
2087
  invitation
1882
2088
  ]
@@ -1884,21 +2090,21 @@ var InvitationsServiceImpl = class {
1884
2090
  });
1885
2091
  this._removedAccepted.on(ctx, (invitation) => {
1886
2092
  next({
1887
- action: import_services4.QueryInvitationsResponse.Action.REMOVED,
1888
- type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
2093
+ action: import_services5.QueryInvitationsResponse.Action.REMOVED,
2094
+ type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
1889
2095
  invitations: [
1890
2096
  invitation
1891
2097
  ]
1892
2098
  });
1893
2099
  });
1894
2100
  next({
1895
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
1896
- type: import_services4.QueryInvitationsResponse.Type.CREATED,
2101
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2102
+ type: import_services5.QueryInvitationsResponse.Type.CREATED,
1897
2103
  invitations: Array.from(this._createInvitations.values()).map((invitation) => invitation.get())
1898
2104
  });
1899
2105
  next({
1900
- action: import_services4.QueryInvitationsResponse.Action.ADDED,
1901
- type: import_services4.QueryInvitationsResponse.Type.ACCEPTED,
2106
+ action: import_services5.QueryInvitationsResponse.Action.ADDED,
2107
+ type: import_services5.QueryInvitationsResponse.Type.ACCEPTED,
1902
2108
  invitations: Array.from(this._acceptInvitations.values()).map((invitation) => invitation.get())
1903
2109
  });
1904
2110
  });
@@ -1906,12 +2112,12 @@ var InvitationsServiceImpl = class {
1906
2112
  };
1907
2113
 
1908
2114
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
1909
- var import_credentials9 = require("@dxos/credentials");
2115
+ var import_credentials10 = require("@dxos/credentials");
1910
2116
  var import_feed_store2 = require("@dxos/feed-store");
1911
- var import_invariant8 = require("@dxos/invariant");
1912
- var import_log7 = require("@dxos/log");
1913
- var import_services5 = require("@dxos/protocols/proto/dxos/client/services");
1914
- var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
2117
+ var import_invariant9 = require("@dxos/invariant");
2118
+ var import_log8 = require("@dxos/log");
2119
+ var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2120
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts";
1915
2121
  var SpaceInvitationProtocol = class {
1916
2122
  constructor(_spaceManager, _signingContext, _keyring, _spaceKey) {
1917
2123
  this._spaceManager = _spaceManager;
@@ -1927,14 +2133,14 @@ var SpaceInvitationProtocol = class {
1927
2133
  }
1928
2134
  getInvitationContext() {
1929
2135
  return {
1930
- kind: import_services5.Invitation.Kind.SPACE,
2136
+ kind: import_services6.Invitation.Kind.SPACE,
1931
2137
  spaceKey: this._spaceKey
1932
2138
  };
1933
2139
  }
1934
2140
  async admit(request, guestProfile) {
1935
2141
  var _a;
1936
- (0, import_invariant8.invariant)(this._spaceKey, void 0, {
1937
- F: __dxlog_file9,
2142
+ (0, import_invariant9.invariant)(this._spaceKey, void 0, {
2143
+ F: __dxlog_file10,
1938
2144
  L: 42,
1939
2145
  S: this,
1940
2146
  A: [
@@ -1943,8 +2149,8 @@ var SpaceInvitationProtocol = class {
1943
2149
  ]
1944
2150
  });
1945
2151
  const space = await this._spaceManager.spaces.get(this._spaceKey);
1946
- (0, import_invariant8.invariant)(space, void 0, {
1947
- F: __dxlog_file9,
2152
+ (0, import_invariant9.invariant)(space, void 0, {
2153
+ F: __dxlog_file10,
1948
2154
  L: 44,
1949
2155
  S: this,
1950
2156
  A: [
@@ -1952,8 +2158,8 @@ var SpaceInvitationProtocol = class {
1952
2158
  ""
1953
2159
  ]
1954
2160
  });
1955
- (0, import_invariant8.invariant)(request.space, void 0, {
1956
- F: __dxlog_file9,
2161
+ (0, import_invariant9.invariant)(request.space, void 0, {
2162
+ F: __dxlog_file10,
1957
2163
  L: 46,
1958
2164
  S: this,
1959
2165
  A: [
@@ -1962,18 +2168,18 @@ var SpaceInvitationProtocol = class {
1962
2168
  ]
1963
2169
  });
1964
2170
  const { identityKey, deviceKey } = request.space;
1965
- (0, import_log7.log)("writing guest credentials", {
2171
+ (0, import_log8.log)("writing guest credentials", {
1966
2172
  host: this._signingContext.deviceKey,
1967
2173
  guest: deviceKey
1968
2174
  }, {
1969
- F: __dxlog_file9,
2175
+ F: __dxlog_file10,
1970
2176
  L: 49,
1971
2177
  S: this,
1972
2178
  C: (f, a) => f(...a)
1973
2179
  });
1974
- const credentials = await (0, import_credentials9.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
1975
- (0, import_invariant8.invariant)(credentials[0].credential, void 0, {
1976
- F: __dxlog_file9,
2180
+ const credentials = await (0, import_credentials10.createAdmissionCredentials)(this._signingContext.credentialSigner, identityKey, space.key, space.inner.genesisFeedKey, guestProfile);
2181
+ (0, import_invariant9.invariant)(credentials[0].credential, void 0, {
2182
+ F: __dxlog_file10,
1977
2183
  L: 60,
1978
2184
  S: this,
1979
2185
  A: [
@@ -1982,8 +2188,8 @@ var SpaceInvitationProtocol = class {
1982
2188
  ]
1983
2189
  });
1984
2190
  const spaceMemberCredential = credentials[0].credential.credential;
1985
- (0, import_invariant8.invariant)((0, import_credentials9.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
1986
- F: __dxlog_file9,
2191
+ (0, import_invariant9.invariant)((0, import_credentials10.getCredentialAssertion)(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2192
+ F: __dxlog_file10,
1987
2193
  L: 62,
1988
2194
  S: this,
1989
2195
  A: [
@@ -2018,8 +2224,8 @@ var SpaceInvitationProtocol = class {
2018
2224
  };
2019
2225
  }
2020
2226
  async accept(response) {
2021
- (0, import_invariant8.invariant)(response.space, void 0, {
2022
- F: __dxlog_file9,
2227
+ (0, import_invariant9.invariant)(response.space, void 0, {
2228
+ F: __dxlog_file10,
2023
2229
  L: 97,
2024
2230
  S: this,
2025
2231
  A: [
@@ -2028,9 +2234,9 @@ var SpaceInvitationProtocol = class {
2028
2234
  ]
2029
2235
  });
2030
2236
  const { credential, controlTimeframe, dataTimeframe } = response.space;
2031
- const assertion = (0, import_credentials9.getCredentialAssertion)(credential);
2032
- (0, import_invariant8.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2033
- F: __dxlog_file9,
2237
+ const assertion = (0, import_credentials10.getCredentialAssertion)(credential);
2238
+ (0, import_invariant9.invariant)(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
2239
+ F: __dxlog_file10,
2034
2240
  L: 100,
2035
2241
  S: this,
2036
2242
  A: [
@@ -2038,8 +2244,8 @@ var SpaceInvitationProtocol = class {
2038
2244
  "'Invalid credential'"
2039
2245
  ]
2040
2246
  });
2041
- (0, import_invariant8.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
2042
- F: __dxlog_file9,
2247
+ (0, import_invariant9.invariant)(credential.subject.id.equals(this._signingContext.identityKey), void 0, {
2248
+ F: __dxlog_file10,
2043
2249
  L: 101,
2044
2250
  S: this,
2045
2251
  A: [
@@ -2062,47 +2268,47 @@ var SpaceInvitationProtocol = class {
2062
2268
 
2063
2269
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2064
2270
  var import_async9 = require("@dxos/async");
2065
- var import_context6 = require("@dxos/context");
2066
- var import_credentials13 = require("@dxos/credentials");
2067
- var import_invariant10 = require("@dxos/invariant");
2271
+ var import_context7 = require("@dxos/context");
2272
+ var import_credentials14 = require("@dxos/credentials");
2273
+ var import_invariant11 = require("@dxos/invariant");
2068
2274
  var import_keys7 = require("@dxos/keys");
2069
- var import_log10 = require("@dxos/log");
2070
- var import_protocols6 = require("@dxos/protocols");
2071
- var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2275
+ var import_log11 = require("@dxos/log");
2276
+ var import_protocols7 = require("@dxos/protocols");
2277
+ var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
2072
2278
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
2073
2279
  var import_util4 = require("@dxos/util");
2074
2280
 
2075
2281
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2076
2282
  var import_async8 = require("@dxos/async");
2077
2283
  var import_client_protocol3 = require("@dxos/client-protocol");
2078
- var import_context5 = require("@dxos/context");
2284
+ var import_context6 = require("@dxos/context");
2079
2285
  var import_debug4 = require("@dxos/debug");
2080
2286
  var import_echo_pipeline = require("@dxos/echo-pipeline");
2081
2287
  var import_errors3 = require("@dxos/errors");
2082
2288
  var import_keys6 = require("@dxos/keys");
2083
- var import_log9 = require("@dxos/log");
2084
- var import_services6 = require("@dxos/protocols/proto/dxos/client/services");
2085
- var import_credentials10 = require("@dxos/protocols/proto/dxos/halo/credentials");
2289
+ var import_log10 = require("@dxos/log");
2290
+ var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2291
+ var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
2086
2292
  var import_timeframe = require("@dxos/timeframe");
2087
2293
  var import_util3 = require("@dxos/util");
2088
2294
 
2089
2295
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
2090
2296
  var import_async7 = require("@dxos/async");
2091
- var import_context4 = require("@dxos/context");
2092
- var import_invariant9 = require("@dxos/invariant");
2297
+ var import_context5 = require("@dxos/context");
2298
+ var import_invariant10 = require("@dxos/invariant");
2093
2299
  var import_keys5 = require("@dxos/keys");
2094
- var import_log8 = require("@dxos/log");
2095
- var import_protocols5 = require("@dxos/protocols");
2300
+ var import_log9 = require("@dxos/log");
2301
+ var import_protocols6 = require("@dxos/protocols");
2096
2302
  var import_teleport2 = require("@dxos/teleport");
2097
2303
  var import_util2 = require("@dxos/util");
2098
- var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2304
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
2099
2305
  var DEFAULT_RETRY_TIMEOUT = 1e3;
2100
2306
  var DEFAULT_SUCCESS_DELAY = 1e3;
2101
2307
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
2102
2308
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
2103
2309
  var NotarizationPlugin = class {
2104
2310
  constructor() {
2105
- this._ctx = new import_context4.Context();
2311
+ this._ctx = new import_context5.Context();
2106
2312
  this._extensionOpened = new import_async7.Event();
2107
2313
  this._extensions = /* @__PURE__ */ new Set();
2108
2314
  this._processedCredentials = new import_util2.ComplexSet(import_keys5.PublicKey.hash);
@@ -2120,16 +2326,16 @@ var NotarizationPlugin = class {
2120
2326
  * Request credentials to be notarized.
2121
2327
  */
2122
2328
  async notarize({ ctx: opCtx, credentials, timeout = DEFAULT_NOTARIZE_TIMEOUT, retryTimeout = DEFAULT_RETRY_TIMEOUT, successDelay = DEFAULT_SUCCESS_DELAY }) {
2123
- (0, import_log8.log)("notarize", {
2329
+ (0, import_log9.log)("notarize", {
2124
2330
  credentials
2125
2331
  }, {
2126
- F: __dxlog_file10,
2332
+ F: __dxlog_file11,
2127
2333
  L: 90,
2128
2334
  S: this,
2129
2335
  C: (f, a) => f(...a)
2130
2336
  });
2131
- (0, import_invariant9.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
2132
- F: __dxlog_file10,
2337
+ (0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
2338
+ F: __dxlog_file11,
2133
2339
  L: 91,
2134
2340
  S: this,
2135
2341
  A: [
@@ -2140,10 +2346,10 @@ var NotarizationPlugin = class {
2140
2346
  const errors = new import_async7.Trigger();
2141
2347
  const ctx = this._ctx.derive({
2142
2348
  onError: (err) => {
2143
- import_log8.log.warn("Notarization error", {
2349
+ import_log9.log.warn("Notarization error", {
2144
2350
  err
2145
2351
  }, {
2146
- F: __dxlog_file10,
2352
+ F: __dxlog_file11,
2147
2353
  L: 99,
2148
2354
  S: this,
2149
2355
  C: (f, a) => f(...a)
@@ -2155,11 +2361,11 @@ var NotarizationPlugin = class {
2155
2361
  opCtx == null ? void 0 : opCtx.onDispose(() => ctx.dispose());
2156
2362
  if (timeout !== 0) {
2157
2363
  (0, import_async7.scheduleTask)(ctx, () => {
2158
- import_log8.log.warn("Notarization timeout", {
2364
+ import_log9.log.warn("Notarization timeout", {
2159
2365
  timeout,
2160
2366
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
2161
2367
  }, {
2162
- F: __dxlog_file10,
2368
+ F: __dxlog_file11,
2163
2369
  L: 111,
2164
2370
  S: this,
2165
2371
  C: (f, a) => f(...a)
@@ -2179,10 +2385,10 @@ var NotarizationPlugin = class {
2179
2385
  ...this._extensions
2180
2386
  ].find((peer2) => !peersTried.has(peer2));
2181
2387
  if (!peer) {
2182
- import_log8.log.warn("Exhausted all peers to notarize with", {
2388
+ import_log9.log.warn("Exhausted all peers to notarize with", {
2183
2389
  retryIn: retryTimeout
2184
2390
  }, {
2185
- F: __dxlog_file10,
2391
+ F: __dxlog_file11,
2186
2392
  L: 136,
2187
2393
  S: this,
2188
2394
  C: (f, a) => f(...a)
@@ -2192,11 +2398,11 @@ var NotarizationPlugin = class {
2192
2398
  return;
2193
2399
  }
2194
2400
  peersTried.add(peer);
2195
- (0, import_log8.log)("try notarizing", {
2401
+ (0, import_log9.log)("try notarizing", {
2196
2402
  peer: peer.localPeerId,
2197
2403
  credentialId: credentials.map((credential) => credential.id)
2198
2404
  }, {
2199
- F: __dxlog_file10,
2405
+ F: __dxlog_file11,
2200
2406
  L: 143,
2201
2407
  S: this,
2202
2408
  C: (f, a) => f(...a)
@@ -2204,8 +2410,8 @@ var NotarizationPlugin = class {
2204
2410
  await peer.rpc.NotarizationService.notarize({
2205
2411
  credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
2206
2412
  });
2207
- (0, import_log8.log)("success", void 0, {
2208
- F: __dxlog_file10,
2413
+ (0, import_log9.log)("success", void 0, {
2414
+ F: __dxlog_file11,
2209
2415
  L: 147,
2210
2416
  S: this,
2211
2417
  C: (f, a) => f(...a)
@@ -2213,8 +2419,8 @@ var NotarizationPlugin = class {
2213
2419
  await (0, import_async7.sleep)(successDelay);
2214
2420
  } catch (err) {
2215
2421
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
2216
- import_log8.log.warn("error notarizing (recoverable)", err, {
2217
- F: __dxlog_file10,
2422
+ import_log9.log.warn("error notarizing (recoverable)", err, {
2423
+ F: __dxlog_file11,
2218
2424
  L: 151,
2219
2425
  S: this,
2220
2426
  C: (f, a) => f(...a)
@@ -2227,12 +2433,12 @@ var NotarizationPlugin = class {
2227
2433
  this._extensionOpened.on(ctx, () => notarizeTask.schedule());
2228
2434
  try {
2229
2435
  await Promise.race([
2230
- (0, import_context4.rejectOnDispose)(ctx),
2436
+ (0, import_context5.rejectOnDispose)(ctx),
2231
2437
  allNotarized,
2232
2438
  errors.wait()
2233
2439
  ]);
2234
- (0, import_log8.log)("done", void 0, {
2235
- F: __dxlog_file10,
2440
+ (0, import_log9.log)("done", void 0, {
2441
+ F: __dxlog_file11,
2236
2442
  L: 162,
2237
2443
  S: this,
2238
2444
  C: (f, a) => f(...a)
@@ -2254,8 +2460,8 @@ var NotarizationPlugin = class {
2254
2460
  this._processCredentialsTriggers.delete(credential.id);
2255
2461
  }
2256
2462
  setWriter(writer) {
2257
- (0, import_invariant9.invariant)(!this._writer, "Writer already set.", {
2258
- F: __dxlog_file10,
2463
+ (0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
2464
+ F: __dxlog_file11,
2259
2465
  L: 181,
2260
2466
  S: this,
2261
2467
  A: [
@@ -2280,8 +2486,8 @@ var NotarizationPlugin = class {
2280
2486
  throw new Error(WRITER_NOT_SET_ERROR_CODE);
2281
2487
  }
2282
2488
  for (const credential of (_a = request.credentials) != null ? _a : []) {
2283
- (0, import_invariant9.invariant)(credential.id, "Credential must have an id", {
2284
- F: __dxlog_file10,
2489
+ (0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
2490
+ F: __dxlog_file11,
2285
2491
  L: 200,
2286
2492
  S: this,
2287
2493
  A: [
@@ -2298,10 +2504,10 @@ var NotarizationPlugin = class {
2298
2504
  createExtension() {
2299
2505
  const extension = new NotarizationTeleportExtension({
2300
2506
  onOpen: async () => {
2301
- (0, import_log8.log)("extension opened", {
2507
+ (0, import_log9.log)("extension opened", {
2302
2508
  peer: extension.localPeerId
2303
2509
  }, {
2304
- F: __dxlog_file10,
2510
+ F: __dxlog_file11,
2305
2511
  L: 211,
2306
2512
  S: this,
2307
2513
  C: (f, a) => f(...a)
@@ -2310,10 +2516,10 @@ var NotarizationPlugin = class {
2310
2516
  this._extensionOpened.emit();
2311
2517
  },
2312
2518
  onClose: async () => {
2313
- (0, import_log8.log)("extension closed", {
2519
+ (0, import_log9.log)("extension closed", {
2314
2520
  peer: extension.localPeerId
2315
2521
  }, {
2316
- F: __dxlog_file10,
2522
+ F: __dxlog_file11,
2317
2523
  L: 216,
2318
2524
  S: this,
2319
2525
  C: (f, a) => f(...a)
@@ -2329,10 +2535,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2329
2535
  constructor(_params) {
2330
2536
  super({
2331
2537
  requested: {
2332
- NotarizationService: import_protocols5.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2538
+ NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2333
2539
  },
2334
2540
  exposed: {
2335
- NotarizationService: import_protocols5.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2541
+ NotarizationService: import_protocols6.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
2336
2542
  }
2337
2543
  });
2338
2544
  this._params = _params;
@@ -2357,7 +2563,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2357
2563
  };
2358
2564
 
2359
2565
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2360
- function _ts_decorate(decorators, target, key, desc) {
2566
+ function _ts_decorate3(decorators, target, key, desc) {
2361
2567
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2362
2568
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2363
2569
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2367,12 +2573,13 @@ function _ts_decorate(decorators, target, key, desc) {
2367
2573
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2368
2574
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2369
2575
  }
2370
- var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2576
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
2577
+ var ENABLE_FEED_PURGE = false;
2371
2578
  var DataSpace = class DataSpace2 {
2372
2579
  constructor(params) {
2373
- this._ctx = new import_context5.Context();
2580
+ this._ctx = new import_context6.Context();
2374
2581
  this._notarizationPlugin = new NotarizationPlugin();
2375
- this._state = import_services6.SpaceState.CLOSED;
2582
+ this._state = import_services7.SpaceState.CLOSED;
2376
2583
  /**
2377
2584
  * Error for _state === SpaceState.ERROR.
2378
2585
  */
@@ -2428,8 +2635,8 @@ var DataSpace = class DataSpace2 {
2428
2635
  async _open() {
2429
2636
  await this._notarizationPlugin.open();
2430
2637
  await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
2431
- await this._inner.open();
2432
- this._state = import_services6.SpaceState.CONTROL_ONLY;
2638
+ await this._inner.open(new import_context6.Context());
2639
+ this._state = import_services7.SpaceState.CONTROL_ONLY;
2433
2640
  this.stateUpdate.emit();
2434
2641
  this.metrics = {};
2435
2642
  this.metrics.open = new Date();
@@ -2440,9 +2647,9 @@ var DataSpace = class DataSpace2 {
2440
2647
  async _close() {
2441
2648
  var _a, _b;
2442
2649
  await ((_b = (_a = this._callbacks).beforeClose) == null ? void 0 : _b.call(_a));
2443
- this._state = import_services6.SpaceState.CLOSED;
2650
+ this._state = import_services7.SpaceState.CLOSED;
2444
2651
  await this._ctx.dispose();
2445
- this._ctx = new import_context5.Context();
2652
+ this._ctx = new import_context6.Context();
2446
2653
  await this.authVerifier.close();
2447
2654
  await this._inner.close();
2448
2655
  await this._inner.spaceState.removeCredentialProcessor(this._notarizationPlugin);
@@ -2465,21 +2672,21 @@ var DataSpace = class DataSpace2 {
2465
2672
  await this.initializeDataPipeline();
2466
2673
  } catch (err) {
2467
2674
  if (err instanceof import_errors3.CancelledError) {
2468
- (0, import_log9.log)("data pipeline initialization cancelled", err, {
2469
- F: __dxlog_file11,
2470
- L: 193,
2675
+ (0, import_log10.log)("data pipeline initialization cancelled", err, {
2676
+ F: __dxlog_file12,
2677
+ L: 199,
2471
2678
  S: this,
2472
2679
  C: (f, a) => f(...a)
2473
2680
  });
2474
2681
  return;
2475
2682
  }
2476
- import_log9.log.error("Error initializing data pipeline", err, {
2477
- F: __dxlog_file11,
2478
- L: 197,
2683
+ import_log10.log.error("Error initializing data pipeline", err, {
2684
+ F: __dxlog_file12,
2685
+ L: 203,
2479
2686
  S: this,
2480
2687
  C: (f, a) => f(...a)
2481
2688
  });
2482
- this._state = import_services6.SpaceState.ERROR;
2689
+ this._state = import_services7.SpaceState.ERROR;
2483
2690
  this.error = err;
2484
2691
  this.stateUpdate.emit();
2485
2692
  } finally {
@@ -2489,19 +2696,19 @@ var DataSpace = class DataSpace2 {
2489
2696
  }
2490
2697
  async initializeDataPipeline() {
2491
2698
  var _a, _b, _c, _d;
2492
- if (this._state !== import_services6.SpaceState.CONTROL_ONLY) {
2699
+ if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
2493
2700
  throw new import_errors3.SystemError("Invalid operation");
2494
2701
  }
2495
- this._state = import_services6.SpaceState.INITIALIZING;
2702
+ this._state = import_services7.SpaceState.INITIALIZING;
2496
2703
  await this._inner.controlPipeline.state.waitUntilReachedTargetTimeframe({
2497
2704
  ctx: this._ctx,
2498
2705
  breakOnStall: false
2499
2706
  });
2500
2707
  this.metrics.controlPipelineReady = new Date();
2501
2708
  await this._createWritableFeeds();
2502
- (0, import_log9.log)("writable feeds created", void 0, {
2503
- F: __dxlog_file11,
2504
- L: 221,
2709
+ (0, import_log10.log)("writable feeds created", void 0, {
2710
+ F: __dxlog_file12,
2711
+ L: 227,
2505
2712
  S: this,
2506
2713
  C: (f, a) => f(...a)
2507
2714
  });
@@ -2515,10 +2722,10 @@ var DataSpace = class DataSpace2 {
2515
2722
  }
2516
2723
  await this._inner.initializeDataPipeline();
2517
2724
  this.metrics.dataPipelineOpen = new Date();
2518
- await (0, import_context5.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2519
- (0, import_log9.log)("waiting for data pipeline to reach target timeframe", void 0, {
2520
- F: __dxlog_file11,
2521
- L: 242,
2725
+ await (0, import_context6.cancelWithContext)(this._ctx, this._inner.dataPipeline.ensureEpochInitialized());
2726
+ (0, import_log10.log)("waiting for data pipeline to reach target timeframe", void 0, {
2727
+ F: __dxlog_file12,
2728
+ L: 248,
2522
2729
  S: this,
2523
2730
  C: (f, a) => f(...a)
2524
2731
  });
@@ -2527,14 +2734,14 @@ var DataSpace = class DataSpace2 {
2527
2734
  breakOnStall: false
2528
2735
  });
2529
2736
  this.metrics.dataPipelineReady = new Date();
2530
- (0, import_log9.log)("data pipeline ready", void 0, {
2531
- F: __dxlog_file11,
2532
- L: 251,
2737
+ (0, import_log10.log)("data pipeline ready", void 0, {
2738
+ F: __dxlog_file12,
2739
+ L: 257,
2533
2740
  S: this,
2534
2741
  C: (f, a) => f(...a)
2535
2742
  });
2536
2743
  await ((_b = (_a = this._callbacks).beforeReady) == null ? void 0 : _b.call(_a));
2537
- this._state = import_services6.SpaceState.READY;
2744
+ this._state = import_services7.SpaceState.READY;
2538
2745
  this.stateUpdate.emit();
2539
2746
  await ((_d = (_c = this._callbacks).afterReady) == null ? void 0 : _d.call(_c));
2540
2747
  }
@@ -2552,7 +2759,7 @@ var DataSpace = class DataSpace2 {
2552
2759
  spaceKey: this.key,
2553
2760
  deviceKey: this._signingContext.deviceKey,
2554
2761
  identityKey: this._signingContext.identityKey,
2555
- designation: import_credentials10.AdmittedFeed.Designation.CONTROL
2762
+ designation: import_credentials11.AdmittedFeed.Designation.CONTROL
2556
2763
  }
2557
2764
  }));
2558
2765
  }
@@ -2569,7 +2776,7 @@ var DataSpace = class DataSpace2 {
2569
2776
  spaceKey: this.key,
2570
2777
  deviceKey: this._signingContext.deviceKey,
2571
2778
  identityKey: this._signingContext.identityKey,
2572
- designation: import_credentials10.AdmittedFeed.Designation.DATA
2779
+ designation: import_credentials11.AdmittedFeed.Designation.DATA
2573
2780
  }
2574
2781
  }));
2575
2782
  }
@@ -2602,59 +2809,62 @@ var DataSpace = class DataSpace2 {
2602
2809
  receipt.seq
2603
2810
  ]
2604
2811
  ]));
2605
- for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
2606
- const indexBeforeEpoch = epoch.timeframe.get(feed.key);
2607
- if (indexBeforeEpoch) {
2608
- await feed.clear(0, indexBeforeEpoch + 1);
2812
+ if (ENABLE_FEED_PURGE) {
2813
+ for (const feed of (_b = (_a = this.inner.dataPipeline.pipelineState) == null ? void 0 : _a.feeds) != null ? _b : []) {
2814
+ const indexBeforeEpoch = epoch.timeframe.get(feed.key);
2815
+ if (indexBeforeEpoch === void 0) {
2816
+ continue;
2817
+ }
2818
+ await feed.safeClear(0, indexBeforeEpoch + 1);
2609
2819
  }
2610
2820
  }
2611
2821
  }
2612
2822
  async activate() {
2613
- if (this._state !== import_services6.SpaceState.INACTIVE) {
2823
+ if (this._state !== import_services7.SpaceState.INACTIVE) {
2614
2824
  return;
2615
2825
  }
2616
- await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.ACTIVE);
2826
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
2617
2827
  await this._open();
2618
2828
  this.initializeDataPipelineAsync();
2619
2829
  }
2620
2830
  async deactivate() {
2621
- if (this._state === import_services6.SpaceState.INACTIVE) {
2831
+ if (this._state === import_services7.SpaceState.INACTIVE) {
2622
2832
  return;
2623
2833
  }
2624
- await this._metadataStore.setSpaceState(this.key, import_services6.SpaceState.INACTIVE);
2834
+ await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
2625
2835
  await this._close();
2626
- this._state = import_services6.SpaceState.INACTIVE;
2836
+ this._state = import_services7.SpaceState.INACTIVE;
2627
2837
  this.stateUpdate.emit();
2628
2838
  }
2629
2839
  };
2630
- _ts_decorate([
2840
+ _ts_decorate3([
2631
2841
  import_async8.synchronized
2632
2842
  ], DataSpace.prototype, "open", null);
2633
- _ts_decorate([
2843
+ _ts_decorate3([
2634
2844
  import_async8.synchronized
2635
2845
  ], DataSpace.prototype, "close", null);
2636
- _ts_decorate([
2846
+ _ts_decorate3([
2637
2847
  (0, import_debug4.timed)(1e4)
2638
2848
  ], DataSpace.prototype, "_createWritableFeeds", null);
2639
- _ts_decorate([
2849
+ _ts_decorate3([
2640
2850
  import_async8.synchronized
2641
2851
  ], DataSpace.prototype, "activate", null);
2642
- _ts_decorate([
2852
+ _ts_decorate3([
2643
2853
  import_async8.synchronized
2644
2854
  ], DataSpace.prototype, "deactivate", null);
2645
- DataSpace = _ts_decorate([
2855
+ DataSpace = _ts_decorate3([
2646
2856
  (0, import_async8.trackLeaks)("open", "close")
2647
2857
  ], DataSpace);
2648
2858
 
2649
2859
  // packages/sdk/client-services/src/packlets/spaces/genesis.ts
2650
- var import_credentials11 = require("@dxos/credentials");
2860
+ var import_credentials12 = require("@dxos/credentials");
2651
2861
  var import_debug5 = require("@dxos/debug");
2652
- var import_credentials12 = require("@dxos/protocols/proto/dxos/halo/credentials");
2862
+ var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
2653
2863
  var import_timeframe2 = require("@dxos/timeframe");
2654
2864
  var spaceGenesis = async (keyring, signingContext, space) => {
2655
2865
  var _a, _b, _c, _d;
2656
2866
  const credentials = [
2657
- await (0, import_credentials11.createCredential)({
2867
+ await (0, import_credentials12.createCredential)({
2658
2868
  signer: keyring,
2659
2869
  issuer: space.key,
2660
2870
  subject: space.key,
@@ -2663,14 +2873,14 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2663
2873
  spaceKey: space.key
2664
2874
  }
2665
2875
  }),
2666
- await (0, import_credentials11.createCredential)({
2876
+ await (0, import_credentials12.createCredential)({
2667
2877
  signer: keyring,
2668
2878
  issuer: space.key,
2669
2879
  subject: signingContext.identityKey,
2670
2880
  assertion: {
2671
2881
  "@type": "dxos.halo.credentials.SpaceMember",
2672
2882
  spaceKey: space.key,
2673
- role: import_credentials12.SpaceMember.Role.ADMIN,
2883
+ role: import_credentials13.SpaceMember.Role.ADMIN,
2674
2884
  profile: signingContext.profile,
2675
2885
  genesisFeedKey: (_a = space.controlFeedKey) != null ? _a : (0, import_debug5.failUndefined)()
2676
2886
  }
@@ -2682,7 +2892,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2682
2892
  spaceKey: space.key,
2683
2893
  identityKey: signingContext.identityKey,
2684
2894
  deviceKey: signingContext.deviceKey,
2685
- designation: import_credentials12.AdmittedFeed.Designation.CONTROL
2895
+ designation: import_credentials13.AdmittedFeed.Designation.CONTROL
2686
2896
  }
2687
2897
  }),
2688
2898
  await signingContext.credentialSigner.createCredential({
@@ -2692,7 +2902,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2692
2902
  spaceKey: space.key,
2693
2903
  identityKey: signingContext.identityKey,
2694
2904
  deviceKey: signingContext.deviceKey,
2695
- designation: import_credentials12.AdmittedFeed.Designation.DATA
2905
+ designation: import_credentials13.AdmittedFeed.Designation.DATA
2696
2906
  }
2697
2907
  }),
2698
2908
  await signingContext.credentialSigner.createCredential({
@@ -2717,7 +2927,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
2717
2927
  };
2718
2928
 
2719
2929
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
2720
- function _ts_decorate2(decorators, target, key, desc) {
2930
+ function _ts_decorate4(decorators, target, key, desc) {
2721
2931
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2722
2932
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2723
2933
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2727,7 +2937,7 @@ function _ts_decorate2(decorators, target, key, desc) {
2727
2937
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2728
2938
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2729
2939
  }
2730
- var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
2940
+ var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
2731
2941
  var DataSpaceManager = class DataSpaceManager2 {
2732
2942
  constructor(_spaceManager, _metadataStore, _dataServiceSubscriptions, _keyring, _signingContext, _feedStore) {
2733
2943
  this._spaceManager = _spaceManager;
@@ -2736,7 +2946,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2736
2946
  this._keyring = _keyring;
2737
2947
  this._signingContext = _signingContext;
2738
2948
  this._feedStore = _feedStore;
2739
- this._ctx = new import_context6.Context();
2949
+ this._ctx = new import_context7.Context();
2740
2950
  this.updated = new import_async9.Event();
2741
2951
  this._spaces = new import_util4.ComplexMap(import_keys7.PublicKey.hash);
2742
2952
  this._isOpen = false;
@@ -2747,49 +2957,49 @@ var DataSpaceManager = class DataSpaceManager2 {
2747
2957
  return this._spaces;
2748
2958
  }
2749
2959
  async open() {
2750
- (0, import_log10.log)("open", void 0, {
2751
- F: __dxlog_file12,
2960
+ (0, import_log11.log)("open", void 0, {
2961
+ F: __dxlog_file13,
2752
2962
  L: 79,
2753
2963
  S: this,
2754
2964
  C: (f, a) => f(...a)
2755
2965
  });
2756
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.begin({
2966
+ import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.begin({
2757
2967
  id: this._instanceId
2758
2968
  }), {
2759
- F: __dxlog_file12,
2969
+ F: __dxlog_file13,
2760
2970
  L: 80,
2761
2971
  S: this,
2762
2972
  C: (f, a) => f(...a)
2763
2973
  });
2764
2974
  await this._metadataStore.load();
2765
- (0, import_log10.log)("metadata loaded", {
2975
+ (0, import_log11.log)("metadata loaded", {
2766
2976
  spaces: this._metadataStore.spaces.length
2767
2977
  }, {
2768
- F: __dxlog_file12,
2978
+ F: __dxlog_file13,
2769
2979
  L: 82,
2770
2980
  S: this,
2771
2981
  C: (f, a) => f(...a)
2772
2982
  });
2773
2983
  for (const spaceMetadata of this._metadataStore.spaces) {
2774
2984
  try {
2775
- (0, import_log10.log)("load space", {
2985
+ (0, import_log11.log)("load space", {
2776
2986
  spaceMetadata
2777
2987
  }, {
2778
- F: __dxlog_file12,
2988
+ F: __dxlog_file13,
2779
2989
  L: 86,
2780
2990
  S: this,
2781
2991
  C: (f, a) => f(...a)
2782
2992
  });
2783
2993
  const space = await this._constructSpace(spaceMetadata);
2784
- if (spaceMetadata.state !== import_services7.SpaceState.INACTIVE) {
2994
+ if (spaceMetadata.state !== import_services8.SpaceState.INACTIVE) {
2785
2995
  space.initializeDataPipelineAsync();
2786
2996
  }
2787
2997
  } catch (err) {
2788
- import_log10.log.error("Error loading space", {
2998
+ import_log11.log.error("Error loading space", {
2789
2999
  spaceMetadata,
2790
3000
  err
2791
3001
  }, {
2792
- F: __dxlog_file12,
3002
+ F: __dxlog_file13,
2793
3003
  L: 92,
2794
3004
  S: this,
2795
3005
  C: (f, a) => f(...a)
@@ -2798,18 +3008,18 @@ var DataSpaceManager = class DataSpaceManager2 {
2798
3008
  }
2799
3009
  this._isOpen = true;
2800
3010
  this.updated.emit();
2801
- import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols6.trace.end({
3011
+ import_log11.log.trace("dxos.echo.data-space-manager.open", import_protocols7.trace.end({
2802
3012
  id: this._instanceId
2803
3013
  }), {
2804
- F: __dxlog_file12,
3014
+ F: __dxlog_file13,
2805
3015
  L: 98,
2806
3016
  S: this,
2807
3017
  C: (f, a) => f(...a)
2808
3018
  });
2809
3019
  }
2810
3020
  async close() {
2811
- (0, import_log10.log)("close", void 0, {
2812
- F: __dxlog_file12,
3021
+ (0, import_log11.log)("close", void 0, {
3022
+ F: __dxlog_file13,
2813
3023
  L: 103,
2814
3024
  S: this,
2815
3025
  C: (f, a) => f(...a)
@@ -2824,8 +3034,8 @@ var DataSpaceManager = class DataSpaceManager2 {
2824
3034
  * Creates a new space writing the genesis credentials to the control feed.
2825
3035
  */
2826
3036
  async createSpace() {
2827
- (0, import_invariant10.invariant)(this._isOpen, "Not open.", {
2828
- F: __dxlog_file12,
3037
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3038
+ F: __dxlog_file13,
2829
3039
  L: 116,
2830
3040
  S: this,
2831
3041
  A: [
@@ -2841,12 +3051,12 @@ var DataSpaceManager = class DataSpaceManager2 {
2841
3051
  genesisFeedKey: controlFeedKey,
2842
3052
  controlFeedKey,
2843
3053
  dataFeedKey,
2844
- state: import_services7.SpaceState.ACTIVE
3054
+ state: import_services8.SpaceState.ACTIVE
2845
3055
  };
2846
- (0, import_log10.log)("creating space...", {
3056
+ (0, import_log11.log)("creating space...", {
2847
3057
  spaceKey
2848
3058
  }, {
2849
- F: __dxlog_file12,
3059
+ F: __dxlog_file13,
2850
3060
  L: 128,
2851
3061
  S: this,
2852
3062
  C: (f, a) => f(...a)
@@ -2855,8 +3065,8 @@ var DataSpaceManager = class DataSpaceManager2 {
2855
3065
  const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner);
2856
3066
  await this._metadataStore.addSpace(metadata);
2857
3067
  const memberCredential = credentials[1];
2858
- (0, import_invariant10.invariant)((0, import_credentials13.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2859
- F: __dxlog_file12,
3068
+ (0, import_invariant11.invariant)((0, import_credentials14.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
3069
+ F: __dxlog_file13,
2860
3070
  L: 135,
2861
3071
  S: this,
2862
3072
  A: [
@@ -2871,16 +3081,16 @@ var DataSpaceManager = class DataSpaceManager2 {
2871
3081
  }
2872
3082
  // TODO(burdon): Rename join space.
2873
3083
  async acceptSpace(opts) {
2874
- (0, import_log10.log)("accept space", {
3084
+ (0, import_log11.log)("accept space", {
2875
3085
  opts
2876
3086
  }, {
2877
- F: __dxlog_file12,
3087
+ F: __dxlog_file13,
2878
3088
  L: 147,
2879
3089
  S: this,
2880
3090
  C: (f, a) => f(...a)
2881
3091
  });
2882
- (0, import_invariant10.invariant)(this._isOpen, "Not open.", {
2883
- F: __dxlog_file12,
3092
+ (0, import_invariant11.invariant)(this._isOpen, "Not open.", {
3093
+ F: __dxlog_file13,
2884
3094
  L: 148,
2885
3095
  S: this,
2886
3096
  A: [
@@ -2888,8 +3098,8 @@ var DataSpaceManager = class DataSpaceManager2 {
2888
3098
  "'Not open.'"
2889
3099
  ]
2890
3100
  });
2891
- (0, import_invariant10.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
2892
- F: __dxlog_file12,
3101
+ (0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
3102
+ F: __dxlog_file13,
2893
3103
  L: 149,
2894
3104
  S: this,
2895
3105
  A: [
@@ -2915,16 +3125,16 @@ var DataSpaceManager = class DataSpaceManager2 {
2915
3125
  * TODO(dmaretskyi): Consider removing.
2916
3126
  */
2917
3127
  async waitUntilSpaceReady(spaceKey) {
2918
- await (0, import_context6.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
3128
+ await (0, import_context7.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
2919
3129
  const space = this._spaces.get(spaceKey);
2920
- return !!space && space.state === import_services7.SpaceState.READY;
3130
+ return !!space && space.state === import_services8.SpaceState.READY;
2921
3131
  }));
2922
3132
  }
2923
3133
  async _constructSpace(metadata) {
2924
- (0, import_log10.log)("construct space", {
3134
+ (0, import_log11.log)("construct space", {
2925
3135
  metadata
2926
3136
  }, {
2927
- F: __dxlog_file12,
3137
+ F: __dxlog_file13,
2928
3138
  L: 182,
2929
3139
  S: this,
2930
3140
  C: (f, a) => f(...a)
@@ -2959,8 +3169,8 @@ var DataSpaceManager = class DataSpaceManager2 {
2959
3169
  session.addExtension("dxos.mesh.teleport.notarization", dataSpace.notarizationPlugin.createExtension());
2960
3170
  },
2961
3171
  onAuthFailure: () => {
2962
- import_log10.log.warn("auth failure", void 0, {
2963
- F: __dxlog_file12,
3172
+ import_log11.log.warn("auth failure", void 0, {
3173
+ F: __dxlog_file13,
2964
3174
  L: 213,
2965
3175
  S: this,
2966
3176
  C: (f, a) => f(...a)
@@ -2972,7 +3182,7 @@ var DataSpaceManager = class DataSpaceManager2 {
2972
3182
  dataFeed && space.setDataFeed(dataFeed);
2973
3183
  const dataSpace = new DataSpace({
2974
3184
  inner: space,
2975
- initialState: metadata.state === import_services7.SpaceState.INACTIVE ? import_services7.SpaceState.INACTIVE : import_services7.SpaceState.CLOSED,
3185
+ initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
2976
3186
  metadataStore: this._metadataStore,
2977
3187
  gossip,
2978
3188
  presence,
@@ -2981,10 +3191,10 @@ var DataSpaceManager = class DataSpaceManager2 {
2981
3191
  signingContext: this._signingContext,
2982
3192
  callbacks: {
2983
3193
  beforeReady: async () => {
2984
- (0, import_log10.log)("before space ready", {
3194
+ (0, import_log11.log)("before space ready", {
2985
3195
  space: space.key
2986
3196
  }, {
2987
- F: __dxlog_file12,
3197
+ F: __dxlog_file13,
2988
3198
  L: 231,
2989
3199
  S: this,
2990
3200
  C: (f, a) => f(...a)
@@ -2992,11 +3202,11 @@ var DataSpaceManager = class DataSpaceManager2 {
2992
3202
  await this._dataServiceSubscriptions.registerSpace(space.key, dataSpace.dataPipeline.databaseHost.createDataServiceHost());
2993
3203
  },
2994
3204
  afterReady: async () => {
2995
- (0, import_log10.log)("after space ready", {
3205
+ (0, import_log11.log)("after space ready", {
2996
3206
  space: space.key,
2997
3207
  open: this._isOpen
2998
3208
  }, {
2999
- F: __dxlog_file12,
3209
+ F: __dxlog_file13,
3000
3210
  L: 238,
3001
3211
  S: this,
3002
3212
  C: (f, a) => f(...a)
@@ -3006,10 +3216,10 @@ var DataSpaceManager = class DataSpaceManager2 {
3006
3216
  }
3007
3217
  },
3008
3218
  beforeClose: async () => {
3009
- (0, import_log10.log)("before space close", {
3219
+ (0, import_log11.log)("before space close", {
3010
3220
  space: space.key
3011
3221
  }, {
3012
- F: __dxlog_file12,
3222
+ F: __dxlog_file13,
3013
3223
  L: 244,
3014
3224
  S: this,
3015
3225
  C: (f, a) => f(...a)
@@ -3019,7 +3229,7 @@ var DataSpaceManager = class DataSpaceManager2 {
3019
3229
  },
3020
3230
  cache: metadata.cache
3021
3231
  });
3022
- if (metadata.state !== import_services7.SpaceState.INACTIVE) {
3232
+ if (metadata.state !== import_services8.SpaceState.INACTIVE) {
3023
3233
  await dataSpace.open();
3024
3234
  }
3025
3235
  if (metadata.controlTimeframe) {
@@ -3032,33 +3242,33 @@ var DataSpaceManager = class DataSpaceManager2 {
3032
3242
  return dataSpace;
3033
3243
  }
3034
3244
  };
3035
- _ts_decorate2([
3245
+ _ts_decorate4([
3036
3246
  import_async9.synchronized
3037
3247
  ], DataSpaceManager.prototype, "open", null);
3038
- _ts_decorate2([
3248
+ _ts_decorate4([
3039
3249
  import_async9.synchronized
3040
3250
  ], DataSpaceManager.prototype, "close", null);
3041
- _ts_decorate2([
3251
+ _ts_decorate4([
3042
3252
  import_async9.synchronized
3043
3253
  ], DataSpaceManager.prototype, "createSpace", null);
3044
- _ts_decorate2([
3254
+ _ts_decorate4([
3045
3255
  import_async9.synchronized
3046
3256
  ], DataSpaceManager.prototype, "acceptSpace", null);
3047
- DataSpaceManager = _ts_decorate2([
3257
+ DataSpaceManager = _ts_decorate4([
3048
3258
  (0, import_async9.trackLeaks)("open", "close")
3049
3259
  ], DataSpaceManager);
3050
3260
 
3051
3261
  // packages/sdk/client-services/src/packlets/spaces/spaces-service.ts
3052
3262
  var import_async10 = require("@dxos/async");
3053
- var import_codec_protobuf4 = require("@dxos/codec-protobuf");
3263
+ var import_codec_protobuf5 = require("@dxos/codec-protobuf");
3054
3264
  var import_debug6 = require("@dxos/debug");
3055
3265
  var import_echo_pipeline2 = require("@dxos/echo-pipeline");
3056
3266
  var import_errors4 = require("@dxos/errors");
3057
- var import_log11 = require("@dxos/log");
3058
- var import_protocols7 = require("@dxos/protocols");
3059
- var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
3267
+ var import_log12 = require("@dxos/log");
3268
+ var import_protocols8 = require("@dxos/protocols");
3269
+ var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
3060
3270
  var import_util5 = require("@dxos/util");
3061
- var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3271
+ var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
3062
3272
  var SpacesServiceImpl = class {
3063
3273
  constructor(_identityManager, _spaceManager, _dataServiceSubscriptions, _getDataSpaceManager) {
3064
3274
  this._identityManager = _identityManager;
@@ -3080,10 +3290,10 @@ var SpacesServiceImpl = class {
3080
3290
  const space = (_a = dataSpaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3081
3291
  if (state) {
3082
3292
  switch (state) {
3083
- case import_services8.SpaceState.ACTIVE:
3293
+ case import_services9.SpaceState.ACTIVE:
3084
3294
  await space.activate();
3085
3295
  break;
3086
- case import_services8.SpaceState.INACTIVE:
3296
+ case import_services9.SpaceState.INACTIVE:
3087
3297
  await space.deactivate();
3088
3298
  break;
3089
3299
  default:
@@ -3092,14 +3302,14 @@ var SpacesServiceImpl = class {
3092
3302
  }
3093
3303
  }
3094
3304
  querySpaces() {
3095
- return new import_codec_protobuf4.Stream(({ next, ctx }) => {
3305
+ return new import_codec_protobuf5.Stream(({ next, ctx }) => {
3096
3306
  const scheduler = new import_async10.UpdateScheduler(ctx, async () => {
3097
3307
  const dataSpaceManager = await this._getDataSpaceManager();
3098
3308
  const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
3099
- (0, import_log11.log)("update", {
3309
+ (0, import_log12.log)("update", {
3100
3310
  spaces
3101
3311
  }, {
3102
- F: __dxlog_file13,
3312
+ F: __dxlog_file14,
3103
3313
  L: 78,
3104
3314
  S: this,
3105
3315
  C: (f, a) => f(...a)
@@ -3147,7 +3357,7 @@ var SpacesServiceImpl = class {
3147
3357
  await space.postMessage(getChannelId(channel), message);
3148
3358
  }
3149
3359
  subscribeMessages({ spaceKey, channel }) {
3150
- return new import_codec_protobuf4.Stream(({ ctx, next }) => {
3360
+ return new import_codec_protobuf5.Stream(({ ctx, next }) => {
3151
3361
  (0, import_async10.scheduleTask)(ctx, async () => {
3152
3362
  var _a;
3153
3363
  const dataSpaceManager = await this._getDataSpaceManager();
@@ -3160,7 +3370,7 @@ var SpacesServiceImpl = class {
3160
3370
  });
3161
3371
  }
3162
3372
  queryCredentials({ spaceKey }) {
3163
- return new import_codec_protobuf4.Stream(({ ctx, next }) => {
3373
+ return new import_codec_protobuf5.Stream(({ ctx, next }) => {
3164
3374
  var _a;
3165
3375
  const space = (_a = this._spaceManager.spaces.get(spaceKey)) != null ? _a : (0, import_debug6.raise)(new import_echo_pipeline2.SpaceNotFoundError(spaceKey));
3166
3376
  const processor = {
@@ -3194,7 +3404,7 @@ var SpacesServiceImpl = class {
3194
3404
  return {
3195
3405
  spaceKey: space.key,
3196
3406
  state: space.state,
3197
- error: space.error ? (0, import_protocols7.encodeError)(space.error) : void 0,
3407
+ error: space.error ? (0, import_protocols8.encodeError)(space.error) : void 0,
3198
3408
  pipeline: {
3199
3409
  currentEpoch: space.dataPipeline.currentEpoch,
3200
3410
  appliedEpoch: space.dataPipeline.appliedEpoch,
@@ -3222,7 +3432,7 @@ var SpacesServiceImpl = class {
3222
3432
  displayName: (_c2 = (_b2 = member.assertion.profile) == null ? void 0 : _b2.displayName) != null ? _c2 : (0, import_util5.humanize)(member.key)
3223
3433
  }
3224
3434
  },
3225
- presence: isMe || peers.length > 0 ? import_services8.SpaceMember.PresenceState.ONLINE : import_services8.SpaceMember.PresenceState.OFFLINE,
3435
+ presence: isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
3226
3436
  peerStates: peers
3227
3437
  };
3228
3438
  }),
@@ -3235,8 +3445,18 @@ var SpacesServiceImpl = class {
3235
3445
  var getChannelId = (channel) => `user-channel/${channel}`;
3236
3446
 
3237
3447
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3238
- var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3239
- var ServiceContext = class {
3448
+ function _ts_decorate5(decorators, target, key, desc) {
3449
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3450
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3451
+ r = Reflect.decorate(decorators, target, key, desc);
3452
+ else
3453
+ for (var i = decorators.length - 1; i >= 0; i--)
3454
+ if (d = decorators[i])
3455
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3456
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
3457
+ }
3458
+ var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
3459
+ var ServiceContext = class ServiceContext2 {
3240
3460
  // prettier-ignore
3241
3461
  constructor(storage, networkManager, signalManager, modelFactory) {
3242
3462
  this.storage = storage;
@@ -3270,54 +3490,54 @@ var ServiceContext = class {
3270
3490
  });
3271
3491
  this.identityManager = new IdentityManager(this.metadataStore, this.keyring, this.feedStore, this.spaceManager);
3272
3492
  this.invitations = new InvitationsHandler(this.networkManager);
3273
- this._handlerFactories.set(import_services9.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3493
+ this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => {
3274
3494
  var _a;
3275
3495
  return (_a = this.identityManager.identity) != null ? _a : (0, import_debug7.failUndefined)();
3276
3496
  }, this._acceptIdentity.bind(this)));
3277
3497
  }
3278
- async open() {
3279
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.begin({
3280
- id: this._instanceId
3281
- }), {
3282
- F: __dxlog_file14,
3283
- L: 125,
3498
+ async open(ctx) {
3499
+ await this._checkStorageVersion();
3500
+ (0, import_log13.log)("opening...", void 0, {
3501
+ F: __dxlog_file15,
3502
+ L: 131,
3284
3503
  S: this,
3285
3504
  C: (f, a) => f(...a)
3286
3505
  });
3287
- await this._checkStorageVersion();
3288
- (0, import_log12.log)("opening...", void 0, {
3289
- F: __dxlog_file14,
3290
- L: 129,
3506
+ import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.begin({
3507
+ id: this._instanceId
3508
+ }), {
3509
+ F: __dxlog_file15,
3510
+ L: 132,
3291
3511
  S: this,
3292
3512
  C: (f, a) => f(...a)
3293
3513
  });
3294
3514
  await this.signalManager.open();
3295
3515
  await this.networkManager.open();
3296
3516
  await this.spaceManager.open();
3297
- await this.identityManager.open();
3517
+ await this.identityManager.open(ctx);
3298
3518
  if (this.identityManager.identity) {
3299
- await this._initialize();
3519
+ await this._initialize(ctx);
3300
3520
  }
3301
- (0, import_log12.log)("opened", void 0, {
3302
- F: __dxlog_file14,
3303
- L: 137,
3521
+ import_log13.log.trace("dxos.sdk.service-context.open", import_protocols9.trace.end({
3522
+ id: this._instanceId
3523
+ }), {
3524
+ F: __dxlog_file15,
3525
+ L: 140,
3304
3526
  S: this,
3305
3527
  C: (f, a) => f(...a)
3306
3528
  });
3307
- import_log12.log.trace("dxos.sdk.service-context.open", import_protocols8.trace.end({
3308
- id: this._instanceId
3309
- }), {
3310
- F: __dxlog_file14,
3311
- L: 138,
3529
+ (0, import_log13.log)("opened", void 0, {
3530
+ F: __dxlog_file15,
3531
+ L: 141,
3312
3532
  S: this,
3313
3533
  C: (f, a) => f(...a)
3314
3534
  });
3315
3535
  }
3316
3536
  async close() {
3317
3537
  var _a;
3318
- (0, import_log12.log)("closing...", void 0, {
3319
- F: __dxlog_file14,
3320
- L: 142,
3538
+ (0, import_log13.log)("closing...", void 0, {
3539
+ F: __dxlog_file15,
3540
+ L: 145,
3321
3541
  S: this,
3322
3542
  C: (f, a) => f(...a)
3323
3543
  });
@@ -3331,23 +3551,23 @@ var ServiceContext = class {
3331
3551
  await this.networkManager.close();
3332
3552
  await this.signalManager.close();
3333
3553
  this.dataServiceSubscriptions.clear();
3334
- (0, import_log12.log)("closed", void 0, {
3335
- F: __dxlog_file14,
3336
- L: 153,
3554
+ (0, import_log13.log)("closed", void 0, {
3555
+ F: __dxlog_file15,
3556
+ L: 156,
3337
3557
  S: this,
3338
3558
  C: (f, a) => f(...a)
3339
3559
  });
3340
3560
  }
3341
3561
  async createIdentity(params = {}) {
3342
3562
  const identity = await this.identityManager.createIdentity(params);
3343
- await this._initialize();
3563
+ await this._initialize(new import_context8.Context());
3344
3564
  return identity;
3345
3565
  }
3346
3566
  getInvitationHandler(invitation) {
3347
3567
  const factory = this._handlerFactories.get(invitation.kind);
3348
- (0, import_invariant11.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
3349
- F: __dxlog_file14,
3350
- L: 165,
3568
+ (0, import_invariant12.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
3569
+ F: __dxlog_file15,
3570
+ L: 168,
3351
3571
  S: this,
3352
3572
  A: [
3353
3573
  "factory",
@@ -3358,21 +3578,21 @@ var ServiceContext = class {
3358
3578
  }
3359
3579
  async _acceptIdentity(params) {
3360
3580
  const identity = await this.identityManager.acceptIdentity(params);
3361
- await this._initialize();
3581
+ await this._initialize(new import_context8.Context());
3362
3582
  return identity;
3363
3583
  }
3364
3584
  async _checkStorageVersion() {
3365
3585
  await this.metadataStore.load();
3366
- if (this.metadataStore.version !== import_protocols8.STORAGE_VERSION) {
3367
- throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols8.STORAGE_VERSION}`);
3586
+ if (this.metadataStore.version !== import_protocols9.STORAGE_VERSION) {
3587
+ throw new Error(`Invalid storage version: current=${this.metadataStore.version}, expected=${import_protocols9.STORAGE_VERSION}`);
3368
3588
  }
3369
3589
  }
3370
3590
  // Called when identity is created.
3371
- async _initialize() {
3591
+ async _initialize(ctx) {
3372
3592
  var _a;
3373
- (0, import_log12.log)("initializing spaces...", void 0, {
3374
- F: __dxlog_file14,
3375
- L: 186,
3593
+ (0, import_log13.log)("initializing spaces...", void 0, {
3594
+ F: __dxlog_file15,
3595
+ L: 190,
3376
3596
  S: this,
3377
3597
  C: (f, a) => f(...a)
3378
3598
  });
@@ -3392,10 +3612,10 @@ var ServiceContext = class {
3392
3612
  };
3393
3613
  this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.dataServiceSubscriptions, this.keyring, signingContext, this.feedStore);
3394
3614
  await this.dataSpaceManager.open();
3395
- this._handlerFactories.set(import_services9.Invitation.Kind.SPACE, (invitation) => {
3396
- (0, import_invariant11.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3397
- F: __dxlog_file14,
3398
- L: 209,
3615
+ this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
3616
+ (0, import_invariant12.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
3617
+ F: __dxlog_file15,
3618
+ L: 213,
3399
3619
  S: this,
3400
3620
  A: [
3401
3621
  "this.dataSpaceManager",
@@ -3407,7 +3627,7 @@ var ServiceContext = class {
3407
3627
  this.initialized.wake();
3408
3628
  this._deviceSpaceSync = {
3409
3629
  processCredential: async (credential) => {
3410
- const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
3630
+ const assertion = (0, import_credentials15.getCredentialAssertion)(credential);
3411
3631
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
3412
3632
  return;
3413
3633
  }
@@ -3415,33 +3635,33 @@ var ServiceContext = class {
3415
3635
  return;
3416
3636
  }
3417
3637
  if (!this.dataSpaceManager) {
3418
- (0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
3638
+ (0, import_log13.log)("dataSpaceManager not initialized yet, ignoring space admission", {
3419
3639
  details: assertion
3420
3640
  }, {
3421
- F: __dxlog_file14,
3422
- L: 225,
3641
+ F: __dxlog_file15,
3642
+ L: 229,
3423
3643
  S: this,
3424
3644
  C: (f, a) => f(...a)
3425
3645
  });
3426
3646
  return;
3427
3647
  }
3428
3648
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
3429
- (0, import_log12.log)("space already exists, ignoring space admission", {
3649
+ (0, import_log13.log)("space already exists, ignoring space admission", {
3430
3650
  details: assertion
3431
3651
  }, {
3432
- F: __dxlog_file14,
3433
- L: 229,
3652
+ F: __dxlog_file15,
3653
+ L: 233,
3434
3654
  S: this,
3435
3655
  C: (f, a) => f(...a)
3436
3656
  });
3437
3657
  return;
3438
3658
  }
3439
3659
  try {
3440
- (0, import_log12.log)("accepting space recorded in halo", {
3660
+ (0, import_log13.log)("accepting space recorded in halo", {
3441
3661
  details: assertion
3442
3662
  }, {
3443
- F: __dxlog_file14,
3444
- L: 234,
3663
+ F: __dxlog_file15,
3664
+ L: 238,
3445
3665
  S: this,
3446
3666
  C: (f, a) => f(...a)
3447
3667
  });
@@ -3450,9 +3670,9 @@ var ServiceContext = class {
3450
3670
  genesisFeedKey: assertion.genesisFeedKey
3451
3671
  });
3452
3672
  } catch (err) {
3453
- import_log12.log.catch(err, void 0, {
3454
- F: __dxlog_file14,
3455
- L: 240,
3673
+ import_log13.log.catch(err, void 0, {
3674
+ F: __dxlog_file15,
3675
+ L: 244,
3456
3676
  S: this,
3457
3677
  C: (f, a) => f(...a)
3458
3678
  });
@@ -3462,26 +3682,37 @@ var ServiceContext = class {
3462
3682
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
3463
3683
  }
3464
3684
  };
3685
+ _ts_decorate5([
3686
+ import_tracing3.trace.span()
3687
+ ], ServiceContext.prototype, "open", null);
3688
+ _ts_decorate5([
3689
+ import_tracing3.trace.span()
3690
+ ], ServiceContext.prototype, "_initialize", null);
3691
+ ServiceContext = _ts_decorate5([
3692
+ import_tracing3.trace.resource()
3693
+ ], ServiceContext);
3465
3694
 
3466
3695
  // packages/sdk/client-services/src/packlets/services/service-host.ts
3467
3696
  var import_async17 = require("@dxos/async");
3468
3697
  var import_client_protocol5 = require("@dxos/client-protocol");
3469
- var import_document_model = require("@dxos/document-model");
3698
+ var import_context10 = require("@dxos/context");
3699
+ var import_document_model2 = require("@dxos/document-model");
3470
3700
  var import_echo_pipeline4 = require("@dxos/echo-pipeline");
3471
- var import_invariant13 = require("@dxos/invariant");
3701
+ var import_invariant14 = require("@dxos/invariant");
3472
3702
  var import_keys12 = require("@dxos/keys");
3473
- var import_log15 = require("@dxos/log");
3703
+ var import_log16 = require("@dxos/log");
3474
3704
  var import_messaging = require("@dxos/messaging");
3475
3705
  var import_model_factory = require("@dxos/model-factory");
3476
3706
  var import_network_manager2 = require("@dxos/network-manager");
3477
- var import_protocols9 = require("@dxos/protocols");
3478
- var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3707
+ var import_protocols10 = require("@dxos/protocols");
3708
+ var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
3479
3709
  var import_text_model = require("@dxos/text-model");
3710
+ var import_tracing4 = require("@dxos/tracing");
3480
3711
 
3481
3712
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
3482
3713
  var import_async12 = require("@dxos/async");
3483
- var import_codec_protobuf5 = require("@dxos/codec-protobuf");
3484
- var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
3714
+ var import_codec_protobuf6 = require("@dxos/codec-protobuf");
3715
+ var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
3485
3716
  var DevicesServiceImpl = class {
3486
3717
  constructor(_identityManager) {
3487
3718
  this._identityManager = _identityManager;
@@ -3490,7 +3721,7 @@ var DevicesServiceImpl = class {
3490
3721
  throw new Error("Method not implemented.");
3491
3722
  }
3492
3723
  queryDevices() {
3493
- return new import_codec_protobuf5.Stream(({ next }) => {
3724
+ return new import_codec_protobuf6.Stream(({ next }) => {
3494
3725
  const update = () => {
3495
3726
  var _a;
3496
3727
  const deviceKeys = (_a = this._identityManager.identity) == null ? void 0 : _a.authorizedDeviceKeys;
@@ -3504,7 +3735,7 @@ var DevicesServiceImpl = class {
3504
3735
  var _a2;
3505
3736
  return {
3506
3737
  deviceKey: key,
3507
- kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services10.DeviceKind.CURRENT : import_services10.DeviceKind.TRUSTED
3738
+ kind: ((_a2 = this._identityManager.identity) == null ? void 0 : _a2.deviceKey.equals(key)) ? import_services11.DeviceKind.CURRENT : import_services11.DeviceKind.TRUSTED
3508
3739
  };
3509
3740
  })
3510
3741
  });
@@ -3527,16 +3758,16 @@ var DevicesServiceImpl = class {
3527
3758
 
3528
3759
  // packages/sdk/client-services/src/packlets/devtools/devtools.ts
3529
3760
  var import_async15 = require("@dxos/async");
3530
- var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3761
+ var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3531
3762
 
3532
3763
  // packages/sdk/client-services/src/packlets/devtools/feeds.ts
3533
3764
  var import_async13 = require("@dxos/async");
3534
- var import_codec_protobuf6 = require("@dxos/codec-protobuf");
3765
+ var import_codec_protobuf7 = require("@dxos/codec-protobuf");
3535
3766
  var import_feed_store4 = require("@dxos/feed-store");
3536
3767
  var import_keys9 = require("@dxos/keys");
3537
3768
  var import_util6 = require("@dxos/util");
3538
3769
  var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
3539
- return new import_codec_protobuf6.Stream(({ next }) => {
3770
+ return new import_codec_protobuf7.Stream(({ next }) => {
3540
3771
  const subscriptions = new import_async13.EventSubscriptions();
3541
3772
  const feedMap = new import_util6.ComplexMap(import_keys9.PublicKey.hash);
3542
3773
  const update = () => {
@@ -3568,7 +3799,7 @@ var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
3568
3799
  });
3569
3800
  };
3570
3801
  var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
3571
- return new import_codec_protobuf6.Stream(({ next }) => {
3802
+ return new import_codec_protobuf7.Stream(({ next }) => {
3572
3803
  if (!feedKey) {
3573
3804
  return;
3574
3805
  }
@@ -3608,8 +3839,8 @@ var subscribeToFeedBlocks = ({ feedStore }, { feedKey, maxBlocks = 10 }) => {
3608
3839
 
3609
3840
  // packages/sdk/client-services/src/packlets/devtools/keys.ts
3610
3841
  var import_async14 = require("@dxos/async");
3611
- var import_codec_protobuf7 = require("@dxos/codec-protobuf");
3612
- var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf7.Stream(({ next, ctx }) => {
3842
+ var import_codec_protobuf8 = require("@dxos/codec-protobuf");
3843
+ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf8.Stream(({ next, ctx }) => {
3613
3844
  const update = async () => {
3614
3845
  next({
3615
3846
  keys: await keyring.list()
@@ -3620,8 +3851,8 @@ var subscribeToKeyringKeys = ({ keyring }) => new import_codec_protobuf7.Stream(
3620
3851
  });
3621
3852
 
3622
3853
  // packages/sdk/client-services/src/packlets/devtools/metadata.ts
3623
- var import_codec_protobuf8 = require("@dxos/codec-protobuf");
3624
- var subscribeToMetadata = ({ context }) => new import_codec_protobuf8.Stream(({ next, ctx }) => {
3854
+ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
3855
+ var subscribeToMetadata = ({ context }) => new import_codec_protobuf9.Stream(({ next, ctx }) => {
3625
3856
  context.metadataStore.update.on(ctx, (data) => next({
3626
3857
  metadata: data
3627
3858
  }));
@@ -3631,10 +3862,10 @@ var subscribeToMetadata = ({ context }) => new import_codec_protobuf8.Stream(({
3631
3862
  });
3632
3863
 
3633
3864
  // packages/sdk/client-services/src/packlets/devtools/network.ts
3634
- var import_codec_protobuf9 = require("@dxos/codec-protobuf");
3635
- var import_context7 = require("@dxos/context");
3865
+ var import_codec_protobuf10 = require("@dxos/codec-protobuf");
3866
+ var import_context9 = require("@dxos/context");
3636
3867
  var import_keys10 = require("@dxos/keys");
3637
- var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf9.Stream(({ next, close }) => {
3868
+ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next, close }) => {
3638
3869
  const update = () => {
3639
3870
  try {
3640
3871
  const status = signalManager.getStatus();
@@ -3648,8 +3879,8 @@ var subscribeToNetworkStatus = ({ signalManager }) => new import_codec_protobuf9
3648
3879
  signalManager.statusChanged.on(() => update());
3649
3880
  update();
3650
3881
  });
3651
- var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf9.Stream(({ next }) => {
3652
- const ctx = new import_context7.Context();
3882
+ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf10.Stream(({ next }) => {
3883
+ const ctx = new import_context9.Context();
3653
3884
  signalManager.onMessage.on(ctx, (message) => {
3654
3885
  next({
3655
3886
  message: {
@@ -3670,7 +3901,7 @@ var subscribeToSignal = ({ signalManager }) => new import_codec_protobuf9.Stream
3670
3901
  return ctx.dispose();
3671
3902
  };
3672
3903
  });
3673
- var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf9.Stream(({ next }) => {
3904
+ var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf10.Stream(({ next }) => {
3674
3905
  var _a;
3675
3906
  const update = () => {
3676
3907
  var _a2;
@@ -3686,9 +3917,9 @@ var subscribeToSwarmInfo = ({ networkManager }) => new import_codec_protobuf9.St
3686
3917
  });
3687
3918
 
3688
3919
  // packages/sdk/client-services/src/packlets/devtools/spaces.ts
3689
- var import_codec_protobuf10 = require("@dxos/codec-protobuf");
3920
+ var import_codec_protobuf11 = require("@dxos/codec-protobuf");
3690
3921
  var subscribeToSpaces = (context, { spaceKeys = [] }) => {
3691
- return new import_codec_protobuf10.Stream(({ next }) => {
3922
+ return new import_codec_protobuf11.Stream(({ next }) => {
3692
3923
  let unsubscribe;
3693
3924
  const update = async () => {
3694
3925
  const spaces = [
@@ -3732,7 +3963,7 @@ var DevtoolsServiceImpl = class {
3732
3963
  this.params = params;
3733
3964
  }
3734
3965
  events(request) {
3735
- return new import_codec_protobuf11.Stream(({ next }) => {
3966
+ return new import_codec_protobuf12.Stream(({ next }) => {
3736
3967
  this.params.events.ready.on(() => {
3737
3968
  next({
3738
3969
  ready: {}
@@ -3839,10 +4070,10 @@ var DevtoolsServiceImpl = class {
3839
4070
  };
3840
4071
 
3841
4072
  // packages/sdk/client-services/src/packlets/locks/node.ts
3842
- var import_invariant12 = require("@dxos/invariant");
4073
+ var import_invariant13 = require("@dxos/invariant");
3843
4074
  var import_lock_file = require("@dxos/lock-file");
3844
- var import_log13 = require("@dxos/log");
3845
- function _ts_decorate3(decorators, target, key, desc) {
4075
+ var import_log14 = require("@dxos/log");
4076
+ function _ts_decorate6(decorators, target, key, desc) {
3846
4077
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3847
4078
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3848
4079
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3852,7 +4083,7 @@ function _ts_decorate3(decorators, target, key, desc) {
3852
4083
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
3853
4084
  return c > 3 && r && Object.defineProperty(target, key, r), r;
3854
4085
  }
3855
- var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
4086
+ var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
3856
4087
  var Lock = class {
3857
4088
  constructor({ lockKey: lockPath, onAcquire, onRelease }) {
3858
4089
  this._lockPath = lockPath;
@@ -3864,16 +4095,16 @@ var Lock = class {
3864
4095
  }
3865
4096
  async acquire() {
3866
4097
  var _a;
3867
- (0, import_log13.log)("acquiring lock...", void 0, {
3868
- F: __dxlog_file15,
4098
+ (0, import_log14.log)("acquiring lock...", void 0, {
4099
+ F: __dxlog_file16,
3869
4100
  L: 32,
3870
4101
  S: this,
3871
4102
  C: (f, a) => f(...a)
3872
4103
  });
3873
4104
  this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
3874
4105
  await ((_a = this._onAcquire) == null ? void 0 : _a.call(this));
3875
- (0, import_log13.log)("acquired lock", void 0, {
3876
- F: __dxlog_file15,
4106
+ (0, import_log14.log)("acquired lock", void 0, {
4107
+ F: __dxlog_file16,
3877
4108
  L: 37,
3878
4109
  S: this,
3879
4110
  C: (f, a) => f(...a)
@@ -3882,8 +4113,8 @@ var Lock = class {
3882
4113
  async release() {
3883
4114
  var _a;
3884
4115
  await ((_a = this._onRelease) == null ? void 0 : _a.call(this));
3885
- (0, import_invariant12.invariant)(this._fileHandle, "Lock is not acquired", {
3886
- F: __dxlog_file15,
4116
+ (0, import_invariant13.invariant)(this._fileHandle, "Lock is not acquired", {
4117
+ F: __dxlog_file16,
3887
4118
  L: 42,
3888
4119
  S: this,
3889
4120
  A: [
@@ -3894,29 +4125,30 @@ var Lock = class {
3894
4125
  await import_lock_file.LockFile.release(this._fileHandle);
3895
4126
  }
3896
4127
  };
3897
- _ts_decorate3([
3898
- import_log13.logInfo
4128
+ _ts_decorate6([
4129
+ import_log14.logInfo
3899
4130
  ], Lock.prototype, "lockKey", null);
3900
4131
 
3901
4132
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
3902
4133
  var import_async16 = require("@dxos/async");
3903
- var import_codec_protobuf12 = require("@dxos/codec-protobuf");
3904
- var import_log14 = require("@dxos/log");
3905
- var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
4134
+ var import_codec_protobuf13 = require("@dxos/codec-protobuf");
4135
+ var import_log15 = require("@dxos/log");
4136
+ var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
3906
4137
  var import_util7 = require("@dxos/util");
3907
4138
  var LoggingServiceImpl = class {
3908
4139
  constructor() {
3909
4140
  this._logs = new import_async16.Event();
4141
+ this._started = new Date();
3910
4142
  this._logProcessor = (_config, entry2) => {
3911
4143
  this._logs.emit(entry2);
3912
4144
  };
3913
4145
  }
3914
4146
  async open() {
3915
- import_log14.log.runtimeConfig.processors.push(this._logProcessor);
4147
+ import_log15.log.runtimeConfig.processors.push(this._logProcessor);
3916
4148
  }
3917
4149
  async close() {
3918
- const index = import_log14.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
3919
- import_log14.log.runtimeConfig.processors.splice(index, 1);
4150
+ const index = import_log15.log.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
4151
+ import_log15.log.runtimeConfig.processors.splice(index, 1);
3920
4152
  }
3921
4153
  async controlMetrics({ reset, record }) {
3922
4154
  if (reset) {
@@ -3931,35 +4163,41 @@ var LoggingServiceImpl = class {
3931
4163
  recording: import_util7.tracer.recording
3932
4164
  };
3933
4165
  }
3934
- queryMetrics({ interval }) {
3935
- const createNumericalValues = (key) => {
4166
+ /**
4167
+ * @deprecated (Move to diagnostics).
4168
+ */
4169
+ queryMetrics({ interval = 5e3 }) {
4170
+ const getNumericalValues = (key) => {
3936
4171
  var _a;
3937
- const consume = (_a = import_util7.tracer.get(key)) != null ? _a : [];
4172
+ const events = (_a = import_util7.tracer.get(key)) != null ? _a : [];
3938
4173
  return {
3939
4174
  key,
3940
- stats: (0, import_util7.numericalValues)(consume, "duration")
4175
+ stats: (0, import_util7.numericalValues)(events, "duration")
3941
4176
  };
3942
4177
  };
3943
- return new import_codec_protobuf12.Stream(({ next }) => {
4178
+ return new import_codec_protobuf13.Stream(({ next }) => {
3944
4179
  const update = () => {
3945
4180
  const metrics = {
3946
4181
  timestamp: new Date(),
3947
4182
  values: [
3948
- createNumericalValues("dxos.echo.pipeline.control"),
3949
- createNumericalValues("dxos.echo.pipeline.data")
3950
- ]
4183
+ getNumericalValues("dxos.echo.pipeline.control"),
4184
+ getNumericalValues("dxos.echo.pipeline.data")
4185
+ ].filter(Boolean)
3951
4186
  };
3952
- next(metrics);
4187
+ next({
4188
+ timestamp: new Date(),
4189
+ metrics
4190
+ });
3953
4191
  };
3954
4192
  update();
3955
- const i = setInterval(update, interval);
4193
+ const i = setInterval(update, Math.max(interval, 1e3));
3956
4194
  return () => {
3957
4195
  clearInterval(i);
3958
4196
  };
3959
4197
  });
3960
4198
  }
3961
4199
  queryLogs(request) {
3962
- return new import_codec_protobuf12.Stream(({ ctx, next }) => {
4200
+ return new import_codec_protobuf13.Stream(({ ctx, next }) => {
3963
4201
  const handler = (entry2) => {
3964
4202
  var _a, _b, _c, _d, _e;
3965
4203
  if (LOG_PROCESSING > 0) {
@@ -3973,7 +4211,7 @@ var LoggingServiceImpl = class {
3973
4211
  }
3974
4212
  const record = {
3975
4213
  ...entry2,
3976
- context: (0, import_util7.jsonify)((0, import_log14.getContextFromEntry)(entry2)),
4214
+ context: (0, import_util7.jsonify)((0, import_log15.getContextFromEntry)(entry2)),
3977
4215
  timestamp: new Date(),
3978
4216
  meta: {
3979
4217
  // TODO(dmaretskyi): Fix proto.
@@ -3994,17 +4232,17 @@ var LoggingServiceImpl = class {
3994
4232
  };
3995
4233
  var matchFilter = (filter, level, path, options) => {
3996
4234
  switch (options) {
3997
- case import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE:
4235
+ case import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE:
3998
4236
  return level >= filter.level && (!filter.pattern || path.includes(filter.pattern));
3999
- case import_services11.QueryLogsRequest.MatchingOptions.EXPLICIT:
4237
+ case import_services12.QueryLogsRequest.MatchingOptions.EXPLICIT:
4000
4238
  return level === filter.level && (!filter.pattern || path.includes(filter.pattern));
4001
4239
  }
4002
4240
  };
4003
4241
  var shouldLog = (entry2, request) => {
4004
4242
  var _a;
4005
- const options = (_a = request.options) != null ? _a : import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4243
+ const options = (_a = request.options) != null ? _a : import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4006
4244
  if (request.filters === void 0) {
4007
- return options === import_services11.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4245
+ return options === import_services12.QueryLogsRequest.MatchingOptions.INCLUSIVE;
4008
4246
  } else {
4009
4247
  return request.filters.some((filter) => {
4010
4248
  var _a2, _b;
@@ -4015,14 +4253,14 @@ var shouldLog = (entry2, request) => {
4015
4253
  var LOG_PROCESSING = 0;
4016
4254
 
4017
4255
  // packages/sdk/client-services/src/packlets/network/network-service.ts
4018
- var import_codec_protobuf13 = require("@dxos/codec-protobuf");
4256
+ var import_codec_protobuf14 = require("@dxos/codec-protobuf");
4019
4257
  var NetworkServiceImpl = class {
4020
4258
  constructor(networkManager, signalManager) {
4021
4259
  this.networkManager = networkManager;
4022
4260
  this.signalManager = signalManager;
4023
4261
  }
4024
4262
  queryStatus() {
4025
- return new import_codec_protobuf13.Stream(({ next }) => {
4263
+ return new import_codec_protobuf14.Stream(({ next }) => {
4026
4264
  const update = () => {
4027
4265
  next({
4028
4266
  swarm: this.networkManager.connectionState,
@@ -4096,12 +4334,15 @@ var toStorageType = (type) => {
4096
4334
  };
4097
4335
 
4098
4336
  // packages/sdk/client-services/src/packlets/system/system-service.ts
4099
- var import_codec_protobuf14 = require("@dxos/codec-protobuf");
4337
+ var import_codec_protobuf15 = require("@dxos/codec-protobuf");
4338
+ var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
4339
+ var import_util9 = require("@dxos/util");
4100
4340
  var SystemServiceImpl = class {
4101
- constructor({ config, statusUpdate, onUpdateStatus, getCurrentStatus, onReset }) {
4341
+ constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
4102
4342
  this._config = config;
4103
4343
  this._statusUpdate = statusUpdate;
4104
4344
  this._getCurrentStatus = getCurrentStatus;
4345
+ this._getDiagnostics = getDiagnostics;
4105
4346
  this._onUpdateStatus = onUpdateStatus;
4106
4347
  this._onReset = onReset;
4107
4348
  }
@@ -4109,12 +4350,25 @@ var SystemServiceImpl = class {
4109
4350
  var _a, _b;
4110
4351
  return (_b = (_a = this._config) == null ? void 0 : _a.values) != null ? _b : {};
4111
4352
  }
4353
+ /**
4354
+ * NOTE: Since this is serialized as a JSON object, we allow the option to serialize keys.
4355
+ */
4356
+ async getDiagnostics({ keys } = {}) {
4357
+ const diagnostics = await this._getDiagnostics();
4358
+ return {
4359
+ timestamp: new Date(),
4360
+ diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util9.jsonKeyReplacer)({
4361
+ truncate: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
4362
+ humanize: keys === import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
4363
+ })))
4364
+ };
4365
+ }
4112
4366
  async updateStatus({ status }) {
4113
4367
  await this._onUpdateStatus(status);
4114
4368
  }
4115
4369
  // TODO(burdon): Standardize interval option in stream request?
4116
4370
  queryStatus({ interval = 3e3 } = {}) {
4117
- return new import_codec_protobuf14.Stream(({ next }) => {
4371
+ return new import_codec_protobuf15.Stream(({ next }) => {
4118
4372
  const update = () => {
4119
4373
  next({
4120
4374
  status: this._getCurrentStatus()
@@ -4159,7 +4413,7 @@ var ServiceRegistry = class {
4159
4413
  };
4160
4414
 
4161
4415
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4162
- function _ts_decorate4(decorators, target, key, desc) {
4416
+ function _ts_decorate7(decorators, target, key, desc) {
4163
4417
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4164
4418
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4165
4419
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4169,23 +4423,22 @@ function _ts_decorate4(decorators, target, key, desc) {
4169
4423
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
4170
4424
  return c > 3 && r && Object.defineProperty(target, key, r), r;
4171
4425
  }
4172
- var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
4426
+ var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
4173
4427
  var createDefaultModelFactory = () => {
4174
- return new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel).registerModel(import_text_model.TextModel);
4428
+ return new import_model_factory.ModelFactory().registerModel(import_document_model2.DocumentModel).registerModel(import_text_model.TextModel);
4175
4429
  };
4176
- var ClientServicesHost = class {
4430
+ var ClientServicesHost = class ClientServicesHost2 {
4177
4431
  constructor({
4178
4432
  config,
4179
4433
  modelFactory = createDefaultModelFactory(),
4180
- // TODO(burdon): Create ApolloLink abstraction (see Client).
4181
4434
  transportFactory,
4182
4435
  signalManager,
4183
- connectionLog,
4184
4436
  storage,
4185
4437
  // TODO(wittjosiah): Turn this on by default.
4186
4438
  lockKey,
4187
4439
  callbacks
4188
4440
  } = {}) {
4441
+ this._tracingService = import_tracing4.TRACE_PROCESSOR.createTraceSender();
4189
4442
  this._statusUpdate = new import_async17.Event();
4190
4443
  this._opening = false;
4191
4444
  this._open = false;
@@ -4204,7 +4457,7 @@ var ClientServicesHost = class {
4204
4457
  lockKey,
4205
4458
  onAcquire: () => {
4206
4459
  if (!this._opening) {
4207
- void this.open();
4460
+ void this.open(new import_context10.Context());
4208
4461
  }
4209
4462
  },
4210
4463
  onRelease: () => this.close()
@@ -4213,12 +4466,15 @@ var ClientServicesHost = class {
4213
4466
  this._systemService = new SystemServiceImpl({
4214
4467
  config: this._config,
4215
4468
  statusUpdate: this._statusUpdate,
4216
- getCurrentStatus: () => this.isOpen ? import_services12.SystemStatus.ACTIVE : import_services12.SystemStatus.INACTIVE,
4469
+ getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
4470
+ getDiagnostics: () => {
4471
+ return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
4472
+ },
4217
4473
  onUpdateStatus: async (status) => {
4218
4474
  var _a, _b;
4219
- if (!this.isOpen && status === import_services12.SystemStatus.ACTIVE) {
4475
+ if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
4220
4476
  await ((_a = this._resourceLock) == null ? void 0 : _a.acquire());
4221
- } else if (this.isOpen && status === import_services12.SystemStatus.INACTIVE) {
4477
+ } else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
4222
4478
  await ((_b = this._resourceLock) == null ? void 0 : _b.release());
4223
4479
  }
4224
4480
  },
@@ -4228,12 +4484,19 @@ var ClientServicesHost = class {
4228
4484
  });
4229
4485
  this._loggingService = new LoggingServiceImpl();
4230
4486
  this._serviceRegistry = new ServiceRegistry(import_client_protocol5.clientServiceBundle, {
4231
- SystemService: this._systemService
4487
+ SystemService: this._systemService,
4488
+ TracingService: this._tracingService
4232
4489
  });
4233
4490
  }
4234
4491
  get isOpen() {
4235
4492
  return this._open;
4236
4493
  }
4494
+ get config() {
4495
+ return this._config;
4496
+ }
4497
+ get context() {
4498
+ return this._serviceContext;
4499
+ }
4237
4500
  get serviceRegistry() {
4238
4501
  return this._serviceRegistry;
4239
4502
  }
@@ -4250,19 +4513,25 @@ var ClientServicesHost = class {
4250
4513
  */
4251
4514
  initialize({ config, ...options }) {
4252
4515
  var _a, _b, _c;
4253
- (0, import_invariant13.invariant)(!this._open, "service host is open", {
4254
- F: __dxlog_file16,
4255
- L: 167,
4516
+ (0, import_invariant14.invariant)(!this._open, "service host is open", {
4517
+ F: __dxlog_file17,
4518
+ L: 181,
4256
4519
  S: this,
4257
4520
  A: [
4258
4521
  "!this._open",
4259
4522
  "'service host is open'"
4260
4523
  ]
4261
4524
  });
4525
+ import_log16.log.info("initializing...", void 0, {
4526
+ F: __dxlog_file17,
4527
+ L: 182,
4528
+ S: this,
4529
+ C: (f, a) => f(...a)
4530
+ });
4262
4531
  if (config) {
4263
- (0, import_invariant13.invariant)(!this._config, "config already set", {
4264
- F: __dxlog_file16,
4265
- L: 170,
4532
+ (0, import_invariant14.invariant)(!this._config, "config already set", {
4533
+ F: __dxlog_file17,
4534
+ L: 185,
4266
4535
  S: this,
4267
4536
  A: [
4268
4537
  "!this._config",
@@ -4278,9 +4547,9 @@ var ClientServicesHost = class {
4278
4547
  iceServers: (_a = this._config) == null ? void 0 : _a.get("runtime.services.ice")
4279
4548
  }), signalManager = new import_messaging.WebsocketSignalManager((_c = (_b = this._config) == null ? void 0 : _b.get("runtime.services.signaling")) != null ? _c : []) } = options;
4280
4549
  this._signalManager = signalManager;
4281
- (0, import_invariant13.invariant)(!this._networkManager, "network manager already set", {
4282
- F: __dxlog_file16,
4283
- L: 187,
4550
+ (0, import_invariant14.invariant)(!this._networkManager, "network manager already set", {
4551
+ F: __dxlog_file17,
4552
+ L: 201,
4284
4553
  S: this,
4285
4554
  A: [
4286
4555
  "!this._networkManager",
@@ -4292,51 +4561,57 @@ var ClientServicesHost = class {
4292
4561
  transportFactory,
4293
4562
  signalManager
4294
4563
  });
4564
+ import_log16.log.info("initialized", void 0, {
4565
+ F: __dxlog_file17,
4566
+ L: 208,
4567
+ S: this,
4568
+ C: (f, a) => f(...a)
4569
+ });
4295
4570
  }
4296
- async open() {
4571
+ async open(ctx) {
4297
4572
  var _a, _b, _c;
4298
4573
  if (this._open) {
4299
4574
  return;
4300
4575
  }
4301
4576
  const traceId = import_keys12.PublicKey.random().toHex();
4302
- import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.begin({
4577
+ import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.begin({
4303
4578
  id: traceId
4304
4579
  }), {
4305
- F: __dxlog_file16,
4306
- L: 202,
4580
+ F: __dxlog_file17,
4581
+ L: 219,
4307
4582
  S: this,
4308
4583
  C: (f, a) => f(...a)
4309
4584
  });
4310
- (0, import_invariant13.invariant)(this._config, "config not set", {
4311
- F: __dxlog_file16,
4312
- L: 204,
4585
+ (0, import_invariant14.invariant)(this._config, "config not set", {
4586
+ F: __dxlog_file17,
4587
+ L: 221,
4313
4588
  S: this,
4314
4589
  A: [
4315
4590
  "this._config",
4316
4591
  "'config not set'"
4317
4592
  ]
4318
4593
  });
4319
- (0, import_invariant13.invariant)(this._storage, "storage not set", {
4320
- F: __dxlog_file16,
4321
- L: 205,
4594
+ (0, import_invariant14.invariant)(this._storage, "storage not set", {
4595
+ F: __dxlog_file17,
4596
+ L: 222,
4322
4597
  S: this,
4323
4598
  A: [
4324
4599
  "this._storage",
4325
4600
  "'storage not set'"
4326
4601
  ]
4327
4602
  });
4328
- (0, import_invariant13.invariant)(this._signalManager, "signal manager not set", {
4329
- F: __dxlog_file16,
4330
- L: 206,
4603
+ (0, import_invariant14.invariant)(this._signalManager, "signal manager not set", {
4604
+ F: __dxlog_file17,
4605
+ L: 223,
4331
4606
  S: this,
4332
4607
  A: [
4333
4608
  "this._signalManager",
4334
4609
  "'signal manager not set'"
4335
4610
  ]
4336
4611
  });
4337
- (0, import_invariant13.invariant)(this._networkManager, "network manager not set", {
4338
- F: __dxlog_file16,
4339
- L: 207,
4612
+ (0, import_invariant14.invariant)(this._networkManager, "network manager not set", {
4613
+ F: __dxlog_file17,
4614
+ L: 224,
4340
4615
  S: this,
4341
4616
  A: [
4342
4617
  "this._networkManager",
@@ -4344,11 +4619,11 @@ var ClientServicesHost = class {
4344
4619
  ]
4345
4620
  });
4346
4621
  this._opening = true;
4347
- (0, import_log15.log)("opening...", {
4622
+ import_log16.log.info("opening...", {
4348
4623
  lockKey: (_a = this._resourceLock) == null ? void 0 : _a.lockKey
4349
4624
  }, {
4350
- F: __dxlog_file16,
4351
- L: 210,
4625
+ F: __dxlog_file17,
4626
+ L: 227,
4352
4627
  S: this,
4353
4628
  C: (f, a) => f(...a)
4354
4629
  });
@@ -4367,6 +4642,7 @@ var ClientServicesHost = class {
4367
4642
  DataService: new import_echo_pipeline4.DataServiceImpl(this._serviceContext.dataServiceSubscriptions),
4368
4643
  NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
4369
4644
  LoggingService: this._loggingService,
4645
+ TracingService: this._tracingService,
4370
4646
  // TODO(burdon): Move to new protobuf definitions.
4371
4647
  DevtoolsHost: new DevtoolsServiceImpl({
4372
4648
  events: new DevtoolsHostEvents(),
@@ -4374,24 +4650,24 @@ var ClientServicesHost = class {
4374
4650
  context: this._serviceContext
4375
4651
  })
4376
4652
  });
4377
- await this._serviceContext.open();
4653
+ await this._serviceContext.open(ctx);
4378
4654
  this._opening = false;
4379
4655
  this._open = true;
4380
4656
  this._statusUpdate.emit();
4381
4657
  const deviceKey = (_c = this._serviceContext.identityManager.identity) == null ? void 0 : _c.deviceKey;
4382
- (0, import_log15.log)("opened", {
4658
+ import_log16.log.info("opened", {
4383
4659
  deviceKey
4384
4660
  }, {
4385
- F: __dxlog_file16,
4386
- L: 265,
4661
+ F: __dxlog_file17,
4662
+ L: 280,
4387
4663
  S: this,
4388
4664
  C: (f, a) => f(...a)
4389
4665
  });
4390
- import_log15.log.trace("dxos.sdk.client-services-host.open", import_protocols9.trace.end({
4666
+ import_log16.log.trace("dxos.client-services.host.open", import_protocols10.trace.end({
4391
4667
  id: traceId
4392
4668
  }), {
4393
- F: __dxlog_file16,
4394
- L: 266,
4669
+ F: __dxlog_file17,
4670
+ L: 281,
4395
4671
  S: this,
4396
4672
  C: (f, a) => f(...a)
4397
4673
  });
@@ -4402,11 +4678,11 @@ var ClientServicesHost = class {
4402
4678
  return;
4403
4679
  }
4404
4680
  const deviceKey = (_a = this._serviceContext.identityManager.identity) == null ? void 0 : _a.deviceKey;
4405
- (0, import_log15.log)("closing...", {
4681
+ import_log16.log.info("closing...", {
4406
4682
  deviceKey
4407
4683
  }, {
4408
- F: __dxlog_file16,
4409
- L: 276,
4684
+ F: __dxlog_file17,
4685
+ L: 292,
4410
4686
  S: this,
4411
4687
  C: (f, a) => f(...a)
4412
4688
  });
@@ -4417,11 +4693,11 @@ var ClientServicesHost = class {
4417
4693
  await this._serviceContext.close();
4418
4694
  this._open = false;
4419
4695
  this._statusUpdate.emit();
4420
- (0, import_log15.log)("closed", {
4696
+ import_log16.log.info("closed", {
4421
4697
  deviceKey
4422
4698
  }, {
4423
- F: __dxlog_file16,
4424
- L: 282,
4699
+ F: __dxlog_file17,
4700
+ L: 298,
4425
4701
  S: this,
4426
4702
  C: (f, a) => f(...a)
4427
4703
  });
@@ -4429,48 +4705,59 @@ var ClientServicesHost = class {
4429
4705
  async reset() {
4430
4706
  var _a, _b, _c;
4431
4707
  const traceId = import_keys12.PublicKey.random().toHex();
4432
- import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.begin({
4708
+ import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.begin({
4433
4709
  id: traceId
4434
4710
  }), {
4435
- F: __dxlog_file16,
4436
- L: 287,
4711
+ F: __dxlog_file17,
4712
+ L: 303,
4437
4713
  S: this,
4438
4714
  C: (f, a) => f(...a)
4439
4715
  });
4440
- (0, import_log15.log)("resetting...", void 0, {
4441
- F: __dxlog_file16,
4442
- L: 289,
4716
+ (0, import_log16.log)("resetting...", void 0, {
4717
+ F: __dxlog_file17,
4718
+ L: 305,
4443
4719
  S: this,
4444
4720
  C: (f, a) => f(...a)
4445
4721
  });
4446
4722
  await ((_a = this._serviceContext) == null ? void 0 : _a.close());
4447
4723
  await this._storage.reset();
4448
- (0, import_log15.log)("reset", void 0, {
4449
- F: __dxlog_file16,
4450
- L: 292,
4724
+ (0, import_log16.log)("reset", void 0, {
4725
+ F: __dxlog_file17,
4726
+ L: 308,
4451
4727
  S: this,
4452
4728
  C: (f, a) => f(...a)
4453
4729
  });
4454
- import_log15.log.trace("dxos.sdk.client-services-host.reset", import_protocols9.trace.end({
4730
+ import_log16.log.trace("dxos.sdk.client-services-host.reset", import_protocols10.trace.end({
4455
4731
  id: traceId
4456
4732
  }), {
4457
- F: __dxlog_file16,
4458
- L: 293,
4733
+ F: __dxlog_file17,
4734
+ L: 309,
4459
4735
  S: this,
4460
4736
  C: (f, a) => f(...a)
4461
4737
  });
4462
4738
  await ((_c = (_b = this._callbacks) == null ? void 0 : _b.onReset) == null ? void 0 : _c.call(_b));
4463
4739
  }
4464
4740
  };
4465
- _ts_decorate4([
4466
- import_async17.synchronized
4741
+ _ts_decorate7([
4742
+ import_tracing4.trace.info()
4743
+ ], ClientServicesHost.prototype, "_opening", void 0);
4744
+ _ts_decorate7([
4745
+ import_tracing4.trace.info()
4746
+ ], ClientServicesHost.prototype, "_open", void 0);
4747
+ _ts_decorate7([
4748
+ import_async17.synchronized,
4749
+ import_tracing4.trace.span()
4467
4750
  ], ClientServicesHost.prototype, "open", null);
4468
- _ts_decorate4([
4469
- import_async17.synchronized
4751
+ _ts_decorate7([
4752
+ import_async17.synchronized,
4753
+ import_tracing4.trace.span()
4470
4754
  ], ClientServicesHost.prototype, "close", null);
4755
+ ClientServicesHost = _ts_decorate7([
4756
+ import_tracing4.trace.resource()
4757
+ ], ClientServicesHost);
4471
4758
 
4472
4759
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts
4473
- var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/invitation-utils.ts";
4760
+ var __dxlog_file18 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/testing/invitation-utils.ts";
4474
4761
  var sanitizeInvitation = (invitation) => {
4475
4762
  return {
4476
4763
  invitationId: invitation.invitationId,
@@ -4490,7 +4777,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4490
4777
  hostObservable.subscribe(async (hostInvitation) => {
4491
4778
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
4492
4779
  switch (hostInvitation.state) {
4493
- case import_services13.Invitation.State.CONNECTING: {
4780
+ case import_services15.Invitation.State.CONNECTING: {
4494
4781
  if ((_b = (_a = hooks == null ? void 0 : hooks.host) == null ? void 0 : _a.onConnecting) == null ? void 0 : _b.call(_a, hostObservable)) {
4495
4782
  break;
4496
4783
  }
@@ -4498,12 +4785,12 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4498
4785
  guestObservable.subscribe(async (guestInvitation) => {
4499
4786
  var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
4500
4787
  switch (guestInvitation.state) {
4501
- case import_services13.Invitation.State.CONNECTING: {
4788
+ case import_services15.Invitation.State.CONNECTING: {
4502
4789
  if ((_b2 = (_a2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _a2.onConnecting) == null ? void 0 : _b2.call(_a2, guestObservable)) {
4503
4790
  break;
4504
4791
  }
4505
- (0, import_invariant14.invariant)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey), void 0, {
4506
- F: __dxlog_file17,
4792
+ (0, import_invariant15.invariant)(hostInvitation.swarmKey.equals(guestInvitation.swarmKey), void 0, {
4793
+ F: __dxlog_file18,
4507
4794
  L: 84,
4508
4795
  S: void 0,
4509
4796
  A: [
@@ -4513,22 +4800,22 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4513
4800
  });
4514
4801
  break;
4515
4802
  }
4516
- case import_services13.Invitation.State.CONNECTED: {
4803
+ case import_services15.Invitation.State.CONNECTED: {
4517
4804
  (_d2 = (_c2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _c2.onConnected) == null ? void 0 : _d2.call(_c2, guestObservable);
4518
4805
  break;
4519
4806
  }
4520
- case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
4807
+ case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
4521
4808
  if ((_f2 = (_e2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _e2.onReady) == null ? void 0 : _f2.call(_e2, guestObservable)) {
4522
4809
  break;
4523
4810
  }
4524
4811
  await guestObservable.authenticate(await authCode.wait());
4525
4812
  break;
4526
4813
  }
4527
- case import_services13.Invitation.State.AUTHENTICATING: {
4814
+ case import_services15.Invitation.State.AUTHENTICATING: {
4528
4815
  (_h2 = (_g2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _g2.onAuthenticating) == null ? void 0 : _h2.call(_g2, guestObservable);
4529
4816
  break;
4530
4817
  }
4531
- case import_services13.Invitation.State.SUCCESS: {
4818
+ case import_services15.Invitation.State.SUCCESS: {
4532
4819
  if ((_j2 = (_i2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _i2.onSuccess) == null ? void 0 : _j2.call(_i2, guestObservable)) {
4533
4820
  break;
4534
4821
  }
@@ -4537,7 +4824,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4537
4824
  });
4538
4825
  break;
4539
4826
  }
4540
- case import_services13.Invitation.State.CANCELLED: {
4827
+ case import_services15.Invitation.State.CANCELLED: {
4541
4828
  if ((_l2 = (_k2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _k2.onCancelled) == null ? void 0 : _l2.call(_k2, guestObservable)) {
4542
4829
  break;
4543
4830
  }
@@ -4546,7 +4833,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4546
4833
  });
4547
4834
  break;
4548
4835
  }
4549
- case import_services13.Invitation.State.TIMEOUT: {
4836
+ case import_services15.Invitation.State.TIMEOUT: {
4550
4837
  if ((_n2 = (_m2 = hooks == null ? void 0 : hooks.guest) == null ? void 0 : _m2.onTimeout) == null ? void 0 : _n2.call(_m2, guestObservable)) {
4551
4838
  return;
4552
4839
  }
@@ -4566,11 +4853,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4566
4853
  });
4567
4854
  break;
4568
4855
  }
4569
- case import_services13.Invitation.State.CONNECTED: {
4856
+ case import_services15.Invitation.State.CONNECTED: {
4570
4857
  (_d = (_c = hooks == null ? void 0 : hooks.host) == null ? void 0 : _c.onConnected) == null ? void 0 : _d.call(_c, hostObservable);
4571
4858
  break;
4572
4859
  }
4573
- case import_services13.Invitation.State.READY_FOR_AUTHENTICATION: {
4860
+ case import_services15.Invitation.State.READY_FOR_AUTHENTICATION: {
4574
4861
  if ((_f = (_e = hooks == null ? void 0 : hooks.host) == null ? void 0 : _e.onReady) == null ? void 0 : _f.call(_e, hostObservable)) {
4575
4862
  break;
4576
4863
  }
@@ -4579,11 +4866,11 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4579
4866
  }
4580
4867
  break;
4581
4868
  }
4582
- case import_services13.Invitation.State.AUTHENTICATING: {
4869
+ case import_services15.Invitation.State.AUTHENTICATING: {
4583
4870
  (_h = (_g = hooks == null ? void 0 : hooks.host) == null ? void 0 : _g.onAuthenticating) == null ? void 0 : _h.call(_g, hostObservable);
4584
4871
  break;
4585
4872
  }
4586
- case import_services13.Invitation.State.SUCCESS: {
4873
+ case import_services15.Invitation.State.SUCCESS: {
4587
4874
  if ((_j = (_i = hooks == null ? void 0 : hooks.host) == null ? void 0 : _i.onSuccess) == null ? void 0 : _j.call(_i, hostObservable)) {
4588
4875
  break;
4589
4876
  }
@@ -4592,7 +4879,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4592
4879
  });
4593
4880
  break;
4594
4881
  }
4595
- case import_services13.Invitation.State.CANCELLED: {
4882
+ case import_services15.Invitation.State.CANCELLED: {
4596
4883
  if ((_l = (_k = hooks == null ? void 0 : hooks.host) == null ? void 0 : _k.onCancelled) == null ? void 0 : _l.call(_k, hostObservable)) {
4597
4884
  break;
4598
4885
  }
@@ -4601,7 +4888,7 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4601
4888
  });
4602
4889
  break;
4603
4890
  }
4604
- case import_services13.Invitation.State.TIMEOUT: {
4891
+ case import_services15.Invitation.State.TIMEOUT: {
4605
4892
  if ((_n = (_m = hooks == null ? void 0 : hooks.host) == null ? void 0 : _m.onTimeout) == null ? void 0 : _n.call(_m, hostObservable)) {
4606
4893
  break;
4607
4894
  }
@@ -4627,12 +4914,12 @@ var performInvitation = ({ host, guest, options, hooks }) => {
4627
4914
  };
4628
4915
  var createInvitation = (host, options) => {
4629
4916
  options != null ? options : options = {
4630
- authMethod: import_services13.Invitation.AuthMethod.NONE,
4917
+ authMethod: import_services15.Invitation.AuthMethod.NONE,
4631
4918
  ...options != null ? options : {}
4632
4919
  };
4633
4920
  if (host instanceof ServiceContext) {
4634
4921
  const hostHandler = host.getInvitationHandler({
4635
- kind: import_services13.Invitation.Kind.SPACE,
4922
+ kind: import_services15.Invitation.Kind.SPACE,
4636
4923
  ...options
4637
4924
  });
4638
4925
  return host.invitations.createInvitation(hostHandler, options);
@@ -4651,8 +4938,8 @@ var acceptInvitation = (guest, invitation) => {
4651
4938
  };
4652
4939
 
4653
4940
  // packages/sdk/client-services/src/packlets/testing/test-builder.ts
4654
- var import_context8 = require("@dxos/context");
4655
- var import_credentials15 = require("@dxos/credentials");
4941
+ var import_context11 = require("@dxos/context");
4942
+ var import_credentials16 = require("@dxos/credentials");
4656
4943
  var import_debug8 = require("@dxos/debug");
4657
4944
  var import_echo_pipeline5 = require("@dxos/echo-pipeline");
4658
4945
  var import_testing = require("@dxos/echo-pipeline/testing");
@@ -4686,7 +4973,7 @@ var createPeers = async (numPeers) => {
4686
4973
  const peer = createServiceContext({
4687
4974
  signalContext
4688
4975
  });
4689
- await peer.open();
4976
+ await peer.open(new import_context11.Context());
4690
4977
  return peer;
4691
4978
  }));
4692
4979
  };
@@ -4701,7 +4988,7 @@ var syncItemsLocal = async (db1, db2) => {
4701
4988
  var TestBuilder = class {
4702
4989
  constructor() {
4703
4990
  this.signalContext = new import_messaging2.MemorySignalManagerContext();
4704
- this._ctx = new import_context8.Context();
4991
+ this._ctx = new import_context11.Context();
4705
4992
  }
4706
4993
  createPeer(peerOptions) {
4707
4994
  const peer = new TestPeer(this.signalContext, peerOptions);
@@ -4797,8 +5084,8 @@ var createSigningContext = async (keyring) => {
4797
5084
  return {
4798
5085
  identityKey,
4799
5086
  deviceKey,
4800
- credentialSigner: (0, import_credentials15.createCredentialSignerWithChain)(keyring, {
4801
- credential: await new import_credentials15.CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey)
5087
+ credentialSigner: (0, import_credentials16.createCredentialSignerWithChain)(keyring, {
5088
+ credential: await new import_credentials16.CredentialGenerator(keyring, identityKey, deviceKey).createDeviceAuthorization(deviceKey)
4802
5089
  }, deviceKey),
4803
5090
  recordCredential: async () => {
4804
5091
  }