@dxos/protocols 0.8.4-main.fffef41 → 0.8.4-staging.ac66bdf99f

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 (286) hide show
  1. package/README.md +1 -1
  2. package/dist/src/FeedProtocol.d.ts +528 -0
  3. package/dist/src/FeedProtocol.d.ts.map +1 -0
  4. package/dist/src/FeedProtocol.js +237 -0
  5. package/dist/src/FeedProtocol.js.map +1 -0
  6. package/dist/src/FunctionProtocol.d.ts +8 -2
  7. package/dist/src/FunctionProtocol.d.ts.map +1 -1
  8. package/dist/src/buf/proto/gen/dxos/client/queue_pb.d.ts +237 -0
  9. package/dist/src/buf/proto/gen/dxos/client/queue_pb.d.ts.map +1 -0
  10. package/dist/src/buf/proto/gen/dxos/client/queue_pb.js +44 -0
  11. package/dist/src/buf/proto/gen/dxos/client/queue_pb.js.map +1 -0
  12. package/dist/src/buf/proto/gen/dxos/client/services_pb.d.ts +64 -3
  13. package/dist/src/buf/proto/gen/dxos/client/services_pb.d.ts.map +1 -1
  14. package/dist/src/buf/proto/gen/dxos/client/services_pb.js +68 -37
  15. package/dist/src/buf/proto/gen/dxos/client/services_pb.js.map +1 -1
  16. package/dist/src/buf/proto/gen/dxos/config_pb.d.ts +106 -0
  17. package/dist/src/buf/proto/gen/dxos/config_pb.d.ts.map +1 -1
  18. package/dist/src/buf/proto/gen/dxos/config_pb.js +72 -1
  19. package/dist/src/buf/proto/gen/dxos/config_pb.js.map +1 -1
  20. package/dist/src/buf/proto/gen/dxos/echo/metadata_pb.d.ts +6 -0
  21. package/dist/src/buf/proto/gen/dxos/echo/metadata_pb.d.ts.map +1 -1
  22. package/dist/src/buf/proto/gen/dxos/echo/metadata_pb.js +1 -1
  23. package/dist/src/buf/proto/gen/dxos/echo/metadata_pb.js.map +1 -1
  24. package/dist/src/buf/proto/gen/dxos/echo/query_pb.d.ts +12 -2
  25. package/dist/src/buf/proto/gen/dxos/echo/query_pb.d.ts.map +1 -1
  26. package/dist/src/buf/proto/gen/dxos/echo/query_pb.js +1 -1
  27. package/dist/src/buf/proto/gen/dxos/echo/query_pb.js.map +1 -1
  28. package/dist/src/buf/proto/gen/dxos/echo/service_pb.d.ts +55 -9
  29. package/dist/src/buf/proto/gen/dxos/echo/service_pb.d.ts.map +1 -1
  30. package/dist/src/buf/proto/gen/dxos/echo/service_pb.js +15 -5
  31. package/dist/src/buf/proto/gen/dxos/echo/service_pb.js.map +1 -1
  32. package/dist/src/buf/proto/gen/dxos/edge/messenger_pb.d.ts +28 -0
  33. package/dist/src/buf/proto/gen/dxos/edge/messenger_pb.d.ts.map +1 -1
  34. package/dist/src/buf/proto/gen/dxos/edge/messenger_pb.js +10 -5
  35. package/dist/src/buf/proto/gen/dxos/edge/messenger_pb.js.map +1 -1
  36. package/dist/src/buf/proto/gen/dxos/google_pb.js +1 -1
  37. package/dist/src/buf/proto/gen/dxos/google_pb.js.map +1 -1
  38. package/dist/src/buf/proto/gen/dxos/halo/credentials_pb.d.ts +39 -0
  39. package/dist/src/buf/proto/gen/dxos/halo/credentials_pb.d.ts.map +1 -1
  40. package/dist/src/buf/proto/gen/dxos/halo/credentials_pb.js +27 -2
  41. package/dist/src/buf/proto/gen/dxos/halo/credentials_pb.js.map +1 -1
  42. package/dist/src/buf/proto/gen/dxos/iframe_pb.d.ts +1 -10
  43. package/dist/src/buf/proto/gen/dxos/iframe_pb.d.ts.map +1 -1
  44. package/dist/src/buf/proto/gen/dxos/iframe_pb.js +1 -1
  45. package/dist/src/buf/proto/gen/dxos/iframe_pb.js.map +1 -1
  46. package/dist/src/buf/proto/gen/dxos/rpc_pb.d.ts +24 -0
  47. package/dist/src/buf/proto/gen/dxos/rpc_pb.d.ts.map +1 -1
  48. package/dist/src/buf/proto/gen/dxos/rpc_pb.js +12 -7
  49. package/dist/src/buf/proto/gen/dxos/rpc_pb.js.map +1 -1
  50. package/dist/src/buf/proto/gen/dxos/tracing_pb.d.ts +1 -139
  51. package/dist/src/buf/proto/gen/dxos/tracing_pb.d.ts.map +1 -1
  52. package/dist/src/buf/proto/gen/dxos/tracing_pb.js +11 -45
  53. package/dist/src/buf/proto/gen/dxos/tracing_pb.js.map +1 -1
  54. package/dist/src/codec.test.js +1 -1
  55. package/dist/src/edge/EdgeFunctionEnv.d.ts +108 -0
  56. package/dist/src/edge/EdgeFunctionEnv.d.ts.map +1 -0
  57. package/dist/src/edge/EdgeFunctionEnv.js +4 -0
  58. package/dist/src/edge/EdgeFunctionEnv.js.map +1 -0
  59. package/dist/src/{edge.d.ts → edge/edge.d.ts} +204 -26
  60. package/dist/src/edge/edge.d.ts.map +1 -0
  61. package/dist/src/{edge.js → edge/edge.js} +32 -14
  62. package/dist/src/edge/edge.js.map +1 -0
  63. package/dist/src/{edge-error.d.ts → edge/errors.d.ts} +6 -7
  64. package/dist/src/edge/errors.d.ts.map +1 -0
  65. package/dist/src/{edge-error.js → edge/errors.js} +14 -15
  66. package/dist/src/edge/errors.js.map +1 -0
  67. package/dist/src/edge/index.d.ts +5 -0
  68. package/dist/src/edge/index.d.ts.map +1 -0
  69. package/dist/src/edge/index.js +8 -0
  70. package/dist/src/edge/index.js.map +1 -0
  71. package/dist/src/edge/registry.d.ts +127 -0
  72. package/dist/src/edge/registry.d.ts.map +1 -0
  73. package/dist/src/edge/registry.js +79 -0
  74. package/dist/src/edge/registry.js.map +1 -0
  75. package/dist/src/errors/base-errors.d.ts +86 -8
  76. package/dist/src/errors/base-errors.d.ts.map +1 -1
  77. package/dist/src/errors/base-errors.js +4 -20
  78. package/dist/src/errors/base-errors.js.map +1 -1
  79. package/dist/src/errors/encoding.d.ts +2 -2
  80. package/dist/src/errors/encoding.d.ts.map +1 -1
  81. package/dist/src/errors/encoding.js +1 -1
  82. package/dist/src/errors/encoding.js.map +1 -1
  83. package/dist/src/errors/errors.d.ts +619 -42
  84. package/dist/src/errors/errors.d.ts.map +1 -1
  85. package/dist/src/errors/errors.js +50 -104
  86. package/dist/src/errors/errors.js.map +1 -1
  87. package/dist/src/errors/errors.test.js +2 -2
  88. package/dist/src/errors/errors.test.js.map +1 -1
  89. package/dist/src/errors/helpers.d.ts +9 -5
  90. package/dist/src/errors/helpers.d.ts.map +1 -1
  91. package/dist/src/errors/helpers.js +3 -3
  92. package/dist/src/errors/helpers.js.map +1 -1
  93. package/dist/src/errors/index.d.ts +5 -5
  94. package/dist/src/errors/index.js +5 -5
  95. package/dist/src/feed-replication.d.ts.map +1 -1
  96. package/dist/src/index.d.ts +12 -13
  97. package/dist/src/index.d.ts.map +1 -1
  98. package/dist/src/index.js +11 -12
  99. package/dist/src/index.js.map +1 -1
  100. package/dist/src/indexing.test.js +1 -1
  101. package/dist/src/messenger.d.ts +16 -0
  102. package/dist/src/messenger.d.ts.map +1 -0
  103. package/dist/src/messenger.js +4 -0
  104. package/dist/src/messenger.js.map +1 -0
  105. package/dist/src/proto/gen/dxos/client/services.d.ts +1009 -845
  106. package/dist/src/proto/gen/dxos/client/services.d.ts.map +1 -1
  107. package/dist/src/proto/gen/dxos/client/services.js +107 -94
  108. package/dist/src/proto/gen/dxos/client/services.js.map +1 -1
  109. package/dist/src/proto/gen/dxos/config.d.ts +59 -0
  110. package/dist/src/proto/gen/dxos/config.d.ts.map +1 -1
  111. package/dist/src/proto/gen/dxos/config.js +26 -0
  112. package/dist/src/proto/gen/dxos/config.js.map +1 -1
  113. package/dist/src/proto/gen/dxos/devtools/host.d.ts +31 -31
  114. package/dist/src/proto/gen/dxos/devtools/host.d.ts.map +1 -1
  115. package/dist/src/proto/gen/dxos/echo/metadata.d.ts +4 -0
  116. package/dist/src/proto/gen/dxos/echo/metadata.d.ts.map +1 -1
  117. package/dist/src/proto/gen/dxos/echo/metadata.js.map +1 -1
  118. package/dist/src/proto/gen/dxos/echo/query.d.ts +17 -1
  119. package/dist/src/proto/gen/dxos/echo/query.d.ts.map +1 -1
  120. package/dist/src/proto/gen/dxos/echo/query.js.map +1 -1
  121. package/dist/src/proto/gen/dxos/echo/service.d.ts +34 -8
  122. package/dist/src/proto/gen/dxos/echo/service.d.ts.map +1 -1
  123. package/dist/src/proto/gen/dxos/edge/messenger.d.ts +24 -0
  124. package/dist/src/proto/gen/dxos/edge/messenger.d.ts.map +1 -1
  125. package/dist/src/proto/gen/dxos/edge/messenger.js.map +1 -1
  126. package/dist/src/proto/gen/dxos/halo/credentials.d.ts +15 -1
  127. package/dist/src/proto/gen/dxos/halo/credentials.d.ts.map +1 -1
  128. package/dist/src/proto/gen/dxos/halo/credentials.js +9 -0
  129. package/dist/src/proto/gen/dxos/halo/credentials.js.map +1 -1
  130. package/dist/src/proto/gen/dxos/iframe.d.ts +0 -10
  131. package/dist/src/proto/gen/dxos/iframe.d.ts.map +1 -1
  132. package/dist/src/proto/gen/dxos/iframe.js.map +1 -1
  133. package/dist/src/proto/gen/dxos/rpc.d.ts +19 -0
  134. package/dist/src/proto/gen/dxos/rpc.d.ts.map +1 -1
  135. package/dist/src/proto/gen/dxos/rpc.js.map +1 -1
  136. package/dist/src/proto/gen/dxos/tracing.d.ts +0 -79
  137. package/dist/src/proto/gen/dxos/tracing.d.ts.map +1 -1
  138. package/dist/src/proto/gen/google/protobuf.d.ts +326 -40
  139. package/dist/src/proto/gen/google/protobuf.d.ts.map +1 -1
  140. package/dist/src/proto/gen/google/protobuf.js +127 -1
  141. package/dist/src/proto/gen/google/protobuf.js.map +1 -1
  142. package/dist/src/proto/gen/index.d.ts +40 -7
  143. package/dist/src/proto/gen/index.d.ts.map +1 -1
  144. package/dist/src/proto/gen/index.js +1 -1
  145. package/dist/src/proto/gen/index.js.map +1 -1
  146. package/dist/src/proto/index.d.ts +2 -2
  147. package/dist/src/proto/index.js +1 -1
  148. package/dist/src/proto/types.d.ts +1 -1
  149. package/dist/src/space-archive.d.ts +60 -1
  150. package/dist/src/space-archive.d.ts.map +1 -1
  151. package/dist/src/space-archive.js +13 -1
  152. package/dist/src/space-archive.js.map +1 -1
  153. package/dist/src/types.d.ts +2 -2
  154. package/dist/tsconfig.tsbuildinfo +1 -1
  155. package/package.json +19 -15
  156. package/src/FeedProtocol.ts +320 -0
  157. package/src/FunctionProtocol.ts +8 -6
  158. package/src/buf/proto/gen/dxos/agent/dashboard_pb.ts +1 -1
  159. package/src/buf/proto/gen/dxos/agent/echo-proxy_pb.ts +1 -1
  160. package/src/buf/proto/gen/dxos/agent/epoch_pb.ts +1 -1
  161. package/src/buf/proto/gen/dxos/agent/functions_pb.ts +1 -1
  162. package/src/buf/proto/gen/dxos/bot_pb.ts +1 -1
  163. package/src/buf/proto/gen/dxos/client/invitation_pb.ts +1 -1
  164. package/src/buf/proto/gen/dxos/client/logging_pb.ts +1 -1
  165. package/src/buf/proto/gen/dxos/client/queue_pb.ts +286 -0
  166. package/src/buf/proto/gen/dxos/client/services_pb.ts +114 -40
  167. package/src/buf/proto/gen/dxos/config_pb.ts +125 -2
  168. package/src/buf/proto/gen/dxos/devtools/diagnostics_pb.ts +1 -1
  169. package/src/buf/proto/gen/dxos/devtools/host_pb.ts +1 -1
  170. package/src/buf/proto/gen/dxos/devtools/swarm_pb.ts +1 -1
  171. package/src/buf/proto/gen/dxos/echo/blob_pb.ts +1 -1
  172. package/src/buf/proto/gen/dxos/echo/feed_pb.ts +1 -1
  173. package/src/buf/proto/gen/dxos/echo/filter_pb.ts +1 -1
  174. package/src/buf/proto/gen/dxos/echo/indexing_pb.ts +1 -1
  175. package/src/buf/proto/gen/dxos/echo/metadata_pb.ts +9 -2
  176. package/src/buf/proto/gen/dxos/echo/model/document_pb.ts +1 -1
  177. package/src/buf/proto/gen/dxos/echo/model/messenger_pb.ts +1 -1
  178. package/src/buf/proto/gen/dxos/echo/model/text_pb.ts +1 -1
  179. package/src/buf/proto/gen/dxos/echo/object_pb.ts +1 -1
  180. package/src/buf/proto/gen/dxos/echo/query_pb.ts +16 -4
  181. package/src/buf/proto/gen/dxos/echo/service_pb.ts +68 -16
  182. package/src/buf/proto/gen/dxos/echo/snapshot_pb.ts +1 -1
  183. package/src/buf/proto/gen/dxos/echo/timeframe_pb.ts +1 -1
  184. package/src/buf/proto/gen/dxos/edge/calls_pb.ts +1 -1
  185. package/src/buf/proto/gen/dxos/edge/messenger_pb.ts +39 -6
  186. package/src/buf/proto/gen/dxos/edge/signal_pb.ts +1 -1
  187. package/src/buf/proto/gen/dxos/error_pb.ts +1 -1
  188. package/src/buf/proto/gen/dxos/field_options_pb.ts +1 -1
  189. package/src/buf/proto/gen/dxos/google_pb.ts +1 -1
  190. package/src/buf/proto/gen/dxos/gravity_pb.ts +1 -1
  191. package/src/buf/proto/gen/dxos/halo/credentials/auth_pb.ts +1 -1
  192. package/src/buf/proto/gen/dxos/halo/credentials/greet_pb.ts +1 -1
  193. package/src/buf/proto/gen/dxos/halo/credentials/identity_pb.ts +1 -1
  194. package/src/buf/proto/gen/dxos/halo/credentials_pb.ts +49 -3
  195. package/src/buf/proto/gen/dxos/halo/invitations_pb.ts +1 -1
  196. package/src/buf/proto/gen/dxos/halo/keyring_pb.ts +1 -1
  197. package/src/buf/proto/gen/dxos/halo/keys_pb.ts +1 -1
  198. package/src/buf/proto/gen/dxos/halo/signed_pb.ts +1 -1
  199. package/src/buf/proto/gen/dxos/iframe_pb.ts +3 -14
  200. package/src/buf/proto/gen/dxos/keys_pb.ts +1 -1
  201. package/src/buf/proto/gen/dxos/mesh/bridge_pb.ts +1 -1
  202. package/src/buf/proto/gen/dxos/mesh/broadcast_pb.ts +1 -1
  203. package/src/buf/proto/gen/dxos/mesh/messaging_pb.ts +1 -1
  204. package/src/buf/proto/gen/dxos/mesh/muxer_pb.ts +1 -1
  205. package/src/buf/proto/gen/dxos/mesh/presence_pb.ts +1 -1
  206. package/src/buf/proto/gen/dxos/mesh/protocol_pb.ts +1 -1
  207. package/src/buf/proto/gen/dxos/mesh/replicator_pb.ts +1 -1
  208. package/src/buf/proto/gen/dxos/mesh/signal_pb.ts +1 -1
  209. package/src/buf/proto/gen/dxos/mesh/swarm_pb.ts +1 -1
  210. package/src/buf/proto/gen/dxos/mesh/teleport/admission-discovery_pb.ts +1 -1
  211. package/src/buf/proto/gen/dxos/mesh/teleport/auth_pb.ts +1 -1
  212. package/src/buf/proto/gen/dxos/mesh/teleport/automerge_pb.ts +1 -1
  213. package/src/buf/proto/gen/dxos/mesh/teleport/blobsync_pb.ts +1 -1
  214. package/src/buf/proto/gen/dxos/mesh/teleport/control_pb.ts +1 -1
  215. package/src/buf/proto/gen/dxos/mesh/teleport/gossip_pb.ts +1 -1
  216. package/src/buf/proto/gen/dxos/mesh/teleport/notarization_pb.ts +1 -1
  217. package/src/buf/proto/gen/dxos/mesh/teleport/replicator_pb.ts +1 -1
  218. package/src/buf/proto/gen/dxos/registry_pb.ts +1 -1
  219. package/src/buf/proto/gen/dxos/rpc_pb.ts +37 -8
  220. package/src/buf/proto/gen/dxos/service/agentmanager_pb.ts +1 -1
  221. package/src/buf/proto/gen/dxos/service/publisher_pb.ts +1 -1
  222. package/src/buf/proto/gen/dxos/service/supervisor_pb.ts +1 -1
  223. package/src/buf/proto/gen/dxos/service/tunnel_pb.ts +1 -1
  224. package/src/buf/proto/gen/dxos/tracing_pb.ts +12 -179
  225. package/src/buf/proto/gen/dxos/type_pb.ts +1 -1
  226. package/src/buf/proto/gen/dxos/value_pb.ts +1 -1
  227. package/src/buf/proto/gen/example/testing/data_pb.ts +1 -1
  228. package/src/buf/proto/gen/example/testing/rpc_pb.ts +1 -1
  229. package/src/codec.test.ts +1 -1
  230. package/src/edge/EdgeFunctionEnv.ts +191 -0
  231. package/src/{edge.ts → edge/edge.ts} +166 -39
  232. package/src/{edge-error.ts → edge/errors.ts} +15 -16
  233. package/src/edge/index.ts +8 -0
  234. package/src/edge/registry.ts +96 -0
  235. package/src/errors/base-errors.ts +4 -22
  236. package/src/errors/encoding.ts +2 -3
  237. package/src/errors/errors.test.ts +2 -2
  238. package/src/errors/errors.ts +57 -124
  239. package/src/errors/helpers.ts +6 -7
  240. package/src/errors/index.ts +5 -5
  241. package/src/feed-replication.ts +1 -0
  242. package/src/index.ts +12 -13
  243. package/src/indexing.test.ts +1 -1
  244. package/src/messenger.ts +22 -0
  245. package/src/proto/dxos/client/queue.proto +81 -0
  246. package/src/proto/dxos/client/services.proto +19 -1
  247. package/src/proto/dxos/config.proto +48 -1
  248. package/src/proto/dxos/echo/metadata.proto +3 -0
  249. package/src/proto/dxos/echo/query.proto +4 -1
  250. package/src/proto/dxos/echo/service.proto +27 -6
  251. package/src/proto/dxos/edge/messenger.proto +10 -0
  252. package/src/proto/dxos/halo/credentials.proto +15 -0
  253. package/src/proto/dxos/iframe.proto +1 -3
  254. package/src/proto/dxos/rpc.proto +7 -0
  255. package/src/proto/dxos/tracing.proto +0 -40
  256. package/src/proto/gen/dxos/client/services.ts +1009 -845
  257. package/src/proto/gen/dxos/config.ts +59 -0
  258. package/src/proto/gen/dxos/devtools/host.ts +31 -31
  259. package/src/proto/gen/dxos/echo/metadata.ts +4 -0
  260. package/src/proto/gen/dxos/echo/query.ts +17 -1
  261. package/src/proto/gen/dxos/echo/service.ts +33 -8
  262. package/src/proto/gen/dxos/edge/messenger.ts +24 -0
  263. package/src/proto/gen/dxos/halo/credentials.ts +15 -1
  264. package/src/proto/gen/dxos/iframe.ts +0 -10
  265. package/src/proto/gen/dxos/rpc.ts +19 -0
  266. package/src/proto/gen/dxos/tracing.ts +0 -76
  267. package/src/proto/gen/google/protobuf.ts +326 -40
  268. package/src/proto/gen/index.ts +41 -8
  269. package/src/proto/index.ts +2 -2
  270. package/src/proto/types.ts +1 -1
  271. package/src/space-archive.ts +70 -1
  272. package/src/types.ts +2 -2
  273. package/dist/src/edge-error.d.ts.map +0 -1
  274. package/dist/src/edge-error.js.map +0 -1
  275. package/dist/src/edge.d.ts.map +0 -1
  276. package/dist/src/edge.js.map +0 -1
  277. package/dist/src/query.d.ts +0 -5
  278. package/dist/src/query.d.ts.map +0 -1
  279. package/dist/src/query.js +0 -8
  280. package/dist/src/query.js.map +0 -1
  281. package/dist/src/queue.d.ts +0 -37
  282. package/dist/src/queue.d.ts.map +0 -1
  283. package/dist/src/queue.js +0 -8
  284. package/dist/src/queue.js.map +0 -1
  285. package/src/query.ts +0 -8
  286. package/src/queue.ts +0 -51
@@ -8,11 +8,25 @@ import { BaseError } from '@dxos/errors';
8
8
  import { invariant } from '@dxos/invariant';
9
9
  import { SpaceId } from '@dxos/keys';
10
10
 
11
+ /**
12
+ * HTTP header sent on every Edge request to classify traffic for metering.
13
+ */
14
+ export const EDGE_CLIENT_TAG_HEADER = 'X-DXOS-Client-Tag';
15
+
11
16
  // TODO(burdon): Rename EdgerRouterEndpoint.
12
17
  // If we would rename it, we need to be careful to not break composer production.
13
18
  export enum EdgeService {
14
19
  AUTOMERGE_REPLICATOR = 'automerge-replicator',
20
+ /**
21
+ * Control feed replicator (hypercore append only logs) for the space.
22
+ */
23
+ // TODO(mykola): Remove once we migrate to keyhive for access control.
15
24
  FEED_REPLICATOR = 'feed-replicator',
25
+ /**
26
+ * Feed replicator (ordered data list) for the space.
27
+ */
28
+ // TODO(mykola): Rename to FEED_REPLICATOR when we migrate to keyhive for access control.
29
+ QUEUE_REPLICATOR = 'queue-replicator',
16
30
  SWARM = 'swarm',
17
31
  SIGNAL = 'signal',
18
32
  STATUS = 'status',
@@ -23,13 +37,15 @@ export type EdgeSuccess<T> = {
23
37
  data: T;
24
38
  };
25
39
 
26
- export type SerializedError = {
27
- code?: string;
28
- message?: string;
29
- context?: Record<string, unknown>;
30
- stack?: string;
31
- cause?: SerializedError;
32
- };
40
+ const _SerializedError = Schema.Struct({
41
+ name: Schema.optional(Schema.String),
42
+ message: Schema.optional(Schema.String),
43
+ context: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
44
+ stack: Schema.optional(Schema.String),
45
+ cause: Schema.optional(Schema.suspend(() => SerializedError)),
46
+ });
47
+ export interface SerializedError extends Schema.Schema.Type<typeof _SerializedError> {}
48
+ export const SerializedError: Schema.Schema<SerializedError, SerializedError, never> = _SerializedError;
33
49
 
34
50
  export type EdgeErrorData = { type: string } & Record<string, any>;
35
51
 
@@ -37,11 +53,6 @@ export type EdgeErrorData = { type: string } & Record<string, any>;
37
53
  * This is the shape of the error response from the Edge service,
38
54
  * when the error is gracefully handled, the Response will be an object with this shape and have status code 200.
39
55
  */
40
- // TODO(dmaretskyi): Refactor this type to just be { success: false, error: SerializedError }
41
- // reason -> error.message
42
- // cause -> error.cause
43
- // errorData.type -> error.code
44
- // ...errorData -> error.context
45
56
  export type EdgeFailure = {
46
57
  /**
47
58
  * Branded Type.
@@ -50,11 +61,11 @@ export type EdgeFailure = {
50
61
  /**
51
62
  * An explanation of why the call failed. Used mostly for logging and monitoring.
52
63
  */
53
- reason: string;
64
+ message: string;
54
65
  /**
55
66
  * Cause Error captured on the EDGE service to aid debugging on the client.
56
67
  */
57
- cause?: SerializedError;
68
+ error?: SerializedError;
58
69
  /**
59
70
  * Information that can be used to retry the request such that it will succeed, for example:
60
71
  * 1. { type: 'auth_required', challenge: string }
@@ -62,16 +73,16 @@ export type EdgeFailure = {
62
73
  * 2. { type: 'user_confirmation_required', dialog: { title: string, message: string, confirmation_payload: string } }
63
74
  * Requires showing a confirmation dialog to a user and retrying the request with confirmation_payload included
64
75
  * if the user confirms.
65
- * When errorData is returned simply retrying the request won't have any effect.
66
- * EdgeHttpClient should parse well-known errorData into Error types and throw.
76
+ * When data is returned simply retrying the request won't have any effect.
77
+ * EdgeHttpClient should parse well-known data into Error types and throw.
67
78
  */
68
- errorData?: EdgeErrorData;
79
+ data?: EdgeErrorData;
69
80
  };
70
81
 
71
82
  /**
72
83
  * Represents a body response from the Edge service.
73
84
  */
74
- export type EdgeBody<T> = EdgeSuccess<T> | EdgeFailure;
85
+ export type EdgeEnvelope<T> = EdgeSuccess<T> | EdgeFailure;
75
86
 
76
87
  /**
77
88
  * Use this to create a response from the Edge service.
@@ -92,21 +103,32 @@ export const EdgeResponse = Object.freeze({
92
103
  );
93
104
  },
94
105
  failure: ({
95
- reason,
96
- cause,
97
- errorData,
106
+ message,
107
+ error,
108
+ errorEncoded,
109
+ data,
98
110
  shouldRetryAfter,
99
111
  status = 500,
100
112
  }: {
101
113
  /**
102
114
  * An explanation of why the call failed. Used mostly for logging and monitoring.
103
115
  */
104
- reason: string;
116
+ message: string;
105
117
  /**
106
118
  * Error that caused the failure.
107
119
  * Useful for debugging.
120
+ *
121
+ * Use only one of the fields `error` or `errorEncoded`.s
122
+ */
123
+ error?: Error;
124
+ /**
125
+ * Encoded Error that caused the failure.
126
+ * Useful for debugging.
127
+ *
128
+ * Use only one of the fields `error` or `errorEncoded`.
108
129
  */
109
- cause?: Error;
130
+ errorEncoded?: SerializedError;
131
+
110
132
  /**
111
133
  * Information that can be used to retry the request such that it will succeed, for example:
112
134
  * 1. { type: 'auth_required', challenge: string }
@@ -114,10 +136,10 @@ export const EdgeResponse = Object.freeze({
114
136
  * 2. { type: 'user_confirmation_required', dialog: { title: string, message: string, confirmation_payload: string } }
115
137
  * Requires showing a confirmation dialog to a user and retrying the request with confirmation_payload included
116
138
  * if the user confirms.
117
- * When errorData is returned simply retrying the request won't have any effect.
118
- * EdgeHttpClient should parse well-known errorData into Error types and throw.
139
+ * When data is returned simply retrying the request won't have any effect.
140
+ * EdgeHttpClient should parse well-known data into Error types and throw.
119
141
  */
120
- errorData?: EdgeErrorData;
142
+ data?: EdgeErrorData;
121
143
  /**
122
144
  * If provided, this request will be marked as retryable and the client will wait for the specified number of milliseconds before retrying.
123
145
  * If not provided, the client will not retry the request.
@@ -138,9 +160,9 @@ export const EdgeResponse = Object.freeze({
138
160
  return new Response(
139
161
  JSON.stringify({
140
162
  success: false,
141
- reason,
142
- errorData,
143
- cause: cause ? ErrorCodec.encode(cause) : undefined,
163
+ message,
164
+ data,
165
+ error: error ? ErrorCodec.encode(error) : errorEncoded,
144
166
  } satisfies EdgeFailure),
145
167
  {
146
168
  status,
@@ -232,20 +254,19 @@ export type UploadFunctionRequest = {
232
254
  * Runtime cannot be changed once the function was deployed.
233
255
  * @default Runtime.WORKERS_FOR_PLATFORMS
234
256
  */
235
- runtime?: Runtime;
257
+ runtime?: FunctionRuntimeKind;
236
258
  };
237
259
 
238
260
  /**
239
261
  * Note: Do not change the values of these enums, this values are stored in the FunctionVersions database.
240
262
  */
241
- export enum Runtime {
263
+ export const FunctionRuntimeKind = Schema.Enums({
242
264
  // https://developers.cloudflare.com/cloudflare-for-platforms/workers-for-platforms/
243
- WORKERS_FOR_PLATFORMS = 'WORKERS_FOR_PLATFORMS',
265
+ WORKERS_FOR_PLATFORMS: 'WORKERS_FOR_PLATFORMS',
244
266
  // https://developers.cloudflare.com/workers/runtime-apis/bindings/worker-loader/
245
- WORKER_LOADER = 'WORKER_LOADER',
246
- // Local worker dispatcher for testing.
247
- TEST = 'TEST',
248
- }
267
+ WORKER_LOADER: 'WORKER_LOADER',
268
+ });
269
+ export type FunctionRuntimeKind = Schema.Schema.Type<typeof FunctionRuntimeKind>;
249
270
 
250
271
  export type UploadFunctionResponseBody = {
251
272
  functionId: string;
@@ -408,15 +429,15 @@ const MAX_ERROR_DEPTH = 3;
408
429
  */
409
430
  export const ErrorCodec = Object.freeze({
410
431
  encode: (err: Error, depth: number = 0): SerializedError => ({
411
- code: 'code' in err ? (err as any).code : undefined,
432
+ name: 'name' in err ? err.name : (err as any).code || 'Error',
412
433
  message: err.message,
413
434
  stack: err.stack,
414
435
  cause: err.cause instanceof Error && depth < MAX_ERROR_DEPTH ? ErrorCodec.encode(err.cause, depth + 1) : undefined,
415
436
  }),
416
437
  decode: (serializedError: SerializedError, depth: number = 0): Error => {
417
438
  let err: Error;
418
- if (typeof serializedError.code === 'string') {
419
- err = new BaseError(serializedError.code, {
439
+ if (typeof serializedError.name === 'string') {
440
+ err = new BaseError(serializedError.name, {
420
441
  message: serializedError.message ?? 'Unknown error',
421
442
  cause:
422
443
  serializedError.cause && depth < MAX_ERROR_DEPTH
@@ -475,3 +496,109 @@ export const EdgeHttpErrorCodec = Object.freeze({
475
496
  return ErrorCodec.decode(body.error);
476
497
  },
477
498
  });
499
+
500
+ //
501
+ // Data management.
502
+ //
503
+
504
+ export type ListSpacesRequest = { limit?: number; cursor?: string; order?: 'asc' | 'desc' };
505
+ export type ListSpacesResponse = {
506
+ spaces: SpaceActivityEntry[];
507
+ cursor?: string;
508
+ limit: number;
509
+ };
510
+
511
+ export type ListActiveIdentitiesRequest = { cursor?: string; limit?: number };
512
+ export type ListActiveIdentitiesResponse = {
513
+ identities: {
514
+ identityKey: string;
515
+ haloSpaceId: string | null;
516
+ createdAt: string | null;
517
+ agentKey: string | null;
518
+ hasRecovery: boolean;
519
+ }[];
520
+ cursor?: string;
521
+ complete: boolean;
522
+ totalCount: number;
523
+ };
524
+
525
+ export type InspectSpaceRequest = { spaceId: string };
526
+ export type InspectSpaceResponse = {
527
+ spaceId: string;
528
+ metadata: { createdAt: string; identityKey?: string; status?: 'active' | 'deleting' } | null;
529
+ members: {
530
+ count: number;
531
+ list: { identityKey: string; role?: string; agentKey?: string }[];
532
+ };
533
+ controlFeeds: {
534
+ replicationProgress: { [feedKey: string]: { replicated: number; processed: number } };
535
+ };
536
+ echo: {
537
+ dataFeeds: {
538
+ count: number;
539
+ totalBlocks: number;
540
+ byNamespace: { namespace: string; feeds: { feedId: string; blockCount: number }[] }[];
541
+ };
542
+ documentCount: number;
543
+ objectCount: number;
544
+ deletedObjectCount: number;
545
+ indexedDocumentCount: number;
546
+ objectsByType: { typeDxn: string; count: number }[];
547
+ indexerStatus: {
548
+ indexingInProgress: boolean;
549
+ cursors: { indexName: string; sourceName: string; resourceId: string | null; cursor: string | number }[];
550
+ totalChanges: number;
551
+ };
552
+ };
553
+ usageInLast30Days: {
554
+ lastActivity: string | null;
555
+ wsEvents: number;
556
+ httpEvents: number;
557
+ totalEvents: number;
558
+ } | null;
559
+ durableObjects: { type: string; doId: string }[];
560
+ };
561
+
562
+ export type InspectIdentityRequest = { identityKey: string };
563
+ export type InspectIdentityResponse = {
564
+ identityKey: string;
565
+ agentKey: string | null;
566
+ haloSpaceId: string | null;
567
+ hasRecovery: boolean;
568
+ routerDoId: string;
569
+ agentDoId: string | null;
570
+ ownedFunctions: { id: string; name: string; versionCount: number }[];
571
+ spaces: InspectSpaceResponse[];
572
+ };
573
+
574
+ /** Matches the SerializedSpace format from @dxos/echo-db, extended with spaceId. */
575
+ export type SpaceExportPayload = {
576
+ version: number;
577
+ timestamp: string;
578
+ spaceId: string;
579
+ objects: Record<string, unknown>[];
580
+ };
581
+
582
+ export type SpaceActivityEntry = {
583
+ spaceId: string;
584
+ lastActivity: string;
585
+ totalEvents: number;
586
+ metadata: { createdAt: string; identityKey?: string; status?: 'active' | 'deleting' } | null;
587
+ };
588
+
589
+ export type SpaceExportResult = {
590
+ spaceId: string;
591
+ downloadPath: string;
592
+ downloadUrl: string;
593
+ expiresAt: string;
594
+ objectCount: number;
595
+ sizeBytes: number;
596
+ };
597
+
598
+ export type ExportSpaceRequest = { spaceId: string; origin: string };
599
+
600
+ export type DeleteSpaceRequest = { spaceId: string };
601
+ export type DeleteSpaceResponse = { status: string; spaceId: string };
602
+
603
+ export type DeleteIdentityRequest = { identityKey: string };
604
+ export type DeleteIdentityResponse = { status: string; identityKey: string };
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type EdgeErrorData, type EdgeFailure, EdgeHttpErrorCodec, ErrorCodec } from './edge.js';
5
+ import { type EdgeErrorData, type EdgeFailure, EdgeHttpErrorCodec, ErrorCodec } from './edge.ts';
6
6
 
7
7
  // TODO(burdon): Reconcile with @dxos/errors.
8
8
  /**
@@ -16,11 +16,11 @@ import { type EdgeErrorData, type EdgeFailure, EdgeHttpErrorCodec, ErrorCodec }
16
16
  export class EdgeCallFailedError extends Error {
17
17
  public static fromUnsuccessfulResponse(response: Response, body: EdgeFailure): EdgeCallFailedError {
18
18
  const error = new EdgeCallFailedError({
19
- reason: body.reason,
20
- errorData: body.errorData,
21
- isRetryable: body.errorData == null && response.headers.has('Retry-After'),
19
+ message: body.message,
20
+ data: body.data,
21
+ isRetryable: body.data == null && response.headers.has('Retry-After'),
22
22
  retryAfterMs: getRetryAfterMillis(response),
23
- cause: body.cause ? ErrorCodec.decode(body.cause) : undefined,
23
+ cause: body.error ? ErrorCodec.decode(body.error) : undefined,
24
24
  });
25
25
 
26
26
  return error;
@@ -28,7 +28,7 @@ export class EdgeCallFailedError extends Error {
28
28
 
29
29
  public static async fromHttpFailure(response: Response): Promise<EdgeCallFailedError> {
30
30
  return new EdgeCallFailedError({
31
- reason: `HTTP code ${response.status}: ${response.statusText}.`,
31
+ message: `HTTP code ${response.status}: ${response.statusText}.`,
32
32
  isRetryable: isRetryableCode(response.status),
33
33
  retryAfterMs: getRetryAfterMillis(response),
34
34
  cause: await EdgeHttpErrorCodec.decode(response),
@@ -37,27 +37,26 @@ export class EdgeCallFailedError extends Error {
37
37
 
38
38
  public static fromProcessingFailureCause(cause: Error): EdgeCallFailedError {
39
39
  return new EdgeCallFailedError({
40
- reason: 'Error processing request.',
40
+ message: 'Error processing request.',
41
41
  isRetryable: true,
42
42
  cause,
43
43
  });
44
44
  }
45
45
 
46
- readonly reason: string;
47
- readonly errorData?: EdgeErrorData;
46
+ readonly data?: EdgeErrorData;
48
47
  readonly isRetryable?: boolean;
49
48
  readonly retryAfterMs?: number;
50
49
 
51
50
  constructor(args: {
52
- reason: string;
51
+ message: string;
53
52
  isRetryable?: boolean;
54
- errorData?: EdgeErrorData;
53
+ data?: EdgeErrorData;
55
54
  retryAfterMs?: number;
56
55
  cause?: Error;
57
56
  }) {
58
- super(args.reason, { cause: args.cause });
59
- this.reason = args.reason;
60
- this.errorData = args.errorData;
57
+ super(args.message, { cause: args.cause });
58
+ this.message = args.message;
59
+ this.data = args.data;
61
60
  this.retryAfterMs = args.retryAfterMs;
62
61
  this.isRetryable = Boolean(args.isRetryable);
63
62
  }
@@ -66,9 +65,9 @@ export class EdgeCallFailedError extends Error {
66
65
  export class EdgeAuthChallengeError extends EdgeCallFailedError {
67
66
  constructor(
68
67
  public readonly challenge: string,
69
- errorData: EdgeErrorData,
68
+ data: EdgeErrorData,
70
69
  ) {
71
- super({ reason: 'Auth challenge.', errorData, isRetryable: false });
70
+ super({ message: 'Auth challenge.', data, isRetryable: false });
72
71
  }
73
72
  }
74
73
 
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './edge.ts';
6
+ export * as EdgeFunctionEnv from './EdgeFunctionEnv.ts';
7
+ export * from './errors.ts';
8
+ export * from './registry.ts';
@@ -0,0 +1,96 @@
1
+ //
2
+ // Copyright 2026 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ /**
8
+ * Hydrated plugin metadata, mirroring the @dxos/app-framework `Plugin.Meta` shape.
9
+ *
10
+ * Defined locally rather than imported from @dxos/app-framework to keep the protocols
11
+ * package free of UI/runtime dependencies. Consumers can treat decoded values as
12
+ * `Plugin.Meta` directly.
13
+ */
14
+ export const PluginMetaSchema = Schema.Struct({
15
+ id: Schema.String.pipe(Schema.nonEmptyString()),
16
+ name: Schema.String.pipe(Schema.nonEmptyString()),
17
+ description: Schema.optional(Schema.String),
18
+ homePage: Schema.optional(Schema.String),
19
+ source: Schema.optional(Schema.String),
20
+ screenshots: Schema.optional(Schema.Array(Schema.String)),
21
+ tags: Schema.optional(Schema.Array(Schema.String)),
22
+ icon: Schema.optional(Schema.String),
23
+ iconHue: Schema.optional(Schema.String),
24
+ });
25
+ export type PluginMeta = Schema.Schema.Type<typeof PluginMetaSchema>;
26
+
27
+ /**
28
+ * Health signal the registry service attaches to a hydrated entry when a refresh fails.
29
+ * Clients surface the appropriate badge or filter entries based on this field.
30
+ */
31
+ export const PluginHealthSchema = Schema.Literal('ok', 'release-missing', 'manifest-invalid', 'repo-unavailable');
32
+ export type PluginHealth = Schema.Schema.Type<typeof PluginHealthSchema>;
33
+
34
+ /**
35
+ * Shape of the manifest-asset JSON the registry service fetches from each plugin's latest release.
36
+ * Extends {@link PluginMetaSchema} with an optional override for the module bundle filename
37
+ * (defaults to `plugin.mjs`).
38
+ */
39
+ export const PluginManifestSchema = Schema.Struct({
40
+ ...PluginMetaSchema.fields,
41
+ moduleFile: Schema.optional(Schema.String),
42
+ });
43
+ export type PluginManifest = Schema.Schema.Type<typeof PluginManifestSchema>;
44
+
45
+ /**
46
+ * Single hydrated plugin entry returned by the registry service.
47
+ */
48
+ export const PluginEntrySchema = Schema.Struct({
49
+ /** GitHub repository in `owner/name` form. */
50
+ repo: Schema.String.pipe(Schema.nonEmptyString()),
51
+ /** Plugin metadata from the repo's latest-release `manifest.json`. */
52
+ meta: PluginMetaSchema,
53
+ /**
54
+ * URL from which Composer can dynamic-import the plugin module. The registry service is
55
+ * responsible for returning a URL that is CORS-safe for browser `import()` (e.g. served or
56
+ * proxied by the service itself); clients pass this value directly to the URL loader.
57
+ */
58
+ moduleUrl: Schema.String,
59
+ /** Release tag the entry was resolved from (e.g. `v0.1.0`). */
60
+ releaseTag: Schema.String,
61
+ /** Health signal set by the service when an entry fails to refresh. */
62
+ health: PluginHealthSchema,
63
+ /** Unix ms when this entry was last successfully hydrated. */
64
+ hydratedAt: Schema.Number,
65
+ });
66
+ export type PluginEntry = Schema.Schema.Type<typeof PluginEntrySchema>;
67
+
68
+ /**
69
+ * Response body of `GET /registry/plugins`.
70
+ */
71
+ export const GetPluginsResponseBodySchema = Schema.Struct({
72
+ /** Wire-format schema version, pinned to 1. */
73
+ version: Schema.Literal(1),
74
+ /** Hydrated entries. Order matches the order in the upstream catalog manifest. */
75
+ plugins: Schema.Array(PluginEntrySchema),
76
+ /** Unix ms timestamp of the most recent successful refresh cycle. */
77
+ refreshedAt: Schema.Number,
78
+ });
79
+ export type GetPluginsResponseBody = Schema.Schema.Type<typeof GetPluginsResponseBodySchema>;
80
+
81
+ /**
82
+ * Shape of the catalog manifest published in the upstream community-plugins repo.
83
+ * Extra keys (e.g. `$schema`) are permitted.
84
+ */
85
+ export const RegistryManifestSchema = Schema.Struct(
86
+ {
87
+ version: Schema.Literal(1),
88
+ plugins: Schema.Array(
89
+ Schema.Struct({
90
+ repo: Schema.String,
91
+ }),
92
+ ),
93
+ },
94
+ Schema.Record({ key: Schema.String, value: Schema.Unknown }),
95
+ );
96
+ export type RegistryManifest = Schema.Schema.Type<typeof RegistryManifestSchema>;
@@ -2,43 +2,25 @@
2
2
  // Copyright 2021 DXOS.org
3
3
  //
4
4
 
5
- // TODO(dmaretskyi): Reconcile with @dxos/errors
6
-
7
5
  /**
8
6
  * NOTE: Messages should be sentences (Start with a capital letter and end with a period).
9
7
  * Errors can optionally include a JSON context object.
10
8
  */
11
- export class BaseError extends Error {
12
- constructor(
13
- readonly code: string,
14
- message?: string,
15
- readonly context?: Record<string, any>,
16
- ) {
17
- // TODO(dmaretskyi): Error.cause.
18
- super(message ?? code);
19
- this.name = code;
20
- // NOTE: Restores prototype chain (https://stackoverflow.com/a/48342359).
21
- Object.setPrototypeOf(this, new.target.prototype);
22
- }
23
- }
24
-
25
- // TODO(dmaretskyi): Consider common error classes with error codes:
26
- // throw new SystemError(ERROR_CODE_OUT_OF_MEMORY, 'Out of memory', { a: 1, b: 2 });
9
+ import { BaseError } from '@dxos/errors';
27
10
 
28
11
  /**
29
12
  * User facing API Errors.
30
13
  * E.g., something was misconfigured.
31
14
  */
32
- export class ApiError extends BaseError {}
15
+ export class ApiError extends BaseError.extend('ApiError') {}
33
16
 
34
17
  /**
35
18
  * Internal system errors.
36
19
  * E.g., unexpected/unrecoverable runtime error.
37
20
  */
38
- export class SystemError extends BaseError {}
21
+ export class SystemError extends BaseError.extend('SystemError') {}
39
22
 
40
23
  /**
41
24
  * Database errors.
42
25
  */
43
- // TODO(wittjosiah): Same as ApiError?
44
- export class DatabaseError extends BaseError {}
26
+ export class DatabaseError extends BaseError.extend('DatabaseError') {}
@@ -2,9 +2,8 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type Error as SerializedErrorProto } from '../proto/gen/dxos/error.js';
6
-
7
- import { reconstructError } from './helpers.js';
5
+ import { type Error as SerializedErrorProto } from '../proto/gen/dxos/error.ts';
6
+ import { reconstructError } from './helpers.ts';
8
7
 
9
8
  export const encodeError = (err: any): SerializedErrorProto => {
10
9
  if (typeof err === 'object' && err?.message) {
@@ -4,12 +4,12 @@
4
4
 
5
5
  import { describe, expect, test } from 'vitest';
6
6
 
7
- import { ApiError } from './base-errors.js';
7
+ import { ApiError } from './base-errors.ts';
8
8
 
9
9
  describe('Errors', () => {
10
10
  test('test', async () => {
11
11
  const runTest = async () => {
12
- throw new ApiError('Test error');
12
+ throw new ApiError({ message: 'Test error' });
13
13
  };
14
14
 
15
15
  await expect(runTest()).rejects.toThrowError('Test error');