@aephia/atlas-kit 0.6.0-next.10 → 0.6.0-next.100

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 (620) 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 +27 -14
  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 +10 -15
  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 +30 -29
  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 +137 -111
  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 +35 -0
  34. package/dist/client/index.d.ts.map +1 -1
  35. package/dist/client/index.js +35 -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 +104 -67
  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 +101 -108
  47. package/dist/crafting/actions/index.js.map +1 -1
  48. package/dist/crafting/index.d.ts +33 -3
  49. package/dist/crafting/index.d.ts.map +1 -1
  50. package/dist/crafting/index.js +44 -15
  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 +2 -1
  55. package/dist/factions/actions/index.js.map +1 -1
  56. package/dist/factions/index.d.ts +1 -1
  57. package/dist/factions/index.d.ts.map +1 -1
  58. package/dist/factions/index.js +14 -8
  59. package/dist/factions/index.js.map +1 -1
  60. package/dist/factions/profile-faction.d.ts +20 -8
  61. package/dist/factions/profile-faction.d.ts.map +1 -1
  62. package/dist/factions/profile-faction.js +20 -8
  63. package/dist/factions/profile-faction.js.map +1 -1
  64. package/dist/fleets/actions/add-ship.d.ts +35 -0
  65. package/dist/fleets/actions/add-ship.d.ts.map +1 -0
  66. package/dist/fleets/actions/add-ship.js +149 -0
  67. package/dist/fleets/actions/add-ship.js.map +1 -0
  68. package/dist/fleets/actions/create-fleet.d.ts +36 -0
  69. package/dist/fleets/actions/create-fleet.d.ts.map +1 -0
  70. package/dist/fleets/actions/create-fleet.js +138 -0
  71. package/dist/fleets/actions/create-fleet.js.map +1 -0
  72. package/dist/fleets/actions/crew-transfer.d.ts +41 -0
  73. package/dist/fleets/actions/crew-transfer.d.ts.map +1 -0
  74. package/dist/fleets/actions/crew-transfer.js +114 -0
  75. package/dist/fleets/actions/crew-transfer.js.map +1 -0
  76. package/dist/fleets/actions/dock-bounds.d.ts +38 -0
  77. package/dist/fleets/actions/dock-bounds.d.ts.map +1 -0
  78. package/dist/fleets/actions/dock-bounds.js +46 -0
  79. package/dist/fleets/actions/dock-bounds.js.map +1 -0
  80. package/dist/fleets/actions/index.d.ts +37 -16
  81. package/dist/fleets/actions/index.d.ts.map +1 -1
  82. package/dist/fleets/actions/index.js +245 -153
  83. package/dist/fleets/actions/index.js.map +1 -1
  84. package/dist/fleets/actions/respawn.d.ts +38 -0
  85. package/dist/fleets/actions/respawn.d.ts.map +1 -0
  86. package/dist/fleets/actions/respawn.js +122 -0
  87. package/dist/fleets/actions/respawn.js.map +1 -0
  88. package/dist/fleets/actions/ship-import.d.ts.map +1 -1
  89. package/dist/fleets/actions/ship-import.js +41 -13
  90. package/dist/fleets/actions/ship-import.js.map +1 -1
  91. package/dist/fleets/cooldown.d.ts +44 -0
  92. package/dist/fleets/cooldown.d.ts.map +1 -0
  93. package/dist/fleets/cooldown.js +43 -0
  94. package/dist/fleets/cooldown.js.map +1 -0
  95. package/dist/fleets/coordinate-warp-estimate.d.ts +70 -0
  96. package/dist/fleets/coordinate-warp-estimate.d.ts.map +1 -0
  97. package/dist/fleets/coordinate-warp-estimate.js +46 -0
  98. package/dist/fleets/coordinate-warp-estimate.js.map +1 -0
  99. package/dist/fleets/index.d.ts +35 -0
  100. package/dist/fleets/index.d.ts.map +1 -1
  101. package/dist/fleets/index.js +52 -2
  102. package/dist/fleets/index.js.map +1 -1
  103. package/dist/fleets/movement-arithmetic.d.ts +21 -0
  104. package/dist/fleets/movement-arithmetic.d.ts.map +1 -0
  105. package/dist/fleets/movement-arithmetic.js +41 -0
  106. package/dist/fleets/movement-arithmetic.js.map +1 -0
  107. package/dist/fleets/subwarp-estimate.d.ts +70 -0
  108. package/dist/fleets/subwarp-estimate.d.ts.map +1 -0
  109. package/dist/fleets/subwarp-estimate.js +38 -0
  110. package/dist/fleets/subwarp-estimate.js.map +1 -0
  111. package/dist/fleets/travel-profile.d.ts +102 -0
  112. package/dist/fleets/travel-profile.d.ts.map +1 -0
  113. package/dist/fleets/travel-profile.js +120 -0
  114. package/dist/fleets/travel-profile.js.map +1 -0
  115. package/dist/fleets/warp-lane-estimate.d.ts +59 -0
  116. package/dist/fleets/warp-lane-estimate.d.ts.map +1 -0
  117. package/dist/fleets/warp-lane-estimate.js +36 -0
  118. package/dist/fleets/warp-lane-estimate.js.map +1 -0
  119. package/dist/fleets/warp-lane-policy.d.ts +68 -0
  120. package/dist/fleets/warp-lane-policy.d.ts.map +1 -0
  121. package/dist/fleets/warp-lane-policy.js +91 -0
  122. package/dist/fleets/warp-lane-policy.js.map +1 -0
  123. package/dist/fleets/warp-lane-toll.d.ts +55 -0
  124. package/dist/fleets/warp-lane-toll.d.ts.map +1 -0
  125. package/dist/fleets/warp-lane-toll.js +79 -0
  126. package/dist/fleets/warp-lane-toll.js.map +1 -0
  127. package/dist/identity/actions/create-profile.d.ts +2 -0
  128. package/dist/identity/actions/create-profile.d.ts.map +1 -1
  129. package/dist/identity/actions/create-profile.js +14 -9
  130. package/dist/identity/actions/create-profile.js.map +1 -1
  131. package/dist/identity/actions/index.d.ts +3 -3
  132. package/dist/identity/actions/index.d.ts.map +1 -1
  133. package/dist/identity/actions/index.js +48 -27
  134. package/dist/identity/actions/index.js.map +1 -1
  135. package/dist/identity/index.d.ts +8 -0
  136. package/dist/identity/index.d.ts.map +1 -1
  137. package/dist/identity/index.js +8 -0
  138. package/dist/identity/index.js.map +1 -1
  139. package/dist/identity/permissions.d.ts +19 -6
  140. package/dist/identity/permissions.d.ts.map +1 -1
  141. package/dist/identity/permissions.js +27 -10
  142. package/dist/identity/permissions.js.map +1 -1
  143. package/dist/identity/research-state.d.ts +60 -0
  144. package/dist/identity/research-state.d.ts.map +1 -0
  145. package/dist/identity/research-state.js +68 -0
  146. package/dist/identity/research-state.js.map +1 -0
  147. package/dist/index.d.ts +24 -0
  148. package/dist/index.d.ts.map +1 -1
  149. package/dist/index.js +20 -3
  150. package/dist/index.js.map +1 -1
  151. package/dist/internal/c4/cargo-bytes-config.d.ts +7 -0
  152. package/dist/internal/c4/cargo-bytes-config.d.ts.map +1 -0
  153. package/dist/internal/c4/cargo-bytes-config.js +19 -0
  154. package/dist/internal/c4/cargo-bytes-config.js.map +1 -0
  155. package/dist/internal/c4/character-registration.d.ts +2 -0
  156. package/dist/internal/c4/character-registration.d.ts.map +1 -1
  157. package/dist/internal/c4/character-registration.js +2 -0
  158. package/dist/internal/c4/character-registration.js.map +1 -1
  159. package/dist/internal/c4/claim-stake-definitions.d.ts +4 -4
  160. package/dist/internal/c4/claim-stake-definitions.d.ts.map +1 -1
  161. package/dist/internal/c4/claim-stake-definitions.js.map +1 -1
  162. package/dist/internal/c4/claim-stake.d.ts +4 -27
  163. package/dist/internal/c4/claim-stake.d.ts.map +1 -1
  164. package/dist/internal/c4/claim-stake.js +25 -38
  165. package/dist/internal/c4/claim-stake.js.map +1 -1
  166. package/dist/internal/c4/combat.d.ts +0 -27
  167. package/dist/internal/c4/combat.d.ts.map +1 -1
  168. package/dist/internal/c4/combat.js +0 -33
  169. package/dist/internal/c4/combat.js.map +1 -1
  170. package/dist/internal/c4/crafting-process-codec.d.ts +13 -0
  171. package/dist/internal/c4/crafting-process-codec.d.ts.map +1 -0
  172. package/dist/internal/c4/crafting-process-codec.js +34 -0
  173. package/dist/internal/c4/crafting-process-codec.js.map +1 -0
  174. package/dist/internal/c4/crafting.d.ts +25 -33
  175. package/dist/internal/c4/crafting.d.ts.map +1 -1
  176. package/dist/internal/c4/crafting.js +53 -44
  177. package/dist/internal/c4/crafting.js.map +1 -1
  178. package/dist/internal/c4/currency-cache.d.ts +6 -0
  179. package/dist/internal/c4/currency-cache.d.ts.map +1 -0
  180. package/dist/internal/c4/currency-cache.js +30 -0
  181. package/dist/internal/c4/currency-cache.js.map +1 -0
  182. package/dist/internal/c4/docking-funding.d.ts +4 -0
  183. package/dist/internal/c4/docking-funding.d.ts.map +1 -0
  184. package/dist/internal/c4/docking-funding.js +11 -0
  185. package/dist/internal/c4/docking-funding.js.map +1 -0
  186. package/dist/internal/c4/faction-adapter.d.ts +12 -0
  187. package/dist/internal/c4/faction-adapter.d.ts.map +1 -0
  188. package/dist/internal/c4/faction-adapter.js +52 -0
  189. package/dist/internal/c4/faction-adapter.js.map +1 -0
  190. package/dist/internal/c4/faction-epoch-meter.d.ts +10 -0
  191. package/dist/internal/c4/faction-epoch-meter.d.ts.map +1 -0
  192. package/dist/internal/c4/faction-epoch-meter.js +31 -0
  193. package/dist/internal/c4/faction-epoch-meter.js.map +1 -0
  194. package/dist/internal/c4/faction-treasury.d.ts +23 -0
  195. package/dist/internal/c4/faction-treasury.d.ts.map +1 -0
  196. package/dist/internal/c4/faction-treasury.js +48 -0
  197. package/dist/internal/c4/faction-treasury.js.map +1 -0
  198. package/dist/internal/c4/factions.d.ts +9 -57
  199. package/dist/internal/c4/factions.d.ts.map +1 -1
  200. package/dist/internal/c4/factions.js +21 -139
  201. package/dist/internal/c4/factions.js.map +1 -1
  202. package/dist/internal/c4/fleet-arrival.d.ts +28 -0
  203. package/dist/internal/c4/fleet-arrival.d.ts.map +1 -0
  204. package/dist/internal/c4/fleet-arrival.js +42 -0
  205. package/dist/internal/c4/fleet-arrival.js.map +1 -0
  206. package/dist/internal/c4/fleet-creation.d.ts +7 -0
  207. package/dist/internal/c4/fleet-creation.d.ts.map +1 -0
  208. package/dist/internal/c4/fleet-creation.js +180 -0
  209. package/dist/internal/c4/fleet-creation.js.map +1 -0
  210. package/dist/internal/c4/fleet-crew-binding.d.ts +9 -0
  211. package/dist/internal/c4/fleet-crew-binding.d.ts.map +1 -1
  212. package/dist/internal/c4/fleet-crew-binding.js +15 -0
  213. package/dist/internal/c4/fleet-crew-binding.js.map +1 -1
  214. package/dist/internal/c4/fleet-respawn.d.ts +17 -0
  215. package/dist/internal/c4/fleet-respawn.d.ts.map +1 -0
  216. package/dist/internal/c4/fleet-respawn.js +62 -0
  217. package/dist/internal/c4/fleet-respawn.js.map +1 -0
  218. package/dist/internal/c4/fleet-ship-assembly.d.ts +11 -0
  219. package/dist/internal/c4/fleet-ship-assembly.d.ts.map +1 -0
  220. package/dist/internal/c4/fleet-ship-assembly.js +44 -0
  221. package/dist/internal/c4/fleet-ship-assembly.js.map +1 -0
  222. package/dist/internal/c4/fleet.d.ts +45 -19
  223. package/dist/internal/c4/fleet.d.ts.map +1 -1
  224. package/dist/internal/c4/fleet.js +26 -7
  225. package/dist/internal/c4/fleet.js.map +1 -1
  226. package/dist/internal/c4/game-definition-layout.d.ts +2 -0
  227. package/dist/internal/c4/game-definition-layout.d.ts.map +1 -1
  228. package/dist/internal/c4/game-definition-layout.js +4 -0
  229. package/dist/internal/c4/game-definition-layout.js.map +1 -1
  230. package/dist/internal/c4/game.d.ts +46 -11
  231. package/dist/internal/c4/game.d.ts.map +1 -1
  232. package/dist/internal/c4/game.js +108 -20
  233. package/dist/internal/c4/game.js.map +1 -1
  234. package/dist/internal/c4/identity.d.ts +4 -2
  235. package/dist/internal/c4/identity.d.ts.map +1 -1
  236. package/dist/internal/c4/identity.js +1 -1
  237. package/dist/internal/c4/identity.js.map +1 -1
  238. package/dist/internal/c4/local-market-order.d.ts +31 -0
  239. package/dist/internal/c4/local-market-order.d.ts.map +1 -0
  240. package/dist/internal/c4/local-market-order.js +47 -0
  241. package/dist/internal/c4/local-market-order.js.map +1 -0
  242. package/dist/internal/c4/loyalty.d.ts +0 -27
  243. package/dist/internal/c4/loyalty.d.ts.map +1 -1
  244. package/dist/internal/c4/loyalty.js +0 -33
  245. package/dist/internal/c4/loyalty.js.map +1 -1
  246. package/dist/internal/c4/market.d.ts +2 -38
  247. package/dist/internal/c4/market.d.ts.map +1 -1
  248. package/dist/internal/c4/market.js +13 -51
  249. package/dist/internal/c4/market.js.map +1 -1
  250. package/dist/internal/c4/mining-instructions.d.ts +2 -0
  251. package/dist/internal/c4/mining-instructions.d.ts.map +1 -0
  252. package/dist/internal/c4/mining-instructions.js +3 -0
  253. package/dist/internal/c4/mining-instructions.js.map +1 -0
  254. package/dist/internal/c4/open-signal.d.ts +8 -0
  255. package/dist/internal/c4/open-signal.d.ts.map +1 -0
  256. package/dist/internal/c4/open-signal.js +37 -0
  257. package/dist/internal/c4/open-signal.js.map +1 -0
  258. package/dist/internal/c4/profile-permissions.d.ts +5 -3
  259. package/dist/internal/c4/profile-permissions.d.ts.map +1 -1
  260. package/dist/internal/c4/profile-permissions.js +61 -8
  261. package/dist/internal/c4/profile-permissions.js.map +1 -1
  262. package/dist/internal/c4/region-geometry.d.ts +8 -0
  263. package/dist/internal/c4/region-geometry.d.ts.map +1 -0
  264. package/dist/internal/c4/region-geometry.js +43 -0
  265. package/dist/internal/c4/region-geometry.js.map +1 -0
  266. package/dist/internal/c4/rewards.d.ts +0 -27
  267. package/dist/internal/c4/rewards.d.ts.map +1 -1
  268. package/dist/internal/c4/rewards.js +0 -33
  269. package/dist/internal/c4/rewards.js.map +1 -1
  270. package/dist/internal/c4/runtime-bindings.d.ts +4 -0
  271. package/dist/internal/c4/runtime-bindings.d.ts.map +1 -0
  272. package/dist/internal/c4/runtime-bindings.js +4 -0
  273. package/dist/internal/c4/runtime-bindings.js.map +1 -0
  274. package/dist/internal/c4/scan-detection-codecs.d.ts +3 -0
  275. package/dist/internal/c4/scan-detection-codecs.d.ts.map +1 -0
  276. package/dist/internal/c4/scan-detection-codecs.js +3 -0
  277. package/dist/internal/c4/scan-detection-codecs.js.map +1 -0
  278. package/dist/internal/c4/scan-lifecycle.d.ts +306 -0
  279. package/dist/internal/c4/scan-lifecycle.d.ts.map +1 -0
  280. package/dist/internal/c4/scan-lifecycle.js +258 -0
  281. package/dist/internal/c4/scan-lifecycle.js.map +1 -0
  282. package/dist/internal/c4/scanning.d.ts +1 -28
  283. package/dist/internal/c4/scanning.d.ts.map +1 -1
  284. package/dist/internal/c4/scanning.js +2 -33
  285. package/dist/internal/c4/scanning.js.map +1 -1
  286. package/dist/internal/c4/ship-import.d.ts +4 -0
  287. package/dist/internal/c4/ship-import.d.ts.map +1 -0
  288. package/dist/internal/c4/ship-import.js +13 -0
  289. package/dist/internal/c4/ship-import.js.map +1 -0
  290. package/dist/internal/c4/ship-stats.d.ts.map +1 -1
  291. package/dist/internal/c4/ship-stats.js +25 -21
  292. package/dist/internal/c4/ship-stats.js.map +1 -1
  293. package/dist/internal/c4/starbase.d.ts +0 -32
  294. package/dist/internal/c4/starbase.d.ts.map +1 -1
  295. package/dist/internal/c4/starbase.js +3 -41
  296. package/dist/internal/c4/starbase.js.map +1 -1
  297. package/dist/internal/c4/world.d.ts +36 -7
  298. package/dist/internal/c4/world.d.ts.map +1 -1
  299. package/dist/internal/c4/world.js +58 -25
  300. package/dist/internal/c4/world.js.map +1 -1
  301. package/dist/internal/cargo.d.ts +2 -0
  302. package/dist/internal/cargo.d.ts.map +1 -1
  303. package/dist/internal/cargo.js +8 -0
  304. package/dist/internal/cargo.js.map +1 -1
  305. package/dist/internal/fleet.d.ts +1 -0
  306. package/dist/internal/fleet.d.ts.map +1 -1
  307. package/dist/internal/fleet.js +3 -1
  308. package/dist/internal/fleet.js.map +1 -1
  309. package/dist/internal/loyalty-atlas-bank-state.d.ts +16 -0
  310. package/dist/internal/loyalty-atlas-bank-state.d.ts.map +1 -0
  311. package/dist/internal/loyalty-atlas-bank-state.js +10 -0
  312. package/dist/internal/loyalty-atlas-bank-state.js.map +1 -0
  313. package/dist/internal/planning/action-runtime.d.ts +38 -0
  314. package/dist/internal/planning/action-runtime.d.ts.map +1 -0
  315. package/dist/internal/planning/action-runtime.js +63 -0
  316. package/dist/internal/planning/action-runtime.js.map +1 -0
  317. package/dist/internal/planning/arrival-guards.d.ts +20 -0
  318. package/dist/internal/planning/arrival-guards.d.ts.map +1 -0
  319. package/dist/internal/planning/arrival-guards.js +187 -0
  320. package/dist/internal/planning/arrival-guards.js.map +1 -0
  321. package/dist/internal/planning/authorization-adapter.d.ts +45 -37
  322. package/dist/internal/planning/authorization-adapter.d.ts.map +1 -1
  323. package/dist/internal/planning/authorization-adapter.js +165 -76
  324. package/dist/internal/planning/authorization-adapter.js.map +1 -1
  325. package/dist/internal/planning/character-registration-guard.d.ts +4 -0
  326. package/dist/internal/planning/character-registration-guard.d.ts.map +1 -0
  327. package/dist/internal/planning/character-registration-guard.js +58 -0
  328. package/dist/internal/planning/character-registration-guard.js.map +1 -0
  329. package/dist/internal/planning/character-registration.d.ts +23 -0
  330. package/dist/internal/planning/character-registration.d.ts.map +1 -0
  331. package/dist/internal/planning/character-registration.js +86 -0
  332. package/dist/internal/planning/character-registration.js.map +1 -0
  333. package/dist/internal/planning/currency-cache-guard.d.ts +4 -0
  334. package/dist/internal/planning/currency-cache-guard.d.ts.map +1 -0
  335. package/dist/internal/planning/currency-cache-guard.js +32 -0
  336. package/dist/internal/planning/currency-cache-guard.js.map +1 -0
  337. package/dist/internal/planning/democracy-history.d.ts +50 -0
  338. package/dist/internal/planning/democracy-history.d.ts.map +1 -0
  339. package/dist/internal/planning/democracy-history.js +198 -0
  340. package/dist/internal/planning/democracy-history.js.map +1 -0
  341. package/dist/internal/planning/faction-enrollment.d.ts +0 -2
  342. package/dist/internal/planning/faction-enrollment.d.ts.map +1 -1
  343. package/dist/internal/planning/faction-enrollment.js +1 -22
  344. package/dist/internal/planning/faction-enrollment.js.map +1 -1
  345. package/dist/internal/planning/faction-trade-guards.d.ts +30 -0
  346. package/dist/internal/planning/faction-trade-guards.d.ts.map +1 -0
  347. package/dist/internal/planning/faction-trade-guards.js +15 -0
  348. package/dist/internal/planning/faction-trade-guards.js.map +1 -0
  349. package/dist/internal/planning/faction-trade-state.d.ts +16 -0
  350. package/dist/internal/planning/faction-trade-state.d.ts.map +1 -0
  351. package/dist/internal/planning/faction-trade-state.js +43 -0
  352. package/dist/internal/planning/faction-trade-state.js.map +1 -0
  353. package/dist/internal/planning/fleet-arrival.d.ts +40 -0
  354. package/dist/internal/planning/fleet-arrival.d.ts.map +1 -0
  355. package/dist/internal/planning/fleet-arrival.js +105 -0
  356. package/dist/internal/planning/fleet-arrival.js.map +1 -0
  357. package/dist/internal/planning/fleet-attack-xp.d.ts +20 -0
  358. package/dist/internal/planning/fleet-attack-xp.d.ts.map +1 -0
  359. package/dist/internal/planning/fleet-attack-xp.js +110 -0
  360. package/dist/internal/planning/fleet-attack-xp.js.map +1 -0
  361. package/dist/internal/planning/fleet-creation.d.ts +30 -0
  362. package/dist/internal/planning/fleet-creation.d.ts.map +1 -0
  363. package/dist/internal/planning/fleet-creation.js +108 -0
  364. package/dist/internal/planning/fleet-creation.js.map +1 -0
  365. package/dist/internal/planning/fleet-crew-guard.d.ts +28 -0
  366. package/dist/internal/planning/fleet-crew-guard.d.ts.map +1 -0
  367. package/dist/internal/planning/fleet-crew-guard.js +47 -0
  368. package/dist/internal/planning/fleet-crew-guard.js.map +1 -0
  369. package/dist/internal/planning/fleet-crew-transfer.d.ts +7 -0
  370. package/dist/internal/planning/fleet-crew-transfer.d.ts.map +1 -0
  371. package/dist/internal/planning/fleet-crew-transfer.js +131 -0
  372. package/dist/internal/planning/fleet-crew-transfer.js.map +1 -0
  373. package/dist/internal/planning/fleet-dock-funding-guard.d.ts +42 -0
  374. package/dist/internal/planning/fleet-dock-funding-guard.d.ts.map +1 -0
  375. package/dist/internal/planning/fleet-dock-funding-guard.js +225 -0
  376. package/dist/internal/planning/fleet-dock-funding-guard.js.map +1 -0
  377. package/dist/internal/planning/fleet-dock-funding.d.ts +9 -0
  378. package/dist/internal/planning/fleet-dock-funding.d.ts.map +1 -0
  379. package/dist/internal/planning/fleet-dock-funding.js +154 -0
  380. package/dist/internal/planning/fleet-dock-funding.js.map +1 -0
  381. package/dist/internal/planning/fleet-docking-guard.d.ts +4 -0
  382. package/dist/internal/planning/fleet-docking-guard.d.ts.map +1 -0
  383. package/dist/internal/planning/fleet-docking-guard.js +42 -0
  384. package/dist/internal/planning/fleet-docking-guard.js.map +1 -0
  385. package/dist/internal/planning/fleet-docking.d.ts +10 -0
  386. package/dist/internal/planning/fleet-docking.d.ts.map +1 -0
  387. package/dist/internal/planning/fleet-docking.js +85 -0
  388. package/dist/internal/planning/fleet-docking.js.map +1 -0
  389. package/dist/internal/planning/fleet-respawn.d.ts +28 -0
  390. package/dist/internal/planning/fleet-respawn.d.ts.map +1 -0
  391. package/dist/internal/planning/fleet-respawn.js +166 -0
  392. package/dist/internal/planning/fleet-respawn.js.map +1 -0
  393. package/dist/internal/planning/fleet-ship-assembly.d.ts +36 -0
  394. package/dist/internal/planning/fleet-ship-assembly.d.ts.map +1 -0
  395. package/dist/internal/planning/fleet-ship-assembly.js +137 -0
  396. package/dist/internal/planning/fleet-ship-assembly.js.map +1 -0
  397. package/dist/internal/planning/governance-fees.d.ts +64 -0
  398. package/dist/internal/planning/governance-fees.d.ts.map +1 -0
  399. package/dist/internal/planning/governance-fees.js +239 -0
  400. package/dist/internal/planning/governance-fees.js.map +1 -0
  401. package/dist/internal/planning/local-market-order-funding.d.ts +8 -0
  402. package/dist/internal/planning/local-market-order-funding.d.ts.map +1 -0
  403. package/dist/internal/planning/local-market-order-funding.js +126 -0
  404. package/dist/internal/planning/local-market-order-funding.js.map +1 -0
  405. package/dist/internal/planning/local-market-order.d.ts +40 -0
  406. package/dist/internal/planning/local-market-order.d.ts.map +1 -0
  407. package/dist/internal/planning/local-market-order.js +166 -0
  408. package/dist/internal/planning/local-market-order.js.map +1 -0
  409. package/dist/internal/planning/mining-stop.d.ts +14 -0
  410. package/dist/internal/planning/mining-stop.d.ts.map +1 -0
  411. package/dist/internal/planning/mining-stop.js +41 -0
  412. package/dist/internal/planning/mining-stop.js.map +1 -0
  413. package/dist/internal/planning/movement-character.d.ts +7 -0
  414. package/dist/internal/planning/movement-character.d.ts.map +1 -0
  415. package/dist/internal/planning/movement-character.js +41 -0
  416. package/dist/internal/planning/movement-character.js.map +1 -0
  417. package/dist/internal/planning/movement-xp-guard.d.ts +4 -0
  418. package/dist/internal/planning/movement-xp-guard.d.ts.map +1 -0
  419. package/dist/internal/planning/movement-xp-guard.js +103 -0
  420. package/dist/internal/planning/movement-xp-guard.js.map +1 -0
  421. package/dist/internal/planning/open-signal-guard.d.ts +3 -0
  422. package/dist/internal/planning/open-signal-guard.d.ts.map +1 -0
  423. package/dist/internal/planning/open-signal-guard.js +31 -0
  424. package/dist/internal/planning/open-signal-guard.js.map +1 -0
  425. package/dist/internal/planning/open-signal.d.ts +31 -0
  426. package/dist/internal/planning/open-signal.d.ts.map +1 -0
  427. package/dist/internal/planning/open-signal.js +85 -0
  428. package/dist/internal/planning/open-signal.js.map +1 -0
  429. package/dist/internal/planning/recipe-state.d.ts +6 -0
  430. package/dist/internal/planning/recipe-state.d.ts.map +1 -0
  431. package/dist/internal/planning/recipe-state.js +20 -0
  432. package/dist/internal/planning/recipe-state.js.map +1 -0
  433. package/dist/internal/planning/rent.d.ts +19 -0
  434. package/dist/internal/planning/rent.d.ts.map +1 -0
  435. package/dist/internal/planning/rent.js +35 -0
  436. package/dist/internal/planning/rent.js.map +1 -0
  437. package/dist/internal/planning/respawn-guards.d.ts +3 -0
  438. package/dist/internal/planning/respawn-guards.d.ts.map +1 -0
  439. package/dist/internal/planning/respawn-guards.js +41 -0
  440. package/dist/internal/planning/respawn-guards.js.map +1 -0
  441. package/dist/internal/planning/runtime-guards.d.ts +43 -0
  442. package/dist/internal/planning/runtime-guards.d.ts.map +1 -0
  443. package/dist/internal/planning/runtime-guards.js +638 -0
  444. package/dist/internal/planning/runtime-guards.js.map +1 -0
  445. package/dist/internal/planning/scan-completion-guard.d.ts +43 -0
  446. package/dist/internal/planning/scan-completion-guard.d.ts.map +1 -0
  447. package/dist/internal/planning/scan-completion-guard.js +94 -0
  448. package/dist/internal/planning/scan-completion-guard.js.map +1 -0
  449. package/dist/internal/planning/scan-completion.d.ts +20 -0
  450. package/dist/internal/planning/scan-completion.d.ts.map +1 -0
  451. package/dist/internal/planning/scan-completion.js +196 -0
  452. package/dist/internal/planning/scan-completion.js.map +1 -0
  453. package/dist/internal/planning/scan-detect-guard.d.ts +34 -0
  454. package/dist/internal/planning/scan-detect-guard.d.ts.map +1 -0
  455. package/dist/internal/planning/scan-detect-guard.js +77 -0
  456. package/dist/internal/planning/scan-detect-guard.js.map +1 -0
  457. package/dist/internal/planning/scan-detect.d.ts +24 -0
  458. package/dist/internal/planning/scan-detect.d.ts.map +1 -0
  459. package/dist/internal/planning/scan-detect.js +244 -0
  460. package/dist/internal/planning/scan-detect.js.map +1 -0
  461. package/dist/internal/planning/scan-input.d.ts +9 -0
  462. package/dist/internal/planning/scan-input.d.ts.map +1 -0
  463. package/dist/internal/planning/scan-input.js +58 -0
  464. package/dist/internal/planning/scan-input.js.map +1 -0
  465. package/dist/internal/planning/ship-import-funding.d.ts +22 -0
  466. package/dist/internal/planning/ship-import-funding.d.ts.map +1 -0
  467. package/dist/internal/planning/ship-import-funding.js +52 -0
  468. package/dist/internal/planning/ship-import-funding.js.map +1 -0
  469. package/dist/internal/planning/ship-token.d.ts +0 -1
  470. package/dist/internal/planning/ship-token.d.ts.map +1 -1
  471. package/dist/internal/planning/ship-token.js +2 -5
  472. package/dist/internal/planning/ship-token.js.map +1 -1
  473. package/dist/internal/planning/starbase-system-guard.d.ts +6 -0
  474. package/dist/internal/planning/starbase-system-guard.d.ts.map +1 -0
  475. package/dist/internal/planning/starbase-system-guard.js +93 -0
  476. package/dist/internal/planning/starbase-system-guard.js.map +1 -0
  477. package/dist/internal/planning/starbase-system.d.ts +15 -0
  478. package/dist/internal/planning/starbase-system.d.ts.map +1 -0
  479. package/dist/internal/planning/starbase-system.js +25 -0
  480. package/dist/internal/planning/starbase-system.js.map +1 -0
  481. package/dist/internal/planning/token-mint.d.ts +4 -0
  482. package/dist/internal/planning/token-mint.d.ts.map +1 -0
  483. package/dist/internal/planning/token-mint.js +15 -0
  484. package/dist/internal/planning/token-mint.js.map +1 -0
  485. package/dist/internal/planning/trade-faction-market.d.ts +20 -0
  486. package/dist/internal/planning/trade-faction-market.d.ts.map +1 -0
  487. package/dist/internal/planning/trade-faction-market.js +56 -0
  488. package/dist/internal/planning/trade-faction-market.js.map +1 -0
  489. package/dist/internal/planning/xp-runtime.d.ts +36 -0
  490. package/dist/internal/planning/xp-runtime.d.ts.map +1 -0
  491. package/dist/internal/planning/xp-runtime.js +126 -0
  492. package/dist/internal/planning/xp-runtime.js.map +1 -0
  493. package/dist/internal/system-program.d.ts +4 -0
  494. package/dist/internal/system-program.d.ts.map +1 -0
  495. package/dist/internal/system-program.js +3 -0
  496. package/dist/internal/system-program.js.map +1 -0
  497. package/dist/loyalty/actions/index.d.ts.map +1 -1
  498. package/dist/loyalty/actions/index.js +7 -20
  499. package/dist/loyalty/actions/index.js.map +1 -1
  500. package/dist/loyalty/index.d.ts.map +1 -1
  501. package/dist/loyalty/index.js +2 -6
  502. package/dist/loyalty/index.js.map +1 -1
  503. package/dist/markets/actions/index.d.ts +61 -3
  504. package/dist/markets/actions/index.d.ts.map +1 -1
  505. package/dist/markets/actions/index.js +142 -36
  506. package/dist/markets/actions/index.js.map +1 -1
  507. package/dist/markets/actions/trade-faction-market.d.ts +43 -0
  508. package/dist/markets/actions/trade-faction-market.d.ts.map +1 -0
  509. package/dist/markets/actions/trade-faction-market.js +282 -0
  510. package/dist/markets/actions/trade-faction-market.js.map +1 -0
  511. package/dist/markets/index.d.ts +38 -7
  512. package/dist/markets/index.d.ts.map +1 -1
  513. package/dist/markets/index.js +57 -10
  514. package/dist/markets/index.js.map +1 -1
  515. package/dist/mining/actions/index.d.ts +87 -0
  516. package/dist/mining/actions/index.d.ts.map +1 -0
  517. package/dist/mining/actions/index.js +332 -0
  518. package/dist/mining/actions/index.js.map +1 -0
  519. package/dist/mining/estimate.d.ts +114 -0
  520. package/dist/mining/estimate.d.ts.map +1 -0
  521. package/dist/mining/estimate.js +127 -0
  522. package/dist/mining/estimate.js.map +1 -0
  523. package/dist/mining/index.d.ts +9 -2
  524. package/dist/mining/index.d.ts.map +1 -1
  525. package/dist/mining/index.js +7 -2
  526. package/dist/mining/index.js.map +1 -1
  527. package/dist/mining/profile.d.ts +82 -0
  528. package/dist/mining/profile.d.ts.map +1 -0
  529. package/dist/mining/profile.js +109 -0
  530. package/dist/mining/profile.js.map +1 -0
  531. package/dist/planning/assembly.d.ts +5 -0
  532. package/dist/planning/assembly.d.ts.map +1 -1
  533. package/dist/planning/assembly.js +30 -2
  534. package/dist/planning/assembly.js.map +1 -1
  535. package/dist/planning/execution.d.ts +18 -3
  536. package/dist/planning/execution.d.ts.map +1 -1
  537. package/dist/planning/execution.js +492 -40
  538. package/dist/planning/execution.js.map +1 -1
  539. package/dist/planning/index.d.ts +196 -149
  540. package/dist/planning/index.d.ts.map +1 -1
  541. package/dist/planning/index.js +910 -121
  542. package/dist/planning/index.js.map +1 -1
  543. package/dist/planning/plan-sequence-checkpoint.d.ts +9 -0
  544. package/dist/planning/plan-sequence-checkpoint.d.ts.map +1 -1
  545. package/dist/planning/plan-sequence-checkpoint.js +16 -7
  546. package/dist/planning/plan-sequence-checkpoint.js.map +1 -1
  547. package/dist/planning/plan-sequence-execution.d.ts +5 -0
  548. package/dist/planning/plan-sequence-execution.d.ts.map +1 -1
  549. package/dist/planning/plan-sequence-execution.js +74 -30
  550. package/dist/planning/plan-sequence-execution.js.map +1 -1
  551. package/dist/planning/plan-sequence.d.ts +2 -1
  552. package/dist/planning/plan-sequence.d.ts.map +1 -1
  553. package/dist/planning/plan-sequence.js +8 -1
  554. package/dist/planning/plan-sequence.js.map +1 -1
  555. package/dist/planning/simulation.d.ts +25 -1
  556. package/dist/planning/simulation.d.ts.map +1 -1
  557. package/dist/planning/simulation.js +111 -11
  558. package/dist/planning/simulation.js.map +1 -1
  559. package/dist/registry/cargo.d.ts +7 -12
  560. package/dist/registry/cargo.d.ts.map +1 -1
  561. package/dist/registry/cargo.js +19 -19
  562. package/dist/registry/cargo.js.map +1 -1
  563. package/dist/registry/docking.d.ts +10 -0
  564. package/dist/registry/docking.d.ts.map +1 -0
  565. package/dist/registry/docking.js +12 -0
  566. package/dist/registry/docking.js.map +1 -0
  567. package/dist/registry/index.d.ts +4 -0
  568. package/dist/registry/index.d.ts.map +1 -1
  569. package/dist/registry/index.js.map +1 -1
  570. package/dist/registry/onboarding.d.ts +10 -2
  571. package/dist/registry/onboarding.d.ts.map +1 -1
  572. package/dist/registry/onboarding.js +20 -7
  573. package/dist/registry/onboarding.js.map +1 -1
  574. package/dist/registry/scanning.d.ts +7 -0
  575. package/dist/registry/scanning.d.ts.map +1 -0
  576. package/dist/registry/scanning.js +13 -0
  577. package/dist/registry/scanning.js.map +1 -0
  578. package/dist/registry/ship-stats-snapshot.js +19 -19
  579. package/dist/registry/ship-stats-snapshot.js.map +1 -1
  580. package/dist/registry/ships.d.ts +22 -2
  581. package/dist/registry/ships.d.ts.map +1 -1
  582. package/dist/registry/ships.js +31 -4
  583. package/dist/registry/ships.js.map +1 -1
  584. package/dist/registry/xp-runtime.d.ts +4 -0
  585. package/dist/registry/xp-runtime.d.ts.map +1 -0
  586. package/dist/registry/xp-runtime.js +14 -0
  587. package/dist/registry/xp-runtime.js.map +1 -0
  588. package/dist/scanning/actions/index.d.ts +116 -0
  589. package/dist/scanning/actions/index.d.ts.map +1 -0
  590. package/dist/scanning/actions/index.js +185 -0
  591. package/dist/scanning/actions/index.js.map +1 -0
  592. package/dist/scanning/index.d.ts +4 -1
  593. package/dist/scanning/index.d.ts.map +1 -1
  594. package/dist/scanning/index.js +12 -8
  595. package/dist/scanning/index.js.map +1 -1
  596. package/dist/scanning/lifecycle.d.ts +77 -0
  597. package/dist/scanning/lifecycle.d.ts.map +1 -0
  598. package/dist/scanning/lifecycle.js +93 -0
  599. package/dist/scanning/lifecycle.js.map +1 -0
  600. package/dist/scanning/odds.d.ts +111 -0
  601. package/dist/scanning/odds.d.ts.map +1 -0
  602. package/dist/scanning/odds.js +294 -0
  603. package/dist/scanning/odds.js.map +1 -0
  604. package/dist/scanning/signals.d.ts +121 -0
  605. package/dist/scanning/signals.d.ts.map +1 -0
  606. package/dist/scanning/signals.js +171 -0
  607. package/dist/scanning/signals.js.map +1 -0
  608. package/dist/world/index.d.ts +110 -5
  609. package/dist/world/index.d.ts.map +1 -1
  610. package/dist/world/index.js +109 -4
  611. package/dist/world/index.js.map +1 -1
  612. package/dist/world/planet-claim-stake-plots.d.ts +130 -0
  613. package/dist/world/planet-claim-stake-plots.d.ts.map +1 -0
  614. package/dist/world/planet-claim-stake-plots.js +110 -0
  615. package/dist/world/planet-claim-stake-plots.js.map +1 -0
  616. package/dist/world/starbase-status.d.ts +176 -0
  617. package/dist/world/starbase-status.d.ts.map +1 -0
  618. package/dist/world/starbase-status.js +153 -0
  619. package/dist/world/starbase-status.js.map +1 -0
  620. package/package.json +10 -2
@@ -1,9 +1,25 @@
1
+ import { validateCurrencyInstructions } from '../internal/planning/currency-cache-guard.js';
2
+ import { normalizeFleetDockFundingGuard, dockFundingGuardToJSON, validateFleetDockFundingGuards, } from '../internal/planning/fleet-dock-funding-guard.js';
3
+ import { normalizeLocalMarketOrderGuard, localMarketOrderGuardToJSON, validateLocalMarketOrderInstructions, } from '../internal/planning/local-market-order.js';
4
+ import { validateCrewTransferInstructions, } from '../internal/planning/fleet-crew-guard.js';
5
+ import { validateCompletionInstructions, scanCompletionDiscriminators, } from '../internal/planning/scan-completion-guard.js';
6
+ import { validateOpenSignalInstructions } from '../internal/planning/open-signal-guard.js';
7
+ import { validateDetectInstructions, } from '../internal/planning/scan-detect-guard.js';
8
+ import { validateRespawnInstructions } from '../internal/planning/respawn-guards.js';
9
+ import { validateFleetAttackInstructions, } from '../internal/planning/fleet-attack-xp.js';
10
+ import { validateMovementXpInstructions } from '../internal/planning/movement-xp-guard.js';
11
+ import { validateFleetDockingGuards } from '../internal/planning/fleet-docking-guard.js';
12
+ import { validateStarbaseSystemInstructions, validateStarbaseSystemGuards, } from '../internal/planning/starbase-system-guard.js';
13
+ import { validateCharacterRegistrationInstructions } from '../internal/planning/character-registration-guard.js';
14
+ import { normalizeArrivalGuard, arrivalGuardToJSON, validateArrivalInstructions, } from '../internal/planning/arrival-guards.js';
15
+ import { isRuntimeGuard, normalizeRuntimeGuard, runtimeGuardToJSON, validateRuntimeInstructions, } from '../internal/planning/runtime-guards.js';
16
+ import { isTradeBuyGuard, isTradeSellGuard, isTradeMeterGuard, isFactionTradeGuard, } from '../internal/planning/faction-trade-guards.js';
1
17
  import { AccountRole, getBase64Decoder, getBase64Encoder, isAddress, isWritableRole, } from '@solana/kit';
2
- import { InvalidActionInputError } from '../client/errors.js';
18
+ import { InvalidActionInputError, SageSdkError } from '../client/errors.js';
3
19
  import { deepFreeze } from '../internal/immutable-tree.js';
20
+ import { validateMiningStopInstructions } from '../internal/planning/mining-stop.js';
4
21
  import { validatePlanComposition } from './composition.js';
5
22
  import { isPlanInstance, registerPlanInstance } from './plan-instances.js';
6
- const PLAN_BRAND = Symbol('AephiaSagePlan');
7
23
  const BASE64_PATTERN = /^(?:[A-Za-z\d+/]{4})*(?:[A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/u;
8
24
  const DATA_HASH_PATTERN = /^[\da-f]{64}$/u;
9
25
  const ACCOUNT_ROLES = new Set([
@@ -138,7 +154,7 @@ function normalizeSemanticFact(value, field) {
138
154
  if (semantic.scope !== 'transaction') {
139
155
  return invalid(`${field}.scope`, semantic.scope, 'the token "transaction"');
140
156
  }
141
- return { kind: 'exclusive', scope: 'transaction' };
157
+ return Object.freeze({ kind: 'exclusive', scope: 'transaction' });
142
158
  }
143
159
  if (semantic.kind === 'requires' || semantic.kind === 'invalidates') {
144
160
  assertKeys(semantic, field, ['kind', 'resource', 'fact']);
@@ -159,9 +175,635 @@ function normalizeSemanticFact(value, field) {
159
175
  }
160
176
  return invalid(`${field}.kind`, semantic.kind, 'one of exclusive, requires, invalidates, or transition');
161
177
  }
162
- function normalizePrecondition(value, field, version = 6) {
178
+ function normalizePrecondition(value, field) {
163
179
  const precondition = readRecord(value, field);
164
- if (version >= 6 && precondition.kind === 'game-ship-config') {
180
+ if (precondition.kind === 'fleet-arrival')
181
+ return normalizeArrivalGuard(precondition, field);
182
+ if (isRuntimeGuard(precondition))
183
+ return normalizeRuntimeGuard(precondition, field);
184
+ if (precondition.kind === 'character-registration') {
185
+ assertKeys(precondition, field, [
186
+ 'kind',
187
+ 'address',
188
+ 'game',
189
+ 'profile',
190
+ 'profileDataHash',
191
+ 'funder',
192
+ 'xpBudget',
193
+ 'xpBudgetConfig',
194
+ 'maximumFunderDebit',
195
+ 'characterSize',
196
+ 'initializationHash',
197
+ 'characterLamports',
198
+ 'budgetLamports',
199
+ 'describes',
200
+ ]);
201
+ if (typeof precondition.characterSize !== 'number' ||
202
+ !Number.isSafeInteger(precondition.characterSize) ||
203
+ precondition.characterSize < 423)
204
+ invalid(`${field}.characterSize`, precondition.characterSize, 'a qualified Character allocation of at least 423 bytes');
205
+ for (const key of ['characterLamports', 'budgetLamports'])
206
+ if (typeof precondition[key] !== 'bigint' || precondition[key] < 0n)
207
+ invalid(`${field}.${key}`, precondition[key], 'a nonnegative bigint');
208
+ const maximumFunderDebit = precondition.maximumFunderDebit;
209
+ if (typeof maximumFunderDebit !== 'bigint' || maximumFunderDebit < 0n)
210
+ invalid(`${field}.maximumFunderDebit`, maximumFunderDebit, 'a nonnegative bigint');
211
+ return Object.freeze({
212
+ kind: 'character-registration',
213
+ address: readAddress(precondition.address, `${field}.address`),
214
+ game: readAddress(precondition.game, `${field}.game`),
215
+ profile: readAddress(precondition.profile, `${field}.profile`),
216
+ profileDataHash: readDataHash(precondition.profileDataHash, `${field}.profileDataHash`),
217
+ funder: readAddress(precondition.funder, `${field}.funder`),
218
+ xpBudget: readAddress(precondition.xpBudget, `${field}.xpBudget`),
219
+ xpBudgetConfig: readAddress(precondition.xpBudgetConfig, `${field}.xpBudgetConfig`),
220
+ maximumFunderDebit,
221
+ characterLamports: precondition.characterLamports,
222
+ budgetLamports: precondition.budgetLamports,
223
+ characterSize: precondition.characterSize,
224
+ initializationHash: readDataHash(precondition.initializationHash, `${field}.initializationHash`),
225
+ describes: readString(precondition.describes, `${field}.describes`),
226
+ });
227
+ }
228
+ if (precondition.kind === 'ship-import-funding') {
229
+ assertKeys(precondition, field, [
230
+ 'kind',
231
+ 'address',
232
+ 'game',
233
+ 'profile',
234
+ 'system',
235
+ 'shipId',
236
+ 'maximumProfileDebit',
237
+ 'describes',
238
+ ]);
239
+ const shipId = precondition.shipId;
240
+ if (typeof shipId !== 'number' ||
241
+ !Number.isInteger(shipId) ||
242
+ shipId < 0 ||
243
+ shipId > 65535)
244
+ invalid(`${field}.shipId`, shipId, 'an unsigned u16 ship configuration ID');
245
+ const maximumProfileDebit = precondition.maximumProfileDebit;
246
+ if (typeof maximumProfileDebit !== 'bigint' || maximumProfileDebit < 0n)
247
+ invalid(`${field}.maximumProfileDebit`, maximumProfileDebit, 'a nonnegative bigint');
248
+ return Object.freeze({
249
+ kind: 'ship-import-funding',
250
+ address: readAddress(precondition.address, `${field}.address`),
251
+ game: readAddress(precondition.game, `${field}.game`),
252
+ profile: readAddress(precondition.profile, `${field}.profile`),
253
+ system: readAddress(precondition.system, `${field}.system`),
254
+ shipId,
255
+ maximumProfileDebit,
256
+ describes: readString(precondition.describes, `${field}.describes`),
257
+ });
258
+ }
259
+ if (precondition.kind === 'fleet-attack') {
260
+ assertKeys(precondition, field, [
261
+ 'kind',
262
+ 'address',
263
+ 'defender',
264
+ 'game',
265
+ 'profile',
266
+ 'defenderProfile',
267
+ 'instructionKey',
268
+ 'describes',
269
+ ]);
270
+ return Object.freeze({
271
+ kind: 'fleet-attack',
272
+ address: readAddress(precondition.address, `${field}.address`),
273
+ defender: readAddress(precondition.defender, `${field}.defender`),
274
+ game: readAddress(precondition.game, `${field}.game`),
275
+ profile: readAddress(precondition.profile, `${field}.profile`),
276
+ defenderProfile: readAddress(precondition.defenderProfile, `${field}.defenderProfile`),
277
+ instructionKey: readString(precondition.instructionKey, `${field}.instructionKey`),
278
+ describes: readString(precondition.describes, `${field}.describes`),
279
+ });
280
+ }
281
+ if (precondition.kind === 'currency-cache') {
282
+ assertKeys(precondition, field, ['kind', 'address', 'game', 'describes']);
283
+ return Object.freeze({
284
+ kind: 'currency-cache',
285
+ address: readAddress(precondition.address, `${field}.address`),
286
+ game: readAddress(precondition.game, `${field}.game`),
287
+ describes: readString(precondition.describes, `${field}.describes`),
288
+ });
289
+ }
290
+ if (precondition.kind === 'movement-character') {
291
+ assertKeys(precondition, field, [
292
+ 'kind',
293
+ 'address',
294
+ 'game',
295
+ 'profile',
296
+ 'stateHash',
297
+ 'describes',
298
+ ]);
299
+ return Object.freeze({
300
+ kind: 'movement-character',
301
+ address: readAddress(precondition.address, `${field}.address`),
302
+ game: readAddress(precondition.game, `${field}.game`),
303
+ profile: readAddress(precondition.profile, `${field}.profile`),
304
+ stateHash: readDataHash(precondition.stateHash, `${field}.stateHash`),
305
+ describes: readString(precondition.describes, `${field}.describes`),
306
+ });
307
+ }
308
+ if (precondition.kind === 'fleet-docking-policy') {
309
+ assertKeys(precondition, field, [
310
+ 'kind',
311
+ 'address',
312
+ 'game',
313
+ 'system',
314
+ 'ownership',
315
+ 'describes',
316
+ ]);
317
+ return Object.freeze({
318
+ kind: 'fleet-docking-policy',
319
+ address: readAddress(precondition.address, `${field}.address`),
320
+ game: readAddress(precondition.game, `${field}.game`),
321
+ system: readAddress(precondition.system, `${field}.system`),
322
+ ownership: readAddress(precondition.ownership, `${field}.ownership`),
323
+ describes: readString(precondition.describes, `${field}.describes`),
324
+ });
325
+ }
326
+ if (precondition.kind === 'starbase-system') {
327
+ assertKeys(precondition, field, ['kind', 'address', 'game', 'starbaseSequenceId', 'describes'], ['requireCss']);
328
+ if (precondition.requireCss !== undefined &&
329
+ precondition.requireCss !== true)
330
+ invalid(`${field}.requireCss`, precondition.requireCss, 'true when CSS access is required, otherwise omitted');
331
+ const sequence = precondition.starbaseSequenceId;
332
+ if (typeof sequence !== 'bigint' ||
333
+ sequence < 0n ||
334
+ sequence > 18446744073709551615n)
335
+ invalid(`${field}.starbaseSequenceId`, sequence, 'an unsigned u64 Starbase sequence');
336
+ return Object.freeze({
337
+ kind: 'starbase-system',
338
+ address: readAddress(precondition.address, `${field}.address`),
339
+ game: readAddress(precondition.game, `${field}.game`),
340
+ starbaseSequenceId: sequence,
341
+ ...(precondition.requireCss === undefined
342
+ ? {}
343
+ : { requireCss: true }),
344
+ describes: readString(precondition.describes, `${field}.describes`),
345
+ });
346
+ }
347
+ if (precondition.kind === 'fleet-mining') {
348
+ assertKeys(precondition, field, [
349
+ 'kind',
350
+ 'address',
351
+ 'game',
352
+ 'profile',
353
+ 'asteroid',
354
+ 'describes',
355
+ ]);
356
+ return Object.freeze({
357
+ kind: 'fleet-mining',
358
+ address: readAddress(precondition.address, `${field}.address`),
359
+ game: readAddress(precondition.game, `${field}.game`),
360
+ profile: readAddress(precondition.profile, `${field}.profile`),
361
+ asteroid: readAddress(precondition.asteroid, `${field}.asteroid`),
362
+ describes: readString(precondition.describes, `${field}.describes`),
363
+ });
364
+ }
365
+ if (isFactionTradeGuard(precondition)) {
366
+ const kind = precondition.kind;
367
+ assertKeys(precondition, field, [
368
+ 'kind',
369
+ 'address',
370
+ 'game',
371
+ 'factionId',
372
+ 'describes',
373
+ 'schemaVersion',
374
+ ...(isTradeBuyGuard(precondition)
375
+ ? ['cargoId', 'floorRaw']
376
+ : isTradeSellGuard(precondition)
377
+ ? ['atlasOutCapPerEpochRaw', 'epochLengthSeconds']
378
+ : []),
379
+ ]);
380
+ const unsigned = (key, max = 65535) => {
381
+ const n = precondition[key];
382
+ if (typeof n !== 'number' || !Number.isInteger(n) || n < 0 || n > max)
383
+ invalid(`${field}.${key}`, n, `an unsigned ${max === 255 ? 'u8' : 'u16'} integer`);
384
+ return n;
385
+ };
386
+ const integer = (key, signed = false) => {
387
+ const n = precondition[key];
388
+ const min = signed ? -(1n << 63n) : 0n;
389
+ const max = signed ? (1n << 63n) - 1n : (1n << 64n) - 1n;
390
+ if (typeof n !== 'bigint' || n < min || n > max)
391
+ invalid(`${field}.${key}`, n, signed ? 'an i64 bigint' : 'a u64 bigint');
392
+ return n;
393
+ };
394
+ const common = {
395
+ address: readAddress(precondition.address, `${field}.address`),
396
+ game: readAddress(precondition.game, `${field}.game`),
397
+ factionId: unsigned('factionId'),
398
+ schemaVersion: unsigned('schemaVersion', 255),
399
+ describes: readString(precondition.describes, `${field}.describes`),
400
+ };
401
+ if (isTradeBuyGuard(precondition))
402
+ return Object.freeze({
403
+ kind,
404
+ ...common,
405
+ cargoId: unsigned('cargoId'),
406
+ floorRaw: integer('floorRaw'),
407
+ });
408
+ if (isTradeSellGuard(precondition))
409
+ return Object.freeze({
410
+ kind,
411
+ ...common,
412
+ atlasOutCapPerEpochRaw: integer('atlasOutCapPerEpochRaw'),
413
+ epochLengthSeconds: integer('epochLengthSeconds', true),
414
+ });
415
+ return Object.freeze({ kind, ...common });
416
+ }
417
+ if (precondition.kind === 'fleet-add-ship') {
418
+ assertKeys(precondition, field, [
419
+ 'kind',
420
+ 'address',
421
+ 'game',
422
+ 'profile',
423
+ 'authority',
424
+ 'system',
425
+ 'shipId',
426
+ 'amount',
427
+ 'keyIndex',
428
+ 'configHash',
429
+ 'maximumProfileDebit',
430
+ 'describes',
431
+ ]);
432
+ const keyIndex = precondition.keyIndex;
433
+ if (typeof keyIndex !== 'number' ||
434
+ !Number.isInteger(keyIndex) ||
435
+ keyIndex < 0 ||
436
+ keyIndex > 65535)
437
+ invalid(`${field}.keyIndex`, keyIndex, 'an integer from 0 through 65535');
438
+ const shipId = precondition.shipId;
439
+ if (typeof shipId !== 'number' ||
440
+ !Number.isInteger(shipId) ||
441
+ shipId < 0 ||
442
+ shipId > 65535)
443
+ invalid(`${field}.shipId`, shipId, 'a u16 ship configuration ID');
444
+ const amount = precondition.amount;
445
+ if (typeof amount !== 'bigint' || amount < 1n || amount > 255n)
446
+ invalid(`${field}.amount`, amount, 'a whole ship quantity from 1n through 255n');
447
+ const maximumProfileDebit = precondition.maximumProfileDebit;
448
+ if (typeof maximumProfileDebit !== 'bigint' || maximumProfileDebit < 0n)
449
+ invalid(`${field}.maximumProfileDebit`, maximumProfileDebit, 'a nonnegative bigint');
450
+ return Object.freeze({
451
+ kind: 'fleet-add-ship',
452
+ address: readAddress(precondition.address, `${field}.address`),
453
+ game: readAddress(precondition.game, `${field}.game`),
454
+ profile: readAddress(precondition.profile, `${field}.profile`),
455
+ authority: readAddress(precondition.authority, `${field}.authority`),
456
+ system: readAddress(precondition.system, `${field}.system`),
457
+ keyIndex,
458
+ shipId,
459
+ amount,
460
+ maximumProfileDebit,
461
+ configHash: readDataHash(precondition.configHash, `${field}.configHash`),
462
+ describes: readString(precondition.describes, `${field}.describes`),
463
+ });
464
+ }
465
+ if (precondition.kind === 'scan-completion') {
466
+ const addresses = [
467
+ 'address',
468
+ 'game',
469
+ 'signal',
470
+ 'profile',
471
+ 'character',
472
+ 'authority',
473
+ 'policy',
474
+ 'loot',
475
+ 'xpBudget',
476
+ 'xpConfig',
477
+ ];
478
+ assertKeys(precondition, field, [
479
+ 'kind',
480
+ 'operation',
481
+ ...addresses,
482
+ 'keyIndex',
483
+ 'status',
484
+ 'expectedSequence',
485
+ 'configHash',
486
+ 'describes',
487
+ ]);
488
+ if (typeof precondition.operation !== 'string' ||
489
+ !Object.hasOwn(scanCompletionDiscriminators, precondition.operation))
490
+ invalid(field, precondition.operation, 'a supported scan lifecycle operation');
491
+ const keyIndex = precondition.keyIndex, status = precondition.status, sequence = precondition.expectedSequence;
492
+ if (typeof keyIndex !== 'number' ||
493
+ !Number.isInteger(keyIndex) ||
494
+ keyIndex < 0 ||
495
+ keyIndex > 65535)
496
+ invalid(field, keyIndex, 'a u16 key index');
497
+ if (typeof status !== 'number' ||
498
+ !Number.isInteger(status) ||
499
+ status < 1 ||
500
+ status > 6)
501
+ invalid(field, status, 'a current nonempty signal state');
502
+ if (typeof sequence !== 'bigint' ||
503
+ sequence < 0n ||
504
+ sequence > 18446744073709551615n)
505
+ invalid(field, sequence, 'a u64 sequence');
506
+ const parsed = Object.fromEntries(addresses.map((k) => [k, readAddress(precondition[k], `${field}.${k}`)]));
507
+ return Object.freeze({
508
+ kind: 'scan-completion',
509
+ operation: precondition.operation,
510
+ ...parsed,
511
+ keyIndex,
512
+ status,
513
+ expectedSequence: sequence,
514
+ configHash: readDataHash(precondition.configHash, field),
515
+ describes: readString(precondition.describes, field),
516
+ });
517
+ }
518
+ if (precondition.kind === 'scan-detect') {
519
+ assertKeys(precondition, field, [
520
+ 'kind',
521
+ 'address',
522
+ 'game',
523
+ 'profile',
524
+ 'authority',
525
+ 'character',
526
+ 'signal',
527
+ 'pattern',
528
+ 'policy',
529
+ 'loot',
530
+ 'tracker',
531
+ 'keyIndex',
532
+ 'patternId',
533
+ 'focus',
534
+ 'expectedSequence',
535
+ 'policyRevision',
536
+ 'profileRevision',
537
+ 'configHash',
538
+ 'describes',
539
+ ]);
540
+ const numbers = {};
541
+ for (const [key, max] of [
542
+ ['keyIndex', 65535],
543
+ ['patternId', 65535],
544
+ ['focus', 4],
545
+ ['policyRevision', 4294967295],
546
+ ['profileRevision', 4294967295],
547
+ ]) {
548
+ const value = precondition[key];
549
+ if (typeof value !== 'number' ||
550
+ !Number.isInteger(value) ||
551
+ value < 0 ||
552
+ value > max)
553
+ invalid(`${field}.${key}`, value, `an integer from zero through ${max}`);
554
+ numbers[key] = value;
555
+ }
556
+ const sequence = precondition.expectedSequence;
557
+ if (typeof sequence !== 'bigint' ||
558
+ sequence < 0n ||
559
+ sequence > 18446744073709551615n)
560
+ invalid(`${field}.expectedSequence`, sequence, 'a u64 bigint');
561
+ return Object.freeze({
562
+ kind: 'scan-detect',
563
+ address: readAddress(precondition.address, field),
564
+ game: readAddress(precondition.game, field),
565
+ profile: readAddress(precondition.profile, field),
566
+ authority: readAddress(precondition.authority, field),
567
+ character: readAddress(precondition.character, field),
568
+ signal: readAddress(precondition.signal, field),
569
+ pattern: readAddress(precondition.pattern, field),
570
+ policy: readAddress(precondition.policy, field),
571
+ loot: readAddress(precondition.loot, field),
572
+ tracker: readAddress(precondition.tracker, field),
573
+ keyIndex: numbers.keyIndex,
574
+ patternId: numbers.patternId,
575
+ focus: numbers.focus,
576
+ policyRevision: numbers.policyRevision,
577
+ profileRevision: numbers.profileRevision,
578
+ expectedSequence: sequence,
579
+ configHash: readDataHash(precondition.configHash, field),
580
+ describes: readString(precondition.describes, field),
581
+ });
582
+ }
583
+ if (precondition.kind === 'fleet-crew-transfer') {
584
+ assertKeys(precondition, field, [
585
+ 'kind',
586
+ 'direction',
587
+ 'address',
588
+ 'game',
589
+ 'profile',
590
+ 'authority',
591
+ 'system',
592
+ 'starbasePlayer',
593
+ 'keyIndex',
594
+ 'count',
595
+ 'systemSequenceId',
596
+ 'describes',
597
+ ]);
598
+ for (const key of ['count', 'keyIndex']) {
599
+ const n = precondition[key];
600
+ if (typeof n !== 'number' ||
601
+ !Number.isInteger(n) ||
602
+ n < (key === 'count' ? 1 : 0) ||
603
+ n > 65535)
604
+ invalid(field, n, 'a positive u16 count and u16 key index');
605
+ }
606
+ const direction = precondition.direction, sequence = precondition.systemSequenceId;
607
+ if (direction !== 'load' && direction !== 'unload')
608
+ invalid(field, direction, 'load or unload');
609
+ if (typeof sequence !== 'bigint' ||
610
+ sequence < 0n ||
611
+ sequence > (1n << 64n) - 1n)
612
+ invalid(field, sequence, 'a u64 System generation');
613
+ return Object.freeze({
614
+ kind: 'fleet-crew-transfer',
615
+ direction,
616
+ address: readAddress(precondition.address, field),
617
+ game: readAddress(precondition.game, field),
618
+ profile: readAddress(precondition.profile, field),
619
+ authority: readAddress(precondition.authority, field),
620
+ system: readAddress(precondition.system, field),
621
+ starbasePlayer: readAddress(precondition.starbasePlayer, field),
622
+ count: precondition.count,
623
+ keyIndex: precondition.keyIndex,
624
+ systemSequenceId: sequence,
625
+ describes: readString(precondition.describes, field),
626
+ });
627
+ }
628
+ if (precondition.kind === 'fleet-respawn') {
629
+ assertKeys(precondition, field, [
630
+ 'kind',
631
+ 'address',
632
+ 'game',
633
+ 'profile',
634
+ 'authority',
635
+ 'system',
636
+ 'keyIndex',
637
+ 'phase',
638
+ 'fleetHash',
639
+ 'maximumRecoveryFee',
640
+ 'maximumProfileDebit',
641
+ 'describes',
642
+ ]);
643
+ const keyIndex = precondition.keyIndex;
644
+ if (typeof keyIndex !== 'number' ||
645
+ !Number.isInteger(keyIndex) ||
646
+ keyIndex < 0 ||
647
+ keyIndex > 65535)
648
+ invalid(`${field}.keyIndex`, keyIndex, 'a u16 key index');
649
+ const phase = precondition.phase;
650
+ if (phase !== 'start' && phase !== 'complete')
651
+ invalid(`${field}.phase`, phase, 'start or complete');
652
+ const maximumRecoveryFee = precondition.maximumRecoveryFee, maximumProfileDebit = precondition.maximumProfileDebit;
653
+ for (const value of [maximumRecoveryFee, maximumProfileDebit])
654
+ if (typeof value !== 'bigint' || value < 0n || value > (1n << 64n) - 1n)
655
+ invalid(field, value, 'a nonnegative u64 funding ceiling');
656
+ return Object.freeze({
657
+ kind: 'fleet-respawn',
658
+ address: readAddress(precondition.address, field),
659
+ game: readAddress(precondition.game, field),
660
+ profile: readAddress(precondition.profile, field),
661
+ authority: readAddress(precondition.authority, field),
662
+ system: readAddress(precondition.system, field),
663
+ keyIndex,
664
+ phase,
665
+ fleetHash: readDataHash(precondition.fleetHash, field),
666
+ maximumRecoveryFee: maximumRecoveryFee,
667
+ maximumProfileDebit: maximumProfileDebit,
668
+ describes: readString(precondition.describes, field),
669
+ });
670
+ }
671
+ if (precondition.kind === 'fleet-dock-funding')
672
+ return normalizeFleetDockFundingGuard(precondition);
673
+ if (precondition.kind === 'local-market-order')
674
+ return normalizeLocalMarketOrderGuard(precondition);
675
+ if (precondition.kind === 'scan-signal-open') {
676
+ assertKeys(precondition, field, [
677
+ 'kind',
678
+ 'address',
679
+ 'game',
680
+ 'fleet',
681
+ 'profile',
682
+ 'authority',
683
+ 'character',
684
+ 'keyIndex',
685
+ 'authorityHash',
686
+ 'maximumProfileDebit',
687
+ 'describes',
688
+ ]);
689
+ const keyIndex = precondition.keyIndex;
690
+ if (typeof keyIndex !== 'number' ||
691
+ !Number.isInteger(keyIndex) ||
692
+ keyIndex < 0 ||
693
+ keyIndex > 65535)
694
+ invalid(field, keyIndex, 'a u16 key index');
695
+ const maximumProfileDebit = precondition.maximumProfileDebit;
696
+ if (typeof maximumProfileDebit !== 'bigint' ||
697
+ maximumProfileDebit < 0n ||
698
+ maximumProfileDebit > 0xffffffffffffffffn)
699
+ invalid(field, maximumProfileDebit, 'a nonnegative u64 funding ceiling');
700
+ return Object.freeze({
701
+ kind: 'scan-signal-open',
702
+ authorityHash: readDataHash(precondition.authorityHash, field),
703
+ address: readAddress(precondition.address, field),
704
+ game: readAddress(precondition.game, field),
705
+ fleet: readAddress(precondition.fleet, field),
706
+ profile: readAddress(precondition.profile, field),
707
+ authority: readAddress(precondition.authority, field),
708
+ character: readAddress(precondition.character, field),
709
+ keyIndex,
710
+ maximumProfileDebit,
711
+ describes: readString(precondition.describes, field),
712
+ });
713
+ }
714
+ if (precondition.kind === 'fleet-create') {
715
+ assertKeys(precondition, field, [
716
+ 'kind',
717
+ 'address',
718
+ 'game',
719
+ 'profile',
720
+ 'authority',
721
+ 'system',
722
+ 'keyIndex',
723
+ 'label',
724
+ 'maximumProfileDebit',
725
+ 'describes',
726
+ ]);
727
+ const keyIndex = precondition.keyIndex;
728
+ if (typeof keyIndex !== 'number' ||
729
+ !Number.isSafeInteger(keyIndex) ||
730
+ keyIndex < 0 ||
731
+ keyIndex > 65_535)
732
+ invalid(`${field}.keyIndex`, keyIndex, 'an integer from 0 through 65535');
733
+ const label = readString(precondition.label, `${field}.label`);
734
+ const bytes = new TextEncoder().encode(label);
735
+ if (label.trim().length === 0 ||
736
+ label.includes('\0') ||
737
+ bytes.length > 64 ||
738
+ new TextDecoder('utf-8', { ignoreBOM: true }).decode(bytes) !== label)
739
+ invalid(`${field}.label`, label, 'a nonblank, NUL-free Unicode label of at most 64 UTF-8 bytes');
740
+ const maximumProfileDebit = precondition.maximumProfileDebit;
741
+ if (typeof maximumProfileDebit !== 'bigint' || maximumProfileDebit < 0n)
742
+ invalid(`${field}.maximumProfileDebit`, maximumProfileDebit, 'a nonnegative bigint');
743
+ return Object.freeze({
744
+ kind: 'fleet-create',
745
+ address: readAddress(precondition.address, `${field}.address`),
746
+ game: readAddress(precondition.game, `${field}.game`),
747
+ profile: readAddress(precondition.profile, `${field}.profile`),
748
+ authority: readAddress(precondition.authority, `${field}.authority`),
749
+ system: readAddress(precondition.system, `${field}.system`),
750
+ keyIndex,
751
+ label,
752
+ maximumProfileDebit,
753
+ describes: readString(precondition.describes, `${field}.describes`),
754
+ });
755
+ }
756
+ if (precondition.kind === 'system-account-or-absent') {
757
+ assertKeys(precondition, field, ['kind', 'address', 'describes']);
758
+ return Object.freeze({
759
+ kind: 'system-account-or-absent',
760
+ address: readAddress(precondition.address, `${field}.address`),
761
+ describes: readString(precondition.describes, `${field}.describes`),
762
+ });
763
+ }
764
+ if (precondition.kind === 'recipe-state') {
765
+ assertKeys(precondition, field, [
766
+ 'kind',
767
+ 'address',
768
+ 'configHash',
769
+ 'requiredUses',
770
+ 'describes',
771
+ ]);
772
+ const requiredUses = precondition.requiredUses;
773
+ if (typeof requiredUses !== 'bigint' ||
774
+ requiredUses < 0n ||
775
+ requiredUses > (1n << 64n) - 1n)
776
+ invalid(`${field}.requiredUses`, requiredUses, 'an unsigned u64 bigint');
777
+ const configHash = readDataHash(precondition.configHash, `${field}.configHash`);
778
+ return Object.freeze({
779
+ kind: 'recipe-state',
780
+ address: readAddress(precondition.address, `${field}.address`),
781
+ configHash,
782
+ requiredUses,
783
+ describes: readString(precondition.describes, `${field}.describes`),
784
+ });
785
+ }
786
+ if (precondition.kind === 'token-mint') {
787
+ assertKeys(precondition, field, [
788
+ 'kind',
789
+ 'address',
790
+ 'decimals',
791
+ 'describes',
792
+ ]);
793
+ const decimals = precondition.decimals;
794
+ if (typeof decimals !== 'number' ||
795
+ !Number.isInteger(decimals) ||
796
+ decimals < 0 ||
797
+ decimals > 255)
798
+ invalid(`${field}.decimals`, decimals, 'an unsigned u8 mint decimals value');
799
+ return Object.freeze({
800
+ kind: 'token-mint',
801
+ address: readAddress(precondition.address, `${field}.address`),
802
+ decimals,
803
+ describes: readString(precondition.describes, `${field}.describes`),
804
+ });
805
+ }
806
+ if (precondition.kind === 'game-ship-config') {
165
807
  assertKeys(precondition, field, [
166
808
  'kind',
167
809
  'address',
@@ -180,7 +822,7 @@ function normalizePrecondition(value, field, version = 6) {
180
822
  describes: readString(precondition.describes, `${field}.describes`),
181
823
  });
182
824
  }
183
- if (version >= 5 && precondition.kind === 'game-account') {
825
+ if (precondition.kind === 'game-account') {
184
826
  assertKeys(precondition, field, ['kind', 'address', 'describes']);
185
827
  return Object.freeze({
186
828
  kind: 'game-account',
@@ -188,8 +830,7 @@ function normalizePrecondition(value, field, version = 6) {
188
830
  describes: readString(precondition.describes, `${field}.describes`),
189
831
  });
190
832
  }
191
- if (version >= 4 &&
192
- ['token-account', 'game-cargo-config', 'cargo-cache'].includes(String(precondition.kind))) {
833
+ if (['game-cargo-bytes-config', 'token-account', 'cargo-cache'].includes(String(precondition.kind))) {
193
834
  const base = {
194
835
  address: readAddress(precondition.address, `${field}.address`),
195
836
  describes: readString(precondition.describes, `${field}.describes`),
@@ -216,7 +857,7 @@ function normalizePrecondition(value, field, version = 6) {
216
857
  minimumBalance: amount,
217
858
  });
218
859
  }
219
- if (precondition.kind === 'game-cargo-config') {
860
+ if (precondition.kind === 'game-cargo-bytes-config') {
220
861
  assertKeys(precondition, field, [
221
862
  'kind',
222
863
  'address',
@@ -232,7 +873,7 @@ function normalizePrecondition(value, field, version = 6) {
232
873
  invalid(`${field}.cargoId`, id, 'a u16 cargo ID');
233
874
  return Object.freeze({
234
875
  ...base,
235
- kind: 'game-cargo-config',
876
+ kind: precondition.kind,
236
877
  cargoId: id,
237
878
  configHash: readDataHash(precondition.configHash, `${field}.configHash`),
238
879
  });
@@ -257,7 +898,7 @@ function normalizePrecondition(value, field, version = 6) {
257
898
  bump,
258
899
  });
259
900
  }
260
- if (precondition.kind === 'token-account-or-absent' && version >= 3) {
901
+ if (precondition.kind === 'token-account-or-absent') {
261
902
  assertKeys(precondition, field, [
262
903
  'kind',
263
904
  'address',
@@ -273,7 +914,7 @@ function normalizePrecondition(value, field, version = 6) {
273
914
  describes: readString(precondition.describes, `${field}.describes`),
274
915
  });
275
916
  }
276
- if (precondition.kind === 'account-absent' && version !== 1) {
917
+ if (precondition.kind === 'account-absent') {
277
918
  assertKeys(precondition, field, ['kind', 'address', 'describes']);
278
919
  return Object.freeze({
279
920
  kind: 'account-absent',
@@ -282,17 +923,7 @@ function normalizePrecondition(value, field, version = 6) {
282
923
  });
283
924
  }
284
925
  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');
926
+ invalid(`${field}.kind`, precondition.kind, 'a supported current Plan guard; recreate the Plan using the current capability planner');
296
927
  }
297
928
  assertKeys(precondition, field, ['kind', 'address', 'dataHash', 'describes']);
298
929
  return Object.freeze({
@@ -328,84 +959,78 @@ function instructionToJSON(instruction) {
328
959
  return deepFreeze(value);
329
960
  }
330
961
  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 = {
962
+ return deepFreeze({
963
+ v: 27,
334
964
  kind: plan.kind,
335
965
  summary: plan.summary,
336
966
  affected: [...plan.affected],
337
967
  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,
968
+ steps: plan.steps.map((step) => ({
969
+ instruction: instructionToJSON(step.instruction),
970
+ describes: step.describes,
971
+ ...((step.semantics?.length ?? 0) > 0
972
+ ? { semantics: step.semantics.map((semantic) => ({ ...semantic })) }
973
+ : {}),
974
+ signers: [...step.signers],
408
975
  })),
976
+ preconditions: plan.preconditions.map((guard) => {
977
+ if (guard.kind === 'recipe-state')
978
+ return { ...guard, requiredUses: String(guard.requiredUses) };
979
+ if (guard.kind === 'scan-detect' || guard.kind === 'scan-completion')
980
+ return { ...guard, expectedSequence: String(guard.expectedSequence) };
981
+ if (guard.kind === 'fleet-dock-funding')
982
+ return dockFundingGuardToJSON(guard);
983
+ if (guard.kind === 'fleet-arrival')
984
+ return arrivalGuardToJSON(guard);
985
+ if (guard.kind === 'fleet-crew-transfer')
986
+ return { ...guard, systemSequenceId: String(guard.systemSequenceId) };
987
+ if (guard.kind === 'fleet-respawn')
988
+ return {
989
+ ...guard,
990
+ maximumRecoveryFee: String(guard.maximumRecoveryFee),
991
+ maximumProfileDebit: String(guard.maximumProfileDebit),
992
+ };
993
+ if (isRuntimeGuard(guard))
994
+ return runtimeGuardToJSON(guard);
995
+ if (isTradeBuyGuard(guard))
996
+ return { ...guard, floorRaw: String(guard.floorRaw) };
997
+ if (isTradeSellGuard(guard))
998
+ return {
999
+ ...guard,
1000
+ atlasOutCapPerEpochRaw: String(guard.atlasOutCapPerEpochRaw),
1001
+ epochLengthSeconds: String(guard.epochLengthSeconds),
1002
+ };
1003
+ if (guard.kind === 'fleet-add-ship')
1004
+ return {
1005
+ ...guard,
1006
+ amount: String(guard.amount),
1007
+ maximumProfileDebit: String(guard.maximumProfileDebit),
1008
+ };
1009
+ if (guard.kind === 'character-registration')
1010
+ return {
1011
+ ...guard,
1012
+ maximumFunderDebit: String(guard.maximumFunderDebit),
1013
+ characterLamports: String(guard.characterLamports),
1014
+ budgetLamports: String(guard.budgetLamports),
1015
+ };
1016
+ if (guard.kind === 'scan-signal-open' ||
1017
+ guard.kind === 'fleet-create' ||
1018
+ guard.kind === 'ship-import-funding')
1019
+ return {
1020
+ ...guard,
1021
+ maximumProfileDebit: String(guard.maximumProfileDebit),
1022
+ };
1023
+ if (guard.kind === 'starbase-system')
1024
+ return {
1025
+ ...guard,
1026
+ starbaseSequenceId: String(guard.starbaseSequenceId),
1027
+ };
1028
+ if (guard.kind === 'local-market-order')
1029
+ return localMarketOrderGuardToJSON(guard);
1030
+ if (guard.kind === 'token-account')
1031
+ return { ...guard, minimumBalance: String(guard.minimumBalance) };
1032
+ return { ...guard };
1033
+ }),
409
1034
  });
410
1035
  }
411
1036
  /** Creates an inert branded Plan while deriving every aggregate field.
@@ -427,6 +1052,17 @@ export function createPlan(input) {
427
1052
  assertKeys(value, 'plan', ['kind', 'summary', 'steps', 'preconditions']);
428
1053
  const steps = Object.freeze(readArray(value.steps, 'plan.steps').map((step, index) => normalizeStep(step, `plan.steps[${String(index)}]`)));
429
1054
  const preconditions = Object.freeze(readArray(value.preconditions, 'plan.preconditions').map((precondition, index) => normalizePrecondition(precondition, `plan.preconditions[${String(index)}]`)));
1055
+ validateCurrencyInstructions(steps, preconditions);
1056
+ validateShipImportFundingComposition(preconditions);
1057
+ validateStarbaseSystemGuards(steps, preconditions);
1058
+ validateFleetDockingGuards(steps, preconditions);
1059
+ validateFleetDockFundingGuards(steps, preconditions);
1060
+ validateDetectInstructions(steps, preconditions);
1061
+ validateCompletionInstructions(steps, preconditions);
1062
+ validateRespawnInstructions(steps, preconditions);
1063
+ validateCrewTransferInstructions(steps, preconditions);
1064
+ validateOpenSignalInstructions(steps, preconditions);
1065
+ validateLocalMarketOrderInstructions(steps, preconditions);
430
1066
  const descriptions = Object.freeze(steps.map((step) => step.describes));
431
1067
  const plan = {
432
1068
  kind: readString(value.kind, 'plan.kind'),
@@ -438,7 +1074,6 @@ export function createPlan(input) {
438
1074
  describe: () => descriptions,
439
1075
  toJSON: () => planToJSON(plan),
440
1076
  };
441
- Object.defineProperty(plan, PLAN_BRAND, { value: true });
442
1077
  registerPlanInstance(plan);
443
1078
  return Object.freeze(plan);
444
1079
  }
@@ -473,7 +1108,7 @@ function sameAddresses(actual, encoded) {
473
1108
  *
474
1109
  * @example
475
1110
  * ```ts
476
- * declare const wire: PlanJsonV1 | PlanJsonV2 | PlanJsonV3 | PlanJsonV4 | PlanJsonV5 | PlanJsonV6;
1111
+ * declare const wire: PlanJson;
477
1112
  * const plan = planFromJSON(wire);
478
1113
  * console.log(plan.describe());
479
1114
  * ```
@@ -489,34 +1124,122 @@ export function planFromJSON(json) {
489
1124
  'affected',
490
1125
  'requiredSigners',
491
1126
  ]);
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
- });
1127
+ if (value.v !== 27) {
1128
+ throw new InvalidActionInputError('planJson.v', value.v, 'the current Plan wire version 27', 'Recreate the Plan using the current capability planner; do not change its saved version or migrate its guards.');
511
1129
  }
1130
+ value.preconditions = readArray(value.preconditions, 'planJson.preconditions').map((entry) => {
1131
+ const guard = readRecord(entry, 'precondition');
1132
+ if (guard.kind === 'recipe-state') {
1133
+ if (typeof guard.requiredUses !== 'string' ||
1134
+ !/^(0|[1-9][0-9]*)$/.test(guard.requiredUses))
1135
+ invalid('requiredUses', guard.requiredUses, 'a canonical unsigned decimal string');
1136
+ return { ...guard, requiredUses: BigInt(guard.requiredUses) };
1137
+ }
1138
+ if (guard.kind === 'fleet-dock-funding')
1139
+ return normalizeFleetDockFundingGuard(guard, true);
1140
+ if (guard.kind === 'local-market-order')
1141
+ return normalizeLocalMarketOrderGuard(guard, true);
1142
+ if (guard.kind === 'scan-detect' || guard.kind === 'scan-completion') {
1143
+ if (typeof guard.expectedSequence !== 'string' ||
1144
+ !/^(0|[1-9][0-9]*)$/.test(guard.expectedSequence))
1145
+ invalid('expectedSequence', guard.expectedSequence, 'a canonical unsigned decimal string');
1146
+ return { ...guard, expectedSequence: BigInt(guard.expectedSequence) };
1147
+ }
1148
+ if (guard.kind === 'fleet-arrival')
1149
+ return normalizeArrivalGuard(guard, 'precondition', true);
1150
+ if (isRuntimeGuard(guard))
1151
+ return normalizeRuntimeGuard(guard, 'precondition', true);
1152
+ if (isTradeBuyGuard(guard) || isTradeSellGuard(guard)) {
1153
+ const keys = isTradeBuyGuard(guard)
1154
+ ? ['floorRaw']
1155
+ : ['atlasOutCapPerEpochRaw', 'epochLengthSeconds'];
1156
+ const decoded = { ...guard };
1157
+ for (const key of keys) {
1158
+ const raw = guard[key];
1159
+ const pattern = key === 'epochLengthSeconds'
1160
+ ? /^(0|[1-9][0-9]*|-[1-9][0-9]*)$/
1161
+ : /^(0|[1-9][0-9]*)$/;
1162
+ if (typeof raw !== 'string' || !pattern.test(raw))
1163
+ invalid(key, raw, 'a canonical decimal string');
1164
+ decoded[key] = BigInt(raw);
1165
+ }
1166
+ return decoded;
1167
+ }
1168
+ if (guard.kind === 'fleet-add-ship') {
1169
+ for (const field of ['amount', 'maximumProfileDebit'])
1170
+ if (typeof guard[field] !== 'string' ||
1171
+ !/^(0|[1-9][0-9]*)$/.test(guard[field]))
1172
+ invalid(field, guard[field], 'a canonical unsigned decimal string');
1173
+ return {
1174
+ ...guard,
1175
+ amount: BigInt(guard.amount),
1176
+ maximumProfileDebit: BigInt(guard.maximumProfileDebit),
1177
+ };
1178
+ }
1179
+ if (guard.kind === 'character-registration') {
1180
+ for (const key of ['characterLamports', 'budgetLamports'])
1181
+ if (typeof guard[key] !== 'string' ||
1182
+ !/^(0|[1-9][0-9]*)$/.test(guard[key]))
1183
+ invalid(key, guard[key], 'a canonical unsigned decimal string');
1184
+ if (typeof guard.maximumFunderDebit !== 'string' ||
1185
+ !/^(0|[1-9][0-9]*)$/.test(guard.maximumFunderDebit))
1186
+ invalid('maximumFunderDebit', guard.maximumFunderDebit, 'a canonical unsigned decimal string');
1187
+ return {
1188
+ ...guard,
1189
+ maximumFunderDebit: BigInt(guard.maximumFunderDebit),
1190
+ characterLamports: BigInt(guard.characterLamports),
1191
+ budgetLamports: BigInt(guard.budgetLamports),
1192
+ };
1193
+ }
1194
+ if (guard.kind === 'fleet-crew-transfer') {
1195
+ if (typeof guard.systemSequenceId !== 'string' ||
1196
+ !/^(0|[1-9][0-9]*)$/.test(guard.systemSequenceId))
1197
+ invalid('systemSequenceId', guard.systemSequenceId, 'a canonical unsigned decimal string');
1198
+ return { ...guard, systemSequenceId: BigInt(guard.systemSequenceId) };
1199
+ }
1200
+ if (guard.kind === 'fleet-respawn') {
1201
+ for (const key of ['maximumRecoveryFee', 'maximumProfileDebit'])
1202
+ if (typeof guard[key] !== 'string' ||
1203
+ !/^(0|[1-9][0-9]*)$/.test(guard[key]))
1204
+ invalid(key, guard[key], 'a canonical unsigned decimal string');
1205
+ return {
1206
+ ...guard,
1207
+ maximumRecoveryFee: BigInt(guard.maximumRecoveryFee),
1208
+ maximumProfileDebit: BigInt(guard.maximumProfileDebit),
1209
+ };
1210
+ }
1211
+ if (guard.kind === 'scan-signal-open' ||
1212
+ guard.kind === 'fleet-create' ||
1213
+ guard.kind === 'ship-import-funding') {
1214
+ if (typeof guard.maximumProfileDebit !== 'string' ||
1215
+ !/^(0|[1-9][0-9]*)$/.test(guard.maximumProfileDebit))
1216
+ invalid('maximumProfileDebit', guard.maximumProfileDebit, 'a canonical unsigned decimal string');
1217
+ return {
1218
+ ...guard,
1219
+ maximumProfileDebit: BigInt(guard.maximumProfileDebit),
1220
+ };
1221
+ }
1222
+ if (guard.kind === 'starbase-system') {
1223
+ if (typeof guard.starbaseSequenceId !== 'string' ||
1224
+ !/^(0|[1-9][0-9]*)$/.test(guard.starbaseSequenceId))
1225
+ invalid('starbaseSequenceId', guard.starbaseSequenceId, 'a canonical unsigned decimal string');
1226
+ return { ...guard, starbaseSequenceId: BigInt(guard.starbaseSequenceId) };
1227
+ }
1228
+ if (guard.kind !== 'token-account')
1229
+ return guard;
1230
+ if (typeof guard.minimumBalance !== 'string' ||
1231
+ !/^(0|[1-9][0-9]*)$/.test(guard.minimumBalance))
1232
+ invalid('minimumBalance', guard.minimumBalance, 'a canonical unsigned decimal string');
1233
+ return { ...guard, minimumBalance: BigInt(guard.minimumBalance) };
1234
+ });
512
1235
  const steps = readArray(value.steps, 'planJson.steps').map((candidate, index) => {
513
1236
  const field = `planJson.steps[${String(index)}]`;
514
1237
  const step = readRecord(candidate, field);
515
- assertKeys(step, field, ['instruction', 'describes', 'signers'], version !== 1 ? ['semantics'] : []);
1238
+ assertKeys(step, field, ['instruction', 'describes', 'signers'], ['semantics']);
516
1239
  return {
517
1240
  instruction: readWireInstruction(step.instruction, `${field}.instruction`),
518
1241
  describes: readString(step.describes, `${field}.describes`),
519
- ...(version !== 1 && step.semantics !== undefined
1242
+ ...(step.semantics !== undefined
520
1243
  ? {
521
1244
  semantics: readArray(step.semantics, `${field}.semantics`).map((semantic, semanticIndex) => normalizeSemanticFact(semantic, `${field}.semantics[${String(semanticIndex)}]`)),
522
1245
  }
@@ -524,7 +1247,7 @@ export function planFromJSON(json) {
524
1247
  signers: readArray(step.signers, `${field}.signers`).map((signer, signerIndex) => readAddress(signer, `${field}.signers[${String(signerIndex)}]`)),
525
1248
  };
526
1249
  });
527
- const preconditions = readArray(value.preconditions, 'planJson.preconditions').map((candidate, index) => normalizePrecondition(candidate, `planJson.preconditions[${String(index)}]`, version));
1250
+ const preconditions = readArray(value.preconditions, 'planJson.preconditions').map((candidate, index) => normalizePrecondition(candidate, `planJson.preconditions[${String(index)}]`));
528
1251
  const affected = readArray(value.affected, 'planJson.affected').map((candidate, index) => readAddress(candidate, `planJson.affected[${String(index)}]`));
529
1252
  const requiredSigners = readArray(value.requiredSigners, 'planJson.requiredSigners').map((candidate, index) => readAddress(candidate, `planJson.requiredSigners[${String(index)}]`));
530
1253
  const plan = createPlan({
@@ -533,6 +1256,12 @@ export function planFromJSON(json) {
533
1256
  steps,
534
1257
  preconditions,
535
1258
  });
1259
+ validateStarbaseSystemInstructions(plan.steps, plan.preconditions);
1260
+ validateFleetDockingGuards(plan.steps, plan.preconditions);
1261
+ validateFleetDockFundingGuards(plan.steps, plan.preconditions);
1262
+ validateMovementXpInstructions(plan.steps, plan.preconditions);
1263
+ validateFleetAttackInstructions(plan.steps, plan.preconditions);
1264
+ validateCharacterRegistrationInstructions(plan.steps, plan.preconditions);
536
1265
  if (!sameAddresses(plan.affected, affected)) {
537
1266
  invalid('planJson.affected', value.affected, 'the first-seen union of writable instruction account addresses');
538
1267
  }
@@ -549,6 +1278,49 @@ function assertPlan(value, index) {
549
1278
  function combinedSummary(steps) {
550
1279
  return steps.map((step) => step.describes).join(' ');
551
1280
  }
1281
+ function validateShipImportFundingComposition(guards) {
1282
+ const targets = new Map();
1283
+ for (const guard of guards) {
1284
+ if (guard.kind !== 'ship-import-funding')
1285
+ continue;
1286
+ const identity = `${guard.game}:${guard.profile}:${guard.system}:${String(guard.shipId)}`;
1287
+ const previous = targets.get(guard.address);
1288
+ if (previous !== undefined && previous !== identity)
1289
+ 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.');
1290
+ targets.set(guard.address, identity);
1291
+ }
1292
+ }
1293
+ function validateFactionGuardComposition(guards) {
1294
+ const retained = new Map();
1295
+ for (const guard of guards) {
1296
+ if (!isFactionTradeGuard(guard))
1297
+ continue;
1298
+ const constraints = [
1299
+ [
1300
+ `${isTradeMeterGuard(guard) ? 'meter' : 'treasury'}:${guard.address}:identity`,
1301
+ `${guard.game}:${String(guard.factionId)}`,
1302
+ ],
1303
+ ];
1304
+ if (!isTradeMeterGuard(guard)) {
1305
+ constraints.push(isTradeBuyGuard(guard)
1306
+ ? [
1307
+ `${guard.address}:buy:${String(guard.cargoId)}`,
1308
+ String(guard.floorRaw),
1309
+ ]
1310
+ : [
1311
+ `${guard.address}:sell`,
1312
+ `${String(guard.atlasOutCapPerEpochRaw)}:${String(guard.epochLengthSeconds)}`,
1313
+ ]);
1314
+ }
1315
+ constraints.push([`${guard.address}:schema`, String(guard.schemaVersion)]);
1316
+ for (const [key, value] of constraints) {
1317
+ const previous = retained.get(key);
1318
+ if (previous !== undefined && previous !== value)
1319
+ 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.');
1320
+ retained.set(key, value);
1321
+ }
1322
+ }
1323
+ }
552
1324
  /** Combines one or more Plans with deterministic associative flattening.
553
1325
  *
554
1326
  * Semantic validation is eager. Conflict indices are relative to the flattened
@@ -569,11 +1341,28 @@ export function combinePlans(...plans) {
569
1341
  plans.forEach(assertPlan);
570
1342
  const steps = plans.flatMap((plan) => plan.steps);
571
1343
  validatePlanComposition(steps);
1344
+ const preconditions = plans.flatMap((plan) => plan.preconditions);
1345
+ validateFactionGuardComposition(preconditions);
1346
+ validateMiningStopInstructions(steps, preconditions);
1347
+ validateStarbaseSystemInstructions(steps, preconditions);
1348
+ validateFleetDockingGuards(steps, preconditions);
1349
+ validateFleetDockFundingGuards(steps, preconditions);
1350
+ validateCharacterRegistrationInstructions(steps, preconditions);
1351
+ validateArrivalInstructions(steps, preconditions);
1352
+ validateDetectInstructions(steps, preconditions);
1353
+ validateCompletionInstructions(steps, preconditions);
1354
+ validateRespawnInstructions(steps, preconditions);
1355
+ validateCrewTransferInstructions(steps, preconditions);
1356
+ validateOpenSignalInstructions(steps, preconditions);
1357
+ validateLocalMarketOrderInstructions(steps, preconditions);
1358
+ validateRuntimeInstructions(steps, preconditions);
1359
+ validateMovementXpInstructions(steps, preconditions);
1360
+ validateFleetAttackInstructions(steps, preconditions);
572
1361
  return createPlan({
573
1362
  kind: 'combined',
574
1363
  summary: combinedSummary(steps),
575
1364
  steps,
576
- preconditions: plans.flatMap((plan) => plan.preconditions),
1365
+ preconditions,
577
1366
  });
578
1367
  }
579
1368
  export { assemblePlan } from './assembly.js';