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,629 @@
1
+ import path from 'node:path';
2
+ import { create as createFont } from 'fontkit';
3
+ import sharp from 'sharp';
4
+ import { compareCodeUnits, hashCanonical } from '../core/canonical.js';
5
+ import { RenderBudget, RENDER_MAX_DECODED_PIXELS } from '../core/render-budget.js';
6
+ import { ServiceError } from '../core/result.js';
7
+ import { DETERMINISTIC_TOOL_FONT_HASH, shapeFontkitOutline } from '../core/svg-text.js';
8
+ import { decodeDds } from './dds.js';
9
+ import { GUI_BMFONT_MAX_CHARACTERS, GUI_BINARY_FONT_MAX_BYTES, GUI_BMFONT_MAX_BYTES, GUI_BMFONT_MAX_FIELDS_PER_RECORD, GUI_BMFONT_MAX_KERNING_PAIRS, GUI_BMFONT_MAX_PAGES, GUI_BMFONT_MAX_RECORDS, GUI_TEXT_MAX_CHARACTERS, GUI_TEXT_MAX_MISSING_GLYPH_SAMPLES, } from './limits.js';
10
+ import { decodeTga } from './tga.js';
11
+ function normalizeAssetPath(value) {
12
+ return value
13
+ .replaceAll('\\', '/')
14
+ .replace(/^\/+|^\.\//u, '')
15
+ .toLowerCase();
16
+ }
17
+ function parseFields(line) {
18
+ const result = {};
19
+ let fields = 0;
20
+ for (const match of line.matchAll(/([A-Za-z][A-Za-z0-9]*)=(?:"([^"]*)"|(-?\d+))/gu)) {
21
+ fields += 1;
22
+ if (fields > GUI_BMFONT_MAX_FIELDS_PER_RECORD) {
23
+ throw new ServiceError('GUI_FONT_FIELD_BUDGET_BLOCKED', 'BMFont record exceeds the fixed field ceiling', { fields, maximumFieldsPerRecord: GUI_BMFONT_MAX_FIELDS_PER_RECORD });
24
+ }
25
+ const key = match[1];
26
+ const quoted = match[2];
27
+ const numeric = match[3];
28
+ if (key !== undefined) {
29
+ const value = quoted ?? Number(numeric);
30
+ if (typeof value === 'number' && !Number.isSafeInteger(value)) {
31
+ throw new ServiceError('GUI_FONT_FIELD_INVALID', 'BMFont numeric fields must be safe integers', { field: key });
32
+ }
33
+ result[key] = value;
34
+ }
35
+ }
36
+ return result;
37
+ }
38
+ export function parseBmFont(text) {
39
+ if (Buffer.byteLength(text, 'utf8') > GUI_BMFONT_MAX_BYTES) {
40
+ throw new ServiceError('GUI_FONT_BYTES_BLOCKED', 'BMFont source exceeds the fixed 2 MiB admission ceiling', { maximumBytes: GUI_BMFONT_MAX_BYTES });
41
+ }
42
+ let size = 16;
43
+ let lineHeight = 16;
44
+ let base;
45
+ const pages = new Map();
46
+ const characters = new Map();
47
+ const kerning = new Map();
48
+ let recognised = false;
49
+ let cursor = 0;
50
+ let records = 0;
51
+ while (cursor <= text.length) {
52
+ records += 1;
53
+ if (records > GUI_BMFONT_MAX_RECORDS) {
54
+ throw new ServiceError('GUI_FONT_RECORD_BUDGET_BLOCKED', 'BMFont source exceeds the fixed record ceiling', { records, maximumRecords: GUI_BMFONT_MAX_RECORDS });
55
+ }
56
+ const next = text.indexOf('\n', cursor);
57
+ const rawLine = text.slice(cursor, next < 0 ? text.length : next).replace(/\r$/u, '');
58
+ const line = rawLine.trim();
59
+ if (line.startsWith('info ')) {
60
+ const fields = parseFields(line);
61
+ size = Math.abs(typeof fields.size === 'number' ? fields.size : size);
62
+ recognised = true;
63
+ }
64
+ else if (line.startsWith('common ')) {
65
+ const fields = parseFields(line);
66
+ lineHeight = typeof fields.lineHeight === 'number' ? fields.lineHeight : lineHeight;
67
+ base = typeof fields.base === 'number' ? fields.base : base;
68
+ recognised = true;
69
+ }
70
+ else if (line.startsWith('page ')) {
71
+ const fields = parseFields(line);
72
+ const id = typeof fields.id === 'number' ? fields.id : pages.size;
73
+ if (!Number.isSafeInteger(id) || id < 0 || id >= GUI_BMFONT_MAX_PAGES) {
74
+ throw new ServiceError('GUI_FONT_PAGE_BUDGET_BLOCKED', 'BMFont page id exceeds the fixed page-map ceiling', { pageId: id, maximumPages: GUI_BMFONT_MAX_PAGES });
75
+ }
76
+ if (typeof fields.file === 'string') {
77
+ if (!pages.has(id) && pages.size >= GUI_BMFONT_MAX_PAGES) {
78
+ throw new ServiceError('GUI_FONT_PAGE_BUDGET_BLOCKED', 'BMFont source exceeds the fixed page-map ceiling', { pages: pages.size + 1, maximumPages: GUI_BMFONT_MAX_PAGES });
79
+ }
80
+ pages.set(id, fields.file);
81
+ }
82
+ recognised = true;
83
+ }
84
+ else if (line.startsWith('char ')) {
85
+ const fields = parseFields(line);
86
+ const id = fields.id;
87
+ if (typeof id === 'number' && Number.isSafeInteger(id) && id >= 0 && id <= 0x10ffff) {
88
+ if (!characters.has(id) && characters.size >= GUI_BMFONT_MAX_CHARACTERS) {
89
+ throw new ServiceError('GUI_FONT_CHARACTER_BUDGET_BLOCKED', 'BMFont source exceeds the fixed character-map ceiling', {
90
+ characters: characters.size + 1,
91
+ maximumCharacters: GUI_BMFONT_MAX_CHARACTERS,
92
+ });
93
+ }
94
+ characters.set(id, {
95
+ id,
96
+ x: typeof fields.x === 'number' ? fields.x : 0,
97
+ y: typeof fields.y === 'number' ? fields.y : 0,
98
+ width: typeof fields.width === 'number' ? fields.width : 0,
99
+ height: typeof fields.height === 'number' ? fields.height : 0,
100
+ xOffset: typeof fields.xoffset === 'number' ? fields.xoffset : 0,
101
+ yOffset: typeof fields.yoffset === 'number' ? fields.yoffset : 0,
102
+ xAdvance: typeof fields.xadvance === 'number'
103
+ ? fields.xadvance
104
+ : typeof fields.width === 'number'
105
+ ? fields.width
106
+ : 0,
107
+ page: typeof fields.page === 'number' ? fields.page : 0,
108
+ });
109
+ }
110
+ recognised = true;
111
+ }
112
+ else if (line.startsWith('kerning ')) {
113
+ const fields = parseFields(line);
114
+ if (typeof fields.first === 'number' && typeof fields.second === 'number') {
115
+ const key = `${fields.first}:${fields.second}`;
116
+ if (!kerning.has(key) && kerning.size >= GUI_BMFONT_MAX_KERNING_PAIRS) {
117
+ throw new ServiceError('GUI_FONT_KERNING_BUDGET_BLOCKED', 'BMFont source exceeds the fixed kerning-map ceiling', {
118
+ kerningPairs: kerning.size + 1,
119
+ maximumKerningPairs: GUI_BMFONT_MAX_KERNING_PAIRS,
120
+ });
121
+ }
122
+ kerning.set(key, typeof fields.amount === 'number' ? fields.amount : 0);
123
+ }
124
+ recognised = true;
125
+ }
126
+ if (next < 0)
127
+ break;
128
+ cursor = next + 1;
129
+ }
130
+ return recognised
131
+ ? {
132
+ size: Math.max(1, size),
133
+ lineHeight: Math.max(1, lineHeight),
134
+ base: Math.max(0, base ?? Math.min(size, lineHeight)),
135
+ baseDeclared: base !== undefined,
136
+ pages: [...pages.entries()].sort(([left], [right]) => left - right).map(([, page]) => page),
137
+ characters,
138
+ kerning,
139
+ }
140
+ : undefined;
141
+ }
142
+ function selectFont(value) {
143
+ return 'fonts' in value ? value.fonts[0] : value;
144
+ }
145
+ export class GuiAssetCatalog {
146
+ graph;
147
+ budget;
148
+ files = new Map();
149
+ basenames = new Map();
150
+ rasters = new Map();
151
+ frames = new Map();
152
+ glyphRasters = new Map();
153
+ metrics = new Map();
154
+ fontDefinitions = new Map();
155
+ constructor(graph, scannedFiles, budget = new RenderBudget()) {
156
+ this.graph = graph;
157
+ this.budget = budget;
158
+ for (const file of scannedFiles
159
+ .filter((candidate) => candidate.shadowedBy === undefined)
160
+ .sort((left, right) => compareCodeUnits(left.relativePath, right.relativePath))) {
161
+ const normalized = normalizeAssetPath(file.relativePath);
162
+ this.files.set(normalized, file);
163
+ const basename = path.posix.basename(normalized);
164
+ const candidates = this.basenames.get(basename) ?? [];
165
+ candidates.push(file);
166
+ this.basenames.set(basename, candidates);
167
+ }
168
+ for (const definition of graph.fonts)
169
+ this.fontDefinitions.set(definition.name.toLowerCase(), definition);
170
+ }
171
+ resolveFile(assetPath, relativeTo) {
172
+ const normalized = normalizeAssetPath(assetPath);
173
+ const normalizedCandidates = path.posix.extname(normalized).length === 0
174
+ ? [normalized, `${normalized}.fnt`, `${normalized}.ttf`, `${normalized}.otf`]
175
+ : [normalized];
176
+ for (const candidatePath of normalizedCandidates) {
177
+ const direct = this.files.get(candidatePath);
178
+ if (direct !== undefined)
179
+ return direct;
180
+ }
181
+ if (relativeTo !== undefined) {
182
+ for (const candidatePath of normalizedCandidates) {
183
+ const relative = normalizeAssetPath(path.posix.join(path.posix.dirname(normalizeAssetPath(relativeTo)), candidatePath));
184
+ const candidate = this.files.get(relative);
185
+ if (candidate !== undefined)
186
+ return candidate;
187
+ }
188
+ }
189
+ for (const candidatePath of normalizedCandidates) {
190
+ const candidates = this.basenames.get(path.posix.basename(candidatePath));
191
+ if (candidates?.length === 1)
192
+ return candidates[0];
193
+ }
194
+ return undefined;
195
+ }
196
+ async loadRaster(assetPath, relativeTo) {
197
+ const file = this.resolveFile(assetPath, relativeTo);
198
+ if (file === undefined)
199
+ return {
200
+ width: 0,
201
+ height: 0,
202
+ data: Buffer.alloc(0),
203
+ format: path.extname(assetPath).slice(1).toLowerCase() || 'unknown',
204
+ supported: false,
205
+ reason: `Texture not found: ${assetPath}`,
206
+ };
207
+ const key = `${file.displayPath}:${file.sha256}`;
208
+ let promise = this.rasters.get(key);
209
+ if (promise === undefined) {
210
+ this.budget.reserveRasterOperation(`gui-raster:${key}`, `GUI asset decode ${file.displayPath}`);
211
+ promise = this.decodeRaster(file);
212
+ this.rasters.set(key, promise);
213
+ }
214
+ return promise;
215
+ }
216
+ loadSpriteFrame(sprite, requestedFrame) {
217
+ const texturePath = sprite.texturePath;
218
+ if (texturePath === undefined)
219
+ return Promise.resolve(undefined);
220
+ const frameCount = Math.max(1, sprite.frameCount);
221
+ const frame = Math.max(0, Math.min(frameCount - 1, Math.trunc(requestedFrame)));
222
+ const key = `${sprite.id}:${texturePath}:${frameCount}:${frame}`;
223
+ let promise = this.frames.get(key);
224
+ if (promise === undefined) {
225
+ promise = this.decodeSpriteFrame(sprite, texturePath, frameCount, frame, key);
226
+ this.frames.set(key, promise);
227
+ }
228
+ return promise;
229
+ }
230
+ async decodeSpriteFrame(sprite, texturePath, frameCount, frame, operationKey) {
231
+ const raster = await this.loadRaster(texturePath, sprite.sourcePath);
232
+ if (!raster.supported || raster.width === 0 || raster.height === 0) {
233
+ return {
234
+ spriteName: sprite.name,
235
+ texturePath,
236
+ frame,
237
+ frameCount,
238
+ width: raster.width,
239
+ height: raster.height,
240
+ format: raster.format,
241
+ supported: false,
242
+ ...(raster.reason === undefined ? {} : { reason: raster.reason }),
243
+ };
244
+ }
245
+ if (raster.width % frameCount !== 0) {
246
+ return {
247
+ spriteName: sprite.name,
248
+ texturePath,
249
+ frame,
250
+ frameCount,
251
+ width: raster.width,
252
+ height: raster.height,
253
+ format: raster.format,
254
+ supported: false,
255
+ reason: `Horizontal frame strip width ${raster.width} is not divisible by noOfFrames ${frameCount}.`,
256
+ };
257
+ }
258
+ const frameWidth = raster.width / frameCount;
259
+ this.budget.reserveRasterOperation(`gui-sprite-frame:${operationKey}`, `GUI sprite frame rasterization ${sprite.name}`);
260
+ this.budget.reserve(raster.width, raster.height, `GUI texture Sharp plane ${texturePath}`, {
261
+ maximumPixels: RENDER_MAX_DECODED_PIXELS,
262
+ });
263
+ this.budget.reserve(frameWidth, raster.height, `GUI sprite frame ${sprite.name}`, {
264
+ maximumPixels: RENDER_MAX_DECODED_PIXELS,
265
+ });
266
+ const png = await sharp(raster.data, {
267
+ raw: { width: raster.width, height: raster.height, channels: 4 },
268
+ limitInputPixels: RENDER_MAX_DECODED_PIXELS,
269
+ })
270
+ .extract({ left: frame * frameWidth, top: 0, width: frameWidth, height: raster.height })
271
+ .png({ compressionLevel: 9, adaptiveFiltering: false, palette: false })
272
+ .toBuffer();
273
+ return {
274
+ spriteName: sprite.name,
275
+ texturePath,
276
+ frame,
277
+ frameCount,
278
+ width: frameWidth,
279
+ height: raster.height,
280
+ dataUri: `data:image/png;base64,${png.toString('base64')}`,
281
+ format: raster.format,
282
+ supported: true,
283
+ };
284
+ }
285
+ measureText(fontName, text, fontSize) {
286
+ if (text.length > GUI_TEXT_MAX_CHARACTERS) {
287
+ throw new ServiceError('GUI_TEXT_BUDGET_BLOCKED', 'GUI text measurement exceeds the fixed character ceiling', { characters: text.length, maximumCharacters: GUI_TEXT_MAX_CHARACTERS });
288
+ }
289
+ const safeSize = Math.max(1, fontSize);
290
+ const entry = fontName === undefined ? undefined : this.loadFontMetrics(fontName);
291
+ if (entry?.kind === 'fontkit' && entry.font !== undefined) {
292
+ const run = entry.font.layout(text);
293
+ const missingGlyphs = this.missingFontkitCodePoints(entry.font, text);
294
+ const scale = safeSize / entry.font.unitsPerEm;
295
+ return {
296
+ width: run.advanceWidth * scale,
297
+ lineHeight: (entry.font.ascent - entry.font.descent + entry.font.lineGap) * scale,
298
+ source: 'fontkit',
299
+ missingGlyphs,
300
+ };
301
+ }
302
+ if (entry?.kind === 'bmfont' && entry.bmfont !== undefined) {
303
+ const scale = safeSize / entry.bmfont.size;
304
+ let width = 0;
305
+ let previous;
306
+ const missingGlyphs = [];
307
+ for (const character of text) {
308
+ const codePoint = character.codePointAt(0) ?? 0;
309
+ const metric = entry.bmfont.characters.get(codePoint);
310
+ if (metric === undefined) {
311
+ if (missingGlyphs.length < GUI_TEXT_MAX_MISSING_GLYPH_SAMPLES &&
312
+ !missingGlyphs.includes(codePoint))
313
+ missingGlyphs.push(codePoint);
314
+ width += safeSize * 0.6;
315
+ }
316
+ else {
317
+ if (previous !== undefined)
318
+ width += (entry.bmfont.kerning.get(`${previous}:${codePoint}`) ?? 0) * scale;
319
+ width += metric.xAdvance * scale;
320
+ }
321
+ previous = codePoint;
322
+ }
323
+ return {
324
+ width,
325
+ lineHeight: entry.bmfont.lineHeight * scale,
326
+ source: 'bmfont',
327
+ missingGlyphs,
328
+ };
329
+ }
330
+ const graphemes = Array.from(new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment(text)).length;
331
+ return {
332
+ width: graphemes * safeSize * 0.58,
333
+ lineHeight: safeSize * 1.2,
334
+ source: 'approximation',
335
+ missingGlyphs: [],
336
+ };
337
+ }
338
+ async shapeText(fontName, text, fontSize) {
339
+ const entry = fontName === undefined ? undefined : this.loadFontMetrics(fontName);
340
+ if (entry?.kind === 'fontkit' && entry.font !== undefined) {
341
+ const shaped = shapeFontkitOutline(entry.font, entry.sourceFile.sha256, text, fontSize);
342
+ return {
343
+ source: 'fontkit-path',
344
+ sourceHash: entry.sourceFile.sha256,
345
+ width: shaped.width,
346
+ baseline: entry.font.ascent * (Math.max(1, fontSize) / entry.font.unitsPerEm),
347
+ baselineModelled: true,
348
+ glyphs: shaped.glyphs.map(({ key, path: glyphPath, x, y, scale }) => ({
349
+ kind: 'outline',
350
+ key,
351
+ path: glyphPath,
352
+ x,
353
+ y,
354
+ scale,
355
+ })),
356
+ missingGlyphs: this.missingFontkitCodePoints(entry.font, text),
357
+ };
358
+ }
359
+ if (entry?.kind === 'bmfont' && entry.bmfont !== undefined) {
360
+ const scale = Math.max(1, fontSize) / entry.bmfont.size;
361
+ const glyphs = [];
362
+ const missingGlyphs = [];
363
+ const pageHashes = new Set();
364
+ let visibleCharacters = 0;
365
+ let penX = 0;
366
+ let previous;
367
+ for (const character of text) {
368
+ if (!/^\s$/u.test(character))
369
+ visibleCharacters += 1;
370
+ const codePoint = character.codePointAt(0) ?? 0;
371
+ const metric = entry.bmfont.characters.get(codePoint);
372
+ if (metric === undefined) {
373
+ if (missingGlyphs.length < GUI_TEXT_MAX_MISSING_GLYPH_SAMPLES &&
374
+ !missingGlyphs.includes(codePoint))
375
+ missingGlyphs.push(codePoint);
376
+ penX += Math.max(1, fontSize) * 0.6;
377
+ previous = codePoint;
378
+ continue;
379
+ }
380
+ if (previous !== undefined)
381
+ penX += (entry.bmfont.kerning.get(`${previous}:${codePoint}`) ?? 0) * scale;
382
+ const pagePath = entry.bmfont.pages[metric.page];
383
+ const raster = pagePath === undefined
384
+ ? undefined
385
+ : await this.loadBmFontGlyph(entry, pagePath, metric, codePoint);
386
+ if (raster !== undefined && pagePath !== undefined) {
387
+ const page = this.resolveFile(pagePath, entry.sourceFile.relativePath);
388
+ if (page !== undefined)
389
+ pageHashes.add(page.sha256);
390
+ glyphs.push({
391
+ kind: 'bitmap',
392
+ key: `${entry.sourceFile.sha256}:${codePoint}:${Math.max(1, fontSize)}`,
393
+ dataUri: raster.dataUri,
394
+ x: penX + metric.xOffset * scale,
395
+ y: metric.yOffset * scale,
396
+ width: raster.width * scale,
397
+ height: raster.height * scale,
398
+ });
399
+ }
400
+ else if (metric.width > 0 &&
401
+ metric.height > 0 &&
402
+ missingGlyphs.length < GUI_TEXT_MAX_MISSING_GLYPH_SAMPLES &&
403
+ !missingGlyphs.includes(codePoint)) {
404
+ missingGlyphs.push(codePoint);
405
+ }
406
+ penX += metric.xAdvance * scale;
407
+ previous = codePoint;
408
+ }
409
+ return {
410
+ source: visibleCharacters > 0 && glyphs.length === 0 ? 'deterministic-fallback' : 'bmfont-atlas',
411
+ sourceHash: hashCanonical([entry.sourceFile.sha256, ...[...pageHashes].sort()]),
412
+ width: penX,
413
+ baseline: entry.bmfont.base * scale,
414
+ baselineModelled: entry.bmfont.baseDeclared,
415
+ glyphs,
416
+ missingGlyphs,
417
+ };
418
+ }
419
+ return {
420
+ source: 'deterministic-fallback',
421
+ sourceHash: DETERMINISTIC_TOOL_FONT_HASH,
422
+ width: this.measureText(undefined, text, fontSize).width,
423
+ baseline: Math.max(1, fontSize) * 0.8,
424
+ baselineModelled: false,
425
+ glyphs: [],
426
+ missingGlyphs: [],
427
+ };
428
+ }
429
+ fontDefinition(fontName) {
430
+ return this.fontDefinitions.get(fontName.toLowerCase());
431
+ }
432
+ resolvedFontMetrics(fontName) {
433
+ const entry = fontName === undefined ? undefined : this.loadFontMetrics(fontName);
434
+ if (entry?.kind === 'bmfont' && entry.bmfont !== undefined)
435
+ return {
436
+ source: 'bmfont',
437
+ nativeSize: entry.bmfont.size,
438
+ nativeLineHeight: entry.bmfont.lineHeight,
439
+ nativeBaseline: entry.bmfont.base,
440
+ baselineModelled: entry.bmfont.baseDeclared,
441
+ };
442
+ if (entry?.kind === 'fontkit' && entry.font !== undefined)
443
+ return { source: 'fontkit', baselineModelled: true };
444
+ return { source: 'approximation', baselineModelled: false };
445
+ }
446
+ missingFontkitCodePoints(font, text) {
447
+ const missingGlyphs = [];
448
+ for (const character of text) {
449
+ const codePoint = character.codePointAt(0) ?? 0;
450
+ if (font.glyphForCodePoint(codePoint).id === 0 &&
451
+ missingGlyphs.length < GUI_TEXT_MAX_MISSING_GLYPH_SAMPLES &&
452
+ !missingGlyphs.includes(codePoint))
453
+ missingGlyphs.push(codePoint);
454
+ }
455
+ return missingGlyphs;
456
+ }
457
+ loadFontMetrics(fontName) {
458
+ const key = fontName.toLowerCase();
459
+ if (this.metrics.has(key))
460
+ return this.metrics.get(key) ?? undefined;
461
+ const definition = this.fontDefinitions.get(key);
462
+ if (definition === undefined) {
463
+ this.metrics.set(key, null);
464
+ return undefined;
465
+ }
466
+ for (const assetPath of definition.assetPaths) {
467
+ const file = this.resolveFile(assetPath, definition.sourcePath);
468
+ if (file === undefined)
469
+ continue;
470
+ const extension = path.extname(file.relativePath).toLowerCase();
471
+ try {
472
+ if (extension === '.fnt') {
473
+ if (file.bytes.length > GUI_BMFONT_MAX_BYTES) {
474
+ throw new ServiceError('GUI_FONT_BYTES_BLOCKED', `BMFont ${file.displayPath} exceeds the fixed source-byte ceiling`, { bytes: file.bytes.length, maximumBytes: GUI_BMFONT_MAX_BYTES });
475
+ }
476
+ const bmfont = parseBmFont(file.bytes.toString('utf8'));
477
+ if (bmfont !== undefined) {
478
+ const result = { kind: 'bmfont', bmfont, sourceFile: file };
479
+ this.metrics.set(key, result);
480
+ return result;
481
+ }
482
+ }
483
+ else if (['.ttf', '.otf', '.woff', '.woff2'].includes(extension)) {
484
+ if (file.bytes.length > GUI_BINARY_FONT_MAX_BYTES) {
485
+ throw new ServiceError('GUI_FONT_BYTES_BLOCKED', `Font ${file.displayPath} exceeds the fixed binary-font byte ceiling`, { bytes: file.bytes.length, maximumBytes: GUI_BINARY_FONT_MAX_BYTES });
486
+ }
487
+ const font = selectFont(createFont(file.bytes));
488
+ if (font !== undefined) {
489
+ const result = { kind: 'fontkit', font, sourceFile: file };
490
+ this.metrics.set(key, result);
491
+ return result;
492
+ }
493
+ }
494
+ }
495
+ catch (error) {
496
+ if (error instanceof ServiceError)
497
+ throw error;
498
+ // Invalid font assets are surfaced as missing metrics by the renderer fidelity report.
499
+ }
500
+ }
501
+ this.metrics.set(key, null);
502
+ return undefined;
503
+ }
504
+ loadBmFontGlyph(entry, pagePath, metric, codePoint) {
505
+ if (metric.width <= 0 || metric.height <= 0)
506
+ return Promise.resolve(undefined);
507
+ const key = `${entry.sourceFile.sha256}:${pagePath}:${codePoint}:${metric.x}:${metric.y}:${metric.width}:${metric.height}`;
508
+ let promise = this.glyphRasters.get(key);
509
+ if (promise === undefined) {
510
+ promise = (async () => {
511
+ const raster = await this.loadRaster(pagePath, entry.sourceFile.relativePath);
512
+ if (!raster.supported ||
513
+ metric.x < 0 ||
514
+ metric.y < 0 ||
515
+ metric.width <= 0 ||
516
+ metric.height <= 0 ||
517
+ metric.x + metric.width > raster.width ||
518
+ metric.y + metric.height > raster.height)
519
+ return undefined;
520
+ this.budget.reserveRasterOperation(`gui-bmfont-glyph:${key}`, `GUI BMFont glyph rasterization U+${codePoint.toString(16).toUpperCase()}`);
521
+ this.budget.reserve(metric.width, metric.height, `GUI BMFont glyph U+${codePoint.toString(16).toUpperCase()}`, { maximumPixels: RENDER_MAX_DECODED_PIXELS });
522
+ const png = await sharp(raster.data, {
523
+ raw: { width: raster.width, height: raster.height, channels: 4 },
524
+ limitInputPixels: RENDER_MAX_DECODED_PIXELS,
525
+ })
526
+ .extract({ left: metric.x, top: metric.y, width: metric.width, height: metric.height })
527
+ .png({ compressionLevel: 9, adaptiveFiltering: false, palette: false })
528
+ .toBuffer();
529
+ return {
530
+ dataUri: `data:image/png;base64,${png.toString('base64')}`,
531
+ width: metric.width,
532
+ height: metric.height,
533
+ };
534
+ })();
535
+ this.glyphRasters.set(key, promise);
536
+ }
537
+ return promise;
538
+ }
539
+ async decodeRaster(file) {
540
+ const extension = path.extname(file.relativePath).toLowerCase();
541
+ const operationKey = `gui-raster:${file.displayPath}:${file.sha256}`;
542
+ if (extension === '.dds') {
543
+ const decoded = decodeDds(file.bytes, this.budget, operationKey);
544
+ return 'unsupported' in decoded
545
+ ? {
546
+ width: 0,
547
+ height: 0,
548
+ data: Buffer.alloc(0),
549
+ format: decoded.format,
550
+ supported: false,
551
+ reason: decoded.reason,
552
+ }
553
+ : {
554
+ width: decoded.width,
555
+ height: decoded.height,
556
+ data: decoded.data,
557
+ format: decoded.format,
558
+ supported: true,
559
+ };
560
+ }
561
+ if (extension === '.tga') {
562
+ const decoded = decodeTga(file.bytes, this.budget, operationKey);
563
+ return 'unsupported' in decoded
564
+ ? {
565
+ width: 0,
566
+ height: 0,
567
+ data: Buffer.alloc(0),
568
+ format: decoded.format,
569
+ supported: false,
570
+ reason: decoded.reason,
571
+ }
572
+ : {
573
+ width: decoded.width,
574
+ height: decoded.height,
575
+ data: decoded.data,
576
+ format: decoded.format,
577
+ supported: true,
578
+ };
579
+ }
580
+ if (extension === '.svg') {
581
+ throw new ServiceError('RENDER_ASSET_SVG_BLOCKED', 'Workspace SVG raster inputs are not accepted; use a bounded PNG source asset', { path: file.displayPath });
582
+ }
583
+ if (extension !== '.png' && extension !== '.bmp') {
584
+ return {
585
+ width: 0,
586
+ height: 0,
587
+ data: Buffer.alloc(0),
588
+ format: extension.slice(1) || 'unknown',
589
+ supported: false,
590
+ reason: `Raster format ${extension || '<none>'} is unsupported.`,
591
+ };
592
+ }
593
+ try {
594
+ const metadata = await sharp(file.bytes, {
595
+ limitInputPixels: RENDER_MAX_DECODED_PIXELS,
596
+ }).metadata();
597
+ this.budget.reserve(metadata.width, metadata.height, `GUI asset ${file.displayPath}`, {
598
+ maximumPixels: RENDER_MAX_DECODED_PIXELS,
599
+ });
600
+ const decoded = await sharp(file.bytes, { limitInputPixels: RENDER_MAX_DECODED_PIXELS })
601
+ .ensureAlpha()
602
+ .raw()
603
+ .toBuffer({ resolveWithObject: true });
604
+ return {
605
+ width: decoded.info.width,
606
+ height: decoded.info.height,
607
+ data: decoded.data,
608
+ format: extension.slice(1),
609
+ supported: true,
610
+ };
611
+ }
612
+ catch (error) {
613
+ if (error instanceof ServiceError)
614
+ throw error;
615
+ if (error instanceof Error && /pixel limit/iu.test(error.message)) {
616
+ throw new ServiceError('RENDER_PIXELS_BLOCKED', `GUI asset ${file.displayPath} exceeds the fixed per-artifact pixel ceiling`, { label: `GUI asset ${file.displayPath}`, maximumPixels: RENDER_MAX_DECODED_PIXELS });
617
+ }
618
+ return {
619
+ width: 0,
620
+ height: 0,
621
+ data: Buffer.alloc(0),
622
+ format: extension.slice(1),
623
+ supported: false,
624
+ reason: error instanceof Error ? error.message : String(error),
625
+ };
626
+ }
627
+ }
628
+ }
629
+ //# sourceMappingURL=assets.js.map