@elaraai/e3-rack 0.0.0-bootstrap.0 → 1.0.94

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 (306) hide show
  1. package/README.md +407 -2
  2. package/dist/src/client/client.spec.d.ts +6 -0
  3. package/dist/src/client/client.spec.d.ts.map +1 -0
  4. package/dist/src/client/client.spec.js +150 -0
  5. package/dist/src/client/client.spec.js.map +1 -0
  6. package/dist/src/client/connect.d.ts +52 -0
  7. package/dist/src/client/connect.d.ts.map +1 -0
  8. package/dist/src/client/connect.js +112 -0
  9. package/dist/src/client/connect.js.map +1 -0
  10. package/dist/src/client/hub-client.d.ts +57 -0
  11. package/dist/src/client/hub-client.d.ts.map +1 -0
  12. package/dist/src/client/hub-client.js +87 -0
  13. package/dist/src/client/hub-client.js.map +1 -0
  14. package/dist/src/client/local-http.d.ts +78 -0
  15. package/dist/src/client/local-http.d.ts.map +1 -0
  16. package/dist/src/client/local-http.js +149 -0
  17. package/dist/src/client/local-http.js.map +1 -0
  18. package/dist/src/client/session-attempts.d.ts +20 -0
  19. package/dist/src/client/session-attempts.d.ts.map +1 -0
  20. package/dist/src/client/session-attempts.js +88 -0
  21. package/dist/src/client/session-attempts.js.map +1 -0
  22. package/dist/src/client/session-data-server.d.ts +37 -0
  23. package/dist/src/client/session-data-server.d.ts.map +1 -0
  24. package/dist/src/client/session-data-server.js +280 -0
  25. package/dist/src/client/session-data-server.js.map +1 -0
  26. package/dist/src/client/session-data-server.spec.d.ts +6 -0
  27. package/dist/src/client/session-data-server.spec.d.ts.map +1 -0
  28. package/dist/src/client/session-data-server.spec.js +192 -0
  29. package/dist/src/client/session-data-server.spec.js.map +1 -0
  30. package/dist/src/client/session.d.ts +119 -0
  31. package/dist/src/client/session.d.ts.map +1 -0
  32. package/dist/src/client/session.js +290 -0
  33. package/dist/src/client/session.js.map +1 -0
  34. package/dist/src/hub/config.d.ts +74 -0
  35. package/dist/src/hub/config.d.ts.map +1 -0
  36. package/dist/src/hub/config.js +159 -0
  37. package/dist/src/hub/config.js.map +1 -0
  38. package/dist/src/hub/fair-lease-store.d.ts +36 -0
  39. package/dist/src/hub/fair-lease-store.d.ts.map +1 -0
  40. package/dist/src/hub/fair-lease-store.js +73 -0
  41. package/dist/src/hub/fair-lease-store.js.map +1 -0
  42. package/dist/src/hub/hub.d.ts +91 -0
  43. package/dist/src/hub/hub.d.ts.map +1 -0
  44. package/dist/src/hub/hub.js +641 -0
  45. package/dist/src/hub/hub.js.map +1 -0
  46. package/dist/src/hub/hub.spec.d.ts +6 -0
  47. package/dist/src/hub/hub.spec.d.ts.map +1 -0
  48. package/dist/src/hub/hub.spec.js +363 -0
  49. package/dist/src/hub/hub.spec.js.map +1 -0
  50. package/dist/src/hub/infrastructure.spec.d.ts +6 -0
  51. package/dist/src/hub/infrastructure.spec.d.ts.map +1 -0
  52. package/dist/src/hub/infrastructure.spec.js +211 -0
  53. package/dist/src/hub/infrastructure.spec.js.map +1 -0
  54. package/dist/src/hub/lock.d.ts +62 -0
  55. package/dist/src/hub/lock.d.ts.map +1 -0
  56. package/dist/src/hub/lock.js +165 -0
  57. package/dist/src/hub/lock.js.map +1 -0
  58. package/dist/src/hub/main.d.ts +16 -0
  59. package/dist/src/hub/main.d.ts.map +1 -0
  60. package/dist/src/hub/main.js +56 -0
  61. package/dist/src/hub/main.js.map +1 -0
  62. package/dist/src/hub/session-bridge.d.ts +116 -0
  63. package/dist/src/hub/session-bridge.d.ts.map +1 -0
  64. package/dist/src/hub/session-bridge.js +336 -0
  65. package/dist/src/hub/session-bridge.js.map +1 -0
  66. package/dist/src/identity/file-identity-store.d.ts +18 -0
  67. package/dist/src/identity/file-identity-store.d.ts.map +1 -0
  68. package/dist/src/identity/file-identity-store.js +34 -0
  69. package/dist/src/identity/file-identity-store.js.map +1 -0
  70. package/dist/src/identity/file-identity-store.spec.d.ts +6 -0
  71. package/dist/src/identity/file-identity-store.spec.d.ts.map +1 -0
  72. package/dist/src/identity/file-identity-store.spec.js +59 -0
  73. package/dist/src/identity/file-identity-store.spec.js.map +1 -0
  74. package/dist/src/identity/in-memory-identity-store.d.ts +48 -0
  75. package/dist/src/identity/in-memory-identity-store.d.ts.map +1 -0
  76. package/dist/src/identity/in-memory-identity-store.js +102 -0
  77. package/dist/src/identity/in-memory-identity-store.js.map +1 -0
  78. package/dist/src/identity/machine-identity.d.ts +134 -0
  79. package/dist/src/identity/machine-identity.d.ts.map +1 -0
  80. package/dist/src/identity/machine-identity.js +65 -0
  81. package/dist/src/identity/machine-identity.js.map +1 -0
  82. package/dist/src/index.d.ts +34 -0
  83. package/dist/src/index.d.ts.map +1 -0
  84. package/dist/src/index.js +34 -0
  85. package/dist/src/index.js.map +1 -0
  86. package/dist/src/lease/closure.d.ts +96 -0
  87. package/dist/src/lease/closure.d.ts.map +1 -0
  88. package/dist/src/lease/closure.js +192 -0
  89. package/dist/src/lease/closure.js.map +1 -0
  90. package/dist/src/lease/closure.spec.d.ts +6 -0
  91. package/dist/src/lease/closure.spec.d.ts.map +1 -0
  92. package/dist/src/lease/closure.spec.js +35 -0
  93. package/dist/src/lease/closure.spec.js.map +1 -0
  94. package/dist/src/lease/coordinator.d.ts +34 -0
  95. package/dist/src/lease/coordinator.d.ts.map +1 -0
  96. package/dist/src/lease/coordinator.js +42 -0
  97. package/dist/src/lease/coordinator.js.map +1 -0
  98. package/dist/src/lease/in-memory-lease-store.d.ts +58 -0
  99. package/dist/src/lease/in-memory-lease-store.d.ts.map +1 -0
  100. package/dist/src/lease/in-memory-lease-store.js +132 -0
  101. package/dist/src/lease/in-memory-lease-store.js.map +1 -0
  102. package/dist/src/lease/lease-store.d.ts +169 -0
  103. package/dist/src/lease/lease-store.d.ts.map +1 -0
  104. package/dist/src/lease/lease-store.js +94 -0
  105. package/dist/src/lease/lease-store.js.map +1 -0
  106. package/dist/src/lease/lease-store.spec.d.ts +6 -0
  107. package/dist/src/lease/lease-store.spec.d.ts.map +1 -0
  108. package/dist/src/lease/lease-store.spec.js +8 -0
  109. package/dist/src/lease/lease-store.spec.js.map +1 -0
  110. package/dist/src/lease/rack-dispatch.d.ts +105 -0
  111. package/dist/src/lease/rack-dispatch.d.ts.map +1 -0
  112. package/dist/src/lease/rack-dispatch.js +6 -0
  113. package/dist/src/lease/rack-dispatch.js.map +1 -0
  114. package/dist/src/mutation-queue.d.ts +13 -0
  115. package/dist/src/mutation-queue.d.ts.map +1 -0
  116. package/dist/src/mutation-queue.js +17 -0
  117. package/dist/src/mutation-queue.js.map +1 -0
  118. package/dist/src/paths.d.ts +56 -0
  119. package/dist/src/paths.d.ts.map +1 -0
  120. package/dist/src/paths.js +82 -0
  121. package/dist/src/paths.js.map +1 -0
  122. package/dist/src/protocol/control.d.ts +295 -0
  123. package/dist/src/protocol/control.d.ts.map +1 -0
  124. package/dist/src/protocol/control.js +74 -0
  125. package/dist/src/protocol/control.js.map +1 -0
  126. package/dist/src/protocol/index.d.ts +9 -0
  127. package/dist/src/protocol/index.d.ts.map +1 -0
  128. package/dist/src/protocol/index.js +9 -0
  129. package/dist/src/protocol/index.js.map +1 -0
  130. package/dist/src/protocol/rack-wire.d.ts +357 -0
  131. package/dist/src/protocol/rack-wire.d.ts.map +1 -0
  132. package/dist/src/protocol/rack-wire.js +262 -0
  133. package/dist/src/protocol/rack-wire.js.map +1 -0
  134. package/dist/src/protocol/rack-wire.spec.d.ts +6 -0
  135. package/dist/src/protocol/rack-wire.spec.d.ts.map +1 -0
  136. package/dist/src/protocol/rack-wire.spec.js +14 -0
  137. package/dist/src/protocol/rack-wire.spec.js.map +1 -0
  138. package/dist/src/protocol/registration.d.ts +70 -0
  139. package/dist/src/protocol/registration.d.ts.map +1 -0
  140. package/dist/src/protocol/registration.js +67 -0
  141. package/dist/src/protocol/registration.js.map +1 -0
  142. package/dist/src/protocol/session-data.d.ts +69 -0
  143. package/dist/src/protocol/session-data.d.ts.map +1 -0
  144. package/dist/src/protocol/session-data.js +26 -0
  145. package/dist/src/protocol/session-data.js.map +1 -0
  146. package/dist/src/protocol/task-envelope.d.ts +198 -0
  147. package/dist/src/protocol/task-envelope.d.ts.map +1 -0
  148. package/dist/src/protocol/task-envelope.js +93 -0
  149. package/dist/src/protocol/task-envelope.js.map +1 -0
  150. package/dist/src/protocol/wire-golden.d.ts +8 -0
  151. package/dist/src/protocol/wire-golden.d.ts.map +1 -0
  152. package/dist/src/protocol/wire-golden.js +34 -0
  153. package/dist/src/protocol/wire-golden.js.map +1 -0
  154. package/dist/src/protocol/wire-samples.d.ts +11 -0
  155. package/dist/src/protocol/wire-samples.d.ts.map +1 -0
  156. package/dist/src/protocol/wire-samples.js +52 -0
  157. package/dist/src/protocol/wire-samples.js.map +1 -0
  158. package/dist/src/registry/file-rack-registry.d.ts +68 -0
  159. package/dist/src/registry/file-rack-registry.d.ts.map +1 -0
  160. package/dist/src/registry/file-rack-registry.js +138 -0
  161. package/dist/src/registry/file-rack-registry.js.map +1 -0
  162. package/dist/src/registry/file-rack-registry.spec.d.ts +6 -0
  163. package/dist/src/registry/file-rack-registry.spec.d.ts.map +1 -0
  164. package/dist/src/registry/file-rack-registry.spec.js +50 -0
  165. package/dist/src/registry/file-rack-registry.spec.js.map +1 -0
  166. package/dist/src/registry/rack-registry.d.ts +64 -0
  167. package/dist/src/registry/rack-registry.d.ts.map +1 -0
  168. package/dist/src/registry/rack-registry.js +65 -0
  169. package/dist/src/registry/rack-registry.js.map +1 -0
  170. package/dist/src/registry/rack-registry.spec.d.ts +6 -0
  171. package/dist/src/registry/rack-registry.spec.d.ts.map +1 -0
  172. package/dist/src/registry/rack-registry.spec.js +8 -0
  173. package/dist/src/registry/rack-registry.spec.js.map +1 -0
  174. package/dist/src/routing/eligibility.d.ts +38 -0
  175. package/dist/src/routing/eligibility.d.ts.map +1 -0
  176. package/dist/src/routing/eligibility.js +78 -0
  177. package/dist/src/routing/eligibility.js.map +1 -0
  178. package/dist/src/routing/host-coupling.d.ts +26 -0
  179. package/dist/src/routing/host-coupling.d.ts.map +1 -0
  180. package/dist/src/routing/host-coupling.js +62 -0
  181. package/dist/src/routing/host-coupling.js.map +1 -0
  182. package/dist/src/routing/policy.d.ts +188 -0
  183. package/dist/src/routing/policy.d.ts.map +1 -0
  184. package/dist/src/routing/policy.js +212 -0
  185. package/dist/src/routing/policy.js.map +1 -0
  186. package/dist/src/routing/routing.spec.d.ts +6 -0
  187. package/dist/src/routing/routing.spec.d.ts.map +1 -0
  188. package/dist/src/routing/routing.spec.js +100 -0
  189. package/dist/src/routing/routing.spec.js.map +1 -0
  190. package/dist/src/routing/tiers.d.ts +22 -0
  191. package/dist/src/routing/tiers.d.ts.map +1 -0
  192. package/dist/src/routing/tiers.js +26 -0
  193. package/dist/src/routing/tiers.js.map +1 -0
  194. package/dist/src/runner/api-server.d.ts +45 -0
  195. package/dist/src/runner/api-server.d.ts.map +1 -0
  196. package/dist/src/runner/api-server.js +21 -0
  197. package/dist/src/runner/api-server.js.map +1 -0
  198. package/dist/src/runner/capacity.d.ts +13 -0
  199. package/dist/src/runner/capacity.d.ts.map +1 -0
  200. package/dist/src/runner/capacity.js +18 -0
  201. package/dist/src/runner/capacity.js.map +1 -0
  202. package/dist/src/runner/rack-body.d.ts +43 -0
  203. package/dist/src/runner/rack-body.d.ts.map +1 -0
  204. package/dist/src/runner/rack-body.js +208 -0
  205. package/dist/src/runner/rack-body.js.map +1 -0
  206. package/dist/src/runner/rack-runner.d.ts +62 -0
  207. package/dist/src/runner/rack-runner.d.ts.map +1 -0
  208. package/dist/src/runner/rack-runner.js +75 -0
  209. package/dist/src/runner/rack-runner.js.map +1 -0
  210. package/dist/src/runner/rack-runner.spec.d.ts +6 -0
  211. package/dist/src/runner/rack-runner.spec.d.ts.map +1 -0
  212. package/dist/src/runner/rack-runner.spec.js +302 -0
  213. package/dist/src/runner/rack-runner.spec.js.map +1 -0
  214. package/dist/src/runner/split.spec.d.ts +6 -0
  215. package/dist/src/runner/split.spec.d.ts.map +1 -0
  216. package/dist/src/runner/split.spec.js +188 -0
  217. package/dist/src/runner/split.spec.js.map +1 -0
  218. package/dist/src/runner-event.d.ts +261 -0
  219. package/dist/src/runner-event.d.ts.map +1 -0
  220. package/dist/src/runner-event.js +332 -0
  221. package/dist/src/runner-event.js.map +1 -0
  222. package/dist/src/server/beast2.d.ts +19 -0
  223. package/dist/src/server/beast2.d.ts.map +1 -0
  224. package/dist/src/server/beast2.js +18 -0
  225. package/dist/src/server/beast2.js.map +1 -0
  226. package/dist/src/server/body-limit.d.ts +16 -0
  227. package/dist/src/server/body-limit.d.ts.map +1 -0
  228. package/dist/src/server/body-limit.js +53 -0
  229. package/dist/src/server/body-limit.js.map +1 -0
  230. package/dist/src/server/body-limit.spec.d.ts +2 -0
  231. package/dist/src/server/body-limit.spec.d.ts.map +1 -0
  232. package/dist/src/server/body-limit.spec.js +32 -0
  233. package/dist/src/server/body-limit.spec.js.map +1 -0
  234. package/dist/src/server/bounded.d.ts +16 -0
  235. package/dist/src/server/bounded.d.ts.map +1 -0
  236. package/dist/src/server/bounded.js +39 -0
  237. package/dist/src/server/bounded.js.map +1 -0
  238. package/dist/src/server/dispatch.d.ts +137 -0
  239. package/dist/src/server/dispatch.d.ts.map +1 -0
  240. package/dist/src/server/dispatch.js +267 -0
  241. package/dist/src/server/dispatch.js.map +1 -0
  242. package/dist/src/server/env-publication.d.ts +45 -0
  243. package/dist/src/server/env-publication.d.ts.map +1 -0
  244. package/dist/src/server/env-publication.js +10 -0
  245. package/dist/src/server/env-publication.js.map +1 -0
  246. package/dist/src/server/index.d.ts +16 -0
  247. package/dist/src/server/index.d.ts.map +1 -0
  248. package/dist/src/server/index.js +17 -0
  249. package/dist/src/server/index.js.map +1 -0
  250. package/dist/src/server/protocol.spec.d.ts +6 -0
  251. package/dist/src/server/protocol.spec.d.ts.map +1 -0
  252. package/dist/src/server/protocol.spec.js +78 -0
  253. package/dist/src/server/protocol.spec.js.map +1 -0
  254. package/dist/src/server/rack-routes.d.ts +175 -0
  255. package/dist/src/server/rack-routes.d.ts.map +1 -0
  256. package/dist/src/server/rack-routes.js +755 -0
  257. package/dist/src/server/rack-routes.js.map +1 -0
  258. package/dist/src/server/rack-routes.spec.d.ts +6 -0
  259. package/dist/src/server/rack-routes.spec.d.ts.map +1 -0
  260. package/dist/src/server/rack-routes.spec.js +477 -0
  261. package/dist/src/server/rack-routes.spec.js.map +1 -0
  262. package/dist/src/server/storage-bridge.d.ts +140 -0
  263. package/dist/src/server/storage-bridge.d.ts.map +1 -0
  264. package/dist/src/server/storage-bridge.js +6 -0
  265. package/dist/src/server/storage-bridge.js.map +1 -0
  266. package/dist/src/state-file.d.ts +10 -0
  267. package/dist/src/state-file.d.ts.map +1 -0
  268. package/dist/src/state-file.js +38 -0
  269. package/dist/src/state-file.js.map +1 -0
  270. package/dist/src/testing/in-memory.d.ts +116 -0
  271. package/dist/src/testing/in-memory.d.ts.map +1 -0
  272. package/dist/src/testing/in-memory.js +193 -0
  273. package/dist/src/testing/in-memory.js.map +1 -0
  274. package/dist/src/testing/index.d.ts +14 -0
  275. package/dist/src/testing/index.d.ts.map +1 -0
  276. package/dist/src/testing/index.js +14 -0
  277. package/dist/src/testing/index.js.map +1 -0
  278. package/dist/src/testing/lease-store-contract.d.ts +14 -0
  279. package/dist/src/testing/lease-store-contract.d.ts.map +1 -0
  280. package/dist/src/testing/lease-store-contract.js +78 -0
  281. package/dist/src/testing/lease-store-contract.js.map +1 -0
  282. package/dist/src/testing/protocol-suite.d.ts +38 -0
  283. package/dist/src/testing/protocol-suite.d.ts.map +1 -0
  284. package/dist/src/testing/protocol-suite.js +207 -0
  285. package/dist/src/testing/protocol-suite.js.map +1 -0
  286. package/dist/src/testing/rack-registry-contract.d.ts +15 -0
  287. package/dist/src/testing/rack-registry-contract.d.ts.map +1 -0
  288. package/dist/src/testing/rack-registry-contract.js +106 -0
  289. package/dist/src/testing/rack-registry-contract.js.map +1 -0
  290. package/dist/src/testing/test-rack-agent.d.ts +121 -0
  291. package/dist/src/testing/test-rack-agent.d.ts.map +1 -0
  292. package/dist/src/testing/test-rack-agent.js +316 -0
  293. package/dist/src/testing/test-rack-agent.js.map +1 -0
  294. package/dist/src/tls/tls.d.ts +67 -0
  295. package/dist/src/tls/tls.d.ts.map +1 -0
  296. package/dist/src/tls/tls.js +200 -0
  297. package/dist/src/tls/tls.js.map +1 -0
  298. package/dist/src/tls/tls.spec.d.ts +6 -0
  299. package/dist/src/tls/tls.spec.d.ts.map +1 -0
  300. package/dist/src/tls/tls.spec.js +101 -0
  301. package/dist/src/tls/tls.spec.js.map +1 -0
  302. package/dist/src/version.d.ts +9 -0
  303. package/dist/src/version.d.ts.map +1 -0
  304. package/dist/src/version.js +10 -0
  305. package/dist/src/version.js.map +1 -0
  306. package/package.json +67 -7
@@ -0,0 +1,357 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Rack machine-protocol wire types (epic #67 design §9) — the BEAST2 bodies
7
+ * exchanged between a rack agent and the deployment's /api/rack endpoints.
8
+ * Shared by the server routes (e3-cloud-core), the HTTP client, and the
9
+ * rack agent, so the shapes live here beside the delegation types.
10
+ */
11
+ import { ArrayType, BlobType, BooleanType, DateTimeType, DictType, IntegerType, NullType, OptionType, StringType, StructType, VariantType, type ValueTypeOf } from '@elaraai/east';
12
+ /**
13
+ * What an enrolling agent declares about its host: the operator-facing
14
+ * label, the runner tiers it has rootfs images for (node | py |
15
+ * py-datascience | c | full — the #57 vocabulary), its max concurrent
16
+ * microVMs, and the agent build it runs.
17
+ */
18
+ export declare const RackHostInfoType: StructType<{
19
+ readonly label: StringType;
20
+ readonly tiers: ArrayType<StringType>;
21
+ readonly capacity: IntegerType;
22
+ readonly agentVersion: StringType;
23
+ }>;
24
+ export type RackHostInfo = ValueTypeOf<typeof RackHostInfoType>;
25
+ /**
26
+ * POST /rack/enroll request — exchanges a single-use enrollment token
27
+ * (minted by an admin in the UI) for a long-lived rack credential.
28
+ */
29
+ export declare const RackEnrollRequestType: StructType<{
30
+ readonly enrollmentToken: StringType;
31
+ readonly hostInfo: StructType<{
32
+ readonly label: StringType;
33
+ readonly tiers: ArrayType<StringType>;
34
+ readonly capacity: IntegerType;
35
+ readonly agentVersion: StringType;
36
+ }>;
37
+ }>;
38
+ export type RackEnrollRequest = ValueTypeOf<typeof RackEnrollRequestType>;
39
+ /**
40
+ * POST /rack/enroll response — the generated rack identity and its
41
+ * bearer credential. The token is shown exactly once and stored hashed
42
+ * at rest server-side; the agent persists it mode 0600.
43
+ */
44
+ export declare const RackEnrollResponseType: StructType<{
45
+ readonly rackId: StringType;
46
+ readonly rackToken: StringType;
47
+ }>;
48
+ export type RackEnrollResponse = ValueTypeOf<typeof RackEnrollResponseType>;
49
+ /** A (repo, leaseId) reference — leases are partitioned per repo. */
50
+ export declare const RackLeaseRefType: StructType<{
51
+ readonly repo: StringType;
52
+ readonly leaseId: StringType;
53
+ }>;
54
+ export type RackLeaseRef = ValueTypeOf<typeof RackLeaseRefType>;
55
+ /**
56
+ * POST /rack/lease request — long-poll for the next claimable task
57
+ * matching any of the agent's tiers. `bootId` declares WHICH process
58
+ * lifetime is asking: under `requireStartApproval` only the approved boot
59
+ * receives grants, checked against the request itself so no heartbeat
60
+ * ordering can leak a lease to an unapproved restart (D12, #90).
61
+ */
62
+ export declare const RackLeaseRequestType: StructType<{
63
+ readonly tiers: ArrayType<StringType>;
64
+ readonly bootId: StringType;
65
+ }>;
66
+ export type RackLeaseRequest = ValueTypeOf<typeof RackLeaseRequestType>;
67
+ /**
68
+ * A granted lease. `eventJson` carries the lease's event (e3-cloud-core's
69
+ * `RackLeaseEvent`, v2 since elaraai/e3-cloud#214) as JSON: the runner
70
+ * containers' v2 event (#205) the guest runs, the runtime version, and the
71
+ * lease's closure. The agent must extend visibility before
72
+ * `visibilityDeadline` or the lease becomes reclaimable.
73
+ */
74
+ export declare const RackLeaseGrantType: StructType<{
75
+ readonly repo: StringType;
76
+ readonly workspace: StringType;
77
+ readonly leaseId: StringType;
78
+ readonly tier: StringType;
79
+ /** Compute size tag -> the agent's VM shape (serverless when unset upstream). */
80
+ readonly computeSize: StringType;
81
+ readonly eventJson: StringType;
82
+ readonly visibilityDeadline: DateTimeType;
83
+ }>;
84
+ export type RackLeaseGrant = ValueTypeOf<typeof RackLeaseGrantType>;
85
+ /**
86
+ * POST /rack/heartbeat request — liveness + running work, every ~15 s.
87
+ * `bootId` (D12, #90) is a fresh uuid per agent process lifetime, the unit
88
+ * of start-approval quarantine. `cacheBytes` (RCK-D1, elaraai/e3-cloud#214)
89
+ * is what the agent's object cache holds after its last collection, which
90
+ * it runs after every lease and every 10 minutes; the cloud keeps none of
91
+ * it yet (a registration is a stored value: its shape grows only with a
92
+ * migration).
93
+ *
94
+ * The machine protocol evolves IN PLACE (pre-GA): a deployment and its
95
+ * racks update together. #80's drift check is the planned skew answer —
96
+ * a too-old binary gets "update required", never shape negotiation.
97
+ */
98
+ export declare const RackHeartbeatRequestType: StructType<{
99
+ readonly healthy: BooleanType;
100
+ readonly freeCapacity: IntegerType;
101
+ readonly runningLeases: ArrayType<StructType<{
102
+ readonly repo: StringType;
103
+ readonly leaseId: StringType;
104
+ }>>;
105
+ readonly agentVersion: StringType;
106
+ readonly bootId: StringType;
107
+ readonly cacheBytes: IntegerType;
108
+ }>;
109
+ export type RackHeartbeatRequest = ValueTypeOf<typeof RackHeartbeatRequestType>;
110
+ /**
111
+ * POST /rack/heartbeat response —
112
+ * - `stop`: leases the agent should stop working on (cancelled by an
113
+ * operator, or superseded because the runner fell back to cloud).
114
+ * This remains a backstop; /rack/lease/watch delivers prompt cancellation.
115
+ * - `rotatedToken` (D12, #90): a successor rack token (shown once, hashed
116
+ * at rest server-side). The agent persists it and switches; the old
117
+ * token stays valid until the successor's first use, then for a short
118
+ * grace window — a lost response never strands the agent, and a leaked
119
+ * token ages out with rotation.
120
+ * - `pendingApproval` (D12, #90): this boot is quarantined awaiting the
121
+ * fleet-table Approve (`requireStartApproval`); the agent keeps
122
+ * heartbeating but receives no leases.
123
+ */
124
+ export declare const RackHeartbeatResponseType: StructType<{
125
+ readonly stop: ArrayType<StructType<{
126
+ readonly repo: StringType;
127
+ readonly leaseId: StringType;
128
+ }>>;
129
+ readonly rotatedToken: OptionType<StringType>;
130
+ readonly pendingApproval: BooleanType;
131
+ }>;
132
+ export type RackHeartbeatResponse = ValueTypeOf<typeof RackHeartbeatResponseType>;
133
+ /** The most running leases one cancellation watch may name. */
134
+ export declare const RACK_WATCH_MAX_LEASES = 128;
135
+ /** POST /rack/lease/watch: hold a read-only request until named work must stop. */
136
+ export declare const RackWatchRequestType: StructType<{
137
+ readonly runningLeases: ArrayType<StructType<{
138
+ readonly repo: StringType;
139
+ readonly leaseId: StringType;
140
+ }>>;
141
+ }>;
142
+ export type RackWatchRequest = ValueTypeOf<typeof RackWatchRequestType>;
143
+ /** Cancellation notifications contain only references supplied by this caller. */
144
+ export declare const RackWatchResponseType: StructType<{
145
+ readonly stop: ArrayType<StructType<{
146
+ readonly repo: StringType;
147
+ readonly leaseId: StringType;
148
+ }>>;
149
+ }>;
150
+ export type RackWatchResponse = ValueTypeOf<typeof RackWatchResponseType>;
151
+ /** POST /rack/lease/extend request — refresh a running lease's visibility. */
152
+ export declare const RackExtendRequestType: StructType<{
153
+ readonly repo: StringType;
154
+ readonly leaseId: StringType;
155
+ }>;
156
+ export type RackExtendRequest = ValueTypeOf<typeof RackExtendRequestType>;
157
+ /**
158
+ * POST /rack/complete request — terminal result for a lease. `resultJson`
159
+ * carries the lease's result (e3-cloud-core's `RackLeaseResult`) as JSON.
160
+ *
161
+ * Output delivery (#74): a large output was already PUT via the presigned
162
+ * target — `outputUploadId` makes the server verify-and-commit it (SHA-256
163
+ * checked server-side; a tampered upload rejects the completion). A small
164
+ * (≤4 KB) output rides `inlineOutput` instead and the server writes it
165
+ * through the normal object-store normalization, computing the hash itself.
166
+ */
167
+ export declare const RackCompleteRequestType: StructType<{
168
+ readonly repo: StringType;
169
+ readonly leaseId: StringType;
170
+ readonly resultJson: StringType;
171
+ readonly outputUploadId: OptionType<StringType>;
172
+ readonly inlineOutput: OptionType<BlobType>;
173
+ }>;
174
+ export type RackCompleteRequest = ValueTypeOf<typeof RackCompleteRequestType>;
175
+ /** An object an agent declares or commits: its hash and size. */
176
+ export declare const RackObjectSizeType: StructType<{
177
+ readonly hash: StringType;
178
+ readonly size: IntegerType;
179
+ }>;
180
+ export type RackObjectSize = ValueTypeOf<typeof RackObjectSizeType>;
181
+ /** An object an agent PUT through a write target, and the version its PUT made. */
182
+ export declare const RackObjectCommitType: StructType<{
183
+ readonly hash: StringType;
184
+ readonly size: IntegerType;
185
+ readonly version: StringType;
186
+ }>;
187
+ export type RackObjectCommit = ValueTypeOf<typeof RackObjectCommitType>;
188
+ /**
189
+ * POST /rack/storage request — storage descriptors for a claimed lease
190
+ * (#74, #214):
191
+ * - `need` lists the object hashes the agent's content-addressed cache
192
+ * lacks; every one must be in the lease's closure (server-validated —
193
+ * review F5);
194
+ * - `output` declares a whole output for a staged PUT target (#210);
195
+ * - `outputs` declares objects the lease's guest wrote, each for a PUT target
196
+ * at its content address bound to its SHA-256 (#214);
197
+ * - `commits` names objects the agent PUT through those targets, and the
198
+ * versions its PUTs made, for the cloud to take in.
199
+ */
200
+ export declare const RackStorageRequestType: StructType<{
201
+ readonly repo: StringType;
202
+ readonly leaseId: StringType;
203
+ readonly need: ArrayType<StringType>;
204
+ readonly output: OptionType<StructType<{
205
+ readonly hash: StringType;
206
+ readonly size: IntegerType;
207
+ }>>;
208
+ /** #94 Slice B: environment hash to resolve published layers for. Must
209
+ * equal the lease's own declared environment (F5). */
210
+ readonly envManifest: OptionType<StringType>;
211
+ readonly outputs: ArrayType<StructType<{
212
+ readonly hash: StringType;
213
+ readonly size: IntegerType;
214
+ }>>;
215
+ readonly commits: ArrayType<StructType<{
216
+ readonly hash: StringType;
217
+ readonly size: IntegerType;
218
+ readonly version: StringType;
219
+ }>>;
220
+ }>;
221
+ export type RackStorageRequest = ValueTypeOf<typeof RackStorageRequestType>;
222
+ /**
223
+ * One object descriptor: small (≤4 KB) objects live in DynamoDB and are
224
+ * carried inline; large objects get a presigned S3 GET.
225
+ */
226
+ export declare const RackObjectDescriptorType: VariantType<{
227
+ readonly inline: StructType<{
228
+ readonly hash: StringType;
229
+ readonly data: BlobType;
230
+ }>;
231
+ readonly url: StructType<{
232
+ readonly hash: StringType;
233
+ readonly url: StringType;
234
+ }>;
235
+ }>;
236
+ export type RackObjectDescriptor = ValueTypeOf<typeof RackObjectDescriptorType>;
237
+ /** One published env layer: content digest + presigned GET (#94). */
238
+ export declare const RackEnvLayerType: StructType<{
239
+ readonly digest: StringType;
240
+ readonly url: StringType;
241
+ readonly sizeBytes: IntegerType;
242
+ }>;
243
+ /**
244
+ * Where an object a lease's guest wrote goes (#214): nowhere, when the store
245
+ * holds it already (`held`), or a PUT at its content address, whose headers
246
+ * the agent sends as given: they are signed into its URL.
247
+ */
248
+ export declare const RackWriteTargetType: VariantType<{
249
+ readonly held: NullType;
250
+ readonly put: StructType<{
251
+ readonly url: StringType;
252
+ readonly headers: DictType<StringType, StringType>;
253
+ }>;
254
+ }>;
255
+ export type RackWriteTarget = ValueTypeOf<typeof RackWriteTargetType>;
256
+ /** POST /rack/storage response. */
257
+ export declare const RackStorageResponseType: StructType<{
258
+ readonly objects: ArrayType<VariantType<{
259
+ readonly inline: StructType<{
260
+ readonly hash: StringType;
261
+ readonly data: BlobType;
262
+ }>;
263
+ readonly url: StructType<{
264
+ readonly hash: StringType;
265
+ readonly url: StringType;
266
+ }>;
267
+ }>>;
268
+ readonly output: OptionType<StructType<{
269
+ readonly url: StringType;
270
+ readonly uploadId: StringType;
271
+ }>>;
272
+ /** #94 Slice B: the env's published manifest (small JSON, inline) plus a
273
+ * presigned GET per delta layer — set iff `envManifest` was requested
274
+ * and the env is published. */
275
+ readonly env: OptionType<StructType<{
276
+ readonly manifestJson: StringType;
277
+ readonly layers: ArrayType<StructType<{
278
+ readonly digest: StringType;
279
+ readonly url: StringType;
280
+ readonly sizeBytes: IntegerType;
281
+ }>>;
282
+ }>>;
283
+ /** Each declared output's target, in the order declared */
284
+ readonly targets: ArrayType<StructType<{
285
+ readonly hash: StringType;
286
+ readonly target: VariantType<{
287
+ readonly held: NullType;
288
+ readonly put: StructType<{
289
+ readonly url: StringType;
290
+ readonly headers: DictType<StringType, StringType>;
291
+ }>;
292
+ }>;
293
+ }>>;
294
+ /** Whether each commit was taken in, in the order named */
295
+ readonly committed: ArrayType<StructType<{
296
+ readonly hash: StringType;
297
+ readonly committed: BooleanType;
298
+ }>>;
299
+ }>;
300
+ export type RackStorageResponse = ValueTypeOf<typeof RackStorageResponseType>;
301
+ export type RackEnvLayer = ValueTypeOf<typeof RackEnvLayerType>;
302
+ /** One streamed log chunk (agent batches ≥1 s or ≥32 KB per POST). */
303
+ export declare const RackLogChunkType: StructType<{
304
+ readonly stream: VariantType<{
305
+ readonly stdout: NullType;
306
+ readonly stderr: NullType;
307
+ }>;
308
+ readonly data: StringType;
309
+ }>;
310
+ export type RackLogChunk = ValueTypeOf<typeof RackLogChunkType>;
311
+ /** POST /rack/logs request — batched stdout/stderr for a claimed lease. */
312
+ export declare const RackLogsRequestType: StructType<{
313
+ readonly repo: StringType;
314
+ readonly leaseId: StringType;
315
+ readonly chunks: ArrayType<StructType<{
316
+ readonly stream: VariantType<{
317
+ readonly stdout: NullType;
318
+ readonly stderr: NullType;
319
+ }>;
320
+ readonly data: StringType;
321
+ }>>;
322
+ }>;
323
+ export type RackLogsRequest = ValueTypeOf<typeof RackLogsRequestType>;
324
+ /**
325
+ * POST /rack/complete response — accepted-and-discarded semantics:
326
+ * - recorded: the result landed; the runner will pick it up
327
+ * - idempotent: the lease was already completed (retry) — all good
328
+ * - discarded: the lease was superseded/cancelled/reclaimed; the agent
329
+ * drops local state and moves on (never an error)
330
+ */
331
+ export declare const RackCompleteResponseType: StructType<{
332
+ readonly disposition: VariantType<{
333
+ readonly recorded: NullType;
334
+ readonly idempotent: NullType;
335
+ readonly discarded: NullType;
336
+ }>;
337
+ }>;
338
+ export type RackCompleteResponse = ValueTypeOf<typeof RackCompleteResponseType>;
339
+ /**
340
+ * The oldest rack agent the cloud leases work to (elaraai/e3-cloud#214): one
341
+ * whose guest runs e3-core's own execution over its lease's staged closure,
342
+ * and reads the v2 lease event, which names the runtime its work was built
343
+ * with (#189). It subsumes the environment (0.3.0) and function (0.4.0)
344
+ * capability gates. An older agent is refused at lease time and told to
345
+ * upgrade; its work runs in the cloud.
346
+ */
347
+ export declare const LEASE_MIN_AGENT = "0.5.0";
348
+ /**
349
+ * Whether an agent version is at least another, under dotted-numeric semver:
350
+ * pre-release and build suffixes are ignored, only the numeric core compared.
351
+ *
352
+ * @param version - The agent's version, as its registration reports it
353
+ * @param min - The least version
354
+ * @returns Whether `version` is `min` or later
355
+ */
356
+ export declare function agentVersionAtLeast(version: string, min: string): boolean;
357
+ //# sourceMappingURL=rack-wire.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rack-wire.d.ts","sourceRoot":"","sources":["../../../src/protocol/rack-wire.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,EACX,KAAK,WAAW,EACjB,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;;;EAK3B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;EAGhC,CAAC;AACH,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;EAGjC,CAAC;AACH,M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C,OAAO,gBAAgB,CAAC,CAAC;AAEhE,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB;;;;;;;;;;EAI9B,CAAC;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;;;;;;EAMnC,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAEhF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAUzE"}
@@ -0,0 +1,262 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ /**
6
+ * Rack machine-protocol wire types (epic #67 design §9) — the BEAST2 bodies
7
+ * exchanged between a rack agent and the deployment's /api/rack endpoints.
8
+ * Shared by the server routes (e3-cloud-core), the HTTP client, and the
9
+ * rack agent, so the shapes live here beside the delegation types.
10
+ */
11
+ import { ArrayType, BlobType, BooleanType, DateTimeType, DictType, IntegerType, NullType, OptionType, StringType, StructType, VariantType, } from '@elaraai/east';
12
+ /**
13
+ * What an enrolling agent declares about its host: the operator-facing
14
+ * label, the runner tiers it has rootfs images for (node | py |
15
+ * py-datascience | c | full — the #57 vocabulary), its max concurrent
16
+ * microVMs, and the agent build it runs.
17
+ */
18
+ export const RackHostInfoType = StructType({
19
+ label: StringType,
20
+ tiers: ArrayType(StringType),
21
+ capacity: IntegerType,
22
+ agentVersion: StringType,
23
+ });
24
+ /**
25
+ * POST /rack/enroll request — exchanges a single-use enrollment token
26
+ * (minted by an admin in the UI) for a long-lived rack credential.
27
+ */
28
+ export const RackEnrollRequestType = StructType({
29
+ enrollmentToken: StringType,
30
+ hostInfo: RackHostInfoType,
31
+ });
32
+ /**
33
+ * POST /rack/enroll response — the generated rack identity and its
34
+ * bearer credential. The token is shown exactly once and stored hashed
35
+ * at rest server-side; the agent persists it mode 0600.
36
+ */
37
+ export const RackEnrollResponseType = StructType({
38
+ rackId: StringType,
39
+ rackToken: StringType,
40
+ });
41
+ /** A (repo, leaseId) reference — leases are partitioned per repo. */
42
+ export const RackLeaseRefType = StructType({
43
+ repo: StringType,
44
+ leaseId: StringType,
45
+ });
46
+ /**
47
+ * POST /rack/lease request — long-poll for the next claimable task
48
+ * matching any of the agent's tiers. `bootId` declares WHICH process
49
+ * lifetime is asking: under `requireStartApproval` only the approved boot
50
+ * receives grants, checked against the request itself so no heartbeat
51
+ * ordering can leak a lease to an unapproved restart (D12, #90).
52
+ */
53
+ export const RackLeaseRequestType = StructType({
54
+ tiers: ArrayType(StringType),
55
+ bootId: StringType,
56
+ });
57
+ /**
58
+ * A granted lease. `eventJson` carries the lease's event (e3-cloud-core's
59
+ * `RackLeaseEvent`, v2 since elaraai/e3-cloud#214) as JSON: the runner
60
+ * containers' v2 event (#205) the guest runs, the runtime version, and the
61
+ * lease's closure. The agent must extend visibility before
62
+ * `visibilityDeadline` or the lease becomes reclaimable.
63
+ */
64
+ export const RackLeaseGrantType = StructType({
65
+ repo: StringType,
66
+ workspace: StringType,
67
+ leaseId: StringType,
68
+ tier: StringType,
69
+ /** Compute size tag -> the agent's VM shape (serverless when unset upstream). */
70
+ computeSize: StringType,
71
+ eventJson: StringType,
72
+ visibilityDeadline: DateTimeType,
73
+ });
74
+ /**
75
+ * POST /rack/heartbeat request — liveness + running work, every ~15 s.
76
+ * `bootId` (D12, #90) is a fresh uuid per agent process lifetime, the unit
77
+ * of start-approval quarantine. `cacheBytes` (RCK-D1, elaraai/e3-cloud#214)
78
+ * is what the agent's object cache holds after its last collection, which
79
+ * it runs after every lease and every 10 minutes; the cloud keeps none of
80
+ * it yet (a registration is a stored value: its shape grows only with a
81
+ * migration).
82
+ *
83
+ * The machine protocol evolves IN PLACE (pre-GA): a deployment and its
84
+ * racks update together. #80's drift check is the planned skew answer —
85
+ * a too-old binary gets "update required", never shape negotiation.
86
+ */
87
+ export const RackHeartbeatRequestType = StructType({
88
+ healthy: BooleanType,
89
+ freeCapacity: IntegerType,
90
+ runningLeases: ArrayType(RackLeaseRefType),
91
+ agentVersion: StringType,
92
+ bootId: StringType,
93
+ cacheBytes: IntegerType,
94
+ });
95
+ /**
96
+ * POST /rack/heartbeat response —
97
+ * - `stop`: leases the agent should stop working on (cancelled by an
98
+ * operator, or superseded because the runner fell back to cloud).
99
+ * This remains a backstop; /rack/lease/watch delivers prompt cancellation.
100
+ * - `rotatedToken` (D12, #90): a successor rack token (shown once, hashed
101
+ * at rest server-side). The agent persists it and switches; the old
102
+ * token stays valid until the successor's first use, then for a short
103
+ * grace window — a lost response never strands the agent, and a leaked
104
+ * token ages out with rotation.
105
+ * - `pendingApproval` (D12, #90): this boot is quarantined awaiting the
106
+ * fleet-table Approve (`requireStartApproval`); the agent keeps
107
+ * heartbeating but receives no leases.
108
+ */
109
+ export const RackHeartbeatResponseType = StructType({
110
+ stop: ArrayType(RackLeaseRefType),
111
+ rotatedToken: OptionType(StringType),
112
+ pendingApproval: BooleanType,
113
+ });
114
+ /** The most running leases one cancellation watch may name. */
115
+ export const RACK_WATCH_MAX_LEASES = 128;
116
+ /** POST /rack/lease/watch: hold a read-only request until named work must stop. */
117
+ export const RackWatchRequestType = StructType({
118
+ runningLeases: ArrayType(RackLeaseRefType),
119
+ });
120
+ /** Cancellation notifications contain only references supplied by this caller. */
121
+ export const RackWatchResponseType = StructType({
122
+ stop: ArrayType(RackLeaseRefType),
123
+ });
124
+ /** POST /rack/lease/extend request — refresh a running lease's visibility. */
125
+ export const RackExtendRequestType = StructType({
126
+ repo: StringType,
127
+ leaseId: StringType,
128
+ });
129
+ /**
130
+ * POST /rack/complete request — terminal result for a lease. `resultJson`
131
+ * carries the lease's result (e3-cloud-core's `RackLeaseResult`) as JSON.
132
+ *
133
+ * Output delivery (#74): a large output was already PUT via the presigned
134
+ * target — `outputUploadId` makes the server verify-and-commit it (SHA-256
135
+ * checked server-side; a tampered upload rejects the completion). A small
136
+ * (≤4 KB) output rides `inlineOutput` instead and the server writes it
137
+ * through the normal object-store normalization, computing the hash itself.
138
+ */
139
+ export const RackCompleteRequestType = StructType({
140
+ repo: StringType,
141
+ leaseId: StringType,
142
+ resultJson: StringType,
143
+ outputUploadId: OptionType(StringType),
144
+ inlineOutput: OptionType(BlobType),
145
+ });
146
+ /** An object an agent declares or commits: its hash and size. */
147
+ export const RackObjectSizeType = StructType({ hash: StringType, size: IntegerType });
148
+ /** An object an agent PUT through a write target, and the version its PUT made. */
149
+ export const RackObjectCommitType = StructType({ hash: StringType, size: IntegerType, version: StringType });
150
+ /**
151
+ * POST /rack/storage request — storage descriptors for a claimed lease
152
+ * (#74, #214):
153
+ * - `need` lists the object hashes the agent's content-addressed cache
154
+ * lacks; every one must be in the lease's closure (server-validated —
155
+ * review F5);
156
+ * - `output` declares a whole output for a staged PUT target (#210);
157
+ * - `outputs` declares objects the lease's guest wrote, each for a PUT target
158
+ * at its content address bound to its SHA-256 (#214);
159
+ * - `commits` names objects the agent PUT through those targets, and the
160
+ * versions its PUTs made, for the cloud to take in.
161
+ */
162
+ export const RackStorageRequestType = StructType({
163
+ repo: StringType,
164
+ leaseId: StringType,
165
+ need: ArrayType(StringType),
166
+ output: OptionType(RackObjectSizeType),
167
+ /** #94 Slice B: environment hash to resolve published layers for. Must
168
+ * equal the lease's own declared environment (F5). */
169
+ envManifest: OptionType(StringType),
170
+ outputs: ArrayType(RackObjectSizeType),
171
+ commits: ArrayType(RackObjectCommitType),
172
+ });
173
+ /**
174
+ * One object descriptor: small (≤4 KB) objects live in DynamoDB and are
175
+ * carried inline; large objects get a presigned S3 GET.
176
+ */
177
+ export const RackObjectDescriptorType = VariantType({
178
+ inline: StructType({ hash: StringType, data: BlobType }),
179
+ url: StructType({ hash: StringType, url: StringType }),
180
+ });
181
+ /** One published env layer: content digest + presigned GET (#94). */
182
+ export const RackEnvLayerType = StructType({
183
+ digest: StringType,
184
+ url: StringType,
185
+ sizeBytes: IntegerType,
186
+ });
187
+ /**
188
+ * Where an object a lease's guest wrote goes (#214): nowhere, when the store
189
+ * holds it already (`held`), or a PUT at its content address, whose headers
190
+ * the agent sends as given: they are signed into its URL.
191
+ */
192
+ export const RackWriteTargetType = VariantType({
193
+ held: NullType,
194
+ put: StructType({ url: StringType, headers: DictType(StringType, StringType) }),
195
+ });
196
+ /** POST /rack/storage response. */
197
+ export const RackStorageResponseType = StructType({
198
+ objects: ArrayType(RackObjectDescriptorType),
199
+ output: OptionType(StructType({ url: StringType, uploadId: StringType })),
200
+ /** #94 Slice B: the env's published manifest (small JSON, inline) plus a
201
+ * presigned GET per delta layer — set iff `envManifest` was requested
202
+ * and the env is published. */
203
+ env: OptionType(StructType({ manifestJson: StringType, layers: ArrayType(RackEnvLayerType) })),
204
+ /** Each declared output's target, in the order declared */
205
+ targets: ArrayType(StructType({ hash: StringType, target: RackWriteTargetType })),
206
+ /** Whether each commit was taken in, in the order named */
207
+ committed: ArrayType(StructType({ hash: StringType, committed: BooleanType })),
208
+ });
209
+ /** One streamed log chunk (agent batches ≥1 s or ≥32 KB per POST). */
210
+ export const RackLogChunkType = StructType({
211
+ stream: VariantType({ stdout: NullType, stderr: NullType }),
212
+ data: StringType,
213
+ });
214
+ /** POST /rack/logs request — batched stdout/stderr for a claimed lease. */
215
+ export const RackLogsRequestType = StructType({
216
+ repo: StringType,
217
+ leaseId: StringType,
218
+ chunks: ArrayType(RackLogChunkType),
219
+ });
220
+ /**
221
+ * POST /rack/complete response — accepted-and-discarded semantics:
222
+ * - recorded: the result landed; the runner will pick it up
223
+ * - idempotent: the lease was already completed (retry) — all good
224
+ * - discarded: the lease was superseded/cancelled/reclaimed; the agent
225
+ * drops local state and moves on (never an error)
226
+ */
227
+ export const RackCompleteResponseType = StructType({
228
+ disposition: VariantType({
229
+ recorded: NullType,
230
+ idempotent: NullType,
231
+ discarded: NullType,
232
+ }),
233
+ });
234
+ /**
235
+ * The oldest rack agent the cloud leases work to (elaraai/e3-cloud#214): one
236
+ * whose guest runs e3-core's own execution over its lease's staged closure,
237
+ * and reads the v2 lease event, which names the runtime its work was built
238
+ * with (#189). It subsumes the environment (0.3.0) and function (0.4.0)
239
+ * capability gates. An older agent is refused at lease time and told to
240
+ * upgrade; its work runs in the cloud.
241
+ */
242
+ export const LEASE_MIN_AGENT = '0.5.0';
243
+ /**
244
+ * Whether an agent version is at least another, under dotted-numeric semver:
245
+ * pre-release and build suffixes are ignored, only the numeric core compared.
246
+ *
247
+ * @param version - The agent's version, as its registration reports it
248
+ * @param min - The least version
249
+ * @returns Whether `version` is `min` or later
250
+ */
251
+ export function agentVersionAtLeast(version, min) {
252
+ const core = (v) => (v.split(/[-+]/)[0] ?? '').split('.').map((n) => parseInt(n, 10) || 0);
253
+ const a = core(version);
254
+ const b = core(min);
255
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
256
+ const d = (a[i] ?? 0) - (b[i] ?? 0);
257
+ if (d !== 0)
258
+ return d > 0;
259
+ }
260
+ return true; // equal
261
+ }
262
+ //# sourceMappingURL=rack-wire.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rack-wire.js","sourceRoot":"","sources":["../../../src/protocol/rack-wire.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;GAKG;AAEH,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,WAAW,GAEZ,MAAM,eAAe,CAAC;AAEvB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC;IACzC,KAAK,EAAE,UAAU;IACjB,KAAK,EAAE,SAAS,CAAC,UAAU,CAAC;IAC5B,QAAQ,EAAE,WAAW;IACrB,YAAY,EAAE,UAAU;CACz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CAAC,CAAC,CAAC;IACzE,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACtD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,IAAI,CAAC,CAAC,QAAQ;AACvB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=rack-wire.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rack-wire.spec.d.ts","sourceRoot":"","sources":["../../../src/protocol/rack-wire.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Licensed under BSL 1.1. See LICENSE for details.
4
+ */
5
+ import { it } from 'node:test';
6
+ import assert from 'node:assert/strict';
7
+ import { wireSamples } from './wire-samples.js';
8
+ import { wireGolden } from './wire-golden.js';
9
+ for (const sample of wireSamples) {
10
+ it(`encodes ${sample.name} identically to its e3-cloud protocol fixture`, () => {
11
+ assert.equal(Buffer.from(sample.encode()).toString('hex'), wireGolden[sample.name]);
12
+ });
13
+ }
14
+ //# sourceMappingURL=rack-wire.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rack-wire.spec.js","sourceRoot":"","sources":["../../../src/protocol/rack-wire.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AAC/B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE,CAAC;IACjC,EAAE,CAAC,WAAW,MAAM,CAAC,IAAI,+CAA+C,EAAE,GAAG,EAAE;QAC7E,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACtF,CAAC,CAAC,CAAC;AACL,CAAC"}