@dxos/client-services 0.6.13-main.548ca8d → 0.6.13-main.ed424a1

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 (70) hide show
  1. package/dist/lib/browser/{chunk-UEQIHAL2.mjs → chunk-IPWEAPT2.mjs} +728 -379
  2. package/dist/lib/browser/chunk-IPWEAPT2.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +5 -1
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +5 -1
  7. package/dist/lib/browser/testing/index.mjs.map +3 -3
  8. package/dist/lib/node/{chunk-MA5EWTRH.cjs → chunk-DJIOUOAF.cjs} +769 -422
  9. package/dist/lib/node/chunk-DJIOUOAF.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +49 -45
  11. package/dist/lib/node/index.cjs.map +1 -1
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +12 -8
  14. package/dist/lib/node/testing/index.cjs.map +3 -3
  15. package/dist/lib/node-esm/{chunk-AIBLDI4U.mjs → chunk-MMU5KC57.mjs} +728 -379
  16. package/dist/lib/node-esm/chunk-MMU5KC57.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +5 -1
  18. package/dist/lib/node-esm/index.mjs.map +1 -1
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +5 -1
  21. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  22. package/dist/types/src/index.d.ts +1 -0
  23. package/dist/types/src/index.d.ts.map +1 -1
  24. package/dist/types/src/packlets/agents/edge-agent-manager.d.ts +35 -0
  25. package/dist/types/src/packlets/agents/edge-agent-manager.d.ts.map +1 -0
  26. package/dist/types/src/packlets/agents/edge-agent-service.d.ts +10 -0
  27. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -0
  28. package/dist/types/src/packlets/agents/index.d.ts +3 -0
  29. package/dist/types/src/packlets/agents/index.d.ts.map +1 -0
  30. package/dist/types/src/packlets/identity/identity-manager.d.ts +11 -7
  31. package/dist/types/src/packlets/identity/identity-manager.d.ts.map +1 -1
  32. package/dist/types/src/packlets/identity/identity.d.ts +4 -2
  33. package/dist/types/src/packlets/identity/identity.d.ts.map +1 -1
  34. package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
  35. package/dist/types/src/packlets/invitations/edge-invitation-handler.d.ts.map +1 -1
  36. package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
  37. package/dist/types/src/packlets/services/service-context.d.ts +4 -1
  38. package/dist/types/src/packlets/services/service-context.d.ts.map +1 -1
  39. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  40. package/dist/types/src/packlets/spaces/data-space-manager.d.ts +1 -0
  41. package/dist/types/src/packlets/spaces/data-space-manager.d.ts.map +1 -1
  42. package/dist/types/src/packlets/spaces/data-space.d.ts +1 -0
  43. package/dist/types/src/packlets/spaces/data-space.d.ts.map +1 -1
  44. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts +4 -0
  45. package/dist/types/src/packlets/spaces/notarization-plugin.d.ts.map +1 -1
  46. package/dist/types/src/packlets/testing/test-builder.d.ts.map +1 -1
  47. package/dist/types/src/version.d.ts +1 -1
  48. package/package.json +38 -38
  49. package/src/index.ts +1 -0
  50. package/src/packlets/agents/edge-agent-manager.ts +163 -0
  51. package/src/packlets/agents/edge-agent-service.ts +42 -0
  52. package/src/packlets/agents/index.ts +6 -0
  53. package/src/packlets/identity/identity-manager.test.ts +26 -10
  54. package/src/packlets/identity/identity-manager.ts +19 -19
  55. package/src/packlets/identity/identity.test.ts +2 -0
  56. package/src/packlets/identity/identity.ts +21 -12
  57. package/src/packlets/invitations/device-invitation-protocol.ts +5 -1
  58. package/src/packlets/invitations/edge-invitation-handler.ts +6 -5
  59. package/src/packlets/invitations/invitations-handler.ts +1 -2
  60. package/src/packlets/services/service-context.ts +75 -45
  61. package/src/packlets/services/service-host.ts +8 -0
  62. package/src/packlets/spaces/data-space-manager.ts +4 -2
  63. package/src/packlets/spaces/data-space.ts +3 -0
  64. package/src/packlets/spaces/edge-feed-replicator.test.ts +5 -6
  65. package/src/packlets/spaces/notarization-plugin.ts +27 -0
  66. package/src/packlets/testing/test-builder.ts +4 -0
  67. package/src/version.ts +1 -1
  68. package/dist/lib/browser/chunk-UEQIHAL2.mjs.map +0 -7
  69. package/dist/lib/node/chunk-MA5EWTRH.cjs.map +0 -7
  70. package/dist/lib/node-esm/chunk-AIBLDI4U.mjs.map +0 -7
@@ -404,7 +404,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
404
404
  import { TRACE_PROCESSOR } from "@dxos/tracing";
405
405
 
406
406
  // packages/sdk/client-services/src/version.ts
407
- var DXOS_VERSION = "0.6.13-main.548ca8d";
407
+ var DXOS_VERSION = "0.6.13-main.ed424a1";
408
408
 
409
409
  // packages/sdk/client-services/src/packlets/services/platform.ts
410
410
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -1558,6 +1558,7 @@ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/sr
1558
1558
  var DEFAULT_RETRY_TIMEOUT = 1e3;
1559
1559
  var DEFAULT_SUCCESS_DELAY = 1e3;
1560
1560
  var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
1561
+ var DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL = 3e3;
1561
1562
  var MAX_EDGE_RETRIES = 2;
1562
1563
  var WRITER_NOT_SET_ERROR_CODE = "WRITER_NOT_SET";
1563
1564
  var credentialCodec = schema2.getCodecForType("dxos.halo.credentials.Credential");
@@ -1568,11 +1569,44 @@ var NotarizationPlugin = class extends Resource3 {
1568
1569
  this._extensions = /* @__PURE__ */ new Set();
1569
1570
  this._processedCredentials = new ComplexSet(PublicKey4.hash);
1570
1571
  this._processCredentialsTriggers = new ComplexMap3(PublicKey4.hash);
1572
+ this._activeEdgePollingIntervalHandle = void 0;
1571
1573
  this._spaceId = params.spaceId;
1574
+ this._activeEdgePollingInterval = params.activeEdgePollingInterval ?? DEFAULT_ACTIVE_EDGE_POLLING_INTERVAL;
1572
1575
  if (params.edgeClient && params.edgeFeatures?.feedReplicator) {
1573
1576
  this._edgeClient = params.edgeClient;
1574
1577
  }
1575
1578
  }
1579
+ setActiveEdgePollingEnabled(enabled) {
1580
+ invariant4(this.isOpen, void 0, {
1581
+ F: __dxlog_file8,
1582
+ L: 109,
1583
+ S: this,
1584
+ A: [
1585
+ "this.isOpen",
1586
+ ""
1587
+ ]
1588
+ });
1589
+ const client = this._edgeClient;
1590
+ invariant4(client, void 0, {
1591
+ F: __dxlog_file8,
1592
+ L: 111,
1593
+ S: this,
1594
+ A: [
1595
+ "client",
1596
+ ""
1597
+ ]
1598
+ });
1599
+ if (enabled && !this._activeEdgePollingIntervalHandle) {
1600
+ this._activeEdgePollingIntervalHandle = setInterval(() => {
1601
+ if (this._writer) {
1602
+ this._notarizePendingEdgeCredentials(client, this._writer);
1603
+ }
1604
+ }, this._activeEdgePollingInterval);
1605
+ } else if (!enabled && this._activeEdgePollingIntervalHandle) {
1606
+ clearInterval(this._activeEdgePollingIntervalHandle);
1607
+ this._activeEdgePollingIntervalHandle = void 0;
1608
+ }
1609
+ }
1576
1610
  get hasWriter() {
1577
1611
  return !!this._writer;
1578
1612
  }
@@ -1582,6 +1616,10 @@ var NotarizationPlugin = class extends Resource3 {
1582
1616
  }
1583
1617
  }
1584
1618
  async _close() {
1619
+ if (this._activeEdgePollingIntervalHandle) {
1620
+ clearInterval(this._activeEdgePollingIntervalHandle);
1621
+ this._activeEdgePollingIntervalHandle = void 0;
1622
+ }
1585
1623
  await this._ctx.dispose();
1586
1624
  }
1587
1625
  /**
@@ -1592,13 +1630,13 @@ var NotarizationPlugin = class extends Resource3 {
1592
1630
  credentials
1593
1631
  }, {
1594
1632
  F: __dxlog_file8,
1595
- L: 126,
1633
+ L: 153,
1596
1634
  S: this,
1597
1635
  C: (f, a) => f(...a)
1598
1636
  });
1599
1637
  invariant4(credentials.every((credential) => credential.id), "Credentials must have an id", {
1600
1638
  F: __dxlog_file8,
1601
- L: 127,
1639
+ L: 154,
1602
1640
  S: this,
1603
1641
  A: [
1604
1642
  "credentials.every((credential) => credential.id)",
@@ -1612,7 +1650,7 @@ var NotarizationPlugin = class extends Resource3 {
1612
1650
  err
1613
1651
  }, {
1614
1652
  F: __dxlog_file8,
1615
- L: 135,
1653
+ L: 162,
1616
1654
  S: this,
1617
1655
  C: (f, a) => f(...a)
1618
1656
  });
@@ -1644,7 +1682,7 @@ var NotarizationPlugin = class extends Resource3 {
1644
1682
  ]);
1645
1683
  log6("done", void 0, {
1646
1684
  F: __dxlog_file8,
1647
- L: 160,
1685
+ L: 187,
1648
1686
  S: this,
1649
1687
  C: (f, a) => f(...a)
1650
1688
  });
@@ -1667,7 +1705,7 @@ var NotarizationPlugin = class extends Resource3 {
1667
1705
  retryIn: retryTimeout
1668
1706
  }, {
1669
1707
  F: __dxlog_file8,
1670
- L: 183,
1708
+ L: 210,
1671
1709
  S: this,
1672
1710
  C: (f, a) => f(...a)
1673
1711
  });
@@ -1681,7 +1719,7 @@ var NotarizationPlugin = class extends Resource3 {
1681
1719
  credentialId: credentials.map((credential) => credential.id)
1682
1720
  }, {
1683
1721
  F: __dxlog_file8,
1684
- L: 190,
1722
+ L: 217,
1685
1723
  S: this,
1686
1724
  C: (f, a) => f(...a)
1687
1725
  });
@@ -1690,7 +1728,7 @@ var NotarizationPlugin = class extends Resource3 {
1690
1728
  });
1691
1729
  log6("success", void 0, {
1692
1730
  F: __dxlog_file8,
1693
- L: 194,
1731
+ L: 221,
1694
1732
  S: this,
1695
1733
  C: (f, a) => f(...a)
1696
1734
  });
@@ -1699,7 +1737,7 @@ var NotarizationPlugin = class extends Resource3 {
1699
1737
  if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
1700
1738
  log6.info("error notarizing (recoverable)", err, {
1701
1739
  F: __dxlog_file8,
1702
- L: 199,
1740
+ L: 226,
1703
1741
  S: this,
1704
1742
  C: (f, a) => f(...a)
1705
1743
  });
@@ -1728,7 +1766,7 @@ var NotarizationPlugin = class extends Resource3 {
1728
1766
  });
1729
1767
  log6("edge notarization success", void 0, {
1730
1768
  F: __dxlog_file8,
1731
- L: 227,
1769
+ L: 254,
1732
1770
  S: this,
1733
1771
  C: (f, a) => f(...a)
1734
1772
  });
@@ -1751,7 +1789,7 @@ var NotarizationPlugin = class extends Resource3 {
1751
1789
  setWriter(writer) {
1752
1790
  invariant4(!this._writer, "Writer already set.", {
1753
1791
  F: __dxlog_file8,
1754
- L: 247,
1792
+ L: 274,
1755
1793
  S: this,
1756
1794
  A: [
1757
1795
  "!this._writer",
@@ -1781,7 +1819,7 @@ var NotarizationPlugin = class extends Resource3 {
1781
1819
  if (!credentials.length) {
1782
1820
  log6("edge did not return credentials for notarization", void 0, {
1783
1821
  F: __dxlog_file8,
1784
- L: 269,
1822
+ L: 296,
1785
1823
  S: this,
1786
1824
  C: (f, a) => f(...a)
1787
1825
  });
@@ -1791,7 +1829,7 @@ var NotarizationPlugin = class extends Resource3 {
1791
1829
  count: credentials.length
1792
1830
  }, {
1793
1831
  F: __dxlog_file8,
1794
- L: 273,
1832
+ L: 300,
1795
1833
  S: this,
1796
1834
  C: (f, a) => f(...a)
1797
1835
  });
@@ -1804,7 +1842,7 @@ var NotarizationPlugin = class extends Resource3 {
1804
1842
  count: decodedCredentials.length
1805
1843
  }, {
1806
1844
  F: __dxlog_file8,
1807
- L: 282,
1845
+ L: 309,
1808
1846
  S: this,
1809
1847
  C: (f, a) => f(...a)
1810
1848
  });
@@ -1832,7 +1870,7 @@ var NotarizationPlugin = class extends Resource3 {
1832
1870
  for (const credential of credentials) {
1833
1871
  invariant4(credential.id, "Credential must have an id", {
1834
1872
  F: __dxlog_file8,
1835
- L: 308,
1873
+ L: 335,
1836
1874
  S: this,
1837
1875
  A: [
1838
1876
  "credential.id",
@@ -1856,7 +1894,7 @@ var NotarizationPlugin = class extends Resource3 {
1856
1894
  peer: extension.localPeerId
1857
1895
  }, {
1858
1896
  F: __dxlog_file8,
1859
- L: 323,
1897
+ L: 350,
1860
1898
  S: this,
1861
1899
  C: (f, a) => f(...a)
1862
1900
  });
@@ -1868,7 +1906,7 @@ var NotarizationPlugin = class extends Resource3 {
1868
1906
  peer: extension.localPeerId
1869
1907
  }, {
1870
1908
  F: __dxlog_file8,
1871
- L: 328,
1909
+ L: 355,
1872
1910
  S: this,
1873
1911
  C: (f, a) => f(...a)
1874
1912
  });
@@ -1885,7 +1923,7 @@ var NotarizationPlugin = class extends Resource3 {
1885
1923
  peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
1886
1924
  }, {
1887
1925
  F: __dxlog_file8,
1888
- L: 340,
1926
+ L: 367,
1889
1927
  S: this,
1890
1928
  C: (f, a) => f(...a)
1891
1929
  });
@@ -1901,7 +1939,7 @@ var handleEdgeError = (error) => {
1901
1939
  if (!(error instanceof EdgeCallFailedError) || error.errorData) {
1902
1940
  log6.catch(error, void 0, {
1903
1941
  F: __dxlog_file8,
1904
- L: 354,
1942
+ L: 381,
1905
1943
  S: void 0,
1906
1944
  C: (f, a) => f(...a)
1907
1945
  });
@@ -1910,7 +1948,7 @@ var handleEdgeError = (error) => {
1910
1948
  reason: error.reason
1911
1949
  }, {
1912
1950
  F: __dxlog_file8,
1913
- L: 356,
1951
+ L: 383,
1914
1952
  S: void 0,
1915
1953
  C: (f, a) => f(...a)
1916
1954
  });
@@ -2013,7 +2051,7 @@ import { LifecycleState, Resource as Resource4, cancelWithContext } from "@dxos/
2013
2051
  import { createAdmissionCredentials, getCredentialAssertion as getCredentialAssertion2 } from "@dxos/credentials";
2014
2052
  import { convertLegacyReferences as convertLegacyReferences2, findInlineObjectOfType as findInlineObjectOfType2, AuthStatus, CredentialServerExtension } from "@dxos/echo-pipeline";
2015
2053
  import { LEGACY_TYPE_PROPERTIES, SpaceDocVersion as SpaceDocVersion2, encodeReference } from "@dxos/echo-protocol";
2016
- import { TYPE_PROPERTIES as TYPE_PROPERTIES2, generateEchoId, getTypeReference } from "@dxos/echo-schema";
2054
+ import { TYPE_PROPERTIES as TYPE_PROPERTIES2, createObjectId, getTypeReference } from "@dxos/echo-schema";
2017
2055
  import { writeMessages } from "@dxos/feed-store";
2018
2056
  import { invariant as invariant5 } from "@dxos/invariant";
2019
2057
  import { PublicKey as PublicKey5 } from "@dxos/keys";
@@ -2162,7 +2200,7 @@ var DataSpaceManager = class extends Resource4 {
2162
2200
  async _open() {
2163
2201
  log8("open", void 0, {
2164
2202
  F: __dxlog_file10,
2165
- L: 198,
2203
+ L: 199,
2166
2204
  S: this,
2167
2205
  C: (f, a) => f(...a)
2168
2206
  });
@@ -2170,7 +2208,7 @@ var DataSpaceManager = class extends Resource4 {
2170
2208
  id: this._instanceId
2171
2209
  }), {
2172
2210
  F: __dxlog_file10,
2173
- L: 199,
2211
+ L: 200,
2174
2212
  S: this,
2175
2213
  C: (f, a) => f(...a)
2176
2214
  });
@@ -2178,7 +2216,7 @@ var DataSpaceManager = class extends Resource4 {
2178
2216
  spaces: this._metadataStore.spaces.length
2179
2217
  }, {
2180
2218
  F: __dxlog_file10,
2181
- L: 200,
2219
+ L: 201,
2182
2220
  S: this,
2183
2221
  C: (f, a) => f(...a)
2184
2222
  });
@@ -2188,7 +2226,7 @@ var DataSpaceManager = class extends Resource4 {
2188
2226
  spaceMetadata
2189
2227
  }, {
2190
2228
  F: __dxlog_file10,
2191
- L: 204,
2229
+ L: 205,
2192
2230
  S: this,
2193
2231
  C: (f, a) => f(...a)
2194
2232
  });
@@ -2199,7 +2237,7 @@ var DataSpaceManager = class extends Resource4 {
2199
2237
  err
2200
2238
  }, {
2201
2239
  F: __dxlog_file10,
2202
- L: 207,
2240
+ L: 208,
2203
2241
  S: this,
2204
2242
  C: (f, a) => f(...a)
2205
2243
  });
@@ -2210,7 +2248,7 @@ var DataSpaceManager = class extends Resource4 {
2210
2248
  id: this._instanceId
2211
2249
  }), {
2212
2250
  F: __dxlog_file10,
2213
- L: 213,
2251
+ L: 214,
2214
2252
  S: this,
2215
2253
  C: (f, a) => f(...a)
2216
2254
  });
@@ -2218,7 +2256,7 @@ var DataSpaceManager = class extends Resource4 {
2218
2256
  async _close() {
2219
2257
  log8("close", void 0, {
2220
2258
  F: __dxlog_file10,
2221
- L: 218,
2259
+ L: 219,
2222
2260
  S: this,
2223
2261
  C: (f, a) => f(...a)
2224
2262
  });
@@ -2233,7 +2271,7 @@ var DataSpaceManager = class extends Resource4 {
2233
2271
  async createSpace() {
2234
2272
  invariant5(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
2235
2273
  F: __dxlog_file10,
2236
- L: 230,
2274
+ L: 231,
2237
2275
  S: this,
2238
2276
  A: [
2239
2277
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2254,7 +2292,7 @@ var DataSpaceManager = class extends Resource4 {
2254
2292
  spaceKey
2255
2293
  }, {
2256
2294
  F: __dxlog_file10,
2257
- L: 242,
2295
+ L: 243,
2258
2296
  S: this,
2259
2297
  C: (f, a) => f(...a)
2260
2298
  });
@@ -2266,7 +2304,7 @@ var DataSpaceManager = class extends Resource4 {
2266
2304
  const memberCredential = credentials[1];
2267
2305
  invariant5(getCredentialAssertion2(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2268
2306
  F: __dxlog_file10,
2269
- L: 252,
2307
+ L: 253,
2270
2308
  S: this,
2271
2309
  A: [
2272
2310
  "getCredentialAssertion(memberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2298,7 +2336,7 @@ var DataSpaceManager = class extends Resource4 {
2298
2336
  spaceId: space.id
2299
2337
  }, {
2300
2338
  F: __dxlog_file10,
2301
- L: 277,
2339
+ L: 278,
2302
2340
  S: this,
2303
2341
  C: (f, a) => f(...a)
2304
2342
  });
@@ -2319,7 +2357,7 @@ var DataSpaceManager = class extends Resource4 {
2319
2357
  keys: []
2320
2358
  }
2321
2359
  };
2322
- const propertiesId = generateEchoId();
2360
+ const propertiesId = createObjectId();
2323
2361
  document.change((doc) => {
2324
2362
  setDeep(doc, [
2325
2363
  "objects",
@@ -2333,7 +2371,7 @@ var DataSpaceManager = class extends Resource4 {
2333
2371
  const automergeIndex = space.automergeSpaceState.rootUrl;
2334
2372
  invariant5(automergeIndex, void 0, {
2335
2373
  F: __dxlog_file10,
2336
- L: 310,
2374
+ L: 311,
2337
2375
  S: this,
2338
2376
  A: [
2339
2377
  "automergeIndex",
@@ -2350,13 +2388,13 @@ var DataSpaceManager = class extends Resource4 {
2350
2388
  opts
2351
2389
  }, {
2352
2390
  F: __dxlog_file10,
2353
- L: 319,
2391
+ L: 320,
2354
2392
  S: this,
2355
2393
  C: (f, a) => f(...a)
2356
2394
  });
2357
2395
  invariant5(this._lifecycleState === LifecycleState.OPEN, "Not open.", {
2358
2396
  F: __dxlog_file10,
2359
- L: 320,
2397
+ L: 321,
2360
2398
  S: this,
2361
2399
  A: [
2362
2400
  "this._lifecycleState === LifecycleState.OPEN",
@@ -2365,7 +2403,7 @@ var DataSpaceManager = class extends Resource4 {
2365
2403
  });
2366
2404
  invariant5(!this._spaces.has(opts.spaceKey), "Space already exists.", {
2367
2405
  F: __dxlog_file10,
2368
- L: 321,
2406
+ L: 322,
2369
2407
  S: this,
2370
2408
  A: [
2371
2409
  "!this._spaces.has(opts.spaceKey)",
@@ -2389,7 +2427,7 @@ var DataSpaceManager = class extends Resource4 {
2389
2427
  const space = this._spaceManager.spaces.get(options.spaceKey);
2390
2428
  invariant5(space, void 0, {
2391
2429
  F: __dxlog_file10,
2392
- L: 341,
2430
+ L: 342,
2393
2431
  S: this,
2394
2432
  A: [
2395
2433
  "space",
@@ -2402,7 +2440,7 @@ var DataSpaceManager = class extends Resource4 {
2402
2440
  const credentials = await createAdmissionCredentials(this._signingContext.credentialSigner, options.identityKey, space.key, space.genesisFeedKey, options.role, space.spaceState.membershipChainHeads, options.profile, options.delegationCredentialId);
2403
2441
  invariant5(credentials[0].credential, void 0, {
2404
2442
  F: __dxlog_file10,
2405
- L: 360,
2443
+ L: 361,
2406
2444
  S: this,
2407
2445
  A: [
2408
2446
  "credentials[0].credential",
@@ -2412,7 +2450,7 @@ var DataSpaceManager = class extends Resource4 {
2412
2450
  const spaceMemberCredential = credentials[0].credential.credential;
2413
2451
  invariant5(getCredentialAssertion2(spaceMemberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
2414
2452
  F: __dxlog_file10,
2415
- L: 362,
2453
+ L: 363,
2416
2454
  S: this,
2417
2455
  A: [
2418
2456
  "getCredentialAssertion(spaceMemberCredential)['@type'] === 'dxos.halo.credentials.SpaceMember'",
@@ -2450,7 +2488,7 @@ var DataSpaceManager = class extends Resource4 {
2450
2488
  const space = this._spaces.get(spaceKey);
2451
2489
  invariant5(space, "Space not found.", {
2452
2490
  F: __dxlog_file10,
2453
- L: 399,
2491
+ L: 400,
2454
2492
  S: this,
2455
2493
  A: [
2456
2494
  "space",
@@ -2475,7 +2513,7 @@ var DataSpaceManager = class extends Resource4 {
2475
2513
  metadata
2476
2514
  }, {
2477
2515
  F: __dxlog_file10,
2478
- L: 418,
2516
+ L: 419,
2479
2517
  S: this,
2480
2518
  C: (f, a) => f(...a)
2481
2519
  });
@@ -2519,7 +2557,7 @@ var DataSpaceManager = class extends Resource4 {
2519
2557
  err
2520
2558
  }, {
2521
2559
  F: __dxlog_file10,
2522
- L: 460,
2560
+ L: 461,
2523
2561
  S: this,
2524
2562
  C: (f, a) => f(...a)
2525
2563
  });
@@ -2529,7 +2567,7 @@ var DataSpaceManager = class extends Resource4 {
2529
2567
  onAuthFailure: () => {
2530
2568
  log8.warn("auth failure", void 0, {
2531
2569
  F: __dxlog_file10,
2532
- L: 465,
2570
+ L: 466,
2533
2571
  S: this,
2534
2572
  C: (f, a) => f(...a)
2535
2573
  });
@@ -2562,7 +2600,7 @@ var DataSpaceManager = class extends Resource4 {
2562
2600
  space: space.key
2563
2601
  }, {
2564
2602
  F: __dxlog_file10,
2565
- L: 492,
2603
+ L: 493,
2566
2604
  S: this,
2567
2605
  C: (f, a) => f(...a)
2568
2606
  });
@@ -2573,7 +2611,7 @@ var DataSpaceManager = class extends Resource4 {
2573
2611
  open: this._lifecycleState === LifecycleState.OPEN
2574
2612
  }, {
2575
2613
  F: __dxlog_file10,
2576
- L: 495,
2614
+ L: 496,
2577
2615
  S: this,
2578
2616
  C: (f, a) => f(...a)
2579
2617
  });
@@ -2592,7 +2630,7 @@ var DataSpaceManager = class extends Resource4 {
2592
2630
  space: space.key
2593
2631
  }, {
2594
2632
  F: __dxlog_file10,
2595
- L: 503,
2633
+ L: 504,
2596
2634
  S: this,
2597
2635
  C: (f, a) => f(...a)
2598
2636
  });
@@ -2601,7 +2639,8 @@ var DataSpaceManager = class extends Resource4 {
2601
2639
  cache: metadata.cache,
2602
2640
  edgeConnection: this._edgeConnection,
2603
2641
  edgeHttpClient: this._edgeHttpClient,
2604
- edgeFeatures: this._edgeFeatures
2642
+ edgeFeatures: this._edgeFeatures,
2643
+ activeEdgeNotarizationPollingInterval: this._runtimeParams?.activeEdgeNotarizationPollingInterval
2605
2644
  });
2606
2645
  dataSpace.postOpen.append(async () => {
2607
2646
  const setting = dataSpace.getEdgeReplicationSetting();
@@ -2612,7 +2651,7 @@ var DataSpaceManager = class extends Resource4 {
2612
2651
  spaceId: dataSpace.id
2613
2652
  }, {
2614
2653
  F: __dxlog_file10,
2615
- L: 516,
2654
+ L: 518,
2616
2655
  S: this,
2617
2656
  C: (f, a) => f(...a)
2618
2657
  });
@@ -2642,7 +2681,7 @@ var DataSpaceManager = class extends Resource4 {
2642
2681
  space: space.key
2643
2682
  }, {
2644
2683
  F: __dxlog_file10,
2645
- L: 543,
2684
+ L: 545,
2646
2685
  S: this,
2647
2686
  C: (f, a) => f(...a)
2648
2687
  });
@@ -2675,7 +2714,7 @@ var DataSpaceManager = class extends Resource4 {
2675
2714
  closedSessions
2676
2715
  }, {
2677
2716
  F: __dxlog_file10,
2678
- L: 569,
2717
+ L: 571,
2679
2718
  S: this,
2680
2719
  C: (f, a) => f(...a)
2681
2720
  });
@@ -2690,7 +2729,7 @@ var DataSpaceManager = class extends Resource4 {
2690
2729
  peerId: peerState.peerId
2691
2730
  }, {
2692
2731
  F: __dxlog_file10,
2693
- L: 583,
2732
+ L: 585,
2694
2733
  S: this,
2695
2734
  C: (f, a) => f(...a)
2696
2735
  });
@@ -3118,7 +3157,7 @@ var Identity = class {
3118
3157
  deviceKey: params.deviceKey
3119
3158
  }, {
3120
3159
  F: __dxlog_file12,
3121
- L: 78,
3160
+ L: 79,
3122
3161
  S: this,
3123
3162
  C: (f, a) => f(...a)
3124
3163
  });
@@ -3159,10 +3198,13 @@ var Identity = class {
3159
3198
  await this.space.spaceState.addCredentialProcessor(this._deviceStateMachine);
3160
3199
  await this.space.spaceState.addCredentialProcessor(this._profileStateMachine);
3161
3200
  await this.space.spaceState.addCredentialProcessor(this._defaultSpaceStateMachine);
3201
+ await this.space.open(ctx);
3202
+ }
3203
+ async joinNetwork() {
3162
3204
  if (this._edgeFeedReplicator) {
3163
3205
  this.space.protocol.feedAdded.append(this._onFeedAdded);
3164
3206
  }
3165
- await this.space.open(ctx);
3207
+ await this.space.startProtocol();
3166
3208
  await this._edgeFeedReplicator?.open();
3167
3209
  }
3168
3210
  async close(ctx) {
@@ -3192,6 +3234,9 @@ var Identity = class {
3192
3234
  get controlPipeline() {
3193
3235
  return this.space.controlPipeline;
3194
3236
  }
3237
+ get haloSpaceId() {
3238
+ return this.space.id;
3239
+ }
3195
3240
  get haloSpaceKey() {
3196
3241
  return this.space.key;
3197
3242
  }
@@ -3214,7 +3259,7 @@ var Identity = class {
3214
3259
  getIdentityCredentialSigner() {
3215
3260
  invariant7(this._deviceStateMachine.deviceCredentialChain, "Device credential chain is not ready.", {
3216
3261
  F: __dxlog_file12,
3217
- L: 189,
3262
+ L: 195,
3218
3263
  S: this,
3219
3264
  A: [
3220
3265
  "this._deviceStateMachine.deviceCredentialChain",
@@ -3258,20 +3303,21 @@ var Identity = class {
3258
3303
  dataFeedKey
3259
3304
  }, {
3260
3305
  F: __dxlog_file12,
3261
- L: 214,
3306
+ L: 220,
3262
3307
  S: this,
3263
3308
  C: (f, a) => f(...a)
3264
3309
  });
3265
3310
  const signer = this.getIdentityCredentialSigner();
3311
+ const deviceCredential = await signer.createCredential({
3312
+ subject: deviceKey,
3313
+ assertion: {
3314
+ "@type": "dxos.halo.credentials.AuthorizedDevice",
3315
+ identityKey: this.identityKey,
3316
+ deviceKey
3317
+ }
3318
+ });
3266
3319
  await writeMessages3(this.controlPipeline.writer, [
3267
- await signer.createCredential({
3268
- subject: deviceKey,
3269
- assertion: {
3270
- "@type": "dxos.halo.credentials.AuthorizedDevice",
3271
- identityKey: this.identityKey,
3272
- deviceKey
3273
- }
3274
- }),
3320
+ deviceCredential,
3275
3321
  await signer.createCredential({
3276
3322
  subject: controlFeedKey,
3277
3323
  assertion: {
@@ -3297,6 +3343,7 @@ var Identity = class {
3297
3343
  credential
3298
3344
  }
3299
3345
  })));
3346
+ return deviceCredential;
3300
3347
  }
3301
3348
  };
3302
3349
  _ts_decorate4([
@@ -3345,7 +3392,6 @@ var IdentityManager = class {
3345
3392
  this._edgeFeatures = params.edgeFeatures;
3346
3393
  this._devicePresenceAnnounceInterval = params.devicePresenceAnnounceInterval ?? DEVICE_PRESENCE_ANNOUNCE_INTERVAL;
3347
3394
  this._devicePresenceOfflineTimeout = params.devicePresenceOfflineTimeout ?? DEVICE_PRESENCE_OFFLINE_TIMEOUT;
3348
- this._callbacks = params.callbacks;
3349
3395
  }
3350
3396
  get identity() {
3351
3397
  return this._identity;
@@ -3356,7 +3402,7 @@ var IdentityManager = class {
3356
3402
  id: traceId
3357
3403
  }), {
3358
3404
  F: __dxlog_file13,
3359
- L: 121,
3405
+ L: 116,
3360
3406
  S: this,
3361
3407
  C: (f, a) => f(...a)
3362
3408
  });
@@ -3365,7 +3411,7 @@ var IdentityManager = class {
3365
3411
  identityRecord
3366
3412
  }, {
3367
3413
  F: __dxlog_file13,
3368
- L: 124,
3414
+ L: 119,
3369
3415
  S: this,
3370
3416
  C: (f, a) => f(...a)
3371
3417
  });
@@ -3378,7 +3424,7 @@ var IdentityManager = class {
3378
3424
  displayName: this._identity.profileDocument?.displayName
3379
3425
  }, {
3380
3426
  F: __dxlog_file13,
3381
- L: 129,
3427
+ L: 124,
3382
3428
  S: this,
3383
3429
  C: (f, a) => f(...a)
3384
3430
  });
@@ -3388,7 +3434,7 @@ var IdentityManager = class {
3388
3434
  id: traceId
3389
3435
  }), {
3390
3436
  F: __dxlog_file13,
3391
- L: 136,
3437
+ L: 131,
3392
3438
  S: this,
3393
3439
  C: (f, a) => f(...a)
3394
3440
  });
@@ -3396,13 +3442,13 @@ var IdentityManager = class {
3396
3442
  async close() {
3397
3443
  await this._identity?.close(new Context4(void 0, {
3398
3444
  F: __dxlog_file13,
3399
- L: 140
3445
+ L: 135
3400
3446
  }));
3401
3447
  }
3402
3448
  async createIdentity({ displayName, deviceProfile } = {}) {
3403
3449
  invariant8(!this._identity, "Identity already exists.", {
3404
3450
  F: __dxlog_file13,
3405
- L: 145,
3451
+ L: 140,
3406
3452
  S: this,
3407
3453
  A: [
3408
3454
  "!this._identity",
@@ -3411,7 +3457,7 @@ var IdentityManager = class {
3411
3457
  });
3412
3458
  log11("creating identity...", void 0, {
3413
3459
  F: __dxlog_file13,
3414
- L: 146,
3460
+ L: 141,
3415
3461
  S: this,
3416
3462
  C: (f, a) => f(...a)
3417
3463
  });
@@ -3429,13 +3475,13 @@ var IdentityManager = class {
3429
3475
  const identity = await this._constructIdentity(identityRecord);
3430
3476
  await identity.open(new Context4(void 0, {
3431
3477
  F: __dxlog_file13,
3432
- L: 161
3478
+ L: 156
3433
3479
  }));
3434
3480
  {
3435
3481
  const generator = new CredentialGenerator(this._keyring, identityRecord.identityKey, identityRecord.deviceKey);
3436
3482
  invariant8(identityRecord.haloSpace.genesisFeedKey, "Genesis feed key is required.", {
3437
3483
  F: __dxlog_file13,
3438
- L: 165,
3484
+ L: 160,
3439
3485
  S: this,
3440
3486
  A: [
3441
3487
  "identityRecord.haloSpace.genesisFeedKey",
@@ -3444,7 +3490,7 @@ var IdentityManager = class {
3444
3490
  });
3445
3491
  invariant8(identityRecord.haloSpace.dataFeedKey, "Data feed key is required.", {
3446
3492
  F: __dxlog_file13,
3447
- L: 166,
3493
+ L: 161,
3448
3494
  S: this,
3449
3495
  A: [
3450
3496
  "identityRecord.haloSpace.dataFeedKey",
@@ -3483,7 +3529,7 @@ var IdentityManager = class {
3483
3529
  displayName: this._identity.profileDocument?.displayName
3484
3530
  }, {
3485
3531
  F: __dxlog_file13,
3486
- L: 208,
3532
+ L: 199,
3487
3533
  S: this,
3488
3534
  C: (f, a) => f(...a)
3489
3535
  });
@@ -3494,7 +3540,7 @@ var IdentityManager = class {
3494
3540
  profile: identity.profileDocument
3495
3541
  }, {
3496
3542
  F: __dxlog_file13,
3497
- L: 214,
3543
+ L: 205,
3498
3544
  S: this,
3499
3545
  C: (f, a) => f(...a)
3500
3546
  });
@@ -3524,20 +3570,20 @@ var IdentityManager = class {
3524
3570
  };
3525
3571
  }
3526
3572
  /**
3527
- * Accept an existing identity. Expects its device key to be authorized (now or later).
3573
+ * Prepare an identity object as the first step of acceptIdentity flow.
3528
3574
  */
3529
- async acceptIdentity(params) {
3575
+ async prepareIdentity(params) {
3530
3576
  log11("accepting identity", {
3531
3577
  params
3532
3578
  }, {
3533
3579
  F: __dxlog_file13,
3534
- L: 252,
3580
+ L: 244,
3535
3581
  S: this,
3536
3582
  C: (f, a) => f(...a)
3537
3583
  });
3538
3584
  invariant8(!this._identity, "Identity already exists.", {
3539
3585
  F: __dxlog_file13,
3540
- L: 253,
3586
+ L: 245,
3541
3587
  S: this,
3542
3588
  A: [
3543
3589
  "!this._identity",
@@ -3558,23 +3604,32 @@ var IdentityManager = class {
3558
3604
  const identity = await this._constructIdentity(identityRecord);
3559
3605
  await identity.open(new Context4(void 0, {
3560
3606
  F: __dxlog_file13,
3561
- L: 268
3607
+ L: 259
3562
3608
  }));
3609
+ return {
3610
+ identity,
3611
+ identityRecord
3612
+ };
3613
+ }
3614
+ /**
3615
+ * Accept an existing identity. Expects its device key to be authorized (now or later).
3616
+ */
3617
+ async acceptIdentity(identity, identityRecord, profile) {
3563
3618
  this._identity = identity;
3564
- await this._metadataStore.setIdentityRecord(identityRecord);
3565
3619
  await this._identity.ready();
3620
+ await this._metadataStore.setIdentityRecord(identityRecord);
3566
3621
  log11.trace("dxos.halo.identity", {
3567
- identityKey: identityRecord.identityKey,
3622
+ identityKey: this._identity.identityKey,
3568
3623
  displayName: this._identity.profileDocument?.displayName
3569
3624
  }, {
3570
3625
  F: __dxlog_file13,
3571
- L: 272,
3626
+ L: 273,
3572
3627
  S: this,
3573
3628
  C: (f, a) => f(...a)
3574
3629
  });
3575
3630
  await this.updateDeviceProfile({
3576
3631
  ...this.createDefaultDeviceProfile(),
3577
- ...params.deviceProfile
3632
+ ...profile
3578
3633
  });
3579
3634
  this.stateUpdate.emit();
3580
3635
  log11("accepted identity", {
@@ -3582,11 +3637,10 @@ var IdentityManager = class {
3582
3637
  deviceKey: identity.deviceKey
3583
3638
  }, {
3584
3639
  F: __dxlog_file13,
3585
- L: 282,
3640
+ L: 284,
3586
3641
  S: this,
3587
3642
  C: (f, a) => f(...a)
3588
3643
  });
3589
- return identity;
3590
3644
  }
3591
3645
  /**
3592
3646
  * Update the profile document of an existing identity.
@@ -3594,7 +3648,7 @@ var IdentityManager = class {
3594
3648
  async updateProfile(profile) {
3595
3649
  invariant8(this._identity, "Identity not initialized.", {
3596
3650
  F: __dxlog_file13,
3597
- L: 290,
3651
+ L: 291,
3598
3652
  S: this,
3599
3653
  A: [
3600
3654
  "this._identity",
@@ -3625,7 +3679,7 @@ var IdentityManager = class {
3625
3679
  async updateDeviceProfile(profile) {
3626
3680
  invariant8(this._identity, "Identity not initialized.", {
3627
3681
  F: __dxlog_file13,
3628
- L: 307,
3682
+ L: 308,
3629
3683
  S: this,
3630
3684
  A: [
3631
3685
  "this._identity",
@@ -3661,7 +3715,7 @@ var IdentityManager = class {
3661
3715
  async _constructIdentity(identityRecord) {
3662
3716
  invariant8(!this._identity, void 0, {
3663
3717
  F: __dxlog_file13,
3664
- L: 333,
3718
+ L: 334,
3665
3719
  S: this,
3666
3720
  A: [
3667
3721
  "!this._identity",
@@ -3672,7 +3726,7 @@ var IdentityManager = class {
3672
3726
  identityRecord
3673
3727
  }, {
3674
3728
  F: __dxlog_file13,
3675
- L: 334,
3729
+ L: 335,
3676
3730
  S: this,
3677
3731
  C: (f, a) => f(...a)
3678
3732
  });
@@ -3687,7 +3741,7 @@ var IdentityManager = class {
3687
3741
  });
3688
3742
  invariant8(identityRecord.haloSpace.controlFeedKey, void 0, {
3689
3743
  F: __dxlog_file13,
3690
- L: 347,
3744
+ L: 348,
3691
3745
  S: this,
3692
3746
  A: [
3693
3747
  "identityRecord.haloSpace.controlFeedKey",
@@ -3699,7 +3753,7 @@ var IdentityManager = class {
3699
3753
  });
3700
3754
  invariant8(identityRecord.haloSpace.dataFeedKey, void 0, {
3701
3755
  F: __dxlog_file13,
3702
- L: 351,
3756
+ L: 352,
3703
3757
  S: this,
3704
3758
  A: [
3705
3759
  "identityRecord.haloSpace.dataFeedKey",
@@ -3736,11 +3790,10 @@ var IdentityManager = class {
3736
3790
  identityKey: identityRecord.identityKey
3737
3791
  }, {
3738
3792
  F: __dxlog_file13,
3739
- L: 380,
3793
+ L: 381,
3740
3794
  S: this,
3741
3795
  C: (f, a) => f(...a)
3742
3796
  });
3743
- this._callbacks?.onIdentityConstruction?.(identity);
3744
3797
  if (identityRecord.haloSpace.controlTimeframe) {
3745
3798
  identity.controlPipeline.state.setTargetTimeframe(identityRecord.haloSpace.controlTimeframe);
3746
3799
  }
@@ -4013,7 +4066,7 @@ var DataSpace = class {
4013
4066
  constructor(params) {
4014
4067
  this._ctx = new Context5(void 0, {
4015
4068
  F: __dxlog_file15,
4016
- L: 95
4069
+ L: 96
4017
4070
  });
4018
4071
  this._cache = void 0;
4019
4072
  this._edgeFeedReplicator = void 0;
@@ -4046,7 +4099,8 @@ var DataSpace = class {
4046
4099
  this._notarizationPlugin = new NotarizationPlugin({
4047
4100
  spaceId: this._inner.id,
4048
4101
  edgeClient: params.edgeHttpClient,
4049
- edgeFeatures: params.edgeFeatures
4102
+ edgeFeatures: params.edgeFeatures,
4103
+ activeEdgePollingInterval: params.activeEdgeNotarizationPollingInterval
4050
4104
  });
4051
4105
  this.authVerifier = new TrustedKeySetAuthVerifier({
4052
4106
  trustedKeysProvider: () => new ComplexSet3(PublicKey8.hash, Array.from(this._inner.spaceState.members.values()).filter((member) => member.role !== SpaceMember5.Role.REMOVED).map((member) => member.key)),
@@ -4065,7 +4119,7 @@ var DataSpace = class {
4065
4119
  state: SpaceState4[this._state]
4066
4120
  }, {
4067
4121
  F: __dxlog_file15,
4068
- L: 170,
4122
+ L: 172,
4069
4123
  S: this,
4070
4124
  C: (f, a) => f(...a)
4071
4125
  });
@@ -4124,15 +4178,16 @@ var DataSpace = class {
4124
4178
  }
4125
4179
  await this._inner.open(new Context5(void 0, {
4126
4180
  F: __dxlog_file15,
4127
- L: 244
4181
+ L: 246
4128
4182
  }));
4183
+ await this._inner.startProtocol();
4129
4184
  await this._edgeFeedReplicator?.open();
4130
4185
  this._state = SpaceState4.SPACE_CONTROL_ONLY;
4131
4186
  log13("new state", {
4132
4187
  state: SpaceState4[this._state]
4133
4188
  }, {
4134
4189
  F: __dxlog_file15,
4135
- L: 249,
4190
+ L: 252,
4136
4191
  S: this,
4137
4192
  C: (f, a) => f(...a)
4138
4193
  });
@@ -4152,14 +4207,14 @@ var DataSpace = class {
4152
4207
  state: SpaceState4[this._state]
4153
4208
  }, {
4154
4209
  F: __dxlog_file15,
4155
- L: 268,
4210
+ L: 271,
4156
4211
  S: this,
4157
4212
  C: (f, a) => f(...a)
4158
4213
  });
4159
4214
  await this._ctx.dispose();
4160
4215
  this._ctx = new Context5(void 0, {
4161
4216
  F: __dxlog_file15,
4162
- L: 270
4217
+ L: 273
4163
4218
  });
4164
4219
  if (this._edgeFeedReplicator) {
4165
4220
  this.inner.protocol.feedAdded.remove(this._onFeedAdded);
@@ -4192,7 +4247,7 @@ var DataSpace = class {
4192
4247
  if (err instanceof CancelledError || err instanceof ContextDisposedError) {
4193
4248
  log13("data pipeline initialization cancelled", err, {
4194
4249
  F: __dxlog_file15,
4195
- L: 308,
4250
+ L: 311,
4196
4251
  S: this,
4197
4252
  C: (f, a) => f(...a)
4198
4253
  });
@@ -4200,7 +4255,7 @@ var DataSpace = class {
4200
4255
  }
4201
4256
  log13.error("Error initializing data pipeline", err, {
4202
4257
  F: __dxlog_file15,
4203
- L: 312,
4258
+ L: 315,
4204
4259
  S: this,
4205
4260
  C: (f, a) => f(...a)
4206
4261
  });
@@ -4209,7 +4264,7 @@ var DataSpace = class {
4209
4264
  state: SpaceState4[this._state]
4210
4265
  }, {
4211
4266
  F: __dxlog_file15,
4212
- L: 314,
4267
+ L: 317,
4213
4268
  S: this,
4214
4269
  C: (f, a) => f(...a)
4215
4270
  });
@@ -4229,13 +4284,13 @@ var DataSpace = class {
4229
4284
  state: SpaceState4[this._state]
4230
4285
  }, {
4231
4286
  F: __dxlog_file15,
4232
- L: 330,
4287
+ L: 333,
4233
4288
  S: this,
4234
4289
  C: (f, a) => f(...a)
4235
4290
  });
4236
4291
  log13("initializing control pipeline", void 0, {
4237
4292
  F: __dxlog_file15,
4238
- L: 332,
4293
+ L: 335,
4239
4294
  S: this,
4240
4295
  C: (f, a) => f(...a)
4241
4296
  });
@@ -4244,21 +4299,21 @@ var DataSpace = class {
4244
4299
  const ready = this.stateUpdate.waitForCondition(() => this._state === SpaceState4.SPACE_READY);
4245
4300
  log13("initializing automerge root", void 0, {
4246
4301
  F: __dxlog_file15,
4247
- L: 340,
4302
+ L: 343,
4248
4303
  S: this,
4249
4304
  C: (f, a) => f(...a)
4250
4305
  });
4251
4306
  this._automergeSpaceState.startProcessingRootDocs();
4252
4307
  log13("waiting for space to be ready", void 0, {
4253
4308
  F: __dxlog_file15,
4254
- L: 344,
4309
+ L: 347,
4255
4310
  S: this,
4256
4311
  C: (f, a) => f(...a)
4257
4312
  });
4258
4313
  await ready;
4259
4314
  log13("space is ready", void 0, {
4260
4315
  F: __dxlog_file15,
4261
- L: 346,
4316
+ L: 349,
4262
4317
  S: this,
4263
4318
  C: (f, a) => f(...a)
4264
4319
  });
@@ -4270,7 +4325,7 @@ var DataSpace = class {
4270
4325
  state: SpaceState4[this._state]
4271
4326
  }, {
4272
4327
  F: __dxlog_file15,
4273
- L: 353,
4328
+ L: 356,
4274
4329
  S: this,
4275
4330
  C: (f, a) => f(...a)
4276
4331
  });
@@ -4287,7 +4342,7 @@ var DataSpace = class {
4287
4342
  await this._createWritableFeeds();
4288
4343
  log13("writable feeds created", void 0, {
4289
4344
  F: __dxlog_file15,
4290
- L: 370,
4345
+ L: 373,
4291
4346
  S: this,
4292
4347
  C: (f, a) => f(...a)
4293
4348
  });
@@ -4341,7 +4396,7 @@ var DataSpace = class {
4341
4396
  count: credentials.length
4342
4397
  }, {
4343
4398
  F: __dxlog_file15,
4344
- L: 428,
4399
+ L: 431,
4345
4400
  S: this,
4346
4401
  C: (f, a) => f(...a)
4347
4402
  });
@@ -4352,14 +4407,14 @@ var DataSpace = class {
4352
4407
  });
4353
4408
  log13("credentials notarized", void 0, {
4354
4409
  F: __dxlog_file15,
4355
- L: 432,
4410
+ L: 435,
4356
4411
  S: this,
4357
4412
  C: (f, a) => f(...a)
4358
4413
  });
4359
4414
  } catch (err) {
4360
4415
  log13.error("error notarizing credentials for feed admission", err, {
4361
4416
  F: __dxlog_file15,
4362
- L: 434,
4417
+ L: 437,
4363
4418
  S: this,
4364
4419
  C: (f, a) => f(...a)
4365
4420
  });
@@ -4374,7 +4429,7 @@ var DataSpace = class {
4374
4429
  rootUrl
4375
4430
  }, {
4376
4431
  F: __dxlog_file15,
4377
- L: 444,
4432
+ L: 447,
4378
4433
  S: this,
4379
4434
  C: (f, a) => f(...a)
4380
4435
  });
@@ -4426,7 +4481,7 @@ var DataSpace = class {
4426
4481
  err
4427
4482
  }, {
4428
4483
  F: __dxlog_file15,
4429
- L: 487,
4484
+ L: 490,
4430
4485
  S: this,
4431
4486
  C: (f, a) => f(...a)
4432
4487
  });
@@ -4516,7 +4571,7 @@ var DataSpace = class {
4516
4571
  state: SpaceState4[this._state]
4517
4572
  }, {
4518
4573
  F: __dxlog_file15,
4519
- L: 569,
4574
+ L: 572,
4520
4575
  S: this,
4521
4576
  C: (f, a) => f(...a)
4522
4577
  });
@@ -4576,6 +4631,7 @@ DataSpace = _ts_decorate6([
4576
4631
  ], DataSpace);
4577
4632
 
4578
4633
  // packages/sdk/client-services/src/packlets/invitations/device-invitation-protocol.ts
4634
+ import { getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
4579
4635
  import { invariant as invariant10 } from "@dxos/invariant";
4580
4636
  import { AlreadyJoinedError as AlreadyJoinedError2 } from "@dxos/protocols";
4581
4637
  import { Invitation as Invitation2 } from "@dxos/protocols/proto/dxos/client/services";
@@ -4606,7 +4662,7 @@ var DeviceInvitationProtocol = class {
4606
4662
  async admit(_, request) {
4607
4663
  invariant10(request.device, void 0, {
4608
4664
  F: __dxlog_file16,
4609
- L: 50,
4665
+ L: 51,
4610
4666
  S: this,
4611
4667
  A: [
4612
4668
  "request.device",
@@ -4614,13 +4670,23 @@ var DeviceInvitationProtocol = class {
4614
4670
  ]
4615
4671
  });
4616
4672
  const identity = this._getIdentity();
4617
- await identity.admitDevice(request.device);
4673
+ const credential = await identity.admitDevice(request.device);
4674
+ invariant10(getCredentialAssertion4(credential)["@type"] === "dxos.halo.credentials.AuthorizedDevice", void 0, {
4675
+ F: __dxlog_file16,
4676
+ L: 54,
4677
+ S: this,
4678
+ A: [
4679
+ "getCredentialAssertion(credential)['@type'] === 'dxos.halo.credentials.AuthorizedDevice'",
4680
+ ""
4681
+ ]
4682
+ });
4618
4683
  return {
4619
4684
  device: {
4620
4685
  identityKey: identity.identityKey,
4621
4686
  haloSpaceKey: identity.haloSpaceKey,
4622
4687
  genesisFeedKey: identity.haloGenesisFeedKey,
4623
- controlTimeframe: identity.controlPipeline.state.timeframe
4688
+ controlTimeframe: identity.controlPipeline.state.timeframe,
4689
+ credential
4624
4690
  }
4625
4691
  };
4626
4692
  }
@@ -4652,7 +4718,7 @@ var DeviceInvitationProtocol = class {
4652
4718
  async accept(response, request) {
4653
4719
  invariant10(response.device, void 0, {
4654
4720
  F: __dxlog_file16,
4655
- L: 95,
4721
+ L: 98,
4656
4722
  S: this,
4657
4723
  A: [
4658
4724
  "response.device",
@@ -4662,7 +4728,7 @@ var DeviceInvitationProtocol = class {
4662
4728
  const { identityKey, haloSpaceKey, genesisFeedKey, controlTimeframe } = response.device;
4663
4729
  invariant10(request.device, void 0, {
4664
4730
  F: __dxlog_file16,
4665
- L: 98,
4731
+ L: 101,
4666
4732
  S: this,
4667
4733
  A: [
4668
4734
  "request.device",
@@ -4678,7 +4744,8 @@ var DeviceInvitationProtocol = class {
4678
4744
  controlFeedKey,
4679
4745
  dataFeedKey,
4680
4746
  controlTimeframe,
4681
- deviceProfile: profile
4747
+ deviceProfile: profile,
4748
+ authorizedDeviceCredential: response.device.credential
4682
4749
  });
4683
4750
  return {
4684
4751
  identityKey
@@ -4690,7 +4757,7 @@ var DeviceInvitationProtocol = class {
4690
4757
  import { scheduleTask as scheduleTask7, TimeoutError as TimeoutError2 } from "@dxos/async";
4691
4758
  import { INVITATION_TIMEOUT } from "@dxos/client-protocol";
4692
4759
  import { ContextDisposedError as ContextDisposedError3 } from "@dxos/context";
4693
- import { createKeyPair, sign } from "@dxos/crypto";
4760
+ import { createKeyPair, sign as sign2 } from "@dxos/crypto";
4694
4761
  import { invariant as invariant15 } from "@dxos/invariant";
4695
4762
  import { PublicKey as PublicKey11 } from "@dxos/keys";
4696
4763
  import { log as log19 } from "@dxos/log";
@@ -4704,7 +4771,7 @@ import { ComplexSet as ComplexSet5 } from "@dxos/util";
4704
4771
 
4705
4772
  // packages/sdk/client-services/src/packlets/invitations/edge-invitation-handler.ts
4706
4773
  import { scheduleMicroTask as scheduleMicroTask3, scheduleTask as scheduleTask5 } from "@dxos/async";
4707
- import { ed25519Signature } from "@dxos/crypto";
4774
+ import { sign } from "@dxos/crypto";
4708
4775
  import { invariant as invariant11 } from "@dxos/invariant";
4709
4776
  import { SpaceId as SpaceId2 } from "@dxos/keys";
4710
4777
  import { log as log14 } from "@dxos/log";
@@ -4861,15 +4928,16 @@ var EdgeInvitationHandler = class {
4861
4928
  return await this._client.joinSpaceByInvitation(spaceId, request);
4862
4929
  } catch (error) {
4863
4930
  if (error instanceof EdgeAuthChallengeError) {
4864
- guardedState.set(this, Invitation4.State.AUTHENTICATING);
4865
4931
  const publicKey = guardedState.current.guestKeypair?.publicKey;
4866
4932
  const privateKey = guardedState.current.guestKeypair?.privateKey;
4867
4933
  if (!privateKey || !publicKey) {
4868
4934
  throw error;
4869
4935
  }
4870
- const signature = await ed25519Signature(privateKey, Buffer.from(error.challenge, "base64"));
4871
- request.signature = Buffer.from(signature).toString("base64");
4872
- return this._client.joinSpaceByInvitation(spaceId, request);
4936
+ const signature = sign(Buffer.from(error.challenge, "base64"), privateKey);
4937
+ return this._client.joinSpaceByInvitation(spaceId, {
4938
+ ...request,
4939
+ signature: Buffer.from(signature).toString("base64")
4940
+ });
4873
4941
  } else {
4874
4942
  throw error;
4875
4943
  }
@@ -5944,7 +6012,7 @@ var InvitationsHandler = class {
5944
6012
  const edgeInvitationHandler = new EdgeInvitationHandler(this._connectionParams?.edgeInvitations, this._edgeClient, {
5945
6013
  onInvitationSuccess: async (admissionResponse, admissionRequest) => {
5946
6014
  const result = await protocol.accept(admissionResponse, admissionRequest);
5947
- log19("admitted by edge", {
6015
+ log19.info("admitted by edge", {
5948
6016
  ...protocol.toJSON()
5949
6017
  }, {
5950
6018
  F: __dxlog_file22,
@@ -6061,8 +6129,7 @@ var InvitationsHandler = class {
6061
6129
  S: this,
6062
6130
  C: (f, a) => f(...a)
6063
6131
  });
6064
- setState(Invitation7.State.AUTHENTICATING);
6065
- const signature = sign(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
6132
+ const signature = sign2(Buffer.from(introductionResponse.challenge), invitation.guestKeypair.privateKey);
6066
6133
  const response = await extension.rpc.InvitationHostService.authenticate({
6067
6134
  signedChallenge: signature
6068
6135
  });
@@ -6177,7 +6244,7 @@ var InvitationsServiceImpl = class {
6177
6244
  };
6178
6245
 
6179
6246
  // packages/sdk/client-services/src/packlets/invitations/space-invitation-protocol.ts
6180
- import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion4 } from "@dxos/credentials";
6247
+ import { createCancelDelegatedSpaceInvitationCredential, createDelegatedSpaceInvitationCredential, getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
6181
6248
  import { writeMessages as writeMessages4 } from "@dxos/feed-store";
6182
6249
  import { invariant as invariant16 } from "@dxos/invariant";
6183
6250
  import { log as log20 } from "@dxos/log";
@@ -6422,7 +6489,7 @@ var SpaceInvitationProtocol = class {
6422
6489
  ]
6423
6490
  });
6424
6491
  const { credential, controlTimeframe, dataTimeframe } = response.space;
6425
- const assertion = getCredentialAssertion4(credential);
6492
+ const assertion = getCredentialAssertion5(credential);
6426
6493
  invariant16(assertion["@type"] === "dxos.halo.credentials.SpaceMember", "Invalid credential", {
6427
6494
  F: __dxlog_file23,
6428
6495
  L: 182,
@@ -7025,24 +7092,282 @@ ClientRpcServer = _ts_decorate8([
7025
7092
  trace8.resource()
7026
7093
  ], ClientRpcServer);
7027
7094
 
7095
+ // packages/sdk/client-services/src/packlets/agents/edge-agent-manager.ts
7096
+ import { DeferredTask as DeferredTask2, Event as Event9, scheduleTask as scheduleTask8, synchronized as synchronized3 } from "@dxos/async";
7097
+ import { Resource as Resource6 } from "@dxos/context";
7098
+ import { invariant as invariant18 } from "@dxos/invariant";
7099
+ import { PublicKey as PublicKey13 } from "@dxos/keys";
7100
+ import { log as log23 } from "@dxos/log";
7101
+ import { EdgeAgentStatus, EdgeCallFailedError as EdgeCallFailedError3 } from "@dxos/protocols";
7102
+ import { SpaceState as SpaceState5 } from "@dxos/protocols/proto/dxos/client/services";
7103
+ function _ts_decorate9(decorators, target, key, desc) {
7104
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7105
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7106
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
7107
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7108
+ }
7109
+ var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/agents/edge-agent-manager.ts";
7110
+ var AGENT_STATUS_QUERY_RETRY_INTERVAL = 5e3;
7111
+ var AGENT_STATUS_QUERY_RETRY_JITTER = 1e3;
7112
+ var EdgeAgentManager = class extends Resource6 {
7113
+ constructor(_edgeFeatures, _edgeHttpClient, _dataSpaceManager, _identity) {
7114
+ super();
7115
+ this._edgeFeatures = _edgeFeatures;
7116
+ this._edgeHttpClient = _edgeHttpClient;
7117
+ this._dataSpaceManager = _dataSpaceManager;
7118
+ this._identity = _identity;
7119
+ this.agentStatusChanged = new Event9();
7120
+ this._lastKnownDeviceCount = 0;
7121
+ }
7122
+ get agentStatus() {
7123
+ return this._agentStatus;
7124
+ }
7125
+ get agentExists() {
7126
+ return this._agentStatus && this._agentStatus !== EdgeAgentStatus.NOT_FOUND;
7127
+ }
7128
+ async createAgent() {
7129
+ invariant18(this.isOpen, void 0, {
7130
+ F: __dxlog_file26,
7131
+ L: 52,
7132
+ S: this,
7133
+ A: [
7134
+ "this.isOpen",
7135
+ ""
7136
+ ]
7137
+ });
7138
+ invariant18(this._edgeHttpClient, void 0, {
7139
+ F: __dxlog_file26,
7140
+ L: 53,
7141
+ S: this,
7142
+ A: [
7143
+ "this._edgeHttpClient",
7144
+ ""
7145
+ ]
7146
+ });
7147
+ invariant18(this._edgeFeatures?.agents, void 0, {
7148
+ F: __dxlog_file26,
7149
+ L: 54,
7150
+ S: this,
7151
+ A: [
7152
+ "this._edgeFeatures?.agents",
7153
+ ""
7154
+ ]
7155
+ });
7156
+ const response = await this._edgeHttpClient.createAgent({
7157
+ identityKey: this._identity.identityKey.toHex(),
7158
+ haloSpaceId: this._identity.haloSpaceId,
7159
+ haloSpaceKey: this._identity.haloSpaceKey.toHex()
7160
+ });
7161
+ const deviceKey = PublicKey13.fromHex(response.deviceKey);
7162
+ await this._identity.admitDevice({
7163
+ deviceKey,
7164
+ controlFeedKey: PublicKey13.fromHex(response.feedKey),
7165
+ // TODO: agents don't have data feed, should be removed
7166
+ dataFeedKey: PublicKey13.random()
7167
+ });
7168
+ log23("agent created", response, {
7169
+ F: __dxlog_file26,
7170
+ L: 71,
7171
+ S: this,
7172
+ C: (f, a) => f(...a)
7173
+ });
7174
+ this._updateStatus(EdgeAgentStatus.ACTIVE, deviceKey);
7175
+ }
7176
+ async _open() {
7177
+ const isEnabled = this._edgeHttpClient && this._edgeFeatures?.agents;
7178
+ log23("edge agent manager open", {
7179
+ isEnabled
7180
+ }, {
7181
+ F: __dxlog_file26,
7182
+ L: 79,
7183
+ S: this,
7184
+ C: (f, a) => f(...a)
7185
+ });
7186
+ if (!isEnabled) {
7187
+ return;
7188
+ }
7189
+ this._lastKnownDeviceCount = this._identity.authorizedDeviceKeys.size;
7190
+ this._fetchAgentStatusTask = new DeferredTask2(this._ctx, async () => {
7191
+ await this._fetchAgentStatus();
7192
+ });
7193
+ this._fetchAgentStatusTask.schedule();
7194
+ this._dataSpaceManager.updated.on(this._ctx, () => {
7195
+ if (this._agentDeviceKey) {
7196
+ this._ensureAgentIsInSpaces(this._agentDeviceKey);
7197
+ }
7198
+ });
7199
+ this._identity.stateUpdate.on(this._ctx, () => {
7200
+ const maybeAgentWasCreated = this._identity.authorizedDeviceKeys.size > this._lastKnownDeviceCount;
7201
+ if (this.agentExists || !maybeAgentWasCreated) {
7202
+ return;
7203
+ }
7204
+ this._lastKnownDeviceCount = this._identity.authorizedDeviceKeys.size;
7205
+ this._fetchAgentStatusTask?.schedule();
7206
+ });
7207
+ }
7208
+ async _close() {
7209
+ this._fetchAgentStatusTask = void 0;
7210
+ this._lastKnownDeviceCount = 0;
7211
+ }
7212
+ async _fetchAgentStatus() {
7213
+ invariant18(this._edgeHttpClient, void 0, {
7214
+ F: __dxlog_file26,
7215
+ L: 113,
7216
+ S: this,
7217
+ A: [
7218
+ "this._edgeHttpClient",
7219
+ ""
7220
+ ]
7221
+ });
7222
+ try {
7223
+ log23("fetching agent status", void 0, {
7224
+ F: __dxlog_file26,
7225
+ L: 115,
7226
+ S: this,
7227
+ C: (f, a) => f(...a)
7228
+ });
7229
+ const { agent } = await this._edgeHttpClient.getAgentStatus({
7230
+ ownerIdentityKey: this._identity.identityKey
7231
+ });
7232
+ const wasAgentCreatedDuringQuery = this._agentStatus === EdgeAgentStatus.ACTIVE;
7233
+ if (!wasAgentCreatedDuringQuery) {
7234
+ const deviceKey = agent.deviceKey ? PublicKey13.fromHex(agent.deviceKey) : void 0;
7235
+ this._updateStatus(agent.status, deviceKey);
7236
+ }
7237
+ } catch (err) {
7238
+ if (err instanceof EdgeCallFailedError3) {
7239
+ if (!err.isRetryable) {
7240
+ log23.warn("non retryable error on agent status fetch attempt", {
7241
+ err
7242
+ }, {
7243
+ F: __dxlog_file26,
7244
+ L: 125,
7245
+ S: this,
7246
+ C: (f, a) => f(...a)
7247
+ });
7248
+ return;
7249
+ }
7250
+ }
7251
+ const retryAfterMs = AGENT_STATUS_QUERY_RETRY_INTERVAL + Math.random() * AGENT_STATUS_QUERY_RETRY_JITTER;
7252
+ log23.info("agent status fetching failed", {
7253
+ err,
7254
+ retryAfterMs
7255
+ }, {
7256
+ F: __dxlog_file26,
7257
+ L: 130,
7258
+ S: this,
7259
+ C: (f, a) => f(...a)
7260
+ });
7261
+ scheduleTask8(this._ctx, () => this._fetchAgentStatusTask?.schedule(), retryAfterMs);
7262
+ }
7263
+ }
7264
+ /**
7265
+ * We don't want notarization plugin to always actively poll edge looking for credentials to notarize,
7266
+ * because most of the time we'll be getting an empty response.
7267
+ * Instead, we stay in active polling mode while there are spaces where we don't see our agent's feed.
7268
+ */
7269
+ _ensureAgentIsInSpaces(agentDeviceKey) {
7270
+ for (const space of this._dataSpaceManager.spaces.values()) {
7271
+ if ([
7272
+ SpaceState5.SPACE_INACTIVE,
7273
+ SpaceState5.SPACE_CLOSED
7274
+ ].includes(space.state)) {
7275
+ continue;
7276
+ }
7277
+ const agentFeedNeedsNotarization = !space.inner.spaceState.feeds.values().some((feed) => feed.assertion.deviceKey.equals(agentDeviceKey));
7278
+ space.notarizationPlugin.setActiveEdgePollingEnabled(agentFeedNeedsNotarization);
7279
+ log23.info("set active edge polling", {
7280
+ enabled: agentFeedNeedsNotarization,
7281
+ spaceId: space.id
7282
+ }, {
7283
+ F: __dxlog_file26,
7284
+ L: 150,
7285
+ S: this,
7286
+ C: (f, a) => f(...a)
7287
+ });
7288
+ }
7289
+ }
7290
+ _updateStatus(status, deviceKey) {
7291
+ this._agentStatus = status;
7292
+ this._agentDeviceKey = deviceKey;
7293
+ this.agentStatusChanged.emit(status);
7294
+ if (deviceKey) {
7295
+ this._ensureAgentIsInSpaces(deviceKey);
7296
+ }
7297
+ log23.info("agent status update", {
7298
+ status
7299
+ }, {
7300
+ F: __dxlog_file26,
7301
+ L: 161,
7302
+ S: this,
7303
+ C: (f, a) => f(...a)
7304
+ });
7305
+ }
7306
+ };
7307
+ _ts_decorate9([
7308
+ synchronized3
7309
+ ], EdgeAgentManager.prototype, "createAgent", null);
7310
+
7311
+ // packages/sdk/client-services/src/packlets/agents/edge-agent-service.ts
7312
+ import { Stream as Stream11 } from "@dxos/codec-protobuf";
7313
+ import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7314
+ import { QueryAgentStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
7315
+ var EdgeAgentServiceImpl = class {
7316
+ constructor(_agentManagerProvider) {
7317
+ this._agentManagerProvider = _agentManagerProvider;
7318
+ }
7319
+ async createAgent() {
7320
+ return (await this._agentManagerProvider()).createAgent();
7321
+ }
7322
+ queryAgentStatus() {
7323
+ return new Stream11(({ ctx, next }) => {
7324
+ next({
7325
+ status: QueryAgentStatusResponse.AgentStatus.UNKNOWN
7326
+ });
7327
+ void this._agentManagerProvider().then((agentManager) => {
7328
+ next({
7329
+ status: mapStatus(agentManager.agentStatus)
7330
+ });
7331
+ agentManager.agentStatusChanged.on(ctx, (newStatus) => {
7332
+ next({
7333
+ status: mapStatus(newStatus)
7334
+ });
7335
+ });
7336
+ });
7337
+ });
7338
+ }
7339
+ };
7340
+ var mapStatus = (agentStatus) => {
7341
+ switch (agentStatus) {
7342
+ case EdgeAgentStatus2.ACTIVE:
7343
+ return QueryAgentStatusResponse.AgentStatus.ACTIVE;
7344
+ case EdgeAgentStatus2.INACTIVE:
7345
+ return QueryAgentStatusResponse.AgentStatus.INACTIVE;
7346
+ case EdgeAgentStatus2.NOT_FOUND:
7347
+ return QueryAgentStatusResponse.AgentStatus.NOT_FOUND;
7348
+ case void 0:
7349
+ return QueryAgentStatusResponse.AgentStatus.UNKNOWN;
7350
+ }
7351
+ };
7352
+
7028
7353
  // packages/sdk/client-services/src/packlets/services/service-context.ts
7029
- import { Mutex as Mutex4, scheduleMicroTask as scheduleMicroTask4, Trigger as Trigger9 } from "@dxos/async";
7030
- import { Context as Context9, Resource as Resource6 } from "@dxos/context";
7031
- import { getCredentialAssertion as getCredentialAssertion5 } from "@dxos/credentials";
7354
+ import { Mutex as Mutex4, Trigger as Trigger9 } from "@dxos/async";
7355
+ import { Context as Context9, Resource as Resource7 } from "@dxos/context";
7356
+ import { getCredentialAssertion as getCredentialAssertion6 } from "@dxos/credentials";
7032
7357
  import { failUndefined as failUndefined2, warnAfterTimeout as warnAfterTimeout2 } from "@dxos/debug";
7033
7358
  import { EchoEdgeReplicator, EchoHost, MeshEchoReplicator, MetadataStore, SpaceManager, valueEncoding } from "@dxos/echo-pipeline";
7034
7359
  import { createChainEdgeIdentity, createEphemeralEdgeIdentity } from "@dxos/edge-client";
7035
7360
  import { FeedFactory, FeedStore } from "@dxos/feed-store";
7036
- import { invariant as invariant18 } from "@dxos/invariant";
7361
+ import { invariant as invariant19 } from "@dxos/invariant";
7037
7362
  import { Keyring } from "@dxos/keyring";
7038
- import { PublicKey as PublicKey13 } from "@dxos/keys";
7039
- import { log as log23 } from "@dxos/log";
7363
+ import { PublicKey as PublicKey14 } from "@dxos/keys";
7364
+ import { log as log24 } from "@dxos/log";
7040
7365
  import { InvalidStorageVersionError, STORAGE_VERSION as STORAGE_VERSION2, trace as trace9 } from "@dxos/protocols";
7041
7366
  import { Invitation as Invitation10 } from "@dxos/protocols/proto/dxos/client/services";
7042
7367
  import { BlobStore } from "@dxos/teleport-extension-object-sync";
7043
7368
  import { trace as Trace3 } from "@dxos/tracing";
7044
7369
  import { safeInstanceof } from "@dxos/util";
7045
- function _ts_decorate9(decorators, target, key, desc) {
7370
+ function _ts_decorate10(decorators, target, key, desc) {
7046
7371
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7047
7372
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7048
7373
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
@@ -7110,8 +7435,8 @@ function _using_ctx3() {
7110
7435
  }
7111
7436
  };
7112
7437
  }
7113
- var __dxlog_file26 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
7114
- var ServiceContext = class extends Resource6 {
7438
+ var __dxlog_file27 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
7439
+ var ServiceContext = class extends Resource7 {
7115
7440
  constructor(storage, level, networkManager, signalManager, _edgeConnection, _edgeHttpClient, _runtimeParams, _edgeFeatures) {
7116
7441
  super();
7117
7442
  this.storage = storage;
@@ -7127,7 +7452,7 @@ var ServiceContext = class extends Resource6 {
7127
7452
  this._meshReplicator = void 0;
7128
7453
  this._echoEdgeReplicator = void 0;
7129
7454
  this._handlerFactories = /* @__PURE__ */ new Map();
7130
- this._instanceId = PublicKey13.random().toHex();
7455
+ this._instanceId = PublicKey14.random().toHex();
7131
7456
  this.metadataStore = new MetadataStore(storage.createDirectory("metadata"));
7132
7457
  this.blobStore = new BlobStore(storage.createDirectory("blobs"));
7133
7458
  this.keyring = new Keyring(storage.createDirectory("keyring"));
@@ -7156,50 +7481,7 @@ var ServiceContext = class extends Resource6 {
7156
7481
  devicePresenceOfflineTimeout: this._runtimeParams?.devicePresenceOfflineTimeout,
7157
7482
  devicePresenceAnnounceInterval: this._runtimeParams?.devicePresenceAnnounceInterval,
7158
7483
  edgeConnection: this._edgeConnection,
7159
- edgeFeatures: this._edgeFeatures,
7160
- callbacks: {
7161
- onIdentityConstruction: (identity) => {
7162
- if (this._edgeConnection) {
7163
- scheduleMicroTask4(this._ctx, async () => {
7164
- try {
7165
- var _usingCtx = _using_ctx3();
7166
- const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
7167
- log23.info("Setting identity on edge connection", {
7168
- identity: identity.identityKey.toHex(),
7169
- oldIdentity: this._edgeConnection.identityKey,
7170
- swarms: this.networkManager.topics
7171
- }, {
7172
- F: __dxlog_file26,
7173
- L: 147,
7174
- S: this,
7175
- C: (f, a) => f(...a)
7176
- });
7177
- await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
7178
- await identity.ready();
7179
- });
7180
- invariant18(identity.deviceCredentialChain, void 0, {
7181
- F: __dxlog_file26,
7182
- L: 157,
7183
- S: this,
7184
- A: [
7185
- "identity.deviceCredentialChain",
7186
- ""
7187
- ]
7188
- });
7189
- this._edgeConnection.setIdentity(await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []));
7190
- this.networkManager.setPeerInfo({
7191
- identityKey: identity.identityKey.toHex(),
7192
- peerKey: identity.deviceKey.toHex()
7193
- });
7194
- } catch (_) {
7195
- _usingCtx.e = _;
7196
- } finally {
7197
- _usingCtx.d();
7198
- }
7199
- });
7200
- }
7201
- }
7202
- }
7484
+ edgeFeatures: this._edgeFeatures
7203
7485
  });
7204
7486
  this.echoHost = new EchoHost({
7205
7487
  kv: this.level
@@ -7219,24 +7501,23 @@ var ServiceContext = class extends Resource6 {
7219
7501
  }
7220
7502
  async _open(ctx) {
7221
7503
  await this._checkStorageVersion();
7222
- log23("opening...", void 0, {
7223
- F: __dxlog_file26,
7224
- L: 218,
7504
+ log24("opening...", void 0, {
7505
+ F: __dxlog_file27,
7506
+ L: 186,
7225
7507
  S: this,
7226
7508
  C: (f, a) => f(...a)
7227
7509
  });
7228
- log23.trace("dxos.sdk.service-context.open", trace9.begin({
7510
+ log24.trace("dxos.sdk.service-context.open", trace9.begin({
7229
7511
  id: this._instanceId
7230
7512
  }), {
7231
- F: __dxlog_file26,
7232
- L: 219,
7513
+ F: __dxlog_file27,
7514
+ L: 187,
7233
7515
  S: this,
7234
7516
  C: (f, a) => f(...a)
7235
7517
  });
7236
- if (this._edgeConnection) {
7237
- this._edgeConnection.setIdentity(await createEphemeralEdgeIdentity());
7238
- await this._edgeConnection.open();
7239
- }
7518
+ await this.identityManager.open(ctx);
7519
+ await this._setNetworkIdentity();
7520
+ await this._edgeConnection?.open();
7240
7521
  await this.signalManager.open();
7241
7522
  await this.networkManager.open();
7242
7523
  await this.echoHost.open(ctx);
@@ -7248,38 +7529,38 @@ var ServiceContext = class extends Resource6 {
7248
7529
  }
7249
7530
  await this.metadataStore.load();
7250
7531
  await this.spaceManager.open();
7251
- await this.identityManager.open(ctx);
7252
7532
  if (this.identityManager.identity) {
7533
+ await this.identityManager.identity.joinNetwork();
7253
7534
  await this._initialize(ctx);
7254
7535
  }
7255
7536
  const loadedInvitations = await this.invitationsManager.loadPersistentInvitations();
7256
- log23("loaded persistent invitations", {
7537
+ log24("loaded persistent invitations", {
7257
7538
  count: loadedInvitations.invitations?.length
7258
7539
  }, {
7259
- F: __dxlog_file26,
7260
- L: 246,
7540
+ F: __dxlog_file27,
7541
+ L: 215,
7261
7542
  S: this,
7262
7543
  C: (f, a) => f(...a)
7263
7544
  });
7264
- log23.trace("dxos.sdk.service-context.open", trace9.end({
7545
+ log24.trace("dxos.sdk.service-context.open", trace9.end({
7265
7546
  id: this._instanceId
7266
7547
  }), {
7267
- F: __dxlog_file26,
7268
- L: 248,
7548
+ F: __dxlog_file27,
7549
+ L: 217,
7269
7550
  S: this,
7270
7551
  C: (f, a) => f(...a)
7271
7552
  });
7272
- log23("opened", void 0, {
7273
- F: __dxlog_file26,
7274
- L: 249,
7553
+ log24("opened", void 0, {
7554
+ F: __dxlog_file27,
7555
+ L: 218,
7275
7556
  S: this,
7276
7557
  C: (f, a) => f(...a)
7277
7558
  });
7278
7559
  }
7279
7560
  async _close(ctx) {
7280
- log23("closing...", void 0, {
7281
- F: __dxlog_file26,
7282
- L: 253,
7561
+ log24("closing...", void 0, {
7562
+ F: __dxlog_file27,
7563
+ L: 222,
7283
7564
  S: this,
7284
7565
  C: (f, a) => f(...a)
7285
7566
  });
@@ -7287,6 +7568,7 @@ var ServiceContext = class extends Resource6 {
7287
7568
  await this.identityManager.identity.space.spaceState.removeCredentialProcessor(this._deviceSpaceSync);
7288
7569
  }
7289
7570
  await this.dataSpaceManager?.close();
7571
+ await this.edgeAgentManager?.close();
7290
7572
  await this.identityManager.close();
7291
7573
  await this.spaceManager.close();
7292
7574
  await this.feedStore.close();
@@ -7295,26 +7577,28 @@ var ServiceContext = class extends Resource6 {
7295
7577
  await this.networkManager.close();
7296
7578
  await this.signalManager.close();
7297
7579
  await this._edgeConnection?.close();
7298
- log23("closed", void 0, {
7299
- F: __dxlog_file26,
7300
- L: 268,
7580
+ log24("closed", void 0, {
7581
+ F: __dxlog_file27,
7582
+ L: 238,
7301
7583
  S: this,
7302
7584
  C: (f, a) => f(...a)
7303
7585
  });
7304
7586
  }
7305
7587
  async createIdentity(params = {}) {
7306
7588
  const identity = await this.identityManager.createIdentity(params);
7589
+ await this._setNetworkIdentity();
7590
+ await identity.joinNetwork();
7307
7591
  await this._initialize(new Context9(void 0, {
7308
- F: __dxlog_file26,
7309
- L: 273
7592
+ F: __dxlog_file27,
7593
+ L: 245
7310
7594
  }));
7311
7595
  return identity;
7312
7596
  }
7313
7597
  getInvitationHandler(invitation) {
7314
7598
  const factory = this._handlerFactories.get(invitation.kind);
7315
- invariant18(factory, `Unknown invitation kind: ${invitation.kind}`, {
7316
- F: __dxlog_file26,
7317
- L: 279,
7599
+ invariant19(factory, `Unknown invitation kind: ${invitation.kind}`, {
7600
+ F: __dxlog_file27,
7601
+ L: 251,
7318
7602
  S: this,
7319
7603
  A: [
7320
7604
  "factory",
@@ -7332,10 +7616,15 @@ var ServiceContext = class extends Resource6 {
7332
7616
  }
7333
7617
  }
7334
7618
  async _acceptIdentity(params) {
7335
- const identity = await this.identityManager.acceptIdentity(params);
7619
+ const { identity, identityRecord } = await this.identityManager.prepareIdentity(params);
7620
+ await this._setNetworkIdentity({
7621
+ deviceCredential: params.authorizedDeviceCredential
7622
+ });
7623
+ await identity.joinNetwork();
7624
+ await this.identityManager.acceptIdentity(identity, identityRecord, params.deviceProfile);
7336
7625
  await this._initialize(new Context9(void 0, {
7337
- F: __dxlog_file26,
7338
- L: 295
7626
+ F: __dxlog_file27,
7627
+ L: 270
7339
7628
  }));
7340
7629
  return identity;
7341
7630
  }
@@ -7347,9 +7636,9 @@ var ServiceContext = class extends Resource6 {
7347
7636
  }
7348
7637
  // Called when identity is created.
7349
7638
  async _initialize(ctx) {
7350
- log23("initializing spaces...", void 0, {
7351
- F: __dxlog_file26,
7352
- L: 310,
7639
+ log24("initializing spaces...", void 0, {
7640
+ F: __dxlog_file27,
7641
+ L: 285,
7353
7642
  S: this,
7354
7643
  C: (f, a) => f(...a)
7355
7644
  });
@@ -7383,10 +7672,12 @@ var ServiceContext = class extends Resource6 {
7383
7672
  edgeFeatures: this._edgeFeatures
7384
7673
  });
7385
7674
  await this.dataSpaceManager.open();
7675
+ this.edgeAgentManager = new EdgeAgentManager(this._edgeFeatures, this._edgeHttpClient, this.dataSpaceManager, identity);
7676
+ await this.edgeAgentManager.open();
7386
7677
  this._handlerFactories.set(Invitation10.Kind.SPACE, (invitation) => {
7387
- invariant18(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7388
- F: __dxlog_file26,
7389
- L: 340,
7678
+ invariant19(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
7679
+ F: __dxlog_file27,
7680
+ L: 323,
7390
7681
  S: this,
7391
7682
  A: [
7392
7683
  "this.dataSpaceManager",
@@ -7398,7 +7689,7 @@ var ServiceContext = class extends Resource6 {
7398
7689
  this.initialized.wake();
7399
7690
  this._deviceSpaceSync = {
7400
7691
  processCredential: async (credential) => {
7401
- const assertion = getCredentialAssertion5(credential);
7692
+ const assertion = getCredentialAssertion6(credential);
7402
7693
  if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
7403
7694
  return;
7404
7695
  }
@@ -7406,33 +7697,33 @@ var ServiceContext = class extends Resource6 {
7406
7697
  return;
7407
7698
  }
7408
7699
  if (!this.dataSpaceManager) {
7409
- log23("dataSpaceManager not initialized yet, ignoring space admission", {
7700
+ log24("dataSpaceManager not initialized yet, ignoring space admission", {
7410
7701
  details: assertion
7411
7702
  }, {
7412
- F: __dxlog_file26,
7413
- L: 356,
7703
+ F: __dxlog_file27,
7704
+ L: 339,
7414
7705
  S: this,
7415
7706
  C: (f, a) => f(...a)
7416
7707
  });
7417
7708
  return;
7418
7709
  }
7419
7710
  if (this.dataSpaceManager.spaces.has(assertion.spaceKey)) {
7420
- log23("space already exists, ignoring space admission", {
7711
+ log24("space already exists, ignoring space admission", {
7421
7712
  details: assertion
7422
7713
  }, {
7423
- F: __dxlog_file26,
7424
- L: 360,
7714
+ F: __dxlog_file27,
7715
+ L: 343,
7425
7716
  S: this,
7426
7717
  C: (f, a) => f(...a)
7427
7718
  });
7428
7719
  return;
7429
7720
  }
7430
7721
  try {
7431
- log23("accepting space recorded in halo", {
7722
+ log24("accepting space recorded in halo", {
7432
7723
  details: assertion
7433
7724
  }, {
7434
- F: __dxlog_file26,
7435
- L: 365,
7725
+ F: __dxlog_file27,
7726
+ L: 348,
7436
7727
  S: this,
7437
7728
  C: (f, a) => f(...a)
7438
7729
  });
@@ -7441,9 +7732,9 @@ var ServiceContext = class extends Resource6 {
7441
7732
  genesisFeedKey: assertion.genesisFeedKey
7442
7733
  });
7443
7734
  } catch (err) {
7444
- log23.catch(err, void 0, {
7445
- F: __dxlog_file26,
7446
- L: 371,
7735
+ log24.catch(err, void 0, {
7736
+ F: __dxlog_file27,
7737
+ L: 354,
7447
7738
  S: this,
7448
7739
  C: (f, a) => f(...a)
7449
7740
  });
@@ -7452,14 +7743,65 @@ var ServiceContext = class extends Resource6 {
7452
7743
  };
7453
7744
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
7454
7745
  }
7746
+ async _setNetworkIdentity(params) {
7747
+ try {
7748
+ var _usingCtx = _using_ctx3();
7749
+ const _ = _usingCtx.u(await this._edgeIdentityUpdateMutex.acquire());
7750
+ let edgeIdentity;
7751
+ const identity = this.identityManager.identity;
7752
+ if (identity) {
7753
+ log24.info("Setting identity on edge connection", {
7754
+ identity: identity.identityKey.toHex(),
7755
+ swarms: this.networkManager.topics
7756
+ }, {
7757
+ F: __dxlog_file27,
7758
+ L: 368,
7759
+ S: this,
7760
+ C: (f, a) => f(...a)
7761
+ });
7762
+ if (params?.deviceCredential) {
7763
+ edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, {
7764
+ credential: params.deviceCredential
7765
+ }, []);
7766
+ } else {
7767
+ await warnAfterTimeout2(1e4, "Waiting for identity to be ready for edge connection", async () => {
7768
+ await identity.ready();
7769
+ });
7770
+ invariant19(identity.deviceCredentialChain, void 0, {
7771
+ F: __dxlog_file27,
7772
+ L: 386,
7773
+ S: this,
7774
+ A: [
7775
+ "identity.deviceCredentialChain",
7776
+ ""
7777
+ ]
7778
+ });
7779
+ edgeIdentity = await createChainEdgeIdentity(identity.signer, identity.identityKey, identity.deviceKey, identity.deviceCredentialChain, []);
7780
+ }
7781
+ } else {
7782
+ edgeIdentity = await createEphemeralEdgeIdentity();
7783
+ }
7784
+ if (this._edgeConnection) {
7785
+ this._edgeConnection.setIdentity(edgeIdentity);
7786
+ }
7787
+ this.networkManager.setPeerInfo({
7788
+ identityKey: edgeIdentity.identityKey,
7789
+ peerKey: edgeIdentity.peerKey
7790
+ });
7791
+ } catch (_) {
7792
+ _usingCtx.e = _;
7793
+ } finally {
7794
+ _usingCtx.d();
7795
+ }
7796
+ }
7455
7797
  };
7456
- _ts_decorate9([
7798
+ _ts_decorate10([
7457
7799
  Trace3.span()
7458
7800
  ], ServiceContext.prototype, "_open", null);
7459
- _ts_decorate9([
7801
+ _ts_decorate10([
7460
7802
  Trace3.span()
7461
7803
  ], ServiceContext.prototype, "_initialize", null);
7462
- ServiceContext = _ts_decorate9([
7804
+ ServiceContext = _ts_decorate10([
7463
7805
  safeInstanceof("dxos.client-services.ServiceContext"),
7464
7806
  Trace3.resource()
7465
7807
  ], ServiceContext);
@@ -7552,11 +7894,11 @@ var toStorageType = (type) => {
7552
7894
 
7553
7895
  // packages/sdk/client-services/src/packlets/storage/level.ts
7554
7896
  import path from "@dxos/node-std/path";
7555
- import { PublicKey as PublicKey14 } from "@dxos/keys";
7897
+ import { PublicKey as PublicKey15 } from "@dxos/keys";
7556
7898
  import { createLevel as createKV } from "@dxos/kv-store";
7557
7899
  var createLevel = async (config) => {
7558
7900
  const persistent = isPersistent(config);
7559
- const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${PublicKey14.random().toHex()}`;
7901
+ const storagePath = persistent ? path.join(getRootPath(config), "level") : `/tmp/dxos-${PublicKey15.random().toHex()}`;
7560
7902
  const level = createKV(storagePath);
7561
7903
  await level.open();
7562
7904
  return level;
@@ -7564,11 +7906,11 @@ var createLevel = async (config) => {
7564
7906
 
7565
7907
  // packages/sdk/client-services/src/packlets/storage/profile-archive.ts
7566
7908
  import { cbor } from "@dxos/automerge/automerge-repo";
7567
- import { invariant as invariant19 } from "@dxos/invariant";
7568
- import { log as log24 } from "@dxos/log";
7909
+ import { invariant as invariant20 } from "@dxos/invariant";
7910
+ import { log as log25 } from "@dxos/log";
7569
7911
  import { ProfileArchiveEntryType } from "@dxos/protocols";
7570
7912
  import { arrayToBuffer as arrayToBuffer2 } from "@dxos/util";
7571
- var __dxlog_file27 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
7913
+ var __dxlog_file28 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
7572
7914
  var encodeProfileArchive = (profile) => cbor.encode(profile);
7573
7915
  var decodeProfileArchive = (data) => cbor.decode(data);
7574
7916
  var exportProfileData = async ({ storage, level }) => {
@@ -7581,10 +7923,10 @@ var exportProfileData = async ({ storage, level }) => {
7581
7923
  {
7582
7924
  const directory = await storage.createDirectory();
7583
7925
  const files = await directory.list();
7584
- log24.info("begin exporting files", {
7926
+ log25.info("begin exporting files", {
7585
7927
  count: files.length
7586
7928
  }, {
7587
- F: __dxlog_file27,
7929
+ F: __dxlog_file28,
7588
7930
  L: 30,
7589
7931
  S: void 0,
7590
7932
  C: (f, a) => f(...a)
@@ -7599,18 +7941,18 @@ var exportProfileData = async ({ storage, level }) => {
7599
7941
  value: data
7600
7942
  });
7601
7943
  }
7602
- log24.info("done exporting files", {
7944
+ log25.info("done exporting files", {
7603
7945
  count: files.length
7604
7946
  }, {
7605
- F: __dxlog_file27,
7947
+ F: __dxlog_file28,
7606
7948
  L: 41,
7607
7949
  S: void 0,
7608
7950
  C: (f, a) => f(...a)
7609
7951
  });
7610
7952
  }
7611
7953
  {
7612
- log24.info("begin exporting kv pairs", void 0, {
7613
- F: __dxlog_file27,
7954
+ log25.info("begin exporting kv pairs", void 0, {
7955
+ F: __dxlog_file28,
7614
7956
  L: 45,
7615
7957
  S: void 0,
7616
7958
  C: (f, a) => f(...a)
@@ -7628,10 +7970,10 @@ var exportProfileData = async ({ storage, level }) => {
7628
7970
  });
7629
7971
  count++;
7630
7972
  }
7631
- log24.info("done exporting kv pairs", {
7973
+ log25.info("done exporting kv pairs", {
7632
7974
  count
7633
7975
  }, {
7634
- F: __dxlog_file27,
7976
+ F: __dxlog_file28,
7635
7977
  L: 56,
7636
7978
  S: void 0,
7637
7979
  C: (f, a) => f(...a)
@@ -7646,8 +7988,8 @@ var importProfileData = async ({ storage, level }, archive) => {
7646
7988
  switch (entry2.type) {
7647
7989
  case ProfileArchiveEntryType.FILE: {
7648
7990
  const directory = await storage.createDirectory();
7649
- invariant19(typeof entry2.key === "string", "Invalid key type", {
7650
- F: __dxlog_file27,
7991
+ invariant20(typeof entry2.key === "string", "Invalid key type", {
7992
+ F: __dxlog_file28,
7651
7993
  L: 79,
7652
7994
  S: void 0,
7653
7995
  A: [
@@ -7656,8 +7998,8 @@ var importProfileData = async ({ storage, level }, archive) => {
7656
7998
  ]
7657
7999
  });
7658
8000
  const file = await directory.getOrCreateFile(entry2.key);
7659
- invariant19(entry2.value instanceof Uint8Array, "Invalid value type", {
7660
- F: __dxlog_file27,
8001
+ invariant20(entry2.value instanceof Uint8Array, "Invalid value type", {
8002
+ F: __dxlog_file28,
7661
8003
  L: 81,
7662
8004
  S: void 0,
7663
8005
  A: [
@@ -7670,8 +8012,8 @@ var importProfileData = async ({ storage, level }, archive) => {
7670
8012
  break;
7671
8013
  }
7672
8014
  case ProfileArchiveEntryType.KEY_VALUE: {
7673
- invariant19(entry2.key instanceof Uint8Array, "Invalid key type", {
7674
- F: __dxlog_file27,
8015
+ invariant20(entry2.key instanceof Uint8Array, "Invalid key type", {
8016
+ F: __dxlog_file28,
7675
8017
  L: 87,
7676
8018
  S: void 0,
7677
8019
  A: [
@@ -7679,8 +8021,8 @@ var importProfileData = async ({ storage, level }, archive) => {
7679
8021
  "'Invalid key type'"
7680
8022
  ]
7681
8023
  });
7682
- invariant19(entry2.value instanceof Uint8Array, "Invalid value type", {
7683
- F: __dxlog_file27,
8024
+ invariant20(entry2.value instanceof Uint8Array, "Invalid value type", {
8025
+ F: __dxlog_file28,
7684
8026
  L: 88,
7685
8027
  S: void 0,
7686
8028
  A: [
@@ -7700,20 +8042,20 @@ var importProfileData = async ({ storage, level }, archive) => {
7700
8042
  if (++count % 1e3 === 0) {
7701
8043
  await batch.write();
7702
8044
  batch = level.batch();
7703
- log24.info("importing", {
8045
+ log25.info("importing", {
7704
8046
  count,
7705
8047
  total: archive.storage.length,
7706
8048
  progress: `${(count / archive.storage.length * 100).toFixed()}%`
7707
8049
  }, {
7708
- F: __dxlog_file27,
8050
+ F: __dxlog_file28,
7709
8051
  L: 101,
7710
8052
  S: void 0,
7711
8053
  C: (f, a) => f(...a)
7712
8054
  });
7713
8055
  }
7714
8056
  }
7715
- log24.info("committing changes..", void 0, {
7716
- F: __dxlog_file27,
8057
+ log25.info("committing changes..", void 0, {
8058
+ F: __dxlog_file28,
7717
8059
  L: 109,
7718
8060
  S: void 0,
7719
8061
  C: (f, a) => f(...a)
@@ -7722,13 +8064,13 @@ var importProfileData = async ({ storage, level }, archive) => {
7722
8064
  };
7723
8065
 
7724
8066
  // packages/sdk/client-services/src/packlets/services/service-host.ts
7725
- import { Event as Event10, synchronized as synchronized3 } from "@dxos/async";
8067
+ import { Event as Event11, synchronized as synchronized4 } from "@dxos/async";
7726
8068
  import { clientServiceBundle } from "@dxos/client-protocol";
7727
8069
  import { Context as Context10 } from "@dxos/context";
7728
8070
  import { EdgeClient, EdgeHttpClient, createStubEdgeIdentity } from "@dxos/edge-client";
7729
- import { invariant as invariant21 } from "@dxos/invariant";
7730
- import { PublicKey as PublicKey17 } from "@dxos/keys";
7731
- import { log as log26 } from "@dxos/log";
8071
+ import { invariant as invariant22 } from "@dxos/invariant";
8072
+ import { PublicKey as PublicKey18 } from "@dxos/keys";
8073
+ import { log as log27 } from "@dxos/log";
7732
8074
  import { EdgeSignalManager, WebsocketSignalManager } from "@dxos/messaging";
7733
8075
  import { SwarmNetworkManager, createIceProvider, createRtcTransportFactory } from "@dxos/network-manager";
7734
8076
  import { trace as trace10 } from "@dxos/protocols";
@@ -7738,10 +8080,10 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
7738
8080
 
7739
8081
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
7740
8082
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
7741
- import { Stream as Stream11 } from "@dxos/codec-protobuf";
7742
- import { invariant as invariant20 } from "@dxos/invariant";
8083
+ import { Stream as Stream12 } from "@dxos/codec-protobuf";
8084
+ import { invariant as invariant21 } from "@dxos/invariant";
7743
8085
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
7744
- var __dxlog_file28 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8086
+ var __dxlog_file29 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
7745
8087
  var DevicesServiceImpl = class {
7746
8088
  constructor(_identityManager) {
7747
8089
  this._identityManager = _identityManager;
@@ -7750,7 +8092,7 @@ var DevicesServiceImpl = class {
7750
8092
  return this._identityManager.updateDeviceProfile(profile);
7751
8093
  }
7752
8094
  queryDevices() {
7753
- return new Stream11(({ next }) => {
8095
+ return new Stream12(({ next }) => {
7754
8096
  const update = () => {
7755
8097
  const deviceKeys = this._identityManager.identity?.authorizedDeviceKeys;
7756
8098
  if (!deviceKeys) {
@@ -7758,8 +8100,8 @@ var DevicesServiceImpl = class {
7758
8100
  devices: []
7759
8101
  });
7760
8102
  } else {
7761
- invariant20(this._identityManager.identity?.presence, "presence not present", {
7762
- F: __dxlog_file28,
8103
+ invariant21(this._identityManager.identity?.presence, "presence not present", {
8104
+ F: __dxlog_file29,
7763
8105
  L: 32,
7764
8106
  S: this,
7765
8107
  A: [
@@ -7819,9 +8161,9 @@ var DevicesServiceImpl = class {
7819
8161
  };
7820
8162
 
7821
8163
  // packages/sdk/client-services/src/packlets/identity/contacts-service.ts
7822
- import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask8, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
7823
- import { Stream as Stream12 } from "@dxos/codec-protobuf";
7824
- import { PublicKey as PublicKey15 } from "@dxos/keys";
8164
+ import { EventSubscriptions as EventSubscriptions4, scheduleTask as scheduleTask9, UpdateScheduler as UpdateScheduler2 } from "@dxos/async";
8165
+ import { Stream as Stream13 } from "@dxos/codec-protobuf";
8166
+ import { PublicKey as PublicKey16 } from "@dxos/keys";
7825
8167
  import { ComplexMap as ComplexMap5, ComplexSet as ComplexSet6 } from "@dxos/util";
7826
8168
  var ContactsServiceImpl = class {
7827
8169
  constructor(_identityManager, _spaceManager, _dataSpaceManagerProvider) {
@@ -7862,7 +8204,7 @@ var ContactsServiceImpl = class {
7862
8204
  });
7863
8205
  }
7864
8206
  return acc;
7865
- }, new ComplexMap5(PublicKey15.hash));
8207
+ }, new ComplexMap5(PublicKey16.hash));
7866
8208
  return {
7867
8209
  contacts: [
7868
8210
  ...contacts.values()
@@ -7870,15 +8212,15 @@ var ContactsServiceImpl = class {
7870
8212
  };
7871
8213
  }
7872
8214
  queryContacts() {
7873
- const subscribedSpaceKeySet = new ComplexSet6(PublicKey15.hash);
7874
- return new Stream12(({ next, ctx }) => {
8215
+ const subscribedSpaceKeySet = new ComplexSet6(PublicKey16.hash);
8216
+ return new Stream13(({ next, ctx }) => {
7875
8217
  const pushUpdateTask = new UpdateScheduler2(ctx, async () => {
7876
8218
  const contacts = await this.getContacts();
7877
8219
  next(contacts);
7878
8220
  }, {
7879
8221
  maxFrequency: 2
7880
8222
  });
7881
- scheduleTask8(ctx, async () => {
8223
+ scheduleTask9(ctx, async () => {
7882
8224
  const subscriptions = new EventSubscriptions4();
7883
8225
  ctx.onDispose(() => subscriptions.clear());
7884
8226
  const subscribeToSpaceAndUpdate = () => {
@@ -7902,27 +8244,27 @@ var ContactsServiceImpl = class {
7902
8244
  };
7903
8245
 
7904
8246
  // packages/sdk/client-services/src/packlets/logging/logging-service.ts
7905
- import { Event as Event9 } from "@dxos/async";
7906
- import { Stream as Stream13 } from "@dxos/codec-protobuf";
7907
- import { PublicKey as PublicKey16 } from "@dxos/keys";
7908
- import { getContextFromEntry, log as log25 } from "@dxos/log";
8247
+ import { Event as Event10 } from "@dxos/async";
8248
+ import { Stream as Stream14 } from "@dxos/codec-protobuf";
8249
+ import { PublicKey as PublicKey17 } from "@dxos/keys";
8250
+ import { getContextFromEntry, log as log26 } from "@dxos/log";
7909
8251
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
7910
8252
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
7911
8253
  var LoggingServiceImpl = class {
7912
8254
  constructor() {
7913
- this._logs = new Event9();
8255
+ this._logs = new Event10();
7914
8256
  this._started = Date.now();
7915
- this._sessionId = PublicKey16.random().toHex();
8257
+ this._sessionId = PublicKey17.random().toHex();
7916
8258
  this._logProcessor = (_config, entry2) => {
7917
8259
  this._logs.emit(entry2);
7918
8260
  };
7919
8261
  }
7920
8262
  async open() {
7921
- log25.runtimeConfig.processors.push(this._logProcessor);
8263
+ log26.runtimeConfig.processors.push(this._logProcessor);
7922
8264
  }
7923
8265
  async close() {
7924
- const index = log25.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
7925
- log25.runtimeConfig.processors.splice(index, 1);
8266
+ const index = log26.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
8267
+ log26.runtimeConfig.processors.splice(index, 1);
7926
8268
  }
7927
8269
  async controlMetrics({ reset, record }) {
7928
8270
  if (reset) {
@@ -7948,7 +8290,7 @@ var LoggingServiceImpl = class {
7948
8290
  stats: numericalValues(events, "duration")
7949
8291
  };
7950
8292
  };
7951
- return new Stream13(({ next }) => {
8293
+ return new Stream14(({ next }) => {
7952
8294
  const update = () => {
7953
8295
  const metrics2 = {
7954
8296
  timestamp: /* @__PURE__ */ new Date(),
@@ -7970,7 +8312,7 @@ var LoggingServiceImpl = class {
7970
8312
  });
7971
8313
  }
7972
8314
  queryLogs(request) {
7973
- return new Stream13(({ ctx, next }) => {
8315
+ return new Stream14(({ ctx, next }) => {
7974
8316
  const handler = (entry2) => {
7975
8317
  if (LOG_PROCESSING > 0) {
7976
8318
  return;
@@ -8026,14 +8368,14 @@ var shouldLog = (entry2, request) => {
8026
8368
  var LOG_PROCESSING = 0;
8027
8369
 
8028
8370
  // packages/sdk/client-services/src/packlets/network/network-service.ts
8029
- import { Stream as Stream14 } from "@dxos/codec-protobuf";
8371
+ import { Stream as Stream15 } from "@dxos/codec-protobuf";
8030
8372
  var NetworkServiceImpl = class {
8031
8373
  constructor(networkManager, signalManager) {
8032
8374
  this.networkManager = networkManager;
8033
8375
  this.signalManager = signalManager;
8034
8376
  }
8035
8377
  queryStatus() {
8036
- return new Stream14(({ next }) => {
8378
+ return new Stream15(({ next }) => {
8037
8379
  const update = () => {
8038
8380
  next({
8039
8381
  swarm: this.networkManager.connectionState,
@@ -8059,7 +8401,7 @@ var NetworkServiceImpl = class {
8059
8401
  };
8060
8402
 
8061
8403
  // packages/sdk/client-services/src/packlets/system/system-service.ts
8062
- import { Stream as Stream15 } from "@dxos/codec-protobuf";
8404
+ import { Stream as Stream16 } from "@dxos/codec-protobuf";
8063
8405
  import { GetDiagnosticsRequest as GetDiagnosticsRequest2 } from "@dxos/protocols/proto/dxos/client/services";
8064
8406
  import { jsonKeyReplacer as jsonKeyReplacer2 } from "@dxos/util";
8065
8407
  var SystemServiceImpl = class {
@@ -8095,7 +8437,7 @@ var SystemServiceImpl = class {
8095
8437
  }
8096
8438
  // TODO(burdon): Standardize interval option in stream request?
8097
8439
  queryStatus({ interval = 3e3 } = {}) {
8098
- return new Stream15(({ next }) => {
8440
+ return new Stream16(({ next }) => {
8099
8441
  const update = () => {
8100
8442
  next({
8101
8443
  status: this._getCurrentStatus()
@@ -8116,13 +8458,13 @@ var SystemServiceImpl = class {
8116
8458
  };
8117
8459
 
8118
8460
  // packages/sdk/client-services/src/packlets/services/service-host.ts
8119
- function _ts_decorate10(decorators, target, key, desc) {
8461
+ function _ts_decorate11(decorators, target, key, desc) {
8120
8462
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8121
8463
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
8122
8464
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8123
8465
  return c > 3 && r && Object.defineProperty(target, key, r), r;
8124
8466
  }
8125
- var __dxlog_file29 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
8467
+ var __dxlog_file30 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
8126
8468
  var ClientServicesHost = class {
8127
8469
  constructor({
8128
8470
  config,
@@ -8136,7 +8478,7 @@ var ClientServicesHost = class {
8136
8478
  runtimeParams
8137
8479
  } = {}) {
8138
8480
  this._tracingService = TRACE_PROCESSOR3.createTraceSender();
8139
- this._statusUpdate = new Event10();
8481
+ this._statusUpdate = new Event11();
8140
8482
  this._edgeConnection = void 0;
8141
8483
  this._edgeHttpClient = void 0;
8142
8484
  this._opening = false;
@@ -8161,8 +8503,8 @@ var ClientServicesHost = class {
8161
8503
  onAcquire: () => {
8162
8504
  if (!this._opening) {
8163
8505
  void this.open(new Context10(void 0, {
8164
- F: __dxlog_file29,
8165
- L: 133
8506
+ F: __dxlog_file30,
8507
+ L: 134
8166
8508
  }));
8167
8509
  }
8168
8510
  },
@@ -8218,25 +8560,25 @@ var ClientServicesHost = class {
8218
8560
  * Can only be called once.
8219
8561
  */
8220
8562
  initialize({ config, ...options }) {
8221
- invariant21(!this._open, "service host is open", {
8222
- F: __dxlog_file29,
8223
- L: 199,
8563
+ invariant22(!this._open, "service host is open", {
8564
+ F: __dxlog_file30,
8565
+ L: 200,
8224
8566
  S: this,
8225
8567
  A: [
8226
8568
  "!this._open",
8227
8569
  "'service host is open'"
8228
8570
  ]
8229
8571
  });
8230
- log26("initializing...", void 0, {
8231
- F: __dxlog_file29,
8232
- L: 200,
8572
+ log27("initializing...", void 0, {
8573
+ F: __dxlog_file30,
8574
+ L: 201,
8233
8575
  S: this,
8234
8576
  C: (f, a) => f(...a)
8235
8577
  });
8236
8578
  if (config) {
8237
- invariant21(!this._config, "config already set", {
8238
- F: __dxlog_file29,
8239
- L: 203,
8579
+ invariant22(!this._config, "config already set", {
8580
+ F: __dxlog_file30,
8581
+ L: 204,
8240
8582
  S: this,
8241
8583
  A: [
8242
8584
  "!this._config",
@@ -8249,9 +8591,9 @@ var ClientServicesHost = class {
8249
8591
  }
8250
8592
  }
8251
8593
  if (!options.signalManager) {
8252
- log26.warn("running signaling without telemetry metadata.", void 0, {
8253
- F: __dxlog_file29,
8254
- L: 211,
8594
+ log27.warn("running signaling without telemetry metadata.", void 0, {
8595
+ F: __dxlog_file30,
8596
+ L: 212,
8255
8597
  S: this,
8256
8598
  C: (f, a) => f(...a)
8257
8599
  });
@@ -8269,9 +8611,9 @@ var ClientServicesHost = class {
8269
8611
  edgeConnection: this._edgeConnection
8270
8612
  }) : new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
8271
8613
  this._signalManager = signalManager;
8272
- invariant21(!this._networkManager, "network manager already set", {
8273
- F: __dxlog_file29,
8274
- L: 233,
8614
+ invariant22(!this._networkManager, "network manager already set", {
8615
+ F: __dxlog_file30,
8616
+ L: 234,
8275
8617
  S: this,
8276
8618
  A: [
8277
8619
  "!this._networkManager",
@@ -8287,9 +8629,9 @@ var ClientServicesHost = class {
8287
8629
  peerKey: this._edgeConnection.peerKey
8288
8630
  } : void 0
8289
8631
  });
8290
- log26("initialized", void 0, {
8291
- F: __dxlog_file29,
8292
- L: 246,
8632
+ log27("initialized", void 0, {
8633
+ F: __dxlog_file30,
8634
+ L: 247,
8293
8635
  S: this,
8294
8636
  C: (f, a) => f(...a)
8295
8637
  });
@@ -8298,45 +8640,45 @@ var ClientServicesHost = class {
8298
8640
  if (this._open) {
8299
8641
  return;
8300
8642
  }
8301
- const traceId = PublicKey17.random().toHex();
8302
- log26.trace("dxos.client-services.host.open", trace10.begin({
8643
+ const traceId = PublicKey18.random().toHex();
8644
+ log27.trace("dxos.client-services.host.open", trace10.begin({
8303
8645
  id: traceId
8304
8646
  }), {
8305
- F: __dxlog_file29,
8306
- L: 257,
8647
+ F: __dxlog_file30,
8648
+ L: 258,
8307
8649
  S: this,
8308
8650
  C: (f, a) => f(...a)
8309
8651
  });
8310
- invariant21(this._config, "config not set", {
8311
- F: __dxlog_file29,
8312
- L: 259,
8652
+ invariant22(this._config, "config not set", {
8653
+ F: __dxlog_file30,
8654
+ L: 260,
8313
8655
  S: this,
8314
8656
  A: [
8315
8657
  "this._config",
8316
8658
  "'config not set'"
8317
8659
  ]
8318
8660
  });
8319
- invariant21(this._storage, "storage not set", {
8320
- F: __dxlog_file29,
8321
- L: 260,
8661
+ invariant22(this._storage, "storage not set", {
8662
+ F: __dxlog_file30,
8663
+ L: 261,
8322
8664
  S: this,
8323
8665
  A: [
8324
8666
  "this._storage",
8325
8667
  "'storage not set'"
8326
8668
  ]
8327
8669
  });
8328
- invariant21(this._signalManager, "signal manager not set", {
8329
- F: __dxlog_file29,
8330
- L: 261,
8670
+ invariant22(this._signalManager, "signal manager not set", {
8671
+ F: __dxlog_file30,
8672
+ L: 262,
8331
8673
  S: this,
8332
8674
  A: [
8333
8675
  "this._signalManager",
8334
8676
  "'signal manager not set'"
8335
8677
  ]
8336
8678
  });
8337
- invariant21(this._networkManager, "network manager not set", {
8338
- F: __dxlog_file29,
8339
- L: 262,
8679
+ invariant22(this._networkManager, "network manager not set", {
8680
+ F: __dxlog_file30,
8681
+ L: 263,
8340
8682
  S: this,
8341
8683
  A: [
8342
8684
  "this._networkManager",
@@ -8344,11 +8686,11 @@ var ClientServicesHost = class {
8344
8686
  ]
8345
8687
  });
8346
8688
  this._opening = true;
8347
- log26("opening...", {
8689
+ log27("opening...", {
8348
8690
  lockKey: this._resourceLock?.lockKey
8349
8691
  }, {
8350
- F: __dxlog_file29,
8351
- L: 265,
8692
+ F: __dxlog_file30,
8693
+ L: 266,
8352
8694
  S: this,
8353
8695
  C: (f, a) => f(...a)
8354
8696
  });
@@ -8363,6 +8705,10 @@ var ClientServicesHost = class {
8363
8705
  await this._serviceContext.initialized.wait();
8364
8706
  return this._serviceContext.dataSpaceManager;
8365
8707
  };
8708
+ const agentManagerProvider = async () => {
8709
+ await this._serviceContext.initialized.wait();
8710
+ return this._serviceContext.edgeAgentManager;
8711
+ };
8366
8712
  const identityService = new IdentityServiceImpl(this._serviceContext.identityManager, this._serviceContext.keyring, () => this._serviceContext.dataSpaceManager, (params) => this._createIdentity(params), (profile) => this._serviceContext.broadcastProfileUpdate(profile));
8367
8713
  this._serviceRegistry.setServices({
8368
8714
  SystemService: this._systemService,
@@ -8381,7 +8727,8 @@ var ClientServicesHost = class {
8381
8727
  events: new DevtoolsHostEvents(),
8382
8728
  config: this._config,
8383
8729
  context: this._serviceContext
8384
- })
8730
+ }),
8731
+ EdgeAgentService: new EdgeAgentServiceImpl(agentManagerProvider)
8385
8732
  });
8386
8733
  await this._serviceContext.open(ctx);
8387
8734
  await identityService.open();
@@ -8400,19 +8747,19 @@ var ClientServicesHost = class {
8400
8747
  this._open = true;
8401
8748
  this._statusUpdate.emit();
8402
8749
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
8403
- log26("opened", {
8750
+ log27("opened", {
8404
8751
  deviceKey
8405
8752
  }, {
8406
- F: __dxlog_file29,
8407
- L: 354,
8753
+ F: __dxlog_file30,
8754
+ L: 362,
8408
8755
  S: this,
8409
8756
  C: (f, a) => f(...a)
8410
8757
  });
8411
- log26.trace("dxos.client-services.host.open", trace10.end({
8758
+ log27.trace("dxos.client-services.host.open", trace10.end({
8412
8759
  id: traceId
8413
8760
  }), {
8414
- F: __dxlog_file29,
8415
- L: 355,
8761
+ F: __dxlog_file30,
8762
+ L: 363,
8416
8763
  S: this,
8417
8764
  C: (f, a) => f(...a)
8418
8765
  });
@@ -8422,11 +8769,11 @@ var ClientServicesHost = class {
8422
8769
  return;
8423
8770
  }
8424
8771
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
8425
- log26("closing...", {
8772
+ log27("closing...", {
8426
8773
  deviceKey
8427
8774
  }, {
8428
- F: __dxlog_file29,
8429
- L: 366,
8775
+ F: __dxlog_file30,
8776
+ L: 374,
8430
8777
  S: this,
8431
8778
  C: (f, a) => f(...a)
8432
8779
  });
@@ -8440,44 +8787,44 @@ var ClientServicesHost = class {
8440
8787
  await this._level?.close();
8441
8788
  this._open = false;
8442
8789
  this._statusUpdate.emit();
8443
- log26("closed", {
8790
+ log27("closed", {
8444
8791
  deviceKey
8445
8792
  }, {
8446
- F: __dxlog_file29,
8447
- L: 375,
8793
+ F: __dxlog_file30,
8794
+ L: 383,
8448
8795
  S: this,
8449
8796
  C: (f, a) => f(...a)
8450
8797
  });
8451
8798
  }
8452
8799
  async reset() {
8453
- const traceId = PublicKey17.random().toHex();
8454
- log26.trace("dxos.sdk.client-services-host.reset", trace10.begin({
8800
+ const traceId = PublicKey18.random().toHex();
8801
+ log27.trace("dxos.sdk.client-services-host.reset", trace10.begin({
8455
8802
  id: traceId
8456
8803
  }), {
8457
- F: __dxlog_file29,
8458
- L: 380,
8804
+ F: __dxlog_file30,
8805
+ L: 388,
8459
8806
  S: this,
8460
8807
  C: (f, a) => f(...a)
8461
8808
  });
8462
- log26.info("resetting...", void 0, {
8463
- F: __dxlog_file29,
8464
- L: 382,
8809
+ log27.info("resetting...", void 0, {
8810
+ F: __dxlog_file30,
8811
+ L: 390,
8465
8812
  S: this,
8466
8813
  C: (f, a) => f(...a)
8467
8814
  });
8468
8815
  await this._serviceContext?.close();
8469
8816
  await this._storage.reset();
8470
- log26.info("reset", void 0, {
8471
- F: __dxlog_file29,
8472
- L: 385,
8817
+ log27.info("reset", void 0, {
8818
+ F: __dxlog_file30,
8819
+ L: 393,
8473
8820
  S: this,
8474
8821
  C: (f, a) => f(...a)
8475
8822
  });
8476
- log26.trace("dxos.sdk.client-services-host.reset", trace10.end({
8823
+ log27.trace("dxos.sdk.client-services-host.reset", trace10.end({
8477
8824
  id: traceId
8478
8825
  }), {
8479
- F: __dxlog_file29,
8480
- L: 386,
8826
+ F: __dxlog_file30,
8827
+ L: 394,
8481
8828
  S: this,
8482
8829
  C: (f, a) => f(...a)
8483
8830
  });
@@ -8489,21 +8836,21 @@ var ClientServicesHost = class {
8489
8836
  return identity;
8490
8837
  }
8491
8838
  };
8492
- _ts_decorate10([
8839
+ _ts_decorate11([
8493
8840
  Trace4.info()
8494
8841
  ], ClientServicesHost.prototype, "_opening", void 0);
8495
- _ts_decorate10([
8842
+ _ts_decorate11([
8496
8843
  Trace4.info()
8497
8844
  ], ClientServicesHost.prototype, "_open", void 0);
8498
- _ts_decorate10([
8499
- synchronized3,
8845
+ _ts_decorate11([
8846
+ synchronized4,
8500
8847
  Trace4.span()
8501
8848
  ], ClientServicesHost.prototype, "open", null);
8502
- _ts_decorate10([
8503
- synchronized3,
8849
+ _ts_decorate11([
8850
+ synchronized4,
8504
8851
  Trace4.span()
8505
8852
  ], ClientServicesHost.prototype, "close", null);
8506
- ClientServicesHost = _ts_decorate10([
8853
+ ClientServicesHost = _ts_decorate11([
8507
8854
  Trace4.resource()
8508
8855
  ], ClientServicesHost);
8509
8856
 
@@ -8541,6 +8888,8 @@ export {
8541
8888
  Lock,
8542
8889
  isLocked,
8543
8890
  ClientRpcServer,
8891
+ EdgeAgentManager,
8892
+ EdgeAgentServiceImpl,
8544
8893
  ServiceContext,
8545
8894
  ServiceRegistry,
8546
8895
  createStorageObjects,
@@ -8551,4 +8900,4 @@ export {
8551
8900
  importProfileData,
8552
8901
  ClientServicesHost
8553
8902
  };
8554
- //# sourceMappingURL=chunk-UEQIHAL2.mjs.map
8903
+ //# sourceMappingURL=chunk-IPWEAPT2.mjs.map