@astrale-os/kernel-client 0.5.1 → 0.6.0-beta.10

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 (661) hide show
  1. package/dist/auth/auth.d.ts +18 -0
  2. package/dist/auth/auth.js +15 -0
  3. package/dist/auth/authorization.d.ts +13 -0
  4. package/dist/auth/authorization.js +17 -0
  5. package/dist/auth/credential.d.ts +19 -0
  6. package/dist/auth/credential.js +21 -0
  7. package/dist/auth/identity.d.ts +14 -0
  8. package/dist/auth/identity.js +15 -0
  9. package/dist/auth/index.d.ts +6 -16
  10. package/dist/auth/index.js +5 -10
  11. package/dist/auth/provision.d.ts +8 -0
  12. package/dist/auth/provision.js +10 -0
  13. package/dist/client/admission.d.ts +4 -0
  14. package/dist/client/admission.js +34 -0
  15. package/dist/client/client.d.ts +24 -109
  16. package/dist/client/client.js +80 -381
  17. package/dist/client/credential.d.ts +12 -0
  18. package/dist/client/credential.js +51 -0
  19. package/dist/client/index.d.ts +6 -0
  20. package/dist/client/index.js +4 -0
  21. package/dist/client/request.d.ts +26 -0
  22. package/dist/client/request.js +100 -0
  23. package/dist/client/result.d.ts +35 -0
  24. package/dist/client/result.js +28 -0
  25. package/dist/client/routing-control.d.ts +10 -0
  26. package/dist/client/routing-control.js +23 -0
  27. package/dist/errors/client-error.d.ts +3 -0
  28. package/dist/errors/client-error.js +8 -0
  29. package/dist/errors/index.d.ts +7 -6
  30. package/dist/errors/index.js +7 -4
  31. package/dist/errors/miss-error.d.ts +8 -0
  32. package/dist/errors/miss-error.js +10 -0
  33. package/dist/errors/protocol-error.d.ts +9 -0
  34. package/dist/errors/protocol-error.js +9 -0
  35. package/dist/errors/response-error.d.ts +11 -0
  36. package/dist/errors/response-error.js +16 -0
  37. package/dist/errors/session-error.d.ts +8 -20
  38. package/dist/errors/session-error.js +6 -22
  39. package/dist/errors/stale-route-error.d.ts +9 -0
  40. package/dist/errors/stale-route-error.js +12 -0
  41. package/dist/errors/transport-error.d.ts +30 -0
  42. package/dist/errors/transport-error.js +18 -0
  43. package/dist/graph/domain/binding.d.ts +22 -0
  44. package/dist/graph/domain/binding.js +123 -0
  45. package/dist/graph/domain/domain.typecheck.d.ts +1 -0
  46. package/dist/graph/domain/domain.typecheck.js +139 -0
  47. package/dist/graph/domain/index.d.ts +3 -0
  48. package/dist/graph/domain/index.js +1 -0
  49. package/dist/graph/domain/model.d.ts +18 -0
  50. package/dist/graph/domain/model.js +1 -0
  51. package/dist/graph/domain/page.d.ts +23 -0
  52. package/dist/graph/domain/page.js +42 -0
  53. package/dist/graph/domain/project.d.ts +8 -0
  54. package/dist/graph/domain/project.js +120 -0
  55. package/dist/graph/domain/provenance.d.ts +6 -0
  56. package/dist/graph/domain/provenance.js +11 -0
  57. package/dist/graph/errors.d.ts +8 -0
  58. package/dist/graph/errors.js +14 -0
  59. package/dist/graph/graph.d.ts +26 -0
  60. package/dist/graph/graph.js +18 -0
  61. package/dist/graph/index.d.ts +8 -26
  62. package/dist/graph/index.js +6 -21
  63. package/dist/graph/mutation.d.ts +5 -0
  64. package/dist/graph/mutation.js +17 -0
  65. package/dist/graph/page/index.d.ts +2 -0
  66. package/dist/graph/page/index.js +1 -0
  67. package/dist/graph/page/neighbors.d.ts +9 -0
  68. package/dist/graph/page/neighbors.js +34 -0
  69. package/dist/graph/page/page.d.ts +37 -0
  70. package/dist/graph/page/page.js +55 -0
  71. package/dist/graph/page-contract.d.ts +13 -0
  72. package/dist/graph/page-contract.js +1 -0
  73. package/dist/graph/provenance.d.ts +12 -0
  74. package/dist/graph/provenance.js +37 -0
  75. package/dist/graph/query.d.ts +4 -0
  76. package/dist/graph/query.js +69 -0
  77. package/dist/graph/read.d.ts +6 -0
  78. package/dist/graph/read.js +17 -0
  79. package/dist/index.d.ts +6 -25
  80. package/dist/index.js +6 -21
  81. package/dist/pacer/batcher/batcher.d.ts +7 -0
  82. package/dist/pacer/batcher/batcher.js +13 -0
  83. package/dist/pacer/batcher/defaults.d.ts +2 -0
  84. package/dist/pacer/batcher/defaults.js +2 -0
  85. package/dist/pacer/batcher/index.d.ts +1 -0
  86. package/dist/pacer/batcher/index.js +1 -0
  87. package/dist/pacer/index.d.ts +4 -10
  88. package/dist/pacer/index.js +4 -11
  89. package/dist/pacer/limiter/defaults.d.ts +2 -0
  90. package/dist/pacer/limiter/defaults.js +2 -0
  91. package/dist/pacer/limiter/index.d.ts +1 -0
  92. package/dist/pacer/limiter/index.js +1 -0
  93. package/dist/pacer/limiter/limiter.d.ts +7 -0
  94. package/dist/pacer/limiter/limiter.js +14 -0
  95. package/dist/pacer/queue/defaults.d.ts +1 -0
  96. package/dist/pacer/queue/defaults.js +1 -0
  97. package/dist/pacer/queue/index.d.ts +1 -0
  98. package/dist/pacer/queue/index.js +1 -0
  99. package/dist/pacer/queue/queue.d.ts +6 -0
  100. package/dist/pacer/queue/queue.js +12 -0
  101. package/dist/pacer/retry/defaults.d.ts +6 -0
  102. package/dist/pacer/retry/defaults.js +16 -0
  103. package/dist/pacer/retry/index.d.ts +1 -0
  104. package/dist/pacer/retry/index.js +1 -0
  105. package/dist/pacer/retry/retry.d.ts +9 -0
  106. package/dist/pacer/retry/retry.js +55 -0
  107. package/dist/pool/index.d.ts +2 -4
  108. package/dist/pool/index.js +0 -2
  109. package/dist/pool/pool.d.ts +19 -59
  110. package/dist/pool/pool.js +46 -64
  111. package/dist/pool/target.d.ts +15 -0
  112. package/dist/pool/target.js +49 -0
  113. package/dist/schema/admission.d.ts +12 -0
  114. package/dist/schema/admission.js +17 -0
  115. package/dist/schema/contracts.d.ts +12 -0
  116. package/dist/schema/contracts.js +1 -0
  117. package/dist/schema/index.d.ts +3 -16
  118. package/dist/schema/index.js +2 -12
  119. package/dist/schema/introspection.d.ts +5 -0
  120. package/dist/schema/introspection.js +15 -0
  121. package/dist/schema/operation.d.ts +5 -0
  122. package/dist/schema/operation.js +9 -0
  123. package/dist/schema/schema.d.ts +19 -0
  124. package/dist/schema/schema.js +43 -0
  125. package/dist/session/bound.d.ts +42 -9
  126. package/dist/session/bound.js +70 -37
  127. package/dist/session/context/control.d.ts +5 -0
  128. package/dist/session/context/control.js +17 -0
  129. package/dist/session/context/index.d.ts +4 -0
  130. package/dist/session/context/index.js +4 -0
  131. package/dist/session/context/limits.d.ts +7 -0
  132. package/dist/session/context/limits.js +18 -0
  133. package/dist/session/context/operation.d.ts +19 -0
  134. package/dist/session/context/operation.js +72 -0
  135. package/dist/session/context/policy.d.ts +11 -0
  136. package/dist/session/context/policy.js +69 -0
  137. package/dist/session/discovery/bundle.d.ts +17 -0
  138. package/dist/session/discovery/bundle.js +55 -0
  139. package/dist/session/discovery/discovery.d.ts +19 -0
  140. package/dist/session/discovery/discovery.js +55 -0
  141. package/dist/session/discovery/index.d.ts +20 -0
  142. package/dist/session/discovery/index.js +15 -0
  143. package/dist/session/discovery/publication.d.ts +23 -0
  144. package/dist/session/discovery/publication.js +123 -0
  145. package/dist/session/discovery/snapshot.d.ts +12 -0
  146. package/dist/session/discovery/snapshot.js +3 -0
  147. package/dist/session/discovery/transport.d.ts +6 -0
  148. package/dist/session/discovery/transport.js +13 -0
  149. package/dist/session/index.d.ts +10 -16
  150. package/dist/session/index.js +3 -9
  151. package/dist/session/reference.d.ts +36 -0
  152. package/dist/session/reference.js +74 -0
  153. package/dist/session/routing/auth.d.ts +18 -0
  154. package/dist/session/routing/auth.js +39 -0
  155. package/dist/session/routing/cache.d.ts +20 -0
  156. package/dist/session/routing/cache.js +115 -0
  157. package/dist/session/routing/dispatch.d.ts +34 -0
  158. package/dist/session/routing/dispatch.js +137 -0
  159. package/dist/session/routing/envelope.d.ts +13 -0
  160. package/dist/session/routing/envelope.js +35 -0
  161. package/dist/session/routing/expectation.d.ts +6 -0
  162. package/dist/session/routing/expectation.js +1 -0
  163. package/dist/session/routing/index.d.ts +6 -0
  164. package/dist/session/routing/index.js +5 -0
  165. package/dist/session/routing/request.d.ts +8 -0
  166. package/dist/session/routing/request.js +25 -0
  167. package/dist/session/session.d.ts +67 -0
  168. package/dist/session/session.js +257 -0
  169. package/dist/session/session.typecheck.d.ts +1 -0
  170. package/dist/session/session.typecheck.js +31 -0
  171. package/dist/session/views/catalog.d.ts +15 -0
  172. package/dist/session/views/catalog.js +70 -0
  173. package/dist/session/views/index.d.ts +2 -0
  174. package/dist/session/views/index.js +2 -0
  175. package/dist/session/views/resolve.d.ts +11 -0
  176. package/dist/session/views/resolve.js +13 -0
  177. package/dist/store/entity-index.d.ts +22 -0
  178. package/dist/store/entity-index.js +94 -0
  179. package/dist/store/index.d.ts +1 -26
  180. package/dist/store/index.js +1 -19
  181. package/dist/store/memory.d.ts +46 -97
  182. package/dist/store/memory.js +346 -763
  183. package/dist/store/mutation.d.ts +5 -0
  184. package/dist/store/mutation.js +34 -0
  185. package/dist/store/observe.d.ts +3 -0
  186. package/dist/store/observe.js +17 -0
  187. package/dist/store/optimistic.d.ts +12 -0
  188. package/dist/store/optimistic.js +43 -0
  189. package/dist/store/query-key.d.ts +5 -0
  190. package/dist/store/query-key.js +22 -0
  191. package/dist/store/shape.d.ts +25 -0
  192. package/dist/store/shape.js +29 -0
  193. package/dist/store/store.d.ts +68 -0
  194. package/dist/store/store.js +144 -0
  195. package/dist/store/store.typecheck.d.ts +1 -0
  196. package/dist/store/store.typecheck.js +40 -0
  197. package/dist/transport/auto/decision.d.ts +22 -0
  198. package/dist/transport/auto/decision.js +48 -0
  199. package/dist/transport/auto/fallback.d.ts +16 -0
  200. package/dist/transport/auto/fallback.js +75 -0
  201. package/dist/transport/auto/index.d.ts +2 -0
  202. package/dist/transport/auto/index.js +2 -0
  203. package/dist/transport/auto/transport.d.ts +37 -0
  204. package/dist/transport/auto/transport.js +140 -0
  205. package/dist/transport/auto/warning.d.ts +13 -0
  206. package/dist/transport/auto/warning.js +18 -0
  207. package/dist/transport/deadline.d.ts +11 -0
  208. package/dist/transport/deadline.js +39 -0
  209. package/dist/transport/failure.d.ts +7 -0
  210. package/dist/transport/failure.js +9 -0
  211. package/dist/transport/http/index.d.ts +1 -0
  212. package/dist/transport/http/index.js +1 -0
  213. package/dist/transport/http/response.d.ts +8 -0
  214. package/dist/transport/http/response.js +79 -0
  215. package/dist/transport/http/stream.d.ts +26 -0
  216. package/dist/transport/http/stream.js +214 -0
  217. package/dist/transport/http/transport.d.ts +32 -0
  218. package/dist/transport/http/transport.js +343 -0
  219. package/dist/transport/index.d.ts +2 -8
  220. package/dist/transport/index.js +1 -6
  221. package/dist/transport/transport.d.ts +34 -0
  222. package/dist/transport/transport.js +1 -0
  223. package/dist/transport/websocket/connection.d.ts +38 -0
  224. package/dist/transport/websocket/connection.js +284 -0
  225. package/dist/transport/websocket/exchange.d.ts +46 -0
  226. package/dist/transport/websocket/exchange.js +300 -0
  227. package/dist/transport/websocket/index.d.ts +1 -0
  228. package/dist/transport/websocket/index.js +1 -0
  229. package/dist/transport/websocket/transport.d.ts +46 -0
  230. package/dist/transport/websocket/transport.js +164 -0
  231. package/package.json +41 -35
  232. package/dist/auth/addressing.d.ts +0 -32
  233. package/dist/auth/addressing.d.ts.map +0 -1
  234. package/dist/auth/addressing.js +0 -36
  235. package/dist/auth/addressing.js.map +0 -1
  236. package/dist/auth/api.d.ts +0 -70
  237. package/dist/auth/api.d.ts.map +0 -1
  238. package/dist/auth/api.js +0 -36
  239. package/dist/auth/api.js.map +0 -1
  240. package/dist/auth/batch.d.ts +0 -18
  241. package/dist/auth/batch.d.ts.map +0 -1
  242. package/dist/auth/batch.js +0 -25
  243. package/dist/auth/batch.js.map +0 -1
  244. package/dist/auth/composition.d.ts +0 -27
  245. package/dist/auth/composition.d.ts.map +0 -1
  246. package/dist/auth/composition.js +0 -83
  247. package/dist/auth/composition.js.map +0 -1
  248. package/dist/auth/defaults.d.ts +0 -3
  249. package/dist/auth/defaults.d.ts.map +0 -1
  250. package/dist/auth/defaults.js +0 -3
  251. package/dist/auth/defaults.js.map +0 -1
  252. package/dist/auth/index.d.ts.map +0 -1
  253. package/dist/auth/index.js.map +0 -1
  254. package/dist/auth/minting.d.ts +0 -35
  255. package/dist/auth/minting.d.ts.map +0 -1
  256. package/dist/auth/minting.js +0 -31
  257. package/dist/auth/minting.js.map +0 -1
  258. package/dist/auth/permissions.d.ts +0 -55
  259. package/dist/auth/permissions.d.ts.map +0 -1
  260. package/dist/auth/permissions.js +0 -47
  261. package/dist/auth/permissions.js.map +0 -1
  262. package/dist/auth/principal.d.ts +0 -19
  263. package/dist/auth/principal.d.ts.map +0 -1
  264. package/dist/auth/principal.js +0 -46
  265. package/dist/auth/principal.js.map +0 -1
  266. package/dist/auth/shorthands.d.ts +0 -19
  267. package/dist/auth/shorthands.d.ts.map +0 -1
  268. package/dist/auth/shorthands.js +0 -27
  269. package/dist/auth/shorthands.js.map +0 -1
  270. package/dist/client/batch.d.ts +0 -26
  271. package/dist/client/batch.d.ts.map +0 -1
  272. package/dist/client/batch.js +0 -8
  273. package/dist/client/batch.js.map +0 -1
  274. package/dist/client/bound.d.ts +0 -27
  275. package/dist/client/bound.d.ts.map +0 -1
  276. package/dist/client/bound.js +0 -14
  277. package/dist/client/bound.js.map +0 -1
  278. package/dist/client/client.d.ts.map +0 -1
  279. package/dist/client/client.js.map +0 -1
  280. package/dist/client/config.d.ts +0 -112
  281. package/dist/client/config.d.ts.map +0 -1
  282. package/dist/client/config.js +0 -10
  283. package/dist/client/config.js.map +0 -1
  284. package/dist/client/fn-map.d.ts +0 -61
  285. package/dist/client/fn-map.d.ts.map +0 -1
  286. package/dist/client/fn-map.js +0 -2
  287. package/dist/client/fn-map.js.map +0 -1
  288. package/dist/client/freeze.d.ts +0 -32
  289. package/dist/client/freeze.d.ts.map +0 -1
  290. package/dist/client/freeze.js +0 -42
  291. package/dist/client/freeze.js.map +0 -1
  292. package/dist/client/hooks.d.ts +0 -49
  293. package/dist/client/hooks.d.ts.map +0 -1
  294. package/dist/client/hooks.js +0 -2
  295. package/dist/client/hooks.js.map +0 -1
  296. package/dist/errors/errors.d.ts +0 -156
  297. package/dist/errors/errors.d.ts.map +0 -1
  298. package/dist/errors/errors.js +0 -238
  299. package/dist/errors/errors.js.map +0 -1
  300. package/dist/errors/guards.d.ts +0 -39
  301. package/dist/errors/guards.d.ts.map +0 -1
  302. package/dist/errors/guards.js +0 -127
  303. package/dist/errors/guards.js.map +0 -1
  304. package/dist/errors/index.d.ts.map +0 -1
  305. package/dist/errors/index.js.map +0 -1
  306. package/dist/errors/session-error.d.ts.map +0 -1
  307. package/dist/errors/session-error.js.map +0 -1
  308. package/dist/graph/api.d.ts +0 -85
  309. package/dist/graph/api.d.ts.map +0 -1
  310. package/dist/graph/api.js +0 -66
  311. package/dist/graph/api.js.map +0 -1
  312. package/dist/graph/index.d.ts.map +0 -1
  313. package/dist/graph/index.js.map +0 -1
  314. package/dist/graph/mutate/builder.d.ts +0 -108
  315. package/dist/graph/mutate/builder.d.ts.map +0 -1
  316. package/dist/graph/mutate/builder.js +0 -127
  317. package/dist/graph/mutate/builder.js.map +0 -1
  318. package/dist/graph/mutate/index.d.ts +0 -5
  319. package/dist/graph/mutate/index.d.ts.map +0 -1
  320. package/dist/graph/mutate/index.js +0 -3
  321. package/dist/graph/mutate/index.js.map +0 -1
  322. package/dist/graph/mutate/shorthands.d.ts +0 -42
  323. package/dist/graph/mutate/shorthands.d.ts.map +0 -1
  324. package/dist/graph/mutate/shorthands.js +0 -65
  325. package/dist/graph/mutate/shorthands.js.map +0 -1
  326. package/dist/graph/named.d.ts +0 -38
  327. package/dist/graph/named.d.ts.map +0 -1
  328. package/dist/graph/named.js +0 -47
  329. package/dist/graph/named.js.map +0 -1
  330. package/dist/graph/query/builder.d.ts +0 -116
  331. package/dist/graph/query/builder.d.ts.map +0 -1
  332. package/dist/graph/query/builder.js +0 -136
  333. package/dist/graph/query/builder.js.map +0 -1
  334. package/dist/graph/query/edge-ref.d.ts +0 -13
  335. package/dist/graph/query/edge-ref.d.ts.map +0 -1
  336. package/dist/graph/query/edge-ref.js +0 -56
  337. package/dist/graph/query/edge-ref.js.map +0 -1
  338. package/dist/graph/query/edges.d.ts +0 -10
  339. package/dist/graph/query/edges.d.ts.map +0 -1
  340. package/dist/graph/query/edges.js +0 -11
  341. package/dist/graph/query/edges.js.map +0 -1
  342. package/dist/graph/query/errors.d.ts +0 -31
  343. package/dist/graph/query/errors.d.ts.map +0 -1
  344. package/dist/graph/query/errors.js +0 -28
  345. package/dist/graph/query/errors.js.map +0 -1
  346. package/dist/graph/query/filter.d.ts +0 -50
  347. package/dist/graph/query/filter.d.ts.map +0 -1
  348. package/dist/graph/query/filter.js +0 -32
  349. package/dist/graph/query/filter.js.map +0 -1
  350. package/dist/graph/query/index.d.ts +0 -12
  351. package/dist/graph/query/index.d.ts.map +0 -1
  352. package/dist/graph/query/index.js +0 -7
  353. package/dist/graph/query/index.js.map +0 -1
  354. package/dist/graph/query/lower.d.ts +0 -30
  355. package/dist/graph/query/lower.d.ts.map +0 -1
  356. package/dist/graph/query/lower.js +0 -171
  357. package/dist/graph/query/lower.js.map +0 -1
  358. package/dist/graph/query/shorthands.d.ts +0 -34
  359. package/dist/graph/query/shorthands.d.ts.map +0 -1
  360. package/dist/graph/query/shorthands.js +0 -71
  361. package/dist/graph/query/shorthands.js.map +0 -1
  362. package/dist/graph/query/traverse.d.ts +0 -59
  363. package/dist/graph/query/traverse.d.ts.map +0 -1
  364. package/dist/graph/query/traverse.js +0 -144
  365. package/dist/graph/query/traverse.js.map +0 -1
  366. package/dist/graph/reconcile/execute.d.ts +0 -8
  367. package/dist/graph/reconcile/execute.d.ts.map +0 -1
  368. package/dist/graph/reconcile/execute.js +0 -56
  369. package/dist/graph/reconcile/execute.js.map +0 -1
  370. package/dist/graph/reconcile/index.d.ts +0 -5
  371. package/dist/graph/reconcile/index.d.ts.map +0 -1
  372. package/dist/graph/reconcile/index.js +0 -3
  373. package/dist/graph/reconcile/index.js.map +0 -1
  374. package/dist/graph/reconcile/input.d.ts +0 -80
  375. package/dist/graph/reconcile/input.d.ts.map +0 -1
  376. package/dist/graph/reconcile/input.js +0 -5
  377. package/dist/graph/reconcile/input.js.map +0 -1
  378. package/dist/graph/reconcile/normalize.d.ts +0 -3
  379. package/dist/graph/reconcile/normalize.d.ts.map +0 -1
  380. package/dist/graph/reconcile/normalize.js +0 -144
  381. package/dist/graph/reconcile/normalize.js.map +0 -1
  382. package/dist/graph/reconcile/result.d.ts +0 -19
  383. package/dist/graph/reconcile/result.d.ts.map +0 -1
  384. package/dist/graph/reconcile/result.js +0 -95
  385. package/dist/graph/reconcile/result.js.map +0 -1
  386. package/dist/graph/reconcile/scope.d.ts +0 -6
  387. package/dist/graph/reconcile/scope.d.ts.map +0 -1
  388. package/dist/graph/reconcile/scope.js +0 -69
  389. package/dist/graph/reconcile/scope.js.map +0 -1
  390. package/dist/graph/result/envelope.d.ts +0 -37
  391. package/dist/graph/result/envelope.d.ts.map +0 -1
  392. package/dist/graph/result/envelope.js +0 -59
  393. package/dist/graph/result/envelope.js.map +0 -1
  394. package/dist/graph/result/index.d.ts +0 -6
  395. package/dist/graph/result/index.d.ts.map +0 -1
  396. package/dist/graph/result/index.js +0 -4
  397. package/dist/graph/result/index.js.map +0 -1
  398. package/dist/graph/result/next.d.ts +0 -16
  399. package/dist/graph/result/next.d.ts.map +0 -1
  400. package/dist/graph/result/next.js +0 -77
  401. package/dist/graph/result/next.js.map +0 -1
  402. package/dist/graph/result/paged.d.ts +0 -30
  403. package/dist/graph/result/paged.d.ts.map +0 -1
  404. package/dist/graph/result/paged.js +0 -41
  405. package/dist/graph/result/paged.js.map +0 -1
  406. package/dist/graph/wire.d.ts +0 -33
  407. package/dist/graph/wire.d.ts.map +0 -1
  408. package/dist/graph/wire.js +0 -16
  409. package/dist/graph/wire.js.map +0 -1
  410. package/dist/index.d.ts.map +0 -1
  411. package/dist/index.js.map +0 -1
  412. package/dist/pacer/batcher.d.ts +0 -11
  413. package/dist/pacer/batcher.d.ts.map +0 -1
  414. package/dist/pacer/batcher.js +0 -15
  415. package/dist/pacer/batcher.js.map +0 -1
  416. package/dist/pacer/defaults.d.ts +0 -18
  417. package/dist/pacer/defaults.d.ts.map +0 -1
  418. package/dist/pacer/defaults.js +0 -18
  419. package/dist/pacer/defaults.js.map +0 -1
  420. package/dist/pacer/index.d.ts.map +0 -1
  421. package/dist/pacer/index.js.map +0 -1
  422. package/dist/pacer/queue.d.ts +0 -11
  423. package/dist/pacer/queue.d.ts.map +0 -1
  424. package/dist/pacer/queue.js +0 -15
  425. package/dist/pacer/queue.js.map +0 -1
  426. package/dist/pacer/rate-limiter.d.ts +0 -11
  427. package/dist/pacer/rate-limiter.d.ts.map +0 -1
  428. package/dist/pacer/rate-limiter.js +0 -15
  429. package/dist/pacer/rate-limiter.js.map +0 -1
  430. package/dist/pacer/retry.d.ts +0 -14
  431. package/dist/pacer/retry.d.ts.map +0 -1
  432. package/dist/pacer/retry.js +0 -50
  433. package/dist/pacer/retry.js.map +0 -1
  434. package/dist/pool/errors.d.ts +0 -13
  435. package/dist/pool/errors.d.ts.map +0 -1
  436. package/dist/pool/errors.js +0 -16
  437. package/dist/pool/errors.js.map +0 -1
  438. package/dist/pool/index.d.ts.map +0 -1
  439. package/dist/pool/index.js.map +0 -1
  440. package/dist/pool/pool.d.ts.map +0 -1
  441. package/dist/pool/pool.js.map +0 -1
  442. package/dist/schema/bound/binder.d.ts +0 -49
  443. package/dist/schema/bound/binder.d.ts.map +0 -1
  444. package/dist/schema/bound/binder.js +0 -195
  445. package/dist/schema/bound/binder.js.map +0 -1
  446. package/dist/schema/bound/bound-node.d.ts +0 -105
  447. package/dist/schema/bound/bound-node.d.ts.map +0 -1
  448. package/dist/schema/bound/bound-node.js +0 -128
  449. package/dist/schema/bound/bound-node.js.map +0 -1
  450. package/dist/schema/bound/index.d.ts +0 -10
  451. package/dist/schema/bound/index.d.ts.map +0 -1
  452. package/dist/schema/bound/index.js +0 -5
  453. package/dist/schema/bound/index.js.map +0 -1
  454. package/dist/schema/bound/view.d.ts +0 -44
  455. package/dist/schema/bound/view.d.ts.map +0 -1
  456. package/dist/schema/bound/view.js +0 -117
  457. package/dist/schema/bound/view.js.map +0 -1
  458. package/dist/schema/bound/write-props.d.ts +0 -38
  459. package/dist/schema/bound/write-props.d.ts.map +0 -1
  460. package/dist/schema/bound/write-props.js +0 -2
  461. package/dist/schema/bound/write-props.js.map +0 -1
  462. package/dist/schema/call-args.d.ts +0 -6
  463. package/dist/schema/call-args.d.ts.map +0 -1
  464. package/dist/schema/call-args.js +0 -21
  465. package/dist/schema/call-args.js.map +0 -1
  466. package/dist/schema/class-proxy.d.ts +0 -11
  467. package/dist/schema/class-proxy.d.ts.map +0 -1
  468. package/dist/schema/class-proxy.js +0 -46
  469. package/dist/schema/class-proxy.js.map +0 -1
  470. package/dist/schema/extract.d.ts +0 -24
  471. package/dist/schema/extract.d.ts.map +0 -1
  472. package/dist/schema/extract.js +0 -45
  473. package/dist/schema/extract.js.map +0 -1
  474. package/dist/schema/from-entries.d.ts +0 -12
  475. package/dist/schema/from-entries.d.ts.map +0 -1
  476. package/dist/schema/from-entries.js +0 -39
  477. package/dist/schema/from-entries.js.map +0 -1
  478. package/dist/schema/index.d.ts.map +0 -1
  479. package/dist/schema/index.js.map +0 -1
  480. package/dist/schema/known-dispatch.d.ts +0 -6
  481. package/dist/schema/known-dispatch.d.ts.map +0 -1
  482. package/dist/schema/known-dispatch.js +0 -39
  483. package/dist/schema/known-dispatch.js.map +0 -1
  484. package/dist/schema/node-proxy.d.ts +0 -21
  485. package/dist/schema/node-proxy.d.ts.map +0 -1
  486. package/dist/schema/node-proxy.js +0 -75
  487. package/dist/schema/node-proxy.js.map +0 -1
  488. package/dist/schema/persistence.d.ts +0 -31
  489. package/dist/schema/persistence.d.ts.map +0 -1
  490. package/dist/schema/persistence.js +0 -2
  491. package/dist/schema/persistence.js.map +0 -1
  492. package/dist/schema/proxy-types.d.ts +0 -131
  493. package/dist/schema/proxy-types.d.ts.map +0 -1
  494. package/dist/schema/proxy-types.js +0 -2
  495. package/dist/schema/proxy-types.js.map +0 -1
  496. package/dist/schema/registry.d.ts +0 -50
  497. package/dist/schema/registry.d.ts.map +0 -1
  498. package/dist/schema/registry.js +0 -110
  499. package/dist/schema/registry.js.map +0 -1
  500. package/dist/schema/resolve.d.ts +0 -26
  501. package/dist/schema/resolve.d.ts.map +0 -1
  502. package/dist/schema/resolve.js +0 -27
  503. package/dist/schema/resolve.js.map +0 -1
  504. package/dist/schema/typed-client.d.ts +0 -10
  505. package/dist/schema/typed-client.d.ts.map +0 -1
  506. package/dist/schema/typed-client.js +0 -26
  507. package/dist/schema/typed-client.js.map +0 -1
  508. package/dist/schema/types.d.ts +0 -9
  509. package/dist/schema/types.d.ts.map +0 -1
  510. package/dist/schema/types.js +0 -2
  511. package/dist/schema/types.js.map +0 -1
  512. package/dist/session/bound.d.ts.map +0 -1
  513. package/dist/session/bound.js.map +0 -1
  514. package/dist/session/client-session.d.ts +0 -72
  515. package/dist/session/client-session.d.ts.map +0 -1
  516. package/dist/session/client-session.js +0 -673
  517. package/dist/session/client-session.js.map +0 -1
  518. package/dist/session/config.d.ts +0 -168
  519. package/dist/session/config.d.ts.map +0 -1
  520. package/dist/session/config.js +0 -2
  521. package/dist/session/config.js.map +0 -1
  522. package/dist/session/delegation/cache.d.ts +0 -139
  523. package/dist/session/delegation/cache.d.ts.map +0 -1
  524. package/dist/session/delegation/cache.js +0 -256
  525. package/dist/session/delegation/cache.js.map +0 -1
  526. package/dist/session/delegation/errors.d.ts +0 -44
  527. package/dist/session/delegation/errors.d.ts.map +0 -1
  528. package/dist/session/delegation/errors.js +0 -62
  529. package/dist/session/delegation/errors.js.map +0 -1
  530. package/dist/session/delegation/policy.d.ts +0 -183
  531. package/dist/session/delegation/policy.d.ts.map +0 -1
  532. package/dist/session/delegation/policy.js +0 -114
  533. package/dist/session/delegation/policy.js.map +0 -1
  534. package/dist/session/delegation/utils.d.ts +0 -4
  535. package/dist/session/delegation/utils.d.ts.map +0 -1
  536. package/dist/session/delegation/utils.js +0 -12
  537. package/dist/session/delegation/utils.js.map +0 -1
  538. package/dist/session/delegation-mint.d.ts +0 -13
  539. package/dist/session/delegation-mint.d.ts.map +0 -1
  540. package/dist/session/delegation-mint.js +0 -39
  541. package/dist/session/delegation-mint.js.map +0 -1
  542. package/dist/session/dispatch-routes.d.ts +0 -27
  543. package/dist/session/dispatch-routes.d.ts.map +0 -1
  544. package/dist/session/dispatch-routes.js +0 -77
  545. package/dist/session/dispatch-routes.js.map +0 -1
  546. package/dist/session/errors/index.d.ts +0 -6
  547. package/dist/session/errors/index.d.ts.map +0 -1
  548. package/dist/session/errors/index.js +0 -8
  549. package/dist/session/errors/index.js.map +0 -1
  550. package/dist/session/errors/session-errors.d.ts +0 -52
  551. package/dist/session/errors/session-errors.d.ts.map +0 -1
  552. package/dist/session/errors/session-errors.js +0 -70
  553. package/dist/session/errors/session-errors.js.map +0 -1
  554. package/dist/session/forward.d.ts +0 -15
  555. package/dist/session/forward.d.ts.map +0 -1
  556. package/dist/session/forward.js +0 -40
  557. package/dist/session/forward.js.map +0 -1
  558. package/dist/session/helpers.d.ts +0 -23
  559. package/dist/session/helpers.d.ts.map +0 -1
  560. package/dist/session/helpers.js +0 -56
  561. package/dist/session/helpers.js.map +0 -1
  562. package/dist/session/hooks.d.ts +0 -140
  563. package/dist/session/hooks.d.ts.map +0 -1
  564. package/dist/session/hooks.js +0 -2
  565. package/dist/session/hooks.js.map +0 -1
  566. package/dist/session/index.d.ts.map +0 -1
  567. package/dist/session/index.js.map +0 -1
  568. package/dist/session/redirect/errors.d.ts +0 -45
  569. package/dist/session/redirect/errors.d.ts.map +0 -1
  570. package/dist/session/redirect/errors.js +0 -52
  571. package/dist/session/redirect/errors.js.map +0 -1
  572. package/dist/session/redirect/policy.d.ts +0 -79
  573. package/dist/session/redirect/policy.d.ts.map +0 -1
  574. package/dist/session/redirect/policy.js +0 -69
  575. package/dist/session/redirect/policy.js.map +0 -1
  576. package/dist/session/types.d.ts +0 -54
  577. package/dist/session/types.d.ts.map +0 -1
  578. package/dist/session/types.js +0 -2
  579. package/dist/session/types.js.map +0 -1
  580. package/dist/store/canonicalize.d.ts +0 -44
  581. package/dist/store/canonicalize.d.ts.map +0 -1
  582. package/dist/store/canonicalize.js +0 -0
  583. package/dist/store/canonicalize.js.map +0 -1
  584. package/dist/store/entities.d.ts +0 -81
  585. package/dist/store/entities.d.ts.map +0 -1
  586. package/dist/store/entities.js +0 -202
  587. package/dist/store/entities.js.map +0 -1
  588. package/dist/store/index.d.ts.map +0 -1
  589. package/dist/store/index.js.map +0 -1
  590. package/dist/store/invalidate.d.ts +0 -66
  591. package/dist/store/invalidate.d.ts.map +0 -1
  592. package/dist/store/invalidate.js +0 -117
  593. package/dist/store/invalidate.js.map +0 -1
  594. package/dist/store/memory.d.ts.map +0 -1
  595. package/dist/store/memory.js.map +0 -1
  596. package/dist/store/overlay.d.ts +0 -118
  597. package/dist/store/overlay.d.ts.map +0 -1
  598. package/dist/store/overlay.js +0 -237
  599. package/dist/store/overlay.js.map +0 -1
  600. package/dist/store/schedule.d.ts +0 -31
  601. package/dist/store/schedule.d.ts.map +0 -1
  602. package/dist/store/schedule.js +0 -76
  603. package/dist/store/schedule.js.map +0 -1
  604. package/dist/store/shapes.d.ts +0 -92
  605. package/dist/store/shapes.d.ts.map +0 -1
  606. package/dist/store/shapes.js +0 -369
  607. package/dist/store/shapes.js.map +0 -1
  608. package/dist/store/types.d.ts +0 -168
  609. package/dist/store/types.d.ts.map +0 -1
  610. package/dist/store/types.js +0 -7
  611. package/dist/store/types.js.map +0 -1
  612. package/dist/transport/binary.d.ts +0 -15
  613. package/dist/transport/binary.d.ts.map +0 -1
  614. package/dist/transport/binary.js +0 -2
  615. package/dist/transport/binary.js.map +0 -1
  616. package/dist/transport/contract.d.ts +0 -58
  617. package/dist/transport/contract.d.ts.map +0 -1
  618. package/dist/transport/contract.js +0 -11
  619. package/dist/transport/contract.js.map +0 -1
  620. package/dist/transport/fetch.d.ts +0 -31
  621. package/dist/transport/fetch.d.ts.map +0 -1
  622. package/dist/transport/fetch.js +0 -78
  623. package/dist/transport/fetch.js.map +0 -1
  624. package/dist/transport/http-envelope.d.ts +0 -49
  625. package/dist/transport/http-envelope.d.ts.map +0 -1
  626. package/dist/transport/http-envelope.js +0 -418
  627. package/dist/transport/http-envelope.js.map +0 -1
  628. package/dist/transport/http-routed.d.ts +0 -61
  629. package/dist/transport/http-routed.d.ts.map +0 -1
  630. package/dist/transport/http-routed.js +0 -409
  631. package/dist/transport/http-routed.js.map +0 -1
  632. package/dist/transport/index.d.ts.map +0 -1
  633. package/dist/transport/index.js.map +0 -1
  634. package/dist/transport/request-id.d.ts +0 -9
  635. package/dist/transport/request-id.d.ts.map +0 -1
  636. package/dist/transport/request-id.js +0 -12
  637. package/dist/transport/request-id.js.map +0 -1
  638. package/dist/transport/ws-envelope.d.ts +0 -74
  639. package/dist/transport/ws-envelope.d.ts.map +0 -1
  640. package/dist/transport/ws-envelope.js +0 -567
  641. package/dist/transport/ws-envelope.js.map +0 -1
  642. package/dist/util/race-signal.d.ts +0 -12
  643. package/dist/util/race-signal.d.ts.map +0 -1
  644. package/dist/util/race-signal.js +0 -34
  645. package/dist/util/race-signal.js.map +0 -1
  646. package/dist/wire/controller.d.ts +0 -38
  647. package/dist/wire/controller.d.ts.map +0 -1
  648. package/dist/wire/controller.js +0 -38
  649. package/dist/wire/controller.js.map +0 -1
  650. package/dist/wire/index.d.ts +0 -7
  651. package/dist/wire/index.d.ts.map +0 -1
  652. package/dist/wire/index.js +0 -4
  653. package/dist/wire/index.js.map +0 -1
  654. package/dist/wire/meta.d.ts +0 -81
  655. package/dist/wire/meta.d.ts.map +0 -1
  656. package/dist/wire/meta.js +0 -44
  657. package/dist/wire/meta.js.map +0 -1
  658. package/dist/wire/sse.d.ts +0 -67
  659. package/dist/wire/sse.d.ts.map +0 -1
  660. package/dist/wire/sse.js +0 -170
  661. package/dist/wire/sse.js.map +0 -1
@@ -0,0 +1,37 @@
1
+ import type { Fetch } from '../http/index.js';
2
+ import type { RequestOptions, Transport, TransportRequest, TransportResult } from '../index.js';
3
+ import type { WebSocketConstructor } from '../websocket/index.js';
4
+ import type { ClientWarning } from './warning.js';
5
+ export interface AutoTransportOptions {
6
+ readonly endpoints: {
7
+ readonly http: string;
8
+ readonly websocket: string;
9
+ };
10
+ readonly codec?: 'json' | 'msgpack';
11
+ readonly fetch?: Fetch;
12
+ readonly websocket?: WebSocketConstructor;
13
+ readonly headers?: Readonly<Record<string, string>>;
14
+ readonly timeoutMs?: number;
15
+ readonly maximumRequestBytes?: number;
16
+ readonly maximumResponseBytes?: number;
17
+ readonly maximumBufferedBytes?: number;
18
+ readonly maximumActiveInvocations?: number;
19
+ readonly maximumBufferedStreamItems?: number;
20
+ readonly onWarning?: (warning: ClientWarning) => void;
21
+ }
22
+ /** Sticky WebSocket-first Transport with one delivery-aware HTTP fallback decision. */
23
+ export declare class AutoTransport implements Transport {
24
+ private readonly websocket;
25
+ private readonly http;
26
+ private readonly decision;
27
+ private readonly timeoutMs;
28
+ private readonly onWarning;
29
+ private closed;
30
+ constructor(options: AutoTransportOptions);
31
+ dispatch(input: TransportRequest, options?: RequestOptions): Promise<TransportResult>;
32
+ private dispatchWithBudget;
33
+ close(): void;
34
+ private determine;
35
+ private tryWebsocket;
36
+ private requireOpen;
37
+ }
@@ -0,0 +1,140 @@
1
+ import { TransportError } from '../../errors/index.js';
2
+ import { invocationFailure } from '../failure.js';
3
+ import { HttpTransport } from '../http/index.js';
4
+ import { positiveInteger } from '../index.js';
5
+ import { WebSocketTransport } from '../websocket/index.js';
6
+ import { AutoDecision } from './decision.js';
7
+ import { InvocationBudget, mayFallback, warningTarget } from './fallback.js';
8
+ import { emitWarning } from './warning.js';
9
+ const DEFAULT_TIMEOUT_MS = 30_000;
10
+ /** Sticky WebSocket-first Transport with one delivery-aware HTTP fallback decision. */
11
+ export class AutoTransport {
12
+ websocket;
13
+ http;
14
+ decision = new AutoDecision();
15
+ timeoutMs;
16
+ onWarning;
17
+ closed = false;
18
+ constructor(options) {
19
+ if (options === null || typeof options !== 'object') {
20
+ throw new TypeError('AutoTransport options must be an object.');
21
+ }
22
+ if (options.onWarning !== undefined && typeof options.onWarning !== 'function') {
23
+ throw new TypeError('AutoTransport onWarning must be a function.');
24
+ }
25
+ this.timeoutMs = positiveInteger(options.timeoutMs ?? DEFAULT_TIMEOUT_MS, 'timeoutMs');
26
+ this.onWarning = options.onWarning;
27
+ this.http = new HttpTransport({
28
+ url: options.endpoints.http,
29
+ ...(options.codec === undefined ? {} : { codec: options.codec }),
30
+ ...(options.fetch === undefined ? {} : { fetch: options.fetch }),
31
+ ...(options.headers === undefined ? {} : { headers: options.headers }),
32
+ timeoutMs: this.timeoutMs,
33
+ ...(options.maximumRequestBytes === undefined
34
+ ? {}
35
+ : { maximumRequestBytes: options.maximumRequestBytes }),
36
+ ...(options.maximumResponseBytes === undefined
37
+ ? {}
38
+ : { maximumResponseBytes: options.maximumResponseBytes }),
39
+ });
40
+ this.websocket = new WebSocketTransport({
41
+ url: options.endpoints.websocket,
42
+ ...(options.codec === undefined ? {} : { codec: options.codec }),
43
+ ...(options.websocket === undefined ? {} : { websocket: options.websocket }),
44
+ timeoutMs: this.timeoutMs,
45
+ ...(options.maximumRequestBytes === undefined
46
+ ? {}
47
+ : { maximumRequestBytes: options.maximumRequestBytes }),
48
+ ...(options.maximumResponseBytes === undefined
49
+ ? {}
50
+ : { maximumResponseBytes: options.maximumResponseBytes }),
51
+ ...(options.maximumBufferedBytes === undefined
52
+ ? {}
53
+ : { maximumBufferedBytes: options.maximumBufferedBytes }),
54
+ ...(options.maximumActiveInvocations === undefined
55
+ ? {}
56
+ : { maximumActiveInvocations: options.maximumActiveInvocations }),
57
+ ...(options.maximumBufferedStreamItems === undefined
58
+ ? {}
59
+ : { maximumBufferedStreamItems: options.maximumBufferedStreamItems }),
60
+ });
61
+ }
62
+ async dispatch(input, options) {
63
+ this.requireOpen();
64
+ const budget = new InvocationBudget(options, this.timeoutMs);
65
+ return this.dispatchWithBudget(input, budget);
66
+ }
67
+ async dispatchWithBudget(input, budget) {
68
+ const ticket = this.decision.begin();
69
+ if (ticket.kind === 'selected') {
70
+ return ticket.selection === 'websocket'
71
+ ? this.tryWebsocket(input, budget, false)
72
+ : this.http.dispatch(input, budget.options());
73
+ }
74
+ if (ticket.kind === 'wait') {
75
+ const selection = await budget.wait(ticket.selection);
76
+ this.requireOpen();
77
+ if (!selection)
78
+ return this.dispatchWithBudget(input, budget);
79
+ return selection === 'websocket'
80
+ ? this.tryWebsocket(input, budget, false)
81
+ : this.http.dispatch(input, budget.options());
82
+ }
83
+ return this.determine(input, budget);
84
+ }
85
+ close() {
86
+ if (this.closed)
87
+ return;
88
+ this.closed = true;
89
+ this.decision.close();
90
+ this.websocket.close();
91
+ }
92
+ async determine(input, budget) {
93
+ return this.tryWebsocket(input, budget, true);
94
+ }
95
+ async tryWebsocket(input, budget, probing) {
96
+ try {
97
+ const result = await this.websocket.dispatch(input, budget.options());
98
+ if (probing)
99
+ this.decision.select('websocket');
100
+ return result;
101
+ }
102
+ catch (error) {
103
+ if (budget.cancelled) {
104
+ if (probing)
105
+ this.decision.release();
106
+ throw error;
107
+ }
108
+ if (error instanceof TransportError &&
109
+ error.context.kind === 'invocation' &&
110
+ error.context.delivery === 'unknown') {
111
+ this.decision.demote();
112
+ throw error;
113
+ }
114
+ if (!mayFallback(error)) {
115
+ if (probing) {
116
+ this.decision.select('websocket');
117
+ }
118
+ throw error;
119
+ }
120
+ const idempotency = budget.idempotency;
121
+ const warning = {
122
+ code: 'AUTO_TRANSPORT_DOWNGRADED',
123
+ target: warningTarget(input),
124
+ websocket: this.websocket.url,
125
+ http: this.http.url,
126
+ phase: error.phase,
127
+ delivery: 'not-sent',
128
+ idempotency,
129
+ };
130
+ emitWarning(Object.freeze(warning), this.onWarning);
131
+ this.decision.demote();
132
+ return this.http.dispatch(input, budget.options());
133
+ }
134
+ }
135
+ requireOpen() {
136
+ if (!this.closed)
137
+ return;
138
+ throw invocationFailure('AutoTransport is closed.', 'closed');
139
+ }
140
+ }
@@ -0,0 +1,13 @@
1
+ import type { NodePath } from '@astrale-os/kernel-core/path';
2
+ import type { TransportPhase } from '../../errors/index.js';
3
+ export interface ClientWarning {
4
+ readonly code: 'AUTO_TRANSPORT_DOWNGRADED';
5
+ readonly target: NodePath;
6
+ readonly websocket: string;
7
+ readonly http: string;
8
+ readonly phase: TransportPhase;
9
+ readonly delivery: 'not-sent';
10
+ readonly idempotency: 'supplied' | 'absent';
11
+ }
12
+ export declare function formatClientWarning(warning: ClientWarning): string;
13
+ export declare function emitWarning(warning: ClientWarning, observer: ((warning: ClientWarning) => void) | undefined): void;
@@ -0,0 +1,18 @@
1
+ export function formatClientWarning(warning) {
2
+ return [
3
+ '[Astrale] WebSocket was unavailable before send; using HTTP for this client.',
4
+ `idempotency=${warning.idempotency}`,
5
+ `target=${JSON.stringify(warning.target)} websocket=${warning.websocket} http=${warning.http} phase=${warning.phase}`,
6
+ ].join(' ');
7
+ }
8
+ export function emitWarning(warning, observer) {
9
+ try {
10
+ if (observer)
11
+ observer(warning);
12
+ else
13
+ globalThis.console?.warn(formatClientWarning(warning));
14
+ }
15
+ catch {
16
+ // Warning observation cannot change invocation settlement.
17
+ }
18
+ }
@@ -0,0 +1,11 @@
1
+ export interface ControlledSignal {
2
+ readonly signal: AbortSignal;
3
+ readonly timedOut: boolean;
4
+ cancel(reason?: unknown): void;
5
+ close(): void;
6
+ }
7
+ /** One caller signal plus one transport-owned lifetime deadline. */
8
+ export declare function controlledSignal(parent: AbortSignal | undefined, timeoutMs: number): ControlledSignal;
9
+ export declare function positiveInteger(input: number, label: string): number;
10
+ export declare function requireLive(control: ControlledSignal): void;
11
+ export declare function asError(value: unknown): Error;
@@ -0,0 +1,39 @@
1
+ /** One caller signal plus one transport-owned lifetime deadline. */
2
+ export function controlledSignal(parent, timeoutMs) {
3
+ const controller = new AbortController();
4
+ let timedOut = false;
5
+ const abort = () => controller.abort(parent?.reason);
6
+ if (parent?.aborted)
7
+ abort();
8
+ else
9
+ parent?.addEventListener('abort', abort, { once: true });
10
+ const timer = setTimeout(() => {
11
+ timedOut = true;
12
+ controller.abort(new Error('request timeout'));
13
+ }, timeoutMs);
14
+ return {
15
+ signal: controller.signal,
16
+ get timedOut() {
17
+ return timedOut;
18
+ },
19
+ cancel: (reason) => controller.abort(reason),
20
+ close: () => {
21
+ clearTimeout(timer);
22
+ parent?.removeEventListener('abort', abort);
23
+ },
24
+ };
25
+ }
26
+ export function positiveInteger(input, label) {
27
+ if (!Number.isSafeInteger(input) || input < 1 || input > 2_147_483_647) {
28
+ throw new TypeError(`${label} must be a positive safe platform integer.`);
29
+ }
30
+ return input;
31
+ }
32
+ export function requireLive(control) {
33
+ if (!control.signal.aborted)
34
+ return;
35
+ throw control.signal.reason ?? new Error('request was cancelled.');
36
+ }
37
+ export function asError(value) {
38
+ return value instanceof Error ? value : new Error(String(value));
39
+ }
@@ -0,0 +1,7 @@
1
+ import { TransportError, type InvocationTransportErrorOptions } from '../errors/index.js';
2
+ type InvocationFailureEvidence = Omit<InvocationTransportErrorOptions, 'delivery' | 'phase'> & {
3
+ readonly delivery?: InvocationTransportErrorOptions['delivery'];
4
+ };
5
+ /** Create invocation transport evidence with the common not-sent default. */
6
+ export declare function invocationFailure(message: string, phase: InvocationTransportErrorOptions['phase'], evidence?: InvocationFailureEvidence): TransportError;
7
+ export {};
@@ -0,0 +1,9 @@
1
+ import { TransportError } from '../errors/index.js';
2
+ /** Create invocation transport evidence with the common not-sent default. */
3
+ export function invocationFailure(message, phase, evidence = {}) {
4
+ return TransportError.invocation(message, {
5
+ ...evidence,
6
+ phase,
7
+ delivery: evidence.delivery ?? 'not-sent',
8
+ });
9
+ }
@@ -0,0 +1 @@
1
+ export { HttpTransport, type Fetch, type HttpTransportOptions } from './transport.js';
@@ -0,0 +1 @@
1
+ export { HttpTransport } from './transport.js';
@@ -0,0 +1,8 @@
1
+ import * as codecs from '@astrale-os/kernel-protocol/codecs';
2
+ import * as protocol from '@astrale-os/kernel-protocol/invocation';
3
+ export declare function codecForResponse(contentType: string | null): Promise<codecs.Codec | undefined>;
4
+ export declare function readBoundedBody(response: Response, maximumBytes: number, signal: AbortSignal): Promise<Uint8Array>;
5
+ export declare function requireId(expected: protocol.RequestId, received: protocol.RequestId): void;
6
+ export declare function decodeProtocol<T>(label: string, decode: () => T): T;
7
+ export declare function normalizeMediaType(input: string | null): string | undefined;
8
+ export declare function binaryHeaders(input: Headers, names: readonly string[]): Readonly<Record<string, string>>;
@@ -0,0 +1,79 @@
1
+ import * as codecs from '@astrale-os/kernel-protocol/codecs';
2
+ import * as protocol from '@astrale-os/kernel-protocol/invocation';
3
+ import { ProtocolError, ResponseError } from '../../errors/index.js';
4
+ import { asError } from '../index.js';
5
+ export async function codecForResponse(contentType) {
6
+ const mediaType = normalizeMediaType(contentType);
7
+ const supported = mediaType === codecs.CONTENT_TYPE_MSGPACK
8
+ ? [codecs.json, await codecs.loadMsgpack()]
9
+ : [codecs.json];
10
+ return protocol.http.codecForContentType(contentType, supported);
11
+ }
12
+ export async function readBoundedBody(response, maximumBytes, signal) {
13
+ const declared = response.headers.get('content-length');
14
+ if (declared !== null && Number(declared) > maximumBytes) {
15
+ throw new ProtocolError(`response exceeds maximumResponseBytes (${maximumBytes}).`);
16
+ }
17
+ if (response.body === null)
18
+ return new Uint8Array();
19
+ const reader = response.body.getReader();
20
+ const chunks = [];
21
+ let total = 0;
22
+ try {
23
+ while (true) {
24
+ if (signal.aborted)
25
+ throw signal.reason;
26
+ const next = await reader.read();
27
+ if (next.done)
28
+ break;
29
+ total += next.value.byteLength;
30
+ if (total > maximumBytes) {
31
+ throw new ProtocolError(`response exceeds maximumResponseBytes (${maximumBytes}).`);
32
+ }
33
+ chunks.push(next.value);
34
+ }
35
+ }
36
+ catch (error) {
37
+ await reader.cancel(error).catch(() => undefined);
38
+ throw error;
39
+ }
40
+ const output = new Uint8Array(total);
41
+ let offset = 0;
42
+ for (const chunk of chunks) {
43
+ output.set(chunk, offset);
44
+ offset += chunk.byteLength;
45
+ }
46
+ return output;
47
+ }
48
+ export function requireId(expected, received) {
49
+ if (received !== expected) {
50
+ throw new ProtocolError(`response id ${JSON.stringify(received)} does not match request id ${JSON.stringify(expected)}.`);
51
+ }
52
+ }
53
+ export function decodeProtocol(label, decode) {
54
+ try {
55
+ return decode();
56
+ }
57
+ catch (error) {
58
+ if (error instanceof ResponseError || error instanceof ProtocolError)
59
+ throw error;
60
+ throw new ProtocolError(`server returned an invalid ${label}.`, { cause: asError(error) });
61
+ }
62
+ }
63
+ export function normalizeMediaType(input) {
64
+ if (input === null)
65
+ return undefined;
66
+ const value = input.split(';', 1)[0]?.trim().toLowerCase();
67
+ return value === '' ? undefined : value;
68
+ }
69
+ export function binaryHeaders(input, names) {
70
+ const output = {};
71
+ for (const name of names) {
72
+ const value = input.get(name);
73
+ if (value === null) {
74
+ throw new ProtocolError(`server omitted declared binary application header ${name}.`);
75
+ }
76
+ output[name] = value;
77
+ }
78
+ return Object.freeze(output);
79
+ }
@@ -0,0 +1,26 @@
1
+ import type { Value } from '@astrale-os/kernel-dsl/value';
2
+ import type * as codecs from '@astrale-os/kernel-protocol/codecs';
3
+ import * as protocol from '@astrale-os/kernel-protocol/invocation';
4
+ import type { Stream } from '../../client/index.js';
5
+ import { type ControlledSignal } from '../index.js';
6
+ export declare class HttpStream implements Stream {
7
+ private readonly frames;
8
+ private readonly codec;
9
+ private readonly requestId;
10
+ private readonly control;
11
+ invocation: protocol.InvocationId;
12
+ private claimed;
13
+ private terminal;
14
+ private index;
15
+ private interruption;
16
+ private constructor();
17
+ static open(response: Response, codec: codecs.Codec, requestId: protocol.RequestId, maximumFrameBytes: number, control: ControlledSignal): Promise<HttpStream>;
18
+ [Symbol.asyncIterator](): AsyncIterator<Value>;
19
+ cancel(reason?: string): Promise<void>;
20
+ private next;
21
+ private readFrame;
22
+ private finish;
23
+ private interrupt;
24
+ private stop;
25
+ private abortFailure;
26
+ }
@@ -0,0 +1,214 @@
1
+ import * as protocol from '@astrale-os/kernel-protocol/invocation';
2
+ import { ProtocolError, ResponseError, TransportError } from '../../errors/index.js';
3
+ import { invocationFailure } from '../failure.js';
4
+ import { asError } from '../index.js';
5
+ import { decodeProtocol, requireId } from './response.js';
6
+ export class HttpStream {
7
+ frames;
8
+ codec;
9
+ requestId;
10
+ control;
11
+ invocation;
12
+ claimed = false;
13
+ terminal = false;
14
+ index = 0;
15
+ interruption;
16
+ constructor(frames, codec, requestId, control) {
17
+ this.frames = frames;
18
+ this.codec = codec;
19
+ this.requestId = requestId;
20
+ this.control = control;
21
+ const abort = () => void this.interrupt(this.abortFailure(control.signal.reason));
22
+ if (control.signal.aborted)
23
+ abort();
24
+ else
25
+ control.signal.addEventListener('abort', abort, { once: true });
26
+ }
27
+ static async open(response, codec, requestId, maximumFrameBytes, control) {
28
+ if (response.body === null)
29
+ throw new ProtocolError('stream has no body.');
30
+ const stream = new HttpStream(new LengthPrefixedFrames(response.body.getReader(), maximumFrameBytes), codec, requestId, control);
31
+ const first = await stream.readFrame();
32
+ if (first === null || first.kind !== 'stream.start') {
33
+ await stream.stop('invalid stream start');
34
+ throw new ProtocolError('stream did not begin with stream.start.');
35
+ }
36
+ stream.invocation = first.invocation;
37
+ return stream;
38
+ }
39
+ [Symbol.asyncIterator]() {
40
+ if (this.claimed)
41
+ throw new TypeError('streams admit exactly one consumer.');
42
+ this.claimed = true;
43
+ return {
44
+ next: () => this.next(),
45
+ return: async () => {
46
+ await this.cancel('stream consumer stopped');
47
+ return { done: true, value: undefined };
48
+ },
49
+ throw: async (error) => {
50
+ await this.cancel('stream consumer failed');
51
+ throw error;
52
+ },
53
+ };
54
+ }
55
+ async cancel(reason = 'stream cancelled') {
56
+ await this.stop(reason);
57
+ }
58
+ async next() {
59
+ if (this.interruption !== undefined)
60
+ throw this.interruption;
61
+ if (this.terminal)
62
+ return { done: true, value: undefined };
63
+ try {
64
+ const frame = await this.readFrame();
65
+ if (frame === null) {
66
+ throw new ProtocolError('stream ended without a terminal frame.');
67
+ }
68
+ if (frame.kind === 'stream.item') {
69
+ if (frame.index !== this.index) {
70
+ throw new ProtocolError(`stream item ${frame.index} does not match expected index ${this.index}.`);
71
+ }
72
+ this.index += 1;
73
+ return { done: false, value: frame.value };
74
+ }
75
+ if (frame.kind === 'stream.error') {
76
+ await this.finish();
77
+ throw new ResponseError(frame.error.code, frame.error.message, this.invocation, frame.error.data);
78
+ }
79
+ if (frame.kind !== 'stream.end') {
80
+ throw new ProtocolError(`Unexpected ${frame.kind} frame inside stream.`);
81
+ }
82
+ if (frame.count !== this.index) {
83
+ throw new ProtocolError(`stream ended with count ${frame.count}; ${this.index} items were received.`);
84
+ }
85
+ await this.finish();
86
+ return { done: true, value: undefined };
87
+ }
88
+ catch (error) {
89
+ const failure = this.interruption ?? retainInvocationId(error, this.invocation);
90
+ await this.stop(failure);
91
+ throw failure;
92
+ }
93
+ }
94
+ async readFrame() {
95
+ const payload = await this.frames.read();
96
+ if (this.interruption !== undefined)
97
+ throw this.interruption;
98
+ if (payload === null)
99
+ return null;
100
+ const frame = decodeProtocol('stream frame', () => protocol.decodeStreamFrame(this.codec.decode(payload)));
101
+ requireId(this.requestId, frame.requestId);
102
+ return frame;
103
+ }
104
+ async finish() {
105
+ if (this.terminal)
106
+ return;
107
+ await this.frames.requireEnd();
108
+ this.terminal = true;
109
+ this.control.close();
110
+ }
111
+ async interrupt(reason) {
112
+ if (this.terminal || this.interruption !== undefined)
113
+ return;
114
+ this.interruption = reason;
115
+ await this.frames.cancel(reason);
116
+ this.control.close();
117
+ }
118
+ async stop(reason) {
119
+ if (this.terminal)
120
+ return;
121
+ this.terminal = true;
122
+ this.control.cancel(reason);
123
+ await this.frames.cancel(reason);
124
+ this.control.close();
125
+ }
126
+ abortFailure(reason) {
127
+ if (this.control.timedOut) {
128
+ return invocationFailure('stream exceeded its invocation timeout.', 'timeout', {
129
+ cause: asError(reason),
130
+ delivery: 'unknown',
131
+ invocation: this.invocation,
132
+ });
133
+ }
134
+ return asError(reason ?? new Error('stream was cancelled.'));
135
+ }
136
+ }
137
+ function retainInvocationId(input, invocation) {
138
+ if (input instanceof ProtocolError && input.invocation === undefined) {
139
+ return new ProtocolError(input.message, { cause: input, invocation });
140
+ }
141
+ if (input instanceof TransportError &&
142
+ input.context.kind === 'invocation' &&
143
+ input.context.invocation === undefined) {
144
+ return invocationFailure(input.message, input.phase, {
145
+ cause: input,
146
+ delivery: input.context.delivery,
147
+ invocation,
148
+ });
149
+ }
150
+ return input;
151
+ }
152
+ class LengthPrefixedFrames {
153
+ reader;
154
+ maximumFrameBytes;
155
+ chunk = new Uint8Array();
156
+ offset = 0;
157
+ done = false;
158
+ constructor(reader, maximumFrameBytes) {
159
+ this.reader = reader;
160
+ this.maximumFrameBytes = maximumFrameBytes;
161
+ }
162
+ async read() {
163
+ const header = await this.take(4, true);
164
+ if (header === null)
165
+ return null;
166
+ const length = new DataView(header.buffer, header.byteOffset, header.byteLength).getUint32(0);
167
+ if (length > this.maximumFrameBytes) {
168
+ throw new ProtocolError(`stream frame exceeds maximumResponseBytes (${this.maximumFrameBytes}).`);
169
+ }
170
+ return (await this.take(length, false));
171
+ }
172
+ async requireEnd() {
173
+ const extra = await this.take(1, true);
174
+ if (extra !== null) {
175
+ throw new ProtocolError('stream contains data after its terminal frame.');
176
+ }
177
+ }
178
+ async cancel(reason) {
179
+ try {
180
+ await this.reader.cancel(reason);
181
+ }
182
+ catch {
183
+ // Cancellation is best-effort after the client has already chosen a terminal outcome.
184
+ }
185
+ }
186
+ async take(length, allowCleanEnd) {
187
+ const output = new Uint8Array(length);
188
+ let written = 0;
189
+ while (written < length) {
190
+ if (this.offset === this.chunk.byteLength) {
191
+ if (this.done) {
192
+ if (allowCleanEnd && written === 0)
193
+ return null;
194
+ throw new ProtocolError('stream ended in the middle of a frame.');
195
+ }
196
+ const next = await this.reader.read();
197
+ if (next.done) {
198
+ this.done = true;
199
+ continue;
200
+ }
201
+ this.chunk = next.value;
202
+ this.offset = 0;
203
+ if (this.chunk.byteLength === 0)
204
+ continue;
205
+ }
206
+ const available = this.chunk.byteLength - this.offset;
207
+ const count = Math.min(available, length - written);
208
+ output.set(this.chunk.subarray(this.offset, this.offset + count), written);
209
+ written += count;
210
+ this.offset += count;
211
+ }
212
+ return output;
213
+ }
214
+ }
@@ -0,0 +1,32 @@
1
+ import type { RequestOptions, Transport, TransportRequest, TransportResult } from '../index.js';
2
+ /** Web Fetch capability used by the built-in HTTP transport. */
3
+ export type Fetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
4
+ export interface HttpTransportOptions {
5
+ readonly url: string;
6
+ readonly codec?: 'json' | 'msgpack';
7
+ /** Inject this capability when the host does not provide global Fetch. */
8
+ readonly fetch?: Fetch;
9
+ readonly headers?: Readonly<Record<string, string>>;
10
+ readonly timeoutMs?: number;
11
+ /** Maximum bytes in one encoded request before Fetch handoff. */
12
+ readonly maximumRequestBytes?: number;
13
+ /** Maximum unary, binary, or individual stream-frame body size. */
14
+ readonly maximumResponseBytes?: number;
15
+ }
16
+ /** HTTP implementation of the universal invocation protocol. */
17
+ export declare class HttpTransport implements Transport {
18
+ readonly url: string;
19
+ private readonly codecName;
20
+ private readonly fetchImpl;
21
+ private readonly headers;
22
+ private readonly timeoutMs;
23
+ private readonly maximumRequestBytes;
24
+ private readonly maximumResponseBytes;
25
+ private nextId;
26
+ constructor(options: HttpTransportOptions);
27
+ dispatch(input: TransportRequest, options?: RequestOptions): Promise<TransportResult>;
28
+ private fetchResponse;
29
+ private decodeBinary;
30
+ private nextRequestId;
31
+ private requestCodec;
32
+ }