@aephia/atlas-kit 0.6.0-next.7 → 0.6.0-next.71

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 (501) 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 +87 -37
  19. package/dist/claim-stakes/actions/index.js.map +1 -1
  20. package/dist/client/contracts.d.ts +16 -6
  21. package/dist/client/contracts.d.ts.map +1 -1
  22. package/dist/client/errors.d.ts +6 -2
  23. package/dist/client/errors.d.ts.map +1 -1
  24. package/dist/client/errors.js +31 -1
  25. package/dist/client/errors.js.map +1 -1
  26. package/dist/client/index.d.ts +1 -0
  27. package/dist/client/index.d.ts.map +1 -1
  28. package/dist/client/index.js +1 -0
  29. package/dist/client/index.js.map +1 -1
  30. package/dist/client/rpc-subscription-provider.d.ts +35 -0
  31. package/dist/client/rpc-subscription-provider.d.ts.map +1 -0
  32. package/dist/client/rpc-subscription-provider.js +190 -0
  33. package/dist/client/rpc-subscription-provider.js.map +1 -0
  34. package/dist/combat/actions/index.d.ts.map +1 -1
  35. package/dist/combat/actions/index.js +98 -50
  36. package/dist/combat/actions/index.js.map +1 -1
  37. package/dist/crafting/actions/index.d.ts.map +1 -1
  38. package/dist/crafting/actions/index.js +49 -29
  39. package/dist/crafting/actions/index.js.map +1 -1
  40. package/dist/crafting/index.d.ts +24 -2
  41. package/dist/crafting/index.d.ts.map +1 -1
  42. package/dist/crafting/index.js +31 -2
  43. package/dist/crafting/index.js.map +1 -1
  44. package/dist/factions/actions/index.d.ts +1 -0
  45. package/dist/factions/actions/index.d.ts.map +1 -1
  46. package/dist/factions/actions/index.js.map +1 -1
  47. package/dist/factions/index.d.ts +1 -1
  48. package/dist/factions/index.d.ts.map +1 -1
  49. package/dist/factions/index.js +1 -1
  50. package/dist/factions/index.js.map +1 -1
  51. package/dist/factions/profile-faction.d.ts +20 -8
  52. package/dist/factions/profile-faction.d.ts.map +1 -1
  53. package/dist/factions/profile-faction.js +20 -8
  54. package/dist/factions/profile-faction.js.map +1 -1
  55. package/dist/fleets/actions/add-ship.d.ts +35 -0
  56. package/dist/fleets/actions/add-ship.d.ts.map +1 -0
  57. package/dist/fleets/actions/add-ship.js +149 -0
  58. package/dist/fleets/actions/add-ship.js.map +1 -0
  59. package/dist/fleets/actions/create-fleet.d.ts +36 -0
  60. package/dist/fleets/actions/create-fleet.d.ts.map +1 -0
  61. package/dist/fleets/actions/create-fleet.js +138 -0
  62. package/dist/fleets/actions/create-fleet.js.map +1 -0
  63. package/dist/fleets/actions/crew-transfer.d.ts +41 -0
  64. package/dist/fleets/actions/crew-transfer.d.ts.map +1 -0
  65. package/dist/fleets/actions/crew-transfer.js +114 -0
  66. package/dist/fleets/actions/crew-transfer.js.map +1 -0
  67. package/dist/fleets/actions/index.d.ts +34 -15
  68. package/dist/fleets/actions/index.d.ts.map +1 -1
  69. package/dist/fleets/actions/index.js +168 -109
  70. package/dist/fleets/actions/index.js.map +1 -1
  71. package/dist/fleets/actions/respawn.d.ts +38 -0
  72. package/dist/fleets/actions/respawn.d.ts.map +1 -0
  73. package/dist/fleets/actions/respawn.js +122 -0
  74. package/dist/fleets/actions/respawn.js.map +1 -0
  75. package/dist/fleets/actions/ship-import.d.ts +48 -0
  76. package/dist/fleets/actions/ship-import.d.ts.map +1 -0
  77. package/dist/fleets/actions/ship-import.js +330 -0
  78. package/dist/fleets/actions/ship-import.js.map +1 -0
  79. package/dist/fleets/cooldown.d.ts +44 -0
  80. package/dist/fleets/cooldown.d.ts.map +1 -0
  81. package/dist/fleets/cooldown.js +43 -0
  82. package/dist/fleets/cooldown.js.map +1 -0
  83. package/dist/fleets/coordinate-warp-estimate.d.ts +70 -0
  84. package/dist/fleets/coordinate-warp-estimate.d.ts.map +1 -0
  85. package/dist/fleets/coordinate-warp-estimate.js +46 -0
  86. package/dist/fleets/coordinate-warp-estimate.js.map +1 -0
  87. package/dist/fleets/index.d.ts +5 -0
  88. package/dist/fleets/index.d.ts.map +1 -1
  89. package/dist/fleets/index.js +5 -0
  90. package/dist/fleets/index.js.map +1 -1
  91. package/dist/fleets/movement-arithmetic.d.ts +21 -0
  92. package/dist/fleets/movement-arithmetic.d.ts.map +1 -0
  93. package/dist/fleets/movement-arithmetic.js +41 -0
  94. package/dist/fleets/movement-arithmetic.js.map +1 -0
  95. package/dist/fleets/subwarp-estimate.d.ts +70 -0
  96. package/dist/fleets/subwarp-estimate.d.ts.map +1 -0
  97. package/dist/fleets/subwarp-estimate.js +38 -0
  98. package/dist/fleets/subwarp-estimate.js.map +1 -0
  99. package/dist/fleets/warp-lane-estimate.d.ts +59 -0
  100. package/dist/fleets/warp-lane-estimate.d.ts.map +1 -0
  101. package/dist/fleets/warp-lane-estimate.js +36 -0
  102. package/dist/fleets/warp-lane-estimate.js.map +1 -0
  103. package/dist/fleets/warp-lane-toll.d.ts +55 -0
  104. package/dist/fleets/warp-lane-toll.d.ts.map +1 -0
  105. package/dist/fleets/warp-lane-toll.js +79 -0
  106. package/dist/fleets/warp-lane-toll.js.map +1 -0
  107. package/dist/identity/actions/create-profile.d.ts +56 -0
  108. package/dist/identity/actions/create-profile.d.ts.map +1 -0
  109. package/dist/identity/actions/create-profile.js +139 -0
  110. package/dist/identity/actions/create-profile.js.map +1 -0
  111. package/dist/identity/actions/index.d.ts +4 -3
  112. package/dist/identity/actions/index.d.ts.map +1 -1
  113. package/dist/identity/actions/index.js +49 -27
  114. package/dist/identity/actions/index.js.map +1 -1
  115. package/dist/identity/index.d.ts +15 -0
  116. package/dist/identity/index.d.ts.map +1 -1
  117. package/dist/identity/index.js +15 -0
  118. package/dist/identity/index.js.map +1 -1
  119. package/dist/identity/permissions.d.ts +124 -0
  120. package/dist/identity/permissions.d.ts.map +1 -0
  121. package/dist/identity/permissions.js +171 -0
  122. package/dist/identity/permissions.js.map +1 -0
  123. package/dist/index.d.ts +23 -0
  124. package/dist/index.d.ts.map +1 -1
  125. package/dist/index.js +18 -1
  126. package/dist/index.js.map +1 -1
  127. package/dist/internal/c4/cargo-bytes-config.d.ts +7 -0
  128. package/dist/internal/c4/cargo-bytes-config.d.ts.map +1 -0
  129. package/dist/internal/c4/cargo-bytes-config.js +19 -0
  130. package/dist/internal/c4/cargo-bytes-config.js.map +1 -0
  131. package/dist/internal/c4/character-registration.d.ts +2 -0
  132. package/dist/internal/c4/character-registration.d.ts.map +1 -1
  133. package/dist/internal/c4/character-registration.js +2 -0
  134. package/dist/internal/c4/character-registration.js.map +1 -1
  135. package/dist/internal/c4/claim-stake.d.ts +0 -27
  136. package/dist/internal/c4/claim-stake.d.ts.map +1 -1
  137. package/dist/internal/c4/claim-stake.js +0 -33
  138. package/dist/internal/c4/claim-stake.js.map +1 -1
  139. package/dist/internal/c4/combat.d.ts +0 -27
  140. package/dist/internal/c4/combat.d.ts.map +1 -1
  141. package/dist/internal/c4/combat.js +0 -33
  142. package/dist/internal/c4/combat.js.map +1 -1
  143. package/dist/internal/c4/crafting-process-codec.d.ts +13 -0
  144. package/dist/internal/c4/crafting-process-codec.d.ts.map +1 -0
  145. package/dist/internal/c4/crafting-process-codec.js +34 -0
  146. package/dist/internal/c4/crafting-process-codec.js.map +1 -0
  147. package/dist/internal/c4/crafting.d.ts +11 -31
  148. package/dist/internal/c4/crafting.d.ts.map +1 -1
  149. package/dist/internal/c4/crafting.js +26 -43
  150. package/dist/internal/c4/crafting.js.map +1 -1
  151. package/dist/internal/c4/faction-adapter.d.ts +12 -0
  152. package/dist/internal/c4/faction-adapter.d.ts.map +1 -0
  153. package/dist/internal/c4/faction-adapter.js +52 -0
  154. package/dist/internal/c4/faction-adapter.js.map +1 -0
  155. package/dist/internal/c4/faction-epoch-meter.d.ts +10 -0
  156. package/dist/internal/c4/faction-epoch-meter.d.ts.map +1 -0
  157. package/dist/internal/c4/faction-epoch-meter.js +31 -0
  158. package/dist/internal/c4/faction-epoch-meter.js.map +1 -0
  159. package/dist/internal/c4/faction-treasury.d.ts +23 -0
  160. package/dist/internal/c4/faction-treasury.d.ts.map +1 -0
  161. package/dist/internal/c4/faction-treasury.js +48 -0
  162. package/dist/internal/c4/faction-treasury.js.map +1 -0
  163. package/dist/internal/c4/factions.d.ts +9 -57
  164. package/dist/internal/c4/factions.d.ts.map +1 -1
  165. package/dist/internal/c4/factions.js +21 -139
  166. package/dist/internal/c4/factions.js.map +1 -1
  167. package/dist/internal/c4/fleet-arrival.d.ts +28 -0
  168. package/dist/internal/c4/fleet-arrival.d.ts.map +1 -0
  169. package/dist/internal/c4/fleet-arrival.js +42 -0
  170. package/dist/internal/c4/fleet-arrival.js.map +1 -0
  171. package/dist/internal/c4/fleet-creation.d.ts +7 -0
  172. package/dist/internal/c4/fleet-creation.d.ts.map +1 -0
  173. package/dist/internal/c4/fleet-creation.js +180 -0
  174. package/dist/internal/c4/fleet-creation.js.map +1 -0
  175. package/dist/internal/c4/fleet-crew-binding.d.ts +9 -0
  176. package/dist/internal/c4/fleet-crew-binding.d.ts.map +1 -1
  177. package/dist/internal/c4/fleet-crew-binding.js +15 -0
  178. package/dist/internal/c4/fleet-crew-binding.js.map +1 -1
  179. package/dist/internal/c4/fleet-respawn.d.ts +19 -0
  180. package/dist/internal/c4/fleet-respawn.d.ts.map +1 -0
  181. package/dist/internal/c4/fleet-respawn.js +91 -0
  182. package/dist/internal/c4/fleet-respawn.js.map +1 -0
  183. package/dist/internal/c4/fleet-ship-assembly.d.ts +11 -0
  184. package/dist/internal/c4/fleet-ship-assembly.d.ts.map +1 -0
  185. package/dist/internal/c4/fleet-ship-assembly.js +44 -0
  186. package/dist/internal/c4/fleet-ship-assembly.js.map +1 -0
  187. package/dist/internal/c4/fleet.d.ts +43 -19
  188. package/dist/internal/c4/fleet.d.ts.map +1 -1
  189. package/dist/internal/c4/fleet.js +1 -0
  190. package/dist/internal/c4/fleet.js.map +1 -1
  191. package/dist/internal/c4/game.d.ts +31 -8
  192. package/dist/internal/c4/game.d.ts.map +1 -1
  193. package/dist/internal/c4/game.js +88 -12
  194. package/dist/internal/c4/game.js.map +1 -1
  195. package/dist/internal/c4/identity.d.ts +2 -7
  196. package/dist/internal/c4/identity.d.ts.map +1 -1
  197. package/dist/internal/c4/identity.js +2 -23
  198. package/dist/internal/c4/identity.js.map +1 -1
  199. package/dist/internal/c4/loyalty.d.ts +0 -27
  200. package/dist/internal/c4/loyalty.d.ts.map +1 -1
  201. package/dist/internal/c4/loyalty.js +0 -33
  202. package/dist/internal/c4/loyalty.js.map +1 -1
  203. package/dist/internal/c4/market.d.ts +1 -37
  204. package/dist/internal/c4/market.d.ts.map +1 -1
  205. package/dist/internal/c4/market.js +11 -49
  206. package/dist/internal/c4/market.js.map +1 -1
  207. package/dist/internal/c4/mining-instructions.d.ts +2 -0
  208. package/dist/internal/c4/mining-instructions.d.ts.map +1 -0
  209. package/dist/internal/c4/mining-instructions.js +3 -0
  210. package/dist/internal/c4/mining-instructions.js.map +1 -0
  211. package/dist/internal/c4/open-signal.d.ts +8 -0
  212. package/dist/internal/c4/open-signal.d.ts.map +1 -0
  213. package/dist/internal/c4/open-signal.js +37 -0
  214. package/dist/internal/c4/open-signal.js.map +1 -0
  215. package/dist/internal/c4/profile-creation.d.ts +17 -0
  216. package/dist/internal/c4/profile-creation.d.ts.map +1 -0
  217. package/dist/internal/c4/profile-creation.js +36 -0
  218. package/dist/internal/c4/profile-creation.js.map +1 -0
  219. package/dist/internal/c4/profile-permissions.d.ts +14 -0
  220. package/dist/internal/c4/profile-permissions.d.ts.map +1 -0
  221. package/dist/internal/c4/profile-permissions.js +81 -0
  222. package/dist/internal/c4/profile-permissions.js.map +1 -0
  223. package/dist/internal/c4/region-geometry.d.ts +8 -0
  224. package/dist/internal/c4/region-geometry.d.ts.map +1 -0
  225. package/dist/internal/c4/region-geometry.js +43 -0
  226. package/dist/internal/c4/region-geometry.js.map +1 -0
  227. package/dist/internal/c4/rewards.d.ts +0 -27
  228. package/dist/internal/c4/rewards.d.ts.map +1 -1
  229. package/dist/internal/c4/rewards.js +0 -33
  230. package/dist/internal/c4/rewards.js.map +1 -1
  231. package/dist/internal/c4/runtime-bindings.d.ts +3 -0
  232. package/dist/internal/c4/runtime-bindings.d.ts.map +1 -0
  233. package/dist/internal/c4/runtime-bindings.js +4 -0
  234. package/dist/internal/c4/runtime-bindings.js.map +1 -0
  235. package/dist/internal/c4/scan-detection-codecs.d.ts +3 -0
  236. package/dist/internal/c4/scan-detection-codecs.d.ts.map +1 -0
  237. package/dist/internal/c4/scan-detection-codecs.js +3 -0
  238. package/dist/internal/c4/scan-detection-codecs.js.map +1 -0
  239. package/dist/internal/c4/scan-lifecycle.d.ts +306 -0
  240. package/dist/internal/c4/scan-lifecycle.d.ts.map +1 -0
  241. package/dist/internal/c4/scan-lifecycle.js +258 -0
  242. package/dist/internal/c4/scan-lifecycle.js.map +1 -0
  243. package/dist/internal/c4/scanning.d.ts +1 -28
  244. package/dist/internal/c4/scanning.d.ts.map +1 -1
  245. package/dist/internal/c4/scanning.js +2 -33
  246. package/dist/internal/c4/scanning.js.map +1 -1
  247. package/dist/internal/c4/ship-import.d.ts +4 -0
  248. package/dist/internal/c4/ship-import.d.ts.map +1 -0
  249. package/dist/internal/c4/ship-import.js +13 -0
  250. package/dist/internal/c4/ship-import.js.map +1 -0
  251. package/dist/internal/c4/ship-stats.d.ts.map +1 -1
  252. package/dist/internal/c4/ship-stats.js +25 -21
  253. package/dist/internal/c4/ship-stats.js.map +1 -1
  254. package/dist/internal/c4/starbase.d.ts +0 -32
  255. package/dist/internal/c4/starbase.d.ts.map +1 -1
  256. package/dist/internal/c4/starbase.js +3 -41
  257. package/dist/internal/c4/starbase.js.map +1 -1
  258. package/dist/internal/c4/world.d.ts +17 -2
  259. package/dist/internal/c4/world.d.ts.map +1 -1
  260. package/dist/internal/c4/world.js +32 -6
  261. package/dist/internal/c4/world.js.map +1 -1
  262. package/dist/internal/cargo.d.ts +2 -0
  263. package/dist/internal/cargo.d.ts.map +1 -1
  264. package/dist/internal/cargo.js +8 -0
  265. package/dist/internal/cargo.js.map +1 -1
  266. package/dist/internal/fleet.d.ts +1 -0
  267. package/dist/internal/fleet.d.ts.map +1 -1
  268. package/dist/internal/fleet.js +3 -1
  269. package/dist/internal/fleet.js.map +1 -1
  270. package/dist/internal/loyalty-atlas-bank-state.d.ts +16 -0
  271. package/dist/internal/loyalty-atlas-bank-state.d.ts.map +1 -0
  272. package/dist/internal/loyalty-atlas-bank-state.js +10 -0
  273. package/dist/internal/loyalty-atlas-bank-state.js.map +1 -0
  274. package/dist/internal/planning/action-runtime.d.ts +38 -0
  275. package/dist/internal/planning/action-runtime.d.ts.map +1 -0
  276. package/dist/internal/planning/action-runtime.js +63 -0
  277. package/dist/internal/planning/action-runtime.js.map +1 -0
  278. package/dist/internal/planning/arrival-guards.d.ts +20 -0
  279. package/dist/internal/planning/arrival-guards.d.ts.map +1 -0
  280. package/dist/internal/planning/arrival-guards.js +187 -0
  281. package/dist/internal/planning/arrival-guards.js.map +1 -0
  282. package/dist/internal/planning/authorization-adapter.d.ts +19 -6
  283. package/dist/internal/planning/authorization-adapter.d.ts.map +1 -1
  284. package/dist/internal/planning/authorization-adapter.js +102 -16
  285. package/dist/internal/planning/authorization-adapter.js.map +1 -1
  286. package/dist/internal/planning/character-registration-guard.d.ts +4 -0
  287. package/dist/internal/planning/character-registration-guard.d.ts.map +1 -0
  288. package/dist/internal/planning/character-registration-guard.js +58 -0
  289. package/dist/internal/planning/character-registration-guard.js.map +1 -0
  290. package/dist/internal/planning/character-registration.d.ts +23 -0
  291. package/dist/internal/planning/character-registration.d.ts.map +1 -0
  292. package/dist/internal/planning/character-registration.js +86 -0
  293. package/dist/internal/planning/character-registration.js.map +1 -0
  294. package/dist/internal/planning/democracy-history.d.ts +50 -0
  295. package/dist/internal/planning/democracy-history.d.ts.map +1 -0
  296. package/dist/internal/planning/democracy-history.js +198 -0
  297. package/dist/internal/planning/democracy-history.js.map +1 -0
  298. package/dist/internal/planning/faction-enrollment.js +2 -2
  299. package/dist/internal/planning/faction-enrollment.js.map +1 -1
  300. package/dist/internal/planning/faction-trade-guards.d.ts +30 -0
  301. package/dist/internal/planning/faction-trade-guards.d.ts.map +1 -0
  302. package/dist/internal/planning/faction-trade-guards.js +15 -0
  303. package/dist/internal/planning/faction-trade-guards.js.map +1 -0
  304. package/dist/internal/planning/faction-trade-state.d.ts +16 -0
  305. package/dist/internal/planning/faction-trade-state.d.ts.map +1 -0
  306. package/dist/internal/planning/faction-trade-state.js +43 -0
  307. package/dist/internal/planning/faction-trade-state.js.map +1 -0
  308. package/dist/internal/planning/fleet-arrival.d.ts +40 -0
  309. package/dist/internal/planning/fleet-arrival.d.ts.map +1 -0
  310. package/dist/internal/planning/fleet-arrival.js +106 -0
  311. package/dist/internal/planning/fleet-arrival.js.map +1 -0
  312. package/dist/internal/planning/fleet-attack-xp.d.ts +20 -0
  313. package/dist/internal/planning/fleet-attack-xp.d.ts.map +1 -0
  314. package/dist/internal/planning/fleet-attack-xp.js +110 -0
  315. package/dist/internal/planning/fleet-attack-xp.js.map +1 -0
  316. package/dist/internal/planning/fleet-creation.d.ts +30 -0
  317. package/dist/internal/planning/fleet-creation.d.ts.map +1 -0
  318. package/dist/internal/planning/fleet-creation.js +107 -0
  319. package/dist/internal/planning/fleet-creation.js.map +1 -0
  320. package/dist/internal/planning/fleet-crew-guard.d.ts +28 -0
  321. package/dist/internal/planning/fleet-crew-guard.d.ts.map +1 -0
  322. package/dist/internal/planning/fleet-crew-guard.js +47 -0
  323. package/dist/internal/planning/fleet-crew-guard.js.map +1 -0
  324. package/dist/internal/planning/fleet-crew-transfer.d.ts +7 -0
  325. package/dist/internal/planning/fleet-crew-transfer.d.ts.map +1 -0
  326. package/dist/internal/planning/fleet-crew-transfer.js +131 -0
  327. package/dist/internal/planning/fleet-crew-transfer.js.map +1 -0
  328. package/dist/internal/planning/fleet-respawn.d.ts +28 -0
  329. package/dist/internal/planning/fleet-respawn.d.ts.map +1 -0
  330. package/dist/internal/planning/fleet-respawn.js +164 -0
  331. package/dist/internal/planning/fleet-respawn.js.map +1 -0
  332. package/dist/internal/planning/fleet-ship-assembly.d.ts +36 -0
  333. package/dist/internal/planning/fleet-ship-assembly.d.ts.map +1 -0
  334. package/dist/internal/planning/fleet-ship-assembly.js +136 -0
  335. package/dist/internal/planning/fleet-ship-assembly.js.map +1 -0
  336. package/dist/internal/planning/governance-fees.d.ts +64 -0
  337. package/dist/internal/planning/governance-fees.d.ts.map +1 -0
  338. package/dist/internal/planning/governance-fees.js +239 -0
  339. package/dist/internal/planning/governance-fees.js.map +1 -0
  340. package/dist/internal/planning/mining-stop.d.ts +14 -0
  341. package/dist/internal/planning/mining-stop.d.ts.map +1 -0
  342. package/dist/internal/planning/mining-stop.js +41 -0
  343. package/dist/internal/planning/mining-stop.js.map +1 -0
  344. package/dist/internal/planning/movement-character.d.ts +7 -0
  345. package/dist/internal/planning/movement-character.d.ts.map +1 -0
  346. package/dist/internal/planning/movement-character.js +41 -0
  347. package/dist/internal/planning/movement-character.js.map +1 -0
  348. package/dist/internal/planning/movement-xp-guard.d.ts +4 -0
  349. package/dist/internal/planning/movement-xp-guard.d.ts.map +1 -0
  350. package/dist/internal/planning/movement-xp-guard.js +103 -0
  351. package/dist/internal/planning/movement-xp-guard.js.map +1 -0
  352. package/dist/internal/planning/open-signal-guard.d.ts +3 -0
  353. package/dist/internal/planning/open-signal-guard.d.ts.map +1 -0
  354. package/dist/internal/planning/open-signal-guard.js +31 -0
  355. package/dist/internal/planning/open-signal-guard.js.map +1 -0
  356. package/dist/internal/planning/open-signal.d.ts +31 -0
  357. package/dist/internal/planning/open-signal.d.ts.map +1 -0
  358. package/dist/internal/planning/open-signal.js +84 -0
  359. package/dist/internal/planning/open-signal.js.map +1 -0
  360. package/dist/internal/planning/respawn-guards.d.ts +3 -0
  361. package/dist/internal/planning/respawn-guards.d.ts.map +1 -0
  362. package/dist/internal/planning/respawn-guards.js +41 -0
  363. package/dist/internal/planning/respawn-guards.js.map +1 -0
  364. package/dist/internal/planning/runtime-guards.d.ts +43 -0
  365. package/dist/internal/planning/runtime-guards.d.ts.map +1 -0
  366. package/dist/internal/planning/runtime-guards.js +636 -0
  367. package/dist/internal/planning/runtime-guards.js.map +1 -0
  368. package/dist/internal/planning/scan-completion-guard.d.ts +43 -0
  369. package/dist/internal/planning/scan-completion-guard.d.ts.map +1 -0
  370. package/dist/internal/planning/scan-completion-guard.js +94 -0
  371. package/dist/internal/planning/scan-completion-guard.js.map +1 -0
  372. package/dist/internal/planning/scan-completion.d.ts +20 -0
  373. package/dist/internal/planning/scan-completion.d.ts.map +1 -0
  374. package/dist/internal/planning/scan-completion.js +220 -0
  375. package/dist/internal/planning/scan-completion.js.map +1 -0
  376. package/dist/internal/planning/scan-detect-guard.d.ts +34 -0
  377. package/dist/internal/planning/scan-detect-guard.d.ts.map +1 -0
  378. package/dist/internal/planning/scan-detect-guard.js +77 -0
  379. package/dist/internal/planning/scan-detect-guard.js.map +1 -0
  380. package/dist/internal/planning/scan-detect.d.ts +24 -0
  381. package/dist/internal/planning/scan-detect.d.ts.map +1 -0
  382. package/dist/internal/planning/scan-detect.js +244 -0
  383. package/dist/internal/planning/scan-detect.js.map +1 -0
  384. package/dist/internal/planning/ship-import-funding.d.ts +22 -0
  385. package/dist/internal/planning/ship-import-funding.d.ts.map +1 -0
  386. package/dist/internal/planning/ship-import-funding.js +52 -0
  387. package/dist/internal/planning/ship-import-funding.js.map +1 -0
  388. package/dist/internal/planning/ship-token.d.ts +10 -0
  389. package/dist/internal/planning/ship-token.d.ts.map +1 -0
  390. package/dist/internal/planning/ship-token.js +47 -0
  391. package/dist/internal/planning/ship-token.js.map +1 -0
  392. package/dist/internal/planning/starbase-system-guard.d.ts +6 -0
  393. package/dist/internal/planning/starbase-system-guard.d.ts.map +1 -0
  394. package/dist/internal/planning/starbase-system-guard.js +93 -0
  395. package/dist/internal/planning/starbase-system-guard.js.map +1 -0
  396. package/dist/internal/planning/starbase-system.d.ts +12 -0
  397. package/dist/internal/planning/starbase-system.d.ts.map +1 -0
  398. package/dist/internal/planning/starbase-system.js +22 -0
  399. package/dist/internal/planning/starbase-system.js.map +1 -0
  400. package/dist/internal/planning/token-mint.d.ts +4 -0
  401. package/dist/internal/planning/token-mint.d.ts.map +1 -0
  402. package/dist/internal/planning/token-mint.js +15 -0
  403. package/dist/internal/planning/token-mint.js.map +1 -0
  404. package/dist/internal/planning/trade-faction-market.d.ts +20 -0
  405. package/dist/internal/planning/trade-faction-market.d.ts.map +1 -0
  406. package/dist/internal/planning/trade-faction-market.js +56 -0
  407. package/dist/internal/planning/trade-faction-market.js.map +1 -0
  408. package/dist/internal/planning/xp-runtime.d.ts +36 -0
  409. package/dist/internal/planning/xp-runtime.d.ts.map +1 -0
  410. package/dist/internal/planning/xp-runtime.js +126 -0
  411. package/dist/internal/planning/xp-runtime.js.map +1 -0
  412. package/dist/loyalty/actions/index.d.ts.map +1 -1
  413. package/dist/loyalty/actions/index.js +4 -3
  414. package/dist/loyalty/actions/index.js.map +1 -1
  415. package/dist/loyalty/index.d.ts.map +1 -1
  416. package/dist/loyalty/index.js +2 -6
  417. package/dist/loyalty/index.js.map +1 -1
  418. package/dist/markets/actions/index.d.ts +1 -0
  419. package/dist/markets/actions/index.d.ts.map +1 -1
  420. package/dist/markets/actions/index.js +40 -16
  421. package/dist/markets/actions/index.js.map +1 -1
  422. package/dist/markets/actions/trade-faction-market.d.ts +43 -0
  423. package/dist/markets/actions/trade-faction-market.d.ts.map +1 -0
  424. package/dist/markets/actions/trade-faction-market.js +291 -0
  425. package/dist/markets/actions/trade-faction-market.js.map +1 -0
  426. package/dist/mining/actions/index.d.ts +84 -0
  427. package/dist/mining/actions/index.d.ts.map +1 -0
  428. package/dist/mining/actions/index.js +328 -0
  429. package/dist/mining/actions/index.js.map +1 -0
  430. package/dist/mining/estimate.d.ts +114 -0
  431. package/dist/mining/estimate.d.ts.map +1 -0
  432. package/dist/mining/estimate.js +127 -0
  433. package/dist/mining/estimate.js.map +1 -0
  434. package/dist/mining/index.d.ts +8 -2
  435. package/dist/mining/index.d.ts.map +1 -1
  436. package/dist/mining/index.js +6 -2
  437. package/dist/mining/index.js.map +1 -1
  438. package/dist/planning/assembly.d.ts.map +1 -1
  439. package/dist/planning/assembly.js +18 -0
  440. package/dist/planning/assembly.js.map +1 -1
  441. package/dist/planning/execution.d.ts.map +1 -1
  442. package/dist/planning/execution.js +378 -12
  443. package/dist/planning/execution.js.map +1 -1
  444. package/dist/planning/index.d.ts +180 -132
  445. package/dist/planning/index.d.ts.map +1 -1
  446. package/dist/planning/index.js +845 -104
  447. package/dist/planning/index.js.map +1 -1
  448. package/dist/planning/simulation.d.ts +25 -1
  449. package/dist/planning/simulation.d.ts.map +1 -1
  450. package/dist/planning/simulation.js +111 -11
  451. package/dist/planning/simulation.js.map +1 -1
  452. package/dist/registry/cargo.d.ts +6 -11
  453. package/dist/registry/cargo.d.ts.map +1 -1
  454. package/dist/registry/cargo.js +19 -19
  455. package/dist/registry/cargo.js.map +1 -1
  456. package/dist/registry/index.d.ts +4 -0
  457. package/dist/registry/index.d.ts.map +1 -1
  458. package/dist/registry/index.js.map +1 -1
  459. package/dist/registry/onboarding.d.ts +8 -1
  460. package/dist/registry/onboarding.d.ts.map +1 -1
  461. package/dist/registry/onboarding.js +18 -5
  462. package/dist/registry/onboarding.js.map +1 -1
  463. package/dist/registry/scanning.d.ts +7 -0
  464. package/dist/registry/scanning.d.ts.map +1 -0
  465. package/dist/registry/scanning.js +13 -0
  466. package/dist/registry/scanning.js.map +1 -0
  467. package/dist/registry/ship-stats-snapshot.js +19 -19
  468. package/dist/registry/ship-stats-snapshot.js.map +1 -1
  469. package/dist/registry/ships.d.ts +30 -0
  470. package/dist/registry/ships.d.ts.map +1 -0
  471. package/dist/registry/ships.js +59 -0
  472. package/dist/registry/ships.js.map +1 -0
  473. package/dist/registry/xp-runtime.d.ts +4 -0
  474. package/dist/registry/xp-runtime.d.ts.map +1 -0
  475. package/dist/registry/xp-runtime.js +14 -0
  476. package/dist/registry/xp-runtime.js.map +1 -0
  477. package/dist/scanning/actions/index.d.ts +116 -0
  478. package/dist/scanning/actions/index.d.ts.map +1 -0
  479. package/dist/scanning/actions/index.js +209 -0
  480. package/dist/scanning/actions/index.js.map +1 -0
  481. package/dist/scanning/index.d.ts +4 -1
  482. package/dist/scanning/index.d.ts.map +1 -1
  483. package/dist/scanning/index.js +5 -2
  484. package/dist/scanning/index.js.map +1 -1
  485. package/dist/scanning/lifecycle.d.ts +77 -0
  486. package/dist/scanning/lifecycle.d.ts.map +1 -0
  487. package/dist/scanning/lifecycle.js +93 -0
  488. package/dist/scanning/lifecycle.js.map +1 -0
  489. package/dist/scanning/odds.d.ts +111 -0
  490. package/dist/scanning/odds.d.ts.map +1 -0
  491. package/dist/scanning/odds.js +294 -0
  492. package/dist/scanning/odds.js.map +1 -0
  493. package/dist/scanning/signals.d.ts +121 -0
  494. package/dist/scanning/signals.d.ts.map +1 -0
  495. package/dist/scanning/signals.js +171 -0
  496. package/dist/scanning/signals.js.map +1 -0
  497. package/dist/world/index.d.ts +64 -5
  498. package/dist/world/index.d.ts.map +1 -1
  499. package/dist/world/index.js +53 -4
  500. package/dist/world/index.js.map +1 -1
  501. package/package.json +10 -2
@@ -1,6 +1,19 @@
1
+ import { validateCrewTransferInstructions, } from '../internal/planning/fleet-crew-guard.js';
2
+ import { validateCompletionInstructions, scanCompletionDiscriminators, } from '../internal/planning/scan-completion-guard.js';
3
+ import { validateOpenSignalInstructions } from '../internal/planning/open-signal-guard.js';
4
+ import { validateDetectInstructions, } from '../internal/planning/scan-detect-guard.js';
5
+ import { validateRespawnInstructions } from '../internal/planning/respawn-guards.js';
6
+ import { validateFleetAttackInstructions, } from '../internal/planning/fleet-attack-xp.js';
7
+ import { validateMovementXpInstructions } from '../internal/planning/movement-xp-guard.js';
8
+ import { validateStarbaseSystemInstructions, validateStarbaseSystemGuards, } from '../internal/planning/starbase-system-guard.js';
9
+ import { validateCharacterRegistrationInstructions } from '../internal/planning/character-registration-guard.js';
10
+ import { normalizeArrivalGuard, arrivalGuardToJSON, validateArrivalInstructions, } from '../internal/planning/arrival-guards.js';
11
+ import { isRuntimeGuard, normalizeRuntimeGuard, runtimeGuardToJSON, validateRuntimeInstructions, } from '../internal/planning/runtime-guards.js';
12
+ import { isTradeBuyGuard, isTradeSellGuard, isTradeMeterGuard, isFactionTradeGuard, } from '../internal/planning/faction-trade-guards.js';
1
13
  import { AccountRole, getBase64Decoder, getBase64Encoder, isAddress, isWritableRole, } from '@solana/kit';
2
- import { InvalidActionInputError } from '../client/errors.js';
14
+ import { InvalidActionInputError, SageSdkError } from '../client/errors.js';
3
15
  import { deepFreeze } from '../internal/immutable-tree.js';
16
+ import { validateMiningStopInstructions } from '../internal/planning/mining-stop.js';
4
17
  import { validatePlanComposition } from './composition.js';
5
18
  import { isPlanInstance, registerPlanInstance } from './plan-instances.js';
6
19
  const PLAN_BRAND = Symbol('AephiaSagePlan');
@@ -159,9 +172,601 @@ 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 = 5) {
175
+ function normalizePrecondition(value, field) {
163
176
  const precondition = readRecord(value, field);
164
- if (version === 5 && precondition.kind === 'game-account') {
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 === 'scan-signal-open') {
642
+ assertKeys(precondition, field, [
643
+ 'kind',
644
+ 'address',
645
+ 'game',
646
+ 'fleet',
647
+ 'profile',
648
+ 'authority',
649
+ 'character',
650
+ 'keyIndex',
651
+ 'authorityHash',
652
+ 'maximumProfileDebit',
653
+ 'describes',
654
+ ]);
655
+ const keyIndex = precondition.keyIndex;
656
+ if (typeof keyIndex !== 'number' ||
657
+ !Number.isInteger(keyIndex) ||
658
+ keyIndex < 0 ||
659
+ keyIndex > 65535)
660
+ invalid(field, keyIndex, 'a u16 key index');
661
+ const maximumProfileDebit = precondition.maximumProfileDebit;
662
+ if (typeof maximumProfileDebit !== 'bigint' ||
663
+ maximumProfileDebit < 0n ||
664
+ maximumProfileDebit > 0xffffffffffffffffn)
665
+ invalid(field, maximumProfileDebit, 'a nonnegative u64 funding ceiling');
666
+ return Object.freeze({
667
+ kind: 'scan-signal-open',
668
+ authorityHash: readDataHash(precondition.authorityHash, field),
669
+ address: readAddress(precondition.address, field),
670
+ game: readAddress(precondition.game, field),
671
+ fleet: readAddress(precondition.fleet, field),
672
+ profile: readAddress(precondition.profile, field),
673
+ authority: readAddress(precondition.authority, field),
674
+ character: readAddress(precondition.character, field),
675
+ keyIndex,
676
+ maximumProfileDebit,
677
+ describes: readString(precondition.describes, field),
678
+ });
679
+ }
680
+ if (precondition.kind === 'fleet-create') {
681
+ assertKeys(precondition, field, [
682
+ 'kind',
683
+ 'address',
684
+ 'game',
685
+ 'profile',
686
+ 'authority',
687
+ 'system',
688
+ 'keyIndex',
689
+ 'label',
690
+ 'maximumProfileDebit',
691
+ 'describes',
692
+ ]);
693
+ const keyIndex = precondition.keyIndex;
694
+ if (typeof keyIndex !== 'number' ||
695
+ !Number.isSafeInteger(keyIndex) ||
696
+ keyIndex < 0 ||
697
+ keyIndex > 65_535)
698
+ invalid(`${field}.keyIndex`, keyIndex, 'an integer from 0 through 65535');
699
+ const label = readString(precondition.label, `${field}.label`);
700
+ const bytes = new TextEncoder().encode(label);
701
+ if (label.trim().length === 0 ||
702
+ label.includes('\0') ||
703
+ bytes.length > 64 ||
704
+ new TextDecoder('utf-8', { ignoreBOM: true }).decode(bytes) !== label)
705
+ invalid(`${field}.label`, label, 'a nonblank, NUL-free Unicode label of at most 64 UTF-8 bytes');
706
+ const maximumProfileDebit = precondition.maximumProfileDebit;
707
+ if (typeof maximumProfileDebit !== 'bigint' || maximumProfileDebit < 0n)
708
+ invalid(`${field}.maximumProfileDebit`, maximumProfileDebit, 'a nonnegative bigint');
709
+ return Object.freeze({
710
+ kind: 'fleet-create',
711
+ address: readAddress(precondition.address, `${field}.address`),
712
+ game: readAddress(precondition.game, `${field}.game`),
713
+ profile: readAddress(precondition.profile, `${field}.profile`),
714
+ authority: readAddress(precondition.authority, `${field}.authority`),
715
+ system: readAddress(precondition.system, `${field}.system`),
716
+ keyIndex,
717
+ label,
718
+ maximumProfileDebit,
719
+ describes: readString(precondition.describes, `${field}.describes`),
720
+ });
721
+ }
722
+ if (precondition.kind === 'system-account-or-absent') {
723
+ assertKeys(precondition, field, ['kind', 'address', 'describes']);
724
+ return Object.freeze({
725
+ kind: 'system-account-or-absent',
726
+ address: readAddress(precondition.address, `${field}.address`),
727
+ describes: readString(precondition.describes, `${field}.describes`),
728
+ });
729
+ }
730
+ if (precondition.kind === 'token-mint') {
731
+ assertKeys(precondition, field, [
732
+ 'kind',
733
+ 'address',
734
+ 'decimals',
735
+ 'describes',
736
+ ]);
737
+ const decimals = precondition.decimals;
738
+ if (typeof decimals !== 'number' ||
739
+ !Number.isInteger(decimals) ||
740
+ decimals < 0 ||
741
+ decimals > 255)
742
+ invalid(`${field}.decimals`, decimals, 'an unsigned u8 mint decimals value');
743
+ return Object.freeze({
744
+ kind: 'token-mint',
745
+ address: readAddress(precondition.address, `${field}.address`),
746
+ decimals,
747
+ describes: readString(precondition.describes, `${field}.describes`),
748
+ });
749
+ }
750
+ if (precondition.kind === 'game-ship-config') {
751
+ assertKeys(precondition, field, [
752
+ 'kind',
753
+ 'address',
754
+ 'shipId',
755
+ 'configHash',
756
+ 'describes',
757
+ ]);
758
+ const id = precondition.shipId;
759
+ if (typeof id !== 'number' || !Number.isInteger(id) || id < 0 || id > 65535)
760
+ invalid(`${field}.shipId`, id, 'a u16 ship configuration ID');
761
+ return Object.freeze({
762
+ kind: 'game-ship-config',
763
+ address: readAddress(precondition.address, `${field}.address`),
764
+ shipId: id,
765
+ configHash: readDataHash(precondition.configHash, `${field}.configHash`),
766
+ describes: readString(precondition.describes, `${field}.describes`),
767
+ });
768
+ }
769
+ if (precondition.kind === 'game-account') {
165
770
  assertKeys(precondition, field, ['kind', 'address', 'describes']);
166
771
  return Object.freeze({
167
772
  kind: 'game-account',
@@ -169,8 +774,7 @@ function normalizePrecondition(value, field, version = 5) {
169
774
  describes: readString(precondition.describes, `${field}.describes`),
170
775
  });
171
776
  }
172
- if (version >= 4 &&
173
- ['token-account', 'game-cargo-config', 'cargo-cache'].includes(String(precondition.kind))) {
777
+ if (['game-cargo-bytes-config', 'token-account', 'cargo-cache'].includes(String(precondition.kind))) {
174
778
  const base = {
175
779
  address: readAddress(precondition.address, `${field}.address`),
176
780
  describes: readString(precondition.describes, `${field}.describes`),
@@ -197,7 +801,7 @@ function normalizePrecondition(value, field, version = 5) {
197
801
  minimumBalance: amount,
198
802
  });
199
803
  }
200
- if (precondition.kind === 'game-cargo-config') {
804
+ if (precondition.kind === 'game-cargo-bytes-config') {
201
805
  assertKeys(precondition, field, [
202
806
  'kind',
203
807
  'address',
@@ -213,7 +817,7 @@ function normalizePrecondition(value, field, version = 5) {
213
817
  invalid(`${field}.cargoId`, id, 'a u16 cargo ID');
214
818
  return Object.freeze({
215
819
  ...base,
216
- kind: 'game-cargo-config',
820
+ kind: precondition.kind,
217
821
  cargoId: id,
218
822
  configHash: readDataHash(precondition.configHash, `${field}.configHash`),
219
823
  });
@@ -238,7 +842,7 @@ function normalizePrecondition(value, field, version = 5) {
238
842
  bump,
239
843
  });
240
844
  }
241
- if (precondition.kind === 'token-account-or-absent' && version >= 3) {
845
+ if (precondition.kind === 'token-account-or-absent') {
242
846
  assertKeys(precondition, field, [
243
847
  'kind',
244
848
  'address',
@@ -254,7 +858,7 @@ function normalizePrecondition(value, field, version = 5) {
254
858
  describes: readString(precondition.describes, `${field}.describes`),
255
859
  });
256
860
  }
257
- if (precondition.kind === 'account-absent' && version !== 1) {
861
+ if (precondition.kind === 'account-absent') {
258
862
  assertKeys(precondition, field, ['kind', 'address', 'describes']);
259
863
  return Object.freeze({
260
864
  kind: 'account-absent',
@@ -263,15 +867,7 @@ function normalizePrecondition(value, field, version = 5) {
263
867
  });
264
868
  }
265
869
  if (precondition.kind !== 'account-state') {
266
- invalid(`${field}.kind`, precondition.kind, version === 5
267
- ? 'one of account-state, account-absent, token-account-or-absent, token-account, game-cargo-config, cargo-cache, or game-account'
268
- : version === 4
269
- ? 'one of account-state, account-absent, token-account-or-absent, token-account, game-cargo-config, or cargo-cache'
270
- : version === 3
271
- ? 'one of account-state, account-absent, or token-account-or-absent'
272
- : version === 2
273
- ? 'one of account-state or account-absent'
274
- : 'the value account-state');
870
+ invalid(`${field}.kind`, precondition.kind, 'a supported current Plan guard; recreate the Plan using the current capability planner');
275
871
  }
276
872
  assertKeys(precondition, field, ['kind', 'address', 'dataHash', 'describes']);
277
873
  return Object.freeze({
@@ -307,74 +903,72 @@ function instructionToJSON(instruction) {
307
903
  return deepFreeze(value);
308
904
  }
309
905
  function planToJSON(plan) {
310
- const hasSemantics = plan.steps.some((step) => (step.semantics?.length ?? 0) > 0);
311
- const hasAbsentPrecondition = plan.preconditions.some(({ kind }) => kind === 'account-absent');
312
- const common = {
906
+ return deepFreeze({
907
+ v: 24,
313
908
  kind: plan.kind,
314
909
  summary: plan.summary,
315
910
  affected: [...plan.affected],
316
911
  requiredSigners: [...plan.requiredSigners],
317
- };
318
- const steps = plan.steps.map((step) => ({
319
- instruction: instructionToJSON(step.instruction),
320
- describes: step.describes,
321
- ...((step.semantics?.length ?? 0) > 0
322
- ? { semantics: step.semantics.map((semantic) => ({ ...semantic })) }
323
- : {}),
324
- signers: [...step.signers],
325
- }));
326
- if (plan.preconditions.some(({ kind }) => kind === 'game-account')) {
327
- return deepFreeze({
328
- v: 5,
329
- ...common,
330
- steps,
331
- preconditions: plan.preconditions.map((guard) => guard.kind === 'token-account'
332
- ? { ...guard, minimumBalance: String(guard.minimumBalance) }
333
- : { ...guard }),
334
- });
335
- }
336
- if (plan.preconditions.some(({ kind }) => kind === 'token-account' ||
337
- kind === 'game-cargo-config' ||
338
- kind === 'cargo-cache')) {
339
- return deepFreeze({
340
- v: 4,
341
- ...common,
342
- steps,
343
- preconditions: plan.preconditions.map((guard) => guard.kind === 'token-account'
344
- ? { ...guard, minimumBalance: String(guard.minimumBalance) }
345
- : { ...guard }),
346
- });
347
- }
348
- if (plan.preconditions.some(({ kind }) => kind === 'token-account-or-absent')) {
349
- return deepFreeze({
350
- v: 3,
351
- ...common,
352
- steps,
353
- preconditions: plan.preconditions.map((guard) => ({
354
- ...guard,
355
- })),
356
- });
357
- }
358
- if (hasSemantics || hasAbsentPrecondition) {
359
- return deepFreeze({
360
- v: 2,
361
- ...common,
362
- steps,
363
- preconditions: plan.preconditions.map((guard) => ({
364
- ...guard,
365
- })),
366
- });
367
- }
368
- return deepFreeze({
369
- v: 1,
370
- ...common,
371
- steps,
372
- preconditions: plan.preconditions.map((precondition) => ({
373
- kind: 'account-state',
374
- address: precondition.address,
375
- dataHash: precondition.dataHash,
376
- describes: precondition.describes,
912
+ steps: plan.steps.map((step) => ({
913
+ instruction: instructionToJSON(step.instruction),
914
+ describes: step.describes,
915
+ ...((step.semantics?.length ?? 0) > 0
916
+ ? { semantics: step.semantics.map((semantic) => ({ ...semantic })) }
917
+ : {}),
918
+ signers: [...step.signers],
377
919
  })),
920
+ preconditions: plan.preconditions.map((guard) => {
921
+ if (guard.kind === 'scan-detect' || guard.kind === 'scan-completion')
922
+ return { ...guard, expectedSequence: String(guard.expectedSequence) };
923
+ if (guard.kind === 'fleet-arrival')
924
+ return arrivalGuardToJSON(guard);
925
+ if (guard.kind === 'fleet-crew-transfer')
926
+ return { ...guard, systemSequenceId: String(guard.systemSequenceId) };
927
+ if (guard.kind === 'fleet-respawn')
928
+ return {
929
+ ...guard,
930
+ maximumRecoveryFee: String(guard.maximumRecoveryFee),
931
+ maximumProfileDebit: String(guard.maximumProfileDebit),
932
+ };
933
+ if (isRuntimeGuard(guard))
934
+ return runtimeGuardToJSON(guard);
935
+ if (isTradeBuyGuard(guard))
936
+ return { ...guard, floorRaw: String(guard.floorRaw) };
937
+ if (isTradeSellGuard(guard))
938
+ return {
939
+ ...guard,
940
+ atlasOutCapPerEpochRaw: String(guard.atlasOutCapPerEpochRaw),
941
+ epochLengthSeconds: String(guard.epochLengthSeconds),
942
+ };
943
+ if (guard.kind === 'fleet-add-ship')
944
+ return {
945
+ ...guard,
946
+ amount: String(guard.amount),
947
+ maximumProfileDebit: String(guard.maximumProfileDebit),
948
+ };
949
+ if (guard.kind === 'character-registration')
950
+ return {
951
+ ...guard,
952
+ maximumFunderDebit: String(guard.maximumFunderDebit),
953
+ characterLamports: String(guard.characterLamports),
954
+ budgetLamports: String(guard.budgetLamports),
955
+ };
956
+ if (guard.kind === 'scan-signal-open' ||
957
+ guard.kind === 'fleet-create' ||
958
+ guard.kind === 'ship-import-funding')
959
+ return {
960
+ ...guard,
961
+ maximumProfileDebit: String(guard.maximumProfileDebit),
962
+ };
963
+ if (guard.kind === 'starbase-system')
964
+ return {
965
+ ...guard,
966
+ starbaseSequenceId: String(guard.starbaseSequenceId),
967
+ };
968
+ if (guard.kind === 'token-account')
969
+ return { ...guard, minimumBalance: String(guard.minimumBalance) };
970
+ return { ...guard };
971
+ }),
378
972
  });
379
973
  }
380
974
  /** Creates an inert branded Plan while deriving every aggregate field.
@@ -396,6 +990,13 @@ export function createPlan(input) {
396
990
  assertKeys(value, 'plan', ['kind', 'summary', 'steps', 'preconditions']);
397
991
  const steps = Object.freeze(readArray(value.steps, 'plan.steps').map((step, index) => normalizeStep(step, `plan.steps[${String(index)}]`)));
398
992
  const preconditions = Object.freeze(readArray(value.preconditions, 'plan.preconditions').map((precondition, index) => normalizePrecondition(precondition, `plan.preconditions[${String(index)}]`)));
993
+ validateShipImportFundingComposition(preconditions);
994
+ validateStarbaseSystemGuards(steps, preconditions);
995
+ validateDetectInstructions(steps, preconditions);
996
+ validateCompletionInstructions(steps, preconditions);
997
+ validateRespawnInstructions(steps, preconditions);
998
+ validateCrewTransferInstructions(steps, preconditions);
999
+ validateOpenSignalInstructions(steps, preconditions);
399
1000
  const descriptions = Object.freeze(steps.map((step) => step.describes));
400
1001
  const plan = {
401
1002
  kind: readString(value.kind, 'plan.kind'),
@@ -442,7 +1043,7 @@ function sameAddresses(actual, encoded) {
442
1043
  *
443
1044
  * @example
444
1045
  * ```ts
445
- * declare const wire: PlanJsonV1 | PlanJsonV2 | PlanJsonV3 | PlanJsonV4 | PlanJsonV5;
1046
+ * declare const wire: PlanJson;
446
1047
  * const plan = planFromJSON(wire);
447
1048
  * console.log(plan.describe());
448
1049
  * ```
@@ -458,33 +1059,112 @@ export function planFromJSON(json) {
458
1059
  'affected',
459
1060
  'requiredSigners',
460
1061
  ]);
461
- if (value.v !== 1 &&
462
- value.v !== 2 &&
463
- value.v !== 3 &&
464
- value.v !== 4 &&
465
- value.v !== 5) {
466
- invalid('planJson.v', value.v, 'the Plan wire version 1, 2, 3, 4, or 5');
467
- }
468
- const version = value.v;
469
- if (version >= 4 && Array.isArray(value.preconditions)) {
470
- value.preconditions = value.preconditions.map((entry) => {
471
- const guard = readRecord(entry, 'precondition');
472
- if (guard.kind !== 'token-account')
473
- return guard;
474
- if (typeof guard.minimumBalance !== 'string' ||
475
- !/^(0|[1-9][0-9]*)$/.test(guard.minimumBalance))
476
- invalid('minimumBalance', guard.minimumBalance, 'a canonical unsigned decimal string');
477
- return { ...guard, minimumBalance: BigInt(guard.minimumBalance) };
478
- });
1062
+ if (value.v !== 24) {
1063
+ throw new InvalidActionInputError('planJson.v', value.v, 'the current Plan wire version 24', 'Recreate the Plan using the current capability planner; do not change its saved version or migrate its guards.');
479
1064
  }
1065
+ value.preconditions = readArray(value.preconditions, 'planJson.preconditions').map((entry) => {
1066
+ const guard = readRecord(entry, 'precondition');
1067
+ if (guard.kind === 'scan-detect' || guard.kind === 'scan-completion') {
1068
+ if (typeof guard.expectedSequence !== 'string' ||
1069
+ !/^(0|[1-9][0-9]*)$/.test(guard.expectedSequence))
1070
+ invalid('expectedSequence', guard.expectedSequence, 'a canonical unsigned decimal string');
1071
+ return { ...guard, expectedSequence: BigInt(guard.expectedSequence) };
1072
+ }
1073
+ if (guard.kind === 'fleet-arrival')
1074
+ return normalizeArrivalGuard(guard, 'precondition', true);
1075
+ if (isRuntimeGuard(guard))
1076
+ return normalizeRuntimeGuard(guard, 'precondition', true);
1077
+ if (isTradeBuyGuard(guard) || isTradeSellGuard(guard)) {
1078
+ const keys = isTradeBuyGuard(guard)
1079
+ ? ['floorRaw']
1080
+ : ['atlasOutCapPerEpochRaw', 'epochLengthSeconds'];
1081
+ const decoded = { ...guard };
1082
+ for (const key of keys) {
1083
+ const raw = guard[key];
1084
+ const pattern = key === 'epochLengthSeconds'
1085
+ ? /^(0|[1-9][0-9]*|-[1-9][0-9]*)$/
1086
+ : /^(0|[1-9][0-9]*)$/;
1087
+ if (typeof raw !== 'string' || !pattern.test(raw))
1088
+ invalid(key, raw, 'a canonical decimal string');
1089
+ decoded[key] = BigInt(raw);
1090
+ }
1091
+ return decoded;
1092
+ }
1093
+ if (guard.kind === 'fleet-add-ship') {
1094
+ for (const field of ['amount', 'maximumProfileDebit'])
1095
+ if (typeof guard[field] !== 'string' ||
1096
+ !/^(0|[1-9][0-9]*)$/.test(guard[field]))
1097
+ invalid(field, guard[field], 'a canonical unsigned decimal string');
1098
+ return {
1099
+ ...guard,
1100
+ amount: BigInt(guard.amount),
1101
+ maximumProfileDebit: BigInt(guard.maximumProfileDebit),
1102
+ };
1103
+ }
1104
+ if (guard.kind === 'character-registration') {
1105
+ for (const key of ['characterLamports', 'budgetLamports'])
1106
+ if (typeof guard[key] !== 'string' ||
1107
+ !/^(0|[1-9][0-9]*)$/.test(guard[key]))
1108
+ invalid(key, guard[key], 'a canonical unsigned decimal string');
1109
+ if (typeof guard.maximumFunderDebit !== 'string' ||
1110
+ !/^(0|[1-9][0-9]*)$/.test(guard.maximumFunderDebit))
1111
+ invalid('maximumFunderDebit', guard.maximumFunderDebit, 'a canonical unsigned decimal string');
1112
+ return {
1113
+ ...guard,
1114
+ maximumFunderDebit: BigInt(guard.maximumFunderDebit),
1115
+ characterLamports: BigInt(guard.characterLamports),
1116
+ budgetLamports: BigInt(guard.budgetLamports),
1117
+ };
1118
+ }
1119
+ if (guard.kind === 'fleet-crew-transfer') {
1120
+ if (typeof guard.systemSequenceId !== 'string' ||
1121
+ !/^(0|[1-9][0-9]*)$/.test(guard.systemSequenceId))
1122
+ invalid('systemSequenceId', guard.systemSequenceId, 'a canonical unsigned decimal string');
1123
+ return { ...guard, systemSequenceId: BigInt(guard.systemSequenceId) };
1124
+ }
1125
+ if (guard.kind === 'fleet-respawn') {
1126
+ for (const key of ['maximumRecoveryFee', 'maximumProfileDebit'])
1127
+ if (typeof guard[key] !== 'string' ||
1128
+ !/^(0|[1-9][0-9]*)$/.test(guard[key]))
1129
+ invalid(key, guard[key], 'a canonical unsigned decimal string');
1130
+ return {
1131
+ ...guard,
1132
+ maximumRecoveryFee: BigInt(guard.maximumRecoveryFee),
1133
+ maximumProfileDebit: BigInt(guard.maximumProfileDebit),
1134
+ };
1135
+ }
1136
+ if (guard.kind === 'scan-signal-open' ||
1137
+ guard.kind === 'fleet-create' ||
1138
+ guard.kind === 'ship-import-funding') {
1139
+ if (typeof guard.maximumProfileDebit !== 'string' ||
1140
+ !/^(0|[1-9][0-9]*)$/.test(guard.maximumProfileDebit))
1141
+ invalid('maximumProfileDebit', guard.maximumProfileDebit, 'a canonical unsigned decimal string');
1142
+ return {
1143
+ ...guard,
1144
+ maximumProfileDebit: BigInt(guard.maximumProfileDebit),
1145
+ };
1146
+ }
1147
+ if (guard.kind === 'starbase-system') {
1148
+ if (typeof guard.starbaseSequenceId !== 'string' ||
1149
+ !/^(0|[1-9][0-9]*)$/.test(guard.starbaseSequenceId))
1150
+ invalid('starbaseSequenceId', guard.starbaseSequenceId, 'a canonical unsigned decimal string');
1151
+ return { ...guard, starbaseSequenceId: BigInt(guard.starbaseSequenceId) };
1152
+ }
1153
+ if (guard.kind !== 'token-account')
1154
+ return guard;
1155
+ if (typeof guard.minimumBalance !== 'string' ||
1156
+ !/^(0|[1-9][0-9]*)$/.test(guard.minimumBalance))
1157
+ invalid('minimumBalance', guard.minimumBalance, 'a canonical unsigned decimal string');
1158
+ return { ...guard, minimumBalance: BigInt(guard.minimumBalance) };
1159
+ });
480
1160
  const steps = readArray(value.steps, 'planJson.steps').map((candidate, index) => {
481
1161
  const field = `planJson.steps[${String(index)}]`;
482
1162
  const step = readRecord(candidate, field);
483
- assertKeys(step, field, ['instruction', 'describes', 'signers'], version !== 1 ? ['semantics'] : []);
1163
+ assertKeys(step, field, ['instruction', 'describes', 'signers'], ['semantics']);
484
1164
  return {
485
1165
  instruction: readWireInstruction(step.instruction, `${field}.instruction`),
486
1166
  describes: readString(step.describes, `${field}.describes`),
487
- ...(version !== 1 && step.semantics !== undefined
1167
+ ...(step.semantics !== undefined
488
1168
  ? {
489
1169
  semantics: readArray(step.semantics, `${field}.semantics`).map((semantic, semanticIndex) => normalizeSemanticFact(semantic, `${field}.semantics[${String(semanticIndex)}]`)),
490
1170
  }
@@ -492,7 +1172,7 @@ export function planFromJSON(json) {
492
1172
  signers: readArray(step.signers, `${field}.signers`).map((signer, signerIndex) => readAddress(signer, `${field}.signers[${String(signerIndex)}]`)),
493
1173
  };
494
1174
  });
495
- const preconditions = readArray(value.preconditions, 'planJson.preconditions').map((candidate, index) => normalizePrecondition(candidate, `planJson.preconditions[${String(index)}]`, version));
1175
+ const preconditions = readArray(value.preconditions, 'planJson.preconditions').map((candidate, index) => normalizePrecondition(candidate, `planJson.preconditions[${String(index)}]`));
496
1176
  const affected = readArray(value.affected, 'planJson.affected').map((candidate, index) => readAddress(candidate, `planJson.affected[${String(index)}]`));
497
1177
  const requiredSigners = readArray(value.requiredSigners, 'planJson.requiredSigners').map((candidate, index) => readAddress(candidate, `planJson.requiredSigners[${String(index)}]`));
498
1178
  const plan = createPlan({
@@ -501,6 +1181,10 @@ export function planFromJSON(json) {
501
1181
  steps,
502
1182
  preconditions,
503
1183
  });
1184
+ validateStarbaseSystemInstructions(plan.steps, plan.preconditions);
1185
+ validateMovementXpInstructions(plan.steps, plan.preconditions);
1186
+ validateFleetAttackInstructions(plan.steps, plan.preconditions);
1187
+ validateCharacterRegistrationInstructions(plan.steps, plan.preconditions);
504
1188
  if (!sameAddresses(plan.affected, affected)) {
505
1189
  invalid('planJson.affected', value.affected, 'the first-seen union of writable instruction account addresses');
506
1190
  }
@@ -517,6 +1201,49 @@ function assertPlan(value, index) {
517
1201
  function combinedSummary(steps) {
518
1202
  return steps.map((step) => step.describes).join(' ');
519
1203
  }
1204
+ function validateShipImportFundingComposition(guards) {
1205
+ const targets = new Map();
1206
+ for (const guard of guards) {
1207
+ if (guard.kind !== 'ship-import-funding')
1208
+ continue;
1209
+ const identity = `${guard.game}:${guard.profile}:${guard.system}:${String(guard.shipId)}`;
1210
+ const previous = targets.get(guard.address);
1211
+ if (previous !== undefined && previous !== identity)
1212
+ 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.');
1213
+ targets.set(guard.address, identity);
1214
+ }
1215
+ }
1216
+ function validateFactionGuardComposition(guards) {
1217
+ const retained = new Map();
1218
+ for (const guard of guards) {
1219
+ if (!isFactionTradeGuard(guard))
1220
+ continue;
1221
+ const constraints = [
1222
+ [
1223
+ `${isTradeMeterGuard(guard) ? 'meter' : 'treasury'}:${guard.address}:identity`,
1224
+ `${guard.game}:${String(guard.factionId)}`,
1225
+ ],
1226
+ ];
1227
+ if (!isTradeMeterGuard(guard)) {
1228
+ constraints.push(isTradeBuyGuard(guard)
1229
+ ? [
1230
+ `${guard.address}:buy:${String(guard.cargoId)}`,
1231
+ String(guard.floorRaw),
1232
+ ]
1233
+ : [
1234
+ `${guard.address}:sell`,
1235
+ `${String(guard.atlasOutCapPerEpochRaw)}:${String(guard.epochLengthSeconds)}`,
1236
+ ]);
1237
+ }
1238
+ constraints.push([`${guard.address}:schema`, String(guard.schemaVersion)]);
1239
+ for (const [key, value] of constraints) {
1240
+ const previous = retained.get(key);
1241
+ if (previous !== undefined && previous !== value)
1242
+ 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.');
1243
+ retained.set(key, value);
1244
+ }
1245
+ }
1246
+ }
520
1247
  /** Combines one or more Plans with deterministic associative flattening.
521
1248
  *
522
1249
  * Semantic validation is eager. Conflict indices are relative to the flattened
@@ -537,11 +1264,25 @@ export function combinePlans(...plans) {
537
1264
  plans.forEach(assertPlan);
538
1265
  const steps = plans.flatMap((plan) => plan.steps);
539
1266
  validatePlanComposition(steps);
1267
+ const preconditions = plans.flatMap((plan) => plan.preconditions);
1268
+ validateFactionGuardComposition(preconditions);
1269
+ validateMiningStopInstructions(steps, preconditions);
1270
+ validateStarbaseSystemInstructions(steps, preconditions);
1271
+ validateCharacterRegistrationInstructions(steps, preconditions);
1272
+ validateArrivalInstructions(steps, preconditions);
1273
+ validateDetectInstructions(steps, preconditions);
1274
+ validateCompletionInstructions(steps, preconditions);
1275
+ validateRespawnInstructions(steps, preconditions);
1276
+ validateCrewTransferInstructions(steps, preconditions);
1277
+ validateOpenSignalInstructions(steps, preconditions);
1278
+ validateRuntimeInstructions(steps, preconditions);
1279
+ validateMovementXpInstructions(steps, preconditions);
1280
+ validateFleetAttackInstructions(steps, preconditions);
540
1281
  return createPlan({
541
1282
  kind: 'combined',
542
1283
  summary: combinedSummary(steps),
543
1284
  steps,
544
- preconditions: plans.flatMap((plan) => plan.preconditions),
1285
+ preconditions,
545
1286
  });
546
1287
  }
547
1288
  export { assemblePlan } from './assembly.js';