@aephia/atlas-kit 0.6.0-next.8 → 0.6.0-next.81

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 (540) hide show
  1. package/README.md +3 -1
  2. package/dist/cargo/actions/deposit.d.ts +1 -1
  3. package/dist/cargo/actions/deposit.d.ts.map +1 -1
  4. package/dist/cargo/actions/deposit.js +25 -12
  5. package/dist/cargo/actions/deposit.js.map +1 -1
  6. package/dist/cargo/actions/index.d.ts.map +1 -1
  7. package/dist/cargo/actions/index.js +3 -2
  8. package/dist/cargo/actions/index.js.map +1 -1
  9. package/dist/cargo/actions/wallet-token.d.ts +1 -1
  10. package/dist/cargo/actions/wallet-token.d.ts.map +1 -1
  11. package/dist/cargo/actions/wallet-token.js +1 -9
  12. package/dist/cargo/actions/wallet-token.js.map +1 -1
  13. package/dist/cargo/actions/withdrawal.d.ts.map +1 -1
  14. package/dist/cargo/actions/withdrawal.js +22 -10
  15. package/dist/cargo/actions/withdrawal.js.map +1 -1
  16. package/dist/claim-stakes/actions/index.d.ts +13 -0
  17. package/dist/claim-stakes/actions/index.d.ts.map +1 -1
  18. package/dist/claim-stakes/actions/index.js +95 -44
  19. package/dist/claim-stakes/actions/index.js.map +1 -1
  20. package/dist/claim-stakes/index.d.ts +14 -0
  21. package/dist/claim-stakes/index.d.ts.map +1 -1
  22. package/dist/claim-stakes/index.js +23 -2
  23. package/dist/claim-stakes/index.js.map +1 -1
  24. package/dist/client/context.d.ts.map +1 -1
  25. package/dist/client/context.js +1 -1
  26. package/dist/client/context.js.map +1 -1
  27. package/dist/client/contracts.d.ts +16 -6
  28. package/dist/client/contracts.d.ts.map +1 -1
  29. package/dist/client/errors.d.ts +6 -2
  30. package/dist/client/errors.d.ts.map +1 -1
  31. package/dist/client/errors.js +31 -1
  32. package/dist/client/errors.js.map +1 -1
  33. package/dist/client/index.d.ts +1 -0
  34. package/dist/client/index.d.ts.map +1 -1
  35. package/dist/client/index.js +1 -0
  36. package/dist/client/index.js.map +1 -1
  37. package/dist/client/rpc-subscription-provider.d.ts +35 -0
  38. package/dist/client/rpc-subscription-provider.d.ts.map +1 -0
  39. package/dist/client/rpc-subscription-provider.js +190 -0
  40. package/dist/client/rpc-subscription-provider.js.map +1 -0
  41. package/dist/combat/actions/index.d.ts.map +1 -1
  42. package/dist/combat/actions/index.js +98 -50
  43. package/dist/combat/actions/index.js.map +1 -1
  44. package/dist/crafting/actions/index.d.ts +11 -0
  45. package/dist/crafting/actions/index.d.ts.map +1 -1
  46. package/dist/crafting/actions/index.js +60 -29
  47. package/dist/crafting/actions/index.js.map +1 -1
  48. package/dist/crafting/index.d.ts +31 -2
  49. package/dist/crafting/index.d.ts.map +1 -1
  50. package/dist/crafting/index.js +41 -14
  51. package/dist/crafting/index.js.map +1 -1
  52. package/dist/factions/actions/index.d.ts +1 -0
  53. package/dist/factions/actions/index.d.ts.map +1 -1
  54. package/dist/factions/actions/index.js.map +1 -1
  55. package/dist/factions/index.d.ts +1 -1
  56. package/dist/factions/index.d.ts.map +1 -1
  57. package/dist/factions/index.js +14 -8
  58. package/dist/factions/index.js.map +1 -1
  59. package/dist/factions/profile-faction.d.ts +20 -8
  60. package/dist/factions/profile-faction.d.ts.map +1 -1
  61. package/dist/factions/profile-faction.js +20 -8
  62. package/dist/factions/profile-faction.js.map +1 -1
  63. package/dist/fleets/actions/add-ship.d.ts +35 -0
  64. package/dist/fleets/actions/add-ship.d.ts.map +1 -0
  65. package/dist/fleets/actions/add-ship.js +149 -0
  66. package/dist/fleets/actions/add-ship.js.map +1 -0
  67. package/dist/fleets/actions/create-fleet.d.ts +36 -0
  68. package/dist/fleets/actions/create-fleet.d.ts.map +1 -0
  69. package/dist/fleets/actions/create-fleet.js +138 -0
  70. package/dist/fleets/actions/create-fleet.js.map +1 -0
  71. package/dist/fleets/actions/crew-transfer.d.ts +41 -0
  72. package/dist/fleets/actions/crew-transfer.d.ts.map +1 -0
  73. package/dist/fleets/actions/crew-transfer.js +114 -0
  74. package/dist/fleets/actions/crew-transfer.js.map +1 -0
  75. package/dist/fleets/actions/index.d.ts +33 -15
  76. package/dist/fleets/actions/index.d.ts.map +1 -1
  77. package/dist/fleets/actions/index.js +168 -110
  78. package/dist/fleets/actions/index.js.map +1 -1
  79. package/dist/fleets/actions/respawn.d.ts +38 -0
  80. package/dist/fleets/actions/respawn.d.ts.map +1 -0
  81. package/dist/fleets/actions/respawn.js +122 -0
  82. package/dist/fleets/actions/respawn.js.map +1 -0
  83. package/dist/fleets/actions/ship-import.d.ts.map +1 -1
  84. package/dist/fleets/actions/ship-import.js +37 -11
  85. package/dist/fleets/actions/ship-import.js.map +1 -1
  86. package/dist/fleets/cooldown.d.ts +44 -0
  87. package/dist/fleets/cooldown.d.ts.map +1 -0
  88. package/dist/fleets/cooldown.js +43 -0
  89. package/dist/fleets/cooldown.js.map +1 -0
  90. package/dist/fleets/coordinate-warp-estimate.d.ts +70 -0
  91. package/dist/fleets/coordinate-warp-estimate.d.ts.map +1 -0
  92. package/dist/fleets/coordinate-warp-estimate.js +46 -0
  93. package/dist/fleets/coordinate-warp-estimate.js.map +1 -0
  94. package/dist/fleets/index.d.ts +34 -0
  95. package/dist/fleets/index.d.ts.map +1 -1
  96. package/dist/fleets/index.js +51 -2
  97. package/dist/fleets/index.js.map +1 -1
  98. package/dist/fleets/movement-arithmetic.d.ts +21 -0
  99. package/dist/fleets/movement-arithmetic.d.ts.map +1 -0
  100. package/dist/fleets/movement-arithmetic.js +41 -0
  101. package/dist/fleets/movement-arithmetic.js.map +1 -0
  102. package/dist/fleets/subwarp-estimate.d.ts +70 -0
  103. package/dist/fleets/subwarp-estimate.d.ts.map +1 -0
  104. package/dist/fleets/subwarp-estimate.js +38 -0
  105. package/dist/fleets/subwarp-estimate.js.map +1 -0
  106. package/dist/fleets/warp-lane-estimate.d.ts +59 -0
  107. package/dist/fleets/warp-lane-estimate.d.ts.map +1 -0
  108. package/dist/fleets/warp-lane-estimate.js +36 -0
  109. package/dist/fleets/warp-lane-estimate.js.map +1 -0
  110. package/dist/fleets/warp-lane-policy.d.ts +68 -0
  111. package/dist/fleets/warp-lane-policy.d.ts.map +1 -0
  112. package/dist/fleets/warp-lane-policy.js +91 -0
  113. package/dist/fleets/warp-lane-policy.js.map +1 -0
  114. package/dist/fleets/warp-lane-toll.d.ts +55 -0
  115. package/dist/fleets/warp-lane-toll.d.ts.map +1 -0
  116. package/dist/fleets/warp-lane-toll.js +79 -0
  117. package/dist/fleets/warp-lane-toll.js.map +1 -0
  118. package/dist/identity/actions/create-profile.d.ts +56 -0
  119. package/dist/identity/actions/create-profile.d.ts.map +1 -0
  120. package/dist/identity/actions/create-profile.js +139 -0
  121. package/dist/identity/actions/create-profile.js.map +1 -0
  122. package/dist/identity/actions/index.d.ts +4 -3
  123. package/dist/identity/actions/index.d.ts.map +1 -1
  124. package/dist/identity/actions/index.js +49 -27
  125. package/dist/identity/actions/index.js.map +1 -1
  126. package/dist/identity/index.d.ts +15 -0
  127. package/dist/identity/index.d.ts.map +1 -1
  128. package/dist/identity/index.js +15 -0
  129. package/dist/identity/index.js.map +1 -1
  130. package/dist/identity/permissions.d.ts +124 -0
  131. package/dist/identity/permissions.d.ts.map +1 -0
  132. package/dist/identity/permissions.js +171 -0
  133. package/dist/identity/permissions.js.map +1 -0
  134. package/dist/index.d.ts +24 -0
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +20 -3
  137. package/dist/index.js.map +1 -1
  138. package/dist/internal/c4/cargo-bytes-config.d.ts +7 -0
  139. package/dist/internal/c4/cargo-bytes-config.d.ts.map +1 -0
  140. package/dist/internal/c4/cargo-bytes-config.js +19 -0
  141. package/dist/internal/c4/cargo-bytes-config.js.map +1 -0
  142. package/dist/internal/c4/character-registration.d.ts +2 -0
  143. package/dist/internal/c4/character-registration.d.ts.map +1 -1
  144. package/dist/internal/c4/character-registration.js +2 -0
  145. package/dist/internal/c4/character-registration.js.map +1 -1
  146. package/dist/internal/c4/claim-stake.d.ts +4 -27
  147. package/dist/internal/c4/claim-stake.d.ts.map +1 -1
  148. package/dist/internal/c4/claim-stake.js +25 -38
  149. package/dist/internal/c4/claim-stake.js.map +1 -1
  150. package/dist/internal/c4/combat.d.ts +0 -27
  151. package/dist/internal/c4/combat.d.ts.map +1 -1
  152. package/dist/internal/c4/combat.js +0 -33
  153. package/dist/internal/c4/combat.js.map +1 -1
  154. package/dist/internal/c4/crafting-process-codec.d.ts +13 -0
  155. package/dist/internal/c4/crafting-process-codec.d.ts.map +1 -0
  156. package/dist/internal/c4/crafting-process-codec.js +34 -0
  157. package/dist/internal/c4/crafting-process-codec.js.map +1 -0
  158. package/dist/internal/c4/crafting.d.ts +11 -31
  159. package/dist/internal/c4/crafting.d.ts.map +1 -1
  160. package/dist/internal/c4/crafting.js +26 -43
  161. package/dist/internal/c4/crafting.js.map +1 -1
  162. package/dist/internal/c4/faction-adapter.d.ts +12 -0
  163. package/dist/internal/c4/faction-adapter.d.ts.map +1 -0
  164. package/dist/internal/c4/faction-adapter.js +52 -0
  165. package/dist/internal/c4/faction-adapter.js.map +1 -0
  166. package/dist/internal/c4/faction-epoch-meter.d.ts +10 -0
  167. package/dist/internal/c4/faction-epoch-meter.d.ts.map +1 -0
  168. package/dist/internal/c4/faction-epoch-meter.js +31 -0
  169. package/dist/internal/c4/faction-epoch-meter.js.map +1 -0
  170. package/dist/internal/c4/faction-treasury.d.ts +23 -0
  171. package/dist/internal/c4/faction-treasury.d.ts.map +1 -0
  172. package/dist/internal/c4/faction-treasury.js +48 -0
  173. package/dist/internal/c4/faction-treasury.js.map +1 -0
  174. package/dist/internal/c4/factions.d.ts +9 -57
  175. package/dist/internal/c4/factions.d.ts.map +1 -1
  176. package/dist/internal/c4/factions.js +21 -139
  177. package/dist/internal/c4/factions.js.map +1 -1
  178. package/dist/internal/c4/fleet-arrival.d.ts +28 -0
  179. package/dist/internal/c4/fleet-arrival.d.ts.map +1 -0
  180. package/dist/internal/c4/fleet-arrival.js +42 -0
  181. package/dist/internal/c4/fleet-arrival.js.map +1 -0
  182. package/dist/internal/c4/fleet-creation.d.ts +7 -0
  183. package/dist/internal/c4/fleet-creation.d.ts.map +1 -0
  184. package/dist/internal/c4/fleet-creation.js +180 -0
  185. package/dist/internal/c4/fleet-creation.js.map +1 -0
  186. package/dist/internal/c4/fleet-crew-binding.d.ts +9 -0
  187. package/dist/internal/c4/fleet-crew-binding.d.ts.map +1 -1
  188. package/dist/internal/c4/fleet-crew-binding.js +15 -0
  189. package/dist/internal/c4/fleet-crew-binding.js.map +1 -1
  190. package/dist/internal/c4/fleet-respawn.d.ts +19 -0
  191. package/dist/internal/c4/fleet-respawn.d.ts.map +1 -0
  192. package/dist/internal/c4/fleet-respawn.js +91 -0
  193. package/dist/internal/c4/fleet-respawn.js.map +1 -0
  194. package/dist/internal/c4/fleet-ship-assembly.d.ts +11 -0
  195. package/dist/internal/c4/fleet-ship-assembly.d.ts.map +1 -0
  196. package/dist/internal/c4/fleet-ship-assembly.js +44 -0
  197. package/dist/internal/c4/fleet-ship-assembly.js.map +1 -0
  198. package/dist/internal/c4/fleet.d.ts +45 -19
  199. package/dist/internal/c4/fleet.d.ts.map +1 -1
  200. package/dist/internal/c4/fleet.js +26 -7
  201. package/dist/internal/c4/fleet.js.map +1 -1
  202. package/dist/internal/c4/game.d.ts +27 -9
  203. package/dist/internal/c4/game.d.ts.map +1 -1
  204. package/dist/internal/c4/game.js +77 -14
  205. package/dist/internal/c4/game.js.map +1 -1
  206. package/dist/internal/c4/identity.d.ts +4 -8
  207. package/dist/internal/c4/identity.d.ts.map +1 -1
  208. package/dist/internal/c4/identity.js +3 -24
  209. package/dist/internal/c4/identity.js.map +1 -1
  210. package/dist/internal/c4/local-market-order.d.ts +2 -0
  211. package/dist/internal/c4/local-market-order.d.ts.map +1 -0
  212. package/dist/internal/c4/local-market-order.js +4 -0
  213. package/dist/internal/c4/local-market-order.js.map +1 -0
  214. package/dist/internal/c4/loyalty.d.ts +0 -27
  215. package/dist/internal/c4/loyalty.d.ts.map +1 -1
  216. package/dist/internal/c4/loyalty.js +0 -33
  217. package/dist/internal/c4/loyalty.js.map +1 -1
  218. package/dist/internal/c4/market.d.ts +2 -38
  219. package/dist/internal/c4/market.d.ts.map +1 -1
  220. package/dist/internal/c4/market.js +13 -51
  221. package/dist/internal/c4/market.js.map +1 -1
  222. package/dist/internal/c4/mining-instructions.d.ts +2 -0
  223. package/dist/internal/c4/mining-instructions.d.ts.map +1 -0
  224. package/dist/internal/c4/mining-instructions.js +3 -0
  225. package/dist/internal/c4/mining-instructions.js.map +1 -0
  226. package/dist/internal/c4/open-signal.d.ts +8 -0
  227. package/dist/internal/c4/open-signal.d.ts.map +1 -0
  228. package/dist/internal/c4/open-signal.js +37 -0
  229. package/dist/internal/c4/open-signal.js.map +1 -0
  230. package/dist/internal/c4/profile-creation.d.ts +17 -0
  231. package/dist/internal/c4/profile-creation.d.ts.map +1 -0
  232. package/dist/internal/c4/profile-creation.js +36 -0
  233. package/dist/internal/c4/profile-creation.js.map +1 -0
  234. package/dist/internal/c4/profile-permissions.d.ts +14 -0
  235. package/dist/internal/c4/profile-permissions.d.ts.map +1 -0
  236. package/dist/internal/c4/profile-permissions.js +81 -0
  237. package/dist/internal/c4/profile-permissions.js.map +1 -0
  238. package/dist/internal/c4/region-geometry.d.ts +8 -0
  239. package/dist/internal/c4/region-geometry.d.ts.map +1 -0
  240. package/dist/internal/c4/region-geometry.js +43 -0
  241. package/dist/internal/c4/region-geometry.js.map +1 -0
  242. package/dist/internal/c4/rewards.d.ts +0 -27
  243. package/dist/internal/c4/rewards.d.ts.map +1 -1
  244. package/dist/internal/c4/rewards.js +0 -33
  245. package/dist/internal/c4/rewards.js.map +1 -1
  246. package/dist/internal/c4/runtime-bindings.d.ts +3 -0
  247. package/dist/internal/c4/runtime-bindings.d.ts.map +1 -0
  248. package/dist/internal/c4/runtime-bindings.js +4 -0
  249. package/dist/internal/c4/runtime-bindings.js.map +1 -0
  250. package/dist/internal/c4/scan-detection-codecs.d.ts +3 -0
  251. package/dist/internal/c4/scan-detection-codecs.d.ts.map +1 -0
  252. package/dist/internal/c4/scan-detection-codecs.js +3 -0
  253. package/dist/internal/c4/scan-detection-codecs.js.map +1 -0
  254. package/dist/internal/c4/scan-lifecycle.d.ts +306 -0
  255. package/dist/internal/c4/scan-lifecycle.d.ts.map +1 -0
  256. package/dist/internal/c4/scan-lifecycle.js +258 -0
  257. package/dist/internal/c4/scan-lifecycle.js.map +1 -0
  258. package/dist/internal/c4/scanning.d.ts +1 -28
  259. package/dist/internal/c4/scanning.d.ts.map +1 -1
  260. package/dist/internal/c4/scanning.js +2 -33
  261. package/dist/internal/c4/scanning.js.map +1 -1
  262. package/dist/internal/c4/ship-import.d.ts +4 -0
  263. package/dist/internal/c4/ship-import.d.ts.map +1 -0
  264. package/dist/internal/c4/ship-import.js +13 -0
  265. package/dist/internal/c4/ship-import.js.map +1 -0
  266. package/dist/internal/c4/ship-stats.d.ts.map +1 -1
  267. package/dist/internal/c4/ship-stats.js +25 -21
  268. package/dist/internal/c4/ship-stats.js.map +1 -1
  269. package/dist/internal/c4/starbase.d.ts +0 -32
  270. package/dist/internal/c4/starbase.d.ts.map +1 -1
  271. package/dist/internal/c4/starbase.js +3 -41
  272. package/dist/internal/c4/starbase.js.map +1 -1
  273. package/dist/internal/c4/world.d.ts +36 -7
  274. package/dist/internal/c4/world.d.ts.map +1 -1
  275. package/dist/internal/c4/world.js +58 -25
  276. package/dist/internal/c4/world.js.map +1 -1
  277. package/dist/internal/cargo.d.ts +2 -0
  278. package/dist/internal/cargo.d.ts.map +1 -1
  279. package/dist/internal/cargo.js +8 -0
  280. package/dist/internal/cargo.js.map +1 -1
  281. package/dist/internal/fleet.d.ts +1 -0
  282. package/dist/internal/fleet.d.ts.map +1 -1
  283. package/dist/internal/fleet.js +3 -1
  284. package/dist/internal/fleet.js.map +1 -1
  285. package/dist/internal/loyalty-atlas-bank-state.d.ts +16 -0
  286. package/dist/internal/loyalty-atlas-bank-state.d.ts.map +1 -0
  287. package/dist/internal/loyalty-atlas-bank-state.js +10 -0
  288. package/dist/internal/loyalty-atlas-bank-state.js.map +1 -0
  289. package/dist/internal/planning/action-runtime.d.ts +38 -0
  290. package/dist/internal/planning/action-runtime.d.ts.map +1 -0
  291. package/dist/internal/planning/action-runtime.js +63 -0
  292. package/dist/internal/planning/action-runtime.js.map +1 -0
  293. package/dist/internal/planning/arrival-guards.d.ts +20 -0
  294. package/dist/internal/planning/arrival-guards.d.ts.map +1 -0
  295. package/dist/internal/planning/arrival-guards.js +187 -0
  296. package/dist/internal/planning/arrival-guards.js.map +1 -0
  297. package/dist/internal/planning/authorization-adapter.d.ts +6 -6
  298. package/dist/internal/planning/authorization-adapter.d.ts.map +1 -1
  299. package/dist/internal/planning/authorization-adapter.js +81 -16
  300. package/dist/internal/planning/authorization-adapter.js.map +1 -1
  301. package/dist/internal/planning/character-registration-guard.d.ts +4 -0
  302. package/dist/internal/planning/character-registration-guard.d.ts.map +1 -0
  303. package/dist/internal/planning/character-registration-guard.js +58 -0
  304. package/dist/internal/planning/character-registration-guard.js.map +1 -0
  305. package/dist/internal/planning/character-registration.d.ts +23 -0
  306. package/dist/internal/planning/character-registration.d.ts.map +1 -0
  307. package/dist/internal/planning/character-registration.js +86 -0
  308. package/dist/internal/planning/character-registration.js.map +1 -0
  309. package/dist/internal/planning/democracy-history.d.ts +50 -0
  310. package/dist/internal/planning/democracy-history.d.ts.map +1 -0
  311. package/dist/internal/planning/democracy-history.js +198 -0
  312. package/dist/internal/planning/democracy-history.js.map +1 -0
  313. package/dist/internal/planning/faction-trade-guards.d.ts +30 -0
  314. package/dist/internal/planning/faction-trade-guards.d.ts.map +1 -0
  315. package/dist/internal/planning/faction-trade-guards.js +15 -0
  316. package/dist/internal/planning/faction-trade-guards.js.map +1 -0
  317. package/dist/internal/planning/faction-trade-state.d.ts +16 -0
  318. package/dist/internal/planning/faction-trade-state.d.ts.map +1 -0
  319. package/dist/internal/planning/faction-trade-state.js +43 -0
  320. package/dist/internal/planning/faction-trade-state.js.map +1 -0
  321. package/dist/internal/planning/fleet-arrival.d.ts +40 -0
  322. package/dist/internal/planning/fleet-arrival.d.ts.map +1 -0
  323. package/dist/internal/planning/fleet-arrival.js +105 -0
  324. package/dist/internal/planning/fleet-arrival.js.map +1 -0
  325. package/dist/internal/planning/fleet-attack-xp.d.ts +20 -0
  326. package/dist/internal/planning/fleet-attack-xp.d.ts.map +1 -0
  327. package/dist/internal/planning/fleet-attack-xp.js +110 -0
  328. package/dist/internal/planning/fleet-attack-xp.js.map +1 -0
  329. package/dist/internal/planning/fleet-creation.d.ts +30 -0
  330. package/dist/internal/planning/fleet-creation.d.ts.map +1 -0
  331. package/dist/internal/planning/fleet-creation.js +107 -0
  332. package/dist/internal/planning/fleet-creation.js.map +1 -0
  333. package/dist/internal/planning/fleet-crew-guard.d.ts +28 -0
  334. package/dist/internal/planning/fleet-crew-guard.d.ts.map +1 -0
  335. package/dist/internal/planning/fleet-crew-guard.js +47 -0
  336. package/dist/internal/planning/fleet-crew-guard.js.map +1 -0
  337. package/dist/internal/planning/fleet-crew-transfer.d.ts +7 -0
  338. package/dist/internal/planning/fleet-crew-transfer.d.ts.map +1 -0
  339. package/dist/internal/planning/fleet-crew-transfer.js +131 -0
  340. package/dist/internal/planning/fleet-crew-transfer.js.map +1 -0
  341. package/dist/internal/planning/fleet-respawn.d.ts +28 -0
  342. package/dist/internal/planning/fleet-respawn.d.ts.map +1 -0
  343. package/dist/internal/planning/fleet-respawn.js +164 -0
  344. package/dist/internal/planning/fleet-respawn.js.map +1 -0
  345. package/dist/internal/planning/fleet-ship-assembly.d.ts +36 -0
  346. package/dist/internal/planning/fleet-ship-assembly.d.ts.map +1 -0
  347. package/dist/internal/planning/fleet-ship-assembly.js +136 -0
  348. package/dist/internal/planning/fleet-ship-assembly.js.map +1 -0
  349. package/dist/internal/planning/governance-fees.d.ts +64 -0
  350. package/dist/internal/planning/governance-fees.d.ts.map +1 -0
  351. package/dist/internal/planning/governance-fees.js +239 -0
  352. package/dist/internal/planning/governance-fees.js.map +1 -0
  353. package/dist/internal/planning/local-market-order-funding.d.ts +8 -0
  354. package/dist/internal/planning/local-market-order-funding.d.ts.map +1 -0
  355. package/dist/internal/planning/local-market-order-funding.js +123 -0
  356. package/dist/internal/planning/local-market-order-funding.js.map +1 -0
  357. package/dist/internal/planning/local-market-order.d.ts +42 -0
  358. package/dist/internal/planning/local-market-order.d.ts.map +1 -0
  359. package/dist/internal/planning/local-market-order.js +192 -0
  360. package/dist/internal/planning/local-market-order.js.map +1 -0
  361. package/dist/internal/planning/mining-stop.d.ts +14 -0
  362. package/dist/internal/planning/mining-stop.d.ts.map +1 -0
  363. package/dist/internal/planning/mining-stop.js +41 -0
  364. package/dist/internal/planning/mining-stop.js.map +1 -0
  365. package/dist/internal/planning/movement-character.d.ts +7 -0
  366. package/dist/internal/planning/movement-character.d.ts.map +1 -0
  367. package/dist/internal/planning/movement-character.js +41 -0
  368. package/dist/internal/planning/movement-character.js.map +1 -0
  369. package/dist/internal/planning/movement-xp-guard.d.ts +4 -0
  370. package/dist/internal/planning/movement-xp-guard.d.ts.map +1 -0
  371. package/dist/internal/planning/movement-xp-guard.js +103 -0
  372. package/dist/internal/planning/movement-xp-guard.js.map +1 -0
  373. package/dist/internal/planning/open-signal-guard.d.ts +3 -0
  374. package/dist/internal/planning/open-signal-guard.d.ts.map +1 -0
  375. package/dist/internal/planning/open-signal-guard.js +31 -0
  376. package/dist/internal/planning/open-signal-guard.js.map +1 -0
  377. package/dist/internal/planning/open-signal.d.ts +31 -0
  378. package/dist/internal/planning/open-signal.d.ts.map +1 -0
  379. package/dist/internal/planning/open-signal.js +84 -0
  380. package/dist/internal/planning/open-signal.js.map +1 -0
  381. package/dist/internal/planning/respawn-guards.d.ts +3 -0
  382. package/dist/internal/planning/respawn-guards.d.ts.map +1 -0
  383. package/dist/internal/planning/respawn-guards.js +41 -0
  384. package/dist/internal/planning/respawn-guards.js.map +1 -0
  385. package/dist/internal/planning/runtime-guards.d.ts +43 -0
  386. package/dist/internal/planning/runtime-guards.d.ts.map +1 -0
  387. package/dist/internal/planning/runtime-guards.js +636 -0
  388. package/dist/internal/planning/runtime-guards.js.map +1 -0
  389. package/dist/internal/planning/scan-completion-guard.d.ts +43 -0
  390. package/dist/internal/planning/scan-completion-guard.d.ts.map +1 -0
  391. package/dist/internal/planning/scan-completion-guard.js +94 -0
  392. package/dist/internal/planning/scan-completion-guard.js.map +1 -0
  393. package/dist/internal/planning/scan-completion.d.ts +20 -0
  394. package/dist/internal/planning/scan-completion.d.ts.map +1 -0
  395. package/dist/internal/planning/scan-completion.js +196 -0
  396. package/dist/internal/planning/scan-completion.js.map +1 -0
  397. package/dist/internal/planning/scan-detect-guard.d.ts +34 -0
  398. package/dist/internal/planning/scan-detect-guard.d.ts.map +1 -0
  399. package/dist/internal/planning/scan-detect-guard.js +77 -0
  400. package/dist/internal/planning/scan-detect-guard.js.map +1 -0
  401. package/dist/internal/planning/scan-detect.d.ts +24 -0
  402. package/dist/internal/planning/scan-detect.d.ts.map +1 -0
  403. package/dist/internal/planning/scan-detect.js +244 -0
  404. package/dist/internal/planning/scan-detect.js.map +1 -0
  405. package/dist/internal/planning/scan-input.d.ts +9 -0
  406. package/dist/internal/planning/scan-input.d.ts.map +1 -0
  407. package/dist/internal/planning/scan-input.js +58 -0
  408. package/dist/internal/planning/scan-input.js.map +1 -0
  409. package/dist/internal/planning/ship-import-funding.d.ts +22 -0
  410. package/dist/internal/planning/ship-import-funding.d.ts.map +1 -0
  411. package/dist/internal/planning/ship-import-funding.js +52 -0
  412. package/dist/internal/planning/ship-import-funding.js.map +1 -0
  413. package/dist/internal/planning/ship-token.d.ts.map +1 -1
  414. package/dist/internal/planning/ship-token.js +2 -4
  415. package/dist/internal/planning/ship-token.js.map +1 -1
  416. package/dist/internal/planning/starbase-system-guard.d.ts +6 -0
  417. package/dist/internal/planning/starbase-system-guard.d.ts.map +1 -0
  418. package/dist/internal/planning/starbase-system-guard.js +93 -0
  419. package/dist/internal/planning/starbase-system-guard.js.map +1 -0
  420. package/dist/internal/planning/starbase-system.d.ts +12 -0
  421. package/dist/internal/planning/starbase-system.d.ts.map +1 -0
  422. package/dist/internal/planning/starbase-system.js +22 -0
  423. package/dist/internal/planning/starbase-system.js.map +1 -0
  424. package/dist/internal/planning/token-mint.d.ts +4 -0
  425. package/dist/internal/planning/token-mint.d.ts.map +1 -0
  426. package/dist/internal/planning/token-mint.js +15 -0
  427. package/dist/internal/planning/token-mint.js.map +1 -0
  428. package/dist/internal/planning/trade-faction-market.d.ts +20 -0
  429. package/dist/internal/planning/trade-faction-market.d.ts.map +1 -0
  430. package/dist/internal/planning/trade-faction-market.js +56 -0
  431. package/dist/internal/planning/trade-faction-market.js.map +1 -0
  432. package/dist/internal/planning/xp-runtime.d.ts +36 -0
  433. package/dist/internal/planning/xp-runtime.d.ts.map +1 -0
  434. package/dist/internal/planning/xp-runtime.js +126 -0
  435. package/dist/internal/planning/xp-runtime.js.map +1 -0
  436. package/dist/loyalty/actions/index.d.ts.map +1 -1
  437. package/dist/loyalty/actions/index.js +4 -3
  438. package/dist/loyalty/actions/index.js.map +1 -1
  439. package/dist/loyalty/index.d.ts.map +1 -1
  440. package/dist/loyalty/index.js +2 -6
  441. package/dist/loyalty/index.js.map +1 -1
  442. package/dist/markets/actions/index.d.ts +58 -3
  443. package/dist/markets/actions/index.d.ts.map +1 -1
  444. package/dist/markets/actions/index.js +133 -25
  445. package/dist/markets/actions/index.js.map +1 -1
  446. package/dist/markets/actions/trade-faction-market.d.ts +43 -0
  447. package/dist/markets/actions/trade-faction-market.d.ts.map +1 -0
  448. package/dist/markets/actions/trade-faction-market.js +291 -0
  449. package/dist/markets/actions/trade-faction-market.js.map +1 -0
  450. package/dist/markets/index.d.ts +7 -7
  451. package/dist/markets/index.d.ts.map +1 -1
  452. package/dist/markets/index.js +9 -9
  453. package/dist/markets/index.js.map +1 -1
  454. package/dist/mining/actions/index.d.ts +84 -0
  455. package/dist/mining/actions/index.d.ts.map +1 -0
  456. package/dist/mining/actions/index.js +328 -0
  457. package/dist/mining/actions/index.js.map +1 -0
  458. package/dist/mining/estimate.d.ts +114 -0
  459. package/dist/mining/estimate.d.ts.map +1 -0
  460. package/dist/mining/estimate.js +127 -0
  461. package/dist/mining/estimate.js.map +1 -0
  462. package/dist/mining/index.d.ts +8 -2
  463. package/dist/mining/index.d.ts.map +1 -1
  464. package/dist/mining/index.js +6 -2
  465. package/dist/mining/index.js.map +1 -1
  466. package/dist/planning/assembly.d.ts.map +1 -1
  467. package/dist/planning/assembly.js +20 -0
  468. package/dist/planning/assembly.js.map +1 -1
  469. package/dist/planning/execution.d.ts.map +1 -1
  470. package/dist/planning/execution.js +405 -16
  471. package/dist/planning/execution.js.map +1 -1
  472. package/dist/planning/index.d.ts +171 -149
  473. package/dist/planning/index.d.ts.map +1 -1
  474. package/dist/planning/index.js +837 -121
  475. package/dist/planning/index.js.map +1 -1
  476. package/dist/planning/plan-sequence.d.ts.map +1 -1
  477. package/dist/planning/plan-sequence.js +8 -1
  478. package/dist/planning/plan-sequence.js.map +1 -1
  479. package/dist/planning/simulation.d.ts +25 -1
  480. package/dist/planning/simulation.d.ts.map +1 -1
  481. package/dist/planning/simulation.js +111 -11
  482. package/dist/planning/simulation.js.map +1 -1
  483. package/dist/registry/cargo.d.ts +6 -11
  484. package/dist/registry/cargo.d.ts.map +1 -1
  485. package/dist/registry/cargo.js +19 -19
  486. package/dist/registry/cargo.js.map +1 -1
  487. package/dist/registry/index.d.ts +4 -0
  488. package/dist/registry/index.d.ts.map +1 -1
  489. package/dist/registry/index.js.map +1 -1
  490. package/dist/registry/onboarding.d.ts +8 -1
  491. package/dist/registry/onboarding.d.ts.map +1 -1
  492. package/dist/registry/onboarding.js +18 -5
  493. package/dist/registry/onboarding.js.map +1 -1
  494. package/dist/registry/scanning.d.ts +7 -0
  495. package/dist/registry/scanning.d.ts.map +1 -0
  496. package/dist/registry/scanning.js +13 -0
  497. package/dist/registry/scanning.js.map +1 -0
  498. package/dist/registry/ship-stats-snapshot.js +19 -19
  499. package/dist/registry/ship-stats-snapshot.js.map +1 -1
  500. package/dist/registry/ships.d.ts +22 -2
  501. package/dist/registry/ships.d.ts.map +1 -1
  502. package/dist/registry/ships.js +28 -4
  503. package/dist/registry/ships.js.map +1 -1
  504. package/dist/registry/xp-runtime.d.ts +4 -0
  505. package/dist/registry/xp-runtime.d.ts.map +1 -0
  506. package/dist/registry/xp-runtime.js +14 -0
  507. package/dist/registry/xp-runtime.js.map +1 -0
  508. package/dist/scanning/actions/index.d.ts +116 -0
  509. package/dist/scanning/actions/index.d.ts.map +1 -0
  510. package/dist/scanning/actions/index.js +185 -0
  511. package/dist/scanning/actions/index.js.map +1 -0
  512. package/dist/scanning/index.d.ts +4 -1
  513. package/dist/scanning/index.d.ts.map +1 -1
  514. package/dist/scanning/index.js +12 -8
  515. package/dist/scanning/index.js.map +1 -1
  516. package/dist/scanning/lifecycle.d.ts +77 -0
  517. package/dist/scanning/lifecycle.d.ts.map +1 -0
  518. package/dist/scanning/lifecycle.js +93 -0
  519. package/dist/scanning/lifecycle.js.map +1 -0
  520. package/dist/scanning/odds.d.ts +111 -0
  521. package/dist/scanning/odds.d.ts.map +1 -0
  522. package/dist/scanning/odds.js +294 -0
  523. package/dist/scanning/odds.js.map +1 -0
  524. package/dist/scanning/signals.d.ts +121 -0
  525. package/dist/scanning/signals.d.ts.map +1 -0
  526. package/dist/scanning/signals.js +171 -0
  527. package/dist/scanning/signals.js.map +1 -0
  528. package/dist/world/index.d.ts +110 -5
  529. package/dist/world/index.d.ts.map +1 -1
  530. package/dist/world/index.js +109 -4
  531. package/dist/world/index.js.map +1 -1
  532. package/dist/world/planet-claim-stake-plots.d.ts +130 -0
  533. package/dist/world/planet-claim-stake-plots.d.ts.map +1 -0
  534. package/dist/world/planet-claim-stake-plots.js +110 -0
  535. package/dist/world/planet-claim-stake-plots.js.map +1 -0
  536. package/dist/world/starbase-status.d.ts +176 -0
  537. package/dist/world/starbase-status.d.ts.map +1 -0
  538. package/dist/world/starbase-status.js +153 -0
  539. package/dist/world/starbase-status.js.map +1 -0
  540. package/package.json +10 -2
@@ -1,9 +1,22 @@
1
+ import { normalizeLocalMarketOrderGuard, localMarketOrderGuardToJSON, validateLocalMarketOrderInstructions, } from '../internal/planning/local-market-order.js';
2
+ import { validateCrewTransferInstructions, } from '../internal/planning/fleet-crew-guard.js';
3
+ import { validateCompletionInstructions, scanCompletionDiscriminators, } from '../internal/planning/scan-completion-guard.js';
4
+ import { validateOpenSignalInstructions } from '../internal/planning/open-signal-guard.js';
5
+ import { validateDetectInstructions, } from '../internal/planning/scan-detect-guard.js';
6
+ import { validateRespawnInstructions } from '../internal/planning/respawn-guards.js';
7
+ import { validateFleetAttackInstructions, } from '../internal/planning/fleet-attack-xp.js';
8
+ import { validateMovementXpInstructions } from '../internal/planning/movement-xp-guard.js';
9
+ import { validateStarbaseSystemInstructions, validateStarbaseSystemGuards, } from '../internal/planning/starbase-system-guard.js';
10
+ import { validateCharacterRegistrationInstructions } from '../internal/planning/character-registration-guard.js';
11
+ import { normalizeArrivalGuard, arrivalGuardToJSON, validateArrivalInstructions, } from '../internal/planning/arrival-guards.js';
12
+ import { isRuntimeGuard, normalizeRuntimeGuard, runtimeGuardToJSON, validateRuntimeInstructions, } from '../internal/planning/runtime-guards.js';
13
+ import { isTradeBuyGuard, isTradeSellGuard, isTradeMeterGuard, isFactionTradeGuard, } from '../internal/planning/faction-trade-guards.js';
1
14
  import { AccountRole, getBase64Decoder, getBase64Encoder, isAddress, isWritableRole, } from '@solana/kit';
2
- import { InvalidActionInputError } from '../client/errors.js';
15
+ import { InvalidActionInputError, SageSdkError } from '../client/errors.js';
3
16
  import { deepFreeze } from '../internal/immutable-tree.js';
17
+ import { validateMiningStopInstructions } from '../internal/planning/mining-stop.js';
4
18
  import { validatePlanComposition } from './composition.js';
5
19
  import { isPlanInstance, registerPlanInstance } from './plan-instances.js';
6
- const PLAN_BRAND = Symbol('AephiaSagePlan');
7
20
  const BASE64_PATTERN = /^(?:[A-Za-z\d+/]{4})*(?:[A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/u;
8
21
  const DATA_HASH_PATTERN = /^[\da-f]{64}$/u;
9
22
  const ACCOUNT_ROLES = new Set([
@@ -138,7 +151,7 @@ function normalizeSemanticFact(value, field) {
138
151
  if (semantic.scope !== 'transaction') {
139
152
  return invalid(`${field}.scope`, semantic.scope, 'the token "transaction"');
140
153
  }
141
- return { kind: 'exclusive', scope: 'transaction' };
154
+ return Object.freeze({ kind: 'exclusive', scope: 'transaction' });
142
155
  }
143
156
  if (semantic.kind === 'requires' || semantic.kind === 'invalidates') {
144
157
  assertKeys(semantic, field, ['kind', 'resource', 'fact']);
@@ -159,9 +172,584 @@ function normalizeSemanticFact(value, field) {
159
172
  }
160
173
  return invalid(`${field}.kind`, semantic.kind, 'one of exclusive, requires, invalidates, or transition');
161
174
  }
162
- function normalizePrecondition(value, field, version = 6) {
175
+ function normalizePrecondition(value, field) {
163
176
  const precondition = readRecord(value, field);
164
- if (version >= 6 && precondition.kind === 'game-ship-config') {
177
+ if (precondition.kind === 'fleet-arrival')
178
+ return normalizeArrivalGuard(precondition, field);
179
+ if (isRuntimeGuard(precondition))
180
+ return normalizeRuntimeGuard(precondition, field);
181
+ if (precondition.kind === 'character-registration') {
182
+ assertKeys(precondition, field, [
183
+ 'kind',
184
+ 'address',
185
+ 'game',
186
+ 'profile',
187
+ 'profileDataHash',
188
+ 'funder',
189
+ 'xpBudget',
190
+ 'xpBudgetConfig',
191
+ 'maximumFunderDebit',
192
+ 'characterSize',
193
+ 'initializationHash',
194
+ 'characterLamports',
195
+ 'budgetLamports',
196
+ 'describes',
197
+ ]);
198
+ if (typeof precondition.characterSize !== 'number' ||
199
+ !Number.isSafeInteger(precondition.characterSize) ||
200
+ precondition.characterSize < 423)
201
+ invalid(`${field}.characterSize`, precondition.characterSize, 'a qualified Character allocation of at least 423 bytes');
202
+ for (const key of ['characterLamports', 'budgetLamports'])
203
+ if (typeof precondition[key] !== 'bigint' || precondition[key] < 0n)
204
+ invalid(`${field}.${key}`, precondition[key], 'a nonnegative bigint');
205
+ const maximumFunderDebit = precondition.maximumFunderDebit;
206
+ if (typeof maximumFunderDebit !== 'bigint' || maximumFunderDebit < 0n)
207
+ invalid(`${field}.maximumFunderDebit`, maximumFunderDebit, 'a nonnegative bigint');
208
+ return Object.freeze({
209
+ kind: 'character-registration',
210
+ address: readAddress(precondition.address, `${field}.address`),
211
+ game: readAddress(precondition.game, `${field}.game`),
212
+ profile: readAddress(precondition.profile, `${field}.profile`),
213
+ profileDataHash: readDataHash(precondition.profileDataHash, `${field}.profileDataHash`),
214
+ funder: readAddress(precondition.funder, `${field}.funder`),
215
+ xpBudget: readAddress(precondition.xpBudget, `${field}.xpBudget`),
216
+ xpBudgetConfig: readAddress(precondition.xpBudgetConfig, `${field}.xpBudgetConfig`),
217
+ maximumFunderDebit,
218
+ characterLamports: precondition.characterLamports,
219
+ budgetLamports: precondition.budgetLamports,
220
+ characterSize: precondition.characterSize,
221
+ initializationHash: readDataHash(precondition.initializationHash, `${field}.initializationHash`),
222
+ describes: readString(precondition.describes, `${field}.describes`),
223
+ });
224
+ }
225
+ if (precondition.kind === 'ship-import-funding') {
226
+ assertKeys(precondition, field, [
227
+ 'kind',
228
+ 'address',
229
+ 'game',
230
+ 'profile',
231
+ 'system',
232
+ 'shipId',
233
+ 'maximumProfileDebit',
234
+ 'describes',
235
+ ]);
236
+ const shipId = precondition.shipId;
237
+ if (typeof shipId !== 'number' ||
238
+ !Number.isInteger(shipId) ||
239
+ shipId < 0 ||
240
+ shipId > 65535)
241
+ invalid(`${field}.shipId`, shipId, 'an unsigned u16 ship configuration ID');
242
+ const maximumProfileDebit = precondition.maximumProfileDebit;
243
+ if (typeof maximumProfileDebit !== 'bigint' || maximumProfileDebit < 0n)
244
+ invalid(`${field}.maximumProfileDebit`, maximumProfileDebit, 'a nonnegative bigint');
245
+ return Object.freeze({
246
+ kind: 'ship-import-funding',
247
+ address: readAddress(precondition.address, `${field}.address`),
248
+ game: readAddress(precondition.game, `${field}.game`),
249
+ profile: readAddress(precondition.profile, `${field}.profile`),
250
+ system: readAddress(precondition.system, `${field}.system`),
251
+ shipId,
252
+ maximumProfileDebit,
253
+ describes: readString(precondition.describes, `${field}.describes`),
254
+ });
255
+ }
256
+ if (precondition.kind === 'fleet-attack') {
257
+ assertKeys(precondition, field, [
258
+ 'kind',
259
+ 'address',
260
+ 'defender',
261
+ 'game',
262
+ 'profile',
263
+ 'defenderProfile',
264
+ 'instructionKey',
265
+ 'describes',
266
+ ]);
267
+ return Object.freeze({
268
+ kind: 'fleet-attack',
269
+ address: readAddress(precondition.address, `${field}.address`),
270
+ defender: readAddress(precondition.defender, `${field}.defender`),
271
+ game: readAddress(precondition.game, `${field}.game`),
272
+ profile: readAddress(precondition.profile, `${field}.profile`),
273
+ defenderProfile: readAddress(precondition.defenderProfile, `${field}.defenderProfile`),
274
+ instructionKey: readString(precondition.instructionKey, `${field}.instructionKey`),
275
+ describes: readString(precondition.describes, `${field}.describes`),
276
+ });
277
+ }
278
+ if (precondition.kind === 'movement-character') {
279
+ assertKeys(precondition, field, [
280
+ 'kind',
281
+ 'address',
282
+ 'game',
283
+ 'profile',
284
+ 'stateHash',
285
+ 'describes',
286
+ ]);
287
+ return Object.freeze({
288
+ kind: 'movement-character',
289
+ address: readAddress(precondition.address, `${field}.address`),
290
+ game: readAddress(precondition.game, `${field}.game`),
291
+ profile: readAddress(precondition.profile, `${field}.profile`),
292
+ stateHash: readDataHash(precondition.stateHash, `${field}.stateHash`),
293
+ describes: readString(precondition.describes, `${field}.describes`),
294
+ });
295
+ }
296
+ if (precondition.kind === 'starbase-system') {
297
+ assertKeys(precondition, field, ['kind', 'address', 'game', 'starbaseSequenceId', 'describes'], ['requireCss']);
298
+ if (precondition.requireCss !== undefined &&
299
+ precondition.requireCss !== true)
300
+ invalid(`${field}.requireCss`, precondition.requireCss, 'true when CSS access is required, otherwise omitted');
301
+ const sequence = precondition.starbaseSequenceId;
302
+ if (typeof sequence !== 'bigint' ||
303
+ sequence < 0n ||
304
+ sequence > 18446744073709551615n)
305
+ invalid(`${field}.starbaseSequenceId`, sequence, 'an unsigned u64 Starbase sequence');
306
+ return Object.freeze({
307
+ kind: 'starbase-system',
308
+ address: readAddress(precondition.address, `${field}.address`),
309
+ game: readAddress(precondition.game, `${field}.game`),
310
+ starbaseSequenceId: sequence,
311
+ ...(precondition.requireCss === undefined
312
+ ? {}
313
+ : { requireCss: true }),
314
+ describes: readString(precondition.describes, `${field}.describes`),
315
+ });
316
+ }
317
+ if (precondition.kind === 'fleet-mining') {
318
+ assertKeys(precondition, field, [
319
+ 'kind',
320
+ 'address',
321
+ 'game',
322
+ 'profile',
323
+ 'asteroid',
324
+ 'describes',
325
+ ]);
326
+ return Object.freeze({
327
+ kind: 'fleet-mining',
328
+ address: readAddress(precondition.address, `${field}.address`),
329
+ game: readAddress(precondition.game, `${field}.game`),
330
+ profile: readAddress(precondition.profile, `${field}.profile`),
331
+ asteroid: readAddress(precondition.asteroid, `${field}.asteroid`),
332
+ describes: readString(precondition.describes, `${field}.describes`),
333
+ });
334
+ }
335
+ if (isFactionTradeGuard(precondition)) {
336
+ const kind = precondition.kind;
337
+ assertKeys(precondition, field, [
338
+ 'kind',
339
+ 'address',
340
+ 'game',
341
+ 'factionId',
342
+ 'describes',
343
+ 'schemaVersion',
344
+ ...(isTradeBuyGuard(precondition)
345
+ ? ['cargoId', 'floorRaw']
346
+ : isTradeSellGuard(precondition)
347
+ ? ['atlasOutCapPerEpochRaw', 'epochLengthSeconds']
348
+ : []),
349
+ ]);
350
+ const unsigned = (key, max = 65535) => {
351
+ const n = precondition[key];
352
+ if (typeof n !== 'number' || !Number.isInteger(n) || n < 0 || n > max)
353
+ invalid(`${field}.${key}`, n, `an unsigned ${max === 255 ? 'u8' : 'u16'} integer`);
354
+ return n;
355
+ };
356
+ const integer = (key, signed = false) => {
357
+ const n = precondition[key];
358
+ const min = signed ? -(1n << 63n) : 0n;
359
+ const max = signed ? (1n << 63n) - 1n : (1n << 64n) - 1n;
360
+ if (typeof n !== 'bigint' || n < min || n > max)
361
+ invalid(`${field}.${key}`, n, signed ? 'an i64 bigint' : 'a u64 bigint');
362
+ return n;
363
+ };
364
+ const common = {
365
+ address: readAddress(precondition.address, `${field}.address`),
366
+ game: readAddress(precondition.game, `${field}.game`),
367
+ factionId: unsigned('factionId'),
368
+ schemaVersion: unsigned('schemaVersion', 255),
369
+ describes: readString(precondition.describes, `${field}.describes`),
370
+ };
371
+ if (isTradeBuyGuard(precondition))
372
+ return Object.freeze({
373
+ kind,
374
+ ...common,
375
+ cargoId: unsigned('cargoId'),
376
+ floorRaw: integer('floorRaw'),
377
+ });
378
+ if (isTradeSellGuard(precondition))
379
+ return Object.freeze({
380
+ kind,
381
+ ...common,
382
+ atlasOutCapPerEpochRaw: integer('atlasOutCapPerEpochRaw'),
383
+ epochLengthSeconds: integer('epochLengthSeconds', true),
384
+ });
385
+ return Object.freeze({ kind, ...common });
386
+ }
387
+ if (precondition.kind === 'fleet-add-ship') {
388
+ assertKeys(precondition, field, [
389
+ 'kind',
390
+ 'address',
391
+ 'game',
392
+ 'profile',
393
+ 'authority',
394
+ 'system',
395
+ 'shipId',
396
+ 'amount',
397
+ 'keyIndex',
398
+ 'configHash',
399
+ 'maximumProfileDebit',
400
+ 'describes',
401
+ ]);
402
+ const keyIndex = precondition.keyIndex;
403
+ if (typeof keyIndex !== 'number' ||
404
+ !Number.isInteger(keyIndex) ||
405
+ keyIndex < 0 ||
406
+ keyIndex > 65535)
407
+ invalid(`${field}.keyIndex`, keyIndex, 'an integer from 0 through 65535');
408
+ const shipId = precondition.shipId;
409
+ if (typeof shipId !== 'number' ||
410
+ !Number.isInteger(shipId) ||
411
+ shipId < 0 ||
412
+ shipId > 65535)
413
+ invalid(`${field}.shipId`, shipId, 'a u16 ship configuration ID');
414
+ const amount = precondition.amount;
415
+ if (typeof amount !== 'bigint' || amount < 1n || amount > 255n)
416
+ invalid(`${field}.amount`, amount, 'a whole ship quantity from 1n through 255n');
417
+ const maximumProfileDebit = precondition.maximumProfileDebit;
418
+ if (typeof maximumProfileDebit !== 'bigint' || maximumProfileDebit < 0n)
419
+ invalid(`${field}.maximumProfileDebit`, maximumProfileDebit, 'a nonnegative bigint');
420
+ return Object.freeze({
421
+ kind: 'fleet-add-ship',
422
+ address: readAddress(precondition.address, `${field}.address`),
423
+ game: readAddress(precondition.game, `${field}.game`),
424
+ profile: readAddress(precondition.profile, `${field}.profile`),
425
+ authority: readAddress(precondition.authority, `${field}.authority`),
426
+ system: readAddress(precondition.system, `${field}.system`),
427
+ keyIndex,
428
+ shipId,
429
+ amount,
430
+ maximumProfileDebit,
431
+ configHash: readDataHash(precondition.configHash, `${field}.configHash`),
432
+ describes: readString(precondition.describes, `${field}.describes`),
433
+ });
434
+ }
435
+ if (precondition.kind === 'scan-completion') {
436
+ const addresses = [
437
+ 'address',
438
+ 'game',
439
+ 'signal',
440
+ 'profile',
441
+ 'character',
442
+ 'authority',
443
+ 'policy',
444
+ 'loot',
445
+ 'xpBudget',
446
+ 'xpConfig',
447
+ ];
448
+ assertKeys(precondition, field, [
449
+ 'kind',
450
+ 'operation',
451
+ ...addresses,
452
+ 'keyIndex',
453
+ 'status',
454
+ 'expectedSequence',
455
+ 'configHash',
456
+ 'describes',
457
+ ]);
458
+ if (typeof precondition.operation !== 'string' ||
459
+ !Object.hasOwn(scanCompletionDiscriminators, precondition.operation))
460
+ invalid(field, precondition.operation, 'a supported scan lifecycle operation');
461
+ const keyIndex = precondition.keyIndex, status = precondition.status, sequence = precondition.expectedSequence;
462
+ if (typeof keyIndex !== 'number' ||
463
+ !Number.isInteger(keyIndex) ||
464
+ keyIndex < 0 ||
465
+ keyIndex > 65535)
466
+ invalid(field, keyIndex, 'a u16 key index');
467
+ if (typeof status !== 'number' ||
468
+ !Number.isInteger(status) ||
469
+ status < 1 ||
470
+ status > 6)
471
+ invalid(field, status, 'a current nonempty signal state');
472
+ if (typeof sequence !== 'bigint' ||
473
+ sequence < 0n ||
474
+ sequence > 18446744073709551615n)
475
+ invalid(field, sequence, 'a u64 sequence');
476
+ const parsed = Object.fromEntries(addresses.map((k) => [k, readAddress(precondition[k], `${field}.${k}`)]));
477
+ return Object.freeze({
478
+ kind: 'scan-completion',
479
+ operation: precondition.operation,
480
+ ...parsed,
481
+ keyIndex,
482
+ status,
483
+ expectedSequence: sequence,
484
+ configHash: readDataHash(precondition.configHash, field),
485
+ describes: readString(precondition.describes, field),
486
+ });
487
+ }
488
+ if (precondition.kind === 'scan-detect') {
489
+ assertKeys(precondition, field, [
490
+ 'kind',
491
+ 'address',
492
+ 'game',
493
+ 'profile',
494
+ 'authority',
495
+ 'character',
496
+ 'signal',
497
+ 'pattern',
498
+ 'policy',
499
+ 'loot',
500
+ 'tracker',
501
+ 'keyIndex',
502
+ 'patternId',
503
+ 'focus',
504
+ 'expectedSequence',
505
+ 'policyRevision',
506
+ 'profileRevision',
507
+ 'configHash',
508
+ 'describes',
509
+ ]);
510
+ const numbers = {};
511
+ for (const [key, max] of [
512
+ ['keyIndex', 65535],
513
+ ['patternId', 65535],
514
+ ['focus', 4],
515
+ ['policyRevision', 4294967295],
516
+ ['profileRevision', 4294967295],
517
+ ]) {
518
+ const value = precondition[key];
519
+ if (typeof value !== 'number' ||
520
+ !Number.isInteger(value) ||
521
+ value < 0 ||
522
+ value > max)
523
+ invalid(`${field}.${key}`, value, `an integer from zero through ${max}`);
524
+ numbers[key] = value;
525
+ }
526
+ const sequence = precondition.expectedSequence;
527
+ if (typeof sequence !== 'bigint' ||
528
+ sequence < 0n ||
529
+ sequence > 18446744073709551615n)
530
+ invalid(`${field}.expectedSequence`, sequence, 'a u64 bigint');
531
+ return Object.freeze({
532
+ kind: 'scan-detect',
533
+ address: readAddress(precondition.address, field),
534
+ game: readAddress(precondition.game, field),
535
+ profile: readAddress(precondition.profile, field),
536
+ authority: readAddress(precondition.authority, field),
537
+ character: readAddress(precondition.character, field),
538
+ signal: readAddress(precondition.signal, field),
539
+ pattern: readAddress(precondition.pattern, field),
540
+ policy: readAddress(precondition.policy, field),
541
+ loot: readAddress(precondition.loot, field),
542
+ tracker: readAddress(precondition.tracker, field),
543
+ keyIndex: numbers.keyIndex,
544
+ patternId: numbers.patternId,
545
+ focus: numbers.focus,
546
+ policyRevision: numbers.policyRevision,
547
+ profileRevision: numbers.profileRevision,
548
+ expectedSequence: sequence,
549
+ configHash: readDataHash(precondition.configHash, field),
550
+ describes: readString(precondition.describes, field),
551
+ });
552
+ }
553
+ if (precondition.kind === 'fleet-crew-transfer') {
554
+ assertKeys(precondition, field, [
555
+ 'kind',
556
+ 'direction',
557
+ 'address',
558
+ 'game',
559
+ 'profile',
560
+ 'authority',
561
+ 'system',
562
+ 'starbasePlayer',
563
+ 'keyIndex',
564
+ 'count',
565
+ 'systemSequenceId',
566
+ 'describes',
567
+ ]);
568
+ for (const key of ['count', 'keyIndex']) {
569
+ const n = precondition[key];
570
+ if (typeof n !== 'number' ||
571
+ !Number.isInteger(n) ||
572
+ n < (key === 'count' ? 1 : 0) ||
573
+ n > 65535)
574
+ invalid(field, n, 'a positive u16 count and u16 key index');
575
+ }
576
+ const direction = precondition.direction, sequence = precondition.systemSequenceId;
577
+ if (direction !== 'load' && direction !== 'unload')
578
+ invalid(field, direction, 'load or unload');
579
+ if (typeof sequence !== 'bigint' ||
580
+ sequence < 0n ||
581
+ sequence > (1n << 64n) - 1n)
582
+ invalid(field, sequence, 'a u64 System generation');
583
+ return Object.freeze({
584
+ kind: 'fleet-crew-transfer',
585
+ direction,
586
+ address: readAddress(precondition.address, field),
587
+ game: readAddress(precondition.game, field),
588
+ profile: readAddress(precondition.profile, field),
589
+ authority: readAddress(precondition.authority, field),
590
+ system: readAddress(precondition.system, field),
591
+ starbasePlayer: readAddress(precondition.starbasePlayer, field),
592
+ count: precondition.count,
593
+ keyIndex: precondition.keyIndex,
594
+ systemSequenceId: sequence,
595
+ describes: readString(precondition.describes, field),
596
+ });
597
+ }
598
+ if (precondition.kind === 'fleet-respawn') {
599
+ assertKeys(precondition, field, [
600
+ 'kind',
601
+ 'address',
602
+ 'game',
603
+ 'profile',
604
+ 'authority',
605
+ 'system',
606
+ 'keyIndex',
607
+ 'phase',
608
+ 'fleetHash',
609
+ 'maximumRecoveryFee',
610
+ 'maximumProfileDebit',
611
+ 'describes',
612
+ ]);
613
+ const keyIndex = precondition.keyIndex;
614
+ if (typeof keyIndex !== 'number' ||
615
+ !Number.isInteger(keyIndex) ||
616
+ keyIndex < 0 ||
617
+ keyIndex > 65535)
618
+ invalid(`${field}.keyIndex`, keyIndex, 'a u16 key index');
619
+ const phase = precondition.phase;
620
+ if (phase !== 'start' && phase !== 'complete')
621
+ invalid(`${field}.phase`, phase, 'start or complete');
622
+ const maximumRecoveryFee = precondition.maximumRecoveryFee, maximumProfileDebit = precondition.maximumProfileDebit;
623
+ for (const value of [maximumRecoveryFee, maximumProfileDebit])
624
+ if (typeof value !== 'bigint' || value < 0n || value > (1n << 64n) - 1n)
625
+ invalid(field, value, 'a nonnegative u64 funding ceiling');
626
+ return Object.freeze({
627
+ kind: 'fleet-respawn',
628
+ address: readAddress(precondition.address, field),
629
+ game: readAddress(precondition.game, field),
630
+ profile: readAddress(precondition.profile, field),
631
+ authority: readAddress(precondition.authority, field),
632
+ system: readAddress(precondition.system, field),
633
+ keyIndex,
634
+ phase,
635
+ fleetHash: readDataHash(precondition.fleetHash, field),
636
+ maximumRecoveryFee: maximumRecoveryFee,
637
+ maximumProfileDebit: maximumProfileDebit,
638
+ describes: readString(precondition.describes, field),
639
+ });
640
+ }
641
+ if (precondition.kind === 'local-market-order')
642
+ return normalizeLocalMarketOrderGuard(precondition);
643
+ if (precondition.kind === 'scan-signal-open') {
644
+ assertKeys(precondition, field, [
645
+ 'kind',
646
+ 'address',
647
+ 'game',
648
+ 'fleet',
649
+ 'profile',
650
+ 'authority',
651
+ 'character',
652
+ 'keyIndex',
653
+ 'authorityHash',
654
+ 'maximumProfileDebit',
655
+ 'describes',
656
+ ]);
657
+ const keyIndex = precondition.keyIndex;
658
+ if (typeof keyIndex !== 'number' ||
659
+ !Number.isInteger(keyIndex) ||
660
+ keyIndex < 0 ||
661
+ keyIndex > 65535)
662
+ invalid(field, keyIndex, 'a u16 key index');
663
+ const maximumProfileDebit = precondition.maximumProfileDebit;
664
+ if (typeof maximumProfileDebit !== 'bigint' ||
665
+ maximumProfileDebit < 0n ||
666
+ maximumProfileDebit > 0xffffffffffffffffn)
667
+ invalid(field, maximumProfileDebit, 'a nonnegative u64 funding ceiling');
668
+ return Object.freeze({
669
+ kind: 'scan-signal-open',
670
+ authorityHash: readDataHash(precondition.authorityHash, field),
671
+ address: readAddress(precondition.address, field),
672
+ game: readAddress(precondition.game, field),
673
+ fleet: readAddress(precondition.fleet, field),
674
+ profile: readAddress(precondition.profile, field),
675
+ authority: readAddress(precondition.authority, field),
676
+ character: readAddress(precondition.character, field),
677
+ keyIndex,
678
+ maximumProfileDebit,
679
+ describes: readString(precondition.describes, field),
680
+ });
681
+ }
682
+ if (precondition.kind === 'fleet-create') {
683
+ assertKeys(precondition, field, [
684
+ 'kind',
685
+ 'address',
686
+ 'game',
687
+ 'profile',
688
+ 'authority',
689
+ 'system',
690
+ 'keyIndex',
691
+ 'label',
692
+ 'maximumProfileDebit',
693
+ 'describes',
694
+ ]);
695
+ const keyIndex = precondition.keyIndex;
696
+ if (typeof keyIndex !== 'number' ||
697
+ !Number.isSafeInteger(keyIndex) ||
698
+ keyIndex < 0 ||
699
+ keyIndex > 65_535)
700
+ invalid(`${field}.keyIndex`, keyIndex, 'an integer from 0 through 65535');
701
+ const label = readString(precondition.label, `${field}.label`);
702
+ const bytes = new TextEncoder().encode(label);
703
+ if (label.trim().length === 0 ||
704
+ label.includes('\0') ||
705
+ bytes.length > 64 ||
706
+ new TextDecoder('utf-8', { ignoreBOM: true }).decode(bytes) !== label)
707
+ invalid(`${field}.label`, label, 'a nonblank, NUL-free Unicode label of at most 64 UTF-8 bytes');
708
+ const maximumProfileDebit = precondition.maximumProfileDebit;
709
+ if (typeof maximumProfileDebit !== 'bigint' || maximumProfileDebit < 0n)
710
+ invalid(`${field}.maximumProfileDebit`, maximumProfileDebit, 'a nonnegative bigint');
711
+ return Object.freeze({
712
+ kind: 'fleet-create',
713
+ address: readAddress(precondition.address, `${field}.address`),
714
+ game: readAddress(precondition.game, `${field}.game`),
715
+ profile: readAddress(precondition.profile, `${field}.profile`),
716
+ authority: readAddress(precondition.authority, `${field}.authority`),
717
+ system: readAddress(precondition.system, `${field}.system`),
718
+ keyIndex,
719
+ label,
720
+ maximumProfileDebit,
721
+ describes: readString(precondition.describes, `${field}.describes`),
722
+ });
723
+ }
724
+ if (precondition.kind === 'system-account-or-absent') {
725
+ assertKeys(precondition, field, ['kind', 'address', 'describes']);
726
+ return Object.freeze({
727
+ kind: 'system-account-or-absent',
728
+ address: readAddress(precondition.address, `${field}.address`),
729
+ describes: readString(precondition.describes, `${field}.describes`),
730
+ });
731
+ }
732
+ if (precondition.kind === 'token-mint') {
733
+ assertKeys(precondition, field, [
734
+ 'kind',
735
+ 'address',
736
+ 'decimals',
737
+ 'describes',
738
+ ]);
739
+ const decimals = precondition.decimals;
740
+ if (typeof decimals !== 'number' ||
741
+ !Number.isInteger(decimals) ||
742
+ decimals < 0 ||
743
+ decimals > 255)
744
+ invalid(`${field}.decimals`, decimals, 'an unsigned u8 mint decimals value');
745
+ return Object.freeze({
746
+ kind: 'token-mint',
747
+ address: readAddress(precondition.address, `${field}.address`),
748
+ decimals,
749
+ describes: readString(precondition.describes, `${field}.describes`),
750
+ });
751
+ }
752
+ if (precondition.kind === 'game-ship-config') {
165
753
  assertKeys(precondition, field, [
166
754
  'kind',
167
755
  'address',
@@ -180,7 +768,7 @@ function normalizePrecondition(value, field, version = 6) {
180
768
  describes: readString(precondition.describes, `${field}.describes`),
181
769
  });
182
770
  }
183
- if (version >= 5 && precondition.kind === 'game-account') {
771
+ if (precondition.kind === 'game-account') {
184
772
  assertKeys(precondition, field, ['kind', 'address', 'describes']);
185
773
  return Object.freeze({
186
774
  kind: 'game-account',
@@ -188,8 +776,7 @@ function normalizePrecondition(value, field, version = 6) {
188
776
  describes: readString(precondition.describes, `${field}.describes`),
189
777
  });
190
778
  }
191
- if (version >= 4 &&
192
- ['token-account', 'game-cargo-config', 'cargo-cache'].includes(String(precondition.kind))) {
779
+ if (['game-cargo-bytes-config', 'token-account', 'cargo-cache'].includes(String(precondition.kind))) {
193
780
  const base = {
194
781
  address: readAddress(precondition.address, `${field}.address`),
195
782
  describes: readString(precondition.describes, `${field}.describes`),
@@ -216,7 +803,7 @@ function normalizePrecondition(value, field, version = 6) {
216
803
  minimumBalance: amount,
217
804
  });
218
805
  }
219
- if (precondition.kind === 'game-cargo-config') {
806
+ if (precondition.kind === 'game-cargo-bytes-config') {
220
807
  assertKeys(precondition, field, [
221
808
  'kind',
222
809
  'address',
@@ -232,7 +819,7 @@ function normalizePrecondition(value, field, version = 6) {
232
819
  invalid(`${field}.cargoId`, id, 'a u16 cargo ID');
233
820
  return Object.freeze({
234
821
  ...base,
235
- kind: 'game-cargo-config',
822
+ kind: precondition.kind,
236
823
  cargoId: id,
237
824
  configHash: readDataHash(precondition.configHash, `${field}.configHash`),
238
825
  });
@@ -257,7 +844,7 @@ function normalizePrecondition(value, field, version = 6) {
257
844
  bump,
258
845
  });
259
846
  }
260
- if (precondition.kind === 'token-account-or-absent' && version >= 3) {
847
+ if (precondition.kind === 'token-account-or-absent') {
261
848
  assertKeys(precondition, field, [
262
849
  'kind',
263
850
  'address',
@@ -273,7 +860,7 @@ function normalizePrecondition(value, field, version = 6) {
273
860
  describes: readString(precondition.describes, `${field}.describes`),
274
861
  });
275
862
  }
276
- if (precondition.kind === 'account-absent' && version !== 1) {
863
+ if (precondition.kind === 'account-absent') {
277
864
  assertKeys(precondition, field, ['kind', 'address', 'describes']);
278
865
  return Object.freeze({
279
866
  kind: 'account-absent',
@@ -282,17 +869,7 @@ function normalizePrecondition(value, field, version = 6) {
282
869
  });
283
870
  }
284
871
  if (precondition.kind !== 'account-state') {
285
- invalid(`${field}.kind`, precondition.kind, version === 6
286
- ? 'one of account-state, account-absent, token-account-or-absent, token-account, game-cargo-config, cargo-cache, game-account, or game-ship-config'
287
- : version === 5
288
- ? 'one of account-state, account-absent, token-account-or-absent, token-account, game-cargo-config, cargo-cache, or game-account'
289
- : version === 4
290
- ? 'one of account-state, account-absent, token-account-or-absent, token-account, game-cargo-config, or cargo-cache'
291
- : version === 3
292
- ? 'one of account-state, account-absent, or token-account-or-absent'
293
- : version === 2
294
- ? 'one of account-state or account-absent'
295
- : 'the value account-state');
872
+ invalid(`${field}.kind`, precondition.kind, 'a supported current Plan guard; recreate the Plan using the current capability planner');
296
873
  }
297
874
  assertKeys(precondition, field, ['kind', 'address', 'dataHash', 'describes']);
298
875
  return Object.freeze({
@@ -328,84 +905,74 @@ function instructionToJSON(instruction) {
328
905
  return deepFreeze(value);
329
906
  }
330
907
  function planToJSON(plan) {
331
- const hasSemantics = plan.steps.some((step) => (step.semantics?.length ?? 0) > 0);
332
- const hasAbsentPrecondition = plan.preconditions.some(({ kind }) => kind === 'account-absent');
333
- const common = {
908
+ return deepFreeze({
909
+ v: 25,
334
910
  kind: plan.kind,
335
911
  summary: plan.summary,
336
912
  affected: [...plan.affected],
337
913
  requiredSigners: [...plan.requiredSigners],
338
- };
339
- const steps = plan.steps.map((step) => ({
340
- instruction: instructionToJSON(step.instruction),
341
- describes: step.describes,
342
- ...((step.semantics?.length ?? 0) > 0
343
- ? { semantics: step.semantics.map((semantic) => ({ ...semantic })) }
344
- : {}),
345
- signers: [...step.signers],
346
- }));
347
- if (plan.preconditions.some(({ kind }) => kind === 'game-ship-config')) {
348
- return deepFreeze({
349
- v: 6,
350
- ...common,
351
- steps,
352
- preconditions: plan.preconditions.map((guard) => guard.kind === 'token-account'
353
- ? { ...guard, minimumBalance: String(guard.minimumBalance) }
354
- : { ...guard }),
355
- });
356
- }
357
- if (plan.preconditions.some(({ kind }) => kind === 'game-account')) {
358
- return deepFreeze({
359
- v: 5,
360
- ...common,
361
- steps,
362
- preconditions: plan.preconditions.map((guard) => guard.kind === 'token-account'
363
- ? { ...guard, minimumBalance: String(guard.minimumBalance) }
364
- : { ...guard }),
365
- });
366
- }
367
- if (plan.preconditions.some(({ kind }) => kind === 'token-account' ||
368
- kind === 'game-cargo-config' ||
369
- kind === 'cargo-cache')) {
370
- return deepFreeze({
371
- v: 4,
372
- ...common,
373
- steps,
374
- preconditions: plan.preconditions.map((guard) => guard.kind === 'token-account'
375
- ? { ...guard, minimumBalance: String(guard.minimumBalance) }
376
- : { ...guard }),
377
- });
378
- }
379
- if (plan.preconditions.some(({ kind }) => kind === 'token-account-or-absent')) {
380
- return deepFreeze({
381
- v: 3,
382
- ...common,
383
- steps,
384
- preconditions: plan.preconditions.map((guard) => ({
385
- ...guard,
386
- })),
387
- });
388
- }
389
- if (hasSemantics || hasAbsentPrecondition) {
390
- return deepFreeze({
391
- v: 2,
392
- ...common,
393
- steps,
394
- preconditions: plan.preconditions.map((guard) => ({
395
- ...guard,
396
- })),
397
- });
398
- }
399
- return deepFreeze({
400
- v: 1,
401
- ...common,
402
- steps,
403
- preconditions: plan.preconditions.map((precondition) => ({
404
- kind: 'account-state',
405
- address: precondition.address,
406
- dataHash: precondition.dataHash,
407
- describes: precondition.describes,
914
+ steps: plan.steps.map((step) => ({
915
+ instruction: instructionToJSON(step.instruction),
916
+ describes: step.describes,
917
+ ...((step.semantics?.length ?? 0) > 0
918
+ ? { semantics: step.semantics.map((semantic) => ({ ...semantic })) }
919
+ : {}),
920
+ signers: [...step.signers],
408
921
  })),
922
+ preconditions: plan.preconditions.map((guard) => {
923
+ if (guard.kind === 'scan-detect' || guard.kind === 'scan-completion')
924
+ return { ...guard, expectedSequence: String(guard.expectedSequence) };
925
+ if (guard.kind === 'fleet-arrival')
926
+ return arrivalGuardToJSON(guard);
927
+ if (guard.kind === 'fleet-crew-transfer')
928
+ return { ...guard, systemSequenceId: String(guard.systemSequenceId) };
929
+ if (guard.kind === 'fleet-respawn')
930
+ return {
931
+ ...guard,
932
+ maximumRecoveryFee: String(guard.maximumRecoveryFee),
933
+ maximumProfileDebit: String(guard.maximumProfileDebit),
934
+ };
935
+ if (isRuntimeGuard(guard))
936
+ return runtimeGuardToJSON(guard);
937
+ if (isTradeBuyGuard(guard))
938
+ return { ...guard, floorRaw: String(guard.floorRaw) };
939
+ if (isTradeSellGuard(guard))
940
+ return {
941
+ ...guard,
942
+ atlasOutCapPerEpochRaw: String(guard.atlasOutCapPerEpochRaw),
943
+ epochLengthSeconds: String(guard.epochLengthSeconds),
944
+ };
945
+ if (guard.kind === 'fleet-add-ship')
946
+ return {
947
+ ...guard,
948
+ amount: String(guard.amount),
949
+ maximumProfileDebit: String(guard.maximumProfileDebit),
950
+ };
951
+ if (guard.kind === 'character-registration')
952
+ return {
953
+ ...guard,
954
+ maximumFunderDebit: String(guard.maximumFunderDebit),
955
+ characterLamports: String(guard.characterLamports),
956
+ budgetLamports: String(guard.budgetLamports),
957
+ };
958
+ if (guard.kind === 'scan-signal-open' ||
959
+ guard.kind === 'fleet-create' ||
960
+ guard.kind === 'ship-import-funding')
961
+ return {
962
+ ...guard,
963
+ maximumProfileDebit: String(guard.maximumProfileDebit),
964
+ };
965
+ if (guard.kind === 'starbase-system')
966
+ return {
967
+ ...guard,
968
+ starbaseSequenceId: String(guard.starbaseSequenceId),
969
+ };
970
+ if (guard.kind === 'local-market-order')
971
+ return localMarketOrderGuardToJSON(guard);
972
+ if (guard.kind === 'token-account')
973
+ return { ...guard, minimumBalance: String(guard.minimumBalance) };
974
+ return { ...guard };
975
+ }),
409
976
  });
410
977
  }
411
978
  /** Creates an inert branded Plan while deriving every aggregate field.
@@ -427,6 +994,14 @@ export function createPlan(input) {
427
994
  assertKeys(value, 'plan', ['kind', 'summary', 'steps', 'preconditions']);
428
995
  const steps = Object.freeze(readArray(value.steps, 'plan.steps').map((step, index) => normalizeStep(step, `plan.steps[${String(index)}]`)));
429
996
  const preconditions = Object.freeze(readArray(value.preconditions, 'plan.preconditions').map((precondition, index) => normalizePrecondition(precondition, `plan.preconditions[${String(index)}]`)));
997
+ validateShipImportFundingComposition(preconditions);
998
+ validateStarbaseSystemGuards(steps, preconditions);
999
+ validateDetectInstructions(steps, preconditions);
1000
+ validateCompletionInstructions(steps, preconditions);
1001
+ validateRespawnInstructions(steps, preconditions);
1002
+ validateCrewTransferInstructions(steps, preconditions);
1003
+ validateOpenSignalInstructions(steps, preconditions);
1004
+ validateLocalMarketOrderInstructions(steps, preconditions);
430
1005
  const descriptions = Object.freeze(steps.map((step) => step.describes));
431
1006
  const plan = {
432
1007
  kind: readString(value.kind, 'plan.kind'),
@@ -438,7 +1013,6 @@ export function createPlan(input) {
438
1013
  describe: () => descriptions,
439
1014
  toJSON: () => planToJSON(plan),
440
1015
  };
441
- Object.defineProperty(plan, PLAN_BRAND, { value: true });
442
1016
  registerPlanInstance(plan);
443
1017
  return Object.freeze(plan);
444
1018
  }
@@ -473,7 +1047,7 @@ function sameAddresses(actual, encoded) {
473
1047
  *
474
1048
  * @example
475
1049
  * ```ts
476
- * declare const wire: PlanJsonV1 | PlanJsonV2 | PlanJsonV3 | PlanJsonV4 | PlanJsonV5 | PlanJsonV6;
1050
+ * declare const wire: PlanJson;
477
1051
  * const plan = planFromJSON(wire);
478
1052
  * console.log(plan.describe());
479
1053
  * ```
@@ -489,34 +1063,114 @@ export function planFromJSON(json) {
489
1063
  'affected',
490
1064
  'requiredSigners',
491
1065
  ]);
492
- if (value.v !== 1 &&
493
- value.v !== 2 &&
494
- value.v !== 3 &&
495
- value.v !== 4 &&
496
- value.v !== 5 &&
497
- value.v !== 6) {
498
- invalid('planJson.v', value.v, 'the Plan wire version 1, 2, 3, 4, 5, or 6');
499
- }
500
- const version = value.v;
501
- if (version >= 4 && Array.isArray(value.preconditions)) {
502
- value.preconditions = value.preconditions.map((entry) => {
503
- const guard = readRecord(entry, 'precondition');
504
- if (guard.kind !== 'token-account')
505
- return guard;
506
- if (typeof guard.minimumBalance !== 'string' ||
507
- !/^(0|[1-9][0-9]*)$/.test(guard.minimumBalance))
508
- invalid('minimumBalance', guard.minimumBalance, 'a canonical unsigned decimal string');
509
- return { ...guard, minimumBalance: BigInt(guard.minimumBalance) };
510
- });
1066
+ if (value.v !== 25) {
1067
+ throw new InvalidActionInputError('planJson.v', value.v, 'the current Plan wire version 25', 'Recreate the Plan using the current capability planner; do not change its saved version or migrate its guards.');
511
1068
  }
1069
+ value.preconditions = readArray(value.preconditions, 'planJson.preconditions').map((entry) => {
1070
+ const guard = readRecord(entry, 'precondition');
1071
+ if (guard.kind === 'local-market-order')
1072
+ return normalizeLocalMarketOrderGuard(guard, true);
1073
+ if (guard.kind === 'scan-detect' || guard.kind === 'scan-completion') {
1074
+ if (typeof guard.expectedSequence !== 'string' ||
1075
+ !/^(0|[1-9][0-9]*)$/.test(guard.expectedSequence))
1076
+ invalid('expectedSequence', guard.expectedSequence, 'a canonical unsigned decimal string');
1077
+ return { ...guard, expectedSequence: BigInt(guard.expectedSequence) };
1078
+ }
1079
+ if (guard.kind === 'fleet-arrival')
1080
+ return normalizeArrivalGuard(guard, 'precondition', true);
1081
+ if (isRuntimeGuard(guard))
1082
+ return normalizeRuntimeGuard(guard, 'precondition', true);
1083
+ if (isTradeBuyGuard(guard) || isTradeSellGuard(guard)) {
1084
+ const keys = isTradeBuyGuard(guard)
1085
+ ? ['floorRaw']
1086
+ : ['atlasOutCapPerEpochRaw', 'epochLengthSeconds'];
1087
+ const decoded = { ...guard };
1088
+ for (const key of keys) {
1089
+ const raw = guard[key];
1090
+ const pattern = key === 'epochLengthSeconds'
1091
+ ? /^(0|[1-9][0-9]*|-[1-9][0-9]*)$/
1092
+ : /^(0|[1-9][0-9]*)$/;
1093
+ if (typeof raw !== 'string' || !pattern.test(raw))
1094
+ invalid(key, raw, 'a canonical decimal string');
1095
+ decoded[key] = BigInt(raw);
1096
+ }
1097
+ return decoded;
1098
+ }
1099
+ if (guard.kind === 'fleet-add-ship') {
1100
+ for (const field of ['amount', 'maximumProfileDebit'])
1101
+ if (typeof guard[field] !== 'string' ||
1102
+ !/^(0|[1-9][0-9]*)$/.test(guard[field]))
1103
+ invalid(field, guard[field], 'a canonical unsigned decimal string');
1104
+ return {
1105
+ ...guard,
1106
+ amount: BigInt(guard.amount),
1107
+ maximumProfileDebit: BigInt(guard.maximumProfileDebit),
1108
+ };
1109
+ }
1110
+ if (guard.kind === 'character-registration') {
1111
+ for (const key of ['characterLamports', 'budgetLamports'])
1112
+ if (typeof guard[key] !== 'string' ||
1113
+ !/^(0|[1-9][0-9]*)$/.test(guard[key]))
1114
+ invalid(key, guard[key], 'a canonical unsigned decimal string');
1115
+ if (typeof guard.maximumFunderDebit !== 'string' ||
1116
+ !/^(0|[1-9][0-9]*)$/.test(guard.maximumFunderDebit))
1117
+ invalid('maximumFunderDebit', guard.maximumFunderDebit, 'a canonical unsigned decimal string');
1118
+ return {
1119
+ ...guard,
1120
+ maximumFunderDebit: BigInt(guard.maximumFunderDebit),
1121
+ characterLamports: BigInt(guard.characterLamports),
1122
+ budgetLamports: BigInt(guard.budgetLamports),
1123
+ };
1124
+ }
1125
+ if (guard.kind === 'fleet-crew-transfer') {
1126
+ if (typeof guard.systemSequenceId !== 'string' ||
1127
+ !/^(0|[1-9][0-9]*)$/.test(guard.systemSequenceId))
1128
+ invalid('systemSequenceId', guard.systemSequenceId, 'a canonical unsigned decimal string');
1129
+ return { ...guard, systemSequenceId: BigInt(guard.systemSequenceId) };
1130
+ }
1131
+ if (guard.kind === 'fleet-respawn') {
1132
+ for (const key of ['maximumRecoveryFee', 'maximumProfileDebit'])
1133
+ if (typeof guard[key] !== 'string' ||
1134
+ !/^(0|[1-9][0-9]*)$/.test(guard[key]))
1135
+ invalid(key, guard[key], 'a canonical unsigned decimal string');
1136
+ return {
1137
+ ...guard,
1138
+ maximumRecoveryFee: BigInt(guard.maximumRecoveryFee),
1139
+ maximumProfileDebit: BigInt(guard.maximumProfileDebit),
1140
+ };
1141
+ }
1142
+ if (guard.kind === 'scan-signal-open' ||
1143
+ guard.kind === 'fleet-create' ||
1144
+ guard.kind === 'ship-import-funding') {
1145
+ if (typeof guard.maximumProfileDebit !== 'string' ||
1146
+ !/^(0|[1-9][0-9]*)$/.test(guard.maximumProfileDebit))
1147
+ invalid('maximumProfileDebit', guard.maximumProfileDebit, 'a canonical unsigned decimal string');
1148
+ return {
1149
+ ...guard,
1150
+ maximumProfileDebit: BigInt(guard.maximumProfileDebit),
1151
+ };
1152
+ }
1153
+ if (guard.kind === 'starbase-system') {
1154
+ if (typeof guard.starbaseSequenceId !== 'string' ||
1155
+ !/^(0|[1-9][0-9]*)$/.test(guard.starbaseSequenceId))
1156
+ invalid('starbaseSequenceId', guard.starbaseSequenceId, 'a canonical unsigned decimal string');
1157
+ return { ...guard, starbaseSequenceId: BigInt(guard.starbaseSequenceId) };
1158
+ }
1159
+ if (guard.kind !== 'token-account')
1160
+ return guard;
1161
+ if (typeof guard.minimumBalance !== 'string' ||
1162
+ !/^(0|[1-9][0-9]*)$/.test(guard.minimumBalance))
1163
+ invalid('minimumBalance', guard.minimumBalance, 'a canonical unsigned decimal string');
1164
+ return { ...guard, minimumBalance: BigInt(guard.minimumBalance) };
1165
+ });
512
1166
  const steps = readArray(value.steps, 'planJson.steps').map((candidate, index) => {
513
1167
  const field = `planJson.steps[${String(index)}]`;
514
1168
  const step = readRecord(candidate, field);
515
- assertKeys(step, field, ['instruction', 'describes', 'signers'], version !== 1 ? ['semantics'] : []);
1169
+ assertKeys(step, field, ['instruction', 'describes', 'signers'], ['semantics']);
516
1170
  return {
517
1171
  instruction: readWireInstruction(step.instruction, `${field}.instruction`),
518
1172
  describes: readString(step.describes, `${field}.describes`),
519
- ...(version !== 1 && step.semantics !== undefined
1173
+ ...(step.semantics !== undefined
520
1174
  ? {
521
1175
  semantics: readArray(step.semantics, `${field}.semantics`).map((semantic, semanticIndex) => normalizeSemanticFact(semantic, `${field}.semantics[${String(semanticIndex)}]`)),
522
1176
  }
@@ -524,7 +1178,7 @@ export function planFromJSON(json) {
524
1178
  signers: readArray(step.signers, `${field}.signers`).map((signer, signerIndex) => readAddress(signer, `${field}.signers[${String(signerIndex)}]`)),
525
1179
  };
526
1180
  });
527
- const preconditions = readArray(value.preconditions, 'planJson.preconditions').map((candidate, index) => normalizePrecondition(candidate, `planJson.preconditions[${String(index)}]`, version));
1181
+ const preconditions = readArray(value.preconditions, 'planJson.preconditions').map((candidate, index) => normalizePrecondition(candidate, `planJson.preconditions[${String(index)}]`));
528
1182
  const affected = readArray(value.affected, 'planJson.affected').map((candidate, index) => readAddress(candidate, `planJson.affected[${String(index)}]`));
529
1183
  const requiredSigners = readArray(value.requiredSigners, 'planJson.requiredSigners').map((candidate, index) => readAddress(candidate, `planJson.requiredSigners[${String(index)}]`));
530
1184
  const plan = createPlan({
@@ -533,6 +1187,10 @@ export function planFromJSON(json) {
533
1187
  steps,
534
1188
  preconditions,
535
1189
  });
1190
+ validateStarbaseSystemInstructions(plan.steps, plan.preconditions);
1191
+ validateMovementXpInstructions(plan.steps, plan.preconditions);
1192
+ validateFleetAttackInstructions(plan.steps, plan.preconditions);
1193
+ validateCharacterRegistrationInstructions(plan.steps, plan.preconditions);
536
1194
  if (!sameAddresses(plan.affected, affected)) {
537
1195
  invalid('planJson.affected', value.affected, 'the first-seen union of writable instruction account addresses');
538
1196
  }
@@ -549,6 +1207,49 @@ function assertPlan(value, index) {
549
1207
  function combinedSummary(steps) {
550
1208
  return steps.map((step) => step.describes).join(' ');
551
1209
  }
1210
+ function validateShipImportFundingComposition(guards) {
1211
+ const targets = new Map();
1212
+ for (const guard of guards) {
1213
+ if (guard.kind !== 'ship-import-funding')
1214
+ continue;
1215
+ const identity = `${guard.game}:${guard.profile}:${guard.system}:${String(guard.shipId)}`;
1216
+ const previous = targets.get(guard.address);
1217
+ if (previous !== undefined && previous !== identity)
1218
+ throw new SageSdkError('INCOMPATIBLE_PLAN_COMPOSITION', 'Ship imports retain conflicting identities or different configurations for one StarbasePlayer. Use separate confirmed imports, then refresh inventory and replan; prefunding cannot be shared across independently estimated storage growth.');
1219
+ targets.set(guard.address, identity);
1220
+ }
1221
+ }
1222
+ function validateFactionGuardComposition(guards) {
1223
+ const retained = new Map();
1224
+ for (const guard of guards) {
1225
+ if (!isFactionTradeGuard(guard))
1226
+ continue;
1227
+ const constraints = [
1228
+ [
1229
+ `${isTradeMeterGuard(guard) ? 'meter' : 'treasury'}:${guard.address}:identity`,
1230
+ `${guard.game}:${String(guard.factionId)}`,
1231
+ ],
1232
+ ];
1233
+ if (!isTradeMeterGuard(guard)) {
1234
+ constraints.push(isTradeBuyGuard(guard)
1235
+ ? [
1236
+ `${guard.address}:buy:${String(guard.cargoId)}`,
1237
+ String(guard.floorRaw),
1238
+ ]
1239
+ : [
1240
+ `${guard.address}:sell`,
1241
+ `${String(guard.atlasOutCapPerEpochRaw)}:${String(guard.epochLengthSeconds)}`,
1242
+ ]);
1243
+ }
1244
+ constraints.push([`${guard.address}:schema`, String(guard.schemaVersion)]);
1245
+ for (const [key, value] of constraints) {
1246
+ const previous = retained.get(key);
1247
+ if (previous !== undefined && previous !== value)
1248
+ throw new SageSdkError('INCOMPATIBLE_PLAN_COMPOSITION', 'Faction Market Plans retain incompatible Treasury policy or shared account identity. Refresh the affected Markets and prepare compatible Plans, or use separate confirmed transactions.');
1249
+ retained.set(key, value);
1250
+ }
1251
+ }
1252
+ }
552
1253
  /** Combines one or more Plans with deterministic associative flattening.
553
1254
  *
554
1255
  * Semantic validation is eager. Conflict indices are relative to the flattened
@@ -569,11 +1270,26 @@ export function combinePlans(...plans) {
569
1270
  plans.forEach(assertPlan);
570
1271
  const steps = plans.flatMap((plan) => plan.steps);
571
1272
  validatePlanComposition(steps);
1273
+ const preconditions = plans.flatMap((plan) => plan.preconditions);
1274
+ validateFactionGuardComposition(preconditions);
1275
+ validateMiningStopInstructions(steps, preconditions);
1276
+ validateStarbaseSystemInstructions(steps, preconditions);
1277
+ validateCharacterRegistrationInstructions(steps, preconditions);
1278
+ validateArrivalInstructions(steps, preconditions);
1279
+ validateDetectInstructions(steps, preconditions);
1280
+ validateCompletionInstructions(steps, preconditions);
1281
+ validateRespawnInstructions(steps, preconditions);
1282
+ validateCrewTransferInstructions(steps, preconditions);
1283
+ validateOpenSignalInstructions(steps, preconditions);
1284
+ validateLocalMarketOrderInstructions(steps, preconditions);
1285
+ validateRuntimeInstructions(steps, preconditions);
1286
+ validateMovementXpInstructions(steps, preconditions);
1287
+ validateFleetAttackInstructions(steps, preconditions);
572
1288
  return createPlan({
573
1289
  kind: 'combined',
574
1290
  summary: combinedSummary(steps),
575
1291
  steps,
576
- preconditions: plans.flatMap((plan) => plan.preconditions),
1292
+ preconditions,
577
1293
  });
578
1294
  }
579
1295
  export { assemblePlan } from './assembly.js';