@aephia/atlas-kit 0.6.0-next.11 → 0.6.0-next.110

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 (686) 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 +26 -115
  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 +15 -37
  8. package/dist/cargo/actions/index.js.map +1 -1
  9. package/dist/cargo/actions/wallet-context.d.ts +51 -2
  10. package/dist/cargo/actions/wallet-context.d.ts.map +1 -1
  11. package/dist/cargo/actions/wallet-context.js +125 -2
  12. package/dist/cargo/actions/wallet-context.js.map +1 -1
  13. package/dist/cargo/actions/wallet-token.d.ts +1 -6
  14. package/dist/cargo/actions/wallet-token.d.ts.map +1 -1
  15. package/dist/cargo/actions/wallet-token.js +0 -53
  16. package/dist/cargo/actions/wallet-token.js.map +1 -1
  17. package/dist/cargo/actions/withdrawal.d.ts.map +1 -1
  18. package/dist/cargo/actions/withdrawal.js +37 -162
  19. package/dist/cargo/actions/withdrawal.js.map +1 -1
  20. package/dist/claim-stakes/actions/index.d.ts +13 -0
  21. package/dist/claim-stakes/actions/index.d.ts.map +1 -1
  22. package/dist/claim-stakes/actions/index.js +373 -544
  23. package/dist/claim-stakes/actions/index.js.map +1 -1
  24. package/dist/claim-stakes/index.d.ts +14 -0
  25. package/dist/claim-stakes/index.d.ts.map +1 -1
  26. package/dist/claim-stakes/index.js +23 -2
  27. package/dist/claim-stakes/index.js.map +1 -1
  28. package/dist/client/context.d.ts.map +1 -1
  29. package/dist/client/context.js +1 -1
  30. package/dist/client/context.js.map +1 -1
  31. package/dist/client/contracts.d.ts +16 -6
  32. package/dist/client/contracts.d.ts.map +1 -1
  33. package/dist/client/errors.d.ts +6 -2
  34. package/dist/client/errors.d.ts.map +1 -1
  35. package/dist/client/errors.js +31 -1
  36. package/dist/client/errors.js.map +1 -1
  37. package/dist/client/index.d.ts +35 -0
  38. package/dist/client/index.d.ts.map +1 -1
  39. package/dist/client/index.js +35 -0
  40. package/dist/client/index.js.map +1 -1
  41. package/dist/client/rpc-subscription-provider.d.ts +35 -0
  42. package/dist/client/rpc-subscription-provider.d.ts.map +1 -0
  43. package/dist/client/rpc-subscription-provider.js +190 -0
  44. package/dist/client/rpc-subscription-provider.js.map +1 -0
  45. package/dist/combat/actions/index.d.ts +2 -2
  46. package/dist/combat/actions/index.d.ts.map +1 -1
  47. package/dist/combat/actions/index.js +192 -224
  48. package/dist/combat/actions/index.js.map +1 -1
  49. package/dist/combat/index.d.ts +4 -3
  50. package/dist/combat/index.d.ts.map +1 -1
  51. package/dist/combat/index.js +3 -2
  52. package/dist/combat/index.js.map +1 -1
  53. package/dist/crafting/actions/index.d.ts +11 -0
  54. package/dist/crafting/actions/index.d.ts.map +1 -1
  55. package/dist/crafting/actions/index.js +175 -283
  56. package/dist/crafting/actions/index.js.map +1 -1
  57. package/dist/crafting/index.d.ts +33 -3
  58. package/dist/crafting/index.d.ts.map +1 -1
  59. package/dist/crafting/index.js +45 -16
  60. package/dist/crafting/index.js.map +1 -1
  61. package/dist/factions/actions/index.d.ts +1 -0
  62. package/dist/factions/actions/index.d.ts.map +1 -1
  63. package/dist/factions/actions/index.js +2 -1
  64. package/dist/factions/actions/index.js.map +1 -1
  65. package/dist/factions/index.d.ts +1 -1
  66. package/dist/factions/index.d.ts.map +1 -1
  67. package/dist/factions/index.js +14 -8
  68. package/dist/factions/index.js.map +1 -1
  69. package/dist/factions/profile-faction.d.ts +20 -8
  70. package/dist/factions/profile-faction.d.ts.map +1 -1
  71. package/dist/factions/profile-faction.js +20 -8
  72. package/dist/factions/profile-faction.js.map +1 -1
  73. package/dist/fleets/actions/add-ship.d.ts +35 -0
  74. package/dist/fleets/actions/add-ship.d.ts.map +1 -0
  75. package/dist/fleets/actions/add-ship.js +149 -0
  76. package/dist/fleets/actions/add-ship.js.map +1 -0
  77. package/dist/fleets/actions/create-fleet.d.ts +36 -0
  78. package/dist/fleets/actions/create-fleet.d.ts.map +1 -0
  79. package/dist/fleets/actions/create-fleet.js +138 -0
  80. package/dist/fleets/actions/create-fleet.js.map +1 -0
  81. package/dist/fleets/actions/crew-transfer.d.ts +41 -0
  82. package/dist/fleets/actions/crew-transfer.d.ts.map +1 -0
  83. package/dist/fleets/actions/crew-transfer.js +114 -0
  84. package/dist/fleets/actions/crew-transfer.js.map +1 -0
  85. package/dist/fleets/actions/dock-bounds.d.ts +38 -0
  86. package/dist/fleets/actions/dock-bounds.d.ts.map +1 -0
  87. package/dist/fleets/actions/dock-bounds.js +46 -0
  88. package/dist/fleets/actions/dock-bounds.js.map +1 -0
  89. package/dist/fleets/actions/index.d.ts +37 -16
  90. package/dist/fleets/actions/index.d.ts.map +1 -1
  91. package/dist/fleets/actions/index.js +303 -284
  92. package/dist/fleets/actions/index.js.map +1 -1
  93. package/dist/fleets/actions/respawn.d.ts +38 -0
  94. package/dist/fleets/actions/respawn.d.ts.map +1 -0
  95. package/dist/fleets/actions/respawn.js +122 -0
  96. package/dist/fleets/actions/respawn.js.map +1 -0
  97. package/dist/fleets/actions/ship-import.d.ts.map +1 -1
  98. package/dist/fleets/actions/ship-import.js +59 -76
  99. package/dist/fleets/actions/ship-import.js.map +1 -1
  100. package/dist/fleets/cooldown.d.ts +44 -0
  101. package/dist/fleets/cooldown.d.ts.map +1 -0
  102. package/dist/fleets/cooldown.js +43 -0
  103. package/dist/fleets/cooldown.js.map +1 -0
  104. package/dist/fleets/coordinate-warp-estimate.d.ts +70 -0
  105. package/dist/fleets/coordinate-warp-estimate.d.ts.map +1 -0
  106. package/dist/fleets/coordinate-warp-estimate.js +46 -0
  107. package/dist/fleets/coordinate-warp-estimate.js.map +1 -0
  108. package/dist/fleets/index.d.ts +35 -0
  109. package/dist/fleets/index.d.ts.map +1 -1
  110. package/dist/fleets/index.js +52 -2
  111. package/dist/fleets/index.js.map +1 -1
  112. package/dist/fleets/movement-arithmetic.d.ts +21 -0
  113. package/dist/fleets/movement-arithmetic.d.ts.map +1 -0
  114. package/dist/fleets/movement-arithmetic.js +41 -0
  115. package/dist/fleets/movement-arithmetic.js.map +1 -0
  116. package/dist/fleets/subwarp-estimate.d.ts +70 -0
  117. package/dist/fleets/subwarp-estimate.d.ts.map +1 -0
  118. package/dist/fleets/subwarp-estimate.js +38 -0
  119. package/dist/fleets/subwarp-estimate.js.map +1 -0
  120. package/dist/fleets/travel-profile.d.ts +102 -0
  121. package/dist/fleets/travel-profile.d.ts.map +1 -0
  122. package/dist/fleets/travel-profile.js +120 -0
  123. package/dist/fleets/travel-profile.js.map +1 -0
  124. package/dist/fleets/warp-lane-estimate.d.ts +59 -0
  125. package/dist/fleets/warp-lane-estimate.d.ts.map +1 -0
  126. package/dist/fleets/warp-lane-estimate.js +36 -0
  127. package/dist/fleets/warp-lane-estimate.js.map +1 -0
  128. package/dist/fleets/warp-lane-policy.d.ts +68 -0
  129. package/dist/fleets/warp-lane-policy.d.ts.map +1 -0
  130. package/dist/fleets/warp-lane-policy.js +91 -0
  131. package/dist/fleets/warp-lane-policy.js.map +1 -0
  132. package/dist/fleets/warp-lane-toll.d.ts +55 -0
  133. package/dist/fleets/warp-lane-toll.d.ts.map +1 -0
  134. package/dist/fleets/warp-lane-toll.js +79 -0
  135. package/dist/fleets/warp-lane-toll.js.map +1 -0
  136. package/dist/identity/actions/index.d.ts +3 -3
  137. package/dist/identity/actions/index.d.ts.map +1 -1
  138. package/dist/identity/actions/index.js +50 -28
  139. package/dist/identity/actions/index.js.map +1 -1
  140. package/dist/identity/index.d.ts +12 -2
  141. package/dist/identity/index.d.ts.map +1 -1
  142. package/dist/identity/index.js +10 -1
  143. package/dist/identity/index.js.map +1 -1
  144. package/dist/identity/permissions.d.ts +11 -2
  145. package/dist/identity/permissions.d.ts.map +1 -1
  146. package/dist/identity/permissions.js +13 -4
  147. package/dist/identity/permissions.js.map +1 -1
  148. package/dist/identity/research-state.d.ts +60 -0
  149. package/dist/identity/research-state.d.ts.map +1 -0
  150. package/dist/identity/research-state.js +68 -0
  151. package/dist/identity/research-state.js.map +1 -0
  152. package/dist/index.d.ts +24 -0
  153. package/dist/index.d.ts.map +1 -1
  154. package/dist/index.js +20 -3
  155. package/dist/index.js.map +1 -1
  156. package/dist/internal/c4/account-decoding.d.ts +12 -0
  157. package/dist/internal/c4/account-decoding.d.ts.map +1 -0
  158. package/dist/internal/c4/account-decoding.js +36 -0
  159. package/dist/internal/c4/account-decoding.js.map +1 -0
  160. package/dist/internal/c4/cargo-bytes-config.d.ts +7 -0
  161. package/dist/internal/c4/cargo-bytes-config.d.ts.map +1 -0
  162. package/dist/internal/c4/cargo-bytes-config.js +19 -0
  163. package/dist/internal/c4/cargo-bytes-config.js.map +1 -0
  164. package/dist/internal/c4/character-modifier.d.ts +1 -1
  165. package/dist/internal/c4/character-modifier.d.ts.map +1 -1
  166. package/dist/internal/c4/character-registration.d.ts +2 -0
  167. package/dist/internal/c4/character-registration.d.ts.map +1 -1
  168. package/dist/internal/c4/character-registration.js +2 -0
  169. package/dist/internal/c4/character-registration.js.map +1 -1
  170. package/dist/internal/c4/character.d.ts +155 -0
  171. package/dist/internal/c4/character.d.ts.map +1 -0
  172. package/dist/internal/c4/character.js +79 -0
  173. package/dist/internal/c4/character.js.map +1 -0
  174. package/dist/internal/c4/claim-stake-configuration.js +4 -2
  175. package/dist/internal/c4/claim-stake-configuration.js.map +1 -1
  176. package/dist/internal/c4/claim-stake-definitions.d.ts +4 -4
  177. package/dist/internal/c4/claim-stake-definitions.d.ts.map +1 -1
  178. package/dist/internal/c4/claim-stake-definitions.js.map +1 -1
  179. package/dist/internal/c4/claim-stake.d.ts +4 -27
  180. package/dist/internal/c4/claim-stake.d.ts.map +1 -1
  181. package/dist/internal/c4/claim-stake.js +30 -41
  182. package/dist/internal/c4/claim-stake.js.map +1 -1
  183. package/dist/internal/c4/combat.d.ts +1 -82
  184. package/dist/internal/c4/combat.d.ts.map +1 -1
  185. package/dist/internal/c4/combat.js +10 -171
  186. package/dist/internal/c4/combat.js.map +1 -1
  187. package/dist/internal/c4/crafting-process-codec.d.ts +13 -0
  188. package/dist/internal/c4/crafting-process-codec.d.ts.map +1 -0
  189. package/dist/internal/c4/crafting-process-codec.js +34 -0
  190. package/dist/internal/c4/crafting-process-codec.js.map +1 -0
  191. package/dist/internal/c4/crafting.d.ts +25 -33
  192. package/dist/internal/c4/crafting.d.ts.map +1 -1
  193. package/dist/internal/c4/crafting.js +61 -49
  194. package/dist/internal/c4/crafting.js.map +1 -1
  195. package/dist/internal/c4/currency-cache.d.ts +6 -0
  196. package/dist/internal/c4/currency-cache.d.ts.map +1 -0
  197. package/dist/internal/c4/currency-cache.js +30 -0
  198. package/dist/internal/c4/currency-cache.js.map +1 -0
  199. package/dist/internal/c4/docking-funding.d.ts +4 -0
  200. package/dist/internal/c4/docking-funding.d.ts.map +1 -0
  201. package/dist/internal/c4/docking-funding.js +11 -0
  202. package/dist/internal/c4/docking-funding.js.map +1 -0
  203. package/dist/internal/c4/faction-adapter.d.ts +12 -0
  204. package/dist/internal/c4/faction-adapter.d.ts.map +1 -0
  205. package/dist/internal/c4/faction-adapter.js +52 -0
  206. package/dist/internal/c4/faction-adapter.js.map +1 -0
  207. package/dist/internal/c4/faction-epoch-meter.d.ts +10 -0
  208. package/dist/internal/c4/faction-epoch-meter.d.ts.map +1 -0
  209. package/dist/internal/c4/faction-epoch-meter.js +31 -0
  210. package/dist/internal/c4/faction-epoch-meter.js.map +1 -0
  211. package/dist/internal/c4/faction-treasury.d.ts +23 -0
  212. package/dist/internal/c4/faction-treasury.d.ts.map +1 -0
  213. package/dist/internal/c4/faction-treasury.js +48 -0
  214. package/dist/internal/c4/faction-treasury.js.map +1 -0
  215. package/dist/internal/c4/faction.d.ts +21 -0
  216. package/dist/internal/c4/faction.d.ts.map +1 -0
  217. package/dist/internal/c4/faction.js +23 -0
  218. package/dist/internal/c4/faction.js.map +1 -0
  219. package/dist/internal/c4/factions.d.ts +9 -57
  220. package/dist/internal/c4/factions.d.ts.map +1 -1
  221. package/dist/internal/c4/factions.js +29 -156
  222. package/dist/internal/c4/factions.js.map +1 -1
  223. package/dist/internal/c4/fleet-arrival.d.ts +28 -0
  224. package/dist/internal/c4/fleet-arrival.d.ts.map +1 -0
  225. package/dist/internal/c4/fleet-arrival.js +42 -0
  226. package/dist/internal/c4/fleet-arrival.js.map +1 -0
  227. package/dist/internal/c4/fleet-creation.d.ts +7 -0
  228. package/dist/internal/c4/fleet-creation.d.ts.map +1 -0
  229. package/dist/internal/c4/fleet-creation.js +180 -0
  230. package/dist/internal/c4/fleet-creation.js.map +1 -0
  231. package/dist/internal/c4/fleet-crew-binding.d.ts +9 -0
  232. package/dist/internal/c4/fleet-crew-binding.d.ts.map +1 -1
  233. package/dist/internal/c4/fleet-crew-binding.js +20 -3
  234. package/dist/internal/c4/fleet-crew-binding.js.map +1 -1
  235. package/dist/internal/c4/fleet-respawn.d.ts +17 -0
  236. package/dist/internal/c4/fleet-respawn.d.ts.map +1 -0
  237. package/dist/internal/c4/fleet-respawn.js +62 -0
  238. package/dist/internal/c4/fleet-respawn.js.map +1 -0
  239. package/dist/internal/c4/fleet-ship-assembly.d.ts +11 -0
  240. package/dist/internal/c4/fleet-ship-assembly.d.ts.map +1 -0
  241. package/dist/internal/c4/fleet-ship-assembly.js +44 -0
  242. package/dist/internal/c4/fleet-ship-assembly.js.map +1 -0
  243. package/dist/internal/c4/fleet.d.ts +45 -19
  244. package/dist/internal/c4/fleet.d.ts.map +1 -1
  245. package/dist/internal/c4/fleet.js +37 -29
  246. package/dist/internal/c4/fleet.js.map +1 -1
  247. package/dist/internal/c4/game-definition-layout.d.ts +2 -0
  248. package/dist/internal/c4/game-definition-layout.d.ts.map +1 -1
  249. package/dist/internal/c4/game-definition-layout.js +4 -0
  250. package/dist/internal/c4/game-definition-layout.js.map +1 -1
  251. package/dist/internal/c4/game.d.ts +47 -12
  252. package/dist/internal/c4/game.d.ts.map +1 -1
  253. package/dist/internal/c4/game.js +110 -21
  254. package/dist/internal/c4/game.js.map +1 -1
  255. package/dist/internal/c4/identity.d.ts +2 -152
  256. package/dist/internal/c4/identity.d.ts.map +1 -1
  257. package/dist/internal/c4/identity.js +6 -110
  258. package/dist/internal/c4/identity.js.map +1 -1
  259. package/dist/internal/c4/local-market-order.d.ts +31 -0
  260. package/dist/internal/c4/local-market-order.d.ts.map +1 -0
  261. package/dist/internal/c4/local-market-order.js +47 -0
  262. package/dist/internal/c4/local-market-order.js.map +1 -0
  263. package/dist/internal/c4/loot-layout.js +1 -1
  264. package/dist/internal/c4/loot-layout.js.map +1 -1
  265. package/dist/internal/c4/loot.d.ts +58 -0
  266. package/dist/internal/c4/loot.d.ts.map +1 -0
  267. package/dist/internal/c4/loot.js +130 -0
  268. package/dist/internal/c4/loot.js.map +1 -0
  269. package/dist/internal/c4/loyalty.d.ts +0 -27
  270. package/dist/internal/c4/loyalty.d.ts.map +1 -1
  271. package/dist/internal/c4/loyalty.js +14 -43
  272. package/dist/internal/c4/loyalty.js.map +1 -1
  273. package/dist/internal/c4/market.d.ts +2 -38
  274. package/dist/internal/c4/market.d.ts.map +1 -1
  275. package/dist/internal/c4/market.js +13 -51
  276. package/dist/internal/c4/market.js.map +1 -1
  277. package/dist/internal/c4/mining-instructions.d.ts +2 -0
  278. package/dist/internal/c4/mining-instructions.d.ts.map +1 -0
  279. package/dist/internal/c4/mining-instructions.js +3 -0
  280. package/dist/internal/c4/mining-instructions.js.map +1 -0
  281. package/dist/internal/c4/open-signal.d.ts +8 -0
  282. package/dist/internal/c4/open-signal.d.ts.map +1 -0
  283. package/dist/internal/c4/open-signal.js +37 -0
  284. package/dist/internal/c4/open-signal.js.map +1 -0
  285. package/dist/internal/c4/pda.js +1 -1
  286. package/dist/internal/c4/pda.js.map +1 -1
  287. package/dist/internal/c4/profile-faction.d.ts.map +1 -1
  288. package/dist/internal/c4/profile-faction.js +11 -21
  289. package/dist/internal/c4/profile-faction.js.map +1 -1
  290. package/dist/internal/c4/profile-permissions.d.ts +5 -3
  291. package/dist/internal/c4/profile-permissions.d.ts.map +1 -1
  292. package/dist/internal/c4/profile-permissions.js +61 -8
  293. package/dist/internal/c4/profile-permissions.js.map +1 -1
  294. package/dist/internal/c4/region-geometry.d.ts +8 -0
  295. package/dist/internal/c4/region-geometry.d.ts.map +1 -0
  296. package/dist/internal/c4/region-geometry.js +43 -0
  297. package/dist/internal/c4/region-geometry.js.map +1 -0
  298. package/dist/internal/c4/rewards.d.ts +1 -61
  299. package/dist/internal/c4/rewards.d.ts.map +1 -1
  300. package/dist/internal/c4/rewards.js +14 -115
  301. package/dist/internal/c4/rewards.js.map +1 -1
  302. package/dist/internal/c4/runtime-bindings.d.ts +4 -0
  303. package/dist/internal/c4/runtime-bindings.d.ts.map +1 -0
  304. package/dist/internal/c4/runtime-bindings.js +4 -0
  305. package/dist/internal/c4/runtime-bindings.js.map +1 -0
  306. package/dist/internal/c4/scan-detection-codecs.d.ts +3 -0
  307. package/dist/internal/c4/scan-detection-codecs.d.ts.map +1 -0
  308. package/dist/internal/c4/scan-detection-codecs.js +3 -0
  309. package/dist/internal/c4/scan-detection-codecs.js.map +1 -0
  310. package/dist/internal/c4/scan-lifecycle.d.ts +306 -0
  311. package/dist/internal/c4/scan-lifecycle.d.ts.map +1 -0
  312. package/dist/internal/c4/scan-lifecycle.js +261 -0
  313. package/dist/internal/c4/scan-lifecycle.js.map +1 -0
  314. package/dist/internal/c4/scanning.d.ts +1 -28
  315. package/dist/internal/c4/scanning.d.ts.map +1 -1
  316. package/dist/internal/c4/scanning.js +7 -36
  317. package/dist/internal/c4/scanning.js.map +1 -1
  318. package/dist/internal/c4/ship-import.d.ts +4 -0
  319. package/dist/internal/c4/ship-import.d.ts.map +1 -0
  320. package/dist/internal/c4/ship-import.js +13 -0
  321. package/dist/internal/c4/ship-import.js.map +1 -0
  322. package/dist/internal/c4/ship-stats.d.ts.map +1 -1
  323. package/dist/internal/c4/ship-stats.js +25 -21
  324. package/dist/internal/c4/ship-stats.js.map +1 -1
  325. package/dist/internal/c4/starbase.d.ts +0 -32
  326. package/dist/internal/c4/starbase.d.ts.map +1 -1
  327. package/dist/internal/c4/starbase.js +12 -62
  328. package/dist/internal/c4/starbase.js.map +1 -1
  329. package/dist/internal/c4/world.d.ts +36 -7
  330. package/dist/internal/c4/world.d.ts.map +1 -1
  331. package/dist/internal/c4/world.js +67 -48
  332. package/dist/internal/c4/world.js.map +1 -1
  333. package/dist/internal/cargo.d.ts +2 -0
  334. package/dist/internal/cargo.d.ts.map +1 -1
  335. package/dist/internal/cargo.js +8 -0
  336. package/dist/internal/cargo.js.map +1 -1
  337. package/dist/internal/fleet.d.ts +1 -0
  338. package/dist/internal/fleet.d.ts.map +1 -1
  339. package/dist/internal/fleet.js +3 -1
  340. package/dist/internal/fleet.js.map +1 -1
  341. package/dist/internal/loyalty-atlas-bank-state.d.ts +16 -0
  342. package/dist/internal/loyalty-atlas-bank-state.d.ts.map +1 -0
  343. package/dist/internal/loyalty-atlas-bank-state.js +10 -0
  344. package/dist/internal/loyalty-atlas-bank-state.js.map +1 -0
  345. package/dist/internal/planning/action-runtime.d.ts +38 -0
  346. package/dist/internal/planning/action-runtime.d.ts.map +1 -0
  347. package/dist/internal/planning/action-runtime.js +63 -0
  348. package/dist/internal/planning/action-runtime.js.map +1 -0
  349. package/dist/internal/planning/arrival-guards.d.ts +19 -0
  350. package/dist/internal/planning/arrival-guards.d.ts.map +1 -0
  351. package/dist/internal/planning/arrival-guards.js +171 -0
  352. package/dist/internal/planning/arrival-guards.js.map +1 -0
  353. package/dist/internal/planning/authorization-adapter.d.ts +45 -37
  354. package/dist/internal/planning/authorization-adapter.d.ts.map +1 -1
  355. package/dist/internal/planning/authorization-adapter.js +165 -76
  356. package/dist/internal/planning/authorization-adapter.js.map +1 -1
  357. package/dist/internal/planning/character-registration-guard.d.ts +4 -0
  358. package/dist/internal/planning/character-registration-guard.d.ts.map +1 -0
  359. package/dist/internal/planning/character-registration-guard.js +58 -0
  360. package/dist/internal/planning/character-registration-guard.js.map +1 -0
  361. package/dist/internal/planning/character-registration.d.ts +23 -0
  362. package/dist/internal/planning/character-registration.d.ts.map +1 -0
  363. package/dist/internal/planning/character-registration.js +87 -0
  364. package/dist/internal/planning/character-registration.js.map +1 -0
  365. package/dist/internal/planning/currency-cache-guard.d.ts +4 -0
  366. package/dist/internal/planning/currency-cache-guard.d.ts.map +1 -0
  367. package/dist/internal/planning/currency-cache-guard.js +32 -0
  368. package/dist/internal/planning/currency-cache-guard.js.map +1 -0
  369. package/dist/internal/planning/democracy-history.d.ts +50 -0
  370. package/dist/internal/planning/democracy-history.d.ts.map +1 -0
  371. package/dist/internal/planning/democracy-history.js +198 -0
  372. package/dist/internal/planning/democracy-history.js.map +1 -0
  373. package/dist/internal/planning/faction-enrollment.d.ts +0 -2
  374. package/dist/internal/planning/faction-enrollment.d.ts.map +1 -1
  375. package/dist/internal/planning/faction-enrollment.js +1 -22
  376. package/dist/internal/planning/faction-enrollment.js.map +1 -1
  377. package/dist/internal/planning/faction-trade-guards.d.ts +30 -0
  378. package/dist/internal/planning/faction-trade-guards.d.ts.map +1 -0
  379. package/dist/internal/planning/faction-trade-guards.js +15 -0
  380. package/dist/internal/planning/faction-trade-guards.js.map +1 -0
  381. package/dist/internal/planning/faction-trade-state.d.ts +16 -0
  382. package/dist/internal/planning/faction-trade-state.d.ts.map +1 -0
  383. package/dist/internal/planning/faction-trade-state.js +43 -0
  384. package/dist/internal/planning/faction-trade-state.js.map +1 -0
  385. package/dist/internal/planning/fleet-arrival.d.ts +40 -0
  386. package/dist/internal/planning/fleet-arrival.d.ts.map +1 -0
  387. package/dist/internal/planning/fleet-arrival.js +106 -0
  388. package/dist/internal/planning/fleet-arrival.js.map +1 -0
  389. package/dist/internal/planning/fleet-attack-xp.d.ts +20 -0
  390. package/dist/internal/planning/fleet-attack-xp.d.ts.map +1 -0
  391. package/dist/internal/planning/fleet-attack-xp.js +110 -0
  392. package/dist/internal/planning/fleet-attack-xp.js.map +1 -0
  393. package/dist/internal/planning/fleet-creation.d.ts +30 -0
  394. package/dist/internal/planning/fleet-creation.d.ts.map +1 -0
  395. package/dist/internal/planning/fleet-creation.js +109 -0
  396. package/dist/internal/planning/fleet-creation.js.map +1 -0
  397. package/dist/internal/planning/fleet-crew-guard.d.ts +28 -0
  398. package/dist/internal/planning/fleet-crew-guard.d.ts.map +1 -0
  399. package/dist/internal/planning/fleet-crew-guard.js +47 -0
  400. package/dist/internal/planning/fleet-crew-guard.js.map +1 -0
  401. package/dist/internal/planning/fleet-crew-transfer.d.ts +7 -0
  402. package/dist/internal/planning/fleet-crew-transfer.d.ts.map +1 -0
  403. package/dist/internal/planning/fleet-crew-transfer.js +132 -0
  404. package/dist/internal/planning/fleet-crew-transfer.js.map +1 -0
  405. package/dist/internal/planning/fleet-dock-funding-guard.d.ts +42 -0
  406. package/dist/internal/planning/fleet-dock-funding-guard.d.ts.map +1 -0
  407. package/dist/internal/planning/fleet-dock-funding-guard.js +208 -0
  408. package/dist/internal/planning/fleet-dock-funding-guard.js.map +1 -0
  409. package/dist/internal/planning/fleet-dock-funding.d.ts +9 -0
  410. package/dist/internal/planning/fleet-dock-funding.d.ts.map +1 -0
  411. package/dist/internal/planning/fleet-dock-funding.js +154 -0
  412. package/dist/internal/planning/fleet-dock-funding.js.map +1 -0
  413. package/dist/internal/planning/fleet-docking-guard.d.ts +4 -0
  414. package/dist/internal/planning/fleet-docking-guard.d.ts.map +1 -0
  415. package/dist/internal/planning/fleet-docking-guard.js +42 -0
  416. package/dist/internal/planning/fleet-docking-guard.js.map +1 -0
  417. package/dist/internal/planning/fleet-docking.d.ts +10 -0
  418. package/dist/internal/planning/fleet-docking.d.ts.map +1 -0
  419. package/dist/internal/planning/fleet-docking.js +85 -0
  420. package/dist/internal/planning/fleet-docking.js.map +1 -0
  421. package/dist/internal/planning/fleet-respawn.d.ts +28 -0
  422. package/dist/internal/planning/fleet-respawn.d.ts.map +1 -0
  423. package/dist/internal/planning/fleet-respawn.js +167 -0
  424. package/dist/internal/planning/fleet-respawn.js.map +1 -0
  425. package/dist/internal/planning/fleet-ship-assembly.d.ts +36 -0
  426. package/dist/internal/planning/fleet-ship-assembly.d.ts.map +1 -0
  427. package/dist/internal/planning/fleet-ship-assembly.js +138 -0
  428. package/dist/internal/planning/fleet-ship-assembly.js.map +1 -0
  429. package/dist/internal/planning/fleet-state.d.ts +25 -0
  430. package/dist/internal/planning/fleet-state.d.ts.map +1 -0
  431. package/dist/internal/planning/fleet-state.js +28 -0
  432. package/dist/internal/planning/fleet-state.js.map +1 -0
  433. package/dist/internal/planning/governance-fees.d.ts +64 -0
  434. package/dist/internal/planning/governance-fees.d.ts.map +1 -0
  435. package/dist/internal/planning/governance-fees.js +239 -0
  436. package/dist/internal/planning/governance-fees.js.map +1 -0
  437. package/dist/internal/planning/local-market-order-funding.d.ts +8 -0
  438. package/dist/internal/planning/local-market-order-funding.d.ts.map +1 -0
  439. package/dist/internal/planning/local-market-order-funding.js +127 -0
  440. package/dist/internal/planning/local-market-order-funding.js.map +1 -0
  441. package/dist/internal/planning/local-market-order.d.ts +40 -0
  442. package/dist/internal/planning/local-market-order.d.ts.map +1 -0
  443. package/dist/internal/planning/local-market-order.js +138 -0
  444. package/dist/internal/planning/local-market-order.js.map +1 -0
  445. package/dist/internal/planning/mining-stop.d.ts +14 -0
  446. package/dist/internal/planning/mining-stop.d.ts.map +1 -0
  447. package/dist/internal/planning/mining-stop.js +41 -0
  448. package/dist/internal/planning/mining-stop.js.map +1 -0
  449. package/dist/internal/planning/movement-character.d.ts +7 -0
  450. package/dist/internal/planning/movement-character.d.ts.map +1 -0
  451. package/dist/internal/planning/movement-character.js +41 -0
  452. package/dist/internal/planning/movement-character.js.map +1 -0
  453. package/dist/internal/planning/movement-xp-guard.d.ts +4 -0
  454. package/dist/internal/planning/movement-xp-guard.d.ts.map +1 -0
  455. package/dist/internal/planning/movement-xp-guard.js +103 -0
  456. package/dist/internal/planning/movement-xp-guard.js.map +1 -0
  457. package/dist/internal/planning/open-signal-guard.d.ts +3 -0
  458. package/dist/internal/planning/open-signal-guard.d.ts.map +1 -0
  459. package/dist/internal/planning/open-signal-guard.js +31 -0
  460. package/dist/internal/planning/open-signal-guard.js.map +1 -0
  461. package/dist/internal/planning/open-signal.d.ts +31 -0
  462. package/dist/internal/planning/open-signal.d.ts.map +1 -0
  463. package/dist/internal/planning/open-signal.js +86 -0
  464. package/dist/internal/planning/open-signal.js.map +1 -0
  465. package/dist/internal/planning/original-token.d.ts +34 -0
  466. package/dist/internal/planning/original-token.d.ts.map +1 -0
  467. package/dist/internal/planning/original-token.js +98 -0
  468. package/dist/internal/planning/original-token.js.map +1 -0
  469. package/dist/internal/planning/plan-fields.d.ts +59 -0
  470. package/dist/internal/planning/plan-fields.d.ts.map +1 -0
  471. package/dist/internal/planning/plan-fields.js +153 -0
  472. package/dist/internal/planning/plan-fields.js.map +1 -0
  473. package/dist/internal/planning/plan-guards.d.ts +4 -0
  474. package/dist/internal/planning/plan-guards.d.ts.map +1 -0
  475. package/dist/internal/planning/plan-guards.js +168 -0
  476. package/dist/internal/planning/plan-guards.js.map +1 -0
  477. package/dist/internal/planning/recipe-state.d.ts +6 -0
  478. package/dist/internal/planning/recipe-state.d.ts.map +1 -0
  479. package/dist/internal/planning/recipe-state.js +20 -0
  480. package/dist/internal/planning/recipe-state.js.map +1 -0
  481. package/dist/internal/planning/rent.d.ts +19 -0
  482. package/dist/internal/planning/rent.d.ts.map +1 -0
  483. package/dist/internal/planning/rent.js +35 -0
  484. package/dist/internal/planning/rent.js.map +1 -0
  485. package/dist/internal/planning/respawn-guards.d.ts +3 -0
  486. package/dist/internal/planning/respawn-guards.d.ts.map +1 -0
  487. package/dist/internal/planning/respawn-guards.js +41 -0
  488. package/dist/internal/planning/respawn-guards.js.map +1 -0
  489. package/dist/internal/planning/runtime-guards.d.ts +41 -0
  490. package/dist/internal/planning/runtime-guards.d.ts.map +1 -0
  491. package/dist/internal/planning/runtime-guards.js +635 -0
  492. package/dist/internal/planning/runtime-guards.js.map +1 -0
  493. package/dist/internal/planning/scan-completion-guard.d.ts +43 -0
  494. package/dist/internal/planning/scan-completion-guard.d.ts.map +1 -0
  495. package/dist/internal/planning/scan-completion-guard.js +94 -0
  496. package/dist/internal/planning/scan-completion-guard.js.map +1 -0
  497. package/dist/internal/planning/scan-completion.d.ts +20 -0
  498. package/dist/internal/planning/scan-completion.d.ts.map +1 -0
  499. package/dist/internal/planning/scan-completion.js +197 -0
  500. package/dist/internal/planning/scan-completion.js.map +1 -0
  501. package/dist/internal/planning/scan-detect-guard.d.ts +34 -0
  502. package/dist/internal/planning/scan-detect-guard.d.ts.map +1 -0
  503. package/dist/internal/planning/scan-detect-guard.js +77 -0
  504. package/dist/internal/planning/scan-detect-guard.js.map +1 -0
  505. package/dist/internal/planning/scan-detect.d.ts +24 -0
  506. package/dist/internal/planning/scan-detect.d.ts.map +1 -0
  507. package/dist/internal/planning/scan-detect.js +245 -0
  508. package/dist/internal/planning/scan-detect.js.map +1 -0
  509. package/dist/internal/planning/scan-input.d.ts +9 -0
  510. package/dist/internal/planning/scan-input.d.ts.map +1 -0
  511. package/dist/internal/planning/scan-input.js +58 -0
  512. package/dist/internal/planning/scan-input.js.map +1 -0
  513. package/dist/internal/planning/ship-import-funding.d.ts +22 -0
  514. package/dist/internal/planning/ship-import-funding.d.ts.map +1 -0
  515. package/dist/internal/planning/ship-import-funding.js +53 -0
  516. package/dist/internal/planning/ship-import-funding.js.map +1 -0
  517. package/dist/internal/planning/ship-token.d.ts +1 -6
  518. package/dist/internal/planning/ship-token.d.ts.map +1 -1
  519. package/dist/internal/planning/ship-token.js +2 -41
  520. package/dist/internal/planning/ship-token.js.map +1 -1
  521. package/dist/internal/planning/starbase-player-owner.d.ts +21 -0
  522. package/dist/internal/planning/starbase-player-owner.d.ts.map +1 -0
  523. package/dist/internal/planning/starbase-player-owner.js +17 -0
  524. package/dist/internal/planning/starbase-player-owner.js.map +1 -0
  525. package/dist/internal/planning/starbase-system-guard.d.ts +6 -0
  526. package/dist/internal/planning/starbase-system-guard.d.ts.map +1 -0
  527. package/dist/internal/planning/starbase-system-guard.js +93 -0
  528. package/dist/internal/planning/starbase-system-guard.js.map +1 -0
  529. package/dist/internal/planning/starbase-system.d.ts +15 -0
  530. package/dist/internal/planning/starbase-system.d.ts.map +1 -0
  531. package/dist/internal/planning/starbase-system.js +25 -0
  532. package/dist/internal/planning/starbase-system.js.map +1 -0
  533. package/dist/internal/planning/token-mint.d.ts +4 -0
  534. package/dist/internal/planning/token-mint.d.ts.map +1 -0
  535. package/dist/internal/planning/token-mint.js +15 -0
  536. package/dist/internal/planning/token-mint.js.map +1 -0
  537. package/dist/internal/planning/trade-faction-market.d.ts +20 -0
  538. package/dist/internal/planning/trade-faction-market.d.ts.map +1 -0
  539. package/dist/internal/planning/trade-faction-market.js +56 -0
  540. package/dist/internal/planning/trade-faction-market.js.map +1 -0
  541. package/dist/internal/planning/wallet-starbase.d.ts +34 -0
  542. package/dist/internal/planning/wallet-starbase.d.ts.map +1 -0
  543. package/dist/internal/planning/wallet-starbase.js +39 -0
  544. package/dist/internal/planning/wallet-starbase.js.map +1 -0
  545. package/dist/internal/planning/xp-runtime.d.ts +36 -0
  546. package/dist/internal/planning/xp-runtime.d.ts.map +1 -0
  547. package/dist/internal/planning/xp-runtime.js +126 -0
  548. package/dist/internal/planning/xp-runtime.js.map +1 -0
  549. package/dist/internal/system-program.d.ts +4 -0
  550. package/dist/internal/system-program.d.ts.map +1 -0
  551. package/dist/internal/system-program.js +3 -0
  552. package/dist/internal/system-program.js.map +1 -0
  553. package/dist/loyalty/actions/index.d.ts.map +1 -1
  554. package/dist/loyalty/actions/index.js +8 -21
  555. package/dist/loyalty/actions/index.js.map +1 -1
  556. package/dist/loyalty/index.d.ts.map +1 -1
  557. package/dist/loyalty/index.js +2 -6
  558. package/dist/loyalty/index.js.map +1 -1
  559. package/dist/markets/actions/index.d.ts +61 -3
  560. package/dist/markets/actions/index.d.ts.map +1 -1
  561. package/dist/markets/actions/index.js +227 -160
  562. package/dist/markets/actions/index.js.map +1 -1
  563. package/dist/markets/actions/trade-faction-market.d.ts +43 -0
  564. package/dist/markets/actions/trade-faction-market.d.ts.map +1 -0
  565. package/dist/markets/actions/trade-faction-market.js +282 -0
  566. package/dist/markets/actions/trade-faction-market.js.map +1 -0
  567. package/dist/markets/index.d.ts +38 -7
  568. package/dist/markets/index.d.ts.map +1 -1
  569. package/dist/markets/index.js +57 -10
  570. package/dist/markets/index.js.map +1 -1
  571. package/dist/mining/actions/index.d.ts +87 -0
  572. package/dist/mining/actions/index.d.ts.map +1 -0
  573. package/dist/mining/actions/index.js +319 -0
  574. package/dist/mining/actions/index.js.map +1 -0
  575. package/dist/mining/estimate.d.ts +114 -0
  576. package/dist/mining/estimate.d.ts.map +1 -0
  577. package/dist/mining/estimate.js +127 -0
  578. package/dist/mining/estimate.js.map +1 -0
  579. package/dist/mining/index.d.ts +9 -2
  580. package/dist/mining/index.d.ts.map +1 -1
  581. package/dist/mining/index.js +7 -2
  582. package/dist/mining/index.js.map +1 -1
  583. package/dist/mining/profile.d.ts +82 -0
  584. package/dist/mining/profile.d.ts.map +1 -0
  585. package/dist/mining/profile.js +109 -0
  586. package/dist/mining/profile.js.map +1 -0
  587. package/dist/planning/assembly.d.ts +5 -0
  588. package/dist/planning/assembly.d.ts.map +1 -1
  589. package/dist/planning/assembly.js +8 -4
  590. package/dist/planning/assembly.js.map +1 -1
  591. package/dist/planning/execution.d.ts +18 -3
  592. package/dist/planning/execution.d.ts.map +1 -1
  593. package/dist/planning/execution.js +492 -40
  594. package/dist/planning/execution.js.map +1 -1
  595. package/dist/planning/index.d.ts +196 -149
  596. package/dist/planning/index.d.ts.map +1 -1
  597. package/dist/planning/index.js +44 -292
  598. package/dist/planning/index.js.map +1 -1
  599. package/dist/planning/plan-sequence-checkpoint.d.ts +9 -0
  600. package/dist/planning/plan-sequence-checkpoint.d.ts.map +1 -1
  601. package/dist/planning/plan-sequence-checkpoint.js +16 -7
  602. package/dist/planning/plan-sequence-checkpoint.js.map +1 -1
  603. package/dist/planning/plan-sequence-execution.d.ts +5 -0
  604. package/dist/planning/plan-sequence-execution.d.ts.map +1 -1
  605. package/dist/planning/plan-sequence-execution.js +74 -30
  606. package/dist/planning/plan-sequence-execution.js.map +1 -1
  607. package/dist/planning/plan-sequence.d.ts +2 -1
  608. package/dist/planning/plan-sequence.d.ts.map +1 -1
  609. package/dist/planning/plan-sequence.js +8 -1
  610. package/dist/planning/plan-sequence.js.map +1 -1
  611. package/dist/planning/plan-validation.d.ts +14 -0
  612. package/dist/planning/plan-validation.d.ts.map +1 -0
  613. package/dist/planning/plan-validation.js +124 -0
  614. package/dist/planning/plan-validation.js.map +1 -0
  615. package/dist/planning/simulation.d.ts +25 -1
  616. package/dist/planning/simulation.d.ts.map +1 -1
  617. package/dist/planning/simulation.js +111 -11
  618. package/dist/planning/simulation.js.map +1 -1
  619. package/dist/registry/cargo.d.ts +7 -12
  620. package/dist/registry/cargo.d.ts.map +1 -1
  621. package/dist/registry/cargo.js +19 -19
  622. package/dist/registry/cargo.js.map +1 -1
  623. package/dist/registry/docking.d.ts +10 -0
  624. package/dist/registry/docking.d.ts.map +1 -0
  625. package/dist/registry/docking.js +12 -0
  626. package/dist/registry/docking.js.map +1 -0
  627. package/dist/registry/index.d.ts +4 -0
  628. package/dist/registry/index.d.ts.map +1 -1
  629. package/dist/registry/index.js.map +1 -1
  630. package/dist/registry/onboarding.d.ts +10 -2
  631. package/dist/registry/onboarding.d.ts.map +1 -1
  632. package/dist/registry/onboarding.js +20 -7
  633. package/dist/registry/onboarding.js.map +1 -1
  634. package/dist/registry/scanning.d.ts +7 -0
  635. package/dist/registry/scanning.d.ts.map +1 -0
  636. package/dist/registry/scanning.js +13 -0
  637. package/dist/registry/scanning.js.map +1 -0
  638. package/dist/registry/ship-stats-snapshot.js +19 -19
  639. package/dist/registry/ship-stats-snapshot.js.map +1 -1
  640. package/dist/registry/ships.d.ts +22 -2
  641. package/dist/registry/ships.d.ts.map +1 -1
  642. package/dist/registry/ships.js +31 -4
  643. package/dist/registry/ships.js.map +1 -1
  644. package/dist/registry/xp-runtime.d.ts +4 -0
  645. package/dist/registry/xp-runtime.d.ts.map +1 -0
  646. package/dist/registry/xp-runtime.js +14 -0
  647. package/dist/registry/xp-runtime.js.map +1 -0
  648. package/dist/rewards/index.d.ts.map +1 -1
  649. package/dist/rewards/index.js +5 -4
  650. package/dist/rewards/index.js.map +1 -1
  651. package/dist/scanning/actions/index.d.ts +116 -0
  652. package/dist/scanning/actions/index.d.ts.map +1 -0
  653. package/dist/scanning/actions/index.js +185 -0
  654. package/dist/scanning/actions/index.js.map +1 -0
  655. package/dist/scanning/index.d.ts +5 -2
  656. package/dist/scanning/index.d.ts.map +1 -1
  657. package/dist/scanning/index.js +13 -9
  658. package/dist/scanning/index.js.map +1 -1
  659. package/dist/scanning/lifecycle.d.ts +77 -0
  660. package/dist/scanning/lifecycle.d.ts.map +1 -0
  661. package/dist/scanning/lifecycle.js +93 -0
  662. package/dist/scanning/lifecycle.js.map +1 -0
  663. package/dist/scanning/odds.d.ts +111 -0
  664. package/dist/scanning/odds.d.ts.map +1 -0
  665. package/dist/scanning/odds.js +294 -0
  666. package/dist/scanning/odds.js.map +1 -0
  667. package/dist/scanning/signals.d.ts +121 -0
  668. package/dist/scanning/signals.d.ts.map +1 -0
  669. package/dist/scanning/signals.js +171 -0
  670. package/dist/scanning/signals.js.map +1 -0
  671. package/dist/starbases/actions/index.d.ts.map +1 -1
  672. package/dist/starbases/actions/index.js +3 -14
  673. package/dist/starbases/actions/index.js.map +1 -1
  674. package/dist/world/index.d.ts +110 -5
  675. package/dist/world/index.d.ts.map +1 -1
  676. package/dist/world/index.js +109 -4
  677. package/dist/world/index.js.map +1 -1
  678. package/dist/world/planet-claim-stake-plots.d.ts +130 -0
  679. package/dist/world/planet-claim-stake-plots.d.ts.map +1 -0
  680. package/dist/world/planet-claim-stake-plots.js +110 -0
  681. package/dist/world/planet-claim-stake-plots.js.map +1 -0
  682. package/dist/world/starbase-status.d.ts +176 -0
  683. package/dist/world/starbase-status.d.ts.map +1 -0
  684. package/dist/world/starbase-status.js +153 -0
  685. package/dist/world/starbase-status.js.map +1 -0
  686. package/package.json +10 -2
@@ -1,15 +1,21 @@
1
- import { getAddressEncoder, getBytesEncoder, getProgramDerivedAddress, isAddress, } from '@solana/kit';
1
+ import { deriveCurrencyCache, validateCurrencyCache, } from '../../internal/c4/currency-cache.js';
2
+ import { validateStarbaseSystem } from '../../internal/planning/starbase-system.js';
3
+ import { SYSTEM_PROGRAM } from '../../internal/system-program.js';
4
+ import { getAddressEncoder, isAddress } from '@solana/kit';
5
+ import { resolveActionRuntime } from '../../internal/planning/action-runtime.js';
6
+ import { requireProfileStarbasePlayer } from '../../internal/planning/starbase-player-owner.js';
2
7
  import { InvalidActionInputError, SageSdkError } from '../../client/errors.js';
3
8
  import { readContextRawAccounts } from '../../client/reconciliation.js';
4
- import { sage } from '../../internal/c4/bindings.js';
9
+ import { GAME_DISCRIMINATOR, SAGE_PROGRAM_ADDRESS, } from '../../internal/c4/runtime-bindings.js';
5
10
  import { craftingHabAccountDefinition, craftingProcessAccountDefinition, deriveRecipeAddress, recipeAccountDefinition, } from '../../internal/c4/crafting.js';
6
- import { characterAccountDefinition, findCharacterPda, } from '../../internal/c4/identity.js';
11
+ import { characterAccountDefinition, findCharacterPda, } from '../../internal/c4/character.js';
7
12
  import { deriveStarbasePlayerAddress, starbasePlayerAccountDefinition, } from '../../internal/c4/starbase.js';
8
13
  import { deriveInternalCraftingProcessState } from '../../internal/crafting-process-state.js';
9
14
  import { requireGameAddress } from '../../internal/game-context.js';
10
- import { adaptCancelCraftingProcessInstruction, adaptStartCraftingProcessInstruction, adaptCompleteCraftingProcessInstruction, validatePlanAuthorization, } from '../../internal/planning/authorization-adapter.js';
11
- import { deriveStarSystemAddress, starSystemAccountDefinition, } from '../../internal/c4/world.js';
15
+ import { adaptCancelCraftingProcessInstruction, adaptStartCraftingProcessInstruction, adaptCompleteCraftingProcessInstruction, readPlanAuthorization, } from '../../internal/planning/authorization-adapter.js';
16
+ import { starSystemAccountDefinition } from '../../internal/c4/world.js';
12
17
  import { createPlan, } from '../../planning/index.js';
18
+ import { hashRecipeConfiguration, validateRecipeUsage, } from '../../internal/planning/recipe-state.js';
13
19
  const U64_MAX = (1n << 64n) - 1n;
14
20
  const U32_MAX = 4_294_967_295;
15
21
  function invalid(field, value, acceptedRange, remedy) {
@@ -38,15 +44,7 @@ function readAddress(value, field) {
38
44
  function validateStartOptions(value) {
39
45
  const options = readRecord(value, 'options');
40
46
  assertKeys(options, 'options', ['authorization', 'craftingProcess', 'quantity', 'numCrew'], ['craftingHab']);
41
- const authorizationRecord = readRecord(options.authorization, 'authorization');
42
- assertKeys(authorizationRecord, 'authorization', ['profile', 'authority', 'keyIndex'], ['certificate']);
43
- const authorization = authorizationRecord;
44
- readAddress(authorization.profile, 'authorization.profile');
45
- readAddress(authorization.authority, 'authorization.authority');
46
- if (authorization.certificate !== undefined) {
47
- readAddress(authorization.certificate, 'authorization.certificate');
48
- }
49
- validatePlanAuthorization(authorization);
47
+ const authorization = readPlanAuthorization(options.authorization);
50
48
  if (typeof options.quantity !== 'bigint' ||
51
49
  options.quantity <= 0n ||
52
50
  options.quantity > U64_MAX) {
@@ -68,35 +66,11 @@ function validateStartOptions(value) {
68
66
  : { craftingHab: options.craftingHab }),
69
67
  };
70
68
  }
71
- function validateCompleteOptions(value) {
72
- const options = readRecord(value, 'options');
73
- assertKeys(options, 'options', ['authorization', 'atUnixSeconds']);
74
- const authorizationRecord = readRecord(options.authorization, 'authorization');
75
- assertKeys(authorizationRecord, 'authorization', ['profile', 'authority', 'keyIndex'], ['certificate']);
76
- const authorization = authorizationRecord;
77
- readAddress(authorization.profile, 'authorization.profile');
78
- readAddress(authorization.authority, 'authorization.authority');
79
- if (authorization.certificate !== undefined) {
80
- readAddress(authorization.certificate, 'authorization.certificate');
81
- }
82
- validatePlanAuthorization(authorization);
83
- if (typeof options.atUnixSeconds !== 'bigint' || options.atUnixSeconds < 0n) {
84
- invalid('atUnixSeconds', options.atUnixSeconds, 'a non-negative bigint Unix timestamp', 'Set atUnixSeconds to the explicit current Unix timestamp before retrying.');
85
- }
86
- return { atUnixSeconds: options.atUnixSeconds, authorization };
87
- }
88
- function validateCancelOptions(value) {
69
+ /** Validates completion or cancellation options, which share one shape. */
70
+ function validateProcessOptions(value) {
89
71
  const options = readRecord(value, 'options');
90
72
  assertKeys(options, 'options', ['authorization', 'atUnixSeconds']);
91
- const authorizationRecord = readRecord(options.authorization, 'authorization');
92
- assertKeys(authorizationRecord, 'authorization', ['profile', 'authority', 'keyIndex'], ['certificate']);
93
- const authorization = authorizationRecord;
94
- readAddress(authorization.profile, 'authorization.profile');
95
- readAddress(authorization.authority, 'authorization.authority');
96
- if (authorization.certificate !== undefined) {
97
- readAddress(authorization.certificate, 'authorization.certificate');
98
- }
99
- validatePlanAuthorization(authorization);
73
+ const authorization = readPlanAuthorization(options.authorization);
100
74
  if (typeof options.atUnixSeconds !== 'bigint' || options.atUnixSeconds < 0n) {
101
75
  invalid('atUnixSeconds', options.atUnixSeconds, 'a non-negative bigint Unix timestamp', 'Set atUnixSeconds to the explicit current Unix timestamp before retrying.');
102
76
  }
@@ -134,27 +108,6 @@ function validateKnownInputs(recipe, items, quantity, source, sourceAddress) {
134
108
  }
135
109
  }
136
110
  }
137
- async function deriveCurrencyCacheAddress(game) {
138
- const [address] = await getProgramDerivedAddress({
139
- programAddress: sage.SAGE_PROGRAM_ADDRESS,
140
- seeds: [
141
- getBytesEncoder().encode(new TextEncoder().encode('CurrencyConfig')),
142
- getAddressEncoder().encode(game),
143
- ],
144
- });
145
- return address;
146
- }
147
- function validateCurrencyCache(account, game, canonicalAddress) {
148
- const decoder = sage.getCurrencyConfigCacheDecoder();
149
- const validDiscriminator = sage.CURRENCY_CONFIG_CACHE_DISCRIMINATOR.every((byte, index) => account.data[index] === byte);
150
- if (account.address !== canonicalAddress ||
151
- account.owner !== sage.SAGE_PROGRAM_ADDRESS ||
152
- account.data.length !== decoder.fixedSize ||
153
- !validDiscriminator ||
154
- decoder.decode(account.data).gameId !== game) {
155
- fail(`CurrencyCache ${account.address} does not match the configured Game, canonical PDA, owner, or pinned account layout. Refresh the Game currency configuration and retry.`, account.address);
156
- }
157
- }
158
111
  async function hashAccountState(account) {
159
112
  const owner = getAddressEncoder().encode(account.owner);
160
113
  const canonical = new Uint8Array(owner.length + account.data.length);
@@ -171,11 +124,19 @@ async function precondition(account, describes) {
171
124
  kind: 'account-state',
172
125
  });
173
126
  }
174
- async function resolveAccounts(ctx, recipe, player, options, game) {
175
- const character = await findCharacterPda(options.authorization.profile, game);
127
+ async function recipePrecondition(account, describes, requiredUses = 0n) {
128
+ return {
129
+ kind: 'recipe-state',
130
+ address: account.address,
131
+ configHash: await hashRecipeConfiguration(account),
132
+ requiredUses,
133
+ describes,
134
+ };
135
+ }
136
+ async function resolveAccounts(ctx, recipe, player, options, game, character) {
176
137
  const currencyCache = options.craftingHab === undefined
177
138
  ? undefined
178
- : await deriveCurrencyCacheAddress(game);
139
+ : await deriveCurrencyCache(game).then(([address]) => address);
179
140
  const addresses = [
180
141
  character,
181
142
  player.address,
@@ -218,11 +179,11 @@ async function resolveAccounts(ctx, recipe, player, options, game) {
218
179
  recipeData.id !== recipe.id ||
219
180
  recipeData.status !== recipe.status ||
220
181
  recipeData.habRequired !== recipe.habRequired ||
221
- recipeData.usageCountRaw !== recipe.usageCountRaw ||
222
182
  recipeData.usageLimitRaw !== recipe.usageLimitRaw ||
223
183
  !sameBalances(recipe.ingredients, recipeData.inputs)) {
224
184
  fail(`Recipe ${recipe.address} changed or does not match the configured Game, canonical PDA, status, limits, or ingredients. Refresh the Recipe through this context and retry.`, recipe.address);
225
185
  }
186
+ validateRecipeUsage(recipeAccount, options.quantity);
226
187
  if (options.craftingHab === undefined) {
227
188
  return { character, characterAccount, playerAccount, recipeAccount };
228
189
  }
@@ -240,7 +201,7 @@ async function resolveAccounts(ctx, recipe, player, options, game) {
240
201
  !sameBalances(options.craftingHab.production.inventory.items, habData.production.inventory.amounts)) {
241
202
  fail(`Crafting Hab ${options.craftingHab.address} changed or does not match its Game, Profile, System, active capacity, unlocked Recipe, or production inventory. Refresh the Crafting Hab through this context and retry.`, options.craftingHab.address);
242
203
  }
243
- validateCurrencyCache(currencyCacheAccount, game, currencyCache);
204
+ await validateCurrencyCache(currencyCacheAccount, game, 'crafting');
244
205
  return {
245
206
  character,
246
207
  characterAccount,
@@ -258,6 +219,17 @@ async function resolveAccounts(ctx, recipe, player, options, game) {
258
219
  * returns one inert Plan whose two required signer roles are bound only during
259
220
  * execution.
260
221
  *
222
+ * A Recipe whose stored `usageLimitRaw` is `0n` is treated as unlimited: the
223
+ * local usage-limit precondition is skipped regardless of `usageCountRaw`.
224
+ * This is pinned SDK behavior, not a verified game rule. The pinned generated
225
+ * Recipe documents `usageLimit` only as "The maximum number of times that
226
+ * this recipe can be used", and every Recipe observed on z.ink PTR stores
227
+ * `9007199254740991` (2^53 - 1) as its limit, so no zero-limit Recipe has been
228
+ * simulated or executed. If the program enforces a limit the SDK did not,
229
+ * simulation or execution surfaces its `UsageLimitExceeded` error
230
+ * (`1367932950`) instead of a local precondition failure. See
231
+ * `docs/evidence/crafting-zero-usage-limit.md`.
232
+ *
261
233
  * @example
262
234
  * ```ts
263
235
  * declare const ctx: SageContext;
@@ -275,24 +247,10 @@ export async function planStartCraftingProcess(ctx, recipe, player, input) {
275
247
  if (recipe.game.address !== game || canonicalRecipe !== recipe.address) {
276
248
  fail(`Recipe ${recipe.address} does not match the configured Game ${game} or its canonical recipe-id PDA. Refresh the Recipe through this context and retry.`, recipe.address);
277
249
  }
278
- if (player.playerProfile.address !== options.authorization.profile) {
279
- fail(`Starbase Player ${player.address} does not belong to authorization Profile ${options.authorization.profile}. Refresh the Starbase Player for that Profile and retry.`, player.address);
280
- }
281
- const canonicalPlayer = await deriveStarbasePlayerAddress(player.system.address, player.character.address);
282
- if (canonicalPlayer !== player.address) {
283
- fail(`Starbase Player ${player.address} is not canonical for its Character and System. Refresh the Starbase Player through this context and retry.`, player.address);
284
- }
250
+ const character = await requireProfileStarbasePlayer(player, options.authorization.profile, game);
285
251
  if (recipe.status !== 'active') {
286
252
  fail(`Recipe ${recipe.name} is ${recipe.status}, so it cannot start a Crafting Process. Choose an active Recipe, refresh it, and retry.`, recipe.address);
287
253
  }
288
- if (recipe.usageLimitRaw !== 0n &&
289
- (recipe.usageCountRaw >= recipe.usageLimitRaw ||
290
- options.quantity > recipe.usageLimitRaw - recipe.usageCountRaw)) {
291
- const remaining = recipe.usageCountRaw >= recipe.usageLimitRaw
292
- ? 0n
293
- : recipe.usageLimitRaw - recipe.usageCountRaw;
294
- fail(`Recipe ${recipe.name} usage limit has remaining ${String(remaining)}, but requested ${String(options.quantity)}. Reduce quantity or choose another active Recipe before retrying.`, recipe.address);
295
- }
296
254
  if (options.numCrew > player.availableCrew) {
297
255
  fail(`Starbase Player ${player.address} has only ${String(player.availableCrew)} crew available, but numCrew requested ${String(options.numCrew)}. Reduce numCrew or free crew, refresh the Starbase Player, and retry.`, player.address);
298
256
  }
@@ -323,26 +281,41 @@ export async function planStartCraftingProcess(ctx, recipe, player, input) {
323
281
  else {
324
282
  validateKnownInputs(recipe, player.cargo.items, options.quantity, 'Starbase Player', player.address);
325
283
  }
326
- const resolved = await resolveAccounts(ctx, recipe, player, options, game);
284
+ const resolved = await resolveAccounts(ctx, recipe, player, options, game, character);
285
+ const [runtimeSystem] = await readContextRawAccounts(ctx, [
286
+ player.system.address,
287
+ ]);
288
+ if (!runtimeSystem)
289
+ fail('The crafting System is missing. Refresh the Starbase and recreate this Plan.', player.system.address);
290
+ const runtime = await resolveActionRuntime(ctx, {
291
+ mode: 'crafting-start',
292
+ game,
293
+ system: player.system.address,
294
+ starbaseSeqId: starSystemAccountDefinition.decode(runtimeSystem).sequenceId,
295
+ ...(options.craftingHab === undefined
296
+ ? {}
297
+ : { structure: options.craftingHab.address }),
298
+ });
327
299
  const description = `Start crafting ${String(options.quantity)} units of ${recipe.name} with ${String(options.numCrew)} crew at Starbase Player ${player.address}.`;
328
300
  const preconditions = [
329
301
  precondition(resolved.characterAccount, `The canonical Character remains assigned to Profile ${options.authorization.profile} in the configured Game.`),
330
302
  precondition(resolved.playerAccount, `Starbase Player ${player.address} retains its Character, Profile, System, crew, and input inventory.`),
331
- precondition(resolved.recipeAccount, `Recipe ${recipe.name} remains active with the validated usage limit and ingredients.`),
303
+ recipePrecondition(resolved.recipeAccount, `Recipe ${recipe.name} retains its configuration and enough remaining uses for this job.`, options.quantity),
332
304
  ...(resolved.habAccount === undefined
333
305
  ? []
334
306
  : [
335
307
  precondition(resolved.habAccount, `Crafting Hab ${resolved.habAccount.address} remains active with an available job slot, the Recipe unlocked, and sufficient inputs.`),
336
- precondition(resolved.currencyCacheAccount, 'The canonical CurrencyCache remains assigned to the configured Game for Hab crafting.'),
337
308
  ]),
338
309
  ];
339
310
  return createPlan({
340
311
  kind: 'crafting.start-process',
341
- preconditions: await Promise.all(preconditions),
312
+ preconditions: [...runtime.guards, ...(await Promise.all(preconditions))],
342
313
  steps: [
343
314
  {
344
- describes: description,
315
+ describes: `${description} ${runtime.description}`,
345
316
  instruction: adaptStartCraftingProcessInstruction({
317
+ ...runtime.accounts,
318
+ starbaseGovernance: runtime.accounts.starbaseGovernance,
346
319
  authorization: options.authorization,
347
320
  character: resolved.character,
348
321
  craftingProcess: options.craftingProcess,
@@ -362,7 +335,7 @@ export async function planStartCraftingProcess(ctx, recipe, player, input) {
362
335
  signers: [options.authorization.authority, options.craftingProcess],
363
336
  },
364
337
  ],
365
- summary: description,
338
+ summary: `${description} ${runtime.description}`,
366
339
  });
367
340
  }
368
341
  function sameProcessSnapshot(process, account) {
@@ -372,7 +345,7 @@ function sameProcessSnapshot(process, account) {
372
345
  account.system === process.system.address &&
373
346
  account.starbasePlayer === process.starbasePlayer.address &&
374
347
  account.starbaseSequenceId === process.starbaseSequenceId &&
375
- account.craftingHab === process.craftingHab.address &&
348
+ account.craftingHab === process.craftingHab?.address &&
376
349
  account.quantityRaw === process.quantityRaw &&
377
350
  account.numCrew === process.numCrew &&
378
351
  account.startsAtUnixSeconds === process.startsAtUnixSeconds &&
@@ -382,47 +355,57 @@ function sameProcessSnapshot(process, account) {
382
355
  account.inputs.storageCostRaw === process.inputs.usedStorageUnitsRaw &&
383
356
  sameBalances(process.inputs.items, account.inputs.amounts));
384
357
  }
358
+ /** SDK reads omit `craftingHab` for a Process without a Hab; a caller-built
359
+ * snapshot carrying the raw stored System address is rejected with that cause
360
+ * instead of being read as a Hab and reported as a changed Process. */
361
+ function processHabAddress(process) {
362
+ const habAddress = process.craftingHab?.address;
363
+ if (habAddress === SYSTEM_PROGRAM)
364
+ invalid('process.craftingHab', habAddress, 'a Crafting Hab address, or no craftingHab for a Process started without a Hab', 'The stored System address means this Process has no Hab. Use a snapshot from getCraftingProcess, which omits craftingHab, or omit craftingHab, then plan again.');
365
+ return habAddress;
366
+ }
385
367
  function validateGameRead(account, game) {
386
368
  if (account.address !== game ||
387
- account.owner !== sage.SAGE_PROGRAM_ADDRESS ||
388
- account.data.length < sage.GAME_DISCRIMINATOR.length ||
389
- !sage.GAME_DISCRIMINATOR.every((byte, index) => account.data[index] === byte)) {
369
+ account.owner !== SAGE_PROGRAM_ADDRESS ||
370
+ account.data.length < GAME_DISCRIMINATOR.length ||
371
+ !GAME_DISCRIMINATOR.every((byte, index) => account.data[index] === byte)) {
390
372
  fail(`Game ${account.address} does not match the configured address, owner, or pinned account layout. Refresh the configured Game and retry.`, account.address);
391
373
  }
392
374
  }
393
- async function resolveCompleteAccounts(ctx, process, options, game) {
394
- const character = await findCharacterPda(options.authorization.profile, game);
395
- const currencyCache = await deriveCurrencyCacheAddress(game);
396
- const habAddress = process.craftingHab.address === sage.SAGE_PROGRAM_ADDRESS
397
- ? undefined
398
- : process.craftingHab.address;
399
- const addresses = [
375
+ /** Reads and validates the Crafting Process graph shared by completion and
376
+ * cancellation, with `extra` in the same read: the unchanged Process, its
377
+ * canonical System and Starbase, the unchanged Recipe and its Hab policy, the
378
+ * Profile's canonical Starbase Player and Character, and the Process Hab,
379
+ * active and owned, when present. `action` completes the remedies, and
380
+ * `staleStarbaseGuidance` adds advice for a replaced Starbase. */
381
+ async function resolveProcessAccounts(ctx, process, profile, game, action, extra, staleStarbaseGuidance) {
382
+ const character = await findCharacterPda(profile, game);
383
+ const habAddress = processHabAddress(process);
384
+ const [processCandidate, recipeCandidate, playerCandidate, systemCandidate, characterCandidate, extraAccount, habCandidate,] = await readContextRawAccounts(ctx, [
400
385
  process.address,
401
386
  process.recipe.address,
402
387
  process.starbasePlayer.address,
403
388
  process.system.address,
404
- ...(habAddress === undefined ? [] : [habAddress]),
405
389
  character,
406
- game,
407
- currencyCache,
408
- ];
409
- const reads = await readContextRawAccounts(ctx, addresses);
410
- const byAddress = new Map(addresses.map((address, index) => [address, reads[index]]));
411
- const processAccount = requireAccount(byAddress.get(process.address), process.address, `Crafting Process ${process.address} is missing, so it may already be cancelled or closed. Refresh the Crafting Process and retry only if it still exists.`);
412
- const recipeAccount = requireAccount(byAddress.get(process.recipe.address), process.recipe.address, `Recipe ${process.recipe.address} is missing. Refresh the Crafting Process and its Recipe before retrying completion.`);
413
- const playerAccount = requireAccount(byAddress.get(process.starbasePlayer.address), process.starbasePlayer.address, `Starbase Player ${process.starbasePlayer.address} is missing. Refresh the Crafting Process and Starbase Player before retrying completion.`);
414
- const systemAccount = requireAccount(byAddress.get(process.system.address), process.system.address, `Star System ${process.system.address} is missing. Refresh the Crafting Process and Star System before retrying completion.`);
415
- const characterAccount = requireAccount(byAddress.get(character), character, `Canonical Character ${character} is missing for Profile ${options.authorization.profile}. Create or repair the Character in the configured Game before retrying completion.`);
416
- const gameAccount = requireAccount(byAddress.get(game), game, `Configured Game ${game} is missing. Refresh the configured Game before retrying completion.`);
417
- const currencyCacheAccount = requireAccount(byAddress.get(currencyCache), currencyCache, `Canonical CurrencyCache ${currencyCache} is missing for the configured Game. Refresh the Game currency configuration before retrying completion.`);
418
- const habAccount = habAddress === undefined
419
- ? undefined
420
- : requireAccount(byAddress.get(habAddress), habAddress, `Crafting Hab ${habAddress} is missing. Refresh the Crafting Process and Hab before retrying completion.`);
421
- const processData = craftingProcessAccountDefinition.decode(processAccount);
390
+ extra,
391
+ ...(habAddress === undefined ? [] : [habAddress]),
392
+ ]);
393
+ const processAccount = requireAccount(processCandidate, process.address, `Crafting Process ${process.address} is missing, so it may already be completed, cancelled, or closed. Refresh the Crafting Process and retry only if it still exists.`);
422
394
  if (processAccount.address !== process.address ||
423
- !sameProcessSnapshot(process, processData)) {
395
+ !sameProcessSnapshot(process, craftingProcessAccountDefinition.decode(processAccount))) {
424
396
  fail(`Crafting Process ${process.address} changed or no longer matches its relationships, timing, crew, quantity, fee, or inputs. Refresh the Crafting Process and retry.`, process.address);
425
397
  }
398
+ await validateStarbaseSystem(requireAccount(systemCandidate, process.system.address, `Star System ${process.system.address} is missing. Refresh the Crafting Process and Star System before retrying ${action}.`), {
399
+ address: process.system.address,
400
+ game,
401
+ starbaseSequenceId: process.starbaseSequenceId,
402
+ }, staleStarbaseGuidance);
403
+ const recipeAccount = requireAccount(recipeCandidate, process.recipe.address, `Recipe ${process.recipe.address} is missing. Refresh the Crafting Process and its Recipe before retrying ${action}.`);
404
+ const playerAccount = requireAccount(playerCandidate, process.starbasePlayer.address, `Starbase Player ${process.starbasePlayer.address} is missing. Refresh the Crafting Process and Starbase Player before retrying ${action}.`);
405
+ const characterAccount = requireAccount(characterCandidate, character, `Canonical Character ${character} is missing for Profile ${profile}. Create or repair the Character in the configured Game before retrying ${action}.`);
406
+ const habAccount = habAddress === undefined
407
+ ? undefined
408
+ : requireAccount(habCandidate, habAddress, `Crafting Hab ${habAddress} is missing. Refresh the Crafting Process and Hab before retrying ${action}.`);
426
409
  const recipeData = recipeAccountDefinition.decode(recipeAccount);
427
410
  const canonicalRecipe = await deriveRecipeAddress(game, recipeData.id);
428
411
  if (recipeAccount.address !== process.recipe.address ||
@@ -432,65 +415,72 @@ async function resolveCompleteAccounts(ctx, process, options, game) {
432
415
  recipeData.name !== process.recipe.name ||
433
416
  recipeData.status !== process.recipe.status ||
434
417
  recipeData.habRequired !== process.recipe.habRequired ||
435
- recipeData.usageCountRaw !== process.recipe.usageCountRaw ||
436
418
  recipeData.usageLimitRaw !== process.recipe.usageLimitRaw ||
437
419
  !sameBalances(process.recipe.ingredients, recipeData.inputs) ||
438
420
  !sameBalances(process.recipe.outputs, recipeData.outputs)) {
439
- fail(`Recipe ${process.recipe.address} changed or does not match the configured Game, canonical recipe-id PDA, status, Hab policy, limits, ingredients, or outputs. Refresh the Crafting Process and Recipe before retrying completion.`, process.recipe.address);
421
+ fail(`Recipe ${process.recipe.address} changed or does not match the configured Game, canonical recipe-id PDA, status, Hab policy, limits, ingredients, or outputs. Refresh the Crafting Process and Recipe before retrying ${action}.`, process.recipe.address);
440
422
  }
441
423
  if (recipeData.habRequired && habAddress === undefined) {
442
- fail(`Recipe ${recipeData.name} requires a Crafting Hab, but Crafting Process ${process.address} omits one. Refresh or repair the Process relationship before retrying completion.`, process.address);
424
+ fail(`Recipe ${recipeData.name} requires a Crafting Hab, but Crafting Process ${process.address} omits one. Refresh or repair the Process relationship before retrying ${action}.`, process.address);
443
425
  }
444
426
  const playerData = starbasePlayerAccountDefinition.decode(playerAccount);
445
427
  const canonicalPlayer = await deriveStarbasePlayerAddress(process.system.address, character);
446
428
  if (playerAccount.address !== process.starbasePlayer.address ||
447
429
  canonicalPlayer !== process.starbasePlayer.address ||
448
- playerData.playerProfile !== options.authorization.profile ||
430
+ playerData.playerProfile !== profile ||
449
431
  playerData.character !== character ||
450
432
  playerData.system !== process.system.address) {
451
- fail(`Starbase Player ${process.starbasePlayer.address} does not match the authorization Profile, canonical Character, or Crafting Process System. Refresh the Crafting Process and Starbase Player before retrying completion.`, process.starbasePlayer.address);
452
- }
453
- const systemData = starSystemAccountDefinition.decode(systemAccount);
454
- const canonicalSystem = await deriveStarSystemAddress(game, systemData.systemId);
455
- if (systemAccount.address !== process.system.address ||
456
- canonicalSystem !== process.system.address ||
457
- systemData.game !== game ||
458
- systemData.sequenceId !== process.starbaseSequenceId ||
459
- systemData.starbase === undefined) {
460
- fail(`Star System ${process.system.address} does not match the configured Game, canonical system-id PDA, active Starbase, or Crafting Process Starbase sequence. Refresh the Crafting Process and Star System before retrying completion.`, process.system.address);
433
+ fail(`Starbase Player ${process.starbasePlayer.address} does not match the authorization Profile, canonical Character, or Crafting Process System. Refresh the Crafting Process and Starbase Player before retrying ${action}.`, process.starbasePlayer.address);
461
434
  }
462
435
  if (habAccount !== undefined) {
463
436
  const habData = craftingHabAccountDefinition.decode(habAccount);
464
437
  if (habAccount.address !== habAddress ||
465
438
  habData.game !== game ||
466
- habData.ownerProfile !== options.authorization.profile ||
439
+ habData.ownerProfile !== profile ||
467
440
  habData.system !== process.system.address ||
468
441
  habData.systemSequenceId !== process.starbaseSequenceId ||
469
442
  habData.state.kind !== 'active') {
470
- fail(`Crafting Hab ${habAddress} is not active or does not match the configured Game, authorization Profile, Crafting Process System, or Starbase sequence. Refresh the Crafting Process and Hab before retrying completion.`, habAccount.address);
443
+ fail(`Crafting Hab ${habAddress} is not active or does not match the configured Game, authorization Profile, Crafting Process System, or Starbase sequence. Refresh the Crafting Process and Hab before retrying ${action}.`, habAccount.address);
471
444
  }
472
445
  }
473
446
  const characterData = characterAccountDefinition.decode(characterAccount);
474
447
  if (characterAccount.address !== character ||
475
- characterData.playerProfile !== options.authorization.profile ||
448
+ characterData.playerProfile !== profile ||
476
449
  characterData.game !== game) {
477
- fail(`The canonical Character does not match Profile ${options.authorization.profile} and the configured Game ${game}. Refresh or repair the Character relationship before retrying completion.`, characterAccount.address);
450
+ fail(`The canonical Character does not match Profile ${profile} and the configured Game ${game}. Refresh or repair the Character relationship before retrying ${action}.`, characterAccount.address);
478
451
  }
479
- validateGameRead(gameAccount, game);
480
- validateCurrencyCache(currencyCacheAccount, game, currencyCache);
481
452
  return {
482
453
  character,
483
454
  characterAccount,
484
- currencyCache,
485
- currencyCacheAccount,
486
- gameAccount,
487
- ...(habAccount === undefined ? {} : { habAccount }),
455
+ extraAccount,
456
+ habAccount,
488
457
  playerAccount,
489
458
  processAccount,
490
459
  recipeAccount,
491
- systemAccount,
492
460
  };
493
461
  }
462
+ /** The validated Process graph preconditions, with `systemGuard` after the
463
+ * Starbase Player when the action guards the Starbase separately. */
464
+ function processPreconditions(process, resolved, profile, systemGuard = []) {
465
+ return [
466
+ precondition(resolved.processAccount, `Crafting Process ${process.address} retains its validated relationships, timing, crew, quantity, fee, and inputs.`),
467
+ recipePrecondition(resolved.recipeAccount, `Recipe ${process.recipe.name} retains its validated Game, Hab policy, ingredients, and outputs.`),
468
+ precondition(resolved.playerAccount, `Starbase Player ${process.starbasePlayer.address} retains its Profile, Character, and System relationships.`),
469
+ ...systemGuard.map((guard) => Promise.resolve(guard)),
470
+ ...(resolved.habAccount === undefined
471
+ ? []
472
+ : [
473
+ precondition(resolved.habAccount, `Crafting Hab ${resolved.habAccount.address} remains active in the validated Game, Profile, System, and Starbase sequence.`),
474
+ ]),
475
+ precondition(resolved.characterAccount, `The canonical Character remains assigned to Profile ${profile} in the configured Game.`),
476
+ ];
477
+ }
478
+ /** Requires the authorization Profile to own the Process. */
479
+ function requireProcessOwner(process, profile) {
480
+ if (process.profile.address !== profile) {
481
+ fail(`Crafting Process ${process.address} does not belong to authorization Profile ${profile}. Use the owning Profile, refresh the Process, and retry.`, process.address);
482
+ }
483
+ }
494
484
  /** Plans completion of one Crafting Process without signing, simulation, or writes.
495
485
  *
496
486
  * The planner resolves and validates the Process account graph, requires Profile
@@ -508,11 +498,10 @@ async function resolveCompleteAccounts(ctx, process, options, game) {
508
498
  * ```
509
499
  */
510
500
  export async function planCompleteCraftingProcess(ctx, process, input) {
511
- const options = validateCompleteOptions(input);
501
+ const options = validateProcessOptions(input);
512
502
  const game = requireGameAddress(ctx);
513
- if (process.profile.address !== options.authorization.profile) {
514
- fail(`Crafting Process ${process.address} does not belong to authorization Profile ${options.authorization.profile}. Use the owning Profile, refresh the Process, and retry.`, process.address);
515
- }
503
+ const { profile } = options.authorization;
504
+ requireProcessOwner(process, profile);
516
505
  const state = deriveInternalCraftingProcessState(process, options.atUnixSeconds);
517
506
  if (state.kind !== 'complete') {
518
507
  const timing = state.kind === 'scheduled'
@@ -520,33 +509,36 @@ export async function planCompleteCraftingProcess(ctx, process, input) {
520
509
  : `in-progress and not complete with ${String(state.remainingSeconds)} seconds remaining`;
521
510
  fail(`Crafting Process ${process.address} is ${timing} at Unix timestamp ${String(options.atUnixSeconds)}. Wait until it is complete, provide a current timestamp, and retry.`, process.address);
522
511
  }
523
- const resolved = await resolveCompleteAccounts(ctx, process, options, game);
524
- const description = `Complete crafting ${String(process.quantityRaw)} units of ${process.recipe.name} at Starbase Player ${process.starbasePlayer.address}, returning ${String(process.numCrew)} crew and producing the Recipe outputs.`;
525
- const preconditions = [
526
- precondition(resolved.processAccount, `Crafting Process ${process.address} retains its validated relationships, timing, crew, quantity, fee, and inputs.`),
527
- precondition(resolved.recipeAccount, `Recipe ${process.recipe.name} retains its validated Game, Hab policy, ingredients, and outputs.`),
528
- precondition(resolved.playerAccount, `Starbase Player ${process.starbasePlayer.address} retains its Profile, Character, and System relationships.`),
529
- precondition(resolved.systemAccount, `Star System ${process.system.address} retains its active Starbase and validated sequence.`),
512
+ const [currencyCache] = await deriveCurrencyCache(game);
513
+ const resolved = await resolveProcessAccounts(ctx, process, profile, game, 'completion', currencyCache);
514
+ await validateCurrencyCache(requireAccount(resolved.extraAccount, currencyCache, `Canonical CurrencyCache ${currencyCache} is missing for the configured Game. Refresh the Game currency configuration before retrying completion.`), game, 'crafting');
515
+ const runtime = await resolveActionRuntime(ctx, {
516
+ mode: 'crafting-complete',
517
+ game,
518
+ system: process.system.address,
519
+ starbaseSeqId: process.starbaseSequenceId,
520
+ character: resolved.character,
521
+ process: process.address,
530
522
  ...(resolved.habAccount === undefined
531
- ? []
532
- : [
533
- precondition(resolved.habAccount, `Crafting Hab ${resolved.habAccount.address} remains active in the validated Game, Profile, System, and Starbase sequence.`),
534
- ]),
535
- precondition(resolved.characterAccount, `The canonical Character remains assigned to Profile ${options.authorization.profile} in the configured Game.`),
536
- precondition(resolved.gameAccount, `Game ${game} retains its pinned owner and account layout.`),
537
- precondition(resolved.currencyCacheAccount, 'The canonical CurrencyCache remains assigned to the configured Game.'),
538
- ];
523
+ ? {}
524
+ : { structure: resolved.habAccount.address }),
525
+ });
526
+ const description = `Complete crafting ${String(process.quantityRaw)} units of ${process.recipe.name} at Starbase Player ${process.starbasePlayer.address}, returning ${String(process.numCrew)} crew and producing the Recipe outputs.`;
539
527
  return createPlan({
540
528
  kind: 'crafting.complete-process',
541
- preconditions: await Promise.all(preconditions),
529
+ preconditions: [
530
+ ...runtime.guards,
531
+ ...(await Promise.all(processPreconditions(process, resolved, profile))),
532
+ ],
542
533
  steps: [
543
534
  {
544
- describes: description,
535
+ describes: `${description} ${runtime.description}`,
545
536
  instruction: adaptCompleteCraftingProcessInstruction({
537
+ ...runtime.accounts,
546
538
  authorization: options.authorization,
547
539
  character: resolved.character,
548
540
  craftingProcess: process.address,
549
- currencyCache: resolved.currencyCache,
541
+ currencyCache,
550
542
  game,
551
543
  recipe: process.recipe.address,
552
544
  starbasePlayer: process.starbasePlayer.address,
@@ -558,108 +550,9 @@ export async function planCompleteCraftingProcess(ctx, process, input) {
558
550
  signers: [options.authorization.authority],
559
551
  },
560
552
  ],
561
- summary: description,
553
+ summary: `${description} ${runtime.description}`,
562
554
  });
563
555
  }
564
- async function resolveCancelAccounts(ctx, process, options, game) {
565
- const character = await findCharacterPda(options.authorization.profile, game);
566
- const habAddress = process.craftingHab.address === sage.SAGE_PROGRAM_ADDRESS
567
- ? undefined
568
- : process.craftingHab.address;
569
- const addresses = [
570
- process.address,
571
- process.recipe.address,
572
- process.starbasePlayer.address,
573
- process.system.address,
574
- ...(habAddress === undefined ? [] : [habAddress]),
575
- character,
576
- game,
577
- ];
578
- const reads = await readContextRawAccounts(ctx, addresses);
579
- const byAddress = new Map(addresses.map((address, index) => [address, reads[index]]));
580
- const processAccount = requireAccount(byAddress.get(process.address), process.address, `Crafting Process ${process.address} is missing, so it may already be completed, cancelled, or closed. Refresh the Crafting Process and retry only if it still exists.`);
581
- const systemAccount = requireAccount(byAddress.get(process.system.address), process.system.address, `Star System ${process.system.address} is missing. Refresh the Crafting Process and Star System before retrying cancellation.`);
582
- const processData = craftingProcessAccountDefinition.decode(processAccount);
583
- if (processAccount.address !== process.address ||
584
- !sameProcessSnapshot(process, processData)) {
585
- fail(`Crafting Process ${process.address} changed or no longer matches its relationships, timing, crew, quantity, fee, or inputs. Refresh the Crafting Process and retry.`, process.address);
586
- }
587
- const systemData = starSystemAccountDefinition.decode(systemAccount);
588
- const canonicalSystem = await deriveStarSystemAddress(game, systemData.systemId);
589
- if (systemAccount.address !== process.system.address ||
590
- canonicalSystem !== process.system.address ||
591
- systemData.game !== game) {
592
- fail(`Star System ${process.system.address} does not match the configured Game or canonical system-id PDA. Refresh the Crafting Process and Star System before retrying cancellation.`, process.system.address);
593
- }
594
- if (systemData.sequenceId !== process.starbaseSequenceId) {
595
- fail(`The Starbase sequence for Crafting Process ${process.address} is stale at ${String(process.starbaseSequenceId)}, while Star System ${process.system.address} is at sequence ${String(systemData.sequenceId)}. The program requires destroyCraftingProcess for this destroyed-Starbase cleanup case; do not cancel the Process.`, process.address);
596
- }
597
- if (systemData.starbase === undefined) {
598
- fail(`Star System ${process.system.address} does not have an active Starbase. Refresh the Crafting Process and Star System before retrying cancellation.`, process.system.address);
599
- }
600
- const recipeAccount = requireAccount(byAddress.get(process.recipe.address), process.recipe.address, `Recipe ${process.recipe.address} is missing. Refresh the Crafting Process and its Recipe before retrying cancellation.`);
601
- const playerAccount = requireAccount(byAddress.get(process.starbasePlayer.address), process.starbasePlayer.address, `Starbase Player ${process.starbasePlayer.address} is missing. Refresh the Crafting Process and Starbase Player before retrying cancellation.`);
602
- const characterAccount = requireAccount(byAddress.get(character), character, `Canonical Character ${character} is missing for Profile ${options.authorization.profile}. Create or repair the Character in the configured Game before retrying cancellation.`);
603
- const gameAccount = requireAccount(byAddress.get(game), game, `Configured Game ${game} is missing. Refresh the configured Game before retrying cancellation.`);
604
- const habAccount = habAddress === undefined
605
- ? undefined
606
- : requireAccount(byAddress.get(habAddress), habAddress, `Crafting Hab ${habAddress} is missing. Refresh the Crafting Process and Hab before retrying cancellation.`);
607
- const recipeData = recipeAccountDefinition.decode(recipeAccount);
608
- const canonicalRecipe = await deriveRecipeAddress(game, recipeData.id);
609
- if (recipeAccount.address !== process.recipe.address ||
610
- canonicalRecipe !== process.recipe.address ||
611
- recipeData.game !== game ||
612
- recipeData.id !== process.recipe.id ||
613
- recipeData.name !== process.recipe.name ||
614
- recipeData.status !== process.recipe.status ||
615
- recipeData.habRequired !== process.recipe.habRequired ||
616
- recipeData.usageCountRaw !== process.recipe.usageCountRaw ||
617
- recipeData.usageLimitRaw !== process.recipe.usageLimitRaw ||
618
- !sameBalances(process.recipe.ingredients, recipeData.inputs) ||
619
- !sameBalances(process.recipe.outputs, recipeData.outputs)) {
620
- fail(`Recipe ${process.recipe.address} changed or does not match the configured Game, canonical recipe-id PDA, status, Hab policy, limits, ingredients, or outputs. Refresh the Crafting Process and Recipe before retrying cancellation.`, process.recipe.address);
621
- }
622
- if (recipeData.habRequired && habAddress === undefined) {
623
- fail(`Recipe ${recipeData.name} requires a Crafting Hab, but Crafting Process ${process.address} omits one. Refresh or repair the Process relationship before retrying cancellation.`, process.address);
624
- }
625
- const playerData = starbasePlayerAccountDefinition.decode(playerAccount);
626
- const canonicalPlayer = await deriveStarbasePlayerAddress(process.system.address, character);
627
- if (playerAccount.address !== process.starbasePlayer.address ||
628
- canonicalPlayer !== process.starbasePlayer.address ||
629
- playerData.playerProfile !== options.authorization.profile ||
630
- playerData.character !== character ||
631
- playerData.system !== process.system.address) {
632
- fail(`Starbase Player ${process.starbasePlayer.address} does not match the authorization Profile, canonical Character, or Crafting Process System. Refresh the Crafting Process and Starbase Player before retrying cancellation.`, process.starbasePlayer.address);
633
- }
634
- if (habAccount !== undefined) {
635
- const habData = craftingHabAccountDefinition.decode(habAccount);
636
- if (habAccount.address !== habAddress ||
637
- habData.game !== game ||
638
- habData.ownerProfile !== options.authorization.profile ||
639
- habData.system !== process.system.address ||
640
- habData.systemSequenceId !== process.starbaseSequenceId ||
641
- habData.state.kind !== 'active') {
642
- fail(`Crafting Hab ${habAddress} is not active or does not match the configured Game, authorization Profile, Crafting Process System, or Starbase sequence. Refresh the Crafting Process and Hab before retrying cancellation.`, habAccount.address);
643
- }
644
- }
645
- const characterData = characterAccountDefinition.decode(characterAccount);
646
- if (characterAccount.address !== character ||
647
- characterData.playerProfile !== options.authorization.profile ||
648
- characterData.game !== game) {
649
- fail(`The canonical Character does not match Profile ${options.authorization.profile} and the configured Game ${game}. Refresh or repair the Character relationship before retrying cancellation.`, characterAccount.address);
650
- }
651
- validateGameRead(gameAccount, game);
652
- return {
653
- character,
654
- characterAccount,
655
- gameAccount,
656
- ...(habAccount === undefined ? {} : { habAccount }),
657
- playerAccount,
658
- processAccount,
659
- recipeAccount,
660
- systemAccount,
661
- };
662
- }
663
556
  /** Plans cancellation of one unfinished Crafting Process without signing or writes.
664
557
  *
665
558
  * The planner resolves and validates the Process account graph, requires Profile
@@ -677,33 +570,32 @@ async function resolveCancelAccounts(ctx, process, options, game) {
677
570
  * ```
678
571
  */
679
572
  export async function planCancelCraftingProcess(ctx, process, input) {
680
- const options = validateCancelOptions(input);
573
+ const options = validateProcessOptions(input);
681
574
  const game = requireGameAddress(ctx);
682
- if (process.profile.address !== options.authorization.profile) {
683
- fail(`Crafting Process ${process.address} does not belong to authorization Profile ${options.authorization.profile}. Use the owning Profile, refresh the Process, and retry.`, process.address);
684
- }
575
+ const { profile } = options.authorization;
576
+ requireProcessOwner(process, profile);
685
577
  const state = deriveInternalCraftingProcessState(process, options.atUnixSeconds);
686
578
  if (state.kind === 'complete') {
687
579
  fail(`Crafting Process ${process.address} is complete at Unix timestamp ${String(options.atUnixSeconds)} and cannot be cancelled. Use planCompleteCraftingProcess with a refreshed snapshot instead.`, process.address);
688
580
  }
689
- const resolved = await resolveCancelAccounts(ctx, process, options, game);
581
+ const resolved = await resolveProcessAccounts(ctx, process, profile, game, 'cancellation', game, 'For a Crafting Process belonging to the destroyed Starbase, use destroyCraftingProcess; do not cancel the Process.');
582
+ const gameAccount = requireAccount(resolved.extraAccount, game, `Configured Game ${game} is missing. Refresh the configured Game before retrying cancellation.`);
583
+ validateGameRead(gameAccount, game);
690
584
  const description = `Cancel crafting ${String(process.quantityRaw)} units of ${process.recipe.name} at Starbase Player ${process.starbasePlayer.address}, returning all inputs and ${String(process.numCrew)} crew and closing the Crafting Process.`;
691
- const preconditions = [
692
- precondition(resolved.processAccount, `Crafting Process ${process.address} retains its validated relationships, timing, crew, quantity, fee, and inputs.`),
693
- precondition(resolved.recipeAccount, `Recipe ${process.recipe.name} retains its validated Game, Hab policy, usage, ingredients, and outputs.`),
694
- precondition(resolved.playerAccount, `Starbase Player ${process.starbasePlayer.address} retains its Profile, Character, and System relationships.`),
695
- precondition(resolved.systemAccount, `Star System ${process.system.address} retains its active Starbase and validated sequence.`),
696
- ...(resolved.habAccount === undefined
697
- ? []
698
- : [
699
- precondition(resolved.habAccount, `Crafting Hab ${resolved.habAccount.address} remains active in the validated Game, Profile, System, and Starbase sequence.`),
700
- ]),
701
- precondition(resolved.characterAccount, `The canonical Character remains assigned to Profile ${options.authorization.profile} in the configured Game.`),
702
- precondition(resolved.gameAccount, `Game ${game} retains its pinned owner and account layout.`),
703
- ];
704
585
  return createPlan({
705
586
  kind: 'crafting.cancel-process',
706
- preconditions: await Promise.all(preconditions),
587
+ preconditions: await Promise.all([
588
+ ...processPreconditions(process, resolved, profile, [
589
+ {
590
+ kind: 'starbase-system',
591
+ address: process.system.address,
592
+ game,
593
+ starbaseSequenceId: process.starbaseSequenceId,
594
+ describes: `Star System ${process.system.address} retains its canonical Game identity, active Starbase and sequence ${process.starbaseSequenceId}; unrelated shared activity may change.`,
595
+ },
596
+ ]),
597
+ precondition(gameAccount, `Game ${game} retains its pinned owner and account layout.`),
598
+ ]),
707
599
  steps: [
708
600
  {
709
601
  describes: description,