hoi4-agent-tools 0.0.0-bootstrap.1 → 0.1.2

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 (416) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/LICENSE +201 -0
  3. package/README.md +140 -2
  4. package/SECURITY.md +17 -0
  5. package/dist/bin/http.d.ts +3 -0
  6. package/dist/bin/http.d.ts.map +1 -0
  7. package/dist/bin/http.js +27 -0
  8. package/dist/bin/http.js.map +1 -0
  9. package/dist/bin/setup.d.ts +3 -0
  10. package/dist/bin/setup.d.ts.map +1 -0
  11. package/dist/bin/setup.js +188 -0
  12. package/dist/bin/setup.js.map +1 -0
  13. package/dist/bin/stdio.d.ts +3 -0
  14. package/dist/bin/stdio.d.ts.map +1 -0
  15. package/dist/bin/stdio.js +36 -0
  16. package/dist/bin/stdio.js.map +1 -0
  17. package/dist/hoi4_agent_tools/core/artifacts.d.ts +117 -0
  18. package/dist/hoi4_agent_tools/core/artifacts.d.ts.map +1 -0
  19. package/dist/hoi4_agent_tools/core/artifacts.js +1047 -0
  20. package/dist/hoi4_agent_tools/core/artifacts.js.map +1 -0
  21. package/dist/hoi4_agent_tools/core/canonical.d.ts +13 -0
  22. package/dist/hoi4_agent_tools/core/canonical.d.ts.map +1 -0
  23. package/dist/hoi4_agent_tools/core/canonical.js +41 -0
  24. package/dist/hoi4_agent_tools/core/canonical.js.map +1 -0
  25. package/dist/hoi4_agent_tools/core/configuration.d.ts +137 -0
  26. package/dist/hoi4_agent_tools/core/configuration.d.ts.map +1 -0
  27. package/dist/hoi4_agent_tools/core/configuration.js +383 -0
  28. package/dist/hoi4_agent_tools/core/configuration.js.map +1 -0
  29. package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts +18 -0
  30. package/dist/hoi4_agent_tools/core/diagnostic-collector.d.ts.map +1 -0
  31. package/dist/hoi4_agent_tools/core/diagnostic-collector.js +45 -0
  32. package/dist/hoi4_agent_tools/core/diagnostic-collector.js.map +1 -0
  33. package/dist/hoi4_agent_tools/core/diagnostics.d.ts +26 -0
  34. package/dist/hoi4_agent_tools/core/diagnostics.d.ts.map +1 -0
  35. package/dist/hoi4_agent_tools/core/diagnostics.js +25 -0
  36. package/dist/hoi4_agent_tools/core/diagnostics.js.map +1 -0
  37. package/dist/hoi4_agent_tools/core/diff.d.ts +22 -0
  38. package/dist/hoi4_agent_tools/core/diff.d.ts.map +1 -0
  39. package/dist/hoi4_agent_tools/core/diff.js +93 -0
  40. package/dist/hoi4_agent_tools/core/diff.js.map +1 -0
  41. package/dist/hoi4_agent_tools/core/engine.d.ts +56 -0
  42. package/dist/hoi4_agent_tools/core/engine.d.ts.map +1 -0
  43. package/dist/hoi4_agent_tools/core/engine.js +319 -0
  44. package/dist/hoi4_agent_tools/core/engine.js.map +1 -0
  45. package/dist/hoi4_agent_tools/core/image-diff.d.ts +14 -0
  46. package/dist/hoi4_agent_tools/core/image-diff.d.ts.map +1 -0
  47. package/dist/hoi4_agent_tools/core/image-diff.js +121 -0
  48. package/dist/hoi4_agent_tools/core/image-diff.js.map +1 -0
  49. package/dist/hoi4_agent_tools/core/index.d.ts +64 -0
  50. package/dist/hoi4_agent_tools/core/index.d.ts.map +1 -0
  51. package/dist/hoi4_agent_tools/core/index.js +963 -0
  52. package/dist/hoi4_agent_tools/core/index.js.map +1 -0
  53. package/dist/hoi4_agent_tools/core/index.public.d.ts +16 -0
  54. package/dist/hoi4_agent_tools/core/index.public.d.ts.map +1 -0
  55. package/dist/hoi4_agent_tools/core/index.public.js +16 -0
  56. package/dist/hoi4_agent_tools/core/index.public.js.map +1 -0
  57. package/dist/hoi4_agent_tools/core/render-budget.d.ts +51 -0
  58. package/dist/hoi4_agent_tools/core/render-budget.d.ts.map +1 -0
  59. package/dist/hoi4_agent_tools/core/render-budget.js +109 -0
  60. package/dist/hoi4_agent_tools/core/render-budget.js.map +1 -0
  61. package/dist/hoi4_agent_tools/core/result.d.ts +45 -0
  62. package/dist/hoi4_agent_tools/core/result.d.ts.map +1 -0
  63. package/dist/hoi4_agent_tools/core/result.js +26 -0
  64. package/dist/hoi4_agent_tools/core/result.js.map +1 -0
  65. package/dist/hoi4_agent_tools/core/scanner.d.ts +28 -0
  66. package/dist/hoi4_agent_tools/core/scanner.d.ts.map +1 -0
  67. package/dist/hoi4_agent_tools/core/scanner.js +136 -0
  68. package/dist/hoi4_agent_tools/core/scanner.js.map +1 -0
  69. package/dist/hoi4_agent_tools/core/server-state.d.ts +31 -0
  70. package/dist/hoi4_agent_tools/core/server-state.d.ts.map +1 -0
  71. package/dist/hoi4_agent_tools/core/server-state.js +413 -0
  72. package/dist/hoi4_agent_tools/core/server-state.js.map +1 -0
  73. package/dist/hoi4_agent_tools/core/source/encoding.d.ts +10 -0
  74. package/dist/hoi4_agent_tools/core/source/encoding.d.ts.map +1 -0
  75. package/dist/hoi4_agent_tools/core/source/encoding.js +54 -0
  76. package/dist/hoi4_agent_tools/core/source/encoding.js.map +1 -0
  77. package/dist/hoi4_agent_tools/core/source/index.d.ts +7 -0
  78. package/dist/hoi4_agent_tools/core/source/index.d.ts.map +1 -0
  79. package/dist/hoi4_agent_tools/core/source/index.js +7 -0
  80. package/dist/hoi4_agent_tools/core/source/index.js.map +1 -0
  81. package/dist/hoi4_agent_tools/core/source/lexer.d.ts +30 -0
  82. package/dist/hoi4_agent_tools/core/source/lexer.d.ts.map +1 -0
  83. package/dist/hoi4_agent_tools/core/source/lexer.js +266 -0
  84. package/dist/hoi4_agent_tools/core/source/lexer.js.map +1 -0
  85. package/dist/hoi4_agent_tools/core/source/limits.d.ts +21 -0
  86. package/dist/hoi4_agent_tools/core/source/limits.d.ts.map +1 -0
  87. package/dist/hoi4_agent_tools/core/source/limits.js +49 -0
  88. package/dist/hoi4_agent_tools/core/source/limits.js.map +1 -0
  89. package/dist/hoi4_agent_tools/core/source/localisation.d.ts +20 -0
  90. package/dist/hoi4_agent_tools/core/source/localisation.d.ts.map +1 -0
  91. package/dist/hoi4_agent_tools/core/source/localisation.js +163 -0
  92. package/dist/hoi4_agent_tools/core/source/localisation.js.map +1 -0
  93. package/dist/hoi4_agent_tools/core/source/parser.d.ts +44 -0
  94. package/dist/hoi4_agent_tools/core/source/parser.d.ts.map +1 -0
  95. package/dist/hoi4_agent_tools/core/source/parser.js +334 -0
  96. package/dist/hoi4_agent_tools/core/source/parser.js.map +1 -0
  97. package/dist/hoi4_agent_tools/core/source/rewrite.d.ts +10 -0
  98. package/dist/hoi4_agent_tools/core/source/rewrite.d.ts.map +1 -0
  99. package/dist/hoi4_agent_tools/core/source/rewrite.js +28 -0
  100. package/dist/hoi4_agent_tools/core/source/rewrite.js.map +1 -0
  101. package/dist/hoi4_agent_tools/core/svg-text.d.ts +34 -0
  102. package/dist/hoi4_agent_tools/core/svg-text.d.ts.map +1 -0
  103. package/dist/hoi4_agent_tools/core/svg-text.js +127 -0
  104. package/dist/hoi4_agent_tools/core/svg-text.js.map +1 -0
  105. package/dist/hoi4_agent_tools/core/transaction-limits.d.ts +9 -0
  106. package/dist/hoi4_agent_tools/core/transaction-limits.d.ts.map +1 -0
  107. package/dist/hoi4_agent_tools/core/transaction-limits.js +9 -0
  108. package/dist/hoi4_agent_tools/core/transaction-limits.js.map +1 -0
  109. package/dist/hoi4_agent_tools/core/transactions.d.ts +162 -0
  110. package/dist/hoi4_agent_tools/core/transactions.d.ts.map +1 -0
  111. package/dist/hoi4_agent_tools/core/transactions.js +1181 -0
  112. package/dist/hoi4_agent_tools/core/transactions.js.map +1 -0
  113. package/dist/hoi4_agent_tools/core/workspace.d.ts +68 -0
  114. package/dist/hoi4_agent_tools/core/workspace.d.ts.map +1 -0
  115. package/dist/hoi4_agent_tools/core/workspace.js +794 -0
  116. package/dist/hoi4_agent_tools/core/workspace.js.map +1 -0
  117. package/dist/hoi4_agent_tools/focus/compiler.d.ts +9 -0
  118. package/dist/hoi4_agent_tools/focus/compiler.d.ts.map +1 -0
  119. package/dist/hoi4_agent_tools/focus/compiler.js +273 -0
  120. package/dist/hoi4_agent_tools/focus/compiler.js.map +1 -0
  121. package/dist/hoi4_agent_tools/focus/continuous-render.d.ts +32 -0
  122. package/dist/hoi4_agent_tools/focus/continuous-render.d.ts.map +1 -0
  123. package/dist/hoi4_agent_tools/focus/continuous-render.js +179 -0
  124. package/dist/hoi4_agent_tools/focus/continuous-render.js.map +1 -0
  125. package/dist/hoi4_agent_tools/focus/drift.d.ts +22 -0
  126. package/dist/hoi4_agent_tools/focus/drift.d.ts.map +1 -0
  127. package/dist/hoi4_agent_tools/focus/drift.js +124 -0
  128. package/dist/hoi4_agent_tools/focus/drift.js.map +1 -0
  129. package/dist/hoi4_agent_tools/focus/geometry.d.ts +17 -0
  130. package/dist/hoi4_agent_tools/focus/geometry.d.ts.map +1 -0
  131. package/dist/hoi4_agent_tools/focus/geometry.js +35 -0
  132. package/dist/hoi4_agent_tools/focus/geometry.js.map +1 -0
  133. package/dist/hoi4_agent_tools/focus/importer.d.ts +9 -0
  134. package/dist/hoi4_agent_tools/focus/importer.d.ts.map +1 -0
  135. package/dist/hoi4_agent_tools/focus/importer.js +732 -0
  136. package/dist/hoi4_agent_tools/focus/importer.js.map +1 -0
  137. package/dist/hoi4_agent_tools/focus/index.d.ts +14 -0
  138. package/dist/hoi4_agent_tools/focus/index.d.ts.map +1 -0
  139. package/dist/hoi4_agent_tools/focus/index.js +14 -0
  140. package/dist/hoi4_agent_tools/focus/index.js.map +1 -0
  141. package/dist/hoi4_agent_tools/focus/layout.d.ts +5 -0
  142. package/dist/hoi4_agent_tools/focus/layout.d.ts.map +1 -0
  143. package/dist/hoi4_agent_tools/focus/layout.js +653 -0
  144. package/dist/hoi4_agent_tools/focus/layout.js.map +1 -0
  145. package/dist/hoi4_agent_tools/focus/limits.d.ts +9 -0
  146. package/dist/hoi4_agent_tools/focus/limits.d.ts.map +1 -0
  147. package/dist/hoi4_agent_tools/focus/limits.js +9 -0
  148. package/dist/hoi4_agent_tools/focus/limits.js.map +1 -0
  149. package/dist/hoi4_agent_tools/focus/lint.d.ts +14 -0
  150. package/dist/hoi4_agent_tools/focus/lint.d.ts.map +1 -0
  151. package/dist/hoi4_agent_tools/focus/lint.js +839 -0
  152. package/dist/hoi4_agent_tools/focus/lint.js.map +1 -0
  153. package/dist/hoi4_agent_tools/focus/model.d.ts +303 -0
  154. package/dist/hoi4_agent_tools/focus/model.d.ts.map +1 -0
  155. package/dist/hoi4_agent_tools/focus/model.js +20 -0
  156. package/dist/hoi4_agent_tools/focus/model.js.map +1 -0
  157. package/dist/hoi4_agent_tools/focus/native-effects.d.ts +9 -0
  158. package/dist/hoi4_agent_tools/focus/native-effects.d.ts.map +1 -0
  159. package/dist/hoi4_agent_tools/focus/native-effects.js +563 -0
  160. package/dist/hoi4_agent_tools/focus/native-effects.js.map +1 -0
  161. package/dist/hoi4_agent_tools/focus/planning.d.ts +15 -0
  162. package/dist/hoi4_agent_tools/focus/planning.d.ts.map +1 -0
  163. package/dist/hoi4_agent_tools/focus/planning.js +241 -0
  164. package/dist/hoi4_agent_tools/focus/planning.js.map +1 -0
  165. package/dist/hoi4_agent_tools/focus/presentation.d.ts +24 -0
  166. package/dist/hoi4_agent_tools/focus/presentation.d.ts.map +1 -0
  167. package/dist/hoi4_agent_tools/focus/presentation.js +204 -0
  168. package/dist/hoi4_agent_tools/focus/presentation.js.map +1 -0
  169. package/dist/hoi4_agent_tools/focus/render.d.ts +35 -0
  170. package/dist/hoi4_agent_tools/focus/render.d.ts.map +1 -0
  171. package/dist/hoi4_agent_tools/focus/render.js +491 -0
  172. package/dist/hoi4_agent_tools/focus/render.js.map +1 -0
  173. package/dist/hoi4_agent_tools/focus/service.d.ts +82 -0
  174. package/dist/hoi4_agent_tools/focus/service.d.ts.map +1 -0
  175. package/dist/hoi4_agent_tools/focus/service.js +492 -0
  176. package/dist/hoi4_agent_tools/focus/service.js.map +1 -0
  177. package/dist/hoi4_agent_tools/focus/source-update.d.ts +6 -0
  178. package/dist/hoi4_agent_tools/focus/source-update.d.ts.map +1 -0
  179. package/dist/hoi4_agent_tools/focus/source-update.js +328 -0
  180. package/dist/hoi4_agent_tools/focus/source-update.js.map +1 -0
  181. package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts +37 -0
  182. package/dist/hoi4_agent_tools/gui/animation-manifest.d.ts.map +1 -0
  183. package/dist/hoi4_agent_tools/gui/animation-manifest.js +66 -0
  184. package/dist/hoi4_agent_tools/gui/animation-manifest.js.map +1 -0
  185. package/dist/hoi4_agent_tools/gui/assets.d.ts +71 -0
  186. package/dist/hoi4_agent_tools/gui/assets.d.ts.map +1 -0
  187. package/dist/hoi4_agent_tools/gui/assets.js +629 -0
  188. package/dist/hoi4_agent_tools/gui/assets.js.map +1 -0
  189. package/dist/hoi4_agent_tools/gui/dds.d.ts +17 -0
  190. package/dist/hoi4_agent_tools/gui/dds.d.ts.map +1 -0
  191. package/dist/hoi4_agent_tools/gui/dds.js +245 -0
  192. package/dist/hoi4_agent_tools/gui/dds.js.map +1 -0
  193. package/dist/hoi4_agent_tools/gui/helpers.d.ts +101 -0
  194. package/dist/hoi4_agent_tools/gui/helpers.d.ts.map +1 -0
  195. package/dist/hoi4_agent_tools/gui/helpers.js +1072 -0
  196. package/dist/hoi4_agent_tools/gui/helpers.js.map +1 -0
  197. package/dist/hoi4_agent_tools/gui/index.d.ts +15 -0
  198. package/dist/hoi4_agent_tools/gui/index.d.ts.map +1 -0
  199. package/dist/hoi4_agent_tools/gui/index.js +15 -0
  200. package/dist/hoi4_agent_tools/gui/index.js.map +1 -0
  201. package/dist/hoi4_agent_tools/gui/layout.d.ts +6 -0
  202. package/dist/hoi4_agent_tools/gui/layout.d.ts.map +1 -0
  203. package/dist/hoi4_agent_tools/gui/layout.js +753 -0
  204. package/dist/hoi4_agent_tools/gui/layout.js.map +1 -0
  205. package/dist/hoi4_agent_tools/gui/limits.d.ts +25 -0
  206. package/dist/hoi4_agent_tools/gui/limits.d.ts.map +1 -0
  207. package/dist/hoi4_agent_tools/gui/limits.js +27 -0
  208. package/dist/hoi4_agent_tools/gui/limits.js.map +1 -0
  209. package/dist/hoi4_agent_tools/gui/renderer.d.ts +18 -0
  210. package/dist/hoi4_agent_tools/gui/renderer.d.ts.map +1 -0
  211. package/dist/hoi4_agent_tools/gui/renderer.js +388 -0
  212. package/dist/hoi4_agent_tools/gui/renderer.js.map +1 -0
  213. package/dist/hoi4_agent_tools/gui/scenario.d.ts +66 -0
  214. package/dist/hoi4_agent_tools/gui/scenario.d.ts.map +1 -0
  215. package/dist/hoi4_agent_tools/gui/scenario.js +191 -0
  216. package/dist/hoi4_agent_tools/gui/scenario.js.map +1 -0
  217. package/dist/hoi4_agent_tools/gui/source-graph.d.ts +7 -0
  218. package/dist/hoi4_agent_tools/gui/source-graph.d.ts.map +1 -0
  219. package/dist/hoi4_agent_tools/gui/source-graph.js +1074 -0
  220. package/dist/hoi4_agent_tools/gui/source-graph.js.map +1 -0
  221. package/dist/hoi4_agent_tools/gui/source-patch.d.ts +13 -0
  222. package/dist/hoi4_agent_tools/gui/source-patch.d.ts.map +1 -0
  223. package/dist/hoi4_agent_tools/gui/source-patch.js +90 -0
  224. package/dist/hoi4_agent_tools/gui/source-patch.js.map +1 -0
  225. package/dist/hoi4_agent_tools/gui/studio.d.ts +86 -0
  226. package/dist/hoi4_agent_tools/gui/studio.d.ts.map +1 -0
  227. package/dist/hoi4_agent_tools/gui/studio.js +830 -0
  228. package/dist/hoi4_agent_tools/gui/studio.js.map +1 -0
  229. package/dist/hoi4_agent_tools/gui/tga.d.ts +16 -0
  230. package/dist/hoi4_agent_tools/gui/tga.d.ts.map +1 -0
  231. package/dist/hoi4_agent_tools/gui/tga.js +157 -0
  232. package/dist/hoi4_agent_tools/gui/tga.js.map +1 -0
  233. package/dist/hoi4_agent_tools/gui/types.d.ts +322 -0
  234. package/dist/hoi4_agent_tools/gui/types.d.ts.map +1 -0
  235. package/dist/hoi4_agent_tools/gui/types.js +19 -0
  236. package/dist/hoi4_agent_tools/gui/types.js.map +1 -0
  237. package/dist/hoi4_agent_tools/gui/validators.d.ts +8 -0
  238. package/dist/hoi4_agent_tools/gui/validators.d.ts.map +1 -0
  239. package/dist/hoi4_agent_tools/gui/validators.js +951 -0
  240. package/dist/hoi4_agent_tools/gui/validators.js.map +1 -0
  241. package/dist/hoi4_agent_tools/map/bmp.d.ts +62 -0
  242. package/dist/hoi4_agent_tools/map/bmp.d.ts.map +1 -0
  243. package/dist/hoi4_agent_tools/map/bmp.js +363 -0
  244. package/dist/hoi4_agent_tools/map/bmp.js.map +1 -0
  245. package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts +5 -0
  246. package/dist/hoi4_agent_tools/map/diagnostic-limit.d.ts.map +1 -0
  247. package/dist/hoi4_agent_tools/map/diagnostic-limit.js +21 -0
  248. package/dist/hoi4_agent_tools/map/diagnostic-limit.js.map +1 -0
  249. package/dist/hoi4_agent_tools/map/index.d.ts +8 -0
  250. package/dist/hoi4_agent_tools/map/index.d.ts.map +1 -0
  251. package/dist/hoi4_agent_tools/map/index.js +8 -0
  252. package/dist/hoi4_agent_tools/map/index.js.map +1 -0
  253. package/dist/hoi4_agent_tools/map/limits.d.ts +13 -0
  254. package/dist/hoi4_agent_tools/map/limits.d.ts.map +1 -0
  255. package/dist/hoi4_agent_tools/map/limits.js +13 -0
  256. package/dist/hoi4_agent_tools/map/limits.js.map +1 -0
  257. package/dist/hoi4_agent_tools/map/model.d.ts +269 -0
  258. package/dist/hoi4_agent_tools/map/model.d.ts.map +1 -0
  259. package/dist/hoi4_agent_tools/map/model.js +1114 -0
  260. package/dist/hoi4_agent_tools/map/model.js.map +1 -0
  261. package/dist/hoi4_agent_tools/map/operations.d.ts +401 -0
  262. package/dist/hoi4_agent_tools/map/operations.d.ts.map +1 -0
  263. package/dist/hoi4_agent_tools/map/operations.js +2717 -0
  264. package/dist/hoi4_agent_tools/map/operations.js.map +1 -0
  265. package/dist/hoi4_agent_tools/map/render.d.ts +90 -0
  266. package/dist/hoi4_agent_tools/map/render.d.ts.map +1 -0
  267. package/dist/hoi4_agent_tools/map/render.js +759 -0
  268. package/dist/hoi4_agent_tools/map/render.js.map +1 -0
  269. package/dist/hoi4_agent_tools/map/service.d.ts +81 -0
  270. package/dist/hoi4_agent_tools/map/service.d.ts.map +1 -0
  271. package/dist/hoi4_agent_tools/map/service.js +695 -0
  272. package/dist/hoi4_agent_tools/map/service.js.map +1 -0
  273. package/dist/hoi4_agent_tools/map/validation.d.ts +23 -0
  274. package/dist/hoi4_agent_tools/map/validation.d.ts.map +1 -0
  275. package/dist/hoi4_agent_tools/map/validation.js +1177 -0
  276. package/dist/hoi4_agent_tools/map/validation.js.map +1 -0
  277. package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts +3 -0
  278. package/dist/hoi4_agent_tools/mcp/prompts/register.d.ts.map +1 -0
  279. package/dist/hoi4_agent_tools/mcp/prompts/register.js +50 -0
  280. package/dist/hoi4_agent_tools/mcp/prompts/register.js.map +1 -0
  281. package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts +9 -0
  282. package/dist/hoi4_agent_tools/mcp/registry/metadata.d.ts.map +1 -0
  283. package/dist/hoi4_agent_tools/mcp/registry/metadata.js +10 -0
  284. package/dist/hoi4_agent_tools/mcp/registry/metadata.js.map +1 -0
  285. package/dist/hoi4_agent_tools/mcp/resources/register.d.ts +5 -0
  286. package/dist/hoi4_agent_tools/mcp/resources/register.d.ts.map +1 -0
  287. package/dist/hoi4_agent_tools/mcp/resources/register.js +278 -0
  288. package/dist/hoi4_agent_tools/mcp/resources/register.js.map +1 -0
  289. package/dist/hoi4_agent_tools/mcp/security/auth.d.ts +24 -0
  290. package/dist/hoi4_agent_tools/mcp/security/auth.d.ts.map +1 -0
  291. package/dist/hoi4_agent_tools/mcp/security/auth.js +234 -0
  292. package/dist/hoi4_agent_tools/mcp/security/auth.js.map +1 -0
  293. package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts +35 -0
  294. package/dist/hoi4_agent_tools/mcp/server/base-tools.d.ts.map +1 -0
  295. package/dist/hoi4_agent_tools/mcp/server/base-tools.js +835 -0
  296. package/dist/hoi4_agent_tools/mcp/server/base-tools.js.map +1 -0
  297. package/dist/hoi4_agent_tools/mcp/server/create.d.ts +5 -0
  298. package/dist/hoi4_agent_tools/mcp/server/create.d.ts.map +1 -0
  299. package/dist/hoi4_agent_tools/mcp/server/create.js +26 -0
  300. package/dist/hoi4_agent_tools/mcp/server/create.js.map +1 -0
  301. package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts +133 -0
  302. package/dist/hoi4_agent_tools/mcp/server/output-schemas.d.ts.map +1 -0
  303. package/dist/hoi4_agent_tools/mcp/server/output-schemas.js +127 -0
  304. package/dist/hoi4_agent_tools/mcp/server/output-schemas.js.map +1 -0
  305. package/dist/hoi4_agent_tools/mcp/server/progress.d.ts +8 -0
  306. package/dist/hoi4_agent_tools/mcp/server/progress.d.ts.map +1 -0
  307. package/dist/hoi4_agent_tools/mcp/server/progress.js +21 -0
  308. package/dist/hoi4_agent_tools/mcp/server/progress.js.map +1 -0
  309. package/dist/hoi4_agent_tools/mcp/server/result.d.ts +232 -0
  310. package/dist/hoi4_agent_tools/mcp/server/result.d.ts.map +1 -0
  311. package/dist/hoi4_agent_tools/mcp/server/result.js +353 -0
  312. package/dist/hoi4_agent_tools/mcp/server/result.js.map +1 -0
  313. package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts +5 -0
  314. package/dist/hoi4_agent_tools/mcp/tools/focus.d.ts.map +1 -0
  315. package/dist/hoi4_agent_tools/mcp/tools/focus.js +1059 -0
  316. package/dist/hoi4_agent_tools/mcp/tools/focus.js.map +1 -0
  317. package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts +111 -0
  318. package/dist/hoi4_agent_tools/mcp/tools/gui.d.ts.map +1 -0
  319. package/dist/hoi4_agent_tools/mcp/tools/gui.js +598 -0
  320. package/dist/hoi4_agent_tools/mcp/tools/gui.js.map +1 -0
  321. package/dist/hoi4_agent_tools/mcp/tools/map.d.ts +5 -0
  322. package/dist/hoi4_agent_tools/mcp/tools/map.d.ts.map +1 -0
  323. package/dist/hoi4_agent_tools/mcp/tools/map.js +685 -0
  324. package/dist/hoi4_agent_tools/mcp/tools/map.js.map +1 -0
  325. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts +58 -0
  326. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.d.ts.map +1 -0
  327. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js +181 -0
  328. package/dist/hoi4_agent_tools/mcp/transports/bounded-stdio.js.map +1 -0
  329. package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts +26 -0
  330. package/dist/hoi4_agent_tools/mcp/transports/event-store.d.ts.map +1 -0
  331. package/dist/hoi4_agent_tools/mcp/transports/event-store.js +86 -0
  332. package/dist/hoi4_agent_tools/mcp/transports/event-store.js.map +1 -0
  333. package/dist/hoi4_agent_tools/mcp/transports/http.d.ts +28 -0
  334. package/dist/hoi4_agent_tools/mcp/transports/http.d.ts.map +1 -0
  335. package/dist/hoi4_agent_tools/mcp/transports/http.js +744 -0
  336. package/dist/hoi4_agent_tools/mcp/transports/http.js.map +1 -0
  337. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts +15 -0
  338. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.d.ts.map +1 -0
  339. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js +51 -0
  340. package/dist/hoi4_agent_tools/mcp/transports/protocol-gate.js.map +1 -0
  341. package/dist/hoi4_agent_tools/runtime.d.ts +4 -0
  342. package/dist/hoi4_agent_tools/runtime.d.ts.map +1 -0
  343. package/dist/hoi4_agent_tools/runtime.js +27 -0
  344. package/dist/hoi4_agent_tools/runtime.js.map +1 -0
  345. package/dist/hoi4_agent_tools/schemas/common.d.ts +74 -0
  346. package/dist/hoi4_agent_tools/schemas/common.d.ts.map +1 -0
  347. package/dist/hoi4_agent_tools/schemas/common.js +51 -0
  348. package/dist/hoi4_agent_tools/schemas/common.js.map +1 -0
  349. package/dist/hoi4_agent_tools/schemas/focus.d.ts +784 -0
  350. package/dist/hoi4_agent_tools/schemas/focus.d.ts.map +1 -0
  351. package/dist/hoi4_agent_tools/schemas/focus.js +330 -0
  352. package/dist/hoi4_agent_tools/schemas/focus.js.map +1 -0
  353. package/dist/hoi4_agent_tools/schemas/index.d.ts +5 -0
  354. package/dist/hoi4_agent_tools/schemas/index.d.ts.map +1 -0
  355. package/dist/hoi4_agent_tools/schemas/index.js +5 -0
  356. package/dist/hoi4_agent_tools/schemas/index.js.map +1 -0
  357. package/dist/hoi4_agent_tools/schemas/map.d.ts +654 -0
  358. package/dist/hoi4_agent_tools/schemas/map.d.ts.map +1 -0
  359. package/dist/hoi4_agent_tools/schemas/map.js +570 -0
  360. package/dist/hoi4_agent_tools/schemas/map.js.map +1 -0
  361. package/dist/hoi4_agent_tools/schemas/transaction.d.ts +259 -0
  362. package/dist/hoi4_agent_tools/schemas/transaction.d.ts.map +1 -0
  363. package/dist/hoi4_agent_tools/schemas/transaction.js +104 -0
  364. package/dist/hoi4_agent_tools/schemas/transaction.js.map +1 -0
  365. package/dist/hoi4_agent_tools/version.d.ts +6 -0
  366. package/dist/hoi4_agent_tools/version.d.ts.map +1 -0
  367. package/dist/hoi4_agent_tools/version.js +7 -0
  368. package/dist/hoi4_agent_tools/version.js.map +1 -0
  369. package/dist/index.d.ts +3 -0
  370. package/dist/index.d.ts.map +1 -0
  371. package/dist/index.js +3 -0
  372. package/dist/index.js.map +1 -0
  373. package/docs/README.md +22 -0
  374. package/docs/adr/0001-runtime-and-language.md +16 -0
  375. package/docs/adr/0002-lossless-source-model.md +18 -0
  376. package/docs/adr/0003-image-and-font-codecs.md +18 -0
  377. package/docs/adr/0004-focus-layout.md +16 -0
  378. package/docs/adr/0005-offline-rendering.md +18 -0
  379. package/docs/adr/0006-mcp-sdk-and-protocol.md +16 -0
  380. package/docs/adr/0007-storage-and-transactions.md +24 -0
  381. package/docs/adr/0008-test-strategy.md +18 -0
  382. package/docs/adr/0009-packaging-and-registry.md +16 -0
  383. package/docs/adr/0010-unsupported-and-refusal-policy.md +18 -0
  384. package/docs/adr/0011-http-security.md +16 -0
  385. package/docs/adr/README.md +13 -0
  386. package/docs/architecture.md +60 -0
  387. package/docs/artifacts.md +133 -0
  388. package/docs/compatibility.md +33 -0
  389. package/docs/completion-report.md +60 -0
  390. package/docs/configuration.md +285 -0
  391. package/docs/focus-workflow.md +68 -0
  392. package/docs/gui-workflow.md +121 -0
  393. package/docs/limitations.md +30 -0
  394. package/docs/map-workflow.md +89 -0
  395. package/docs/performance.md +117 -0
  396. package/docs/release.md +181 -0
  397. package/docs/research/mcp-2026-07-10.md +46 -0
  398. package/docs/research/source-ledger.md +68 -0
  399. package/docs/security.md +139 -0
  400. package/docs/self-hosting.md +168 -0
  401. package/docs/testing.md +43 -0
  402. package/docs/third-party-notices.md +11 -0
  403. package/docs/transactions.md +162 -0
  404. package/docs/troubleshooting.md +46 -0
  405. package/package.json +98 -5
  406. package/schemas/configuration.schema.json +794 -0
  407. package/schemas/continuous-focus-palette.schema.json +325 -0
  408. package/schemas/focus-plan.schema.json +902 -0
  409. package/schemas/focus-planning-sidecar.schema.json +364 -0
  410. package/schemas/gui-animation-source.schema.json +176 -0
  411. package/schemas/gui-helper.schema.json +301 -0
  412. package/schemas/gui-scenario.schema.json +298 -0
  413. package/schemas/map-operation.schema.json +2284 -0
  414. package/schemas/operation-result.schema.json +344 -0
  415. package/schemas/transaction-manifest.schema.json +685 -0
  416. package/server.json +32 -0
@@ -0,0 +1,759 @@
1
+ import sharp from 'sharp';
2
+ import { compareCodeUnits, canonicalJson, sha256Bytes } from '../core/canonical.js';
3
+ import { assertRenderDimensions, RenderBudget, RENDER_MAX_PIXELS } from '../core/render-budget.js';
4
+ import { ServiceError } from '../core/result.js';
5
+ import { validateMapAsync } from './validation.js';
6
+ function stableColor(key) {
7
+ const hash = sha256Bytes(key);
8
+ const first = Number.parseInt(hash.slice(0, 2), 16);
9
+ const second = Number.parseInt(hash.slice(2, 4), 16);
10
+ const third = Number.parseInt(hash.slice(4, 6), 16);
11
+ return {
12
+ r: 48 + (first % 176),
13
+ g: 48 + (second % 176),
14
+ b: 48 + (third % 176),
15
+ };
16
+ }
17
+ function stateId(index, provinceId) {
18
+ const states = index.stateForProvince(provinceId);
19
+ return states.length === 1 ? states[0]?.id : undefined;
20
+ }
21
+ function regionId(index, provinceId) {
22
+ const regions = index.regionForProvince(provinceId);
23
+ return regions.length === 1 ? regions[0]?.id : undefined;
24
+ }
25
+ function baseColor(index, provinceId, layer) {
26
+ const definition = index.definitionsById.get(provinceId);
27
+ if (definition === undefined)
28
+ return { r: 255, g: 0, b: 255 };
29
+ const state = stateId(index, provinceId);
30
+ const stateRecord = state === undefined ? undefined : index.statesById.get(state);
31
+ if (layer === 'province')
32
+ return definition.color;
33
+ if (layer === 'state')
34
+ return stableColor(state === undefined ? 'state:none' : `state:${state}`);
35
+ if (layer === 'strategic-region') {
36
+ const region = regionId(index, provinceId);
37
+ return stableColor(region === undefined ? 'region:none' : `region:${region}`);
38
+ }
39
+ if (layer === 'terrain')
40
+ return stableColor(`terrain:${definition.terrain}`);
41
+ if (layer === 'continent')
42
+ return stableColor(`continent:${definition.continent}`);
43
+ if (layer === 'owner')
44
+ return stableColor(`owner:${stateRecord?.owner ?? 'none'}`);
45
+ if (layer === 'controller')
46
+ return stableColor(`controller:${stateRecord?.controller ?? stateRecord?.owner ?? 'none'}`);
47
+ if (layer === 'cores')
48
+ return stableColor(`cores:${[...(stateRecord?.cores ?? [])].sort().join(',') || 'none'}`);
49
+ if (layer === 'claims')
50
+ return stableColor(`claims:${[...(stateRecord?.claims ?? [])].sort().join(',') || 'none'}`);
51
+ return index.raster?.coastalProvinceIds.has(provinceId)
52
+ ? definition.type === 'land'
53
+ ? { r: 227, g: 186, b: 65 }
54
+ : { r: 44, g: 158, b: 202 }
55
+ : { r: 45, g: 51, b: 58 };
56
+ }
57
+ function setPixel(bytes, width, height, x, y, color, alpha = 255) {
58
+ if (x < 0 || y < 0 || x >= width || y >= height)
59
+ return;
60
+ const offset = (y * width + x) * 4;
61
+ bytes[offset] = color.r;
62
+ bytes[offset + 1] = color.g;
63
+ bytes[offset + 2] = color.b;
64
+ bytes[offset + 3] = alpha;
65
+ }
66
+ function marker(bytes, width, height, x, y, color, radius = 2) {
67
+ for (let dy = -radius; dy <= radius; dy += 1) {
68
+ for (let dx = -radius; dx <= radius; dx += 1) {
69
+ if (dx * dx + dy * dy <= radius * radius)
70
+ setPixel(bytes, width, height, Math.round(x) + dx, Math.round(y) + dy, color);
71
+ }
72
+ }
73
+ }
74
+ function line(bytes, width, height, from, to, color) {
75
+ let x0 = Math.round(from.centerX);
76
+ let y0 = Math.round(from.centerY);
77
+ const x1 = Math.round(to.centerX);
78
+ const y1 = Math.round(to.centerY);
79
+ const dx = Math.abs(x1 - x0);
80
+ const sx = x0 < x1 ? 1 : -1;
81
+ const dy = -Math.abs(y1 - y0);
82
+ const sy = y0 < y1 ? 1 : -1;
83
+ let error = dx + dy;
84
+ for (;;) {
85
+ marker(bytes, width, height, x0, y0, color, 1);
86
+ if (x0 === x1 && y0 === y1)
87
+ break;
88
+ const doubled = error * 2;
89
+ if (doubled >= dy) {
90
+ error += dy;
91
+ x0 += sx;
92
+ }
93
+ if (doubled <= dx) {
94
+ error += dx;
95
+ y0 += sy;
96
+ }
97
+ }
98
+ }
99
+ function provinceCenter(index, provinceId) {
100
+ return index.raster?.geometry.get(provinceId);
101
+ }
102
+ function stateCenter(index, state) {
103
+ let pixels = 0;
104
+ let weightedX = 0;
105
+ let weightedY = 0;
106
+ let minX = Number.POSITIVE_INFINITY;
107
+ let minY = Number.POSITIVE_INFINITY;
108
+ let maxX = Number.NEGATIVE_INFINITY;
109
+ let maxY = Number.NEGATIVE_INFINITY;
110
+ for (const provinceId of state.provinces) {
111
+ const geometry = provinceCenter(index, provinceId);
112
+ if (geometry === undefined)
113
+ continue;
114
+ pixels += geometry.pixelCount;
115
+ weightedX += geometry.centerX * geometry.pixelCount;
116
+ weightedY += geometry.centerY * geometry.pixelCount;
117
+ minX = Math.min(minX, geometry.minX);
118
+ minY = Math.min(minY, geometry.minY);
119
+ maxX = Math.max(maxX, geometry.maxX);
120
+ maxY = Math.max(maxY, geometry.maxY);
121
+ }
122
+ if (pixels === 0)
123
+ return undefined;
124
+ return {
125
+ id: state.id,
126
+ pixelCount: pixels,
127
+ minX,
128
+ minY,
129
+ maxX,
130
+ maxY,
131
+ centerX: weightedX / pixels,
132
+ centerY: weightedY / pixels,
133
+ };
134
+ }
135
+ function valueMarkers(bytes, width, height, center, values, namespace, phase) {
136
+ const entries = [...values].sort(([left], [right]) => compareCodeUnits(left, right));
137
+ for (const [index, [key, value]] of entries.entries()) {
138
+ const angle = ((index + phase) % 8) * (Math.PI / 4);
139
+ const ring = 3 + Math.floor((index + phase) / 8) * 3;
140
+ marker(bytes, width, height, center.centerX + Math.cos(angle) * ring, center.centerY + Math.sin(angle) * ring, stableColor(`${namespace}:${key}`), Math.min(4, Math.max(1, Math.ceil(Math.log2(Math.max(0, value) + 1)))));
141
+ }
142
+ }
143
+ async function renderCheckpoint(signal) {
144
+ signal?.throwIfAborted();
145
+ await new Promise((resolve) => setImmediate(resolve));
146
+ signal?.throwIfAborted();
147
+ }
148
+ function mapCoordinateToPixel(index, x, z) {
149
+ const raster = index.raster;
150
+ if (raster === undefined)
151
+ return undefined;
152
+ const pixel = { x: Math.floor(x), y: raster.height - 1 - Math.floor(z) };
153
+ return pixel.x < 0 || pixel.y < 0 || pixel.x >= raster.width || pixel.y >= raster.height
154
+ ? undefined
155
+ : pixel;
156
+ }
157
+ async function applyOverlays(index, bytes, overlays, signal) {
158
+ const raster = index.raster;
159
+ if (raster === undefined)
160
+ return;
161
+ if (overlays.has('coastlines')) {
162
+ for (let y = 0; y < raster.height; y += 1) {
163
+ if (y % 32 === 0)
164
+ await renderCheckpoint(signal);
165
+ for (let x = 0; x < raster.width; x += 1) {
166
+ const id = raster.provinceIds[y * raster.width + x] ?? -1;
167
+ const definition = index.definitionsById.get(id);
168
+ if (definition?.type !== 'land')
169
+ continue;
170
+ const neighbors = [
171
+ raster.provinceIds[y * raster.width + (x === 0 ? raster.width - 1 : x - 1)] ?? -1,
172
+ raster.provinceIds[y * raster.width + (x === raster.width - 1 ? 0 : x + 1)] ?? -1,
173
+ y === 0 ? -1 : (raster.provinceIds[(y - 1) * raster.width + x] ?? -1),
174
+ y === raster.height - 1 ? -1 : (raster.provinceIds[(y + 1) * raster.width + x] ?? -1),
175
+ ];
176
+ if (neighbors.some((neighbor) => index.definitionsById.get(neighbor)?.type === 'sea')) {
177
+ setPixel(bytes, raster.width, raster.height, x, y, { r: 65, g: 223, b: 255 });
178
+ }
179
+ }
180
+ }
181
+ }
182
+ if (overlays.has('ports')) {
183
+ for (const state of index.states) {
184
+ for (const [provinceId, buildings] of state.provinceBuildings) {
185
+ if ((buildings.get('naval_base') ?? 0) <= 0)
186
+ continue;
187
+ const center = provinceCenter(index, provinceId);
188
+ if (center !== undefined)
189
+ marker(bytes, raster.width, raster.height, center.centerX, center.centerY, { r: 46, g: 221, b: 255 }, 3);
190
+ }
191
+ }
192
+ }
193
+ if (overlays.has('victory-points')) {
194
+ for (const state of index.states) {
195
+ for (const point of state.victoryPoints) {
196
+ const center = provinceCenter(index, point.provinceId);
197
+ if (center !== undefined)
198
+ marker(bytes, raster.width, raster.height, center.centerX, center.centerY, { r: 255, g: 223, b: 72 }, Math.min(5, Math.max(2, Math.ceil(point.value / 10))));
199
+ }
200
+ }
201
+ }
202
+ if (overlays.has('resources')) {
203
+ for (const state of [...index.states].sort((left, right) => left.id - right.id)) {
204
+ signal?.throwIfAborted();
205
+ const center = stateCenter(index, state);
206
+ if (center !== undefined)
207
+ valueMarkers(bytes, raster.width, raster.height, center, state.resources, 'resource', 0);
208
+ }
209
+ }
210
+ if (overlays.has('state-buildings')) {
211
+ for (const state of [...index.states].sort((left, right) => left.id - right.id)) {
212
+ signal?.throwIfAborted();
213
+ const center = stateCenter(index, state);
214
+ if (center !== undefined)
215
+ valueMarkers(bytes, raster.width, raster.height, center, state.stateBuildings, 'state-building', 2);
216
+ }
217
+ }
218
+ if (overlays.has('province-buildings')) {
219
+ for (const state of [...index.states].sort((left, right) => left.id - right.id)) {
220
+ for (const [provinceId, buildings] of [...state.provinceBuildings].sort(([left], [right]) => left - right)) {
221
+ signal?.throwIfAborted();
222
+ const center = provinceCenter(index, provinceId);
223
+ if (center !== undefined)
224
+ valueMarkers(bytes, raster.width, raster.height, center, buildings, 'province-building', 4);
225
+ }
226
+ }
227
+ }
228
+ if (overlays.has('supply-nodes')) {
229
+ for (const node of index.supplyNodes) {
230
+ const center = provinceCenter(index, node.provinceId);
231
+ if (center !== undefined)
232
+ marker(bytes, raster.width, raster.height, center.centerX, center.centerY, { r: 241, g: 76, b: 76 }, 3);
233
+ }
234
+ }
235
+ if (overlays.has('railways')) {
236
+ for (const railway of index.railways) {
237
+ for (let position = 1; position < railway.provinces.length; position += 1) {
238
+ const fromId = railway.provinces[position - 1];
239
+ const toId = railway.provinces[position];
240
+ if (fromId === undefined || toId === undefined)
241
+ continue;
242
+ const from = provinceCenter(index, fromId);
243
+ const to = provinceCenter(index, toId);
244
+ if (from !== undefined && to !== undefined)
245
+ line(bytes, raster.width, raster.height, from, to, { r: 94, g: 233, b: 121 });
246
+ }
247
+ }
248
+ }
249
+ if (overlays.has('adjacencies')) {
250
+ for (const adjacency of index.adjacencies) {
251
+ const from = provinceCenter(index, adjacency.from);
252
+ const to = provinceCenter(index, adjacency.to);
253
+ if (from !== undefined && to !== undefined)
254
+ line(bytes, raster.width, raster.height, from, to, adjacency.type === 'impassable' ? { r: 255, g: 72, b: 72 } : { r: 211, g: 102, b: 255 });
255
+ }
256
+ }
257
+ if (overlays.has('building-positions')) {
258
+ for (const position of index.buildingPositions) {
259
+ const pixel = mapCoordinateToPixel(index, position.x, position.z);
260
+ if (pixel !== undefined)
261
+ marker(bytes, raster.width, raster.height, pixel.x, pixel.y, { r: 255, g: 153, b: 51 }, 2);
262
+ }
263
+ }
264
+ if (overlays.has('unit-positions')) {
265
+ for (const position of index.unitPositions) {
266
+ const pixel = mapCoordinateToPixel(index, position.x, position.z);
267
+ if (pixel !== undefined)
268
+ marker(bytes, raster.width, raster.height, pixel.x, pixel.y, { r: 255, g: 255, b: 255 }, 2);
269
+ }
270
+ }
271
+ if (overlays.has('weather-positions')) {
272
+ for (const position of index.weatherPositions) {
273
+ const pixel = mapCoordinateToPixel(index, position.x, position.z);
274
+ if (pixel !== undefined)
275
+ marker(bytes, raster.width, raster.height, pixel.x, pixel.y, { r: 88, g: 174, b: 255 }, position.size === 'big' ? 4 : 2);
276
+ }
277
+ }
278
+ }
279
+ async function renderMetadata(index, options, signal) {
280
+ const victoryPoints = index.states
281
+ .flatMap((state) => state.victoryPoints.map(({ provinceId, value }) => ({
282
+ stateId: state.id,
283
+ provinceId,
284
+ value,
285
+ sourcePath: state.file.displayPath,
286
+ })))
287
+ .sort((left, right) => left.stateId - right.stateId ||
288
+ left.provinceId - right.provinceId ||
289
+ left.value - right.value);
290
+ const normalAdjacencies = [...(index.raster?.adjacency ?? [])]
291
+ .flatMap(([from, neighbors]) => [...neighbors].flatMap((to) => (from < to ? [{ from, to }] : [])))
292
+ .sort((left, right) => left.from - right.from || left.to - right.to);
293
+ return {
294
+ offline: true,
295
+ renderer: 'hoi4-agent-tools-agent-nudger',
296
+ layer: options.layer,
297
+ overlays: options.overlays,
298
+ scale: options.scale,
299
+ width: index.raster?.width ?? 0,
300
+ height: index.raster?.height ?? 0,
301
+ definitions: index.definitions.map(({ id, color, type, coastal, terrain, continent }) => ({
302
+ id,
303
+ color,
304
+ type,
305
+ coastal,
306
+ terrain,
307
+ continent,
308
+ })),
309
+ states: [...index.states]
310
+ .sort((left, right) => left.id - right.id)
311
+ .map(({ id, name, capital, provinces, resources, stateBuildings, provinceBuildings, owner, controller, cores, claims, }) => ({
312
+ id,
313
+ name,
314
+ capital: capital ?? null,
315
+ manpower: index.statesById.get(id)?.manpower ?? 0,
316
+ category: index.statesById.get(id)?.category ?? '',
317
+ provinces: [...provinces].sort((a, b) => a - b),
318
+ resources: Object.fromEntries([...resources].sort(([left], [right]) => compareCodeUnits(left, right))),
319
+ stateBuildings: Object.fromEntries([...stateBuildings].sort(([left], [right]) => compareCodeUnits(left, right))),
320
+ provinceBuildings: Object.fromEntries([...provinceBuildings]
321
+ .sort(([left], [right]) => left - right)
322
+ .map(([provinceId, buildings]) => [
323
+ String(provinceId),
324
+ Object.fromEntries([...buildings].sort(([left], [right]) => compareCodeUnits(left, right))),
325
+ ])),
326
+ owner: owner ?? null,
327
+ controller: controller ?? null,
328
+ cores: [...cores].sort(),
329
+ claims: [...claims].sort(),
330
+ })),
331
+ regions: [...index.regions]
332
+ .sort((left, right) => left.id - right.id)
333
+ .map(({ id, name, provinces }) => ({
334
+ id,
335
+ name,
336
+ provinces: [...provinces].sort((a, b) => a - b),
337
+ })),
338
+ victoryPoints,
339
+ ports: [...index.ports]
340
+ .sort((left, right) => left.stateId - right.stateId || left.provinceId - right.provinceId)
341
+ .map(({ stateId, provinceId, level, coastal, adjacentSeaProvinceIds, positions }) => ({
342
+ stateId,
343
+ provinceId,
344
+ level,
345
+ coastal,
346
+ adjacentSeaProvinceIds: [...adjacentSeaProvinceIds].sort((left, right) => left - right),
347
+ positions: positions.map(({ building, x, y, z, rotation, adjacentSeaProvince, document, line }) => ({
348
+ building,
349
+ x,
350
+ y,
351
+ z,
352
+ rotation,
353
+ adjacentSeaProvince,
354
+ sourcePath: document.file.displayPath,
355
+ line,
356
+ })),
357
+ })),
358
+ supplyNodes: index.supplyNodes.map(({ level, provinceId, document, line }) => ({
359
+ level,
360
+ provinceId,
361
+ sourcePath: document.file.displayPath,
362
+ line,
363
+ })),
364
+ railways: index.railways.map(({ level, declaredCount, provinces, document, line }, ordinal) => ({
365
+ ordinal,
366
+ level,
367
+ declaredCount,
368
+ provinces: [...provinces],
369
+ sourcePath: document.file.displayPath,
370
+ line,
371
+ })),
372
+ adjacencies: index.adjacencies.map(({ from, to, type, through, startX, startY, stopX, stopY, rule, comment, document, line }, ordinal) => ({
373
+ ordinal,
374
+ from,
375
+ to,
376
+ type,
377
+ through,
378
+ startX,
379
+ startY,
380
+ stopX,
381
+ stopY,
382
+ rule,
383
+ comment,
384
+ sourcePath: document.file.displayPath,
385
+ line,
386
+ })),
387
+ normalAdjacencies,
388
+ buildingPositions: index.buildingPositions.map(({ stateId, building, x, y, z, rotation, adjacentSeaProvince, document, line }) => ({
389
+ stateId,
390
+ building,
391
+ x,
392
+ y,
393
+ z,
394
+ rotation,
395
+ adjacentSeaProvince,
396
+ sourcePath: document.file.displayPath,
397
+ line,
398
+ })),
399
+ unitPositions: index.unitPositions.map(({ provinceId, type, x, y, z, rotation, offset, document, line }) => ({
400
+ provinceId,
401
+ type,
402
+ x,
403
+ y,
404
+ z,
405
+ rotation,
406
+ offset,
407
+ sourcePath: document.file.displayPath,
408
+ line,
409
+ })),
410
+ weatherPositions: index.weatherPositions.map(({ strategicRegionId, x, y, z, size, document, line }) => ({
411
+ strategicRegionId,
412
+ x,
413
+ y,
414
+ z,
415
+ size,
416
+ sourcePath: document.file.displayPath,
417
+ line,
418
+ })),
419
+ entityLocators: [...index.entityLocators]
420
+ .sort((left, right) => compareCodeUnits(left.entity, right.entity) || compareCodeUnits(left.name, right.name))
421
+ .map(({ entity, name, position, file }) => ({
422
+ entity,
423
+ name,
424
+ position: [...position],
425
+ sourcePath: file.displayPath,
426
+ })),
427
+ validation: await validateMapAsync(index, signal === undefined ? {} : { signal }),
428
+ };
429
+ }
430
+ function htmlDocument(title, png, json) {
431
+ const escapedTitle = title
432
+ .replaceAll('&', '&amp;')
433
+ .replaceAll('<', '&lt;')
434
+ .replaceAll('>', '&gt;');
435
+ const escapedJson = json.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;');
436
+ return `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escapedTitle}</title><style>html{background:#10151b;color:#edf2f7;font:14px system-ui}body{margin:20px}.controls{display:flex;gap:8px;align-items:center;margin:12px 0}button{background:#263241;color:#edf2f7;border:1px solid #526173;border-radius:4px;padding:6px 10px}.viewport{height:70vh;overflow:hidden;border:1px solid #48515c;background:#080b0f;position:relative;touch-action:none}.viewport img{image-rendering:pixelated;transform-origin:0 0;position:absolute;max-width:none;cursor:grab;user-select:none}.viewport img.dragging{cursor:grabbing}pre{white-space:pre-wrap;overflow-wrap:anywhere}</style></head><body><h1>${escapedTitle}</h1><p>Offline deterministic map representation; not an in-game screenshot or source editor.</p><div class="controls"><button id="out" type="button">-</button><button id="reset" type="button">Reset</button><button id="in" type="button">+</button><output id="zoom">100%</output></div><div class="viewport" id="viewport"><img id="map" draggable="false" alt="${escapedTitle}" src="data:image/png;base64,${png.toString('base64')}"></div><details><summary>Render metadata</summary><pre>${escapedJson}</pre></details><script>(()=>{const image=document.getElementById('map'),viewport=document.getElementById('viewport'),label=document.getElementById('zoom');let scale=1,x=0,y=0,drag=false,lastX=0,lastY=0;const draw=()=>{image.style.transform='translate('+x+'px,'+y+'px) scale('+scale+')';label.value=Math.round(scale*100)+'%'};const zoom=(factor,cx=viewport.clientWidth/2,cy=viewport.clientHeight/2)=>{const next=Math.min(16,Math.max(.1,scale*factor));x=cx-(cx-x)*(next/scale);y=cy-(cy-y)*(next/scale);scale=next;draw()};document.getElementById('in').onclick=()=>zoom(1.25);document.getElementById('out').onclick=()=>zoom(.8);document.getElementById('reset').onclick=()=>{scale=1;x=0;y=0;draw()};viewport.addEventListener('wheel',event=>{event.preventDefault();const bounds=viewport.getBoundingClientRect();zoom(event.deltaY<0?1.15:.87,event.clientX-bounds.left,event.clientY-bounds.top)},{passive:false});image.addEventListener('pointerdown',event=>{drag=true;lastX=event.clientX;lastY=event.clientY;image.setPointerCapture(event.pointerId);image.classList.add('dragging')});image.addEventListener('pointermove',event=>{if(!drag)return;x+=event.clientX-lastX;y+=event.clientY-lastY;lastX=event.clientX;lastY=event.clientY;draw()});image.addEventListener('pointerup',()=>{drag=false;image.classList.remove('dragging')});draw()})();</script></body></html>`;
437
+ }
438
+ async function encodePng(raw, width, height, scale) {
439
+ assertRenderDimensions(width, height, 'map Sharp source raster');
440
+ assertRenderDimensions(width * scale, height * scale, 'map Sharp output raster');
441
+ let pipeline = sharp(raw, {
442
+ raw: { width, height, channels: 4 },
443
+ limitInputPixels: RENDER_MAX_PIXELS,
444
+ });
445
+ if (scale !== 1)
446
+ pipeline = pipeline.resize(width * scale, height * scale, { kernel: 'nearest' });
447
+ return pipeline.png({ compressionLevel: 9, adaptiveFiltering: false, palette: false }).toBuffer();
448
+ }
449
+ export async function renderMap(index, options = {}) {
450
+ const raster = index.raster;
451
+ if (raster === undefined) {
452
+ const budgetDiagnostic = index.diagnostics.find(({ code }) => code.startsWith('RENDER_'));
453
+ if (budgetDiagnostic !== undefined) {
454
+ throw new ServiceError(budgetDiagnostic.code, budgetDiagnostic.message, budgetDiagnostic.details ?? {});
455
+ }
456
+ throw new ServiceError('MAP_RENDER_RASTER_MISSING', 'Cannot render without a valid province bitmap and definitions');
457
+ }
458
+ const resolved = {
459
+ layer: options.layer ?? 'province',
460
+ overlays: [...new Set(options.overlays ?? [])].sort(),
461
+ scale: options.scale ?? 1,
462
+ };
463
+ if (!Number.isInteger(resolved.scale) || resolved.scale < 1 || resolved.scale > 16)
464
+ throw new ServiceError('MAP_RENDER_SCALE_INVALID', 'Map render scale must be an integer from 1 through 16');
465
+ const budget = options.budget ?? new RenderBudget();
466
+ assertRenderDimensions(raster.width, raster.height, 'map RGBA source plane');
467
+ const outputDimensions = budget.reserve(raster.width * resolved.scale, raster.height * resolved.scale, 'map PNG output');
468
+ const raw = Buffer.alloc(raster.width * raster.height * 4);
469
+ for (let offset = 0; offset < raster.provinceIds.length; offset += 1) {
470
+ if (offset % Math.max(raster.width * 32, 1) === 0)
471
+ await renderCheckpoint(options.signal);
472
+ const color = baseColor(index, raster.provinceIds[offset] ?? -1, resolved.layer);
473
+ const target = offset * 4;
474
+ raw[target] = color.r;
475
+ raw[target + 1] = color.g;
476
+ raw[target + 2] = color.b;
477
+ raw[target + 3] = 255;
478
+ }
479
+ await applyOverlays(index, raw, new Set(resolved.overlays), options.signal);
480
+ options.signal?.throwIfAborted();
481
+ const png = await encodePng(raw, raster.width, raster.height, resolved.scale);
482
+ options.signal?.throwIfAborted();
483
+ const json = `${canonicalJson(await renderMetadata(index, resolved, options.signal))}\n`;
484
+ const html = htmlDocument(`Agent Nudger map - ${resolved.layer}`, png, json);
485
+ return {
486
+ width: outputDimensions.width,
487
+ height: outputDimensions.height,
488
+ png,
489
+ json,
490
+ html,
491
+ hashes: { png: sha256Bytes(png), json: sha256Bytes(json), html: sha256Bytes(html) },
492
+ };
493
+ }
494
+ function definitionSignature(index, id) {
495
+ const value = index.definitionsById.get(id);
496
+ return value === undefined
497
+ ? null
498
+ : canonicalJson({
499
+ color: value.color,
500
+ type: value.type,
501
+ coastal: value.coastal,
502
+ terrain: value.terrain,
503
+ continent: value.continent,
504
+ });
505
+ }
506
+ function listSignature(value) {
507
+ return canonicalJson(value);
508
+ }
509
+ function stateSignature(index, id) {
510
+ const state = index.statesById.get(id);
511
+ return state === undefined
512
+ ? null
513
+ : canonicalJson({
514
+ name: state.name,
515
+ capital: state.capital ?? null,
516
+ manpower: state.manpower,
517
+ category: state.category,
518
+ resources: Object.fromEntries(state.resources),
519
+ owner: state.owner ?? null,
520
+ controller: state.controller ?? null,
521
+ cores: [...state.cores].sort(),
522
+ claims: [...state.claims].sort(),
523
+ victoryPoints: state.victoryPoints
524
+ .map(({ provinceId, value }) => ({ provinceId, value }))
525
+ .sort((left, right) => left.provinceId - right.provinceId || left.value - right.value),
526
+ stateBuildings: Object.fromEntries(state.stateBuildings),
527
+ provinceBuildings: Object.fromEntries([...state.provinceBuildings]
528
+ .sort(([left], [right]) => left - right)
529
+ .map(([provinceId, buildings]) => [String(provinceId), Object.fromEntries(buildings)])),
530
+ });
531
+ }
532
+ function diffRecordMaps(before, after) {
533
+ return [...new Set([...before.keys(), ...after.keys()])]
534
+ .sort((left, right) => compareCodeUnits(left, right))
535
+ .flatMap((key) => {
536
+ const left = before.get(key) ?? null;
537
+ const right = after.get(key) ?? null;
538
+ return left === right ? [] : [{ key, before: left, after: right }];
539
+ });
540
+ }
541
+ function occurrenceRecordMap(values, groupKey, signature) {
542
+ const occurrences = new Map();
543
+ const result = new Map();
544
+ for (const value of values) {
545
+ const group = groupKey(value);
546
+ const occurrence = occurrences.get(group) ?? 0;
547
+ occurrences.set(group, occurrence + 1);
548
+ result.set(`${group}:${occurrence}`, canonicalJson(signature(value)));
549
+ }
550
+ return result;
551
+ }
552
+ export function semanticMapDiff(before, after) {
553
+ const provinceIds = uniqueNumbers([
554
+ ...before.definitionsById.keys(),
555
+ ...after.definitionsById.keys(),
556
+ ]);
557
+ const definitions = provinceIds.flatMap((id) => {
558
+ const left = definitionSignature(before, id);
559
+ const right = definitionSignature(after, id);
560
+ return left === right ? [] : [{ id, before: left, after: right }];
561
+ });
562
+ const stateMembership = provinceIds.flatMap((provinceId) => {
563
+ const left = before
564
+ .stateForProvince(provinceId)
565
+ .map(({ id }) => id)
566
+ .sort((a, b) => a - b);
567
+ const right = after
568
+ .stateForProvince(provinceId)
569
+ .map(({ id }) => id)
570
+ .sort((a, b) => a - b);
571
+ return listSignature(left) === listSignature(right)
572
+ ? []
573
+ : [{ provinceId, before: left, after: right }];
574
+ });
575
+ const regionMembership = provinceIds.flatMap((provinceId) => {
576
+ const left = before
577
+ .regionForProvince(provinceId)
578
+ .map(({ id }) => id)
579
+ .sort((a, b) => a - b);
580
+ const right = after
581
+ .regionForProvince(provinceId)
582
+ .map(({ id }) => id)
583
+ .sort((a, b) => a - b);
584
+ return listSignature(left) === listSignature(right)
585
+ ? []
586
+ : [{ provinceId, before: left, after: right }];
587
+ });
588
+ const stateIds = uniqueNumbers([...before.statesById.keys(), ...after.statesById.keys()]);
589
+ const states = stateIds.flatMap((id) => {
590
+ const left = stateSignature(before, id);
591
+ const right = stateSignature(after, id);
592
+ return left === right ? [] : [{ key: String(id), before: left, after: right }];
593
+ });
594
+ const portRecords = (index) => new Map(index.ports.map((port) => [
595
+ `${port.stateId}:${port.provinceId}`,
596
+ canonicalJson({
597
+ level: port.level,
598
+ coastal: port.coastal,
599
+ adjacentSeaProvinceIds: port.adjacentSeaProvinceIds,
600
+ positionCount: port.positions.length,
601
+ }),
602
+ ]));
603
+ const buildingPositionRecords = (index) => occurrenceRecordMap(index.buildingPositions, ({ stateId, building }) => `${stateId}:${building}`, ({ stateId, building, x, y, z, rotation, adjacentSeaProvince }) => ({
604
+ stateId,
605
+ building,
606
+ x,
607
+ y,
608
+ z,
609
+ rotation,
610
+ adjacentSeaProvince,
611
+ }));
612
+ const unitPositionRecords = (index) => occurrenceRecordMap(index.unitPositions, ({ provinceId, type }) => `${provinceId}:${type}`, ({ provinceId, type, x, y, z, rotation, offset }) => ({
613
+ provinceId,
614
+ type,
615
+ x,
616
+ y,
617
+ z,
618
+ rotation,
619
+ offset,
620
+ }));
621
+ const weatherPositionRecords = (index) => occurrenceRecordMap(index.weatherPositions, ({ strategicRegionId, size }) => `${strategicRegionId}:${size}`, ({ strategicRegionId, x, y, z, size }) => ({ strategicRegionId, x, y, z, size }));
622
+ const entityLocatorRecords = (index) => occurrenceRecordMap(index.entityLocators, ({ entity, name }) => `${entity}:${name}`, ({ entity, name, position }) => ({ entity, name, position }));
623
+ const supplyNodeRecords = (index) => occurrenceRecordMap(index.supplyNodes, ({ provinceId }) => String(provinceId), ({ level, provinceId }) => ({ level, provinceId }));
624
+ const railwayRecords = (index) => new Map(index.railways.map(({ level, provinces }, position) => [
625
+ String(position),
626
+ canonicalJson({ level, provinces }),
627
+ ]));
628
+ const adjacencyRecords = (index) => occurrenceRecordMap(index.adjacencies, ({ from, to, type }) => `${Math.min(from, to)}:${Math.max(from, to)}:${type}`, ({ from, to, type, through, startX, startY, stopX, stopY, rule, comment }) => ({
629
+ from,
630
+ to,
631
+ type,
632
+ through,
633
+ startX,
634
+ startY,
635
+ stopX,
636
+ stopY,
637
+ rule,
638
+ comment,
639
+ }));
640
+ const normalAdjacencyRecords = (index) => {
641
+ const result = new Map();
642
+ for (const [from, neighbors] of index.raster?.adjacency ?? []) {
643
+ for (const to of neighbors) {
644
+ if (from >= to)
645
+ continue;
646
+ result.set(`${from}:${to}`, canonicalJson({ from, to }));
647
+ }
648
+ }
649
+ return result;
650
+ };
651
+ const beforeNormalAdjacencies = normalAdjacencyRecords(before);
652
+ const afterNormalAdjacencies = normalAdjacencyRecords(after);
653
+ const normalAdjacencies = diffRecordMaps(beforeNormalAdjacencies, afterNormalAdjacencies);
654
+ return {
655
+ definitions,
656
+ stateMembership,
657
+ regionMembership,
658
+ states,
659
+ ports: diffRecordMaps(portRecords(before), portRecords(after)),
660
+ buildingPositions: diffRecordMaps(buildingPositionRecords(before), buildingPositionRecords(after)),
661
+ unitPositions: diffRecordMaps(unitPositionRecords(before), unitPositionRecords(after)),
662
+ weatherPositions: diffRecordMaps(weatherPositionRecords(before), weatherPositionRecords(after)),
663
+ entityLocators: diffRecordMaps(entityLocatorRecords(before), entityLocatorRecords(after)),
664
+ supplyNodes: diffRecordMaps(supplyNodeRecords(before), supplyNodeRecords(after)),
665
+ railways: diffRecordMaps(railwayRecords(before), railwayRecords(after)),
666
+ adjacencies: diffRecordMaps(adjacencyRecords(before), adjacencyRecords(after)),
667
+ normalAdjacencies,
668
+ supplyNodesChanged: listSignature(before.supplyNodes.map(({ level, provinceId }) => ({ level, provinceId }))) !==
669
+ listSignature(after.supplyNodes.map(({ level, provinceId }) => ({ level, provinceId }))),
670
+ railwaysChanged: listSignature(before.railways.map(({ level, provinces }) => ({ level, provinces }))) !==
671
+ listSignature(after.railways.map(({ level, provinces }) => ({ level, provinces }))),
672
+ adjacenciesChanged: listSignature(before.adjacencies.map(({ from, to, type, through, rule }) => ({
673
+ from,
674
+ to,
675
+ type,
676
+ through,
677
+ rule,
678
+ }))) !==
679
+ listSignature(after.adjacencies.map(({ from, to, type, through, rule }) => ({
680
+ from,
681
+ to,
682
+ type,
683
+ through,
684
+ rule,
685
+ }))),
686
+ normalAdjacenciesChanged: normalAdjacencies.length > 0,
687
+ };
688
+ }
689
+ function uniqueNumbers(values) {
690
+ return [...new Set(values)].sort((left, right) => left - right);
691
+ }
692
+ export async function renderMapDiff(before, after, options = {}) {
693
+ const left = before.provinceBitmap;
694
+ const right = after.provinceBitmap;
695
+ if (left === undefined || right?.width !== left.width || left.height !== right.height) {
696
+ const budgetDiagnostic = [...before.diagnostics, ...after.diagnostics].find(({ code }) => code.startsWith('RENDER_'));
697
+ if (budgetDiagnostic !== undefined) {
698
+ throw new ServiceError(budgetDiagnostic.code, budgetDiagnostic.message, budgetDiagnostic.details ?? {});
699
+ }
700
+ throw new ServiceError('MAP_DIFF_BITMAP_MISMATCH', 'Map diff requires same-sized baseline and proposed province bitmaps');
701
+ }
702
+ const scale = options.scale ?? 1;
703
+ if (!Number.isInteger(scale) || scale < 1 || scale > 16)
704
+ throw new ServiceError('MAP_RENDER_SCALE_INVALID', 'Map render scale must be an integer from 1 through 16');
705
+ const budget = options.budget ?? new RenderBudget();
706
+ assertRenderDimensions(left.width, left.height, 'map diff RGBA source plane');
707
+ const outputDimensions = budget.reserve(left.width * scale, left.height * scale, 'map diff PNG output');
708
+ const raw = Buffer.alloc(left.width * left.height * 4);
709
+ const changedProvinceIds = new Set();
710
+ for (let y = 0; y < left.height; y += 1) {
711
+ if (y % 32 === 0)
712
+ await renderCheckpoint(options.signal);
713
+ for (let x = 0; x < left.width; x += 1) {
714
+ const beforeColor = left.rgbAt(x, y);
715
+ const afterColor = right.rgbAt(x, y);
716
+ const changed = beforeColor.r !== afterColor.r ||
717
+ beforeColor.g !== afterColor.g ||
718
+ beforeColor.b !== afterColor.b;
719
+ setPixel(raw, left.width, left.height, x, y, changed ? { r: 255, g: 54, b: 124 } : { r: 43, g: 48, b: 55 }, 255);
720
+ if (changed) {
721
+ const offset = y * left.width + x;
722
+ const beforeId = before.raster?.provinceIds[offset] ?? -1;
723
+ const afterId = after.raster?.provinceIds[offset] ?? -1;
724
+ if (beforeId >= 0)
725
+ changedProvinceIds.add(beforeId);
726
+ if (afterId >= 0)
727
+ changedProvinceIds.add(afterId);
728
+ }
729
+ }
730
+ }
731
+ options.signal?.throwIfAborted();
732
+ const png = await encodePng(raw, left.width, left.height, scale);
733
+ options.signal?.throwIfAborted();
734
+ const semantic = semanticMapDiff(before, after);
735
+ const changedBounds = left.diffBounds(right);
736
+ const metadata = {
737
+ offline: true,
738
+ renderer: 'hoi4-agent-tools-agent-nudger-diff',
739
+ changedBounds: changedBounds ?? null,
740
+ changedProvinceIds: [...changedProvinceIds].sort((a, b) => a - b),
741
+ semantic,
742
+ ...(options.review === undefined ? {} : { review: options.review }),
743
+ };
744
+ const json = `${canonicalJson(metadata)}\n`;
745
+ const html = htmlDocument('Agent Nudger pixel and semantic diff', png, json);
746
+ return {
747
+ width: outputDimensions.width,
748
+ height: outputDimensions.height,
749
+ png,
750
+ json,
751
+ html,
752
+ hashes: { png: sha256Bytes(png), json: sha256Bytes(json), html: sha256Bytes(html) },
753
+ ...(changedBounds === undefined ? {} : { changedBounds }),
754
+ changedProvinceIds: metadata.changedProvinceIds,
755
+ semantic,
756
+ ...(options.review === undefined ? {} : { review: options.review }),
757
+ };
758
+ }
759
+ //# sourceMappingURL=render.js.map